7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
573 stopwatching(parent, font);
574 if(parent.activeChild == this)
575 parent.activeChild = null;
576 if(parent.activeClient == this)
577 parent.activeClient = null;
582 // Prevent destructor from being called again...
588 /////////////////////////////////
591 OldLink slave = master.slaves.FindLink(this);
592 master.slaves.Delete(slave);
599 parent.childrenCycle.Remove(cycle);
601 parent.childrenOrder.Remove(order);
602 parent.children.Remove(this);
607 /////////////////////////////////
609 while(ptr = resources.first)
612 resources.Delete(ptr);
619 for(child = children.first; child; child = child.next)
621 // child.stopwatching(this, font);
623 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
624 // Don't want property here
625 *&child.parent = null;
628 while(slave = slaves.first)
630 // Don't want property here
631 *&((Window)slave.data).master = null;
632 slaves.Delete(slave);
635 // Because we do a decref in DestroyEx...
643 // Why was this commented?
644 //if(this != guiApp.desktop)
657 if(((subclass(Window))_class).pureVTbl)
659 if(_vTbl == _class._vTbl)
661 _vTbl = ((subclass(Window))_class).pureVTbl;
666 for(m = 0; m < _class.vTblSize; m++)
668 if(_vTbl[m] == _class._vTbl[m])
669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
673 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
676 dirtyArea.Free(null);
677 renderArea.Free(null);
678 overRenderArea.Free(null);
679 clipExtent.Free(null);
680 scrollExtent.Free(null);
681 dirtyBack.Free(null);
685 tempExtents[0].Free(null);
686 tempExtents[1].Free(null);
687 tempExtents[2].Free(null);
688 tempExtents[3].Free(null);
693 //#if !defined(ECERE_VANILLA)
694 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
696 if(this == activeDesigner)
700 char * name = property::name;
701 return name ? name : "";
706 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
707 bool OnGetDataFromString(char * string)
709 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
712 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
713 this = designer.form;
714 else if(!strcmpi(string, "(Desktop)"))
715 this = activeDesigner;
717 return activeDesigner.FindObject(&this, string);
723 // --- Window updates system ---
725 // Setup a bitmap for Redrawing on client area of Window
726 Surface Redraw(Box box)
728 Surface surface = null;
730 Box clientArea = this.clientArea;
734 mox.left -= clientStart.x;
735 mox.top -= clientStart.y;
736 mox.right -= clientStart.x;
737 mox.bottom -= clientStart.y;
739 mox.Clip(clientArea);
740 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
742 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
744 int x = absPosition.x + clientStart.x;
745 int y = absPosition.y + clientStart.y;
746 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
748 x -= rootWindow.clientStart.x;
749 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
751 if(!guiApp.fullScreenMode || is3D)
753 x -= rootWindow.absPosition.x;
754 y -= rootWindow.absPosition.y;
758 x += rootWindow.parent.clientStart.x;
759 y += rootWindow.parent.clientStart.y;
761 mox.left += rootWindow.parent.clientStart.x;
762 mox.top += rootWindow.parent.clientStart.y;
763 mox.right += rootWindow.parent.clientStart.x;
764 mox.bottom += rootWindow.parent.clientStart.y;
769 surface = display.GetSurface(x, y, mox);
772 surface.width = clientSize.w;
773 surface.height = clientSize.h;
779 // Setup a bitmap for Redrawing on full Window
780 Surface RedrawFull(Box box)
782 Surface surface = null;
790 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
792 int x = absPosition.x;
793 int y = absPosition.y;
794 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
796 x -= rootWindow.clientStart.x;
797 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
799 if(!guiApp.fullScreenMode || is3D)
801 x -= rootWindow.absPosition.x;
802 y -= rootWindow.absPosition.y;
805 x += rootWindow.parent.clientStart.x;
806 y += rootWindow.parent.clientStart.y;
808 mox.left += rootWindow.parent.clientStart.x;
809 mox.top += rootWindow.parent.clientStart.y;
810 mox.right += rootWindow.parent.clientStart.x;
811 mox.bottom += rootWindow.parent.clientStart.y;
816 surface = display.GetSurface(x, y, mox);
819 surface.width = size.w;
820 surface.height = size.h;
826 void FigureCaption(char * caption)
828 Window activeClient = null;
832 strcpy(caption, this.caption);
833 if(style.isDocument || fileName)
835 if(caption[0]) strcat(caption, " - ");
837 strcat(caption, fileName);
841 sprintf(title, "Untitled %d", documentID);
842 strcat(caption, title);
845 strcat(caption, " *");
850 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
852 if(activeClient && activeClient.state == maximized)
854 if(activeClient.caption)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, activeClient.caption);
859 if(activeClient.style.isDocument || activeClient.fileName)
861 if(caption[0]) strcat(caption, " - ");
862 strcat(caption, "[");
863 if(activeClient.fileName)
864 strcat(caption, activeClient.fileName);
868 sprintf(title, "Untitled %d", activeClient.documentID);
869 strcat(caption, title);
871 if(activeClient.modifiedDocument)
872 strcat(caption, " *");
873 strcat(caption, "]");
878 // Code for returning dirty from ScrollDisplay:
880 for(d = 0; d<scrollExtent.count; d++)
882 Box * box = &scrollExtent.boxes[d];
888 Min(box.right, box.left-scroll.x),box.bottom
890 dirtyArea.UnionBox(update);
896 Max(box.left, box.right-scroll.x), box.top,
897 box.right, box.bottom
899 dirtyArea.UnionBox(update);
907 box.right, Min(box.bottom, box.top-scroll.y),
909 dirtyArea.UnionBox(update);
915 box.left, Max(box.top, box.bottom-scroll.y),
916 box.right, box.bottom
918 dirtyArea.UnionBox(update);
923 void UpdateDecorations(void)
925 // TODO: *** TEMPORARY HACK ***
932 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
934 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
936 Update({ -clientStart.x,0, -1, clientSize.h-1 });
938 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
941 // Returns w & h for Position
942 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
944 Window parent = this.parent ? this.parent : guiApp.desktop;
945 int xOffset = 0, yOffset = 0;
946 int vpw = parent ? parent.clientSize.w : 0;
947 int vph = parent ? parent.clientSize.h : 0;
948 int pw = parent ? parent.clientSize.w : 0;
949 int ph = parent ? parent.clientSize.h : 0;
950 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
951 int x = anchor.left.distance, y = anchor.top.distance;
953 MinMaxValue ew = 0, eh = 0;
955 float cascadeW, cascadeH;
957 int tilingW, tilingH, tilingSplit, tilingLastH;
958 int addX = 0, addY = 0;
960 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
962 Window masterWindow = this;
963 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
966 if(master == guiApp.desktop)
967 masterWindow = guiApp.desktop.activeChild;
969 masterWindow = master.rootWindow;
970 if(!masterWindow) masterWindow = this;
972 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
973 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
976 pw = vpw = box.right - box.left + 1;
978 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
981 ph = vph = box.bottom - box.top + 1;
997 vpw = pw = parent.size.w;
998 vph = ph = parent.size.h;
1000 else if(!style.fixed /*|| style.isDocument*/)
1002 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1003 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1005 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1008 Desktop3D_FixSize(&pw, &ph);
1009 Desktop3D_FixSize(&vpw, &vph);
1012 if(pw < skinMinSize.w) pw = skinMinSize.w;
1013 if(ph < skinMinSize.h) ph = skinMinSize.h;
1014 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1015 if(vph < skinMinSize.h) vph = skinMinSize.h;
1017 // TODO: Must fix what we're snapping
1020 if(anchor.left.type)
1022 SNAPUP(x, textCellW);
1024 else if(anchor.right.type)
1026 SNAPDOWN(x, textCellW);
1031 SNAPUP(y, textCellH);
1033 else if(anchor.bottom.type)
1035 SNAPDOWN(y, textCellH);
1039 // This is required to get proper initial decoration size using native decorations on Windows
1040 #if defined(__WIN32__)
1041 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1042 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1044 GetDecorationsSize(&ew, &eh);
1046 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1048 // Leave room for non client windows (eventually dockable panels)
1050 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1051 for(win = parent.children.first; win; win = win.next)
1053 if(!win.isActiveClient && win.visible)
1055 Size size = win.size;
1056 Point pos = win.position;
1057 int left = pos.x, top = pos.y;
1058 int right = pos.x + size.w, bottom = pos.y + size.h;
1059 if(win.size.w > win.size.h)
1062 loY = Max(loY, bottom);
1063 else if(top > ph - ph / 4)
1064 hiY = Min(hiY, top);
1069 loX = Max(loX, right);
1070 else if(left > pw - pw / 4)
1071 hiX = Min(hiX, left);
1080 if(parent.sbv && !parent.sbv.style.hidden)
1081 pw += guiApp.currentSkin.VerticalSBW();
1082 if(parent.sbh && !parent.sbh.style.hidden)
1083 ph += guiApp.currentSkin.HorizontalSBH();
1085 if(anchor.left.type == cascade)
1087 w = (int)(pw * 0.80);
1088 h = (int)(ph * 0.80);
1090 else if(anchor.left.type >= vTiled)
1095 numTiling = parent.numPositions - parent.numIcons;
1096 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1097 if(anchor.left.type == vTiled)
1099 tilingH = (int)sqrt(numTiling);
1100 tilingW = numTiling / tilingH;
1104 tilingW = (int)sqrt(numTiling);
1105 tilingH = numTiling / tilingW;
1108 leftOver = numTiling - tilingH * tilingW;
1111 tilingSplit = (tilingW - leftOver) * tilingH;
1112 tilingLastH = tilingH+1;
1115 tilingSplit = numTiling;
1117 if(positionID >= tilingSplit)
1119 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1120 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1121 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1122 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1126 x = xOffset + pw * (positionID / tilingH) / tilingW;
1127 y = yOffset + ph * (positionID % tilingH) / tilingH;
1128 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1129 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1133 SNAPDOWN(x, textCellW);
1134 SNAPDOWN(y, textCellH);
1135 SNAPDOWN(x2, textCellW);
1136 SNAPDOWN(y2, textCellH);
1144 if(sizeAnchor.isClientW) w += ew;
1145 if(sizeAnchor.isClientH) h += eh;
1147 if(anchor.left.type == offset)
1148 x = anchor.left.distance;
1149 else if(anchor.left.type == relative)
1150 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1151 else if(anchor.right.type == relative)
1152 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1153 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1154 else if(anchor.right.type == offset)
1155 ex = vpw - anchor.right.distance;
1157 if(anchor.top.type == offset)
1158 y = anchor.top.distance;
1159 else if(anchor.top.type == relative)
1160 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1161 else if(anchor.bottom.type == relative)
1162 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1163 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1164 else if(anchor.bottom.type == offset)
1165 ey = vph - anchor.bottom.distance;
1167 if(anchor.left.type && anchor.right.type)
1169 switch(anchor.right.type)
1172 ex = pw * (1.0f-anchor.right.percent);
1173 w = Max((int)(ex + 0.5) - x, 0);
1176 ex = vpw - anchor.right.distance;
1177 w = Max((int)(ex + 0.5) - x, 0);
1181 if(anchor.top.type && anchor.bottom.type)
1183 switch(anchor.bottom.type)
1186 ey = ph * (1.0f-anchor.bottom.percent);
1187 h = Max((int)(ey + 0.5) - y, 0);
1190 ey = vph - anchor.bottom.distance;
1191 h = Max((int)(ey + 0.5) - y, 0);
1200 if(state == normal /*|| state == Hidden*/)
1202 bool addSbV = false, addSbH = false;
1204 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1205 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1207 w = Max(w, minSize.w);
1208 h = Max(h, minSize.h);
1209 w = Min(w, maxSize.w);
1210 h = Min(h, maxSize.h);
1212 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1214 if(w) w -= guiApp.currentSkin.VerticalSBW();
1217 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1219 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1223 if(!OnResizing(&w, &h))
1229 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1230 w += guiApp.currentSkin.VerticalSBW();
1231 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1232 h += guiApp.currentSkin.HorizontalSBH();
1234 w = Max(w, skinMinSize.w);
1235 h = Max(h, skinMinSize.h);
1248 SNAPDOWN(w, textCellW);
1249 SNAPDOWN(h, textCellH);
1252 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1254 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1257 (pw - w) / CASCADE_SPACE,
1258 (ph - h) / CASCADE_SPACE);
1264 cascW = (pw - w) / (numCascade-1);
1265 cascH = (ph - h) / (numCascade-1);
1266 SNAPDOWN(cascW, textCellW);
1267 SNAPDOWN(cascH, textCellH);
1268 cascadeW = (float)cascW;
1269 cascadeH = (float)cascH;
1273 numCascade = Max(numCascade, 2);
1274 cascadeW = (float)(pw - w) / (numCascade-1);
1275 cascadeH = (float)(ph - h) / (numCascade-1);
1278 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1279 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1281 else if(anchor.left.type < vTiled)
1283 if(!anchor.left.type || anchor.horz.type == middleRelative)
1285 if(!anchor.right.type)
1287 if(anchor.horz.type == middleRelative)
1288 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1290 x = vpw / 2 + anchor.horz.distance - w / 2;
1296 // case A_EDGE: x = x - w; break;
1298 if(!anchor.top.type || anchor.vert.type == middleRelative)
1300 if(!anchor.bottom.type)
1302 if(anchor.vert.type == middleRelative)
1303 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1305 y = vph / 2 + anchor.vert.distance - h / 2;
1311 // case A_EDGE: y = y - h; break;
1314 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1322 SNAPDOWN(x, textCellW);
1323 SNAPDOWN(y, textCellH);
1335 if(anchored && style.fixed && style.isActiveClient)
1340 void UpdateCaret(bool forceUpdate, bool erase)
1342 static Window lastWindow = null;
1343 static int caretX, caretY, caretSize;
1345 if(guiApp && guiApp.caretOwner == this)
1347 int x = caretPos.x - scroll.x;
1348 int y = caretPos.y - scroll.y;
1350 if((erase || this.caretSize) &&
1351 x >= clientArea.left && x <= clientArea.right &&
1352 y >= clientArea.top && y <= clientArea.bottom)
1356 guiApp.interfaceDriver.SetCaret(
1357 x + absPosition.x + clientStart.x,
1358 y + absPosition.y + clientStart.y, this.caretSize);
1359 guiApp.caretEnabled = true;
1361 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1365 if(lastWindow != this)
1367 updateBox.left = x + 1;
1369 updateBox.right = x + 2;
1370 updateBox.bottom = y + this.caretSize - 1;
1374 updateBox.left = Min(x + 1, caretX + 1);
1375 updateBox.top = Min(y, caretY);
1376 updateBox.right = Max(x + 2, caretX + 2);
1377 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1380 guiApp.caretOwner.Update(updateBox);
1387 caretSize = this.caretSize;
1393 guiApp.interfaceDriver.SetCaret(0,0,0);
1394 guiApp.caretEnabled = false;
1400 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1405 scrolledPos.x = position.x = x;
1406 scrolledPos.y = position.y = y;
1408 clientSize.w = size.w = w;
1409 clientSize.h = size.h = h;
1411 if(parent && !style.nonClient)
1413 //if(!style.fixed || style.isDocument)
1415 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1416 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1420 clientStart.x = clientStart.y = 0;
1422 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1424 //if(!activeClient || activeClient.state != maximized)
1425 if(!noAutoScrollArea)
1427 // Check if scroll area must be modified
1428 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1430 bool foundChild = false;
1432 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1433 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1434 for(child = children.first; child; child = child.next)
1436 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1437 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1439 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1440 w = Max(w, child.position.x + child.size.w);
1441 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1442 w = Max(w, Max(child.position.x, 0) + child.size.w);
1443 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1444 h = Max(h, child.position.y + child.size.h);
1445 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1446 h = Max(h, Max(child.position.y, 0) + child.size.h);
1451 if(foundChild && (w > cw || h > ch))
1453 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1455 int stepX = sbStep.x, stepY = sbStep.y;
1456 // Needed to make snapped down position match the skin's check of client area
1457 // against realvirtual
1460 SNAPDOWN(stepX, textCellW);
1461 SNAPDOWN(stepY, textCellH);
1462 stepX = Max(stepX, textCellW);
1463 stepY = Max(stepY, textCellH);
1465 if(scrollFlags.snapX)
1467 if(scrollFlags.snapY)
1470 reqScrollArea.w = w;
1471 reqScrollArea.h = h;
1474 else if(reqScrollArea.w || reqScrollArea.h)
1476 reqScrollArea.w = 0;
1477 reqScrollArea.h = 0;
1478 SetScrollPosition(0,0);
1483 // Automatic MDI Client Scrolling Area Adjustment
1484 if(parent && !parent.noAutoScrollArea)
1486 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1487 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1489 Window parent = this.parent;
1490 int w = parent.reqScrollArea.w;
1491 int h = parent.reqScrollArea.h;
1493 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1494 w = Max(w, position.x + size.w);
1495 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1496 w = Max(w, Max(position.x, 0) + size.w);
1497 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1498 h = Max(h, position.y + size.h);
1499 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1500 h = Max(h, Max(position.y, 0) + size.h);
1502 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1503 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1505 /*bool resize = false;
1506 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1507 // Needed to make snapped down position match the skin's check of client area
1508 // against realvirtual
1511 SNAPDOWN(stepX, textCellW);
1512 SNAPDOWN(stepY, textCellH);
1513 stepX = Max(stepX, textCellW);
1514 stepY = Max(stepY, textCellH);
1516 if(parent.scrollFlags.snapX)
1518 if(parent.scrollFlags.snapY)
1520 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1522 parent.reqScrollArea.w = w;
1523 parent.reqScrollArea.h = h;*/
1525 // parent.UpdateScrollBars(true, true);
1526 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1527 false, true, true, true, false, false);
1532 GetRidOfVirtualArea();
1536 UpdateScrollBars(modifyThisArea, false);
1537 else if(guiApp.currentSkin)
1540 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1542 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1543 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1544 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1545 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1548 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1549 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1551 absPosition = scrolledPos;
1552 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1553 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1555 if(this != guiApp.desktop && parent)
1557 absPosition.x += parent.absPosition.x;
1558 absPosition.y += parent.absPosition.y;
1559 if(!style.nonClient && this != guiApp.desktop)
1561 absPosition.x += parent.clientStart.x;
1562 absPosition.y += parent.clientStart.y;
1566 box = Box { 0, 0, size.w - 1, size.h - 1 };
1571 // Clip against parent's client area
1572 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1574 // Compute client area in this window coordinate system
1575 clientArea.left = 0;
1577 clientArea.right = clientSize.w - 1;
1578 clientArea.bottom = clientSize.h - 1;
1580 // Clip against parent's client area
1582 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1586 //absPosition.x -= parent.clientStart.x;
1587 //absPosition.y -= parent.clientStart.y;
1590 // Adjust all children
1591 for(child = children.first; child; child = child.next)
1592 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1594 UpdateCaret(false, false);
1597 void GetRidOfVirtualArea(void)
1599 if(parent && !parent.destroyed && style.fixed &&
1600 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1601 parent.reqScrollArea.w && parent.reqScrollArea.h)
1603 if(!parent.noAutoScrollArea)
1607 for(child = children.first; child; child = child.next)
1609 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1611 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1612 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1621 Window parent = this.parent;
1623 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1624 false, true, true, true, false, false);
1626 parent.SetScrollArea(0,0,true);
1627 parent.SetScrollPosition(0,0);
1633 public void ExternalPosition(int x, int y, int w, int h)
1635 Position(x, y, w, h, false, true, true, true, false, false);
1638 // (w, h): Full window size
1639 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1641 bool result = false;
1642 int oldCW = clientSize.w, oldCH = clientSize.h;
1643 bool clientResized, windowResized, windowMoved;
1645 bool realResized = size.w != w || size.h != h;
1647 // TOCHECK: This wasn't in ecere.dll
1648 //if(!parent) return true;
1649 if(destroyed) return false;
1651 windowMoved = position.x != x || position.y != y || force;
1653 // windowResized = realResized || force;
1654 windowResized = size.w != w || size.h != h || force;
1656 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1662 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1663 scrolledPos.x - parent.clientStart.x + this.box.right,
1664 scrolledPos.y - parent.clientStart.y + this.box.bottom
1670 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1675 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1677 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1678 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1679 windowResized = true;
1681 if(display && rootWindow != this)
1684 if(guiApp && guiApp.windowMoving)
1686 if(guiApp.windowMoving.style.nonClient)
1687 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1689 guiApp.windowMoving.parent.SetMouseRangeToClient();
1699 // Buttons bitmap resources crash if we do this while switching mode
1700 if(!guiApp || !guiApp.modeSwitching)
1703 // Process Anchored Children
1707 for(child = children.first; child; child = child.next)
1710 ((child.stateAnchor.left.type != offset ||
1711 child.stateAnchor.top.type != offset ||
1712 child.stateAnchor.right.type != none ||
1713 child.stateAnchor.bottom.type != none) ||
1714 child.state == maximized || child.state == minimized))
1716 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1718 // child.Position(x, y, w, h, false, true, true, true, false);
1719 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1720 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1726 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1727 //if(updateScrollBars)
1729 OnResize(clientSize.w, clientSize.h);
1731 if((clientResized || windowMoved) && created)
1732 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1734 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1736 Window master = guiApp.interimWindow.master;
1737 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1740 if(rootWindow == this && !is3D)
1744 x -= guiApp.desktop.absPosition.x;
1745 y -= guiApp.desktop.absPosition.y;
1747 //guiApp.Log("Position %s\n", caption);
1750 if(windowResized || windowMoved)
1751 if(display && !display.flags.memBackBuffer && changeRootWindow)
1752 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1754 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1755 for(child = parent.children.first; child && child != this; child = child.next)
1756 if(child.rootWindow)
1757 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1762 if(windowMoved || windowResized)
1764 display.Lock(true /*false*/);
1767 display.Position(absPosition.x, absPosition.y);
1768 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1771 // result = realResized ? display.Resize(size.w, size.h) : true;
1772 if(nativeDecorations && rootWindow.windowHandle)
1774 int w = clientSize.w, h = clientSize.h;
1775 if(hasMenuBar) h += skinMenuHeight;
1776 if(hasStatusBar) h += statusBarHeight;
1777 if(sbv && sbv.visible) w += sbv.size.w;
1778 if(sbh && sbh.visible) h += sbh.size.h;
1779 result = manageDisplay ? display.Resize(w, h) : true;
1782 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1786 else if(clientResized)
1788 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1791 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1795 if(windowMoved || windowResized)
1800 if(guiApp.driver && changeRootWindow && windowHandle)
1802 if(windowResized || windowMoved)
1803 if(!display || display.flags.memBackBuffer)
1804 guiApp.interfaceDriver.PositionRootWindow(this,
1805 x, y, w, h, windowMoved, windowResized);
1806 guiApp.interfaceDriver.UpdateRootWindow(this);
1808 for(child = children.first; child; child = child.next)
1810 if(child.is3D && child.created)
1812 // Copy Display Content
1813 child.display.displaySystem = display.displaySystem;
1814 child.display.window = display.window;
1815 child.display.current = display.current;
1816 child.display.width = display.width;
1817 child.display.height = display.height;
1818 child.display.driverData = display.driverData;
1819 child.display.mutex = null;
1830 void UpdateScrollBars(bool flag, bool fullThing)
1833 bool resizeH = false, resizeV = false;
1834 bool scrolled = false;
1835 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1836 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1838 if(destroyed) return;
1839 if(guiApp.currentSkin)
1841 MinMaxValue cw = 0, ch = 0;
1842 bool sbvVisible, sbhVisible;
1844 int positionH, positionV;
1846 // First get client area with no respect to scroll bars
1851 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1853 if(scrollFlags.dontHide)
1856 cw -= guiApp.currentSkin.VerticalSBW();
1858 ch -= guiApp.currentSkin.HorizontalSBH();
1860 // Update the scrollbar visibility
1866 sbh.disabled = rangeH <= 1;
1867 if(sbh.style.hidden)
1877 sbv.disabled = rangeV <= 1;
1878 if(sbv.style.hidden)
1886 int oldHRange = sbh ? sbh.range : 0;
1887 int oldVRange = sbv ? sbv.range : 0;
1888 // Then start off with horizontal scrollbar range
1891 positionH = sbh.thumbPosition;
1898 SBSetTotal(sbh, rvw);
1901 ch -= guiApp.currentSkin.HorizontalSBH();
1904 // Do the same for vertical scrollbar
1907 positionV = sbv.thumbPosition;
1913 SBSetTotal(sbv, rvh);
1917 cw -= guiApp.currentSkin.VerticalSBW();
1918 // Maybe we need to set the range on the horizontal scrollbar again
1926 SBSetTotal(sbh, rvw);
1927 //sbh.Action(setRange, positionH, 0);
1928 if(rangeH <= 1 && sbh.range > 1)
1930 ch -= guiApp.currentSkin.HorizontalSBH();
1936 SBSetTotal(sbv, rvh);
1938 //sbv.Action(setRange, positionV, 0);
1943 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1944 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1947 // Update the scrollbar visibility
1948 if(!scrollFlags.dontHide)
1950 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1954 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1961 if(guiApp.currentSkin)
1968 sbhVisible = sbh.style.hidden ? true : false;
1970 sbvVisible = sbv.style.hidden ? true : false;
1972 // Do our resize here
1973 if(flag && (resizeH || resizeV) && fullThing)
1975 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1980 OnResize(clientSize.w, clientSize.h);
1986 sbh.visible = sbhVisible;
1988 sbv.visible = sbvVisible;
1990 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1991 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1994 sbh.pageStep = clientSize.w;
1996 sbv.pageStep = clientSize.h;
1998 // Notify doesn't handle setRange anymore... process it here
2001 int positionH = sbh.thumbPosition;
2002 if(scroll.x != positionH)
2004 OnHScroll(setRange, positionH, 0);
2008 SNAPDOWN(positionH, textCellW);
2009 scroll.x = positionH;
2015 int seen = clientSize.w, total = reqScrollArea.w;
2018 if(scrollFlags.snapX)
2019 SNAPDOWN(seen, sbStep.x);
2021 if(!total) total = seen;
2022 range = total - seen + 1;
2024 range = Max(range, 1);
2026 if(x >= range) x = range - 1;
2028 if(scrollFlags.snapX)
2029 SNAPUP(x, sbStep.x);
2033 OnHScroll(setRange, x, 0);
2038 SNAPDOWN(x, textCellW);
2044 int positionV = sbv.thumbPosition;
2045 if(scroll.y != positionV)
2047 OnVScroll(setRange, positionV, 0);
2051 SNAPDOWN(positionV, textCellH);
2052 scroll.y = positionV;
2058 int seen = clientSize.h, total = reqScrollArea.h;
2061 if(scrollFlags.snapY)
2062 SNAPDOWN(seen, sbStep.y);
2064 if(!total) total = seen;
2065 range = total - seen + 1;
2066 range = Max(range, 1);
2068 if(y >= range) y = range - 1;
2070 if(scrollFlags.snapY)
2071 SNAPUP(y, sbStep.y);
2075 OnVScroll(setRange, y, 0);
2080 SNAPDOWN(y, textCellH);
2086 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2089 for(child = children.first; child; child = child.next)
2091 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2094 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2095 child.Position(x, y, w, h, false, true, false, true, false, false);
2102 // Process Scrollbars
2104 if(sbh) // && !sbh.style.hidden
2107 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2108 // Need to set the range again (should improve...) since the scrollbars didn't have
2109 // the right size when UpdateScrollArea set the range on it
2112 sbh.seen = clientSize.w;
2116 if(sbv) // && !sbv.state.hidden
2119 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2120 // Need to set the range again (should improve...) since the scrollbars didn't have
2121 // the right size when UpdateScrollArea set the range on it
2124 sbv.seen = clientSize.h;
2129 // TESTING THIS LOWER
2130 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2133 for(child = children.first; child; child = child.next)
2135 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2138 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2139 child.Position(x, y, w, h, false, true, false, true, false, false);
2145 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2147 SetState(maximized, false, mods);
2151 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2153 SetState(normal, false, mods);
2157 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2159 SetState(minimized, false, mods);
2160 parent.CycleChildren(false, true, false, true);
2164 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2167 // Scroll bar notifications
2168 if(action != setRange)
2170 bool changed = false;
2174 if(scroll.x != position)
2176 OnHScroll(action, position, keyFlags);
2181 SNAPDOWN(position, textCellW);
2183 scroll.x = position;
2187 if(scroll.y != position)
2189 OnVScroll(action, position, keyFlags);
2194 SNAPDOWN(position, textCellH);
2196 scroll.y = position;
2200 bool childMove = false;
2201 for(child = children.first; child; child = child.next)
2203 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2206 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2207 child.Position(x, y, w, h, false, true, false, true, false, false);
2211 // Testing this patch out to solve MDI workspace redraw bugs
2212 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2213 // Scroll offsets to blame?
2217 UpdateCaret(false, false);
2221 // Testing this patch out to solve MDI workspace redraw bugs
2222 for(child = children.first; child; child = child.next)
2224 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2233 Window GetParentMenuBar()
2235 Window menuBarParent;
2236 if(formDesigner) return null;
2237 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2239 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2240 if(menuBarParent && !menuBarParent.isActiveClient)
2246 void CreateSystemChildren(void)
2248 Window parent = this;
2249 bool scrollBarChanged = false;
2250 bool hasClose = false, hasMaxMin = false;
2251 Point scroll = this.scroll;
2253 if(state == maximized)
2255 parent = GetParentMenuBar();
2262 if(style.hasClose) hasClose = true;
2263 if(style.hasMaximize || style.hasMinimize)
2270 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2272 sysButtons[2].Destroy(0);
2273 sysButtons[2] = null;
2275 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2277 sysButtons[1].Destroy(0);
2278 sysButtons[1] = null;
2280 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2282 sysButtons[0].Destroy(0);
2283 sysButtons[0] = null;
2286 if(hasClose && parent)
2293 parent, master = this,
2294 inactive = true, nonClient = true, visible = false;
2296 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2302 if(this.parent == guiApp.desktop)
2303 sysButtons[2].hotKey = altF4;
2304 else if(style.isActiveClient)
2305 sysButtons[2].hotKey = ctrlF4;
2306 sysButtons[2].Create();
2309 sysButtons[2].symbol = 'X';
2310 sysButtons[2].disabled = !style.hasClose;
2313 if(hasMaxMin && parent)
2317 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2318 if(state == maximized)
2321 method = RestoreButtonClicked;
2327 method = MaximizeButtonClicked;
2335 parent, master = this,
2336 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2338 sysButtons[1].Create();
2340 sysButtons[1].NotifyClicked = method;
2342 sysButtons[1].symbol = symbol;
2343 sysButtons[1].disabled = !style.hasMaximize;
2346 if(hasMaxMin && parent)
2350 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2351 if (state == minimized)
2354 method = RestoreButtonClicked;
2360 method = MinimizeButtonClicked;
2368 parent, master = this,
2369 hotKey = altM, inactive = true, nonClient = true, visible = false
2371 sysButtons[0].Create();
2373 sysButtons[0].NotifyClicked = method;
2375 sysButtons[0].symbol = symbol;
2376 sysButtons[0].disabled = !style.hasMinimize;
2379 // Create the scrollbars
2380 if(style.hasHorzScroll && !sbh)
2386 direction = horizontal,
2390 snap = scrollFlags.snapX,
2391 NotifyScrolling = ScrollBarNotification
2394 scrollBarChanged = true;
2396 else if(sbh && !style.hasHorzScroll)
2402 if(style.hasVertScroll && !sbv)
2408 direction = vertical,
2412 snap = scrollFlags.snapY,
2413 NotifyScrolling = ScrollBarNotification
2416 scrollBarChanged = true;
2418 else if(sbv && !style.hasVertScroll)
2423 if(scrollBarChanged)
2425 SetScrollLineStep(sbStep.x, sbStep.y);
2426 UpdateScrollBars(true, true);
2430 if(scrollBarChanged)
2432 if(sbh) sbh.thumbPosition = scroll.x;
2433 if(sbv) sbv.thumbPosition = scroll.y;
2437 void UpdateCaption(void)
2439 if(rootWindow == this)
2442 FigureCaption(caption);
2443 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2445 UpdateDecorations();
2448 if(parent.activeClient == this) // Added this last check
2450 if(parent.rootWindow == parent)
2453 parent.FigureCaption(caption);
2454 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2457 parent.UpdateCaption();
2459 parent.UpdateDecorations();
2463 void UpdateActiveDocument(Window previous)
2465 Window activeClient = this.activeClient;
2466 Window activeChild = this.activeChild;
2473 activeClient.CreateSystemChildren();
2475 previous.CreateSystemChildren();
2487 // Build window list
2490 Menu windowMenu = menu.FindMenu("Window");
2495 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2498 Window document = cycle.data;
2499 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2501 char name[2048], caption[2048];
2502 document.FigureCaption(caption);
2503 sprintf(name, "%d %s", id+1, caption);
2504 windowMenu.AddDynamic(MenuItem
2506 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2507 NotifySelect = MenuWindowSelectWindow
2511 if(activeClient.cycle == cycle) break;
2516 if((!previous && activeClient) || !activeClient)
2522 item = menu.FindItem(MenuWindowCloseAll, 0);
2523 if(item) item.disabled = false;
2524 item = menu.FindItem(MenuWindowNext, 0);
2525 if(item) item.disabled = false;
2526 item = menu.FindItem(MenuWindowPrevious, 0);
2527 if(item) item.disabled = false;
2528 item = menu.FindItem(MenuWindowCascade, 0);
2529 if(item) item.disabled = false;
2530 item = menu.FindItem(MenuWindowTileHorz, 0);
2531 if(item) item.disabled = false;
2532 item = menu.FindItem(MenuWindowTileVert, 0);
2533 if(item) item.disabled = false;
2534 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2535 if(item) item.disabled = false;
2536 item = menu.FindItem(MenuWindowWindows, 0);
2537 if(item) item.disabled = false;
2540 item = menu.FindItem(MenuFileClose, 0);
2541 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2542 item = menu.FindItem(MenuFileSaveAll, 0);
2543 if(item) item.disabled = numDocuments < 1;
2545 if(activeClient && activeClient.menu && activeClient.state != minimized)
2549 //activeClient.menu.Clean(activeClient);
2550 menu.Merge(activeClient.menu, true, activeClient);
2554 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2557 menu.Merge(activeChild.menu, true, activeChild);
2560 // This is called again for a child window change, with same active client
2561 OnActivateClient(activeClient, previous);
2562 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2563 parent.UpdateActiveDocument(null);
2566 void _ShowDecorations(Box box, bool post)
2568 if(rootWindow == this && nativeDecorations) return;
2569 if(visible && this != guiApp.desktop)
2571 Surface surface = RedrawFull(box);
2575 FigureCaption(caption);
2578 ShowDecorations(captionFont.font,
2581 active, //parent.activeClient == this
2582 guiApp.windowMoving == this);
2584 PreShowDecorations(captionFont.font,
2587 active, //parent.activeClient == this
2588 guiApp.windowMoving == this);
2595 void UpdateExtent(Box refresh)
2597 Surface surface = null;
2599 if(!manageDisplay) { OnRedraw(null);return; }
2600 _ShowDecorations(refresh, false);
2602 surface = Redraw(refresh);
2603 // Opaque background: just fill before EW_REDRAW (clear?)
2606 surface.SetBackground(background);
2607 surface.SetForeground(foreground);
2608 surface.DrawingChar(' ');
2609 if(this == rootWindow)
2611 if(style.drawBehind || background.a)
2613 int a = background.a;
2614 // Premultiply alpha for clear color
2615 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2616 surface.Clear(colorBuffer);
2617 surface.SetBackground(background);
2620 else if(background.a)
2624 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2625 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2628 if(display.flags.alpha && background.a < 255 && background)
2630 surface.Area(0,0,clientSize.w, clientSize.h);
2631 /*if(style.clearDepthBuffer)
2632 surface.Clear(depthBuffer);*/
2634 else if(/*style.clearDepthBuffer || */background.a)
2636 int a = background.a;
2637 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2638 // Premultiply alpha for clear color
2639 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2640 surface.Clear(colorBuffer);
2641 surface.SetBackground(background);
2646 surface.TextFont(usedFont.font);
2647 surface.TextOpacity(false);
2651 // Draw the caret ...
2652 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2654 // surface.SetBackground(0xFFFFFF - background.color);
2655 surface.SetBackground(~background.color);
2657 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2658 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2664 void DrawOverChildren(Box refresh)
2666 Surface surface = Redraw(refresh);
2670 surface.DrawingChar(' ');
2671 surface.SetBackground(background);
2672 surface.SetForeground(foreground);
2674 surface.TextFont(usedFont.font);
2675 surface.TextOpacity(false);
2677 OnDrawOverChildren(surface);
2682 _ShowDecorations(refresh, true);
2685 void ComputeClipExtents(void)
2688 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2690 clipExtent.Copy(this.clipExtent);
2692 for(child = children.last; child; child = child.prev)
2694 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2696 bool opaque = child.IsOpaque(); // TODO: acess background directly
2697 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2699 child.clipExtent.Copy(clipExtent);
2700 child.clipExtent.Offset(-dx, -dy);
2701 child.clipExtent.IntersectBox(child.box);
2703 child.ComputeClipExtents();
2705 if(opaque && !child.style.nonClient)
2707 // Adjust the box for the parent:
2708 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2709 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2714 // ??? Only do this for overlapped window or if parent has with clip children flag
2716 // Do this if window has clip children flag on (default false?)
2717 // this.clipExtent = clipExtent;
2719 clipExtent.Free(null);
2722 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2724 bool opaque = IsOpaque();
2726 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2727 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2729 offsetX -= rootWindow.clientStart.x;
2730 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2734 for(child = children.last; child; child = child.prev)
2736 ColorAlpha background = *(ColorAlpha *)&child.background;
2737 bool opaque = child.IsOpaque();
2738 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2742 // Adjust renderArea to the root window level
2743 Extent * renderArea = &rootWindow.tempExtents[3];
2745 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2746 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2747 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2749 offsetX -= child.rootWindow.clientStart.x;
2750 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2754 Extent childRenderArea;
2756 if(backBufferUpdate != null)
2758 childRenderArea.Copy(backBufferUpdate);
2759 childRenderArea.Offset(-offsetX, -offsetY);
2762 childRenderArea.Copy(child.dirtyArea);
2764 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2765 renderArea.Copy(dirtyExtent);
2766 renderArea.Offset(-offsetX, -offsetY);
2767 childRenderArea.Union(renderArea);
2770 // Intersect with the clip extent
2771 childRenderArea.Intersection(child.clipExtent);
2774 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2776 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2777 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2779 renderArea->Offset(offsetX, offsetY);
2781 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2782 // overDirtyExtent.Union(renderArea);
2783 renderArea->Empty();
2784 // childRenderArea.Free();
2786 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2791 for(child = children.last; child; child = child.prev)
2793 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2795 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2800 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2802 bool opaque = IsOpaque();
2803 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2805 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2806 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2808 offsetX -= rootWindow.clientStart.x;
2809 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2813 for(child = children.last; child; child = child.prev)
2815 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2817 ColorAlpha background = *(ColorAlpha *)&child.background;
2818 bool opaque = child.IsOpaque();
2819 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2823 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2824 // Adjust renderArea to the root window level
2826 renderArea.Copy(child.dirtyArea);
2827 renderArea.Offset(offsetX, offsetY);
2828 dirtyExtent.Union(renderArea);
2829 overDirtyExtent.Union(renderArea);
2835 for(child = children.last; child; child = child.prev)
2837 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2839 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2843 if(backBufferUpdate != null)
2845 renderArea.Copy(backBufferUpdate);
2846 renderArea.Offset(-offsetX, -offsetY);
2848 overRenderArea.Copy(backBufferUpdate);
2849 overRenderArea.Offset(-offsetX, -offsetY);
2855 renderArea.Copy(dirtyArea);
2857 overRenderArea.Copy(dirtyArea);
2860 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2861 dirtyExtentWindow->Copy(dirtyExtent);
2862 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2863 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2864 dirtyExtentWindow->Empty();
2866 // Intersect with the clip extent
2867 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2870 if(renderArea.count > 10)
2873 printf("\nToo many extents (%d):\n", renderArea.count);
2875 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2876 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2881 for(c = 0; c<10; c++)
2884 FASTLIST_LOOP(renderArea, extentBox)
2886 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2888 renderArea.Copy(extent);
2890 FASTLIST_LOOP(renderArea, extentBox)
2893 printf("(%d, %d) - (%d, %d)\n",
2894 extentBox.box.left, extentBox.box.top,
2895 extentBox.box.right, extentBox.box.bottom);
2899 printf("\nNow %d\n", renderArea.count);
2905 // WHY WAS THIS COMMENTED ??
2907 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2908 dirtyExtentWindow->Copy(overDirtyExtent);
2909 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2910 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2911 dirtyExtentWindow->Empty();
2913 // Intersect with the clip extent
2914 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2920 if(scrollExtent.count)
2922 // Subtract render extent from scrolling extent
2923 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2925 if(backBufferUpdate == null)
2927 Extent * dirty = &rootWindow.tempExtents[3];
2930 // Intersect scrolling extent with clip extent
2931 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2933 // offset this scroll to be at the root window level
2934 scrollExtent.Offset(offsetX, offsetY);
2935 // Add area that was scrolled to the dirty extents of the back buffer
2936 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2940 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2941 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2942 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2947 scrollExtent.Empty();
2949 // Add the exposed extent to the window render area
2950 dirty->Offset(-offsetX, -offsetY);
2951 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2956 // Subtract the window's box from the transparency forced extent
2957 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2963 renderArea.Copy(this.renderArea);
2964 renderArea.Offset(offsetX, offsetY);
2965 dirtyExtent.Union(renderArea);
2971 Extent renderArea { };
2973 renderArea.Copy(overRenderArea);
2974 renderArea.Offset(offsetX, offsetY);
2975 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2980 if(backBufferUpdate != null)
2982 // Remove render area from dirty area
2983 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2985 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2992 // Remove the window render area from the dirty extents of the back buffer
2993 rootWindow.dirtyBack.Exclusion(renderArea);
2997 void Render(Extent updateExtent)
3001 Window rootWindow = this.rootWindow;
3002 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3003 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3005 offsetX -= rootWindow.clientStart.x;
3006 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3009 if(rootWindow.fullRender)
3018 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3019 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3024 /*if(renderArea.count)
3025 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3028 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3030 Box box = extentBox.box;
3033 /*printf("(%d, %d) - (%d, %d)\n",
3034 extentBox.box.left, extentBox.box.top,
3035 extentBox.box.right, extentBox.box.bottom);*/
3040 box.left += offsetX;
3042 box.right += offsetX;
3043 box.bottom += offsetY;
3045 if(updateExtent != null)
3046 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3050 for(child = children.first; child; child = child.next)
3051 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3052 child.Render(updateExtent);
3054 if(rootWindow.fullRender)
3055 DrawOverChildren(box);
3058 // TO DO: There's an issue about draw over children...
3059 // TO DO: Don't wanna go through this if method isn't used
3060 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3061 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3063 Box box = extentBox.box;
3065 DrawOverChildren(box);
3067 box.left += offsetX;
3069 box.right += offsetX;
3070 box.bottom += offsetY;
3072 if(updateExtent != null)
3073 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3076 for(child = children.first; child; child = child.next)
3077 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3078 child.Render(updateExtent);
3081 overRenderArea.Empty();
3084 public void UpdateDisplay(void)
3086 if(!manageDisplay) { OnRedraw(null);return; }
3087 if(rootWindow && this != rootWindow)
3088 rootWindow.UpdateDisplay();
3091 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3092 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3095 dirtyExtent.Clear();
3098 clipExtent.AddBox(box);
3100 display.StartUpdate();
3102 if(!rootWindow.fullRender)
3104 ComputeClipExtents();
3105 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3106 ComputeRenderArea(dirtyExtent, overExtent, null);
3109 clipExtent.Free(null);
3111 dirtyExtent.Free(null);
3112 overExtent.Free(null);
3114 if(display.flags.flipping)
3117 display.Update(null);
3121 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3122 updateExtent.Clear();
3124 Render(updateExtent);
3126 updateExtent.UnionBox(this.box, tempExtents[0]);
3129 //printf("\n\nUpdate:\n------------------------------------------\n");
3132 //FASTLIST_LOOP(updateExtent, extentBox)
3133 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3136 /*printf("Updating (%d, %d) - (%d, %d)\n",
3137 extentBox.box.left, extentBox.box.top,
3138 extentBox.box.right, extentBox.box.bottom);*/
3141 display.Update(extentBox.box);
3144 updateExtent.Free(null);
3147 display.EndUpdate();
3155 void UpdateBackDisplay(Box box)
3161 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3163 //printf("UpdateBackDisplay going through!\n");
3164 display.StartUpdate();
3168 intersection.Copy(dirtyBack);
3169 intersection.IntersectBox(box);
3171 dirtyExtent.Clear();
3174 clipExtent.AddBox(box);
3176 if(!rootWindow.fullRender)
3178 ComputeClipExtents();
3179 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3182 clipExtent.Free(null);
3184 intersection.Free(null);
3185 dirtyExtent.Free(null);
3186 overExtent.Free(null);
3191 if(display.flags.flipping)
3192 display.Update(null);
3195 rootWindow.display.Update(box);
3198 display.EndUpdate();
3202 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3203 if(dirtyBack.count > MAX_DIRTY_BACK)
3205 BoxItem extentBox, next;
3206 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3207 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3209 next = (BoxItem)extentBox.next;
3210 if(extentBox != first)
3212 if(extentBox.box.left < first.box.left)
3213 first.box.left = extentBox.box.left;
3214 if(extentBox.box.top < first.box.top)
3215 first.box.top = extentBox.box.top;
3216 if(extentBox.box.right > first.box.right)
3217 first.box.right = extentBox.box.right;
3218 if(extentBox.box.bottom > first.box.bottom)
3219 first.box.bottom = extentBox.box.bottom;
3220 dirtyBack.Delete(extentBox);
3229 // --- Window positioning ---
3230 // --- Window identification ---
3232 // Returns window at position "Position"
3233 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3235 Window child, result = null;
3237 box.left += absPosition.x;
3238 box.right += absPosition.x;
3239 box.top += absPosition.y;
3240 box.bottom += absPosition.y;
3242 if(!destroyed && visible && (acceptDisabled || !disabled))
3244 int lx = x - absPosition.x;
3245 int ly = y - absPosition.y;
3246 if(IsInside(lx, ly))
3247 // if(box.IsPointInside(Point{x, y}))
3249 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3250 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3253 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3254 Window ancestor = null;
3256 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3257 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3258 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3260 if(child != statusBar && child.rootWindow == rootWindow)
3262 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3269 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3270 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3272 if(child != statusBar && child.rootWindow == rootWindow)
3274 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3281 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3289 Window FindModal(void)
3291 Window modalWindow = this, check;
3292 Window check2 = null;
3293 for(check = this; check.master; check = check.master)
3295 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3297 modalWindow = check.master.modalSlave;
3298 check = modalWindow;
3300 // TESTING THIS FOR DROPBOX...
3301 if(!rootWindow || !rootWindow.style.interim)
3303 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3305 if(check2.modalSlave && check2.modalSlave.created)
3307 modalWindow = check2.modalSlave;
3315 if(modalWindow == this)
3317 for(check = this; check.activeChild; check = check.activeChild)
3319 if(check.modalSlave)
3321 modalWindow = check.modalSlave;
3327 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3328 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3331 void StopMoving(void)
3333 if(this == guiApp.windowMoving)
3335 guiApp.windowMoving = null;
3336 UpdateDecorations();
3337 SetMouseRange(null);
3340 if(rootWindow.active)
3341 guiApp.interfaceDriver.StopMoving(rootWindow);
3344 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3345 guiApp.windowIsResizing = false;
3349 void SelectMouseCursor(void)
3354 Window cursorWindow = null;
3355 bool rx, ry, rex, rey;
3357 guiApp.desktop.GetMousePosition(&x, &y);
3358 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3360 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3361 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3362 else if(mouseWindow)
3364 modalWindow = mouseWindow.FindModal();
3365 x -= mouseWindow.absPosition.x;
3366 y -= mouseWindow.absPosition.y;
3367 if(guiApp.windowIsResizing)
3369 rex = guiApp.resizeEndX;
3370 rey = guiApp.resizeEndY;
3371 rx = guiApp.resizeX;
3372 ry = guiApp.resizeY;
3373 if((rex && rey) || (rx && ry))
3374 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3375 else if((rex && ry) || (rx && rey))
3376 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3377 else if((ry || rey) && (!rx && !rex))
3378 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3379 else if((rx || rex) && (!ry && !rey))
3380 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3382 else if(!modalWindow && !guiApp.windowCaptured &&
3383 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3384 &rx, &ry, &rex, &rey))
3386 if((rex && rey) || (rx && ry))
3387 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3388 else if((rex && ry) || (rx && rey))
3389 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3390 else if((ry || rey) && (!rx && !rex))
3391 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3392 else if((rx || rex) && (!ry && !rey))
3393 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3395 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3397 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3398 mouseWindow.rootWindow != mouseWindow)
3399 cursorWindow = mouseWindow.parent;
3401 cursorWindow = mouseWindow;
3403 else if(!guiApp.interimWindow)
3404 cursorWindow = guiApp.windowCaptured;
3407 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3408 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3410 else if(modalWindow)
3412 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3414 else if(guiApp.interimWindow)
3416 if(guiApp.interimWindow.cursor)
3417 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3419 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3424 // --- State based input ---
3425 bool AcquireInputEx(bool state)
3430 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3431 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3433 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3435 guiApp.acquiredWindow = state ? this : null;
3438 SetMouseRangeToClient();
3439 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3444 SelectMouseCursor();
3446 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3450 // --- Window activation ---
3451 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3454 if(!parent || !parent.style.inactive)
3456 Window parent = this.parent;
3459 if(rootWindow == this)
3460 Log(active ? "active\n" : "inactive\n");
3462 if(active && requireRemaximize)
3464 if(state == maximized)
3466 property::state = normal;
3467 property::state = maximized;
3469 requireRemaximize = false;
3472 // Testing this here...
3473 if(!parent || parent == guiApp.desktop || parent.active)
3475 this.active = active;
3478 // TESTING THIS HERE
3479 UpdateDecorations();
3480 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3481 result = NotifyActivate(master, this, active, previous);
3484 this.active = !active;
3489 if(!parent || parent == guiApp.desktop || parent.active)
3491 this.active = active;
3493 AcquireInputEx(active);
3498 if(guiApp.caretOwner)
3502 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3503 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3504 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3505 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3507 guiApp.caretOwner.Update(extent);
3510 if(visible || !guiApp.caretOwner)
3511 guiApp.caretOwner = this;
3512 UpdateCaret(false, false);
3518 this.active = false;
3520 AcquireInputEx(active);
3522 if(!active && guiApp.caretOwner == this)
3524 UpdateCaret(false, true);
3525 guiApp.caretOwner = null;
3526 guiApp.interfaceDriver.SetCaret(0,0,0);
3527 guiApp.caretEnabled = false;
3532 if(!active && parent && parent.activeChild && parent.activeChild != this)
3533 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3539 if(!active && menuBar)
3542 menuBar.OnActivate(false, null, &goOn, true);
3543 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3548 Window aChild = activeChild;
3550 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3562 void ConsequentialMouseMove(bool kbMoving)
3566 if(kbMoving || !guiApp.windowMoving)
3570 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3572 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3574 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3575 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3581 bool IsDescendantOf(Window ancestor)
3584 for(window = this; window && window != ancestor; window = window.parent);
3585 return window == ancestor;
3588 bool IsSlaveOf(Window master)
3591 for(window = this; window && window != master; window = window.master);
3592 return window == master;
3595 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3599 if(this && !destroyed /*&& state != Hidden*/)
3601 Window swap = externalSwap;
3609 if(activateParent &&
3610 (parent.activeChild != this ||
3611 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3612 active && _isModal &&
3613 parent != master && master)
3614 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3620 bool real = parent.activeChild != this;
3622 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3623 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3624 !IsDescendantOf(guiApp.interimWindow) &&
3625 !IsSlaveOf(guiApp.interimWindow))
3627 Window interimWindow = guiApp.interimWindow;
3628 while(interimWindow && interimWindow != this)
3630 Window master = interimWindow.master;
3632 guiApp.interimWindow = null;
3633 if(guiApp.caretOwner)
3634 guiApp.caretOwner.UpdateCaret(false, false);
3636 incref interimWindow;
3637 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3642 delete interimWindow;
3643 interimWindow = (master && master.style.interim) ? master : null;
3648 guiApp.interimWindow = this;
3649 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3650 guiApp.caretEnabled = false;*/
3651 UpdateCaret(false, true);
3656 bool acquireInput = false;
3658 parent.activeChild &&
3659 parent.activeChild.state == maximized &&
3660 parent != guiApp.desktop;
3662 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3667 swap = parent.activeChild;
3668 if(swap && swap.destroyed) swap = null;
3669 if(swap && swap != this)
3672 if(!swap.PropagateActive(false, this, &goOn, true))
3673 swap = parent.activeChild;
3684 if(!parent || parent.activeChild != this || style.interim)
3687 result = PropagateActive(true, swap, &goOn, true);
3688 if(!result && !goOn)
3693 acquireInput = true;
3697 if(style.hasMaximize && parent != guiApp.desktop)
3700 SetState(maximized, false, 0);
3701 else if(state != maximized)
3704 for(child = parent.children.first; child; child = child.next)
3706 if(this != child && child.state == maximized)
3707 child.SetState(normal, false, 0);
3714 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3716 Window previous = parent.activeClient;
3717 parent.activeChild = this;
3718 if(!style.nonClient /*&& style.isActiveClient*/)
3722 if(style.isActiveClient)
3723 parent.activeClient = this;
3724 // Moved UpdateActiveDocument inside hidden check
3725 // To prevent activating previous window while creating a new one
3726 // (It was messing up the privateModule in the CodeEditor)
3727 parent.UpdateActiveDocument(previous);
3733 //if(!style.isRemote)
3735 if(rootWindow != this)
3737 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3738 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3740 else if(!guiApp.fullScreenMode)
3742 Window modalRoot = FindModal();
3743 if(!modalRoot) modalRoot = this;
3744 if(!modalRoot.isForegroundWindow)
3746 modalRoot.isForegroundWindow = true;
3747 // To check : Why is parent null?
3748 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3750 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3752 modalRoot.isForegroundWindow = false;
3757 if(result && real && (!style.inactive || moveInactive) && parent)
3759 Window last = parent.children.last;
3761 if(!style.stayOnTop)
3762 for(; last && last.style.stayOnTop; last = last.prev);
3764 parent.children.Move(this, last);
3766 // Definitely don't want that: why not?
3770 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3776 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3783 parent.activeChild = null;
3784 if(!style.nonClient /*&& style.isActiveClient*/)
3786 Window previous = parent.activeClient;
3787 if(style.isActiveClient)
3788 parent.activeClient = null;
3789 parent.UpdateActiveDocument(previous);
3793 if(this == guiApp.interimWindow)
3795 guiApp.interimWindow = null;
3796 if(guiApp.caretOwner)
3797 guiApp.caretOwner.UpdateCaret(false, false);
3799 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3806 if(!active || !swap)
3807 UpdateDecorations();
3809 swap.UpdateDecorations();
3811 if(active && rootWindow != this)
3812 ConsequentialMouseMove(false);
3819 // --- Input Messages ---
3820 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3822 static bool reEntrancy = false;
3823 if(reEntrancy) return;
3827 guiApp.cursorUpdate = true;
3828 if(guiApp.windowScrolling && !consequential)
3830 guiApp.windowScrolling.SetScrollPosition(
3831 (guiApp.windowScrolling.sbh) ?
3832 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3833 (guiApp.windowScrolling.sbv) ?
3834 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3836 if(guiApp.windowMoving)
3838 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3840 Window window = guiApp.windowMoving;
3842 int w = window.size.w;
3843 int h = window.size.h;
3848 rx = mouseX - guiApp.windowMovingStart.x;
3849 ry = mouseY - guiApp.windowMovingStart.y;
3852 window.GetDecorationsSize(&ew, &eh);
3854 if(guiApp.windowIsResizing)
3856 x = window.scrolledPos.x;
3857 y = window.scrolledPos.y;
3861 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3862 rx = guiApp.windowResizingBefore.w - aw;
3863 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3864 w = guiApp.windowResizingBefore.w - rx;
3868 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3869 ry = guiApp.windowResizingBefore.h - ah;
3870 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3871 ry = Max(ry, -guiApp.windowMovingBefore.y);
3872 h = guiApp.windowResizingBefore.h - ry;
3874 if(guiApp.resizeEndX)
3876 w = guiApp.windowResizingBefore.w + rx;
3879 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3887 w = Max(w, window.minSize.w);
3888 h = Max(h, window.minSize.h);
3889 w = Min(w, window.maxSize.w);
3890 h = Min(h, window.maxSize.h);
3892 if(!window.OnResizing(&w, &h))
3894 w = window.clientSize.w;
3895 h = window.clientSize.h;
3898 w = Max(w, window.skinMinSize.w);
3899 h = Max(h, window.skinMinSize.h);
3906 SNAPDOWN(w, textCellW);
3907 SNAPDOWN(h, textCellH);
3912 aw = Max(w,window.skinMinSize.w);
3913 rx = guiApp.windowResizingBefore.w - aw;
3914 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3915 w = guiApp.windowResizingBefore.w - rx;
3919 ah = Max(h,window.skinMinSize.h);
3920 ry = guiApp.windowResizingBefore.h - ah;
3921 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3922 ry = Max(ry, -guiApp.windowMovingBefore.y);
3923 h = guiApp.windowResizingBefore.h - ry;
3928 if(!guiApp.windowIsResizing || guiApp.resizeX)
3929 x = guiApp.windowMovingBefore.x + rx;
3930 if(!guiApp.windowIsResizing || guiApp.resizeY)
3931 y = guiApp.windowMovingBefore.y + ry;
3933 if(!guiApp.windowIsResizing)
3936 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3938 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3939 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3940 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3941 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3945 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3946 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3952 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3954 if(!window.OnMoving(&x, &y, w, h))
3956 x = window.scrolledPos.x;
3957 y = window.scrolledPos.y;
3963 SNAPDOWN(x, textCellW);
3964 SNAPDOWN(y, textCellH);
3967 if(!window.style.nonClient)
3969 if(!window.style.fixed /*|| window.style.isDocument*/)
3971 if(!window.style.dontScrollHorz)
3972 x += window.parent.scroll.x;
3973 if(!window.style.dontScrollVert)
3974 y += window.parent.scroll.y;
3978 // Break the anchors for moveable/resizable windows
3979 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3980 if(window.style.fixed)
3982 if(window.state == normal)
3984 window.normalAnchor = Anchor { left = x, top = y };
3985 window.normalSizeAnchor = SizeAnchor { { w, h } };
3986 window.anchored = false;
3990 window.stateAnchor = Anchor { left = x, top = y };
3991 window.stateSizeAnchor = SizeAnchor { { w, h } };
3993 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3994 // TOCHECK: Investigate why the following only redraws the scrollbars
3995 //window.Position(x, y, w, h, false, true, true, true, false, true);
3997 guiApp.movingLast.x = mouseX;
3998 guiApp.movingLast.y = mouseY;
4004 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4007 bool wasMoving = guiApp.windowMoving ? true : false;
4008 bool wasScrolling = guiApp.windowScrolling ? true : false;
4010 while(result && w != this)
4012 Window msgWindow = GetAtPosition(x,y, false, true, w);
4013 Window trueWindow = GetAtPosition(x,y, false, false, w);
4014 bool windowDragged = false;
4019 window = (w && !w.disabled) ? w : null;
4021 if(trueWindow) incref trueWindow;
4023 if(consequential) mods->isSideEffect = true;
4025 UpdateMouseMove(x, y, consequential);
4027 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4029 if(!guiApp.windowCaptured.isEnabled)
4030 guiApp.windowCaptured.ReleaseCapture();
4032 window = guiApp.windowCaptured;
4035 if(trueWindow && activate &&
4036 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4037 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4038 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4039 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4041 if(mods->alt && !mods->ctrl && !mods->shift)
4043 Window moved = trueWindow;
4044 for(moved = trueWindow; moved; moved = moved.parent)
4045 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4050 windowDragged = true;
4052 // Cancel the ALT menu toggling...
4053 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4058 if(window && activate &&
4059 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4060 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4061 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4062 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4064 Window modalWindow = window.FindModal();
4066 /*if(mods->alt && !mods->shift && !mods->ctrl)
4068 Window moved = window;
4069 for(moved = window; moved; moved = moved.parent)
4070 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4075 windowDragged = true;
4077 // Cancel the ALT menu toggling...
4078 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4084 Window activateWindow = modalWindow ? modalWindow : window;
4085 if(activateWindow && !activateWindow.isRemote)
4087 bool doActivation = true;
4088 //bool needToDoActivation = false;
4089 Window check = activateWindow;
4091 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4093 if(!check.style.inactive)
4095 //needToDoActivation = true;
4097 doActivation = false;
4102 if(!needToDoActivation)
4103 doActivation = false;
4106 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4107 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4109 // Let the OnLeftButtonDown do the activating instead
4110 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4118 incref activateWindow;
4119 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4121 delete activateWindow;
4125 if(activateWindow._refCount == 1)
4127 delete activateWindow;
4131 delete activateWindow;
4132 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4135 mods->isActivate = true;
4139 if(!modalWindow && window && !window.destroyed)
4141 if(!guiApp.windowCaptured || windowDragged)
4143 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4145 bool moving = ((window.state != maximized &&
4146 window.IsMouseMoving(
4147 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4148 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4150 if(!moving && window.IsMouseResizing(
4151 x - window.absPosition.x,
4152 y - window.absPosition.y,
4153 window.size.w, window.size.h,
4154 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4156 guiApp.windowIsResizing = true;
4157 guiApp.windowResizingBefore.w = window.size.w;
4158 guiApp.windowResizingBefore.h = window.size.h;
4160 if(guiApp.windowIsResizing || windowDragged || moving)
4163 guiApp.windowMoving = window;
4164 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4165 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4166 guiApp.windowMovingBefore.x = window.position.x;//s;
4167 guiApp.windowMovingBefore.y = window.position.y;//s;
4168 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4169 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4172 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4174 if(window.style.fixed &&
4176 window.IsMouseMoving(
4177 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4179 window.ShowSysMenu(x, y);
4183 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4185 if(window.sbv || window.sbh)
4188 guiApp.windowScrolling = window;
4189 guiApp.windowScrollingStart.x = x;
4190 guiApp.windowScrollingStart.y = y;
4191 guiApp.windowScrollingBefore.x = window.scroll.x;
4192 guiApp.windowScrollingBefore.y = window.scroll.y;
4195 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4197 if(window.style.hasMaximize &&
4198 window.IsMouseMoving(
4199 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4202 (window.state == maximized) ? normal : maximized, false, *mods);
4210 if(guiApp.windowMoving)
4212 if(guiApp.windowMoving.parent)
4214 if(guiApp.windowMoving.style.nonClient)
4215 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4217 guiApp.windowMoving.parent.SetMouseRangeToClient();
4221 window.UpdateDecorations();
4224 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4226 // Log("\n*** LEFT BUTTON UP ***\n");
4227 if(guiApp.windowMoving)
4228 guiApp.windowMoving.StopMoving();
4230 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4232 if(guiApp.windowScrolling)
4234 Window windowScrolling = guiApp.windowScrolling;
4235 guiApp.windowScrolling = null;
4236 windowScrolling.ReleaseCapture();
4240 if(!result || (window && window.destroyed)) window = null;
4242 if(window && window.FindModal())
4245 if(trueWindow && trueWindow.FindModal())
4253 msgWindow = GetAtPosition(x,y, true, false);
4255 msgWindow.SelectMouseCursor();
4258 if(guiApp.windowCaptured || trueWindow)
4260 Window prevWindow = guiApp.prevWindow;
4261 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4263 guiApp.prevWindow.mouseInside = false;
4264 guiApp.prevWindow = null;
4266 // Eventually fix this not to include captured?
4267 if(!trueWindow.IsDescendantOf(prevWindow) && !prevWindow.OnMouseLeave(*mods))
4270 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4272 Box box = trueWindow.box;
4273 box.left += trueWindow.absPosition.x;
4274 box.right += trueWindow.absPosition.x;
4275 box.top += trueWindow.absPosition.y;
4276 box.bottom += trueWindow.absPosition.y;
4278 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4280 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4281 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4283 overX = Max(Min(overX, 32767),-32768);
4284 overY = Max(Min(overY, 32767),-32768);
4286 trueWindow.mouseInside = true;
4287 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4291 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4292 guiApp.prevWindow = trueWindow;
4294 guiApp.prevWindow = null;
4296 SelectMouseCursor();
4298 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4300 int clientX = x - (window.absPosition.x + window.clientStart.x);
4301 int clientY = y - (window.absPosition.y + window.clientStart.y);
4303 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4305 clientX = Max(Min(clientX, 32767),-32768);
4306 clientY = Max(Min(clientY, 32767),-32768);
4308 MouseMethod = (void *)window._vTbl[method];
4310 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4313 if(!MouseMethod(window, clientX, clientY, *mods))
4320 if(result && w && w.clickThrough && w.parent)
4325 if(!result || !w || !w.clickThrough)
4332 // --- Mouse cursor management ---
4334 bool KeyMessage(uint method, Key key, unichar character)
4339 if(guiApp.interimWindow)
4340 this = guiApp.interimWindow;
4343 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4347 if(!style.inactive || rootWindow != this)
4349 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4350 Window modalWindow = FindModal();
4351 Window interimMaster = master ? master.rootWindow : null;
4355 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4356 status = OnSysKeyDown(key, character);
4357 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4358 status = OnSysKeyHit(key, character);
4359 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4360 status = OnSysKeyUp(key, character);
4367 // Process Key Message for Internal UI Keyboard actions
4368 if(status && !destroyed && menuBar && state != minimized)
4371 if((SmartKey)key != alt)
4372 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4375 SmartKey sk = (SmartKey) key;
4376 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4378 status = menuBar.KeyMessage(method, key, character);
4383 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4384 menuBar.OnKeyHit(escape, 0);
4386 if(!menuBar.focus && guiApp.caretOwner)
4387 guiApp.caretOwner.UpdateCaret(true, false);
4390 if(!destroyed && status)
4392 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4396 case left: case up: case right: case down:
4397 if(guiApp.windowMoving == this)
4400 int w = guiApp.windowMoving.size.w;
4401 int h = guiApp.windowMoving.size.h;
4402 int x = guiApp.windowMoving.scrolledPos.x;
4403 int y = guiApp.windowMoving.scrolledPos.y;
4407 if(key == down || key == up)
4408 step = Max(step, textCellH);
4410 step = Max(step, textCellW);
4413 if(guiApp.windowIsResizing)
4417 case left: w-=step; break;
4418 case right: w+=step; break;
4419 case up: h-=step; break;
4420 case down: h+=step; break;
4427 case left: x-=step; break;
4428 case right: x+=step; break;
4429 case up: y-=step; break;
4430 case down: y+=step; break;
4434 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4435 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4437 if(!guiApp.windowIsResizing || guiApp.resizeX)
4438 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4440 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4442 if(!guiApp.windowIsResizing || guiApp.resizeY)
4443 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4445 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4447 guiApp.interfaceDriver.SetMousePosition(x, y);
4448 ConsequentialMouseMove(true);
4456 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4458 guiApp.windowMoving.StopMoving();
4459 ConsequentialMouseMove(false);
4467 ShowSysMenu(absPosition.x, absPosition.y);
4475 if(!destroyed && status && state != minimized)
4477 // Process all the way down the children
4478 if(activeChild && !activeChild.disabled)
4480 status = activeChild.KeyMessage(method, key, character);
4482 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4483 key.code != left && key.code != right && key.code != up && key.code != down)
4485 status = activeClient.KeyMessage(method, key, character);
4489 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4491 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4492 // && defaultControl != activeChild)
4494 delete previousActive;
4495 previousActive = activeChild;
4496 if(previousActive) incref previousActive;
4498 ConsequentialMouseMove(false);
4499 if((defaultControl.active ||
4500 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4501 defaultControl.KeyMessage(method, defaultKey, character);
4507 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4509 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4516 ShowSysMenu(absPosition.x, absPosition.y);
4523 if(this != guiApp.desktop)
4525 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4527 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4529 MenuMoveOrSize(key.shift, true);
4533 else if(guiApp.windowMoving)
4535 guiApp.windowMoving.StopMoving();
4536 ConsequentialMouseMove(false);
4544 if(!destroyed && status && state != minimized)
4546 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4550 case tab: case shiftTab:
4552 Window cycleParent = this;
4553 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4554 cycleParent = master.parent;
4556 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4558 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4560 Window child = cycleParent.activeChild;
4562 // Scroll the window to include the active control
4564 if(cycleParent.sbh && !child.style.dontScrollHorz)
4566 if(child.scrolledPos.x < 0)
4567 cycleParent.sbh.Action(Position,
4568 cycleParent.scroll.x + child.scrolledPos.x, 0);
4569 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4570 cycleParent.sbh.Action(Position,
4571 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4573 if(cycleParent.sbv && !child.style.dontScrollVert)
4575 if(child.scrolledPos.y < 0)
4576 cycleParent.sbv.Action(Position,
4577 cycleParent.scroll.y + child.scrolledPos.y, 0);
4578 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4579 cycleParent.sbv.Action(Position,
4580 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4583 cycleParent.ConsequentialMouseMove(false);
4589 case f6: case shiftF6:
4590 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4592 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4593 if(parent == guiApp.desktop)
4594 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4604 if(CycleChildren(key.shift, true, false, true))
4612 // mIRC Style Window Shortcuts
4613 case alt1: case alt2: case alt3: case alt4: case alt5:
4614 case alt6: case alt7: case alt8: case alt9: case alt0:
4619 for(document = children.first; document; document = document.next)
4621 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4623 if(document == activeChild)
4625 if(document.state == minimized)
4626 document.SetState(normal, false, key);
4629 document.SetState(minimized, false, key);
4630 CycleChildren(false, true, false);
4635 if(activeChild.state == maximized && document.style.hasMaximize)
4636 document.SetState(maximized, false, key);
4637 else if(document.state == minimized)
4638 document.SetState(normal, false, key);
4639 document.Activate();
4654 if(!destroyed && status)
4656 if(state == minimized)
4661 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4663 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4665 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4666 previousActive.ActivateEx(true, false, false, true, null, null);
4667 delete previousActive;
4673 if(!destroyed && status)
4675 status = ProcessHotKeys(method, key, character);
4677 if(!destroyed && status && !modalWindow && state != minimized)
4680 status = KeyMethod(this, key, character);
4681 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4682 status = OnKeyHit(key, character);
4683 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4685 bool result = false;
4688 case ctrlUp: case ctrlDown:
4689 if(sbv && !guiApp.windowScrolling)
4690 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4692 case wheelUp: case wheelDown:
4693 if(sbv && !guiApp.windowScrolling)
4695 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4696 // Do we want to do a consequential move regardless of result in this case?
4697 ConsequentialMouseMove(false);
4700 case ctrlPageUp: case ctrlPageDown:
4701 if(sbh && !guiApp.windowScrolling)
4702 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4707 ConsequentialMouseMove(false);
4712 if(status && !destroyed && menuBar && state != minimized)
4713 status = menuBar.KeyMessage(method, key, character);
4715 if(style.interim && /*destroyed && */status && interimMaster)
4717 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4718 status = interimMaster.KeyMessage(method, key, character);
4725 bool ProcessHotKeys(uint method, Key key, unichar character)
4730 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4731 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4732 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4734 Window hotKeyWindow = hotKey.window;
4735 Window parent = hotKeyWindow.parent;
4736 Window prevActiveWindow = activeChild;
4737 // For when sys buttons are placed inside the menu bar
4738 if(parent && parent._class == class(PopupMenu))
4739 parent = parent.parent;
4741 // 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
4742 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4745 if(prevActiveWindow) incref prevActiveWindow;
4746 incref hotKeyWindow;
4747 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4748 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4751 delete hotKeyWindow;
4752 delete prevActiveWindow;
4756 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4757 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4758 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4760 // ********* WORKING ON THIS ***********
4761 if(prevActiveWindow && !guiApp.interimWindow)
4762 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4765 else if(hotKeyWindow.style.inactive)
4766 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4768 delete prevActiveWindow;
4769 delete hotKeyWindow;
4770 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4771 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4775 if(status && tabCycle)
4778 for(child = children.first; child; child = child.next)
4780 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4791 // --- Windows and graphics initialization / termination ---
4792 bool SetupRoot(void)
4796 // Setup relationship with outside world (bb root || !bb)
4797 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4798 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4802 tempExtents = new0 Extent[4];
4807 /*if(guiApp.fullScreenMode)
4808 rootWindow = guiApp.desktop;
4810 //rootWindow = parent.created ? parent.rootWindow : null;
4811 rootWindow = parent.rootWindow;
4814 against = &parent.box;
4816 against = &parent.clientArea;
4819 for(child = children.first; child; child = child.next)
4822 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4825 bool Setup(bool positionChildren)
4827 bool result = false;
4830 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4832 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4833 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4835 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4837 // This was here, is it really needed?
4838 //guiApp.interfaceDriver.ActivateRootWindow(this);
4842 displaySystem = DisplaySystem {};
4843 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4845 delete displaySystem;
4850 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4851 if(display.Create(displaySystem, windowHandle))
4858 // Sometimes icon does not show up on Windows XP if we set here...
4859 // guiApp.interfaceDriver.SetIcon(this, icon);
4861 else if(this != guiApp.desktop)
4863 display = rootWindow ? rootWindow.display : null;
4869 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4870 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4872 for(child = children.first; child; child = child.next)
4874 if(child.created && !child.Setup(false))
4880 bool SetupDisplay(void)
4882 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4883 if(is3D) return Window3D_SetupDisplay(this); else
4890 class_data void ** pureVTbl;
4892 bool LoadGraphics(bool creation, bool resetAnchors)
4894 bool result = false;
4895 bool success = false;
4897 WindowState stateBackup = state;
4899 if(((subclass(Window))_class).pureVTbl)
4901 if(_vTbl == _class._vTbl)
4903 _vTbl = ((subclass(Window))_class).pureVTbl;
4908 for(m = 0; m < _class.vTblSize; m++)
4910 if(_vTbl[m] == _class._vTbl[m])
4911 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4915 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4917 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4919 _vTbl = _class._vTbl;
4924 for(m = 0; m < _class.vTblSize; m++)
4926 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4927 _vTbl[m] = _class._vTbl[m];
4932 if(guiApp.fullScreenMode || this != guiApp.desktop)
4934 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4940 display.Lock(false);
4941 if(rootWindow == this)
4943 // Set Color Palette
4944 display.SetPalette(palette, true);
4948 if(guiApp.fullScreenMode && this == guiApp.desktop)
4953 for(c=0; c<SystemCursor::enumSize; c++)
4954 if(!guiApp.systemCursors[c].bitmap)
4956 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4957 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4958 if(guiApp.systemCursors[c].bitmapName)
4960 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4961 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4962 if(guiApp.systemCursors[c].bitmap)
4963 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4968 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4970 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4971 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4973 cursor.bitmap.paletteShades = cursor.paletteShades;
4977 guiApp.cursorUpdate = true;
4980 ConsequentialMouseMove(false);
4986 // Load Window Graphic Resources
4989 if(usedFont == setFont || usedFont == window.systemFont)
4990 RemoveResource(usedFont);
4993 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4996 RemoveResource(systemFont);
4999 RemoveResource(captionFont);
5001 for(ptr = resources.first; ptr; ptr = ptr.next)
5003 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5006 AddResource(setFont);
5008 AddResource(systemFont);
5010 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5017 //if(master && master.font)
5018 if(parent && parent.font)
5022 faceName = parent.font.faceName,
5023 size = parent.font.size,
5024 bold = parent.font.bold,
5025 italic = parent.font.italic,
5026 underline = parent.font.underline
5028 //font = parent.font;
5029 watch(parent) { font { } };
5032 font = guiApp.currentSkin.SystemFont();
5039 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5040 AddResource(captionFont);
5042 if(OnLoadGraphics())
5048 //SetScrollLineStep(sbStep.x, sbStep.y);
5050 if(this != guiApp.desktop)
5054 normalAnchor = anchor;
5055 normalSizeAnchor = sizeAnchor;
5058 // Break the anchors for moveable/resizable windows
5060 if(style.fixed && style.isDocument)
5062 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5074 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5075 stateSizeAnchor = SizeAnchor {};
5080 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5085 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5086 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5089 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5093 stateAnchor = normalAnchor;
5094 stateSizeAnchor = normalSizeAnchor;
5097 position = Point { };
5098 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5109 if(Position(x, y, w, h, true, false, true, true, true, true))
5111 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5114 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5131 success = result = true;
5134 if(!creation && result)
5136 // Load menu bar first because sys buttons are on it...
5139 if(!menuBar.LoadGraphics(false, resetAnchors))
5145 for(child = children.first; child; child = child.next)
5147 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5154 CreateSystemChildren();
5158 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5161 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5166 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5167 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5170 // Do this here to avoid problems on Windows
5171 if(stateBackup == maximized)
5172 property::state = maximized;
5176 void UnloadGraphics(bool destroyWindows)
5180 // Free children's graphics
5181 for(child = children.first; child; child = child.next)
5182 child.UnloadGraphics(destroyWindows);
5185 display.Lock(false);
5188 if(guiApp.fullScreenMode && this == guiApp.desktop)
5193 for(c=0; c<SystemCursor::enumSize; c++)
5194 if(guiApp.systemCursors[c].bitmap)
5195 delete guiApp.systemCursors[c].bitmap;
5197 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5198 delete cursor.bitmap;
5200 guiApp.cursorBackground.Free();
5203 if(display && display.displaySystem)
5207 for(ptr = resources.first; ptr; ptr = ptr.next)
5211 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5216 // Free window graphics
5219 // Free skin graphics
5220 if(rootWindow == this)
5222 DisplaySystem displaySystem = display.displaySystem;
5225 display.driverData = null;
5226 display.displaySystem = null;
5230 if(displaySystem && !displaySystem.numDisplays && !is3D)
5231 delete displaySystem;
5240 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5241 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5243 if(this == guiApp.desktop || parent == guiApp.desktop)
5245 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5246 guiApp.interfaceDriver.DestroyRootWindow(this);
5250 // --- Window Hiding ---
5252 void SetVisibility(bool state)
5254 bool visible = (style.hidden || !created) ? false : state;
5255 if(visible != this.visible)
5259 this.visible = visible;
5260 for(child = children.first; child; child = child.next)
5261 child.SetVisibility(visible);
5263 ConsequentialMouseMove(false);
5264 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5268 // --- Windows and graphics initialization / termination ---
5270 bool DisplayModeChanged(void)
5272 bool result = false;
5273 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5275 guiApp.modeSwitching = true;
5276 UnloadGraphics(false);
5278 if(LoadGraphics(false, false))
5280 guiApp.modeSwitching = false;
5285 // --- Window updates system ---
5287 void UpdateDirty(Box updateBox)
5289 if(!manageDisplay) { OnRedraw(null);return; }
5292 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5295 if(display.flags.flipping)
5298 rootWindow.UpdateDisplay();
5301 UpdateBackDisplay(updateBox);
5303 if(guiApp.fullScreenMode)
5305 guiApp.cursorUpdate = true;
5306 guiApp.PreserveAndDrawCursor();
5308 if(guiApp.fullScreenMode)
5309 guiApp.RestoreCursorBackground();
5315 // This function is strictly called as a result of system window activation
5316 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5319 Window interimMaster = null;
5320 Window interimWindow = guiApp.interimWindow;
5321 if(interimWindow && interimWindow.master)
5322 interimMaster = interimWindow.master.rootWindow;
5324 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5325 // SetState(normal, false, 0);
5326 SetState(lastState, false, 0);
5328 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5332 /* WTH is this doing here?
5333 while(swap && swap.activeChild)
5335 swap = swap.activeChild;
5338 // TESTING THIS BEFORE...
5339 if(interimWindow && this == interimMaster)
5343 // Window interimSwap = this;
5344 Window menuBar = this.menuBar;
5345 if(menuBar && interimWindow.master == menuBar)
5348 while(interimSwap && interimSwap.activeChild)
5349 interimSwap = interimSwap.activeChild;
5351 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5352 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5354 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5355 //result = ActivateEx(true, true, false, activateRoot, window, null);
5360 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5361 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5363 if(interimWindow == this && interimMaster && !active)
5365 while(interimMaster && interimMaster.interim && interimMaster.master)
5367 // printf("Going up one master %s\n", interimMaster._class.name);
5368 interimMaster = interimMaster.master.rootWindow;
5370 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5371 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5377 bool DestroyEx(int64 returnCode)
5380 Timer timer, nextTimer;
5382 OldLink prevOrder = null;
5383 Window client = null;
5385 if(parent) stopwatching(parent, font);
5387 // if(window.modalSlave) return false;
5388 if(destroyed || !created)
5395 OldLink slave = master.slaves.FindLink(this);
5396 master.slaves.Delete(slave);
5399 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5405 this.returnCode = (DialogResult)returnCode;
5407 AcquireInput(false);
5412 master.hotKeys.Delete(hotKey);
5416 if(guiApp.prevWindow == this)
5418 guiApp.prevWindow = null;
5421 if(guiApp.caretOwner == this)
5423 guiApp.interfaceDriver.SetCaret(0,0,0);
5424 UpdateCaret(false, true);
5425 guiApp.caretEnabled = false;
5430 parent.childrenCycle.Remove(cycle);
5434 OldLink tmpPrev = order.prev;
5435 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5436 prevOrder = tmpPrev;
5439 client = tmpPrev ? tmpPrev.data : null;
5440 if(client == this) { client = null; break; }
5441 if(client && (client.style.hidden || client.destroyed || !client.created))
5442 tmpPrev = client.order.prev;
5446 prevOrder = tmpPrev;
5451 // If this window can be an active client, make sure the next window we activate can also be one
5452 if(!style.nonClient && style.isActiveClient)
5454 tmpPrev = prevOrder;
5457 client = tmpPrev ? tmpPrev.data : null;
5458 if(client == this) { client = null; break; }
5459 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5460 tmpPrev = client.order.prev;
5464 prevOrder = tmpPrev;
5468 if(client && client.style.hidden) client = null;
5470 // parent.childrenOrder.Remove(order);
5473 if(parent && style.isActiveClient && visible)
5475 if(state == minimized) parent.numIcons--;
5476 parent.numPositions--;
5479 // TESTING THIS HERE!
5483 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5484 // to create a window inside a rootwindow that's being destroyed)
5485 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5487 if(master && !master.destroyed /*&&
5488 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5490 if(master.defaultControl == this)
5491 master.defaultControl = null;
5494 parent.OnChildAddedOrRemoved(this, true);
5495 if(parent && !parent.destroyed /*&&
5496 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5498 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5500 if(order && prevOrder && prevOrder.data != this && active)
5502 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5504 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5505 if(parent.activeClient == this)
5507 parent.activeClient = null;
5508 parent.UpdateActiveDocument(null);
5513 if(guiApp.interimWindow == this)
5516 PropagateActive(false, null, &goOn, true);
5520 //if(window.parent.activeChild == window)
5521 parent.activeChild = null;
5522 if(!style.nonClient /*&& style.isActiveClient*/)
5524 Window previous = parent.activeClient;
5525 if(style.isActiveClient)
5526 parent.activeClient = null;
5527 parent.UpdateActiveDocument(previous);
5532 else if(parent.activeClient == this)
5534 parent.activeClient = client;
5535 parent.UpdateActiveDocument(this);
5539 if(guiApp.interimWindow == this)
5541 guiApp.interimWindow = null;
5542 if(guiApp.caretOwner)
5544 Window desktop = guiApp.desktop;
5545 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5546 guiApp.caretOwner.UpdateCaret(false, false);
5551 if(_isModal && master && master.modalSlave == this)
5552 master.modalSlave = null;
5556 if(!guiApp.caretOwner && parent.caretSize)
5558 guiApp.caretOwner = parent;
5559 parent.UpdateCaret(false, false);
5560 parent.Update(null);
5563 // Why was this commented out?
5564 GetRidOfVirtualArea();
5570 dirtyArea.Free(null);
5571 dirtyBack.Free(null);
5572 scrollExtent.Free(null);
5574 /* ATTEMPTING TO MOVE THAT ABOVE
5583 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5584 for(;(child = window.children.first);)
5586 for(; child && (child.destroyed || !child.created); child = child.next);
5595 UnloadGraphics(true);
5598 delete previousActive;
5601 // statusBar = null;
5604 if(master && !master.destroyed)
5606 //master.NotifyDestroyed(this, this.returnCode);
5607 NotifyDestroyed(master, this, this.returnCode);
5610 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5612 nextTimer = timer.next;
5613 if(timer.window == this)
5615 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5616 // timer.window = null;
5622 if(this == guiApp.windowMoving)
5625 if(guiApp.windowCaptured == this)
5627 //guiApp.windowCaptured = null;
5629 if(rootWindow != this && rootWindow)
5630 rootWindow.ConsequentialMouseMove(false);
5638 //for(child = children.first; next = child ? child.next : null, child; child = next)
5639 for(;(child = children.first); )
5641 for(; child && (child.destroyed || !child.created); child = child.next);
5651 /* // MOVED THIS UP...
5654 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5655 for(;(child = window.children.first); )
5657 for(; child && (child.destroyed || !child.created); child = child.next);
5666 while((slave = slaves.first))
5668 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5670 ((Window)slave.data).DestroyEx(0);
5675 if(guiApp.caretOwner == this)
5676 guiApp.caretOwner = null;
5678 sysButtons[0] = null;
5679 sysButtons[1] = null;
5680 sysButtons[2] = null;
5683 if(rootWindow != this)
5685 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5688 box.left -= parent.clientStart.x;
5689 box.top -= parent.clientStart.y;
5690 box.right -= parent.clientStart.x;
5691 box.bottom -= parent.clientStart.y;
5693 if(parent) parent.Update(box);
5698 OldLink slave = master.slaves.FindVoid(this);
5699 master.slaves.Delete(slave);
5705 parent.children.Remove(this);
5710 //autoCreate = false;
5713 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5714 if(((subclass(Window))_class).pureVTbl)
5716 if(_vTbl == _class._vTbl)
5718 _vTbl = ((subclass(Window))_class).pureVTbl;
5723 for(m = 0; m < _class.vTblSize; m++)
5725 if(_vTbl[m] == _class._vTbl[m])
5726 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5735 void SetStateEx(WindowState newState, bool activate)
5738 WindowState prevState = state;
5742 if(prevState != newState)
5743 lastState = prevState;
5745 if(rootWindow != this || !nativeDecorations || !windowHandle)
5747 if(style.isActiveClient && !style.hidden && prevState == minimized)
5750 // This block used to be at the end of the function... moved it for flicker problem in X
5751 // ------------------------------------------------------
5755 stateAnchor = normalAnchor;
5756 stateSizeAnchor = normalSizeAnchor;
5759 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5760 stateSizeAnchor = SizeAnchor {};
5764 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5767 byte * idBuffer = new0 byte[size];
5769 for(child = parent.children.first; child; child = child.next)
5771 if(child != this && child.state == minimized)
5773 if(child.iconID > size - 2)
5775 idBuffer = renew0 idBuffer byte[size*2];
5776 memset(idBuffer + size, 0, size);
5779 idBuffer[child.iconID] = (byte)bool::true;
5782 for(c = 0; c<size; c++)
5787 if(style.isActiveClient && !style.hidden)
5790 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5791 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5795 // TOCHECK: Why was this here?
5796 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5797 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5798 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5800 Position(x, y, w, h, true, true, true, true, false, true);
5802 if(!style.inactive && !style.interim && this == parent.activeClient)
5803 parent.UpdateActiveDocument(null);
5806 CreateSystemChildren();
5807 // ------------------------------------------------------
5810 int GetPositionID(Window forChild)
5814 byte * idBuffer = new0 byte[size];
5817 for(child = children.first; child; child = child.next)
5819 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5821 if(child.positionID > size - 2)
5823 idBuffer = renew0 idBuffer byte[size*2];
5824 memset(idBuffer + size, 0, size);
5827 idBuffer[child.positionID] = (byte)bool::true;
5830 for(c = 0; c<size; c++)
5837 // --- Window related graphics ---
5839 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5841 palette = newPalette;
5842 if(rootWindow.display)
5843 rootWindow.display.SetPalette(palette, colorMatch);
5846 public bool AcquireInput(bool acquired)
5849 if(acquiredInput != acquired)
5851 if(active || (!visible && creationActivation == activate))
5852 result = AcquireInputEx(acquired);
5857 acquiredInput = acquired ? result : !result;
5862 void ListChildren(ListBox listBox)
5866 for(child = children.first; child; child = child.next)
5868 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5870 DataRow row = listBox.AddRow();
5871 row.tag = (int64)child;
5872 child.FigureCaption(caption);
5873 row.SetData(null, caption);
5878 void UpdateVisual(Box extent)
5880 if(guiApp.driver != null)
5882 if(guiApp.fullScreenMode && guiApp.desktop.display)
5884 guiApp.desktop.mutex.Wait();
5885 guiApp.desktop.display.Lock(true);
5888 if(guiApp.desktop.active)
5890 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5892 if(guiApp.desktop.display.flags.flipping)
5893 guiApp.desktop.Update(null);
5894 guiApp.desktop.UpdateDisplay();
5895 guiApp.cursorUpdate = true;
5897 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5899 guiApp.PreserveAndDrawCursor();
5900 // guiApp.desktop.display.ShowScreen();
5901 guiApp.cursorUpdate = false;
5902 guiApp.desktop.dirty = false;
5903 guiApp.RestoreCursorBackground();
5907 guiApp.desktop.display.Unlock();
5908 guiApp.desktop.mutex.Release();
5912 Window rootWindow = this.rootWindow;
5913 rootWindow.mutex.Wait();
5918 guiApp.SignalEvent();
5921 guiApp.waitMutex.Wait();
5922 guiApp.interfaceDriver.Lock(rootWindow);
5923 if(!rootWindow.style.hidden && rootWindow.dirty)
5925 if(rootWindow.display)
5927 rootWindow.UpdateDisplay();
5928 //rootWindow.display.ShowScreen(null);
5930 rootWindow.dirty = false;
5932 guiApp.interfaceDriver.Unlock(rootWindow);
5933 guiApp.waitMutex.Release();
5936 rootWindow.mutex.Release();
5941 void UnlockDisplay(void)
5943 guiApp.interfaceDriver.Unlock(rootWindow);
5946 void LockDisplay(void)
5948 guiApp.interfaceDriver.Lock(rootWindow);
5951 Surface GetSurface(Box box)
5953 return Redraw((box == null) ? this.box : box);
5956 void SetMousePosition(int x, int y)
5958 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5962 void IntegrationActivate(bool active)
5964 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5966 isForegroundWindow = true;
5967 ActivateEx(active, active, false, false, null, null);
5968 isForegroundWindow = false;
5973 Window QueryCapture(void)
5975 return guiApp.windowCaptured;
5978 int GetDocumentID(void)
5982 byte * idBuffer = new0 byte[size];
5985 for(child = children.first; child; child = child.next)
5987 // TO CHECK: Do we want a documentID when we already have a file name?
5988 if(child.style.isDocument && !child.fileName)
5990 if(child.documentID-1 > size - 2)
5992 idBuffer = renew0 idBuffer byte[size*2];
5993 memset(idBuffer + size, 0, size);
5996 idBuffer[child.documentID-1] = 1;
5999 for(c = 0; c<size; c++)
6007 void SetInitSize(Size size)
6010 sizeAnchor.size = size;
6011 normalSizeAnchor = sizeAnchor;
6013 // Break the anchors for moveable/resizable windows
6014 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6016 stateAnchor = normalAnchor;
6017 stateSizeAnchor = normalSizeAnchor;
6019 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6020 Position(x,y, w, h, true, true, true, true, false, true);
6024 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6026 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6028 guiApp.windowIsResizing = resize;
6029 guiApp.windowMoving = this;
6030 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6031 if(guiApp.windowIsResizing)
6033 guiApp.windowMovingStart.x += size.w - 1;
6034 guiApp.windowMovingStart.y += size.h - 1;
6036 guiApp.windowMovingBefore = scrolledPos;
6037 guiApp.windowResizingBefore = size;
6038 guiApp.windowMoving.UpdateDecorations();
6039 if(guiApp.windowIsResizing)
6040 guiApp.resizeEndX = guiApp.resizeEndY = true;
6042 if(setCursorPosition)
6043 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6047 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6048 guiApp.windowMovingStart.x += x - absPosition.x;
6049 guiApp.windowMovingStart.y += y - absPosition.y;
6052 if(guiApp.windowMoving)
6054 if(guiApp.windowMoving.style.nonClient)
6055 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6057 guiApp.windowMoving.parent.SetMouseRangeToClient();
6062 if(this == rootWindow)
6063 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6071 bool result = false;
6075 else if(guiApp && guiApp.driver != null)
6077 void * systemParent = null;
6078 OldLink slaveHolder;
6080 bool visible = !style.hidden;
6084 systemParent = parent;
6085 parent = guiApp.desktop;
6087 last = parent ? parent.children.last : null;
6089 if((parent && parent != guiApp.desktop && !parent.created) ||
6090 (master && master != guiApp.desktop && !master.created))
6094 stopwatching(parent, font);
6097 property::parent = guiApp.desktop;
6098 if(!master) master = parent;
6100 if(_isModal && master.modalSlave)
6101 property::master = master.modalSlave;
6105 parent.children.Remove(this);
6108 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6109 if(slaveHolder.data == this)
6111 master.slaves.Delete(slaveHolder);
6116 if(parent == guiApp.desktop && !mutex)
6119 if(style.isDocument)
6122 parent.numDocuments--;
6123 documentID = parent.GetDocumentID();
6126 if(!style.stayOnTop)
6127 for(; last && last.style.stayOnTop; last = last.prev);
6129 parent.children.Insert((last == this) ? null : last, this);
6130 //parent.children.Add(this);
6133 dispDriver = parent.dispDriver;
6136 master.modalSlave = this;
6138 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6143 master.slaves.Add(slaveHolder = OldLink { data = this });
6148 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6150 if(style.isDefault && !master.defaultControl)
6151 master.defaultControl = this;
6153 stateAnchor = normalAnchor = anchor;
6154 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6156 // TOCHECK: Why is this here?
6157 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6158 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6160 this.visible = false;
6161 style.hidden = true;
6164 // autoCreate = true;
6172 if(parent == guiApp.desktop)
6173 Log("LoadGraphics %s\n", caption);
6175 if(LoadGraphics(true, false))
6183 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6190 if(style.hasMenuBar /*&& menu*/)
6196 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6197 interim = false, inactive = true, nonClient = true, size.h = 24
6205 // Create the system buttons
6206 CreateSystemChildren();
6208 UpdateActiveDocument(null);
6210 if(style.isDocument)
6214 MenuItem item = menu.FindItem(MenuFileSave, 0);
6215 if(item) item.disabled = !modifiedDocument && fileName;
6220 if(parent == guiApp.desktop)
6221 Log("Preemptive SetState %s\n", caption);
6224 // Preemptive Set State to ensure proper anchoring
6225 SetStateEx(state, false);
6227 style.hidden = true;
6233 for(child = children.first; child; child = next)
6236 if(!child.created && (child.autoCreate || child.wasCreated))
6243 for(link = slaves.first; link; link = next)
6245 Window slave = link.data;
6247 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6250 // Things might have happened that invalidated 'next'...
6251 // Start over the search for slaves to create.
6252 // (Added this to fix crash with Stacker & Toolbar)
6253 next = slaves.first;
6262 if(parent == guiApp.desktop)
6263 Log("Real SetState %s\n", caption);
6266 if(isActiveClient && visible)
6268 parent.numPositions--;
6269 if(state == minimized) parent.numIcons--;
6272 parent.OnChildAddedOrRemoved(this, false);
6274 // Real set state & activate for proper display & activation
6275 property::visible = visible;
6276 // SetState(state & 0x00000003, true, 0);
6277 guiApp.interfaceDriver.SetIcon(this, icon);
6282 /*if(rootWindow == this)
6283 guiApp.interfaceDriver.ActivateRootWindow(this);
6285 if(creationActivation == activate)
6286 ActivateEx(true, false, true, true, null, null);
6287 else if(creationActivation == flash)
6292 rootWindow.ConsequentialMouseMove(false);
6303 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6309 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6311 //style.hidden = true; // !visible;
6312 style.hidden = !visible;
6313 if(master.modalSlave == this)
6314 master.modalSlave = null;
6321 void WriteCaption(Surface surface, int x, int y)
6324 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6327 void Update(Box region)
6333 rootWindow = this.rootWindow;
6335 // rootWindow.mutex.Wait();
6336 if(!destroyed && visible && display)
6341 // Testing this to avoid repetitve full update to take time...
6342 if(dirtyArea.count == 1)
6344 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6345 if(item.box.left <= box.left &&
6346 item.box.top <= box.top &&
6347 item.box.right >= box.right &&
6348 item.box.bottom >= box.bottom)
6350 rootWindow.dirty = true;
6355 if(display.flags.flipping && !rootWindow.dirty)
6357 if(this == rootWindow)
6361 rootWindow.Update(null);
6366 rootWindow.dirty = true;
6371 realBox.left += clientStart.x;
6372 realBox.top += clientStart.y;
6373 realBox.right += clientStart.x;
6374 realBox.bottom += clientStart.y;
6380 if(realBox.right >= realBox.left &&
6381 realBox.bottom >= realBox.top)
6383 // if(!rootWindow.fullRender)
6384 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6386 for(child = children.first; child; child = child.next)
6391 box.left -= child.absPosition.x - absPosition.x;
6392 box.top -= child.absPosition.y - absPosition.y;
6393 box.right -= child.absPosition.x - absPosition.x;
6394 box.bottom -= child.absPosition.y - absPosition.y;
6395 if(box.right >= child.box.left && box.left <= child.box.right &&
6396 box.bottom >= child.box.top && box.top <= child.box.bottom)
6398 box.left -= child.clientStart.x;
6399 box.top -= child.clientStart.y;
6400 box.right -= child.clientStart.x;
6401 box.bottom -= child.clientStart.y;
6407 realBox.left += absPosition.x - rootWindow.absPosition.x;
6408 realBox.top += absPosition.y - rootWindow.absPosition.y;
6409 realBox.right += absPosition.x - rootWindow.absPosition.x;
6410 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6411 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6414 else if(this == guiApp.desktop)
6417 for(window = children.first; window; window = window.next)
6423 Box childBox = region;
6425 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6426 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6427 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6428 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6430 window.Update(childBox);
6433 window.Update(null);
6438 // rootWindow.mutex.Release();
6445 if(guiApp.windowCaptured != this)
6447 if(guiApp.windowCaptured)
6451 //Logf("Captured %s (%s)\n", caption, class.name);
6452 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6453 guiApp.windowCaptured = this;
6459 bool Destroy(int64 code)
6464 if(!destroyed && !CloseConfirmation(false)) return false;
6468 // TOCHECK: Should autoCreate be set to false here?
6479 void Move(int x, int y, int w, int h)
6481 normalAnchor = Anchor { left = x, top = y };
6482 normalSizeAnchor = SizeAnchor { size = { w, h } };
6484 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6486 if(destroyed) return;
6488 stateAnchor = normalAnchor;
6489 stateSizeAnchor = normalSizeAnchor;
6491 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6492 Position(x,y, w, h, true, true, true, true, false, true);
6496 DialogResult Modal(void)
6502 // FIXES MEMORY LEAK IF Create() FAILED
6508 void SetScrollArea(int width, int height, bool snapToStep)
6510 bool resize = false;
6513 int stepX = sbStep.x, stepY = sbStep.y;
6514 // Needed to make snapped down position match the skin's check of client area
6515 // against realvirtual
6518 SNAPDOWN(stepX, textCellW);
6519 SNAPDOWN(stepY, textCellH);
6520 stepX = Max(stepX, textCellW);
6521 stepY = Max(stepY, textCellH);
6523 if(scrollFlags.snapX)
6524 SNAPUP(width, stepX);
6525 if(scrollFlags.snapY)
6526 SNAPUP(height, stepY);
6529 reqScrollArea.w = width;
6530 reqScrollArea.h = height;
6531 noAutoScrollArea = (width > 0 || height > 0);
6533 UpdateScrollBars(true, true);
6536 void SetScrollPosition(int x, int y)
6539 sbh.Action(setPosition, x, 0);
6543 int seen = clientSize.w, total = reqScrollArea.w;
6545 if(scrollFlags.snapX)
6546 SNAPDOWN(seen, sbStep.x);
6548 if(!total) total = seen;
6549 range = total - seen + 1;
6550 range = Max(range, 1);
6552 if(x >= range) x = range - 1;
6554 if(scrollFlags.snapX)
6555 SNAPUP(x, sbStep.x);
6558 OnHScroll(setPosition, x, 0);
6562 SNAPDOWN(x, textCellW);
6568 sbv.Action(setPosition, y, 0);
6572 int seen = clientSize.h, total = reqScrollArea.h;
6575 if(scrollFlags.snapY)
6576 SNAPDOWN(seen, sbStep.y);
6578 if(!total) total = seen;
6579 range = total - seen + 1;
6580 range = Max(range, 1);
6582 if(y >= range) y = range - 1;
6584 if(scrollFlags.snapY)
6585 SNAPUP(y, sbStep.y);
6588 OnVScroll(setPosition, y, 0);
6591 SNAPDOWN(y, textCellH);
6596 UpdateCaret(false, false);
6599 void SetScrollLineStep(int stepX, int stepY)
6605 SNAPDOWN(stepX, textCellW);
6606 SNAPDOWN(stepY, textCellH);
6607 stepX = Max(stepX, textCellW);
6608 stepY = Max(stepY, textCellH);
6611 sbh.lineStep = stepX;
6613 sbv.lineStep = stepY;
6616 void SetState(WindowState newState, bool activate, Modifiers mods)
6620 if(state == newState || OnStateChange(newState, mods))
6622 WindowState prevState = state;
6626 // This used to be at the end of the brackets... moved for X, testing...
6627 // This has the effect of activating the window through the system...
6628 if(rootWindow == this)
6629 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6631 SetStateEx(newState, activate);
6633 if(rootWindow == this && !rootWindow.nativeDecorations)
6635 int x = position.x, y = position.y;
6638 x -= guiApp.desktop.absPosition.x;
6639 y -= guiApp.desktop.absPosition.y;
6641 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6645 //state = prevState;
6647 if(state != maximized && style.hasMaximize)
6650 for(child = parent.children.first; child; child = child.next)
6652 if(child != this && child.state == maximized)
6653 child.SetStateEx(normal, false);
6657 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6658 parent.UpdateScrollBars(true, true);
6661 // Do we really need this stuff here?
6662 // Shouldn't the Activate stuff take care of it?
6663 if(parent.rootWindow == parent && style)
6666 parent.FigureCaption(caption);
6667 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6668 parent.UpdateDecorations();
6672 rootWindow.ConsequentialMouseMove(false);
6679 BitmapResource GetIcon(SkinBitmap iconID)
6681 return guiApp.currentSkin.GetBitmap(iconID);
6684 void SetMouseRange(Box range)
6686 if(range || guiApp.fullScreenMode)
6691 clip.left = range.left + absPosition.x + clientStart.x;
6692 clip.top = range.top + absPosition.y + clientStart.y;
6693 clip.right = range.right + absPosition.x + clientStart.x;
6694 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6698 clip.left = guiApp.desktop.box.left;
6699 clip.top = guiApp.desktop.box.top;
6700 clip.right = guiApp.desktop.box.right;
6701 clip.bottom = guiApp.desktop.box.bottom;
6703 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6706 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6709 void SetMouseRangeToClient(void)
6711 if(guiApp.fullScreenMode || this != guiApp.desktop)
6713 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6714 box.Clip(clientArea);
6718 SetMouseRange(null);
6721 void SetMouseRangeToWindow(void)
6723 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6724 if(this == guiApp.desktop)
6725 SetMouseRangeToClient();
6730 // x, y: Desktop Coordinates
6731 void ShowSysMenu(int x, int y)
6734 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6737 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6738 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6742 menu, $"Move", m, NotifySelect = MenuWindowMove,
6743 disabled = !style.fixed || state == maximized
6747 menu, $"Size", s, NotifySelect = MenuWindowSize,
6748 disabled = !style.sizable || state != normal
6752 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6753 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6757 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6758 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6762 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6763 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6765 MenuDivider { menu };
6768 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6769 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6771 windowMenu.Create();
6776 ActivateEx(true, true, true, true, null, null);
6779 void MakeActive(void)
6781 ActivateEx(true, false, true, false, null, null);
6784 void SoftActivate(void)
6786 if(guiApp.desktop.active)
6792 void Deactivate(void)
6794 ActivateEx(false, true, true, true, null, null);
6799 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6802 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6804 bool result = false;
6805 if(activeChild && activeChild.cycle)
6807 Window modalWindow, child = activeChild;
6808 if(!clientOnly /*&& parent.tabCycle*/)
6810 Window next = child;
6813 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6817 if(parent && parent.CycleChildren(backward, false, true, true))
6825 next = next.cycle.prev.data;
6827 next = next.cycle.next.data;
6828 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6833 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6834 parent.tabCycle && parent.CycleChildren(backward, false, false))
6838 if(tabCycleOnly && !tabCycle) return false;
6845 child = child.cycle.prev.data;
6847 child = child.cycle.next.data;
6848 if(child == child.parent.activeChild)
6850 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6853 modalWindow = child.FindModal();
6856 // Scroll the window to include the active control
6857 if(sbh && !child.style.dontScrollHorz)
6859 if(child.scrolledPos.x < 0)
6860 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6861 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6862 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6864 if(sbv && !child.style.dontScrollVert)
6866 if(child.scrolledPos.y < 0)
6867 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6868 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6869 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6873 child = modalWindow ? modalWindow : child;
6874 child.ActivateEx(true, true, true, true, null, null);
6875 if(child.tabCycle && child.childrenCycle.first)
6876 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6884 ConsequentialMouseMove(false);
6888 void AddResource(Resource resource)
6892 ResPtr ptr { resource = resource };
6896 // Load Graphics here if window is created already
6897 if(/*created && */display)
6899 display.Lock(false);
6900 ptr.loaded = display.displaySystem.LoadResource(resource);
6904 // Temporary hack to load font right away for listbox in dropbox ...
6905 else if(master && master.display)
6907 master.display.Lock(false);
6908 master.display.displaySystem.LoadResource(resource);
6909 master.display.Unlock();
6915 void RemoveResource(Resource resource)
6920 for(ptr = resources.first; ptr; ptr = ptr.next)
6922 if(ptr.resource == resource)
6928 // Unload Graphics here if window is created already
6929 if(/*created && */display)
6933 display.Lock(false);
6934 display.displaySystem.UnloadResource(resource, ptr.loaded);
6940 resources.Delete(ptr);
6945 void SetCaret(int x, int y, int size)
6952 if(active && !style.interim)
6954 if(visible || !guiApp.caretOwner)
6955 guiApp.caretOwner = size ? this : null;
6957 UpdateCaret(false, false);
6960 guiApp.interfaceDriver.SetCaret(0,0,0);
6961 UpdateCaret(false, true);
6962 guiApp.caretEnabled = false;
6965 else if(style.inactive && active)
6967 guiApp.interfaceDriver.SetCaret(0,0,0);
6968 UpdateCaret(false, true);
6969 guiApp.caretEnabled = false;
6974 void Scroll(int x, int y)
6976 bool opaque = !style.drawBehind || background.a;
6977 if(opaque && display && display.flags.scrolling)
6979 Box box = clientArea;
6980 box.left += clientStart.x;
6981 box.top += clientStart.y;
6982 box.right += clientStart.x;
6983 box.bottom += clientStart.y;
6985 //scrollExtent.Free(null);
6986 scrollExtent.AddBox(box);
6987 scrolledArea.x += x;
6988 scrolledArea.y += y;
6990 //scrollExtent.Free();
6991 //scrollExtent.AddBox(clientArea);
6992 //scrollExtent.Offset(clientStart.x, clientStart.y);
6993 //scrolledArea.x = x;
6994 //scrolledArea.y = y;
7000 rootWindow.dirty = true;
7003 void ReleaseCapture()
7005 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7007 Window oldCaptured = guiApp.windowCaptured;
7008 guiApp.windowCaptured = null;
7009 guiApp.prevWindow = null;
7012 //guiApp.Log("Released Capture\n");
7014 guiApp.interfaceDriver.SetMouseCapture(null);
7016 //oldCaptured.OnMouseCaptureLost();
7019 oldCaptured.ConsequentialMouseMove(false);
7024 private void _SetCaption(char * format, va_list args)
7031 char caption[MAX_F_STRING];
7032 vsnprintf(caption, sizeof(caption), format, args);
7033 caption[sizeof(caption)-1] = 0;
7035 this.caption = CopyString(caption);
7040 firewatchers caption;
7044 /*deprecated*/ void SetText(char * format, ...)
7047 va_start(args, format);
7048 _SetCaption(format, args);
7052 void SetCaption(char * format, ...)
7055 va_start(args, format);
7056 _SetCaption(format, args);
7060 bool Grab(Bitmap bitmap, Box box, bool decorations)
7062 bool result = false;
7063 if(display || this == guiApp.desktop)
7065 Box clip = {MININT, MININT, MAXINT, MAXINT};
7071 clip.Clip(clientArea);
7073 clip.Clip(this.box);
7075 if(rootWindow != this)
7077 clip.left += absPosition.y;
7078 clip.top += absPosition.y;
7079 clip.right += absPosition.x;
7080 clip.bottom += absPosition.y;
7083 clip.left += decorations ? 0 : clientStart.x;
7084 clip.top += decorations ? 0 : clientStart.y;
7085 clip.right += decorations ? 0 : clientStart.x;
7086 clip.bottom += decorations ? 0 : clientStart.y;
7088 if(display && display.flags.flipping)
7090 rootWindow.Update(null);
7091 rootWindow.UpdateDisplay();
7098 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7099 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7103 result = display.Grab(bitmap, clip.left, clip.top,
7104 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7106 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7108 if(!bitmap.Convert(null, pixelFormat888, null))
7115 void GetMousePosition(int * x, int * y)
7117 int mouseX = 0, mouseY = 0;
7118 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7121 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7122 if(this != guiApp.desktop)
7124 mouseX -= absPosition.x + clientStart.x;
7125 mouseY -= absPosition.y + clientStart.y;
7132 DialogResult DoModal()
7134 DialogResult returnCode = 0;
7135 int terminated = terminateX;
7138 while(!destroyed && guiApp.driver != null)
7140 if(terminateX != terminated)
7142 terminated = terminateX;
7143 guiApp.desktop.Destroy(0);
7144 if(guiApp.desktop.created)
7147 //printf("Resetting terminate X to 0\n");
7153 guiApp.UpdateDisplay();
7154 if(!guiApp.ProcessInput(false))
7157 returnCode = this.returnCode;
7170 return !destroyed && guiApp.driver != null && terminateX < 2;
7173 DialogResult DoModalEnd()
7175 DialogResult returnCode = this.returnCode;
7180 // --- Window manipulation ---
7181 /*bool GetDisabled()
7183 bool disabled = this.disabled;
7185 for(window = this; (window = window.master); )
7196 // --- Mouse Manipulation ---
7197 void GetNCMousePosition(int * x, int * y)
7199 GetMousePosition(x, y);
7200 if(x) *x += clientStart.x;
7201 if(y) *y += clientStart.y;
7204 // --- Carets manipulation ---
7205 void GetCaretPosition(Point caretPos)
7207 caretPos = this.caretPos;
7210 int GetCaretSize(void)
7215 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7221 bool CloseConfirmation(bool parentClosing)
7234 if(!OnClose(parentClosing))
7237 // If you want to skip this, simply set modifiedDocument to false in OnClose
7238 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7240 DialogResult dialogRes;
7243 sprintf(message, $"Save changes to %s?", fileName);
7245 sprintf(message, $"Save changes to Untitled %d?", documentID);
7247 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7249 if(dialogRes == yes)
7251 // TOFIX: Precomp error if brackets are taken out
7252 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7254 else if(dialogRes == cancel)
7260 for(slave = slaves.first; slave; slave = slave.next)
7262 Window w = slave.data;
7263 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7265 // ((Window)slave.data).CloseConfirmation(true);
7274 for(child = children.first; child; child = child.next)
7275 if(child.master != this && !child.CloseConfirmation(true))
7285 // Static methods... move them somewhere else?
7286 void ::RestoreCaret()
7288 if(guiApp.caretOwner)
7289 guiApp.caretOwner.UpdateCaret(false, false);
7292 void ::FreeMouseRange()
7294 guiApp.interfaceDriver.SetMouseRange(null, null);
7298 bool MenuFileClose(MenuItem selection, Modifiers mods)
7300 Window document = activeChild;
7302 document.Destroy(0);
7306 bool MenuFileExit(MenuItem selection, Modifiers mods)
7312 bool MenuFileSave(MenuItem selection, Modifiers mods)
7316 fileMonitor.fileName = null;
7319 if(OnSaveFile(fileName))
7321 //if(OnFileModified != Window::OnFileModified)
7324 fileMonitor.fileName = fileName;
7330 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7331 DialogResult answer = dialog.Modal();
7333 if(answer != yes) return (bool)answer;
7336 return MenuFileSaveAs(selection, mods);
7339 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7341 DialogResult result = (DialogResult)bool::true;
7342 FileDialog fileDialog = saveDialog;
7345 fileDialog = FileDialog {};
7350 fileDialog.filePath = fileName;
7353 char filePath[MAX_FILENAME];
7354 sprintf(filePath, "Untitled %d", documentID);
7355 fileDialog.filePath = filePath;
7357 fileMonitor.fileName = null;
7359 fileDialog.type = save;
7360 fileDialog.text = $"Save As";
7364 fileDialog.master = master.parent ? master : this;
7365 if(fileDialog.Modal() == ok)
7367 char * filePath = fileDialog.filePath;
7369 if(OnSaveFile(filePath))
7372 property::fileName = filePath;
7373 NotifySaved(master, this, filePath);
7378 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7379 DialogResult answer = dialog.Modal();
7394 //if(OnFileModified != Window::OnFileModified && fileName)
7397 fileMonitor.fileName = fileName;
7401 return (bool)result; // Actually returning result from Yes/NoCancel message box
7404 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7406 Window document = activeChild;
7408 for(document = children.first; document; document = next)
7410 next = document.next;
7411 if(document.style.isDocument || document.fileName)
7412 document.MenuFileSave(selection, mods);
7417 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7421 for(document = children.first; document; document = document.next)
7422 //if(document.style.isDocument && document.state == minimized)
7423 if(document.style.isActiveClient && document.state == minimized)
7424 document.SetState(minimized, false, mods);
7428 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7430 Window document = activeChild;
7433 Window firstDocument = null;
7435 OldLink cycle = document.cycle.prev;
7440 if(child.style.isActiveClient && !child.style.hidden)
7444 firstDocument = child;
7445 if(child.state == minimized)
7446 child.SetState(minimized, false, mods);
7449 child.positionID = id++;
7450 child.SetState(normal, false, mods);
7451 child.anchor.left.type = cascade;
7454 child.normalSizeAnchor = *&child.sizeAnchor;
7455 child.normalAnchor = child.anchor;
7457 // Break the anchors for moveable/resizable windows
7458 if(child.style.fixed)
7460 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7462 (*&child.normalAnchor).left = x;
7463 (*&child.normalAnchor).top = y;
7464 (*&child.normalAnchor).right.type = none;
7465 (*&child.normalAnchor).bottom.type = none;
7467 child.normalSizeAnchor.isClientW = false;
7468 child.normalSizeAnchor.isClientH = false;
7469 child.normalSizeAnchor.size.w = w;
7470 child.normalSizeAnchor.size.h = h;
7471 child.anchored = false;
7474 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7476 child.stateAnchor = child.normalAnchor;
7477 child.stateSizeAnchor = child.normalSizeAnchor;
7479 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7480 child.Position(x, y, w, h, true, true, true, true, false, false);
7485 last = children.last;
7486 if(!child.style.stayOnTop)
7487 for(; last && last.style.stayOnTop; last = last.prev);
7488 children.Move(child, last);
7489 childrenOrder.Move(child.order, childrenOrder.last);
7491 if(cycle == document.cycle) break;
7495 firstDocument.Activate();
7500 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7507 // Close all closes all active clients, not all documents
7508 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7510 Window next, document;
7512 for(document = children.first; document; document = next)
7514 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7515 if(document.style.isActiveClient)
7516 if(!document.Destroy(0) && !document.style.hidden)
7522 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7524 if(style.hasMaximize && state != maximized)
7525 SetState(maximized, 0, 0);
7529 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7531 if(style.hasMinimize && state != minimized)
7533 SetState(minimized, 0, 0);
7534 parent.CycleChildren(false, true, false, true);
7539 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7541 MenuMoveOrSize(false, selection ? true : false);
7545 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7547 CycleChildren(false, true, false, true);
7551 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7553 CycleChildren(true, true, false, true);
7557 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7559 MenuMoveOrSize(true, true);
7563 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7566 SetState(normal, 0, 0);
7570 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7573 int64 id = selection.id;
7574 OldLink cycle = activeClient.cycle;
7576 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7579 Window sibling = cycle.data;
7580 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7588 document = cycle.data;
7589 document.Activate();
7591 //if(activeChild.state == maximized)
7592 // document.SetState(maximized, false, mods);
7593 //else if(document.state == minimized)
7594 // document.SetState(normal, false, mods);
7598 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7600 stayOnTop = !style.stayOnTop;
7604 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7606 Window document = activeChild;
7609 Window firstDocument = null;
7610 OldLink cycle = document.cycle;
7614 Window child = cycle.data;
7615 if(child.style.isActiveClient && !child.style.hidden)
7617 if(!firstDocument) firstDocument = child;
7618 if(child.state == minimized)
7619 child.SetState(minimized, false, mods);
7622 child.positionID = id++;
7623 child.SetState(normal, false, mods);
7624 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7626 child.anchor.left.type = hTiled;
7629 child.normalSizeAnchor = *&child.sizeAnchor;
7630 child.normalAnchor = child.anchor;
7632 // Break the anchors for moveable/resizable windows
7633 if(child.style.fixed)
7635 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7637 (*&child.normalAnchor).left = x;
7638 (*&child.normalAnchor).top = y;
7639 (*&child.normalAnchor).right.type = none;
7640 (*&child.normalAnchor).bottom.type = none;
7641 child.normalSizeAnchor.isClientW = false;
7642 child.normalSizeAnchor.isClientH = false;
7643 child.normalSizeAnchor.size.w = w;
7644 child.normalSizeAnchor.size.h = h;
7645 child.anchored = false;
7648 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7650 child.stateAnchor = child.normalAnchor;
7651 child.stateSizeAnchor = child.normalSizeAnchor;
7653 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7654 child.Position(x,y, w, h, true, true, true, true, false, true);
7659 if((cycle = cycle.next) == document.cycle) break;
7662 firstDocument.Activate();
7667 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7669 Window document = activeChild;
7672 Window firstDocument = null;
7674 OldLink cycle = document.cycle;
7679 //if(child.style.isDocument)
7680 if(child.style.isActiveClient && !child.style.hidden)
7682 if(!firstDocument) firstDocument = child;
7683 if(child.state == minimized)
7684 child.SetState(minimized, false, mods);
7687 child.positionID = id++;
7688 child.SetState(normal, false, mods);
7689 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7691 child.anchor.left.type = vTiled;
7694 child.normalSizeAnchor = *&child.sizeAnchor;
7695 child.normalAnchor = child.anchor;
7697 // Break the anchors for moveable/resizable windows
7698 if(child.style.fixed)
7700 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7702 (*&child.normalAnchor).left = x;
7703 (*&child.normalAnchor).top = y;
7704 (*&child.normalAnchor).right.type = none;
7705 (*&child.normalAnchor).bottom.type = none;
7706 child.normalSizeAnchor.isClientW = false;
7707 child.normalSizeAnchor.isClientH = false;
7708 child.normalSizeAnchor.size.w = w;
7709 child.normalSizeAnchor.size.h = h;
7710 child.anchored = false;
7713 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7715 child.stateAnchor = child.normalAnchor;
7716 child.stateSizeAnchor = child.normalSizeAnchor;
7718 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7719 child.Position(x,y, w, h, true, true, true, true, false, true);
7724 if((cycle = cycle.next) == document.cycle) break;
7727 firstDocument.Activate();
7732 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7734 WindowList dialog { master = this };
7735 Window document = (Window)dialog.Modal();
7738 if(activeChild.state == maximized)
7739 document.SetState(maximized, false, mods);
7740 else if(document.state == minimized)
7741 document.SetState(normal, false, mods);
7742 document.Activate();
7748 virtual bool OnCreate(void);
7749 virtual void OnDestroy(void);
7750 virtual void OnDestroyed(void);
7751 virtual bool OnClose(bool parentClosing);
7752 virtual bool OnStateChange(WindowState state, Modifiers mods);
7753 virtual bool OnPostCreate(void);
7754 virtual bool OnMoving(int *x, int *y, int w, int h);
7755 virtual bool OnResizing(int *width, int *height);
7756 virtual void OnResize(int width, int height);
7757 virtual void OnPosition(int x, int y, int width, int height);
7758 virtual bool OnLoadGraphics(void);
7759 virtual void OnApplyGraphics(void);
7760 virtual void OnUnloadGraphics(void);
7761 virtual void OnRedraw(Surface surface);
7762 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7763 virtual void OnActivateClient(Window client, Window previous);
7764 virtual bool OnKeyDown(Key key, unichar ch);
7765 virtual bool OnKeyUp(Key key, unichar ch);
7766 virtual bool OnKeyHit(Key key, unichar ch);
7767 virtual bool OnSysKeyDown(Key key, unichar ch);
7768 virtual bool OnSysKeyUp(Key key, unichar ch);
7769 virtual bool OnSysKeyHit(Key key, unichar ch);
7770 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7771 virtual bool OnMouseLeave(Modifiers mods);
7772 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7773 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7774 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7775 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7776 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7777 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7778 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7779 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7780 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7781 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7782 virtual void OnMouseCaptureLost(void);
7783 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7784 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7785 virtual void OnDrawOverChildren(Surface surface);
7786 virtual bool OnFileModified(FileChange fileChange, char * param);
7787 virtual bool OnSaveFile(char * fileName);
7789 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7790 // Note: A 'client' would refer to isActiveClient, rather than
7791 // being confined to the 'client area' (nonClient == false)
7792 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7793 virtual void OnChildVisibilityToggled(Window child, bool visible);
7794 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7796 // Skins Virtual Functions
7797 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7798 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7799 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7804 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7805 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7806 virtual bool IsMouseMoving(int x, int y, int w, int h)
7810 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7814 virtual void UpdateNonClient();
7815 virtual void SetBox(Box box); // This is used in the MySkin skin
7816 virtual bool IsInside(int x, int y)
7818 return box.IsPointInside({x, y});
7820 virtual bool IsOpaque()
7822 return (!style.drawBehind || background.a == 255);
7826 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7827 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7828 virtual void Window::NotifySaved(Window window, char * filePath);
7833 property Window parent
7835 property_category $"Layout"
7838 if(value || guiApp.desktop)
7841 Window oldParent = parent;
7842 Anchor anchor = this.anchor;
7844 if(value && value.IsDescendantOf(this)) return;
7845 if(value && value == this)
7847 if(!value) value = guiApp.desktop;
7849 if(value == oldParent) return;
7851 if(!master || (master == this.parent && master == guiApp.desktop))
7852 property::master = value;
7856 parent.children.Remove(this);
7860 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7861 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7862 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7863 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7867 last = value.children.last;
7869 if(style.isDocument)
7872 parent.numDocuments--;
7873 documentID = value.GetDocumentID();
7876 if(style.isActiveClient && !style.hidden)
7878 if(parent && parent != guiApp.desktop && !(style.hidden))
7880 if(state == minimized) parent.numIcons--;
7881 parent.numPositions--;
7885 if(!style.stayOnTop)
7886 for(; last && last.style.stayOnTop; last = last.prev);
7888 value.children.Insert(last, this);
7890 // *** NEW HERE: ***
7892 parent.childrenCycle.Delete(cycle);
7894 parent.childrenOrder.Delete(order);
7897 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7898 // Should something else be done?
7899 if(parent && parent.activeChild == this)
7900 parent.activeChild = null;
7901 if(parent && parent.activeClient == this)
7902 parent.activeClient = null;
7908 int x = position.x, y = position.y, w = size.w, h = size.h;
7912 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7913 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7915 vpw = value.clientSize.w;
7916 vph = value.clientSize.h;
7922 else if(style.fixed)
7924 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7925 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7928 anchor = this.anchor;
7930 if(anchor.left.type == offset) anchor.left.distance = x;
7931 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7932 if(anchor.top.type == offset) anchor.top.distance = y;
7933 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7934 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7935 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7936 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7937 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7938 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7939 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7941 if(!anchor.left.type && !anchor.right.type)
7943 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7944 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7946 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7947 if(!anchor.top.type && !anchor.bottom.type)
7949 anchor.vert.distance = (y + h / 2) - (vph / 2);
7950 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7952 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7955 parent.OnChildAddedOrRemoved(this, false);
7961 parent.childrenCycle.Insert(
7962 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7963 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7965 cycle = OldLink { data = this });
7966 parent.childrenOrder.Insert(
7967 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7968 order = OldLink { data = this });
7971 if(!style.hidden && style.isActiveClient)
7973 positionID = parent.GetPositionID(this);
7974 parent.numPositions++;
7975 if(state == minimized) parent.numIcons--;
7978 // *** FONT INHERITANCE ***
7979 if(!setFont && oldParent)
7980 stopwatching(oldParent, font);
7984 RemoveResource(systemFont);
7987 // TESTING WITH WATCHERS:
7988 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7989 // usedFont = setFont ? setFont : (systemFont);
7993 if(guiApp.currentSkin)
7995 systemFont = guiApp.currentSkin.SystemFont();
7998 usedFont = systemFont;
7999 AddResource(systemFont);
8007 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8016 if(value.rootWindow && value.rootWindow.display && rootWindow)
8018 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8019 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8022 UnloadGraphics(false);
8025 LoadGraphics(false, false);
8028 if(value.rootWindow != rootWindow)
8029 DisplayModeChanged();
8033 scrolledPos.x = MININT; // Prevent parent update
8035 bool anchored = this.anchored;
8036 property::anchor = anchor;
8037 this.anchored = anchored;
8042 if(guiApp.currentSkin)
8043 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8045 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8046 Position(x, y, w, h, true, true, true, true, false, true);
8051 // else parent = value;
8053 oldParent.OnChildAddedOrRemoved(this, true);
8056 get { return parent; }
8059 property Window master
8061 property_category $"Behavior"
8064 //if(this == value) return;
8065 if(value && value.IsSlaveOf(this)) return;
8071 OldLink slaveHolder;
8072 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8073 if(slaveHolder.data == this)
8075 master.slaves.Delete(slaveHolder);
8082 value.slaves.Add(OldLink { data = this });
8087 master.hotKeys.Remove(hotKey);
8088 value.hotKeys.Add(hotKey);
8091 if(master && master.defaultControl == this)
8092 master.defaultControl = null;
8094 if(style.isDefault && !value.defaultControl)
8095 value.defaultControl = this;
8100 get { return master ? master : parent; }
8103 property char * caption
8105 property_category $"Appearance"
8112 caption = new char[strlen(value)+1];
8114 strcpy(caption, value);
8119 get { return caption; }
8124 property_category $"Behavior"
8133 master.hotKeys.Add(hotKey = HotKeySlot { });
8137 hotKey.window = this;
8142 master.hotKeys.Delete(hotKey);
8147 get { return hotKey ? hotKey.key : 0; }
8150 property Color background
8152 property_category $"Appearance"
8155 background.color = value;
8160 if(this == rootWindow)
8161 guiApp.interfaceDriver.SetRootWindowColor(this);
8164 get { return background.color; }
8167 property Percentage opacity
8169 property_category $"Appearance"
8172 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8173 drawBehind = (background.a == 255) ? false : true;
8175 get { return background.a / 255.0f; }
8178 property Color foreground
8180 property_category $"Appearance"
8188 get { return foreground; }
8191 property BorderStyle borderStyle
8193 property_category $"Appearance"
8196 if(!((BorderBits)value).fixed)
8198 style.hasClose = false;
8199 style.hasMaximize = false;
8200 style.hasMinimize = false;
8201 nativeDecorations = false;
8203 style.borderBits = value;
8207 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8209 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8210 Position(x, y, w, h, true, true, true, true, false, true);
8211 CreateSystemChildren();
8214 get { return (BorderStyle)style.borderBits; }
8217 property Size minClientSize
8219 property_category $"Layout"
8220 set { minSize = value; }
8221 get { value = minSize; }
8224 property Size maxClientSize
8226 property_category $"Layout"
8227 set { maxSize = value; }
8228 get { value = maxSize; }
8231 property bool hasMaximize
8233 property_category $"Window Style"
8236 style.hasMaximize = value;
8237 if(value) { style.fixed = true; style.contour = true; }
8241 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8243 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8244 Position(x, y, w, h, true, true, true, true, false, true);
8246 CreateSystemChildren();
8249 get { return style.hasMaximize; }
8252 property bool hasMinimize
8254 property_category $"Window Style"
8257 style.hasMinimize = value;
8258 if(value) { style.fixed = true; style.contour = true; }
8262 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8264 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8265 Position(x, y, w, h, true, true, true, true, false, true);
8267 CreateSystemChildren();
8270 get { return style.hasMinimize; }
8273 property bool hasClose
8275 property_category $"Window Style"
8278 style.hasClose = value;
8279 if(value) { style.fixed = true; style.contour = true; }
8283 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8284 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8285 Position(x, y, w, h, true, true, true, true, false, true);
8286 CreateSystemChildren();
8289 get { return style.hasClose; }
8292 property bool nonClient
8294 property_category $"Layout"
8297 style.nonClient = value;
8299 style.stayOnTop = true;
8301 get { return style.nonClient; }
8304 property bool inactive
8306 property_category $"Behavior"
8311 // *** NEW HERE: ***
8315 parent.childrenCycle.Delete(cycle);
8317 parent.childrenOrder.Delete(order);
8324 active = false; // true;
8325 if(parent.activeChild == this)
8326 parent.activeChild = null;
8327 if(parent.activeClient == this)
8328 parent.activeClient = null;
8337 parent.childrenCycle.Insert(
8338 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8339 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8341 cycle = OldLink { data = this });
8343 parent.childrenOrder.Insert(
8344 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8345 order = OldLink { data = this });
8348 style.inactive = value;
8350 get { return style.inactive; }
8353 property bool clickThrough
8355 property_category $"Behavior"
8356 set { style.clickThrough = value; }
8357 get { return style.clickThrough; }
8360 property bool isRemote
8362 property_category $"Behavior"
8363 set { style.isRemote = value; }
8364 get { return style.isRemote; }
8367 property bool noCycle
8369 property_category $"Behavior"
8370 set { style.noCycle = value; }
8371 get { return style.noCycle; }
8374 property bool isModal
8376 property_category $"Behavior"
8377 set { style.modal = value; }
8378 get { return style.modal; }
8381 property bool interim
8383 property_category $"Behavior"
8384 set { style.interim = value; }
8385 get { return style.interim; }
8388 property bool tabCycle
8390 property_category $"Behavior"
8391 set { style.tabCycle = value; }
8392 get { return style.tabCycle; }
8395 property bool isDefault
8397 property_category $"Behavior"
8405 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8406 if(sibling != this && sibling.style.isDefault)
8407 sibling.style.isDefault = false;*/
8408 if(master.defaultControl)
8409 master.defaultControl.style.isDefault = false;
8410 master.defaultControl = this;
8412 else if(master.defaultControl == this)
8413 master.defaultControl = null;
8417 style.isDefault = value;
8419 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8421 get { return style.isDefault; }
8424 property bool drawBehind
8426 property_category $"Window Style"
8427 set { style.drawBehind = value; }
8428 get { return style.drawBehind; }
8431 property bool hasMenuBar
8433 property_category $"Window Style"
8443 if(created && !menuBar)
8450 anchor = Anchor { top = 23, left = 1, right = 1 },
8452 inactive = true, nonClient = true
8457 else if(created && menuBar)
8462 style.hasMenuBar = value;
8464 get { return style.hasMenuBar; }
8467 property bool hasStatusBar
8469 property_category $"Window Style"
8476 statusBar = StatusBar { this };
8484 style.hasStatusBar = value;
8486 get { return style.hasStatusBar; }
8488 property bool stayOnTop
8490 property_category $"Window Style"
8495 if(created && !style.stayOnTop)
8497 if(rootWindow == this)
8498 guiApp.interfaceDriver.OrderRootWindow(this, true);
8499 else if(parent.children.last != this)
8501 parent.children.Move(this, parent.children.last);
8505 style.stayOnTop = true;
8509 if(created && style.stayOnTop)
8511 if(rootWindow == this)
8512 guiApp.interfaceDriver.OrderRootWindow(this, false);
8519 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8520 order && ((Window)order.data).style.stayOnTop;
8521 order = (order == parent.childrenOrder.first) ? null : order.prev);
8522 last = order ? order.data : null;
8526 for(last = parent.children.last;
8527 last && last.style.stayOnTop;
8531 parent.children.Move(this, last);
8535 style.stayOnTop = false;
8538 get { return style.stayOnTop; }
8543 property_category $"Window Style"
8553 if(menuBar && !value)
8560 if(!menuBar && style.hasMenuBar && value)
8564 this, menu = value, isMenuBar = true,
8565 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8566 inactive = true, nonClient = true
8570 UpdateActiveDocument(null);
8573 get { return menu; }
8576 property FontResource font
8578 property_category $"Appearance"
8580 isset { return setFont ? true : false; }
8585 if(value && !setFont) { stopwatching(parent, font); }
8586 else if(!value && setFont)
8592 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8601 RemoveResource(setFont);
8606 RemoveResource(systemFont);
8613 AddResource(setFont);
8616 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8619 systemFont = guiApp.currentSkin.SystemFont();
8621 usedFont = systemFont;
8622 AddResource(systemFont);
8630 get { return usedFont; }
8633 property SizeAnchor sizeAnchor
8635 property_category $"Layout"
8638 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8639 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8640 sizeAnchor.isClientW != sizeAnchor.isClientH;
8647 normalSizeAnchor = sizeAnchor;
8649 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8651 stateAnchor = normalAnchor;
8652 stateSizeAnchor = normalSizeAnchor;
8654 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8655 Position(x,y, w, h, true, true, true, true, false, true);
8662 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8663 sizeAnchor.isClientW,
8664 sizeAnchor.isClientH
8671 property_category $"Layout"
8674 Anchor thisAnchor = anchor;
8675 SizeAnchor thisSizeAnchor = sizeAnchor;
8676 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8677 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8678 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8679 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8680 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8681 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8687 sizeAnchor.isClientW = false;
8688 sizeAnchor.isClientH = false;
8689 sizeAnchor.size = value;
8691 normalSizeAnchor = sizeAnchor;
8693 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8695 stateAnchor = normalAnchor;
8696 stateSizeAnchor = normalSizeAnchor;
8698 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8699 Position(x, y, w, h, true, true, true, true, false, true);
8700 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8703 get { value = size; }
8706 property Size clientSize
8708 property_category $"Layout"
8711 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8712 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8713 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8718 sizeAnchor.isClientW = true;
8719 sizeAnchor.isClientH = true;
8720 sizeAnchor.size = value;
8722 normalSizeAnchor = sizeAnchor;
8724 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8726 stateAnchor = normalAnchor;
8727 stateSizeAnchor = normalSizeAnchor;
8729 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8730 Position(x,y, w, h, true, true, true, true, false, true);
8731 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8734 get { value = this ? clientSize : { 0, 0 }; }
8737 property Size initSize { get { value = sizeAnchor.size; } };
8739 property Anchor anchor
8741 property_category $"Layout"
8742 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8748 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8750 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8751 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8753 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8755 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8756 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8760 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8762 anchor.left.distance = 0;
8763 anchor.horz.type = 0;
8765 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8767 anchor.top.distance = 0;
8768 anchor.vert.type = 0;
8777 normalAnchor = anchor;
8779 // Break the anchors for moveable/resizable windows
8780 /*if(style.fixed ) //&& value.left.type == cascade)
8782 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8784 this.anchor = normalAnchor = Anchor { left = x, top = y };
8785 normalSizeAnchor = SizeAnchor { { w, h } };
8788 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8790 stateAnchor = normalAnchor;
8791 stateSizeAnchor = normalSizeAnchor;
8793 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8794 Position(x, y, w, h, true, true, true, true, false, true);
8803 get { value = this ? anchor : Anchor { }; }
8806 property Point position
8808 property_category $"Layout"
8811 if(value == null) return;
8813 anchor.left = value.x;
8814 anchor.top = value.y;
8815 anchor.right.type = none;
8816 anchor.bottom.type = none;
8821 normalAnchor = anchor;
8823 // Break the anchors for moveable/resizable windows
8827 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8829 normalAnchor.left = x;
8830 normalAnchor.top = y;
8831 normalAnchor.right.type = none;
8832 normalAnchor.bottom.type = none;
8833 normalSizeAnchor.size.width = w;
8834 normalSizeAnchor.size.height = h;
8838 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8840 stateAnchor = normalAnchor;
8841 stateSizeAnchor = normalSizeAnchor;
8843 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8844 Position(x,y, w, h, true, true, true, true, false, true);
8848 get { value = position; }
8851 property bool disabled
8853 property_category $"Behavior"
8856 if(this && disabled != value)
8863 get { return (bool)disabled; }
8866 property bool isEnabled
8871 for(parent = this; parent; parent = parent.parent)
8878 property WindowState state
8880 property_category $"Behavior"
8881 set { SetState(value, false, 0); }
8882 get { return this ? state : 0; }
8885 property bool visible
8887 property_category $"Behavior"
8890 if(this && !value && !style.hidden && parent)
8892 bool wasActiveChild = parent.activeChild == this;
8893 Window client = null;
8895 style.hidden = true;
8896 if(style.isActiveClient)
8898 parent.numPositions--;
8899 if(state == minimized) parent.numIcons--;
8904 OldLink prevOrder = null;
8906 if(rootWindow == this)
8907 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8910 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8913 box.left -= parent.clientStart.x;
8914 box.top -= parent.clientStart.y;
8915 box.right -= parent.clientStart.x;
8916 box.bottom -= parent.clientStart.y;
8920 if(_isModal && master && master.modalSlave == this)
8921 master.modalSlave = null;
8925 OldLink tmpPrev = order.prev;
8926 client = tmpPrev ? tmpPrev.data : null;
8927 if(client && !client.style.hidden && !client.destroyed && client.created)
8928 prevOrder = tmpPrev;
8931 client = tmpPrev ? tmpPrev.data : null;
8932 if(client == this) { client = null; break; }
8933 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8935 tmpPrev = client.order.prev;
8940 prevOrder = tmpPrev;
8945 // If this window can be an active client, make sure the next window we activate can also be one
8946 if(!style.nonClient && style.isActiveClient)
8948 tmpPrev = prevOrder;
8951 client = tmpPrev ? tmpPrev.data : null;
8952 if(client == this) { client = null; break; }
8953 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8955 tmpPrev = client.order.prev;
8960 prevOrder = tmpPrev;
8964 if(client && client.style.hidden) client = null;
8968 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8970 if(order && prevOrder && prevOrder.data != this)
8971 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8973 ActivateEx(false, false, false, true, null, null);
8975 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8976 if(parent.activeClient == this)
8978 parent.activeClient = null;
8979 parent.UpdateActiveDocument(null);
8982 else if(parent.activeClient == this)
8984 parent.activeClient = client;
8985 parent.UpdateActiveDocument(this);
8988 // *** Not doing this anymore ***
8991 parent.childrenCycle.Delete(cycle);
8993 parent.childrenOrder.Delete(order);
8998 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9003 else if(this && value && style.hidden)
9005 style.hidden = false;
9008 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9009 if(rootWindow == this)
9010 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9012 if(_isModal && master)
9013 master.modalSlave = this;
9015 if(style.isActiveClient)
9017 positionID = parent.GetPositionID(this);
9018 parent.numPositions++;
9019 if(state == minimized) parent.numIcons++;
9022 // *** NOT DOING THIS ANYMORE ***
9024 if(!(style.inactive))
9026 if(!(style.noCycle))
9028 cycle = parent.childrenCycle.AddAfter(
9029 (parent.activeChild && parent.activeChild.cycle) ?
9030 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9033 order = parent.childrenOrder.AddAfter(
9034 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9041 if(true || !parent.activeChild)
9042 ActivateEx(true, false, true, true, null, null);
9044 if(creationActivation == activate)
9045 ActivateEx(true, false, true, true, null, null);
9046 else if(creationActivation == flash && !object)
9049 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9053 ConsequentialMouseMove(false);
9059 style.hidden = !value;
9062 get { return (style.hidden || !setVisible) ? false : true; }
9065 property bool isDocument
9067 property_category $"Document"
9068 set { style.isDocument = value; }
9069 get { return style.isDocument; }
9072 property bool mergeMenus
9074 property_category $"Window Style"
9075 set { mergeMenus = value; }
9076 get { return (bool)mergeMenus; }
9079 property bool hasHorzScroll
9081 property_category $"Window Style"
9086 if(!style.hasHorzScroll && created)
9088 CreateSystemChildren();
9089 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9092 else if(style.hasHorzScroll)
9096 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9098 style.hasHorzScroll = value;
9101 get { return style.hasHorzScroll; }
9104 property bool hasVertScroll
9106 property_category $"Window Style"
9111 if(!style.hasVertScroll && created)
9113 style.hasVertScroll = true;
9114 CreateSystemChildren();
9115 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9118 else if(style.hasVertScroll)
9122 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9124 style.hasVertScroll = value;
9126 get { return style.hasVertScroll; }
9129 property bool dontHideScroll
9131 property_category $"Behavior"
9134 scrollFlags.dontHide = value;
9137 //UpdateScrollBars(true, true);
9138 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9142 // UpdateScrollBars(true, true);
9143 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9146 get { return scrollFlags.dontHide; }
9149 property bool dontScrollVert
9151 property_category $"Behavior"
9152 set { style.dontScrollVert = value; }
9153 get { return style.dontScrollVert; }
9155 property bool dontScrollHorz
9157 property_category $"Behavior"
9158 set { style.dontScrollHorz = value; }
9159 get { return style.dontScrollHorz; }
9162 property bool snapVertScroll
9164 property_category $"Behavior"
9167 scrollFlags.snapY = value;
9168 if(sbv) sbv.snap = value;
9170 get { return scrollFlags.snapY; }
9172 property bool snapHorzScroll
9174 property_category $"Behavior"
9177 scrollFlags.snapX = value;
9178 if(sbh) sbh.snap = value;
9180 get { return scrollFlags.snapX; }
9183 property Point scroll
9185 property_category $"Behavior"
9186 set { if(this) SetScrollPosition(value.x, value.y); }
9187 get { value = scroll; }
9190 property bool modifyVirtualArea
9192 property_category $"Behavior"
9193 set { modifyVirtArea = value; }
9194 get { return (bool)modifyVirtArea; }
9197 property bool dontAutoScrollArea
9199 property_category $"Behavior"
9200 // Activating a child control out of view will automatically scroll to make it in view
9201 set { noAutoScrollArea = value; }
9202 get { return (bool)noAutoScrollArea; }
9205 property char * fileName
9207 property_category $"Document"
9210 if(menu && ((!fileName && value) || (fileName && !value)))
9212 MenuItem item = menu.FindItem(MenuFileSave, 0);
9213 if(item) item.disabled = !modifiedDocument && value;
9218 if(value && value[0])
9219 fileName = CopyString(value);
9221 if(parent && this == parent.activeClient)
9222 parent.UpdateActiveDocument(null);
9226 // if(style.isDocument)
9228 fileMonitor.fileName = value;
9230 get { return fileName; }
9235 property_category $"Data"
9240 property bool modifiedDocument
9242 property_category $"Document"
9245 if(style.isDocument || fileName)
9249 MenuItem item = menu.FindItem(MenuFileSave, 0);
9250 if(item) item.disabled = !value && fileName;
9254 if(modifiedDocument != value)
9256 modifiedDocument = value;
9257 if(style.isDocument || fileName)
9261 get { return (bool)modifiedDocument; }
9264 property bool showInTaskBar
9266 property_category $"Window Style"
9267 set { style.showInTaskBar = value; }
9268 get { return (style.showInTaskBar; }
9270 property FileDialog saveDialog { set { saveDialog = value; } };
9271 property bool isActiveClient
9273 property_category $"Behavior"
9274 set { style.isActiveClient = value; }
9275 get { return style.isActiveClient; }
9278 property Cursor cursor
9280 property_category $"Appearance"
9284 SelectMouseCursor();
9286 get { return cursor; }
9289 //#if !defined(ECERE_VANILLA)
9290 property char * name
9292 property_category $"Design"
9295 return (this && object) ? object.name : null;
9300 activeDesigner.RenameObject(object, value);
9304 property char * displayDriver
9306 property_category $"Behavior"
9309 dispDriver = GetDisplayDriver(value);
9310 //DisplayModeChanged();
9314 return dispDriver ? dispDriver.name : null;
9318 // RUNTIME PROPERTIES
9319 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9320 property Size scrollArea
9322 property_category $"Behavior"
9326 SetScrollArea(value.w, value.h, false);
9328 SetScrollArea(0,0, true);
9330 get { value = scrollArea; }
9333 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9338 property_category $"Layout"
9339 set { if(this) is3D = value; }
9340 get { return (bool)is3D; }
9343 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9345 // Will be merged with font later
9346 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9347 property Point clientStart { get { value = clientStart; } };
9348 property Point absPosition { get { value = absPosition; } };
9349 property Anchor normalAnchor { get { value = normalAnchor; } };
9350 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9351 property bool active { get { return (bool)active; } };
9352 property bool created { get { return (bool)created; } };
9353 property bool destroyed { get { return (bool)destroyed; } };
9354 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9355 property Window firstChild { get { return children.first; } };
9356 property Window lastChild { get { return children.last; } };
9357 property Window activeClient { get { return activeClient; } };
9358 property Window activeChild { get { return activeChild; } };
9359 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9360 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9361 property ScrollBar horzScroll { get { return sbh; } };
9362 property ScrollBar vertScroll { get { return sbv; } };
9363 property StatusBar statusBar { get { return statusBar; } };
9364 property Window rootWindow { get { return rootWindow; } };
9365 property bool closing { get { return (bool)closing; } set { closing = value; } };
9366 property int documentID { get { return documentID; } };
9367 property Window previous { get { return prev; } }
9368 property Window next { get { return next; } }
9369 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9370 property PopupMenu menuBar { get { return menuBar; } }
9371 property ScrollBar sbv { get { return sbv; } }
9372 property ScrollBar sbh { get { return sbh; } }
9373 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9374 property void * systemHandle { get { return windowHandle; } }
9375 property Button minimizeButton { get { return sysButtons[0]; } };
9376 property Button maximizeButton { get { return sysButtons[1]; } };
9377 property Button closeButton { get { return sysButtons[2]; } };
9378 property BitmapResource icon
9380 get { return icon; }
9384 if(icon) incref icon;
9386 guiApp.interfaceDriver.SetIcon(this, value);
9389 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9390 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9391 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9392 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9393 property bool nativeDecorations
9395 get { return (bool)nativeDecorations; }
9396 set { nativeDecorations = value; }
9397 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9400 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9401 bool result = false;
9402 if(nativeDecorations)
9404 if(rootWindow == this)
9408 if(formDesigner && activeDesigner)
9410 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9411 Window form = cd ? cd.form : null;
9412 if(form && parent == form.parent)
9417 return result != style.fixed;
9421 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9423 property char * text
9425 property_category $"Deprecated"
9427 set { property::caption = value; }
9428 get { return property::caption; }
9434 WindowBits style; // Window Style
9435 char * caption; // Name / Caption
9436 Window parent; // Parent window
9437 OldList children; // List of children in Z order
9438 Window activeChild; // Child window having focus
9439 Window activeClient;
9440 Window previousActive; // Child active prior to activating the default child
9441 Window master; // Window owning and receiving notifications concerning this window
9442 OldList slaves; // List of windows belonging to this window
9443 Display display; // Display this window is drawn into
9445 Point position; // Position in parent window client area
9446 Point absPosition; // Absolute position
9447 Point clientStart; // Client area position from (0,0) in this window
9449 Size clientSize; // Client area size
9450 Size scrollArea; // Virtual Scroll area size
9451 Size reqScrollArea; // Requested virtual area size
9452 Point scroll; // Virtual area scrolling position
9453 ScrollBar sbh, sbv; // Scrollbar window handles
9454 Cursor cursor; // Mouse cursor used for this window
9457 StatusBar statusBar;
9458 Button sysButtons[3];
9460 Box clientArea; // Client Area box clipped to parent
9462 HotKeySlot hotKey; // HotKey for this window
9466 ScrollFlags scrollFlags;// Window Scrollbar Flags
9467 int64 id; // Control ID
9469 ColorAlpha background; // Background color used to draw the window area
9471 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9472 OldList childrenCycle; // Cycling order
9473 OldLink cycle; // Element of parent's cycling order
9474 OldList childrenOrder; // Circular Z-Order
9475 OldLink order; // Element of parent's circular Z-Order
9476 Window modalSlave; // Slave window blocking this window's interaction
9478 Window rootWindow; // Topmost system managed window
9479 void * windowHandle; // System window handle
9481 DialogResult returnCode;// Return code for modal windows
9483 Point sbStep; // Scrollbar line scrolling steps
9486 SizeAnchor stateSizeAnchor;
9488 Anchor normalAnchor;
9489 SizeAnchor normalSizeAnchor;
9491 Size skinMinSize; // Minimal window size based on style
9492 Point scrolledPos; // Scrolled position
9493 Box box; // Window box clipped to parent
9494 Box * against; // What to clip the box to
9496 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9497 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9498 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9499 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9500 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9501 Point scrolledArea; // Distance to scroll area by
9502 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9504 OldList hotKeys; // List of the hotkeys of all children
9505 Window defaultControl; // Default child control
9509 ColorAlpha * palette; // Color palette used for this window
9511 int caretSize; // Size of caret, non zero if a caret is present
9512 Point caretPos; // Caret position
9514 void * systemParent; // Parent System Window for embedded windows
9521 WindowState lastState;
9523 FileMonitor fileMonitor
9525 this, FileChange { modified = true };
9527 bool OnFileNotify(FileChange action, char * param)
9530 fileMonitor.StopMonitoring();
9531 if(OnFileModified(action, param))
9532 fileMonitor.StartMonitoring();
9537 FontResource setFont, systemFont;
9538 FontResource usedFont;
9539 FontResource captionFont;
9541 FileDialog saveDialog;
9543 SizeAnchor sizeAnchor;
9545 // FormDesigner data
9548 Extent * tempExtents; //[4];
9549 BitmapResource icon;
9551 CreationActivationOption creationActivation;
9554 bool active:1; // true if window and ancestors are active
9555 bool acquiredInput:1; // true if the window is processing state based input
9556 bool modifiedDocument:1;
9557 bool disabled:1; // true if window cannot interact
9558 bool isForegroundWindow:1;// true while a root window is being activated
9559 bool visible:1; // Visibility flag
9560 bool destroyed:1; // true if window is being destroyed
9561 bool anchored:1; // true if this window is repositioned when the parent resizes
9562 bool dirty:1; // Flag set to true if any descendant must be redrawn
9568 bool modifyVirtArea:1;
9569 bool noAutoScrollArea:1;
9572 bool setVisible:1; // FOR FORM DESIGNER
9578 bool useSharedMemory:1;
9581 bool nativeDecorations:1;
9582 bool manageDisplay:1;
9583 bool formDesigner:1; // True if we this is running in the form editor
9584 bool requireRemaximize:1;
9587 // Checks used internally for them not to take effect in FormDesigner
9588 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9589 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9591 WindowController controller;
9592 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9595 public class CommonControl : Window
9597 // creationActivation = doNothing;
9600 public property String toolTip
9602 property_category $"Appearance"
9605 if(created) CommonControl::OnDestroy();
9607 toolTip = value ? ToolTip { tip = value; } : null;
9609 if(created) CommonControl::OnCreate();
9611 get { return toolTip ? toolTip.tip : null; }
9617 // (Very) Ugly work around for the fact that the parent watcher
9618 // won't fire when it's already been disconnected...
9619 eInstance_FireSelfWatchers(toolTip,
9620 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9626 toolTip.parent = this;
9635 public class Percentage : float
9637 char * OnGetString(char * string, float * fieldData, bool * needClass)
9641 sprintf(string, "%.2f", this);
9642 c = strlen(string)-1;
9645 if(string[c] != '0')
9646 last = Max(last, c);
9647 if(string[c] == '.')
9660 public void ApplySkin(Class c, char * name, void ** vTbl)
9662 char className[1024];
9667 subclass(Window) wc = (subclass(Window))c;
9668 subclass(Window) base = (subclass(Window))c.base;
9670 sprintf(className, "%sSkin_%s", name, c.name);
9671 wc.pureVTbl = c._vTbl;
9672 c._vTbl = new void *[c.vTblSize];
9673 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9674 sc = eSystem_FindClass(c.module.application, className);
9678 for(m = 0; m < c.base.vTblSize; m++)
9680 if(c._vTbl[m] == base.pureVTbl[m])
9681 c._vTbl[m] = vTbl[m];
9686 for(m = 0; m < c.vTblSize; m++)
9688 if(sc._vTbl[m] != wc.pureVTbl[m])
9689 c._vTbl[m] = sc._vTbl[m];
9693 for(d = c.derivatives.first; d; d = d.next)
9695 ApplySkin(d.data, name, c._vTbl);
9699 public void UnapplySkin(Class c)
9701 char className[1024];
9703 subclass(Window) wc = (subclass(Window))c;
9704 subclass(Window) base = (subclass(Window))c.base;
9707 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9710 c._vTbl = wc.pureVTbl;
9714 for(d = c.derivatives.first; d; d = d.next)
9716 UnapplySkin(d.data);
9720 void CheckFontIntegrity(Window window)
9725 if(window.usedFont && window.usedFont.font == 0xecececec)
9727 FontResource uf = window.usedFont;
9728 char * className = window._class.name;
9729 char * text = window.text;
9732 for(c = window.firstChild; c; c = c.next)
9733 CheckFontIntegrity(c);
9737 public class ControllableWindow : Window
9739 /*WindowController controller;
9740 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9741 ~ControllableWindow() { delete controller; }*/
9744 class WindowControllerInterface : ControllableWindow
9746 bool OnKeyDown(Key key, unichar ch)
9748 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9750 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9754 bool OnKeyUp(Key key, unichar ch)
9756 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9758 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9762 bool OnKeyHit(Key key, unichar ch)
9764 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9766 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9770 bool OnMouseMove(int x, int y, Modifiers mods)
9772 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9774 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9778 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9780 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9782 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9786 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9788 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9790 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9794 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9796 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9798 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9802 bool OnRightButtonDown(int x, int y, Modifiers mods)
9804 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9806 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9810 bool OnRightButtonUp(int x, int y, Modifiers mods)
9812 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9814 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9818 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9820 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9822 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9826 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9828 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9830 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9834 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9836 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9838 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9842 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9844 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9846 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9850 void OnResize(int width, int height)
9852 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9853 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9856 void OnRedraw(Surface surface)
9858 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9859 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9864 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9866 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9870 bool OnLoadGraphics()
9872 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9874 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9878 void OnUnloadGraphics()
9880 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9881 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9885 public class WindowController<class V>
9888 property Window window
9892 uint size = class(Window).vTblSize;
9895 windowVTbl = new void *[size];
9896 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9897 if(value._vTbl == value._class._vTbl)
9899 value._vTbl = new void *[value._class.vTblSize];
9900 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9904 for(c = 0; c < size; c++)
9906 void * function = class(WindowControllerInterface)._vTbl[c];
9907 if(function != DefaultFunction)
9908 value._vTbl[c] = function;
9910 value._vTbl[c] = windowVTbl[c];
9915 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9918 get { return window; }
9920 property V controlled
9922 set { controlled = value; }
9923 get { return controlled; }
9925 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9926 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9927 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9928 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9929 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9930 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9931 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9932 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9933 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9934 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9935 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9936 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9937 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9938 virtual void V::OnResize(WindowController controller, int width, int height);
9939 virtual void V::OnRedraw(WindowController controller, Surface surface);
9940 virtual bool V::OnCreate(WindowController controller);
9941 virtual bool V::OnLoadGraphics(WindowController controller);
9942 virtual void V::OnUnloadGraphics(WindowController controller);
9945 int (** windowVTbl)();