7 import "GuiApplication"
28 #if defined(__WIN32__)
29 import "Win32Interface"
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
36 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
45 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
47 define skinMenuHeight = 40;
48 define statusBarHeight = 30;
50 define skinMenuHeight = 25;
51 define statusBarHeight = 18;
54 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
56 public enum DialogResult : int64 { cancel, yes, no, ok };
58 public class MouseButtons
61 bool left:1, right:1, middle:1;
64 public struct SizeAnchor
67 bool isClientW, isClientH;
72 #define SNAPDOWN(x, d) \
75 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
78 #define SNAPUP(x, d) \
81 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
84 /*static */define MAX_DIRTY_BACK = 10;
86 /////////////////////////////////////////////////////////////////////////////
87 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
88 /////////////////////////////////////////////////////////////////////////////
90 #define ACCESS_ITEM(l, id) \
93 #define FASTLIST_LOOP(l, v) \
94 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
96 #define FASTLIST_LOOPN(l, v, n) \
97 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
100 #define ACCESS_ITEM(l, id) \
101 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
103 #define FASTLIST_LOOP(l, v) \
104 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
106 #define FASTLIST_LOOPN(l, v, n) \
107 for( v = (void *)ACCESS_ITEM((l), (l).first), \
108 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
109 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
112 private class FastItem : struct
117 private struct FastList
122 int count, size, itemSize;
129 first = last = free = -1;
137 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
140 FastItem Add(uint itemSize)
143 if(free == -1 || !size)
150 newSize = (size + (size >> 1));
151 items = (FastItem)renew items byte[newSize * itemSize];
156 this.itemSize = itemSize;
157 items = (FastItem)new byte[newSize * itemSize];
160 for(c = size; c<newSize-1; c++)
162 ACCESS_ITEM(this, c).prev = -1;
163 ACCESS_ITEM(this, c).next = c+1;
165 ACCESS_ITEM(this, c).prev = -1;
166 ACCESS_ITEM(this, c).next = -1;
170 item = ACCESS_ITEM(this, free);
173 ACCESS_ITEM(this, item.prev).next = free;
183 void Delete(FastItem item)
186 ACCESS_ITEM(this, item.prev).next = item.next;
188 ACCESS_ITEM(this, item.next).prev = item.prev;
190 if(ACCESS_ITEM(this, first) == item)
192 if(ACCESS_ITEM(this, last) == item)
197 free = ((byte *)item - (byte *)items) / itemSize;
205 free = first = last = -1;
209 private class BoxItem : Item //FastItem
214 public /*private */struct Extent : OldList //FastList
223 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
224 Add(BoxItem { box = box });
227 void Copy(Extent source)
233 //FASTLIST_LOOP(source, extentBox)
234 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
235 AddBox(extentBox.box);
238 void IntersectBox(Box box)
240 // Clip all boxes of extent against inside of the new box
241 BoxItem extentBox, next;
243 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
244 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
246 next = (BoxItem)extentBox.next;
247 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
248 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
249 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
250 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
251 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
256 void ExcludeBox(Box box, Extent temp)
263 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
265 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
266 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
269 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
273 extentBox.box.left, extentBox.box.top,
274 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
280 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
284 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
285 extentBox.box.right, extentBox.box.bottom
291 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
294 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
298 extentBox.box.left, Max(extentBox.box.top, box.top),
299 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
305 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
309 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
310 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
318 AddBox(extentBox.box);
324 void UnionBox(Box box, Extent temp)
326 BoxItem extentBox, next;
328 // First pass: check if this box is not already covered by one of the extent's box
329 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
331 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
332 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
339 // Second pass: only keep boxes not completely covered in the new box
340 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
342 next = (BoxItem)extentBox.next;
343 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
344 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
348 // Add the exclusion to the extent
349 ExcludeBox(box, temp);
352 if(box.bottom >= box.top && box.right >= box.left)
354 // Optimization: if the resulting boxes touch, add them smarter
355 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
357 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
359 if(Abs(box.right - extentBox.box.left) <= 1)
361 extentBox.box.left = box.left;
364 else if(Abs(box.left - extentBox.box.right) <= 1)
366 extentBox.box.right = box.right;
370 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
372 if(Abs(box.bottom - extentBox.box.top) <= 1)
374 extentBox.box.top = box.top;
377 else if(Abs(box.top - extentBox.box.bottom) <= 1)
379 extentBox.box.bottom = box.bottom;
391 void Union(Extent b, Extent temp)
395 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
396 UnionBox(extentBox.box, temp);
399 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
406 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
409 temp2.IntersectBox(extentBox.box);
416 void Exclusion(Extent b, Extent temp)
419 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
420 ExcludeBox(extentBox.box, temp);
423 void Offset(int x, int y)
426 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
428 extentBox.box.left += x;
429 extentBox.box.top += y;
430 extentBox.box.right += x;
431 extentBox.box.bottom += y;
436 private define MINIMIZED_WIDTH = 160;
437 private define CASCADE_SPACE = 16;
439 // namespace Windows;
441 private class ScrollFlags
443 bool snapX:1, snapY:1, dontHide:1;
446 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
448 class WindowBits : BorderBits
450 BorderBits borderBits:6:0;
451 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
452 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
453 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
456 public enum BorderStyle : BorderBits
459 contour = BorderBits { contour = true },
460 fixed = BorderBits { fixed = true } | contour,
461 sizable = BorderBits { sizable = true } | fixed,
462 thin = BorderBits { fixed = true, thin = true } | contour,
463 sizableThin = BorderBits { sizable = true } | thin,
464 deep = BorderBits { deep = true },
465 bevel = BorderBits { bevel = true },
466 sizableDeep = sizable|deep,
467 sizableBevel = sizable|bevel,
468 fixedDeep = fixed|deep,
469 fixedBevel = fixed|bevel,
470 deepContour = deep|contour
473 public enum CreationActivationOption
475 activate, flash, doNothing
478 public enum WindowState { normal, minimized, maximized };
480 private class ResPtr : struct
487 private class HotKeySlot : struct
489 HotKeySlot prev, next;
497 class_data const char * icon;
499 class_default_property caption;
500 // class_initialize GuiApplication::Initialize;
501 class_designer FormDesigner;
502 class_property const char * icon
504 set { class_data(icon) = value; }
505 get { return class_data(icon); }
510 bool switchMode = true;
511 #if defined(__ANDROID__)
516 guiApp.Initialize(switchMode);
518 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
520 if(_vTbl == ((subclass(Window))_class).pureVTbl)
522 _vTbl = _class._vTbl;
524 else if(_vTbl != _class._vTbl)
527 for(m = 0; m < _class.vTblSize; m++)
529 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
530 _vTbl[m] = _class._vTbl[m];
535 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
536 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
537 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
538 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
542 // caption = CopyString(class.name);
544 children.offset = (byte*)&prev - (byte*)this;
545 childrenOrder.circ = true;
546 childrenCycle.circ = true;
548 maxSize = Size { MAXINT, MAXINT };
552 //style.isActiveClient = true;
555 modifyVirtArea = true;
556 manageDisplay = true;
557 nativeDecorations = true;
559 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
560 sbStep.x = sbStep.y = 8;
562 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
564 cursor = guiApp.GetCursor(arrow);
565 property::parent = guiApp.desktop;
577 int i, lockCount = guiApp.lockMutex.lockCount;
578 for(i = 0; i < lockCount; i++)
579 guiApp.lockMutex.Release();
581 for(i = 0; i < lockCount; i++)
582 guiApp.lockMutex.Wait();
587 stopwatching(parent, font);
588 if(parent.activeChild == this)
589 parent.activeChild = null;
590 if(parent.activeClient == this)
591 parent.activeClient = null;
596 // Prevent destructor from being called again...
602 /////////////////////////////////
605 OldLink slave = master.slaves.FindLink(this);
606 master.slaves.Delete(slave);
613 parent.childrenCycle.Remove(cycle);
615 parent.childrenOrder.Remove(order);
616 parent.children.Remove(this);
621 /////////////////////////////////
623 while((ptr = resources.first))
626 resources.Delete(ptr);
633 for(child = children.first; child; child = child.next)
635 // child.stopwatching(this, font);
637 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
638 // Don't want property here
639 *&child.parent = null;
642 while((slave = slaves.first))
644 // Don't want property here
645 *&((Window)slave.data).master = null;
646 slaves.Delete(slave);
649 // Because we do a decref in DestroyEx...
657 // Why was this commented?
658 //if(this != guiApp.desktop)
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);
1673 // (w, h): Full window size
1674 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1676 bool result = false;
1677 int oldCW = clientSize.w, oldCH = clientSize.h;
1678 bool clientResized, windowResized, windowMoved;
1680 //bool realResized = size.w != w || size.h != h;
1682 // TOCHECK: This wasn't in ecere.dll
1683 //if(!parent) return true;
1684 if(destroyed) return false;
1686 windowMoved = position.x != x || position.y != y || force;
1688 // windowResized = realResized || force;
1689 windowResized = size.w != w || size.h != h || force;
1691 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1697 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1698 scrolledPos.x - parent.clientStart.x + this.box.right,
1699 scrolledPos.y - parent.clientStart.y + this.box.bottom
1705 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1710 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1712 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1713 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1714 windowResized = true;
1716 if(display && rootWindow != this)
1719 if(guiApp && guiApp.windowMoving)
1721 if(guiApp.windowMoving.style.nonClient)
1722 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1724 guiApp.windowMoving.parent.SetMouseRangeToClient();
1734 // Buttons bitmap resources crash if we do this while switching mode
1735 if(!guiApp || !guiApp.modeSwitching)
1738 // Process Anchored Children
1742 for(child = children.first; child; child = child.next)
1745 ((child.stateAnchor.left.type != offset ||
1746 child.stateAnchor.top.type != offset ||
1747 child.stateAnchor.right.type != none ||
1748 child.stateAnchor.bottom.type != none) ||
1749 child.state == maximized || child.state == minimized))
1751 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1753 // child.Position(x, y, w, h, false, true, true, true, false);
1754 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1755 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1761 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1762 //if(updateScrollBars)
1764 OnResize(clientSize.w, clientSize.h);
1766 if((clientResized || windowMoved) && created)
1767 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1769 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1771 Window master = guiApp.interimWindow.master;
1772 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1775 if(rootWindow == this && !is3D)
1779 x -= guiApp.desktop.absPosition.x;
1780 y -= guiApp.desktop.absPosition.y;
1782 //guiApp.Log("Position %s\n", caption);
1785 if(windowResized || windowMoved)
1786 if(display && !display.flags.memBackBuffer && changeRootWindow)
1787 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1789 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1790 for(child = parent.children.first; child && child != this; child = child.next)
1791 if(child.rootWindow)
1792 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1797 if(windowMoved || windowResized)
1799 display.Lock(true /*false*/);
1802 display.Position(absPosition.x, absPosition.y);
1803 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1806 // result = realResized ? display.Resize(size.w, size.h) : true;
1807 if(nativeDecorations && rootWindow.windowHandle)
1809 int w = clientSize.w, h = clientSize.h;
1810 if(hasMenuBar) h += skinMenuHeight;
1811 if(hasStatusBar) h += statusBarHeight;
1812 if(sbv && sbv.visible) w += sbv.size.w;
1813 if(sbh && sbh.visible) h += sbh.size.h;
1814 result = manageDisplay ? display.Resize(w, h) : true;
1817 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1821 else if(clientResized)
1823 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1826 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1830 if(windowMoved || windowResized)
1835 if(guiApp.driver && changeRootWindow && windowHandle)
1837 if(windowResized || windowMoved)
1838 if(!display || display.flags.memBackBuffer)
1839 guiApp.interfaceDriver.PositionRootWindow(this,
1840 x, y, w, h, windowMoved, windowResized);
1841 guiApp.interfaceDriver.UpdateRootWindow(this);
1843 for(child = children.first; child; child = child.next)
1845 if(child.is3D && child.created)
1847 // Copy Display Content
1848 child.display.displaySystem = display.displaySystem;
1849 child.display.window = display.window;
1850 child.display.current = display.current;
1851 child.display.width = display.width;
1852 child.display.height = display.height;
1853 child.display.driverData = display.driverData;
1854 child.display.mutex = null;
1865 void UpdateScrollBars(bool flag, bool fullThing)
1868 bool resizeH = false, resizeV = false;
1869 bool scrolled = false;
1870 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1871 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1873 if(destroyed) return;
1874 if(guiApp.currentSkin)
1876 MinMaxValue cw = 0, ch = 0;
1877 bool sbvVisible, sbhVisible;
1878 int rangeH = 0, rangeV = 0;
1879 int positionH = 0, positionV;
1881 // First get client area with no respect to scroll bars
1886 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1888 if(scrollFlags.dontHide)
1891 cw -= guiApp.currentSkin.VerticalSBW();
1893 ch -= guiApp.currentSkin.HorizontalSBH();
1895 // Update the scrollbar visibility
1901 sbh.disabled = rangeH <= 1;
1902 if(sbh.style.hidden)
1912 sbv.disabled = rangeV <= 1;
1913 if(sbv.style.hidden)
1921 int oldHRange = sbh ? sbh.range : 0;
1922 int oldVRange = sbv ? sbv.range : 0;
1923 // Then start off with horizontal scrollbar range
1926 positionH = sbh.thumbPosition;
1933 SBSetTotal(sbh, rvw);
1936 ch -= guiApp.currentSkin.HorizontalSBH();
1939 // Do the same for vertical scrollbar
1942 positionV = sbv.thumbPosition;
1948 SBSetTotal(sbv, rvh);
1952 cw -= guiApp.currentSkin.VerticalSBW();
1953 // Maybe we need to set the range on the horizontal scrollbar again
1961 SBSetTotal(sbh, rvw);
1962 //sbh.Action(setRange, positionH, 0);
1963 if(rangeH <= 1 && sbh.range > 1)
1965 ch -= guiApp.currentSkin.HorizontalSBH();
1971 SBSetTotal(sbv, rvh);
1973 //sbv.Action(setRange, positionV, 0);
1978 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1979 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1982 // Update the scrollbar visibility
1983 if(!scrollFlags.dontHide)
1985 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1989 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1996 if(guiApp.currentSkin)
2003 sbhVisible = sbh.style.hidden ? true : false;
2005 sbvVisible = sbv.style.hidden ? true : false;
2007 // Do our resize here
2008 if(flag && (resizeH || resizeV) && fullThing)
2010 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2015 OnResize(clientSize.w, clientSize.h);
2021 sbh.visible = sbhVisible;
2023 sbv.visible = sbvVisible;
2025 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2026 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2029 sbh.pageStep = clientSize.w;
2031 sbv.pageStep = clientSize.h;
2033 // Notify doesn't handle setRange anymore... process it here
2036 int positionH = sbh.thumbPosition;
2037 if(scroll.x != positionH)
2039 OnHScroll(setRange, positionH, 0);
2043 SNAPDOWN(positionH, textCellW);
2044 scroll.x = positionH;
2050 int seen = clientSize.w, total = reqScrollArea.w;
2053 if(scrollFlags.snapX)
2054 SNAPDOWN(seen, sbStep.x);
2056 if(!total) total = seen;
2057 range = total - seen + 1;
2059 range = Max(range, 1);
2061 if(x >= range) x = range - 1;
2063 if(scrollFlags.snapX)
2064 SNAPUP(x, sbStep.x);
2068 OnHScroll(setRange, x, 0);
2073 SNAPDOWN(x, textCellW);
2079 int positionV = sbv.thumbPosition;
2080 if(scroll.y != positionV)
2082 OnVScroll(setRange, positionV, 0);
2086 SNAPDOWN(positionV, textCellH);
2087 scroll.y = positionV;
2093 int seen = clientSize.h, total = reqScrollArea.h;
2096 if(scrollFlags.snapY)
2097 SNAPDOWN(seen, sbStep.y);
2099 if(!total) total = seen;
2100 range = total - seen + 1;
2101 range = Max(range, 1);
2103 if(y >= range) y = range - 1;
2105 if(scrollFlags.snapY)
2106 SNAPUP(y, sbStep.y);
2110 OnVScroll(setRange, y, 0);
2115 SNAPDOWN(y, textCellH);
2121 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2124 for(child = children.first; child; child = child.next)
2126 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2129 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2130 child.Position(x, y, w, h, false, true, false, true, false, false);
2137 // Process Scrollbars
2139 if(sbh) // && !sbh.style.hidden
2142 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2143 // Need to set the range again (should improve...) since the scrollbars didn't have
2144 // the right size when UpdateScrollArea set the range on it
2147 sbh.seen = clientSize.w;
2151 if(sbv) // && !sbv.state.hidden
2154 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2155 // Need to set the range again (should improve...) since the scrollbars didn't have
2156 // the right size when UpdateScrollArea set the range on it
2159 sbv.seen = clientSize.h;
2164 // TESTING THIS LOWER
2165 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2168 for(child = children.first; child; child = child.next)
2170 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2173 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2174 child.Position(x, y, w, h, false, true, false, true, false, false);
2180 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2182 SetState(maximized, false, mods);
2186 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2188 SetState(normal, false, mods);
2192 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2194 SetState(minimized, false, mods);
2195 parent.CycleChildren(false, true, false, true);
2199 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2202 // Scroll bar notifications
2203 if(action != setRange)
2205 bool changed = false;
2209 if(scroll.x != position)
2211 OnHScroll(action, position, keyFlags);
2216 SNAPDOWN(position, textCellW);
2218 scroll.x = position;
2222 if(scroll.y != position)
2224 OnVScroll(action, position, keyFlags);
2229 SNAPDOWN(position, textCellH);
2231 scroll.y = position;
2235 bool childMove = false;
2236 for(child = children.first; child; child = child.next)
2238 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2241 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2242 child.Position(x, y, w, h, false, true, false, true, false, false);
2246 // Testing this patch out to solve MDI workspace redraw bugs
2247 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2248 // Scroll offsets to blame?
2252 UpdateCaret(false, false);
2256 // Testing this patch out to solve MDI workspace redraw bugs
2257 for(child = children.first; child; child = child.next)
2259 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2268 Window GetParentMenuBar()
2270 Window menuBarParent;
2271 if(formDesigner) return null;
2272 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2274 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2275 if(menuBarParent && !menuBarParent.isActiveClient)
2281 void CreateSystemChildren(void)
2283 Window parent = this;
2284 bool scrollBarChanged = false;
2285 bool hasClose = false, hasMaxMin = false;
2286 Point scroll = this.scroll;
2288 if(state == maximized)
2290 parent = GetParentMenuBar();
2297 if(style.hasClose) hasClose = true;
2298 if(style.hasMaximize || style.hasMinimize)
2305 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2307 sysButtons[2].Destroy(0);
2308 sysButtons[2] = null;
2310 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2312 sysButtons[1].Destroy(0);
2313 sysButtons[1] = null;
2315 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2317 sysButtons[0].Destroy(0);
2318 sysButtons[0] = null;
2321 if(hasClose && parent)
2328 parent, master = this,
2329 inactive = true, nonClient = true, visible = false;
2331 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2337 if(this.parent == guiApp.desktop)
2338 sysButtons[2].hotKey = altF4;
2339 else if(style.isActiveClient)
2340 sysButtons[2].hotKey = ctrlF4;
2341 sysButtons[2].Create();
2344 sysButtons[2].symbol = 'X';
2345 sysButtons[2].disabled = !style.hasClose;
2348 if(hasMaxMin && parent)
2352 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2353 if(state == maximized)
2356 method = RestoreButtonClicked;
2362 method = MaximizeButtonClicked;
2370 parent, master = this,
2371 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2373 sysButtons[1].Create();
2375 sysButtons[1].NotifyClicked = method;
2377 sysButtons[1].symbol = symbol;
2378 sysButtons[1].disabled = !style.hasMaximize;
2381 if(hasMaxMin && parent)
2385 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2386 if (state == minimized)
2389 method = RestoreButtonClicked;
2395 method = MinimizeButtonClicked;
2403 parent, master = this,
2404 hotKey = altM, inactive = true, nonClient = true, visible = false
2406 sysButtons[0].Create();
2408 sysButtons[0].NotifyClicked = method;
2410 sysButtons[0].symbol = symbol;
2411 sysButtons[0].disabled = !style.hasMinimize;
2414 // Create the scrollbars
2415 if(style.hasHorzScroll && !sbh)
2421 direction = horizontal,
2425 snap = scrollFlags.snapX,
2426 NotifyScrolling = ScrollBarNotification
2429 scrollBarChanged = true;
2431 else if(sbh && !style.hasHorzScroll)
2437 if(style.hasVertScroll && !sbv)
2443 direction = vertical,
2447 snap = scrollFlags.snapY,
2448 NotifyScrolling = ScrollBarNotification
2451 scrollBarChanged = true;
2453 else if(sbv && !style.hasVertScroll)
2458 if(scrollBarChanged)
2460 SetScrollLineStep(sbStep.x, sbStep.y);
2461 UpdateScrollBars(true, true);
2465 if(scrollBarChanged)
2467 if(sbh) sbh.thumbPosition = scroll.x;
2468 if(sbv) sbv.thumbPosition = scroll.y;
2472 void UpdateCaption(void)
2474 if(rootWindow == this)
2477 FigureCaption(caption);
2478 if(guiApp.interfaceDriver)
2479 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2481 UpdateDecorations();
2484 if(parent.activeClient == this) // Added this last check
2486 if(parent.rootWindow == parent)
2489 parent.FigureCaption(caption);
2490 if(guiApp.interfaceDriver)
2491 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2494 parent.UpdateCaption();
2496 parent.UpdateDecorations();
2500 void UpdateActiveDocument(Window previous)
2502 Window activeClient = this.activeClient;
2503 Window activeChild = this.activeChild;
2510 activeClient.CreateSystemChildren();
2512 previous.CreateSystemChildren();
2524 // Build window list
2527 Menu windowMenu = menu.FindMenu("Window");
2532 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2534 Window document = cycle.data;
2535 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2537 char name[2048], caption[2048];
2538 document.FigureCaption(caption);
2539 sprintf(name, "%d %s", id+1, caption);
2540 windowMenu.AddDynamic(MenuItem
2542 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2543 NotifySelect = MenuWindowSelectWindow
2547 if(activeClient.cycle == cycle) break;
2552 if((!previous && activeClient) || !activeClient)
2558 item = menu.FindItem(MenuWindowCloseAll, 0);
2559 if(item) item.disabled = false;
2560 item = menu.FindItem(MenuWindowNext, 0);
2561 if(item) item.disabled = false;
2562 item = menu.FindItem(MenuWindowPrevious, 0);
2563 if(item) item.disabled = false;
2564 item = menu.FindItem(MenuWindowCascade, 0);
2565 if(item) item.disabled = false;
2566 item = menu.FindItem(MenuWindowTileHorz, 0);
2567 if(item) item.disabled = false;
2568 item = menu.FindItem(MenuWindowTileVert, 0);
2569 if(item) item.disabled = false;
2570 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2571 if(item) item.disabled = false;
2572 item = menu.FindItem(MenuWindowWindows, 0);
2573 if(item) item.disabled = false;
2576 item = menu.FindItem(MenuFileClose, 0);
2577 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2578 item = menu.FindItem(MenuFileSaveAll, 0);
2579 if(item) item.disabled = numDocuments < 1;
2581 if(activeClient && activeClient.menu && activeClient.state != minimized)
2585 //activeClient.menu.Clean(activeClient);
2586 menu.Merge(activeClient.menu, true, activeClient);
2590 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2593 menu.Merge(activeChild.menu, true, activeChild);
2596 // This is called again for a child window change, with same active client
2597 OnActivateClient(activeClient, previous);
2598 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2599 parent.UpdateActiveDocument(null);
2602 void _ShowDecorations(Box box, bool post)
2604 if(rootWindow == this && nativeDecorations && !is3D) return;
2605 if(visible && this != guiApp.desktop)
2607 Surface surface = RedrawFull(box);
2611 FigureCaption(caption);
2614 ShowDecorations(captionFont.font,
2617 active, //parent.activeClient == this
2618 guiApp.windowMoving == this);
2620 PreShowDecorations(captionFont.font,
2623 active, //parent.activeClient == this
2624 guiApp.windowMoving == this);
2631 void UpdateExtent(Box refresh)
2633 Surface surface = null;
2635 if(!manageDisplay) { OnRedraw(null);return; }
2636 _ShowDecorations(refresh, false);
2638 surface = Redraw(refresh);
2639 // Opaque background: just fill before EW_REDRAW (clear?)
2642 surface.SetBackground(background);
2643 surface.SetForeground(foreground);
2644 surface.DrawingChar(' ');
2645 if(this == rootWindow)
2647 if(style.drawBehind || background.a)
2649 int a = background.a;
2650 // Premultiply alpha for clear color
2651 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2652 surface.Clear(colorBuffer);
2653 surface.SetBackground(background);
2656 else if(background.a)
2660 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2661 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2664 if(display.flags.alpha && background.a < 255 && background)
2666 surface.Area(0,0,clientSize.w, clientSize.h);
2667 /*if(style.clearDepthBuffer)
2668 surface.Clear(depthBuffer);*/
2670 else if(/*style.clearDepthBuffer || */background.a)
2672 int a = background.a;
2673 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2674 // Premultiply alpha for clear color
2675 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2676 surface.Clear(colorBuffer);
2677 surface.SetBackground(background);
2682 surface.TextFont(usedFont.font);
2683 surface.TextOpacity(false);
2687 // Draw the caret ...
2688 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2690 // surface.SetBackground(0xFFFFFF - background.color);
2691 surface.SetBackground(~background.color);
2693 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2694 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2700 void DrawOverChildren(Box refresh)
2702 Surface surface = Redraw(refresh);
2706 surface.DrawingChar(' ');
2707 surface.SetBackground(background);
2708 surface.SetForeground(foreground);
2710 surface.TextFont(usedFont.font);
2711 surface.TextOpacity(false);
2713 OnDrawOverChildren(surface);
2718 _ShowDecorations(refresh, true);
2721 void ComputeClipExtents(void)
2724 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2726 clipExtent.Copy(this.clipExtent);
2728 for(child = children.last; child; child = child.prev)
2730 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2732 bool opaque = child.IsOpaque(); // TODO: acess background directly
2733 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2735 child.clipExtent.Copy(clipExtent);
2736 child.clipExtent.Offset(-dx, -dy);
2737 child.clipExtent.IntersectBox(child.box);
2739 child.ComputeClipExtents();
2741 if(opaque && !child.style.nonClient)
2743 // Adjust the box for the parent:
2744 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2745 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2750 // ??? Only do this for overlapped window or if parent has with clip children flag
2752 // Do this if window has clip children flag on (default false?)
2753 // this.clipExtent = clipExtent;
2755 clipExtent.Free(null);
2758 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2761 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2762 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2764 offsetX -= rootWindow.clientStart.x;
2765 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2769 for(child = children.last; child; child = child.prev)
2771 bool opaque = child.IsOpaque();
2772 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2776 // Adjust renderArea to the root window level
2777 Extent * renderArea = &rootWindow.tempExtents[3];
2779 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2780 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2781 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2783 offsetX -= child.rootWindow.clientStart.x;
2784 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2788 Extent childRenderArea;
2790 if(backBufferUpdate != null)
2792 childRenderArea.Copy(backBufferUpdate);
2793 childRenderArea.Offset(-offsetX, -offsetY);
2796 childRenderArea.Copy(child.dirtyArea);
2798 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2799 renderArea.Copy(dirtyExtent);
2800 renderArea.Offset(-offsetX, -offsetY);
2801 childRenderArea.Union(renderArea);
2804 // Intersect with the clip extent
2805 childRenderArea.Intersection(child.clipExtent);
2808 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2810 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2811 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2813 renderArea->Offset(offsetX, offsetY);
2815 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2816 // overDirtyExtent.Union(renderArea);
2817 renderArea->Empty();
2818 // childRenderArea.Free();
2820 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2825 for(child = children.last; child; child = child.prev)
2827 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2829 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2834 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2836 bool opaque = IsOpaque();
2837 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2839 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2840 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2842 offsetX -= rootWindow.clientStart.x;
2843 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2847 for(child = children.last; child; child = child.prev)
2849 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2851 ColorAlpha background = *(ColorAlpha *)&child.background;
2852 bool opaque = child.IsOpaque();
2853 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2857 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2858 // Adjust renderArea to the root window level
2860 renderArea.Copy(child.dirtyArea);
2861 renderArea.Offset(offsetX, offsetY);
2862 dirtyExtent.Union(renderArea);
2863 overDirtyExtent.Union(renderArea);
2869 for(child = children.last; child; child = child.prev)
2871 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2873 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2877 if(backBufferUpdate != null)
2879 renderArea.Copy(backBufferUpdate);
2880 renderArea.Offset(-offsetX, -offsetY);
2882 overRenderArea.Copy(backBufferUpdate);
2883 overRenderArea.Offset(-offsetX, -offsetY);
2889 renderArea.Copy(dirtyArea);
2891 overRenderArea.Copy(dirtyArea);
2894 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2895 dirtyExtentWindow->Copy(dirtyExtent);
2896 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2897 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2898 dirtyExtentWindow->Empty();
2900 // Intersect with the clip extent
2901 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2904 if(renderArea.count > 10)
2907 printf("\nToo many extents (%d):\n", renderArea.count);
2909 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2910 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2915 for(c = 0; c<10; c++)
2918 FASTLIST_LOOP(renderArea, extentBox)
2920 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2922 renderArea.Copy(extent);
2924 FASTLIST_LOOP(renderArea, extentBox)
2927 printf("(%d, %d) - (%d, %d)\n",
2928 extentBox.box.left, extentBox.box.top,
2929 extentBox.box.right, extentBox.box.bottom);
2933 printf("\nNow %d\n", renderArea.count);
2939 // WHY WAS THIS COMMENTED ??
2941 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2942 dirtyExtentWindow->Copy(overDirtyExtent);
2943 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2944 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2945 dirtyExtentWindow->Empty();
2947 // Intersect with the clip extent
2948 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2954 if(scrollExtent.count)
2956 // Subtract render extent from scrolling extent
2957 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2959 if(backBufferUpdate == null)
2961 Extent * dirty = &rootWindow.tempExtents[3];
2964 // Intersect scrolling extent with clip extent
2965 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2967 // offset this scroll to be at the root window level
2968 scrollExtent.Offset(offsetX, offsetY);
2969 // Add area that was scrolled to the dirty extents of the back buffer
2970 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2974 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2975 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2976 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2981 scrollExtent.Empty();
2983 // Add the exposed extent to the window render area
2984 dirty->Offset(-offsetX, -offsetY);
2985 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2990 // Subtract the window's box from the transparency forced extent
2991 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2997 renderArea.Copy(this.renderArea);
2998 renderArea.Offset(offsetX, offsetY);
2999 dirtyExtent.Union(renderArea);
3005 Extent renderArea { };
3007 renderArea.Copy(overRenderArea);
3008 renderArea.Offset(offsetX, offsetY);
3009 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3014 if(backBufferUpdate != null)
3016 // Remove render area from dirty area
3017 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3019 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3026 // Remove the window render area from the dirty extents of the back buffer
3027 rootWindow.dirtyBack.Exclusion(renderArea);
3031 void Render(Extent updateExtent)
3035 Window rootWindow = this.rootWindow;
3036 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3037 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3039 offsetX -= rootWindow.clientStart.x;
3040 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3043 if(rootWindow.fullRender)
3052 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3053 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3058 /*if(renderArea.count)
3059 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3062 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3064 Box box = extentBox.box;
3067 /*printf("(%d, %d) - (%d, %d)\n",
3068 extentBox.box.left, extentBox.box.top,
3069 extentBox.box.right, extentBox.box.bottom);*/
3074 box.left += offsetX;
3076 box.right += offsetX;
3077 box.bottom += offsetY;
3079 if(updateExtent != null)
3080 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3084 for(child = children.first; child; child = child.next)
3085 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3086 child.Render(updateExtent);
3088 if(rootWindow.fullRender)
3089 DrawOverChildren(box);
3092 // TO DO: There's an issue about draw over children...
3093 // TO DO: Don't wanna go through this if method isn't used
3094 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3095 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3097 Box box = extentBox.box;
3099 DrawOverChildren(box);
3101 box.left += offsetX;
3103 box.right += offsetX;
3104 box.bottom += offsetY;
3106 if(updateExtent != null)
3107 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3110 for(child = children.first; child; child = child.next)
3111 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3112 child.Render(updateExtent);
3115 overRenderArea.Empty();
3118 public void UpdateDisplay(void)
3120 if(!manageDisplay) { OnRedraw(null);return; }
3121 if(rootWindow && this != rootWindow)
3122 rootWindow.UpdateDisplay();
3125 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3126 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3129 dirtyExtent.Clear();
3132 clipExtent.AddBox(box);
3134 display.StartUpdate();
3136 if(!rootWindow.fullRender)
3138 ComputeClipExtents();
3139 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3140 ComputeRenderArea(dirtyExtent, overExtent, null);
3143 clipExtent.Free(null);
3145 dirtyExtent.Free(null);
3146 overExtent.Free(null);
3148 if(display.flags.flipping)
3151 display.Update(null);
3155 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3156 updateExtent.Clear();
3158 Render(updateExtent);
3160 updateExtent.UnionBox(this.box, tempExtents[0]);
3163 //printf("\n\nUpdate:\n------------------------------------------\n");
3166 //FASTLIST_LOOP(updateExtent, extentBox)
3167 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3170 /*printf("Updating (%d, %d) - (%d, %d)\n",
3171 extentBox.box.left, extentBox.box.top,
3172 extentBox.box.right, extentBox.box.bottom);*/
3175 display.Update(extentBox.box);
3178 updateExtent.Free(null);
3181 display.EndUpdate();
3189 void UpdateBackDisplay(Box box)
3195 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3197 //printf("UpdateBackDisplay going through!\n");
3198 display.StartUpdate();
3202 intersection.Copy(dirtyBack);
3203 intersection.IntersectBox(box);
3205 dirtyExtent.Clear();
3208 clipExtent.AddBox(box);
3210 if(!rootWindow.fullRender)
3212 ComputeClipExtents();
3213 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3216 clipExtent.Free(null);
3218 intersection.Free(null);
3219 dirtyExtent.Free(null);
3220 overExtent.Free(null);
3225 if(display.flags.flipping)
3226 display.Update(null);
3229 rootWindow.display.Update(box);
3232 display.EndUpdate();
3236 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3237 if(dirtyBack.count > MAX_DIRTY_BACK)
3239 BoxItem extentBox, next;
3240 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3241 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3243 next = (BoxItem)extentBox.next;
3244 if(extentBox != first)
3246 if(extentBox.box.left < first.box.left)
3247 first.box.left = extentBox.box.left;
3248 if(extentBox.box.top < first.box.top)
3249 first.box.top = extentBox.box.top;
3250 if(extentBox.box.right > first.box.right)
3251 first.box.right = extentBox.box.right;
3252 if(extentBox.box.bottom > first.box.bottom)
3253 first.box.bottom = extentBox.box.bottom;
3254 dirtyBack.Delete(extentBox);
3263 // --- Window positioning ---
3264 // --- Window identification ---
3266 // Returns window at position "Position"
3267 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3269 Window child, result = null;
3271 box.left += absPosition.x;
3272 box.right += absPosition.x;
3273 box.top += absPosition.y;
3274 box.bottom += absPosition.y;
3276 if(!destroyed && visible && (acceptDisabled || !disabled))
3278 int lx = x - absPosition.x;
3279 int ly = y - absPosition.y;
3280 if(IsInside(lx, ly))
3281 // if(box.IsPointInside(Point{x, y}))
3283 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3284 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3287 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3288 Window ancestor = null;
3290 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3291 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3293 if(child != statusBar && child.rootWindow == rootWindow)
3295 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3302 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3304 if(child != statusBar && child.rootWindow == rootWindow)
3306 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3313 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3321 Window FindModal(void)
3323 Window modalWindow = this, check;
3324 Window check2 = null;
3325 for(check = this; check.master; check = check.master)
3327 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3329 modalWindow = check.master.modalSlave;
3330 check = modalWindow;
3332 // TESTING THIS FOR DROPBOX...
3333 if(!rootWindow || !rootWindow.style.interim)
3335 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3337 if(check2.modalSlave && check2.modalSlave.created)
3339 modalWindow = check2.modalSlave;
3347 if(modalWindow == this)
3349 for(check = this; check.activeChild; check = check.activeChild)
3351 if(check.modalSlave)
3353 modalWindow = check.modalSlave;
3359 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3360 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3363 void StopMoving(void)
3365 if(this == guiApp.windowMoving)
3367 guiApp.windowMoving = null;
3368 UpdateDecorations();
3369 SetMouseRange(null);
3372 if(rootWindow.active)
3373 guiApp.interfaceDriver.StopMoving(rootWindow);
3375 guiApp.windowCaptured.ReleaseCapture();
3376 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3377 guiApp.windowIsResizing = false;
3381 void SelectMouseCursor(void)
3386 Window cursorWindow = null;
3387 bool rx, ry, rex, rey;
3389 guiApp.desktop.GetMousePosition(&x, &y);
3390 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3392 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3393 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3394 else if(mouseWindow)
3396 modalWindow = mouseWindow.FindModal();
3397 x -= mouseWindow.absPosition.x;
3398 y -= mouseWindow.absPosition.y;
3399 if(guiApp.windowIsResizing)
3401 rex = guiApp.resizeEndX;
3402 rey = guiApp.resizeEndY;
3403 rx = guiApp.resizeX;
3404 ry = guiApp.resizeY;
3405 if((rex && rey) || (rx && ry))
3406 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3407 else if((rex && ry) || (rx && rey))
3408 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3409 else if((ry || rey) && (!rx && !rex))
3410 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3411 else if((rx || rex) && (!ry && !rey))
3412 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3414 else if(!modalWindow && !guiApp.windowCaptured &&
3415 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3416 &rx, &ry, &rex, &rey))
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(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3429 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3430 mouseWindow.rootWindow != mouseWindow)
3431 cursorWindow = mouseWindow.parent;
3433 cursorWindow = mouseWindow;
3435 else if(!guiApp.interimWindow)
3436 cursorWindow = guiApp.windowCaptured;
3439 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3440 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3442 else if(modalWindow)
3444 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3446 else if(guiApp.interimWindow)
3448 if(guiApp.interimWindow.cursor)
3449 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3451 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3456 // --- State based input ---
3457 bool AcquireInputEx(bool state)
3462 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3463 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3465 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3467 guiApp.acquiredWindow = state ? this : null;
3470 SetMouseRangeToClient();
3471 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3476 SelectMouseCursor();
3478 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3482 // --- Window activation ---
3483 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3486 if(!parent || !parent.style.inactive)
3488 Window parent = this.parent;
3491 if(rootWindow == this)
3492 Log(active ? "active\n" : "inactive\n");
3494 if(active && requireRemaximize)
3496 if(state == maximized)
3498 property::state = normal;
3499 property::state = maximized;
3501 requireRemaximize = false;
3504 // Testing this here...
3505 if(!parent || parent == guiApp.desktop || parent.active)
3507 this.active = active;
3510 // TESTING THIS HERE
3511 UpdateDecorations();
3512 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3513 result = NotifyActivate(master, this, active, previous);
3516 this.active = !active;
3521 if(!parent || parent == guiApp.desktop || parent.active)
3523 this.active = active;
3525 AcquireInputEx(active);
3526 if(active && isEnabled)
3530 if(guiApp.caretOwner)
3534 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3535 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3536 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3537 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3539 guiApp.caretOwner.Update(extent);
3542 if(visible || !guiApp.caretOwner)
3543 guiApp.caretOwner = this;
3544 UpdateCaret(false, false);
3550 this.active = false;
3552 AcquireInputEx(active);
3554 if(!active && guiApp.caretOwner == this)
3556 UpdateCaret(false, true);
3557 guiApp.caretOwner = null;
3558 guiApp.interfaceDriver.SetCaret(0,0,0);
3559 guiApp.caretEnabled = false;
3564 if(!active && parent && parent.activeChild && parent.activeChild != this)
3565 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3571 if(!active && menuBar)
3574 menuBar.OnActivate(false, null, &goOn, true);
3575 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3580 Window aChild = activeChild;
3582 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3594 void ConsequentialMouseMove(bool kbMoving)
3598 if(kbMoving || !guiApp.windowMoving)
3602 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3604 if(guiApp.interfaceDriver)
3605 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3607 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3608 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3614 bool IsDescendantOf(Window ancestor)
3617 for(window = this; window && window != ancestor; window = window.parent);
3618 return window == ancestor;
3621 bool IsSlaveOf(Window master)
3624 for(window = this; window && window != master; window = window.master);
3625 return window == master;
3628 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3632 if(this && !destroyed /*&& state != Hidden*/)
3634 Window swap = externalSwap;
3642 if(activateParent &&
3643 (parent.activeChild != this ||
3644 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3645 active && _isModal &&
3646 parent != master && master)
3647 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3653 bool real = parent.activeChild != this;
3655 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3656 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3657 !IsDescendantOf(guiApp.interimWindow) &&
3658 !IsSlaveOf(guiApp.interimWindow))
3660 Window interimWindow = guiApp.interimWindow;
3661 while(interimWindow && interimWindow != this)
3663 Window master = interimWindow.master;
3665 guiApp.interimWindow = null;
3666 if(guiApp.caretOwner)
3667 guiApp.caretOwner.UpdateCaret(false, false);
3669 incref interimWindow;
3670 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3675 delete interimWindow;
3676 interimWindow = (master && master.style.interim) ? master : null;
3681 guiApp.interimWindow = this;
3682 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3683 guiApp.caretEnabled = false;*/
3684 UpdateCaret(false, true);
3689 //bool acquireInput = false;
3691 parent.activeChild &&
3692 parent.activeChild.state == maximized &&
3693 parent != guiApp.desktop;
3695 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3700 swap = parent.activeChild;
3701 if(swap && swap.destroyed) swap = null;
3702 if(swap && swap != this)
3705 if(!swap.PropagateActive(false, this, &goOn, true))
3706 swap = parent.activeChild;
3717 if(!parent || parent.activeChild != this || style.interim)
3720 result = PropagateActive(true, swap, &goOn, true);
3721 if(!result && !goOn)
3726 //acquireInput = true;
3730 if(style.hasMaximize && parent != guiApp.desktop)
3733 SetState(maximized, false, 0);
3734 else if(state != maximized)
3737 for(child = parent.children.first; child; child = child.next)
3739 if(this != child && child.state == maximized)
3740 child.SetState(normal, false, 0);
3747 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3749 Window previous = parent.activeClient;
3750 parent.activeChild = this;
3751 if(!style.nonClient /*&& style.isActiveClient*/)
3755 if(style.isActiveClient)
3756 parent.activeClient = this;
3757 // Moved UpdateActiveDocument inside hidden check
3758 // To prevent activating previous window while creating a new one
3759 // (It was messing up the privateModule in the CodeEditor)
3760 parent.UpdateActiveDocument(previous);
3766 //if(!style.isRemote)
3768 if(rootWindow != this)
3770 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3771 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3773 else if(!guiApp.fullScreenMode)
3775 Window modalRoot = FindModal();
3776 if(!modalRoot) modalRoot = this;
3777 if(!modalRoot.isForegroundWindow)
3779 modalRoot.isForegroundWindow = true;
3780 // To check : Why is parent null?
3781 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3783 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3785 modalRoot.isForegroundWindow = false;
3790 if(result && real && (!style.inactive || moveInactive) && parent)
3792 Window last = parent.children.last;
3794 if(!style.stayOnTop)
3795 for(; last && last.style.stayOnTop; last = last.prev);
3797 parent.children.Move(this, last);
3799 // Definitely don't want that: why not?
3803 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3809 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3816 parent.activeChild = null;
3817 if(!style.nonClient /*&& style.isActiveClient*/)
3819 Window previous = parent.activeClient;
3820 if(style.isActiveClient)
3821 parent.activeClient = null;
3822 parent.UpdateActiveDocument(previous);
3826 if(this == guiApp.interimWindow)
3828 guiApp.interimWindow = null;
3829 if(guiApp.caretOwner)
3830 guiApp.caretOwner.UpdateCaret(false, false);
3832 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3839 if(!active || !swap)
3840 UpdateDecorations();
3842 swap.UpdateDecorations();
3844 if(active && rootWindow != this)
3845 ConsequentialMouseMove(false);
3852 // --- Input Messages ---
3853 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3855 static bool reEntrancy = false;
3856 if(reEntrancy) return;
3860 guiApp.cursorUpdate = true;
3861 if(guiApp.windowScrolling && !consequential)
3863 guiApp.windowScrolling.SetScrollPosition(
3864 (guiApp.windowScrolling.sbh) ?
3865 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3866 (guiApp.windowScrolling.sbv) ?
3867 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3869 if(guiApp.windowMoving)
3871 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3873 Window window = guiApp.windowMoving;
3875 int w = window.size.w;
3876 int h = window.size.h;
3881 rx = mouseX - guiApp.windowMovingStart.x;
3882 ry = mouseY - guiApp.windowMovingStart.y;
3885 window.GetDecorationsSize(&ew, &eh);
3887 if(guiApp.windowIsResizing)
3889 x = window.scrolledPos.x;
3890 y = window.scrolledPos.y;
3894 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3895 rx = guiApp.windowResizingBefore.w - aw;
3896 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3897 w = guiApp.windowResizingBefore.w - rx;
3901 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3902 ry = guiApp.windowResizingBefore.h - ah;
3903 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3904 ry = Max(ry, -guiApp.windowMovingBefore.y);
3905 h = guiApp.windowResizingBefore.h - ry;
3907 if(guiApp.resizeEndX)
3909 w = guiApp.windowResizingBefore.w + rx;
3912 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3920 w = Max(w, window.minSize.w);
3921 h = Max(h, window.minSize.h);
3922 w = Min(w, window.maxSize.w);
3923 h = Min(h, window.maxSize.h);
3925 if(!window.OnResizing(&w, &h))
3927 w = window.clientSize.w;
3928 h = window.clientSize.h;
3931 w = Max(w, window.skinMinSize.w);
3932 h = Max(h, window.skinMinSize.h);
3939 SNAPDOWN(w, textCellW);
3940 SNAPDOWN(h, textCellH);
3945 aw = Max(w,window.skinMinSize.w);
3946 rx = guiApp.windowResizingBefore.w - aw;
3947 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3948 w = guiApp.windowResizingBefore.w - rx;
3952 ah = Max(h,window.skinMinSize.h);
3953 ry = guiApp.windowResizingBefore.h - ah;
3954 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3955 ry = Max(ry, -guiApp.windowMovingBefore.y);
3956 h = guiApp.windowResizingBefore.h - ry;
3961 if(!guiApp.windowIsResizing || guiApp.resizeX)
3962 x = guiApp.windowMovingBefore.x + rx;
3963 if(!guiApp.windowIsResizing || guiApp.resizeY)
3964 y = guiApp.windowMovingBefore.y + ry;
3966 if(!guiApp.windowIsResizing)
3969 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3971 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3972 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3973 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3974 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3978 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3979 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3985 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3987 if(!window.OnMoving(&x, &y, w, h))
3989 x = window.scrolledPos.x;
3990 y = window.scrolledPos.y;
3996 SNAPDOWN(x, textCellW);
3997 SNAPDOWN(y, textCellH);
4000 if(!window.style.nonClient)
4002 if(!window.style.fixed /*|| window.style.isDocument*/)
4004 if(!window.style.dontScrollHorz)
4005 x += window.parent.scroll.x;
4006 if(!window.style.dontScrollVert)
4007 y += window.parent.scroll.y;
4011 // Break the anchors for moveable/resizable windows
4012 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4013 if(window.style.fixed)
4015 if(window.state == normal)
4017 window.normalAnchor = Anchor { left = x, top = y };
4018 window.normalSizeAnchor = SizeAnchor { { w, h } };
4019 window.anchored = false;
4023 window.stateAnchor = Anchor { left = x, top = y };
4024 window.stateSizeAnchor = SizeAnchor { { w, h } };
4026 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4027 // TOCHECK: Investigate why the following only redraws the scrollbars
4028 //window.Position(x, y, w, h, false, true, true, true, false, true);
4030 guiApp.movingLast.x = mouseX;
4031 guiApp.movingLast.y = mouseY;
4037 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4040 bool wasMoving = guiApp.windowMoving ? true : false;
4041 bool wasScrolling = guiApp.windowScrolling ? true : false;
4043 while(result && w != this)
4045 Window msgWindow = GetAtPosition(x,y, false, true, w);
4046 Window trueWindow = GetAtPosition(x,y, false, false, w);
4047 bool windowDragged = false;
4052 window = (w && !w.disabled) ? w : null;
4054 if(trueWindow) incref trueWindow;
4056 if(consequential) mods->isSideEffect = true;
4058 UpdateMouseMove(x, y, consequential);
4060 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4062 if(!guiApp.windowCaptured.isEnabled)
4063 guiApp.windowCaptured.ReleaseCapture();
4065 window = guiApp.windowCaptured;
4068 if(trueWindow && activate &&
4069 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4070 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4071 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4072 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4074 if(mods->alt && !mods->ctrl && !mods->shift)
4076 Window moved = trueWindow;
4077 for(moved = trueWindow; moved; moved = moved.parent)
4078 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4083 windowDragged = true;
4085 // Cancel the ALT menu toggling...
4086 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4091 if(window && activate &&
4092 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4093 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4094 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4095 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4097 Window modalWindow = window.FindModal();
4099 /*if(mods->alt && !mods->shift && !mods->ctrl)
4101 Window moved = window;
4102 for(moved = window; moved; moved = moved.parent)
4103 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4108 windowDragged = true;
4110 // Cancel the ALT menu toggling...
4111 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4117 Window activateWindow = modalWindow ? modalWindow : window;
4118 if(activateWindow && !activateWindow.isRemote)
4120 bool doActivation = true;
4121 //bool needToDoActivation = false;
4122 Window check = activateWindow;
4124 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4126 if(!check.style.inactive)
4128 //needToDoActivation = true;
4130 doActivation = false;
4135 if(!needToDoActivation)
4136 doActivation = false;
4139 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4140 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4142 // Let the OnLeftButtonDown do the activating instead
4143 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4151 incref activateWindow;
4152 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4154 delete activateWindow;
4158 if(activateWindow._refCount == 1)
4160 delete activateWindow;
4164 delete activateWindow;
4165 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4168 mods->isActivate = true;
4172 if(!modalWindow && window && !window.destroyed)
4174 if(!guiApp.windowCaptured || windowDragged)
4176 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4178 bool moving = ((window.state != maximized &&
4179 window.IsMouseMoving(
4180 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4181 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4183 if(!moving && window.IsMouseResizing(
4184 x - window.absPosition.x,
4185 y - window.absPosition.y,
4186 window.size.w, window.size.h,
4187 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4189 guiApp.windowIsResizing = true;
4190 guiApp.windowResizingBefore.w = window.size.w;
4191 guiApp.windowResizingBefore.h = window.size.h;
4193 if(guiApp.windowIsResizing || windowDragged || moving)
4196 guiApp.windowMoving = window;
4197 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4198 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4199 guiApp.windowMovingBefore.x = window.position.x;//s;
4200 guiApp.windowMovingBefore.y = window.position.y;//s;
4201 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4202 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4205 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4207 if(window.style.fixed &&
4209 window.IsMouseMoving(
4210 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4212 window.ShowSysMenu(x, y);
4216 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4218 if(window.sbv || window.sbh)
4221 guiApp.windowScrolling = window;
4222 guiApp.windowScrollingStart.x = x;
4223 guiApp.windowScrollingStart.y = y;
4224 guiApp.windowScrollingBefore.x = window.scroll.x;
4225 guiApp.windowScrollingBefore.y = window.scroll.y;
4228 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4230 if(window.style.hasMaximize &&
4231 window.IsMouseMoving(
4232 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4235 (window.state == maximized) ? normal : maximized, false, *mods);
4243 if(guiApp.windowMoving)
4245 if(guiApp.windowMoving.parent)
4247 if(guiApp.windowMoving.style.nonClient)
4248 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4250 guiApp.windowMoving.parent.SetMouseRangeToClient();
4254 window.UpdateDecorations();
4257 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4259 // Log("\n*** LEFT BUTTON UP ***\n");
4260 if(guiApp.windowMoving)
4261 guiApp.windowMoving.StopMoving();
4263 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4265 if(guiApp.windowScrolling)
4267 Window windowScrolling = guiApp.windowScrolling;
4268 guiApp.windowScrolling = null;
4269 windowScrolling.ReleaseCapture();
4273 if(!result || (window && window.destroyed)) window = null;
4275 if(window && window.FindModal())
4278 if(trueWindow && trueWindow.FindModal())
4286 msgWindow = GetAtPosition(x,y, true, false);
4288 msgWindow.SelectMouseCursor();
4291 if(guiApp.windowCaptured || trueWindow)
4293 Window prevWindow = guiApp.prevWindow;
4294 List<Window> overWindows = guiApp.overWindows;
4295 Iterator<Window> it { overWindows };
4300 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4303 result = w.OnMouseLeave(*mods);
4305 overWindows.TakeOut(w);
4309 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4311 guiApp.prevWindow.mouseInside = false;
4312 guiApp.prevWindow = null;
4316 if(trueWindow.IsDescendantOf(prevWindow))
4318 if(!overWindows.Find(prevWindow))
4319 overWindows.Add(prevWindow);
4321 // Eventually fix this not to include captured?
4322 else if(!prevWindow.OnMouseLeave(*mods))
4326 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4328 Box box = trueWindow.box;
4329 box.left += trueWindow.absPosition.x;
4330 box.right += trueWindow.absPosition.x;
4331 box.top += trueWindow.absPosition.y;
4332 box.bottom += trueWindow.absPosition.y;
4334 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4336 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4337 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4339 overX = Max(Min(overX, 32767),-32768);
4340 overY = Max(Min(overY, 32767),-32768);
4342 trueWindow.mouseInside = true;
4343 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4347 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4349 for(w : guiApp.overWindows; w == trueWindow)
4352 guiApp.overWindows.TakeOut(w);
4355 guiApp.prevWindow = trueWindow;
4358 guiApp.prevWindow = null;
4360 SelectMouseCursor();
4362 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4363 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4365 int clientX = x - (window.absPosition.x + window.clientStart.x);
4366 int clientY = y - (window.absPosition.y + window.clientStart.y);
4368 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4370 clientX = Max(Min(clientX, 32767),-32768);
4371 clientY = Max(Min(clientY, 32767),-32768);
4373 MouseMethod = (void *)window._vTbl[method];
4375 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4378 if(!MouseMethod(window, clientX, clientY, *mods))
4382 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4383 window.OnMouseLeave(*mods);
4390 if(result && w && w.clickThrough && w.parent)
4395 if(!result || !w || !w.clickThrough)
4402 // --- Mouse cursor management ---
4404 bool KeyMessage(uint method, Key key, unichar character)
4409 if(guiApp.interimWindow)
4410 this = guiApp.interimWindow;
4413 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4417 if(!style.inactive || rootWindow != this)
4419 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4420 Window modalWindow = FindModal();
4421 Window interimMaster = master ? master.rootWindow : null;
4425 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4426 status = OnSysKeyDown(key, character);
4427 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4428 status = OnSysKeyHit(key, character);
4429 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4430 status = OnSysKeyUp(key, character);
4437 // Process Key Message for Internal UI Keyboard actions
4438 if(status && !destroyed && menuBar && state != minimized)
4441 if((SmartKey)key != alt)
4442 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4445 SmartKey sk = (SmartKey) key;
4446 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4448 status = menuBar.KeyMessage(method, key, character);
4453 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4454 menuBar.OnKeyHit(escape, 0);
4456 if(!menuBar.focus && guiApp.caretOwner)
4457 guiApp.caretOwner.UpdateCaret(true, false);
4460 if(!destroyed && status)
4462 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4466 case left: case up: case right: case down:
4467 if(guiApp.windowMoving == this)
4470 int w = guiApp.windowMoving.size.w;
4471 int h = guiApp.windowMoving.size.h;
4472 int x = guiApp.windowMoving.scrolledPos.x;
4473 int y = guiApp.windowMoving.scrolledPos.y;
4477 if(key == down || key == up)
4478 step = Max(step, textCellH);
4480 step = Max(step, textCellW);
4483 if(guiApp.windowIsResizing)
4487 case left: w-=step; break;
4488 case right: w+=step; break;
4489 case up: h-=step; break;
4490 case down: h+=step; break;
4497 case left: x-=step; break;
4498 case right: x+=step; break;
4499 case up: y-=step; break;
4500 case down: y+=step; break;
4504 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4505 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4507 if(!guiApp.windowIsResizing || guiApp.resizeX)
4508 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4510 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4512 if(!guiApp.windowIsResizing || guiApp.resizeY)
4513 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4515 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4517 guiApp.interfaceDriver.SetMousePosition(x, y);
4518 ConsequentialMouseMove(true);
4526 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4528 guiApp.windowMoving.StopMoving();
4529 ConsequentialMouseMove(false);
4537 ShowSysMenu(absPosition.x, absPosition.y);
4545 if(!destroyed && status && state != minimized)
4547 // Process all the way down the children
4548 if(activeChild && !activeChild.disabled)
4550 status = activeChild.KeyMessage(method, key, character);
4552 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4553 key.code != left && key.code != right && key.code != up && key.code != down)
4555 status = activeClient.KeyMessage(method, key, character);
4559 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4561 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4562 // && defaultControl != activeChild)
4564 delete previousActive;
4565 previousActive = activeChild;
4566 if(previousActive) incref previousActive;
4568 ConsequentialMouseMove(false);
4569 if((defaultControl.active ||
4570 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4571 defaultControl.KeyMessage(method, defaultKey, character);
4577 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4579 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4586 ShowSysMenu(absPosition.x, absPosition.y);
4593 if(this != guiApp.desktop)
4595 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4597 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4599 MenuMoveOrSize(key.shift, true);
4603 else if(guiApp.windowMoving)
4605 guiApp.windowMoving.StopMoving();
4606 ConsequentialMouseMove(false);
4614 if(!destroyed && status && state != minimized)
4616 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4620 case tab: case shiftTab:
4622 Window cycleParent = this;
4623 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4624 cycleParent = master.parent;
4626 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4628 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4631 Window child = cycleParent.activeChild;
4633 // Scroll the window to include the active control
4634 if(cycleParent.sbh && !child.style.dontScrollHorz)
4636 if(child.scrolledPos.x < 0)
4637 cycleParent.sbh.Action(Position,
4638 cycleParent.scroll.x + child.scrolledPos.x, 0);
4639 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4640 cycleParent.sbh.Action(Position,
4641 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4643 if(cycleParent.sbv && !child.style.dontScrollVert)
4645 if(child.scrolledPos.y < 0)
4646 cycleParent.sbv.Action(Position,
4647 cycleParent.scroll.y + child.scrolledPos.y, 0);
4648 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4649 cycleParent.sbv.Action(Position,
4650 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4653 cycleParent.ConsequentialMouseMove(false);
4659 case f6: case shiftF6:
4660 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4662 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4663 if(parent == guiApp.desktop)
4664 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4674 if(CycleChildren(key.shift, true, false, true))
4682 // mIRC Style Window Shortcuts
4683 case alt1: case alt2: case alt3: case alt4: case alt5:
4684 case alt6: case alt7: case alt8: case alt9: case alt0:
4689 for(document = children.first; document; document = document.next)
4691 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4693 if(document == activeChild)
4695 if(document.state == minimized)
4696 document.SetState(normal, false, key);
4699 document.SetState(minimized, false, key);
4700 CycleChildren(false, true, false);
4705 if(activeChild.state == maximized && document.style.hasMaximize)
4706 document.SetState(maximized, false, key);
4707 else if(document.state == minimized)
4708 document.SetState(normal, false, key);
4709 document.Activate();
4724 if(!destroyed && status)
4726 if(state == minimized)
4731 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4733 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4735 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4736 previousActive.ActivateEx(true, false, false, true, null, null);
4737 delete previousActive;
4743 if(!destroyed && status)
4745 status = ProcessHotKeys(method, key, character);
4747 if(!destroyed && status && !modalWindow && state != minimized)
4750 status = KeyMethod(this, key, character);
4751 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4752 status = OnKeyHit(key, character);
4753 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4755 bool result = false;
4758 case ctrlUp: case ctrlDown:
4759 if(sbv && !guiApp.windowScrolling)
4760 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4762 case wheelUp: case wheelDown:
4763 if(sbv && !guiApp.windowScrolling)
4765 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4766 // Do we want to do a consequential move regardless of result in this case?
4767 ConsequentialMouseMove(false);
4770 case ctrlPageUp: case ctrlPageDown:
4771 if(sbh && !guiApp.windowScrolling)
4772 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4777 ConsequentialMouseMove(false);
4782 if(status && !destroyed && menuBar && state != minimized)
4783 status = menuBar.KeyMessage(method, key, character);
4785 if(style.interim && /*destroyed && */status && interimMaster)
4787 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4788 status = interimMaster.KeyMessage(method, key, character);
4795 bool ProcessHotKeys(uint method, Key key, unichar character)
4800 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4801 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4802 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4804 Window hotKeyWindow = hotKey.window;
4805 Window parent = hotKeyWindow.parent;
4806 Window prevActiveWindow = activeChild;
4807 // For when sys buttons are placed inside the menu bar
4808 if(parent && parent._class == class(PopupMenu))
4809 parent = parent.parent;
4811 // 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
4812 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4815 if(prevActiveWindow) incref prevActiveWindow;
4816 incref hotKeyWindow;
4817 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4818 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4821 delete hotKeyWindow;
4822 delete prevActiveWindow;
4826 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4827 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4828 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4830 // ********* WORKING ON THIS ***********
4831 if(prevActiveWindow && !guiApp.interimWindow)
4832 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4835 else if(hotKeyWindow.style.inactive)
4836 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4838 delete prevActiveWindow;
4839 delete hotKeyWindow;
4840 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4841 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4845 if(status && tabCycle)
4848 for(child = children.first; child; child = child.next)
4850 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4861 // --- Windows and graphics initialization / termination ---
4862 bool SetupRoot(void)
4866 // Setup relationship with outside world (bb root || !bb)
4867 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4868 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4872 tempExtents = new0 Extent[4];
4877 /*if(guiApp.fullScreenMode)
4878 rootWindow = guiApp.desktop;
4880 //rootWindow = parent.created ? parent.rootWindow : null;
4881 rootWindow = parent.rootWindow;
4884 against = &parent.box;
4886 against = &parent.clientArea;
4889 for(child = children.first; child; child = child.next)
4892 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4895 bool Setup(bool positionChildren)
4897 bool result = false;
4900 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4902 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4903 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4906 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4908 // This was here, is it really needed?
4909 //guiApp.interfaceDriver.ActivateRootWindow(this);
4913 displaySystem = DisplaySystem {};
4914 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4916 delete displaySystem;
4921 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4922 if(display.Create(displaySystem, windowHandle))
4929 // Sometimes icon does not show up on Windows XP if we set here...
4930 // guiApp.interfaceDriver.SetIcon(this, icon);
4932 else if(this != guiApp.desktop)
4934 display = rootWindow ? rootWindow.display : null;
4940 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4941 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4943 for(child = children.first; child; child = child.next)
4945 if(child.created && !child.Setup(false))
4948 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4949 child.UpdateCaption();
4954 bool SetupDisplay(void)
4956 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4957 if(is3D) return Window3D_SetupDisplay(this); else
4964 class_data void ** pureVTbl;
4966 bool LoadGraphics(bool creation, bool resetAnchors)
4968 bool result = false;
4969 bool success = false;
4971 WindowState stateBackup = state;
4973 if(((subclass(Window))_class).pureVTbl)
4975 if(_vTbl == _class._vTbl)
4977 _vTbl = ((subclass(Window))_class).pureVTbl;
4982 for(m = 0; m < _class.vTblSize; m++)
4984 if(_vTbl[m] == _class._vTbl[m])
4985 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4989 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4991 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4993 _vTbl = _class._vTbl;
4998 for(m = 0; m < _class.vTblSize; m++)
5000 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5001 _vTbl[m] = _class._vTbl[m];
5006 if(guiApp.fullScreenMode || this != guiApp.desktop)
5008 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5014 display.Lock(false);
5015 if(rootWindow == this)
5017 // Set Color Palette
5018 display.SetPalette(palette, true);
5022 if(guiApp.fullScreenMode && this == guiApp.desktop)
5027 for(c=0; c<SystemCursor::enumSize; c++)
5028 if(!guiApp.systemCursors[c].bitmap)
5030 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5031 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5032 if(guiApp.systemCursors[c].bitmapName)
5034 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5035 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5036 if(guiApp.systemCursors[c].bitmap)
5037 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5042 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5044 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5045 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5047 cursor.bitmap.paletteShades = cursor.paletteShades;
5051 guiApp.cursorUpdate = true;
5054 ConsequentialMouseMove(false);
5060 // Load Window Graphic Resources
5063 if(usedFont == setFont || usedFont == window.systemFont)
5064 RemoveResource(usedFont);
5067 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5070 RemoveResource(systemFont);
5073 RemoveResource(captionFont);
5075 for(ptr = resources.first; ptr; ptr = ptr.next)
5077 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5078 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5081 AddResource(setFont);
5083 AddResource(systemFont);
5085 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5092 //if(master && master.font)
5093 if(parent && parent.font)
5097 faceName = parent.font.faceName,
5098 size = parent.font.size,
5099 bold = parent.font.bold,
5100 italic = parent.font.italic,
5101 underline = parent.font.underline
5103 //font = parent.font;
5104 watch(parent) { font { } };
5107 font = guiApp.currentSkin.SystemFont();
5114 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5115 AddResource(captionFont);
5117 if(OnLoadGraphics())
5123 //SetScrollLineStep(sbStep.x, sbStep.y);
5125 if(this != guiApp.desktop)
5129 normalAnchor = anchor;
5130 normalSizeAnchor = sizeAnchor;
5133 // Break the anchors for moveable/resizable windows
5135 if(style.fixed && style.isDocument)
5137 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5149 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5150 stateSizeAnchor = SizeAnchor {};
5155 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5160 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5161 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5164 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5168 stateAnchor = normalAnchor;
5169 stateSizeAnchor = normalSizeAnchor;
5172 position = Point { };
5173 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5184 if(Position(x, y, w, h, true, false, true, true, true, true))
5186 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5189 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5206 success = result = true;
5209 if(!creation && result)
5211 // Load menu bar first because sys buttons are on it...
5214 if(!menuBar.LoadGraphics(false, resetAnchors))
5220 for(child = children.first; child; child = child.next)
5222 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5229 CreateSystemChildren();
5233 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5236 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5239 LogErrorCode(graphicsLoadingFailed, _class.name);
5241 // Do this here to avoid problems on Windows
5242 if(rootWindow == this && parent && stateBackup == maximized)
5243 property::state = maximized;
5247 void UnloadGraphics(bool destroyWindows)
5251 // Free children's graphics
5252 for(child = children.first; child; child = child.next)
5253 child.UnloadGraphics(destroyWindows);
5256 display.Lock(false);
5259 if(guiApp.fullScreenMode && this == guiApp.desktop)
5264 for(c=0; c<SystemCursor::enumSize; c++)
5265 if(guiApp.systemCursors[c].bitmap)
5266 delete guiApp.systemCursors[c].bitmap;
5268 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5269 delete cursor.bitmap;
5271 guiApp.cursorBackground.Free();
5274 if(display && display.displaySystem)
5278 for(ptr = resources.first; ptr; ptr = ptr.next)
5282 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5287 // Free window graphics
5290 // Free skin graphics
5291 if(rootWindow == this)
5293 DisplaySystem displaySystem = display.displaySystem;
5296 display.driverData = null;
5297 display.displaySystem = null;
5301 if(displaySystem && !displaySystem.numDisplays && !is3D)
5302 delete displaySystem;
5311 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5312 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5314 if(this == guiApp.desktop || parent == guiApp.desktop)
5316 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5317 guiApp.interfaceDriver.DestroyRootWindow(this);
5321 // --- Window Hiding ---
5323 void SetVisibility(bool state)
5325 bool visible = (style.hidden || !created) ? false : state;
5326 if(visible != this.visible)
5330 this.visible = visible;
5331 for(child = children.first; child; child = child.next)
5332 child.SetVisibility(visible);
5334 ConsequentialMouseMove(false);
5335 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5339 // --- Windows and graphics initialization / termination ---
5341 bool DisplayModeChanged(void)
5343 bool result = false;
5344 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5346 guiApp.modeSwitching = true;
5347 UnloadGraphics(false);
5349 if(LoadGraphics(false, false))
5351 guiApp.modeSwitching = false;
5356 // --- Window updates system ---
5358 void UpdateDirty(Box updateBox)
5360 if(!manageDisplay) { OnRedraw(null);return; }
5363 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5366 if(display.flags.flipping)
5369 rootWindow.UpdateDisplay();
5372 UpdateBackDisplay(updateBox);
5374 if(guiApp.fullScreenMode)
5376 guiApp.cursorUpdate = true;
5377 guiApp.PreserveAndDrawCursor();
5379 if(guiApp.fullScreenMode)
5380 guiApp.RestoreCursorBackground();
5386 // This function is strictly called as a result of system window activation
5387 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5390 Window interimMaster = null;
5391 Window interimWindow = guiApp.interimWindow;
5392 if(interimWindow && interimWindow.master)
5393 interimMaster = interimWindow.master.rootWindow;
5395 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5396 // SetState(normal, false, 0);
5397 SetState(lastState, false, 0);
5399 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5403 /* WTH is this doing here?
5404 while(swap && swap.activeChild)
5406 swap = swap.activeChild;
5409 // TESTING THIS BEFORE...
5410 if(interimWindow && this == interimMaster)
5414 // Window interimSwap = this;
5415 Window menuBar = this.menuBar;
5416 if(menuBar && interimWindow.master == menuBar)
5419 while(interimSwap && interimSwap.activeChild)
5420 interimSwap = interimSwap.activeChild;
5422 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5423 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5425 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5426 //result = ActivateEx(true, true, false, activateRoot, window, null);
5431 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5432 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5434 if(interimWindow == this && interimMaster && !active)
5436 while(interimMaster && interimMaster.interim && interimMaster.master)
5438 // printf("Going up one master %s\n", interimMaster._class.name);
5439 interimMaster = interimMaster.master.rootWindow;
5441 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5442 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5448 bool DestroyEx(int64 returnCode)
5451 Timer timer, nextTimer;
5453 OldLink prevOrder = null;
5454 Window client = null;
5456 if(parent) stopwatching(parent, font);
5458 // if(window.modalSlave) return false;
5459 if(destroyed || !created)
5466 OldLink slave = master.slaves.FindLink(this);
5467 master.slaves.Delete(slave);
5470 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5476 this.returnCode = (DialogResult)returnCode;
5478 AcquireInput(false);
5483 master.hotKeys.Delete(hotKey);
5487 if(guiApp.prevWindow == this)
5489 guiApp.prevWindow = null;
5494 for(w : guiApp.overWindows; w == this)
5497 guiApp.overWindows.TakeOut(w);
5501 if(guiApp.caretOwner == this)
5503 guiApp.interfaceDriver.SetCaret(0,0,0);
5504 UpdateCaret(false, true);
5505 guiApp.caretEnabled = false;
5510 parent.childrenCycle.Remove(cycle);
5514 OldLink tmpPrev = order.prev;
5515 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5516 prevOrder = tmpPrev;
5519 client = tmpPrev ? tmpPrev.data : null;
5520 if(client == this) { client = null; break; }
5521 if(client && (client.style.hidden || client.destroyed || !client.created))
5522 tmpPrev = client.order.prev;
5526 prevOrder = tmpPrev;
5531 // If this window can be an active client, make sure the next window we activate can also be one
5532 if(!style.nonClient && style.isActiveClient)
5534 tmpPrev = prevOrder;
5537 client = tmpPrev ? tmpPrev.data : null;
5538 if(client == this) { client = null; break; }
5539 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5540 tmpPrev = client.order.prev;
5544 prevOrder = tmpPrev;
5548 if(client && client.style.hidden) client = null;
5550 // parent.childrenOrder.Remove(order);
5553 if(parent && style.isActiveClient && visible)
5555 if(state == minimized) parent.numIcons--;
5556 parent.numPositions--;
5559 // TESTING THIS HERE!
5563 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5564 // to create a window inside a rootwindow that's being destroyed)
5565 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5567 if(master && !master.destroyed /*&&
5568 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5570 if(master.defaultControl == this)
5571 master.defaultControl = null;
5574 parent.OnChildAddedOrRemoved(this, true);
5575 if(parent && !parent.destroyed /*&&
5576 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5578 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5580 if(order && prevOrder && prevOrder.data != this && active)
5582 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5584 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5585 if(parent.activeClient == this)
5587 parent.activeClient = null;
5588 parent.UpdateActiveDocument(null);
5593 if(guiApp.interimWindow == this)
5596 PropagateActive(false, null, &goOn, true);
5600 //if(window.parent.activeChild == window)
5601 parent.activeChild = null;
5602 if(!style.nonClient /*&& style.isActiveClient*/)
5604 Window previous = parent.activeClient;
5605 if(style.isActiveClient)
5606 parent.activeClient = null;
5607 parent.UpdateActiveDocument(previous);
5612 else if(parent.activeClient == this)
5614 parent.activeClient = client;
5615 parent.UpdateActiveDocument(this);
5619 if(guiApp.interimWindow == this)
5621 guiApp.interimWindow = null;
5622 if(guiApp.caretOwner)
5624 Window desktop = guiApp.desktop;
5625 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5626 guiApp.caretOwner.UpdateCaret(false, false);
5631 if(_isModal && master && master.modalSlave == this)
5632 master.modalSlave = null;
5636 if(!guiApp.caretOwner && parent.caretSize)
5638 guiApp.caretOwner = parent;
5639 parent.UpdateCaret(false, false);
5640 parent.Update(null);
5643 // Why was this commented out?
5644 GetRidOfVirtualArea();
5650 dirtyArea.Free(null);
5651 dirtyBack.Free(null);
5652 scrollExtent.Free(null);
5654 /* ATTEMPTING TO MOVE THAT ABOVE
5663 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5664 for(;(child = window.children.first);)
5666 for(; child && (child.destroyed || !child.created); child = child.next);
5675 UnloadGraphics(true);
5678 delete previousActive;
5681 // statusBar = null;
5684 if(master && !master.destroyed)
5686 //master.NotifyDestroyed(this, this.returnCode);
5687 NotifyDestroyed(master, this, this.returnCode);
5690 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5692 nextTimer = timer.next;
5693 if(timer.window == this)
5695 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5696 // timer.window = null;
5702 if(this == guiApp.windowMoving)
5705 if(guiApp.windowCaptured == this)
5707 //guiApp.windowCaptured = null;
5709 if(rootWindow != this && rootWindow)
5710 rootWindow.ConsequentialMouseMove(false);
5718 //for(child = children.first; next = child ? child.next : null, child; child = next)
5719 for(;(child = children.first); )
5721 for(; child && (child.destroyed || !child.created); child = child.next);
5731 /* // MOVED THIS UP...
5734 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5735 for(;(child = window.children.first); )
5737 for(; child && (child.destroyed || !child.created); child = child.next);
5746 while((slave = slaves.first))
5748 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5750 ((Window)slave.data).DestroyEx(0);
5755 if(guiApp.caretOwner == this)
5756 guiApp.caretOwner = null;
5758 sysButtons[0] = null;
5759 sysButtons[1] = null;
5760 sysButtons[2] = null;
5763 if(rootWindow != this)
5765 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5768 box.left -= parent.clientStart.x;
5769 box.top -= parent.clientStart.y;
5770 box.right -= parent.clientStart.x;
5771 box.bottom -= parent.clientStart.y;
5773 if(parent) parent.Update(box);
5778 OldLink slave = master.slaves.FindVoid(this);
5779 master.slaves.Delete(slave);
5785 parent.children.Remove(this);
5790 //autoCreate = false;
5793 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5794 if(((subclass(Window))_class).pureVTbl)
5796 if(_vTbl == _class._vTbl)
5798 _vTbl = ((subclass(Window))_class).pureVTbl;
5803 for(m = 0; m < _class.vTblSize; m++)
5805 if(_vTbl[m] == _class._vTbl[m])
5806 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5815 void SetStateEx(WindowState newState, bool activate)
5818 WindowState prevState = state;
5822 if(prevState != newState)
5823 lastState = prevState;
5825 if(rootWindow != this || !nativeDecorations || !windowHandle)
5827 if(style.isActiveClient && !style.hidden && prevState == minimized)
5830 // This block used to be at the end of the function... moved it for flicker problem in X
5831 // ------------------------------------------------------
5835 stateAnchor = normalAnchor;
5836 stateSizeAnchor = normalSizeAnchor;
5839 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5840 stateSizeAnchor = SizeAnchor {};
5846 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5849 byte * idBuffer = new0 byte[size];
5851 for(child = parent.children.first; child; child = child.next)
5853 if(child != this && child.state == minimized)
5855 if(child.iconID > size - 2)
5857 idBuffer = renew0 idBuffer byte[size*2];
5858 memset(idBuffer + size, 0, size);
5861 idBuffer[child.iconID] = (byte)bool::true;
5864 for(c = 0; c<size; c++)
5869 if(style.isActiveClient && !style.hidden)
5872 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5873 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5878 // TOCHECK: Why was this here?
5879 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5880 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5881 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5883 if(state != minimized || hasMinimize)
5884 Position(x, y, w, h, true, true, true, true, false, true);
5886 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5887 parent.UpdateActiveDocument(null);
5890 if(state != minimized || hasMinimize)
5891 CreateSystemChildren();
5892 // ------------------------------------------------------
5895 int GetPositionID(Window forChild)
5899 byte * idBuffer = new0 byte[size];
5902 for(child = children.first; child; child = child.next)
5904 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5906 if(child.positionID > size - 2)
5908 idBuffer = renew0 idBuffer byte[size*2];
5909 memset(idBuffer + size, 0, size);
5912 idBuffer[child.positionID] = (byte)bool::true;
5915 for(c = 0; c<size; c++)
5922 // --- Window related graphics ---
5924 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5926 palette = newPalette;
5927 if(rootWindow.display)
5928 rootWindow.display.SetPalette(palette, colorMatch);
5931 public bool AcquireInput(bool acquired)
5934 if(acquiredInput != acquired)
5936 if(active || (!visible && creationActivation == activate))
5937 result = AcquireInputEx(acquired);
5942 acquiredInput = acquired ? result : !result;
5947 void ListChildren(ListBox listBox)
5951 for(child = children.first; child; child = child.next)
5953 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5955 DataRow row = listBox.AddRow();
5956 row.tag = (int64)(intptr)child;
5957 child.FigureCaption(caption);
5958 row.SetData(null, caption);
5963 void UpdateVisual(Box extent)
5965 if(guiApp.driver != null)
5967 if(guiApp.fullScreenMode && guiApp.desktop.display)
5969 guiApp.desktop.mutex.Wait();
5970 guiApp.desktop.display.Lock(true);
5973 if(guiApp.desktop.active)
5975 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5977 if(guiApp.desktop.display.flags.flipping)
5978 guiApp.desktop.Update(null);
5979 guiApp.desktop.UpdateDisplay();
5980 guiApp.cursorUpdate = true;
5982 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5984 guiApp.PreserveAndDrawCursor();
5985 // guiApp.desktop.display.ShowScreen();
5986 guiApp.cursorUpdate = false;
5987 guiApp.desktop.dirty = false;
5988 guiApp.RestoreCursorBackground();
5992 guiApp.desktop.display.Unlock();
5993 guiApp.desktop.mutex.Release();
5997 Window rootWindow = this.rootWindow;
5998 rootWindow.mutex.Wait();
6003 guiApp.SignalEvent();
6006 guiApp.waitMutex.Wait();
6007 guiApp.interfaceDriver.Lock(rootWindow);
6008 if(!rootWindow.style.hidden && rootWindow.dirty)
6010 if(rootWindow.display)
6012 rootWindow.UpdateDisplay();
6013 //rootWindow.display.ShowScreen(null);
6015 rootWindow.dirty = false;
6017 guiApp.interfaceDriver.Unlock(rootWindow);
6018 guiApp.waitMutex.Release();
6021 rootWindow.mutex.Release();
6026 void UnlockDisplay(void)
6028 guiApp.interfaceDriver.Unlock(rootWindow);
6031 void LockDisplay(void)
6033 guiApp.interfaceDriver.Lock(rootWindow);
6036 Surface GetSurface(Box box)
6038 return Redraw((box == null) ? this.box : box);
6041 void SetMousePosition(int x, int y)
6043 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6047 void IntegrationActivate(bool active)
6049 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6051 isForegroundWindow = true;
6052 ActivateEx(active, active, false, false, null, null);
6053 isForegroundWindow = false;
6058 Window QueryCapture(void)
6060 return guiApp.windowCaptured;
6063 int GetDocumentID(void)
6067 byte * idBuffer = new0 byte[size];
6070 for(child = children.first; child; child = child.next)
6072 // TO CHECK: Do we want a documentID when we already have a file name?
6073 if(child.style.isDocument && !child.fileName)
6075 if(child.documentID-1 > size - 2)
6077 idBuffer = renew0 idBuffer byte[size*2];
6078 memset(idBuffer + size, 0, size);
6081 idBuffer[child.documentID-1] = 1;
6084 for(c = 0; c<size; c++)
6092 void SetInitSize(Size size)
6095 sizeAnchor.size = size;
6096 normalSizeAnchor = sizeAnchor;
6098 // Break the anchors for moveable/resizable windows
6099 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6101 stateAnchor = normalAnchor;
6102 stateSizeAnchor = normalSizeAnchor;
6104 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6105 Position(x,y, w, h, true, true, true, true, false, true);
6109 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6111 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6113 guiApp.windowIsResizing = resize;
6114 guiApp.windowMoving = this;
6115 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6116 if(guiApp.windowIsResizing)
6118 guiApp.windowMovingStart.x += size.w - 1;
6119 guiApp.windowMovingStart.y += size.h - 1;
6121 guiApp.windowMovingBefore = scrolledPos;
6122 guiApp.windowResizingBefore = size;
6123 guiApp.windowMoving.UpdateDecorations();
6124 if(guiApp.windowIsResizing)
6125 guiApp.resizeEndX = guiApp.resizeEndY = true;
6127 if(setCursorPosition)
6128 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6132 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6133 guiApp.windowMovingStart.x += x - absPosition.x;
6134 guiApp.windowMovingStart.y += y - absPosition.y;
6137 if(guiApp.windowMoving)
6139 if(guiApp.windowMoving.style.nonClient)
6140 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6142 guiApp.windowMoving.parent.SetMouseRangeToClient();
6147 if(this == rootWindow)
6148 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6152 void SetupFileMonitor()
6156 fileMonitor = FileMonitor
6158 this, FileChange { modified = true };
6160 bool OnFileNotify(FileChange action, const char * param)
6163 fileMonitor.StopMonitoring();
6164 if(OnFileModified(action, param))
6165 fileMonitor.StartMonitoring();
6178 bool result = false;
6182 else if(guiApp && guiApp.driver != null)
6184 OldLink slaveHolder;
6186 bool visible = !style.hidden;
6190 systemParent = parent;
6191 parent = guiApp.desktop;
6193 last = parent ? parent.children.last : null;
6195 if((parent && parent != guiApp.desktop && !parent.created) ||
6196 (master && master != guiApp.desktop && !master.created))
6200 stopwatching(parent, font);
6203 property::parent = guiApp.desktop;
6204 if(!master) master = parent;
6206 if(_isModal && master.modalSlave)
6207 property::master = master.modalSlave;
6211 parent.children.Remove(this);
6214 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6215 if(slaveHolder.data == this)
6217 master.slaves.Delete(slaveHolder);
6222 if(parent == guiApp.desktop && !mutex)
6225 if(style.isDocument)
6228 parent.numDocuments--;
6229 documentID = parent.GetDocumentID();
6232 if(!style.stayOnTop)
6233 for(; last && last.style.stayOnTop; last = last.prev);
6235 parent.children.Insert((last == this) ? null : last, this);
6236 //parent.children.Add(this);
6239 dispDriver = parent.dispDriver;
6242 master.modalSlave = this;
6244 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6249 master.slaves.Add(slaveHolder = OldLink { data = this });
6254 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6256 if(style.isDefault && !master.defaultControl)
6257 master.defaultControl = this;
6259 stateAnchor = normalAnchor = anchor;
6260 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6262 // TOCHECK: Why is this here?
6263 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6264 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6266 this.visible = false;
6267 style.hidden = true;
6270 // autoCreate = true;
6278 if(parent == guiApp.desktop)
6279 Log("LoadGraphics %s\n", caption);
6281 if(LoadGraphics(true, false))
6289 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6296 if(style.hasMenuBar /*&& menu*/)
6302 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6303 interim = false, inactive = true, nonClient = true, size.h = 24
6311 // Create the system buttons
6312 CreateSystemChildren();
6314 UpdateActiveDocument(null);
6316 if(style.isDocument)
6320 MenuItem item = menu.FindItem(MenuFileSave, 0);
6321 if(item) item.disabled = !modifiedDocument && fileName;
6326 if(parent == guiApp.desktop)
6327 Log("Preemptive SetState %s\n", caption);
6330 // Preemptive Set State to ensure proper anchoring
6331 SetStateEx(state, false);
6333 style.hidden = true;
6339 for(child = children.first; child; child = next)
6342 if(!child.created && (child.autoCreate || child.wasCreated))
6349 for(link = slaves.first; link; link = next)
6351 Window slave = link.data;
6353 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6356 // Things might have happened that invalidated 'next'...
6357 // Start over the search for slaves to create.
6358 // (Added this to fix crash with Stacker & Toolbar)
6359 next = slaves.first;
6368 if(parent == guiApp.desktop)
6369 Log("Real SetState %s\n", caption);
6372 if(isActiveClient && visible)
6374 parent.numPositions--;
6375 if(state == minimized) parent.numIcons--;
6378 parent.OnChildAddedOrRemoved(this, false);
6380 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6382 // Real set state & activate for proper display & activation
6383 property::visible = visible;
6384 // SetState(state & 0x00000003, true, 0);
6385 guiApp.interfaceDriver.SetIcon(this, icon);
6390 /*if(rootWindow == this)
6391 guiApp.interfaceDriver.ActivateRootWindow(this);
6393 if(creationActivation == activate && guiApp.desktop.active)
6394 ActivateEx(true, false, true, true, null, null);
6395 else if(creationActivation == activate || creationActivation == flash)
6398 if(this == rootWindow)
6404 rootWindow.ConsequentialMouseMove(false);
6415 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6421 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6423 //style.hidden = true; // !visible;
6424 style.hidden = !visible;
6425 if(master.modalSlave == this)
6426 master.modalSlave = null;
6433 void WriteCaption(Surface surface, int x, int y)
6436 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6439 void Update(Box region)
6445 rootWindow = this.rootWindow;
6447 // rootWindow.mutex.Wait();
6448 if(!destroyed && visible && display)
6453 // Testing this to avoid repetitve full update to take time...
6454 if(rootWindow.fullRender)
6456 rootWindow.dirty = true;
6459 if(dirtyArea.count == 1)
6461 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6462 if(item.box.left <= box.left &&
6463 item.box.top <= box.top &&
6464 item.box.right >= box.right &&
6465 item.box.bottom >= box.bottom)
6467 rootWindow.dirty = true;
6472 if(display.flags.flipping && !rootWindow.dirty)
6474 if(this == rootWindow)
6478 rootWindow.Update(null);
6483 rootWindow.dirty = true;
6488 realBox.left += clientStart.x;
6489 realBox.top += clientStart.y;
6490 realBox.right += clientStart.x;
6491 realBox.bottom += clientStart.y;
6497 if(realBox.right >= realBox.left &&
6498 realBox.bottom >= realBox.top)
6500 // if(!rootWindow.fullRender)
6501 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6503 for(child = children.first; child; child = child.next)
6508 box.left -= child.absPosition.x - absPosition.x;
6509 box.top -= child.absPosition.y - absPosition.y;
6510 box.right -= child.absPosition.x - absPosition.x;
6511 box.bottom -= child.absPosition.y - absPosition.y;
6512 if(box.right >= child.box.left && box.left <= child.box.right &&
6513 box.bottom >= child.box.top && box.top <= child.box.bottom)
6515 box.left -= child.clientStart.x;
6516 box.top -= child.clientStart.y;
6517 box.right -= child.clientStart.x;
6518 box.bottom -= child.clientStart.y;
6524 realBox.left += absPosition.x - rootWindow.absPosition.x;
6525 realBox.top += absPosition.y - rootWindow.absPosition.y;
6526 realBox.right += absPosition.x - rootWindow.absPosition.x;
6527 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6528 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6531 else if(this == guiApp.desktop)
6534 for(window = children.first; window; window = window.next)
6540 Box childBox = region;
6542 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6543 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6544 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6545 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6547 window.Update(childBox);
6550 window.Update(null);
6555 // rootWindow.mutex.Release();
6562 if(guiApp.windowCaptured != this)
6564 if(guiApp.windowCaptured)
6568 //Logf("Captured %s (%s)\n", caption, class.name);
6569 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6570 guiApp.windowCaptured = this;
6576 bool Destroy(int64 code)
6581 if(!destroyed && !CloseConfirmation(false)) return false;
6585 // TOCHECK: Should autoCreate be set to false here?
6596 void Move(int x, int y, int w, int h)
6598 normalAnchor = Anchor { left = x, top = y };
6599 normalSizeAnchor = SizeAnchor { size = { w, h } };
6601 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6603 if(destroyed) return;
6605 stateAnchor = normalAnchor;
6606 stateSizeAnchor = normalSizeAnchor;
6608 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6609 Position(x,y, w, h, true, true, true, true, false, true);
6613 DialogResult Modal(void)
6619 // FIXES MEMORY LEAK IF Create() FAILED
6625 void SetScrollArea(int width, int height, bool snapToStep)
6629 int stepX = sbStep.x, stepY = sbStep.y;
6630 // Needed to make snapped down position match the skin's check of client area
6631 // against realvirtual
6634 SNAPDOWN(stepX, textCellW);
6635 SNAPDOWN(stepY, textCellH);
6636 stepX = Max(stepX, textCellW);
6637 stepY = Max(stepY, textCellH);
6639 if(scrollFlags.snapX)
6640 SNAPUP(width, stepX);
6641 if(scrollFlags.snapY)
6642 SNAPUP(height, stepY);
6645 reqScrollArea.w = width;
6646 reqScrollArea.h = height;
6647 noAutoScrollArea = (width > 0 || height > 0);
6649 UpdateScrollBars(true, true);
6652 void SetScrollPosition(int x, int y)
6655 sbh.Action(setPosition, x, 0);
6659 int seen = clientSize.w, total = reqScrollArea.w;
6661 if(scrollFlags.snapX)
6662 SNAPDOWN(seen, sbStep.x);
6664 if(!total) total = seen;
6665 range = total - seen + 1;
6666 range = Max(range, 1);
6668 if(x >= range) x = range - 1;
6670 if(scrollFlags.snapX)
6671 SNAPUP(x, sbStep.x);
6674 OnHScroll(setPosition, x, 0);
6678 SNAPDOWN(x, textCellW);
6684 sbv.Action(setPosition, y, 0);
6688 int seen = clientSize.h, total = reqScrollArea.h;
6691 if(scrollFlags.snapY)
6692 SNAPDOWN(seen, sbStep.y);
6694 if(!total) total = seen;
6695 range = total - seen + 1;
6696 range = Max(range, 1);
6698 if(y >= range) y = range - 1;
6700 if(scrollFlags.snapY)
6701 SNAPUP(y, sbStep.y);
6704 OnVScroll(setPosition, y, 0);
6707 SNAPDOWN(y, textCellH);
6712 UpdateCaret(false, false);
6715 void SetScrollLineStep(int stepX, int stepY)
6721 SNAPDOWN(stepX, textCellW);
6722 SNAPDOWN(stepY, textCellH);
6723 stepX = Max(stepX, textCellW);
6724 stepY = Max(stepY, textCellH);
6727 sbh.lineStep = stepX;
6729 sbv.lineStep = stepY;
6732 void SetState(WindowState newState, bool activate, Modifiers mods)
6736 if(state == newState || OnStateChange(newState, mods))
6738 //WindowState prevState = state;
6742 // This used to be at the end of the brackets... moved for X, testing...
6743 // This has the effect of activating the window through the system...
6744 if(rootWindow == this)
6745 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6747 SetStateEx(newState, activate);
6749 if(rootWindow == this && !rootWindow.nativeDecorations)
6751 int x = position.x, y = position.y;
6754 x -= guiApp.desktop.absPosition.x;
6755 y -= guiApp.desktop.absPosition.y;
6757 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6761 //state = prevState;
6763 if(state != maximized && style.hasMaximize)
6766 for(child = parent.children.first; child; child = child.next)
6768 if(child != this && child.state == maximized)
6769 child.SetStateEx(normal, false);
6773 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6774 parent.UpdateScrollBars(true, true);
6777 // Do we really need this stuff here?
6778 // Shouldn't the Activate stuff take care of it?
6779 if(parent.rootWindow == parent && style)
6782 parent.FigureCaption(caption);
6783 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6784 parent.UpdateDecorations();
6788 rootWindow.ConsequentialMouseMove(false);
6795 BitmapResource GetIcon(SkinBitmap iconID)
6797 return guiApp.currentSkin.GetBitmap(iconID);
6800 void SetMouseRange(Box range)
6802 if(range || guiApp.fullScreenMode)
6807 clip.left = range.left + absPosition.x + clientStart.x;
6808 clip.top = range.top + absPosition.y + clientStart.y;
6809 clip.right = range.right + absPosition.x + clientStart.x;
6810 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6814 clip.left = guiApp.desktop.box.left;
6815 clip.top = guiApp.desktop.box.top;
6816 clip.right = guiApp.desktop.box.right;
6817 clip.bottom = guiApp.desktop.box.bottom;
6819 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6822 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6825 void SetMouseRangeToClient(void)
6827 if(guiApp.fullScreenMode || this != guiApp.desktop)
6829 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6830 box.Clip(clientArea);
6834 SetMouseRange(null);
6837 void SetMouseRangeToWindow(void)
6839 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6840 if(this == guiApp.desktop)
6841 SetMouseRangeToClient();
6846 // x, y: Desktop Coordinates
6847 void ShowSysMenu(int x, int y)
6850 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6853 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6854 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6858 menu, $"Move", m, NotifySelect = MenuWindowMove,
6859 disabled = !style.fixed || state == maximized
6863 menu, $"Size", s, NotifySelect = MenuWindowSize,
6864 disabled = !style.sizable || state != normal
6868 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6869 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6873 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6874 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6878 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6879 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6881 MenuDivider { menu };
6884 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6885 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6887 windowMenu.Create();
6892 ActivateEx(true, true, true, true, null, null);
6895 void MakeActive(void)
6897 ActivateEx(true, false, true, false, null, null);
6900 void SoftActivate(void)
6902 if(guiApp.desktop.active)
6907 if(this == rootWindow)
6912 void Deactivate(void)
6914 ActivateEx(false, true, true, true, null, null);
6919 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6922 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6924 bool result = false;
6925 if(activeChild && activeChild.cycle)
6927 Window modalWindow, child = activeChild;
6928 if(!clientOnly /*&& parent.tabCycle*/)
6930 Window next = child;
6933 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6937 if(parent && parent.CycleChildren(backward, false, true, true))
6945 next = next.cycle.prev.data;
6947 next = next.cycle.next.data;
6948 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6953 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6954 parent.tabCycle && parent.CycleChildren(backward, false, false))
6958 if(tabCycleOnly && !tabCycle) return false;
6965 child = child.cycle.prev.data;
6967 child = child.cycle.next.data;
6968 if(child == child.parent.activeChild)
6970 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6973 modalWindow = child.FindModal();
6976 // Scroll the window to include the active control
6977 if(sbh && !child.style.dontScrollHorz)
6979 if(child.scrolledPos.x < 0)
6980 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6981 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6982 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6984 if(sbv && !child.style.dontScrollVert)
6986 if(child.scrolledPos.y < 0)
6987 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6988 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6989 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6993 child = modalWindow ? modalWindow : child;
6994 child.ActivateEx(true, true, true, true, null, null);
6995 if(child.tabCycle && child.childrenCycle.first)
6996 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7004 ConsequentialMouseMove(false);
7008 void AddResource(Resource resource)
7012 ResPtr ptr { resource = resource };
7016 // Load Graphics here if window is created already
7017 if(/*created && */display)
7019 display.Lock(false);
7020 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7021 ptr.loaded = display.displaySystem.LoadResource(resource);
7025 // Temporary hack to load font right away for listbox in dropbox ...
7026 else if(master && master.display)
7028 master.display.Lock(false);
7029 master.display.displaySystem.LoadResource(resource);
7030 master.display.Unlock();
7036 void RemoveResource(Resource resource)
7041 for(ptr = resources.first; ptr; ptr = ptr.next)
7043 if(ptr.resource == resource)
7049 // Unload Graphics here if window is created already
7050 if(/*created && */display)
7054 display.Lock(false);
7055 display.displaySystem.UnloadResource(resource, ptr.loaded);
7061 resources.Delete(ptr);
7066 void SetCaret(int x, int y, int size)
7073 if(active && !style.interim && isEnabled)
7075 if(visible || !guiApp.caretOwner)
7076 guiApp.caretOwner = size ? this : null;
7078 UpdateCaret(false, false);
7081 guiApp.interfaceDriver.SetCaret(0,0,0);
7082 UpdateCaret(false, true);
7083 guiApp.caretEnabled = false;
7086 else if(style.inactive && active)
7088 guiApp.interfaceDriver.SetCaret(0,0,0);
7089 UpdateCaret(false, true);
7090 guiApp.caretEnabled = false;
7095 void Scroll(int x, int y)
7097 bool opaque = !style.drawBehind || background.a;
7098 if(opaque && display && display.flags.scrolling)
7100 Box box = clientArea;
7101 box.left += clientStart.x;
7102 box.top += clientStart.y;
7103 box.right += clientStart.x;
7104 box.bottom += clientStart.y;
7106 //scrollExtent.Free(null);
7107 scrollExtent.AddBox(box);
7108 scrolledArea.x += x;
7109 scrolledArea.y += y;
7111 //scrollExtent.Free();
7112 //scrollExtent.AddBox(clientArea);
7113 //scrollExtent.Offset(clientStart.x, clientStart.y);
7114 //scrolledArea.x = x;
7115 //scrolledArea.y = y;
7121 rootWindow.dirty = true;
7124 void ReleaseCapture()
7126 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7128 Window oldCaptured = guiApp.windowCaptured;
7129 guiApp.windowCaptured = null;
7130 guiApp.prevWindow = null;
7133 //guiApp.Log("Released Capture\n");
7135 guiApp.interfaceDriver.SetMouseCapture(null);
7137 //oldCaptured.OnMouseCaptureLost();
7140 oldCaptured.ConsequentialMouseMove(false);
7145 private void _SetCaption(const char * format, va_list args)
7152 char caption[MAX_F_STRING];
7153 vsnprintf(caption, sizeof(caption), format, args);
7154 caption[sizeof(caption)-1] = 0;
7156 this.caption = CopyString(caption);
7161 firewatchers caption;
7165 /*deprecated*/ void SetText(const char * format, ...)
7168 va_start(args, format);
7169 _SetCaption(format, args);
7173 void SetCaption(const char * format, ...)
7176 va_start(args, format);
7177 _SetCaption(format, args);
7181 bool Grab(Bitmap bitmap, Box box, bool decorations)
7183 bool result = false;
7184 if(display || this == guiApp.desktop)
7186 Box clip = {MININT, MININT, MAXINT, MAXINT};
7192 clip.Clip(clientArea);
7194 clip.Clip(this.box);
7196 if(rootWindow != this)
7198 clip.left += absPosition.y;
7199 clip.top += absPosition.y;
7200 clip.right += absPosition.x;
7201 clip.bottom += absPosition.y;
7204 clip.left += decorations ? 0 : clientStart.x;
7205 clip.top += decorations ? 0 : clientStart.y;
7206 clip.right += decorations ? 0 : clientStart.x;
7207 clip.bottom += decorations ? 0 : clientStart.y;
7209 if(display && display.flags.flipping)
7211 rootWindow.Update(null);
7212 rootWindow.UpdateDisplay();
7219 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7220 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7224 result = display.Grab(bitmap, clip.left, clip.top,
7225 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7227 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7229 if(!bitmap.Convert(null, pixelFormat888, null))
7236 void GetMousePosition(int * x, int * y)
7238 int mouseX = 0, mouseY = 0;
7239 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7242 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7243 if(this != guiApp.desktop)
7245 mouseX -= absPosition.x + clientStart.x;
7246 mouseY -= absPosition.y + clientStart.y;
7253 DialogResult DoModal()
7255 DialogResult returnCode = 0;
7256 int terminated = terminateX;
7259 while(!destroyed && guiApp.driver != null)
7261 if(terminateX != terminated)
7263 terminated = terminateX;
7264 guiApp.desktop.Destroy(0);
7265 if(guiApp.desktop.created)
7268 //printf("Resetting terminate X to 0\n");
7274 guiApp.UpdateDisplay();
7275 if(!guiApp.ProcessInput(false))
7278 returnCode = this.returnCode;
7291 return !destroyed && guiApp.driver != null && terminateX < 2;
7294 DialogResult DoModalEnd()
7296 DialogResult returnCode = this.returnCode;
7301 // --- Window manipulation ---
7302 /*bool GetDisabled()
7304 bool disabled = this.disabled;
7306 for(window = this; (window = window.master); )
7317 // --- Mouse Manipulation ---
7318 void GetNCMousePosition(int * x, int * y)
7320 GetMousePosition(x, y);
7321 if(x) *x += clientStart.x;
7322 if(y) *y += clientStart.y;
7325 // --- Carets manipulation ---
7326 void GetCaretPosition(Point caretPos)
7328 caretPos = this.caretPos;
7331 int GetCaretSize(void)
7336 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7342 bool CloseConfirmation(bool parentClosing)
7355 if(!OnClose(parentClosing))
7358 // If you want to skip this, simply set modifiedDocument to false in OnClose
7359 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7361 DialogResult dialogRes;
7364 sprintf(message, $"Save changes to %s?", fileName);
7366 sprintf(message, $"Save changes to Untitled %d?", documentID);
7368 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7370 if(dialogRes == yes)
7372 // TOFIX: Precomp error if brackets are taken out
7373 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7375 else if(dialogRes == cancel)
7381 for(slave = slaves.first; slave; slave = slave.next)
7383 Window w = slave.data;
7384 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7392 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7395 for(child = children.first; child; child = child.next)
7396 if(child.isActiveClient && !child.CloseConfirmation(true))
7404 for(child = children.first; child; child = child.next)
7405 if(!child.isActiveClient && !child.CloseConfirmation(true))
7415 // Static methods... move them somewhere else?
7416 void ::RestoreCaret()
7418 if(guiApp.caretOwner)
7419 guiApp.caretOwner.UpdateCaret(false, false);
7422 void ::FreeMouseRange()
7424 guiApp.interfaceDriver.SetMouseRange(null, null);
7428 bool MenuFileClose(MenuItem selection, Modifiers mods)
7430 Window document = activeChild;
7432 document.Destroy(0);
7436 bool MenuFileExit(MenuItem selection, Modifiers mods)
7442 bool MenuFileSave(MenuItem selection, Modifiers mods)
7447 fileMonitor.fileName = null;
7450 if(OnSaveFile(fileName))
7452 //if(OnFileModified != Window::OnFileModified)
7455 fileMonitor.fileName = fileName;
7461 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7462 DialogResult answer = dialog.Modal();
7464 if(answer != yes) return (bool)answer;
7467 return MenuFileSaveAs(selection, mods);
7470 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7472 DialogResult result = (DialogResult)bool::true;
7473 FileDialog fileDialog = saveDialog;
7478 fileDialog = FileDialog {};
7483 fileDialog.filePath = fileName;
7486 char filePath[MAX_FILENAME];
7487 sprintf(filePath, "Untitled %d", documentID);
7488 fileDialog.filePath = filePath;
7490 fileMonitor.fileName = null;
7492 fileDialog.type = save;
7493 fileDialog.text = $"Save As";
7497 fileDialog.master = master.parent ? master : this;
7498 if(fileDialog.Modal() == ok)
7500 const char * filePath = fileDialog.filePath;
7502 if(OnSaveFile(filePath))
7505 property::fileName = filePath;
7506 NotifySaved(master, this, filePath);
7511 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7512 DialogResult answer = dialog.Modal();
7527 //if(OnFileModified != Window::OnFileModified && fileName)
7530 fileMonitor.fileName = fileName;
7534 return (bool)result; // Actually returning result from Yes/NoCancel message box
7537 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7539 Window document = activeChild;
7541 for(document = children.first; document; document = next)
7543 next = document.next;
7544 if(document.style.isDocument || document.fileName)
7545 document.MenuFileSave(selection, mods);
7550 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7554 for(document = children.first; document; document = document.next)
7555 //if(document.style.isDocument && document.state == minimized)
7556 if(document.style.isActiveClient && document.state == minimized)
7557 document.SetState(minimized, false, mods);
7561 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7563 Window document = activeChild;
7566 Window firstDocument = null;
7568 OldLink cycle = document.cycle.prev;
7573 if(child.style.isActiveClient && !child.style.hidden)
7577 firstDocument = child;
7578 if(child.state == minimized)
7579 child.SetState(minimized, false, mods);
7582 child.positionID = id++;
7583 child.SetState(normal, false, mods);
7584 child.anchor.left.type = cascade;
7587 child.normalSizeAnchor = *&child.sizeAnchor;
7588 child.normalAnchor = child.anchor;
7590 // Break the anchors for moveable/resizable windows
7591 if(child.style.fixed)
7593 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7595 (*&child.normalAnchor).left = x;
7596 (*&child.normalAnchor).top = y;
7597 (*&child.normalAnchor).right.type = none;
7598 (*&child.normalAnchor).bottom.type = none;
7599 (*&child.normalSizeAnchor).isClientW = false;
7600 (*&child.normalSizeAnchor).isClientH = false;
7601 (*&child.normalSizeAnchor).size.w = w;
7602 (*&child.normalSizeAnchor).size.h = h;
7603 child.anchored = false;
7606 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7608 child.stateAnchor = child.normalAnchor;
7609 child.stateSizeAnchor = child.normalSizeAnchor;
7611 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7612 child.Position(x, y, w, h, true, true, true, true, false, false);
7617 last = children.last;
7618 if(!child.style.stayOnTop)
7619 for(; last && last.style.stayOnTop; last = last.prev);
7620 children.Move(child, last);
7621 childrenOrder.Move(child.order, childrenOrder.last);
7623 if(cycle == document.cycle) break;
7627 firstDocument.Activate();
7632 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7639 // Close all closes all active clients, not all documents
7640 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7642 Window next, document;
7644 for(document = children.first; document; document = next)
7646 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7647 if(document.style.isActiveClient)
7648 if(!document.Destroy(0) && !document.style.hidden)
7654 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7656 if(style.hasMaximize && state != maximized)
7657 SetState(maximized, 0, 0);
7661 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7663 if(style.hasMinimize && state != minimized)
7665 SetState(minimized, 0, 0);
7666 parent.CycleChildren(false, true, false, true);
7671 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7673 MenuMoveOrSize(false, selection ? true : false);
7677 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7679 CycleChildren(false, true, false, true);
7683 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7685 CycleChildren(true, true, false, true);
7689 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7691 MenuMoveOrSize(true, true);
7695 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7698 SetState(normal, 0, 0);
7702 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7705 int64 id = selection.id;
7706 OldLink cycle = activeClient.cycle;
7708 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7711 Window sibling = cycle.data;
7712 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7720 document = cycle.data;
7721 document.Activate();
7723 //if(activeChild.state == maximized)
7724 // document.SetState(maximized, false, mods);
7725 //else if(document.state == minimized)
7726 // document.SetState(normal, false, mods);
7730 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7732 stayOnTop = !style.stayOnTop;
7736 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7738 Window document = activeChild;
7741 Window firstDocument = null;
7742 OldLink cycle = document.cycle;
7746 Window child = cycle.data;
7747 if(child.style.isActiveClient && !child.style.hidden)
7749 if(!firstDocument) firstDocument = child;
7750 if(child.state == minimized)
7751 child.SetState(minimized, false, mods);
7754 child.positionID = id++;
7755 child.SetState(normal, false, mods);
7756 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7758 child.anchor.left.type = hTiled;
7761 child.normalSizeAnchor = *&child.sizeAnchor;
7762 child.normalAnchor = child.anchor;
7764 // Break the anchors for moveable/resizable windows
7765 if(child.style.fixed)
7767 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7769 (*&child.normalAnchor).left = x;
7770 (*&child.normalAnchor).top = y;
7771 (*&child.normalAnchor).right.type = none;
7772 (*&child.normalAnchor).bottom.type = none;
7773 (*&child.normalSizeAnchor).isClientW = false;
7774 (*&child.normalSizeAnchor).isClientH = false;
7775 (*&child.normalSizeAnchor).size.w = w;
7776 (*&child.normalSizeAnchor).size.h = h;
7777 child.anchored = false;
7780 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7782 child.stateAnchor = child.normalAnchor;
7783 child.stateSizeAnchor = child.normalSizeAnchor;
7785 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7786 child.Position(x,y, w, h, true, true, true, true, false, true);
7791 if((cycle = cycle.next) == document.cycle) break;
7794 firstDocument.Activate();
7799 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7801 Window document = activeChild;
7804 Window firstDocument = null;
7806 OldLink cycle = document.cycle;
7811 //if(child.style.isDocument)
7812 if(child.style.isActiveClient && !child.style.hidden)
7814 if(!firstDocument) firstDocument = child;
7815 if(child.state == minimized)
7816 child.SetState(minimized, false, mods);
7819 child.positionID = id++;
7820 child.SetState(normal, false, mods);
7821 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7823 child.anchor.left.type = vTiled;
7826 child.normalSizeAnchor = *&child.sizeAnchor;
7827 child.normalAnchor = child.anchor;
7829 // Break the anchors for moveable/resizable windows
7830 if(child.style.fixed)
7832 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7834 (*&child.normalAnchor).left = x;
7835 (*&child.normalAnchor).top = y;
7836 (*&child.normalAnchor).right.type = none;
7837 (*&child.normalAnchor).bottom.type = none;
7838 (*&child.normalSizeAnchor).isClientW = false;
7839 (*&child.normalSizeAnchor).isClientH = false;
7840 (*&child.normalSizeAnchor).size.w = w;
7841 (*&child.normalSizeAnchor).size.h = h;
7842 child.anchored = false;
7845 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7847 child.stateAnchor = child.normalAnchor;
7848 child.stateSizeAnchor = child.normalSizeAnchor;
7850 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7851 child.Position(x,y, w, h, true, true, true, true, false, true);
7856 if((cycle = cycle.next) == document.cycle) break;
7859 firstDocument.Activate();
7864 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7866 WindowList dialog { master = this };
7867 Window document = (Window)(intptr)dialog.Modal();
7870 if(activeChild.state == maximized)
7871 document.SetState(maximized, false, mods);
7872 else if(document.state == minimized)
7873 document.SetState(normal, false, mods);
7874 document.Activate();
7880 virtual bool OnCreate(void);
7881 virtual void OnDestroy(void);
7882 virtual void OnDestroyed(void);
7883 virtual bool OnClose(bool parentClosing);
7884 virtual bool OnStateChange(WindowState state, Modifiers mods);
7885 virtual bool OnPostCreate(void);
7886 virtual bool OnMoving(int *x, int *y, int w, int h);
7887 virtual bool OnResizing(int *width, int *height);
7888 virtual void OnResize(int width, int height);
7889 virtual void OnPosition(int x, int y, int width, int height);
7890 virtual bool OnLoadGraphics(void);
7891 virtual void OnApplyGraphics(void);
7892 virtual void OnUnloadGraphics(void);
7893 virtual void OnRedraw(Surface surface);
7894 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7895 virtual void OnActivateClient(Window client, Window previous);
7896 virtual bool OnKeyDown(Key key, unichar ch);
7897 virtual bool OnKeyUp(Key key, unichar ch);
7898 virtual bool OnKeyHit(Key key, unichar ch);
7899 virtual bool OnSysKeyDown(Key key, unichar ch);
7900 virtual bool OnSysKeyUp(Key key, unichar ch);
7901 virtual bool OnSysKeyHit(Key key, unichar ch);
7902 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7903 virtual bool OnMouseLeave(Modifiers mods);
7904 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7905 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7906 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7907 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7908 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7909 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7910 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7911 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7912 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7913 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7914 virtual void OnMouseCaptureLost(void);
7915 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7916 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7917 virtual void OnDrawOverChildren(Surface surface);
7918 virtual bool OnFileModified(FileChange fileChange, const char * param);
7919 virtual bool OnSaveFile(const char * fileName);
7921 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7922 // Note: A 'client' would refer to isActiveClient, rather than
7923 // being confined to the 'client area' (nonClient == false)
7924 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7925 virtual void OnChildVisibilityToggled(Window child, bool visible);
7926 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7928 // Skins Virtual Functions
7929 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7930 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7931 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7936 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7937 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7938 virtual bool IsMouseMoving(int x, int y, int w, int h)
7942 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7946 virtual void UpdateNonClient();
7947 virtual void SetBox(Box box); // This is used in the MySkin skin
7948 virtual bool IsInside(int x, int y)
7950 return box.IsPointInside({x, y});
7952 virtual bool IsOpaque()
7954 return (!style.drawBehind || background.a == 255);
7958 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7959 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7960 virtual void Window::NotifySaved(Window window, const char * filePath);
7965 property Window parent
7967 property_category $"Layout"
7970 if(value || guiApp.desktop)
7973 Window oldParent = parent;
7974 Anchor anchor = this.anchor;
7976 if(value && value.IsDescendantOf(this)) return;
7977 if(value && value == this)
7979 if(!value) value = guiApp.desktop;
7981 if(value == oldParent) return;
7983 if(!master || (master == this.parent && master == guiApp.desktop))
7984 property::master = value;
7988 parent.children.Remove(this);
7992 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7993 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7994 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7995 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7999 last = value.children.last;
8001 if(style.isDocument)
8004 parent.numDocuments--;
8005 documentID = value.GetDocumentID();
8008 if(style.isActiveClient && !style.hidden)
8010 if(parent && parent != guiApp.desktop && !(style.hidden))
8012 if(state == minimized) parent.numIcons--;
8013 parent.numPositions--;
8017 if(!style.stayOnTop)
8018 for(; last && last.style.stayOnTop; last = last.prev);
8020 value.children.Insert(last, this);
8022 // *** NEW HERE: ***
8024 parent.childrenCycle.Delete(cycle);
8026 parent.childrenOrder.Delete(order);
8029 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8030 // Should something else be done?
8031 if(parent && parent.activeChild == this)
8032 parent.activeChild = null;
8033 if(parent && parent.activeClient == this)
8034 parent.activeClient = null;
8040 int x = position.x, y = position.y, w = size.w, h = size.h;
8044 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8045 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8047 vpw = value.clientSize.w;
8048 vph = value.clientSize.h;
8054 else if(style.fixed)
8056 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8057 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8060 anchor = this.anchor;
8062 if(anchor.left.type == offset) anchor.left.distance = x;
8063 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8064 if(anchor.top.type == offset) anchor.top.distance = y;
8065 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8066 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8067 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8068 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8069 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8070 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8071 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8073 if(!anchor.left.type && !anchor.right.type)
8075 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8076 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8078 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8079 if(!anchor.top.type && !anchor.bottom.type)
8081 anchor.vert.distance = (y + h / 2) - (vph / 2);
8082 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8084 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8087 parent.OnChildAddedOrRemoved(this, false);
8093 parent.childrenCycle.Insert(
8094 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8095 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8097 cycle = OldLink { data = this });
8098 parent.childrenOrder.Insert(
8099 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8100 order = OldLink { data = this });
8103 if(!style.hidden && style.isActiveClient)
8105 positionID = parent.GetPositionID(this);
8106 parent.numPositions++;
8107 if(state == minimized) parent.numIcons--;
8110 // *** FONT INHERITANCE ***
8111 if(!setFont && oldParent)
8112 stopwatching(oldParent, font);
8116 RemoveResource(systemFont);
8119 // TESTING WITH WATCHERS:
8120 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8121 // usedFont = setFont ? setFont : (systemFont);
8125 if(guiApp.currentSkin)
8127 systemFont = guiApp.currentSkin.SystemFont();
8130 usedFont = systemFont;
8131 AddResource(systemFont);
8139 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8148 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8150 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8151 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8154 UnloadGraphics(false);
8157 LoadGraphics(false, false);
8160 if(value.rootWindow != rootWindow)
8161 DisplayModeChanged();
8165 scrolledPos.x = MININT; // Prevent parent update
8167 bool anchored = this.anchored;
8168 property::anchor = anchor;
8169 this.anchored = anchored;
8174 if(guiApp.currentSkin)
8175 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8177 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8178 Position(x, y, w, h, true, true, true, true, false, true);
8183 // else parent = value;
8185 oldParent.OnChildAddedOrRemoved(this, true);
8188 get { return parent; }
8191 property Window master
8193 property_category $"Behavior"
8196 //if(this == value) return;
8197 if(value && value.IsSlaveOf(this)) return;
8203 OldLink slaveHolder;
8204 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8205 if(slaveHolder.data == this)
8207 master.slaves.Delete(slaveHolder);
8214 value.slaves.Add(OldLink { data = this });
8219 master.hotKeys.Remove(hotKey);
8220 value.hotKeys.Add(hotKey);
8223 if(master && master.defaultControl == this)
8224 master.defaultControl = null;
8226 if(style.isDefault && !value.defaultControl)
8227 value.defaultControl = this;
8232 get { return master ? master : parent; }
8235 property const char * caption
8237 property_category $"Appearance"
8244 caption = new char[strlen(value)+1];
8246 strcpy(caption, value);
8251 get { return caption; }
8256 property_category $"Behavior"
8265 master.hotKeys.Add(hotKey = HotKeySlot { });
8269 hotKey.window = this;
8274 master.hotKeys.Delete(hotKey);
8279 get { return hotKey ? hotKey.key : 0; }
8282 property Color background
8284 property_category $"Appearance"
8287 background.color = value;
8292 if(this == rootWindow)
8293 guiApp.interfaceDriver.SetRootWindowColor(this);
8296 get { return background.color; }
8299 property Percentage opacity
8301 property_category $"Appearance"
8304 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8305 drawBehind = (background.a == 255) ? false : true;
8307 get { return background.a / 255.0f; }
8310 property Color foreground
8312 property_category $"Appearance"
8320 get { return foreground; }
8323 property BorderStyle borderStyle
8325 property_category $"Appearance"
8328 if(!((BorderBits)value).fixed)
8330 style.hasClose = false;
8331 style.hasMaximize = false;
8332 style.hasMinimize = false;
8333 nativeDecorations = false;
8335 style.borderBits = value;
8339 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8341 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8342 Position(x, y, w, h, true, true, true, true, false, true);
8343 CreateSystemChildren();
8346 get { return (BorderStyle)style.borderBits; }
8349 property Size minClientSize
8351 property_category $"Layout"
8352 set { minSize = value; }
8353 get { value = minSize; }
8356 property Size maxClientSize
8358 property_category $"Layout"
8359 set { maxSize = value; }
8360 get { value = maxSize; }
8363 property bool hasMaximize
8365 property_category $"Window Style"
8368 style.hasMaximize = value;
8369 if(value) { style.fixed = true; style.contour = true; }
8373 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8375 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8376 Position(x, y, w, h, true, true, true, true, false, true);
8378 CreateSystemChildren();
8381 get { return style.hasMaximize; }
8384 property bool hasMinimize
8386 property_category $"Window Style"
8389 style.hasMinimize = value;
8390 if(value) { style.fixed = true; style.contour = true; }
8394 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8396 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8397 Position(x, y, w, h, true, true, true, true, false, true);
8399 CreateSystemChildren();
8402 get { return style.hasMinimize; }
8405 property bool hasClose
8407 property_category $"Window Style"
8410 style.hasClose = value;
8411 if(value) { style.fixed = true; style.contour = true; }
8415 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8416 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8417 Position(x, y, w, h, true, true, true, true, false, true);
8418 CreateSystemChildren();
8421 get { return style.hasClose; }
8424 property bool nonClient
8426 property_category $"Layout"
8429 style.nonClient = value;
8431 style.stayOnTop = true;
8433 get { return style.nonClient; }
8436 property bool inactive
8438 property_category $"Behavior"
8443 // *** NEW HERE: ***
8447 parent.childrenCycle.Delete(cycle);
8449 parent.childrenOrder.Delete(order);
8456 active = false; // true;
8457 if(parent.activeChild == this)
8458 parent.activeChild = null;
8459 if(parent.activeClient == this)
8460 parent.activeClient = null;
8469 parent.childrenCycle.Insert(
8470 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8471 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8473 cycle = OldLink { data = this });
8475 parent.childrenOrder.Insert(
8476 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8477 order = OldLink { data = this });
8480 style.inactive = value;
8482 get { return style.inactive; }
8485 property bool clickThrough
8487 property_category $"Behavior"
8488 set { style.clickThrough = value; }
8489 get { return style.clickThrough; }
8492 property bool isRemote
8494 property_category $"Behavior"
8495 set { style.isRemote = value; }
8496 get { return style.isRemote; }
8499 property bool noCycle
8501 property_category $"Behavior"
8502 set { style.noCycle = value; }
8503 get { return style.noCycle; }
8506 property bool isModal
8508 property_category $"Behavior"
8509 set { style.modal = value; }
8510 get { return style.modal; }
8513 property bool interim
8515 property_category $"Behavior"
8516 set { style.interim = value; }
8517 get { return style.interim; }
8520 property bool tabCycle
8522 property_category $"Behavior"
8523 set { style.tabCycle = value; }
8524 get { return style.tabCycle; }
8527 property bool isDefault
8529 property_category $"Behavior"
8537 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8538 if(sibling != this && sibling.style.isDefault)
8539 sibling.style.isDefault = false;*/
8540 if(master.defaultControl)
8541 master.defaultControl.style.isDefault = false;
8542 master.defaultControl = this;
8544 else if(master.defaultControl == this)
8545 master.defaultControl = null;
8549 style.isDefault = value;
8551 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8553 get { return style.isDefault; }
8556 property bool drawBehind
8558 property_category $"Window Style"
8559 set { style.drawBehind = value; }
8560 get { return style.drawBehind; }
8563 property bool hasMenuBar
8565 property_category $"Window Style"
8575 if(created && !menuBar)
8582 anchor = Anchor { top = 23, left = 1, right = 1 },
8584 inactive = true, nonClient = true
8589 else if(created && menuBar)
8594 style.hasMenuBar = value;
8596 get { return style.hasMenuBar; }
8599 property bool hasStatusBar
8601 property_category $"Window Style"
8608 statusBar = StatusBar { this };
8616 style.hasStatusBar = value;
8618 get { return style.hasStatusBar; }
8620 property bool stayOnTop
8622 property_category $"Window Style"
8627 if(created && !style.stayOnTop)
8629 if(rootWindow == this)
8630 guiApp.interfaceDriver.OrderRootWindow(this, true);
8631 else if(parent.children.last != this)
8633 parent.children.Move(this, parent.children.last);
8637 style.stayOnTop = true;
8641 if(created && style.stayOnTop)
8643 if(rootWindow == this)
8644 guiApp.interfaceDriver.OrderRootWindow(this, false);
8651 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8652 order && ((Window)order.data).style.stayOnTop;
8653 order = (order == parent.childrenOrder.first) ? null : order.prev);
8654 last = order ? order.data : null;
8658 for(last = parent.children.last;
8659 last && last.style.stayOnTop;
8663 parent.children.Move(this, last);
8667 style.stayOnTop = false;
8670 get { return style.stayOnTop; }
8675 property_category $"Window Style"
8685 if(menuBar && !value)
8692 if(!menuBar && style.hasMenuBar && value)
8696 this, menu = value, isMenuBar = true,
8697 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8698 inactive = true, nonClient = true
8702 UpdateActiveDocument(null);
8705 get { return menu; }
8708 property FontResource font
8710 property_category $"Appearance"
8712 isset { return setFont ? true : false; }
8717 if(value && !setFont) { stopwatching(parent, font); }
8718 else if(!value && setFont)
8724 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8733 RemoveResource(setFont);
8738 RemoveResource(systemFont);
8745 AddResource(setFont);
8748 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8751 systemFont = guiApp.currentSkin.SystemFont();
8753 usedFont = systemFont;
8754 AddResource(systemFont);
8762 get { return usedFont; }
8765 property SizeAnchor sizeAnchor
8767 property_category $"Layout"
8770 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8771 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8772 sizeAnchor.isClientW != sizeAnchor.isClientH;
8779 normalSizeAnchor = sizeAnchor;
8781 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8783 stateAnchor = normalAnchor;
8784 stateSizeAnchor = normalSizeAnchor;
8786 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8787 Position(x,y, w, h, true, true, true, true, false, true);
8794 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8795 sizeAnchor.isClientW,
8796 sizeAnchor.isClientH
8803 property_category $"Layout"
8806 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8807 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8808 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8814 sizeAnchor.isClientW = false;
8815 sizeAnchor.isClientH = false;
8816 sizeAnchor.size = value;
8818 normalSizeAnchor = sizeAnchor;
8820 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8822 stateAnchor = normalAnchor;
8823 stateSizeAnchor = normalSizeAnchor;
8825 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8826 Position(x, y, w, h, true, true, true, true, false, true);
8827 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8830 get { value = size; }
8833 property Size clientSize
8835 property_category $"Layout"
8838 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8839 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8840 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8845 sizeAnchor.isClientW = true;
8846 sizeAnchor.isClientH = true;
8847 sizeAnchor.size = value;
8849 normalSizeAnchor = sizeAnchor;
8851 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8853 stateAnchor = normalAnchor;
8854 stateSizeAnchor = normalSizeAnchor;
8856 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8857 Position(x,y, w, h, true, true, true, true, false, true);
8858 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8861 get { value = this ? clientSize : { 0, 0 }; }
8864 property Size initSize { get { value = sizeAnchor.size; } };
8866 property Anchor anchor
8868 property_category $"Layout"
8869 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8875 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8877 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8878 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8880 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8882 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8883 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8887 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8889 anchor.left.distance = 0;
8890 anchor.horz.type = 0;
8892 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8894 anchor.top.distance = 0;
8895 anchor.vert.type = 0;
8904 normalAnchor = anchor;
8906 // Break the anchors for moveable/resizable windows
8907 /*if(style.fixed ) //&& value.left.type == cascade)
8909 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8911 this.anchor = normalAnchor = Anchor { left = x, top = y };
8912 normalSizeAnchor = SizeAnchor { { w, h } };
8915 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8917 stateAnchor = normalAnchor;
8918 stateSizeAnchor = normalSizeAnchor;
8920 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8921 Position(x, y, w, h, true, true, true, true, false, true);
8930 get { value = this ? anchor : Anchor { }; }
8933 property Point position
8935 property_category $"Layout"
8938 if(value == null) return;
8940 anchor.left = value.x;
8941 anchor.top = value.y;
8942 anchor.right.type = none;
8943 anchor.bottom.type = none;
8948 normalAnchor = anchor;
8950 // Break the anchors for moveable/resizable windows
8954 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8956 normalAnchor.left = x;
8957 normalAnchor.top = y;
8958 normalAnchor.right.type = none;
8959 normalAnchor.bottom.type = none;
8960 normalSizeAnchor.size.width = w;
8961 normalSizeAnchor.size.height = h;
8965 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8967 stateAnchor = normalAnchor;
8968 stateSizeAnchor = normalSizeAnchor;
8970 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8971 Position(x,y, w, h, true, true, true, true, false, true);
8975 get { value = position; }
8978 property bool disabled
8980 property_category $"Behavior"
8983 if(this && disabled != value)
8990 get { return (bool)disabled; }
8993 property bool isEnabled
8998 for(parent = this; parent; parent = parent.parent)
9005 property WindowState state
9007 property_category $"Behavior"
9008 set { SetState(value, false, 0); }
9009 get { return this ? state : 0; }
9012 property bool visible
9014 property_category $"Behavior"
9017 if(this && !value && !style.hidden && parent)
9019 bool wasActiveChild = parent.activeChild == this;
9020 Window client = null;
9022 style.hidden = true;
9023 if(style.isActiveClient)
9025 parent.numPositions--;
9026 if(state == minimized) parent.numIcons--;
9031 OldLink prevOrder = null;
9033 if(rootWindow == this)
9034 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9037 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9040 box.left -= parent.clientStart.x;
9041 box.top -= parent.clientStart.y;
9042 box.right -= parent.clientStart.x;
9043 box.bottom -= parent.clientStart.y;
9047 if(_isModal && master && master.modalSlave == this)
9048 master.modalSlave = null;
9052 OldLink tmpPrev = order.prev;
9053 client = tmpPrev ? tmpPrev.data : null;
9054 if(client && !client.style.hidden && !client.destroyed && client.created)
9055 prevOrder = tmpPrev;
9058 client = tmpPrev ? tmpPrev.data : null;
9059 if(client == this) { client = null; break; }
9060 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9062 tmpPrev = client.order.prev;
9067 prevOrder = tmpPrev;
9072 // If this window can be an active client, make sure the next window we activate can also be one
9073 if(!style.nonClient && style.isActiveClient)
9075 tmpPrev = prevOrder;
9078 client = tmpPrev ? tmpPrev.data : null;
9079 if(client == this) { client = null; break; }
9080 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9082 tmpPrev = client.order.prev;
9087 prevOrder = tmpPrev;
9091 if(client && client.style.hidden) client = null;
9095 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9097 if(order && prevOrder && prevOrder.data != this)
9098 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9100 ActivateEx(false, false, false, true, null, null);
9102 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9103 if(parent.activeClient == this)
9105 parent.activeClient = null;
9106 parent.UpdateActiveDocument(null);
9109 else if(parent.activeClient == this)
9111 parent.activeClient = client;
9112 parent.UpdateActiveDocument(this);
9115 // *** Not doing this anymore ***
9118 parent.childrenCycle.Delete(cycle);
9120 parent.childrenOrder.Delete(order);
9125 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9130 else if(this && value && style.hidden)
9132 style.hidden = false;
9135 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9136 if(rootWindow == this)
9137 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9139 if(_isModal && master)
9140 master.modalSlave = this;
9142 if(style.isActiveClient)
9144 positionID = parent.GetPositionID(this);
9145 parent.numPositions++;
9146 if(state == minimized) parent.numIcons++;
9149 // *** NOT DOING THIS ANYMORE ***
9151 if(!(style.inactive))
9153 if(!(style.noCycle))
9155 cycle = parent.childrenCycle.AddAfter(
9156 (parent.activeChild && parent.activeChild.cycle) ?
9157 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9160 order = parent.childrenOrder.AddAfter(
9161 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9168 if(true || !parent.activeChild)
9169 ActivateEx(true, false, true, true, null, null);
9171 if(creationActivation == activate && guiApp.desktop.active)
9172 ActivateEx(true, false, true, true, null, null);
9173 else if((creationActivation == activate || creationActivation == flash) && !object)
9176 if(this == rootWindow)
9180 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9184 ConsequentialMouseMove(false);
9190 style.hidden = !value;
9193 get { return (style.hidden || !setVisible) ? false : true; }
9196 property bool isDocument
9198 property_category $"Document"
9199 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9200 get { return style.isDocument; }
9203 property bool mergeMenus
9205 property_category $"Window Style"
9206 set { mergeMenus = value; }
9207 get { return (bool)mergeMenus; }
9210 property bool hasHorzScroll
9212 property_category $"Window Style"
9217 if(!style.hasHorzScroll && created)
9219 CreateSystemChildren();
9220 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9223 else if(style.hasHorzScroll)
9227 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9229 style.hasHorzScroll = value;
9232 get { return style.hasHorzScroll; }
9235 property bool hasVertScroll
9237 property_category $"Window Style"
9242 if(!style.hasVertScroll && created)
9244 style.hasVertScroll = true;
9245 CreateSystemChildren();
9246 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9249 else if(style.hasVertScroll)
9253 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9255 style.hasVertScroll = value;
9257 get { return style.hasVertScroll; }
9260 property bool dontHideScroll
9262 property_category $"Behavior"
9265 scrollFlags.dontHide = value;
9268 //UpdateScrollBars(true, true);
9269 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9273 // UpdateScrollBars(true, true);
9274 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9277 get { return scrollFlags.dontHide; }
9280 property bool dontScrollVert
9282 property_category $"Behavior"
9283 set { style.dontScrollVert = value; }
9284 get { return style.dontScrollVert; }
9286 property bool dontScrollHorz
9288 property_category $"Behavior"
9289 set { style.dontScrollHorz = value; }
9290 get { return style.dontScrollHorz; }
9293 property bool snapVertScroll
9295 property_category $"Behavior"
9298 scrollFlags.snapY = value;
9299 if(sbv) sbv.snap = value;
9301 get { return scrollFlags.snapY; }
9303 property bool snapHorzScroll
9305 property_category $"Behavior"
9308 scrollFlags.snapX = value;
9309 if(sbh) sbh.snap = value;
9311 get { return scrollFlags.snapX; }
9314 property Point scroll
9316 property_category $"Behavior"
9317 set { if(this) SetScrollPosition(value.x, value.y); }
9318 get { value = scroll; }
9321 property bool modifyVirtualArea
9323 property_category $"Behavior"
9324 set { modifyVirtArea = value; }
9325 get { return (bool)modifyVirtArea; }
9328 property bool dontAutoScrollArea
9330 property_category $"Behavior"
9331 // Activating a child control out of view will automatically scroll to make it in view
9332 set { noAutoScrollArea = value; }
9333 get { return (bool)noAutoScrollArea; }
9336 property const char * fileName
9338 property_category $"Document"
9343 if(menu && ((!fileName && value) || (fileName && !value)))
9345 MenuItem item = menu.FindItem(MenuFileSave, 0);
9346 if(item) item.disabled = !modifiedDocument && value;
9351 if(value && value[0])
9352 fileName = CopyString(value);
9354 if(parent && this == parent.activeClient)
9355 parent.UpdateActiveDocument(null);
9359 // if(style.isDocument)
9361 fileMonitor.fileName = value;
9363 get { return fileName; }
9368 property_category $"Data"
9373 property bool modifiedDocument
9375 property_category $"Document"
9378 if(style.isDocument || fileName)
9382 MenuItem item = menu.FindItem(MenuFileSave, 0);
9383 if(item) item.disabled = !value && fileName;
9387 if(modifiedDocument != value)
9389 modifiedDocument = value;
9390 if(style.isDocument || fileName)
9394 get { return (bool)modifiedDocument; }
9397 property bool showInTaskBar
9399 property_category $"Window Style"
9402 style.showInTaskBar = value;
9403 #if defined(__WIN32__)
9404 Win32UpdateStyle(this);
9407 get { return style.showInTaskBar; }
9409 property FileDialog saveDialog { set { saveDialog = value; } };
9410 property bool isActiveClient
9412 property_category $"Behavior"
9415 if(parent && style.isActiveClient != value && !style.hidden)
9419 if(state == minimized) parent.numIcons++;
9420 parent.numPositions++;
9424 if(state == minimized) parent.numIcons--;
9425 parent.numPositions--;
9428 style.isActiveClient = value;
9430 get { return style.isActiveClient; }
9433 property Cursor cursor
9435 property_category $"Appearance"
9439 SelectMouseCursor();
9441 get { return cursor; }
9444 //#if !defined(ECERE_VANILLA)
9445 property const char * name
9447 property_category $"Design"
9450 return (this && object) ? object.name : null;
9455 activeDesigner.RenameObject(object, value);
9459 property const char * displayDriver
9461 property_category $"Behavior"
9464 dispDriver = GetDisplayDriver(value);
9465 //DisplayModeChanged();
9469 return dispDriver ? dispDriver.name : null;
9473 // RUNTIME PROPERTIES
9474 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9475 property Size scrollArea
9477 property_category $"Behavior"
9481 SetScrollArea(value.w, value.h, false);
9483 SetScrollArea(0,0, true);
9485 get { value = scrollArea; }
9488 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9493 property_category $"Layout"
9494 set { if(this) is3D = value; }
9495 get { return (bool)is3D; }
9498 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9500 // Will be merged with font later
9501 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9502 property Point clientStart { get { value = clientStart; } };
9503 property Point absPosition { get { value = absPosition; } };
9504 property Anchor normalAnchor { get { value = normalAnchor; } };
9505 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9506 property bool active { get { return (bool)active; } };
9507 property bool created { get { return (bool)created; } };
9508 property bool destroyed { get { return (bool)destroyed; } };
9509 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9510 property Window firstChild { get { return children.first; } };
9511 property Window lastChild { get { return children.last; } };
9512 property Window activeClient { get { return activeClient; } };
9513 property Window activeChild { get { return activeChild; } };
9514 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9515 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9516 property ScrollBar horzScroll { get { return sbh; } };
9517 property ScrollBar vertScroll { get { return sbv; } };
9518 property StatusBar statusBar { get { return statusBar; } };
9519 property Window rootWindow { get { return rootWindow; } };
9520 property bool closing { get { return (bool)closing; } set { closing = value; } };
9521 property int documentID { get { return documentID; } };
9522 property Window previous { get { return prev; } }
9523 property Window next { get { return next; } }
9524 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9525 property PopupMenu menuBar { get { return menuBar; } }
9526 property ScrollBar sbv { get { return sbv; } }
9527 property ScrollBar sbh { get { return sbh; } }
9528 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9529 property void * systemHandle { get { return windowHandle; } }
9530 property Button minimizeButton { get { return sysButtons[0]; } };
9531 property Button maximizeButton { get { return sysButtons[1]; } };
9532 property Button closeButton { get { return sysButtons[2]; } };
9533 property BitmapResource icon
9535 get { return icon; }
9539 if(icon) incref icon;
9541 guiApp.interfaceDriver.SetIcon(this, value);
9544 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9545 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9546 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9547 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9548 property bool nativeDecorations
9550 get { return (bool)nativeDecorations; }
9551 set { nativeDecorations = value; }
9552 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9555 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9556 bool result = false;
9557 if(nativeDecorations)
9559 if(rootWindow == this)
9563 if(formDesigner && activeDesigner)
9565 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9566 Window form = cd ? cd.form : null;
9567 if(form && parent == form.parent)
9572 return result != style.fixed;
9576 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9578 property const char * text
9580 property_category $"Deprecated"
9582 set { property::caption = value; }
9583 get { return property::caption; }
9589 WindowBits style; // Window Style
9590 char * caption; // Name / Caption
9591 Window parent; // Parent window
9592 OldList children; // List of children in Z order
9593 Window activeChild; // Child window having focus
9594 Window activeClient;
9595 Window previousActive; // Child active prior to activating the default child
9596 Window master; // Window owning and receiving notifications concerning this window
9597 OldList slaves; // List of windows belonging to this window
9598 Display display; // Display this window is drawn into
9600 Point position; // Position in parent window client area
9601 Point absPosition; // Absolute position
9602 Point clientStart; // Client area position from (0,0) in this window
9604 Size clientSize; // Client area size
9605 Size scrollArea; // Virtual Scroll area size
9606 Size reqScrollArea; // Requested virtual area size
9607 Point scroll; // Virtual area scrolling position
9608 ScrollBar sbh, sbv; // Scrollbar window handles
9609 Cursor cursor; // Mouse cursor used for this window
9612 StatusBar statusBar;
9613 Button sysButtons[3];
9615 Box clientArea; // Client Area box clipped to parent
9617 HotKeySlot hotKey; // HotKey for this window
9621 ScrollFlags scrollFlags;// Window Scrollbar Flags
9622 int64 id; // Control ID
9624 ColorAlpha background; // Background color used to draw the window area
9626 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9627 OldList childrenCycle; // Cycling order
9628 OldLink cycle; // Element of parent's cycling order
9629 OldList childrenOrder; // Circular Z-Order
9630 OldLink order; // Element of parent's circular Z-Order
9631 Window modalSlave; // Slave window blocking this window's interaction
9633 Window rootWindow; // Topmost system managed window
9634 void * windowHandle; // System window handle
9636 DialogResult returnCode;// Return code for modal windows
9638 Point sbStep; // Scrollbar line scrolling steps
9641 SizeAnchor stateSizeAnchor;
9643 Anchor normalAnchor;
9644 SizeAnchor normalSizeAnchor;
9646 Size skinMinSize; // Minimal window size based on style
9647 Point scrolledPos; // Scrolled position
9648 Box box; // Window box clipped to parent
9649 Box * against; // What to clip the box to
9651 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9652 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9653 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9654 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9655 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9656 Point scrolledArea; // Distance to scroll area by
9657 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9659 OldList hotKeys; // List of the hotkeys of all children
9660 Window defaultControl; // Default child control
9664 ColorAlpha * palette; // Color palette used for this window
9666 int caretSize; // Size of caret, non zero if a caret is present
9667 Point caretPos; // Caret position
9669 void * systemParent; // Parent System Window for embedded windows
9676 WindowState lastState;
9678 FileMonitor fileMonitor;
9680 FontResource setFont, systemFont;
9681 FontResource usedFont;
9682 FontResource captionFont;
9684 FileDialog saveDialog;
9686 SizeAnchor sizeAnchor;
9688 // FormDesigner data
9691 Extent * tempExtents; //[4];
9692 BitmapResource icon;
9694 CreationActivationOption creationActivation;
9697 bool active:1; // true if window and ancestors are active
9698 bool acquiredInput:1; // true if the window is processing state based input
9699 bool modifiedDocument:1;
9700 bool disabled:1; // true if window cannot interact
9701 bool isForegroundWindow:1;// true while a root window is being activated
9702 bool visible:1; // Visibility flag
9703 bool destroyed:1; // true if window is being destroyed
9704 bool anchored:1; // true if this window is repositioned when the parent resizes
9705 bool dirty:1; // Flag set to true if any descendant must be redrawn
9711 bool modifyVirtArea:1;
9712 bool noAutoScrollArea:1;
9715 bool setVisible:1; // FOR FORM DESIGNER
9721 bool useSharedMemory:1;
9724 bool nativeDecorations:1;
9725 bool manageDisplay:1;
9726 bool formDesigner:1; // True if we this is running in the form editor
9727 bool requireRemaximize:1;
9730 // Checks used internally for them not to take effect in FormDesigner
9731 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9732 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9734 WindowController controller;
9735 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9738 public class CommonControl : Window
9740 // creationActivation = doNothing;
9743 public property const String toolTip
9745 property_category $"Appearance"
9748 if(created) CommonControl::OnDestroy();
9750 toolTip = value ? ToolTip { tip = value; } : null;
9752 if(created) CommonControl::OnCreate();
9754 get { return toolTip ? toolTip.tip : null; }
9760 // (Very) Ugly work around for the fact that the parent watcher
9761 // won't fire when it's already been disconnected...
9762 eInstance_FireSelfWatchers(toolTip,
9763 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9769 toolTip.parent = this;
9778 public class Percentage : float
9780 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9784 sprintf(string, "%.2f", this);
9785 c = strlen(string)-1;
9788 if(string[c] != '0')
9789 last = Max(last, c);
9790 if(string[c] == '.')
9803 public void ApplySkin(Class c, const char * name, void ** vTbl)
9805 char className[1024];
9810 subclass(Window) wc = (subclass(Window))c;
9811 subclass(Window) base = (subclass(Window))c.base;
9813 sprintf(className, "%sSkin_%s", name, c.name);
9814 wc.pureVTbl = c._vTbl;
9815 c._vTbl = new void *[c.vTblSize];
9816 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9817 sc = eSystem_FindClass(c.module.application, className);
9821 for(m = 0; m < c.base.vTblSize; m++)
9823 if(c._vTbl[m] == base.pureVTbl[m])
9824 c._vTbl[m] = vTbl[m];
9829 for(m = 0; m < c.vTblSize; m++)
9831 if(sc._vTbl[m] != wc.pureVTbl[m])
9832 c._vTbl[m] = sc._vTbl[m];
9836 for(d = c.derivatives.first; d; d = d.next)
9838 ApplySkin(d.data, name, c._vTbl);
9842 public void UnapplySkin(Class c)
9844 subclass(Window) wc = (subclass(Window))c;
9847 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9850 c._vTbl = wc.pureVTbl;
9854 for(d = c.derivatives.first; d; d = d.next)
9856 UnapplySkin(d.data);
9860 void CheckFontIntegrity(Window window)
9865 if(window.usedFont && window.usedFont.font == 0xecececec)
9867 FontResource uf = window.usedFont;
9868 char * className = window._class.name;
9869 char * text = window.text;
9872 for(c = window.firstChild; c; c = c.next)
9873 CheckFontIntegrity(c);
9877 public class ControllableWindow : Window
9879 /*WindowController controller;
9880 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9881 ~ControllableWindow() { delete controller; }*/
9884 class WindowControllerInterface : ControllableWindow
9886 bool OnKeyDown(Key key, unichar ch)
9888 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9890 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9894 bool OnKeyUp(Key key, unichar ch)
9896 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9898 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9902 bool OnKeyHit(Key key, unichar ch)
9904 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9906 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9910 bool OnMouseMove(int x, int y, Modifiers mods)
9912 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9914 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9918 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9920 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9922 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9926 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9928 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9930 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9934 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9936 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9938 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9942 bool OnRightButtonDown(int x, int y, Modifiers mods)
9944 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9946 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9950 bool OnRightButtonUp(int x, int y, Modifiers mods)
9952 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9954 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9958 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9960 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9962 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9966 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9968 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9970 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9974 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9976 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9978 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9982 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9984 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9986 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9990 void OnResize(int width, int height)
9992 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9993 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9996 void OnRedraw(Surface surface)
9998 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9999 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
10004 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
10006 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
10010 bool OnLoadGraphics()
10012 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
10014 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
10018 void OnUnloadGraphics()
10020 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10021 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
10025 public class WindowController<class V>
10028 property Window window
10032 uint size = class(Window).vTblSize;
10035 windowVTbl = new void *[size];
10036 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10037 if(value._vTbl == value._class._vTbl)
10039 value._vTbl = new void *[value._class.vTblSize];
10040 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10044 for(c = 0; c < size; c++)
10046 void * function = class(WindowControllerInterface)._vTbl[c];
10047 if(function != DefaultFunction)
10048 value._vTbl[c] = function;
10050 value._vTbl[c] = windowVTbl[c];
10055 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10058 get { return window; }
10060 property V controlled
10062 set { controlled = value; }
10063 get { return controlled; }
10065 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10066 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10067 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10068 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10069 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10070 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10071 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10072 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10073 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10074 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10075 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10076 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10077 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10078 virtual void V::OnResize(WindowController controller, int width, int height);
10079 virtual void V::OnRedraw(WindowController controller, Surface surface);
10080 virtual bool V::OnCreate(WindowController controller);
10081 virtual bool V::OnLoadGraphics(WindowController controller);
10082 virtual void V::OnUnloadGraphics(WindowController controller);
10085 int (** windowVTbl)();
10089 ~WindowController()