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 const char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property const 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 int i, lockCount = guiApp.lockMutex.lockCount;
574 for(i = 0; i < lockCount; i++)
575 guiApp.lockMutex.Release();
577 for(i = 0; i < lockCount; i++)
578 guiApp.lockMutex.Wait();
583 stopwatching(parent, font);
584 if(parent.activeChild == this)
585 parent.activeChild = null;
586 if(parent.activeClient == this)
587 parent.activeClient = null;
592 // Prevent destructor from being called again...
598 /////////////////////////////////
601 OldLink slave = master.slaves.FindLink(this);
602 master.slaves.Delete(slave);
609 parent.childrenCycle.Remove(cycle);
611 parent.childrenOrder.Remove(order);
612 parent.children.Remove(this);
617 /////////////////////////////////
619 while((ptr = resources.first))
622 resources.Delete(ptr);
629 for(child = children.first; child; child = child.next)
631 // child.stopwatching(this, font);
633 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
634 // Don't want property here
635 *&child.parent = null;
638 while((slave = slaves.first))
640 // Don't want property here
641 *&((Window)slave.data).master = null;
642 slaves.Delete(slave);
645 // Because we do a decref in DestroyEx...
653 // Why was this commented?
654 //if(this != guiApp.desktop)
667 if(((subclass(Window))_class).pureVTbl)
669 if(_vTbl == _class._vTbl)
671 _vTbl = ((subclass(Window))_class).pureVTbl;
676 for(m = 0; m < _class.vTblSize; m++)
678 if(_vTbl[m] == _class._vTbl[m])
679 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
683 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
686 dirtyArea.Free(null);
687 renderArea.Free(null);
688 overRenderArea.Free(null);
689 clipExtent.Free(null);
690 scrollExtent.Free(null);
691 dirtyBack.Free(null);
695 tempExtents[0].Free(null);
696 tempExtents[1].Free(null);
697 tempExtents[2].Free(null);
698 tempExtents[3].Free(null);
703 //#if !defined(ECERE_VANILLA)
704 const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
706 if(this == activeDesigner)
710 const char * name = property::name;
711 return name ? name : "";
716 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
717 bool OnGetDataFromString(const char * string)
719 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
722 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
723 this = designer.form;
724 else if(!strcmpi(string, "(Desktop)"))
725 this = activeDesigner;
727 return activeDesigner.FindObject(&this, string);
733 // --- Window updates system ---
735 // Setup a bitmap for Redrawing on client area of Window
736 Surface Redraw(Box box)
738 Surface surface = null;
740 Box clientArea = this.clientArea;
744 mox.left -= clientStart.x;
745 mox.top -= clientStart.y;
746 mox.right -= clientStart.x;
747 mox.bottom -= clientStart.y;
749 mox.Clip(clientArea);
750 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
752 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
754 int x = absPosition.x + clientStart.x;
755 int y = absPosition.y + clientStart.y;
756 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
758 x -= rootWindow.clientStart.x;
759 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
761 if(!guiApp.fullScreenMode || is3D)
763 x -= rootWindow.absPosition.x;
764 y -= rootWindow.absPosition.y;
768 x += rootWindow.parent.clientStart.x;
769 y += rootWindow.parent.clientStart.y;
771 mox.left += rootWindow.parent.clientStart.x;
772 mox.top += rootWindow.parent.clientStart.y;
773 mox.right += rootWindow.parent.clientStart.x;
774 mox.bottom += rootWindow.parent.clientStart.y;
779 surface = display.GetSurface(x, y, mox);
782 surface.width = clientSize.w;
783 surface.height = clientSize.h;
789 // Setup a bitmap for Redrawing on full Window
790 Surface RedrawFull(Box box)
792 Surface surface = null;
800 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
802 int x = absPosition.x;
803 int y = absPosition.y;
804 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
806 x -= rootWindow.clientStart.x;
807 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
809 if(!guiApp.fullScreenMode || is3D)
811 x -= rootWindow.absPosition.x;
812 y -= rootWindow.absPosition.y;
815 x += rootWindow.parent.clientStart.x;
816 y += rootWindow.parent.clientStart.y;
818 mox.left += rootWindow.parent.clientStart.x;
819 mox.top += rootWindow.parent.clientStart.y;
820 mox.right += rootWindow.parent.clientStart.x;
821 mox.bottom += rootWindow.parent.clientStart.y;
826 surface = display.GetSurface(x, y, mox);
829 surface.width = size.w;
830 surface.height = size.h;
836 void FigureCaption(char * caption)
838 Window activeClient = null;
842 strcpy(caption, this.caption);
843 if(style.isDocument || fileName)
845 if(caption[0]) strcat(caption, " - ");
847 strcat(caption, fileName);
851 sprintf(title, "Untitled %d", documentID);
852 strcat(caption, title);
855 strcat(caption, " *");
860 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
862 if(activeClient && activeClient.state == maximized)
864 if(activeClient.caption)
866 if(caption[0]) strcat(caption, " - ");
867 strcat(caption, activeClient.caption);
869 if(activeClient.style.isDocument || activeClient.fileName)
871 if(caption[0]) strcat(caption, " - ");
872 strcat(caption, "[");
873 if(activeClient.fileName)
874 strcat(caption, activeClient.fileName);
878 sprintf(title, "Untitled %d", activeClient.documentID);
879 strcat(caption, title);
881 if(activeClient.modifiedDocument)
882 strcat(caption, " *");
883 strcat(caption, "]");
888 // Code for returning dirty from ScrollDisplay:
890 for(d = 0; d<scrollExtent.count; d++)
892 Box * box = &scrollExtent.boxes[d];
898 Min(box.right, box.left-scroll.x),box.bottom
900 dirtyArea.UnionBox(update);
906 Max(box.left, box.right-scroll.x), box.top,
907 box.right, box.bottom
909 dirtyArea.UnionBox(update);
917 box.right, Min(box.bottom, box.top-scroll.y),
919 dirtyArea.UnionBox(update);
925 box.left, Max(box.top, box.bottom-scroll.y),
926 box.right, box.bottom
928 dirtyArea.UnionBox(update);
933 void UpdateDecorations(void)
935 // TODO: *** TEMPORARY HACK ***
942 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
944 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
946 Update({ -clientStart.x,0, -1, clientSize.h-1 });
948 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
951 // Returns w & h for Position
952 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
954 Window parent = this.parent ? this.parent : guiApp.desktop;
955 int xOffset = 0, yOffset = 0;
956 int vpw = parent ? parent.clientSize.w : 0;
957 int vph = parent ? parent.clientSize.h : 0;
958 int pw = parent ? parent.clientSize.w : 0;
959 int ph = parent ? parent.clientSize.h : 0;
960 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
961 int x = anchor.left.distance, y = anchor.top.distance;
962 float ex = 0, ey = 0;
963 MinMaxValue ew = 0, eh = 0;
965 float cascadeW, cascadeH;
967 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
968 int addX = 0, addY = 0;
970 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
972 Window masterWindow = this;
973 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
976 if(master == guiApp.desktop)
977 masterWindow = guiApp.desktop.activeChild;
979 masterWindow = master.rootWindow;
980 if(!masterWindow) masterWindow = this;
982 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
983 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
986 pw = vpw = box.right - box.left + 1;
988 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
991 ph = vph = box.bottom - box.top + 1;
1007 vpw = pw = parent.size.w;
1008 vph = ph = parent.size.h;
1010 else if(!style.fixed /*|| style.isDocument*/)
1012 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1013 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1015 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1018 Desktop3D_FixSize(&pw, &ph);
1019 Desktop3D_FixSize(&vpw, &vph);
1022 if(pw < skinMinSize.w) pw = skinMinSize.w;
1023 if(ph < skinMinSize.h) ph = skinMinSize.h;
1024 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1025 if(vph < skinMinSize.h) vph = skinMinSize.h;
1027 // TODO: Must fix what we're snapping
1030 if(anchor.left.type)
1032 SNAPUP(x, textCellW);
1034 else if(anchor.right.type)
1036 SNAPDOWN(x, textCellW);
1041 SNAPUP(y, textCellH);
1043 else if(anchor.bottom.type)
1045 SNAPDOWN(y, textCellH);
1049 // This is required to get proper initial decoration size using native decorations on Windows
1050 #if defined(__WIN32__)
1051 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1052 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1054 GetDecorationsSize(&ew, &eh);
1056 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1058 // Leave room for non client windows (eventually dockable panels)
1060 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1061 for(win = parent.children.first; win; win = win.next)
1063 if(!win.nonClient && !win.isActiveClient && win.visible)
1065 Size size = win.size;
1066 Point pos = win.position;
1067 int left = pos.x, top = pos.y;
1068 int right = pos.x + size.w, bottom = pos.y + size.h;
1069 if(win.size.w > win.size.h)
1072 loY = Max(loY, bottom);
1073 else if(top > ph - ph / 4)
1074 hiY = Min(hiY, top);
1079 loX = Max(loX, right);
1080 else if(left > pw - pw / 4)
1081 hiX = Min(hiX, left);
1090 if(parent.sbv && !parent.sbv.style.hidden)
1091 pw += guiApp.currentSkin.VerticalSBW();
1092 if(parent.sbh && !parent.sbh.style.hidden)
1093 ph += guiApp.currentSkin.HorizontalSBH();
1095 if(anchor.left.type == cascade)
1097 w = (int)(pw * 0.80);
1098 h = (int)(ph * 0.80);
1100 else if(anchor.left.type >= vTiled)
1105 numTiling = parent.numPositions - parent.numIcons;
1106 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1107 if(anchor.left.type == vTiled)
1109 tilingH = (int)sqrt(numTiling);
1110 tilingW = numTiling / tilingH;
1114 tilingW = (int)sqrt(numTiling);
1115 tilingH = numTiling / tilingW;
1118 leftOver = numTiling - tilingH * tilingW;
1121 tilingSplit = (tilingW - leftOver) * tilingH;
1122 tilingLastH = tilingH+1;
1125 tilingSplit = numTiling;
1127 if(positionID >= tilingSplit)
1129 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1130 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1131 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1132 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1136 x = xOffset + pw * (positionID / tilingH) / tilingW;
1137 y = yOffset + ph * (positionID % tilingH) / tilingH;
1138 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1139 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1143 SNAPDOWN(x, textCellW);
1144 SNAPDOWN(y, textCellH);
1145 SNAPDOWN(x2, textCellW);
1146 SNAPDOWN(y2, textCellH);
1154 if(sizeAnchor.isClientW) w += ew;
1155 if(sizeAnchor.isClientH) h += eh;
1157 if(anchor.left.type == offset)
1158 x = anchor.left.distance;
1159 else if(anchor.left.type == relative)
1160 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1161 else if(anchor.right.type == relative)
1162 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1163 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1164 else if(anchor.right.type == offset)
1165 ex = vpw - anchor.right.distance;
1167 if(anchor.top.type == offset)
1168 y = anchor.top.distance;
1169 else if(anchor.top.type == relative)
1170 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1171 else if(anchor.bottom.type == relative)
1172 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1173 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1174 else if(anchor.bottom.type == offset)
1175 ey = vph - anchor.bottom.distance;
1177 if(anchor.left.type && anchor.right.type)
1179 switch(anchor.right.type)
1182 ex = pw * (1.0f-anchor.right.percent);
1183 w = Max((int)(ex + 0.5) - x, 0);
1186 ex = vpw - anchor.right.distance;
1187 w = Max((int)(ex + 0.5) - x, 0);
1191 if(anchor.top.type && anchor.bottom.type)
1193 switch(anchor.bottom.type)
1196 ey = ph * (1.0f-anchor.bottom.percent);
1197 h = Max((int)(ey + 0.5) - y, 0);
1200 ey = vph - anchor.bottom.distance;
1201 h = Max((int)(ey + 0.5) - y, 0);
1210 if(state == normal /*|| state == Hidden*/)
1212 bool addSbV = false, addSbH = false;
1214 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1215 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1217 w = Max(w, minSize.w);
1218 h = Max(h, minSize.h);
1219 w = Min(w, maxSize.w);
1220 h = Min(h, maxSize.h);
1222 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1224 if(w) w -= guiApp.currentSkin.VerticalSBW();
1227 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1229 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1233 if(!OnResizing(&w, &h))
1239 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1240 w += guiApp.currentSkin.VerticalSBW();
1241 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1242 h += guiApp.currentSkin.HorizontalSBH();
1244 w = Max(w, skinMinSize.w);
1245 h = Max(h, skinMinSize.h);
1258 SNAPDOWN(w, textCellW);
1259 SNAPDOWN(h, textCellH);
1262 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1264 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1267 (pw - w) / CASCADE_SPACE,
1268 (ph - h) / CASCADE_SPACE);
1274 cascW = (pw - w) / (numCascade-1);
1275 cascH = (ph - h) / (numCascade-1);
1276 SNAPDOWN(cascW, textCellW);
1277 SNAPDOWN(cascH, textCellH);
1278 cascadeW = (float)cascW;
1279 cascadeH = (float)cascH;
1283 numCascade = Max(numCascade, 2);
1284 cascadeW = (float)(pw - w) / (numCascade-1);
1285 cascadeH = (float)(ph - h) / (numCascade-1);
1288 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1289 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1291 else if(anchor.left.type < vTiled)
1293 if(!anchor.left.type || anchor.horz.type == middleRelative)
1295 if(!anchor.right.type)
1297 if(anchor.horz.type == middleRelative)
1298 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1300 x = vpw / 2 + anchor.horz.distance - w / 2;
1306 // case A_EDGE: x = x - w; break;
1308 if(!anchor.top.type || anchor.vert.type == middleRelative)
1310 if(!anchor.bottom.type)
1312 if(anchor.vert.type == middleRelative)
1313 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1315 y = vph / 2 + anchor.vert.distance - h / 2;
1321 // case A_EDGE: y = y - h; break;
1324 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1332 SNAPDOWN(x, textCellW);
1333 SNAPDOWN(y, textCellH);
1345 if(anchored && style.fixed && style.isActiveClient)
1350 void UpdateCaret(bool forceUpdate, bool erase)
1352 static Window lastWindow = null;
1353 static int caretX, caretY, caretSize;
1355 if(guiApp && guiApp.caretOwner == this)
1357 int x = caretPos.x - scroll.x;
1358 int y = caretPos.y - scroll.y;
1360 if((erase || this.caretSize) &&
1361 x >= clientArea.left && x <= clientArea.right &&
1362 y >= clientArea.top && y <= clientArea.bottom)
1366 guiApp.interfaceDriver.SetCaret(
1367 x + absPosition.x + clientStart.x,
1368 y + absPosition.y + clientStart.y, this.caretSize);
1369 guiApp.caretEnabled = true;
1371 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1375 if(lastWindow != this)
1377 updateBox.left = x + 1;
1379 updateBox.right = x + 2;
1380 updateBox.bottom = y + this.caretSize - 1;
1384 updateBox.left = Min(x + 1, caretX + 1);
1385 updateBox.top = Min(y, caretY);
1386 updateBox.right = Max(x + 2, caretX + 2);
1387 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1390 guiApp.caretOwner.Update(updateBox);
1397 caretSize = this.caretSize;
1403 guiApp.interfaceDriver.SetCaret(0,0,0);
1404 guiApp.caretEnabled = false;
1410 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1415 scrolledPos.x = position.x = x;
1416 scrolledPos.y = position.y = y;
1418 clientSize.w = size.w = w;
1419 clientSize.h = size.h = h;
1421 if(parent && !style.nonClient)
1423 //if(!style.fixed || style.isDocument)
1425 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1426 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1430 clientStart.x = clientStart.y = 0;
1432 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1434 //if(!activeClient || activeClient.state != maximized)
1435 if(!noAutoScrollArea)
1437 // Check if scroll area must be modified
1438 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1440 bool foundChild = false;
1442 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1443 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1444 for(child = children.first; child; child = child.next)
1446 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1447 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1449 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1450 w = Max(w, child.position.x + child.size.w);
1451 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1452 w = Max(w, Max(child.position.x, 0) + child.size.w);
1453 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1454 h = Max(h, child.position.y + child.size.h);
1455 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1456 h = Max(h, Max(child.position.y, 0) + child.size.h);
1461 if(foundChild && (w > cw || h > ch))
1463 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1465 int stepX = sbStep.x, stepY = sbStep.y;
1466 // Needed to make snapped down position match the skin's check of client area
1467 // against realvirtual
1470 SNAPDOWN(stepX, textCellW);
1471 SNAPDOWN(stepY, textCellH);
1472 stepX = Max(stepX, textCellW);
1473 stepY = Max(stepY, textCellH);
1475 if(scrollFlags.snapX)
1477 if(scrollFlags.snapY)
1480 reqScrollArea.w = w;
1481 reqScrollArea.h = h;
1484 else if(reqScrollArea.w || reqScrollArea.h)
1486 reqScrollArea.w = 0;
1487 reqScrollArea.h = 0;
1488 SetScrollPosition(0,0);
1493 // Automatic MDI Client Scrolling Area Adjustment
1494 if(parent && !parent.noAutoScrollArea)
1496 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1497 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1499 Window parent = this.parent;
1500 int w = parent.reqScrollArea.w;
1501 int h = parent.reqScrollArea.h;
1503 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1504 w = Max(w, position.x + size.w);
1505 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1506 w = Max(w, Max(position.x, 0) + size.w);
1507 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1508 h = Max(h, position.y + size.h);
1509 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1510 h = Max(h, Max(position.y, 0) + size.h);
1512 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1513 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1515 /*bool resize = false;
1516 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1517 // Needed to make snapped down position match the skin's check of client area
1518 // against realvirtual
1521 SNAPDOWN(stepX, textCellW);
1522 SNAPDOWN(stepY, textCellH);
1523 stepX = Max(stepX, textCellW);
1524 stepY = Max(stepY, textCellH);
1526 if(parent.scrollFlags.snapX)
1528 if(parent.scrollFlags.snapY)
1530 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1532 parent.reqScrollArea.w = w;
1533 parent.reqScrollArea.h = h;*/
1535 // parent.UpdateScrollBars(true, true);
1536 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1537 false, true, true, true, false, false);
1542 GetRidOfVirtualArea();
1546 UpdateScrollBars(modifyThisArea, false);
1547 else if(guiApp.currentSkin)
1550 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1552 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1553 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1554 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1555 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1558 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1559 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1561 absPosition = scrolledPos;
1562 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1563 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1565 if(this != guiApp.desktop && parent)
1567 absPosition.x += parent.absPosition.x;
1568 absPosition.y += parent.absPosition.y;
1569 if(!style.nonClient && this != guiApp.desktop)
1571 absPosition.x += parent.clientStart.x;
1572 absPosition.y += parent.clientStart.y;
1576 box = Box { 0, 0, size.w - 1, size.h - 1 };
1581 // Clip against parent's client area
1582 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1584 // Compute client area in this window coordinate system
1585 clientArea.left = 0;
1587 clientArea.right = clientSize.w - 1;
1588 clientArea.bottom = clientSize.h - 1;
1590 // Clip against parent's client area
1592 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1596 //absPosition.x -= parent.clientStart.x;
1597 //absPosition.y -= parent.clientStart.y;
1600 // Adjust all children
1601 for(child = children.first; child; child = child.next)
1602 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1604 UpdateCaret(false, false);
1607 void GetRidOfVirtualArea(void)
1609 if(parent && !parent.destroyed && style.fixed &&
1610 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1611 parent.reqScrollArea.w && parent.reqScrollArea.h)
1613 if(!parent.noAutoScrollArea)
1615 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1619 for(child = children.first; child; child = child.next)
1621 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1623 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1624 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1634 Window parent = this.parent;
1636 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1637 false, true, true, true, false, false);
1639 parent.SetScrollArea(0,0,true);
1640 parent.SetScrollPosition(0,0);
1646 public void ExternalPosition(int x, int y, int w, int h)
1648 Position(x, y, w, h, false, true, true, true, false, false);
1651 // (w, h): Full window size
1652 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1654 bool result = false;
1655 int oldCW = clientSize.w, oldCH = clientSize.h;
1656 bool clientResized, windowResized, windowMoved;
1658 //bool realResized = size.w != w || size.h != h;
1660 // TOCHECK: This wasn't in ecere.dll
1661 //if(!parent) return true;
1662 if(destroyed) return false;
1664 windowMoved = position.x != x || position.y != y || force;
1666 // windowResized = realResized || force;
1667 windowResized = size.w != w || size.h != h || force;
1669 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1675 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1676 scrolledPos.x - parent.clientStart.x + this.box.right,
1677 scrolledPos.y - parent.clientStart.y + this.box.bottom
1683 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1688 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1690 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1691 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1692 windowResized = true;
1694 if(display && rootWindow != this)
1697 if(guiApp && guiApp.windowMoving)
1699 if(guiApp.windowMoving.style.nonClient)
1700 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1702 guiApp.windowMoving.parent.SetMouseRangeToClient();
1712 // Buttons bitmap resources crash if we do this while switching mode
1713 if(!guiApp || !guiApp.modeSwitching)
1716 // Process Anchored Children
1720 for(child = children.first; child; child = child.next)
1723 ((child.stateAnchor.left.type != offset ||
1724 child.stateAnchor.top.type != offset ||
1725 child.stateAnchor.right.type != none ||
1726 child.stateAnchor.bottom.type != none) ||
1727 child.state == maximized || child.state == minimized))
1729 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1731 // child.Position(x, y, w, h, false, true, true, true, false);
1732 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1733 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1739 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1740 //if(updateScrollBars)
1742 OnResize(clientSize.w, clientSize.h);
1744 if((clientResized || windowMoved) && created)
1745 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1747 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1749 Window master = guiApp.interimWindow.master;
1750 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1753 if(rootWindow == this && !is3D)
1757 x -= guiApp.desktop.absPosition.x;
1758 y -= guiApp.desktop.absPosition.y;
1760 //guiApp.Log("Position %s\n", caption);
1763 if(windowResized || windowMoved)
1764 if(display && !display.flags.memBackBuffer && changeRootWindow)
1765 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1767 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1768 for(child = parent.children.first; child && child != this; child = child.next)
1769 if(child.rootWindow)
1770 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1775 if(windowMoved || windowResized)
1777 display.Lock(true /*false*/);
1780 display.Position(absPosition.x, absPosition.y);
1781 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1784 // result = realResized ? display.Resize(size.w, size.h) : true;
1785 if(nativeDecorations && rootWindow.windowHandle)
1787 int w = clientSize.w, h = clientSize.h;
1788 if(hasMenuBar) h += skinMenuHeight;
1789 if(hasStatusBar) h += statusBarHeight;
1790 if(sbv && sbv.visible) w += sbv.size.w;
1791 if(sbh && sbh.visible) h += sbh.size.h;
1792 result = manageDisplay ? display.Resize(w, h) : true;
1795 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1799 else if(clientResized)
1801 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1804 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1808 if(windowMoved || windowResized)
1813 if(guiApp.driver && changeRootWindow && windowHandle)
1815 if(windowResized || windowMoved)
1816 if(!display || display.flags.memBackBuffer)
1817 guiApp.interfaceDriver.PositionRootWindow(this,
1818 x, y, w, h, windowMoved, windowResized);
1819 guiApp.interfaceDriver.UpdateRootWindow(this);
1821 for(child = children.first; child; child = child.next)
1823 if(child.is3D && child.created)
1825 // Copy Display Content
1826 child.display.displaySystem = display.displaySystem;
1827 child.display.window = display.window;
1828 child.display.current = display.current;
1829 child.display.width = display.width;
1830 child.display.height = display.height;
1831 child.display.driverData = display.driverData;
1832 child.display.mutex = null;
1843 void UpdateScrollBars(bool flag, bool fullThing)
1846 bool resizeH = false, resizeV = false;
1847 bool scrolled = false;
1848 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1849 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1851 if(destroyed) return;
1852 if(guiApp.currentSkin)
1854 MinMaxValue cw = 0, ch = 0;
1855 bool sbvVisible, sbhVisible;
1856 int rangeH = 0, rangeV = 0;
1857 int positionH = 0, positionV;
1859 // First get client area with no respect to scroll bars
1864 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1866 if(scrollFlags.dontHide)
1869 cw -= guiApp.currentSkin.VerticalSBW();
1871 ch -= guiApp.currentSkin.HorizontalSBH();
1873 // Update the scrollbar visibility
1879 sbh.disabled = rangeH <= 1;
1880 if(sbh.style.hidden)
1890 sbv.disabled = rangeV <= 1;
1891 if(sbv.style.hidden)
1899 int oldHRange = sbh ? sbh.range : 0;
1900 int oldVRange = sbv ? sbv.range : 0;
1901 // Then start off with horizontal scrollbar range
1904 positionH = sbh.thumbPosition;
1911 SBSetTotal(sbh, rvw);
1914 ch -= guiApp.currentSkin.HorizontalSBH();
1917 // Do the same for vertical scrollbar
1920 positionV = sbv.thumbPosition;
1926 SBSetTotal(sbv, rvh);
1930 cw -= guiApp.currentSkin.VerticalSBW();
1931 // Maybe we need to set the range on the horizontal scrollbar again
1939 SBSetTotal(sbh, rvw);
1940 //sbh.Action(setRange, positionH, 0);
1941 if(rangeH <= 1 && sbh.range > 1)
1943 ch -= guiApp.currentSkin.HorizontalSBH();
1949 SBSetTotal(sbv, rvh);
1951 //sbv.Action(setRange, positionV, 0);
1956 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1957 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1960 // Update the scrollbar visibility
1961 if(!scrollFlags.dontHide)
1963 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1967 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1974 if(guiApp.currentSkin)
1981 sbhVisible = sbh.style.hidden ? true : false;
1983 sbvVisible = sbv.style.hidden ? true : false;
1985 // Do our resize here
1986 if(flag && (resizeH || resizeV) && fullThing)
1988 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1993 OnResize(clientSize.w, clientSize.h);
1999 sbh.visible = sbhVisible;
2001 sbv.visible = sbvVisible;
2003 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2004 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2007 sbh.pageStep = clientSize.w;
2009 sbv.pageStep = clientSize.h;
2011 // Notify doesn't handle setRange anymore... process it here
2014 int positionH = sbh.thumbPosition;
2015 if(scroll.x != positionH)
2017 OnHScroll(setRange, positionH, 0);
2021 SNAPDOWN(positionH, textCellW);
2022 scroll.x = positionH;
2028 int seen = clientSize.w, total = reqScrollArea.w;
2031 if(scrollFlags.snapX)
2032 SNAPDOWN(seen, sbStep.x);
2034 if(!total) total = seen;
2035 range = total - seen + 1;
2037 range = Max(range, 1);
2039 if(x >= range) x = range - 1;
2041 if(scrollFlags.snapX)
2042 SNAPUP(x, sbStep.x);
2046 OnHScroll(setRange, x, 0);
2051 SNAPDOWN(x, textCellW);
2057 int positionV = sbv.thumbPosition;
2058 if(scroll.y != positionV)
2060 OnVScroll(setRange, positionV, 0);
2064 SNAPDOWN(positionV, textCellH);
2065 scroll.y = positionV;
2071 int seen = clientSize.h, total = reqScrollArea.h;
2074 if(scrollFlags.snapY)
2075 SNAPDOWN(seen, sbStep.y);
2077 if(!total) total = seen;
2078 range = total - seen + 1;
2079 range = Max(range, 1);
2081 if(y >= range) y = range - 1;
2083 if(scrollFlags.snapY)
2084 SNAPUP(y, sbStep.y);
2088 OnVScroll(setRange, y, 0);
2093 SNAPDOWN(y, textCellH);
2099 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2102 for(child = children.first; child; child = child.next)
2104 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2107 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2108 child.Position(x, y, w, h, false, true, false, true, false, false);
2115 // Process Scrollbars
2117 if(sbh) // && !sbh.style.hidden
2120 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2121 // Need to set the range again (should improve...) since the scrollbars didn't have
2122 // the right size when UpdateScrollArea set the range on it
2125 sbh.seen = clientSize.w;
2129 if(sbv) // && !sbv.state.hidden
2132 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2133 // Need to set the range again (should improve...) since the scrollbars didn't have
2134 // the right size when UpdateScrollArea set the range on it
2137 sbv.seen = clientSize.h;
2142 // TESTING THIS LOWER
2143 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2146 for(child = children.first; child; child = child.next)
2148 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2151 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2152 child.Position(x, y, w, h, false, true, false, true, false, false);
2158 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2160 SetState(maximized, false, mods);
2164 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2166 SetState(normal, false, mods);
2170 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2172 SetState(minimized, false, mods);
2173 parent.CycleChildren(false, true, false, true);
2177 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2180 // Scroll bar notifications
2181 if(action != setRange)
2183 bool changed = false;
2187 if(scroll.x != position)
2189 OnHScroll(action, position, keyFlags);
2194 SNAPDOWN(position, textCellW);
2196 scroll.x = position;
2200 if(scroll.y != position)
2202 OnVScroll(action, position, keyFlags);
2207 SNAPDOWN(position, textCellH);
2209 scroll.y = position;
2213 bool childMove = false;
2214 for(child = children.first; child; child = child.next)
2216 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2219 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2220 child.Position(x, y, w, h, false, true, false, true, false, false);
2224 // Testing this patch out to solve MDI workspace redraw bugs
2225 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2226 // Scroll offsets to blame?
2230 UpdateCaret(false, false);
2234 // Testing this patch out to solve MDI workspace redraw bugs
2235 for(child = children.first; child; child = child.next)
2237 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2246 Window GetParentMenuBar()
2248 Window menuBarParent;
2249 if(formDesigner) return null;
2250 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2252 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2253 if(menuBarParent && !menuBarParent.isActiveClient)
2259 void CreateSystemChildren(void)
2261 Window parent = this;
2262 bool scrollBarChanged = false;
2263 bool hasClose = false, hasMaxMin = false;
2264 Point scroll = this.scroll;
2266 if(state == maximized)
2268 parent = GetParentMenuBar();
2275 if(style.hasClose) hasClose = true;
2276 if(style.hasMaximize || style.hasMinimize)
2283 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2285 sysButtons[2].Destroy(0);
2286 sysButtons[2] = null;
2288 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2290 sysButtons[1].Destroy(0);
2291 sysButtons[1] = null;
2293 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2295 sysButtons[0].Destroy(0);
2296 sysButtons[0] = null;
2299 if(hasClose && parent)
2306 parent, master = this,
2307 inactive = true, nonClient = true, visible = false;
2309 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2315 if(this.parent == guiApp.desktop)
2316 sysButtons[2].hotKey = altF4;
2317 else if(style.isActiveClient)
2318 sysButtons[2].hotKey = ctrlF4;
2319 sysButtons[2].Create();
2322 sysButtons[2].symbol = 'X';
2323 sysButtons[2].disabled = !style.hasClose;
2326 if(hasMaxMin && parent)
2330 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2331 if(state == maximized)
2334 method = RestoreButtonClicked;
2340 method = MaximizeButtonClicked;
2348 parent, master = this,
2349 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2351 sysButtons[1].Create();
2353 sysButtons[1].NotifyClicked = method;
2355 sysButtons[1].symbol = symbol;
2356 sysButtons[1].disabled = !style.hasMaximize;
2359 if(hasMaxMin && parent)
2363 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2364 if (state == minimized)
2367 method = RestoreButtonClicked;
2373 method = MinimizeButtonClicked;
2381 parent, master = this,
2382 hotKey = altM, inactive = true, nonClient = true, visible = false
2384 sysButtons[0].Create();
2386 sysButtons[0].NotifyClicked = method;
2388 sysButtons[0].symbol = symbol;
2389 sysButtons[0].disabled = !style.hasMinimize;
2392 // Create the scrollbars
2393 if(style.hasHorzScroll && !sbh)
2399 direction = horizontal,
2403 snap = scrollFlags.snapX,
2404 NotifyScrolling = ScrollBarNotification
2407 scrollBarChanged = true;
2409 else if(sbh && !style.hasHorzScroll)
2415 if(style.hasVertScroll && !sbv)
2421 direction = vertical,
2425 snap = scrollFlags.snapY,
2426 NotifyScrolling = ScrollBarNotification
2429 scrollBarChanged = true;
2431 else if(sbv && !style.hasVertScroll)
2436 if(scrollBarChanged)
2438 SetScrollLineStep(sbStep.x, sbStep.y);
2439 UpdateScrollBars(true, true);
2443 if(scrollBarChanged)
2445 if(sbh) sbh.thumbPosition = scroll.x;
2446 if(sbv) sbv.thumbPosition = scroll.y;
2450 void UpdateCaption(void)
2452 if(rootWindow == this)
2455 FigureCaption(caption);
2456 if(guiApp.interfaceDriver)
2457 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2459 UpdateDecorations();
2462 if(parent.activeClient == this) // Added this last check
2464 if(parent.rootWindow == parent)
2467 parent.FigureCaption(caption);
2468 if(guiApp.interfaceDriver)
2469 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2472 parent.UpdateCaption();
2474 parent.UpdateDecorations();
2478 void UpdateActiveDocument(Window previous)
2480 Window activeClient = this.activeClient;
2481 Window activeChild = this.activeChild;
2488 activeClient.CreateSystemChildren();
2490 previous.CreateSystemChildren();
2502 // Build window list
2505 Menu windowMenu = menu.FindMenu("Window");
2510 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2512 Window document = cycle.data;
2513 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2515 char name[2048], caption[2048];
2516 document.FigureCaption(caption);
2517 sprintf(name, "%d %s", id+1, caption);
2518 windowMenu.AddDynamic(MenuItem
2520 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2521 NotifySelect = MenuWindowSelectWindow
2525 if(activeClient.cycle == cycle) break;
2530 if((!previous && activeClient) || !activeClient)
2536 item = menu.FindItem(MenuWindowCloseAll, 0);
2537 if(item) item.disabled = false;
2538 item = menu.FindItem(MenuWindowNext, 0);
2539 if(item) item.disabled = false;
2540 item = menu.FindItem(MenuWindowPrevious, 0);
2541 if(item) item.disabled = false;
2542 item = menu.FindItem(MenuWindowCascade, 0);
2543 if(item) item.disabled = false;
2544 item = menu.FindItem(MenuWindowTileHorz, 0);
2545 if(item) item.disabled = false;
2546 item = menu.FindItem(MenuWindowTileVert, 0);
2547 if(item) item.disabled = false;
2548 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2549 if(item) item.disabled = false;
2550 item = menu.FindItem(MenuWindowWindows, 0);
2551 if(item) item.disabled = false;
2554 item = menu.FindItem(MenuFileClose, 0);
2555 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2556 item = menu.FindItem(MenuFileSaveAll, 0);
2557 if(item) item.disabled = numDocuments < 1;
2559 if(activeClient && activeClient.menu && activeClient.state != minimized)
2563 //activeClient.menu.Clean(activeClient);
2564 menu.Merge(activeClient.menu, true, activeClient);
2568 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2571 menu.Merge(activeChild.menu, true, activeChild);
2574 // This is called again for a child window change, with same active client
2575 OnActivateClient(activeClient, previous);
2576 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2577 parent.UpdateActiveDocument(null);
2580 void _ShowDecorations(Box box, bool post)
2582 if(rootWindow == this && nativeDecorations && !is3D) return;
2583 if(visible && this != guiApp.desktop)
2585 Surface surface = RedrawFull(box);
2589 FigureCaption(caption);
2592 ShowDecorations(captionFont.font,
2595 active, //parent.activeClient == this
2596 guiApp.windowMoving == this);
2598 PreShowDecorations(captionFont.font,
2601 active, //parent.activeClient == this
2602 guiApp.windowMoving == this);
2609 void UpdateExtent(Box refresh)
2611 Surface surface = null;
2613 if(!manageDisplay) { OnRedraw(null);return; }
2614 _ShowDecorations(refresh, false);
2616 surface = Redraw(refresh);
2617 // Opaque background: just fill before EW_REDRAW (clear?)
2620 surface.SetBackground(background);
2621 surface.SetForeground(foreground);
2622 surface.DrawingChar(' ');
2623 if(this == rootWindow)
2625 if(style.drawBehind || background.a)
2627 int a = background.a;
2628 // Premultiply alpha for clear color
2629 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2630 surface.Clear(colorBuffer);
2631 surface.SetBackground(background);
2634 else if(background.a)
2638 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2639 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2642 if(display.flags.alpha && background.a < 255 && background)
2644 surface.Area(0,0,clientSize.w, clientSize.h);
2645 /*if(style.clearDepthBuffer)
2646 surface.Clear(depthBuffer);*/
2648 else if(/*style.clearDepthBuffer || */background.a)
2650 int a = background.a;
2651 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2652 // Premultiply alpha for clear color
2653 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2654 surface.Clear(colorBuffer);
2655 surface.SetBackground(background);
2660 surface.TextFont(usedFont.font);
2661 surface.TextOpacity(false);
2665 // Draw the caret ...
2666 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2668 // surface.SetBackground(0xFFFFFF - background.color);
2669 surface.SetBackground(~background.color);
2671 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2672 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2678 void DrawOverChildren(Box refresh)
2680 Surface surface = Redraw(refresh);
2684 surface.DrawingChar(' ');
2685 surface.SetBackground(background);
2686 surface.SetForeground(foreground);
2688 surface.TextFont(usedFont.font);
2689 surface.TextOpacity(false);
2691 OnDrawOverChildren(surface);
2696 _ShowDecorations(refresh, true);
2699 void ComputeClipExtents(void)
2702 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2704 clipExtent.Copy(this.clipExtent);
2706 for(child = children.last; child; child = child.prev)
2708 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2710 bool opaque = child.IsOpaque(); // TODO: acess background directly
2711 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2713 child.clipExtent.Copy(clipExtent);
2714 child.clipExtent.Offset(-dx, -dy);
2715 child.clipExtent.IntersectBox(child.box);
2717 child.ComputeClipExtents();
2719 if(opaque && !child.style.nonClient)
2721 // Adjust the box for the parent:
2722 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2723 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2728 // ??? Only do this for overlapped window or if parent has with clip children flag
2730 // Do this if window has clip children flag on (default false?)
2731 // this.clipExtent = clipExtent;
2733 clipExtent.Free(null);
2736 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2739 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2740 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2742 offsetX -= rootWindow.clientStart.x;
2743 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2747 for(child = children.last; child; child = child.prev)
2749 bool opaque = child.IsOpaque();
2750 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2754 // Adjust renderArea to the root window level
2755 Extent * renderArea = &rootWindow.tempExtents[3];
2757 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2758 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2759 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2761 offsetX -= child.rootWindow.clientStart.x;
2762 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2766 Extent childRenderArea;
2768 if(backBufferUpdate != null)
2770 childRenderArea.Copy(backBufferUpdate);
2771 childRenderArea.Offset(-offsetX, -offsetY);
2774 childRenderArea.Copy(child.dirtyArea);
2776 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2777 renderArea.Copy(dirtyExtent);
2778 renderArea.Offset(-offsetX, -offsetY);
2779 childRenderArea.Union(renderArea);
2782 // Intersect with the clip extent
2783 childRenderArea.Intersection(child.clipExtent);
2786 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2788 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2789 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2791 renderArea->Offset(offsetX, offsetY);
2793 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2794 // overDirtyExtent.Union(renderArea);
2795 renderArea->Empty();
2796 // childRenderArea.Free();
2798 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2803 for(child = children.last; child; child = child.prev)
2805 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2807 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2812 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2814 bool opaque = IsOpaque();
2815 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2817 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2818 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2820 offsetX -= rootWindow.clientStart.x;
2821 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2825 for(child = children.last; child; child = child.prev)
2827 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2829 ColorAlpha background = *(ColorAlpha *)&child.background;
2830 bool opaque = child.IsOpaque();
2831 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2835 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2836 // Adjust renderArea to the root window level
2838 renderArea.Copy(child.dirtyArea);
2839 renderArea.Offset(offsetX, offsetY);
2840 dirtyExtent.Union(renderArea);
2841 overDirtyExtent.Union(renderArea);
2847 for(child = children.last; child; child = child.prev)
2849 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2851 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2855 if(backBufferUpdate != null)
2857 renderArea.Copy(backBufferUpdate);
2858 renderArea.Offset(-offsetX, -offsetY);
2860 overRenderArea.Copy(backBufferUpdate);
2861 overRenderArea.Offset(-offsetX, -offsetY);
2867 renderArea.Copy(dirtyArea);
2869 overRenderArea.Copy(dirtyArea);
2872 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2873 dirtyExtentWindow->Copy(dirtyExtent);
2874 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2875 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2876 dirtyExtentWindow->Empty();
2878 // Intersect with the clip extent
2879 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2882 if(renderArea.count > 10)
2885 printf("\nToo many extents (%d):\n", renderArea.count);
2887 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2888 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2893 for(c = 0; c<10; c++)
2896 FASTLIST_LOOP(renderArea, extentBox)
2898 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2900 renderArea.Copy(extent);
2902 FASTLIST_LOOP(renderArea, extentBox)
2905 printf("(%d, %d) - (%d, %d)\n",
2906 extentBox.box.left, extentBox.box.top,
2907 extentBox.box.right, extentBox.box.bottom);
2911 printf("\nNow %d\n", renderArea.count);
2917 // WHY WAS THIS COMMENTED ??
2919 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2920 dirtyExtentWindow->Copy(overDirtyExtent);
2921 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2922 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2923 dirtyExtentWindow->Empty();
2925 // Intersect with the clip extent
2926 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2932 if(scrollExtent.count)
2934 // Subtract render extent from scrolling extent
2935 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2937 if(backBufferUpdate == null)
2939 Extent * dirty = &rootWindow.tempExtents[3];
2942 // Intersect scrolling extent with clip extent
2943 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2945 // offset this scroll to be at the root window level
2946 scrollExtent.Offset(offsetX, offsetY);
2947 // Add area that was scrolled to the dirty extents of the back buffer
2948 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2952 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2953 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2954 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2959 scrollExtent.Empty();
2961 // Add the exposed extent to the window render area
2962 dirty->Offset(-offsetX, -offsetY);
2963 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2968 // Subtract the window's box from the transparency forced extent
2969 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2975 renderArea.Copy(this.renderArea);
2976 renderArea.Offset(offsetX, offsetY);
2977 dirtyExtent.Union(renderArea);
2983 Extent renderArea { };
2985 renderArea.Copy(overRenderArea);
2986 renderArea.Offset(offsetX, offsetY);
2987 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2992 if(backBufferUpdate != null)
2994 // Remove render area from dirty area
2995 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2997 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3004 // Remove the window render area from the dirty extents of the back buffer
3005 rootWindow.dirtyBack.Exclusion(renderArea);
3009 void Render(Extent updateExtent)
3013 Window rootWindow = this.rootWindow;
3014 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3015 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3017 offsetX -= rootWindow.clientStart.x;
3018 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3021 if(rootWindow.fullRender)
3030 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3031 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3036 /*if(renderArea.count)
3037 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3040 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3042 Box box = extentBox.box;
3045 /*printf("(%d, %d) - (%d, %d)\n",
3046 extentBox.box.left, extentBox.box.top,
3047 extentBox.box.right, extentBox.box.bottom);*/
3052 box.left += offsetX;
3054 box.right += offsetX;
3055 box.bottom += offsetY;
3057 if(updateExtent != null)
3058 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3062 for(child = children.first; child; child = child.next)
3063 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3064 child.Render(updateExtent);
3066 if(rootWindow.fullRender)
3067 DrawOverChildren(box);
3070 // TO DO: There's an issue about draw over children...
3071 // TO DO: Don't wanna go through this if method isn't used
3072 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3073 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3075 Box box = extentBox.box;
3077 DrawOverChildren(box);
3079 box.left += offsetX;
3081 box.right += offsetX;
3082 box.bottom += offsetY;
3084 if(updateExtent != null)
3085 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3088 for(child = children.first; child; child = child.next)
3089 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3090 child.Render(updateExtent);
3093 overRenderArea.Empty();
3096 public void UpdateDisplay(void)
3098 if(!manageDisplay) { OnRedraw(null);return; }
3099 if(rootWindow && this != rootWindow)
3100 rootWindow.UpdateDisplay();
3103 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3104 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3107 dirtyExtent.Clear();
3110 clipExtent.AddBox(box);
3112 display.StartUpdate();
3114 if(!rootWindow.fullRender)
3116 ComputeClipExtents();
3117 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3118 ComputeRenderArea(dirtyExtent, overExtent, null);
3121 clipExtent.Free(null);
3123 dirtyExtent.Free(null);
3124 overExtent.Free(null);
3126 if(display.flags.flipping)
3129 display.Update(null);
3133 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3134 updateExtent.Clear();
3136 Render(updateExtent);
3138 updateExtent.UnionBox(this.box, tempExtents[0]);
3141 //printf("\n\nUpdate:\n------------------------------------------\n");
3144 //FASTLIST_LOOP(updateExtent, extentBox)
3145 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3148 /*printf("Updating (%d, %d) - (%d, %d)\n",
3149 extentBox.box.left, extentBox.box.top,
3150 extentBox.box.right, extentBox.box.bottom);*/
3153 display.Update(extentBox.box);
3156 updateExtent.Free(null);
3159 display.EndUpdate();
3167 void UpdateBackDisplay(Box box)
3173 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3175 //printf("UpdateBackDisplay going through!\n");
3176 display.StartUpdate();
3180 intersection.Copy(dirtyBack);
3181 intersection.IntersectBox(box);
3183 dirtyExtent.Clear();
3186 clipExtent.AddBox(box);
3188 if(!rootWindow.fullRender)
3190 ComputeClipExtents();
3191 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3194 clipExtent.Free(null);
3196 intersection.Free(null);
3197 dirtyExtent.Free(null);
3198 overExtent.Free(null);
3203 if(display.flags.flipping)
3204 display.Update(null);
3207 rootWindow.display.Update(box);
3210 display.EndUpdate();
3214 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3215 if(dirtyBack.count > MAX_DIRTY_BACK)
3217 BoxItem extentBox, next;
3218 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3219 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3221 next = (BoxItem)extentBox.next;
3222 if(extentBox != first)
3224 if(extentBox.box.left < first.box.left)
3225 first.box.left = extentBox.box.left;
3226 if(extentBox.box.top < first.box.top)
3227 first.box.top = extentBox.box.top;
3228 if(extentBox.box.right > first.box.right)
3229 first.box.right = extentBox.box.right;
3230 if(extentBox.box.bottom > first.box.bottom)
3231 first.box.bottom = extentBox.box.bottom;
3232 dirtyBack.Delete(extentBox);
3241 // --- Window positioning ---
3242 // --- Window identification ---
3244 // Returns window at position "Position"
3245 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3247 Window child, result = null;
3249 box.left += absPosition.x;
3250 box.right += absPosition.x;
3251 box.top += absPosition.y;
3252 box.bottom += absPosition.y;
3254 if(!destroyed && visible && (acceptDisabled || !disabled))
3256 int lx = x - absPosition.x;
3257 int ly = y - absPosition.y;
3258 if(IsInside(lx, ly))
3259 // if(box.IsPointInside(Point{x, y}))
3261 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3262 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3265 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3266 Window ancestor = null;
3268 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3269 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3271 if(child != statusBar && child.rootWindow == rootWindow)
3273 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3280 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3282 if(child != statusBar && child.rootWindow == rootWindow)
3284 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3291 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3299 Window FindModal(void)
3301 Window modalWindow = this, check;
3302 Window check2 = null;
3303 for(check = this; check.master; check = check.master)
3305 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3307 modalWindow = check.master.modalSlave;
3308 check = modalWindow;
3310 // TESTING THIS FOR DROPBOX...
3311 if(!rootWindow || !rootWindow.style.interim)
3313 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3315 if(check2.modalSlave && check2.modalSlave.created)
3317 modalWindow = check2.modalSlave;
3325 if(modalWindow == this)
3327 for(check = this; check.activeChild; check = check.activeChild)
3329 if(check.modalSlave)
3331 modalWindow = check.modalSlave;
3337 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3338 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3341 void StopMoving(void)
3343 if(this == guiApp.windowMoving)
3345 guiApp.windowMoving = null;
3346 UpdateDecorations();
3347 SetMouseRange(null);
3350 if(rootWindow.active)
3351 guiApp.interfaceDriver.StopMoving(rootWindow);
3354 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3355 guiApp.windowIsResizing = false;
3359 void SelectMouseCursor(void)
3364 Window cursorWindow = null;
3365 bool rx, ry, rex, rey;
3367 guiApp.desktop.GetMousePosition(&x, &y);
3368 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3370 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3371 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3372 else if(mouseWindow)
3374 modalWindow = mouseWindow.FindModal();
3375 x -= mouseWindow.absPosition.x;
3376 y -= mouseWindow.absPosition.y;
3377 if(guiApp.windowIsResizing)
3379 rex = guiApp.resizeEndX;
3380 rey = guiApp.resizeEndY;
3381 rx = guiApp.resizeX;
3382 ry = guiApp.resizeY;
3383 if((rex && rey) || (rx && ry))
3384 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3385 else if((rex && ry) || (rx && rey))
3386 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3387 else if((ry || rey) && (!rx && !rex))
3388 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3389 else if((rx || rex) && (!ry && !rey))
3390 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3392 else if(!modalWindow && !guiApp.windowCaptured &&
3393 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3394 &rx, &ry, &rex, &rey))
3396 if((rex && rey) || (rx && ry))
3397 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3398 else if((rex && ry) || (rx && rey))
3399 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3400 else if((ry || rey) && (!rx && !rex))
3401 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3402 else if((rx || rex) && (!ry && !rey))
3403 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3405 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3407 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3408 mouseWindow.rootWindow != mouseWindow)
3409 cursorWindow = mouseWindow.parent;
3411 cursorWindow = mouseWindow;
3413 else if(!guiApp.interimWindow)
3414 cursorWindow = guiApp.windowCaptured;
3417 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3418 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3420 else if(modalWindow)
3422 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3424 else if(guiApp.interimWindow)
3426 if(guiApp.interimWindow.cursor)
3427 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3429 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3434 // --- State based input ---
3435 bool AcquireInputEx(bool state)
3440 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3441 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3443 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3445 guiApp.acquiredWindow = state ? this : null;
3448 SetMouseRangeToClient();
3449 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3454 SelectMouseCursor();
3456 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3460 // --- Window activation ---
3461 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3464 if(!parent || !parent.style.inactive)
3466 Window parent = this.parent;
3469 if(rootWindow == this)
3470 Log(active ? "active\n" : "inactive\n");
3472 if(active && requireRemaximize)
3474 if(state == maximized)
3476 property::state = normal;
3477 property::state = maximized;
3479 requireRemaximize = false;
3482 // Testing this here...
3483 if(!parent || parent == guiApp.desktop || parent.active)
3485 this.active = active;
3488 // TESTING THIS HERE
3489 UpdateDecorations();
3490 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3491 result = NotifyActivate(master, this, active, previous);
3494 this.active = !active;
3499 if(!parent || parent == guiApp.desktop || parent.active)
3501 this.active = active;
3503 AcquireInputEx(active);
3504 if(active && isEnabled)
3508 if(guiApp.caretOwner)
3512 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3513 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3514 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3515 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3517 guiApp.caretOwner.Update(extent);
3520 if(visible || !guiApp.caretOwner)
3521 guiApp.caretOwner = this;
3522 UpdateCaret(false, false);
3528 this.active = false;
3530 AcquireInputEx(active);
3532 if(!active && guiApp.caretOwner == this)
3534 UpdateCaret(false, true);
3535 guiApp.caretOwner = null;
3536 guiApp.interfaceDriver.SetCaret(0,0,0);
3537 guiApp.caretEnabled = false;
3542 if(!active && parent && parent.activeChild && parent.activeChild != this)
3543 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3549 if(!active && menuBar)
3552 menuBar.OnActivate(false, null, &goOn, true);
3553 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3558 Window aChild = activeChild;
3560 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3572 void ConsequentialMouseMove(bool kbMoving)
3576 if(kbMoving || !guiApp.windowMoving)
3580 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3582 if(guiApp.interfaceDriver)
3583 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3585 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3586 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3592 bool IsDescendantOf(Window ancestor)
3595 for(window = this; window && window != ancestor; window = window.parent);
3596 return window == ancestor;
3599 bool IsSlaveOf(Window master)
3602 for(window = this; window && window != master; window = window.master);
3603 return window == master;
3606 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3610 if(this && !destroyed /*&& state != Hidden*/)
3612 Window swap = externalSwap;
3620 if(activateParent &&
3621 (parent.activeChild != this ||
3622 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3623 active && _isModal &&
3624 parent != master && master)
3625 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3631 bool real = parent.activeChild != this;
3633 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3634 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3635 !IsDescendantOf(guiApp.interimWindow) &&
3636 !IsSlaveOf(guiApp.interimWindow))
3638 Window interimWindow = guiApp.interimWindow;
3639 while(interimWindow && interimWindow != this)
3641 Window master = interimWindow.master;
3643 guiApp.interimWindow = null;
3644 if(guiApp.caretOwner)
3645 guiApp.caretOwner.UpdateCaret(false, false);
3647 incref interimWindow;
3648 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3653 delete interimWindow;
3654 interimWindow = (master && master.style.interim) ? master : null;
3659 guiApp.interimWindow = this;
3660 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3661 guiApp.caretEnabled = false;*/
3662 UpdateCaret(false, true);
3667 //bool acquireInput = false;
3669 parent.activeChild &&
3670 parent.activeChild.state == maximized &&
3671 parent != guiApp.desktop;
3673 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3678 swap = parent.activeChild;
3679 if(swap && swap.destroyed) swap = null;
3680 if(swap && swap != this)
3683 if(!swap.PropagateActive(false, this, &goOn, true))
3684 swap = parent.activeChild;
3695 if(!parent || parent.activeChild != this || style.interim)
3698 result = PropagateActive(true, swap, &goOn, true);
3699 if(!result && !goOn)
3704 //acquireInput = true;
3708 if(style.hasMaximize && parent != guiApp.desktop)
3711 SetState(maximized, false, 0);
3712 else if(state != maximized)
3715 for(child = parent.children.first; child; child = child.next)
3717 if(this != child && child.state == maximized)
3718 child.SetState(normal, false, 0);
3725 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3727 Window previous = parent.activeClient;
3728 parent.activeChild = this;
3729 if(!style.nonClient /*&& style.isActiveClient*/)
3733 if(style.isActiveClient)
3734 parent.activeClient = this;
3735 // Moved UpdateActiveDocument inside hidden check
3736 // To prevent activating previous window while creating a new one
3737 // (It was messing up the privateModule in the CodeEditor)
3738 parent.UpdateActiveDocument(previous);
3744 //if(!style.isRemote)
3746 if(rootWindow != this)
3748 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3749 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3751 else if(!guiApp.fullScreenMode)
3753 Window modalRoot = FindModal();
3754 if(!modalRoot) modalRoot = this;
3755 if(!modalRoot.isForegroundWindow)
3757 modalRoot.isForegroundWindow = true;
3758 // To check : Why is parent null?
3759 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3761 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3763 modalRoot.isForegroundWindow = false;
3768 if(result && real && (!style.inactive || moveInactive) && parent)
3770 Window last = parent.children.last;
3772 if(!style.stayOnTop)
3773 for(; last && last.style.stayOnTop; last = last.prev);
3775 parent.children.Move(this, last);
3777 // Definitely don't want that: why not?
3781 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3787 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3794 parent.activeChild = null;
3795 if(!style.nonClient /*&& style.isActiveClient*/)
3797 Window previous = parent.activeClient;
3798 if(style.isActiveClient)
3799 parent.activeClient = null;
3800 parent.UpdateActiveDocument(previous);
3804 if(this == guiApp.interimWindow)
3806 guiApp.interimWindow = null;
3807 if(guiApp.caretOwner)
3808 guiApp.caretOwner.UpdateCaret(false, false);
3810 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3817 if(!active || !swap)
3818 UpdateDecorations();
3820 swap.UpdateDecorations();
3822 if(active && rootWindow != this)
3823 ConsequentialMouseMove(false);
3830 // --- Input Messages ---
3831 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3833 static bool reEntrancy = false;
3834 if(reEntrancy) return;
3838 guiApp.cursorUpdate = true;
3839 if(guiApp.windowScrolling && !consequential)
3841 guiApp.windowScrolling.SetScrollPosition(
3842 (guiApp.windowScrolling.sbh) ?
3843 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3844 (guiApp.windowScrolling.sbv) ?
3845 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3847 if(guiApp.windowMoving)
3849 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3851 Window window = guiApp.windowMoving;
3853 int w = window.size.w;
3854 int h = window.size.h;
3859 rx = mouseX - guiApp.windowMovingStart.x;
3860 ry = mouseY - guiApp.windowMovingStart.y;
3863 window.GetDecorationsSize(&ew, &eh);
3865 if(guiApp.windowIsResizing)
3867 x = window.scrolledPos.x;
3868 y = window.scrolledPos.y;
3872 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3873 rx = guiApp.windowResizingBefore.w - aw;
3874 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3875 w = guiApp.windowResizingBefore.w - rx;
3879 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3880 ry = guiApp.windowResizingBefore.h - ah;
3881 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3882 ry = Max(ry, -guiApp.windowMovingBefore.y);
3883 h = guiApp.windowResizingBefore.h - ry;
3885 if(guiApp.resizeEndX)
3887 w = guiApp.windowResizingBefore.w + rx;
3890 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3898 w = Max(w, window.minSize.w);
3899 h = Max(h, window.minSize.h);
3900 w = Min(w, window.maxSize.w);
3901 h = Min(h, window.maxSize.h);
3903 if(!window.OnResizing(&w, &h))
3905 w = window.clientSize.w;
3906 h = window.clientSize.h;
3909 w = Max(w, window.skinMinSize.w);
3910 h = Max(h, window.skinMinSize.h);
3917 SNAPDOWN(w, textCellW);
3918 SNAPDOWN(h, textCellH);
3923 aw = Max(w,window.skinMinSize.w);
3924 rx = guiApp.windowResizingBefore.w - aw;
3925 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3926 w = guiApp.windowResizingBefore.w - rx;
3930 ah = Max(h,window.skinMinSize.h);
3931 ry = guiApp.windowResizingBefore.h - ah;
3932 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3933 ry = Max(ry, -guiApp.windowMovingBefore.y);
3934 h = guiApp.windowResizingBefore.h - ry;
3939 if(!guiApp.windowIsResizing || guiApp.resizeX)
3940 x = guiApp.windowMovingBefore.x + rx;
3941 if(!guiApp.windowIsResizing || guiApp.resizeY)
3942 y = guiApp.windowMovingBefore.y + ry;
3944 if(!guiApp.windowIsResizing)
3947 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3949 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3950 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3951 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3952 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3956 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3957 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3963 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3965 if(!window.OnMoving(&x, &y, w, h))
3967 x = window.scrolledPos.x;
3968 y = window.scrolledPos.y;
3974 SNAPDOWN(x, textCellW);
3975 SNAPDOWN(y, textCellH);
3978 if(!window.style.nonClient)
3980 if(!window.style.fixed /*|| window.style.isDocument*/)
3982 if(!window.style.dontScrollHorz)
3983 x += window.parent.scroll.x;
3984 if(!window.style.dontScrollVert)
3985 y += window.parent.scroll.y;
3989 // Break the anchors for moveable/resizable windows
3990 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3991 if(window.style.fixed)
3993 if(window.state == normal)
3995 window.normalAnchor = Anchor { left = x, top = y };
3996 window.normalSizeAnchor = SizeAnchor { { w, h } };
3997 window.anchored = false;
4001 window.stateAnchor = Anchor { left = x, top = y };
4002 window.stateSizeAnchor = SizeAnchor { { w, h } };
4004 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4005 // TOCHECK: Investigate why the following only redraws the scrollbars
4006 //window.Position(x, y, w, h, false, true, true, true, false, true);
4008 guiApp.movingLast.x = mouseX;
4009 guiApp.movingLast.y = mouseY;
4015 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4018 bool wasMoving = guiApp.windowMoving ? true : false;
4019 bool wasScrolling = guiApp.windowScrolling ? true : false;
4021 while(result && w != this)
4023 Window msgWindow = GetAtPosition(x,y, false, true, w);
4024 Window trueWindow = GetAtPosition(x,y, false, false, w);
4025 bool windowDragged = false;
4030 window = (w && !w.disabled) ? w : null;
4032 if(trueWindow) incref trueWindow;
4034 if(consequential) mods->isSideEffect = true;
4036 UpdateMouseMove(x, y, consequential);
4038 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4040 if(!guiApp.windowCaptured.isEnabled)
4041 guiApp.windowCaptured.ReleaseCapture();
4043 window = guiApp.windowCaptured;
4046 if(trueWindow && activate &&
4047 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4048 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4049 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4050 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4052 if(mods->alt && !mods->ctrl && !mods->shift)
4054 Window moved = trueWindow;
4055 for(moved = trueWindow; moved; moved = moved.parent)
4056 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4061 windowDragged = true;
4063 // Cancel the ALT menu toggling...
4064 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4069 if(window && activate &&
4070 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4071 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4072 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4073 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4075 Window modalWindow = window.FindModal();
4077 /*if(mods->alt && !mods->shift && !mods->ctrl)
4079 Window moved = window;
4080 for(moved = window; moved; moved = moved.parent)
4081 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4086 windowDragged = true;
4088 // Cancel the ALT menu toggling...
4089 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4095 Window activateWindow = modalWindow ? modalWindow : window;
4096 if(activateWindow && !activateWindow.isRemote)
4098 bool doActivation = true;
4099 //bool needToDoActivation = false;
4100 Window check = activateWindow;
4102 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4104 if(!check.style.inactive)
4106 //needToDoActivation = true;
4108 doActivation = false;
4113 if(!needToDoActivation)
4114 doActivation = false;
4117 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4118 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4120 // Let the OnLeftButtonDown do the activating instead
4121 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4129 incref activateWindow;
4130 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4132 delete activateWindow;
4136 if(activateWindow._refCount == 1)
4138 delete activateWindow;
4142 delete activateWindow;
4143 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4146 mods->isActivate = true;
4150 if(!modalWindow && window && !window.destroyed)
4152 if(!guiApp.windowCaptured || windowDragged)
4154 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4156 bool moving = ((window.state != maximized &&
4157 window.IsMouseMoving(
4158 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4159 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4161 if(!moving && window.IsMouseResizing(
4162 x - window.absPosition.x,
4163 y - window.absPosition.y,
4164 window.size.w, window.size.h,
4165 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4167 guiApp.windowIsResizing = true;
4168 guiApp.windowResizingBefore.w = window.size.w;
4169 guiApp.windowResizingBefore.h = window.size.h;
4171 if(guiApp.windowIsResizing || windowDragged || moving)
4174 guiApp.windowMoving = window;
4175 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4176 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4177 guiApp.windowMovingBefore.x = window.position.x;//s;
4178 guiApp.windowMovingBefore.y = window.position.y;//s;
4179 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4180 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4183 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4185 if(window.style.fixed &&
4187 window.IsMouseMoving(
4188 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4190 window.ShowSysMenu(x, y);
4194 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4196 if(window.sbv || window.sbh)
4199 guiApp.windowScrolling = window;
4200 guiApp.windowScrollingStart.x = x;
4201 guiApp.windowScrollingStart.y = y;
4202 guiApp.windowScrollingBefore.x = window.scroll.x;
4203 guiApp.windowScrollingBefore.y = window.scroll.y;
4206 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4208 if(window.style.hasMaximize &&
4209 window.IsMouseMoving(
4210 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4213 (window.state == maximized) ? normal : maximized, false, *mods);
4221 if(guiApp.windowMoving)
4223 if(guiApp.windowMoving.parent)
4225 if(guiApp.windowMoving.style.nonClient)
4226 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4228 guiApp.windowMoving.parent.SetMouseRangeToClient();
4232 window.UpdateDecorations();
4235 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4237 // Log("\n*** LEFT BUTTON UP ***\n");
4238 if(guiApp.windowMoving)
4239 guiApp.windowMoving.StopMoving();
4241 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4243 if(guiApp.windowScrolling)
4245 Window windowScrolling = guiApp.windowScrolling;
4246 guiApp.windowScrolling = null;
4247 windowScrolling.ReleaseCapture();
4251 if(!result || (window && window.destroyed)) window = null;
4253 if(window && window.FindModal())
4256 if(trueWindow && trueWindow.FindModal())
4264 msgWindow = GetAtPosition(x,y, true, false);
4266 msgWindow.SelectMouseCursor();
4269 if(guiApp.windowCaptured || trueWindow)
4271 Window prevWindow = guiApp.prevWindow;
4272 List<Window> overWindows = guiApp.overWindows;
4273 Iterator<Window> it { overWindows };
4278 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4281 result = w.OnMouseLeave(*mods);
4283 overWindows.TakeOut(w);
4287 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4289 guiApp.prevWindow.mouseInside = false;
4290 guiApp.prevWindow = null;
4294 if(trueWindow.IsDescendantOf(prevWindow))
4296 if(!overWindows.Find(prevWindow))
4297 overWindows.Add(prevWindow);
4299 // Eventually fix this not to include captured?
4300 else if(!prevWindow.OnMouseLeave(*mods))
4304 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4306 Box box = trueWindow.box;
4307 box.left += trueWindow.absPosition.x;
4308 box.right += trueWindow.absPosition.x;
4309 box.top += trueWindow.absPosition.y;
4310 box.bottom += trueWindow.absPosition.y;
4312 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4314 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4315 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4317 overX = Max(Min(overX, 32767),-32768);
4318 overY = Max(Min(overY, 32767),-32768);
4320 trueWindow.mouseInside = true;
4321 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4325 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4327 for(w : guiApp.overWindows; w == trueWindow)
4330 guiApp.overWindows.TakeOut(w);
4333 guiApp.prevWindow = trueWindow;
4336 guiApp.prevWindow = null;
4338 SelectMouseCursor();
4340 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4341 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4343 int clientX = x - (window.absPosition.x + window.clientStart.x);
4344 int clientY = y - (window.absPosition.y + window.clientStart.y);
4346 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4348 clientX = Max(Min(clientX, 32767),-32768);
4349 clientY = Max(Min(clientY, 32767),-32768);
4351 MouseMethod = (void *)window._vTbl[method];
4353 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4356 if(!MouseMethod(window, clientX, clientY, *mods))
4363 if(result && w && w.clickThrough && w.parent)
4368 if(!result || !w || !w.clickThrough)
4375 // --- Mouse cursor management ---
4377 bool KeyMessage(uint method, Key key, unichar character)
4382 if(guiApp.interimWindow)
4383 this = guiApp.interimWindow;
4386 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4390 if(!style.inactive || rootWindow != this)
4392 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4393 Window modalWindow = FindModal();
4394 Window interimMaster = master ? master.rootWindow : null;
4398 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4399 status = OnSysKeyDown(key, character);
4400 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4401 status = OnSysKeyHit(key, character);
4402 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4403 status = OnSysKeyUp(key, character);
4410 // Process Key Message for Internal UI Keyboard actions
4411 if(status && !destroyed && menuBar && state != minimized)
4414 if((SmartKey)key != alt)
4415 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4418 SmartKey sk = (SmartKey) key;
4419 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4421 status = menuBar.KeyMessage(method, key, character);
4426 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4427 menuBar.OnKeyHit(escape, 0);
4429 if(!menuBar.focus && guiApp.caretOwner)
4430 guiApp.caretOwner.UpdateCaret(true, false);
4433 if(!destroyed && status)
4435 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4439 case left: case up: case right: case down:
4440 if(guiApp.windowMoving == this)
4443 int w = guiApp.windowMoving.size.w;
4444 int h = guiApp.windowMoving.size.h;
4445 int x = guiApp.windowMoving.scrolledPos.x;
4446 int y = guiApp.windowMoving.scrolledPos.y;
4450 if(key == down || key == up)
4451 step = Max(step, textCellH);
4453 step = Max(step, textCellW);
4456 if(guiApp.windowIsResizing)
4460 case left: w-=step; break;
4461 case right: w+=step; break;
4462 case up: h-=step; break;
4463 case down: h+=step; break;
4470 case left: x-=step; break;
4471 case right: x+=step; break;
4472 case up: y-=step; break;
4473 case down: y+=step; break;
4477 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4478 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4480 if(!guiApp.windowIsResizing || guiApp.resizeX)
4481 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4483 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4485 if(!guiApp.windowIsResizing || guiApp.resizeY)
4486 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4488 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4490 guiApp.interfaceDriver.SetMousePosition(x, y);
4491 ConsequentialMouseMove(true);
4499 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4501 guiApp.windowMoving.StopMoving();
4502 ConsequentialMouseMove(false);
4510 ShowSysMenu(absPosition.x, absPosition.y);
4518 if(!destroyed && status && state != minimized)
4520 // Process all the way down the children
4521 if(activeChild && !activeChild.disabled)
4523 status = activeChild.KeyMessage(method, key, character);
4525 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4526 key.code != left && key.code != right && key.code != up && key.code != down)
4528 status = activeClient.KeyMessage(method, key, character);
4532 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4534 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4535 // && defaultControl != activeChild)
4537 delete previousActive;
4538 previousActive = activeChild;
4539 if(previousActive) incref previousActive;
4541 ConsequentialMouseMove(false);
4542 if((defaultControl.active ||
4543 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4544 defaultControl.KeyMessage(method, defaultKey, character);
4550 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4552 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4559 ShowSysMenu(absPosition.x, absPosition.y);
4566 if(this != guiApp.desktop)
4568 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4570 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4572 MenuMoveOrSize(key.shift, true);
4576 else if(guiApp.windowMoving)
4578 guiApp.windowMoving.StopMoving();
4579 ConsequentialMouseMove(false);
4587 if(!destroyed && status && state != minimized)
4589 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4593 case tab: case shiftTab:
4595 Window cycleParent = this;
4596 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4597 cycleParent = master.parent;
4599 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4601 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4604 Window child = cycleParent.activeChild;
4606 // Scroll the window to include the active control
4607 if(cycleParent.sbh && !child.style.dontScrollHorz)
4609 if(child.scrolledPos.x < 0)
4610 cycleParent.sbh.Action(Position,
4611 cycleParent.scroll.x + child.scrolledPos.x, 0);
4612 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4613 cycleParent.sbh.Action(Position,
4614 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4616 if(cycleParent.sbv && !child.style.dontScrollVert)
4618 if(child.scrolledPos.y < 0)
4619 cycleParent.sbv.Action(Position,
4620 cycleParent.scroll.y + child.scrolledPos.y, 0);
4621 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4622 cycleParent.sbv.Action(Position,
4623 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4626 cycleParent.ConsequentialMouseMove(false);
4632 case f6: case shiftF6:
4633 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4635 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4636 if(parent == guiApp.desktop)
4637 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4647 if(CycleChildren(key.shift, true, false, true))
4655 // mIRC Style Window Shortcuts
4656 case alt1: case alt2: case alt3: case alt4: case alt5:
4657 case alt6: case alt7: case alt8: case alt9: case alt0:
4662 for(document = children.first; document; document = document.next)
4664 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4666 if(document == activeChild)
4668 if(document.state == minimized)
4669 document.SetState(normal, false, key);
4672 document.SetState(minimized, false, key);
4673 CycleChildren(false, true, false);
4678 if(activeChild.state == maximized && document.style.hasMaximize)
4679 document.SetState(maximized, false, key);
4680 else if(document.state == minimized)
4681 document.SetState(normal, false, key);
4682 document.Activate();
4697 if(!destroyed && status)
4699 if(state == minimized)
4704 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4706 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4708 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4709 previousActive.ActivateEx(true, false, false, true, null, null);
4710 delete previousActive;
4716 if(!destroyed && status)
4718 status = ProcessHotKeys(method, key, character);
4720 if(!destroyed && status && !modalWindow && state != minimized)
4723 status = KeyMethod(this, key, character);
4724 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4725 status = OnKeyHit(key, character);
4726 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4728 bool result = false;
4731 case ctrlUp: case ctrlDown:
4732 if(sbv && !guiApp.windowScrolling)
4733 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4735 case wheelUp: case wheelDown:
4736 if(sbv && !guiApp.windowScrolling)
4738 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4739 // Do we want to do a consequential move regardless of result in this case?
4740 ConsequentialMouseMove(false);
4743 case ctrlPageUp: case ctrlPageDown:
4744 if(sbh && !guiApp.windowScrolling)
4745 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4750 ConsequentialMouseMove(false);
4755 if(status && !destroyed && menuBar && state != minimized)
4756 status = menuBar.KeyMessage(method, key, character);
4758 if(style.interim && /*destroyed && */status && interimMaster)
4760 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4761 status = interimMaster.KeyMessage(method, key, character);
4768 bool ProcessHotKeys(uint method, Key key, unichar character)
4773 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4774 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4775 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4777 Window hotKeyWindow = hotKey.window;
4778 Window parent = hotKeyWindow.parent;
4779 Window prevActiveWindow = activeChild;
4780 // For when sys buttons are placed inside the menu bar
4781 if(parent && parent._class == class(PopupMenu))
4782 parent = parent.parent;
4784 // 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
4785 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4788 if(prevActiveWindow) incref prevActiveWindow;
4789 incref hotKeyWindow;
4790 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4791 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4794 delete hotKeyWindow;
4795 delete prevActiveWindow;
4799 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4800 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4801 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4803 // ********* WORKING ON THIS ***********
4804 if(prevActiveWindow && !guiApp.interimWindow)
4805 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4808 else if(hotKeyWindow.style.inactive)
4809 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4811 delete prevActiveWindow;
4812 delete hotKeyWindow;
4813 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4814 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4818 if(status && tabCycle)
4821 for(child = children.first; child; child = child.next)
4823 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4834 // --- Windows and graphics initialization / termination ---
4835 bool SetupRoot(void)
4839 // Setup relationship with outside world (bb root || !bb)
4840 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4841 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4845 tempExtents = new0 Extent[4];
4850 /*if(guiApp.fullScreenMode)
4851 rootWindow = guiApp.desktop;
4853 //rootWindow = parent.created ? parent.rootWindow : null;
4854 rootWindow = parent.rootWindow;
4857 against = &parent.box;
4859 against = &parent.clientArea;
4862 for(child = children.first; child; child = child.next)
4865 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4868 bool Setup(bool positionChildren)
4870 bool result = false;
4873 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4875 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4876 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4879 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4881 // This was here, is it really needed?
4882 //guiApp.interfaceDriver.ActivateRootWindow(this);
4886 displaySystem = DisplaySystem {};
4887 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4889 delete displaySystem;
4894 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4895 if(display.Create(displaySystem, windowHandle))
4902 // Sometimes icon does not show up on Windows XP if we set here...
4903 // guiApp.interfaceDriver.SetIcon(this, icon);
4905 else if(this != guiApp.desktop)
4907 display = rootWindow ? rootWindow.display : null;
4913 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4914 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4916 for(child = children.first; child; child = child.next)
4918 if(child.created && !child.Setup(false))
4921 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4922 child.UpdateCaption();
4927 bool SetupDisplay(void)
4929 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4930 if(is3D) return Window3D_SetupDisplay(this); else
4937 class_data void ** pureVTbl;
4939 bool LoadGraphics(bool creation, bool resetAnchors)
4941 bool result = false;
4942 bool success = false;
4944 WindowState stateBackup = state;
4946 if(((subclass(Window))_class).pureVTbl)
4948 if(_vTbl == _class._vTbl)
4950 _vTbl = ((subclass(Window))_class).pureVTbl;
4955 for(m = 0; m < _class.vTblSize; m++)
4957 if(_vTbl[m] == _class._vTbl[m])
4958 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4962 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4964 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4966 _vTbl = _class._vTbl;
4971 for(m = 0; m < _class.vTblSize; m++)
4973 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4974 _vTbl[m] = _class._vTbl[m];
4979 if(guiApp.fullScreenMode || this != guiApp.desktop)
4981 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4987 display.Lock(false);
4988 if(rootWindow == this)
4990 // Set Color Palette
4991 display.SetPalette(palette, true);
4995 if(guiApp.fullScreenMode && this == guiApp.desktop)
5000 for(c=0; c<SystemCursor::enumSize; c++)
5001 if(!guiApp.systemCursors[c].bitmap)
5003 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5004 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5005 if(guiApp.systemCursors[c].bitmapName)
5007 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5008 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5009 if(guiApp.systemCursors[c].bitmap)
5010 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5015 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5017 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5018 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5020 cursor.bitmap.paletteShades = cursor.paletteShades;
5024 guiApp.cursorUpdate = true;
5027 ConsequentialMouseMove(false);
5033 // Load Window Graphic Resources
5036 if(usedFont == setFont || usedFont == window.systemFont)
5037 RemoveResource(usedFont);
5040 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5043 RemoveResource(systemFont);
5046 RemoveResource(captionFont);
5048 for(ptr = resources.first; ptr; ptr = ptr.next)
5050 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5051 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5054 AddResource(setFont);
5056 AddResource(systemFont);
5058 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5065 //if(master && master.font)
5066 if(parent && parent.font)
5070 faceName = parent.font.faceName,
5071 size = parent.font.size,
5072 bold = parent.font.bold,
5073 italic = parent.font.italic,
5074 underline = parent.font.underline
5076 //font = parent.font;
5077 watch(parent) { font { } };
5080 font = guiApp.currentSkin.SystemFont();
5087 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5088 AddResource(captionFont);
5090 if(OnLoadGraphics())
5096 //SetScrollLineStep(sbStep.x, sbStep.y);
5098 if(this != guiApp.desktop)
5102 normalAnchor = anchor;
5103 normalSizeAnchor = sizeAnchor;
5106 // Break the anchors for moveable/resizable windows
5108 if(style.fixed && style.isDocument)
5110 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5122 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5123 stateSizeAnchor = SizeAnchor {};
5128 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5133 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5134 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5137 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5141 stateAnchor = normalAnchor;
5142 stateSizeAnchor = normalSizeAnchor;
5145 position = Point { };
5146 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5157 if(Position(x, y, w, h, true, false, true, true, true, true))
5159 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5162 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5179 success = result = true;
5182 if(!creation && result)
5184 // Load menu bar first because sys buttons are on it...
5187 if(!menuBar.LoadGraphics(false, resetAnchors))
5193 for(child = children.first; child; child = child.next)
5195 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5202 CreateSystemChildren();
5206 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5209 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5212 LogErrorCode(graphicsLoadingFailed, _class.name);
5214 // Do this here to avoid problems on Windows
5215 if(stateBackup == maximized)
5216 property::state = maximized;
5220 void UnloadGraphics(bool destroyWindows)
5224 // Free children's graphics
5225 for(child = children.first; child; child = child.next)
5226 child.UnloadGraphics(destroyWindows);
5229 display.Lock(false);
5232 if(guiApp.fullScreenMode && this == guiApp.desktop)
5237 for(c=0; c<SystemCursor::enumSize; c++)
5238 if(guiApp.systemCursors[c].bitmap)
5239 delete guiApp.systemCursors[c].bitmap;
5241 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5242 delete cursor.bitmap;
5244 guiApp.cursorBackground.Free();
5247 if(display && display.displaySystem)
5251 for(ptr = resources.first; ptr; ptr = ptr.next)
5255 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5260 // Free window graphics
5263 // Free skin graphics
5264 if(rootWindow == this)
5266 DisplaySystem displaySystem = display.displaySystem;
5269 display.driverData = null;
5270 display.displaySystem = null;
5274 if(displaySystem && !displaySystem.numDisplays && !is3D)
5275 delete displaySystem;
5284 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5285 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5287 if(this == guiApp.desktop || parent == guiApp.desktop)
5289 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5290 guiApp.interfaceDriver.DestroyRootWindow(this);
5294 // --- Window Hiding ---
5296 void SetVisibility(bool state)
5298 bool visible = (style.hidden || !created) ? false : state;
5299 if(visible != this.visible)
5303 this.visible = visible;
5304 for(child = children.first; child; child = child.next)
5305 child.SetVisibility(visible);
5307 ConsequentialMouseMove(false);
5308 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5312 // --- Windows and graphics initialization / termination ---
5314 bool DisplayModeChanged(void)
5316 bool result = false;
5317 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5319 guiApp.modeSwitching = true;
5320 UnloadGraphics(false);
5322 if(LoadGraphics(false, false))
5324 guiApp.modeSwitching = false;
5329 // --- Window updates system ---
5331 void UpdateDirty(Box updateBox)
5333 if(!manageDisplay) { OnRedraw(null);return; }
5336 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5339 if(display.flags.flipping)
5342 rootWindow.UpdateDisplay();
5345 UpdateBackDisplay(updateBox);
5347 if(guiApp.fullScreenMode)
5349 guiApp.cursorUpdate = true;
5350 guiApp.PreserveAndDrawCursor();
5352 if(guiApp.fullScreenMode)
5353 guiApp.RestoreCursorBackground();
5359 // This function is strictly called as a result of system window activation
5360 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5363 Window interimMaster = null;
5364 Window interimWindow = guiApp.interimWindow;
5365 if(interimWindow && interimWindow.master)
5366 interimMaster = interimWindow.master.rootWindow;
5368 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5369 // SetState(normal, false, 0);
5370 SetState(lastState, false, 0);
5372 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5376 /* WTH is this doing here?
5377 while(swap && swap.activeChild)
5379 swap = swap.activeChild;
5382 // TESTING THIS BEFORE...
5383 if(interimWindow && this == interimMaster)
5387 // Window interimSwap = this;
5388 Window menuBar = this.menuBar;
5389 if(menuBar && interimWindow.master == menuBar)
5392 while(interimSwap && interimSwap.activeChild)
5393 interimSwap = interimSwap.activeChild;
5395 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5396 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5398 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5399 //result = ActivateEx(true, true, false, activateRoot, window, null);
5404 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5405 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5407 if(interimWindow == this && interimMaster && !active)
5409 while(interimMaster && interimMaster.interim && interimMaster.master)
5411 // printf("Going up one master %s\n", interimMaster._class.name);
5412 interimMaster = interimMaster.master.rootWindow;
5414 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5415 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5421 bool DestroyEx(int64 returnCode)
5424 Timer timer, nextTimer;
5426 OldLink prevOrder = null;
5427 Window client = null;
5429 if(parent) stopwatching(parent, font);
5431 // if(window.modalSlave) return false;
5432 if(destroyed || !created)
5439 OldLink slave = master.slaves.FindLink(this);
5440 master.slaves.Delete(slave);
5443 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5449 this.returnCode = (DialogResult)returnCode;
5451 AcquireInput(false);
5456 master.hotKeys.Delete(hotKey);
5460 if(guiApp.prevWindow == this)
5462 guiApp.prevWindow = null;
5467 for(w : guiApp.overWindows; w == this)
5470 guiApp.overWindows.TakeOut(w);
5474 if(guiApp.caretOwner == this)
5476 guiApp.interfaceDriver.SetCaret(0,0,0);
5477 UpdateCaret(false, true);
5478 guiApp.caretEnabled = false;
5483 parent.childrenCycle.Remove(cycle);
5487 OldLink tmpPrev = order.prev;
5488 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5489 prevOrder = tmpPrev;
5492 client = tmpPrev ? tmpPrev.data : null;
5493 if(client == this) { client = null; break; }
5494 if(client && (client.style.hidden || client.destroyed || !client.created))
5495 tmpPrev = client.order.prev;
5499 prevOrder = tmpPrev;
5504 // If this window can be an active client, make sure the next window we activate can also be one
5505 if(!style.nonClient && style.isActiveClient)
5507 tmpPrev = prevOrder;
5510 client = tmpPrev ? tmpPrev.data : null;
5511 if(client == this) { client = null; break; }
5512 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5513 tmpPrev = client.order.prev;
5517 prevOrder = tmpPrev;
5521 if(client && client.style.hidden) client = null;
5523 // parent.childrenOrder.Remove(order);
5526 if(parent && style.isActiveClient && visible)
5528 if(state == minimized) parent.numIcons--;
5529 parent.numPositions--;
5532 // TESTING THIS HERE!
5536 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5537 // to create a window inside a rootwindow that's being destroyed)
5538 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5540 if(master && !master.destroyed /*&&
5541 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5543 if(master.defaultControl == this)
5544 master.defaultControl = null;
5547 parent.OnChildAddedOrRemoved(this, true);
5548 if(parent && !parent.destroyed /*&&
5549 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5551 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5553 if(order && prevOrder && prevOrder.data != this && active)
5555 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5557 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5558 if(parent.activeClient == this)
5560 parent.activeClient = null;
5561 parent.UpdateActiveDocument(null);
5566 if(guiApp.interimWindow == this)
5569 PropagateActive(false, null, &goOn, true);
5573 //if(window.parent.activeChild == window)
5574 parent.activeChild = null;
5575 if(!style.nonClient /*&& style.isActiveClient*/)
5577 Window previous = parent.activeClient;
5578 if(style.isActiveClient)
5579 parent.activeClient = null;
5580 parent.UpdateActiveDocument(previous);
5585 else if(parent.activeClient == this)
5587 parent.activeClient = client;
5588 parent.UpdateActiveDocument(this);
5592 if(guiApp.interimWindow == this)
5594 guiApp.interimWindow = null;
5595 if(guiApp.caretOwner)
5597 Window desktop = guiApp.desktop;
5598 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5599 guiApp.caretOwner.UpdateCaret(false, false);
5604 if(_isModal && master && master.modalSlave == this)
5605 master.modalSlave = null;
5609 if(!guiApp.caretOwner && parent.caretSize)
5611 guiApp.caretOwner = parent;
5612 parent.UpdateCaret(false, false);
5613 parent.Update(null);
5616 // Why was this commented out?
5617 GetRidOfVirtualArea();
5623 dirtyArea.Free(null);
5624 dirtyBack.Free(null);
5625 scrollExtent.Free(null);
5627 /* ATTEMPTING TO MOVE THAT ABOVE
5636 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5637 for(;(child = window.children.first);)
5639 for(; child && (child.destroyed || !child.created); child = child.next);
5648 UnloadGraphics(true);
5651 delete previousActive;
5654 // statusBar = null;
5657 if(master && !master.destroyed)
5659 //master.NotifyDestroyed(this, this.returnCode);
5660 NotifyDestroyed(master, this, this.returnCode);
5663 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5665 nextTimer = timer.next;
5666 if(timer.window == this)
5668 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5669 // timer.window = null;
5675 if(this == guiApp.windowMoving)
5678 if(guiApp.windowCaptured == this)
5680 //guiApp.windowCaptured = null;
5682 if(rootWindow != this && rootWindow)
5683 rootWindow.ConsequentialMouseMove(false);
5691 //for(child = children.first; next = child ? child.next : null, child; child = next)
5692 for(;(child = children.first); )
5694 for(; child && (child.destroyed || !child.created); child = child.next);
5704 /* // MOVED THIS UP...
5707 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5708 for(;(child = window.children.first); )
5710 for(; child && (child.destroyed || !child.created); child = child.next);
5719 while((slave = slaves.first))
5721 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5723 ((Window)slave.data).DestroyEx(0);
5728 if(guiApp.caretOwner == this)
5729 guiApp.caretOwner = null;
5731 sysButtons[0] = null;
5732 sysButtons[1] = null;
5733 sysButtons[2] = null;
5736 if(rootWindow != this)
5738 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5741 box.left -= parent.clientStart.x;
5742 box.top -= parent.clientStart.y;
5743 box.right -= parent.clientStart.x;
5744 box.bottom -= parent.clientStart.y;
5746 if(parent) parent.Update(box);
5751 OldLink slave = master.slaves.FindVoid(this);
5752 master.slaves.Delete(slave);
5758 parent.children.Remove(this);
5763 //autoCreate = false;
5766 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5767 if(((subclass(Window))_class).pureVTbl)
5769 if(_vTbl == _class._vTbl)
5771 _vTbl = ((subclass(Window))_class).pureVTbl;
5776 for(m = 0; m < _class.vTblSize; m++)
5778 if(_vTbl[m] == _class._vTbl[m])
5779 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5788 void SetStateEx(WindowState newState, bool activate)
5791 WindowState prevState = state;
5795 if(prevState != newState)
5796 lastState = prevState;
5798 if(rootWindow != this || !nativeDecorations || !windowHandle)
5800 if(style.isActiveClient && !style.hidden && prevState == minimized)
5803 // This block used to be at the end of the function... moved it for flicker problem in X
5804 // ------------------------------------------------------
5808 stateAnchor = normalAnchor;
5809 stateSizeAnchor = normalSizeAnchor;
5812 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5813 stateSizeAnchor = SizeAnchor {};
5817 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5820 byte * idBuffer = new0 byte[size];
5822 for(child = parent.children.first; child; child = child.next)
5824 if(child != this && child.state == minimized)
5826 if(child.iconID > size - 2)
5828 idBuffer = renew0 idBuffer byte[size*2];
5829 memset(idBuffer + size, 0, size);
5832 idBuffer[child.iconID] = (byte)bool::true;
5835 for(c = 0; c<size; c++)
5840 if(style.isActiveClient && !style.hidden)
5843 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5844 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5848 // TOCHECK: Why was this here?
5849 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5850 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5851 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5853 Position(x, y, w, h, true, true, true, true, false, true);
5855 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5856 parent.UpdateActiveDocument(null);
5859 CreateSystemChildren();
5860 // ------------------------------------------------------
5863 int GetPositionID(Window forChild)
5867 byte * idBuffer = new0 byte[size];
5870 for(child = children.first; child; child = child.next)
5872 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5874 if(child.positionID > size - 2)
5876 idBuffer = renew0 idBuffer byte[size*2];
5877 memset(idBuffer + size, 0, size);
5880 idBuffer[child.positionID] = (byte)bool::true;
5883 for(c = 0; c<size; c++)
5890 // --- Window related graphics ---
5892 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5894 palette = newPalette;
5895 if(rootWindow.display)
5896 rootWindow.display.SetPalette(palette, colorMatch);
5899 public bool AcquireInput(bool acquired)
5902 if(acquiredInput != acquired)
5904 if(active || (!visible && creationActivation == activate))
5905 result = AcquireInputEx(acquired);
5910 acquiredInput = acquired ? result : !result;
5915 void ListChildren(ListBox listBox)
5919 for(child = children.first; child; child = child.next)
5921 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5923 DataRow row = listBox.AddRow();
5924 row.tag = (int64)(intptr)child;
5925 child.FigureCaption(caption);
5926 row.SetData(null, caption);
5931 void UpdateVisual(Box extent)
5933 if(guiApp.driver != null)
5935 if(guiApp.fullScreenMode && guiApp.desktop.display)
5937 guiApp.desktop.mutex.Wait();
5938 guiApp.desktop.display.Lock(true);
5941 if(guiApp.desktop.active)
5943 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5945 if(guiApp.desktop.display.flags.flipping)
5946 guiApp.desktop.Update(null);
5947 guiApp.desktop.UpdateDisplay();
5948 guiApp.cursorUpdate = true;
5950 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5952 guiApp.PreserveAndDrawCursor();
5953 // guiApp.desktop.display.ShowScreen();
5954 guiApp.cursorUpdate = false;
5955 guiApp.desktop.dirty = false;
5956 guiApp.RestoreCursorBackground();
5960 guiApp.desktop.display.Unlock();
5961 guiApp.desktop.mutex.Release();
5965 Window rootWindow = this.rootWindow;
5966 rootWindow.mutex.Wait();
5971 guiApp.SignalEvent();
5974 guiApp.waitMutex.Wait();
5975 guiApp.interfaceDriver.Lock(rootWindow);
5976 if(!rootWindow.style.hidden && rootWindow.dirty)
5978 if(rootWindow.display)
5980 rootWindow.UpdateDisplay();
5981 //rootWindow.display.ShowScreen(null);
5983 rootWindow.dirty = false;
5985 guiApp.interfaceDriver.Unlock(rootWindow);
5986 guiApp.waitMutex.Release();
5989 rootWindow.mutex.Release();
5994 void UnlockDisplay(void)
5996 guiApp.interfaceDriver.Unlock(rootWindow);
5999 void LockDisplay(void)
6001 guiApp.interfaceDriver.Lock(rootWindow);
6004 Surface GetSurface(Box box)
6006 return Redraw((box == null) ? this.box : box);
6009 void SetMousePosition(int x, int y)
6011 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6015 void IntegrationActivate(bool active)
6017 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6019 isForegroundWindow = true;
6020 ActivateEx(active, active, false, false, null, null);
6021 isForegroundWindow = false;
6026 Window QueryCapture(void)
6028 return guiApp.windowCaptured;
6031 int GetDocumentID(void)
6035 byte * idBuffer = new0 byte[size];
6038 for(child = children.first; child; child = child.next)
6040 // TO CHECK: Do we want a documentID when we already have a file name?
6041 if(child.style.isDocument && !child.fileName)
6043 if(child.documentID-1 > size - 2)
6045 idBuffer = renew0 idBuffer byte[size*2];
6046 memset(idBuffer + size, 0, size);
6049 idBuffer[child.documentID-1] = 1;
6052 for(c = 0; c<size; c++)
6060 void SetInitSize(Size size)
6063 sizeAnchor.size = size;
6064 normalSizeAnchor = sizeAnchor;
6066 // Break the anchors for moveable/resizable windows
6067 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6069 stateAnchor = normalAnchor;
6070 stateSizeAnchor = normalSizeAnchor;
6072 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6073 Position(x,y, w, h, true, true, true, true, false, true);
6077 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6079 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6081 guiApp.windowIsResizing = resize;
6082 guiApp.windowMoving = this;
6083 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6084 if(guiApp.windowIsResizing)
6086 guiApp.windowMovingStart.x += size.w - 1;
6087 guiApp.windowMovingStart.y += size.h - 1;
6089 guiApp.windowMovingBefore = scrolledPos;
6090 guiApp.windowResizingBefore = size;
6091 guiApp.windowMoving.UpdateDecorations();
6092 if(guiApp.windowIsResizing)
6093 guiApp.resizeEndX = guiApp.resizeEndY = true;
6095 if(setCursorPosition)
6096 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6100 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6101 guiApp.windowMovingStart.x += x - absPosition.x;
6102 guiApp.windowMovingStart.y += y - absPosition.y;
6105 if(guiApp.windowMoving)
6107 if(guiApp.windowMoving.style.nonClient)
6108 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6110 guiApp.windowMoving.parent.SetMouseRangeToClient();
6115 if(this == rootWindow)
6116 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6120 void SetupFileMonitor()
6124 fileMonitor = FileMonitor
6126 this, FileChange { modified = true };
6128 bool OnFileNotify(FileChange action, const char * param)
6131 fileMonitor.StopMonitoring();
6132 if(OnFileModified(action, param))
6133 fileMonitor.StartMonitoring();
6146 bool result = false;
6150 else if(guiApp && guiApp.driver != null)
6152 OldLink slaveHolder;
6154 bool visible = !style.hidden;
6158 systemParent = parent;
6159 parent = guiApp.desktop;
6161 last = parent ? parent.children.last : null;
6163 if((parent && parent != guiApp.desktop && !parent.created) ||
6164 (master && master != guiApp.desktop && !master.created))
6168 stopwatching(parent, font);
6171 property::parent = guiApp.desktop;
6172 if(!master) master = parent;
6174 if(_isModal && master.modalSlave)
6175 property::master = master.modalSlave;
6179 parent.children.Remove(this);
6182 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6183 if(slaveHolder.data == this)
6185 master.slaves.Delete(slaveHolder);
6190 if(parent == guiApp.desktop && !mutex)
6193 if(style.isDocument)
6196 parent.numDocuments--;
6197 documentID = parent.GetDocumentID();
6200 if(!style.stayOnTop)
6201 for(; last && last.style.stayOnTop; last = last.prev);
6203 parent.children.Insert((last == this) ? null : last, this);
6204 //parent.children.Add(this);
6207 dispDriver = parent.dispDriver;
6210 master.modalSlave = this;
6212 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6217 master.slaves.Add(slaveHolder = OldLink { data = this });
6222 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6224 if(style.isDefault && !master.defaultControl)
6225 master.defaultControl = this;
6227 stateAnchor = normalAnchor = anchor;
6228 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6230 // TOCHECK: Why is this here?
6231 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6232 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6234 this.visible = false;
6235 style.hidden = true;
6238 // autoCreate = true;
6246 if(parent == guiApp.desktop)
6247 Log("LoadGraphics %s\n", caption);
6249 if(LoadGraphics(true, false))
6257 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6264 if(style.hasMenuBar /*&& menu*/)
6270 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6271 interim = false, inactive = true, nonClient = true, size.h = 24
6279 // Create the system buttons
6280 CreateSystemChildren();
6282 UpdateActiveDocument(null);
6284 if(style.isDocument)
6288 MenuItem item = menu.FindItem(MenuFileSave, 0);
6289 if(item) item.disabled = !modifiedDocument && fileName;
6294 if(parent == guiApp.desktop)
6295 Log("Preemptive SetState %s\n", caption);
6298 // Preemptive Set State to ensure proper anchoring
6299 SetStateEx(state, false);
6301 style.hidden = true;
6307 for(child = children.first; child; child = next)
6310 if(!child.created && (child.autoCreate || child.wasCreated))
6317 for(link = slaves.first; link; link = next)
6319 Window slave = link.data;
6321 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6324 // Things might have happened that invalidated 'next'...
6325 // Start over the search for slaves to create.
6326 // (Added this to fix crash with Stacker & Toolbar)
6327 next = slaves.first;
6336 if(parent == guiApp.desktop)
6337 Log("Real SetState %s\n", caption);
6340 if(isActiveClient && visible)
6342 parent.numPositions--;
6343 if(state == minimized) parent.numIcons--;
6346 parent.OnChildAddedOrRemoved(this, false);
6348 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6350 // Real set state & activate for proper display & activation
6351 property::visible = visible;
6352 // SetState(state & 0x00000003, true, 0);
6353 guiApp.interfaceDriver.SetIcon(this, icon);
6358 /*if(rootWindow == this)
6359 guiApp.interfaceDriver.ActivateRootWindow(this);
6361 if(creationActivation == activate)
6362 ActivateEx(true, false, true, true, null, null);
6363 else if(creationActivation == flash)
6368 rootWindow.ConsequentialMouseMove(false);
6379 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6385 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6387 //style.hidden = true; // !visible;
6388 style.hidden = !visible;
6389 if(master.modalSlave == this)
6390 master.modalSlave = null;
6397 void WriteCaption(Surface surface, int x, int y)
6400 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6403 void Update(Box region)
6409 rootWindow = this.rootWindow;
6411 // rootWindow.mutex.Wait();
6412 if(!destroyed && visible && display)
6417 // Testing this to avoid repetitve full update to take time...
6418 if(dirtyArea.count == 1)
6420 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6421 if(item.box.left <= box.left &&
6422 item.box.top <= box.top &&
6423 item.box.right >= box.right &&
6424 item.box.bottom >= box.bottom)
6426 rootWindow.dirty = true;
6431 if(display.flags.flipping && !rootWindow.dirty)
6433 if(this == rootWindow)
6437 rootWindow.Update(null);
6442 rootWindow.dirty = true;
6447 realBox.left += clientStart.x;
6448 realBox.top += clientStart.y;
6449 realBox.right += clientStart.x;
6450 realBox.bottom += clientStart.y;
6456 if(realBox.right >= realBox.left &&
6457 realBox.bottom >= realBox.top)
6459 // if(!rootWindow.fullRender)
6460 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6462 for(child = children.first; child; child = child.next)
6467 box.left -= child.absPosition.x - absPosition.x;
6468 box.top -= child.absPosition.y - absPosition.y;
6469 box.right -= child.absPosition.x - absPosition.x;
6470 box.bottom -= child.absPosition.y - absPosition.y;
6471 if(box.right >= child.box.left && box.left <= child.box.right &&
6472 box.bottom >= child.box.top && box.top <= child.box.bottom)
6474 box.left -= child.clientStart.x;
6475 box.top -= child.clientStart.y;
6476 box.right -= child.clientStart.x;
6477 box.bottom -= child.clientStart.y;
6483 realBox.left += absPosition.x - rootWindow.absPosition.x;
6484 realBox.top += absPosition.y - rootWindow.absPosition.y;
6485 realBox.right += absPosition.x - rootWindow.absPosition.x;
6486 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6487 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6490 else if(this == guiApp.desktop)
6493 for(window = children.first; window; window = window.next)
6499 Box childBox = region;
6501 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6502 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6503 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6504 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6506 window.Update(childBox);
6509 window.Update(null);
6514 // rootWindow.mutex.Release();
6521 if(guiApp.windowCaptured != this)
6523 if(guiApp.windowCaptured)
6527 //Logf("Captured %s (%s)\n", caption, class.name);
6528 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6529 guiApp.windowCaptured = this;
6535 bool Destroy(int64 code)
6540 if(!destroyed && !CloseConfirmation(false)) return false;
6544 // TOCHECK: Should autoCreate be set to false here?
6555 void Move(int x, int y, int w, int h)
6557 normalAnchor = Anchor { left = x, top = y };
6558 normalSizeAnchor = SizeAnchor { size = { w, h } };
6560 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6562 if(destroyed) return;
6564 stateAnchor = normalAnchor;
6565 stateSizeAnchor = normalSizeAnchor;
6567 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6568 Position(x,y, w, h, true, true, true, true, false, true);
6572 DialogResult Modal(void)
6578 // FIXES MEMORY LEAK IF Create() FAILED
6584 void SetScrollArea(int width, int height, bool snapToStep)
6588 int stepX = sbStep.x, stepY = sbStep.y;
6589 // Needed to make snapped down position match the skin's check of client area
6590 // against realvirtual
6593 SNAPDOWN(stepX, textCellW);
6594 SNAPDOWN(stepY, textCellH);
6595 stepX = Max(stepX, textCellW);
6596 stepY = Max(stepY, textCellH);
6598 if(scrollFlags.snapX)
6599 SNAPUP(width, stepX);
6600 if(scrollFlags.snapY)
6601 SNAPUP(height, stepY);
6604 reqScrollArea.w = width;
6605 reqScrollArea.h = height;
6606 noAutoScrollArea = (width > 0 || height > 0);
6608 UpdateScrollBars(true, true);
6611 void SetScrollPosition(int x, int y)
6614 sbh.Action(setPosition, x, 0);
6618 int seen = clientSize.w, total = reqScrollArea.w;
6620 if(scrollFlags.snapX)
6621 SNAPDOWN(seen, sbStep.x);
6623 if(!total) total = seen;
6624 range = total - seen + 1;
6625 range = Max(range, 1);
6627 if(x >= range) x = range - 1;
6629 if(scrollFlags.snapX)
6630 SNAPUP(x, sbStep.x);
6633 OnHScroll(setPosition, x, 0);
6637 SNAPDOWN(x, textCellW);
6643 sbv.Action(setPosition, y, 0);
6647 int seen = clientSize.h, total = reqScrollArea.h;
6650 if(scrollFlags.snapY)
6651 SNAPDOWN(seen, sbStep.y);
6653 if(!total) total = seen;
6654 range = total - seen + 1;
6655 range = Max(range, 1);
6657 if(y >= range) y = range - 1;
6659 if(scrollFlags.snapY)
6660 SNAPUP(y, sbStep.y);
6663 OnVScroll(setPosition, y, 0);
6666 SNAPDOWN(y, textCellH);
6671 UpdateCaret(false, false);
6674 void SetScrollLineStep(int stepX, int stepY)
6680 SNAPDOWN(stepX, textCellW);
6681 SNAPDOWN(stepY, textCellH);
6682 stepX = Max(stepX, textCellW);
6683 stepY = Max(stepY, textCellH);
6686 sbh.lineStep = stepX;
6688 sbv.lineStep = stepY;
6691 void SetState(WindowState newState, bool activate, Modifiers mods)
6695 if(state == newState || OnStateChange(newState, mods))
6697 //WindowState prevState = state;
6701 // This used to be at the end of the brackets... moved for X, testing...
6702 // This has the effect of activating the window through the system...
6703 if(rootWindow == this)
6704 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6706 SetStateEx(newState, activate);
6708 if(rootWindow == this && !rootWindow.nativeDecorations)
6710 int x = position.x, y = position.y;
6713 x -= guiApp.desktop.absPosition.x;
6714 y -= guiApp.desktop.absPosition.y;
6716 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6720 //state = prevState;
6722 if(state != maximized && style.hasMaximize)
6725 for(child = parent.children.first; child; child = child.next)
6727 if(child != this && child.state == maximized)
6728 child.SetStateEx(normal, false);
6732 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6733 parent.UpdateScrollBars(true, true);
6736 // Do we really need this stuff here?
6737 // Shouldn't the Activate stuff take care of it?
6738 if(parent.rootWindow == parent && style)
6741 parent.FigureCaption(caption);
6742 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6743 parent.UpdateDecorations();
6747 rootWindow.ConsequentialMouseMove(false);
6754 BitmapResource GetIcon(SkinBitmap iconID)
6756 return guiApp.currentSkin.GetBitmap(iconID);
6759 void SetMouseRange(Box range)
6761 if(range || guiApp.fullScreenMode)
6766 clip.left = range.left + absPosition.x + clientStart.x;
6767 clip.top = range.top + absPosition.y + clientStart.y;
6768 clip.right = range.right + absPosition.x + clientStart.x;
6769 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6773 clip.left = guiApp.desktop.box.left;
6774 clip.top = guiApp.desktop.box.top;
6775 clip.right = guiApp.desktop.box.right;
6776 clip.bottom = guiApp.desktop.box.bottom;
6778 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6781 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6784 void SetMouseRangeToClient(void)
6786 if(guiApp.fullScreenMode || this != guiApp.desktop)
6788 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6789 box.Clip(clientArea);
6793 SetMouseRange(null);
6796 void SetMouseRangeToWindow(void)
6798 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6799 if(this == guiApp.desktop)
6800 SetMouseRangeToClient();
6805 // x, y: Desktop Coordinates
6806 void ShowSysMenu(int x, int y)
6809 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6812 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6813 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6817 menu, $"Move", m, NotifySelect = MenuWindowMove,
6818 disabled = !style.fixed || state == maximized
6822 menu, $"Size", s, NotifySelect = MenuWindowSize,
6823 disabled = !style.sizable || state != normal
6827 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6828 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6832 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6833 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6837 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6838 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6840 MenuDivider { menu };
6843 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6844 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6846 windowMenu.Create();
6851 ActivateEx(true, true, true, true, null, null);
6854 void MakeActive(void)
6856 ActivateEx(true, false, true, false, null, null);
6859 void SoftActivate(void)
6861 if(guiApp.desktop.active)
6867 void Deactivate(void)
6869 ActivateEx(false, true, true, true, null, null);
6874 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6877 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6879 bool result = false;
6880 if(activeChild && activeChild.cycle)
6882 Window modalWindow, child = activeChild;
6883 if(!clientOnly /*&& parent.tabCycle*/)
6885 Window next = child;
6888 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6892 if(parent && parent.CycleChildren(backward, false, true, true))
6900 next = next.cycle.prev.data;
6902 next = next.cycle.next.data;
6903 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6908 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6909 parent.tabCycle && parent.CycleChildren(backward, false, false))
6913 if(tabCycleOnly && !tabCycle) return false;
6920 child = child.cycle.prev.data;
6922 child = child.cycle.next.data;
6923 if(child == child.parent.activeChild)
6925 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6928 modalWindow = child.FindModal();
6931 // Scroll the window to include the active control
6932 if(sbh && !child.style.dontScrollHorz)
6934 if(child.scrolledPos.x < 0)
6935 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6936 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6937 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6939 if(sbv && !child.style.dontScrollVert)
6941 if(child.scrolledPos.y < 0)
6942 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6943 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6944 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6948 child = modalWindow ? modalWindow : child;
6949 child.ActivateEx(true, true, true, true, null, null);
6950 if(child.tabCycle && child.childrenCycle.first)
6951 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6959 ConsequentialMouseMove(false);
6963 void AddResource(Resource resource)
6967 ResPtr ptr { resource = resource };
6971 // Load Graphics here if window is created already
6972 if(/*created && */display)
6974 display.Lock(false);
6975 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
6976 ptr.loaded = display.displaySystem.LoadResource(resource);
6980 // Temporary hack to load font right away for listbox in dropbox ...
6981 else if(master && master.display)
6983 master.display.Lock(false);
6984 master.display.displaySystem.LoadResource(resource);
6985 master.display.Unlock();
6991 void RemoveResource(Resource resource)
6996 for(ptr = resources.first; ptr; ptr = ptr.next)
6998 if(ptr.resource == resource)
7004 // Unload Graphics here if window is created already
7005 if(/*created && */display)
7009 display.Lock(false);
7010 display.displaySystem.UnloadResource(resource, ptr.loaded);
7016 resources.Delete(ptr);
7021 void SetCaret(int x, int y, int size)
7028 if(active && !style.interim && isEnabled)
7030 if(visible || !guiApp.caretOwner)
7031 guiApp.caretOwner = size ? this : null;
7033 UpdateCaret(false, false);
7036 guiApp.interfaceDriver.SetCaret(0,0,0);
7037 UpdateCaret(false, true);
7038 guiApp.caretEnabled = false;
7041 else if(style.inactive && active)
7043 guiApp.interfaceDriver.SetCaret(0,0,0);
7044 UpdateCaret(false, true);
7045 guiApp.caretEnabled = false;
7050 void Scroll(int x, int y)
7052 bool opaque = !style.drawBehind || background.a;
7053 if(opaque && display && display.flags.scrolling)
7055 Box box = clientArea;
7056 box.left += clientStart.x;
7057 box.top += clientStart.y;
7058 box.right += clientStart.x;
7059 box.bottom += clientStart.y;
7061 //scrollExtent.Free(null);
7062 scrollExtent.AddBox(box);
7063 scrolledArea.x += x;
7064 scrolledArea.y += y;
7066 //scrollExtent.Free();
7067 //scrollExtent.AddBox(clientArea);
7068 //scrollExtent.Offset(clientStart.x, clientStart.y);
7069 //scrolledArea.x = x;
7070 //scrolledArea.y = y;
7076 rootWindow.dirty = true;
7079 void ReleaseCapture()
7081 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7083 Window oldCaptured = guiApp.windowCaptured;
7084 guiApp.windowCaptured = null;
7085 guiApp.prevWindow = null;
7088 //guiApp.Log("Released Capture\n");
7090 guiApp.interfaceDriver.SetMouseCapture(null);
7092 //oldCaptured.OnMouseCaptureLost();
7095 oldCaptured.ConsequentialMouseMove(false);
7100 private void _SetCaption(const char * format, va_list args)
7107 char caption[MAX_F_STRING];
7108 vsnprintf(caption, sizeof(caption), format, args);
7109 caption[sizeof(caption)-1] = 0;
7111 this.caption = CopyString(caption);
7116 firewatchers caption;
7120 /*deprecated*/ void SetText(const char * format, ...)
7123 va_start(args, format);
7124 _SetCaption(format, args);
7128 void SetCaption(const char * format, ...)
7131 va_start(args, format);
7132 _SetCaption(format, args);
7136 bool Grab(Bitmap bitmap, Box box, bool decorations)
7138 bool result = false;
7139 if(display || this == guiApp.desktop)
7141 Box clip = {MININT, MININT, MAXINT, MAXINT};
7147 clip.Clip(clientArea);
7149 clip.Clip(this.box);
7151 if(rootWindow != this)
7153 clip.left += absPosition.y;
7154 clip.top += absPosition.y;
7155 clip.right += absPosition.x;
7156 clip.bottom += absPosition.y;
7159 clip.left += decorations ? 0 : clientStart.x;
7160 clip.top += decorations ? 0 : clientStart.y;
7161 clip.right += decorations ? 0 : clientStart.x;
7162 clip.bottom += decorations ? 0 : clientStart.y;
7164 if(display && display.flags.flipping)
7166 rootWindow.Update(null);
7167 rootWindow.UpdateDisplay();
7174 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7175 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7179 result = display.Grab(bitmap, clip.left, clip.top,
7180 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7182 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7184 if(!bitmap.Convert(null, pixelFormat888, null))
7191 void GetMousePosition(int * x, int * y)
7193 int mouseX = 0, mouseY = 0;
7194 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7197 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7198 if(this != guiApp.desktop)
7200 mouseX -= absPosition.x + clientStart.x;
7201 mouseY -= absPosition.y + clientStart.y;
7208 DialogResult DoModal()
7210 DialogResult returnCode = 0;
7211 int terminated = terminateX;
7214 while(!destroyed && guiApp.driver != null)
7216 if(terminateX != terminated)
7218 terminated = terminateX;
7219 guiApp.desktop.Destroy(0);
7220 if(guiApp.desktop.created)
7223 //printf("Resetting terminate X to 0\n");
7229 guiApp.UpdateDisplay();
7230 if(!guiApp.ProcessInput(false))
7233 returnCode = this.returnCode;
7246 return !destroyed && guiApp.driver != null && terminateX < 2;
7249 DialogResult DoModalEnd()
7251 DialogResult returnCode = this.returnCode;
7256 // --- Window manipulation ---
7257 /*bool GetDisabled()
7259 bool disabled = this.disabled;
7261 for(window = this; (window = window.master); )
7272 // --- Mouse Manipulation ---
7273 void GetNCMousePosition(int * x, int * y)
7275 GetMousePosition(x, y);
7276 if(x) *x += clientStart.x;
7277 if(y) *y += clientStart.y;
7280 // --- Carets manipulation ---
7281 void GetCaretPosition(Point caretPos)
7283 caretPos = this.caretPos;
7286 int GetCaretSize(void)
7291 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7297 bool CloseConfirmation(bool parentClosing)
7310 if(!OnClose(parentClosing))
7313 // If you want to skip this, simply set modifiedDocument to false in OnClose
7314 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7316 DialogResult dialogRes;
7319 sprintf(message, $"Save changes to %s?", fileName);
7321 sprintf(message, $"Save changes to Untitled %d?", documentID);
7323 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7325 if(dialogRes == yes)
7327 // TOFIX: Precomp error if brackets are taken out
7328 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7330 else if(dialogRes == cancel)
7336 for(slave = slaves.first; slave; slave = slave.next)
7338 Window w = slave.data;
7339 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7347 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7350 for(child = children.first; child; child = child.next)
7351 if(child.isActiveClient && !child.CloseConfirmation(true))
7359 for(child = children.first; child; child = child.next)
7360 if(!child.isActiveClient && !child.CloseConfirmation(true))
7370 // Static methods... move them somewhere else?
7371 void ::RestoreCaret()
7373 if(guiApp.caretOwner)
7374 guiApp.caretOwner.UpdateCaret(false, false);
7377 void ::FreeMouseRange()
7379 guiApp.interfaceDriver.SetMouseRange(null, null);
7383 bool MenuFileClose(MenuItem selection, Modifiers mods)
7385 Window document = activeChild;
7387 document.Destroy(0);
7391 bool MenuFileExit(MenuItem selection, Modifiers mods)
7397 bool MenuFileSave(MenuItem selection, Modifiers mods)
7402 fileMonitor.fileName = null;
7405 if(OnSaveFile(fileName))
7407 //if(OnFileModified != Window::OnFileModified)
7410 fileMonitor.fileName = fileName;
7416 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7417 DialogResult answer = dialog.Modal();
7419 if(answer != yes) return (bool)answer;
7422 return MenuFileSaveAs(selection, mods);
7425 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7427 DialogResult result = (DialogResult)bool::true;
7428 FileDialog fileDialog = saveDialog;
7433 fileDialog = FileDialog {};
7438 fileDialog.filePath = fileName;
7441 char filePath[MAX_FILENAME];
7442 sprintf(filePath, "Untitled %d", documentID);
7443 fileDialog.filePath = filePath;
7445 fileMonitor.fileName = null;
7447 fileDialog.type = save;
7448 fileDialog.text = $"Save As";
7452 fileDialog.master = master.parent ? master : this;
7453 if(fileDialog.Modal() == ok)
7455 const char * filePath = fileDialog.filePath;
7457 if(OnSaveFile(filePath))
7460 property::fileName = filePath;
7461 NotifySaved(master, this, filePath);
7466 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7467 DialogResult answer = dialog.Modal();
7482 //if(OnFileModified != Window::OnFileModified && fileName)
7485 fileMonitor.fileName = fileName;
7489 return (bool)result; // Actually returning result from Yes/NoCancel message box
7492 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7494 Window document = activeChild;
7496 for(document = children.first; document; document = next)
7498 next = document.next;
7499 if(document.style.isDocument || document.fileName)
7500 document.MenuFileSave(selection, mods);
7505 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7509 for(document = children.first; document; document = document.next)
7510 //if(document.style.isDocument && document.state == minimized)
7511 if(document.style.isActiveClient && document.state == minimized)
7512 document.SetState(minimized, false, mods);
7516 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7518 Window document = activeChild;
7521 Window firstDocument = null;
7523 OldLink cycle = document.cycle.prev;
7528 if(child.style.isActiveClient && !child.style.hidden)
7532 firstDocument = child;
7533 if(child.state == minimized)
7534 child.SetState(minimized, false, mods);
7537 child.positionID = id++;
7538 child.SetState(normal, false, mods);
7539 child.anchor.left.type = cascade;
7542 child.normalSizeAnchor = *&child.sizeAnchor;
7543 child.normalAnchor = child.anchor;
7545 // Break the anchors for moveable/resizable windows
7546 if(child.style.fixed)
7548 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7550 (*&child.normalAnchor).left = x;
7551 (*&child.normalAnchor).top = y;
7552 (*&child.normalAnchor).right.type = none;
7553 (*&child.normalAnchor).bottom.type = none;
7555 child.normalSizeAnchor.isClientW = false;
7556 child.normalSizeAnchor.isClientH = false;
7557 child.normalSizeAnchor.size.w = w;
7558 child.normalSizeAnchor.size.h = h;
7559 child.anchored = false;
7562 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7564 child.stateAnchor = child.normalAnchor;
7565 child.stateSizeAnchor = child.normalSizeAnchor;
7567 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7568 child.Position(x, y, w, h, true, true, true, true, false, false);
7573 last = children.last;
7574 if(!child.style.stayOnTop)
7575 for(; last && last.style.stayOnTop; last = last.prev);
7576 children.Move(child, last);
7577 childrenOrder.Move(child.order, childrenOrder.last);
7579 if(cycle == document.cycle) break;
7583 firstDocument.Activate();
7588 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7595 // Close all closes all active clients, not all documents
7596 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7598 Window next, document;
7600 for(document = children.first; document; document = next)
7602 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7603 if(document.style.isActiveClient)
7604 if(!document.Destroy(0) && !document.style.hidden)
7610 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7612 if(style.hasMaximize && state != maximized)
7613 SetState(maximized, 0, 0);
7617 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7619 if(style.hasMinimize && state != minimized)
7621 SetState(minimized, 0, 0);
7622 parent.CycleChildren(false, true, false, true);
7627 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7629 MenuMoveOrSize(false, selection ? true : false);
7633 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7635 CycleChildren(false, true, false, true);
7639 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7641 CycleChildren(true, true, false, true);
7645 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7647 MenuMoveOrSize(true, true);
7651 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7654 SetState(normal, 0, 0);
7658 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7661 int64 id = selection.id;
7662 OldLink cycle = activeClient.cycle;
7664 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7667 Window sibling = cycle.data;
7668 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7676 document = cycle.data;
7677 document.Activate();
7679 //if(activeChild.state == maximized)
7680 // document.SetState(maximized, false, mods);
7681 //else if(document.state == minimized)
7682 // document.SetState(normal, false, mods);
7686 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7688 stayOnTop = !style.stayOnTop;
7692 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7694 Window document = activeChild;
7697 Window firstDocument = null;
7698 OldLink cycle = document.cycle;
7702 Window child = cycle.data;
7703 if(child.style.isActiveClient && !child.style.hidden)
7705 if(!firstDocument) firstDocument = child;
7706 if(child.state == minimized)
7707 child.SetState(minimized, false, mods);
7710 child.positionID = id++;
7711 child.SetState(normal, false, mods);
7712 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7714 child.anchor.left.type = hTiled;
7717 child.normalSizeAnchor = *&child.sizeAnchor;
7718 child.normalAnchor = child.anchor;
7720 // Break the anchors for moveable/resizable windows
7721 if(child.style.fixed)
7723 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7725 (*&child.normalAnchor).left = x;
7726 (*&child.normalAnchor).top = y;
7727 (*&child.normalAnchor).right.type = none;
7728 (*&child.normalAnchor).bottom.type = none;
7729 child.normalSizeAnchor.isClientW = false;
7730 child.normalSizeAnchor.isClientH = false;
7731 child.normalSizeAnchor.size.w = w;
7732 child.normalSizeAnchor.size.h = h;
7733 child.anchored = false;
7736 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7738 child.stateAnchor = child.normalAnchor;
7739 child.stateSizeAnchor = child.normalSizeAnchor;
7741 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7742 child.Position(x,y, w, h, true, true, true, true, false, true);
7747 if((cycle = cycle.next) == document.cycle) break;
7750 firstDocument.Activate();
7755 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7757 Window document = activeChild;
7760 Window firstDocument = null;
7762 OldLink cycle = document.cycle;
7767 //if(child.style.isDocument)
7768 if(child.style.isActiveClient && !child.style.hidden)
7770 if(!firstDocument) firstDocument = child;
7771 if(child.state == minimized)
7772 child.SetState(minimized, false, mods);
7775 child.positionID = id++;
7776 child.SetState(normal, false, mods);
7777 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7779 child.anchor.left.type = vTiled;
7782 child.normalSizeAnchor = *&child.sizeAnchor;
7783 child.normalAnchor = child.anchor;
7785 // Break the anchors for moveable/resizable windows
7786 if(child.style.fixed)
7788 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7790 (*&child.normalAnchor).left = x;
7791 (*&child.normalAnchor).top = y;
7792 (*&child.normalAnchor).right.type = none;
7793 (*&child.normalAnchor).bottom.type = none;
7794 child.normalSizeAnchor.isClientW = false;
7795 child.normalSizeAnchor.isClientH = false;
7796 child.normalSizeAnchor.size.w = w;
7797 child.normalSizeAnchor.size.h = h;
7798 child.anchored = false;
7801 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7803 child.stateAnchor = child.normalAnchor;
7804 child.stateSizeAnchor = child.normalSizeAnchor;
7806 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7807 child.Position(x,y, w, h, true, true, true, true, false, true);
7812 if((cycle = cycle.next) == document.cycle) break;
7815 firstDocument.Activate();
7820 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7822 WindowList dialog { master = this };
7823 Window document = (Window)(intptr)dialog.Modal();
7826 if(activeChild.state == maximized)
7827 document.SetState(maximized, false, mods);
7828 else if(document.state == minimized)
7829 document.SetState(normal, false, mods);
7830 document.Activate();
7836 virtual bool OnCreate(void);
7837 virtual void OnDestroy(void);
7838 virtual void OnDestroyed(void);
7839 virtual bool OnClose(bool parentClosing);
7840 virtual bool OnStateChange(WindowState state, Modifiers mods);
7841 virtual bool OnPostCreate(void);
7842 virtual bool OnMoving(int *x, int *y, int w, int h);
7843 virtual bool OnResizing(int *width, int *height);
7844 virtual void OnResize(int width, int height);
7845 virtual void OnPosition(int x, int y, int width, int height);
7846 virtual bool OnLoadGraphics(void);
7847 virtual void OnApplyGraphics(void);
7848 virtual void OnUnloadGraphics(void);
7849 virtual void OnRedraw(Surface surface);
7850 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7851 virtual void OnActivateClient(Window client, Window previous);
7852 virtual bool OnKeyDown(Key key, unichar ch);
7853 virtual bool OnKeyUp(Key key, unichar ch);
7854 virtual bool OnKeyHit(Key key, unichar ch);
7855 virtual bool OnSysKeyDown(Key key, unichar ch);
7856 virtual bool OnSysKeyUp(Key key, unichar ch);
7857 virtual bool OnSysKeyHit(Key key, unichar ch);
7858 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7859 virtual bool OnMouseLeave(Modifiers mods);
7860 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7861 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7862 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7863 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7864 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7865 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7866 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7867 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7868 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7869 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7870 virtual void OnMouseCaptureLost(void);
7871 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7872 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7873 virtual void OnDrawOverChildren(Surface surface);
7874 virtual bool OnFileModified(FileChange fileChange, const char * param);
7875 virtual bool OnSaveFile(const char * fileName);
7877 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7878 // Note: A 'client' would refer to isActiveClient, rather than
7879 // being confined to the 'client area' (nonClient == false)
7880 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7881 virtual void OnChildVisibilityToggled(Window child, bool visible);
7882 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7884 // Skins Virtual Functions
7885 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7886 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7887 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7892 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7893 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7894 virtual bool IsMouseMoving(int x, int y, int w, int h)
7898 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7902 virtual void UpdateNonClient();
7903 virtual void SetBox(Box box); // This is used in the MySkin skin
7904 virtual bool IsInside(int x, int y)
7906 return box.IsPointInside({x, y});
7908 virtual bool IsOpaque()
7910 return (!style.drawBehind || background.a == 255);
7914 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7915 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7916 virtual void Window::NotifySaved(Window window, const char * filePath);
7921 property Window parent
7923 property_category $"Layout"
7926 if(value || guiApp.desktop)
7929 Window oldParent = parent;
7930 Anchor anchor = this.anchor;
7932 if(value && value.IsDescendantOf(this)) return;
7933 if(value && value == this)
7935 if(!value) value = guiApp.desktop;
7937 if(value == oldParent) return;
7939 if(!master || (master == this.parent && master == guiApp.desktop))
7940 property::master = value;
7944 parent.children.Remove(this);
7948 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7949 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7950 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7951 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7955 last = value.children.last;
7957 if(style.isDocument)
7960 parent.numDocuments--;
7961 documentID = value.GetDocumentID();
7964 if(style.isActiveClient && !style.hidden)
7966 if(parent && parent != guiApp.desktop && !(style.hidden))
7968 if(state == minimized) parent.numIcons--;
7969 parent.numPositions--;
7973 if(!style.stayOnTop)
7974 for(; last && last.style.stayOnTop; last = last.prev);
7976 value.children.Insert(last, this);
7978 // *** NEW HERE: ***
7980 parent.childrenCycle.Delete(cycle);
7982 parent.childrenOrder.Delete(order);
7985 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7986 // Should something else be done?
7987 if(parent && parent.activeChild == this)
7988 parent.activeChild = null;
7989 if(parent && parent.activeClient == this)
7990 parent.activeClient = null;
7996 int x = position.x, y = position.y, w = size.w, h = size.h;
8000 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8001 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8003 vpw = value.clientSize.w;
8004 vph = value.clientSize.h;
8010 else if(style.fixed)
8012 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8013 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8016 anchor = this.anchor;
8018 if(anchor.left.type == offset) anchor.left.distance = x;
8019 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8020 if(anchor.top.type == offset) anchor.top.distance = y;
8021 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8022 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8023 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8024 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8025 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8026 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8027 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8029 if(!anchor.left.type && !anchor.right.type)
8031 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8032 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8034 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8035 if(!anchor.top.type && !anchor.bottom.type)
8037 anchor.vert.distance = (y + h / 2) - (vph / 2);
8038 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8040 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8043 parent.OnChildAddedOrRemoved(this, false);
8049 parent.childrenCycle.Insert(
8050 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8051 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8053 cycle = OldLink { data = this });
8054 parent.childrenOrder.Insert(
8055 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8056 order = OldLink { data = this });
8059 if(!style.hidden && style.isActiveClient)
8061 positionID = parent.GetPositionID(this);
8062 parent.numPositions++;
8063 if(state == minimized) parent.numIcons--;
8066 // *** FONT INHERITANCE ***
8067 if(!setFont && oldParent)
8068 stopwatching(oldParent, font);
8072 RemoveResource(systemFont);
8075 // TESTING WITH WATCHERS:
8076 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8077 // usedFont = setFont ? setFont : (systemFont);
8081 if(guiApp.currentSkin)
8083 systemFont = guiApp.currentSkin.SystemFont();
8086 usedFont = systemFont;
8087 AddResource(systemFont);
8095 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8104 if(value.rootWindow && value.rootWindow.display && rootWindow)
8106 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8107 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8110 UnloadGraphics(false);
8114 LoadGraphics(false, false);
8117 if(value.rootWindow != rootWindow)
8118 DisplayModeChanged();
8122 scrolledPos.x = MININT; // Prevent parent update
8124 bool anchored = this.anchored;
8125 property::anchor = anchor;
8126 this.anchored = anchored;
8131 if(guiApp.currentSkin)
8132 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8134 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8135 Position(x, y, w, h, true, true, true, true, false, true);
8140 // else parent = value;
8142 oldParent.OnChildAddedOrRemoved(this, true);
8145 get { return parent; }
8148 property Window master
8150 property_category $"Behavior"
8153 //if(this == value) return;
8154 if(value && value.IsSlaveOf(this)) return;
8160 OldLink slaveHolder;
8161 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8162 if(slaveHolder.data == this)
8164 master.slaves.Delete(slaveHolder);
8171 value.slaves.Add(OldLink { data = this });
8176 master.hotKeys.Remove(hotKey);
8177 value.hotKeys.Add(hotKey);
8180 if(master && master.defaultControl == this)
8181 master.defaultControl = null;
8183 if(style.isDefault && !value.defaultControl)
8184 value.defaultControl = this;
8189 get { return master ? master : parent; }
8192 property const char * caption
8194 property_category $"Appearance"
8201 caption = new char[strlen(value)+1];
8203 strcpy(caption, value);
8208 get { return caption; }
8213 property_category $"Behavior"
8222 master.hotKeys.Add(hotKey = HotKeySlot { });
8226 hotKey.window = this;
8231 master.hotKeys.Delete(hotKey);
8236 get { return hotKey ? hotKey.key : 0; }
8239 property Color background
8241 property_category $"Appearance"
8244 background.color = value;
8249 if(this == rootWindow)
8250 guiApp.interfaceDriver.SetRootWindowColor(this);
8253 get { return background.color; }
8256 property Percentage opacity
8258 property_category $"Appearance"
8261 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8262 drawBehind = (background.a == 255) ? false : true;
8264 get { return background.a / 255.0f; }
8267 property Color foreground
8269 property_category $"Appearance"
8277 get { return foreground; }
8280 property BorderStyle borderStyle
8282 property_category $"Appearance"
8285 if(!((BorderBits)value).fixed)
8287 style.hasClose = false;
8288 style.hasMaximize = false;
8289 style.hasMinimize = false;
8290 nativeDecorations = false;
8292 style.borderBits = value;
8296 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8298 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8299 Position(x, y, w, h, true, true, true, true, false, true);
8300 CreateSystemChildren();
8303 get { return (BorderStyle)style.borderBits; }
8306 property Size minClientSize
8308 property_category $"Layout"
8309 set { minSize = value; }
8310 get { value = minSize; }
8313 property Size maxClientSize
8315 property_category $"Layout"
8316 set { maxSize = value; }
8317 get { value = maxSize; }
8320 property bool hasMaximize
8322 property_category $"Window Style"
8325 style.hasMaximize = value;
8326 if(value) { style.fixed = true; style.contour = true; }
8330 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8332 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8333 Position(x, y, w, h, true, true, true, true, false, true);
8335 CreateSystemChildren();
8338 get { return style.hasMaximize; }
8341 property bool hasMinimize
8343 property_category $"Window Style"
8346 style.hasMinimize = value;
8347 if(value) { style.fixed = true; style.contour = true; }
8351 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8353 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8354 Position(x, y, w, h, true, true, true, true, false, true);
8356 CreateSystemChildren();
8359 get { return style.hasMinimize; }
8362 property bool hasClose
8364 property_category $"Window Style"
8367 style.hasClose = value;
8368 if(value) { style.fixed = true; style.contour = true; }
8372 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8373 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8374 Position(x, y, w, h, true, true, true, true, false, true);
8375 CreateSystemChildren();
8378 get { return style.hasClose; }
8381 property bool nonClient
8383 property_category $"Layout"
8386 style.nonClient = value;
8388 style.stayOnTop = true;
8390 get { return style.nonClient; }
8393 property bool inactive
8395 property_category $"Behavior"
8400 // *** NEW HERE: ***
8404 parent.childrenCycle.Delete(cycle);
8406 parent.childrenOrder.Delete(order);
8413 active = false; // true;
8414 if(parent.activeChild == this)
8415 parent.activeChild = null;
8416 if(parent.activeClient == this)
8417 parent.activeClient = null;
8426 parent.childrenCycle.Insert(
8427 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8428 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8430 cycle = OldLink { data = this });
8432 parent.childrenOrder.Insert(
8433 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8434 order = OldLink { data = this });
8437 style.inactive = value;
8439 get { return style.inactive; }
8442 property bool clickThrough
8444 property_category $"Behavior"
8445 set { style.clickThrough = value; }
8446 get { return style.clickThrough; }
8449 property bool isRemote
8451 property_category $"Behavior"
8452 set { style.isRemote = value; }
8453 get { return style.isRemote; }
8456 property bool noCycle
8458 property_category $"Behavior"
8459 set { style.noCycle = value; }
8460 get { return style.noCycle; }
8463 property bool isModal
8465 property_category $"Behavior"
8466 set { style.modal = value; }
8467 get { return style.modal; }
8470 property bool interim
8472 property_category $"Behavior"
8473 set { style.interim = value; }
8474 get { return style.interim; }
8477 property bool tabCycle
8479 property_category $"Behavior"
8480 set { style.tabCycle = value; }
8481 get { return style.tabCycle; }
8484 property bool isDefault
8486 property_category $"Behavior"
8494 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8495 if(sibling != this && sibling.style.isDefault)
8496 sibling.style.isDefault = false;*/
8497 if(master.defaultControl)
8498 master.defaultControl.style.isDefault = false;
8499 master.defaultControl = this;
8501 else if(master.defaultControl == this)
8502 master.defaultControl = null;
8506 style.isDefault = value;
8508 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8510 get { return style.isDefault; }
8513 property bool drawBehind
8515 property_category $"Window Style"
8516 set { style.drawBehind = value; }
8517 get { return style.drawBehind; }
8520 property bool hasMenuBar
8522 property_category $"Window Style"
8532 if(created && !menuBar)
8539 anchor = Anchor { top = 23, left = 1, right = 1 },
8541 inactive = true, nonClient = true
8546 else if(created && menuBar)
8551 style.hasMenuBar = value;
8553 get { return style.hasMenuBar; }
8556 property bool hasStatusBar
8558 property_category $"Window Style"
8565 statusBar = StatusBar { this };
8573 style.hasStatusBar = value;
8575 get { return style.hasStatusBar; }
8577 property bool stayOnTop
8579 property_category $"Window Style"
8584 if(created && !style.stayOnTop)
8586 if(rootWindow == this)
8587 guiApp.interfaceDriver.OrderRootWindow(this, true);
8588 else if(parent.children.last != this)
8590 parent.children.Move(this, parent.children.last);
8594 style.stayOnTop = true;
8598 if(created && style.stayOnTop)
8600 if(rootWindow == this)
8601 guiApp.interfaceDriver.OrderRootWindow(this, false);
8608 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8609 order && ((Window)order.data).style.stayOnTop;
8610 order = (order == parent.childrenOrder.first) ? null : order.prev);
8611 last = order ? order.data : null;
8615 for(last = parent.children.last;
8616 last && last.style.stayOnTop;
8620 parent.children.Move(this, last);
8624 style.stayOnTop = false;
8627 get { return style.stayOnTop; }
8632 property_category $"Window Style"
8642 if(menuBar && !value)
8649 if(!menuBar && style.hasMenuBar && value)
8653 this, menu = value, isMenuBar = true,
8654 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8655 inactive = true, nonClient = true
8659 UpdateActiveDocument(null);
8662 get { return menu; }
8665 property FontResource font
8667 property_category $"Appearance"
8669 isset { return setFont ? true : false; }
8674 if(value && !setFont) { stopwatching(parent, font); }
8675 else if(!value && setFont)
8681 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8690 RemoveResource(setFont);
8695 RemoveResource(systemFont);
8702 AddResource(setFont);
8705 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8708 systemFont = guiApp.currentSkin.SystemFont();
8710 usedFont = systemFont;
8711 AddResource(systemFont);
8719 get { return usedFont; }
8722 property SizeAnchor sizeAnchor
8724 property_category $"Layout"
8727 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8728 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8729 sizeAnchor.isClientW != sizeAnchor.isClientH;
8736 normalSizeAnchor = sizeAnchor;
8738 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8740 stateAnchor = normalAnchor;
8741 stateSizeAnchor = normalSizeAnchor;
8743 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8744 Position(x,y, w, h, true, true, true, true, false, true);
8751 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8752 sizeAnchor.isClientW,
8753 sizeAnchor.isClientH
8760 property_category $"Layout"
8763 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8764 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8765 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8771 sizeAnchor.isClientW = false;
8772 sizeAnchor.isClientH = false;
8773 sizeAnchor.size = value;
8775 normalSizeAnchor = sizeAnchor;
8777 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8779 stateAnchor = normalAnchor;
8780 stateSizeAnchor = normalSizeAnchor;
8782 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8783 Position(x, y, w, h, true, true, true, true, false, true);
8784 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8787 get { value = size; }
8790 property Size clientSize
8792 property_category $"Layout"
8795 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8796 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8797 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8802 sizeAnchor.isClientW = true;
8803 sizeAnchor.isClientH = true;
8804 sizeAnchor.size = value;
8806 normalSizeAnchor = sizeAnchor;
8808 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8810 stateAnchor = normalAnchor;
8811 stateSizeAnchor = normalSizeAnchor;
8813 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8814 Position(x,y, w, h, true, true, true, true, false, true);
8815 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8818 get { value = this ? clientSize : { 0, 0 }; }
8821 property Size initSize { get { value = sizeAnchor.size; } };
8823 property Anchor anchor
8825 property_category $"Layout"
8826 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8832 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8834 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8835 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8837 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8839 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8840 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8844 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8846 anchor.left.distance = 0;
8847 anchor.horz.type = 0;
8849 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8851 anchor.top.distance = 0;
8852 anchor.vert.type = 0;
8861 normalAnchor = anchor;
8863 // Break the anchors for moveable/resizable windows
8864 /*if(style.fixed ) //&& value.left.type == cascade)
8866 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8868 this.anchor = normalAnchor = Anchor { left = x, top = y };
8869 normalSizeAnchor = SizeAnchor { { w, h } };
8872 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8874 stateAnchor = normalAnchor;
8875 stateSizeAnchor = normalSizeAnchor;
8877 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8878 Position(x, y, w, h, true, true, true, true, false, true);
8887 get { value = this ? anchor : Anchor { }; }
8890 property Point position
8892 property_category $"Layout"
8895 if(value == null) return;
8897 anchor.left = value.x;
8898 anchor.top = value.y;
8899 anchor.right.type = none;
8900 anchor.bottom.type = none;
8905 normalAnchor = anchor;
8907 // Break the anchors for moveable/resizable windows
8911 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8913 normalAnchor.left = x;
8914 normalAnchor.top = y;
8915 normalAnchor.right.type = none;
8916 normalAnchor.bottom.type = none;
8917 normalSizeAnchor.size.width = w;
8918 normalSizeAnchor.size.height = h;
8922 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8924 stateAnchor = normalAnchor;
8925 stateSizeAnchor = normalSizeAnchor;
8927 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8928 Position(x,y, w, h, true, true, true, true, false, true);
8932 get { value = position; }
8935 property bool disabled
8937 property_category $"Behavior"
8940 if(this && disabled != value)
8947 get { return (bool)disabled; }
8950 property bool isEnabled
8955 for(parent = this; parent; parent = parent.parent)
8962 property WindowState state
8964 property_category $"Behavior"
8965 set { SetState(value, false, 0); }
8966 get { return this ? state : 0; }
8969 property bool visible
8971 property_category $"Behavior"
8974 if(this && !value && !style.hidden && parent)
8976 bool wasActiveChild = parent.activeChild == this;
8977 Window client = null;
8979 style.hidden = true;
8980 if(style.isActiveClient)
8982 parent.numPositions--;
8983 if(state == minimized) parent.numIcons--;
8988 OldLink prevOrder = null;
8990 if(rootWindow == this)
8991 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8994 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8997 box.left -= parent.clientStart.x;
8998 box.top -= parent.clientStart.y;
8999 box.right -= parent.clientStart.x;
9000 box.bottom -= parent.clientStart.y;
9004 if(_isModal && master && master.modalSlave == this)
9005 master.modalSlave = null;
9009 OldLink tmpPrev = order.prev;
9010 client = tmpPrev ? tmpPrev.data : null;
9011 if(client && !client.style.hidden && !client.destroyed && client.created)
9012 prevOrder = tmpPrev;
9015 client = tmpPrev ? tmpPrev.data : null;
9016 if(client == this) { client = null; break; }
9017 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9019 tmpPrev = client.order.prev;
9024 prevOrder = tmpPrev;
9029 // If this window can be an active client, make sure the next window we activate can also be one
9030 if(!style.nonClient && style.isActiveClient)
9032 tmpPrev = prevOrder;
9035 client = tmpPrev ? tmpPrev.data : null;
9036 if(client == this) { client = null; break; }
9037 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9039 tmpPrev = client.order.prev;
9044 prevOrder = tmpPrev;
9048 if(client && client.style.hidden) client = null;
9052 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9054 if(order && prevOrder && prevOrder.data != this)
9055 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9057 ActivateEx(false, false, false, true, null, null);
9059 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9060 if(parent.activeClient == this)
9062 parent.activeClient = null;
9063 parent.UpdateActiveDocument(null);
9066 else if(parent.activeClient == this)
9068 parent.activeClient = client;
9069 parent.UpdateActiveDocument(this);
9072 // *** Not doing this anymore ***
9075 parent.childrenCycle.Delete(cycle);
9077 parent.childrenOrder.Delete(order);
9082 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9087 else if(this && value && style.hidden)
9089 style.hidden = false;
9092 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9093 if(rootWindow == this)
9094 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9096 if(_isModal && master)
9097 master.modalSlave = this;
9099 if(style.isActiveClient)
9101 positionID = parent.GetPositionID(this);
9102 parent.numPositions++;
9103 if(state == minimized) parent.numIcons++;
9106 // *** NOT DOING THIS ANYMORE ***
9108 if(!(style.inactive))
9110 if(!(style.noCycle))
9112 cycle = parent.childrenCycle.AddAfter(
9113 (parent.activeChild && parent.activeChild.cycle) ?
9114 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9117 order = parent.childrenOrder.AddAfter(
9118 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9125 if(true || !parent.activeChild)
9126 ActivateEx(true, false, true, true, null, null);
9128 if(creationActivation == activate)
9129 ActivateEx(true, false, true, true, null, null);
9130 else if(creationActivation == flash && !object)
9133 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9137 ConsequentialMouseMove(false);
9143 style.hidden = !value;
9146 get { return (style.hidden || !setVisible) ? false : true; }
9149 property bool isDocument
9151 property_category $"Document"
9152 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9153 get { return style.isDocument; }
9156 property bool mergeMenus
9158 property_category $"Window Style"
9159 set { mergeMenus = value; }
9160 get { return (bool)mergeMenus; }
9163 property bool hasHorzScroll
9165 property_category $"Window Style"
9170 if(!style.hasHorzScroll && created)
9172 CreateSystemChildren();
9173 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9176 else if(style.hasHorzScroll)
9180 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9182 style.hasHorzScroll = value;
9185 get { return style.hasHorzScroll; }
9188 property bool hasVertScroll
9190 property_category $"Window Style"
9195 if(!style.hasVertScroll && created)
9197 style.hasVertScroll = true;
9198 CreateSystemChildren();
9199 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9202 else if(style.hasVertScroll)
9206 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9208 style.hasVertScroll = value;
9210 get { return style.hasVertScroll; }
9213 property bool dontHideScroll
9215 property_category $"Behavior"
9218 scrollFlags.dontHide = value;
9221 //UpdateScrollBars(true, true);
9222 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9226 // UpdateScrollBars(true, true);
9227 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9230 get { return scrollFlags.dontHide; }
9233 property bool dontScrollVert
9235 property_category $"Behavior"
9236 set { style.dontScrollVert = value; }
9237 get { return style.dontScrollVert; }
9239 property bool dontScrollHorz
9241 property_category $"Behavior"
9242 set { style.dontScrollHorz = value; }
9243 get { return style.dontScrollHorz; }
9246 property bool snapVertScroll
9248 property_category $"Behavior"
9251 scrollFlags.snapY = value;
9252 if(sbv) sbv.snap = value;
9254 get { return scrollFlags.snapY; }
9256 property bool snapHorzScroll
9258 property_category $"Behavior"
9261 scrollFlags.snapX = value;
9262 if(sbh) sbh.snap = value;
9264 get { return scrollFlags.snapX; }
9267 property Point scroll
9269 property_category $"Behavior"
9270 set { if(this) SetScrollPosition(value.x, value.y); }
9271 get { value = scroll; }
9274 property bool modifyVirtualArea
9276 property_category $"Behavior"
9277 set { modifyVirtArea = value; }
9278 get { return (bool)modifyVirtArea; }
9281 property bool dontAutoScrollArea
9283 property_category $"Behavior"
9284 // Activating a child control out of view will automatically scroll to make it in view
9285 set { noAutoScrollArea = value; }
9286 get { return (bool)noAutoScrollArea; }
9289 property const char * fileName
9291 property_category $"Document"
9296 if(menu && ((!fileName && value) || (fileName && !value)))
9298 MenuItem item = menu.FindItem(MenuFileSave, 0);
9299 if(item) item.disabled = !modifiedDocument && value;
9304 if(value && value[0])
9305 fileName = CopyString(value);
9307 if(parent && this == parent.activeClient)
9308 parent.UpdateActiveDocument(null);
9312 // if(style.isDocument)
9314 fileMonitor.fileName = value;
9316 get { return fileName; }
9321 property_category $"Data"
9326 property bool modifiedDocument
9328 property_category $"Document"
9331 if(style.isDocument || fileName)
9335 MenuItem item = menu.FindItem(MenuFileSave, 0);
9336 if(item) item.disabled = !value && fileName;
9340 if(modifiedDocument != value)
9342 modifiedDocument = value;
9343 if(style.isDocument || fileName)
9347 get { return (bool)modifiedDocument; }
9350 property bool showInTaskBar
9352 property_category $"Window Style"
9353 set { style.showInTaskBar = value; }
9354 get { return style.showInTaskBar; }
9356 property FileDialog saveDialog { set { saveDialog = value; } };
9357 property bool isActiveClient
9359 property_category $"Behavior"
9362 if(parent && style.isActiveClient != value && !style.hidden)
9366 if(state == minimized) parent.numIcons++;
9367 parent.numPositions++;
9371 if(state == minimized) parent.numIcons--;
9372 parent.numPositions--;
9375 style.isActiveClient = value;
9377 get { return style.isActiveClient; }
9380 property Cursor cursor
9382 property_category $"Appearance"
9386 SelectMouseCursor();
9388 get { return cursor; }
9391 //#if !defined(ECERE_VANILLA)
9392 property const char * name
9394 property_category $"Design"
9397 return (this && object) ? object.name : null;
9402 activeDesigner.RenameObject(object, value);
9406 property const char * displayDriver
9408 property_category $"Behavior"
9411 dispDriver = GetDisplayDriver(value);
9412 //DisplayModeChanged();
9416 return dispDriver ? dispDriver.name : null;
9420 // RUNTIME PROPERTIES
9421 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9422 property Size scrollArea
9424 property_category $"Behavior"
9428 SetScrollArea(value.w, value.h, false);
9430 SetScrollArea(0,0, true);
9432 get { value = scrollArea; }
9435 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9440 property_category $"Layout"
9441 set { if(this) is3D = value; }
9442 get { return (bool)is3D; }
9445 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9447 // Will be merged with font later
9448 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9449 property Point clientStart { get { value = clientStart; } };
9450 property Point absPosition { get { value = absPosition; } };
9451 property Anchor normalAnchor { get { value = normalAnchor; } };
9452 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9453 property bool active { get { return (bool)active; } };
9454 property bool created { get { return (bool)created; } };
9455 property bool destroyed { get { return (bool)destroyed; } };
9456 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9457 property Window firstChild { get { return children.first; } };
9458 property Window lastChild { get { return children.last; } };
9459 property Window activeClient { get { return activeClient; } };
9460 property Window activeChild { get { return activeChild; } };
9461 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9462 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9463 property ScrollBar horzScroll { get { return sbh; } };
9464 property ScrollBar vertScroll { get { return sbv; } };
9465 property StatusBar statusBar { get { return statusBar; } };
9466 property Window rootWindow { get { return rootWindow; } };
9467 property bool closing { get { return (bool)closing; } set { closing = value; } };
9468 property int documentID { get { return documentID; } };
9469 property Window previous { get { return prev; } }
9470 property Window next { get { return next; } }
9471 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9472 property PopupMenu menuBar { get { return menuBar; } }
9473 property ScrollBar sbv { get { return sbv; } }
9474 property ScrollBar sbh { get { return sbh; } }
9475 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9476 property void * systemHandle { get { return windowHandle; } }
9477 property Button minimizeButton { get { return sysButtons[0]; } };
9478 property Button maximizeButton { get { return sysButtons[1]; } };
9479 property Button closeButton { get { return sysButtons[2]; } };
9480 property BitmapResource icon
9482 get { return icon; }
9486 if(icon) incref icon;
9488 guiApp.interfaceDriver.SetIcon(this, value);
9491 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9492 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9493 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9494 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9495 property bool nativeDecorations
9497 get { return (bool)nativeDecorations; }
9498 set { nativeDecorations = value; }
9499 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9502 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9503 bool result = false;
9504 if(nativeDecorations)
9506 if(rootWindow == this)
9510 if(formDesigner && activeDesigner)
9512 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9513 Window form = cd ? cd.form : null;
9514 if(form && parent == form.parent)
9519 return result != style.fixed;
9523 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9525 property const char * text
9527 property_category $"Deprecated"
9529 set { property::caption = value; }
9530 get { return property::caption; }
9536 WindowBits style; // Window Style
9537 char * caption; // Name / Caption
9538 Window parent; // Parent window
9539 OldList children; // List of children in Z order
9540 Window activeChild; // Child window having focus
9541 Window activeClient;
9542 Window previousActive; // Child active prior to activating the default child
9543 Window master; // Window owning and receiving notifications concerning this window
9544 OldList slaves; // List of windows belonging to this window
9545 Display display; // Display this window is drawn into
9547 Point position; // Position in parent window client area
9548 Point absPosition; // Absolute position
9549 Point clientStart; // Client area position from (0,0) in this window
9551 Size clientSize; // Client area size
9552 Size scrollArea; // Virtual Scroll area size
9553 Size reqScrollArea; // Requested virtual area size
9554 Point scroll; // Virtual area scrolling position
9555 ScrollBar sbh, sbv; // Scrollbar window handles
9556 Cursor cursor; // Mouse cursor used for this window
9559 StatusBar statusBar;
9560 Button sysButtons[3];
9562 Box clientArea; // Client Area box clipped to parent
9564 HotKeySlot hotKey; // HotKey for this window
9568 ScrollFlags scrollFlags;// Window Scrollbar Flags
9569 int64 id; // Control ID
9571 ColorAlpha background; // Background color used to draw the window area
9573 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9574 OldList childrenCycle; // Cycling order
9575 OldLink cycle; // Element of parent's cycling order
9576 OldList childrenOrder; // Circular Z-Order
9577 OldLink order; // Element of parent's circular Z-Order
9578 Window modalSlave; // Slave window blocking this window's interaction
9580 Window rootWindow; // Topmost system managed window
9581 void * windowHandle; // System window handle
9583 DialogResult returnCode;// Return code for modal windows
9585 Point sbStep; // Scrollbar line scrolling steps
9588 SizeAnchor stateSizeAnchor;
9590 Anchor normalAnchor;
9591 SizeAnchor normalSizeAnchor;
9593 Size skinMinSize; // Minimal window size based on style
9594 Point scrolledPos; // Scrolled position
9595 Box box; // Window box clipped to parent
9596 Box * against; // What to clip the box to
9598 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9599 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9600 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9601 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9602 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9603 Point scrolledArea; // Distance to scroll area by
9604 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9606 OldList hotKeys; // List of the hotkeys of all children
9607 Window defaultControl; // Default child control
9611 ColorAlpha * palette; // Color palette used for this window
9613 int caretSize; // Size of caret, non zero if a caret is present
9614 Point caretPos; // Caret position
9616 void * systemParent; // Parent System Window for embedded windows
9623 WindowState lastState;
9625 FileMonitor fileMonitor;
9627 FontResource setFont, systemFont;
9628 FontResource usedFont;
9629 FontResource captionFont;
9631 FileDialog saveDialog;
9633 SizeAnchor sizeAnchor;
9635 // FormDesigner data
9638 Extent * tempExtents; //[4];
9639 BitmapResource icon;
9641 CreationActivationOption creationActivation;
9644 bool active:1; // true if window and ancestors are active
9645 bool acquiredInput:1; // true if the window is processing state based input
9646 bool modifiedDocument:1;
9647 bool disabled:1; // true if window cannot interact
9648 bool isForegroundWindow:1;// true while a root window is being activated
9649 bool visible:1; // Visibility flag
9650 bool destroyed:1; // true if window is being destroyed
9651 bool anchored:1; // true if this window is repositioned when the parent resizes
9652 bool dirty:1; // Flag set to true if any descendant must be redrawn
9658 bool modifyVirtArea:1;
9659 bool noAutoScrollArea:1;
9662 bool setVisible:1; // FOR FORM DESIGNER
9668 bool useSharedMemory:1;
9671 bool nativeDecorations:1;
9672 bool manageDisplay:1;
9673 bool formDesigner:1; // True if we this is running in the form editor
9674 bool requireRemaximize:1;
9677 // Checks used internally for them not to take effect in FormDesigner
9678 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9679 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9681 WindowController controller;
9682 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9685 public class CommonControl : Window
9687 // creationActivation = doNothing;
9690 public property const String toolTip
9692 property_category $"Appearance"
9695 if(created) CommonControl::OnDestroy();
9697 toolTip = value ? ToolTip { tip = value; } : null;
9699 if(created) CommonControl::OnCreate();
9701 get { return toolTip ? toolTip.tip : null; }
9707 // (Very) Ugly work around for the fact that the parent watcher
9708 // won't fire when it's already been disconnected...
9709 eInstance_FireSelfWatchers(toolTip,
9710 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9716 toolTip.parent = this;
9725 public class Percentage : float
9727 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9731 sprintf(string, "%.2f", this);
9732 c = strlen(string)-1;
9735 if(string[c] != '0')
9736 last = Max(last, c);
9737 if(string[c] == '.')
9750 public void ApplySkin(Class c, const char * name, void ** vTbl)
9752 char className[1024];
9757 subclass(Window) wc = (subclass(Window))c;
9758 subclass(Window) base = (subclass(Window))c.base;
9760 sprintf(className, "%sSkin_%s", name, c.name);
9761 wc.pureVTbl = c._vTbl;
9762 c._vTbl = new void *[c.vTblSize];
9763 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9764 sc = eSystem_FindClass(c.module.application, className);
9768 for(m = 0; m < c.base.vTblSize; m++)
9770 if(c._vTbl[m] == base.pureVTbl[m])
9771 c._vTbl[m] = vTbl[m];
9776 for(m = 0; m < c.vTblSize; m++)
9778 if(sc._vTbl[m] != wc.pureVTbl[m])
9779 c._vTbl[m] = sc._vTbl[m];
9783 for(d = c.derivatives.first; d; d = d.next)
9785 ApplySkin(d.data, name, c._vTbl);
9789 public void UnapplySkin(Class c)
9791 subclass(Window) wc = (subclass(Window))c;
9794 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9797 c._vTbl = wc.pureVTbl;
9801 for(d = c.derivatives.first; d; d = d.next)
9803 UnapplySkin(d.data);
9807 void CheckFontIntegrity(Window window)
9812 if(window.usedFont && window.usedFont.font == 0xecececec)
9814 FontResource uf = window.usedFont;
9815 char * className = window._class.name;
9816 char * text = window.text;
9819 for(c = window.firstChild; c; c = c.next)
9820 CheckFontIntegrity(c);
9824 public class ControllableWindow : Window
9826 /*WindowController controller;
9827 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9828 ~ControllableWindow() { delete controller; }*/
9831 class WindowControllerInterface : ControllableWindow
9833 bool OnKeyDown(Key key, unichar ch)
9835 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9837 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9841 bool OnKeyUp(Key key, unichar ch)
9843 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9845 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9849 bool OnKeyHit(Key key, unichar ch)
9851 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9853 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9857 bool OnMouseMove(int x, int y, Modifiers mods)
9859 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9861 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9865 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9867 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9869 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9873 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9875 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9877 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9881 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9883 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9885 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9889 bool OnRightButtonDown(int x, int y, Modifiers mods)
9891 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9893 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9897 bool OnRightButtonUp(int x, int y, Modifiers mods)
9899 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9901 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9905 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9907 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9909 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9913 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9915 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9917 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9921 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9923 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9925 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9929 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9931 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9933 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9937 void OnResize(int width, int height)
9939 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9940 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9943 void OnRedraw(Surface surface)
9945 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9946 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9951 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9953 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9957 bool OnLoadGraphics()
9959 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9961 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9965 void OnUnloadGraphics()
9967 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9968 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9972 public class WindowController<class V>
9975 property Window window
9979 uint size = class(Window).vTblSize;
9982 windowVTbl = new void *[size];
9983 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9984 if(value._vTbl == value._class._vTbl)
9986 value._vTbl = new void *[value._class.vTblSize];
9987 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9991 for(c = 0; c < size; c++)
9993 void * function = class(WindowControllerInterface)._vTbl[c];
9994 if(function != DefaultFunction)
9995 value._vTbl[c] = function;
9997 value._vTbl[c] = windowVTbl[c];
10002 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10005 get { return window; }
10007 property V controlled
10009 set { controlled = value; }
10010 get { return controlled; }
10012 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10013 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10014 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10015 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10016 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10017 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10018 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10019 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10020 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10021 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10022 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10023 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10024 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10025 virtual void V::OnResize(WindowController controller, int width, int height);
10026 virtual void V::OnRedraw(WindowController controller, Surface surface);
10027 virtual bool V::OnCreate(WindowController controller);
10028 virtual bool V::OnLoadGraphics(WindowController controller);
10029 virtual void V::OnUnloadGraphics(WindowController controller);
10032 int (** windowVTbl)();
10036 ~WindowController()