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;
494 public struct TouchPointerInfo
498 float size, pressure;
501 public enum TouchPointerEvent { move, up, down, pointerUp, pointerDown };
506 class_data const char * icon;
508 class_default_property caption;
509 // class_initialize GuiApplication::Initialize;
510 class_designer FormDesigner;
511 class_property const char * icon
513 set { class_data(icon) = value; }
514 get { return class_data(icon); }
519 bool switchMode = true;
520 #if defined(__ANDROID__)
525 guiApp.Initialize(switchMode);
527 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
529 if(_vTbl == ((subclass(Window))_class).pureVTbl)
531 _vTbl = _class._vTbl;
533 else if(_vTbl != _class._vTbl)
536 for(m = 0; m < _class.vTblSize; m++)
538 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
539 _vTbl[m] = _class._vTbl[m];
544 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
545 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
546 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
547 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
551 // caption = CopyString(class.name);
553 children.offset = (byte*)&prev - (byte*)this;
554 childrenOrder.circ = true;
555 childrenCycle.circ = true;
557 maxSize = Size { MAXINT, MAXINT };
561 //style.isActiveClient = true;
564 modifyVirtArea = true;
565 manageDisplay = true;
566 nativeDecorations = true;
568 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
569 sbStep.x = sbStep.y = 8;
571 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
573 cursor = guiApp.GetCursor(arrow);
574 property::parent = guiApp.desktop;
586 int i, lockCount = guiApp.lockMutex.lockCount;
587 for(i = 0; i < lockCount; i++)
588 guiApp.lockMutex.Release();
590 for(i = 0; i < lockCount; i++)
591 guiApp.lockMutex.Wait();
596 stopwatching(parent, font);
597 if(parent.activeChild == this)
598 parent.activeChild = null;
599 if(parent.activeClient == this)
600 parent.activeClient = null;
605 // Prevent destructor from being called again...
611 /////////////////////////////////
614 OldLink slave = master.slaves.FindLink(this);
615 master.slaves.Delete(slave);
622 parent.childrenCycle.Remove(cycle);
624 parent.childrenOrder.Remove(order);
625 parent.children.Remove(this);
630 /////////////////////////////////
632 while((ptr = resources.first))
635 resources.Delete(ptr);
642 for(child = children.first; child; child = child.next)
644 // child.stopwatching(this, font);
646 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
647 // Don't want property here
648 *&child.parent = null;
651 while((slave = slaves.first))
653 // Don't want property here
654 *&((Window)slave.data).master = null;
655 slaves.Delete(slave);
658 // Because we do a decref in DestroyEx...
666 // Why was this commented?
667 //if(this != guiApp.desktop)
680 if(((subclass(Window))_class).pureVTbl)
682 if(_vTbl == _class._vTbl)
684 _vTbl = ((subclass(Window))_class).pureVTbl;
689 for(m = 0; m < _class.vTblSize; m++)
691 if(_vTbl[m] == _class._vTbl[m])
692 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
696 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
699 dirtyArea.Free(null);
700 renderArea.Free(null);
701 overRenderArea.Free(null);
702 clipExtent.Free(null);
703 scrollExtent.Free(null);
704 dirtyBack.Free(null);
708 tempExtents[0].Free(null);
709 tempExtents[1].Free(null);
710 tempExtents[2].Free(null);
711 tempExtents[3].Free(null);
718 //#if !defined(ECERE_VANILLA)
719 const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
721 if(this == activeDesigner)
725 const char * name = property::name;
726 return name ? name : "";
731 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
732 bool OnGetDataFromString(const char * string)
734 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
737 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
738 this = designer.form;
739 else if(!strcmpi(string, "(Desktop)"))
740 this = activeDesigner;
742 return activeDesigner.FindObject(&this, string);
748 // --- Window updates system ---
750 // Setup a bitmap for Redrawing on client area of Window
751 Surface Redraw(Box box)
753 Surface surface = null;
755 Box clientArea = this.clientArea;
759 mox.left -= clientStart.x;
760 mox.top -= clientStart.y;
761 mox.right -= clientStart.x;
762 mox.bottom -= clientStart.y;
764 mox.Clip(clientArea);
765 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
767 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
769 int x = absPosition.x + clientStart.x;
770 int y = absPosition.y + clientStart.y;
771 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
773 x -= rootWindow.clientStart.x;
774 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
776 if(!guiApp.fullScreenMode || is3D)
778 x -= rootWindow.absPosition.x;
779 y -= rootWindow.absPosition.y;
783 int dx = rootWindow.parent.parent.clientStart.x;
784 int dy = rootWindow.parent.parent.clientStart.y;
785 if(!rootWindow.parent.nativeDecorations)
787 dx += rootWindow.parent.clientStart.x;
788 dy += rootWindow.parent.clientStart.y;
802 surface = display.GetSurface(x, y, mox);
805 surface.width = clientSize.w;
806 surface.height = clientSize.h;
812 // Setup a bitmap for Redrawing on full Window
813 Surface RedrawFull(Box box)
815 Surface surface = null;
823 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
825 int x = absPosition.x;
826 int y = absPosition.y;
827 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
829 x -= rootWindow.clientStart.x;
830 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
832 if(!guiApp.fullScreenMode || is3D)
834 x -= rootWindow.absPosition.x;
835 y -= rootWindow.absPosition.y;
838 int dx = rootWindow.parent.parent.clientStart.x;
839 int dy = rootWindow.parent.parent.clientStart.y;
840 if(!rootWindow.parent.nativeDecorations)
842 dx += rootWindow.parent.clientStart.x;
843 dy += rootWindow.parent.clientStart.y;
857 surface = display.GetSurface(x, y, mox);
860 surface.width = size.w;
861 surface.height = size.h;
867 void FigureCaption(char * caption)
869 Window activeClient = null;
873 strcpy(caption, this.caption);
874 if(style.isDocument || fileName)
876 if(caption[0]) strcat(caption, " - ");
878 strcat(caption, fileName);
882 sprintf(title, "Untitled %d", documentID);
883 strcat(caption, title);
886 strcat(caption, " *");
891 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
893 if(activeClient && activeClient.state == maximized)
895 if(activeClient.caption)
897 if(caption[0]) strcat(caption, " - ");
898 strcat(caption, activeClient.caption);
900 if(activeClient.style.isDocument || activeClient.fileName)
902 if(caption[0]) strcat(caption, " - ");
903 strcat(caption, "[");
904 if(activeClient.fileName)
905 strcat(caption, activeClient.fileName);
909 sprintf(title, "Untitled %d", activeClient.documentID);
910 strcat(caption, title);
912 if(activeClient.modifiedDocument)
913 strcat(caption, " *");
914 strcat(caption, "]");
919 // Code for returning dirty from ScrollDisplay:
921 for(d = 0; d<scrollExtent.count; d++)
923 Box * box = &scrollExtent.boxes[d];
929 Min(box.right, box.left-scroll.x),box.bottom
931 dirtyArea.UnionBox(update);
937 Max(box.left, box.right-scroll.x), box.top,
938 box.right, box.bottom
940 dirtyArea.UnionBox(update);
948 box.right, Min(box.bottom, box.top-scroll.y),
950 dirtyArea.UnionBox(update);
956 box.left, Max(box.top, box.bottom-scroll.y),
957 box.right, box.bottom
959 dirtyArea.UnionBox(update);
964 void UpdateDecorations(void)
966 // TODO: *** TEMPORARY HACK ***
973 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
975 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
977 Update({ -clientStart.x,0, -1, clientSize.h-1 });
979 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
982 // Returns w & h for Position
983 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
985 Window parent = this.parent ? this.parent : guiApp.desktop;
986 int xOffset = 0, yOffset = 0;
987 int vpw = parent ? parent.clientSize.w : 0;
988 int vph = parent ? parent.clientSize.h : 0;
989 int pw = parent ? parent.clientSize.w : 0;
990 int ph = parent ? parent.clientSize.h : 0;
991 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
992 int x = anchor.left.distance, y = anchor.top.distance;
993 float ex = 0, ey = 0;
994 MinMaxValue ew = 0, eh = 0;
996 float cascadeW, cascadeH;
998 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
999 int addX = 0, addY = 0;
1001 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
1003 Window masterWindow = this;
1004 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
1007 if(master == guiApp.desktop)
1008 masterWindow = guiApp.desktop.activeChild;
1010 masterWindow = master.rootWindow;
1011 if(!masterWindow) masterWindow = this;
1013 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
1014 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
1017 pw = vpw = box.right - box.left + 1;
1019 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
1022 ph = vph = box.bottom - box.top + 1;
1038 vpw = pw = parent.size.w;
1039 vph = ph = parent.size.h;
1041 else if(!style.fixed /*|| style.isDocument*/)
1043 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1044 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1046 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1049 Desktop3D_FixSize(&pw, &ph);
1050 Desktop3D_FixSize(&vpw, &vph);
1053 if(pw < skinMinSize.w) pw = skinMinSize.w;
1054 if(ph < skinMinSize.h) ph = skinMinSize.h;
1055 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1056 if(vph < skinMinSize.h) vph = skinMinSize.h;
1058 // TODO: Must fix what we're snapping
1061 if(anchor.left.type)
1063 SNAPUP(x, textCellW);
1065 else if(anchor.right.type)
1067 SNAPDOWN(x, textCellW);
1072 SNAPUP(y, textCellH);
1074 else if(anchor.bottom.type)
1076 SNAPDOWN(y, textCellH);
1080 // This is required to get proper initial decoration size using native decorations on Windows
1081 #if defined(__WIN32__)
1082 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1083 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1085 GetDecorationsSize(&ew, &eh);
1087 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1089 // Leave room for non client windows (eventually dockable panels)
1091 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1092 for(win = parent.children.first; win; win = win.next)
1094 if(!win.nonClient && !win.isActiveClient && win.visible)
1096 Size size = win.size;
1097 Point pos = win.position;
1098 int left = pos.x, top = pos.y;
1099 int right = pos.x + size.w, bottom = pos.y + size.h;
1100 if(win.size.w > win.size.h)
1103 loY = Max(loY, bottom);
1104 else if(top > ph - ph / 4)
1105 hiY = Min(hiY, top);
1110 loX = Max(loX, right);
1111 else if(left > pw - pw / 4)
1112 hiX = Min(hiX, left);
1121 if(parent.sbv && !parent.sbv.style.hidden)
1122 pw += guiApp.currentSkin.VerticalSBW();
1123 if(parent.sbh && !parent.sbh.style.hidden)
1124 ph += guiApp.currentSkin.HorizontalSBH();
1126 if(anchor.left.type == cascade)
1128 w = (int)(pw * 0.80);
1129 h = (int)(ph * 0.80);
1131 else if(anchor.left.type >= vTiled)
1136 numTiling = parent.numPositions - parent.numIcons;
1137 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1138 if(anchor.left.type == vTiled)
1140 tilingH = (int)sqrt(numTiling);
1141 tilingW = numTiling / tilingH;
1145 tilingW = (int)sqrt(numTiling);
1146 tilingH = numTiling / tilingW;
1149 leftOver = numTiling - tilingH * tilingW;
1152 tilingSplit = (tilingW - leftOver) * tilingH;
1153 tilingLastH = tilingH+1;
1156 tilingSplit = numTiling;
1158 if(positionID >= tilingSplit)
1160 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1161 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1162 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1163 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1167 x = xOffset + pw * (positionID / tilingH) / tilingW;
1168 y = yOffset + ph * (positionID % tilingH) / tilingH;
1169 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1170 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1174 SNAPDOWN(x, textCellW);
1175 SNAPDOWN(y, textCellH);
1176 SNAPDOWN(x2, textCellW);
1177 SNAPDOWN(y2, textCellH);
1185 if(sizeAnchor.isClientW) w += ew;
1186 if(sizeAnchor.isClientH) h += eh;
1188 if(anchor.left.type == offset)
1189 x = anchor.left.distance;
1190 else if(anchor.left.type == relative)
1191 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1192 else if(anchor.right.type == relative)
1193 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1194 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1195 else if(anchor.right.type == offset)
1196 ex = vpw - anchor.right.distance;
1198 if(anchor.top.type == offset)
1199 y = anchor.top.distance;
1200 else if(anchor.top.type == relative)
1201 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1202 else if(anchor.bottom.type == relative)
1203 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1204 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1205 else if(anchor.bottom.type == offset)
1206 ey = vph - anchor.bottom.distance;
1208 if(anchor.left.type && anchor.right.type)
1210 switch(anchor.right.type)
1213 ex = pw * (1.0f-anchor.right.percent);
1214 w = Max((int)(ex + 0.5) - x, 0);
1217 ex = vpw - anchor.right.distance;
1218 w = Max((int)(ex + 0.5) - x, 0);
1222 if(anchor.top.type && anchor.bottom.type)
1224 switch(anchor.bottom.type)
1227 ey = ph * (1.0f-anchor.bottom.percent);
1228 h = Max((int)(ey + 0.5) - y, 0);
1231 ey = vph - anchor.bottom.distance;
1232 h = Max((int)(ey + 0.5) - y, 0);
1241 if(state == normal /*|| state == Hidden*/)
1243 bool addSbV = false, addSbH = false;
1245 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1246 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1248 w = Max(w, minSize.w);
1249 h = Max(h, minSize.h);
1250 w = Min(w, maxSize.w);
1251 h = Min(h, maxSize.h);
1253 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1255 if(w) w -= guiApp.currentSkin.VerticalSBW();
1258 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1260 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1264 if(!OnResizing(&w, &h))
1270 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1271 w += guiApp.currentSkin.VerticalSBW();
1272 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1273 h += guiApp.currentSkin.HorizontalSBH();
1275 w = Max(w, skinMinSize.w);
1276 h = Max(h, skinMinSize.h);
1289 SNAPDOWN(w, textCellW);
1290 SNAPDOWN(h, textCellH);
1293 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1295 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1298 (pw - w) / CASCADE_SPACE,
1299 (ph - h) / CASCADE_SPACE);
1305 cascW = (pw - w) / (numCascade-1);
1306 cascH = (ph - h) / (numCascade-1);
1307 SNAPDOWN(cascW, textCellW);
1308 SNAPDOWN(cascH, textCellH);
1309 cascadeW = (float)cascW;
1310 cascadeH = (float)cascH;
1314 numCascade = Max(numCascade, 2);
1315 cascadeW = (float)(pw - w) / (numCascade-1);
1316 cascadeH = (float)(ph - h) / (numCascade-1);
1319 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1320 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1322 else if(anchor.left.type < vTiled)
1324 if(!anchor.left.type || anchor.horz.type == middleRelative)
1326 if(!anchor.right.type)
1328 if(anchor.horz.type == middleRelative)
1329 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1331 x = vpw / 2 + anchor.horz.distance - w / 2;
1337 // case A_EDGE: x = x - w; break;
1339 if(!anchor.top.type || anchor.vert.type == middleRelative)
1341 if(!anchor.bottom.type)
1343 if(anchor.vert.type == middleRelative)
1344 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1346 y = vph / 2 + anchor.vert.distance - h / 2;
1352 // case A_EDGE: y = y - h; break;
1355 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1363 SNAPDOWN(x, textCellW);
1364 SNAPDOWN(y, textCellH);
1376 if(anchored && style.fixed && style.isActiveClient)
1381 void UpdateCaret(bool forceUpdate, bool erase)
1383 static Window lastWindow = null;
1384 static int caretX, caretY, caretSize;
1386 if(guiApp && guiApp.caretOwner == this)
1388 int x = caretPos.x - scroll.x;
1389 int y = caretPos.y - scroll.y;
1391 if((erase || this.caretSize) &&
1392 x >= clientArea.left && x <= clientArea.right &&
1393 y >= clientArea.top && y <= clientArea.bottom)
1397 guiApp.interfaceDriver.SetCaret(
1398 x + absPosition.x + clientStart.x,
1399 y + absPosition.y + clientStart.y, this.caretSize);
1400 guiApp.caretEnabled = true;
1402 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1406 if(lastWindow != this)
1408 updateBox.left = x + 1;
1410 updateBox.right = x + 2;
1411 updateBox.bottom = y + this.caretSize - 1;
1415 updateBox.left = Min(x + 1, caretX + 1);
1416 updateBox.top = Min(y, caretY);
1417 updateBox.right = Max(x + 2, caretX + 2);
1418 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1421 guiApp.caretOwner.Update(updateBox);
1428 caretSize = this.caretSize;
1434 guiApp.interfaceDriver.SetCaret(0,0,0);
1435 guiApp.caretEnabled = false;
1441 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1446 scrolledPos.x = position.x = x;
1447 scrolledPos.y = position.y = y;
1449 clientSize.w = size.w = w;
1450 clientSize.h = size.h = h;
1452 if(parent && !style.nonClient)
1454 //if(!style.fixed || style.isDocument)
1456 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1457 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1461 clientStart.x = clientStart.y = 0;
1463 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1465 //if(!activeClient || activeClient.state != maximized)
1466 if(!noAutoScrollArea)
1468 // Check if scroll area must be modified
1469 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1471 bool foundChild = false;
1473 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1474 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1475 for(child = children.first; child; child = child.next)
1477 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1478 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1480 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1481 w = Max(w, child.position.x + child.size.w);
1482 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1483 w = Max(w, Max(child.position.x, 0) + child.size.w);
1484 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1485 h = Max(h, child.position.y + child.size.h);
1486 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1487 h = Max(h, Max(child.position.y, 0) + child.size.h);
1492 if(foundChild && (w > cw || h > ch))
1494 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1496 int stepX = sbStep.x, stepY = sbStep.y;
1497 // Needed to make snapped down position match the skin's check of client area
1498 // against realvirtual
1501 SNAPDOWN(stepX, textCellW);
1502 SNAPDOWN(stepY, textCellH);
1503 stepX = Max(stepX, textCellW);
1504 stepY = Max(stepY, textCellH);
1506 if(scrollFlags.snapX)
1508 if(scrollFlags.snapY)
1511 reqScrollArea.w = w;
1512 reqScrollArea.h = h;
1515 else if(reqScrollArea.w || reqScrollArea.h)
1517 reqScrollArea.w = 0;
1518 reqScrollArea.h = 0;
1519 SetScrollPosition(0,0);
1524 // Automatic MDI Client Scrolling Area Adjustment
1525 if(parent && !parent.noAutoScrollArea)
1527 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1528 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1530 Window parent = this.parent;
1531 int w = parent.reqScrollArea.w;
1532 int h = parent.reqScrollArea.h;
1534 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1535 w = Max(w, position.x + size.w);
1536 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1537 w = Max(w, Max(position.x, 0) + size.w);
1538 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1539 h = Max(h, position.y + size.h);
1540 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1541 h = Max(h, Max(position.y, 0) + size.h);
1543 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1544 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1546 /*bool resize = false;
1547 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1548 // Needed to make snapped down position match the skin's check of client area
1549 // against realvirtual
1552 SNAPDOWN(stepX, textCellW);
1553 SNAPDOWN(stepY, textCellH);
1554 stepX = Max(stepX, textCellW);
1555 stepY = Max(stepY, textCellH);
1557 if(parent.scrollFlags.snapX)
1559 if(parent.scrollFlags.snapY)
1561 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1563 parent.reqScrollArea.w = w;
1564 parent.reqScrollArea.h = h;*/
1566 // parent.UpdateScrollBars(true, true);
1567 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1568 false, true, true, true, false, false);
1573 GetRidOfVirtualArea();
1577 UpdateScrollBars(modifyThisArea, false);
1578 else if(guiApp.currentSkin)
1581 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1583 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1584 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1585 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1586 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1589 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1590 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1592 absPosition = scrolledPos;
1593 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1594 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1596 if(this != guiApp.desktop && parent)
1598 absPosition.x += parent.absPosition.x;
1599 absPosition.y += parent.absPosition.y;
1600 if(!style.nonClient && this != guiApp.desktop)
1602 absPosition.x += parent.clientStart.x;
1603 absPosition.y += parent.clientStart.y;
1607 box = Box { 0, 0, size.w - 1, size.h - 1 };
1612 // Clip against parent's client area
1613 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1615 // Compute client area in this window coordinate system
1616 clientArea.left = 0;
1618 clientArea.right = clientSize.w - 1;
1619 clientArea.bottom = clientSize.h - 1;
1621 // Clip against parent's client area
1623 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1627 //absPosition.x -= parent.clientStart.x;
1628 //absPosition.y -= parent.clientStart.y;
1631 // Adjust all children
1632 for(child = children.first; child; child = child.next)
1633 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1635 UpdateCaret(false, false);
1638 void GetRidOfVirtualArea(void)
1640 if(parent && !parent.destroyed && style.fixed &&
1641 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1642 parent.reqScrollArea.w && parent.reqScrollArea.h)
1644 if(!parent.noAutoScrollArea)
1646 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1650 for(child = children.first; child; child = child.next)
1652 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1654 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1655 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1665 Window parent = this.parent;
1667 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1668 false, true, true, true, false, false);
1670 parent.SetScrollArea(0,0,true);
1671 parent.SetScrollPosition(0,0);
1677 public void ExternalPosition(int x, int y, int w, int h)
1679 Position(x, y, w, h, false, true, true, true, false, false);
1680 /* TO REVIEW: Redj's code trying to fix position saving
1685 normalAnchor = Anchor { left = x, top = y };
1686 normalSizeAnchor = SizeAnchor { { w, h } };
1693 // (w, h): Full window size
1694 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1696 bool result = false;
1697 int oldCW = clientSize.w, oldCH = clientSize.h;
1698 bool clientResized, windowResized, windowMoved;
1700 //bool realResized = size.w != w || size.h != h;
1702 // TOCHECK: This wasn't in ecere.dll
1703 //if(!parent) return true;
1704 if(destroyed) return false;
1706 windowMoved = position.x != x || position.y != y || force;
1708 // windowResized = realResized || force;
1709 windowResized = size.w != w || size.h != h || force;
1711 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1717 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1718 scrolledPos.x - parent.clientStart.x + this.box.right,
1719 scrolledPos.y - parent.clientStart.y + this.box.bottom
1725 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1730 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1732 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1733 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1734 windowResized = true;
1736 if(display && rootWindow != this)
1739 if(guiApp && guiApp.windowMoving)
1741 if(guiApp.windowMoving.style.nonClient)
1742 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1744 guiApp.windowMoving.parent.SetMouseRangeToClient();
1754 // Buttons bitmap resources crash if we do this while switching mode
1755 if(!guiApp || !guiApp.modeSwitching)
1758 // Process Anchored Children
1762 for(child = children.first; child; child = child.next)
1765 ((child.stateAnchor.left.type != offset ||
1766 child.stateAnchor.top.type != offset ||
1767 child.stateAnchor.right.type != none ||
1768 child.stateAnchor.bottom.type != none) ||
1769 child.state == maximized || child.state == minimized))
1771 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1773 // child.Position(x, y, w, h, false, true, true, true, false);
1774 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1775 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1781 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1782 //if(updateScrollBars)
1784 OnResize(clientSize.w, clientSize.h);
1786 if((clientResized || windowMoved) && created)
1787 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1789 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1791 Window master = guiApp.interimWindow.master;
1792 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1795 if(rootWindow == this && !is3D)
1799 x -= guiApp.desktop.absPosition.x;
1800 y -= guiApp.desktop.absPosition.y;
1802 //guiApp.Log("Position %s\n", caption);
1805 if(windowResized || windowMoved)
1806 if(display && !display.flags.memBackBuffer && changeRootWindow)
1807 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1809 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1810 for(child = parent.children.first; child && child != this; child = child.next)
1811 if(child.rootWindow)
1812 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1817 if(windowMoved || windowResized)
1819 display.Lock(true /*false*/);
1822 display.Position(absPosition.x, absPosition.y);
1823 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1826 // result = realResized ? display.Resize(size.w, size.h) : true;
1827 if(nativeDecorations && rootWindow.windowHandle)
1829 int w = clientSize.w, h = clientSize.h;
1830 if(hasMenuBar) h += skinMenuHeight;
1831 if(hasStatusBar) h += statusBarHeight;
1832 if(sbv && sbv.visible) w += sbv.size.w;
1833 if(sbh && sbh.visible) h += sbh.size.h;
1834 result = manageDisplay ? display.Resize(w, h) : true;
1837 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1841 else if(clientResized)
1843 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1846 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1850 if(windowMoved || windowResized)
1855 if(guiApp.driver && changeRootWindow && windowHandle)
1857 if(windowResized || windowMoved)
1858 if(!display || display.flags.memBackBuffer)
1859 guiApp.interfaceDriver.PositionRootWindow(this,
1860 x, y, w, h, windowMoved, windowResized);
1861 guiApp.interfaceDriver.UpdateRootWindow(this);
1863 for(child = children.first; child; child = child.next)
1865 if(child.is3D && child.created)
1867 // Copy Display Content
1868 child.display.displaySystem = display.displaySystem;
1869 child.display.window = display.window;
1870 child.display.current = display.current;
1871 child.display.width = display.width;
1872 child.display.height = display.height;
1873 child.display.driverData = display.driverData;
1874 child.display.mutex = null;
1885 void UpdateScrollBars(bool flag, bool fullThing)
1888 bool resizeH = false, resizeV = false;
1889 bool scrolled = false;
1890 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1891 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1893 if(destroyed) return;
1894 if(guiApp.currentSkin)
1896 MinMaxValue cw = 0, ch = 0;
1897 bool sbvVisible, sbhVisible;
1898 int rangeH = 0, rangeV = 0;
1899 int positionH = 0, positionV;
1901 // First get client area with no respect to scroll bars
1906 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1908 if(scrollFlags.dontHide)
1911 cw -= guiApp.currentSkin.VerticalSBW();
1913 ch -= guiApp.currentSkin.HorizontalSBH();
1915 // Update the scrollbar visibility
1921 sbh.disabled = rangeH <= 1;
1922 if(sbh.style.hidden)
1932 sbv.disabled = rangeV <= 1;
1933 if(sbv.style.hidden)
1941 int oldHRange = sbh ? sbh.range : 0;
1942 int oldVRange = sbv ? sbv.range : 0;
1943 // Then start off with horizontal scrollbar range
1946 positionH = sbh.thumbPosition;
1953 SBSetTotal(sbh, rvw);
1956 ch -= guiApp.currentSkin.HorizontalSBH();
1959 // Do the same for vertical scrollbar
1962 positionV = sbv.thumbPosition;
1968 SBSetTotal(sbv, rvh);
1972 cw -= guiApp.currentSkin.VerticalSBW();
1973 // Maybe we need to set the range on the horizontal scrollbar again
1981 SBSetTotal(sbh, rvw);
1982 //sbh.Action(setRange, positionH, 0);
1983 if(rangeH <= 1 && sbh.range > 1)
1985 ch -= guiApp.currentSkin.HorizontalSBH();
1991 SBSetTotal(sbv, rvh);
1993 //sbv.Action(setRange, positionV, 0);
1998 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1999 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
2002 // Update the scrollbar visibility
2003 if(!scrollFlags.dontHide)
2005 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
2009 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2016 if(guiApp.currentSkin)
2023 sbhVisible = sbh.style.hidden ? true : false;
2025 sbvVisible = sbv.style.hidden ? true : false;
2027 // Do our resize here
2028 if(flag && (resizeH || resizeV) && fullThing)
2030 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2035 OnResize(clientSize.w, clientSize.h);
2041 sbh.visible = sbhVisible;
2043 sbv.visible = sbvVisible;
2045 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2046 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2049 sbh.pageStep = clientSize.w;
2051 sbv.pageStep = clientSize.h;
2053 // Notify doesn't handle setRange anymore... process it here
2056 int positionH = sbh.thumbPosition;
2057 if(scroll.x != positionH)
2059 OnHScroll(setRange, positionH, 0);
2063 SNAPDOWN(positionH, textCellW);
2064 scroll.x = positionH;
2070 int seen = clientSize.w, total = reqScrollArea.w;
2073 if(scrollFlags.snapX)
2074 SNAPDOWN(seen, sbStep.x);
2076 if(!total) total = seen;
2077 range = total - seen + 1;
2079 range = Max(range, 1);
2081 if(x >= range) x = range - 1;
2083 if(scrollFlags.snapX)
2084 SNAPUP(x, sbStep.x);
2088 OnHScroll(setRange, x, 0);
2093 SNAPDOWN(x, textCellW);
2099 int positionV = sbv.thumbPosition;
2100 if(scroll.y != positionV)
2102 OnVScroll(setRange, positionV, 0);
2106 SNAPDOWN(positionV, textCellH);
2107 scroll.y = positionV;
2113 int seen = clientSize.h, total = reqScrollArea.h;
2116 if(scrollFlags.snapY)
2117 SNAPDOWN(seen, sbStep.y);
2119 if(!total) total = seen;
2120 range = total - seen + 1;
2121 range = Max(range, 1);
2123 if(y >= range) y = range - 1;
2125 if(scrollFlags.snapY)
2126 SNAPUP(y, sbStep.y);
2130 OnVScroll(setRange, y, 0);
2135 SNAPDOWN(y, textCellH);
2141 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2144 for(child = children.first; child; child = child.next)
2146 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2149 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2150 child.Position(x, y, w, h, false, true, false, true, false, false);
2157 // Process Scrollbars
2159 if(sbh) // && !sbh.style.hidden
2162 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2163 // Need to set the range again (should improve...) since the scrollbars didn't have
2164 // the right size when UpdateScrollArea set the range on it
2167 sbh.seen = clientSize.w;
2171 if(sbv) // && !sbv.state.hidden
2174 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2175 // Need to set the range again (should improve...) since the scrollbars didn't have
2176 // the right size when UpdateScrollArea set the range on it
2179 sbv.seen = clientSize.h;
2184 // TESTING THIS LOWER
2185 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2188 for(child = children.first; child; child = child.next)
2190 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2193 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2194 child.Position(x, y, w, h, false, true, false, true, false, false);
2200 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2202 SetState(maximized, false, mods);
2206 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2208 SetState(normal, false, mods);
2212 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2214 SetState(minimized, false, mods);
2215 parent.CycleChildren(false, true, false, true);
2219 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2222 // Scroll bar notifications
2223 if(action != setRange)
2225 bool changed = false;
2229 if(scroll.x != position)
2231 OnHScroll(action, position, keyFlags);
2236 SNAPDOWN(position, textCellW);
2238 scroll.x = position;
2242 if(scroll.y != position)
2244 OnVScroll(action, position, keyFlags);
2249 SNAPDOWN(position, textCellH);
2251 scroll.y = position;
2255 bool childMove = false;
2256 for(child = children.first; child; child = child.next)
2258 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2261 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2262 child.Position(x, y, w, h, false, true, false, true, false, false);
2266 // Testing this patch out to solve MDI workspace redraw bugs
2267 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2268 // Scroll offsets to blame?
2272 UpdateCaret(false, false);
2276 // Testing this patch out to solve MDI workspace redraw bugs
2277 for(child = children.first; child; child = child.next)
2279 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2288 Window GetParentMenuBar()
2290 Window menuBarParent;
2291 if(formDesigner) return null;
2292 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2294 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2295 if(menuBarParent && !menuBarParent.isActiveClient)
2301 void CreateSystemChildren(void)
2303 Window parent = this;
2304 bool scrollBarChanged = false;
2305 bool hasClose = false, hasMaxMin = false;
2306 Point scroll = this.scroll;
2308 if(state == maximized)
2310 parent = GetParentMenuBar();
2317 if(style.hasClose) hasClose = true;
2318 if(style.hasMaximize || style.hasMinimize)
2325 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2327 sysButtons[2].Destroy(0);
2328 sysButtons[2] = null;
2330 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2332 sysButtons[1].Destroy(0);
2333 sysButtons[1] = null;
2335 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2337 sysButtons[0].Destroy(0);
2338 sysButtons[0] = null;
2341 if(hasClose && parent)
2348 parent, master = this,
2349 inactive = true, nonClient = true, visible = false;
2351 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2357 if(this.parent == guiApp.desktop)
2358 sysButtons[2].hotKey = altF4;
2359 else if(style.isActiveClient)
2360 sysButtons[2].hotKey = ctrlF4;
2361 sysButtons[2].Create();
2364 sysButtons[2].symbol = 'X';
2365 sysButtons[2].disabled = !style.hasClose;
2368 if(hasMaxMin && parent)
2372 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2373 if(state == maximized)
2376 method = RestoreButtonClicked;
2382 method = MaximizeButtonClicked;
2390 parent, master = this,
2391 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2393 sysButtons[1].Create();
2395 sysButtons[1].NotifyClicked = method;
2397 sysButtons[1].symbol = symbol;
2398 sysButtons[1].disabled = !style.hasMaximize;
2401 if(hasMaxMin && parent)
2405 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2406 if (state == minimized)
2409 method = RestoreButtonClicked;
2415 method = MinimizeButtonClicked;
2423 parent, master = this,
2424 hotKey = altM, inactive = true, nonClient = true, visible = false
2426 sysButtons[0].Create();
2428 sysButtons[0].NotifyClicked = method;
2430 sysButtons[0].symbol = symbol;
2431 sysButtons[0].disabled = !style.hasMinimize;
2434 // Create the scrollbars
2435 if(style.hasHorzScroll && !sbh)
2441 direction = horizontal,
2445 snap = scrollFlags.snapX,
2446 NotifyScrolling = ScrollBarNotification
2449 scrollBarChanged = true;
2451 else if(sbh && !style.hasHorzScroll)
2457 if(style.hasVertScroll && !sbv)
2463 direction = vertical,
2467 snap = scrollFlags.snapY,
2468 NotifyScrolling = ScrollBarNotification
2471 scrollBarChanged = true;
2473 else if(sbv && !style.hasVertScroll)
2478 if(scrollBarChanged)
2480 SetScrollLineStep(sbStep.x, sbStep.y);
2481 UpdateScrollBars(true, true);
2485 if(scrollBarChanged)
2487 if(sbh) sbh.thumbPosition = scroll.x;
2488 if(sbv) sbv.thumbPosition = scroll.y;
2492 void UpdateCaption(void)
2494 if(rootWindow == this)
2497 FigureCaption(caption);
2498 if(guiApp.interfaceDriver)
2499 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2501 UpdateDecorations();
2504 if(parent.activeClient == this) // Added this last check
2506 if(parent.rootWindow == parent)
2509 parent.FigureCaption(caption);
2510 if(guiApp.interfaceDriver)
2511 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2514 parent.UpdateCaption();
2516 parent.UpdateDecorations();
2520 void UpdateActiveDocument(Window previous)
2522 Window activeClient = this.activeClient;
2523 Window activeChild = this.activeChild;
2530 activeClient.CreateSystemChildren();
2532 previous.CreateSystemChildren();
2544 // Build window list
2547 Menu windowMenu = menu.FindMenu("Window");
2552 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2554 Window document = cycle.data;
2555 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2557 char name[2048], caption[2048];
2558 document.FigureCaption(caption);
2559 sprintf(name, "%d %s", id+1, caption);
2560 windowMenu.AddDynamic(MenuItem
2562 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2563 NotifySelect = MenuWindowSelectWindow
2567 if(activeClient.cycle == cycle) break;
2572 if((!previous && activeClient) || !activeClient)
2578 item = menu.FindItem(MenuWindowCloseAll, 0);
2579 if(item) item.disabled = false;
2580 item = menu.FindItem(MenuWindowNext, 0);
2581 if(item) item.disabled = false;
2582 item = menu.FindItem(MenuWindowPrevious, 0);
2583 if(item) item.disabled = false;
2584 item = menu.FindItem(MenuWindowCascade, 0);
2585 if(item) item.disabled = false;
2586 item = menu.FindItem(MenuWindowTileHorz, 0);
2587 if(item) item.disabled = false;
2588 item = menu.FindItem(MenuWindowTileVert, 0);
2589 if(item) item.disabled = false;
2590 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2591 if(item) item.disabled = false;
2592 item = menu.FindItem(MenuWindowWindows, 0);
2593 if(item) item.disabled = false;
2596 item = menu.FindItem(MenuFileClose, 0);
2597 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2598 item = menu.FindItem(MenuFileSaveAll, 0);
2599 if(item) item.disabled = numDocuments < 1;
2601 if(activeClient && activeClient.menu && activeClient.state != minimized)
2605 //activeClient.menu.Clean(activeClient);
2606 menu.Merge(activeClient.menu, true, activeClient);
2610 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2613 menu.Merge(activeChild.menu, true, activeChild);
2616 // This is called again for a child window change, with same active client
2617 OnActivateClient(activeClient, previous);
2618 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2619 parent.UpdateActiveDocument(null);
2622 void _ShowDecorations(Box box, bool post)
2624 if(rootWindow == this && nativeDecorations && !is3D) return;
2625 if(visible && this != guiApp.desktop)
2627 Surface surface = RedrawFull(box);
2631 FigureCaption(caption);
2634 ShowDecorations(captionFont.font,
2637 active, //parent.activeClient == this
2638 guiApp.windowMoving == this);
2640 PreShowDecorations(captionFont.font,
2643 active, //parent.activeClient == this
2644 guiApp.windowMoving == this);
2651 void UpdateExtent(Box refresh)
2653 Surface surface = null;
2655 if(!manageDisplay) { OnRedraw(null);return; }
2656 _ShowDecorations(refresh, false);
2658 surface = Redraw(refresh);
2659 // Opaque background: just fill before EW_REDRAW (clear?)
2662 surface.SetBackground(background);
2663 surface.SetForeground(foreground);
2664 surface.DrawingChar(' ');
2665 if(this == rootWindow)
2667 if(style.drawBehind || background.a)
2669 int a = background.a;
2670 // Premultiply alpha for clear color
2671 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2672 surface.Clear(colorBuffer);
2673 surface.SetBackground(background);
2676 else if(background.a)
2680 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2681 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2684 if(display.flags.alpha && background.a < 255 && background)
2686 surface.Area(0,0,clientSize.w, clientSize.h);
2687 /*if(style.clearDepthBuffer)
2688 surface.Clear(depthBuffer);*/
2690 else if(/*style.clearDepthBuffer || */background.a)
2692 int a = background.a;
2693 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2694 // Premultiply alpha for clear color
2695 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2696 surface.Clear(colorBuffer);
2697 surface.SetBackground(background);
2702 surface.TextFont(usedFont.font);
2703 surface.TextOpacity(false);
2707 // Draw the caret ...
2708 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2710 // surface.SetBackground(0xFFFFFF - background.color);
2711 surface.SetBackground(~background.color);
2713 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2714 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2720 void DrawOverChildren(Box refresh)
2722 Surface surface = Redraw(refresh);
2726 surface.DrawingChar(' ');
2727 surface.SetBackground(background);
2728 surface.SetForeground(foreground);
2730 surface.TextFont(usedFont.font);
2731 surface.TextOpacity(false);
2733 OnDrawOverChildren(surface);
2738 _ShowDecorations(refresh, true);
2741 void ComputeClipExtents(void)
2744 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2746 clipExtent.Copy(this.clipExtent);
2748 for(child = children.last; child; child = child.prev)
2750 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2752 bool opaque = child.IsOpaque(); // TODO: acess background directly
2753 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2755 child.clipExtent.Copy(clipExtent);
2756 child.clipExtent.Offset(-dx, -dy);
2757 child.clipExtent.IntersectBox(child.box);
2759 child.ComputeClipExtents();
2761 if(opaque && !child.style.nonClient)
2763 // Adjust the box for the parent:
2764 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2765 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2770 // ??? Only do this for overlapped window or if parent has with clip children flag
2772 // Do this if window has clip children flag on (default false?)
2773 // this.clipExtent = clipExtent;
2775 clipExtent.Free(null);
2778 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2781 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2782 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2784 offsetX -= rootWindow.clientStart.x;
2785 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2789 for(child = children.last; child; child = child.prev)
2791 bool opaque = child.IsOpaque();
2792 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2796 // Adjust renderArea to the root window level
2797 Extent * renderArea = &rootWindow.tempExtents[3];
2799 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2800 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2801 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2803 offsetX -= child.rootWindow.clientStart.x;
2804 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2808 Extent childRenderArea;
2810 if(backBufferUpdate != null)
2812 childRenderArea.Copy(backBufferUpdate);
2813 childRenderArea.Offset(-offsetX, -offsetY);
2816 childRenderArea.Copy(child.dirtyArea);
2818 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2819 renderArea.Copy(dirtyExtent);
2820 renderArea.Offset(-offsetX, -offsetY);
2821 childRenderArea.Union(renderArea);
2824 // Intersect with the clip extent
2825 childRenderArea.Intersection(child.clipExtent);
2828 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2830 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2831 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2833 renderArea->Offset(offsetX, offsetY);
2835 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2836 // overDirtyExtent.Union(renderArea);
2837 renderArea->Empty();
2838 // childRenderArea.Free();
2840 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2845 for(child = children.last; child; child = child.prev)
2847 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2849 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2854 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2856 bool opaque = IsOpaque();
2857 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2859 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2860 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2862 offsetX -= rootWindow.clientStart.x;
2863 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2867 for(child = children.last; child; child = child.prev)
2869 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2871 ColorAlpha background = *(ColorAlpha *)&child.background;
2872 bool opaque = child.IsOpaque();
2873 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2877 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2878 // Adjust renderArea to the root window level
2880 renderArea.Copy(child.dirtyArea);
2881 renderArea.Offset(offsetX, offsetY);
2882 dirtyExtent.Union(renderArea);
2883 overDirtyExtent.Union(renderArea);
2889 for(child = children.last; child; child = child.prev)
2891 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2893 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2897 if(backBufferUpdate != null)
2899 renderArea.Copy(backBufferUpdate);
2900 renderArea.Offset(-offsetX, -offsetY);
2902 overRenderArea.Copy(backBufferUpdate);
2903 overRenderArea.Offset(-offsetX, -offsetY);
2909 renderArea.Copy(dirtyArea);
2911 overRenderArea.Copy(dirtyArea);
2914 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2915 dirtyExtentWindow->Copy(dirtyExtent);
2916 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2917 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2918 dirtyExtentWindow->Empty();
2920 // Intersect with the clip extent
2921 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2924 if(renderArea.count > 10)
2927 printf("\nToo many extents (%d):\n", renderArea.count);
2929 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2930 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2935 for(c = 0; c<10; c++)
2938 FASTLIST_LOOP(renderArea, extentBox)
2940 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2942 renderArea.Copy(extent);
2944 FASTLIST_LOOP(renderArea, extentBox)
2947 printf("(%d, %d) - (%d, %d)\n",
2948 extentBox.box.left, extentBox.box.top,
2949 extentBox.box.right, extentBox.box.bottom);
2953 printf("\nNow %d\n", renderArea.count);
2959 // WHY WAS THIS COMMENTED ??
2961 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2962 dirtyExtentWindow->Copy(overDirtyExtent);
2963 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2964 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2965 dirtyExtentWindow->Empty();
2967 // Intersect with the clip extent
2968 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2974 if(scrollExtent.count)
2976 // Subtract render extent from scrolling extent
2977 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2979 if(backBufferUpdate == null)
2981 Extent * dirty = &rootWindow.tempExtents[3];
2984 // Intersect scrolling extent with clip extent
2985 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2987 // offset this scroll to be at the root window level
2988 scrollExtent.Offset(offsetX, offsetY);
2989 // Add area that was scrolled to the dirty extents of the back buffer
2990 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2994 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2995 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2996 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
3001 scrollExtent.Empty();
3003 // Add the exposed extent to the window render area
3004 dirty->Offset(-offsetX, -offsetY);
3005 renderArea.Union(dirty, rootWindow.tempExtents[0]);
3010 // Subtract the window's box from the transparency forced extent
3011 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3017 renderArea.Copy(this.renderArea);
3018 renderArea.Offset(offsetX, offsetY);
3019 dirtyExtent.Union(renderArea);
3025 Extent renderArea { };
3027 renderArea.Copy(overRenderArea);
3028 renderArea.Offset(offsetX, offsetY);
3029 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3034 if(backBufferUpdate != null)
3036 // Remove render area from dirty area
3037 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3039 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3046 // Remove the window render area from the dirty extents of the back buffer
3047 rootWindow.dirtyBack.Exclusion(renderArea);
3051 void Render(Extent updateExtent)
3055 Window rootWindow = this.rootWindow;
3056 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3057 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3059 offsetX -= rootWindow.clientStart.x;
3060 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3063 if(rootWindow.fullRender)
3072 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3073 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3078 /*if(renderArea.count)
3079 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3082 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3084 Box box = extentBox.box;
3087 /*printf("(%d, %d) - (%d, %d)\n",
3088 extentBox.box.left, extentBox.box.top,
3089 extentBox.box.right, extentBox.box.bottom);*/
3094 box.left += offsetX;
3096 box.right += offsetX;
3097 box.bottom += offsetY;
3099 if(updateExtent != null)
3100 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3104 for(child = children.first; child; child = child.next)
3105 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3106 child.Render(updateExtent);
3108 if(rootWindow.fullRender)
3109 DrawOverChildren(box);
3112 // TO DO: There's an issue about draw over children...
3113 // TO DO: Don't wanna go through this if method isn't used
3114 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3115 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3117 Box box = extentBox.box;
3119 DrawOverChildren(box);
3121 box.left += offsetX;
3123 box.right += offsetX;
3124 box.bottom += offsetY;
3126 if(updateExtent != null)
3127 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3130 for(child = children.first; child; child = child.next)
3131 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3132 child.Render(updateExtent);
3135 overRenderArea.Empty();
3138 public void UpdateDisplay(void)
3140 if(!manageDisplay) { OnRedraw(null);return; }
3141 if(rootWindow && this != rootWindow)
3142 rootWindow.UpdateDisplay();
3145 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3146 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3149 dirtyExtent.Clear();
3152 clipExtent.AddBox(box);
3154 display.StartUpdate();
3156 if(!rootWindow.fullRender)
3158 ComputeClipExtents();
3159 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3160 ComputeRenderArea(dirtyExtent, overExtent, null);
3163 clipExtent.Free(null);
3165 dirtyExtent.Free(null);
3166 overExtent.Free(null);
3168 if(display.flags.flipping)
3171 display.Update(null);
3175 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3176 updateExtent.Clear();
3178 Render(updateExtent);
3180 updateExtent.UnionBox(this.box, tempExtents[0]);
3183 //printf("\n\nUpdate:\n------------------------------------------\n");
3186 //FASTLIST_LOOP(updateExtent, extentBox)
3187 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3190 /*printf("Updating (%d, %d) - (%d, %d)\n",
3191 extentBox.box.left, extentBox.box.top,
3192 extentBox.box.right, extentBox.box.bottom);*/
3195 display.Update(extentBox.box);
3198 updateExtent.Free(null);
3201 display.EndUpdate();
3209 void UpdateBackDisplay(Box box)
3215 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3217 //printf("UpdateBackDisplay going through!\n");
3218 display.StartUpdate();
3222 intersection.Copy(dirtyBack);
3223 intersection.IntersectBox(box);
3225 dirtyExtent.Clear();
3228 clipExtent.AddBox(box);
3230 if(!rootWindow.fullRender)
3232 ComputeClipExtents();
3233 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3236 clipExtent.Free(null);
3238 intersection.Free(null);
3239 dirtyExtent.Free(null);
3240 overExtent.Free(null);
3245 if(display.flags.flipping)
3246 display.Update(null);
3249 rootWindow.display.Update(box);
3252 display.EndUpdate();
3256 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3257 if(dirtyBack.count > MAX_DIRTY_BACK)
3259 BoxItem extentBox, next;
3260 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3261 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3263 next = (BoxItem)extentBox.next;
3264 if(extentBox != first)
3266 if(extentBox.box.left < first.box.left)
3267 first.box.left = extentBox.box.left;
3268 if(extentBox.box.top < first.box.top)
3269 first.box.top = extentBox.box.top;
3270 if(extentBox.box.right > first.box.right)
3271 first.box.right = extentBox.box.right;
3272 if(extentBox.box.bottom > first.box.bottom)
3273 first.box.bottom = extentBox.box.bottom;
3274 dirtyBack.Delete(extentBox);
3283 // --- Window positioning ---
3284 // --- Window identification ---
3286 // Returns window at position "Position"
3287 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3289 Window child, result = null;
3291 box.left += absPosition.x;
3292 box.right += absPosition.x;
3293 box.top += absPosition.y;
3294 box.bottom += absPosition.y;
3296 if(!destroyed && visible && (acceptDisabled || !disabled))
3298 int lx = x - absPosition.x;
3299 int ly = y - absPosition.y;
3300 if(IsInside(lx, ly))
3301 // if(box.IsPointInside(Point{x, y}))
3303 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3304 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3307 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3308 Window ancestor = null;
3310 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3311 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3313 if(child != statusBar && child.rootWindow == rootWindow)
3315 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3322 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3324 if(child != statusBar && child.rootWindow == rootWindow)
3326 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3333 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3341 Window FindModal(void)
3343 Window modalWindow = this, check;
3344 Window check2 = null;
3345 for(check = this; check.master; check = check.master)
3347 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3349 modalWindow = check.master.modalSlave;
3350 check = modalWindow;
3352 // TESTING THIS FOR DROPBOX...
3353 if(!rootWindow || !rootWindow.style.interim)
3355 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3357 if(check2.modalSlave && check2.modalSlave.created)
3359 modalWindow = check2.modalSlave;
3367 if(modalWindow == this)
3369 for(check = this; check.activeChild; check = check.activeChild)
3371 if(check.modalSlave)
3373 modalWindow = check.modalSlave;
3379 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3380 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3383 void StopMoving(void)
3385 if(this == guiApp.windowMoving)
3387 guiApp.windowMoving = null;
3388 UpdateDecorations();
3389 SetMouseRange(null);
3392 if(rootWindow.active)
3393 guiApp.interfaceDriver.StopMoving(rootWindow);
3395 guiApp.windowCaptured.ReleaseCapture();
3396 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3397 guiApp.windowIsResizing = false;
3401 void SelectMouseCursor(void)
3406 Window cursorWindow = null;
3407 bool rx, ry, rex, rey;
3409 guiApp.desktop.GetMousePosition(&x, &y);
3410 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3412 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3413 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3414 else if(mouseWindow)
3416 modalWindow = mouseWindow.FindModal();
3417 x -= mouseWindow.absPosition.x;
3418 y -= mouseWindow.absPosition.y;
3419 if(guiApp.windowIsResizing)
3421 rex = guiApp.resizeEndX;
3422 rey = guiApp.resizeEndY;
3423 rx = guiApp.resizeX;
3424 ry = guiApp.resizeY;
3425 if((rex && rey) || (rx && ry))
3426 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3427 else if((rex && ry) || (rx && rey))
3428 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3429 else if((ry || rey) && (!rx && !rex))
3430 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3431 else if((rx || rex) && (!ry && !rey))
3432 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3434 else if(!modalWindow && !guiApp.windowCaptured &&
3435 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3436 &rx, &ry, &rex, &rey))
3438 if((rex && rey) || (rx && ry))
3439 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3440 else if((rex && ry) || (rx && rey))
3441 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3442 else if((ry || rey) && (!rx && !rex))
3443 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3444 else if((rx || rex) && (!ry && !rey))
3445 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3447 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3449 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3450 mouseWindow.rootWindow != mouseWindow)
3451 cursorWindow = mouseWindow.parent;
3453 cursorWindow = mouseWindow;
3455 else if(!guiApp.interimWindow)
3456 cursorWindow = guiApp.windowCaptured;
3459 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3460 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3462 else if(modalWindow)
3464 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3466 else if(guiApp.interimWindow)
3468 if(guiApp.interimWindow.cursor)
3469 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3471 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3476 // --- State based input ---
3477 bool AcquireInputEx(bool state)
3482 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3483 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3485 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3487 guiApp.acquiredWindow = state ? this : null;
3490 SetMouseRangeToClient();
3491 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3496 SelectMouseCursor();
3498 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3502 // --- Window activation ---
3503 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3506 if(!parent || !parent.style.inactive)
3508 Window parent = this.parent;
3511 if(rootWindow == this)
3512 Log(active ? "active\n" : "inactive\n");
3514 if(active && requireRemaximize)
3516 if(state == maximized)
3518 property::state = normal;
3519 property::state = maximized;
3521 requireRemaximize = false;
3524 // Testing this here...
3525 if(!parent || parent == guiApp.desktop || parent.active)
3527 this.active = active;
3530 // TESTING THIS HERE
3531 UpdateDecorations();
3532 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3533 result = NotifyActivate(master, this, active, previous);
3536 this.active = !active;
3541 if(!parent || parent == guiApp.desktop || parent.active)
3543 this.active = active;
3545 AcquireInputEx(active);
3546 if(active && isEnabled)
3550 if(guiApp.caretOwner)
3554 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3555 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3556 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3557 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3559 guiApp.caretOwner.Update(extent);
3562 if(visible || !guiApp.caretOwner)
3563 guiApp.caretOwner = this;
3564 UpdateCaret(false, false);
3570 this.active = false;
3572 AcquireInputEx(active);
3574 if(!active && guiApp.caretOwner == this)
3576 UpdateCaret(false, true);
3577 guiApp.caretOwner = null;
3578 guiApp.interfaceDriver.SetCaret(0,0,0);
3579 guiApp.caretEnabled = false;
3584 if(!active && parent && parent.activeChild && parent.activeChild != this)
3585 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3591 if(!active && menuBar)
3594 menuBar.OnActivate(false, null, &goOn, true);
3595 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3600 Window aChild = activeChild;
3602 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3614 void ConsequentialMouseMove(bool kbMoving)
3616 if(rootWindow && !noConsequential)
3618 if(kbMoving || !guiApp.windowMoving)
3622 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3624 if(guiApp.interfaceDriver)
3625 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3627 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3628 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3634 bool IsDescendantOf(Window ancestor)
3637 for(window = this; window && window != ancestor; window = window.parent);
3638 return window == ancestor;
3641 bool IsSlaveOf(Window master)
3644 for(window = this; window && window != master; window = window.master);
3645 return window == master;
3648 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3652 if(this && !destroyed /*&& state != Hidden*/)
3654 Window swap = externalSwap;
3662 if(activateParent &&
3663 (parent.activeChild != this ||
3664 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3665 active && _isModal &&
3666 parent != master && master)
3667 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3673 bool real = parent.activeChild != this;
3675 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3676 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3677 !IsDescendantOf(guiApp.interimWindow) &&
3678 !IsSlaveOf(guiApp.interimWindow))
3680 Window interimWindow = guiApp.interimWindow;
3681 while(interimWindow && interimWindow != this)
3683 Window master = interimWindow.master;
3685 guiApp.interimWindow = null;
3686 if(guiApp.caretOwner)
3687 guiApp.caretOwner.UpdateCaret(false, false);
3689 incref interimWindow;
3690 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3695 delete interimWindow;
3696 interimWindow = (master && master.style.interim) ? master : null;
3701 guiApp.interimWindow = this;
3702 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3703 guiApp.caretEnabled = false;*/
3704 UpdateCaret(false, true);
3709 //bool acquireInput = false;
3711 parent.activeChild &&
3712 parent.activeChild.state == maximized &&
3713 parent != guiApp.desktop;
3715 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3720 swap = parent.activeChild;
3721 if(swap && swap.destroyed) swap = null;
3722 if(swap && swap != this)
3725 if(!swap.PropagateActive(false, this, &goOn, true))
3726 swap = parent.activeChild;
3737 if(!parent || parent.activeChild != this || style.interim)
3740 result = PropagateActive(true, swap, &goOn, true);
3741 if(!result && !goOn)
3746 //acquireInput = true;
3750 if(style.hasMaximize && parent != guiApp.desktop)
3753 SetState(maximized, false, 0);
3754 else if(state != maximized)
3757 for(child = parent.children.first; child; child = child.next)
3759 if(this != child && child.state == maximized)
3760 child.SetState(normal, false, 0);
3767 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3769 Window previous = parent.activeClient;
3770 parent.activeChild = this;
3771 if(!style.nonClient /*&& style.isActiveClient*/)
3775 if(style.isActiveClient)
3776 parent.activeClient = this;
3777 // Moved UpdateActiveDocument inside hidden check
3778 // To prevent activating previous window while creating a new one
3779 // (It was messing up the privateModule in the CodeEditor)
3780 parent.UpdateActiveDocument(previous);
3786 //if(!style.isRemote)
3788 if(rootWindow != this)
3790 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3791 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3793 else if(!guiApp.fullScreenMode)
3795 Window modalRoot = FindModal();
3796 if(!modalRoot) modalRoot = this;
3797 if(!modalRoot.isForegroundWindow)
3799 modalRoot.isForegroundWindow = true;
3800 // To check : Why is parent null?
3801 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3803 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3805 modalRoot.isForegroundWindow = false;
3810 if(result && real && (!style.inactive || moveInactive) && parent)
3812 Window last = parent.children.last;
3814 if(!style.stayOnTop)
3815 for(; last && last.style.stayOnTop; last = last.prev);
3817 parent.children.Move(this, last);
3819 // Definitely don't want that: why not?
3823 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3829 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3836 parent.activeChild = null;
3837 if(!style.nonClient /*&& style.isActiveClient*/)
3839 Window previous = parent.activeClient;
3840 if(style.isActiveClient)
3841 parent.activeClient = null;
3842 parent.UpdateActiveDocument(previous);
3846 if(this == guiApp.interimWindow)
3848 guiApp.interimWindow = null;
3849 if(guiApp.caretOwner)
3850 guiApp.caretOwner.UpdateCaret(false, false);
3852 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3859 if(!active || !swap)
3860 UpdateDecorations();
3862 swap.UpdateDecorations();
3864 if(active && rootWindow != this)
3865 ConsequentialMouseMove(false);
3872 // --- Input Messages ---
3873 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3875 static bool reEntrancy = false;
3876 if(reEntrancy) return;
3880 guiApp.cursorUpdate = true;
3881 if(guiApp.windowScrolling && !consequential)
3883 guiApp.windowScrolling.SetScrollPosition(
3884 (guiApp.windowScrolling.sbh) ?
3885 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3886 (guiApp.windowScrolling.sbv) ?
3887 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3889 if(guiApp.windowMoving)
3891 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3893 Window window = guiApp.windowMoving;
3895 int w = window.size.w;
3896 int h = window.size.h;
3901 rx = mouseX - guiApp.windowMovingStart.x;
3902 ry = mouseY - guiApp.windowMovingStart.y;
3905 window.GetDecorationsSize(&ew, &eh);
3907 if(guiApp.windowIsResizing)
3909 x = window.scrolledPos.x;
3910 y = window.scrolledPos.y;
3914 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3915 rx = guiApp.windowResizingBefore.w - aw;
3916 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3917 w = guiApp.windowResizingBefore.w - rx;
3921 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3922 ry = guiApp.windowResizingBefore.h - ah;
3923 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3924 ry = Max(ry, -guiApp.windowMovingBefore.y);
3925 h = guiApp.windowResizingBefore.h - ry;
3927 if(guiApp.resizeEndX)
3929 w = guiApp.windowResizingBefore.w + rx;
3932 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3940 w = Max(w, window.minSize.w);
3941 h = Max(h, window.minSize.h);
3942 w = Min(w, window.maxSize.w);
3943 h = Min(h, window.maxSize.h);
3945 if(!window.OnResizing(&w, &h))
3947 w = window.clientSize.w;
3948 h = window.clientSize.h;
3951 w = Max(w, window.skinMinSize.w);
3952 h = Max(h, window.skinMinSize.h);
3959 SNAPDOWN(w, textCellW);
3960 SNAPDOWN(h, textCellH);
3965 aw = Max(w,window.skinMinSize.w);
3966 rx = guiApp.windowResizingBefore.w - aw;
3967 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3968 w = guiApp.windowResizingBefore.w - rx;
3972 ah = Max(h,window.skinMinSize.h);
3973 ry = guiApp.windowResizingBefore.h - ah;
3974 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3975 ry = Max(ry, -guiApp.windowMovingBefore.y);
3976 h = guiApp.windowResizingBefore.h - ry;
3981 if(!guiApp.windowIsResizing || guiApp.resizeX)
3982 x = guiApp.windowMovingBefore.x + rx;
3983 if(!guiApp.windowIsResizing || guiApp.resizeY)
3984 y = guiApp.windowMovingBefore.y + ry;
3986 if(!guiApp.windowIsResizing)
3989 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3991 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3992 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3993 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3994 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3998 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3999 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
4005 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
4007 if(!window.OnMoving(&x, &y, w, h))
4009 x = window.scrolledPos.x;
4010 y = window.scrolledPos.y;
4016 SNAPDOWN(x, textCellW);
4017 SNAPDOWN(y, textCellH);
4020 if(!window.style.nonClient)
4022 if(!window.style.fixed /*|| window.style.isDocument*/)
4024 if(!window.style.dontScrollHorz)
4025 x += window.parent.scroll.x;
4026 if(!window.style.dontScrollVert)
4027 y += window.parent.scroll.y;
4031 // Break the anchors for moveable/resizable windows
4032 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4033 if(window.style.fixed)
4035 if(window.state == normal)
4037 window.normalAnchor = Anchor { left = x, top = y };
4038 window.normalSizeAnchor = SizeAnchor { { w, h } };
4039 window.anchored = false;
4043 window.stateAnchor = Anchor { left = x, top = y };
4044 window.stateSizeAnchor = SizeAnchor { { w, h } };
4046 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4047 // TOCHECK: Investigate why the following only redraws the scrollbars
4048 //window.Position(x, y, w, h, false, true, true, true, false, true);
4050 guiApp.movingLast.x = mouseX;
4051 guiApp.movingLast.y = mouseY;
4057 public bool MultiTouchMessage(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers * mods, bool consequential, bool activate)
4063 while(result && w != this)
4065 // TODO: How to handle this?
4068 Window msgWindow = GetAtPosition(x,y, false, true, w);
4073 window = (w && !w.disabled) ? w : null;
4075 if(consequential) mods->isSideEffect = true;
4076 if(!result || (window && window.destroyed)) window = null;
4080 if(window.OnMultiTouch && !window.disabled)
4082 Array<TouchPointerInfo> in { size = infos.size };
4083 memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
4087 i.x -= (window.absPosition.x + window.clientStart.x);
4088 i.y -= (window.absPosition.y + window.clientStart.y);
4090 i.x = Max(Min(i.x, 32767),-32768);
4091 i.y = Max(Min(i.y, 32767),-32768);
4095 if(!window.OnMultiTouch(event, in, *mods))
4102 if(!result || !w || !w.clickThrough)
4110 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4113 bool wasMoving = guiApp.windowMoving ? true : false;
4114 bool wasScrolling = guiApp.windowScrolling ? true : false;
4116 while(result && w != this)
4118 Window msgWindow = GetAtPosition(x,y, false, true, w);
4119 Window trueWindow = GetAtPosition(x,y, false, false, w);
4120 bool windowDragged = false;
4125 window = (w && !w.disabled) ? w : null;
4127 if(trueWindow) incref trueWindow;
4129 if(consequential) mods->isSideEffect = true;
4131 UpdateMouseMove(x, y, consequential);
4133 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4135 if(!guiApp.windowCaptured.isEnabled)
4136 guiApp.windowCaptured.ReleaseCapture();
4138 window = guiApp.windowCaptured;
4141 if(trueWindow && activate &&
4142 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4143 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4144 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4145 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4147 if(mods->alt && !mods->ctrl && !mods->shift)
4149 Window moved = trueWindow;
4150 for(moved = trueWindow; moved; moved = moved.parent)
4151 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4156 windowDragged = true;
4158 // Cancel the ALT menu toggling...
4159 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4164 if(window && activate &&
4165 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4166 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4167 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4168 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4170 Window modalWindow = window.FindModal();
4172 /*if(mods->alt && !mods->shift && !mods->ctrl)
4174 Window moved = window;
4175 for(moved = window; moved; moved = moved.parent)
4176 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4181 windowDragged = true;
4183 // Cancel the ALT menu toggling...
4184 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4190 Window activateWindow = modalWindow ? modalWindow : window;
4191 if(activateWindow && !activateWindow.isRemote)
4193 bool doActivation = true;
4194 //bool needToDoActivation = false;
4195 Window check = activateWindow;
4197 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4199 if(!check.style.inactive)
4201 //needToDoActivation = true;
4203 doActivation = false;
4208 if(!needToDoActivation)
4209 doActivation = false;
4212 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4213 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4215 // Let the OnLeftButtonDown do the activating instead
4216 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4224 incref activateWindow;
4225 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4227 delete activateWindow;
4231 if(activateWindow._refCount == 1)
4233 delete activateWindow;
4237 delete activateWindow;
4238 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4241 mods->isActivate = true;
4245 if(!modalWindow && window && !window.destroyed)
4247 if(!guiApp.windowCaptured || windowDragged)
4249 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4251 bool moving = ((window.state != maximized &&
4252 window.IsMouseMoving(
4253 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4254 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4256 if(!moving && window.IsMouseResizing(
4257 x - window.absPosition.x,
4258 y - window.absPosition.y,
4259 window.size.w, window.size.h,
4260 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4262 guiApp.windowIsResizing = true;
4263 guiApp.windowResizingBefore.w = window.size.w;
4264 guiApp.windowResizingBefore.h = window.size.h;
4266 if(guiApp.windowIsResizing || windowDragged || moving)
4269 guiApp.windowMoving = window;
4270 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4271 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4272 guiApp.windowMovingBefore.x = window.position.x;//s;
4273 guiApp.windowMovingBefore.y = window.position.y;//s;
4274 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4275 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4278 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4280 if(window.style.fixed &&
4282 window.IsMouseMoving(
4283 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4285 window.ShowSysMenu(x, y);
4289 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4291 if(window.sbv || window.sbh)
4294 guiApp.windowScrolling = window;
4295 guiApp.windowScrollingStart.x = x;
4296 guiApp.windowScrollingStart.y = y;
4297 guiApp.windowScrollingBefore.x = window.scroll.x;
4298 guiApp.windowScrollingBefore.y = window.scroll.y;
4301 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4303 if(window.style.hasMaximize &&
4304 window.IsMouseMoving(
4305 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4308 (window.state == maximized) ? normal : maximized, false, *mods);
4316 if(guiApp.windowMoving)
4318 if(guiApp.windowMoving.parent)
4320 if(guiApp.windowMoving.style.nonClient)
4321 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4323 guiApp.windowMoving.parent.SetMouseRangeToClient();
4327 window.UpdateDecorations();
4330 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4332 // Log("\n*** LEFT BUTTON UP ***\n");
4333 if(guiApp.windowMoving)
4334 guiApp.windowMoving.StopMoving();
4336 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4338 if(guiApp.windowScrolling)
4340 Window windowScrolling = guiApp.windowScrolling;
4341 guiApp.windowScrolling = null;
4342 windowScrolling.ReleaseCapture();
4346 if(!result || (window && window.destroyed)) window = null;
4348 if(window && window.FindModal())
4351 if(trueWindow && trueWindow.FindModal())
4359 msgWindow = GetAtPosition(x,y, true, false);
4361 msgWindow.SelectMouseCursor();
4364 if(guiApp.windowCaptured || trueWindow)
4366 Window prevWindow = guiApp.prevWindow;
4367 List<Window> overWindows = guiApp.overWindows;
4368 Iterator<Window> it { overWindows };
4373 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4376 result = w.OnMouseLeave(*mods);
4378 overWindows.TakeOut(w);
4382 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4384 guiApp.prevWindow.mouseInside = false;
4385 guiApp.prevWindow = null;
4389 if(trueWindow.IsDescendantOf(prevWindow))
4391 if(!overWindows.Find(prevWindow))
4392 overWindows.Add(prevWindow);
4394 // Eventually fix this not to include captured?
4395 else if(!prevWindow.OnMouseLeave(*mods))
4399 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4401 Box box = trueWindow.box;
4402 box.left += trueWindow.absPosition.x;
4403 box.right += trueWindow.absPosition.x;
4404 box.top += trueWindow.absPosition.y;
4405 box.bottom += trueWindow.absPosition.y;
4407 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4409 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4410 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4412 overX = Max(Min(overX, 32767),-32768);
4413 overY = Max(Min(overY, 32767),-32768);
4415 trueWindow.mouseInside = true;
4416 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4420 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4422 for(w : guiApp.overWindows; w == trueWindow)
4425 guiApp.overWindows.TakeOut(w);
4428 guiApp.prevWindow = trueWindow;
4431 guiApp.prevWindow = null;
4433 SelectMouseCursor();
4435 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4436 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4438 int clientX = x - (window.absPosition.x + window.clientStart.x);
4439 int clientY = y - (window.absPosition.y + window.clientStart.y);
4441 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4443 clientX = Max(Min(clientX, 32767),-32768);
4444 clientY = Max(Min(clientY, 32767),-32768);
4446 MouseMethod = (void *)window._vTbl[method];
4448 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4451 if(!MouseMethod(window, clientX, clientY, *mods))
4455 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4456 window.OnMouseLeave(*mods);
4463 if(result && w && w.clickThrough && w.parent)
4468 if(!result || !w || !w.clickThrough)
4475 // --- Mouse cursor management ---
4477 bool KeyMessage(uint method, Key key, unichar character)
4482 if(guiApp.interimWindow)
4483 this = guiApp.interimWindow;
4486 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4490 if(!style.inactive || rootWindow != this)
4492 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4493 Window modalWindow = FindModal();
4494 Window interimMaster = master ? master.rootWindow : null;
4498 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4499 status = OnSysKeyDown(key, character);
4500 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4501 status = OnSysKeyHit(key, character);
4502 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4503 status = OnSysKeyUp(key, character);
4510 // Process Key Message for Internal UI Keyboard actions
4511 if(status && !destroyed && menuBar && state != minimized)
4514 if((SmartKey)key != alt)
4515 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4518 SmartKey sk = (SmartKey) key;
4519 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4521 status = menuBar.KeyMessage(method, key, character);
4526 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4527 menuBar.OnKeyHit(escape, 0);
4529 if(!menuBar.focus && guiApp.caretOwner)
4530 guiApp.caretOwner.UpdateCaret(true, false);
4533 if(!destroyed && status)
4535 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4539 case left: case up: case right: case down:
4540 if(guiApp.windowMoving == this)
4543 int w = guiApp.windowMoving.size.w;
4544 int h = guiApp.windowMoving.size.h;
4545 int x = guiApp.windowMoving.scrolledPos.x;
4546 int y = guiApp.windowMoving.scrolledPos.y;
4550 if(key == down || key == up)
4551 step = Max(step, textCellH);
4553 step = Max(step, textCellW);
4556 if(guiApp.windowIsResizing)
4560 case left: w-=step; break;
4561 case right: w+=step; break;
4562 case up: h-=step; break;
4563 case down: h+=step; break;
4570 case left: x-=step; break;
4571 case right: x+=step; break;
4572 case up: y-=step; break;
4573 case down: y+=step; break;
4577 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4578 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4580 if(!guiApp.windowIsResizing || guiApp.resizeX)
4581 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4583 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4585 if(!guiApp.windowIsResizing || guiApp.resizeY)
4586 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4588 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4590 guiApp.interfaceDriver.SetMousePosition(x, y);
4591 ConsequentialMouseMove(true);
4599 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4601 guiApp.windowMoving.StopMoving();
4602 ConsequentialMouseMove(false);
4610 ShowSysMenu(absPosition.x, absPosition.y);
4618 if(!destroyed && status && state != minimized)
4620 // Process all the way down the children
4621 if(activeChild && !activeChild.disabled)
4623 status = activeChild.KeyMessage(method, key, character);
4625 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4626 key.code != left && key.code != right && key.code != up && key.code != down)
4628 status = activeClient.KeyMessage(method, key, character);
4632 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4634 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4635 // && defaultControl != activeChild)
4637 delete previousActive;
4638 previousActive = activeChild;
4639 if(previousActive) incref previousActive;
4641 ConsequentialMouseMove(false);
4642 if((defaultControl.active ||
4643 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4644 defaultControl.KeyMessage(method, defaultKey, character);
4650 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4652 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4659 ShowSysMenu(absPosition.x, absPosition.y);
4666 if(this != guiApp.desktop)
4668 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4670 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4672 MenuMoveOrSize(key.shift, true);
4676 else if(guiApp.windowMoving)
4678 guiApp.windowMoving.StopMoving();
4679 ConsequentialMouseMove(false);
4687 if(!destroyed && status && state != minimized)
4689 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4693 case tab: case shiftTab:
4695 Window cycleParent = this;
4696 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4697 cycleParent = master.parent;
4699 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4701 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4704 Window child = cycleParent.activeChild;
4706 // Scroll the window to include the active control
4707 if(cycleParent.sbh && !child.style.dontScrollHorz)
4709 if(child.scrolledPos.x < 0)
4710 cycleParent.sbh.Action(Position,
4711 cycleParent.scroll.x + child.scrolledPos.x, 0);
4712 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4713 cycleParent.sbh.Action(Position,
4714 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4716 if(cycleParent.sbv && !child.style.dontScrollVert)
4718 if(child.scrolledPos.y < 0)
4719 cycleParent.sbv.Action(Position,
4720 cycleParent.scroll.y + child.scrolledPos.y, 0);
4721 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4722 cycleParent.sbv.Action(Position,
4723 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4726 cycleParent.ConsequentialMouseMove(false);
4732 case f6: case shiftF6:
4733 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4735 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4736 if(parent == guiApp.desktop)
4737 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4747 if(CycleChildren(key.shift, true, false, true))
4755 // mIRC Style Window Shortcuts
4756 case alt1: case alt2: case alt3: case alt4: case alt5:
4757 case alt6: case alt7: case alt8: case alt9: case alt0:
4762 for(document = children.first; document; document = document.next)
4764 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4766 if(document == activeChild)
4768 if(document.state == minimized)
4769 document.SetState(normal, false, key);
4772 document.SetState(minimized, false, key);
4773 CycleChildren(false, true, false);
4778 if(activeChild.state == maximized && document.style.hasMaximize)
4779 document.SetState(maximized, false, key);
4780 else if(document.state == minimized)
4781 document.SetState(normal, false, key);
4782 document.Activate();
4797 if(!destroyed && status)
4799 if(state == minimized)
4804 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4806 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4808 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4809 previousActive.ActivateEx(true, false, false, true, null, null);
4810 delete previousActive;
4816 if(!destroyed && status)
4818 status = ProcessHotKeys(method, key, character);
4820 if(!destroyed && status && !modalWindow && state != minimized)
4823 status = KeyMethod(this, key, character);
4824 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4825 status = OnKeyHit(key, character);
4826 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4828 bool result = false;
4831 case ctrlUp: case ctrlDown:
4832 if(sbv && !guiApp.windowScrolling)
4833 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4835 case wheelUp: case wheelDown:
4836 if(sbv && !guiApp.windowScrolling)
4838 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4839 // Do we want to do a consequential move regardless of result in this case?
4840 ConsequentialMouseMove(false);
4843 case ctrlPageUp: case ctrlPageDown:
4844 if(sbh && !guiApp.windowScrolling)
4845 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4850 ConsequentialMouseMove(false);
4855 if(status && !destroyed && menuBar && state != minimized)
4856 status = menuBar.KeyMessage(method, key, character);
4858 if(style.interim && /*destroyed && */status && interimMaster)
4860 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4861 status = interimMaster.KeyMessage(method, key, character);
4868 bool ProcessHotKeys(uint method, Key key, unichar character)
4873 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4874 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4875 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4877 Window hotKeyWindow = hotKey.window;
4878 Window parent = hotKeyWindow.parent;
4879 Window prevActiveWindow = activeChild;
4880 // For when sys buttons are placed inside the menu bar
4881 if(parent && parent._class == class(PopupMenu))
4882 parent = parent.parent;
4884 // 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
4885 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4888 if(prevActiveWindow) incref prevActiveWindow;
4889 incref hotKeyWindow;
4890 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4891 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4894 delete hotKeyWindow;
4895 delete prevActiveWindow;
4899 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4900 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4901 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4903 // ********* WORKING ON THIS ***********
4904 if(prevActiveWindow && !guiApp.interimWindow)
4905 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4908 else if(hotKeyWindow.style.inactive)
4909 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4911 delete prevActiveWindow;
4912 delete hotKeyWindow;
4913 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4914 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4918 if(status && tabCycle)
4921 for(child = children.first; child; child = child.next)
4923 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4934 // --- Windows and graphics initialization / termination ---
4935 bool SetupRoot(void)
4939 // Setup relationship with outside world (bb root || !bb)
4940 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4941 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4945 tempExtents = new0 Extent[4];
4950 /*if(guiApp.fullScreenMode)
4951 rootWindow = guiApp.desktop;
4953 //rootWindow = parent.created ? parent.rootWindow : null;
4954 rootWindow = parent.rootWindow;
4957 against = &parent.box;
4959 against = &parent.clientArea;
4962 for(child = children.first; child; child = child.next)
4965 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4968 bool Setup(bool positionChildren)
4970 bool result = false;
4973 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4975 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4976 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4979 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4981 // This was here, is it really needed?
4982 //guiApp.interfaceDriver.ActivateRootWindow(this);
4986 displaySystem = DisplaySystem {};
4987 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4989 delete displaySystem;
4994 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4995 if(display.Create(displaySystem, windowHandle))
5002 // Sometimes icon does not show up on Windows XP if we set here...
5003 // guiApp.interfaceDriver.SetIcon(this, icon);
5005 else if(this != guiApp.desktop)
5007 display = rootWindow ? rootWindow.display : null;
5013 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
5014 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
5016 for(child = children.first; child; child = child.next)
5018 if(child.created && !child.Setup(false))
5021 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
5022 child.UpdateCaption();
5027 bool SetupDisplay(void)
5029 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
5030 if(is3D) return Window3D_SetupDisplay(this); else
5037 class_data void ** pureVTbl;
5039 bool LoadGraphics(bool creation, bool resetAnchors)
5041 bool result = false;
5042 bool success = false;
5044 WindowState stateBackup = state;
5046 if(((subclass(Window))_class).pureVTbl)
5048 if(_vTbl == _class._vTbl)
5050 _vTbl = ((subclass(Window))_class).pureVTbl;
5055 for(m = 0; m < _class.vTblSize; m++)
5057 if(_vTbl[m] == _class._vTbl[m])
5058 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5062 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
5064 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5066 _vTbl = _class._vTbl;
5071 for(m = 0; m < _class.vTblSize; m++)
5073 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5074 _vTbl[m] = _class._vTbl[m];
5079 if(guiApp.fullScreenMode || this != guiApp.desktop)
5081 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5087 display.Lock(false);
5088 if(rootWindow == this)
5090 // Set Color Palette
5091 display.SetPalette(palette, true);
5095 if(guiApp.fullScreenMode && this == guiApp.desktop)
5100 for(c=0; c<SystemCursor::enumSize; c++)
5101 if(!guiApp.systemCursors[c].bitmap)
5103 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5104 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5105 if(guiApp.systemCursors[c].bitmapName)
5107 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5108 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5109 if(guiApp.systemCursors[c].bitmap)
5110 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5115 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5117 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5118 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5120 cursor.bitmap.paletteShades = cursor.paletteShades;
5124 guiApp.cursorUpdate = true;
5127 ConsequentialMouseMove(false);
5133 // Load Window Graphic Resources
5136 if(usedFont == setFont || usedFont == window.systemFont)
5137 RemoveResource(usedFont);
5140 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5143 RemoveResource(systemFont);
5146 RemoveResource(captionFont);
5148 for(ptr = resources.first; ptr; ptr = ptr.next)
5150 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5151 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5154 AddResource(setFont);
5156 AddResource(systemFont);
5158 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5165 //if(master && master.font)
5166 if(parent && parent.font)
5170 faceName = parent.font.faceName,
5171 size = parent.font.size,
5172 bold = parent.font.bold,
5173 italic = parent.font.italic,
5174 underline = parent.font.underline
5176 //font = parent.font;
5177 watch(parent) { font { } };
5180 font = guiApp.currentSkin.SystemFont();
5187 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5188 AddResource(captionFont);
5190 if(OnLoadGraphics())
5196 //SetScrollLineStep(sbStep.x, sbStep.y);
5198 if(this != guiApp.desktop)
5202 normalAnchor = anchor;
5203 normalSizeAnchor = sizeAnchor;
5206 // Break the anchors for moveable/resizable windows
5208 if(style.fixed && style.isDocument)
5210 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5222 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5223 stateSizeAnchor = SizeAnchor {};
5228 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5233 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5234 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5237 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5241 stateAnchor = normalAnchor;
5242 stateSizeAnchor = normalSizeAnchor;
5245 position = Point { };
5246 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5257 if(Position(x, y, w, h, true, false, true, true, true, true))
5259 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5262 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5279 success = result = true;
5282 if(!creation && result)
5284 // Load menu bar first because sys buttons are on it...
5287 if(!menuBar.LoadGraphics(false, resetAnchors))
5293 for(child = children.first; child; child = child.next)
5295 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5302 CreateSystemChildren();
5306 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5309 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5312 LogErrorCode(graphicsLoadingFailed, _class.name);
5314 // Do this here to avoid problems on Windows
5315 if(rootWindow == this && parent && stateBackup == maximized)
5316 property::state = maximized;
5320 void UnloadGraphics(bool destroyWindows)
5324 // Free children's graphics
5325 for(child = children.first; child; child = child.next)
5326 child.UnloadGraphics(destroyWindows);
5329 display.Lock(false);
5332 if(guiApp.fullScreenMode && this == guiApp.desktop)
5337 for(c=0; c<SystemCursor::enumSize; c++)
5338 if(guiApp.systemCursors[c].bitmap)
5339 delete guiApp.systemCursors[c].bitmap;
5341 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5342 delete cursor.bitmap;
5344 guiApp.cursorBackground.Free();
5347 if(display && display.displaySystem)
5351 for(ptr = resources.first; ptr; ptr = ptr.next)
5355 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5360 // Free window graphics
5363 // Free skin graphics
5364 if(rootWindow == this)
5366 DisplaySystem displaySystem = display.displaySystem;
5369 display.driverData = null;
5370 display.displaySystem = null;
5374 if(displaySystem && !displaySystem.numDisplays && !is3D)
5375 delete displaySystem;
5384 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5385 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5387 if(this == guiApp.desktop || parent == guiApp.desktop)
5389 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5390 guiApp.interfaceDriver.DestroyRootWindow(this);
5394 // --- Window Hiding ---
5396 void SetVisibility(bool state)
5398 bool visible = (style.hidden || !created) ? false : state;
5399 if(visible != this.visible)
5403 this.visible = visible;
5404 for(child = children.first; child; child = child.next)
5405 child.SetVisibility(visible);
5407 ConsequentialMouseMove(false);
5408 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5412 // --- Windows and graphics initialization / termination ---
5414 bool DisplayModeChanged(void)
5416 bool result = false;
5417 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5419 guiApp.modeSwitching = true;
5420 UnloadGraphics(false);
5422 if(LoadGraphics(false, false))
5424 guiApp.modeSwitching = false;
5429 // --- Window updates system ---
5431 void UpdateDirty(Box updateBox)
5433 if(!manageDisplay) { OnRedraw(null);return; }
5436 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5439 if(display.flags.flipping)
5442 rootWindow.UpdateDisplay();
5445 UpdateBackDisplay(updateBox);
5447 if(guiApp.fullScreenMode)
5449 guiApp.cursorUpdate = true;
5450 guiApp.PreserveAndDrawCursor();
5452 if(guiApp.fullScreenMode)
5453 guiApp.RestoreCursorBackground();
5459 // This function is strictly called as a result of system window activation
5460 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5463 Window interimMaster = null;
5464 Window interimWindow = guiApp.interimWindow;
5465 if(interimWindow && interimWindow.master)
5466 interimMaster = interimWindow.master.rootWindow;
5468 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5469 // SetState(normal, false, 0);
5470 SetState(lastState, false, 0);
5472 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5476 /* WTH is this doing here?
5477 while(swap && swap.activeChild)
5479 swap = swap.activeChild;
5482 // TESTING THIS BEFORE...
5483 if(interimWindow && this == interimMaster)
5487 // Window interimSwap = this;
5488 Window menuBar = this.menuBar;
5489 if(menuBar && interimWindow.master == menuBar)
5492 while(interimSwap && interimSwap.activeChild)
5493 interimSwap = interimSwap.activeChild;
5495 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5496 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5498 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5499 //result = ActivateEx(true, true, false, activateRoot, window, null);
5504 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5505 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5507 if(interimWindow == this && interimMaster && !active)
5509 while(interimMaster && interimMaster.interim && interimMaster.master)
5511 // printf("Going up one master %s\n", interimMaster._class.name);
5512 interimMaster = interimMaster.master.rootWindow;
5514 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5515 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5521 bool DestroyEx(int64 returnCode)
5524 Timer timer, nextTimer;
5526 OldLink prevOrder = null;
5527 Window client = null;
5529 if(parent) stopwatching(parent, font);
5531 // if(window.modalSlave) return false;
5532 if(destroyed || !created)
5539 OldLink slave = master.slaves.FindLink(this);
5540 master.slaves.Delete(slave);
5543 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5549 this.returnCode = (DialogResult)returnCode;
5551 AcquireInput(false);
5556 master.hotKeys.Delete(hotKey);
5560 if(guiApp.prevWindow == this)
5562 guiApp.prevWindow = null;
5567 for(w : guiApp.overWindows; w == this)
5570 guiApp.overWindows.TakeOut(w);
5574 if(guiApp.caretOwner == this)
5576 guiApp.interfaceDriver.SetCaret(0,0,0);
5577 UpdateCaret(false, true);
5578 guiApp.caretEnabled = false;
5583 parent.childrenCycle.Remove(cycle);
5587 OldLink tmpPrev = order.prev;
5588 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5589 prevOrder = tmpPrev;
5592 client = tmpPrev ? tmpPrev.data : null;
5593 if(client == this) { client = null; break; }
5594 if(client && (client.style.hidden || client.destroyed || !client.created))
5595 tmpPrev = client.order.prev;
5599 prevOrder = tmpPrev;
5604 // If this window can be an active client, make sure the next window we activate can also be one
5605 if(!style.nonClient && style.isActiveClient)
5607 tmpPrev = prevOrder;
5610 client = tmpPrev ? tmpPrev.data : null;
5611 if(client == this) { client = null; break; }
5612 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5613 tmpPrev = client.order.prev;
5617 prevOrder = tmpPrev;
5621 if(client && client.style.hidden) client = null;
5623 // parent.childrenOrder.Remove(order);
5626 if(parent && style.isActiveClient && visible)
5628 if(state == minimized) parent.numIcons--;
5629 parent.numPositions--;
5632 // TESTING THIS HERE!
5636 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5637 // to create a window inside a rootwindow that's being destroyed)
5638 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5640 if(master && !master.destroyed /*&&
5641 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5643 if(master.defaultControl == this)
5644 master.defaultControl = null;
5647 parent.OnChildAddedOrRemoved(this, true);
5648 if(parent && !parent.destroyed /*&&
5649 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5651 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5653 if(order && prevOrder && prevOrder.data != this && active)
5655 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5657 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5658 if(parent.activeClient == this)
5660 parent.activeClient = null;
5661 parent.UpdateActiveDocument(null);
5666 if(guiApp.interimWindow == this)
5669 PropagateActive(false, null, &goOn, true);
5673 //if(window.parent.activeChild == window)
5674 parent.activeChild = null;
5675 if(!style.nonClient /*&& style.isActiveClient*/)
5677 Window previous = parent.activeClient;
5678 if(style.isActiveClient)
5679 parent.activeClient = null;
5680 parent.UpdateActiveDocument(previous);
5685 else if(parent.activeClient == this)
5687 parent.activeClient = client;
5688 parent.UpdateActiveDocument(this);
5692 if(guiApp.interimWindow == this)
5694 guiApp.interimWindow = null;
5695 if(guiApp.caretOwner)
5697 Window desktop = guiApp.desktop;
5698 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5699 guiApp.caretOwner.UpdateCaret(false, false);
5704 if(_isModal && master && master.modalSlave == this)
5705 master.modalSlave = null;
5709 if(!guiApp.caretOwner && parent.caretSize)
5711 guiApp.caretOwner = parent;
5712 parent.UpdateCaret(false, false);
5713 parent.Update(null);
5716 // Why was this commented out?
5717 GetRidOfVirtualArea();
5723 dirtyArea.Free(null);
5724 dirtyBack.Free(null);
5725 scrollExtent.Free(null);
5727 /* ATTEMPTING TO MOVE THAT ABOVE
5736 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5737 for(;(child = window.children.first);)
5739 for(; child && (child.destroyed || !child.created); child = child.next);
5748 UnloadGraphics(true);
5751 delete previousActive;
5754 // statusBar = null;
5757 if(master && !master.destroyed)
5759 //master.NotifyDestroyed(this, this.returnCode);
5760 NotifyDestroyed(master, this, this.returnCode);
5763 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5765 nextTimer = timer.next;
5766 if(timer.window == this)
5768 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5769 // timer.window = null;
5775 if(this == guiApp.windowMoving)
5778 if(guiApp.windowCaptured == this)
5780 //guiApp.windowCaptured = null;
5782 if(rootWindow != this && rootWindow)
5783 rootWindow.ConsequentialMouseMove(false);
5791 //for(child = children.first; next = child ? child.next : null, child; child = next)
5792 for(;(child = children.first); )
5794 for(; child && (child.destroyed || !child.created); child = child.next);
5804 /* // MOVED THIS UP...
5807 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5808 for(;(child = window.children.first); )
5810 for(; child && (child.destroyed || !child.created); child = child.next);
5819 while((slave = slaves.first))
5821 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5823 ((Window)slave.data).DestroyEx(0);
5828 if(guiApp.caretOwner == this)
5829 guiApp.caretOwner = null;
5831 sysButtons[0] = null;
5832 sysButtons[1] = null;
5833 sysButtons[2] = null;
5836 if(rootWindow != this)
5838 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5841 box.left -= parent.clientStart.x;
5842 box.top -= parent.clientStart.y;
5843 box.right -= parent.clientStart.x;
5844 box.bottom -= parent.clientStart.y;
5846 if(parent) parent.Update(box);
5851 OldLink slave = master.slaves.FindVoid(this);
5852 master.slaves.Delete(slave);
5858 parent.children.Remove(this);
5863 //autoCreate = false;
5866 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5867 if(((subclass(Window))_class).pureVTbl)
5869 if(_vTbl == _class._vTbl)
5871 _vTbl = ((subclass(Window))_class).pureVTbl;
5876 for(m = 0; m < _class.vTblSize; m++)
5878 if(_vTbl[m] == _class._vTbl[m])
5879 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5888 void SetStateEx(WindowState newState, bool activate)
5891 WindowState prevState = state;
5895 if(prevState != newState)
5896 lastState = prevState;
5898 if(rootWindow != this || !nativeDecorations || !windowHandle)
5900 if(style.isActiveClient && !style.hidden && prevState == minimized)
5903 // This block used to be at the end of the function... moved it for flicker problem in X
5904 // ------------------------------------------------------
5908 stateAnchor = normalAnchor;
5909 stateSizeAnchor = normalSizeAnchor;
5912 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5913 stateSizeAnchor = SizeAnchor {};
5919 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5922 byte * idBuffer = new0 byte[size];
5924 for(child = parent.children.first; child; child = child.next)
5926 if(child != this && child.state == minimized)
5928 if(child.iconID > size - 2)
5930 idBuffer = renew0 idBuffer byte[size*2];
5931 memset(idBuffer + size, 0, size);
5934 idBuffer[child.iconID] = (byte)bool::true;
5937 for(c = 0; c<size; c++)
5942 if(style.isActiveClient && !style.hidden)
5945 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5946 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5951 // TOCHECK: Why was this here?
5952 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5953 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5954 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5956 if(state != minimized || hasMinimize)
5957 Position(x, y, w, h, true, true, true, true, false, true);
5959 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5960 parent.UpdateActiveDocument(null);
5963 if(state != minimized || hasMinimize)
5964 CreateSystemChildren();
5965 // ------------------------------------------------------
5968 int GetPositionID(Window forChild)
5972 byte * idBuffer = new0 byte[size];
5975 for(child = children.first; child; child = child.next)
5977 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5979 if(child.positionID > size - 2)
5981 idBuffer = renew0 idBuffer byte[size*2];
5982 memset(idBuffer + size, 0, size);
5985 idBuffer[child.positionID] = (byte)bool::true;
5988 for(c = 0; c<size; c++)
5995 // --- Window related graphics ---
5997 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5999 palette = newPalette;
6000 if(rootWindow.display)
6001 rootWindow.display.SetPalette(palette, colorMatch);
6004 public bool AcquireInput(bool acquired)
6007 if(acquiredInput != acquired)
6009 if(active || (!visible && creationActivation == activate))
6010 result = AcquireInputEx(acquired);
6015 acquiredInput = acquired ? result : !result;
6020 void ListChildren(ListBox listBox)
6024 for(child = children.first; child; child = child.next)
6026 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
6028 DataRow row = listBox.AddRow();
6029 row.tag = (int64)(intptr)child;
6030 child.FigureCaption(caption);
6031 row.SetData(null, caption);
6036 void UpdateVisual(Box extent)
6038 if(guiApp.driver != null)
6040 if(guiApp.fullScreenMode && guiApp.desktop.display)
6042 guiApp.desktop.mutex.Wait();
6043 guiApp.desktop.display.Lock(true);
6046 if(guiApp.desktop.active)
6048 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
6050 if(guiApp.desktop.display.flags.flipping)
6051 guiApp.desktop.Update(null);
6052 guiApp.desktop.UpdateDisplay();
6053 guiApp.cursorUpdate = true;
6055 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
6057 guiApp.PreserveAndDrawCursor();
6058 // guiApp.desktop.display.ShowScreen();
6059 guiApp.cursorUpdate = false;
6060 guiApp.desktop.dirty = false;
6061 guiApp.RestoreCursorBackground();
6065 guiApp.desktop.display.Unlock();
6066 guiApp.desktop.mutex.Release();
6070 Window rootWindow = this.rootWindow;
6071 rootWindow.mutex.Wait();
6076 guiApp.SignalEvent();
6079 guiApp.waitMutex.Wait();
6080 guiApp.interfaceDriver.Lock(rootWindow);
6081 if(!rootWindow.style.hidden && rootWindow.dirty)
6083 if(rootWindow.display)
6085 rootWindow.UpdateDisplay();
6086 //rootWindow.display.ShowScreen(null);
6088 rootWindow.dirty = false;
6090 guiApp.interfaceDriver.Unlock(rootWindow);
6091 guiApp.waitMutex.Release();
6094 rootWindow.mutex.Release();
6099 void UnlockDisplay(void)
6101 guiApp.interfaceDriver.Unlock(rootWindow);
6104 void LockDisplay(void)
6106 guiApp.interfaceDriver.Lock(rootWindow);
6109 Surface GetSurface(Box box)
6111 return Redraw((box == null) ? this.box : box);
6114 void SetMousePosition(int x, int y)
6116 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6120 void IntegrationActivate(bool active)
6122 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6124 isForegroundWindow = true;
6125 ActivateEx(active, active, false, false, null, null);
6126 isForegroundWindow = false;
6131 Window QueryCapture(void)
6133 return guiApp.windowCaptured;
6136 int GetDocumentID(void)
6140 byte * idBuffer = new0 byte[size];
6143 for(child = children.first; child; child = child.next)
6145 // TO CHECK: Do we want a documentID when we already have a file name?
6146 if(child.style.isDocument && !child.fileName)
6148 if(child.documentID-1 > size - 2)
6150 idBuffer = renew0 idBuffer byte[size*2];
6151 memset(idBuffer + size, 0, size);
6154 idBuffer[child.documentID-1] = 1;
6157 for(c = 0; c<size; c++)
6165 void SetInitSize(Size size)
6168 sizeAnchor.size = size;
6169 normalSizeAnchor = sizeAnchor;
6171 // Break the anchors for moveable/resizable windows
6172 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6174 stateAnchor = normalAnchor;
6175 stateSizeAnchor = normalSizeAnchor;
6177 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6178 Position(x,y, w, h, true, true, true, true, false, true);
6182 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6184 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6186 guiApp.windowIsResizing = resize;
6187 guiApp.windowMoving = this;
6188 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6189 if(guiApp.windowIsResizing)
6191 guiApp.windowMovingStart.x += size.w - 1;
6192 guiApp.windowMovingStart.y += size.h - 1;
6194 guiApp.windowMovingBefore = scrolledPos;
6195 guiApp.windowResizingBefore = size;
6196 guiApp.windowMoving.UpdateDecorations();
6197 if(guiApp.windowIsResizing)
6198 guiApp.resizeEndX = guiApp.resizeEndY = true;
6200 if(setCursorPosition)
6201 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6205 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6206 guiApp.windowMovingStart.x += x - absPosition.x;
6207 guiApp.windowMovingStart.y += y - absPosition.y;
6210 if(guiApp.windowMoving)
6212 if(guiApp.windowMoving.style.nonClient)
6213 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6215 guiApp.windowMoving.parent.SetMouseRangeToClient();
6220 if(this == rootWindow)
6221 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6225 void SetupFileMonitor()
6229 fileMonitor = FileMonitor
6231 this, FileChange { modified = true };
6233 bool OnFileNotify(FileChange action, const char * param)
6236 fileMonitor.StopMonitoring();
6237 if(OnFileModified(action, param))
6238 fileMonitor.StartMonitoring();
6251 bool result = false;
6255 else if(guiApp && guiApp.driver != null)
6257 OldLink slaveHolder;
6259 bool visible = !style.hidden;
6263 systemParent = parent;
6264 parent = guiApp.desktop;
6266 last = parent ? parent.children.last : null;
6268 if((parent && parent != guiApp.desktop && !parent.created) ||
6269 (master && master != guiApp.desktop && !master.created))
6273 stopwatching(parent, font);
6276 property::parent = guiApp.desktop;
6277 if(!master) master = parent;
6279 if(_isModal && master.modalSlave)
6280 property::master = master.modalSlave;
6284 parent.children.Remove(this);
6287 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6288 if(slaveHolder.data == this)
6290 master.slaves.Delete(slaveHolder);
6295 if(parent == guiApp.desktop && !mutex)
6298 if(style.isDocument)
6301 parent.numDocuments--;
6302 documentID = parent.GetDocumentID();
6305 if(!style.stayOnTop)
6306 for(; last && last.style.stayOnTop; last = last.prev);
6308 parent.children.Insert((last == this) ? null : last, this);
6309 //parent.children.Add(this);
6312 dispDriver = parent.dispDriver;
6315 master.modalSlave = this;
6317 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6322 master.slaves.Add(slaveHolder = OldLink { data = this });
6327 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6329 if(style.isDefault && !master.defaultControl)
6330 master.defaultControl = this;
6332 stateAnchor = normalAnchor = anchor;
6333 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6335 // TOCHECK: Why is this here?
6336 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6337 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6339 this.visible = false;
6340 style.hidden = true;
6343 // autoCreate = true;
6351 if(parent == guiApp.desktop)
6352 Log("LoadGraphics %s\n", caption);
6354 if(LoadGraphics(true, false))
6362 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6369 if(style.hasMenuBar /*&& menu*/)
6375 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6376 interim = false, inactive = true, nonClient = true, size.h = 24
6384 // Create the system buttons
6385 CreateSystemChildren();
6387 UpdateActiveDocument(null);
6389 if(style.isDocument)
6393 MenuItem item = menu.FindItem(MenuFileSave, 0);
6394 if(item) item.disabled = !modifiedDocument && fileName;
6399 if(parent == guiApp.desktop)
6400 Log("Preemptive SetState %s\n", caption);
6403 // Preemptive Set State to ensure proper anchoring
6404 SetStateEx(state, false);
6406 style.hidden = true;
6412 for(child = children.first; child; child = next)
6415 if(!child.created && (child.autoCreate || child.wasCreated))
6422 for(link = slaves.first; link; link = next)
6424 Window slave = link.data;
6426 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6429 // Things might have happened that invalidated 'next'...
6430 // Start over the search for slaves to create.
6431 // (Added this to fix crash with Stacker & Toolbar)
6432 next = slaves.first;
6441 if(parent == guiApp.desktop)
6442 Log("Real SetState %s\n", caption);
6445 if(isActiveClient && visible)
6447 parent.numPositions--;
6448 if(state == minimized) parent.numIcons--;
6451 parent.OnChildAddedOrRemoved(this, false);
6453 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6455 // Real set state & activate for proper display & activation
6456 property::visible = visible;
6457 // SetState(state & 0x00000003, true, 0);
6458 guiApp.interfaceDriver.SetIcon(this, icon);
6463 /*if(rootWindow == this)
6464 guiApp.interfaceDriver.ActivateRootWindow(this);
6466 if(creationActivation == activate && guiApp.desktop.active)
6467 ActivateEx(true, false, true, true, null, null);
6468 else if(creationActivation == activate || creationActivation == flash)
6471 if(this == rootWindow)
6476 if(!destroyed && !noConsequential)
6477 rootWindow.ConsequentialMouseMove(false);
6488 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6494 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6496 //style.hidden = true; // !visible;
6497 style.hidden = !visible;
6498 if(master.modalSlave == this)
6499 master.modalSlave = null;
6506 void WriteCaption(Surface surface, int x, int y)
6509 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6512 void Update(Box region)
6518 rootWindow = this.rootWindow;
6520 // rootWindow.mutex.Wait();
6521 if(!destroyed && visible && display)
6526 // Testing this to avoid repetitve full update to take time...
6527 if(rootWindow.fullRender)
6529 rootWindow.dirty = true;
6532 if(dirtyArea.count == 1)
6534 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6535 if(item.box.left <= box.left &&
6536 item.box.top <= box.top &&
6537 item.box.right >= box.right &&
6538 item.box.bottom >= box.bottom)
6540 rootWindow.dirty = true;
6545 if(display.flags.flipping && !rootWindow.dirty)
6547 if(this == rootWindow)
6551 rootWindow.Update(null);
6556 rootWindow.dirty = true;
6561 realBox.left += clientStart.x;
6562 realBox.top += clientStart.y;
6563 realBox.right += clientStart.x;
6564 realBox.bottom += clientStart.y;
6570 if(realBox.right >= realBox.left &&
6571 realBox.bottom >= realBox.top)
6573 // if(!rootWindow.fullRender)
6574 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6576 for(child = children.first; child; child = child.next)
6581 box.left -= child.absPosition.x - absPosition.x;
6582 box.top -= child.absPosition.y - absPosition.y;
6583 box.right -= child.absPosition.x - absPosition.x;
6584 box.bottom -= child.absPosition.y - absPosition.y;
6585 if(box.right >= child.box.left && box.left <= child.box.right &&
6586 box.bottom >= child.box.top && box.top <= child.box.bottom)
6588 box.left -= child.clientStart.x;
6589 box.top -= child.clientStart.y;
6590 box.right -= child.clientStart.x;
6591 box.bottom -= child.clientStart.y;
6597 realBox.left += absPosition.x - rootWindow.absPosition.x;
6598 realBox.top += absPosition.y - rootWindow.absPosition.y;
6599 realBox.right += absPosition.x - rootWindow.absPosition.x;
6600 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6601 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6604 else if(this == guiApp.desktop)
6607 for(window = children.first; window; window = window.next)
6613 Box childBox = region;
6615 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6616 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6617 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6618 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6620 window.Update(childBox);
6623 window.Update(null);
6628 // rootWindow.mutex.Release();
6635 if(guiApp.windowCaptured != this)
6637 if(guiApp.windowCaptured)
6641 //Logf("Captured %s (%s)\n", caption, class.name);
6642 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6643 guiApp.windowCaptured = this;
6649 bool Destroy(int64 code)
6654 if(!destroyed && !CloseConfirmation(false)) return false;
6658 // TOCHECK: Should autoCreate be set to false here?
6669 void Move(int x, int y, int w, int h)
6671 normalAnchor = Anchor { left = x, top = y };
6672 normalSizeAnchor = SizeAnchor { size = { w, h } };
6674 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6676 if(destroyed) return;
6678 stateAnchor = normalAnchor;
6679 stateSizeAnchor = normalSizeAnchor;
6681 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6682 Position(x,y, w, h, true, true, true, true, false, true);
6686 DialogResult Modal(void)
6692 // FIXES MEMORY LEAK IF Create() FAILED
6698 void SetScrollArea(int width, int height, bool snapToStep)
6702 int stepX = sbStep.x, stepY = sbStep.y;
6703 // Needed to make snapped down position match the skin's check of client area
6704 // against realvirtual
6707 SNAPDOWN(stepX, textCellW);
6708 SNAPDOWN(stepY, textCellH);
6709 stepX = Max(stepX, textCellW);
6710 stepY = Max(stepY, textCellH);
6712 if(scrollFlags.snapX)
6713 SNAPUP(width, stepX);
6714 if(scrollFlags.snapY)
6715 SNAPUP(height, stepY);
6718 reqScrollArea.w = width;
6719 reqScrollArea.h = height;
6720 noAutoScrollArea = (width > 0 || height > 0);
6722 UpdateScrollBars(true, true);
6725 void SetScrollPosition(int x, int y)
6728 sbh.Action(setPosition, x, 0);
6732 int seen = clientSize.w, total = reqScrollArea.w;
6734 if(scrollFlags.snapX)
6735 SNAPDOWN(seen, sbStep.x);
6737 if(!total) total = seen;
6738 range = total - seen + 1;
6739 range = Max(range, 1);
6741 if(x >= range) x = range - 1;
6743 if(scrollFlags.snapX)
6744 SNAPUP(x, sbStep.x);
6747 OnHScroll(setPosition, x, 0);
6751 SNAPDOWN(x, textCellW);
6757 sbv.Action(setPosition, y, 0);
6761 int seen = clientSize.h, total = reqScrollArea.h;
6764 if(scrollFlags.snapY)
6765 SNAPDOWN(seen, sbStep.y);
6767 if(!total) total = seen;
6768 range = total - seen + 1;
6769 range = Max(range, 1);
6771 if(y >= range) y = range - 1;
6773 if(scrollFlags.snapY)
6774 SNAPUP(y, sbStep.y);
6777 OnVScroll(setPosition, y, 0);
6780 SNAPDOWN(y, textCellH);
6785 UpdateCaret(false, false);
6788 void SetScrollLineStep(int stepX, int stepY)
6794 SNAPDOWN(stepX, textCellW);
6795 SNAPDOWN(stepY, textCellH);
6796 stepX = Max(stepX, textCellW);
6797 stepY = Max(stepY, textCellH);
6800 sbh.lineStep = stepX;
6802 sbv.lineStep = stepY;
6805 void SetState(WindowState newState, bool activate, Modifiers mods)
6809 if(state == newState || OnStateChange(newState, mods))
6811 //WindowState prevState = state;
6815 // This used to be at the end of the brackets... moved for X, testing...
6816 // This has the effect of activating the window through the system...
6817 if(rootWindow == this)
6818 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6820 SetStateEx(newState, activate);
6822 if(rootWindow == this && !rootWindow.nativeDecorations)
6824 int x = position.x, y = position.y;
6827 x -= guiApp.desktop.absPosition.x;
6828 y -= guiApp.desktop.absPosition.y;
6830 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6834 //state = prevState;
6836 if(state != maximized && style.hasMaximize)
6839 for(child = parent.children.first; child; child = child.next)
6841 if(child != this && child.state == maximized)
6842 child.SetStateEx(normal, false);
6846 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6847 parent.UpdateScrollBars(true, true);
6850 // Do we really need this stuff here?
6851 // Shouldn't the Activate stuff take care of it?
6852 if(parent.rootWindow == parent && style)
6855 parent.FigureCaption(caption);
6856 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6857 parent.UpdateDecorations();
6861 rootWindow.ConsequentialMouseMove(false);
6868 BitmapResource GetIcon(SkinBitmap iconID)
6870 return guiApp.currentSkin.GetBitmap(iconID);
6873 void SetMouseRange(Box range)
6875 if(range || guiApp.fullScreenMode)
6880 clip.left = range.left + absPosition.x + clientStart.x;
6881 clip.top = range.top + absPosition.y + clientStart.y;
6882 clip.right = range.right + absPosition.x + clientStart.x;
6883 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6887 clip.left = guiApp.desktop.box.left;
6888 clip.top = guiApp.desktop.box.top;
6889 clip.right = guiApp.desktop.box.right;
6890 clip.bottom = guiApp.desktop.box.bottom;
6892 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6895 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6898 void SetMouseRangeToClient(void)
6900 if(guiApp.fullScreenMode || this != guiApp.desktop)
6902 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6903 box.Clip(clientArea);
6907 SetMouseRange(null);
6910 void SetMouseRangeToWindow(void)
6912 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6913 if(this == guiApp.desktop)
6914 SetMouseRangeToClient();
6919 // x, y: Desktop Coordinates
6920 void ShowSysMenu(int x, int y)
6923 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6926 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6927 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6931 menu, $"Move", m, NotifySelect = MenuWindowMove,
6932 disabled = !style.fixed || state == maximized
6936 menu, $"Size", s, NotifySelect = MenuWindowSize,
6937 disabled = !style.sizable || state != normal
6941 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6942 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6946 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6947 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6951 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6952 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6954 MenuDivider { menu };
6957 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6958 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6960 windowMenu.Create();
6965 ActivateEx(true, true, true, true, null, null);
6968 void MakeActive(void)
6970 ActivateEx(true, false, true, false, null, null);
6973 void SoftActivate(void)
6975 if(guiApp.desktop.active)
6980 if(this == rootWindow)
6985 void Deactivate(void)
6987 ActivateEx(false, true, true, true, null, null);
6992 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6995 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6997 bool result = false;
6998 if(activeChild && activeChild.cycle)
7000 Window modalWindow, child = activeChild;
7001 if(!clientOnly /*&& parent.tabCycle*/)
7003 Window next = child;
7006 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
7010 if(parent && parent.CycleChildren(backward, false, true, true))
7018 next = next.cycle.prev.data;
7020 next = next.cycle.next.data;
7021 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
7026 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
7027 parent.tabCycle && parent.CycleChildren(backward, false, false))
7031 if(tabCycleOnly && !tabCycle) return false;
7038 child = child.cycle.prev.data;
7040 child = child.cycle.next.data;
7041 if(child == child.parent.activeChild)
7043 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
7046 modalWindow = child.FindModal();
7049 // Scroll the window to include the active control
7050 if(sbh && !child.style.dontScrollHorz)
7052 if(child.scrolledPos.x < 0)
7053 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
7054 else if(child.scrolledPos.x + child.size.w > clientSize.w)
7055 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
7057 if(sbv && !child.style.dontScrollVert)
7059 if(child.scrolledPos.y < 0)
7060 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
7061 else if(child.scrolledPos.y + child.size.h > clientSize.h)
7062 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
7066 child = modalWindow ? modalWindow : child;
7067 child.ActivateEx(true, true, true, true, null, null);
7068 if(child.tabCycle && child.childrenCycle.first)
7069 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7077 ConsequentialMouseMove(false);
7081 void AddResource(Resource resource)
7085 ResPtr ptr { resource = resource };
7089 // Load Graphics here if window is created already
7090 if(/*created && */display)
7092 display.Lock(false);
7093 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7094 ptr.loaded = display.displaySystem.LoadResource(resource);
7098 // Temporary hack to load font right away for listbox in dropbox ...
7099 else if(master && master.display)
7101 master.display.Lock(false);
7102 master.display.displaySystem.LoadResource(resource);
7103 master.display.Unlock();
7109 void RemoveResource(Resource resource)
7114 for(ptr = resources.first; ptr; ptr = ptr.next)
7116 if(ptr.resource == resource)
7122 // Unload Graphics here if window is created already
7123 if(/*created && */display)
7127 display.Lock(false);
7128 display.displaySystem.UnloadResource(resource, ptr.loaded);
7134 resources.Delete(ptr);
7139 void SetCaret(int x, int y, int size)
7146 if(active && !style.interim && isEnabled)
7148 if(visible || !guiApp.caretOwner)
7149 guiApp.caretOwner = size ? this : null;
7151 UpdateCaret(false, false);
7154 guiApp.interfaceDriver.SetCaret(0,0,0);
7155 UpdateCaret(false, true);
7156 guiApp.caretEnabled = false;
7159 else if(style.inactive && active)
7161 guiApp.interfaceDriver.SetCaret(0,0,0);
7162 UpdateCaret(false, true);
7163 guiApp.caretEnabled = false;
7168 void Scroll(int x, int y)
7170 bool opaque = !style.drawBehind || background.a;
7171 if(opaque && display && display.flags.scrolling)
7173 Box box = clientArea;
7174 box.left += clientStart.x;
7175 box.top += clientStart.y;
7176 box.right += clientStart.x;
7177 box.bottom += clientStart.y;
7179 //scrollExtent.Free(null);
7180 scrollExtent.AddBox(box);
7181 scrolledArea.x += x;
7182 scrolledArea.y += y;
7184 //scrollExtent.Free();
7185 //scrollExtent.AddBox(clientArea);
7186 //scrollExtent.Offset(clientStart.x, clientStart.y);
7187 //scrolledArea.x = x;
7188 //scrolledArea.y = y;
7194 rootWindow.dirty = true;
7197 void ReleaseCapture()
7199 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7201 Window oldCaptured = guiApp.windowCaptured;
7202 guiApp.windowCaptured = null;
7203 guiApp.prevWindow = null;
7206 //guiApp.Log("Released Capture\n");
7208 guiApp.interfaceDriver.SetMouseCapture(null);
7210 //oldCaptured.OnMouseCaptureLost();
7213 oldCaptured.ConsequentialMouseMove(false);
7218 private void _SetCaption(const char * format, va_list args)
7225 char caption[MAX_F_STRING];
7226 vsnprintf(caption, sizeof(caption), format, args);
7227 caption[sizeof(caption)-1] = 0;
7229 this.caption = CopyString(caption);
7234 firewatchers caption;
7238 /*deprecated*/ void SetText(const char * format, ...)
7241 va_start(args, format);
7242 _SetCaption(format, args);
7246 void SetCaption(const char * format, ...)
7249 va_start(args, format);
7250 _SetCaption(format, args);
7254 bool Grab(Bitmap bitmap, Box box, bool decorations)
7256 bool result = false;
7257 if(display || this == guiApp.desktop)
7259 Box clip = {MININT, MININT, MAXINT, MAXINT};
7265 clip.Clip(clientArea);
7267 clip.Clip(this.box);
7269 if(rootWindow != this)
7271 clip.left += absPosition.y;
7272 clip.top += absPosition.y;
7273 clip.right += absPosition.x;
7274 clip.bottom += absPosition.y;
7277 if(!nativeDecorations)
7279 clip.left += decorations ? 0 : clientStart.x;
7280 clip.top += decorations ? 0 : clientStart.y;
7281 clip.right += decorations ? 0 : clientStart.x;
7282 clip.bottom += decorations ? 0 : clientStart.y;
7285 if(display && display.flags.flipping)
7287 rootWindow.Update(null);
7288 rootWindow.UpdateDisplay();
7295 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7296 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7300 result = display.Grab(bitmap, clip.left, clip.top,
7301 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7303 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7305 if(!bitmap.Convert(null, pixelFormat888, null))
7312 void GetMousePosition(int * x, int * y)
7314 int mouseX = 0, mouseY = 0;
7315 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7318 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7319 if(this != guiApp.desktop)
7321 mouseX -= absPosition.x + clientStart.x;
7322 mouseY -= absPosition.y + clientStart.y;
7329 DialogResult DoModal()
7331 DialogResult returnCode = 0;
7332 int terminated = terminateX;
7335 while(!destroyed && guiApp.driver != null)
7337 if(terminateX != terminated)
7339 terminated = terminateX;
7340 guiApp.desktop.Destroy(0);
7341 if(guiApp.desktop.created)
7344 //printf("Resetting terminate X to 0\n");
7350 guiApp.UpdateDisplay();
7351 if(!guiApp.ProcessInput(false))
7354 returnCode = this.returnCode;
7367 return !destroyed && guiApp.driver != null && terminateX < 2;
7370 DialogResult DoModalEnd()
7372 DialogResult returnCode = this.returnCode;
7377 // --- Window manipulation ---
7378 /*bool GetDisabled()
7380 bool disabled = this.disabled;
7382 for(window = this; (window = window.master); )
7393 // --- Mouse Manipulation ---
7394 void GetNCMousePosition(int * x, int * y)
7396 GetMousePosition(x, y);
7397 if(x) *x += clientStart.x;
7398 if(y) *y += clientStart.y;
7401 // --- Carets manipulation ---
7402 void GetCaretPosition(Point caretPos)
7404 caretPos = this.caretPos;
7407 int GetCaretSize(void)
7412 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7418 bool CloseConfirmation(bool parentClosing)
7431 if(!OnClose(parentClosing))
7434 // If you want to skip this, simply set modifiedDocument to false in OnClose
7435 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7437 DialogResult dialogRes;
7440 sprintf(message, $"Save changes to %s?", fileName);
7442 sprintf(message, $"Save changes to Untitled %d?", documentID);
7444 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7446 if(dialogRes == yes)
7448 // TOFIX: Precomp error if brackets are taken out
7449 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7451 else if(dialogRes == cancel)
7457 for(slave = slaves.first; slave; slave = slave.next)
7459 Window w = slave.data;
7460 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7468 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7471 for(child = children.first; child; child = child.next)
7472 if(child.isActiveClient && !child.CloseConfirmation(true))
7480 for(child = children.first; child; child = child.next)
7481 if(!child.isActiveClient && !child.CloseConfirmation(true))
7491 // Static methods... move them somewhere else?
7492 void ::RestoreCaret()
7494 if(guiApp.caretOwner)
7495 guiApp.caretOwner.UpdateCaret(false, false);
7498 void ::FreeMouseRange()
7500 guiApp.interfaceDriver.SetMouseRange(null, null);
7504 bool MenuFileClose(MenuItem selection, Modifiers mods)
7506 Window document = activeChild;
7508 document.Destroy(0);
7512 bool MenuFileExit(MenuItem selection, Modifiers mods)
7518 bool MenuFileSave(MenuItem selection, Modifiers mods)
7523 fileMonitor.fileName = null;
7526 if(OnSaveFile(fileName))
7528 //if(OnFileModified != Window::OnFileModified)
7531 fileMonitor.fileName = fileName;
7537 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7538 DialogResult answer = dialog.Modal();
7540 if(answer != yes) return (bool)answer;
7543 return MenuFileSaveAs(selection, mods);
7546 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7548 DialogResult result = (DialogResult)bool::true;
7549 FileDialog fileDialog = saveDialog;
7554 fileDialog = FileDialog {};
7559 fileDialog.filePath = fileName;
7562 char filePath[MAX_FILENAME];
7563 sprintf(filePath, "Untitled %d", documentID);
7564 fileDialog.filePath = filePath;
7566 fileMonitor.fileName = null;
7568 fileDialog.type = save;
7569 fileDialog.text = $"Save As";
7573 fileDialog.master = master.parent ? master : this;
7574 if(fileDialog.Modal() == ok)
7576 const char * filePath = fileDialog.filePath;
7578 if(OnSaveFile(filePath))
7581 property::fileName = filePath;
7582 NotifySaved(master, this, filePath);
7587 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7588 DialogResult answer = dialog.Modal();
7603 //if(OnFileModified != Window::OnFileModified && fileName)
7606 fileMonitor.fileName = fileName;
7610 return (bool)result; // Actually returning result from Yes/NoCancel message box
7613 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7615 Window document = activeChild;
7617 for(document = children.first; document; document = next)
7619 next = document.next;
7620 if(document.style.isDocument || document.fileName)
7621 document.MenuFileSave(selection, mods);
7626 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7630 for(document = children.first; document; document = document.next)
7631 //if(document.style.isDocument && document.state == minimized)
7632 if(document.style.isActiveClient && document.state == minimized)
7633 document.SetState(minimized, false, mods);
7637 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7639 Window document = activeChild;
7642 Window firstDocument = null;
7644 OldLink cycle = document.cycle.prev;
7649 if(child.style.isActiveClient && !child.style.hidden)
7653 firstDocument = child;
7654 if(child.state == minimized)
7655 child.SetState(minimized, false, mods);
7658 child.positionID = id++;
7659 child.SetState(normal, false, mods);
7660 child.anchor.left.type = cascade;
7663 child.normalSizeAnchor = *&child.sizeAnchor;
7664 child.normalAnchor = child.anchor;
7666 // Break the anchors for moveable/resizable windows
7667 if(child.style.fixed)
7669 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7671 (*&child.normalAnchor).left = x;
7672 (*&child.normalAnchor).top = y;
7673 (*&child.normalAnchor).right.type = none;
7674 (*&child.normalAnchor).bottom.type = none;
7675 (*&child.normalSizeAnchor).isClientW = false;
7676 (*&child.normalSizeAnchor).isClientH = false;
7677 (*&child.normalSizeAnchor).size.w = w;
7678 (*&child.normalSizeAnchor).size.h = h;
7679 child.anchored = false;
7682 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7684 child.stateAnchor = child.normalAnchor;
7685 child.stateSizeAnchor = child.normalSizeAnchor;
7687 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7688 child.Position(x, y, w, h, true, true, true, true, false, false);
7693 last = children.last;
7694 if(!child.style.stayOnTop)
7695 for(; last && last.style.stayOnTop; last = last.prev);
7696 children.Move(child, last);
7697 childrenOrder.Move(child.order, childrenOrder.last);
7699 if(cycle == document.cycle) break;
7703 firstDocument.Activate();
7708 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7715 // Close all closes all active clients, not all documents
7716 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7718 Window next, document;
7720 for(document = children.first; document; document = next)
7722 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7723 if(document.style.isActiveClient)
7724 if(!document.Destroy(0) && !document.style.hidden)
7730 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7732 if(style.hasMaximize && state != maximized)
7733 SetState(maximized, 0, 0);
7737 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7739 if(style.hasMinimize && state != minimized)
7741 SetState(minimized, 0, 0);
7742 parent.CycleChildren(false, true, false, true);
7747 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7749 MenuMoveOrSize(false, selection ? true : false);
7753 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7755 CycleChildren(false, true, false, true);
7759 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7761 CycleChildren(true, true, false, true);
7765 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7767 MenuMoveOrSize(true, true);
7771 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7774 SetState(normal, 0, 0);
7778 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7781 int64 id = selection.id;
7782 OldLink cycle = activeClient.cycle;
7784 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7787 Window sibling = cycle.data;
7788 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7796 document = cycle.data;
7797 document.Activate();
7799 //if(activeChild.state == maximized)
7800 // document.SetState(maximized, false, mods);
7801 //else if(document.state == minimized)
7802 // document.SetState(normal, false, mods);
7806 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7808 stayOnTop = !style.stayOnTop;
7812 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7814 Window document = activeChild;
7817 Window firstDocument = null;
7818 OldLink cycle = document.cycle;
7822 Window child = cycle.data;
7823 if(child.style.isActiveClient && !child.style.hidden)
7825 if(!firstDocument) firstDocument = child;
7826 if(child.state == minimized)
7827 child.SetState(minimized, false, mods);
7830 child.positionID = id++;
7831 child.SetState(normal, false, mods);
7832 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7834 child.anchor.left.type = hTiled;
7837 child.normalSizeAnchor = *&child.sizeAnchor;
7838 child.normalAnchor = child.anchor;
7840 // Break the anchors for moveable/resizable windows
7841 if(child.style.fixed)
7843 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7845 (*&child.normalAnchor).left = x;
7846 (*&child.normalAnchor).top = y;
7847 (*&child.normalAnchor).right.type = none;
7848 (*&child.normalAnchor).bottom.type = none;
7849 (*&child.normalSizeAnchor).isClientW = false;
7850 (*&child.normalSizeAnchor).isClientH = false;
7851 (*&child.normalSizeAnchor).size.w = w;
7852 (*&child.normalSizeAnchor).size.h = h;
7853 child.anchored = false;
7856 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7858 child.stateAnchor = child.normalAnchor;
7859 child.stateSizeAnchor = child.normalSizeAnchor;
7861 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7862 child.Position(x,y, w, h, true, true, true, true, false, true);
7867 if((cycle = cycle.next) == document.cycle) break;
7870 firstDocument.Activate();
7875 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7877 Window document = activeChild;
7880 Window firstDocument = null;
7882 OldLink cycle = document.cycle;
7887 //if(child.style.isDocument)
7888 if(child.style.isActiveClient && !child.style.hidden)
7890 if(!firstDocument) firstDocument = child;
7891 if(child.state == minimized)
7892 child.SetState(minimized, false, mods);
7895 child.positionID = id++;
7896 child.SetState(normal, false, mods);
7897 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7899 child.anchor.left.type = vTiled;
7902 child.normalSizeAnchor = *&child.sizeAnchor;
7903 child.normalAnchor = child.anchor;
7905 // Break the anchors for moveable/resizable windows
7906 if(child.style.fixed)
7908 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7910 (*&child.normalAnchor).left = x;
7911 (*&child.normalAnchor).top = y;
7912 (*&child.normalAnchor).right.type = none;
7913 (*&child.normalAnchor).bottom.type = none;
7914 (*&child.normalSizeAnchor).isClientW = false;
7915 (*&child.normalSizeAnchor).isClientH = false;
7916 (*&child.normalSizeAnchor).size.w = w;
7917 (*&child.normalSizeAnchor).size.h = h;
7918 child.anchored = false;
7921 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7923 child.stateAnchor = child.normalAnchor;
7924 child.stateSizeAnchor = child.normalSizeAnchor;
7926 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7927 child.Position(x,y, w, h, true, true, true, true, false, true);
7932 if((cycle = cycle.next) == document.cycle) break;
7935 firstDocument.Activate();
7940 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7942 WindowList dialog { master = this };
7943 Window document = (Window)(intptr)dialog.Modal();
7946 if(activeChild.state == maximized)
7947 document.SetState(maximized, false, mods);
7948 else if(document.state == minimized)
7949 document.SetState(normal, false, mods);
7950 document.Activate();
7956 virtual bool OnCreate(void);
7957 virtual void OnDestroy(void);
7958 virtual void OnDestroyed(void);
7959 virtual bool OnClose(bool parentClosing);
7960 virtual bool OnStateChange(WindowState state, Modifiers mods);
7961 virtual bool OnPostCreate(void);
7962 virtual bool OnMoving(int *x, int *y, int w, int h);
7963 virtual bool OnResizing(int *width, int *height);
7964 virtual void OnResize(int width, int height);
7965 virtual void OnPosition(int x, int y, int width, int height);
7966 virtual bool OnLoadGraphics(void);
7967 virtual void OnApplyGraphics(void);
7968 virtual void OnUnloadGraphics(void);
7969 virtual void OnRedraw(Surface surface);
7970 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7971 virtual void OnActivateClient(Window client, Window previous);
7972 virtual bool OnKeyDown(Key key, unichar ch);
7973 virtual bool OnKeyUp(Key key, unichar ch);
7974 virtual bool OnKeyHit(Key key, unichar ch);
7975 virtual bool OnSysKeyDown(Key key, unichar ch);
7976 virtual bool OnSysKeyUp(Key key, unichar ch);
7977 virtual bool OnSysKeyHit(Key key, unichar ch);
7978 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7979 virtual bool OnMouseLeave(Modifiers mods);
7980 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7981 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7982 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7983 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7984 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7985 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7986 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7987 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7988 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7989 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7990 virtual bool OnMultiTouch(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods);
7991 virtual void OnMouseCaptureLost(void);
7992 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7993 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7994 virtual void OnDrawOverChildren(Surface surface);
7995 virtual bool OnFileModified(FileChange fileChange, const char * param);
7996 virtual bool OnSaveFile(const char * fileName);
7998 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7999 // Note: A 'client' would refer to isActiveClient, rather than
8000 // being confined to the 'client area' (nonClient == false)
8001 virtual void OnChildAddedOrRemoved(Window child, bool removed);
8002 virtual void OnChildVisibilityToggled(Window child, bool visible);
8003 virtual void OnChildResized(Window child, int x, int y, int w, int h);
8005 // Skins Virtual Functions
8006 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
8007 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
8008 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
8013 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8014 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8015 virtual bool IsMouseMoving(int x, int y, int w, int h)
8019 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
8023 virtual void UpdateNonClient();
8024 virtual void SetBox(Box box); // This is used in the MySkin skin
8025 virtual bool IsInside(int x, int y)
8027 return box.IsPointInside({x, y});
8029 virtual bool IsOpaque()
8031 return (!style.drawBehind || background.a == 255);
8035 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
8036 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
8037 virtual void Window::NotifySaved(Window window, const char * filePath);
8042 property Window parent
8044 property_category $"Layout"
8047 if(value || guiApp.desktop)
8050 Window oldParent = parent;
8051 Anchor anchor = this.anchor;
8053 if(value && value.IsDescendantOf(this)) return;
8054 if(value && value == this)
8056 if(!value) value = guiApp.desktop;
8058 if(value == oldParent) return;
8060 if(!master || (master == this.parent && master == guiApp.desktop))
8061 property::master = value;
8065 parent.children.Remove(this);
8069 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8070 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
8071 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8072 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8076 last = value.children.last;
8078 if(style.isDocument)
8081 parent.numDocuments--;
8082 documentID = value.GetDocumentID();
8085 if(style.isActiveClient && !style.hidden)
8087 if(parent && parent != guiApp.desktop && !(style.hidden))
8089 if(state == minimized) parent.numIcons--;
8090 parent.numPositions--;
8094 if(!style.stayOnTop)
8095 for(; last && last.style.stayOnTop; last = last.prev);
8097 value.children.Insert(last, this);
8099 // *** NEW HERE: ***
8101 parent.childrenCycle.Delete(cycle);
8103 parent.childrenOrder.Delete(order);
8106 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8107 // Should something else be done?
8108 if(parent && parent.activeChild == this)
8109 parent.activeChild = null;
8110 if(parent && parent.activeClient == this)
8111 parent.activeClient = null;
8117 int x = position.x, y = position.y, w = size.w, h = size.h;
8121 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8122 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8124 vpw = value.clientSize.w;
8125 vph = value.clientSize.h;
8131 else if(style.fixed)
8133 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8134 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8137 anchor = this.anchor;
8139 if(anchor.left.type == offset) anchor.left.distance = x;
8140 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8141 if(anchor.top.type == offset) anchor.top.distance = y;
8142 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8143 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8144 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8145 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8146 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8147 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8148 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8150 if(!anchor.left.type && !anchor.right.type)
8152 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8153 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8155 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8156 if(!anchor.top.type && !anchor.bottom.type)
8158 anchor.vert.distance = (y + h / 2) - (vph / 2);
8159 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8161 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8164 parent.OnChildAddedOrRemoved(this, false);
8170 parent.childrenCycle.Insert(
8171 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8172 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8174 cycle = OldLink { data = this });
8175 parent.childrenOrder.Insert(
8176 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8177 order = OldLink { data = this });
8180 if(!style.hidden && style.isActiveClient)
8182 positionID = parent.GetPositionID(this);
8183 parent.numPositions++;
8184 if(state == minimized) parent.numIcons--;
8187 // *** FONT INHERITANCE ***
8188 if(!setFont && oldParent)
8189 stopwatching(oldParent, font);
8193 RemoveResource(systemFont);
8196 // TESTING WITH WATCHERS:
8197 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8198 // usedFont = setFont ? setFont : (systemFont);
8202 if(guiApp.currentSkin)
8204 systemFont = guiApp.currentSkin.SystemFont();
8207 usedFont = systemFont;
8208 AddResource(systemFont);
8216 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8225 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8227 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8228 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8231 UnloadGraphics(false);
8234 LoadGraphics(false, false);
8237 if(value.rootWindow != rootWindow)
8238 DisplayModeChanged();
8242 scrolledPos.x = MININT; // Prevent parent update
8244 bool anchored = this.anchored;
8245 property::anchor = anchor;
8246 this.anchored = anchored;
8251 if(guiApp.currentSkin)
8252 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8254 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8255 Position(x, y, w, h, true, true, true, true, false, true);
8260 // else parent = value;
8262 oldParent.OnChildAddedOrRemoved(this, true);
8265 get { return parent; }
8268 property Window master
8270 property_category $"Behavior"
8273 //if(this == value) return;
8274 if(value && value.IsSlaveOf(this)) return;
8280 OldLink slaveHolder;
8281 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8282 if(slaveHolder.data == this)
8284 master.slaves.Delete(slaveHolder);
8291 value.slaves.Add(OldLink { data = this });
8296 master.hotKeys.Remove(hotKey);
8297 value.hotKeys.Add(hotKey);
8300 if(master && master.defaultControl == this)
8301 master.defaultControl = null;
8303 if(style.isDefault && !value.defaultControl)
8304 value.defaultControl = this;
8309 get { return master ? master : parent; }
8312 property const char * caption
8314 property_category $"Appearance"
8321 caption = new char[strlen(value)+1];
8323 strcpy(caption, value);
8328 get { return caption; }
8333 property_category $"Behavior"
8342 master.hotKeys.Add(hotKey = HotKeySlot { });
8346 hotKey.window = this;
8351 master.hotKeys.Delete(hotKey);
8356 get { return hotKey ? hotKey.key : 0; }
8359 property Color background
8361 property_category $"Appearance"
8364 background.color = value;
8369 if(this == rootWindow)
8370 guiApp.interfaceDriver.SetRootWindowColor(this);
8373 get { return background.color; }
8376 property Percentage opacity
8378 property_category $"Appearance"
8381 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8382 drawBehind = (background.a == 255) ? false : true;
8384 get { return background.a / 255.0f; }
8387 property Color foreground
8389 property_category $"Appearance"
8397 get { return foreground; }
8400 property BorderStyle borderStyle
8402 property_category $"Appearance"
8405 if(!((BorderBits)value).fixed)
8407 style.hasClose = false;
8408 style.hasMaximize = false;
8409 style.hasMinimize = false;
8410 nativeDecorations = false;
8412 style.borderBits = value;
8416 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8418 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8419 Position(x, y, w, h, true, true, true, true, false, true);
8420 CreateSystemChildren();
8423 get { return (BorderStyle)style.borderBits; }
8426 property Size minClientSize
8428 property_category $"Layout"
8429 set { minSize = value; }
8430 get { value = minSize; }
8433 property Size maxClientSize
8435 property_category $"Layout"
8436 set { maxSize = value; }
8437 get { value = maxSize; }
8440 property bool hasMaximize
8442 property_category $"Window Style"
8445 style.hasMaximize = value;
8446 if(value) { style.fixed = true; style.contour = true; }
8450 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8452 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8453 Position(x, y, w, h, true, true, true, true, false, true);
8455 CreateSystemChildren();
8458 get { return style.hasMaximize; }
8461 property bool hasMinimize
8463 property_category $"Window Style"
8466 style.hasMinimize = value;
8467 if(value) { style.fixed = true; style.contour = true; }
8471 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8473 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8474 Position(x, y, w, h, true, true, true, true, false, true);
8476 CreateSystemChildren();
8479 get { return style.hasMinimize; }
8482 property bool hasClose
8484 property_category $"Window Style"
8487 style.hasClose = value;
8488 if(value) { style.fixed = true; style.contour = true; }
8492 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8493 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8494 Position(x, y, w, h, true, true, true, true, false, true);
8495 CreateSystemChildren();
8498 get { return style.hasClose; }
8501 property bool nonClient
8503 property_category $"Layout"
8506 style.nonClient = value;
8508 style.stayOnTop = true;
8510 get { return style.nonClient; }
8513 property bool inactive
8515 property_category $"Behavior"
8520 // *** NEW HERE: ***
8524 parent.childrenCycle.Delete(cycle);
8526 parent.childrenOrder.Delete(order);
8533 active = false; // true;
8534 if(parent.activeChild == this)
8535 parent.activeChild = null;
8536 if(parent.activeClient == this)
8537 parent.activeClient = null;
8546 parent.childrenCycle.Insert(
8547 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8548 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8550 cycle = OldLink { data = this });
8552 parent.childrenOrder.Insert(
8553 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8554 order = OldLink { data = this });
8557 style.inactive = value;
8559 get { return style.inactive; }
8562 property bool clickThrough
8564 property_category $"Behavior"
8565 set { style.clickThrough = value; }
8566 get { return style.clickThrough; }
8569 property bool isRemote
8571 property_category $"Behavior"
8572 set { style.isRemote = value; }
8573 get { return style.isRemote; }
8576 property bool noCycle
8578 property_category $"Behavior"
8579 set { style.noCycle = value; }
8580 get { return style.noCycle; }
8583 property bool isModal
8585 property_category $"Behavior"
8586 set { style.modal = value; }
8587 get { return style.modal; }
8590 property bool interim
8592 property_category $"Behavior"
8593 set { style.interim = value; }
8594 get { return style.interim; }
8597 property bool tabCycle
8599 property_category $"Behavior"
8600 set { style.tabCycle = value; }
8601 get { return style.tabCycle; }
8604 property bool isDefault
8606 property_category $"Behavior"
8614 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8615 if(sibling != this && sibling.style.isDefault)
8616 sibling.style.isDefault = false;*/
8617 if(master.defaultControl)
8618 master.defaultControl.style.isDefault = false;
8619 master.defaultControl = this;
8621 else if(master.defaultControl == this)
8622 master.defaultControl = null;
8626 style.isDefault = value;
8628 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8630 get { return style.isDefault; }
8633 property bool drawBehind
8635 property_category $"Window Style"
8636 set { style.drawBehind = value; }
8637 get { return style.drawBehind; }
8640 property bool hasMenuBar
8642 property_category $"Window Style"
8652 if(created && !menuBar)
8659 anchor = Anchor { top = 23, left = 1, right = 1 },
8661 inactive = true, nonClient = true
8666 else if(created && menuBar)
8671 style.hasMenuBar = value;
8673 get { return style.hasMenuBar; }
8676 property bool hasStatusBar
8678 property_category $"Window Style"
8685 statusBar = StatusBar { this };
8693 style.hasStatusBar = value;
8695 get { return style.hasStatusBar; }
8697 property bool stayOnTop
8699 property_category $"Window Style"
8704 if(created && !style.stayOnTop)
8706 if(rootWindow == this)
8707 guiApp.interfaceDriver.OrderRootWindow(this, true);
8708 else if(parent.children.last != this)
8710 parent.children.Move(this, parent.children.last);
8714 style.stayOnTop = true;
8718 if(created && style.stayOnTop)
8720 if(rootWindow == this)
8721 guiApp.interfaceDriver.OrderRootWindow(this, false);
8728 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8729 order && ((Window)order.data).style.stayOnTop;
8730 order = (order == parent.childrenOrder.first) ? null : order.prev);
8731 last = order ? order.data : null;
8735 for(last = parent.children.last;
8736 last && last.style.stayOnTop;
8740 parent.children.Move(this, last);
8744 style.stayOnTop = false;
8747 get { return style.stayOnTop; }
8752 property_category $"Window Style"
8762 if(menuBar && !value)
8769 if(!menuBar && style.hasMenuBar && value)
8773 this, menu = value, isMenuBar = true,
8774 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8775 inactive = true, nonClient = true
8779 UpdateActiveDocument(null);
8782 get { return menu; }
8785 property FontResource font
8787 property_category $"Appearance"
8789 isset { return setFont ? true : false; }
8794 if(value && !setFont) { stopwatching(parent, font); }
8795 else if(!value && setFont)
8801 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8810 RemoveResource(setFont);
8815 RemoveResource(systemFont);
8822 AddResource(setFont);
8825 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8828 systemFont = guiApp.currentSkin.SystemFont();
8830 usedFont = systemFont;
8831 AddResource(systemFont);
8839 get { return usedFont; }
8842 property SizeAnchor sizeAnchor
8844 property_category $"Layout"
8847 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8848 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8849 sizeAnchor.isClientW != sizeAnchor.isClientH;
8856 normalSizeAnchor = sizeAnchor;
8858 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8860 stateAnchor = normalAnchor;
8861 stateSizeAnchor = normalSizeAnchor;
8863 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8864 Position(x,y, w, h, true, true, true, true, false, true);
8871 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8872 sizeAnchor.isClientW,
8873 sizeAnchor.isClientH
8880 property_category $"Layout"
8883 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8884 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8885 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8891 sizeAnchor.isClientW = false;
8892 sizeAnchor.isClientH = false;
8893 sizeAnchor.size = value;
8895 normalSizeAnchor = sizeAnchor;
8897 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8899 stateAnchor = normalAnchor;
8900 stateSizeAnchor = normalSizeAnchor;
8902 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8903 Position(x, y, w, h, true, true, true, true, false, true);
8904 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8907 get { value = size; }
8910 property Size clientSize
8912 property_category $"Layout"
8915 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8916 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8917 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8922 sizeAnchor.isClientW = true;
8923 sizeAnchor.isClientH = true;
8924 sizeAnchor.size = value;
8926 normalSizeAnchor = sizeAnchor;
8928 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8930 stateAnchor = normalAnchor;
8931 stateSizeAnchor = normalSizeAnchor;
8933 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8934 Position(x,y, w, h, true, true, true, true, false, true);
8935 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8938 get { value = this ? clientSize : { 0, 0 }; }
8941 property Size initSize { get { value = sizeAnchor.size; } };
8943 property Anchor anchor
8945 property_category $"Layout"
8946 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8952 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8954 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8955 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8957 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8959 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8960 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8964 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8966 anchor.left.distance = 0;
8967 anchor.horz.type = 0;
8969 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8971 anchor.top.distance = 0;
8972 anchor.vert.type = 0;
8981 normalAnchor = anchor;
8983 // Break the anchors for moveable/resizable windows
8984 /*if(style.fixed ) //&& value.left.type == cascade)
8986 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8988 this.anchor = normalAnchor = Anchor { left = x, top = y };
8989 normalSizeAnchor = SizeAnchor { { w, h } };
8992 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8994 stateAnchor = normalAnchor;
8995 stateSizeAnchor = normalSizeAnchor;
8997 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8998 Position(x, y, w, h, true, true, true, true, false, true);
9007 get { value = this ? anchor : Anchor { }; }
9010 property Point position
9012 property_category $"Layout"
9015 if(value == null) return;
9017 anchor.left = value.x;
9018 anchor.top = value.y;
9019 anchor.right.type = none;
9020 anchor.bottom.type = none;
9025 normalAnchor = anchor;
9027 // Break the anchors for moveable/resizable windows
9031 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9033 normalAnchor.left = x;
9034 normalAnchor.top = y;
9035 normalAnchor.right.type = none;
9036 normalAnchor.bottom.type = none;
9037 normalSizeAnchor.size.width = w;
9038 normalSizeAnchor.size.height = h;
9042 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9044 stateAnchor = normalAnchor;
9045 stateSizeAnchor = normalSizeAnchor;
9047 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9048 Position(x,y, w, h, true, true, true, true, false, true);
9052 get { value = position; }
9055 property bool disabled
9057 property_category $"Behavior"
9060 if(this && disabled != value)
9067 get { return (bool)disabled; }
9070 property bool isEnabled
9075 for(parent = this; parent; parent = parent.parent)
9082 property WindowState state
9084 property_category $"Behavior"
9085 set { SetState(value, false, 0); }
9086 get { return this ? state : 0; }
9089 property bool visible
9091 property_category $"Behavior"
9094 if(this && !value && !style.hidden && parent)
9096 bool wasActiveChild = parent.activeChild == this;
9097 Window client = null;
9099 style.hidden = true;
9100 if(style.isActiveClient)
9102 parent.numPositions--;
9103 if(state == minimized) parent.numIcons--;
9108 OldLink prevOrder = null;
9110 if(rootWindow == this)
9111 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9114 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9117 box.left -= parent.clientStart.x;
9118 box.top -= parent.clientStart.y;
9119 box.right -= parent.clientStart.x;
9120 box.bottom -= parent.clientStart.y;
9124 if(_isModal && master && master.modalSlave == this)
9125 master.modalSlave = null;
9129 OldLink tmpPrev = order.prev;
9130 client = tmpPrev ? tmpPrev.data : null;
9131 if(client && !client.style.hidden && !client.destroyed && client.created)
9132 prevOrder = tmpPrev;
9135 client = tmpPrev ? tmpPrev.data : null;
9136 if(client == this) { client = null; break; }
9137 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9139 tmpPrev = client.order.prev;
9144 prevOrder = tmpPrev;
9149 // If this window can be an active client, make sure the next window we activate can also be one
9150 if(!style.nonClient && style.isActiveClient)
9152 tmpPrev = prevOrder;
9155 client = tmpPrev ? tmpPrev.data : null;
9156 if(client == this) { client = null; break; }
9157 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9159 tmpPrev = client.order.prev;
9164 prevOrder = tmpPrev;
9168 if(client && client.style.hidden) client = null;
9172 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9174 if(order && prevOrder && prevOrder.data != this)
9175 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9177 ActivateEx(false, false, false, true, null, null);
9179 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9180 if(parent.activeClient == this)
9182 parent.activeClient = null;
9183 parent.UpdateActiveDocument(null);
9186 else if(parent.activeClient == this)
9188 parent.activeClient = client;
9189 parent.UpdateActiveDocument(this);
9192 // *** Not doing this anymore ***
9195 parent.childrenCycle.Delete(cycle);
9197 parent.childrenOrder.Delete(order);
9202 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9207 else if(this && value && style.hidden)
9209 style.hidden = false;
9212 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9213 if(rootWindow == this)
9214 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9216 if(_isModal && master)
9217 master.modalSlave = this;
9219 if(style.isActiveClient)
9221 positionID = parent.GetPositionID(this);
9222 parent.numPositions++;
9223 if(state == minimized) parent.numIcons++;
9226 // *** NOT DOING THIS ANYMORE ***
9228 if(!(style.inactive))
9230 if(!(style.noCycle))
9232 cycle = parent.childrenCycle.AddAfter(
9233 (parent.activeChild && parent.activeChild.cycle) ?
9234 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9237 order = parent.childrenOrder.AddAfter(
9238 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9245 if(true || !parent.activeChild)
9246 ActivateEx(true, false, true, true, null, null);
9248 if(creationActivation == activate && guiApp.desktop.active)
9249 ActivateEx(true, false, true, true, null, null);
9250 else if((creationActivation == activate || creationActivation == flash) && !object)
9253 if(this == rootWindow)
9257 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9261 ConsequentialMouseMove(false);
9267 style.hidden = !value;
9270 get { return (style.hidden || !setVisible) ? false : true; }
9273 property bool isDocument
9275 property_category $"Document"
9276 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9277 get { return style.isDocument; }
9280 property bool mergeMenus
9282 property_category $"Window Style"
9283 set { mergeMenus = value; }
9284 get { return (bool)mergeMenus; }
9287 property bool hasHorzScroll
9289 property_category $"Window Style"
9294 if(!style.hasHorzScroll && created)
9296 CreateSystemChildren();
9297 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9300 else if(style.hasHorzScroll)
9304 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9306 style.hasHorzScroll = value;
9309 get { return style.hasHorzScroll; }
9312 property bool hasVertScroll
9314 property_category $"Window Style"
9319 if(!style.hasVertScroll && created)
9321 style.hasVertScroll = true;
9322 CreateSystemChildren();
9323 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9326 else if(style.hasVertScroll)
9330 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9332 style.hasVertScroll = value;
9334 get { return style.hasVertScroll; }
9337 property bool dontHideScroll
9339 property_category $"Behavior"
9342 scrollFlags.dontHide = value;
9345 //UpdateScrollBars(true, true);
9346 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9350 // UpdateScrollBars(true, true);
9351 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9354 get { return scrollFlags.dontHide; }
9357 property bool dontScrollVert
9359 property_category $"Behavior"
9360 set { style.dontScrollVert = value; }
9361 get { return style.dontScrollVert; }
9363 property bool dontScrollHorz
9365 property_category $"Behavior"
9366 set { style.dontScrollHorz = value; }
9367 get { return style.dontScrollHorz; }
9370 property bool snapVertScroll
9372 property_category $"Behavior"
9375 scrollFlags.snapY = value;
9376 if(sbv) sbv.snap = value;
9378 get { return scrollFlags.snapY; }
9380 property bool snapHorzScroll
9382 property_category $"Behavior"
9385 scrollFlags.snapX = value;
9386 if(sbh) sbh.snap = value;
9388 get { return scrollFlags.snapX; }
9391 property Point scroll
9393 property_category $"Behavior"
9394 set { if(this) SetScrollPosition(value.x, value.y); }
9395 get { value = scroll; }
9398 property bool modifyVirtualArea
9400 property_category $"Behavior"
9401 set { modifyVirtArea = value; }
9402 get { return (bool)modifyVirtArea; }
9405 property bool dontAutoScrollArea
9407 property_category $"Behavior"
9408 // Activating a child control out of view will automatically scroll to make it in view
9409 set { noAutoScrollArea = value; }
9410 get { return (bool)noAutoScrollArea; }
9413 property const char * fileName
9415 property_category $"Document"
9420 if(menu && ((!fileName && value) || (fileName && !value)))
9422 MenuItem item = menu.FindItem(MenuFileSave, 0);
9423 if(item) item.disabled = !modifiedDocument && value;
9428 if(value && value[0])
9429 fileName = CopyString(value);
9431 if(parent && this == parent.activeClient)
9432 parent.UpdateActiveDocument(null);
9436 // if(style.isDocument)
9438 fileMonitor.fileName = value;
9440 get { return fileName; }
9445 property_category $"Data"
9450 property bool modifiedDocument
9452 property_category $"Document"
9455 if(style.isDocument || fileName)
9459 MenuItem item = menu.FindItem(MenuFileSave, 0);
9460 if(item) item.disabled = !value && fileName;
9464 if(modifiedDocument != value)
9466 modifiedDocument = value;
9467 if(style.isDocument || fileName)
9471 get { return (bool)modifiedDocument; }
9474 property bool showInTaskBar
9476 property_category $"Window Style"
9479 style.showInTaskBar = value;
9480 #if defined(__WIN32__)
9481 Win32UpdateStyle(this);
9484 get { return style.showInTaskBar; }
9486 property FileDialog saveDialog { set { saveDialog = value; } };
9487 property bool isActiveClient
9489 property_category $"Behavior"
9492 if(parent && style.isActiveClient != value && !style.hidden)
9496 if(state == minimized) parent.numIcons++;
9497 parent.numPositions++;
9501 if(state == minimized) parent.numIcons--;
9502 parent.numPositions--;
9505 style.isActiveClient = value;
9507 get { return style.isActiveClient; }
9510 property Cursor cursor
9512 property_category $"Appearance"
9516 SelectMouseCursor();
9518 get { return cursor; }
9521 //#if !defined(ECERE_VANILLA)
9522 property const char * name
9524 property_category $"Design"
9527 return (this && object) ? object.name : null;
9532 activeDesigner.RenameObject(object, value);
9536 property const char * displayDriver
9538 property_category $"Behavior"
9541 dispDriver = GetDisplayDriver(value);
9542 //DisplayModeChanged();
9546 return dispDriver ? dispDriver.name : null;
9550 // RUNTIME PROPERTIES
9551 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9552 property Size scrollArea
9554 property_category $"Behavior"
9558 SetScrollArea(value.w, value.h, false);
9560 SetScrollArea(0,0, true);
9562 get { value = scrollArea; }
9565 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9570 property_category $"Layout"
9571 set { if(this) is3D = value; }
9572 get { return (bool)is3D; }
9575 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9577 // Will be merged with font later
9578 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9579 property Point clientStart { get { value = clientStart; } };
9580 property Point absPosition { get { value = absPosition; } };
9581 property Anchor normalAnchor { get { value = normalAnchor; } };
9582 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9583 property bool active { get { return (bool)active; } };
9584 property bool created { get { return (bool)created; } };
9585 property bool destroyed { get { return (bool)destroyed; } };
9586 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9587 property Window firstChild { get { return children.first; } };
9588 property Window lastChild { get { return children.last; } };
9589 property Window activeClient { get { return activeClient; } };
9590 property Window activeChild { get { return activeChild; } };
9591 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9592 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9593 property ScrollBar horzScroll { get { return sbh; } };
9594 property ScrollBar vertScroll { get { return sbv; } };
9595 property StatusBar statusBar { get { return statusBar; } };
9596 property Window rootWindow { get { return rootWindow; } };
9597 property bool closing { get { return (bool)closing; } set { closing = value; } };
9598 property int documentID { get { return documentID; } };
9599 property Window previous { get { return prev; } }
9600 property Window next { get { return next; } }
9601 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9602 property PopupMenu menuBar { get { return menuBar; } }
9603 property ScrollBar sbv { get { return sbv; } }
9604 property ScrollBar sbh { get { return sbh; } }
9605 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9606 property void * systemHandle { get { return windowHandle; } }
9607 property Button minimizeButton { get { return sysButtons[0]; } };
9608 property Button maximizeButton { get { return sysButtons[1]; } };
9609 property Button closeButton { get { return sysButtons[2]; } };
9610 property BitmapResource icon
9612 get { return icon; }
9616 if(icon) incref icon;
9618 guiApp.interfaceDriver.SetIcon(this, value);
9621 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9622 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9623 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9624 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9625 property bool nativeDecorations
9627 get { return (bool)nativeDecorations; }
9628 set { nativeDecorations = value; }
9629 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9632 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9633 bool result = false;
9634 if(nativeDecorations)
9636 if(rootWindow == this)
9640 if(formDesigner && activeDesigner)
9642 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9643 Window form = cd ? cd.form : null;
9644 if(form && parent == form.parent)
9649 return result != style.fixed;
9653 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9655 property const char * text
9657 property_category $"Deprecated"
9659 set { property::caption = value; }
9660 get { return property::caption; }
9666 WindowBits style; // Window Style
9667 char * caption; // Name / Caption
9668 Window parent; // Parent window
9669 OldList children; // List of children in Z order
9670 Window activeChild; // Child window having focus
9671 Window activeClient;
9672 Window previousActive; // Child active prior to activating the default child
9673 Window master; // Window owning and receiving notifications concerning this window
9674 OldList slaves; // List of windows belonging to this window
9675 Display display; // Display this window is drawn into
9677 Point position; // Position in parent window client area
9678 Point absPosition; // Absolute position
9679 Point clientStart; // Client area position from (0,0) in this window
9681 Size clientSize; // Client area size
9682 Size scrollArea; // Virtual Scroll area size
9683 Size reqScrollArea; // Requested virtual area size
9684 Point scroll; // Virtual area scrolling position
9685 ScrollBar sbh, sbv; // Scrollbar window handles
9686 Cursor cursor; // Mouse cursor used for this window
9689 StatusBar statusBar;
9690 Button sysButtons[3];
9692 Box clientArea; // Client Area box clipped to parent
9694 HotKeySlot hotKey; // HotKey for this window
9698 ScrollFlags scrollFlags;// Window Scrollbar Flags
9699 int64 id; // Control ID
9701 ColorAlpha background; // Background color used to draw the window area
9703 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9704 OldList childrenCycle; // Cycling order
9705 OldLink cycle; // Element of parent's cycling order
9706 OldList childrenOrder; // Circular Z-Order
9707 OldLink order; // Element of parent's circular Z-Order
9708 Window modalSlave; // Slave window blocking this window's interaction
9710 Window rootWindow; // Topmost system managed window
9711 void * windowHandle; // System window handle
9713 DialogResult returnCode;// Return code for modal windows
9715 Point sbStep; // Scrollbar line scrolling steps
9718 SizeAnchor stateSizeAnchor;
9720 Anchor normalAnchor;
9721 SizeAnchor normalSizeAnchor;
9723 Size skinMinSize; // Minimal window size based on style
9724 Point scrolledPos; // Scrolled position
9725 Box box; // Window box clipped to parent
9726 Box * against; // What to clip the box to
9728 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9729 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9730 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9731 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9732 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9733 Point scrolledArea; // Distance to scroll area by
9734 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9736 OldList hotKeys; // List of the hotkeys of all children
9737 Window defaultControl; // Default child control
9741 ColorAlpha * palette; // Color palette used for this window
9743 int caretSize; // Size of caret, non zero if a caret is present
9744 Point caretPos; // Caret position
9746 void * systemParent; // Parent System Window for embedded windows
9753 WindowState lastState;
9755 FileMonitor fileMonitor;
9757 FontResource setFont, systemFont;
9758 FontResource usedFont;
9759 FontResource captionFont;
9761 FileDialog saveDialog;
9763 SizeAnchor sizeAnchor;
9765 // FormDesigner data
9768 Extent * tempExtents; //[4];
9769 BitmapResource icon;
9771 CreationActivationOption creationActivation;
9774 bool active:1; // true if window and ancestors are active
9775 bool acquiredInput:1; // true if the window is processing state based input
9776 bool modifiedDocument:1;
9777 bool disabled:1; // true if window cannot interact
9778 bool isForegroundWindow:1;// true while a root window is being activated
9779 bool visible:1; // Visibility flag
9780 bool destroyed:1; // true if window is being destroyed
9781 bool anchored:1; // true if this window is repositioned when the parent resizes
9782 bool dirty:1; // Flag set to true if any descendant must be redrawn
9788 bool modifyVirtArea:1;
9789 bool noAutoScrollArea:1;
9792 bool setVisible:1; // FOR FORM DESIGNER
9798 bool useSharedMemory:1;
9801 bool nativeDecorations:1;
9802 bool manageDisplay:1;
9803 bool formDesigner:1; // True if we this is running in the form editor
9804 bool requireRemaximize:1;
9805 bool noConsequential:1;
9808 // Checks used internally for them not to take effect in FormDesigner
9809 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9810 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9812 WindowController controller;
9814 public property WindowController controller
9816 get { return controller; }
9820 controller.setWindow(null);
9826 controller.setWindow(this);
9831 public property bool noConsequential
9833 set { noConsequential = value; }
9834 get { return noConsequential; }
9838 public class CommonControl : Window
9840 // creationActivation = doNothing;
9843 public property const String toolTip
9845 property_category $"Appearance"
9848 if(created) CommonControl::OnDestroy();
9850 toolTip = value ? ToolTip { tip = value; } : null;
9852 if(created) CommonControl::OnCreate();
9854 get { return toolTip ? toolTip.tip : null; }
9860 // (Very) Ugly work around for the fact that the parent watcher
9861 // won't fire when it's already been disconnected...
9862 eInstance_FireSelfWatchers(toolTip,
9863 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9869 toolTip.parent = this;
9878 public class Percentage : float
9880 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9884 sprintf(string, "%.2f", this);
9885 c = strlen(string)-1;
9888 if(string[c] != '0')
9889 last = Max(last, c);
9890 if(string[c] == '.')
9903 public void ApplySkin(Class c, const char * name, void ** vTbl)
9905 char className[1024];
9910 subclass(Window) wc = (subclass(Window))c;
9911 subclass(Window) base = (subclass(Window))c.base;
9913 sprintf(className, "%sSkin_%s", name, c.name);
9914 wc.pureVTbl = c._vTbl;
9915 c._vTbl = new void *[c.vTblSize];
9916 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9917 sc = eSystem_FindClass(c.module.application, className);
9921 for(m = 0; m < c.base.vTblSize; m++)
9923 if(c._vTbl[m] == base.pureVTbl[m])
9924 c._vTbl[m] = vTbl[m];
9929 for(m = 0; m < c.vTblSize; m++)
9931 if(sc._vTbl[m] != wc.pureVTbl[m])
9932 c._vTbl[m] = sc._vTbl[m];
9936 for(d = c.derivatives.first; d; d = d.next)
9938 ApplySkin(d.data, name, c._vTbl);
9942 public void UnapplySkin(Class c)
9944 subclass(Window) wc = (subclass(Window))c;
9947 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9950 c._vTbl = wc.pureVTbl;
9954 for(d = c.derivatives.first; d; d = d.next)
9956 UnapplySkin(d.data);
9960 void CheckFontIntegrity(Window window)
9965 if(window.usedFont && window.usedFont.font == 0xecececec)
9967 FontResource uf = window.usedFont;
9968 char * className = window._class.name;
9969 char * text = window.text;
9972 for(c = window.firstChild; c; c = c.next)
9973 CheckFontIntegrity(c);
9977 public class ControllableWindow : Window
9979 /*WindowController controller;
9980 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9981 ~ControllableWindow() { delete controller; }*/
9984 class WindowControllerInterface : ControllableWindow
9986 bool OnKeyDown(Key key, unichar ch)
9988 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9991 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9993 result = onKeyDown(controller.window, key, ch);
9998 bool OnKeyUp(Key key, unichar ch)
10000 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
10003 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
10005 result = onKeyUp(controller.window, key, ch);
10010 bool OnKeyHit(Key key, unichar ch)
10012 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
10015 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
10017 result = onKeyHit(controller.window, key, ch);
10022 bool OnMouseMove(int x, int y, Modifiers mods)
10024 bool result = controller.OnMouseMove ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods) : true;
10027 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
10029 result = onMouseMove(controller.window, x, y, mods);
10034 bool OnLeftButtonDown(int x, int y, Modifiers mods)
10036 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10039 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
10040 if(onLeftButtonDown)
10041 result = onLeftButtonDown(controller.window, x, y, mods);
10046 bool OnLeftButtonUp(int x, int y, Modifiers mods)
10048 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10051 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
10053 result = onLeftButtonUp(controller.window, x, y, mods);
10058 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
10060 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10063 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
10064 if(onLeftDoubleClick)
10065 result = onLeftDoubleClick(controller.window, x, y, mods);
10070 bool OnRightButtonDown(int x, int y, Modifiers mods)
10072 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10075 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
10076 if(onRightButtonDown)
10077 result = onRightButtonDown(controller.window, x, y, mods);
10082 bool OnRightButtonUp(int x, int y, Modifiers mods)
10084 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10087 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
10088 if(onRightButtonUp)
10089 result = onRightButtonUp(controller.window, x, y, mods);
10094 bool OnRightDoubleClick(int x, int y, Modifiers mods)
10096 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10099 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
10100 if(onRightDoubleClick)
10101 result = onRightDoubleClick(controller.window, x, y, mods);
10106 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10108 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10111 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10112 if(onMiddleButtonDown)
10113 result = onMiddleButtonDown(controller.window, x, y, mods);
10118 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10120 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10123 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10124 if(onMiddleButtonUp)
10125 result = onMiddleButtonUp(controller.window, x, y, mods);
10130 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10132 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10135 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10136 if(onMiddleDoubleClick)
10137 onMiddleDoubleClick(controller.window, x, y, mods);
10142 bool OnMultiTouch(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods)
10144 bool result = controller.OnMultiTouch ? ((bool(*)(Window, WindowController, TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers))(void *)controller.OnMultiTouch)((Window)controller.controlled, controller, event, infos, mods) : true;
10147 bool(* onMultiTouch)(Window, TouchPointerEvent, Array<TouchPointerInfo>, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMultiTouch];
10149 onMultiTouch(controller.window, event, infos, mods);
10154 void OnResize(int width, int height)
10156 if(controller.OnResize)
10157 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10159 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10161 onResize(controller.window, width, height);
10165 void OnRedraw(Surface surface)
10167 if(controller.OnRedraw)
10168 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10170 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10172 onRedraw(controller.window, surface);
10178 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10181 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10183 result = onCreate(controller.window);
10188 bool OnLoadGraphics()
10190 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10193 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10195 result = onLoadGraphics(controller.window);
10200 void OnUnloadGraphics()
10202 if(controller.OnUnloadGraphics)
10203 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10205 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10206 if(onUnloadGraphics)
10207 onUnloadGraphics(controller.window);
10212 public class WindowController<class V>
10214 void setWindow(Window value)
10216 uint size = class(Window).vTblSize;
10220 windowVTbl = new void *[size];
10221 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10222 if(value._vTbl == value._class._vTbl)
10224 value._vTbl = new void *[value._class.vTblSize];
10225 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10229 for(c = 0; c < size; c++)
10231 void * function = class(WindowControllerInterface)._vTbl[c];
10232 if(function && function != DefaultFunction)
10233 value._vTbl[c] = function;
10235 value._vTbl[c] = windowVTbl[c];
10241 memcpy(window._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10247 property Window window
10249 get { return window; }
10251 property V controlled
10253 set { controlled = value; }
10254 get { return controlled; }
10256 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10257 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10258 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10259 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10260 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10261 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10262 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10263 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10264 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10265 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10266 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10267 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10268 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10269 virtual bool V::OnMultiTouch(WindowController controller, TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods);
10270 virtual void V::OnResize(WindowController controller, int width, int height);
10271 virtual void V::OnRedraw(WindowController controller, Surface surface);
10272 virtual bool V::OnCreate(WindowController controller);
10273 virtual bool V::OnLoadGraphics(WindowController controller);
10274 virtual void V::OnUnloadGraphics(WindowController controller);
10277 public int (** windowVTbl)();
10281 ~WindowController()