7 import "GuiApplication"
28 #if defined(__WIN32__)
29 import "Win32Interface"
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
36 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
45 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
47 define skinMenuHeight = 40;
48 define statusBarHeight = 30;
50 define skinMenuHeight = 25;
51 define statusBarHeight = 18;
54 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
56 public enum DialogResult : int64 { cancel, yes, no, ok };
58 public class MouseButtons
61 bool left:1, right:1, middle:1;
64 public struct SizeAnchor
67 bool isClientW, isClientH;
72 #define SNAPDOWN(x, d) \
75 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
78 #define SNAPUP(x, d) \
81 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
84 /*static */define MAX_DIRTY_BACK = 10;
86 /////////////////////////////////////////////////////////////////////////////
87 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
88 /////////////////////////////////////////////////////////////////////////////
90 #define ACCESS_ITEM(l, id) \
93 #define FASTLIST_LOOP(l, v) \
94 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
96 #define FASTLIST_LOOPN(l, v, n) \
97 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
100 #define ACCESS_ITEM(l, id) \
101 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
103 #define FASTLIST_LOOP(l, v) \
104 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
106 #define FASTLIST_LOOPN(l, v, n) \
107 for( v = (void *)ACCESS_ITEM((l), (l).first), \
108 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
109 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
112 private class FastItem : struct
117 private struct FastList
122 int count, size, itemSize;
129 first = last = free = -1;
137 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
140 FastItem Add(uint itemSize)
143 if(free == -1 || !size)
150 newSize = (size + (size >> 1));
151 items = (FastItem)renew items byte[newSize * itemSize];
156 this.itemSize = itemSize;
157 items = (FastItem)new byte[newSize * itemSize];
160 for(c = size; c<newSize-1; c++)
162 ACCESS_ITEM(this, c).prev = -1;
163 ACCESS_ITEM(this, c).next = c+1;
165 ACCESS_ITEM(this, c).prev = -1;
166 ACCESS_ITEM(this, c).next = -1;
170 item = ACCESS_ITEM(this, free);
173 ACCESS_ITEM(this, item.prev).next = free;
183 void Delete(FastItem item)
186 ACCESS_ITEM(this, item.prev).next = item.next;
188 ACCESS_ITEM(this, item.next).prev = item.prev;
190 if(ACCESS_ITEM(this, first) == item)
192 if(ACCESS_ITEM(this, last) == item)
197 free = ((byte *)item - (byte *)items) / itemSize;
205 free = first = last = -1;
209 private class BoxItem : Item //FastItem
214 public /*private */struct Extent : OldList //FastList
223 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
224 Add(BoxItem { box = box });
227 void Copy(Extent source)
233 //FASTLIST_LOOP(source, extentBox)
234 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
235 AddBox(extentBox.box);
238 void IntersectBox(Box box)
240 // Clip all boxes of extent against inside of the new box
241 BoxItem extentBox, next;
243 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
244 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
246 next = (BoxItem)extentBox.next;
247 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
248 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
249 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
250 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
251 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
256 void ExcludeBox(Box box, Extent temp)
263 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
265 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
266 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
269 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
273 extentBox.box.left, extentBox.box.top,
274 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
280 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
284 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
285 extentBox.box.right, extentBox.box.bottom
291 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
294 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
298 extentBox.box.left, Max(extentBox.box.top, box.top),
299 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
305 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
309 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
310 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
318 AddBox(extentBox.box);
324 void UnionBox(Box box, Extent temp)
326 BoxItem extentBox, next;
328 // First pass: check if this box is not already covered by one of the extent's box
329 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
331 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
332 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
339 // Second pass: only keep boxes not completely covered in the new box
340 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
342 next = (BoxItem)extentBox.next;
343 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
344 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
348 // Add the exclusion to the extent
349 ExcludeBox(box, temp);
352 if(box.bottom >= box.top && box.right >= box.left)
354 // Optimization: if the resulting boxes touch, add them smarter
355 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
357 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
359 if(Abs(box.right - extentBox.box.left) <= 1)
361 extentBox.box.left = box.left;
364 else if(Abs(box.left - extentBox.box.right) <= 1)
366 extentBox.box.right = box.right;
370 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
372 if(Abs(box.bottom - extentBox.box.top) <= 1)
374 extentBox.box.top = box.top;
377 else if(Abs(box.top - extentBox.box.bottom) <= 1)
379 extentBox.box.bottom = box.bottom;
391 void Union(Extent b, Extent temp)
395 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
396 UnionBox(extentBox.box, temp);
399 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
406 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
409 temp2.IntersectBox(extentBox.box);
416 void Exclusion(Extent b, Extent temp)
419 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
420 ExcludeBox(extentBox.box, temp);
423 void Offset(int x, int y)
426 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
428 extentBox.box.left += x;
429 extentBox.box.top += y;
430 extentBox.box.right += x;
431 extentBox.box.bottom += y;
436 private define MINIMIZED_WIDTH = 160;
437 private define CASCADE_SPACE = 16;
439 // namespace Windows;
441 private class ScrollFlags
443 bool snapX:1, snapY:1, dontHide:1;
446 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
448 class WindowBits : BorderBits
450 BorderBits borderBits:6:0;
451 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
452 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
453 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
456 public enum BorderStyle : BorderBits
459 contour = BorderBits { contour = true },
460 fixed = BorderBits { fixed = true } | contour,
461 sizable = BorderBits { sizable = true } | fixed,
462 thin = BorderBits { fixed = true, thin = true } | contour,
463 sizableThin = BorderBits { sizable = true } | thin,
464 deep = BorderBits { deep = true },
465 bevel = BorderBits { bevel = true },
466 sizableDeep = sizable|deep,
467 sizableBevel = sizable|bevel,
468 fixedDeep = fixed|deep,
469 fixedBevel = fixed|bevel,
470 deepContour = deep|contour
473 public enum CreationActivationOption
475 activate, flash, doNothing
478 public enum WindowState { normal, minimized, maximized };
480 private class ResPtr : struct
487 private class HotKeySlot : struct
489 HotKeySlot prev, next;
494 public struct TouchPointerInfo
498 float size, pressure;
501 public enum TouchPointerEvent { move, up, down, pointerUp, pointerDown };
506 class_data const char * icon;
508 class_default_property caption;
509 // class_initialize GuiApplication::Initialize;
510 class_designer FormDesigner;
511 class_property const char * icon
513 set { class_data(icon) = value; }
514 get { return class_data(icon); }
519 bool switchMode = true;
520 #if defined(__ANDROID__)
525 guiApp.Initialize(switchMode);
527 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
529 if(_vTbl == ((subclass(Window))_class).pureVTbl)
531 _vTbl = _class._vTbl;
533 else if(_vTbl != _class._vTbl)
536 for(m = 0; m < _class.vTblSize; m++)
538 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
539 _vTbl[m] = _class._vTbl[m];
544 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
545 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
546 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
547 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
551 // caption = CopyString(class.name);
553 children.offset = (byte*)&prev - (byte*)this;
554 childrenOrder.circ = true;
555 childrenCycle.circ = true;
557 maxSize = Size { MAXINT, MAXINT };
561 //style.isActiveClient = true;
564 modifyVirtArea = true;
565 manageDisplay = true;
566 nativeDecorations = true;
568 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
569 sbStep.x = sbStep.y = 8;
571 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
573 cursor = guiApp.GetCursor(arrow);
574 property::parent = guiApp.desktop;
586 int i, lockCount = guiApp.lockMutex.lockCount;
587 for(i = 0; i < lockCount; i++)
588 guiApp.lockMutex.Release();
590 for(i = 0; i < lockCount; i++)
591 guiApp.lockMutex.Wait();
596 stopwatching(parent, font);
597 if(parent.activeChild == this)
598 parent.activeChild = null;
599 if(parent.activeClient == this)
600 parent.activeClient = null;
605 // Prevent destructor from being called again...
611 /////////////////////////////////
614 OldLink slave = master.slaves.FindLink(this);
615 master.slaves.Delete(slave);
622 parent.childrenCycle.Remove(cycle);
624 parent.childrenOrder.Remove(order);
625 parent.children.Remove(this);
630 /////////////////////////////////
632 while((ptr = resources.first))
635 resources.Delete(ptr);
642 for(child = children.first; child; child = child.next)
644 // child.stopwatching(this, font);
646 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
647 // Don't want property here
648 *&child.parent = null;
651 while((slave = slaves.first))
653 // Don't want property here
654 *&((Window)slave.data).master = null;
655 slaves.Delete(slave);
658 // Because we do a decref in DestroyEx...
666 // Why was this commented?
667 //if(this != guiApp.desktop)
680 if(((subclass(Window))_class).pureVTbl)
682 if(_vTbl == _class._vTbl)
684 _vTbl = ((subclass(Window))_class).pureVTbl;
689 for(m = 0; m < _class.vTblSize; m++)
691 if(_vTbl[m] == _class._vTbl[m])
692 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
696 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
699 dirtyArea.Free(null);
700 renderArea.Free(null);
701 overRenderArea.Free(null);
702 clipExtent.Free(null);
703 scrollExtent.Free(null);
704 dirtyBack.Free(null);
708 tempExtents[0].Free(null);
709 tempExtents[1].Free(null);
710 tempExtents[2].Free(null);
711 tempExtents[3].Free(null);
718 //#if !defined(ECERE_VANILLA)
719 const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
721 if(this == activeDesigner)
725 const char * name = property::name;
726 return name ? name : "";
731 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
732 bool OnGetDataFromString(const char * string)
734 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
737 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
738 this = designer.form;
739 else if(!strcmpi(string, "(Desktop)"))
740 this = activeDesigner;
742 return activeDesigner.FindObject(&this, string);
748 // --- Window updates system ---
750 // Setup a bitmap for Redrawing on client area of Window
751 Surface Redraw(Box box)
753 Surface surface = null;
755 Box clientArea = this.clientArea;
759 mox.left -= clientStart.x;
760 mox.top -= clientStart.y;
761 mox.right -= clientStart.x;
762 mox.bottom -= clientStart.y;
764 mox.Clip(clientArea);
765 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
767 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
769 int x = absPosition.x + clientStart.x;
770 int y = absPosition.y + clientStart.y;
771 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
773 x -= rootWindow.clientStart.x;
774 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
776 if(!guiApp.fullScreenMode || is3D)
778 x -= rootWindow.absPosition.x;
779 y -= rootWindow.absPosition.y;
783 int dx = rootWindow.parent.parent.clientStart.x;
784 int dy = rootWindow.parent.parent.clientStart.y;
785 if(!rootWindow.parent.nativeDecorations)
787 dx += rootWindow.parent.clientStart.x;
788 dy += rootWindow.parent.clientStart.y;
802 surface = display.GetSurface(x, y, mox);
805 surface.width = clientSize.w;
806 surface.height = clientSize.h;
812 // Setup a bitmap for Redrawing on full Window
813 Surface RedrawFull(Box box)
815 Surface surface = null;
823 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
825 int x = absPosition.x;
826 int y = absPosition.y;
827 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
829 x -= rootWindow.clientStart.x;
830 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
832 if(!guiApp.fullScreenMode || is3D)
834 x -= rootWindow.absPosition.x;
835 y -= rootWindow.absPosition.y;
838 int dx = rootWindow.parent.parent.clientStart.x;
839 int dy = rootWindow.parent.parent.clientStart.y;
840 if(!rootWindow.parent.nativeDecorations)
842 dx += rootWindow.parent.clientStart.x;
843 dy += rootWindow.parent.clientStart.y;
857 surface = display.GetSurface(x, y, mox);
860 surface.width = size.w;
861 surface.height = size.h;
867 void FigureCaption(char * caption)
869 Window activeClient = null;
873 strcpy(caption, this.caption);
874 if(style.isDocument || fileName)
876 if(caption[0]) strcat(caption, " - ");
878 strcat(caption, fileName);
882 sprintf(title, "Untitled %d", documentID);
883 strcat(caption, title);
886 strcat(caption, " *");
891 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
893 if(activeClient && activeClient.state == maximized)
895 if(activeClient.caption)
897 if(caption[0]) strcat(caption, " - ");
898 strcat(caption, activeClient.caption);
900 if(activeClient.style.isDocument || activeClient.fileName)
902 if(caption[0]) strcat(caption, " - ");
903 strcat(caption, "[");
904 if(activeClient.fileName)
905 strcat(caption, activeClient.fileName);
909 sprintf(title, "Untitled %d", activeClient.documentID);
910 strcat(caption, title);
912 if(activeClient.modifiedDocument)
913 strcat(caption, " *");
914 strcat(caption, "]");
919 // Code for returning dirty from ScrollDisplay:
921 for(d = 0; d<scrollExtent.count; d++)
923 Box * box = &scrollExtent.boxes[d];
929 Min(box.right, box.left-scroll.x),box.bottom
931 dirtyArea.UnionBox(update);
937 Max(box.left, box.right-scroll.x), box.top,
938 box.right, box.bottom
940 dirtyArea.UnionBox(update);
948 box.right, Min(box.bottom, box.top-scroll.y),
950 dirtyArea.UnionBox(update);
956 box.left, Max(box.top, box.bottom-scroll.y),
957 box.right, box.bottom
959 dirtyArea.UnionBox(update);
964 void UpdateDecorations(void)
966 // TODO: *** TEMPORARY HACK ***
973 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
975 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
977 Update({ -clientStart.x,0, -1, clientSize.h-1 });
979 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
982 // Returns w & h for Position
983 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
985 Window parent = this.parent ? this.parent : guiApp.desktop;
986 int xOffset = 0, yOffset = 0;
987 int vpw = parent ? parent.clientSize.w : 0;
988 int vph = parent ? parent.clientSize.h : 0;
989 int pw = parent ? parent.clientSize.w : 0;
990 int ph = parent ? parent.clientSize.h : 0;
991 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
992 int x = anchor.left.distance, y = anchor.top.distance;
993 float ex = 0, ey = 0;
994 MinMaxValue ew = 0, eh = 0;
996 float cascadeW, cascadeH;
998 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
999 int addX = 0, addY = 0;
1001 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
1003 Window masterWindow = this;
1004 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
1007 if(master == guiApp.desktop)
1008 masterWindow = guiApp.desktop.activeChild;
1010 masterWindow = master.rootWindow;
1011 if(!masterWindow) masterWindow = this;
1013 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
1014 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
1017 pw = vpw = box.right - box.left + 1;
1019 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
1022 ph = vph = box.bottom - box.top + 1;
1038 vpw = pw = parent.size.w;
1039 vph = ph = parent.size.h;
1041 else if(!style.fixed /*|| style.isDocument*/)
1043 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1044 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1046 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1049 Desktop3D_FixSize(&pw, &ph);
1050 Desktop3D_FixSize(&vpw, &vph);
1053 if(pw < skinMinSize.w) pw = skinMinSize.w;
1054 if(ph < skinMinSize.h) ph = skinMinSize.h;
1055 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1056 if(vph < skinMinSize.h) vph = skinMinSize.h;
1058 // TODO: Must fix what we're snapping
1061 if(anchor.left.type)
1063 SNAPUP(x, textCellW);
1065 else if(anchor.right.type)
1067 SNAPDOWN(x, textCellW);
1072 SNAPUP(y, textCellH);
1074 else if(anchor.bottom.type)
1076 SNAPDOWN(y, textCellH);
1080 // This is required to get proper initial decoration size using native decorations on Windows
1081 #if defined(__WIN32__)
1082 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1083 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1085 GetDecorationsSize(&ew, &eh);
1087 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1089 // Leave room for non client windows (eventually dockable panels)
1091 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1092 for(win = parent.children.first; win; win = win.next)
1094 if(!win.nonClient && !win.isActiveClient && win.visible)
1096 Size size = win.size;
1097 Point pos = win.position;
1098 int left = pos.x, top = pos.y;
1099 int right = pos.x + size.w, bottom = pos.y + size.h;
1100 if(win.size.w > win.size.h)
1103 loY = Max(loY, bottom);
1104 else if(top > ph - ph / 4)
1105 hiY = Min(hiY, top);
1110 loX = Max(loX, right);
1111 else if(left > pw - pw / 4)
1112 hiX = Min(hiX, left);
1121 if(parent.sbv && !parent.sbv.style.hidden)
1122 pw += guiApp.currentSkin.VerticalSBW();
1123 if(parent.sbh && !parent.sbh.style.hidden)
1124 ph += guiApp.currentSkin.HorizontalSBH();
1126 if(anchor.left.type == cascade)
1128 w = (int)(pw * 0.80);
1129 h = (int)(ph * 0.80);
1131 else if(anchor.left.type >= vTiled)
1136 numTiling = parent.numPositions - parent.numIcons;
1137 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1138 if(anchor.left.type == vTiled)
1140 tilingH = (int)sqrt(numTiling);
1141 tilingW = numTiling / tilingH;
1145 tilingW = (int)sqrt(numTiling);
1146 tilingH = numTiling / tilingW;
1149 leftOver = numTiling - tilingH * tilingW;
1152 tilingSplit = (tilingW - leftOver) * tilingH;
1153 tilingLastH = tilingH+1;
1156 tilingSplit = numTiling;
1158 if(positionID >= tilingSplit)
1160 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1161 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1162 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1163 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1167 x = xOffset + pw * (positionID / tilingH) / tilingW;
1168 y = yOffset + ph * (positionID % tilingH) / tilingH;
1169 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1170 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1174 SNAPDOWN(x, textCellW);
1175 SNAPDOWN(y, textCellH);
1176 SNAPDOWN(x2, textCellW);
1177 SNAPDOWN(y2, textCellH);
1185 if(sizeAnchor.isClientW) w += ew;
1186 if(sizeAnchor.isClientH) h += eh;
1188 if(anchor.left.type == offset)
1189 x = anchor.left.distance;
1190 else if(anchor.left.type == relative)
1191 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1192 else if(anchor.right.type == relative)
1193 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1194 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1195 else if(anchor.right.type == offset)
1196 ex = vpw - anchor.right.distance;
1198 if(anchor.top.type == offset)
1199 y = anchor.top.distance;
1200 else if(anchor.top.type == relative)
1201 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1202 else if(anchor.bottom.type == relative)
1203 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1204 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1205 else if(anchor.bottom.type == offset)
1206 ey = vph - anchor.bottom.distance;
1208 if(anchor.left.type && anchor.right.type)
1210 switch(anchor.right.type)
1213 ex = pw * (1.0f-anchor.right.percent);
1214 w = Max((int)(ex + 0.5) - x, 0);
1217 ex = vpw - anchor.right.distance;
1218 w = Max((int)(ex + 0.5) - x, 0);
1222 if(anchor.top.type && anchor.bottom.type)
1224 switch(anchor.bottom.type)
1227 ey = ph * (1.0f-anchor.bottom.percent);
1228 h = Max((int)(ey + 0.5) - y, 0);
1231 ey = vph - anchor.bottom.distance;
1232 h = Max((int)(ey + 0.5) - y, 0);
1241 if(state == normal /*|| state == Hidden*/)
1243 bool addSbV = false, addSbH = false;
1245 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1246 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1248 w = Max(w, minSize.w);
1249 h = Max(h, minSize.h);
1250 w = Min(w, maxSize.w);
1251 h = Min(h, maxSize.h);
1253 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1255 if(w) w -= guiApp.currentSkin.VerticalSBW();
1258 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1260 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1264 if(!OnResizing(&w, &h))
1270 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1271 w += guiApp.currentSkin.VerticalSBW();
1272 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1273 h += guiApp.currentSkin.HorizontalSBH();
1275 w = Max(w, skinMinSize.w);
1276 h = Max(h, skinMinSize.h);
1289 SNAPDOWN(w, textCellW);
1290 SNAPDOWN(h, textCellH);
1293 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1295 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1298 (pw - w) / CASCADE_SPACE,
1299 (ph - h) / CASCADE_SPACE);
1305 cascW = (pw - w) / (numCascade-1);
1306 cascH = (ph - h) / (numCascade-1);
1307 SNAPDOWN(cascW, textCellW);
1308 SNAPDOWN(cascH, textCellH);
1309 cascadeW = (float)cascW;
1310 cascadeH = (float)cascH;
1314 numCascade = Max(numCascade, 2);
1315 cascadeW = (float)(pw - w) / (numCascade-1);
1316 cascadeH = (float)(ph - h) / (numCascade-1);
1319 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1320 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1322 else if(anchor.left.type < vTiled)
1324 if(!anchor.left.type || anchor.horz.type == middleRelative)
1326 if(!anchor.right.type)
1328 if(anchor.horz.type == middleRelative)
1329 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1331 x = vpw / 2 + anchor.horz.distance - w / 2;
1337 // case A_EDGE: x = x - w; break;
1339 if(!anchor.top.type || anchor.vert.type == middleRelative)
1341 if(!anchor.bottom.type)
1343 if(anchor.vert.type == middleRelative)
1344 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1346 y = vph / 2 + anchor.vert.distance - h / 2;
1352 // case A_EDGE: y = y - h; break;
1355 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1363 SNAPDOWN(x, textCellW);
1364 SNAPDOWN(y, textCellH);
1376 if(anchored && style.fixed && style.isActiveClient)
1381 void UpdateCaret(bool forceUpdate, bool erase)
1383 static Window lastWindow = null;
1384 static int caretX, caretY, caretSize;
1386 if(guiApp && guiApp.caretOwner == this)
1388 int x = caretPos.x - scroll.x;
1389 int y = caretPos.y - scroll.y;
1391 if((erase || this.caretSize) &&
1392 x >= clientArea.left && x <= clientArea.right &&
1393 y >= clientArea.top && y <= clientArea.bottom)
1397 guiApp.interfaceDriver.SetCaret(
1398 x + absPosition.x + clientStart.x,
1399 y + absPosition.y + clientStart.y, this.caretSize);
1400 guiApp.caretEnabled = true;
1402 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1406 if(lastWindow != this)
1408 updateBox.left = x + 1;
1410 updateBox.right = x + 2;
1411 updateBox.bottom = y + this.caretSize - 1;
1415 updateBox.left = Min(x + 1, caretX + 1);
1416 updateBox.top = Min(y, caretY);
1417 updateBox.right = Max(x + 2, caretX + 2);
1418 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1421 guiApp.caretOwner.Update(updateBox);
1428 caretSize = this.caretSize;
1434 guiApp.interfaceDriver.SetCaret(0,0,0);
1435 guiApp.caretEnabled = false;
1441 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1446 scrolledPos.x = position.x = x;
1447 scrolledPos.y = position.y = y;
1449 clientSize.w = size.w = w;
1450 clientSize.h = size.h = h;
1452 if(parent && !style.nonClient)
1454 //if(!style.fixed || style.isDocument)
1456 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1457 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1461 clientStart.x = clientStart.y = 0;
1463 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1465 //if(!activeClient || activeClient.state != maximized)
1466 if(!noAutoScrollArea)
1468 // Check if scroll area must be modified
1469 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1471 bool foundChild = false;
1473 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1474 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1475 for(child = children.first; child; child = child.next)
1477 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1478 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1480 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1481 w = Max(w, child.position.x + child.size.w);
1482 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1483 w = Max(w, Max(child.position.x, 0) + child.size.w);
1484 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1485 h = Max(h, child.position.y + child.size.h);
1486 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1487 h = Max(h, Max(child.position.y, 0) + child.size.h);
1492 if(foundChild && (w > cw || h > ch))
1494 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1496 int stepX = sbStep.x, stepY = sbStep.y;
1497 // Needed to make snapped down position match the skin's check of client area
1498 // against realvirtual
1501 SNAPDOWN(stepX, textCellW);
1502 SNAPDOWN(stepY, textCellH);
1503 stepX = Max(stepX, textCellW);
1504 stepY = Max(stepY, textCellH);
1506 if(scrollFlags.snapX)
1508 if(scrollFlags.snapY)
1511 reqScrollArea.w = w;
1512 reqScrollArea.h = h;
1515 else if(reqScrollArea.w || reqScrollArea.h)
1517 reqScrollArea.w = 0;
1518 reqScrollArea.h = 0;
1519 SetScrollPosition(0,0);
1524 // Automatic MDI Client Scrolling Area Adjustment
1525 if(parent && !parent.noAutoScrollArea)
1527 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1528 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1530 Window parent = this.parent;
1531 int w = parent.reqScrollArea.w;
1532 int h = parent.reqScrollArea.h;
1534 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1535 w = Max(w, position.x + size.w);
1536 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1537 w = Max(w, Max(position.x, 0) + size.w);
1538 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1539 h = Max(h, position.y + size.h);
1540 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1541 h = Max(h, Max(position.y, 0) + size.h);
1543 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1544 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1546 /*bool resize = false;
1547 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1548 // Needed to make snapped down position match the skin's check of client area
1549 // against realvirtual
1552 SNAPDOWN(stepX, textCellW);
1553 SNAPDOWN(stepY, textCellH);
1554 stepX = Max(stepX, textCellW);
1555 stepY = Max(stepY, textCellH);
1557 if(parent.scrollFlags.snapX)
1559 if(parent.scrollFlags.snapY)
1561 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1563 parent.reqScrollArea.w = w;
1564 parent.reqScrollArea.h = h;*/
1566 // parent.UpdateScrollBars(true, true);
1567 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1568 false, true, true, true, false, false);
1573 GetRidOfVirtualArea();
1577 UpdateScrollBars(modifyThisArea, false);
1578 else if(guiApp.currentSkin)
1581 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1583 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1584 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1585 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1586 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1589 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1590 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1592 absPosition = scrolledPos;
1593 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1594 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1596 if(this != guiApp.desktop && parent)
1598 absPosition.x += parent.absPosition.x;
1599 absPosition.y += parent.absPosition.y;
1600 if(!style.nonClient && this != guiApp.desktop)
1602 absPosition.x += parent.clientStart.x;
1603 absPosition.y += parent.clientStart.y;
1607 box = Box { 0, 0, size.w - 1, size.h - 1 };
1612 // Clip against parent's client area
1613 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1615 // Compute client area in this window coordinate system
1616 clientArea.left = 0;
1618 clientArea.right = clientSize.w - 1;
1619 clientArea.bottom = clientSize.h - 1;
1621 // Clip against parent's client area
1623 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1627 //absPosition.x -= parent.clientStart.x;
1628 //absPosition.y -= parent.clientStart.y;
1631 // Adjust all children
1632 for(child = children.first; child; child = child.next)
1633 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1635 UpdateCaret(false, false);
1638 void GetRidOfVirtualArea(void)
1640 if(parent && !parent.destroyed && style.fixed &&
1641 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1642 parent.reqScrollArea.w && parent.reqScrollArea.h)
1644 if(!parent.noAutoScrollArea)
1646 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1650 for(child = children.first; child; child = child.next)
1652 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1654 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1655 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1665 Window parent = this.parent;
1667 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1668 false, true, true, true, false, false);
1670 parent.SetScrollArea(0,0,true);
1671 parent.SetScrollPosition(0,0);
1677 public void ExternalPosition(int x, int y, int w, int h)
1679 Position(x, y, w, h, false, true, true, true, false, false);
1682 // (w, h): Full window size
1683 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1685 bool result = false;
1686 int oldCW = clientSize.w, oldCH = clientSize.h;
1687 bool clientResized, windowResized, windowMoved;
1689 //bool realResized = size.w != w || size.h != h;
1691 // TOCHECK: This wasn't in ecere.dll
1692 //if(!parent) return true;
1693 if(destroyed) return false;
1695 windowMoved = position.x != x || position.y != y || force;
1697 // windowResized = realResized || force;
1698 windowResized = size.w != w || size.h != h || force;
1700 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1706 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1707 scrolledPos.x - parent.clientStart.x + this.box.right,
1708 scrolledPos.y - parent.clientStart.y + this.box.bottom
1714 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1719 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1721 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1722 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1723 windowResized = true;
1725 if(display && rootWindow != this)
1728 if(guiApp && guiApp.windowMoving)
1730 if(guiApp.windowMoving.style.nonClient)
1731 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1733 guiApp.windowMoving.parent.SetMouseRangeToClient();
1743 // Buttons bitmap resources crash if we do this while switching mode
1744 if(!guiApp || !guiApp.modeSwitching)
1747 // Process Anchored Children
1751 for(child = children.first; child; child = child.next)
1754 ((child.stateAnchor.left.type != offset ||
1755 child.stateAnchor.top.type != offset ||
1756 child.stateAnchor.right.type != none ||
1757 child.stateAnchor.bottom.type != none) ||
1758 child.state == maximized || child.state == minimized))
1760 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1762 // child.Position(x, y, w, h, false, true, true, true, false);
1763 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1764 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1770 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1771 //if(updateScrollBars)
1773 OnResize(clientSize.w, clientSize.h);
1775 if((clientResized || windowMoved) && created)
1776 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1778 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1780 Window master = guiApp.interimWindow.master;
1781 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1784 if(rootWindow == this && !is3D)
1788 x -= guiApp.desktop.absPosition.x;
1789 y -= guiApp.desktop.absPosition.y;
1791 //guiApp.Log("Position %s\n", caption);
1794 if(windowResized || windowMoved)
1795 if(display && !display.flags.memBackBuffer && changeRootWindow)
1796 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1798 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1799 for(child = parent.children.first; child && child != this; child = child.next)
1800 if(child.rootWindow)
1801 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1806 if(windowMoved || windowResized)
1808 display.Lock(true /*false*/);
1811 display.Position(absPosition.x, absPosition.y);
1812 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1815 // result = realResized ? display.Resize(size.w, size.h) : true;
1816 if(nativeDecorations && rootWindow.windowHandle)
1818 int w = clientSize.w, h = clientSize.h;
1819 if(hasMenuBar) h += skinMenuHeight;
1820 if(hasStatusBar) h += statusBarHeight;
1821 if(sbv && sbv.visible) w += sbv.size.w;
1822 if(sbh && sbh.visible) h += sbh.size.h;
1823 result = manageDisplay ? display.Resize(w, h) : true;
1826 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1830 else if(clientResized)
1832 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1835 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1839 if(windowMoved || windowResized)
1844 if(guiApp.driver && changeRootWindow && windowHandle)
1846 if(windowResized || windowMoved)
1847 if(!display || display.flags.memBackBuffer)
1848 guiApp.interfaceDriver.PositionRootWindow(this,
1849 x, y, w, h, windowMoved, windowResized);
1850 guiApp.interfaceDriver.UpdateRootWindow(this);
1852 for(child = children.first; child; child = child.next)
1854 if(child.is3D && child.created)
1856 // Copy Display Content
1857 child.display.displaySystem = display.displaySystem;
1858 child.display.window = display.window;
1859 child.display.current = display.current;
1860 child.display.width = display.width;
1861 child.display.height = display.height;
1862 child.display.driverData = display.driverData;
1863 child.display.mutex = null;
1874 void UpdateScrollBars(bool flag, bool fullThing)
1877 bool resizeH = false, resizeV = false;
1878 bool scrolled = false;
1879 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1880 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1882 if(destroyed) return;
1883 if(guiApp.currentSkin)
1885 MinMaxValue cw = 0, ch = 0;
1886 bool sbvVisible, sbhVisible;
1887 int rangeH = 0, rangeV = 0;
1888 int positionH = 0, positionV;
1890 // First get client area with no respect to scroll bars
1895 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1897 if(scrollFlags.dontHide)
1900 cw -= guiApp.currentSkin.VerticalSBW();
1902 ch -= guiApp.currentSkin.HorizontalSBH();
1904 // Update the scrollbar visibility
1910 sbh.disabled = rangeH <= 1;
1911 if(sbh.style.hidden)
1921 sbv.disabled = rangeV <= 1;
1922 if(sbv.style.hidden)
1930 int oldHRange = sbh ? sbh.range : 0;
1931 int oldVRange = sbv ? sbv.range : 0;
1932 // Then start off with horizontal scrollbar range
1935 positionH = sbh.thumbPosition;
1942 SBSetTotal(sbh, rvw);
1945 ch -= guiApp.currentSkin.HorizontalSBH();
1948 // Do the same for vertical scrollbar
1951 positionV = sbv.thumbPosition;
1957 SBSetTotal(sbv, rvh);
1961 cw -= guiApp.currentSkin.VerticalSBW();
1962 // Maybe we need to set the range on the horizontal scrollbar again
1970 SBSetTotal(sbh, rvw);
1971 //sbh.Action(setRange, positionH, 0);
1972 if(rangeH <= 1 && sbh.range > 1)
1974 ch -= guiApp.currentSkin.HorizontalSBH();
1980 SBSetTotal(sbv, rvh);
1982 //sbv.Action(setRange, positionV, 0);
1987 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1988 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1991 // Update the scrollbar visibility
1992 if(!scrollFlags.dontHide)
1994 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1998 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2005 if(guiApp.currentSkin)
2012 sbhVisible = sbh.style.hidden ? true : false;
2014 sbvVisible = sbv.style.hidden ? true : false;
2016 // Do our resize here
2017 if(flag && (resizeH || resizeV) && fullThing)
2019 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2024 OnResize(clientSize.w, clientSize.h);
2030 sbh.visible = sbhVisible;
2032 sbv.visible = sbvVisible;
2034 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2035 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2038 sbh.pageStep = clientSize.w;
2040 sbv.pageStep = clientSize.h;
2042 // Notify doesn't handle setRange anymore... process it here
2045 int positionH = sbh.thumbPosition;
2046 if(scroll.x != positionH)
2048 OnHScroll(setRange, positionH, 0);
2052 SNAPDOWN(positionH, textCellW);
2053 scroll.x = positionH;
2059 int seen = clientSize.w, total = reqScrollArea.w;
2062 if(scrollFlags.snapX)
2063 SNAPDOWN(seen, sbStep.x);
2065 if(!total) total = seen;
2066 range = total - seen + 1;
2068 range = Max(range, 1);
2070 if(x >= range) x = range - 1;
2072 if(scrollFlags.snapX)
2073 SNAPUP(x, sbStep.x);
2077 OnHScroll(setRange, x, 0);
2082 SNAPDOWN(x, textCellW);
2088 int positionV = sbv.thumbPosition;
2089 if(scroll.y != positionV)
2091 OnVScroll(setRange, positionV, 0);
2095 SNAPDOWN(positionV, textCellH);
2096 scroll.y = positionV;
2102 int seen = clientSize.h, total = reqScrollArea.h;
2105 if(scrollFlags.snapY)
2106 SNAPDOWN(seen, sbStep.y);
2108 if(!total) total = seen;
2109 range = total - seen + 1;
2110 range = Max(range, 1);
2112 if(y >= range) y = range - 1;
2114 if(scrollFlags.snapY)
2115 SNAPUP(y, sbStep.y);
2119 OnVScroll(setRange, y, 0);
2124 SNAPDOWN(y, textCellH);
2130 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2133 for(child = children.first; child; child = child.next)
2135 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2138 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2139 child.Position(x, y, w, h, false, true, false, true, false, false);
2146 // Process Scrollbars
2148 if(sbh) // && !sbh.style.hidden
2151 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2152 // Need to set the range again (should improve...) since the scrollbars didn't have
2153 // the right size when UpdateScrollArea set the range on it
2156 sbh.seen = clientSize.w;
2160 if(sbv) // && !sbv.state.hidden
2163 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2164 // Need to set the range again (should improve...) since the scrollbars didn't have
2165 // the right size when UpdateScrollArea set the range on it
2168 sbv.seen = clientSize.h;
2173 // TESTING THIS LOWER
2174 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2177 for(child = children.first; child; child = child.next)
2179 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2182 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2183 child.Position(x, y, w, h, false, true, false, true, false, false);
2189 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2191 SetState(maximized, false, mods);
2195 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2197 SetState(normal, false, mods);
2201 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2203 SetState(minimized, false, mods);
2204 parent.CycleChildren(false, true, false, true);
2208 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2211 // Scroll bar notifications
2212 if(action != setRange)
2214 bool changed = false;
2218 if(scroll.x != position)
2220 OnHScroll(action, position, keyFlags);
2225 SNAPDOWN(position, textCellW);
2227 scroll.x = position;
2231 if(scroll.y != position)
2233 OnVScroll(action, position, keyFlags);
2238 SNAPDOWN(position, textCellH);
2240 scroll.y = position;
2244 bool childMove = false;
2245 for(child = children.first; child; child = child.next)
2247 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2250 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2251 child.Position(x, y, w, h, false, true, false, true, false, false);
2255 // Testing this patch out to solve MDI workspace redraw bugs
2256 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2257 // Scroll offsets to blame?
2261 UpdateCaret(false, false);
2265 // Testing this patch out to solve MDI workspace redraw bugs
2266 for(child = children.first; child; child = child.next)
2268 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2277 Window GetParentMenuBar()
2279 Window menuBarParent;
2280 if(formDesigner) return null;
2281 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2283 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2284 if(menuBarParent && !menuBarParent.isActiveClient)
2290 void CreateSystemChildren(void)
2292 Window parent = this;
2293 bool scrollBarChanged = false;
2294 bool hasClose = false, hasMaxMin = false;
2295 Point scroll = this.scroll;
2297 if(state == maximized)
2299 parent = GetParentMenuBar();
2306 if(style.hasClose) hasClose = true;
2307 if(style.hasMaximize || style.hasMinimize)
2314 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2316 sysButtons[2].Destroy(0);
2317 sysButtons[2] = null;
2319 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2321 sysButtons[1].Destroy(0);
2322 sysButtons[1] = null;
2324 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2326 sysButtons[0].Destroy(0);
2327 sysButtons[0] = null;
2330 if(hasClose && parent)
2337 parent, master = this,
2338 inactive = true, nonClient = true, visible = false;
2340 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2346 if(this.parent == guiApp.desktop)
2347 sysButtons[2].hotKey = altF4;
2348 else if(style.isActiveClient)
2349 sysButtons[2].hotKey = ctrlF4;
2350 sysButtons[2].Create();
2353 sysButtons[2].symbol = 'X';
2354 sysButtons[2].disabled = !style.hasClose;
2357 if(hasMaxMin && parent)
2361 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2362 if(state == maximized)
2365 method = RestoreButtonClicked;
2371 method = MaximizeButtonClicked;
2379 parent, master = this,
2380 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2382 sysButtons[1].Create();
2384 sysButtons[1].NotifyClicked = method;
2386 sysButtons[1].symbol = symbol;
2387 sysButtons[1].disabled = !style.hasMaximize;
2390 if(hasMaxMin && parent)
2394 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2395 if (state == minimized)
2398 method = RestoreButtonClicked;
2404 method = MinimizeButtonClicked;
2412 parent, master = this,
2413 hotKey = altM, inactive = true, nonClient = true, visible = false
2415 sysButtons[0].Create();
2417 sysButtons[0].NotifyClicked = method;
2419 sysButtons[0].symbol = symbol;
2420 sysButtons[0].disabled = !style.hasMinimize;
2423 // Create the scrollbars
2424 if(style.hasHorzScroll && !sbh)
2430 direction = horizontal,
2434 snap = scrollFlags.snapX,
2435 NotifyScrolling = ScrollBarNotification
2438 scrollBarChanged = true;
2440 else if(sbh && !style.hasHorzScroll)
2446 if(style.hasVertScroll && !sbv)
2452 direction = vertical,
2456 snap = scrollFlags.snapY,
2457 NotifyScrolling = ScrollBarNotification
2460 scrollBarChanged = true;
2462 else if(sbv && !style.hasVertScroll)
2467 if(scrollBarChanged)
2469 SetScrollLineStep(sbStep.x, sbStep.y);
2470 UpdateScrollBars(true, true);
2474 if(scrollBarChanged)
2476 if(sbh) sbh.thumbPosition = scroll.x;
2477 if(sbv) sbv.thumbPosition = scroll.y;
2481 void UpdateCaption(void)
2483 if(rootWindow == this)
2486 FigureCaption(caption);
2487 if(guiApp.interfaceDriver)
2488 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2490 UpdateDecorations();
2493 if(parent.activeClient == this) // Added this last check
2495 if(parent.rootWindow == parent)
2498 parent.FigureCaption(caption);
2499 if(guiApp.interfaceDriver)
2500 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2503 parent.UpdateCaption();
2505 parent.UpdateDecorations();
2509 void UpdateActiveDocument(Window previous)
2511 Window activeClient = this.activeClient;
2512 Window activeChild = this.activeChild;
2519 activeClient.CreateSystemChildren();
2521 previous.CreateSystemChildren();
2533 // Build window list
2536 Menu windowMenu = menu.FindMenu("Window");
2541 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2543 Window document = cycle.data;
2544 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2546 char name[2048], caption[2048];
2547 document.FigureCaption(caption);
2548 sprintf(name, "%d %s", id+1, caption);
2549 windowMenu.AddDynamic(MenuItem
2551 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2552 NotifySelect = MenuWindowSelectWindow
2556 if(activeClient.cycle == cycle) break;
2561 if((!previous && activeClient) || !activeClient)
2567 item = menu.FindItem(MenuWindowCloseAll, 0);
2568 if(item) item.disabled = false;
2569 item = menu.FindItem(MenuWindowNext, 0);
2570 if(item) item.disabled = false;
2571 item = menu.FindItem(MenuWindowPrevious, 0);
2572 if(item) item.disabled = false;
2573 item = menu.FindItem(MenuWindowCascade, 0);
2574 if(item) item.disabled = false;
2575 item = menu.FindItem(MenuWindowTileHorz, 0);
2576 if(item) item.disabled = false;
2577 item = menu.FindItem(MenuWindowTileVert, 0);
2578 if(item) item.disabled = false;
2579 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2580 if(item) item.disabled = false;
2581 item = menu.FindItem(MenuWindowWindows, 0);
2582 if(item) item.disabled = false;
2585 item = menu.FindItem(MenuFileClose, 0);
2586 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2587 item = menu.FindItem(MenuFileSaveAll, 0);
2588 if(item) item.disabled = numDocuments < 1;
2590 if(activeClient && activeClient.menu && activeClient.state != minimized)
2594 //activeClient.menu.Clean(activeClient);
2595 menu.Merge(activeClient.menu, true, activeClient);
2599 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2602 menu.Merge(activeChild.menu, true, activeChild);
2605 // This is called again for a child window change, with same active client
2606 OnActivateClient(activeClient, previous);
2607 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2608 parent.UpdateActiveDocument(null);
2611 void _ShowDecorations(Box box, bool post)
2613 if(rootWindow == this && nativeDecorations && !is3D) return;
2614 if(visible && this != guiApp.desktop)
2616 Surface surface = RedrawFull(box);
2620 FigureCaption(caption);
2623 ShowDecorations(captionFont.font,
2626 active, //parent.activeClient == this
2627 guiApp.windowMoving == this);
2629 PreShowDecorations(captionFont.font,
2632 active, //parent.activeClient == this
2633 guiApp.windowMoving == this);
2640 void UpdateExtent(Box refresh)
2642 Surface surface = null;
2644 if(!manageDisplay) { OnRedraw(null);return; }
2645 _ShowDecorations(refresh, false);
2647 surface = Redraw(refresh);
2648 // Opaque background: just fill before EW_REDRAW (clear?)
2651 surface.SetBackground(background);
2652 surface.SetForeground(foreground);
2653 surface.DrawingChar(' ');
2654 if(this == rootWindow)
2656 if(style.drawBehind || background.a)
2658 int a = background.a;
2659 // Premultiply alpha for clear color
2660 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2661 surface.Clear(colorBuffer);
2662 surface.SetBackground(background);
2665 else if(background.a)
2669 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2670 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2673 if(display.flags.alpha && background.a < 255 && background)
2675 surface.Area(0,0,clientSize.w, clientSize.h);
2676 /*if(style.clearDepthBuffer)
2677 surface.Clear(depthBuffer);*/
2679 else if(/*style.clearDepthBuffer || */background.a)
2681 int a = background.a;
2682 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2683 // Premultiply alpha for clear color
2684 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2685 surface.Clear(colorBuffer);
2686 surface.SetBackground(background);
2691 surface.TextFont(usedFont.font);
2692 surface.TextOpacity(false);
2696 // Draw the caret ...
2697 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2699 // surface.SetBackground(0xFFFFFF - background.color);
2700 surface.SetBackground(~background.color);
2702 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2703 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2709 void DrawOverChildren(Box refresh)
2711 Surface surface = Redraw(refresh);
2715 surface.DrawingChar(' ');
2716 surface.SetBackground(background);
2717 surface.SetForeground(foreground);
2719 surface.TextFont(usedFont.font);
2720 surface.TextOpacity(false);
2722 OnDrawOverChildren(surface);
2727 _ShowDecorations(refresh, true);
2730 void ComputeClipExtents(void)
2733 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2735 clipExtent.Copy(this.clipExtent);
2737 for(child = children.last; child; child = child.prev)
2739 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2741 bool opaque = child.IsOpaque(); // TODO: acess background directly
2742 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2744 child.clipExtent.Copy(clipExtent);
2745 child.clipExtent.Offset(-dx, -dy);
2746 child.clipExtent.IntersectBox(child.box);
2748 child.ComputeClipExtents();
2750 if(opaque && !child.style.nonClient)
2752 // Adjust the box for the parent:
2753 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2754 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2759 // ??? Only do this for overlapped window or if parent has with clip children flag
2761 // Do this if window has clip children flag on (default false?)
2762 // this.clipExtent = clipExtent;
2764 clipExtent.Free(null);
2767 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2770 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2771 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2773 offsetX -= rootWindow.clientStart.x;
2774 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2778 for(child = children.last; child; child = child.prev)
2780 bool opaque = child.IsOpaque();
2781 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2785 // Adjust renderArea to the root window level
2786 Extent * renderArea = &rootWindow.tempExtents[3];
2788 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2789 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2790 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2792 offsetX -= child.rootWindow.clientStart.x;
2793 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2797 Extent childRenderArea;
2799 if(backBufferUpdate != null)
2801 childRenderArea.Copy(backBufferUpdate);
2802 childRenderArea.Offset(-offsetX, -offsetY);
2805 childRenderArea.Copy(child.dirtyArea);
2807 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2808 renderArea.Copy(dirtyExtent);
2809 renderArea.Offset(-offsetX, -offsetY);
2810 childRenderArea.Union(renderArea);
2813 // Intersect with the clip extent
2814 childRenderArea.Intersection(child.clipExtent);
2817 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2819 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2820 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2822 renderArea->Offset(offsetX, offsetY);
2824 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2825 // overDirtyExtent.Union(renderArea);
2826 renderArea->Empty();
2827 // childRenderArea.Free();
2829 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2834 for(child = children.last; child; child = child.prev)
2836 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2838 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2843 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2845 bool opaque = IsOpaque();
2846 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2848 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2849 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2851 offsetX -= rootWindow.clientStart.x;
2852 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2856 for(child = children.last; child; child = child.prev)
2858 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2860 ColorAlpha background = *(ColorAlpha *)&child.background;
2861 bool opaque = child.IsOpaque();
2862 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2866 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2867 // Adjust renderArea to the root window level
2869 renderArea.Copy(child.dirtyArea);
2870 renderArea.Offset(offsetX, offsetY);
2871 dirtyExtent.Union(renderArea);
2872 overDirtyExtent.Union(renderArea);
2878 for(child = children.last; child; child = child.prev)
2880 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2882 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2886 if(backBufferUpdate != null)
2888 renderArea.Copy(backBufferUpdate);
2889 renderArea.Offset(-offsetX, -offsetY);
2891 overRenderArea.Copy(backBufferUpdate);
2892 overRenderArea.Offset(-offsetX, -offsetY);
2898 renderArea.Copy(dirtyArea);
2900 overRenderArea.Copy(dirtyArea);
2903 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2904 dirtyExtentWindow->Copy(dirtyExtent);
2905 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2906 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2907 dirtyExtentWindow->Empty();
2909 // Intersect with the clip extent
2910 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2913 if(renderArea.count > 10)
2916 printf("\nToo many extents (%d):\n", renderArea.count);
2918 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2919 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2924 for(c = 0; c<10; c++)
2927 FASTLIST_LOOP(renderArea, extentBox)
2929 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2931 renderArea.Copy(extent);
2933 FASTLIST_LOOP(renderArea, extentBox)
2936 printf("(%d, %d) - (%d, %d)\n",
2937 extentBox.box.left, extentBox.box.top,
2938 extentBox.box.right, extentBox.box.bottom);
2942 printf("\nNow %d\n", renderArea.count);
2948 // WHY WAS THIS COMMENTED ??
2950 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2951 dirtyExtentWindow->Copy(overDirtyExtent);
2952 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2953 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2954 dirtyExtentWindow->Empty();
2956 // Intersect with the clip extent
2957 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2963 if(scrollExtent.count)
2965 // Subtract render extent from scrolling extent
2966 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2968 if(backBufferUpdate == null)
2970 Extent * dirty = &rootWindow.tempExtents[3];
2973 // Intersect scrolling extent with clip extent
2974 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2976 // offset this scroll to be at the root window level
2977 scrollExtent.Offset(offsetX, offsetY);
2978 // Add area that was scrolled to the dirty extents of the back buffer
2979 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2983 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2984 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2985 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2990 scrollExtent.Empty();
2992 // Add the exposed extent to the window render area
2993 dirty->Offset(-offsetX, -offsetY);
2994 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2999 // Subtract the window's box from the transparency forced extent
3000 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3006 renderArea.Copy(this.renderArea);
3007 renderArea.Offset(offsetX, offsetY);
3008 dirtyExtent.Union(renderArea);
3014 Extent renderArea { };
3016 renderArea.Copy(overRenderArea);
3017 renderArea.Offset(offsetX, offsetY);
3018 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3023 if(backBufferUpdate != null)
3025 // Remove render area from dirty area
3026 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3028 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3035 // Remove the window render area from the dirty extents of the back buffer
3036 rootWindow.dirtyBack.Exclusion(renderArea);
3040 void Render(Extent updateExtent)
3044 Window rootWindow = this.rootWindow;
3045 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3046 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3048 offsetX -= rootWindow.clientStart.x;
3049 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3052 if(rootWindow.fullRender)
3061 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3062 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3067 /*if(renderArea.count)
3068 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3071 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3073 Box box = extentBox.box;
3076 /*printf("(%d, %d) - (%d, %d)\n",
3077 extentBox.box.left, extentBox.box.top,
3078 extentBox.box.right, extentBox.box.bottom);*/
3083 box.left += offsetX;
3085 box.right += offsetX;
3086 box.bottom += offsetY;
3088 if(updateExtent != null)
3089 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3093 for(child = children.first; child; child = child.next)
3094 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3095 child.Render(updateExtent);
3097 if(rootWindow.fullRender)
3098 DrawOverChildren(box);
3101 // TO DO: There's an issue about draw over children...
3102 // TO DO: Don't wanna go through this if method isn't used
3103 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3104 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3106 Box box = extentBox.box;
3108 DrawOverChildren(box);
3110 box.left += offsetX;
3112 box.right += offsetX;
3113 box.bottom += offsetY;
3115 if(updateExtent != null)
3116 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3119 for(child = children.first; child; child = child.next)
3120 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3121 child.Render(updateExtent);
3124 overRenderArea.Empty();
3127 public void UpdateDisplay(void)
3129 if(!manageDisplay) { OnRedraw(null);return; }
3130 if(rootWindow && this != rootWindow)
3131 rootWindow.UpdateDisplay();
3134 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3135 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3138 dirtyExtent.Clear();
3141 clipExtent.AddBox(box);
3143 display.StartUpdate();
3145 if(!rootWindow.fullRender)
3147 ComputeClipExtents();
3148 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3149 ComputeRenderArea(dirtyExtent, overExtent, null);
3152 clipExtent.Free(null);
3154 dirtyExtent.Free(null);
3155 overExtent.Free(null);
3157 if(display.flags.flipping)
3160 display.Update(null);
3164 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3165 updateExtent.Clear();
3167 Render(updateExtent);
3169 updateExtent.UnionBox(this.box, tempExtents[0]);
3172 //printf("\n\nUpdate:\n------------------------------------------\n");
3175 //FASTLIST_LOOP(updateExtent, extentBox)
3176 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3179 /*printf("Updating (%d, %d) - (%d, %d)\n",
3180 extentBox.box.left, extentBox.box.top,
3181 extentBox.box.right, extentBox.box.bottom);*/
3184 display.Update(extentBox.box);
3187 updateExtent.Free(null);
3190 display.EndUpdate();
3198 void UpdateBackDisplay(Box box)
3204 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3206 //printf("UpdateBackDisplay going through!\n");
3207 display.StartUpdate();
3211 intersection.Copy(dirtyBack);
3212 intersection.IntersectBox(box);
3214 dirtyExtent.Clear();
3217 clipExtent.AddBox(box);
3219 if(!rootWindow.fullRender)
3221 ComputeClipExtents();
3222 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3225 clipExtent.Free(null);
3227 intersection.Free(null);
3228 dirtyExtent.Free(null);
3229 overExtent.Free(null);
3234 if(display.flags.flipping)
3235 display.Update(null);
3238 rootWindow.display.Update(box);
3241 display.EndUpdate();
3245 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3246 if(dirtyBack.count > MAX_DIRTY_BACK)
3248 BoxItem extentBox, next;
3249 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3250 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3252 next = (BoxItem)extentBox.next;
3253 if(extentBox != first)
3255 if(extentBox.box.left < first.box.left)
3256 first.box.left = extentBox.box.left;
3257 if(extentBox.box.top < first.box.top)
3258 first.box.top = extentBox.box.top;
3259 if(extentBox.box.right > first.box.right)
3260 first.box.right = extentBox.box.right;
3261 if(extentBox.box.bottom > first.box.bottom)
3262 first.box.bottom = extentBox.box.bottom;
3263 dirtyBack.Delete(extentBox);
3272 // --- Window positioning ---
3273 // --- Window identification ---
3275 // Returns window at position "Position"
3276 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3278 Window child, result = null;
3280 box.left += absPosition.x;
3281 box.right += absPosition.x;
3282 box.top += absPosition.y;
3283 box.bottom += absPosition.y;
3285 if(!destroyed && visible && (acceptDisabled || !disabled))
3287 int lx = x - absPosition.x;
3288 int ly = y - absPosition.y;
3289 if(IsInside(lx, ly))
3290 // if(box.IsPointInside(Point{x, y}))
3292 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3293 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3296 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3297 Window ancestor = null;
3299 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3300 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3302 if(child != statusBar && child.rootWindow == rootWindow)
3304 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3311 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3313 if(child != statusBar && child.rootWindow == rootWindow)
3315 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3322 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3330 Window FindModal(void)
3332 Window modalWindow = this, check;
3333 Window check2 = null;
3334 for(check = this; check.master; check = check.master)
3336 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3338 modalWindow = check.master.modalSlave;
3339 check = modalWindow;
3341 // TESTING THIS FOR DROPBOX...
3342 if(!rootWindow || !rootWindow.style.interim)
3344 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3346 if(check2.modalSlave && check2.modalSlave.created)
3348 modalWindow = check2.modalSlave;
3356 if(modalWindow == this)
3358 for(check = this; check.activeChild; check = check.activeChild)
3360 if(check.modalSlave)
3362 modalWindow = check.modalSlave;
3368 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3369 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3372 void StopMoving(void)
3374 if(this == guiApp.windowMoving)
3376 guiApp.windowMoving = null;
3377 UpdateDecorations();
3378 SetMouseRange(null);
3381 if(rootWindow.active)
3382 guiApp.interfaceDriver.StopMoving(rootWindow);
3384 guiApp.windowCaptured.ReleaseCapture();
3385 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3386 guiApp.windowIsResizing = false;
3390 void SelectMouseCursor(void)
3395 Window cursorWindow = null;
3396 bool rx, ry, rex, rey;
3398 guiApp.desktop.GetMousePosition(&x, &y);
3399 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3401 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3402 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3403 else if(mouseWindow)
3405 modalWindow = mouseWindow.FindModal();
3406 x -= mouseWindow.absPosition.x;
3407 y -= mouseWindow.absPosition.y;
3408 if(guiApp.windowIsResizing)
3410 rex = guiApp.resizeEndX;
3411 rey = guiApp.resizeEndY;
3412 rx = guiApp.resizeX;
3413 ry = guiApp.resizeY;
3414 if((rex && rey) || (rx && ry))
3415 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3416 else if((rex && ry) || (rx && rey))
3417 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3418 else if((ry || rey) && (!rx && !rex))
3419 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3420 else if((rx || rex) && (!ry && !rey))
3421 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3423 else if(!modalWindow && !guiApp.windowCaptured &&
3424 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3425 &rx, &ry, &rex, &rey))
3427 if((rex && rey) || (rx && ry))
3428 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3429 else if((rex && ry) || (rx && rey))
3430 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3431 else if((ry || rey) && (!rx && !rex))
3432 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3433 else if((rx || rex) && (!ry && !rey))
3434 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3436 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3438 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3439 mouseWindow.rootWindow != mouseWindow)
3440 cursorWindow = mouseWindow.parent;
3442 cursorWindow = mouseWindow;
3444 else if(!guiApp.interimWindow)
3445 cursorWindow = guiApp.windowCaptured;
3448 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3449 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3451 else if(modalWindow)
3453 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3455 else if(guiApp.interimWindow)
3457 if(guiApp.interimWindow.cursor)
3458 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3460 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3465 // --- State based input ---
3466 bool AcquireInputEx(bool state)
3471 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3472 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3474 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3476 guiApp.acquiredWindow = state ? this : null;
3479 SetMouseRangeToClient();
3480 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3485 SelectMouseCursor();
3487 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3491 // --- Window activation ---
3492 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3495 if(!parent || !parent.style.inactive)
3497 Window parent = this.parent;
3500 if(rootWindow == this)
3501 Log(active ? "active\n" : "inactive\n");
3503 if(active && requireRemaximize)
3505 if(state == maximized)
3507 property::state = normal;
3508 property::state = maximized;
3510 requireRemaximize = false;
3513 // Testing this here...
3514 if(!parent || parent == guiApp.desktop || parent.active)
3516 this.active = active;
3519 // TESTING THIS HERE
3520 UpdateDecorations();
3521 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3522 result = NotifyActivate(master, this, active, previous);
3525 this.active = !active;
3530 if(!parent || parent == guiApp.desktop || parent.active)
3532 this.active = active;
3534 AcquireInputEx(active);
3535 if(active && isEnabled)
3539 if(guiApp.caretOwner)
3543 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3544 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3545 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3546 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3548 guiApp.caretOwner.Update(extent);
3551 if(visible || !guiApp.caretOwner)
3552 guiApp.caretOwner = this;
3553 UpdateCaret(false, false);
3559 this.active = false;
3561 AcquireInputEx(active);
3563 if(!active && guiApp.caretOwner == this)
3565 UpdateCaret(false, true);
3566 guiApp.caretOwner = null;
3567 guiApp.interfaceDriver.SetCaret(0,0,0);
3568 guiApp.caretEnabled = false;
3573 if(!active && parent && parent.activeChild && parent.activeChild != this)
3574 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3580 if(!active && menuBar)
3583 menuBar.OnActivate(false, null, &goOn, true);
3584 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3589 Window aChild = activeChild;
3591 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3603 void ConsequentialMouseMove(bool kbMoving)
3607 if(kbMoving || !guiApp.windowMoving)
3611 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3613 if(guiApp.interfaceDriver)
3614 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3616 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3617 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3623 bool IsDescendantOf(Window ancestor)
3626 for(window = this; window && window != ancestor; window = window.parent);
3627 return window == ancestor;
3630 bool IsSlaveOf(Window master)
3633 for(window = this; window && window != master; window = window.master);
3634 return window == master;
3637 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3641 if(this && !destroyed /*&& state != Hidden*/)
3643 Window swap = externalSwap;
3651 if(activateParent &&
3652 (parent.activeChild != this ||
3653 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3654 active && _isModal &&
3655 parent != master && master)
3656 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3662 bool real = parent.activeChild != this;
3664 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3665 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3666 !IsDescendantOf(guiApp.interimWindow) &&
3667 !IsSlaveOf(guiApp.interimWindow))
3669 Window interimWindow = guiApp.interimWindow;
3670 while(interimWindow && interimWindow != this)
3672 Window master = interimWindow.master;
3674 guiApp.interimWindow = null;
3675 if(guiApp.caretOwner)
3676 guiApp.caretOwner.UpdateCaret(false, false);
3678 incref interimWindow;
3679 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3684 delete interimWindow;
3685 interimWindow = (master && master.style.interim) ? master : null;
3690 guiApp.interimWindow = this;
3691 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3692 guiApp.caretEnabled = false;*/
3693 UpdateCaret(false, true);
3698 //bool acquireInput = false;
3700 parent.activeChild &&
3701 parent.activeChild.state == maximized &&
3702 parent != guiApp.desktop;
3704 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3709 swap = parent.activeChild;
3710 if(swap && swap.destroyed) swap = null;
3711 if(swap && swap != this)
3714 if(!swap.PropagateActive(false, this, &goOn, true))
3715 swap = parent.activeChild;
3726 if(!parent || parent.activeChild != this || style.interim)
3729 result = PropagateActive(true, swap, &goOn, true);
3730 if(!result && !goOn)
3735 //acquireInput = true;
3739 if(style.hasMaximize && parent != guiApp.desktop)
3742 SetState(maximized, false, 0);
3743 else if(state != maximized)
3746 for(child = parent.children.first; child; child = child.next)
3748 if(this != child && child.state == maximized)
3749 child.SetState(normal, false, 0);
3756 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3758 Window previous = parent.activeClient;
3759 parent.activeChild = this;
3760 if(!style.nonClient /*&& style.isActiveClient*/)
3764 if(style.isActiveClient)
3765 parent.activeClient = this;
3766 // Moved UpdateActiveDocument inside hidden check
3767 // To prevent activating previous window while creating a new one
3768 // (It was messing up the privateModule in the CodeEditor)
3769 parent.UpdateActiveDocument(previous);
3775 //if(!style.isRemote)
3777 if(rootWindow != this)
3779 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3780 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3782 else if(!guiApp.fullScreenMode)
3784 Window modalRoot = FindModal();
3785 if(!modalRoot) modalRoot = this;
3786 if(!modalRoot.isForegroundWindow)
3788 modalRoot.isForegroundWindow = true;
3789 // To check : Why is parent null?
3790 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3792 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3794 modalRoot.isForegroundWindow = false;
3799 if(result && real && (!style.inactive || moveInactive) && parent)
3801 Window last = parent.children.last;
3803 if(!style.stayOnTop)
3804 for(; last && last.style.stayOnTop; last = last.prev);
3806 parent.children.Move(this, last);
3808 // Definitely don't want that: why not?
3812 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3818 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3825 parent.activeChild = null;
3826 if(!style.nonClient /*&& style.isActiveClient*/)
3828 Window previous = parent.activeClient;
3829 if(style.isActiveClient)
3830 parent.activeClient = null;
3831 parent.UpdateActiveDocument(previous);
3835 if(this == guiApp.interimWindow)
3837 guiApp.interimWindow = null;
3838 if(guiApp.caretOwner)
3839 guiApp.caretOwner.UpdateCaret(false, false);
3841 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3848 if(!active || !swap)
3849 UpdateDecorations();
3851 swap.UpdateDecorations();
3853 if(active && rootWindow != this)
3854 ConsequentialMouseMove(false);
3861 // --- Input Messages ---
3862 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3864 static bool reEntrancy = false;
3865 if(reEntrancy) return;
3869 guiApp.cursorUpdate = true;
3870 if(guiApp.windowScrolling && !consequential)
3872 guiApp.windowScrolling.SetScrollPosition(
3873 (guiApp.windowScrolling.sbh) ?
3874 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3875 (guiApp.windowScrolling.sbv) ?
3876 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3878 if(guiApp.windowMoving)
3880 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3882 Window window = guiApp.windowMoving;
3884 int w = window.size.w;
3885 int h = window.size.h;
3890 rx = mouseX - guiApp.windowMovingStart.x;
3891 ry = mouseY - guiApp.windowMovingStart.y;
3894 window.GetDecorationsSize(&ew, &eh);
3896 if(guiApp.windowIsResizing)
3898 x = window.scrolledPos.x;
3899 y = window.scrolledPos.y;
3903 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3904 rx = guiApp.windowResizingBefore.w - aw;
3905 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3906 w = guiApp.windowResizingBefore.w - rx;
3910 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3911 ry = guiApp.windowResizingBefore.h - ah;
3912 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3913 ry = Max(ry, -guiApp.windowMovingBefore.y);
3914 h = guiApp.windowResizingBefore.h - ry;
3916 if(guiApp.resizeEndX)
3918 w = guiApp.windowResizingBefore.w + rx;
3921 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3929 w = Max(w, window.minSize.w);
3930 h = Max(h, window.minSize.h);
3931 w = Min(w, window.maxSize.w);
3932 h = Min(h, window.maxSize.h);
3934 if(!window.OnResizing(&w, &h))
3936 w = window.clientSize.w;
3937 h = window.clientSize.h;
3940 w = Max(w, window.skinMinSize.w);
3941 h = Max(h, window.skinMinSize.h);
3948 SNAPDOWN(w, textCellW);
3949 SNAPDOWN(h, textCellH);
3954 aw = Max(w,window.skinMinSize.w);
3955 rx = guiApp.windowResizingBefore.w - aw;
3956 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3957 w = guiApp.windowResizingBefore.w - rx;
3961 ah = Max(h,window.skinMinSize.h);
3962 ry = guiApp.windowResizingBefore.h - ah;
3963 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3964 ry = Max(ry, -guiApp.windowMovingBefore.y);
3965 h = guiApp.windowResizingBefore.h - ry;
3970 if(!guiApp.windowIsResizing || guiApp.resizeX)
3971 x = guiApp.windowMovingBefore.x + rx;
3972 if(!guiApp.windowIsResizing || guiApp.resizeY)
3973 y = guiApp.windowMovingBefore.y + ry;
3975 if(!guiApp.windowIsResizing)
3978 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3980 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3981 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3982 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3983 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3987 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3988 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3994 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3996 if(!window.OnMoving(&x, &y, w, h))
3998 x = window.scrolledPos.x;
3999 y = window.scrolledPos.y;
4005 SNAPDOWN(x, textCellW);
4006 SNAPDOWN(y, textCellH);
4009 if(!window.style.nonClient)
4011 if(!window.style.fixed /*|| window.style.isDocument*/)
4013 if(!window.style.dontScrollHorz)
4014 x += window.parent.scroll.x;
4015 if(!window.style.dontScrollVert)
4016 y += window.parent.scroll.y;
4020 // Break the anchors for moveable/resizable windows
4021 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4022 if(window.style.fixed)
4024 if(window.state == normal)
4026 window.normalAnchor = Anchor { left = x, top = y };
4027 window.normalSizeAnchor = SizeAnchor { { w, h } };
4028 window.anchored = false;
4032 window.stateAnchor = Anchor { left = x, top = y };
4033 window.stateSizeAnchor = SizeAnchor { { w, h } };
4035 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4036 // TOCHECK: Investigate why the following only redraws the scrollbars
4037 //window.Position(x, y, w, h, false, true, true, true, false, true);
4039 guiApp.movingLast.x = mouseX;
4040 guiApp.movingLast.y = mouseY;
4046 public bool MultiTouchMessage(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers * mods, bool consequential, bool activate)
4052 while(result && w != this)
4054 // TODO: How to handle this?
4057 Window msgWindow = GetAtPosition(x,y, false, true, w);
4062 window = (w && !w.disabled) ? w : null;
4064 if(consequential) mods->isSideEffect = true;
4065 if(!result || (window && window.destroyed)) window = null;
4069 if(window.OnMultiTouch && !window.disabled)
4071 Array<TouchPointerInfo> in { size = infos.size };
4072 memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
4076 i.x -= (window.absPosition.x + window.clientStart.x);
4077 i.y -= (window.absPosition.y + window.clientStart.y);
4079 i.x = Max(Min(i.x, 32767),-32768);
4080 i.y = Max(Min(i.y, 32767),-32768);
4084 if(!window.OnMultiTouch(event, in, *mods))
4091 if(!result || !w || !w.clickThrough)
4099 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4102 bool wasMoving = guiApp.windowMoving ? true : false;
4103 bool wasScrolling = guiApp.windowScrolling ? true : false;
4105 while(result && w != this)
4107 Window msgWindow = GetAtPosition(x,y, false, true, w);
4108 Window trueWindow = GetAtPosition(x,y, false, false, w);
4109 bool windowDragged = false;
4114 window = (w && !w.disabled) ? w : null;
4116 if(trueWindow) incref trueWindow;
4118 if(consequential) mods->isSideEffect = true;
4120 UpdateMouseMove(x, y, consequential);
4122 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4124 if(!guiApp.windowCaptured.isEnabled)
4125 guiApp.windowCaptured.ReleaseCapture();
4127 window = guiApp.windowCaptured;
4130 if(trueWindow && activate &&
4131 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4132 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4133 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4134 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4136 if(mods->alt && !mods->ctrl && !mods->shift)
4138 Window moved = trueWindow;
4139 for(moved = trueWindow; moved; moved = moved.parent)
4140 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4145 windowDragged = true;
4147 // Cancel the ALT menu toggling...
4148 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4153 if(window && activate &&
4154 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4155 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4156 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4157 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4159 Window modalWindow = window.FindModal();
4161 /*if(mods->alt && !mods->shift && !mods->ctrl)
4163 Window moved = window;
4164 for(moved = window; moved; moved = moved.parent)
4165 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4170 windowDragged = true;
4172 // Cancel the ALT menu toggling...
4173 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4179 Window activateWindow = modalWindow ? modalWindow : window;
4180 if(activateWindow && !activateWindow.isRemote)
4182 bool doActivation = true;
4183 //bool needToDoActivation = false;
4184 Window check = activateWindow;
4186 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4188 if(!check.style.inactive)
4190 //needToDoActivation = true;
4192 doActivation = false;
4197 if(!needToDoActivation)
4198 doActivation = false;
4201 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4202 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4204 // Let the OnLeftButtonDown do the activating instead
4205 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4213 incref activateWindow;
4214 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4216 delete activateWindow;
4220 if(activateWindow._refCount == 1)
4222 delete activateWindow;
4226 delete activateWindow;
4227 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4230 mods->isActivate = true;
4234 if(!modalWindow && window && !window.destroyed)
4236 if(!guiApp.windowCaptured || windowDragged)
4238 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4240 bool moving = ((window.state != maximized &&
4241 window.IsMouseMoving(
4242 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4243 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4245 if(!moving && window.IsMouseResizing(
4246 x - window.absPosition.x,
4247 y - window.absPosition.y,
4248 window.size.w, window.size.h,
4249 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4251 guiApp.windowIsResizing = true;
4252 guiApp.windowResizingBefore.w = window.size.w;
4253 guiApp.windowResizingBefore.h = window.size.h;
4255 if(guiApp.windowIsResizing || windowDragged || moving)
4258 guiApp.windowMoving = window;
4259 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4260 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4261 guiApp.windowMovingBefore.x = window.position.x;//s;
4262 guiApp.windowMovingBefore.y = window.position.y;//s;
4263 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4264 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4267 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4269 if(window.style.fixed &&
4271 window.IsMouseMoving(
4272 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4274 window.ShowSysMenu(x, y);
4278 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4280 if(window.sbv || window.sbh)
4283 guiApp.windowScrolling = window;
4284 guiApp.windowScrollingStart.x = x;
4285 guiApp.windowScrollingStart.y = y;
4286 guiApp.windowScrollingBefore.x = window.scroll.x;
4287 guiApp.windowScrollingBefore.y = window.scroll.y;
4290 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4292 if(window.style.hasMaximize &&
4293 window.IsMouseMoving(
4294 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4297 (window.state == maximized) ? normal : maximized, false, *mods);
4305 if(guiApp.windowMoving)
4307 if(guiApp.windowMoving.parent)
4309 if(guiApp.windowMoving.style.nonClient)
4310 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4312 guiApp.windowMoving.parent.SetMouseRangeToClient();
4316 window.UpdateDecorations();
4319 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4321 // Log("\n*** LEFT BUTTON UP ***\n");
4322 if(guiApp.windowMoving)
4323 guiApp.windowMoving.StopMoving();
4325 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4327 if(guiApp.windowScrolling)
4329 Window windowScrolling = guiApp.windowScrolling;
4330 guiApp.windowScrolling = null;
4331 windowScrolling.ReleaseCapture();
4335 if(!result || (window && window.destroyed)) window = null;
4337 if(window && window.FindModal())
4340 if(trueWindow && trueWindow.FindModal())
4348 msgWindow = GetAtPosition(x,y, true, false);
4350 msgWindow.SelectMouseCursor();
4353 if(guiApp.windowCaptured || trueWindow)
4355 Window prevWindow = guiApp.prevWindow;
4356 List<Window> overWindows = guiApp.overWindows;
4357 Iterator<Window> it { overWindows };
4362 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4365 result = w.OnMouseLeave(*mods);
4367 overWindows.TakeOut(w);
4371 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4373 guiApp.prevWindow.mouseInside = false;
4374 guiApp.prevWindow = null;
4378 if(trueWindow.IsDescendantOf(prevWindow))
4380 if(!overWindows.Find(prevWindow))
4381 overWindows.Add(prevWindow);
4383 // Eventually fix this not to include captured?
4384 else if(!prevWindow.OnMouseLeave(*mods))
4388 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4390 Box box = trueWindow.box;
4391 box.left += trueWindow.absPosition.x;
4392 box.right += trueWindow.absPosition.x;
4393 box.top += trueWindow.absPosition.y;
4394 box.bottom += trueWindow.absPosition.y;
4396 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4398 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4399 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4401 overX = Max(Min(overX, 32767),-32768);
4402 overY = Max(Min(overY, 32767),-32768);
4404 trueWindow.mouseInside = true;
4405 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4409 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4411 for(w : guiApp.overWindows; w == trueWindow)
4414 guiApp.overWindows.TakeOut(w);
4417 guiApp.prevWindow = trueWindow;
4420 guiApp.prevWindow = null;
4422 SelectMouseCursor();
4424 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4425 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4427 int clientX = x - (window.absPosition.x + window.clientStart.x);
4428 int clientY = y - (window.absPosition.y + window.clientStart.y);
4430 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4432 clientX = Max(Min(clientX, 32767),-32768);
4433 clientY = Max(Min(clientY, 32767),-32768);
4435 MouseMethod = (void *)window._vTbl[method];
4437 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4440 if(!MouseMethod(window, clientX, clientY, *mods))
4444 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4445 window.OnMouseLeave(*mods);
4452 if(result && w && w.clickThrough && w.parent)
4457 if(!result || !w || !w.clickThrough)
4464 // --- Mouse cursor management ---
4466 bool KeyMessage(uint method, Key key, unichar character)
4471 if(guiApp.interimWindow)
4472 this = guiApp.interimWindow;
4475 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4479 if(!style.inactive || rootWindow != this)
4481 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4482 Window modalWindow = FindModal();
4483 Window interimMaster = master ? master.rootWindow : null;
4487 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4488 status = OnSysKeyDown(key, character);
4489 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4490 status = OnSysKeyHit(key, character);
4491 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4492 status = OnSysKeyUp(key, character);
4499 // Process Key Message for Internal UI Keyboard actions
4500 if(status && !destroyed && menuBar && state != minimized)
4503 if((SmartKey)key != alt)
4504 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4507 SmartKey sk = (SmartKey) key;
4508 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4510 status = menuBar.KeyMessage(method, key, character);
4515 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4516 menuBar.OnKeyHit(escape, 0);
4518 if(!menuBar.focus && guiApp.caretOwner)
4519 guiApp.caretOwner.UpdateCaret(true, false);
4522 if(!destroyed && status)
4524 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4528 case left: case up: case right: case down:
4529 if(guiApp.windowMoving == this)
4532 int w = guiApp.windowMoving.size.w;
4533 int h = guiApp.windowMoving.size.h;
4534 int x = guiApp.windowMoving.scrolledPos.x;
4535 int y = guiApp.windowMoving.scrolledPos.y;
4539 if(key == down || key == up)
4540 step = Max(step, textCellH);
4542 step = Max(step, textCellW);
4545 if(guiApp.windowIsResizing)
4549 case left: w-=step; break;
4550 case right: w+=step; break;
4551 case up: h-=step; break;
4552 case down: h+=step; break;
4559 case left: x-=step; break;
4560 case right: x+=step; break;
4561 case up: y-=step; break;
4562 case down: y+=step; break;
4566 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4567 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4569 if(!guiApp.windowIsResizing || guiApp.resizeX)
4570 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4572 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4574 if(!guiApp.windowIsResizing || guiApp.resizeY)
4575 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4577 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4579 guiApp.interfaceDriver.SetMousePosition(x, y);
4580 ConsequentialMouseMove(true);
4588 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4590 guiApp.windowMoving.StopMoving();
4591 ConsequentialMouseMove(false);
4599 ShowSysMenu(absPosition.x, absPosition.y);
4607 if(!destroyed && status && state != minimized)
4609 // Process all the way down the children
4610 if(activeChild && !activeChild.disabled)
4612 status = activeChild.KeyMessage(method, key, character);
4614 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4615 key.code != left && key.code != right && key.code != up && key.code != down)
4617 status = activeClient.KeyMessage(method, key, character);
4621 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4623 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4624 // && defaultControl != activeChild)
4626 delete previousActive;
4627 previousActive = activeChild;
4628 if(previousActive) incref previousActive;
4630 ConsequentialMouseMove(false);
4631 if((defaultControl.active ||
4632 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4633 defaultControl.KeyMessage(method, defaultKey, character);
4639 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4641 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4648 ShowSysMenu(absPosition.x, absPosition.y);
4655 if(this != guiApp.desktop)
4657 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4659 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4661 MenuMoveOrSize(key.shift, true);
4665 else if(guiApp.windowMoving)
4667 guiApp.windowMoving.StopMoving();
4668 ConsequentialMouseMove(false);
4676 if(!destroyed && status && state != minimized)
4678 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4682 case tab: case shiftTab:
4684 Window cycleParent = this;
4685 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4686 cycleParent = master.parent;
4688 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4690 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4693 Window child = cycleParent.activeChild;
4695 // Scroll the window to include the active control
4696 if(cycleParent.sbh && !child.style.dontScrollHorz)
4698 if(child.scrolledPos.x < 0)
4699 cycleParent.sbh.Action(Position,
4700 cycleParent.scroll.x + child.scrolledPos.x, 0);
4701 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4702 cycleParent.sbh.Action(Position,
4703 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4705 if(cycleParent.sbv && !child.style.dontScrollVert)
4707 if(child.scrolledPos.y < 0)
4708 cycleParent.sbv.Action(Position,
4709 cycleParent.scroll.y + child.scrolledPos.y, 0);
4710 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4711 cycleParent.sbv.Action(Position,
4712 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4715 cycleParent.ConsequentialMouseMove(false);
4721 case f6: case shiftF6:
4722 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4724 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4725 if(parent == guiApp.desktop)
4726 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4736 if(CycleChildren(key.shift, true, false, true))
4744 // mIRC Style Window Shortcuts
4745 case alt1: case alt2: case alt3: case alt4: case alt5:
4746 case alt6: case alt7: case alt8: case alt9: case alt0:
4751 for(document = children.first; document; document = document.next)
4753 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4755 if(document == activeChild)
4757 if(document.state == minimized)
4758 document.SetState(normal, false, key);
4761 document.SetState(minimized, false, key);
4762 CycleChildren(false, true, false);
4767 if(activeChild.state == maximized && document.style.hasMaximize)
4768 document.SetState(maximized, false, key);
4769 else if(document.state == minimized)
4770 document.SetState(normal, false, key);
4771 document.Activate();
4786 if(!destroyed && status)
4788 if(state == minimized)
4793 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4795 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4797 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4798 previousActive.ActivateEx(true, false, false, true, null, null);
4799 delete previousActive;
4805 if(!destroyed && status)
4807 status = ProcessHotKeys(method, key, character);
4809 if(!destroyed && status && !modalWindow && state != minimized)
4812 status = KeyMethod(this, key, character);
4813 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4814 status = OnKeyHit(key, character);
4815 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4817 bool result = false;
4820 case ctrlUp: case ctrlDown:
4821 if(sbv && !guiApp.windowScrolling)
4822 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4824 case wheelUp: case wheelDown:
4825 if(sbv && !guiApp.windowScrolling)
4827 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4828 // Do we want to do a consequential move regardless of result in this case?
4829 ConsequentialMouseMove(false);
4832 case ctrlPageUp: case ctrlPageDown:
4833 if(sbh && !guiApp.windowScrolling)
4834 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4839 ConsequentialMouseMove(false);
4844 if(status && !destroyed && menuBar && state != minimized)
4845 status = menuBar.KeyMessage(method, key, character);
4847 if(style.interim && /*destroyed && */status && interimMaster)
4849 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4850 status = interimMaster.KeyMessage(method, key, character);
4857 bool ProcessHotKeys(uint method, Key key, unichar character)
4862 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4863 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4864 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4866 Window hotKeyWindow = hotKey.window;
4867 Window parent = hotKeyWindow.parent;
4868 Window prevActiveWindow = activeChild;
4869 // For when sys buttons are placed inside the menu bar
4870 if(parent && parent._class == class(PopupMenu))
4871 parent = parent.parent;
4873 // 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
4874 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4877 if(prevActiveWindow) incref prevActiveWindow;
4878 incref hotKeyWindow;
4879 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4880 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4883 delete hotKeyWindow;
4884 delete prevActiveWindow;
4888 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4889 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4890 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4892 // ********* WORKING ON THIS ***********
4893 if(prevActiveWindow && !guiApp.interimWindow)
4894 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4897 else if(hotKeyWindow.style.inactive)
4898 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4900 delete prevActiveWindow;
4901 delete hotKeyWindow;
4902 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4903 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4907 if(status && tabCycle)
4910 for(child = children.first; child; child = child.next)
4912 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4923 // --- Windows and graphics initialization / termination ---
4924 bool SetupRoot(void)
4928 // Setup relationship with outside world (bb root || !bb)
4929 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4930 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4934 tempExtents = new0 Extent[4];
4939 /*if(guiApp.fullScreenMode)
4940 rootWindow = guiApp.desktop;
4942 //rootWindow = parent.created ? parent.rootWindow : null;
4943 rootWindow = parent.rootWindow;
4946 against = &parent.box;
4948 against = &parent.clientArea;
4951 for(child = children.first; child; child = child.next)
4954 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4957 bool Setup(bool positionChildren)
4959 bool result = false;
4962 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4964 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4965 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4968 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4970 // This was here, is it really needed?
4971 //guiApp.interfaceDriver.ActivateRootWindow(this);
4975 displaySystem = DisplaySystem {};
4976 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4978 delete displaySystem;
4983 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4984 if(display.Create(displaySystem, windowHandle))
4991 // Sometimes icon does not show up on Windows XP if we set here...
4992 // guiApp.interfaceDriver.SetIcon(this, icon);
4994 else if(this != guiApp.desktop)
4996 display = rootWindow ? rootWindow.display : null;
5002 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
5003 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
5005 for(child = children.first; child; child = child.next)
5007 if(child.created && !child.Setup(false))
5010 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
5011 child.UpdateCaption();
5016 bool SetupDisplay(void)
5018 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
5019 if(is3D) return Window3D_SetupDisplay(this); else
5026 class_data void ** pureVTbl;
5028 bool LoadGraphics(bool creation, bool resetAnchors)
5030 bool result = false;
5031 bool success = false;
5033 WindowState stateBackup = state;
5035 if(((subclass(Window))_class).pureVTbl)
5037 if(_vTbl == _class._vTbl)
5039 _vTbl = ((subclass(Window))_class).pureVTbl;
5044 for(m = 0; m < _class.vTblSize; m++)
5046 if(_vTbl[m] == _class._vTbl[m])
5047 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5051 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
5053 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5055 _vTbl = _class._vTbl;
5060 for(m = 0; m < _class.vTblSize; m++)
5062 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5063 _vTbl[m] = _class._vTbl[m];
5068 if(guiApp.fullScreenMode || this != guiApp.desktop)
5070 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5076 display.Lock(false);
5077 if(rootWindow == this)
5079 // Set Color Palette
5080 display.SetPalette(palette, true);
5084 if(guiApp.fullScreenMode && this == guiApp.desktop)
5089 for(c=0; c<SystemCursor::enumSize; c++)
5090 if(!guiApp.systemCursors[c].bitmap)
5092 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5093 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5094 if(guiApp.systemCursors[c].bitmapName)
5096 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5097 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5098 if(guiApp.systemCursors[c].bitmap)
5099 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5104 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5106 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5107 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5109 cursor.bitmap.paletteShades = cursor.paletteShades;
5113 guiApp.cursorUpdate = true;
5116 ConsequentialMouseMove(false);
5122 // Load Window Graphic Resources
5125 if(usedFont == setFont || usedFont == window.systemFont)
5126 RemoveResource(usedFont);
5129 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5132 RemoveResource(systemFont);
5135 RemoveResource(captionFont);
5137 for(ptr = resources.first; ptr; ptr = ptr.next)
5139 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5140 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5143 AddResource(setFont);
5145 AddResource(systemFont);
5147 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5154 //if(master && master.font)
5155 if(parent && parent.font)
5159 faceName = parent.font.faceName,
5160 size = parent.font.size,
5161 bold = parent.font.bold,
5162 italic = parent.font.italic,
5163 underline = parent.font.underline
5165 //font = parent.font;
5166 watch(parent) { font { } };
5169 font = guiApp.currentSkin.SystemFont();
5176 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5177 AddResource(captionFont);
5179 if(OnLoadGraphics())
5185 //SetScrollLineStep(sbStep.x, sbStep.y);
5187 if(this != guiApp.desktop)
5191 normalAnchor = anchor;
5192 normalSizeAnchor = sizeAnchor;
5195 // Break the anchors for moveable/resizable windows
5197 if(style.fixed && style.isDocument)
5199 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5211 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5212 stateSizeAnchor = SizeAnchor {};
5217 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5222 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5223 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5226 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5230 stateAnchor = normalAnchor;
5231 stateSizeAnchor = normalSizeAnchor;
5234 position = Point { };
5235 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5246 if(Position(x, y, w, h, true, false, true, true, true, true))
5248 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5251 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5268 success = result = true;
5271 if(!creation && result)
5273 // Load menu bar first because sys buttons are on it...
5276 if(!menuBar.LoadGraphics(false, resetAnchors))
5282 for(child = children.first; child; child = child.next)
5284 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5291 CreateSystemChildren();
5295 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5298 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5301 LogErrorCode(graphicsLoadingFailed, _class.name);
5303 // Do this here to avoid problems on Windows
5304 if(rootWindow == this && parent && stateBackup == maximized)
5305 property::state = maximized;
5309 void UnloadGraphics(bool destroyWindows)
5313 // Free children's graphics
5314 for(child = children.first; child; child = child.next)
5315 child.UnloadGraphics(destroyWindows);
5318 display.Lock(false);
5321 if(guiApp.fullScreenMode && this == guiApp.desktop)
5326 for(c=0; c<SystemCursor::enumSize; c++)
5327 if(guiApp.systemCursors[c].bitmap)
5328 delete guiApp.systemCursors[c].bitmap;
5330 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5331 delete cursor.bitmap;
5333 guiApp.cursorBackground.Free();
5336 if(display && display.displaySystem)
5340 for(ptr = resources.first; ptr; ptr = ptr.next)
5344 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5349 // Free window graphics
5352 // Free skin graphics
5353 if(rootWindow == this)
5355 DisplaySystem displaySystem = display.displaySystem;
5358 display.driverData = null;
5359 display.displaySystem = null;
5363 if(displaySystem && !displaySystem.numDisplays && !is3D)
5364 delete displaySystem;
5373 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5374 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5376 if(this == guiApp.desktop || parent == guiApp.desktop)
5378 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5379 guiApp.interfaceDriver.DestroyRootWindow(this);
5383 // --- Window Hiding ---
5385 void SetVisibility(bool state)
5387 bool visible = (style.hidden || !created) ? false : state;
5388 if(visible != this.visible)
5392 this.visible = visible;
5393 for(child = children.first; child; child = child.next)
5394 child.SetVisibility(visible);
5396 ConsequentialMouseMove(false);
5397 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5401 // --- Windows and graphics initialization / termination ---
5403 bool DisplayModeChanged(void)
5405 bool result = false;
5406 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5408 guiApp.modeSwitching = true;
5409 UnloadGraphics(false);
5411 if(LoadGraphics(false, false))
5413 guiApp.modeSwitching = false;
5418 // --- Window updates system ---
5420 void UpdateDirty(Box updateBox)
5422 if(!manageDisplay) { OnRedraw(null);return; }
5425 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5428 if(display.flags.flipping)
5431 rootWindow.UpdateDisplay();
5434 UpdateBackDisplay(updateBox);
5436 if(guiApp.fullScreenMode)
5438 guiApp.cursorUpdate = true;
5439 guiApp.PreserveAndDrawCursor();
5441 if(guiApp.fullScreenMode)
5442 guiApp.RestoreCursorBackground();
5448 // This function is strictly called as a result of system window activation
5449 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5452 Window interimMaster = null;
5453 Window interimWindow = guiApp.interimWindow;
5454 if(interimWindow && interimWindow.master)
5455 interimMaster = interimWindow.master.rootWindow;
5457 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5458 // SetState(normal, false, 0);
5459 SetState(lastState, false, 0);
5461 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5465 /* WTH is this doing here?
5466 while(swap && swap.activeChild)
5468 swap = swap.activeChild;
5471 // TESTING THIS BEFORE...
5472 if(interimWindow && this == interimMaster)
5476 // Window interimSwap = this;
5477 Window menuBar = this.menuBar;
5478 if(menuBar && interimWindow.master == menuBar)
5481 while(interimSwap && interimSwap.activeChild)
5482 interimSwap = interimSwap.activeChild;
5484 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5485 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5487 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5488 //result = ActivateEx(true, true, false, activateRoot, window, null);
5493 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5494 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5496 if(interimWindow == this && interimMaster && !active)
5498 while(interimMaster && interimMaster.interim && interimMaster.master)
5500 // printf("Going up one master %s\n", interimMaster._class.name);
5501 interimMaster = interimMaster.master.rootWindow;
5503 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5504 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5510 bool DestroyEx(int64 returnCode)
5513 Timer timer, nextTimer;
5515 OldLink prevOrder = null;
5516 Window client = null;
5518 if(parent) stopwatching(parent, font);
5520 // if(window.modalSlave) return false;
5521 if(destroyed || !created)
5528 OldLink slave = master.slaves.FindLink(this);
5529 master.slaves.Delete(slave);
5532 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5538 this.returnCode = (DialogResult)returnCode;
5540 AcquireInput(false);
5545 master.hotKeys.Delete(hotKey);
5549 if(guiApp.prevWindow == this)
5551 guiApp.prevWindow = null;
5556 for(w : guiApp.overWindows; w == this)
5559 guiApp.overWindows.TakeOut(w);
5563 if(guiApp.caretOwner == this)
5565 guiApp.interfaceDriver.SetCaret(0,0,0);
5566 UpdateCaret(false, true);
5567 guiApp.caretEnabled = false;
5572 parent.childrenCycle.Remove(cycle);
5576 OldLink tmpPrev = order.prev;
5577 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5578 prevOrder = tmpPrev;
5581 client = tmpPrev ? tmpPrev.data : null;
5582 if(client == this) { client = null; break; }
5583 if(client && (client.style.hidden || client.destroyed || !client.created))
5584 tmpPrev = client.order.prev;
5588 prevOrder = tmpPrev;
5593 // If this window can be an active client, make sure the next window we activate can also be one
5594 if(!style.nonClient && style.isActiveClient)
5596 tmpPrev = prevOrder;
5599 client = tmpPrev ? tmpPrev.data : null;
5600 if(client == this) { client = null; break; }
5601 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5602 tmpPrev = client.order.prev;
5606 prevOrder = tmpPrev;
5610 if(client && client.style.hidden) client = null;
5612 // parent.childrenOrder.Remove(order);
5615 if(parent && style.isActiveClient && visible)
5617 if(state == minimized) parent.numIcons--;
5618 parent.numPositions--;
5621 // TESTING THIS HERE!
5625 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5626 // to create a window inside a rootwindow that's being destroyed)
5627 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5629 if(master && !master.destroyed /*&&
5630 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5632 if(master.defaultControl == this)
5633 master.defaultControl = null;
5636 parent.OnChildAddedOrRemoved(this, true);
5637 if(parent && !parent.destroyed /*&&
5638 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5640 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5642 if(order && prevOrder && prevOrder.data != this && active)
5644 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5646 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5647 if(parent.activeClient == this)
5649 parent.activeClient = null;
5650 parent.UpdateActiveDocument(null);
5655 if(guiApp.interimWindow == this)
5658 PropagateActive(false, null, &goOn, true);
5662 //if(window.parent.activeChild == window)
5663 parent.activeChild = null;
5664 if(!style.nonClient /*&& style.isActiveClient*/)
5666 Window previous = parent.activeClient;
5667 if(style.isActiveClient)
5668 parent.activeClient = null;
5669 parent.UpdateActiveDocument(previous);
5674 else if(parent.activeClient == this)
5676 parent.activeClient = client;
5677 parent.UpdateActiveDocument(this);
5681 if(guiApp.interimWindow == this)
5683 guiApp.interimWindow = null;
5684 if(guiApp.caretOwner)
5686 Window desktop = guiApp.desktop;
5687 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5688 guiApp.caretOwner.UpdateCaret(false, false);
5693 if(_isModal && master && master.modalSlave == this)
5694 master.modalSlave = null;
5698 if(!guiApp.caretOwner && parent.caretSize)
5700 guiApp.caretOwner = parent;
5701 parent.UpdateCaret(false, false);
5702 parent.Update(null);
5705 // Why was this commented out?
5706 GetRidOfVirtualArea();
5712 dirtyArea.Free(null);
5713 dirtyBack.Free(null);
5714 scrollExtent.Free(null);
5716 /* ATTEMPTING TO MOVE THAT ABOVE
5725 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5726 for(;(child = window.children.first);)
5728 for(; child && (child.destroyed || !child.created); child = child.next);
5737 UnloadGraphics(true);
5740 delete previousActive;
5743 // statusBar = null;
5746 if(master && !master.destroyed)
5748 //master.NotifyDestroyed(this, this.returnCode);
5749 NotifyDestroyed(master, this, this.returnCode);
5752 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5754 nextTimer = timer.next;
5755 if(timer.window == this)
5757 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5758 // timer.window = null;
5764 if(this == guiApp.windowMoving)
5767 if(guiApp.windowCaptured == this)
5769 //guiApp.windowCaptured = null;
5771 if(rootWindow != this && rootWindow)
5772 rootWindow.ConsequentialMouseMove(false);
5780 //for(child = children.first; next = child ? child.next : null, child; child = next)
5781 for(;(child = children.first); )
5783 for(; child && (child.destroyed || !child.created); child = child.next);
5793 /* // MOVED THIS UP...
5796 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5797 for(;(child = window.children.first); )
5799 for(; child && (child.destroyed || !child.created); child = child.next);
5808 while((slave = slaves.first))
5810 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5812 ((Window)slave.data).DestroyEx(0);
5817 if(guiApp.caretOwner == this)
5818 guiApp.caretOwner = null;
5820 sysButtons[0] = null;
5821 sysButtons[1] = null;
5822 sysButtons[2] = null;
5825 if(rootWindow != this)
5827 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5830 box.left -= parent.clientStart.x;
5831 box.top -= parent.clientStart.y;
5832 box.right -= parent.clientStart.x;
5833 box.bottom -= parent.clientStart.y;
5835 if(parent) parent.Update(box);
5840 OldLink slave = master.slaves.FindVoid(this);
5841 master.slaves.Delete(slave);
5847 parent.children.Remove(this);
5852 //autoCreate = false;
5855 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5856 if(((subclass(Window))_class).pureVTbl)
5858 if(_vTbl == _class._vTbl)
5860 _vTbl = ((subclass(Window))_class).pureVTbl;
5865 for(m = 0; m < _class.vTblSize; m++)
5867 if(_vTbl[m] == _class._vTbl[m])
5868 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5877 void SetStateEx(WindowState newState, bool activate)
5880 WindowState prevState = state;
5884 if(prevState != newState)
5885 lastState = prevState;
5887 if(rootWindow != this || !nativeDecorations || !windowHandle)
5889 if(style.isActiveClient && !style.hidden && prevState == minimized)
5892 // This block used to be at the end of the function... moved it for flicker problem in X
5893 // ------------------------------------------------------
5897 stateAnchor = normalAnchor;
5898 stateSizeAnchor = normalSizeAnchor;
5901 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5902 stateSizeAnchor = SizeAnchor {};
5908 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5911 byte * idBuffer = new0 byte[size];
5913 for(child = parent.children.first; child; child = child.next)
5915 if(child != this && child.state == minimized)
5917 if(child.iconID > size - 2)
5919 idBuffer = renew0 idBuffer byte[size*2];
5920 memset(idBuffer + size, 0, size);
5923 idBuffer[child.iconID] = (byte)bool::true;
5926 for(c = 0; c<size; c++)
5931 if(style.isActiveClient && !style.hidden)
5934 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5935 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5940 // TOCHECK: Why was this here?
5941 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5942 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5943 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5945 if(state != minimized || hasMinimize)
5946 Position(x, y, w, h, true, true, true, true, false, true);
5948 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5949 parent.UpdateActiveDocument(null);
5952 if(state != minimized || hasMinimize)
5953 CreateSystemChildren();
5954 // ------------------------------------------------------
5957 int GetPositionID(Window forChild)
5961 byte * idBuffer = new0 byte[size];
5964 for(child = children.first; child; child = child.next)
5966 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5968 if(child.positionID > size - 2)
5970 idBuffer = renew0 idBuffer byte[size*2];
5971 memset(idBuffer + size, 0, size);
5974 idBuffer[child.positionID] = (byte)bool::true;
5977 for(c = 0; c<size; c++)
5984 // --- Window related graphics ---
5986 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5988 palette = newPalette;
5989 if(rootWindow.display)
5990 rootWindow.display.SetPalette(palette, colorMatch);
5993 public bool AcquireInput(bool acquired)
5996 if(acquiredInput != acquired)
5998 if(active || (!visible && creationActivation == activate))
5999 result = AcquireInputEx(acquired);
6004 acquiredInput = acquired ? result : !result;
6009 void ListChildren(ListBox listBox)
6013 for(child = children.first; child; child = child.next)
6015 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
6017 DataRow row = listBox.AddRow();
6018 row.tag = (int64)(intptr)child;
6019 child.FigureCaption(caption);
6020 row.SetData(null, caption);
6025 void UpdateVisual(Box extent)
6027 if(guiApp.driver != null)
6029 if(guiApp.fullScreenMode && guiApp.desktop.display)
6031 guiApp.desktop.mutex.Wait();
6032 guiApp.desktop.display.Lock(true);
6035 if(guiApp.desktop.active)
6037 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
6039 if(guiApp.desktop.display.flags.flipping)
6040 guiApp.desktop.Update(null);
6041 guiApp.desktop.UpdateDisplay();
6042 guiApp.cursorUpdate = true;
6044 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
6046 guiApp.PreserveAndDrawCursor();
6047 // guiApp.desktop.display.ShowScreen();
6048 guiApp.cursorUpdate = false;
6049 guiApp.desktop.dirty = false;
6050 guiApp.RestoreCursorBackground();
6054 guiApp.desktop.display.Unlock();
6055 guiApp.desktop.mutex.Release();
6059 Window rootWindow = this.rootWindow;
6060 rootWindow.mutex.Wait();
6065 guiApp.SignalEvent();
6068 guiApp.waitMutex.Wait();
6069 guiApp.interfaceDriver.Lock(rootWindow);
6070 if(!rootWindow.style.hidden && rootWindow.dirty)
6072 if(rootWindow.display)
6074 rootWindow.UpdateDisplay();
6075 //rootWindow.display.ShowScreen(null);
6077 rootWindow.dirty = false;
6079 guiApp.interfaceDriver.Unlock(rootWindow);
6080 guiApp.waitMutex.Release();
6083 rootWindow.mutex.Release();
6088 void UnlockDisplay(void)
6090 guiApp.interfaceDriver.Unlock(rootWindow);
6093 void LockDisplay(void)
6095 guiApp.interfaceDriver.Lock(rootWindow);
6098 Surface GetSurface(Box box)
6100 return Redraw((box == null) ? this.box : box);
6103 void SetMousePosition(int x, int y)
6105 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6109 void IntegrationActivate(bool active)
6111 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6113 isForegroundWindow = true;
6114 ActivateEx(active, active, false, false, null, null);
6115 isForegroundWindow = false;
6120 Window QueryCapture(void)
6122 return guiApp.windowCaptured;
6125 int GetDocumentID(void)
6129 byte * idBuffer = new0 byte[size];
6132 for(child = children.first; child; child = child.next)
6134 // TO CHECK: Do we want a documentID when we already have a file name?
6135 if(child.style.isDocument && !child.fileName)
6137 if(child.documentID-1 > size - 2)
6139 idBuffer = renew0 idBuffer byte[size*2];
6140 memset(idBuffer + size, 0, size);
6143 idBuffer[child.documentID-1] = 1;
6146 for(c = 0; c<size; c++)
6154 void SetInitSize(Size size)
6157 sizeAnchor.size = size;
6158 normalSizeAnchor = sizeAnchor;
6160 // Break the anchors for moveable/resizable windows
6161 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6163 stateAnchor = normalAnchor;
6164 stateSizeAnchor = normalSizeAnchor;
6166 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6167 Position(x,y, w, h, true, true, true, true, false, true);
6171 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6173 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6175 guiApp.windowIsResizing = resize;
6176 guiApp.windowMoving = this;
6177 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6178 if(guiApp.windowIsResizing)
6180 guiApp.windowMovingStart.x += size.w - 1;
6181 guiApp.windowMovingStart.y += size.h - 1;
6183 guiApp.windowMovingBefore = scrolledPos;
6184 guiApp.windowResizingBefore = size;
6185 guiApp.windowMoving.UpdateDecorations();
6186 if(guiApp.windowIsResizing)
6187 guiApp.resizeEndX = guiApp.resizeEndY = true;
6189 if(setCursorPosition)
6190 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6194 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6195 guiApp.windowMovingStart.x += x - absPosition.x;
6196 guiApp.windowMovingStart.y += y - absPosition.y;
6199 if(guiApp.windowMoving)
6201 if(guiApp.windowMoving.style.nonClient)
6202 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6204 guiApp.windowMoving.parent.SetMouseRangeToClient();
6209 if(this == rootWindow)
6210 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6214 void SetupFileMonitor()
6218 fileMonitor = FileMonitor
6220 this, FileChange { modified = true };
6222 bool OnFileNotify(FileChange action, const char * param)
6225 fileMonitor.StopMonitoring();
6226 if(OnFileModified(action, param))
6227 fileMonitor.StartMonitoring();
6240 bool result = false;
6244 else if(guiApp && guiApp.driver != null)
6246 OldLink slaveHolder;
6248 bool visible = !style.hidden;
6252 systemParent = parent;
6253 parent = guiApp.desktop;
6255 last = parent ? parent.children.last : null;
6257 if((parent && parent != guiApp.desktop && !parent.created) ||
6258 (master && master != guiApp.desktop && !master.created))
6262 stopwatching(parent, font);
6265 property::parent = guiApp.desktop;
6266 if(!master) master = parent;
6268 if(_isModal && master.modalSlave)
6269 property::master = master.modalSlave;
6273 parent.children.Remove(this);
6276 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6277 if(slaveHolder.data == this)
6279 master.slaves.Delete(slaveHolder);
6284 if(parent == guiApp.desktop && !mutex)
6287 if(style.isDocument)
6290 parent.numDocuments--;
6291 documentID = parent.GetDocumentID();
6294 if(!style.stayOnTop)
6295 for(; last && last.style.stayOnTop; last = last.prev);
6297 parent.children.Insert((last == this) ? null : last, this);
6298 //parent.children.Add(this);
6301 dispDriver = parent.dispDriver;
6304 master.modalSlave = this;
6306 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6311 master.slaves.Add(slaveHolder = OldLink { data = this });
6316 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6318 if(style.isDefault && !master.defaultControl)
6319 master.defaultControl = this;
6321 stateAnchor = normalAnchor = anchor;
6322 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6324 // TOCHECK: Why is this here?
6325 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6326 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6328 this.visible = false;
6329 style.hidden = true;
6332 // autoCreate = true;
6340 if(parent == guiApp.desktop)
6341 Log("LoadGraphics %s\n", caption);
6343 if(LoadGraphics(true, false))
6351 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6358 if(style.hasMenuBar /*&& menu*/)
6364 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6365 interim = false, inactive = true, nonClient = true, size.h = 24
6373 // Create the system buttons
6374 CreateSystemChildren();
6376 UpdateActiveDocument(null);
6378 if(style.isDocument)
6382 MenuItem item = menu.FindItem(MenuFileSave, 0);
6383 if(item) item.disabled = !modifiedDocument && fileName;
6388 if(parent == guiApp.desktop)
6389 Log("Preemptive SetState %s\n", caption);
6392 // Preemptive Set State to ensure proper anchoring
6393 SetStateEx(state, false);
6395 style.hidden = true;
6401 for(child = children.first; child; child = next)
6404 if(!child.created && (child.autoCreate || child.wasCreated))
6411 for(link = slaves.first; link; link = next)
6413 Window slave = link.data;
6415 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6418 // Things might have happened that invalidated 'next'...
6419 // Start over the search for slaves to create.
6420 // (Added this to fix crash with Stacker & Toolbar)
6421 next = slaves.first;
6430 if(parent == guiApp.desktop)
6431 Log("Real SetState %s\n", caption);
6434 if(isActiveClient && visible)
6436 parent.numPositions--;
6437 if(state == minimized) parent.numIcons--;
6440 parent.OnChildAddedOrRemoved(this, false);
6442 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6444 // Real set state & activate for proper display & activation
6445 property::visible = visible;
6446 // SetState(state & 0x00000003, true, 0);
6447 guiApp.interfaceDriver.SetIcon(this, icon);
6452 /*if(rootWindow == this)
6453 guiApp.interfaceDriver.ActivateRootWindow(this);
6455 if(creationActivation == activate && guiApp.desktop.active)
6456 ActivateEx(true, false, true, true, null, null);
6457 else if(creationActivation == activate || creationActivation == flash)
6460 if(this == rootWindow)
6466 rootWindow.ConsequentialMouseMove(false);
6477 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6483 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6485 //style.hidden = true; // !visible;
6486 style.hidden = !visible;
6487 if(master.modalSlave == this)
6488 master.modalSlave = null;
6495 void WriteCaption(Surface surface, int x, int y)
6498 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6501 void Update(Box region)
6507 rootWindow = this.rootWindow;
6509 // rootWindow.mutex.Wait();
6510 if(!destroyed && visible && display)
6515 // Testing this to avoid repetitve full update to take time...
6516 if(rootWindow.fullRender)
6518 rootWindow.dirty = true;
6521 if(dirtyArea.count == 1)
6523 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6524 if(item.box.left <= box.left &&
6525 item.box.top <= box.top &&
6526 item.box.right >= box.right &&
6527 item.box.bottom >= box.bottom)
6529 rootWindow.dirty = true;
6534 if(display.flags.flipping && !rootWindow.dirty)
6536 if(this == rootWindow)
6540 rootWindow.Update(null);
6545 rootWindow.dirty = true;
6550 realBox.left += clientStart.x;
6551 realBox.top += clientStart.y;
6552 realBox.right += clientStart.x;
6553 realBox.bottom += clientStart.y;
6559 if(realBox.right >= realBox.left &&
6560 realBox.bottom >= realBox.top)
6562 // if(!rootWindow.fullRender)
6563 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6565 for(child = children.first; child; child = child.next)
6570 box.left -= child.absPosition.x - absPosition.x;
6571 box.top -= child.absPosition.y - absPosition.y;
6572 box.right -= child.absPosition.x - absPosition.x;
6573 box.bottom -= child.absPosition.y - absPosition.y;
6574 if(box.right >= child.box.left && box.left <= child.box.right &&
6575 box.bottom >= child.box.top && box.top <= child.box.bottom)
6577 box.left -= child.clientStart.x;
6578 box.top -= child.clientStart.y;
6579 box.right -= child.clientStart.x;
6580 box.bottom -= child.clientStart.y;
6586 realBox.left += absPosition.x - rootWindow.absPosition.x;
6587 realBox.top += absPosition.y - rootWindow.absPosition.y;
6588 realBox.right += absPosition.x - rootWindow.absPosition.x;
6589 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6590 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6593 else if(this == guiApp.desktop)
6596 for(window = children.first; window; window = window.next)
6602 Box childBox = region;
6604 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6605 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6606 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6607 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6609 window.Update(childBox);
6612 window.Update(null);
6617 // rootWindow.mutex.Release();
6624 if(guiApp.windowCaptured != this)
6626 if(guiApp.windowCaptured)
6630 //Logf("Captured %s (%s)\n", caption, class.name);
6631 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6632 guiApp.windowCaptured = this;
6638 bool Destroy(int64 code)
6643 if(!destroyed && !CloseConfirmation(false)) return false;
6647 // TOCHECK: Should autoCreate be set to false here?
6658 void Move(int x, int y, int w, int h)
6660 normalAnchor = Anchor { left = x, top = y };
6661 normalSizeAnchor = SizeAnchor { size = { w, h } };
6663 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6665 if(destroyed) return;
6667 stateAnchor = normalAnchor;
6668 stateSizeAnchor = normalSizeAnchor;
6670 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6671 Position(x,y, w, h, true, true, true, true, false, true);
6675 DialogResult Modal(void)
6681 // FIXES MEMORY LEAK IF Create() FAILED
6687 void SetScrollArea(int width, int height, bool snapToStep)
6691 int stepX = sbStep.x, stepY = sbStep.y;
6692 // Needed to make snapped down position match the skin's check of client area
6693 // against realvirtual
6696 SNAPDOWN(stepX, textCellW);
6697 SNAPDOWN(stepY, textCellH);
6698 stepX = Max(stepX, textCellW);
6699 stepY = Max(stepY, textCellH);
6701 if(scrollFlags.snapX)
6702 SNAPUP(width, stepX);
6703 if(scrollFlags.snapY)
6704 SNAPUP(height, stepY);
6707 reqScrollArea.w = width;
6708 reqScrollArea.h = height;
6709 noAutoScrollArea = (width > 0 || height > 0);
6711 UpdateScrollBars(true, true);
6714 void SetScrollPosition(int x, int y)
6717 sbh.Action(setPosition, x, 0);
6721 int seen = clientSize.w, total = reqScrollArea.w;
6723 if(scrollFlags.snapX)
6724 SNAPDOWN(seen, sbStep.x);
6726 if(!total) total = seen;
6727 range = total - seen + 1;
6728 range = Max(range, 1);
6730 if(x >= range) x = range - 1;
6732 if(scrollFlags.snapX)
6733 SNAPUP(x, sbStep.x);
6736 OnHScroll(setPosition, x, 0);
6740 SNAPDOWN(x, textCellW);
6746 sbv.Action(setPosition, y, 0);
6750 int seen = clientSize.h, total = reqScrollArea.h;
6753 if(scrollFlags.snapY)
6754 SNAPDOWN(seen, sbStep.y);
6756 if(!total) total = seen;
6757 range = total - seen + 1;
6758 range = Max(range, 1);
6760 if(y >= range) y = range - 1;
6762 if(scrollFlags.snapY)
6763 SNAPUP(y, sbStep.y);
6766 OnVScroll(setPosition, y, 0);
6769 SNAPDOWN(y, textCellH);
6774 UpdateCaret(false, false);
6777 void SetScrollLineStep(int stepX, int stepY)
6783 SNAPDOWN(stepX, textCellW);
6784 SNAPDOWN(stepY, textCellH);
6785 stepX = Max(stepX, textCellW);
6786 stepY = Max(stepY, textCellH);
6789 sbh.lineStep = stepX;
6791 sbv.lineStep = stepY;
6794 void SetState(WindowState newState, bool activate, Modifiers mods)
6798 if(state == newState || OnStateChange(newState, mods))
6800 //WindowState prevState = state;
6804 // This used to be at the end of the brackets... moved for X, testing...
6805 // This has the effect of activating the window through the system...
6806 if(rootWindow == this)
6807 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6809 SetStateEx(newState, activate);
6811 if(rootWindow == this && !rootWindow.nativeDecorations)
6813 int x = position.x, y = position.y;
6816 x -= guiApp.desktop.absPosition.x;
6817 y -= guiApp.desktop.absPosition.y;
6819 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6823 //state = prevState;
6825 if(state != maximized && style.hasMaximize)
6828 for(child = parent.children.first; child; child = child.next)
6830 if(child != this && child.state == maximized)
6831 child.SetStateEx(normal, false);
6835 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6836 parent.UpdateScrollBars(true, true);
6839 // Do we really need this stuff here?
6840 // Shouldn't the Activate stuff take care of it?
6841 if(parent.rootWindow == parent && style)
6844 parent.FigureCaption(caption);
6845 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6846 parent.UpdateDecorations();
6850 rootWindow.ConsequentialMouseMove(false);
6857 BitmapResource GetIcon(SkinBitmap iconID)
6859 return guiApp.currentSkin.GetBitmap(iconID);
6862 void SetMouseRange(Box range)
6864 if(range || guiApp.fullScreenMode)
6869 clip.left = range.left + absPosition.x + clientStart.x;
6870 clip.top = range.top + absPosition.y + clientStart.y;
6871 clip.right = range.right + absPosition.x + clientStart.x;
6872 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6876 clip.left = guiApp.desktop.box.left;
6877 clip.top = guiApp.desktop.box.top;
6878 clip.right = guiApp.desktop.box.right;
6879 clip.bottom = guiApp.desktop.box.bottom;
6881 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6884 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6887 void SetMouseRangeToClient(void)
6889 if(guiApp.fullScreenMode || this != guiApp.desktop)
6891 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6892 box.Clip(clientArea);
6896 SetMouseRange(null);
6899 void SetMouseRangeToWindow(void)
6901 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6902 if(this == guiApp.desktop)
6903 SetMouseRangeToClient();
6908 // x, y: Desktop Coordinates
6909 void ShowSysMenu(int x, int y)
6912 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6915 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6916 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6920 menu, $"Move", m, NotifySelect = MenuWindowMove,
6921 disabled = !style.fixed || state == maximized
6925 menu, $"Size", s, NotifySelect = MenuWindowSize,
6926 disabled = !style.sizable || state != normal
6930 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6931 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6935 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6936 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6940 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6941 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6943 MenuDivider { menu };
6946 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6947 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6949 windowMenu.Create();
6954 ActivateEx(true, true, true, true, null, null);
6957 void MakeActive(void)
6959 ActivateEx(true, false, true, false, null, null);
6962 void SoftActivate(void)
6964 if(guiApp.desktop.active)
6969 if(this == rootWindow)
6974 void Deactivate(void)
6976 ActivateEx(false, true, true, true, null, null);
6981 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6984 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6986 bool result = false;
6987 if(activeChild && activeChild.cycle)
6989 Window modalWindow, child = activeChild;
6990 if(!clientOnly /*&& parent.tabCycle*/)
6992 Window next = child;
6995 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6999 if(parent && parent.CycleChildren(backward, false, true, true))
7007 next = next.cycle.prev.data;
7009 next = next.cycle.next.data;
7010 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
7015 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
7016 parent.tabCycle && parent.CycleChildren(backward, false, false))
7020 if(tabCycleOnly && !tabCycle) return false;
7027 child = child.cycle.prev.data;
7029 child = child.cycle.next.data;
7030 if(child == child.parent.activeChild)
7032 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
7035 modalWindow = child.FindModal();
7038 // Scroll the window to include the active control
7039 if(sbh && !child.style.dontScrollHorz)
7041 if(child.scrolledPos.x < 0)
7042 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
7043 else if(child.scrolledPos.x + child.size.w > clientSize.w)
7044 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
7046 if(sbv && !child.style.dontScrollVert)
7048 if(child.scrolledPos.y < 0)
7049 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
7050 else if(child.scrolledPos.y + child.size.h > clientSize.h)
7051 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
7055 child = modalWindow ? modalWindow : child;
7056 child.ActivateEx(true, true, true, true, null, null);
7057 if(child.tabCycle && child.childrenCycle.first)
7058 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7066 ConsequentialMouseMove(false);
7070 void AddResource(Resource resource)
7074 ResPtr ptr { resource = resource };
7078 // Load Graphics here if window is created already
7079 if(/*created && */display)
7081 display.Lock(false);
7082 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7083 ptr.loaded = display.displaySystem.LoadResource(resource);
7087 // Temporary hack to load font right away for listbox in dropbox ...
7088 else if(master && master.display)
7090 master.display.Lock(false);
7091 master.display.displaySystem.LoadResource(resource);
7092 master.display.Unlock();
7098 void RemoveResource(Resource resource)
7103 for(ptr = resources.first; ptr; ptr = ptr.next)
7105 if(ptr.resource == resource)
7111 // Unload Graphics here if window is created already
7112 if(/*created && */display)
7116 display.Lock(false);
7117 display.displaySystem.UnloadResource(resource, ptr.loaded);
7123 resources.Delete(ptr);
7128 void SetCaret(int x, int y, int size)
7135 if(active && !style.interim && isEnabled)
7137 if(visible || !guiApp.caretOwner)
7138 guiApp.caretOwner = size ? this : null;
7140 UpdateCaret(false, false);
7143 guiApp.interfaceDriver.SetCaret(0,0,0);
7144 UpdateCaret(false, true);
7145 guiApp.caretEnabled = false;
7148 else if(style.inactive && active)
7150 guiApp.interfaceDriver.SetCaret(0,0,0);
7151 UpdateCaret(false, true);
7152 guiApp.caretEnabled = false;
7157 void Scroll(int x, int y)
7159 bool opaque = !style.drawBehind || background.a;
7160 if(opaque && display && display.flags.scrolling)
7162 Box box = clientArea;
7163 box.left += clientStart.x;
7164 box.top += clientStart.y;
7165 box.right += clientStart.x;
7166 box.bottom += clientStart.y;
7168 //scrollExtent.Free(null);
7169 scrollExtent.AddBox(box);
7170 scrolledArea.x += x;
7171 scrolledArea.y += y;
7173 //scrollExtent.Free();
7174 //scrollExtent.AddBox(clientArea);
7175 //scrollExtent.Offset(clientStart.x, clientStart.y);
7176 //scrolledArea.x = x;
7177 //scrolledArea.y = y;
7183 rootWindow.dirty = true;
7186 void ReleaseCapture()
7188 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7190 Window oldCaptured = guiApp.windowCaptured;
7191 guiApp.windowCaptured = null;
7192 guiApp.prevWindow = null;
7195 //guiApp.Log("Released Capture\n");
7197 guiApp.interfaceDriver.SetMouseCapture(null);
7199 //oldCaptured.OnMouseCaptureLost();
7202 oldCaptured.ConsequentialMouseMove(false);
7207 private void _SetCaption(const char * format, va_list args)
7214 char caption[MAX_F_STRING];
7215 vsnprintf(caption, sizeof(caption), format, args);
7216 caption[sizeof(caption)-1] = 0;
7218 this.caption = CopyString(caption);
7223 firewatchers caption;
7227 /*deprecated*/ void SetText(const char * format, ...)
7230 va_start(args, format);
7231 _SetCaption(format, args);
7235 void SetCaption(const char * format, ...)
7238 va_start(args, format);
7239 _SetCaption(format, args);
7243 bool Grab(Bitmap bitmap, Box box, bool decorations)
7245 bool result = false;
7246 if(display || this == guiApp.desktop)
7248 Box clip = {MININT, MININT, MAXINT, MAXINT};
7254 clip.Clip(clientArea);
7256 clip.Clip(this.box);
7258 if(rootWindow != this)
7260 clip.left += absPosition.y;
7261 clip.top += absPosition.y;
7262 clip.right += absPosition.x;
7263 clip.bottom += absPosition.y;
7266 clip.left += decorations ? 0 : clientStart.x;
7267 clip.top += decorations ? 0 : clientStart.y;
7268 clip.right += decorations ? 0 : clientStart.x;
7269 clip.bottom += decorations ? 0 : clientStart.y;
7271 if(display && display.flags.flipping)
7273 rootWindow.Update(null);
7274 rootWindow.UpdateDisplay();
7281 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7282 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7286 result = display.Grab(bitmap, clip.left, clip.top,
7287 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7289 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7291 if(!bitmap.Convert(null, pixelFormat888, null))
7298 void GetMousePosition(int * x, int * y)
7300 int mouseX = 0, mouseY = 0;
7301 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7304 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7305 if(this != guiApp.desktop)
7307 mouseX -= absPosition.x + clientStart.x;
7308 mouseY -= absPosition.y + clientStart.y;
7315 DialogResult DoModal()
7317 DialogResult returnCode = 0;
7318 int terminated = terminateX;
7321 while(!destroyed && guiApp.driver != null)
7323 if(terminateX != terminated)
7325 terminated = terminateX;
7326 guiApp.desktop.Destroy(0);
7327 if(guiApp.desktop.created)
7330 //printf("Resetting terminate X to 0\n");
7336 guiApp.UpdateDisplay();
7337 if(!guiApp.ProcessInput(false))
7340 returnCode = this.returnCode;
7353 return !destroyed && guiApp.driver != null && terminateX < 2;
7356 DialogResult DoModalEnd()
7358 DialogResult returnCode = this.returnCode;
7363 // --- Window manipulation ---
7364 /*bool GetDisabled()
7366 bool disabled = this.disabled;
7368 for(window = this; (window = window.master); )
7379 // --- Mouse Manipulation ---
7380 void GetNCMousePosition(int * x, int * y)
7382 GetMousePosition(x, y);
7383 if(x) *x += clientStart.x;
7384 if(y) *y += clientStart.y;
7387 // --- Carets manipulation ---
7388 void GetCaretPosition(Point caretPos)
7390 caretPos = this.caretPos;
7393 int GetCaretSize(void)
7398 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7404 bool CloseConfirmation(bool parentClosing)
7417 if(!OnClose(parentClosing))
7420 // If you want to skip this, simply set modifiedDocument to false in OnClose
7421 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7423 DialogResult dialogRes;
7426 sprintf(message, $"Save changes to %s?", fileName);
7428 sprintf(message, $"Save changes to Untitled %d?", documentID);
7430 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7432 if(dialogRes == yes)
7434 // TOFIX: Precomp error if brackets are taken out
7435 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7437 else if(dialogRes == cancel)
7443 for(slave = slaves.first; slave; slave = slave.next)
7445 Window w = slave.data;
7446 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7454 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7457 for(child = children.first; child; child = child.next)
7458 if(child.isActiveClient && !child.CloseConfirmation(true))
7466 for(child = children.first; child; child = child.next)
7467 if(!child.isActiveClient && !child.CloseConfirmation(true))
7477 // Static methods... move them somewhere else?
7478 void ::RestoreCaret()
7480 if(guiApp.caretOwner)
7481 guiApp.caretOwner.UpdateCaret(false, false);
7484 void ::FreeMouseRange()
7486 guiApp.interfaceDriver.SetMouseRange(null, null);
7490 bool MenuFileClose(MenuItem selection, Modifiers mods)
7492 Window document = activeChild;
7494 document.Destroy(0);
7498 bool MenuFileExit(MenuItem selection, Modifiers mods)
7504 bool MenuFileSave(MenuItem selection, Modifiers mods)
7509 fileMonitor.fileName = null;
7512 if(OnSaveFile(fileName))
7514 //if(OnFileModified != Window::OnFileModified)
7517 fileMonitor.fileName = fileName;
7523 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7524 DialogResult answer = dialog.Modal();
7526 if(answer != yes) return (bool)answer;
7529 return MenuFileSaveAs(selection, mods);
7532 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7534 DialogResult result = (DialogResult)bool::true;
7535 FileDialog fileDialog = saveDialog;
7540 fileDialog = FileDialog {};
7545 fileDialog.filePath = fileName;
7548 char filePath[MAX_FILENAME];
7549 sprintf(filePath, "Untitled %d", documentID);
7550 fileDialog.filePath = filePath;
7552 fileMonitor.fileName = null;
7554 fileDialog.type = save;
7555 fileDialog.text = $"Save As";
7559 fileDialog.master = master.parent ? master : this;
7560 if(fileDialog.Modal() == ok)
7562 const char * filePath = fileDialog.filePath;
7564 if(OnSaveFile(filePath))
7567 property::fileName = filePath;
7568 NotifySaved(master, this, filePath);
7573 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7574 DialogResult answer = dialog.Modal();
7589 //if(OnFileModified != Window::OnFileModified && fileName)
7592 fileMonitor.fileName = fileName;
7596 return (bool)result; // Actually returning result from Yes/NoCancel message box
7599 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7601 Window document = activeChild;
7603 for(document = children.first; document; document = next)
7605 next = document.next;
7606 if(document.style.isDocument || document.fileName)
7607 document.MenuFileSave(selection, mods);
7612 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7616 for(document = children.first; document; document = document.next)
7617 //if(document.style.isDocument && document.state == minimized)
7618 if(document.style.isActiveClient && document.state == minimized)
7619 document.SetState(minimized, false, mods);
7623 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7625 Window document = activeChild;
7628 Window firstDocument = null;
7630 OldLink cycle = document.cycle.prev;
7635 if(child.style.isActiveClient && !child.style.hidden)
7639 firstDocument = child;
7640 if(child.state == minimized)
7641 child.SetState(minimized, false, mods);
7644 child.positionID = id++;
7645 child.SetState(normal, false, mods);
7646 child.anchor.left.type = cascade;
7649 child.normalSizeAnchor = *&child.sizeAnchor;
7650 child.normalAnchor = child.anchor;
7652 // Break the anchors for moveable/resizable windows
7653 if(child.style.fixed)
7655 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7657 (*&child.normalAnchor).left = x;
7658 (*&child.normalAnchor).top = y;
7659 (*&child.normalAnchor).right.type = none;
7660 (*&child.normalAnchor).bottom.type = none;
7661 (*&child.normalSizeAnchor).isClientW = false;
7662 (*&child.normalSizeAnchor).isClientH = false;
7663 (*&child.normalSizeAnchor).size.w = w;
7664 (*&child.normalSizeAnchor).size.h = h;
7665 child.anchored = false;
7668 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7670 child.stateAnchor = child.normalAnchor;
7671 child.stateSizeAnchor = child.normalSizeAnchor;
7673 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7674 child.Position(x, y, w, h, true, true, true, true, false, false);
7679 last = children.last;
7680 if(!child.style.stayOnTop)
7681 for(; last && last.style.stayOnTop; last = last.prev);
7682 children.Move(child, last);
7683 childrenOrder.Move(child.order, childrenOrder.last);
7685 if(cycle == document.cycle) break;
7689 firstDocument.Activate();
7694 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7701 // Close all closes all active clients, not all documents
7702 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7704 Window next, document;
7706 for(document = children.first; document; document = next)
7708 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7709 if(document.style.isActiveClient)
7710 if(!document.Destroy(0) && !document.style.hidden)
7716 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7718 if(style.hasMaximize && state != maximized)
7719 SetState(maximized, 0, 0);
7723 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7725 if(style.hasMinimize && state != minimized)
7727 SetState(minimized, 0, 0);
7728 parent.CycleChildren(false, true, false, true);
7733 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7735 MenuMoveOrSize(false, selection ? true : false);
7739 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7741 CycleChildren(false, true, false, true);
7745 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7747 CycleChildren(true, true, false, true);
7751 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7753 MenuMoveOrSize(true, true);
7757 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7760 SetState(normal, 0, 0);
7764 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7767 int64 id = selection.id;
7768 OldLink cycle = activeClient.cycle;
7770 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7773 Window sibling = cycle.data;
7774 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7782 document = cycle.data;
7783 document.Activate();
7785 //if(activeChild.state == maximized)
7786 // document.SetState(maximized, false, mods);
7787 //else if(document.state == minimized)
7788 // document.SetState(normal, false, mods);
7792 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7794 stayOnTop = !style.stayOnTop;
7798 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7800 Window document = activeChild;
7803 Window firstDocument = null;
7804 OldLink cycle = document.cycle;
7808 Window child = cycle.data;
7809 if(child.style.isActiveClient && !child.style.hidden)
7811 if(!firstDocument) firstDocument = child;
7812 if(child.state == minimized)
7813 child.SetState(minimized, false, mods);
7816 child.positionID = id++;
7817 child.SetState(normal, false, mods);
7818 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7820 child.anchor.left.type = hTiled;
7823 child.normalSizeAnchor = *&child.sizeAnchor;
7824 child.normalAnchor = child.anchor;
7826 // Break the anchors for moveable/resizable windows
7827 if(child.style.fixed)
7829 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7831 (*&child.normalAnchor).left = x;
7832 (*&child.normalAnchor).top = y;
7833 (*&child.normalAnchor).right.type = none;
7834 (*&child.normalAnchor).bottom.type = none;
7835 (*&child.normalSizeAnchor).isClientW = false;
7836 (*&child.normalSizeAnchor).isClientH = false;
7837 (*&child.normalSizeAnchor).size.w = w;
7838 (*&child.normalSizeAnchor).size.h = h;
7839 child.anchored = false;
7842 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7844 child.stateAnchor = child.normalAnchor;
7845 child.stateSizeAnchor = child.normalSizeAnchor;
7847 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7848 child.Position(x,y, w, h, true, true, true, true, false, true);
7853 if((cycle = cycle.next) == document.cycle) break;
7856 firstDocument.Activate();
7861 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7863 Window document = activeChild;
7866 Window firstDocument = null;
7868 OldLink cycle = document.cycle;
7873 //if(child.style.isDocument)
7874 if(child.style.isActiveClient && !child.style.hidden)
7876 if(!firstDocument) firstDocument = child;
7877 if(child.state == minimized)
7878 child.SetState(minimized, false, mods);
7881 child.positionID = id++;
7882 child.SetState(normal, false, mods);
7883 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7885 child.anchor.left.type = vTiled;
7888 child.normalSizeAnchor = *&child.sizeAnchor;
7889 child.normalAnchor = child.anchor;
7891 // Break the anchors for moveable/resizable windows
7892 if(child.style.fixed)
7894 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7896 (*&child.normalAnchor).left = x;
7897 (*&child.normalAnchor).top = y;
7898 (*&child.normalAnchor).right.type = none;
7899 (*&child.normalAnchor).bottom.type = none;
7900 (*&child.normalSizeAnchor).isClientW = false;
7901 (*&child.normalSizeAnchor).isClientH = false;
7902 (*&child.normalSizeAnchor).size.w = w;
7903 (*&child.normalSizeAnchor).size.h = h;
7904 child.anchored = false;
7907 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7909 child.stateAnchor = child.normalAnchor;
7910 child.stateSizeAnchor = child.normalSizeAnchor;
7912 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7913 child.Position(x,y, w, h, true, true, true, true, false, true);
7918 if((cycle = cycle.next) == document.cycle) break;
7921 firstDocument.Activate();
7926 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7928 WindowList dialog { master = this };
7929 Window document = (Window)(intptr)dialog.Modal();
7932 if(activeChild.state == maximized)
7933 document.SetState(maximized, false, mods);
7934 else if(document.state == minimized)
7935 document.SetState(normal, false, mods);
7936 document.Activate();
7942 virtual bool OnCreate(void);
7943 virtual void OnDestroy(void);
7944 virtual void OnDestroyed(void);
7945 virtual bool OnClose(bool parentClosing);
7946 virtual bool OnStateChange(WindowState state, Modifiers mods);
7947 virtual bool OnPostCreate(void);
7948 virtual bool OnMoving(int *x, int *y, int w, int h);
7949 virtual bool OnResizing(int *width, int *height);
7950 virtual void OnResize(int width, int height);
7951 virtual void OnPosition(int x, int y, int width, int height);
7952 virtual bool OnLoadGraphics(void);
7953 virtual void OnApplyGraphics(void);
7954 virtual void OnUnloadGraphics(void);
7955 virtual void OnRedraw(Surface surface);
7956 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7957 virtual void OnActivateClient(Window client, Window previous);
7958 virtual bool OnKeyDown(Key key, unichar ch);
7959 virtual bool OnKeyUp(Key key, unichar ch);
7960 virtual bool OnKeyHit(Key key, unichar ch);
7961 virtual bool OnSysKeyDown(Key key, unichar ch);
7962 virtual bool OnSysKeyUp(Key key, unichar ch);
7963 virtual bool OnSysKeyHit(Key key, unichar ch);
7964 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7965 virtual bool OnMouseLeave(Modifiers mods);
7966 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7967 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7968 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7969 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7970 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7971 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7972 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7973 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7974 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7975 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7976 virtual bool OnMultiTouch(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods);
7977 virtual void OnMouseCaptureLost(void);
7978 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7979 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7980 virtual void OnDrawOverChildren(Surface surface);
7981 virtual bool OnFileModified(FileChange fileChange, const char * param);
7982 virtual bool OnSaveFile(const char * fileName);
7984 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7985 // Note: A 'client' would refer to isActiveClient, rather than
7986 // being confined to the 'client area' (nonClient == false)
7987 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7988 virtual void OnChildVisibilityToggled(Window child, bool visible);
7989 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7991 // Skins Virtual Functions
7992 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7993 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7994 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7999 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8000 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
8001 virtual bool IsMouseMoving(int x, int y, int w, int h)
8005 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
8009 virtual void UpdateNonClient();
8010 virtual void SetBox(Box box); // This is used in the MySkin skin
8011 virtual bool IsInside(int x, int y)
8013 return box.IsPointInside({x, y});
8015 virtual bool IsOpaque()
8017 return (!style.drawBehind || background.a == 255);
8021 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
8022 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
8023 virtual void Window::NotifySaved(Window window, const char * filePath);
8028 property Window parent
8030 property_category $"Layout"
8033 if(value || guiApp.desktop)
8036 Window oldParent = parent;
8037 Anchor anchor = this.anchor;
8039 if(value && value.IsDescendantOf(this)) return;
8040 if(value && value == this)
8042 if(!value) value = guiApp.desktop;
8044 if(value == oldParent) return;
8046 if(!master || (master == this.parent && master == guiApp.desktop))
8047 property::master = value;
8051 parent.children.Remove(this);
8055 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8056 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
8057 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8058 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8062 last = value.children.last;
8064 if(style.isDocument)
8067 parent.numDocuments--;
8068 documentID = value.GetDocumentID();
8071 if(style.isActiveClient && !style.hidden)
8073 if(parent && parent != guiApp.desktop && !(style.hidden))
8075 if(state == minimized) parent.numIcons--;
8076 parent.numPositions--;
8080 if(!style.stayOnTop)
8081 for(; last && last.style.stayOnTop; last = last.prev);
8083 value.children.Insert(last, this);
8085 // *** NEW HERE: ***
8087 parent.childrenCycle.Delete(cycle);
8089 parent.childrenOrder.Delete(order);
8092 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8093 // Should something else be done?
8094 if(parent && parent.activeChild == this)
8095 parent.activeChild = null;
8096 if(parent && parent.activeClient == this)
8097 parent.activeClient = null;
8103 int x = position.x, y = position.y, w = size.w, h = size.h;
8107 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8108 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8110 vpw = value.clientSize.w;
8111 vph = value.clientSize.h;
8117 else if(style.fixed)
8119 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8120 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8123 anchor = this.anchor;
8125 if(anchor.left.type == offset) anchor.left.distance = x;
8126 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8127 if(anchor.top.type == offset) anchor.top.distance = y;
8128 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8129 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8130 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8131 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8132 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8133 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8134 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8136 if(!anchor.left.type && !anchor.right.type)
8138 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8139 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8141 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8142 if(!anchor.top.type && !anchor.bottom.type)
8144 anchor.vert.distance = (y + h / 2) - (vph / 2);
8145 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8147 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8150 parent.OnChildAddedOrRemoved(this, false);
8156 parent.childrenCycle.Insert(
8157 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8158 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8160 cycle = OldLink { data = this });
8161 parent.childrenOrder.Insert(
8162 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8163 order = OldLink { data = this });
8166 if(!style.hidden && style.isActiveClient)
8168 positionID = parent.GetPositionID(this);
8169 parent.numPositions++;
8170 if(state == minimized) parent.numIcons--;
8173 // *** FONT INHERITANCE ***
8174 if(!setFont && oldParent)
8175 stopwatching(oldParent, font);
8179 RemoveResource(systemFont);
8182 // TESTING WITH WATCHERS:
8183 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8184 // usedFont = setFont ? setFont : (systemFont);
8188 if(guiApp.currentSkin)
8190 systemFont = guiApp.currentSkin.SystemFont();
8193 usedFont = systemFont;
8194 AddResource(systemFont);
8202 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8211 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8213 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8214 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8217 UnloadGraphics(false);
8220 LoadGraphics(false, false);
8223 if(value.rootWindow != rootWindow)
8224 DisplayModeChanged();
8228 scrolledPos.x = MININT; // Prevent parent update
8230 bool anchored = this.anchored;
8231 property::anchor = anchor;
8232 this.anchored = anchored;
8237 if(guiApp.currentSkin)
8238 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8240 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8241 Position(x, y, w, h, true, true, true, true, false, true);
8246 // else parent = value;
8248 oldParent.OnChildAddedOrRemoved(this, true);
8251 get { return parent; }
8254 property Window master
8256 property_category $"Behavior"
8259 //if(this == value) return;
8260 if(value && value.IsSlaveOf(this)) return;
8266 OldLink slaveHolder;
8267 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8268 if(slaveHolder.data == this)
8270 master.slaves.Delete(slaveHolder);
8277 value.slaves.Add(OldLink { data = this });
8282 master.hotKeys.Remove(hotKey);
8283 value.hotKeys.Add(hotKey);
8286 if(master && master.defaultControl == this)
8287 master.defaultControl = null;
8289 if(style.isDefault && !value.defaultControl)
8290 value.defaultControl = this;
8295 get { return master ? master : parent; }
8298 property const char * caption
8300 property_category $"Appearance"
8307 caption = new char[strlen(value)+1];
8309 strcpy(caption, value);
8314 get { return caption; }
8319 property_category $"Behavior"
8328 master.hotKeys.Add(hotKey = HotKeySlot { });
8332 hotKey.window = this;
8337 master.hotKeys.Delete(hotKey);
8342 get { return hotKey ? hotKey.key : 0; }
8345 property Color background
8347 property_category $"Appearance"
8350 background.color = value;
8355 if(this == rootWindow)
8356 guiApp.interfaceDriver.SetRootWindowColor(this);
8359 get { return background.color; }
8362 property Percentage opacity
8364 property_category $"Appearance"
8367 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8368 drawBehind = (background.a == 255) ? false : true;
8370 get { return background.a / 255.0f; }
8373 property Color foreground
8375 property_category $"Appearance"
8383 get { return foreground; }
8386 property BorderStyle borderStyle
8388 property_category $"Appearance"
8391 if(!((BorderBits)value).fixed)
8393 style.hasClose = false;
8394 style.hasMaximize = false;
8395 style.hasMinimize = false;
8396 nativeDecorations = false;
8398 style.borderBits = value;
8402 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8404 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8405 Position(x, y, w, h, true, true, true, true, false, true);
8406 CreateSystemChildren();
8409 get { return (BorderStyle)style.borderBits; }
8412 property Size minClientSize
8414 property_category $"Layout"
8415 set { minSize = value; }
8416 get { value = minSize; }
8419 property Size maxClientSize
8421 property_category $"Layout"
8422 set { maxSize = value; }
8423 get { value = maxSize; }
8426 property bool hasMaximize
8428 property_category $"Window Style"
8431 style.hasMaximize = value;
8432 if(value) { style.fixed = true; style.contour = true; }
8436 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8438 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8439 Position(x, y, w, h, true, true, true, true, false, true);
8441 CreateSystemChildren();
8444 get { return style.hasMaximize; }
8447 property bool hasMinimize
8449 property_category $"Window Style"
8452 style.hasMinimize = value;
8453 if(value) { style.fixed = true; style.contour = true; }
8457 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8459 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8460 Position(x, y, w, h, true, true, true, true, false, true);
8462 CreateSystemChildren();
8465 get { return style.hasMinimize; }
8468 property bool hasClose
8470 property_category $"Window Style"
8473 style.hasClose = value;
8474 if(value) { style.fixed = true; style.contour = true; }
8478 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8479 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8480 Position(x, y, w, h, true, true, true, true, false, true);
8481 CreateSystemChildren();
8484 get { return style.hasClose; }
8487 property bool nonClient
8489 property_category $"Layout"
8492 style.nonClient = value;
8494 style.stayOnTop = true;
8496 get { return style.nonClient; }
8499 property bool inactive
8501 property_category $"Behavior"
8506 // *** NEW HERE: ***
8510 parent.childrenCycle.Delete(cycle);
8512 parent.childrenOrder.Delete(order);
8519 active = false; // true;
8520 if(parent.activeChild == this)
8521 parent.activeChild = null;
8522 if(parent.activeClient == this)
8523 parent.activeClient = null;
8532 parent.childrenCycle.Insert(
8533 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8534 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8536 cycle = OldLink { data = this });
8538 parent.childrenOrder.Insert(
8539 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8540 order = OldLink { data = this });
8543 style.inactive = value;
8545 get { return style.inactive; }
8548 property bool clickThrough
8550 property_category $"Behavior"
8551 set { style.clickThrough = value; }
8552 get { return style.clickThrough; }
8555 property bool isRemote
8557 property_category $"Behavior"
8558 set { style.isRemote = value; }
8559 get { return style.isRemote; }
8562 property bool noCycle
8564 property_category $"Behavior"
8565 set { style.noCycle = value; }
8566 get { return style.noCycle; }
8569 property bool isModal
8571 property_category $"Behavior"
8572 set { style.modal = value; }
8573 get { return style.modal; }
8576 property bool interim
8578 property_category $"Behavior"
8579 set { style.interim = value; }
8580 get { return style.interim; }
8583 property bool tabCycle
8585 property_category $"Behavior"
8586 set { style.tabCycle = value; }
8587 get { return style.tabCycle; }
8590 property bool isDefault
8592 property_category $"Behavior"
8600 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8601 if(sibling != this && sibling.style.isDefault)
8602 sibling.style.isDefault = false;*/
8603 if(master.defaultControl)
8604 master.defaultControl.style.isDefault = false;
8605 master.defaultControl = this;
8607 else if(master.defaultControl == this)
8608 master.defaultControl = null;
8612 style.isDefault = value;
8614 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8616 get { return style.isDefault; }
8619 property bool drawBehind
8621 property_category $"Window Style"
8622 set { style.drawBehind = value; }
8623 get { return style.drawBehind; }
8626 property bool hasMenuBar
8628 property_category $"Window Style"
8638 if(created && !menuBar)
8645 anchor = Anchor { top = 23, left = 1, right = 1 },
8647 inactive = true, nonClient = true
8652 else if(created && menuBar)
8657 style.hasMenuBar = value;
8659 get { return style.hasMenuBar; }
8662 property bool hasStatusBar
8664 property_category $"Window Style"
8671 statusBar = StatusBar { this };
8679 style.hasStatusBar = value;
8681 get { return style.hasStatusBar; }
8683 property bool stayOnTop
8685 property_category $"Window Style"
8690 if(created && !style.stayOnTop)
8692 if(rootWindow == this)
8693 guiApp.interfaceDriver.OrderRootWindow(this, true);
8694 else if(parent.children.last != this)
8696 parent.children.Move(this, parent.children.last);
8700 style.stayOnTop = true;
8704 if(created && style.stayOnTop)
8706 if(rootWindow == this)
8707 guiApp.interfaceDriver.OrderRootWindow(this, false);
8714 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8715 order && ((Window)order.data).style.stayOnTop;
8716 order = (order == parent.childrenOrder.first) ? null : order.prev);
8717 last = order ? order.data : null;
8721 for(last = parent.children.last;
8722 last && last.style.stayOnTop;
8726 parent.children.Move(this, last);
8730 style.stayOnTop = false;
8733 get { return style.stayOnTop; }
8738 property_category $"Window Style"
8748 if(menuBar && !value)
8755 if(!menuBar && style.hasMenuBar && value)
8759 this, menu = value, isMenuBar = true,
8760 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8761 inactive = true, nonClient = true
8765 UpdateActiveDocument(null);
8768 get { return menu; }
8771 property FontResource font
8773 property_category $"Appearance"
8775 isset { return setFont ? true : false; }
8780 if(value && !setFont) { stopwatching(parent, font); }
8781 else if(!value && setFont)
8787 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8796 RemoveResource(setFont);
8801 RemoveResource(systemFont);
8808 AddResource(setFont);
8811 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8814 systemFont = guiApp.currentSkin.SystemFont();
8816 usedFont = systemFont;
8817 AddResource(systemFont);
8825 get { return usedFont; }
8828 property SizeAnchor sizeAnchor
8830 property_category $"Layout"
8833 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8834 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8835 sizeAnchor.isClientW != sizeAnchor.isClientH;
8842 normalSizeAnchor = sizeAnchor;
8844 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8846 stateAnchor = normalAnchor;
8847 stateSizeAnchor = normalSizeAnchor;
8849 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8850 Position(x,y, w, h, true, true, true, true, false, true);
8857 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8858 sizeAnchor.isClientW,
8859 sizeAnchor.isClientH
8866 property_category $"Layout"
8869 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8870 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8871 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8877 sizeAnchor.isClientW = false;
8878 sizeAnchor.isClientH = false;
8879 sizeAnchor.size = value;
8881 normalSizeAnchor = sizeAnchor;
8883 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8885 stateAnchor = normalAnchor;
8886 stateSizeAnchor = normalSizeAnchor;
8888 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8889 Position(x, y, w, h, true, true, true, true, false, true);
8890 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8893 get { value = size; }
8896 property Size clientSize
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;
8908 sizeAnchor.isClientW = true;
8909 sizeAnchor.isClientH = true;
8910 sizeAnchor.size = value;
8912 normalSizeAnchor = sizeAnchor;
8914 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8916 stateAnchor = normalAnchor;
8917 stateSizeAnchor = normalSizeAnchor;
8919 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8920 Position(x,y, w, h, true, true, true, true, false, true);
8921 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8924 get { value = this ? clientSize : { 0, 0 }; }
8927 property Size initSize { get { value = sizeAnchor.size; } };
8929 property Anchor anchor
8931 property_category $"Layout"
8932 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8938 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8940 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8941 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8943 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8945 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8946 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8950 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8952 anchor.left.distance = 0;
8953 anchor.horz.type = 0;
8955 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8957 anchor.top.distance = 0;
8958 anchor.vert.type = 0;
8967 normalAnchor = anchor;
8969 // Break the anchors for moveable/resizable windows
8970 /*if(style.fixed ) //&& value.left.type == cascade)
8972 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8974 this.anchor = normalAnchor = Anchor { left = x, top = y };
8975 normalSizeAnchor = SizeAnchor { { w, h } };
8978 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8980 stateAnchor = normalAnchor;
8981 stateSizeAnchor = normalSizeAnchor;
8983 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8984 Position(x, y, w, h, true, true, true, true, false, true);
8993 get { value = this ? anchor : Anchor { }; }
8996 property Point position
8998 property_category $"Layout"
9001 if(value == null) return;
9003 anchor.left = value.x;
9004 anchor.top = value.y;
9005 anchor.right.type = none;
9006 anchor.bottom.type = none;
9011 normalAnchor = anchor;
9013 // Break the anchors for moveable/resizable windows
9017 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9019 normalAnchor.left = x;
9020 normalAnchor.top = y;
9021 normalAnchor.right.type = none;
9022 normalAnchor.bottom.type = none;
9023 normalSizeAnchor.size.width = w;
9024 normalSizeAnchor.size.height = h;
9028 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9030 stateAnchor = normalAnchor;
9031 stateSizeAnchor = normalSizeAnchor;
9033 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9034 Position(x,y, w, h, true, true, true, true, false, true);
9038 get { value = position; }
9041 property bool disabled
9043 property_category $"Behavior"
9046 if(this && disabled != value)
9053 get { return (bool)disabled; }
9056 property bool isEnabled
9061 for(parent = this; parent; parent = parent.parent)
9068 property WindowState state
9070 property_category $"Behavior"
9071 set { SetState(value, false, 0); }
9072 get { return this ? state : 0; }
9075 property bool visible
9077 property_category $"Behavior"
9080 if(this && !value && !style.hidden && parent)
9082 bool wasActiveChild = parent.activeChild == this;
9083 Window client = null;
9085 style.hidden = true;
9086 if(style.isActiveClient)
9088 parent.numPositions--;
9089 if(state == minimized) parent.numIcons--;
9094 OldLink prevOrder = null;
9096 if(rootWindow == this)
9097 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9100 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9103 box.left -= parent.clientStart.x;
9104 box.top -= parent.clientStart.y;
9105 box.right -= parent.clientStart.x;
9106 box.bottom -= parent.clientStart.y;
9110 if(_isModal && master && master.modalSlave == this)
9111 master.modalSlave = null;
9115 OldLink tmpPrev = order.prev;
9116 client = tmpPrev ? tmpPrev.data : null;
9117 if(client && !client.style.hidden && !client.destroyed && client.created)
9118 prevOrder = tmpPrev;
9121 client = tmpPrev ? tmpPrev.data : null;
9122 if(client == this) { client = null; break; }
9123 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9125 tmpPrev = client.order.prev;
9130 prevOrder = tmpPrev;
9135 // If this window can be an active client, make sure the next window we activate can also be one
9136 if(!style.nonClient && style.isActiveClient)
9138 tmpPrev = prevOrder;
9141 client = tmpPrev ? tmpPrev.data : null;
9142 if(client == this) { client = null; break; }
9143 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9145 tmpPrev = client.order.prev;
9150 prevOrder = tmpPrev;
9154 if(client && client.style.hidden) client = null;
9158 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9160 if(order && prevOrder && prevOrder.data != this)
9161 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9163 ActivateEx(false, false, false, true, null, null);
9165 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9166 if(parent.activeClient == this)
9168 parent.activeClient = null;
9169 parent.UpdateActiveDocument(null);
9172 else if(parent.activeClient == this)
9174 parent.activeClient = client;
9175 parent.UpdateActiveDocument(this);
9178 // *** Not doing this anymore ***
9181 parent.childrenCycle.Delete(cycle);
9183 parent.childrenOrder.Delete(order);
9188 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9193 else if(this && value && style.hidden)
9195 style.hidden = false;
9198 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9199 if(rootWindow == this)
9200 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9202 if(_isModal && master)
9203 master.modalSlave = this;
9205 if(style.isActiveClient)
9207 positionID = parent.GetPositionID(this);
9208 parent.numPositions++;
9209 if(state == minimized) parent.numIcons++;
9212 // *** NOT DOING THIS ANYMORE ***
9214 if(!(style.inactive))
9216 if(!(style.noCycle))
9218 cycle = parent.childrenCycle.AddAfter(
9219 (parent.activeChild && parent.activeChild.cycle) ?
9220 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9223 order = parent.childrenOrder.AddAfter(
9224 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9231 if(true || !parent.activeChild)
9232 ActivateEx(true, false, true, true, null, null);
9234 if(creationActivation == activate && guiApp.desktop.active)
9235 ActivateEx(true, false, true, true, null, null);
9236 else if((creationActivation == activate || creationActivation == flash) && !object)
9239 if(this == rootWindow)
9243 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9247 ConsequentialMouseMove(false);
9253 style.hidden = !value;
9256 get { return (style.hidden || !setVisible) ? false : true; }
9259 property bool isDocument
9261 property_category $"Document"
9262 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9263 get { return style.isDocument; }
9266 property bool mergeMenus
9268 property_category $"Window Style"
9269 set { mergeMenus = value; }
9270 get { return (bool)mergeMenus; }
9273 property bool hasHorzScroll
9275 property_category $"Window Style"
9280 if(!style.hasHorzScroll && created)
9282 CreateSystemChildren();
9283 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9286 else if(style.hasHorzScroll)
9290 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9292 style.hasHorzScroll = value;
9295 get { return style.hasHorzScroll; }
9298 property bool hasVertScroll
9300 property_category $"Window Style"
9305 if(!style.hasVertScroll && created)
9307 style.hasVertScroll = true;
9308 CreateSystemChildren();
9309 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9312 else if(style.hasVertScroll)
9316 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9318 style.hasVertScroll = value;
9320 get { return style.hasVertScroll; }
9323 property bool dontHideScroll
9325 property_category $"Behavior"
9328 scrollFlags.dontHide = value;
9331 //UpdateScrollBars(true, true);
9332 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9336 // UpdateScrollBars(true, true);
9337 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9340 get { return scrollFlags.dontHide; }
9343 property bool dontScrollVert
9345 property_category $"Behavior"
9346 set { style.dontScrollVert = value; }
9347 get { return style.dontScrollVert; }
9349 property bool dontScrollHorz
9351 property_category $"Behavior"
9352 set { style.dontScrollHorz = value; }
9353 get { return style.dontScrollHorz; }
9356 property bool snapVertScroll
9358 property_category $"Behavior"
9361 scrollFlags.snapY = value;
9362 if(sbv) sbv.snap = value;
9364 get { return scrollFlags.snapY; }
9366 property bool snapHorzScroll
9368 property_category $"Behavior"
9371 scrollFlags.snapX = value;
9372 if(sbh) sbh.snap = value;
9374 get { return scrollFlags.snapX; }
9377 property Point scroll
9379 property_category $"Behavior"
9380 set { if(this) SetScrollPosition(value.x, value.y); }
9381 get { value = scroll; }
9384 property bool modifyVirtualArea
9386 property_category $"Behavior"
9387 set { modifyVirtArea = value; }
9388 get { return (bool)modifyVirtArea; }
9391 property bool dontAutoScrollArea
9393 property_category $"Behavior"
9394 // Activating a child control out of view will automatically scroll to make it in view
9395 set { noAutoScrollArea = value; }
9396 get { return (bool)noAutoScrollArea; }
9399 property const char * fileName
9401 property_category $"Document"
9406 if(menu && ((!fileName && value) || (fileName && !value)))
9408 MenuItem item = menu.FindItem(MenuFileSave, 0);
9409 if(item) item.disabled = !modifiedDocument && value;
9414 if(value && value[0])
9415 fileName = CopyString(value);
9417 if(parent && this == parent.activeClient)
9418 parent.UpdateActiveDocument(null);
9422 // if(style.isDocument)
9424 fileMonitor.fileName = value;
9426 get { return fileName; }
9431 property_category $"Data"
9436 property bool modifiedDocument
9438 property_category $"Document"
9441 if(style.isDocument || fileName)
9445 MenuItem item = menu.FindItem(MenuFileSave, 0);
9446 if(item) item.disabled = !value && fileName;
9450 if(modifiedDocument != value)
9452 modifiedDocument = value;
9453 if(style.isDocument || fileName)
9457 get { return (bool)modifiedDocument; }
9460 property bool showInTaskBar
9462 property_category $"Window Style"
9465 style.showInTaskBar = value;
9466 #if defined(__WIN32__)
9467 Win32UpdateStyle(this);
9470 get { return style.showInTaskBar; }
9472 property FileDialog saveDialog { set { saveDialog = value; } };
9473 property bool isActiveClient
9475 property_category $"Behavior"
9478 if(parent && style.isActiveClient != value && !style.hidden)
9482 if(state == minimized) parent.numIcons++;
9483 parent.numPositions++;
9487 if(state == minimized) parent.numIcons--;
9488 parent.numPositions--;
9491 style.isActiveClient = value;
9493 get { return style.isActiveClient; }
9496 property Cursor cursor
9498 property_category $"Appearance"
9502 SelectMouseCursor();
9504 get { return cursor; }
9507 //#if !defined(ECERE_VANILLA)
9508 property const char * name
9510 property_category $"Design"
9513 return (this && object) ? object.name : null;
9518 activeDesigner.RenameObject(object, value);
9522 property const char * displayDriver
9524 property_category $"Behavior"
9527 dispDriver = GetDisplayDriver(value);
9528 //DisplayModeChanged();
9532 return dispDriver ? dispDriver.name : null;
9536 // RUNTIME PROPERTIES
9537 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9538 property Size scrollArea
9540 property_category $"Behavior"
9544 SetScrollArea(value.w, value.h, false);
9546 SetScrollArea(0,0, true);
9548 get { value = scrollArea; }
9551 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9556 property_category $"Layout"
9557 set { if(this) is3D = value; }
9558 get { return (bool)is3D; }
9561 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9563 // Will be merged with font later
9564 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9565 property Point clientStart { get { value = clientStart; } };
9566 property Point absPosition { get { value = absPosition; } };
9567 property Anchor normalAnchor { get { value = normalAnchor; } };
9568 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9569 property bool active { get { return (bool)active; } };
9570 property bool created { get { return (bool)created; } };
9571 property bool destroyed { get { return (bool)destroyed; } };
9572 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9573 property Window firstChild { get { return children.first; } };
9574 property Window lastChild { get { return children.last; } };
9575 property Window activeClient { get { return activeClient; } };
9576 property Window activeChild { get { return activeChild; } };
9577 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9578 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9579 property ScrollBar horzScroll { get { return sbh; } };
9580 property ScrollBar vertScroll { get { return sbv; } };
9581 property StatusBar statusBar { get { return statusBar; } };
9582 property Window rootWindow { get { return rootWindow; } };
9583 property bool closing { get { return (bool)closing; } set { closing = value; } };
9584 property int documentID { get { return documentID; } };
9585 property Window previous { get { return prev; } }
9586 property Window next { get { return next; } }
9587 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9588 property PopupMenu menuBar { get { return menuBar; } }
9589 property ScrollBar sbv { get { return sbv; } }
9590 property ScrollBar sbh { get { return sbh; } }
9591 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9592 property void * systemHandle { get { return windowHandle; } }
9593 property Button minimizeButton { get { return sysButtons[0]; } };
9594 property Button maximizeButton { get { return sysButtons[1]; } };
9595 property Button closeButton { get { return sysButtons[2]; } };
9596 property BitmapResource icon
9598 get { return icon; }
9602 if(icon) incref icon;
9604 guiApp.interfaceDriver.SetIcon(this, value);
9607 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9608 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9609 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9610 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9611 property bool nativeDecorations
9613 get { return (bool)nativeDecorations; }
9614 set { nativeDecorations = value; }
9615 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9618 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9619 bool result = false;
9620 if(nativeDecorations)
9622 if(rootWindow == this)
9626 if(formDesigner && activeDesigner)
9628 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9629 Window form = cd ? cd.form : null;
9630 if(form && parent == form.parent)
9635 return result != style.fixed;
9639 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9641 property const char * text
9643 property_category $"Deprecated"
9645 set { property::caption = value; }
9646 get { return property::caption; }
9652 WindowBits style; // Window Style
9653 char * caption; // Name / Caption
9654 Window parent; // Parent window
9655 OldList children; // List of children in Z order
9656 Window activeChild; // Child window having focus
9657 Window activeClient;
9658 Window previousActive; // Child active prior to activating the default child
9659 Window master; // Window owning and receiving notifications concerning this window
9660 OldList slaves; // List of windows belonging to this window
9661 Display display; // Display this window is drawn into
9663 Point position; // Position in parent window client area
9664 Point absPosition; // Absolute position
9665 Point clientStart; // Client area position from (0,0) in this window
9667 Size clientSize; // Client area size
9668 Size scrollArea; // Virtual Scroll area size
9669 Size reqScrollArea; // Requested virtual area size
9670 Point scroll; // Virtual area scrolling position
9671 ScrollBar sbh, sbv; // Scrollbar window handles
9672 Cursor cursor; // Mouse cursor used for this window
9675 StatusBar statusBar;
9676 Button sysButtons[3];
9678 Box clientArea; // Client Area box clipped to parent
9680 HotKeySlot hotKey; // HotKey for this window
9684 ScrollFlags scrollFlags;// Window Scrollbar Flags
9685 int64 id; // Control ID
9687 ColorAlpha background; // Background color used to draw the window area
9689 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9690 OldList childrenCycle; // Cycling order
9691 OldLink cycle; // Element of parent's cycling order
9692 OldList childrenOrder; // Circular Z-Order
9693 OldLink order; // Element of parent's circular Z-Order
9694 Window modalSlave; // Slave window blocking this window's interaction
9696 Window rootWindow; // Topmost system managed window
9697 void * windowHandle; // System window handle
9699 DialogResult returnCode;// Return code for modal windows
9701 Point sbStep; // Scrollbar line scrolling steps
9704 SizeAnchor stateSizeAnchor;
9706 Anchor normalAnchor;
9707 SizeAnchor normalSizeAnchor;
9709 Size skinMinSize; // Minimal window size based on style
9710 Point scrolledPos; // Scrolled position
9711 Box box; // Window box clipped to parent
9712 Box * against; // What to clip the box to
9714 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9715 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9716 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9717 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9718 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9719 Point scrolledArea; // Distance to scroll area by
9720 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9722 OldList hotKeys; // List of the hotkeys of all children
9723 Window defaultControl; // Default child control
9727 ColorAlpha * palette; // Color palette used for this window
9729 int caretSize; // Size of caret, non zero if a caret is present
9730 Point caretPos; // Caret position
9732 void * systemParent; // Parent System Window for embedded windows
9739 WindowState lastState;
9741 FileMonitor fileMonitor;
9743 FontResource setFont, systemFont;
9744 FontResource usedFont;
9745 FontResource captionFont;
9747 FileDialog saveDialog;
9749 SizeAnchor sizeAnchor;
9751 // FormDesigner data
9754 Extent * tempExtents; //[4];
9755 BitmapResource icon;
9757 CreationActivationOption creationActivation;
9760 bool active:1; // true if window and ancestors are active
9761 bool acquiredInput:1; // true if the window is processing state based input
9762 bool modifiedDocument:1;
9763 bool disabled:1; // true if window cannot interact
9764 bool isForegroundWindow:1;// true while a root window is being activated
9765 bool visible:1; // Visibility flag
9766 bool destroyed:1; // true if window is being destroyed
9767 bool anchored:1; // true if this window is repositioned when the parent resizes
9768 bool dirty:1; // Flag set to true if any descendant must be redrawn
9774 bool modifyVirtArea:1;
9775 bool noAutoScrollArea:1;
9778 bool setVisible:1; // FOR FORM DESIGNER
9784 bool useSharedMemory:1;
9787 bool nativeDecorations:1;
9788 bool manageDisplay:1;
9789 bool formDesigner:1; // True if we this is running in the form editor
9790 bool requireRemaximize:1;
9793 // Checks used internally for them not to take effect in FormDesigner
9794 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9795 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9797 WindowController controller;
9799 public property WindowController controller
9801 get { return controller; }
9805 controller.setWindow(null);
9811 controller.setWindow(this);
9817 public class CommonControl : Window
9819 // creationActivation = doNothing;
9822 public property const String toolTip
9824 property_category $"Appearance"
9827 if(created) CommonControl::OnDestroy();
9829 toolTip = value ? ToolTip { tip = value; } : null;
9831 if(created) CommonControl::OnCreate();
9833 get { return toolTip ? toolTip.tip : null; }
9839 // (Very) Ugly work around for the fact that the parent watcher
9840 // won't fire when it's already been disconnected...
9841 eInstance_FireSelfWatchers(toolTip,
9842 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9848 toolTip.parent = this;
9857 public class Percentage : float
9859 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9863 sprintf(string, "%.2f", this);
9864 c = strlen(string)-1;
9867 if(string[c] != '0')
9868 last = Max(last, c);
9869 if(string[c] == '.')
9882 public void ApplySkin(Class c, const char * name, void ** vTbl)
9884 char className[1024];
9889 subclass(Window) wc = (subclass(Window))c;
9890 subclass(Window) base = (subclass(Window))c.base;
9892 sprintf(className, "%sSkin_%s", name, c.name);
9893 wc.pureVTbl = c._vTbl;
9894 c._vTbl = new void *[c.vTblSize];
9895 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9896 sc = eSystem_FindClass(c.module.application, className);
9900 for(m = 0; m < c.base.vTblSize; m++)
9902 if(c._vTbl[m] == base.pureVTbl[m])
9903 c._vTbl[m] = vTbl[m];
9908 for(m = 0; m < c.vTblSize; m++)
9910 if(sc._vTbl[m] != wc.pureVTbl[m])
9911 c._vTbl[m] = sc._vTbl[m];
9915 for(d = c.derivatives.first; d; d = d.next)
9917 ApplySkin(d.data, name, c._vTbl);
9921 public void UnapplySkin(Class c)
9923 subclass(Window) wc = (subclass(Window))c;
9926 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9929 c._vTbl = wc.pureVTbl;
9933 for(d = c.derivatives.first; d; d = d.next)
9935 UnapplySkin(d.data);
9939 void CheckFontIntegrity(Window window)
9944 if(window.usedFont && window.usedFont.font == 0xecececec)
9946 FontResource uf = window.usedFont;
9947 char * className = window._class.name;
9948 char * text = window.text;
9951 for(c = window.firstChild; c; c = c.next)
9952 CheckFontIntegrity(c);
9956 public class ControllableWindow : Window
9958 /*WindowController controller;
9959 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9960 ~ControllableWindow() { delete controller; }*/
9963 class WindowControllerInterface : ControllableWindow
9965 bool OnKeyDown(Key key, unichar ch)
9967 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9970 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9972 result = onKeyDown(controller.window, key, ch);
9977 bool OnKeyUp(Key key, unichar ch)
9979 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
9982 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
9984 result = onKeyUp(controller.window, key, ch);
9989 bool OnKeyHit(Key key, unichar ch)
9991 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
9994 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
9996 result = onKeyHit(controller.window, key, ch);
10001 bool OnMouseMove(int x, int y, Modifiers mods)
10003 bool result = controller.OnMouseMove ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods) : true;
10006 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
10008 result = onMouseMove(controller.window, x, y, mods);
10013 bool OnLeftButtonDown(int x, int y, Modifiers mods)
10015 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10018 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
10019 if(onLeftButtonDown)
10020 result = onLeftButtonDown(controller.window, x, y, mods);
10025 bool OnLeftButtonUp(int x, int y, Modifiers mods)
10027 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10030 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
10032 result = onLeftButtonUp(controller.window, x, y, mods);
10037 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
10039 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10042 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
10043 if(onLeftDoubleClick)
10044 result = onLeftDoubleClick(controller.window, x, y, mods);
10049 bool OnRightButtonDown(int x, int y, Modifiers mods)
10051 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10054 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
10055 if(onRightButtonDown)
10056 result = onRightButtonDown(controller.window, x, y, mods);
10061 bool OnRightButtonUp(int x, int y, Modifiers mods)
10063 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10066 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
10067 if(onRightButtonUp)
10068 result = onRightButtonUp(controller.window, x, y, mods);
10073 bool OnRightDoubleClick(int x, int y, Modifiers mods)
10075 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10078 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
10079 if(onRightDoubleClick)
10080 result = onRightDoubleClick(controller.window, x, y, mods);
10085 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10087 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10090 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10091 if(onMiddleButtonDown)
10092 result = onMiddleButtonDown(controller.window, x, y, mods);
10097 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10099 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10102 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10103 if(onMiddleButtonUp)
10104 result = onMiddleButtonUp(controller.window, x, y, mods);
10109 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10111 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10114 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10115 if(onMiddleDoubleClick)
10116 onMiddleDoubleClick(controller.window, x, y, mods);
10121 bool OnMultiTouch(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods)
10123 bool result = controller.OnMultiTouch ? ((bool(*)(Window, WindowController, TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers))(void *)controller.OnMultiTouch)((Window)controller.controlled, controller, event, infos, mods) : true;
10126 bool(* onMultiTouch)(Window, TouchPointerEvent, Array<TouchPointerInfo>, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMultiTouch];
10128 onMultiTouch(controller.window, event, infos, mods);
10133 void OnResize(int width, int height)
10135 if(controller.OnResize)
10136 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10138 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10140 onResize(controller.window, width, height);
10144 void OnRedraw(Surface surface)
10146 if(controller.OnRedraw)
10147 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10149 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10151 onRedraw(controller.window, surface);
10157 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10160 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10162 result = onCreate(controller.window);
10167 bool OnLoadGraphics()
10169 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10172 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10174 result = onLoadGraphics(controller.window);
10179 void OnUnloadGraphics()
10181 if(controller.OnUnloadGraphics)
10182 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10184 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10185 if(onUnloadGraphics)
10186 onUnloadGraphics(controller.window);
10191 public class WindowController<class V>
10193 void setWindow(Window value)
10195 uint size = class(Window).vTblSize;
10199 windowVTbl = new void *[size];
10200 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10201 if(value._vTbl == value._class._vTbl)
10203 value._vTbl = new void *[value._class.vTblSize];
10204 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10208 for(c = 0; c < size; c++)
10210 void * function = class(WindowControllerInterface)._vTbl[c];
10211 if(function && function != DefaultFunction)
10212 value._vTbl[c] = function;
10214 value._vTbl[c] = windowVTbl[c];
10220 memcpy(window._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10226 property Window window
10228 get { return window; }
10230 property V controlled
10232 set { controlled = value; }
10233 get { return controlled; }
10235 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10236 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10237 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10238 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10239 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10240 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10241 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10242 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10243 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10244 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10245 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10246 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10247 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10248 virtual bool V::OnMultiTouch(WindowController controller, TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers mods);
10249 virtual void V::OnResize(WindowController controller, int width, int height);
10250 virtual void V::OnRedraw(WindowController controller, Surface surface);
10251 virtual bool V::OnCreate(WindowController controller);
10252 virtual bool V::OnLoadGraphics(WindowController controller);
10253 virtual void V::OnUnloadGraphics(WindowController controller);
10256 public int (** windowVTbl)();
10260 ~WindowController()