7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
573 stopwatching(parent, font);
574 if(parent.activeChild == this)
575 parent.activeChild = null;
576 if(parent.activeClient == this)
577 parent.activeClient = null;
582 // Prevent destructor from being called again...
588 /////////////////////////////////
591 OldLink slave = master.slaves.FindLink(this);
592 master.slaves.Delete(slave);
599 parent.childrenCycle.Remove(cycle);
601 parent.childrenOrder.Remove(order);
602 parent.children.Remove(this);
607 /////////////////////////////////
609 while(ptr = resources.first)
612 resources.Delete(ptr);
619 for(child = children.first; child; child = child.next)
621 // child.stopwatching(this, font);
623 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
624 // Don't want property here
625 *&child.parent = null;
628 while(slave = slaves.first)
630 // Don't want property here
631 *&((Window)slave.data).master = null;
632 slaves.Delete(slave);
635 // Because we do a decref in DestroyEx...
643 // Why was this commented?
644 //if(this != guiApp.desktop)
657 if(((subclass(Window))_class).pureVTbl)
659 if(_vTbl == _class._vTbl)
661 _vTbl = ((subclass(Window))_class).pureVTbl;
666 for(m = 0; m < _class.vTblSize; m++)
668 if(_vTbl[m] == _class._vTbl[m])
669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
673 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
676 dirtyArea.Free(null);
677 renderArea.Free(null);
678 overRenderArea.Free(null);
679 clipExtent.Free(null);
680 scrollExtent.Free(null);
681 dirtyBack.Free(null);
685 tempExtents[0].Free(null);
686 tempExtents[1].Free(null);
687 tempExtents[2].Free(null);
688 tempExtents[3].Free(null);
693 //#if !defined(ECERE_VANILLA)
694 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
696 if(this == activeDesigner)
700 char * name = property::name;
701 return name ? name : "";
706 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
707 bool OnGetDataFromString(char * string)
709 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
712 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
713 this = designer.form;
714 else if(!strcmpi(string, "(Desktop)"))
715 this = activeDesigner;
717 return activeDesigner.FindObject(&this, string);
723 // --- Window updates system ---
725 // Setup a bitmap for Redrawing on client area of Window
726 Surface Redraw(Box box)
728 Surface surface = null;
730 Box clientArea = this.clientArea;
734 mox.left -= clientStart.x;
735 mox.top -= clientStart.y;
736 mox.right -= clientStart.x;
737 mox.bottom -= clientStart.y;
739 mox.Clip(clientArea);
740 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
742 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
744 int x = absPosition.x + clientStart.x;
745 int y = absPosition.y + clientStart.y;
746 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
748 x -= rootWindow.clientStart.x;
749 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
751 if(!guiApp.fullScreenMode || is3D)
753 x -= rootWindow.absPosition.x;
754 y -= rootWindow.absPosition.y;
758 x += rootWindow.parent.clientStart.x;
759 y += rootWindow.parent.clientStart.y;
761 mox.left += rootWindow.parent.clientStart.x;
762 mox.top += rootWindow.parent.clientStart.y;
763 mox.right += rootWindow.parent.clientStart.x;
764 mox.bottom += rootWindow.parent.clientStart.y;
769 surface = display.GetSurface(x, y, mox);
772 surface.width = clientSize.w;
773 surface.height = clientSize.h;
779 // Setup a bitmap for Redrawing on full Window
780 Surface RedrawFull(Box box)
782 Surface surface = null;
790 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
792 int x = absPosition.x;
793 int y = absPosition.y;
794 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
796 x -= rootWindow.clientStart.x;
797 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
799 if(!guiApp.fullScreenMode || is3D)
801 x -= rootWindow.absPosition.x;
802 y -= rootWindow.absPosition.y;
805 x += rootWindow.parent.clientStart.x;
806 y += rootWindow.parent.clientStart.y;
808 mox.left += rootWindow.parent.clientStart.x;
809 mox.top += rootWindow.parent.clientStart.y;
810 mox.right += rootWindow.parent.clientStart.x;
811 mox.bottom += rootWindow.parent.clientStart.y;
816 surface = display.GetSurface(x, y, mox);
819 surface.width = size.w;
820 surface.height = size.h;
826 void FigureCaption(char * caption)
828 Window activeClient = null;
832 strcpy(caption, this.caption);
833 if(style.isDocument || fileName)
835 if(caption[0]) strcat(caption, " - ");
837 strcat(caption, fileName);
841 sprintf(title, "Untitled %d", documentID);
842 strcat(caption, title);
845 strcat(caption, " *");
850 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
852 if(activeClient && activeClient.state == maximized)
854 if(activeClient.caption)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, activeClient.caption);
859 if(activeClient.style.isDocument || activeClient.fileName)
861 if(caption[0]) strcat(caption, " - ");
862 strcat(caption, "[");
863 if(activeClient.fileName)
864 strcat(caption, activeClient.fileName);
868 sprintf(title, "Untitled %d", activeClient.documentID);
869 strcat(caption, title);
871 if(activeClient.modifiedDocument)
872 strcat(caption, " *");
873 strcat(caption, "]");
878 // Code for returning dirty from ScrollDisplay:
880 for(d = 0; d<scrollExtent.count; d++)
882 Box * box = &scrollExtent.boxes[d];
888 Min(box.right, box.left-scroll.x),box.bottom
890 dirtyArea.UnionBox(update);
896 Max(box.left, box.right-scroll.x), box.top,
897 box.right, box.bottom
899 dirtyArea.UnionBox(update);
907 box.right, Min(box.bottom, box.top-scroll.y),
909 dirtyArea.UnionBox(update);
915 box.left, Max(box.top, box.bottom-scroll.y),
916 box.right, box.bottom
918 dirtyArea.UnionBox(update);
923 void UpdateDecorations(void)
925 // TODO: *** TEMPORARY HACK ***
932 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
934 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
936 Update({ -clientStart.x,0, -1, clientSize.h-1 });
938 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
941 // Returns w & h for Position
942 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
944 Window parent = this.parent ? this.parent : guiApp.desktop;
945 int xOffset = 0, yOffset = 0;
946 int vpw = parent ? parent.clientSize.w : 0;
947 int vph = parent ? parent.clientSize.h : 0;
948 int pw = parent ? parent.clientSize.w : 0;
949 int ph = parent ? parent.clientSize.h : 0;
950 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
951 int x = anchor.left.distance, y = anchor.top.distance;
953 MinMaxValue ew = 0, eh = 0;
955 float cascadeW, cascadeH;
957 int tilingW, tilingH, tilingSplit, tilingLastH;
958 int addX = 0, addY = 0;
960 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
962 Window masterWindow = this;
963 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
966 if(master == guiApp.desktop)
967 masterWindow = guiApp.desktop.activeChild;
969 masterWindow = master.rootWindow;
970 if(!masterWindow) masterWindow = this;
972 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
973 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
976 pw = vpw = box.right - box.left + 1;
978 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
981 ph = vph = box.bottom - box.top + 1;
997 vpw = pw = parent.size.w;
998 vph = ph = parent.size.h;
1000 else if(!style.fixed /*|| style.isDocument*/)
1002 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1003 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1005 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1008 Desktop3D_FixSize(&pw, &ph);
1009 Desktop3D_FixSize(&vpw, &vph);
1012 if(pw < skinMinSize.w) pw = skinMinSize.w;
1013 if(ph < skinMinSize.h) ph = skinMinSize.h;
1014 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1015 if(vph < skinMinSize.h) vph = skinMinSize.h;
1017 // TODO: Must fix what we're snapping
1020 if(anchor.left.type)
1022 SNAPUP(x, textCellW);
1024 else if(anchor.right.type)
1026 SNAPDOWN(x, textCellW);
1031 SNAPUP(y, textCellH);
1033 else if(anchor.bottom.type)
1035 SNAPDOWN(y, textCellH);
1039 // This is required to get proper initial decoration size using native decorations on Windows
1040 #if defined(__WIN32__)
1041 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1042 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1044 GetDecorationsSize(&ew, &eh);
1046 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1048 // Leave room for non client windows (eventually dockable panels)
1050 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1051 for(win = parent.children.first; win; win = win.next)
1053 if(!win.isActiveClient && win.visible)
1055 Size size = win.size;
1056 Point pos = win.position;
1057 int left = pos.x, top = pos.y;
1058 int right = pos.x + size.w, bottom = pos.y + size.h;
1059 if(win.size.w > win.size.h)
1062 loY = Max(loY, bottom);
1063 else if(top > ph - ph / 4)
1064 hiY = Min(hiY, top);
1069 loX = Max(loX, right);
1070 else if(left > pw - pw / 4)
1071 hiX = Min(hiX, left);
1080 if(parent.sbv && !parent.sbv.style.hidden)
1081 pw += guiApp.currentSkin.VerticalSBW();
1082 if(parent.sbh && !parent.sbh.style.hidden)
1083 ph += guiApp.currentSkin.HorizontalSBH();
1085 if(anchor.left.type == cascade)
1087 w = (int)(pw * 0.80);
1088 h = (int)(ph * 0.80);
1090 else if(anchor.left.type >= vTiled)
1095 numTiling = parent.numPositions - parent.numIcons;
1096 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1097 if(anchor.left.type == vTiled)
1099 tilingH = (int)sqrt(numTiling);
1100 tilingW = numTiling / tilingH;
1104 tilingW = (int)sqrt(numTiling);
1105 tilingH = numTiling / tilingW;
1108 leftOver = numTiling - tilingH * tilingW;
1111 tilingSplit = (tilingW - leftOver) * tilingH;
1112 tilingLastH = tilingH+1;
1115 tilingSplit = numTiling;
1117 if(positionID >= tilingSplit)
1119 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1120 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1121 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1122 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1126 x = xOffset + pw * (positionID / tilingH) / tilingW;
1127 y = yOffset + ph * (positionID % tilingH) / tilingH;
1128 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1129 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1133 SNAPDOWN(x, textCellW);
1134 SNAPDOWN(y, textCellH);
1135 SNAPDOWN(x2, textCellW);
1136 SNAPDOWN(y2, textCellH);
1144 if(sizeAnchor.isClientW) w += ew;
1145 if(sizeAnchor.isClientH) h += eh;
1147 if(anchor.left.type == offset)
1148 x = anchor.left.distance;
1149 else if(anchor.left.type == relative)
1150 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1151 else if(anchor.right.type == relative)
1152 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1153 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1154 else if(anchor.right.type == offset)
1155 ex = vpw - anchor.right.distance;
1157 if(anchor.top.type == offset)
1158 y = anchor.top.distance;
1159 else if(anchor.top.type == relative)
1160 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1161 else if(anchor.bottom.type == relative)
1162 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1163 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1164 else if(anchor.bottom.type == offset)
1165 ey = vph - anchor.bottom.distance;
1167 if(anchor.left.type && anchor.right.type)
1169 switch(anchor.right.type)
1172 ex = pw * (1.0f-anchor.right.percent);
1173 w = Max((int)(ex + 0.5) - x, 0);
1176 ex = vpw - anchor.right.distance;
1177 w = Max((int)(ex + 0.5) - x, 0);
1181 if(anchor.top.type && anchor.bottom.type)
1183 switch(anchor.bottom.type)
1186 ey = ph * (1.0f-anchor.bottom.percent);
1187 h = Max((int)(ey + 0.5) - y, 0);
1190 ey = vph - anchor.bottom.distance;
1191 h = Max((int)(ey + 0.5) - y, 0);
1200 if(state == normal /*|| state == Hidden*/)
1202 bool addSbV = false, addSbH = false;
1204 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1205 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1207 w = Max(w, minSize.w);
1208 h = Max(h, minSize.h);
1209 w = Min(w, maxSize.w);
1210 h = Min(h, maxSize.h);
1212 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1214 if(w) w -= guiApp.currentSkin.VerticalSBW();
1217 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1219 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1223 if(!OnResizing(&w, &h))
1229 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1230 w += guiApp.currentSkin.VerticalSBW();
1231 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1232 h += guiApp.currentSkin.HorizontalSBH();
1234 w = Max(w, skinMinSize.w);
1235 h = Max(h, skinMinSize.h);
1248 SNAPDOWN(w, textCellW);
1249 SNAPDOWN(h, textCellH);
1252 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1254 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1257 (pw - w) / CASCADE_SPACE,
1258 (ph - h) / CASCADE_SPACE);
1264 cascW = (pw - w) / (numCascade-1);
1265 cascH = (ph - h) / (numCascade-1);
1266 SNAPDOWN(cascW, textCellW);
1267 SNAPDOWN(cascH, textCellH);
1268 cascadeW = (float)cascW;
1269 cascadeH = (float)cascH;
1273 numCascade = Max(numCascade, 2);
1274 cascadeW = (float)(pw - w) / (numCascade-1);
1275 cascadeH = (float)(ph - h) / (numCascade-1);
1278 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1279 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1281 else if(anchor.left.type < vTiled)
1283 if(!anchor.left.type || anchor.horz.type == middleRelative)
1285 if(!anchor.right.type)
1287 if(anchor.horz.type == middleRelative)
1288 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1290 x = vpw / 2 + anchor.horz.distance - w / 2;
1296 // case A_EDGE: x = x - w; break;
1298 if(!anchor.top.type || anchor.vert.type == middleRelative)
1300 if(!anchor.bottom.type)
1302 if(anchor.vert.type == middleRelative)
1303 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1305 y = vph / 2 + anchor.vert.distance - h / 2;
1311 // case A_EDGE: y = y - h; break;
1314 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1322 SNAPDOWN(x, textCellW);
1323 SNAPDOWN(y, textCellH);
1335 if(anchored && style.fixed && style.isActiveClient)
1340 void UpdateCaret(bool forceUpdate, bool erase)
1342 static Window lastWindow = null;
1343 static int caretX, caretY, caretSize;
1345 if(guiApp && guiApp.caretOwner == this)
1347 int x = caretPos.x - scroll.x;
1348 int y = caretPos.y - scroll.y;
1350 if((erase || this.caretSize) &&
1351 x >= clientArea.left && x <= clientArea.right &&
1352 y >= clientArea.top && y <= clientArea.bottom)
1356 guiApp.interfaceDriver.SetCaret(
1357 x + absPosition.x + clientStart.x,
1358 y + absPosition.y + clientStart.y, this.caretSize);
1359 guiApp.caretEnabled = true;
1361 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1365 if(lastWindow != this)
1367 updateBox.left = x + 1;
1369 updateBox.right = x + 2;
1370 updateBox.bottom = y + this.caretSize - 1;
1374 updateBox.left = Min(x + 1, caretX + 1);
1375 updateBox.top = Min(y, caretY);
1376 updateBox.right = Max(x + 2, caretX + 2);
1377 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1380 guiApp.caretOwner.Update(updateBox);
1387 caretSize = this.caretSize;
1393 guiApp.interfaceDriver.SetCaret(0,0,0);
1394 guiApp.caretEnabled = false;
1400 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1405 scrolledPos.x = position.x = x;
1406 scrolledPos.y = position.y = y;
1408 clientSize.w = size.w = w;
1409 clientSize.h = size.h = h;
1411 if(parent && !style.nonClient)
1413 //if(!style.fixed || style.isDocument)
1415 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1416 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1420 clientStart.x = clientStart.y = 0;
1422 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1424 //if(!activeClient || activeClient.state != maximized)
1425 if(!noAutoScrollArea)
1427 // Check if scroll area must be modified
1428 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1430 bool foundChild = false;
1432 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1433 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1434 for(child = children.first; child; child = child.next)
1436 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1437 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1439 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1440 w = Max(w, child.position.x + child.size.w);
1441 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1442 w = Max(w, Max(child.position.x, 0) + child.size.w);
1443 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1444 h = Max(h, child.position.y + child.size.h);
1445 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1446 h = Max(h, Max(child.position.y, 0) + child.size.h);
1451 if(foundChild && (w > cw || h > ch))
1453 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1455 int stepX = sbStep.x, stepY = sbStep.y;
1456 // Needed to make snapped down position match the skin's check of client area
1457 // against realvirtual
1460 SNAPDOWN(stepX, textCellW);
1461 SNAPDOWN(stepY, textCellH);
1462 stepX = Max(stepX, textCellW);
1463 stepY = Max(stepY, textCellH);
1465 if(scrollFlags.snapX)
1467 if(scrollFlags.snapY)
1470 reqScrollArea.w = w;
1471 reqScrollArea.h = h;
1474 else if(reqScrollArea.w || reqScrollArea.h)
1476 reqScrollArea.w = 0;
1477 reqScrollArea.h = 0;
1478 SetScrollPosition(0,0);
1483 // Automatic MDI Client Scrolling Area Adjustment
1484 if(parent && !parent.noAutoScrollArea)
1486 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1487 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1489 Window parent = this.parent;
1490 int w = parent.reqScrollArea.w;
1491 int h = parent.reqScrollArea.h;
1493 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1494 w = Max(w, position.x + size.w);
1495 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1496 w = Max(w, Max(position.x, 0) + size.w);
1497 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1498 h = Max(h, position.y + size.h);
1499 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1500 h = Max(h, Max(position.y, 0) + size.h);
1502 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1503 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1505 /*bool resize = false;
1506 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1507 // Needed to make snapped down position match the skin's check of client area
1508 // against realvirtual
1511 SNAPDOWN(stepX, textCellW);
1512 SNAPDOWN(stepY, textCellH);
1513 stepX = Max(stepX, textCellW);
1514 stepY = Max(stepY, textCellH);
1516 if(parent.scrollFlags.snapX)
1518 if(parent.scrollFlags.snapY)
1520 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1522 parent.reqScrollArea.w = w;
1523 parent.reqScrollArea.h = h;*/
1525 // parent.UpdateScrollBars(true, true);
1526 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1527 false, true, true, true, false, false);
1532 GetRidOfVirtualArea();
1536 UpdateScrollBars(modifyThisArea, false);
1537 else if(guiApp.currentSkin)
1540 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1542 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1543 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1544 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1545 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1548 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1549 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1551 absPosition = scrolledPos;
1552 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1553 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1555 if(this != guiApp.desktop && parent)
1557 absPosition.x += parent.absPosition.x;
1558 absPosition.y += parent.absPosition.y;
1559 if(!style.nonClient && this != guiApp.desktop)
1561 absPosition.x += parent.clientStart.x;
1562 absPosition.y += parent.clientStart.y;
1566 box = Box { 0, 0, size.w - 1, size.h - 1 };
1571 // Clip against parent's client area
1572 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1574 // Compute client area in this window coordinate system
1575 clientArea.left = 0;
1577 clientArea.right = clientSize.w - 1;
1578 clientArea.bottom = clientSize.h - 1;
1580 // Clip against parent's client area
1582 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1586 //absPosition.x -= parent.clientStart.x;
1587 //absPosition.y -= parent.clientStart.y;
1590 // Adjust all children
1591 for(child = children.first; child; child = child.next)
1592 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1594 UpdateCaret(false, false);
1597 void GetRidOfVirtualArea(void)
1599 if(parent && !parent.destroyed && style.fixed &&
1600 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1601 parent.reqScrollArea.w && parent.reqScrollArea.h)
1603 if(!parent.noAutoScrollArea)
1607 for(child = children.first; child; child = child.next)
1609 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1611 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1612 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1621 Window parent = this.parent;
1623 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1624 false, true, true, true, false, false);
1626 parent.SetScrollArea(0,0,true);
1627 parent.SetScrollPosition(0,0);
1633 public void ExternalPosition(int x, int y, int w, int h)
1635 Position(x, y, w, h, false, true, true, true, false, false);
1638 // (w, h): Full window size
1639 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1641 bool result = false;
1642 int oldCW = clientSize.w, oldCH = clientSize.h;
1643 bool clientResized, windowResized, windowMoved;
1645 bool realResized = size.w != w || size.h != h;
1647 // TOCHECK: This wasn't in ecere.dll
1648 //if(!parent) return true;
1649 if(destroyed) return false;
1651 windowMoved = position.x != x || position.y != y || force;
1653 // windowResized = realResized || force;
1654 windowResized = size.w != w || size.h != h || force;
1656 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1662 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1663 scrolledPos.x - parent.clientStart.x + this.box.right,
1664 scrolledPos.y - parent.clientStart.y + this.box.bottom
1670 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1675 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1677 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1678 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1679 windowResized = true;
1681 if(display && rootWindow != this)
1684 if(guiApp && guiApp.windowMoving)
1686 if(guiApp.windowMoving.style.nonClient)
1687 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1689 guiApp.windowMoving.parent.SetMouseRangeToClient();
1699 // Buttons bitmap resources crash if we do this while switching mode
1700 if(!guiApp || !guiApp.modeSwitching)
1703 // Process Anchored Children
1707 for(child = children.first; child; child = child.next)
1710 ((child.stateAnchor.left.type != offset ||
1711 child.stateAnchor.top.type != offset ||
1712 child.stateAnchor.right.type != none ||
1713 child.stateAnchor.bottom.type != none) ||
1714 child.state == maximized || child.state == minimized))
1716 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1718 // child.Position(x, y, w, h, false, true, true, true, false);
1719 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1720 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1726 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1727 //if(updateScrollBars)
1729 OnResize(clientSize.w, clientSize.h);
1731 if((clientResized || windowMoved) && created)
1732 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1734 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1736 Window master = guiApp.interimWindow.master;
1737 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1740 if(rootWindow == this && !is3D)
1744 x -= guiApp.desktop.absPosition.x;
1745 y -= guiApp.desktop.absPosition.y;
1747 //guiApp.Log("Position %s\n", caption);
1750 if(windowResized || windowMoved)
1751 if(display && !display.flags.memBackBuffer && changeRootWindow)
1752 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1754 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1755 for(child = parent.children.first; child && child != this; child = child.next)
1756 if(child.rootWindow)
1757 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1762 if(windowMoved || windowResized)
1764 display.Lock(true /*false*/);
1767 display.Position(absPosition.x, absPosition.y);
1768 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1771 // result = realResized ? display.Resize(size.w, size.h) : true;
1772 if(nativeDecorations && rootWindow.windowHandle)
1774 int w = clientSize.w, h = clientSize.h;
1775 if(hasMenuBar) h += skinMenuHeight;
1776 if(hasStatusBar) h += statusBarHeight;
1777 if(sbv && sbv.visible) w += sbv.size.w;
1778 if(sbh && sbh.visible) h += sbh.size.h;
1779 result = manageDisplay ? display.Resize(w, h) : true;
1782 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1786 else if(clientResized)
1788 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1791 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1795 if(windowMoved || windowResized)
1800 if(guiApp.driver && changeRootWindow && windowHandle)
1802 if(windowResized || windowMoved)
1803 if(!display || display.flags.memBackBuffer)
1804 guiApp.interfaceDriver.PositionRootWindow(this,
1805 x, y, w, h, windowMoved, windowResized);
1806 guiApp.interfaceDriver.UpdateRootWindow(this);
1808 for(child = children.first; child; child = child.next)
1810 if(child.is3D && child.created)
1812 // Copy Display Content
1813 child.display.displaySystem = display.displaySystem;
1814 child.display.window = display.window;
1815 child.display.current = display.current;
1816 child.display.width = display.width;
1817 child.display.height = display.height;
1818 child.display.driverData = display.driverData;
1819 child.display.mutex = null;
1830 void UpdateScrollBars(bool flag, bool fullThing)
1833 bool resizeH = false, resizeV = false;
1834 bool scrolled = false;
1835 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1836 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1838 if(destroyed) return;
1839 if(guiApp.currentSkin)
1841 MinMaxValue cw = 0, ch = 0;
1842 bool sbvVisible, sbhVisible;
1844 int positionH, positionV;
1846 // First get client area with no respect to scroll bars
1851 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1853 if(scrollFlags.dontHide)
1856 cw -= guiApp.currentSkin.VerticalSBW();
1858 ch -= guiApp.currentSkin.HorizontalSBH();
1860 // Update the scrollbar visibility
1866 sbh.disabled = rangeH <= 1;
1867 if(sbh.style.hidden)
1877 sbv.disabled = rangeV <= 1;
1878 if(sbv.style.hidden)
1886 int oldHRange = sbh ? sbh.range : 0;
1887 int oldVRange = sbv ? sbv.range : 0;
1888 // Then start off with horizontal scrollbar range
1891 positionH = sbh.thumbPosition;
1898 SBSetTotal(sbh, rvw);
1901 ch -= guiApp.currentSkin.HorizontalSBH();
1904 // Do the same for vertical scrollbar
1907 positionV = sbv.thumbPosition;
1913 SBSetTotal(sbv, rvh);
1917 cw -= guiApp.currentSkin.VerticalSBW();
1918 // Maybe we need to set the range on the horizontal scrollbar again
1926 SBSetTotal(sbh, rvw);
1927 //sbh.Action(setRange, positionH, 0);
1928 if(rangeH <= 1 && sbh.range > 1)
1930 ch -= guiApp.currentSkin.HorizontalSBH();
1936 SBSetTotal(sbv, rvh);
1938 //sbv.Action(setRange, positionV, 0);
1943 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1944 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1947 // Update the scrollbar visibility
1948 if(!scrollFlags.dontHide)
1950 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1954 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1961 if(guiApp.currentSkin)
1968 sbhVisible = sbh.style.hidden ? true : false;
1970 sbvVisible = sbv.style.hidden ? true : false;
1972 // Do our resize here
1973 if(flag && (resizeH || resizeV) && fullThing)
1975 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1980 OnResize(clientSize.w, clientSize.h);
1986 sbh.visible = sbhVisible;
1988 sbv.visible = sbvVisible;
1990 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1991 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1994 sbh.pageStep = clientSize.w;
1996 sbv.pageStep = clientSize.h;
1998 // Notify doesn't handle setRange anymore... process it here
2001 int positionH = sbh.thumbPosition;
2002 if(scroll.x != positionH)
2004 OnHScroll(setRange, positionH, 0);
2008 SNAPDOWN(positionH, textCellW);
2009 scroll.x = positionH;
2015 int seen = clientSize.w, total = reqScrollArea.w;
2018 if(scrollFlags.snapX)
2019 SNAPDOWN(seen, sbStep.x);
2021 if(!total) total = seen;
2022 range = total - seen + 1;
2024 range = Max(range, 1);
2026 if(x >= range) x = range - 1;
2028 if(scrollFlags.snapX)
2029 SNAPUP(x, sbStep.x);
2033 OnHScroll(setRange, x, 0);
2038 SNAPDOWN(x, textCellW);
2044 int positionV = sbv.thumbPosition;
2045 if(scroll.y != positionV)
2047 OnVScroll(setRange, positionV, 0);
2051 SNAPDOWN(positionV, textCellH);
2052 scroll.y = positionV;
2058 int seen = clientSize.h, total = reqScrollArea.h;
2061 if(scrollFlags.snapY)
2062 SNAPDOWN(seen, sbStep.y);
2064 if(!total) total = seen;
2065 range = total - seen + 1;
2066 range = Max(range, 1);
2068 if(y >= range) y = range - 1;
2070 if(scrollFlags.snapY)
2071 SNAPUP(y, sbStep.y);
2075 OnVScroll(setRange, y, 0);
2080 SNAPDOWN(y, textCellH);
2086 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2089 for(child = children.first; child; child = child.next)
2091 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2094 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2095 child.Position(x, y, w, h, false, true, false, true, false, false);
2102 // Process Scrollbars
2104 if(sbh) // && !sbh.style.hidden
2107 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2108 // Need to set the range again (should improve...) since the scrollbars didn't have
2109 // the right size when UpdateScrollArea set the range on it
2112 sbh.seen = clientSize.w;
2116 if(sbv) // && !sbv.state.hidden
2119 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2120 // Need to set the range again (should improve...) since the scrollbars didn't have
2121 // the right size when UpdateScrollArea set the range on it
2124 sbv.seen = clientSize.h;
2129 // TESTING THIS LOWER
2130 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2133 for(child = children.first; child; child = child.next)
2135 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2138 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2139 child.Position(x, y, w, h, false, true, false, true, false, false);
2145 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2147 SetState(maximized, false, mods);
2151 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2153 SetState(normal, false, mods);
2157 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2159 SetState(minimized, false, mods);
2160 parent.CycleChildren(false, true, false, true);
2164 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2167 // Scroll bar notifications
2168 if(action != setRange)
2170 bool changed = false;
2174 if(scroll.x != position)
2176 OnHScroll(action, position, keyFlags);
2181 SNAPDOWN(position, textCellW);
2183 scroll.x = position;
2187 if(scroll.y != position)
2189 OnVScroll(action, position, keyFlags);
2194 SNAPDOWN(position, textCellH);
2196 scroll.y = position;
2200 bool childMove = false;
2201 for(child = children.first; child; child = child.next)
2203 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2206 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2207 child.Position(x, y, w, h, false, true, false, true, false, false);
2211 // Testing this patch out to solve MDI workspace redraw bugs
2212 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2213 // Scroll offsets to blame?
2217 UpdateCaret(false, false);
2221 // Testing this patch out to solve MDI workspace redraw bugs
2222 for(child = children.first; child; child = child.next)
2224 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2233 Window GetParentMenuBar()
2235 Window menuBarParent;
2236 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2238 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2239 if(menuBarParent && !menuBarParent.isActiveClient)
2245 void CreateSystemChildren(void)
2247 Window parent = this;
2248 bool scrollBarChanged = false;
2249 bool hasClose = false, hasMaxMin = false;
2250 Point scroll = this.scroll;
2252 if(state == maximized)
2254 parent = GetParentMenuBar();
2261 if(style.hasClose) hasClose = true;
2262 if(style.hasMaximize || style.hasMinimize)
2269 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2271 sysButtons[2].Destroy(0);
2272 sysButtons[2] = null;
2274 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2276 sysButtons[1].Destroy(0);
2277 sysButtons[1] = null;
2279 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2281 sysButtons[0].Destroy(0);
2282 sysButtons[0] = null;
2285 if(hasClose && parent)
2292 parent, master = this,
2293 inactive = true, nonClient = true, visible = false;
2295 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2301 if(this.parent == guiApp.desktop)
2302 sysButtons[2].hotKey = altF4;
2303 else if(style.isActiveClient)
2304 sysButtons[2].hotKey = ctrlF4;
2305 sysButtons[2].Create();
2308 sysButtons[2].symbol = 'X';
2309 sysButtons[2].disabled = !style.hasClose;
2312 if(hasMaxMin && parent)
2316 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2317 if(state == maximized)
2320 method = RestoreButtonClicked;
2326 method = MaximizeButtonClicked;
2334 parent, master = this,
2335 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2337 sysButtons[1].Create();
2339 sysButtons[1].NotifyClicked = method;
2341 sysButtons[1].symbol = symbol;
2342 sysButtons[1].disabled = !style.hasMaximize;
2345 if(hasMaxMin && parent)
2349 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2350 if (state == minimized)
2353 method = RestoreButtonClicked;
2359 method = MinimizeButtonClicked;
2367 parent, master = this,
2368 hotKey = altM, inactive = true, nonClient = true, visible = false
2370 sysButtons[0].Create();
2372 sysButtons[0].NotifyClicked = method;
2374 sysButtons[0].symbol = symbol;
2375 sysButtons[0].disabled = !style.hasMinimize;
2378 // Create the scrollbars
2379 if(style.hasHorzScroll && !sbh)
2385 direction = horizontal,
2389 snap = scrollFlags.snapX,
2390 NotifyScrolling = ScrollBarNotification
2393 scrollBarChanged = true;
2395 else if(sbh && !style.hasHorzScroll)
2401 if(style.hasVertScroll && !sbv)
2407 direction = vertical,
2411 snap = scrollFlags.snapY,
2412 NotifyScrolling = ScrollBarNotification
2415 scrollBarChanged = true;
2417 else if(sbv && !style.hasVertScroll)
2422 if(scrollBarChanged)
2424 SetScrollLineStep(sbStep.x, sbStep.y);
2425 UpdateScrollBars(true, true);
2429 if(scrollBarChanged)
2431 if(sbh) sbh.thumbPosition = scroll.x;
2432 if(sbv) sbv.thumbPosition = scroll.y;
2436 void UpdateCaption(void)
2438 if(rootWindow == this)
2441 FigureCaption(caption);
2442 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2444 UpdateDecorations();
2447 if(parent.activeClient == this) // Added this last check
2449 if(parent.rootWindow == parent)
2452 parent.FigureCaption(caption);
2453 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2456 parent.UpdateCaption();
2458 parent.UpdateDecorations();
2462 void UpdateActiveDocument(Window previous)
2464 Window activeClient = this.activeClient;
2465 Window activeChild = this.activeChild;
2472 activeClient.CreateSystemChildren();
2474 previous.CreateSystemChildren();
2486 // Build window list
2489 Menu windowMenu = menu.FindMenu("Window");
2494 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2497 Window document = cycle.data;
2498 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2500 char name[2048], caption[2048];
2501 document.FigureCaption(caption);
2502 sprintf(name, "%d %s", id+1, caption);
2503 windowMenu.AddDynamic(MenuItem
2505 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2506 NotifySelect = MenuWindowSelectWindow
2510 if(activeClient.cycle == cycle) break;
2515 if((!previous && activeClient) || !activeClient)
2521 item = menu.FindItem(MenuWindowCloseAll, 0);
2522 if(item) item.disabled = false;
2523 item = menu.FindItem(MenuWindowNext, 0);
2524 if(item) item.disabled = false;
2525 item = menu.FindItem(MenuWindowPrevious, 0);
2526 if(item) item.disabled = false;
2527 item = menu.FindItem(MenuWindowCascade, 0);
2528 if(item) item.disabled = false;
2529 item = menu.FindItem(MenuWindowTileHorz, 0);
2530 if(item) item.disabled = false;
2531 item = menu.FindItem(MenuWindowTileVert, 0);
2532 if(item) item.disabled = false;
2533 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2534 if(item) item.disabled = false;
2535 item = menu.FindItem(MenuWindowWindows, 0);
2536 if(item) item.disabled = false;
2539 item = menu.FindItem(MenuFileClose, 0);
2540 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2541 item = menu.FindItem(MenuFileSaveAll, 0);
2542 if(item) item.disabled = numDocuments < 1;
2544 if(activeClient && activeClient.menu && activeClient.state != minimized)
2548 //activeClient.menu.Clean(activeClient);
2549 menu.Merge(activeClient.menu, true, activeClient);
2553 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2556 menu.Merge(activeChild.menu, true, activeChild);
2559 // This is called again for a child window change, with same active client
2560 OnActivateClient(activeClient, previous);
2561 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2562 parent.UpdateActiveDocument(null);
2565 void _ShowDecorations(Box box, bool post)
2567 if(rootWindow == this && nativeDecorations) return;
2568 if(visible && this != guiApp.desktop)
2570 Surface surface = RedrawFull(box);
2574 FigureCaption(caption);
2577 ShowDecorations(captionFont.font,
2580 active, //parent.activeClient == this
2581 guiApp.windowMoving == this);
2583 PreShowDecorations(captionFont.font,
2586 active, //parent.activeClient == this
2587 guiApp.windowMoving == this);
2594 void UpdateExtent(Box refresh)
2596 Surface surface = null;
2598 if(!manageDisplay) { OnRedraw(null);return; }
2599 _ShowDecorations(refresh, false);
2601 surface = Redraw(refresh);
2602 // Opaque background: just fill before EW_REDRAW (clear?)
2605 surface.SetBackground(background);
2606 surface.SetForeground(foreground);
2607 surface.DrawingChar(' ');
2608 if(this == rootWindow)
2610 if(style.drawBehind || background.a)
2612 int a = background.a;
2613 // Premultiply alpha for clear color
2614 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2615 surface.Clear(colorBuffer);
2616 surface.SetBackground(background);
2619 else if(background.a)
2623 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2624 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2627 if(display.flags.alpha && background.a < 255 && background)
2629 surface.Area(0,0,clientSize.w, clientSize.h);
2630 /*if(style.clearDepthBuffer)
2631 surface.Clear(depthBuffer);*/
2633 else if(/*style.clearDepthBuffer || */background.a)
2635 int a = background.a;
2636 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2637 // Premultiply alpha for clear color
2638 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2639 surface.Clear(colorBuffer);
2640 surface.SetBackground(background);
2645 surface.TextFont(usedFont.font);
2646 surface.TextOpacity(false);
2650 // Draw the caret ...
2651 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2653 // surface.SetBackground(0xFFFFFF - background.color);
2654 surface.SetBackground(~background.color);
2656 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2657 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2663 void DrawOverChildren(Box refresh)
2665 Surface surface = Redraw(refresh);
2669 surface.DrawingChar(' ');
2670 surface.SetBackground(background);
2671 surface.SetForeground(foreground);
2673 surface.TextFont(usedFont.font);
2674 surface.TextOpacity(false);
2676 OnDrawOverChildren(surface);
2681 _ShowDecorations(refresh, true);
2684 void ComputeClipExtents(void)
2687 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2689 clipExtent.Copy(this.clipExtent);
2691 for(child = children.last; child; child = child.prev)
2693 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2695 bool opaque = child.IsOpaque(); // TODO: acess background directly
2696 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2698 child.clipExtent.Copy(clipExtent);
2699 child.clipExtent.Offset(-dx, -dy);
2700 child.clipExtent.IntersectBox(child.box);
2702 child.ComputeClipExtents();
2704 if(opaque && !child.style.nonClient)
2706 // Adjust the box for the parent:
2707 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2708 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2713 // ??? Only do this for overlapped window or if parent has with clip children flag
2715 // Do this if window has clip children flag on (default false?)
2716 // this.clipExtent = clipExtent;
2718 clipExtent.Free(null);
2721 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2723 bool opaque = IsOpaque();
2725 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2726 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2728 offsetX -= rootWindow.clientStart.x;
2729 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2733 for(child = children.last; child; child = child.prev)
2735 ColorAlpha background = *(ColorAlpha *)&child.background;
2736 bool opaque = child.IsOpaque();
2737 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2741 // Adjust renderArea to the root window level
2742 Extent * renderArea = &rootWindow.tempExtents[3];
2744 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2745 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2746 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2748 offsetX -= child.rootWindow.clientStart.x;
2749 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2753 Extent childRenderArea;
2755 if(backBufferUpdate != null)
2757 childRenderArea.Copy(backBufferUpdate);
2758 childRenderArea.Offset(-offsetX, -offsetY);
2761 childRenderArea.Copy(child.dirtyArea);
2763 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2764 renderArea.Copy(dirtyExtent);
2765 renderArea.Offset(-offsetX, -offsetY);
2766 childRenderArea.Union(renderArea);
2769 // Intersect with the clip extent
2770 childRenderArea.Intersection(child.clipExtent);
2773 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2775 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2776 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2778 renderArea->Offset(offsetX, offsetY);
2780 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2781 // overDirtyExtent.Union(renderArea);
2782 renderArea->Empty();
2783 // childRenderArea.Free();
2785 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2790 for(child = children.last; child; child = child.prev)
2792 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2794 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2799 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2801 bool opaque = IsOpaque();
2802 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2804 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2805 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2807 offsetX -= rootWindow.clientStart.x;
2808 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2812 for(child = children.last; child; child = child.prev)
2814 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2816 ColorAlpha background = *(ColorAlpha *)&child.background;
2817 bool opaque = child.IsOpaque();
2818 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2822 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2823 // Adjust renderArea to the root window level
2825 renderArea.Copy(child.dirtyArea);
2826 renderArea.Offset(offsetX, offsetY);
2827 dirtyExtent.Union(renderArea);
2828 overDirtyExtent.Union(renderArea);
2834 for(child = children.last; child; child = child.prev)
2836 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2838 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2842 if(backBufferUpdate != null)
2844 renderArea.Copy(backBufferUpdate);
2845 renderArea.Offset(-offsetX, -offsetY);
2847 overRenderArea.Copy(backBufferUpdate);
2848 overRenderArea.Offset(-offsetX, -offsetY);
2854 renderArea.Copy(dirtyArea);
2856 overRenderArea.Copy(dirtyArea);
2859 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2860 dirtyExtentWindow->Copy(dirtyExtent);
2861 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2862 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2863 dirtyExtentWindow->Empty();
2865 // Intersect with the clip extent
2866 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2869 if(renderArea.count > 10)
2872 printf("\nToo many extents (%d):\n", renderArea.count);
2874 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2875 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2880 for(c = 0; c<10; c++)
2883 FASTLIST_LOOP(renderArea, extentBox)
2885 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2887 renderArea.Copy(extent);
2889 FASTLIST_LOOP(renderArea, extentBox)
2892 printf("(%d, %d) - (%d, %d)\n",
2893 extentBox.box.left, extentBox.box.top,
2894 extentBox.box.right, extentBox.box.bottom);
2898 printf("\nNow %d\n", renderArea.count);
2904 // WHY WAS THIS COMMENTED ??
2906 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2907 dirtyExtentWindow->Copy(overDirtyExtent);
2908 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2909 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2910 dirtyExtentWindow->Empty();
2912 // Intersect with the clip extent
2913 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2919 if(scrollExtent.count)
2921 // Subtract render extent from scrolling extent
2922 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2924 if(backBufferUpdate == null)
2926 Extent * dirty = &rootWindow.tempExtents[3];
2929 // Intersect scrolling extent with clip extent
2930 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2932 // offset this scroll to be at the root window level
2933 scrollExtent.Offset(offsetX, offsetY);
2934 // Add area that was scrolled to the dirty extents of the back buffer
2935 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2939 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2940 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2941 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2946 scrollExtent.Empty();
2948 // Add the exposed extent to the window render area
2949 dirty->Offset(-offsetX, -offsetY);
2950 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2955 // Subtract the window's box from the transparency forced extent
2956 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2962 renderArea.Copy(this.renderArea);
2963 renderArea.Offset(offsetX, offsetY);
2964 dirtyExtent.Union(renderArea);
2970 Extent renderArea { };
2972 renderArea.Copy(overRenderArea);
2973 renderArea.Offset(offsetX, offsetY);
2974 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2979 if(backBufferUpdate != null)
2981 // Remove render area from dirty area
2982 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2984 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2991 // Remove the window render area from the dirty extents of the back buffer
2992 rootWindow.dirtyBack.Exclusion(renderArea);
2996 void Render(Extent updateExtent)
3000 Window rootWindow = this.rootWindow;
3001 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3002 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3004 offsetX -= rootWindow.clientStart.x;
3005 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3008 if(rootWindow.fullRender)
3017 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3018 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3023 /*if(renderArea.count)
3024 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3027 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3029 Box box = extentBox.box;
3032 /*printf("(%d, %d) - (%d, %d)\n",
3033 extentBox.box.left, extentBox.box.top,
3034 extentBox.box.right, extentBox.box.bottom);*/
3039 box.left += offsetX;
3041 box.right += offsetX;
3042 box.bottom += offsetY;
3044 if(updateExtent != null)
3045 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3049 for(child = children.first; child; child = child.next)
3050 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3051 child.Render(updateExtent);
3053 if(rootWindow.fullRender)
3054 DrawOverChildren(box);
3057 // TO DO: There's an issue about draw over children...
3058 // TO DO: Don't wanna go through this if method isn't used
3059 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3060 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3062 Box box = extentBox.box;
3064 DrawOverChildren(box);
3066 box.left += offsetX;
3068 box.right += offsetX;
3069 box.bottom += offsetY;
3071 if(updateExtent != null)
3072 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3075 for(child = children.first; child; child = child.next)
3076 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3077 child.Render(updateExtent);
3080 overRenderArea.Empty();
3083 public void UpdateDisplay(void)
3085 if(!manageDisplay) { OnRedraw(null);return; }
3086 if(rootWindow && this != rootWindow)
3087 rootWindow.UpdateDisplay();
3090 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3091 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3094 dirtyExtent.Clear();
3097 clipExtent.AddBox(box);
3099 display.StartUpdate();
3101 if(!rootWindow.fullRender)
3103 ComputeClipExtents();
3104 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3105 ComputeRenderArea(dirtyExtent, overExtent, null);
3108 clipExtent.Free(null);
3110 dirtyExtent.Free(null);
3111 overExtent.Free(null);
3113 if(display.flags.flipping)
3116 display.Update(null);
3120 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3121 updateExtent.Clear();
3123 Render(updateExtent);
3125 updateExtent.UnionBox(this.box, tempExtents[0]);
3128 //printf("\n\nUpdate:\n------------------------------------------\n");
3131 //FASTLIST_LOOP(updateExtent, extentBox)
3132 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3135 /*printf("Updating (%d, %d) - (%d, %d)\n",
3136 extentBox.box.left, extentBox.box.top,
3137 extentBox.box.right, extentBox.box.bottom);*/
3140 display.Update(extentBox.box);
3143 updateExtent.Free(null);
3146 display.EndUpdate();
3154 void UpdateBackDisplay(Box box)
3160 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3162 //printf("UpdateBackDisplay going through!\n");
3163 display.StartUpdate();
3167 intersection.Copy(dirtyBack);
3168 intersection.IntersectBox(box);
3170 dirtyExtent.Clear();
3173 clipExtent.AddBox(box);
3175 if(!rootWindow.fullRender)
3177 ComputeClipExtents();
3178 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3181 clipExtent.Free(null);
3183 intersection.Free(null);
3184 dirtyExtent.Free(null);
3185 overExtent.Free(null);
3190 if(display.flags.flipping)
3191 display.Update(null);
3194 rootWindow.display.Update(box);
3197 display.EndUpdate();
3201 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3202 if(dirtyBack.count > MAX_DIRTY_BACK)
3204 BoxItem extentBox, next;
3205 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3206 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3208 next = (BoxItem)extentBox.next;
3209 if(extentBox != first)
3211 if(extentBox.box.left < first.box.left)
3212 first.box.left = extentBox.box.left;
3213 if(extentBox.box.top < first.box.top)
3214 first.box.top = extentBox.box.top;
3215 if(extentBox.box.right > first.box.right)
3216 first.box.right = extentBox.box.right;
3217 if(extentBox.box.bottom > first.box.bottom)
3218 first.box.bottom = extentBox.box.bottom;
3219 dirtyBack.Delete(extentBox);
3228 // --- Window positioning ---
3229 // --- Window identification ---
3231 // Returns window at position "Position"
3232 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3234 Window child, result = null;
3236 box.left += absPosition.x;
3237 box.right += absPosition.x;
3238 box.top += absPosition.y;
3239 box.bottom += absPosition.y;
3241 if(!destroyed && visible && (acceptDisabled || !disabled))
3243 int lx = x - absPosition.x;
3244 int ly = y - absPosition.y;
3245 if(IsInside(lx, ly))
3246 // if(box.IsPointInside(Point{x, y}))
3248 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3249 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3252 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3253 Window ancestor = null;
3255 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3256 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3257 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3259 if(child != statusBar && child.rootWindow == rootWindow)
3261 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3268 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3269 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3271 if(child != statusBar && child.rootWindow == rootWindow)
3273 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3280 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3288 Window FindModal(void)
3290 Window modalWindow = this, check;
3291 Window check2 = null;
3292 for(check = this; check.master; check = check.master)
3294 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3296 modalWindow = check.master.modalSlave;
3297 check = modalWindow;
3299 // TESTING THIS FOR DROPBOX...
3300 if(!rootWindow || !rootWindow.style.interim)
3302 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3304 if(check2.modalSlave && check2.modalSlave.created)
3306 modalWindow = check2.modalSlave;
3314 if(modalWindow == this)
3316 for(check = this; check.activeChild; check = check.activeChild)
3318 if(check.modalSlave)
3320 modalWindow = check.modalSlave;
3326 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3327 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3330 void StopMoving(void)
3332 if(this == guiApp.windowMoving)
3334 guiApp.windowMoving = null;
3335 UpdateDecorations();
3336 SetMouseRange(null);
3339 if(rootWindow.active)
3340 guiApp.interfaceDriver.StopMoving(rootWindow);
3343 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3344 guiApp.windowIsResizing = false;
3348 void SelectMouseCursor(void)
3353 Window cursorWindow = null;
3354 bool rx, ry, rex, rey;
3356 guiApp.desktop.GetMousePosition(&x, &y);
3357 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3359 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3360 guiApp.SetCurrentCursor(guiApp.windowMoving, guiApp.systemCursors[moving]);
3361 else if(mouseWindow)
3363 modalWindow = mouseWindow.FindModal();
3364 x -= mouseWindow.absPosition.x;
3365 y -= mouseWindow.absPosition.y;
3366 if(guiApp.windowIsResizing)
3368 rex = guiApp.resizeEndX;
3369 rey = guiApp.resizeEndY;
3370 rx = guiApp.resizeX;
3371 ry = guiApp.resizeY;
3372 if((rex && rey) || (rx && ry))
3373 guiApp.SetCurrentCursor(guiApp.windowMoving, guiApp.systemCursors[sizeNWSE]);
3374 else if((rex && ry) || (rx && rey))
3375 guiApp.SetCurrentCursor(guiApp.windowMoving, guiApp.systemCursors[sizeNESW]);
3376 else if((ry || rey) && (!rx && !rex))
3377 guiApp.SetCurrentCursor(guiApp.windowMoving, guiApp.systemCursors[sizeNS]);
3378 else if((rx || rex) && (!ry && !rey))
3379 guiApp.SetCurrentCursor(guiApp.windowMoving, guiApp.systemCursors[sizeWE]);
3381 else if(!modalWindow && !guiApp.windowCaptured &&
3382 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3383 &rx, &ry, &rex, &rey))
3385 if((rex && rey) || (rx && ry))
3386 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3387 else if((rex && ry) || (rx && rey))
3388 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3389 else if((ry || rey) && (!rx && !rex))
3390 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3391 else if((rx || rex) && (!ry && !rey))
3392 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3394 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3396 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3397 mouseWindow.rootWindow != mouseWindow)
3398 cursorWindow = mouseWindow.parent;
3400 cursorWindow = mouseWindow;
3402 else if(!guiApp.interimWindow)
3403 cursorWindow = guiApp.windowCaptured;
3406 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3407 guiApp.SetCurrentCursor(cursorWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3409 else if(modalWindow)
3411 guiApp.SetCurrentCursor(null, guiApp.systemCursors[arrow]);
3413 else if(guiApp.interimWindow)
3415 if(guiApp.interimWindow.cursor)
3416 guiApp.SetCurrentCursor(guiApp.interimWindow, guiApp.interimWindow.cursor);
3418 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3423 // --- State based input ---
3424 bool AcquireInputEx(bool state)
3429 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3430 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3432 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3434 guiApp.acquiredWindow = state ? this : null;
3437 SetMouseRangeToClient();
3438 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3443 SelectMouseCursor();
3445 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3449 // --- Window activation ---
3450 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3453 if(!parent || !parent.style.inactive)
3455 Window parent = this.parent;
3458 if(rootWindow == this)
3459 Log(active ? "active\n" : "inactive\n");
3462 // Testing this here...
3463 if(!parent || parent == guiApp.desktop || parent.active)
3465 this.active = active;
3468 // TESTING THIS HERE
3469 UpdateDecorations();
3470 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3471 result = NotifyActivate(master, this, active, previous);
3474 this.active = !active;
3479 if(!parent || parent == guiApp.desktop || parent.active)
3481 this.active = active;
3483 AcquireInputEx(active);
3488 if(guiApp.caretOwner)
3492 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3493 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3494 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3495 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3497 guiApp.caretOwner.Update(extent);
3500 if(visible || !guiApp.caretOwner)
3501 guiApp.caretOwner = this;
3502 UpdateCaret(false, false);
3508 this.active = false;
3510 AcquireInputEx(active);
3512 if(!active && guiApp.caretOwner == this)
3514 UpdateCaret(false, true);
3515 guiApp.caretOwner = null;
3516 guiApp.interfaceDriver.SetCaret(0,0,0);
3517 guiApp.caretEnabled = false;
3522 if(!active && parent && parent.activeChild && parent.activeChild != this)
3523 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3529 if(!active && menuBar)
3532 menuBar.OnActivate(false, null, &goOn, true);
3533 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3538 Window aChild = activeChild;
3540 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3552 void ConsequentialMouseMove(bool kbMoving)
3556 if(kbMoving || !guiApp.windowMoving)
3560 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3562 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3564 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3565 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3571 bool IsDescendantOf(Window ancestor)
3574 for(window = this; window && window != ancestor; window = window.parent);
3575 return window == ancestor;
3578 bool IsSlaveOf(Window master)
3581 for(window = this; window && window != master; window = window.master);
3582 return window == master;
3585 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3589 if(this && !destroyed /*&& state != Hidden*/)
3591 Window swap = externalSwap;
3599 if(activateParent &&
3600 (parent.activeChild != this ||
3601 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3602 active && _isModal &&
3603 parent != master && master)
3604 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3610 bool real = parent.activeChild != this;
3612 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3613 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3614 !IsDescendantOf(guiApp.interimWindow) &&
3615 !IsSlaveOf(guiApp.interimWindow))
3617 Window interimWindow = guiApp.interimWindow;
3618 while(interimWindow && interimWindow != this)
3620 Window master = interimWindow.master;
3622 guiApp.interimWindow = null;
3623 if(guiApp.caretOwner)
3624 guiApp.caretOwner.UpdateCaret(false, false);
3626 incref interimWindow;
3627 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3632 delete interimWindow;
3633 interimWindow = (master && master.style.interim) ? master : null;
3638 guiApp.interimWindow = this;
3639 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3640 guiApp.caretEnabled = false;*/
3641 UpdateCaret(false, true);
3646 bool acquireInput = false;
3648 parent.activeChild &&
3649 parent.activeChild.state == maximized &&
3650 parent != guiApp.desktop;
3652 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3657 swap = parent.activeChild;
3658 if(swap && swap.destroyed) swap = null;
3659 if(swap && swap != this)
3662 if(!swap.PropagateActive(false, this, &goOn, true))
3663 swap = parent.activeChild;
3674 if(!parent || parent.activeChild != this || style.interim)
3677 result = PropagateActive(true, swap, &goOn, true);
3678 if(!result && !goOn)
3683 acquireInput = true;
3687 if(style.hasMaximize && parent != guiApp.desktop)
3690 SetState(maximized, false, 0);
3691 else if(state != maximized)
3694 for(child = parent.children.first; child; child = child.next)
3696 if(this != child && child.state == maximized)
3697 child.SetState(normal, false, 0);
3704 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3706 Window previous = parent.activeClient;
3707 parent.activeChild = this;
3708 if(!style.nonClient /*&& style.isActiveClient*/)
3712 if(style.isActiveClient)
3713 parent.activeClient = this;
3714 // Moved UpdateActiveDocument inside hidden check
3715 // To prevent activating previous window while creating a new one
3716 // (It was messing up the privateModule in the CodeEditor)
3717 parent.UpdateActiveDocument(previous);
3723 //if(!style.isRemote)
3725 if(rootWindow != this)
3727 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3728 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3730 else if(!guiApp.fullScreenMode)
3732 Window modalRoot = FindModal();
3733 if(!modalRoot) modalRoot = this;
3734 if(!modalRoot.isForegroundWindow)
3736 modalRoot.isForegroundWindow = true;
3737 // To check : Why is parent null?
3738 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3740 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3742 modalRoot.isForegroundWindow = false;
3747 if(result && real && (!style.inactive || moveInactive) && parent)
3749 Window last = parent.children.last;
3751 if(!style.stayOnTop)
3752 for(; last && last.style.stayOnTop; last = last.prev);
3754 parent.children.Move(this, last);
3756 // Definitely don't want that: why not?
3760 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3766 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3773 parent.activeChild = null;
3774 if(!style.nonClient /*&& style.isActiveClient*/)
3776 Window previous = parent.activeClient;
3777 if(style.isActiveClient)
3778 parent.activeClient = null;
3779 parent.UpdateActiveDocument(previous);
3783 if(this == guiApp.interimWindow)
3785 guiApp.interimWindow = null;
3786 if(guiApp.caretOwner)
3787 guiApp.caretOwner.UpdateCaret(false, false);
3789 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3796 if(!active || !swap)
3797 UpdateDecorations();
3799 swap.UpdateDecorations();
3801 if(active && rootWindow != this)
3802 ConsequentialMouseMove(false);
3809 // --- Input Messages ---
3810 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3812 static bool reEntrancy = false;
3813 if(reEntrancy) return;
3817 guiApp.cursorUpdate = true;
3818 if(guiApp.windowScrolling && !consequential)
3820 guiApp.windowScrolling.SetScrollPosition(
3821 (guiApp.windowScrolling.sbh) ?
3822 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3823 (guiApp.windowScrolling.sbv) ?
3824 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3826 if(guiApp.windowMoving)
3828 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3830 Window window = guiApp.windowMoving;
3832 int w = window.size.w;
3833 int h = window.size.h;
3838 rx = mouseX - guiApp.windowMovingStart.x;
3839 ry = mouseY - guiApp.windowMovingStart.y;
3842 window.GetDecorationsSize(&ew, &eh);
3844 if(guiApp.windowIsResizing)
3846 x = window.scrolledPos.x;
3847 y = window.scrolledPos.y;
3851 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3852 rx = guiApp.windowResizingBefore.w - aw;
3853 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3854 w = guiApp.windowResizingBefore.w - rx;
3858 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3859 ry = guiApp.windowResizingBefore.h - ah;
3860 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3861 ry = Max(ry, -guiApp.windowMovingBefore.y);
3862 h = guiApp.windowResizingBefore.h - ry;
3864 if(guiApp.resizeEndX)
3866 w = guiApp.windowResizingBefore.w + rx;
3869 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3877 w = Max(w, window.minSize.w);
3878 h = Max(h, window.minSize.h);
3879 w = Min(w, window.maxSize.w);
3880 h = Min(h, window.maxSize.h);
3882 if(!window.OnResizing(&w, &h))
3884 w = window.clientSize.w;
3885 h = window.clientSize.h;
3888 w = Max(w, window.skinMinSize.w);
3889 h = Max(h, window.skinMinSize.h);
3896 SNAPDOWN(w, textCellW);
3897 SNAPDOWN(h, textCellH);
3902 aw = Max(w,window.skinMinSize.w);
3903 rx = guiApp.windowResizingBefore.w - aw;
3904 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3905 w = guiApp.windowResizingBefore.w - rx;
3909 ah = Max(h,window.skinMinSize.h);
3910 ry = guiApp.windowResizingBefore.h - ah;
3911 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3912 ry = Max(ry, -guiApp.windowMovingBefore.y);
3913 h = guiApp.windowResizingBefore.h - ry;
3918 if(!guiApp.windowIsResizing || guiApp.resizeX)
3919 x = guiApp.windowMovingBefore.x + rx;
3920 if(!guiApp.windowIsResizing || guiApp.resizeY)
3921 y = guiApp.windowMovingBefore.y + ry;
3923 if(!guiApp.windowIsResizing)
3926 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3928 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3929 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3930 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3931 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3935 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3936 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3942 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3944 if(!window.OnMoving(&x, &y, w, h))
3946 x = window.scrolledPos.x;
3947 y = window.scrolledPos.y;
3953 SNAPDOWN(x, textCellW);
3954 SNAPDOWN(y, textCellH);
3957 if(!window.style.nonClient)
3959 if(!window.style.fixed /*|| window.style.isDocument*/)
3961 if(!window.style.dontScrollHorz)
3962 x += window.parent.scroll.x;
3963 if(!window.style.dontScrollVert)
3964 y += window.parent.scroll.y;
3968 // Break the anchors for moveable/resizable windows
3969 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3970 if(window.style.fixed)
3972 if(window.state == normal)
3974 window.normalAnchor = Anchor { left = x, top = y };
3975 window.normalSizeAnchor = SizeAnchor { { w, h } };
3976 window.anchored = false;
3980 window.stateAnchor = Anchor { left = x, top = y };
3981 window.stateSizeAnchor = SizeAnchor { { w, h } };
3983 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3984 // TOCHECK: Investigate why the following only redraws the scrollbars
3985 //window.Position(x, y, w, h, false, true, true, true, false, true);
3987 guiApp.movingLast.x = mouseX;
3988 guiApp.movingLast.y = mouseY;
3994 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3997 bool wasMoving = guiApp.windowMoving ? true : false;
3998 bool wasScrolling = guiApp.windowScrolling ? true : false;
4000 while(result && w != this)
4002 Window msgWindow = GetAtPosition(x,y, false, true, w);
4003 Window trueWindow = GetAtPosition(x,y, false, false, w);
4004 bool windowDragged = false;
4009 window = (w && !w.disabled) ? w : null;
4011 if(trueWindow) incref trueWindow;
4013 if(consequential) mods->isSideEffect = true;
4015 UpdateMouseMove(x, y, consequential);
4017 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4019 if(!guiApp.windowCaptured.isEnabled)
4020 guiApp.windowCaptured.ReleaseCapture();
4022 window = guiApp.windowCaptured;
4025 if(trueWindow && activate &&
4026 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4027 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4028 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4029 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4031 if(mods->alt && !mods->ctrl && !mods->shift)
4033 Window moved = trueWindow;
4034 for(moved = trueWindow; moved; moved = moved.parent)
4035 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4040 windowDragged = true;
4042 // Cancel the ALT menu toggling...
4043 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4048 if(window && activate &&
4049 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4050 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4051 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4052 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4054 Window modalWindow = window.FindModal();
4056 /*if(mods->alt && !mods->shift && !mods->ctrl)
4058 Window moved = window;
4059 for(moved = window; moved; moved = moved.parent)
4060 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4065 windowDragged = true;
4067 // Cancel the ALT menu toggling...
4068 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4074 Window activateWindow = modalWindow ? modalWindow : window;
4075 if(activateWindow && !activateWindow.isRemote)
4077 bool doActivation = true;
4078 //bool needToDoActivation = false;
4079 Window check = activateWindow;
4081 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4083 if(!check.style.inactive)
4085 //needToDoActivation = true;
4087 doActivation = false;
4092 if(!needToDoActivation)
4093 doActivation = false;
4096 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4097 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4099 // Let the OnLeftButtonDown do the activating instead
4100 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4108 incref activateWindow;
4109 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4111 delete activateWindow;
4115 if(activateWindow._refCount == 1)
4117 delete activateWindow;
4121 delete activateWindow;
4122 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4125 mods->isActivate = true;
4129 if(!modalWindow && window && !window.destroyed)
4131 if(!guiApp.windowCaptured || windowDragged)
4133 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4135 bool moving = ((window.state != maximized &&
4136 window.IsMouseMoving(
4137 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4138 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4140 if(!moving && window.IsMouseResizing(
4141 x - window.absPosition.x,
4142 y - window.absPosition.y,
4143 window.size.w, window.size.h,
4144 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4146 guiApp.windowIsResizing = true;
4147 guiApp.windowResizingBefore.w = window.size.w;
4148 guiApp.windowResizingBefore.h = window.size.h;
4150 if(guiApp.windowIsResizing || windowDragged || moving)
4153 guiApp.windowMoving = window;
4154 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4155 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4156 guiApp.windowMovingBefore.x = window.position.x;//s;
4157 guiApp.windowMovingBefore.y = window.position.y;//s;
4158 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4159 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4162 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4164 if(window.style.fixed &&
4166 window.IsMouseMoving(
4167 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4169 window.ShowSysMenu(x, y);
4173 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4175 if(window.sbv || window.sbh)
4178 guiApp.windowScrolling = window;
4179 guiApp.windowScrollingStart.x = x;
4180 guiApp.windowScrollingStart.y = y;
4181 guiApp.windowScrollingBefore.x = window.scroll.x;
4182 guiApp.windowScrollingBefore.y = window.scroll.y;
4185 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4187 if(window.style.hasMaximize &&
4188 window.IsMouseMoving(
4189 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4192 (window.state == maximized) ? normal : maximized, false, *mods);
4200 if(guiApp.windowMoving)
4202 if(guiApp.windowMoving.parent)
4204 if(guiApp.windowMoving.style.nonClient)
4205 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4207 guiApp.windowMoving.parent.SetMouseRangeToClient();
4211 window.UpdateDecorations();
4214 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4216 // Log("\n*** LEFT BUTTON UP ***\n");
4217 if(guiApp.windowMoving)
4218 guiApp.windowMoving.StopMoving();
4220 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4222 if(guiApp.windowScrolling)
4224 Window windowScrolling = guiApp.windowScrolling;
4225 guiApp.windowScrolling = null;
4226 windowScrolling.ReleaseCapture();
4230 if(!result || (window && window.destroyed)) window = null;
4232 if(window && window.FindModal())
4235 if(trueWindow && trueWindow.FindModal())
4243 msgWindow = GetAtPosition(x,y, true, false);
4245 msgWindow.SelectMouseCursor();
4248 if(guiApp.windowCaptured || trueWindow)
4250 Window prevWindow = guiApp.prevWindow;
4251 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4253 guiApp.prevWindow.mouseInside = false;
4254 guiApp.prevWindow = null;
4256 // Eventually fix this not to include captured?
4257 if(!trueWindow.IsDescendantOf(prevWindow) && !prevWindow.OnMouseLeave(*mods))
4260 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4262 Box box = trueWindow.box;
4263 box.left += trueWindow.absPosition.x;
4264 box.right += trueWindow.absPosition.x;
4265 box.top += trueWindow.absPosition.y;
4266 box.bottom += trueWindow.absPosition.y;
4268 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4270 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4271 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4273 overX = Max(Min(overX, 32767),-32768);
4274 overY = Max(Min(overY, 32767),-32768);
4276 trueWindow.mouseInside = true;
4277 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4281 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4282 guiApp.prevWindow = trueWindow;
4284 guiApp.prevWindow = null;
4286 SelectMouseCursor();
4288 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4290 int clientX = x - (window.absPosition.x + window.clientStart.x);
4291 int clientY = y - (window.absPosition.y + window.clientStart.y);
4293 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4295 clientX = Max(Min(clientX, 32767),-32768);
4296 clientY = Max(Min(clientY, 32767),-32768);
4298 MouseMethod = (void *)window._vTbl[method];
4300 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4303 if(!MouseMethod(window, clientX, clientY, *mods))
4310 if(result && w && w.clickThrough && w.parent)
4315 if(!result || !w || !w.clickThrough)
4322 // --- Mouse cursor management ---
4324 bool KeyMessage(uint method, Key key, unichar character)
4329 if(guiApp.interimWindow)
4330 this = guiApp.interimWindow;
4333 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4337 if(!style.inactive || rootWindow != this)
4339 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4340 Window modalWindow = FindModal();
4341 Window interimMaster = master ? master.rootWindow : null;
4345 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4346 status = OnSysKeyDown(key, character);
4347 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4348 status = OnSysKeyHit(key, character);
4349 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4350 status = OnSysKeyUp(key, character);
4357 // Process Key Message for Internal UI Keyboard actions
4358 if(status && !destroyed && menuBar && state != minimized)
4361 if((SmartKey)key != alt)
4362 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4365 SmartKey sk = (SmartKey) key;
4366 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4368 status = menuBar.KeyMessage(method, key, character);
4373 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4374 menuBar.OnKeyHit(escape, 0);
4376 if(!menuBar.focus && guiApp.caretOwner)
4377 guiApp.caretOwner.UpdateCaret(true, false);
4380 if(!destroyed && status)
4382 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4386 case left: case up: case right: case down:
4387 if(guiApp.windowMoving == this)
4390 int w = guiApp.windowMoving.size.w;
4391 int h = guiApp.windowMoving.size.h;
4392 int x = guiApp.windowMoving.scrolledPos.x;
4393 int y = guiApp.windowMoving.scrolledPos.y;
4397 if(key == down || key == up)
4398 step = Max(step, textCellH);
4400 step = Max(step, textCellW);
4403 if(guiApp.windowIsResizing)
4407 case left: w-=step; break;
4408 case right: w+=step; break;
4409 case up: h-=step; break;
4410 case down: h+=step; break;
4417 case left: x-=step; break;
4418 case right: x+=step; break;
4419 case up: y-=step; break;
4420 case down: y+=step; break;
4424 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4425 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4427 if(!guiApp.windowIsResizing || guiApp.resizeX)
4428 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4430 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4432 if(!guiApp.windowIsResizing || guiApp.resizeY)
4433 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4435 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4437 guiApp.interfaceDriver.SetMousePosition(x, y);
4438 ConsequentialMouseMove(true);
4446 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4448 guiApp.windowMoving.StopMoving();
4449 ConsequentialMouseMove(false);
4457 ShowSysMenu(absPosition.x, absPosition.y);
4465 if(!destroyed && status && state != minimized)
4467 // Process all the way down the children
4468 if(activeChild && !activeChild.disabled)
4470 status = activeChild.KeyMessage(method, key, character);
4472 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4473 key.code != left && key.code != right && key.code != up && key.code != down)
4475 status = activeClient.KeyMessage(method, key, character);
4479 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4481 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4482 // && defaultControl != activeChild)
4484 delete previousActive;
4485 previousActive = activeChild;
4486 if(previousActive) incref previousActive;
4488 ConsequentialMouseMove(false);
4489 if((defaultControl.active ||
4490 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4491 defaultControl.KeyMessage(method, defaultKey, character);
4497 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4499 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4506 ShowSysMenu(absPosition.x, absPosition.y);
4513 if(this != guiApp.desktop)
4515 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4517 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4519 MenuMoveOrSize(key.shift, true);
4523 else if(guiApp.windowMoving)
4525 guiApp.windowMoving.StopMoving();
4526 ConsequentialMouseMove(false);
4534 if(!destroyed && status && state != minimized)
4536 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4540 case tab: case shiftTab:
4542 Window cycleParent = this;
4543 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4544 cycleParent = master.parent;
4546 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4548 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4550 Window child = cycleParent.activeChild;
4552 // Scroll the window to include the active control
4554 if(cycleParent.sbh && !child.style.dontScrollHorz)
4556 if(child.scrolledPos.x < 0)
4557 cycleParent.sbh.Action(Position,
4558 cycleParent.scroll.x + child.scrolledPos.x, 0);
4559 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4560 cycleParent.sbh.Action(Position,
4561 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4563 if(cycleParent.sbv && !child.style.dontScrollVert)
4565 if(child.scrolledPos.y < 0)
4566 cycleParent.sbv.Action(Position,
4567 cycleParent.scroll.y + child.scrolledPos.y, 0);
4568 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4569 cycleParent.sbv.Action(Position,
4570 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4573 cycleParent.ConsequentialMouseMove(false);
4579 case f6: case shiftF6:
4580 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4582 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4583 if(parent == guiApp.desktop)
4584 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4594 if(CycleChildren(key.shift, true, false, true))
4602 // mIRC Style Window Shortcuts
4603 case alt1: case alt2: case alt3: case alt4: case alt5:
4604 case alt6: case alt7: case alt8: case alt9: case alt0:
4609 for(document = children.first; document; document = document.next)
4611 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4613 if(document == activeChild)
4615 if(document.state == minimized)
4616 document.SetState(normal, false, key);
4619 document.SetState(minimized, false, key);
4620 CycleChildren(false, true, false);
4625 if(activeChild.state == maximized && document.style.hasMaximize)
4626 document.SetState(maximized, false, key);
4627 else if(document.state == minimized)
4628 document.SetState(normal, false, key);
4629 document.Activate();
4644 if(!destroyed && status)
4646 if(state == minimized)
4651 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4653 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4655 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4656 previousActive.ActivateEx(true, false, false, true, null, null);
4657 delete previousActive;
4663 if(!destroyed && status)
4665 status = ProcessHotKeys(method, key, character);
4667 if(!destroyed && status && !modalWindow && state != minimized)
4670 status = KeyMethod(this, key, character);
4671 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4672 status = OnKeyHit(key, character);
4673 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4675 bool result = false;
4678 case ctrlUp: case ctrlDown:
4679 if(sbv && !guiApp.windowScrolling)
4680 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4682 case wheelUp: case wheelDown:
4683 if(sbv && !guiApp.windowScrolling)
4685 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4686 // Do we want to do a consequential move regardless of result in this case?
4687 ConsequentialMouseMove(false);
4690 case ctrlPageUp: case ctrlPageDown:
4691 if(sbh && !guiApp.windowScrolling)
4692 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4697 ConsequentialMouseMove(false);
4702 if(status && !destroyed && menuBar && state != minimized)
4703 status = menuBar.KeyMessage(method, key, character);
4705 if(style.interim && /*destroyed && */status && interimMaster)
4707 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4708 status = interimMaster.KeyMessage(method, key, character);
4715 bool ProcessHotKeys(uint method, Key key, unichar character)
4720 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4721 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4722 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4724 Window hotKeyWindow = hotKey.window;
4725 Window parent = hotKeyWindow.parent;
4726 Window prevActiveWindow = activeChild;
4727 // For when sys buttons are placed inside the menu bar
4728 if(parent && parent._class == class(PopupMenu))
4729 parent = parent.parent;
4731 // 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
4732 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4735 if(prevActiveWindow) incref prevActiveWindow;
4736 incref hotKeyWindow;
4737 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4738 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4741 delete hotKeyWindow;
4742 delete prevActiveWindow;
4746 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4747 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4748 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4750 // ********* WORKING ON THIS ***********
4751 if(prevActiveWindow && !guiApp.interimWindow)
4752 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4755 else if(hotKeyWindow.style.inactive)
4756 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4758 delete prevActiveWindow;
4759 delete hotKeyWindow;
4760 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4761 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4765 if(status && tabCycle)
4768 for(child = children.first; child; child = child.next)
4770 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4781 // --- Windows and graphics initialization / termination ---
4782 bool SetupRoot(void)
4786 // Setup relationship with outside world (bb root || !bb)
4787 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4788 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4792 tempExtents = new0 Extent[4];
4797 /*if(guiApp.fullScreenMode)
4798 rootWindow = guiApp.desktop;
4800 //rootWindow = parent.created ? parent.rootWindow : null;
4801 rootWindow = parent.rootWindow;
4804 against = &parent.box;
4806 against = &parent.clientArea;
4809 for(child = children.first; child; child = child.next)
4812 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4815 bool Setup(bool positionChildren)
4817 bool result = false;
4820 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4822 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4823 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4825 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4827 // This was here, is it really needed?
4828 //guiApp.interfaceDriver.ActivateRootWindow(this);
4832 displaySystem = DisplaySystem {};
4833 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4835 delete displaySystem;
4840 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4841 if(display.Create(displaySystem, windowHandle))
4848 // Sometimes icon does not show up on Windows XP if we set here...
4849 // guiApp.interfaceDriver.SetIcon(this, icon);
4851 else if(this != guiApp.desktop)
4853 display = rootWindow ? rootWindow.display : null;
4859 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4860 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4862 for(child = children.first; child; child = child.next)
4864 if(child.created && !child.Setup(false))
4870 bool SetupDisplay(void)
4872 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4873 if(is3D) return Window3D_SetupDisplay(this); else
4880 class_data void ** pureVTbl;
4882 bool LoadGraphics(bool creation, bool resetAnchors)
4884 bool result = false;
4885 bool success = false;
4887 WindowState stateBackup = state;
4889 if(((subclass(Window))_class).pureVTbl)
4891 if(_vTbl == _class._vTbl)
4893 _vTbl = ((subclass(Window))_class).pureVTbl;
4898 for(m = 0; m < _class.vTblSize; m++)
4900 if(_vTbl[m] == _class._vTbl[m])
4901 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4905 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4907 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4909 _vTbl = _class._vTbl;
4914 for(m = 0; m < _class.vTblSize; m++)
4916 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4917 _vTbl[m] = _class._vTbl[m];
4922 if(guiApp.fullScreenMode || this != guiApp.desktop)
4924 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4930 display.Lock(false);
4931 if(rootWindow == this)
4933 // Set Color Palette
4934 display.SetPalette(palette, true);
4938 if(guiApp.fullScreenMode && this == guiApp.desktop)
4943 for(c=0; c<SystemCursor::enumSize; c++)
4944 if(!guiApp.systemCursors[c].bitmap)
4946 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4947 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4948 if(guiApp.systemCursors[c].bitmapName)
4950 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4951 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4952 if(guiApp.systemCursors[c].bitmap)
4953 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4958 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4960 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4961 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4963 cursor.bitmap.paletteShades = cursor.paletteShades;
4967 guiApp.cursorUpdate = true;
4970 ConsequentialMouseMove(false);
4976 // Load Window Graphic Resources
4979 if(usedFont == setFont || usedFont == window.systemFont)
4980 RemoveResource(usedFont);
4983 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4986 RemoveResource(systemFont);
4989 RemoveResource(captionFont);
4991 for(ptr = resources.first; ptr; ptr = ptr.next)
4993 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4996 AddResource(setFont);
4998 AddResource(systemFont);
5000 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5007 //if(master && master.font)
5008 if(parent && parent.font)
5012 faceName = parent.font.faceName,
5013 size = parent.font.size,
5014 bold = parent.font.bold,
5015 italic = parent.font.italic,
5016 underline = parent.font.underline
5018 //font = parent.font;
5019 watch(parent) { font { } };
5022 font = guiApp.currentSkin.SystemFont();
5029 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5030 AddResource(captionFont);
5032 if(OnLoadGraphics())
5038 //SetScrollLineStep(sbStep.x, sbStep.y);
5040 if(this != guiApp.desktop)
5044 normalAnchor = anchor;
5045 normalSizeAnchor = sizeAnchor;
5048 // Break the anchors for moveable/resizable windows
5050 if(style.fixed && style.isDocument)
5052 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5064 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5065 stateSizeAnchor = SizeAnchor {};
5070 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5075 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5076 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5079 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5083 stateAnchor = normalAnchor;
5084 stateSizeAnchor = normalSizeAnchor;
5087 position = Point { };
5088 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5099 if(Position(x, y, w, h, true, false, true, true, true, true))
5101 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5104 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5121 success = result = true;
5124 if(!creation && result)
5126 // Load menu bar first because sys buttons are on it...
5129 if(!menuBar.LoadGraphics(false, resetAnchors))
5135 for(child = children.first; child; child = child.next)
5137 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5144 CreateSystemChildren();
5148 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5151 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5156 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5157 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5160 // Do this here to avoid problems on Windows
5161 if(stateBackup == maximized)
5162 property::state = maximized;
5166 void UnloadGraphics(bool destroyWindows)
5170 // Free children's graphics
5171 for(child = children.first; child; child = child.next)
5172 child.UnloadGraphics(destroyWindows);
5175 display.Lock(false);
5178 if(guiApp.fullScreenMode && this == guiApp.desktop)
5183 for(c=0; c<SystemCursor::enumSize; c++)
5184 if(guiApp.systemCursors[c].bitmap)
5185 delete guiApp.systemCursors[c].bitmap;
5187 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5188 delete cursor.bitmap;
5190 guiApp.cursorBackground.Free();
5193 if(display && display.displaySystem)
5197 for(ptr = resources.first; ptr; ptr = ptr.next)
5201 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5206 // Free window graphics
5209 // Free skin graphics
5210 if(rootWindow == this)
5212 DisplaySystem displaySystem = display.displaySystem;
5215 display.driverData = null;
5216 display.displaySystem = null;
5220 if(displaySystem && !displaySystem.numDisplays && !is3D)
5221 delete displaySystem;
5230 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5231 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5233 if(this == guiApp.desktop || parent == guiApp.desktop)
5235 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5236 guiApp.interfaceDriver.DestroyRootWindow(this);
5240 // --- Window Hiding ---
5242 void SetVisibility(bool state)
5244 bool visible = (style.hidden || !created) ? false : state;
5245 if(visible != this.visible)
5249 this.visible = visible;
5250 for(child = children.first; child; child = child.next)
5251 child.SetVisibility(visible);
5253 ConsequentialMouseMove(false);
5254 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5258 // --- Windows and graphics initialization / termination ---
5260 bool DisplayModeChanged(void)
5262 bool result = false;
5263 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5265 guiApp.modeSwitching = true;
5266 UnloadGraphics(false);
5268 if(LoadGraphics(false, false))
5270 guiApp.modeSwitching = false;
5275 // --- Window updates system ---
5277 void UpdateDirty(Box updateBox)
5279 if(!manageDisplay) { OnRedraw(null);return; }
5282 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5285 if(display.flags.flipping)
5288 rootWindow.UpdateDisplay();
5291 UpdateBackDisplay(updateBox);
5293 if(guiApp.fullScreenMode)
5295 guiApp.cursorUpdate = true;
5296 guiApp.PreserveAndDrawCursor();
5298 if(guiApp.fullScreenMode)
5299 guiApp.RestoreCursorBackground();
5305 // This function is strictly called as a result of system window activation
5306 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5309 Window interimMaster = null;
5310 Window interimWindow = guiApp.interimWindow;
5311 if(interimWindow && interimWindow.master)
5312 interimMaster = interimWindow.master.rootWindow;
5314 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5315 // SetState(normal, false, 0);
5316 SetState(lastState, false, 0);
5318 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5322 /* WTH is this doing here?
5323 while(swap && swap.activeChild)
5325 swap = swap.activeChild;
5328 // TESTING THIS BEFORE...
5329 if(interimWindow && this == interimMaster)
5333 // Window interimSwap = this;
5334 Window menuBar = this.menuBar;
5335 if(menuBar && interimWindow.master == menuBar)
5338 while(interimSwap && interimSwap.activeChild)
5339 interimSwap = interimSwap.activeChild;
5341 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5342 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5344 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5345 //result = ActivateEx(true, true, false, activateRoot, window, null);
5350 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5351 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5353 if(interimWindow == this && interimMaster && !active)
5355 while(interimMaster && interimMaster.interim && interimMaster.master)
5357 // printf("Going up one master %s\n", interimMaster._class.name);
5358 interimMaster = interimMaster.master.rootWindow;
5360 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5361 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5367 bool DestroyEx(int64 returnCode)
5370 Timer timer, nextTimer;
5372 OldLink prevOrder = null;
5373 Window client = null;
5375 if(parent) stopwatching(parent, font);
5377 // if(window.modalSlave) return false;
5378 if(destroyed || !created)
5385 OldLink slave = master.slaves.FindLink(this);
5386 master.slaves.Delete(slave);
5389 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5395 this.returnCode = (DialogResult)returnCode;
5397 AcquireInput(false);
5402 master.hotKeys.Delete(hotKey);
5406 if(guiApp.prevWindow == this)
5408 guiApp.prevWindow = null;
5411 if(guiApp.caretOwner == this)
5413 guiApp.interfaceDriver.SetCaret(0,0,0);
5414 UpdateCaret(false, true);
5415 guiApp.caretEnabled = false;
5420 parent.childrenCycle.Remove(cycle);
5424 OldLink tmpPrev = order.prev;
5425 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5426 prevOrder = tmpPrev;
5429 client = tmpPrev ? tmpPrev.data : null;
5430 if(client == this) { client = null; break; }
5431 if(client && (client.style.hidden || client.destroyed || !client.created))
5432 tmpPrev = client.order.prev;
5436 prevOrder = tmpPrev;
5441 // If this window can be an active client, make sure the next window we activate can also be one
5442 if(!style.nonClient && style.isActiveClient)
5444 tmpPrev = prevOrder;
5447 client = tmpPrev ? tmpPrev.data : null;
5448 if(client == this) { client = null; break; }
5449 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5450 tmpPrev = client.order.prev;
5454 prevOrder = tmpPrev;
5458 if(client && client.style.hidden) client = null;
5460 // parent.childrenOrder.Remove(order);
5463 if(parent && style.isActiveClient && visible)
5465 if(state == minimized) parent.numIcons--;
5466 parent.numPositions--;
5469 // TESTING THIS HERE!
5473 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5474 // to create a window inside a rootwindow that's being destroyed)
5475 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5477 if(master && !master.destroyed /*&&
5478 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5480 if(master.defaultControl == this)
5481 master.defaultControl = null;
5484 parent.OnChildAddedOrRemoved(this, true);
5485 if(parent && !parent.destroyed /*&&
5486 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5488 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5490 if(order && prevOrder && prevOrder.data != this && active)
5492 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5494 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5495 if(parent.activeClient == this)
5497 parent.activeClient = null;
5498 parent.UpdateActiveDocument(null);
5503 if(guiApp.interimWindow == this)
5506 PropagateActive(false, null, &goOn, true);
5510 //if(window.parent.activeChild == window)
5511 parent.activeChild = null;
5512 if(!style.nonClient /*&& style.isActiveClient*/)
5514 Window previous = parent.activeClient;
5515 if(style.isActiveClient)
5516 parent.activeClient = null;
5517 parent.UpdateActiveDocument(previous);
5522 else if(parent.activeClient == this)
5524 parent.activeClient = client;
5525 parent.UpdateActiveDocument(this);
5529 if(guiApp.interimWindow == this)
5531 guiApp.interimWindow = null;
5532 if(guiApp.caretOwner)
5534 Window desktop = guiApp.desktop;
5535 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5536 guiApp.caretOwner.UpdateCaret(false, false);
5541 if(_isModal && master && master.modalSlave == this)
5542 master.modalSlave = null;
5546 if(!guiApp.caretOwner && parent.caretSize)
5548 guiApp.caretOwner = parent;
5549 parent.UpdateCaret(false, false);
5550 parent.Update(null);
5553 // Why was this commented out?
5554 GetRidOfVirtualArea();
5560 dirtyArea.Free(null);
5561 dirtyBack.Free(null);
5562 scrollExtent.Free(null);
5564 /* ATTEMPTING TO MOVE THAT ABOVE
5573 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5574 for(;(child = window.children.first);)
5576 for(; child && (child.destroyed || !child.created); child = child.next);
5585 UnloadGraphics(true);
5588 delete previousActive;
5591 // statusBar = null;
5594 if(master && !master.destroyed)
5596 //master.NotifyDestroyed(this, this.returnCode);
5597 NotifyDestroyed(master, this, this.returnCode);
5600 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5602 nextTimer = timer.next;
5603 if(timer.window == this)
5605 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5606 // timer.window = null;
5612 if(this == guiApp.windowMoving)
5615 if(guiApp.windowCaptured == this)
5617 //guiApp.windowCaptured = null;
5619 if(rootWindow != this && rootWindow)
5620 rootWindow.ConsequentialMouseMove(false);
5628 //for(child = children.first; next = child ? child.next : null, child; child = next)
5629 for(;(child = children.first); )
5631 for(; child && (child.destroyed || !child.created); child = child.next);
5641 /* // MOVED THIS UP...
5644 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5645 for(;(child = window.children.first); )
5647 for(; child && (child.destroyed || !child.created); child = child.next);
5656 while((slave = slaves.first))
5658 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5660 ((Window)slave.data).DestroyEx(0);
5665 if(guiApp.caretOwner == this)
5666 guiApp.caretOwner = null;
5668 sysButtons[0] = null;
5669 sysButtons[1] = null;
5670 sysButtons[2] = null;
5673 if(rootWindow != this)
5675 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5678 box.left -= parent.clientStart.x;
5679 box.top -= parent.clientStart.y;
5680 box.right -= parent.clientStart.x;
5681 box.bottom -= parent.clientStart.y;
5683 if(parent) parent.Update(box);
5688 OldLink slave = master.slaves.FindVoid(this);
5689 master.slaves.Delete(slave);
5695 parent.children.Remove(this);
5700 //autoCreate = false;
5703 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5704 if(((subclass(Window))_class).pureVTbl)
5706 if(_vTbl == _class._vTbl)
5708 _vTbl = ((subclass(Window))_class).pureVTbl;
5713 for(m = 0; m < _class.vTblSize; m++)
5715 if(_vTbl[m] == _class._vTbl[m])
5716 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5725 void SetStateEx(WindowState newState, bool activate)
5728 WindowState prevState = state;
5732 if(prevState != newState)
5733 lastState = prevState;
5735 if(rootWindow != this || !nativeDecorations || !windowHandle)
5737 if(style.isActiveClient && !style.hidden && prevState == minimized)
5740 // This block used to be at the end of the function... moved it for flicker problem in X
5741 // ------------------------------------------------------
5745 stateAnchor = normalAnchor;
5746 stateSizeAnchor = normalSizeAnchor;
5749 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5750 stateSizeAnchor = SizeAnchor {};
5754 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5757 byte * idBuffer = new0 byte[size];
5759 for(child = parent.children.first; child; child = child.next)
5761 if(child != this && child.state == minimized)
5763 if(child.iconID > size - 2)
5765 idBuffer = renew0 idBuffer byte[size*2];
5766 memset(idBuffer + size, 0, size);
5769 idBuffer[child.iconID] = (byte)bool::true;
5772 for(c = 0; c<size; c++)
5777 if(style.isActiveClient && !style.hidden)
5780 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5781 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5785 // TOCHECK: Why was this here?
5786 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5787 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5788 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5790 Position(x, y, w, h, true, true, true, true, false, true);
5792 if(!style.inactive && !style.interim && this == parent.activeClient)
5793 parent.UpdateActiveDocument(null);
5796 CreateSystemChildren();
5797 // ------------------------------------------------------
5800 int GetPositionID(Window forChild)
5804 byte * idBuffer = new0 byte[size];
5807 for(child = children.first; child; child = child.next)
5809 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5811 if(child.positionID > size - 2)
5813 idBuffer = renew0 idBuffer byte[size*2];
5814 memset(idBuffer + size, 0, size);
5817 idBuffer[child.positionID] = (byte)bool::true;
5820 for(c = 0; c<size; c++)
5827 // --- Window related graphics ---
5829 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5831 palette = newPalette;
5832 if(rootWindow.display)
5833 rootWindow.display.SetPalette(palette, colorMatch);
5836 public bool AcquireInput(bool acquired)
5839 if(acquiredInput != acquired)
5841 if(active || (!visible && creationActivation == activate))
5842 result = AcquireInputEx(acquired);
5847 acquiredInput = acquired ? result : !result;
5852 void ListChildren(ListBox listBox)
5856 for(child = children.first; child; child = child.next)
5858 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5860 DataRow row = listBox.AddRow();
5861 row.tag = (int64)child;
5862 child.FigureCaption(caption);
5863 row.SetData(null, caption);
5868 void UpdateVisual(Box extent)
5870 if(guiApp.driver != null)
5872 if(guiApp.fullScreenMode && guiApp.desktop.display)
5874 guiApp.desktop.mutex.Wait();
5875 guiApp.desktop.display.Lock(true);
5878 if(guiApp.desktop.active)
5880 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5882 if(guiApp.desktop.display.flags.flipping)
5883 guiApp.desktop.Update(null);
5884 guiApp.desktop.UpdateDisplay();
5885 guiApp.cursorUpdate = true;
5887 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5889 guiApp.PreserveAndDrawCursor();
5890 // guiApp.desktop.display.ShowScreen();
5891 guiApp.cursorUpdate = false;
5892 guiApp.desktop.dirty = false;
5893 guiApp.RestoreCursorBackground();
5897 guiApp.desktop.display.Unlock();
5898 guiApp.desktop.mutex.Release();
5902 Window rootWindow = this.rootWindow;
5903 rootWindow.mutex.Wait();
5908 guiApp.SignalEvent();
5911 guiApp.waitMutex.Wait();
5912 guiApp.interfaceDriver.Lock(rootWindow);
5913 if(!rootWindow.style.hidden && rootWindow.dirty)
5915 if(rootWindow.display)
5917 rootWindow.UpdateDisplay();
5918 //rootWindow.display.ShowScreen(null);
5920 rootWindow.dirty = false;
5922 guiApp.interfaceDriver.Unlock(rootWindow);
5923 guiApp.waitMutex.Release();
5926 rootWindow.mutex.Release();
5931 void UnlockDisplay(void)
5933 guiApp.interfaceDriver.Unlock(rootWindow);
5936 void LockDisplay(void)
5938 guiApp.interfaceDriver.Lock(rootWindow);
5941 Surface GetSurface(Box box)
5943 return Redraw((box == null) ? this.box : box);
5946 void SetMousePosition(int x, int y)
5948 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5952 void IntegrationActivate(bool active)
5954 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5956 isForegroundWindow = true;
5957 ActivateEx(active, active, false, false, null, null);
5958 isForegroundWindow = false;
5963 Window QueryCapture(void)
5965 return guiApp.windowCaptured;
5968 int GetDocumentID(void)
5972 byte * idBuffer = new0 byte[size];
5975 for(child = children.first; child; child = child.next)
5977 // TO CHECK: Do we want a documentID when we already have a file name?
5978 if(child.style.isDocument && !child.fileName)
5980 if(child.documentID-1 > size - 2)
5982 idBuffer = renew0 idBuffer byte[size*2];
5983 memset(idBuffer + size, 0, size);
5986 idBuffer[child.documentID-1] = 1;
5989 for(c = 0; c<size; c++)
5997 void SetInitSize(Size size)
6000 sizeAnchor.size = size;
6001 normalSizeAnchor = sizeAnchor;
6003 // Break the anchors for moveable/resizable windows
6004 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6006 stateAnchor = normalAnchor;
6007 stateSizeAnchor = normalSizeAnchor;
6009 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6010 Position(x,y, w, h, true, true, true, true, false, true);
6014 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6016 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6018 guiApp.windowIsResizing = resize;
6019 guiApp.windowMoving = this;
6020 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6021 if(guiApp.windowIsResizing)
6023 guiApp.windowMovingStart.x += size.w - 1;
6024 guiApp.windowMovingStart.y += size.h - 1;
6026 guiApp.windowMovingBefore = scrolledPos;
6027 guiApp.windowResizingBefore = size;
6028 guiApp.windowMoving.UpdateDecorations();
6029 if(guiApp.windowIsResizing)
6030 guiApp.resizeEndX = guiApp.resizeEndY = true;
6032 if(setCursorPosition)
6033 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6037 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6038 guiApp.windowMovingStart.x += x - absPosition.x;
6039 guiApp.windowMovingStart.y += y - absPosition.y;
6042 if(guiApp.windowMoving)
6044 if(guiApp.windowMoving.style.nonClient)
6045 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6047 guiApp.windowMoving.parent.SetMouseRangeToClient();
6052 if(this == rootWindow)
6053 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6061 bool result = false;
6065 else if(guiApp && guiApp.driver != null)
6067 void * systemParent = null;
6068 OldLink slaveHolder;
6070 bool visible = !style.hidden;
6074 systemParent = parent;
6075 parent = guiApp.desktop;
6077 last = parent ? parent.children.last : null;
6079 if((parent && parent != guiApp.desktop && !parent.created) ||
6080 (master && master != guiApp.desktop && !master.created))
6084 stopwatching(parent, font);
6087 property::parent = guiApp.desktop;
6088 if(!master) master = parent;
6090 if(_isModal && master.modalSlave)
6091 property::master = master.modalSlave;
6095 parent.children.Remove(this);
6098 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6099 if(slaveHolder.data == this)
6101 master.slaves.Delete(slaveHolder);
6106 if(parent == guiApp.desktop && !mutex)
6109 if(style.isDocument)
6112 parent.numDocuments--;
6113 documentID = parent.GetDocumentID();
6116 if(!style.stayOnTop)
6117 for(; last && last.style.stayOnTop; last = last.prev);
6119 parent.children.Insert((last == this) ? null : last, this);
6120 //parent.children.Add(this);
6123 dispDriver = parent.dispDriver;
6126 master.modalSlave = this;
6128 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6133 master.slaves.Add(slaveHolder = OldLink { data = this });
6138 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6140 if(style.isDefault && !master.defaultControl)
6141 master.defaultControl = this;
6143 stateAnchor = normalAnchor = anchor;
6144 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6146 // TOCHECK: Why is this here?
6147 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6148 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6150 this.visible = false;
6151 style.hidden = true;
6154 // autoCreate = true;
6162 if(parent == guiApp.desktop)
6163 Log("LoadGraphics %s\n", caption);
6165 if(LoadGraphics(true, false))
6173 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6180 if(style.hasMenuBar /*&& menu*/)
6186 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6187 interim = false, inactive = true, nonClient = true, size.h = 24
6195 // Create the system buttons
6196 CreateSystemChildren();
6198 UpdateActiveDocument(null);
6200 if(style.isDocument)
6204 MenuItem item = menu.FindItem(MenuFileSave, 0);
6205 if(item) item.disabled = !modifiedDocument && fileName;
6210 if(parent == guiApp.desktop)
6211 Log("Preemptive SetState %s\n", caption);
6214 // Preemptive Set State to ensure proper anchoring
6215 SetStateEx(state, false);
6217 style.hidden = true;
6223 for(child = children.first; child; child = next)
6226 if(!child.created && (child.autoCreate || child.wasCreated))
6233 for(link = slaves.first; link; link = next)
6235 Window slave = link.data;
6237 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6240 // Things might have happened that invalidated 'next'...
6241 // Start over the search for slaves to create.
6242 // (Added this to fix crash with Stacker & Toolbar)
6243 next = slaves.first;
6252 if(parent == guiApp.desktop)
6253 Log("Real SetState %s\n", caption);
6256 if(isActiveClient && visible)
6258 parent.numPositions--;
6259 if(state == minimized) parent.numIcons--;
6262 parent.OnChildAddedOrRemoved(this, false);
6264 // Real set state & activate for proper display & activation
6265 property::visible = visible;
6266 // SetState(state & 0x00000003, true, 0);
6267 guiApp.interfaceDriver.SetIcon(this, icon);
6272 /*if(rootWindow == this)
6273 guiApp.interfaceDriver.ActivateRootWindow(this);
6275 if(creationActivation == activate)
6276 ActivateEx(true, false, true, true, null, null);
6277 else if(creationActivation == flash)
6282 rootWindow.ConsequentialMouseMove(false);
6293 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6299 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6301 //style.hidden = true; // !visible;
6302 style.hidden = !visible;
6303 if(master.modalSlave == this)
6304 master.modalSlave = null;
6311 void WriteCaption(Surface surface, int x, int y)
6314 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6317 void Update(Box region)
6323 rootWindow = this.rootWindow;
6325 // rootWindow.mutex.Wait();
6326 if(!destroyed && visible && display)
6331 // Testing this to avoid repetitve full update to take time...
6332 if(dirtyArea.count == 1)
6334 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6335 if(item.box.left <= box.left &&
6336 item.box.top <= box.top &&
6337 item.box.right >= box.right &&
6338 item.box.bottom >= box.bottom)
6340 rootWindow.dirty = true;
6345 if(display.flags.flipping && !rootWindow.dirty)
6347 if(this == rootWindow)
6351 rootWindow.Update(null);
6356 rootWindow.dirty = true;
6361 realBox.left += clientStart.x;
6362 realBox.top += clientStart.y;
6363 realBox.right += clientStart.x;
6364 realBox.bottom += clientStart.y;
6370 if(realBox.right >= realBox.left &&
6371 realBox.bottom >= realBox.top)
6373 // if(!rootWindow.fullRender)
6374 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6376 for(child = children.first; child; child = child.next)
6381 box.left -= child.absPosition.x - absPosition.x;
6382 box.top -= child.absPosition.y - absPosition.y;
6383 box.right -= child.absPosition.x - absPosition.x;
6384 box.bottom -= child.absPosition.y - absPosition.y;
6385 if(box.right >= child.box.left && box.left <= child.box.right &&
6386 box.bottom >= child.box.top && box.top <= child.box.bottom)
6388 box.left -= child.clientStart.x;
6389 box.top -= child.clientStart.y;
6390 box.right -= child.clientStart.x;
6391 box.bottom -= child.clientStart.y;
6397 realBox.left += absPosition.x - rootWindow.absPosition.x;
6398 realBox.top += absPosition.y - rootWindow.absPosition.y;
6399 realBox.right += absPosition.x - rootWindow.absPosition.x;
6400 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6401 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6404 else if(this == guiApp.desktop)
6407 for(window = children.first; window; window = window.next)
6413 Box childBox = region;
6415 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6416 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6417 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6418 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6420 window.Update(childBox);
6423 window.Update(null);
6428 // rootWindow.mutex.Release();
6435 if(guiApp.windowCaptured != this)
6437 if(guiApp.windowCaptured)
6441 //Logf("Captured %s (%s)\n", caption, class.name);
6442 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6443 guiApp.windowCaptured = this;
6449 bool Destroy(int64 code)
6454 if(!destroyed && !CloseConfirmation(false)) return false;
6458 // TOCHECK: Should autoCreate be set to false here?
6469 void Move(int x, int y, int w, int h)
6471 normalAnchor = Anchor { left = x, top = y };
6472 normalSizeAnchor = SizeAnchor { size = { w, h } };
6474 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6476 if(destroyed) return;
6478 stateAnchor = normalAnchor;
6479 stateSizeAnchor = normalSizeAnchor;
6481 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6482 Position(x,y, w, h, true, true, true, true, false, true);
6486 DialogResult Modal(void)
6492 // FIXES MEMORY LEAK IF Create() FAILED
6498 void SetScrollArea(int width, int height, bool snapToStep)
6500 bool resize = false;
6503 int stepX = sbStep.x, stepY = sbStep.y;
6504 // Needed to make snapped down position match the skin's check of client area
6505 // against realvirtual
6508 SNAPDOWN(stepX, textCellW);
6509 SNAPDOWN(stepY, textCellH);
6510 stepX = Max(stepX, textCellW);
6511 stepY = Max(stepY, textCellH);
6513 if(scrollFlags.snapX)
6514 SNAPUP(width, stepX);
6515 if(scrollFlags.snapY)
6516 SNAPUP(height, stepY);
6519 reqScrollArea.w = width;
6520 reqScrollArea.h = height;
6521 noAutoScrollArea = (width > 0 || height > 0);
6523 UpdateScrollBars(true, true);
6526 void SetScrollPosition(int x, int y)
6529 sbh.Action(setPosition, x, 0);
6533 int seen = clientSize.w, total = reqScrollArea.w;
6535 if(scrollFlags.snapX)
6536 SNAPDOWN(seen, sbStep.x);
6538 if(!total) total = seen;
6539 range = total - seen + 1;
6540 range = Max(range, 1);
6542 if(x >= range) x = range - 1;
6544 if(scrollFlags.snapX)
6545 SNAPUP(x, sbStep.x);
6548 OnHScroll(setPosition, x, 0);
6552 SNAPDOWN(x, textCellW);
6558 sbv.Action(setPosition, y, 0);
6562 int seen = clientSize.h, total = reqScrollArea.h;
6565 if(scrollFlags.snapY)
6566 SNAPDOWN(seen, sbStep.y);
6568 if(!total) total = seen;
6569 range = total - seen + 1;
6570 range = Max(range, 1);
6572 if(y >= range) y = range - 1;
6574 if(scrollFlags.snapY)
6575 SNAPUP(y, sbStep.y);
6578 OnVScroll(setPosition, y, 0);
6581 SNAPDOWN(y, textCellH);
6586 UpdateCaret(false, false);
6589 void SetScrollLineStep(int stepX, int stepY)
6595 SNAPDOWN(stepX, textCellW);
6596 SNAPDOWN(stepY, textCellH);
6597 stepX = Max(stepX, textCellW);
6598 stepY = Max(stepY, textCellH);
6601 sbh.lineStep = stepX;
6603 sbv.lineStep = stepY;
6606 void SetState(WindowState newState, bool activate, Modifiers mods)
6610 if(state == newState || OnStateChange(newState, mods))
6612 WindowState prevState = state;
6616 // This used to be at the end of the brackets... moved for X, testing...
6617 // This has the effect of activating the window through the system...
6618 if(rootWindow == this)
6619 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6621 SetStateEx(newState, activate);
6623 if(rootWindow == this && !rootWindow.nativeDecorations)
6625 int x = position.x, y = position.y;
6628 x -= guiApp.desktop.absPosition.x;
6629 y -= guiApp.desktop.absPosition.y;
6631 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6635 //state = prevState;
6637 if(state != maximized && style.hasMaximize)
6640 for(child = parent.children.first; child; child = child.next)
6642 if(child != this && child.state == maximized)
6643 child.SetStateEx(normal, false);
6647 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6648 parent.UpdateScrollBars(true, true);
6651 // Do we really need this stuff here?
6652 // Shouldn't the Activate stuff take care of it?
6653 if(parent.rootWindow == parent && style)
6656 parent.FigureCaption(caption);
6657 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6658 parent.UpdateDecorations();
6662 rootWindow.ConsequentialMouseMove(false);
6669 BitmapResource GetIcon(SkinBitmap iconID)
6671 return guiApp.currentSkin.GetBitmap(iconID);
6674 void SetMouseRange(Box range)
6676 if(range || guiApp.fullScreenMode)
6681 clip.left = range.left + absPosition.x + clientStart.x;
6682 clip.top = range.top + absPosition.y + clientStart.y;
6683 clip.right = range.right + absPosition.x + clientStart.x;
6684 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6688 clip.left = guiApp.desktop.box.left;
6689 clip.top = guiApp.desktop.box.top;
6690 clip.right = guiApp.desktop.box.right;
6691 clip.bottom = guiApp.desktop.box.bottom;
6693 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6696 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6699 void SetMouseRangeToClient(void)
6701 if(guiApp.fullScreenMode || this != guiApp.desktop)
6703 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6704 box.Clip(clientArea);
6708 SetMouseRange(null);
6711 void SetMouseRangeToWindow(void)
6713 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6714 if(this == guiApp.desktop)
6715 SetMouseRangeToClient();
6720 // x, y: Desktop Coordinates
6721 void ShowSysMenu(int x, int y)
6724 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6727 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6728 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6732 menu, $"Move", m, NotifySelect = MenuWindowMove,
6733 disabled = !style.fixed || state == maximized
6737 menu, $"Size", s, NotifySelect = MenuWindowSize,
6738 disabled = !style.sizable || state != normal
6742 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6743 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6747 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6748 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6752 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6753 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6755 MenuDivider { menu };
6758 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6759 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6761 windowMenu.Create();
6766 ActivateEx(true, true, true, true, null, null);
6769 void MakeActive(void)
6771 ActivateEx(true, false, true, false, null, null);
6774 void SoftActivate(void)
6776 if(guiApp.desktop.active)
6782 void Deactivate(void)
6784 ActivateEx(false, true, true, true, null, null);
6789 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6792 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6794 bool result = false;
6795 if(activeChild && activeChild.cycle)
6797 Window modalWindow, child = activeChild;
6798 if(!clientOnly /*&& parent.tabCycle*/)
6800 Window next = child;
6803 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6807 if(parent && parent.CycleChildren(backward, false, true, true))
6815 next = next.cycle.prev.data;
6817 next = next.cycle.next.data;
6818 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6823 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6824 parent.tabCycle && parent.CycleChildren(backward, false, false))
6828 if(tabCycleOnly && !tabCycle) return false;
6835 child = child.cycle.prev.data;
6837 child = child.cycle.next.data;
6838 if(child == child.parent.activeChild)
6840 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6843 modalWindow = child.FindModal();
6846 // Scroll the window to include the active control
6847 if(sbh && !child.style.dontScrollHorz)
6849 if(child.scrolledPos.x < 0)
6850 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6851 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6852 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6854 if(sbv && !child.style.dontScrollVert)
6856 if(child.scrolledPos.y < 0)
6857 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6858 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6859 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6863 child = modalWindow ? modalWindow : child;
6864 child.ActivateEx(true, true, true, true, null, null);
6865 if(child.tabCycle && child.childrenCycle.first)
6866 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6874 ConsequentialMouseMove(false);
6878 void AddResource(Resource resource)
6882 ResPtr ptr { resource = resource };
6886 // Load Graphics here if window is created already
6887 if(/*created && */display)
6889 display.Lock(false);
6890 ptr.loaded = display.displaySystem.LoadResource(resource);
6894 // Temporary hack to load font right away for listbox in dropbox ...
6895 else if(master && master.display)
6897 master.display.Lock(false);
6898 master.display.displaySystem.LoadResource(resource);
6899 master.display.Unlock();
6905 void RemoveResource(Resource resource)
6910 for(ptr = resources.first; ptr; ptr = ptr.next)
6912 if(ptr.resource == resource)
6918 // Unload Graphics here if window is created already
6919 if(/*created && */display)
6923 display.Lock(false);
6924 display.displaySystem.UnloadResource(resource, ptr.loaded);
6930 resources.Delete(ptr);
6935 void SetCaret(int x, int y, int size)
6942 if(active && !style.interim)
6944 if(visible || !guiApp.caretOwner)
6945 guiApp.caretOwner = size ? this : null;
6947 UpdateCaret(false, false);
6950 guiApp.interfaceDriver.SetCaret(0,0,0);
6951 UpdateCaret(false, true);
6952 guiApp.caretEnabled = false;
6955 else if(style.inactive && active)
6957 guiApp.interfaceDriver.SetCaret(0,0,0);
6958 UpdateCaret(false, true);
6959 guiApp.caretEnabled = false;
6964 void Scroll(int x, int y)
6966 bool opaque = !style.drawBehind || background.a;
6967 if(opaque && display && display.flags.scrolling)
6969 Box box = clientArea;
6970 box.left += clientStart.x;
6971 box.top += clientStart.y;
6972 box.right += clientStart.x;
6973 box.bottom += clientStart.y;
6975 //scrollExtent.Free(null);
6976 scrollExtent.AddBox(box);
6977 scrolledArea.x += x;
6978 scrolledArea.y += y;
6980 //scrollExtent.Free();
6981 //scrollExtent.AddBox(clientArea);
6982 //scrollExtent.Offset(clientStart.x, clientStart.y);
6983 //scrolledArea.x = x;
6984 //scrolledArea.y = y;
6990 rootWindow.dirty = true;
6993 void ReleaseCapture()
6995 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6997 Window oldCaptured = guiApp.windowCaptured;
6998 guiApp.windowCaptured = null;
6999 guiApp.prevWindow = null;
7002 //guiApp.Log("Released Capture\n");
7004 guiApp.interfaceDriver.SetMouseCapture(null);
7006 //oldCaptured.OnMouseCaptureLost();
7009 oldCaptured.ConsequentialMouseMove(false);
7014 private void _SetCaption(char * format, va_list args)
7021 char caption[MAX_F_STRING];
7022 vsnprintf(caption, sizeof(caption), format, args);
7023 caption[sizeof(caption)-1] = 0;
7025 this.caption = CopyString(caption);
7030 firewatchers caption;
7034 /*deprecated*/ void SetText(char * format, ...)
7037 va_start(args, format);
7038 _SetCaption(format, args);
7042 void SetCaption(char * format, ...)
7045 va_start(args, format);
7046 _SetCaption(format, args);
7050 bool Grab(Bitmap bitmap, Box box, bool decorations)
7052 bool result = false;
7053 if(display || this == guiApp.desktop)
7055 Box clip = {MININT, MININT, MAXINT, MAXINT};
7061 clip.Clip(clientArea);
7063 clip.Clip(this.box);
7065 if(rootWindow != this)
7067 clip.left += absPosition.y;
7068 clip.top += absPosition.y;
7069 clip.right += absPosition.x;
7070 clip.bottom += absPosition.y;
7073 clip.left += decorations ? 0 : clientStart.x;
7074 clip.top += decorations ? 0 : clientStart.y;
7075 clip.right += decorations ? 0 : clientStart.x;
7076 clip.bottom += decorations ? 0 : clientStart.y;
7078 if(display && display.flags.flipping)
7080 rootWindow.Update(null);
7081 rootWindow.UpdateDisplay();
7088 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7089 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7093 result = display.Grab(bitmap, clip.left, clip.top,
7094 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7096 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7098 if(!bitmap.Convert(null, pixelFormat888, null))
7105 void GetMousePosition(int * x, int * y)
7107 int mouseX = 0, mouseY = 0;
7108 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7111 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7112 if(this != guiApp.desktop)
7114 mouseX -= absPosition.x + clientStart.x;
7115 mouseY -= absPosition.y + clientStart.y;
7122 DialogResult DoModal()
7124 DialogResult returnCode = 0;
7125 int terminated = terminateX;
7128 while(!destroyed && guiApp.driver != null)
7130 if(terminateX != terminated)
7132 terminated = terminateX;
7133 guiApp.desktop.Destroy(0);
7134 if(guiApp.desktop.created)
7137 //printf("Resetting terminate X to 0\n");
7143 guiApp.UpdateDisplay();
7144 if(!guiApp.ProcessInput(false))
7147 returnCode = this.returnCode;
7160 return !destroyed && guiApp.driver != null && terminateX < 2;
7163 DialogResult DoModalEnd()
7165 DialogResult returnCode = this.returnCode;
7170 // --- Window manipulation ---
7171 /*bool GetDisabled()
7173 bool disabled = this.disabled;
7175 for(window = this; (window = window.master); )
7186 // --- Mouse Manipulation ---
7187 void GetNCMousePosition(int * x, int * y)
7189 GetMousePosition(x, y);
7190 if(x) *x += clientStart.x;
7191 if(y) *y += clientStart.y;
7194 // --- Carets manipulation ---
7195 void GetCaretPosition(Point caretPos)
7197 caretPos = this.caretPos;
7200 int GetCaretSize(void)
7205 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7211 bool CloseConfirmation(bool parentClosing)
7224 if(!OnClose(parentClosing))
7227 // If you want to skip this, simply set modifiedDocument to false in OnClose
7228 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7230 DialogResult dialogRes;
7233 sprintf(message, $"Save changes to %s?", fileName);
7235 sprintf(message, $"Save changes to Untitled %d?", documentID);
7237 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7239 if(dialogRes == yes)
7241 // TOFIX: Precomp error if brackets are taken out
7242 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7244 else if(dialogRes == cancel)
7250 for(slave = slaves.first; slave; slave = slave.next)
7252 Window w = slave.data;
7253 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7255 // ((Window)slave.data).CloseConfirmation(true);
7264 for(child = children.first; child; child = child.next)
7265 if(child.master != this && !child.CloseConfirmation(true))
7275 // Static methods... move them somewhere else?
7276 void ::RestoreCaret()
7278 if(guiApp.caretOwner)
7279 guiApp.caretOwner.UpdateCaret(false, false);
7282 void ::FreeMouseRange()
7284 guiApp.interfaceDriver.SetMouseRange(null, null);
7288 bool MenuFileClose(MenuItem selection, Modifiers mods)
7290 Window document = activeChild;
7292 document.Destroy(0);
7296 bool MenuFileExit(MenuItem selection, Modifiers mods)
7302 bool MenuFileSave(MenuItem selection, Modifiers mods)
7306 fileMonitor.fileName = null;
7309 if(OnSaveFile(fileName))
7311 //if(OnFileModified != Window::OnFileModified)
7314 fileMonitor.fileName = fileName;
7320 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7321 DialogResult answer = dialog.Modal();
7323 if(answer != yes) return (bool)answer;
7326 return MenuFileSaveAs(selection, mods);
7329 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7331 DialogResult result = (DialogResult)bool::true;
7332 FileDialog fileDialog = saveDialog;
7335 fileDialog = FileDialog {};
7340 fileDialog.filePath = fileName;
7343 char filePath[MAX_FILENAME];
7344 sprintf(filePath, "Untitled %d", documentID);
7345 fileDialog.filePath = filePath;
7347 fileMonitor.fileName = null;
7349 fileDialog.type = save;
7350 fileDialog.text = $"Save As";
7354 fileDialog.master = master.parent ? master : this;
7355 if(fileDialog.Modal() == ok)
7357 char * filePath = fileDialog.filePath;
7359 if(OnSaveFile(filePath))
7362 property::fileName = filePath;
7363 NotifySaved(master, this, filePath);
7368 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7369 DialogResult answer = dialog.Modal();
7384 //if(OnFileModified != Window::OnFileModified && fileName)
7387 fileMonitor.fileName = fileName;
7391 return (bool)result; // Actually returning result from Yes/NoCancel message box
7394 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7396 Window document = activeChild;
7398 for(document = children.first; document; document = next)
7400 next = document.next;
7401 if(document.style.isDocument || document.fileName)
7402 document.MenuFileSave(selection, mods);
7407 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7411 for(document = children.first; document; document = document.next)
7412 //if(document.style.isDocument && document.state == minimized)
7413 if(document.style.isActiveClient && document.state == minimized)
7414 document.SetState(minimized, false, mods);
7418 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7420 Window document = activeChild;
7423 Window firstDocument = null;
7425 OldLink cycle = document.cycle.prev;
7430 if(child.style.isActiveClient && !child.style.hidden)
7434 firstDocument = child;
7435 if(child.state == minimized)
7436 child.SetState(minimized, false, mods);
7439 child.positionID = id++;
7440 child.SetState(normal, false, mods);
7441 child.anchor.left.type = cascade;
7444 child.normalSizeAnchor = *&child.sizeAnchor;
7445 child.normalAnchor = child.anchor;
7447 // Break the anchors for moveable/resizable windows
7448 if(child.style.fixed)
7450 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7452 (*&child.normalAnchor).left = x;
7453 (*&child.normalAnchor).top = y;
7454 (*&child.normalAnchor).right.type = none;
7455 (*&child.normalAnchor).bottom.type = none;
7457 child.normalSizeAnchor.isClientW = false;
7458 child.normalSizeAnchor.isClientH = false;
7459 child.normalSizeAnchor.size.w = w;
7460 child.normalSizeAnchor.size.h = h;
7461 child.anchored = false;
7464 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7466 child.stateAnchor = child.normalAnchor;
7467 child.stateSizeAnchor = child.normalSizeAnchor;
7469 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7470 child.Position(x, y, w, h, true, true, true, true, false, false);
7475 last = children.last;
7476 if(!child.style.stayOnTop)
7477 for(; last && last.style.stayOnTop; last = last.prev);
7478 children.Move(child, last);
7479 childrenOrder.Move(child.order, childrenOrder.last);
7481 if(cycle == document.cycle) break;
7485 firstDocument.Activate();
7490 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7497 // Close all closes all active clients, not all documents
7498 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7500 Window next, document;
7502 for(document = children.first; document; document = next)
7504 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7505 if(document.style.isActiveClient)
7506 if(!document.Destroy(0) && !document.style.hidden)
7512 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7514 if(style.hasMaximize && state != maximized)
7515 SetState(maximized, 0, 0);
7519 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7521 if(style.hasMinimize && state != minimized)
7523 SetState(minimized, 0, 0);
7524 parent.CycleChildren(false, true, false, true);
7529 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7531 MenuMoveOrSize(false, selection ? true : false);
7535 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7537 CycleChildren(false, true, false, true);
7541 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7543 CycleChildren(true, true, false, true);
7547 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7549 MenuMoveOrSize(true, true);
7553 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7556 SetState(normal, 0, 0);
7560 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7563 int64 id = selection.id;
7564 OldLink cycle = activeClient.cycle;
7566 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7569 Window sibling = cycle.data;
7570 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7578 document = cycle.data;
7579 document.Activate();
7581 //if(activeChild.state == maximized)
7582 // document.SetState(maximized, false, mods);
7583 //else if(document.state == minimized)
7584 // document.SetState(normal, false, mods);
7588 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7590 stayOnTop = !style.stayOnTop;
7594 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7596 Window document = activeChild;
7599 Window firstDocument = null;
7600 OldLink cycle = document.cycle;
7604 Window child = cycle.data;
7605 if(child.style.isActiveClient && !child.style.hidden)
7607 if(!firstDocument) firstDocument = child;
7608 if(child.state == minimized)
7609 child.SetState(minimized, false, mods);
7612 child.positionID = id++;
7613 child.SetState(normal, false, mods);
7614 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7616 child.anchor.left.type = hTiled;
7619 child.normalSizeAnchor = *&child.sizeAnchor;
7620 child.normalAnchor = child.anchor;
7622 // Break the anchors for moveable/resizable windows
7623 if(child.style.fixed)
7625 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7627 (*&child.normalAnchor).left = x;
7628 (*&child.normalAnchor).top = y;
7629 (*&child.normalAnchor).right.type = none;
7630 (*&child.normalAnchor).bottom.type = none;
7631 child.normalSizeAnchor.isClientW = false;
7632 child.normalSizeAnchor.isClientH = false;
7633 child.normalSizeAnchor.size.w = w;
7634 child.normalSizeAnchor.size.h = h;
7635 child.anchored = false;
7638 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7640 child.stateAnchor = child.normalAnchor;
7641 child.stateSizeAnchor = child.normalSizeAnchor;
7643 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7644 child.Position(x,y, w, h, true, true, true, true, false, true);
7649 if((cycle = cycle.next) == document.cycle) break;
7652 firstDocument.Activate();
7657 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7659 Window document = activeChild;
7662 Window firstDocument = null;
7664 OldLink cycle = document.cycle;
7669 //if(child.style.isDocument)
7670 if(child.style.isActiveClient && !child.style.hidden)
7672 if(!firstDocument) firstDocument = child;
7673 if(child.state == minimized)
7674 child.SetState(minimized, false, mods);
7677 child.positionID = id++;
7678 child.SetState(normal, false, mods);
7679 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7681 child.anchor.left.type = vTiled;
7684 child.normalSizeAnchor = *&child.sizeAnchor;
7685 child.normalAnchor = child.anchor;
7687 // Break the anchors for moveable/resizable windows
7688 if(child.style.fixed)
7690 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7692 (*&child.normalAnchor).left = x;
7693 (*&child.normalAnchor).top = y;
7694 (*&child.normalAnchor).right.type = none;
7695 (*&child.normalAnchor).bottom.type = none;
7696 child.normalSizeAnchor.isClientW = false;
7697 child.normalSizeAnchor.isClientH = false;
7698 child.normalSizeAnchor.size.w = w;
7699 child.normalSizeAnchor.size.h = h;
7700 child.anchored = false;
7703 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7705 child.stateAnchor = child.normalAnchor;
7706 child.stateSizeAnchor = child.normalSizeAnchor;
7708 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7709 child.Position(x,y, w, h, true, true, true, true, false, true);
7714 if((cycle = cycle.next) == document.cycle) break;
7717 firstDocument.Activate();
7722 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7724 WindowList dialog { master = this };
7725 Window document = (Window)dialog.Modal();
7728 if(activeChild.state == maximized)
7729 document.SetState(maximized, false, mods);
7730 else if(document.state == minimized)
7731 document.SetState(normal, false, mods);
7732 document.Activate();
7738 virtual bool OnCreate(void);
7739 virtual void OnDestroy(void);
7740 virtual void OnDestroyed(void);
7741 virtual bool OnClose(bool parentClosing);
7742 virtual bool OnStateChange(WindowState state, Modifiers mods);
7743 virtual bool OnPostCreate(void);
7744 virtual bool OnMoving(int *x, int *y, int w, int h);
7745 virtual bool OnResizing(int *width, int *height);
7746 virtual void OnResize(int width, int height);
7747 virtual void OnPosition(int x, int y, int width, int height);
7748 virtual bool OnLoadGraphics(void);
7749 virtual void OnApplyGraphics(void);
7750 virtual void OnUnloadGraphics(void);
7751 virtual void OnRedraw(Surface surface);
7752 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7753 virtual void OnActivateClient(Window client, Window previous);
7754 virtual bool OnKeyDown(Key key, unichar ch);
7755 virtual bool OnKeyUp(Key key, unichar ch);
7756 virtual bool OnKeyHit(Key key, unichar ch);
7757 virtual bool OnSysKeyDown(Key key, unichar ch);
7758 virtual bool OnSysKeyUp(Key key, unichar ch);
7759 virtual bool OnSysKeyHit(Key key, unichar ch);
7760 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7761 virtual bool OnMouseLeave(Modifiers mods);
7762 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7763 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7764 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7765 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7766 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7767 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7768 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7769 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7770 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7771 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7772 virtual void OnMouseCaptureLost(void);
7773 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7774 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7775 virtual void OnDrawOverChildren(Surface surface);
7776 virtual bool OnFileModified(FileChange fileChange, char * param);
7777 virtual bool OnSaveFile(char * fileName);
7779 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7780 // Note: A 'client' would refer to isActiveClient, rather than
7781 // being confined to the 'client area' (nonClient == false)
7782 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7783 virtual void OnChildVisibilityToggled(Window child, bool visible);
7784 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7786 // Skins Virtual Functions
7787 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7788 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7789 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7794 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7795 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7796 virtual bool IsMouseMoving(int x, int y, int w, int h)
7800 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7804 virtual void UpdateNonClient();
7805 virtual void SetBox(Box box); // This isn't used anywhere at this time
7806 virtual bool IsInside(int x, int y)
7808 return box.IsPointInside({x, y});
7810 virtual bool IsOpaque()
7812 return (!style.drawBehind || background.a == 255);
7816 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7817 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7818 virtual void Window::NotifySaved(Window window, char * filePath);
7823 property Window parent
7825 property_category $"Layout"
7828 if(value || guiApp.desktop)
7831 Window oldParent = parent;
7832 Anchor anchor = this.anchor;
7834 if(value && value.IsDescendantOf(this)) return;
7835 if(value && value == this)
7837 if(!value) value = guiApp.desktop;
7839 if(value == oldParent) return;
7841 if(!master || (master == this.parent && master == guiApp.desktop))
7842 property::master = value;
7846 parent.children.Remove(this);
7850 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7851 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7852 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7853 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7857 last = value.children.last;
7859 if(style.isDocument)
7862 parent.numDocuments--;
7863 documentID = value.GetDocumentID();
7866 if(style.isActiveClient && !style.hidden)
7868 if(parent && parent != guiApp.desktop && !(style.hidden))
7870 if(state == minimized) parent.numIcons--;
7871 parent.numPositions--;
7875 if(!style.stayOnTop)
7876 for(; last && last.style.stayOnTop; last = last.prev);
7878 value.children.Insert(last, this);
7880 // *** NEW HERE: ***
7882 parent.childrenCycle.Delete(cycle);
7884 parent.childrenOrder.Delete(order);
7887 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7888 // Should something else be done?
7889 if(parent && parent.activeChild == this)
7890 parent.activeChild = null;
7891 if(parent && parent.activeClient == this)
7892 parent.activeClient = null;
7898 int x = position.x, y = position.y, w = size.w, h = size.h;
7902 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7903 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7905 vpw = value.clientSize.w;
7906 vph = value.clientSize.h;
7912 else if(style.fixed)
7914 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7915 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7918 anchor = this.anchor;
7920 if(anchor.left.type == offset) anchor.left.distance = x;
7921 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7922 if(anchor.top.type == offset) anchor.top.distance = y;
7923 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7924 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7925 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7926 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7927 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7928 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7929 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7931 if(!anchor.left.type && !anchor.right.type)
7933 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7934 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7936 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7937 if(!anchor.top.type && !anchor.bottom.type)
7939 anchor.vert.distance = (y + h / 2) - (vph / 2);
7940 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7942 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7945 parent.OnChildAddedOrRemoved(this, false);
7951 parent.childrenCycle.Insert(
7952 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7953 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7955 cycle = OldLink { data = this });
7956 parent.childrenOrder.Insert(
7957 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7958 order = OldLink { data = this });
7961 if(!style.hidden && style.isActiveClient)
7963 positionID = parent.GetPositionID(this);
7964 parent.numPositions++;
7965 if(state == minimized) parent.numIcons--;
7968 // *** FONT INHERITANCE ***
7969 if(!setFont && oldParent)
7970 stopwatching(oldParent, font);
7974 RemoveResource(systemFont);
7977 // TESTING WITH WATCHERS:
7978 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7979 // usedFont = setFont ? setFont : (systemFont);
7983 if(guiApp.currentSkin)
7985 systemFont = guiApp.currentSkin.SystemFont();
7988 usedFont = systemFont;
7989 AddResource(systemFont);
7997 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8006 if(value.rootWindow && value.rootWindow.display && rootWindow)
8008 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8009 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8012 UnloadGraphics(false);
8015 LoadGraphics(false, false);
8018 if(value.rootWindow != rootWindow)
8019 DisplayModeChanged();
8023 scrolledPos.x = MININT; // Prevent parent update
8025 bool anchored = this.anchored;
8026 property::anchor = anchor;
8027 this.anchored = anchored;
8032 if(guiApp.currentSkin)
8033 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8035 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8036 Position(x, y, w, h, true, true, true, true, false, true);
8041 // else parent = value;
8043 oldParent.OnChildAddedOrRemoved(this, true);
8046 get { return parent; }
8049 property Window master
8051 property_category $"Behavior"
8054 //if(this == value) return;
8055 if(value && value.IsSlaveOf(this)) return;
8061 OldLink slaveHolder;
8062 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8063 if(slaveHolder.data == this)
8065 master.slaves.Delete(slaveHolder);
8072 value.slaves.Add(OldLink { data = this });
8077 master.hotKeys.Remove(hotKey);
8078 value.hotKeys.Add(hotKey);
8081 if(master && master.defaultControl == this)
8082 master.defaultControl = null;
8084 if(style.isDefault && !value.defaultControl)
8085 value.defaultControl = this;
8090 get { return master ? master : parent; }
8093 property char * caption
8095 property_category $"Appearance"
8102 caption = new char[strlen(value)+1];
8104 strcpy(caption, value);
8109 get { return caption; }
8114 property_category $"Behavior"
8123 master.hotKeys.Add(hotKey = HotKeySlot { });
8127 hotKey.window = this;
8132 master.hotKeys.Delete(hotKey);
8137 get { return hotKey ? hotKey.key : 0; }
8140 property Color background
8142 property_category $"Appearance"
8145 background.color = value;
8150 if(this == rootWindow)
8151 guiApp.interfaceDriver.SetRootWindowColor(this);
8154 get { return background.color; }
8157 property Percentage opacity
8159 property_category $"Appearance"
8162 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8163 drawBehind = (background.a == 255) ? false : true;
8165 get { return background.a / 255.0f; }
8168 property Color foreground
8170 property_category $"Appearance"
8178 get { return foreground; }
8181 property BorderStyle borderStyle
8183 property_category $"Appearance"
8186 if(!((BorderBits)value).fixed)
8188 style.hasClose = false;
8189 style.hasMaximize = false;
8190 style.hasMinimize = false;
8191 nativeDecorations = false;
8193 style.borderBits = value;
8197 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8199 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8200 Position(x, y, w, h, true, true, true, true, false, true);
8201 CreateSystemChildren();
8204 get { return (BorderStyle)style.borderBits; }
8207 property Size minClientSize
8209 property_category $"Layout"
8210 set { minSize = value; }
8211 get { value = minSize; }
8214 property Size maxClientSize
8216 property_category $"Layout"
8217 set { maxSize = value; }
8218 get { value = maxSize; }
8221 property bool hasMaximize
8223 property_category $"Window Style"
8226 style.hasMaximize = value;
8227 if(value) { style.fixed = true; style.contour = true; }
8231 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8233 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8234 Position(x, y, w, h, true, true, true, true, false, true);
8236 CreateSystemChildren();
8239 get { return style.hasMaximize; }
8242 property bool hasMinimize
8244 property_category $"Window Style"
8247 style.hasMinimize = value;
8248 if(value) { style.fixed = true; style.contour = true; }
8252 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8254 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8255 Position(x, y, w, h, true, true, true, true, false, true);
8257 CreateSystemChildren();
8260 get { return style.hasMinimize; }
8263 property bool hasClose
8265 property_category $"Window Style"
8268 style.hasClose = value;
8269 if(value) { style.fixed = true; style.contour = true; }
8273 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8274 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8275 Position(x, y, w, h, true, true, true, true, false, true);
8276 CreateSystemChildren();
8279 get { return style.hasClose; }
8282 property bool nonClient
8284 property_category $"Layout"
8287 style.nonClient = value;
8289 style.stayOnTop = true;
8291 get { return style.nonClient; }
8294 property bool inactive
8296 property_category $"Behavior"
8301 // *** NEW HERE: ***
8305 parent.childrenCycle.Delete(cycle);
8307 parent.childrenOrder.Delete(order);
8314 active = false; // true;
8315 if(parent.activeChild == this)
8316 parent.activeChild = null;
8317 if(parent.activeClient == this)
8318 parent.activeClient = null;
8327 parent.childrenCycle.Insert(
8328 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8329 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8331 cycle = OldLink { data = this });
8333 parent.childrenOrder.Insert(
8334 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8335 order = OldLink { data = this });
8338 style.inactive = value;
8340 get { return style.inactive; }
8343 property bool clickThrough
8345 property_category $"Behavior"
8346 set { style.clickThrough = value; }
8347 get { return style.clickThrough; }
8350 property bool isRemote
8352 property_category $"Behavior"
8353 set { style.isRemote = value; }
8354 get { return style.isRemote; }
8357 property bool noCycle
8359 property_category $"Behavior"
8360 set { style.noCycle = value; }
8361 get { return style.noCycle; }
8364 property bool isModal
8366 property_category $"Behavior"
8367 set { style.modal = value; }
8368 get { return style.modal; }
8371 property bool interim
8373 property_category $"Behavior"
8374 set { style.interim = value; }
8375 get { return style.interim; }
8378 property bool tabCycle
8380 property_category $"Behavior"
8381 set { style.tabCycle = value; }
8382 get { return style.tabCycle; }
8385 property bool isDefault
8387 property_category $"Behavior"
8395 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8396 if(sibling != this && sibling.style.isDefault)
8397 sibling.style.isDefault = false;*/
8398 if(master.defaultControl)
8399 master.defaultControl.style.isDefault = false;
8400 master.defaultControl = this;
8402 else if(master.defaultControl == this)
8403 master.defaultControl = null;
8407 style.isDefault = value;
8409 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8411 get { return style.isDefault; }
8414 property bool drawBehind
8416 property_category $"Window Style"
8417 set { style.drawBehind = value; }
8418 get { return style.drawBehind; }
8421 property bool hasMenuBar
8423 property_category $"Window Style"
8433 if(created && !menuBar)
8440 anchor = Anchor { top = 23, left = 1, right = 1 },
8442 inactive = true, nonClient = true
8447 else if(created && menuBar)
8452 style.hasMenuBar = value;
8454 get { return style.hasMenuBar; }
8457 property bool hasStatusBar
8459 property_category $"Window Style"
8466 statusBar = StatusBar { this };
8474 style.hasStatusBar = value;
8476 get { return style.hasStatusBar; }
8478 property bool stayOnTop
8480 property_category $"Window Style"
8485 if(created && !style.stayOnTop)
8487 if(rootWindow == this)
8488 guiApp.interfaceDriver.OrderRootWindow(this, true);
8489 else if(parent.children.last != this)
8491 parent.children.Move(this, parent.children.last);
8495 style.stayOnTop = true;
8499 if(created && style.stayOnTop)
8501 if(rootWindow == this)
8502 guiApp.interfaceDriver.OrderRootWindow(this, false);
8509 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8510 order && ((Window)order.data).style.stayOnTop;
8511 order = (order == parent.childrenOrder.first) ? null : order.prev);
8512 last = order ? order.data : null;
8516 for(last = parent.children.last;
8517 last && last.style.stayOnTop;
8521 parent.children.Move(this, last);
8525 style.stayOnTop = false;
8528 get { return style.stayOnTop; }
8533 property_category $"Window Style"
8543 if(menuBar && !value)
8550 if(!menuBar && style.hasMenuBar && value)
8554 this, menu = value, isMenuBar = true,
8555 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8556 inactive = true, nonClient = true
8560 UpdateActiveDocument(null);
8563 get { return menu; }
8566 property FontResource font
8568 property_category $"Appearance"
8570 isset { return setFont ? true : false; }
8575 if(value && !setFont) { stopwatching(parent, font); }
8576 else if(!value && setFont)
8582 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8591 RemoveResource(setFont);
8596 RemoveResource(systemFont);
8603 AddResource(setFont);
8606 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8609 systemFont = guiApp.currentSkin.SystemFont();
8611 usedFont = systemFont;
8612 AddResource(systemFont);
8620 get { return usedFont; }
8623 property SizeAnchor sizeAnchor
8625 property_category $"Layout"
8628 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8629 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8630 sizeAnchor.isClientW != sizeAnchor.isClientH;
8637 normalSizeAnchor = sizeAnchor;
8639 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8641 stateAnchor = normalAnchor;
8642 stateSizeAnchor = normalSizeAnchor;
8644 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8645 Position(x,y, w, h, true, true, true, true, false, true);
8652 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8653 sizeAnchor.isClientW,
8654 sizeAnchor.isClientH
8661 property_category $"Layout"
8664 Anchor thisAnchor = anchor;
8665 SizeAnchor thisSizeAnchor = sizeAnchor;
8666 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8667 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8668 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8669 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8670 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8671 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8677 sizeAnchor.isClientW = false;
8678 sizeAnchor.isClientH = false;
8679 sizeAnchor.size = value;
8681 normalSizeAnchor = sizeAnchor;
8683 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8685 stateAnchor = normalAnchor;
8686 stateSizeAnchor = normalSizeAnchor;
8688 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8689 Position(x, y, w, h, true, true, true, true, false, true);
8690 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8693 get { value = size; }
8696 property Size clientSize
8698 property_category $"Layout"
8701 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8702 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8703 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8708 sizeAnchor.isClientW = true;
8709 sizeAnchor.isClientH = true;
8710 sizeAnchor.size = value;
8712 normalSizeAnchor = sizeAnchor;
8714 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8716 stateAnchor = normalAnchor;
8717 stateSizeAnchor = normalSizeAnchor;
8719 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8720 Position(x,y, w, h, true, true, true, true, false, true);
8721 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8724 get { value = this ? clientSize : { 0, 0 }; }
8727 property Size initSize { get { value = sizeAnchor.size; } };
8729 property Anchor anchor
8731 property_category $"Layout"
8732 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8738 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8740 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8741 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8743 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8745 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8746 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8750 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8752 anchor.left.distance = 0;
8753 anchor.horz.type = 0;
8755 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8757 anchor.top.distance = 0;
8758 anchor.vert.type = 0;
8767 normalAnchor = anchor;
8769 // Break the anchors for moveable/resizable windows
8770 /*if(style.fixed ) //&& value.left.type == cascade)
8772 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8774 this.anchor = normalAnchor = Anchor { left = x, top = y };
8775 normalSizeAnchor = SizeAnchor { { w, h } };
8778 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8780 stateAnchor = normalAnchor;
8781 stateSizeAnchor = normalSizeAnchor;
8783 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8784 Position(x, y, w, h, true, true, true, true, false, true);
8793 get { value = this ? anchor : Anchor { }; }
8796 property Point position
8798 property_category $"Layout"
8801 if(value == null) return;
8803 anchor.left = value.x;
8804 anchor.top = value.y;
8805 anchor.right.type = none;
8806 anchor.bottom.type = none;
8811 normalAnchor = anchor;
8813 // Break the anchors for moveable/resizable windows
8817 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8819 normalAnchor.left = x;
8820 normalAnchor.top = y;
8821 normalAnchor.right.type = none;
8822 normalAnchor.bottom.type = none;
8823 normalSizeAnchor.size.width = w;
8824 normalSizeAnchor.size.height = h;
8828 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8830 stateAnchor = normalAnchor;
8831 stateSizeAnchor = normalSizeAnchor;
8833 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8834 Position(x,y, w, h, true, true, true, true, false, true);
8838 get { value = position; }
8841 property bool disabled
8843 property_category $"Behavior"
8846 if(this && disabled != value)
8853 get { return (bool)disabled; }
8856 property bool isEnabled
8861 for(parent = this; parent; parent = parent.parent)
8868 property WindowState state
8870 property_category $"Behavior"
8871 set { SetState(value, false, 0); }
8872 get { return this ? state : 0; }
8875 property bool visible
8877 property_category $"Behavior"
8880 if(this && !value && !style.hidden && parent)
8882 bool wasActiveChild = parent.activeChild == this;
8883 Window client = null;
8885 style.hidden = true;
8886 if(style.isActiveClient)
8888 parent.numPositions--;
8889 if(state == minimized) parent.numIcons--;
8894 OldLink prevOrder = null;
8896 if(rootWindow == this)
8897 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8900 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8903 box.left -= parent.clientStart.x;
8904 box.top -= parent.clientStart.y;
8905 box.right -= parent.clientStart.x;
8906 box.bottom -= parent.clientStart.y;
8910 if(_isModal && master && master.modalSlave == this)
8911 master.modalSlave = null;
8915 OldLink tmpPrev = order.prev;
8916 client = tmpPrev ? tmpPrev.data : null;
8917 if(client && !client.style.hidden && !client.destroyed && client.created)
8918 prevOrder = tmpPrev;
8921 client = tmpPrev ? tmpPrev.data : null;
8922 if(client == this) { client = null; break; }
8923 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8925 tmpPrev = client.order.prev;
8930 prevOrder = tmpPrev;
8935 // If this window can be an active client, make sure the next window we activate can also be one
8936 if(!style.nonClient && style.isActiveClient)
8938 tmpPrev = prevOrder;
8941 client = tmpPrev ? tmpPrev.data : null;
8942 if(client == this) { client = null; break; }
8943 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8945 tmpPrev = client.order.prev;
8950 prevOrder = tmpPrev;
8954 if(client && client.style.hidden) client = null;
8958 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8960 if(order && prevOrder && prevOrder.data != this)
8961 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8963 ActivateEx(false, false, false, true, null, null);
8965 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8966 if(parent.activeClient == this)
8968 parent.activeClient = null;
8969 parent.UpdateActiveDocument(null);
8972 else if(parent.activeClient == this)
8974 parent.activeClient = client;
8975 parent.UpdateActiveDocument(this);
8978 // *** Not doing this anymore ***
8981 parent.childrenCycle.Delete(cycle);
8983 parent.childrenOrder.Delete(order);
8988 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8993 else if(this && value && style.hidden)
8995 style.hidden = false;
8998 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8999 if(rootWindow == this)
9000 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9002 if(_isModal && master)
9003 master.modalSlave = this;
9005 if(style.isActiveClient)
9007 positionID = parent.GetPositionID(this);
9008 parent.numPositions++;
9009 if(state == minimized) parent.numIcons++;
9012 // *** NOT DOING THIS ANYMORE ***
9014 if(!(style.inactive))
9016 if(!(style.noCycle))
9018 cycle = parent.childrenCycle.AddAfter(
9019 (parent.activeChild && parent.activeChild.cycle) ?
9020 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9023 order = parent.childrenOrder.AddAfter(
9024 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9031 if(true || !parent.activeChild)
9032 ActivateEx(true, false, true, true, null, null);
9034 if(creationActivation == activate)
9035 ActivateEx(true, false, true, true, null, null);
9036 else if(creationActivation == flash && !object)
9039 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9043 ConsequentialMouseMove(false);
9049 style.hidden = !value;
9052 get { return (style.hidden || !setVisible) ? false : true; }
9055 property bool isDocument
9057 property_category $"Document"
9058 set { style.isDocument = value; }
9059 get { return style.isDocument; }
9062 property bool mergeMenus
9064 property_category $"Window Style"
9065 set { mergeMenus = value; }
9066 get { return (bool)mergeMenus; }
9069 property bool hasHorzScroll
9071 property_category $"Window Style"
9076 if(!style.hasHorzScroll && created)
9078 CreateSystemChildren();
9079 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9082 else if(style.hasHorzScroll)
9086 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9088 style.hasHorzScroll = value;
9091 get { return style.hasHorzScroll; }
9094 property bool hasVertScroll
9096 property_category $"Window Style"
9101 if(!style.hasVertScroll && created)
9103 style.hasVertScroll = true;
9104 CreateSystemChildren();
9105 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9108 else if(style.hasVertScroll)
9112 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9114 style.hasVertScroll = value;
9116 get { return style.hasVertScroll; }
9119 property bool dontHideScroll
9121 property_category $"Behavior"
9124 scrollFlags.dontHide = value;
9127 //UpdateScrollBars(true, true);
9128 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9132 // UpdateScrollBars(true, true);
9133 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9136 get { return scrollFlags.dontHide; }
9139 property bool dontScrollVert
9141 property_category $"Behavior"
9142 set { style.dontScrollVert = value; }
9143 get { return style.dontScrollVert; }
9145 property bool dontScrollHorz
9147 property_category $"Behavior"
9148 set { style.dontScrollHorz = value; }
9149 get { return style.dontScrollHorz; }
9152 property bool snapVertScroll
9154 property_category $"Behavior"
9157 scrollFlags.snapY = value;
9158 if(sbv) sbv.snap = value;
9160 get { return scrollFlags.snapY; }
9162 property bool snapHorzScroll
9164 property_category $"Behavior"
9167 scrollFlags.snapX = value;
9168 if(sbh) sbh.snap = value;
9170 get { return scrollFlags.snapX; }
9173 property Point scroll
9175 property_category $"Behavior"
9176 set { if(this) SetScrollPosition(value.x, value.y); }
9177 get { value = scroll; }
9180 property bool modifyVirtualArea
9182 property_category $"Behavior"
9183 set { modifyVirtArea = value; }
9184 get { return (bool)modifyVirtArea; }
9187 property bool dontAutoScrollArea
9189 property_category $"Behavior"
9190 // Activating a child control out of view will automatically scroll to make it in view
9191 set { noAutoScrollArea = value; }
9192 get { return (bool)noAutoScrollArea; }
9195 property char * fileName
9197 property_category $"Document"
9200 if(menu && ((!fileName && value) || (fileName && !value)))
9202 MenuItem item = menu.FindItem(MenuFileSave, 0);
9203 if(item) item.disabled = !modifiedDocument && value;
9208 if(value && value[0])
9209 fileName = CopyString(value);
9211 if(parent && this == parent.activeClient)
9212 parent.UpdateActiveDocument(null);
9216 // if(style.isDocument)
9218 fileMonitor.fileName = value;
9220 get { return fileName; }
9225 property_category $"Data"
9230 property bool modifiedDocument
9232 property_category $"Document"
9235 if(style.isDocument || fileName)
9239 MenuItem item = menu.FindItem(MenuFileSave, 0);
9240 if(item) item.disabled = !value && fileName;
9244 if(modifiedDocument != value)
9246 modifiedDocument = value;
9247 if(style.isDocument || fileName)
9251 get { return (bool)modifiedDocument; }
9254 property bool showInTaskBar
9256 property_category $"Window Style"
9257 set { style.showInTaskBar = value; }
9258 get { return (style.showInTaskBar; }
9260 property FileDialog saveDialog { set { saveDialog = value; } };
9261 property bool isActiveClient
9263 property_category $"Behavior"
9264 set { style.isActiveClient = value; }
9265 get { return style.isActiveClient; }
9268 property Cursor cursor
9270 property_category $"Appearance"
9274 SelectMouseCursor();
9276 get { return cursor; }
9279 //#if !defined(ECERE_VANILLA)
9280 property char * name
9282 property_category $"Design"
9285 return (this && object) ? object.name : null;
9290 activeDesigner.RenameObject(object, value);
9294 property char * displayDriver
9296 property_category $"Behavior"
9299 dispDriver = GetDisplayDriver(value);
9300 //DisplayModeChanged();
9304 return dispDriver ? dispDriver.name : null;
9308 // RUNTIME PROPERTIES
9309 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9310 property Size scrollArea
9312 property_category $"Behavior"
9316 SetScrollArea(value.w, value.h, false);
9318 SetScrollArea(0,0, true);
9320 get { value = scrollArea; }
9323 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9328 property_category $"Layout"
9329 set { if(this) is3D = value; }
9330 get { return (bool)is3D; }
9333 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9335 // Will be merged with font later
9336 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9337 property Point clientStart { get { value = clientStart; } };
9338 property Point absPosition { get { value = absPosition; } };
9339 property Anchor normalAnchor { get { value = normalAnchor; } };
9340 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9341 property bool active { get { return (bool)active; } };
9342 property bool created { get { return (bool)created; } };
9343 property bool destroyed { get { return (bool)destroyed; } };
9344 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9345 property Window firstChild { get { return children.first; } };
9346 property Window lastChild { get { return children.last; } };
9347 property Window activeClient { get { return activeClient; } };
9348 property Window activeChild { get { return activeChild; } };
9349 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9350 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9351 property ScrollBar horzScroll { get { return sbh; } };
9352 property ScrollBar vertScroll { get { return sbv; } };
9353 property StatusBar statusBar { get { return statusBar; } };
9354 property Window rootWindow { get { return rootWindow; } };
9355 property bool closing { get { return (bool)closing; } set { closing = value; } };
9356 property int documentID { get { return documentID; } };
9357 property Window previous { get { return prev; } }
9358 property Window next { get { return next; } }
9359 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9360 property PopupMenu menuBar { get { return menuBar; } }
9361 property ScrollBar sbv { get { return sbv; } }
9362 property ScrollBar sbh { get { return sbh; } }
9363 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9364 property void * systemHandle { get { return windowHandle; } }
9365 property Button minimizeButton { get { return sysButtons[0]; } };
9366 property Button maximizeButton { get { return sysButtons[1]; } };
9367 property Button closeButton { get { return sysButtons[2]; } };
9368 property BitmapResource icon
9370 get { return icon; }
9374 if(icon) incref icon;
9376 guiApp.interfaceDriver.SetIcon(this, value);
9379 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9380 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9381 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9382 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9383 property bool nativeDecorations
9385 get { return (bool)nativeDecorations; }
9386 set { nativeDecorations = value; }
9387 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9390 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9391 bool result = false;
9392 if(nativeDecorations)
9394 if(rootWindow == this)
9398 if(formDesigner && activeDesigner)
9400 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9401 Window form = cd ? cd.form : null;
9402 if(form && parent == form.parent)
9407 return result != style.fixed;
9411 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9413 property char * text
9415 property_category $"Deprecated"
9417 set { property::caption = value; }
9418 get { return property::caption; }
9424 WindowBits style; // Window Style
9425 char * caption; // Name / Caption
9426 Window parent; // Parent window
9427 OldList children; // List of children in Z order
9428 Window activeChild; // Child window having focus
9429 Window activeClient;
9430 Window previousActive; // Child active prior to activating the default child
9431 Window master; // Window owning and receiving notifications concerning this window
9432 OldList slaves; // List of windows belonging to this window
9433 Display display; // Display this window is drawn into
9435 Point position; // Position in parent window client area
9436 Point absPosition; // Absolute position
9437 Point clientStart; // Client area position from (0,0) in this window
9439 Size clientSize; // Client area size
9440 Size scrollArea; // Virtual Scroll area size
9441 Size reqScrollArea; // Requested virtual area size
9442 Point scroll; // Virtual area scrolling position
9443 ScrollBar sbh, sbv; // Scrollbar window handles
9444 Cursor cursor; // Mouse cursor used for this window
9447 StatusBar statusBar;
9448 Button sysButtons[3];
9450 Box clientArea; // Client Area box clipped to parent
9452 HotKeySlot hotKey; // HotKey for this window
9456 ScrollFlags scrollFlags;// Window Scrollbar Flags
9457 int64 id; // Control ID
9459 ColorAlpha background; // Background color used to draw the window area
9461 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9462 OldList childrenCycle; // Cycling order
9463 OldLink cycle; // Element of parent's cycling order
9464 OldList childrenOrder; // Circular Z-Order
9465 OldLink order; // Element of parent's circular Z-Order
9466 Window modalSlave; // Slave window blocking this window's interaction
9468 Window rootWindow; // Topmost system managed window
9469 void * windowHandle; // System window handle
9471 DialogResult returnCode;// Return code for modal windows
9473 Point sbStep; // Scrollbar line scrolling steps
9476 SizeAnchor stateSizeAnchor;
9478 Anchor normalAnchor;
9479 SizeAnchor normalSizeAnchor;
9481 Size skinMinSize; // Minimal window size based on style
9482 Point scrolledPos; // Scrolled position
9483 Box box; // Window box clipped to parent
9484 Box * against; // What to clip the box to
9486 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9487 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9488 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9489 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9490 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9491 Point scrolledArea; // Distance to scroll area by
9492 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9494 OldList hotKeys; // List of the hotkeys of all children
9495 Window defaultControl; // Default child control
9499 ColorAlpha * palette; // Color palette used for this window
9501 int caretSize; // Size of caret, non zero if a caret is present
9502 Point caretPos; // Caret position
9504 void * systemParent; // Parent System Window for embedded windows
9511 WindowState lastState;
9513 FileMonitor fileMonitor
9515 this, FileChange { modified = true };
9517 bool OnFileNotify(FileChange action, char * param)
9520 fileMonitor.StopMonitoring();
9521 if(OnFileModified(action, param))
9522 fileMonitor.StartMonitoring();
9527 FontResource setFont, systemFont;
9528 FontResource usedFont;
9529 FontResource captionFont;
9531 FileDialog saveDialog;
9533 SizeAnchor sizeAnchor;
9535 // FormDesigner data
9538 Extent * tempExtents; //[4];
9539 BitmapResource icon;
9541 CreationActivationOption creationActivation;
9544 bool active:1; // true if window and ancestors are active
9545 bool acquiredInput:1; // true if the window is processing state based input
9546 bool modifiedDocument:1;
9547 bool disabled:1; // true if window cannot interact
9548 bool isForegroundWindow:1;// true while a root window is being activated
9549 bool visible:1; // Visibility flag
9550 bool destroyed:1; // true if window is being destroyed
9551 bool anchored:1; // true if this window is repositioned when the parent resizes
9552 bool dirty:1; // Flag set to true if any descendant must be redrawn
9558 bool modifyVirtArea:1;
9559 bool noAutoScrollArea:1;
9562 bool setVisible:1; // FOR FORM DESIGNER
9568 bool useSharedMemory:1;
9571 bool nativeDecorations:1;
9572 bool manageDisplay:1;
9573 bool formDesigner:1; // True if we this is running in the form editor
9576 // Checks used internally for them not to take effect in FormDesigner
9577 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9578 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9580 WindowController controller;
9581 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9584 public class CommonControl : Window
9586 // creationActivation = doNothing;
9589 public property String toolTip
9591 property_category $"Appearance"
9594 if(created) CommonControl::OnDestroy();
9596 toolTip = value ? ToolTip { tip = value; } : null;
9598 if(created) CommonControl::OnCreate();
9600 get { return toolTip ? toolTip.tip : null; }
9606 // (Very) Ugly work around for the fact that the parent watcher
9607 // won't fire when it's already been disconnected...
9608 eInstance_FireSelfWatchers(toolTip,
9609 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9615 toolTip.parent = this;
9624 public class Percentage : float
9626 char * OnGetString(char * string, float * fieldData, bool * needClass)
9630 sprintf(string, "%.2f", this);
9631 c = strlen(string)-1;
9634 if(string[c] != '0')
9635 last = Max(last, c);
9636 if(string[c] == '.')
9649 public void ApplySkin(Class c, char * name, void ** vTbl)
9651 char className[1024];
9656 subclass(Window) wc = (subclass(Window))c;
9657 subclass(Window) base = (subclass(Window))c.base;
9659 sprintf(className, "%sSkin_%s", name, c.name);
9660 wc.pureVTbl = c._vTbl;
9661 c._vTbl = new void *[c.vTblSize];
9662 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9663 sc = eSystem_FindClass(c.module.application, className);
9667 for(m = 0; m < c.base.vTblSize; m++)
9669 if(c._vTbl[m] == base.pureVTbl[m])
9670 c._vTbl[m] = vTbl[m];
9675 for(m = 0; m < c.vTblSize; m++)
9677 if(sc._vTbl[m] != wc.pureVTbl[m])
9678 c._vTbl[m] = sc._vTbl[m];
9682 for(d = c.derivatives.first; d; d = d.next)
9684 ApplySkin(d.data, name, c._vTbl);
9688 public void UnapplySkin(Class c)
9690 char className[1024];
9692 subclass(Window) wc = (subclass(Window))c;
9693 subclass(Window) base = (subclass(Window))c.base;
9696 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9699 c._vTbl = wc.pureVTbl;
9703 for(d = c.derivatives.first; d; d = d.next)
9705 UnapplySkin(d.data);
9709 void CheckFontIntegrity(Window window)
9714 if(window.usedFont && window.usedFont.font == 0xecececec)
9716 FontResource uf = window.usedFont;
9717 char * className = window._class.name;
9718 char * text = window.text;
9721 for(c = window.firstChild; c; c = c.next)
9722 CheckFontIntegrity(c);
9726 public class ControllableWindow : Window
9728 /*WindowController controller;
9729 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9730 ~ControllableWindow() { delete controller; }*/
9733 class WindowControllerInterface : ControllableWindow
9735 bool OnKeyDown(Key key, unichar ch)
9737 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9739 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9743 bool OnKeyUp(Key key, unichar ch)
9745 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9747 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9751 bool OnKeyHit(Key key, unichar ch)
9753 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9755 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9759 bool OnMouseMove(int x, int y, Modifiers mods)
9761 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9763 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9767 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9769 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9771 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9775 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9777 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9779 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9783 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9785 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9787 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9791 bool OnRightButtonDown(int x, int y, Modifiers mods)
9793 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9795 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9799 bool OnRightButtonUp(int x, int y, Modifiers mods)
9801 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9803 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9807 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9809 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9811 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9815 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9817 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9819 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9823 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9825 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9827 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9831 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9833 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9835 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9839 void OnResize(int width, int height)
9841 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9842 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9845 void OnRedraw(Surface surface)
9847 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9848 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9853 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9855 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9859 bool OnLoadGraphics()
9861 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9863 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9867 void OnUnloadGraphics()
9869 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9870 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9874 public class WindowController<class V>
9877 property Window window
9881 uint size = class(Window).vTblSize;
9884 windowVTbl = new void *[size];
9885 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9886 if(value._vTbl == value._class._vTbl)
9888 value._vTbl = new void *[value._class.vTblSize];
9889 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9893 for(c = 0; c < size; c++)
9895 void * function = class(WindowControllerInterface)._vTbl[c];
9896 if(function != DefaultFunction)
9897 value._vTbl[c] = function;
9899 value._vTbl[c] = windowVTbl[c];
9904 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9907 get { return window; }
9909 property V controlled
9911 set { controlled = value; }
9912 get { return controlled; }
9914 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9915 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9916 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9917 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9918 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9919 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9920 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9921 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9922 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9923 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9924 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9925 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9926 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9927 virtual void V::OnResize(WindowController controller, int width, int height);
9928 virtual void V::OnRedraw(WindowController controller, Surface surface);
9929 virtual bool V::OnCreate(WindowController controller);
9930 virtual bool V::OnLoadGraphics(WindowController controller);
9931 virtual void V::OnUnloadGraphics(WindowController controller);
9934 int (** windowVTbl)();