7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // 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
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data const char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property const char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
571 #if !defined(__EMSCRIPTEN__)
574 int i, lockCount = guiApp.lockMutex.lockCount;
575 for(i = 0; i < lockCount; i++)
576 guiApp.lockMutex.Release();
578 for(i = 0; i < lockCount; i++)
579 guiApp.lockMutex.Wait();
585 stopwatching(parent, font);
586 if(parent.activeChild == this)
587 parent.activeChild = null;
588 if(parent.activeClient == this)
589 parent.activeClient = null;
594 // Prevent destructor from being called again...
600 /////////////////////////////////
603 OldLink slave = master.slaves.FindLink(this);
604 master.slaves.Delete(slave);
611 parent.childrenCycle.Remove(cycle);
613 parent.childrenOrder.Remove(order);
614 parent.children.Remove(this);
619 /////////////////////////////////
621 while((ptr = resources.first))
624 resources.Delete(ptr);
631 for(child = children.first; child; child = child.next)
633 // child.stopwatching(this, font);
635 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
636 // Don't want property here
637 *&child.parent = null;
640 while((slave = slaves.first))
642 // Don't want property here
643 *&((Window)slave.data).master = null;
644 slaves.Delete(slave);
647 // Because we do a decref in DestroyEx...
655 // Why was this commented?
656 //if(this != guiApp.desktop)
666 #if !defined(__EMSCRIPTEN__)
671 if(((subclass(Window))_class).pureVTbl)
673 if(_vTbl == _class._vTbl)
675 _vTbl = ((subclass(Window))_class).pureVTbl;
680 for(m = 0; m < _class.vTblSize; m++)
682 if(_vTbl[m] == _class._vTbl[m])
683 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
687 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
690 dirtyArea.Free(null);
691 renderArea.Free(null);
692 overRenderArea.Free(null);
693 clipExtent.Free(null);
694 scrollExtent.Free(null);
695 dirtyBack.Free(null);
699 tempExtents[0].Free(null);
700 tempExtents[1].Free(null);
701 tempExtents[2].Free(null);
702 tempExtents[3].Free(null);
709 //#if !defined(ECERE_VANILLA)
710 const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
712 if(this == activeDesigner)
716 const char * name = property::name;
717 return name ? name : "";
722 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
723 bool OnGetDataFromString(const char * string)
725 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
728 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
729 this = designer.form;
730 else if(!strcmpi(string, "(Desktop)"))
731 this = activeDesigner;
733 return activeDesigner.FindObject(&this, string);
739 // --- Window updates system ---
741 // Setup a bitmap for Redrawing on client area of Window
742 Surface Redraw(Box box)
744 Surface surface = null;
746 Box clientArea = this.clientArea;
750 mox.left -= clientStart.x;
751 mox.top -= clientStart.y;
752 mox.right -= clientStart.x;
753 mox.bottom -= clientStart.y;
755 mox.Clip(clientArea);
756 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
758 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
760 int x = absPosition.x + clientStart.x;
761 int y = absPosition.y + clientStart.y;
762 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
764 x -= rootWindow.clientStart.x;
765 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
767 if(!guiApp.fullScreenMode || is3D)
769 x -= rootWindow.absPosition.x;
770 y -= rootWindow.absPosition.y;
774 int dx = rootWindow.parent.parent.clientStart.x;
775 int dy = rootWindow.parent.parent.clientStart.y;
776 if(!rootWindow.parent.nativeDecorations)
778 dx += rootWindow.parent.clientStart.x;
779 dy += rootWindow.parent.clientStart.y;
793 surface = display.GetSurface(x, y, mox);
796 surface.width = clientSize.w;
797 surface.height = clientSize.h;
803 // Setup a bitmap for Redrawing on full Window
804 Surface RedrawFull(Box box)
806 Surface surface = null;
814 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
816 int x = absPosition.x;
817 int y = absPosition.y;
818 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
820 x -= rootWindow.clientStart.x;
821 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
823 if(!guiApp.fullScreenMode || is3D)
825 x -= rootWindow.absPosition.x;
826 y -= rootWindow.absPosition.y;
829 int dx = rootWindow.parent.parent.clientStart.x;
830 int dy = rootWindow.parent.parent.clientStart.y;
831 if(!rootWindow.parent.nativeDecorations)
833 dx += rootWindow.parent.clientStart.x;
834 dy += rootWindow.parent.clientStart.y;
848 surface = display.GetSurface(x, y, mox);
851 surface.width = size.w;
852 surface.height = size.h;
858 void FigureCaption(char * caption)
860 Window activeClient = null;
864 strcpy(caption, this.caption);
865 if(style.isDocument || fileName)
867 if(caption[0]) strcat(caption, " - ");
869 strcat(caption, fileName);
873 sprintf(title, "Untitled %d", documentID);
874 strcat(caption, title);
877 strcat(caption, " *");
882 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
884 if(activeClient && activeClient.state == maximized)
886 if(activeClient.caption)
888 if(caption[0]) strcat(caption, " - ");
889 strcat(caption, activeClient.caption);
891 if(activeClient.style.isDocument || activeClient.fileName)
893 if(caption[0]) strcat(caption, " - ");
894 strcat(caption, "[");
895 if(activeClient.fileName)
896 strcat(caption, activeClient.fileName);
900 sprintf(title, "Untitled %d", activeClient.documentID);
901 strcat(caption, title);
903 if(activeClient.modifiedDocument)
904 strcat(caption, " *");
905 strcat(caption, "]");
910 // Code for returning dirty from ScrollDisplay:
912 for(d = 0; d<scrollExtent.count; d++)
914 Box * box = &scrollExtent.boxes[d];
920 Min(box.right, box.left-scroll.x),box.bottom
922 dirtyArea.UnionBox(update);
928 Max(box.left, box.right-scroll.x), box.top,
929 box.right, box.bottom
931 dirtyArea.UnionBox(update);
939 box.right, Min(box.bottom, box.top-scroll.y),
941 dirtyArea.UnionBox(update);
947 box.left, Max(box.top, box.bottom-scroll.y),
948 box.right, box.bottom
950 dirtyArea.UnionBox(update);
955 void UpdateDecorations(void)
957 // TODO: *** TEMPORARY HACK ***
964 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
966 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
968 Update({ -clientStart.x,0, -1, clientSize.h-1 });
970 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
973 // Returns w & h for Position
974 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
976 Window parent = this.parent ? this.parent : guiApp.desktop;
977 int xOffset = 0, yOffset = 0;
978 int vpw = parent ? parent.clientSize.w : 0;
979 int vph = parent ? parent.clientSize.h : 0;
980 int pw = parent ? parent.clientSize.w : 0;
981 int ph = parent ? parent.clientSize.h : 0;
982 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
983 int x = anchor.left.distance, y = anchor.top.distance;
984 float ex = 0, ey = 0;
985 MinMaxValue ew = 0, eh = 0;
987 float cascadeW, cascadeH;
989 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
990 int addX = 0, addY = 0;
992 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
994 Window masterWindow = this;
995 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
998 if(master == guiApp.desktop)
999 masterWindow = guiApp.desktop.activeChild;
1001 masterWindow = master.rootWindow;
1002 if(!masterWindow) masterWindow = this;
1004 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
1005 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
1008 pw = vpw = box.right - box.left + 1;
1010 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
1013 ph = vph = box.bottom - box.top + 1;
1029 vpw = pw = parent.size.w;
1030 vph = ph = parent.size.h;
1032 else if(!style.fixed /*|| style.isDocument*/)
1034 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1035 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1037 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1040 Desktop3D_FixSize(&pw, &ph);
1041 Desktop3D_FixSize(&vpw, &vph);
1044 if(pw < skinMinSize.w) pw = skinMinSize.w;
1045 if(ph < skinMinSize.h) ph = skinMinSize.h;
1046 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1047 if(vph < skinMinSize.h) vph = skinMinSize.h;
1049 // TODO: Must fix what we're snapping
1052 if(anchor.left.type)
1054 SNAPUP(x, textCellW);
1056 else if(anchor.right.type)
1058 SNAPDOWN(x, textCellW);
1063 SNAPUP(y, textCellH);
1065 else if(anchor.bottom.type)
1067 SNAPDOWN(y, textCellH);
1071 // This is required to get proper initial decoration size using native decorations on Windows
1072 #if defined(__WIN32__)
1073 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1074 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1076 GetDecorationsSize(&ew, &eh);
1078 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1080 // Leave room for non client windows (eventually dockable panels)
1082 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1083 for(win = parent.children.first; win; win = win.next)
1085 if(!win.nonClient && !win.isActiveClient && win.visible)
1087 Size size = win.size;
1088 Point pos = win.position;
1089 int left = pos.x, top = pos.y;
1090 int right = pos.x + size.w, bottom = pos.y + size.h;
1091 if(win.size.w > win.size.h)
1094 loY = Max(loY, bottom);
1095 else if(top > ph - ph / 4)
1096 hiY = Min(hiY, top);
1101 loX = Max(loX, right);
1102 else if(left > pw - pw / 4)
1103 hiX = Min(hiX, left);
1112 if(parent.sbv && !parent.sbv.style.hidden)
1113 pw += guiApp.currentSkin.VerticalSBW();
1114 if(parent.sbh && !parent.sbh.style.hidden)
1115 ph += guiApp.currentSkin.HorizontalSBH();
1117 if(anchor.left.type == cascade)
1119 w = (int)(pw * 0.80);
1120 h = (int)(ph * 0.80);
1122 else if(anchor.left.type >= vTiled)
1127 numTiling = parent.numPositions - parent.numIcons;
1128 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1129 if(anchor.left.type == vTiled)
1131 tilingH = (int)sqrt(numTiling);
1132 tilingW = numTiling / tilingH;
1136 tilingW = (int)sqrt(numTiling);
1137 tilingH = numTiling / tilingW;
1140 leftOver = numTiling - tilingH * tilingW;
1143 tilingSplit = (tilingW - leftOver) * tilingH;
1144 tilingLastH = tilingH+1;
1147 tilingSplit = numTiling;
1149 if(positionID >= tilingSplit)
1151 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1152 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1153 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1154 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1158 x = xOffset + pw * (positionID / tilingH) / tilingW;
1159 y = yOffset + ph * (positionID % tilingH) / tilingH;
1160 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1161 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1165 SNAPDOWN(x, textCellW);
1166 SNAPDOWN(y, textCellH);
1167 SNAPDOWN(x2, textCellW);
1168 SNAPDOWN(y2, textCellH);
1176 if(sizeAnchor.isClientW) w += ew;
1177 if(sizeAnchor.isClientH) h += eh;
1179 if(anchor.left.type == offset)
1180 x = anchor.left.distance;
1181 else if(anchor.left.type == relative)
1182 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1183 else if(anchor.right.type == relative)
1184 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1185 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1186 else if(anchor.right.type == offset)
1187 ex = vpw - anchor.right.distance;
1189 if(anchor.top.type == offset)
1190 y = anchor.top.distance;
1191 else if(anchor.top.type == relative)
1192 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1193 else if(anchor.bottom.type == relative)
1194 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1195 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1196 else if(anchor.bottom.type == offset)
1197 ey = vph - anchor.bottom.distance;
1199 if(anchor.left.type && anchor.right.type)
1201 switch(anchor.right.type)
1204 ex = pw * (1.0f-anchor.right.percent);
1205 w = Max((int)(ex + 0.5) - x, 0);
1208 ex = vpw - anchor.right.distance;
1209 w = Max((int)(ex + 0.5) - x, 0);
1213 if(anchor.top.type && anchor.bottom.type)
1215 switch(anchor.bottom.type)
1218 ey = ph * (1.0f-anchor.bottom.percent);
1219 h = Max((int)(ey + 0.5) - y, 0);
1222 ey = vph - anchor.bottom.distance;
1223 h = Max((int)(ey + 0.5) - y, 0);
1232 if(state == normal /*|| state == Hidden*/)
1234 bool addSbV = false, addSbH = false;
1236 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1237 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1239 w = Max(w, minSize.w);
1240 h = Max(h, minSize.h);
1241 w = Min(w, maxSize.w);
1242 h = Min(h, maxSize.h);
1244 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1246 if(w) w -= guiApp.currentSkin.VerticalSBW();
1249 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1251 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1255 if(!OnResizing(&w, &h))
1261 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1262 w += guiApp.currentSkin.VerticalSBW();
1263 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1264 h += guiApp.currentSkin.HorizontalSBH();
1266 w = Max(w, skinMinSize.w);
1267 h = Max(h, skinMinSize.h);
1280 SNAPDOWN(w, textCellW);
1281 SNAPDOWN(h, textCellH);
1284 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1286 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1289 (pw - w) / CASCADE_SPACE,
1290 (ph - h) / CASCADE_SPACE);
1296 cascW = (pw - w) / (numCascade-1);
1297 cascH = (ph - h) / (numCascade-1);
1298 SNAPDOWN(cascW, textCellW);
1299 SNAPDOWN(cascH, textCellH);
1300 cascadeW = (float)cascW;
1301 cascadeH = (float)cascH;
1305 numCascade = Max(numCascade, 2);
1306 cascadeW = (float)(pw - w) / (numCascade-1);
1307 cascadeH = (float)(ph - h) / (numCascade-1);
1310 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1311 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1313 else if(anchor.left.type < vTiled)
1315 if(!anchor.left.type || anchor.horz.type == middleRelative)
1317 if(!anchor.right.type)
1319 if(anchor.horz.type == middleRelative)
1320 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1322 x = vpw / 2 + anchor.horz.distance - w / 2;
1328 // case A_EDGE: x = x - w; break;
1330 if(!anchor.top.type || anchor.vert.type == middleRelative)
1332 if(!anchor.bottom.type)
1334 if(anchor.vert.type == middleRelative)
1335 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1337 y = vph / 2 + anchor.vert.distance - h / 2;
1343 // case A_EDGE: y = y - h; break;
1346 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1354 SNAPDOWN(x, textCellW);
1355 SNAPDOWN(y, textCellH);
1367 if(anchored && style.fixed && style.isActiveClient)
1372 void UpdateCaret(bool forceUpdate, bool erase)
1374 static Window lastWindow = null;
1375 static int caretX, caretY, caretSize;
1377 if(guiApp && guiApp.caretOwner == this)
1379 int x = caretPos.x - scroll.x;
1380 int y = caretPos.y - scroll.y;
1382 if((erase || this.caretSize) &&
1383 x >= clientArea.left && x <= clientArea.right &&
1384 y >= clientArea.top && y <= clientArea.bottom)
1388 guiApp.interfaceDriver.SetCaret(
1389 x + absPosition.x + clientStart.x,
1390 y + absPosition.y + clientStart.y, this.caretSize);
1391 guiApp.caretEnabled = true;
1393 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1397 if(lastWindow != this)
1399 updateBox.left = x + 1;
1401 updateBox.right = x + 2;
1402 updateBox.bottom = y + this.caretSize - 1;
1406 updateBox.left = Min(x + 1, caretX + 1);
1407 updateBox.top = Min(y, caretY);
1408 updateBox.right = Max(x + 2, caretX + 2);
1409 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1412 guiApp.caretOwner.Update(updateBox);
1419 caretSize = this.caretSize;
1425 guiApp.interfaceDriver.SetCaret(0,0,0);
1426 guiApp.caretEnabled = false;
1432 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1437 scrolledPos.x = position.x = x;
1438 scrolledPos.y = position.y = y;
1440 clientSize.w = size.w = w;
1441 clientSize.h = size.h = h;
1443 if(parent && !style.nonClient)
1445 //if(!style.fixed || style.isDocument)
1447 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1448 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1452 clientStart.x = clientStart.y = 0;
1454 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1456 //if(!activeClient || activeClient.state != maximized)
1457 if(!noAutoScrollArea)
1459 // Check if scroll area must be modified
1460 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1462 bool foundChild = false;
1464 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1465 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1466 for(child = children.first; child; child = child.next)
1468 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1469 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1471 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1472 w = Max(w, child.position.x + child.size.w);
1473 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1474 w = Max(w, Max(child.position.x, 0) + child.size.w);
1475 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1476 h = Max(h, child.position.y + child.size.h);
1477 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1478 h = Max(h, Max(child.position.y, 0) + child.size.h);
1483 if(foundChild && (w > cw || h > ch))
1485 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1487 int stepX = sbStep.x, stepY = sbStep.y;
1488 // Needed to make snapped down position match the skin's check of client area
1489 // against realvirtual
1492 SNAPDOWN(stepX, textCellW);
1493 SNAPDOWN(stepY, textCellH);
1494 stepX = Max(stepX, textCellW);
1495 stepY = Max(stepY, textCellH);
1497 if(scrollFlags.snapX)
1499 if(scrollFlags.snapY)
1502 reqScrollArea.w = w;
1503 reqScrollArea.h = h;
1506 else if(reqScrollArea.w || reqScrollArea.h)
1508 reqScrollArea.w = 0;
1509 reqScrollArea.h = 0;
1510 SetScrollPosition(0,0);
1515 // Automatic MDI Client Scrolling Area Adjustment
1516 if(parent && !parent.noAutoScrollArea)
1518 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1519 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1521 Window parent = this.parent;
1522 int w = parent.reqScrollArea.w;
1523 int h = parent.reqScrollArea.h;
1525 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1526 w = Max(w, position.x + size.w);
1527 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1528 w = Max(w, Max(position.x, 0) + size.w);
1529 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1530 h = Max(h, position.y + size.h);
1531 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1532 h = Max(h, Max(position.y, 0) + size.h);
1534 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1535 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1537 /*bool resize = false;
1538 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1539 // Needed to make snapped down position match the skin's check of client area
1540 // against realvirtual
1543 SNAPDOWN(stepX, textCellW);
1544 SNAPDOWN(stepY, textCellH);
1545 stepX = Max(stepX, textCellW);
1546 stepY = Max(stepY, textCellH);
1548 if(parent.scrollFlags.snapX)
1550 if(parent.scrollFlags.snapY)
1552 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1554 parent.reqScrollArea.w = w;
1555 parent.reqScrollArea.h = h;*/
1557 // parent.UpdateScrollBars(true, true);
1558 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1559 false, true, true, true, false, false);
1564 GetRidOfVirtualArea();
1568 UpdateScrollBars(modifyThisArea, false);
1569 else if(guiApp.currentSkin)
1572 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1574 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1575 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1576 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1577 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1580 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1581 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1583 absPosition = scrolledPos;
1584 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1585 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1587 if(this != guiApp.desktop && parent)
1589 absPosition.x += parent.absPosition.x;
1590 absPosition.y += parent.absPosition.y;
1591 if(!style.nonClient && this != guiApp.desktop)
1593 absPosition.x += parent.clientStart.x;
1594 absPosition.y += parent.clientStart.y;
1598 box = Box { 0, 0, size.w - 1, size.h - 1 };
1603 // Clip against parent's client area
1604 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1606 // Compute client area in this window coordinate system
1607 clientArea.left = 0;
1609 clientArea.right = clientSize.w - 1;
1610 clientArea.bottom = clientSize.h - 1;
1612 // Clip against parent's client area
1614 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1618 //absPosition.x -= parent.clientStart.x;
1619 //absPosition.y -= parent.clientStart.y;
1622 // Adjust all children
1623 for(child = children.first; child; child = child.next)
1624 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1626 UpdateCaret(false, false);
1629 void GetRidOfVirtualArea(void)
1631 if(parent && !parent.destroyed && style.fixed &&
1632 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1633 parent.reqScrollArea.w && parent.reqScrollArea.h)
1635 if(!parent.noAutoScrollArea)
1637 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1641 for(child = children.first; child; child = child.next)
1643 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1645 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1646 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1656 Window parent = this.parent;
1658 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1659 false, true, true, true, false, false);
1661 parent.SetScrollArea(0,0,true);
1662 parent.SetScrollPosition(0,0);
1668 public void ExternalPosition(int x, int y, int w, int h)
1670 Position(x, y, w, h, false, true, true, true, false, false);
1671 /* TO REVIEW: Redj's code trying to fix position saving
1676 normalAnchor = Anchor { left = x, top = y };
1677 normalSizeAnchor = SizeAnchor { { w, h } };
1684 // (w, h): Full window size
1685 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1687 bool result = false;
1688 int oldCW = clientSize.w, oldCH = clientSize.h;
1689 bool clientResized, windowResized, windowMoved;
1691 //bool realResized = size.w != w || size.h != h;
1693 // TOCHECK: This wasn't in ecere.dll
1694 //if(!parent) return true;
1695 if(destroyed) return false;
1697 windowMoved = position.x != x || position.y != y || force;
1699 // windowResized = realResized || force;
1700 windowResized = size.w != w || size.h != h || force;
1702 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1708 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1709 scrolledPos.x - parent.clientStart.x + this.box.right,
1710 scrolledPos.y - parent.clientStart.y + this.box.bottom
1716 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1721 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1723 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1724 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1725 windowResized = true;
1727 if(display && rootWindow != this)
1730 if(guiApp && guiApp.windowMoving)
1732 if(guiApp.windowMoving.style.nonClient)
1733 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1735 guiApp.windowMoving.parent.SetMouseRangeToClient();
1745 // Buttons bitmap resources crash if we do this while switching mode
1746 if(!guiApp || !guiApp.modeSwitching)
1749 // Process Anchored Children
1753 for(child = children.first; child; child = child.next)
1756 ((child.stateAnchor.left.type != offset ||
1757 child.stateAnchor.top.type != offset ||
1758 child.stateAnchor.right.type != none ||
1759 child.stateAnchor.bottom.type != none) ||
1760 child.state == maximized || child.state == minimized))
1762 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1764 // child.Position(x, y, w, h, false, true, true, true, false);
1765 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1766 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1772 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1773 //if(updateScrollBars)
1775 OnResize(clientSize.w, clientSize.h);
1777 if((clientResized || windowMoved) && created)
1778 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1780 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1782 Window master = guiApp.interimWindow.master;
1783 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1786 if(rootWindow == this && !is3D)
1790 x -= guiApp.desktop.absPosition.x;
1791 y -= guiApp.desktop.absPosition.y;
1793 //guiApp.Log("Position %s\n", caption);
1796 if(windowResized || windowMoved)
1797 if(display && !display.flags.memBackBuffer && changeRootWindow)
1798 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1800 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1801 for(child = parent.children.first; child && child != this; child = child.next)
1802 if(child.rootWindow)
1803 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1808 if(windowMoved || windowResized)
1810 display.Lock(true /*false*/);
1813 display.Position(absPosition.x, absPosition.y);
1814 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1817 // result = realResized ? display.Resize(size.w, size.h) : true;
1818 if(nativeDecorations && rootWindow.windowHandle)
1820 int w = clientSize.w, h = clientSize.h;
1821 if(hasMenuBar) h += skinMenuHeight;
1822 if(hasStatusBar) h += statusBarHeight;
1823 if(sbv && sbv.visible) w += sbv.size.w;
1824 if(sbh && sbh.visible) h += sbh.size.h;
1825 result = manageDisplay ? display.Resize(w, h) : true;
1828 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1832 else if(clientResized)
1834 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1837 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1841 if(windowMoved || windowResized)
1846 if(guiApp.driver && changeRootWindow && windowHandle)
1848 if(windowResized || windowMoved)
1849 if(!display || display.flags.memBackBuffer)
1850 guiApp.interfaceDriver.PositionRootWindow(this,
1851 x, y, w, h, windowMoved, windowResized);
1852 guiApp.interfaceDriver.UpdateRootWindow(this);
1854 for(child = children.first; child; child = child.next)
1856 if(child.is3D && child.created)
1858 // Copy Display Content
1859 child.display.displaySystem = display.displaySystem;
1860 child.display.window = display.window;
1861 child.display.current = display.current;
1862 child.display.width = display.width;
1863 child.display.height = display.height;
1864 child.display.driverData = display.driverData;
1865 #if !defined(__EMSCRIPTEN__)
1866 child.display.mutex = null;
1878 void UpdateScrollBars(bool flag, bool fullThing)
1881 bool resizeH = false, resizeV = false;
1882 bool scrolled = false;
1883 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1884 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1886 if(destroyed) return;
1887 if(guiApp.currentSkin)
1889 MinMaxValue cw = 0, ch = 0;
1890 bool sbvVisible, sbhVisible;
1891 int rangeH = 0, rangeV = 0;
1892 int positionH = 0, positionV;
1894 // First get client area with no respect to scroll bars
1899 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1901 if(scrollFlags.dontHide)
1904 cw -= guiApp.currentSkin.VerticalSBW();
1906 ch -= guiApp.currentSkin.HorizontalSBH();
1908 // Update the scrollbar visibility
1914 sbh.disabled = rangeH <= 1;
1915 if(sbh.style.hidden)
1925 sbv.disabled = rangeV <= 1;
1926 if(sbv.style.hidden)
1934 int oldHRange = sbh ? sbh.range : 0;
1935 int oldVRange = sbv ? sbv.range : 0;
1936 // Then start off with horizontal scrollbar range
1939 positionH = sbh.thumbPosition;
1946 SBSetTotal(sbh, rvw);
1949 ch -= guiApp.currentSkin.HorizontalSBH();
1952 // Do the same for vertical scrollbar
1955 positionV = sbv.thumbPosition;
1961 SBSetTotal(sbv, rvh);
1965 cw -= guiApp.currentSkin.VerticalSBW();
1966 // Maybe we need to set the range on the horizontal scrollbar again
1974 SBSetTotal(sbh, rvw);
1975 //sbh.Action(setRange, positionH, 0);
1976 if(rangeH <= 1 && sbh.range > 1)
1978 ch -= guiApp.currentSkin.HorizontalSBH();
1984 SBSetTotal(sbv, rvh);
1986 //sbv.Action(setRange, positionV, 0);
1991 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1992 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1995 // Update the scrollbar visibility
1996 if(!scrollFlags.dontHide)
1998 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
2002 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2009 if(guiApp.currentSkin)
2016 sbhVisible = sbh.style.hidden ? true : false;
2018 sbvVisible = sbv.style.hidden ? true : false;
2020 // Do our resize here
2021 if(flag && (resizeH || resizeV) && fullThing)
2023 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2028 OnResize(clientSize.w, clientSize.h);
2034 sbh.visible = sbhVisible;
2036 sbv.visible = sbvVisible;
2038 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2039 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2042 sbh.pageStep = clientSize.w;
2044 sbv.pageStep = clientSize.h;
2046 // Notify doesn't handle setRange anymore... process it here
2049 int positionH = sbh.thumbPosition;
2050 if(scroll.x != positionH)
2052 OnHScroll(setRange, positionH, 0);
2056 SNAPDOWN(positionH, textCellW);
2057 scroll.x = positionH;
2063 int seen = clientSize.w, total = reqScrollArea.w;
2066 if(scrollFlags.snapX)
2067 SNAPDOWN(seen, sbStep.x);
2069 if(!total) total = seen;
2070 range = total - seen + 1;
2072 range = Max(range, 1);
2074 if(x >= range) x = range - 1;
2076 if(scrollFlags.snapX)
2077 SNAPUP(x, sbStep.x);
2081 OnHScroll(setRange, x, 0);
2086 SNAPDOWN(x, textCellW);
2092 int positionV = sbv.thumbPosition;
2093 if(scroll.y != positionV)
2095 OnVScroll(setRange, positionV, 0);
2099 SNAPDOWN(positionV, textCellH);
2100 scroll.y = positionV;
2106 int seen = clientSize.h, total = reqScrollArea.h;
2109 if(scrollFlags.snapY)
2110 SNAPDOWN(seen, sbStep.y);
2112 if(!total) total = seen;
2113 range = total - seen + 1;
2114 range = Max(range, 1);
2116 if(y >= range) y = range - 1;
2118 if(scrollFlags.snapY)
2119 SNAPUP(y, sbStep.y);
2123 OnVScroll(setRange, y, 0);
2128 SNAPDOWN(y, textCellH);
2134 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2137 for(child = children.first; child; child = child.next)
2139 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2142 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2143 child.Position(x, y, w, h, false, true, false, true, false, false);
2150 // Process Scrollbars
2152 if(sbh) // && !sbh.style.hidden
2155 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2156 // Need to set the range again (should improve...) since the scrollbars didn't have
2157 // the right size when UpdateScrollArea set the range on it
2160 sbh.seen = clientSize.w;
2164 if(sbv) // && !sbv.state.hidden
2167 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2168 // Need to set the range again (should improve...) since the scrollbars didn't have
2169 // the right size when UpdateScrollArea set the range on it
2172 sbv.seen = clientSize.h;
2177 // TESTING THIS LOWER
2178 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2181 for(child = children.first; child; child = child.next)
2183 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2186 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2187 child.Position(x, y, w, h, false, true, false, true, false, false);
2193 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2195 SetState(maximized, false, mods);
2199 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2201 SetState(normal, false, mods);
2205 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2207 SetState(minimized, false, mods);
2208 parent.CycleChildren(false, true, false, true);
2212 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2215 // Scroll bar notifications
2216 if(action != setRange)
2218 bool changed = false;
2222 if(scroll.x != position)
2224 OnHScroll(action, position, keyFlags);
2229 SNAPDOWN(position, textCellW);
2231 scroll.x = position;
2235 if(scroll.y != position)
2237 OnVScroll(action, position, keyFlags);
2242 SNAPDOWN(position, textCellH);
2244 scroll.y = position;
2248 bool childMove = false;
2249 for(child = children.first; child; child = child.next)
2251 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2254 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2255 child.Position(x, y, w, h, false, true, false, true, false, false);
2259 // Testing this patch out to solve MDI workspace redraw bugs
2260 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2261 // Scroll offsets to blame?
2265 UpdateCaret(false, false);
2269 // Testing this patch out to solve MDI workspace redraw bugs
2270 for(child = children.first; child; child = child.next)
2272 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2281 Window GetParentMenuBar()
2283 Window menuBarParent;
2284 if(formDesigner) return null;
2285 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2287 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2288 if(menuBarParent && !menuBarParent.isActiveClient)
2294 void CreateSystemChildren(void)
2296 Window parent = this;
2297 bool scrollBarChanged = false;
2298 bool hasClose = false, hasMaxMin = false;
2299 Point scroll = this.scroll;
2301 if(state == maximized)
2303 parent = GetParentMenuBar();
2310 if(style.hasClose) hasClose = true;
2311 if(style.hasMaximize || style.hasMinimize)
2318 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2320 sysButtons[2].Destroy(0);
2321 sysButtons[2] = null;
2323 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2325 sysButtons[1].Destroy(0);
2326 sysButtons[1] = null;
2328 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2330 sysButtons[0].Destroy(0);
2331 sysButtons[0] = null;
2334 if(hasClose && parent)
2341 parent, master = this,
2342 inactive = true, nonClient = true, visible = false;
2344 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2350 if(this.parent == guiApp.desktop)
2351 sysButtons[2].hotKey = altF4;
2352 else if(style.isActiveClient)
2353 sysButtons[2].hotKey = ctrlF4;
2354 sysButtons[2].Create();
2357 sysButtons[2].symbol = 'X';
2358 sysButtons[2].disabled = !style.hasClose;
2361 if(hasMaxMin && parent)
2365 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2366 if(state == maximized)
2369 method = RestoreButtonClicked;
2375 method = MaximizeButtonClicked;
2383 parent, master = this,
2384 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2386 sysButtons[1].Create();
2388 sysButtons[1].NotifyClicked = method;
2390 sysButtons[1].symbol = symbol;
2391 sysButtons[1].disabled = !style.hasMaximize;
2394 if(hasMaxMin && parent)
2398 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2399 if (state == minimized)
2402 method = RestoreButtonClicked;
2408 method = MinimizeButtonClicked;
2416 parent, master = this,
2417 hotKey = altM, inactive = true, nonClient = true, visible = false
2419 sysButtons[0].Create();
2421 sysButtons[0].NotifyClicked = method;
2423 sysButtons[0].symbol = symbol;
2424 sysButtons[0].disabled = !style.hasMinimize;
2427 // Create the scrollbars
2428 if(style.hasHorzScroll && !sbh)
2434 direction = horizontal,
2438 snap = scrollFlags.snapX,
2439 NotifyScrolling = ScrollBarNotification
2442 scrollBarChanged = true;
2444 else if(sbh && !style.hasHorzScroll)
2450 if(style.hasVertScroll && !sbv)
2456 direction = vertical,
2460 snap = scrollFlags.snapY,
2461 NotifyScrolling = ScrollBarNotification
2464 scrollBarChanged = true;
2466 else if(sbv && !style.hasVertScroll)
2471 if(scrollBarChanged)
2473 SetScrollLineStep(sbStep.x, sbStep.y);
2474 UpdateScrollBars(true, true);
2478 if(scrollBarChanged)
2480 if(sbh) sbh.thumbPosition = scroll.x;
2481 if(sbv) sbv.thumbPosition = scroll.y;
2485 void UpdateCaption(void)
2487 if(rootWindow == this)
2490 FigureCaption(caption);
2491 if(guiApp.interfaceDriver)
2492 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2494 UpdateDecorations();
2497 if(parent.activeClient == this) // Added this last check
2499 if(parent.rootWindow == parent)
2502 parent.FigureCaption(caption);
2503 if(guiApp.interfaceDriver)
2504 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2507 parent.UpdateCaption();
2509 parent.UpdateDecorations();
2513 void UpdateActiveDocument(Window previous)
2515 Window activeClient = this.activeClient;
2516 Window activeChild = this.activeChild;
2523 activeClient.CreateSystemChildren();
2525 previous.CreateSystemChildren();
2537 // Build window list
2540 Menu windowMenu = menu.FindMenu("Window");
2545 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2547 Window document = cycle.data;
2548 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2550 char name[2048], caption[2048];
2551 document.FigureCaption(caption);
2552 sprintf(name, "%d %s", id+1, caption);
2553 windowMenu.AddDynamic(MenuItem
2555 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2556 NotifySelect = MenuWindowSelectWindow
2560 if(activeClient.cycle == cycle) break;
2565 if((!previous && activeClient) || !activeClient)
2571 item = menu.FindItem(MenuWindowCloseAll, 0);
2572 if(item) item.disabled = false;
2573 item = menu.FindItem(MenuWindowNext, 0);
2574 if(item) item.disabled = false;
2575 item = menu.FindItem(MenuWindowPrevious, 0);
2576 if(item) item.disabled = false;
2577 item = menu.FindItem(MenuWindowCascade, 0);
2578 if(item) item.disabled = false;
2579 item = menu.FindItem(MenuWindowTileHorz, 0);
2580 if(item) item.disabled = false;
2581 item = menu.FindItem(MenuWindowTileVert, 0);
2582 if(item) item.disabled = false;
2583 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2584 if(item) item.disabled = false;
2585 item = menu.FindItem(MenuWindowWindows, 0);
2586 if(item) item.disabled = false;
2589 item = menu.FindItem(MenuFileClose, 0);
2590 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2591 item = menu.FindItem(MenuFileSaveAll, 0);
2592 if(item) item.disabled = numDocuments < 1;
2594 if(activeClient && activeClient.menu && activeClient.state != minimized)
2598 //activeClient.menu.Clean(activeClient);
2599 menu.Merge(activeClient.menu, true, activeClient);
2603 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2606 menu.Merge(activeChild.menu, true, activeChild);
2609 // This is called again for a child window change, with same active client
2610 OnActivateClient(activeClient, previous);
2611 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2612 parent.UpdateActiveDocument(null);
2615 void _ShowDecorations(Box box, bool post)
2617 if(rootWindow == this && nativeDecorations && !is3D) return;
2618 if(visible && this != guiApp.desktop)
2620 Surface surface = RedrawFull(box);
2624 FigureCaption(caption);
2627 ShowDecorations(captionFont.font,
2630 active, //parent.activeClient == this
2631 guiApp.windowMoving == this);
2633 PreShowDecorations(captionFont.font,
2636 active, //parent.activeClient == this
2637 guiApp.windowMoving == this);
2644 void UpdateExtent(Box refresh)
2646 Surface surface = null;
2648 if(!manageDisplay) { OnRedraw(null);return; }
2649 _ShowDecorations(refresh, false);
2651 surface = Redraw(refresh);
2652 // Opaque background: just fill before EW_REDRAW (clear?)
2655 surface.SetBackground(background);
2656 surface.SetForeground(foreground);
2657 surface.DrawingChar(' ');
2658 if(this == rootWindow)
2660 if(style.drawBehind || background.a)
2662 int a = background.a;
2663 // Premultiply alpha for clear color
2664 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2665 surface.Clear(colorBuffer);
2666 surface.SetBackground(background);
2669 else if(background.a)
2673 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2674 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2677 if(display.flags.alpha && background.a < 255 && background)
2679 surface.Area(0,0,clientSize.w, clientSize.h);
2680 /*if(style.clearDepthBuffer)
2681 surface.Clear(depthBuffer);*/
2683 else if(/*style.clearDepthBuffer || */background.a)
2685 int a = background.a;
2686 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2687 // Premultiply alpha for clear color
2688 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2689 surface.Clear(colorBuffer);
2690 surface.SetBackground(background);
2695 surface.TextFont(usedFont.font);
2696 surface.TextOpacity(false);
2700 // Draw the caret ...
2701 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2703 // surface.SetBackground(0xFFFFFF - background.color);
2704 surface.SetBackground(~background.color);
2706 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2707 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2713 void DrawOverChildren(Box refresh)
2715 Surface surface = Redraw(refresh);
2719 surface.DrawingChar(' ');
2720 surface.SetBackground(background);
2721 surface.SetForeground(foreground);
2723 surface.TextFont(usedFont.font);
2724 surface.TextOpacity(false);
2726 OnDrawOverChildren(surface);
2731 _ShowDecorations(refresh, true);
2734 void ComputeClipExtents(void)
2737 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2739 clipExtent.Copy(this.clipExtent);
2741 for(child = children.last; child; child = child.prev)
2743 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2745 bool opaque = child.IsOpaque(); // TODO: acess background directly
2746 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2748 child.clipExtent.Copy(clipExtent);
2749 child.clipExtent.Offset(-dx, -dy);
2750 child.clipExtent.IntersectBox(child.box);
2752 child.ComputeClipExtents();
2754 if(opaque && !child.style.nonClient)
2756 // Adjust the box for the parent:
2757 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2758 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2763 // ??? Only do this for overlapped window or if parent has with clip children flag
2765 // Do this if window has clip children flag on (default false?)
2766 // this.clipExtent = clipExtent;
2768 clipExtent.Free(null);
2771 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2774 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2775 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2777 offsetX -= rootWindow.clientStart.x;
2778 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2782 for(child = children.last; child; child = child.prev)
2784 bool opaque = child.IsOpaque();
2785 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2789 // Adjust renderArea to the root window level
2790 Extent * renderArea = &rootWindow.tempExtents[3];
2792 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2793 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2794 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2796 offsetX -= child.rootWindow.clientStart.x;
2797 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2801 Extent childRenderArea;
2803 if(backBufferUpdate != null)
2805 childRenderArea.Copy(backBufferUpdate);
2806 childRenderArea.Offset(-offsetX, -offsetY);
2809 childRenderArea.Copy(child.dirtyArea);
2811 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2812 renderArea.Copy(dirtyExtent);
2813 renderArea.Offset(-offsetX, -offsetY);
2814 childRenderArea.Union(renderArea);
2817 // Intersect with the clip extent
2818 childRenderArea.Intersection(child.clipExtent);
2821 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2823 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2824 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2826 renderArea->Offset(offsetX, offsetY);
2828 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2829 // overDirtyExtent.Union(renderArea);
2830 renderArea->Empty();
2831 // childRenderArea.Free();
2833 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2838 for(child = children.last; child; child = child.prev)
2840 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2842 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2847 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2849 bool opaque = IsOpaque();
2850 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2852 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2853 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2855 offsetX -= rootWindow.clientStart.x;
2856 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2860 for(child = children.last; child; child = child.prev)
2862 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2864 ColorAlpha background = *(ColorAlpha *)&child.background;
2865 bool opaque = child.IsOpaque();
2866 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2870 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2871 // Adjust renderArea to the root window level
2873 renderArea.Copy(child.dirtyArea);
2874 renderArea.Offset(offsetX, offsetY);
2875 dirtyExtent.Union(renderArea);
2876 overDirtyExtent.Union(renderArea);
2882 for(child = children.last; child; child = child.prev)
2884 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2886 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2890 if(backBufferUpdate != null)
2892 renderArea.Copy(backBufferUpdate);
2893 renderArea.Offset(-offsetX, -offsetY);
2895 overRenderArea.Copy(backBufferUpdate);
2896 overRenderArea.Offset(-offsetX, -offsetY);
2902 renderArea.Copy(dirtyArea);
2904 overRenderArea.Copy(dirtyArea);
2907 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2908 dirtyExtentWindow->Copy(dirtyExtent);
2909 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2910 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2911 dirtyExtentWindow->Empty();
2913 // Intersect with the clip extent
2914 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2917 if(renderArea.count > 10)
2920 printf("\nToo many extents (%d):\n", renderArea.count);
2922 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2923 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2928 for(c = 0; c<10; c++)
2931 FASTLIST_LOOP(renderArea, extentBox)
2933 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2935 renderArea.Copy(extent);
2937 FASTLIST_LOOP(renderArea, extentBox)
2940 printf("(%d, %d) - (%d, %d)\n",
2941 extentBox.box.left, extentBox.box.top,
2942 extentBox.box.right, extentBox.box.bottom);
2946 printf("\nNow %d\n", renderArea.count);
2952 // WHY WAS THIS COMMENTED ??
2954 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2955 dirtyExtentWindow->Copy(overDirtyExtent);
2956 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2957 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2958 dirtyExtentWindow->Empty();
2960 // Intersect with the clip extent
2961 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2967 if(scrollExtent.count)
2969 // Subtract render extent from scrolling extent
2970 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2972 if(backBufferUpdate == null)
2974 Extent * dirty = &rootWindow.tempExtents[3];
2977 // Intersect scrolling extent with clip extent
2978 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2980 // offset this scroll to be at the root window level
2981 scrollExtent.Offset(offsetX, offsetY);
2982 // Add area that was scrolled to the dirty extents of the back buffer
2983 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2987 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2988 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2989 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2994 scrollExtent.Empty();
2996 // Add the exposed extent to the window render area
2997 dirty->Offset(-offsetX, -offsetY);
2998 renderArea.Union(dirty, rootWindow.tempExtents[0]);
3003 // Subtract the window's box from the transparency forced extent
3004 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3010 renderArea.Copy(this.renderArea);
3011 renderArea.Offset(offsetX, offsetY);
3012 dirtyExtent.Union(renderArea);
3018 Extent renderArea { };
3020 renderArea.Copy(overRenderArea);
3021 renderArea.Offset(offsetX, offsetY);
3022 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3027 if(backBufferUpdate != null)
3029 // Remove render area from dirty area
3030 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3032 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3039 // Remove the window render area from the dirty extents of the back buffer
3040 rootWindow.dirtyBack.Exclusion(renderArea);
3044 void Render(Extent updateExtent)
3048 Window rootWindow = this.rootWindow;
3049 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3050 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3052 offsetX -= rootWindow.clientStart.x;
3053 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3056 if(rootWindow.fullRender)
3065 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3066 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3071 /*if(renderArea.count)
3072 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3075 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3077 Box box = extentBox.box;
3080 /*printf("(%d, %d) - (%d, %d)\n",
3081 extentBox.box.left, extentBox.box.top,
3082 extentBox.box.right, extentBox.box.bottom);*/
3087 box.left += offsetX;
3089 box.right += offsetX;
3090 box.bottom += offsetY;
3092 if(updateExtent != null)
3093 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3097 for(child = children.first; child; child = child.next)
3098 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3099 child.Render(updateExtent);
3101 if(rootWindow.fullRender)
3102 DrawOverChildren(box);
3105 // TO DO: There's an issue about draw over children...
3106 // TO DO: Don't wanna go through this if method isn't used
3107 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3108 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3110 Box box = extentBox.box;
3112 DrawOverChildren(box);
3114 box.left += offsetX;
3116 box.right += offsetX;
3117 box.bottom += offsetY;
3119 if(updateExtent != null)
3120 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3123 for(child = children.first; child; child = child.next)
3124 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3125 child.Render(updateExtent);
3128 overRenderArea.Empty();
3131 public void UpdateDisplay(void)
3133 if(!manageDisplay) { OnRedraw(null);return; }
3134 if(rootWindow && this != rootWindow)
3135 rootWindow.UpdateDisplay();
3138 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3139 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3142 dirtyExtent.Clear();
3145 clipExtent.AddBox(box);
3147 display.StartUpdate();
3149 if(!rootWindow.fullRender)
3151 ComputeClipExtents();
3152 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3153 ComputeRenderArea(dirtyExtent, overExtent, null);
3156 clipExtent.Free(null);
3158 dirtyExtent.Free(null);
3159 overExtent.Free(null);
3161 if(display.flags.flipping)
3164 display.Update(null);
3168 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3169 updateExtent.Clear();
3171 Render(updateExtent);
3173 updateExtent.UnionBox(this.box, tempExtents[0]);
3176 //printf("\n\nUpdate:\n------------------------------------------\n");
3179 //FASTLIST_LOOP(updateExtent, extentBox)
3180 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3183 /*printf("Updating (%d, %d) - (%d, %d)\n",
3184 extentBox.box.left, extentBox.box.top,
3185 extentBox.box.right, extentBox.box.bottom);*/
3188 display.Update(extentBox.box);
3191 updateExtent.Free(null);
3194 display.EndUpdate();
3202 void UpdateBackDisplay(Box box)
3208 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3210 //printf("UpdateBackDisplay going through!\n");
3211 display.StartUpdate();
3215 intersection.Copy(dirtyBack);
3216 intersection.IntersectBox(box);
3218 dirtyExtent.Clear();
3221 clipExtent.AddBox(box);
3223 if(!rootWindow.fullRender)
3225 ComputeClipExtents();
3226 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3229 clipExtent.Free(null);
3231 intersection.Free(null);
3232 dirtyExtent.Free(null);
3233 overExtent.Free(null);
3238 if(display.flags.flipping)
3239 display.Update(null);
3242 rootWindow.display.Update(box);
3245 display.EndUpdate();
3249 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3250 if(dirtyBack.count > MAX_DIRTY_BACK)
3252 BoxItem extentBox, next;
3253 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3254 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3256 next = (BoxItem)extentBox.next;
3257 if(extentBox != first)
3259 if(extentBox.box.left < first.box.left)
3260 first.box.left = extentBox.box.left;
3261 if(extentBox.box.top < first.box.top)
3262 first.box.top = extentBox.box.top;
3263 if(extentBox.box.right > first.box.right)
3264 first.box.right = extentBox.box.right;
3265 if(extentBox.box.bottom > first.box.bottom)
3266 first.box.bottom = extentBox.box.bottom;
3267 dirtyBack.Delete(extentBox);
3276 // --- Window positioning ---
3277 // --- Window identification ---
3279 // Returns window at position "Position"
3280 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3282 Window child, result = null;
3284 box.left += absPosition.x;
3285 box.right += absPosition.x;
3286 box.top += absPosition.y;
3287 box.bottom += absPosition.y;
3289 if(!destroyed && visible && (acceptDisabled || !disabled))
3291 int lx = x - absPosition.x;
3292 int ly = y - absPosition.y;
3293 if(IsInside(lx, ly))
3294 // if(box.IsPointInside(Point{x, y}))
3296 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3297 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3300 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3301 Window ancestor = null;
3303 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3304 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3306 if(child != statusBar && child.rootWindow == rootWindow)
3308 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3315 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3317 if(child != statusBar && child.rootWindow == rootWindow)
3319 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3326 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3334 Window FindModal(void)
3336 Window modalWindow = this, check;
3337 Window check2 = null;
3338 for(check = this; check.master; check = check.master)
3340 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3342 modalWindow = check.master.modalSlave;
3343 check = modalWindow;
3345 // TESTING THIS FOR DROPBOX...
3346 if(!rootWindow || !rootWindow.style.interim)
3348 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3350 if(check2.modalSlave && check2.modalSlave.created)
3352 modalWindow = check2.modalSlave;
3360 if(modalWindow == this)
3362 for(check = this; check.activeChild; check = check.activeChild)
3364 if(check.modalSlave)
3366 modalWindow = check.modalSlave;
3372 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3373 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3376 void StopMoving(void)
3378 if(this == guiApp.windowMoving)
3380 guiApp.windowMoving = null;
3381 UpdateDecorations();
3382 SetMouseRange(null);
3385 if(rootWindow.active)
3386 guiApp.interfaceDriver.StopMoving(rootWindow);
3388 guiApp.windowCaptured.ReleaseCapture();
3389 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3390 guiApp.windowIsResizing = false;
3394 void SelectMouseCursor(void)
3399 Window cursorWindow = null;
3400 bool rx, ry, rex, rey;
3402 guiApp.desktop.GetMousePosition(&x, &y);
3403 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3405 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3406 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3407 else if(mouseWindow)
3409 modalWindow = mouseWindow.FindModal();
3410 x -= mouseWindow.absPosition.x;
3411 y -= mouseWindow.absPosition.y;
3412 if(guiApp.windowIsResizing)
3414 rex = guiApp.resizeEndX;
3415 rey = guiApp.resizeEndY;
3416 rx = guiApp.resizeX;
3417 ry = guiApp.resizeY;
3418 if((rex && rey) || (rx && ry))
3419 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3420 else if((rex && ry) || (rx && rey))
3421 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3422 else if((ry || rey) && (!rx && !rex))
3423 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3424 else if((rx || rex) && (!ry && !rey))
3425 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3427 else if(!modalWindow && !guiApp.windowCaptured &&
3428 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3429 &rx, &ry, &rex, &rey))
3431 if((rex && rey) || (rx && ry))
3432 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3433 else if((rex && ry) || (rx && rey))
3434 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3435 else if((ry || rey) && (!rx && !rex))
3436 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3437 else if((rx || rex) && (!ry && !rey))
3438 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3440 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3442 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3443 mouseWindow.rootWindow != mouseWindow)
3444 cursorWindow = mouseWindow.parent;
3446 cursorWindow = mouseWindow;
3448 else if(!guiApp.interimWindow)
3449 cursorWindow = guiApp.windowCaptured;
3452 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3453 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3455 else if(modalWindow)
3457 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3459 else if(guiApp.interimWindow)
3461 if(guiApp.interimWindow.cursor)
3462 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3464 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3469 // --- State based input ---
3470 bool AcquireInputEx(bool state)
3475 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3476 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3478 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3480 guiApp.acquiredWindow = state ? this : null;
3483 SetMouseRangeToClient();
3484 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3489 SelectMouseCursor();
3491 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3495 // --- Window activation ---
3496 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3499 if(!parent || !parent.style.inactive)
3501 Window parent = this.parent;
3504 if(rootWindow == this)
3505 Log(active ? "active\n" : "inactive\n");
3507 if(active && requireRemaximize)
3509 if(state == maximized)
3511 property::state = normal;
3512 property::state = maximized;
3514 requireRemaximize = false;
3517 // Testing this here...
3518 if(!parent || parent == guiApp.desktop || parent.active)
3520 this.active = active;
3523 // TESTING THIS HERE
3524 UpdateDecorations();
3525 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3526 result = NotifyActivate(master, this, active, previous);
3529 this.active = !active;
3534 if(!parent || parent == guiApp.desktop || parent.active)
3536 this.active = active;
3538 AcquireInputEx(active);
3539 if(active && isEnabled)
3543 if(guiApp.caretOwner)
3547 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3548 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3549 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3550 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3552 guiApp.caretOwner.Update(extent);
3555 if(visible || !guiApp.caretOwner)
3556 guiApp.caretOwner = this;
3557 UpdateCaret(false, false);
3563 this.active = false;
3565 AcquireInputEx(active);
3567 if(!active && guiApp.caretOwner == this)
3569 UpdateCaret(false, true);
3570 guiApp.caretOwner = null;
3571 guiApp.interfaceDriver.SetCaret(0,0,0);
3572 guiApp.caretEnabled = false;
3577 if(!active && parent && parent.activeChild && parent.activeChild != this)
3578 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3584 if(!active && menuBar)
3587 menuBar.OnActivate(false, null, &goOn, true);
3588 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3593 Window aChild = activeChild;
3595 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3607 void ConsequentialMouseMove(bool kbMoving)
3611 if(kbMoving || !guiApp.windowMoving)
3615 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3617 if(guiApp.interfaceDriver)
3618 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3620 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3621 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3627 bool IsDescendantOf(Window ancestor)
3630 for(window = this; window && window != ancestor; window = window.parent);
3631 return window == ancestor;
3634 bool IsSlaveOf(Window master)
3637 for(window = this; window && window != master; window = window.master);
3638 return window == master;
3641 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3645 if(this && !destroyed /*&& state != Hidden*/)
3647 Window swap = externalSwap;
3655 if(activateParent &&
3656 (parent.activeChild != this ||
3657 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3658 active && _isModal &&
3659 parent != master && master)
3660 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3666 bool real = parent.activeChild != this;
3668 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3669 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3670 !IsDescendantOf(guiApp.interimWindow) &&
3671 !IsSlaveOf(guiApp.interimWindow))
3673 Window interimWindow = guiApp.interimWindow;
3674 while(interimWindow && interimWindow != this)
3676 Window master = interimWindow.master;
3678 guiApp.interimWindow = null;
3679 if(guiApp.caretOwner)
3680 guiApp.caretOwner.UpdateCaret(false, false);
3682 incref interimWindow;
3683 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3688 delete interimWindow;
3689 interimWindow = (master && master.style.interim) ? master : null;
3694 guiApp.interimWindow = this;
3695 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3696 guiApp.caretEnabled = false;*/
3697 UpdateCaret(false, true);
3702 //bool acquireInput = false;
3704 parent.activeChild &&
3705 parent.activeChild.state == maximized &&
3706 parent != guiApp.desktop;
3708 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3713 swap = parent.activeChild;
3714 if(swap && swap.destroyed) swap = null;
3715 if(swap && swap != this)
3718 if(!swap.PropagateActive(false, this, &goOn, true))
3719 swap = parent.activeChild;
3730 if(!parent || parent.activeChild != this || style.interim)
3733 result = PropagateActive(true, swap, &goOn, true);
3734 if(!result && !goOn)
3739 //acquireInput = true;
3743 if(style.hasMaximize && parent != guiApp.desktop)
3746 SetState(maximized, false, 0);
3747 else if(state != maximized)
3750 for(child = parent.children.first; child; child = child.next)
3752 if(this != child && child.state == maximized)
3753 child.SetState(normal, false, 0);
3760 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3762 Window previous = parent.activeClient;
3763 parent.activeChild = this;
3764 if(!style.nonClient /*&& style.isActiveClient*/)
3768 if(style.isActiveClient)
3769 parent.activeClient = this;
3770 // Moved UpdateActiveDocument inside hidden check
3771 // To prevent activating previous window while creating a new one
3772 // (It was messing up the privateModule in the CodeEditor)
3773 parent.UpdateActiveDocument(previous);
3779 //if(!style.isRemote)
3781 if(rootWindow != this)
3783 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3784 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3786 else if(!guiApp.fullScreenMode)
3788 Window modalRoot = FindModal();
3789 if(!modalRoot) modalRoot = this;
3790 if(!modalRoot.isForegroundWindow)
3792 modalRoot.isForegroundWindow = true;
3793 // To check : Why is parent null?
3794 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3796 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3798 modalRoot.isForegroundWindow = false;
3803 if(result && real && (!style.inactive || moveInactive) && parent)
3805 Window last = parent.children.last;
3807 if(!style.stayOnTop)
3808 for(; last && last.style.stayOnTop; last = last.prev);
3810 parent.children.Move(this, last);
3812 // Definitely don't want that: why not?
3816 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3822 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3829 parent.activeChild = null;
3830 if(!style.nonClient /*&& style.isActiveClient*/)
3832 Window previous = parent.activeClient;
3833 if(style.isActiveClient)
3834 parent.activeClient = null;
3835 parent.UpdateActiveDocument(previous);
3839 if(this == guiApp.interimWindow)
3841 guiApp.interimWindow = null;
3842 if(guiApp.caretOwner)
3843 guiApp.caretOwner.UpdateCaret(false, false);
3845 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3852 if(!active || !swap)
3853 UpdateDecorations();
3855 swap.UpdateDecorations();
3857 if(active && rootWindow != this)
3858 ConsequentialMouseMove(false);
3865 // --- Input Messages ---
3866 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3868 static bool reEntrancy = false;
3869 if(reEntrancy) return;
3873 guiApp.cursorUpdate = true;
3874 if(guiApp.windowScrolling && !consequential)
3876 guiApp.windowScrolling.SetScrollPosition(
3877 (guiApp.windowScrolling.sbh) ?
3878 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3879 (guiApp.windowScrolling.sbv) ?
3880 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3882 if(guiApp.windowMoving)
3884 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3886 Window window = guiApp.windowMoving;
3888 int w = window.size.w;
3889 int h = window.size.h;
3894 rx = mouseX - guiApp.windowMovingStart.x;
3895 ry = mouseY - guiApp.windowMovingStart.y;
3898 window.GetDecorationsSize(&ew, &eh);
3900 if(guiApp.windowIsResizing)
3902 x = window.scrolledPos.x;
3903 y = window.scrolledPos.y;
3907 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3908 rx = guiApp.windowResizingBefore.w - aw;
3909 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3910 w = guiApp.windowResizingBefore.w - rx;
3914 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3915 ry = guiApp.windowResizingBefore.h - ah;
3916 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3917 ry = Max(ry, -guiApp.windowMovingBefore.y);
3918 h = guiApp.windowResizingBefore.h - ry;
3920 if(guiApp.resizeEndX)
3922 w = guiApp.windowResizingBefore.w + rx;
3925 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3933 w = Max(w, window.minSize.w);
3934 h = Max(h, window.minSize.h);
3935 w = Min(w, window.maxSize.w);
3936 h = Min(h, window.maxSize.h);
3938 if(!window.OnResizing(&w, &h))
3940 w = window.clientSize.w;
3941 h = window.clientSize.h;
3944 w = Max(w, window.skinMinSize.w);
3945 h = Max(h, window.skinMinSize.h);
3952 SNAPDOWN(w, textCellW);
3953 SNAPDOWN(h, textCellH);
3958 aw = Max(w,window.skinMinSize.w);
3959 rx = guiApp.windowResizingBefore.w - aw;
3960 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3961 w = guiApp.windowResizingBefore.w - rx;
3965 ah = Max(h,window.skinMinSize.h);
3966 ry = guiApp.windowResizingBefore.h - ah;
3967 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3968 ry = Max(ry, -guiApp.windowMovingBefore.y);
3969 h = guiApp.windowResizingBefore.h - ry;
3974 if(!guiApp.windowIsResizing || guiApp.resizeX)
3975 x = guiApp.windowMovingBefore.x + rx;
3976 if(!guiApp.windowIsResizing || guiApp.resizeY)
3977 y = guiApp.windowMovingBefore.y + ry;
3979 if(!guiApp.windowIsResizing)
3982 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3984 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3985 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3986 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3987 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3991 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3992 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3998 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
4000 if(!window.OnMoving(&x, &y, w, h))
4002 x = window.scrolledPos.x;
4003 y = window.scrolledPos.y;
4009 SNAPDOWN(x, textCellW);
4010 SNAPDOWN(y, textCellH);
4013 if(!window.style.nonClient)
4015 if(!window.style.fixed /*|| window.style.isDocument*/)
4017 if(!window.style.dontScrollHorz)
4018 x += window.parent.scroll.x;
4019 if(!window.style.dontScrollVert)
4020 y += window.parent.scroll.y;
4024 // Break the anchors for moveable/resizable windows
4025 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4026 if(window.style.fixed)
4028 if(window.state == normal)
4030 window.normalAnchor = Anchor { left = x, top = y };
4031 window.normalSizeAnchor = SizeAnchor { { w, h } };
4032 window.anchored = false;
4036 window.stateAnchor = Anchor { left = x, top = y };
4037 window.stateSizeAnchor = SizeAnchor { { w, h } };
4039 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4040 // TOCHECK: Investigate why the following only redraws the scrollbars
4041 //window.Position(x, y, w, h, false, true, true, true, false, true);
4043 guiApp.movingLast.x = mouseX;
4044 guiApp.movingLast.y = mouseY;
4050 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4053 bool wasMoving = guiApp.windowMoving ? true : false;
4054 bool wasScrolling = guiApp.windowScrolling ? true : false;
4056 while(result && w != this)
4058 Window msgWindow = GetAtPosition(x,y, false, true, w);
4059 Window trueWindow = GetAtPosition(x,y, false, false, w);
4060 bool windowDragged = false;
4065 window = (w && !w.disabled) ? w : null;
4067 if(trueWindow) incref trueWindow;
4069 if(consequential) mods->isSideEffect = true;
4071 UpdateMouseMove(x, y, consequential);
4073 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4075 if(!guiApp.windowCaptured.isEnabled)
4076 guiApp.windowCaptured.ReleaseCapture();
4078 window = guiApp.windowCaptured;
4081 if(trueWindow && activate &&
4082 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4083 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4084 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4085 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4087 if(mods->alt && !mods->ctrl && !mods->shift)
4089 Window moved = trueWindow;
4090 for(moved = trueWindow; moved; moved = moved.parent)
4091 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4096 windowDragged = true;
4098 // Cancel the ALT menu toggling...
4099 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4104 if(window && activate &&
4105 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4106 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4107 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4108 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4110 Window modalWindow = window.FindModal();
4112 /*if(mods->alt && !mods->shift && !mods->ctrl)
4114 Window moved = window;
4115 for(moved = window; moved; moved = moved.parent)
4116 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4121 windowDragged = true;
4123 // Cancel the ALT menu toggling...
4124 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4130 Window activateWindow = modalWindow ? modalWindow : window;
4131 if(activateWindow && !activateWindow.isRemote)
4133 bool doActivation = true;
4134 //bool needToDoActivation = false;
4135 Window check = activateWindow;
4137 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4139 if(!check.style.inactive)
4141 //needToDoActivation = true;
4143 doActivation = false;
4148 if(!needToDoActivation)
4149 doActivation = false;
4152 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4153 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4155 // Let the OnLeftButtonDown do the activating instead
4156 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4164 incref activateWindow;
4165 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4167 delete activateWindow;
4171 if(activateWindow._refCount == 1)
4173 delete activateWindow;
4177 delete activateWindow;
4178 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4181 mods->isActivate = true;
4185 if(!modalWindow && window && !window.destroyed)
4187 if(!guiApp.windowCaptured || windowDragged)
4189 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4191 bool moving = ((window.state != maximized &&
4192 window.IsMouseMoving(
4193 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4194 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4196 if(!moving && window.IsMouseResizing(
4197 x - window.absPosition.x,
4198 y - window.absPosition.y,
4199 window.size.w, window.size.h,
4200 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4202 guiApp.windowIsResizing = true;
4203 guiApp.windowResizingBefore.w = window.size.w;
4204 guiApp.windowResizingBefore.h = window.size.h;
4206 if(guiApp.windowIsResizing || windowDragged || moving)
4209 guiApp.windowMoving = window;
4210 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4211 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4212 guiApp.windowMovingBefore.x = window.position.x;//s;
4213 guiApp.windowMovingBefore.y = window.position.y;//s;
4214 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4215 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4218 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4220 if(window.style.fixed &&
4222 window.IsMouseMoving(
4223 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4225 window.ShowSysMenu(x, y);
4229 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4231 if(window.sbv || window.sbh)
4234 guiApp.windowScrolling = window;
4235 guiApp.windowScrollingStart.x = x;
4236 guiApp.windowScrollingStart.y = y;
4237 guiApp.windowScrollingBefore.x = window.scroll.x;
4238 guiApp.windowScrollingBefore.y = window.scroll.y;
4241 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4243 if(window.style.hasMaximize &&
4244 window.IsMouseMoving(
4245 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4248 (window.state == maximized) ? normal : maximized, false, *mods);
4256 if(guiApp.windowMoving)
4258 if(guiApp.windowMoving.parent)
4260 if(guiApp.windowMoving.style.nonClient)
4261 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4263 guiApp.windowMoving.parent.SetMouseRangeToClient();
4267 window.UpdateDecorations();
4270 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4272 // Log("\n*** LEFT BUTTON UP ***\n");
4273 if(guiApp.windowMoving)
4274 guiApp.windowMoving.StopMoving();
4276 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4278 if(guiApp.windowScrolling)
4280 Window windowScrolling = guiApp.windowScrolling;
4281 guiApp.windowScrolling = null;
4282 windowScrolling.ReleaseCapture();
4286 if(!result || (window && window.destroyed)) window = null;
4288 if(window && window.FindModal())
4291 if(trueWindow && trueWindow.FindModal())
4299 msgWindow = GetAtPosition(x,y, true, false);
4301 msgWindow.SelectMouseCursor();
4304 if(guiApp.windowCaptured || trueWindow)
4306 Window prevWindow = guiApp.prevWindow;
4307 List<Window> overWindows = guiApp.overWindows;
4308 Iterator<Window> it { overWindows };
4313 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4316 result = w.OnMouseLeave(*mods);
4318 overWindows.TakeOut(w);
4322 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4324 guiApp.prevWindow.mouseInside = false;
4325 guiApp.prevWindow = null;
4329 if(trueWindow.IsDescendantOf(prevWindow))
4331 if(!overWindows.Find(prevWindow))
4332 overWindows.Add(prevWindow);
4334 // Eventually fix this not to include captured?
4335 else if(!prevWindow.OnMouseLeave(*mods))
4339 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4341 Box box = trueWindow.box;
4342 box.left += trueWindow.absPosition.x;
4343 box.right += trueWindow.absPosition.x;
4344 box.top += trueWindow.absPosition.y;
4345 box.bottom += trueWindow.absPosition.y;
4347 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4349 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4350 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4352 overX = Max(Min(overX, 32767),-32768);
4353 overY = Max(Min(overY, 32767),-32768);
4355 trueWindow.mouseInside = true;
4356 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4360 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4362 for(w : guiApp.overWindows; w == trueWindow)
4365 guiApp.overWindows.TakeOut(w);
4368 guiApp.prevWindow = trueWindow;
4371 guiApp.prevWindow = null;
4373 SelectMouseCursor();
4375 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4376 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4378 int clientX = x - (window.absPosition.x + window.clientStart.x);
4379 int clientY = y - (window.absPosition.y + window.clientStart.y);
4381 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4383 clientX = Max(Min(clientX, 32767),-32768);
4384 clientY = Max(Min(clientY, 32767),-32768);
4386 MouseMethod = (void *)window._vTbl[method];
4388 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4391 if(!MouseMethod(window, clientX, clientY, *mods))
4395 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4396 window.OnMouseLeave(*mods);
4403 if(result && w && w.clickThrough && w.parent)
4408 if(!result || !w || !w.clickThrough)
4415 // --- Mouse cursor management ---
4417 bool KeyMessage(uint method, Key key, unichar character)
4422 if(guiApp.interimWindow)
4423 this = guiApp.interimWindow;
4426 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4430 if(!style.inactive || rootWindow != this)
4432 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4433 Window modalWindow = FindModal();
4434 Window interimMaster = master ? master.rootWindow : null;
4438 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4439 status = OnSysKeyDown(key, character);
4440 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4441 status = OnSysKeyHit(key, character);
4442 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4443 status = OnSysKeyUp(key, character);
4450 // Process Key Message for Internal UI Keyboard actions
4451 if(status && !destroyed && menuBar && state != minimized)
4454 if((SmartKey)key != alt)
4455 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4458 SmartKey sk = (SmartKey) key;
4459 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4461 status = menuBar.KeyMessage(method, key, character);
4466 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4467 menuBar.OnKeyHit(escape, 0);
4469 if(!menuBar.focus && guiApp.caretOwner)
4470 guiApp.caretOwner.UpdateCaret(true, false);
4473 if(!destroyed && status)
4475 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4479 case left: case up: case right: case down:
4480 if(guiApp.windowMoving == this)
4483 int w = guiApp.windowMoving.size.w;
4484 int h = guiApp.windowMoving.size.h;
4485 int x = guiApp.windowMoving.scrolledPos.x;
4486 int y = guiApp.windowMoving.scrolledPos.y;
4490 if(key == down || key == up)
4491 step = Max(step, textCellH);
4493 step = Max(step, textCellW);
4496 if(guiApp.windowIsResizing)
4500 case left: w-=step; break;
4501 case right: w+=step; break;
4502 case up: h-=step; break;
4503 case down: h+=step; break;
4510 case left: x-=step; break;
4511 case right: x+=step; break;
4512 case up: y-=step; break;
4513 case down: y+=step; break;
4517 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4518 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4520 if(!guiApp.windowIsResizing || guiApp.resizeX)
4521 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4523 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4525 if(!guiApp.windowIsResizing || guiApp.resizeY)
4526 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4528 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4530 guiApp.interfaceDriver.SetMousePosition(x, y);
4531 ConsequentialMouseMove(true);
4539 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4541 guiApp.windowMoving.StopMoving();
4542 ConsequentialMouseMove(false);
4550 ShowSysMenu(absPosition.x, absPosition.y);
4558 if(!destroyed && status && state != minimized)
4560 // Process all the way down the children
4561 if(activeChild && !activeChild.disabled)
4563 status = activeChild.KeyMessage(method, key, character);
4565 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4566 key.code != left && key.code != right && key.code != up && key.code != down)
4568 status = activeClient.KeyMessage(method, key, character);
4572 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4574 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4575 // && defaultControl != activeChild)
4577 delete previousActive;
4578 previousActive = activeChild;
4579 if(previousActive) incref previousActive;
4581 ConsequentialMouseMove(false);
4582 if((defaultControl.active ||
4583 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4584 defaultControl.KeyMessage(method, defaultKey, character);
4590 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4592 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4599 ShowSysMenu(absPosition.x, absPosition.y);
4606 if(this != guiApp.desktop)
4608 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4610 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4612 MenuMoveOrSize(key.shift, true);
4616 else if(guiApp.windowMoving)
4618 guiApp.windowMoving.StopMoving();
4619 ConsequentialMouseMove(false);
4627 if(!destroyed && status && state != minimized)
4629 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4633 case tab: case shiftTab:
4635 Window cycleParent = this;
4636 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4637 cycleParent = master.parent;
4639 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4641 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4644 Window child = cycleParent.activeChild;
4646 // Scroll the window to include the active control
4647 if(cycleParent.sbh && !child.style.dontScrollHorz)
4649 if(child.scrolledPos.x < 0)
4650 cycleParent.sbh.Action(Position,
4651 cycleParent.scroll.x + child.scrolledPos.x, 0);
4652 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4653 cycleParent.sbh.Action(Position,
4654 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4656 if(cycleParent.sbv && !child.style.dontScrollVert)
4658 if(child.scrolledPos.y < 0)
4659 cycleParent.sbv.Action(Position,
4660 cycleParent.scroll.y + child.scrolledPos.y, 0);
4661 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4662 cycleParent.sbv.Action(Position,
4663 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4666 cycleParent.ConsequentialMouseMove(false);
4672 case f6: case shiftF6:
4673 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4675 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4676 if(parent == guiApp.desktop)
4677 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4687 if(CycleChildren(key.shift, true, false, true))
4695 // mIRC Style Window Shortcuts
4696 case alt1: case alt2: case alt3: case alt4: case alt5:
4697 case alt6: case alt7: case alt8: case alt9: case alt0:
4702 for(document = children.first; document; document = document.next)
4704 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4706 if(document == activeChild)
4708 if(document.state == minimized)
4709 document.SetState(normal, false, key);
4712 document.SetState(minimized, false, key);
4713 CycleChildren(false, true, false);
4718 if(activeChild.state == maximized && document.style.hasMaximize)
4719 document.SetState(maximized, false, key);
4720 else if(document.state == minimized)
4721 document.SetState(normal, false, key);
4722 document.Activate();
4737 if(!destroyed && status)
4739 if(state == minimized)
4744 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4746 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4748 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4749 previousActive.ActivateEx(true, false, false, true, null, null);
4750 delete previousActive;
4756 if(!destroyed && status)
4758 status = ProcessHotKeys(method, key, character);
4760 if(!destroyed && status && !modalWindow && state != minimized)
4763 status = KeyMethod(this, key, character);
4764 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4765 status = OnKeyHit(key, character);
4766 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4768 bool result = false;
4771 case ctrlUp: case ctrlDown:
4772 if(sbv && !guiApp.windowScrolling)
4773 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4775 case wheelUp: case wheelDown:
4776 if(sbv && !guiApp.windowScrolling)
4778 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4779 // Do we want to do a consequential move regardless of result in this case?
4780 ConsequentialMouseMove(false);
4783 case ctrlPageUp: case ctrlPageDown:
4784 if(sbh && !guiApp.windowScrolling)
4785 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4790 ConsequentialMouseMove(false);
4795 if(status && !destroyed && menuBar && state != minimized)
4796 status = menuBar.KeyMessage(method, key, character);
4798 if(style.interim && /*destroyed && */status && interimMaster)
4800 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4801 status = interimMaster.KeyMessage(method, key, character);
4808 bool ProcessHotKeys(uint method, Key key, unichar character)
4813 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4814 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4815 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4817 Window hotKeyWindow = hotKey.window;
4818 Window parent = hotKeyWindow.parent;
4819 Window prevActiveWindow = activeChild;
4820 // For when sys buttons are placed inside the menu bar
4821 if(parent && parent._class == class(PopupMenu))
4822 parent = parent.parent;
4824 // 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
4825 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4828 if(prevActiveWindow) incref prevActiveWindow;
4829 incref hotKeyWindow;
4830 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4831 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4834 delete hotKeyWindow;
4835 delete prevActiveWindow;
4839 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4840 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4841 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4843 // ********* WORKING ON THIS ***********
4844 if(prevActiveWindow && !guiApp.interimWindow)
4845 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4848 else if(hotKeyWindow.style.inactive)
4849 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4851 delete prevActiveWindow;
4852 delete hotKeyWindow;
4853 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4854 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4858 if(status && tabCycle)
4861 for(child = children.first; child; child = child.next)
4863 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4874 // --- Windows and graphics initialization / termination ---
4875 bool SetupRoot(void)
4879 // Setup relationship with outside world (bb root || !bb)
4880 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4881 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4885 tempExtents = new0 Extent[4];
4890 /*if(guiApp.fullScreenMode)
4891 rootWindow = guiApp.desktop;
4893 //rootWindow = parent.created ? parent.rootWindow : null;
4894 rootWindow = parent.rootWindow;
4897 against = &parent.box;
4899 against = &parent.clientArea;
4902 for(child = children.first; child; child = child.next)
4905 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4908 bool Setup(bool positionChildren)
4910 bool result = false;
4913 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4915 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4916 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4919 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4921 // This was here, is it really needed?
4922 //guiApp.interfaceDriver.ActivateRootWindow(this);
4926 displaySystem = DisplaySystem {};
4927 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4929 delete displaySystem;
4934 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4935 if(display.Create(displaySystem, windowHandle))
4942 // Sometimes icon does not show up on Windows XP if we set here...
4943 // guiApp.interfaceDriver.SetIcon(this, icon);
4945 else if(this != guiApp.desktop)
4947 display = rootWindow ? rootWindow.display : null;
4953 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4954 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4956 for(child = children.first; child; child = child.next)
4958 if(child.created && !child.Setup(false))
4961 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4962 child.UpdateCaption();
4967 bool SetupDisplay(void)
4969 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4970 if(is3D) return Window3D_SetupDisplay(this); else
4977 class_data void ** pureVTbl;
4979 bool LoadGraphics(bool creation, bool resetAnchors)
4981 bool result = false;
4982 bool success = false;
4984 WindowState stateBackup = state;
4986 if(((subclass(Window))_class).pureVTbl)
4988 if(_vTbl == _class._vTbl)
4990 _vTbl = ((subclass(Window))_class).pureVTbl;
4995 for(m = 0; m < _class.vTblSize; m++)
4997 if(_vTbl[m] == _class._vTbl[m])
4998 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5002 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
5004 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5006 _vTbl = _class._vTbl;
5011 for(m = 0; m < _class.vTblSize; m++)
5013 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5014 _vTbl[m] = _class._vTbl[m];
5019 if(guiApp.fullScreenMode || this != guiApp.desktop)
5021 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5027 display.Lock(false);
5028 if(rootWindow == this)
5030 // Set Color Palette
5031 display.SetPalette(palette, true);
5035 if(guiApp.fullScreenMode && this == guiApp.desktop)
5040 for(c=0; c<SystemCursor::enumSize; c++)
5041 if(!guiApp.systemCursors[c].bitmap)
5043 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5044 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5045 if(guiApp.systemCursors[c].bitmapName)
5047 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5048 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5049 if(guiApp.systemCursors[c].bitmap)
5050 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5055 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5057 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5058 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5060 cursor.bitmap.paletteShades = cursor.paletteShades;
5064 guiApp.cursorUpdate = true;
5067 ConsequentialMouseMove(false);
5073 // Load Window Graphic Resources
5076 if(usedFont == setFont || usedFont == window.systemFont)
5077 RemoveResource(usedFont);
5080 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5083 RemoveResource(systemFont);
5086 RemoveResource(captionFont);
5088 for(ptr = resources.first; ptr; ptr = ptr.next)
5090 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5091 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5094 AddResource(setFont);
5096 AddResource(systemFont);
5098 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5105 //if(master && master.font)
5106 if(parent && parent.font)
5110 faceName = parent.font.faceName,
5111 size = parent.font.size,
5112 bold = parent.font.bold,
5113 italic = parent.font.italic,
5114 underline = parent.font.underline
5116 //font = parent.font;
5117 watch(parent) { font { } };
5120 font = guiApp.currentSkin.SystemFont();
5127 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5128 AddResource(captionFont);
5130 if(OnLoadGraphics())
5136 //SetScrollLineStep(sbStep.x, sbStep.y);
5138 if(this != guiApp.desktop)
5142 normalAnchor = anchor;
5143 normalSizeAnchor = sizeAnchor;
5146 // Break the anchors for moveable/resizable windows
5148 if(style.fixed && style.isDocument)
5150 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5162 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5163 stateSizeAnchor = SizeAnchor {};
5168 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5173 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5174 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5177 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5181 stateAnchor = normalAnchor;
5182 stateSizeAnchor = normalSizeAnchor;
5185 position = Point { };
5186 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5197 if(Position(x, y, w, h, true, false, true, true, true, true))
5199 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5202 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5219 success = result = true;
5222 if(!creation && result)
5224 // Load menu bar first because sys buttons are on it...
5227 if(!menuBar.LoadGraphics(false, resetAnchors))
5233 for(child = children.first; child; child = child.next)
5235 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5242 CreateSystemChildren();
5246 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5249 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5252 LogErrorCode(graphicsLoadingFailed, _class.name);
5254 // Do this here to avoid problems on Windows
5255 if(rootWindow == this && parent && stateBackup == maximized)
5256 property::state = maximized;
5260 void UnloadGraphics(bool destroyWindows)
5264 // Free children's graphics
5265 for(child = children.first; child; child = child.next)
5266 child.UnloadGraphics(destroyWindows);
5269 display.Lock(false);
5272 if(guiApp.fullScreenMode && this == guiApp.desktop)
5277 for(c=0; c<SystemCursor::enumSize; c++)
5278 if(guiApp.systemCursors[c].bitmap)
5279 delete guiApp.systemCursors[c].bitmap;
5281 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5282 delete cursor.bitmap;
5284 guiApp.cursorBackground.Free();
5287 if(display && display.displaySystem)
5291 for(ptr = resources.first; ptr; ptr = ptr.next)
5295 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5300 // Free window graphics
5303 // Free skin graphics
5304 if(rootWindow == this)
5306 DisplaySystem displaySystem = display.displaySystem;
5309 display.driverData = null;
5310 display.displaySystem = null;
5314 if(displaySystem && !displaySystem.numDisplays && !is3D)
5315 delete displaySystem;
5324 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5325 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5327 if(this == guiApp.desktop || parent == guiApp.desktop)
5329 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5330 guiApp.interfaceDriver.DestroyRootWindow(this);
5334 // --- Window Hiding ---
5336 void SetVisibility(bool state)
5338 bool visible = (style.hidden || !created) ? false : state;
5339 if(visible != this.visible)
5343 this.visible = visible;
5344 for(child = children.first; child; child = child.next)
5345 child.SetVisibility(visible);
5347 ConsequentialMouseMove(false);
5348 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5352 // --- Windows and graphics initialization / termination ---
5354 bool DisplayModeChanged(void)
5356 bool result = false;
5357 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5359 guiApp.modeSwitching = true;
5360 UnloadGraphics(false);
5362 if(LoadGraphics(false, false))
5364 guiApp.modeSwitching = false;
5369 // --- Window updates system ---
5371 void UpdateDirty(Box updateBox)
5373 if(!manageDisplay) { OnRedraw(null);return; }
5376 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5379 if(display.flags.flipping)
5382 rootWindow.UpdateDisplay();
5385 UpdateBackDisplay(updateBox);
5387 if(guiApp.fullScreenMode)
5389 guiApp.cursorUpdate = true;
5390 guiApp.PreserveAndDrawCursor();
5392 if(guiApp.fullScreenMode)
5393 guiApp.RestoreCursorBackground();
5399 // This function is strictly called as a result of system window activation
5400 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5403 Window interimMaster = null;
5404 Window interimWindow = guiApp.interimWindow;
5405 if(interimWindow && interimWindow.master)
5406 interimMaster = interimWindow.master.rootWindow;
5408 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5409 // SetState(normal, false, 0);
5410 SetState(lastState, false, 0);
5412 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5416 /* WTH is this doing here?
5417 while(swap && swap.activeChild)
5419 swap = swap.activeChild;
5422 // TESTING THIS BEFORE...
5423 if(interimWindow && this == interimMaster)
5427 // Window interimSwap = this;
5428 Window menuBar = this.menuBar;
5429 if(menuBar && interimWindow.master == menuBar)
5432 while(interimSwap && interimSwap.activeChild)
5433 interimSwap = interimSwap.activeChild;
5435 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5436 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5438 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5439 //result = ActivateEx(true, true, false, activateRoot, window, null);
5444 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5445 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5447 if(interimWindow == this && interimMaster && !active)
5449 while(interimMaster && interimMaster.interim && interimMaster.master)
5451 // printf("Going up one master %s\n", interimMaster._class.name);
5452 interimMaster = interimMaster.master.rootWindow;
5454 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5455 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5461 bool DestroyEx(int64 returnCode)
5464 Timer timer, nextTimer;
5466 OldLink prevOrder = null;
5467 Window client = null;
5469 if(parent) stopwatching(parent, font);
5471 // if(window.modalSlave) return false;
5472 if(destroyed || !created)
5479 OldLink slave = master.slaves.FindLink(this);
5480 master.slaves.Delete(slave);
5483 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5489 this.returnCode = (DialogResult)returnCode;
5491 AcquireInput(false);
5496 master.hotKeys.Delete(hotKey);
5500 if(guiApp.prevWindow == this)
5502 guiApp.prevWindow = null;
5507 for(w : guiApp.overWindows; w == this)
5510 guiApp.overWindows.TakeOut(w);
5514 if(guiApp.caretOwner == this)
5516 guiApp.interfaceDriver.SetCaret(0,0,0);
5517 UpdateCaret(false, true);
5518 guiApp.caretEnabled = false;
5523 parent.childrenCycle.Remove(cycle);
5527 OldLink tmpPrev = order.prev;
5528 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5529 prevOrder = tmpPrev;
5532 client = tmpPrev ? tmpPrev.data : null;
5533 if(client == this) { client = null; break; }
5534 if(client && (client.style.hidden || client.destroyed || !client.created))
5535 tmpPrev = client.order.prev;
5539 prevOrder = tmpPrev;
5544 // If this window can be an active client, make sure the next window we activate can also be one
5545 if(!style.nonClient && style.isActiveClient)
5547 tmpPrev = prevOrder;
5550 client = tmpPrev ? tmpPrev.data : null;
5551 if(client == this) { client = null; break; }
5552 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5553 tmpPrev = client.order.prev;
5557 prevOrder = tmpPrev;
5561 if(client && client.style.hidden) client = null;
5563 // parent.childrenOrder.Remove(order);
5566 if(parent && style.isActiveClient && visible)
5568 if(state == minimized) parent.numIcons--;
5569 parent.numPositions--;
5572 // TESTING THIS HERE!
5576 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5577 // to create a window inside a rootwindow that's being destroyed)
5578 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5580 if(master && !master.destroyed /*&&
5581 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5583 if(master.defaultControl == this)
5584 master.defaultControl = null;
5587 parent.OnChildAddedOrRemoved(this, true);
5588 if(parent && !parent.destroyed /*&&
5589 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5591 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5593 if(order && prevOrder && prevOrder.data != this && active)
5595 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5597 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5598 if(parent.activeClient == this)
5600 parent.activeClient = null;
5601 parent.UpdateActiveDocument(null);
5606 if(guiApp.interimWindow == this)
5609 PropagateActive(false, null, &goOn, true);
5613 //if(window.parent.activeChild == window)
5614 parent.activeChild = null;
5615 if(!style.nonClient /*&& style.isActiveClient*/)
5617 Window previous = parent.activeClient;
5618 if(style.isActiveClient)
5619 parent.activeClient = null;
5620 parent.UpdateActiveDocument(previous);
5625 else if(parent.activeClient == this)
5627 parent.activeClient = client;
5628 parent.UpdateActiveDocument(this);
5632 if(guiApp.interimWindow == this)
5634 guiApp.interimWindow = null;
5635 if(guiApp.caretOwner)
5637 Window desktop = guiApp.desktop;
5638 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5639 guiApp.caretOwner.UpdateCaret(false, false);
5644 if(_isModal && master && master.modalSlave == this)
5645 master.modalSlave = null;
5649 if(!guiApp.caretOwner && parent.caretSize)
5651 guiApp.caretOwner = parent;
5652 parent.UpdateCaret(false, false);
5653 parent.Update(null);
5656 // Why was this commented out?
5657 GetRidOfVirtualArea();
5663 dirtyArea.Free(null);
5664 dirtyBack.Free(null);
5665 scrollExtent.Free(null);
5667 /* ATTEMPTING TO MOVE THAT ABOVE
5676 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5677 for(;(child = window.children.first);)
5679 for(; child && (child.destroyed || !child.created); child = child.next);
5688 UnloadGraphics(true);
5691 delete previousActive;
5694 // statusBar = null;
5697 if(master && !master.destroyed)
5699 //master.NotifyDestroyed(this, this.returnCode);
5700 NotifyDestroyed(master, this, this.returnCode);
5703 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5705 nextTimer = timer.next;
5706 if(timer.window == this)
5708 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5709 // timer.window = null;
5715 if(this == guiApp.windowMoving)
5718 if(guiApp.windowCaptured == this)
5720 //guiApp.windowCaptured = null;
5722 if(rootWindow != this && rootWindow)
5723 rootWindow.ConsequentialMouseMove(false);
5731 //for(child = children.first; next = child ? child.next : null, child; child = next)
5732 for(;(child = children.first); )
5734 for(; child && (child.destroyed || !child.created); child = child.next);
5744 /* // MOVED THIS UP...
5747 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5748 for(;(child = window.children.first); )
5750 for(; child && (child.destroyed || !child.created); child = child.next);
5759 while((slave = slaves.first))
5761 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5763 ((Window)slave.data).DestroyEx(0);
5768 if(guiApp.caretOwner == this)
5769 guiApp.caretOwner = null;
5771 sysButtons[0] = null;
5772 sysButtons[1] = null;
5773 sysButtons[2] = null;
5776 if(rootWindow != this)
5778 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5781 box.left -= parent.clientStart.x;
5782 box.top -= parent.clientStart.y;
5783 box.right -= parent.clientStart.x;
5784 box.bottom -= parent.clientStart.y;
5786 if(parent) parent.Update(box);
5791 OldLink slave = master.slaves.FindVoid(this);
5792 master.slaves.Delete(slave);
5798 parent.children.Remove(this);
5803 //autoCreate = false;
5806 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5807 if(((subclass(Window))_class).pureVTbl)
5809 if(_vTbl == _class._vTbl)
5811 _vTbl = ((subclass(Window))_class).pureVTbl;
5816 for(m = 0; m < _class.vTblSize; m++)
5818 if(_vTbl[m] == _class._vTbl[m])
5819 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5828 void SetStateEx(WindowState newState, bool activate)
5831 WindowState prevState = state;
5835 if(prevState != newState)
5836 lastState = prevState;
5838 if(rootWindow != this || !nativeDecorations || !windowHandle)
5840 if(style.isActiveClient && !style.hidden && prevState == minimized)
5843 // This block used to be at the end of the function... moved it for flicker problem in X
5844 // ------------------------------------------------------
5848 stateAnchor = normalAnchor;
5849 stateSizeAnchor = normalSizeAnchor;
5852 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5853 stateSizeAnchor = SizeAnchor {};
5857 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5860 byte * idBuffer = new0 byte[size];
5862 for(child = parent.children.first; child; child = child.next)
5864 if(child != this && child.state == minimized)
5866 if(child.iconID > size - 2)
5868 idBuffer = renew0 idBuffer byte[size*2];
5869 memset(idBuffer + size, 0, size);
5872 idBuffer[child.iconID] = (byte)bool::true;
5875 for(c = 0; c<size; c++)
5880 if(style.isActiveClient && !style.hidden)
5883 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5884 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5888 // TOCHECK: Why was this here?
5889 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5890 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5891 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5893 Position(x, y, w, h, true, true, true, true, false, true);
5895 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5896 parent.UpdateActiveDocument(null);
5899 CreateSystemChildren();
5900 // ------------------------------------------------------
5903 int GetPositionID(Window forChild)
5907 byte * idBuffer = new0 byte[size];
5910 for(child = children.first; child; child = child.next)
5912 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5914 if(child.positionID > size - 2)
5916 idBuffer = renew0 idBuffer byte[size*2];
5917 memset(idBuffer + size, 0, size);
5920 idBuffer[child.positionID] = (byte)bool::true;
5923 for(c = 0; c<size; c++)
5930 // --- Window related graphics ---
5932 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5934 palette = newPalette;
5935 if(rootWindow.display)
5936 rootWindow.display.SetPalette(palette, colorMatch);
5939 public bool AcquireInput(bool acquired)
5942 if(acquiredInput != acquired)
5944 if(active || (!visible && creationActivation == activate))
5945 result = AcquireInputEx(acquired);
5950 acquiredInput = acquired ? result : !result;
5955 void ListChildren(ListBox listBox)
5959 for(child = children.first; child; child = child.next)
5961 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5963 DataRow row = listBox.AddRow();
5964 row.tag = (int64)(intptr)child;
5965 child.FigureCaption(caption);
5966 row.SetData(null, caption);
5971 void UpdateVisual(Box extent)
5973 if(guiApp.driver != null)
5975 if(guiApp.fullScreenMode && guiApp.desktop.display)
5977 #if !defined(__EMSCRIPTEN__)
5978 guiApp.desktop.mutex.Wait();
5980 guiApp.desktop.display.Lock(true);
5983 if(guiApp.desktop.active)
5985 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5987 if(guiApp.desktop.display.flags.flipping)
5988 guiApp.desktop.Update(null);
5989 guiApp.desktop.UpdateDisplay();
5990 guiApp.cursorUpdate = true;
5992 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5994 guiApp.PreserveAndDrawCursor();
5995 // guiApp.desktop.display.ShowScreen();
5996 guiApp.cursorUpdate = false;
5997 guiApp.desktop.dirty = false;
5998 guiApp.RestoreCursorBackground();
6002 guiApp.desktop.display.Unlock();
6003 #if !defined(__EMSCRIPTEN__)
6004 guiApp.desktop.mutex.Release();
6009 Window rootWindow = this.rootWindow;
6010 #if !defined(__EMSCRIPTEN__)
6011 rootWindow.mutex.Wait();
6017 guiApp.SignalEvent();
6020 #if !defined(__EMSCRIPTEN__)
6021 guiApp.waitMutex.Wait();
6023 guiApp.interfaceDriver.Lock(rootWindow);
6024 if(!rootWindow.style.hidden && rootWindow.dirty)
6026 if(rootWindow.display)
6028 rootWindow.UpdateDisplay();
6029 //rootWindow.display.ShowScreen(null);
6031 rootWindow.dirty = false;
6033 guiApp.interfaceDriver.Unlock(rootWindow);
6034 #if !defined(__EMSCRIPTEN__)
6035 guiApp.waitMutex.Release();
6039 #if !defined(__EMSCRIPTEN__)
6040 rootWindow.mutex.Release();
6046 void UnlockDisplay(void)
6048 guiApp.interfaceDriver.Unlock(rootWindow);
6051 void LockDisplay(void)
6053 guiApp.interfaceDriver.Lock(rootWindow);
6056 Surface GetSurface(Box box)
6058 return Redraw((box == null) ? this.box : box);
6061 void SetMousePosition(int x, int y)
6063 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6067 void IntegrationActivate(bool active)
6069 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6071 isForegroundWindow = true;
6072 ActivateEx(active, active, false, false, null, null);
6073 isForegroundWindow = false;
6078 Window QueryCapture(void)
6080 return guiApp.windowCaptured;
6083 int GetDocumentID(void)
6087 byte * idBuffer = new0 byte[size];
6090 for(child = children.first; child; child = child.next)
6092 // TO CHECK: Do we want a documentID when we already have a file name?
6093 if(child.style.isDocument && !child.fileName)
6095 if(child.documentID-1 > size - 2)
6097 idBuffer = renew0 idBuffer byte[size*2];
6098 memset(idBuffer + size, 0, size);
6101 idBuffer[child.documentID-1] = 1;
6104 for(c = 0; c<size; c++)
6112 void SetInitSize(Size size)
6115 sizeAnchor.size = size;
6116 normalSizeAnchor = sizeAnchor;
6118 // Break the anchors for moveable/resizable windows
6119 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6121 stateAnchor = normalAnchor;
6122 stateSizeAnchor = normalSizeAnchor;
6124 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6125 Position(x,y, w, h, true, true, true, true, false, true);
6129 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6131 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6133 guiApp.windowIsResizing = resize;
6134 guiApp.windowMoving = this;
6135 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6136 if(guiApp.windowIsResizing)
6138 guiApp.windowMovingStart.x += size.w - 1;
6139 guiApp.windowMovingStart.y += size.h - 1;
6141 guiApp.windowMovingBefore = scrolledPos;
6142 guiApp.windowResizingBefore = size;
6143 guiApp.windowMoving.UpdateDecorations();
6144 if(guiApp.windowIsResizing)
6145 guiApp.resizeEndX = guiApp.resizeEndY = true;
6147 if(setCursorPosition)
6148 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6152 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6153 guiApp.windowMovingStart.x += x - absPosition.x;
6154 guiApp.windowMovingStart.y += y - absPosition.y;
6157 if(guiApp.windowMoving)
6159 if(guiApp.windowMoving.style.nonClient)
6160 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6162 guiApp.windowMoving.parent.SetMouseRangeToClient();
6167 if(this == rootWindow)
6168 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6172 void SetupFileMonitor()
6174 #if !defined(__EMSCRIPTEN__)
6177 fileMonitor = FileMonitor
6179 this, FileChange { modified = true };
6181 bool OnFileNotify(FileChange action, const char * param)
6184 fileMonitor.StopMonitoring();
6185 if(OnFileModified(action, param))
6186 fileMonitor.StartMonitoring();
6200 bool result = false;
6204 else if(guiApp && guiApp.driver != null)
6206 OldLink slaveHolder;
6208 bool visible = !style.hidden;
6212 systemParent = parent;
6213 parent = guiApp.desktop;
6215 last = parent ? parent.children.last : null;
6217 if((parent && parent != guiApp.desktop && !parent.created) ||
6218 (master && master != guiApp.desktop && !master.created))
6222 stopwatching(parent, font);
6225 property::parent = guiApp.desktop;
6226 if(!master) master = parent;
6228 if(_isModal && master.modalSlave)
6229 property::master = master.modalSlave;
6233 parent.children.Remove(this);
6236 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6237 if(slaveHolder.data == this)
6239 master.slaves.Delete(slaveHolder);
6244 #if !defined(__EMSCRIPTEN__)
6245 if(parent == guiApp.desktop && !mutex)
6249 if(style.isDocument)
6252 parent.numDocuments--;
6253 documentID = parent.GetDocumentID();
6256 if(!style.stayOnTop)
6257 for(; last && last.style.stayOnTop; last = last.prev);
6259 parent.children.Insert((last == this) ? null : last, this);
6260 //parent.children.Add(this);
6263 dispDriver = parent.dispDriver;
6266 master.modalSlave = this;
6268 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6273 master.slaves.Add(slaveHolder = OldLink { data = this });
6278 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6280 if(style.isDefault && !master.defaultControl)
6281 master.defaultControl = this;
6283 stateAnchor = normalAnchor = anchor;
6284 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6286 // TOCHECK: Why is this here?
6287 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6288 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6290 this.visible = false;
6291 style.hidden = true;
6294 // autoCreate = true;
6302 if(parent == guiApp.desktop)
6303 Log("LoadGraphics %s\n", caption);
6305 if(LoadGraphics(true, false))
6313 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6320 if(style.hasMenuBar /*&& menu*/)
6326 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6327 interim = false, inactive = true, nonClient = true, size.h = 24
6335 // Create the system buttons
6336 CreateSystemChildren();
6338 UpdateActiveDocument(null);
6340 if(style.isDocument)
6344 MenuItem item = menu.FindItem(MenuFileSave, 0);
6345 if(item) item.disabled = !modifiedDocument && fileName;
6350 if(parent == guiApp.desktop)
6351 Log("Preemptive SetState %s\n", caption);
6354 // Preemptive Set State to ensure proper anchoring
6355 SetStateEx(state, false);
6357 style.hidden = true;
6363 for(child = children.first; child; child = next)
6366 if(!child.created && (child.autoCreate || child.wasCreated))
6373 for(link = slaves.first; link; link = next)
6375 Window slave = link.data;
6377 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6380 // Things might have happened that invalidated 'next'...
6381 // Start over the search for slaves to create.
6382 // (Added this to fix crash with Stacker & Toolbar)
6383 next = slaves.first;
6392 if(parent == guiApp.desktop)
6393 Log("Real SetState %s\n", caption);
6396 if(isActiveClient && visible)
6398 parent.numPositions--;
6399 if(state == minimized) parent.numIcons--;
6402 parent.OnChildAddedOrRemoved(this, false);
6404 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6406 // Real set state & activate for proper display & activation
6407 property::visible = visible;
6408 // SetState(state & 0x00000003, true, 0);
6409 guiApp.interfaceDriver.SetIcon(this, icon);
6414 /*if(rootWindow == this)
6415 guiApp.interfaceDriver.ActivateRootWindow(this);
6417 if(creationActivation == activate && guiApp.desktop.active)
6418 ActivateEx(true, false, true, true, null, null);
6419 else if(creationActivation == activate || creationActivation == flash)
6422 if(this == rootWindow)
6428 rootWindow.ConsequentialMouseMove(false);
6439 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6445 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6447 //style.hidden = true; // !visible;
6448 style.hidden = !visible;
6449 if(master.modalSlave == this)
6450 master.modalSlave = null;
6457 void WriteCaption(Surface surface, int x, int y)
6460 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6463 void Update(Box region)
6469 rootWindow = this.rootWindow;
6471 // rootWindow.mutex.Wait();
6472 if(!destroyed && visible && display)
6477 // Testing this to avoid repetitve full update to take time...
6478 if(rootWindow.fullRender)
6480 rootWindow.dirty = true;
6483 if(dirtyArea.count == 1)
6485 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6486 if(item.box.left <= box.left &&
6487 item.box.top <= box.top &&
6488 item.box.right >= box.right &&
6489 item.box.bottom >= box.bottom)
6491 rootWindow.dirty = true;
6496 if(display.flags.flipping && !rootWindow.dirty)
6498 if(this == rootWindow)
6502 rootWindow.Update(null);
6507 rootWindow.dirty = true;
6512 realBox.left += clientStart.x;
6513 realBox.top += clientStart.y;
6514 realBox.right += clientStart.x;
6515 realBox.bottom += clientStart.y;
6521 if(realBox.right >= realBox.left &&
6522 realBox.bottom >= realBox.top)
6524 // if(!rootWindow.fullRender)
6525 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6527 for(child = children.first; child; child = child.next)
6532 box.left -= child.absPosition.x - absPosition.x;
6533 box.top -= child.absPosition.y - absPosition.y;
6534 box.right -= child.absPosition.x - absPosition.x;
6535 box.bottom -= child.absPosition.y - absPosition.y;
6536 if(box.right >= child.box.left && box.left <= child.box.right &&
6537 box.bottom >= child.box.top && box.top <= child.box.bottom)
6539 box.left -= child.clientStart.x;
6540 box.top -= child.clientStart.y;
6541 box.right -= child.clientStart.x;
6542 box.bottom -= child.clientStart.y;
6548 realBox.left += absPosition.x - rootWindow.absPosition.x;
6549 realBox.top += absPosition.y - rootWindow.absPosition.y;
6550 realBox.right += absPosition.x - rootWindow.absPosition.x;
6551 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6552 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6555 else if(this == guiApp.desktop)
6558 for(window = children.first; window; window = window.next)
6564 Box childBox = region;
6566 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6567 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6568 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6569 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6571 window.Update(childBox);
6574 window.Update(null);
6579 // rootWindow.mutex.Release();
6586 if(guiApp.windowCaptured != this)
6588 if(guiApp.windowCaptured)
6592 //Logf("Captured %s (%s)\n", caption, class.name);
6593 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6594 guiApp.windowCaptured = this;
6600 bool Destroy(int64 code)
6605 if(!destroyed && !CloseConfirmation(false)) return false;
6609 // TOCHECK: Should autoCreate be set to false here?
6620 void Move(int x, int y, int w, int h)
6622 normalAnchor = Anchor { left = x, top = y };
6623 normalSizeAnchor = SizeAnchor { size = { w, h } };
6625 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6627 if(destroyed) return;
6629 stateAnchor = normalAnchor;
6630 stateSizeAnchor = normalSizeAnchor;
6632 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6633 Position(x,y, w, h, true, true, true, true, false, true);
6637 DialogResult Modal(void)
6643 // FIXES MEMORY LEAK IF Create() FAILED
6649 void SetScrollArea(int width, int height, bool snapToStep)
6653 int stepX = sbStep.x, stepY = sbStep.y;
6654 // Needed to make snapped down position match the skin's check of client area
6655 // against realvirtual
6658 SNAPDOWN(stepX, textCellW);
6659 SNAPDOWN(stepY, textCellH);
6660 stepX = Max(stepX, textCellW);
6661 stepY = Max(stepY, textCellH);
6663 if(scrollFlags.snapX)
6664 SNAPUP(width, stepX);
6665 if(scrollFlags.snapY)
6666 SNAPUP(height, stepY);
6669 reqScrollArea.w = width;
6670 reqScrollArea.h = height;
6671 noAutoScrollArea = (width > 0 || height > 0);
6673 UpdateScrollBars(true, true);
6676 void SetScrollPosition(int x, int y)
6679 sbh.Action(setPosition, x, 0);
6683 int seen = clientSize.w, total = reqScrollArea.w;
6685 if(scrollFlags.snapX)
6686 SNAPDOWN(seen, sbStep.x);
6688 if(!total) total = seen;
6689 range = total - seen + 1;
6690 range = Max(range, 1);
6692 if(x >= range) x = range - 1;
6694 if(scrollFlags.snapX)
6695 SNAPUP(x, sbStep.x);
6698 OnHScroll(setPosition, x, 0);
6702 SNAPDOWN(x, textCellW);
6708 sbv.Action(setPosition, y, 0);
6712 int seen = clientSize.h, total = reqScrollArea.h;
6715 if(scrollFlags.snapY)
6716 SNAPDOWN(seen, sbStep.y);
6718 if(!total) total = seen;
6719 range = total - seen + 1;
6720 range = Max(range, 1);
6722 if(y >= range) y = range - 1;
6724 if(scrollFlags.snapY)
6725 SNAPUP(y, sbStep.y);
6728 OnVScroll(setPosition, y, 0);
6731 SNAPDOWN(y, textCellH);
6736 UpdateCaret(false, false);
6739 void SetScrollLineStep(int stepX, int stepY)
6745 SNAPDOWN(stepX, textCellW);
6746 SNAPDOWN(stepY, textCellH);
6747 stepX = Max(stepX, textCellW);
6748 stepY = Max(stepY, textCellH);
6751 sbh.lineStep = stepX;
6753 sbv.lineStep = stepY;
6756 void SetState(WindowState newState, bool activate, Modifiers mods)
6760 if(state == newState || OnStateChange(newState, mods))
6762 //WindowState prevState = state;
6766 // This used to be at the end of the brackets... moved for X, testing...
6767 // This has the effect of activating the window through the system...
6768 if(rootWindow == this)
6769 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6771 SetStateEx(newState, activate);
6773 if(rootWindow == this && !rootWindow.nativeDecorations)
6775 int x = position.x, y = position.y;
6778 x -= guiApp.desktop.absPosition.x;
6779 y -= guiApp.desktop.absPosition.y;
6781 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6785 //state = prevState;
6787 if(state != maximized && style.hasMaximize)
6790 for(child = parent.children.first; child; child = child.next)
6792 if(child != this && child.state == maximized)
6793 child.SetStateEx(normal, false);
6797 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6798 parent.UpdateScrollBars(true, true);
6801 // Do we really need this stuff here?
6802 // Shouldn't the Activate stuff take care of it?
6803 if(parent.rootWindow == parent && style)
6806 parent.FigureCaption(caption);
6807 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6808 parent.UpdateDecorations();
6812 rootWindow.ConsequentialMouseMove(false);
6819 BitmapResource GetIcon(SkinBitmap iconID)
6821 return guiApp.currentSkin.GetBitmap(iconID);
6824 void SetMouseRange(Box range)
6826 if(range || guiApp.fullScreenMode)
6831 clip.left = range.left + absPosition.x + clientStart.x;
6832 clip.top = range.top + absPosition.y + clientStart.y;
6833 clip.right = range.right + absPosition.x + clientStart.x;
6834 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6838 clip.left = guiApp.desktop.box.left;
6839 clip.top = guiApp.desktop.box.top;
6840 clip.right = guiApp.desktop.box.right;
6841 clip.bottom = guiApp.desktop.box.bottom;
6843 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6846 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6849 void SetMouseRangeToClient(void)
6851 if(guiApp.fullScreenMode || this != guiApp.desktop)
6853 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6854 box.Clip(clientArea);
6858 SetMouseRange(null);
6861 void SetMouseRangeToWindow(void)
6863 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6864 if(this == guiApp.desktop)
6865 SetMouseRangeToClient();
6870 // x, y: Desktop Coordinates
6871 void ShowSysMenu(int x, int y)
6874 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6877 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6878 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6882 menu, $"Move", m, NotifySelect = MenuWindowMove,
6883 disabled = !style.fixed || state == maximized
6887 menu, $"Size", s, NotifySelect = MenuWindowSize,
6888 disabled = !style.sizable || state != normal
6892 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6893 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6897 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6898 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6902 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6903 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6905 MenuDivider { menu };
6908 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6909 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6911 windowMenu.Create();
6916 ActivateEx(true, true, true, true, null, null);
6919 void MakeActive(void)
6921 ActivateEx(true, false, true, false, null, null);
6924 void SoftActivate(void)
6926 if(guiApp.desktop.active)
6931 if(this == rootWindow)
6936 void Deactivate(void)
6938 ActivateEx(false, true, true, true, null, null);
6943 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6946 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6948 bool result = false;
6949 if(activeChild && activeChild.cycle)
6951 Window modalWindow, child = activeChild;
6952 if(!clientOnly /*&& parent.tabCycle*/)
6954 Window next = child;
6957 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6961 if(parent && parent.CycleChildren(backward, false, true, true))
6969 next = next.cycle.prev.data;
6971 next = next.cycle.next.data;
6972 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6977 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6978 parent.tabCycle && parent.CycleChildren(backward, false, false))
6982 if(tabCycleOnly && !tabCycle) return false;
6989 child = child.cycle.prev.data;
6991 child = child.cycle.next.data;
6992 if(child == child.parent.activeChild)
6994 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6997 modalWindow = child.FindModal();
7000 // Scroll the window to include the active control
7001 if(sbh && !child.style.dontScrollHorz)
7003 if(child.scrolledPos.x < 0)
7004 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
7005 else if(child.scrolledPos.x + child.size.w > clientSize.w)
7006 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
7008 if(sbv && !child.style.dontScrollVert)
7010 if(child.scrolledPos.y < 0)
7011 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
7012 else if(child.scrolledPos.y + child.size.h > clientSize.h)
7013 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
7017 child = modalWindow ? modalWindow : child;
7018 child.ActivateEx(true, true, true, true, null, null);
7019 if(child.tabCycle && child.childrenCycle.first)
7020 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7028 ConsequentialMouseMove(false);
7032 void AddResource(Resource resource)
7036 ResPtr ptr { resource = resource };
7040 // Load Graphics here if window is created already
7041 if(/*created && */display)
7043 display.Lock(false);
7044 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7045 ptr.loaded = display.displaySystem.LoadResource(resource);
7049 // Temporary hack to load font right away for listbox in dropbox ...
7050 else if(master && master.display)
7052 master.display.Lock(false);
7053 master.display.displaySystem.LoadResource(resource);
7054 master.display.Unlock();
7060 void RemoveResource(Resource resource)
7065 for(ptr = resources.first; ptr; ptr = ptr.next)
7067 if(ptr.resource == resource)
7073 // Unload Graphics here if window is created already
7074 if(/*created && */display)
7078 display.Lock(false);
7079 display.displaySystem.UnloadResource(resource, ptr.loaded);
7085 resources.Delete(ptr);
7090 void SetCaret(int x, int y, int size)
7097 if(active && !style.interim && isEnabled)
7099 if(visible || !guiApp.caretOwner)
7100 guiApp.caretOwner = size ? this : null;
7102 UpdateCaret(false, false);
7105 guiApp.interfaceDriver.SetCaret(0,0,0);
7106 UpdateCaret(false, true);
7107 guiApp.caretEnabled = false;
7110 else if(style.inactive && active)
7112 guiApp.interfaceDriver.SetCaret(0,0,0);
7113 UpdateCaret(false, true);
7114 guiApp.caretEnabled = false;
7119 void Scroll(int x, int y)
7121 bool opaque = !style.drawBehind || background.a;
7122 if(opaque && display && display.flags.scrolling)
7124 Box box = clientArea;
7125 box.left += clientStart.x;
7126 box.top += clientStart.y;
7127 box.right += clientStart.x;
7128 box.bottom += clientStart.y;
7130 //scrollExtent.Free(null);
7131 scrollExtent.AddBox(box);
7132 scrolledArea.x += x;
7133 scrolledArea.y += y;
7135 //scrollExtent.Free();
7136 //scrollExtent.AddBox(clientArea);
7137 //scrollExtent.Offset(clientStart.x, clientStart.y);
7138 //scrolledArea.x = x;
7139 //scrolledArea.y = y;
7145 rootWindow.dirty = true;
7148 void ReleaseCapture()
7150 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7152 Window oldCaptured = guiApp.windowCaptured;
7153 guiApp.windowCaptured = null;
7154 guiApp.prevWindow = null;
7157 //guiApp.Log("Released Capture\n");
7159 guiApp.interfaceDriver.SetMouseCapture(null);
7161 //oldCaptured.OnMouseCaptureLost();
7164 oldCaptured.ConsequentialMouseMove(false);
7169 private void _SetCaption(const char * format, va_list args)
7176 char caption[MAX_F_STRING];
7177 vsnprintf(caption, sizeof(caption), format, args);
7178 caption[sizeof(caption)-1] = 0;
7180 this.caption = CopyString(caption);
7185 firewatchers caption;
7189 /*deprecated*/ void SetText(const char * format, ...)
7192 va_start(args, format);
7193 _SetCaption(format, args);
7197 void SetCaption(const char * format, ...)
7200 va_start(args, format);
7201 _SetCaption(format, args);
7205 bool Grab(Bitmap bitmap, Box box, bool decorations)
7207 bool result = false;
7208 if(display || this == guiApp.desktop)
7210 Box clip = {MININT, MININT, MAXINT, MAXINT};
7216 clip.Clip(clientArea);
7218 clip.Clip(this.box);
7220 if(rootWindow != this)
7222 clip.left += absPosition.y;
7223 clip.top += absPosition.y;
7224 clip.right += absPosition.x;
7225 clip.bottom += absPosition.y;
7228 clip.left += decorations ? 0 : clientStart.x;
7229 clip.top += decorations ? 0 : clientStart.y;
7230 clip.right += decorations ? 0 : clientStart.x;
7231 clip.bottom += decorations ? 0 : clientStart.y;
7233 if(display && display.flags.flipping)
7235 rootWindow.Update(null);
7236 rootWindow.UpdateDisplay();
7243 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7244 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7248 result = display.Grab(bitmap, clip.left, clip.top,
7249 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7251 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7253 if(!bitmap.Convert(null, pixelFormat888, null))
7260 void GetMousePosition(int * x, int * y)
7262 int mouseX = 0, mouseY = 0;
7263 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7266 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7267 if(this != guiApp.desktop)
7269 mouseX -= absPosition.x + clientStart.x;
7270 mouseY -= absPosition.y + clientStart.y;
7277 DialogResult DoModal()
7279 DialogResult returnCode = 0;
7280 int terminated = terminateX;
7283 while(!destroyed && guiApp.driver != null)
7285 if(terminateX != terminated)
7287 terminated = terminateX;
7288 guiApp.desktop.Destroy(0);
7289 if(guiApp.desktop.created)
7292 //printf("Resetting terminate X to 0\n");
7298 guiApp.UpdateDisplay();
7299 if(!guiApp.ProcessInput(false))
7302 returnCode = this.returnCode;
7315 return !destroyed && guiApp.driver != null && terminateX < 2;
7318 DialogResult DoModalEnd()
7320 DialogResult returnCode = this.returnCode;
7325 // --- Window manipulation ---
7326 /*bool GetDisabled()
7328 bool disabled = this.disabled;
7330 for(window = this; (window = window.master); )
7341 // --- Mouse Manipulation ---
7342 void GetNCMousePosition(int * x, int * y)
7344 GetMousePosition(x, y);
7345 if(x) *x += clientStart.x;
7346 if(y) *y += clientStart.y;
7349 // --- Carets manipulation ---
7350 void GetCaretPosition(Point caretPos)
7352 caretPos = this.caretPos;
7355 int GetCaretSize(void)
7360 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7366 bool CloseConfirmation(bool parentClosing)
7379 if(!OnClose(parentClosing))
7382 // If you want to skip this, simply set modifiedDocument to false in OnClose
7383 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7385 DialogResult dialogRes;
7388 sprintf(message, $"Save changes to %s?", fileName);
7390 sprintf(message, $"Save changes to Untitled %d?", documentID);
7392 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7394 if(dialogRes == yes)
7396 // TOFIX: Precomp error if brackets are taken out
7397 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7399 else if(dialogRes == cancel)
7405 for(slave = slaves.first; slave; slave = slave.next)
7407 Window w = slave.data;
7408 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7416 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7419 for(child = children.first; child; child = child.next)
7420 if(child.isActiveClient && !child.CloseConfirmation(true))
7428 for(child = children.first; child; child = child.next)
7429 if(!child.isActiveClient && !child.CloseConfirmation(true))
7439 // Static methods... move them somewhere else?
7440 void ::RestoreCaret()
7442 if(guiApp.caretOwner)
7443 guiApp.caretOwner.UpdateCaret(false, false);
7446 void ::FreeMouseRange()
7448 guiApp.interfaceDriver.SetMouseRange(null, null);
7452 bool MenuFileClose(MenuItem selection, Modifiers mods)
7454 Window document = activeChild;
7456 document.Destroy(0);
7460 bool MenuFileExit(MenuItem selection, Modifiers mods)
7466 bool MenuFileSave(MenuItem selection, Modifiers mods)
7471 #if !defined(__EMSCRIPTEN__)
7472 fileMonitor.fileName = null;
7476 if(OnSaveFile(fileName))
7478 //if(OnFileModified != Window::OnFileModified)
7481 #if !defined(__EMSCRIPTEN__)
7482 fileMonitor.fileName = fileName;
7489 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7490 DialogResult answer = dialog.Modal();
7492 if(answer != yes) return (bool)answer;
7495 return MenuFileSaveAs(selection, mods);
7498 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7500 DialogResult result = (DialogResult)bool::true;
7501 FileDialog fileDialog = saveDialog;
7506 fileDialog = FileDialog {};
7511 fileDialog.filePath = fileName;
7514 char filePath[MAX_FILENAME];
7515 sprintf(filePath, "Untitled %d", documentID);
7516 fileDialog.filePath = filePath;
7518 #if !defined(__EMSCRIPTEN__)
7519 fileMonitor.fileName = null;
7522 fileDialog.type = save;
7523 fileDialog.text = $"Save As";
7527 fileDialog.master = master.parent ? master : this;
7528 if(fileDialog.Modal() == ok)
7530 const char * filePath = fileDialog.filePath;
7532 if(OnSaveFile(filePath))
7535 property::fileName = filePath;
7536 NotifySaved(master, this, filePath);
7541 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7542 DialogResult answer = dialog.Modal();
7557 #if !defined(__EMSCRIPTEN__)
7558 //if(OnFileModified != Window::OnFileModified && fileName)
7561 fileMonitor.fileName = fileName;
7566 return (bool)result; // Actually returning result from Yes/NoCancel message box
7569 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7571 Window document = activeChild;
7573 for(document = children.first; document; document = next)
7575 next = document.next;
7576 if(document.style.isDocument || document.fileName)
7577 document.MenuFileSave(selection, mods);
7582 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7586 for(document = children.first; document; document = document.next)
7587 //if(document.style.isDocument && document.state == minimized)
7588 if(document.style.isActiveClient && document.state == minimized)
7589 document.SetState(minimized, false, mods);
7593 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7595 Window document = activeChild;
7598 Window firstDocument = null;
7600 OldLink cycle = document.cycle.prev;
7605 if(child.style.isActiveClient && !child.style.hidden)
7609 firstDocument = child;
7610 if(child.state == minimized)
7611 child.SetState(minimized, false, mods);
7614 child.positionID = id++;
7615 child.SetState(normal, false, mods);
7616 child.anchor.left.type = cascade;
7619 child.normalSizeAnchor = *&child.sizeAnchor;
7620 child.normalAnchor = child.anchor;
7622 // Break the anchors for moveable/resizable windows
7623 if(child.style.fixed)
7625 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7627 (*&child.normalAnchor).left = x;
7628 (*&child.normalAnchor).top = y;
7629 (*&child.normalAnchor).right.type = none;
7630 (*&child.normalAnchor).bottom.type = none;
7632 (*&child.normalSizeAnchor).isClientW = false;
7633 (*&child.normalSizeAnchor).isClientH = false;
7634 (*&child.normalSizeAnchor).size.w = w;
7635 (*&child.normalSizeAnchor).size.h = h;
7636 child.anchored = false;
7639 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7641 child.stateAnchor = child.normalAnchor;
7642 child.stateSizeAnchor = child.normalSizeAnchor;
7644 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7645 child.Position(x, y, w, h, true, true, true, true, false, false);
7650 last = children.last;
7651 if(!child.style.stayOnTop)
7652 for(; last && last.style.stayOnTop; last = last.prev);
7653 children.Move(child, last);
7654 childrenOrder.Move(child.order, childrenOrder.last);
7656 if(cycle == document.cycle) break;
7660 firstDocument.Activate();
7665 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7672 // Close all closes all active clients, not all documents
7673 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7675 Window next, document;
7677 for(document = children.first; document; document = next)
7679 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7680 if(document.style.isActiveClient)
7681 if(!document.Destroy(0) && !document.style.hidden)
7687 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7689 if(style.hasMaximize && state != maximized)
7690 SetState(maximized, 0, 0);
7694 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7696 if(style.hasMinimize && state != minimized)
7698 SetState(minimized, 0, 0);
7699 parent.CycleChildren(false, true, false, true);
7704 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7706 MenuMoveOrSize(false, selection ? true : false);
7710 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7712 CycleChildren(false, true, false, true);
7716 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7718 CycleChildren(true, true, false, true);
7722 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7724 MenuMoveOrSize(true, true);
7728 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7731 SetState(normal, 0, 0);
7735 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7738 int64 id = selection.id;
7739 OldLink cycle = activeClient.cycle;
7741 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7744 Window sibling = cycle.data;
7745 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7753 document = cycle.data;
7754 document.Activate();
7756 //if(activeChild.state == maximized)
7757 // document.SetState(maximized, false, mods);
7758 //else if(document.state == minimized)
7759 // document.SetState(normal, false, mods);
7763 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7765 stayOnTop = !style.stayOnTop;
7769 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7771 Window document = activeChild;
7774 Window firstDocument = null;
7775 OldLink cycle = document.cycle;
7779 Window child = cycle.data;
7780 if(child.style.isActiveClient && !child.style.hidden)
7782 if(!firstDocument) firstDocument = child;
7783 if(child.state == minimized)
7784 child.SetState(minimized, false, mods);
7787 child.positionID = id++;
7788 child.SetState(normal, false, mods);
7789 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7791 child.anchor.left.type = hTiled;
7794 child.normalSizeAnchor = *&child.sizeAnchor;
7795 child.normalAnchor = child.anchor;
7797 // Break the anchors for moveable/resizable windows
7798 if(child.style.fixed)
7800 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7802 (*&child.normalAnchor).left = x;
7803 (*&child.normalAnchor).top = y;
7804 (*&child.normalAnchor).right.type = none;
7805 (*&child.normalAnchor).bottom.type = none;
7806 (*&child.normalSizeAnchor).isClientW = false;
7807 (*&child.normalSizeAnchor).isClientH = false;
7808 (*&child.normalSizeAnchor).size.w = w;
7809 (*&child.normalSizeAnchor).size.h = h;
7810 child.anchored = false;
7813 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7815 child.stateAnchor = child.normalAnchor;
7816 child.stateSizeAnchor = child.normalSizeAnchor;
7818 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7819 child.Position(x,y, w, h, true, true, true, true, false, true);
7824 if((cycle = cycle.next) == document.cycle) break;
7827 firstDocument.Activate();
7832 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7834 Window document = activeChild;
7837 Window firstDocument = null;
7839 OldLink cycle = document.cycle;
7844 //if(child.style.isDocument)
7845 if(child.style.isActiveClient && !child.style.hidden)
7847 if(!firstDocument) firstDocument = child;
7848 if(child.state == minimized)
7849 child.SetState(minimized, false, mods);
7852 child.positionID = id++;
7853 child.SetState(normal, false, mods);
7854 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7856 child.anchor.left.type = vTiled;
7859 child.normalSizeAnchor = *&child.sizeAnchor;
7860 child.normalAnchor = child.anchor;
7862 // Break the anchors for moveable/resizable windows
7863 if(child.style.fixed)
7865 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7867 (*&child.normalAnchor).left = x;
7868 (*&child.normalAnchor).top = y;
7869 (*&child.normalAnchor).right.type = none;
7870 (*&child.normalAnchor).bottom.type = none;
7871 (*&child.normalSizeAnchor).isClientW = false;
7872 (*&child.normalSizeAnchor).isClientH = false;
7873 (*&child.normalSizeAnchor).size.w = w;
7874 (*&child.normalSizeAnchor).size.h = h;
7875 child.anchored = false;
7878 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7880 child.stateAnchor = child.normalAnchor;
7881 child.stateSizeAnchor = child.normalSizeAnchor;
7883 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7884 child.Position(x,y, w, h, true, true, true, true, false, true);
7889 if((cycle = cycle.next) == document.cycle) break;
7892 firstDocument.Activate();
7897 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7899 WindowList dialog { master = this };
7900 Window document = (Window)(intptr)dialog.Modal();
7903 if(activeChild.state == maximized)
7904 document.SetState(maximized, false, mods);
7905 else if(document.state == minimized)
7906 document.SetState(normal, false, mods);
7907 document.Activate();
7913 virtual bool OnCreate(void);
7914 virtual void OnDestroy(void);
7915 virtual void OnDestroyed(void);
7916 virtual bool OnClose(bool parentClosing);
7917 virtual bool OnStateChange(WindowState state, Modifiers mods);
7918 virtual bool OnPostCreate(void);
7919 virtual bool OnMoving(int *x, int *y, int w, int h);
7920 virtual bool OnResizing(int *width, int *height);
7921 virtual void OnResize(int width, int height);
7922 virtual void OnPosition(int x, int y, int width, int height);
7923 virtual bool OnLoadGraphics(void);
7924 virtual void OnApplyGraphics(void);
7925 virtual void OnUnloadGraphics(void);
7926 virtual void OnRedraw(Surface surface);
7927 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7928 virtual void OnActivateClient(Window client, Window previous);
7929 virtual bool OnKeyDown(Key key, unichar ch);
7930 virtual bool OnKeyUp(Key key, unichar ch);
7931 virtual bool OnKeyHit(Key key, unichar ch);
7932 virtual bool OnSysKeyDown(Key key, unichar ch);
7933 virtual bool OnSysKeyUp(Key key, unichar ch);
7934 virtual bool OnSysKeyHit(Key key, unichar ch);
7935 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7936 virtual bool OnMouseLeave(Modifiers mods);
7937 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7938 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7939 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7940 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7941 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7942 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7943 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7944 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7945 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7946 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7947 virtual void OnMouseCaptureLost(void);
7948 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7949 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7950 virtual void OnDrawOverChildren(Surface surface);
7951 virtual bool OnFileModified(FileChange fileChange, const char * param);
7952 virtual bool OnSaveFile(const char * fileName);
7954 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7955 // Note: A 'client' would refer to isActiveClient, rather than
7956 // being confined to the 'client area' (nonClient == false)
7957 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7958 virtual void OnChildVisibilityToggled(Window child, bool visible);
7959 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7961 // Skins Virtual Functions
7962 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7963 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7964 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7969 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7970 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7971 virtual bool IsMouseMoving(int x, int y, int w, int h)
7975 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7979 virtual void UpdateNonClient();
7980 virtual void SetBox(Box box); // This is used in the MySkin skin
7981 virtual bool IsInside(int x, int y)
7983 return box.IsPointInside({x, y});
7985 virtual bool IsOpaque()
7987 return (!style.drawBehind || background.a == 255);
7991 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7992 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7993 virtual void Window::NotifySaved(Window window, const char * filePath);
7998 property Window parent
8000 property_category $"Layout"
8003 if(value || guiApp.desktop)
8006 Window oldParent = parent;
8007 Anchor anchor = this.anchor;
8009 if(value && value.IsDescendantOf(this)) return;
8010 if(value && value == this)
8012 if(!value) value = guiApp.desktop;
8014 if(value == oldParent) return;
8016 if(!master || (master == this.parent && master == guiApp.desktop))
8017 property::master = value;
8021 parent.children.Remove(this);
8025 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8026 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
8027 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
8028 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8032 last = value.children.last;
8034 if(style.isDocument)
8037 parent.numDocuments--;
8038 documentID = value.GetDocumentID();
8041 if(style.isActiveClient && !style.hidden)
8043 if(parent && parent != guiApp.desktop && !(style.hidden))
8045 if(state == minimized) parent.numIcons--;
8046 parent.numPositions--;
8050 if(!style.stayOnTop)
8051 for(; last && last.style.stayOnTop; last = last.prev);
8053 value.children.Insert(last, this);
8055 // *** NEW HERE: ***
8057 parent.childrenCycle.Delete(cycle);
8059 parent.childrenOrder.Delete(order);
8062 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8063 // Should something else be done?
8064 if(parent && parent.activeChild == this)
8065 parent.activeChild = null;
8066 if(parent && parent.activeClient == this)
8067 parent.activeClient = null;
8073 int x = position.x, y = position.y, w = size.w, h = size.h;
8077 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8078 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8080 vpw = value.clientSize.w;
8081 vph = value.clientSize.h;
8087 else if(style.fixed)
8089 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8090 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8093 anchor = this.anchor;
8095 if(anchor.left.type == offset) anchor.left.distance = x;
8096 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8097 if(anchor.top.type == offset) anchor.top.distance = y;
8098 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8099 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8100 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8101 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8102 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8103 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8104 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8106 if(!anchor.left.type && !anchor.right.type)
8108 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8109 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8111 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8112 if(!anchor.top.type && !anchor.bottom.type)
8114 anchor.vert.distance = (y + h / 2) - (vph / 2);
8115 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8117 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8120 parent.OnChildAddedOrRemoved(this, false);
8126 parent.childrenCycle.Insert(
8127 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8128 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8130 cycle = OldLink { data = this });
8131 parent.childrenOrder.Insert(
8132 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8133 order = OldLink { data = this });
8136 if(!style.hidden && style.isActiveClient)
8138 positionID = parent.GetPositionID(this);
8139 parent.numPositions++;
8140 if(state == minimized) parent.numIcons--;
8143 // *** FONT INHERITANCE ***
8144 if(!setFont && oldParent)
8145 stopwatching(oldParent, font);
8149 RemoveResource(systemFont);
8152 // TESTING WITH WATCHERS:
8153 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8154 // usedFont = setFont ? setFont : (systemFont);
8158 if(guiApp.currentSkin)
8160 systemFont = guiApp.currentSkin.SystemFont();
8163 usedFont = systemFont;
8164 AddResource(systemFont);
8172 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8181 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8183 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8184 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8187 UnloadGraphics(false);
8190 LoadGraphics(false, false);
8193 if(value.rootWindow != rootWindow)
8194 DisplayModeChanged();
8198 scrolledPos.x = MININT; // Prevent parent update
8200 bool anchored = this.anchored;
8201 property::anchor = anchor;
8202 this.anchored = anchored;
8207 if(guiApp.currentSkin)
8208 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8210 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8211 Position(x, y, w, h, true, true, true, true, false, true);
8216 // else parent = value;
8218 oldParent.OnChildAddedOrRemoved(this, true);
8221 get { return parent; }
8224 property Window master
8226 property_category $"Behavior"
8229 //if(this == value) return;
8230 if(value && value.IsSlaveOf(this)) return;
8236 OldLink slaveHolder;
8237 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8238 if(slaveHolder.data == this)
8240 master.slaves.Delete(slaveHolder);
8247 value.slaves.Add(OldLink { data = this });
8252 master.hotKeys.Remove(hotKey);
8253 value.hotKeys.Add(hotKey);
8256 if(master && master.defaultControl == this)
8257 master.defaultControl = null;
8259 if(style.isDefault && !value.defaultControl)
8260 value.defaultControl = this;
8265 get { return master ? master : parent; }
8268 property const char * caption
8270 property_category $"Appearance"
8277 caption = new char[strlen(value)+1];
8279 strcpy(caption, value);
8284 get { return caption; }
8289 property_category $"Behavior"
8298 master.hotKeys.Add(hotKey = HotKeySlot { });
8302 hotKey.window = this;
8307 master.hotKeys.Delete(hotKey);
8312 get { return hotKey ? hotKey.key : 0; }
8315 property Color background
8317 property_category $"Appearance"
8320 background.color = value;
8325 if(this == rootWindow)
8326 guiApp.interfaceDriver.SetRootWindowColor(this);
8329 get { return background.color; }
8332 property Percentage opacity
8334 property_category $"Appearance"
8337 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8338 drawBehind = (background.a == 255) ? false : true;
8340 get { return background.a / 255.0f; }
8343 property Color foreground
8345 property_category $"Appearance"
8353 get { return foreground; }
8356 property BorderStyle borderStyle
8358 property_category $"Appearance"
8361 if(!((BorderBits)value).fixed)
8363 style.hasClose = false;
8364 style.hasMaximize = false;
8365 style.hasMinimize = false;
8366 nativeDecorations = false;
8368 style.borderBits = value;
8372 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8374 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8375 Position(x, y, w, h, true, true, true, true, false, true);
8376 CreateSystemChildren();
8379 get { return (BorderStyle)style.borderBits; }
8382 property Size minClientSize
8384 property_category $"Layout"
8385 set { minSize = value; }
8386 get { value = minSize; }
8389 property Size maxClientSize
8391 property_category $"Layout"
8392 set { maxSize = value; }
8393 get { value = maxSize; }
8396 property bool hasMaximize
8398 property_category $"Window Style"
8401 style.hasMaximize = value;
8402 if(value) { style.fixed = true; style.contour = true; }
8406 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8408 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8409 Position(x, y, w, h, true, true, true, true, false, true);
8411 CreateSystemChildren();
8414 get { return style.hasMaximize; }
8417 property bool hasMinimize
8419 property_category $"Window Style"
8422 style.hasMinimize = value;
8423 if(value) { style.fixed = true; style.contour = true; }
8427 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8429 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8430 Position(x, y, w, h, true, true, true, true, false, true);
8432 CreateSystemChildren();
8435 get { return style.hasMinimize; }
8438 property bool hasClose
8440 property_category $"Window Style"
8443 style.hasClose = value;
8444 if(value) { style.fixed = true; style.contour = true; }
8448 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8449 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8450 Position(x, y, w, h, true, true, true, true, false, true);
8451 CreateSystemChildren();
8454 get { return style.hasClose; }
8457 property bool nonClient
8459 property_category $"Layout"
8462 style.nonClient = value;
8464 style.stayOnTop = true;
8466 get { return style.nonClient; }
8469 property bool inactive
8471 property_category $"Behavior"
8476 // *** NEW HERE: ***
8480 parent.childrenCycle.Delete(cycle);
8482 parent.childrenOrder.Delete(order);
8489 active = false; // true;
8490 if(parent.activeChild == this)
8491 parent.activeChild = null;
8492 if(parent.activeClient == this)
8493 parent.activeClient = null;
8502 parent.childrenCycle.Insert(
8503 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8504 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8506 cycle = OldLink { data = this });
8508 parent.childrenOrder.Insert(
8509 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8510 order = OldLink { data = this });
8513 style.inactive = value;
8515 get { return style.inactive; }
8518 property bool clickThrough
8520 property_category $"Behavior"
8521 set { style.clickThrough = value; }
8522 get { return style.clickThrough; }
8525 property bool isRemote
8527 property_category $"Behavior"
8528 set { style.isRemote = value; }
8529 get { return style.isRemote; }
8532 property bool noCycle
8534 property_category $"Behavior"
8535 set { style.noCycle = value; }
8536 get { return style.noCycle; }
8539 property bool isModal
8541 property_category $"Behavior"
8542 set { style.modal = value; }
8543 get { return style.modal; }
8546 property bool interim
8548 property_category $"Behavior"
8549 set { style.interim = value; }
8550 get { return style.interim; }
8553 property bool tabCycle
8555 property_category $"Behavior"
8556 set { style.tabCycle = value; }
8557 get { return style.tabCycle; }
8560 property bool isDefault
8562 property_category $"Behavior"
8570 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8571 if(sibling != this && sibling.style.isDefault)
8572 sibling.style.isDefault = false;*/
8573 if(master.defaultControl)
8574 master.defaultControl.style.isDefault = false;
8575 master.defaultControl = this;
8577 else if(master.defaultControl == this)
8578 master.defaultControl = null;
8582 style.isDefault = value;
8584 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8586 get { return style.isDefault; }
8589 property bool drawBehind
8591 property_category $"Window Style"
8592 set { style.drawBehind = value; }
8593 get { return style.drawBehind; }
8596 property bool hasMenuBar
8598 property_category $"Window Style"
8608 if(created && !menuBar)
8615 anchor = Anchor { top = 23, left = 1, right = 1 },
8617 inactive = true, nonClient = true
8622 else if(created && menuBar)
8627 style.hasMenuBar = value;
8629 get { return style.hasMenuBar; }
8632 property bool hasStatusBar
8634 property_category $"Window Style"
8641 statusBar = StatusBar { this };
8649 style.hasStatusBar = value;
8651 get { return style.hasStatusBar; }
8653 property bool stayOnTop
8655 property_category $"Window Style"
8660 if(created && !style.stayOnTop)
8662 if(rootWindow == this)
8663 guiApp.interfaceDriver.OrderRootWindow(this, true);
8664 else if(parent.children.last != this)
8666 parent.children.Move(this, parent.children.last);
8670 style.stayOnTop = true;
8674 if(created && style.stayOnTop)
8676 if(rootWindow == this)
8677 guiApp.interfaceDriver.OrderRootWindow(this, false);
8684 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8685 order && ((Window)order.data).style.stayOnTop;
8686 order = (order == parent.childrenOrder.first) ? null : order.prev);
8687 last = order ? order.data : null;
8691 for(last = parent.children.last;
8692 last && last.style.stayOnTop;
8696 parent.children.Move(this, last);
8700 style.stayOnTop = false;
8703 get { return style.stayOnTop; }
8708 property_category $"Window Style"
8718 if(menuBar && !value)
8725 if(!menuBar && style.hasMenuBar && value)
8729 this, menu = value, isMenuBar = true,
8730 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8731 inactive = true, nonClient = true
8735 UpdateActiveDocument(null);
8738 get { return menu; }
8741 property FontResource font
8743 property_category $"Appearance"
8745 isset { return setFont ? true : false; }
8750 if(value && !setFont) { stopwatching(parent, font); }
8751 else if(!value && setFont)
8757 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8766 RemoveResource(setFont);
8771 RemoveResource(systemFont);
8778 AddResource(setFont);
8781 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8784 systemFont = guiApp.currentSkin.SystemFont();
8786 usedFont = systemFont;
8787 AddResource(systemFont);
8795 get { return usedFont; }
8798 property SizeAnchor sizeAnchor
8800 property_category $"Layout"
8803 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8804 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8805 sizeAnchor.isClientW != sizeAnchor.isClientH;
8812 normalSizeAnchor = sizeAnchor;
8814 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8816 stateAnchor = normalAnchor;
8817 stateSizeAnchor = normalSizeAnchor;
8819 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8820 Position(x,y, w, h, true, true, true, true, false, true);
8827 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8828 sizeAnchor.isClientW,
8829 sizeAnchor.isClientH
8836 property_category $"Layout"
8839 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8840 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8841 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8847 sizeAnchor.isClientW = false;
8848 sizeAnchor.isClientH = false;
8849 sizeAnchor.size = value;
8851 normalSizeAnchor = sizeAnchor;
8853 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8855 stateAnchor = normalAnchor;
8856 stateSizeAnchor = normalSizeAnchor;
8858 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8859 Position(x, y, w, h, true, true, true, true, false, true);
8860 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8863 get { value = size; }
8866 property Size clientSize
8868 property_category $"Layout"
8871 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8872 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8873 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8878 sizeAnchor.isClientW = true;
8879 sizeAnchor.isClientH = true;
8880 sizeAnchor.size = value;
8882 normalSizeAnchor = sizeAnchor;
8884 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8886 stateAnchor = normalAnchor;
8887 stateSizeAnchor = normalSizeAnchor;
8889 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8890 Position(x,y, w, h, true, true, true, true, false, true);
8891 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8894 get { value = this ? clientSize : { 0, 0 }; }
8897 property Size initSize { get { value = sizeAnchor.size; } };
8899 property Anchor anchor
8901 property_category $"Layout"
8902 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8908 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8910 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8911 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8913 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8915 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8916 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8920 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8922 anchor.left.distance = 0;
8923 anchor.horz.type = 0;
8925 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8927 anchor.top.distance = 0;
8928 anchor.vert.type = 0;
8937 normalAnchor = anchor;
8939 // Break the anchors for moveable/resizable windows
8940 /*if(style.fixed ) //&& value.left.type == cascade)
8942 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8944 this.anchor = normalAnchor = Anchor { left = x, top = y };
8945 normalSizeAnchor = SizeAnchor { { w, h } };
8948 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8950 stateAnchor = normalAnchor;
8951 stateSizeAnchor = normalSizeAnchor;
8953 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8954 Position(x, y, w, h, true, true, true, true, false, true);
8963 get { value = this ? anchor : Anchor { }; }
8966 property Point position
8968 property_category $"Layout"
8971 if(value == null) return;
8973 anchor.left = value.x;
8974 anchor.top = value.y;
8975 anchor.right.type = none;
8976 anchor.bottom.type = none;
8981 normalAnchor = anchor;
8983 // Break the anchors for moveable/resizable windows
8987 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8989 normalAnchor.left = x;
8990 normalAnchor.top = y;
8991 normalAnchor.right.type = none;
8992 normalAnchor.bottom.type = none;
8993 normalSizeAnchor.size.width = w;
8994 normalSizeAnchor.size.height = h;
8998 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
9000 stateAnchor = normalAnchor;
9001 stateSizeAnchor = normalSizeAnchor;
9003 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
9004 Position(x,y, w, h, true, true, true, true, false, true);
9008 get { value = position; }
9011 property bool disabled
9013 property_category $"Behavior"
9016 if(this && disabled != value)
9023 get { return (bool)disabled; }
9026 property bool isEnabled
9031 for(parent = this; parent; parent = parent.parent)
9038 property WindowState state
9040 property_category $"Behavior"
9041 set { SetState(value, false, 0); }
9042 get { return this ? state : 0; }
9045 property bool visible
9047 property_category $"Behavior"
9050 if(this && !value && !style.hidden && parent)
9052 bool wasActiveChild = parent.activeChild == this;
9053 Window client = null;
9055 style.hidden = true;
9056 if(style.isActiveClient)
9058 parent.numPositions--;
9059 if(state == minimized) parent.numIcons--;
9064 OldLink prevOrder = null;
9066 if(rootWindow == this)
9067 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9070 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9073 box.left -= parent.clientStart.x;
9074 box.top -= parent.clientStart.y;
9075 box.right -= parent.clientStart.x;
9076 box.bottom -= parent.clientStart.y;
9080 if(_isModal && master && master.modalSlave == this)
9081 master.modalSlave = null;
9085 OldLink tmpPrev = order.prev;
9086 client = tmpPrev ? tmpPrev.data : null;
9087 if(client && !client.style.hidden && !client.destroyed && client.created)
9088 prevOrder = tmpPrev;
9091 client = tmpPrev ? tmpPrev.data : null;
9092 if(client == this) { client = null; break; }
9093 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9095 tmpPrev = client.order.prev;
9100 prevOrder = tmpPrev;
9105 // If this window can be an active client, make sure the next window we activate can also be one
9106 if(!style.nonClient && style.isActiveClient)
9108 tmpPrev = prevOrder;
9111 client = tmpPrev ? tmpPrev.data : null;
9112 if(client == this) { client = null; break; }
9113 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9115 tmpPrev = client.order.prev;
9120 prevOrder = tmpPrev;
9124 if(client && client.style.hidden) client = null;
9128 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9130 if(order && prevOrder && prevOrder.data != this)
9131 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9133 ActivateEx(false, false, false, true, null, null);
9135 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9136 if(parent.activeClient == this)
9138 parent.activeClient = null;
9139 parent.UpdateActiveDocument(null);
9142 else if(parent.activeClient == this)
9144 parent.activeClient = client;
9145 parent.UpdateActiveDocument(this);
9148 // *** Not doing this anymore ***
9151 parent.childrenCycle.Delete(cycle);
9153 parent.childrenOrder.Delete(order);
9158 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9163 else if(this && value && style.hidden)
9165 style.hidden = false;
9168 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9169 if(rootWindow == this)
9170 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9172 if(_isModal && master)
9173 master.modalSlave = this;
9175 if(style.isActiveClient)
9177 positionID = parent.GetPositionID(this);
9178 parent.numPositions++;
9179 if(state == minimized) parent.numIcons++;
9182 // *** NOT DOING THIS ANYMORE ***
9184 if(!(style.inactive))
9186 if(!(style.noCycle))
9188 cycle = parent.childrenCycle.AddAfter(
9189 (parent.activeChild && parent.activeChild.cycle) ?
9190 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9193 order = parent.childrenOrder.AddAfter(
9194 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9201 if(true || !parent.activeChild)
9202 ActivateEx(true, false, true, true, null, null);
9204 if(creationActivation == activate && guiApp.desktop.active)
9205 ActivateEx(true, false, true, true, null, null);
9206 else if((creationActivation == activate || creationActivation == flash) && !object)
9209 if(this == rootWindow)
9213 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9217 ConsequentialMouseMove(false);
9223 style.hidden = !value;
9226 get { return (style.hidden || !setVisible) ? false : true; }
9229 property bool isDocument
9231 property_category $"Document"
9232 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9233 get { return style.isDocument; }
9236 property bool mergeMenus
9238 property_category $"Window Style"
9239 set { mergeMenus = value; }
9240 get { return (bool)mergeMenus; }
9243 property bool hasHorzScroll
9245 property_category $"Window Style"
9250 if(!style.hasHorzScroll && created)
9252 CreateSystemChildren();
9253 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9256 else if(style.hasHorzScroll)
9260 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9262 style.hasHorzScroll = value;
9265 get { return style.hasHorzScroll; }
9268 property bool hasVertScroll
9270 property_category $"Window Style"
9275 if(!style.hasVertScroll && created)
9277 style.hasVertScroll = true;
9278 CreateSystemChildren();
9279 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9282 else if(style.hasVertScroll)
9286 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9288 style.hasVertScroll = value;
9290 get { return style.hasVertScroll; }
9293 property bool dontHideScroll
9295 property_category $"Behavior"
9298 scrollFlags.dontHide = value;
9301 //UpdateScrollBars(true, true);
9302 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9306 // UpdateScrollBars(true, true);
9307 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9310 get { return scrollFlags.dontHide; }
9313 property bool dontScrollVert
9315 property_category $"Behavior"
9316 set { style.dontScrollVert = value; }
9317 get { return style.dontScrollVert; }
9319 property bool dontScrollHorz
9321 property_category $"Behavior"
9322 set { style.dontScrollHorz = value; }
9323 get { return style.dontScrollHorz; }
9326 property bool snapVertScroll
9328 property_category $"Behavior"
9331 scrollFlags.snapY = value;
9332 if(sbv) sbv.snap = value;
9334 get { return scrollFlags.snapY; }
9336 property bool snapHorzScroll
9338 property_category $"Behavior"
9341 scrollFlags.snapX = value;
9342 if(sbh) sbh.snap = value;
9344 get { return scrollFlags.snapX; }
9347 property Point scroll
9349 property_category $"Behavior"
9350 set { if(this) SetScrollPosition(value.x, value.y); }
9351 get { value = scroll; }
9354 property bool modifyVirtualArea
9356 property_category $"Behavior"
9357 set { modifyVirtArea = value; }
9358 get { return (bool)modifyVirtArea; }
9361 property bool dontAutoScrollArea
9363 property_category $"Behavior"
9364 // Activating a child control out of view will automatically scroll to make it in view
9365 set { noAutoScrollArea = value; }
9366 get { return (bool)noAutoScrollArea; }
9369 property const char * fileName
9371 property_category $"Document"
9376 if(menu && ((!fileName && value) || (fileName && !value)))
9378 MenuItem item = menu.FindItem(MenuFileSave, 0);
9379 if(item) item.disabled = !modifiedDocument && value;
9384 if(value && value[0])
9385 fileName = CopyString(value);
9387 if(parent && this == parent.activeClient)
9388 parent.UpdateActiveDocument(null);
9392 // if(style.isDocument)
9393 #if !defined(__EMSCRIPTEN__)
9395 fileMonitor.fileName = value;
9398 get { return fileName; }
9403 property_category $"Data"
9408 property bool modifiedDocument
9410 property_category $"Document"
9413 if(style.isDocument || fileName)
9417 MenuItem item = menu.FindItem(MenuFileSave, 0);
9418 if(item) item.disabled = !value && fileName;
9422 if(modifiedDocument != value)
9424 modifiedDocument = value;
9425 if(style.isDocument || fileName)
9429 get { return (bool)modifiedDocument; }
9432 property bool showInTaskBar
9434 property_category $"Window Style"
9435 set { style.showInTaskBar = value; }
9436 get { return style.showInTaskBar; }
9438 property FileDialog saveDialog { set { saveDialog = value; } };
9439 property bool isActiveClient
9441 property_category $"Behavior"
9444 if(parent && style.isActiveClient != value && !style.hidden)
9448 if(state == minimized) parent.numIcons++;
9449 parent.numPositions++;
9453 if(state == minimized) parent.numIcons--;
9454 parent.numPositions--;
9457 style.isActiveClient = value;
9459 get { return style.isActiveClient; }
9462 property Cursor cursor
9464 property_category $"Appearance"
9468 SelectMouseCursor();
9470 get { return cursor; }
9473 //#if !defined(ECERE_VANILLA)
9474 property const char * name
9476 property_category $"Design"
9479 return (this && object) ? object.name : null;
9484 activeDesigner.RenameObject(object, value);
9488 property const char * displayDriver
9490 property_category $"Behavior"
9493 dispDriver = GetDisplayDriver(value);
9494 //DisplayModeChanged();
9498 return dispDriver ? dispDriver.name : null;
9502 // RUNTIME PROPERTIES
9503 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9504 property Size scrollArea
9506 property_category $"Behavior"
9510 SetScrollArea(value.w, value.h, false);
9512 SetScrollArea(0,0, true);
9514 get { value = scrollArea; }
9517 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9522 property_category $"Layout"
9523 set { if(this) is3D = value; }
9524 get { return (bool)is3D; }
9527 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9529 // Will be merged with font later
9530 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9531 property Point clientStart { get { value = clientStart; } };
9532 property Point absPosition { get { value = absPosition; } };
9533 property Anchor normalAnchor { get { value = normalAnchor; } };
9534 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9535 property bool active { get { return (bool)active; } };
9536 property bool created { get { return (bool)created; } };
9537 property bool destroyed { get { return (bool)destroyed; } };
9538 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9539 property Window firstChild { get { return children.first; } };
9540 property Window lastChild { get { return children.last; } };
9541 property Window activeClient { get { return activeClient; } };
9542 property Window activeChild { get { return activeChild; } };
9543 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9544 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9545 property ScrollBar horzScroll { get { return sbh; } };
9546 property ScrollBar vertScroll { get { return sbv; } };
9547 property StatusBar statusBar { get { return statusBar; } };
9548 property Window rootWindow { get { return rootWindow; } };
9549 property bool closing { get { return (bool)closing; } set { closing = value; } };
9550 property int documentID { get { return documentID; } };
9551 property Window previous { get { return prev; } }
9552 property Window next { get { return next; } }
9553 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9554 property PopupMenu menuBar { get { return menuBar; } }
9555 property ScrollBar sbv { get { return sbv; } }
9556 property ScrollBar sbh { get { return sbh; } }
9557 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9558 property void * systemHandle { get { return windowHandle; } }
9559 property Button minimizeButton { get { return sysButtons[0]; } };
9560 property Button maximizeButton { get { return sysButtons[1]; } };
9561 property Button closeButton { get { return sysButtons[2]; } };
9562 property BitmapResource icon
9564 get { return icon; }
9568 if(icon) incref icon;
9570 guiApp.interfaceDriver.SetIcon(this, value);
9573 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9574 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9575 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9576 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9577 property bool nativeDecorations
9579 get { return (bool)nativeDecorations; }
9580 set { nativeDecorations = value; }
9581 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9584 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9585 bool result = false;
9586 if(nativeDecorations)
9588 if(rootWindow == this)
9592 if(formDesigner && activeDesigner)
9594 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9595 Window form = cd ? cd.form : null;
9596 if(form && parent == form.parent)
9601 return result != style.fixed;
9605 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9607 property const char * text
9609 property_category $"Deprecated"
9611 set { property::caption = value; }
9612 get { return property::caption; }
9618 WindowBits style; // Window Style
9619 char * caption; // Name / Caption
9620 Window parent; // Parent window
9621 OldList children; // List of children in Z order
9622 Window activeChild; // Child window having focus
9623 Window activeClient;
9624 Window previousActive; // Child active prior to activating the default child
9625 Window master; // Window owning and receiving notifications concerning this window
9626 OldList slaves; // List of windows belonging to this window
9627 Display display; // Display this window is drawn into
9629 Point position; // Position in parent window client area
9630 Point absPosition; // Absolute position
9631 Point clientStart; // Client area position from (0,0) in this window
9633 Size clientSize; // Client area size
9634 Size scrollArea; // Virtual Scroll area size
9635 Size reqScrollArea; // Requested virtual area size
9636 Point scroll; // Virtual area scrolling position
9637 ScrollBar sbh, sbv; // Scrollbar window handles
9638 Cursor cursor; // Mouse cursor used for this window
9641 StatusBar statusBar;
9642 Button sysButtons[3];
9644 Box clientArea; // Client Area box clipped to parent
9646 HotKeySlot hotKey; // HotKey for this window
9650 ScrollFlags scrollFlags;// Window Scrollbar Flags
9651 int64 id; // Control ID
9653 ColorAlpha background; // Background color used to draw the window area
9655 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9656 OldList childrenCycle; // Cycling order
9657 OldLink cycle; // Element of parent's cycling order
9658 OldList childrenOrder; // Circular Z-Order
9659 OldLink order; // Element of parent's circular Z-Order
9660 Window modalSlave; // Slave window blocking this window's interaction
9662 Window rootWindow; // Topmost system managed window
9663 void * windowHandle; // System window handle
9665 DialogResult returnCode;// Return code for modal windows
9667 Point sbStep; // Scrollbar line scrolling steps
9670 SizeAnchor stateSizeAnchor;
9672 Anchor normalAnchor;
9673 SizeAnchor normalSizeAnchor;
9675 Size skinMinSize; // Minimal window size based on style
9676 Point scrolledPos; // Scrolled position
9677 Box box; // Window box clipped to parent
9678 Box * against; // What to clip the box to
9680 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9681 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9682 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9683 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9684 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9685 Point scrolledArea; // Distance to scroll area by
9686 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9688 OldList hotKeys; // List of the hotkeys of all children
9689 Window defaultControl; // Default child control
9693 ColorAlpha * palette; // Color palette used for this window
9695 int caretSize; // Size of caret, non zero if a caret is present
9696 Point caretPos; // Caret position
9698 void * systemParent; // Parent System Window for embedded windows
9704 #if !defined(__EMSCRIPTEN__)
9707 WindowState lastState;
9709 #if !defined(__EMSCRIPTEN__)
9710 FileMonitor fileMonitor;
9713 FontResource setFont, systemFont;
9714 FontResource usedFont;
9715 FontResource captionFont;
9717 FileDialog saveDialog;
9719 SizeAnchor sizeAnchor;
9721 // FormDesigner data
9724 Extent * tempExtents; //[4];
9725 BitmapResource icon;
9727 CreationActivationOption creationActivation;
9730 bool active:1; // true if window and ancestors are active
9731 bool acquiredInput:1; // true if the window is processing state based input
9732 bool modifiedDocument:1;
9733 bool disabled:1; // true if window cannot interact
9734 bool isForegroundWindow:1;// true while a root window is being activated
9735 bool visible:1; // Visibility flag
9736 bool destroyed:1; // true if window is being destroyed
9737 bool anchored:1; // true if this window is repositioned when the parent resizes
9738 bool dirty:1; // Flag set to true if any descendant must be redrawn
9744 bool modifyVirtArea:1;
9745 bool noAutoScrollArea:1;
9748 bool setVisible:1; // FOR FORM DESIGNER
9754 bool useSharedMemory:1;
9757 bool nativeDecorations:1;
9758 bool manageDisplay:1;
9759 bool formDesigner:1; // True if we this is running in the form editor
9760 bool requireRemaximize:1;
9763 // Checks used internally for them not to take effect in FormDesigner
9764 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9765 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9767 WindowController controller;
9768 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9771 public class CommonControl : Window
9773 // creationActivation = doNothing;
9776 public property const String toolTip
9778 property_category $"Appearance"
9781 if(created) CommonControl::OnDestroy();
9783 toolTip = value ? ToolTip { tip = value; } : null;
9785 if(created) CommonControl::OnCreate();
9787 get { return toolTip ? toolTip.tip : null; }
9793 // (Very) Ugly work around for the fact that the parent watcher
9794 // won't fire when it's already been disconnected...
9795 eInstance_FireSelfWatchers(toolTip,
9796 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9802 toolTip.parent = this;
9811 public class Percentage : float
9813 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9817 sprintf(string, "%.2f", this);
9818 c = strlen(string)-1;
9821 if(string[c] != '0')
9822 last = Max(last, c);
9823 if(string[c] == '.')
9836 public void ApplySkin(Class c, const char * name, void ** vTbl)
9838 char className[1024];
9843 subclass(Window) wc = (subclass(Window))c;
9844 subclass(Window) base = (subclass(Window))c.base;
9846 sprintf(className, "%sSkin_%s", name, c.name);
9847 wc.pureVTbl = c._vTbl;
9848 c._vTbl = new void *[c.vTblSize];
9849 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9850 sc = eSystem_FindClass(c.module.application, className);
9854 for(m = 0; m < c.base.vTblSize; m++)
9856 if(c._vTbl[m] == base.pureVTbl[m])
9857 c._vTbl[m] = vTbl[m];
9862 for(m = 0; m < c.vTblSize; m++)
9864 if(sc._vTbl[m] != wc.pureVTbl[m])
9865 c._vTbl[m] = sc._vTbl[m];
9869 for(d = c.derivatives.first; d; d = d.next)
9871 ApplySkin(d.data, name, c._vTbl);
9875 public void UnapplySkin(Class c)
9877 subclass(Window) wc = (subclass(Window))c;
9880 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9883 c._vTbl = wc.pureVTbl;
9887 for(d = c.derivatives.first; d; d = d.next)
9889 UnapplySkin(d.data);
9893 void CheckFontIntegrity(Window window)
9898 if(window.usedFont && window.usedFont.font == 0xecececec)
9900 FontResource uf = window.usedFont;
9901 char * className = window._class.name;
9902 char * text = window.text;
9905 for(c = window.firstChild; c; c = c.next)
9906 CheckFontIntegrity(c);
9910 public class ControllableWindow : Window
9912 /*WindowController controller;
9913 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9914 ~ControllableWindow() { delete controller; }*/
9917 class WindowControllerInterface : ControllableWindow
9919 bool OnKeyDown(Key key, unichar ch)
9921 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9924 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9926 result = onKeyDown(controller.window, key, ch);
9931 bool OnKeyUp(Key key, unichar ch)
9933 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
9936 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
9938 result = onKeyUp(controller.window, key, ch);
9943 bool OnKeyHit(Key key, unichar ch)
9945 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
9948 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
9950 result = onKeyHit(controller.window, key, ch);
9955 bool OnMouseMove(int x, int y, Modifiers mods)
9957 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9960 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
9962 result = onMouseMove(controller.window, x, y, mods);
9967 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9969 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
9972 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
9973 if(onLeftButtonDown)
9974 result = onLeftButtonDown(controller.window, x, y, mods);
9979 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9981 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
9984 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
9986 result = onLeftButtonUp(controller.window, x, y, mods);
9991 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9993 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
9996 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
9997 if(onLeftDoubleClick)
9998 result = onLeftDoubleClick(controller.window, x, y, mods);
10003 bool OnRightButtonDown(int x, int y, Modifiers mods)
10005 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10008 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
10009 if(onRightButtonDown)
10010 result = onRightButtonDown(controller.window, x, y, mods);
10015 bool OnRightButtonUp(int x, int y, Modifiers mods)
10017 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10020 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
10021 if(onRightButtonUp)
10022 result = onRightButtonUp(controller.window, x, y, mods);
10027 bool OnRightDoubleClick(int x, int y, Modifiers mods)
10029 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10032 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
10033 if(onRightDoubleClick)
10034 result = onRightDoubleClick(controller.window, x, y, mods);
10039 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10041 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10044 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10045 if(onMiddleButtonDown)
10046 result = onMiddleButtonDown(controller.window, x, y, mods);
10051 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10053 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10056 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10057 if(onMiddleButtonUp)
10058 result = onMiddleButtonUp(controller.window, x, y, mods);
10063 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10065 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10068 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10069 if(onMiddleDoubleClick)
10070 onMiddleDoubleClick(controller.window, x, y, mods);
10075 void OnResize(int width, int height)
10077 if(controller.OnResize)
10078 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10080 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10082 onResize(controller.window, width, height);
10086 void OnRedraw(Surface surface)
10088 if(controller.OnRedraw)
10089 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10091 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10093 onRedraw(controller.window, surface);
10099 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10102 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10104 result = onCreate(controller.window);
10109 bool OnLoadGraphics()
10111 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10114 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10116 result = onLoadGraphics(controller.window);
10121 void OnUnloadGraphics()
10123 if(controller.OnUnloadGraphics)
10124 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10126 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10127 if(onUnloadGraphics)
10128 onUnloadGraphics(controller.window);
10133 public class WindowController<class V>
10136 property Window window
10140 uint size = class(Window).vTblSize;
10143 windowVTbl = new void *[size];
10144 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10145 if(value._vTbl == value._class._vTbl)
10147 value._vTbl = new void *[value._class.vTblSize];
10148 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10152 for(c = 0; c < size; c++)
10154 void * function = class(WindowControllerInterface)._vTbl[c];
10155 if(function && function != DefaultFunction)
10156 value._vTbl[c] = function;
10158 value._vTbl[c] = windowVTbl[c];
10163 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10166 get { return window; }
10168 property V controlled
10170 set { controlled = value; }
10171 get { return controlled; }
10173 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10174 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10175 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10176 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10177 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10178 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10179 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10180 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10181 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10182 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10183 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10184 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10185 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10186 virtual void V::OnResize(WindowController controller, int width, int height);
10187 virtual void V::OnRedraw(WindowController controller, Surface surface);
10188 virtual bool V::OnCreate(WindowController controller);
10189 virtual bool V::OnLoadGraphics(WindowController controller);
10190 virtual void V::OnUnloadGraphics(WindowController controller);
10193 int (** windowVTbl)();
10197 ~WindowController()