7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
573 stopwatching(parent, font);
574 if(parent.activeChild == this)
575 parent.activeChild = null;
576 if(parent.activeClient == this)
577 parent.activeClient = null;
582 // Prevent destructor from being called again...
588 /////////////////////////////////
591 OldLink slave = master.slaves.FindLink(this);
592 master.slaves.Delete(slave);
599 parent.childrenCycle.Remove(cycle);
601 parent.childrenOrder.Remove(order);
602 parent.children.Remove(this);
607 /////////////////////////////////
609 while(ptr = resources.first)
612 resources.Delete(ptr);
619 for(child = children.first; child; child = child.next)
621 // child.stopwatching(this, font);
623 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
624 // Don't want property here
625 *&child.parent = null;
628 while(slave = slaves.first)
630 // Don't want property here
631 *&((Window)slave.data).master = null;
632 slaves.Delete(slave);
635 // Because we do a decref in DestroyEx...
643 // Why was this commented?
644 //if(this != guiApp.desktop)
657 if(((subclass(Window))_class).pureVTbl)
659 if(_vTbl == _class._vTbl)
661 _vTbl = ((subclass(Window))_class).pureVTbl;
666 for(m = 0; m < _class.vTblSize; m++)
668 if(_vTbl[m] == _class._vTbl[m])
669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
673 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
676 dirtyArea.Free(null);
677 renderArea.Free(null);
678 overRenderArea.Free(null);
679 clipExtent.Free(null);
680 scrollExtent.Free(null);
681 dirtyBack.Free(null);
685 tempExtents[0].Free(null);
686 tempExtents[1].Free(null);
687 tempExtents[2].Free(null);
688 tempExtents[3].Free(null);
693 //#if !defined(ECERE_VANILLA)
694 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
696 if(this == activeDesigner)
700 char * name = property::name;
701 return name ? name : "";
706 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
707 bool OnGetDataFromString(char * string)
709 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
712 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
713 this = designer.form;
714 else if(!strcmpi(string, "(Desktop)"))
715 this = activeDesigner;
717 return activeDesigner.FindObject(&this, string);
723 // --- Window updates system ---
725 // Setup a bitmap for Redrawing on client area of Window
726 Surface Redraw(Box box)
728 Surface surface = null;
730 Box clientArea = this.clientArea;
734 mox.left -= clientStart.x;
735 mox.top -= clientStart.y;
736 mox.right -= clientStart.x;
737 mox.bottom -= clientStart.y;
739 mox.Clip(clientArea);
740 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
742 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
744 int x = absPosition.x + clientStart.x;
745 int y = absPosition.y + clientStart.y;
746 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
748 x -= rootWindow.clientStart.x;
749 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
751 if(!guiApp.fullScreenMode || is3D)
753 x -= rootWindow.absPosition.x;
754 y -= rootWindow.absPosition.y;
758 x += rootWindow.parent.clientStart.x;
759 y += rootWindow.parent.clientStart.y;
761 mox.left += rootWindow.parent.clientStart.x;
762 mox.top += rootWindow.parent.clientStart.y;
763 mox.right += rootWindow.parent.clientStart.x;
764 mox.bottom += rootWindow.parent.clientStart.y;
769 surface = display.GetSurface(x, y, mox);
772 surface.width = clientSize.w;
773 surface.height = clientSize.h;
779 // Setup a bitmap for Redrawing on full Window
780 Surface RedrawFull(Box box)
782 Surface surface = null;
790 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
792 int x = absPosition.x;
793 int y = absPosition.y;
794 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
796 x -= rootWindow.clientStart.x;
797 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
799 if(!guiApp.fullScreenMode || is3D)
801 x -= rootWindow.absPosition.x;
802 y -= rootWindow.absPosition.y;
805 x += rootWindow.parent.clientStart.x;
806 y += rootWindow.parent.clientStart.y;
808 mox.left += rootWindow.parent.clientStart.x;
809 mox.top += rootWindow.parent.clientStart.y;
810 mox.right += rootWindow.parent.clientStart.x;
811 mox.bottom += rootWindow.parent.clientStart.y;
816 surface = display.GetSurface(x, y, mox);
819 surface.width = size.w;
820 surface.height = size.h;
826 void FigureCaption(char * caption)
828 Window activeClient = null;
832 strcpy(caption, this.caption);
833 if(style.isDocument || fileName)
835 if(caption[0]) strcat(caption, " - ");
837 strcat(caption, fileName);
841 sprintf(title, "Untitled %d", documentID);
842 strcat(caption, title);
845 strcat(caption, " *");
850 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
852 if(activeClient && activeClient.state == maximized)
854 if(activeClient.caption)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, activeClient.caption);
859 if(activeClient.style.isDocument || activeClient.fileName)
861 if(caption[0]) strcat(caption, " - ");
862 strcat(caption, "[");
863 if(activeClient.fileName)
864 strcat(caption, activeClient.fileName);
868 sprintf(title, "Untitled %d", activeClient.documentID);
869 strcat(caption, title);
871 if(activeClient.modifiedDocument)
872 strcat(caption, " *");
873 strcat(caption, "]");
878 // Code for returning dirty from ScrollDisplay:
880 for(d = 0; d<scrollExtent.count; d++)
882 Box * box = &scrollExtent.boxes[d];
888 Min(box.right, box.left-scroll.x),box.bottom
890 dirtyArea.UnionBox(update);
896 Max(box.left, box.right-scroll.x), box.top,
897 box.right, box.bottom
899 dirtyArea.UnionBox(update);
907 box.right, Min(box.bottom, box.top-scroll.y),
909 dirtyArea.UnionBox(update);
915 box.left, Max(box.top, box.bottom-scroll.y),
916 box.right, box.bottom
918 dirtyArea.UnionBox(update);
923 void UpdateDecorations(void)
925 // TODO: *** TEMPORARY HACK ***
932 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
934 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
936 Update({ -clientStart.x,0, -1, clientSize.h-1 });
938 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
941 // Returns w & h for Position
942 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
944 Window parent = this.parent ? this.parent : guiApp.desktop;
945 int xOffset = 0, yOffset = 0;
946 int vpw = parent ? parent.clientSize.w : 0;
947 int vph = parent ? parent.clientSize.h : 0;
948 int pw = parent ? parent.clientSize.w : 0;
949 int ph = parent ? parent.clientSize.h : 0;
950 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
951 int x = anchor.left.distance, y = anchor.top.distance;
953 MinMaxValue ew = 0, eh = 0;
955 float cascadeW, cascadeH;
957 int tilingW, tilingH, tilingSplit, tilingLastH;
958 int addX = 0, addY = 0;
960 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
962 Window masterWindow = this;
963 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
966 if(master == guiApp.desktop)
967 masterWindow = guiApp.desktop.activeChild;
969 masterWindow = master.rootWindow;
970 if(!masterWindow) masterWindow = this;
972 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
973 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
976 pw = vpw = box.right - box.left + 1;
978 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
981 ph = vph = box.bottom - box.top + 1;
997 vpw = pw = parent.size.w;
998 vph = ph = parent.size.h;
1000 else if(!style.fixed /*|| style.isDocument*/)
1002 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1003 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1005 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1008 Desktop3D_FixSize(&pw, &ph);
1009 Desktop3D_FixSize(&vpw, &vph);
1012 if(pw < skinMinSize.w) pw = skinMinSize.w;
1013 if(ph < skinMinSize.h) ph = skinMinSize.h;
1014 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1015 if(vph < skinMinSize.h) vph = skinMinSize.h;
1017 // TODO: Must fix what we're snapping
1020 if(anchor.left.type)
1022 SNAPUP(x, textCellW);
1024 else if(anchor.right.type)
1026 SNAPDOWN(x, textCellW);
1031 SNAPUP(y, textCellH);
1033 else if(anchor.bottom.type)
1035 SNAPDOWN(y, textCellH);
1039 // This is required to get proper initial decoration size using native decorations on Windows
1040 #if defined(__WIN32__)
1041 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1042 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1044 GetDecorationsSize(&ew, &eh);
1046 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1048 // Leave room for non client windows (eventually dockable panels)
1050 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1051 for(win = parent.children.first; win; win = win.next)
1053 if(!win.isActiveClient && win.visible)
1055 Size size = win.size;
1056 Point pos = win.position;
1057 int left = pos.x, top = pos.y;
1058 int right = pos.x + size.w, bottom = pos.y + size.h;
1059 if(win.size.w > win.size.h)
1062 loY = Max(loY, bottom);
1063 else if(top > ph - ph / 4)
1064 hiY = Min(hiY, top);
1069 loX = Max(loX, right);
1070 else if(left > pw - pw / 4)
1071 hiX = Min(hiX, left);
1080 if(parent.sbv && !parent.sbv.style.hidden)
1081 pw += guiApp.currentSkin.VerticalSBW();
1082 if(parent.sbh && !parent.sbh.style.hidden)
1083 ph += guiApp.currentSkin.HorizontalSBH();
1085 if(anchor.left.type == cascade)
1087 w = (int)(pw * 0.80);
1088 h = (int)(ph * 0.80);
1090 else if(anchor.left.type >= vTiled)
1095 numTiling = parent.numPositions - parent.numIcons;
1096 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1097 if(anchor.left.type == vTiled)
1099 tilingH = (int)sqrt(numTiling);
1100 tilingW = numTiling / tilingH;
1104 tilingW = (int)sqrt(numTiling);
1105 tilingH = numTiling / tilingW;
1108 leftOver = numTiling - tilingH * tilingW;
1111 tilingSplit = (tilingW - leftOver) * tilingH;
1112 tilingLastH = tilingH+1;
1115 tilingSplit = numTiling;
1117 if(positionID >= tilingSplit)
1119 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1120 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1121 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1122 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1126 x = xOffset + pw * (positionID / tilingH) / tilingW;
1127 y = yOffset + ph * (positionID % tilingH) / tilingH;
1128 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1129 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1133 SNAPDOWN(x, textCellW);
1134 SNAPDOWN(y, textCellH);
1135 SNAPDOWN(x2, textCellW);
1136 SNAPDOWN(y2, textCellH);
1144 if(sizeAnchor.isClientW) w += ew;
1145 if(sizeAnchor.isClientH) h += eh;
1147 if(anchor.left.type == offset)
1148 x = anchor.left.distance;
1149 else if(anchor.left.type == relative)
1150 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1151 else if(anchor.right.type == relative)
1152 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1153 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1154 else if(anchor.right.type == offset)
1155 ex = vpw - anchor.right.distance;
1157 if(anchor.top.type == offset)
1158 y = anchor.top.distance;
1159 else if(anchor.top.type == relative)
1160 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1161 else if(anchor.bottom.type == relative)
1162 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1163 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1164 else if(anchor.bottom.type == offset)
1165 ey = vph - anchor.bottom.distance;
1167 if(anchor.left.type && anchor.right.type)
1169 switch(anchor.right.type)
1172 ex = pw * (1.0f-anchor.right.percent);
1173 w = Max((int)(ex + 0.5) - x, 0);
1176 ex = vpw - anchor.right.distance;
1177 w = Max((int)(ex + 0.5) - x, 0);
1181 if(anchor.top.type && anchor.bottom.type)
1183 switch(anchor.bottom.type)
1186 ey = ph * (1.0f-anchor.bottom.percent);
1187 h = Max((int)(ey + 0.5) - y, 0);
1190 ey = vph - anchor.bottom.distance;
1191 h = Max((int)(ey + 0.5) - y, 0);
1200 if(state == normal /*|| state == Hidden*/)
1202 bool addSbV = false, addSbH = false;
1204 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1205 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1207 w = Max(w, minSize.w);
1208 h = Max(h, minSize.h);
1209 w = Min(w, maxSize.w);
1210 h = Min(h, maxSize.h);
1212 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1214 if(w) w -= guiApp.currentSkin.VerticalSBW();
1217 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1219 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1223 if(!OnResizing(&w, &h))
1229 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1230 w += guiApp.currentSkin.VerticalSBW();
1231 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1232 h += guiApp.currentSkin.HorizontalSBH();
1234 w = Max(w, skinMinSize.w);
1235 h = Max(h, skinMinSize.h);
1248 SNAPDOWN(w, textCellW);
1249 SNAPDOWN(h, textCellH);
1252 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1254 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1257 (pw - w) / CASCADE_SPACE,
1258 (ph - h) / CASCADE_SPACE);
1264 cascW = (pw - w) / (numCascade-1);
1265 cascH = (ph - h) / (numCascade-1);
1266 SNAPDOWN(cascW, textCellW);
1267 SNAPDOWN(cascH, textCellH);
1268 cascadeW = (float)cascW;
1269 cascadeH = (float)cascH;
1273 numCascade = Max(numCascade, 2);
1274 cascadeW = (float)(pw - w) / (numCascade-1);
1275 cascadeH = (float)(ph - h) / (numCascade-1);
1278 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1279 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1281 else if(anchor.left.type < vTiled)
1283 if(!anchor.left.type || anchor.horz.type == middleRelative)
1285 if(!anchor.right.type)
1287 if(anchor.horz.type == middleRelative)
1288 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1290 x = vpw / 2 + anchor.horz.distance - w / 2;
1296 // case A_EDGE: x = x - w; break;
1298 if(!anchor.top.type || anchor.vert.type == middleRelative)
1300 if(!anchor.bottom.type)
1302 if(anchor.vert.type == middleRelative)
1303 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1305 y = vph / 2 + anchor.vert.distance - h / 2;
1311 // case A_EDGE: y = y - h; break;
1314 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1322 SNAPDOWN(x, textCellW);
1323 SNAPDOWN(y, textCellH);
1335 if(anchored && style.fixed && style.isActiveClient)
1340 void UpdateCaret(bool forceUpdate, bool erase)
1342 static Window lastWindow = null;
1343 static int caretX, caretY, caretSize;
1345 if(guiApp && guiApp.caretOwner == this)
1347 int x = caretPos.x - scroll.x;
1348 int y = caretPos.y - scroll.y;
1350 if((erase || this.caretSize) &&
1351 x >= clientArea.left && x <= clientArea.right &&
1352 y >= clientArea.top && y <= clientArea.bottom)
1356 guiApp.interfaceDriver.SetCaret(
1357 x + absPosition.x + clientStart.x,
1358 y + absPosition.y + clientStart.y, this.caretSize);
1359 guiApp.caretEnabled = true;
1361 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1365 if(lastWindow != this)
1367 updateBox.left = x + 1;
1369 updateBox.right = x + 2;
1370 updateBox.bottom = y + this.caretSize - 1;
1374 updateBox.left = Min(x + 1, caretX + 1);
1375 updateBox.top = Min(y, caretY);
1376 updateBox.right = Max(x + 2, caretX + 2);
1377 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1380 guiApp.caretOwner.Update(updateBox);
1387 caretSize = this.caretSize;
1393 guiApp.interfaceDriver.SetCaret(0,0,0);
1394 guiApp.caretEnabled = false;
1400 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1405 scrolledPos.x = position.x = x;
1406 scrolledPos.y = position.y = y;
1408 clientSize.w = size.w = w;
1409 clientSize.h = size.h = h;
1411 if(parent && !style.nonClient)
1413 //if(!style.fixed || style.isDocument)
1415 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1416 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1420 clientStart.x = clientStart.y = 0;
1422 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1424 //if(!activeClient || activeClient.state != maximized)
1425 if(!noAutoScrollArea)
1427 // Check if scroll area must be modified
1428 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1430 bool foundChild = false;
1432 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1433 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1434 for(child = children.first; child; child = child.next)
1436 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1437 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1439 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1440 w = Max(w, child.position.x + child.size.w);
1441 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1442 w = Max(w, Max(child.position.x, 0) + child.size.w);
1443 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1444 h = Max(h, child.position.y + child.size.h);
1445 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1446 h = Max(h, Max(child.position.y, 0) + child.size.h);
1451 if(foundChild && (w > cw || h > ch))
1453 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1455 int stepX = sbStep.x, stepY = sbStep.y;
1456 // Needed to make snapped down position match the skin's check of client area
1457 // against realvirtual
1460 SNAPDOWN(stepX, textCellW);
1461 SNAPDOWN(stepY, textCellH);
1462 stepX = Max(stepX, textCellW);
1463 stepY = Max(stepY, textCellH);
1465 if(scrollFlags.snapX)
1467 if(scrollFlags.snapY)
1470 reqScrollArea.w = w;
1471 reqScrollArea.h = h;
1474 else if(reqScrollArea.w || reqScrollArea.h)
1476 reqScrollArea.w = 0;
1477 reqScrollArea.h = 0;
1478 SetScrollPosition(0,0);
1483 // Automatic MDI Client Scrolling Area Adjustment
1484 if(parent && !parent.noAutoScrollArea)
1486 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1487 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1489 Window parent = this.parent;
1490 int w = parent.reqScrollArea.w;
1491 int h = parent.reqScrollArea.h;
1493 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1494 w = Max(w, position.x + size.w);
1495 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1496 w = Max(w, Max(position.x, 0) + size.w);
1497 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1498 h = Max(h, position.y + size.h);
1499 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1500 h = Max(h, Max(position.y, 0) + size.h);
1502 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1503 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1505 /*bool resize = false;
1506 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1507 // Needed to make snapped down position match the skin's check of client area
1508 // against realvirtual
1511 SNAPDOWN(stepX, textCellW);
1512 SNAPDOWN(stepY, textCellH);
1513 stepX = Max(stepX, textCellW);
1514 stepY = Max(stepY, textCellH);
1516 if(parent.scrollFlags.snapX)
1518 if(parent.scrollFlags.snapY)
1520 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1522 parent.reqScrollArea.w = w;
1523 parent.reqScrollArea.h = h;*/
1525 // parent.UpdateScrollBars(true, true);
1526 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1527 false, true, true, true, false, false);
1532 GetRidOfVirtualArea();
1536 UpdateScrollBars(modifyThisArea, false);
1537 else if(guiApp.currentSkin)
1540 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1542 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1543 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1544 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1545 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1548 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1549 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1551 absPosition = scrolledPos;
1552 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1553 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1555 if(this != guiApp.desktop && parent)
1557 absPosition.x += parent.absPosition.x;
1558 absPosition.y += parent.absPosition.y;
1559 if(!style.nonClient && this != guiApp.desktop)
1561 absPosition.x += parent.clientStart.x;
1562 absPosition.y += parent.clientStart.y;
1566 box = Box { 0, 0, size.w - 1, size.h - 1 };
1571 // Clip against parent's client area
1572 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1574 // Compute client area in this window coordinate system
1575 clientArea.left = 0;
1577 clientArea.right = clientSize.w - 1;
1578 clientArea.bottom = clientSize.h - 1;
1580 // Clip against parent's client area
1582 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1586 //absPosition.x -= parent.clientStart.x;
1587 //absPosition.y -= parent.clientStart.y;
1590 // Adjust all children
1591 for(child = children.first; child; child = child.next)
1592 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1594 UpdateCaret(false, false);
1597 void GetRidOfVirtualArea(void)
1599 if(parent && !parent.destroyed && style.fixed &&
1600 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1601 parent.reqScrollArea.w && parent.reqScrollArea.h)
1603 if(!parent.noAutoScrollArea)
1607 for(child = children.first; child; child = child.next)
1609 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1611 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1612 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1621 Window parent = this.parent;
1623 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1624 false, true, true, true, false, false);
1626 parent.SetScrollArea(0,0,true);
1627 parent.SetScrollPosition(0,0);
1633 public void ExternalPosition(int x, int y, int w, int h)
1635 Position(x, y, w, h, false, true, true, true, false, false);
1638 // (w, h): Full window size
1639 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1641 bool result = false;
1642 int oldCW = clientSize.w, oldCH = clientSize.h;
1643 bool clientResized, windowResized, windowMoved;
1645 bool realResized = size.w != w || size.h != h;
1647 // TOCHECK: This wasn't in ecere.dll
1648 //if(!parent) return true;
1649 if(destroyed) return false;
1651 windowMoved = position.x != x || position.y != y || force;
1653 // windowResized = realResized || force;
1654 windowResized = size.w != w || size.h != h || force;
1656 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1662 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1663 scrolledPos.x - parent.clientStart.x + this.box.right,
1664 scrolledPos.y - parent.clientStart.y + this.box.bottom
1670 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1675 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1677 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1678 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1679 windowResized = true;
1681 if(display && rootWindow != this)
1684 if(guiApp && guiApp.windowMoving)
1686 if(guiApp.windowMoving.style.nonClient)
1687 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1689 guiApp.windowMoving.parent.SetMouseRangeToClient();
1699 // Buttons bitmap resources crash if we do this while switching mode
1700 if(!guiApp || !guiApp.modeSwitching)
1703 // Process Anchored Children
1707 for(child = children.first; child; child = child.next)
1710 ((child.stateAnchor.left.type != offset ||
1711 child.stateAnchor.top.type != offset ||
1712 child.stateAnchor.right.type != none ||
1713 child.stateAnchor.bottom.type != none) ||
1714 child.state == maximized || child.state == minimized))
1716 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1718 // child.Position(x, y, w, h, false, true, true, true, false);
1719 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1720 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1726 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1727 //if(updateScrollBars)
1729 OnResize(clientSize.w, clientSize.h);
1731 if((clientResized || windowMoved) && created)
1732 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1734 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1736 Window master = guiApp.interimWindow.master;
1737 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1740 if(rootWindow == this && !is3D)
1744 x -= guiApp.desktop.absPosition.x;
1745 y -= guiApp.desktop.absPosition.y;
1747 //guiApp.Log("Position %s\n", caption);
1750 if(windowResized || windowMoved)
1751 if(display && !display.flags.memBackBuffer && changeRootWindow)
1752 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1754 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1755 for(child = parent.children.first; child && child != this; child = child.next)
1756 if(child.rootWindow)
1757 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1762 if(windowMoved || windowResized)
1764 display.Lock(true /*false*/);
1767 display.Position(absPosition.x, absPosition.y);
1768 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1771 // result = realResized ? display.Resize(size.w, size.h) : true;
1772 if(nativeDecorations && rootWindow.windowHandle)
1774 int w = clientSize.w, h = clientSize.h;
1775 if(hasMenuBar) h += skinMenuHeight;
1776 if(hasStatusBar) h += statusBarHeight;
1777 if(sbv && sbv.visible) w += sbv.size.w;
1778 if(sbh && sbh.visible) h += sbh.size.h;
1779 result = manageDisplay ? display.Resize(w, h) : true;
1782 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1786 else if(clientResized)
1788 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1791 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1795 if(windowMoved || windowResized)
1800 if(guiApp.driver && changeRootWindow && windowHandle)
1802 if(windowResized || windowMoved)
1803 if(!display || display.flags.memBackBuffer)
1804 guiApp.interfaceDriver.PositionRootWindow(this,
1805 x, y, w, h, windowMoved, windowResized);
1806 guiApp.interfaceDriver.UpdateRootWindow(this);
1808 for(child = children.first; child; child = child.next)
1810 if(child.is3D && child.created)
1812 // Copy Display Content
1813 child.display.displaySystem = display.displaySystem;
1814 child.display.window = display.window;
1815 child.display.current = display.current;
1816 child.display.width = display.width;
1817 child.display.height = display.height;
1818 child.display.driverData = display.driverData;
1819 child.display.mutex = null;
1830 void UpdateScrollBars(bool flag, bool fullThing)
1833 bool resizeH = false, resizeV = false;
1834 bool scrolled = false;
1835 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1836 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1838 if(destroyed) return;
1839 if(guiApp.currentSkin)
1841 MinMaxValue cw = 0, ch = 0;
1842 bool sbvVisible, sbhVisible;
1844 int positionH, positionV;
1846 // First get client area with no respect to scroll bars
1851 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1853 if(scrollFlags.dontHide)
1856 cw -= guiApp.currentSkin.VerticalSBW();
1858 ch -= guiApp.currentSkin.HorizontalSBH();
1860 // Update the scrollbar visibility
1866 sbh.disabled = rangeH <= 1;
1867 if(sbh.style.hidden)
1877 sbv.disabled = rangeV <= 1;
1878 if(sbv.style.hidden)
1886 int oldHRange = sbh ? sbh.range : 0;
1887 int oldVRange = sbv ? sbv.range : 0;
1888 // Then start off with horizontal scrollbar range
1891 positionH = sbh.thumbPosition;
1898 SBSetTotal(sbh, rvw);
1901 ch -= guiApp.currentSkin.HorizontalSBH();
1904 // Do the same for vertical scrollbar
1907 positionV = sbv.thumbPosition;
1913 SBSetTotal(sbv, rvh);
1917 cw -= guiApp.currentSkin.VerticalSBW();
1918 // Maybe we need to set the range on the horizontal scrollbar again
1926 SBSetTotal(sbh, rvw);
1927 //sbh.Action(setRange, positionH, 0);
1928 if(rangeH <= 1 && sbh.range > 1)
1930 ch -= guiApp.currentSkin.HorizontalSBH();
1936 SBSetTotal(sbv, rvh);
1938 //sbv.Action(setRange, positionV, 0);
1943 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1944 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1947 // Update the scrollbar visibility
1948 if(!scrollFlags.dontHide)
1950 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1954 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1961 if(guiApp.currentSkin)
1968 sbhVisible = sbh.style.hidden ? true : false;
1970 sbvVisible = sbv.style.hidden ? true : false;
1972 // Do our resize here
1973 if(flag && (resizeH || resizeV) && fullThing)
1975 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1980 OnResize(clientSize.w, clientSize.h);
1986 sbh.visible = sbhVisible;
1988 sbv.visible = sbvVisible;
1990 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1991 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1994 sbh.pageStep = clientSize.w;
1996 sbv.pageStep = clientSize.h;
1998 // Notify doesn't handle setRange anymore... process it here
2001 int positionH = sbh.thumbPosition;
2002 if(scroll.x != positionH)
2004 OnHScroll(setRange, positionH, 0);
2008 SNAPDOWN(positionH, textCellW);
2009 scroll.x = positionH;
2015 int seen = clientSize.w, total = reqScrollArea.w;
2018 if(scrollFlags.snapX)
2019 SNAPDOWN(seen, sbStep.x);
2021 if(!total) total = seen;
2022 range = total - seen + 1;
2024 range = Max(range, 1);
2026 if(x >= range) x = range - 1;
2028 if(scrollFlags.snapX)
2029 SNAPUP(x, sbStep.x);
2033 OnHScroll(setRange, x, 0);
2038 SNAPDOWN(x, textCellW);
2044 int positionV = sbv.thumbPosition;
2045 if(scroll.y != positionV)
2047 OnVScroll(setRange, positionV, 0);
2051 SNAPDOWN(positionV, textCellH);
2052 scroll.y = positionV;
2058 int seen = clientSize.h, total = reqScrollArea.h;
2061 if(scrollFlags.snapY)
2062 SNAPDOWN(seen, sbStep.y);
2064 if(!total) total = seen;
2065 range = total - seen + 1;
2066 range = Max(range, 1);
2068 if(y >= range) y = range - 1;
2070 if(scrollFlags.snapY)
2071 SNAPUP(y, sbStep.y);
2075 OnVScroll(setRange, y, 0);
2080 SNAPDOWN(y, textCellH);
2086 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2089 for(child = children.first; child; child = child.next)
2091 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2094 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2095 child.Position(x, y, w, h, false, true, false, true, false, false);
2102 // Process Scrollbars
2104 if(sbh) // && !sbh.style.hidden
2107 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2108 // Need to set the range again (should improve...) since the scrollbars didn't have
2109 // the right size when UpdateScrollArea set the range on it
2112 sbh.seen = clientSize.w;
2116 if(sbv) // && !sbv.state.hidden
2119 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2120 // Need to set the range again (should improve...) since the scrollbars didn't have
2121 // the right size when UpdateScrollArea set the range on it
2124 sbv.seen = clientSize.h;
2129 // TESTING THIS LOWER
2130 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2133 for(child = children.first; child; child = child.next)
2135 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2138 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2139 child.Position(x, y, w, h, false, true, false, true, false, false);
2145 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2147 SetState(maximized, false, mods);
2151 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2153 SetState(normal, false, mods);
2157 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2159 SetState(minimized, false, mods);
2160 parent.CycleChildren(false, true, false, true);
2164 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2167 // Scroll bar notifications
2168 if(action != setRange)
2170 bool changed = false;
2174 if(scroll.x != position)
2176 OnHScroll(action, position, keyFlags);
2181 SNAPDOWN(position, textCellW);
2183 scroll.x = position;
2187 if(scroll.y != position)
2189 OnVScroll(action, position, keyFlags);
2194 SNAPDOWN(position, textCellH);
2196 scroll.y = position;
2200 bool childMove = false;
2201 for(child = children.first; child; child = child.next)
2203 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2206 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2207 child.Position(x, y, w, h, false, true, false, true, false, false);
2211 // Testing this patch out to solve MDI workspace redraw bugs
2212 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2213 // Scroll offsets to blame?
2217 UpdateCaret(false, false);
2221 // Testing this patch out to solve MDI workspace redraw bugs
2222 for(child = children.first; child; child = child.next)
2224 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2233 Window GetParentMenuBar()
2235 Window menuBarParent;
2236 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2238 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2239 if(menuBarParent && !menuBarParent.isActiveClient)
2245 void CreateSystemChildren(void)
2247 Window parent = this;
2248 bool scrollBarChanged = false;
2249 bool hasClose = false, hasMaxMin = false;
2250 Point scroll = this.scroll;
2252 if(state == maximized)
2254 parent = GetParentMenuBar();
2255 if(!parent && nativeDecorations)
2256 parent = rootWindow;
2261 if(style.hasClose) hasClose = true;
2262 if(style.hasMaximize || style.hasMinimize)
2269 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2271 sysButtons[2].Destroy(0);
2272 sysButtons[2] = null;
2274 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2276 sysButtons[1].Destroy(0);
2277 sysButtons[1] = null;
2279 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2281 sysButtons[0].Destroy(0);
2282 sysButtons[0] = null;
2285 if(hasClose && parent)
2292 parent, master = this,
2293 inactive = true, nonClient = true, visible = false;
2295 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2301 if(this.parent == guiApp.desktop)
2302 sysButtons[2].hotKey = altF4;
2303 else if(style.isActiveClient)
2304 sysButtons[2].hotKey = ctrlF4;
2305 sysButtons[2].Create();
2308 sysButtons[2].symbol = 'X';
2309 sysButtons[2].disabled = !style.hasClose;
2312 if(hasMaxMin && parent)
2316 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2317 if(state == maximized)
2320 method = RestoreButtonClicked;
2326 method = MaximizeButtonClicked;
2334 parent, master = this,
2335 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2337 sysButtons[1].Create();
2339 sysButtons[1].NotifyClicked = method;
2341 sysButtons[1].symbol = symbol;
2342 sysButtons[1].disabled = !style.hasMaximize;
2345 if(hasMaxMin && parent)
2349 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2350 if (state == minimized)
2353 method = RestoreButtonClicked;
2359 method = MinimizeButtonClicked;
2367 parent, master = this,
2368 hotKey = altM, inactive = true, nonClient = true, visible = false
2370 sysButtons[0].Create();
2372 sysButtons[0].NotifyClicked = method;
2374 sysButtons[0].symbol = symbol;
2375 sysButtons[0].disabled = !style.hasMinimize;
2378 // Create the scrollbars
2379 if(style.hasHorzScroll && !sbh)
2385 direction = horizontal,
2389 snap = scrollFlags.snapX,
2390 NotifyScrolling = ScrollBarNotification
2393 scrollBarChanged = true;
2395 else if(sbh && !style.hasHorzScroll)
2401 if(style.hasVertScroll && !sbv)
2407 direction = vertical,
2411 snap = scrollFlags.snapY,
2412 NotifyScrolling = ScrollBarNotification
2415 scrollBarChanged = true;
2417 else if(sbv && !style.hasVertScroll)
2422 if(scrollBarChanged)
2424 SetScrollLineStep(sbStep.x, sbStep.y);
2425 UpdateScrollBars(true, true);
2429 if(scrollBarChanged)
2431 if(sbh) sbh.thumbPosition = scroll.x;
2432 if(sbv) sbv.thumbPosition = scroll.y;
2436 void UpdateCaption(void)
2438 if(rootWindow == this)
2441 FigureCaption(caption);
2442 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2444 UpdateDecorations();
2447 if(parent.activeClient == this) // Added this last check
2449 if(parent.rootWindow == parent)
2452 parent.FigureCaption(caption);
2453 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2456 parent.UpdateCaption();
2458 parent.UpdateDecorations();
2462 void UpdateActiveDocument(Window previous)
2464 Window activeClient = this.activeClient;
2465 Window activeChild = this.activeChild;
2472 activeClient.CreateSystemChildren();
2474 previous.CreateSystemChildren();
2486 // Build window list
2489 Menu windowMenu = menu.FindMenu("Window");
2494 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2497 Window document = cycle.data;
2498 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2500 char name[2048], caption[2048];
2501 document.FigureCaption(caption);
2502 sprintf(name, "%d %s", id+1, caption);
2503 windowMenu.AddDynamic(MenuItem
2505 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2506 NotifySelect = MenuWindowSelectWindow
2510 if(activeClient.cycle == cycle) break;
2515 if((!previous && activeClient) || !activeClient)
2521 item = menu.FindItem(MenuWindowCloseAll, 0);
2522 if(item) item.disabled = false;
2523 item = menu.FindItem(MenuWindowNext, 0);
2524 if(item) item.disabled = false;
2525 item = menu.FindItem(MenuWindowPrevious, 0);
2526 if(item) item.disabled = false;
2527 item = menu.FindItem(MenuWindowCascade, 0);
2528 if(item) item.disabled = false;
2529 item = menu.FindItem(MenuWindowTileHorz, 0);
2530 if(item) item.disabled = false;
2531 item = menu.FindItem(MenuWindowTileVert, 0);
2532 if(item) item.disabled = false;
2533 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2534 if(item) item.disabled = false;
2535 item = menu.FindItem(MenuWindowWindows, 0);
2536 if(item) item.disabled = false;
2539 item = menu.FindItem(MenuFileClose, 0);
2540 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2541 item = menu.FindItem(MenuFileSaveAll, 0);
2542 if(item) item.disabled = numDocuments < 1;
2544 if(activeClient && activeClient.menu && activeClient.state != minimized)
2548 //activeClient.menu.Clean(activeClient);
2549 menu.Merge(activeClient.menu, true, activeClient);
2553 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2556 menu.Merge(activeChild.menu, true, activeChild);
2559 // This is called again for a child window change, with same active client
2560 OnActivateClient(activeClient, previous);
2561 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2562 parent.UpdateActiveDocument(null);
2565 void _ShowDecorations(Box box, bool post)
2567 if(rootWindow == this && nativeDecorations) return;
2568 if(visible && this != guiApp.desktop)
2570 Surface surface = RedrawFull(box);
2574 FigureCaption(caption);
2577 ShowDecorations(captionFont.font,
2580 active, //parent.activeClient == this
2581 guiApp.windowMoving == this);
2583 PreShowDecorations(captionFont.font,
2586 active, //parent.activeClient == this
2587 guiApp.windowMoving == this);
2594 void UpdateExtent(Box refresh)
2596 Surface surface = null;
2598 if(!manageDisplay) { OnRedraw(null);return; }
2599 _ShowDecorations(refresh, false);
2601 surface = Redraw(refresh);
2602 // Opaque background: just fill before EW_REDRAW (clear?)
2605 surface.SetBackground(background);
2606 surface.SetForeground(foreground);
2607 surface.DrawingChar(' ');
2608 if(this == rootWindow)
2610 if(style.drawBehind || background.a)
2612 int a = background.a;
2613 // Premultiply alpha for clear color
2614 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2615 surface.Clear(colorBuffer);
2616 surface.SetBackground(background);
2619 else if(background.a)
2623 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2624 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2627 if(display.flags.alpha && background.a < 255 && background)
2629 surface.Area(0,0,clientSize.w, clientSize.h);
2630 /*if(style.clearDepthBuffer)
2631 surface.Clear(depthBuffer);*/
2633 else if(/*style.clearDepthBuffer || */background.a)
2635 int a = background.a;
2636 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2637 // Premultiply alpha for clear color
2638 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2639 surface.Clear(colorBuffer);
2640 surface.SetBackground(background);
2645 surface.TextFont(usedFont.font);
2646 surface.TextOpacity(false);
2650 // Draw the caret ...
2651 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2653 // surface.SetBackground(0xFFFFFF - background.color);
2654 surface.SetBackground(~background.color);
2656 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2657 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2663 void DrawOverChildren(Box refresh)
2665 Surface surface = Redraw(refresh);
2669 surface.DrawingChar(' ');
2670 surface.SetBackground(background);
2671 surface.SetForeground(foreground);
2673 surface.TextFont(usedFont.font);
2674 surface.TextOpacity(false);
2676 OnDrawOverChildren(surface);
2681 _ShowDecorations(refresh, true);
2684 void ComputeClipExtents(void)
2687 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2689 clipExtent.Copy(this.clipExtent);
2691 for(child = children.last; child; child = child.prev)
2693 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2695 bool opaque = child.IsOpaque(); // TODO: acess background directly
2696 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2698 child.clipExtent.Copy(clipExtent);
2699 child.clipExtent.Offset(-dx, -dy);
2700 child.clipExtent.IntersectBox(child.box);
2702 child.ComputeClipExtents();
2704 if(opaque && !child.style.nonClient)
2706 // Adjust the box for the parent:
2707 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2708 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2713 // ??? Only do this for overlapped window or if parent has with clip children flag
2715 // Do this if window has clip children flag on (default false?)
2716 // this.clipExtent = clipExtent;
2718 clipExtent.Free(null);
2721 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2723 bool opaque = IsOpaque();
2725 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2726 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2728 offsetX -= rootWindow.clientStart.x;
2729 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2733 for(child = children.last; child; child = child.prev)
2735 ColorAlpha background = *(ColorAlpha *)&child.background;
2736 bool opaque = child.IsOpaque();
2737 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2741 // Adjust renderArea to the root window level
2742 Extent * renderArea = &rootWindow.tempExtents[3];
2744 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2745 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2746 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2748 offsetX -= child.rootWindow.clientStart.x;
2749 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2753 Extent childRenderArea;
2755 if(backBufferUpdate != null)
2757 childRenderArea.Copy(backBufferUpdate);
2758 childRenderArea.Offset(-offsetX, -offsetY);
2761 childRenderArea.Copy(child.dirtyArea);
2763 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2764 renderArea.Copy(dirtyExtent);
2765 renderArea.Offset(-offsetX, -offsetY);
2766 childRenderArea.Union(renderArea);
2769 // Intersect with the clip extent
2770 childRenderArea.Intersection(child.clipExtent);
2773 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2775 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2776 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2778 renderArea->Offset(offsetX, offsetY);
2780 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2781 // overDirtyExtent.Union(renderArea);
2782 renderArea->Empty();
2783 // childRenderArea.Free();
2785 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2790 for(child = children.last; child; child = child.prev)
2792 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2794 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2799 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2801 bool opaque = IsOpaque();
2802 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2804 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2805 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2807 offsetX -= rootWindow.clientStart.x;
2808 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2812 for(child = children.last; child; child = child.prev)
2814 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2816 ColorAlpha background = *(ColorAlpha *)&child.background;
2817 bool opaque = child.IsOpaque();
2818 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2822 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2823 // Adjust renderArea to the root window level
2825 renderArea.Copy(child.dirtyArea);
2826 renderArea.Offset(offsetX, offsetY);
2827 dirtyExtent.Union(renderArea);
2828 overDirtyExtent.Union(renderArea);
2834 for(child = children.last; child; child = child.prev)
2836 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2838 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2842 if(backBufferUpdate != null)
2844 renderArea.Copy(backBufferUpdate);
2845 renderArea.Offset(-offsetX, -offsetY);
2847 overRenderArea.Copy(backBufferUpdate);
2848 overRenderArea.Offset(-offsetX, -offsetY);
2854 renderArea.Copy(dirtyArea);
2856 overRenderArea.Copy(dirtyArea);
2859 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2860 dirtyExtentWindow->Copy(dirtyExtent);
2861 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2862 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2863 dirtyExtentWindow->Empty();
2865 // Intersect with the clip extent
2866 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2869 if(renderArea.count > 10)
2872 printf("\nToo many extents (%d):\n", renderArea.count);
2874 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2875 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2880 for(c = 0; c<10; c++)
2883 FASTLIST_LOOP(renderArea, extentBox)
2885 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2887 renderArea.Copy(extent);
2889 FASTLIST_LOOP(renderArea, extentBox)
2892 printf("(%d, %d) - (%d, %d)\n",
2893 extentBox.box.left, extentBox.box.top,
2894 extentBox.box.right, extentBox.box.bottom);
2898 printf("\nNow %d\n", renderArea.count);
2904 // WHY WAS THIS COMMENTED ??
2906 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2907 dirtyExtentWindow->Copy(overDirtyExtent);
2908 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2909 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2910 dirtyExtentWindow->Empty();
2912 // Intersect with the clip extent
2913 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2919 if(scrollExtent.count)
2921 // Subtract render extent from scrolling extent
2922 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2924 if(backBufferUpdate == null)
2926 Extent * dirty = &rootWindow.tempExtents[3];
2929 // Intersect scrolling extent with clip extent
2930 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2932 // offset this scroll to be at the root window level
2933 scrollExtent.Offset(offsetX, offsetY);
2934 // Add area that was scrolled to the dirty extents of the back buffer
2935 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2939 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2940 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2941 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2946 scrollExtent.Empty();
2948 // Add the exposed extent to the window render area
2949 dirty->Offset(-offsetX, -offsetY);
2950 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2955 // Subtract the window's box from the transparency forced extent
2956 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2962 renderArea.Copy(this.renderArea);
2963 renderArea.Offset(offsetX, offsetY);
2964 dirtyExtent.Union(renderArea);
2970 Extent renderArea { };
2972 renderArea.Copy(overRenderArea);
2973 renderArea.Offset(offsetX, offsetY);
2974 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2979 if(backBufferUpdate != null)
2981 // Remove render area from dirty area
2982 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2984 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2991 // Remove the window render area from the dirty extents of the back buffer
2992 rootWindow.dirtyBack.Exclusion(renderArea);
2996 void Render(Extent updateExtent)
3000 Window rootWindow = this.rootWindow;
3001 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3002 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3004 offsetX -= rootWindow.clientStart.x;
3005 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3008 if(rootWindow.fullRender)
3017 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3018 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3023 /*if(renderArea.count)
3024 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3027 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3029 Box box = extentBox.box;
3032 /*printf("(%d, %d) - (%d, %d)\n",
3033 extentBox.box.left, extentBox.box.top,
3034 extentBox.box.right, extentBox.box.bottom);*/
3039 box.left += offsetX;
3041 box.right += offsetX;
3042 box.bottom += offsetY;
3044 if(updateExtent != null)
3045 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3049 for(child = children.first; child; child = child.next)
3050 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3051 child.Render(updateExtent);
3053 if(rootWindow.fullRender)
3054 DrawOverChildren(box);
3057 // TO DO: There's an issue about draw over children...
3058 // TO DO: Don't wanna go through this if method isn't used
3059 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3060 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3062 Box box = extentBox.box;
3064 DrawOverChildren(box);
3066 box.left += offsetX;
3068 box.right += offsetX;
3069 box.bottom += offsetY;
3071 if(updateExtent != null)
3072 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3075 for(child = children.first; child; child = child.next)
3076 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3077 child.Render(updateExtent);
3080 overRenderArea.Empty();
3083 public void UpdateDisplay(void)
3085 if(!manageDisplay) { OnRedraw(null);return; }
3086 if(rootWindow && this != rootWindow)
3087 rootWindow.UpdateDisplay();
3090 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3091 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3094 dirtyExtent.Clear();
3097 clipExtent.AddBox(box);
3099 display.StartUpdate();
3101 if(!rootWindow.fullRender)
3103 ComputeClipExtents();
3104 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3105 ComputeRenderArea(dirtyExtent, overExtent, null);
3108 clipExtent.Free(null);
3110 dirtyExtent.Free(null);
3111 overExtent.Free(null);
3113 if(display.flags.flipping)
3116 display.Update(null);
3120 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3121 updateExtent.Clear();
3123 Render(updateExtent);
3125 updateExtent.UnionBox(this.box, tempExtents[0]);
3128 //printf("\n\nUpdate:\n------------------------------------------\n");
3131 //FASTLIST_LOOP(updateExtent, extentBox)
3132 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3135 /*printf("Updating (%d, %d) - (%d, %d)\n",
3136 extentBox.box.left, extentBox.box.top,
3137 extentBox.box.right, extentBox.box.bottom);*/
3140 display.Update(extentBox.box);
3143 updateExtent.Free(null);
3146 display.EndUpdate();
3154 void UpdateBackDisplay(Box box)
3160 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3162 //printf("UpdateBackDisplay going through!\n");
3163 display.StartUpdate();
3167 intersection.Copy(dirtyBack);
3168 intersection.IntersectBox(box);
3170 dirtyExtent.Clear();
3173 clipExtent.AddBox(box);
3175 if(!rootWindow.fullRender)
3177 ComputeClipExtents();
3178 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3181 clipExtent.Free(null);
3183 intersection.Free(null);
3184 dirtyExtent.Free(null);
3185 overExtent.Free(null);
3190 if(display.flags.flipping)
3191 display.Update(null);
3194 rootWindow.display.Update(box);
3197 display.EndUpdate();
3201 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3202 if(dirtyBack.count > MAX_DIRTY_BACK)
3204 BoxItem extentBox, next;
3205 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3206 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3208 next = (BoxItem)extentBox.next;
3209 if(extentBox != first)
3211 if(extentBox.box.left < first.box.left)
3212 first.box.left = extentBox.box.left;
3213 if(extentBox.box.top < first.box.top)
3214 first.box.top = extentBox.box.top;
3215 if(extentBox.box.right > first.box.right)
3216 first.box.right = extentBox.box.right;
3217 if(extentBox.box.bottom > first.box.bottom)
3218 first.box.bottom = extentBox.box.bottom;
3219 dirtyBack.Delete(extentBox);
3228 // --- Window positioning ---
3229 // --- Window identification ---
3231 // Returns window at position "Position"
3232 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3234 Window child, result = null;
3236 box.left += absPosition.x;
3237 box.right += absPosition.x;
3238 box.top += absPosition.y;
3239 box.bottom += absPosition.y;
3241 if(!destroyed && visible && (acceptDisabled || !disabled))
3243 int lx = x - absPosition.x;
3244 int ly = y - absPosition.y;
3245 if(IsInside(lx, ly))
3246 // if(box.IsPointInside(Point{x, y}))
3248 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3249 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3252 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3253 Window ancestor = null;
3255 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3256 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3257 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3259 if(child != statusBar && child.rootWindow == rootWindow)
3261 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3268 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3269 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3271 if(child != statusBar && child.rootWindow == rootWindow)
3273 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3280 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3288 Window FindModal(void)
3290 Window modalWindow = this, check;
3291 Window check2 = null;
3292 for(check = this; check.master; check = check.master)
3294 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3296 modalWindow = check.master.modalSlave;
3297 check = modalWindow;
3299 // TESTING THIS FOR DROPBOX...
3300 if(!rootWindow || !rootWindow.style.interim)
3302 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3304 if(check2.modalSlave && check2.modalSlave.created)
3306 modalWindow = check2.modalSlave;
3314 if(modalWindow == this)
3316 for(check = this; check.activeChild; check = check.activeChild)
3318 if(check.modalSlave)
3320 modalWindow = check.modalSlave;
3326 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3327 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3330 void StopMoving(void)
3332 if(this == guiApp.windowMoving)
3334 guiApp.windowMoving = null;
3335 UpdateDecorations();
3336 SetMouseRange(null);
3339 if(rootWindow.active)
3340 guiApp.interfaceDriver.StopMoving(rootWindow);
3343 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3344 guiApp.windowIsResizing = false;
3348 void SelectMouseCursor(void)
3353 Window cursorWindow = null;
3354 bool rx, ry, rex, rey;
3356 guiApp.desktop.GetMousePosition(&x, &y);
3357 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3359 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3360 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3361 else if(mouseWindow)
3363 modalWindow = mouseWindow.FindModal();
3364 x -= mouseWindow.absPosition.x;
3365 y -= mouseWindow.absPosition.y;
3366 if(guiApp.windowIsResizing)
3368 rex = guiApp.resizeEndX;
3369 rey = guiApp.resizeEndY;
3370 rx = guiApp.resizeX;
3371 ry = guiApp.resizeY;
3372 if((rex && rey) || (rx && ry))
3373 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3374 else if((rex && ry) || (rx && rey))
3375 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3376 else if((ry || rey) && (!rx && !rex))
3377 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3378 else if((rx || rex) && (!ry && !rey))
3379 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3381 else if(!modalWindow && !guiApp.windowCaptured &&
3382 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3383 &rx, &ry, &rex, &rey))
3385 if((rex && rey) || (rx && ry))
3386 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3387 else if((rex && ry) || (rx && rey))
3388 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3389 else if((ry || rey) && (!rx && !rex))
3390 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3391 else if((rx || rex) && (!ry && !rey))
3392 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3394 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3396 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3397 cursorWindow = mouseWindow.parent;
3399 cursorWindow = mouseWindow;
3401 else if(!guiApp.interimWindow)
3402 cursorWindow = guiApp.windowCaptured;
3405 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3406 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3408 else if(modalWindow)
3410 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3412 else if(guiApp.interimWindow)
3414 if(guiApp.interimWindow.cursor)
3415 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3417 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3422 // --- State based input ---
3423 bool AcquireInputEx(bool state)
3428 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3429 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3431 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3433 guiApp.acquiredWindow = state ? this : null;
3436 SetMouseRangeToClient();
3437 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3442 SelectMouseCursor();
3444 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3448 // --- Window activation ---
3449 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3452 if(!parent || !parent.style.inactive)
3454 Window parent = this.parent;
3457 if(rootWindow == this)
3458 Log(active ? "active\n" : "inactive\n");
3461 // Testing this here...
3462 if(!parent || parent == guiApp.desktop || parent.active)
3464 this.active = active;
3467 // TESTING THIS HERE
3468 UpdateDecorations();
3469 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3470 result = NotifyActivate(master, this, active, previous);
3473 this.active = !active;
3478 if(!parent || parent == guiApp.desktop || parent.active)
3480 this.active = active;
3482 AcquireInputEx(active);
3487 if(guiApp.caretOwner)
3491 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3492 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3493 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3494 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3496 guiApp.caretOwner.Update(extent);
3499 if(visible || !guiApp.caretOwner)
3500 guiApp.caretOwner = this;
3501 UpdateCaret(false, false);
3507 this.active = false;
3509 AcquireInputEx(active);
3511 if(!active && guiApp.caretOwner == this)
3513 UpdateCaret(false, true);
3514 guiApp.caretOwner = null;
3515 guiApp.interfaceDriver.SetCaret(0,0,0);
3516 guiApp.caretEnabled = false;
3521 if(!active && parent && parent.activeChild && parent.activeChild != this)
3522 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3528 if(!active && menuBar)
3531 menuBar.OnActivate(false, null, &goOn, true);
3532 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3537 Window aChild = activeChild;
3539 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3551 void ConsequentialMouseMove(bool kbMoving)
3555 if(kbMoving || !guiApp.windowMoving)
3559 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3561 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3563 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3564 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3570 bool IsDescendantOf(Window ancestor)
3573 for(window = this; window && window != ancestor; window = window.parent);
3574 return window == ancestor;
3577 bool IsSlaveOf(Window master)
3580 for(window = this; window && window != master; window = window.master);
3581 return window == master;
3584 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3588 if(this && !destroyed /*&& state != Hidden*/)
3590 Window swap = externalSwap;
3598 if(activateParent &&
3599 (parent.activeChild != this ||
3600 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3601 active && _isModal &&
3602 parent != master && master)
3603 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3609 bool real = parent.activeChild != this;
3611 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3612 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3613 !IsDescendantOf(guiApp.interimWindow) &&
3614 !IsSlaveOf(guiApp.interimWindow))
3616 Window interimWindow = guiApp.interimWindow;
3617 while(interimWindow && interimWindow != this)
3619 Window master = interimWindow.master;
3621 guiApp.interimWindow = null;
3622 if(guiApp.caretOwner)
3623 guiApp.caretOwner.UpdateCaret(false, false);
3625 incref interimWindow;
3626 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3631 delete interimWindow;
3632 interimWindow = (master && master.style.interim) ? master : null;
3637 guiApp.interimWindow = this;
3638 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3639 guiApp.caretEnabled = false;*/
3640 UpdateCaret(false, true);
3645 bool acquireInput = false;
3647 parent.activeChild &&
3648 parent.activeChild.state == maximized &&
3649 parent != guiApp.desktop;
3651 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3656 swap = parent.activeChild;
3657 if(swap && swap.destroyed) swap = null;
3658 if(swap && swap != this)
3661 if(!swap.PropagateActive(false, this, &goOn, true))
3662 swap = parent.activeChild;
3673 if(!parent || parent.activeChild != this || style.interim)
3676 result = PropagateActive(true, swap, &goOn, true);
3677 if(!result && !goOn)
3682 acquireInput = true;
3686 if(style.hasMaximize && parent != guiApp.desktop)
3689 SetState(maximized, false, 0);
3690 else if(state != maximized)
3693 for(child = parent.children.first; child; child = child.next)
3695 if(this != child && child.state == maximized)
3696 child.SetState(normal, false, 0);
3703 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3705 Window previous = parent.activeClient;
3706 parent.activeChild = this;
3707 if(!style.nonClient /*&& style.isActiveClient*/)
3711 if(style.isActiveClient)
3712 parent.activeClient = this;
3713 // Moved UpdateActiveDocument inside hidden check
3714 // To prevent activating previous window while creating a new one
3715 // (It was messing up the privateModule in the CodeEditor)
3716 parent.UpdateActiveDocument(previous);
3722 //if(!style.isRemote)
3724 if(rootWindow != this)
3726 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3727 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3729 else if(!guiApp.fullScreenMode)
3731 Window modalRoot = FindModal();
3732 if(!modalRoot) modalRoot = this;
3733 if(!modalRoot.isForegroundWindow)
3735 modalRoot.isForegroundWindow = true;
3736 // To check : Why is parent null?
3737 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3739 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3741 modalRoot.isForegroundWindow = false;
3746 if(result && real && (!style.inactive || moveInactive) && parent)
3748 Window last = parent.children.last;
3750 if(!style.stayOnTop)
3751 for(; last && last.style.stayOnTop; last = last.prev);
3753 parent.children.Move(this, last);
3755 // Definitely don't want that: why not?
3759 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3765 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3772 parent.activeChild = null;
3773 if(!style.nonClient /*&& style.isActiveClient*/)
3775 Window previous = parent.activeClient;
3776 if(style.isActiveClient)
3777 parent.activeClient = null;
3778 parent.UpdateActiveDocument(previous);
3782 if(this == guiApp.interimWindow)
3784 guiApp.interimWindow = null;
3785 if(guiApp.caretOwner)
3786 guiApp.caretOwner.UpdateCaret(false, false);
3788 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3795 if(!active || !swap)
3796 UpdateDecorations();
3798 swap.UpdateDecorations();
3800 if(active && rootWindow != this)
3801 ConsequentialMouseMove(false);
3808 // --- Input Messages ---
3809 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3811 static bool reEntrancy = false;
3812 if(reEntrancy) return;
3816 guiApp.cursorUpdate = true;
3817 if(guiApp.windowScrolling && !consequential)
3819 guiApp.windowScrolling.SetScrollPosition(
3820 (guiApp.windowScrolling.sbh) ?
3821 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3822 (guiApp.windowScrolling.sbv) ?
3823 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3825 if(guiApp.windowMoving)
3827 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3829 Window window = guiApp.windowMoving;
3831 int w = window.size.w;
3832 int h = window.size.h;
3837 rx = mouseX - guiApp.windowMovingStart.x;
3838 ry = mouseY - guiApp.windowMovingStart.y;
3841 window.GetDecorationsSize(&ew, &eh);
3843 if(guiApp.windowIsResizing)
3845 x = window.scrolledPos.x;
3846 y = window.scrolledPos.y;
3850 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3851 rx = guiApp.windowResizingBefore.w - aw;
3852 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3853 w = guiApp.windowResizingBefore.w - rx;
3857 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3858 ry = guiApp.windowResizingBefore.h - ah;
3859 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3860 ry = Max(ry, -guiApp.windowMovingBefore.y);
3861 h = guiApp.windowResizingBefore.h - ry;
3863 if(guiApp.resizeEndX)
3865 w = guiApp.windowResizingBefore.w + rx;
3868 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3876 w = Max(w, window.minSize.w);
3877 h = Max(h, window.minSize.h);
3878 w = Min(w, window.maxSize.w);
3879 h = Min(h, window.maxSize.h);
3881 if(!window.OnResizing(&w, &h))
3883 w = window.clientSize.w;
3884 h = window.clientSize.h;
3887 w = Max(w, window.skinMinSize.w);
3888 h = Max(h, window.skinMinSize.h);
3895 SNAPDOWN(w, textCellW);
3896 SNAPDOWN(h, textCellH);
3901 aw = Max(w,window.skinMinSize.w);
3902 rx = guiApp.windowResizingBefore.w - aw;
3903 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3904 w = guiApp.windowResizingBefore.w - rx;
3908 ah = Max(h,window.skinMinSize.h);
3909 ry = guiApp.windowResizingBefore.h - ah;
3910 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3911 ry = Max(ry, -guiApp.windowMovingBefore.y);
3912 h = guiApp.windowResizingBefore.h - ry;
3917 if(!guiApp.windowIsResizing || guiApp.resizeX)
3918 x = guiApp.windowMovingBefore.x + rx;
3919 if(!guiApp.windowIsResizing || guiApp.resizeY)
3920 y = guiApp.windowMovingBefore.y + ry;
3922 if(!guiApp.windowIsResizing)
3925 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3927 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3928 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3929 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3930 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3934 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3935 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3941 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3943 if(!window.OnMoving(&x, &y, w, h))
3945 x = window.scrolledPos.x;
3946 y = window.scrolledPos.y;
3952 SNAPDOWN(x, textCellW);
3953 SNAPDOWN(y, textCellH);
3956 if(!window.style.nonClient)
3958 if(!window.style.fixed /*|| window.style.isDocument*/)
3960 if(!window.style.dontScrollHorz)
3961 x += window.parent.scroll.x;
3962 if(!window.style.dontScrollVert)
3963 y += window.parent.scroll.y;
3967 // Break the anchors for moveable/resizable windows
3968 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3969 if(window.style.fixed)
3971 if(window.state == normal)
3973 window.normalAnchor = Anchor { left = x, top = y };
3974 window.normalSizeAnchor = SizeAnchor { { w, h } };
3975 window.anchored = false;
3979 window.stateAnchor = Anchor { left = x, top = y };
3980 window.stateSizeAnchor = SizeAnchor { { w, h } };
3982 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3983 // TOCHECK: Investigate why the following only redraws the scrollbars
3984 //window.Position(x, y, w, h, false, true, true, true, false, true);
3986 guiApp.movingLast.x = mouseX;
3987 guiApp.movingLast.y = mouseY;
3993 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3996 bool wasMoving = guiApp.windowMoving ? true : false;
3997 bool wasScrolling = guiApp.windowScrolling ? true : false;
3999 while(result && w != this)
4001 Window msgWindow = GetAtPosition(x,y, false, true, w);
4002 Window trueWindow = GetAtPosition(x,y, false, false, w);
4003 bool windowDragged = false;
4008 window = (w && !w.disabled) ? w : null;
4010 if(trueWindow) incref trueWindow;
4012 if(consequential) mods->isSideEffect = true;
4014 UpdateMouseMove(x, y, consequential);
4016 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4018 if(!guiApp.windowCaptured.isEnabled)
4019 guiApp.windowCaptured.ReleaseCapture();
4021 window = guiApp.windowCaptured;
4024 if(trueWindow && activate &&
4025 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4026 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4027 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4028 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4030 if(mods->alt && !mods->ctrl && !mods->shift)
4032 Window moved = trueWindow;
4033 for(moved = trueWindow; moved; moved = moved.parent)
4034 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4039 windowDragged = true;
4041 // Cancel the ALT menu toggling...
4042 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4047 if(window && activate &&
4048 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4049 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4050 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4051 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4053 Window modalWindow = window.FindModal();
4055 /*if(mods->alt && !mods->shift && !mods->ctrl)
4057 Window moved = window;
4058 for(moved = window; moved; moved = moved.parent)
4059 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4064 windowDragged = true;
4066 // Cancel the ALT menu toggling...
4067 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4073 Window activateWindow = modalWindow ? modalWindow : window;
4074 if(activateWindow && !activateWindow.isRemote)
4076 bool doActivation = true;
4077 //bool needToDoActivation = false;
4078 Window check = activateWindow;
4080 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4082 if(!check.style.inactive)
4084 //needToDoActivation = true;
4086 doActivation = false;
4091 if(!needToDoActivation)
4092 doActivation = false;
4095 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4096 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4098 // Let the OnLeftButtonDown do the activating instead
4099 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4107 incref activateWindow;
4108 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4110 delete activateWindow;
4114 if(activateWindow._refCount == 1)
4116 delete activateWindow;
4120 delete activateWindow;
4121 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4124 mods->isActivate = true;
4128 if(!modalWindow && window && !window.destroyed)
4130 if(!guiApp.windowCaptured || windowDragged)
4132 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4134 bool moving = ((window.state != maximized &&
4135 window.IsMouseMoving(
4136 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4137 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4139 if(!moving && window.IsMouseResizing(
4140 x - window.absPosition.x,
4141 y - window.absPosition.y,
4142 window.size.w, window.size.h,
4143 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4145 guiApp.windowIsResizing = true;
4146 guiApp.windowResizingBefore.w = window.size.w;
4147 guiApp.windowResizingBefore.h = window.size.h;
4149 if(guiApp.windowIsResizing || windowDragged || moving)
4152 guiApp.windowMoving = window;
4153 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4154 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4155 guiApp.windowMovingBefore.x = window.position.x;//s;
4156 guiApp.windowMovingBefore.y = window.position.y;//s;
4157 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4158 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4161 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4163 if(window.style.fixed &&
4165 window.IsMouseMoving(
4166 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4168 window.ShowSysMenu(x, y);
4172 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4174 if(window.sbv || window.sbh)
4177 guiApp.windowScrolling = window;
4178 guiApp.windowScrollingStart.x = x;
4179 guiApp.windowScrollingStart.y = y;
4180 guiApp.windowScrollingBefore.x = window.scroll.x;
4181 guiApp.windowScrollingBefore.y = window.scroll.y;
4184 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4186 if(window.style.hasMaximize &&
4187 window.IsMouseMoving(
4188 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4191 (window.state == maximized) ? normal : maximized, false, *mods);
4199 if(guiApp.windowMoving)
4201 if(guiApp.windowMoving.parent)
4203 if(guiApp.windowMoving.style.nonClient)
4204 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4206 guiApp.windowMoving.parent.SetMouseRangeToClient();
4210 window.UpdateDecorations();
4213 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4215 // Log("\n*** LEFT BUTTON UP ***\n");
4216 if(guiApp.windowMoving)
4217 guiApp.windowMoving.StopMoving();
4219 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4221 if(guiApp.windowScrolling)
4223 Window windowScrolling = guiApp.windowScrolling;
4224 guiApp.windowScrolling = null;
4225 windowScrolling.ReleaseCapture();
4229 if(!result || (window && window.destroyed)) window = null;
4231 if(window && window.FindModal())
4234 if(trueWindow && trueWindow.FindModal())
4242 msgWindow = GetAtPosition(x,y, true, false);
4244 msgWindow.SelectMouseCursor();
4247 if(guiApp.windowCaptured || trueWindow)
4249 Window prevWindow = guiApp.prevWindow;
4250 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4252 guiApp.prevWindow.mouseInside = false;
4253 guiApp.prevWindow = null;
4255 // Eventually fix this not to include captured?
4256 if(!prevWindow.OnMouseLeave(*mods))
4259 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4261 Box box = trueWindow.box;
4262 box.left += trueWindow.absPosition.x;
4263 box.right += trueWindow.absPosition.x;
4264 box.top += trueWindow.absPosition.y;
4265 box.bottom += trueWindow.absPosition.y;
4267 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4269 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4270 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4272 overX = Max(Min(overX, 32767),-32768);
4273 overY = Max(Min(overY, 32767),-32768);
4275 trueWindow.mouseInside = true;
4276 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4280 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4281 guiApp.prevWindow = trueWindow;
4283 guiApp.prevWindow = null;
4285 SelectMouseCursor();
4287 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4289 int clientX = x - (window.absPosition.x + window.clientStart.x);
4290 int clientY = y - (window.absPosition.y + window.clientStart.y);
4292 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4294 clientX = Max(Min(clientX, 32767),-32768);
4295 clientY = Max(Min(clientY, 32767),-32768);
4297 MouseMethod = (void *)window._vTbl[method];
4299 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4302 if(!MouseMethod(window, clientX, clientY, *mods))
4309 if(result && w && w.clickThrough && w.parent)
4314 if(!result || !w || !w.clickThrough)
4321 // --- Mouse cursor management ---
4323 bool KeyMessage(uint method, Key key, unichar character)
4328 if(guiApp.interimWindow)
4329 this = guiApp.interimWindow;
4332 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4336 if(!style.inactive || rootWindow != this)
4338 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4339 Window modalWindow = FindModal();
4340 Window interimMaster = master ? master.rootWindow : null;
4344 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4345 status = OnSysKeyDown(key, character);
4346 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4347 status = OnSysKeyHit(key, character);
4348 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4349 status = OnSysKeyUp(key, character);
4356 // Process Key Message for Internal UI Keyboard actions
4357 if(status && !destroyed && menuBar && state != minimized)
4360 if((SmartKey)key != alt)
4361 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4364 SmartKey sk = (SmartKey) key;
4365 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4367 status = menuBar.KeyMessage(method, key, character);
4372 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4373 menuBar.OnKeyHit(escape, 0);
4375 if(!menuBar.focus && guiApp.caretOwner)
4376 guiApp.caretOwner.UpdateCaret(true, false);
4379 if(!destroyed && status)
4381 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4385 case left: case up: case right: case down:
4386 if(guiApp.windowMoving == this)
4389 int w = guiApp.windowMoving.size.w;
4390 int h = guiApp.windowMoving.size.h;
4391 int x = guiApp.windowMoving.scrolledPos.x;
4392 int y = guiApp.windowMoving.scrolledPos.y;
4396 if(key == down || key == up)
4397 step = Max(step, textCellH);
4399 step = Max(step, textCellW);
4402 if(guiApp.windowIsResizing)
4406 case left: w-=step; break;
4407 case right: w+=step; break;
4408 case up: h-=step; break;
4409 case down: h+=step; break;
4416 case left: x-=step; break;
4417 case right: x+=step; break;
4418 case up: y-=step; break;
4419 case down: y+=step; break;
4423 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4424 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4426 if(!guiApp.windowIsResizing || guiApp.resizeX)
4427 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4429 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4431 if(!guiApp.windowIsResizing || guiApp.resizeY)
4432 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4434 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4436 guiApp.interfaceDriver.SetMousePosition(x, y);
4437 ConsequentialMouseMove(true);
4445 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4447 guiApp.windowMoving.StopMoving();
4448 ConsequentialMouseMove(false);
4456 ShowSysMenu(absPosition.x, absPosition.y);
4464 if(!destroyed && status && state != minimized)
4466 // Process all the way down the children
4467 if(activeChild && !activeChild.disabled)
4469 status = activeChild.KeyMessage(method, key, character);
4471 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4472 key.code != left && key.code != right && key.code != up && key.code != down)
4474 status = activeClient.KeyMessage(method, key, character);
4478 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4480 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4481 // && defaultControl != activeChild)
4483 delete previousActive;
4484 previousActive = activeChild;
4485 if(previousActive) incref previousActive;
4487 ConsequentialMouseMove(false);
4488 if((defaultControl.active ||
4489 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4490 defaultControl.KeyMessage(method, defaultKey, character);
4496 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4498 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4505 ShowSysMenu(absPosition.x, absPosition.y);
4512 if(this != guiApp.desktop)
4514 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4516 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4518 MenuMoveOrSize(key.shift, true);
4522 else if(guiApp.windowMoving)
4524 guiApp.windowMoving.StopMoving();
4525 ConsequentialMouseMove(false);
4533 if(!destroyed && status && state != minimized)
4535 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4539 case tab: case shiftTab:
4541 Window cycleParent = this;
4542 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4543 cycleParent = master.parent;
4545 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4547 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4549 Window child = cycleParent.activeChild;
4551 // Scroll the window to include the active control
4553 if(cycleParent.sbh && !child.style.dontScrollHorz)
4555 if(child.scrolledPos.x < 0)
4556 cycleParent.sbh.Action(Position,
4557 cycleParent.scroll.x + child.scrolledPos.x, 0);
4558 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4559 cycleParent.sbh.Action(Position,
4560 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4562 if(cycleParent.sbv && !child.style.dontScrollVert)
4564 if(child.scrolledPos.y < 0)
4565 cycleParent.sbv.Action(Position,
4566 cycleParent.scroll.y + child.scrolledPos.y, 0);
4567 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4568 cycleParent.sbv.Action(Position,
4569 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4572 cycleParent.ConsequentialMouseMove(false);
4578 case f6: case shiftF6:
4579 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4581 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4582 if(parent == guiApp.desktop)
4583 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4593 if(CycleChildren(key.shift, true, false, true))
4601 // mIRC Style Window Shortcuts
4602 case alt1: case alt2: case alt3: case alt4: case alt5:
4603 case alt6: case alt7: case alt8: case alt9: case alt0:
4608 for(document = children.first; document; document = document.next)
4610 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4612 if(document == activeChild)
4614 if(document.state == minimized)
4615 document.SetState(normal, false, key);
4618 document.SetState(minimized, false, key);
4619 CycleChildren(false, true, false);
4624 if(activeChild.state == maximized && document.style.hasMaximize)
4625 document.SetState(maximized, false, key);
4626 else if(document.state == minimized)
4627 document.SetState(normal, false, key);
4628 document.Activate();
4643 if(!destroyed && status)
4645 if(state == minimized)
4650 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4652 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4654 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4655 previousActive.ActivateEx(true, false, false, true, null, null);
4656 delete previousActive;
4662 if(!destroyed && status)
4664 status = ProcessHotKeys(method, key, character);
4666 if(!destroyed && status && !modalWindow && state != minimized)
4669 status = KeyMethod(this, key, character);
4670 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4671 status = OnKeyHit(key, character);
4672 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4674 bool result = false;
4677 case ctrlUp: case ctrlDown:
4678 if(sbv && !guiApp.windowScrolling)
4679 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4681 case wheelUp: case wheelDown:
4682 if(sbv && !guiApp.windowScrolling)
4684 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4685 // Do we want to do a consequential move regardless of result in this case?
4686 ConsequentialMouseMove(false);
4689 case ctrlPageUp: case ctrlPageDown:
4690 if(sbh && !guiApp.windowScrolling)
4691 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4696 ConsequentialMouseMove(false);
4701 if(status && !destroyed && menuBar && state != minimized)
4702 status = menuBar.KeyMessage(method, key, character);
4704 if(style.interim && /*destroyed && */status && interimMaster)
4706 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4707 status = interimMaster.KeyMessage(method, key, character);
4714 bool ProcessHotKeys(uint method, Key key, unichar character)
4719 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4720 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4721 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4723 Window hotKeyWindow = hotKey.window;
4724 Window parent = hotKeyWindow.parent;
4725 Window prevActiveWindow = activeChild;
4726 // For when sys buttons are placed inside the menu bar
4727 if(parent && parent._class == class(PopupMenu))
4728 parent = parent.parent;
4730 // 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
4731 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4734 if(prevActiveWindow) incref prevActiveWindow;
4735 incref hotKeyWindow;
4736 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4737 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4740 delete hotKeyWindow;
4741 delete prevActiveWindow;
4745 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4746 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4747 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4749 // ********* WORKING ON THIS ***********
4750 if(prevActiveWindow && !guiApp.interimWindow)
4751 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4754 else if(hotKeyWindow.style.inactive)
4755 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4757 delete prevActiveWindow;
4758 delete hotKeyWindow;
4759 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4760 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4764 if(status && tabCycle)
4767 for(child = children.first; child; child = child.next)
4769 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4780 // --- Windows and graphics initialization / termination ---
4781 bool SetupRoot(void)
4785 // Setup relationship with outside world (bb root || !bb)
4786 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4787 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4791 tempExtents = new0 Extent[4];
4796 /*if(guiApp.fullScreenMode)
4797 rootWindow = guiApp.desktop;
4799 //rootWindow = parent.created ? parent.rootWindow : null;
4800 rootWindow = parent.rootWindow;
4803 against = &parent.box;
4805 against = &parent.clientArea;
4808 for(child = children.first; child; child = child.next)
4811 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4814 bool Setup(bool positionChildren)
4816 bool result = false;
4819 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4821 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4822 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4824 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4826 // This was here, is it really needed?
4827 //guiApp.interfaceDriver.ActivateRootWindow(this);
4831 displaySystem = DisplaySystem {};
4832 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4834 delete displaySystem;
4839 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4840 if(display.Create(displaySystem, windowHandle))
4847 // Sometimes icon does not show up on Windows XP if we set here...
4848 // guiApp.interfaceDriver.SetIcon(this, icon);
4850 else if(this != guiApp.desktop)
4852 display = rootWindow ? rootWindow.display : null;
4858 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4859 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4861 for(child = children.first; child; child = child.next)
4863 if(child.created && !child.Setup(false))
4869 bool SetupDisplay(void)
4871 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4872 if(is3D) return Window3D_SetupDisplay(this); else
4879 class_data void ** pureVTbl;
4881 bool LoadGraphics(bool creation, bool resetAnchors)
4883 bool result = false;
4884 bool success = false;
4886 WindowState stateBackup = state;
4888 if(((subclass(Window))_class).pureVTbl)
4890 if(_vTbl == _class._vTbl)
4892 _vTbl = ((subclass(Window))_class).pureVTbl;
4897 for(m = 0; m < _class.vTblSize; m++)
4899 if(_vTbl[m] == _class._vTbl[m])
4900 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4904 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4906 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4908 _vTbl = _class._vTbl;
4913 for(m = 0; m < _class.vTblSize; m++)
4915 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4916 _vTbl[m] = _class._vTbl[m];
4921 if(guiApp.fullScreenMode || this != guiApp.desktop)
4923 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4929 display.Lock(false);
4930 if(rootWindow == this)
4932 // Set Color Palette
4933 display.SetPalette(palette, true);
4937 if(guiApp.fullScreenMode && this == guiApp.desktop)
4942 for(c=0; c<SystemCursor::enumSize; c++)
4943 if(!guiApp.systemCursors[c].bitmap)
4945 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4946 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4947 if(guiApp.systemCursors[c].bitmapName)
4949 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4950 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4951 if(guiApp.systemCursors[c].bitmap)
4952 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4957 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4959 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4960 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4962 cursor.bitmap.paletteShades = cursor.paletteShades;
4966 guiApp.cursorUpdate = true;
4969 ConsequentialMouseMove(false);
4975 // Load Window Graphic Resources
4978 if(usedFont == setFont || usedFont == window.systemFont)
4979 RemoveResource(usedFont);
4982 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4985 RemoveResource(systemFont);
4988 RemoveResource(captionFont);
4990 for(ptr = resources.first; ptr; ptr = ptr.next)
4992 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4995 AddResource(setFont);
4997 AddResource(systemFont);
4999 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5006 //if(master && master.font)
5007 if(parent && parent.font)
5011 faceName = parent.font.faceName,
5012 size = parent.font.size,
5013 bold = parent.font.bold,
5014 italic = parent.font.italic,
5015 underline = parent.font.underline
5017 //font = parent.font;
5018 watch(parent) { font { } };
5021 font = guiApp.currentSkin.SystemFont();
5028 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5029 AddResource(captionFont);
5031 if(OnLoadGraphics())
5037 //SetScrollLineStep(sbStep.x, sbStep.y);
5039 if(this != guiApp.desktop)
5043 normalAnchor = anchor;
5044 normalSizeAnchor = sizeAnchor;
5047 // Break the anchors for moveable/resizable windows
5049 if(style.fixed && style.isDocument)
5051 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5063 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5064 stateSizeAnchor = SizeAnchor {};
5069 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5074 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5075 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5078 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5082 stateAnchor = normalAnchor;
5083 stateSizeAnchor = normalSizeAnchor;
5086 position = Point { };
5087 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5098 if(Position(x, y, w, h, true, false, true, true, true, true))
5100 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5103 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5120 success = result = true;
5123 if(!creation && result)
5125 // Load menu bar first because sys buttons are on it...
5128 if(!menuBar.LoadGraphics(false, resetAnchors))
5134 for(child = children.first; child; child = child.next)
5136 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5143 CreateSystemChildren();
5147 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5150 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5155 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5156 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5159 // Do this here to avoid problems on Windows
5160 if(stateBackup == maximized)
5161 property::state = maximized;
5165 void UnloadGraphics(bool destroyWindows)
5169 // Free children's graphics
5170 for(child = children.first; child; child = child.next)
5171 child.UnloadGraphics(destroyWindows);
5174 display.Lock(false);
5177 if(guiApp.fullScreenMode && this == guiApp.desktop)
5182 for(c=0; c<SystemCursor::enumSize; c++)
5183 if(guiApp.systemCursors[c].bitmap)
5184 delete guiApp.systemCursors[c].bitmap;
5186 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5187 delete cursor.bitmap;
5189 guiApp.cursorBackground.Free();
5192 if(display && display.displaySystem)
5196 for(ptr = resources.first; ptr; ptr = ptr.next)
5200 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5205 // Free window graphics
5208 // Free skin graphics
5209 if(rootWindow == this)
5211 DisplaySystem displaySystem = display.displaySystem;
5214 display.driverData = null;
5215 display.displaySystem = null;
5219 if(displaySystem && !displaySystem.numDisplays && !is3D)
5220 delete displaySystem;
5229 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5230 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5232 if(this == guiApp.desktop || parent == guiApp.desktop)
5234 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5235 guiApp.interfaceDriver.DestroyRootWindow(this);
5239 // --- Window Hiding ---
5241 void SetVisibility(bool state)
5243 bool visible = (style.hidden || !created) ? false : state;
5244 if(visible != this.visible)
5248 this.visible = visible;
5249 for(child = children.first; child; child = child.next)
5250 child.SetVisibility(visible);
5252 ConsequentialMouseMove(false);
5253 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5257 // --- Windows and graphics initialization / termination ---
5259 bool DisplayModeChanged(void)
5261 bool result = false;
5262 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5264 guiApp.modeSwitching = true;
5265 UnloadGraphics(false);
5267 if(LoadGraphics(false, false))
5269 guiApp.modeSwitching = false;
5274 // --- Window updates system ---
5276 void UpdateDirty(Box updateBox)
5278 if(!manageDisplay) { OnRedraw(null);return; }
5281 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5284 if(display.flags.flipping)
5287 rootWindow.UpdateDisplay();
5290 UpdateBackDisplay(updateBox);
5292 if(guiApp.fullScreenMode)
5294 guiApp.cursorUpdate = true;
5295 guiApp.PreserveAndDrawCursor();
5297 if(guiApp.fullScreenMode)
5298 guiApp.RestoreCursorBackground();
5304 // This function is strictly called as a result of system window activation
5305 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5308 Window interimMaster = null;
5309 Window interimWindow = guiApp.interimWindow;
5310 if(interimWindow && interimWindow.master)
5311 interimMaster = interimWindow.master.rootWindow;
5313 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5314 // SetState(normal, false, 0);
5315 SetState(lastState, false, 0);
5317 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5321 /* WTH is this doing here?
5322 while(swap && swap.activeChild)
5324 swap = swap.activeChild;
5327 // TESTING THIS BEFORE...
5328 if(interimWindow && this == interimMaster)
5332 // Window interimSwap = this;
5333 Window menuBar = this.menuBar;
5334 if(menuBar && interimWindow.master == menuBar)
5337 while(interimSwap && interimSwap.activeChild)
5338 interimSwap = interimSwap.activeChild;
5340 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5341 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5343 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5344 //result = ActivateEx(true, true, false, activateRoot, window, null);
5349 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5350 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5352 if(interimWindow == this && interimMaster && !active)
5354 while(interimMaster && interimMaster.interim && interimMaster.master)
5356 // printf("Going up one master %s\n", interimMaster._class.name);
5357 interimMaster = interimMaster.master.rootWindow;
5359 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5360 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5366 bool DestroyEx(int64 returnCode)
5369 Timer timer, nextTimer;
5371 OldLink prevOrder = null;
5372 Window client = null;
5374 if(parent) stopwatching(parent, font);
5376 // if(window.modalSlave) return false;
5377 if(destroyed || !created)
5384 OldLink slave = master.slaves.FindLink(this);
5385 master.slaves.Delete(slave);
5388 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5394 this.returnCode = (DialogResult)returnCode;
5396 AcquireInput(false);
5401 master.hotKeys.Delete(hotKey);
5405 if(guiApp.prevWindow == this)
5407 guiApp.prevWindow = null;
5410 if(guiApp.caretOwner == this)
5412 guiApp.interfaceDriver.SetCaret(0,0,0);
5413 UpdateCaret(false, true);
5414 guiApp.caretEnabled = false;
5419 parent.childrenCycle.Remove(cycle);
5423 OldLink tmpPrev = order.prev;
5424 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5425 prevOrder = tmpPrev;
5428 client = tmpPrev ? tmpPrev.data : null;
5429 if(client == this) { client = null; break; }
5430 if(client && (client.style.hidden || client.destroyed || !client.created))
5431 tmpPrev = client.order.prev;
5435 prevOrder = tmpPrev;
5440 // If this window can be an active client, make sure the next window we activate can also be one
5441 if(!style.nonClient && style.isActiveClient)
5443 tmpPrev = prevOrder;
5446 client = tmpPrev ? tmpPrev.data : null;
5447 if(client == this) { client = null; break; }
5448 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5449 tmpPrev = client.order.prev;
5453 prevOrder = tmpPrev;
5457 if(client && client.style.hidden) client = null;
5459 // parent.childrenOrder.Remove(order);
5462 if(parent && style.isActiveClient && visible)
5464 if(state == minimized) parent.numIcons--;
5465 parent.numPositions--;
5468 // TESTING THIS HERE!
5472 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5473 // to create a window inside a rootwindow that's being destroyed)
5474 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5476 if(master && !master.destroyed /*&&
5477 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5479 if(master.defaultControl == this)
5480 master.defaultControl = null;
5483 parent.OnChildAddedOrRemoved(this, true);
5484 if(parent && !parent.destroyed /*&&
5485 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5487 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5489 if(order && prevOrder && prevOrder.data != this && active)
5491 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5493 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5494 if(parent.activeClient == this)
5496 parent.activeClient = null;
5497 parent.UpdateActiveDocument(null);
5502 if(guiApp.interimWindow == this)
5505 PropagateActive(false, null, &goOn, true);
5509 //if(window.parent.activeChild == window)
5510 parent.activeChild = null;
5511 if(!style.nonClient /*&& style.isActiveClient*/)
5513 Window previous = parent.activeClient;
5514 if(style.isActiveClient)
5515 parent.activeClient = null;
5516 parent.UpdateActiveDocument(previous);
5521 else if(parent.activeClient == this)
5523 parent.activeClient = client;
5524 parent.UpdateActiveDocument(this);
5528 if(guiApp.interimWindow == this)
5530 guiApp.interimWindow = null;
5531 if(guiApp.caretOwner)
5533 Window desktop = guiApp.desktop;
5534 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5535 guiApp.caretOwner.UpdateCaret(false, false);
5540 if(_isModal && master && master.modalSlave == this)
5541 master.modalSlave = null;
5545 if(!guiApp.caretOwner && parent.caretSize)
5547 guiApp.caretOwner = parent;
5548 parent.UpdateCaret(false, false);
5549 parent.Update(null);
5552 // Why was this commented out?
5553 GetRidOfVirtualArea();
5559 dirtyArea.Free(null);
5560 dirtyBack.Free(null);
5561 scrollExtent.Free(null);
5563 /* ATTEMPTING TO MOVE THAT ABOVE
5572 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5573 for(;(child = window.children.first);)
5575 for(; child && (child.destroyed || !child.created); child = child.next);
5584 UnloadGraphics(true);
5587 delete previousActive;
5590 // statusBar = null;
5593 if(master && !master.destroyed)
5595 //master.NotifyDestroyed(this, this.returnCode);
5596 NotifyDestroyed(master, this, this.returnCode);
5599 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5601 nextTimer = timer.next;
5602 if(timer.window == this)
5604 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5605 // timer.window = null;
5611 if(this == guiApp.windowMoving)
5614 if(guiApp.windowCaptured == this)
5616 //guiApp.windowCaptured = null;
5618 if(rootWindow != this && rootWindow)
5619 rootWindow.ConsequentialMouseMove(false);
5627 //for(child = children.first; next = child ? child.next : null, child; child = next)
5628 for(;(child = children.first); )
5630 for(; child && (child.destroyed || !child.created); child = child.next);
5640 /* // MOVED THIS UP...
5643 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5644 for(;(child = window.children.first); )
5646 for(; child && (child.destroyed || !child.created); child = child.next);
5655 while((slave = slaves.first))
5657 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5659 ((Window)slave.data).DestroyEx(0);
5664 if(guiApp.caretOwner == this)
5665 guiApp.caretOwner = null;
5667 sysButtons[0] = null;
5668 sysButtons[1] = null;
5669 sysButtons[2] = null;
5672 if(rootWindow != this)
5674 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5677 box.left -= parent.clientStart.x;
5678 box.top -= parent.clientStart.y;
5679 box.right -= parent.clientStart.x;
5680 box.bottom -= parent.clientStart.y;
5682 if(parent) parent.Update(box);
5687 OldLink slave = master.slaves.FindVoid(this);
5688 master.slaves.Delete(slave);
5694 parent.children.Remove(this);
5699 //autoCreate = false;
5702 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5703 if(((subclass(Window))_class).pureVTbl)
5705 if(_vTbl == _class._vTbl)
5707 _vTbl = ((subclass(Window))_class).pureVTbl;
5712 for(m = 0; m < _class.vTblSize; m++)
5714 if(_vTbl[m] == _class._vTbl[m])
5715 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5724 void SetStateEx(WindowState newState, bool activate)
5727 WindowState prevState = state;
5731 if(prevState != newState)
5732 lastState = prevState;
5734 if(rootWindow != this || !nativeDecorations || !windowHandle)
5736 if(style.isActiveClient && !style.hidden && prevState == minimized)
5739 // This block used to be at the end of the function... moved it for flicker problem in X
5740 // ------------------------------------------------------
5744 stateAnchor = normalAnchor;
5745 stateSizeAnchor = normalSizeAnchor;
5748 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5749 stateSizeAnchor = SizeAnchor {};
5753 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5756 byte * idBuffer = new0 byte[size];
5758 for(child = parent.children.first; child; child = child.next)
5760 if(child != this && child.state == minimized)
5762 if(child.iconID > size - 2)
5764 idBuffer = renew0 idBuffer byte[size*2];
5765 memset(idBuffer + size, 0, size);
5768 idBuffer[child.iconID] = (byte)bool::true;
5771 for(c = 0; c<size; c++)
5776 if(style.isActiveClient && !style.hidden)
5779 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5780 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5784 // TOCHECK: Why was this here?
5785 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5786 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5787 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5789 Position(x, y, w, h, true, true, true, true, false, true);
5791 if(!style.inactive && !style.interim && this == parent.activeClient)
5792 parent.UpdateActiveDocument(null);
5795 CreateSystemChildren();
5796 // ------------------------------------------------------
5799 int GetPositionID(Window forChild)
5803 byte * idBuffer = new0 byte[size];
5806 for(child = children.first; child; child = child.next)
5808 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5810 if(child.positionID > size - 2)
5812 idBuffer = renew0 idBuffer byte[size*2];
5813 memset(idBuffer + size, 0, size);
5816 idBuffer[child.positionID] = (byte)bool::true;
5819 for(c = 0; c<size; c++)
5826 // --- Window related graphics ---
5828 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5830 palette = newPalette;
5831 if(rootWindow.display)
5832 rootWindow.display.SetPalette(palette, colorMatch);
5835 public bool AcquireInput(bool acquired)
5838 if(acquiredInput != acquired)
5840 if(active || (!visible && creationActivation == activate))
5841 result = AcquireInputEx(acquired);
5846 acquiredInput = acquired ? result : !result;
5851 void ListChildren(ListBox listBox)
5855 for(child = children.first; child; child = child.next)
5857 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5859 DataRow row = listBox.AddRow();
5860 row.tag = (int64)child;
5861 child.FigureCaption(caption);
5862 row.SetData(null, caption);
5867 void UpdateVisual(Box extent)
5869 if(guiApp.driver != null)
5871 if(guiApp.fullScreenMode && guiApp.desktop.display)
5873 guiApp.desktop.mutex.Wait();
5874 guiApp.desktop.display.Lock(true);
5877 if(guiApp.desktop.active)
5879 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5881 if(guiApp.desktop.display.flags.flipping)
5882 guiApp.desktop.Update(null);
5883 guiApp.desktop.UpdateDisplay();
5884 guiApp.cursorUpdate = true;
5886 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5888 guiApp.PreserveAndDrawCursor();
5889 // guiApp.desktop.display.ShowScreen();
5890 guiApp.cursorUpdate = false;
5891 guiApp.desktop.dirty = false;
5892 guiApp.RestoreCursorBackground();
5896 guiApp.desktop.display.Unlock();
5897 guiApp.desktop.mutex.Release();
5901 Window rootWindow = this.rootWindow;
5902 rootWindow.mutex.Wait();
5907 guiApp.SignalEvent();
5910 guiApp.waitMutex.Wait();
5911 guiApp.interfaceDriver.Lock(rootWindow);
5912 if(!rootWindow.style.hidden && rootWindow.dirty)
5914 if(rootWindow.display)
5916 rootWindow.UpdateDisplay();
5917 //rootWindow.display.ShowScreen(null);
5919 rootWindow.dirty = false;
5921 guiApp.interfaceDriver.Unlock(rootWindow);
5922 guiApp.waitMutex.Release();
5925 rootWindow.mutex.Release();
5930 void UnlockDisplay(void)
5932 guiApp.interfaceDriver.Unlock(rootWindow);
5935 void LockDisplay(void)
5937 guiApp.interfaceDriver.Lock(rootWindow);
5940 Surface GetSurface(Box box)
5942 return Redraw((box == null) ? this.box : box);
5945 void SetMousePosition(int x, int y)
5947 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5951 void IntegrationActivate(bool active)
5953 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5955 isForegroundWindow = true;
5956 ActivateEx(active, active, false, false, null, null);
5957 isForegroundWindow = false;
5962 Window QueryCapture(void)
5964 return guiApp.windowCaptured;
5967 int GetDocumentID(void)
5971 byte * idBuffer = new0 byte[size];
5974 for(child = children.first; child; child = child.next)
5976 // TO CHECK: Do we want a documentID when we already have a file name?
5977 if(child.style.isDocument && !child.fileName)
5979 if(child.documentID-1 > size - 2)
5981 idBuffer = renew0 idBuffer byte[size*2];
5982 memset(idBuffer + size, 0, size);
5985 idBuffer[child.documentID-1] = 1;
5988 for(c = 0; c<size; c++)
5996 void SetInitSize(Size size)
5999 sizeAnchor.size = size;
6000 normalSizeAnchor = sizeAnchor;
6002 // Break the anchors for moveable/resizable windows
6003 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6005 stateAnchor = normalAnchor;
6006 stateSizeAnchor = normalSizeAnchor;
6008 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6009 Position(x,y, w, h, true, true, true, true, false, true);
6013 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6015 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6017 guiApp.windowIsResizing = resize;
6018 guiApp.windowMoving = this;
6019 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6020 if(guiApp.windowIsResizing)
6022 guiApp.windowMovingStart.x += size.w - 1;
6023 guiApp.windowMovingStart.y += size.h - 1;
6025 guiApp.windowMovingBefore = scrolledPos;
6026 guiApp.windowResizingBefore = size;
6027 guiApp.windowMoving.UpdateDecorations();
6028 if(guiApp.windowIsResizing)
6029 guiApp.resizeEndX = guiApp.resizeEndY = true;
6031 if(setCursorPosition)
6032 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6036 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6037 guiApp.windowMovingStart.x += x - absPosition.x;
6038 guiApp.windowMovingStart.y += y - absPosition.y;
6041 if(guiApp.windowMoving)
6043 if(guiApp.windowMoving.style.nonClient)
6044 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6046 guiApp.windowMoving.parent.SetMouseRangeToClient();
6051 if(this == rootWindow)
6052 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6060 bool result = false;
6064 else if(guiApp && guiApp.driver != null)
6066 void * systemParent = null;
6067 OldLink slaveHolder;
6069 bool visible = !style.hidden;
6073 systemParent = parent;
6074 parent = guiApp.desktop;
6076 last = parent ? parent.children.last : null;
6078 if((parent && parent != guiApp.desktop && !parent.created) ||
6079 (master && master != guiApp.desktop && !master.created))
6083 stopwatching(parent, font);
6086 property::parent = guiApp.desktop;
6087 if(!master) master = parent;
6089 if(_isModal && master.modalSlave)
6090 property::master = master.modalSlave;
6094 parent.children.Remove(this);
6097 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6098 if(slaveHolder.data == this)
6100 master.slaves.Delete(slaveHolder);
6105 if(parent == guiApp.desktop && !mutex)
6108 if(style.isDocument)
6111 parent.numDocuments--;
6112 documentID = parent.GetDocumentID();
6115 if(!style.stayOnTop)
6116 for(; last && last.style.stayOnTop; last = last.prev);
6118 parent.children.Insert((last == this) ? null : last, this);
6119 //parent.children.Add(this);
6122 dispDriver = parent.dispDriver;
6125 master.modalSlave = this;
6127 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6132 master.slaves.Add(slaveHolder = OldLink { data = this });
6137 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6139 if(style.isDefault && !master.defaultControl)
6140 master.defaultControl = this;
6142 stateAnchor = normalAnchor = anchor;
6143 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6145 // TOCHECK: Why is this here?
6146 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6147 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6149 this.visible = false;
6150 style.hidden = true;
6153 // autoCreate = true;
6161 if(parent == guiApp.desktop)
6162 Log("LoadGraphics %s\n", caption);
6164 if(LoadGraphics(true, false))
6172 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6179 if(style.hasMenuBar /*&& menu*/)
6185 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6186 interim = false, inactive = true, nonClient = true, size.h = 24
6194 // Create the system buttons
6195 CreateSystemChildren();
6197 UpdateActiveDocument(null);
6199 if(style.isDocument)
6203 MenuItem item = menu.FindItem(MenuFileSave, 0);
6204 if(item) item.disabled = !modifiedDocument && fileName;
6209 if(parent == guiApp.desktop)
6210 Log("Preemptive SetState %s\n", caption);
6213 // Preemptive Set State to ensure proper anchoring
6214 SetStateEx(state, false);
6216 style.hidden = true;
6222 for(child = children.first; child; child = next)
6225 if(!child.created && (child.autoCreate || child.wasCreated))
6232 for(link = slaves.first; link; link = next)
6234 Window slave = link.data;
6236 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6239 // Things might have happened that invalidated 'next'...
6240 // Start over the search for slaves to create.
6241 // (Added this to fix crash with Stacker & Toolbar)
6242 next = slaves.first;
6251 if(parent == guiApp.desktop)
6252 Log("Real SetState %s\n", caption);
6255 if(isActiveClient && visible)
6257 parent.numPositions--;
6258 if(state == minimized) parent.numIcons--;
6261 parent.OnChildAddedOrRemoved(this, false);
6263 // Real set state & activate for proper display & activation
6264 property::visible = visible;
6265 // SetState(state & 0x00000003, true, 0);
6266 guiApp.interfaceDriver.SetIcon(this, icon);
6271 /*if(rootWindow == this)
6272 guiApp.interfaceDriver.ActivateRootWindow(this);
6274 if(creationActivation == activate)
6275 ActivateEx(true, false, true, true, null, null);
6276 else if(creationActivation == flash)
6281 rootWindow.ConsequentialMouseMove(false);
6292 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6298 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6300 //style.hidden = true; // !visible;
6301 style.hidden = !visible;
6302 if(master.modalSlave == this)
6303 master.modalSlave = null;
6310 void WriteCaption(Surface surface, int x, int y)
6313 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6316 void Update(Box region)
6322 rootWindow = this.rootWindow;
6324 // rootWindow.mutex.Wait();
6325 if(!destroyed && visible && display)
6330 // Testing this to avoid repetitve full update to take time...
6331 if(dirtyArea.count == 1)
6333 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6334 if(item.box.left <= box.left &&
6335 item.box.top <= box.top &&
6336 item.box.right >= box.right &&
6337 item.box.bottom >= box.bottom)
6339 rootWindow.dirty = true;
6344 if(display.flags.flipping && !rootWindow.dirty)
6346 if(this == rootWindow)
6350 rootWindow.Update(null);
6355 rootWindow.dirty = true;
6360 realBox.left += clientStart.x;
6361 realBox.top += clientStart.y;
6362 realBox.right += clientStart.x;
6363 realBox.bottom += clientStart.y;
6369 if(realBox.right >= realBox.left &&
6370 realBox.bottom >= realBox.top)
6372 // if(!rootWindow.fullRender)
6373 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6375 for(child = children.first; child; child = child.next)
6380 box.left -= child.absPosition.x - absPosition.x;
6381 box.top -= child.absPosition.y - absPosition.y;
6382 box.right -= child.absPosition.x - absPosition.x;
6383 box.bottom -= child.absPosition.y - absPosition.y;
6384 if(box.right >= child.box.left && box.left <= child.box.right &&
6385 box.bottom >= child.box.top && box.top <= child.box.bottom)
6387 box.left -= child.clientStart.x;
6388 box.top -= child.clientStart.y;
6389 box.right -= child.clientStart.x;
6390 box.bottom -= child.clientStart.y;
6396 realBox.left += absPosition.x - rootWindow.absPosition.x;
6397 realBox.top += absPosition.y - rootWindow.absPosition.y;
6398 realBox.right += absPosition.x - rootWindow.absPosition.x;
6399 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6400 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6403 else if(this == guiApp.desktop)
6406 for(window = children.first; window; window = window.next)
6412 Box childBox = region;
6414 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6415 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6416 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6417 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6419 window.Update(childBox);
6422 window.Update(null);
6427 // rootWindow.mutex.Release();
6434 if(guiApp.windowCaptured != this)
6436 if(guiApp.windowCaptured)
6440 //Logf("Captured %s (%s)\n", caption, class.name);
6441 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6442 guiApp.windowCaptured = this;
6448 bool Destroy(int64 code)
6453 if(!destroyed && !CloseConfirmation(false)) return false;
6457 // TOCHECK: Should autoCreate be set to false here?
6468 void Move(int x, int y, int w, int h)
6470 normalAnchor = Anchor { left = x, top = y };
6471 normalSizeAnchor = SizeAnchor { size = { w, h } };
6473 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6475 if(destroyed) return;
6477 stateAnchor = normalAnchor;
6478 stateSizeAnchor = normalSizeAnchor;
6480 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6481 Position(x,y, w, h, true, true, true, true, false, true);
6485 DialogResult Modal(void)
6491 // FIXES MEMORY LEAK IF Create() FAILED
6497 void SetScrollArea(int width, int height, bool snapToStep)
6499 bool resize = false;
6502 int stepX = sbStep.x, stepY = sbStep.y;
6503 // Needed to make snapped down position match the skin's check of client area
6504 // against realvirtual
6507 SNAPDOWN(stepX, textCellW);
6508 SNAPDOWN(stepY, textCellH);
6509 stepX = Max(stepX, textCellW);
6510 stepY = Max(stepY, textCellH);
6512 if(scrollFlags.snapX)
6513 SNAPUP(width, stepX);
6514 if(scrollFlags.snapY)
6515 SNAPUP(height, stepY);
6518 reqScrollArea.w = width;
6519 reqScrollArea.h = height;
6520 noAutoScrollArea = (width > 0 || height > 0);
6522 UpdateScrollBars(true, true);
6525 void SetScrollPosition(int x, int y)
6528 sbh.Action(setPosition, x, 0);
6532 int seen = clientSize.w, total = reqScrollArea.w;
6534 if(scrollFlags.snapX)
6535 SNAPDOWN(seen, sbStep.x);
6537 if(!total) total = seen;
6538 range = total - seen + 1;
6539 range = Max(range, 1);
6541 if(x >= range) x = range - 1;
6543 if(scrollFlags.snapX)
6544 SNAPUP(x, sbStep.x);
6547 OnHScroll(setPosition, x, 0);
6551 SNAPDOWN(x, textCellW);
6557 sbv.Action(setPosition, y, 0);
6561 int seen = clientSize.h, total = reqScrollArea.h;
6564 if(scrollFlags.snapY)
6565 SNAPDOWN(seen, sbStep.y);
6567 if(!total) total = seen;
6568 range = total - seen + 1;
6569 range = Max(range, 1);
6571 if(y >= range) y = range - 1;
6573 if(scrollFlags.snapY)
6574 SNAPUP(y, sbStep.y);
6577 OnVScroll(setPosition, y, 0);
6580 SNAPDOWN(y, textCellH);
6585 UpdateCaret(false, false);
6588 void SetScrollLineStep(int stepX, int stepY)
6594 SNAPDOWN(stepX, textCellW);
6595 SNAPDOWN(stepY, textCellH);
6596 stepX = Max(stepX, textCellW);
6597 stepY = Max(stepY, textCellH);
6600 sbh.lineStep = stepX;
6602 sbv.lineStep = stepY;
6605 void SetState(WindowState newState, bool activate, Modifiers mods)
6609 if(state == newState || OnStateChange(newState, mods))
6611 WindowState prevState = state;
6615 // This used to be at the end of the brackets... moved for X, testing...
6616 // This has the effect of activating the window through the system...
6617 if(rootWindow == this)
6618 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6620 SetStateEx(newState, activate);
6622 if(rootWindow == this && !rootWindow.nativeDecorations)
6624 int x = position.x, y = position.y;
6627 x -= guiApp.desktop.absPosition.x;
6628 y -= guiApp.desktop.absPosition.y;
6630 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6634 //state = prevState;
6636 if(state != maximized && style.hasMaximize)
6639 for(child = parent.children.first; child; child = child.next)
6641 if(child != this && child.state == maximized)
6642 child.SetStateEx(normal, false);
6646 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6647 parent.UpdateScrollBars(true, true);
6650 // Do we really need this stuff here?
6651 // Shouldn't the Activate stuff take care of it?
6652 if(parent.rootWindow == parent && style)
6655 parent.FigureCaption(caption);
6656 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6657 parent.UpdateDecorations();
6661 rootWindow.ConsequentialMouseMove(false);
6668 BitmapResource GetIcon(SkinBitmap iconID)
6670 return guiApp.currentSkin.GetBitmap(iconID);
6673 void SetMouseRange(Box range)
6675 if(range || guiApp.fullScreenMode)
6680 clip.left = range.left + absPosition.x + clientStart.x;
6681 clip.top = range.top + absPosition.y + clientStart.y;
6682 clip.right = range.right + absPosition.x + clientStart.x;
6683 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6687 clip.left = guiApp.desktop.box.left;
6688 clip.top = guiApp.desktop.box.top;
6689 clip.right = guiApp.desktop.box.right;
6690 clip.bottom = guiApp.desktop.box.bottom;
6692 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6695 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6698 void SetMouseRangeToClient(void)
6700 if(guiApp.fullScreenMode || this != guiApp.desktop)
6702 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6703 box.Clip(clientArea);
6707 SetMouseRange(null);
6710 void SetMouseRangeToWindow(void)
6712 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6713 if(this == guiApp.desktop)
6714 SetMouseRangeToClient();
6719 // x, y: Desktop Coordinates
6720 void ShowSysMenu(int x, int y)
6723 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6726 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6727 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6731 menu, $"Move", m, NotifySelect = MenuWindowMove,
6732 disabled = !style.fixed || state == maximized
6736 menu, $"Size", s, NotifySelect = MenuWindowSize,
6737 disabled = !style.sizable || state != normal
6741 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6742 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6746 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6747 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6751 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6752 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6754 MenuDivider { menu };
6757 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6758 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6760 windowMenu.Create();
6765 ActivateEx(true, true, true, true, null, null);
6768 void MakeActive(void)
6770 ActivateEx(true, false, true, false, null, null);
6773 void SoftActivate(void)
6775 if(guiApp.desktop.active)
6781 void Deactivate(void)
6783 ActivateEx(false, true, true, true, null, null);
6788 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6791 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6793 bool result = false;
6794 if(activeChild && activeChild.cycle)
6796 Window modalWindow, child = activeChild;
6797 if(!clientOnly /*&& parent.tabCycle*/)
6799 Window next = child;
6802 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6806 if(parent && parent.CycleChildren(backward, false, true, true))
6814 next = next.cycle.prev.data;
6816 next = next.cycle.next.data;
6817 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6822 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6823 parent.tabCycle && parent.CycleChildren(backward, false, false))
6827 if(tabCycleOnly && !tabCycle) return false;
6834 child = child.cycle.prev.data;
6836 child = child.cycle.next.data;
6837 if(child == child.parent.activeChild)
6839 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6842 modalWindow = child.FindModal();
6845 // Scroll the window to include the active control
6846 if(sbh && !child.style.dontScrollHorz)
6848 if(child.scrolledPos.x < 0)
6849 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6850 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6851 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6853 if(sbv && !child.style.dontScrollVert)
6855 if(child.scrolledPos.y < 0)
6856 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6857 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6858 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6862 child = modalWindow ? modalWindow : child;
6863 child.ActivateEx(true, true, true, true, null, null);
6864 if(child.tabCycle && child.childrenCycle.first)
6865 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6873 ConsequentialMouseMove(false);
6877 void AddResource(Resource resource)
6881 ResPtr ptr { resource = resource };
6885 // Load Graphics here if window is created already
6886 if(/*created && */display)
6888 display.Lock(false);
6889 ptr.loaded = display.displaySystem.LoadResource(resource);
6893 // Temporary hack to load font right away for listbox in dropbox ...
6894 else if(master && master.display)
6896 master.display.Lock(false);
6897 master.display.displaySystem.LoadResource(resource);
6898 master.display.Unlock();
6904 void RemoveResource(Resource resource)
6909 for(ptr = resources.first; ptr; ptr = ptr.next)
6911 if(ptr.resource == resource)
6917 // Unload Graphics here if window is created already
6918 if(/*created && */display)
6922 display.Lock(false);
6923 display.displaySystem.UnloadResource(resource, ptr.loaded);
6929 resources.Delete(ptr);
6934 void SetCaret(int x, int y, int size)
6941 if(active && !style.interim)
6943 if(visible || !guiApp.caretOwner)
6944 guiApp.caretOwner = size ? this : null;
6946 UpdateCaret(false, false);
6949 guiApp.interfaceDriver.SetCaret(0,0,0);
6950 UpdateCaret(false, true);
6951 guiApp.caretEnabled = false;
6954 else if(style.inactive && active)
6956 guiApp.interfaceDriver.SetCaret(0,0,0);
6957 UpdateCaret(false, true);
6958 guiApp.caretEnabled = false;
6963 void Scroll(int x, int y)
6965 bool opaque = !style.drawBehind || background.a;
6966 if(opaque && display && display.flags.scrolling)
6968 Box box = clientArea;
6969 box.left += clientStart.x;
6970 box.top += clientStart.y;
6971 box.right += clientStart.x;
6972 box.bottom += clientStart.y;
6974 //scrollExtent.Free(null);
6975 scrollExtent.AddBox(box);
6976 scrolledArea.x += x;
6977 scrolledArea.y += y;
6979 //scrollExtent.Free();
6980 //scrollExtent.AddBox(clientArea);
6981 //scrollExtent.Offset(clientStart.x, clientStart.y);
6982 //scrolledArea.x = x;
6983 //scrolledArea.y = y;
6989 rootWindow.dirty = true;
6992 void ReleaseCapture()
6994 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6996 Window oldCaptured = guiApp.windowCaptured;
6997 guiApp.windowCaptured = null;
6998 guiApp.prevWindow = null;
7001 //guiApp.Log("Released Capture\n");
7003 guiApp.interfaceDriver.SetMouseCapture(null);
7005 //oldCaptured.OnMouseCaptureLost();
7008 oldCaptured.ConsequentialMouseMove(false);
7013 private void _SetCaption(char * format, va_list args)
7020 char caption[MAX_F_STRING];
7021 vsnprintf(caption, sizeof(caption), format, args);
7022 caption[sizeof(caption)-1] = 0;
7024 this.caption = CopyString(caption);
7029 firewatchers caption;
7033 /*deprecated*/ void SetText(char * format, ...)
7036 va_start(args, format);
7037 _SetCaption(format, args);
7041 void SetCaption(char * format, ...)
7044 va_start(args, format);
7045 _SetCaption(format, args);
7049 bool Grab(Bitmap bitmap, Box box, bool decorations)
7051 bool result = false;
7052 if(display || this == guiApp.desktop)
7054 Box clip = {MININT, MININT, MAXINT, MAXINT};
7060 clip.Clip(clientArea);
7062 clip.Clip(this.box);
7064 if(rootWindow != this)
7066 clip.left += absPosition.y;
7067 clip.top += absPosition.y;
7068 clip.right += absPosition.x;
7069 clip.bottom += absPosition.y;
7072 clip.left += decorations ? 0 : clientStart.x;
7073 clip.top += decorations ? 0 : clientStart.y;
7074 clip.right += decorations ? 0 : clientStart.x;
7075 clip.bottom += decorations ? 0 : clientStart.y;
7077 if(display && display.flags.flipping)
7079 rootWindow.Update(null);
7080 rootWindow.UpdateDisplay();
7087 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7088 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7092 result = display.Grab(bitmap, clip.left, clip.top,
7093 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7095 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7097 if(!bitmap.Convert(null, pixelFormat888, null))
7104 void GetMousePosition(int * x, int * y)
7106 int mouseX = 0, mouseY = 0;
7107 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7110 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7111 if(this != guiApp.desktop)
7113 mouseX -= absPosition.x + clientStart.x;
7114 mouseY -= absPosition.y + clientStart.y;
7121 DialogResult DoModal()
7123 DialogResult returnCode = 0;
7124 int terminated = terminateX;
7127 while(!destroyed && guiApp.driver != null)
7129 if(terminateX != terminated)
7131 terminated = terminateX;
7132 guiApp.desktop.Destroy(0);
7133 if(guiApp.desktop.created)
7136 //printf("Resetting terminate X to 0\n");
7142 guiApp.UpdateDisplay();
7143 if(!guiApp.ProcessInput(false))
7146 returnCode = this.returnCode;
7159 return !destroyed && guiApp.driver != null && terminateX < 2;
7162 DialogResult DoModalEnd()
7164 DialogResult returnCode = this.returnCode;
7169 // --- Window manipulation ---
7170 /*bool GetDisabled()
7172 bool disabled = this.disabled;
7174 for(window = this; (window = window.master); )
7185 // --- Mouse Manipulation ---
7186 void GetNCMousePosition(int * x, int * y)
7188 GetMousePosition(x, y);
7189 if(x) *x += clientStart.x;
7190 if(y) *y += clientStart.y;
7193 // --- Carets manipulation ---
7194 void GetCaretPosition(Point caretPos)
7196 caretPos = this.caretPos;
7199 int GetCaretSize(void)
7204 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7210 bool CloseConfirmation(bool parentClosing)
7223 if(!OnClose(parentClosing))
7226 // If you want to skip this, simply set modifiedDocument to false in OnClose
7227 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7229 DialogResult dialogRes;
7232 sprintf(message, $"Save changes to %s?", fileName);
7234 sprintf(message, $"Save changes to Untitled %d?", documentID);
7236 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7238 if(dialogRes == yes)
7240 // TOFIX: Precomp error if brackets are taken out
7241 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7243 else if(dialogRes == cancel)
7249 for(slave = slaves.first; slave; slave = slave.next)
7251 Window w = slave.data;
7252 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7254 // ((Window)slave.data).CloseConfirmation(true);
7263 for(child = children.first; child; child = child.next)
7264 if(child.master != this && !child.CloseConfirmation(true))
7274 // Static methods... move them somewhere else?
7275 void ::RestoreCaret()
7277 if(guiApp.caretOwner)
7278 guiApp.caretOwner.UpdateCaret(false, false);
7281 void ::FreeMouseRange()
7283 guiApp.interfaceDriver.SetMouseRange(null, null);
7287 bool MenuFileClose(MenuItem selection, Modifiers mods)
7289 Window document = activeChild;
7291 document.Destroy(0);
7295 bool MenuFileExit(MenuItem selection, Modifiers mods)
7301 bool MenuFileSave(MenuItem selection, Modifiers mods)
7305 fileMonitor.fileName = null;
7308 if(OnSaveFile(fileName))
7310 //if(OnFileModified != Window::OnFileModified)
7313 fileMonitor.fileName = fileName;
7319 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7320 DialogResult answer = dialog.Modal();
7322 if(answer != yes) return (bool)answer;
7325 return MenuFileSaveAs(selection, mods);
7328 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7330 DialogResult result = (DialogResult)bool::true;
7331 FileDialog fileDialog = saveDialog;
7334 fileDialog = FileDialog {};
7339 fileDialog.filePath = fileName;
7342 char filePath[MAX_FILENAME];
7343 sprintf(filePath, "Untitled %d", documentID);
7344 fileDialog.filePath = filePath;
7346 fileMonitor.fileName = null;
7348 fileDialog.type = save;
7349 fileDialog.text = $"Save As";
7353 fileDialog.master = master.parent ? master : this;
7354 if(fileDialog.Modal() == ok)
7356 char * filePath = fileDialog.filePath;
7358 if(OnSaveFile(filePath))
7361 property::fileName = filePath;
7362 NotifySaved(master, this, filePath);
7367 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7368 DialogResult answer = dialog.Modal();
7383 //if(OnFileModified != Window::OnFileModified && fileName)
7386 fileMonitor.fileName = fileName;
7390 return (bool)result; // Actually returning result from Yes/NoCancel message box
7393 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7395 Window document = activeChild;
7397 for(document = children.first; document; document = next)
7399 next = document.next;
7400 if(document.style.isDocument || document.fileName)
7401 document.MenuFileSave(selection, mods);
7406 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7410 for(document = children.first; document; document = document.next)
7411 //if(document.style.isDocument && document.state == minimized)
7412 if(document.style.isActiveClient && document.state == minimized)
7413 document.SetState(minimized, false, mods);
7417 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7419 Window document = activeChild;
7422 Window firstDocument = null;
7424 OldLink cycle = document.cycle.prev;
7429 if(child.style.isActiveClient && !child.style.hidden)
7433 firstDocument = child;
7434 if(child.state == minimized)
7435 child.SetState(minimized, false, mods);
7438 child.positionID = id++;
7439 child.SetState(normal, false, mods);
7440 child.anchor.left.type = cascade;
7443 child.normalSizeAnchor = *&child.sizeAnchor;
7444 child.normalAnchor = child.anchor;
7446 // Break the anchors for moveable/resizable windows
7447 if(child.style.fixed)
7449 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7451 (*&child.normalAnchor).left = x;
7452 (*&child.normalAnchor).top = y;
7453 (*&child.normalAnchor).right.type = none;
7454 (*&child.normalAnchor).bottom.type = none;
7456 child.normalSizeAnchor.isClientW = false;
7457 child.normalSizeAnchor.isClientH = false;
7458 child.normalSizeAnchor.size.w = w;
7459 child.normalSizeAnchor.size.h = h;
7460 child.anchored = false;
7463 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7465 child.stateAnchor = child.normalAnchor;
7466 child.stateSizeAnchor = child.normalSizeAnchor;
7468 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7469 child.Position(x, y, w, h, true, true, true, true, false, false);
7474 last = children.last;
7475 if(!child.style.stayOnTop)
7476 for(; last && last.style.stayOnTop; last = last.prev);
7477 children.Move(child, last);
7478 childrenOrder.Move(child.order, childrenOrder.last);
7480 if(cycle == document.cycle) break;
7484 firstDocument.Activate();
7489 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7496 // Close all closes all active clients, not all documents
7497 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7499 Window next, document;
7501 for(document = children.first; document; document = next)
7503 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7504 if(document.style.isActiveClient)
7505 if(!document.Destroy(0) && !document.style.hidden)
7511 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7513 if(style.hasMaximize && state != maximized)
7514 SetState(maximized, 0, 0);
7518 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7520 if(style.hasMinimize && state != minimized)
7522 SetState(minimized, 0, 0);
7523 parent.CycleChildren(false, true, false, true);
7528 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7530 MenuMoveOrSize(false, selection ? true : false);
7534 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7536 CycleChildren(false, true, false, true);
7540 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7542 CycleChildren(true, true, false, true);
7546 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7548 MenuMoveOrSize(true, true);
7552 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7555 SetState(normal, 0, 0);
7559 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7562 int64 id = selection.id;
7563 OldLink cycle = activeClient.cycle;
7565 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7568 Window sibling = cycle.data;
7569 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7577 document = cycle.data;
7578 document.Activate();
7580 //if(activeChild.state == maximized)
7581 // document.SetState(maximized, false, mods);
7582 //else if(document.state == minimized)
7583 // document.SetState(normal, false, mods);
7587 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7589 stayOnTop = !style.stayOnTop;
7593 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7595 Window document = activeChild;
7598 Window firstDocument = null;
7599 OldLink cycle = document.cycle;
7603 Window child = cycle.data;
7604 if(child.style.isActiveClient && !child.style.hidden)
7606 if(!firstDocument) firstDocument = child;
7607 if(child.state == minimized)
7608 child.SetState(minimized, false, mods);
7611 child.positionID = id++;
7612 child.SetState(normal, false, mods);
7613 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7615 child.anchor.left.type = hTiled;
7618 child.normalSizeAnchor = *&child.sizeAnchor;
7619 child.normalAnchor = child.anchor;
7621 // Break the anchors for moveable/resizable windows
7622 if(child.style.fixed)
7624 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7626 (*&child.normalAnchor).left = x;
7627 (*&child.normalAnchor).top = y;
7628 (*&child.normalAnchor).right.type = none;
7629 (*&child.normalAnchor).bottom.type = none;
7630 child.normalSizeAnchor.isClientW = false;
7631 child.normalSizeAnchor.isClientH = false;
7632 child.normalSizeAnchor.size.w = w;
7633 child.normalSizeAnchor.size.h = h;
7634 child.anchored = false;
7637 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7639 child.stateAnchor = child.normalAnchor;
7640 child.stateSizeAnchor = child.normalSizeAnchor;
7642 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7643 child.Position(x,y, w, h, true, true, true, true, false, true);
7648 if((cycle = cycle.next) == document.cycle) break;
7651 firstDocument.Activate();
7656 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7658 Window document = activeChild;
7661 Window firstDocument = null;
7663 OldLink cycle = document.cycle;
7668 //if(child.style.isDocument)
7669 if(child.style.isActiveClient && !child.style.hidden)
7671 if(!firstDocument) firstDocument = child;
7672 if(child.state == minimized)
7673 child.SetState(minimized, false, mods);
7676 child.positionID = id++;
7677 child.SetState(normal, false, mods);
7678 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7680 child.anchor.left.type = vTiled;
7683 child.normalSizeAnchor = *&child.sizeAnchor;
7684 child.normalAnchor = child.anchor;
7686 // Break the anchors for moveable/resizable windows
7687 if(child.style.fixed)
7689 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7691 (*&child.normalAnchor).left = x;
7692 (*&child.normalAnchor).top = y;
7693 (*&child.normalAnchor).right.type = none;
7694 (*&child.normalAnchor).bottom.type = none;
7695 child.normalSizeAnchor.isClientW = false;
7696 child.normalSizeAnchor.isClientH = false;
7697 child.normalSizeAnchor.size.w = w;
7698 child.normalSizeAnchor.size.h = h;
7699 child.anchored = false;
7702 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7704 child.stateAnchor = child.normalAnchor;
7705 child.stateSizeAnchor = child.normalSizeAnchor;
7707 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7708 child.Position(x,y, w, h, true, true, true, true, false, true);
7713 if((cycle = cycle.next) == document.cycle) break;
7716 firstDocument.Activate();
7721 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7723 WindowList dialog { master = this };
7724 Window document = (Window)dialog.Modal();
7727 if(activeChild.state == maximized)
7728 document.SetState(maximized, false, mods);
7729 else if(document.state == minimized)
7730 document.SetState(normal, false, mods);
7731 document.Activate();
7737 virtual bool OnCreate(void);
7738 virtual void OnDestroy(void);
7739 virtual void OnDestroyed(void);
7740 virtual bool OnClose(bool parentClosing);
7741 virtual bool OnStateChange(WindowState state, Modifiers mods);
7742 virtual bool OnPostCreate(void);
7743 virtual bool OnMoving(int *x, int *y, int w, int h);
7744 virtual bool OnResizing(int *width, int *height);
7745 virtual void OnResize(int width, int height);
7746 virtual void OnPosition(int x, int y, int width, int height);
7747 virtual bool OnLoadGraphics(void);
7748 virtual void OnApplyGraphics(void);
7749 virtual void OnUnloadGraphics(void);
7750 virtual void OnRedraw(Surface surface);
7751 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7752 virtual void OnActivateClient(Window client, Window previous);
7753 virtual bool OnKeyDown(Key key, unichar ch);
7754 virtual bool OnKeyUp(Key key, unichar ch);
7755 virtual bool OnKeyHit(Key key, unichar ch);
7756 virtual bool OnSysKeyDown(Key key, unichar ch);
7757 virtual bool OnSysKeyUp(Key key, unichar ch);
7758 virtual bool OnSysKeyHit(Key key, unichar ch);
7759 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7760 virtual bool OnMouseLeave(Modifiers mods);
7761 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7762 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7763 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7764 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7765 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7766 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7767 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7768 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7769 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7770 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7771 virtual void OnMouseCaptureLost(void);
7772 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7773 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7774 virtual void OnDrawOverChildren(Surface surface);
7775 virtual bool OnFileModified(FileChange fileChange, char * param);
7776 virtual bool OnSaveFile(char * fileName);
7778 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7779 // Note: A 'client' would refer to isActiveClient, rather than
7780 // being confined to the 'client area' (nonClient == false)
7781 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7782 virtual void OnChildVisibilityToggled(Window child, bool visible);
7783 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7785 // Skins Virtual Functions
7786 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7787 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7788 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7793 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7794 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7795 virtual bool IsMouseMoving(int x, int y, int w, int h)
7799 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7803 virtual void UpdateNonClient();
7804 virtual void SetBox(Box box); // This isn't used anywhere at this time
7805 virtual bool IsInside(int x, int y)
7807 return box.IsPointInside({x, y});
7809 virtual bool IsOpaque()
7811 return (!style.drawBehind || background.a == 255);
7815 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7816 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7817 virtual void Window::NotifySaved(Window window, char * filePath);
7822 property Window parent
7824 property_category $"Layout"
7827 if(value || guiApp.desktop)
7830 Window oldParent = parent;
7831 Anchor anchor = this.anchor;
7833 if(value && value.IsDescendantOf(this)) return;
7834 if(value && value == this)
7836 if(!value) value = guiApp.desktop;
7838 if(value == oldParent) return;
7840 if(!master || (master == this.parent && master == guiApp.desktop))
7841 property::master = value;
7845 parent.children.Remove(this);
7849 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7850 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7851 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7852 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7856 last = value.children.last;
7858 if(style.isDocument)
7861 parent.numDocuments--;
7862 documentID = value.GetDocumentID();
7865 if(style.isActiveClient && !style.hidden)
7867 if(parent && parent != guiApp.desktop && !(style.hidden))
7869 if(state == minimized) parent.numIcons--;
7870 parent.numPositions--;
7874 if(!style.stayOnTop)
7875 for(; last && last.style.stayOnTop; last = last.prev);
7877 value.children.Insert(last, this);
7879 // *** NEW HERE: ***
7881 parent.childrenCycle.Delete(cycle);
7883 parent.childrenOrder.Delete(order);
7886 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7887 // Should something else be done?
7888 if(parent && parent.activeChild == this)
7889 parent.activeChild = null;
7890 if(parent && parent.activeClient == this)
7891 parent.activeClient = null;
7897 int x = position.x, y = position.y, w = size.w, h = size.h;
7901 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7902 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7904 vpw = value.clientSize.w;
7905 vph = value.clientSize.h;
7911 else if(style.fixed)
7913 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7914 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7917 anchor = this.anchor;
7919 if(anchor.left.type == offset) anchor.left.distance = x;
7920 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7921 if(anchor.top.type == offset) anchor.top.distance = y;
7922 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7923 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7924 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7925 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7926 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7927 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7928 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7930 if(!anchor.left.type && !anchor.right.type)
7932 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7933 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7935 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7936 if(!anchor.top.type && !anchor.bottom.type)
7938 anchor.vert.distance = (y + h / 2) - (vph / 2);
7939 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7941 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7944 parent.OnChildAddedOrRemoved(this, false);
7950 parent.childrenCycle.Insert(
7951 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7952 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7954 cycle = OldLink { data = this });
7955 parent.childrenOrder.Insert(
7956 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7957 order = OldLink { data = this });
7960 if(!style.hidden && style.isActiveClient)
7962 positionID = parent.GetPositionID(this);
7963 parent.numPositions++;
7964 if(state == minimized) parent.numIcons--;
7967 // *** FONT INHERITANCE ***
7968 if(!setFont && oldParent)
7969 stopwatching(oldParent, font);
7973 RemoveResource(systemFont);
7976 // TESTING WITH WATCHERS:
7977 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7978 // usedFont = setFont ? setFont : (systemFont);
7982 if(guiApp.currentSkin)
7984 systemFont = guiApp.currentSkin.SystemFont();
7987 usedFont = systemFont;
7988 AddResource(systemFont);
7996 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8005 if(value.rootWindow && value.rootWindow.display && rootWindow)
8007 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8008 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8011 UnloadGraphics(false);
8014 LoadGraphics(false, false);
8017 if(value.rootWindow != rootWindow)
8018 DisplayModeChanged();
8022 scrolledPos.x = MININT; // Prevent parent update
8024 bool anchored = this.anchored;
8025 property::anchor = anchor;
8026 this.anchored = anchored;
8031 if(guiApp.currentSkin)
8032 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8034 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8035 Position(x, y, w, h, true, true, true, true, false, true);
8040 // else parent = value;
8042 oldParent.OnChildAddedOrRemoved(this, true);
8045 get { return parent; }
8048 property Window master
8050 property_category $"Behavior"
8053 //if(this == value) return;
8054 if(value && value.IsSlaveOf(this)) return;
8060 OldLink slaveHolder;
8061 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8062 if(slaveHolder.data == this)
8064 master.slaves.Delete(slaveHolder);
8071 value.slaves.Add(OldLink { data = this });
8076 master.hotKeys.Remove(hotKey);
8077 value.hotKeys.Add(hotKey);
8080 if(master && master.defaultControl == this)
8081 master.defaultControl = null;
8083 if(style.isDefault && !value.defaultControl)
8084 value.defaultControl = this;
8089 get { return master ? master : parent; }
8092 property char * caption
8094 property_category $"Appearance"
8101 caption = new char[strlen(value)+1];
8103 strcpy(caption, value);
8108 get { return caption; }
8113 property_category $"Behavior"
8122 master.hotKeys.Add(hotKey = HotKeySlot { });
8126 hotKey.window = this;
8131 master.hotKeys.Delete(hotKey);
8136 get { return hotKey ? hotKey.key : 0; }
8139 property Color background
8141 property_category $"Appearance"
8144 background.color = value;
8149 if(this == rootWindow)
8150 guiApp.interfaceDriver.SetRootWindowColor(this);
8153 get { return background.color; }
8156 property Percentage opacity
8158 property_category $"Appearance"
8161 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8162 drawBehind = (background.a == 255) ? false : true;
8164 get { return background.a / 255.0f; }
8167 property Color foreground
8169 property_category $"Appearance"
8177 get { return foreground; }
8180 property BorderStyle borderStyle
8182 property_category $"Appearance"
8185 if(!((BorderBits)value).fixed)
8187 style.hasClose = false;
8188 style.hasMaximize = false;
8189 style.hasMinimize = false;
8190 nativeDecorations = false;
8192 style.borderBits = value;
8196 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8198 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8199 Position(x, y, w, h, true, true, true, true, false, true);
8200 CreateSystemChildren();
8203 get { return (BorderStyle)style.borderBits; }
8206 property Size minClientSize
8208 property_category $"Layout"
8209 set { minSize = value; }
8210 get { value = minSize; }
8213 property Size maxClientSize
8215 property_category $"Layout"
8216 set { maxSize = value; }
8217 get { value = maxSize; }
8220 property bool hasMaximize
8222 property_category $"Window Style"
8225 style.hasMaximize = value;
8226 if(value) { style.fixed = true; style.contour = true; }
8230 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8232 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8233 Position(x, y, w, h, true, true, true, true, false, true);
8235 CreateSystemChildren();
8238 get { return style.hasMaximize; }
8241 property bool hasMinimize
8243 property_category $"Window Style"
8246 style.hasMinimize = value;
8247 if(value) { style.fixed = true; style.contour = true; }
8251 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8253 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8254 Position(x, y, w, h, true, true, true, true, false, true);
8256 CreateSystemChildren();
8259 get { return style.hasMinimize; }
8262 property bool hasClose
8264 property_category $"Window Style"
8267 style.hasClose = value;
8268 if(value) { style.fixed = true; style.contour = true; }
8272 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8273 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8274 Position(x, y, w, h, true, true, true, true, false, true);
8275 CreateSystemChildren();
8278 get { return style.hasClose; }
8281 property bool nonClient
8283 property_category $"Layout"
8286 style.nonClient = value;
8288 style.stayOnTop = true;
8290 get { return style.nonClient; }
8293 property bool inactive
8295 property_category $"Behavior"
8300 // *** NEW HERE: ***
8304 parent.childrenCycle.Delete(cycle);
8306 parent.childrenOrder.Delete(order);
8313 active = false; // true;
8314 if(parent.activeChild == this)
8315 parent.activeChild = null;
8316 if(parent.activeClient == this)
8317 parent.activeClient = null;
8326 parent.childrenCycle.Insert(
8327 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8328 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8330 cycle = OldLink { data = this });
8332 parent.childrenOrder.Insert(
8333 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8334 order = OldLink { data = this });
8337 style.inactive = value;
8339 get { return style.inactive; }
8342 property bool clickThrough
8344 property_category $"Behavior"
8345 set { style.clickThrough = value; }
8346 get { return style.clickThrough; }
8349 property bool isRemote
8351 property_category $"Behavior"
8352 set { style.isRemote = value; }
8353 get { return style.isRemote; }
8356 property bool noCycle
8358 property_category $"Behavior"
8359 set { style.noCycle = value; }
8360 get { return style.noCycle; }
8363 property bool isModal
8365 property_category $"Behavior"
8366 set { style.modal = value; }
8367 get { return style.modal; }
8370 property bool interim
8372 property_category $"Behavior"
8373 set { style.interim = value; }
8374 get { return style.interim; }
8377 property bool tabCycle
8379 property_category $"Behavior"
8380 set { style.tabCycle = value; }
8381 get { return style.tabCycle; }
8384 property bool isDefault
8386 property_category $"Behavior"
8394 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8395 if(sibling != this && sibling.style.isDefault)
8396 sibling.style.isDefault = false;*/
8397 if(master.defaultControl)
8398 master.defaultControl.style.isDefault = false;
8399 master.defaultControl = this;
8401 else if(master.defaultControl == this)
8402 master.defaultControl = null;
8406 style.isDefault = value;
8408 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8410 get { return style.isDefault; }
8413 property bool drawBehind
8415 property_category $"Window Style"
8416 set { style.drawBehind = value; }
8417 get { return style.drawBehind; }
8420 property bool hasMenuBar
8422 property_category $"Window Style"
8432 if(created && !menuBar)
8439 anchor = Anchor { top = 23, left = 1, right = 1 },
8441 inactive = true, nonClient = true
8446 else if(created && menuBar)
8451 style.hasMenuBar = value;
8453 get { return style.hasMenuBar; }
8456 property bool hasStatusBar
8458 property_category $"Window Style"
8465 statusBar = StatusBar { this };
8473 style.hasStatusBar = value;
8475 get { return style.hasStatusBar; }
8477 property bool stayOnTop
8479 property_category $"Window Style"
8484 if(created && !style.stayOnTop)
8486 if(rootWindow == this)
8487 guiApp.interfaceDriver.OrderRootWindow(this, true);
8488 else if(parent.children.last != this)
8490 parent.children.Move(this, parent.children.last);
8494 style.stayOnTop = true;
8498 if(created && style.stayOnTop)
8500 if(rootWindow == this)
8501 guiApp.interfaceDriver.OrderRootWindow(this, false);
8508 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8509 order && ((Window)order.data).style.stayOnTop;
8510 order = (order == parent.childrenOrder.first) ? null : order.prev);
8511 last = order ? order.data : null;
8515 for(last = parent.children.last;
8516 last && last.style.stayOnTop;
8520 parent.children.Move(this, last);
8524 style.stayOnTop = false;
8527 get { return style.stayOnTop; }
8532 property_category $"Window Style"
8542 if(menuBar && !value)
8549 if(!menuBar && style.hasMenuBar && value)
8553 this, menu = value, isMenuBar = true,
8554 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8555 inactive = true, nonClient = true
8559 UpdateActiveDocument(null);
8562 get { return menu; }
8565 property FontResource font
8567 property_category $"Appearance"
8569 isset { return setFont ? true : false; }
8574 if(value && !setFont) { stopwatching(parent, font); }
8575 else if(!value && setFont)
8581 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8590 RemoveResource(setFont);
8595 RemoveResource(systemFont);
8602 AddResource(setFont);
8605 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8608 systemFont = guiApp.currentSkin.SystemFont();
8610 usedFont = systemFont;
8611 AddResource(systemFont);
8619 get { return usedFont; }
8622 property SizeAnchor sizeAnchor
8624 property_category $"Layout"
8627 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8628 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8629 sizeAnchor.isClientW != sizeAnchor.isClientH;
8636 normalSizeAnchor = sizeAnchor;
8638 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8640 stateAnchor = normalAnchor;
8641 stateSizeAnchor = normalSizeAnchor;
8643 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8644 Position(x,y, w, h, true, true, true, true, false, true);
8651 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8652 sizeAnchor.isClientW,
8653 sizeAnchor.isClientH
8660 property_category $"Layout"
8663 Anchor thisAnchor = anchor;
8664 SizeAnchor thisSizeAnchor = sizeAnchor;
8665 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8666 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8667 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8668 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8669 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8670 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8676 sizeAnchor.isClientW = false;
8677 sizeAnchor.isClientH = false;
8678 sizeAnchor.size = value;
8680 normalSizeAnchor = sizeAnchor;
8682 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8684 stateAnchor = normalAnchor;
8685 stateSizeAnchor = normalSizeAnchor;
8687 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8688 Position(x, y, w, h, true, true, true, true, false, true);
8689 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8692 get { value = size; }
8695 property Size clientSize
8697 property_category $"Layout"
8700 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8701 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8702 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8707 sizeAnchor.isClientW = true;
8708 sizeAnchor.isClientH = true;
8709 sizeAnchor.size = value;
8711 normalSizeAnchor = sizeAnchor;
8713 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8715 stateAnchor = normalAnchor;
8716 stateSizeAnchor = normalSizeAnchor;
8718 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8719 Position(x,y, w, h, true, true, true, true, false, true);
8722 get { value = clientSize; }
8725 property Size initSize { get { value = sizeAnchor.size; } };
8727 property Anchor anchor
8729 property_category $"Layout"
8730 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8736 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8738 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8739 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8741 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8743 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8744 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8748 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8750 anchor.left.distance = 0;
8751 anchor.horz.type = 0;
8753 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8755 anchor.top.distance = 0;
8756 anchor.vert.type = 0;
8765 normalAnchor = anchor;
8767 // Break the anchors for moveable/resizable windows
8768 /*if(style.fixed ) //&& value.left.type == cascade)
8770 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8772 this.anchor = normalAnchor = Anchor { left = x, top = y };
8773 normalSizeAnchor = SizeAnchor { { w, h } };
8776 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8778 stateAnchor = normalAnchor;
8779 stateSizeAnchor = normalSizeAnchor;
8781 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8782 Position(x, y, w, h, true, true, true, true, false, true);
8791 get { value = this ? anchor : Anchor { }; }
8794 property Point position
8796 property_category $"Layout"
8799 if(value == null) return;
8801 anchor.left = value.x;
8802 anchor.top = value.y;
8803 anchor.right.type = none;
8804 anchor.bottom.type = none;
8809 normalAnchor = anchor;
8811 // Break the anchors for moveable/resizable windows
8815 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8817 normalAnchor.left = x;
8818 normalAnchor.top = y;
8819 normalAnchor.right.type = none;
8820 normalAnchor.bottom.type = none;
8821 normalSizeAnchor.size.width = w;
8822 normalSizeAnchor.size.height = h;
8826 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8828 stateAnchor = normalAnchor;
8829 stateSizeAnchor = normalSizeAnchor;
8831 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8832 Position(x,y, w, h, true, true, true, true, false, true);
8836 get { value = position; }
8839 property bool disabled
8841 property_category $"Behavior"
8844 if(this && disabled != value)
8851 get { return (bool)disabled; }
8854 property bool isEnabled
8859 for(parent = this; parent; parent = parent.parent)
8866 property WindowState state
8868 property_category $"Behavior"
8869 set { SetState(value, false, 0); }
8870 get { return this ? state : 0; }
8873 property bool visible
8875 property_category $"Behavior"
8878 if(this && !value && !style.hidden && parent)
8880 bool wasActiveChild = parent.activeChild == this;
8881 Window client = null;
8883 style.hidden = true;
8884 if(style.isActiveClient)
8886 parent.numPositions--;
8887 if(state == minimized) parent.numIcons--;
8892 OldLink prevOrder = null;
8894 if(rootWindow == this)
8895 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8898 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8901 box.left -= parent.clientStart.x;
8902 box.top -= parent.clientStart.y;
8903 box.right -= parent.clientStart.x;
8904 box.bottom -= parent.clientStart.y;
8908 if(_isModal && master && master.modalSlave == this)
8909 master.modalSlave = null;
8913 OldLink tmpPrev = order.prev;
8914 client = tmpPrev ? tmpPrev.data : null;
8915 if(client && !client.style.hidden && !client.destroyed && client.created)
8916 prevOrder = tmpPrev;
8919 client = tmpPrev ? tmpPrev.data : null;
8920 if(client == this) { client = null; break; }
8921 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8923 tmpPrev = client.order.prev;
8928 prevOrder = tmpPrev;
8933 // If this window can be an active client, make sure the next window we activate can also be one
8934 if(!style.nonClient && style.isActiveClient)
8936 tmpPrev = prevOrder;
8939 client = tmpPrev ? tmpPrev.data : null;
8940 if(client == this) { client = null; break; }
8941 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8943 tmpPrev = client.order.prev;
8948 prevOrder = tmpPrev;
8952 if(client && client.style.hidden) client = null;
8956 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8958 if(order && prevOrder && prevOrder.data != this)
8959 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8961 ActivateEx(false, false, false, true, null, null);
8963 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8964 if(parent.activeClient == this)
8966 parent.activeClient = null;
8967 parent.UpdateActiveDocument(null);
8970 else if(parent.activeClient == this)
8972 parent.activeClient = client;
8973 parent.UpdateActiveDocument(this);
8976 // *** Not doing this anymore ***
8979 parent.childrenCycle.Delete(cycle);
8981 parent.childrenOrder.Delete(order);
8986 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8991 else if(this && value && style.hidden)
8993 style.hidden = false;
8996 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8997 if(rootWindow == this)
8998 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9000 if(_isModal && master)
9001 master.modalSlave = this;
9003 if(style.isActiveClient)
9005 positionID = parent.GetPositionID(this);
9006 parent.numPositions++;
9007 if(state == minimized) parent.numIcons++;
9010 // *** NOT DOING THIS ANYMORE ***
9012 if(!(style.inactive))
9014 if(!(style.noCycle))
9016 cycle = parent.childrenCycle.AddAfter(
9017 (parent.activeChild && parent.activeChild.cycle) ?
9018 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9021 order = parent.childrenOrder.AddAfter(
9022 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9029 if(true || !parent.activeChild)
9030 ActivateEx(true, false, true, true, null, null);
9032 if(creationActivation == activate)
9033 ActivateEx(true, false, true, true, null, null);
9034 else if(creationActivation == flash && !object)
9037 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9041 ConsequentialMouseMove(false);
9047 style.hidden = !value;
9050 get { return (style.hidden || !setVisible) ? false : true; }
9053 property bool isDocument
9055 property_category $"Document"
9056 set { style.isDocument = value; }
9057 get { return style.isDocument; }
9060 property bool mergeMenus
9062 property_category $"Window Style"
9063 set { mergeMenus = value; }
9064 get { return (bool)mergeMenus; }
9067 property bool hasHorzScroll
9069 property_category $"Window Style"
9074 if(!style.hasHorzScroll && created)
9076 CreateSystemChildren();
9077 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9080 else if(style.hasHorzScroll)
9084 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9086 style.hasHorzScroll = value;
9089 get { return style.hasHorzScroll; }
9092 property bool hasVertScroll
9094 property_category $"Window Style"
9099 if(!style.hasVertScroll && created)
9101 style.hasVertScroll = true;
9102 CreateSystemChildren();
9103 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9106 else if(style.hasVertScroll)
9110 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9112 style.hasVertScroll = value;
9114 get { return style.hasVertScroll; }
9117 property bool dontHideScroll
9119 property_category $"Behavior"
9122 scrollFlags.dontHide = value;
9125 //UpdateScrollBars(true, true);
9126 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9130 // UpdateScrollBars(true, true);
9131 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9134 get { return scrollFlags.dontHide; }
9137 property bool dontScrollVert
9139 property_category $"Behavior"
9140 set { style.dontScrollVert = value; }
9141 get { return style.dontScrollVert; }
9143 property bool dontScrollHorz
9145 property_category $"Behavior"
9146 set { style.dontScrollHorz = value; }
9147 get { return style.dontScrollHorz; }
9150 property bool snapVertScroll
9152 property_category $"Behavior"
9155 scrollFlags.snapY = value;
9156 if(sbv) sbv.snap = value;
9158 get { return scrollFlags.snapY; }
9160 property bool snapHorzScroll
9162 property_category $"Behavior"
9165 scrollFlags.snapX = value;
9166 if(sbh) sbh.snap = value;
9168 get { return scrollFlags.snapX; }
9171 property Point scroll
9173 property_category $"Behavior"
9174 set { SetScrollPosition(value.x, value.y); }
9175 get { value = scroll; }
9178 property bool modifyVirtualArea
9180 property_category $"Behavior"
9181 set { modifyVirtArea = value; }
9182 get { return (bool)modifyVirtArea; }
9185 property bool dontAutoScrollArea
9187 property_category $"Behavior"
9188 // Activating a child control out of view will automatically scroll to make it in view
9189 set { noAutoScrollArea = value; }
9190 get { return (bool)noAutoScrollArea; }
9193 property char * fileName
9195 property_category $"Document"
9198 if(menu && ((!fileName && value) || (fileName && !value)))
9200 MenuItem item = menu.FindItem(MenuFileSave, 0);
9201 if(item) item.disabled = !modifiedDocument && value;
9206 if(value && value[0])
9207 fileName = CopyString(value);
9209 if(parent && this == parent.activeClient)
9210 parent.UpdateActiveDocument(null);
9214 // if(style.isDocument)
9216 fileMonitor.fileName = value;
9218 get { return fileName; }
9223 property_category $"Data"
9228 property bool modifiedDocument
9230 property_category $"Document"
9233 if(style.isDocument || fileName)
9237 MenuItem item = menu.FindItem(MenuFileSave, 0);
9238 if(item) item.disabled = !value && fileName;
9242 if(modifiedDocument != value)
9244 modifiedDocument = value;
9245 if(style.isDocument || fileName)
9249 get { return (bool)modifiedDocument; }
9252 property bool showInTaskBar
9254 property_category $"Window Style"
9255 set { style.showInTaskBar = value; }
9256 get { return (style.showInTaskBar; }
9258 property FileDialog saveDialog { set { saveDialog = value; } };
9259 property bool isActiveClient
9261 property_category $"Behavior"
9262 set { style.isActiveClient = value; }
9263 get { return style.isActiveClient; }
9266 property Cursor cursor
9268 property_category $"Appearance"
9272 SelectMouseCursor();
9274 get { return cursor; }
9277 //#if !defined(ECERE_VANILLA)
9278 property char * name
9280 property_category $"Design"
9283 return (this && object) ? object.name : null;
9288 activeDesigner.RenameObject(object, value);
9292 property char * displayDriver
9294 property_category $"Behavior"
9297 dispDriver = GetDisplayDriver(value);
9298 //DisplayModeChanged();
9302 return dispDriver ? dispDriver.name : null;
9306 // RUNTIME PROPERTIES
9307 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9308 property Size scrollArea
9310 property_category $"Behavior"
9314 SetScrollArea(value.w, value.h, false);
9316 SetScrollArea(0,0, true);
9318 get { value = scrollArea; }
9321 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9326 property_category $"Layout"
9327 set { if(this) is3D = value; }
9328 get { return (bool)is3D; }
9331 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9333 // Will be merged with font later
9334 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9335 property Point clientStart { get { value = clientStart; } };
9336 property Point absPosition { get { value = absPosition; } };
9337 property Anchor normalAnchor { get {value = normalAnchor; } };
9338 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9339 property bool active { get { return (bool)active; } };
9340 property bool created { get { return (bool)created; } };
9341 property bool destroyed { get { return (bool)destroyed; } };
9342 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9343 property Window firstChild { get { return children.first; } };
9344 property Window lastChild { get { return children.last; } };
9345 property Window activeClient { get { return activeClient; } };
9346 property Window activeChild { get { return activeChild; } };
9347 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9348 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9349 property ScrollBar horzScroll { get { return sbh; } };
9350 property ScrollBar vertScroll { get { return sbv; } };
9351 property StatusBar statusBar { get { return statusBar; } };
9352 property Window rootWindow { get { return rootWindow; } };
9353 property bool closing { get { return (bool)closing; } set { closing = value; } };
9354 property int documentID { get { return documentID; } };
9355 property Window previous { get { return prev; } }
9356 property Window next { get { return next; } }
9357 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9358 property PopupMenu menuBar { get { return menuBar; } }
9359 property ScrollBar sbv { get { return sbv; } }
9360 property ScrollBar sbh { get { return sbh; } }
9361 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9362 property void * systemHandle { get { return windowHandle; } }
9363 property Button minimizeButton { get { return sysButtons[0]; } };
9364 property Button maximizeButton { get { return sysButtons[1]; } };
9365 property Button closeButton { get { return sysButtons[2]; } };
9366 property BitmapResource icon
9368 get { return icon; }
9372 if(icon) incref icon;
9374 guiApp.interfaceDriver.SetIcon(this, value);
9377 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9378 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9379 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9380 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9381 property bool nativeDecorations
9383 get { return (bool)nativeDecorations; }
9384 set { nativeDecorations = value; }
9385 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9388 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9389 bool result = false;
9390 if(nativeDecorations)
9392 if(rootWindow == this)
9396 if(formDesigner && activeDesigner)
9398 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9399 Window form = cd ? cd.form : null;
9400 if(form && parent == form.parent)
9405 return result != style.fixed;
9409 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9411 property char * text
9413 property_category $"Deprecated"
9415 set { property::caption = value; }
9416 get { return property::caption; }
9422 WindowBits style; // Window Style
9423 char * caption; // Name / Caption
9424 Window parent; // Parent window
9425 OldList children; // List of children in Z order
9426 Window activeChild; // Child window having focus
9427 Window activeClient;
9428 Window previousActive; // Child active prior to activating the default child
9429 Window master; // Window owning and receiving notifications concerning this window
9430 OldList slaves; // List of windows belonging to this window
9431 Display display; // Display this window is drawn into
9433 Point position; // Position in parent window client area
9434 Point absPosition; // Absolute position
9435 Point clientStart; // Client area position from (0,0) in this window
9437 Size clientSize; // Client area size
9438 Size scrollArea; // Virtual Scroll area size
9439 Size reqScrollArea; // Requested virtual area size
9440 Point scroll; // Virtual area scrolling position
9441 ScrollBar sbh, sbv; // Scrollbar window handles
9442 Cursor cursor; // Mouse cursor used for this window
9445 StatusBar statusBar;
9446 Button sysButtons[3];
9448 Box clientArea; // Client Area box clipped to parent
9450 HotKeySlot hotKey; // HotKey for this window
9454 ScrollFlags scrollFlags;// Window Scrollbar Flags
9455 int64 id; // Control ID
9457 ColorAlpha background; // Background color used to draw the window area
9459 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9460 OldList childrenCycle; // Cycling order
9461 OldLink cycle; // Element of parent's cycling order
9462 OldList childrenOrder; // Circular Z-Order
9463 OldLink order; // Element of parent's circular Z-Order
9464 Window modalSlave; // Slave window blocking this window's interaction
9466 Window rootWindow; // Topmost system managed window
9467 void * windowHandle; // System window handle
9469 DialogResult returnCode;// Return code for modal windows
9471 Point sbStep; // Scrollbar line scrolling steps
9474 SizeAnchor stateSizeAnchor;
9476 Anchor normalAnchor;
9477 SizeAnchor normalSizeAnchor;
9479 Size skinMinSize; // Minimal window size based on style
9480 Point scrolledPos; // Scrolled position
9481 Box box; // Window box clipped to parent
9482 Box * against; // What to clip the box to
9484 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9485 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9486 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9487 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9488 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9489 Point scrolledArea; // Distance to scroll area by
9490 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9492 OldList hotKeys; // List of the hotkeys of all children
9493 Window defaultControl; // Default child control
9497 ColorAlpha * palette; // Color palette used for this window
9499 int caretSize; // Size of caret, non zero if a caret is present
9500 Point caretPos; // Caret position
9502 void * systemParent; // Parent System Window for embedded windows
9509 WindowState lastState;
9511 FileMonitor fileMonitor
9513 this, FileChange { modified = true };
9515 bool OnFileNotify(FileChange action, char * param)
9518 fileMonitor.StopMonitoring();
9519 if(OnFileModified(action, param))
9520 fileMonitor.StartMonitoring();
9525 FontResource setFont, systemFont;
9526 FontResource usedFont;
9527 FontResource captionFont;
9529 FileDialog saveDialog;
9531 SizeAnchor sizeAnchor;
9533 // FormDesigner data
9536 Extent * tempExtents; //[4];
9537 BitmapResource icon;
9539 CreationActivationOption creationActivation;
9542 bool active:1; // true if window and ancestors are active
9543 bool acquiredInput:1; // true if the window is processing state based input
9544 bool modifiedDocument:1;
9545 bool disabled:1; // true if window cannot interact
9546 bool isForegroundWindow:1;// true while a root window is being activated
9547 bool visible:1; // Visibility flag
9548 bool destroyed:1; // true if window is being destroyed
9549 bool anchored:1; // true if this window is repositioned when the parent resizes
9550 bool dirty:1; // Flag set to true if any descendant must be redrawn
9556 bool modifyVirtArea:1;
9557 bool noAutoScrollArea:1;
9560 bool setVisible:1; // FOR FORM DESIGNER
9566 bool useSharedMemory:1;
9569 bool nativeDecorations:1;
9570 bool manageDisplay:1;
9571 bool formDesigner:1; // True if we this is running in the form editor
9574 // Checks used internally for them not to take effect in FormDesigner
9575 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9576 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9578 WindowController controller;
9579 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9582 public class CommonControl : Window
9584 // creationActivation = doNothing;
9587 public property String toolTip
9589 property_category $"Appearance"
9592 if(created) CommonControl::OnDestroy();
9594 toolTip = value ? ToolTip { tip = value; } : null;
9596 if(created) CommonControl::OnCreate();
9598 get { return toolTip ? toolTip.tip : null; }
9604 // (Very) Ugly work around for the fact that the parent watcher
9605 // won't fire when it's already been disconnected...
9606 eInstance_FireSelfWatchers(toolTip,
9607 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9613 toolTip.parent = this;
9622 public class Percentage : float
9624 char * OnGetString(char * string, float * fieldData, bool * needClass)
9628 sprintf(string, "%.2f", this);
9629 c = strlen(string)-1;
9632 if(string[c] != '0')
9633 last = Max(last, c);
9634 if(string[c] == '.')
9647 public void ApplySkin(Class c, char * name, void ** vTbl)
9649 char className[1024];
9654 subclass(Window) wc = (subclass(Window))c;
9655 subclass(Window) base = (subclass(Window))c.base;
9657 sprintf(className, "%sSkin_%s", name, c.name);
9658 wc.pureVTbl = c._vTbl;
9659 c._vTbl = new void *[c.vTblSize];
9660 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9661 sc = eSystem_FindClass(c.module.application, className);
9665 for(m = 0; m < c.base.vTblSize; m++)
9667 if(c._vTbl[m] == base.pureVTbl[m])
9668 c._vTbl[m] = vTbl[m];
9673 for(m = 0; m < c.vTblSize; m++)
9675 if(sc._vTbl[m] != wc.pureVTbl[m])
9676 c._vTbl[m] = sc._vTbl[m];
9680 for(d = c.derivatives.first; d; d = d.next)
9682 ApplySkin(d.data, name, c._vTbl);
9686 public void UnapplySkin(Class c)
9688 char className[1024];
9690 subclass(Window) wc = (subclass(Window))c;
9691 subclass(Window) base = (subclass(Window))c.base;
9694 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9697 c._vTbl = wc.pureVTbl;
9701 for(d = c.derivatives.first; d; d = d.next)
9703 UnapplySkin(d.data);
9707 void CheckFontIntegrity(Window window)
9712 if(window.usedFont && window.usedFont.font == 0xecececec)
9714 FontResource uf = window.usedFont;
9715 char * className = window._class.name;
9716 char * text = window.text;
9719 for(c = window.firstChild; c; c = c.next)
9720 CheckFontIntegrity(c);
9724 public class ControllableWindow : Window
9726 /*WindowController controller;
9727 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9728 ~ControllableWindow() { delete controller; }*/
9731 class WindowControllerInterface : ControllableWindow
9733 bool OnKeyDown(Key key, unichar ch)
9735 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9737 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9741 bool OnKeyUp(Key key, unichar ch)
9743 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9745 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9749 bool OnKeyHit(Key key, unichar ch)
9751 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9753 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9757 bool OnMouseMove(int x, int y, Modifiers mods)
9759 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9761 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9765 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9767 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9769 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9773 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9775 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9777 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9781 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9783 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9785 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9789 bool OnRightButtonDown(int x, int y, Modifiers mods)
9791 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9793 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9797 bool OnRightButtonUp(int x, int y, Modifiers mods)
9799 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9801 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9805 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9807 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9809 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9813 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9815 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9817 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9821 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9823 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9825 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9829 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9831 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9833 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9837 void OnResize(int width, int height)
9839 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9840 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9843 void OnRedraw(Surface surface)
9845 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9846 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9851 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9853 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9857 bool OnLoadGraphics()
9859 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9861 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9865 void OnUnloadGraphics()
9867 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9868 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9872 public class WindowController<class V>
9875 property Window window
9879 uint size = class(Window).vTblSize;
9882 windowVTbl = new void *[size];
9883 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9884 if(value._vTbl == value._class._vTbl)
9886 value._vTbl = new void *[value._class.vTblSize];
9887 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9891 for(c = 0; c < size; c++)
9893 void * function = class(WindowControllerInterface)._vTbl[c];
9894 if(function != DefaultFunction)
9895 value._vTbl[c] = function;
9897 value._vTbl[c] = windowVTbl[c];
9902 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9905 get { return window; }
9907 property V controlled
9909 set { controlled = value; }
9910 get { return controlled; }
9912 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9913 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9914 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9915 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9916 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9917 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9918 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9919 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9920 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9921 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9922 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9923 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9924 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9925 virtual void V::OnResize(WindowController controller, int width, int height);
9926 virtual void V::OnRedraw(WindowController controller, Surface surface);
9927 virtual bool V::OnCreate(WindowController controller);
9928 virtual bool V::OnLoadGraphics(WindowController controller);
9929 virtual void V::OnUnloadGraphics(WindowController controller);
9932 int (** windowVTbl)();