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 && !is3D)
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 && !is3D)
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 if(guiApp.interfaceDriver)
2444 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2446 UpdateDecorations();
2449 if(parent.activeClient == this) // Added this last check
2451 if(parent.rootWindow == parent)
2454 parent.FigureCaption(caption);
2455 if(guiApp.interfaceDriver)
2456 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2459 parent.UpdateCaption();
2461 parent.UpdateDecorations();
2465 void UpdateActiveDocument(Window previous)
2467 Window activeClient = this.activeClient;
2468 Window activeChild = this.activeChild;
2475 activeClient.CreateSystemChildren();
2477 previous.CreateSystemChildren();
2489 // Build window list
2492 Menu windowMenu = menu.FindMenu("Window");
2497 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2500 Window document = cycle.data;
2501 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2503 char name[2048], caption[2048];
2504 document.FigureCaption(caption);
2505 sprintf(name, "%d %s", id+1, caption);
2506 windowMenu.AddDynamic(MenuItem
2508 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2509 NotifySelect = MenuWindowSelectWindow
2513 if(activeClient.cycle == cycle) break;
2518 if((!previous && activeClient) || !activeClient)
2524 item = menu.FindItem(MenuWindowCloseAll, 0);
2525 if(item) item.disabled = false;
2526 item = menu.FindItem(MenuWindowNext, 0);
2527 if(item) item.disabled = false;
2528 item = menu.FindItem(MenuWindowPrevious, 0);
2529 if(item) item.disabled = false;
2530 item = menu.FindItem(MenuWindowCascade, 0);
2531 if(item) item.disabled = false;
2532 item = menu.FindItem(MenuWindowTileHorz, 0);
2533 if(item) item.disabled = false;
2534 item = menu.FindItem(MenuWindowTileVert, 0);
2535 if(item) item.disabled = false;
2536 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2537 if(item) item.disabled = false;
2538 item = menu.FindItem(MenuWindowWindows, 0);
2539 if(item) item.disabled = false;
2542 item = menu.FindItem(MenuFileClose, 0);
2543 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2544 item = menu.FindItem(MenuFileSaveAll, 0);
2545 if(item) item.disabled = numDocuments < 1;
2547 if(activeClient && activeClient.menu && activeClient.state != minimized)
2551 //activeClient.menu.Clean(activeClient);
2552 menu.Merge(activeClient.menu, true, activeClient);
2556 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2559 menu.Merge(activeChild.menu, true, activeChild);
2562 // This is called again for a child window change, with same active client
2563 OnActivateClient(activeClient, previous);
2564 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2565 parent.UpdateActiveDocument(null);
2568 void _ShowDecorations(Box box, bool post)
2570 if(rootWindow == this && nativeDecorations && !is3D) return;
2571 if(visible && this != guiApp.desktop)
2573 Surface surface = RedrawFull(box);
2577 FigureCaption(caption);
2580 ShowDecorations(captionFont.font,
2583 active, //parent.activeClient == this
2584 guiApp.windowMoving == this);
2586 PreShowDecorations(captionFont.font,
2589 active, //parent.activeClient == this
2590 guiApp.windowMoving == this);
2597 void UpdateExtent(Box refresh)
2599 Surface surface = null;
2601 if(!manageDisplay) { OnRedraw(null);return; }
2602 _ShowDecorations(refresh, false);
2604 surface = Redraw(refresh);
2605 // Opaque background: just fill before EW_REDRAW (clear?)
2608 surface.SetBackground(background);
2609 surface.SetForeground(foreground);
2610 surface.DrawingChar(' ');
2611 if(this == rootWindow)
2613 if(style.drawBehind || background.a)
2615 int a = background.a;
2616 // Premultiply alpha for clear color
2617 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2618 surface.Clear(colorBuffer);
2619 surface.SetBackground(background);
2622 else if(background.a)
2626 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2627 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2630 if(display.flags.alpha && background.a < 255 && background)
2632 surface.Area(0,0,clientSize.w, clientSize.h);
2633 /*if(style.clearDepthBuffer)
2634 surface.Clear(depthBuffer);*/
2636 else if(/*style.clearDepthBuffer || */background.a)
2638 int a = background.a;
2639 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2640 // Premultiply alpha for clear color
2641 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2642 surface.Clear(colorBuffer);
2643 surface.SetBackground(background);
2648 surface.TextFont(usedFont.font);
2649 surface.TextOpacity(false);
2653 // Draw the caret ...
2654 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2656 // surface.SetBackground(0xFFFFFF - background.color);
2657 surface.SetBackground(~background.color);
2659 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2660 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2666 void DrawOverChildren(Box refresh)
2668 Surface surface = Redraw(refresh);
2672 surface.DrawingChar(' ');
2673 surface.SetBackground(background);
2674 surface.SetForeground(foreground);
2676 surface.TextFont(usedFont.font);
2677 surface.TextOpacity(false);
2679 OnDrawOverChildren(surface);
2684 _ShowDecorations(refresh, true);
2687 void ComputeClipExtents(void)
2690 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2692 clipExtent.Copy(this.clipExtent);
2694 for(child = children.last; child; child = child.prev)
2696 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2698 bool opaque = child.IsOpaque(); // TODO: acess background directly
2699 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2701 child.clipExtent.Copy(clipExtent);
2702 child.clipExtent.Offset(-dx, -dy);
2703 child.clipExtent.IntersectBox(child.box);
2705 child.ComputeClipExtents();
2707 if(opaque && !child.style.nonClient)
2709 // Adjust the box for the parent:
2710 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2711 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2716 // ??? Only do this for overlapped window or if parent has with clip children flag
2718 // Do this if window has clip children flag on (default false?)
2719 // this.clipExtent = clipExtent;
2721 clipExtent.Free(null);
2724 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2726 bool opaque = IsOpaque();
2728 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2729 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2731 offsetX -= rootWindow.clientStart.x;
2732 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2736 for(child = children.last; child; child = child.prev)
2738 ColorAlpha background = *(ColorAlpha *)&child.background;
2739 bool opaque = child.IsOpaque();
2740 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2744 // Adjust renderArea to the root window level
2745 Extent * renderArea = &rootWindow.tempExtents[3];
2747 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2748 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2749 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2751 offsetX -= child.rootWindow.clientStart.x;
2752 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2756 Extent childRenderArea;
2758 if(backBufferUpdate != null)
2760 childRenderArea.Copy(backBufferUpdate);
2761 childRenderArea.Offset(-offsetX, -offsetY);
2764 childRenderArea.Copy(child.dirtyArea);
2766 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2767 renderArea.Copy(dirtyExtent);
2768 renderArea.Offset(-offsetX, -offsetY);
2769 childRenderArea.Union(renderArea);
2772 // Intersect with the clip extent
2773 childRenderArea.Intersection(child.clipExtent);
2776 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2778 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2779 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2781 renderArea->Offset(offsetX, offsetY);
2783 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2784 // overDirtyExtent.Union(renderArea);
2785 renderArea->Empty();
2786 // childRenderArea.Free();
2788 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2793 for(child = children.last; child; child = child.prev)
2795 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2797 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2802 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2804 bool opaque = IsOpaque();
2805 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2807 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2808 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2810 offsetX -= rootWindow.clientStart.x;
2811 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2815 for(child = children.last; child; child = child.prev)
2817 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2819 ColorAlpha background = *(ColorAlpha *)&child.background;
2820 bool opaque = child.IsOpaque();
2821 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2825 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2826 // Adjust renderArea to the root window level
2828 renderArea.Copy(child.dirtyArea);
2829 renderArea.Offset(offsetX, offsetY);
2830 dirtyExtent.Union(renderArea);
2831 overDirtyExtent.Union(renderArea);
2837 for(child = children.last; child; child = child.prev)
2839 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2841 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2845 if(backBufferUpdate != null)
2847 renderArea.Copy(backBufferUpdate);
2848 renderArea.Offset(-offsetX, -offsetY);
2850 overRenderArea.Copy(backBufferUpdate);
2851 overRenderArea.Offset(-offsetX, -offsetY);
2857 renderArea.Copy(dirtyArea);
2859 overRenderArea.Copy(dirtyArea);
2862 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2863 dirtyExtentWindow->Copy(dirtyExtent);
2864 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2865 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2866 dirtyExtentWindow->Empty();
2868 // Intersect with the clip extent
2869 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2872 if(renderArea.count > 10)
2875 printf("\nToo many extents (%d):\n", renderArea.count);
2877 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2878 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2883 for(c = 0; c<10; c++)
2886 FASTLIST_LOOP(renderArea, extentBox)
2888 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2890 renderArea.Copy(extent);
2892 FASTLIST_LOOP(renderArea, extentBox)
2895 printf("(%d, %d) - (%d, %d)\n",
2896 extentBox.box.left, extentBox.box.top,
2897 extentBox.box.right, extentBox.box.bottom);
2901 printf("\nNow %d\n", renderArea.count);
2907 // WHY WAS THIS COMMENTED ??
2909 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2910 dirtyExtentWindow->Copy(overDirtyExtent);
2911 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2912 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2913 dirtyExtentWindow->Empty();
2915 // Intersect with the clip extent
2916 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2922 if(scrollExtent.count)
2924 // Subtract render extent from scrolling extent
2925 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2927 if(backBufferUpdate == null)
2929 Extent * dirty = &rootWindow.tempExtents[3];
2932 // Intersect scrolling extent with clip extent
2933 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2935 // offset this scroll to be at the root window level
2936 scrollExtent.Offset(offsetX, offsetY);
2937 // Add area that was scrolled to the dirty extents of the back buffer
2938 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2942 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2943 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2944 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2949 scrollExtent.Empty();
2951 // Add the exposed extent to the window render area
2952 dirty->Offset(-offsetX, -offsetY);
2953 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2958 // Subtract the window's box from the transparency forced extent
2959 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2965 renderArea.Copy(this.renderArea);
2966 renderArea.Offset(offsetX, offsetY);
2967 dirtyExtent.Union(renderArea);
2973 Extent renderArea { };
2975 renderArea.Copy(overRenderArea);
2976 renderArea.Offset(offsetX, offsetY);
2977 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2982 if(backBufferUpdate != null)
2984 // Remove render area from dirty area
2985 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2987 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2994 // Remove the window render area from the dirty extents of the back buffer
2995 rootWindow.dirtyBack.Exclusion(renderArea);
2999 void Render(Extent updateExtent)
3003 Window rootWindow = this.rootWindow;
3004 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3005 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3007 offsetX -= rootWindow.clientStart.x;
3008 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3011 if(rootWindow.fullRender)
3020 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3021 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3026 /*if(renderArea.count)
3027 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3030 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3032 Box box = extentBox.box;
3035 /*printf("(%d, %d) - (%d, %d)\n",
3036 extentBox.box.left, extentBox.box.top,
3037 extentBox.box.right, extentBox.box.bottom);*/
3042 box.left += offsetX;
3044 box.right += offsetX;
3045 box.bottom += offsetY;
3047 if(updateExtent != null)
3048 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3052 for(child = children.first; child; child = child.next)
3053 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3054 child.Render(updateExtent);
3056 if(rootWindow.fullRender)
3057 DrawOverChildren(box);
3060 // TO DO: There's an issue about draw over children...
3061 // TO DO: Don't wanna go through this if method isn't used
3062 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3063 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3065 Box box = extentBox.box;
3067 DrawOverChildren(box);
3069 box.left += offsetX;
3071 box.right += offsetX;
3072 box.bottom += offsetY;
3074 if(updateExtent != null)
3075 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3078 for(child = children.first; child; child = child.next)
3079 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3080 child.Render(updateExtent);
3083 overRenderArea.Empty();
3086 public void UpdateDisplay(void)
3088 if(!manageDisplay) { OnRedraw(null);return; }
3089 if(rootWindow && this != rootWindow)
3090 rootWindow.UpdateDisplay();
3093 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3094 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3097 dirtyExtent.Clear();
3100 clipExtent.AddBox(box);
3102 display.StartUpdate();
3104 if(!rootWindow.fullRender)
3106 ComputeClipExtents();
3107 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3108 ComputeRenderArea(dirtyExtent, overExtent, null);
3111 clipExtent.Free(null);
3113 dirtyExtent.Free(null);
3114 overExtent.Free(null);
3116 if(display.flags.flipping)
3119 display.Update(null);
3123 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3124 updateExtent.Clear();
3126 Render(updateExtent);
3128 updateExtent.UnionBox(this.box, tempExtents[0]);
3131 //printf("\n\nUpdate:\n------------------------------------------\n");
3134 //FASTLIST_LOOP(updateExtent, extentBox)
3135 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3138 /*printf("Updating (%d, %d) - (%d, %d)\n",
3139 extentBox.box.left, extentBox.box.top,
3140 extentBox.box.right, extentBox.box.bottom);*/
3143 display.Update(extentBox.box);
3146 updateExtent.Free(null);
3149 display.EndUpdate();
3157 void UpdateBackDisplay(Box box)
3163 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3165 //printf("UpdateBackDisplay going through!\n");
3166 display.StartUpdate();
3170 intersection.Copy(dirtyBack);
3171 intersection.IntersectBox(box);
3173 dirtyExtent.Clear();
3176 clipExtent.AddBox(box);
3178 if(!rootWindow.fullRender)
3180 ComputeClipExtents();
3181 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3184 clipExtent.Free(null);
3186 intersection.Free(null);
3187 dirtyExtent.Free(null);
3188 overExtent.Free(null);
3193 if(display.flags.flipping)
3194 display.Update(null);
3197 rootWindow.display.Update(box);
3200 display.EndUpdate();
3204 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3205 if(dirtyBack.count > MAX_DIRTY_BACK)
3207 BoxItem extentBox, next;
3208 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3209 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3211 next = (BoxItem)extentBox.next;
3212 if(extentBox != first)
3214 if(extentBox.box.left < first.box.left)
3215 first.box.left = extentBox.box.left;
3216 if(extentBox.box.top < first.box.top)
3217 first.box.top = extentBox.box.top;
3218 if(extentBox.box.right > first.box.right)
3219 first.box.right = extentBox.box.right;
3220 if(extentBox.box.bottom > first.box.bottom)
3221 first.box.bottom = extentBox.box.bottom;
3222 dirtyBack.Delete(extentBox);
3231 // --- Window positioning ---
3232 // --- Window identification ---
3234 // Returns window at position "Position"
3235 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3237 Window child, result = null;
3239 box.left += absPosition.x;
3240 box.right += absPosition.x;
3241 box.top += absPosition.y;
3242 box.bottom += absPosition.y;
3244 if(!destroyed && visible && (acceptDisabled || !disabled))
3246 int lx = x - absPosition.x;
3247 int ly = y - absPosition.y;
3248 if(IsInside(lx, ly))
3249 // if(box.IsPointInside(Point{x, y}))
3251 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3252 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3255 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3256 Window ancestor = null;
3258 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3259 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3261 if(child != statusBar && child.rootWindow == rootWindow)
3263 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3270 for(child = (isD ? (last != ancestor ? ancestor : 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);
3494 if(active && isEnabled)
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 if(guiApp.interfaceDriver)
3573 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3575 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3576 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3582 bool IsDescendantOf(Window ancestor)
3585 for(window = this; window && window != ancestor; window = window.parent);
3586 return window == ancestor;
3589 bool IsSlaveOf(Window master)
3592 for(window = this; window && window != master; window = window.master);
3593 return window == master;
3596 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3600 if(this && !destroyed /*&& state != Hidden*/)
3602 Window swap = externalSwap;
3610 if(activateParent &&
3611 (parent.activeChild != this ||
3612 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3613 active && _isModal &&
3614 parent != master && master)
3615 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3621 bool real = parent.activeChild != this;
3623 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3624 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3625 !IsDescendantOf(guiApp.interimWindow) &&
3626 !IsSlaveOf(guiApp.interimWindow))
3628 Window interimWindow = guiApp.interimWindow;
3629 while(interimWindow && interimWindow != this)
3631 Window master = interimWindow.master;
3633 guiApp.interimWindow = null;
3634 if(guiApp.caretOwner)
3635 guiApp.caretOwner.UpdateCaret(false, false);
3637 incref interimWindow;
3638 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3643 delete interimWindow;
3644 interimWindow = (master && master.style.interim) ? master : null;
3649 guiApp.interimWindow = this;
3650 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3651 guiApp.caretEnabled = false;*/
3652 UpdateCaret(false, true);
3657 bool acquireInput = false;
3659 parent.activeChild &&
3660 parent.activeChild.state == maximized &&
3661 parent != guiApp.desktop;
3663 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3668 swap = parent.activeChild;
3669 if(swap && swap.destroyed) swap = null;
3670 if(swap && swap != this)
3673 if(!swap.PropagateActive(false, this, &goOn, true))
3674 swap = parent.activeChild;
3685 if(!parent || parent.activeChild != this || style.interim)
3688 result = PropagateActive(true, swap, &goOn, true);
3689 if(!result && !goOn)
3694 acquireInput = true;
3698 if(style.hasMaximize && parent != guiApp.desktop)
3701 SetState(maximized, false, 0);
3702 else if(state != maximized)
3705 for(child = parent.children.first; child; child = child.next)
3707 if(this != child && child.state == maximized)
3708 child.SetState(normal, false, 0);
3715 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3717 Window previous = parent.activeClient;
3718 parent.activeChild = this;
3719 if(!style.nonClient /*&& style.isActiveClient*/)
3723 if(style.isActiveClient)
3724 parent.activeClient = this;
3725 // Moved UpdateActiveDocument inside hidden check
3726 // To prevent activating previous window while creating a new one
3727 // (It was messing up the privateModule in the CodeEditor)
3728 parent.UpdateActiveDocument(previous);
3734 //if(!style.isRemote)
3736 if(rootWindow != this)
3738 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3739 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3741 else if(!guiApp.fullScreenMode)
3743 Window modalRoot = FindModal();
3744 if(!modalRoot) modalRoot = this;
3745 if(!modalRoot.isForegroundWindow)
3747 modalRoot.isForegroundWindow = true;
3748 // To check : Why is parent null?
3749 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3751 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3753 modalRoot.isForegroundWindow = false;
3758 if(result && real && (!style.inactive || moveInactive) && parent)
3760 Window last = parent.children.last;
3762 if(!style.stayOnTop)
3763 for(; last && last.style.stayOnTop; last = last.prev);
3765 parent.children.Move(this, last);
3767 // Definitely don't want that: why not?
3771 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3777 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3784 parent.activeChild = null;
3785 if(!style.nonClient /*&& style.isActiveClient*/)
3787 Window previous = parent.activeClient;
3788 if(style.isActiveClient)
3789 parent.activeClient = null;
3790 parent.UpdateActiveDocument(previous);
3794 if(this == guiApp.interimWindow)
3796 guiApp.interimWindow = null;
3797 if(guiApp.caretOwner)
3798 guiApp.caretOwner.UpdateCaret(false, false);
3800 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3807 if(!active || !swap)
3808 UpdateDecorations();
3810 swap.UpdateDecorations();
3812 if(active && rootWindow != this)
3813 ConsequentialMouseMove(false);
3820 // --- Input Messages ---
3821 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3823 static bool reEntrancy = false;
3824 if(reEntrancy) return;
3828 guiApp.cursorUpdate = true;
3829 if(guiApp.windowScrolling && !consequential)
3831 guiApp.windowScrolling.SetScrollPosition(
3832 (guiApp.windowScrolling.sbh) ?
3833 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3834 (guiApp.windowScrolling.sbv) ?
3835 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3837 if(guiApp.windowMoving)
3839 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3841 Window window = guiApp.windowMoving;
3843 int w = window.size.w;
3844 int h = window.size.h;
3849 rx = mouseX - guiApp.windowMovingStart.x;
3850 ry = mouseY - guiApp.windowMovingStart.y;
3853 window.GetDecorationsSize(&ew, &eh);
3855 if(guiApp.windowIsResizing)
3857 x = window.scrolledPos.x;
3858 y = window.scrolledPos.y;
3862 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3863 rx = guiApp.windowResizingBefore.w - aw;
3864 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3865 w = guiApp.windowResizingBefore.w - rx;
3869 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3870 ry = guiApp.windowResizingBefore.h - ah;
3871 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3872 ry = Max(ry, -guiApp.windowMovingBefore.y);
3873 h = guiApp.windowResizingBefore.h - ry;
3875 if(guiApp.resizeEndX)
3877 w = guiApp.windowResizingBefore.w + rx;
3880 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3888 w = Max(w, window.minSize.w);
3889 h = Max(h, window.minSize.h);
3890 w = Min(w, window.maxSize.w);
3891 h = Min(h, window.maxSize.h);
3893 if(!window.OnResizing(&w, &h))
3895 w = window.clientSize.w;
3896 h = window.clientSize.h;
3899 w = Max(w, window.skinMinSize.w);
3900 h = Max(h, window.skinMinSize.h);
3907 SNAPDOWN(w, textCellW);
3908 SNAPDOWN(h, textCellH);
3913 aw = Max(w,window.skinMinSize.w);
3914 rx = guiApp.windowResizingBefore.w - aw;
3915 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3916 w = guiApp.windowResizingBefore.w - rx;
3920 ah = Max(h,window.skinMinSize.h);
3921 ry = guiApp.windowResizingBefore.h - ah;
3922 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3923 ry = Max(ry, -guiApp.windowMovingBefore.y);
3924 h = guiApp.windowResizingBefore.h - ry;
3929 if(!guiApp.windowIsResizing || guiApp.resizeX)
3930 x = guiApp.windowMovingBefore.x + rx;
3931 if(!guiApp.windowIsResizing || guiApp.resizeY)
3932 y = guiApp.windowMovingBefore.y + ry;
3934 if(!guiApp.windowIsResizing)
3937 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3939 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3940 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3941 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3942 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3946 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3947 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3953 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3955 if(!window.OnMoving(&x, &y, w, h))
3957 x = window.scrolledPos.x;
3958 y = window.scrolledPos.y;
3964 SNAPDOWN(x, textCellW);
3965 SNAPDOWN(y, textCellH);
3968 if(!window.style.nonClient)
3970 if(!window.style.fixed /*|| window.style.isDocument*/)
3972 if(!window.style.dontScrollHorz)
3973 x += window.parent.scroll.x;
3974 if(!window.style.dontScrollVert)
3975 y += window.parent.scroll.y;
3979 // Break the anchors for moveable/resizable windows
3980 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3981 if(window.style.fixed)
3983 if(window.state == normal)
3985 window.normalAnchor = Anchor { left = x, top = y };
3986 window.normalSizeAnchor = SizeAnchor { { w, h } };
3987 window.anchored = false;
3991 window.stateAnchor = Anchor { left = x, top = y };
3992 window.stateSizeAnchor = SizeAnchor { { w, h } };
3994 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3995 // TOCHECK: Investigate why the following only redraws the scrollbars
3996 //window.Position(x, y, w, h, false, true, true, true, false, true);
3998 guiApp.movingLast.x = mouseX;
3999 guiApp.movingLast.y = mouseY;
4005 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4008 bool wasMoving = guiApp.windowMoving ? true : false;
4009 bool wasScrolling = guiApp.windowScrolling ? true : false;
4011 while(result && w != this)
4013 Window msgWindow = GetAtPosition(x,y, false, true, w);
4014 Window trueWindow = GetAtPosition(x,y, false, false, w);
4015 bool windowDragged = false;
4020 window = (w && !w.disabled) ? w : null;
4022 if(trueWindow) incref trueWindow;
4024 if(consequential) mods->isSideEffect = true;
4026 UpdateMouseMove(x, y, consequential);
4028 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4030 if(!guiApp.windowCaptured.isEnabled)
4031 guiApp.windowCaptured.ReleaseCapture();
4033 window = guiApp.windowCaptured;
4036 if(trueWindow && activate &&
4037 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4038 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4039 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4040 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4042 if(mods->alt && !mods->ctrl && !mods->shift)
4044 Window moved = trueWindow;
4045 for(moved = trueWindow; moved; moved = moved.parent)
4046 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4051 windowDragged = true;
4053 // Cancel the ALT menu toggling...
4054 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4059 if(window && activate &&
4060 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4061 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4062 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4063 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4065 Window modalWindow = window.FindModal();
4067 /*if(mods->alt && !mods->shift && !mods->ctrl)
4069 Window moved = window;
4070 for(moved = window; moved; moved = moved.parent)
4071 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4076 windowDragged = true;
4078 // Cancel the ALT menu toggling...
4079 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4085 Window activateWindow = modalWindow ? modalWindow : window;
4086 if(activateWindow && !activateWindow.isRemote)
4088 bool doActivation = true;
4089 //bool needToDoActivation = false;
4090 Window check = activateWindow;
4092 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4094 if(!check.style.inactive)
4096 //needToDoActivation = true;
4098 doActivation = false;
4103 if(!needToDoActivation)
4104 doActivation = false;
4107 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4108 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4110 // Let the OnLeftButtonDown do the activating instead
4111 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4119 incref activateWindow;
4120 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4122 delete activateWindow;
4126 if(activateWindow._refCount == 1)
4128 delete activateWindow;
4132 delete activateWindow;
4133 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4136 mods->isActivate = true;
4140 if(!modalWindow && window && !window.destroyed)
4142 if(!guiApp.windowCaptured || windowDragged)
4144 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4146 bool moving = ((window.state != maximized &&
4147 window.IsMouseMoving(
4148 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4149 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4151 if(!moving && window.IsMouseResizing(
4152 x - window.absPosition.x,
4153 y - window.absPosition.y,
4154 window.size.w, window.size.h,
4155 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4157 guiApp.windowIsResizing = true;
4158 guiApp.windowResizingBefore.w = window.size.w;
4159 guiApp.windowResizingBefore.h = window.size.h;
4161 if(guiApp.windowIsResizing || windowDragged || moving)
4164 guiApp.windowMoving = window;
4165 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4166 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4167 guiApp.windowMovingBefore.x = window.position.x;//s;
4168 guiApp.windowMovingBefore.y = window.position.y;//s;
4169 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4170 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4173 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4175 if(window.style.fixed &&
4177 window.IsMouseMoving(
4178 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4180 window.ShowSysMenu(x, y);
4184 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4186 if(window.sbv || window.sbh)
4189 guiApp.windowScrolling = window;
4190 guiApp.windowScrollingStart.x = x;
4191 guiApp.windowScrollingStart.y = y;
4192 guiApp.windowScrollingBefore.x = window.scroll.x;
4193 guiApp.windowScrollingBefore.y = window.scroll.y;
4196 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4198 if(window.style.hasMaximize &&
4199 window.IsMouseMoving(
4200 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4203 (window.state == maximized) ? normal : maximized, false, *mods);
4211 if(guiApp.windowMoving)
4213 if(guiApp.windowMoving.parent)
4215 if(guiApp.windowMoving.style.nonClient)
4216 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4218 guiApp.windowMoving.parent.SetMouseRangeToClient();
4222 window.UpdateDecorations();
4225 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4227 // Log("\n*** LEFT BUTTON UP ***\n");
4228 if(guiApp.windowMoving)
4229 guiApp.windowMoving.StopMoving();
4231 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4233 if(guiApp.windowScrolling)
4235 Window windowScrolling = guiApp.windowScrolling;
4236 guiApp.windowScrolling = null;
4237 windowScrolling.ReleaseCapture();
4241 if(!result || (window && window.destroyed)) window = null;
4243 if(window && window.FindModal())
4246 if(trueWindow && trueWindow.FindModal())
4254 msgWindow = GetAtPosition(x,y, true, false);
4256 msgWindow.SelectMouseCursor();
4259 if(guiApp.windowCaptured || trueWindow)
4261 Window prevWindow = guiApp.prevWindow;
4262 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4264 guiApp.prevWindow.mouseInside = false;
4265 guiApp.prevWindow = null;
4267 // Eventually fix this not to include captured?
4268 if(!trueWindow.IsDescendantOf(prevWindow) && !prevWindow.OnMouseLeave(*mods))
4271 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4273 Box box = trueWindow.box;
4274 box.left += trueWindow.absPosition.x;
4275 box.right += trueWindow.absPosition.x;
4276 box.top += trueWindow.absPosition.y;
4277 box.bottom += trueWindow.absPosition.y;
4279 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4281 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4282 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4284 overX = Max(Min(overX, 32767),-32768);
4285 overY = Max(Min(overY, 32767),-32768);
4287 trueWindow.mouseInside = true;
4288 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4292 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4293 guiApp.prevWindow = trueWindow;
4295 guiApp.prevWindow = null;
4297 SelectMouseCursor();
4299 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4300 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4302 int clientX = x - (window.absPosition.x + window.clientStart.x);
4303 int clientY = y - (window.absPosition.y + window.clientStart.y);
4305 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4307 clientX = Max(Min(clientX, 32767),-32768);
4308 clientY = Max(Min(clientY, 32767),-32768);
4310 MouseMethod = (void *)window._vTbl[method];
4312 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4315 if(!MouseMethod(window, clientX, clientY, *mods))
4322 if(result && w && w.clickThrough && w.parent)
4327 if(!result || !w || !w.clickThrough)
4334 // --- Mouse cursor management ---
4336 bool KeyMessage(uint method, Key key, unichar character)
4341 if(guiApp.interimWindow)
4342 this = guiApp.interimWindow;
4345 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4349 if(!style.inactive || rootWindow != this)
4351 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4352 Window modalWindow = FindModal();
4353 Window interimMaster = master ? master.rootWindow : null;
4357 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4358 status = OnSysKeyDown(key, character);
4359 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4360 status = OnSysKeyHit(key, character);
4361 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4362 status = OnSysKeyUp(key, character);
4369 // Process Key Message for Internal UI Keyboard actions
4370 if(status && !destroyed && menuBar && state != minimized)
4373 if((SmartKey)key != alt)
4374 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4377 SmartKey sk = (SmartKey) key;
4378 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4380 status = menuBar.KeyMessage(method, key, character);
4385 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4386 menuBar.OnKeyHit(escape, 0);
4388 if(!menuBar.focus && guiApp.caretOwner)
4389 guiApp.caretOwner.UpdateCaret(true, false);
4392 if(!destroyed && status)
4394 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4398 case left: case up: case right: case down:
4399 if(guiApp.windowMoving == this)
4402 int w = guiApp.windowMoving.size.w;
4403 int h = guiApp.windowMoving.size.h;
4404 int x = guiApp.windowMoving.scrolledPos.x;
4405 int y = guiApp.windowMoving.scrolledPos.y;
4409 if(key == down || key == up)
4410 step = Max(step, textCellH);
4412 step = Max(step, textCellW);
4415 if(guiApp.windowIsResizing)
4419 case left: w-=step; break;
4420 case right: w+=step; break;
4421 case up: h-=step; break;
4422 case down: h+=step; break;
4429 case left: x-=step; break;
4430 case right: x+=step; break;
4431 case up: y-=step; break;
4432 case down: y+=step; break;
4436 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4437 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4439 if(!guiApp.windowIsResizing || guiApp.resizeX)
4440 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4442 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4444 if(!guiApp.windowIsResizing || guiApp.resizeY)
4445 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4447 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4449 guiApp.interfaceDriver.SetMousePosition(x, y);
4450 ConsequentialMouseMove(true);
4458 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4460 guiApp.windowMoving.StopMoving();
4461 ConsequentialMouseMove(false);
4469 ShowSysMenu(absPosition.x, absPosition.y);
4477 if(!destroyed && status && state != minimized)
4479 // Process all the way down the children
4480 if(activeChild && !activeChild.disabled)
4482 status = activeChild.KeyMessage(method, key, character);
4484 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4485 key.code != left && key.code != right && key.code != up && key.code != down)
4487 status = activeClient.KeyMessage(method, key, character);
4491 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4493 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4494 // && defaultControl != activeChild)
4496 delete previousActive;
4497 previousActive = activeChild;
4498 if(previousActive) incref previousActive;
4500 ConsequentialMouseMove(false);
4501 if((defaultControl.active ||
4502 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4503 defaultControl.KeyMessage(method, defaultKey, character);
4509 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4511 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4518 ShowSysMenu(absPosition.x, absPosition.y);
4525 if(this != guiApp.desktop)
4527 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4529 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4531 MenuMoveOrSize(key.shift, true);
4535 else if(guiApp.windowMoving)
4537 guiApp.windowMoving.StopMoving();
4538 ConsequentialMouseMove(false);
4546 if(!destroyed && status && state != minimized)
4548 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4552 case tab: case shiftTab:
4554 Window cycleParent = this;
4555 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4556 cycleParent = master.parent;
4558 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4560 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4562 Window child = cycleParent.activeChild;
4564 // Scroll the window to include the active control
4566 if(cycleParent.sbh && !child.style.dontScrollHorz)
4568 if(child.scrolledPos.x < 0)
4569 cycleParent.sbh.Action(Position,
4570 cycleParent.scroll.x + child.scrolledPos.x, 0);
4571 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4572 cycleParent.sbh.Action(Position,
4573 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4575 if(cycleParent.sbv && !child.style.dontScrollVert)
4577 if(child.scrolledPos.y < 0)
4578 cycleParent.sbv.Action(Position,
4579 cycleParent.scroll.y + child.scrolledPos.y, 0);
4580 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4581 cycleParent.sbv.Action(Position,
4582 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4585 cycleParent.ConsequentialMouseMove(false);
4591 case f6: case shiftF6:
4592 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4594 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4595 if(parent == guiApp.desktop)
4596 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4606 if(CycleChildren(key.shift, true, false, true))
4614 // mIRC Style Window Shortcuts
4615 case alt1: case alt2: case alt3: case alt4: case alt5:
4616 case alt6: case alt7: case alt8: case alt9: case alt0:
4621 for(document = children.first; document; document = document.next)
4623 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4625 if(document == activeChild)
4627 if(document.state == minimized)
4628 document.SetState(normal, false, key);
4631 document.SetState(minimized, false, key);
4632 CycleChildren(false, true, false);
4637 if(activeChild.state == maximized && document.style.hasMaximize)
4638 document.SetState(maximized, false, key);
4639 else if(document.state == minimized)
4640 document.SetState(normal, false, key);
4641 document.Activate();
4656 if(!destroyed && status)
4658 if(state == minimized)
4663 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4665 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4667 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4668 previousActive.ActivateEx(true, false, false, true, null, null);
4669 delete previousActive;
4675 if(!destroyed && status)
4677 status = ProcessHotKeys(method, key, character);
4679 if(!destroyed && status && !modalWindow && state != minimized)
4682 status = KeyMethod(this, key, character);
4683 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4684 status = OnKeyHit(key, character);
4685 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4687 bool result = false;
4690 case ctrlUp: case ctrlDown:
4691 if(sbv && !guiApp.windowScrolling)
4692 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4694 case wheelUp: case wheelDown:
4695 if(sbv && !guiApp.windowScrolling)
4697 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4698 // Do we want to do a consequential move regardless of result in this case?
4699 ConsequentialMouseMove(false);
4702 case ctrlPageUp: case ctrlPageDown:
4703 if(sbh && !guiApp.windowScrolling)
4704 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4709 ConsequentialMouseMove(false);
4714 if(status && !destroyed && menuBar && state != minimized)
4715 status = menuBar.KeyMessage(method, key, character);
4717 if(style.interim && /*destroyed && */status && interimMaster)
4719 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4720 status = interimMaster.KeyMessage(method, key, character);
4727 bool ProcessHotKeys(uint method, Key key, unichar character)
4732 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4733 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4734 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4736 Window hotKeyWindow = hotKey.window;
4737 Window parent = hotKeyWindow.parent;
4738 Window prevActiveWindow = activeChild;
4739 // For when sys buttons are placed inside the menu bar
4740 if(parent && parent._class == class(PopupMenu))
4741 parent = parent.parent;
4743 // 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
4744 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4747 if(prevActiveWindow) incref prevActiveWindow;
4748 incref hotKeyWindow;
4749 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4750 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4753 delete hotKeyWindow;
4754 delete prevActiveWindow;
4758 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4759 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4760 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4762 // ********* WORKING ON THIS ***********
4763 if(prevActiveWindow && !guiApp.interimWindow)
4764 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4767 else if(hotKeyWindow.style.inactive)
4768 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4770 delete prevActiveWindow;
4771 delete hotKeyWindow;
4772 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4773 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4777 if(status && tabCycle)
4780 for(child = children.first; child; child = child.next)
4782 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4793 // --- Windows and graphics initialization / termination ---
4794 bool SetupRoot(void)
4798 // Setup relationship with outside world (bb root || !bb)
4799 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4800 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4804 tempExtents = new0 Extent[4];
4809 /*if(guiApp.fullScreenMode)
4810 rootWindow = guiApp.desktop;
4812 //rootWindow = parent.created ? parent.rootWindow : null;
4813 rootWindow = parent.rootWindow;
4816 against = &parent.box;
4818 against = &parent.clientArea;
4821 for(child = children.first; child; child = child.next)
4824 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4827 bool Setup(bool positionChildren)
4829 bool result = false;
4832 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4834 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4835 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4838 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4840 // This was here, is it really needed?
4841 //guiApp.interfaceDriver.ActivateRootWindow(this);
4845 displaySystem = DisplaySystem {};
4846 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4848 delete displaySystem;
4853 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4854 if(display.Create(displaySystem, windowHandle))
4861 // Sometimes icon does not show up on Windows XP if we set here...
4862 // guiApp.interfaceDriver.SetIcon(this, icon);
4864 else if(this != guiApp.desktop)
4866 display = rootWindow ? rootWindow.display : null;
4872 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4873 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4875 for(child = children.first; child; child = child.next)
4877 if(child.created && !child.Setup(false))
4880 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4881 child.UpdateCaption();
4886 bool SetupDisplay(void)
4888 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4889 if(is3D) return Window3D_SetupDisplay(this); else
4896 class_data void ** pureVTbl;
4898 bool LoadGraphics(bool creation, bool resetAnchors)
4900 bool result = false;
4901 bool success = false;
4903 WindowState stateBackup = state;
4905 if(((subclass(Window))_class).pureVTbl)
4907 if(_vTbl == _class._vTbl)
4909 _vTbl = ((subclass(Window))_class).pureVTbl;
4914 for(m = 0; m < _class.vTblSize; m++)
4916 if(_vTbl[m] == _class._vTbl[m])
4917 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4921 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4923 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4925 _vTbl = _class._vTbl;
4930 for(m = 0; m < _class.vTblSize; m++)
4932 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4933 _vTbl[m] = _class._vTbl[m];
4938 if(guiApp.fullScreenMode || this != guiApp.desktop)
4940 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4946 display.Lock(false);
4947 if(rootWindow == this)
4949 // Set Color Palette
4950 display.SetPalette(palette, true);
4954 if(guiApp.fullScreenMode && this == guiApp.desktop)
4959 for(c=0; c<SystemCursor::enumSize; c++)
4960 if(!guiApp.systemCursors[c].bitmap)
4962 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4963 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4964 if(guiApp.systemCursors[c].bitmapName)
4966 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4967 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4968 if(guiApp.systemCursors[c].bitmap)
4969 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4974 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4976 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4977 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4979 cursor.bitmap.paletteShades = cursor.paletteShades;
4983 guiApp.cursorUpdate = true;
4986 ConsequentialMouseMove(false);
4992 // Load Window Graphic Resources
4995 if(usedFont == setFont || usedFont == window.systemFont)
4996 RemoveResource(usedFont);
4999 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5002 RemoveResource(systemFont);
5005 RemoveResource(captionFont);
5007 for(ptr = resources.first; ptr; ptr = ptr.next)
5009 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5010 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5013 AddResource(setFont);
5015 AddResource(systemFont);
5017 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5024 //if(master && master.font)
5025 if(parent && parent.font)
5029 faceName = parent.font.faceName,
5030 size = parent.font.size,
5031 bold = parent.font.bold,
5032 italic = parent.font.italic,
5033 underline = parent.font.underline
5035 //font = parent.font;
5036 watch(parent) { font { } };
5039 font = guiApp.currentSkin.SystemFont();
5046 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5047 AddResource(captionFont);
5049 if(OnLoadGraphics())
5055 //SetScrollLineStep(sbStep.x, sbStep.y);
5057 if(this != guiApp.desktop)
5061 normalAnchor = anchor;
5062 normalSizeAnchor = sizeAnchor;
5065 // Break the anchors for moveable/resizable windows
5067 if(style.fixed && style.isDocument)
5069 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5081 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5082 stateSizeAnchor = SizeAnchor {};
5087 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5092 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5093 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5096 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5100 stateAnchor = normalAnchor;
5101 stateSizeAnchor = normalSizeAnchor;
5104 position = Point { };
5105 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5116 if(Position(x, y, w, h, true, false, true, true, true, true))
5118 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5121 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5138 success = result = true;
5141 if(!creation && result)
5143 // Load menu bar first because sys buttons are on it...
5146 if(!menuBar.LoadGraphics(false, resetAnchors))
5152 for(child = children.first; child; child = child.next)
5154 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5161 CreateSystemChildren();
5165 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5168 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5173 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5174 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5177 // Do this here to avoid problems on Windows
5178 if(stateBackup == maximized)
5179 property::state = maximized;
5183 void UnloadGraphics(bool destroyWindows)
5187 // Free children's graphics
5188 for(child = children.first; child; child = child.next)
5189 child.UnloadGraphics(destroyWindows);
5192 display.Lock(false);
5195 if(guiApp.fullScreenMode && this == guiApp.desktop)
5200 for(c=0; c<SystemCursor::enumSize; c++)
5201 if(guiApp.systemCursors[c].bitmap)
5202 delete guiApp.systemCursors[c].bitmap;
5204 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5205 delete cursor.bitmap;
5207 guiApp.cursorBackground.Free();
5210 if(display && display.displaySystem)
5214 for(ptr = resources.first; ptr; ptr = ptr.next)
5218 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5223 // Free window graphics
5226 // Free skin graphics
5227 if(rootWindow == this)
5229 DisplaySystem displaySystem = display.displaySystem;
5232 display.driverData = null;
5233 display.displaySystem = null;
5237 if(displaySystem && !displaySystem.numDisplays && !is3D)
5238 delete displaySystem;
5247 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5248 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5250 if(this == guiApp.desktop || parent == guiApp.desktop)
5252 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5253 guiApp.interfaceDriver.DestroyRootWindow(this);
5257 // --- Window Hiding ---
5259 void SetVisibility(bool state)
5261 bool visible = (style.hidden || !created) ? false : state;
5262 if(visible != this.visible)
5266 this.visible = visible;
5267 for(child = children.first; child; child = child.next)
5268 child.SetVisibility(visible);
5270 ConsequentialMouseMove(false);
5271 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5275 // --- Windows and graphics initialization / termination ---
5277 bool DisplayModeChanged(void)
5279 bool result = false;
5280 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5282 guiApp.modeSwitching = true;
5283 UnloadGraphics(false);
5285 if(LoadGraphics(false, false))
5287 guiApp.modeSwitching = false;
5292 // --- Window updates system ---
5294 void UpdateDirty(Box updateBox)
5296 if(!manageDisplay) { OnRedraw(null);return; }
5299 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5302 if(display.flags.flipping)
5305 rootWindow.UpdateDisplay();
5308 UpdateBackDisplay(updateBox);
5310 if(guiApp.fullScreenMode)
5312 guiApp.cursorUpdate = true;
5313 guiApp.PreserveAndDrawCursor();
5315 if(guiApp.fullScreenMode)
5316 guiApp.RestoreCursorBackground();
5322 // This function is strictly called as a result of system window activation
5323 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5326 Window interimMaster = null;
5327 Window interimWindow = guiApp.interimWindow;
5328 if(interimWindow && interimWindow.master)
5329 interimMaster = interimWindow.master.rootWindow;
5331 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5332 // SetState(normal, false, 0);
5333 SetState(lastState, false, 0);
5335 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5339 /* WTH is this doing here?
5340 while(swap && swap.activeChild)
5342 swap = swap.activeChild;
5345 // TESTING THIS BEFORE...
5346 if(interimWindow && this == interimMaster)
5350 // Window interimSwap = this;
5351 Window menuBar = this.menuBar;
5352 if(menuBar && interimWindow.master == menuBar)
5355 while(interimSwap && interimSwap.activeChild)
5356 interimSwap = interimSwap.activeChild;
5358 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5359 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5361 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5362 //result = ActivateEx(true, true, false, activateRoot, window, null);
5367 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5368 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5370 if(interimWindow == this && interimMaster && !active)
5372 while(interimMaster && interimMaster.interim && interimMaster.master)
5374 // printf("Going up one master %s\n", interimMaster._class.name);
5375 interimMaster = interimMaster.master.rootWindow;
5377 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5378 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5384 bool DestroyEx(int64 returnCode)
5387 Timer timer, nextTimer;
5389 OldLink prevOrder = null;
5390 Window client = null;
5392 if(parent) stopwatching(parent, font);
5394 // if(window.modalSlave) return false;
5395 if(destroyed || !created)
5402 OldLink slave = master.slaves.FindLink(this);
5403 master.slaves.Delete(slave);
5406 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5412 this.returnCode = (DialogResult)returnCode;
5414 AcquireInput(false);
5419 master.hotKeys.Delete(hotKey);
5423 if(guiApp.prevWindow == this)
5425 guiApp.prevWindow = null;
5428 if(guiApp.caretOwner == this)
5430 guiApp.interfaceDriver.SetCaret(0,0,0);
5431 UpdateCaret(false, true);
5432 guiApp.caretEnabled = false;
5437 parent.childrenCycle.Remove(cycle);
5441 OldLink tmpPrev = order.prev;
5442 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5443 prevOrder = tmpPrev;
5446 client = tmpPrev ? tmpPrev.data : null;
5447 if(client == this) { client = null; break; }
5448 if(client && (client.style.hidden || client.destroyed || !client.created))
5449 tmpPrev = client.order.prev;
5453 prevOrder = tmpPrev;
5458 // If this window can be an active client, make sure the next window we activate can also be one
5459 if(!style.nonClient && style.isActiveClient)
5461 tmpPrev = prevOrder;
5464 client = tmpPrev ? tmpPrev.data : null;
5465 if(client == this) { client = null; break; }
5466 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5467 tmpPrev = client.order.prev;
5471 prevOrder = tmpPrev;
5475 if(client && client.style.hidden) client = null;
5477 // parent.childrenOrder.Remove(order);
5480 if(parent && style.isActiveClient && visible)
5482 if(state == minimized) parent.numIcons--;
5483 parent.numPositions--;
5486 // TESTING THIS HERE!
5490 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5491 // to create a window inside a rootwindow that's being destroyed)
5492 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5494 if(master && !master.destroyed /*&&
5495 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5497 if(master.defaultControl == this)
5498 master.defaultControl = null;
5501 parent.OnChildAddedOrRemoved(this, true);
5502 if(parent && !parent.destroyed /*&&
5503 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5505 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5507 if(order && prevOrder && prevOrder.data != this && active)
5509 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5511 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5512 if(parent.activeClient == this)
5514 parent.activeClient = null;
5515 parent.UpdateActiveDocument(null);
5520 if(guiApp.interimWindow == this)
5523 PropagateActive(false, null, &goOn, true);
5527 //if(window.parent.activeChild == window)
5528 parent.activeChild = null;
5529 if(!style.nonClient /*&& style.isActiveClient*/)
5531 Window previous = parent.activeClient;
5532 if(style.isActiveClient)
5533 parent.activeClient = null;
5534 parent.UpdateActiveDocument(previous);
5539 else if(parent.activeClient == this)
5541 parent.activeClient = client;
5542 parent.UpdateActiveDocument(this);
5546 if(guiApp.interimWindow == this)
5548 guiApp.interimWindow = null;
5549 if(guiApp.caretOwner)
5551 Window desktop = guiApp.desktop;
5552 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5553 guiApp.caretOwner.UpdateCaret(false, false);
5558 if(_isModal && master && master.modalSlave == this)
5559 master.modalSlave = null;
5563 if(!guiApp.caretOwner && parent.caretSize)
5565 guiApp.caretOwner = parent;
5566 parent.UpdateCaret(false, false);
5567 parent.Update(null);
5570 // Why was this commented out?
5571 GetRidOfVirtualArea();
5577 dirtyArea.Free(null);
5578 dirtyBack.Free(null);
5579 scrollExtent.Free(null);
5581 /* ATTEMPTING TO MOVE THAT ABOVE
5590 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5591 for(;(child = window.children.first);)
5593 for(; child && (child.destroyed || !child.created); child = child.next);
5602 UnloadGraphics(true);
5605 delete previousActive;
5608 // statusBar = null;
5611 if(master && !master.destroyed)
5613 //master.NotifyDestroyed(this, this.returnCode);
5614 NotifyDestroyed(master, this, this.returnCode);
5617 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5619 nextTimer = timer.next;
5620 if(timer.window == this)
5622 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5623 // timer.window = null;
5629 if(this == guiApp.windowMoving)
5632 if(guiApp.windowCaptured == this)
5634 //guiApp.windowCaptured = null;
5636 if(rootWindow != this && rootWindow)
5637 rootWindow.ConsequentialMouseMove(false);
5645 //for(child = children.first; next = child ? child.next : null, child; child = next)
5646 for(;(child = children.first); )
5648 for(; child && (child.destroyed || !child.created); child = child.next);
5658 /* // MOVED THIS UP...
5661 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5662 for(;(child = window.children.first); )
5664 for(; child && (child.destroyed || !child.created); child = child.next);
5673 while((slave = slaves.first))
5675 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5677 ((Window)slave.data).DestroyEx(0);
5682 if(guiApp.caretOwner == this)
5683 guiApp.caretOwner = null;
5685 sysButtons[0] = null;
5686 sysButtons[1] = null;
5687 sysButtons[2] = null;
5690 if(rootWindow != this)
5692 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5695 box.left -= parent.clientStart.x;
5696 box.top -= parent.clientStart.y;
5697 box.right -= parent.clientStart.x;
5698 box.bottom -= parent.clientStart.y;
5700 if(parent) parent.Update(box);
5705 OldLink slave = master.slaves.FindVoid(this);
5706 master.slaves.Delete(slave);
5712 parent.children.Remove(this);
5717 //autoCreate = false;
5720 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5721 if(((subclass(Window))_class).pureVTbl)
5723 if(_vTbl == _class._vTbl)
5725 _vTbl = ((subclass(Window))_class).pureVTbl;
5730 for(m = 0; m < _class.vTblSize; m++)
5732 if(_vTbl[m] == _class._vTbl[m])
5733 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5742 void SetStateEx(WindowState newState, bool activate)
5745 WindowState prevState = state;
5749 if(prevState != newState)
5750 lastState = prevState;
5752 if(rootWindow != this || !nativeDecorations || !windowHandle)
5754 if(style.isActiveClient && !style.hidden && prevState == minimized)
5757 // This block used to be at the end of the function... moved it for flicker problem in X
5758 // ------------------------------------------------------
5762 stateAnchor = normalAnchor;
5763 stateSizeAnchor = normalSizeAnchor;
5766 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5767 stateSizeAnchor = SizeAnchor {};
5771 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5774 byte * idBuffer = new0 byte[size];
5776 for(child = parent.children.first; child; child = child.next)
5778 if(child != this && child.state == minimized)
5780 if(child.iconID > size - 2)
5782 idBuffer = renew0 idBuffer byte[size*2];
5783 memset(idBuffer + size, 0, size);
5786 idBuffer[child.iconID] = (byte)bool::true;
5789 for(c = 0; c<size; c++)
5794 if(style.isActiveClient && !style.hidden)
5797 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5798 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5802 // TOCHECK: Why was this here?
5803 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5804 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5805 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5807 Position(x, y, w, h, true, true, true, true, false, true);
5809 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5810 parent.UpdateActiveDocument(null);
5813 CreateSystemChildren();
5814 // ------------------------------------------------------
5817 int GetPositionID(Window forChild)
5821 byte * idBuffer = new0 byte[size];
5824 for(child = children.first; child; child = child.next)
5826 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5828 if(child.positionID > size - 2)
5830 idBuffer = renew0 idBuffer byte[size*2];
5831 memset(idBuffer + size, 0, size);
5834 idBuffer[child.positionID] = (byte)bool::true;
5837 for(c = 0; c<size; c++)
5844 // --- Window related graphics ---
5846 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5848 palette = newPalette;
5849 if(rootWindow.display)
5850 rootWindow.display.SetPalette(palette, colorMatch);
5853 public bool AcquireInput(bool acquired)
5856 if(acquiredInput != acquired)
5858 if(active || (!visible && creationActivation == activate))
5859 result = AcquireInputEx(acquired);
5864 acquiredInput = acquired ? result : !result;
5869 void ListChildren(ListBox listBox)
5873 for(child = children.first; child; child = child.next)
5875 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5877 DataRow row = listBox.AddRow();
5878 row.tag = (int64)child;
5879 child.FigureCaption(caption);
5880 row.SetData(null, caption);
5885 void UpdateVisual(Box extent)
5887 if(guiApp.driver != null)
5889 if(guiApp.fullScreenMode && guiApp.desktop.display)
5891 guiApp.desktop.mutex.Wait();
5892 guiApp.desktop.display.Lock(true);
5895 if(guiApp.desktop.active)
5897 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5899 if(guiApp.desktop.display.flags.flipping)
5900 guiApp.desktop.Update(null);
5901 guiApp.desktop.UpdateDisplay();
5902 guiApp.cursorUpdate = true;
5904 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5906 guiApp.PreserveAndDrawCursor();
5907 // guiApp.desktop.display.ShowScreen();
5908 guiApp.cursorUpdate = false;
5909 guiApp.desktop.dirty = false;
5910 guiApp.RestoreCursorBackground();
5914 guiApp.desktop.display.Unlock();
5915 guiApp.desktop.mutex.Release();
5919 Window rootWindow = this.rootWindow;
5920 rootWindow.mutex.Wait();
5925 guiApp.SignalEvent();
5928 guiApp.waitMutex.Wait();
5929 guiApp.interfaceDriver.Lock(rootWindow);
5930 if(!rootWindow.style.hidden && rootWindow.dirty)
5932 if(rootWindow.display)
5934 rootWindow.UpdateDisplay();
5935 //rootWindow.display.ShowScreen(null);
5937 rootWindow.dirty = false;
5939 guiApp.interfaceDriver.Unlock(rootWindow);
5940 guiApp.waitMutex.Release();
5943 rootWindow.mutex.Release();
5948 void UnlockDisplay(void)
5950 guiApp.interfaceDriver.Unlock(rootWindow);
5953 void LockDisplay(void)
5955 guiApp.interfaceDriver.Lock(rootWindow);
5958 Surface GetSurface(Box box)
5960 return Redraw((box == null) ? this.box : box);
5963 void SetMousePosition(int x, int y)
5965 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5969 void IntegrationActivate(bool active)
5971 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5973 isForegroundWindow = true;
5974 ActivateEx(active, active, false, false, null, null);
5975 isForegroundWindow = false;
5980 Window QueryCapture(void)
5982 return guiApp.windowCaptured;
5985 int GetDocumentID(void)
5989 byte * idBuffer = new0 byte[size];
5992 for(child = children.first; child; child = child.next)
5994 // TO CHECK: Do we want a documentID when we already have a file name?
5995 if(child.style.isDocument && !child.fileName)
5997 if(child.documentID-1 > size - 2)
5999 idBuffer = renew0 idBuffer byte[size*2];
6000 memset(idBuffer + size, 0, size);
6003 idBuffer[child.documentID-1] = 1;
6006 for(c = 0; c<size; c++)
6014 void SetInitSize(Size size)
6017 sizeAnchor.size = size;
6018 normalSizeAnchor = sizeAnchor;
6020 // Break the anchors for moveable/resizable windows
6021 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6023 stateAnchor = normalAnchor;
6024 stateSizeAnchor = normalSizeAnchor;
6026 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6027 Position(x,y, w, h, true, true, true, true, false, true);
6031 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6033 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6035 guiApp.windowIsResizing = resize;
6036 guiApp.windowMoving = this;
6037 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6038 if(guiApp.windowIsResizing)
6040 guiApp.windowMovingStart.x += size.w - 1;
6041 guiApp.windowMovingStart.y += size.h - 1;
6043 guiApp.windowMovingBefore = scrolledPos;
6044 guiApp.windowResizingBefore = size;
6045 guiApp.windowMoving.UpdateDecorations();
6046 if(guiApp.windowIsResizing)
6047 guiApp.resizeEndX = guiApp.resizeEndY = true;
6049 if(setCursorPosition)
6050 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6054 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6055 guiApp.windowMovingStart.x += x - absPosition.x;
6056 guiApp.windowMovingStart.y += y - absPosition.y;
6059 if(guiApp.windowMoving)
6061 if(guiApp.windowMoving.style.nonClient)
6062 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6064 guiApp.windowMoving.parent.SetMouseRangeToClient();
6069 if(this == rootWindow)
6070 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6078 bool result = false;
6082 else if(guiApp && guiApp.driver != null)
6084 void * systemParent = null;
6085 OldLink slaveHolder;
6087 bool visible = !style.hidden;
6091 systemParent = parent;
6092 parent = guiApp.desktop;
6094 last = parent ? parent.children.last : null;
6096 if((parent && parent != guiApp.desktop && !parent.created) ||
6097 (master && master != guiApp.desktop && !master.created))
6101 stopwatching(parent, font);
6104 property::parent = guiApp.desktop;
6105 if(!master) master = parent;
6107 if(_isModal && master.modalSlave)
6108 property::master = master.modalSlave;
6112 parent.children.Remove(this);
6115 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6116 if(slaveHolder.data == this)
6118 master.slaves.Delete(slaveHolder);
6123 if(parent == guiApp.desktop && !mutex)
6126 if(style.isDocument)
6129 parent.numDocuments--;
6130 documentID = parent.GetDocumentID();
6133 if(!style.stayOnTop)
6134 for(; last && last.style.stayOnTop; last = last.prev);
6136 parent.children.Insert((last == this) ? null : last, this);
6137 //parent.children.Add(this);
6140 dispDriver = parent.dispDriver;
6143 master.modalSlave = this;
6145 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6150 master.slaves.Add(slaveHolder = OldLink { data = this });
6155 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6157 if(style.isDefault && !master.defaultControl)
6158 master.defaultControl = this;
6160 stateAnchor = normalAnchor = anchor;
6161 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6163 // TOCHECK: Why is this here?
6164 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6165 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6167 this.visible = false;
6168 style.hidden = true;
6171 // autoCreate = true;
6179 if(parent == guiApp.desktop)
6180 Log("LoadGraphics %s\n", caption);
6182 if(LoadGraphics(true, false))
6190 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6197 if(style.hasMenuBar /*&& menu*/)
6203 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6204 interim = false, inactive = true, nonClient = true, size.h = 24
6212 // Create the system buttons
6213 CreateSystemChildren();
6215 UpdateActiveDocument(null);
6217 if(style.isDocument)
6221 MenuItem item = menu.FindItem(MenuFileSave, 0);
6222 if(item) item.disabled = !modifiedDocument && fileName;
6227 if(parent == guiApp.desktop)
6228 Log("Preemptive SetState %s\n", caption);
6231 // Preemptive Set State to ensure proper anchoring
6232 SetStateEx(state, false);
6234 style.hidden = true;
6240 for(child = children.first; child; child = next)
6243 if(!child.created && (child.autoCreate || child.wasCreated))
6250 for(link = slaves.first; link; link = next)
6252 Window slave = link.data;
6254 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6257 // Things might have happened that invalidated 'next'...
6258 // Start over the search for slaves to create.
6259 // (Added this to fix crash with Stacker & Toolbar)
6260 next = slaves.first;
6269 if(parent == guiApp.desktop)
6270 Log("Real SetState %s\n", caption);
6273 if(isActiveClient && visible)
6275 parent.numPositions--;
6276 if(state == minimized) parent.numIcons--;
6279 parent.OnChildAddedOrRemoved(this, false);
6281 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6283 // Real set state & activate for proper display & activation
6284 property::visible = visible;
6285 // SetState(state & 0x00000003, true, 0);
6286 guiApp.interfaceDriver.SetIcon(this, icon);
6291 /*if(rootWindow == this)
6292 guiApp.interfaceDriver.ActivateRootWindow(this);
6294 if(creationActivation == activate)
6295 ActivateEx(true, false, true, true, null, null);
6296 else if(creationActivation == flash)
6301 rootWindow.ConsequentialMouseMove(false);
6312 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6318 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6320 //style.hidden = true; // !visible;
6321 style.hidden = !visible;
6322 if(master.modalSlave == this)
6323 master.modalSlave = null;
6330 void WriteCaption(Surface surface, int x, int y)
6333 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6336 void Update(Box region)
6342 rootWindow = this.rootWindow;
6344 // rootWindow.mutex.Wait();
6345 if(!destroyed && visible && display)
6350 // Testing this to avoid repetitve full update to take time...
6351 if(dirtyArea.count == 1)
6353 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6354 if(item.box.left <= box.left &&
6355 item.box.top <= box.top &&
6356 item.box.right >= box.right &&
6357 item.box.bottom >= box.bottom)
6359 rootWindow.dirty = true;
6364 if(display.flags.flipping && !rootWindow.dirty)
6366 if(this == rootWindow)
6370 rootWindow.Update(null);
6375 rootWindow.dirty = true;
6380 realBox.left += clientStart.x;
6381 realBox.top += clientStart.y;
6382 realBox.right += clientStart.x;
6383 realBox.bottom += clientStart.y;
6389 if(realBox.right >= realBox.left &&
6390 realBox.bottom >= realBox.top)
6392 // if(!rootWindow.fullRender)
6393 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6395 for(child = children.first; child; child = child.next)
6400 box.left -= child.absPosition.x - absPosition.x;
6401 box.top -= child.absPosition.y - absPosition.y;
6402 box.right -= child.absPosition.x - absPosition.x;
6403 box.bottom -= child.absPosition.y - absPosition.y;
6404 if(box.right >= child.box.left && box.left <= child.box.right &&
6405 box.bottom >= child.box.top && box.top <= child.box.bottom)
6407 box.left -= child.clientStart.x;
6408 box.top -= child.clientStart.y;
6409 box.right -= child.clientStart.x;
6410 box.bottom -= child.clientStart.y;
6416 realBox.left += absPosition.x - rootWindow.absPosition.x;
6417 realBox.top += absPosition.y - rootWindow.absPosition.y;
6418 realBox.right += absPosition.x - rootWindow.absPosition.x;
6419 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6420 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6423 else if(this == guiApp.desktop)
6426 for(window = children.first; window; window = window.next)
6432 Box childBox = region;
6434 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6435 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6436 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6437 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6439 window.Update(childBox);
6442 window.Update(null);
6447 // rootWindow.mutex.Release();
6454 if(guiApp.windowCaptured != this)
6456 if(guiApp.windowCaptured)
6460 //Logf("Captured %s (%s)\n", caption, class.name);
6461 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6462 guiApp.windowCaptured = this;
6468 bool Destroy(int64 code)
6473 if(!destroyed && !CloseConfirmation(false)) return false;
6477 // TOCHECK: Should autoCreate be set to false here?
6488 void Move(int x, int y, int w, int h)
6490 normalAnchor = Anchor { left = x, top = y };
6491 normalSizeAnchor = SizeAnchor { size = { w, h } };
6493 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6495 if(destroyed) return;
6497 stateAnchor = normalAnchor;
6498 stateSizeAnchor = normalSizeAnchor;
6500 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6501 Position(x,y, w, h, true, true, true, true, false, true);
6505 DialogResult Modal(void)
6511 // FIXES MEMORY LEAK IF Create() FAILED
6517 void SetScrollArea(int width, int height, bool snapToStep)
6519 bool resize = false;
6522 int stepX = sbStep.x, stepY = sbStep.y;
6523 // Needed to make snapped down position match the skin's check of client area
6524 // against realvirtual
6527 SNAPDOWN(stepX, textCellW);
6528 SNAPDOWN(stepY, textCellH);
6529 stepX = Max(stepX, textCellW);
6530 stepY = Max(stepY, textCellH);
6532 if(scrollFlags.snapX)
6533 SNAPUP(width, stepX);
6534 if(scrollFlags.snapY)
6535 SNAPUP(height, stepY);
6538 reqScrollArea.w = width;
6539 reqScrollArea.h = height;
6540 noAutoScrollArea = (width > 0 || height > 0);
6542 UpdateScrollBars(true, true);
6545 void SetScrollPosition(int x, int y)
6548 sbh.Action(setPosition, x, 0);
6552 int seen = clientSize.w, total = reqScrollArea.w;
6554 if(scrollFlags.snapX)
6555 SNAPDOWN(seen, sbStep.x);
6557 if(!total) total = seen;
6558 range = total - seen + 1;
6559 range = Max(range, 1);
6561 if(x >= range) x = range - 1;
6563 if(scrollFlags.snapX)
6564 SNAPUP(x, sbStep.x);
6567 OnHScroll(setPosition, x, 0);
6571 SNAPDOWN(x, textCellW);
6577 sbv.Action(setPosition, y, 0);
6581 int seen = clientSize.h, total = reqScrollArea.h;
6584 if(scrollFlags.snapY)
6585 SNAPDOWN(seen, sbStep.y);
6587 if(!total) total = seen;
6588 range = total - seen + 1;
6589 range = Max(range, 1);
6591 if(y >= range) y = range - 1;
6593 if(scrollFlags.snapY)
6594 SNAPUP(y, sbStep.y);
6597 OnVScroll(setPosition, y, 0);
6600 SNAPDOWN(y, textCellH);
6605 UpdateCaret(false, false);
6608 void SetScrollLineStep(int stepX, int stepY)
6614 SNAPDOWN(stepX, textCellW);
6615 SNAPDOWN(stepY, textCellH);
6616 stepX = Max(stepX, textCellW);
6617 stepY = Max(stepY, textCellH);
6620 sbh.lineStep = stepX;
6622 sbv.lineStep = stepY;
6625 void SetState(WindowState newState, bool activate, Modifiers mods)
6629 if(state == newState || OnStateChange(newState, mods))
6631 WindowState prevState = state;
6635 // This used to be at the end of the brackets... moved for X, testing...
6636 // This has the effect of activating the window through the system...
6637 if(rootWindow == this)
6638 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6640 SetStateEx(newState, activate);
6642 if(rootWindow == this && !rootWindow.nativeDecorations)
6644 int x = position.x, y = position.y;
6647 x -= guiApp.desktop.absPosition.x;
6648 y -= guiApp.desktop.absPosition.y;
6650 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6654 //state = prevState;
6656 if(state != maximized && style.hasMaximize)
6659 for(child = parent.children.first; child; child = child.next)
6661 if(child != this && child.state == maximized)
6662 child.SetStateEx(normal, false);
6666 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6667 parent.UpdateScrollBars(true, true);
6670 // Do we really need this stuff here?
6671 // Shouldn't the Activate stuff take care of it?
6672 if(parent.rootWindow == parent && style)
6675 parent.FigureCaption(caption);
6676 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6677 parent.UpdateDecorations();
6681 rootWindow.ConsequentialMouseMove(false);
6688 BitmapResource GetIcon(SkinBitmap iconID)
6690 return guiApp.currentSkin.GetBitmap(iconID);
6693 void SetMouseRange(Box range)
6695 if(range || guiApp.fullScreenMode)
6700 clip.left = range.left + absPosition.x + clientStart.x;
6701 clip.top = range.top + absPosition.y + clientStart.y;
6702 clip.right = range.right + absPosition.x + clientStart.x;
6703 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6707 clip.left = guiApp.desktop.box.left;
6708 clip.top = guiApp.desktop.box.top;
6709 clip.right = guiApp.desktop.box.right;
6710 clip.bottom = guiApp.desktop.box.bottom;
6712 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6715 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6718 void SetMouseRangeToClient(void)
6720 if(guiApp.fullScreenMode || this != guiApp.desktop)
6722 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6723 box.Clip(clientArea);
6727 SetMouseRange(null);
6730 void SetMouseRangeToWindow(void)
6732 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6733 if(this == guiApp.desktop)
6734 SetMouseRangeToClient();
6739 // x, y: Desktop Coordinates
6740 void ShowSysMenu(int x, int y)
6743 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6746 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6747 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6751 menu, $"Move", m, NotifySelect = MenuWindowMove,
6752 disabled = !style.fixed || state == maximized
6756 menu, $"Size", s, NotifySelect = MenuWindowSize,
6757 disabled = !style.sizable || state != normal
6761 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6762 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6766 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6767 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6771 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6772 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6774 MenuDivider { menu };
6777 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6778 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6780 windowMenu.Create();
6785 ActivateEx(true, true, true, true, null, null);
6788 void MakeActive(void)
6790 ActivateEx(true, false, true, false, null, null);
6793 void SoftActivate(void)
6795 if(guiApp.desktop.active)
6801 void Deactivate(void)
6803 ActivateEx(false, true, true, true, null, null);
6808 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6811 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6813 bool result = false;
6814 if(activeChild && activeChild.cycle)
6816 Window modalWindow, child = activeChild;
6817 if(!clientOnly /*&& parent.tabCycle*/)
6819 Window next = child;
6822 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6826 if(parent && parent.CycleChildren(backward, false, true, true))
6834 next = next.cycle.prev.data;
6836 next = next.cycle.next.data;
6837 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6842 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6843 parent.tabCycle && parent.CycleChildren(backward, false, false))
6847 if(tabCycleOnly && !tabCycle) return false;
6854 child = child.cycle.prev.data;
6856 child = child.cycle.next.data;
6857 if(child == child.parent.activeChild)
6859 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6862 modalWindow = child.FindModal();
6865 // Scroll the window to include the active control
6866 if(sbh && !child.style.dontScrollHorz)
6868 if(child.scrolledPos.x < 0)
6869 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6870 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6871 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6873 if(sbv && !child.style.dontScrollVert)
6875 if(child.scrolledPos.y < 0)
6876 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6877 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6878 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6882 child = modalWindow ? modalWindow : child;
6883 child.ActivateEx(true, true, true, true, null, null);
6884 if(child.tabCycle && child.childrenCycle.first)
6885 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6893 ConsequentialMouseMove(false);
6897 void AddResource(Resource resource)
6901 ResPtr ptr { resource = resource };
6905 // Load Graphics here if window is created already
6906 if(/*created && */display)
6908 display.Lock(false);
6909 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
6910 ptr.loaded = display.displaySystem.LoadResource(resource);
6914 // Temporary hack to load font right away for listbox in dropbox ...
6915 else if(master && master.display)
6917 master.display.Lock(false);
6918 master.display.displaySystem.LoadResource(resource);
6919 master.display.Unlock();
6925 void RemoveResource(Resource resource)
6930 for(ptr = resources.first; ptr; ptr = ptr.next)
6932 if(ptr.resource == resource)
6938 // Unload Graphics here if window is created already
6939 if(/*created && */display)
6943 display.Lock(false);
6944 display.displaySystem.UnloadResource(resource, ptr.loaded);
6950 resources.Delete(ptr);
6955 void SetCaret(int x, int y, int size)
6962 if(active && !style.interim && isEnabled)
6964 if(visible || !guiApp.caretOwner)
6965 guiApp.caretOwner = size ? this : null;
6967 UpdateCaret(false, false);
6970 guiApp.interfaceDriver.SetCaret(0,0,0);
6971 UpdateCaret(false, true);
6972 guiApp.caretEnabled = false;
6975 else if(style.inactive && active)
6977 guiApp.interfaceDriver.SetCaret(0,0,0);
6978 UpdateCaret(false, true);
6979 guiApp.caretEnabled = false;
6984 void Scroll(int x, int y)
6986 bool opaque = !style.drawBehind || background.a;
6987 if(opaque && display && display.flags.scrolling)
6989 Box box = clientArea;
6990 box.left += clientStart.x;
6991 box.top += clientStart.y;
6992 box.right += clientStart.x;
6993 box.bottom += clientStart.y;
6995 //scrollExtent.Free(null);
6996 scrollExtent.AddBox(box);
6997 scrolledArea.x += x;
6998 scrolledArea.y += y;
7000 //scrollExtent.Free();
7001 //scrollExtent.AddBox(clientArea);
7002 //scrollExtent.Offset(clientStart.x, clientStart.y);
7003 //scrolledArea.x = x;
7004 //scrolledArea.y = y;
7010 rootWindow.dirty = true;
7013 void ReleaseCapture()
7015 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7017 Window oldCaptured = guiApp.windowCaptured;
7018 guiApp.windowCaptured = null;
7019 guiApp.prevWindow = null;
7022 //guiApp.Log("Released Capture\n");
7024 guiApp.interfaceDriver.SetMouseCapture(null);
7026 //oldCaptured.OnMouseCaptureLost();
7029 oldCaptured.ConsequentialMouseMove(false);
7034 private void _SetCaption(char * format, va_list args)
7041 char caption[MAX_F_STRING];
7042 vsnprintf(caption, sizeof(caption), format, args);
7043 caption[sizeof(caption)-1] = 0;
7045 this.caption = CopyString(caption);
7050 firewatchers caption;
7054 /*deprecated*/ void SetText(char * format, ...)
7057 va_start(args, format);
7058 _SetCaption(format, args);
7062 void SetCaption(char * format, ...)
7065 va_start(args, format);
7066 _SetCaption(format, args);
7070 bool Grab(Bitmap bitmap, Box box, bool decorations)
7072 bool result = false;
7073 if(display || this == guiApp.desktop)
7075 Box clip = {MININT, MININT, MAXINT, MAXINT};
7081 clip.Clip(clientArea);
7083 clip.Clip(this.box);
7085 if(rootWindow != this)
7087 clip.left += absPosition.y;
7088 clip.top += absPosition.y;
7089 clip.right += absPosition.x;
7090 clip.bottom += absPosition.y;
7093 clip.left += decorations ? 0 : clientStart.x;
7094 clip.top += decorations ? 0 : clientStart.y;
7095 clip.right += decorations ? 0 : clientStart.x;
7096 clip.bottom += decorations ? 0 : clientStart.y;
7098 if(display && display.flags.flipping)
7100 rootWindow.Update(null);
7101 rootWindow.UpdateDisplay();
7108 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7109 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7113 result = display.Grab(bitmap, clip.left, clip.top,
7114 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7116 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7118 if(!bitmap.Convert(null, pixelFormat888, null))
7125 void GetMousePosition(int * x, int * y)
7127 int mouseX = 0, mouseY = 0;
7128 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7131 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7132 if(this != guiApp.desktop)
7134 mouseX -= absPosition.x + clientStart.x;
7135 mouseY -= absPosition.y + clientStart.y;
7142 DialogResult DoModal()
7144 DialogResult returnCode = 0;
7145 int terminated = terminateX;
7148 while(!destroyed && guiApp.driver != null)
7150 if(terminateX != terminated)
7152 terminated = terminateX;
7153 guiApp.desktop.Destroy(0);
7154 if(guiApp.desktop.created)
7157 //printf("Resetting terminate X to 0\n");
7163 guiApp.UpdateDisplay();
7164 if(!guiApp.ProcessInput(false))
7167 returnCode = this.returnCode;
7180 return !destroyed && guiApp.driver != null && terminateX < 2;
7183 DialogResult DoModalEnd()
7185 DialogResult returnCode = this.returnCode;
7190 // --- Window manipulation ---
7191 /*bool GetDisabled()
7193 bool disabled = this.disabled;
7195 for(window = this; (window = window.master); )
7206 // --- Mouse Manipulation ---
7207 void GetNCMousePosition(int * x, int * y)
7209 GetMousePosition(x, y);
7210 if(x) *x += clientStart.x;
7211 if(y) *y += clientStart.y;
7214 // --- Carets manipulation ---
7215 void GetCaretPosition(Point caretPos)
7217 caretPos = this.caretPos;
7220 int GetCaretSize(void)
7225 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7231 bool CloseConfirmation(bool parentClosing)
7244 if(!OnClose(parentClosing))
7247 // If you want to skip this, simply set modifiedDocument to false in OnClose
7248 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7250 DialogResult dialogRes;
7253 sprintf(message, $"Save changes to %s?", fileName);
7255 sprintf(message, $"Save changes to Untitled %d?", documentID);
7257 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7259 if(dialogRes == yes)
7261 // TOFIX: Precomp error if brackets are taken out
7262 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7264 else if(dialogRes == cancel)
7270 for(slave = slaves.first; slave; slave = slave.next)
7272 Window w = slave.data;
7273 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7281 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7284 for(child = children.first; child; child = child.next)
7285 if(child.isActiveClient && !child.CloseConfirmation(true))
7293 for(child = children.first; child; child = child.next)
7294 if(!child.isActiveClient && !child.CloseConfirmation(true))
7304 // Static methods... move them somewhere else?
7305 void ::RestoreCaret()
7307 if(guiApp.caretOwner)
7308 guiApp.caretOwner.UpdateCaret(false, false);
7311 void ::FreeMouseRange()
7313 guiApp.interfaceDriver.SetMouseRange(null, null);
7317 bool MenuFileClose(MenuItem selection, Modifiers mods)
7319 Window document = activeChild;
7321 document.Destroy(0);
7325 bool MenuFileExit(MenuItem selection, Modifiers mods)
7331 bool MenuFileSave(MenuItem selection, Modifiers mods)
7335 fileMonitor.fileName = null;
7338 if(OnSaveFile(fileName))
7340 //if(OnFileModified != Window::OnFileModified)
7343 fileMonitor.fileName = fileName;
7349 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7350 DialogResult answer = dialog.Modal();
7352 if(answer != yes) return (bool)answer;
7355 return MenuFileSaveAs(selection, mods);
7358 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7360 DialogResult result = (DialogResult)bool::true;
7361 FileDialog fileDialog = saveDialog;
7364 fileDialog = FileDialog {};
7369 fileDialog.filePath = fileName;
7372 char filePath[MAX_FILENAME];
7373 sprintf(filePath, "Untitled %d", documentID);
7374 fileDialog.filePath = filePath;
7376 fileMonitor.fileName = null;
7378 fileDialog.type = save;
7379 fileDialog.text = $"Save As";
7383 fileDialog.master = master.parent ? master : this;
7384 if(fileDialog.Modal() == ok)
7386 char * filePath = fileDialog.filePath;
7388 if(OnSaveFile(filePath))
7391 property::fileName = filePath;
7392 NotifySaved(master, this, filePath);
7397 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7398 DialogResult answer = dialog.Modal();
7413 //if(OnFileModified != Window::OnFileModified && fileName)
7416 fileMonitor.fileName = fileName;
7420 return (bool)result; // Actually returning result from Yes/NoCancel message box
7423 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7425 Window document = activeChild;
7427 for(document = children.first; document; document = next)
7429 next = document.next;
7430 if(document.style.isDocument || document.fileName)
7431 document.MenuFileSave(selection, mods);
7436 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7440 for(document = children.first; document; document = document.next)
7441 //if(document.style.isDocument && document.state == minimized)
7442 if(document.style.isActiveClient && document.state == minimized)
7443 document.SetState(minimized, false, mods);
7447 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7449 Window document = activeChild;
7452 Window firstDocument = null;
7454 OldLink cycle = document.cycle.prev;
7459 if(child.style.isActiveClient && !child.style.hidden)
7463 firstDocument = child;
7464 if(child.state == minimized)
7465 child.SetState(minimized, false, mods);
7468 child.positionID = id++;
7469 child.SetState(normal, false, mods);
7470 child.anchor.left.type = cascade;
7473 child.normalSizeAnchor = *&child.sizeAnchor;
7474 child.normalAnchor = child.anchor;
7476 // Break the anchors for moveable/resizable windows
7477 if(child.style.fixed)
7479 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7481 (*&child.normalAnchor).left = x;
7482 (*&child.normalAnchor).top = y;
7483 (*&child.normalAnchor).right.type = none;
7484 (*&child.normalAnchor).bottom.type = none;
7486 child.normalSizeAnchor.isClientW = false;
7487 child.normalSizeAnchor.isClientH = false;
7488 child.normalSizeAnchor.size.w = w;
7489 child.normalSizeAnchor.size.h = h;
7490 child.anchored = false;
7493 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7495 child.stateAnchor = child.normalAnchor;
7496 child.stateSizeAnchor = child.normalSizeAnchor;
7498 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7499 child.Position(x, y, w, h, true, true, true, true, false, false);
7504 last = children.last;
7505 if(!child.style.stayOnTop)
7506 for(; last && last.style.stayOnTop; last = last.prev);
7507 children.Move(child, last);
7508 childrenOrder.Move(child.order, childrenOrder.last);
7510 if(cycle == document.cycle) break;
7514 firstDocument.Activate();
7519 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7526 // Close all closes all active clients, not all documents
7527 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7529 Window next, document;
7531 for(document = children.first; document; document = next)
7533 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7534 if(document.style.isActiveClient)
7535 if(!document.Destroy(0) && !document.style.hidden)
7541 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7543 if(style.hasMaximize && state != maximized)
7544 SetState(maximized, 0, 0);
7548 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7550 if(style.hasMinimize && state != minimized)
7552 SetState(minimized, 0, 0);
7553 parent.CycleChildren(false, true, false, true);
7558 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7560 MenuMoveOrSize(false, selection ? true : false);
7564 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7566 CycleChildren(false, true, false, true);
7570 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7572 CycleChildren(true, true, false, true);
7576 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7578 MenuMoveOrSize(true, true);
7582 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7585 SetState(normal, 0, 0);
7589 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7592 int64 id = selection.id;
7593 OldLink cycle = activeClient.cycle;
7595 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7598 Window sibling = cycle.data;
7599 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7607 document = cycle.data;
7608 document.Activate();
7610 //if(activeChild.state == maximized)
7611 // document.SetState(maximized, false, mods);
7612 //else if(document.state == minimized)
7613 // document.SetState(normal, false, mods);
7617 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7619 stayOnTop = !style.stayOnTop;
7623 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7625 Window document = activeChild;
7628 Window firstDocument = null;
7629 OldLink cycle = document.cycle;
7633 Window child = cycle.data;
7634 if(child.style.isActiveClient && !child.style.hidden)
7636 if(!firstDocument) firstDocument = child;
7637 if(child.state == minimized)
7638 child.SetState(minimized, false, mods);
7641 child.positionID = id++;
7642 child.SetState(normal, false, mods);
7643 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7645 child.anchor.left.type = hTiled;
7648 child.normalSizeAnchor = *&child.sizeAnchor;
7649 child.normalAnchor = child.anchor;
7651 // Break the anchors for moveable/resizable windows
7652 if(child.style.fixed)
7654 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7656 (*&child.normalAnchor).left = x;
7657 (*&child.normalAnchor).top = y;
7658 (*&child.normalAnchor).right.type = none;
7659 (*&child.normalAnchor).bottom.type = none;
7660 child.normalSizeAnchor.isClientW = false;
7661 child.normalSizeAnchor.isClientH = false;
7662 child.normalSizeAnchor.size.w = w;
7663 child.normalSizeAnchor.size.h = h;
7664 child.anchored = false;
7667 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7669 child.stateAnchor = child.normalAnchor;
7670 child.stateSizeAnchor = child.normalSizeAnchor;
7672 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7673 child.Position(x,y, w, h, true, true, true, true, false, true);
7678 if((cycle = cycle.next) == document.cycle) break;
7681 firstDocument.Activate();
7686 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7688 Window document = activeChild;
7691 Window firstDocument = null;
7693 OldLink cycle = document.cycle;
7698 //if(child.style.isDocument)
7699 if(child.style.isActiveClient && !child.style.hidden)
7701 if(!firstDocument) firstDocument = child;
7702 if(child.state == minimized)
7703 child.SetState(minimized, false, mods);
7706 child.positionID = id++;
7707 child.SetState(normal, false, mods);
7708 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7710 child.anchor.left.type = vTiled;
7713 child.normalSizeAnchor = *&child.sizeAnchor;
7714 child.normalAnchor = child.anchor;
7716 // Break the anchors for moveable/resizable windows
7717 if(child.style.fixed)
7719 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7721 (*&child.normalAnchor).left = x;
7722 (*&child.normalAnchor).top = y;
7723 (*&child.normalAnchor).right.type = none;
7724 (*&child.normalAnchor).bottom.type = none;
7725 child.normalSizeAnchor.isClientW = false;
7726 child.normalSizeAnchor.isClientH = false;
7727 child.normalSizeAnchor.size.w = w;
7728 child.normalSizeAnchor.size.h = h;
7729 child.anchored = false;
7732 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7734 child.stateAnchor = child.normalAnchor;
7735 child.stateSizeAnchor = child.normalSizeAnchor;
7737 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7738 child.Position(x,y, w, h, true, true, true, true, false, true);
7743 if((cycle = cycle.next) == document.cycle) break;
7746 firstDocument.Activate();
7751 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7753 WindowList dialog { master = this };
7754 Window document = (Window)dialog.Modal();
7757 if(activeChild.state == maximized)
7758 document.SetState(maximized, false, mods);
7759 else if(document.state == minimized)
7760 document.SetState(normal, false, mods);
7761 document.Activate();
7767 virtual bool OnCreate(void);
7768 virtual void OnDestroy(void);
7769 virtual void OnDestroyed(void);
7770 virtual bool OnClose(bool parentClosing);
7771 virtual bool OnStateChange(WindowState state, Modifiers mods);
7772 virtual bool OnPostCreate(void);
7773 virtual bool OnMoving(int *x, int *y, int w, int h);
7774 virtual bool OnResizing(int *width, int *height);
7775 virtual void OnResize(int width, int height);
7776 virtual void OnPosition(int x, int y, int width, int height);
7777 virtual bool OnLoadGraphics(void);
7778 virtual void OnApplyGraphics(void);
7779 virtual void OnUnloadGraphics(void);
7780 virtual void OnRedraw(Surface surface);
7781 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7782 virtual void OnActivateClient(Window client, Window previous);
7783 virtual bool OnKeyDown(Key key, unichar ch);
7784 virtual bool OnKeyUp(Key key, unichar ch);
7785 virtual bool OnKeyHit(Key key, unichar ch);
7786 virtual bool OnSysKeyDown(Key key, unichar ch);
7787 virtual bool OnSysKeyUp(Key key, unichar ch);
7788 virtual bool OnSysKeyHit(Key key, unichar ch);
7789 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7790 virtual bool OnMouseLeave(Modifiers mods);
7791 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7792 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7793 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7794 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7795 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7796 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7797 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7798 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7799 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7800 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7801 virtual void OnMouseCaptureLost(void);
7802 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7803 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7804 virtual void OnDrawOverChildren(Surface surface);
7805 virtual bool OnFileModified(FileChange fileChange, char * param);
7806 virtual bool OnSaveFile(char * fileName);
7808 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7809 // Note: A 'client' would refer to isActiveClient, rather than
7810 // being confined to the 'client area' (nonClient == false)
7811 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7812 virtual void OnChildVisibilityToggled(Window child, bool visible);
7813 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7815 // Skins Virtual Functions
7816 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7817 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7818 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7823 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7824 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7825 virtual bool IsMouseMoving(int x, int y, int w, int h)
7829 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7833 virtual void UpdateNonClient();
7834 virtual void SetBox(Box box); // This is used in the MySkin skin
7835 virtual bool IsInside(int x, int y)
7837 return box.IsPointInside({x, y});
7839 virtual bool IsOpaque()
7841 return (!style.drawBehind || background.a == 255);
7845 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7846 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7847 virtual void Window::NotifySaved(Window window, char * filePath);
7852 property Window parent
7854 property_category $"Layout"
7857 if(value || guiApp.desktop)
7860 Window oldParent = parent;
7861 Anchor anchor = this.anchor;
7863 if(value && value.IsDescendantOf(this)) return;
7864 if(value && value == this)
7866 if(!value) value = guiApp.desktop;
7868 if(value == oldParent) return;
7870 if(!master || (master == this.parent && master == guiApp.desktop))
7871 property::master = value;
7875 parent.children.Remove(this);
7879 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7880 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7881 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7882 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7886 last = value.children.last;
7888 if(style.isDocument)
7891 parent.numDocuments--;
7892 documentID = value.GetDocumentID();
7895 if(style.isActiveClient && !style.hidden)
7897 if(parent && parent != guiApp.desktop && !(style.hidden))
7899 if(state == minimized) parent.numIcons--;
7900 parent.numPositions--;
7904 if(!style.stayOnTop)
7905 for(; last && last.style.stayOnTop; last = last.prev);
7907 value.children.Insert(last, this);
7909 // *** NEW HERE: ***
7911 parent.childrenCycle.Delete(cycle);
7913 parent.childrenOrder.Delete(order);
7916 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7917 // Should something else be done?
7918 if(parent && parent.activeChild == this)
7919 parent.activeChild = null;
7920 if(parent && parent.activeClient == this)
7921 parent.activeClient = null;
7927 int x = position.x, y = position.y, w = size.w, h = size.h;
7931 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7932 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7934 vpw = value.clientSize.w;
7935 vph = value.clientSize.h;
7941 else if(style.fixed)
7943 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7944 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7947 anchor = this.anchor;
7949 if(anchor.left.type == offset) anchor.left.distance = x;
7950 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7951 if(anchor.top.type == offset) anchor.top.distance = y;
7952 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7953 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7954 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7955 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7956 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7957 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7958 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7960 if(!anchor.left.type && !anchor.right.type)
7962 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7963 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7965 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7966 if(!anchor.top.type && !anchor.bottom.type)
7968 anchor.vert.distance = (y + h / 2) - (vph / 2);
7969 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7971 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7974 parent.OnChildAddedOrRemoved(this, false);
7980 parent.childrenCycle.Insert(
7981 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7982 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7984 cycle = OldLink { data = this });
7985 parent.childrenOrder.Insert(
7986 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7987 order = OldLink { data = this });
7990 if(!style.hidden && style.isActiveClient)
7992 positionID = parent.GetPositionID(this);
7993 parent.numPositions++;
7994 if(state == minimized) parent.numIcons--;
7997 // *** FONT INHERITANCE ***
7998 if(!setFont && oldParent)
7999 stopwatching(oldParent, font);
8003 RemoveResource(systemFont);
8006 // TESTING WITH WATCHERS:
8007 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8008 // usedFont = setFont ? setFont : (systemFont);
8012 if(guiApp.currentSkin)
8014 systemFont = guiApp.currentSkin.SystemFont();
8017 usedFont = systemFont;
8018 AddResource(systemFont);
8026 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8035 if(value.rootWindow && value.rootWindow.display && rootWindow)
8037 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8038 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8041 UnloadGraphics(false);
8045 LoadGraphics(false, false);
8048 if(value.rootWindow != rootWindow)
8049 DisplayModeChanged();
8053 scrolledPos.x = MININT; // Prevent parent update
8055 bool anchored = this.anchored;
8056 property::anchor = anchor;
8057 this.anchored = anchored;
8062 if(guiApp.currentSkin)
8063 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8065 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8066 Position(x, y, w, h, true, true, true, true, false, true);
8071 // else parent = value;
8073 oldParent.OnChildAddedOrRemoved(this, true);
8076 get { return parent; }
8079 property Window master
8081 property_category $"Behavior"
8084 //if(this == value) return;
8085 if(value && value.IsSlaveOf(this)) return;
8091 OldLink slaveHolder;
8092 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8093 if(slaveHolder.data == this)
8095 master.slaves.Delete(slaveHolder);
8102 value.slaves.Add(OldLink { data = this });
8107 master.hotKeys.Remove(hotKey);
8108 value.hotKeys.Add(hotKey);
8111 if(master && master.defaultControl == this)
8112 master.defaultControl = null;
8114 if(style.isDefault && !value.defaultControl)
8115 value.defaultControl = this;
8120 get { return master ? master : parent; }
8123 property char * caption
8125 property_category $"Appearance"
8132 caption = new char[strlen(value)+1];
8134 strcpy(caption, value);
8139 get { return caption; }
8144 property_category $"Behavior"
8153 master.hotKeys.Add(hotKey = HotKeySlot { });
8157 hotKey.window = this;
8162 master.hotKeys.Delete(hotKey);
8167 get { return hotKey ? hotKey.key : 0; }
8170 property Color background
8172 property_category $"Appearance"
8175 background.color = value;
8180 if(this == rootWindow)
8181 guiApp.interfaceDriver.SetRootWindowColor(this);
8184 get { return background.color; }
8187 property Percentage opacity
8189 property_category $"Appearance"
8192 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8193 drawBehind = (background.a == 255) ? false : true;
8195 get { return background.a / 255.0f; }
8198 property Color foreground
8200 property_category $"Appearance"
8208 get { return foreground; }
8211 property BorderStyle borderStyle
8213 property_category $"Appearance"
8216 if(!((BorderBits)value).fixed)
8218 style.hasClose = false;
8219 style.hasMaximize = false;
8220 style.hasMinimize = false;
8221 nativeDecorations = false;
8223 style.borderBits = value;
8227 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8229 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8230 Position(x, y, w, h, true, true, true, true, false, true);
8231 CreateSystemChildren();
8234 get { return (BorderStyle)style.borderBits; }
8237 property Size minClientSize
8239 property_category $"Layout"
8240 set { minSize = value; }
8241 get { value = minSize; }
8244 property Size maxClientSize
8246 property_category $"Layout"
8247 set { maxSize = value; }
8248 get { value = maxSize; }
8251 property bool hasMaximize
8253 property_category $"Window Style"
8256 style.hasMaximize = value;
8257 if(value) { style.fixed = true; style.contour = true; }
8261 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8263 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8264 Position(x, y, w, h, true, true, true, true, false, true);
8266 CreateSystemChildren();
8269 get { return style.hasMaximize; }
8272 property bool hasMinimize
8274 property_category $"Window Style"
8277 style.hasMinimize = value;
8278 if(value) { style.fixed = true; style.contour = true; }
8282 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);
8287 CreateSystemChildren();
8290 get { return style.hasMinimize; }
8293 property bool hasClose
8295 property_category $"Window Style"
8298 style.hasClose = value;
8299 if(value) { style.fixed = true; style.contour = true; }
8303 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8304 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8305 Position(x, y, w, h, true, true, true, true, false, true);
8306 CreateSystemChildren();
8309 get { return style.hasClose; }
8312 property bool nonClient
8314 property_category $"Layout"
8317 style.nonClient = value;
8319 style.stayOnTop = true;
8321 get { return style.nonClient; }
8324 property bool inactive
8326 property_category $"Behavior"
8331 // *** NEW HERE: ***
8335 parent.childrenCycle.Delete(cycle);
8337 parent.childrenOrder.Delete(order);
8344 active = false; // true;
8345 if(parent.activeChild == this)
8346 parent.activeChild = null;
8347 if(parent.activeClient == this)
8348 parent.activeClient = null;
8357 parent.childrenCycle.Insert(
8358 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8359 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8361 cycle = OldLink { data = this });
8363 parent.childrenOrder.Insert(
8364 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8365 order = OldLink { data = this });
8368 style.inactive = value;
8370 get { return style.inactive; }
8373 property bool clickThrough
8375 property_category $"Behavior"
8376 set { style.clickThrough = value; }
8377 get { return style.clickThrough; }
8380 property bool isRemote
8382 property_category $"Behavior"
8383 set { style.isRemote = value; }
8384 get { return style.isRemote; }
8387 property bool noCycle
8389 property_category $"Behavior"
8390 set { style.noCycle = value; }
8391 get { return style.noCycle; }
8394 property bool isModal
8396 property_category $"Behavior"
8397 set { style.modal = value; }
8398 get { return style.modal; }
8401 property bool interim
8403 property_category $"Behavior"
8404 set { style.interim = value; }
8405 get { return style.interim; }
8408 property bool tabCycle
8410 property_category $"Behavior"
8411 set { style.tabCycle = value; }
8412 get { return style.tabCycle; }
8415 property bool isDefault
8417 property_category $"Behavior"
8425 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8426 if(sibling != this && sibling.style.isDefault)
8427 sibling.style.isDefault = false;*/
8428 if(master.defaultControl)
8429 master.defaultControl.style.isDefault = false;
8430 master.defaultControl = this;
8432 else if(master.defaultControl == this)
8433 master.defaultControl = null;
8437 style.isDefault = value;
8439 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8441 get { return style.isDefault; }
8444 property bool drawBehind
8446 property_category $"Window Style"
8447 set { style.drawBehind = value; }
8448 get { return style.drawBehind; }
8451 property bool hasMenuBar
8453 property_category $"Window Style"
8463 if(created && !menuBar)
8470 anchor = Anchor { top = 23, left = 1, right = 1 },
8472 inactive = true, nonClient = true
8477 else if(created && menuBar)
8482 style.hasMenuBar = value;
8484 get { return style.hasMenuBar; }
8487 property bool hasStatusBar
8489 property_category $"Window Style"
8496 statusBar = StatusBar { this };
8504 style.hasStatusBar = value;
8506 get { return style.hasStatusBar; }
8508 property bool stayOnTop
8510 property_category $"Window Style"
8515 if(created && !style.stayOnTop)
8517 if(rootWindow == this)
8518 guiApp.interfaceDriver.OrderRootWindow(this, true);
8519 else if(parent.children.last != this)
8521 parent.children.Move(this, parent.children.last);
8525 style.stayOnTop = true;
8529 if(created && style.stayOnTop)
8531 if(rootWindow == this)
8532 guiApp.interfaceDriver.OrderRootWindow(this, false);
8539 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8540 order && ((Window)order.data).style.stayOnTop;
8541 order = (order == parent.childrenOrder.first) ? null : order.prev);
8542 last = order ? order.data : null;
8546 for(last = parent.children.last;
8547 last && last.style.stayOnTop;
8551 parent.children.Move(this, last);
8555 style.stayOnTop = false;
8558 get { return style.stayOnTop; }
8563 property_category $"Window Style"
8573 if(menuBar && !value)
8580 if(!menuBar && style.hasMenuBar && value)
8584 this, menu = value, isMenuBar = true,
8585 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8586 inactive = true, nonClient = true
8590 UpdateActiveDocument(null);
8593 get { return menu; }
8596 property FontResource font
8598 property_category $"Appearance"
8600 isset { return setFont ? true : false; }
8605 if(value && !setFont) { stopwatching(parent, font); }
8606 else if(!value && setFont)
8612 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8621 RemoveResource(setFont);
8626 RemoveResource(systemFont);
8633 AddResource(setFont);
8636 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8639 systemFont = guiApp.currentSkin.SystemFont();
8641 usedFont = systemFont;
8642 AddResource(systemFont);
8650 get { return usedFont; }
8653 property SizeAnchor sizeAnchor
8655 property_category $"Layout"
8658 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8659 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8660 sizeAnchor.isClientW != sizeAnchor.isClientH;
8667 normalSizeAnchor = sizeAnchor;
8669 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8671 stateAnchor = normalAnchor;
8672 stateSizeAnchor = normalSizeAnchor;
8674 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8675 Position(x,y, w, h, true, true, true, true, false, true);
8682 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8683 sizeAnchor.isClientW,
8684 sizeAnchor.isClientH
8691 property_category $"Layout"
8694 Anchor thisAnchor = anchor;
8695 SizeAnchor thisSizeAnchor = sizeAnchor;
8696 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8697 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8698 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8699 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8700 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8701 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8707 sizeAnchor.isClientW = false;
8708 sizeAnchor.isClientH = false;
8709 sizeAnchor.size = value;
8711 normalSizeAnchor = sizeAnchor;
8713 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8715 stateAnchor = normalAnchor;
8716 stateSizeAnchor = normalSizeAnchor;
8718 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8719 Position(x, y, w, h, true, true, true, true, false, true);
8720 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8723 get { value = size; }
8726 property Size clientSize
8728 property_category $"Layout"
8731 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8732 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8733 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8738 sizeAnchor.isClientW = true;
8739 sizeAnchor.isClientH = true;
8740 sizeAnchor.size = value;
8742 normalSizeAnchor = sizeAnchor;
8744 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8746 stateAnchor = normalAnchor;
8747 stateSizeAnchor = normalSizeAnchor;
8749 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8750 Position(x,y, w, h, true, true, true, true, false, true);
8751 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8754 get { value = this ? clientSize : { 0, 0 }; }
8757 property Size initSize { get { value = sizeAnchor.size; } };
8759 property Anchor anchor
8761 property_category $"Layout"
8762 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8768 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8770 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8771 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8773 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8775 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8776 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8780 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8782 anchor.left.distance = 0;
8783 anchor.horz.type = 0;
8785 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8787 anchor.top.distance = 0;
8788 anchor.vert.type = 0;
8797 normalAnchor = anchor;
8799 // Break the anchors for moveable/resizable windows
8800 /*if(style.fixed ) //&& value.left.type == cascade)
8802 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8804 this.anchor = normalAnchor = Anchor { left = x, top = y };
8805 normalSizeAnchor = SizeAnchor { { w, h } };
8808 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8810 stateAnchor = normalAnchor;
8811 stateSizeAnchor = normalSizeAnchor;
8813 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8814 Position(x, y, w, h, true, true, true, true, false, true);
8823 get { value = this ? anchor : Anchor { }; }
8826 property Point position
8828 property_category $"Layout"
8831 if(value == null) return;
8833 anchor.left = value.x;
8834 anchor.top = value.y;
8835 anchor.right.type = none;
8836 anchor.bottom.type = none;
8841 normalAnchor = anchor;
8843 // Break the anchors for moveable/resizable windows
8847 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8849 normalAnchor.left = x;
8850 normalAnchor.top = y;
8851 normalAnchor.right.type = none;
8852 normalAnchor.bottom.type = none;
8853 normalSizeAnchor.size.width = w;
8854 normalSizeAnchor.size.height = h;
8858 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8860 stateAnchor = normalAnchor;
8861 stateSizeAnchor = normalSizeAnchor;
8863 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8864 Position(x,y, w, h, true, true, true, true, false, true);
8868 get { value = position; }
8871 property bool disabled
8873 property_category $"Behavior"
8876 if(this && disabled != value)
8883 get { return (bool)disabled; }
8886 property bool isEnabled
8891 for(parent = this; parent; parent = parent.parent)
8898 property WindowState state
8900 property_category $"Behavior"
8901 set { SetState(value, false, 0); }
8902 get { return this ? state : 0; }
8905 property bool visible
8907 property_category $"Behavior"
8910 if(this && !value && !style.hidden && parent)
8912 bool wasActiveChild = parent.activeChild == this;
8913 Window client = null;
8915 style.hidden = true;
8916 if(style.isActiveClient)
8918 parent.numPositions--;
8919 if(state == minimized) parent.numIcons--;
8924 OldLink prevOrder = null;
8926 if(rootWindow == this)
8927 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8930 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8933 box.left -= parent.clientStart.x;
8934 box.top -= parent.clientStart.y;
8935 box.right -= parent.clientStart.x;
8936 box.bottom -= parent.clientStart.y;
8940 if(_isModal && master && master.modalSlave == this)
8941 master.modalSlave = null;
8945 OldLink tmpPrev = order.prev;
8946 client = tmpPrev ? tmpPrev.data : null;
8947 if(client && !client.style.hidden && !client.destroyed && client.created)
8948 prevOrder = tmpPrev;
8951 client = tmpPrev ? tmpPrev.data : null;
8952 if(client == this) { client = null; break; }
8953 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8955 tmpPrev = client.order.prev;
8960 prevOrder = tmpPrev;
8965 // If this window can be an active client, make sure the next window we activate can also be one
8966 if(!style.nonClient && style.isActiveClient)
8968 tmpPrev = prevOrder;
8971 client = tmpPrev ? tmpPrev.data : null;
8972 if(client == this) { client = null; break; }
8973 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8975 tmpPrev = client.order.prev;
8980 prevOrder = tmpPrev;
8984 if(client && client.style.hidden) client = null;
8988 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8990 if(order && prevOrder && prevOrder.data != this)
8991 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8993 ActivateEx(false, false, false, true, null, null);
8995 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8996 if(parent.activeClient == this)
8998 parent.activeClient = null;
8999 parent.UpdateActiveDocument(null);
9002 else if(parent.activeClient == this)
9004 parent.activeClient = client;
9005 parent.UpdateActiveDocument(this);
9008 // *** Not doing this anymore ***
9011 parent.childrenCycle.Delete(cycle);
9013 parent.childrenOrder.Delete(order);
9018 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9023 else if(this && value && style.hidden)
9025 style.hidden = false;
9028 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9029 if(rootWindow == this)
9030 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9032 if(_isModal && master)
9033 master.modalSlave = this;
9035 if(style.isActiveClient)
9037 positionID = parent.GetPositionID(this);
9038 parent.numPositions++;
9039 if(state == minimized) parent.numIcons++;
9042 // *** NOT DOING THIS ANYMORE ***
9044 if(!(style.inactive))
9046 if(!(style.noCycle))
9048 cycle = parent.childrenCycle.AddAfter(
9049 (parent.activeChild && parent.activeChild.cycle) ?
9050 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9053 order = parent.childrenOrder.AddAfter(
9054 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9061 if(true || !parent.activeChild)
9062 ActivateEx(true, false, true, true, null, null);
9064 if(creationActivation == activate)
9065 ActivateEx(true, false, true, true, null, null);
9066 else if(creationActivation == flash && !object)
9069 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9073 ConsequentialMouseMove(false);
9079 style.hidden = !value;
9082 get { return (style.hidden || !setVisible) ? false : true; }
9085 property bool isDocument
9087 property_category $"Document"
9088 set { style.isDocument = value; }
9089 get { return style.isDocument; }
9092 property bool mergeMenus
9094 property_category $"Window Style"
9095 set { mergeMenus = value; }
9096 get { return (bool)mergeMenus; }
9099 property bool hasHorzScroll
9101 property_category $"Window Style"
9106 if(!style.hasHorzScroll && created)
9108 CreateSystemChildren();
9109 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9112 else if(style.hasHorzScroll)
9116 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9118 style.hasHorzScroll = value;
9121 get { return style.hasHorzScroll; }
9124 property bool hasVertScroll
9126 property_category $"Window Style"
9131 if(!style.hasVertScroll && created)
9133 style.hasVertScroll = true;
9134 CreateSystemChildren();
9135 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9138 else if(style.hasVertScroll)
9142 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9144 style.hasVertScroll = value;
9146 get { return style.hasVertScroll; }
9149 property bool dontHideScroll
9151 property_category $"Behavior"
9154 scrollFlags.dontHide = value;
9157 //UpdateScrollBars(true, true);
9158 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9162 // UpdateScrollBars(true, true);
9163 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9166 get { return scrollFlags.dontHide; }
9169 property bool dontScrollVert
9171 property_category $"Behavior"
9172 set { style.dontScrollVert = value; }
9173 get { return style.dontScrollVert; }
9175 property bool dontScrollHorz
9177 property_category $"Behavior"
9178 set { style.dontScrollHorz = value; }
9179 get { return style.dontScrollHorz; }
9182 property bool snapVertScroll
9184 property_category $"Behavior"
9187 scrollFlags.snapY = value;
9188 if(sbv) sbv.snap = value;
9190 get { return scrollFlags.snapY; }
9192 property bool snapHorzScroll
9194 property_category $"Behavior"
9197 scrollFlags.snapX = value;
9198 if(sbh) sbh.snap = value;
9200 get { return scrollFlags.snapX; }
9203 property Point scroll
9205 property_category $"Behavior"
9206 set { if(this) SetScrollPosition(value.x, value.y); }
9207 get { value = scroll; }
9210 property bool modifyVirtualArea
9212 property_category $"Behavior"
9213 set { modifyVirtArea = value; }
9214 get { return (bool)modifyVirtArea; }
9217 property bool dontAutoScrollArea
9219 property_category $"Behavior"
9220 // Activating a child control out of view will automatically scroll to make it in view
9221 set { noAutoScrollArea = value; }
9222 get { return (bool)noAutoScrollArea; }
9225 property char * fileName
9227 property_category $"Document"
9230 if(menu && ((!fileName && value) || (fileName && !value)))
9232 MenuItem item = menu.FindItem(MenuFileSave, 0);
9233 if(item) item.disabled = !modifiedDocument && value;
9238 if(value && value[0])
9239 fileName = CopyString(value);
9241 if(parent && this == parent.activeClient)
9242 parent.UpdateActiveDocument(null);
9246 // if(style.isDocument)
9248 fileMonitor.fileName = value;
9250 get { return fileName; }
9255 property_category $"Data"
9260 property bool modifiedDocument
9262 property_category $"Document"
9265 if(style.isDocument || fileName)
9269 MenuItem item = menu.FindItem(MenuFileSave, 0);
9270 if(item) item.disabled = !value && fileName;
9274 if(modifiedDocument != value)
9276 modifiedDocument = value;
9277 if(style.isDocument || fileName)
9281 get { return (bool)modifiedDocument; }
9284 property bool showInTaskBar
9286 property_category $"Window Style"
9287 set { style.showInTaskBar = value; }
9288 get { return style.showInTaskBar; }
9290 property FileDialog saveDialog { set { saveDialog = value; } };
9291 property bool isActiveClient
9293 property_category $"Behavior"
9294 set { style.isActiveClient = value; }
9295 get { return style.isActiveClient; }
9298 property Cursor cursor
9300 property_category $"Appearance"
9304 SelectMouseCursor();
9306 get { return cursor; }
9309 //#if !defined(ECERE_VANILLA)
9310 property char * name
9312 property_category $"Design"
9315 return (this && object) ? object.name : null;
9320 activeDesigner.RenameObject(object, value);
9324 property char * displayDriver
9326 property_category $"Behavior"
9329 dispDriver = GetDisplayDriver(value);
9330 //DisplayModeChanged();
9334 return dispDriver ? dispDriver.name : null;
9338 // RUNTIME PROPERTIES
9339 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9340 property Size scrollArea
9342 property_category $"Behavior"
9346 SetScrollArea(value.w, value.h, false);
9348 SetScrollArea(0,0, true);
9350 get { value = scrollArea; }
9353 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9358 property_category $"Layout"
9359 set { if(this) is3D = value; }
9360 get { return (bool)is3D; }
9363 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9365 // Will be merged with font later
9366 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9367 property Point clientStart { get { value = clientStart; } };
9368 property Point absPosition { get { value = absPosition; } };
9369 property Anchor normalAnchor { get { value = normalAnchor; } };
9370 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9371 property bool active { get { return (bool)active; } };
9372 property bool created { get { return (bool)created; } };
9373 property bool destroyed { get { return (bool)destroyed; } };
9374 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9375 property Window firstChild { get { return children.first; } };
9376 property Window lastChild { get { return children.last; } };
9377 property Window activeClient { get { return activeClient; } };
9378 property Window activeChild { get { return activeChild; } };
9379 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9380 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9381 property ScrollBar horzScroll { get { return sbh; } };
9382 property ScrollBar vertScroll { get { return sbv; } };
9383 property StatusBar statusBar { get { return statusBar; } };
9384 property Window rootWindow { get { return rootWindow; } };
9385 property bool closing { get { return (bool)closing; } set { closing = value; } };
9386 property int documentID { get { return documentID; } };
9387 property Window previous { get { return prev; } }
9388 property Window next { get { return next; } }
9389 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9390 property PopupMenu menuBar { get { return menuBar; } }
9391 property ScrollBar sbv { get { return sbv; } }
9392 property ScrollBar sbh { get { return sbh; } }
9393 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9394 property void * systemHandle { get { return windowHandle; } }
9395 property Button minimizeButton { get { return sysButtons[0]; } };
9396 property Button maximizeButton { get { return sysButtons[1]; } };
9397 property Button closeButton { get { return sysButtons[2]; } };
9398 property BitmapResource icon
9400 get { return icon; }
9404 if(icon) incref icon;
9406 guiApp.interfaceDriver.SetIcon(this, value);
9409 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9410 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9411 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9412 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9413 property bool nativeDecorations
9415 get { return (bool)nativeDecorations; }
9416 set { nativeDecorations = value; }
9417 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9420 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9421 bool result = false;
9422 if(nativeDecorations)
9424 if(rootWindow == this)
9428 if(formDesigner && activeDesigner)
9430 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9431 Window form = cd ? cd.form : null;
9432 if(form && parent == form.parent)
9437 return result != style.fixed;
9441 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9443 property char * text
9445 property_category $"Deprecated"
9447 set { property::caption = value; }
9448 get { return property::caption; }
9454 WindowBits style; // Window Style
9455 char * caption; // Name / Caption
9456 Window parent; // Parent window
9457 OldList children; // List of children in Z order
9458 Window activeChild; // Child window having focus
9459 Window activeClient;
9460 Window previousActive; // Child active prior to activating the default child
9461 Window master; // Window owning and receiving notifications concerning this window
9462 OldList slaves; // List of windows belonging to this window
9463 Display display; // Display this window is drawn into
9465 Point position; // Position in parent window client area
9466 Point absPosition; // Absolute position
9467 Point clientStart; // Client area position from (0,0) in this window
9469 Size clientSize; // Client area size
9470 Size scrollArea; // Virtual Scroll area size
9471 Size reqScrollArea; // Requested virtual area size
9472 Point scroll; // Virtual area scrolling position
9473 ScrollBar sbh, sbv; // Scrollbar window handles
9474 Cursor cursor; // Mouse cursor used for this window
9477 StatusBar statusBar;
9478 Button sysButtons[3];
9480 Box clientArea; // Client Area box clipped to parent
9482 HotKeySlot hotKey; // HotKey for this window
9486 ScrollFlags scrollFlags;// Window Scrollbar Flags
9487 int64 id; // Control ID
9489 ColorAlpha background; // Background color used to draw the window area
9491 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9492 OldList childrenCycle; // Cycling order
9493 OldLink cycle; // Element of parent's cycling order
9494 OldList childrenOrder; // Circular Z-Order
9495 OldLink order; // Element of parent's circular Z-Order
9496 Window modalSlave; // Slave window blocking this window's interaction
9498 Window rootWindow; // Topmost system managed window
9499 void * windowHandle; // System window handle
9501 DialogResult returnCode;// Return code for modal windows
9503 Point sbStep; // Scrollbar line scrolling steps
9506 SizeAnchor stateSizeAnchor;
9508 Anchor normalAnchor;
9509 SizeAnchor normalSizeAnchor;
9511 Size skinMinSize; // Minimal window size based on style
9512 Point scrolledPos; // Scrolled position
9513 Box box; // Window box clipped to parent
9514 Box * against; // What to clip the box to
9516 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9517 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9518 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9519 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9520 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9521 Point scrolledArea; // Distance to scroll area by
9522 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9524 OldList hotKeys; // List of the hotkeys of all children
9525 Window defaultControl; // Default child control
9529 ColorAlpha * palette; // Color palette used for this window
9531 int caretSize; // Size of caret, non zero if a caret is present
9532 Point caretPos; // Caret position
9534 void * systemParent; // Parent System Window for embedded windows
9541 WindowState lastState;
9543 FileMonitor fileMonitor
9545 this, FileChange { modified = true };
9547 bool OnFileNotify(FileChange action, char * param)
9550 fileMonitor.StopMonitoring();
9551 if(OnFileModified(action, param))
9552 fileMonitor.StartMonitoring();
9557 FontResource setFont, systemFont;
9558 FontResource usedFont;
9559 FontResource captionFont;
9561 FileDialog saveDialog;
9563 SizeAnchor sizeAnchor;
9565 // FormDesigner data
9568 Extent * tempExtents; //[4];
9569 BitmapResource icon;
9571 CreationActivationOption creationActivation;
9574 bool active:1; // true if window and ancestors are active
9575 bool acquiredInput:1; // true if the window is processing state based input
9576 bool modifiedDocument:1;
9577 bool disabled:1; // true if window cannot interact
9578 bool isForegroundWindow:1;// true while a root window is being activated
9579 bool visible:1; // Visibility flag
9580 bool destroyed:1; // true if window is being destroyed
9581 bool anchored:1; // true if this window is repositioned when the parent resizes
9582 bool dirty:1; // Flag set to true if any descendant must be redrawn
9588 bool modifyVirtArea:1;
9589 bool noAutoScrollArea:1;
9592 bool setVisible:1; // FOR FORM DESIGNER
9598 bool useSharedMemory:1;
9601 bool nativeDecorations:1;
9602 bool manageDisplay:1;
9603 bool formDesigner:1; // True if we this is running in the form editor
9604 bool requireRemaximize:1;
9607 // Checks used internally for them not to take effect in FormDesigner
9608 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9609 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9611 WindowController controller;
9612 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9615 public class CommonControl : Window
9617 // creationActivation = doNothing;
9620 public property String toolTip
9622 property_category $"Appearance"
9625 if(created) CommonControl::OnDestroy();
9627 toolTip = value ? ToolTip { tip = value; } : null;
9629 if(created) CommonControl::OnCreate();
9631 get { return toolTip ? toolTip.tip : null; }
9637 // (Very) Ugly work around for the fact that the parent watcher
9638 // won't fire when it's already been disconnected...
9639 eInstance_FireSelfWatchers(toolTip,
9640 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9646 toolTip.parent = this;
9655 public class Percentage : float
9657 char * OnGetString(char * string, float * fieldData, bool * needClass)
9661 sprintf(string, "%.2f", this);
9662 c = strlen(string)-1;
9665 if(string[c] != '0')
9666 last = Max(last, c);
9667 if(string[c] == '.')
9680 public void ApplySkin(Class c, char * name, void ** vTbl)
9682 char className[1024];
9687 subclass(Window) wc = (subclass(Window))c;
9688 subclass(Window) base = (subclass(Window))c.base;
9690 sprintf(className, "%sSkin_%s", name, c.name);
9691 wc.pureVTbl = c._vTbl;
9692 c._vTbl = new void *[c.vTblSize];
9693 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9694 sc = eSystem_FindClass(c.module.application, className);
9698 for(m = 0; m < c.base.vTblSize; m++)
9700 if(c._vTbl[m] == base.pureVTbl[m])
9701 c._vTbl[m] = vTbl[m];
9706 for(m = 0; m < c.vTblSize; m++)
9708 if(sc._vTbl[m] != wc.pureVTbl[m])
9709 c._vTbl[m] = sc._vTbl[m];
9713 for(d = c.derivatives.first; d; d = d.next)
9715 ApplySkin(d.data, name, c._vTbl);
9719 public void UnapplySkin(Class c)
9721 char className[1024];
9723 subclass(Window) wc = (subclass(Window))c;
9724 subclass(Window) base = (subclass(Window))c.base;
9727 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9730 c._vTbl = wc.pureVTbl;
9734 for(d = c.derivatives.first; d; d = d.next)
9736 UnapplySkin(d.data);
9740 void CheckFontIntegrity(Window window)
9745 if(window.usedFont && window.usedFont.font == 0xecececec)
9747 FontResource uf = window.usedFont;
9748 char * className = window._class.name;
9749 char * text = window.text;
9752 for(c = window.firstChild; c; c = c.next)
9753 CheckFontIntegrity(c);
9757 public class ControllableWindow : Window
9759 /*WindowController controller;
9760 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9761 ~ControllableWindow() { delete controller; }*/
9764 class WindowControllerInterface : ControllableWindow
9766 bool OnKeyDown(Key key, unichar ch)
9768 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9770 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9774 bool OnKeyUp(Key key, unichar ch)
9776 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9778 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9782 bool OnKeyHit(Key key, unichar ch)
9784 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9786 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9790 bool OnMouseMove(int x, int y, Modifiers mods)
9792 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9794 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9798 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9800 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9802 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9806 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9808 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9810 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9814 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9816 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9818 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9822 bool OnRightButtonDown(int x, int y, Modifiers mods)
9824 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9826 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9830 bool OnRightButtonUp(int x, int y, Modifiers mods)
9832 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9834 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9838 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9840 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9842 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9846 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9848 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9850 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9854 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9856 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9858 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9862 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9864 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9866 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9870 void OnResize(int width, int height)
9872 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9873 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9876 void OnRedraw(Surface surface)
9878 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9879 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9884 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9886 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9890 bool OnLoadGraphics()
9892 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9894 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9898 void OnUnloadGraphics()
9900 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9901 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9905 public class WindowController<class V>
9908 property Window window
9912 uint size = class(Window).vTblSize;
9915 windowVTbl = new void *[size];
9916 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9917 if(value._vTbl == value._class._vTbl)
9919 value._vTbl = new void *[value._class.vTblSize];
9920 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9924 for(c = 0; c < size; c++)
9926 void * function = class(WindowControllerInterface)._vTbl[c];
9927 if(function != DefaultFunction)
9928 value._vTbl[c] = function;
9930 value._vTbl[c] = windowVTbl[c];
9935 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9938 get { return window; }
9940 property V controlled
9942 set { controlled = value; }
9943 get { return controlled; }
9945 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9946 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9947 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9948 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9949 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9950 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9951 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9952 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9953 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9954 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9955 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9956 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9957 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9958 virtual void V::OnResize(WindowController controller, int width, int height);
9959 virtual void V::OnRedraw(WindowController controller, Surface surface);
9960 virtual bool V::OnCreate(WindowController controller);
9961 virtual bool V::OnLoadGraphics(WindowController controller);
9962 virtual void V::OnUnloadGraphics(WindowController controller);
9965 int (** windowVTbl)();