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 !defined(__EMSCRIPTEN__)
828 if(!guiApp.fullScreenMode || is3D)
831 x -= rootWindow.absPosition.x;
832 y -= rootWindow.absPosition.y;
835 int dx = rootWindow.parent.parent.clientStart.x;
836 int dy = rootWindow.parent.parent.clientStart.y;
837 if(!rootWindow.parent.nativeDecorations)
839 dx += rootWindow.parent.clientStart.x;
840 dy += rootWindow.parent.clientStart.y;
854 surface = display.GetSurface(x, y, mox);
857 surface.width = size.w;
858 surface.height = size.h;
864 void FigureCaption(char * caption)
866 Window activeClient = null;
870 strcpy(caption, this.caption);
871 if(style.isDocument || fileName)
873 if(caption[0]) strcat(caption, " - ");
875 strcat(caption, fileName);
879 sprintf(title, "Untitled %d", documentID);
880 strcat(caption, title);
883 strcat(caption, " *");
888 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
890 if(activeClient && activeClient.state == maximized)
892 if(activeClient.caption)
894 if(caption[0]) strcat(caption, " - ");
895 strcat(caption, activeClient.caption);
897 if(activeClient.style.isDocument || activeClient.fileName)
899 if(caption[0]) strcat(caption, " - ");
900 strcat(caption, "[");
901 if(activeClient.fileName)
902 strcat(caption, activeClient.fileName);
906 sprintf(title, "Untitled %d", activeClient.documentID);
907 strcat(caption, title);
909 if(activeClient.modifiedDocument)
910 strcat(caption, " *");
911 strcat(caption, "]");
916 // Code for returning dirty from ScrollDisplay:
918 for(d = 0; d<scrollExtent.count; d++)
920 Box * box = &scrollExtent.boxes[d];
926 Min(box.right, box.left-scroll.x),box.bottom
928 dirtyArea.UnionBox(update);
934 Max(box.left, box.right-scroll.x), box.top,
935 box.right, box.bottom
937 dirtyArea.UnionBox(update);
945 box.right, Min(box.bottom, box.top-scroll.y),
947 dirtyArea.UnionBox(update);
953 box.left, Max(box.top, box.bottom-scroll.y),
954 box.right, box.bottom
956 dirtyArea.UnionBox(update);
961 void UpdateDecorations(void)
963 // TODO: *** TEMPORARY HACK ***
970 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
972 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
974 Update({ -clientStart.x,0, -1, clientSize.h-1 });
976 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
979 // Returns w & h for Position
980 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
982 Window parent = this.parent ? this.parent : guiApp.desktop;
983 int xOffset = 0, yOffset = 0;
984 int vpw = parent ? parent.clientSize.w : 0;
985 int vph = parent ? parent.clientSize.h : 0;
986 int pw = parent ? parent.clientSize.w : 0;
987 int ph = parent ? parent.clientSize.h : 0;
988 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
989 int x = anchor.left.distance, y = anchor.top.distance;
990 float ex = 0, ey = 0;
991 MinMaxValue ew = 0, eh = 0;
993 float cascadeW, cascadeH;
995 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
996 int addX = 0, addY = 0;
998 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
1000 Window masterWindow = this;
1001 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
1004 if(master == guiApp.desktop)
1005 masterWindow = guiApp.desktop.activeChild;
1007 masterWindow = master.rootWindow;
1008 if(!masterWindow) masterWindow = this;
1010 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
1011 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
1014 pw = vpw = box.right - box.left + 1;
1016 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
1019 ph = vph = box.bottom - box.top + 1;
1035 vpw = pw = parent.size.w;
1036 vph = ph = parent.size.h;
1038 else if(!style.fixed /*|| style.isDocument*/)
1040 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1041 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1043 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1046 Desktop3D_FixSize(&pw, &ph);
1047 Desktop3D_FixSize(&vpw, &vph);
1050 if(pw < skinMinSize.w) pw = skinMinSize.w;
1051 if(ph < skinMinSize.h) ph = skinMinSize.h;
1052 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1053 if(vph < skinMinSize.h) vph = skinMinSize.h;
1055 // TODO: Must fix what we're snapping
1058 if(anchor.left.type)
1060 SNAPUP(x, textCellW);
1062 else if(anchor.right.type)
1064 SNAPDOWN(x, textCellW);
1069 SNAPUP(y, textCellH);
1071 else if(anchor.bottom.type)
1073 SNAPDOWN(y, textCellH);
1077 // This is required to get proper initial decoration size using native decorations on Windows
1078 #if defined(__WIN32__)
1079 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1080 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1082 GetDecorationsSize(&ew, &eh);
1084 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1086 // Leave room for non client windows (eventually dockable panels)
1088 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1089 for(win = parent.children.first; win; win = win.next)
1091 if(!win.nonClient && !win.isActiveClient && win.visible)
1093 Size size = win.size;
1094 Point pos = win.position;
1095 int left = pos.x, top = pos.y;
1096 int right = pos.x + size.w, bottom = pos.y + size.h;
1097 if(win.size.w > win.size.h)
1100 loY = Max(loY, bottom);
1101 else if(top > ph - ph / 4)
1102 hiY = Min(hiY, top);
1107 loX = Max(loX, right);
1108 else if(left > pw - pw / 4)
1109 hiX = Min(hiX, left);
1118 if(parent.sbv && !parent.sbv.style.hidden)
1119 pw += guiApp.currentSkin.VerticalSBW();
1120 if(parent.sbh && !parent.sbh.style.hidden)
1121 ph += guiApp.currentSkin.HorizontalSBH();
1123 if(anchor.left.type == cascade)
1125 w = (int)(pw * 0.80);
1126 h = (int)(ph * 0.80);
1128 else if(anchor.left.type >= vTiled)
1133 numTiling = parent.numPositions - parent.numIcons;
1134 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1135 if(anchor.left.type == vTiled)
1137 tilingH = (int)sqrt(numTiling);
1138 tilingW = numTiling / tilingH;
1142 tilingW = (int)sqrt(numTiling);
1143 tilingH = numTiling / tilingW;
1146 leftOver = numTiling - tilingH * tilingW;
1149 tilingSplit = (tilingW - leftOver) * tilingH;
1150 tilingLastH = tilingH+1;
1153 tilingSplit = numTiling;
1155 if(positionID >= tilingSplit)
1157 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1158 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1159 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1160 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1164 x = xOffset + pw * (positionID / tilingH) / tilingW;
1165 y = yOffset + ph * (positionID % tilingH) / tilingH;
1166 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1167 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1171 SNAPDOWN(x, textCellW);
1172 SNAPDOWN(y, textCellH);
1173 SNAPDOWN(x2, textCellW);
1174 SNAPDOWN(y2, textCellH);
1182 if(sizeAnchor.isClientW) w += ew;
1183 if(sizeAnchor.isClientH) h += eh;
1185 if(anchor.left.type == offset)
1186 x = anchor.left.distance;
1187 else if(anchor.left.type == relative)
1188 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1189 else if(anchor.right.type == relative)
1190 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1191 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1192 else if(anchor.right.type == offset)
1193 ex = vpw - anchor.right.distance;
1195 if(anchor.top.type == offset)
1196 y = anchor.top.distance;
1197 else if(anchor.top.type == relative)
1198 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1199 else if(anchor.bottom.type == relative)
1200 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1201 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1202 else if(anchor.bottom.type == offset)
1203 ey = vph - anchor.bottom.distance;
1205 if(anchor.left.type && anchor.right.type)
1207 switch(anchor.right.type)
1210 ex = pw * (1.0f-anchor.right.percent);
1211 w = Max((int)(ex + 0.5) - x, 0);
1214 ex = vpw - anchor.right.distance;
1215 w = Max((int)(ex + 0.5) - x, 0);
1219 if(anchor.top.type && anchor.bottom.type)
1221 switch(anchor.bottom.type)
1224 ey = ph * (1.0f-anchor.bottom.percent);
1225 h = Max((int)(ey + 0.5) - y, 0);
1228 ey = vph - anchor.bottom.distance;
1229 h = Max((int)(ey + 0.5) - y, 0);
1238 if(state == normal /*|| state == Hidden*/)
1240 bool addSbV = false, addSbH = false;
1242 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1243 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1245 w = Max(w, minSize.w);
1246 h = Max(h, minSize.h);
1247 w = Min(w, maxSize.w);
1248 h = Min(h, maxSize.h);
1250 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1252 if(w) w -= guiApp.currentSkin.VerticalSBW();
1255 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1257 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1261 if(!OnResizing(&w, &h))
1267 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1268 w += guiApp.currentSkin.VerticalSBW();
1269 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1270 h += guiApp.currentSkin.HorizontalSBH();
1272 w = Max(w, skinMinSize.w);
1273 h = Max(h, skinMinSize.h);
1286 SNAPDOWN(w, textCellW);
1287 SNAPDOWN(h, textCellH);
1290 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1292 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1295 (pw - w) / CASCADE_SPACE,
1296 (ph - h) / CASCADE_SPACE);
1302 cascW = (pw - w) / (numCascade-1);
1303 cascH = (ph - h) / (numCascade-1);
1304 SNAPDOWN(cascW, textCellW);
1305 SNAPDOWN(cascH, textCellH);
1306 cascadeW = (float)cascW;
1307 cascadeH = (float)cascH;
1311 numCascade = Max(numCascade, 2);
1312 cascadeW = (float)(pw - w) / (numCascade-1);
1313 cascadeH = (float)(ph - h) / (numCascade-1);
1316 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1317 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1319 else if(anchor.left.type < vTiled)
1321 if(!anchor.left.type || anchor.horz.type == middleRelative)
1323 if(!anchor.right.type)
1325 if(anchor.horz.type == middleRelative)
1326 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1328 x = vpw / 2 + anchor.horz.distance - w / 2;
1334 // case A_EDGE: x = x - w; break;
1336 if(!anchor.top.type || anchor.vert.type == middleRelative)
1338 if(!anchor.bottom.type)
1340 if(anchor.vert.type == middleRelative)
1341 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1343 y = vph / 2 + anchor.vert.distance - h / 2;
1349 // case A_EDGE: y = y - h; break;
1352 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1360 SNAPDOWN(x, textCellW);
1361 SNAPDOWN(y, textCellH);
1373 if(anchored && style.fixed && style.isActiveClient)
1378 void UpdateCaret(bool forceUpdate, bool erase)
1380 static Window lastWindow = null;
1381 static int caretX, caretY, caretSize;
1383 if(guiApp && guiApp.caretOwner == this)
1385 int x = caretPos.x - scroll.x;
1386 int y = caretPos.y - scroll.y;
1388 if((erase || this.caretSize) &&
1389 x >= clientArea.left && x <= clientArea.right &&
1390 y >= clientArea.top && y <= clientArea.bottom)
1394 guiApp.interfaceDriver.SetCaret(
1395 x + absPosition.x + clientStart.x,
1396 y + absPosition.y + clientStart.y, this.caretSize);
1397 guiApp.caretEnabled = true;
1399 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1403 if(lastWindow != this)
1405 updateBox.left = x + 1;
1407 updateBox.right = x + 2;
1408 updateBox.bottom = y + this.caretSize - 1;
1412 updateBox.left = Min(x + 1, caretX + 1);
1413 updateBox.top = Min(y, caretY);
1414 updateBox.right = Max(x + 2, caretX + 2);
1415 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1418 guiApp.caretOwner.Update(updateBox);
1425 caretSize = this.caretSize;
1431 guiApp.interfaceDriver.SetCaret(0,0,0);
1432 guiApp.caretEnabled = false;
1438 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1443 scrolledPos.x = position.x = x;
1444 scrolledPos.y = position.y = y;
1446 clientSize.w = size.w = w;
1447 clientSize.h = size.h = h;
1449 if(parent && !style.nonClient)
1451 //if(!style.fixed || style.isDocument)
1453 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1454 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1458 clientStart.x = clientStart.y = 0;
1460 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1462 //if(!activeClient || activeClient.state != maximized)
1463 if(!noAutoScrollArea)
1465 // Check if scroll area must be modified
1466 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1468 bool foundChild = false;
1470 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1471 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1472 for(child = children.first; child; child = child.next)
1474 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1475 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1477 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1478 w = Max(w, child.position.x + child.size.w);
1479 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1480 w = Max(w, Max(child.position.x, 0) + child.size.w);
1481 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1482 h = Max(h, child.position.y + child.size.h);
1483 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1484 h = Max(h, Max(child.position.y, 0) + child.size.h);
1489 if(foundChild && (w > cw || h > ch))
1491 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1493 int stepX = sbStep.x, stepY = sbStep.y;
1494 // Needed to make snapped down position match the skin's check of client area
1495 // against realvirtual
1498 SNAPDOWN(stepX, textCellW);
1499 SNAPDOWN(stepY, textCellH);
1500 stepX = Max(stepX, textCellW);
1501 stepY = Max(stepY, textCellH);
1503 if(scrollFlags.snapX)
1505 if(scrollFlags.snapY)
1508 reqScrollArea.w = w;
1509 reqScrollArea.h = h;
1512 else if(reqScrollArea.w || reqScrollArea.h)
1514 reqScrollArea.w = 0;
1515 reqScrollArea.h = 0;
1516 SetScrollPosition(0,0);
1521 // Automatic MDI Client Scrolling Area Adjustment
1522 if(parent && !parent.noAutoScrollArea)
1524 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1525 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1527 Window parent = this.parent;
1528 int w = parent.reqScrollArea.w;
1529 int h = parent.reqScrollArea.h;
1531 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1532 w = Max(w, position.x + size.w);
1533 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1534 w = Max(w, Max(position.x, 0) + size.w);
1535 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1536 h = Max(h, position.y + size.h);
1537 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1538 h = Max(h, Max(position.y, 0) + size.h);
1540 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1541 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1543 /*bool resize = false;
1544 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1545 // Needed to make snapped down position match the skin's check of client area
1546 // against realvirtual
1549 SNAPDOWN(stepX, textCellW);
1550 SNAPDOWN(stepY, textCellH);
1551 stepX = Max(stepX, textCellW);
1552 stepY = Max(stepY, textCellH);
1554 if(parent.scrollFlags.snapX)
1556 if(parent.scrollFlags.snapY)
1558 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1560 parent.reqScrollArea.w = w;
1561 parent.reqScrollArea.h = h;*/
1563 // parent.UpdateScrollBars(true, true);
1564 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1565 false, true, true, true, false, false);
1570 GetRidOfVirtualArea();
1574 UpdateScrollBars(modifyThisArea, false);
1575 else if(guiApp.currentSkin)
1578 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1580 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1581 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1582 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1583 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1586 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1587 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1589 absPosition = scrolledPos;
1590 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1591 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1593 if(this != guiApp.desktop && parent)
1595 absPosition.x += parent.absPosition.x;
1596 absPosition.y += parent.absPosition.y;
1597 if(!style.nonClient && this != guiApp.desktop)
1599 absPosition.x += parent.clientStart.x;
1600 absPosition.y += parent.clientStart.y;
1604 box = Box { 0, 0, size.w - 1, size.h - 1 };
1609 // Clip against parent's client area
1610 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1612 // Compute client area in this window coordinate system
1613 clientArea.left = 0;
1615 clientArea.right = clientSize.w - 1;
1616 clientArea.bottom = clientSize.h - 1;
1618 // Clip against parent's client area
1620 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1624 //absPosition.x -= parent.clientStart.x;
1625 //absPosition.y -= parent.clientStart.y;
1628 // Adjust all children
1629 for(child = children.first; child; child = child.next)
1630 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1632 UpdateCaret(false, false);
1635 void GetRidOfVirtualArea(void)
1637 if(parent && !parent.destroyed && style.fixed &&
1638 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1639 parent.reqScrollArea.w && parent.reqScrollArea.h)
1641 if(!parent.noAutoScrollArea)
1643 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1647 for(child = children.first; child; child = child.next)
1649 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1651 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1652 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1662 Window parent = this.parent;
1664 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1665 false, true, true, true, false, false);
1667 parent.SetScrollArea(0,0,true);
1668 parent.SetScrollPosition(0,0);
1674 public void ExternalPosition(int x, int y, int w, int h)
1676 Position(x, y, w, h, false, true, true, true, false, false);
1677 /* TO REVIEW: Redj's code trying to fix position saving
1682 normalAnchor = Anchor { left = x, top = y };
1683 normalSizeAnchor = SizeAnchor { { w, h } };
1690 // (w, h): Full window size
1691 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1693 bool result = false;
1694 int oldCW = clientSize.w, oldCH = clientSize.h;
1695 bool clientResized, windowResized, windowMoved;
1697 //bool realResized = size.w != w || size.h != h;
1699 // TOCHECK: This wasn't in ecere.dll
1700 //if(!parent) return true;
1701 if(destroyed) return false;
1703 windowMoved = position.x != x || position.y != y || force;
1705 // windowResized = realResized || force;
1706 windowResized = size.w != w || size.h != h || force;
1708 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1714 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1715 scrolledPos.x - parent.clientStart.x + this.box.right,
1716 scrolledPos.y - parent.clientStart.y + this.box.bottom
1722 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1727 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1729 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1730 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1731 windowResized = true;
1733 if(display && rootWindow != this)
1736 if(guiApp && guiApp.windowMoving)
1738 if(guiApp.windowMoving.style.nonClient)
1739 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1741 guiApp.windowMoving.parent.SetMouseRangeToClient();
1751 // Buttons bitmap resources crash if we do this while switching mode
1752 if(!guiApp || !guiApp.modeSwitching)
1755 // Process Anchored Children
1759 for(child = children.first; child; child = child.next)
1762 ((child.stateAnchor.left.type != offset ||
1763 child.stateAnchor.top.type != offset ||
1764 child.stateAnchor.right.type != none ||
1765 child.stateAnchor.bottom.type != none) ||
1766 child.state == maximized || child.state == minimized))
1768 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1770 // child.Position(x, y, w, h, false, true, true, true, false);
1771 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1772 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1778 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1779 //if(updateScrollBars)
1781 OnResize(clientSize.w, clientSize.h);
1783 if((clientResized || windowMoved) && created)
1784 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1786 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1788 Window master = guiApp.interimWindow.master;
1789 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1792 if(rootWindow == this && !is3D)
1796 x -= guiApp.desktop.absPosition.x;
1797 y -= guiApp.desktop.absPosition.y;
1799 //guiApp.Log("Position %s\n", caption);
1802 if(windowResized || windowMoved)
1803 if(display && !display.flags.memBackBuffer && changeRootWindow)
1804 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1807 #if !defined(__EMSCRIPTEN__)
1808 !guiApp.fullScreenMode &&
1810 this != guiApp.desktop && (windowResized || windowMoved))
1811 for(child = parent.children.first; child && child != this; child = child.next)
1812 if(child.rootWindow)
1813 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1818 if(windowMoved || windowResized)
1820 display.Lock(true /*false*/);
1823 display.Position(absPosition.x, absPosition.y);
1824 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1827 // result = realResized ? display.Resize(size.w, size.h) : true;
1828 if(nativeDecorations && rootWindow.windowHandle)
1830 int w = clientSize.w, h = clientSize.h;
1831 if(hasMenuBar) h += skinMenuHeight;
1832 if(hasStatusBar) h += statusBarHeight;
1833 if(sbv && sbv.visible) w += sbv.size.w;
1834 if(sbh && sbh.visible) h += sbh.size.h;
1835 result = manageDisplay ? display.Resize(w, h) : true;
1838 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1842 else if(clientResized)
1844 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1847 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1851 if(windowMoved || windowResized)
1856 if(guiApp.driver && changeRootWindow && windowHandle)
1858 if(windowResized || windowMoved)
1859 if(!display || display.flags.memBackBuffer)
1860 guiApp.interfaceDriver.PositionRootWindow(this,
1861 x, y, w, h, windowMoved, windowResized);
1862 guiApp.interfaceDriver.UpdateRootWindow(this);
1864 for(child = children.first; child; child = child.next)
1866 if(child.is3D && child.created)
1868 // Copy Display Content
1869 child.display.displaySystem = display.displaySystem;
1870 child.display.window = display.window;
1871 child.display.current = display.current;
1872 child.display.width = display.width;
1873 child.display.height = display.height;
1874 child.display.driverData = display.driverData;
1875 #if !defined(__EMSCRIPTEN__)
1876 child.display.mutex = null;
1888 void UpdateScrollBars(bool flag, bool fullThing)
1891 bool resizeH = false, resizeV = false;
1892 bool scrolled = false;
1893 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1894 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1896 if(destroyed) return;
1897 if(guiApp.currentSkin)
1899 MinMaxValue cw = 0, ch = 0;
1900 bool sbvVisible, sbhVisible;
1901 int rangeH = 0, rangeV = 0;
1902 int positionH = 0, positionV;
1904 // First get client area with no respect to scroll bars
1909 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1911 if(scrollFlags.dontHide)
1914 cw -= guiApp.currentSkin.VerticalSBW();
1916 ch -= guiApp.currentSkin.HorizontalSBH();
1918 // Update the scrollbar visibility
1924 sbh.disabled = rangeH <= 1;
1925 if(sbh.style.hidden)
1935 sbv.disabled = rangeV <= 1;
1936 if(sbv.style.hidden)
1944 int oldHRange = sbh ? sbh.range : 0;
1945 int oldVRange = sbv ? sbv.range : 0;
1946 // Then start off with horizontal scrollbar range
1949 positionH = sbh.thumbPosition;
1956 SBSetTotal(sbh, rvw);
1959 ch -= guiApp.currentSkin.HorizontalSBH();
1962 // Do the same for vertical scrollbar
1965 positionV = sbv.thumbPosition;
1971 SBSetTotal(sbv, rvh);
1975 cw -= guiApp.currentSkin.VerticalSBW();
1976 // Maybe we need to set the range on the horizontal scrollbar again
1984 SBSetTotal(sbh, rvw);
1985 //sbh.Action(setRange, positionH, 0);
1986 if(rangeH <= 1 && sbh.range > 1)
1988 ch -= guiApp.currentSkin.HorizontalSBH();
1994 SBSetTotal(sbv, rvh);
1996 //sbv.Action(setRange, positionV, 0);
2001 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
2002 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
2005 // Update the scrollbar visibility
2006 if(!scrollFlags.dontHide)
2008 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
2012 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2019 if(guiApp.currentSkin)
2026 sbhVisible = sbh.style.hidden ? true : false;
2028 sbvVisible = sbv.style.hidden ? true : false;
2030 // Do our resize here
2031 if(flag && (resizeH || resizeV) && fullThing)
2033 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2038 OnResize(clientSize.w, clientSize.h);
2044 sbh.visible = sbhVisible;
2046 sbv.visible = sbvVisible;
2048 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2049 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2052 sbh.pageStep = clientSize.w;
2054 sbv.pageStep = clientSize.h;
2056 // Notify doesn't handle setRange anymore... process it here
2059 int positionH = sbh.thumbPosition;
2060 if(scroll.x != positionH)
2062 OnHScroll(setRange, positionH, 0);
2066 SNAPDOWN(positionH, textCellW);
2067 scroll.x = positionH;
2073 int seen = clientSize.w, total = reqScrollArea.w;
2076 if(scrollFlags.snapX)
2077 SNAPDOWN(seen, sbStep.x);
2079 if(!total) total = seen;
2080 range = total - seen + 1;
2082 range = Max(range, 1);
2084 if(x >= range) x = range - 1;
2086 if(scrollFlags.snapX)
2087 SNAPUP(x, sbStep.x);
2091 OnHScroll(setRange, x, 0);
2096 SNAPDOWN(x, textCellW);
2102 int positionV = sbv.thumbPosition;
2103 if(scroll.y != positionV)
2105 OnVScroll(setRange, positionV, 0);
2109 SNAPDOWN(positionV, textCellH);
2110 scroll.y = positionV;
2116 int seen = clientSize.h, total = reqScrollArea.h;
2119 if(scrollFlags.snapY)
2120 SNAPDOWN(seen, sbStep.y);
2122 if(!total) total = seen;
2123 range = total - seen + 1;
2124 range = Max(range, 1);
2126 if(y >= range) y = range - 1;
2128 if(scrollFlags.snapY)
2129 SNAPUP(y, sbStep.y);
2133 OnVScroll(setRange, y, 0);
2138 SNAPDOWN(y, textCellH);
2144 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2147 for(child = children.first; child; child = child.next)
2149 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2152 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2153 child.Position(x, y, w, h, false, true, false, true, false, false);
2160 // Process Scrollbars
2162 if(sbh) // && !sbh.style.hidden
2165 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2166 // Need to set the range again (should improve...) since the scrollbars didn't have
2167 // the right size when UpdateScrollArea set the range on it
2170 sbh.seen = clientSize.w;
2174 if(sbv) // && !sbv.state.hidden
2177 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2178 // Need to set the range again (should improve...) since the scrollbars didn't have
2179 // the right size when UpdateScrollArea set the range on it
2182 sbv.seen = clientSize.h;
2187 // TESTING THIS LOWER
2188 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2191 for(child = children.first; child; child = child.next)
2193 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2196 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2197 child.Position(x, y, w, h, false, true, false, true, false, false);
2203 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2205 SetState(maximized, false, mods);
2209 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2211 SetState(normal, false, mods);
2215 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2217 SetState(minimized, false, mods);
2218 parent.CycleChildren(false, true, false, true);
2222 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2225 // Scroll bar notifications
2226 if(action != setRange)
2228 bool changed = false;
2232 if(scroll.x != position)
2234 OnHScroll(action, position, keyFlags);
2239 SNAPDOWN(position, textCellW);
2241 scroll.x = position;
2245 if(scroll.y != position)
2247 OnVScroll(action, position, keyFlags);
2252 SNAPDOWN(position, textCellH);
2254 scroll.y = position;
2258 bool childMove = false;
2259 for(child = children.first; child; child = child.next)
2261 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2264 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2265 child.Position(x, y, w, h, false, true, false, true, false, false);
2269 // Testing this patch out to solve MDI workspace redraw bugs
2270 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2271 // Scroll offsets to blame?
2275 UpdateCaret(false, false);
2279 // Testing this patch out to solve MDI workspace redraw bugs
2280 for(child = children.first; child; child = child.next)
2282 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2291 Window GetParentMenuBar()
2293 Window menuBarParent;
2294 if(formDesigner) return null;
2295 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2297 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2298 if(menuBarParent && !menuBarParent.isActiveClient)
2304 void CreateSystemChildren(void)
2306 Window parent = this;
2307 bool scrollBarChanged = false;
2308 bool hasClose = false, hasMaxMin = false;
2309 Point scroll = this.scroll;
2311 if(state == maximized)
2313 parent = GetParentMenuBar();
2320 if(style.hasClose) hasClose = true;
2321 if(style.hasMaximize || style.hasMinimize)
2328 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2330 sysButtons[2].Destroy(0);
2331 sysButtons[2] = null;
2333 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2335 sysButtons[1].Destroy(0);
2336 sysButtons[1] = null;
2338 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2340 sysButtons[0].Destroy(0);
2341 sysButtons[0] = null;
2344 if(hasClose && parent)
2351 parent, master = this,
2352 inactive = true, nonClient = true, visible = false;
2354 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2360 if(this.parent == guiApp.desktop)
2361 sysButtons[2].hotKey = altF4;
2362 else if(style.isActiveClient)
2363 sysButtons[2].hotKey = ctrlF4;
2364 sysButtons[2].Create();
2367 sysButtons[2].symbol = 'X';
2368 sysButtons[2].disabled = !style.hasClose;
2371 if(hasMaxMin && parent)
2375 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2376 if(state == maximized)
2379 method = RestoreButtonClicked;
2385 method = MaximizeButtonClicked;
2393 parent, master = this,
2394 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2396 sysButtons[1].Create();
2398 sysButtons[1].NotifyClicked = method;
2400 sysButtons[1].symbol = symbol;
2401 sysButtons[1].disabled = !style.hasMaximize;
2404 if(hasMaxMin && parent)
2408 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2409 if (state == minimized)
2412 method = RestoreButtonClicked;
2418 method = MinimizeButtonClicked;
2426 parent, master = this,
2427 hotKey = altM, inactive = true, nonClient = true, visible = false
2429 sysButtons[0].Create();
2431 sysButtons[0].NotifyClicked = method;
2433 sysButtons[0].symbol = symbol;
2434 sysButtons[0].disabled = !style.hasMinimize;
2437 // Create the scrollbars
2438 if(style.hasHorzScroll && !sbh)
2444 direction = horizontal,
2448 snap = scrollFlags.snapX,
2449 NotifyScrolling = ScrollBarNotification
2452 scrollBarChanged = true;
2454 else if(sbh && !style.hasHorzScroll)
2460 if(style.hasVertScroll && !sbv)
2466 direction = vertical,
2470 snap = scrollFlags.snapY,
2471 NotifyScrolling = ScrollBarNotification
2474 scrollBarChanged = true;
2476 else if(sbv && !style.hasVertScroll)
2481 if(scrollBarChanged)
2483 SetScrollLineStep(sbStep.x, sbStep.y);
2484 UpdateScrollBars(true, true);
2488 if(scrollBarChanged)
2490 if(sbh) sbh.thumbPosition = scroll.x;
2491 if(sbv) sbv.thumbPosition = scroll.y;
2495 void UpdateCaption(void)
2497 if(rootWindow == this)
2500 FigureCaption(caption);
2501 if(guiApp.interfaceDriver)
2502 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2504 UpdateDecorations();
2507 if(parent.activeClient == this) // Added this last check
2509 if(parent.rootWindow == parent)
2512 parent.FigureCaption(caption);
2513 if(guiApp.interfaceDriver)
2514 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2517 parent.UpdateCaption();
2519 parent.UpdateDecorations();
2523 void UpdateActiveDocument(Window previous)
2525 Window activeClient = this.activeClient;
2526 Window activeChild = this.activeChild;
2533 activeClient.CreateSystemChildren();
2535 previous.CreateSystemChildren();
2547 // Build window list
2550 Menu windowMenu = menu.FindMenu("Window");
2555 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2557 Window document = cycle.data;
2558 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2560 char name[2048], caption[2048];
2561 document.FigureCaption(caption);
2562 sprintf(name, "%d %s", id+1, caption);
2563 windowMenu.AddDynamic(MenuItem
2565 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2566 NotifySelect = MenuWindowSelectWindow
2570 if(activeClient.cycle == cycle) break;
2575 if((!previous && activeClient) || !activeClient)
2581 item = menu.FindItem(MenuWindowCloseAll, 0);
2582 if(item) item.disabled = false;
2583 item = menu.FindItem(MenuWindowNext, 0);
2584 if(item) item.disabled = false;
2585 item = menu.FindItem(MenuWindowPrevious, 0);
2586 if(item) item.disabled = false;
2587 item = menu.FindItem(MenuWindowCascade, 0);
2588 if(item) item.disabled = false;
2589 item = menu.FindItem(MenuWindowTileHorz, 0);
2590 if(item) item.disabled = false;
2591 item = menu.FindItem(MenuWindowTileVert, 0);
2592 if(item) item.disabled = false;
2593 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2594 if(item) item.disabled = false;
2595 item = menu.FindItem(MenuWindowWindows, 0);
2596 if(item) item.disabled = false;
2599 item = menu.FindItem(MenuFileClose, 0);
2600 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2601 item = menu.FindItem(MenuFileSaveAll, 0);
2602 if(item) item.disabled = numDocuments < 1;
2604 if(activeClient && activeClient.menu && activeClient.state != minimized)
2608 //activeClient.menu.Clean(activeClient);
2609 menu.Merge(activeClient.menu, true, activeClient);
2613 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2616 menu.Merge(activeChild.menu, true, activeChild);
2619 // This is called again for a child window change, with same active client
2620 OnActivateClient(activeClient, previous);
2621 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2622 parent.UpdateActiveDocument(null);
2625 void _ShowDecorations(Box box, bool post)
2627 if(rootWindow == this && nativeDecorations && !is3D) return;
2628 if(visible && this != guiApp.desktop)
2630 Surface surface = RedrawFull(box);
2634 FigureCaption(caption);
2637 ShowDecorations(captionFont.font,
2640 active, //parent.activeClient == this
2641 guiApp.windowMoving == this);
2643 PreShowDecorations(captionFont.font,
2646 active, //parent.activeClient == this
2647 guiApp.windowMoving == this);
2654 void UpdateExtent(Box refresh)
2656 Surface surface = null;
2658 if(!manageDisplay) { OnRedraw(null);return; }
2659 _ShowDecorations(refresh, false);
2661 surface = Redraw(refresh);
2662 // Opaque background: just fill before EW_REDRAW (clear?)
2665 surface.SetBackground(background);
2666 surface.SetForeground(foreground);
2667 surface.DrawingChar(' ');
2668 if(this == rootWindow)
2670 if(style.drawBehind || background.a)
2672 int a = background.a;
2673 // Premultiply alpha for clear color
2674 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2675 surface.Clear(colorBuffer);
2676 surface.SetBackground(background);
2679 else if(background.a)
2683 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2684 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2687 if(display.flags.alpha && background.a < 255 && background)
2689 surface.Area(0,0,clientSize.w, clientSize.h);
2690 /*if(style.clearDepthBuffer)
2691 surface.Clear(depthBuffer);*/
2693 else if(/*style.clearDepthBuffer || */background.a)
2695 int a = background.a;
2696 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2697 // Premultiply alpha for clear color
2698 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2699 surface.Clear(colorBuffer);
2700 surface.SetBackground(background);
2705 surface.TextFont(usedFont.font);
2706 surface.TextOpacity(false);
2710 // Draw the caret ...
2711 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2713 // surface.SetBackground(0xFFFFFF - background.color);
2714 surface.SetBackground(~background.color);
2716 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2717 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2723 void DrawOverChildren(Box refresh)
2725 Surface surface = Redraw(refresh);
2729 surface.DrawingChar(' ');
2730 surface.SetBackground(background);
2731 surface.SetForeground(foreground);
2733 surface.TextFont(usedFont.font);
2734 surface.TextOpacity(false);
2736 OnDrawOverChildren(surface);
2741 _ShowDecorations(refresh, true);
2744 void ComputeClipExtents(void)
2747 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2749 clipExtent.Copy(this.clipExtent);
2751 for(child = children.last; child; child = child.prev)
2753 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2755 bool opaque = child.IsOpaque(); // TODO: acess background directly
2756 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2758 child.clipExtent.Copy(clipExtent);
2759 child.clipExtent.Offset(-dx, -dy);
2760 child.clipExtent.IntersectBox(child.box);
2762 child.ComputeClipExtents();
2764 if(opaque && !child.style.nonClient)
2766 // Adjust the box for the parent:
2767 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2768 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2773 // ??? Only do this for overlapped window or if parent has with clip children flag
2775 // Do this if window has clip children flag on (default false?)
2776 // this.clipExtent = clipExtent;
2778 clipExtent.Free(null);
2781 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2784 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2785 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2787 offsetX -= rootWindow.clientStart.x;
2788 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2792 for(child = children.last; child; child = child.prev)
2794 bool opaque = child.IsOpaque();
2795 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2799 // Adjust renderArea to the root window level
2800 Extent * renderArea = &rootWindow.tempExtents[3];
2802 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2803 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2804 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2806 offsetX -= child.rootWindow.clientStart.x;
2807 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2811 Extent childRenderArea;
2813 if(backBufferUpdate != null)
2815 childRenderArea.Copy(backBufferUpdate);
2816 childRenderArea.Offset(-offsetX, -offsetY);
2819 childRenderArea.Copy(child.dirtyArea);
2821 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2822 renderArea.Copy(dirtyExtent);
2823 renderArea.Offset(-offsetX, -offsetY);
2824 childRenderArea.Union(renderArea);
2827 // Intersect with the clip extent
2828 childRenderArea.Intersection(child.clipExtent);
2831 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2833 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2834 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2836 renderArea->Offset(offsetX, offsetY);
2838 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2839 // overDirtyExtent.Union(renderArea);
2840 renderArea->Empty();
2841 // childRenderArea.Free();
2843 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2848 for(child = children.last; child; child = child.prev)
2850 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2852 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2857 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2859 bool opaque = IsOpaque();
2860 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2862 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2863 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2865 offsetX -= rootWindow.clientStart.x;
2866 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2870 for(child = children.last; child; child = child.prev)
2872 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2874 ColorAlpha background = *(ColorAlpha *)&child.background;
2875 bool opaque = child.IsOpaque();
2876 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2880 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2881 // Adjust renderArea to the root window level
2883 renderArea.Copy(child.dirtyArea);
2884 renderArea.Offset(offsetX, offsetY);
2885 dirtyExtent.Union(renderArea);
2886 overDirtyExtent.Union(renderArea);
2892 for(child = children.last; child; child = child.prev)
2894 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2896 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2900 if(backBufferUpdate != null)
2902 renderArea.Copy(backBufferUpdate);
2903 renderArea.Offset(-offsetX, -offsetY);
2905 overRenderArea.Copy(backBufferUpdate);
2906 overRenderArea.Offset(-offsetX, -offsetY);
2912 renderArea.Copy(dirtyArea);
2914 overRenderArea.Copy(dirtyArea);
2917 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2918 dirtyExtentWindow->Copy(dirtyExtent);
2919 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2920 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2921 dirtyExtentWindow->Empty();
2923 // Intersect with the clip extent
2924 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2927 if(renderArea.count > 10)
2930 printf("\nToo many extents (%d):\n", renderArea.count);
2932 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2933 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2938 for(c = 0; c<10; c++)
2941 FASTLIST_LOOP(renderArea, extentBox)
2943 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2945 renderArea.Copy(extent);
2947 FASTLIST_LOOP(renderArea, extentBox)
2950 printf("(%d, %d) - (%d, %d)\n",
2951 extentBox.box.left, extentBox.box.top,
2952 extentBox.box.right, extentBox.box.bottom);
2956 printf("\nNow %d\n", renderArea.count);
2962 // WHY WAS THIS COMMENTED ??
2964 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2965 dirtyExtentWindow->Copy(overDirtyExtent);
2966 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2967 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2968 dirtyExtentWindow->Empty();
2970 // Intersect with the clip extent
2971 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2977 if(scrollExtent.count)
2979 // Subtract render extent from scrolling extent
2980 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2982 if(backBufferUpdate == null)
2984 Extent * dirty = &rootWindow.tempExtents[3];
2987 // Intersect scrolling extent with clip extent
2988 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2990 // offset this scroll to be at the root window level
2991 scrollExtent.Offset(offsetX, offsetY);
2992 // Add area that was scrolled to the dirty extents of the back buffer
2993 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2997 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2998 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2999 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
3004 scrollExtent.Empty();
3006 // Add the exposed extent to the window render area
3007 dirty->Offset(-offsetX, -offsetY);
3008 renderArea.Union(dirty, rootWindow.tempExtents[0]);
3013 // Subtract the window's box from the transparency forced extent
3014 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3020 renderArea.Copy(this.renderArea);
3021 renderArea.Offset(offsetX, offsetY);
3022 dirtyExtent.Union(renderArea);
3028 Extent renderArea { };
3030 renderArea.Copy(overRenderArea);
3031 renderArea.Offset(offsetX, offsetY);
3032 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3037 if(backBufferUpdate != null)
3039 // Remove render area from dirty area
3040 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3042 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3049 // Remove the window render area from the dirty extents of the back buffer
3050 rootWindow.dirtyBack.Exclusion(renderArea);
3054 void Render(Extent updateExtent)
3058 Window rootWindow = this.rootWindow;
3059 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3060 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3062 offsetX -= rootWindow.clientStart.x;
3063 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3066 if(rootWindow.fullRender)
3075 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3076 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3081 /*if(renderArea.count)
3082 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3085 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3087 Box box = extentBox.box;
3090 /*printf("(%d, %d) - (%d, %d)\n",
3091 extentBox.box.left, extentBox.box.top,
3092 extentBox.box.right, extentBox.box.bottom);*/
3097 box.left += offsetX;
3099 box.right += offsetX;
3100 box.bottom += offsetY;
3102 if(updateExtent != null)
3103 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3107 for(child = children.first; child; child = child.next)
3108 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3109 child.Render(updateExtent);
3111 if(rootWindow.fullRender)
3112 DrawOverChildren(box);
3115 // TO DO: There's an issue about draw over children...
3116 // TO DO: Don't wanna go through this if method isn't used
3117 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3118 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3120 Box box = extentBox.box;
3122 DrawOverChildren(box);
3124 box.left += offsetX;
3126 box.right += offsetX;
3127 box.bottom += offsetY;
3129 if(updateExtent != null)
3130 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3133 for(child = children.first; child; child = child.next)
3134 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3135 child.Render(updateExtent);
3138 overRenderArea.Empty();
3141 public void UpdateDisplay(void)
3143 if(!manageDisplay) { OnRedraw(null);return; }
3144 if(rootWindow && this != rootWindow)
3145 rootWindow.UpdateDisplay();
3148 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3149 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3152 dirtyExtent.Clear();
3155 clipExtent.AddBox(box);
3157 display.StartUpdate();
3159 if(!rootWindow.fullRender)
3161 ComputeClipExtents();
3162 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3163 ComputeRenderArea(dirtyExtent, overExtent, null);
3166 clipExtent.Free(null);
3168 dirtyExtent.Free(null);
3169 overExtent.Free(null);
3171 if(display.flags.flipping)
3174 display.Update(null);
3178 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3179 updateExtent.Clear();
3181 Render(updateExtent);
3183 updateExtent.UnionBox(this.box, tempExtents[0]);
3186 //printf("\n\nUpdate:\n------------------------------------------\n");
3189 //FASTLIST_LOOP(updateExtent, extentBox)
3190 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3193 /*printf("Updating (%d, %d) - (%d, %d)\n",
3194 extentBox.box.left, extentBox.box.top,
3195 extentBox.box.right, extentBox.box.bottom);*/
3198 display.Update(extentBox.box);
3201 updateExtent.Free(null);
3204 display.EndUpdate();
3212 void UpdateBackDisplay(Box box)
3218 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3220 //printf("UpdateBackDisplay going through!\n");
3221 display.StartUpdate();
3225 intersection.Copy(dirtyBack);
3226 intersection.IntersectBox(box);
3228 dirtyExtent.Clear();
3231 clipExtent.AddBox(box);
3233 if(!rootWindow.fullRender)
3235 ComputeClipExtents();
3236 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3239 clipExtent.Free(null);
3241 intersection.Free(null);
3242 dirtyExtent.Free(null);
3243 overExtent.Free(null);
3248 if(display.flags.flipping)
3249 display.Update(null);
3252 rootWindow.display.Update(box);
3255 display.EndUpdate();
3259 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3260 if(dirtyBack.count > MAX_DIRTY_BACK)
3262 BoxItem extentBox, next;
3263 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3264 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3266 next = (BoxItem)extentBox.next;
3267 if(extentBox != first)
3269 if(extentBox.box.left < first.box.left)
3270 first.box.left = extentBox.box.left;
3271 if(extentBox.box.top < first.box.top)
3272 first.box.top = extentBox.box.top;
3273 if(extentBox.box.right > first.box.right)
3274 first.box.right = extentBox.box.right;
3275 if(extentBox.box.bottom > first.box.bottom)
3276 first.box.bottom = extentBox.box.bottom;
3277 dirtyBack.Delete(extentBox);
3286 // --- Window positioning ---
3287 // --- Window identification ---
3289 // Returns window at position "Position"
3290 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3292 Window child, result = null;
3294 box.left += absPosition.x;
3295 box.right += absPosition.x;
3296 box.top += absPosition.y;
3297 box.bottom += absPosition.y;
3299 if(!destroyed && visible && (acceptDisabled || !disabled))
3301 int lx = x - absPosition.x;
3302 int ly = y - absPosition.y;
3303 if(IsInside(lx, ly))
3304 // if(box.IsPointInside(Point{x, y}))
3306 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3307 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3310 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3311 Window ancestor = null;
3313 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3314 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3316 if(child != statusBar && child.rootWindow == rootWindow)
3318 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3325 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3327 if(child != statusBar && child.rootWindow == rootWindow)
3329 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3336 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3344 Window FindModal(void)
3346 Window modalWindow = this, check;
3347 Window check2 = null;
3348 for(check = this; check.master; check = check.master)
3350 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3352 modalWindow = check.master.modalSlave;
3353 check = modalWindow;
3355 // TESTING THIS FOR DROPBOX...
3356 if(!rootWindow || !rootWindow.style.interim)
3358 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3360 if(check2.modalSlave && check2.modalSlave.created)
3362 modalWindow = check2.modalSlave;
3370 if(modalWindow == this)
3372 for(check = this; check.activeChild; check = check.activeChild)
3374 if(check.modalSlave)
3376 modalWindow = check.modalSlave;
3382 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3383 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3386 void StopMoving(void)
3388 if(this == guiApp.windowMoving)
3390 guiApp.windowMoving = null;
3391 UpdateDecorations();
3392 SetMouseRange(null);
3395 if(rootWindow.active)
3396 guiApp.interfaceDriver.StopMoving(rootWindow);
3398 guiApp.windowCaptured.ReleaseCapture();
3399 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3400 guiApp.windowIsResizing = false;
3404 void SelectMouseCursor(void)
3409 Window cursorWindow = null;
3410 bool rx, ry, rex, rey;
3412 guiApp.desktop.GetMousePosition(&x, &y);
3413 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3415 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3416 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3417 else if(mouseWindow)
3419 modalWindow = mouseWindow.FindModal();
3420 x -= mouseWindow.absPosition.x;
3421 y -= mouseWindow.absPosition.y;
3422 if(guiApp.windowIsResizing)
3424 rex = guiApp.resizeEndX;
3425 rey = guiApp.resizeEndY;
3426 rx = guiApp.resizeX;
3427 ry = guiApp.resizeY;
3428 if((rex && rey) || (rx && ry))
3429 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3430 else if((rex && ry) || (rx && rey))
3431 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3432 else if((ry || rey) && (!rx && !rex))
3433 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3434 else if((rx || rex) && (!ry && !rey))
3435 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3437 else if(!modalWindow && !guiApp.windowCaptured &&
3438 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3439 &rx, &ry, &rex, &rey))
3441 if((rex && rey) || (rx && ry))
3442 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3443 else if((rex && ry) || (rx && rey))
3444 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3445 else if((ry || rey) && (!rx && !rex))
3446 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3447 else if((rx || rex) && (!ry && !rey))
3448 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3450 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3452 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3453 mouseWindow.rootWindow != mouseWindow)
3454 cursorWindow = mouseWindow.parent;
3456 cursorWindow = mouseWindow;
3458 else if(!guiApp.interimWindow)
3459 cursorWindow = guiApp.windowCaptured;
3462 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3463 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3465 else if(modalWindow)
3467 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3469 else if(guiApp.interimWindow)
3471 if(guiApp.interimWindow.cursor)
3472 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3474 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3479 // --- State based input ---
3480 bool AcquireInputEx(bool state)
3485 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3486 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3488 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3490 guiApp.acquiredWindow = state ? this : null;
3493 SetMouseRangeToClient();
3494 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3499 SelectMouseCursor();
3501 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3505 // --- Window activation ---
3506 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3509 if(!parent || !parent.style.inactive)
3511 Window parent = this.parent;
3514 if(rootWindow == this)
3515 Log(active ? "active\n" : "inactive\n");
3517 if(active && requireRemaximize)
3519 if(state == maximized)
3521 property::state = normal;
3522 property::state = maximized;
3524 requireRemaximize = false;
3527 // Testing this here...
3528 if(!parent || parent == guiApp.desktop || parent.active)
3530 this.active = active;
3533 // TESTING THIS HERE
3534 UpdateDecorations();
3535 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3536 result = NotifyActivate(master, this, active, previous);
3539 this.active = !active;
3544 if(!parent || parent == guiApp.desktop || parent.active)
3546 this.active = active;
3548 AcquireInputEx(active);
3549 if(active && isEnabled)
3553 if(guiApp.caretOwner)
3557 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3558 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3559 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3560 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3562 guiApp.caretOwner.Update(extent);
3565 if(visible || !guiApp.caretOwner)
3566 guiApp.caretOwner = this;
3567 UpdateCaret(false, false);
3573 this.active = false;
3575 AcquireInputEx(active);
3577 if(!active && guiApp.caretOwner == this)
3579 UpdateCaret(false, true);
3580 guiApp.caretOwner = null;
3581 guiApp.interfaceDriver.SetCaret(0,0,0);
3582 guiApp.caretEnabled = false;
3587 if(!active && parent && parent.activeChild && parent.activeChild != this)
3588 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3594 if(!active && menuBar)
3597 menuBar.OnActivate(false, null, &goOn, true);
3598 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3603 Window aChild = activeChild;
3605 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3617 void ConsequentialMouseMove(bool kbMoving)
3621 if(kbMoving || !guiApp.windowMoving)
3625 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3627 if(guiApp.interfaceDriver)
3628 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3630 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3631 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3637 bool IsDescendantOf(Window ancestor)
3640 for(window = this; window && window != ancestor; window = window.parent);
3641 return window == ancestor;
3644 bool IsSlaveOf(Window master)
3647 for(window = this; window && window != master; window = window.master);
3648 return window == master;
3651 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3655 if(this && !destroyed /*&& state != Hidden*/)
3657 Window swap = externalSwap;
3665 if(activateParent &&
3666 (parent.activeChild != this ||
3667 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3668 active && _isModal &&
3669 parent != master && master)
3670 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3676 bool real = parent.activeChild != this;
3678 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3679 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3680 !IsDescendantOf(guiApp.interimWindow) &&
3681 !IsSlaveOf(guiApp.interimWindow))
3683 Window interimWindow = guiApp.interimWindow;
3684 while(interimWindow && interimWindow != this)
3686 Window master = interimWindow.master;
3688 guiApp.interimWindow = null;
3689 if(guiApp.caretOwner)
3690 guiApp.caretOwner.UpdateCaret(false, false);
3692 incref interimWindow;
3693 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3698 delete interimWindow;
3699 interimWindow = (master && master.style.interim) ? master : null;
3704 guiApp.interimWindow = this;
3705 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3706 guiApp.caretEnabled = false;*/
3707 UpdateCaret(false, true);
3712 //bool acquireInput = false;
3714 parent.activeChild &&
3715 parent.activeChild.state == maximized &&
3716 parent != guiApp.desktop;
3718 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3723 swap = parent.activeChild;
3724 if(swap && swap.destroyed) swap = null;
3725 if(swap && swap != this)
3728 if(!swap.PropagateActive(false, this, &goOn, true))
3729 swap = parent.activeChild;
3740 if(!parent || parent.activeChild != this || style.interim)
3743 result = PropagateActive(true, swap, &goOn, true);
3744 if(!result && !goOn)
3749 //acquireInput = true;
3753 if(style.hasMaximize && parent != guiApp.desktop)
3756 SetState(maximized, false, 0);
3757 else if(state != maximized)
3760 for(child = parent.children.first; child; child = child.next)
3762 if(this != child && child.state == maximized)
3763 child.SetState(normal, false, 0);
3770 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3772 Window previous = parent.activeClient;
3773 parent.activeChild = this;
3774 if(!style.nonClient /*&& style.isActiveClient*/)
3778 if(style.isActiveClient)
3779 parent.activeClient = this;
3780 // Moved UpdateActiveDocument inside hidden check
3781 // To prevent activating previous window while creating a new one
3782 // (It was messing up the privateModule in the CodeEditor)
3783 parent.UpdateActiveDocument(previous);
3789 //if(!style.isRemote)
3791 if(rootWindow != this)
3793 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3794 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3797 #if !defined(__EMSCRIPTEN__)
3798 if(!guiApp.fullScreenMode)
3801 Window modalRoot = FindModal();
3802 if(!modalRoot) modalRoot = this;
3803 if(!modalRoot.isForegroundWindow)
3805 modalRoot.isForegroundWindow = true;
3806 // To check : Why is parent null?
3807 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3809 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3811 modalRoot.isForegroundWindow = false;
3816 if(result && real && (!style.inactive || moveInactive) && parent)
3818 Window last = parent.children.last;
3820 if(!style.stayOnTop)
3821 for(; last && last.style.stayOnTop; last = last.prev);
3823 parent.children.Move(this, last);
3825 // Definitely don't want that: why not?
3829 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3835 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3842 parent.activeChild = null;
3843 if(!style.nonClient /*&& style.isActiveClient*/)
3845 Window previous = parent.activeClient;
3846 if(style.isActiveClient)
3847 parent.activeClient = null;
3848 parent.UpdateActiveDocument(previous);
3852 if(this == guiApp.interimWindow)
3854 guiApp.interimWindow = null;
3855 if(guiApp.caretOwner)
3856 guiApp.caretOwner.UpdateCaret(false, false);
3858 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3865 if(!active || !swap)
3866 UpdateDecorations();
3868 swap.UpdateDecorations();
3870 if(active && rootWindow != this)
3871 ConsequentialMouseMove(false);
3878 // --- Input Messages ---
3879 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3881 static bool reEntrancy = false;
3882 if(reEntrancy) return;
3886 guiApp.cursorUpdate = true;
3887 if(guiApp.windowScrolling && !consequential)
3889 guiApp.windowScrolling.SetScrollPosition(
3890 (guiApp.windowScrolling.sbh) ?
3891 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3892 (guiApp.windowScrolling.sbv) ?
3893 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3895 if(guiApp.windowMoving)
3897 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3899 Window window = guiApp.windowMoving;
3901 int w = window.size.w;
3902 int h = window.size.h;
3907 rx = mouseX - guiApp.windowMovingStart.x;
3908 ry = mouseY - guiApp.windowMovingStart.y;
3911 window.GetDecorationsSize(&ew, &eh);
3913 if(guiApp.windowIsResizing)
3915 x = window.scrolledPos.x;
3916 y = window.scrolledPos.y;
3920 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3921 rx = guiApp.windowResizingBefore.w - aw;
3922 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3923 w = guiApp.windowResizingBefore.w - rx;
3927 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3928 ry = guiApp.windowResizingBefore.h - ah;
3929 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3930 ry = Max(ry, -guiApp.windowMovingBefore.y);
3931 h = guiApp.windowResizingBefore.h - ry;
3933 if(guiApp.resizeEndX)
3935 w = guiApp.windowResizingBefore.w + rx;
3938 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3946 w = Max(w, window.minSize.w);
3947 h = Max(h, window.minSize.h);
3948 w = Min(w, window.maxSize.w);
3949 h = Min(h, window.maxSize.h);
3951 if(!window.OnResizing(&w, &h))
3953 w = window.clientSize.w;
3954 h = window.clientSize.h;
3957 w = Max(w, window.skinMinSize.w);
3958 h = Max(h, window.skinMinSize.h);
3965 SNAPDOWN(w, textCellW);
3966 SNAPDOWN(h, textCellH);
3971 aw = Max(w,window.skinMinSize.w);
3972 rx = guiApp.windowResizingBefore.w - aw;
3973 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3974 w = guiApp.windowResizingBefore.w - rx;
3978 ah = Max(h,window.skinMinSize.h);
3979 ry = guiApp.windowResizingBefore.h - ah;
3980 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3981 ry = Max(ry, -guiApp.windowMovingBefore.y);
3982 h = guiApp.windowResizingBefore.h - ry;
3987 if(!guiApp.windowIsResizing || guiApp.resizeX)
3988 x = guiApp.windowMovingBefore.x + rx;
3989 if(!guiApp.windowIsResizing || guiApp.resizeY)
3990 y = guiApp.windowMovingBefore.y + ry;
3992 if(!guiApp.windowIsResizing)
3995 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3997 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3998 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3999 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
4000 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
4004 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
4005 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
4011 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
4013 if(!window.OnMoving(&x, &y, w, h))
4015 x = window.scrolledPos.x;
4016 y = window.scrolledPos.y;
4022 SNAPDOWN(x, textCellW);
4023 SNAPDOWN(y, textCellH);
4026 if(!window.style.nonClient)
4028 if(!window.style.fixed /*|| window.style.isDocument*/)
4030 if(!window.style.dontScrollHorz)
4031 x += window.parent.scroll.x;
4032 if(!window.style.dontScrollVert)
4033 y += window.parent.scroll.y;
4037 // Break the anchors for moveable/resizable windows
4038 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4039 if(window.style.fixed)
4041 if(window.state == normal)
4043 window.normalAnchor = Anchor { left = x, top = y };
4044 window.normalSizeAnchor = SizeAnchor { { w, h } };
4045 window.anchored = false;
4049 window.stateAnchor = Anchor { left = x, top = y };
4050 window.stateSizeAnchor = SizeAnchor { { w, h } };
4052 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4053 // TOCHECK: Investigate why the following only redraws the scrollbars
4054 //window.Position(x, y, w, h, false, true, true, true, false, true);
4056 guiApp.movingLast.x = mouseX;
4057 guiApp.movingLast.y = mouseY;
4063 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4066 bool wasMoving = guiApp.windowMoving ? true : false;
4067 bool wasScrolling = guiApp.windowScrolling ? true : false;
4069 while(result && w != this)
4071 Window msgWindow = GetAtPosition(x,y, false, true, w);
4072 Window trueWindow = GetAtPosition(x,y, false, false, w);
4073 bool windowDragged = false;
4078 window = (w && !w.disabled) ? w : null;
4080 if(trueWindow) incref trueWindow;
4082 if(consequential) mods->isSideEffect = true;
4084 UpdateMouseMove(x, y, consequential);
4086 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4088 if(!guiApp.windowCaptured.isEnabled)
4089 guiApp.windowCaptured.ReleaseCapture();
4091 window = guiApp.windowCaptured;
4094 if(trueWindow && activate &&
4095 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4096 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4097 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4098 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4100 if(mods->alt && !mods->ctrl && !mods->shift)
4102 Window moved = trueWindow;
4103 for(moved = trueWindow; moved; moved = moved.parent)
4104 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4109 windowDragged = true;
4111 // Cancel the ALT menu toggling...
4112 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4117 if(window && activate &&
4118 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4119 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4120 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4121 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4123 Window modalWindow = window.FindModal();
4125 /*if(mods->alt && !mods->shift && !mods->ctrl)
4127 Window moved = window;
4128 for(moved = window; moved; moved = moved.parent)
4129 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4134 windowDragged = true;
4136 // Cancel the ALT menu toggling...
4137 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4143 Window activateWindow = modalWindow ? modalWindow : window;
4144 if(activateWindow && !activateWindow.isRemote)
4146 bool doActivation = true;
4147 //bool needToDoActivation = false;
4148 Window check = activateWindow;
4150 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4152 if(!check.style.inactive)
4154 //needToDoActivation = true;
4156 doActivation = false;
4161 if(!needToDoActivation)
4162 doActivation = false;
4165 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4166 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4168 // Let the OnLeftButtonDown do the activating instead
4169 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4177 incref activateWindow;
4178 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4180 delete activateWindow;
4184 if(activateWindow._refCount == 1)
4186 delete activateWindow;
4190 delete activateWindow;
4191 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4194 mods->isActivate = true;
4198 if(!modalWindow && window && !window.destroyed)
4200 if(!guiApp.windowCaptured || windowDragged)
4202 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4204 bool moving = ((window.state != maximized &&
4205 window.IsMouseMoving(
4206 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4207 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4209 if(!moving && window.IsMouseResizing(
4210 x - window.absPosition.x,
4211 y - window.absPosition.y,
4212 window.size.w, window.size.h,
4213 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4215 guiApp.windowIsResizing = true;
4216 guiApp.windowResizingBefore.w = window.size.w;
4217 guiApp.windowResizingBefore.h = window.size.h;
4219 if(guiApp.windowIsResizing || windowDragged || moving)
4222 guiApp.windowMoving = window;
4223 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4224 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4225 guiApp.windowMovingBefore.x = window.position.x;//s;
4226 guiApp.windowMovingBefore.y = window.position.y;//s;
4227 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4228 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4231 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4233 if(window.style.fixed &&
4235 window.IsMouseMoving(
4236 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4238 window.ShowSysMenu(x, y);
4242 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4244 if(window.sbv || window.sbh)
4247 guiApp.windowScrolling = window;
4248 guiApp.windowScrollingStart.x = x;
4249 guiApp.windowScrollingStart.y = y;
4250 guiApp.windowScrollingBefore.x = window.scroll.x;
4251 guiApp.windowScrollingBefore.y = window.scroll.y;
4254 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4256 if(window.style.hasMaximize &&
4257 window.IsMouseMoving(
4258 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4261 (window.state == maximized) ? normal : maximized, false, *mods);
4269 if(guiApp.windowMoving)
4271 if(guiApp.windowMoving.parent)
4273 if(guiApp.windowMoving.style.nonClient)
4274 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4276 guiApp.windowMoving.parent.SetMouseRangeToClient();
4280 window.UpdateDecorations();
4283 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4285 // Log("\n*** LEFT BUTTON UP ***\n");
4286 if(guiApp.windowMoving)
4287 guiApp.windowMoving.StopMoving();
4289 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4291 if(guiApp.windowScrolling)
4293 Window windowScrolling = guiApp.windowScrolling;
4294 guiApp.windowScrolling = null;
4295 windowScrolling.ReleaseCapture();
4299 if(!result || (window && window.destroyed)) window = null;
4301 if(window && window.FindModal())
4304 if(trueWindow && trueWindow.FindModal())
4312 msgWindow = GetAtPosition(x,y, true, false);
4314 msgWindow.SelectMouseCursor();
4317 if(guiApp.windowCaptured || trueWindow)
4319 Window prevWindow = guiApp.prevWindow;
4320 List<Window> overWindows = guiApp.overWindows;
4321 Iterator<Window> it { overWindows };
4326 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4329 result = w.OnMouseLeave(*mods);
4331 overWindows.TakeOut(w);
4335 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4337 guiApp.prevWindow.mouseInside = false;
4338 guiApp.prevWindow = null;
4342 if(trueWindow.IsDescendantOf(prevWindow))
4344 if(!overWindows.Find(prevWindow))
4345 overWindows.Add(prevWindow);
4347 // Eventually fix this not to include captured?
4348 else if(!prevWindow.OnMouseLeave(*mods))
4352 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4354 Box box = trueWindow.box;
4355 box.left += trueWindow.absPosition.x;
4356 box.right += trueWindow.absPosition.x;
4357 box.top += trueWindow.absPosition.y;
4358 box.bottom += trueWindow.absPosition.y;
4360 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4362 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4363 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4365 overX = Max(Min(overX, 32767),-32768);
4366 overY = Max(Min(overY, 32767),-32768);
4368 trueWindow.mouseInside = true;
4369 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4373 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4375 for(w : guiApp.overWindows; w == trueWindow)
4378 guiApp.overWindows.TakeOut(w);
4381 guiApp.prevWindow = trueWindow;
4384 guiApp.prevWindow = null;
4386 SelectMouseCursor();
4388 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4389 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4391 int clientX = x - (window.absPosition.x + window.clientStart.x);
4392 int clientY = y - (window.absPosition.y + window.clientStart.y);
4394 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4396 clientX = Max(Min(clientX, 32767),-32768);
4397 clientY = Max(Min(clientY, 32767),-32768);
4399 MouseMethod = (void *)window._vTbl[method];
4401 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4404 if(!MouseMethod(window, clientX, clientY, *mods))
4408 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4409 window.OnMouseLeave(*mods);
4416 if(result && w && w.clickThrough && w.parent)
4421 if(!result || !w || !w.clickThrough)
4428 // --- Mouse cursor management ---
4430 bool KeyMessage(uint method, Key key, unichar character)
4435 if(guiApp.interimWindow)
4436 this = guiApp.interimWindow;
4439 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4443 if(!style.inactive || rootWindow != this)
4445 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4446 Window modalWindow = FindModal();
4447 Window interimMaster = master ? master.rootWindow : null;
4451 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4452 status = OnSysKeyDown(key, character);
4453 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4454 status = OnSysKeyHit(key, character);
4455 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4456 status = OnSysKeyUp(key, character);
4463 // Process Key Message for Internal UI Keyboard actions
4464 if(status && !destroyed && menuBar && state != minimized)
4467 if((SmartKey)key != alt)
4468 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4471 SmartKey sk = (SmartKey) key;
4472 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4474 status = menuBar.KeyMessage(method, key, character);
4479 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4480 menuBar.OnKeyHit(escape, 0);
4482 if(!menuBar.focus && guiApp.caretOwner)
4483 guiApp.caretOwner.UpdateCaret(true, false);
4486 if(!destroyed && status)
4488 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4492 case left: case up: case right: case down:
4493 if(guiApp.windowMoving == this)
4496 int w = guiApp.windowMoving.size.w;
4497 int h = guiApp.windowMoving.size.h;
4498 int x = guiApp.windowMoving.scrolledPos.x;
4499 int y = guiApp.windowMoving.scrolledPos.y;
4503 if(key == down || key == up)
4504 step = Max(step, textCellH);
4506 step = Max(step, textCellW);
4509 if(guiApp.windowIsResizing)
4513 case left: w-=step; break;
4514 case right: w+=step; break;
4515 case up: h-=step; break;
4516 case down: h+=step; break;
4523 case left: x-=step; break;
4524 case right: x+=step; break;
4525 case up: y-=step; break;
4526 case down: y+=step; break;
4530 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4531 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4533 if(!guiApp.windowIsResizing || guiApp.resizeX)
4534 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4536 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4538 if(!guiApp.windowIsResizing || guiApp.resizeY)
4539 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4541 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4543 guiApp.interfaceDriver.SetMousePosition(x, y);
4544 ConsequentialMouseMove(true);
4552 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4554 guiApp.windowMoving.StopMoving();
4555 ConsequentialMouseMove(false);
4563 ShowSysMenu(absPosition.x, absPosition.y);
4571 if(!destroyed && status && state != minimized)
4573 // Process all the way down the children
4574 if(activeChild && !activeChild.disabled)
4576 status = activeChild.KeyMessage(method, key, character);
4578 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4579 key.code != left && key.code != right && key.code != up && key.code != down)
4581 status = activeClient.KeyMessage(method, key, character);
4585 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4587 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4588 // && defaultControl != activeChild)
4590 delete previousActive;
4591 previousActive = activeChild;
4592 if(previousActive) incref previousActive;
4594 ConsequentialMouseMove(false);
4595 if((defaultControl.active ||
4596 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4597 defaultControl.KeyMessage(method, defaultKey, character);
4603 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4605 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4612 ShowSysMenu(absPosition.x, absPosition.y);
4619 if(this != guiApp.desktop)
4621 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4623 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4625 MenuMoveOrSize(key.shift, true);
4629 else if(guiApp.windowMoving)
4631 guiApp.windowMoving.StopMoving();
4632 ConsequentialMouseMove(false);
4640 if(!destroyed && status && state != minimized)
4642 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4646 case tab: case shiftTab:
4648 Window cycleParent = this;
4649 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4650 cycleParent = master.parent;
4652 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4654 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4657 Window child = cycleParent.activeChild;
4659 // Scroll the window to include the active control
4660 if(cycleParent.sbh && !child.style.dontScrollHorz)
4662 if(child.scrolledPos.x < 0)
4663 cycleParent.sbh.Action(Position,
4664 cycleParent.scroll.x + child.scrolledPos.x, 0);
4665 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4666 cycleParent.sbh.Action(Position,
4667 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4669 if(cycleParent.sbv && !child.style.dontScrollVert)
4671 if(child.scrolledPos.y < 0)
4672 cycleParent.sbv.Action(Position,
4673 cycleParent.scroll.y + child.scrolledPos.y, 0);
4674 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4675 cycleParent.sbv.Action(Position,
4676 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4679 cycleParent.ConsequentialMouseMove(false);
4685 case f6: case shiftF6:
4686 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4688 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4689 if(parent == guiApp.desktop)
4690 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4700 if(CycleChildren(key.shift, true, false, true))
4708 // mIRC Style Window Shortcuts
4709 case alt1: case alt2: case alt3: case alt4: case alt5:
4710 case alt6: case alt7: case alt8: case alt9: case alt0:
4715 for(document = children.first; document; document = document.next)
4717 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4719 if(document == activeChild)
4721 if(document.state == minimized)
4722 document.SetState(normal, false, key);
4725 document.SetState(minimized, false, key);
4726 CycleChildren(false, true, false);
4731 if(activeChild.state == maximized && document.style.hasMaximize)
4732 document.SetState(maximized, false, key);
4733 else if(document.state == minimized)
4734 document.SetState(normal, false, key);
4735 document.Activate();
4750 if(!destroyed && status)
4752 if(state == minimized)
4757 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4759 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4761 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4762 previousActive.ActivateEx(true, false, false, true, null, null);
4763 delete previousActive;
4769 if(!destroyed && status)
4771 status = ProcessHotKeys(method, key, character);
4773 if(!destroyed && status && !modalWindow && state != minimized)
4776 status = KeyMethod(this, key, character);
4777 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4778 status = OnKeyHit(key, character);
4779 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4781 bool result = false;
4784 case ctrlUp: case ctrlDown:
4785 if(sbv && !guiApp.windowScrolling)
4786 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4788 case wheelUp: case wheelDown:
4789 if(sbv && !guiApp.windowScrolling)
4791 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4792 // Do we want to do a consequential move regardless of result in this case?
4793 ConsequentialMouseMove(false);
4796 case ctrlPageUp: case ctrlPageDown:
4797 if(sbh && !guiApp.windowScrolling)
4798 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4803 ConsequentialMouseMove(false);
4808 if(status && !destroyed && menuBar && state != minimized)
4809 status = menuBar.KeyMessage(method, key, character);
4811 if(style.interim && /*destroyed && */status && interimMaster)
4813 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4814 status = interimMaster.KeyMessage(method, key, character);
4821 bool ProcessHotKeys(uint method, Key key, unichar character)
4826 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4827 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4828 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4830 Window hotKeyWindow = hotKey.window;
4831 Window parent = hotKeyWindow.parent;
4832 Window prevActiveWindow = activeChild;
4833 // For when sys buttons are placed inside the menu bar
4834 if(parent && parent._class == class(PopupMenu))
4835 parent = parent.parent;
4837 // 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
4838 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4841 if(prevActiveWindow) incref prevActiveWindow;
4842 incref hotKeyWindow;
4843 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4844 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4847 delete hotKeyWindow;
4848 delete prevActiveWindow;
4852 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4853 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4854 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4856 // ********* WORKING ON THIS ***********
4857 if(prevActiveWindow && !guiApp.interimWindow)
4858 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4861 else if(hotKeyWindow.style.inactive)
4862 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4864 delete prevActiveWindow;
4865 delete hotKeyWindow;
4866 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4867 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4871 if(status && tabCycle)
4874 for(child = children.first; child; child = child.next)
4876 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4887 // --- Windows and graphics initialization / termination ---
4888 bool SetupRoot(void)
4892 // Setup relationship with outside world (bb root || !bb)
4893 #if defined(__EMSCRIPTEN__)
4894 if(this == guiApp.desktop)
4896 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4897 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4902 tempExtents = new0 Extent[4];
4907 /*if(guiApp.fullScreenMode)
4908 rootWindow = guiApp.desktop;
4910 //rootWindow = parent.created ? parent.rootWindow : null;
4911 rootWindow = parent.rootWindow;
4914 against = &parent.box;
4916 against = &parent.clientArea;
4919 for(child = children.first; child; child = child.next)
4922 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4925 bool Setup(bool positionChildren)
4927 bool result = false;
4930 #if defined(__EMSCRIPTEN__)
4931 if(this == guiApp.desktop)
4933 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4936 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4937 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4940 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4942 // This was here, is it really needed?
4943 //guiApp.interfaceDriver.ActivateRootWindow(this);
4947 displaySystem = DisplaySystem {};
4948 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4950 delete displaySystem;
4955 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4956 if(display.Create(displaySystem, windowHandle))
4963 // Sometimes icon does not show up on Windows XP if we set here...
4964 // guiApp.interfaceDriver.SetIcon(this, icon);
4966 else if(this != guiApp.desktop)
4968 display = rootWindow ? rootWindow.display : null;
4974 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4975 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4977 for(child = children.first; child; child = child.next)
4979 if(child.created && !child.Setup(false))
4982 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4983 child.UpdateCaption();
4988 bool SetupDisplay(void)
4990 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4991 if(is3D) return Window3D_SetupDisplay(this); else
4998 class_data void ** pureVTbl;
5000 bool LoadGraphics(bool creation, bool resetAnchors)
5002 bool result = false;
5003 bool success = false;
5005 WindowState stateBackup = state;
5007 if(((subclass(Window))_class).pureVTbl)
5009 if(_vTbl == _class._vTbl)
5011 _vTbl = ((subclass(Window))_class).pureVTbl;
5016 for(m = 0; m < _class.vTblSize; m++)
5018 if(_vTbl[m] == _class._vTbl[m])
5019 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5023 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
5025 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5027 _vTbl = _class._vTbl;
5032 for(m = 0; m < _class.vTblSize; m++)
5034 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5035 _vTbl[m] = _class._vTbl[m];
5041 #if !defined(__EMSCRIPTEN__)
5042 guiApp.fullScreenMode ||
5044 this != guiApp.desktop)
5046 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5052 display.Lock(false);
5053 if(rootWindow == this)
5055 // Set Color Palette
5056 display.SetPalette(palette, true);
5060 if(guiApp.fullScreenMode && this == guiApp.desktop)
5065 for(c=0; c<SystemCursor::enumSize; c++)
5066 if(!guiApp.systemCursors[c].bitmap)
5068 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5069 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5070 if(guiApp.systemCursors[c].bitmapName)
5072 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5073 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5074 if(guiApp.systemCursors[c].bitmap)
5075 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5080 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5082 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5083 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5085 cursor.bitmap.paletteShades = cursor.paletteShades;
5089 guiApp.cursorUpdate = true;
5092 ConsequentialMouseMove(false);
5098 // Load Window Graphic Resources
5101 if(usedFont == setFont || usedFont == window.systemFont)
5102 RemoveResource(usedFont);
5105 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5108 RemoveResource(systemFont);
5111 RemoveResource(captionFont);
5113 for(ptr = resources.first; ptr; ptr = ptr.next)
5115 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5116 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5119 AddResource(setFont);
5121 AddResource(systemFont);
5123 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5130 //if(master && master.font)
5131 if(parent && parent.font)
5135 faceName = parent.font.faceName,
5136 size = parent.font.size,
5137 bold = parent.font.bold,
5138 italic = parent.font.italic,
5139 underline = parent.font.underline
5141 //font = parent.font;
5142 watch(parent) { font { } };
5145 font = guiApp.currentSkin.SystemFont();
5152 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5153 AddResource(captionFont);
5155 if(OnLoadGraphics())
5161 //SetScrollLineStep(sbStep.x, sbStep.y);
5163 if(this != guiApp.desktop)
5167 normalAnchor = anchor;
5168 normalSizeAnchor = sizeAnchor;
5171 // Break the anchors for moveable/resizable windows
5173 if(style.fixed && style.isDocument)
5175 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5187 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5188 stateSizeAnchor = SizeAnchor {};
5193 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5198 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5199 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5202 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5206 stateAnchor = normalAnchor;
5207 stateSizeAnchor = normalSizeAnchor;
5210 position = Point { };
5211 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5222 if(Position(x, y, w, h, true, false, true, true, true, true))
5224 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5227 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5244 success = result = true;
5247 if(!creation && result)
5249 // Load menu bar first because sys buttons are on it...
5252 if(!menuBar.LoadGraphics(false, resetAnchors))
5258 for(child = children.first; child; child = child.next)
5260 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5267 CreateSystemChildren();
5271 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5274 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5277 LogErrorCode(graphicsLoadingFailed, _class.name);
5279 // Do this here to avoid problems on Windows
5280 if(rootWindow == this && parent && stateBackup == maximized)
5281 property::state = maximized;
5285 void UnloadGraphics(bool destroyWindows)
5289 // Free children's graphics
5290 for(child = children.first; child; child = child.next)
5291 child.UnloadGraphics(destroyWindows);
5294 display.Lock(false);
5297 if(guiApp.fullScreenMode && this == guiApp.desktop)
5302 for(c=0; c<SystemCursor::enumSize; c++)
5303 if(guiApp.systemCursors[c].bitmap)
5304 delete guiApp.systemCursors[c].bitmap;
5306 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5307 delete cursor.bitmap;
5309 guiApp.cursorBackground.Free();
5312 if(display && display.displaySystem)
5316 for(ptr = resources.first; ptr; ptr = ptr.next)
5320 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5325 // Free window graphics
5328 // Free skin graphics
5329 if(rootWindow == this)
5331 DisplaySystem displaySystem = display.displaySystem;
5334 display.driverData = null;
5335 display.displaySystem = null;
5339 if(displaySystem && !displaySystem.numDisplays && !is3D)
5340 delete displaySystem;
5349 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5350 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5352 if(this == guiApp.desktop || parent == guiApp.desktop)
5354 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5355 guiApp.interfaceDriver.DestroyRootWindow(this);
5359 // --- Window Hiding ---
5361 void SetVisibility(bool state)
5363 bool visible = (style.hidden || !created) ? false : state;
5364 if(visible != this.visible)
5368 this.visible = visible;
5369 for(child = children.first; child; child = child.next)
5370 child.SetVisibility(visible);
5372 ConsequentialMouseMove(false);
5373 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5377 // --- Windows and graphics initialization / termination ---
5379 bool DisplayModeChanged(void)
5381 bool result = false;
5382 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5384 guiApp.modeSwitching = true;
5385 UnloadGraphics(false);
5387 if(LoadGraphics(false, false))
5389 guiApp.modeSwitching = false;
5394 // --- Window updates system ---
5396 void UpdateDirty(Box updateBox)
5398 if(!manageDisplay) { OnRedraw(null);return; }
5401 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5404 if(display.flags.flipping)
5407 rootWindow.UpdateDisplay();
5410 UpdateBackDisplay(updateBox);
5412 if(guiApp.fullScreenMode)
5414 guiApp.cursorUpdate = true;
5415 guiApp.PreserveAndDrawCursor();
5417 if(guiApp.fullScreenMode)
5418 guiApp.RestoreCursorBackground();
5424 // This function is strictly called as a result of system window activation
5425 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5428 Window interimMaster = null;
5429 Window interimWindow = guiApp.interimWindow;
5430 if(interimWindow && interimWindow.master)
5431 interimMaster = interimWindow.master.rootWindow;
5433 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5434 // SetState(normal, false, 0);
5435 SetState(lastState, false, 0);
5437 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5441 /* WTH is this doing here?
5442 while(swap && swap.activeChild)
5444 swap = swap.activeChild;
5447 // TESTING THIS BEFORE...
5448 if(interimWindow && this == interimMaster)
5452 // Window interimSwap = this;
5453 Window menuBar = this.menuBar;
5454 if(menuBar && interimWindow.master == menuBar)
5457 while(interimSwap && interimSwap.activeChild)
5458 interimSwap = interimSwap.activeChild;
5460 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5461 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5463 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5464 //result = ActivateEx(true, true, false, activateRoot, window, null);
5469 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5470 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5472 if(interimWindow == this && interimMaster && !active)
5474 while(interimMaster && interimMaster.interim && interimMaster.master)
5476 // printf("Going up one master %s\n", interimMaster._class.name);
5477 interimMaster = interimMaster.master.rootWindow;
5479 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5480 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5486 bool DestroyEx(int64 returnCode)
5489 Timer timer, nextTimer;
5491 OldLink prevOrder = null;
5492 Window client = null;
5494 if(parent) stopwatching(parent, font);
5496 // if(window.modalSlave) return false;
5497 if(destroyed || !created)
5504 OldLink slave = master.slaves.FindLink(this);
5505 master.slaves.Delete(slave);
5508 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5514 this.returnCode = (DialogResult)returnCode;
5516 AcquireInput(false);
5521 master.hotKeys.Delete(hotKey);
5525 if(guiApp.prevWindow == this)
5527 guiApp.prevWindow = null;
5532 for(w : guiApp.overWindows; w == this)
5535 guiApp.overWindows.TakeOut(w);
5539 if(guiApp.caretOwner == this)
5541 guiApp.interfaceDriver.SetCaret(0,0,0);
5542 UpdateCaret(false, true);
5543 guiApp.caretEnabled = false;
5548 parent.childrenCycle.Remove(cycle);
5552 OldLink tmpPrev = order.prev;
5553 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5554 prevOrder = tmpPrev;
5557 client = tmpPrev ? tmpPrev.data : null;
5558 if(client == this) { client = null; break; }
5559 if(client && (client.style.hidden || client.destroyed || !client.created))
5560 tmpPrev = client.order.prev;
5564 prevOrder = tmpPrev;
5569 // If this window can be an active client, make sure the next window we activate can also be one
5570 if(!style.nonClient && style.isActiveClient)
5572 tmpPrev = prevOrder;
5575 client = tmpPrev ? tmpPrev.data : null;
5576 if(client == this) { client = null; break; }
5577 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5578 tmpPrev = client.order.prev;
5582 prevOrder = tmpPrev;
5586 if(client && client.style.hidden) client = null;
5588 // parent.childrenOrder.Remove(order);
5591 if(parent && style.isActiveClient && visible)
5593 if(state == minimized) parent.numIcons--;
5594 parent.numPositions--;
5597 // TESTING THIS HERE!
5601 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5602 // to create a window inside a rootwindow that's being destroyed)
5603 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5605 if(master && !master.destroyed /*&&
5606 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5608 if(master.defaultControl == this)
5609 master.defaultControl = null;
5612 parent.OnChildAddedOrRemoved(this, true);
5613 if(parent && !parent.destroyed /*&&
5614 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5616 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5618 if(order && prevOrder && prevOrder.data != this && active)
5620 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5622 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5623 if(parent.activeClient == this)
5625 parent.activeClient = null;
5626 parent.UpdateActiveDocument(null);
5631 if(guiApp.interimWindow == this)
5634 PropagateActive(false, null, &goOn, true);
5638 //if(window.parent.activeChild == window)
5639 parent.activeChild = null;
5640 if(!style.nonClient /*&& style.isActiveClient*/)
5642 Window previous = parent.activeClient;
5643 if(style.isActiveClient)
5644 parent.activeClient = null;
5645 parent.UpdateActiveDocument(previous);
5650 else if(parent.activeClient == this)
5652 parent.activeClient = client;
5653 parent.UpdateActiveDocument(this);
5657 if(guiApp.interimWindow == this)
5659 guiApp.interimWindow = null;
5660 if(guiApp.caretOwner)
5662 Window desktop = guiApp.desktop;
5663 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5664 guiApp.caretOwner.UpdateCaret(false, false);
5669 if(_isModal && master && master.modalSlave == this)
5670 master.modalSlave = null;
5674 if(!guiApp.caretOwner && parent.caretSize)
5676 guiApp.caretOwner = parent;
5677 parent.UpdateCaret(false, false);
5678 parent.Update(null);
5681 // Why was this commented out?
5682 GetRidOfVirtualArea();
5688 dirtyArea.Free(null);
5689 dirtyBack.Free(null);
5690 scrollExtent.Free(null);
5692 /* ATTEMPTING TO MOVE THAT ABOVE
5701 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5702 for(;(child = window.children.first);)
5704 for(; child && (child.destroyed || !child.created); child = child.next);
5713 UnloadGraphics(true);
5716 delete previousActive;
5719 // statusBar = null;
5722 if(master && !master.destroyed)
5724 //master.NotifyDestroyed(this, this.returnCode);
5725 NotifyDestroyed(master, this, this.returnCode);
5728 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5730 nextTimer = timer.next;
5731 if(timer.window == this)
5733 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5734 // timer.window = null;
5740 if(this == guiApp.windowMoving)
5743 if(guiApp.windowCaptured == this)
5745 //guiApp.windowCaptured = null;
5747 if(rootWindow != this && rootWindow)
5748 rootWindow.ConsequentialMouseMove(false);
5756 //for(child = children.first; next = child ? child.next : null, child; child = next)
5757 for(;(child = children.first); )
5759 for(; child && (child.destroyed || !child.created); child = child.next);
5769 /* // MOVED THIS UP...
5772 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5773 for(;(child = window.children.first); )
5775 for(; child && (child.destroyed || !child.created); child = child.next);
5784 while((slave = slaves.first))
5786 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5788 ((Window)slave.data).DestroyEx(0);
5793 if(guiApp.caretOwner == this)
5794 guiApp.caretOwner = null;
5796 sysButtons[0] = null;
5797 sysButtons[1] = null;
5798 sysButtons[2] = null;
5801 if(rootWindow != this)
5803 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5806 box.left -= parent.clientStart.x;
5807 box.top -= parent.clientStart.y;
5808 box.right -= parent.clientStart.x;
5809 box.bottom -= parent.clientStart.y;
5811 if(parent) parent.Update(box);
5816 OldLink slave = master.slaves.FindVoid(this);
5817 master.slaves.Delete(slave);
5823 parent.children.Remove(this);
5828 //autoCreate = false;
5831 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5832 if(((subclass(Window))_class).pureVTbl)
5834 if(_vTbl == _class._vTbl)
5836 _vTbl = ((subclass(Window))_class).pureVTbl;
5841 for(m = 0; m < _class.vTblSize; m++)
5843 if(_vTbl[m] == _class._vTbl[m])
5844 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5853 void SetStateEx(WindowState newState, bool activate)
5856 WindowState prevState = state;
5860 if(prevState != newState)
5861 lastState = prevState;
5863 if(rootWindow != this || !nativeDecorations || !windowHandle)
5865 if(style.isActiveClient && !style.hidden && prevState == minimized)
5868 // This block used to be at the end of the function... moved it for flicker problem in X
5869 // ------------------------------------------------------
5873 stateAnchor = normalAnchor;
5874 stateSizeAnchor = normalSizeAnchor;
5877 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5878 stateSizeAnchor = SizeAnchor {};
5884 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5887 byte * idBuffer = new0 byte[size];
5889 for(child = parent.children.first; child; child = child.next)
5891 if(child != this && child.state == minimized)
5893 if(child.iconID > size - 2)
5895 idBuffer = renew0 idBuffer byte[size*2];
5896 memset(idBuffer + size, 0, size);
5899 idBuffer[child.iconID] = (byte)bool::true;
5902 for(c = 0; c<size; c++)
5907 if(style.isActiveClient && !style.hidden)
5910 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5911 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5916 // TOCHECK: Why was this here?
5917 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5918 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5919 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5921 if(state != minimized || hasMinimize)
5922 Position(x, y, w, h, true, true, true, true, false, true);
5924 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5925 parent.UpdateActiveDocument(null);
5928 if(state != minimized || hasMinimize)
5929 CreateSystemChildren();
5930 // ------------------------------------------------------
5933 int GetPositionID(Window forChild)
5937 byte * idBuffer = new0 byte[size];
5940 for(child = children.first; child; child = child.next)
5942 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5944 if(child.positionID > size - 2)
5946 idBuffer = renew0 idBuffer byte[size*2];
5947 memset(idBuffer + size, 0, size);
5950 idBuffer[child.positionID] = (byte)bool::true;
5953 for(c = 0; c<size; c++)
5960 // --- Window related graphics ---
5962 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5964 palette = newPalette;
5965 if(rootWindow.display)
5966 rootWindow.display.SetPalette(palette, colorMatch);
5969 public bool AcquireInput(bool acquired)
5972 if((guiApp.acquiredWindow && acquiredInput) != acquired)
5974 if(active || (!visible && creationActivation == activate))
5975 result = AcquireInputEx(acquired);
5980 acquiredInput = acquired ? result : !result;
5985 void ListChildren(ListBox listBox)
5989 for(child = children.first; child; child = child.next)
5991 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5993 DataRow row = listBox.AddRow();
5994 row.tag = (int64)(intptr)child;
5995 child.FigureCaption(caption);
5996 row.SetData(null, caption);
6001 void UpdateVisual(Box extent)
6003 if(guiApp.driver != null)
6005 #if !defined(__EMSCRIPTEN__)
6006 if(guiApp.fullScreenMode && guiApp.desktop.display)
6011 #if !defined(__EMSCRIPTEN__)
6012 guiApp.desktop.mutex.Wait();
6014 guiApp.desktop.display.Lock(true);
6017 if(guiApp.desktop.active)
6019 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
6021 if(guiApp.desktop.display.flags.flipping)
6022 guiApp.desktop.Update(null);
6023 guiApp.desktop.UpdateDisplay();
6024 guiApp.cursorUpdate = true;
6026 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
6028 guiApp.PreserveAndDrawCursor();
6029 // guiApp.desktop.display.ShowScreen();
6030 guiApp.cursorUpdate = false;
6031 guiApp.desktop.dirty = false;
6032 guiApp.RestoreCursorBackground();
6036 guiApp.desktop.display.Unlock();
6037 #if !defined(__EMSCRIPTEN__)
6038 guiApp.desktop.mutex.Release();
6043 Window rootWindow = this.rootWindow;
6044 #if !defined(__EMSCRIPTEN__)
6045 rootWindow.mutex.Wait();
6051 guiApp.SignalEvent();
6054 #if !defined(__EMSCRIPTEN__)
6055 guiApp.waitMutex.Wait();
6057 guiApp.interfaceDriver.Lock(rootWindow);
6058 if(!rootWindow.style.hidden && rootWindow.dirty)
6060 if(rootWindow.display)
6062 rootWindow.UpdateDisplay();
6063 //rootWindow.display.ShowScreen(null);
6065 rootWindow.dirty = false;
6067 guiApp.interfaceDriver.Unlock(rootWindow);
6068 #if !defined(__EMSCRIPTEN__)
6069 guiApp.waitMutex.Release();
6073 #if !defined(__EMSCRIPTEN__)
6074 rootWindow.mutex.Release();
6080 void UnlockDisplay(void)
6082 guiApp.interfaceDriver.Unlock(rootWindow);
6085 void LockDisplay(void)
6087 guiApp.interfaceDriver.Lock(rootWindow);
6090 Surface GetSurface(Box box)
6092 return Redraw((box == null) ? this.box : box);
6095 void SetMousePosition(int x, int y)
6097 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6101 void IntegrationActivate(bool active)
6103 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6105 isForegroundWindow = true;
6106 ActivateEx(active, active, false, false, null, null);
6107 isForegroundWindow = false;
6112 Window QueryCapture(void)
6114 return guiApp.windowCaptured;
6117 int GetDocumentID(void)
6121 byte * idBuffer = new0 byte[size];
6124 for(child = children.first; child; child = child.next)
6126 // TO CHECK: Do we want a documentID when we already have a file name?
6127 if(child.style.isDocument && !child.fileName)
6129 if(child.documentID-1 > size - 2)
6131 idBuffer = renew0 idBuffer byte[size*2];
6132 memset(idBuffer + size, 0, size);
6135 idBuffer[child.documentID-1] = 1;
6138 for(c = 0; c<size; c++)
6146 void SetInitSize(Size size)
6149 sizeAnchor.size = size;
6150 normalSizeAnchor = sizeAnchor;
6152 // Break the anchors for moveable/resizable windows
6153 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6155 stateAnchor = normalAnchor;
6156 stateSizeAnchor = normalSizeAnchor;
6158 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6159 Position(x,y, w, h, true, true, true, true, false, true);
6163 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6165 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6167 guiApp.windowIsResizing = resize;
6168 guiApp.windowMoving = this;
6169 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6170 if(guiApp.windowIsResizing)
6172 guiApp.windowMovingStart.x += size.w - 1;
6173 guiApp.windowMovingStart.y += size.h - 1;
6175 guiApp.windowMovingBefore = scrolledPos;
6176 guiApp.windowResizingBefore = size;
6177 guiApp.windowMoving.UpdateDecorations();
6178 if(guiApp.windowIsResizing)
6179 guiApp.resizeEndX = guiApp.resizeEndY = true;
6181 if(setCursorPosition)
6182 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6186 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6187 guiApp.windowMovingStart.x += x - absPosition.x;
6188 guiApp.windowMovingStart.y += y - absPosition.y;
6191 if(guiApp.windowMoving)
6193 if(guiApp.windowMoving.style.nonClient)
6194 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6196 guiApp.windowMoving.parent.SetMouseRangeToClient();
6201 if(this == rootWindow)
6202 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6206 void SetupFileMonitor()
6208 #if !defined(__EMSCRIPTEN__)
6211 fileMonitor = FileMonitor
6213 this, FileChange { modified = true };
6215 bool OnFileNotify(FileChange action, const char * param)
6218 fileMonitor.StopMonitoring();
6219 if(OnFileModified(action, param))
6220 fileMonitor.StartMonitoring();
6234 bool result = false;
6238 else if(guiApp && guiApp.driver != null)
6240 OldLink slaveHolder;
6242 bool visible = !style.hidden;
6246 systemParent = parent;
6247 parent = guiApp.desktop;
6249 last = parent ? parent.children.last : null;
6251 if((parent && parent != guiApp.desktop && !parent.created) ||
6252 (master && master != guiApp.desktop && !master.created))
6256 stopwatching(parent, font);
6259 property::parent = guiApp.desktop;
6260 if(!master) master = parent;
6262 if(_isModal && master.modalSlave)
6263 property::master = master.modalSlave;
6267 parent.children.Remove(this);
6270 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6271 if(slaveHolder.data == this)
6273 master.slaves.Delete(slaveHolder);
6278 #if !defined(__EMSCRIPTEN__)
6279 if(parent == guiApp.desktop && !mutex)
6283 if(style.isDocument)
6286 parent.numDocuments--;
6287 documentID = parent.GetDocumentID();
6290 if(!style.stayOnTop)
6291 for(; last && last.style.stayOnTop; last = last.prev);
6293 parent.children.Insert((last == this) ? null : last, this);
6294 //parent.children.Add(this);
6297 dispDriver = parent.dispDriver;
6300 master.modalSlave = this;
6302 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6307 master.slaves.Add(slaveHolder = OldLink { data = this });
6312 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6314 if(style.isDefault && !master.defaultControl)
6315 master.defaultControl = this;
6317 stateAnchor = normalAnchor = anchor;
6318 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6320 // TOCHECK: Why is this here?
6321 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6322 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6324 this.visible = false;
6325 style.hidden = true;
6328 // autoCreate = true;
6336 if(parent == guiApp.desktop)
6337 Log("LoadGraphics %s\n", caption);
6339 if(LoadGraphics(true, false))
6347 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6354 if(style.hasMenuBar /*&& menu*/)
6360 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6361 interim = false, inactive = true, nonClient = true, size.h = 24
6369 // Create the system buttons
6370 CreateSystemChildren();
6372 UpdateActiveDocument(null);
6374 if(style.isDocument)
6378 MenuItem item = menu.FindItem(MenuFileSave, 0);
6379 if(item) item.disabled = !modifiedDocument && fileName;
6384 if(parent == guiApp.desktop)
6385 Log("Preemptive SetState %s\n", caption);
6388 // Preemptive Set State to ensure proper anchoring
6389 SetStateEx(state, false);
6391 style.hidden = true;
6397 for(child = children.first; child; child = next)
6400 if(!child.created && (child.autoCreate || child.wasCreated))
6407 for(link = slaves.first; link; link = next)
6409 Window slave = link.data;
6411 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6414 // Things might have happened that invalidated 'next'...
6415 // Start over the search for slaves to create.
6416 // (Added this to fix crash with Stacker & Toolbar)
6417 next = slaves.first;
6426 if(parent == guiApp.desktop)
6427 Log("Real SetState %s\n", caption);
6430 if(isActiveClient && visible)
6432 parent.numPositions--;
6433 if(state == minimized) parent.numIcons--;
6436 parent.OnChildAddedOrRemoved(this, false);
6438 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6440 // Real set state & activate for proper display & activation
6441 property::visible = visible;
6442 // SetState(state & 0x00000003, true, 0);
6443 guiApp.interfaceDriver.SetIcon(this, icon);
6448 /*if(rootWindow == this)
6449 guiApp.interfaceDriver.ActivateRootWindow(this);
6451 if(creationActivation == activate && guiApp.desktop.active)
6452 ActivateEx(true, false, true, true, null, null);
6453 else if(creationActivation == activate || creationActivation == flash)
6456 if(this == rootWindow)
6462 rootWindow.ConsequentialMouseMove(false);
6473 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6479 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6481 //style.hidden = true; // !visible;
6482 style.hidden = !visible;
6483 if(master.modalSlave == this)
6484 master.modalSlave = null;
6491 void WriteCaption(Surface surface, int x, int y)
6494 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6497 void Update(Box region)
6503 rootWindow = this.rootWindow;
6505 // rootWindow.mutex.Wait();
6506 if(!destroyed && visible && display)
6511 // Testing this to avoid repetitve full update to take time...
6512 if(rootWindow.fullRender)
6514 rootWindow.dirty = true;
6517 if(dirtyArea.count == 1)
6519 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6520 if(item.box.left <= box.left &&
6521 item.box.top <= box.top &&
6522 item.box.right >= box.right &&
6523 item.box.bottom >= box.bottom)
6525 rootWindow.dirty = true;
6530 if(display.flags.flipping && !rootWindow.dirty)
6532 if(this == rootWindow)
6536 rootWindow.Update(null);
6541 rootWindow.dirty = true;
6546 realBox.left += clientStart.x;
6547 realBox.top += clientStart.y;
6548 realBox.right += clientStart.x;
6549 realBox.bottom += clientStart.y;
6555 if(realBox.right >= realBox.left &&
6556 realBox.bottom >= realBox.top)
6558 // if(!rootWindow.fullRender)
6559 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6561 for(child = children.first; child; child = child.next)
6566 box.left -= child.absPosition.x - absPosition.x;
6567 box.top -= child.absPosition.y - absPosition.y;
6568 box.right -= child.absPosition.x - absPosition.x;
6569 box.bottom -= child.absPosition.y - absPosition.y;
6570 if(box.right >= child.box.left && box.left <= child.box.right &&
6571 box.bottom >= child.box.top && box.top <= child.box.bottom)
6573 box.left -= child.clientStart.x;
6574 box.top -= child.clientStart.y;
6575 box.right -= child.clientStart.x;
6576 box.bottom -= child.clientStart.y;
6582 realBox.left += absPosition.x - rootWindow.absPosition.x;
6583 realBox.top += absPosition.y - rootWindow.absPosition.y;
6584 realBox.right += absPosition.x - rootWindow.absPosition.x;
6585 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6586 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6589 else if(this == guiApp.desktop)
6592 for(window = children.first; window; window = window.next)
6598 Box childBox = region;
6600 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6601 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6602 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6603 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6605 window.Update(childBox);
6608 window.Update(null);
6613 // rootWindow.mutex.Release();
6620 if(guiApp.windowCaptured != this)
6622 if(guiApp.windowCaptured)
6626 //Logf("Captured %s (%s)\n", caption, class.name);
6627 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6628 guiApp.windowCaptured = this;
6634 bool Destroy(int64 code)
6639 if(!destroyed && !CloseConfirmation(false)) return false;
6643 // TOCHECK: Should autoCreate be set to false here?
6654 void Move(int x, int y, int w, int h)
6656 normalAnchor = Anchor { left = x, top = y };
6657 normalSizeAnchor = SizeAnchor { size = { w, h } };
6659 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6661 if(destroyed) return;
6663 stateAnchor = normalAnchor;
6664 stateSizeAnchor = normalSizeAnchor;
6666 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6667 Position(x,y, w, h, true, true, true, true, false, true);
6671 DialogResult Modal(void)
6677 // FIXES MEMORY LEAK IF Create() FAILED
6683 void SetScrollArea(int width, int height, bool snapToStep)
6687 int stepX = sbStep.x, stepY = sbStep.y;
6688 // Needed to make snapped down position match the skin's check of client area
6689 // against realvirtual
6692 SNAPDOWN(stepX, textCellW);
6693 SNAPDOWN(stepY, textCellH);
6694 stepX = Max(stepX, textCellW);
6695 stepY = Max(stepY, textCellH);
6697 if(scrollFlags.snapX)
6698 SNAPUP(width, stepX);
6699 if(scrollFlags.snapY)
6700 SNAPUP(height, stepY);
6703 reqScrollArea.w = width;
6704 reqScrollArea.h = height;
6705 noAutoScrollArea = (width > 0 || height > 0);
6707 UpdateScrollBars(true, true);
6710 void SetScrollPosition(int x, int y)
6713 sbh.Action(setPosition, x, 0);
6717 int seen = clientSize.w, total = reqScrollArea.w;
6719 if(scrollFlags.snapX)
6720 SNAPDOWN(seen, sbStep.x);
6722 if(!total) total = seen;
6723 range = total - seen + 1;
6724 range = Max(range, 1);
6726 if(x >= range) x = range - 1;
6728 if(scrollFlags.snapX)
6729 SNAPUP(x, sbStep.x);
6732 OnHScroll(setPosition, x, 0);
6736 SNAPDOWN(x, textCellW);
6742 sbv.Action(setPosition, y, 0);
6746 int seen = clientSize.h, total = reqScrollArea.h;
6749 if(scrollFlags.snapY)
6750 SNAPDOWN(seen, sbStep.y);
6752 if(!total) total = seen;
6753 range = total - seen + 1;
6754 range = Max(range, 1);
6756 if(y >= range) y = range - 1;
6758 if(scrollFlags.snapY)
6759 SNAPUP(y, sbStep.y);
6762 OnVScroll(setPosition, y, 0);
6765 SNAPDOWN(y, textCellH);
6770 UpdateCaret(false, false);
6773 void SetScrollLineStep(int stepX, int stepY)
6779 SNAPDOWN(stepX, textCellW);
6780 SNAPDOWN(stepY, textCellH);
6781 stepX = Max(stepX, textCellW);
6782 stepY = Max(stepY, textCellH);
6785 sbh.lineStep = stepX;
6787 sbv.lineStep = stepY;
6790 void SetState(WindowState newState, bool activate, Modifiers mods)
6794 if(state == newState || OnStateChange(newState, mods))
6796 //WindowState prevState = state;
6800 // This used to be at the end of the brackets... moved for X, testing...
6801 // This has the effect of activating the window through the system...
6802 if(rootWindow == this)
6803 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6805 SetStateEx(newState, activate);
6807 if(rootWindow == this && !rootWindow.nativeDecorations)
6809 int x = position.x, y = position.y;
6812 x -= guiApp.desktop.absPosition.x;
6813 y -= guiApp.desktop.absPosition.y;
6815 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6819 //state = prevState;
6821 if(state != maximized && style.hasMaximize)
6824 for(child = parent.children.first; child; child = child.next)
6826 if(child != this && child.state == maximized)
6827 child.SetStateEx(normal, false);
6831 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6832 parent.UpdateScrollBars(true, true);
6835 // Do we really need this stuff here?
6836 // Shouldn't the Activate stuff take care of it?
6837 if(parent.rootWindow == parent && style)
6840 parent.FigureCaption(caption);
6841 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6842 parent.UpdateDecorations();
6846 rootWindow.ConsequentialMouseMove(false);
6853 BitmapResource GetIcon(SkinBitmap iconID)
6855 return guiApp.currentSkin.GetBitmap(iconID);
6858 void SetMouseRange(Box range)
6860 if(range || guiApp.fullScreenMode)
6865 clip.left = range.left + absPosition.x + clientStart.x;
6866 clip.top = range.top + absPosition.y + clientStart.y;
6867 clip.right = range.right + absPosition.x + clientStart.x;
6868 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6872 clip.left = guiApp.desktop.box.left;
6873 clip.top = guiApp.desktop.box.top;
6874 clip.right = guiApp.desktop.box.right;
6875 clip.bottom = guiApp.desktop.box.bottom;
6877 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6880 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6883 void SetMouseRangeToClient(void)
6885 if(guiApp.fullScreenMode || this != guiApp.desktop)
6887 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6888 box.Clip(clientArea);
6892 SetMouseRange(null);
6895 void SetMouseRangeToWindow(void)
6897 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6898 if(this == guiApp.desktop)
6899 SetMouseRangeToClient();
6904 // x, y: Desktop Coordinates
6905 void ShowSysMenu(int x, int y)
6908 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6911 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6912 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6916 menu, $"Move", m, NotifySelect = MenuWindowMove,
6917 disabled = !style.fixed || state == maximized
6921 menu, $"Size", s, NotifySelect = MenuWindowSize,
6922 disabled = !style.sizable || state != normal
6926 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6927 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6931 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6932 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6936 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6937 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6939 MenuDivider { menu };
6942 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6943 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6945 windowMenu.Create();
6950 ActivateEx(true, true, true, true, null, null);
6953 void MakeActive(void)
6955 ActivateEx(true, false, true, false, null, null);
6958 void SoftActivate(void)
6960 if(guiApp.desktop.active)
6965 if(this == rootWindow)
6970 void Deactivate(void)
6972 ActivateEx(false, true, true, true, null, null);
6977 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6980 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6982 bool result = false;
6983 if(activeChild && activeChild.cycle)
6985 Window modalWindow, child = activeChild;
6986 if(!clientOnly /*&& parent.tabCycle*/)
6988 Window next = child;
6991 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6995 if(parent && parent.CycleChildren(backward, false, true, true))
7003 next = next.cycle.prev.data;
7005 next = next.cycle.next.data;
7006 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
7011 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
7012 parent.tabCycle && parent.CycleChildren(backward, false, false))
7016 if(tabCycleOnly && !tabCycle) return false;
7023 child = child.cycle.prev.data;
7025 child = child.cycle.next.data;
7026 if(child == child.parent.activeChild)
7028 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
7031 modalWindow = child.FindModal();
7034 // Scroll the window to include the active control
7035 if(sbh && !child.style.dontScrollHorz)
7037 if(child.scrolledPos.x < 0)
7038 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
7039 else if(child.scrolledPos.x + child.size.w > clientSize.w)
7040 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
7042 if(sbv && !child.style.dontScrollVert)
7044 if(child.scrolledPos.y < 0)
7045 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
7046 else if(child.scrolledPos.y + child.size.h > clientSize.h)
7047 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
7051 child = modalWindow ? modalWindow : child;
7052 child.ActivateEx(true, true, true, true, null, null);
7053 if(child.tabCycle && child.childrenCycle.first)
7054 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7062 ConsequentialMouseMove(false);
7066 void AddResource(Resource resource)
7070 ResPtr ptr { resource = resource };
7074 // Load Graphics here if window is created already
7075 if(/*created && */display)
7077 display.Lock(false);
7078 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7079 ptr.loaded = display.displaySystem.LoadResource(resource);
7083 // Temporary hack to load font right away for listbox in dropbox ...
7084 else if(master && master.display)
7086 master.display.Lock(false);
7087 master.display.displaySystem.LoadResource(resource);
7088 master.display.Unlock();
7094 void RemoveResource(Resource resource)
7099 for(ptr = resources.first; ptr; ptr = ptr.next)
7101 if(ptr.resource == resource)
7107 // Unload Graphics here if window is created already
7108 if(/*created && */display)
7112 display.Lock(false);
7113 display.displaySystem.UnloadResource(resource, ptr.loaded);
7119 resources.Delete(ptr);
7124 void SetCaret(int x, int y, int size)
7131 if(active && !style.interim && isEnabled)
7133 if(visible || !guiApp.caretOwner)
7134 guiApp.caretOwner = size ? this : null;
7136 UpdateCaret(false, false);
7139 guiApp.interfaceDriver.SetCaret(0,0,0);
7140 UpdateCaret(false, true);
7141 guiApp.caretEnabled = false;
7144 else if(style.inactive && active)
7146 guiApp.interfaceDriver.SetCaret(0,0,0);
7147 UpdateCaret(false, true);
7148 guiApp.caretEnabled = false;
7153 void Scroll(int x, int y)
7155 bool opaque = !style.drawBehind || background.a;
7156 if(opaque && display && display.flags.scrolling)
7158 Box box = clientArea;
7159 box.left += clientStart.x;
7160 box.top += clientStart.y;
7161 box.right += clientStart.x;
7162 box.bottom += clientStart.y;
7164 //scrollExtent.Free(null);
7165 scrollExtent.AddBox(box);
7166 scrolledArea.x += x;
7167 scrolledArea.y += y;
7169 //scrollExtent.Free();
7170 //scrollExtent.AddBox(clientArea);
7171 //scrollExtent.Offset(clientStart.x, clientStart.y);
7172 //scrolledArea.x = x;
7173 //scrolledArea.y = y;
7179 rootWindow.dirty = true;
7182 void ReleaseCapture()
7184 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7186 Window oldCaptured = guiApp.windowCaptured;
7187 guiApp.windowCaptured = null;
7188 guiApp.prevWindow = null;
7191 //guiApp.Log("Released Capture\n");
7193 guiApp.interfaceDriver.SetMouseCapture(null);
7195 //oldCaptured.OnMouseCaptureLost();
7198 oldCaptured.ConsequentialMouseMove(false);
7203 private void _SetCaption(const char * format, va_list args)
7210 char caption[MAX_F_STRING];
7211 vsnprintf(caption, sizeof(caption), format, args);
7212 caption[sizeof(caption)-1] = 0;
7214 this.caption = CopyString(caption);
7219 firewatchers caption;
7223 /*deprecated*/ void SetText(const char * format, ...)
7226 va_start(args, format);
7227 _SetCaption(format, args);
7231 void SetCaption(const char * format, ...)
7234 va_start(args, format);
7235 _SetCaption(format, args);
7239 bool Grab(Bitmap bitmap, Box box, bool decorations)
7241 bool result = false;
7242 if(display || this == guiApp.desktop)
7244 Box clip = {MININT, MININT, MAXINT, MAXINT};
7250 clip.Clip(clientArea);
7252 clip.Clip(this.box);
7254 if(rootWindow != this)
7256 clip.left += absPosition.y;
7257 clip.top += absPosition.y;
7258 clip.right += absPosition.x;
7259 clip.bottom += absPosition.y;
7262 clip.left += decorations ? 0 : clientStart.x;
7263 clip.top += decorations ? 0 : clientStart.y;
7264 clip.right += decorations ? 0 : clientStart.x;
7265 clip.bottom += decorations ? 0 : clientStart.y;
7267 if(display && display.flags.flipping)
7269 rootWindow.Update(null);
7270 rootWindow.UpdateDisplay();
7277 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7278 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7282 result = display.Grab(bitmap, clip.left, clip.top,
7283 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7285 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7287 if(!bitmap.Convert(null, pixelFormat888, null))
7294 void GetMousePosition(int * x, int * y)
7296 int mouseX = 0, mouseY = 0;
7297 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7300 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7301 if(this != guiApp.desktop)
7303 mouseX -= absPosition.x + clientStart.x;
7304 mouseY -= absPosition.y + clientStart.y;
7311 DialogResult DoModal()
7313 DialogResult returnCode = 0;
7314 int terminated = terminateX;
7317 while(!destroyed && guiApp.driver != null)
7319 if(terminateX != terminated)
7321 terminated = terminateX;
7322 guiApp.desktop.Destroy(0);
7323 if(guiApp.desktop.created)
7326 //printf("Resetting terminate X to 0\n");
7332 guiApp.UpdateDisplay();
7333 if(!guiApp.ProcessInput(false))
7336 returnCode = this.returnCode;
7349 return !destroyed && guiApp.driver != null && terminateX < 2;
7352 DialogResult DoModalEnd()
7354 DialogResult returnCode = this.returnCode;
7359 // --- Window manipulation ---
7360 /*bool GetDisabled()
7362 bool disabled = this.disabled;
7364 for(window = this; (window = window.master); )
7375 // --- Mouse Manipulation ---
7376 void GetNCMousePosition(int * x, int * y)
7378 GetMousePosition(x, y);
7379 if(x) *x += clientStart.x;
7380 if(y) *y += clientStart.y;
7383 // --- Carets manipulation ---
7384 void GetCaretPosition(Point caretPos)
7386 caretPos = this.caretPos;
7389 int GetCaretSize(void)
7394 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7400 bool CloseConfirmation(bool parentClosing)
7413 if(!OnClose(parentClosing))
7416 // If you want to skip this, simply set modifiedDocument to false in OnClose
7417 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7419 DialogResult dialogRes;
7422 sprintf(message, $"Save changes to %s?", fileName);
7424 sprintf(message, $"Save changes to Untitled %d?", documentID);
7426 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7428 if(dialogRes == yes)
7430 // TOFIX: Precomp error if brackets are taken out
7431 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7433 else if(dialogRes == cancel)
7439 for(slave = slaves.first; slave; slave = slave.next)
7441 Window w = slave.data;
7442 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7450 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7453 for(child = children.first; child; child = child.next)
7454 if(child.isActiveClient && !child.CloseConfirmation(true))
7462 for(child = children.first; child; child = child.next)
7463 if(!child.isActiveClient && !child.CloseConfirmation(true))
7473 // Static methods... move them somewhere else?
7474 void ::RestoreCaret()
7476 if(guiApp.caretOwner)
7477 guiApp.caretOwner.UpdateCaret(false, false);
7480 void ::FreeMouseRange()
7482 guiApp.interfaceDriver.SetMouseRange(null, null);
7486 bool MenuFileClose(MenuItem selection, Modifiers mods)
7488 Window document = activeChild;
7490 document.Destroy(0);
7494 bool MenuFileExit(MenuItem selection, Modifiers mods)
7500 bool MenuFileSave(MenuItem selection, Modifiers mods)
7505 #if !defined(__EMSCRIPTEN__)
7506 fileMonitor.fileName = null;
7510 if(OnSaveFile(fileName))
7512 //if(OnFileModified != Window::OnFileModified)
7515 #if !defined(__EMSCRIPTEN__)
7516 fileMonitor.fileName = fileName;
7523 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7524 DialogResult answer = dialog.Modal();
7526 if(answer != yes) return (bool)answer;
7529 return MenuFileSaveAs(selection, mods);
7532 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7534 DialogResult result = (DialogResult)bool::true;
7535 FileDialog fileDialog = saveDialog;
7540 fileDialog = FileDialog {};
7545 fileDialog.filePath = fileName;
7548 char filePath[MAX_FILENAME];
7549 sprintf(filePath, "Untitled %d", documentID);
7550 fileDialog.filePath = filePath;
7552 #if !defined(__EMSCRIPTEN__)
7553 fileMonitor.fileName = null;
7556 fileDialog.type = save;
7557 fileDialog.text = $"Save As";
7561 fileDialog.master = master.parent ? master : this;
7562 if(fileDialog.Modal() == ok)
7564 const char * filePath = fileDialog.filePath;
7566 if(OnSaveFile(filePath))
7569 property::fileName = filePath;
7570 NotifySaved(master, this, filePath);
7575 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7576 DialogResult answer = dialog.Modal();
7591 #if !defined(__EMSCRIPTEN__)
7592 //if(OnFileModified != Window::OnFileModified && fileName)
7595 fileMonitor.fileName = fileName;
7600 return (bool)result; // Actually returning result from Yes/NoCancel message box
7603 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7605 Window document = activeChild;
7607 for(document = children.first; document; document = next)
7609 next = document.next;
7610 if(document.style.isDocument || document.fileName)
7611 document.MenuFileSave(selection, mods);
7616 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7620 for(document = children.first; document; document = document.next)
7621 //if(document.style.isDocument && document.state == minimized)
7622 if(document.style.isActiveClient && document.state == minimized)
7623 document.SetState(minimized, false, mods);
7627 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7629 Window document = activeChild;
7632 Window firstDocument = null;
7634 OldLink cycle = document.cycle.prev;
7639 if(child.style.isActiveClient && !child.style.hidden)
7643 firstDocument = child;
7644 if(child.state == minimized)
7645 child.SetState(minimized, false, mods);
7648 child.positionID = id++;
7649 child.SetState(normal, false, mods);
7650 child.anchor.left.type = cascade;
7653 child.normalSizeAnchor = *&child.sizeAnchor;
7654 child.normalAnchor = child.anchor;
7656 // Break the anchors for moveable/resizable windows
7657 if(child.style.fixed)
7659 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7661 (*&child.normalAnchor).left = x;
7662 (*&child.normalAnchor).top = y;
7663 (*&child.normalAnchor).right.type = none;
7664 (*&child.normalAnchor).bottom.type = none;
7666 (*&child.normalSizeAnchor).isClientW = false;
7667 (*&child.normalSizeAnchor).isClientH = false;
7668 (*&child.normalSizeAnchor).size.w = w;
7669 (*&child.normalSizeAnchor).size.h = h;
7670 child.anchored = false;
7673 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7675 child.stateAnchor = child.normalAnchor;
7676 child.stateSizeAnchor = child.normalSizeAnchor;
7678 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7679 child.Position(x, y, w, h, true, true, true, true, false, false);
7684 last = children.last;
7685 if(!child.style.stayOnTop)
7686 for(; last && last.style.stayOnTop; last = last.prev);
7687 children.Move(child, last);
7688 childrenOrder.Move(child.order, childrenOrder.last);
7690 if(cycle == document.cycle) break;
7694 firstDocument.Activate();
7699 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7706 // Close all closes all active clients, not all documents
7707 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7709 Window next, document;
7711 for(document = children.first; document; document = next)
7713 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7714 if(document.style.isActiveClient)
7715 if(!document.Destroy(0) && !document.style.hidden)
7721 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7723 if(style.hasMaximize && state != maximized)
7724 SetState(maximized, 0, 0);
7728 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7730 if(style.hasMinimize && state != minimized)
7732 SetState(minimized, 0, 0);
7733 parent.CycleChildren(false, true, false, true);
7738 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7740 MenuMoveOrSize(false, selection ? true : false);
7744 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7746 CycleChildren(false, true, false, true);
7750 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7752 CycleChildren(true, true, false, true);
7756 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7758 MenuMoveOrSize(true, true);
7762 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7765 SetState(normal, 0, 0);
7769 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7772 int64 id = selection.id;
7773 OldLink cycle = activeClient.cycle;
7775 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7778 Window sibling = cycle.data;
7779 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7787 document = cycle.data;
7788 document.Activate();
7790 //if(activeChild.state == maximized)
7791 // document.SetState(maximized, false, mods);
7792 //else if(document.state == minimized)
7793 // document.SetState(normal, false, mods);
7797 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7799 stayOnTop = !style.stayOnTop;
7803 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7805 Window document = activeChild;
7808 Window firstDocument = null;
7809 OldLink cycle = document.cycle;
7813 Window child = cycle.data;
7814 if(child.style.isActiveClient && !child.style.hidden)
7816 if(!firstDocument) firstDocument = child;
7817 if(child.state == minimized)
7818 child.SetState(minimized, false, mods);
7821 child.positionID = id++;
7822 child.SetState(normal, false, mods);
7823 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7825 child.anchor.left.type = hTiled;
7828 child.normalSizeAnchor = *&child.sizeAnchor;
7829 child.normalAnchor = child.anchor;
7831 // Break the anchors for moveable/resizable windows
7832 if(child.style.fixed)
7834 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7836 (*&child.normalAnchor).left = x;
7837 (*&child.normalAnchor).top = y;
7838 (*&child.normalAnchor).right.type = none;
7839 (*&child.normalAnchor).bottom.type = none;
7840 (*&child.normalSizeAnchor).isClientW = false;
7841 (*&child.normalSizeAnchor).isClientH = false;
7842 (*&child.normalSizeAnchor).size.w = w;
7843 (*&child.normalSizeAnchor).size.h = h;
7844 child.anchored = false;
7847 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7849 child.stateAnchor = child.normalAnchor;
7850 child.stateSizeAnchor = child.normalSizeAnchor;
7852 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7853 child.Position(x,y, w, h, true, true, true, true, false, true);
7858 if((cycle = cycle.next) == document.cycle) break;
7861 firstDocument.Activate();
7866 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7868 Window document = activeChild;
7871 Window firstDocument = null;
7873 OldLink cycle = document.cycle;
7878 //if(child.style.isDocument)
7879 if(child.style.isActiveClient && !child.style.hidden)
7881 if(!firstDocument) firstDocument = child;
7882 if(child.state == minimized)
7883 child.SetState(minimized, false, mods);
7886 child.positionID = id++;
7887 child.SetState(normal, false, mods);
7888 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7890 child.anchor.left.type = vTiled;
7893 child.normalSizeAnchor = *&child.sizeAnchor;
7894 child.normalAnchor = child.anchor;
7896 // Break the anchors for moveable/resizable windows
7897 if(child.style.fixed)
7899 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7901 (*&child.normalAnchor).left = x;
7902 (*&child.normalAnchor).top = y;
7903 (*&child.normalAnchor).right.type = none;
7904 (*&child.normalAnchor).bottom.type = none;
7905 (*&child.normalSizeAnchor).isClientW = false;
7906 (*&child.normalSizeAnchor).isClientH = false;
7907 (*&child.normalSizeAnchor).size.w = w;
7908 (*&child.normalSizeAnchor).size.h = h;
7909 child.anchored = false;
7912 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7914 child.stateAnchor = child.normalAnchor;
7915 child.stateSizeAnchor = child.normalSizeAnchor;
7917 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7918 child.Position(x,y, w, h, true, true, true, true, false, true);
7923 if((cycle = cycle.next) == document.cycle) break;
7926 firstDocument.Activate();
7931 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7935 master = this; isModal = true;
7937 void NotifyDestroyed(Window window, DialogResult result)
7939 Window document = (Window)(intptr)result;
7942 if(activeChild.state == maximized)
7943 document.SetState(maximized, false, 0);
7944 else if(document.state == minimized)
7945 document.SetState(normal, false, 0);
7946 document.Activate();
7954 virtual bool OnCreate(void);
7955 virtual void OnDestroy(void);
7956 virtual void OnDestroyed(void);
7957 virtual bool OnClose(bool parentClosing);
7958 virtual bool OnStateChange(WindowState state, Modifiers mods);
7959 virtual bool OnPostCreate(void);
7960 virtual bool OnMoving(int *x, int *y, int w, int h);
7961 virtual bool OnResizing(int *width, int *height);
7962 virtual void OnResize(int width, int height);
7963 virtual void OnPosition(int x, int y, int width, int height);
7964 virtual bool OnLoadGraphics(void);
7965 virtual void OnApplyGraphics(void);
7966 virtual void OnUnloadGraphics(void);
7967 virtual void OnRedraw(Surface surface);
7968 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7969 virtual void OnActivateClient(Window client, Window previous);
7970 virtual bool OnKeyDown(Key key, unichar ch);
7971 virtual bool OnKeyUp(Key key, unichar ch);
7972 virtual bool OnKeyHit(Key key, unichar ch);
7973 virtual bool OnSysKeyDown(Key key, unichar ch);
7974 virtual bool OnSysKeyUp(Key key, unichar ch);
7975 virtual bool OnSysKeyHit(Key key, unichar ch);
7976 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7977 virtual bool OnMouseLeave(Modifiers mods);
7978 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7979 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7980 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7981 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7982 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7983 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7984 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7985 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7986 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7987 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7988 virtual void OnMouseCaptureLost(void);
7989 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7990 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7991 virtual void OnDrawOverChildren(Surface surface);
7992 virtual bool OnFileModified(FileChange fileChange, const char * param);
7993 virtual bool OnSaveFile(const char * fileName);
7995 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7996 // Note: A 'client' would refer to isActiveClient, rather than
7997 // being confined to the 'client area' (nonClient == false)
7998 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7999 virtual void OnChildVisibilityToggled(Window child, bool visible);
8000 virtual void OnChildResized(Window child, int x, int y, int w, int h);
8002 // Skins Virtual Functions
8003 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
8004 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
8005 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
8010 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8011 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8012 virtual bool IsMouseMoving(int x, int y, int w, int h)
8016 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
8020 virtual void UpdateNonClient();
8021 virtual void SetBox(Box box); // This is used in the MySkin skin
8022 virtual bool IsInside(int x, int y)
8024 return box.IsPointInside({x, y});
8026 virtual bool IsOpaque()
8028 return (!style.drawBehind || background.a == 255);
8032 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
8033 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
8034 virtual void Window::NotifySaved(Window window, const char * filePath);
8039 property Window parent
8041 property_category $"Layout"
8044 if(value || guiApp.desktop)
8047 Window oldParent = parent;
8048 Anchor anchor = this.anchor;
8050 if(value && value.IsDescendantOf(this)) return;
8051 if(value && value == this)
8053 if(!value) value = guiApp.desktop;
8055 if(value == oldParent) return;
8057 if(!master || (master == this.parent && master == guiApp.desktop))
8058 property::master = value;
8062 parent.children.Remove(this);
8066 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8067 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
8068 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8069 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8073 last = value.children.last;
8075 if(style.isDocument)
8078 parent.numDocuments--;
8079 documentID = value.GetDocumentID();
8082 if(style.isActiveClient && !style.hidden)
8084 if(parent && parent != guiApp.desktop && !(style.hidden))
8086 if(state == minimized) parent.numIcons--;
8087 parent.numPositions--;
8091 if(!style.stayOnTop)
8092 for(; last && last.style.stayOnTop; last = last.prev);
8094 value.children.Insert(last, this);
8096 // *** NEW HERE: ***
8098 parent.childrenCycle.Delete(cycle);
8100 parent.childrenOrder.Delete(order);
8103 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8104 // Should something else be done?
8105 if(parent && parent.activeChild == this)
8106 parent.activeChild = null;
8107 if(parent && parent.activeClient == this)
8108 parent.activeClient = null;
8114 int x = position.x, y = position.y, w = size.w, h = size.h;
8118 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8119 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8121 vpw = value.clientSize.w;
8122 vph = value.clientSize.h;
8128 else if(style.fixed)
8130 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8131 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8134 anchor = this.anchor;
8136 if(anchor.left.type == offset) anchor.left.distance = x;
8137 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8138 if(anchor.top.type == offset) anchor.top.distance = y;
8139 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8140 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8141 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8142 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8143 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8144 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8145 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8147 if(!anchor.left.type && !anchor.right.type)
8149 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8150 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8152 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8153 if(!anchor.top.type && !anchor.bottom.type)
8155 anchor.vert.distance = (y + h / 2) - (vph / 2);
8156 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8158 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8161 parent.OnChildAddedOrRemoved(this, false);
8167 parent.childrenCycle.Insert(
8168 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8169 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8171 cycle = OldLink { data = this });
8172 parent.childrenOrder.Insert(
8173 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8174 order = OldLink { data = this });
8177 if(!style.hidden && style.isActiveClient)
8179 positionID = parent.GetPositionID(this);
8180 parent.numPositions++;
8181 if(state == minimized) parent.numIcons--;
8184 // *** FONT INHERITANCE ***
8185 if(!setFont && oldParent)
8186 stopwatching(oldParent, font);
8190 RemoveResource(systemFont);
8193 // TESTING WITH WATCHERS:
8194 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8195 // usedFont = setFont ? setFont : (systemFont);
8199 if(guiApp.currentSkin)
8201 systemFont = guiApp.currentSkin.SystemFont();
8204 usedFont = systemFont;
8205 AddResource(systemFont);
8213 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8222 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8224 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8225 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8228 UnloadGraphics(false);
8231 LoadGraphics(false, false);
8234 if(value.rootWindow != rootWindow)
8235 DisplayModeChanged();
8239 scrolledPos.x = MININT; // Prevent parent update
8241 bool anchored = this.anchored;
8242 property::anchor = anchor;
8243 this.anchored = anchored;
8248 if(guiApp.currentSkin)
8249 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8251 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8252 Position(x, y, w, h, true, true, true, true, false, true);
8257 // else parent = value;
8259 oldParent.OnChildAddedOrRemoved(this, true);
8262 get { return parent; }
8265 property Window master
8267 property_category $"Behavior"
8270 //if(this == value) return;
8271 if(value && value.IsSlaveOf(this)) return;
8277 OldLink slaveHolder;
8278 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8279 if(slaveHolder.data == this)
8281 master.slaves.Delete(slaveHolder);
8288 value.slaves.Add(OldLink { data = this });
8293 master.hotKeys.Remove(hotKey);
8294 value.hotKeys.Add(hotKey);
8297 if(master && master.defaultControl == this)
8298 master.defaultControl = null;
8300 if(style.isDefault && !value.defaultControl)
8301 value.defaultControl = this;
8306 get { return master ? master : parent; }
8309 property const char * caption
8311 property_category $"Appearance"
8318 caption = new char[strlen(value)+1];
8320 strcpy(caption, value);
8325 get { return caption; }
8330 property_category $"Behavior"
8339 master.hotKeys.Add(hotKey = HotKeySlot { });
8343 hotKey.window = this;
8348 master.hotKeys.Delete(hotKey);
8353 get { return hotKey ? hotKey.key : 0; }
8356 property Color background
8358 property_category $"Appearance"
8361 background.color = value;
8366 if(this == rootWindow)
8367 guiApp.interfaceDriver.SetRootWindowColor(this);
8370 get { return background.color; }
8373 property Percentage opacity
8375 property_category $"Appearance"
8378 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8379 drawBehind = (background.a == 255) ? false : true;
8381 get { return background.a / 255.0f; }
8384 property Color foreground
8386 property_category $"Appearance"
8394 get { return foreground; }
8397 property BorderStyle borderStyle
8399 property_category $"Appearance"
8402 if(!((BorderBits)value).fixed)
8404 style.hasClose = false;
8405 style.hasMaximize = false;
8406 style.hasMinimize = false;
8407 nativeDecorations = false;
8409 style.borderBits = value;
8413 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8415 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8416 Position(x, y, w, h, true, true, true, true, false, true);
8417 CreateSystemChildren();
8420 get { return (BorderStyle)style.borderBits; }
8423 property Size minClientSize
8425 property_category $"Layout"
8426 set { minSize = value; }
8427 get { value = minSize; }
8430 property Size maxClientSize
8432 property_category $"Layout"
8433 set { maxSize = value; }
8434 get { value = maxSize; }
8437 property bool hasMaximize
8439 property_category $"Window Style"
8442 style.hasMaximize = value;
8443 if(value) { style.fixed = true; style.contour = true; }
8447 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8449 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8450 Position(x, y, w, h, true, true, true, true, false, true);
8452 CreateSystemChildren();
8455 get { return style.hasMaximize; }
8458 property bool hasMinimize
8460 property_category $"Window Style"
8463 style.hasMinimize = value;
8464 if(value) { style.fixed = true; style.contour = true; }
8468 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8470 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8471 Position(x, y, w, h, true, true, true, true, false, true);
8473 CreateSystemChildren();
8476 get { return style.hasMinimize; }
8479 property bool hasClose
8481 property_category $"Window Style"
8484 style.hasClose = value;
8485 if(value) { style.fixed = true; style.contour = true; }
8489 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8490 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8491 Position(x, y, w, h, true, true, true, true, false, true);
8492 CreateSystemChildren();
8495 get { return style.hasClose; }
8498 property bool nonClient
8500 property_category $"Layout"
8503 style.nonClient = value;
8505 style.stayOnTop = true;
8507 get { return style.nonClient; }
8510 property bool inactive
8512 property_category $"Behavior"
8517 // *** NEW HERE: ***
8521 parent.childrenCycle.Delete(cycle);
8523 parent.childrenOrder.Delete(order);
8530 active = false; // true;
8531 if(parent.activeChild == this)
8532 parent.activeChild = null;
8533 if(parent.activeClient == this)
8534 parent.activeClient = null;
8543 parent.childrenCycle.Insert(
8544 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8545 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8547 cycle = OldLink { data = this });
8549 parent.childrenOrder.Insert(
8550 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8551 order = OldLink { data = this });
8554 style.inactive = value;
8556 get { return style.inactive; }
8559 property bool clickThrough
8561 property_category $"Behavior"
8562 set { style.clickThrough = value; }
8563 get { return style.clickThrough; }
8566 property bool isRemote
8568 property_category $"Behavior"
8569 set { style.isRemote = value; }
8570 get { return style.isRemote; }
8573 property bool noCycle
8575 property_category $"Behavior"
8576 set { style.noCycle = value; }
8577 get { return style.noCycle; }
8580 property bool isModal
8582 property_category $"Behavior"
8583 set { style.modal = value; }
8584 get { return style.modal; }
8587 property bool interim
8589 property_category $"Behavior"
8590 set { style.interim = value; }
8591 get { return style.interim; }
8594 property bool tabCycle
8596 property_category $"Behavior"
8597 set { style.tabCycle = value; }
8598 get { return style.tabCycle; }
8601 property bool isDefault
8603 property_category $"Behavior"
8611 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8612 if(sibling != this && sibling.style.isDefault)
8613 sibling.style.isDefault = false;*/
8614 if(master.defaultControl)
8615 master.defaultControl.style.isDefault = false;
8616 master.defaultControl = this;
8618 else if(master.defaultControl == this)
8619 master.defaultControl = null;
8623 style.isDefault = value;
8625 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8627 get { return style.isDefault; }
8630 property bool drawBehind
8632 property_category $"Window Style"
8633 set { style.drawBehind = value; }
8634 get { return style.drawBehind; }
8637 property bool hasMenuBar
8639 property_category $"Window Style"
8649 if(created && !menuBar)
8656 anchor = Anchor { top = 23, left = 1, right = 1 },
8658 inactive = true, nonClient = true
8663 else if(created && menuBar)
8668 style.hasMenuBar = value;
8670 get { return style.hasMenuBar; }
8673 property bool hasStatusBar
8675 property_category $"Window Style"
8682 statusBar = StatusBar { this };
8690 style.hasStatusBar = value;
8692 get { return style.hasStatusBar; }
8694 property bool stayOnTop
8696 property_category $"Window Style"
8701 if(created && !style.stayOnTop)
8703 if(rootWindow == this)
8704 guiApp.interfaceDriver.OrderRootWindow(this, true);
8705 else if(parent.children.last != this)
8707 parent.children.Move(this, parent.children.last);
8711 style.stayOnTop = true;
8715 if(created && style.stayOnTop)
8717 if(rootWindow == this)
8718 guiApp.interfaceDriver.OrderRootWindow(this, false);
8725 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8726 order && ((Window)order.data).style.stayOnTop;
8727 order = (order == parent.childrenOrder.first) ? null : order.prev);
8728 last = order ? order.data : null;
8732 for(last = parent.children.last;
8733 last && last.style.stayOnTop;
8737 parent.children.Move(this, last);
8741 style.stayOnTop = false;
8744 get { return style.stayOnTop; }
8749 property_category $"Window Style"
8759 if(menuBar && !value)
8766 if(!menuBar && style.hasMenuBar && value)
8770 this, menu = value, isMenuBar = true,
8771 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8772 inactive = true, nonClient = true
8776 UpdateActiveDocument(null);
8779 get { return menu; }
8782 property FontResource font
8784 property_category $"Appearance"
8786 isset { return setFont ? true : false; }
8791 if(value && !setFont) { stopwatching(parent, font); }
8792 else if(!value && setFont)
8798 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8807 RemoveResource(setFont);
8812 RemoveResource(systemFont);
8819 AddResource(setFont);
8822 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8825 systemFont = guiApp.currentSkin.SystemFont();
8827 usedFont = systemFont;
8828 AddResource(systemFont);
8836 get { return usedFont; }
8839 property SizeAnchor sizeAnchor
8841 property_category $"Layout"
8844 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8845 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8846 sizeAnchor.isClientW != sizeAnchor.isClientH;
8853 normalSizeAnchor = sizeAnchor;
8855 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8857 stateAnchor = normalAnchor;
8858 stateSizeAnchor = normalSizeAnchor;
8860 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8861 Position(x,y, w, h, true, true, true, true, false, true);
8868 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8869 sizeAnchor.isClientW,
8870 sizeAnchor.isClientH
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;
8888 sizeAnchor.isClientW = false;
8889 sizeAnchor.isClientH = false;
8890 sizeAnchor.size = value;
8892 normalSizeAnchor = sizeAnchor;
8894 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8896 stateAnchor = normalAnchor;
8897 stateSizeAnchor = normalSizeAnchor;
8899 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8900 Position(x, y, w, h, true, true, true, true, false, true);
8901 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8904 get { value = size; }
8907 property Size clientSize
8909 property_category $"Layout"
8912 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8913 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8914 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8919 sizeAnchor.isClientW = true;
8920 sizeAnchor.isClientH = true;
8921 sizeAnchor.size = value;
8923 normalSizeAnchor = sizeAnchor;
8925 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8927 stateAnchor = normalAnchor;
8928 stateSizeAnchor = normalSizeAnchor;
8930 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8931 Position(x,y, w, h, true, true, true, true, false, true);
8932 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8935 get { value = this ? clientSize : { 0, 0 }; }
8938 property Size initSize { get { value = sizeAnchor.size; } };
8940 property Anchor anchor
8942 property_category $"Layout"
8943 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8949 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8951 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8952 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8954 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8956 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8957 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8961 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8963 anchor.left.distance = 0;
8964 anchor.horz.type = 0;
8966 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8968 anchor.top.distance = 0;
8969 anchor.vert.type = 0;
8978 normalAnchor = anchor;
8980 // Break the anchors for moveable/resizable windows
8981 /*if(style.fixed ) //&& value.left.type == cascade)
8983 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8985 this.anchor = normalAnchor = Anchor { left = x, top = y };
8986 normalSizeAnchor = SizeAnchor { { w, h } };
8989 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8991 stateAnchor = normalAnchor;
8992 stateSizeAnchor = normalSizeAnchor;
8994 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8995 Position(x, y, w, h, true, true, true, true, false, true);
9004 get { value = this ? anchor : Anchor { }; }
9007 property Point position
9009 property_category $"Layout"
9012 if(value == null) return;
9014 anchor.left = value.x;
9015 anchor.top = value.y;
9016 anchor.right.type = none;
9017 anchor.bottom.type = none;
9022 normalAnchor = anchor;
9024 // Break the anchors for moveable/resizable windows
9028 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9030 normalAnchor.left = x;
9031 normalAnchor.top = y;
9032 normalAnchor.right.type = none;
9033 normalAnchor.bottom.type = none;
9034 normalSizeAnchor.size.width = w;
9035 normalSizeAnchor.size.height = h;
9039 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9041 stateAnchor = normalAnchor;
9042 stateSizeAnchor = normalSizeAnchor;
9044 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9045 Position(x,y, w, h, true, true, true, true, false, true);
9049 get { value = position; }
9052 property bool disabled
9054 property_category $"Behavior"
9057 if(this && disabled != value)
9064 get { return (bool)disabled; }
9067 property bool isEnabled
9072 for(parent = this; parent; parent = parent.parent)
9079 property WindowState state
9081 property_category $"Behavior"
9082 set { SetState(value, false, 0); }
9083 get { return this ? state : 0; }
9086 property bool visible
9088 property_category $"Behavior"
9091 if(this && !value && !style.hidden && parent)
9093 bool wasActiveChild = parent.activeChild == this;
9094 Window client = null;
9096 style.hidden = true;
9097 if(style.isActiveClient)
9099 parent.numPositions--;
9100 if(state == minimized) parent.numIcons--;
9105 OldLink prevOrder = null;
9107 if(rootWindow == this)
9108 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9111 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9114 box.left -= parent.clientStart.x;
9115 box.top -= parent.clientStart.y;
9116 box.right -= parent.clientStart.x;
9117 box.bottom -= parent.clientStart.y;
9121 if(_isModal && master && master.modalSlave == this)
9122 master.modalSlave = null;
9126 OldLink tmpPrev = order.prev;
9127 client = tmpPrev ? tmpPrev.data : null;
9128 if(client && !client.style.hidden && !client.destroyed && client.created)
9129 prevOrder = tmpPrev;
9132 client = tmpPrev ? tmpPrev.data : null;
9133 if(client == this) { client = null; break; }
9134 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9136 tmpPrev = client.order.prev;
9141 prevOrder = tmpPrev;
9146 // If this window can be an active client, make sure the next window we activate can also be one
9147 if(!style.nonClient && style.isActiveClient)
9149 tmpPrev = prevOrder;
9152 client = tmpPrev ? tmpPrev.data : null;
9153 if(client == this) { client = null; break; }
9154 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9156 tmpPrev = client.order.prev;
9161 prevOrder = tmpPrev;
9165 if(client && client.style.hidden) client = null;
9169 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9171 if(order && prevOrder && prevOrder.data != this)
9172 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9174 ActivateEx(false, false, false, true, null, null);
9176 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9177 if(parent.activeClient == this)
9179 parent.activeClient = null;
9180 parent.UpdateActiveDocument(null);
9183 else if(parent.activeClient == this)
9185 parent.activeClient = client;
9186 parent.UpdateActiveDocument(this);
9189 // *** Not doing this anymore ***
9192 parent.childrenCycle.Delete(cycle);
9194 parent.childrenOrder.Delete(order);
9199 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9204 else if(this && value && style.hidden)
9206 style.hidden = false;
9209 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9210 if(rootWindow == this)
9211 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9213 if(_isModal && master)
9214 master.modalSlave = this;
9216 if(style.isActiveClient)
9218 positionID = parent.GetPositionID(this);
9219 parent.numPositions++;
9220 if(state == minimized) parent.numIcons++;
9223 // *** NOT DOING THIS ANYMORE ***
9225 if(!(style.inactive))
9227 if(!(style.noCycle))
9229 cycle = parent.childrenCycle.AddAfter(
9230 (parent.activeChild && parent.activeChild.cycle) ?
9231 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9234 order = parent.childrenOrder.AddAfter(
9235 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9242 if(true || !parent.activeChild)
9243 ActivateEx(true, false, true, true, null, null);
9245 if(creationActivation == activate && guiApp.desktop.active)
9246 ActivateEx(true, false, true, true, null, null);
9247 else if((creationActivation == activate || creationActivation == flash) && !object)
9250 if(this == rootWindow)
9254 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9258 ConsequentialMouseMove(false);
9264 style.hidden = !value;
9267 get { return (style.hidden || !setVisible) ? false : true; }
9270 property bool isDocument
9272 property_category $"Document"
9273 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9274 get { return style.isDocument; }
9277 property bool mergeMenus
9279 property_category $"Window Style"
9280 set { mergeMenus = value; }
9281 get { return (bool)mergeMenus; }
9284 property bool hasHorzScroll
9286 property_category $"Window Style"
9291 if(!style.hasHorzScroll && created)
9293 CreateSystemChildren();
9294 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9297 else if(style.hasHorzScroll)
9301 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9303 style.hasHorzScroll = value;
9306 get { return style.hasHorzScroll; }
9309 property bool hasVertScroll
9311 property_category $"Window Style"
9316 if(!style.hasVertScroll && created)
9318 style.hasVertScroll = true;
9319 CreateSystemChildren();
9320 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9323 else if(style.hasVertScroll)
9327 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9329 style.hasVertScroll = value;
9331 get { return style.hasVertScroll; }
9334 property bool dontHideScroll
9336 property_category $"Behavior"
9339 scrollFlags.dontHide = value;
9342 //UpdateScrollBars(true, true);
9343 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9347 // UpdateScrollBars(true, true);
9348 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9351 get { return scrollFlags.dontHide; }
9354 property bool dontScrollVert
9356 property_category $"Behavior"
9357 set { style.dontScrollVert = value; }
9358 get { return style.dontScrollVert; }
9360 property bool dontScrollHorz
9362 property_category $"Behavior"
9363 set { style.dontScrollHorz = value; }
9364 get { return style.dontScrollHorz; }
9367 property bool snapVertScroll
9369 property_category $"Behavior"
9372 scrollFlags.snapY = value;
9373 if(sbv) sbv.snap = value;
9375 get { return scrollFlags.snapY; }
9377 property bool snapHorzScroll
9379 property_category $"Behavior"
9382 scrollFlags.snapX = value;
9383 if(sbh) sbh.snap = value;
9385 get { return scrollFlags.snapX; }
9388 property Point scroll
9390 property_category $"Behavior"
9391 set { if(this) SetScrollPosition(value.x, value.y); }
9392 get { value = scroll; }
9395 property bool modifyVirtualArea
9397 property_category $"Behavior"
9398 set { modifyVirtArea = value; }
9399 get { return (bool)modifyVirtArea; }
9402 property bool dontAutoScrollArea
9404 property_category $"Behavior"
9405 // Activating a child control out of view will automatically scroll to make it in view
9406 set { noAutoScrollArea = value; }
9407 get { return (bool)noAutoScrollArea; }
9410 property const char * fileName
9412 property_category $"Document"
9417 if(menu && ((!fileName && value) || (fileName && !value)))
9419 MenuItem item = menu.FindItem(MenuFileSave, 0);
9420 if(item) item.disabled = !modifiedDocument && value;
9425 if(value && value[0])
9426 fileName = CopyString(value);
9428 if(parent && this == parent.activeClient)
9429 parent.UpdateActiveDocument(null);
9433 // if(style.isDocument)
9434 #if !defined(__EMSCRIPTEN__)
9436 fileMonitor.fileName = value;
9439 get { return fileName; }
9444 property_category $"Data"
9449 property bool modifiedDocument
9451 property_category $"Document"
9454 if(style.isDocument || fileName)
9458 MenuItem item = menu.FindItem(MenuFileSave, 0);
9459 if(item) item.disabled = !value && fileName;
9463 if(modifiedDocument != value)
9465 modifiedDocument = value;
9466 if(style.isDocument || fileName)
9470 get { return (bool)modifiedDocument; }
9473 property bool showInTaskBar
9475 property_category $"Window Style"
9478 style.showInTaskBar = value;
9479 #if defined(__WIN32__)
9480 Win32UpdateStyle(this);
9483 get { return style.showInTaskBar; }
9485 property FileDialog saveDialog { set { saveDialog = value; } };
9486 property bool isActiveClient
9488 property_category $"Behavior"
9491 if(parent && style.isActiveClient != value && !style.hidden)
9495 if(state == minimized) parent.numIcons++;
9496 parent.numPositions++;
9500 if(state == minimized) parent.numIcons--;
9501 parent.numPositions--;
9504 style.isActiveClient = value;
9506 get { return style.isActiveClient; }
9509 property Cursor cursor
9511 property_category $"Appearance"
9515 SelectMouseCursor();
9517 get { return cursor; }
9520 //#if !defined(ECERE_VANILLA)
9521 property const char * name
9523 property_category $"Design"
9526 return (this && object) ? object.name : null;
9531 activeDesigner.RenameObject(object, value);
9535 property const char * displayDriver
9537 property_category $"Behavior"
9540 dispDriver = GetDisplayDriver(value);
9541 //DisplayModeChanged();
9545 return dispDriver ? dispDriver.name : null;
9549 // RUNTIME PROPERTIES
9550 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9551 property Size scrollArea
9553 property_category $"Behavior"
9557 SetScrollArea(value.w, value.h, false);
9559 SetScrollArea(0,0, true);
9561 get { value = scrollArea; }
9564 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9569 property_category $"Layout"
9570 set { if(this) is3D = value; }
9571 get { return (bool)is3D; }
9574 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9576 // Will be merged with font later
9577 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9578 property Point clientStart { get { value = clientStart; } };
9579 property Point absPosition { get { value = absPosition; } };
9580 property Anchor normalAnchor { get { value = normalAnchor; } };
9581 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9582 property bool active { get { return (bool)active; } };
9583 property bool created { get { return (bool)created; } };
9584 property bool destroyed { get { return (bool)destroyed; } };
9585 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9586 property Window firstChild { get { return children.first; } };
9587 property Window lastChild { get { return children.last; } };
9588 property Window activeClient { get { return activeClient; } };
9589 property Window activeChild { get { return activeChild; } };
9590 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9591 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9592 property ScrollBar horzScroll { get { return sbh; } };
9593 property ScrollBar vertScroll { get { return sbv; } };
9594 property StatusBar statusBar { get { return statusBar; } };
9595 property Window rootWindow { get { return rootWindow; } };
9596 property bool closing { get { return (bool)closing; } set { closing = value; } };
9597 property int documentID { get { return documentID; } };
9598 property Window previous { get { return prev; } }
9599 property Window next { get { return next; } }
9600 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9601 property PopupMenu menuBar { get { return menuBar; } }
9602 property ScrollBar sbv { get { return sbv; } }
9603 property ScrollBar sbh { get { return sbh; } }
9604 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9605 property void * systemHandle { get { return windowHandle; } }
9606 property Button minimizeButton { get { return sysButtons[0]; } };
9607 property Button maximizeButton { get { return sysButtons[1]; } };
9608 property Button closeButton { get { return sysButtons[2]; } };
9609 property BitmapResource icon
9611 get { return icon; }
9615 if(icon) incref icon;
9617 guiApp.interfaceDriver.SetIcon(this, value);
9620 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9621 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9622 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9623 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9624 property bool nativeDecorations
9626 get { return (bool)nativeDecorations; }
9627 set { nativeDecorations = value; }
9628 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9631 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9632 bool result = false;
9633 if(nativeDecorations)
9635 if(rootWindow == this)
9639 if(formDesigner && activeDesigner)
9641 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9642 Window form = cd ? cd.form : null;
9643 if(form && parent == form.parent)
9648 return result != style.fixed;
9652 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9654 property const char * text
9656 property_category $"Deprecated"
9658 set { property::caption = value; }
9659 get { return property::caption; }
9665 WindowBits style; // Window Style
9666 char * caption; // Name / Caption
9667 Window parent; // Parent window
9668 OldList children; // List of children in Z order
9669 Window activeChild; // Child window having focus
9670 Window activeClient;
9671 Window previousActive; // Child active prior to activating the default child
9672 Window master; // Window owning and receiving notifications concerning this window
9673 OldList slaves; // List of windows belonging to this window
9674 Display display; // Display this window is drawn into
9676 Point position; // Position in parent window client area
9677 Point absPosition; // Absolute position
9678 Point clientStart; // Client area position from (0,0) in this window
9680 Size clientSize; // Client area size
9681 Size scrollArea; // Virtual Scroll area size
9682 Size reqScrollArea; // Requested virtual area size
9683 Point scroll; // Virtual area scrolling position
9684 ScrollBar sbh, sbv; // Scrollbar window handles
9685 Cursor cursor; // Mouse cursor used for this window
9688 StatusBar statusBar;
9689 Button sysButtons[3];
9691 Box clientArea; // Client Area box clipped to parent
9693 HotKeySlot hotKey; // HotKey for this window
9697 ScrollFlags scrollFlags;// Window Scrollbar Flags
9698 int64 id; // Control ID
9700 ColorAlpha background; // Background color used to draw the window area
9702 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9703 OldList childrenCycle; // Cycling order
9704 OldLink cycle; // Element of parent's cycling order
9705 OldList childrenOrder; // Circular Z-Order
9706 OldLink order; // Element of parent's circular Z-Order
9707 Window modalSlave; // Slave window blocking this window's interaction
9709 Window rootWindow; // Topmost system managed window
9710 void * windowHandle; // System window handle
9712 DialogResult returnCode;// Return code for modal windows
9714 Point sbStep; // Scrollbar line scrolling steps
9717 SizeAnchor stateSizeAnchor;
9719 Anchor normalAnchor;
9720 SizeAnchor normalSizeAnchor;
9722 Size skinMinSize; // Minimal window size based on style
9723 Point scrolledPos; // Scrolled position
9724 Box box; // Window box clipped to parent
9725 Box * against; // What to clip the box to
9727 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9728 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9729 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9730 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9731 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9732 Point scrolledArea; // Distance to scroll area by
9733 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9735 OldList hotKeys; // List of the hotkeys of all children
9736 Window defaultControl; // Default child control
9740 ColorAlpha * palette; // Color palette used for this window
9742 int caretSize; // Size of caret, non zero if a caret is present
9743 Point caretPos; // Caret position
9745 void * systemParent; // Parent System Window for embedded windows
9751 #if !defined(__EMSCRIPTEN__)
9754 WindowState lastState;
9756 #if !defined(__EMSCRIPTEN__)
9757 FileMonitor fileMonitor;
9760 FontResource setFont, systemFont;
9761 FontResource usedFont;
9762 FontResource captionFont;
9764 FileDialog saveDialog;
9766 SizeAnchor sizeAnchor;
9768 // FormDesigner data
9771 Extent * tempExtents; //[4];
9772 BitmapResource icon;
9774 CreationActivationOption creationActivation;
9777 bool active:1; // true if window and ancestors are active
9778 bool acquiredInput:1; // true if the window is processing state based input
9779 bool modifiedDocument:1;
9780 bool disabled:1; // true if window cannot interact
9781 bool isForegroundWindow:1;// true while a root window is being activated
9782 bool visible:1; // Visibility flag
9783 bool destroyed:1; // true if window is being destroyed
9784 bool anchored:1; // true if this window is repositioned when the parent resizes
9785 bool dirty:1; // Flag set to true if any descendant must be redrawn
9791 bool modifyVirtArea:1;
9792 bool noAutoScrollArea:1;
9795 bool setVisible:1; // FOR FORM DESIGNER
9801 bool useSharedMemory:1;
9804 bool nativeDecorations:1;
9805 bool manageDisplay:1;
9806 bool formDesigner:1; // True if we this is running in the form editor
9807 bool requireRemaximize:1;
9810 // Checks used internally for them not to take effect in FormDesigner
9811 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9812 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9814 WindowController controller;
9815 public property WindowController controller
9817 get { return controller; }
9821 controller.setWindow(null);
9827 controller.setWindow(this);
9833 public class CommonControl : Window
9835 // creationActivation = doNothing;
9838 public property const String toolTip
9840 property_category $"Appearance"
9843 if(created) CommonControl::OnDestroy();
9845 toolTip = value ? ToolTip { tip = value; } : null;
9847 if(created) CommonControl::OnCreate();
9849 get { return toolTip ? toolTip.tip : null; }
9855 // (Very) Ugly work around for the fact that the parent watcher
9856 // won't fire when it's already been disconnected...
9857 eInstance_FireSelfWatchers(toolTip,
9858 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9864 toolTip.parent = this;
9873 public class Percentage : float
9875 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9879 sprintf(string, "%.2f", this);
9880 c = strlen(string)-1;
9883 if(string[c] != '0')
9884 last = Max(last, c);
9885 if(string[c] == '.')
9898 public void ApplySkin(Class c, const char * name, void ** vTbl)
9900 char className[1024];
9905 subclass(Window) wc = (subclass(Window))c;
9906 subclass(Window) base = (subclass(Window))c.base;
9908 sprintf(className, "%sSkin_%s", name, c.name);
9909 wc.pureVTbl = c._vTbl;
9910 c._vTbl = new void *[c.vTblSize];
9911 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9912 sc = eSystem_FindClass(c.module.application, className);
9916 for(m = 0; m < c.base.vTblSize; m++)
9918 if(c._vTbl[m] == base.pureVTbl[m])
9919 c._vTbl[m] = vTbl[m];
9924 for(m = 0; m < c.vTblSize; m++)
9926 if(sc._vTbl[m] != wc.pureVTbl[m])
9927 c._vTbl[m] = sc._vTbl[m];
9931 for(d = c.derivatives.first; d; d = d.next)
9933 ApplySkin(d.data, name, c._vTbl);
9937 public void UnapplySkin(Class c)
9939 subclass(Window) wc = (subclass(Window))c;
9942 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9945 c._vTbl = wc.pureVTbl;
9949 for(d = c.derivatives.first; d; d = d.next)
9951 UnapplySkin(d.data);
9955 void CheckFontIntegrity(Window window)
9960 if(window.usedFont && window.usedFont.font == 0xecececec)
9962 FontResource uf = window.usedFont;
9963 char * className = window._class.name;
9964 char * text = window.text;
9967 for(c = window.firstChild; c; c = c.next)
9968 CheckFontIntegrity(c);
9972 public class ControllableWindow : Window
9974 /*WindowController controller;
9975 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9976 ~ControllableWindow() { delete controller; }*/
9979 class WindowControllerInterface : ControllableWindow
9981 bool OnKeyDown(Key key, unichar ch)
9983 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9986 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9988 result = onKeyDown(controller.window, key, ch);
9993 bool OnKeyUp(Key key, unichar ch)
9995 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
9998 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
10000 result = onKeyUp(controller.window, key, ch);
10005 bool OnKeyHit(Key key, unichar ch)
10007 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
10010 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
10012 result = onKeyHit(controller.window, key, ch);
10017 bool OnMouseMove(int x, int y, Modifiers mods)
10019 bool result = controller.OnMouseMove ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods) : true;
10022 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
10024 result = onMouseMove(controller.window, x, y, mods);
10029 bool OnLeftButtonDown(int x, int y, Modifiers mods)
10031 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10034 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
10035 if(onLeftButtonDown)
10036 result = onLeftButtonDown(controller.window, x, y, mods);
10041 bool OnLeftButtonUp(int x, int y, Modifiers mods)
10043 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10046 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
10048 result = onLeftButtonUp(controller.window, x, y, mods);
10053 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
10055 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10058 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
10059 if(onLeftDoubleClick)
10060 result = onLeftDoubleClick(controller.window, x, y, mods);
10065 bool OnRightButtonDown(int x, int y, Modifiers mods)
10067 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10070 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
10071 if(onRightButtonDown)
10072 result = onRightButtonDown(controller.window, x, y, mods);
10077 bool OnRightButtonUp(int x, int y, Modifiers mods)
10079 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10082 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
10083 if(onRightButtonUp)
10084 result = onRightButtonUp(controller.window, x, y, mods);
10089 bool OnRightDoubleClick(int x, int y, Modifiers mods)
10091 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10094 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
10095 if(onRightDoubleClick)
10096 result = onRightDoubleClick(controller.window, x, y, mods);
10101 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10103 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10106 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10107 if(onMiddleButtonDown)
10108 result = onMiddleButtonDown(controller.window, x, y, mods);
10113 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10115 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10118 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10119 if(onMiddleButtonUp)
10120 result = onMiddleButtonUp(controller.window, x, y, mods);
10125 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10127 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10130 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10131 if(onMiddleDoubleClick)
10132 onMiddleDoubleClick(controller.window, x, y, mods);
10137 void OnResize(int width, int height)
10139 if(controller.OnResize)
10140 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10142 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10144 onResize(controller.window, width, height);
10148 void OnRedraw(Surface surface)
10150 if(controller.OnRedraw)
10151 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10153 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10155 onRedraw(controller.window, surface);
10161 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10164 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10166 result = onCreate(controller.window);
10171 bool OnLoadGraphics()
10173 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10176 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10178 result = onLoadGraphics(controller.window);
10183 void OnUnloadGraphics()
10185 if(controller.OnUnloadGraphics)
10186 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10188 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10189 if(onUnloadGraphics)
10190 onUnloadGraphics(controller.window);
10195 public class WindowController<class V>
10197 void setWindow(Window value)
10199 uint size = class(Window).vTblSize;
10203 windowVTbl = new void *[size];
10204 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10205 if(value._vTbl == value._class._vTbl)
10207 value._vTbl = new void *[value._class.vTblSize];
10208 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10212 for(c = 0; c < size; c++)
10214 void * function = class(WindowControllerInterface)._vTbl[c];
10215 if(function && function != DefaultFunction)
10216 value._vTbl[c] = function;
10218 value._vTbl[c] = windowVTbl[c];
10224 memcpy(window._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10230 property Window window
10232 get { return window; }
10234 property V controlled
10236 set { controlled = value; }
10237 get { return controlled; }
10239 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10240 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10241 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10242 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10243 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10244 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10245 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10246 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10247 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10248 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10249 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10250 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10251 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10252 virtual void V::OnResize(WindowController controller, int width, int height);
10253 virtual void V::OnRedraw(WindowController controller, Surface surface);
10254 virtual bool V::OnCreate(WindowController controller);
10255 virtual bool V::OnLoadGraphics(WindowController controller);
10256 virtual void V::OnUnloadGraphics(WindowController controller);
10259 public int (** windowVTbl)();
10263 ~WindowController()