7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
42 define skinMenuHeight = 25;
43 define statusBarHeight = 18;
45 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
47 public enum DialogResult { cancel, yes, no, ok };
49 public class MouseButtons
52 bool left:1, right:1, middle:1;
55 public struct SizeAnchor
58 bool isClientW, isClientH;
63 #define SNAPDOWN(x, d) \
66 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
69 #define SNAPUP(x, d) \
72 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
75 /*static */define MAX_DIRTY_BACK = 10;
77 /////////////////////////////////////////////////////////////////////////////
78 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
79 /////////////////////////////////////////////////////////////////////////////
81 #define ACCESS_ITEM(l, id) \
84 #define FASTLIST_LOOP(l, v) \
85 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
87 #define FASTLIST_LOOPN(l, v, n) \
88 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
91 #define ACCESS_ITEM(l, id) \
92 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
94 #define FASTLIST_LOOP(l, v) \
95 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
97 #define FASTLIST_LOOPN(l, v, n) \
98 for( v = (void *)ACCESS_ITEM((l), (l).first), \
99 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
100 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
103 private class FastItem : struct
108 private struct FastList
113 int count, size, itemSize;
120 first = last = free = -1;
128 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
131 FastItem Add(uint itemSize)
134 if(free == -1 || !size)
141 newSize = (size + (size >> 1));
142 items = (FastItem)renew items byte[newSize * itemSize];
147 this.itemSize = itemSize;
148 items = (FastItem)new byte[newSize * itemSize];
151 for(c = size; c<newSize-1; c++)
153 ACCESS_ITEM(this, c).prev = -1;
154 ACCESS_ITEM(this, c).next = c+1;
156 ACCESS_ITEM(this, c).prev = -1;
157 ACCESS_ITEM(this, c).next = -1;
161 item = ACCESS_ITEM(this, free);
164 ACCESS_ITEM(this, item.prev).next = free;
174 void Delete(FastItem item)
177 ACCESS_ITEM(this, item.prev).next = item.next;
179 ACCESS_ITEM(this, item.next).prev = item.prev;
181 if(ACCESS_ITEM(this, first) == item)
183 if(ACCESS_ITEM(this, last) == item)
188 free = ((byte *)item - (byte *)items) / itemSize;
196 free = first = last = -1;
200 private class BoxItem : Item //FastItem
205 public /*private */struct Extent : OldList //FastList
214 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
215 Add(BoxItem { box = box });
218 void Copy(Extent source)
224 //FASTLIST_LOOP(source, extentBox)
225 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
226 AddBox(extentBox.box);
229 void IntersectBox(Box box)
231 // Clip all boxes of extent against inside of the new box
232 BoxItem extentBox, next;
234 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
235 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
237 next = (BoxItem)extentBox.next;
238 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
239 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
240 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
241 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
242 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
247 void ExcludeBox(Box box, Extent temp)
254 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
256 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
257 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
260 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
264 extentBox.box.left, extentBox.box.top,
265 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
271 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
275 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
276 extentBox.box.right, extentBox.box.bottom
282 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
285 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
289 extentBox.box.left, Max(extentBox.box.top, box.top),
290 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
296 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
300 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
301 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
309 AddBox(extentBox.box);
315 void UnionBox(Box box, Extent temp)
317 BoxItem extentBox, next;
319 // First pass: check if this box is not already covered by one of the extent's box
320 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
322 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
323 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
330 // Second pass: only keep boxes not completely covered in the new box
331 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
333 next = (BoxItem)extentBox.next;
334 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
335 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
339 // Add the exclusion to the extent
340 ExcludeBox(box, temp);
343 if(box.bottom >= box.top && box.right >= box.left)
345 // Optimization: if the resulting boxes touch, add them smarter
346 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
348 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
350 if(Abs(box.right - extentBox.box.left) <= 1)
352 extentBox.box.left = box.left;
355 else if(Abs(box.left - extentBox.box.right) <= 1)
357 extentBox.box.right = box.right;
361 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
363 if(Abs(box.bottom - extentBox.box.top) <= 1)
365 extentBox.box.top = box.top;
368 else if(Abs(box.top - extentBox.box.bottom) <= 1)
370 extentBox.box.bottom = box.bottom;
382 void Union(Extent b, Extent temp)
386 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
387 UnionBox(extentBox.box, temp);
390 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
397 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
400 temp2.IntersectBox(extentBox.box);
407 void Exclusion(Extent b, Extent temp)
410 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
411 ExcludeBox(extentBox.box, temp);
414 void Offset(int x, int y)
417 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
419 extentBox.box.left += x;
420 extentBox.box.top += y;
421 extentBox.box.right += x;
422 extentBox.box.bottom += y;
427 private define MINIMIZED_WIDTH = 160;
428 private define CASCADE_SPACE = 16;
430 // namespace Windows;
432 private class ScrollFlags
434 bool snapX:1, snapY:1, dontHide:1;
437 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
439 class WindowBits : BorderBits
441 BorderBits borderBits:6:0;
442 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
443 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
444 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
447 public enum BorderStyle : BorderBits
450 contour = BorderBits { contour = true },
451 fixed = BorderBits { fixed = true } | contour,
452 sizable = BorderBits { sizable = true } | fixed,
453 thin = BorderBits { fixed = true, thin = true } | contour,
454 sizableThin = BorderBits { sizable = true } | thin,
455 deep = BorderBits { deep = true },
456 bevel = BorderBits { bevel = true },
457 sizableDeep = sizable|deep,
458 sizableBevel = sizable|bevel,
459 fixedDeep = fixed|deep,
460 fixedBevel = fixed|bevel,
461 deepContour = deep|contour
464 public enum CreationActivationOption
466 activate, flash, doNothing
469 public enum WindowState { normal, minimized, maximized };
471 private class ResPtr : struct
478 private class HotKeySlot : struct
480 HotKeySlot prev, next;
488 class_data char * icon;
490 class_default_property caption;
491 // class_initialize GuiApplication::Initialize;
492 class_designer FormDesigner;
493 class_property char * icon
495 set { class_data(icon) = value; }
496 get { return class_data(icon); }
501 if(guiApp) guiApp.Initialize(true);
503 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
505 if(_vTbl == ((subclass(Window))_class).pureVTbl)
507 _vTbl = _class._vTbl;
509 else if(_vTbl != _class._vTbl)
512 for(m = 0; m < _class.vTblSize; m++)
514 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
515 _vTbl[m] = _class._vTbl[m];
520 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
521 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
522 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
523 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
527 // caption = CopyString(class.name);
529 children.offset = (byte*)&prev - (byte*)this;
530 childrenOrder.circ = true;
531 childrenCycle.circ = true;
533 maxSize = Size { MAXINT, MAXINT };
537 //style.isActiveClient = true;
540 modifyVirtArea = true;
541 manageDisplay = true;
542 nativeDecorations = true;
544 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
545 sbStep.x = sbStep.y = 8;
547 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
549 cursor = guiApp.GetCursor(arrow);
550 property::parent = guiApp.desktop;
562 stopwatching(parent, font);
563 if(parent.activeChild == this)
564 parent.activeChild = null;
565 if(parent.activeClient == this)
566 parent.activeClient = null;
571 // Prevent destructor from being called again...
577 /////////////////////////////////
580 OldLink slave = master.slaves.FindLink(this);
581 master.slaves.Delete(slave);
588 parent.childrenCycle.Remove(cycle);
590 parent.childrenOrder.Remove(order);
591 parent.children.Remove(this);
596 /////////////////////////////////
598 while(ptr = resources.first)
601 resources.Delete(ptr);
608 for(child = children.first; child; child = child.next)
610 // child.stopwatching(this, font);
612 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
613 // Don't want property here
614 *&child.parent = null;
617 while(slave = slaves.first)
619 // Don't want property here
620 *&((Window)slave.data).master = null;
621 slaves.Delete(slave);
624 // Because we do a decref in DestroyEx...
632 // Why was this commented?
633 //if(this != guiApp.desktop)
646 if(((subclass(Window))_class).pureVTbl)
648 if(_vTbl == _class._vTbl)
650 _vTbl = ((subclass(Window))_class).pureVTbl;
655 for(m = 0; m < _class.vTblSize; m++)
657 if(_vTbl[m] == _class._vTbl[m])
658 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
662 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
665 dirtyArea.Free(null);
666 renderArea.Free(null);
667 overRenderArea.Free(null);
668 clipExtent.Free(null);
669 scrollExtent.Free(null);
670 dirtyBack.Free(null);
674 tempExtents[0].Free(null);
675 tempExtents[1].Free(null);
676 tempExtents[2].Free(null);
677 tempExtents[3].Free(null);
682 //#if !defined(ECERE_VANILLA)
683 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
685 if(this == activeDesigner)
689 char * name = property::name;
690 return name ? name : "";
695 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
696 bool OnGetDataFromString(char * string)
698 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
701 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
702 this = designer.form;
703 else if(!strcmpi(string, "(Desktop)"))
704 this = activeDesigner;
706 return activeDesigner.FindObject(&this, string);
712 // --- Window updates system ---
714 // Setup a bitmap for Redrawing on client area of Window
715 Surface Redraw(Box box)
717 Surface surface = null;
719 Box clientArea = this.clientArea;
723 mox.left -= clientStart.x;
724 mox.top -= clientStart.y;
725 mox.right -= clientStart.x;
726 mox.bottom -= clientStart.y;
728 mox.Clip(clientArea);
729 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
731 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
733 int x = absPosition.x + clientStart.x;
734 int y = absPosition.y + clientStart.y;
735 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
737 x -= rootWindow.clientStart.x;
738 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
740 if(!guiApp.fullScreenMode || is3D)
742 x -= rootWindow.absPosition.x;
743 y -= rootWindow.absPosition.y;
747 x += rootWindow.parent.clientStart.x;
748 y += rootWindow.parent.clientStart.y;
750 mox.left += rootWindow.parent.clientStart.x;
751 mox.top += rootWindow.parent.clientStart.y;
752 mox.right += rootWindow.parent.clientStart.x;
753 mox.bottom += rootWindow.parent.clientStart.y;
758 surface = display.GetSurface(x, y, mox);
761 surface.width = clientSize.w;
762 surface.height = clientSize.h;
768 // Setup a bitmap for Redrawing on full Window
769 Surface RedrawFull(Box box)
771 Surface surface = null;
779 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
781 int x = absPosition.x;
782 int y = absPosition.y;
783 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
785 x -= rootWindow.clientStart.x;
786 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
788 if(!guiApp.fullScreenMode || is3D)
790 x -= rootWindow.absPosition.x;
791 y -= rootWindow.absPosition.y;
794 x += rootWindow.parent.clientStart.x;
795 y += rootWindow.parent.clientStart.y;
797 mox.left += rootWindow.parent.clientStart.x;
798 mox.top += rootWindow.parent.clientStart.y;
799 mox.right += rootWindow.parent.clientStart.x;
800 mox.bottom += rootWindow.parent.clientStart.y;
805 surface = display.GetSurface(x, y, mox);
808 surface.width = size.w;
809 surface.height = size.h;
815 void FigureCaption(char * caption)
817 Window activeClient = null;
821 strcpy(caption, this.caption);
822 if(style.isDocument || fileName)
824 if(caption[0]) strcat(caption, " - ");
826 strcat(caption, fileName);
830 sprintf(title, "Untitled %d", documentID);
831 strcat(caption, title);
834 strcat(caption, " *");
839 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
841 if(activeClient && activeClient.state == maximized)
843 if(activeClient.caption)
845 if(caption[0]) strcat(caption, " - ");
846 strcat(caption, activeClient.caption);
848 if(activeClient.style.isDocument || activeClient.fileName)
850 if(caption[0]) strcat(caption, " - ");
851 strcat(caption, "[");
852 if(activeClient.fileName)
853 strcat(caption, activeClient.fileName);
857 sprintf(title, "Untitled %d", activeClient.documentID);
858 strcat(caption, title);
860 if(activeClient.modifiedDocument)
861 strcat(caption, " *");
862 strcat(caption, "]");
867 // Code for returning dirty from ScrollDisplay:
869 for(d = 0; d<scrollExtent.count; d++)
871 Box * box = &scrollExtent.boxes[d];
877 Min(box.right, box.left-scroll.x),box.bottom
879 dirtyArea.UnionBox(update);
885 Max(box.left, box.right-scroll.x), box.top,
886 box.right, box.bottom
888 dirtyArea.UnionBox(update);
896 box.right, Min(box.bottom, box.top-scroll.y),
898 dirtyArea.UnionBox(update);
904 box.left, Max(box.top, box.bottom-scroll.y),
905 box.right, box.bottom
907 dirtyArea.UnionBox(update);
912 void UpdateDecorations(void)
914 // TODO: *** TEMPORARY HACK ***
921 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
923 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
925 Update({ -clientStart.x,0, -1, clientSize.h-1 });
927 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
930 // Returns w & h for Position
931 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
933 Window parent = this.parent ? this.parent : guiApp.desktop;
934 int vpw = parent ? parent.clientSize.w : 0;
935 int vph = parent ? parent.clientSize.h : 0;
936 int pw = parent ? parent.clientSize.w : 0;
937 int ph = parent ? parent.clientSize.h : 0;
938 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
939 int x = anchor.left.distance, y = anchor.top.distance;
941 MinMaxValue ew = 0, eh = 0;
943 float cascadeW, cascadeH;
945 int tilingW, tilingH, tilingSplit, tilingLastH;
946 int addX = 0, addY = 0;
948 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
950 Window masterWindow = this;
951 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
954 if(master == guiApp.desktop)
955 masterWindow = guiApp.desktop.activeChild;
957 masterWindow = master.rootWindow;
958 if(!masterWindow) masterWindow = this;
960 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
961 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
964 pw = vpw = box.right - box.left + 1;
966 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
969 ph = vph = box.bottom - box.top + 1;
985 vpw = pw = parent.size.w;
986 vph = ph = parent.size.h;
988 else if(!style.fixed /*|| style.isDocument*/)
990 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
991 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
993 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
996 Desktop3D_FixSize(&pw, &ph);
997 Desktop3D_FixSize(&vpw, &vph);
1000 if(pw < skinMinSize.w) pw = skinMinSize.w;
1001 if(ph < skinMinSize.h) ph = skinMinSize.h;
1002 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1003 if(vph < skinMinSize.h) vph = skinMinSize.h;
1005 // TODO: Must fix what we're snapping
1008 if(anchor.left.type)
1010 SNAPUP(x, textCellW);
1012 else if(anchor.right.type)
1014 SNAPDOWN(x, textCellW);
1019 SNAPUP(y, textCellH);
1021 else if(anchor.bottom.type)
1023 SNAPDOWN(y, textCellH);
1027 // This is required to get proper initial decoration size using native decorations on Windows
1028 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1029 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1030 GetDecorationsSize(&ew, &eh);
1032 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1034 if(parent.sbv && !parent.sbv.style.hidden)
1035 pw += guiApp.currentSkin.VerticalSBW();
1036 if(parent.sbh && !parent.sbh.style.hidden)
1037 ph += guiApp.currentSkin.HorizontalSBH();
1039 if(anchor.left.type == cascade)
1041 w = (int)(pw * 0.80);
1042 h = (int)(ph * 0.80);
1044 else if(anchor.left.type >= vTiled)
1049 numTiling = parent.numPositions - parent.numIcons;
1050 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1051 if(anchor.left.type == vTiled)
1053 tilingH = (int)sqrt(numTiling);
1054 tilingW = numTiling / tilingH;
1058 tilingW = (int)sqrt(numTiling);
1059 tilingH = numTiling / tilingW;
1062 leftOver = numTiling - tilingH * tilingW;
1065 tilingSplit = (tilingW - leftOver) * tilingH;
1066 tilingLastH = tilingH+1;
1069 tilingSplit = numTiling;
1071 if(positionID >= tilingSplit)
1073 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1074 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1075 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1076 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1080 x = pw * (positionID / tilingH) / tilingW;
1081 y = ph * (positionID % tilingH) / tilingH;
1082 x2 = pw * (positionID / tilingH + 1) / tilingW;
1083 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1087 SNAPDOWN(x, textCellW);
1088 SNAPDOWN(y, textCellH);
1089 SNAPDOWN(x2, textCellW);
1090 SNAPDOWN(y2, textCellH);
1098 if(sizeAnchor.isClientW) w += ew;
1099 if(sizeAnchor.isClientH) h += eh;
1101 if(anchor.left.type == offset)
1102 x = anchor.left.distance;
1103 else if(anchor.left.type == relative)
1104 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1105 else if(anchor.right.type == relative)
1106 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1107 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1108 else if(anchor.right.type == offset)
1109 ex = vpw - anchor.right.distance;
1111 if(anchor.top.type == offset)
1112 y = anchor.top.distance;
1113 else if(anchor.top.type == relative)
1114 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1115 else if(anchor.bottom.type == relative)
1116 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1117 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1118 else if(anchor.bottom.type == offset)
1119 ey = vph - anchor.bottom.distance;
1121 if(anchor.left.type && anchor.right.type)
1123 switch(anchor.right.type)
1126 ex = pw * (1.0f-anchor.right.percent);
1127 w = Max((int)(ex + 0.5) - x, 0);
1130 ex = vpw - anchor.right.distance;
1131 w = Max((int)(ex + 0.5) - x, 0);
1135 if(anchor.top.type && anchor.bottom.type)
1137 switch(anchor.bottom.type)
1140 ey = ph * (1.0f-anchor.bottom.percent);
1141 h = Max((int)(ey + 0.5) - y, 0);
1144 ey = vph - anchor.bottom.distance;
1145 h = Max((int)(ey + 0.5) - y, 0);
1154 if(state == normal /*|| state == Hidden*/)
1156 bool addSbV = false, addSbH = false;
1158 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1159 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1161 w = Max(w, minSize.w);
1162 h = Max(h, minSize.h);
1163 w = Min(w, maxSize.w);
1164 h = Min(h, maxSize.h);
1166 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1168 if(w) w -= guiApp.currentSkin.VerticalSBW();
1171 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1173 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1177 if(!OnResizing(&w, &h))
1183 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1184 w += guiApp.currentSkin.VerticalSBW();
1185 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1186 h += guiApp.currentSkin.HorizontalSBH();
1188 w = Max(w, skinMinSize.w);
1189 h = Max(h, skinMinSize.h);
1202 SNAPDOWN(w, textCellW);
1203 SNAPDOWN(h, textCellH);
1206 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1208 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1211 (pw - w) / CASCADE_SPACE,
1212 (ph - h) / CASCADE_SPACE);
1218 cascW = (pw - w) / (numCascade-1);
1219 cascH = (ph - h) / (numCascade-1);
1220 SNAPDOWN(cascW, textCellW);
1221 SNAPDOWN(cascH, textCellH);
1222 cascadeW = (float)cascW;
1223 cascadeH = (float)cascH;
1227 numCascade = Max(numCascade, 2);
1228 cascadeW = (float)(pw - w) / (numCascade-1);
1229 cascadeH = (float)(ph - h) / (numCascade-1);
1232 x = (int)((positionID % numCascade) * cascadeW);
1233 y = (int)((positionID % numCascade) * cascadeH);
1235 else if(anchor.left.type < vTiled)
1237 if(!anchor.left.type || anchor.horz.type == middleRelative)
1239 if(!anchor.right.type)
1241 if(anchor.horz.type == middleRelative)
1242 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1244 x = vpw / 2 + anchor.horz.distance - w / 2;
1250 // case A_EDGE: x = x - w; break;
1252 if(!anchor.top.type || anchor.vert.type == middleRelative)
1254 if(!anchor.bottom.type)
1256 if(anchor.vert.type == middleRelative)
1257 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1259 y = vph / 2 + anchor.vert.distance - h / 2;
1265 // case A_EDGE: y = y - h; break;
1268 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1276 SNAPDOWN(x, textCellW);
1277 SNAPDOWN(y, textCellH);
1289 if(anchored && style.fixed && style.isActiveClient)
1294 void UpdateCaret(bool forceUpdate, bool erase)
1296 static Window lastWindow = null;
1297 static int caretX, caretY, caretSize;
1299 if(guiApp && guiApp.caretOwner == this)
1301 int x = caretPos.x - scroll.x;
1302 int y = caretPos.y - scroll.y;
1304 if((erase || this.caretSize) &&
1305 x >= clientArea.left && x <= clientArea.right &&
1306 y >= clientArea.top && y <= clientArea.bottom)
1310 guiApp.interfaceDriver.SetCaret(
1311 x + absPosition.x + clientStart.x,
1312 y + absPosition.y + clientStart.y, this.caretSize);
1313 guiApp.caretEnabled = true;
1315 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1319 if(lastWindow != this)
1321 updateBox.left = x + 1;
1323 updateBox.right = x + 2;
1324 updateBox.bottom = y + this.caretSize - 1;
1328 updateBox.left = Min(x + 1, caretX + 1);
1329 updateBox.top = Min(y, caretY);
1330 updateBox.right = Max(x + 2, caretX + 2);
1331 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1334 guiApp.caretOwner.Update(updateBox);
1341 caretSize = this.caretSize;
1347 guiApp.interfaceDriver.SetCaret(0,0,0);
1348 guiApp.caretEnabled = false;
1354 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1359 scrolledPos.x = position.x = x;
1360 scrolledPos.y = position.y = y;
1362 clientSize.w = size.w = w;
1363 clientSize.h = size.h = h;
1365 if(parent && !style.nonClient)
1367 //if(!style.fixed || style.isDocument)
1369 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1370 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1374 clientStart.x = clientStart.y = 0;
1376 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1378 //if(!activeClient || activeClient.state != maximized)
1379 if(!noAutoScrollArea)
1381 // Check if scroll area must be modified
1382 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1384 bool foundChild = false;
1386 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1387 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1388 for(child = children.first; child; child = child.next)
1390 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1391 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1393 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1394 w = Max(w, child.position.x + child.size.w);
1395 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1396 w = Max(w, Max(child.position.x, 0) + child.size.w);
1397 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1398 h = Max(h, child.position.y + child.size.h);
1399 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1400 h = Max(h, Max(child.position.y, 0) + child.size.h);
1405 if(foundChild && (w > cw || h > ch))
1407 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1409 int stepX = sbStep.x, stepY = sbStep.y;
1410 // Needed to make snapped down position match the skin's check of client area
1411 // against realvirtual
1414 SNAPDOWN(stepX, textCellW);
1415 SNAPDOWN(stepY, textCellH);
1416 stepX = Max(stepX, textCellW);
1417 stepY = Max(stepY, textCellH);
1419 if(scrollFlags.snapX)
1421 if(scrollFlags.snapY)
1424 reqScrollArea.w = w;
1425 reqScrollArea.h = h;
1428 else if(reqScrollArea.w || reqScrollArea.h)
1430 reqScrollArea.w = 0;
1431 reqScrollArea.h = 0;
1432 SetScrollPosition(0,0);
1437 // Automatic MDI Client Scrolling Area Adjustment
1438 if(parent && !parent.noAutoScrollArea)
1440 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1441 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1443 Window parent = this.parent;
1444 int w = parent.reqScrollArea.w;
1445 int h = parent.reqScrollArea.h;
1447 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1448 w = Max(w, position.x + size.w);
1449 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1450 w = Max(w, Max(position.x, 0) + size.w);
1451 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1452 h = Max(h, position.y + size.h);
1453 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1454 h = Max(h, Max(position.y, 0) + size.h);
1456 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1457 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1459 /*bool resize = false;
1460 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1461 // Needed to make snapped down position match the skin's check of client area
1462 // against realvirtual
1465 SNAPDOWN(stepX, textCellW);
1466 SNAPDOWN(stepY, textCellH);
1467 stepX = Max(stepX, textCellW);
1468 stepY = Max(stepY, textCellH);
1470 if(parent.scrollFlags.snapX)
1472 if(parent.scrollFlags.snapY)
1474 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1476 parent.reqScrollArea.w = w;
1477 parent.reqScrollArea.h = h;*/
1479 // parent.UpdateScrollBars(true, true);
1480 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1481 false, true, true, true, false, false);
1486 GetRidOfVirtualArea();
1490 UpdateScrollBars(modifyThisArea, false);
1491 else if(guiApp.currentSkin)
1494 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1496 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1497 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1498 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1499 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1502 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1503 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1505 absPosition = scrolledPos;
1506 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1507 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1509 if(this != guiApp.desktop && parent)
1511 absPosition.x += parent.absPosition.x;
1512 absPosition.y += parent.absPosition.y;
1513 if(!style.nonClient && this != guiApp.desktop)
1515 absPosition.x += parent.clientStart.x;
1516 absPosition.y += parent.clientStart.y;
1520 box = Box { 0, 0, size.w - 1, size.h - 1 };
1525 // Clip against parent's client area
1526 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1528 // Compute client area in this window coordinate system
1529 clientArea.left = 0;
1531 clientArea.right = clientSize.w - 1;
1532 clientArea.bottom = clientSize.h - 1;
1534 // Clip against parent's client area
1536 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1540 //absPosition.x -= parent.clientStart.x;
1541 //absPosition.y -= parent.clientStart.y;
1544 // Adjust all children
1545 for(child = children.first; child; child = child.next)
1546 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1548 UpdateCaret(false, false);
1551 void GetRidOfVirtualArea(void)
1553 if(parent && !parent.destroyed && style.fixed &&
1554 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1555 parent.reqScrollArea.w && parent.reqScrollArea.h)
1557 if(!parent.noAutoScrollArea)
1561 for(child = children.first; child; child = child.next)
1563 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1565 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1566 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1575 Window parent = this.parent;
1577 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1578 false, true, true, true, false, false);
1580 parent.SetScrollArea(0,0,true);
1581 parent.SetScrollPosition(0,0);
1587 public void ExternalPosition(int x, int y, int w, int h)
1589 Position(x, y, w, h, false, true, true, true, false, false);
1592 // (w, h): Full window size
1593 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1595 bool result = false;
1596 int oldCW = clientSize.w, oldCH = clientSize.h;
1597 bool clientResized, windowResized, windowMoved;
1599 bool realResized = size.w != w || size.h != h;
1601 // TOCHECK: This wasn't in ecere.dll
1602 //if(!parent) return true;
1603 if(destroyed) return false;
1605 windowMoved = position.x != x || position.y != y || force;
1607 // windowResized = realResized || force;
1608 windowResized = size.w != w || size.h != h || force;
1610 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1616 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1617 scrolledPos.x - parent.clientStart.x + this.box.right,
1618 scrolledPos.y - parent.clientStart.y + this.box.bottom
1624 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1629 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1631 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1632 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1633 windowResized = true;
1635 if(display && rootWindow != this)
1638 if(guiApp && guiApp.windowMoving)
1640 if(guiApp.windowMoving.style.nonClient)
1641 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1643 guiApp.windowMoving.parent.SetMouseRangeToClient();
1653 // Buttons bitmap resources crash if we do this while switching mode
1654 if(!guiApp || !guiApp.modeSwitching)
1657 // Process Anchored Children
1661 for(child = children.first; child; child = child.next)
1664 ((child.stateAnchor.left.type != offset ||
1665 child.stateAnchor.top.type != offset ||
1666 child.stateAnchor.right.type != none ||
1667 child.stateAnchor.bottom.type != none) ||
1668 child.state == maximized || child.state == minimized))
1670 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1672 // child.Position(x, y, w, h, false, true, true, true, false);
1673 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1674 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1680 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1681 //if(updateScrollBars)
1683 OnResize(clientSize.w, clientSize.h);
1685 if((clientResized || windowMoved) && created)
1686 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1688 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1690 Window master = guiApp.interimWindow.master;
1691 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1694 if(rootWindow == this && !is3D)
1698 x -= guiApp.desktop.absPosition.x;
1699 y -= guiApp.desktop.absPosition.y;
1701 //guiApp.Log("Position %s\n", caption);
1704 if(windowResized || windowMoved)
1705 if(display && !display.flags.memBackBuffer && changeRootWindow)
1706 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1708 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1709 for(child = parent.children.first; child && child != this; child = child.next)
1710 if(child.rootWindow)
1711 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1716 if(windowMoved || windowResized)
1718 display.Lock(true /*false*/);
1721 display.Position(absPosition.x, absPosition.y);
1722 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1725 // result = realResized ? display.Resize(size.w, size.h) : true;
1726 if(nativeDecorations && rootWindow.windowHandle)
1728 int w = clientSize.w, h = clientSize.h;
1729 if(hasMenuBar) h += skinMenuHeight;
1730 if(hasStatusBar) h += statusBarHeight;
1731 if(sbv && sbv.visible) w += sbv.size.w;
1732 if(sbh && sbh.visible) h += sbh.size.h;
1733 result = manageDisplay ? display.Resize(w, h) : true;
1736 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1740 else if(clientResized)
1742 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1745 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1749 if(windowMoved || windowResized)
1754 if(guiApp.driver && changeRootWindow && windowHandle)
1756 if(windowResized || windowMoved)
1757 if(!display || display.flags.memBackBuffer)
1758 guiApp.interfaceDriver.PositionRootWindow(this,
1759 x, y, w, h, windowMoved, windowResized);
1760 guiApp.interfaceDriver.UpdateRootWindow(this);
1762 for(child = children.first; child; child = child.next)
1764 if(child.is3D && child.created)
1766 // Copy Display Content
1767 child.display.displaySystem = display.displaySystem;
1768 child.display.window = display.window;
1769 child.display.current = display.current;
1770 child.display.width = display.width;
1771 child.display.height = display.height;
1772 child.display.driverData = display.driverData;
1773 child.display.mutex = null;
1784 void UpdateScrollBars(bool flag, bool fullThing)
1787 bool resizeH = false, resizeV = false;
1788 bool scrolled = false;
1789 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1790 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1792 if(destroyed) return;
1793 if(guiApp.currentSkin)
1795 MinMaxValue cw = 0, ch = 0;
1796 bool sbvVisible, sbhVisible;
1798 int positionH, positionV;
1800 // First get client area with no respect to scroll bars
1805 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1807 if(scrollFlags.dontHide)
1810 cw -= guiApp.currentSkin.VerticalSBW();
1812 ch -= guiApp.currentSkin.HorizontalSBH();
1814 // Update the scrollbar visibility
1820 sbh.disabled = rangeH <= 1;
1821 if(sbh.style.hidden)
1831 sbv.disabled = rangeV <= 1;
1832 if(sbv.style.hidden)
1840 int oldHRange = sbh ? sbh.range : 0;
1841 int oldVRange = sbv ? sbv.range : 0;
1842 // Then start off with horizontal scrollbar range
1845 positionH = sbh.thumbPosition;
1852 SBSetTotal(sbh, rvw);
1855 ch -= guiApp.currentSkin.HorizontalSBH();
1858 // Do the same for vertical scrollbar
1861 positionV = sbv.thumbPosition;
1867 SBSetTotal(sbv, rvh);
1871 cw -= guiApp.currentSkin.VerticalSBW();
1872 // Maybe we need to set the range on the horizontal scrollbar again
1880 SBSetTotal(sbh, rvw);
1881 //sbh.Action(setRange, positionH, 0);
1882 if(rangeH <= 1 && sbh.range > 1)
1884 ch -= guiApp.currentSkin.HorizontalSBH();
1890 SBSetTotal(sbv, rvh);
1892 //sbv.Action(setRange, positionV, 0);
1897 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1898 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1901 // Update the scrollbar visibility
1902 if(!scrollFlags.dontHide)
1904 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1908 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1915 if(guiApp.currentSkin)
1922 sbhVisible = sbh.style.hidden ? true : false;
1924 sbvVisible = sbv.style.hidden ? true : false;
1926 // Do our resize here
1927 if(flag && (resizeH || resizeV) && fullThing)
1929 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1934 OnResize(clientSize.w, clientSize.h);
1940 sbh.visible = sbhVisible;
1942 sbv.visible = sbvVisible;
1944 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1945 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1948 sbh.pageStep = clientSize.w;
1950 sbv.pageStep = clientSize.h;
1952 // Notify doesn't handle setRange anymore... process it here
1955 int positionH = sbh.thumbPosition;
1956 if(scroll.x != positionH)
1958 OnHScroll(setRange, positionH, 0);
1962 SNAPDOWN(positionH, textCellW);
1963 scroll.x = positionH;
1969 int seen = clientSize.w, total = reqScrollArea.w;
1972 if(scrollFlags.snapX)
1973 SNAPDOWN(seen, sbStep.x);
1975 if(!total) total = seen;
1976 range = total - seen + 1;
1978 range = Max(range, 1);
1980 if(x >= range) x = range - 1;
1982 if(scrollFlags.snapX)
1983 SNAPUP(x, sbStep.x);
1987 OnHScroll(setRange, x, 0);
1992 SNAPDOWN(x, textCellW);
1998 int positionV = sbv.thumbPosition;
1999 if(scroll.y != positionV)
2001 OnVScroll(setRange, positionV, 0);
2005 SNAPDOWN(positionV, textCellH);
2006 scroll.y = positionV;
2012 int seen = clientSize.h, total = reqScrollArea.h;
2015 if(scrollFlags.snapY)
2016 SNAPDOWN(seen, sbStep.y);
2018 if(!total) total = seen;
2019 range = total - seen + 1;
2020 range = Max(range, 1);
2022 if(y >= range) y = range - 1;
2024 if(scrollFlags.snapY)
2025 SNAPUP(y, sbStep.y);
2029 OnVScroll(setRange, y, 0);
2034 SNAPDOWN(y, textCellH);
2040 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2043 for(child = children.first; child; child = child.next)
2045 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2048 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2049 child.Position(x, y, w, h, false, true, false, true, false, false);
2056 // Process Scrollbars
2058 if(sbh) // && !sbh.style.hidden
2061 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2062 // Need to set the range again (should improve...) since the scrollbars didn't have
2063 // the right size when UpdateScrollArea set the range on it
2066 sbh.seen = clientSize.w;
2070 if(sbv) // && !sbv.state.hidden
2073 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2074 // Need to set the range again (should improve...) since the scrollbars didn't have
2075 // the right size when UpdateScrollArea set the range on it
2078 sbv.seen = clientSize.h;
2083 // TESTING THIS LOWER
2084 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2087 for(child = children.first; child; child = child.next)
2089 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2092 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2093 child.Position(x, y, w, h, false, true, false, true, false, false);
2099 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2101 SetState(maximized, false, mods);
2105 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2107 SetState(normal, false, mods);
2111 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2113 SetState(minimized, false, mods);
2114 parent.CycleChildren(false, true, false, true);
2118 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2121 // Scroll bar notifications
2122 if(action != setRange)
2124 bool changed = false;
2128 if(scroll.x != position)
2130 OnHScroll(action, position, keyFlags);
2135 SNAPDOWN(position, textCellW);
2137 scroll.x = position;
2141 if(scroll.y != position)
2143 OnVScroll(action, position, keyFlags);
2148 SNAPDOWN(position, textCellH);
2150 scroll.y = position;
2154 bool childMove = false;
2155 for(child = children.first; child; child = child.next)
2157 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2160 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2161 child.Position(x, y, w, h, false, true, false, true, false, false);
2165 // Testing this patch out to solve MDI workspace redraw bugs
2166 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2167 // Scroll offsets to blame?
2171 UpdateCaret(false, false);
2175 // Testing this patch out to solve MDI workspace redraw bugs
2176 for(child = children.first; child; child = child.next)
2178 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2187 Window GetParentMenuBar()
2189 Window result = this;
2190 bool notActiveClient = false;
2191 Window menuBarParent;
2192 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2194 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2195 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2196 notActiveClient = true;
2201 void CreateSystemChildren(void)
2203 Window parent = this;
2204 bool scrollBarChanged = false;
2205 bool hasClose = false, hasMaxMin = false;
2206 Point scroll = this.scroll;
2208 if(state == maximized)
2209 parent = GetParentMenuBar();
2213 if(style.hasClose) hasClose = true;
2214 if(style.hasMaximize || style.hasMinimize)
2221 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2223 sysButtons[2].Destroy(0);
2224 sysButtons[2] = null;
2226 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2228 sysButtons[1].Destroy(0);
2229 sysButtons[1] = null;
2231 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2233 sysButtons[0].Destroy(0);
2234 sysButtons[0] = null;
2237 if(hasClose && parent)
2244 parent, master = this,
2245 inactive = true, nonClient = true, visible = false;
2247 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2253 if(this.parent == guiApp.desktop)
2254 sysButtons[2].hotKey = altF4;
2255 else if(style.isActiveClient)
2256 sysButtons[2].hotKey = ctrlF4;
2257 sysButtons[2].Create();
2260 sysButtons[2].symbol = 'X';
2261 sysButtons[2].disabled = !style.hasClose;
2264 if(hasMaxMin && parent)
2268 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2269 if(state == maximized)
2272 method = RestoreButtonClicked;
2278 method = MaximizeButtonClicked;
2286 parent, master = this,
2287 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2289 sysButtons[1].Create();
2291 sysButtons[1].NotifyClicked = method;
2293 sysButtons[1].symbol = symbol;
2294 sysButtons[1].disabled = !style.hasMaximize;
2297 if(hasMaxMin && parent)
2301 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2302 if (state == minimized)
2305 method = RestoreButtonClicked;
2311 method = MinimizeButtonClicked;
2319 parent, master = this,
2320 hotKey = altM, inactive = true, nonClient = true, visible = false
2322 sysButtons[0].Create();
2324 sysButtons[0].NotifyClicked = method;
2326 sysButtons[0].symbol = symbol;
2327 sysButtons[0].disabled = !style.hasMinimize;
2330 // Create the scrollbars
2331 if(style.hasHorzScroll && !sbh)
2337 direction = horizontal,
2341 snap = scrollFlags.snapX,
2342 NotifyScrolling = ScrollBarNotification
2345 scrollBarChanged = true;
2347 else if(sbh && !style.hasHorzScroll)
2353 if(style.hasVertScroll && !sbv)
2359 direction = vertical,
2363 snap = scrollFlags.snapY,
2364 NotifyScrolling = ScrollBarNotification
2367 scrollBarChanged = true;
2369 else if(sbv && !style.hasVertScroll)
2374 if(scrollBarChanged)
2376 SetScrollLineStep(sbStep.x, sbStep.y);
2377 UpdateScrollBars(true, true);
2381 if(scrollBarChanged)
2383 if(sbh) sbh.thumbPosition = scroll.x;
2384 if(sbv) sbv.thumbPosition = scroll.y;
2388 void UpdateCaption(void)
2390 if(rootWindow == this)
2393 FigureCaption(caption);
2394 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2396 UpdateDecorations();
2399 if(parent.activeClient == this) // Added this last check
2401 if(parent.rootWindow == parent)
2404 parent.FigureCaption(caption);
2405 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2408 parent.UpdateCaption();
2410 parent.UpdateDecorations();
2414 void UpdateActiveDocument(Window previous)
2416 Window activeClient = this.activeClient;
2417 Window activeChild = this.activeChild;
2424 activeClient.CreateSystemChildren();
2426 previous.CreateSystemChildren();
2438 // Build window list
2441 Menu windowMenu = menu.FindMenu("Window");
2446 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2449 Window document = cycle.data;
2450 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2452 char name[2048], caption[2048];
2453 document.FigureCaption(caption);
2454 sprintf(name, "%d %s", id+1, caption);
2455 windowMenu.AddDynamic(MenuItem
2457 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2458 NotifySelect = MenuWindowSelectWindow
2462 if(activeClient.cycle == cycle) break;
2467 if((!previous && activeClient) || !activeClient)
2473 item = menu.FindItem(MenuWindowCloseAll, 0);
2474 if(item) item.disabled = false;
2475 item = menu.FindItem(MenuWindowNext, 0);
2476 if(item) item.disabled = false;
2477 item = menu.FindItem(MenuWindowPrevious, 0);
2478 if(item) item.disabled = false;
2479 item = menu.FindItem(MenuWindowCascade, 0);
2480 if(item) item.disabled = false;
2481 item = menu.FindItem(MenuWindowTileHorz, 0);
2482 if(item) item.disabled = false;
2483 item = menu.FindItem(MenuWindowTileVert, 0);
2484 if(item) item.disabled = false;
2485 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2486 if(item) item.disabled = false;
2487 item = menu.FindItem(MenuWindowWindows, 0);
2488 if(item) item.disabled = false;
2491 item = menu.FindItem(MenuFileClose, 0);
2492 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2493 item = menu.FindItem(MenuFileSaveAll, 0);
2494 if(item) item.disabled = numDocuments < 1;
2496 if(activeClient && activeClient.menu && activeClient.state != minimized)
2500 //activeClient.menu.Clean(activeClient);
2501 menu.Merge(activeClient.menu, true, activeClient);
2505 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2508 menu.Merge(activeChild.menu, true, activeChild);
2511 // This is called again for a child window change, with same active client
2512 OnActivateClient(activeClient, previous);
2513 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2514 parent.UpdateActiveDocument(null);
2517 void _ShowDecorations(Box box, bool post)
2519 if(rootWindow == this && nativeDecorations) return;
2520 if(visible && this != guiApp.desktop)
2522 Surface surface = RedrawFull(box);
2526 FigureCaption(caption);
2529 ShowDecorations(captionFont.font,
2532 active, //parent.activeClient == this
2533 guiApp.windowMoving == this);
2535 PreShowDecorations(captionFont.font,
2538 active, //parent.activeClient == this
2539 guiApp.windowMoving == this);
2546 void UpdateExtent(Box refresh)
2548 Surface surface = null;
2550 if(!manageDisplay) { OnRedraw(null);return; }
2551 _ShowDecorations(refresh, false);
2553 surface = Redraw(refresh);
2554 // Opaque background: just fill before EW_REDRAW (clear?)
2557 surface.SetBackground(background);
2558 surface.SetForeground(foreground);
2559 surface.DrawingChar(' ');
2560 if(this == rootWindow)
2562 if(style.drawBehind || background.a)
2564 int a = background.a;
2565 // Premultiply alpha for clear color
2566 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2567 surface.Clear(colorBuffer);
2568 surface.SetBackground(background);
2571 else if(background.a)
2575 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2576 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2579 if(display.flags.alpha && background.a < 255 && background)
2581 surface.Area(0,0,clientSize.w, clientSize.h);
2582 /*if(style.clearDepthBuffer)
2583 surface.Clear(depthBuffer);*/
2585 else if(/*style.clearDepthBuffer || */background.a)
2587 int a = background.a;
2588 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2589 // Premultiply alpha for clear color
2590 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2591 surface.Clear(colorBuffer);
2592 surface.SetBackground(background);
2597 surface.TextFont(usedFont.font);
2598 surface.TextOpacity(false);
2602 // Draw the caret ...
2603 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2605 // surface.SetBackground(0xFFFFFF - background.color);
2606 surface.SetBackground(~background.color);
2608 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2609 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2615 void DrawOverChildren(Box refresh)
2617 Surface surface = Redraw(refresh);
2621 surface.DrawingChar(' ');
2622 surface.SetBackground(background);
2623 surface.SetForeground(foreground);
2625 surface.TextFont(usedFont.font);
2626 surface.TextOpacity(false);
2628 OnDrawOverChildren(surface);
2633 _ShowDecorations(refresh, true);
2636 void ComputeClipExtents(void)
2639 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2641 clipExtent.Copy(this.clipExtent);
2643 for(child = children.last; child; child = child.prev)
2645 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2647 bool opaque = child.IsOpaque(); // TODO: acess background directly
2648 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2650 child.clipExtent.Copy(clipExtent);
2651 child.clipExtent.Offset(-dx, -dy);
2652 child.clipExtent.IntersectBox(child.box);
2654 child.ComputeClipExtents();
2656 if(opaque && !child.style.nonClient)
2658 // Adjust the box for the parent:
2659 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2660 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2665 // ??? Only do this for overlapped window or if parent has with clip children flag
2667 // Do this if window has clip children flag on (default false?)
2668 // this.clipExtent = clipExtent;
2670 clipExtent.Free(null);
2673 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2675 bool opaque = IsOpaque();
2677 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2678 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2680 offsetX -= rootWindow.clientStart.x;
2681 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2685 for(child = children.last; child; child = child.prev)
2687 ColorAlpha background = *(ColorAlpha *)&child.background;
2688 bool opaque = child.IsOpaque();
2689 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2693 // Adjust renderArea to the root window level
2694 Extent * renderArea = &rootWindow.tempExtents[1];
2696 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2697 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2699 offsetX -= child.rootWindow.clientStart.x;
2700 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2704 Extent childRenderArea;
2706 if(backBufferUpdate != null)
2708 childRenderArea.Copy(backBufferUpdate);
2709 childRenderArea.Offset(-offsetX, -offsetY);
2712 childRenderArea.Copy(child.dirtyArea);
2714 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2715 renderArea.Copy(dirtyExtent);
2716 renderArea.Offset(-offsetX, -offsetY);
2717 childRenderArea.Union(renderArea);
2720 // Intersect with the clip extent
2721 childRenderArea.Intersection(child.clipExtent);
2724 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2725 renderArea->Offset(offsetX, offsetY);
2726 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2727 // overDirtyExtent.Union(renderArea);
2728 renderArea->Empty();
2729 // childRenderArea.Free();
2731 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2736 for(child = children.last; child; child = child.prev)
2738 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2740 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2745 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2747 bool opaque = IsOpaque();
2748 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2750 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2751 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2753 offsetX -= rootWindow.clientStart.x;
2754 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2758 for(child = children.last; child; child = child.prev)
2760 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2762 ColorAlpha background = *(ColorAlpha *)&child.background;
2763 bool opaque = child.IsOpaque();
2764 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2768 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2769 // Adjust renderArea to the root window level
2771 renderArea.Copy(child.dirtyArea);
2772 renderArea.Offset(offsetX, offsetY);
2773 dirtyExtent.Union(renderArea);
2774 overDirtyExtent.Union(renderArea);
2780 for(child = children.last; child; child = child.prev)
2782 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2784 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2788 if(backBufferUpdate != null)
2790 renderArea.Copy(backBufferUpdate);
2791 renderArea.Offset(-offsetX, -offsetY);
2793 overRenderArea.Copy(backBufferUpdate);
2794 overRenderArea.Offset(-offsetX, -offsetY);
2800 renderArea.Copy(dirtyArea);
2802 overRenderArea.Copy(dirtyArea);
2805 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2806 dirtyExtentWindow->Copy(dirtyExtent);
2807 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2808 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2809 dirtyExtentWindow->Empty();
2811 // Intersect with the clip extent
2812 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2815 if(renderArea.count > 10)
2818 printf("\nToo many extents (%d):\n", renderArea.count);
2820 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2821 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2826 for(c = 0; c<10; c++)
2829 FASTLIST_LOOP(renderArea, extentBox)
2831 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2833 renderArea.Copy(extent);
2835 FASTLIST_LOOP(renderArea, extentBox)
2838 printf("(%d, %d) - (%d, %d)\n",
2839 extentBox.box.left, extentBox.box.top,
2840 extentBox.box.right, extentBox.box.bottom);
2844 printf("\nNow %d\n", renderArea.count);
2850 // WHY WAS THIS COMMENTED ??
2852 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2853 dirtyExtentWindow->Copy(overDirtyExtent);
2854 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2855 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2856 dirtyExtentWindow->Empty();
2858 // Intersect with the clip extent
2859 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2865 if(scrollExtent.count)
2867 // Subtract render extent from scrolling extent
2868 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2870 if(backBufferUpdate == null)
2872 Extent * dirty = &rootWindow.tempExtents[3];
2875 // Intersect scrolling extent with clip extent
2876 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2878 // offset this scroll to be at the root window level
2879 scrollExtent.Offset(offsetX, offsetY);
2880 // Add area that was scrolled to the dirty extents of the back buffer
2881 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2885 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2886 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2887 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2892 scrollExtent.Empty();
2894 // Add the exposed extent to the window render area
2895 dirty->Offset(-offsetX, -offsetY);
2896 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2901 // Subtract the window's box from the transparency forced extent
2902 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2908 renderArea.Copy(this.renderArea);
2909 renderArea.Offset(offsetX, offsetY);
2910 dirtyExtent.Union(renderArea);
2916 Extent renderArea { };
2918 renderArea.Copy(overRenderArea);
2919 renderArea.Offset(offsetX, offsetY);
2920 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2925 if(backBufferUpdate != null)
2927 // Remove render area from dirty area
2928 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2930 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2937 // Remove the window render area from the dirty extents of the back buffer
2938 rootWindow.dirtyBack.Exclusion(renderArea);
2942 void Render(Extent updateExtent)
2946 Window rootWindow = this.rootWindow;
2947 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2948 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2950 offsetX -= rootWindow.clientStart.x;
2951 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2954 if(rootWindow.fullRender)
2963 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2964 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2969 /*if(renderArea.count)
2970 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2973 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2975 Box box = extentBox.box;
2978 /*printf("(%d, %d) - (%d, %d)\n",
2979 extentBox.box.left, extentBox.box.top,
2980 extentBox.box.right, extentBox.box.bottom);*/
2985 box.left += offsetX;
2987 box.right += offsetX;
2988 box.bottom += offsetY;
2990 if(updateExtent != null)
2991 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2995 for(child = children.first; child; child = child.next)
2996 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
2997 child.Render(updateExtent);
2999 if(rootWindow.fullRender)
3000 DrawOverChildren(box);
3003 // TO DO: There's an issue about draw over children...
3004 // TO DO: Don't wanna go through this if method isn't used
3005 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3006 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3008 Box box = extentBox.box;
3010 DrawOverChildren(box);
3012 box.left += offsetX;
3014 box.right += offsetX;
3015 box.bottom += offsetY;
3017 if(updateExtent != null)
3018 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3021 for(child = children.first; child; child = child.next)
3022 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3023 child.Render(updateExtent);
3026 overRenderArea.Empty();
3029 public void UpdateDisplay(void)
3031 if(!manageDisplay) { OnRedraw(null);return; }
3032 if(rootWindow && this != rootWindow)
3033 rootWindow.UpdateDisplay();
3036 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3037 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3040 dirtyExtent.Clear();
3043 clipExtent.AddBox(box);
3045 display.StartUpdate();
3047 if(!rootWindow.fullRender)
3049 ComputeClipExtents();
3050 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3051 ComputeRenderArea(dirtyExtent, overExtent, null);
3054 clipExtent.Free(null);
3056 dirtyExtent.Free(null);
3057 overExtent.Free(null);
3059 if(display.flags.flipping)
3062 display.Update(null);
3066 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3067 updateExtent.Clear();
3069 Render(updateExtent);
3071 updateExtent.UnionBox(this.box, tempExtents[0]);
3074 //printf("\n\nUpdate:\n------------------------------------------\n");
3077 //FASTLIST_LOOP(updateExtent, extentBox)
3078 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3081 /*printf("Updating (%d, %d) - (%d, %d)\n",
3082 extentBox.box.left, extentBox.box.top,
3083 extentBox.box.right, extentBox.box.bottom);*/
3086 display.Update(extentBox.box);
3089 updateExtent.Free(null);
3092 display.EndUpdate();
3100 void UpdateBackDisplay(Box box)
3106 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3108 //printf("UpdateBackDisplay going through!\n");
3109 display.StartUpdate();
3113 intersection.Copy(dirtyBack);
3114 intersection.IntersectBox(box);
3116 dirtyExtent.Clear();
3119 clipExtent.AddBox(box);
3121 if(!rootWindow.fullRender)
3123 ComputeClipExtents();
3124 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3127 clipExtent.Free(null);
3129 intersection.Free(null);
3130 dirtyExtent.Free(null);
3131 overExtent.Free(null);
3136 if(display.flags.flipping)
3137 display.Update(null);
3140 rootWindow.display.Update(box);
3143 display.EndUpdate();
3147 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3148 if(dirtyBack.count > MAX_DIRTY_BACK)
3150 BoxItem extentBox, next;
3151 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3152 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3154 next = (BoxItem)extentBox.next;
3155 if(extentBox != first)
3157 if(extentBox.box.left < first.box.left)
3158 first.box.left = extentBox.box.left;
3159 if(extentBox.box.top < first.box.top)
3160 first.box.top = extentBox.box.top;
3161 if(extentBox.box.right > first.box.right)
3162 first.box.right = extentBox.box.right;
3163 if(extentBox.box.bottom > first.box.bottom)
3164 first.box.bottom = extentBox.box.bottom;
3165 dirtyBack.Delete(extentBox);
3174 // --- Window positioning ---
3175 // --- Window identification ---
3177 // Returns window at position "Position"
3178 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3180 Window child, result = null;
3182 box.left += absPosition.x;
3183 box.right += absPosition.x;
3184 box.top += absPosition.y;
3185 box.bottom += absPosition.y;
3187 if(!destroyed && visible && (acceptDisabled || !disabled))
3189 int lx = x - absPosition.x;
3190 int ly = y - absPosition.y;
3191 if(IsInside(lx, ly))
3192 // if(box.IsPointInside(Point{x, y}))
3194 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3195 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3198 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3200 if(child != statusBar && child.rootWindow == rootWindow)
3202 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3209 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3211 if(child != statusBar && child.rootWindow == rootWindow)
3213 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3225 Window FindModal(void)
3227 Window modalWindow = this, check;
3228 Window check2 = null;
3229 for(check = this; check.master; check = check.master)
3231 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3233 modalWindow = check.master.modalSlave;
3234 check = modalWindow;
3236 // TESTING THIS FOR DROPBOX...
3237 if(!rootWindow || !rootWindow.style.interim)
3239 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3241 if(check2.modalSlave && check2.modalSlave.created)
3243 modalWindow = check2.modalSlave;
3251 if(modalWindow == this)
3253 for(check = this; check.activeChild; check = check.activeChild)
3255 if(check.modalSlave)
3257 modalWindow = check.modalSlave;
3263 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3264 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3267 void StopMoving(void)
3269 if(this == guiApp.windowMoving)
3271 guiApp.windowMoving = null;
3272 UpdateDecorations();
3273 SetMouseRange(null);
3276 if(rootWindow.active)
3277 guiApp.interfaceDriver.StopMoving(rootWindow);
3280 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3281 guiApp.windowIsResizing = false;
3285 void SelectMouseCursor(void)
3290 Window cursorWindow = null;
3291 bool rx, ry, rex, rey;
3293 guiApp.desktop.GetMousePosition(&x, &y);
3294 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3296 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3297 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3298 else if(mouseWindow)
3300 modalWindow = mouseWindow.FindModal();
3301 x -= mouseWindow.absPosition.x;
3302 y -= mouseWindow.absPosition.y;
3303 if(guiApp.windowIsResizing)
3305 rex = guiApp.resizeEndX;
3306 rey = guiApp.resizeEndY;
3307 rx = guiApp.resizeX;
3308 ry = guiApp.resizeY;
3309 if((rex && rey) || (rx && ry))
3310 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3311 else if((rex && ry) || (rx && rey))
3312 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3313 else if((ry || rey) && (!rx && !rex))
3314 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3315 else if((rx || rex) && (!ry && !rey))
3316 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3318 else if(!modalWindow && !guiApp.windowCaptured &&
3319 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3320 &rx, &ry, &rex, &rey))
3322 if((rex && rey) || (rx && ry))
3323 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3324 else if((rex && ry) || (rx && rey))
3325 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3326 else if((ry || rey) && (!rx && !rex))
3327 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3328 else if((rx || rex) && (!ry && !rey))
3329 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3331 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3333 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3334 cursorWindow = mouseWindow.parent;
3336 cursorWindow = mouseWindow;
3338 else if(!guiApp.interimWindow)
3339 cursorWindow = guiApp.windowCaptured;
3342 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3343 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3345 else if(modalWindow)
3347 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3349 else if(guiApp.interimWindow)
3351 if(guiApp.interimWindow.cursor)
3352 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3354 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3359 // --- State based input ---
3360 bool AcquireInputEx(bool state)
3365 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3366 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3368 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3370 guiApp.acquiredWindow = state ? this : null;
3373 SetMouseRangeToClient();
3374 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3379 SelectMouseCursor();
3381 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3385 // --- Window activation ---
3386 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3389 if(!parent || !parent.style.inactive)
3391 Window parent = this.parent;
3394 if(rootWindow == this)
3395 Log(active ? "active\n" : "inactive\n");
3398 // Testing this here...
3399 if(!parent || parent == guiApp.desktop || parent.active)
3401 this.active = active;
3404 // TESTING THIS HERE
3405 UpdateDecorations();
3406 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3407 result = NotifyActivate(master, this, active, previous);
3410 this.active = !active;
3415 if(!parent || parent == guiApp.desktop || parent.active)
3417 this.active = active;
3419 AcquireInputEx(active);
3424 if(guiApp.caretOwner)
3428 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3429 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3430 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3431 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3433 guiApp.caretOwner.Update(extent);
3436 if(visible || !guiApp.caretOwner)
3437 guiApp.caretOwner = this;
3438 UpdateCaret(false, false);
3444 this.active = false;
3446 AcquireInputEx(active);
3448 if(!active && guiApp.caretOwner == this)
3450 UpdateCaret(false, true);
3451 guiApp.caretOwner = null;
3452 guiApp.interfaceDriver.SetCaret(0,0,0);
3453 guiApp.caretEnabled = false;
3458 if(!active && parent && parent.activeChild && parent.activeChild != this)
3459 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3465 if(!active && menuBar)
3468 menuBar.OnActivate(false, null, &goOn, true);
3469 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3474 Window aChild = activeChild;
3476 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3488 void ConsequentialMouseMove(bool kbMoving)
3492 if(kbMoving || !guiApp.windowMoving)
3496 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3498 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3500 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3501 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3507 bool IsDescendantOf(Window ancestor)
3510 for(window = this; window && window != ancestor; window = window.parent);
3511 return window == ancestor;
3514 bool IsSlaveOf(Window master)
3517 for(window = this; window && window != master; window = window.master);
3518 return window == master;
3521 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3525 if(this && !destroyed /*&& state != Hidden*/)
3527 Window swap = externalSwap;
3535 if(activateParent &&
3536 (parent.activeChild != this ||
3537 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3538 active && _isModal &&
3539 parent != master && master)
3540 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3546 bool real = parent.activeChild != this;
3548 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3549 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3550 !IsDescendantOf(guiApp.interimWindow) &&
3551 !IsSlaveOf(guiApp.interimWindow))
3553 Window interimWindow = guiApp.interimWindow;
3554 while(interimWindow && interimWindow != this)
3556 Window master = interimWindow.master;
3558 guiApp.interimWindow = null;
3559 if(guiApp.caretOwner)
3560 guiApp.caretOwner.UpdateCaret(false, false);
3562 incref interimWindow;
3563 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3568 delete interimWindow;
3569 interimWindow = (master && master.style.interim) ? master : null;
3574 guiApp.interimWindow = this;
3575 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3576 guiApp.caretEnabled = false;*/
3577 UpdateCaret(false, true);
3582 bool acquireInput = false;
3584 parent.activeChild &&
3585 parent.activeChild.state == maximized &&
3586 parent != guiApp.desktop;
3588 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3593 swap = parent.activeChild;
3594 if(swap && swap.destroyed) swap = null;
3595 if(swap && swap != this)
3598 if(!swap.PropagateActive(false, this, &goOn, true))
3599 swap = parent.activeChild;
3610 if(!parent || parent.activeChild != this || style.interim)
3613 result = PropagateActive(true, swap, &goOn, true);
3614 if(!result && !goOn)
3619 acquireInput = true;
3623 if(style.hasMaximize && parent != guiApp.desktop)
3626 SetState(maximized, false, 0);
3627 else if(state != maximized)
3630 for(child = parent.children.first; child; child = child.next)
3632 if(this != child && child.state == maximized)
3633 child.SetState(normal, false, 0);
3640 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3642 Window previous = parent.activeClient;
3643 parent.activeChild = this;
3644 if(!style.nonClient /*&& style.isActiveClient*/)
3648 if(style.isActiveClient)
3649 parent.activeClient = this;
3650 // Moved UpdateActiveDocument inside hidden check
3651 // To prevent activating previous window while creating a new one
3652 // (It was messing up the privateModule in the CodeEditor)
3653 parent.UpdateActiveDocument(previous);
3659 //if(!style.isRemote)
3661 if(rootWindow != this)
3663 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3664 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3666 else if(!guiApp.fullScreenMode)
3668 Window modalRoot = FindModal();
3669 if(!modalRoot) modalRoot = this;
3670 if(!modalRoot.isForegroundWindow)
3672 modalRoot.isForegroundWindow = true;
3673 // To check : Why is parent null?
3674 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3676 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3678 modalRoot.isForegroundWindow = false;
3683 if(result && real && (!style.inactive || moveInactive) && parent)
3685 Window last = parent.children.last;
3687 if(!style.stayOnTop)
3688 for(; last && last.style.stayOnTop; last = last.prev);
3690 parent.children.Move(this, last);
3692 // Definitely don't want that: why not?
3696 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3702 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3709 parent.activeChild = null;
3710 if(!style.nonClient /*&& style.isActiveClient*/)
3712 Window previous = parent.activeClient;
3713 if(style.isActiveClient)
3714 parent.activeClient = null;
3715 parent.UpdateActiveDocument(previous);
3719 if(this == guiApp.interimWindow)
3721 guiApp.interimWindow = null;
3722 if(guiApp.caretOwner)
3723 guiApp.caretOwner.UpdateCaret(false, false);
3725 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3732 if(!active || !swap)
3733 UpdateDecorations();
3735 swap.UpdateDecorations();
3737 if(active && rootWindow != this)
3738 ConsequentialMouseMove(false);
3745 // --- Input Messages ---
3746 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3748 static bool reEntrancy = false;
3749 if(reEntrancy) return;
3753 guiApp.cursorUpdate = true;
3754 if(guiApp.windowScrolling && !consequential)
3756 guiApp.windowScrolling.SetScrollPosition(
3757 (guiApp.windowScrolling.sbh) ?
3758 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3759 (guiApp.windowScrolling.sbv) ?
3760 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3762 if(guiApp.windowMoving)
3764 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3766 Window window = guiApp.windowMoving;
3768 int w = window.size.w;
3769 int h = window.size.h;
3774 rx = mouseX - guiApp.windowMovingStart.x;
3775 ry = mouseY - guiApp.windowMovingStart.y;
3778 window.GetDecorationsSize(&ew, &eh);
3780 if(guiApp.windowIsResizing)
3782 x = window.scrolledPos.x;
3783 y = window.scrolledPos.y;
3787 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3788 rx = guiApp.windowResizingBefore.w - aw;
3789 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3790 w = guiApp.windowResizingBefore.w - rx;
3794 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3795 ry = guiApp.windowResizingBefore.h - ah;
3796 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3797 ry = Max(ry, -guiApp.windowMovingBefore.y);
3798 h = guiApp.windowResizingBefore.h - ry;
3800 if(guiApp.resizeEndX)
3802 w = guiApp.windowResizingBefore.w + rx;
3805 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3813 w = Max(w, window.minSize.w);
3814 h = Max(h, window.minSize.h);
3815 w = Min(w, window.maxSize.w);
3816 h = Min(h, window.maxSize.h);
3818 if(!window.OnResizing(&w, &h))
3820 w = window.clientSize.w;
3821 h = window.clientSize.h;
3824 w = Max(w, window.skinMinSize.w);
3825 h = Max(h, window.skinMinSize.h);
3832 SNAPDOWN(w, textCellW);
3833 SNAPDOWN(h, textCellH);
3838 aw = Max(w,window.skinMinSize.w);
3839 rx = guiApp.windowResizingBefore.w - aw;
3840 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3841 w = guiApp.windowResizingBefore.w - rx;
3845 ah = Max(h,window.skinMinSize.h);
3846 ry = guiApp.windowResizingBefore.h - ah;
3847 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3848 ry = Max(ry, -guiApp.windowMovingBefore.y);
3849 h = guiApp.windowResizingBefore.h - ry;
3854 if(!guiApp.windowIsResizing || guiApp.resizeX)
3855 x = guiApp.windowMovingBefore.x + rx;
3856 if(!guiApp.windowIsResizing || guiApp.resizeY)
3857 y = guiApp.windowMovingBefore.y + ry;
3859 if(!guiApp.windowIsResizing)
3862 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3864 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3865 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3866 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3867 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3871 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3872 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3878 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3880 if(!window.OnMoving(&x, &y, w, h))
3882 x = window.scrolledPos.x;
3883 y = window.scrolledPos.y;
3889 SNAPDOWN(x, textCellW);
3890 SNAPDOWN(y, textCellH);
3893 if(!window.style.nonClient)
3895 if(!window.style.fixed /*|| window.style.isDocument*/)
3897 if(!window.style.dontScrollHorz)
3898 x += window.parent.scroll.x;
3899 if(!window.style.dontScrollVert)
3900 y += window.parent.scroll.y;
3904 // Break the anchors for moveable/resizable windows
3905 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3906 if(window.style.fixed)
3908 if(window.state == normal)
3910 window.normalAnchor = Anchor { left = x, top = y };
3911 window.normalSizeAnchor = SizeAnchor { { w, h } };
3912 window.anchored = false;
3916 window.stateAnchor = Anchor { left = x, top = y };
3917 window.stateSizeAnchor = SizeAnchor { { w, h } };
3919 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3920 // TOCHECK: Investigate why the following only redraws the scrollbars
3921 //window.Position(x, y, w, h, false, true, true, true, false, true);
3923 guiApp.movingLast.x = mouseX;
3924 guiApp.movingLast.y = mouseY;
3930 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3933 bool wasMoving = guiApp.windowMoving ? true : false;
3934 bool wasScrolling = guiApp.windowScrolling ? true : false;
3936 while(result && w != this)
3938 Window msgWindow = GetAtPosition(x,y, false, true, w);
3939 Window trueWindow = GetAtPosition(x,y, false, false, w);
3940 bool windowDragged = false;
3945 window = (w && !w.disabled) ? w : null;
3947 if(trueWindow) incref trueWindow;
3949 if(consequential) mods->isSideEffect = true;
3951 UpdateMouseMove(x, y, consequential);
3953 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3955 if(!guiApp.windowCaptured.isEnabled)
3956 guiApp.windowCaptured.ReleaseCapture();
3958 window = guiApp.windowCaptured;
3961 if(trueWindow && activate &&
3962 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3963 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3964 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3965 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3967 if(mods->alt && !mods->ctrl && !mods->shift)
3969 Window moved = trueWindow;
3970 for(moved = trueWindow; moved; moved = moved.parent)
3971 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3976 windowDragged = true;
3978 // Cancel the ALT menu toggling...
3979 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3984 if(window && activate &&
3985 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3986 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3987 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3988 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3990 Window modalWindow = window.FindModal();
3992 /*if(mods->alt && !mods->shift && !mods->ctrl)
3994 Window moved = window;
3995 for(moved = window; moved; moved = moved.parent)
3996 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4001 windowDragged = true;
4003 // Cancel the ALT menu toggling...
4004 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4010 Window activateWindow = modalWindow ? modalWindow : window;
4011 if(activateWindow && !activateWindow.isRemote)
4013 bool doActivation = true;
4014 //bool needToDoActivation = false;
4015 Window check = activateWindow;
4017 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4019 if(!check.style.inactive)
4021 //needToDoActivation = true;
4023 doActivation = false;
4028 if(!needToDoActivation)
4029 doActivation = false;
4032 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4033 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4035 // Let the OnLeftButtonDown do the activating instead
4036 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4044 incref activateWindow;
4045 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4047 delete activateWindow;
4051 if(activateWindow._refCount == 1)
4053 delete activateWindow;
4057 delete activateWindow;
4059 mods->isActivate = true;
4063 if(!modalWindow && window && !window.destroyed)
4065 if(!guiApp.windowCaptured || windowDragged)
4067 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4069 bool moving = ((window.state != maximized &&
4070 window.IsMouseMoving(
4071 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4072 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4074 if(!moving && window.IsMouseResizing(
4075 x - window.absPosition.x,
4076 y - window.absPosition.y,
4077 window.size.w, window.size.h,
4078 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4080 guiApp.windowIsResizing = true;
4081 guiApp.windowResizingBefore.w = window.size.w;
4082 guiApp.windowResizingBefore.h = window.size.h;
4084 if(guiApp.windowIsResizing || windowDragged || moving)
4087 guiApp.windowMoving = window;
4088 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4089 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4090 guiApp.windowMovingBefore.x = window.position.x;//s;
4091 guiApp.windowMovingBefore.y = window.position.y;//s;
4092 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4093 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4096 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4098 if(window.style.fixed &&
4100 window.IsMouseMoving(
4101 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4103 window.ShowSysMenu(x, y);
4107 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4109 if(window.sbv || window.sbh)
4112 guiApp.windowScrolling = window;
4113 guiApp.windowScrollingStart.x = x;
4114 guiApp.windowScrollingStart.y = y;
4115 guiApp.windowScrollingBefore.x = window.scroll.x;
4116 guiApp.windowScrollingBefore.y = window.scroll.y;
4119 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4121 if(window.style.hasMaximize &&
4122 window.IsMouseMoving(
4123 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4126 (window.state == maximized) ? normal : maximized, false, *mods);
4134 if(guiApp.windowMoving)
4136 if(guiApp.windowMoving.parent)
4138 if(guiApp.windowMoving.style.nonClient)
4139 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4141 guiApp.windowMoving.parent.SetMouseRangeToClient();
4145 window.UpdateDecorations();
4148 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4150 // Log("\n*** LEFT BUTTON UP ***\n");
4151 if(guiApp.windowMoving)
4152 guiApp.windowMoving.StopMoving();
4154 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4156 if(guiApp.windowScrolling)
4158 Window windowScrolling = guiApp.windowScrolling;
4159 guiApp.windowScrolling = null;
4160 windowScrolling.ReleaseCapture();
4164 if(!result || (window && window.destroyed)) window = null;
4166 if(window && window.FindModal())
4169 if(trueWindow && trueWindow.FindModal())
4177 msgWindow = GetAtPosition(x,y, true, false);
4179 msgWindow.SelectMouseCursor();
4182 if(guiApp.windowCaptured || trueWindow)
4184 Window prevWindow = guiApp.prevWindow;
4185 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4187 guiApp.prevWindow.mouseInside = false;
4188 guiApp.prevWindow = null;
4190 // Eventually fix this not to include captured?
4191 if(!prevWindow.OnMouseLeave(*mods))
4194 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4196 Box box = trueWindow.box;
4197 box.left += trueWindow.absPosition.x;
4198 box.right += trueWindow.absPosition.x;
4199 box.top += trueWindow.absPosition.y;
4200 box.bottom += trueWindow.absPosition.y;
4202 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4204 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4205 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4207 overX = Max(Min(overX, 32767),-32768);
4208 overY = Max(Min(overY, 32767),-32768);
4210 trueWindow.mouseInside = true;
4211 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4215 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4216 guiApp.prevWindow = trueWindow;
4218 guiApp.prevWindow = null;
4220 SelectMouseCursor();
4222 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4224 int clientX = x - (window.absPosition.x + window.clientStart.x);
4225 int clientY = y - (window.absPosition.y + window.clientStart.y);
4227 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4229 clientX = Max(Min(clientX, 32767),-32768);
4230 clientY = Max(Min(clientY, 32767),-32768);
4232 MouseMethod = (void *)window._vTbl[method];
4234 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4237 if(!MouseMethod(window, clientX, clientY, *mods))
4244 if(result && w && w.clickThrough && w.parent)
4249 if(!result || !w || !w.clickThrough)
4256 // --- Mouse cursor management ---
4258 bool KeyMessage(uint method, Key key, unichar character)
4263 if(guiApp.interimWindow)
4264 this = guiApp.interimWindow;
4267 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4271 if(!style.inactive || rootWindow != this)
4273 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4274 Window modalWindow = FindModal();
4275 Window interimMaster = master ? master.rootWindow : null;
4279 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4280 status = OnSysKeyDown(key, character);
4281 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4282 status = OnSysKeyHit(key, character);
4283 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4284 status = OnSysKeyUp(key, character);
4291 // Process Key Message for Internal UI Keyboard actions
4292 if(status && !destroyed && menuBar && state != minimized)
4295 if((SmartKey)key != alt)
4296 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4299 SmartKey sk = (SmartKey) key;
4300 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4302 status = menuBar.KeyMessage(method, key, character);
4307 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4308 menuBar.OnKeyHit(escape, 0);
4310 if(!menuBar.focus && guiApp.caretOwner)
4311 guiApp.caretOwner.UpdateCaret(true, false);
4314 if(!destroyed && status)
4316 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4320 case left: case up: case right: case down:
4321 if(guiApp.windowMoving == this)
4324 int w = guiApp.windowMoving.size.w;
4325 int h = guiApp.windowMoving.size.h;
4326 int x = guiApp.windowMoving.scrolledPos.x;
4327 int y = guiApp.windowMoving.scrolledPos.y;
4331 if(key == down || key == up)
4332 step = Max(step, textCellH);
4334 step = Max(step, textCellW);
4337 if(guiApp.windowIsResizing)
4341 case left: w-=step; break;
4342 case right: w+=step; break;
4343 case up: h-=step; break;
4344 case down: h+=step; break;
4351 case left: x-=step; break;
4352 case right: x+=step; break;
4353 case up: y-=step; break;
4354 case down: y+=step; break;
4358 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4359 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4361 if(!guiApp.windowIsResizing || guiApp.resizeX)
4362 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4364 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4366 if(!guiApp.windowIsResizing || guiApp.resizeY)
4367 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4369 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4371 guiApp.interfaceDriver.SetMousePosition(x, y);
4372 ConsequentialMouseMove(true);
4380 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4382 guiApp.windowMoving.StopMoving();
4383 ConsequentialMouseMove(false);
4391 ShowSysMenu(absPosition.x, absPosition.y);
4399 if(!destroyed && status && state != minimized)
4401 // Process all the way down the children
4402 if(activeChild && !activeChild.disabled)
4404 status = activeChild.KeyMessage(method, key, character);
4406 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4407 key.code != left && key.code != right && key.code != up && key.code != down)
4409 status = activeClient.KeyMessage(method, key, character);
4413 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4415 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4416 // && defaultControl != activeChild)
4418 delete previousActive;
4419 previousActive = activeChild;
4420 if(previousActive) incref previousActive;
4422 ConsequentialMouseMove(false);
4423 if((defaultControl.active ||
4424 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4425 defaultControl.KeyMessage(method, defaultKey, character);
4431 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4433 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4440 ShowSysMenu(absPosition.x, absPosition.y);
4447 if(this != guiApp.desktop)
4449 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4451 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4453 MenuMoveOrSize(key.shift, true);
4457 else if(guiApp.windowMoving)
4459 guiApp.windowMoving.StopMoving();
4460 ConsequentialMouseMove(false);
4468 if(!destroyed && status && state != minimized)
4470 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4474 case tab: case shiftTab:
4476 Window cycleParent = this;
4477 if(this == guiApp.interimWindow && !master.style.interim && !cycleParent.style.tabCycle)
4478 cycleParent = master.parent;
4480 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4482 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4484 Window child = cycleParent.activeChild;
4486 // Scroll the window to include the active control
4488 if(cycleParent.sbh && !child.style.dontScrollHorz)
4490 if(child.scrolledPos.x < 0)
4491 cycleParent.sbh.Action(Position,
4492 cycleParent.scroll.x + child.scrolledPos.x, 0);
4493 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4494 cycleParent.sbh.Action(Position,
4495 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4497 if(cycleParent.sbv && !child.style.dontScrollVert)
4499 if(child.scrolledPos.y < 0)
4500 cycleParent.sbv.Action(Position,
4501 cycleParent.scroll.y + child.scrolledPos.y, 0);
4502 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4503 cycleParent.sbv.Action(Position,
4504 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4507 cycleParent.ConsequentialMouseMove(false);
4513 case f6: case shiftF6:
4514 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4516 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4517 if(parent == guiApp.desktop)
4518 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4528 if(CycleChildren(key.shift, true, false, true))
4536 // mIRC Style Window Shortcuts
4537 case alt1: case alt2: case alt3: case alt4: case alt5:
4538 case alt6: case alt7: case alt8: case alt9: case alt0:
4543 for(document = children.first; document; document = document.next)
4545 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4547 if(document == activeChild)
4549 if(document.state == minimized)
4550 document.SetState(normal, false, key);
4553 document.SetState(minimized, false, key);
4554 CycleChildren(false, true, false);
4559 if(activeChild.state == maximized && document.style.hasMaximize)
4560 document.SetState(maximized, false, key);
4561 else if(document.state == minimized)
4562 document.SetState(normal, false, key);
4563 document.Activate();
4578 if(!destroyed && status)
4580 if(state == minimized)
4585 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4587 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4589 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4590 previousActive.ActivateEx(true, false, false, true, null, null);
4591 delete previousActive;
4597 if(!destroyed && status)
4599 status = ProcessHotKeys(method, key, character);
4601 if(!destroyed && status && !modalWindow && state != minimized)
4604 status = KeyMethod(this, key, character);
4605 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4606 status = OnKeyHit(key, character);
4607 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4609 bool result = false;
4612 case ctrlUp: case ctrlDown:
4613 if(sbv && !guiApp.windowScrolling)
4614 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4616 case wheelUp: case wheelDown:
4617 if(sbv && !guiApp.windowScrolling)
4619 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4620 // Do we want to do a consequential move regardless of result in this case?
4621 ConsequentialMouseMove(false);
4624 case ctrlPageUp: case ctrlPageDown:
4625 if(sbh && !guiApp.windowScrolling)
4626 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4631 ConsequentialMouseMove(false);
4636 if(status && !destroyed && menuBar && state != minimized)
4637 status = menuBar.KeyMessage(method, key, character);
4639 if(style.interim && /*destroyed && */status && interimMaster)
4641 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4642 status = interimMaster.KeyMessage(method, key, character);
4649 bool ProcessHotKeys(uint method, Key key, unichar character)
4654 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4655 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4656 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4658 Window hotKeyWindow = hotKey.window;
4659 Window parent = hotKeyWindow.parent;
4660 Window prevActiveWindow = activeChild;
4661 // For when sys buttons are placed inside the menu bar
4662 if(parent && parent._class == class(PopupMenu))
4663 parent = parent.parent;
4665 // Don't process non-visible buttons, but make an exception for the Alt-F4 with Native Decorations turned on; This handles alt+enter as well
4666 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4669 if(prevActiveWindow) incref prevActiveWindow;
4670 incref hotKeyWindow;
4671 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4672 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4675 delete hotKeyWindow;
4676 delete prevActiveWindow;
4680 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4681 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4682 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4684 // ********* WORKING ON THIS ***********
4685 if(prevActiveWindow && !guiApp.interimWindow)
4686 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4689 else if(hotKeyWindow.style.inactive)
4690 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4692 delete prevActiveWindow;
4693 delete hotKeyWindow;
4694 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4695 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4699 if(status && tabCycle)
4702 for(child = children.first; child; child = child.next)
4704 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4715 // --- Windows and graphics initialization / termination ---
4716 bool SetupRoot(void)
4720 // Setup relationship with outside world (bb root || !bb)
4721 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4722 (_displayDriver && dispDriver != parent.dispDriver))
4726 tempExtents = new0 Extent[4];
4731 /*if(guiApp.fullScreenMode)
4732 rootWindow = guiApp.desktop;
4734 //rootWindow = parent.created ? parent.rootWindow : null;
4735 rootWindow = parent.rootWindow;
4738 against = &parent.box;
4740 against = &parent.clientArea;
4743 for(child = children.first; child; child = child.next)
4746 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4749 bool Setup(bool positionChildren)
4751 bool result = false;
4754 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && dispDriver != parent.dispDriver))))
4756 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4757 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4759 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4761 // This was here, is it really needed?
4762 //guiApp.interfaceDriver.ActivateRootWindow(this);
4766 displaySystem = DisplaySystem {};
4767 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4769 delete displaySystem;
4774 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4775 if(display.Create(displaySystem, windowHandle))
4782 // Sometimes icon does not show up on Windows XP if we set here...
4783 // guiApp.interfaceDriver.SetIcon(this, icon);
4785 else if(this != guiApp.desktop)
4787 display = rootWindow ? rootWindow.display : null;
4793 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4794 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4796 for(child = children.first; child; child = child.next)
4798 if(child.created && !child.Setup(false))
4804 bool SetupDisplay(void)
4806 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4807 if(is3D) return Window3D_SetupDisplay(this); else
4814 class_data void ** pureVTbl;
4816 bool LoadGraphics(bool creation, bool resetAnchors)
4818 bool result = false;
4819 bool success = false;
4821 WindowState stateBackup = state;
4824 if(!rootWindow.created)
4828 if(((subclass(Window))_class).pureVTbl)
4830 if(_vTbl == _class._vTbl)
4832 _vTbl = ((subclass(Window))_class).pureVTbl;
4837 for(m = 0; m < _class.vTblSize; m++)
4839 if(_vTbl[m] == _class._vTbl[m])
4840 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4844 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4846 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4848 _vTbl = _class._vTbl;
4853 for(m = 0; m < _class.vTblSize; m++)
4855 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4856 _vTbl[m] = _class._vTbl[m];
4861 if(guiApp.fullScreenMode || this != guiApp.desktop)
4863 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4869 display.Lock(false);
4870 if(rootWindow == this)
4872 // Set Color Palette
4873 display.SetPalette(palette, true);
4877 if(guiApp.fullScreenMode && this == guiApp.desktop)
4882 for(c=0; c<SystemCursor::enumSize; c++)
4883 if(!guiApp.systemCursors[c].bitmap)
4885 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4886 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4887 if(guiApp.systemCursors[c].bitmapName)
4889 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4890 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4891 if(guiApp.systemCursors[c].bitmap)
4892 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4897 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4899 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4900 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4902 cursor.bitmap.paletteShades = cursor.paletteShades;
4906 guiApp.cursorUpdate = true;
4909 ConsequentialMouseMove(false);
4915 // Load Window Graphic Resources
4918 if(usedFont == setFont || usedFont == window.systemFont)
4919 RemoveResource(usedFont);
4922 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4925 RemoveResource(systemFont);
4928 RemoveResource(captionFont);
4930 for(ptr = resources.first; ptr; ptr = ptr.next)
4932 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4935 AddResource(setFont);
4937 AddResource(systemFont);
4939 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4946 //if(master && master.font)
4947 if(parent && parent.font)
4951 faceName = parent.font.faceName,
4952 size = parent.font.size,
4953 bold = parent.font.bold,
4954 italic = parent.font.italic,
4955 underline = parent.font.underline
4957 //font = parent.font;
4958 watch(parent) { font { } };
4961 font = guiApp.currentSkin.SystemFont();
4968 captionFont = guiApp.currentSkin.CaptionFont();
4969 AddResource(captionFont);
4971 if(OnLoadGraphics())
4977 //SetScrollLineStep(sbStep.x, sbStep.y);
4979 if(this != guiApp.desktop)
4983 normalAnchor = anchor;
4984 normalSizeAnchor = sizeAnchor;
4987 // Break the anchors for moveable/resizable windows
4989 if(style.fixed && style.isDocument)
4991 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5003 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5004 stateSizeAnchor = SizeAnchor {};
5009 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5014 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5015 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5018 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5022 stateAnchor = normalAnchor;
5023 stateSizeAnchor = normalSizeAnchor;
5026 position = Point { };
5027 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5038 if(Position(x, y, w, h, true, false, true, true, true, true))
5040 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5043 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5060 success = result = true;
5063 if(!creation && result)
5065 // Load menu bar first because sys buttons are on it...
5068 if(!menuBar.LoadGraphics(false, resetAnchors))
5074 for(child = children.first; child; child = child.next)
5076 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5083 CreateSystemChildren();
5087 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5090 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5095 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5096 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5099 // Do this here to avoid problems on Windows
5100 if(stateBackup == maximized)
5101 property::state = maximized;
5105 void UnloadGraphics(bool destroyWindows)
5109 // Free children's graphics
5110 for(child = children.first; child; child = child.next)
5111 child.UnloadGraphics(destroyWindows);
5114 display.Lock(false);
5117 if(guiApp.fullScreenMode && this == guiApp.desktop)
5122 for(c=0; c<SystemCursor::enumSize; c++)
5123 if(guiApp.systemCursors[c].bitmap)
5124 delete guiApp.systemCursors[c].bitmap;
5126 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5127 delete cursor.bitmap;
5129 guiApp.cursorBackground.Free();
5132 if(display && display.displaySystem)
5136 for(ptr = resources.first; ptr; ptr = ptr.next)
5140 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5145 // Free window graphics
5148 // Free skin graphics
5149 if(rootWindow == this)
5151 DisplaySystem displaySystem = display.displaySystem;
5154 display.driverData = null;
5155 display.displaySystem = null;
5159 if(displaySystem && !displaySystem.numDisplays && !is3D)
5160 delete displaySystem;
5169 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5170 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5172 if(this == guiApp.desktop || parent == guiApp.desktop)
5174 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5175 guiApp.interfaceDriver.DestroyRootWindow(this);
5179 // --- Window Hiding ---
5181 void SetVisibility(bool state)
5183 bool visible = (style.hidden || !created) ? false : state;
5184 if(visible != this.visible)
5188 this.visible = visible;
5189 for(child = children.first; child; child = child.next)
5190 child.SetVisibility(visible);
5192 ConsequentialMouseMove(false);
5193 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5197 // --- Windows and graphics initialization / termination ---
5199 bool DisplayModeChanged(void)
5201 bool result = false;
5202 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5204 guiApp.modeSwitching = true;
5205 UnloadGraphics(false);
5207 if(LoadGraphics(false, false))
5209 guiApp.modeSwitching = false;
5214 // --- Window updates system ---
5216 void UpdateDirty(Box updateBox)
5218 if(!manageDisplay) { OnRedraw(null);return; }
5221 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5224 if(display.flags.flipping)
5227 rootWindow.UpdateDisplay();
5230 UpdateBackDisplay(updateBox);
5232 if(guiApp.fullScreenMode)
5234 guiApp.cursorUpdate = true;
5235 guiApp.PreserveAndDrawCursor();
5237 if(guiApp.fullScreenMode)
5238 guiApp.RestoreCursorBackground();
5244 // This function is strictly called as a result of system window activation
5245 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5248 Window interimMaster = null;
5249 Window interimWindow = guiApp.interimWindow;
5250 if(interimWindow && interimWindow.master)
5251 interimMaster = interimWindow.master.rootWindow;
5253 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5254 // SetState(normal, false, 0);
5255 SetState(lastState, false, 0);
5257 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5261 /* WTH is this doing here?
5262 while(swap && swap.activeChild)
5264 swap = swap.activeChild;
5267 // TESTING THIS BEFORE...
5268 if(interimWindow && this == interimMaster)
5272 // Window interimSwap = this;
5273 Window menuBar = this.menuBar;
5274 if(menuBar && interimWindow.master == menuBar)
5277 while(interimSwap && interimSwap.activeChild)
5278 interimSwap = interimSwap.activeChild;
5280 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5281 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5283 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5284 //result = ActivateEx(true, true, false, activateRoot, window, null);
5289 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5290 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5292 if(interimWindow == this && interimMaster && !active)
5294 while(interimMaster && interimMaster.interim && interimMaster.master)
5296 // printf("Going up one master %s\n", interimMaster._class.name);
5297 interimMaster = interimMaster.master.rootWindow;
5299 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5300 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5306 bool DestroyEx(int returnCode)
5309 Timer timer, nextTimer;
5311 OldLink prevOrder = null;
5312 Window client = null;
5314 if(parent) stopwatching(parent, font);
5316 // if(window.modalSlave) return false;
5317 if(destroyed || !created)
5324 OldLink slave = master.slaves.FindLink(this);
5325 master.slaves.Delete(slave);
5328 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5334 this.returnCode = (DialogResult)returnCode;
5336 AcquireInput(false);
5341 master.hotKeys.Delete(hotKey);
5345 if(guiApp.prevWindow == this)
5347 guiApp.prevWindow = null;
5350 if(guiApp.caretOwner == this)
5352 guiApp.interfaceDriver.SetCaret(0,0,0);
5353 UpdateCaret(false, true);
5354 guiApp.caretEnabled = false;
5359 parent.childrenCycle.Remove(cycle);
5363 OldLink tmpPrev = order.prev;
5364 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5365 prevOrder = tmpPrev;
5368 client = tmpPrev ? tmpPrev.data : null;
5369 if(client == this) { client = null; break; }
5370 if(client && (client.style.hidden || client.destroyed || !client.created))
5371 tmpPrev = client.order.prev;
5375 prevOrder = tmpPrev;
5380 // If this window can be an active client, make sure the next window we activate can also be one
5381 if(!style.nonClient && style.isActiveClient)
5383 tmpPrev = prevOrder;
5386 client = tmpPrev ? tmpPrev.data : null;
5387 if(client == this) { client = null; break; }
5388 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5389 tmpPrev = client.order.prev;
5393 prevOrder = tmpPrev;
5397 if(client && client.style.hidden) client = null;
5399 // parent.childrenOrder.Remove(order);
5402 if(parent && style.isActiveClient && visible)
5404 if(state == minimized) parent.numIcons--;
5405 parent.numPositions--;
5408 // TESTING THIS HERE!
5412 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5413 // to create a window inside a rootwindow that's being destroyed)
5414 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5416 if(master && !master.destroyed /*&&
5417 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5419 if(master.defaultControl == this)
5420 master.defaultControl = null;
5423 parent.OnChildAddedOrRemoved(this, true);
5424 if(parent && !parent.destroyed /*&&
5425 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5427 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5429 if(order && prevOrder && prevOrder.data != this && active)
5431 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5433 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5434 if(parent.activeClient == this)
5436 parent.activeClient = null;
5437 parent.UpdateActiveDocument(null);
5442 if(guiApp.interimWindow == this)
5445 PropagateActive(false, null, &goOn, true);
5449 //if(window.parent.activeChild == window)
5450 parent.activeChild = null;
5451 if(!style.nonClient /*&& style.isActiveClient*/)
5453 Window previous = parent.activeClient;
5454 if(style.isActiveClient)
5455 parent.activeClient = null;
5456 parent.UpdateActiveDocument(previous);
5461 else if(parent.activeClient == this)
5463 parent.activeClient = client;
5464 parent.UpdateActiveDocument(this);
5468 if(guiApp.interimWindow == this)
5470 guiApp.interimWindow = null;
5471 if(guiApp.caretOwner)
5473 Window desktop = guiApp.desktop;
5474 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5475 guiApp.caretOwner.UpdateCaret(false, false);
5480 if(_isModal && master && master.modalSlave == this)
5481 master.modalSlave = null;
5485 if(!guiApp.caretOwner && parent.caretSize)
5487 guiApp.caretOwner = parent;
5488 parent.UpdateCaret(false, false);
5489 parent.Update(null);
5492 // Why was this commented out?
5493 GetRidOfVirtualArea();
5499 dirtyArea.Free(null);
5500 dirtyBack.Free(null);
5501 scrollExtent.Free(null);
5503 /* ATTEMPTING TO MOVE THAT ABOVE
5512 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5513 for(;(child = window.children.first);)
5515 for(; child && (child.destroyed || !child.created); child = child.next);
5524 UnloadGraphics(true);
5527 delete previousActive;
5530 // statusBar = null;
5533 if(master && !master.destroyed)
5535 //master.NotifyDestroyed(this, this.returnCode);
5536 NotifyDestroyed(master, this, this.returnCode);
5539 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5541 nextTimer = timer.next;
5542 if(timer.window == this)
5544 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5545 // timer.window = null;
5551 if(this == guiApp.windowMoving)
5554 if(guiApp.windowCaptured == this)
5556 //guiApp.windowCaptured = null;
5558 if(rootWindow != this && rootWindow)
5559 rootWindow.ConsequentialMouseMove(false);
5567 //for(child = children.first; next = child ? child.next : null, child; child = next)
5568 for(;(child = children.first); )
5570 for(; child && (child.destroyed || !child.created); child = child.next);
5580 /* // MOVED THIS UP...
5583 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5584 for(;(child = window.children.first); )
5586 for(; child && (child.destroyed || !child.created); child = child.next);
5595 while((slave = slaves.first))
5597 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5599 ((Window)slave.data).DestroyEx(0);
5604 if(guiApp.caretOwner == this)
5605 guiApp.caretOwner = null;
5607 sysButtons[0] = null;
5608 sysButtons[1] = null;
5609 sysButtons[2] = null;
5612 if(rootWindow != this)
5614 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5617 box.left -= parent.clientStart.x;
5618 box.top -= parent.clientStart.y;
5619 box.right -= parent.clientStart.x;
5620 box.bottom -= parent.clientStart.y;
5622 if(parent) parent.Update(box);
5627 OldLink slave = master.slaves.FindVoid(this);
5628 master.slaves.Delete(slave);
5634 parent.children.Remove(this);
5639 //autoCreate = false;
5642 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5643 if(((subclass(Window))_class).pureVTbl)
5645 if(_vTbl == _class._vTbl)
5647 _vTbl = ((subclass(Window))_class).pureVTbl;
5652 for(m = 0; m < _class.vTblSize; m++)
5654 if(_vTbl[m] == _class._vTbl[m])
5655 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5664 void SetStateEx(WindowState newState, bool activate)
5667 WindowState prevState = state;
5671 if(prevState != newState)
5672 lastState = prevState;
5674 if(rootWindow != this || !nativeDecorations || !windowHandle)
5676 if(style.isActiveClient && !style.hidden && prevState == minimized)
5679 // This block used to be at the end of the function... moved it for flicker problem in X
5680 // ------------------------------------------------------
5684 stateAnchor = normalAnchor;
5685 stateSizeAnchor = normalSizeAnchor;
5688 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5689 stateSizeAnchor = SizeAnchor {};
5693 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5696 byte * idBuffer = new0 byte[size];
5698 for(child = parent.children.first; child; child = child.next)
5700 if(child != this && child.state == minimized)
5702 if(child.iconID > size - 2)
5704 idBuffer = renew0 idBuffer byte[size*2];
5705 memset(idBuffer + size, 0, size);
5708 idBuffer[child.iconID] = (byte)bool::true;
5711 for(c = 0; c<size; c++)
5716 if(style.isActiveClient && !style.hidden)
5719 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5720 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5724 // TOCHECK: Why was this here?
5725 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5726 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5727 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5729 Position(x, y, w, h, true, true, true, true, false, true);
5731 if(!style.inactive && !style.interim && this == parent.activeClient)
5732 parent.UpdateActiveDocument(null);
5735 CreateSystemChildren();
5736 // ------------------------------------------------------
5739 int GetPositionID(Window forChild)
5743 byte * idBuffer = new0 byte[size];
5746 for(child = children.first; child; child = child.next)
5748 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5750 if(child.positionID > size - 2)
5752 idBuffer = renew0 idBuffer byte[size*2];
5753 memset(idBuffer + size, 0, size);
5756 idBuffer[child.positionID] = (byte)bool::true;
5759 for(c = 0; c<size; c++)
5766 // --- Window related graphics ---
5768 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5770 palette = newPalette;
5771 if(rootWindow.display)
5772 rootWindow.display.SetPalette(palette, colorMatch);
5775 public bool AcquireInput(bool acquired)
5778 if(acquiredInput != acquired)
5780 if(active || (!visible && creationActivation == activate))
5781 result = AcquireInputEx(acquired);
5786 acquiredInput = acquired ? result : !result;
5791 void ListChildren(ListBox listBox)
5795 for(child = children.first; child; child = child.next)
5797 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5799 DataRow row = listBox.AddRow();
5800 row.tag = (int)child;
5801 child.FigureCaption(caption);
5802 row.SetData(null, caption);
5807 void UpdateVisual(Box extent)
5809 if(guiApp.driver != null)
5811 if(guiApp.fullScreenMode && guiApp.desktop.display)
5813 guiApp.desktop.mutex.Wait();
5814 guiApp.desktop.display.Lock(true);
5817 if(guiApp.desktop.active)
5819 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5821 if(guiApp.desktop.display.flags.flipping)
5822 guiApp.desktop.Update(null);
5823 guiApp.desktop.UpdateDisplay();
5824 guiApp.cursorUpdate = true;
5826 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5828 guiApp.PreserveAndDrawCursor();
5829 // guiApp.desktop.display.ShowScreen();
5830 guiApp.cursorUpdate = false;
5831 guiApp.desktop.dirty = false;
5832 guiApp.RestoreCursorBackground();
5836 guiApp.desktop.display.Unlock();
5837 guiApp.desktop.mutex.Release();
5841 Window rootWindow = this.rootWindow;
5842 rootWindow.mutex.Wait();
5847 guiApp.SignalEvent();
5850 guiApp.waitMutex.Wait();
5851 guiApp.interfaceDriver.Lock(rootWindow);
5852 if(!rootWindow.style.hidden && rootWindow.dirty)
5854 if(rootWindow.display)
5856 rootWindow.UpdateDisplay();
5857 //rootWindow.display.ShowScreen(null);
5859 rootWindow.dirty = false;
5861 guiApp.interfaceDriver.Unlock(rootWindow);
5862 guiApp.waitMutex.Release();
5865 rootWindow.mutex.Release();
5870 void UnlockDisplay(void)
5872 guiApp.interfaceDriver.Unlock(rootWindow);
5875 void LockDisplay(void)
5877 guiApp.interfaceDriver.Lock(rootWindow);
5880 Surface GetSurface(Box box)
5882 return Redraw((box == null) ? this.box : box);
5885 void SetMousePosition(int x, int y)
5887 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5891 void IntegrationActivate(bool active)
5893 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5895 isForegroundWindow = true;
5896 ActivateEx(active, active, false, false, null, null);
5897 isForegroundWindow = false;
5902 Window QueryCapture(void)
5904 return guiApp.windowCaptured;
5907 int GetDocumentID(void)
5911 byte * idBuffer = new0 byte[size];
5914 for(child = children.first; child; child = child.next)
5916 // TO CHECK: Do we want a documentID when we already have a file name?
5917 if(child.style.isDocument && !child.fileName)
5919 if(child.documentID-1 > size - 2)
5921 idBuffer = renew0 idBuffer byte[size*2];
5922 memset(idBuffer + size, 0, size);
5925 idBuffer[child.documentID-1] = 1;
5928 for(c = 0; c<size; c++)
5936 void SetInitSize(Size size)
5939 sizeAnchor.size = size;
5940 normalSizeAnchor = sizeAnchor;
5942 // Break the anchors for moveable/resizable windows
5943 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5945 stateAnchor = normalAnchor;
5946 stateSizeAnchor = normalSizeAnchor;
5948 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5949 Position(x,y, w, h, true, true, true, true, false, true);
5953 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5955 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5957 guiApp.windowIsResizing = resize;
5958 guiApp.windowMoving = this;
5959 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5960 if(guiApp.windowIsResizing)
5962 guiApp.windowMovingStart.x += size.w - 1;
5963 guiApp.windowMovingStart.y += size.h - 1;
5965 guiApp.windowMovingBefore = scrolledPos;
5966 guiApp.windowResizingBefore = size;
5967 guiApp.windowMoving.UpdateDecorations();
5968 if(guiApp.windowIsResizing)
5969 guiApp.resizeEndX = guiApp.resizeEndY = true;
5971 if(setCursorPosition)
5972 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5976 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5977 guiApp.windowMovingStart.x += x - absPosition.x;
5978 guiApp.windowMovingStart.y += y - absPosition.y;
5981 if(guiApp.windowMoving)
5983 if(guiApp.windowMoving.style.nonClient)
5984 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5986 guiApp.windowMoving.parent.SetMouseRangeToClient();
5991 if(this == rootWindow)
5992 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6000 bool result = false;
6004 else if(guiApp && guiApp.driver != null)
6006 void * systemParent = null;
6007 OldLink slaveHolder;
6009 bool visible = !style.hidden;
6013 systemParent = parent;
6014 parent = guiApp.desktop;
6016 last = parent ? parent.children.last : null;
6018 if((parent && parent != guiApp.desktop && !parent.created) ||
6019 (master && master != guiApp.desktop && !master.created))
6023 stopwatching(parent, font);
6026 property::parent = guiApp.desktop;
6027 if(!master) master = parent;
6029 if(_isModal && master.modalSlave)
6030 property::master = master.modalSlave;
6034 parent.children.Remove(this);
6037 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6038 if(slaveHolder.data == this)
6040 master.slaves.Delete(slaveHolder);
6045 if(parent == guiApp.desktop && !mutex)
6048 if(style.isDocument)
6051 parent.numDocuments--;
6052 documentID = parent.GetDocumentID();
6055 if(!style.stayOnTop)
6056 for(; last && last.style.stayOnTop; last = last.prev);
6058 parent.children.Insert((last == this) ? null : last, this);
6059 //parent.children.Add(this);
6062 dispDriver = parent.dispDriver;
6065 master.modalSlave = this;
6067 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6072 master.slaves.Add(slaveHolder = OldLink { data = this });
6077 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6079 if(style.isDefault && !master.defaultControl)
6080 master.defaultControl = this;
6082 stateAnchor = normalAnchor = anchor;
6083 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6085 // TOCHECK: Why is this here?
6086 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6087 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6089 this.visible = false;
6090 style.hidden = true;
6093 // autoCreate = true;
6101 if(parent == guiApp.desktop)
6102 Log("LoadGraphics %s\n", caption);
6104 if(LoadGraphics(true, false))
6112 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6119 if(style.hasMenuBar /*&& menu*/)
6125 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6126 interim = false, inactive = true, nonClient = true, size.h = 24
6134 // Create the system buttons
6135 CreateSystemChildren();
6137 UpdateActiveDocument(null);
6139 if(style.isDocument)
6143 MenuItem item = menu.FindItem(MenuFileSave, 0);
6144 if(item) item.disabled = !modifiedDocument && fileName;
6149 if(parent == guiApp.desktop)
6150 Log("Preemptive SetState %s\n", caption);
6153 // Preemptive Set State to ensure proper anchoring
6154 SetStateEx(state, false);
6156 style.hidden = true;
6162 for(child = children.first; child; child = next)
6165 if(!child.created && (child.autoCreate || child.wasCreated))
6172 for(link = slaves.first; link; link = next)
6174 Window slave = link.data;
6176 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6179 // Things might have happened that invalidated 'next'...
6180 // Start over the search for slaves to create.
6181 // (Added this to fix crash with Stacker & Toolbar)
6182 next = slaves.first;
6191 if(parent == guiApp.desktop)
6192 Log("Real SetState %s\n", caption);
6195 if(isActiveClient && visible)
6197 parent.numPositions--;
6198 if(state == minimized) parent.numIcons--;
6201 parent.OnChildAddedOrRemoved(this, false);
6203 // Real set state & activate for proper display & activation
6204 property::visible = visible;
6205 // SetState(state & 0x00000003, true, 0);
6206 guiApp.interfaceDriver.SetIcon(this, icon);
6211 /*if(rootWindow == this)
6212 guiApp.interfaceDriver.ActivateRootWindow(this);
6214 if(creationActivation == activate)
6215 ActivateEx(true, false, true, true, null, null);
6216 else if(creationActivation == flash)
6221 rootWindow.ConsequentialMouseMove(false);
6232 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6238 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6240 //style.hidden = true; // !visible;
6241 style.hidden = !visible;
6242 if(master.modalSlave == this)
6243 master.modalSlave = null;
6250 void WriteCaption(Surface surface, int x, int y)
6253 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6256 void Update(Box region)
6262 rootWindow = this.rootWindow;
6264 // rootWindow.mutex.Wait();
6265 if(!destroyed && visible && display)
6270 // Testing this to avoid repetitve full update to take time...
6271 if(dirtyArea.count == 1)
6273 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6274 if(item.box.left <= box.left &&
6275 item.box.top <= box.top &&
6276 item.box.right >= box.right &&
6277 item.box.bottom >= box.bottom)
6279 rootWindow.dirty = true;
6284 if(display.flags.flipping && !rootWindow.dirty)
6286 if(this == rootWindow)
6290 rootWindow.Update(null);
6295 rootWindow.dirty = true;
6300 realBox.left += clientStart.x;
6301 realBox.top += clientStart.y;
6302 realBox.right += clientStart.x;
6303 realBox.bottom += clientStart.y;
6309 if(realBox.right >= realBox.left &&
6310 realBox.bottom >= realBox.top)
6312 // if(!rootWindow.fullRender)
6313 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6315 for(child = children.first; child; child = child.next)
6320 box.left -= child.absPosition.x - absPosition.x;
6321 box.top -= child.absPosition.y - absPosition.y;
6322 box.right -= child.absPosition.x - absPosition.x;
6323 box.bottom -= child.absPosition.y - absPosition.y;
6324 if(box.right >= child.box.left && box.left <= child.box.right &&
6325 box.bottom >= child.box.top && box.top <= child.box.bottom)
6327 box.left -= child.clientStart.x;
6328 box.top -= child.clientStart.y;
6329 box.right -= child.clientStart.x;
6330 box.bottom -= child.clientStart.y;
6336 realBox.left += absPosition.x - rootWindow.absPosition.x;
6337 realBox.top += absPosition.y - rootWindow.absPosition.y;
6338 realBox.right += absPosition.x - rootWindow.absPosition.x;
6339 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6340 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6343 else if(this == guiApp.desktop)
6346 for(window = children.first; window; window = window.next)
6352 Box childBox = region;
6354 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6355 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6356 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6357 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6359 window.Update(childBox);
6362 window.Update(null);
6367 // rootWindow.mutex.Release();
6374 if(guiApp.windowCaptured != this)
6376 if(guiApp.windowCaptured)
6380 //Logf("Captured %s (%s)\n", caption, class.name);
6381 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6382 guiApp.windowCaptured = this;
6388 bool Destroy(int code)
6393 if(!destroyed && !CloseConfirmation(false)) return false;
6397 // TOCHECK: Should autoCreate be set to false here?
6408 void Move(int x, int y, int w, int h)
6410 normalAnchor = Anchor { left = x, top = y };
6411 normalSizeAnchor = SizeAnchor { size = { w, h } };
6413 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6415 if(destroyed) return;
6417 stateAnchor = normalAnchor;
6418 stateSizeAnchor = normalSizeAnchor;
6420 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6421 Position(x,y, w, h, true, true, true, true, false, true);
6425 DialogResult Modal(void)
6431 // FIXES MEMORY LEAK IF Create() FAILED
6437 void SetScrollArea(int width, int height, bool snapToStep)
6439 bool resize = false;
6442 int stepX = sbStep.x, stepY = sbStep.y;
6443 // Needed to make snapped down position match the skin's check of client area
6444 // against realvirtual
6447 SNAPDOWN(stepX, textCellW);
6448 SNAPDOWN(stepY, textCellH);
6449 stepX = Max(stepX, textCellW);
6450 stepY = Max(stepY, textCellH);
6452 if(scrollFlags.snapX)
6453 SNAPUP(width, stepX);
6454 if(scrollFlags.snapY)
6455 SNAPUP(height, stepY);
6458 reqScrollArea.w = width;
6459 reqScrollArea.h = height;
6460 noAutoScrollArea = (width > 0 || height > 0);
6462 UpdateScrollBars(true, true);
6465 void SetScrollPosition(int x, int y)
6468 sbh.Action(setPosition, x, 0);
6472 int seen = clientSize.w, total = reqScrollArea.w;
6474 if(scrollFlags.snapX)
6475 SNAPDOWN(seen, sbStep.x);
6477 if(!total) total = seen;
6478 range = total - seen + 1;
6479 range = Max(range, 1);
6481 if(x >= range) x = range - 1;
6483 if(scrollFlags.snapX)
6484 SNAPUP(x, sbStep.x);
6487 OnHScroll(setPosition, x, 0);
6491 SNAPDOWN(x, textCellW);
6497 sbv.Action(setPosition, y, 0);
6501 int seen = clientSize.h, total = reqScrollArea.h;
6504 if(scrollFlags.snapY)
6505 SNAPDOWN(seen, sbStep.y);
6507 if(!total) total = seen;
6508 range = total - seen + 1;
6509 range = Max(range, 1);
6511 if(y >= range) y = range - 1;
6513 if(scrollFlags.snapY)
6514 SNAPUP(y, sbStep.y);
6517 OnVScroll(setPosition, y, 0);
6520 SNAPDOWN(y, textCellH);
6525 UpdateCaret(false, false);
6528 void SetScrollLineStep(int stepX, int stepY)
6534 SNAPDOWN(stepX, textCellW);
6535 SNAPDOWN(stepY, textCellH);
6536 stepX = Max(stepX, textCellW);
6537 stepY = Max(stepY, textCellH);
6540 sbh.lineStep = stepX;
6542 sbv.lineStep = stepY;
6545 void SetState(WindowState newState, bool activate, Modifiers mods)
6549 if(state == newState || OnStateChange(newState, mods))
6551 WindowState prevState = state;
6555 // This used to be at the end of the brackets... moved for X, testing...
6556 // This has the effect of activating the window through the system...
6557 if(rootWindow == this)
6558 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6560 SetStateEx(newState, activate);
6562 if(rootWindow == this && !rootWindow.nativeDecorations)
6564 int x = position.x, y = position.y;
6567 x -= guiApp.desktop.absPosition.x;
6568 y -= guiApp.desktop.absPosition.y;
6570 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6574 //state = prevState;
6576 if(state != maximized && style.hasMaximize)
6579 for(child = parent.children.first; child; child = child.next)
6581 if(child != this && child.state == maximized)
6582 child.SetStateEx(normal, false);
6586 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6587 parent.UpdateScrollBars(true, true);
6590 // Do we really need this stuff here?
6591 // Shouldn't the Activate stuff take care of it?
6592 if(parent.rootWindow == parent && style)
6595 parent.FigureCaption(caption);
6596 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6597 parent.UpdateDecorations();
6601 rootWindow.ConsequentialMouseMove(false);
6608 BitmapResource GetIcon(SkinBitmap iconID)
6610 return guiApp.currentSkin.GetBitmap(iconID);
6613 void SetMouseRange(Box range)
6615 if(range || guiApp.fullScreenMode)
6620 clip.left = range.left + absPosition.x + clientStart.x;
6621 clip.top = range.top + absPosition.y + clientStart.y;
6622 clip.right = range.right + absPosition.x + clientStart.x;
6623 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6627 clip.left = guiApp.desktop.box.left;
6628 clip.top = guiApp.desktop.box.top;
6629 clip.right = guiApp.desktop.box.right;
6630 clip.bottom = guiApp.desktop.box.bottom;
6632 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6635 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6638 void SetMouseRangeToClient(void)
6640 if(guiApp.fullScreenMode || this != guiApp.desktop)
6642 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6643 box.Clip(clientArea);
6647 SetMouseRange(null);
6650 void SetMouseRangeToWindow(void)
6652 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6653 if(this == guiApp.desktop)
6654 SetMouseRangeToClient();
6659 // x, y: Desktop Coordinates
6660 void ShowSysMenu(int x, int y)
6663 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6666 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6667 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6671 menu, $"Move", m, NotifySelect = MenuWindowMove,
6672 disabled = !style.fixed || state == maximized
6676 menu, $"Size", s, NotifySelect = MenuWindowSize,
6677 disabled = !style.sizable || state != normal
6681 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6682 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6686 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6687 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6691 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6692 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6694 MenuDivider { menu };
6697 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6698 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6700 windowMenu.Create();
6705 ActivateEx(true, true, true, true, null, null);
6708 void MakeActive(void)
6710 ActivateEx(true, false, true, false, null, null);
6713 void SoftActivate(void)
6715 if(guiApp.desktop.active)
6721 void Deactivate(void)
6723 ActivateEx(false, true, true, true, null, null);
6728 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6731 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6733 bool result = false;
6734 if(activeChild && activeChild.cycle)
6736 Window modalWindow, child = activeChild;
6737 if(!clientOnly /*&& parent.tabCycle*/)
6739 Window next = child;
6742 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6746 if(parent && parent.CycleChildren(backward, false, true, true))
6754 next = next.cycle.prev.data;
6756 next = next.cycle.next.data;
6757 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6762 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6763 parent.tabCycle && parent.CycleChildren(backward, false, false))
6767 if(tabCycleOnly && !tabCycle) return false;
6774 child = child.cycle.prev.data;
6776 child = child.cycle.next.data;
6777 if(child == child.parent.activeChild)
6779 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6782 modalWindow = child.FindModal();
6785 // Scroll the window to include the active control
6786 if(sbh && !child.style.dontScrollHorz)
6788 if(child.scrolledPos.x < 0)
6789 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6790 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6791 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6793 if(sbv && !child.style.dontScrollVert)
6795 if(child.scrolledPos.y < 0)
6796 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6797 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6798 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6802 child = modalWindow ? modalWindow : child;
6803 child.ActivateEx(true, true, true, true, null, null);
6804 if(child.tabCycle && child.childrenCycle.first)
6805 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6813 ConsequentialMouseMove(false);
6817 void AddResource(Resource resource)
6821 ResPtr ptr { resource = resource };
6825 // Load Graphics here if window is created already
6826 if(/*created && */display)
6828 display.Lock(false);
6829 ptr.loaded = display.displaySystem.LoadResource(resource);
6833 // Temporary hack to load font right away for listbox in dropbox ...
6834 else if(master && master.display)
6836 master.display.Lock(false);
6837 master.display.displaySystem.LoadResource(resource);
6838 master.display.Unlock();
6844 void RemoveResource(Resource resource)
6849 for(ptr = resources.first; ptr; ptr = ptr.next)
6851 if(ptr.resource == resource)
6857 // Unload Graphics here if window is created already
6858 if(/*created && */display)
6862 display.Lock(false);
6863 display.displaySystem.UnloadResource(resource, ptr.loaded);
6869 resources.Delete(ptr);
6874 void SetCaret(int x, int y, int size)
6881 if(active && !style.interim)
6883 if(visible || !guiApp.caretOwner)
6884 guiApp.caretOwner = size ? this : null;
6886 UpdateCaret(false, false);
6889 guiApp.interfaceDriver.SetCaret(0,0,0);
6890 UpdateCaret(false, true);
6891 guiApp.caretEnabled = false;
6894 else if(style.inactive && active)
6896 guiApp.interfaceDriver.SetCaret(0,0,0);
6897 UpdateCaret(false, true);
6898 guiApp.caretEnabled = false;
6903 void Scroll(int x, int y)
6905 bool opaque = !style.drawBehind || background.a;
6906 if(opaque && display && display.flags.scrolling)
6908 Box box = clientArea;
6909 box.left += clientStart.x;
6910 box.top += clientStart.y;
6911 box.right += clientStart.x;
6912 box.bottom += clientStart.y;
6914 //scrollExtent.Free(null);
6915 scrollExtent.AddBox(box);
6916 scrolledArea.x += x;
6917 scrolledArea.y += y;
6919 //scrollExtent.Free();
6920 //scrollExtent.AddBox(clientArea);
6921 //scrollExtent.Offset(clientStart.x, clientStart.y);
6922 //scrolledArea.x = x;
6923 //scrolledArea.y = y;
6929 rootWindow.dirty = true;
6932 void ReleaseCapture()
6934 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6936 Window oldCaptured = guiApp.windowCaptured;
6937 guiApp.windowCaptured = null;
6938 guiApp.prevWindow = null;
6941 //guiApp.Log("Released Capture\n");
6943 guiApp.interfaceDriver.SetMouseCapture(null);
6945 //oldCaptured.OnMouseCaptureLost();
6948 oldCaptured.ConsequentialMouseMove(false);
6953 void SetText(char * format, ...)
6960 char caption[MAX_F_STRING];
6962 va_start(args, format);
6963 vsprintf(caption, format, args);
6966 this.caption = new char[strlen(caption)+1];
6968 strcpy(this.caption, caption);
6977 bool Grab(Bitmap bitmap, Box box, bool decorations)
6979 bool result = false;
6980 if(display || this == guiApp.desktop)
6982 Box clip = {MININT, MININT, MAXINT, MAXINT};
6988 clip.Clip(clientArea);
6990 clip.Clip(this.box);
6992 if(rootWindow != this)
6994 clip.left += absPosition.y;
6995 clip.top += absPosition.y;
6996 clip.right += absPosition.x;
6997 clip.bottom += absPosition.y;
7000 clip.left += decorations ? 0 : clientStart.x;
7001 clip.top += decorations ? 0 : clientStart.y;
7002 clip.right += decorations ? 0 : clientStart.x;
7003 clip.bottom += decorations ? 0 : clientStart.y;
7005 if(display && display.flags.flipping)
7007 rootWindow.Update(null);
7008 rootWindow.UpdateDisplay();
7015 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7016 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7020 result = display.Grab(bitmap, clip.left, clip.top,
7021 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7023 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7025 if(!bitmap.Convert(null, pixelFormat888, null))
7032 void GetMousePosition(int * x, int * y)
7034 int mouseX = 0, mouseY = 0;
7035 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7038 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7039 if(this != guiApp.desktop)
7041 mouseX -= absPosition.x + clientStart.x;
7042 mouseY -= absPosition.y + clientStart.y;
7049 DialogResult DoModal()
7051 DialogResult returnCode = 0;
7052 int terminated = terminateX;
7055 while(!destroyed && guiApp.driver != null)
7057 if(terminateX != terminated)
7059 terminated = terminateX;
7060 guiApp.desktop.Destroy(0);
7061 if(guiApp.desktop.created)
7064 //printf("Resetting terminate X to 0\n");
7070 guiApp.UpdateDisplay();
7071 if(!guiApp.ProcessInput(false))
7074 returnCode = this.returnCode;
7087 return !destroyed && guiApp.driver != null && terminateX < 2;
7090 DialogResult DoModalEnd()
7092 DialogResult returnCode = this.returnCode;
7097 // --- Window manipulation ---
7098 /*bool GetDisabled()
7100 bool disabled = this.disabled;
7102 for(window = this; (window = window.master); )
7113 // --- Mouse Manipulation ---
7114 void GetNCMousePosition(int * x, int * y)
7116 GetMousePosition(x, y);
7117 if(x) *x += clientStart.x;
7118 if(y) *y += clientStart.y;
7121 // --- Carets manipulation ---
7122 void GetCaretPosition(Point caretPos)
7124 caretPos = this.caretPos;
7127 int GetCaretSize(void)
7132 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7138 bool CloseConfirmation(bool parentClosing)
7151 if(!OnClose(parentClosing))
7154 // If you want to skip this, simply set modifiedDocument to false in OnClose
7155 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7157 DialogResult dialogRes;
7160 sprintf(message, $"Save changes to %s?", fileName);
7162 sprintf(message, $"Save changes to Untitled %d?", documentID);
7164 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7166 if(dialogRes == yes)
7168 // TOFIX: Precomp error if brackets are taken out
7169 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7171 else if(dialogRes == cancel)
7177 for(slave = slaves.first; slave; slave = slave.next)
7179 Window w = slave.data;
7180 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7182 // ((Window)slave.data).CloseConfirmation(true);
7191 for(child = children.first; child; child = child.next)
7192 if(child.master != this && !child.CloseConfirmation(true))
7202 // Static methods... move them somewhere else?
7203 void ::RestoreCaret()
7205 if(guiApp.caretOwner)
7206 guiApp.caretOwner.UpdateCaret(false, false);
7209 void ::FreeMouseRange()
7211 guiApp.interfaceDriver.SetMouseRange(null, null);
7215 bool MenuFileClose(MenuItem selection, Modifiers mods)
7217 Window document = activeChild;
7219 document.Destroy(0);
7223 bool MenuFileExit(MenuItem selection, Modifiers mods)
7229 bool MenuFileSave(MenuItem selection, Modifiers mods)
7233 fileMonitor.fileName = null;
7236 if(OnSaveFile(fileName))
7238 //if(OnFileModified != Window::OnFileModified)
7241 fileMonitor.fileName = fileName;
7247 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7248 DialogResult answer = dialog.Modal();
7250 if(answer != yes) return (bool)answer;
7253 return MenuFileSaveAs(selection, mods);
7256 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7258 DialogResult result = (DialogResult)bool::true;
7259 FileDialog fileDialog = saveDialog;
7262 fileDialog = FileDialog {};
7267 fileDialog.filePath = fileName;
7270 char filePath[MAX_FILENAME];
7271 sprintf(filePath, "Untitled %d", documentID);
7272 fileDialog.filePath = filePath;
7274 fileMonitor.fileName = null;
7276 fileDialog.type = save;
7277 fileDialog.text = $"Save As";
7281 fileDialog.master = master.parent ? master : this;
7282 if(fileDialog.Modal() == ok)
7284 char * filePath = fileDialog.filePath;
7286 if(OnSaveFile(filePath))
7289 property::fileName = filePath;
7290 NotifySaved(master, this, filePath);
7295 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7296 DialogResult answer = dialog.Modal();
7311 //if(OnFileModified != Window::OnFileModified && fileName)
7314 fileMonitor.fileName = fileName;
7318 return (bool)result; // Actually returning result from Yes/NoCancel message box
7321 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7323 Window document = activeChild;
7325 for(document = children.first; document; document = next)
7327 next = document.next;
7328 if(document.style.isDocument || document.fileName)
7329 document.MenuFileSave(selection, mods);
7334 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7338 for(document = children.first; document; document = document.next)
7339 //if(document.style.isDocument && document.state == minimized)
7340 if(document.style.isActiveClient && document.state == minimized)
7341 document.SetState(minimized, false, mods);
7345 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7347 Window document = activeChild;
7350 Window firstDocument = null;
7352 OldLink cycle = document.cycle.prev;
7357 if(child.style.isActiveClient && !child.style.hidden)
7361 firstDocument = child;
7362 if(child.state == minimized)
7363 child.SetState(minimized, false, mods);
7366 child.positionID = id++;
7367 child.SetState(normal, false, mods);
7368 child.anchor.left.type = cascade;
7371 child.normalSizeAnchor = *&child.sizeAnchor;
7372 child.normalAnchor = child.anchor;
7374 // Break the anchors for moveable/resizable windows
7375 if(child.style.fixed)
7377 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7379 (*&child.normalAnchor).left = x;
7380 (*&child.normalAnchor).top = y;
7381 (*&child.normalAnchor).right.type = none;
7382 (*&child.normalAnchor).bottom.type = none;
7384 child.normalSizeAnchor.isClientW = false;
7385 child.normalSizeAnchor.isClientH = false;
7386 child.normalSizeAnchor.size.w = w;
7387 child.normalSizeAnchor.size.h = h;
7388 child.anchored = false;
7391 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7393 child.stateAnchor = child.normalAnchor;
7394 child.stateSizeAnchor = child.normalSizeAnchor;
7396 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7397 child.Position(x, y, w, h, true, true, true, true, false, false);
7402 last = children.last;
7403 if(!child.style.stayOnTop)
7404 for(; last && last.style.stayOnTop; last = last.prev);
7405 children.Move(child, last);
7406 childrenOrder.Move(child.order, childrenOrder.last);
7408 if(cycle == document.cycle) break;
7412 firstDocument.Activate();
7417 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7424 // Close all closes all active clients, not all documents
7425 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7427 Window next, document;
7429 for(document = children.first; document; document = next)
7431 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7432 if(document.style.isActiveClient)
7433 if(!document.Destroy(0) && !document.style.hidden)
7439 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7441 if(style.hasMaximize && state != maximized)
7442 SetState(maximized, 0, 0);
7446 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7448 if(style.hasMinimize && state != minimized)
7450 SetState(minimized, 0, 0);
7451 parent.CycleChildren(false, true, false, true);
7456 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7458 MenuMoveOrSize(false, selection ? true : false);
7462 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7464 CycleChildren(false, true, false, true);
7468 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7470 CycleChildren(true, true, false, true);
7474 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7476 MenuMoveOrSize(true, true);
7480 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7483 SetState(normal, 0, 0);
7487 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7490 int id = selection.id;
7491 OldLink cycle = activeClient.cycle;
7493 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7496 Window sibling = cycle.data;
7497 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7505 document = cycle.data;
7506 document.Activate();
7508 //if(activeChild.state == maximized)
7509 // document.SetState(maximized, false, mods);
7510 //else if(document.state == minimized)
7511 // document.SetState(normal, false, mods);
7515 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7517 stayOnTop = !style.stayOnTop;
7521 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7523 Window document = activeChild;
7526 Window firstDocument = null;
7527 OldLink cycle = document.cycle;
7531 Window child = cycle.data;
7532 if(child.style.isActiveClient && !child.style.hidden)
7534 if(!firstDocument) firstDocument = child;
7535 if(child.state == minimized)
7536 child.SetState(minimized, false, mods);
7539 child.positionID = id++;
7540 child.SetState(normal, false, mods);
7541 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7543 child.anchor.left.type = hTiled;
7546 child.normalSizeAnchor = *&child.sizeAnchor;
7547 child.normalAnchor = child.anchor;
7549 // Break the anchors for moveable/resizable windows
7550 if(child.style.fixed)
7552 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7554 (*&child.normalAnchor).left = x;
7555 (*&child.normalAnchor).top = y;
7556 (*&child.normalAnchor).right.type = none;
7557 (*&child.normalAnchor).bottom.type = none;
7558 child.normalSizeAnchor.isClientW = false;
7559 child.normalSizeAnchor.isClientH = false;
7560 child.normalSizeAnchor.size.w = w;
7561 child.normalSizeAnchor.size.h = h;
7562 child.anchored = false;
7565 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7567 child.stateAnchor = child.normalAnchor;
7568 child.stateSizeAnchor = child.normalSizeAnchor;
7570 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7571 child.Position(x,y, w, h, true, true, true, true, false, true);
7576 if((cycle = cycle.next) == document.cycle) break;
7579 firstDocument.Activate();
7584 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7586 Window document = activeChild;
7589 Window firstDocument = null;
7591 OldLink cycle = document.cycle;
7596 //if(child.style.isDocument)
7597 if(child.style.isActiveClient && !child.style.hidden)
7599 if(!firstDocument) firstDocument = child;
7600 if(child.state == minimized)
7601 child.SetState(minimized, false, mods);
7604 child.positionID = id++;
7605 child.SetState(normal, false, mods);
7606 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7608 child.anchor.left.type = vTiled;
7611 child.normalSizeAnchor = *&child.sizeAnchor;
7612 child.normalAnchor = child.anchor;
7614 // Break the anchors for moveable/resizable windows
7615 if(child.style.fixed)
7617 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7619 (*&child.normalAnchor).left = x;
7620 (*&child.normalAnchor).top = y;
7621 (*&child.normalAnchor).right.type = none;
7622 (*&child.normalAnchor).bottom.type = none;
7623 child.normalSizeAnchor.isClientW = false;
7624 child.normalSizeAnchor.isClientH = false;
7625 child.normalSizeAnchor.size.w = w;
7626 child.normalSizeAnchor.size.h = h;
7627 child.anchored = false;
7630 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7632 child.stateAnchor = child.normalAnchor;
7633 child.stateSizeAnchor = child.normalSizeAnchor;
7635 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7636 child.Position(x,y, w, h, true, true, true, true, false, true);
7641 if((cycle = cycle.next) == document.cycle) break;
7644 firstDocument.Activate();
7649 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7651 WindowList dialog { master = this };
7652 Window document = (Window)dialog.Modal();
7655 if(activeChild.state == maximized)
7656 document.SetState(maximized, false, mods);
7657 else if(document.state == minimized)
7658 document.SetState(normal, false, mods);
7659 document.Activate();
7665 virtual bool OnCreate(void);
7666 virtual void OnDestroy(void);
7667 virtual void OnDestroyed(void);
7668 virtual bool OnClose(bool parentClosing);
7669 virtual bool OnStateChange(WindowState state, Modifiers mods);
7670 virtual bool OnPostCreate(void);
7671 virtual bool OnMoving(int *x, int *y, int w, int h);
7672 virtual bool OnResizing(int *width, int *height);
7673 virtual void OnResize(int width, int height);
7674 virtual void OnPosition(int x, int y, int width, int height);
7675 virtual bool OnLoadGraphics(void);
7676 virtual void OnApplyGraphics(void);
7677 virtual void OnUnloadGraphics(void);
7678 virtual void OnRedraw(Surface surface);
7679 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7680 virtual void OnActivateClient(Window client, Window previous);
7681 virtual bool OnKeyDown(Key key, unichar ch);
7682 virtual bool OnKeyUp(Key key, unichar ch);
7683 virtual bool OnKeyHit(Key key, unichar ch);
7684 virtual bool OnSysKeyDown(Key key, unichar ch);
7685 virtual bool OnSysKeyUp(Key key, unichar ch);
7686 virtual bool OnSysKeyHit(Key key, unichar ch);
7687 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7688 virtual bool OnMouseLeave(Modifiers mods);
7689 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7690 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7691 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7692 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7693 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7694 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7695 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7696 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7697 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7698 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7699 virtual void OnMouseCaptureLost(void);
7700 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7701 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7702 virtual void OnDrawOverChildren(Surface surface);
7703 virtual bool OnFileModified(FileChange fileChange, char * param);
7704 virtual bool OnSaveFile(char * fileName);
7706 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7707 // Note: A 'client' would refer to isActiveClient, rather than
7708 // being confined to the 'client area' (nonClient == false)
7709 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7710 virtual void OnChildVisibilityToggled(Window child, bool visible);
7711 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7713 // Skins Virtual Functions
7714 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7715 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7716 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7721 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7722 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7723 virtual bool IsMouseMoving(int x, int y, int w, int h);
7724 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY);
7725 virtual void UpdateNonClient();
7726 virtual void SetBox(Box box);
7727 virtual bool IsInside(int x, int y)
7729 return box.IsPointInside({x, y});
7731 virtual bool IsOpaque()
7733 return (!style.drawBehind || background.a == 255);
7737 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7738 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7739 virtual void Window::NotifySaved(Window window, char * filePath);
7744 property Window parent
7746 property_category $"Layout"
7749 if(value || guiApp.desktop)
7752 Window oldParent = parent;
7753 Anchor anchor = this.anchor;
7755 if(value && value.IsDescendantOf(this)) return;
7756 if(value && value == this)
7758 if(!value) value = guiApp.desktop;
7760 if(value == oldParent) return;
7762 if(!master || (master == this.parent && master == guiApp.desktop))
7763 property::master = value;
7767 parent.children.Remove(this);
7771 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7772 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7773 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7774 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7778 last = value.children.last;
7780 if(style.isDocument)
7783 parent.numDocuments--;
7784 documentID = value.GetDocumentID();
7787 if(style.isActiveClient && !style.hidden)
7789 if(parent && parent != guiApp.desktop && !(style.hidden))
7791 if(state == minimized) parent.numIcons--;
7792 parent.numPositions--;
7796 if(!style.stayOnTop)
7797 for(; last && last.style.stayOnTop; last = last.prev);
7799 value.children.Insert(last, this);
7801 // *** NEW HERE: ***
7803 parent.childrenCycle.Delete(cycle);
7805 parent.childrenOrder.Delete(order);
7808 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7809 // Should something else be done?
7810 if(parent && parent.activeChild == this)
7811 parent.activeChild = null;
7812 if(parent && parent.activeClient == this)
7813 parent.activeClient = null;
7819 int x = position.x, y = position.y, w = size.w, h = size.h;
7823 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7824 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7826 vpw = value.clientSize.w;
7827 vph = value.clientSize.h;
7833 else if(style.fixed)
7835 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7836 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7839 anchor = this.anchor;
7841 if(anchor.left.type == offset) anchor.left.distance = x;
7842 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7843 if(anchor.top.type == offset) anchor.top.distance = y;
7844 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7845 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7846 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7847 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7848 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7849 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7850 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7852 if(!anchor.left.type && !anchor.right.type)
7854 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7855 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7857 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7858 if(!anchor.top.type && !anchor.bottom.type)
7860 anchor.vert.distance = (y + h / 2) - (vph / 2);
7861 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7863 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7866 parent.OnChildAddedOrRemoved(this, false);
7872 parent.childrenCycle.Insert(
7873 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7874 cycle = OldLink { data = this });
7875 parent.childrenOrder.Insert(
7876 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7877 order = OldLink { data = this });
7880 if(!style.hidden && style.isActiveClient)
7882 positionID = parent.GetPositionID(this);
7883 parent.numPositions++;
7884 if(state == minimized) parent.numIcons--;
7887 // *** FONT INHERITANCE ***
7888 if(!setFont && oldParent)
7889 stopwatching(oldParent, font);
7893 RemoveResource(systemFont);
7896 // TESTING WITH WATCHERS:
7897 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7898 // usedFont = setFont ? setFont : (systemFont);
7902 if(guiApp.currentSkin)
7904 systemFont = guiApp.currentSkin.SystemFont();
7907 usedFont = systemFont;
7908 AddResource(systemFont);
7916 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7925 if(value.rootWindow && value.rootWindow.display && rootWindow)
7927 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7928 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7931 UnloadGraphics(false);
7934 LoadGraphics(false, false);
7937 if(value.rootWindow != rootWindow)
7938 DisplayModeChanged();
7942 scrolledPos.x = MININT; // Prevent parent update
7944 bool anchored = this.anchored;
7945 property::anchor = anchor;
7946 this.anchored = anchored;
7951 if(guiApp.currentSkin)
7952 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7954 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7955 Position(x, y, w, h, true, true, true, true, false, true);
7960 // else parent = value;
7962 oldParent.OnChildAddedOrRemoved(this, true);
7965 get { return parent; }
7968 property Window master
7970 property_category $"Behavior"
7973 //if(this == value) return;
7974 if(value && value.IsSlaveOf(this)) return;
7980 OldLink slaveHolder;
7981 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7982 if(slaveHolder.data == this)
7984 master.slaves.Delete(slaveHolder);
7991 value.slaves.Add(OldLink { data = this });
7996 master.hotKeys.Remove(hotKey);
7997 value.hotKeys.Add(hotKey);
8000 if(master && master.defaultControl == this)
8001 master.defaultControl = null;
8003 if(style.isDefault && !value.defaultControl)
8004 value.defaultControl = this;
8009 get { return master ? master : parent; }
8012 property char * caption
8014 property_category $"Appearance"
8021 caption = new char[strlen(value)+1];
8023 strcpy(caption, value);
8028 get { return caption; }
8033 property_category $"Behavior"
8042 master.hotKeys.Add(hotKey = HotKeySlot { });
8046 hotKey.window = this;
8051 master.hotKeys.Delete(hotKey);
8056 get { return hotKey ? hotKey.key : 0; }
8059 property Color background
8061 property_category $"Appearance"
8064 background.color = value;
8069 if(this == rootWindow)
8070 guiApp.interfaceDriver.SetRootWindowColor(this);
8073 get { return background.color; }
8076 property Percentage opacity
8078 property_category $"Appearance"
8081 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8082 drawBehind = (background.a == 255) ? false : true;
8084 get { return background.a / 255.0f; }
8087 property Color foreground
8089 property_category $"Appearance"
8097 get { return foreground; }
8100 property BorderStyle borderStyle
8102 property_category $"Appearance"
8105 if(!((BorderBits)value).fixed)
8107 style.hasClose = false;
8108 style.hasMaximize = false;
8109 style.hasMinimize = false;
8110 nativeDecorations = false;
8112 style.borderBits = value;
8116 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8118 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8119 Position(x, y, w, h, true, true, true, true, false, true);
8120 CreateSystemChildren();
8123 get { return (BorderStyle)style.borderBits; }
8126 property Size minClientSize
8128 property_category $"Layout"
8129 set { minSize = value; }
8130 get { value = minSize; }
8133 property Size maxClientSize
8135 property_category $"Layout"
8136 set { maxSize = value; }
8137 get { value = maxSize; }
8140 property bool hasMaximize
8142 property_category $"Window Style"
8145 style.hasMaximize = value;
8146 if(value) { style.fixed = true; style.contour = true; }
8150 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8152 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8153 Position(x, y, w, h, true, true, true, true, false, true);
8155 CreateSystemChildren();
8158 get { return style.hasMaximize; }
8161 property bool hasMinimize
8163 property_category $"Window Style"
8166 style.hasMinimize = value;
8167 if(value) { style.fixed = true; style.contour = true; }
8171 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8173 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8174 Position(x, y, w, h, true, true, true, true, false, true);
8176 CreateSystemChildren();
8179 get { return style.hasMinimize; }
8182 property bool hasClose
8184 property_category $"Window Style"
8187 style.hasClose = value;
8188 if(value) { style.fixed = true; style.contour = true; }
8192 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8193 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8194 Position(x, y, w, h, true, true, true, true, false, true);
8195 CreateSystemChildren();
8198 get { return style.hasClose; }
8201 property bool nonClient
8203 property_category $"Layout"
8206 style.nonClient = value;
8208 style.stayOnTop = true;
8210 get { return style.nonClient; }
8213 property bool inactive
8215 property_category $"Behavior"
8220 // *** NEW HERE: ***
8224 parent.childrenCycle.Delete(cycle);
8226 parent.childrenOrder.Delete(order);
8233 active = false; // true;
8234 if(parent.activeChild == this)
8235 parent.activeChild = null;
8236 if(parent.activeClient == this)
8237 parent.activeClient = null;
8246 parent.childrenCycle.Insert(
8247 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8248 cycle = OldLink { data = this });
8250 parent.childrenOrder.Insert(
8251 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8252 order = OldLink { data = this });
8255 style.inactive = value;
8257 get { return style.inactive; }
8260 property bool clickThrough
8262 property_category $"Behavior"
8263 set { style.clickThrough = value; }
8264 get { return style.clickThrough; }
8267 property bool isRemote
8269 property_category $"Behavior"
8270 set { style.isRemote = value; }
8271 get { return style.isRemote; }
8274 property bool noCycle
8276 property_category $"Behavior"
8277 set { style.noCycle = value; }
8278 get { return style.noCycle; }
8281 property bool isModal
8283 property_category $"Behavior"
8284 set { style.modal = value; }
8285 get { return style.modal; }
8288 property bool interim
8290 property_category $"Behavior"
8291 set { style.interim = value; }
8292 get { return style.interim; }
8295 property bool tabCycle
8297 property_category $"Behavior"
8298 set { style.tabCycle = value; }
8299 get { return style.tabCycle; }
8302 property bool isDefault
8304 property_category $"Behavior"
8312 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8313 if(sibling != this && sibling.style.isDefault)
8314 sibling.style.isDefault = false;*/
8315 if(master.defaultControl)
8316 master.defaultControl.style.isDefault = false;
8317 master.defaultControl = this;
8319 else if(master.defaultControl == this)
8320 master.defaultControl = null;
8324 style.isDefault = value;
8326 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8328 get { return style.isDefault; }
8331 property bool drawBehind
8333 property_category $"Window Style"
8334 set { style.drawBehind = value; }
8335 get { return style.drawBehind; }
8338 property bool hasMenuBar
8340 property_category $"Window Style"
8350 if(created && !menuBar)
8357 anchor = Anchor { top = 23, left = 1, right = 1 },
8359 inactive = true, nonClient = true
8364 else if(created && menuBar)
8369 style.hasMenuBar = value;
8371 get { return style.hasMenuBar; }
8374 property bool hasStatusBar
8376 property_category $"Window Style"
8383 statusBar = StatusBar { this };
8391 style.hasStatusBar = value;
8393 get { return style.hasStatusBar; }
8395 property bool stayOnTop
8397 property_category $"Window Style"
8402 if(created && !style.stayOnTop)
8404 if(rootWindow == this)
8405 guiApp.interfaceDriver.OrderRootWindow(this, true);
8406 else if(parent.children.last != this)
8408 parent.children.Move(this, parent.children.last);
8412 style.stayOnTop = true;
8416 if(created && style.stayOnTop)
8418 if(rootWindow == this)
8419 guiApp.interfaceDriver.OrderRootWindow(this, false);
8426 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8427 order && ((Window)order.data).style.stayOnTop;
8428 order = (order == parent.childrenOrder.first) ? null : order.prev);
8429 last = order ? order.data : null;
8433 for(last = parent.children.last;
8434 last && last.style.stayOnTop;
8438 parent.children.Move(this, last);
8442 style.stayOnTop = false;
8445 get { return style.stayOnTop; }
8450 property_category $"Window Style"
8460 if(menuBar && !value)
8467 if(!menuBar && style.hasMenuBar && value)
8471 this, menu = value, isMenuBar = true,
8472 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8473 inactive = true, nonClient = true
8477 UpdateActiveDocument(null);
8480 get { return menu; }
8483 property FontResource font
8485 property_category $"Appearance"
8487 isset { return setFont ? true : false; }
8492 if(value && !setFont) { stopwatching(parent, font); }
8493 else if(!value && setFont)
8499 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8508 RemoveResource(setFont);
8513 RemoveResource(systemFont);
8520 AddResource(setFont);
8523 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8526 systemFont = guiApp.currentSkin.SystemFont();
8528 usedFont = systemFont;
8529 AddResource(systemFont);
8537 get { return usedFont; }
8540 property SizeAnchor sizeAnchor
8542 property_category $"Layout"
8545 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8546 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8547 sizeAnchor.isClientW != sizeAnchor.isClientH;
8554 normalSizeAnchor = sizeAnchor;
8556 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8558 stateAnchor = normalAnchor;
8559 stateSizeAnchor = normalSizeAnchor;
8561 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8562 Position(x,y, w, h, true, true, true, true, false, true);
8569 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8570 sizeAnchor.isClientW,
8571 sizeAnchor.isClientH
8578 property_category $"Layout"
8581 Anchor thisAnchor = anchor;
8582 SizeAnchor thisSizeAnchor = sizeAnchor;
8583 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8584 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8585 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8586 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8587 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8588 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8594 sizeAnchor.isClientW = false;
8595 sizeAnchor.isClientH = false;
8596 sizeAnchor.size = value;
8598 normalSizeAnchor = sizeAnchor;
8600 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8602 stateAnchor = normalAnchor;
8603 stateSizeAnchor = normalSizeAnchor;
8605 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8606 Position(x, y, w, h, true, true, true, true, false, true);
8607 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8610 get { value = size; }
8613 property Size clientSize
8615 property_category $"Layout"
8618 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8619 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8620 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8625 sizeAnchor.isClientW = true;
8626 sizeAnchor.isClientH = true;
8627 sizeAnchor.size = value;
8629 normalSizeAnchor = sizeAnchor;
8631 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8633 stateAnchor = normalAnchor;
8634 stateSizeAnchor = normalSizeAnchor;
8636 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8637 Position(x,y, w, h, true, true, true, true, false, true);
8640 get { value = clientSize; }
8643 property Size initSize { get { value = sizeAnchor.size; } };
8645 property Anchor anchor
8647 property_category $"Layout"
8648 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8654 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8656 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8657 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8659 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8661 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8662 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8666 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8668 anchor.left.distance = 0;
8669 anchor.horz.type = 0;
8671 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8673 anchor.top.distance = 0;
8674 anchor.vert.type = 0;
8683 normalAnchor = anchor;
8685 // Break the anchors for moveable/resizable windows
8686 /*if(style.fixed ) //&& value.left.type == cascade)
8688 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8690 this.anchor = normalAnchor = Anchor { left = x, top = y };
8691 normalSizeAnchor = SizeAnchor { { w, h } };
8694 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8696 stateAnchor = normalAnchor;
8697 stateSizeAnchor = normalSizeAnchor;
8699 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8700 Position(x, y, w, h, true, true, true, true, false, true);
8709 get { value = this ? anchor : Anchor { }; }
8712 property Point position
8714 property_category $"Layout"
8717 if(value == null) return;
8719 anchor.left = value.x;
8720 anchor.top = value.y;
8721 anchor.right.type = none;
8722 anchor.bottom.type = none;
8727 normalAnchor = anchor;
8729 // Break the anchors for moveable/resizable windows
8733 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8735 normalAnchor.left = x;
8736 normalAnchor.top = y;
8737 normalAnchor.right.type = none;
8738 normalAnchor.bottom.type = none;
8739 normalSizeAnchor.size.width = w;
8740 normalSizeAnchor.size.height = h;
8744 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8746 stateAnchor = normalAnchor;
8747 stateSizeAnchor = normalSizeAnchor;
8749 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8750 Position(x,y, w, h, true, true, true, true, false, true);
8754 get { value = position; }
8757 property bool disabled
8759 property_category $"Behavior"
8762 if(this && disabled != value)
8769 get { return (bool)disabled; }
8772 property bool isEnabled
8777 for(parent = this; parent; parent = parent.parent)
8784 property WindowState state
8786 property_category $"Behavior"
8787 set { SetState(value, false, 0); }
8788 get { return this ? state : 0; }
8791 property bool visible
8793 property_category $"Behavior"
8796 if(this && !value && !style.hidden && parent)
8798 bool wasActiveChild = parent.activeChild == this;
8799 Window client = null;
8801 style.hidden = true;
8802 if(style.isActiveClient)
8804 parent.numPositions--;
8805 if(state == minimized) parent.numIcons--;
8810 OldLink prevOrder = null;
8812 if(rootWindow == this)
8813 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8816 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8819 box.left -= parent.clientStart.x;
8820 box.top -= parent.clientStart.y;
8821 box.right -= parent.clientStart.x;
8822 box.bottom -= parent.clientStart.y;
8826 if(_isModal && master && master.modalSlave == this)
8827 master.modalSlave = null;
8831 OldLink tmpPrev = order.prev;
8832 client = tmpPrev ? tmpPrev.data : null;
8833 if(client && !client.style.hidden && !client.destroyed && client.created)
8834 prevOrder = tmpPrev;
8837 client = tmpPrev ? tmpPrev.data : null;
8838 if(client == this) { client = null; break; }
8839 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8841 tmpPrev = client.order.prev;
8846 prevOrder = tmpPrev;
8851 // If this window can be an active client, make sure the next window we activate can also be one
8852 if(!style.nonClient && style.isActiveClient)
8854 tmpPrev = prevOrder;
8857 client = tmpPrev ? tmpPrev.data : null;
8858 if(client == this) { client = null; break; }
8859 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8861 tmpPrev = client.order.prev;
8866 prevOrder = tmpPrev;
8870 if(client && client.style.hidden) client = null;
8874 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8876 if(order && prevOrder && prevOrder.data != this)
8877 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8879 ActivateEx(false, false, false, true, null, null);
8881 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8882 if(parent.activeClient == this)
8884 parent.activeClient = null;
8885 parent.UpdateActiveDocument(null);
8888 else if(parent.activeClient == this)
8890 parent.activeClient = client;
8891 parent.UpdateActiveDocument(this);
8894 // *** Not doing this anymore ***
8897 parent.childrenCycle.Delete(cycle);
8899 parent.childrenOrder.Delete(order);
8904 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8909 else if(this && value && style.hidden)
8911 style.hidden = false;
8914 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8915 if(rootWindow == this)
8916 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8918 if(_isModal && master)
8919 master.modalSlave = this;
8921 if(style.isActiveClient)
8923 positionID = parent.GetPositionID(this);
8924 parent.numPositions++;
8925 if(state == minimized) parent.numIcons++;
8928 // *** NOT DOING THIS ANYMORE ***
8930 if(!(style.inactive))
8932 if(!(style.noCycle))
8934 cycle = parent.childrenCycle.AddAfter(
8935 (parent.activeChild && parent.activeChild.cycle) ?
8936 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8939 order = parent.childrenOrder.AddAfter(
8940 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8947 if(true || !parent.activeChild)
8948 ActivateEx(true, false, true, true, null, null);
8950 if(creationActivation == activate)
8951 ActivateEx(true, false, true, true, null, null);
8952 else if(creationActivation == flash && !object)
8955 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8959 ConsequentialMouseMove(false);
8965 style.hidden = !value;
8968 get { return (style.hidden || !setVisible) ? false : true; }
8971 property bool isDocument
8973 property_category $"Document"
8974 set { style.isDocument = value; }
8975 get { return style.isDocument; }
8978 property bool mergeMenus
8980 property_category $"Window Style"
8981 set { mergeMenus = value; }
8982 get { return (bool)mergeMenus; }
8985 property bool hasHorzScroll
8987 property_category $"Window Style"
8992 if(!style.hasHorzScroll && created)
8994 CreateSystemChildren();
8995 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8998 else if(style.hasHorzScroll)
9002 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9004 style.hasHorzScroll = value;
9007 get { return style.hasHorzScroll; }
9010 property bool hasVertScroll
9012 property_category $"Window Style"
9017 if(!style.hasVertScroll && created)
9019 style.hasVertScroll = true;
9020 CreateSystemChildren();
9021 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9024 else if(style.hasVertScroll)
9028 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9030 style.hasVertScroll = value;
9032 get { return style.hasVertScroll; }
9035 property bool dontHideScroll
9037 property_category $"Behavior"
9040 scrollFlags.dontHide = value;
9043 //UpdateScrollBars(true, true);
9044 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9048 // UpdateScrollBars(true, true);
9049 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9052 get { return scrollFlags.dontHide; }
9055 property bool dontScrollVert
9057 property_category $"Behavior"
9058 set { style.dontScrollVert = value; }
9059 get { return style.dontScrollVert; }
9061 property bool dontScrollHorz
9063 property_category $"Behavior"
9064 set { style.dontScrollHorz = value; }
9065 get { return style.dontScrollHorz; }
9068 property bool snapVertScroll
9070 property_category $"Behavior"
9073 scrollFlags.snapY = value;
9074 if(sbv) sbv.snap = value;
9076 get { return scrollFlags.snapY; }
9078 property bool snapHorzScroll
9080 property_category $"Behavior"
9083 scrollFlags.snapX = value;
9084 if(sbh) sbh.snap = value;
9086 get { return scrollFlags.snapX; }
9089 property Point scroll
9091 property_category $"Behavior"
9092 set { SetScrollPosition(value.x, value.y); }
9093 get { value = scroll; }
9096 property bool modifyVirtualArea
9098 property_category $"Behavior"
9099 set { modifyVirtArea = value; }
9100 get { return (bool)modifyVirtArea; }
9103 property bool dontAutoScrollArea
9105 property_category $"Behavior"
9106 // Activating a child control out of view will automatically scroll to make it in view
9107 set { noAutoScrollArea = value; }
9108 get { return (bool)noAutoScrollArea; }
9111 property char * fileName
9113 property_category $"Document"
9116 if(menu && ((!fileName && value) || (fileName && !value)))
9118 MenuItem item = menu.FindItem(MenuFileSave, 0);
9119 if(item) item.disabled = !modifiedDocument && value;
9124 if(value && value[0])
9125 fileName = CopyString(value);
9127 if(parent && this == parent.activeClient)
9128 parent.UpdateActiveDocument(null);
9132 // if(style.isDocument)
9134 fileMonitor.fileName = value;
9136 get { return fileName; }
9141 property_category $"Data"
9146 property bool modifiedDocument
9148 property_category $"Document"
9151 if(style.isDocument || fileName)
9155 MenuItem item = menu.FindItem(MenuFileSave, 0);
9156 if(item) item.disabled = !value && fileName;
9160 if(modifiedDocument != value)
9162 modifiedDocument = value;
9163 if(style.isDocument || fileName)
9167 get { return (bool)modifiedDocument; }
9170 property bool showInTaskBar
9172 property_category $"Window Style"
9173 set { style.showInTaskBar = value; }
9174 get { return (style.showInTaskBar; }
9176 property FileDialog saveDialog { set { saveDialog = value; } };
9177 property bool isActiveClient
9179 property_category $"Behavior"
9180 set { style.isActiveClient = value; }
9181 get { return style.isActiveClient; }
9184 property Cursor cursor
9186 property_category $"Appearance"
9190 SelectMouseCursor();
9192 get { return cursor; }
9195 //#if !defined(ECERE_VANILLA)
9196 property char * name
9198 property_category $"Design"
9201 return (this && object) ? object.name : null;
9206 activeDesigner.RenameObject(object, value);
9210 property char * displayDriver
9212 property_category $"Behavior"
9215 dispDriver = GetDisplayDriver(value);
9216 //DisplayModeChanged();
9220 return dispDriver ? dispDriver.name : null;
9224 // RUNTIME PROPERTIES
9225 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9226 property Size scrollArea
9228 property_category $"Behavior"
9232 SetScrollArea(value.w, value.h, false);
9234 SetScrollArea(0,0, true);
9236 get { value = scrollArea; }
9239 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9244 property_category $"Layout"
9245 set { if(this) is3D = value; }
9246 get { return (bool)is3D; }
9249 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9251 // Will be merged with font later
9252 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9253 property Point clientStart { get { value = clientStart; } };
9254 property Point absPosition { get { value = absPosition; } };
9255 property Anchor normalAnchor { get {value = normalAnchor; } };
9256 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9257 property bool active { get { return (bool)active; } };
9258 property bool created { get { return (bool)created; } };
9259 property bool destroyed { get { return (bool)destroyed; } };
9260 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9261 property Window firstChild { get { return children.first; } };
9262 property Window lastChild { get { return children.last; } };
9263 property Window activeClient { get { return activeClient; } };
9264 property Window activeChild { get { return activeChild; } };
9265 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9266 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9267 property ScrollBar horzScroll { get { return sbh; } };
9268 property ScrollBar vertScroll { get { return sbv; } };
9269 property StatusBar statusBar { get { return statusBar; } };
9270 property Window rootWindow { get { return rootWindow; } };
9271 property bool closing { get { return (bool)closing; } set { closing = value; } };
9272 property int documentID { get { return documentID; } };
9273 property Window previous { get { return prev; } }
9274 property Window next { get { return next; } }
9275 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9276 property PopupMenu menuBar { get { return menuBar; } }
9277 property ScrollBar sbv { get { return sbv; } }
9278 property ScrollBar sbh { get { return sbh; } }
9279 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9280 property void * systemHandle { get { return windowHandle; } }
9281 property Button minimizeButton { get { return sysButtons[0]; } };
9282 property Button maximizeButton { get { return sysButtons[1]; } };
9283 property Button closeButton { get { return sysButtons[2]; } };
9284 property BitmapResource icon
9286 get { return icon; }
9290 if(icon) incref icon;
9292 guiApp.interfaceDriver.SetIcon(this, value);
9295 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9296 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9297 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9298 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9299 property bool nativeDecorations
9301 get { return (bool)nativeDecorations; }
9302 set { nativeDecorations = value; }
9303 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9306 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9307 bool result = false;
9308 if(nativeDecorations)
9310 if(rootWindow == this)
9314 if(formDesigner && activeDesigner)
9316 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9317 Window form = cd ? cd.form : null;
9318 if(form && parent == form.parent)
9323 return result != style.fixed;
9327 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9329 property char * text
9331 property_category $"Deprecated"
9333 set { property::caption = value; }
9334 get { return property::caption; }
9340 WindowBits style; // Window Style
9341 char * caption; // Name / Caption
9342 Window parent; // Parent window
9343 OldList children; // List of children in Z order
9344 Window activeChild; // Child window having focus
9345 Window activeClient;
9346 Window previousActive; // Child active prior to activating the default child
9347 Window master; // Window owning and receiving notifications concerning this window
9348 OldList slaves; // List of windows belonging to this window
9349 Display display; // Display this window is drawn into
9351 Point position; // Position in parent window client area
9352 Point absPosition; // Absolute position
9353 Point clientStart; // Client area position from (0,0) in this window
9355 Size clientSize; // Client area size
9356 Size scrollArea; // Virtual Scroll area size
9357 Size reqScrollArea; // Requested virtual area size
9358 Point scroll; // Virtual area scrolling position
9359 public ScrollBar sbh, sbv; // Scrollbar window handles
9360 Cursor cursor; // Mouse cursor used for this window
9363 StatusBar statusBar;
9364 Button sysButtons[3];
9366 Box clientArea; // Client Area box clipped to parent
9368 HotKeySlot hotKey; // HotKey for this window
9372 ScrollFlags scrollFlags;// Window Scrollbar Flags
9373 int id; // Control ID
9375 ColorAlpha background; // Background color used to draw the window area
9377 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9378 OldList childrenCycle; // Cycling order
9379 OldLink cycle; // Element of parent's cycling order
9380 OldList childrenOrder; // Circular Z-Order
9381 OldLink order; // Element of parent's circular Z-Order
9382 Window modalSlave; // Slave window blocking this window's interaction
9384 Window rootWindow; // Topmost system managed window
9385 void * windowHandle; // System window handle
9387 DialogResult returnCode;// Return code for modal windows
9389 Point sbStep; // Scrollbar line scrolling steps
9392 SizeAnchor stateSizeAnchor;
9394 Anchor normalAnchor;
9395 SizeAnchor normalSizeAnchor;
9397 Size skinMinSize; // Minimal window size based on style
9398 Point scrolledPos; // Scrolled position
9399 Box box; // Window box clipped to parent
9400 Box * against; // What to clip the box to
9402 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9403 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9404 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9405 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9406 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9407 Point scrolledArea; // Distance to scroll area by
9408 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9410 OldList hotKeys; // List of the hotkeys of all children
9411 Window defaultControl; // Default child control
9415 ColorAlpha * palette; // Color palette used for this window
9417 int caretSize; // Size of caret, non zero if a caret is present
9418 Point caretPos; // Caret position
9420 void * systemParent; // Parent System Window for embedded windows
9427 WindowState lastState;
9429 FileMonitor fileMonitor
9431 this, FileChange { modified = true };
9433 bool OnFileNotify(FileChange action, char * param)
9436 fileMonitor.StopMonitoring();
9437 if(OnFileModified(action, param))
9438 fileMonitor.StartMonitoring();
9443 FontResource setFont, systemFont;
9444 FontResource usedFont;
9445 FontResource captionFont;
9447 FileDialog saveDialog;
9449 SizeAnchor sizeAnchor;
9451 // FormDesigner data
9454 Extent * tempExtents; //[4];
9455 BitmapResource icon;
9457 CreationActivationOption creationActivation;
9460 bool active:1; // true if window and ancestors are active
9461 bool acquiredInput:1; // true if the window is processing state based input
9462 bool modifiedDocument:1;
9463 bool disabled:1; // true if window cannot interact
9464 bool isForegroundWindow:1;// true while a root window is being activated
9465 bool visible:1; // Visibility flag
9466 bool destroyed:1; // true if window is being destroyed
9467 bool anchored:1; // true if this window is repositioned when the parent resizes
9468 bool dirty:1; // Flag set to true if any descendant must be redrawn
9474 bool modifyVirtArea:1;
9475 bool noAutoScrollArea:1;
9478 bool setVisible:1; // FOR FORM DESIGNER
9484 bool useSharedMemory:1;
9487 bool nativeDecorations:1;
9488 bool manageDisplay:1;
9489 bool formDesigner:1; // True if we this is running in the form editor
9492 // Checks used internally for them not to take effect in FormDesigner
9493 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9494 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9496 WindowController controller;
9497 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9500 public class CommonControl : Window
9502 // creationActivation = doNothing;
9505 public property String toolTip
9507 property_category $"Appearance"
9510 if(created) CommonControl::OnDestroy();
9512 toolTip = value ? ToolTip { tip = value; } : null;
9514 if(created) CommonControl::OnCreate();
9516 get { return toolTip ? toolTip.tip : null; }
9522 // (Very) Ugly work around for the fact that the parent watcher
9523 // won't fire when it's already been disconnected...
9524 eInstance_FireSelfWatchers(toolTip,
9525 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9531 toolTip.parent = this;
9540 public class Percentage : float
9542 char * OnGetString(char * string, float * fieldData, bool * needClass)
9546 sprintf(string, "%.2f", this);
9547 c = strlen(string)-1;
9550 if(string[c] != '0')
9551 last = Max(last, c);
9552 if(string[c] == '.')
9565 public void ApplySkin(Class c, char * name, void ** vTbl)
9567 char className[1024];
9572 subclass(Window) wc = (subclass(Window))c;
9573 subclass(Window) base = (subclass(Window))c.base;
9575 sprintf(className, "%sSkin_%s", name, c.name);
9576 wc.pureVTbl = c._vTbl;
9577 c._vTbl = new void *[c.vTblSize];
9578 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9579 sc = eSystem_FindClass(c.module.application, className);
9583 for(m = 0; m < c.base.vTblSize; m++)
9585 if(c._vTbl[m] == base.pureVTbl[m])
9586 c._vTbl[m] = vTbl[m];
9591 for(m = 0; m < c.vTblSize; m++)
9593 if(sc._vTbl[m] != wc.pureVTbl[m])
9594 c._vTbl[m] = sc._vTbl[m];
9598 for(d = c.derivatives.first; d; d = d.next)
9600 ApplySkin(d.data, name, c._vTbl);
9604 public void UnapplySkin(Class c)
9606 char className[1024];
9608 subclass(Window) wc = (subclass(Window))c;
9609 subclass(Window) base = (subclass(Window))c.base;
9612 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9615 c._vTbl = wc.pureVTbl;
9619 for(d = c.derivatives.first; d; d = d.next)
9621 UnapplySkin(d.data);
9625 void CheckFontIntegrity(Window window)
9630 if(window.usedFont && window.usedFont.font == 0xecececec)
9632 FontResource uf = window.usedFont;
9633 char * className = window._class.name;
9634 char * text = window.text;
9637 for(c = window.firstChild; c; c = c.next)
9638 CheckFontIntegrity(c);
9642 public class ControllableWindow : Window
9644 /*WindowController controller;
9645 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9646 ~ControllableWindow() { delete controller; }*/
9649 class WindowControllerInterface : ControllableWindow
9651 bool OnKeyDown(Key key, unichar ch)
9653 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9655 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9659 bool OnKeyUp(Key key, unichar ch)
9661 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9663 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9667 bool OnKeyHit(Key key, unichar ch)
9669 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9671 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9675 bool OnMouseMove(int x, int y, Modifiers mods)
9677 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9679 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9683 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9685 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9687 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9691 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9693 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9695 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9699 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9701 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9703 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9707 bool OnRightButtonDown(int x, int y, Modifiers mods)
9709 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9711 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9715 bool OnRightButtonUp(int x, int y, Modifiers mods)
9717 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9719 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9723 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9725 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9727 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9731 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9733 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9735 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9739 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9741 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9743 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9747 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9749 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9751 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9755 void OnResize(int width, int height)
9757 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9758 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9761 void OnRedraw(Surface surface)
9763 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9764 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9769 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9771 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9775 bool OnLoadGraphics()
9777 bool result = ((int(*)())(void *)controller.OnLoadGraphics)((void *)controller.controlled, (void *)controller);
9779 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics](controller.window);
9783 void OnUnloadGraphics()
9785 ((int(*)())(void *)controller.OnUnloadGraphics)((void *)controller.controlled, (void *)controller);
9786 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics](controller.window);
9790 public class WindowController<class V>
9793 property Window window
9797 uint size = class(Window).vTblSize;
9800 windowVTbl = new void *[size];
9801 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9802 if(value._vTbl == value._class._vTbl)
9804 value._vTbl = new void *[value._class.vTblSize];
9805 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9809 for(c = 0; c < size; c++)
9811 void * function = class(WindowControllerInterface)._vTbl[c];
9812 if(function != DefaultFunction)
9813 value._vTbl[c] = function;
9815 value._vTbl[c] = windowVTbl[c];
9820 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9823 get { return window; }
9825 property V controlled
9827 set { controlled = value; }
9828 get { return controlled; }
9830 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9831 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9832 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9833 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9834 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9835 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9836 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9837 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9838 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9839 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9840 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9841 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9842 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9843 virtual void V::OnResize(WindowController controller, int width, int height);
9844 virtual void V::OnRedraw(WindowController controller, Surface surface);
9845 virtual bool V::OnCreate(WindowController controller);
9846 virtual bool V::OnLoadGraphics(WindowController controller);
9847 virtual void V::OnUnloadGraphics(WindowController controller);
9850 int (** windowVTbl)();