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(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1041 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1042 GetDecorationsSize(&ew, &eh);
1044 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1046 // Leave room for non client windows (eventually dockable panels)
1048 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1049 for(win = parent.children.first; win; win = win.next)
1051 if(!win.isActiveClient && win.visible)
1053 Size size = win.size;
1054 Point pos = win.position;
1055 int left = pos.x, top = pos.y;
1056 int right = pos.x + size.w, bottom = pos.y + size.h;
1057 if(win.size.w > win.size.h)
1060 loY = Max(loY, bottom);
1061 else if(top > ph - ph / 4)
1062 hiY = Min(hiY, top);
1067 loX = Max(loX, right);
1068 else if(left > pw - pw / 4)
1069 hiX = Min(hiX, left);
1078 if(parent.sbv && !parent.sbv.style.hidden)
1079 pw += guiApp.currentSkin.VerticalSBW();
1080 if(parent.sbh && !parent.sbh.style.hidden)
1081 ph += guiApp.currentSkin.HorizontalSBH();
1083 if(anchor.left.type == cascade)
1085 w = (int)(pw * 0.80);
1086 h = (int)(ph * 0.80);
1088 else if(anchor.left.type >= vTiled)
1093 numTiling = parent.numPositions - parent.numIcons;
1094 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1095 if(anchor.left.type == vTiled)
1097 tilingH = (int)sqrt(numTiling);
1098 tilingW = numTiling / tilingH;
1102 tilingW = (int)sqrt(numTiling);
1103 tilingH = numTiling / tilingW;
1106 leftOver = numTiling - tilingH * tilingW;
1109 tilingSplit = (tilingW - leftOver) * tilingH;
1110 tilingLastH = tilingH+1;
1113 tilingSplit = numTiling;
1115 if(positionID >= tilingSplit)
1117 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1118 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1119 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1120 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1124 x = xOffset + pw * (positionID / tilingH) / tilingW;
1125 y = yOffset + ph * (positionID % tilingH) / tilingH;
1126 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1127 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1131 SNAPDOWN(x, textCellW);
1132 SNAPDOWN(y, textCellH);
1133 SNAPDOWN(x2, textCellW);
1134 SNAPDOWN(y2, textCellH);
1142 if(sizeAnchor.isClientW) w += ew;
1143 if(sizeAnchor.isClientH) h += eh;
1145 if(anchor.left.type == offset)
1146 x = anchor.left.distance;
1147 else if(anchor.left.type == relative)
1148 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1149 else if(anchor.right.type == relative)
1150 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1151 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1152 else if(anchor.right.type == offset)
1153 ex = vpw - anchor.right.distance;
1155 if(anchor.top.type == offset)
1156 y = anchor.top.distance;
1157 else if(anchor.top.type == relative)
1158 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1159 else if(anchor.bottom.type == relative)
1160 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1161 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1162 else if(anchor.bottom.type == offset)
1163 ey = vph - anchor.bottom.distance;
1165 if(anchor.left.type && anchor.right.type)
1167 switch(anchor.right.type)
1170 ex = pw * (1.0f-anchor.right.percent);
1171 w = Max((int)(ex + 0.5) - x, 0);
1174 ex = vpw - anchor.right.distance;
1175 w = Max((int)(ex + 0.5) - x, 0);
1179 if(anchor.top.type && anchor.bottom.type)
1181 switch(anchor.bottom.type)
1184 ey = ph * (1.0f-anchor.bottom.percent);
1185 h = Max((int)(ey + 0.5) - y, 0);
1188 ey = vph - anchor.bottom.distance;
1189 h = Max((int)(ey + 0.5) - y, 0);
1198 if(state == normal /*|| state == Hidden*/)
1200 bool addSbV = false, addSbH = false;
1202 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1203 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1205 w = Max(w, minSize.w);
1206 h = Max(h, minSize.h);
1207 w = Min(w, maxSize.w);
1208 h = Min(h, maxSize.h);
1210 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1212 if(w) w -= guiApp.currentSkin.VerticalSBW();
1215 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1217 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1221 if(!OnResizing(&w, &h))
1227 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1228 w += guiApp.currentSkin.VerticalSBW();
1229 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1230 h += guiApp.currentSkin.HorizontalSBH();
1232 w = Max(w, skinMinSize.w);
1233 h = Max(h, skinMinSize.h);
1246 SNAPDOWN(w, textCellW);
1247 SNAPDOWN(h, textCellH);
1250 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1252 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1255 (pw - w) / CASCADE_SPACE,
1256 (ph - h) / CASCADE_SPACE);
1262 cascW = (pw - w) / (numCascade-1);
1263 cascH = (ph - h) / (numCascade-1);
1264 SNAPDOWN(cascW, textCellW);
1265 SNAPDOWN(cascH, textCellH);
1266 cascadeW = (float)cascW;
1267 cascadeH = (float)cascH;
1271 numCascade = Max(numCascade, 2);
1272 cascadeW = (float)(pw - w) / (numCascade-1);
1273 cascadeH = (float)(ph - h) / (numCascade-1);
1276 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1277 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1279 else if(anchor.left.type < vTiled)
1281 if(!anchor.left.type || anchor.horz.type == middleRelative)
1283 if(!anchor.right.type)
1285 if(anchor.horz.type == middleRelative)
1286 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1288 x = vpw / 2 + anchor.horz.distance - w / 2;
1294 // case A_EDGE: x = x - w; break;
1296 if(!anchor.top.type || anchor.vert.type == middleRelative)
1298 if(!anchor.bottom.type)
1300 if(anchor.vert.type == middleRelative)
1301 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1303 y = vph / 2 + anchor.vert.distance - h / 2;
1309 // case A_EDGE: y = y - h; break;
1312 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1320 SNAPDOWN(x, textCellW);
1321 SNAPDOWN(y, textCellH);
1333 if(anchored && style.fixed && style.isActiveClient)
1338 void UpdateCaret(bool forceUpdate, bool erase)
1340 static Window lastWindow = null;
1341 static int caretX, caretY, caretSize;
1343 if(guiApp && guiApp.caretOwner == this)
1345 int x = caretPos.x - scroll.x;
1346 int y = caretPos.y - scroll.y;
1348 if((erase || this.caretSize) &&
1349 x >= clientArea.left && x <= clientArea.right &&
1350 y >= clientArea.top && y <= clientArea.bottom)
1354 guiApp.interfaceDriver.SetCaret(
1355 x + absPosition.x + clientStart.x,
1356 y + absPosition.y + clientStart.y, this.caretSize);
1357 guiApp.caretEnabled = true;
1359 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1363 if(lastWindow != this)
1365 updateBox.left = x + 1;
1367 updateBox.right = x + 2;
1368 updateBox.bottom = y + this.caretSize - 1;
1372 updateBox.left = Min(x + 1, caretX + 1);
1373 updateBox.top = Min(y, caretY);
1374 updateBox.right = Max(x + 2, caretX + 2);
1375 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1378 guiApp.caretOwner.Update(updateBox);
1385 caretSize = this.caretSize;
1391 guiApp.interfaceDriver.SetCaret(0,0,0);
1392 guiApp.caretEnabled = false;
1398 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1403 scrolledPos.x = position.x = x;
1404 scrolledPos.y = position.y = y;
1406 clientSize.w = size.w = w;
1407 clientSize.h = size.h = h;
1409 if(parent && !style.nonClient)
1411 //if(!style.fixed || style.isDocument)
1413 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1414 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1418 clientStart.x = clientStart.y = 0;
1420 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1422 //if(!activeClient || activeClient.state != maximized)
1423 if(!noAutoScrollArea)
1425 // Check if scroll area must be modified
1426 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1428 bool foundChild = false;
1430 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1431 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1432 for(child = children.first; child; child = child.next)
1434 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1435 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1437 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1438 w = Max(w, child.position.x + child.size.w);
1439 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1440 w = Max(w, Max(child.position.x, 0) + child.size.w);
1441 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1442 h = Max(h, child.position.y + child.size.h);
1443 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1444 h = Max(h, Max(child.position.y, 0) + child.size.h);
1449 if(foundChild && (w > cw || h > ch))
1451 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1453 int stepX = sbStep.x, stepY = sbStep.y;
1454 // Needed to make snapped down position match the skin's check of client area
1455 // against realvirtual
1458 SNAPDOWN(stepX, textCellW);
1459 SNAPDOWN(stepY, textCellH);
1460 stepX = Max(stepX, textCellW);
1461 stepY = Max(stepY, textCellH);
1463 if(scrollFlags.snapX)
1465 if(scrollFlags.snapY)
1468 reqScrollArea.w = w;
1469 reqScrollArea.h = h;
1472 else if(reqScrollArea.w || reqScrollArea.h)
1474 reqScrollArea.w = 0;
1475 reqScrollArea.h = 0;
1476 SetScrollPosition(0,0);
1481 // Automatic MDI Client Scrolling Area Adjustment
1482 if(parent && !parent.noAutoScrollArea)
1484 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1485 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1487 Window parent = this.parent;
1488 int w = parent.reqScrollArea.w;
1489 int h = parent.reqScrollArea.h;
1491 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1492 w = Max(w, position.x + size.w);
1493 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1494 w = Max(w, Max(position.x, 0) + size.w);
1495 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1496 h = Max(h, position.y + size.h);
1497 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1498 h = Max(h, Max(position.y, 0) + size.h);
1500 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1501 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1503 /*bool resize = false;
1504 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1505 // Needed to make snapped down position match the skin's check of client area
1506 // against realvirtual
1509 SNAPDOWN(stepX, textCellW);
1510 SNAPDOWN(stepY, textCellH);
1511 stepX = Max(stepX, textCellW);
1512 stepY = Max(stepY, textCellH);
1514 if(parent.scrollFlags.snapX)
1516 if(parent.scrollFlags.snapY)
1518 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1520 parent.reqScrollArea.w = w;
1521 parent.reqScrollArea.h = h;*/
1523 // parent.UpdateScrollBars(true, true);
1524 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1525 false, true, true, true, false, false);
1530 GetRidOfVirtualArea();
1534 UpdateScrollBars(modifyThisArea, false);
1535 else if(guiApp.currentSkin)
1538 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1540 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1541 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1542 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1543 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1546 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1547 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1549 absPosition = scrolledPos;
1550 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1551 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1553 if(this != guiApp.desktop && parent)
1555 absPosition.x += parent.absPosition.x;
1556 absPosition.y += parent.absPosition.y;
1557 if(!style.nonClient && this != guiApp.desktop)
1559 absPosition.x += parent.clientStart.x;
1560 absPosition.y += parent.clientStart.y;
1564 box = Box { 0, 0, size.w - 1, size.h - 1 };
1569 // Clip against parent's client area
1570 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1572 // Compute client area in this window coordinate system
1573 clientArea.left = 0;
1575 clientArea.right = clientSize.w - 1;
1576 clientArea.bottom = clientSize.h - 1;
1578 // Clip against parent's client area
1580 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1584 //absPosition.x -= parent.clientStart.x;
1585 //absPosition.y -= parent.clientStart.y;
1588 // Adjust all children
1589 for(child = children.first; child; child = child.next)
1590 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1592 UpdateCaret(false, false);
1595 void GetRidOfVirtualArea(void)
1597 if(parent && !parent.destroyed && style.fixed &&
1598 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1599 parent.reqScrollArea.w && parent.reqScrollArea.h)
1601 if(!parent.noAutoScrollArea)
1605 for(child = children.first; child; child = child.next)
1607 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1609 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1610 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1619 Window parent = this.parent;
1621 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1622 false, true, true, true, false, false);
1624 parent.SetScrollArea(0,0,true);
1625 parent.SetScrollPosition(0,0);
1631 public void ExternalPosition(int x, int y, int w, int h)
1633 Position(x, y, w, h, false, true, true, true, false, false);
1636 // (w, h): Full window size
1637 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1639 bool result = false;
1640 int oldCW = clientSize.w, oldCH = clientSize.h;
1641 bool clientResized, windowResized, windowMoved;
1643 bool realResized = size.w != w || size.h != h;
1645 // TOCHECK: This wasn't in ecere.dll
1646 //if(!parent) return true;
1647 if(destroyed) return false;
1649 windowMoved = position.x != x || position.y != y || force;
1651 // windowResized = realResized || force;
1652 windowResized = size.w != w || size.h != h || force;
1654 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1660 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1661 scrolledPos.x - parent.clientStart.x + this.box.right,
1662 scrolledPos.y - parent.clientStart.y + this.box.bottom
1668 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1673 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1675 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1676 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1677 windowResized = true;
1679 if(display && rootWindow != this)
1682 if(guiApp && guiApp.windowMoving)
1684 if(guiApp.windowMoving.style.nonClient)
1685 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1687 guiApp.windowMoving.parent.SetMouseRangeToClient();
1697 // Buttons bitmap resources crash if we do this while switching mode
1698 if(!guiApp || !guiApp.modeSwitching)
1701 // Process Anchored Children
1705 for(child = children.first; child; child = child.next)
1708 ((child.stateAnchor.left.type != offset ||
1709 child.stateAnchor.top.type != offset ||
1710 child.stateAnchor.right.type != none ||
1711 child.stateAnchor.bottom.type != none) ||
1712 child.state == maximized || child.state == minimized))
1714 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1716 // child.Position(x, y, w, h, false, true, true, true, false);
1717 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1718 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1724 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1725 //if(updateScrollBars)
1727 OnResize(clientSize.w, clientSize.h);
1729 if((clientResized || windowMoved) && created)
1730 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1732 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1734 Window master = guiApp.interimWindow.master;
1735 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1738 if(rootWindow == this && !is3D)
1742 x -= guiApp.desktop.absPosition.x;
1743 y -= guiApp.desktop.absPosition.y;
1745 //guiApp.Log("Position %s\n", caption);
1748 if(windowResized || windowMoved)
1749 if(display && !display.flags.memBackBuffer && changeRootWindow)
1750 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1752 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1753 for(child = parent.children.first; child && child != this; child = child.next)
1754 if(child.rootWindow)
1755 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1760 if(windowMoved || windowResized)
1762 display.Lock(true /*false*/);
1765 display.Position(absPosition.x, absPosition.y);
1766 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1769 // result = realResized ? display.Resize(size.w, size.h) : true;
1770 if(nativeDecorations && rootWindow.windowHandle)
1772 int w = clientSize.w, h = clientSize.h;
1773 if(hasMenuBar) h += skinMenuHeight;
1774 if(hasStatusBar) h += statusBarHeight;
1775 if(sbv && sbv.visible) w += sbv.size.w;
1776 if(sbh && sbh.visible) h += sbh.size.h;
1777 result = manageDisplay ? display.Resize(w, h) : true;
1780 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1784 else if(clientResized)
1786 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1789 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1793 if(windowMoved || windowResized)
1798 if(guiApp.driver && changeRootWindow && windowHandle)
1800 if(windowResized || windowMoved)
1801 if(!display || display.flags.memBackBuffer)
1802 guiApp.interfaceDriver.PositionRootWindow(this,
1803 x, y, w, h, windowMoved, windowResized);
1804 guiApp.interfaceDriver.UpdateRootWindow(this);
1806 for(child = children.first; child; child = child.next)
1808 if(child.is3D && child.created)
1810 // Copy Display Content
1811 child.display.displaySystem = display.displaySystem;
1812 child.display.window = display.window;
1813 child.display.current = display.current;
1814 child.display.width = display.width;
1815 child.display.height = display.height;
1816 child.display.driverData = display.driverData;
1817 child.display.mutex = null;
1828 void UpdateScrollBars(bool flag, bool fullThing)
1831 bool resizeH = false, resizeV = false;
1832 bool scrolled = false;
1833 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1834 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1836 if(destroyed) return;
1837 if(guiApp.currentSkin)
1839 MinMaxValue cw = 0, ch = 0;
1840 bool sbvVisible, sbhVisible;
1842 int positionH, positionV;
1844 // First get client area with no respect to scroll bars
1849 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1851 if(scrollFlags.dontHide)
1854 cw -= guiApp.currentSkin.VerticalSBW();
1856 ch -= guiApp.currentSkin.HorizontalSBH();
1858 // Update the scrollbar visibility
1864 sbh.disabled = rangeH <= 1;
1865 if(sbh.style.hidden)
1875 sbv.disabled = rangeV <= 1;
1876 if(sbv.style.hidden)
1884 int oldHRange = sbh ? sbh.range : 0;
1885 int oldVRange = sbv ? sbv.range : 0;
1886 // Then start off with horizontal scrollbar range
1889 positionH = sbh.thumbPosition;
1896 SBSetTotal(sbh, rvw);
1899 ch -= guiApp.currentSkin.HorizontalSBH();
1902 // Do the same for vertical scrollbar
1905 positionV = sbv.thumbPosition;
1911 SBSetTotal(sbv, rvh);
1915 cw -= guiApp.currentSkin.VerticalSBW();
1916 // Maybe we need to set the range on the horizontal scrollbar again
1924 SBSetTotal(sbh, rvw);
1925 //sbh.Action(setRange, positionH, 0);
1926 if(rangeH <= 1 && sbh.range > 1)
1928 ch -= guiApp.currentSkin.HorizontalSBH();
1934 SBSetTotal(sbv, rvh);
1936 //sbv.Action(setRange, positionV, 0);
1941 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1942 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1945 // Update the scrollbar visibility
1946 if(!scrollFlags.dontHide)
1948 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1952 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1959 if(guiApp.currentSkin)
1966 sbhVisible = sbh.style.hidden ? true : false;
1968 sbvVisible = sbv.style.hidden ? true : false;
1970 // Do our resize here
1971 if(flag && (resizeH || resizeV) && fullThing)
1973 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1978 OnResize(clientSize.w, clientSize.h);
1984 sbh.visible = sbhVisible;
1986 sbv.visible = sbvVisible;
1988 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1989 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1992 sbh.pageStep = clientSize.w;
1994 sbv.pageStep = clientSize.h;
1996 // Notify doesn't handle setRange anymore... process it here
1999 int positionH = sbh.thumbPosition;
2000 if(scroll.x != positionH)
2002 OnHScroll(setRange, positionH, 0);
2006 SNAPDOWN(positionH, textCellW);
2007 scroll.x = positionH;
2013 int seen = clientSize.w, total = reqScrollArea.w;
2016 if(scrollFlags.snapX)
2017 SNAPDOWN(seen, sbStep.x);
2019 if(!total) total = seen;
2020 range = total - seen + 1;
2022 range = Max(range, 1);
2024 if(x >= range) x = range - 1;
2026 if(scrollFlags.snapX)
2027 SNAPUP(x, sbStep.x);
2031 OnHScroll(setRange, x, 0);
2036 SNAPDOWN(x, textCellW);
2042 int positionV = sbv.thumbPosition;
2043 if(scroll.y != positionV)
2045 OnVScroll(setRange, positionV, 0);
2049 SNAPDOWN(positionV, textCellH);
2050 scroll.y = positionV;
2056 int seen = clientSize.h, total = reqScrollArea.h;
2059 if(scrollFlags.snapY)
2060 SNAPDOWN(seen, sbStep.y);
2062 if(!total) total = seen;
2063 range = total - seen + 1;
2064 range = Max(range, 1);
2066 if(y >= range) y = range - 1;
2068 if(scrollFlags.snapY)
2069 SNAPUP(y, sbStep.y);
2073 OnVScroll(setRange, y, 0);
2078 SNAPDOWN(y, textCellH);
2084 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2087 for(child = children.first; child; child = child.next)
2089 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2092 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2093 child.Position(x, y, w, h, false, true, false, true, false, false);
2100 // Process Scrollbars
2102 if(sbh) // && !sbh.style.hidden
2105 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2106 // Need to set the range again (should improve...) since the scrollbars didn't have
2107 // the right size when UpdateScrollArea set the range on it
2110 sbh.seen = clientSize.w;
2114 if(sbv) // && !sbv.state.hidden
2117 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2118 // Need to set the range again (should improve...) since the scrollbars didn't have
2119 // the right size when UpdateScrollArea set the range on it
2122 sbv.seen = clientSize.h;
2127 // TESTING THIS LOWER
2128 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2131 for(child = children.first; child; child = child.next)
2133 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2136 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2137 child.Position(x, y, w, h, false, true, false, true, false, false);
2143 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2145 SetState(maximized, false, mods);
2149 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2151 SetState(normal, false, mods);
2155 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2157 SetState(minimized, false, mods);
2158 parent.CycleChildren(false, true, false, true);
2162 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2165 // Scroll bar notifications
2166 if(action != setRange)
2168 bool changed = false;
2172 if(scroll.x != position)
2174 OnHScroll(action, position, keyFlags);
2179 SNAPDOWN(position, textCellW);
2181 scroll.x = position;
2185 if(scroll.y != position)
2187 OnVScroll(action, position, keyFlags);
2192 SNAPDOWN(position, textCellH);
2194 scroll.y = position;
2198 bool childMove = false;
2199 for(child = children.first; child; child = child.next)
2201 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2204 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2205 child.Position(x, y, w, h, false, true, false, true, false, false);
2209 // Testing this patch out to solve MDI workspace redraw bugs
2210 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2211 // Scroll offsets to blame?
2215 UpdateCaret(false, false);
2219 // Testing this patch out to solve MDI workspace redraw bugs
2220 for(child = children.first; child; child = child.next)
2222 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2231 Window GetParentMenuBar()
2233 Window menuBarParent;
2234 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2236 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2237 if(menuBarParent && !menuBarParent.isActiveClient)
2243 void CreateSystemChildren(void)
2245 Window parent = this;
2246 bool scrollBarChanged = false;
2247 bool hasClose = false, hasMaxMin = false;
2248 Point scroll = this.scroll;
2250 if(state == maximized)
2252 parent = GetParentMenuBar();
2253 if(!parent && nativeDecorations)
2254 parent = rootWindow;
2259 if(style.hasClose) hasClose = true;
2260 if(style.hasMaximize || style.hasMinimize)
2267 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2269 sysButtons[2].Destroy(0);
2270 sysButtons[2] = null;
2272 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2274 sysButtons[1].Destroy(0);
2275 sysButtons[1] = null;
2277 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2279 sysButtons[0].Destroy(0);
2280 sysButtons[0] = null;
2283 if(hasClose && parent)
2290 parent, master = this,
2291 inactive = true, nonClient = true, visible = false;
2293 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2299 if(this.parent == guiApp.desktop)
2300 sysButtons[2].hotKey = altF4;
2301 else if(style.isActiveClient)
2302 sysButtons[2].hotKey = ctrlF4;
2303 sysButtons[2].Create();
2306 sysButtons[2].symbol = 'X';
2307 sysButtons[2].disabled = !style.hasClose;
2310 if(hasMaxMin && parent)
2314 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2315 if(state == maximized)
2318 method = RestoreButtonClicked;
2324 method = MaximizeButtonClicked;
2332 parent, master = this,
2333 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2335 sysButtons[1].Create();
2337 sysButtons[1].NotifyClicked = method;
2339 sysButtons[1].symbol = symbol;
2340 sysButtons[1].disabled = !style.hasMaximize;
2343 if(hasMaxMin && parent)
2347 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2348 if (state == minimized)
2351 method = RestoreButtonClicked;
2357 method = MinimizeButtonClicked;
2365 parent, master = this,
2366 hotKey = altM, inactive = true, nonClient = true, visible = false
2368 sysButtons[0].Create();
2370 sysButtons[0].NotifyClicked = method;
2372 sysButtons[0].symbol = symbol;
2373 sysButtons[0].disabled = !style.hasMinimize;
2376 // Create the scrollbars
2377 if(style.hasHorzScroll && !sbh)
2383 direction = horizontal,
2387 snap = scrollFlags.snapX,
2388 NotifyScrolling = ScrollBarNotification
2391 scrollBarChanged = true;
2393 else if(sbh && !style.hasHorzScroll)
2399 if(style.hasVertScroll && !sbv)
2405 direction = vertical,
2409 snap = scrollFlags.snapY,
2410 NotifyScrolling = ScrollBarNotification
2413 scrollBarChanged = true;
2415 else if(sbv && !style.hasVertScroll)
2420 if(scrollBarChanged)
2422 SetScrollLineStep(sbStep.x, sbStep.y);
2423 UpdateScrollBars(true, true);
2427 if(scrollBarChanged)
2429 if(sbh) sbh.thumbPosition = scroll.x;
2430 if(sbv) sbv.thumbPosition = scroll.y;
2434 void UpdateCaption(void)
2436 if(rootWindow == this)
2439 FigureCaption(caption);
2440 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2442 UpdateDecorations();
2445 if(parent.activeClient == this) // Added this last check
2447 if(parent.rootWindow == parent)
2450 parent.FigureCaption(caption);
2451 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2454 parent.UpdateCaption();
2456 parent.UpdateDecorations();
2460 void UpdateActiveDocument(Window previous)
2462 Window activeClient = this.activeClient;
2463 Window activeChild = this.activeChild;
2470 activeClient.CreateSystemChildren();
2472 previous.CreateSystemChildren();
2484 // Build window list
2487 Menu windowMenu = menu.FindMenu("Window");
2492 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2495 Window document = cycle.data;
2496 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2498 char name[2048], caption[2048];
2499 document.FigureCaption(caption);
2500 sprintf(name, "%d %s", id+1, caption);
2501 windowMenu.AddDynamic(MenuItem
2503 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2504 NotifySelect = MenuWindowSelectWindow
2508 if(activeClient.cycle == cycle) break;
2513 if((!previous && activeClient) || !activeClient)
2519 item = menu.FindItem(MenuWindowCloseAll, 0);
2520 if(item) item.disabled = false;
2521 item = menu.FindItem(MenuWindowNext, 0);
2522 if(item) item.disabled = false;
2523 item = menu.FindItem(MenuWindowPrevious, 0);
2524 if(item) item.disabled = false;
2525 item = menu.FindItem(MenuWindowCascade, 0);
2526 if(item) item.disabled = false;
2527 item = menu.FindItem(MenuWindowTileHorz, 0);
2528 if(item) item.disabled = false;
2529 item = menu.FindItem(MenuWindowTileVert, 0);
2530 if(item) item.disabled = false;
2531 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2532 if(item) item.disabled = false;
2533 item = menu.FindItem(MenuWindowWindows, 0);
2534 if(item) item.disabled = false;
2537 item = menu.FindItem(MenuFileClose, 0);
2538 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2539 item = menu.FindItem(MenuFileSaveAll, 0);
2540 if(item) item.disabled = numDocuments < 1;
2542 if(activeClient && activeClient.menu && activeClient.state != minimized)
2546 //activeClient.menu.Clean(activeClient);
2547 menu.Merge(activeClient.menu, true, activeClient);
2551 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2554 menu.Merge(activeChild.menu, true, activeChild);
2557 // This is called again for a child window change, with same active client
2558 OnActivateClient(activeClient, previous);
2559 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2560 parent.UpdateActiveDocument(null);
2563 void _ShowDecorations(Box box, bool post)
2565 if(rootWindow == this && nativeDecorations) return;
2566 if(visible && this != guiApp.desktop)
2568 Surface surface = RedrawFull(box);
2572 FigureCaption(caption);
2575 ShowDecorations(captionFont.font,
2578 active, //parent.activeClient == this
2579 guiApp.windowMoving == this);
2581 PreShowDecorations(captionFont.font,
2584 active, //parent.activeClient == this
2585 guiApp.windowMoving == this);
2592 void UpdateExtent(Box refresh)
2594 Surface surface = null;
2596 if(!manageDisplay) { OnRedraw(null);return; }
2597 _ShowDecorations(refresh, false);
2599 surface = Redraw(refresh);
2600 // Opaque background: just fill before EW_REDRAW (clear?)
2603 surface.SetBackground(background);
2604 surface.SetForeground(foreground);
2605 surface.DrawingChar(' ');
2606 if(this == rootWindow)
2608 if(style.drawBehind || background.a)
2610 int a = background.a;
2611 // Premultiply alpha for clear color
2612 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2613 surface.Clear(colorBuffer);
2614 surface.SetBackground(background);
2617 else if(background.a)
2621 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2622 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2625 if(display.flags.alpha && background.a < 255 && background)
2627 surface.Area(0,0,clientSize.w, clientSize.h);
2628 /*if(style.clearDepthBuffer)
2629 surface.Clear(depthBuffer);*/
2631 else if(/*style.clearDepthBuffer || */background.a)
2633 int a = background.a;
2634 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2635 // Premultiply alpha for clear color
2636 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2637 surface.Clear(colorBuffer);
2638 surface.SetBackground(background);
2643 surface.TextFont(usedFont.font);
2644 surface.TextOpacity(false);
2648 // Draw the caret ...
2649 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2651 // surface.SetBackground(0xFFFFFF - background.color);
2652 surface.SetBackground(~background.color);
2654 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2655 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2661 void DrawOverChildren(Box refresh)
2663 Surface surface = Redraw(refresh);
2667 surface.DrawingChar(' ');
2668 surface.SetBackground(background);
2669 surface.SetForeground(foreground);
2671 surface.TextFont(usedFont.font);
2672 surface.TextOpacity(false);
2674 OnDrawOverChildren(surface);
2679 _ShowDecorations(refresh, true);
2682 void ComputeClipExtents(void)
2685 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2687 clipExtent.Copy(this.clipExtent);
2689 for(child = children.last; child; child = child.prev)
2691 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2693 bool opaque = child.IsOpaque(); // TODO: acess background directly
2694 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2696 child.clipExtent.Copy(clipExtent);
2697 child.clipExtent.Offset(-dx, -dy);
2698 child.clipExtent.IntersectBox(child.box);
2700 child.ComputeClipExtents();
2702 if(opaque && !child.style.nonClient)
2704 // Adjust the box for the parent:
2705 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2706 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2711 // ??? Only do this for overlapped window or if parent has with clip children flag
2713 // Do this if window has clip children flag on (default false?)
2714 // this.clipExtent = clipExtent;
2716 clipExtent.Free(null);
2719 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2721 bool opaque = IsOpaque();
2723 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2724 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2726 offsetX -= rootWindow.clientStart.x;
2727 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2731 for(child = children.last; child; child = child.prev)
2733 ColorAlpha background = *(ColorAlpha *)&child.background;
2734 bool opaque = child.IsOpaque();
2735 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2739 // Adjust renderArea to the root window level
2740 Extent * renderArea = &rootWindow.tempExtents[3];
2742 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2743 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2744 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2746 offsetX -= child.rootWindow.clientStart.x;
2747 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2751 Extent childRenderArea;
2753 if(backBufferUpdate != null)
2755 childRenderArea.Copy(backBufferUpdate);
2756 childRenderArea.Offset(-offsetX, -offsetY);
2759 childRenderArea.Copy(child.dirtyArea);
2761 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2762 renderArea.Copy(dirtyExtent);
2763 renderArea.Offset(-offsetX, -offsetY);
2764 childRenderArea.Union(renderArea);
2767 // Intersect with the clip extent
2768 childRenderArea.Intersection(child.clipExtent);
2771 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2773 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2774 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2776 renderArea->Offset(offsetX, offsetY);
2778 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2779 // overDirtyExtent.Union(renderArea);
2780 renderArea->Empty();
2781 // childRenderArea.Free();
2783 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2788 for(child = children.last; child; child = child.prev)
2790 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2792 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2797 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2799 bool opaque = IsOpaque();
2800 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2802 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2803 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2805 offsetX -= rootWindow.clientStart.x;
2806 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2810 for(child = children.last; child; child = child.prev)
2812 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2814 ColorAlpha background = *(ColorAlpha *)&child.background;
2815 bool opaque = child.IsOpaque();
2816 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2820 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2821 // Adjust renderArea to the root window level
2823 renderArea.Copy(child.dirtyArea);
2824 renderArea.Offset(offsetX, offsetY);
2825 dirtyExtent.Union(renderArea);
2826 overDirtyExtent.Union(renderArea);
2832 for(child = children.last; child; child = child.prev)
2834 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2836 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2840 if(backBufferUpdate != null)
2842 renderArea.Copy(backBufferUpdate);
2843 renderArea.Offset(-offsetX, -offsetY);
2845 overRenderArea.Copy(backBufferUpdate);
2846 overRenderArea.Offset(-offsetX, -offsetY);
2852 renderArea.Copy(dirtyArea);
2854 overRenderArea.Copy(dirtyArea);
2857 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2858 dirtyExtentWindow->Copy(dirtyExtent);
2859 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2860 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2861 dirtyExtentWindow->Empty();
2863 // Intersect with the clip extent
2864 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2867 if(renderArea.count > 10)
2870 printf("\nToo many extents (%d):\n", renderArea.count);
2872 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2873 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2878 for(c = 0; c<10; c++)
2881 FASTLIST_LOOP(renderArea, extentBox)
2883 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2885 renderArea.Copy(extent);
2887 FASTLIST_LOOP(renderArea, extentBox)
2890 printf("(%d, %d) - (%d, %d)\n",
2891 extentBox.box.left, extentBox.box.top,
2892 extentBox.box.right, extentBox.box.bottom);
2896 printf("\nNow %d\n", renderArea.count);
2902 // WHY WAS THIS COMMENTED ??
2904 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2905 dirtyExtentWindow->Copy(overDirtyExtent);
2906 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2907 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2908 dirtyExtentWindow->Empty();
2910 // Intersect with the clip extent
2911 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2917 if(scrollExtent.count)
2919 // Subtract render extent from scrolling extent
2920 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2922 if(backBufferUpdate == null)
2924 Extent * dirty = &rootWindow.tempExtents[3];
2927 // Intersect scrolling extent with clip extent
2928 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2930 // offset this scroll to be at the root window level
2931 scrollExtent.Offset(offsetX, offsetY);
2932 // Add area that was scrolled to the dirty extents of the back buffer
2933 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2937 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2938 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2939 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2944 scrollExtent.Empty();
2946 // Add the exposed extent to the window render area
2947 dirty->Offset(-offsetX, -offsetY);
2948 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2953 // Subtract the window's box from the transparency forced extent
2954 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2960 renderArea.Copy(this.renderArea);
2961 renderArea.Offset(offsetX, offsetY);
2962 dirtyExtent.Union(renderArea);
2968 Extent renderArea { };
2970 renderArea.Copy(overRenderArea);
2971 renderArea.Offset(offsetX, offsetY);
2972 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2977 if(backBufferUpdate != null)
2979 // Remove render area from dirty area
2980 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2982 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2989 // Remove the window render area from the dirty extents of the back buffer
2990 rootWindow.dirtyBack.Exclusion(renderArea);
2994 void Render(Extent updateExtent)
2998 Window rootWindow = this.rootWindow;
2999 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3000 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3002 offsetX -= rootWindow.clientStart.x;
3003 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3006 if(rootWindow.fullRender)
3015 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3016 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3021 /*if(renderArea.count)
3022 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3025 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3027 Box box = extentBox.box;
3030 /*printf("(%d, %d) - (%d, %d)\n",
3031 extentBox.box.left, extentBox.box.top,
3032 extentBox.box.right, extentBox.box.bottom);*/
3037 box.left += offsetX;
3039 box.right += offsetX;
3040 box.bottom += offsetY;
3042 if(updateExtent != null)
3043 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3047 for(child = children.first; child; child = child.next)
3048 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3049 child.Render(updateExtent);
3051 if(rootWindow.fullRender)
3052 DrawOverChildren(box);
3055 // TO DO: There's an issue about draw over children...
3056 // TO DO: Don't wanna go through this if method isn't used
3057 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3058 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3060 Box box = extentBox.box;
3062 DrawOverChildren(box);
3064 box.left += offsetX;
3066 box.right += offsetX;
3067 box.bottom += offsetY;
3069 if(updateExtent != null)
3070 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3073 for(child = children.first; child; child = child.next)
3074 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3075 child.Render(updateExtent);
3078 overRenderArea.Empty();
3081 public void UpdateDisplay(void)
3083 if(!manageDisplay) { OnRedraw(null);return; }
3084 if(rootWindow && this != rootWindow)
3085 rootWindow.UpdateDisplay();
3088 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3089 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3092 dirtyExtent.Clear();
3095 clipExtent.AddBox(box);
3097 display.StartUpdate();
3099 if(!rootWindow.fullRender)
3101 ComputeClipExtents();
3102 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3103 ComputeRenderArea(dirtyExtent, overExtent, null);
3106 clipExtent.Free(null);
3108 dirtyExtent.Free(null);
3109 overExtent.Free(null);
3111 if(display.flags.flipping)
3114 display.Update(null);
3118 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3119 updateExtent.Clear();
3121 Render(updateExtent);
3123 updateExtent.UnionBox(this.box, tempExtents[0]);
3126 //printf("\n\nUpdate:\n------------------------------------------\n");
3129 //FASTLIST_LOOP(updateExtent, extentBox)
3130 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3133 /*printf("Updating (%d, %d) - (%d, %d)\n",
3134 extentBox.box.left, extentBox.box.top,
3135 extentBox.box.right, extentBox.box.bottom);*/
3138 display.Update(extentBox.box);
3141 updateExtent.Free(null);
3144 display.EndUpdate();
3152 void UpdateBackDisplay(Box box)
3158 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3160 //printf("UpdateBackDisplay going through!\n");
3161 display.StartUpdate();
3165 intersection.Copy(dirtyBack);
3166 intersection.IntersectBox(box);
3168 dirtyExtent.Clear();
3171 clipExtent.AddBox(box);
3173 if(!rootWindow.fullRender)
3175 ComputeClipExtents();
3176 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3179 clipExtent.Free(null);
3181 intersection.Free(null);
3182 dirtyExtent.Free(null);
3183 overExtent.Free(null);
3188 if(display.flags.flipping)
3189 display.Update(null);
3192 rootWindow.display.Update(box);
3195 display.EndUpdate();
3199 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3200 if(dirtyBack.count > MAX_DIRTY_BACK)
3202 BoxItem extentBox, next;
3203 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3204 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3206 next = (BoxItem)extentBox.next;
3207 if(extentBox != first)
3209 if(extentBox.box.left < first.box.left)
3210 first.box.left = extentBox.box.left;
3211 if(extentBox.box.top < first.box.top)
3212 first.box.top = extentBox.box.top;
3213 if(extentBox.box.right > first.box.right)
3214 first.box.right = extentBox.box.right;
3215 if(extentBox.box.bottom > first.box.bottom)
3216 first.box.bottom = extentBox.box.bottom;
3217 dirtyBack.Delete(extentBox);
3226 // --- Window positioning ---
3227 // --- Window identification ---
3229 // Returns window at position "Position"
3230 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3232 Window child, result = null;
3234 box.left += absPosition.x;
3235 box.right += absPosition.x;
3236 box.top += absPosition.y;
3237 box.bottom += absPosition.y;
3239 if(!destroyed && visible && (acceptDisabled || !disabled))
3241 int lx = x - absPosition.x;
3242 int ly = y - absPosition.y;
3243 if(IsInside(lx, ly))
3244 // if(box.IsPointInside(Point{x, y}))
3246 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3247 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3250 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3251 Window ancestor = null;
3253 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3254 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3255 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3257 if(child != statusBar && child.rootWindow == rootWindow)
3259 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3266 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3267 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3269 if(child != statusBar && child.rootWindow == rootWindow)
3271 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3278 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3286 Window FindModal(void)
3288 Window modalWindow = this, check;
3289 Window check2 = null;
3290 for(check = this; check.master; check = check.master)
3292 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3294 modalWindow = check.master.modalSlave;
3295 check = modalWindow;
3297 // TESTING THIS FOR DROPBOX...
3298 if(!rootWindow || !rootWindow.style.interim)
3300 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3302 if(check2.modalSlave && check2.modalSlave.created)
3304 modalWindow = check2.modalSlave;
3312 if(modalWindow == this)
3314 for(check = this; check.activeChild; check = check.activeChild)
3316 if(check.modalSlave)
3318 modalWindow = check.modalSlave;
3324 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3325 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3328 void StopMoving(void)
3330 if(this == guiApp.windowMoving)
3332 guiApp.windowMoving = null;
3333 UpdateDecorations();
3334 SetMouseRange(null);
3337 if(rootWindow.active)
3338 guiApp.interfaceDriver.StopMoving(rootWindow);
3341 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3342 guiApp.windowIsResizing = false;
3346 void SelectMouseCursor(void)
3351 Window cursorWindow = null;
3352 bool rx, ry, rex, rey;
3354 guiApp.desktop.GetMousePosition(&x, &y);
3355 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3357 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3358 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3359 else if(mouseWindow)
3361 modalWindow = mouseWindow.FindModal();
3362 x -= mouseWindow.absPosition.x;
3363 y -= mouseWindow.absPosition.y;
3364 if(guiApp.windowIsResizing)
3366 rex = guiApp.resizeEndX;
3367 rey = guiApp.resizeEndY;
3368 rx = guiApp.resizeX;
3369 ry = guiApp.resizeY;
3370 if((rex && rey) || (rx && ry))
3371 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3372 else if((rex && ry) || (rx && rey))
3373 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3374 else if((ry || rey) && (!rx && !rex))
3375 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3376 else if((rx || rex) && (!ry && !rey))
3377 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3379 else if(!modalWindow && !guiApp.windowCaptured &&
3380 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3381 &rx, &ry, &rex, &rey))
3383 if((rex && rey) || (rx && ry))
3384 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3385 else if((rex && ry) || (rx && rey))
3386 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3387 else if((ry || rey) && (!rx && !rex))
3388 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3389 else if((rx || rex) && (!ry && !rey))
3390 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3392 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3394 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3395 cursorWindow = mouseWindow.parent;
3397 cursorWindow = mouseWindow;
3399 else if(!guiApp.interimWindow)
3400 cursorWindow = guiApp.windowCaptured;
3403 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3404 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3406 else if(modalWindow)
3408 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3410 else if(guiApp.interimWindow)
3412 if(guiApp.interimWindow.cursor)
3413 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3415 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3420 // --- State based input ---
3421 bool AcquireInputEx(bool state)
3426 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3427 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3429 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3431 guiApp.acquiredWindow = state ? this : null;
3434 SetMouseRangeToClient();
3435 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3440 SelectMouseCursor();
3442 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3446 // --- Window activation ---
3447 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3450 if(!parent || !parent.style.inactive)
3452 Window parent = this.parent;
3455 if(rootWindow == this)
3456 Log(active ? "active\n" : "inactive\n");
3459 // Testing this here...
3460 if(!parent || parent == guiApp.desktop || parent.active)
3462 this.active = active;
3465 // TESTING THIS HERE
3466 UpdateDecorations();
3467 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3468 result = NotifyActivate(master, this, active, previous);
3471 this.active = !active;
3476 if(!parent || parent == guiApp.desktop || parent.active)
3478 this.active = active;
3480 AcquireInputEx(active);
3485 if(guiApp.caretOwner)
3489 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3490 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3491 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3492 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3494 guiApp.caretOwner.Update(extent);
3497 if(visible || !guiApp.caretOwner)
3498 guiApp.caretOwner = this;
3499 UpdateCaret(false, false);
3505 this.active = false;
3507 AcquireInputEx(active);
3509 if(!active && guiApp.caretOwner == this)
3511 UpdateCaret(false, true);
3512 guiApp.caretOwner = null;
3513 guiApp.interfaceDriver.SetCaret(0,0,0);
3514 guiApp.caretEnabled = false;
3519 if(!active && parent && parent.activeChild && parent.activeChild != this)
3520 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3526 if(!active && menuBar)
3529 menuBar.OnActivate(false, null, &goOn, true);
3530 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3535 Window aChild = activeChild;
3537 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3549 void ConsequentialMouseMove(bool kbMoving)
3553 if(kbMoving || !guiApp.windowMoving)
3557 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3559 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3561 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3562 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3568 bool IsDescendantOf(Window ancestor)
3571 for(window = this; window && window != ancestor; window = window.parent);
3572 return window == ancestor;
3575 bool IsSlaveOf(Window master)
3578 for(window = this; window && window != master; window = window.master);
3579 return window == master;
3582 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3586 if(this && !destroyed /*&& state != Hidden*/)
3588 Window swap = externalSwap;
3596 if(activateParent &&
3597 (parent.activeChild != this ||
3598 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3599 active && _isModal &&
3600 parent != master && master)
3601 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3607 bool real = parent.activeChild != this;
3609 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3610 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3611 !IsDescendantOf(guiApp.interimWindow) &&
3612 !IsSlaveOf(guiApp.interimWindow))
3614 Window interimWindow = guiApp.interimWindow;
3615 while(interimWindow && interimWindow != this)
3617 Window master = interimWindow.master;
3619 guiApp.interimWindow = null;
3620 if(guiApp.caretOwner)
3621 guiApp.caretOwner.UpdateCaret(false, false);
3623 incref interimWindow;
3624 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3629 delete interimWindow;
3630 interimWindow = (master && master.style.interim) ? master : null;
3635 guiApp.interimWindow = this;
3636 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3637 guiApp.caretEnabled = false;*/
3638 UpdateCaret(false, true);
3643 bool acquireInput = false;
3645 parent.activeChild &&
3646 parent.activeChild.state == maximized &&
3647 parent != guiApp.desktop;
3649 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3654 swap = parent.activeChild;
3655 if(swap && swap.destroyed) swap = null;
3656 if(swap && swap != this)
3659 if(!swap.PropagateActive(false, this, &goOn, true))
3660 swap = parent.activeChild;
3671 if(!parent || parent.activeChild != this || style.interim)
3674 result = PropagateActive(true, swap, &goOn, true);
3675 if(!result && !goOn)
3680 acquireInput = true;
3684 if(style.hasMaximize && parent != guiApp.desktop)
3687 SetState(maximized, false, 0);
3688 else if(state != maximized)
3691 for(child = parent.children.first; child; child = child.next)
3693 if(this != child && child.state == maximized)
3694 child.SetState(normal, false, 0);
3701 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3703 Window previous = parent.activeClient;
3704 parent.activeChild = this;
3705 if(!style.nonClient /*&& style.isActiveClient*/)
3709 if(style.isActiveClient)
3710 parent.activeClient = this;
3711 // Moved UpdateActiveDocument inside hidden check
3712 // To prevent activating previous window while creating a new one
3713 // (It was messing up the privateModule in the CodeEditor)
3714 parent.UpdateActiveDocument(previous);
3720 //if(!style.isRemote)
3722 if(rootWindow != this)
3724 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3725 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3727 else if(!guiApp.fullScreenMode)
3729 Window modalRoot = FindModal();
3730 if(!modalRoot) modalRoot = this;
3731 if(!modalRoot.isForegroundWindow)
3733 modalRoot.isForegroundWindow = true;
3734 // To check : Why is parent null?
3735 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3737 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3739 modalRoot.isForegroundWindow = false;
3744 if(result && real && (!style.inactive || moveInactive) && parent)
3746 Window last = parent.children.last;
3748 if(!style.stayOnTop)
3749 for(; last && last.style.stayOnTop; last = last.prev);
3751 parent.children.Move(this, last);
3753 // Definitely don't want that: why not?
3757 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3763 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3770 parent.activeChild = null;
3771 if(!style.nonClient /*&& style.isActiveClient*/)
3773 Window previous = parent.activeClient;
3774 if(style.isActiveClient)
3775 parent.activeClient = null;
3776 parent.UpdateActiveDocument(previous);
3780 if(this == guiApp.interimWindow)
3782 guiApp.interimWindow = null;
3783 if(guiApp.caretOwner)
3784 guiApp.caretOwner.UpdateCaret(false, false);
3786 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3793 if(!active || !swap)
3794 UpdateDecorations();
3796 swap.UpdateDecorations();
3798 if(active && rootWindow != this)
3799 ConsequentialMouseMove(false);
3806 // --- Input Messages ---
3807 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3809 static bool reEntrancy = false;
3810 if(reEntrancy) return;
3814 guiApp.cursorUpdate = true;
3815 if(guiApp.windowScrolling && !consequential)
3817 guiApp.windowScrolling.SetScrollPosition(
3818 (guiApp.windowScrolling.sbh) ?
3819 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3820 (guiApp.windowScrolling.sbv) ?
3821 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3823 if(guiApp.windowMoving)
3825 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3827 Window window = guiApp.windowMoving;
3829 int w = window.size.w;
3830 int h = window.size.h;
3835 rx = mouseX - guiApp.windowMovingStart.x;
3836 ry = mouseY - guiApp.windowMovingStart.y;
3839 window.GetDecorationsSize(&ew, &eh);
3841 if(guiApp.windowIsResizing)
3843 x = window.scrolledPos.x;
3844 y = window.scrolledPos.y;
3848 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3849 rx = guiApp.windowResizingBefore.w - aw;
3850 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3851 w = guiApp.windowResizingBefore.w - rx;
3855 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3856 ry = guiApp.windowResizingBefore.h - ah;
3857 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3858 ry = Max(ry, -guiApp.windowMovingBefore.y);
3859 h = guiApp.windowResizingBefore.h - ry;
3861 if(guiApp.resizeEndX)
3863 w = guiApp.windowResizingBefore.w + rx;
3866 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3874 w = Max(w, window.minSize.w);
3875 h = Max(h, window.minSize.h);
3876 w = Min(w, window.maxSize.w);
3877 h = Min(h, window.maxSize.h);
3879 if(!window.OnResizing(&w, &h))
3881 w = window.clientSize.w;
3882 h = window.clientSize.h;
3885 w = Max(w, window.skinMinSize.w);
3886 h = Max(h, window.skinMinSize.h);
3893 SNAPDOWN(w, textCellW);
3894 SNAPDOWN(h, textCellH);
3899 aw = Max(w,window.skinMinSize.w);
3900 rx = guiApp.windowResizingBefore.w - aw;
3901 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3902 w = guiApp.windowResizingBefore.w - rx;
3906 ah = Max(h,window.skinMinSize.h);
3907 ry = guiApp.windowResizingBefore.h - ah;
3908 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3909 ry = Max(ry, -guiApp.windowMovingBefore.y);
3910 h = guiApp.windowResizingBefore.h - ry;
3915 if(!guiApp.windowIsResizing || guiApp.resizeX)
3916 x = guiApp.windowMovingBefore.x + rx;
3917 if(!guiApp.windowIsResizing || guiApp.resizeY)
3918 y = guiApp.windowMovingBefore.y + ry;
3920 if(!guiApp.windowIsResizing)
3923 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3925 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3926 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3927 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3928 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3932 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3933 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3939 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3941 if(!window.OnMoving(&x, &y, w, h))
3943 x = window.scrolledPos.x;
3944 y = window.scrolledPos.y;
3950 SNAPDOWN(x, textCellW);
3951 SNAPDOWN(y, textCellH);
3954 if(!window.style.nonClient)
3956 if(!window.style.fixed /*|| window.style.isDocument*/)
3958 if(!window.style.dontScrollHorz)
3959 x += window.parent.scroll.x;
3960 if(!window.style.dontScrollVert)
3961 y += window.parent.scroll.y;
3965 // Break the anchors for moveable/resizable windows
3966 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3967 if(window.style.fixed)
3969 if(window.state == normal)
3971 window.normalAnchor = Anchor { left = x, top = y };
3972 window.normalSizeAnchor = SizeAnchor { { w, h } };
3973 window.anchored = false;
3977 window.stateAnchor = Anchor { left = x, top = y };
3978 window.stateSizeAnchor = SizeAnchor { { w, h } };
3980 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3981 // TOCHECK: Investigate why the following only redraws the scrollbars
3982 //window.Position(x, y, w, h, false, true, true, true, false, true);
3984 guiApp.movingLast.x = mouseX;
3985 guiApp.movingLast.y = mouseY;
3991 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3994 bool wasMoving = guiApp.windowMoving ? true : false;
3995 bool wasScrolling = guiApp.windowScrolling ? true : false;
3997 while(result && w != this)
3999 Window msgWindow = GetAtPosition(x,y, false, true, w);
4000 Window trueWindow = GetAtPosition(x,y, false, false, w);
4001 bool windowDragged = false;
4006 window = (w && !w.disabled) ? w : null;
4008 if(trueWindow) incref trueWindow;
4010 if(consequential) mods->isSideEffect = true;
4012 UpdateMouseMove(x, y, consequential);
4014 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4016 if(!guiApp.windowCaptured.isEnabled)
4017 guiApp.windowCaptured.ReleaseCapture();
4019 window = guiApp.windowCaptured;
4022 if(trueWindow && activate &&
4023 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4024 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4025 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4026 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4028 if(mods->alt && !mods->ctrl && !mods->shift)
4030 Window moved = trueWindow;
4031 for(moved = trueWindow; moved; moved = moved.parent)
4032 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4037 windowDragged = true;
4039 // Cancel the ALT menu toggling...
4040 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4045 if(window && activate &&
4046 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4047 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4048 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4049 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4051 Window modalWindow = window.FindModal();
4053 /*if(mods->alt && !mods->shift && !mods->ctrl)
4055 Window moved = window;
4056 for(moved = window; moved; moved = moved.parent)
4057 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4062 windowDragged = true;
4064 // Cancel the ALT menu toggling...
4065 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4071 Window activateWindow = modalWindow ? modalWindow : window;
4072 if(activateWindow && !activateWindow.isRemote)
4074 bool doActivation = true;
4075 //bool needToDoActivation = false;
4076 Window check = activateWindow;
4078 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4080 if(!check.style.inactive)
4082 //needToDoActivation = true;
4084 doActivation = false;
4089 if(!needToDoActivation)
4090 doActivation = false;
4093 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4094 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4096 // Let the OnLeftButtonDown do the activating instead
4097 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4105 incref activateWindow;
4106 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4108 delete activateWindow;
4112 if(activateWindow._refCount == 1)
4114 delete activateWindow;
4118 delete activateWindow;
4119 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4122 mods->isActivate = true;
4126 if(!modalWindow && window && !window.destroyed)
4128 if(!guiApp.windowCaptured || windowDragged)
4130 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4132 bool moving = ((window.state != maximized &&
4133 window.IsMouseMoving(
4134 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4135 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4137 if(!moving && window.IsMouseResizing(
4138 x - window.absPosition.x,
4139 y - window.absPosition.y,
4140 window.size.w, window.size.h,
4141 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4143 guiApp.windowIsResizing = true;
4144 guiApp.windowResizingBefore.w = window.size.w;
4145 guiApp.windowResizingBefore.h = window.size.h;
4147 if(guiApp.windowIsResizing || windowDragged || moving)
4150 guiApp.windowMoving = window;
4151 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4152 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4153 guiApp.windowMovingBefore.x = window.position.x;//s;
4154 guiApp.windowMovingBefore.y = window.position.y;//s;
4155 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4156 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4159 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4161 if(window.style.fixed &&
4163 window.IsMouseMoving(
4164 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4166 window.ShowSysMenu(x, y);
4170 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4172 if(window.sbv || window.sbh)
4175 guiApp.windowScrolling = window;
4176 guiApp.windowScrollingStart.x = x;
4177 guiApp.windowScrollingStart.y = y;
4178 guiApp.windowScrollingBefore.x = window.scroll.x;
4179 guiApp.windowScrollingBefore.y = window.scroll.y;
4182 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4184 if(window.style.hasMaximize &&
4185 window.IsMouseMoving(
4186 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4189 (window.state == maximized) ? normal : maximized, false, *mods);
4197 if(guiApp.windowMoving)
4199 if(guiApp.windowMoving.parent)
4201 if(guiApp.windowMoving.style.nonClient)
4202 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4204 guiApp.windowMoving.parent.SetMouseRangeToClient();
4208 window.UpdateDecorations();
4211 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4213 // Log("\n*** LEFT BUTTON UP ***\n");
4214 if(guiApp.windowMoving)
4215 guiApp.windowMoving.StopMoving();
4217 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4219 if(guiApp.windowScrolling)
4221 Window windowScrolling = guiApp.windowScrolling;
4222 guiApp.windowScrolling = null;
4223 windowScrolling.ReleaseCapture();
4227 if(!result || (window && window.destroyed)) window = null;
4229 if(window && window.FindModal())
4232 if(trueWindow && trueWindow.FindModal())
4240 msgWindow = GetAtPosition(x,y, true, false);
4242 msgWindow.SelectMouseCursor();
4245 if(guiApp.windowCaptured || trueWindow)
4247 Window prevWindow = guiApp.prevWindow;
4248 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4250 guiApp.prevWindow.mouseInside = false;
4251 guiApp.prevWindow = null;
4253 // Eventually fix this not to include captured?
4254 if(!prevWindow.OnMouseLeave(*mods))
4257 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4259 Box box = trueWindow.box;
4260 box.left += trueWindow.absPosition.x;
4261 box.right += trueWindow.absPosition.x;
4262 box.top += trueWindow.absPosition.y;
4263 box.bottom += trueWindow.absPosition.y;
4265 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4267 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4268 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4270 overX = Max(Min(overX, 32767),-32768);
4271 overY = Max(Min(overY, 32767),-32768);
4273 trueWindow.mouseInside = true;
4274 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4278 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4279 guiApp.prevWindow = trueWindow;
4281 guiApp.prevWindow = null;
4283 SelectMouseCursor();
4285 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4287 int clientX = x - (window.absPosition.x + window.clientStart.x);
4288 int clientY = y - (window.absPosition.y + window.clientStart.y);
4290 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4292 clientX = Max(Min(clientX, 32767),-32768);
4293 clientY = Max(Min(clientY, 32767),-32768);
4295 MouseMethod = (void *)window._vTbl[method];
4297 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4300 if(!MouseMethod(window, clientX, clientY, *mods))
4307 if(result && w && w.clickThrough && w.parent)
4312 if(!result || !w || !w.clickThrough)
4319 // --- Mouse cursor management ---
4321 bool KeyMessage(uint method, Key key, unichar character)
4326 if(guiApp.interimWindow)
4327 this = guiApp.interimWindow;
4330 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4334 if(!style.inactive || rootWindow != this)
4336 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4337 Window modalWindow = FindModal();
4338 Window interimMaster = master ? master.rootWindow : null;
4342 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4343 status = OnSysKeyDown(key, character);
4344 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4345 status = OnSysKeyHit(key, character);
4346 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4347 status = OnSysKeyUp(key, character);
4354 // Process Key Message for Internal UI Keyboard actions
4355 if(status && !destroyed && menuBar && state != minimized)
4358 if((SmartKey)key != alt)
4359 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4362 SmartKey sk = (SmartKey) key;
4363 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4365 status = menuBar.KeyMessage(method, key, character);
4370 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4371 menuBar.OnKeyHit(escape, 0);
4373 if(!menuBar.focus && guiApp.caretOwner)
4374 guiApp.caretOwner.UpdateCaret(true, false);
4377 if(!destroyed && status)
4379 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4383 case left: case up: case right: case down:
4384 if(guiApp.windowMoving == this)
4387 int w = guiApp.windowMoving.size.w;
4388 int h = guiApp.windowMoving.size.h;
4389 int x = guiApp.windowMoving.scrolledPos.x;
4390 int y = guiApp.windowMoving.scrolledPos.y;
4394 if(key == down || key == up)
4395 step = Max(step, textCellH);
4397 step = Max(step, textCellW);
4400 if(guiApp.windowIsResizing)
4404 case left: w-=step; break;
4405 case right: w+=step; break;
4406 case up: h-=step; break;
4407 case down: h+=step; break;
4414 case left: x-=step; break;
4415 case right: x+=step; break;
4416 case up: y-=step; break;
4417 case down: y+=step; break;
4421 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4422 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4424 if(!guiApp.windowIsResizing || guiApp.resizeX)
4425 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4427 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4429 if(!guiApp.windowIsResizing || guiApp.resizeY)
4430 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4432 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4434 guiApp.interfaceDriver.SetMousePosition(x, y);
4435 ConsequentialMouseMove(true);
4443 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4445 guiApp.windowMoving.StopMoving();
4446 ConsequentialMouseMove(false);
4454 ShowSysMenu(absPosition.x, absPosition.y);
4462 if(!destroyed && status && state != minimized)
4464 // Process all the way down the children
4465 if(activeChild && !activeChild.disabled)
4467 status = activeChild.KeyMessage(method, key, character);
4469 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4470 key.code != left && key.code != right && key.code != up && key.code != down)
4472 status = activeClient.KeyMessage(method, key, character);
4476 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4478 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4479 // && defaultControl != activeChild)
4481 delete previousActive;
4482 previousActive = activeChild;
4483 if(previousActive) incref previousActive;
4485 ConsequentialMouseMove(false);
4486 if((defaultControl.active ||
4487 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4488 defaultControl.KeyMessage(method, defaultKey, character);
4494 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4496 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4503 ShowSysMenu(absPosition.x, absPosition.y);
4510 if(this != guiApp.desktop)
4512 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4514 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4516 MenuMoveOrSize(key.shift, true);
4520 else if(guiApp.windowMoving)
4522 guiApp.windowMoving.StopMoving();
4523 ConsequentialMouseMove(false);
4531 if(!destroyed && status && state != minimized)
4533 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4537 case tab: case shiftTab:
4539 Window cycleParent = this;
4540 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4541 cycleParent = master.parent;
4543 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4545 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4547 Window child = cycleParent.activeChild;
4549 // Scroll the window to include the active control
4551 if(cycleParent.sbh && !child.style.dontScrollHorz)
4553 if(child.scrolledPos.x < 0)
4554 cycleParent.sbh.Action(Position,
4555 cycleParent.scroll.x + child.scrolledPos.x, 0);
4556 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4557 cycleParent.sbh.Action(Position,
4558 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4560 if(cycleParent.sbv && !child.style.dontScrollVert)
4562 if(child.scrolledPos.y < 0)
4563 cycleParent.sbv.Action(Position,
4564 cycleParent.scroll.y + child.scrolledPos.y, 0);
4565 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4566 cycleParent.sbv.Action(Position,
4567 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4570 cycleParent.ConsequentialMouseMove(false);
4576 case f6: case shiftF6:
4577 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4579 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4580 if(parent == guiApp.desktop)
4581 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4591 if(CycleChildren(key.shift, true, false, true))
4599 // mIRC Style Window Shortcuts
4600 case alt1: case alt2: case alt3: case alt4: case alt5:
4601 case alt6: case alt7: case alt8: case alt9: case alt0:
4606 for(document = children.first; document; document = document.next)
4608 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4610 if(document == activeChild)
4612 if(document.state == minimized)
4613 document.SetState(normal, false, key);
4616 document.SetState(minimized, false, key);
4617 CycleChildren(false, true, false);
4622 if(activeChild.state == maximized && document.style.hasMaximize)
4623 document.SetState(maximized, false, key);
4624 else if(document.state == minimized)
4625 document.SetState(normal, false, key);
4626 document.Activate();
4641 if(!destroyed && status)
4643 if(state == minimized)
4648 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4650 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4652 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4653 previousActive.ActivateEx(true, false, false, true, null, null);
4654 delete previousActive;
4660 if(!destroyed && status)
4662 status = ProcessHotKeys(method, key, character);
4664 if(!destroyed && status && !modalWindow && state != minimized)
4667 status = KeyMethod(this, key, character);
4668 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4669 status = OnKeyHit(key, character);
4670 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4672 bool result = false;
4675 case ctrlUp: case ctrlDown:
4676 if(sbv && !guiApp.windowScrolling)
4677 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4679 case wheelUp: case wheelDown:
4680 if(sbv && !guiApp.windowScrolling)
4682 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4683 // Do we want to do a consequential move regardless of result in this case?
4684 ConsequentialMouseMove(false);
4687 case ctrlPageUp: case ctrlPageDown:
4688 if(sbh && !guiApp.windowScrolling)
4689 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4694 ConsequentialMouseMove(false);
4699 if(status && !destroyed && menuBar && state != minimized)
4700 status = menuBar.KeyMessage(method, key, character);
4702 if(style.interim && /*destroyed && */status && interimMaster)
4704 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4705 status = interimMaster.KeyMessage(method, key, character);
4712 bool ProcessHotKeys(uint method, Key key, unichar character)
4717 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4718 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4719 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4721 Window hotKeyWindow = hotKey.window;
4722 Window parent = hotKeyWindow.parent;
4723 Window prevActiveWindow = activeChild;
4724 // For when sys buttons are placed inside the menu bar
4725 if(parent && parent._class == class(PopupMenu))
4726 parent = parent.parent;
4728 // 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
4729 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4732 if(prevActiveWindow) incref prevActiveWindow;
4733 incref hotKeyWindow;
4734 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4735 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4738 delete hotKeyWindow;
4739 delete prevActiveWindow;
4743 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4744 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4745 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4747 // ********* WORKING ON THIS ***********
4748 if(prevActiveWindow && !guiApp.interimWindow)
4749 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4752 else if(hotKeyWindow.style.inactive)
4753 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4755 delete prevActiveWindow;
4756 delete hotKeyWindow;
4757 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4758 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4762 if(status && tabCycle)
4765 for(child = children.first; child; child = child.next)
4767 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4778 // --- Windows and graphics initialization / termination ---
4779 bool SetupRoot(void)
4783 // Setup relationship with outside world (bb root || !bb)
4784 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4785 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4789 tempExtents = new0 Extent[4];
4794 /*if(guiApp.fullScreenMode)
4795 rootWindow = guiApp.desktop;
4797 //rootWindow = parent.created ? parent.rootWindow : null;
4798 rootWindow = parent.rootWindow;
4801 against = &parent.box;
4803 against = &parent.clientArea;
4806 for(child = children.first; child; child = child.next)
4809 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4812 bool Setup(bool positionChildren)
4814 bool result = false;
4817 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4819 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4820 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4822 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4824 // This was here, is it really needed?
4825 //guiApp.interfaceDriver.ActivateRootWindow(this);
4829 displaySystem = DisplaySystem {};
4830 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4832 delete displaySystem;
4837 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4838 if(display.Create(displaySystem, windowHandle))
4845 // Sometimes icon does not show up on Windows XP if we set here...
4846 // guiApp.interfaceDriver.SetIcon(this, icon);
4848 else if(this != guiApp.desktop)
4850 display = rootWindow ? rootWindow.display : null;
4856 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4857 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4859 for(child = children.first; child; child = child.next)
4861 if(child.created && !child.Setup(false))
4867 bool SetupDisplay(void)
4869 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4870 if(is3D) return Window3D_SetupDisplay(this); else
4877 class_data void ** pureVTbl;
4879 bool LoadGraphics(bool creation, bool resetAnchors)
4881 bool result = false;
4882 bool success = false;
4884 WindowState stateBackup = state;
4886 if(((subclass(Window))_class).pureVTbl)
4888 if(_vTbl == _class._vTbl)
4890 _vTbl = ((subclass(Window))_class).pureVTbl;
4895 for(m = 0; m < _class.vTblSize; m++)
4897 if(_vTbl[m] == _class._vTbl[m])
4898 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4902 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4904 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4906 _vTbl = _class._vTbl;
4911 for(m = 0; m < _class.vTblSize; m++)
4913 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4914 _vTbl[m] = _class._vTbl[m];
4919 if(guiApp.fullScreenMode || this != guiApp.desktop)
4921 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4927 display.Lock(false);
4928 if(rootWindow == this)
4930 // Set Color Palette
4931 display.SetPalette(palette, true);
4935 if(guiApp.fullScreenMode && this == guiApp.desktop)
4940 for(c=0; c<SystemCursor::enumSize; c++)
4941 if(!guiApp.systemCursors[c].bitmap)
4943 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4944 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4945 if(guiApp.systemCursors[c].bitmapName)
4947 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4948 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4949 if(guiApp.systemCursors[c].bitmap)
4950 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4955 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4957 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4958 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4960 cursor.bitmap.paletteShades = cursor.paletteShades;
4964 guiApp.cursorUpdate = true;
4967 ConsequentialMouseMove(false);
4973 // Load Window Graphic Resources
4976 if(usedFont == setFont || usedFont == window.systemFont)
4977 RemoveResource(usedFont);
4980 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4983 RemoveResource(systemFont);
4986 RemoveResource(captionFont);
4988 for(ptr = resources.first; ptr; ptr = ptr.next)
4990 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4993 AddResource(setFont);
4995 AddResource(systemFont);
4997 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5004 //if(master && master.font)
5005 if(parent && parent.font)
5009 faceName = parent.font.faceName,
5010 size = parent.font.size,
5011 bold = parent.font.bold,
5012 italic = parent.font.italic,
5013 underline = parent.font.underline
5015 //font = parent.font;
5016 watch(parent) { font { } };
5019 font = guiApp.currentSkin.SystemFont();
5026 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5027 AddResource(captionFont);
5029 if(OnLoadGraphics())
5035 //SetScrollLineStep(sbStep.x, sbStep.y);
5037 if(this != guiApp.desktop)
5041 normalAnchor = anchor;
5042 normalSizeAnchor = sizeAnchor;
5045 // Break the anchors for moveable/resizable windows
5047 if(style.fixed && style.isDocument)
5049 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5061 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5062 stateSizeAnchor = SizeAnchor {};
5067 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5072 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5073 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5076 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5080 stateAnchor = normalAnchor;
5081 stateSizeAnchor = normalSizeAnchor;
5084 position = Point { };
5085 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5096 if(Position(x, y, w, h, true, false, true, true, true, true))
5098 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5101 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5118 success = result = true;
5121 if(!creation && result)
5123 // Load menu bar first because sys buttons are on it...
5126 if(!menuBar.LoadGraphics(false, resetAnchors))
5132 for(child = children.first; child; child = child.next)
5134 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5141 CreateSystemChildren();
5145 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5148 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5153 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5154 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5157 // Do this here to avoid problems on Windows
5158 if(stateBackup == maximized)
5159 property::state = maximized;
5163 void UnloadGraphics(bool destroyWindows)
5167 // Free children's graphics
5168 for(child = children.first; child; child = child.next)
5169 child.UnloadGraphics(destroyWindows);
5172 display.Lock(false);
5175 if(guiApp.fullScreenMode && this == guiApp.desktop)
5180 for(c=0; c<SystemCursor::enumSize; c++)
5181 if(guiApp.systemCursors[c].bitmap)
5182 delete guiApp.systemCursors[c].bitmap;
5184 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5185 delete cursor.bitmap;
5187 guiApp.cursorBackground.Free();
5190 if(display && display.displaySystem)
5194 for(ptr = resources.first; ptr; ptr = ptr.next)
5198 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5203 // Free window graphics
5206 // Free skin graphics
5207 if(rootWindow == this)
5209 DisplaySystem displaySystem = display.displaySystem;
5212 display.driverData = null;
5213 display.displaySystem = null;
5217 if(displaySystem && !displaySystem.numDisplays && !is3D)
5218 delete displaySystem;
5227 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5228 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5230 if(this == guiApp.desktop || parent == guiApp.desktop)
5232 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5233 guiApp.interfaceDriver.DestroyRootWindow(this);
5237 // --- Window Hiding ---
5239 void SetVisibility(bool state)
5241 bool visible = (style.hidden || !created) ? false : state;
5242 if(visible != this.visible)
5246 this.visible = visible;
5247 for(child = children.first; child; child = child.next)
5248 child.SetVisibility(visible);
5250 ConsequentialMouseMove(false);
5251 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5255 // --- Windows and graphics initialization / termination ---
5257 bool DisplayModeChanged(void)
5259 bool result = false;
5260 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5262 guiApp.modeSwitching = true;
5263 UnloadGraphics(false);
5265 if(LoadGraphics(false, false))
5267 guiApp.modeSwitching = false;
5272 // --- Window updates system ---
5274 void UpdateDirty(Box updateBox)
5276 if(!manageDisplay) { OnRedraw(null);return; }
5279 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5282 if(display.flags.flipping)
5285 rootWindow.UpdateDisplay();
5288 UpdateBackDisplay(updateBox);
5290 if(guiApp.fullScreenMode)
5292 guiApp.cursorUpdate = true;
5293 guiApp.PreserveAndDrawCursor();
5295 if(guiApp.fullScreenMode)
5296 guiApp.RestoreCursorBackground();
5302 // This function is strictly called as a result of system window activation
5303 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5306 Window interimMaster = null;
5307 Window interimWindow = guiApp.interimWindow;
5308 if(interimWindow && interimWindow.master)
5309 interimMaster = interimWindow.master.rootWindow;
5311 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5312 // SetState(normal, false, 0);
5313 SetState(lastState, false, 0);
5315 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5319 /* WTH is this doing here?
5320 while(swap && swap.activeChild)
5322 swap = swap.activeChild;
5325 // TESTING THIS BEFORE...
5326 if(interimWindow && this == interimMaster)
5330 // Window interimSwap = this;
5331 Window menuBar = this.menuBar;
5332 if(menuBar && interimWindow.master == menuBar)
5335 while(interimSwap && interimSwap.activeChild)
5336 interimSwap = interimSwap.activeChild;
5338 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5339 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5341 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5342 //result = ActivateEx(true, true, false, activateRoot, window, null);
5347 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5348 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5350 if(interimWindow == this && interimMaster && !active)
5352 while(interimMaster && interimMaster.interim && interimMaster.master)
5354 // printf("Going up one master %s\n", interimMaster._class.name);
5355 interimMaster = interimMaster.master.rootWindow;
5357 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5358 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5364 bool DestroyEx(int64 returnCode)
5367 Timer timer, nextTimer;
5369 OldLink prevOrder = null;
5370 Window client = null;
5372 if(parent) stopwatching(parent, font);
5374 // if(window.modalSlave) return false;
5375 if(destroyed || !created)
5382 OldLink slave = master.slaves.FindLink(this);
5383 master.slaves.Delete(slave);
5386 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5392 this.returnCode = (DialogResult)returnCode;
5394 AcquireInput(false);
5399 master.hotKeys.Delete(hotKey);
5403 if(guiApp.prevWindow == this)
5405 guiApp.prevWindow = null;
5408 if(guiApp.caretOwner == this)
5410 guiApp.interfaceDriver.SetCaret(0,0,0);
5411 UpdateCaret(false, true);
5412 guiApp.caretEnabled = false;
5417 parent.childrenCycle.Remove(cycle);
5421 OldLink tmpPrev = order.prev;
5422 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5423 prevOrder = tmpPrev;
5426 client = tmpPrev ? tmpPrev.data : null;
5427 if(client == this) { client = null; break; }
5428 if(client && (client.style.hidden || client.destroyed || !client.created))
5429 tmpPrev = client.order.prev;
5433 prevOrder = tmpPrev;
5438 // If this window can be an active client, make sure the next window we activate can also be one
5439 if(!style.nonClient && style.isActiveClient)
5441 tmpPrev = prevOrder;
5444 client = tmpPrev ? tmpPrev.data : null;
5445 if(client == this) { client = null; break; }
5446 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5447 tmpPrev = client.order.prev;
5451 prevOrder = tmpPrev;
5455 if(client && client.style.hidden) client = null;
5457 // parent.childrenOrder.Remove(order);
5460 if(parent && style.isActiveClient && visible)
5462 if(state == minimized) parent.numIcons--;
5463 parent.numPositions--;
5466 // TESTING THIS HERE!
5470 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5471 // to create a window inside a rootwindow that's being destroyed)
5472 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5474 if(master && !master.destroyed /*&&
5475 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5477 if(master.defaultControl == this)
5478 master.defaultControl = null;
5481 parent.OnChildAddedOrRemoved(this, true);
5482 if(parent && !parent.destroyed /*&&
5483 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5485 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5487 if(order && prevOrder && prevOrder.data != this && active)
5489 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5491 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5492 if(parent.activeClient == this)
5494 parent.activeClient = null;
5495 parent.UpdateActiveDocument(null);
5500 if(guiApp.interimWindow == this)
5503 PropagateActive(false, null, &goOn, true);
5507 //if(window.parent.activeChild == window)
5508 parent.activeChild = null;
5509 if(!style.nonClient /*&& style.isActiveClient*/)
5511 Window previous = parent.activeClient;
5512 if(style.isActiveClient)
5513 parent.activeClient = null;
5514 parent.UpdateActiveDocument(previous);
5519 else if(parent.activeClient == this)
5521 parent.activeClient = client;
5522 parent.UpdateActiveDocument(this);
5526 if(guiApp.interimWindow == this)
5528 guiApp.interimWindow = null;
5529 if(guiApp.caretOwner)
5531 Window desktop = guiApp.desktop;
5532 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5533 guiApp.caretOwner.UpdateCaret(false, false);
5538 if(_isModal && master && master.modalSlave == this)
5539 master.modalSlave = null;
5543 if(!guiApp.caretOwner && parent.caretSize)
5545 guiApp.caretOwner = parent;
5546 parent.UpdateCaret(false, false);
5547 parent.Update(null);
5550 // Why was this commented out?
5551 GetRidOfVirtualArea();
5557 dirtyArea.Free(null);
5558 dirtyBack.Free(null);
5559 scrollExtent.Free(null);
5561 /* ATTEMPTING TO MOVE THAT ABOVE
5570 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5571 for(;(child = window.children.first);)
5573 for(; child && (child.destroyed || !child.created); child = child.next);
5582 UnloadGraphics(true);
5585 delete previousActive;
5588 // statusBar = null;
5591 if(master && !master.destroyed)
5593 //master.NotifyDestroyed(this, this.returnCode);
5594 NotifyDestroyed(master, this, this.returnCode);
5597 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5599 nextTimer = timer.next;
5600 if(timer.window == this)
5602 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5603 // timer.window = null;
5609 if(this == guiApp.windowMoving)
5612 if(guiApp.windowCaptured == this)
5614 //guiApp.windowCaptured = null;
5616 if(rootWindow != this && rootWindow)
5617 rootWindow.ConsequentialMouseMove(false);
5625 //for(child = children.first; next = child ? child.next : null, child; child = next)
5626 for(;(child = children.first); )
5628 for(; child && (child.destroyed || !child.created); child = child.next);
5638 /* // MOVED THIS UP...
5641 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5642 for(;(child = window.children.first); )
5644 for(; child && (child.destroyed || !child.created); child = child.next);
5653 while((slave = slaves.first))
5655 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5657 ((Window)slave.data).DestroyEx(0);
5662 if(guiApp.caretOwner == this)
5663 guiApp.caretOwner = null;
5665 sysButtons[0] = null;
5666 sysButtons[1] = null;
5667 sysButtons[2] = null;
5670 if(rootWindow != this)
5672 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5675 box.left -= parent.clientStart.x;
5676 box.top -= parent.clientStart.y;
5677 box.right -= parent.clientStart.x;
5678 box.bottom -= parent.clientStart.y;
5680 if(parent) parent.Update(box);
5685 OldLink slave = master.slaves.FindVoid(this);
5686 master.slaves.Delete(slave);
5692 parent.children.Remove(this);
5697 //autoCreate = false;
5700 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5701 if(((subclass(Window))_class).pureVTbl)
5703 if(_vTbl == _class._vTbl)
5705 _vTbl = ((subclass(Window))_class).pureVTbl;
5710 for(m = 0; m < _class.vTblSize; m++)
5712 if(_vTbl[m] == _class._vTbl[m])
5713 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5722 void SetStateEx(WindowState newState, bool activate)
5725 WindowState prevState = state;
5729 if(prevState != newState)
5730 lastState = prevState;
5732 if(rootWindow != this || !nativeDecorations || !windowHandle)
5734 if(style.isActiveClient && !style.hidden && prevState == minimized)
5737 // This block used to be at the end of the function... moved it for flicker problem in X
5738 // ------------------------------------------------------
5742 stateAnchor = normalAnchor;
5743 stateSizeAnchor = normalSizeAnchor;
5746 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5747 stateSizeAnchor = SizeAnchor {};
5751 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5754 byte * idBuffer = new0 byte[size];
5756 for(child = parent.children.first; child; child = child.next)
5758 if(child != this && child.state == minimized)
5760 if(child.iconID > size - 2)
5762 idBuffer = renew0 idBuffer byte[size*2];
5763 memset(idBuffer + size, 0, size);
5766 idBuffer[child.iconID] = (byte)bool::true;
5769 for(c = 0; c<size; c++)
5774 if(style.isActiveClient && !style.hidden)
5777 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5778 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5782 // TOCHECK: Why was this here?
5783 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5784 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5785 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5787 Position(x, y, w, h, true, true, true, true, false, true);
5789 if(!style.inactive && !style.interim && this == parent.activeClient)
5790 parent.UpdateActiveDocument(null);
5793 CreateSystemChildren();
5794 // ------------------------------------------------------
5797 int GetPositionID(Window forChild)
5801 byte * idBuffer = new0 byte[size];
5804 for(child = children.first; child; child = child.next)
5806 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5808 if(child.positionID > size - 2)
5810 idBuffer = renew0 idBuffer byte[size*2];
5811 memset(idBuffer + size, 0, size);
5814 idBuffer[child.positionID] = (byte)bool::true;
5817 for(c = 0; c<size; c++)
5824 // --- Window related graphics ---
5826 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5828 palette = newPalette;
5829 if(rootWindow.display)
5830 rootWindow.display.SetPalette(palette, colorMatch);
5833 public bool AcquireInput(bool acquired)
5836 if(acquiredInput != acquired)
5838 if(active || (!visible && creationActivation == activate))
5839 result = AcquireInputEx(acquired);
5844 acquiredInput = acquired ? result : !result;
5849 void ListChildren(ListBox listBox)
5853 for(child = children.first; child; child = child.next)
5855 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5857 DataRow row = listBox.AddRow();
5858 row.tag = (int64)child;
5859 child.FigureCaption(caption);
5860 row.SetData(null, caption);
5865 void UpdateVisual(Box extent)
5867 if(guiApp.driver != null)
5869 if(guiApp.fullScreenMode && guiApp.desktop.display)
5871 guiApp.desktop.mutex.Wait();
5872 guiApp.desktop.display.Lock(true);
5875 if(guiApp.desktop.active)
5877 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5879 if(guiApp.desktop.display.flags.flipping)
5880 guiApp.desktop.Update(null);
5881 guiApp.desktop.UpdateDisplay();
5882 guiApp.cursorUpdate = true;
5884 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5886 guiApp.PreserveAndDrawCursor();
5887 // guiApp.desktop.display.ShowScreen();
5888 guiApp.cursorUpdate = false;
5889 guiApp.desktop.dirty = false;
5890 guiApp.RestoreCursorBackground();
5894 guiApp.desktop.display.Unlock();
5895 guiApp.desktop.mutex.Release();
5899 Window rootWindow = this.rootWindow;
5900 rootWindow.mutex.Wait();
5905 guiApp.SignalEvent();
5908 guiApp.waitMutex.Wait();
5909 guiApp.interfaceDriver.Lock(rootWindow);
5910 if(!rootWindow.style.hidden && rootWindow.dirty)
5912 if(rootWindow.display)
5914 rootWindow.UpdateDisplay();
5915 //rootWindow.display.ShowScreen(null);
5917 rootWindow.dirty = false;
5919 guiApp.interfaceDriver.Unlock(rootWindow);
5920 guiApp.waitMutex.Release();
5923 rootWindow.mutex.Release();
5928 void UnlockDisplay(void)
5930 guiApp.interfaceDriver.Unlock(rootWindow);
5933 void LockDisplay(void)
5935 guiApp.interfaceDriver.Lock(rootWindow);
5938 Surface GetSurface(Box box)
5940 return Redraw((box == null) ? this.box : box);
5943 void SetMousePosition(int x, int y)
5945 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5949 void IntegrationActivate(bool active)
5951 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5953 isForegroundWindow = true;
5954 ActivateEx(active, active, false, false, null, null);
5955 isForegroundWindow = false;
5960 Window QueryCapture(void)
5962 return guiApp.windowCaptured;
5965 int GetDocumentID(void)
5969 byte * idBuffer = new0 byte[size];
5972 for(child = children.first; child; child = child.next)
5974 // TO CHECK: Do we want a documentID when we already have a file name?
5975 if(child.style.isDocument && !child.fileName)
5977 if(child.documentID-1 > size - 2)
5979 idBuffer = renew0 idBuffer byte[size*2];
5980 memset(idBuffer + size, 0, size);
5983 idBuffer[child.documentID-1] = 1;
5986 for(c = 0; c<size; c++)
5994 void SetInitSize(Size size)
5997 sizeAnchor.size = size;
5998 normalSizeAnchor = sizeAnchor;
6000 // Break the anchors for moveable/resizable windows
6001 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6003 stateAnchor = normalAnchor;
6004 stateSizeAnchor = normalSizeAnchor;
6006 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6007 Position(x,y, w, h, true, true, true, true, false, true);
6011 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6013 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6015 guiApp.windowIsResizing = resize;
6016 guiApp.windowMoving = this;
6017 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6018 if(guiApp.windowIsResizing)
6020 guiApp.windowMovingStart.x += size.w - 1;
6021 guiApp.windowMovingStart.y += size.h - 1;
6023 guiApp.windowMovingBefore = scrolledPos;
6024 guiApp.windowResizingBefore = size;
6025 guiApp.windowMoving.UpdateDecorations();
6026 if(guiApp.windowIsResizing)
6027 guiApp.resizeEndX = guiApp.resizeEndY = true;
6029 if(setCursorPosition)
6030 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6034 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6035 guiApp.windowMovingStart.x += x - absPosition.x;
6036 guiApp.windowMovingStart.y += y - absPosition.y;
6039 if(guiApp.windowMoving)
6041 if(guiApp.windowMoving.style.nonClient)
6042 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6044 guiApp.windowMoving.parent.SetMouseRangeToClient();
6049 if(this == rootWindow)
6050 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6058 bool result = false;
6062 else if(guiApp && guiApp.driver != null)
6064 void * systemParent = null;
6065 OldLink slaveHolder;
6067 bool visible = !style.hidden;
6071 systemParent = parent;
6072 parent = guiApp.desktop;
6074 last = parent ? parent.children.last : null;
6076 if((parent && parent != guiApp.desktop && !parent.created) ||
6077 (master && master != guiApp.desktop && !master.created))
6081 stopwatching(parent, font);
6084 property::parent = guiApp.desktop;
6085 if(!master) master = parent;
6087 if(_isModal && master.modalSlave)
6088 property::master = master.modalSlave;
6092 parent.children.Remove(this);
6095 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6096 if(slaveHolder.data == this)
6098 master.slaves.Delete(slaveHolder);
6103 if(parent == guiApp.desktop && !mutex)
6106 if(style.isDocument)
6109 parent.numDocuments--;
6110 documentID = parent.GetDocumentID();
6113 if(!style.stayOnTop)
6114 for(; last && last.style.stayOnTop; last = last.prev);
6116 parent.children.Insert((last == this) ? null : last, this);
6117 //parent.children.Add(this);
6120 dispDriver = parent.dispDriver;
6123 master.modalSlave = this;
6125 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6130 master.slaves.Add(slaveHolder = OldLink { data = this });
6135 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6137 if(style.isDefault && !master.defaultControl)
6138 master.defaultControl = this;
6140 stateAnchor = normalAnchor = anchor;
6141 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6143 // TOCHECK: Why is this here?
6144 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6145 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6147 this.visible = false;
6148 style.hidden = true;
6151 // autoCreate = true;
6159 if(parent == guiApp.desktop)
6160 Log("LoadGraphics %s\n", caption);
6162 if(LoadGraphics(true, false))
6170 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6177 if(style.hasMenuBar /*&& menu*/)
6183 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6184 interim = false, inactive = true, nonClient = true, size.h = 24
6192 // Create the system buttons
6193 CreateSystemChildren();
6195 UpdateActiveDocument(null);
6197 if(style.isDocument)
6201 MenuItem item = menu.FindItem(MenuFileSave, 0);
6202 if(item) item.disabled = !modifiedDocument && fileName;
6207 if(parent == guiApp.desktop)
6208 Log("Preemptive SetState %s\n", caption);
6211 // Preemptive Set State to ensure proper anchoring
6212 SetStateEx(state, false);
6214 style.hidden = true;
6220 for(child = children.first; child; child = next)
6223 if(!child.created && (child.autoCreate || child.wasCreated))
6230 for(link = slaves.first; link; link = next)
6232 Window slave = link.data;
6234 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6237 // Things might have happened that invalidated 'next'...
6238 // Start over the search for slaves to create.
6239 // (Added this to fix crash with Stacker & Toolbar)
6240 next = slaves.first;
6249 if(parent == guiApp.desktop)
6250 Log("Real SetState %s\n", caption);
6253 if(isActiveClient && visible)
6255 parent.numPositions--;
6256 if(state == minimized) parent.numIcons--;
6259 parent.OnChildAddedOrRemoved(this, false);
6261 // Real set state & activate for proper display & activation
6262 property::visible = visible;
6263 // SetState(state & 0x00000003, true, 0);
6264 guiApp.interfaceDriver.SetIcon(this, icon);
6269 /*if(rootWindow == this)
6270 guiApp.interfaceDriver.ActivateRootWindow(this);
6272 if(creationActivation == activate)
6273 ActivateEx(true, false, true, true, null, null);
6274 else if(creationActivation == flash)
6279 rootWindow.ConsequentialMouseMove(false);
6290 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6296 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6298 //style.hidden = true; // !visible;
6299 style.hidden = !visible;
6300 if(master.modalSlave == this)
6301 master.modalSlave = null;
6308 void WriteCaption(Surface surface, int x, int y)
6311 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6314 void Update(Box region)
6320 rootWindow = this.rootWindow;
6322 // rootWindow.mutex.Wait();
6323 if(!destroyed && visible && display)
6328 // Testing this to avoid repetitve full update to take time...
6329 if(dirtyArea.count == 1)
6331 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6332 if(item.box.left <= box.left &&
6333 item.box.top <= box.top &&
6334 item.box.right >= box.right &&
6335 item.box.bottom >= box.bottom)
6337 rootWindow.dirty = true;
6342 if(display.flags.flipping && !rootWindow.dirty)
6344 if(this == rootWindow)
6348 rootWindow.Update(null);
6353 rootWindow.dirty = true;
6358 realBox.left += clientStart.x;
6359 realBox.top += clientStart.y;
6360 realBox.right += clientStart.x;
6361 realBox.bottom += clientStart.y;
6367 if(realBox.right >= realBox.left &&
6368 realBox.bottom >= realBox.top)
6370 // if(!rootWindow.fullRender)
6371 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6373 for(child = children.first; child; child = child.next)
6378 box.left -= child.absPosition.x - absPosition.x;
6379 box.top -= child.absPosition.y - absPosition.y;
6380 box.right -= child.absPosition.x - absPosition.x;
6381 box.bottom -= child.absPosition.y - absPosition.y;
6382 if(box.right >= child.box.left && box.left <= child.box.right &&
6383 box.bottom >= child.box.top && box.top <= child.box.bottom)
6385 box.left -= child.clientStart.x;
6386 box.top -= child.clientStart.y;
6387 box.right -= child.clientStart.x;
6388 box.bottom -= child.clientStart.y;
6394 realBox.left += absPosition.x - rootWindow.absPosition.x;
6395 realBox.top += absPosition.y - rootWindow.absPosition.y;
6396 realBox.right += absPosition.x - rootWindow.absPosition.x;
6397 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6398 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6401 else if(this == guiApp.desktop)
6404 for(window = children.first; window; window = window.next)
6410 Box childBox = region;
6412 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6413 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6414 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6415 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6417 window.Update(childBox);
6420 window.Update(null);
6425 // rootWindow.mutex.Release();
6432 if(guiApp.windowCaptured != this)
6434 if(guiApp.windowCaptured)
6438 //Logf("Captured %s (%s)\n", caption, class.name);
6439 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6440 guiApp.windowCaptured = this;
6446 bool Destroy(int64 code)
6451 if(!destroyed && !CloseConfirmation(false)) return false;
6455 // TOCHECK: Should autoCreate be set to false here?
6466 void Move(int x, int y, int w, int h)
6468 normalAnchor = Anchor { left = x, top = y };
6469 normalSizeAnchor = SizeAnchor { size = { w, h } };
6471 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6473 if(destroyed) return;
6475 stateAnchor = normalAnchor;
6476 stateSizeAnchor = normalSizeAnchor;
6478 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6479 Position(x,y, w, h, true, true, true, true, false, true);
6483 DialogResult Modal(void)
6489 // FIXES MEMORY LEAK IF Create() FAILED
6495 void SetScrollArea(int width, int height, bool snapToStep)
6497 bool resize = false;
6500 int stepX = sbStep.x, stepY = sbStep.y;
6501 // Needed to make snapped down position match the skin's check of client area
6502 // against realvirtual
6505 SNAPDOWN(stepX, textCellW);
6506 SNAPDOWN(stepY, textCellH);
6507 stepX = Max(stepX, textCellW);
6508 stepY = Max(stepY, textCellH);
6510 if(scrollFlags.snapX)
6511 SNAPUP(width, stepX);
6512 if(scrollFlags.snapY)
6513 SNAPUP(height, stepY);
6516 reqScrollArea.w = width;
6517 reqScrollArea.h = height;
6518 noAutoScrollArea = (width > 0 || height > 0);
6520 UpdateScrollBars(true, true);
6523 void SetScrollPosition(int x, int y)
6526 sbh.Action(setPosition, x, 0);
6530 int seen = clientSize.w, total = reqScrollArea.w;
6532 if(scrollFlags.snapX)
6533 SNAPDOWN(seen, sbStep.x);
6535 if(!total) total = seen;
6536 range = total - seen + 1;
6537 range = Max(range, 1);
6539 if(x >= range) x = range - 1;
6541 if(scrollFlags.snapX)
6542 SNAPUP(x, sbStep.x);
6545 OnHScroll(setPosition, x, 0);
6549 SNAPDOWN(x, textCellW);
6555 sbv.Action(setPosition, y, 0);
6559 int seen = clientSize.h, total = reqScrollArea.h;
6562 if(scrollFlags.snapY)
6563 SNAPDOWN(seen, sbStep.y);
6565 if(!total) total = seen;
6566 range = total - seen + 1;
6567 range = Max(range, 1);
6569 if(y >= range) y = range - 1;
6571 if(scrollFlags.snapY)
6572 SNAPUP(y, sbStep.y);
6575 OnVScroll(setPosition, y, 0);
6578 SNAPDOWN(y, textCellH);
6583 UpdateCaret(false, false);
6586 void SetScrollLineStep(int stepX, int stepY)
6592 SNAPDOWN(stepX, textCellW);
6593 SNAPDOWN(stepY, textCellH);
6594 stepX = Max(stepX, textCellW);
6595 stepY = Max(stepY, textCellH);
6598 sbh.lineStep = stepX;
6600 sbv.lineStep = stepY;
6603 void SetState(WindowState newState, bool activate, Modifiers mods)
6607 if(state == newState || OnStateChange(newState, mods))
6609 WindowState prevState = state;
6613 // This used to be at the end of the brackets... moved for X, testing...
6614 // This has the effect of activating the window through the system...
6615 if(rootWindow == this)
6616 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6618 SetStateEx(newState, activate);
6620 if(rootWindow == this && !rootWindow.nativeDecorations)
6622 int x = position.x, y = position.y;
6625 x -= guiApp.desktop.absPosition.x;
6626 y -= guiApp.desktop.absPosition.y;
6628 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6632 //state = prevState;
6634 if(state != maximized && style.hasMaximize)
6637 for(child = parent.children.first; child; child = child.next)
6639 if(child != this && child.state == maximized)
6640 child.SetStateEx(normal, false);
6644 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6645 parent.UpdateScrollBars(true, true);
6648 // Do we really need this stuff here?
6649 // Shouldn't the Activate stuff take care of it?
6650 if(parent.rootWindow == parent && style)
6653 parent.FigureCaption(caption);
6654 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6655 parent.UpdateDecorations();
6659 rootWindow.ConsequentialMouseMove(false);
6666 BitmapResource GetIcon(SkinBitmap iconID)
6668 return guiApp.currentSkin.GetBitmap(iconID);
6671 void SetMouseRange(Box range)
6673 if(range || guiApp.fullScreenMode)
6678 clip.left = range.left + absPosition.x + clientStart.x;
6679 clip.top = range.top + absPosition.y + clientStart.y;
6680 clip.right = range.right + absPosition.x + clientStart.x;
6681 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6685 clip.left = guiApp.desktop.box.left;
6686 clip.top = guiApp.desktop.box.top;
6687 clip.right = guiApp.desktop.box.right;
6688 clip.bottom = guiApp.desktop.box.bottom;
6690 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6693 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6696 void SetMouseRangeToClient(void)
6698 if(guiApp.fullScreenMode || this != guiApp.desktop)
6700 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6701 box.Clip(clientArea);
6705 SetMouseRange(null);
6708 void SetMouseRangeToWindow(void)
6710 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6711 if(this == guiApp.desktop)
6712 SetMouseRangeToClient();
6717 // x, y: Desktop Coordinates
6718 void ShowSysMenu(int x, int y)
6721 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6724 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6725 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6729 menu, $"Move", m, NotifySelect = MenuWindowMove,
6730 disabled = !style.fixed || state == maximized
6734 menu, $"Size", s, NotifySelect = MenuWindowSize,
6735 disabled = !style.sizable || state != normal
6739 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6740 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6744 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6745 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6749 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6750 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6752 MenuDivider { menu };
6755 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6756 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6758 windowMenu.Create();
6763 ActivateEx(true, true, true, true, null, null);
6766 void MakeActive(void)
6768 ActivateEx(true, false, true, false, null, null);
6771 void SoftActivate(void)
6773 if(guiApp.desktop.active)
6779 void Deactivate(void)
6781 ActivateEx(false, true, true, true, null, null);
6786 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6789 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6791 bool result = false;
6792 if(activeChild && activeChild.cycle)
6794 Window modalWindow, child = activeChild;
6795 if(!clientOnly /*&& parent.tabCycle*/)
6797 Window next = child;
6800 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6804 if(parent && parent.CycleChildren(backward, false, true, true))
6812 next = next.cycle.prev.data;
6814 next = next.cycle.next.data;
6815 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6820 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6821 parent.tabCycle && parent.CycleChildren(backward, false, false))
6825 if(tabCycleOnly && !tabCycle) return false;
6832 child = child.cycle.prev.data;
6834 child = child.cycle.next.data;
6835 if(child == child.parent.activeChild)
6837 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6840 modalWindow = child.FindModal();
6843 // Scroll the window to include the active control
6844 if(sbh && !child.style.dontScrollHorz)
6846 if(child.scrolledPos.x < 0)
6847 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6848 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6849 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6851 if(sbv && !child.style.dontScrollVert)
6853 if(child.scrolledPos.y < 0)
6854 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6855 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6856 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6860 child = modalWindow ? modalWindow : child;
6861 child.ActivateEx(true, true, true, true, null, null);
6862 if(child.tabCycle && child.childrenCycle.first)
6863 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6871 ConsequentialMouseMove(false);
6875 void AddResource(Resource resource)
6879 ResPtr ptr { resource = resource };
6883 // Load Graphics here if window is created already
6884 if(/*created && */display)
6886 display.Lock(false);
6887 ptr.loaded = display.displaySystem.LoadResource(resource);
6891 // Temporary hack to load font right away for listbox in dropbox ...
6892 else if(master && master.display)
6894 master.display.Lock(false);
6895 master.display.displaySystem.LoadResource(resource);
6896 master.display.Unlock();
6902 void RemoveResource(Resource resource)
6907 for(ptr = resources.first; ptr; ptr = ptr.next)
6909 if(ptr.resource == resource)
6915 // Unload Graphics here if window is created already
6916 if(/*created && */display)
6920 display.Lock(false);
6921 display.displaySystem.UnloadResource(resource, ptr.loaded);
6927 resources.Delete(ptr);
6932 void SetCaret(int x, int y, int size)
6939 if(active && !style.interim)
6941 if(visible || !guiApp.caretOwner)
6942 guiApp.caretOwner = size ? this : null;
6944 UpdateCaret(false, false);
6947 guiApp.interfaceDriver.SetCaret(0,0,0);
6948 UpdateCaret(false, true);
6949 guiApp.caretEnabled = false;
6952 else if(style.inactive && active)
6954 guiApp.interfaceDriver.SetCaret(0,0,0);
6955 UpdateCaret(false, true);
6956 guiApp.caretEnabled = false;
6961 void Scroll(int x, int y)
6963 bool opaque = !style.drawBehind || background.a;
6964 if(opaque && display && display.flags.scrolling)
6966 Box box = clientArea;
6967 box.left += clientStart.x;
6968 box.top += clientStart.y;
6969 box.right += clientStart.x;
6970 box.bottom += clientStart.y;
6972 //scrollExtent.Free(null);
6973 scrollExtent.AddBox(box);
6974 scrolledArea.x += x;
6975 scrolledArea.y += y;
6977 //scrollExtent.Free();
6978 //scrollExtent.AddBox(clientArea);
6979 //scrollExtent.Offset(clientStart.x, clientStart.y);
6980 //scrolledArea.x = x;
6981 //scrolledArea.y = y;
6987 rootWindow.dirty = true;
6990 void ReleaseCapture()
6992 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6994 Window oldCaptured = guiApp.windowCaptured;
6995 guiApp.windowCaptured = null;
6996 guiApp.prevWindow = null;
6999 //guiApp.Log("Released Capture\n");
7001 guiApp.interfaceDriver.SetMouseCapture(null);
7003 //oldCaptured.OnMouseCaptureLost();
7006 oldCaptured.ConsequentialMouseMove(false);
7011 private void _SetCaption(char * format, va_list args)
7018 char caption[MAX_F_STRING];
7019 vsnprintf(caption, sizeof(caption), format, args);
7020 caption[sizeof(caption)-1] = 0;
7022 this.caption = CopyString(caption);
7027 firewatchers caption;
7031 /*deprecated*/ void SetText(char * format, ...)
7034 va_start(args, format);
7035 _SetCaption(format, args);
7039 void SetCaption(char * format, ...)
7042 va_start(args, format);
7043 _SetCaption(format, args);
7047 bool Grab(Bitmap bitmap, Box box, bool decorations)
7049 bool result = false;
7050 if(display || this == guiApp.desktop)
7052 Box clip = {MININT, MININT, MAXINT, MAXINT};
7058 clip.Clip(clientArea);
7060 clip.Clip(this.box);
7062 if(rootWindow != this)
7064 clip.left += absPosition.y;
7065 clip.top += absPosition.y;
7066 clip.right += absPosition.x;
7067 clip.bottom += absPosition.y;
7070 clip.left += decorations ? 0 : clientStart.x;
7071 clip.top += decorations ? 0 : clientStart.y;
7072 clip.right += decorations ? 0 : clientStart.x;
7073 clip.bottom += decorations ? 0 : clientStart.y;
7075 if(display && display.flags.flipping)
7077 rootWindow.Update(null);
7078 rootWindow.UpdateDisplay();
7085 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7086 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7090 result = display.Grab(bitmap, clip.left, clip.top,
7091 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7093 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7095 if(!bitmap.Convert(null, pixelFormat888, null))
7102 void GetMousePosition(int * x, int * y)
7104 int mouseX = 0, mouseY = 0;
7105 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7108 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7109 if(this != guiApp.desktop)
7111 mouseX -= absPosition.x + clientStart.x;
7112 mouseY -= absPosition.y + clientStart.y;
7119 DialogResult DoModal()
7121 DialogResult returnCode = 0;
7122 int terminated = terminateX;
7125 while(!destroyed && guiApp.driver != null)
7127 if(terminateX != terminated)
7129 terminated = terminateX;
7130 guiApp.desktop.Destroy(0);
7131 if(guiApp.desktop.created)
7134 //printf("Resetting terminate X to 0\n");
7140 guiApp.UpdateDisplay();
7141 if(!guiApp.ProcessInput(false))
7144 returnCode = this.returnCode;
7157 return !destroyed && guiApp.driver != null && terminateX < 2;
7160 DialogResult DoModalEnd()
7162 DialogResult returnCode = this.returnCode;
7167 // --- Window manipulation ---
7168 /*bool GetDisabled()
7170 bool disabled = this.disabled;
7172 for(window = this; (window = window.master); )
7183 // --- Mouse Manipulation ---
7184 void GetNCMousePosition(int * x, int * y)
7186 GetMousePosition(x, y);
7187 if(x) *x += clientStart.x;
7188 if(y) *y += clientStart.y;
7191 // --- Carets manipulation ---
7192 void GetCaretPosition(Point caretPos)
7194 caretPos = this.caretPos;
7197 int GetCaretSize(void)
7202 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7208 bool CloseConfirmation(bool parentClosing)
7221 if(!OnClose(parentClosing))
7224 // If you want to skip this, simply set modifiedDocument to false in OnClose
7225 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7227 DialogResult dialogRes;
7230 sprintf(message, $"Save changes to %s?", fileName);
7232 sprintf(message, $"Save changes to Untitled %d?", documentID);
7234 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7236 if(dialogRes == yes)
7238 // TOFIX: Precomp error if brackets are taken out
7239 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7241 else if(dialogRes == cancel)
7247 for(slave = slaves.first; slave; slave = slave.next)
7249 Window w = slave.data;
7250 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7252 // ((Window)slave.data).CloseConfirmation(true);
7261 for(child = children.first; child; child = child.next)
7262 if(child.master != this && !child.CloseConfirmation(true))
7272 // Static methods... move them somewhere else?
7273 void ::RestoreCaret()
7275 if(guiApp.caretOwner)
7276 guiApp.caretOwner.UpdateCaret(false, false);
7279 void ::FreeMouseRange()
7281 guiApp.interfaceDriver.SetMouseRange(null, null);
7285 bool MenuFileClose(MenuItem selection, Modifiers mods)
7287 Window document = activeChild;
7289 document.Destroy(0);
7293 bool MenuFileExit(MenuItem selection, Modifiers mods)
7299 bool MenuFileSave(MenuItem selection, Modifiers mods)
7303 fileMonitor.fileName = null;
7306 if(OnSaveFile(fileName))
7308 //if(OnFileModified != Window::OnFileModified)
7311 fileMonitor.fileName = fileName;
7317 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7318 DialogResult answer = dialog.Modal();
7320 if(answer != yes) return (bool)answer;
7323 return MenuFileSaveAs(selection, mods);
7326 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7328 DialogResult result = (DialogResult)bool::true;
7329 FileDialog fileDialog = saveDialog;
7332 fileDialog = FileDialog {};
7337 fileDialog.filePath = fileName;
7340 char filePath[MAX_FILENAME];
7341 sprintf(filePath, "Untitled %d", documentID);
7342 fileDialog.filePath = filePath;
7344 fileMonitor.fileName = null;
7346 fileDialog.type = save;
7347 fileDialog.text = $"Save As";
7351 fileDialog.master = master.parent ? master : this;
7352 if(fileDialog.Modal() == ok)
7354 char * filePath = fileDialog.filePath;
7356 if(OnSaveFile(filePath))
7359 property::fileName = filePath;
7360 NotifySaved(master, this, filePath);
7365 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7366 DialogResult answer = dialog.Modal();
7381 //if(OnFileModified != Window::OnFileModified && fileName)
7384 fileMonitor.fileName = fileName;
7388 return (bool)result; // Actually returning result from Yes/NoCancel message box
7391 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7393 Window document = activeChild;
7395 for(document = children.first; document; document = next)
7397 next = document.next;
7398 if(document.style.isDocument || document.fileName)
7399 document.MenuFileSave(selection, mods);
7404 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7408 for(document = children.first; document; document = document.next)
7409 //if(document.style.isDocument && document.state == minimized)
7410 if(document.style.isActiveClient && document.state == minimized)
7411 document.SetState(minimized, false, mods);
7415 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7417 Window document = activeChild;
7420 Window firstDocument = null;
7422 OldLink cycle = document.cycle.prev;
7427 if(child.style.isActiveClient && !child.style.hidden)
7431 firstDocument = child;
7432 if(child.state == minimized)
7433 child.SetState(minimized, false, mods);
7436 child.positionID = id++;
7437 child.SetState(normal, false, mods);
7438 child.anchor.left.type = cascade;
7441 child.normalSizeAnchor = *&child.sizeAnchor;
7442 child.normalAnchor = child.anchor;
7444 // Break the anchors for moveable/resizable windows
7445 if(child.style.fixed)
7447 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7449 (*&child.normalAnchor).left = x;
7450 (*&child.normalAnchor).top = y;
7451 (*&child.normalAnchor).right.type = none;
7452 (*&child.normalAnchor).bottom.type = none;
7454 child.normalSizeAnchor.isClientW = false;
7455 child.normalSizeAnchor.isClientH = false;
7456 child.normalSizeAnchor.size.w = w;
7457 child.normalSizeAnchor.size.h = h;
7458 child.anchored = false;
7461 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7463 child.stateAnchor = child.normalAnchor;
7464 child.stateSizeAnchor = child.normalSizeAnchor;
7466 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7467 child.Position(x, y, w, h, true, true, true, true, false, false);
7472 last = children.last;
7473 if(!child.style.stayOnTop)
7474 for(; last && last.style.stayOnTop; last = last.prev);
7475 children.Move(child, last);
7476 childrenOrder.Move(child.order, childrenOrder.last);
7478 if(cycle == document.cycle) break;
7482 firstDocument.Activate();
7487 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7494 // Close all closes all active clients, not all documents
7495 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7497 Window next, document;
7499 for(document = children.first; document; document = next)
7501 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7502 if(document.style.isActiveClient)
7503 if(!document.Destroy(0) && !document.style.hidden)
7509 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7511 if(style.hasMaximize && state != maximized)
7512 SetState(maximized, 0, 0);
7516 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7518 if(style.hasMinimize && state != minimized)
7520 SetState(minimized, 0, 0);
7521 parent.CycleChildren(false, true, false, true);
7526 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7528 MenuMoveOrSize(false, selection ? true : false);
7532 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7534 CycleChildren(false, true, false, true);
7538 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7540 CycleChildren(true, true, false, true);
7544 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7546 MenuMoveOrSize(true, true);
7550 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7553 SetState(normal, 0, 0);
7557 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7560 int64 id = selection.id;
7561 OldLink cycle = activeClient.cycle;
7563 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7566 Window sibling = cycle.data;
7567 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7575 document = cycle.data;
7576 document.Activate();
7578 //if(activeChild.state == maximized)
7579 // document.SetState(maximized, false, mods);
7580 //else if(document.state == minimized)
7581 // document.SetState(normal, false, mods);
7585 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7587 stayOnTop = !style.stayOnTop;
7591 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7593 Window document = activeChild;
7596 Window firstDocument = null;
7597 OldLink cycle = document.cycle;
7601 Window child = cycle.data;
7602 if(child.style.isActiveClient && !child.style.hidden)
7604 if(!firstDocument) firstDocument = child;
7605 if(child.state == minimized)
7606 child.SetState(minimized, false, mods);
7609 child.positionID = id++;
7610 child.SetState(normal, false, mods);
7611 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7613 child.anchor.left.type = hTiled;
7616 child.normalSizeAnchor = *&child.sizeAnchor;
7617 child.normalAnchor = child.anchor;
7619 // Break the anchors for moveable/resizable windows
7620 if(child.style.fixed)
7622 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7624 (*&child.normalAnchor).left = x;
7625 (*&child.normalAnchor).top = y;
7626 (*&child.normalAnchor).right.type = none;
7627 (*&child.normalAnchor).bottom.type = none;
7628 child.normalSizeAnchor.isClientW = false;
7629 child.normalSizeAnchor.isClientH = false;
7630 child.normalSizeAnchor.size.w = w;
7631 child.normalSizeAnchor.size.h = h;
7632 child.anchored = false;
7635 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7637 child.stateAnchor = child.normalAnchor;
7638 child.stateSizeAnchor = child.normalSizeAnchor;
7640 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7641 child.Position(x,y, w, h, true, true, true, true, false, true);
7646 if((cycle = cycle.next) == document.cycle) break;
7649 firstDocument.Activate();
7654 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7656 Window document = activeChild;
7659 Window firstDocument = null;
7661 OldLink cycle = document.cycle;
7666 //if(child.style.isDocument)
7667 if(child.style.isActiveClient && !child.style.hidden)
7669 if(!firstDocument) firstDocument = child;
7670 if(child.state == minimized)
7671 child.SetState(minimized, false, mods);
7674 child.positionID = id++;
7675 child.SetState(normal, false, mods);
7676 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7678 child.anchor.left.type = vTiled;
7681 child.normalSizeAnchor = *&child.sizeAnchor;
7682 child.normalAnchor = child.anchor;
7684 // Break the anchors for moveable/resizable windows
7685 if(child.style.fixed)
7687 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7689 (*&child.normalAnchor).left = x;
7690 (*&child.normalAnchor).top = y;
7691 (*&child.normalAnchor).right.type = none;
7692 (*&child.normalAnchor).bottom.type = none;
7693 child.normalSizeAnchor.isClientW = false;
7694 child.normalSizeAnchor.isClientH = false;
7695 child.normalSizeAnchor.size.w = w;
7696 child.normalSizeAnchor.size.h = h;
7697 child.anchored = false;
7700 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7702 child.stateAnchor = child.normalAnchor;
7703 child.stateSizeAnchor = child.normalSizeAnchor;
7705 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7706 child.Position(x,y, w, h, true, true, true, true, false, true);
7711 if((cycle = cycle.next) == document.cycle) break;
7714 firstDocument.Activate();
7719 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7721 WindowList dialog { master = this };
7722 Window document = (Window)dialog.Modal();
7725 if(activeChild.state == maximized)
7726 document.SetState(maximized, false, mods);
7727 else if(document.state == minimized)
7728 document.SetState(normal, false, mods);
7729 document.Activate();
7735 virtual bool OnCreate(void);
7736 virtual void OnDestroy(void);
7737 virtual void OnDestroyed(void);
7738 virtual bool OnClose(bool parentClosing);
7739 virtual bool OnStateChange(WindowState state, Modifiers mods);
7740 virtual bool OnPostCreate(void);
7741 virtual bool OnMoving(int *x, int *y, int w, int h);
7742 virtual bool OnResizing(int *width, int *height);
7743 virtual void OnResize(int width, int height);
7744 virtual void OnPosition(int x, int y, int width, int height);
7745 virtual bool OnLoadGraphics(void);
7746 virtual void OnApplyGraphics(void);
7747 virtual void OnUnloadGraphics(void);
7748 virtual void OnRedraw(Surface surface);
7749 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7750 virtual void OnActivateClient(Window client, Window previous);
7751 virtual bool OnKeyDown(Key key, unichar ch);
7752 virtual bool OnKeyUp(Key key, unichar ch);
7753 virtual bool OnKeyHit(Key key, unichar ch);
7754 virtual bool OnSysKeyDown(Key key, unichar ch);
7755 virtual bool OnSysKeyUp(Key key, unichar ch);
7756 virtual bool OnSysKeyHit(Key key, unichar ch);
7757 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7758 virtual bool OnMouseLeave(Modifiers mods);
7759 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7760 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7761 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7762 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7763 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7764 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7765 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7766 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7767 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7768 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7769 virtual void OnMouseCaptureLost(void);
7770 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7771 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7772 virtual void OnDrawOverChildren(Surface surface);
7773 virtual bool OnFileModified(FileChange fileChange, char * param);
7774 virtual bool OnSaveFile(char * fileName);
7776 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7777 // Note: A 'client' would refer to isActiveClient, rather than
7778 // being confined to the 'client area' (nonClient == false)
7779 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7780 virtual void OnChildVisibilityToggled(Window child, bool visible);
7781 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7783 // Skins Virtual Functions
7784 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7785 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7786 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7791 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7792 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7793 virtual bool IsMouseMoving(int x, int y, int w, int h)
7797 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7801 virtual void UpdateNonClient();
7802 virtual void SetBox(Box box);
7803 virtual bool IsInside(int x, int y)
7805 return box.IsPointInside({x, y});
7807 virtual bool IsOpaque()
7809 return (!style.drawBehind || background.a == 255);
7813 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7814 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7815 virtual void Window::NotifySaved(Window window, char * filePath);
7820 property Window parent
7822 property_category $"Layout"
7825 if(value || guiApp.desktop)
7828 Window oldParent = parent;
7829 Anchor anchor = this.anchor;
7831 if(value && value.IsDescendantOf(this)) return;
7832 if(value && value == this)
7834 if(!value) value = guiApp.desktop;
7836 if(value == oldParent) return;
7838 if(!master || (master == this.parent && master == guiApp.desktop))
7839 property::master = value;
7843 parent.children.Remove(this);
7847 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7848 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7849 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7850 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7854 last = value.children.last;
7856 if(style.isDocument)
7859 parent.numDocuments--;
7860 documentID = value.GetDocumentID();
7863 if(style.isActiveClient && !style.hidden)
7865 if(parent && parent != guiApp.desktop && !(style.hidden))
7867 if(state == minimized) parent.numIcons--;
7868 parent.numPositions--;
7872 if(!style.stayOnTop)
7873 for(; last && last.style.stayOnTop; last = last.prev);
7875 value.children.Insert(last, this);
7877 // *** NEW HERE: ***
7879 parent.childrenCycle.Delete(cycle);
7881 parent.childrenOrder.Delete(order);
7884 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7885 // Should something else be done?
7886 if(parent && parent.activeChild == this)
7887 parent.activeChild = null;
7888 if(parent && parent.activeClient == this)
7889 parent.activeClient = null;
7895 int x = position.x, y = position.y, w = size.w, h = size.h;
7899 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7900 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7902 vpw = value.clientSize.w;
7903 vph = value.clientSize.h;
7909 else if(style.fixed)
7911 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7912 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7915 anchor = this.anchor;
7917 if(anchor.left.type == offset) anchor.left.distance = x;
7918 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7919 if(anchor.top.type == offset) anchor.top.distance = y;
7920 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7921 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7922 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7923 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7924 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7925 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7926 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7928 if(!anchor.left.type && !anchor.right.type)
7930 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7931 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7933 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7934 if(!anchor.top.type && !anchor.bottom.type)
7936 anchor.vert.distance = (y + h / 2) - (vph / 2);
7937 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7939 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7942 parent.OnChildAddedOrRemoved(this, false);
7948 parent.childrenCycle.Insert(
7949 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7950 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7952 cycle = OldLink { data = this });
7953 parent.childrenOrder.Insert(
7954 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7955 order = OldLink { data = this });
7958 if(!style.hidden && style.isActiveClient)
7960 positionID = parent.GetPositionID(this);
7961 parent.numPositions++;
7962 if(state == minimized) parent.numIcons--;
7965 // *** FONT INHERITANCE ***
7966 if(!setFont && oldParent)
7967 stopwatching(oldParent, font);
7971 RemoveResource(systemFont);
7974 // TESTING WITH WATCHERS:
7975 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7976 // usedFont = setFont ? setFont : (systemFont);
7980 if(guiApp.currentSkin)
7982 systemFont = guiApp.currentSkin.SystemFont();
7985 usedFont = systemFont;
7986 AddResource(systemFont);
7994 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8003 if(value.rootWindow && value.rootWindow.display && rootWindow)
8005 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8006 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8009 UnloadGraphics(false);
8012 LoadGraphics(false, false);
8015 if(value.rootWindow != rootWindow)
8016 DisplayModeChanged();
8020 scrolledPos.x = MININT; // Prevent parent update
8022 bool anchored = this.anchored;
8023 property::anchor = anchor;
8024 this.anchored = anchored;
8029 if(guiApp.currentSkin)
8030 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8032 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8033 Position(x, y, w, h, true, true, true, true, false, true);
8038 // else parent = value;
8040 oldParent.OnChildAddedOrRemoved(this, true);
8043 get { return parent; }
8046 property Window master
8048 property_category $"Behavior"
8051 //if(this == value) return;
8052 if(value && value.IsSlaveOf(this)) return;
8058 OldLink slaveHolder;
8059 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8060 if(slaveHolder.data == this)
8062 master.slaves.Delete(slaveHolder);
8069 value.slaves.Add(OldLink { data = this });
8074 master.hotKeys.Remove(hotKey);
8075 value.hotKeys.Add(hotKey);
8078 if(master && master.defaultControl == this)
8079 master.defaultControl = null;
8081 if(style.isDefault && !value.defaultControl)
8082 value.defaultControl = this;
8087 get { return master ? master : parent; }
8090 property char * caption
8092 property_category $"Appearance"
8099 caption = new char[strlen(value)+1];
8101 strcpy(caption, value);
8106 get { return caption; }
8111 property_category $"Behavior"
8120 master.hotKeys.Add(hotKey = HotKeySlot { });
8124 hotKey.window = this;
8129 master.hotKeys.Delete(hotKey);
8134 get { return hotKey ? hotKey.key : 0; }
8137 property Color background
8139 property_category $"Appearance"
8142 background.color = value;
8147 if(this == rootWindow)
8148 guiApp.interfaceDriver.SetRootWindowColor(this);
8151 get { return background.color; }
8154 property Percentage opacity
8156 property_category $"Appearance"
8159 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8160 drawBehind = (background.a == 255) ? false : true;
8162 get { return background.a / 255.0f; }
8165 property Color foreground
8167 property_category $"Appearance"
8175 get { return foreground; }
8178 property BorderStyle borderStyle
8180 property_category $"Appearance"
8183 if(!((BorderBits)value).fixed)
8185 style.hasClose = false;
8186 style.hasMaximize = false;
8187 style.hasMinimize = false;
8188 nativeDecorations = false;
8190 style.borderBits = value;
8194 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8196 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8197 Position(x, y, w, h, true, true, true, true, false, true);
8198 CreateSystemChildren();
8201 get { return (BorderStyle)style.borderBits; }
8204 property Size minClientSize
8206 property_category $"Layout"
8207 set { minSize = value; }
8208 get { value = minSize; }
8211 property Size maxClientSize
8213 property_category $"Layout"
8214 set { maxSize = value; }
8215 get { value = maxSize; }
8218 property bool hasMaximize
8220 property_category $"Window Style"
8223 style.hasMaximize = value;
8224 if(value) { style.fixed = true; style.contour = true; }
8228 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8230 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8231 Position(x, y, w, h, true, true, true, true, false, true);
8233 CreateSystemChildren();
8236 get { return style.hasMaximize; }
8239 property bool hasMinimize
8241 property_category $"Window Style"
8244 style.hasMinimize = value;
8245 if(value) { style.fixed = true; style.contour = true; }
8249 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8251 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8252 Position(x, y, w, h, true, true, true, true, false, true);
8254 CreateSystemChildren();
8257 get { return style.hasMinimize; }
8260 property bool hasClose
8262 property_category $"Window Style"
8265 style.hasClose = value;
8266 if(value) { style.fixed = true; style.contour = true; }
8270 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8271 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8272 Position(x, y, w, h, true, true, true, true, false, true);
8273 CreateSystemChildren();
8276 get { return style.hasClose; }
8279 property bool nonClient
8281 property_category $"Layout"
8284 style.nonClient = value;
8286 style.stayOnTop = true;
8288 get { return style.nonClient; }
8291 property bool inactive
8293 property_category $"Behavior"
8298 // *** NEW HERE: ***
8302 parent.childrenCycle.Delete(cycle);
8304 parent.childrenOrder.Delete(order);
8311 active = false; // true;
8312 if(parent.activeChild == this)
8313 parent.activeChild = null;
8314 if(parent.activeClient == this)
8315 parent.activeClient = null;
8324 parent.childrenCycle.Insert(
8325 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8326 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8328 cycle = OldLink { data = this });
8330 parent.childrenOrder.Insert(
8331 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8332 order = OldLink { data = this });
8335 style.inactive = value;
8337 get { return style.inactive; }
8340 property bool clickThrough
8342 property_category $"Behavior"
8343 set { style.clickThrough = value; }
8344 get { return style.clickThrough; }
8347 property bool isRemote
8349 property_category $"Behavior"
8350 set { style.isRemote = value; }
8351 get { return style.isRemote; }
8354 property bool noCycle
8356 property_category $"Behavior"
8357 set { style.noCycle = value; }
8358 get { return style.noCycle; }
8361 property bool isModal
8363 property_category $"Behavior"
8364 set { style.modal = value; }
8365 get { return style.modal; }
8368 property bool interim
8370 property_category $"Behavior"
8371 set { style.interim = value; }
8372 get { return style.interim; }
8375 property bool tabCycle
8377 property_category $"Behavior"
8378 set { style.tabCycle = value; }
8379 get { return style.tabCycle; }
8382 property bool isDefault
8384 property_category $"Behavior"
8392 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8393 if(sibling != this && sibling.style.isDefault)
8394 sibling.style.isDefault = false;*/
8395 if(master.defaultControl)
8396 master.defaultControl.style.isDefault = false;
8397 master.defaultControl = this;
8399 else if(master.defaultControl == this)
8400 master.defaultControl = null;
8404 style.isDefault = value;
8406 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8408 get { return style.isDefault; }
8411 property bool drawBehind
8413 property_category $"Window Style"
8414 set { style.drawBehind = value; }
8415 get { return style.drawBehind; }
8418 property bool hasMenuBar
8420 property_category $"Window Style"
8430 if(created && !menuBar)
8437 anchor = Anchor { top = 23, left = 1, right = 1 },
8439 inactive = true, nonClient = true
8444 else if(created && menuBar)
8449 style.hasMenuBar = value;
8451 get { return style.hasMenuBar; }
8454 property bool hasStatusBar
8456 property_category $"Window Style"
8463 statusBar = StatusBar { this };
8471 style.hasStatusBar = value;
8473 get { return style.hasStatusBar; }
8475 property bool stayOnTop
8477 property_category $"Window Style"
8482 if(created && !style.stayOnTop)
8484 if(rootWindow == this)
8485 guiApp.interfaceDriver.OrderRootWindow(this, true);
8486 else if(parent.children.last != this)
8488 parent.children.Move(this, parent.children.last);
8492 style.stayOnTop = true;
8496 if(created && style.stayOnTop)
8498 if(rootWindow == this)
8499 guiApp.interfaceDriver.OrderRootWindow(this, false);
8506 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8507 order && ((Window)order.data).style.stayOnTop;
8508 order = (order == parent.childrenOrder.first) ? null : order.prev);
8509 last = order ? order.data : null;
8513 for(last = parent.children.last;
8514 last && last.style.stayOnTop;
8518 parent.children.Move(this, last);
8522 style.stayOnTop = false;
8525 get { return style.stayOnTop; }
8530 property_category $"Window Style"
8540 if(menuBar && !value)
8547 if(!menuBar && style.hasMenuBar && value)
8551 this, menu = value, isMenuBar = true,
8552 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8553 inactive = true, nonClient = true
8557 UpdateActiveDocument(null);
8560 get { return menu; }
8563 property FontResource font
8565 property_category $"Appearance"
8567 isset { return setFont ? true : false; }
8572 if(value && !setFont) { stopwatching(parent, font); }
8573 else if(!value && setFont)
8579 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8588 RemoveResource(setFont);
8593 RemoveResource(systemFont);
8600 AddResource(setFont);
8603 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8606 systemFont = guiApp.currentSkin.SystemFont();
8608 usedFont = systemFont;
8609 AddResource(systemFont);
8617 get { return usedFont; }
8620 property SizeAnchor sizeAnchor
8622 property_category $"Layout"
8625 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8626 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8627 sizeAnchor.isClientW != sizeAnchor.isClientH;
8634 normalSizeAnchor = sizeAnchor;
8636 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8638 stateAnchor = normalAnchor;
8639 stateSizeAnchor = normalSizeAnchor;
8641 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8642 Position(x,y, w, h, true, true, true, true, false, true);
8649 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8650 sizeAnchor.isClientW,
8651 sizeAnchor.isClientH
8658 property_category $"Layout"
8661 Anchor thisAnchor = anchor;
8662 SizeAnchor thisSizeAnchor = sizeAnchor;
8663 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8664 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8665 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8666 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8667 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8668 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8674 sizeAnchor.isClientW = false;
8675 sizeAnchor.isClientH = false;
8676 sizeAnchor.size = value;
8678 normalSizeAnchor = sizeAnchor;
8680 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8682 stateAnchor = normalAnchor;
8683 stateSizeAnchor = normalSizeAnchor;
8685 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8686 Position(x, y, w, h, true, true, true, true, false, true);
8687 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8690 get { value = size; }
8693 property Size clientSize
8695 property_category $"Layout"
8698 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8699 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8700 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8705 sizeAnchor.isClientW = true;
8706 sizeAnchor.isClientH = true;
8707 sizeAnchor.size = value;
8709 normalSizeAnchor = sizeAnchor;
8711 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8713 stateAnchor = normalAnchor;
8714 stateSizeAnchor = normalSizeAnchor;
8716 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8717 Position(x,y, w, h, true, true, true, true, false, true);
8720 get { value = clientSize; }
8723 property Size initSize { get { value = sizeAnchor.size; } };
8725 property Anchor anchor
8727 property_category $"Layout"
8728 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8734 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8736 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8737 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8739 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8741 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8742 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8746 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8748 anchor.left.distance = 0;
8749 anchor.horz.type = 0;
8751 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8753 anchor.top.distance = 0;
8754 anchor.vert.type = 0;
8763 normalAnchor = anchor;
8765 // Break the anchors for moveable/resizable windows
8766 /*if(style.fixed ) //&& value.left.type == cascade)
8768 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8770 this.anchor = normalAnchor = Anchor { left = x, top = y };
8771 normalSizeAnchor = SizeAnchor { { w, h } };
8774 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8776 stateAnchor = normalAnchor;
8777 stateSizeAnchor = normalSizeAnchor;
8779 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8780 Position(x, y, w, h, true, true, true, true, false, true);
8789 get { value = this ? anchor : Anchor { }; }
8792 property Point position
8794 property_category $"Layout"
8797 if(value == null) return;
8799 anchor.left = value.x;
8800 anchor.top = value.y;
8801 anchor.right.type = none;
8802 anchor.bottom.type = none;
8807 normalAnchor = anchor;
8809 // Break the anchors for moveable/resizable windows
8813 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8815 normalAnchor.left = x;
8816 normalAnchor.top = y;
8817 normalAnchor.right.type = none;
8818 normalAnchor.bottom.type = none;
8819 normalSizeAnchor.size.width = w;
8820 normalSizeAnchor.size.height = h;
8824 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8826 stateAnchor = normalAnchor;
8827 stateSizeAnchor = normalSizeAnchor;
8829 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8830 Position(x,y, w, h, true, true, true, true, false, true);
8834 get { value = position; }
8837 property bool disabled
8839 property_category $"Behavior"
8842 if(this && disabled != value)
8849 get { return (bool)disabled; }
8852 property bool isEnabled
8857 for(parent = this; parent; parent = parent.parent)
8864 property WindowState state
8866 property_category $"Behavior"
8867 set { SetState(value, false, 0); }
8868 get { return this ? state : 0; }
8871 property bool visible
8873 property_category $"Behavior"
8876 if(this && !value && !style.hidden && parent)
8878 bool wasActiveChild = parent.activeChild == this;
8879 Window client = null;
8881 style.hidden = true;
8882 if(style.isActiveClient)
8884 parent.numPositions--;
8885 if(state == minimized) parent.numIcons--;
8890 OldLink prevOrder = null;
8892 if(rootWindow == this)
8893 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8896 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8899 box.left -= parent.clientStart.x;
8900 box.top -= parent.clientStart.y;
8901 box.right -= parent.clientStart.x;
8902 box.bottom -= parent.clientStart.y;
8906 if(_isModal && master && master.modalSlave == this)
8907 master.modalSlave = null;
8911 OldLink tmpPrev = order.prev;
8912 client = tmpPrev ? tmpPrev.data : null;
8913 if(client && !client.style.hidden && !client.destroyed && client.created)
8914 prevOrder = tmpPrev;
8917 client = tmpPrev ? tmpPrev.data : null;
8918 if(client == this) { client = null; break; }
8919 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8921 tmpPrev = client.order.prev;
8926 prevOrder = tmpPrev;
8931 // If this window can be an active client, make sure the next window we activate can also be one
8932 if(!style.nonClient && style.isActiveClient)
8934 tmpPrev = prevOrder;
8937 client = tmpPrev ? tmpPrev.data : null;
8938 if(client == this) { client = null; break; }
8939 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8941 tmpPrev = client.order.prev;
8946 prevOrder = tmpPrev;
8950 if(client && client.style.hidden) client = null;
8954 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8956 if(order && prevOrder && prevOrder.data != this)
8957 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8959 ActivateEx(false, false, false, true, null, null);
8961 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8962 if(parent.activeClient == this)
8964 parent.activeClient = null;
8965 parent.UpdateActiveDocument(null);
8968 else if(parent.activeClient == this)
8970 parent.activeClient = client;
8971 parent.UpdateActiveDocument(this);
8974 // *** Not doing this anymore ***
8977 parent.childrenCycle.Delete(cycle);
8979 parent.childrenOrder.Delete(order);
8984 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8989 else if(this && value && style.hidden)
8991 style.hidden = false;
8994 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8995 if(rootWindow == this)
8996 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8998 if(_isModal && master)
8999 master.modalSlave = this;
9001 if(style.isActiveClient)
9003 positionID = parent.GetPositionID(this);
9004 parent.numPositions++;
9005 if(state == minimized) parent.numIcons++;
9008 // *** NOT DOING THIS ANYMORE ***
9010 if(!(style.inactive))
9012 if(!(style.noCycle))
9014 cycle = parent.childrenCycle.AddAfter(
9015 (parent.activeChild && parent.activeChild.cycle) ?
9016 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9019 order = parent.childrenOrder.AddAfter(
9020 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9027 if(true || !parent.activeChild)
9028 ActivateEx(true, false, true, true, null, null);
9030 if(creationActivation == activate)
9031 ActivateEx(true, false, true, true, null, null);
9032 else if(creationActivation == flash && !object)
9035 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9039 ConsequentialMouseMove(false);
9045 style.hidden = !value;
9048 get { return (style.hidden || !setVisible) ? false : true; }
9051 property bool isDocument
9053 property_category $"Document"
9054 set { style.isDocument = value; }
9055 get { return style.isDocument; }
9058 property bool mergeMenus
9060 property_category $"Window Style"
9061 set { mergeMenus = value; }
9062 get { return (bool)mergeMenus; }
9065 property bool hasHorzScroll
9067 property_category $"Window Style"
9072 if(!style.hasHorzScroll && created)
9074 CreateSystemChildren();
9075 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9078 else if(style.hasHorzScroll)
9082 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9084 style.hasHorzScroll = value;
9087 get { return style.hasHorzScroll; }
9090 property bool hasVertScroll
9092 property_category $"Window Style"
9097 if(!style.hasVertScroll && created)
9099 style.hasVertScroll = true;
9100 CreateSystemChildren();
9101 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9104 else if(style.hasVertScroll)
9108 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9110 style.hasVertScroll = value;
9112 get { return style.hasVertScroll; }
9115 property bool dontHideScroll
9117 property_category $"Behavior"
9120 scrollFlags.dontHide = value;
9123 //UpdateScrollBars(true, true);
9124 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9128 // UpdateScrollBars(true, true);
9129 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9132 get { return scrollFlags.dontHide; }
9135 property bool dontScrollVert
9137 property_category $"Behavior"
9138 set { style.dontScrollVert = value; }
9139 get { return style.dontScrollVert; }
9141 property bool dontScrollHorz
9143 property_category $"Behavior"
9144 set { style.dontScrollHorz = value; }
9145 get { return style.dontScrollHorz; }
9148 property bool snapVertScroll
9150 property_category $"Behavior"
9153 scrollFlags.snapY = value;
9154 if(sbv) sbv.snap = value;
9156 get { return scrollFlags.snapY; }
9158 property bool snapHorzScroll
9160 property_category $"Behavior"
9163 scrollFlags.snapX = value;
9164 if(sbh) sbh.snap = value;
9166 get { return scrollFlags.snapX; }
9169 property Point scroll
9171 property_category $"Behavior"
9172 set { SetScrollPosition(value.x, value.y); }
9173 get { value = scroll; }
9176 property bool modifyVirtualArea
9178 property_category $"Behavior"
9179 set { modifyVirtArea = value; }
9180 get { return (bool)modifyVirtArea; }
9183 property bool dontAutoScrollArea
9185 property_category $"Behavior"
9186 // Activating a child control out of view will automatically scroll to make it in view
9187 set { noAutoScrollArea = value; }
9188 get { return (bool)noAutoScrollArea; }
9191 property char * fileName
9193 property_category $"Document"
9196 if(menu && ((!fileName && value) || (fileName && !value)))
9198 MenuItem item = menu.FindItem(MenuFileSave, 0);
9199 if(item) item.disabled = !modifiedDocument && value;
9204 if(value && value[0])
9205 fileName = CopyString(value);
9207 if(parent && this == parent.activeClient)
9208 parent.UpdateActiveDocument(null);
9212 // if(style.isDocument)
9214 fileMonitor.fileName = value;
9216 get { return fileName; }
9221 property_category $"Data"
9226 property bool modifiedDocument
9228 property_category $"Document"
9231 if(style.isDocument || fileName)
9235 MenuItem item = menu.FindItem(MenuFileSave, 0);
9236 if(item) item.disabled = !value && fileName;
9240 if(modifiedDocument != value)
9242 modifiedDocument = value;
9243 if(style.isDocument || fileName)
9247 get { return (bool)modifiedDocument; }
9250 property bool showInTaskBar
9252 property_category $"Window Style"
9253 set { style.showInTaskBar = value; }
9254 get { return (style.showInTaskBar; }
9256 property FileDialog saveDialog { set { saveDialog = value; } };
9257 property bool isActiveClient
9259 property_category $"Behavior"
9260 set { style.isActiveClient = value; }
9261 get { return style.isActiveClient; }
9264 property Cursor cursor
9266 property_category $"Appearance"
9270 SelectMouseCursor();
9272 get { return cursor; }
9275 //#if !defined(ECERE_VANILLA)
9276 property char * name
9278 property_category $"Design"
9281 return (this && object) ? object.name : null;
9286 activeDesigner.RenameObject(object, value);
9290 property char * displayDriver
9292 property_category $"Behavior"
9295 dispDriver = GetDisplayDriver(value);
9296 //DisplayModeChanged();
9300 return dispDriver ? dispDriver.name : null;
9304 // RUNTIME PROPERTIES
9305 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9306 property Size scrollArea
9308 property_category $"Behavior"
9312 SetScrollArea(value.w, value.h, false);
9314 SetScrollArea(0,0, true);
9316 get { value = scrollArea; }
9319 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9324 property_category $"Layout"
9325 set { if(this) is3D = value; }
9326 get { return (bool)is3D; }
9329 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9331 // Will be merged with font later
9332 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9333 property Point clientStart { get { value = clientStart; } };
9334 property Point absPosition { get { value = absPosition; } };
9335 property Anchor normalAnchor { get {value = normalAnchor; } };
9336 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9337 property bool active { get { return (bool)active; } };
9338 property bool created { get { return (bool)created; } };
9339 property bool destroyed { get { return (bool)destroyed; } };
9340 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9341 property Window firstChild { get { return children.first; } };
9342 property Window lastChild { get { return children.last; } };
9343 property Window activeClient { get { return activeClient; } };
9344 property Window activeChild { get { return activeChild; } };
9345 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9346 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9347 property ScrollBar horzScroll { get { return sbh; } };
9348 property ScrollBar vertScroll { get { return sbv; } };
9349 property StatusBar statusBar { get { return statusBar; } };
9350 property Window rootWindow { get { return rootWindow; } };
9351 property bool closing { get { return (bool)closing; } set { closing = value; } };
9352 property int documentID { get { return documentID; } };
9353 property Window previous { get { return prev; } }
9354 property Window next { get { return next; } }
9355 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9356 property PopupMenu menuBar { get { return menuBar; } }
9357 property ScrollBar sbv { get { return sbv; } }
9358 property ScrollBar sbh { get { return sbh; } }
9359 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9360 property void * systemHandle { get { return windowHandle; } }
9361 property Button minimizeButton { get { return sysButtons[0]; } };
9362 property Button maximizeButton { get { return sysButtons[1]; } };
9363 property Button closeButton { get { return sysButtons[2]; } };
9364 property BitmapResource icon
9366 get { return icon; }
9370 if(icon) incref icon;
9372 guiApp.interfaceDriver.SetIcon(this, value);
9375 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9376 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9377 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9378 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9379 property bool nativeDecorations
9381 get { return (bool)nativeDecorations; }
9382 set { nativeDecorations = value; }
9383 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9386 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9387 bool result = false;
9388 if(nativeDecorations)
9390 if(rootWindow == this)
9394 if(formDesigner && activeDesigner)
9396 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9397 Window form = cd ? cd.form : null;
9398 if(form && parent == form.parent)
9403 return result != style.fixed;
9407 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9409 property char * text
9411 property_category $"Deprecated"
9413 set { property::caption = value; }
9414 get { return property::caption; }
9420 WindowBits style; // Window Style
9421 char * caption; // Name / Caption
9422 Window parent; // Parent window
9423 OldList children; // List of children in Z order
9424 Window activeChild; // Child window having focus
9425 Window activeClient;
9426 Window previousActive; // Child active prior to activating the default child
9427 Window master; // Window owning and receiving notifications concerning this window
9428 OldList slaves; // List of windows belonging to this window
9429 Display display; // Display this window is drawn into
9431 Point position; // Position in parent window client area
9432 Point absPosition; // Absolute position
9433 Point clientStart; // Client area position from (0,0) in this window
9435 Size clientSize; // Client area size
9436 Size scrollArea; // Virtual Scroll area size
9437 Size reqScrollArea; // Requested virtual area size
9438 Point scroll; // Virtual area scrolling position
9439 ScrollBar sbh, sbv; // Scrollbar window handles
9440 Cursor cursor; // Mouse cursor used for this window
9443 StatusBar statusBar;
9444 Button sysButtons[3];
9446 Box clientArea; // Client Area box clipped to parent
9448 HotKeySlot hotKey; // HotKey for this window
9452 ScrollFlags scrollFlags;// Window Scrollbar Flags
9453 int64 id; // Control ID
9455 ColorAlpha background; // Background color used to draw the window area
9457 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9458 OldList childrenCycle; // Cycling order
9459 OldLink cycle; // Element of parent's cycling order
9460 OldList childrenOrder; // Circular Z-Order
9461 OldLink order; // Element of parent's circular Z-Order
9462 Window modalSlave; // Slave window blocking this window's interaction
9464 Window rootWindow; // Topmost system managed window
9465 void * windowHandle; // System window handle
9467 DialogResult returnCode;// Return code for modal windows
9469 Point sbStep; // Scrollbar line scrolling steps
9472 SizeAnchor stateSizeAnchor;
9474 Anchor normalAnchor;
9475 SizeAnchor normalSizeAnchor;
9477 Size skinMinSize; // Minimal window size based on style
9478 Point scrolledPos; // Scrolled position
9479 Box box; // Window box clipped to parent
9480 Box * against; // What to clip the box to
9482 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9483 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9484 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9485 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9486 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9487 Point scrolledArea; // Distance to scroll area by
9488 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9490 OldList hotKeys; // List of the hotkeys of all children
9491 Window defaultControl; // Default child control
9495 ColorAlpha * palette; // Color palette used for this window
9497 int caretSize; // Size of caret, non zero if a caret is present
9498 Point caretPos; // Caret position
9500 void * systemParent; // Parent System Window for embedded windows
9507 WindowState lastState;
9509 FileMonitor fileMonitor
9511 this, FileChange { modified = true };
9513 bool OnFileNotify(FileChange action, char * param)
9516 fileMonitor.StopMonitoring();
9517 if(OnFileModified(action, param))
9518 fileMonitor.StartMonitoring();
9523 FontResource setFont, systemFont;
9524 FontResource usedFont;
9525 FontResource captionFont;
9527 FileDialog saveDialog;
9529 SizeAnchor sizeAnchor;
9531 // FormDesigner data
9534 Extent * tempExtents; //[4];
9535 BitmapResource icon;
9537 CreationActivationOption creationActivation;
9540 bool active:1; // true if window and ancestors are active
9541 bool acquiredInput:1; // true if the window is processing state based input
9542 bool modifiedDocument:1;
9543 bool disabled:1; // true if window cannot interact
9544 bool isForegroundWindow:1;// true while a root window is being activated
9545 bool visible:1; // Visibility flag
9546 bool destroyed:1; // true if window is being destroyed
9547 bool anchored:1; // true if this window is repositioned when the parent resizes
9548 bool dirty:1; // Flag set to true if any descendant must be redrawn
9554 bool modifyVirtArea:1;
9555 bool noAutoScrollArea:1;
9558 bool setVisible:1; // FOR FORM DESIGNER
9564 bool useSharedMemory:1;
9567 bool nativeDecorations:1;
9568 bool manageDisplay:1;
9569 bool formDesigner:1; // True if we this is running in the form editor
9572 // Checks used internally for them not to take effect in FormDesigner
9573 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9574 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9576 WindowController controller;
9577 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9580 public class CommonControl : Window
9582 // creationActivation = doNothing;
9585 public property String toolTip
9587 property_category $"Appearance"
9590 if(created) CommonControl::OnDestroy();
9592 toolTip = value ? ToolTip { tip = value; } : null;
9594 if(created) CommonControl::OnCreate();
9596 get { return toolTip ? toolTip.tip : null; }
9602 // (Very) Ugly work around for the fact that the parent watcher
9603 // won't fire when it's already been disconnected...
9604 eInstance_FireSelfWatchers(toolTip,
9605 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9611 toolTip.parent = this;
9620 public class Percentage : float
9622 char * OnGetString(char * string, float * fieldData, bool * needClass)
9626 sprintf(string, "%.2f", this);
9627 c = strlen(string)-1;
9630 if(string[c] != '0')
9631 last = Max(last, c);
9632 if(string[c] == '.')
9645 public void ApplySkin(Class c, char * name, void ** vTbl)
9647 char className[1024];
9652 subclass(Window) wc = (subclass(Window))c;
9653 subclass(Window) base = (subclass(Window))c.base;
9655 sprintf(className, "%sSkin_%s", name, c.name);
9656 wc.pureVTbl = c._vTbl;
9657 c._vTbl = new void *[c.vTblSize];
9658 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9659 sc = eSystem_FindClass(c.module.application, className);
9663 for(m = 0; m < c.base.vTblSize; m++)
9665 if(c._vTbl[m] == base.pureVTbl[m])
9666 c._vTbl[m] = vTbl[m];
9671 for(m = 0; m < c.vTblSize; m++)
9673 if(sc._vTbl[m] != wc.pureVTbl[m])
9674 c._vTbl[m] = sc._vTbl[m];
9678 for(d = c.derivatives.first; d; d = d.next)
9680 ApplySkin(d.data, name, c._vTbl);
9684 public void UnapplySkin(Class c)
9686 char className[1024];
9688 subclass(Window) wc = (subclass(Window))c;
9689 subclass(Window) base = (subclass(Window))c.base;
9692 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9695 c._vTbl = wc.pureVTbl;
9699 for(d = c.derivatives.first; d; d = d.next)
9701 UnapplySkin(d.data);
9705 void CheckFontIntegrity(Window window)
9710 if(window.usedFont && window.usedFont.font == 0xecececec)
9712 FontResource uf = window.usedFont;
9713 char * className = window._class.name;
9714 char * text = window.text;
9717 for(c = window.firstChild; c; c = c.next)
9718 CheckFontIntegrity(c);
9722 public class ControllableWindow : Window
9724 /*WindowController controller;
9725 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9726 ~ControllableWindow() { delete controller; }*/
9729 class WindowControllerInterface : ControllableWindow
9731 bool OnKeyDown(Key key, unichar ch)
9733 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9735 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9739 bool OnKeyUp(Key key, unichar ch)
9741 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9743 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9747 bool OnKeyHit(Key key, unichar ch)
9749 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9751 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9755 bool OnMouseMove(int x, int y, Modifiers mods)
9757 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9759 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9763 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9765 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9767 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9771 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9773 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9775 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9779 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9781 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9783 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9787 bool OnRightButtonDown(int x, int y, Modifiers mods)
9789 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9791 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9795 bool OnRightButtonUp(int x, int y, Modifiers mods)
9797 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9799 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9803 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9805 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9807 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9811 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9813 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9815 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9819 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9821 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9823 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9827 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9829 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9831 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9835 void OnResize(int width, int height)
9837 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9838 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9841 void OnRedraw(Surface surface)
9843 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9844 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9849 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9851 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9855 bool OnLoadGraphics()
9857 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9859 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9863 void OnUnloadGraphics()
9865 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9866 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9870 public class WindowController<class V>
9873 property Window window
9877 uint size = class(Window).vTblSize;
9880 windowVTbl = new void *[size];
9881 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9882 if(value._vTbl == value._class._vTbl)
9884 value._vTbl = new void *[value._class.vTblSize];
9885 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9889 for(c = 0; c < size; c++)
9891 void * function = class(WindowControllerInterface)._vTbl[c];
9892 if(function != DefaultFunction)
9893 value._vTbl[c] = function;
9895 value._vTbl[c] = windowVTbl[c];
9900 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9903 get { return window; }
9905 property V controlled
9907 set { controlled = value; }
9908 get { return controlled; }
9910 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9911 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9912 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9913 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9914 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9915 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9916 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9917 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9918 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9919 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9920 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9921 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9922 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9923 virtual void V::OnResize(WindowController controller, int width, int height);
9924 virtual void V::OnRedraw(WindowController controller, Surface surface);
9925 virtual bool V::OnCreate(WindowController controller);
9926 virtual bool V::OnLoadGraphics(WindowController controller);
9927 virtual void V::OnUnloadGraphics(WindowController controller);
9930 int (** windowVTbl)();