7 import "GuiApplication"
28 #if defined(__WIN32__)
29 import "Win32Interface"
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
36 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
45 // 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
47 define skinMenuHeight = 40;
48 define statusBarHeight = 30;
50 define skinMenuHeight = 25;
51 define statusBarHeight = 18;
54 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
56 public enum DialogResult : int64 { cancel, yes, no, ok };
58 public class MouseButtons
61 bool left:1, right:1, middle:1;
64 public struct SizeAnchor
67 bool isClientW, isClientH;
72 #define SNAPDOWN(x, d) \
75 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
78 #define SNAPUP(x, d) \
81 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
84 /*static */define MAX_DIRTY_BACK = 10;
86 /////////////////////////////////////////////////////////////////////////////
87 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
88 /////////////////////////////////////////////////////////////////////////////
90 #define ACCESS_ITEM(l, id) \
93 #define FASTLIST_LOOP(l, v) \
94 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
96 #define FASTLIST_LOOPN(l, v, n) \
97 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
100 #define ACCESS_ITEM(l, id) \
101 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
103 #define FASTLIST_LOOP(l, v) \
104 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
106 #define FASTLIST_LOOPN(l, v, n) \
107 for( v = (void *)ACCESS_ITEM((l), (l).first), \
108 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
109 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
112 private class FastItem : struct
117 private struct FastList
122 int count, size, itemSize;
129 first = last = free = -1;
137 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
140 FastItem Add(uint itemSize)
143 if(free == -1 || !size)
150 newSize = (size + (size >> 1));
151 items = (FastItem)renew items byte[newSize * itemSize];
156 this.itemSize = itemSize;
157 items = (FastItem)new byte[newSize * itemSize];
160 for(c = size; c<newSize-1; c++)
162 ACCESS_ITEM(this, c).prev = -1;
163 ACCESS_ITEM(this, c).next = c+1;
165 ACCESS_ITEM(this, c).prev = -1;
166 ACCESS_ITEM(this, c).next = -1;
170 item = ACCESS_ITEM(this, free);
173 ACCESS_ITEM(this, item.prev).next = free;
183 void Delete(FastItem item)
186 ACCESS_ITEM(this, item.prev).next = item.next;
188 ACCESS_ITEM(this, item.next).prev = item.prev;
190 if(ACCESS_ITEM(this, first) == item)
192 if(ACCESS_ITEM(this, last) == item)
197 free = ((byte *)item - (byte *)items) / itemSize;
205 free = first = last = -1;
209 private class BoxItem : Item //FastItem
214 public /*private */struct Extent : OldList //FastList
223 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
224 Add(BoxItem { box = box });
227 void Copy(Extent source)
233 //FASTLIST_LOOP(source, extentBox)
234 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
235 AddBox(extentBox.box);
238 void IntersectBox(Box box)
240 // Clip all boxes of extent against inside of the new box
241 BoxItem extentBox, next;
243 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
244 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
246 next = (BoxItem)extentBox.next;
247 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
248 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
249 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
250 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
251 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
256 void ExcludeBox(Box box, Extent temp)
263 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
265 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
266 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
269 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
273 extentBox.box.left, extentBox.box.top,
274 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
280 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
284 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
285 extentBox.box.right, extentBox.box.bottom
291 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
294 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
298 extentBox.box.left, Max(extentBox.box.top, box.top),
299 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
305 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
309 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
310 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
318 AddBox(extentBox.box);
324 void UnionBox(Box box, Extent temp)
326 BoxItem extentBox, next;
328 // First pass: check if this box is not already covered by one of the extent's box
329 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
331 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
332 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
339 // Second pass: only keep boxes not completely covered in the new box
340 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
342 next = (BoxItem)extentBox.next;
343 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
344 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
348 // Add the exclusion to the extent
349 ExcludeBox(box, temp);
352 if(box.bottom >= box.top && box.right >= box.left)
354 // Optimization: if the resulting boxes touch, add them smarter
355 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
357 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
359 if(Abs(box.right - extentBox.box.left) <= 1)
361 extentBox.box.left = box.left;
364 else if(Abs(box.left - extentBox.box.right) <= 1)
366 extentBox.box.right = box.right;
370 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
372 if(Abs(box.bottom - extentBox.box.top) <= 1)
374 extentBox.box.top = box.top;
377 else if(Abs(box.top - extentBox.box.bottom) <= 1)
379 extentBox.box.bottom = box.bottom;
391 void Union(Extent b, Extent temp)
395 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
396 UnionBox(extentBox.box, temp);
399 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
406 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
409 temp2.IntersectBox(extentBox.box);
416 void Exclusion(Extent b, Extent temp)
419 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
420 ExcludeBox(extentBox.box, temp);
423 void Offset(int x, int y)
426 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
428 extentBox.box.left += x;
429 extentBox.box.top += y;
430 extentBox.box.right += x;
431 extentBox.box.bottom += y;
436 private define MINIMIZED_WIDTH = 160;
437 private define CASCADE_SPACE = 16;
439 // namespace Windows;
441 private class ScrollFlags
443 bool snapX:1, snapY:1, dontHide:1;
446 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
448 class WindowBits : BorderBits
450 BorderBits borderBits:6:0;
451 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
452 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
453 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
456 public enum BorderStyle : BorderBits
459 contour = BorderBits { contour = true },
460 fixed = BorderBits { fixed = true } | contour,
461 sizable = BorderBits { sizable = true } | fixed,
462 thin = BorderBits { fixed = true, thin = true } | contour,
463 sizableThin = BorderBits { sizable = true } | thin,
464 deep = BorderBits { deep = true },
465 bevel = BorderBits { bevel = true },
466 sizableDeep = sizable|deep,
467 sizableBevel = sizable|bevel,
468 fixedDeep = fixed|deep,
469 fixedBevel = fixed|bevel,
470 deepContour = deep|contour
473 public enum CreationActivationOption
475 activate, flash, doNothing
478 public enum WindowState { normal, minimized, maximized };
480 private class ResPtr : struct
487 private class HotKeySlot : struct
489 HotKeySlot prev, next;
497 class_data const char * icon;
499 class_default_property caption;
500 // class_initialize GuiApplication::Initialize;
501 class_designer FormDesigner;
502 class_property const char * icon
504 set { class_data(icon) = value; }
505 get { return class_data(icon); }
510 bool switchMode = true;
511 #if defined(__ANDROID__)
516 guiApp.Initialize(switchMode);
518 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
520 if(_vTbl == ((subclass(Window))_class).pureVTbl)
522 _vTbl = _class._vTbl;
524 else if(_vTbl != _class._vTbl)
527 for(m = 0; m < _class.vTblSize; m++)
529 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
530 _vTbl[m] = _class._vTbl[m];
535 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
536 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
537 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
538 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
542 // caption = CopyString(class.name);
544 children.offset = (byte*)&prev - (byte*)this;
545 childrenOrder.circ = true;
546 childrenCycle.circ = true;
548 maxSize = Size { MAXINT, MAXINT };
552 //style.isActiveClient = true;
555 modifyVirtArea = true;
556 manageDisplay = true;
557 nativeDecorations = true;
559 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
560 sbStep.x = sbStep.y = 8;
562 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
564 cursor = guiApp.GetCursor(arrow);
565 property::parent = guiApp.desktop;
575 #if !defined(__EMSCRIPTEN__)
578 int i, lockCount = guiApp.lockMutex.lockCount;
579 for(i = 0; i < lockCount; i++)
580 guiApp.lockMutex.Release();
582 for(i = 0; i < lockCount; i++)
583 guiApp.lockMutex.Wait();
589 stopwatching(parent, font);
590 if(parent.activeChild == this)
591 parent.activeChild = null;
592 if(parent.activeClient == this)
593 parent.activeClient = null;
598 // Prevent destructor from being called again...
604 /////////////////////////////////
607 OldLink slave = master.slaves.FindLink(this);
608 master.slaves.Delete(slave);
615 parent.childrenCycle.Remove(cycle);
617 parent.childrenOrder.Remove(order);
618 parent.children.Remove(this);
623 /////////////////////////////////
625 while((ptr = resources.first))
628 resources.Delete(ptr);
635 for(child = children.first; child; child = child.next)
637 // child.stopwatching(this, font);
639 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
640 // Don't want property here
641 *&child.parent = null;
644 while((slave = slaves.first))
646 // Don't want property here
647 *&((Window)slave.data).master = null;
648 slaves.Delete(slave);
651 // Because we do a decref in DestroyEx...
659 // Why was this commented?
660 //if(this != guiApp.desktop)
670 #if !defined(__EMSCRIPTEN__)
675 if(((subclass(Window))_class).pureVTbl)
677 if(_vTbl == _class._vTbl)
679 _vTbl = ((subclass(Window))_class).pureVTbl;
684 for(m = 0; m < _class.vTblSize; m++)
686 if(_vTbl[m] == _class._vTbl[m])
687 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
691 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
694 dirtyArea.Free(null);
695 renderArea.Free(null);
696 overRenderArea.Free(null);
697 clipExtent.Free(null);
698 scrollExtent.Free(null);
699 dirtyBack.Free(null);
703 tempExtents[0].Free(null);
704 tempExtents[1].Free(null);
705 tempExtents[2].Free(null);
706 tempExtents[3].Free(null);
713 //#if !defined(ECERE_VANILLA)
714 const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
716 if(this == activeDesigner)
720 const char * name = property::name;
721 return name ? name : "";
726 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
727 bool OnGetDataFromString(const char * string)
729 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
732 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
733 this = designer.form;
734 else if(!strcmpi(string, "(Desktop)"))
735 this = activeDesigner;
737 return activeDesigner.FindObject(&this, string);
743 // --- Window updates system ---
745 // Setup a bitmap for Redrawing on client area of Window
746 Surface Redraw(Box box)
748 Surface surface = null;
750 Box clientArea = this.clientArea;
754 mox.left -= clientStart.x;
755 mox.top -= clientStart.y;
756 mox.right -= clientStart.x;
757 mox.bottom -= clientStart.y;
759 mox.Clip(clientArea);
760 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
762 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
764 int x = absPosition.x + clientStart.x;
765 int y = absPosition.y + clientStart.y;
766 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
768 x -= rootWindow.clientStart.x;
769 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
771 if(!guiApp.fullScreenMode || is3D)
773 x -= rootWindow.absPosition.x;
774 y -= rootWindow.absPosition.y;
778 int dx = rootWindow.parent.parent.clientStart.x;
779 int dy = rootWindow.parent.parent.clientStart.y;
780 if(!rootWindow.parent.nativeDecorations)
782 dx += rootWindow.parent.clientStart.x;
783 dy += rootWindow.parent.clientStart.y;
797 surface = display.GetSurface(x, y, mox);
800 surface.width = clientSize.w;
801 surface.height = clientSize.h;
807 // Setup a bitmap for Redrawing on full Window
808 Surface RedrawFull(Box box)
810 Surface surface = null;
818 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
820 int x = absPosition.x;
821 int y = absPosition.y;
822 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
824 x -= rootWindow.clientStart.x;
825 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
827 if(!guiApp.fullScreenMode || is3D)
829 x -= rootWindow.absPosition.x;
830 y -= rootWindow.absPosition.y;
833 int dx = rootWindow.parent.parent.clientStart.x;
834 int dy = rootWindow.parent.parent.clientStart.y;
835 if(!rootWindow.parent.nativeDecorations)
837 dx += rootWindow.parent.clientStart.x;
838 dy += rootWindow.parent.clientStart.y;
852 surface = display.GetSurface(x, y, mox);
855 surface.width = size.w;
856 surface.height = size.h;
862 void FigureCaption(char * caption)
864 Window activeClient = null;
868 strcpy(caption, this.caption);
869 if(style.isDocument || fileName)
871 if(caption[0]) strcat(caption, " - ");
873 strcat(caption, fileName);
877 sprintf(title, "Untitled %d", documentID);
878 strcat(caption, title);
881 strcat(caption, " *");
886 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
888 if(activeClient && activeClient.state == maximized)
890 if(activeClient.caption)
892 if(caption[0]) strcat(caption, " - ");
893 strcat(caption, activeClient.caption);
895 if(activeClient.style.isDocument || activeClient.fileName)
897 if(caption[0]) strcat(caption, " - ");
898 strcat(caption, "[");
899 if(activeClient.fileName)
900 strcat(caption, activeClient.fileName);
904 sprintf(title, "Untitled %d", activeClient.documentID);
905 strcat(caption, title);
907 if(activeClient.modifiedDocument)
908 strcat(caption, " *");
909 strcat(caption, "]");
914 // Code for returning dirty from ScrollDisplay:
916 for(d = 0; d<scrollExtent.count; d++)
918 Box * box = &scrollExtent.boxes[d];
924 Min(box.right, box.left-scroll.x),box.bottom
926 dirtyArea.UnionBox(update);
932 Max(box.left, box.right-scroll.x), box.top,
933 box.right, box.bottom
935 dirtyArea.UnionBox(update);
943 box.right, Min(box.bottom, box.top-scroll.y),
945 dirtyArea.UnionBox(update);
951 box.left, Max(box.top, box.bottom-scroll.y),
952 box.right, box.bottom
954 dirtyArea.UnionBox(update);
959 void UpdateDecorations(void)
961 // TODO: *** TEMPORARY HACK ***
968 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
970 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
972 Update({ -clientStart.x,0, -1, clientSize.h-1 });
974 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
977 // Returns w & h for Position
978 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
980 Window parent = this.parent ? this.parent : guiApp.desktop;
981 int xOffset = 0, yOffset = 0;
982 int vpw = parent ? parent.clientSize.w : 0;
983 int vph = parent ? parent.clientSize.h : 0;
984 int pw = parent ? parent.clientSize.w : 0;
985 int ph = parent ? parent.clientSize.h : 0;
986 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
987 int x = anchor.left.distance, y = anchor.top.distance;
988 float ex = 0, ey = 0;
989 MinMaxValue ew = 0, eh = 0;
991 float cascadeW, cascadeH;
993 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
994 int addX = 0, addY = 0;
996 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
998 Window masterWindow = this;
999 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
1002 if(master == guiApp.desktop)
1003 masterWindow = guiApp.desktop.activeChild;
1005 masterWindow = master.rootWindow;
1006 if(!masterWindow) masterWindow = this;
1008 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
1009 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
1012 pw = vpw = box.right - box.left + 1;
1014 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
1017 ph = vph = box.bottom - box.top + 1;
1033 vpw = pw = parent.size.w;
1034 vph = ph = parent.size.h;
1036 else if(!style.fixed /*|| style.isDocument*/)
1038 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1039 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1041 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1044 Desktop3D_FixSize(&pw, &ph);
1045 Desktop3D_FixSize(&vpw, &vph);
1048 if(pw < skinMinSize.w) pw = skinMinSize.w;
1049 if(ph < skinMinSize.h) ph = skinMinSize.h;
1050 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1051 if(vph < skinMinSize.h) vph = skinMinSize.h;
1053 // TODO: Must fix what we're snapping
1056 if(anchor.left.type)
1058 SNAPUP(x, textCellW);
1060 else if(anchor.right.type)
1062 SNAPDOWN(x, textCellW);
1067 SNAPUP(y, textCellH);
1069 else if(anchor.bottom.type)
1071 SNAPDOWN(y, textCellH);
1075 // This is required to get proper initial decoration size using native decorations on Windows
1076 #if defined(__WIN32__)
1077 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1078 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1080 GetDecorationsSize(&ew, &eh);
1082 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1084 // Leave room for non client windows (eventually dockable panels)
1086 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1087 for(win = parent.children.first; win; win = win.next)
1089 if(!win.nonClient && !win.isActiveClient && win.visible)
1091 Size size = win.size;
1092 Point pos = win.position;
1093 int left = pos.x, top = pos.y;
1094 int right = pos.x + size.w, bottom = pos.y + size.h;
1095 if(win.size.w > win.size.h)
1098 loY = Max(loY, bottom);
1099 else if(top > ph - ph / 4)
1100 hiY = Min(hiY, top);
1105 loX = Max(loX, right);
1106 else if(left > pw - pw / 4)
1107 hiX = Min(hiX, left);
1116 if(parent.sbv && !parent.sbv.style.hidden)
1117 pw += guiApp.currentSkin.VerticalSBW();
1118 if(parent.sbh && !parent.sbh.style.hidden)
1119 ph += guiApp.currentSkin.HorizontalSBH();
1121 if(anchor.left.type == cascade)
1123 w = (int)(pw * 0.80);
1124 h = (int)(ph * 0.80);
1126 else if(anchor.left.type >= vTiled)
1131 numTiling = parent.numPositions - parent.numIcons;
1132 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1133 if(anchor.left.type == vTiled)
1135 tilingH = (int)sqrt(numTiling);
1136 tilingW = numTiling / tilingH;
1140 tilingW = (int)sqrt(numTiling);
1141 tilingH = numTiling / tilingW;
1144 leftOver = numTiling - tilingH * tilingW;
1147 tilingSplit = (tilingW - leftOver) * tilingH;
1148 tilingLastH = tilingH+1;
1151 tilingSplit = numTiling;
1153 if(positionID >= tilingSplit)
1155 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1156 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1157 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1158 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1162 x = xOffset + pw * (positionID / tilingH) / tilingW;
1163 y = yOffset + ph * (positionID % tilingH) / tilingH;
1164 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1165 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1169 SNAPDOWN(x, textCellW);
1170 SNAPDOWN(y, textCellH);
1171 SNAPDOWN(x2, textCellW);
1172 SNAPDOWN(y2, textCellH);
1180 if(sizeAnchor.isClientW) w += ew;
1181 if(sizeAnchor.isClientH) h += eh;
1183 if(anchor.left.type == offset)
1184 x = anchor.left.distance;
1185 else if(anchor.left.type == relative)
1186 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1187 else if(anchor.right.type == relative)
1188 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1189 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1190 else if(anchor.right.type == offset)
1191 ex = vpw - anchor.right.distance;
1193 if(anchor.top.type == offset)
1194 y = anchor.top.distance;
1195 else if(anchor.top.type == relative)
1196 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1197 else if(anchor.bottom.type == relative)
1198 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1199 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1200 else if(anchor.bottom.type == offset)
1201 ey = vph - anchor.bottom.distance;
1203 if(anchor.left.type && anchor.right.type)
1205 switch(anchor.right.type)
1208 ex = pw * (1.0f-anchor.right.percent);
1209 w = Max((int)(ex + 0.5) - x, 0);
1212 ex = vpw - anchor.right.distance;
1213 w = Max((int)(ex + 0.5) - x, 0);
1217 if(anchor.top.type && anchor.bottom.type)
1219 switch(anchor.bottom.type)
1222 ey = ph * (1.0f-anchor.bottom.percent);
1223 h = Max((int)(ey + 0.5) - y, 0);
1226 ey = vph - anchor.bottom.distance;
1227 h = Max((int)(ey + 0.5) - y, 0);
1236 if(state == normal /*|| state == Hidden*/)
1238 bool addSbV = false, addSbH = false;
1240 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1241 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1243 w = Max(w, minSize.w);
1244 h = Max(h, minSize.h);
1245 w = Min(w, maxSize.w);
1246 h = Min(h, maxSize.h);
1248 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1250 if(w) w -= guiApp.currentSkin.VerticalSBW();
1253 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1255 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1259 if(!OnResizing(&w, &h))
1265 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1266 w += guiApp.currentSkin.VerticalSBW();
1267 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1268 h += guiApp.currentSkin.HorizontalSBH();
1270 w = Max(w, skinMinSize.w);
1271 h = Max(h, skinMinSize.h);
1284 SNAPDOWN(w, textCellW);
1285 SNAPDOWN(h, textCellH);
1288 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1290 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1293 (pw - w) / CASCADE_SPACE,
1294 (ph - h) / CASCADE_SPACE);
1300 cascW = (pw - w) / (numCascade-1);
1301 cascH = (ph - h) / (numCascade-1);
1302 SNAPDOWN(cascW, textCellW);
1303 SNAPDOWN(cascH, textCellH);
1304 cascadeW = (float)cascW;
1305 cascadeH = (float)cascH;
1309 numCascade = Max(numCascade, 2);
1310 cascadeW = (float)(pw - w) / (numCascade-1);
1311 cascadeH = (float)(ph - h) / (numCascade-1);
1314 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1315 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1317 else if(anchor.left.type < vTiled)
1319 if(!anchor.left.type || anchor.horz.type == middleRelative)
1321 if(!anchor.right.type)
1323 if(anchor.horz.type == middleRelative)
1324 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1326 x = vpw / 2 + anchor.horz.distance - w / 2;
1332 // case A_EDGE: x = x - w; break;
1334 if(!anchor.top.type || anchor.vert.type == middleRelative)
1336 if(!anchor.bottom.type)
1338 if(anchor.vert.type == middleRelative)
1339 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1341 y = vph / 2 + anchor.vert.distance - h / 2;
1347 // case A_EDGE: y = y - h; break;
1350 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1358 SNAPDOWN(x, textCellW);
1359 SNAPDOWN(y, textCellH);
1371 if(anchored && style.fixed && style.isActiveClient)
1376 void UpdateCaret(bool forceUpdate, bool erase)
1378 static Window lastWindow = null;
1379 static int caretX, caretY, caretSize;
1381 if(guiApp && guiApp.caretOwner == this)
1383 int x = caretPos.x - scroll.x;
1384 int y = caretPos.y - scroll.y;
1386 if((erase || this.caretSize) &&
1387 x >= clientArea.left && x <= clientArea.right &&
1388 y >= clientArea.top && y <= clientArea.bottom)
1392 guiApp.interfaceDriver.SetCaret(
1393 x + absPosition.x + clientStart.x,
1394 y + absPosition.y + clientStart.y, this.caretSize);
1395 guiApp.caretEnabled = true;
1397 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1401 if(lastWindow != this)
1403 updateBox.left = x + 1;
1405 updateBox.right = x + 2;
1406 updateBox.bottom = y + this.caretSize - 1;
1410 updateBox.left = Min(x + 1, caretX + 1);
1411 updateBox.top = Min(y, caretY);
1412 updateBox.right = Max(x + 2, caretX + 2);
1413 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1416 guiApp.caretOwner.Update(updateBox);
1423 caretSize = this.caretSize;
1429 guiApp.interfaceDriver.SetCaret(0,0,0);
1430 guiApp.caretEnabled = false;
1436 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1441 scrolledPos.x = position.x = x;
1442 scrolledPos.y = position.y = y;
1444 clientSize.w = size.w = w;
1445 clientSize.h = size.h = h;
1447 if(parent && !style.nonClient)
1449 //if(!style.fixed || style.isDocument)
1451 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1452 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1456 clientStart.x = clientStart.y = 0;
1458 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1460 //if(!activeClient || activeClient.state != maximized)
1461 if(!noAutoScrollArea)
1463 // Check if scroll area must be modified
1464 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1466 bool foundChild = false;
1468 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1469 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1470 for(child = children.first; child; child = child.next)
1472 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1473 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1475 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1476 w = Max(w, child.position.x + child.size.w);
1477 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1478 w = Max(w, Max(child.position.x, 0) + child.size.w);
1479 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1480 h = Max(h, child.position.y + child.size.h);
1481 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1482 h = Max(h, Max(child.position.y, 0) + child.size.h);
1487 if(foundChild && (w > cw || h > ch))
1489 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1491 int stepX = sbStep.x, stepY = sbStep.y;
1492 // Needed to make snapped down position match the skin's check of client area
1493 // against realvirtual
1496 SNAPDOWN(stepX, textCellW);
1497 SNAPDOWN(stepY, textCellH);
1498 stepX = Max(stepX, textCellW);
1499 stepY = Max(stepY, textCellH);
1501 if(scrollFlags.snapX)
1503 if(scrollFlags.snapY)
1506 reqScrollArea.w = w;
1507 reqScrollArea.h = h;
1510 else if(reqScrollArea.w || reqScrollArea.h)
1512 reqScrollArea.w = 0;
1513 reqScrollArea.h = 0;
1514 SetScrollPosition(0,0);
1519 // Automatic MDI Client Scrolling Area Adjustment
1520 if(parent && !parent.noAutoScrollArea)
1522 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1523 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1525 Window parent = this.parent;
1526 int w = parent.reqScrollArea.w;
1527 int h = parent.reqScrollArea.h;
1529 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1530 w = Max(w, position.x + size.w);
1531 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1532 w = Max(w, Max(position.x, 0) + size.w);
1533 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1534 h = Max(h, position.y + size.h);
1535 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1536 h = Max(h, Max(position.y, 0) + size.h);
1538 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1539 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1541 /*bool resize = false;
1542 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1543 // Needed to make snapped down position match the skin's check of client area
1544 // against realvirtual
1547 SNAPDOWN(stepX, textCellW);
1548 SNAPDOWN(stepY, textCellH);
1549 stepX = Max(stepX, textCellW);
1550 stepY = Max(stepY, textCellH);
1552 if(parent.scrollFlags.snapX)
1554 if(parent.scrollFlags.snapY)
1556 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1558 parent.reqScrollArea.w = w;
1559 parent.reqScrollArea.h = h;*/
1561 // parent.UpdateScrollBars(true, true);
1562 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1563 false, true, true, true, false, false);
1568 GetRidOfVirtualArea();
1572 UpdateScrollBars(modifyThisArea, false);
1573 else if(guiApp.currentSkin)
1576 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1578 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1579 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1580 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1581 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1584 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1585 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1587 absPosition = scrolledPos;
1588 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1589 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1591 if(this != guiApp.desktop && parent)
1593 absPosition.x += parent.absPosition.x;
1594 absPosition.y += parent.absPosition.y;
1595 if(!style.nonClient && this != guiApp.desktop)
1597 absPosition.x += parent.clientStart.x;
1598 absPosition.y += parent.clientStart.y;
1602 box = Box { 0, 0, size.w - 1, size.h - 1 };
1607 // Clip against parent's client area
1608 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1610 // Compute client area in this window coordinate system
1611 clientArea.left = 0;
1613 clientArea.right = clientSize.w - 1;
1614 clientArea.bottom = clientSize.h - 1;
1616 // Clip against parent's client area
1618 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1622 //absPosition.x -= parent.clientStart.x;
1623 //absPosition.y -= parent.clientStart.y;
1626 // Adjust all children
1627 for(child = children.first; child; child = child.next)
1628 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1630 UpdateCaret(false, false);
1633 void GetRidOfVirtualArea(void)
1635 if(parent && !parent.destroyed && style.fixed &&
1636 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1637 parent.reqScrollArea.w && parent.reqScrollArea.h)
1639 if(!parent.noAutoScrollArea)
1641 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1645 for(child = children.first; child; child = child.next)
1647 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1649 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1650 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1660 Window parent = this.parent;
1662 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1663 false, true, true, true, false, false);
1665 parent.SetScrollArea(0,0,true);
1666 parent.SetScrollPosition(0,0);
1672 public void ExternalPosition(int x, int y, int w, int h)
1674 Position(x, y, w, h, false, true, true, true, false, false);
1675 /* TO REVIEW: Redj's code trying to fix position saving
1680 normalAnchor = Anchor { left = x, top = y };
1681 normalSizeAnchor = SizeAnchor { { w, h } };
1688 // (w, h): Full window size
1689 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1691 bool result = false;
1692 int oldCW = clientSize.w, oldCH = clientSize.h;
1693 bool clientResized, windowResized, windowMoved;
1695 //bool realResized = size.w != w || size.h != h;
1697 // TOCHECK: This wasn't in ecere.dll
1698 //if(!parent) return true;
1699 if(destroyed) return false;
1701 windowMoved = position.x != x || position.y != y || force;
1703 // windowResized = realResized || force;
1704 windowResized = size.w != w || size.h != h || force;
1706 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1712 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1713 scrolledPos.x - parent.clientStart.x + this.box.right,
1714 scrolledPos.y - parent.clientStart.y + this.box.bottom
1720 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1725 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1727 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1728 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1729 windowResized = true;
1731 if(display && rootWindow != this)
1734 if(guiApp && guiApp.windowMoving)
1736 if(guiApp.windowMoving.style.nonClient)
1737 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1739 guiApp.windowMoving.parent.SetMouseRangeToClient();
1749 // Buttons bitmap resources crash if we do this while switching mode
1750 if(!guiApp || !guiApp.modeSwitching)
1753 // Process Anchored Children
1757 for(child = children.first; child; child = child.next)
1760 ((child.stateAnchor.left.type != offset ||
1761 child.stateAnchor.top.type != offset ||
1762 child.stateAnchor.right.type != none ||
1763 child.stateAnchor.bottom.type != none) ||
1764 child.state == maximized || child.state == minimized))
1766 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1768 // child.Position(x, y, w, h, false, true, true, true, false);
1769 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1770 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1776 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1777 //if(updateScrollBars)
1779 OnResize(clientSize.w, clientSize.h);
1781 if((clientResized || windowMoved) && created)
1782 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1784 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1786 Window master = guiApp.interimWindow.master;
1787 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1790 if(rootWindow == this && !is3D)
1794 x -= guiApp.desktop.absPosition.x;
1795 y -= guiApp.desktop.absPosition.y;
1797 //guiApp.Log("Position %s\n", caption);
1800 if(windowResized || windowMoved)
1801 if(display && !display.flags.memBackBuffer && changeRootWindow)
1802 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1804 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1805 for(child = parent.children.first; child && child != this; child = child.next)
1806 if(child.rootWindow)
1807 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1812 if(windowMoved || windowResized)
1814 display.Lock(true /*false*/);
1817 display.Position(absPosition.x, absPosition.y);
1818 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1821 // result = realResized ? display.Resize(size.w, size.h) : true;
1822 if(nativeDecorations && rootWindow.windowHandle)
1824 int w = clientSize.w, h = clientSize.h;
1825 if(hasMenuBar) h += skinMenuHeight;
1826 if(hasStatusBar) h += statusBarHeight;
1827 if(sbv && sbv.visible) w += sbv.size.w;
1828 if(sbh && sbh.visible) h += sbh.size.h;
1829 result = manageDisplay ? display.Resize(w, h) : true;
1832 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1836 else if(clientResized)
1838 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1841 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1845 if(windowMoved || windowResized)
1850 if(guiApp.driver && changeRootWindow && windowHandle)
1852 if(windowResized || windowMoved)
1853 if(!display || display.flags.memBackBuffer)
1854 guiApp.interfaceDriver.PositionRootWindow(this,
1855 x, y, w, h, windowMoved, windowResized);
1856 guiApp.interfaceDriver.UpdateRootWindow(this);
1858 for(child = children.first; child; child = child.next)
1860 if(child.is3D && child.created)
1862 // Copy Display Content
1863 child.display.displaySystem = display.displaySystem;
1864 child.display.window = display.window;
1865 child.display.current = display.current;
1866 child.display.width = display.width;
1867 child.display.height = display.height;
1868 child.display.driverData = display.driverData;
1869 #if !defined(__EMSCRIPTEN__)
1870 child.display.mutex = null;
1882 void UpdateScrollBars(bool flag, bool fullThing)
1885 bool resizeH = false, resizeV = false;
1886 bool scrolled = false;
1887 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1888 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1890 if(destroyed) return;
1891 if(guiApp.currentSkin)
1893 MinMaxValue cw = 0, ch = 0;
1894 bool sbvVisible, sbhVisible;
1895 int rangeH = 0, rangeV = 0;
1896 int positionH = 0, positionV;
1898 // First get client area with no respect to scroll bars
1903 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1905 if(scrollFlags.dontHide)
1908 cw -= guiApp.currentSkin.VerticalSBW();
1910 ch -= guiApp.currentSkin.HorizontalSBH();
1912 // Update the scrollbar visibility
1918 sbh.disabled = rangeH <= 1;
1919 if(sbh.style.hidden)
1929 sbv.disabled = rangeV <= 1;
1930 if(sbv.style.hidden)
1938 int oldHRange = sbh ? sbh.range : 0;
1939 int oldVRange = sbv ? sbv.range : 0;
1940 // Then start off with horizontal scrollbar range
1943 positionH = sbh.thumbPosition;
1950 SBSetTotal(sbh, rvw);
1953 ch -= guiApp.currentSkin.HorizontalSBH();
1956 // Do the same for vertical scrollbar
1959 positionV = sbv.thumbPosition;
1965 SBSetTotal(sbv, rvh);
1969 cw -= guiApp.currentSkin.VerticalSBW();
1970 // Maybe we need to set the range on the horizontal scrollbar again
1978 SBSetTotal(sbh, rvw);
1979 //sbh.Action(setRange, positionH, 0);
1980 if(rangeH <= 1 && sbh.range > 1)
1982 ch -= guiApp.currentSkin.HorizontalSBH();
1988 SBSetTotal(sbv, rvh);
1990 //sbv.Action(setRange, positionV, 0);
1995 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1996 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1999 // Update the scrollbar visibility
2000 if(!scrollFlags.dontHide)
2002 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
2006 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2013 if(guiApp.currentSkin)
2020 sbhVisible = sbh.style.hidden ? true : false;
2022 sbvVisible = sbv.style.hidden ? true : false;
2024 // Do our resize here
2025 if(flag && (resizeH || resizeV) && fullThing)
2027 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2032 OnResize(clientSize.w, clientSize.h);
2038 sbh.visible = sbhVisible;
2040 sbv.visible = sbvVisible;
2042 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2043 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2046 sbh.pageStep = clientSize.w;
2048 sbv.pageStep = clientSize.h;
2050 // Notify doesn't handle setRange anymore... process it here
2053 int positionH = sbh.thumbPosition;
2054 if(scroll.x != positionH)
2056 OnHScroll(setRange, positionH, 0);
2060 SNAPDOWN(positionH, textCellW);
2061 scroll.x = positionH;
2067 int seen = clientSize.w, total = reqScrollArea.w;
2070 if(scrollFlags.snapX)
2071 SNAPDOWN(seen, sbStep.x);
2073 if(!total) total = seen;
2074 range = total - seen + 1;
2076 range = Max(range, 1);
2078 if(x >= range) x = range - 1;
2080 if(scrollFlags.snapX)
2081 SNAPUP(x, sbStep.x);
2085 OnHScroll(setRange, x, 0);
2090 SNAPDOWN(x, textCellW);
2096 int positionV = sbv.thumbPosition;
2097 if(scroll.y != positionV)
2099 OnVScroll(setRange, positionV, 0);
2103 SNAPDOWN(positionV, textCellH);
2104 scroll.y = positionV;
2110 int seen = clientSize.h, total = reqScrollArea.h;
2113 if(scrollFlags.snapY)
2114 SNAPDOWN(seen, sbStep.y);
2116 if(!total) total = seen;
2117 range = total - seen + 1;
2118 range = Max(range, 1);
2120 if(y >= range) y = range - 1;
2122 if(scrollFlags.snapY)
2123 SNAPUP(y, sbStep.y);
2127 OnVScroll(setRange, y, 0);
2132 SNAPDOWN(y, textCellH);
2138 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2141 for(child = children.first; child; child = child.next)
2143 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2146 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2147 child.Position(x, y, w, h, false, true, false, true, false, false);
2154 // Process Scrollbars
2156 if(sbh) // && !sbh.style.hidden
2159 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2160 // Need to set the range again (should improve...) since the scrollbars didn't have
2161 // the right size when UpdateScrollArea set the range on it
2164 sbh.seen = clientSize.w;
2168 if(sbv) // && !sbv.state.hidden
2171 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2172 // Need to set the range again (should improve...) since the scrollbars didn't have
2173 // the right size when UpdateScrollArea set the range on it
2176 sbv.seen = clientSize.h;
2181 // TESTING THIS LOWER
2182 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2185 for(child = children.first; child; child = child.next)
2187 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2190 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2191 child.Position(x, y, w, h, false, true, false, true, false, false);
2197 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2199 SetState(maximized, false, mods);
2203 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2205 SetState(normal, false, mods);
2209 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2211 SetState(minimized, false, mods);
2212 parent.CycleChildren(false, true, false, true);
2216 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2219 // Scroll bar notifications
2220 if(action != setRange)
2222 bool changed = false;
2226 if(scroll.x != position)
2228 OnHScroll(action, position, keyFlags);
2233 SNAPDOWN(position, textCellW);
2235 scroll.x = position;
2239 if(scroll.y != position)
2241 OnVScroll(action, position, keyFlags);
2246 SNAPDOWN(position, textCellH);
2248 scroll.y = position;
2252 bool childMove = false;
2253 for(child = children.first; child; child = child.next)
2255 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2258 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2259 child.Position(x, y, w, h, false, true, false, true, false, false);
2263 // Testing this patch out to solve MDI workspace redraw bugs
2264 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2265 // Scroll offsets to blame?
2269 UpdateCaret(false, false);
2273 // Testing this patch out to solve MDI workspace redraw bugs
2274 for(child = children.first; child; child = child.next)
2276 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2285 Window GetParentMenuBar()
2287 Window menuBarParent;
2288 if(formDesigner) return null;
2289 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2291 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2292 if(menuBarParent && !menuBarParent.isActiveClient)
2298 void CreateSystemChildren(void)
2300 Window parent = this;
2301 bool scrollBarChanged = false;
2302 bool hasClose = false, hasMaxMin = false;
2303 Point scroll = this.scroll;
2305 if(state == maximized)
2307 parent = GetParentMenuBar();
2314 if(style.hasClose) hasClose = true;
2315 if(style.hasMaximize || style.hasMinimize)
2322 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2324 sysButtons[2].Destroy(0);
2325 sysButtons[2] = null;
2327 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2329 sysButtons[1].Destroy(0);
2330 sysButtons[1] = null;
2332 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2334 sysButtons[0].Destroy(0);
2335 sysButtons[0] = null;
2338 if(hasClose && parent)
2345 parent, master = this,
2346 inactive = true, nonClient = true, visible = false;
2348 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2354 if(this.parent == guiApp.desktop)
2355 sysButtons[2].hotKey = altF4;
2356 else if(style.isActiveClient)
2357 sysButtons[2].hotKey = ctrlF4;
2358 sysButtons[2].Create();
2361 sysButtons[2].symbol = 'X';
2362 sysButtons[2].disabled = !style.hasClose;
2365 if(hasMaxMin && parent)
2369 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2370 if(state == maximized)
2373 method = RestoreButtonClicked;
2379 method = MaximizeButtonClicked;
2387 parent, master = this,
2388 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2390 sysButtons[1].Create();
2392 sysButtons[1].NotifyClicked = method;
2394 sysButtons[1].symbol = symbol;
2395 sysButtons[1].disabled = !style.hasMaximize;
2398 if(hasMaxMin && parent)
2402 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2403 if (state == minimized)
2406 method = RestoreButtonClicked;
2412 method = MinimizeButtonClicked;
2420 parent, master = this,
2421 hotKey = altM, inactive = true, nonClient = true, visible = false
2423 sysButtons[0].Create();
2425 sysButtons[0].NotifyClicked = method;
2427 sysButtons[0].symbol = symbol;
2428 sysButtons[0].disabled = !style.hasMinimize;
2431 // Create the scrollbars
2432 if(style.hasHorzScroll && !sbh)
2438 direction = horizontal,
2442 snap = scrollFlags.snapX,
2443 NotifyScrolling = ScrollBarNotification
2446 scrollBarChanged = true;
2448 else if(sbh && !style.hasHorzScroll)
2454 if(style.hasVertScroll && !sbv)
2460 direction = vertical,
2464 snap = scrollFlags.snapY,
2465 NotifyScrolling = ScrollBarNotification
2468 scrollBarChanged = true;
2470 else if(sbv && !style.hasVertScroll)
2475 if(scrollBarChanged)
2477 SetScrollLineStep(sbStep.x, sbStep.y);
2478 UpdateScrollBars(true, true);
2482 if(scrollBarChanged)
2484 if(sbh) sbh.thumbPosition = scroll.x;
2485 if(sbv) sbv.thumbPosition = scroll.y;
2489 void UpdateCaption(void)
2491 if(rootWindow == this)
2494 FigureCaption(caption);
2495 if(guiApp.interfaceDriver)
2496 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2498 UpdateDecorations();
2501 if(parent.activeClient == this) // Added this last check
2503 if(parent.rootWindow == parent)
2506 parent.FigureCaption(caption);
2507 if(guiApp.interfaceDriver)
2508 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2511 parent.UpdateCaption();
2513 parent.UpdateDecorations();
2517 void UpdateActiveDocument(Window previous)
2519 Window activeClient = this.activeClient;
2520 Window activeChild = this.activeChild;
2527 activeClient.CreateSystemChildren();
2529 previous.CreateSystemChildren();
2541 // Build window list
2544 Menu windowMenu = menu.FindMenu("Window");
2549 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2551 Window document = cycle.data;
2552 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2554 char name[2048], caption[2048];
2555 document.FigureCaption(caption);
2556 sprintf(name, "%d %s", id+1, caption);
2557 windowMenu.AddDynamic(MenuItem
2559 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2560 NotifySelect = MenuWindowSelectWindow
2564 if(activeClient.cycle == cycle) break;
2569 if((!previous && activeClient) || !activeClient)
2575 item = menu.FindItem(MenuWindowCloseAll, 0);
2576 if(item) item.disabled = false;
2577 item = menu.FindItem(MenuWindowNext, 0);
2578 if(item) item.disabled = false;
2579 item = menu.FindItem(MenuWindowPrevious, 0);
2580 if(item) item.disabled = false;
2581 item = menu.FindItem(MenuWindowCascade, 0);
2582 if(item) item.disabled = false;
2583 item = menu.FindItem(MenuWindowTileHorz, 0);
2584 if(item) item.disabled = false;
2585 item = menu.FindItem(MenuWindowTileVert, 0);
2586 if(item) item.disabled = false;
2587 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2588 if(item) item.disabled = false;
2589 item = menu.FindItem(MenuWindowWindows, 0);
2590 if(item) item.disabled = false;
2593 item = menu.FindItem(MenuFileClose, 0);
2594 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2595 item = menu.FindItem(MenuFileSaveAll, 0);
2596 if(item) item.disabled = numDocuments < 1;
2598 if(activeClient && activeClient.menu && activeClient.state != minimized)
2602 //activeClient.menu.Clean(activeClient);
2603 menu.Merge(activeClient.menu, true, activeClient);
2607 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2610 menu.Merge(activeChild.menu, true, activeChild);
2613 // This is called again for a child window change, with same active client
2614 OnActivateClient(activeClient, previous);
2615 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2616 parent.UpdateActiveDocument(null);
2619 void _ShowDecorations(Box box, bool post)
2621 if(rootWindow == this && nativeDecorations && !is3D) return;
2622 if(visible && this != guiApp.desktop)
2624 Surface surface = RedrawFull(box);
2628 FigureCaption(caption);
2631 ShowDecorations(captionFont.font,
2634 active, //parent.activeClient == this
2635 guiApp.windowMoving == this);
2637 PreShowDecorations(captionFont.font,
2640 active, //parent.activeClient == this
2641 guiApp.windowMoving == this);
2648 void UpdateExtent(Box refresh)
2650 Surface surface = null;
2652 if(!manageDisplay) { OnRedraw(null);return; }
2653 _ShowDecorations(refresh, false);
2655 surface = Redraw(refresh);
2656 // Opaque background: just fill before EW_REDRAW (clear?)
2659 surface.SetBackground(background);
2660 surface.SetForeground(foreground);
2661 surface.DrawingChar(' ');
2662 if(this == rootWindow)
2664 if(style.drawBehind || background.a)
2666 int a = background.a;
2667 // Premultiply alpha for clear color
2668 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2669 surface.Clear(colorBuffer);
2670 surface.SetBackground(background);
2673 else if(background.a)
2677 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2678 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2681 if(display.flags.alpha && background.a < 255 && background)
2683 surface.Area(0,0,clientSize.w, clientSize.h);
2684 /*if(style.clearDepthBuffer)
2685 surface.Clear(depthBuffer);*/
2687 else if(/*style.clearDepthBuffer || */background.a)
2689 int a = background.a;
2690 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2691 // Premultiply alpha for clear color
2692 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2693 surface.Clear(colorBuffer);
2694 surface.SetBackground(background);
2699 surface.TextFont(usedFont.font);
2700 surface.TextOpacity(false);
2704 // Draw the caret ...
2705 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2707 // surface.SetBackground(0xFFFFFF - background.color);
2708 surface.SetBackground(~background.color);
2710 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2711 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2717 void DrawOverChildren(Box refresh)
2719 Surface surface = Redraw(refresh);
2723 surface.DrawingChar(' ');
2724 surface.SetBackground(background);
2725 surface.SetForeground(foreground);
2727 surface.TextFont(usedFont.font);
2728 surface.TextOpacity(false);
2730 OnDrawOverChildren(surface);
2735 _ShowDecorations(refresh, true);
2738 void ComputeClipExtents(void)
2741 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2743 clipExtent.Copy(this.clipExtent);
2745 for(child = children.last; child; child = child.prev)
2747 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2749 bool opaque = child.IsOpaque(); // TODO: acess background directly
2750 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2752 child.clipExtent.Copy(clipExtent);
2753 child.clipExtent.Offset(-dx, -dy);
2754 child.clipExtent.IntersectBox(child.box);
2756 child.ComputeClipExtents();
2758 if(opaque && !child.style.nonClient)
2760 // Adjust the box for the parent:
2761 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2762 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2767 // ??? Only do this for overlapped window or if parent has with clip children flag
2769 // Do this if window has clip children flag on (default false?)
2770 // this.clipExtent = clipExtent;
2772 clipExtent.Free(null);
2775 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2778 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2779 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2781 offsetX -= rootWindow.clientStart.x;
2782 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2786 for(child = children.last; child; child = child.prev)
2788 bool opaque = child.IsOpaque();
2789 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2793 // Adjust renderArea to the root window level
2794 Extent * renderArea = &rootWindow.tempExtents[3];
2796 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2797 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2798 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2800 offsetX -= child.rootWindow.clientStart.x;
2801 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2805 Extent childRenderArea;
2807 if(backBufferUpdate != null)
2809 childRenderArea.Copy(backBufferUpdate);
2810 childRenderArea.Offset(-offsetX, -offsetY);
2813 childRenderArea.Copy(child.dirtyArea);
2815 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2816 renderArea.Copy(dirtyExtent);
2817 renderArea.Offset(-offsetX, -offsetY);
2818 childRenderArea.Union(renderArea);
2821 // Intersect with the clip extent
2822 childRenderArea.Intersection(child.clipExtent);
2825 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2827 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2828 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2830 renderArea->Offset(offsetX, offsetY);
2832 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2833 // overDirtyExtent.Union(renderArea);
2834 renderArea->Empty();
2835 // childRenderArea.Free();
2837 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2842 for(child = children.last; child; child = child.prev)
2844 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2846 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2851 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2853 bool opaque = IsOpaque();
2854 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2856 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2857 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2859 offsetX -= rootWindow.clientStart.x;
2860 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2864 for(child = children.last; child; child = child.prev)
2866 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2868 ColorAlpha background = *(ColorAlpha *)&child.background;
2869 bool opaque = child.IsOpaque();
2870 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2874 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2875 // Adjust renderArea to the root window level
2877 renderArea.Copy(child.dirtyArea);
2878 renderArea.Offset(offsetX, offsetY);
2879 dirtyExtent.Union(renderArea);
2880 overDirtyExtent.Union(renderArea);
2886 for(child = children.last; child; child = child.prev)
2888 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2890 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2894 if(backBufferUpdate != null)
2896 renderArea.Copy(backBufferUpdate);
2897 renderArea.Offset(-offsetX, -offsetY);
2899 overRenderArea.Copy(backBufferUpdate);
2900 overRenderArea.Offset(-offsetX, -offsetY);
2906 renderArea.Copy(dirtyArea);
2908 overRenderArea.Copy(dirtyArea);
2911 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2912 dirtyExtentWindow->Copy(dirtyExtent);
2913 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2914 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2915 dirtyExtentWindow->Empty();
2917 // Intersect with the clip extent
2918 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2921 if(renderArea.count > 10)
2924 printf("\nToo many extents (%d):\n", renderArea.count);
2926 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2927 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2932 for(c = 0; c<10; c++)
2935 FASTLIST_LOOP(renderArea, extentBox)
2937 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2939 renderArea.Copy(extent);
2941 FASTLIST_LOOP(renderArea, extentBox)
2944 printf("(%d, %d) - (%d, %d)\n",
2945 extentBox.box.left, extentBox.box.top,
2946 extentBox.box.right, extentBox.box.bottom);
2950 printf("\nNow %d\n", renderArea.count);
2956 // WHY WAS THIS COMMENTED ??
2958 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2959 dirtyExtentWindow->Copy(overDirtyExtent);
2960 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2961 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2962 dirtyExtentWindow->Empty();
2964 // Intersect with the clip extent
2965 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2971 if(scrollExtent.count)
2973 // Subtract render extent from scrolling extent
2974 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2976 if(backBufferUpdate == null)
2978 Extent * dirty = &rootWindow.tempExtents[3];
2981 // Intersect scrolling extent with clip extent
2982 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2984 // offset this scroll to be at the root window level
2985 scrollExtent.Offset(offsetX, offsetY);
2986 // Add area that was scrolled to the dirty extents of the back buffer
2987 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2991 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2992 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2993 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2998 scrollExtent.Empty();
3000 // Add the exposed extent to the window render area
3001 dirty->Offset(-offsetX, -offsetY);
3002 renderArea.Union(dirty, rootWindow.tempExtents[0]);
3007 // Subtract the window's box from the transparency forced extent
3008 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3014 renderArea.Copy(this.renderArea);
3015 renderArea.Offset(offsetX, offsetY);
3016 dirtyExtent.Union(renderArea);
3022 Extent renderArea { };
3024 renderArea.Copy(overRenderArea);
3025 renderArea.Offset(offsetX, offsetY);
3026 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3031 if(backBufferUpdate != null)
3033 // Remove render area from dirty area
3034 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3036 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3043 // Remove the window render area from the dirty extents of the back buffer
3044 rootWindow.dirtyBack.Exclusion(renderArea);
3048 void Render(Extent updateExtent)
3052 Window rootWindow = this.rootWindow;
3053 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3054 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3056 offsetX -= rootWindow.clientStart.x;
3057 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3060 if(rootWindow.fullRender)
3069 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3070 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3075 /*if(renderArea.count)
3076 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3079 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3081 Box box = extentBox.box;
3084 /*printf("(%d, %d) - (%d, %d)\n",
3085 extentBox.box.left, extentBox.box.top,
3086 extentBox.box.right, extentBox.box.bottom);*/
3091 box.left += offsetX;
3093 box.right += offsetX;
3094 box.bottom += offsetY;
3096 if(updateExtent != null)
3097 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3101 for(child = children.first; child; child = child.next)
3102 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3103 child.Render(updateExtent);
3105 if(rootWindow.fullRender)
3106 DrawOverChildren(box);
3109 // TO DO: There's an issue about draw over children...
3110 // TO DO: Don't wanna go through this if method isn't used
3111 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3112 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3114 Box box = extentBox.box;
3116 DrawOverChildren(box);
3118 box.left += offsetX;
3120 box.right += offsetX;
3121 box.bottom += offsetY;
3123 if(updateExtent != null)
3124 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3127 for(child = children.first; child; child = child.next)
3128 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3129 child.Render(updateExtent);
3132 overRenderArea.Empty();
3135 public void UpdateDisplay(void)
3137 if(!manageDisplay) { OnRedraw(null);return; }
3138 if(rootWindow && this != rootWindow)
3139 rootWindow.UpdateDisplay();
3142 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3143 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3146 dirtyExtent.Clear();
3149 clipExtent.AddBox(box);
3151 display.StartUpdate();
3153 if(!rootWindow.fullRender)
3155 ComputeClipExtents();
3156 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3157 ComputeRenderArea(dirtyExtent, overExtent, null);
3160 clipExtent.Free(null);
3162 dirtyExtent.Free(null);
3163 overExtent.Free(null);
3165 if(display.flags.flipping)
3168 display.Update(null);
3172 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3173 updateExtent.Clear();
3175 Render(updateExtent);
3177 updateExtent.UnionBox(this.box, tempExtents[0]);
3180 //printf("\n\nUpdate:\n------------------------------------------\n");
3183 //FASTLIST_LOOP(updateExtent, extentBox)
3184 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3187 /*printf("Updating (%d, %d) - (%d, %d)\n",
3188 extentBox.box.left, extentBox.box.top,
3189 extentBox.box.right, extentBox.box.bottom);*/
3192 display.Update(extentBox.box);
3195 updateExtent.Free(null);
3198 display.EndUpdate();
3206 void UpdateBackDisplay(Box box)
3212 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3214 //printf("UpdateBackDisplay going through!\n");
3215 display.StartUpdate();
3219 intersection.Copy(dirtyBack);
3220 intersection.IntersectBox(box);
3222 dirtyExtent.Clear();
3225 clipExtent.AddBox(box);
3227 if(!rootWindow.fullRender)
3229 ComputeClipExtents();
3230 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3233 clipExtent.Free(null);
3235 intersection.Free(null);
3236 dirtyExtent.Free(null);
3237 overExtent.Free(null);
3242 if(display.flags.flipping)
3243 display.Update(null);
3246 rootWindow.display.Update(box);
3249 display.EndUpdate();
3253 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3254 if(dirtyBack.count > MAX_DIRTY_BACK)
3256 BoxItem extentBox, next;
3257 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3258 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3260 next = (BoxItem)extentBox.next;
3261 if(extentBox != first)
3263 if(extentBox.box.left < first.box.left)
3264 first.box.left = extentBox.box.left;
3265 if(extentBox.box.top < first.box.top)
3266 first.box.top = extentBox.box.top;
3267 if(extentBox.box.right > first.box.right)
3268 first.box.right = extentBox.box.right;
3269 if(extentBox.box.bottom > first.box.bottom)
3270 first.box.bottom = extentBox.box.bottom;
3271 dirtyBack.Delete(extentBox);
3280 // --- Window positioning ---
3281 // --- Window identification ---
3283 // Returns window at position "Position"
3284 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3286 Window child, result = null;
3288 box.left += absPosition.x;
3289 box.right += absPosition.x;
3290 box.top += absPosition.y;
3291 box.bottom += absPosition.y;
3293 if(!destroyed && visible && (acceptDisabled || !disabled))
3295 int lx = x - absPosition.x;
3296 int ly = y - absPosition.y;
3297 if(IsInside(lx, ly))
3298 // if(box.IsPointInside(Point{x, y}))
3300 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3301 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3304 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3305 Window ancestor = null;
3307 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3308 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3310 if(child != statusBar && child.rootWindow == rootWindow)
3312 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3319 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3321 if(child != statusBar && child.rootWindow == rootWindow)
3323 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3330 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3338 Window FindModal(void)
3340 Window modalWindow = this, check;
3341 Window check2 = null;
3342 for(check = this; check.master; check = check.master)
3344 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3346 modalWindow = check.master.modalSlave;
3347 check = modalWindow;
3349 // TESTING THIS FOR DROPBOX...
3350 if(!rootWindow || !rootWindow.style.interim)
3352 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3354 if(check2.modalSlave && check2.modalSlave.created)
3356 modalWindow = check2.modalSlave;
3364 if(modalWindow == this)
3366 for(check = this; check.activeChild; check = check.activeChild)
3368 if(check.modalSlave)
3370 modalWindow = check.modalSlave;
3376 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3377 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3380 void StopMoving(void)
3382 if(this == guiApp.windowMoving)
3384 guiApp.windowMoving = null;
3385 UpdateDecorations();
3386 SetMouseRange(null);
3389 if(rootWindow.active)
3390 guiApp.interfaceDriver.StopMoving(rootWindow);
3392 guiApp.windowCaptured.ReleaseCapture();
3393 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3394 guiApp.windowIsResizing = false;
3398 void SelectMouseCursor(void)
3403 Window cursorWindow = null;
3404 bool rx, ry, rex, rey;
3406 guiApp.desktop.GetMousePosition(&x, &y);
3407 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3409 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3410 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3411 else if(mouseWindow)
3413 modalWindow = mouseWindow.FindModal();
3414 x -= mouseWindow.absPosition.x;
3415 y -= mouseWindow.absPosition.y;
3416 if(guiApp.windowIsResizing)
3418 rex = guiApp.resizeEndX;
3419 rey = guiApp.resizeEndY;
3420 rx = guiApp.resizeX;
3421 ry = guiApp.resizeY;
3422 if((rex && rey) || (rx && ry))
3423 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3424 else if((rex && ry) || (rx && rey))
3425 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3426 else if((ry || rey) && (!rx && !rex))
3427 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3428 else if((rx || rex) && (!ry && !rey))
3429 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3431 else if(!modalWindow && !guiApp.windowCaptured &&
3432 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3433 &rx, &ry, &rex, &rey))
3435 if((rex && rey) || (rx && ry))
3436 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3437 else if((rex && ry) || (rx && rey))
3438 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3439 else if((ry || rey) && (!rx && !rex))
3440 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3441 else if((rx || rex) && (!ry && !rey))
3442 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3444 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3446 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3447 mouseWindow.rootWindow != mouseWindow)
3448 cursorWindow = mouseWindow.parent;
3450 cursorWindow = mouseWindow;
3452 else if(!guiApp.interimWindow)
3453 cursorWindow = guiApp.windowCaptured;
3456 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3457 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3459 else if(modalWindow)
3461 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3463 else if(guiApp.interimWindow)
3465 if(guiApp.interimWindow.cursor)
3466 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3468 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3473 // --- State based input ---
3474 bool AcquireInputEx(bool state)
3479 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3480 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3482 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3484 guiApp.acquiredWindow = state ? this : null;
3487 SetMouseRangeToClient();
3488 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3493 SelectMouseCursor();
3495 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3499 // --- Window activation ---
3500 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3503 if(!parent || !parent.style.inactive)
3505 Window parent = this.parent;
3508 if(rootWindow == this)
3509 Log(active ? "active\n" : "inactive\n");
3511 if(active && requireRemaximize)
3513 if(state == maximized)
3515 property::state = normal;
3516 property::state = maximized;
3518 requireRemaximize = false;
3521 // Testing this here...
3522 if(!parent || parent == guiApp.desktop || parent.active)
3524 this.active = active;
3527 // TESTING THIS HERE
3528 UpdateDecorations();
3529 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3530 result = NotifyActivate(master, this, active, previous);
3533 this.active = !active;
3538 if(!parent || parent == guiApp.desktop || parent.active)
3540 this.active = active;
3542 AcquireInputEx(active);
3543 if(active && isEnabled)
3547 if(guiApp.caretOwner)
3551 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3552 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3553 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3554 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3556 guiApp.caretOwner.Update(extent);
3559 if(visible || !guiApp.caretOwner)
3560 guiApp.caretOwner = this;
3561 UpdateCaret(false, false);
3567 this.active = false;
3569 AcquireInputEx(active);
3571 if(!active && guiApp.caretOwner == this)
3573 UpdateCaret(false, true);
3574 guiApp.caretOwner = null;
3575 guiApp.interfaceDriver.SetCaret(0,0,0);
3576 guiApp.caretEnabled = false;
3581 if(!active && parent && parent.activeChild && parent.activeChild != this)
3582 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3588 if(!active && menuBar)
3591 menuBar.OnActivate(false, null, &goOn, true);
3592 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3597 Window aChild = activeChild;
3599 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3611 void ConsequentialMouseMove(bool kbMoving)
3615 if(kbMoving || !guiApp.windowMoving)
3619 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3621 if(guiApp.interfaceDriver)
3622 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3624 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3625 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3631 bool IsDescendantOf(Window ancestor)
3634 for(window = this; window && window != ancestor; window = window.parent);
3635 return window == ancestor;
3638 bool IsSlaveOf(Window master)
3641 for(window = this; window && window != master; window = window.master);
3642 return window == master;
3645 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3649 if(this && !destroyed /*&& state != Hidden*/)
3651 Window swap = externalSwap;
3659 if(activateParent &&
3660 (parent.activeChild != this ||
3661 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3662 active && _isModal &&
3663 parent != master && master)
3664 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3670 bool real = parent.activeChild != this;
3672 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3673 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3674 !IsDescendantOf(guiApp.interimWindow) &&
3675 !IsSlaveOf(guiApp.interimWindow))
3677 Window interimWindow = guiApp.interimWindow;
3678 while(interimWindow && interimWindow != this)
3680 Window master = interimWindow.master;
3682 guiApp.interimWindow = null;
3683 if(guiApp.caretOwner)
3684 guiApp.caretOwner.UpdateCaret(false, false);
3686 incref interimWindow;
3687 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3692 delete interimWindow;
3693 interimWindow = (master && master.style.interim) ? master : null;
3698 guiApp.interimWindow = this;
3699 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3700 guiApp.caretEnabled = false;*/
3701 UpdateCaret(false, true);
3706 //bool acquireInput = false;
3708 parent.activeChild &&
3709 parent.activeChild.state == maximized &&
3710 parent != guiApp.desktop;
3712 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3717 swap = parent.activeChild;
3718 if(swap && swap.destroyed) swap = null;
3719 if(swap && swap != this)
3722 if(!swap.PropagateActive(false, this, &goOn, true))
3723 swap = parent.activeChild;
3734 if(!parent || parent.activeChild != this || style.interim)
3737 result = PropagateActive(true, swap, &goOn, true);
3738 if(!result && !goOn)
3743 //acquireInput = true;
3747 if(style.hasMaximize && parent != guiApp.desktop)
3750 SetState(maximized, false, 0);
3751 else if(state != maximized)
3754 for(child = parent.children.first; child; child = child.next)
3756 if(this != child && child.state == maximized)
3757 child.SetState(normal, false, 0);
3764 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3766 Window previous = parent.activeClient;
3767 parent.activeChild = this;
3768 if(!style.nonClient /*&& style.isActiveClient*/)
3772 if(style.isActiveClient)
3773 parent.activeClient = this;
3774 // Moved UpdateActiveDocument inside hidden check
3775 // To prevent activating previous window while creating a new one
3776 // (It was messing up the privateModule in the CodeEditor)
3777 parent.UpdateActiveDocument(previous);
3783 //if(!style.isRemote)
3785 if(rootWindow != this)
3787 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3788 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3790 else if(!guiApp.fullScreenMode)
3792 Window modalRoot = FindModal();
3793 if(!modalRoot) modalRoot = this;
3794 if(!modalRoot.isForegroundWindow)
3796 modalRoot.isForegroundWindow = true;
3797 // To check : Why is parent null?
3798 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3800 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3802 modalRoot.isForegroundWindow = false;
3807 if(result && real && (!style.inactive || moveInactive) && parent)
3809 Window last = parent.children.last;
3811 if(!style.stayOnTop)
3812 for(; last && last.style.stayOnTop; last = last.prev);
3814 parent.children.Move(this, last);
3816 // Definitely don't want that: why not?
3820 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3826 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3833 parent.activeChild = null;
3834 if(!style.nonClient /*&& style.isActiveClient*/)
3836 Window previous = parent.activeClient;
3837 if(style.isActiveClient)
3838 parent.activeClient = null;
3839 parent.UpdateActiveDocument(previous);
3843 if(this == guiApp.interimWindow)
3845 guiApp.interimWindow = null;
3846 if(guiApp.caretOwner)
3847 guiApp.caretOwner.UpdateCaret(false, false);
3849 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3856 if(!active || !swap)
3857 UpdateDecorations();
3859 swap.UpdateDecorations();
3861 if(active && rootWindow != this)
3862 ConsequentialMouseMove(false);
3869 // --- Input Messages ---
3870 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3872 static bool reEntrancy = false;
3873 if(reEntrancy) return;
3877 guiApp.cursorUpdate = true;
3878 if(guiApp.windowScrolling && !consequential)
3880 guiApp.windowScrolling.SetScrollPosition(
3881 (guiApp.windowScrolling.sbh) ?
3882 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3883 (guiApp.windowScrolling.sbv) ?
3884 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3886 if(guiApp.windowMoving)
3888 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3890 Window window = guiApp.windowMoving;
3892 int w = window.size.w;
3893 int h = window.size.h;
3898 rx = mouseX - guiApp.windowMovingStart.x;
3899 ry = mouseY - guiApp.windowMovingStart.y;
3902 window.GetDecorationsSize(&ew, &eh);
3904 if(guiApp.windowIsResizing)
3906 x = window.scrolledPos.x;
3907 y = window.scrolledPos.y;
3911 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3912 rx = guiApp.windowResizingBefore.w - aw;
3913 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3914 w = guiApp.windowResizingBefore.w - rx;
3918 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3919 ry = guiApp.windowResizingBefore.h - ah;
3920 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3921 ry = Max(ry, -guiApp.windowMovingBefore.y);
3922 h = guiApp.windowResizingBefore.h - ry;
3924 if(guiApp.resizeEndX)
3926 w = guiApp.windowResizingBefore.w + rx;
3929 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3937 w = Max(w, window.minSize.w);
3938 h = Max(h, window.minSize.h);
3939 w = Min(w, window.maxSize.w);
3940 h = Min(h, window.maxSize.h);
3942 if(!window.OnResizing(&w, &h))
3944 w = window.clientSize.w;
3945 h = window.clientSize.h;
3948 w = Max(w, window.skinMinSize.w);
3949 h = Max(h, window.skinMinSize.h);
3956 SNAPDOWN(w, textCellW);
3957 SNAPDOWN(h, textCellH);
3962 aw = Max(w,window.skinMinSize.w);
3963 rx = guiApp.windowResizingBefore.w - aw;
3964 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3965 w = guiApp.windowResizingBefore.w - rx;
3969 ah = Max(h,window.skinMinSize.h);
3970 ry = guiApp.windowResizingBefore.h - ah;
3971 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3972 ry = Max(ry, -guiApp.windowMovingBefore.y);
3973 h = guiApp.windowResizingBefore.h - ry;
3978 if(!guiApp.windowIsResizing || guiApp.resizeX)
3979 x = guiApp.windowMovingBefore.x + rx;
3980 if(!guiApp.windowIsResizing || guiApp.resizeY)
3981 y = guiApp.windowMovingBefore.y + ry;
3983 if(!guiApp.windowIsResizing)
3986 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3988 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3989 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3990 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3991 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3995 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3996 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
4002 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
4004 if(!window.OnMoving(&x, &y, w, h))
4006 x = window.scrolledPos.x;
4007 y = window.scrolledPos.y;
4013 SNAPDOWN(x, textCellW);
4014 SNAPDOWN(y, textCellH);
4017 if(!window.style.nonClient)
4019 if(!window.style.fixed /*|| window.style.isDocument*/)
4021 if(!window.style.dontScrollHorz)
4022 x += window.parent.scroll.x;
4023 if(!window.style.dontScrollVert)
4024 y += window.parent.scroll.y;
4028 // Break the anchors for moveable/resizable windows
4029 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4030 if(window.style.fixed)
4032 if(window.state == normal)
4034 window.normalAnchor = Anchor { left = x, top = y };
4035 window.normalSizeAnchor = SizeAnchor { { w, h } };
4036 window.anchored = false;
4040 window.stateAnchor = Anchor { left = x, top = y };
4041 window.stateSizeAnchor = SizeAnchor { { w, h } };
4043 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4044 // TOCHECK: Investigate why the following only redraws the scrollbars
4045 //window.Position(x, y, w, h, false, true, true, true, false, true);
4047 guiApp.movingLast.x = mouseX;
4048 guiApp.movingLast.y = mouseY;
4054 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4057 bool wasMoving = guiApp.windowMoving ? true : false;
4058 bool wasScrolling = guiApp.windowScrolling ? true : false;
4060 while(result && w != this)
4062 Window msgWindow = GetAtPosition(x,y, false, true, w);
4063 Window trueWindow = GetAtPosition(x,y, false, false, w);
4064 bool windowDragged = false;
4069 window = (w && !w.disabled) ? w : null;
4071 if(trueWindow) incref trueWindow;
4073 if(consequential) mods->isSideEffect = true;
4075 UpdateMouseMove(x, y, consequential);
4077 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4079 if(!guiApp.windowCaptured.isEnabled)
4080 guiApp.windowCaptured.ReleaseCapture();
4082 window = guiApp.windowCaptured;
4085 if(trueWindow && activate &&
4086 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4087 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4088 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4089 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4091 if(mods->alt && !mods->ctrl && !mods->shift)
4093 Window moved = trueWindow;
4094 for(moved = trueWindow; moved; moved = moved.parent)
4095 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4100 windowDragged = true;
4102 // Cancel the ALT menu toggling...
4103 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4108 if(window && activate &&
4109 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4110 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4111 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4112 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4114 Window modalWindow = window.FindModal();
4116 /*if(mods->alt && !mods->shift && !mods->ctrl)
4118 Window moved = window;
4119 for(moved = window; moved; moved = moved.parent)
4120 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4125 windowDragged = true;
4127 // Cancel the ALT menu toggling...
4128 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4134 Window activateWindow = modalWindow ? modalWindow : window;
4135 if(activateWindow && !activateWindow.isRemote)
4137 bool doActivation = true;
4138 //bool needToDoActivation = false;
4139 Window check = activateWindow;
4141 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4143 if(!check.style.inactive)
4145 //needToDoActivation = true;
4147 doActivation = false;
4152 if(!needToDoActivation)
4153 doActivation = false;
4156 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4157 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4159 // Let the OnLeftButtonDown do the activating instead
4160 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4168 incref activateWindow;
4169 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4171 delete activateWindow;
4175 if(activateWindow._refCount == 1)
4177 delete activateWindow;
4181 delete activateWindow;
4182 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4185 mods->isActivate = true;
4189 if(!modalWindow && window && !window.destroyed)
4191 if(!guiApp.windowCaptured || windowDragged)
4193 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4195 bool moving = ((window.state != maximized &&
4196 window.IsMouseMoving(
4197 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4198 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4200 if(!moving && window.IsMouseResizing(
4201 x - window.absPosition.x,
4202 y - window.absPosition.y,
4203 window.size.w, window.size.h,
4204 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4206 guiApp.windowIsResizing = true;
4207 guiApp.windowResizingBefore.w = window.size.w;
4208 guiApp.windowResizingBefore.h = window.size.h;
4210 if(guiApp.windowIsResizing || windowDragged || moving)
4213 guiApp.windowMoving = window;
4214 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4215 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4216 guiApp.windowMovingBefore.x = window.position.x;//s;
4217 guiApp.windowMovingBefore.y = window.position.y;//s;
4218 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4219 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4222 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4224 if(window.style.fixed &&
4226 window.IsMouseMoving(
4227 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4229 window.ShowSysMenu(x, y);
4233 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4235 if(window.sbv || window.sbh)
4238 guiApp.windowScrolling = window;
4239 guiApp.windowScrollingStart.x = x;
4240 guiApp.windowScrollingStart.y = y;
4241 guiApp.windowScrollingBefore.x = window.scroll.x;
4242 guiApp.windowScrollingBefore.y = window.scroll.y;
4245 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4247 if(window.style.hasMaximize &&
4248 window.IsMouseMoving(
4249 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4252 (window.state == maximized) ? normal : maximized, false, *mods);
4260 if(guiApp.windowMoving)
4262 if(guiApp.windowMoving.parent)
4264 if(guiApp.windowMoving.style.nonClient)
4265 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4267 guiApp.windowMoving.parent.SetMouseRangeToClient();
4271 window.UpdateDecorations();
4274 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4276 // Log("\n*** LEFT BUTTON UP ***\n");
4277 if(guiApp.windowMoving)
4278 guiApp.windowMoving.StopMoving();
4280 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4282 if(guiApp.windowScrolling)
4284 Window windowScrolling = guiApp.windowScrolling;
4285 guiApp.windowScrolling = null;
4286 windowScrolling.ReleaseCapture();
4290 if(!result || (window && window.destroyed)) window = null;
4292 if(window && window.FindModal())
4295 if(trueWindow && trueWindow.FindModal())
4303 msgWindow = GetAtPosition(x,y, true, false);
4305 msgWindow.SelectMouseCursor();
4308 if(guiApp.windowCaptured || trueWindow)
4310 Window prevWindow = guiApp.prevWindow;
4311 List<Window> overWindows = guiApp.overWindows;
4312 Iterator<Window> it { overWindows };
4317 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4320 result = w.OnMouseLeave(*mods);
4322 overWindows.TakeOut(w);
4326 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4328 guiApp.prevWindow.mouseInside = false;
4329 guiApp.prevWindow = null;
4333 if(trueWindow.IsDescendantOf(prevWindow))
4335 if(!overWindows.Find(prevWindow))
4336 overWindows.Add(prevWindow);
4338 // Eventually fix this not to include captured?
4339 else if(!prevWindow.OnMouseLeave(*mods))
4343 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4345 Box box = trueWindow.box;
4346 box.left += trueWindow.absPosition.x;
4347 box.right += trueWindow.absPosition.x;
4348 box.top += trueWindow.absPosition.y;
4349 box.bottom += trueWindow.absPosition.y;
4351 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4353 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4354 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4356 overX = Max(Min(overX, 32767),-32768);
4357 overY = Max(Min(overY, 32767),-32768);
4359 trueWindow.mouseInside = true;
4360 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4364 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4366 for(w : guiApp.overWindows; w == trueWindow)
4369 guiApp.overWindows.TakeOut(w);
4372 guiApp.prevWindow = trueWindow;
4375 guiApp.prevWindow = null;
4377 SelectMouseCursor();
4379 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4380 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4382 int clientX = x - (window.absPosition.x + window.clientStart.x);
4383 int clientY = y - (window.absPosition.y + window.clientStart.y);
4385 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4387 clientX = Max(Min(clientX, 32767),-32768);
4388 clientY = Max(Min(clientY, 32767),-32768);
4390 MouseMethod = (void *)window._vTbl[method];
4392 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4395 if(!MouseMethod(window, clientX, clientY, *mods))
4399 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4400 window.OnMouseLeave(*mods);
4407 if(result && w && w.clickThrough && w.parent)
4412 if(!result || !w || !w.clickThrough)
4419 // --- Mouse cursor management ---
4421 bool KeyMessage(uint method, Key key, unichar character)
4426 if(guiApp.interimWindow)
4427 this = guiApp.interimWindow;
4430 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4434 if(!style.inactive || rootWindow != this)
4436 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4437 Window modalWindow = FindModal();
4438 Window interimMaster = master ? master.rootWindow : null;
4442 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4443 status = OnSysKeyDown(key, character);
4444 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4445 status = OnSysKeyHit(key, character);
4446 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4447 status = OnSysKeyUp(key, character);
4454 // Process Key Message for Internal UI Keyboard actions
4455 if(status && !destroyed && menuBar && state != minimized)
4458 if((SmartKey)key != alt)
4459 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4462 SmartKey sk = (SmartKey) key;
4463 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4465 status = menuBar.KeyMessage(method, key, character);
4470 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4471 menuBar.OnKeyHit(escape, 0);
4473 if(!menuBar.focus && guiApp.caretOwner)
4474 guiApp.caretOwner.UpdateCaret(true, false);
4477 if(!destroyed && status)
4479 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4483 case left: case up: case right: case down:
4484 if(guiApp.windowMoving == this)
4487 int w = guiApp.windowMoving.size.w;
4488 int h = guiApp.windowMoving.size.h;
4489 int x = guiApp.windowMoving.scrolledPos.x;
4490 int y = guiApp.windowMoving.scrolledPos.y;
4494 if(key == down || key == up)
4495 step = Max(step, textCellH);
4497 step = Max(step, textCellW);
4500 if(guiApp.windowIsResizing)
4504 case left: w-=step; break;
4505 case right: w+=step; break;
4506 case up: h-=step; break;
4507 case down: h+=step; break;
4514 case left: x-=step; break;
4515 case right: x+=step; break;
4516 case up: y-=step; break;
4517 case down: y+=step; break;
4521 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4522 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4524 if(!guiApp.windowIsResizing || guiApp.resizeX)
4525 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4527 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4529 if(!guiApp.windowIsResizing || guiApp.resizeY)
4530 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4532 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4534 guiApp.interfaceDriver.SetMousePosition(x, y);
4535 ConsequentialMouseMove(true);
4543 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4545 guiApp.windowMoving.StopMoving();
4546 ConsequentialMouseMove(false);
4554 ShowSysMenu(absPosition.x, absPosition.y);
4562 if(!destroyed && status && state != minimized)
4564 // Process all the way down the children
4565 if(activeChild && !activeChild.disabled)
4567 status = activeChild.KeyMessage(method, key, character);
4569 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4570 key.code != left && key.code != right && key.code != up && key.code != down)
4572 status = activeClient.KeyMessage(method, key, character);
4576 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4578 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4579 // && defaultControl != activeChild)
4581 delete previousActive;
4582 previousActive = activeChild;
4583 if(previousActive) incref previousActive;
4585 ConsequentialMouseMove(false);
4586 if((defaultControl.active ||
4587 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4588 defaultControl.KeyMessage(method, defaultKey, character);
4594 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4596 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4603 ShowSysMenu(absPosition.x, absPosition.y);
4610 if(this != guiApp.desktop)
4612 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4614 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4616 MenuMoveOrSize(key.shift, true);
4620 else if(guiApp.windowMoving)
4622 guiApp.windowMoving.StopMoving();
4623 ConsequentialMouseMove(false);
4631 if(!destroyed && status && state != minimized)
4633 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4637 case tab: case shiftTab:
4639 Window cycleParent = this;
4640 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4641 cycleParent = master.parent;
4643 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4645 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4648 Window child = cycleParent.activeChild;
4650 // Scroll the window to include the active control
4651 if(cycleParent.sbh && !child.style.dontScrollHorz)
4653 if(child.scrolledPos.x < 0)
4654 cycleParent.sbh.Action(Position,
4655 cycleParent.scroll.x + child.scrolledPos.x, 0);
4656 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4657 cycleParent.sbh.Action(Position,
4658 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4660 if(cycleParent.sbv && !child.style.dontScrollVert)
4662 if(child.scrolledPos.y < 0)
4663 cycleParent.sbv.Action(Position,
4664 cycleParent.scroll.y + child.scrolledPos.y, 0);
4665 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4666 cycleParent.sbv.Action(Position,
4667 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4670 cycleParent.ConsequentialMouseMove(false);
4676 case f6: case shiftF6:
4677 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4679 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4680 if(parent == guiApp.desktop)
4681 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4691 if(CycleChildren(key.shift, true, false, true))
4699 // mIRC Style Window Shortcuts
4700 case alt1: case alt2: case alt3: case alt4: case alt5:
4701 case alt6: case alt7: case alt8: case alt9: case alt0:
4706 for(document = children.first; document; document = document.next)
4708 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4710 if(document == activeChild)
4712 if(document.state == minimized)
4713 document.SetState(normal, false, key);
4716 document.SetState(minimized, false, key);
4717 CycleChildren(false, true, false);
4722 if(activeChild.state == maximized && document.style.hasMaximize)
4723 document.SetState(maximized, false, key);
4724 else if(document.state == minimized)
4725 document.SetState(normal, false, key);
4726 document.Activate();
4741 if(!destroyed && status)
4743 if(state == minimized)
4748 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4750 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4752 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4753 previousActive.ActivateEx(true, false, false, true, null, null);
4754 delete previousActive;
4760 if(!destroyed && status)
4762 status = ProcessHotKeys(method, key, character);
4764 if(!destroyed && status && !modalWindow && state != minimized)
4767 status = KeyMethod(this, key, character);
4768 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4769 status = OnKeyHit(key, character);
4770 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4772 bool result = false;
4775 case ctrlUp: case ctrlDown:
4776 if(sbv && !guiApp.windowScrolling)
4777 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4779 case wheelUp: case wheelDown:
4780 if(sbv && !guiApp.windowScrolling)
4782 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4783 // Do we want to do a consequential move regardless of result in this case?
4784 ConsequentialMouseMove(false);
4787 case ctrlPageUp: case ctrlPageDown:
4788 if(sbh && !guiApp.windowScrolling)
4789 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4794 ConsequentialMouseMove(false);
4799 if(status && !destroyed && menuBar && state != minimized)
4800 status = menuBar.KeyMessage(method, key, character);
4802 if(style.interim && /*destroyed && */status && interimMaster)
4804 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4805 status = interimMaster.KeyMessage(method, key, character);
4812 bool ProcessHotKeys(uint method, Key key, unichar character)
4817 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4818 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4819 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4821 Window hotKeyWindow = hotKey.window;
4822 Window parent = hotKeyWindow.parent;
4823 Window prevActiveWindow = activeChild;
4824 // For when sys buttons are placed inside the menu bar
4825 if(parent && parent._class == class(PopupMenu))
4826 parent = parent.parent;
4828 // 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
4829 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4832 if(prevActiveWindow) incref prevActiveWindow;
4833 incref hotKeyWindow;
4834 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4835 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4838 delete hotKeyWindow;
4839 delete prevActiveWindow;
4843 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4844 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4845 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4847 // ********* WORKING ON THIS ***********
4848 if(prevActiveWindow && !guiApp.interimWindow)
4849 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4852 else if(hotKeyWindow.style.inactive)
4853 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4855 delete prevActiveWindow;
4856 delete hotKeyWindow;
4857 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4858 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4862 if(status && tabCycle)
4865 for(child = children.first; child; child = child.next)
4867 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4878 // --- Windows and graphics initialization / termination ---
4879 bool SetupRoot(void)
4883 // Setup relationship with outside world (bb root || !bb)
4884 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4885 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4889 tempExtents = new0 Extent[4];
4894 /*if(guiApp.fullScreenMode)
4895 rootWindow = guiApp.desktop;
4897 //rootWindow = parent.created ? parent.rootWindow : null;
4898 rootWindow = parent.rootWindow;
4901 against = &parent.box;
4903 against = &parent.clientArea;
4906 for(child = children.first; child; child = child.next)
4909 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4912 bool Setup(bool positionChildren)
4914 bool result = false;
4917 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4919 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4920 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4923 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4925 // This was here, is it really needed?
4926 //guiApp.interfaceDriver.ActivateRootWindow(this);
4930 displaySystem = DisplaySystem {};
4931 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4933 delete displaySystem;
4938 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4939 if(display.Create(displaySystem, windowHandle))
4946 // Sometimes icon does not show up on Windows XP if we set here...
4947 // guiApp.interfaceDriver.SetIcon(this, icon);
4949 else if(this != guiApp.desktop)
4951 display = rootWindow ? rootWindow.display : null;
4957 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4958 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4960 for(child = children.first; child; child = child.next)
4962 if(child.created && !child.Setup(false))
4965 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4966 child.UpdateCaption();
4971 bool SetupDisplay(void)
4973 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4974 if(is3D) return Window3D_SetupDisplay(this); else
4981 class_data void ** pureVTbl;
4983 bool LoadGraphics(bool creation, bool resetAnchors)
4985 bool result = false;
4986 bool success = false;
4988 WindowState stateBackup = state;
4990 if(((subclass(Window))_class).pureVTbl)
4992 if(_vTbl == _class._vTbl)
4994 _vTbl = ((subclass(Window))_class).pureVTbl;
4999 for(m = 0; m < _class.vTblSize; m++)
5001 if(_vTbl[m] == _class._vTbl[m])
5002 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5006 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
5008 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5010 _vTbl = _class._vTbl;
5015 for(m = 0; m < _class.vTblSize; m++)
5017 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5018 _vTbl[m] = _class._vTbl[m];
5023 if(guiApp.fullScreenMode || this != guiApp.desktop)
5025 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5031 display.Lock(false);
5032 if(rootWindow == this)
5034 // Set Color Palette
5035 display.SetPalette(palette, true);
5039 if(guiApp.fullScreenMode && this == guiApp.desktop)
5044 for(c=0; c<SystemCursor::enumSize; c++)
5045 if(!guiApp.systemCursors[c].bitmap)
5047 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5048 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5049 if(guiApp.systemCursors[c].bitmapName)
5051 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5052 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5053 if(guiApp.systemCursors[c].bitmap)
5054 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5059 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5061 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5062 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5064 cursor.bitmap.paletteShades = cursor.paletteShades;
5068 guiApp.cursorUpdate = true;
5071 ConsequentialMouseMove(false);
5077 // Load Window Graphic Resources
5080 if(usedFont == setFont || usedFont == window.systemFont)
5081 RemoveResource(usedFont);
5084 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5087 RemoveResource(systemFont);
5090 RemoveResource(captionFont);
5092 for(ptr = resources.first; ptr; ptr = ptr.next)
5094 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5095 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5098 AddResource(setFont);
5100 AddResource(systemFont);
5102 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5109 //if(master && master.font)
5110 if(parent && parent.font)
5114 faceName = parent.font.faceName,
5115 size = parent.font.size,
5116 bold = parent.font.bold,
5117 italic = parent.font.italic,
5118 underline = parent.font.underline
5120 //font = parent.font;
5121 watch(parent) { font { } };
5124 font = guiApp.currentSkin.SystemFont();
5131 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5132 AddResource(captionFont);
5134 if(OnLoadGraphics())
5140 //SetScrollLineStep(sbStep.x, sbStep.y);
5142 if(this != guiApp.desktop)
5146 normalAnchor = anchor;
5147 normalSizeAnchor = sizeAnchor;
5150 // Break the anchors for moveable/resizable windows
5152 if(style.fixed && style.isDocument)
5154 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5166 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5167 stateSizeAnchor = SizeAnchor {};
5172 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5177 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5178 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5181 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5185 stateAnchor = normalAnchor;
5186 stateSizeAnchor = normalSizeAnchor;
5189 position = Point { };
5190 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5201 if(Position(x, y, w, h, true, false, true, true, true, true))
5203 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5206 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5223 success = result = true;
5226 if(!creation && result)
5228 // Load menu bar first because sys buttons are on it...
5231 if(!menuBar.LoadGraphics(false, resetAnchors))
5237 for(child = children.first; child; child = child.next)
5239 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5246 CreateSystemChildren();
5250 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5253 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5256 LogErrorCode(graphicsLoadingFailed, _class.name);
5258 // Do this here to avoid problems on Windows
5259 if(rootWindow == this && parent && stateBackup == maximized)
5260 property::state = maximized;
5264 void UnloadGraphics(bool destroyWindows)
5268 // Free children's graphics
5269 for(child = children.first; child; child = child.next)
5270 child.UnloadGraphics(destroyWindows);
5273 display.Lock(false);
5276 if(guiApp.fullScreenMode && this == guiApp.desktop)
5281 for(c=0; c<SystemCursor::enumSize; c++)
5282 if(guiApp.systemCursors[c].bitmap)
5283 delete guiApp.systemCursors[c].bitmap;
5285 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5286 delete cursor.bitmap;
5288 guiApp.cursorBackground.Free();
5291 if(display && display.displaySystem)
5295 for(ptr = resources.first; ptr; ptr = ptr.next)
5299 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5304 // Free window graphics
5307 // Free skin graphics
5308 if(rootWindow == this)
5310 DisplaySystem displaySystem = display.displaySystem;
5313 display.driverData = null;
5314 display.displaySystem = null;
5318 if(displaySystem && !displaySystem.numDisplays && !is3D)
5319 delete displaySystem;
5328 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5329 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5331 if(this == guiApp.desktop || parent == guiApp.desktop)
5333 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5334 guiApp.interfaceDriver.DestroyRootWindow(this);
5338 // --- Window Hiding ---
5340 void SetVisibility(bool state)
5342 bool visible = (style.hidden || !created) ? false : state;
5343 if(visible != this.visible)
5347 this.visible = visible;
5348 for(child = children.first; child; child = child.next)
5349 child.SetVisibility(visible);
5351 ConsequentialMouseMove(false);
5352 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5356 // --- Windows and graphics initialization / termination ---
5358 bool DisplayModeChanged(void)
5360 bool result = false;
5361 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5363 guiApp.modeSwitching = true;
5364 UnloadGraphics(false);
5366 if(LoadGraphics(false, false))
5368 guiApp.modeSwitching = false;
5373 // --- Window updates system ---
5375 void UpdateDirty(Box updateBox)
5377 if(!manageDisplay) { OnRedraw(null);return; }
5380 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5383 if(display.flags.flipping)
5386 rootWindow.UpdateDisplay();
5389 UpdateBackDisplay(updateBox);
5391 if(guiApp.fullScreenMode)
5393 guiApp.cursorUpdate = true;
5394 guiApp.PreserveAndDrawCursor();
5396 if(guiApp.fullScreenMode)
5397 guiApp.RestoreCursorBackground();
5403 // This function is strictly called as a result of system window activation
5404 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5407 Window interimMaster = null;
5408 Window interimWindow = guiApp.interimWindow;
5409 if(interimWindow && interimWindow.master)
5410 interimMaster = interimWindow.master.rootWindow;
5412 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5413 // SetState(normal, false, 0);
5414 SetState(lastState, false, 0);
5416 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5420 /* WTH is this doing here?
5421 while(swap && swap.activeChild)
5423 swap = swap.activeChild;
5426 // TESTING THIS BEFORE...
5427 if(interimWindow && this == interimMaster)
5431 // Window interimSwap = this;
5432 Window menuBar = this.menuBar;
5433 if(menuBar && interimWindow.master == menuBar)
5436 while(interimSwap && interimSwap.activeChild)
5437 interimSwap = interimSwap.activeChild;
5439 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5440 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5442 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5443 //result = ActivateEx(true, true, false, activateRoot, window, null);
5448 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5449 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5451 if(interimWindow == this && interimMaster && !active)
5453 while(interimMaster && interimMaster.interim && interimMaster.master)
5455 // printf("Going up one master %s\n", interimMaster._class.name);
5456 interimMaster = interimMaster.master.rootWindow;
5458 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5459 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5465 bool DestroyEx(int64 returnCode)
5468 Timer timer, nextTimer;
5470 OldLink prevOrder = null;
5471 Window client = null;
5473 if(parent) stopwatching(parent, font);
5475 // if(window.modalSlave) return false;
5476 if(destroyed || !created)
5483 OldLink slave = master.slaves.FindLink(this);
5484 master.slaves.Delete(slave);
5487 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5493 this.returnCode = (DialogResult)returnCode;
5495 AcquireInput(false);
5500 master.hotKeys.Delete(hotKey);
5504 if(guiApp.prevWindow == this)
5506 guiApp.prevWindow = null;
5511 for(w : guiApp.overWindows; w == this)
5514 guiApp.overWindows.TakeOut(w);
5518 if(guiApp.caretOwner == this)
5520 guiApp.interfaceDriver.SetCaret(0,0,0);
5521 UpdateCaret(false, true);
5522 guiApp.caretEnabled = false;
5527 parent.childrenCycle.Remove(cycle);
5531 OldLink tmpPrev = order.prev;
5532 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5533 prevOrder = tmpPrev;
5536 client = tmpPrev ? tmpPrev.data : null;
5537 if(client == this) { client = null; break; }
5538 if(client && (client.style.hidden || client.destroyed || !client.created))
5539 tmpPrev = client.order.prev;
5543 prevOrder = tmpPrev;
5548 // If this window can be an active client, make sure the next window we activate can also be one
5549 if(!style.nonClient && style.isActiveClient)
5551 tmpPrev = prevOrder;
5554 client = tmpPrev ? tmpPrev.data : null;
5555 if(client == this) { client = null; break; }
5556 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5557 tmpPrev = client.order.prev;
5561 prevOrder = tmpPrev;
5565 if(client && client.style.hidden) client = null;
5567 // parent.childrenOrder.Remove(order);
5570 if(parent && style.isActiveClient && visible)
5572 if(state == minimized) parent.numIcons--;
5573 parent.numPositions--;
5576 // TESTING THIS HERE!
5580 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5581 // to create a window inside a rootwindow that's being destroyed)
5582 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5584 if(master && !master.destroyed /*&&
5585 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5587 if(master.defaultControl == this)
5588 master.defaultControl = null;
5591 parent.OnChildAddedOrRemoved(this, true);
5592 if(parent && !parent.destroyed /*&&
5593 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5595 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5597 if(order && prevOrder && prevOrder.data != this && active)
5599 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5601 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5602 if(parent.activeClient == this)
5604 parent.activeClient = null;
5605 parent.UpdateActiveDocument(null);
5610 if(guiApp.interimWindow == this)
5613 PropagateActive(false, null, &goOn, true);
5617 //if(window.parent.activeChild == window)
5618 parent.activeChild = null;
5619 if(!style.nonClient /*&& style.isActiveClient*/)
5621 Window previous = parent.activeClient;
5622 if(style.isActiveClient)
5623 parent.activeClient = null;
5624 parent.UpdateActiveDocument(previous);
5629 else if(parent.activeClient == this)
5631 parent.activeClient = client;
5632 parent.UpdateActiveDocument(this);
5636 if(guiApp.interimWindow == this)
5638 guiApp.interimWindow = null;
5639 if(guiApp.caretOwner)
5641 Window desktop = guiApp.desktop;
5642 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5643 guiApp.caretOwner.UpdateCaret(false, false);
5648 if(_isModal && master && master.modalSlave == this)
5649 master.modalSlave = null;
5653 if(!guiApp.caretOwner && parent.caretSize)
5655 guiApp.caretOwner = parent;
5656 parent.UpdateCaret(false, false);
5657 parent.Update(null);
5660 // Why was this commented out?
5661 GetRidOfVirtualArea();
5667 dirtyArea.Free(null);
5668 dirtyBack.Free(null);
5669 scrollExtent.Free(null);
5671 /* ATTEMPTING TO MOVE THAT ABOVE
5680 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5681 for(;(child = window.children.first);)
5683 for(; child && (child.destroyed || !child.created); child = child.next);
5692 UnloadGraphics(true);
5695 delete previousActive;
5698 // statusBar = null;
5701 if(master && !master.destroyed)
5703 //master.NotifyDestroyed(this, this.returnCode);
5704 NotifyDestroyed(master, this, this.returnCode);
5707 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5709 nextTimer = timer.next;
5710 if(timer.window == this)
5712 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5713 // timer.window = null;
5719 if(this == guiApp.windowMoving)
5722 if(guiApp.windowCaptured == this)
5724 //guiApp.windowCaptured = null;
5726 if(rootWindow != this && rootWindow)
5727 rootWindow.ConsequentialMouseMove(false);
5735 //for(child = children.first; next = child ? child.next : null, child; child = next)
5736 for(;(child = children.first); )
5738 for(; child && (child.destroyed || !child.created); child = child.next);
5748 /* // MOVED THIS UP...
5751 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5752 for(;(child = window.children.first); )
5754 for(; child && (child.destroyed || !child.created); child = child.next);
5763 while((slave = slaves.first))
5765 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5767 ((Window)slave.data).DestroyEx(0);
5772 if(guiApp.caretOwner == this)
5773 guiApp.caretOwner = null;
5775 sysButtons[0] = null;
5776 sysButtons[1] = null;
5777 sysButtons[2] = null;
5780 if(rootWindow != this)
5782 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5785 box.left -= parent.clientStart.x;
5786 box.top -= parent.clientStart.y;
5787 box.right -= parent.clientStart.x;
5788 box.bottom -= parent.clientStart.y;
5790 if(parent) parent.Update(box);
5795 OldLink slave = master.slaves.FindVoid(this);
5796 master.slaves.Delete(slave);
5802 parent.children.Remove(this);
5807 //autoCreate = false;
5810 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5811 if(((subclass(Window))_class).pureVTbl)
5813 if(_vTbl == _class._vTbl)
5815 _vTbl = ((subclass(Window))_class).pureVTbl;
5820 for(m = 0; m < _class.vTblSize; m++)
5822 if(_vTbl[m] == _class._vTbl[m])
5823 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5832 void SetStateEx(WindowState newState, bool activate)
5835 WindowState prevState = state;
5839 if(prevState != newState)
5840 lastState = prevState;
5842 if(rootWindow != this || !nativeDecorations || !windowHandle)
5844 if(style.isActiveClient && !style.hidden && prevState == minimized)
5847 // This block used to be at the end of the function... moved it for flicker problem in X
5848 // ------------------------------------------------------
5852 stateAnchor = normalAnchor;
5853 stateSizeAnchor = normalSizeAnchor;
5856 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5857 stateSizeAnchor = SizeAnchor {};
5863 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5866 byte * idBuffer = new0 byte[size];
5868 for(child = parent.children.first; child; child = child.next)
5870 if(child != this && child.state == minimized)
5872 if(child.iconID > size - 2)
5874 idBuffer = renew0 idBuffer byte[size*2];
5875 memset(idBuffer + size, 0, size);
5878 idBuffer[child.iconID] = (byte)bool::true;
5881 for(c = 0; c<size; c++)
5886 if(style.isActiveClient && !style.hidden)
5889 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5890 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5895 // TOCHECK: Why was this here?
5896 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5897 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5898 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5900 if(state != minimized || hasMinimize)
5901 Position(x, y, w, h, true, true, true, true, false, true);
5903 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5904 parent.UpdateActiveDocument(null);
5907 if(state != minimized || hasMinimize)
5908 CreateSystemChildren();
5909 // ------------------------------------------------------
5912 int GetPositionID(Window forChild)
5916 byte * idBuffer = new0 byte[size];
5919 for(child = children.first; child; child = child.next)
5921 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5923 if(child.positionID > size - 2)
5925 idBuffer = renew0 idBuffer byte[size*2];
5926 memset(idBuffer + size, 0, size);
5929 idBuffer[child.positionID] = (byte)bool::true;
5932 for(c = 0; c<size; c++)
5939 // --- Window related graphics ---
5941 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5943 palette = newPalette;
5944 if(rootWindow.display)
5945 rootWindow.display.SetPalette(palette, colorMatch);
5948 public bool AcquireInput(bool acquired)
5951 if(acquiredInput != acquired)
5953 if(active || (!visible && creationActivation == activate))
5954 result = AcquireInputEx(acquired);
5959 acquiredInput = acquired ? result : !result;
5964 void ListChildren(ListBox listBox)
5968 for(child = children.first; child; child = child.next)
5970 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5972 DataRow row = listBox.AddRow();
5973 row.tag = (int64)(intptr)child;
5974 child.FigureCaption(caption);
5975 row.SetData(null, caption);
5980 void UpdateVisual(Box extent)
5982 if(guiApp.driver != null)
5984 if(guiApp.fullScreenMode && guiApp.desktop.display)
5986 #if !defined(__EMSCRIPTEN__)
5987 guiApp.desktop.mutex.Wait();
5989 guiApp.desktop.display.Lock(true);
5992 if(guiApp.desktop.active)
5994 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5996 if(guiApp.desktop.display.flags.flipping)
5997 guiApp.desktop.Update(null);
5998 guiApp.desktop.UpdateDisplay();
5999 guiApp.cursorUpdate = true;
6001 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
6003 guiApp.PreserveAndDrawCursor();
6004 // guiApp.desktop.display.ShowScreen();
6005 guiApp.cursorUpdate = false;
6006 guiApp.desktop.dirty = false;
6007 guiApp.RestoreCursorBackground();
6011 guiApp.desktop.display.Unlock();
6012 #if !defined(__EMSCRIPTEN__)
6013 guiApp.desktop.mutex.Release();
6018 Window rootWindow = this.rootWindow;
6019 #if !defined(__EMSCRIPTEN__)
6020 rootWindow.mutex.Wait();
6026 guiApp.SignalEvent();
6029 #if !defined(__EMSCRIPTEN__)
6030 guiApp.waitMutex.Wait();
6032 guiApp.interfaceDriver.Lock(rootWindow);
6033 if(!rootWindow.style.hidden && rootWindow.dirty)
6035 if(rootWindow.display)
6037 rootWindow.UpdateDisplay();
6038 //rootWindow.display.ShowScreen(null);
6040 rootWindow.dirty = false;
6042 guiApp.interfaceDriver.Unlock(rootWindow);
6043 #if !defined(__EMSCRIPTEN__)
6044 guiApp.waitMutex.Release();
6048 #if !defined(__EMSCRIPTEN__)
6049 rootWindow.mutex.Release();
6055 void UnlockDisplay(void)
6057 guiApp.interfaceDriver.Unlock(rootWindow);
6060 void LockDisplay(void)
6062 guiApp.interfaceDriver.Lock(rootWindow);
6065 Surface GetSurface(Box box)
6067 return Redraw((box == null) ? this.box : box);
6070 void SetMousePosition(int x, int y)
6072 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6076 void IntegrationActivate(bool active)
6078 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6080 isForegroundWindow = true;
6081 ActivateEx(active, active, false, false, null, null);
6082 isForegroundWindow = false;
6087 Window QueryCapture(void)
6089 return guiApp.windowCaptured;
6092 int GetDocumentID(void)
6096 byte * idBuffer = new0 byte[size];
6099 for(child = children.first; child; child = child.next)
6101 // TO CHECK: Do we want a documentID when we already have a file name?
6102 if(child.style.isDocument && !child.fileName)
6104 if(child.documentID-1 > size - 2)
6106 idBuffer = renew0 idBuffer byte[size*2];
6107 memset(idBuffer + size, 0, size);
6110 idBuffer[child.documentID-1] = 1;
6113 for(c = 0; c<size; c++)
6121 void SetInitSize(Size size)
6124 sizeAnchor.size = size;
6125 normalSizeAnchor = sizeAnchor;
6127 // Break the anchors for moveable/resizable windows
6128 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6130 stateAnchor = normalAnchor;
6131 stateSizeAnchor = normalSizeAnchor;
6133 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6134 Position(x,y, w, h, true, true, true, true, false, true);
6138 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6140 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6142 guiApp.windowIsResizing = resize;
6143 guiApp.windowMoving = this;
6144 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6145 if(guiApp.windowIsResizing)
6147 guiApp.windowMovingStart.x += size.w - 1;
6148 guiApp.windowMovingStart.y += size.h - 1;
6150 guiApp.windowMovingBefore = scrolledPos;
6151 guiApp.windowResizingBefore = size;
6152 guiApp.windowMoving.UpdateDecorations();
6153 if(guiApp.windowIsResizing)
6154 guiApp.resizeEndX = guiApp.resizeEndY = true;
6156 if(setCursorPosition)
6157 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6161 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6162 guiApp.windowMovingStart.x += x - absPosition.x;
6163 guiApp.windowMovingStart.y += y - absPosition.y;
6166 if(guiApp.windowMoving)
6168 if(guiApp.windowMoving.style.nonClient)
6169 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6171 guiApp.windowMoving.parent.SetMouseRangeToClient();
6176 if(this == rootWindow)
6177 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6181 void SetupFileMonitor()
6183 #if !defined(__EMSCRIPTEN__)
6186 fileMonitor = FileMonitor
6188 this, FileChange { modified = true };
6190 bool OnFileNotify(FileChange action, const char * param)
6193 fileMonitor.StopMonitoring();
6194 if(OnFileModified(action, param))
6195 fileMonitor.StartMonitoring();
6209 bool result = false;
6213 else if(guiApp && guiApp.driver != null)
6215 OldLink slaveHolder;
6217 bool visible = !style.hidden;
6221 systemParent = parent;
6222 parent = guiApp.desktop;
6224 last = parent ? parent.children.last : null;
6226 if((parent && parent != guiApp.desktop && !parent.created) ||
6227 (master && master != guiApp.desktop && !master.created))
6231 stopwatching(parent, font);
6234 property::parent = guiApp.desktop;
6235 if(!master) master = parent;
6237 if(_isModal && master.modalSlave)
6238 property::master = master.modalSlave;
6242 parent.children.Remove(this);
6245 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6246 if(slaveHolder.data == this)
6248 master.slaves.Delete(slaveHolder);
6253 #if !defined(__EMSCRIPTEN__)
6254 if(parent == guiApp.desktop && !mutex)
6258 if(style.isDocument)
6261 parent.numDocuments--;
6262 documentID = parent.GetDocumentID();
6265 if(!style.stayOnTop)
6266 for(; last && last.style.stayOnTop; last = last.prev);
6268 parent.children.Insert((last == this) ? null : last, this);
6269 //parent.children.Add(this);
6272 dispDriver = parent.dispDriver;
6275 master.modalSlave = this;
6277 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6282 master.slaves.Add(slaveHolder = OldLink { data = this });
6287 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6289 if(style.isDefault && !master.defaultControl)
6290 master.defaultControl = this;
6292 stateAnchor = normalAnchor = anchor;
6293 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6295 // TOCHECK: Why is this here?
6296 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6297 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6299 this.visible = false;
6300 style.hidden = true;
6303 // autoCreate = true;
6311 if(parent == guiApp.desktop)
6312 Log("LoadGraphics %s\n", caption);
6314 if(LoadGraphics(true, false))
6322 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6329 if(style.hasMenuBar /*&& menu*/)
6335 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6336 interim = false, inactive = true, nonClient = true, size.h = 24
6344 // Create the system buttons
6345 CreateSystemChildren();
6347 UpdateActiveDocument(null);
6349 if(style.isDocument)
6353 MenuItem item = menu.FindItem(MenuFileSave, 0);
6354 if(item) item.disabled = !modifiedDocument && fileName;
6359 if(parent == guiApp.desktop)
6360 Log("Preemptive SetState %s\n", caption);
6363 // Preemptive Set State to ensure proper anchoring
6364 SetStateEx(state, false);
6366 style.hidden = true;
6372 for(child = children.first; child; child = next)
6375 if(!child.created && (child.autoCreate || child.wasCreated))
6382 for(link = slaves.first; link; link = next)
6384 Window slave = link.data;
6386 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6389 // Things might have happened that invalidated 'next'...
6390 // Start over the search for slaves to create.
6391 // (Added this to fix crash with Stacker & Toolbar)
6392 next = slaves.first;
6401 if(parent == guiApp.desktop)
6402 Log("Real SetState %s\n", caption);
6405 if(isActiveClient && visible)
6407 parent.numPositions--;
6408 if(state == minimized) parent.numIcons--;
6411 parent.OnChildAddedOrRemoved(this, false);
6413 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6415 // Real set state & activate for proper display & activation
6416 property::visible = visible;
6417 // SetState(state & 0x00000003, true, 0);
6418 guiApp.interfaceDriver.SetIcon(this, icon);
6423 /*if(rootWindow == this)
6424 guiApp.interfaceDriver.ActivateRootWindow(this);
6426 if(creationActivation == activate && guiApp.desktop.active)
6427 ActivateEx(true, false, true, true, null, null);
6428 else if(creationActivation == activate || creationActivation == flash)
6431 if(this == rootWindow)
6437 rootWindow.ConsequentialMouseMove(false);
6448 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6454 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6456 //style.hidden = true; // !visible;
6457 style.hidden = !visible;
6458 if(master.modalSlave == this)
6459 master.modalSlave = null;
6466 void WriteCaption(Surface surface, int x, int y)
6469 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6472 void Update(Box region)
6478 rootWindow = this.rootWindow;
6480 // rootWindow.mutex.Wait();
6481 if(!destroyed && visible && display)
6486 // Testing this to avoid repetitve full update to take time...
6487 if(rootWindow.fullRender)
6489 rootWindow.dirty = true;
6492 if(dirtyArea.count == 1)
6494 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6495 if(item.box.left <= box.left &&
6496 item.box.top <= box.top &&
6497 item.box.right >= box.right &&
6498 item.box.bottom >= box.bottom)
6500 rootWindow.dirty = true;
6505 if(display.flags.flipping && !rootWindow.dirty)
6507 if(this == rootWindow)
6511 rootWindow.Update(null);
6516 rootWindow.dirty = true;
6521 realBox.left += clientStart.x;
6522 realBox.top += clientStart.y;
6523 realBox.right += clientStart.x;
6524 realBox.bottom += clientStart.y;
6530 if(realBox.right >= realBox.left &&
6531 realBox.bottom >= realBox.top)
6533 // if(!rootWindow.fullRender)
6534 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6536 for(child = children.first; child; child = child.next)
6541 box.left -= child.absPosition.x - absPosition.x;
6542 box.top -= child.absPosition.y - absPosition.y;
6543 box.right -= child.absPosition.x - absPosition.x;
6544 box.bottom -= child.absPosition.y - absPosition.y;
6545 if(box.right >= child.box.left && box.left <= child.box.right &&
6546 box.bottom >= child.box.top && box.top <= child.box.bottom)
6548 box.left -= child.clientStart.x;
6549 box.top -= child.clientStart.y;
6550 box.right -= child.clientStart.x;
6551 box.bottom -= child.clientStart.y;
6557 realBox.left += absPosition.x - rootWindow.absPosition.x;
6558 realBox.top += absPosition.y - rootWindow.absPosition.y;
6559 realBox.right += absPosition.x - rootWindow.absPosition.x;
6560 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6561 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6564 else if(this == guiApp.desktop)
6567 for(window = children.first; window; window = window.next)
6573 Box childBox = region;
6575 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6576 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6577 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6578 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6580 window.Update(childBox);
6583 window.Update(null);
6588 // rootWindow.mutex.Release();
6595 if(guiApp.windowCaptured != this)
6597 if(guiApp.windowCaptured)
6601 //Logf("Captured %s (%s)\n", caption, class.name);
6602 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6603 guiApp.windowCaptured = this;
6609 bool Destroy(int64 code)
6614 if(!destroyed && !CloseConfirmation(false)) return false;
6618 // TOCHECK: Should autoCreate be set to false here?
6629 void Move(int x, int y, int w, int h)
6631 normalAnchor = Anchor { left = x, top = y };
6632 normalSizeAnchor = SizeAnchor { size = { w, h } };
6634 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6636 if(destroyed) return;
6638 stateAnchor = normalAnchor;
6639 stateSizeAnchor = normalSizeAnchor;
6641 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6642 Position(x,y, w, h, true, true, true, true, false, true);
6646 DialogResult Modal(void)
6652 // FIXES MEMORY LEAK IF Create() FAILED
6658 void SetScrollArea(int width, int height, bool snapToStep)
6662 int stepX = sbStep.x, stepY = sbStep.y;
6663 // Needed to make snapped down position match the skin's check of client area
6664 // against realvirtual
6667 SNAPDOWN(stepX, textCellW);
6668 SNAPDOWN(stepY, textCellH);
6669 stepX = Max(stepX, textCellW);
6670 stepY = Max(stepY, textCellH);
6672 if(scrollFlags.snapX)
6673 SNAPUP(width, stepX);
6674 if(scrollFlags.snapY)
6675 SNAPUP(height, stepY);
6678 reqScrollArea.w = width;
6679 reqScrollArea.h = height;
6680 noAutoScrollArea = (width > 0 || height > 0);
6682 UpdateScrollBars(true, true);
6685 void SetScrollPosition(int x, int y)
6688 sbh.Action(setPosition, x, 0);
6692 int seen = clientSize.w, total = reqScrollArea.w;
6694 if(scrollFlags.snapX)
6695 SNAPDOWN(seen, sbStep.x);
6697 if(!total) total = seen;
6698 range = total - seen + 1;
6699 range = Max(range, 1);
6701 if(x >= range) x = range - 1;
6703 if(scrollFlags.snapX)
6704 SNAPUP(x, sbStep.x);
6707 OnHScroll(setPosition, x, 0);
6711 SNAPDOWN(x, textCellW);
6717 sbv.Action(setPosition, y, 0);
6721 int seen = clientSize.h, total = reqScrollArea.h;
6724 if(scrollFlags.snapY)
6725 SNAPDOWN(seen, sbStep.y);
6727 if(!total) total = seen;
6728 range = total - seen + 1;
6729 range = Max(range, 1);
6731 if(y >= range) y = range - 1;
6733 if(scrollFlags.snapY)
6734 SNAPUP(y, sbStep.y);
6737 OnVScroll(setPosition, y, 0);
6740 SNAPDOWN(y, textCellH);
6745 UpdateCaret(false, false);
6748 void SetScrollLineStep(int stepX, int stepY)
6754 SNAPDOWN(stepX, textCellW);
6755 SNAPDOWN(stepY, textCellH);
6756 stepX = Max(stepX, textCellW);
6757 stepY = Max(stepY, textCellH);
6760 sbh.lineStep = stepX;
6762 sbv.lineStep = stepY;
6765 void SetState(WindowState newState, bool activate, Modifiers mods)
6769 if(state == newState || OnStateChange(newState, mods))
6771 //WindowState prevState = state;
6775 // This used to be at the end of the brackets... moved for X, testing...
6776 // This has the effect of activating the window through the system...
6777 if(rootWindow == this)
6778 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6780 SetStateEx(newState, activate);
6782 if(rootWindow == this && !rootWindow.nativeDecorations)
6784 int x = position.x, y = position.y;
6787 x -= guiApp.desktop.absPosition.x;
6788 y -= guiApp.desktop.absPosition.y;
6790 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6794 //state = prevState;
6796 if(state != maximized && style.hasMaximize)
6799 for(child = parent.children.first; child; child = child.next)
6801 if(child != this && child.state == maximized)
6802 child.SetStateEx(normal, false);
6806 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6807 parent.UpdateScrollBars(true, true);
6810 // Do we really need this stuff here?
6811 // Shouldn't the Activate stuff take care of it?
6812 if(parent.rootWindow == parent && style)
6815 parent.FigureCaption(caption);
6816 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6817 parent.UpdateDecorations();
6821 rootWindow.ConsequentialMouseMove(false);
6828 BitmapResource GetIcon(SkinBitmap iconID)
6830 return guiApp.currentSkin.GetBitmap(iconID);
6833 void SetMouseRange(Box range)
6835 if(range || guiApp.fullScreenMode)
6840 clip.left = range.left + absPosition.x + clientStart.x;
6841 clip.top = range.top + absPosition.y + clientStart.y;
6842 clip.right = range.right + absPosition.x + clientStart.x;
6843 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6847 clip.left = guiApp.desktop.box.left;
6848 clip.top = guiApp.desktop.box.top;
6849 clip.right = guiApp.desktop.box.right;
6850 clip.bottom = guiApp.desktop.box.bottom;
6852 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6855 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6858 void SetMouseRangeToClient(void)
6860 if(guiApp.fullScreenMode || this != guiApp.desktop)
6862 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6863 box.Clip(clientArea);
6867 SetMouseRange(null);
6870 void SetMouseRangeToWindow(void)
6872 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6873 if(this == guiApp.desktop)
6874 SetMouseRangeToClient();
6879 // x, y: Desktop Coordinates
6880 void ShowSysMenu(int x, int y)
6883 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6886 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6887 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6891 menu, $"Move", m, NotifySelect = MenuWindowMove,
6892 disabled = !style.fixed || state == maximized
6896 menu, $"Size", s, NotifySelect = MenuWindowSize,
6897 disabled = !style.sizable || state != normal
6901 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6902 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6906 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6907 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6911 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6912 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6914 MenuDivider { menu };
6917 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6918 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6920 windowMenu.Create();
6925 ActivateEx(true, true, true, true, null, null);
6928 void MakeActive(void)
6930 ActivateEx(true, false, true, false, null, null);
6933 void SoftActivate(void)
6935 if(guiApp.desktop.active)
6940 if(this == rootWindow)
6945 void Deactivate(void)
6947 ActivateEx(false, true, true, true, null, null);
6952 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6955 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6957 bool result = false;
6958 if(activeChild && activeChild.cycle)
6960 Window modalWindow, child = activeChild;
6961 if(!clientOnly /*&& parent.tabCycle*/)
6963 Window next = child;
6966 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6970 if(parent && parent.CycleChildren(backward, false, true, true))
6978 next = next.cycle.prev.data;
6980 next = next.cycle.next.data;
6981 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6986 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6987 parent.tabCycle && parent.CycleChildren(backward, false, false))
6991 if(tabCycleOnly && !tabCycle) return false;
6998 child = child.cycle.prev.data;
7000 child = child.cycle.next.data;
7001 if(child == child.parent.activeChild)
7003 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
7006 modalWindow = child.FindModal();
7009 // Scroll the window to include the active control
7010 if(sbh && !child.style.dontScrollHorz)
7012 if(child.scrolledPos.x < 0)
7013 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
7014 else if(child.scrolledPos.x + child.size.w > clientSize.w)
7015 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
7017 if(sbv && !child.style.dontScrollVert)
7019 if(child.scrolledPos.y < 0)
7020 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
7021 else if(child.scrolledPos.y + child.size.h > clientSize.h)
7022 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
7026 child = modalWindow ? modalWindow : child;
7027 child.ActivateEx(true, true, true, true, null, null);
7028 if(child.tabCycle && child.childrenCycle.first)
7029 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7037 ConsequentialMouseMove(false);
7041 void AddResource(Resource resource)
7045 ResPtr ptr { resource = resource };
7049 // Load Graphics here if window is created already
7050 if(/*created && */display)
7052 display.Lock(false);
7053 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7054 ptr.loaded = display.displaySystem.LoadResource(resource);
7058 // Temporary hack to load font right away for listbox in dropbox ...
7059 else if(master && master.display)
7061 master.display.Lock(false);
7062 master.display.displaySystem.LoadResource(resource);
7063 master.display.Unlock();
7069 void RemoveResource(Resource resource)
7074 for(ptr = resources.first; ptr; ptr = ptr.next)
7076 if(ptr.resource == resource)
7082 // Unload Graphics here if window is created already
7083 if(/*created && */display)
7087 display.Lock(false);
7088 display.displaySystem.UnloadResource(resource, ptr.loaded);
7094 resources.Delete(ptr);
7099 void SetCaret(int x, int y, int size)
7106 if(active && !style.interim && isEnabled)
7108 if(visible || !guiApp.caretOwner)
7109 guiApp.caretOwner = size ? this : null;
7111 UpdateCaret(false, false);
7114 guiApp.interfaceDriver.SetCaret(0,0,0);
7115 UpdateCaret(false, true);
7116 guiApp.caretEnabled = false;
7119 else if(style.inactive && active)
7121 guiApp.interfaceDriver.SetCaret(0,0,0);
7122 UpdateCaret(false, true);
7123 guiApp.caretEnabled = false;
7128 void Scroll(int x, int y)
7130 bool opaque = !style.drawBehind || background.a;
7131 if(opaque && display && display.flags.scrolling)
7133 Box box = clientArea;
7134 box.left += clientStart.x;
7135 box.top += clientStart.y;
7136 box.right += clientStart.x;
7137 box.bottom += clientStart.y;
7139 //scrollExtent.Free(null);
7140 scrollExtent.AddBox(box);
7141 scrolledArea.x += x;
7142 scrolledArea.y += y;
7144 //scrollExtent.Free();
7145 //scrollExtent.AddBox(clientArea);
7146 //scrollExtent.Offset(clientStart.x, clientStart.y);
7147 //scrolledArea.x = x;
7148 //scrolledArea.y = y;
7154 rootWindow.dirty = true;
7157 void ReleaseCapture()
7159 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7161 Window oldCaptured = guiApp.windowCaptured;
7162 guiApp.windowCaptured = null;
7163 guiApp.prevWindow = null;
7166 //guiApp.Log("Released Capture\n");
7168 guiApp.interfaceDriver.SetMouseCapture(null);
7170 //oldCaptured.OnMouseCaptureLost();
7173 oldCaptured.ConsequentialMouseMove(false);
7178 private void _SetCaption(const char * format, va_list args)
7185 char caption[MAX_F_STRING];
7186 vsnprintf(caption, sizeof(caption), format, args);
7187 caption[sizeof(caption)-1] = 0;
7189 this.caption = CopyString(caption);
7194 firewatchers caption;
7198 /*deprecated*/ void SetText(const char * format, ...)
7201 va_start(args, format);
7202 _SetCaption(format, args);
7206 void SetCaption(const char * format, ...)
7209 va_start(args, format);
7210 _SetCaption(format, args);
7214 bool Grab(Bitmap bitmap, Box box, bool decorations)
7216 bool result = false;
7217 if(display || this == guiApp.desktop)
7219 Box clip = {MININT, MININT, MAXINT, MAXINT};
7225 clip.Clip(clientArea);
7227 clip.Clip(this.box);
7229 if(rootWindow != this)
7231 clip.left += absPosition.y;
7232 clip.top += absPosition.y;
7233 clip.right += absPosition.x;
7234 clip.bottom += absPosition.y;
7237 clip.left += decorations ? 0 : clientStart.x;
7238 clip.top += decorations ? 0 : clientStart.y;
7239 clip.right += decorations ? 0 : clientStart.x;
7240 clip.bottom += decorations ? 0 : clientStart.y;
7242 if(display && display.flags.flipping)
7244 rootWindow.Update(null);
7245 rootWindow.UpdateDisplay();
7252 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7253 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7257 result = display.Grab(bitmap, clip.left, clip.top,
7258 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7260 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7262 if(!bitmap.Convert(null, pixelFormat888, null))
7269 void GetMousePosition(int * x, int * y)
7271 int mouseX = 0, mouseY = 0;
7272 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7275 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7276 if(this != guiApp.desktop)
7278 mouseX -= absPosition.x + clientStart.x;
7279 mouseY -= absPosition.y + clientStart.y;
7286 DialogResult DoModal()
7288 DialogResult returnCode = 0;
7289 int terminated = terminateX;
7292 while(!destroyed && guiApp.driver != null)
7294 if(terminateX != terminated)
7296 terminated = terminateX;
7297 guiApp.desktop.Destroy(0);
7298 if(guiApp.desktop.created)
7301 //printf("Resetting terminate X to 0\n");
7307 guiApp.UpdateDisplay();
7308 if(!guiApp.ProcessInput(false))
7311 returnCode = this.returnCode;
7324 return !destroyed && guiApp.driver != null && terminateX < 2;
7327 DialogResult DoModalEnd()
7329 DialogResult returnCode = this.returnCode;
7334 // --- Window manipulation ---
7335 /*bool GetDisabled()
7337 bool disabled = this.disabled;
7339 for(window = this; (window = window.master); )
7350 // --- Mouse Manipulation ---
7351 void GetNCMousePosition(int * x, int * y)
7353 GetMousePosition(x, y);
7354 if(x) *x += clientStart.x;
7355 if(y) *y += clientStart.y;
7358 // --- Carets manipulation ---
7359 void GetCaretPosition(Point caretPos)
7361 caretPos = this.caretPos;
7364 int GetCaretSize(void)
7369 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7375 bool CloseConfirmation(bool parentClosing)
7388 if(!OnClose(parentClosing))
7391 // If you want to skip this, simply set modifiedDocument to false in OnClose
7392 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7394 DialogResult dialogRes;
7397 sprintf(message, $"Save changes to %s?", fileName);
7399 sprintf(message, $"Save changes to Untitled %d?", documentID);
7401 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7403 if(dialogRes == yes)
7405 // TOFIX: Precomp error if brackets are taken out
7406 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7408 else if(dialogRes == cancel)
7414 for(slave = slaves.first; slave; slave = slave.next)
7416 Window w = slave.data;
7417 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7425 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7428 for(child = children.first; child; child = child.next)
7429 if(child.isActiveClient && !child.CloseConfirmation(true))
7437 for(child = children.first; child; child = child.next)
7438 if(!child.isActiveClient && !child.CloseConfirmation(true))
7448 // Static methods... move them somewhere else?
7449 void ::RestoreCaret()
7451 if(guiApp.caretOwner)
7452 guiApp.caretOwner.UpdateCaret(false, false);
7455 void ::FreeMouseRange()
7457 guiApp.interfaceDriver.SetMouseRange(null, null);
7461 bool MenuFileClose(MenuItem selection, Modifiers mods)
7463 Window document = activeChild;
7465 document.Destroy(0);
7469 bool MenuFileExit(MenuItem selection, Modifiers mods)
7475 bool MenuFileSave(MenuItem selection, Modifiers mods)
7480 #if !defined(__EMSCRIPTEN__)
7481 fileMonitor.fileName = null;
7485 if(OnSaveFile(fileName))
7487 //if(OnFileModified != Window::OnFileModified)
7490 #if !defined(__EMSCRIPTEN__)
7491 fileMonitor.fileName = fileName;
7498 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7499 DialogResult answer = dialog.Modal();
7501 if(answer != yes) return (bool)answer;
7504 return MenuFileSaveAs(selection, mods);
7507 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7509 DialogResult result = (DialogResult)bool::true;
7510 FileDialog fileDialog = saveDialog;
7515 fileDialog = FileDialog {};
7520 fileDialog.filePath = fileName;
7523 char filePath[MAX_FILENAME];
7524 sprintf(filePath, "Untitled %d", documentID);
7525 fileDialog.filePath = filePath;
7527 #if !defined(__EMSCRIPTEN__)
7528 fileMonitor.fileName = null;
7531 fileDialog.type = save;
7532 fileDialog.text = $"Save As";
7536 fileDialog.master = master.parent ? master : this;
7537 if(fileDialog.Modal() == ok)
7539 const char * filePath = fileDialog.filePath;
7541 if(OnSaveFile(filePath))
7544 property::fileName = filePath;
7545 NotifySaved(master, this, filePath);
7550 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7551 DialogResult answer = dialog.Modal();
7566 #if !defined(__EMSCRIPTEN__)
7567 //if(OnFileModified != Window::OnFileModified && fileName)
7570 fileMonitor.fileName = fileName;
7575 return (bool)result; // Actually returning result from Yes/NoCancel message box
7578 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7580 Window document = activeChild;
7582 for(document = children.first; document; document = next)
7584 next = document.next;
7585 if(document.style.isDocument || document.fileName)
7586 document.MenuFileSave(selection, mods);
7591 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7595 for(document = children.first; document; document = document.next)
7596 //if(document.style.isDocument && document.state == minimized)
7597 if(document.style.isActiveClient && document.state == minimized)
7598 document.SetState(minimized, false, mods);
7602 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7604 Window document = activeChild;
7607 Window firstDocument = null;
7609 OldLink cycle = document.cycle.prev;
7614 if(child.style.isActiveClient && !child.style.hidden)
7618 firstDocument = child;
7619 if(child.state == minimized)
7620 child.SetState(minimized, false, mods);
7623 child.positionID = id++;
7624 child.SetState(normal, false, mods);
7625 child.anchor.left.type = cascade;
7628 child.normalSizeAnchor = *&child.sizeAnchor;
7629 child.normalAnchor = child.anchor;
7631 // Break the anchors for moveable/resizable windows
7632 if(child.style.fixed)
7634 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7636 (*&child.normalAnchor).left = x;
7637 (*&child.normalAnchor).top = y;
7638 (*&child.normalAnchor).right.type = none;
7639 (*&child.normalAnchor).bottom.type = none;
7641 (*&child.normalSizeAnchor).isClientW = false;
7642 (*&child.normalSizeAnchor).isClientH = false;
7643 (*&child.normalSizeAnchor).size.w = w;
7644 (*&child.normalSizeAnchor).size.h = h;
7645 child.anchored = false;
7648 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7650 child.stateAnchor = child.normalAnchor;
7651 child.stateSizeAnchor = child.normalSizeAnchor;
7653 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7654 child.Position(x, y, w, h, true, true, true, true, false, false);
7659 last = children.last;
7660 if(!child.style.stayOnTop)
7661 for(; last && last.style.stayOnTop; last = last.prev);
7662 children.Move(child, last);
7663 childrenOrder.Move(child.order, childrenOrder.last);
7665 if(cycle == document.cycle) break;
7669 firstDocument.Activate();
7674 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7681 // Close all closes all active clients, not all documents
7682 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7684 Window next, document;
7686 for(document = children.first; document; document = next)
7688 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7689 if(document.style.isActiveClient)
7690 if(!document.Destroy(0) && !document.style.hidden)
7696 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7698 if(style.hasMaximize && state != maximized)
7699 SetState(maximized, 0, 0);
7703 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7705 if(style.hasMinimize && state != minimized)
7707 SetState(minimized, 0, 0);
7708 parent.CycleChildren(false, true, false, true);
7713 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7715 MenuMoveOrSize(false, selection ? true : false);
7719 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7721 CycleChildren(false, true, false, true);
7725 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7727 CycleChildren(true, true, false, true);
7731 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7733 MenuMoveOrSize(true, true);
7737 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7740 SetState(normal, 0, 0);
7744 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7747 int64 id = selection.id;
7748 OldLink cycle = activeClient.cycle;
7750 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7753 Window sibling = cycle.data;
7754 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7762 document = cycle.data;
7763 document.Activate();
7765 //if(activeChild.state == maximized)
7766 // document.SetState(maximized, false, mods);
7767 //else if(document.state == minimized)
7768 // document.SetState(normal, false, mods);
7772 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7774 stayOnTop = !style.stayOnTop;
7778 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7780 Window document = activeChild;
7783 Window firstDocument = null;
7784 OldLink cycle = document.cycle;
7788 Window child = cycle.data;
7789 if(child.style.isActiveClient && !child.style.hidden)
7791 if(!firstDocument) firstDocument = child;
7792 if(child.state == minimized)
7793 child.SetState(minimized, false, mods);
7796 child.positionID = id++;
7797 child.SetState(normal, false, mods);
7798 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7800 child.anchor.left.type = hTiled;
7803 child.normalSizeAnchor = *&child.sizeAnchor;
7804 child.normalAnchor = child.anchor;
7806 // Break the anchors for moveable/resizable windows
7807 if(child.style.fixed)
7809 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7811 (*&child.normalAnchor).left = x;
7812 (*&child.normalAnchor).top = y;
7813 (*&child.normalAnchor).right.type = none;
7814 (*&child.normalAnchor).bottom.type = none;
7815 (*&child.normalSizeAnchor).isClientW = false;
7816 (*&child.normalSizeAnchor).isClientH = false;
7817 (*&child.normalSizeAnchor).size.w = w;
7818 (*&child.normalSizeAnchor).size.h = h;
7819 child.anchored = false;
7822 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7824 child.stateAnchor = child.normalAnchor;
7825 child.stateSizeAnchor = child.normalSizeAnchor;
7827 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7828 child.Position(x,y, w, h, true, true, true, true, false, true);
7833 if((cycle = cycle.next) == document.cycle) break;
7836 firstDocument.Activate();
7841 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7843 Window document = activeChild;
7846 Window firstDocument = null;
7848 OldLink cycle = document.cycle;
7853 //if(child.style.isDocument)
7854 if(child.style.isActiveClient && !child.style.hidden)
7856 if(!firstDocument) firstDocument = child;
7857 if(child.state == minimized)
7858 child.SetState(minimized, false, mods);
7861 child.positionID = id++;
7862 child.SetState(normal, false, mods);
7863 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7865 child.anchor.left.type = vTiled;
7868 child.normalSizeAnchor = *&child.sizeAnchor;
7869 child.normalAnchor = child.anchor;
7871 // Break the anchors for moveable/resizable windows
7872 if(child.style.fixed)
7874 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7876 (*&child.normalAnchor).left = x;
7877 (*&child.normalAnchor).top = y;
7878 (*&child.normalAnchor).right.type = none;
7879 (*&child.normalAnchor).bottom.type = none;
7880 (*&child.normalSizeAnchor).isClientW = false;
7881 (*&child.normalSizeAnchor).isClientH = false;
7882 (*&child.normalSizeAnchor).size.w = w;
7883 (*&child.normalSizeAnchor).size.h = h;
7884 child.anchored = false;
7887 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7889 child.stateAnchor = child.normalAnchor;
7890 child.stateSizeAnchor = child.normalSizeAnchor;
7892 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7893 child.Position(x,y, w, h, true, true, true, true, false, true);
7898 if((cycle = cycle.next) == document.cycle) break;
7901 firstDocument.Activate();
7906 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7908 WindowList dialog { master = this };
7909 Window document = (Window)(intptr)dialog.Modal();
7912 if(activeChild.state == maximized)
7913 document.SetState(maximized, false, mods);
7914 else if(document.state == minimized)
7915 document.SetState(normal, false, mods);
7916 document.Activate();
7922 virtual bool OnCreate(void);
7923 virtual void OnDestroy(void);
7924 virtual void OnDestroyed(void);
7925 virtual bool OnClose(bool parentClosing);
7926 virtual bool OnStateChange(WindowState state, Modifiers mods);
7927 virtual bool OnPostCreate(void);
7928 virtual bool OnMoving(int *x, int *y, int w, int h);
7929 virtual bool OnResizing(int *width, int *height);
7930 virtual void OnResize(int width, int height);
7931 virtual void OnPosition(int x, int y, int width, int height);
7932 virtual bool OnLoadGraphics(void);
7933 virtual void OnApplyGraphics(void);
7934 virtual void OnUnloadGraphics(void);
7935 virtual void OnRedraw(Surface surface);
7936 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7937 virtual void OnActivateClient(Window client, Window previous);
7938 virtual bool OnKeyDown(Key key, unichar ch);
7939 virtual bool OnKeyUp(Key key, unichar ch);
7940 virtual bool OnKeyHit(Key key, unichar ch);
7941 virtual bool OnSysKeyDown(Key key, unichar ch);
7942 virtual bool OnSysKeyUp(Key key, unichar ch);
7943 virtual bool OnSysKeyHit(Key key, unichar ch);
7944 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7945 virtual bool OnMouseLeave(Modifiers mods);
7946 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7947 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7948 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7949 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7950 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7951 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7952 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7953 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7954 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7955 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7956 virtual void OnMouseCaptureLost(void);
7957 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7958 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7959 virtual void OnDrawOverChildren(Surface surface);
7960 virtual bool OnFileModified(FileChange fileChange, const char * param);
7961 virtual bool OnSaveFile(const char * fileName);
7963 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7964 // Note: A 'client' would refer to isActiveClient, rather than
7965 // being confined to the 'client area' (nonClient == false)
7966 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7967 virtual void OnChildVisibilityToggled(Window child, bool visible);
7968 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7970 // Skins Virtual Functions
7971 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7972 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7973 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7978 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7979 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7980 virtual bool IsMouseMoving(int x, int y, int w, int h)
7984 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7988 virtual void UpdateNonClient();
7989 virtual void SetBox(Box box); // This is used in the MySkin skin
7990 virtual bool IsInside(int x, int y)
7992 return box.IsPointInside({x, y});
7994 virtual bool IsOpaque()
7996 return (!style.drawBehind || background.a == 255);
8000 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
8001 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
8002 virtual void Window::NotifySaved(Window window, const char * filePath);
8007 property Window parent
8009 property_category $"Layout"
8012 if(value || guiApp.desktop)
8015 Window oldParent = parent;
8016 Anchor anchor = this.anchor;
8018 if(value && value.IsDescendantOf(this)) return;
8019 if(value && value == this)
8021 if(!value) value = guiApp.desktop;
8023 if(value == oldParent) return;
8025 if(!master || (master == this.parent && master == guiApp.desktop))
8026 property::master = value;
8030 parent.children.Remove(this);
8034 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8035 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
8036 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8037 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8041 last = value.children.last;
8043 if(style.isDocument)
8046 parent.numDocuments--;
8047 documentID = value.GetDocumentID();
8050 if(style.isActiveClient && !style.hidden)
8052 if(parent && parent != guiApp.desktop && !(style.hidden))
8054 if(state == minimized) parent.numIcons--;
8055 parent.numPositions--;
8059 if(!style.stayOnTop)
8060 for(; last && last.style.stayOnTop; last = last.prev);
8062 value.children.Insert(last, this);
8064 // *** NEW HERE: ***
8066 parent.childrenCycle.Delete(cycle);
8068 parent.childrenOrder.Delete(order);
8071 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8072 // Should something else be done?
8073 if(parent && parent.activeChild == this)
8074 parent.activeChild = null;
8075 if(parent && parent.activeClient == this)
8076 parent.activeClient = null;
8082 int x = position.x, y = position.y, w = size.w, h = size.h;
8086 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8087 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8089 vpw = value.clientSize.w;
8090 vph = value.clientSize.h;
8096 else if(style.fixed)
8098 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8099 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8102 anchor = this.anchor;
8104 if(anchor.left.type == offset) anchor.left.distance = x;
8105 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8106 if(anchor.top.type == offset) anchor.top.distance = y;
8107 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8108 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8109 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8110 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8111 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8112 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8113 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8115 if(!anchor.left.type && !anchor.right.type)
8117 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8118 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8120 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8121 if(!anchor.top.type && !anchor.bottom.type)
8123 anchor.vert.distance = (y + h / 2) - (vph / 2);
8124 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8126 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8129 parent.OnChildAddedOrRemoved(this, false);
8135 parent.childrenCycle.Insert(
8136 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8137 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8139 cycle = OldLink { data = this });
8140 parent.childrenOrder.Insert(
8141 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8142 order = OldLink { data = this });
8145 if(!style.hidden && style.isActiveClient)
8147 positionID = parent.GetPositionID(this);
8148 parent.numPositions++;
8149 if(state == minimized) parent.numIcons--;
8152 // *** FONT INHERITANCE ***
8153 if(!setFont && oldParent)
8154 stopwatching(oldParent, font);
8158 RemoveResource(systemFont);
8161 // TESTING WITH WATCHERS:
8162 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8163 // usedFont = setFont ? setFont : (systemFont);
8167 if(guiApp.currentSkin)
8169 systemFont = guiApp.currentSkin.SystemFont();
8172 usedFont = systemFont;
8173 AddResource(systemFont);
8181 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8190 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8192 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8193 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8196 UnloadGraphics(false);
8199 LoadGraphics(false, false);
8202 if(value.rootWindow != rootWindow)
8203 DisplayModeChanged();
8207 scrolledPos.x = MININT; // Prevent parent update
8209 bool anchored = this.anchored;
8210 property::anchor = anchor;
8211 this.anchored = anchored;
8216 if(guiApp.currentSkin)
8217 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8219 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8220 Position(x, y, w, h, true, true, true, true, false, true);
8225 // else parent = value;
8227 oldParent.OnChildAddedOrRemoved(this, true);
8230 get { return parent; }
8233 property Window master
8235 property_category $"Behavior"
8238 //if(this == value) return;
8239 if(value && value.IsSlaveOf(this)) return;
8245 OldLink slaveHolder;
8246 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8247 if(slaveHolder.data == this)
8249 master.slaves.Delete(slaveHolder);
8256 value.slaves.Add(OldLink { data = this });
8261 master.hotKeys.Remove(hotKey);
8262 value.hotKeys.Add(hotKey);
8265 if(master && master.defaultControl == this)
8266 master.defaultControl = null;
8268 if(style.isDefault && !value.defaultControl)
8269 value.defaultControl = this;
8274 get { return master ? master : parent; }
8277 property const char * caption
8279 property_category $"Appearance"
8286 caption = new char[strlen(value)+1];
8288 strcpy(caption, value);
8293 get { return caption; }
8298 property_category $"Behavior"
8307 master.hotKeys.Add(hotKey = HotKeySlot { });
8311 hotKey.window = this;
8316 master.hotKeys.Delete(hotKey);
8321 get { return hotKey ? hotKey.key : 0; }
8324 property Color background
8326 property_category $"Appearance"
8329 background.color = value;
8334 if(this == rootWindow)
8335 guiApp.interfaceDriver.SetRootWindowColor(this);
8338 get { return background.color; }
8341 property Percentage opacity
8343 property_category $"Appearance"
8346 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8347 drawBehind = (background.a == 255) ? false : true;
8349 get { return background.a / 255.0f; }
8352 property Color foreground
8354 property_category $"Appearance"
8362 get { return foreground; }
8365 property BorderStyle borderStyle
8367 property_category $"Appearance"
8370 if(!((BorderBits)value).fixed)
8372 style.hasClose = false;
8373 style.hasMaximize = false;
8374 style.hasMinimize = false;
8375 nativeDecorations = false;
8377 style.borderBits = value;
8381 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8383 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8384 Position(x, y, w, h, true, true, true, true, false, true);
8385 CreateSystemChildren();
8388 get { return (BorderStyle)style.borderBits; }
8391 property Size minClientSize
8393 property_category $"Layout"
8394 set { minSize = value; }
8395 get { value = minSize; }
8398 property Size maxClientSize
8400 property_category $"Layout"
8401 set { maxSize = value; }
8402 get { value = maxSize; }
8405 property bool hasMaximize
8407 property_category $"Window Style"
8410 style.hasMaximize = value;
8411 if(value) { style.fixed = true; style.contour = true; }
8415 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8417 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8418 Position(x, y, w, h, true, true, true, true, false, true);
8420 CreateSystemChildren();
8423 get { return style.hasMaximize; }
8426 property bool hasMinimize
8428 property_category $"Window Style"
8431 style.hasMinimize = value;
8432 if(value) { style.fixed = true; style.contour = true; }
8436 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8438 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8439 Position(x, y, w, h, true, true, true, true, false, true);
8441 CreateSystemChildren();
8444 get { return style.hasMinimize; }
8447 property bool hasClose
8449 property_category $"Window Style"
8452 style.hasClose = value;
8453 if(value) { style.fixed = true; style.contour = true; }
8457 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8458 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8459 Position(x, y, w, h, true, true, true, true, false, true);
8460 CreateSystemChildren();
8463 get { return style.hasClose; }
8466 property bool nonClient
8468 property_category $"Layout"
8471 style.nonClient = value;
8473 style.stayOnTop = true;
8475 get { return style.nonClient; }
8478 property bool inactive
8480 property_category $"Behavior"
8485 // *** NEW HERE: ***
8489 parent.childrenCycle.Delete(cycle);
8491 parent.childrenOrder.Delete(order);
8498 active = false; // true;
8499 if(parent.activeChild == this)
8500 parent.activeChild = null;
8501 if(parent.activeClient == this)
8502 parent.activeClient = null;
8511 parent.childrenCycle.Insert(
8512 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8513 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8515 cycle = OldLink { data = this });
8517 parent.childrenOrder.Insert(
8518 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8519 order = OldLink { data = this });
8522 style.inactive = value;
8524 get { return style.inactive; }
8527 property bool clickThrough
8529 property_category $"Behavior"
8530 set { style.clickThrough = value; }
8531 get { return style.clickThrough; }
8534 property bool isRemote
8536 property_category $"Behavior"
8537 set { style.isRemote = value; }
8538 get { return style.isRemote; }
8541 property bool noCycle
8543 property_category $"Behavior"
8544 set { style.noCycle = value; }
8545 get { return style.noCycle; }
8548 property bool isModal
8550 property_category $"Behavior"
8551 set { style.modal = value; }
8552 get { return style.modal; }
8555 property bool interim
8557 property_category $"Behavior"
8558 set { style.interim = value; }
8559 get { return style.interim; }
8562 property bool tabCycle
8564 property_category $"Behavior"
8565 set { style.tabCycle = value; }
8566 get { return style.tabCycle; }
8569 property bool isDefault
8571 property_category $"Behavior"
8579 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8580 if(sibling != this && sibling.style.isDefault)
8581 sibling.style.isDefault = false;*/
8582 if(master.defaultControl)
8583 master.defaultControl.style.isDefault = false;
8584 master.defaultControl = this;
8586 else if(master.defaultControl == this)
8587 master.defaultControl = null;
8591 style.isDefault = value;
8593 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8595 get { return style.isDefault; }
8598 property bool drawBehind
8600 property_category $"Window Style"
8601 set { style.drawBehind = value; }
8602 get { return style.drawBehind; }
8605 property bool hasMenuBar
8607 property_category $"Window Style"
8617 if(created && !menuBar)
8624 anchor = Anchor { top = 23, left = 1, right = 1 },
8626 inactive = true, nonClient = true
8631 else if(created && menuBar)
8636 style.hasMenuBar = value;
8638 get { return style.hasMenuBar; }
8641 property bool hasStatusBar
8643 property_category $"Window Style"
8650 statusBar = StatusBar { this };
8658 style.hasStatusBar = value;
8660 get { return style.hasStatusBar; }
8662 property bool stayOnTop
8664 property_category $"Window Style"
8669 if(created && !style.stayOnTop)
8671 if(rootWindow == this)
8672 guiApp.interfaceDriver.OrderRootWindow(this, true);
8673 else if(parent.children.last != this)
8675 parent.children.Move(this, parent.children.last);
8679 style.stayOnTop = true;
8683 if(created && style.stayOnTop)
8685 if(rootWindow == this)
8686 guiApp.interfaceDriver.OrderRootWindow(this, false);
8693 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8694 order && ((Window)order.data).style.stayOnTop;
8695 order = (order == parent.childrenOrder.first) ? null : order.prev);
8696 last = order ? order.data : null;
8700 for(last = parent.children.last;
8701 last && last.style.stayOnTop;
8705 parent.children.Move(this, last);
8709 style.stayOnTop = false;
8712 get { return style.stayOnTop; }
8717 property_category $"Window Style"
8727 if(menuBar && !value)
8734 if(!menuBar && style.hasMenuBar && value)
8738 this, menu = value, isMenuBar = true,
8739 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8740 inactive = true, nonClient = true
8744 UpdateActiveDocument(null);
8747 get { return menu; }
8750 property FontResource font
8752 property_category $"Appearance"
8754 isset { return setFont ? true : false; }
8759 if(value && !setFont) { stopwatching(parent, font); }
8760 else if(!value && setFont)
8766 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8775 RemoveResource(setFont);
8780 RemoveResource(systemFont);
8787 AddResource(setFont);
8790 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8793 systemFont = guiApp.currentSkin.SystemFont();
8795 usedFont = systemFont;
8796 AddResource(systemFont);
8804 get { return usedFont; }
8807 property SizeAnchor sizeAnchor
8809 property_category $"Layout"
8812 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8813 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8814 sizeAnchor.isClientW != sizeAnchor.isClientH;
8821 normalSizeAnchor = sizeAnchor;
8823 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8825 stateAnchor = normalAnchor;
8826 stateSizeAnchor = normalSizeAnchor;
8828 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8829 Position(x,y, w, h, true, true, true, true, false, true);
8836 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8837 sizeAnchor.isClientW,
8838 sizeAnchor.isClientH
8845 property_category $"Layout"
8848 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8849 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8850 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8856 sizeAnchor.isClientW = false;
8857 sizeAnchor.isClientH = false;
8858 sizeAnchor.size = value;
8860 normalSizeAnchor = sizeAnchor;
8862 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8864 stateAnchor = normalAnchor;
8865 stateSizeAnchor = normalSizeAnchor;
8867 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8868 Position(x, y, w, h, true, true, true, true, false, true);
8869 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8872 get { value = size; }
8875 property Size clientSize
8877 property_category $"Layout"
8880 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8881 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8882 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8887 sizeAnchor.isClientW = true;
8888 sizeAnchor.isClientH = true;
8889 sizeAnchor.size = value;
8891 normalSizeAnchor = sizeAnchor;
8893 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8895 stateAnchor = normalAnchor;
8896 stateSizeAnchor = normalSizeAnchor;
8898 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8899 Position(x,y, w, h, true, true, true, true, false, true);
8900 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8903 get { value = this ? clientSize : { 0, 0 }; }
8906 property Size initSize { get { value = sizeAnchor.size; } };
8908 property Anchor anchor
8910 property_category $"Layout"
8911 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8917 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8919 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8920 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8922 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8924 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8925 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8929 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8931 anchor.left.distance = 0;
8932 anchor.horz.type = 0;
8934 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8936 anchor.top.distance = 0;
8937 anchor.vert.type = 0;
8946 normalAnchor = anchor;
8948 // Break the anchors for moveable/resizable windows
8949 /*if(style.fixed ) //&& value.left.type == cascade)
8951 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8953 this.anchor = normalAnchor = Anchor { left = x, top = y };
8954 normalSizeAnchor = SizeAnchor { { w, h } };
8957 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8959 stateAnchor = normalAnchor;
8960 stateSizeAnchor = normalSizeAnchor;
8962 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8963 Position(x, y, w, h, true, true, true, true, false, true);
8972 get { value = this ? anchor : Anchor { }; }
8975 property Point position
8977 property_category $"Layout"
8980 if(value == null) return;
8982 anchor.left = value.x;
8983 anchor.top = value.y;
8984 anchor.right.type = none;
8985 anchor.bottom.type = none;
8990 normalAnchor = anchor;
8992 // Break the anchors for moveable/resizable windows
8996 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8998 normalAnchor.left = x;
8999 normalAnchor.top = y;
9000 normalAnchor.right.type = none;
9001 normalAnchor.bottom.type = none;
9002 normalSizeAnchor.size.width = w;
9003 normalSizeAnchor.size.height = h;
9007 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9009 stateAnchor = normalAnchor;
9010 stateSizeAnchor = normalSizeAnchor;
9012 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9013 Position(x,y, w, h, true, true, true, true, false, true);
9017 get { value = position; }
9020 property bool disabled
9022 property_category $"Behavior"
9025 if(this && disabled != value)
9032 get { return (bool)disabled; }
9035 property bool isEnabled
9040 for(parent = this; parent; parent = parent.parent)
9047 property WindowState state
9049 property_category $"Behavior"
9050 set { SetState(value, false, 0); }
9051 get { return this ? state : 0; }
9054 property bool visible
9056 property_category $"Behavior"
9059 if(this && !value && !style.hidden && parent)
9061 bool wasActiveChild = parent.activeChild == this;
9062 Window client = null;
9064 style.hidden = true;
9065 if(style.isActiveClient)
9067 parent.numPositions--;
9068 if(state == minimized) parent.numIcons--;
9073 OldLink prevOrder = null;
9075 if(rootWindow == this)
9076 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9079 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9082 box.left -= parent.clientStart.x;
9083 box.top -= parent.clientStart.y;
9084 box.right -= parent.clientStart.x;
9085 box.bottom -= parent.clientStart.y;
9089 if(_isModal && master && master.modalSlave == this)
9090 master.modalSlave = null;
9094 OldLink tmpPrev = order.prev;
9095 client = tmpPrev ? tmpPrev.data : null;
9096 if(client && !client.style.hidden && !client.destroyed && client.created)
9097 prevOrder = tmpPrev;
9100 client = tmpPrev ? tmpPrev.data : null;
9101 if(client == this) { client = null; break; }
9102 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9104 tmpPrev = client.order.prev;
9109 prevOrder = tmpPrev;
9114 // If this window can be an active client, make sure the next window we activate can also be one
9115 if(!style.nonClient && style.isActiveClient)
9117 tmpPrev = prevOrder;
9120 client = tmpPrev ? tmpPrev.data : null;
9121 if(client == this) { client = null; break; }
9122 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9124 tmpPrev = client.order.prev;
9129 prevOrder = tmpPrev;
9133 if(client && client.style.hidden) client = null;
9137 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9139 if(order && prevOrder && prevOrder.data != this)
9140 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9142 ActivateEx(false, false, false, true, null, null);
9144 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9145 if(parent.activeClient == this)
9147 parent.activeClient = null;
9148 parent.UpdateActiveDocument(null);
9151 else if(parent.activeClient == this)
9153 parent.activeClient = client;
9154 parent.UpdateActiveDocument(this);
9157 // *** Not doing this anymore ***
9160 parent.childrenCycle.Delete(cycle);
9162 parent.childrenOrder.Delete(order);
9167 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9172 else if(this && value && style.hidden)
9174 style.hidden = false;
9177 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9178 if(rootWindow == this)
9179 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9181 if(_isModal && master)
9182 master.modalSlave = this;
9184 if(style.isActiveClient)
9186 positionID = parent.GetPositionID(this);
9187 parent.numPositions++;
9188 if(state == minimized) parent.numIcons++;
9191 // *** NOT DOING THIS ANYMORE ***
9193 if(!(style.inactive))
9195 if(!(style.noCycle))
9197 cycle = parent.childrenCycle.AddAfter(
9198 (parent.activeChild && parent.activeChild.cycle) ?
9199 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9202 order = parent.childrenOrder.AddAfter(
9203 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9210 if(true || !parent.activeChild)
9211 ActivateEx(true, false, true, true, null, null);
9213 if(creationActivation == activate && guiApp.desktop.active)
9214 ActivateEx(true, false, true, true, null, null);
9215 else if((creationActivation == activate || creationActivation == flash) && !object)
9218 if(this == rootWindow)
9222 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9226 ConsequentialMouseMove(false);
9232 style.hidden = !value;
9235 get { return (style.hidden || !setVisible) ? false : true; }
9238 property bool isDocument
9240 property_category $"Document"
9241 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9242 get { return style.isDocument; }
9245 property bool mergeMenus
9247 property_category $"Window Style"
9248 set { mergeMenus = value; }
9249 get { return (bool)mergeMenus; }
9252 property bool hasHorzScroll
9254 property_category $"Window Style"
9259 if(!style.hasHorzScroll && created)
9261 CreateSystemChildren();
9262 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9265 else if(style.hasHorzScroll)
9269 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9271 style.hasHorzScroll = value;
9274 get { return style.hasHorzScroll; }
9277 property bool hasVertScroll
9279 property_category $"Window Style"
9284 if(!style.hasVertScroll && created)
9286 style.hasVertScroll = true;
9287 CreateSystemChildren();
9288 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9291 else if(style.hasVertScroll)
9295 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9297 style.hasVertScroll = value;
9299 get { return style.hasVertScroll; }
9302 property bool dontHideScroll
9304 property_category $"Behavior"
9307 scrollFlags.dontHide = value;
9310 //UpdateScrollBars(true, true);
9311 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9315 // UpdateScrollBars(true, true);
9316 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9319 get { return scrollFlags.dontHide; }
9322 property bool dontScrollVert
9324 property_category $"Behavior"
9325 set { style.dontScrollVert = value; }
9326 get { return style.dontScrollVert; }
9328 property bool dontScrollHorz
9330 property_category $"Behavior"
9331 set { style.dontScrollHorz = value; }
9332 get { return style.dontScrollHorz; }
9335 property bool snapVertScroll
9337 property_category $"Behavior"
9340 scrollFlags.snapY = value;
9341 if(sbv) sbv.snap = value;
9343 get { return scrollFlags.snapY; }
9345 property bool snapHorzScroll
9347 property_category $"Behavior"
9350 scrollFlags.snapX = value;
9351 if(sbh) sbh.snap = value;
9353 get { return scrollFlags.snapX; }
9356 property Point scroll
9358 property_category $"Behavior"
9359 set { if(this) SetScrollPosition(value.x, value.y); }
9360 get { value = scroll; }
9363 property bool modifyVirtualArea
9365 property_category $"Behavior"
9366 set { modifyVirtArea = value; }
9367 get { return (bool)modifyVirtArea; }
9370 property bool dontAutoScrollArea
9372 property_category $"Behavior"
9373 // Activating a child control out of view will automatically scroll to make it in view
9374 set { noAutoScrollArea = value; }
9375 get { return (bool)noAutoScrollArea; }
9378 property const char * fileName
9380 property_category $"Document"
9385 if(menu && ((!fileName && value) || (fileName && !value)))
9387 MenuItem item = menu.FindItem(MenuFileSave, 0);
9388 if(item) item.disabled = !modifiedDocument && value;
9393 if(value && value[0])
9394 fileName = CopyString(value);
9396 if(parent && this == parent.activeClient)
9397 parent.UpdateActiveDocument(null);
9401 // if(style.isDocument)
9402 #if !defined(__EMSCRIPTEN__)
9404 fileMonitor.fileName = value;
9407 get { return fileName; }
9412 property_category $"Data"
9417 property bool modifiedDocument
9419 property_category $"Document"
9422 if(style.isDocument || fileName)
9426 MenuItem item = menu.FindItem(MenuFileSave, 0);
9427 if(item) item.disabled = !value && fileName;
9431 if(modifiedDocument != value)
9433 modifiedDocument = value;
9434 if(style.isDocument || fileName)
9438 get { return (bool)modifiedDocument; }
9441 property bool showInTaskBar
9443 property_category $"Window Style"
9446 style.showInTaskBar = value;
9447 #if defined(__WIN32__)
9448 Win32UpdateStyle(this);
9451 get { return style.showInTaskBar; }
9453 property FileDialog saveDialog { set { saveDialog = value; } };
9454 property bool isActiveClient
9456 property_category $"Behavior"
9459 if(parent && style.isActiveClient != value && !style.hidden)
9463 if(state == minimized) parent.numIcons++;
9464 parent.numPositions++;
9468 if(state == minimized) parent.numIcons--;
9469 parent.numPositions--;
9472 style.isActiveClient = value;
9474 get { return style.isActiveClient; }
9477 property Cursor cursor
9479 property_category $"Appearance"
9483 SelectMouseCursor();
9485 get { return cursor; }
9488 //#if !defined(ECERE_VANILLA)
9489 property const char * name
9491 property_category $"Design"
9494 return (this && object) ? object.name : null;
9499 activeDesigner.RenameObject(object, value);
9503 property const char * displayDriver
9505 property_category $"Behavior"
9508 dispDriver = GetDisplayDriver(value);
9509 //DisplayModeChanged();
9513 return dispDriver ? dispDriver.name : null;
9517 // RUNTIME PROPERTIES
9518 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9519 property Size scrollArea
9521 property_category $"Behavior"
9525 SetScrollArea(value.w, value.h, false);
9527 SetScrollArea(0,0, true);
9529 get { value = scrollArea; }
9532 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9537 property_category $"Layout"
9538 set { if(this) is3D = value; }
9539 get { return (bool)is3D; }
9542 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9544 // Will be merged with font later
9545 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9546 property Point clientStart { get { value = clientStart; } };
9547 property Point absPosition { get { value = absPosition; } };
9548 property Anchor normalAnchor { get { value = normalAnchor; } };
9549 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9550 property bool active { get { return (bool)active; } };
9551 property bool created { get { return (bool)created; } };
9552 property bool destroyed { get { return (bool)destroyed; } };
9553 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9554 property Window firstChild { get { return children.first; } };
9555 property Window lastChild { get { return children.last; } };
9556 property Window activeClient { get { return activeClient; } };
9557 property Window activeChild { get { return activeChild; } };
9558 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9559 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9560 property ScrollBar horzScroll { get { return sbh; } };
9561 property ScrollBar vertScroll { get { return sbv; } };
9562 property StatusBar statusBar { get { return statusBar; } };
9563 property Window rootWindow { get { return rootWindow; } };
9564 property bool closing { get { return (bool)closing; } set { closing = value; } };
9565 property int documentID { get { return documentID; } };
9566 property Window previous { get { return prev; } }
9567 property Window next { get { return next; } }
9568 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9569 property PopupMenu menuBar { get { return menuBar; } }
9570 property ScrollBar sbv { get { return sbv; } }
9571 property ScrollBar sbh { get { return sbh; } }
9572 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9573 property void * systemHandle { get { return windowHandle; } }
9574 property Button minimizeButton { get { return sysButtons[0]; } };
9575 property Button maximizeButton { get { return sysButtons[1]; } };
9576 property Button closeButton { get { return sysButtons[2]; } };
9577 property BitmapResource icon
9579 get { return icon; }
9583 if(icon) incref icon;
9585 guiApp.interfaceDriver.SetIcon(this, value);
9588 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9589 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9590 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9591 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9592 property bool nativeDecorations
9594 get { return (bool)nativeDecorations; }
9595 set { nativeDecorations = value; }
9596 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9599 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9600 bool result = false;
9601 if(nativeDecorations)
9603 if(rootWindow == this)
9607 if(formDesigner && activeDesigner)
9609 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9610 Window form = cd ? cd.form : null;
9611 if(form && parent == form.parent)
9616 return result != style.fixed;
9620 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9622 property const char * text
9624 property_category $"Deprecated"
9626 set { property::caption = value; }
9627 get { return property::caption; }
9633 WindowBits style; // Window Style
9634 char * caption; // Name / Caption
9635 Window parent; // Parent window
9636 OldList children; // List of children in Z order
9637 Window activeChild; // Child window having focus
9638 Window activeClient;
9639 Window previousActive; // Child active prior to activating the default child
9640 Window master; // Window owning and receiving notifications concerning this window
9641 OldList slaves; // List of windows belonging to this window
9642 Display display; // Display this window is drawn into
9644 Point position; // Position in parent window client area
9645 Point absPosition; // Absolute position
9646 Point clientStart; // Client area position from (0,0) in this window
9648 Size clientSize; // Client area size
9649 Size scrollArea; // Virtual Scroll area size
9650 Size reqScrollArea; // Requested virtual area size
9651 Point scroll; // Virtual area scrolling position
9652 ScrollBar sbh, sbv; // Scrollbar window handles
9653 Cursor cursor; // Mouse cursor used for this window
9656 StatusBar statusBar;
9657 Button sysButtons[3];
9659 Box clientArea; // Client Area box clipped to parent
9661 HotKeySlot hotKey; // HotKey for this window
9665 ScrollFlags scrollFlags;// Window Scrollbar Flags
9666 int64 id; // Control ID
9668 ColorAlpha background; // Background color used to draw the window area
9670 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9671 OldList childrenCycle; // Cycling order
9672 OldLink cycle; // Element of parent's cycling order
9673 OldList childrenOrder; // Circular Z-Order
9674 OldLink order; // Element of parent's circular Z-Order
9675 Window modalSlave; // Slave window blocking this window's interaction
9677 Window rootWindow; // Topmost system managed window
9678 void * windowHandle; // System window handle
9680 DialogResult returnCode;// Return code for modal windows
9682 Point sbStep; // Scrollbar line scrolling steps
9685 SizeAnchor stateSizeAnchor;
9687 Anchor normalAnchor;
9688 SizeAnchor normalSizeAnchor;
9690 Size skinMinSize; // Minimal window size based on style
9691 Point scrolledPos; // Scrolled position
9692 Box box; // Window box clipped to parent
9693 Box * against; // What to clip the box to
9695 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9696 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9697 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9698 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9699 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9700 Point scrolledArea; // Distance to scroll area by
9701 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9703 OldList hotKeys; // List of the hotkeys of all children
9704 Window defaultControl; // Default child control
9708 ColorAlpha * palette; // Color palette used for this window
9710 int caretSize; // Size of caret, non zero if a caret is present
9711 Point caretPos; // Caret position
9713 void * systemParent; // Parent System Window for embedded windows
9719 #if !defined(__EMSCRIPTEN__)
9722 WindowState lastState;
9724 #if !defined(__EMSCRIPTEN__)
9725 FileMonitor fileMonitor;
9728 FontResource setFont, systemFont;
9729 FontResource usedFont;
9730 FontResource captionFont;
9732 FileDialog saveDialog;
9734 SizeAnchor sizeAnchor;
9736 // FormDesigner data
9739 Extent * tempExtents; //[4];
9740 BitmapResource icon;
9742 CreationActivationOption creationActivation;
9745 bool active:1; // true if window and ancestors are active
9746 bool acquiredInput:1; // true if the window is processing state based input
9747 bool modifiedDocument:1;
9748 bool disabled:1; // true if window cannot interact
9749 bool isForegroundWindow:1;// true while a root window is being activated
9750 bool visible:1; // Visibility flag
9751 bool destroyed:1; // true if window is being destroyed
9752 bool anchored:1; // true if this window is repositioned when the parent resizes
9753 bool dirty:1; // Flag set to true if any descendant must be redrawn
9759 bool modifyVirtArea:1;
9760 bool noAutoScrollArea:1;
9763 bool setVisible:1; // FOR FORM DESIGNER
9769 bool useSharedMemory:1;
9772 bool nativeDecorations:1;
9773 bool manageDisplay:1;
9774 bool formDesigner:1; // True if we this is running in the form editor
9775 bool requireRemaximize:1;
9778 // Checks used internally for them not to take effect in FormDesigner
9779 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9780 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9782 WindowController controller;
9783 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9786 public class CommonControl : Window
9788 // creationActivation = doNothing;
9791 public property const String toolTip
9793 property_category $"Appearance"
9796 if(created) CommonControl::OnDestroy();
9798 toolTip = value ? ToolTip { tip = value; } : null;
9800 if(created) CommonControl::OnCreate();
9802 get { return toolTip ? toolTip.tip : null; }
9808 // (Very) Ugly work around for the fact that the parent watcher
9809 // won't fire when it's already been disconnected...
9810 eInstance_FireSelfWatchers(toolTip,
9811 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9817 toolTip.parent = this;
9826 public class Percentage : float
9828 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9832 sprintf(string, "%.2f", this);
9833 c = strlen(string)-1;
9836 if(string[c] != '0')
9837 last = Max(last, c);
9838 if(string[c] == '.')
9851 public void ApplySkin(Class c, const char * name, void ** vTbl)
9853 char className[1024];
9858 subclass(Window) wc = (subclass(Window))c;
9859 subclass(Window) base = (subclass(Window))c.base;
9861 sprintf(className, "%sSkin_%s", name, c.name);
9862 wc.pureVTbl = c._vTbl;
9863 c._vTbl = new void *[c.vTblSize];
9864 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9865 sc = eSystem_FindClass(c.module.application, className);
9869 for(m = 0; m < c.base.vTblSize; m++)
9871 if(c._vTbl[m] == base.pureVTbl[m])
9872 c._vTbl[m] = vTbl[m];
9877 for(m = 0; m < c.vTblSize; m++)
9879 if(sc._vTbl[m] != wc.pureVTbl[m])
9880 c._vTbl[m] = sc._vTbl[m];
9884 for(d = c.derivatives.first; d; d = d.next)
9886 ApplySkin(d.data, name, c._vTbl);
9890 public void UnapplySkin(Class c)
9892 subclass(Window) wc = (subclass(Window))c;
9895 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9898 c._vTbl = wc.pureVTbl;
9902 for(d = c.derivatives.first; d; d = d.next)
9904 UnapplySkin(d.data);
9908 void CheckFontIntegrity(Window window)
9913 if(window.usedFont && window.usedFont.font == 0xecececec)
9915 FontResource uf = window.usedFont;
9916 char * className = window._class.name;
9917 char * text = window.text;
9920 for(c = window.firstChild; c; c = c.next)
9921 CheckFontIntegrity(c);
9925 public class ControllableWindow : Window
9927 /*WindowController controller;
9928 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9929 ~ControllableWindow() { delete controller; }*/
9932 class WindowControllerInterface : ControllableWindow
9934 bool OnKeyDown(Key key, unichar ch)
9936 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9939 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9941 result = onKeyDown(controller.window, key, ch);
9946 bool OnKeyUp(Key key, unichar ch)
9948 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
9951 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
9953 result = onKeyUp(controller.window, key, ch);
9958 bool OnKeyHit(Key key, unichar ch)
9960 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
9963 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
9965 result = onKeyHit(controller.window, key, ch);
9970 bool OnMouseMove(int x, int y, Modifiers mods)
9972 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9975 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
9977 result = onMouseMove(controller.window, x, y, mods);
9982 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9984 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
9987 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
9988 if(onLeftButtonDown)
9989 result = onLeftButtonDown(controller.window, x, y, mods);
9994 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9996 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
9999 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
10001 result = onLeftButtonUp(controller.window, x, y, mods);
10006 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
10008 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10011 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
10012 if(onLeftDoubleClick)
10013 result = onLeftDoubleClick(controller.window, x, y, mods);
10018 bool OnRightButtonDown(int x, int y, Modifiers mods)
10020 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10023 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
10024 if(onRightButtonDown)
10025 result = onRightButtonDown(controller.window, x, y, mods);
10030 bool OnRightButtonUp(int x, int y, Modifiers mods)
10032 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10035 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
10036 if(onRightButtonUp)
10037 result = onRightButtonUp(controller.window, x, y, mods);
10042 bool OnRightDoubleClick(int x, int y, Modifiers mods)
10044 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10047 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
10048 if(onRightDoubleClick)
10049 result = onRightDoubleClick(controller.window, x, y, mods);
10054 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10056 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10059 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10060 if(onMiddleButtonDown)
10061 result = onMiddleButtonDown(controller.window, x, y, mods);
10066 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10068 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10071 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10072 if(onMiddleButtonUp)
10073 result = onMiddleButtonUp(controller.window, x, y, mods);
10078 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10080 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10083 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10084 if(onMiddleDoubleClick)
10085 onMiddleDoubleClick(controller.window, x, y, mods);
10090 void OnResize(int width, int height)
10092 if(controller.OnResize)
10093 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10095 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10097 onResize(controller.window, width, height);
10101 void OnRedraw(Surface surface)
10103 if(controller.OnRedraw)
10104 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10106 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10108 onRedraw(controller.window, surface);
10114 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10117 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10119 result = onCreate(controller.window);
10124 bool OnLoadGraphics()
10126 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10129 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10131 result = onLoadGraphics(controller.window);
10136 void OnUnloadGraphics()
10138 if(controller.OnUnloadGraphics)
10139 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10141 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10142 if(onUnloadGraphics)
10143 onUnloadGraphics(controller.window);
10148 public class WindowController<class V>
10151 property Window window
10155 uint size = class(Window).vTblSize;
10158 windowVTbl = new void *[size];
10159 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10160 if(value._vTbl == value._class._vTbl)
10162 value._vTbl = new void *[value._class.vTblSize];
10163 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10167 for(c = 0; c < size; c++)
10169 void * function = class(WindowControllerInterface)._vTbl[c];
10170 if(function && function != DefaultFunction)
10171 value._vTbl[c] = function;
10173 value._vTbl[c] = windowVTbl[c];
10178 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10181 get { return window; }
10183 property V controlled
10185 set { controlled = value; }
10186 get { return controlled; }
10188 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10189 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10190 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10191 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10192 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10193 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10194 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10195 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10196 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10197 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10198 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10199 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10200 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10201 virtual void V::OnResize(WindowController controller, int width, int height);
10202 virtual void V::OnRedraw(WindowController controller, Surface surface);
10203 virtual bool V::OnCreate(WindowController controller);
10204 virtual bool V::OnLoadGraphics(WindowController controller);
10205 virtual void V::OnUnloadGraphics(WindowController controller);
10208 int (** windowVTbl)();
10212 ~WindowController()