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)
1142 tilingH = (int)sqrt(numTiling);
1143 tilingW = numTiling / tilingH;
1146 tilingH = tilingW = 0;
1152 tilingW = (int)sqrt(numTiling);
1153 tilingH = numTiling / tilingW;
1156 tilingH = tilingW = 0;
1159 leftOver = numTiling - tilingH * tilingW;
1162 tilingSplit = (tilingW - leftOver) * tilingH;
1163 tilingLastH = tilingH+1;
1166 tilingSplit = numTiling;
1168 if(tilingW && tilingH)
1170 if(positionID >= tilingSplit)
1172 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1173 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1174 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1175 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1179 x = xOffset + pw * (positionID / tilingH) / tilingW;
1180 y = yOffset + ph * (positionID % tilingH) / tilingH;
1181 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1182 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1187 // How can this happen? From ec2 parsing test
1195 SNAPDOWN(x, textCellW);
1196 SNAPDOWN(y, textCellH);
1197 SNAPDOWN(x2, textCellW);
1198 SNAPDOWN(y2, textCellH);
1206 if(sizeAnchor.isClientW) w += ew;
1207 if(sizeAnchor.isClientH) h += eh;
1209 if(anchor.left.type == offset)
1210 x = anchor.left.distance;
1211 else if(anchor.left.type == relative)
1212 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1213 else if(anchor.right.type == relative)
1214 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1215 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1216 else if(anchor.right.type == offset)
1217 ex = vpw - anchor.right.distance;
1219 if(anchor.top.type == offset)
1220 y = anchor.top.distance;
1221 else if(anchor.top.type == relative)
1222 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1223 else if(anchor.bottom.type == relative)
1224 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1225 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1226 else if(anchor.bottom.type == offset)
1227 ey = vph - anchor.bottom.distance;
1229 if(anchor.left.type && anchor.right.type)
1231 switch(anchor.right.type)
1234 ex = pw * (1.0f-anchor.right.percent);
1235 w = Max((int)(ex + 0.5) - x, 0);
1238 ex = vpw - anchor.right.distance;
1239 w = Max((int)(ex + 0.5) - x, 0);
1243 if(anchor.top.type && anchor.bottom.type)
1245 switch(anchor.bottom.type)
1248 ey = ph * (1.0f-anchor.bottom.percent);
1249 h = Max((int)(ey + 0.5) - y, 0);
1252 ey = vph - anchor.bottom.distance;
1253 h = Max((int)(ey + 0.5) - y, 0);
1262 if(state == normal /*|| state == Hidden*/)
1264 bool addSbV = false, addSbH = false;
1266 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1267 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1269 w = Max(w, minSize.w);
1270 h = Max(h, minSize.h);
1271 w = Min(w, maxSize.w);
1272 h = Min(h, maxSize.h);
1274 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1276 if(w) w -= guiApp.currentSkin.VerticalSBW();
1279 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1281 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1285 if(!OnResizing(&w, &h))
1291 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1292 w += guiApp.currentSkin.VerticalSBW();
1293 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1294 h += guiApp.currentSkin.HorizontalSBH();
1296 w = Max(w, skinMinSize.w);
1297 h = Max(h, skinMinSize.h);
1310 SNAPDOWN(w, textCellW);
1311 SNAPDOWN(h, textCellH);
1314 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1316 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1319 (pw - w) / CASCADE_SPACE,
1320 (ph - h) / CASCADE_SPACE);
1326 cascW = (pw - w) / (numCascade-1);
1327 cascH = (ph - h) / (numCascade-1);
1328 SNAPDOWN(cascW, textCellW);
1329 SNAPDOWN(cascH, textCellH);
1330 cascadeW = (float)cascW;
1331 cascadeH = (float)cascH;
1335 numCascade = Max(numCascade, 2);
1336 cascadeW = (float)(pw - w) / (numCascade-1);
1337 cascadeH = (float)(ph - h) / (numCascade-1);
1340 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1341 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1343 else if(anchor.left.type < vTiled)
1345 if(!anchor.left.type || anchor.horz.type == middleRelative)
1347 if(!anchor.right.type)
1349 if(anchor.horz.type == middleRelative)
1350 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1352 x = vpw / 2 + anchor.horz.distance - w / 2;
1358 // case A_EDGE: x = x - w; break;
1360 if(!anchor.top.type || anchor.vert.type == middleRelative)
1362 if(!anchor.bottom.type)
1364 if(anchor.vert.type == middleRelative)
1365 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1367 y = vph / 2 + anchor.vert.distance - h / 2;
1373 // case A_EDGE: y = y - h; break;
1376 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1384 SNAPDOWN(x, textCellW);
1385 SNAPDOWN(y, textCellH);
1397 if(anchored && style.fixed && style.isActiveClient)
1402 void UpdateCaret(bool forceUpdate, bool erase)
1404 static Window lastWindow = null;
1405 static int caretX, caretY, caretSize;
1407 if(guiApp && guiApp.caretOwner == this)
1409 int x = caretPos.x - scroll.x;
1410 int y = caretPos.y - scroll.y;
1412 if((erase || this.caretSize) &&
1413 x >= clientArea.left && x <= clientArea.right &&
1414 y >= clientArea.top && y <= clientArea.bottom)
1418 guiApp.interfaceDriver.SetCaret(
1419 x + absPosition.x + clientStart.x,
1420 y + absPosition.y + clientStart.y, this.caretSize);
1421 guiApp.caretEnabled = true;
1423 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1427 if(lastWindow != this)
1429 updateBox.left = x + 1;
1431 updateBox.right = x + 2;
1432 updateBox.bottom = y + this.caretSize - 1;
1436 updateBox.left = Min(x + 1, caretX + 1);
1437 updateBox.top = Min(y, caretY);
1438 updateBox.right = Max(x + 2, caretX + 2);
1439 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1442 guiApp.caretOwner.Update(updateBox);
1449 caretSize = this.caretSize;
1455 guiApp.interfaceDriver.SetCaret(0,0,0);
1456 guiApp.caretEnabled = false;
1462 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1467 scrolledPos.x = position.x = x;
1468 scrolledPos.y = position.y = y;
1470 clientSize.w = size.w = w;
1471 clientSize.h = size.h = h;
1473 if(parent && !style.nonClient)
1475 //if(!style.fixed || style.isDocument)
1477 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1478 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1482 clientStart.x = clientStart.y = 0;
1484 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1486 //if(!activeClient || activeClient.state != maximized)
1487 if(!noAutoScrollArea)
1489 // Check if scroll area must be modified
1490 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1492 bool foundChild = false;
1494 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1495 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1496 for(child = children.first; child; child = child.next)
1498 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1499 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1501 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1502 w = Max(w, child.position.x + child.size.w);
1503 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1504 w = Max(w, Max(child.position.x, 0) + child.size.w);
1505 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1506 h = Max(h, child.position.y + child.size.h);
1507 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1508 h = Max(h, Max(child.position.y, 0) + child.size.h);
1513 if(foundChild && (w > cw || h > ch))
1515 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1517 int stepX = sbStep.x, stepY = sbStep.y;
1518 // Needed to make snapped down position match the skin's check of client area
1519 // against realvirtual
1522 SNAPDOWN(stepX, textCellW);
1523 SNAPDOWN(stepY, textCellH);
1524 stepX = Max(stepX, textCellW);
1525 stepY = Max(stepY, textCellH);
1527 if(scrollFlags.snapX)
1529 if(scrollFlags.snapY)
1532 reqScrollArea.w = w;
1533 reqScrollArea.h = h;
1536 else if(reqScrollArea.w || reqScrollArea.h)
1538 reqScrollArea.w = 0;
1539 reqScrollArea.h = 0;
1540 SetScrollPosition(0,0);
1545 // Automatic MDI Client Scrolling Area Adjustment
1546 if(parent && !parent.noAutoScrollArea)
1548 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1549 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1551 Window parent = this.parent;
1552 int w = parent.reqScrollArea.w;
1553 int h = parent.reqScrollArea.h;
1555 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1556 w = Max(w, position.x + size.w);
1557 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1558 w = Max(w, Max(position.x, 0) + size.w);
1559 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1560 h = Max(h, position.y + size.h);
1561 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1562 h = Max(h, Max(position.y, 0) + size.h);
1564 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1565 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1567 /*bool resize = false;
1568 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1569 // Needed to make snapped down position match the skin's check of client area
1570 // against realvirtual
1573 SNAPDOWN(stepX, textCellW);
1574 SNAPDOWN(stepY, textCellH);
1575 stepX = Max(stepX, textCellW);
1576 stepY = Max(stepY, textCellH);
1578 if(parent.scrollFlags.snapX)
1580 if(parent.scrollFlags.snapY)
1582 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1584 parent.reqScrollArea.w = w;
1585 parent.reqScrollArea.h = h;*/
1587 // parent.UpdateScrollBars(true, true);
1588 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1589 false, true, true, true, false, false);
1594 GetRidOfVirtualArea();
1598 UpdateScrollBars(modifyThisArea, false);
1599 else if(guiApp.currentSkin)
1602 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1604 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1605 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1606 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1607 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1610 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1611 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1613 absPosition = scrolledPos;
1614 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1615 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1617 if(this != guiApp.desktop && parent)
1619 absPosition.x += parent.absPosition.x;
1620 absPosition.y += parent.absPosition.y;
1621 if(!style.nonClient && this != guiApp.desktop)
1623 absPosition.x += parent.clientStart.x;
1624 absPosition.y += parent.clientStart.y;
1628 box = Box { 0, 0, size.w - 1, size.h - 1 };
1633 // Clip against parent's client area
1634 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1636 // Compute client area in this window coordinate system
1637 clientArea.left = 0;
1639 clientArea.right = clientSize.w - 1;
1640 clientArea.bottom = clientSize.h - 1;
1642 // Clip against parent's client area
1644 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1648 //absPosition.x -= parent.clientStart.x;
1649 //absPosition.y -= parent.clientStart.y;
1652 // Adjust all children
1653 for(child = children.first; child; child = child.next)
1654 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1656 UpdateCaret(false, false);
1659 void GetRidOfVirtualArea(void)
1661 if(parent && !parent.destroyed && style.fixed &&
1662 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1663 parent.reqScrollArea.w && parent.reqScrollArea.h)
1665 if(!parent.noAutoScrollArea)
1667 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1671 for(child = children.first; child; child = child.next)
1673 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1675 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1676 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1686 Window parent = this.parent;
1688 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1689 false, true, true, true, false, false);
1691 parent.SetScrollArea(0,0,true);
1692 parent.SetScrollPosition(0,0);
1698 public void ExternalPosition(int x, int y, int w, int h)
1700 Position(x, y, w, h, false, true, true, true, false, false);
1701 /* TO REVIEW: Redj's code trying to fix position saving
1706 normalAnchor = Anchor { left = x, top = y };
1707 normalSizeAnchor = SizeAnchor { { w, h } };
1714 // (w, h): Full window size
1715 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1717 bool result = false;
1718 int oldCW = clientSize.w, oldCH = clientSize.h;
1719 bool clientResized, windowResized, windowMoved;
1721 //bool realResized = size.w != w || size.h != h;
1723 // TOCHECK: This wasn't in ecere.dll
1724 //if(!parent) return true;
1725 if(destroyed) return false;
1727 windowMoved = position.x != x || position.y != y || force;
1729 // windowResized = realResized || force;
1730 windowResized = size.w != w || size.h != h || force;
1732 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1738 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1739 scrolledPos.x - parent.clientStart.x + this.box.right,
1740 scrolledPos.y - parent.clientStart.y + this.box.bottom
1746 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1751 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1753 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1754 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1755 windowResized = true;
1757 if(display && rootWindow != this)
1760 if(guiApp && guiApp.windowMoving)
1762 if(guiApp.windowMoving.style.nonClient)
1763 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1765 guiApp.windowMoving.parent.SetMouseRangeToClient();
1775 // Buttons bitmap resources crash if we do this while switching mode
1776 if(!guiApp || !guiApp.modeSwitching)
1779 // Process Anchored Children
1783 for(child = children.first; child; child = child.next)
1786 ((child.stateAnchor.left.type != offset ||
1787 child.stateAnchor.top.type != offset ||
1788 child.stateAnchor.right.type != none ||
1789 child.stateAnchor.bottom.type != none) ||
1790 child.state == maximized || child.state == minimized))
1792 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1794 // child.Position(x, y, w, h, false, true, true, true, false);
1795 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1796 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1802 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1803 //if(updateScrollBars)
1805 OnResize(clientSize.w, clientSize.h);
1807 if((clientResized || windowMoved) && created)
1808 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1810 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1812 Window master = guiApp.interimWindow.master;
1813 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1816 if(rootWindow == this && !is3D)
1820 x -= guiApp.desktop.absPosition.x;
1821 y -= guiApp.desktop.absPosition.y;
1823 //guiApp.Log("Position %s\n", caption);
1826 if(windowResized || windowMoved)
1827 if(display && !display.flags.memBackBuffer && changeRootWindow)
1828 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1830 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1831 for(child = parent.children.first; child && child != this; child = child.next)
1832 if(child.rootWindow)
1833 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1838 if(windowMoved || windowResized)
1840 display.Lock(true /*false*/);
1843 display.Position(absPosition.x, absPosition.y);
1844 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1847 // result = realResized ? display.Resize(size.w, size.h) : true;
1848 if(nativeDecorations && rootWindow.windowHandle)
1850 int w = clientSize.w, h = clientSize.h;
1851 if(hasMenuBar) h += skinMenuHeight;
1852 if(hasStatusBar) h += statusBarHeight;
1853 if(sbv && sbv.visible) w += sbv.size.w;
1854 if(sbh && sbh.visible) h += sbh.size.h;
1855 result = manageDisplay ? display.Resize(w, h) : true;
1858 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1862 else if(clientResized)
1864 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1867 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1871 if(windowMoved || windowResized)
1876 if(guiApp.driver && changeRootWindow && windowHandle)
1878 if(windowResized || windowMoved)
1879 if(!display || display.flags.memBackBuffer)
1880 guiApp.interfaceDriver.PositionRootWindow(this,
1881 x, y, w, h, windowMoved, windowResized);
1882 guiApp.interfaceDriver.UpdateRootWindow(this);
1884 for(child = children.first; child; child = child.next)
1886 if(child.is3D && child.created)
1888 // Copy Display Content
1889 child.display.displaySystem = display.displaySystem;
1890 child.display.window = display.window;
1891 child.display.current = display.current;
1892 child.display.width = display.width;
1893 child.display.height = display.height;
1894 child.display.driverData = display.driverData;
1895 child.display.mutex = null;
1906 void UpdateScrollBars(bool flag, bool fullThing)
1909 bool resizeH = false, resizeV = false;
1910 bool scrolled = false;
1911 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1912 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1914 if(destroyed) return;
1915 if(guiApp.currentSkin)
1917 MinMaxValue cw = 0, ch = 0;
1918 bool sbvVisible, sbhVisible;
1919 int rangeH = 0, rangeV = 0;
1920 int positionH = 0, positionV;
1922 // First get client area with no respect to scroll bars
1927 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1929 if(scrollFlags.dontHide)
1932 cw -= guiApp.currentSkin.VerticalSBW();
1934 ch -= guiApp.currentSkin.HorizontalSBH();
1936 // Update the scrollbar visibility
1942 sbh.disabled = rangeH <= 1;
1943 if(sbh.style.hidden)
1953 sbv.disabled = rangeV <= 1;
1954 if(sbv.style.hidden)
1962 int oldHRange = sbh ? sbh.range : 0;
1963 int oldVRange = sbv ? sbv.range : 0;
1964 // Then start off with horizontal scrollbar range
1967 positionH = sbh.thumbPosition;
1974 SBSetTotal(sbh, rvw);
1977 ch -= guiApp.currentSkin.HorizontalSBH();
1980 // Do the same for vertical scrollbar
1983 positionV = sbv.thumbPosition;
1989 SBSetTotal(sbv, rvh);
1993 cw -= guiApp.currentSkin.VerticalSBW();
1994 // Maybe we need to set the range on the horizontal scrollbar again
2002 SBSetTotal(sbh, rvw);
2003 //sbh.Action(setRange, positionH, 0);
2004 if(rangeH <= 1 && sbh.range > 1)
2006 ch -= guiApp.currentSkin.HorizontalSBH();
2012 SBSetTotal(sbv, rvh);
2014 //sbv.Action(setRange, positionV, 0);
2019 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
2020 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
2023 // Update the scrollbar visibility
2024 if(!scrollFlags.dontHide)
2026 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
2030 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2037 if(guiApp.currentSkin)
2044 sbhVisible = sbh.style.hidden ? true : false;
2046 sbvVisible = sbv.style.hidden ? true : false;
2048 // Do our resize here
2049 if(flag && (resizeH || resizeV) && fullThing)
2051 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2056 OnResize(clientSize.w, clientSize.h);
2062 sbh.visible = sbhVisible;
2064 sbv.visible = sbvVisible;
2066 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2067 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2070 sbh.pageStep = clientSize.w;
2072 sbv.pageStep = clientSize.h;
2074 // Notify doesn't handle setRange anymore... process it here
2077 int positionH = sbh.thumbPosition;
2078 if(scroll.x != positionH)
2080 OnHScroll(setRange, positionH, 0);
2084 SNAPDOWN(positionH, textCellW);
2085 scroll.x = positionH;
2091 int seen = clientSize.w, total = reqScrollArea.w;
2094 if(scrollFlags.snapX)
2095 SNAPDOWN(seen, sbStep.x);
2097 if(!total) total = seen;
2098 range = total - seen + 1;
2100 range = Max(range, 1);
2102 if(x >= range) x = range - 1;
2104 if(scrollFlags.snapX)
2105 SNAPUP(x, sbStep.x);
2109 OnHScroll(setRange, x, 0);
2114 SNAPDOWN(x, textCellW);
2120 int positionV = sbv.thumbPosition;
2121 if(scroll.y != positionV)
2123 OnVScroll(setRange, positionV, 0);
2127 SNAPDOWN(positionV, textCellH);
2128 scroll.y = positionV;
2134 int seen = clientSize.h, total = reqScrollArea.h;
2137 if(scrollFlags.snapY)
2138 SNAPDOWN(seen, sbStep.y);
2140 if(!total) total = seen;
2141 range = total - seen + 1;
2142 range = Max(range, 1);
2144 if(y >= range) y = range - 1;
2146 if(scrollFlags.snapY)
2147 SNAPUP(y, sbStep.y);
2151 OnVScroll(setRange, y, 0);
2156 SNAPDOWN(y, textCellH);
2162 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2165 for(child = children.first; child; child = child.next)
2167 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2170 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2171 child.Position(x, y, w, h, false, true, false, true, false, false);
2178 // Process Scrollbars
2180 if(sbh) // && !sbh.style.hidden
2183 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2184 // Need to set the range again (should improve...) since the scrollbars didn't have
2185 // the right size when UpdateScrollArea set the range on it
2188 sbh.seen = clientSize.w;
2192 if(sbv) // && !sbv.state.hidden
2195 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2196 // Need to set the range again (should improve...) since the scrollbars didn't have
2197 // the right size when UpdateScrollArea set the range on it
2200 sbv.seen = clientSize.h;
2205 // TESTING THIS LOWER
2206 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2209 for(child = children.first; child; child = child.next)
2211 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2214 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2215 child.Position(x, y, w, h, false, true, false, true, false, false);
2221 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2223 SetState(maximized, false, mods);
2227 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2229 SetState(normal, false, mods);
2233 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2235 SetState(minimized, false, mods);
2236 parent.CycleChildren(false, true, false, true);
2240 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2243 // Scroll bar notifications
2244 if(action != setRange)
2246 bool changed = false;
2250 if(scroll.x != position)
2252 OnHScroll(action, position, keyFlags);
2257 SNAPDOWN(position, textCellW);
2259 scroll.x = position;
2263 if(scroll.y != position)
2265 OnVScroll(action, position, keyFlags);
2270 SNAPDOWN(position, textCellH);
2272 scroll.y = position;
2276 bool childMove = false;
2277 for(child = children.first; child; child = child.next)
2279 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2282 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2283 child.Position(x, y, w, h, false, true, false, true, false, false);
2287 // Testing this patch out to solve MDI workspace redraw bugs
2288 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2289 // Scroll offsets to blame?
2293 UpdateCaret(false, false);
2297 // Testing this patch out to solve MDI workspace redraw bugs
2298 for(child = children.first; child; child = child.next)
2300 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2309 Window GetParentMenuBar()
2311 Window menuBarParent;
2312 if(formDesigner) return null;
2313 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2315 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2316 if(menuBarParent && !menuBarParent.isActiveClient)
2322 void CreateSystemChildren(void)
2324 Window parent = this;
2325 bool scrollBarChanged = false;
2326 bool hasClose = false, hasMaxMin = false;
2327 Point scroll = this.scroll;
2329 if(state == maximized)
2331 parent = GetParentMenuBar();
2338 if(style.hasClose) hasClose = true;
2339 if(style.hasMaximize || style.hasMinimize)
2346 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2348 sysButtons[2].Destroy(0);
2349 sysButtons[2] = null;
2351 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2353 sysButtons[1].Destroy(0);
2354 sysButtons[1] = null;
2356 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2358 sysButtons[0].Destroy(0);
2359 sysButtons[0] = null;
2362 if(hasClose && parent)
2369 parent, master = this,
2370 inactive = true, nonClient = true, visible = false;
2372 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2378 if(this.parent == guiApp.desktop)
2379 sysButtons[2].hotKey = altF4;
2380 else if(style.isActiveClient)
2381 sysButtons[2].hotKey = ctrlF4;
2382 sysButtons[2].Create();
2385 sysButtons[2].symbol = 'X';
2386 sysButtons[2].disabled = !style.hasClose;
2389 if(hasMaxMin && parent)
2393 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2394 if(state == maximized)
2397 method = RestoreButtonClicked;
2403 method = MaximizeButtonClicked;
2411 parent, master = this,
2412 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2414 sysButtons[1].Create();
2416 sysButtons[1].NotifyClicked = method;
2418 sysButtons[1].symbol = symbol;
2419 sysButtons[1].disabled = !style.hasMaximize;
2422 if(hasMaxMin && parent)
2426 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2427 if (state == minimized)
2430 method = RestoreButtonClicked;
2436 method = MinimizeButtonClicked;
2444 parent, master = this,
2445 hotKey = altM, inactive = true, nonClient = true, visible = false
2447 sysButtons[0].Create();
2449 sysButtons[0].NotifyClicked = method;
2451 sysButtons[0].symbol = symbol;
2452 sysButtons[0].disabled = !style.hasMinimize;
2455 // Create the scrollbars
2456 if(style.hasHorzScroll && !sbh)
2462 direction = horizontal,
2466 snap = scrollFlags.snapX,
2467 NotifyScrolling = ScrollBarNotification
2470 scrollBarChanged = true;
2472 else if(sbh && !style.hasHorzScroll)
2478 if(style.hasVertScroll && !sbv)
2484 direction = vertical,
2488 snap = scrollFlags.snapY,
2489 NotifyScrolling = ScrollBarNotification
2492 scrollBarChanged = true;
2494 else if(sbv && !style.hasVertScroll)
2499 if(scrollBarChanged)
2501 SetScrollLineStep(sbStep.x, sbStep.y);
2502 UpdateScrollBars(true, true);
2506 if(scrollBarChanged)
2508 if(sbh) sbh.thumbPosition = scroll.x;
2509 if(sbv) sbv.thumbPosition = scroll.y;
2513 void UpdateCaption(void)
2515 if(rootWindow == this)
2518 FigureCaption(caption);
2519 if(guiApp.interfaceDriver)
2520 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2522 UpdateDecorations();
2525 if(parent.activeClient == this) // Added this last check
2527 if(parent.rootWindow == parent)
2530 parent.FigureCaption(caption);
2531 if(guiApp.interfaceDriver)
2532 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2535 parent.UpdateCaption();
2537 parent.UpdateDecorations();
2541 void UpdateActiveDocument(Window previous)
2543 Window activeClient = this.activeClient;
2544 Window activeChild = this.activeChild;
2551 activeClient.CreateSystemChildren();
2553 previous.CreateSystemChildren();
2565 // Build window list
2568 Menu windowMenu = menu.FindMenu("Window");
2573 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2575 Window document = cycle.data;
2576 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2578 char name[2048], caption[2048];
2579 document.FigureCaption(caption);
2580 sprintf(name, "%d %s", id+1, caption);
2581 windowMenu.AddDynamic(MenuItem
2583 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2584 NotifySelect = MenuWindowSelectWindow
2588 if(activeClient.cycle == cycle) break;
2593 if((!previous && activeClient) || !activeClient)
2599 item = menu.FindItem(MenuWindowCloseAll, 0);
2600 if(item) item.disabled = false;
2601 item = menu.FindItem(MenuWindowNext, 0);
2602 if(item) item.disabled = false;
2603 item = menu.FindItem(MenuWindowPrevious, 0);
2604 if(item) item.disabled = false;
2605 item = menu.FindItem(MenuWindowCascade, 0);
2606 if(item) item.disabled = false;
2607 item = menu.FindItem(MenuWindowTileHorz, 0);
2608 if(item) item.disabled = false;
2609 item = menu.FindItem(MenuWindowTileVert, 0);
2610 if(item) item.disabled = false;
2611 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2612 if(item) item.disabled = false;
2613 item = menu.FindItem(MenuWindowWindows, 0);
2614 if(item) item.disabled = false;
2617 item = menu.FindItem(MenuFileClose, 0);
2618 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2619 item = menu.FindItem(MenuFileSaveAll, 0);
2620 if(item) item.disabled = numDocuments < 1;
2622 if(activeClient && activeClient.menu && activeClient.state != minimized)
2626 //activeClient.menu.Clean(activeClient);
2627 menu.Merge(activeClient.menu, true, activeClient);
2631 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2634 menu.Merge(activeChild.menu, true, activeChild);
2637 // This is called again for a child window change, with same active client
2638 OnActivateClient(activeClient, previous);
2639 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2640 parent.UpdateActiveDocument(null);
2643 void _ShowDecorations(Box box, bool post)
2645 if(rootWindow == this && nativeDecorations && !is3D) return;
2646 if(visible && this != guiApp.desktop)
2648 Surface surface = RedrawFull(box);
2652 FigureCaption(caption);
2655 ShowDecorations(captionFont.font,
2658 active, //parent.activeClient == this
2659 guiApp.windowMoving == this);
2661 PreShowDecorations(captionFont.font,
2664 active, //parent.activeClient == this
2665 guiApp.windowMoving == this);
2672 void UpdateExtent(Box refresh)
2674 Surface surface = null;
2676 if(!manageDisplay) { OnRedraw(null);return; }
2677 _ShowDecorations(refresh, false);
2679 surface = Redraw(refresh);
2680 // Opaque background: just fill before EW_REDRAW (clear?)
2683 surface.SetBackground(background);
2684 surface.SetForeground(foreground);
2685 surface.DrawingChar(' ');
2686 if(this == rootWindow)
2688 if(style.drawBehind || background.a)
2690 int a = background.a;
2691 // Premultiply alpha for clear color
2692 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2693 surface.Clear(colorBuffer);
2694 surface.SetBackground(background);
2697 else if(background.a)
2701 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2702 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2705 if(display.flags.alpha && background.a < 255 && background)
2707 surface.Area(0,0,clientSize.w, clientSize.h);
2708 /*if(style.clearDepthBuffer)
2709 surface.Clear(depthBuffer);*/
2711 else if(/*style.clearDepthBuffer || */background.a)
2713 int a = background.a;
2714 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2715 // Premultiply alpha for clear color
2716 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2717 surface.Clear(colorBuffer);
2718 surface.SetBackground(background);
2723 surface.TextFont(usedFont.font);
2724 surface.TextOpacity(false);
2728 // Draw the caret ...
2729 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2731 // surface.SetBackground(0xFFFFFF - background.color);
2732 surface.SetBackground(~background.color);
2734 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2735 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2741 void DrawOverChildren(Box refresh)
2743 Surface surface = Redraw(refresh);
2747 surface.DrawingChar(' ');
2748 surface.SetBackground(background);
2749 surface.SetForeground(foreground);
2751 surface.TextFont(usedFont.font);
2752 surface.TextOpacity(false);
2754 OnDrawOverChildren(surface);
2759 _ShowDecorations(refresh, true);
2762 void ComputeClipExtents(void)
2765 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2767 clipExtent.Copy(this.clipExtent);
2769 for(child = children.last; child; child = child.prev)
2771 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2773 bool opaque = child.IsOpaque(); // TODO: acess background directly
2774 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2776 child.clipExtent.Copy(clipExtent);
2777 child.clipExtent.Offset(-dx, -dy);
2778 child.clipExtent.IntersectBox(child.box);
2780 child.ComputeClipExtents();
2782 if(opaque && !child.style.nonClient)
2784 // Adjust the box for the parent:
2785 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2786 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2791 // ??? Only do this for overlapped window or if parent has with clip children flag
2793 // Do this if window has clip children flag on (default false?)
2794 // this.clipExtent = clipExtent;
2796 clipExtent.Free(null);
2799 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2802 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2803 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2805 offsetX -= rootWindow.clientStart.x;
2806 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2810 for(child = children.last; child; child = child.prev)
2812 bool opaque = child.IsOpaque();
2813 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2817 // Adjust renderArea to the root window level
2818 Extent * renderArea = &rootWindow.tempExtents[3];
2820 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2821 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2822 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2824 offsetX -= child.rootWindow.clientStart.x;
2825 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2829 Extent childRenderArea;
2831 if(backBufferUpdate != null)
2833 childRenderArea.Copy(backBufferUpdate);
2834 childRenderArea.Offset(-offsetX, -offsetY);
2837 childRenderArea.Copy(child.dirtyArea);
2839 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2840 renderArea.Copy(dirtyExtent);
2841 renderArea.Offset(-offsetX, -offsetY);
2842 childRenderArea.Union(renderArea);
2845 // Intersect with the clip extent
2846 childRenderArea.Intersection(child.clipExtent);
2849 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2851 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2852 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2854 renderArea->Offset(offsetX, offsetY);
2856 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2857 // overDirtyExtent.Union(renderArea);
2858 renderArea->Empty();
2859 // childRenderArea.Free();
2861 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2866 for(child = children.last; child; child = child.prev)
2868 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2870 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2875 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2877 bool opaque = IsOpaque();
2878 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2880 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2881 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2883 offsetX -= rootWindow.clientStart.x;
2884 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2888 for(child = children.last; child; child = child.prev)
2890 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2892 ColorAlpha background = *(ColorAlpha *)&child.background;
2893 bool opaque = child.IsOpaque();
2894 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2898 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2899 // Adjust renderArea to the root window level
2901 renderArea.Copy(child.dirtyArea);
2902 renderArea.Offset(offsetX, offsetY);
2903 dirtyExtent.Union(renderArea);
2904 overDirtyExtent.Union(renderArea);
2910 for(child = children.last; child; child = child.prev)
2912 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2914 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2918 if(backBufferUpdate != null)
2920 renderArea.Copy(backBufferUpdate);
2921 renderArea.Offset(-offsetX, -offsetY);
2923 overRenderArea.Copy(backBufferUpdate);
2924 overRenderArea.Offset(-offsetX, -offsetY);
2930 renderArea.Copy(dirtyArea);
2932 overRenderArea.Copy(dirtyArea);
2935 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2936 dirtyExtentWindow->Copy(dirtyExtent);
2937 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2938 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2939 dirtyExtentWindow->Empty();
2941 // Intersect with the clip extent
2942 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2945 if(renderArea.count > 10)
2948 printf("\nToo many extents (%d):\n", renderArea.count);
2950 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2951 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2956 for(c = 0; c<10; c++)
2959 FASTLIST_LOOP(renderArea, extentBox)
2961 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2963 renderArea.Copy(extent);
2965 FASTLIST_LOOP(renderArea, extentBox)
2968 printf("(%d, %d) - (%d, %d)\n",
2969 extentBox.box.left, extentBox.box.top,
2970 extentBox.box.right, extentBox.box.bottom);
2974 printf("\nNow %d\n", renderArea.count);
2980 // WHY WAS THIS COMMENTED ??
2982 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2983 dirtyExtentWindow->Copy(overDirtyExtent);
2984 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2985 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2986 dirtyExtentWindow->Empty();
2988 // Intersect with the clip extent
2989 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2995 if(scrollExtent.count)
2997 // Subtract render extent from scrolling extent
2998 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
3000 if(backBufferUpdate == null)
3002 Extent * dirty = &rootWindow.tempExtents[3];
3005 // Intersect scrolling extent with clip extent
3006 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
3008 // offset this scroll to be at the root window level
3009 scrollExtent.Offset(offsetX, offsetY);
3010 // Add area that was scrolled to the dirty extents of the back buffer
3011 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
3015 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
3016 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
3017 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
3022 scrollExtent.Empty();
3024 // Add the exposed extent to the window render area
3025 dirty->Offset(-offsetX, -offsetY);
3026 renderArea.Union(dirty, rootWindow.tempExtents[0]);
3031 // Subtract the window's box from the transparency forced extent
3032 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3038 renderArea.Copy(this.renderArea);
3039 renderArea.Offset(offsetX, offsetY);
3040 dirtyExtent.Union(renderArea);
3046 Extent renderArea { };
3048 renderArea.Copy(overRenderArea);
3049 renderArea.Offset(offsetX, offsetY);
3050 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3055 if(backBufferUpdate != null)
3057 // Remove render area from dirty area
3058 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3060 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3067 // Remove the window render area from the dirty extents of the back buffer
3068 rootWindow.dirtyBack.Exclusion(renderArea);
3072 void Render(Extent updateExtent)
3076 Window rootWindow = this.rootWindow;
3077 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3078 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3080 offsetX -= rootWindow.clientStart.x;
3081 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3084 if(rootWindow.fullRender)
3093 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3094 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3099 /*if(renderArea.count)
3100 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3103 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3105 Box box = extentBox.box;
3108 /*printf("(%d, %d) - (%d, %d)\n",
3109 extentBox.box.left, extentBox.box.top,
3110 extentBox.box.right, extentBox.box.bottom);*/
3115 box.left += offsetX;
3117 box.right += offsetX;
3118 box.bottom += offsetY;
3120 if(updateExtent != null)
3121 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3125 for(child = children.first; child; child = child.next)
3126 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3127 child.Render(updateExtent);
3129 if(rootWindow.fullRender)
3130 DrawOverChildren(box);
3133 // TO DO: There's an issue about draw over children...
3134 // TO DO: Don't wanna go through this if method isn't used
3135 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3136 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3138 Box box = extentBox.box;
3140 DrawOverChildren(box);
3142 box.left += offsetX;
3144 box.right += offsetX;
3145 box.bottom += offsetY;
3147 if(updateExtent != null)
3148 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3151 for(child = children.first; child; child = child.next)
3152 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3153 child.Render(updateExtent);
3156 overRenderArea.Empty();
3159 public void UpdateDisplay(void)
3161 if(!manageDisplay) { OnRedraw(null);return; }
3162 if(rootWindow && this != rootWindow)
3163 rootWindow.UpdateDisplay();
3166 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3167 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3170 dirtyExtent.Clear();
3173 clipExtent.AddBox(box);
3175 display.StartUpdate();
3177 if(!rootWindow.fullRender)
3179 ComputeClipExtents();
3180 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3181 ComputeRenderArea(dirtyExtent, overExtent, null);
3184 clipExtent.Free(null);
3186 dirtyExtent.Free(null);
3187 overExtent.Free(null);
3189 if(display.flags.flipping)
3192 display.Update(null);
3196 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3197 updateExtent.Clear();
3199 Render(updateExtent);
3201 updateExtent.UnionBox(this.box, tempExtents[0]);
3204 //printf("\n\nUpdate:\n------------------------------------------\n");
3207 //FASTLIST_LOOP(updateExtent, extentBox)
3208 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3211 /*printf("Updating (%d, %d) - (%d, %d)\n",
3212 extentBox.box.left, extentBox.box.top,
3213 extentBox.box.right, extentBox.box.bottom);*/
3216 display.Update(extentBox.box);
3219 updateExtent.Free(null);
3222 display.EndUpdate();
3230 void UpdateBackDisplay(Box box)
3236 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3238 //printf("UpdateBackDisplay going through!\n");
3239 display.StartUpdate();
3243 intersection.Copy(dirtyBack);
3244 intersection.IntersectBox(box);
3246 dirtyExtent.Clear();
3249 clipExtent.AddBox(box);
3251 if(!rootWindow.fullRender)
3253 ComputeClipExtents();
3254 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3257 clipExtent.Free(null);
3259 intersection.Free(null);
3260 dirtyExtent.Free(null);
3261 overExtent.Free(null);
3266 if(display.flags.flipping)
3267 display.Update(null);
3270 rootWindow.display.Update(box);
3273 display.EndUpdate();
3277 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3278 if(dirtyBack.count > MAX_DIRTY_BACK)
3280 BoxItem extentBox, next;
3281 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3282 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3284 next = (BoxItem)extentBox.next;
3285 if(extentBox != first)
3287 if(extentBox.box.left < first.box.left)
3288 first.box.left = extentBox.box.left;
3289 if(extentBox.box.top < first.box.top)
3290 first.box.top = extentBox.box.top;
3291 if(extentBox.box.right > first.box.right)
3292 first.box.right = extentBox.box.right;
3293 if(extentBox.box.bottom > first.box.bottom)
3294 first.box.bottom = extentBox.box.bottom;
3295 dirtyBack.Delete(extentBox);
3304 // --- Window positioning ---
3305 // --- Window identification ---
3307 // Returns window at position "Position"
3308 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3310 Window child, result = null;
3312 box.left += absPosition.x;
3313 box.right += absPosition.x;
3314 box.top += absPosition.y;
3315 box.bottom += absPosition.y;
3317 if(!destroyed && visible && (acceptDisabled || !disabled))
3319 int lx = x - absPosition.x;
3320 int ly = y - absPosition.y;
3321 if(IsInside(lx, ly))
3322 // if(box.IsPointInside(Point{x, y}))
3324 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3325 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3328 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3329 Window ancestor = null;
3331 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3332 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3334 if(child != statusBar && child.rootWindow == rootWindow)
3336 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3343 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3345 if(child != statusBar && child.rootWindow == rootWindow)
3347 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3354 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3362 Window FindModal(void)
3364 Window modalWindow = this, check;
3365 Window check2 = null;
3366 for(check = this; check.master; check = check.master)
3368 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3370 modalWindow = check.master.modalSlave;
3371 check = modalWindow;
3373 // TESTING THIS FOR DROPBOX...
3374 if(!rootWindow || !rootWindow.style.interim)
3376 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3378 if(check2.modalSlave && check2.modalSlave.created)
3380 modalWindow = check2.modalSlave;
3388 if(modalWindow == this)
3390 for(check = this; check.activeChild; check = check.activeChild)
3392 if(check.modalSlave)
3394 modalWindow = check.modalSlave;
3400 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3401 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3404 void StopMoving(void)
3406 if(this == guiApp.windowMoving)
3408 guiApp.windowMoving = null;
3409 UpdateDecorations();
3410 SetMouseRange(null);
3413 if(rootWindow.active)
3414 guiApp.interfaceDriver.StopMoving(rootWindow);
3416 guiApp.windowCaptured.ReleaseCapture();
3417 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3418 guiApp.windowIsResizing = false;
3422 void SelectMouseCursor(void)
3427 Window cursorWindow = null;
3428 bool rx, ry, rex, rey;
3430 guiApp.desktop.GetMousePosition(&x, &y);
3431 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3433 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3434 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3435 else if(mouseWindow)
3437 modalWindow = mouseWindow.FindModal();
3438 x -= mouseWindow.absPosition.x;
3439 y -= mouseWindow.absPosition.y;
3440 if(guiApp.windowIsResizing)
3442 rex = guiApp.resizeEndX;
3443 rey = guiApp.resizeEndY;
3444 rx = guiApp.resizeX;
3445 ry = guiApp.resizeY;
3446 if((rex && rey) || (rx && ry))
3447 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3448 else if((rex && ry) || (rx && rey))
3449 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3450 else if((ry || rey) && (!rx && !rex))
3451 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3452 else if((rx || rex) && (!ry && !rey))
3453 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3455 else if(!modalWindow && !guiApp.windowCaptured &&
3456 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3457 &rx, &ry, &rex, &rey))
3459 if((rex && rey) || (rx && ry))
3460 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3461 else if((rex && ry) || (rx && rey))
3462 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3463 else if((ry || rey) && (!rx && !rex))
3464 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3465 else if((rx || rex) && (!ry && !rey))
3466 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3468 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3470 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3471 mouseWindow.rootWindow != mouseWindow)
3472 cursorWindow = mouseWindow.parent;
3474 cursorWindow = mouseWindow;
3476 else if(!guiApp.interimWindow)
3477 cursorWindow = guiApp.windowCaptured;
3480 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3481 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3483 else if(modalWindow)
3485 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3487 else if(guiApp.interimWindow)
3489 if(guiApp.interimWindow.cursor)
3490 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3492 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3497 // --- State based input ---
3498 bool AcquireInputEx(bool state)
3503 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3504 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3506 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3508 guiApp.acquiredWindow = state ? this : null;
3511 SetMouseRangeToClient();
3512 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3517 SelectMouseCursor();
3519 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3523 // --- Window activation ---
3524 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3527 if(!parent || !parent.style.inactive)
3529 Window parent = this.parent;
3532 if(rootWindow == this)
3533 Log(active ? "active\n" : "inactive\n");
3535 if(active && requireRemaximize)
3537 if(state == maximized)
3539 property::state = normal;
3540 property::state = maximized;
3542 requireRemaximize = false;
3545 // Testing this here...
3546 if(!parent || parent == guiApp.desktop || parent.active)
3548 this.active = active;
3551 // TESTING THIS HERE
3552 UpdateDecorations();
3553 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3554 result = NotifyActivate(master, this, active, previous);
3557 this.active = !active;
3562 if(!parent || parent == guiApp.desktop || parent.active)
3564 this.active = active;
3566 AcquireInputEx(active);
3567 if(active && isEnabled)
3571 if(guiApp.caretOwner)
3575 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3576 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3577 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3578 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3580 guiApp.caretOwner.Update(extent);
3583 if(visible || !guiApp.caretOwner)
3584 guiApp.caretOwner = this;
3585 UpdateCaret(false, false);
3591 this.active = false;
3593 AcquireInputEx(active);
3595 if(!active && guiApp.caretOwner == this)
3597 UpdateCaret(false, true);
3598 guiApp.caretOwner = null;
3599 guiApp.interfaceDriver.SetCaret(0,0,0);
3600 guiApp.caretEnabled = false;
3605 if(!active && parent && parent.activeChild && parent.activeChild != this)
3606 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3612 if(!active && menuBar)
3615 menuBar.OnActivate(false, null, &goOn, true);
3616 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3621 Window aChild = activeChild;
3623 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3635 void ConsequentialMouseMove(bool kbMoving)
3637 if(rootWindow && !noConsequential)
3639 if(kbMoving || !guiApp.windowMoving)
3643 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3645 if(guiApp.interfaceDriver)
3646 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3648 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3649 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3655 bool IsDescendantOf(Window ancestor)
3658 for(window = this; window && window != ancestor; window = window.parent);
3659 return window == ancestor;
3662 bool IsSlaveOf(Window master)
3665 for(window = this; window && window != master; window = window.master);
3666 return window == master;
3669 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3673 if(this && !destroyed /*&& state != Hidden*/)
3675 Window swap = externalSwap;
3683 if(activateParent &&
3684 (parent.activeChild != this ||
3685 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3686 active && _isModal &&
3687 parent != master && master)
3688 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3694 bool real = parent.activeChild != this;
3696 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3697 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3698 !IsDescendantOf(guiApp.interimWindow) &&
3699 !IsSlaveOf(guiApp.interimWindow))
3701 Window interimWindow = guiApp.interimWindow;
3702 while(interimWindow && interimWindow != this)
3704 Window master = interimWindow.master;
3706 guiApp.interimWindow = null;
3707 if(guiApp.caretOwner)
3708 guiApp.caretOwner.UpdateCaret(false, false);
3710 incref interimWindow;
3711 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3716 delete interimWindow;
3717 interimWindow = (master && master.style.interim) ? master : null;
3722 guiApp.interimWindow = this;
3723 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3724 guiApp.caretEnabled = false;*/
3725 UpdateCaret(false, true);
3730 //bool acquireInput = false;
3732 parent.activeChild &&
3733 parent.activeChild.state == maximized &&
3734 parent != guiApp.desktop;
3736 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3741 swap = parent.activeChild;
3742 if(swap && swap.destroyed) swap = null;
3743 if(swap && swap != this)
3746 if(!swap.PropagateActive(false, this, &goOn, true))
3747 swap = parent.activeChild;
3758 if(!parent || parent.activeChild != this || style.interim)
3761 result = PropagateActive(true, swap, &goOn, true);
3762 if(!result && !goOn)
3767 //acquireInput = true;
3771 if(style.hasMaximize && parent != guiApp.desktop)
3774 SetState(maximized, false, 0);
3775 else if(state != maximized)
3778 for(child = parent.children.first; child; child = child.next)
3780 if(this != child && child.state == maximized)
3781 child.SetState(normal, false, 0);
3788 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3790 Window previous = parent.activeClient;
3791 parent.activeChild = this;
3792 if(!style.nonClient /*&& style.isActiveClient*/)
3796 if(style.isActiveClient)
3797 parent.activeClient = this;
3798 // Moved UpdateActiveDocument inside hidden check
3799 // To prevent activating previous window while creating a new one
3800 // (It was messing up the privateModule in the CodeEditor)
3801 parent.UpdateActiveDocument(previous);
3807 //if(!style.isRemote)
3809 if(rootWindow != this)
3811 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3812 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3814 else if(!guiApp.fullScreenMode)
3816 Window modalRoot = FindModal();
3817 if(!modalRoot) modalRoot = this;
3818 if(!modalRoot.isForegroundWindow)
3820 modalRoot.isForegroundWindow = true;
3821 // To check : Why is parent null?
3822 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3824 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3826 modalRoot.isForegroundWindow = false;
3831 if(result && real && (!style.inactive || moveInactive) && parent)
3833 Window last = parent.children.last;
3835 if(!style.stayOnTop)
3836 for(; last && last.style.stayOnTop; last = last.prev);
3838 parent.children.Move(this, last);
3840 // Definitely don't want that: why not?
3844 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3850 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3857 parent.activeChild = null;
3858 if(!style.nonClient /*&& style.isActiveClient*/)
3860 Window previous = parent.activeClient;
3861 if(style.isActiveClient)
3862 parent.activeClient = null;
3863 parent.UpdateActiveDocument(previous);
3867 if(this == guiApp.interimWindow)
3869 guiApp.interimWindow = null;
3870 if(guiApp.caretOwner)
3871 guiApp.caretOwner.UpdateCaret(false, false);
3873 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3880 if(!active || !swap)
3881 UpdateDecorations();
3883 swap.UpdateDecorations();
3885 if(active && rootWindow != this)
3886 ConsequentialMouseMove(false);
3893 // --- Input Messages ---
3894 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3896 static bool reEntrancy = false;
3897 if(reEntrancy) return;
3901 guiApp.cursorUpdate = true;
3902 if(guiApp.windowScrolling && !consequential)
3904 guiApp.windowScrolling.SetScrollPosition(
3905 (guiApp.windowScrolling.sbh) ?
3906 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3907 (guiApp.windowScrolling.sbv) ?
3908 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3910 if(guiApp.windowMoving)
3912 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3914 Window window = guiApp.windowMoving;
3916 int w = window.size.w;
3917 int h = window.size.h;
3922 rx = mouseX - guiApp.windowMovingStart.x;
3923 ry = mouseY - guiApp.windowMovingStart.y;
3926 window.GetDecorationsSize(&ew, &eh);
3928 if(guiApp.windowIsResizing)
3930 x = window.scrolledPos.x;
3931 y = window.scrolledPos.y;
3935 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3936 rx = guiApp.windowResizingBefore.w - aw;
3937 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3938 w = guiApp.windowResizingBefore.w - rx;
3942 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3943 ry = guiApp.windowResizingBefore.h - ah;
3944 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3945 ry = Max(ry, -guiApp.windowMovingBefore.y);
3946 h = guiApp.windowResizingBefore.h - ry;
3948 if(guiApp.resizeEndX)
3950 w = guiApp.windowResizingBefore.w + rx;
3953 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3961 w = Max(w, window.minSize.w);
3962 h = Max(h, window.minSize.h);
3963 w = Min(w, window.maxSize.w);
3964 h = Min(h, window.maxSize.h);
3966 if(!window.OnResizing(&w, &h))
3968 w = window.clientSize.w;
3969 h = window.clientSize.h;
3972 w = Max(w, window.skinMinSize.w);
3973 h = Max(h, window.skinMinSize.h);
3980 SNAPDOWN(w, textCellW);
3981 SNAPDOWN(h, textCellH);
3986 aw = Max(w,window.skinMinSize.w);
3987 rx = guiApp.windowResizingBefore.w - aw;
3988 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3989 w = guiApp.windowResizingBefore.w - rx;
3993 ah = Max(h,window.skinMinSize.h);
3994 ry = guiApp.windowResizingBefore.h - ah;
3995 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3996 ry = Max(ry, -guiApp.windowMovingBefore.y);
3997 h = guiApp.windowResizingBefore.h - ry;
4002 if(!guiApp.windowIsResizing || guiApp.resizeX)
4003 x = guiApp.windowMovingBefore.x + rx;
4004 if(!guiApp.windowIsResizing || guiApp.resizeY)
4005 y = guiApp.windowMovingBefore.y + ry;
4007 if(!guiApp.windowIsResizing)
4010 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
4012 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
4013 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
4014 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
4015 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
4019 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
4020 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
4026 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
4028 if(!window.OnMoving(&x, &y, w, h))
4030 x = window.scrolledPos.x;
4031 y = window.scrolledPos.y;
4037 SNAPDOWN(x, textCellW);
4038 SNAPDOWN(y, textCellH);
4041 if(!window.style.nonClient)
4043 if(!window.style.fixed /*|| window.style.isDocument*/)
4045 if(!window.style.dontScrollHorz)
4046 x += window.parent.scroll.x;
4047 if(!window.style.dontScrollVert)
4048 y += window.parent.scroll.y;
4052 // Break the anchors for moveable/resizable windows
4053 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4054 if(window.style.fixed)
4056 if(window.state == normal)
4058 window.normalAnchor = Anchor { left = x, top = y };
4059 window.normalSizeAnchor = SizeAnchor { { w, h } };
4060 window.anchored = false;
4064 window.stateAnchor = Anchor { left = x, top = y };
4065 window.stateSizeAnchor = SizeAnchor { { w, h } };
4067 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4068 // TOCHECK: Investigate why the following only redraws the scrollbars
4069 //window.Position(x, y, w, h, false, true, true, true, false, true);
4071 guiApp.movingLast.x = mouseX;
4072 guiApp.movingLast.y = mouseY;
4078 public bool MultiTouchMessage(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers * mods, bool consequential, bool activate)
4084 while(result && w != this)
4086 // TODO: How to handle this?
4089 Window msgWindow = GetAtPosition(x,y, false, true, w);
4094 window = (w && !w.disabled) ? w : null;
4096 if(consequential) mods->isSideEffect = true;
4097 if(!result || (window && window.destroyed)) window = null;
4101 if(window.OnMultiTouch && !window.disabled)
4103 Array<TouchPointerInfo> in { size = infos.size };
4104 memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
4108 i.x -= (window.absPosition.x + window.clientStart.x);
4109 i.y -= (window.absPosition.y + window.clientStart.y);
4111 i.x = Max(Min(i.x, 32767),-32768);
4112 i.y = Max(Min(i.y, 32767),-32768);
4116 if(!window.OnMultiTouch(event, in, *mods))
4123 if(!result || !w || !w.clickThrough)
4131 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4134 bool wasMoving = guiApp.windowMoving ? true : false;
4135 bool wasScrolling = guiApp.windowScrolling ? true : false;
4137 while(result && w != this)
4139 Window msgWindow = GetAtPosition(x,y, false, true, w);
4140 Window trueWindow = GetAtPosition(x,y, false, false, w);
4141 bool windowDragged = false;
4146 window = (w && !w.disabled) ? w : null;
4148 if(trueWindow) incref trueWindow;
4150 if(consequential) mods->isSideEffect = true;
4152 UpdateMouseMove(x, y, consequential);
4154 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4156 if(!guiApp.windowCaptured.isEnabled)
4157 guiApp.windowCaptured.ReleaseCapture();
4159 window = guiApp.windowCaptured;
4162 if(trueWindow && activate &&
4163 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4164 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4165 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4166 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4168 if(mods->alt && !mods->ctrl && !mods->shift)
4170 Window moved = trueWindow;
4171 for(moved = trueWindow; moved; moved = moved.parent)
4172 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4177 windowDragged = true;
4179 // Cancel the ALT menu toggling...
4180 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4185 if(window && activate &&
4186 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4187 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4188 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4189 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4191 Window modalWindow = window.FindModal();
4193 /*if(mods->alt && !mods->shift && !mods->ctrl)
4195 Window moved = window;
4196 for(moved = window; moved; moved = moved.parent)
4197 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4202 windowDragged = true;
4204 // Cancel the ALT menu toggling...
4205 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4211 Window activateWindow = modalWindow ? modalWindow : window;
4212 if(activateWindow && !activateWindow.isRemote)
4214 bool doActivation = true;
4215 //bool needToDoActivation = false;
4216 Window check = activateWindow;
4218 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4220 if(!check.style.inactive)
4222 //needToDoActivation = true;
4224 doActivation = false;
4229 if(!needToDoActivation)
4230 doActivation = false;
4233 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4234 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4236 // Let the OnLeftButtonDown do the activating instead
4237 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4245 incref activateWindow;
4246 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4248 delete activateWindow;
4252 if(activateWindow._refCount == 1)
4254 delete activateWindow;
4258 delete activateWindow;
4259 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4262 mods->isActivate = true;
4266 if(!modalWindow && window && !window.destroyed)
4268 if(!guiApp.windowCaptured || windowDragged)
4270 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4272 bool moving = ((window.state != maximized &&
4273 window.IsMouseMoving(
4274 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4275 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4277 if(!moving && window.IsMouseResizing(
4278 x - window.absPosition.x,
4279 y - window.absPosition.y,
4280 window.size.w, window.size.h,
4281 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4283 guiApp.windowIsResizing = true;
4284 guiApp.windowResizingBefore.w = window.size.w;
4285 guiApp.windowResizingBefore.h = window.size.h;
4287 if(guiApp.windowIsResizing || windowDragged || moving)
4290 guiApp.windowMoving = window;
4291 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4292 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4293 guiApp.windowMovingBefore.x = window.position.x;//s;
4294 guiApp.windowMovingBefore.y = window.position.y;//s;
4295 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4296 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4299 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4301 if(window.style.fixed &&
4303 window.IsMouseMoving(
4304 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4306 window.ShowSysMenu(x, y);
4310 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4312 if(window.sbv || window.sbh)
4315 guiApp.windowScrolling = window;
4316 guiApp.windowScrollingStart.x = x;
4317 guiApp.windowScrollingStart.y = y;
4318 guiApp.windowScrollingBefore.x = window.scroll.x;
4319 guiApp.windowScrollingBefore.y = window.scroll.y;
4322 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4324 if(window.style.hasMaximize &&
4325 window.IsMouseMoving(
4326 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4329 (window.state == maximized) ? normal : maximized, false, *mods);
4337 if(guiApp.windowMoving)
4339 if(guiApp.windowMoving.parent)
4341 if(guiApp.windowMoving.style.nonClient)
4342 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4344 guiApp.windowMoving.parent.SetMouseRangeToClient();
4348 window.UpdateDecorations();
4351 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4353 // Log("\n*** LEFT BUTTON UP ***\n");
4354 if(guiApp.windowMoving)
4355 guiApp.windowMoving.StopMoving();
4357 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4359 if(guiApp.windowScrolling)
4361 Window windowScrolling = guiApp.windowScrolling;
4362 guiApp.windowScrolling = null;
4363 windowScrolling.ReleaseCapture();
4367 if(!result || (window && window.destroyed)) window = null;
4369 if(window && window.FindModal())
4372 if(trueWindow && trueWindow.FindModal())
4380 msgWindow = GetAtPosition(x,y, true, false);
4382 msgWindow.SelectMouseCursor();
4385 if(guiApp.windowCaptured || trueWindow)
4387 Window prevWindow = guiApp.prevWindow;
4388 List<Window> overWindows = guiApp.overWindows;
4389 Iterator<Window> it { overWindows };
4394 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4397 result = w.OnMouseLeave(*mods);
4399 overWindows.TakeOut(w);
4403 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4405 guiApp.prevWindow.mouseInside = false;
4406 guiApp.prevWindow = null;
4410 if(trueWindow.IsDescendantOf(prevWindow))
4412 if(!overWindows.Find(prevWindow))
4413 overWindows.Add(prevWindow);
4415 // Eventually fix this not to include captured?
4416 else if(!prevWindow.OnMouseLeave(*mods))
4420 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4422 Box box = trueWindow.box;
4423 box.left += trueWindow.absPosition.x;
4424 box.right += trueWindow.absPosition.x;
4425 box.top += trueWindow.absPosition.y;
4426 box.bottom += trueWindow.absPosition.y;
4428 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4430 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4431 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4433 overX = Max(Min(overX, 32767),-32768);
4434 overY = Max(Min(overY, 32767),-32768);
4436 trueWindow.mouseInside = true;
4437 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4441 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4443 for(w : guiApp.overWindows; w == trueWindow)
4446 guiApp.overWindows.TakeOut(w);
4449 guiApp.prevWindow = trueWindow;
4452 guiApp.prevWindow = null;
4454 SelectMouseCursor();
4456 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4457 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4459 int clientX = x - (window.absPosition.x + window.clientStart.x);
4460 int clientY = y - (window.absPosition.y + window.clientStart.y);
4462 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4464 clientX = Max(Min(clientX, 32767),-32768);
4465 clientY = Max(Min(clientY, 32767),-32768);
4467 MouseMethod = (void *)window._vTbl[method];
4469 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4472 if(!MouseMethod(window, clientX, clientY, *mods))
4476 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4477 window.OnMouseLeave(*mods);
4484 if(result && w && w.clickThrough && w.parent)
4489 if(!result || !w || !w.clickThrough)
4496 // --- Mouse cursor management ---
4498 bool KeyMessage(uint method, Key key, unichar character)
4503 if(guiApp.interimWindow)
4504 this = guiApp.interimWindow;
4507 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4511 if(!style.inactive || rootWindow != this)
4513 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4514 Window modalWindow = FindModal();
4515 Window interimMaster = master ? master.rootWindow : null;
4519 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4520 status = OnSysKeyDown(key, character);
4521 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4522 status = OnSysKeyHit(key, character);
4523 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4524 status = OnSysKeyUp(key, character);
4531 // Process Key Message for Internal UI Keyboard actions
4532 if(status && !destroyed && menuBar && state != minimized)
4535 if((SmartKey)key != alt)
4536 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4539 SmartKey sk = (SmartKey) key;
4540 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4542 status = menuBar.KeyMessage(method, key, character);
4547 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4548 menuBar.OnKeyHit(escape, 0);
4550 if(!menuBar.focus && guiApp.caretOwner)
4551 guiApp.caretOwner.UpdateCaret(true, false);
4554 if(!destroyed && status)
4556 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4560 case left: case up: case right: case down:
4561 if(guiApp.windowMoving == this)
4564 int w = guiApp.windowMoving.size.w;
4565 int h = guiApp.windowMoving.size.h;
4566 int x = guiApp.windowMoving.scrolledPos.x;
4567 int y = guiApp.windowMoving.scrolledPos.y;
4571 if(key == down || key == up)
4572 step = Max(step, textCellH);
4574 step = Max(step, textCellW);
4577 if(guiApp.windowIsResizing)
4581 case left: w-=step; break;
4582 case right: w+=step; break;
4583 case up: h-=step; break;
4584 case down: h+=step; break;
4591 case left: x-=step; break;
4592 case right: x+=step; break;
4593 case up: y-=step; break;
4594 case down: y+=step; break;
4598 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4599 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4601 if(!guiApp.windowIsResizing || guiApp.resizeX)
4602 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4604 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4606 if(!guiApp.windowIsResizing || guiApp.resizeY)
4607 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4609 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4611 guiApp.interfaceDriver.SetMousePosition(x, y);
4612 ConsequentialMouseMove(true);
4620 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4622 guiApp.windowMoving.StopMoving();
4623 ConsequentialMouseMove(false);
4631 ShowSysMenu(absPosition.x, absPosition.y);
4639 if(!destroyed && status && state != minimized)
4641 // Process all the way down the children
4642 if(activeChild && !activeChild.disabled)
4644 status = activeChild.KeyMessage(method, key, character);
4646 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4647 key.code != left && key.code != right && key.code != up && key.code != down)
4649 status = activeClient.KeyMessage(method, key, character);
4653 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4655 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4656 // && defaultControl != activeChild)
4658 delete previousActive;
4659 previousActive = activeChild;
4660 if(previousActive) incref previousActive;
4662 ConsequentialMouseMove(false);
4663 if((defaultControl.active ||
4664 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4665 defaultControl.KeyMessage(method, defaultKey, character);
4671 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4673 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4680 ShowSysMenu(absPosition.x, absPosition.y);
4687 if(this != guiApp.desktop)
4689 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4691 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4693 MenuMoveOrSize(key.shift, true);
4697 else if(guiApp.windowMoving)
4699 guiApp.windowMoving.StopMoving();
4700 ConsequentialMouseMove(false);
4708 if(!destroyed && status && state != minimized)
4710 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4714 case tab: case shiftTab:
4716 Window cycleParent = this;
4717 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4718 cycleParent = master.parent;
4720 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4722 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4725 Window child = cycleParent.activeChild;
4727 // Scroll the window to include the active control
4728 if(cycleParent.sbh && !child.style.dontScrollHorz)
4730 if(child.scrolledPos.x < 0)
4731 cycleParent.sbh.Action(Position,
4732 cycleParent.scroll.x + child.scrolledPos.x, 0);
4733 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4734 cycleParent.sbh.Action(Position,
4735 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4737 if(cycleParent.sbv && !child.style.dontScrollVert)
4739 if(child.scrolledPos.y < 0)
4740 cycleParent.sbv.Action(Position,
4741 cycleParent.scroll.y + child.scrolledPos.y, 0);
4742 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4743 cycleParent.sbv.Action(Position,
4744 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4747 cycleParent.ConsequentialMouseMove(false);
4753 case f6: case shiftF6:
4754 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4756 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4757 if(parent == guiApp.desktop)
4758 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4768 if(CycleChildren(key.shift, true, false, true))
4776 // mIRC Style Window Shortcuts
4777 case alt1: case alt2: case alt3: case alt4: case alt5:
4778 case alt6: case alt7: case alt8: case alt9: case alt0:
4783 for(document = children.first; document; document = document.next)
4785 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4787 if(document == activeChild)
4789 if(document.state == minimized)
4790 document.SetState(normal, false, key);
4793 document.SetState(minimized, false, key);
4794 CycleChildren(false, true, false);
4799 if(activeChild.state == maximized && document.style.hasMaximize)
4800 document.SetState(maximized, false, key);
4801 else if(document.state == minimized)
4802 document.SetState(normal, false, key);
4803 document.Activate();
4818 if(!destroyed && status)
4820 if(state == minimized)
4825 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4827 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4829 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4830 previousActive.ActivateEx(true, false, false, true, null, null);
4831 delete previousActive;
4837 if(!destroyed && status)
4839 status = ProcessHotKeys(method, key, character);
4841 if(!destroyed && status && !modalWindow && state != minimized)
4844 status = KeyMethod(this, key, character);
4845 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4846 status = OnKeyHit(key, character);
4847 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4849 bool result = false;
4852 case ctrlUp: case ctrlDown:
4853 if(sbv && !guiApp.windowScrolling)
4854 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4856 case wheelUp: case wheelDown:
4857 if(sbv && !guiApp.windowScrolling)
4859 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4860 // Do we want to do a consequential move regardless of result in this case?
4861 ConsequentialMouseMove(false);
4864 case ctrlPageUp: case ctrlPageDown:
4865 if(sbh && !guiApp.windowScrolling)
4866 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4871 ConsequentialMouseMove(false);
4876 if(status && !destroyed && menuBar && state != minimized)
4877 status = menuBar.KeyMessage(method, key, character);
4879 if(style.interim && /*destroyed && */status && interimMaster)
4881 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4882 status = interimMaster.KeyMessage(method, key, character);
4889 bool ProcessHotKeys(uint method, Key key, unichar character)
4894 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4895 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4896 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4898 Window hotKeyWindow = hotKey.window;
4899 Window parent = hotKeyWindow.parent;
4900 Window prevActiveWindow = activeChild;
4901 // For when sys buttons are placed inside the menu bar
4902 if(parent && parent._class == class(PopupMenu))
4903 parent = parent.parent;
4905 // 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
4906 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4909 if(prevActiveWindow) incref prevActiveWindow;
4910 incref hotKeyWindow;
4911 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4912 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4915 delete hotKeyWindow;
4916 delete prevActiveWindow;
4920 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4921 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4922 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4924 // ********* WORKING ON THIS ***********
4925 if(prevActiveWindow && !guiApp.interimWindow)
4926 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4929 else if(hotKeyWindow.style.inactive)
4930 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4932 delete prevActiveWindow;
4933 delete hotKeyWindow;
4934 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4935 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4939 if(status && tabCycle)
4942 for(child = children.first; child; child = child.next)
4944 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4955 // --- Windows and graphics initialization / termination ---
4956 bool SetupRoot(void)
4960 // Setup relationship with outside world (bb root || !bb)
4961 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4962 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4966 tempExtents = new0 Extent[4];
4971 /*if(guiApp.fullScreenMode)
4972 rootWindow = guiApp.desktop;
4974 //rootWindow = parent.created ? parent.rootWindow : null;
4975 rootWindow = parent.rootWindow;
4978 against = &parent.box;
4980 against = &parent.clientArea;
4983 for(child = children.first; child; child = child.next)
4986 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4989 bool Setup(bool positionChildren)
4991 bool result = false;
4994 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4996 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4997 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
5000 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
5002 // This was here, is it really needed?
5003 //guiApp.interfaceDriver.ActivateRootWindow(this);
5007 displaySystem = DisplaySystem {};
5008 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
5010 delete displaySystem;
5015 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
5016 if(display.Create(displaySystem, windowHandle))
5023 // Sometimes icon does not show up on Windows XP if we set here...
5024 // guiApp.interfaceDriver.SetIcon(this, icon);
5026 else if(this != guiApp.desktop)
5028 display = rootWindow ? rootWindow.display : null;
5034 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
5035 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
5037 for(child = children.first; child; child = child.next)
5039 if(child.created && !child.Setup(false))
5042 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
5043 child.UpdateCaption();
5048 bool SetupDisplay(void)
5050 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
5051 if(is3D) return Window3D_SetupDisplay(this); else
5058 class_data void ** pureVTbl;
5060 bool LoadGraphics(bool creation, bool resetAnchors)
5062 bool result = false;
5063 bool success = false;
5065 WindowState stateBackup = state;
5067 if(((subclass(Window))_class).pureVTbl)
5069 if(_vTbl == _class._vTbl)
5071 _vTbl = ((subclass(Window))_class).pureVTbl;
5076 for(m = 0; m < _class.vTblSize; m++)
5078 if(_vTbl[m] == _class._vTbl[m])
5079 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5083 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
5085 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5087 _vTbl = _class._vTbl;
5092 for(m = 0; m < _class.vTblSize; m++)
5094 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5095 _vTbl[m] = _class._vTbl[m];
5100 if(guiApp.fullScreenMode || this != guiApp.desktop)
5102 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5108 display.Lock(false);
5109 if(rootWindow == this)
5111 // Set Color Palette
5112 display.SetPalette(palette, true);
5116 if(guiApp.fullScreenMode && this == guiApp.desktop)
5121 for(c=0; c<SystemCursor::enumSize; c++)
5122 if(!guiApp.systemCursors[c].bitmap)
5124 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5125 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5126 if(guiApp.systemCursors[c].bitmapName)
5128 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5129 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5130 if(guiApp.systemCursors[c].bitmap)
5131 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5136 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5138 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5139 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5141 cursor.bitmap.paletteShades = cursor.paletteShades;
5145 guiApp.cursorUpdate = true;
5148 ConsequentialMouseMove(false);
5154 // Load Window Graphic Resources
5157 if(usedFont == setFont || usedFont == window.systemFont)
5158 RemoveResource(usedFont);
5161 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5164 RemoveResource(systemFont);
5167 RemoveResource(captionFont);
5169 for(ptr = resources.first; ptr; ptr = ptr.next)
5171 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5172 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5175 AddResource(setFont);
5177 AddResource(systemFont);
5179 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5186 //if(master && master.font)
5187 if(parent && parent.font)
5191 faceName = parent.font.faceName,
5192 size = parent.font.size,
5193 bold = parent.font.bold,
5194 italic = parent.font.italic,
5195 underline = parent.font.underline
5197 //font = parent.font;
5198 watch(parent) { font { } };
5201 font = guiApp.currentSkin.SystemFont();
5208 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5209 AddResource(captionFont);
5211 if(OnLoadGraphics())
5217 //SetScrollLineStep(sbStep.x, sbStep.y);
5219 if(this != guiApp.desktop)
5223 normalAnchor = anchor;
5224 normalSizeAnchor = sizeAnchor;
5227 // Break the anchors for moveable/resizable windows
5229 if(style.fixed && style.isDocument)
5231 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5243 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5244 stateSizeAnchor = SizeAnchor {};
5249 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5254 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5255 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5258 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5262 stateAnchor = normalAnchor;
5263 stateSizeAnchor = normalSizeAnchor;
5266 position = Point { };
5267 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5278 if(Position(x, y, w, h, true, false, true, true, true, true))
5280 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5283 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5300 success = result = true;
5303 if(!creation && result)
5305 // Load menu bar first because sys buttons are on it...
5308 if(!menuBar.LoadGraphics(false, resetAnchors))
5314 for(child = children.first; child; child = child.next)
5316 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5323 CreateSystemChildren();
5327 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5330 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5333 LogErrorCode(graphicsLoadingFailed, _class.name);
5335 // Do this here to avoid problems on Windows
5336 if(rootWindow == this && parent && stateBackup == maximized)
5337 property::state = maximized;
5341 void UnloadGraphics(bool destroyWindows)
5345 // Free children's graphics
5346 for(child = children.first; child; child = child.next)
5347 child.UnloadGraphics(destroyWindows);
5350 display.Lock(false);
5353 if(guiApp.fullScreenMode && this == guiApp.desktop)
5358 for(c=0; c<SystemCursor::enumSize; c++)
5359 if(guiApp.systemCursors[c].bitmap)
5360 delete guiApp.systemCursors[c].bitmap;
5362 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5363 delete cursor.bitmap;
5365 guiApp.cursorBackground.Free();
5368 if(display && display.displaySystem)
5372 for(ptr = resources.first; ptr; ptr = ptr.next)
5376 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5381 // Free window graphics
5384 // Free skin graphics
5385 if(rootWindow == this)
5387 DisplaySystem displaySystem = display.displaySystem;
5390 display.driverData = null;
5391 display.displaySystem = null;
5395 if(displaySystem && !displaySystem.numDisplays && !is3D)
5396 delete displaySystem;
5405 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5406 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5408 if(this == guiApp.desktop || parent == guiApp.desktop)
5410 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5411 guiApp.interfaceDriver.DestroyRootWindow(this);
5415 // --- Window Hiding ---
5417 void SetVisibility(bool state)
5419 bool visible = (style.hidden || !created) ? false : state;
5420 if(visible != this.visible)
5424 this.visible = visible;
5425 for(child = children.first; child; child = child.next)
5426 child.SetVisibility(visible);
5428 ConsequentialMouseMove(false);
5429 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5433 // --- Windows and graphics initialization / termination ---
5435 bool DisplayModeChanged(void)
5437 bool result = false;
5438 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5440 guiApp.modeSwitching = true;
5441 UnloadGraphics(false);
5443 if(LoadGraphics(false, false))
5445 guiApp.modeSwitching = false;
5450 // --- Window updates system ---
5452 void UpdateDirty(Box updateBox)
5454 if(!manageDisplay) { OnRedraw(null);return; }
5457 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5460 if(display.flags.flipping)
5463 rootWindow.UpdateDisplay();
5466 UpdateBackDisplay(updateBox);
5468 if(guiApp.fullScreenMode)
5470 guiApp.cursorUpdate = true;
5471 guiApp.PreserveAndDrawCursor();
5473 if(guiApp.fullScreenMode)
5474 guiApp.RestoreCursorBackground();
5480 // This function is strictly called as a result of system window activation
5481 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5484 Window interimMaster = null;
5485 Window interimWindow = guiApp.interimWindow;
5486 if(interimWindow && interimWindow.master)
5487 interimMaster = interimWindow.master.rootWindow;
5489 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5490 // SetState(normal, false, 0);
5491 SetState(lastState, false, 0);
5493 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5497 /* WTH is this doing here?
5498 while(swap && swap.activeChild)
5500 swap = swap.activeChild;
5503 // TESTING THIS BEFORE...
5504 if(interimWindow && this == interimMaster)
5508 // Window interimSwap = this;
5509 Window menuBar = this.menuBar;
5510 if(menuBar && interimWindow.master == menuBar)
5513 while(interimSwap && interimSwap.activeChild)
5514 interimSwap = interimSwap.activeChild;
5516 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5517 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5519 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5520 //result = ActivateEx(true, true, false, activateRoot, window, null);
5525 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5526 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5528 if(interimWindow == this && interimMaster && !active)
5530 while(interimMaster && interimMaster.interim && interimMaster.master)
5532 // printf("Going up one master %s\n", interimMaster._class.name);
5533 interimMaster = interimMaster.master.rootWindow;
5535 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5536 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5542 bool DestroyEx(int64 returnCode)
5545 Timer timer, nextTimer;
5547 OldLink prevOrder = null;
5548 Window client = null;
5550 if(parent) stopwatching(parent, font);
5552 // if(window.modalSlave) return false;
5553 if(destroyed || !created)
5560 OldLink slave = master.slaves.FindLink(this);
5561 master.slaves.Delete(slave);
5564 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5570 this.returnCode = (DialogResult)returnCode;
5572 AcquireInput(false);
5577 master.hotKeys.Delete(hotKey);
5581 if(guiApp.prevWindow == this)
5583 guiApp.prevWindow = null;
5588 for(w : guiApp.overWindows; w == this)
5591 guiApp.overWindows.TakeOut(w);
5595 if(guiApp.caretOwner == this)
5597 guiApp.interfaceDriver.SetCaret(0,0,0);
5598 UpdateCaret(false, true);
5599 guiApp.caretEnabled = false;
5604 parent.childrenCycle.Remove(cycle);
5608 OldLink tmpPrev = order.prev;
5609 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5610 prevOrder = tmpPrev;
5613 client = tmpPrev ? tmpPrev.data : null;
5614 if(client == this) { client = null; break; }
5615 if(client && (client.style.hidden || client.destroyed || !client.created))
5616 tmpPrev = client.order.prev;
5620 prevOrder = tmpPrev;
5625 // If this window can be an active client, make sure the next window we activate can also be one
5626 if(!style.nonClient && style.isActiveClient)
5628 tmpPrev = prevOrder;
5631 client = tmpPrev ? tmpPrev.data : null;
5632 if(client == this) { client = null; break; }
5633 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5634 tmpPrev = client.order.prev;
5638 prevOrder = tmpPrev;
5642 if(client && client.style.hidden) client = null;
5644 // parent.childrenOrder.Remove(order);
5647 if(parent && style.isActiveClient && visible)
5649 if(state == minimized) parent.numIcons--;
5650 parent.numPositions--;
5653 // TESTING THIS HERE!
5657 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5658 // to create a window inside a rootwindow that's being destroyed)
5659 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5661 if(master && !master.destroyed /*&&
5662 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5664 if(master.defaultControl == this)
5665 master.defaultControl = null;
5668 parent.OnChildAddedOrRemoved(this, true);
5669 if(parent && !parent.destroyed /*&&
5670 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5672 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5674 if(order && prevOrder && prevOrder.data != this && active)
5676 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5678 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5679 if(parent.activeClient == this)
5681 parent.activeClient = null;
5682 parent.UpdateActiveDocument(null);
5687 if(guiApp.interimWindow == this)
5690 PropagateActive(false, null, &goOn, true);
5694 //if(window.parent.activeChild == window)
5695 parent.activeChild = null;
5696 if(!style.nonClient /*&& style.isActiveClient*/)
5698 Window previous = parent.activeClient;
5699 if(style.isActiveClient)
5700 parent.activeClient = null;
5701 parent.UpdateActiveDocument(previous);
5706 else if(parent.activeClient == this)
5708 parent.activeClient = client;
5709 parent.UpdateActiveDocument(this);
5713 if(guiApp.interimWindow == this)
5715 guiApp.interimWindow = null;
5716 if(guiApp.caretOwner)
5718 Window desktop = guiApp.desktop;
5719 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5720 guiApp.caretOwner.UpdateCaret(false, false);
5725 if(_isModal && master && master.modalSlave == this)
5726 master.modalSlave = null;
5730 if(!guiApp.caretOwner && parent.caretSize)
5732 guiApp.caretOwner = parent;
5733 parent.UpdateCaret(false, false);
5734 parent.Update(null);
5737 // Why was this commented out?
5738 GetRidOfVirtualArea();
5744 dirtyArea.Free(null);
5745 dirtyBack.Free(null);
5746 scrollExtent.Free(null);
5748 /* ATTEMPTING TO MOVE THAT ABOVE
5757 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5758 for(;(child = window.children.first);)
5760 for(; child && (child.destroyed || !child.created); child = child.next);
5769 UnloadGraphics(true);
5772 delete previousActive;
5775 // statusBar = null;
5778 if(master && !master.destroyed)
5780 //master.NotifyDestroyed(this, this.returnCode);
5781 NotifyDestroyed(master, this, this.returnCode);
5784 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5786 nextTimer = timer.next;
5787 if(timer.window == this)
5789 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5790 // timer.window = null;
5796 if(this == guiApp.windowMoving)
5799 if(guiApp.windowCaptured == this)
5801 //guiApp.windowCaptured = null;
5803 if(rootWindow != this && rootWindow)
5804 rootWindow.ConsequentialMouseMove(false);
5812 //for(child = children.first; next = child ? child.next : null, child; child = next)
5813 for(;(child = children.first); )
5815 for(; child && (child.destroyed || !child.created); child = child.next);
5825 /* // MOVED THIS UP...
5828 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5829 for(;(child = window.children.first); )
5831 for(; child && (child.destroyed || !child.created); child = child.next);
5840 while((slave = slaves.first))
5842 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5844 ((Window)slave.data).DestroyEx(0);
5849 if(guiApp.caretOwner == this)
5850 guiApp.caretOwner = null;
5852 sysButtons[0] = null;
5853 sysButtons[1] = null;
5854 sysButtons[2] = null;
5857 if(rootWindow != this)
5859 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5862 box.left -= parent.clientStart.x;
5863 box.top -= parent.clientStart.y;
5864 box.right -= parent.clientStart.x;
5865 box.bottom -= parent.clientStart.y;
5867 if(parent) parent.Update(box);
5872 OldLink slave = master.slaves.FindVoid(this);
5873 master.slaves.Delete(slave);
5879 parent.children.Remove(this);
5884 //autoCreate = false;
5887 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5888 if(((subclass(Window))_class).pureVTbl)
5890 if(_vTbl == _class._vTbl)
5892 _vTbl = ((subclass(Window))_class).pureVTbl;
5897 for(m = 0; m < _class.vTblSize; m++)
5899 if(_vTbl[m] == _class._vTbl[m])
5900 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5909 void SetStateEx(WindowState newState, bool activate)
5912 WindowState prevState = state;
5916 if(prevState != newState)
5917 lastState = prevState;
5919 if(rootWindow != this || !nativeDecorations || !windowHandle)
5921 if(style.isActiveClient && !style.hidden && prevState == minimized)
5924 // This block used to be at the end of the function... moved it for flicker problem in X
5925 // ------------------------------------------------------
5929 stateAnchor = normalAnchor;
5930 stateSizeAnchor = normalSizeAnchor;
5933 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5934 stateSizeAnchor = SizeAnchor {};
5940 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5943 byte * idBuffer = new0 byte[size];
5945 for(child = parent.children.first; child; child = child.next)
5947 if(child != this && child.state == minimized)
5949 if(child.iconID > size - 2)
5951 idBuffer = renew0 idBuffer byte[size*2];
5952 memset(idBuffer + size, 0, size);
5955 idBuffer[child.iconID] = (byte)bool::true;
5958 for(c = 0; c<size; c++)
5963 if(style.isActiveClient && !style.hidden)
5966 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5967 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5972 // TOCHECK: Why was this here?
5973 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5974 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5975 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5977 if(state != minimized || hasMinimize)
5978 Position(x, y, w, h, true, true, true, true, false, true);
5980 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5981 parent.UpdateActiveDocument(null);
5984 if(state != minimized || hasMinimize)
5985 CreateSystemChildren();
5986 // ------------------------------------------------------
5989 int GetPositionID(Window forChild)
5993 byte * idBuffer = new0 byte[size];
5996 for(child = children.first; child; child = child.next)
5998 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
6000 if(child.positionID > size - 2)
6002 idBuffer = renew0 idBuffer byte[size*2];
6003 memset(idBuffer + size, 0, size);
6006 idBuffer[child.positionID] = (byte)bool::true;
6009 for(c = 0; c<size; c++)
6016 // --- Window related graphics ---
6018 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
6020 palette = newPalette;
6021 if(rootWindow.display)
6022 rootWindow.display.SetPalette(palette, colorMatch);
6025 public bool AcquireInput(bool acquired)
6028 if(acquiredInput != acquired)
6030 if(active || (!visible && creationActivation == activate))
6031 result = AcquireInputEx(acquired);
6036 acquiredInput = acquired ? result : !result;
6041 void ListChildren(ListBox listBox)
6045 for(child = children.first; child; child = child.next)
6047 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
6049 DataRow row = listBox.AddRow();
6050 row.tag = (int64)(intptr)child;
6051 child.FigureCaption(caption);
6052 row.SetData(null, caption);
6057 void UpdateVisual(Box extent)
6059 if(guiApp.driver != null)
6061 if(guiApp.fullScreenMode && guiApp.desktop.display)
6063 guiApp.desktop.mutex.Wait();
6064 guiApp.desktop.display.Lock(true);
6067 if(guiApp.desktop.active)
6069 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
6071 if(guiApp.desktop.display.flags.flipping)
6072 guiApp.desktop.Update(null);
6073 guiApp.desktop.UpdateDisplay();
6074 guiApp.cursorUpdate = true;
6076 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
6078 guiApp.PreserveAndDrawCursor();
6079 // guiApp.desktop.display.ShowScreen();
6080 guiApp.cursorUpdate = false;
6081 guiApp.desktop.dirty = false;
6082 guiApp.RestoreCursorBackground();
6086 guiApp.desktop.display.Unlock();
6087 guiApp.desktop.mutex.Release();
6091 Window rootWindow = this.rootWindow;
6092 rootWindow.mutex.Wait();
6097 guiApp.SignalEvent();
6100 guiApp.waitMutex.Wait();
6101 guiApp.interfaceDriver.Lock(rootWindow);
6102 if(!rootWindow.style.hidden && rootWindow.dirty)
6104 if(rootWindow.display)
6106 rootWindow.UpdateDisplay();
6107 //rootWindow.display.ShowScreen(null);
6109 rootWindow.dirty = false;
6111 guiApp.interfaceDriver.Unlock(rootWindow);
6112 guiApp.waitMutex.Release();
6115 rootWindow.mutex.Release();
6120 void UnlockDisplay(void)
6122 guiApp.interfaceDriver.Unlock(rootWindow);
6125 void LockDisplay(void)
6127 guiApp.interfaceDriver.Lock(rootWindow);
6130 Surface GetSurface(Box box)
6132 return Redraw((box == null) ? this.box : box);
6135 void SetMousePosition(int x, int y)
6137 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6141 void IntegrationActivate(bool active)
6143 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6145 isForegroundWindow = true;
6146 ActivateEx(active, active, false, false, null, null);
6147 isForegroundWindow = false;
6152 Window QueryCapture(void)
6154 return guiApp.windowCaptured;
6157 int GetDocumentID(void)
6161 byte * idBuffer = new0 byte[size];
6164 for(child = children.first; child; child = child.next)
6166 // TO CHECK: Do we want a documentID when we already have a file name?
6167 if(child.style.isDocument && !child.fileName)
6169 if(child.documentID-1 > size - 2)
6171 idBuffer = renew0 idBuffer byte[size*2];
6172 memset(idBuffer + size, 0, size);
6175 idBuffer[child.documentID-1] = 1;
6178 for(c = 0; c<size; c++)
6186 void SetInitSize(Size size)
6189 sizeAnchor.size = size;
6190 normalSizeAnchor = sizeAnchor;
6192 // Break the anchors for moveable/resizable windows
6193 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6195 stateAnchor = normalAnchor;
6196 stateSizeAnchor = normalSizeAnchor;
6198 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6199 Position(x,y, w, h, true, true, true, true, false, true);
6203 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6205 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6207 guiApp.windowIsResizing = resize;
6208 guiApp.windowMoving = this;
6209 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6210 if(guiApp.windowIsResizing)
6212 guiApp.windowMovingStart.x += size.w - 1;
6213 guiApp.windowMovingStart.y += size.h - 1;
6215 guiApp.windowMovingBefore = scrolledPos;
6216 guiApp.windowResizingBefore = size;
6217 guiApp.windowMoving.UpdateDecorations();
6218 if(guiApp.windowIsResizing)
6219 guiApp.resizeEndX = guiApp.resizeEndY = true;
6221 if(setCursorPosition)
6222 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6226 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6227 guiApp.windowMovingStart.x += x - absPosition.x;
6228 guiApp.windowMovingStart.y += y - absPosition.y;
6231 if(guiApp.windowMoving)
6233 if(guiApp.windowMoving.style.nonClient)
6234 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6236 guiApp.windowMoving.parent.SetMouseRangeToClient();
6241 if(this == rootWindow)
6242 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6246 void SetupFileMonitor()
6250 fileMonitor = FileMonitor
6252 this, FileChange { modified = true };
6254 bool OnFileNotify(FileChange action, const char * param)
6257 fileMonitor.StopMonitoring();
6258 if(OnFileModified(action, param))
6259 fileMonitor.StartMonitoring();
6272 bool result = false;
6276 else if(guiApp && guiApp.driver != null)
6278 OldLink slaveHolder;
6280 bool visible = !style.hidden;
6284 systemParent = parent;
6285 parent = guiApp.desktop;
6287 last = parent ? parent.children.last : null;
6289 if((parent && parent != guiApp.desktop && !parent.created) ||
6290 (master && master != guiApp.desktop && !master.created))
6294 stopwatching(parent, font);
6297 property::parent = guiApp.desktop;
6298 if(!master) master = parent;
6300 if(_isModal && master.modalSlave)
6301 property::master = master.modalSlave;
6305 parent.children.Remove(this);
6308 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6309 if(slaveHolder.data == this)
6311 master.slaves.Delete(slaveHolder);
6316 if(parent == guiApp.desktop && !mutex)
6319 if(style.isDocument)
6322 parent.numDocuments--;
6323 documentID = parent.GetDocumentID();
6326 if(!style.stayOnTop)
6327 for(; last && last.style.stayOnTop; last = last.prev);
6329 parent.children.Insert((last == this) ? null : last, this);
6330 //parent.children.Add(this);
6333 dispDriver = parent.dispDriver;
6336 master.modalSlave = this;
6338 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6343 master.slaves.Add(slaveHolder = OldLink { data = this });
6348 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6350 if(style.isDefault && !master.defaultControl)
6351 master.defaultControl = this;
6353 stateAnchor = normalAnchor = anchor;
6354 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6356 // TOCHECK: Why is this here?
6357 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6358 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6360 this.visible = false;
6361 style.hidden = true;
6364 // autoCreate = true;
6372 if(parent == guiApp.desktop)
6373 Log("LoadGraphics %s\n", caption);
6375 if(LoadGraphics(true, false))
6383 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6390 if(style.hasMenuBar /*&& menu*/)
6396 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6397 interim = false, inactive = true, nonClient = true, size.h = 24
6405 // Create the system buttons
6406 CreateSystemChildren();
6408 UpdateActiveDocument(null);
6410 if(style.isDocument)
6414 MenuItem item = menu.FindItem(MenuFileSave, 0);
6415 if(item) item.disabled = !modifiedDocument && fileName;
6420 if(parent == guiApp.desktop)
6421 Log("Preemptive SetState %s\n", caption);
6424 // Preemptive Set State to ensure proper anchoring
6425 SetStateEx(state, false);
6427 style.hidden = true;
6433 for(child = children.first; child; child = next)
6436 if(!child.created && (child.autoCreate || child.wasCreated))
6443 for(link = slaves.first; link; link = next)
6445 Window slave = link.data;
6447 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6450 // Things might have happened that invalidated 'next'...
6451 // Start over the search for slaves to create.
6452 // (Added this to fix crash with Stacker & Toolbar)
6453 next = slaves.first;
6462 if(parent == guiApp.desktop)
6463 Log("Real SetState %s\n", caption);
6466 if(isActiveClient && visible)
6468 parent.numPositions--;
6469 if(state == minimized) parent.numIcons--;
6472 parent.OnChildAddedOrRemoved(this, false);
6474 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6476 // Real set state & activate for proper display & activation
6477 property::visible = visible;
6478 // SetState(state & 0x00000003, true, 0);
6479 guiApp.interfaceDriver.SetIcon(this, icon);
6484 /*if(rootWindow == this)
6485 guiApp.interfaceDriver.ActivateRootWindow(this);
6487 if(creationActivation == activate && guiApp.desktop.active)
6488 ActivateEx(true, false, true, true, null, null);
6489 else if(creationActivation == activate || creationActivation == flash)
6492 if(this == rootWindow)
6497 if(!destroyed && !noConsequential)
6498 rootWindow.ConsequentialMouseMove(false);
6509 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6515 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6517 //style.hidden = true; // !visible;
6518 style.hidden = !visible;
6519 if(master.modalSlave == this)
6520 master.modalSlave = null;
6527 void WriteCaption(Surface surface, int x, int y)
6530 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6533 void Update(Box region)
6539 rootWindow = this.rootWindow;
6541 // rootWindow.mutex.Wait();
6542 if(!destroyed && visible && display)
6547 // Testing this to avoid repetitve full update to take time...
6548 if(rootWindow.fullRender)
6550 rootWindow.dirty = true;
6553 if(dirtyArea.count == 1)
6555 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6556 if(item.box.left <= box.left &&
6557 item.box.top <= box.top &&
6558 item.box.right >= box.right &&
6559 item.box.bottom >= box.bottom)
6561 rootWindow.dirty = true;
6566 if(display.flags.flipping && !rootWindow.dirty)
6568 if(this == rootWindow)
6572 rootWindow.Update(null);
6577 rootWindow.dirty = true;
6582 realBox.left += clientStart.x;
6583 realBox.top += clientStart.y;
6584 realBox.right += clientStart.x;
6585 realBox.bottom += clientStart.y;
6591 if(realBox.right >= realBox.left &&
6592 realBox.bottom >= realBox.top)
6594 // if(!rootWindow.fullRender)
6595 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6597 for(child = children.first; child; child = child.next)
6602 box.left -= child.absPosition.x - absPosition.x;
6603 box.top -= child.absPosition.y - absPosition.y;
6604 box.right -= child.absPosition.x - absPosition.x;
6605 box.bottom -= child.absPosition.y - absPosition.y;
6606 if(box.right >= child.box.left && box.left <= child.box.right &&
6607 box.bottom >= child.box.top && box.top <= child.box.bottom)
6609 box.left -= child.clientStart.x;
6610 box.top -= child.clientStart.y;
6611 box.right -= child.clientStart.x;
6612 box.bottom -= child.clientStart.y;
6618 realBox.left += absPosition.x - rootWindow.absPosition.x;
6619 realBox.top += absPosition.y - rootWindow.absPosition.y;
6620 realBox.right += absPosition.x - rootWindow.absPosition.x;
6621 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6622 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6625 else if(this == guiApp.desktop)
6628 for(window = children.first; window; window = window.next)
6634 Box childBox = region;
6636 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6637 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6638 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6639 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6641 window.Update(childBox);
6644 window.Update(null);
6649 // rootWindow.mutex.Release();
6656 if(guiApp.windowCaptured != this)
6658 if(guiApp.windowCaptured)
6662 //Logf("Captured %s (%s)\n", caption, class.name);
6663 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6664 guiApp.windowCaptured = this;
6670 bool Destroy(int64 code)
6675 if(!destroyed && !CloseConfirmation(false)) return false;
6679 // TOCHECK: Should autoCreate be set to false here?
6690 void Move(int x, int y, int w, int h)
6692 normalAnchor = Anchor { left = x, top = y };
6693 normalSizeAnchor = SizeAnchor { size = { w, h } };
6695 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6697 if(destroyed) return;
6699 stateAnchor = normalAnchor;
6700 stateSizeAnchor = normalSizeAnchor;
6702 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6703 Position(x,y, w, h, true, true, true, true, false, true);
6707 DialogResult Modal(void)
6713 // FIXES MEMORY LEAK IF Create() FAILED
6719 void SetScrollArea(int width, int height, bool snapToStep)
6723 int stepX = sbStep.x, stepY = sbStep.y;
6724 // Needed to make snapped down position match the skin's check of client area
6725 // against realvirtual
6728 SNAPDOWN(stepX, textCellW);
6729 SNAPDOWN(stepY, textCellH);
6730 stepX = Max(stepX, textCellW);
6731 stepY = Max(stepY, textCellH);
6733 if(scrollFlags.snapX)
6734 SNAPUP(width, stepX);
6735 if(scrollFlags.snapY)
6736 SNAPUP(height, stepY);
6739 reqScrollArea.w = width;
6740 reqScrollArea.h = height;
6741 noAutoScrollArea = (width > 0 || height > 0);
6743 UpdateScrollBars(true, true);
6746 void SetScrollPosition(int x, int y)
6749 sbh.Action(setPosition, x, 0);
6753 int seen = clientSize.w, total = reqScrollArea.w;
6755 if(scrollFlags.snapX)
6756 SNAPDOWN(seen, sbStep.x);
6758 if(!total) total = seen;
6759 range = total - seen + 1;
6760 range = Max(range, 1);
6762 if(x >= range) x = range - 1;
6764 if(scrollFlags.snapX)
6765 SNAPUP(x, sbStep.x);
6768 OnHScroll(setPosition, x, 0);
6772 SNAPDOWN(x, textCellW);
6778 sbv.Action(setPosition, y, 0);
6782 int seen = clientSize.h, total = reqScrollArea.h;
6785 if(scrollFlags.snapY)
6786 SNAPDOWN(seen, sbStep.y);
6788 if(!total) total = seen;
6789 range = total - seen + 1;
6790 range = Max(range, 1);
6792 if(y >= range) y = range - 1;
6794 if(scrollFlags.snapY)
6795 SNAPUP(y, sbStep.y);
6798 OnVScroll(setPosition, y, 0);
6801 SNAPDOWN(y, textCellH);
6806 UpdateCaret(false, false);
6809 void SetScrollLineStep(int stepX, int stepY)
6815 SNAPDOWN(stepX, textCellW);
6816 SNAPDOWN(stepY, textCellH);
6817 stepX = Max(stepX, textCellW);
6818 stepY = Max(stepY, textCellH);
6821 sbh.lineStep = stepX;
6823 sbv.lineStep = stepY;
6826 void SetState(WindowState newState, bool activate, Modifiers mods)
6830 if(state == newState || OnStateChange(newState, mods))
6832 //WindowState prevState = state;
6836 // This used to be at the end of the brackets... moved for X, testing...
6837 // This has the effect of activating the window through the system...
6838 if(rootWindow == this)
6839 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6841 SetStateEx(newState, activate);
6843 if(rootWindow == this && !rootWindow.nativeDecorations)
6845 int x = position.x, y = position.y;
6848 x -= guiApp.desktop.absPosition.x;
6849 y -= guiApp.desktop.absPosition.y;
6851 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6855 //state = prevState;
6857 if(state != maximized && style.hasMaximize)
6860 for(child = parent.children.first; child; child = child.next)
6862 if(child != this && child.state == maximized)
6863 child.SetStateEx(normal, false);
6867 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6868 parent.UpdateScrollBars(true, true);
6871 // Do we really need this stuff here?
6872 // Shouldn't the Activate stuff take care of it?
6873 if(parent.rootWindow == parent && style)
6876 parent.FigureCaption(caption);
6877 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6878 parent.UpdateDecorations();
6882 rootWindow.ConsequentialMouseMove(false);
6889 BitmapResource GetIcon(SkinBitmap iconID)
6891 return guiApp.currentSkin.GetBitmap(iconID);
6894 void SetMouseRange(Box range)
6896 if(range || guiApp.fullScreenMode)
6901 clip.left = range.left + absPosition.x + clientStart.x;
6902 clip.top = range.top + absPosition.y + clientStart.y;
6903 clip.right = range.right + absPosition.x + clientStart.x;
6904 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6908 clip.left = guiApp.desktop.box.left;
6909 clip.top = guiApp.desktop.box.top;
6910 clip.right = guiApp.desktop.box.right;
6911 clip.bottom = guiApp.desktop.box.bottom;
6913 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6916 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6919 void SetMouseRangeToClient(void)
6921 if(guiApp.fullScreenMode || this != guiApp.desktop)
6923 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6924 box.Clip(clientArea);
6928 SetMouseRange(null);
6931 void SetMouseRangeToWindow(void)
6933 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6934 if(this == guiApp.desktop)
6935 SetMouseRangeToClient();
6940 // x, y: Desktop Coordinates
6941 void ShowSysMenu(int x, int y)
6944 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6947 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6948 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6952 menu, $"Move", m, NotifySelect = MenuWindowMove,
6953 disabled = !style.fixed || state == maximized
6957 menu, $"Size", s, NotifySelect = MenuWindowSize,
6958 disabled = !style.sizable || state != normal
6962 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6963 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6967 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6968 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6972 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6973 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6975 MenuDivider { menu };
6978 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6979 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6981 windowMenu.Create();
6986 ActivateEx(true, true, true, true, null, null);
6989 void MakeActive(void)
6991 ActivateEx(true, false, true, false, null, null);
6994 void SoftActivate(void)
6996 if(guiApp.desktop.active)
7001 if(this == rootWindow)
7006 void Deactivate(void)
7008 ActivateEx(false, true, true, true, null, null);
7013 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
7016 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
7018 bool result = false;
7019 if(activeChild && activeChild.cycle)
7021 Window modalWindow, child = activeChild;
7022 if(!clientOnly /*&& parent.tabCycle*/)
7024 Window next = child;
7027 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
7031 if(parent && parent.CycleChildren(backward, false, true, true))
7039 next = next.cycle.prev.data;
7041 next = next.cycle.next.data;
7042 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
7047 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
7048 parent.tabCycle && parent.CycleChildren(backward, false, false))
7052 if(tabCycleOnly && !tabCycle) return false;
7059 child = child.cycle.prev.data;
7061 child = child.cycle.next.data;
7062 if(child == child.parent.activeChild)
7064 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
7067 modalWindow = child.FindModal();
7070 // Scroll the window to include the active control
7071 if(sbh && !child.style.dontScrollHorz)
7073 if(child.scrolledPos.x < 0)
7074 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
7075 else if(child.scrolledPos.x + child.size.w > clientSize.w)
7076 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
7078 if(sbv && !child.style.dontScrollVert)
7080 if(child.scrolledPos.y < 0)
7081 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
7082 else if(child.scrolledPos.y + child.size.h > clientSize.h)
7083 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
7087 child = modalWindow ? modalWindow : child;
7088 child.ActivateEx(true, true, true, true, null, null);
7089 if(child.tabCycle && child.childrenCycle.first)
7090 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7098 ConsequentialMouseMove(false);
7102 void AddResource(Resource resource)
7106 ResPtr ptr { resource = resource };
7110 // Load Graphics here if window is created already
7111 if(/*created && */display)
7113 display.Lock(false);
7114 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7115 ptr.loaded = display.displaySystem.LoadResource(resource);
7119 // Temporary hack to load font right away for listbox in dropbox ...
7120 else if(master && master.display)
7122 master.display.Lock(false);
7123 master.display.displaySystem.LoadResource(resource);
7124 master.display.Unlock();
7130 void RemoveResource(Resource resource)
7135 for(ptr = resources.first; ptr; ptr = ptr.next)
7137 if(ptr.resource == resource)
7143 // Unload Graphics here if window is created already
7144 if(/*created && */display)
7148 display.Lock(false);
7149 display.displaySystem.UnloadResource(resource, ptr.loaded);
7155 resources.Delete(ptr);
7160 void SetCaret(int x, int y, int size)
7167 if(active && !style.interim && isEnabled)
7169 if(visible || !guiApp.caretOwner)
7170 guiApp.caretOwner = size ? this : null;
7172 UpdateCaret(false, false);
7175 guiApp.interfaceDriver.SetCaret(0,0,0);
7176 UpdateCaret(false, true);
7177 guiApp.caretEnabled = false;
7180 else if(style.inactive && active)
7182 guiApp.interfaceDriver.SetCaret(0,0,0);
7183 UpdateCaret(false, true);
7184 guiApp.caretEnabled = false;
7189 void Scroll(int x, int y)
7191 bool opaque = !style.drawBehind || background.a;
7192 if(opaque && display && display.flags.scrolling)
7194 Box box = clientArea;
7195 box.left += clientStart.x;
7196 box.top += clientStart.y;
7197 box.right += clientStart.x;
7198 box.bottom += clientStart.y;
7200 //scrollExtent.Free(null);
7201 scrollExtent.AddBox(box);
7202 scrolledArea.x += x;
7203 scrolledArea.y += y;
7205 //scrollExtent.Free();
7206 //scrollExtent.AddBox(clientArea);
7207 //scrollExtent.Offset(clientStart.x, clientStart.y);
7208 //scrolledArea.x = x;
7209 //scrolledArea.y = y;
7215 rootWindow.dirty = true;
7218 void ReleaseCapture()
7220 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7222 Window oldCaptured = guiApp.windowCaptured;
7223 guiApp.windowCaptured = null;
7224 guiApp.prevWindow = null;
7227 //guiApp.Log("Released Capture\n");
7229 guiApp.interfaceDriver.SetMouseCapture(null);
7231 //oldCaptured.OnMouseCaptureLost();
7234 oldCaptured.ConsequentialMouseMove(false);
7239 private void _SetCaption(const char * format, va_list args)
7246 char caption[MAX_F_STRING];
7247 vsnprintf(caption, sizeof(caption), format, args);
7248 caption[sizeof(caption)-1] = 0;
7250 this.caption = CopyString(caption);
7255 firewatchers caption;
7259 /*deprecated*/ void SetText(const char * format, ...)
7262 va_start(args, format);
7263 _SetCaption(format, args);
7267 void SetCaption(const char * format, ...)
7270 va_start(args, format);
7271 _SetCaption(format, args);
7275 bool Grab(Bitmap bitmap, Box box, bool decorations)
7277 bool result = false;
7278 if(display || this == guiApp.desktop)
7280 Box clip = {MININT, MININT, MAXINT, MAXINT};
7286 clip.Clip(clientArea);
7288 clip.Clip(this.box);
7290 if(rootWindow != this)
7292 clip.left += absPosition.y;
7293 clip.top += absPosition.y;
7294 clip.right += absPosition.x;
7295 clip.bottom += absPosition.y;
7298 clip.left += decorations ? 0 : clientStart.x;
7299 clip.top += decorations ? 0 : clientStart.y;
7300 clip.right += decorations ? 0 : clientStart.x;
7301 clip.bottom += decorations ? 0 : clientStart.y;
7303 if(display && display.flags.flipping)
7305 rootWindow.Update(null);
7306 rootWindow.UpdateDisplay();
7313 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7314 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7318 result = display.Grab(bitmap, clip.left, clip.top,
7319 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7321 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7323 if(!bitmap.Convert(null, pixelFormat888, null))
7330 void GetMousePosition(int * x, int * y)
7332 int mouseX = 0, mouseY = 0;
7333 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7336 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7337 if(this != guiApp.desktop)
7339 mouseX -= absPosition.x + clientStart.x;
7340 mouseY -= absPosition.y + clientStart.y;
7347 DialogResult DoModal()
7349 DialogResult returnCode = 0;
7350 int terminated = terminateX;
7353 while(!destroyed && guiApp.driver != null)
7355 if(terminateX != terminated)
7357 terminated = terminateX;
7358 guiApp.desktop.Destroy(0);
7359 if(guiApp.desktop.created)
7362 //printf("Resetting terminate X to 0\n");
7368 guiApp.UpdateDisplay();
7369 if(!guiApp.ProcessInput(false))
7372 returnCode = this.returnCode;
7385 return !destroyed && guiApp.driver != null && terminateX < 2;
7388 DialogResult DoModalEnd()
7390 DialogResult returnCode = this.returnCode;
7395 // --- Window manipulation ---
7396 /*bool GetDisabled()
7398 bool disabled = this.disabled;
7400 for(window = this; (window = window.master); )
7411 // --- Mouse Manipulation ---
7412 void GetNCMousePosition(int * x, int * y)
7414 GetMousePosition(x, y);
7415 if(x) *x += clientStart.x;
7416 if(y) *y += clientStart.y;
7419 // --- Carets manipulation ---
7420 void GetCaretPosition(Point caretPos)
7422 caretPos = this.caretPos;
7425 int GetCaretSize(void)
7430 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7436 bool CloseConfirmation(bool parentClosing)
7449 if(!OnClose(parentClosing))
7452 // If you want to skip this, simply set modifiedDocument to false in OnClose
7453 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7455 DialogResult dialogRes;
7458 sprintf(message, $"Save changes to %s?", fileName);
7460 sprintf(message, $"Save changes to Untitled %d?", documentID);
7462 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7464 if(dialogRes == yes)
7466 // TOFIX: Precomp error if brackets are taken out
7467 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7469 else if(dialogRes == cancel)
7475 for(slave = slaves.first; slave; slave = slave.next)
7477 Window w = slave.data;
7478 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7486 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7489 for(child = children.first; child; child = child.next)
7490 if(child.isActiveClient && !child.CloseConfirmation(true))
7498 for(child = children.first; child; child = child.next)
7499 if(!child.isActiveClient && !child.CloseConfirmation(true))
7509 // Static methods... move them somewhere else?
7510 void ::RestoreCaret()
7512 if(guiApp.caretOwner)
7513 guiApp.caretOwner.UpdateCaret(false, false);
7516 void ::FreeMouseRange()
7518 guiApp.interfaceDriver.SetMouseRange(null, null);
7522 bool MenuFileClose(MenuItem selection, Modifiers mods)
7524 Window document = activeChild;
7526 document.Destroy(0);
7530 bool MenuFileExit(MenuItem selection, Modifiers mods)
7536 bool MenuFileSave(MenuItem selection, Modifiers mods)
7541 fileMonitor.fileName = null;
7544 if(OnSaveFile(fileName))
7546 //if(OnFileModified != Window::OnFileModified)
7549 fileMonitor.fileName = fileName;
7555 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7556 DialogResult answer = dialog.Modal();
7558 if(answer != yes) return (bool)answer;
7561 return MenuFileSaveAs(selection, mods);
7564 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7566 DialogResult result = (DialogResult)bool::true;
7567 FileDialog fileDialog = saveDialog;
7572 fileDialog = FileDialog {};
7577 fileDialog.filePath = fileName;
7580 char filePath[MAX_FILENAME];
7581 sprintf(filePath, "Untitled %d", documentID);
7582 fileDialog.filePath = filePath;
7584 fileMonitor.fileName = null;
7586 fileDialog.type = save;
7587 fileDialog.text = $"Save As";
7591 fileDialog.master = master.parent ? master : this;
7592 if(fileDialog.Modal() == ok)
7594 const char * filePath = fileDialog.filePath;
7596 if(OnSaveFile(filePath))
7599 property::fileName = filePath;
7600 NotifySaved(master, this, filePath);
7605 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7606 DialogResult answer = dialog.Modal();
7621 //if(OnFileModified != Window::OnFileModified && fileName)
7624 fileMonitor.fileName = fileName;
7628 return (bool)result; // Actually returning result from Yes/NoCancel message box
7631 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7633 Window document = activeChild;
7635 for(document = children.first; document; document = next)
7637 next = document.next;
7638 if(document.style.isDocument || document.fileName)
7639 document.MenuFileSave(selection, mods);
7644 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7648 for(document = children.first; document; document = document.next)
7649 //if(document.style.isDocument && document.state == minimized)
7650 if(document.style.isActiveClient && document.state == minimized)
7651 document.SetState(minimized, false, mods);
7655 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7657 Window document = activeChild;
7660 Window firstDocument = null;
7662 OldLink cycle = document.cycle.prev;
7667 if(child.style.isActiveClient && !child.style.hidden)
7671 firstDocument = child;
7672 if(child.state == minimized)
7673 child.SetState(minimized, false, mods);
7676 child.positionID = id++;
7677 child.SetState(normal, false, mods);
7678 child.anchor.left.type = cascade;
7681 child.normalSizeAnchor = *&child.sizeAnchor;
7682 child.normalAnchor = child.anchor;
7684 // Break the anchors for moveable/resizable windows
7685 if(child.style.fixed)
7687 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7689 (*&child.normalAnchor).left = x;
7690 (*&child.normalAnchor).top = y;
7691 (*&child.normalAnchor).right.type = none;
7692 (*&child.normalAnchor).bottom.type = none;
7693 (*&child.normalSizeAnchor).isClientW = false;
7694 (*&child.normalSizeAnchor).isClientH = false;
7695 (*&child.normalSizeAnchor).size.w = w;
7696 (*&child.normalSizeAnchor).size.h = h;
7697 child.anchored = false;
7700 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7702 child.stateAnchor = child.normalAnchor;
7703 child.stateSizeAnchor = child.normalSizeAnchor;
7705 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7706 child.Position(x, y, w, h, true, true, true, true, false, false);
7711 last = children.last;
7712 if(!child.style.stayOnTop)
7713 for(; last && last.style.stayOnTop; last = last.prev);
7714 children.Move(child, last);
7715 childrenOrder.Move(child.order, childrenOrder.last);
7717 if(cycle == document.cycle) break;
7721 firstDocument.Activate();
7726 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7733 // Close all closes all active clients, not all documents
7734 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7736 Window next, document;
7738 for(document = children.first; document; document = next)
7740 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7741 if(document.style.isActiveClient)
7742 if(!document.Destroy(0) && !document.style.hidden)
7748 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7750 if(style.hasMaximize && state != maximized)
7751 SetState(maximized, 0, 0);
7755 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7757 if(style.hasMinimize && state != minimized)
7759 SetState(minimized, 0, 0);
7760 parent.CycleChildren(false, true, false, true);
7765 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7767 MenuMoveOrSize(false, selection ? true : false);
7771 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7773 CycleChildren(false, true, false, true);
7777 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7779 CycleChildren(true, true, false, true);
7783 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7785 MenuMoveOrSize(true, true);
7789 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7792 SetState(normal, 0, 0);
7796 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7799 int64 id = selection.id;
7800 OldLink cycle = activeClient.cycle;
7802 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7805 Window sibling = cycle.data;
7806 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7814 document = cycle.data;
7815 document.Activate();
7817 //if(activeChild.state == maximized)
7818 // document.SetState(maximized, false, mods);
7819 //else if(document.state == minimized)
7820 // document.SetState(normal, false, mods);
7824 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7826 stayOnTop = !style.stayOnTop;
7830 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7832 Window document = activeChild;
7835 Window firstDocument = null;
7836 OldLink cycle = document.cycle;
7840 Window child = cycle.data;
7841 if(child.style.isActiveClient && !child.style.hidden)
7843 if(!firstDocument) firstDocument = child;
7844 if(child.state == minimized)
7845 child.SetState(minimized, false, mods);
7848 child.positionID = id++;
7849 child.SetState(normal, false, mods);
7850 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7852 child.anchor.left.type = hTiled;
7855 child.normalSizeAnchor = *&child.sizeAnchor;
7856 child.normalAnchor = child.anchor;
7858 // Break the anchors for moveable/resizable windows
7859 if(child.style.fixed)
7861 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7863 (*&child.normalAnchor).left = x;
7864 (*&child.normalAnchor).top = y;
7865 (*&child.normalAnchor).right.type = none;
7866 (*&child.normalAnchor).bottom.type = none;
7867 (*&child.normalSizeAnchor).isClientW = false;
7868 (*&child.normalSizeAnchor).isClientH = false;
7869 (*&child.normalSizeAnchor).size.w = w;
7870 (*&child.normalSizeAnchor).size.h = h;
7871 child.anchored = false;
7874 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7876 child.stateAnchor = child.normalAnchor;
7877 child.stateSizeAnchor = child.normalSizeAnchor;
7879 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7880 child.Position(x,y, w, h, true, true, true, true, false, true);
7885 if((cycle = cycle.next) == document.cycle) break;
7888 firstDocument.Activate();
7893 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7895 Window document = activeChild;
7898 Window firstDocument = null;
7900 OldLink cycle = document.cycle;
7905 //if(child.style.isDocument)
7906 if(child.style.isActiveClient && !child.style.hidden)
7908 if(!firstDocument) firstDocument = child;
7909 if(child.state == minimized)
7910 child.SetState(minimized, false, mods);
7913 child.positionID = id++;
7914 child.SetState(normal, false, mods);
7915 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7917 child.anchor.left.type = vTiled;
7920 child.normalSizeAnchor = *&child.sizeAnchor;
7921 child.normalAnchor = child.anchor;
7923 // Break the anchors for moveable/resizable windows
7924 if(child.style.fixed)
7926 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7928 (*&child.normalAnchor).left = x;
7929 (*&child.normalAnchor).top = y;
7930 (*&child.normalAnchor).right.type = none;
7931 (*&child.normalAnchor).bottom.type = none;
7932 (*&child.normalSizeAnchor).isClientW = false;
7933 (*&child.normalSizeAnchor).isClientH = false;
7934 (*&child.normalSizeAnchor).size.w = w;
7935 (*&child.normalSizeAnchor).size.h = h;
7936 child.anchored = false;
7939 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7941 child.stateAnchor = child.normalAnchor;
7942 child.stateSizeAnchor = child.normalSizeAnchor;
7944 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7945 child.Position(x,y, w, h, true, true, true, true, false, true);
7950 if((cycle = cycle.next) == document.cycle) break;
7953 firstDocument.Activate();
7958 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7960 WindowList dialog { master = this };
7961 Window document = (Window)(intptr)dialog.Modal();
7964 if(activeChild.state == maximized)
7965 document.SetState(maximized, false, mods);
7966 else if(document.state == minimized)
7967 document.SetState(normal, false, mods);
7968 document.Activate();
7974 virtual bool OnCreate(void);
7975 virtual void OnDestroy(void);
7976 virtual void OnDestroyed(void);
7977 virtual bool OnClose(bool parentClosing);
7978 virtual bool OnStateChange(WindowState state, Modifiers mods);
7979 virtual bool OnPostCreate(void);
7980 virtual bool OnMoving(int *x, int *y, int w, int h);
7981 virtual bool OnResizing(int *width, int *height);
7982 virtual void OnResize(int width, int height);
7983 virtual void OnPosition(int x, int y, int width, int height);
7984 virtual bool OnLoadGraphics(void);
7985 virtual void OnApplyGraphics(void);
7986 virtual void OnUnloadGraphics(void);
7987 virtual void OnRedraw(Surface surface);
7988 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7989 virtual void OnActivateClient(Window client, Window previous);
7990 virtual bool OnKeyDown(Key key, unichar ch);
7991 virtual bool OnKeyUp(Key key, unichar ch);
7992 virtual bool OnKeyHit(Key key, unichar ch);
7993 virtual bool OnSysKeyDown(Key key, unichar ch);
7994 virtual bool OnSysKeyUp(Key key, unichar ch);
7995 virtual bool OnSysKeyHit(Key key, unichar ch);
7996 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7997 virtual bool OnMouseLeave(Modifiers mods);
7998 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7999 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
8000 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
8001 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
8002 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
8003 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
8004 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
8005 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
8006 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
8007 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
8008 virtual bool OnMultiTouch(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods);
8009 virtual void OnMouseCaptureLost(void);
8010 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
8011 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
8012 virtual void OnDrawOverChildren(Surface surface);
8013 virtual bool OnFileModified(FileChange fileChange, const char * param);
8014 virtual bool OnSaveFile(const char * fileName);
8016 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
8017 // Note: A 'client' would refer to isActiveClient, rather than
8018 // being confined to the 'client area' (nonClient == false)
8019 virtual void OnChildAddedOrRemoved(Window child, bool removed);
8020 virtual void OnChildVisibilityToggled(Window child, bool visible);
8021 virtual void OnChildResized(Window child, int x, int y, int w, int h);
8023 // Skins Virtual Functions
8024 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
8025 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
8026 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
8031 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8032 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8033 virtual bool IsMouseMoving(int x, int y, int w, int h)
8037 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
8041 virtual void UpdateNonClient();
8042 virtual void SetBox(Box box); // This is used in the MySkin skin
8043 virtual bool IsInside(int x, int y)
8045 return box.IsPointInside({x, y});
8047 virtual bool IsOpaque()
8049 return (!style.drawBehind || background.a == 255);
8053 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
8054 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
8055 virtual void Window::NotifySaved(Window window, const char * filePath);
8060 property Window parent
8062 property_category $"Layout"
8065 if(value || guiApp.desktop)
8068 Window oldParent = parent;
8069 Anchor anchor = this.anchor;
8071 if(value && value.IsDescendantOf(this)) return;
8072 if(value && value == this)
8074 if(!value) value = guiApp.desktop;
8076 if(value == oldParent) return;
8078 if(!master || (master == this.parent && master == guiApp.desktop))
8079 property::master = value;
8083 parent.children.Remove(this);
8087 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8088 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
8089 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8090 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8094 last = value.children.last;
8096 if(style.isDocument)
8099 parent.numDocuments--;
8100 documentID = value.GetDocumentID();
8103 if(style.isActiveClient && !style.hidden)
8105 if(parent && parent != guiApp.desktop && !(style.hidden))
8107 if(state == minimized) parent.numIcons--;
8108 parent.numPositions--;
8112 if(!style.stayOnTop)
8113 for(; last && last.style.stayOnTop; last = last.prev);
8115 value.children.Insert(last, this);
8117 // *** NEW HERE: ***
8119 parent.childrenCycle.Delete(cycle);
8121 parent.childrenOrder.Delete(order);
8124 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8125 // Should something else be done?
8126 if(parent && parent.activeChild == this)
8127 parent.activeChild = null;
8128 if(parent && parent.activeClient == this)
8129 parent.activeClient = null;
8135 int x = position.x, y = position.y, w = size.w, h = size.h;
8139 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8140 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8142 vpw = value.clientSize.w;
8143 vph = value.clientSize.h;
8149 else if(style.fixed)
8151 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8152 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8155 anchor = this.anchor;
8157 if(anchor.left.type == offset) anchor.left.distance = x;
8158 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8159 if(anchor.top.type == offset) anchor.top.distance = y;
8160 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8161 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8162 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8163 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8164 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8165 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8166 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8168 if(!anchor.left.type && !anchor.right.type)
8170 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8171 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8173 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8174 if(!anchor.top.type && !anchor.bottom.type)
8176 anchor.vert.distance = (y + h / 2) - (vph / 2);
8177 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8179 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8182 parent.OnChildAddedOrRemoved(this, false);
8188 parent.childrenCycle.Insert(
8189 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8190 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8192 cycle = OldLink { data = this });
8193 parent.childrenOrder.Insert(
8194 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8195 order = OldLink { data = this });
8198 if(!style.hidden && style.isActiveClient)
8200 positionID = parent.GetPositionID(this);
8201 parent.numPositions++;
8202 if(state == minimized) parent.numIcons--;
8205 // *** FONT INHERITANCE ***
8206 if(!setFont && oldParent)
8207 stopwatching(oldParent, font);
8211 RemoveResource(systemFont);
8214 // TESTING WITH WATCHERS:
8215 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8216 // usedFont = setFont ? setFont : (systemFont);
8220 if(guiApp.currentSkin)
8222 systemFont = guiApp.currentSkin.SystemFont();
8225 usedFont = systemFont;
8226 AddResource(systemFont);
8234 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8243 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8245 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8246 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8249 UnloadGraphics(false);
8252 LoadGraphics(false, false);
8255 if(value.rootWindow != rootWindow)
8256 DisplayModeChanged();
8260 scrolledPos.x = MININT; // Prevent parent update
8262 bool anchored = this.anchored;
8263 property::anchor = anchor;
8264 this.anchored = anchored;
8269 if(guiApp.currentSkin)
8270 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8272 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8273 Position(x, y, w, h, true, true, true, true, false, true);
8278 // else parent = value;
8280 oldParent.OnChildAddedOrRemoved(this, true);
8283 get { return parent; }
8286 property Window master
8288 property_category $"Behavior"
8291 //if(this == value) return;
8292 if(value && value.IsSlaveOf(this)) return;
8298 OldLink slaveHolder;
8299 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8300 if(slaveHolder.data == this)
8302 master.slaves.Delete(slaveHolder);
8309 value.slaves.Add(OldLink { data = this });
8314 master.hotKeys.Remove(hotKey);
8315 value.hotKeys.Add(hotKey);
8318 if(master && master.defaultControl == this)
8319 master.defaultControl = null;
8321 if(style.isDefault && !value.defaultControl)
8322 value.defaultControl = this;
8327 get { return master ? master : parent; }
8330 property const char * caption
8332 property_category $"Appearance"
8339 caption = new char[strlen(value)+1];
8341 strcpy(caption, value);
8346 get { return caption; }
8351 property_category $"Behavior"
8360 master.hotKeys.Add(hotKey = HotKeySlot { });
8364 hotKey.window = this;
8369 master.hotKeys.Delete(hotKey);
8374 get { return hotKey ? hotKey.key : 0; }
8377 property Color background
8379 property_category $"Appearance"
8382 background.color = value;
8387 if(this == rootWindow)
8388 guiApp.interfaceDriver.SetRootWindowColor(this);
8391 get { return background.color; }
8394 property Percentage opacity
8396 property_category $"Appearance"
8399 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8400 drawBehind = (background.a == 255) ? false : true;
8402 get { return background.a / 255.0f; }
8405 property Color foreground
8407 property_category $"Appearance"
8415 get { return foreground; }
8418 property BorderStyle borderStyle
8420 property_category $"Appearance"
8423 if(!((BorderBits)value).fixed)
8425 style.hasClose = false;
8426 style.hasMaximize = false;
8427 style.hasMinimize = false;
8428 nativeDecorations = false;
8430 style.borderBits = value;
8434 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8436 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8437 Position(x, y, w, h, true, true, true, true, false, true);
8438 CreateSystemChildren();
8441 get { return (BorderStyle)style.borderBits; }
8444 property Size minClientSize
8446 property_category $"Layout"
8447 set { minSize = value; }
8448 get { value = minSize; }
8451 property Size maxClientSize
8453 property_category $"Layout"
8454 set { maxSize = value; }
8455 get { value = maxSize; }
8458 property bool hasMaximize
8460 property_category $"Window Style"
8463 style.hasMaximize = value;
8464 if(value) { style.fixed = true; style.contour = true; }
8468 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8470 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8471 Position(x, y, w, h, true, true, true, true, false, true);
8473 CreateSystemChildren();
8476 get { return style.hasMaximize; }
8479 property bool hasMinimize
8481 property_category $"Window Style"
8484 style.hasMinimize = value;
8485 if(value) { style.fixed = true; style.contour = true; }
8489 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8491 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8492 Position(x, y, w, h, true, true, true, true, false, true);
8494 CreateSystemChildren();
8497 get { return style.hasMinimize; }
8500 property bool hasClose
8502 property_category $"Window Style"
8505 style.hasClose = value;
8506 if(value) { style.fixed = true; style.contour = true; }
8510 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8511 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8512 Position(x, y, w, h, true, true, true, true, false, true);
8513 CreateSystemChildren();
8516 get { return style.hasClose; }
8519 property bool nonClient
8521 property_category $"Layout"
8524 style.nonClient = value;
8526 style.stayOnTop = true;
8528 get { return style.nonClient; }
8531 property bool inactive
8533 property_category $"Behavior"
8538 // *** NEW HERE: ***
8542 parent.childrenCycle.Delete(cycle);
8544 parent.childrenOrder.Delete(order);
8551 active = false; // true;
8552 if(parent.activeChild == this)
8553 parent.activeChild = null;
8554 if(parent.activeClient == this)
8555 parent.activeClient = null;
8564 parent.childrenCycle.Insert(
8565 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8566 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8568 cycle = OldLink { data = this });
8570 parent.childrenOrder.Insert(
8571 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8572 order = OldLink { data = this });
8575 style.inactive = value;
8577 get { return style.inactive; }
8580 property bool clickThrough
8582 property_category $"Behavior"
8583 set { style.clickThrough = value; }
8584 get { return style.clickThrough; }
8587 property bool isRemote
8589 property_category $"Behavior"
8590 set { style.isRemote = value; }
8591 get { return style.isRemote; }
8594 property bool noCycle
8596 property_category $"Behavior"
8597 set { style.noCycle = value; }
8598 get { return style.noCycle; }
8601 property bool isModal
8603 property_category $"Behavior"
8604 set { style.modal = value; }
8605 get { return style.modal; }
8608 property bool interim
8610 property_category $"Behavior"
8611 set { style.interim = value; }
8612 get { return style.interim; }
8615 property bool tabCycle
8617 property_category $"Behavior"
8618 set { style.tabCycle = value; }
8619 get { return style.tabCycle; }
8622 property bool isDefault
8624 property_category $"Behavior"
8632 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8633 if(sibling != this && sibling.style.isDefault)
8634 sibling.style.isDefault = false;*/
8635 if(master.defaultControl)
8636 master.defaultControl.style.isDefault = false;
8637 master.defaultControl = this;
8639 else if(master.defaultControl == this)
8640 master.defaultControl = null;
8644 style.isDefault = value;
8646 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8648 get { return style.isDefault; }
8651 property bool drawBehind
8653 property_category $"Window Style"
8654 set { style.drawBehind = value; }
8655 get { return style.drawBehind; }
8658 property bool hasMenuBar
8660 property_category $"Window Style"
8670 if(created && !menuBar)
8677 anchor = Anchor { top = 23, left = 1, right = 1 },
8679 inactive = true, nonClient = true
8684 else if(created && menuBar)
8689 style.hasMenuBar = value;
8691 get { return style.hasMenuBar; }
8694 property bool hasStatusBar
8696 property_category $"Window Style"
8703 statusBar = StatusBar { this };
8711 style.hasStatusBar = value;
8713 get { return style.hasStatusBar; }
8715 property bool stayOnTop
8717 property_category $"Window Style"
8722 if(created && !style.stayOnTop)
8724 if(rootWindow == this)
8725 guiApp.interfaceDriver.OrderRootWindow(this, true);
8726 else if(parent.children.last != this)
8728 parent.children.Move(this, parent.children.last);
8732 style.stayOnTop = true;
8736 if(created && style.stayOnTop)
8738 if(rootWindow == this)
8739 guiApp.interfaceDriver.OrderRootWindow(this, false);
8746 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8747 order && ((Window)order.data).style.stayOnTop;
8748 order = (order == parent.childrenOrder.first) ? null : order.prev);
8749 last = order ? order.data : null;
8753 for(last = parent.children.last;
8754 last && last.style.stayOnTop;
8758 parent.children.Move(this, last);
8762 style.stayOnTop = false;
8765 get { return style.stayOnTop; }
8770 property_category $"Window Style"
8780 if(menuBar && !value)
8787 if(!menuBar && style.hasMenuBar && value)
8791 this, menu = value, isMenuBar = true,
8792 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8793 inactive = true, nonClient = true
8797 UpdateActiveDocument(null);
8800 get { return menu; }
8803 property FontResource font
8805 property_category $"Appearance"
8807 isset { return setFont ? true : false; }
8812 if(value && !setFont) { stopwatching(parent, font); }
8813 else if(!value && setFont)
8819 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8828 RemoveResource(setFont);
8833 RemoveResource(systemFont);
8840 AddResource(setFont);
8843 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8846 systemFont = guiApp.currentSkin.SystemFont();
8848 usedFont = systemFont;
8849 AddResource(systemFont);
8857 get { return usedFont; }
8860 property SizeAnchor sizeAnchor
8862 property_category $"Layout"
8865 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8866 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8867 sizeAnchor.isClientW != sizeAnchor.isClientH;
8874 normalSizeAnchor = sizeAnchor;
8876 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8878 stateAnchor = normalAnchor;
8879 stateSizeAnchor = normalSizeAnchor;
8881 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8882 Position(x,y, w, h, true, true, true, true, false, true);
8889 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8890 sizeAnchor.isClientW,
8891 sizeAnchor.isClientH
8898 property_category $"Layout"
8901 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8902 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8903 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8909 sizeAnchor.isClientW = false;
8910 sizeAnchor.isClientH = false;
8911 sizeAnchor.size = value;
8913 normalSizeAnchor = sizeAnchor;
8915 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8917 stateAnchor = normalAnchor;
8918 stateSizeAnchor = normalSizeAnchor;
8920 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8921 Position(x, y, w, h, true, true, true, true, false, true);
8922 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8925 get { value = size; }
8928 property Size clientSize
8930 property_category $"Layout"
8933 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8934 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8935 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8940 sizeAnchor.isClientW = true;
8941 sizeAnchor.isClientH = true;
8942 sizeAnchor.size = value;
8944 normalSizeAnchor = sizeAnchor;
8946 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8948 stateAnchor = normalAnchor;
8949 stateSizeAnchor = normalSizeAnchor;
8951 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8952 Position(x,y, w, h, true, true, true, true, false, true);
8953 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8956 get { value = this ? clientSize : { 0, 0 }; }
8959 property Size initSize { get { value = sizeAnchor.size; } };
8961 property Anchor anchor
8963 property_category $"Layout"
8964 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8970 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8972 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8973 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8975 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8977 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8978 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8982 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8984 anchor.left.distance = 0;
8985 anchor.horz.type = 0;
8987 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8989 anchor.top.distance = 0;
8990 anchor.vert.type = 0;
8999 normalAnchor = anchor;
9001 // Break the anchors for moveable/resizable windows
9002 /*if(style.fixed ) //&& value.left.type == cascade)
9004 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
9006 this.anchor = normalAnchor = Anchor { left = x, top = y };
9007 normalSizeAnchor = SizeAnchor { { w, h } };
9010 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9012 stateAnchor = normalAnchor;
9013 stateSizeAnchor = normalSizeAnchor;
9015 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9016 Position(x, y, w, h, true, true, true, true, false, true);
9025 get { value = this ? anchor : Anchor { }; }
9028 property Point position
9030 property_category $"Layout"
9033 if(value == null) return;
9035 anchor.left = value.x;
9036 anchor.top = value.y;
9037 anchor.right.type = none;
9038 anchor.bottom.type = none;
9043 normalAnchor = anchor;
9045 // Break the anchors for moveable/resizable windows
9049 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9051 normalAnchor.left = x;
9052 normalAnchor.top = y;
9053 normalAnchor.right.type = none;
9054 normalAnchor.bottom.type = none;
9055 normalSizeAnchor.size.width = w;
9056 normalSizeAnchor.size.height = h;
9060 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9062 stateAnchor = normalAnchor;
9063 stateSizeAnchor = normalSizeAnchor;
9065 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9066 Position(x,y, w, h, true, true, true, true, false, true);
9070 get { value = position; }
9073 property bool disabled
9075 property_category $"Behavior"
9078 if(this && disabled != value)
9085 get { return (bool)disabled; }
9088 property bool isEnabled
9093 for(parent = this; parent; parent = parent.parent)
9100 property WindowState state
9102 property_category $"Behavior"
9103 set { SetState(value, false, 0); }
9104 get { return this ? state : 0; }
9107 property bool visible
9109 property_category $"Behavior"
9112 if(this && !value && !style.hidden && parent)
9114 bool wasActiveChild = parent.activeChild == this;
9115 Window client = null;
9117 style.hidden = true;
9118 if(style.isActiveClient)
9120 parent.numPositions--;
9121 if(state == minimized) parent.numIcons--;
9126 OldLink prevOrder = null;
9128 if(rootWindow == this)
9129 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9132 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9135 box.left -= parent.clientStart.x;
9136 box.top -= parent.clientStart.y;
9137 box.right -= parent.clientStart.x;
9138 box.bottom -= parent.clientStart.y;
9142 if(_isModal && master && master.modalSlave == this)
9143 master.modalSlave = null;
9147 OldLink tmpPrev = order.prev;
9148 client = tmpPrev ? tmpPrev.data : null;
9149 if(client && !client.style.hidden && !client.destroyed && client.created)
9150 prevOrder = tmpPrev;
9153 client = tmpPrev ? tmpPrev.data : null;
9154 if(client == this) { client = null; break; }
9155 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9157 tmpPrev = client.order.prev;
9162 prevOrder = tmpPrev;
9167 // If this window can be an active client, make sure the next window we activate can also be one
9168 if(!style.nonClient && style.isActiveClient)
9170 tmpPrev = prevOrder;
9173 client = tmpPrev ? tmpPrev.data : null;
9174 if(client == this) { client = null; break; }
9175 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9177 tmpPrev = client.order.prev;
9182 prevOrder = tmpPrev;
9186 if(client && client.style.hidden) client = null;
9190 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9192 if(order && prevOrder && prevOrder.data != this)
9193 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9195 ActivateEx(false, false, false, true, null, null);
9197 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9198 if(parent.activeClient == this)
9200 parent.activeClient = null;
9201 parent.UpdateActiveDocument(null);
9204 else if(parent.activeClient == this)
9206 parent.activeClient = client;
9207 parent.UpdateActiveDocument(this);
9210 // *** Not doing this anymore ***
9213 parent.childrenCycle.Delete(cycle);
9215 parent.childrenOrder.Delete(order);
9220 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9225 else if(this && value && style.hidden)
9227 style.hidden = false;
9230 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9231 if(rootWindow == this)
9232 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9234 if(_isModal && master)
9235 master.modalSlave = this;
9237 if(style.isActiveClient)
9239 positionID = parent.GetPositionID(this);
9240 parent.numPositions++;
9241 if(state == minimized) parent.numIcons++;
9244 // *** NOT DOING THIS ANYMORE ***
9246 if(!(style.inactive))
9248 if(!(style.noCycle))
9250 cycle = parent.childrenCycle.AddAfter(
9251 (parent.activeChild && parent.activeChild.cycle) ?
9252 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9255 order = parent.childrenOrder.AddAfter(
9256 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9263 if(true || !parent.activeChild)
9264 ActivateEx(true, false, true, true, null, null);
9266 if(creationActivation == activate && guiApp.desktop.active)
9267 ActivateEx(true, false, true, true, null, null);
9268 else if((creationActivation == activate || creationActivation == flash) && !object)
9271 if(this == rootWindow)
9275 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9279 ConsequentialMouseMove(false);
9285 style.hidden = !value;
9288 get { return (style.hidden || !setVisible) ? false : true; }
9291 property bool isDocument
9293 property_category $"Document"
9294 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9295 get { return style.isDocument; }
9298 property bool mergeMenus
9300 property_category $"Window Style"
9301 set { mergeMenus = value; }
9302 get { return (bool)mergeMenus; }
9305 property bool hasHorzScroll
9307 property_category $"Window Style"
9312 if(!style.hasHorzScroll && created)
9314 CreateSystemChildren();
9315 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9318 else if(style.hasHorzScroll)
9322 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9324 style.hasHorzScroll = value;
9327 get { return style.hasHorzScroll; }
9330 property bool hasVertScroll
9332 property_category $"Window Style"
9337 if(!style.hasVertScroll && created)
9339 style.hasVertScroll = true;
9340 CreateSystemChildren();
9341 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9344 else if(style.hasVertScroll)
9348 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9350 style.hasVertScroll = value;
9352 get { return style.hasVertScroll; }
9355 property bool dontHideScroll
9357 property_category $"Behavior"
9360 scrollFlags.dontHide = value;
9363 //UpdateScrollBars(true, true);
9364 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9368 // UpdateScrollBars(true, true);
9369 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9372 get { return scrollFlags.dontHide; }
9375 property bool dontScrollVert
9377 property_category $"Behavior"
9378 set { style.dontScrollVert = value; }
9379 get { return style.dontScrollVert; }
9381 property bool dontScrollHorz
9383 property_category $"Behavior"
9384 set { style.dontScrollHorz = value; }
9385 get { return style.dontScrollHorz; }
9388 property bool snapVertScroll
9390 property_category $"Behavior"
9393 scrollFlags.snapY = value;
9394 if(sbv) sbv.snap = value;
9396 get { return scrollFlags.snapY; }
9398 property bool snapHorzScroll
9400 property_category $"Behavior"
9403 scrollFlags.snapX = value;
9404 if(sbh) sbh.snap = value;
9406 get { return scrollFlags.snapX; }
9409 property Point scroll
9411 property_category $"Behavior"
9412 set { if(this) SetScrollPosition(value.x, value.y); }
9413 get { value = scroll; }
9416 property bool modifyVirtualArea
9418 property_category $"Behavior"
9419 set { modifyVirtArea = value; }
9420 get { return (bool)modifyVirtArea; }
9423 property bool dontAutoScrollArea
9425 property_category $"Behavior"
9426 // Activating a child control out of view will automatically scroll to make it in view
9427 set { noAutoScrollArea = value; }
9428 get { return (bool)noAutoScrollArea; }
9431 property const char * fileName
9433 property_category $"Document"
9438 if(menu && ((!fileName && value) || (fileName && !value)))
9440 MenuItem item = menu.FindItem(MenuFileSave, 0);
9441 if(item) item.disabled = !modifiedDocument && value;
9446 if(value && value[0])
9447 fileName = CopyString(value);
9449 if(parent && this == parent.activeClient)
9450 parent.UpdateActiveDocument(null);
9454 // if(style.isDocument)
9456 fileMonitor.fileName = value;
9458 get { return fileName; }
9463 property_category $"Data"
9468 property bool modifiedDocument
9470 property_category $"Document"
9473 if(style.isDocument || fileName)
9477 MenuItem item = menu.FindItem(MenuFileSave, 0);
9478 if(item) item.disabled = !value && fileName;
9482 if(modifiedDocument != value)
9484 modifiedDocument = value;
9485 if(style.isDocument || fileName)
9489 get { return (bool)modifiedDocument; }
9492 property bool showInTaskBar
9494 property_category $"Window Style"
9497 style.showInTaskBar = value;
9498 #if defined(__WIN32__)
9499 Win32UpdateStyle(this);
9502 get { return style.showInTaskBar; }
9504 property FileDialog saveDialog { set { saveDialog = value; } };
9505 property bool isActiveClient
9507 property_category $"Behavior"
9510 if(parent && style.isActiveClient != value && !style.hidden)
9514 if(state == minimized) parent.numIcons++;
9515 parent.numPositions++;
9519 if(state == minimized) parent.numIcons--;
9520 parent.numPositions--;
9523 style.isActiveClient = value;
9525 get { return style.isActiveClient; }
9528 property Cursor cursor
9530 property_category $"Appearance"
9534 SelectMouseCursor();
9536 get { return cursor; }
9539 //#if !defined(ECERE_VANILLA)
9540 property const char * name
9542 property_category $"Design"
9545 return (this && object) ? object.name : null;
9550 activeDesigner.RenameObject(object, value);
9554 property const char * displayDriver
9556 property_category $"Behavior"
9559 dispDriver = GetDisplayDriver(value);
9560 //DisplayModeChanged();
9564 return dispDriver ? dispDriver.name : null;
9568 // RUNTIME PROPERTIES
9569 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9570 property Size scrollArea
9572 property_category $"Behavior"
9576 SetScrollArea(value.w, value.h, false);
9578 SetScrollArea(0,0, true);
9580 get { value = scrollArea; }
9583 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9588 property_category $"Layout"
9589 set { if(this) is3D = value; }
9590 get { return (bool)is3D; }
9593 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9595 // Will be merged with font later
9596 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9597 property Point clientStart { get { value = clientStart; } };
9598 property Point absPosition { get { value = absPosition; } };
9599 property Anchor normalAnchor { get { value = normalAnchor; } };
9600 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9601 property bool active { get { return (bool)active; } };
9602 property bool created { get { return (bool)created; } };
9603 property bool destroyed { get { return (bool)destroyed; } };
9604 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9605 property Window firstChild { get { return children.first; } };
9606 property Window lastChild { get { return children.last; } };
9607 property Window activeClient { get { return activeClient; } };
9608 property Window activeChild { get { return activeChild; } };
9609 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9610 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9611 property ScrollBar horzScroll { get { return sbh; } };
9612 property ScrollBar vertScroll { get { return sbv; } };
9613 property StatusBar statusBar { get { return statusBar; } };
9614 property Window rootWindow { get { return rootWindow; } };
9615 property bool closing { get { return (bool)closing; } set { closing = value; } };
9616 property int documentID { get { return documentID; } };
9617 property Window previous { get { return prev; } }
9618 property Window next { get { return next; } }
9619 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9620 property PopupMenu menuBar { get { return menuBar; } }
9621 property ScrollBar sbv { get { return sbv; } }
9622 property ScrollBar sbh { get { return sbh; } }
9623 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9624 property void * systemHandle { get { return windowHandle; } }
9625 property Button minimizeButton { get { return sysButtons[0]; } };
9626 property Button maximizeButton { get { return sysButtons[1]; } };
9627 property Button closeButton { get { return sysButtons[2]; } };
9628 property BitmapResource icon
9630 get { return icon; }
9634 if(icon) incref icon;
9636 guiApp.interfaceDriver.SetIcon(this, value);
9639 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9640 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9641 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9642 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9643 property bool nativeDecorations
9645 get { return (bool)nativeDecorations; }
9646 set { nativeDecorations = value; }
9647 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9650 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9651 bool result = false;
9652 if(nativeDecorations)
9654 if(rootWindow == this)
9658 if(formDesigner && activeDesigner)
9660 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9661 Window form = cd ? cd.form : null;
9662 if(form && parent == form.parent)
9667 return result != style.fixed;
9671 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9673 property const char * text
9675 property_category $"Deprecated"
9677 set { property::caption = value; }
9678 get { return property::caption; }
9684 WindowBits style; // Window Style
9685 char * caption; // Name / Caption
9686 Window parent; // Parent window
9687 OldList children; // List of children in Z order
9688 Window activeChild; // Child window having focus
9689 Window activeClient;
9690 Window previousActive; // Child active prior to activating the default child
9691 Window master; // Window owning and receiving notifications concerning this window
9692 OldList slaves; // List of windows belonging to this window
9693 Display display; // Display this window is drawn into
9695 Point position; // Position in parent window client area
9696 Point absPosition; // Absolute position
9697 Point clientStart; // Client area position from (0,0) in this window
9699 Size clientSize; // Client area size
9700 Size scrollArea; // Virtual Scroll area size
9701 Size reqScrollArea; // Requested virtual area size
9702 Point scroll; // Virtual area scrolling position
9703 ScrollBar sbh, sbv; // Scrollbar window handles
9704 Cursor cursor; // Mouse cursor used for this window
9707 StatusBar statusBar;
9708 Button sysButtons[3];
9710 Box clientArea; // Client Area box clipped to parent
9712 HotKeySlot hotKey; // HotKey for this window
9716 ScrollFlags scrollFlags;// Window Scrollbar Flags
9717 int64 id; // Control ID
9719 ColorAlpha background; // Background color used to draw the window area
9721 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9722 OldList childrenCycle; // Cycling order
9723 OldLink cycle; // Element of parent's cycling order
9724 OldList childrenOrder; // Circular Z-Order
9725 OldLink order; // Element of parent's circular Z-Order
9726 Window modalSlave; // Slave window blocking this window's interaction
9728 Window rootWindow; // Topmost system managed window
9729 void * windowHandle; // System window handle
9731 DialogResult returnCode;// Return code for modal windows
9733 Point sbStep; // Scrollbar line scrolling steps
9736 SizeAnchor stateSizeAnchor;
9738 Anchor normalAnchor;
9739 SizeAnchor normalSizeAnchor;
9741 Size skinMinSize; // Minimal window size based on style
9742 Point scrolledPos; // Scrolled position
9743 Box box; // Window box clipped to parent
9744 Box * against; // What to clip the box to
9746 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9747 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9748 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9749 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9750 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9751 Point scrolledArea; // Distance to scroll area by
9752 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9754 OldList hotKeys; // List of the hotkeys of all children
9755 Window defaultControl; // Default child control
9759 ColorAlpha * palette; // Color palette used for this window
9761 int caretSize; // Size of caret, non zero if a caret is present
9762 Point caretPos; // Caret position
9764 void * systemParent; // Parent System Window for embedded windows
9771 WindowState lastState;
9773 FileMonitor fileMonitor;
9775 FontResource setFont, systemFont;
9776 FontResource usedFont;
9777 FontResource captionFont;
9779 FileDialog saveDialog;
9781 SizeAnchor sizeAnchor;
9783 // FormDesigner data
9786 Extent * tempExtents; //[4];
9787 BitmapResource icon;
9789 CreationActivationOption creationActivation;
9792 bool active:1; // true if window and ancestors are active
9793 bool acquiredInput:1; // true if the window is processing state based input
9794 bool modifiedDocument:1;
9795 bool disabled:1; // true if window cannot interact
9796 bool isForegroundWindow:1;// true while a root window is being activated
9797 bool visible:1; // Visibility flag
9798 bool destroyed:1; // true if window is being destroyed
9799 bool anchored:1; // true if this window is repositioned when the parent resizes
9800 bool dirty:1; // Flag set to true if any descendant must be redrawn
9806 bool modifyVirtArea:1;
9807 bool noAutoScrollArea:1;
9810 bool setVisible:1; // FOR FORM DESIGNER
9816 bool useSharedMemory:1;
9819 bool nativeDecorations:1;
9820 bool manageDisplay:1;
9821 bool formDesigner:1; // True if we this is running in the form editor
9822 bool requireRemaximize:1;
9823 bool noConsequential:1;
9826 // Checks used internally for them not to take effect in FormDesigner
9827 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9828 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9830 WindowController controller;
9832 public property WindowController controller
9834 get { return controller; }
9838 controller.setWindow(null);
9844 controller.setWindow(this);
9849 public property bool noConsequential
9851 set { noConsequential = value; }
9852 get { return noConsequential; }
9856 public class CommonControl : Window
9858 // creationActivation = doNothing;
9861 public property const String toolTip
9863 property_category $"Appearance"
9866 if(created) CommonControl::OnDestroy();
9868 toolTip = value ? ToolTip { tip = value; } : null;
9870 if(created) CommonControl::OnCreate();
9872 get { return toolTip ? toolTip.tip : null; }
9878 // (Very) Ugly work around for the fact that the parent watcher
9879 // won't fire when it's already been disconnected...
9880 eInstance_FireSelfWatchers(toolTip,
9881 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9887 toolTip.parent = this;
9896 public class Percentage : float
9898 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9902 sprintf(string, "%.2f", this);
9903 c = strlen(string)-1;
9906 if(string[c] != '0')
9907 last = Max(last, c);
9908 if(string[c] == '.')
9921 public void ApplySkin(Class c, const char * name, void ** vTbl)
9923 char className[1024];
9928 subclass(Window) wc = (subclass(Window))c;
9929 subclass(Window) base = (subclass(Window))c.base;
9931 sprintf(className, "%sSkin_%s", name, c.name);
9932 wc.pureVTbl = c._vTbl;
9933 c._vTbl = new void *[c.vTblSize];
9934 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9935 sc = eSystem_FindClass(c.module.application, className);
9939 for(m = 0; m < c.base.vTblSize; m++)
9941 if(c._vTbl[m] == base.pureVTbl[m])
9942 c._vTbl[m] = vTbl[m];
9947 for(m = 0; m < c.vTblSize; m++)
9949 if(sc._vTbl[m] != wc.pureVTbl[m])
9950 c._vTbl[m] = sc._vTbl[m];
9954 for(d = c.derivatives.first; d; d = d.next)
9956 ApplySkin(d.data, name, c._vTbl);
9960 public void UnapplySkin(Class c)
9962 subclass(Window) wc = (subclass(Window))c;
9965 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9968 c._vTbl = wc.pureVTbl;
9972 for(d = c.derivatives.first; d; d = d.next)
9974 UnapplySkin(d.data);
9978 void CheckFontIntegrity(Window window)
9983 if(window.usedFont && window.usedFont.font == 0xecececec)
9985 FontResource uf = window.usedFont;
9986 char * className = window._class.name;
9987 char * text = window.text;
9990 for(c = window.firstChild; c; c = c.next)
9991 CheckFontIntegrity(c);
9995 public class ControllableWindow : Window
9997 /*WindowController controller;
9998 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9999 ~ControllableWindow() { delete controller; }*/
10002 class WindowControllerInterface : ControllableWindow
10004 bool OnKeyDown(Key key, unichar ch)
10006 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
10009 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
10011 result = onKeyDown(controller.window, key, ch);
10016 bool OnKeyUp(Key key, unichar ch)
10018 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
10021 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
10023 result = onKeyUp(controller.window, key, ch);
10028 bool OnKeyHit(Key key, unichar ch)
10030 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
10033 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
10035 result = onKeyHit(controller.window, key, ch);
10040 bool OnMouseMove(int x, int y, Modifiers mods)
10042 bool result = controller.OnMouseMove ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods) : true;
10045 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
10047 result = onMouseMove(controller.window, x, y, mods);
10052 bool OnLeftButtonDown(int x, int y, Modifiers mods)
10054 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10057 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
10058 if(onLeftButtonDown)
10059 result = onLeftButtonDown(controller.window, x, y, mods);
10064 bool OnLeftButtonUp(int x, int y, Modifiers mods)
10066 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10069 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
10071 result = onLeftButtonUp(controller.window, x, y, mods);
10076 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
10078 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10081 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
10082 if(onLeftDoubleClick)
10083 result = onLeftDoubleClick(controller.window, x, y, mods);
10088 bool OnRightButtonDown(int x, int y, Modifiers mods)
10090 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10093 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
10094 if(onRightButtonDown)
10095 result = onRightButtonDown(controller.window, x, y, mods);
10100 bool OnRightButtonUp(int x, int y, Modifiers mods)
10102 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10105 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
10106 if(onRightButtonUp)
10107 result = onRightButtonUp(controller.window, x, y, mods);
10112 bool OnRightDoubleClick(int x, int y, Modifiers mods)
10114 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10117 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
10118 if(onRightDoubleClick)
10119 result = onRightDoubleClick(controller.window, x, y, mods);
10124 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10126 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10129 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10130 if(onMiddleButtonDown)
10131 result = onMiddleButtonDown(controller.window, x, y, mods);
10136 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10138 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10141 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10142 if(onMiddleButtonUp)
10143 result = onMiddleButtonUp(controller.window, x, y, mods);
10148 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10150 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10153 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10154 if(onMiddleDoubleClick)
10155 onMiddleDoubleClick(controller.window, x, y, mods);
10160 bool OnMultiTouch(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods)
10162 bool result = controller.OnMultiTouch ? ((bool(*)(Window, WindowController, TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers))(void *)controller.OnMultiTouch)((Window)controller.controlled, controller, event, infos, mods) : true;
10165 bool(* onMultiTouch)(Window, TouchPointerEvent, Array<TouchPointerInfo>, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMultiTouch];
10167 onMultiTouch(controller.window, event, infos, mods);
10172 void OnResize(int width, int height)
10174 if(controller.OnResize)
10175 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10177 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10179 onResize(controller.window, width, height);
10183 void OnRedraw(Surface surface)
10185 if(controller.OnRedraw)
10186 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10188 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10190 onRedraw(controller.window, surface);
10196 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10199 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10201 result = onCreate(controller.window);
10206 bool OnLoadGraphics()
10208 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10211 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10213 result = onLoadGraphics(controller.window);
10218 void OnUnloadGraphics()
10220 if(controller.OnUnloadGraphics)
10221 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10223 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10224 if(onUnloadGraphics)
10225 onUnloadGraphics(controller.window);
10230 public class WindowController<class V>
10232 void setWindow(Window value)
10234 uint size = class(Window).vTblSize;
10238 windowVTbl = new void *[size];
10239 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10240 if(value._vTbl == value._class._vTbl)
10242 value._vTbl = new void *[value._class.vTblSize];
10243 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10247 for(c = 0; c < size; c++)
10249 void * function = class(WindowControllerInterface)._vTbl[c];
10250 if(function && function != DefaultFunction)
10251 value._vTbl[c] = function;
10253 value._vTbl[c] = windowVTbl[c];
10259 memcpy(window._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10265 property Window window
10267 get { return window; }
10269 property V controlled
10271 set { controlled = value; }
10272 get { return controlled; }
10274 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10275 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10276 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10277 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10278 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10279 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10280 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10281 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10282 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10283 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10284 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10285 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10286 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10287 virtual bool V::OnMultiTouch(WindowController controller, TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods);
10288 virtual void V::OnResize(WindowController controller, int width, int height);
10289 virtual void V::OnRedraw(WindowController controller, Surface surface);
10290 virtual bool V::OnCreate(WindowController controller);
10291 virtual bool V::OnLoadGraphics(WindowController controller);
10292 virtual void V::OnUnloadGraphics(WindowController controller);
10295 public int (** windowVTbl)();
10299 ~WindowController()