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);
705 //#if !defined(ECERE_VANILLA)
706 const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
708 if(this == activeDesigner)
712 const char * name = property::name;
713 return name ? name : "";
718 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
719 bool OnGetDataFromString(const char * string)
721 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
724 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
725 this = designer.form;
726 else if(!strcmpi(string, "(Desktop)"))
727 this = activeDesigner;
729 return activeDesigner.FindObject(&this, string);
735 // --- Window updates system ---
737 // Setup a bitmap for Redrawing on client area of Window
738 Surface Redraw(Box box)
740 Surface surface = null;
742 Box clientArea = this.clientArea;
746 mox.left -= clientStart.x;
747 mox.top -= clientStart.y;
748 mox.right -= clientStart.x;
749 mox.bottom -= clientStart.y;
751 mox.Clip(clientArea);
752 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
754 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
756 int x = absPosition.x + clientStart.x;
757 int y = absPosition.y + clientStart.y;
758 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
760 x -= rootWindow.clientStart.x;
761 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
763 if(!guiApp.fullScreenMode || is3D)
765 x -= rootWindow.absPosition.x;
766 y -= rootWindow.absPosition.y;
770 int dx = rootWindow.parent.parent.clientStart.x;
771 int dy = rootWindow.parent.parent.clientStart.y;
772 if(!rootWindow.parent.nativeDecorations)
774 dx += rootWindow.parent.clientStart.x;
775 dy += rootWindow.parent.clientStart.y;
789 surface = display.GetSurface(x, y, mox);
792 surface.width = clientSize.w;
793 surface.height = clientSize.h;
799 // Setup a bitmap for Redrawing on full Window
800 Surface RedrawFull(Box box)
802 Surface surface = null;
810 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
812 int x = absPosition.x;
813 int y = absPosition.y;
814 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
816 x -= rootWindow.clientStart.x;
817 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
819 if(!guiApp.fullScreenMode || is3D)
821 x -= rootWindow.absPosition.x;
822 y -= rootWindow.absPosition.y;
825 int dx = rootWindow.parent.parent.clientStart.x;
826 int dy = rootWindow.parent.parent.clientStart.y;
827 if(!rootWindow.parent.nativeDecorations)
829 dx += rootWindow.parent.clientStart.x;
830 dy += rootWindow.parent.clientStart.y;
844 surface = display.GetSurface(x, y, mox);
847 surface.width = size.w;
848 surface.height = size.h;
854 void FigureCaption(char * caption)
856 Window activeClient = null;
860 strcpy(caption, this.caption);
861 if(style.isDocument || fileName)
863 if(caption[0]) strcat(caption, " - ");
865 strcat(caption, fileName);
869 sprintf(title, "Untitled %d", documentID);
870 strcat(caption, title);
873 strcat(caption, " *");
878 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
880 if(activeClient && activeClient.state == maximized)
882 if(activeClient.caption)
884 if(caption[0]) strcat(caption, " - ");
885 strcat(caption, activeClient.caption);
887 if(activeClient.style.isDocument || activeClient.fileName)
889 if(caption[0]) strcat(caption, " - ");
890 strcat(caption, "[");
891 if(activeClient.fileName)
892 strcat(caption, activeClient.fileName);
896 sprintf(title, "Untitled %d", activeClient.documentID);
897 strcat(caption, title);
899 if(activeClient.modifiedDocument)
900 strcat(caption, " *");
901 strcat(caption, "]");
906 // Code for returning dirty from ScrollDisplay:
908 for(d = 0; d<scrollExtent.count; d++)
910 Box * box = &scrollExtent.boxes[d];
916 Min(box.right, box.left-scroll.x),box.bottom
918 dirtyArea.UnionBox(update);
924 Max(box.left, box.right-scroll.x), box.top,
925 box.right, box.bottom
927 dirtyArea.UnionBox(update);
935 box.right, Min(box.bottom, box.top-scroll.y),
937 dirtyArea.UnionBox(update);
943 box.left, Max(box.top, box.bottom-scroll.y),
944 box.right, box.bottom
946 dirtyArea.UnionBox(update);
951 void UpdateDecorations(void)
953 // TODO: *** TEMPORARY HACK ***
960 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
962 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
964 Update({ -clientStart.x,0, -1, clientSize.h-1 });
966 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
969 // Returns w & h for Position
970 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
972 Window parent = this.parent ? this.parent : guiApp.desktop;
973 int xOffset = 0, yOffset = 0;
974 int vpw = parent ? parent.clientSize.w : 0;
975 int vph = parent ? parent.clientSize.h : 0;
976 int pw = parent ? parent.clientSize.w : 0;
977 int ph = parent ? parent.clientSize.h : 0;
978 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
979 int x = anchor.left.distance, y = anchor.top.distance;
980 float ex = 0, ey = 0;
981 MinMaxValue ew = 0, eh = 0;
983 float cascadeW, cascadeH;
985 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
986 int addX = 0, addY = 0;
988 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
990 Window masterWindow = this;
991 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
994 if(master == guiApp.desktop)
995 masterWindow = guiApp.desktop.activeChild;
997 masterWindow = master.rootWindow;
998 if(!masterWindow) masterWindow = this;
1000 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
1001 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
1004 pw = vpw = box.right - box.left + 1;
1006 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
1009 ph = vph = box.bottom - box.top + 1;
1025 vpw = pw = parent.size.w;
1026 vph = ph = parent.size.h;
1028 else if(!style.fixed /*|| style.isDocument*/)
1030 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1031 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1033 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1036 Desktop3D_FixSize(&pw, &ph);
1037 Desktop3D_FixSize(&vpw, &vph);
1040 if(pw < skinMinSize.w) pw = skinMinSize.w;
1041 if(ph < skinMinSize.h) ph = skinMinSize.h;
1042 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1043 if(vph < skinMinSize.h) vph = skinMinSize.h;
1045 // TODO: Must fix what we're snapping
1048 if(anchor.left.type)
1050 SNAPUP(x, textCellW);
1052 else if(anchor.right.type)
1054 SNAPDOWN(x, textCellW);
1059 SNAPUP(y, textCellH);
1061 else if(anchor.bottom.type)
1063 SNAPDOWN(y, textCellH);
1067 // This is required to get proper initial decoration size using native decorations on Windows
1068 #if defined(__WIN32__)
1069 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1070 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1072 GetDecorationsSize(&ew, &eh);
1074 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1076 // Leave room for non client windows (eventually dockable panels)
1078 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1079 for(win = parent.children.first; win; win = win.next)
1081 if(!win.nonClient && !win.isActiveClient && win.visible)
1083 Size size = win.size;
1084 Point pos = win.position;
1085 int left = pos.x, top = pos.y;
1086 int right = pos.x + size.w, bottom = pos.y + size.h;
1087 if(win.size.w > win.size.h)
1090 loY = Max(loY, bottom);
1091 else if(top > ph - ph / 4)
1092 hiY = Min(hiY, top);
1097 loX = Max(loX, right);
1098 else if(left > pw - pw / 4)
1099 hiX = Min(hiX, left);
1108 if(parent.sbv && !parent.sbv.style.hidden)
1109 pw += guiApp.currentSkin.VerticalSBW();
1110 if(parent.sbh && !parent.sbh.style.hidden)
1111 ph += guiApp.currentSkin.HorizontalSBH();
1113 if(anchor.left.type == cascade)
1115 w = (int)(pw * 0.80);
1116 h = (int)(ph * 0.80);
1118 else if(anchor.left.type >= vTiled)
1123 numTiling = parent.numPositions - parent.numIcons;
1124 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1125 if(anchor.left.type == vTiled)
1127 tilingH = (int)sqrt(numTiling);
1128 tilingW = numTiling / tilingH;
1132 tilingW = (int)sqrt(numTiling);
1133 tilingH = numTiling / tilingW;
1136 leftOver = numTiling - tilingH * tilingW;
1139 tilingSplit = (tilingW - leftOver) * tilingH;
1140 tilingLastH = tilingH+1;
1143 tilingSplit = numTiling;
1145 if(positionID >= tilingSplit)
1147 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1148 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1149 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1150 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1154 x = xOffset + pw * (positionID / tilingH) / tilingW;
1155 y = yOffset + ph * (positionID % tilingH) / tilingH;
1156 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1157 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1161 SNAPDOWN(x, textCellW);
1162 SNAPDOWN(y, textCellH);
1163 SNAPDOWN(x2, textCellW);
1164 SNAPDOWN(y2, textCellH);
1172 if(sizeAnchor.isClientW) w += ew;
1173 if(sizeAnchor.isClientH) h += eh;
1175 if(anchor.left.type == offset)
1176 x = anchor.left.distance;
1177 else if(anchor.left.type == relative)
1178 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1179 else if(anchor.right.type == relative)
1180 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1181 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1182 else if(anchor.right.type == offset)
1183 ex = vpw - anchor.right.distance;
1185 if(anchor.top.type == offset)
1186 y = anchor.top.distance;
1187 else if(anchor.top.type == relative)
1188 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1189 else if(anchor.bottom.type == relative)
1190 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1191 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1192 else if(anchor.bottom.type == offset)
1193 ey = vph - anchor.bottom.distance;
1195 if(anchor.left.type && anchor.right.type)
1197 switch(anchor.right.type)
1200 ex = pw * (1.0f-anchor.right.percent);
1201 w = Max((int)(ex + 0.5) - x, 0);
1204 ex = vpw - anchor.right.distance;
1205 w = Max((int)(ex + 0.5) - x, 0);
1209 if(anchor.top.type && anchor.bottom.type)
1211 switch(anchor.bottom.type)
1214 ey = ph * (1.0f-anchor.bottom.percent);
1215 h = Max((int)(ey + 0.5) - y, 0);
1218 ey = vph - anchor.bottom.distance;
1219 h = Max((int)(ey + 0.5) - y, 0);
1228 if(state == normal /*|| state == Hidden*/)
1230 bool addSbV = false, addSbH = false;
1232 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1233 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1235 w = Max(w, minSize.w);
1236 h = Max(h, minSize.h);
1237 w = Min(w, maxSize.w);
1238 h = Min(h, maxSize.h);
1240 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1242 if(w) w -= guiApp.currentSkin.VerticalSBW();
1245 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1247 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1251 if(!OnResizing(&w, &h))
1257 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1258 w += guiApp.currentSkin.VerticalSBW();
1259 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1260 h += guiApp.currentSkin.HorizontalSBH();
1262 w = Max(w, skinMinSize.w);
1263 h = Max(h, skinMinSize.h);
1276 SNAPDOWN(w, textCellW);
1277 SNAPDOWN(h, textCellH);
1280 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1282 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1285 (pw - w) / CASCADE_SPACE,
1286 (ph - h) / CASCADE_SPACE);
1292 cascW = (pw - w) / (numCascade-1);
1293 cascH = (ph - h) / (numCascade-1);
1294 SNAPDOWN(cascW, textCellW);
1295 SNAPDOWN(cascH, textCellH);
1296 cascadeW = (float)cascW;
1297 cascadeH = (float)cascH;
1301 numCascade = Max(numCascade, 2);
1302 cascadeW = (float)(pw - w) / (numCascade-1);
1303 cascadeH = (float)(ph - h) / (numCascade-1);
1306 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1307 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1309 else if(anchor.left.type < vTiled)
1311 if(!anchor.left.type || anchor.horz.type == middleRelative)
1313 if(!anchor.right.type)
1315 if(anchor.horz.type == middleRelative)
1316 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1318 x = vpw / 2 + anchor.horz.distance - w / 2;
1324 // case A_EDGE: x = x - w; break;
1326 if(!anchor.top.type || anchor.vert.type == middleRelative)
1328 if(!anchor.bottom.type)
1330 if(anchor.vert.type == middleRelative)
1331 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1333 y = vph / 2 + anchor.vert.distance - h / 2;
1339 // case A_EDGE: y = y - h; break;
1342 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1350 SNAPDOWN(x, textCellW);
1351 SNAPDOWN(y, textCellH);
1363 if(anchored && style.fixed && style.isActiveClient)
1368 void UpdateCaret(bool forceUpdate, bool erase)
1370 static Window lastWindow = null;
1371 static int caretX, caretY, caretSize;
1373 if(guiApp && guiApp.caretOwner == this)
1375 int x = caretPos.x - scroll.x;
1376 int y = caretPos.y - scroll.y;
1378 if((erase || this.caretSize) &&
1379 x >= clientArea.left && x <= clientArea.right &&
1380 y >= clientArea.top && y <= clientArea.bottom)
1384 guiApp.interfaceDriver.SetCaret(
1385 x + absPosition.x + clientStart.x,
1386 y + absPosition.y + clientStart.y, this.caretSize);
1387 guiApp.caretEnabled = true;
1389 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1393 if(lastWindow != this)
1395 updateBox.left = x + 1;
1397 updateBox.right = x + 2;
1398 updateBox.bottom = y + this.caretSize - 1;
1402 updateBox.left = Min(x + 1, caretX + 1);
1403 updateBox.top = Min(y, caretY);
1404 updateBox.right = Max(x + 2, caretX + 2);
1405 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1408 guiApp.caretOwner.Update(updateBox);
1415 caretSize = this.caretSize;
1421 guiApp.interfaceDriver.SetCaret(0,0,0);
1422 guiApp.caretEnabled = false;
1428 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1433 scrolledPos.x = position.x = x;
1434 scrolledPos.y = position.y = y;
1436 clientSize.w = size.w = w;
1437 clientSize.h = size.h = h;
1439 if(parent && !style.nonClient)
1441 //if(!style.fixed || style.isDocument)
1443 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1444 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1448 clientStart.x = clientStart.y = 0;
1450 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1452 //if(!activeClient || activeClient.state != maximized)
1453 if(!noAutoScrollArea)
1455 // Check if scroll area must be modified
1456 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1458 bool foundChild = false;
1460 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1461 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1462 for(child = children.first; child; child = child.next)
1464 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1465 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1467 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1468 w = Max(w, child.position.x + child.size.w);
1469 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1470 w = Max(w, Max(child.position.x, 0) + child.size.w);
1471 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1472 h = Max(h, child.position.y + child.size.h);
1473 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1474 h = Max(h, Max(child.position.y, 0) + child.size.h);
1479 if(foundChild && (w > cw || h > ch))
1481 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1483 int stepX = sbStep.x, stepY = sbStep.y;
1484 // Needed to make snapped down position match the skin's check of client area
1485 // against realvirtual
1488 SNAPDOWN(stepX, textCellW);
1489 SNAPDOWN(stepY, textCellH);
1490 stepX = Max(stepX, textCellW);
1491 stepY = Max(stepY, textCellH);
1493 if(scrollFlags.snapX)
1495 if(scrollFlags.snapY)
1498 reqScrollArea.w = w;
1499 reqScrollArea.h = h;
1502 else if(reqScrollArea.w || reqScrollArea.h)
1504 reqScrollArea.w = 0;
1505 reqScrollArea.h = 0;
1506 SetScrollPosition(0,0);
1511 // Automatic MDI Client Scrolling Area Adjustment
1512 if(parent && !parent.noAutoScrollArea)
1514 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1515 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1517 Window parent = this.parent;
1518 int w = parent.reqScrollArea.w;
1519 int h = parent.reqScrollArea.h;
1521 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1522 w = Max(w, position.x + size.w);
1523 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1524 w = Max(w, Max(position.x, 0) + size.w);
1525 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1526 h = Max(h, position.y + size.h);
1527 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1528 h = Max(h, Max(position.y, 0) + size.h);
1530 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1531 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1533 /*bool resize = false;
1534 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1535 // Needed to make snapped down position match the skin's check of client area
1536 // against realvirtual
1539 SNAPDOWN(stepX, textCellW);
1540 SNAPDOWN(stepY, textCellH);
1541 stepX = Max(stepX, textCellW);
1542 stepY = Max(stepY, textCellH);
1544 if(parent.scrollFlags.snapX)
1546 if(parent.scrollFlags.snapY)
1548 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1550 parent.reqScrollArea.w = w;
1551 parent.reqScrollArea.h = h;*/
1553 // parent.UpdateScrollBars(true, true);
1554 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1555 false, true, true, true, false, false);
1560 GetRidOfVirtualArea();
1564 UpdateScrollBars(modifyThisArea, false);
1565 else if(guiApp.currentSkin)
1568 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1570 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1571 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1572 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1573 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1576 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1577 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1579 absPosition = scrolledPos;
1580 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1581 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1583 if(this != guiApp.desktop && parent)
1585 absPosition.x += parent.absPosition.x;
1586 absPosition.y += parent.absPosition.y;
1587 if(!style.nonClient && this != guiApp.desktop)
1589 absPosition.x += parent.clientStart.x;
1590 absPosition.y += parent.clientStart.y;
1594 box = Box { 0, 0, size.w - 1, size.h - 1 };
1599 // Clip against parent's client area
1600 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1602 // Compute client area in this window coordinate system
1603 clientArea.left = 0;
1605 clientArea.right = clientSize.w - 1;
1606 clientArea.bottom = clientSize.h - 1;
1608 // Clip against parent's client area
1610 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1614 //absPosition.x -= parent.clientStart.x;
1615 //absPosition.y -= parent.clientStart.y;
1618 // Adjust all children
1619 for(child = children.first; child; child = child.next)
1620 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1622 UpdateCaret(false, false);
1625 void GetRidOfVirtualArea(void)
1627 if(parent && !parent.destroyed && style.fixed &&
1628 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1629 parent.reqScrollArea.w && parent.reqScrollArea.h)
1631 if(!parent.noAutoScrollArea)
1633 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1637 for(child = children.first; child; child = child.next)
1639 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1641 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1642 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1652 Window parent = this.parent;
1654 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1655 false, true, true, true, false, false);
1657 parent.SetScrollArea(0,0,true);
1658 parent.SetScrollPosition(0,0);
1664 public void ExternalPosition(int x, int y, int w, int h)
1666 Position(x, y, w, h, false, true, true, true, false, false);
1669 // (w, h): Full window size
1670 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1672 bool result = false;
1673 int oldCW = clientSize.w, oldCH = clientSize.h;
1674 bool clientResized, windowResized, windowMoved;
1676 //bool realResized = size.w != w || size.h != h;
1678 // TOCHECK: This wasn't in ecere.dll
1679 //if(!parent) return true;
1680 if(destroyed) return false;
1682 windowMoved = position.x != x || position.y != y || force;
1684 // windowResized = realResized || force;
1685 windowResized = size.w != w || size.h != h || force;
1687 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1693 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1694 scrolledPos.x - parent.clientStart.x + this.box.right,
1695 scrolledPos.y - parent.clientStart.y + this.box.bottom
1701 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1706 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1708 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1709 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1710 windowResized = true;
1712 if(display && rootWindow != this)
1715 if(guiApp && guiApp.windowMoving)
1717 if(guiApp.windowMoving.style.nonClient)
1718 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1720 guiApp.windowMoving.parent.SetMouseRangeToClient();
1730 // Buttons bitmap resources crash if we do this while switching mode
1731 if(!guiApp || !guiApp.modeSwitching)
1734 // Process Anchored Children
1738 for(child = children.first; child; child = child.next)
1741 ((child.stateAnchor.left.type != offset ||
1742 child.stateAnchor.top.type != offset ||
1743 child.stateAnchor.right.type != none ||
1744 child.stateAnchor.bottom.type != none) ||
1745 child.state == maximized || child.state == minimized))
1747 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1749 // child.Position(x, y, w, h, false, true, true, true, false);
1750 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1751 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1757 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1758 //if(updateScrollBars)
1760 OnResize(clientSize.w, clientSize.h);
1762 if((clientResized || windowMoved) && created)
1763 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1765 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1767 Window master = guiApp.interimWindow.master;
1768 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1771 if(rootWindow == this && !is3D)
1775 x -= guiApp.desktop.absPosition.x;
1776 y -= guiApp.desktop.absPosition.y;
1778 //guiApp.Log("Position %s\n", caption);
1781 if(windowResized || windowMoved)
1782 if(display && !display.flags.memBackBuffer && changeRootWindow)
1783 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1785 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1786 for(child = parent.children.first; child && child != this; child = child.next)
1787 if(child.rootWindow)
1788 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1793 if(windowMoved || windowResized)
1795 display.Lock(true /*false*/);
1798 display.Position(absPosition.x, absPosition.y);
1799 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1802 // result = realResized ? display.Resize(size.w, size.h) : true;
1803 if(nativeDecorations && rootWindow.windowHandle)
1805 int w = clientSize.w, h = clientSize.h;
1806 if(hasMenuBar) h += skinMenuHeight;
1807 if(hasStatusBar) h += statusBarHeight;
1808 if(sbv && sbv.visible) w += sbv.size.w;
1809 if(sbh && sbh.visible) h += sbh.size.h;
1810 result = manageDisplay ? display.Resize(w, h) : true;
1813 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1817 else if(clientResized)
1819 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1822 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1826 if(windowMoved || windowResized)
1831 if(guiApp.driver && changeRootWindow && windowHandle)
1833 if(windowResized || windowMoved)
1834 if(!display || display.flags.memBackBuffer)
1835 guiApp.interfaceDriver.PositionRootWindow(this,
1836 x, y, w, h, windowMoved, windowResized);
1837 guiApp.interfaceDriver.UpdateRootWindow(this);
1839 for(child = children.first; child; child = child.next)
1841 if(child.is3D && child.created)
1843 // Copy Display Content
1844 child.display.displaySystem = display.displaySystem;
1845 child.display.window = display.window;
1846 child.display.current = display.current;
1847 child.display.width = display.width;
1848 child.display.height = display.height;
1849 child.display.driverData = display.driverData;
1850 child.display.mutex = null;
1861 void UpdateScrollBars(bool flag, bool fullThing)
1864 bool resizeH = false, resizeV = false;
1865 bool scrolled = false;
1866 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1867 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1869 if(destroyed) return;
1870 if(guiApp.currentSkin)
1872 MinMaxValue cw = 0, ch = 0;
1873 bool sbvVisible, sbhVisible;
1874 int rangeH = 0, rangeV = 0;
1875 int positionH = 0, positionV;
1877 // First get client area with no respect to scroll bars
1882 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1884 if(scrollFlags.dontHide)
1887 cw -= guiApp.currentSkin.VerticalSBW();
1889 ch -= guiApp.currentSkin.HorizontalSBH();
1891 // Update the scrollbar visibility
1897 sbh.disabled = rangeH <= 1;
1898 if(sbh.style.hidden)
1908 sbv.disabled = rangeV <= 1;
1909 if(sbv.style.hidden)
1917 int oldHRange = sbh ? sbh.range : 0;
1918 int oldVRange = sbv ? sbv.range : 0;
1919 // Then start off with horizontal scrollbar range
1922 positionH = sbh.thumbPosition;
1929 SBSetTotal(sbh, rvw);
1932 ch -= guiApp.currentSkin.HorizontalSBH();
1935 // Do the same for vertical scrollbar
1938 positionV = sbv.thumbPosition;
1944 SBSetTotal(sbv, rvh);
1948 cw -= guiApp.currentSkin.VerticalSBW();
1949 // Maybe we need to set the range on the horizontal scrollbar again
1957 SBSetTotal(sbh, rvw);
1958 //sbh.Action(setRange, positionH, 0);
1959 if(rangeH <= 1 && sbh.range > 1)
1961 ch -= guiApp.currentSkin.HorizontalSBH();
1967 SBSetTotal(sbv, rvh);
1969 //sbv.Action(setRange, positionV, 0);
1974 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1975 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1978 // Update the scrollbar visibility
1979 if(!scrollFlags.dontHide)
1981 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1985 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1992 if(guiApp.currentSkin)
1999 sbhVisible = sbh.style.hidden ? true : false;
2001 sbvVisible = sbv.style.hidden ? true : false;
2003 // Do our resize here
2004 if(flag && (resizeH || resizeV) && fullThing)
2006 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2011 OnResize(clientSize.w, clientSize.h);
2017 sbh.visible = sbhVisible;
2019 sbv.visible = sbvVisible;
2021 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2022 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2025 sbh.pageStep = clientSize.w;
2027 sbv.pageStep = clientSize.h;
2029 // Notify doesn't handle setRange anymore... process it here
2032 int positionH = sbh.thumbPosition;
2033 if(scroll.x != positionH)
2035 OnHScroll(setRange, positionH, 0);
2039 SNAPDOWN(positionH, textCellW);
2040 scroll.x = positionH;
2046 int seen = clientSize.w, total = reqScrollArea.w;
2049 if(scrollFlags.snapX)
2050 SNAPDOWN(seen, sbStep.x);
2052 if(!total) total = seen;
2053 range = total - seen + 1;
2055 range = Max(range, 1);
2057 if(x >= range) x = range - 1;
2059 if(scrollFlags.snapX)
2060 SNAPUP(x, sbStep.x);
2064 OnHScroll(setRange, x, 0);
2069 SNAPDOWN(x, textCellW);
2075 int positionV = sbv.thumbPosition;
2076 if(scroll.y != positionV)
2078 OnVScroll(setRange, positionV, 0);
2082 SNAPDOWN(positionV, textCellH);
2083 scroll.y = positionV;
2089 int seen = clientSize.h, total = reqScrollArea.h;
2092 if(scrollFlags.snapY)
2093 SNAPDOWN(seen, sbStep.y);
2095 if(!total) total = seen;
2096 range = total - seen + 1;
2097 range = Max(range, 1);
2099 if(y >= range) y = range - 1;
2101 if(scrollFlags.snapY)
2102 SNAPUP(y, sbStep.y);
2106 OnVScroll(setRange, y, 0);
2111 SNAPDOWN(y, textCellH);
2117 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2120 for(child = children.first; child; child = child.next)
2122 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2125 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2126 child.Position(x, y, w, h, false, true, false, true, false, false);
2133 // Process Scrollbars
2135 if(sbh) // && !sbh.style.hidden
2138 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2139 // Need to set the range again (should improve...) since the scrollbars didn't have
2140 // the right size when UpdateScrollArea set the range on it
2143 sbh.seen = clientSize.w;
2147 if(sbv) // && !sbv.state.hidden
2150 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2151 // Need to set the range again (should improve...) since the scrollbars didn't have
2152 // the right size when UpdateScrollArea set the range on it
2155 sbv.seen = clientSize.h;
2160 // TESTING THIS LOWER
2161 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2164 for(child = children.first; child; child = child.next)
2166 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2169 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2170 child.Position(x, y, w, h, false, true, false, true, false, false);
2176 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2178 SetState(maximized, false, mods);
2182 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2184 SetState(normal, false, mods);
2188 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2190 SetState(minimized, false, mods);
2191 parent.CycleChildren(false, true, false, true);
2195 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2198 // Scroll bar notifications
2199 if(action != setRange)
2201 bool changed = false;
2205 if(scroll.x != position)
2207 OnHScroll(action, position, keyFlags);
2212 SNAPDOWN(position, textCellW);
2214 scroll.x = position;
2218 if(scroll.y != position)
2220 OnVScroll(action, position, keyFlags);
2225 SNAPDOWN(position, textCellH);
2227 scroll.y = position;
2231 bool childMove = false;
2232 for(child = children.first; child; child = child.next)
2234 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2237 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2238 child.Position(x, y, w, h, false, true, false, true, false, false);
2242 // Testing this patch out to solve MDI workspace redraw bugs
2243 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2244 // Scroll offsets to blame?
2248 UpdateCaret(false, false);
2252 // Testing this patch out to solve MDI workspace redraw bugs
2253 for(child = children.first; child; child = child.next)
2255 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2264 Window GetParentMenuBar()
2266 Window menuBarParent;
2267 if(formDesigner) return null;
2268 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2270 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2271 if(menuBarParent && !menuBarParent.isActiveClient)
2277 void CreateSystemChildren(void)
2279 Window parent = this;
2280 bool scrollBarChanged = false;
2281 bool hasClose = false, hasMaxMin = false;
2282 Point scroll = this.scroll;
2284 if(state == maximized)
2286 parent = GetParentMenuBar();
2293 if(style.hasClose) hasClose = true;
2294 if(style.hasMaximize || style.hasMinimize)
2301 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2303 sysButtons[2].Destroy(0);
2304 sysButtons[2] = null;
2306 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2308 sysButtons[1].Destroy(0);
2309 sysButtons[1] = null;
2311 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2313 sysButtons[0].Destroy(0);
2314 sysButtons[0] = null;
2317 if(hasClose && parent)
2324 parent, master = this,
2325 inactive = true, nonClient = true, visible = false;
2327 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2333 if(this.parent == guiApp.desktop)
2334 sysButtons[2].hotKey = altF4;
2335 else if(style.isActiveClient)
2336 sysButtons[2].hotKey = ctrlF4;
2337 sysButtons[2].Create();
2340 sysButtons[2].symbol = 'X';
2341 sysButtons[2].disabled = !style.hasClose;
2344 if(hasMaxMin && parent)
2348 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2349 if(state == maximized)
2352 method = RestoreButtonClicked;
2358 method = MaximizeButtonClicked;
2366 parent, master = this,
2367 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2369 sysButtons[1].Create();
2371 sysButtons[1].NotifyClicked = method;
2373 sysButtons[1].symbol = symbol;
2374 sysButtons[1].disabled = !style.hasMaximize;
2377 if(hasMaxMin && parent)
2381 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2382 if (state == minimized)
2385 method = RestoreButtonClicked;
2391 method = MinimizeButtonClicked;
2399 parent, master = this,
2400 hotKey = altM, inactive = true, nonClient = true, visible = false
2402 sysButtons[0].Create();
2404 sysButtons[0].NotifyClicked = method;
2406 sysButtons[0].symbol = symbol;
2407 sysButtons[0].disabled = !style.hasMinimize;
2410 // Create the scrollbars
2411 if(style.hasHorzScroll && !sbh)
2417 direction = horizontal,
2421 snap = scrollFlags.snapX,
2422 NotifyScrolling = ScrollBarNotification
2425 scrollBarChanged = true;
2427 else if(sbh && !style.hasHorzScroll)
2433 if(style.hasVertScroll && !sbv)
2439 direction = vertical,
2443 snap = scrollFlags.snapY,
2444 NotifyScrolling = ScrollBarNotification
2447 scrollBarChanged = true;
2449 else if(sbv && !style.hasVertScroll)
2454 if(scrollBarChanged)
2456 SetScrollLineStep(sbStep.x, sbStep.y);
2457 UpdateScrollBars(true, true);
2461 if(scrollBarChanged)
2463 if(sbh) sbh.thumbPosition = scroll.x;
2464 if(sbv) sbv.thumbPosition = scroll.y;
2468 void UpdateCaption(void)
2470 if(rootWindow == this)
2473 FigureCaption(caption);
2474 if(guiApp.interfaceDriver)
2475 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2477 UpdateDecorations();
2480 if(parent.activeClient == this) // Added this last check
2482 if(parent.rootWindow == parent)
2485 parent.FigureCaption(caption);
2486 if(guiApp.interfaceDriver)
2487 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2490 parent.UpdateCaption();
2492 parent.UpdateDecorations();
2496 void UpdateActiveDocument(Window previous)
2498 Window activeClient = this.activeClient;
2499 Window activeChild = this.activeChild;
2506 activeClient.CreateSystemChildren();
2508 previous.CreateSystemChildren();
2520 // Build window list
2523 Menu windowMenu = menu.FindMenu("Window");
2528 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2530 Window document = cycle.data;
2531 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2533 char name[2048], caption[2048];
2534 document.FigureCaption(caption);
2535 sprintf(name, "%d %s", id+1, caption);
2536 windowMenu.AddDynamic(MenuItem
2538 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2539 NotifySelect = MenuWindowSelectWindow
2543 if(activeClient.cycle == cycle) break;
2548 if((!previous && activeClient) || !activeClient)
2554 item = menu.FindItem(MenuWindowCloseAll, 0);
2555 if(item) item.disabled = false;
2556 item = menu.FindItem(MenuWindowNext, 0);
2557 if(item) item.disabled = false;
2558 item = menu.FindItem(MenuWindowPrevious, 0);
2559 if(item) item.disabled = false;
2560 item = menu.FindItem(MenuWindowCascade, 0);
2561 if(item) item.disabled = false;
2562 item = menu.FindItem(MenuWindowTileHorz, 0);
2563 if(item) item.disabled = false;
2564 item = menu.FindItem(MenuWindowTileVert, 0);
2565 if(item) item.disabled = false;
2566 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2567 if(item) item.disabled = false;
2568 item = menu.FindItem(MenuWindowWindows, 0);
2569 if(item) item.disabled = false;
2572 item = menu.FindItem(MenuFileClose, 0);
2573 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2574 item = menu.FindItem(MenuFileSaveAll, 0);
2575 if(item) item.disabled = numDocuments < 1;
2577 if(activeClient && activeClient.menu && activeClient.state != minimized)
2581 //activeClient.menu.Clean(activeClient);
2582 menu.Merge(activeClient.menu, true, activeClient);
2586 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2589 menu.Merge(activeChild.menu, true, activeChild);
2592 // This is called again for a child window change, with same active client
2593 OnActivateClient(activeClient, previous);
2594 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2595 parent.UpdateActiveDocument(null);
2598 void _ShowDecorations(Box box, bool post)
2600 if(rootWindow == this && nativeDecorations && !is3D) return;
2601 if(visible && this != guiApp.desktop)
2603 Surface surface = RedrawFull(box);
2607 FigureCaption(caption);
2610 ShowDecorations(captionFont.font,
2613 active, //parent.activeClient == this
2614 guiApp.windowMoving == this);
2616 PreShowDecorations(captionFont.font,
2619 active, //parent.activeClient == this
2620 guiApp.windowMoving == this);
2627 void UpdateExtent(Box refresh)
2629 Surface surface = null;
2631 if(!manageDisplay) { OnRedraw(null);return; }
2632 _ShowDecorations(refresh, false);
2634 surface = Redraw(refresh);
2635 // Opaque background: just fill before EW_REDRAW (clear?)
2638 surface.SetBackground(background);
2639 surface.SetForeground(foreground);
2640 surface.DrawingChar(' ');
2641 if(this == rootWindow)
2643 if(style.drawBehind || background.a)
2645 int a = background.a;
2646 // Premultiply alpha for clear color
2647 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2648 surface.Clear(colorBuffer);
2649 surface.SetBackground(background);
2652 else if(background.a)
2656 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2657 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2660 if(display.flags.alpha && background.a < 255 && background)
2662 surface.Area(0,0,clientSize.w, clientSize.h);
2663 /*if(style.clearDepthBuffer)
2664 surface.Clear(depthBuffer);*/
2666 else if(/*style.clearDepthBuffer || */background.a)
2668 int a = background.a;
2669 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2670 // Premultiply alpha for clear color
2671 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2672 surface.Clear(colorBuffer);
2673 surface.SetBackground(background);
2678 surface.TextFont(usedFont.font);
2679 surface.TextOpacity(false);
2683 // Draw the caret ...
2684 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2686 // surface.SetBackground(0xFFFFFF - background.color);
2687 surface.SetBackground(~background.color);
2689 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2690 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2696 void DrawOverChildren(Box refresh)
2698 Surface surface = Redraw(refresh);
2702 surface.DrawingChar(' ');
2703 surface.SetBackground(background);
2704 surface.SetForeground(foreground);
2706 surface.TextFont(usedFont.font);
2707 surface.TextOpacity(false);
2709 OnDrawOverChildren(surface);
2714 _ShowDecorations(refresh, true);
2717 void ComputeClipExtents(void)
2720 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2722 clipExtent.Copy(this.clipExtent);
2724 for(child = children.last; child; child = child.prev)
2726 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2728 bool opaque = child.IsOpaque(); // TODO: acess background directly
2729 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2731 child.clipExtent.Copy(clipExtent);
2732 child.clipExtent.Offset(-dx, -dy);
2733 child.clipExtent.IntersectBox(child.box);
2735 child.ComputeClipExtents();
2737 if(opaque && !child.style.nonClient)
2739 // Adjust the box for the parent:
2740 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2741 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2746 // ??? Only do this for overlapped window or if parent has with clip children flag
2748 // Do this if window has clip children flag on (default false?)
2749 // this.clipExtent = clipExtent;
2751 clipExtent.Free(null);
2754 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2757 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2758 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2760 offsetX -= rootWindow.clientStart.x;
2761 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2765 for(child = children.last; child; child = child.prev)
2767 bool opaque = child.IsOpaque();
2768 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2772 // Adjust renderArea to the root window level
2773 Extent * renderArea = &rootWindow.tempExtents[3];
2775 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2776 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2777 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2779 offsetX -= child.rootWindow.clientStart.x;
2780 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2784 Extent childRenderArea;
2786 if(backBufferUpdate != null)
2788 childRenderArea.Copy(backBufferUpdate);
2789 childRenderArea.Offset(-offsetX, -offsetY);
2792 childRenderArea.Copy(child.dirtyArea);
2794 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2795 renderArea.Copy(dirtyExtent);
2796 renderArea.Offset(-offsetX, -offsetY);
2797 childRenderArea.Union(renderArea);
2800 // Intersect with the clip extent
2801 childRenderArea.Intersection(child.clipExtent);
2804 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2806 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2807 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2809 renderArea->Offset(offsetX, offsetY);
2811 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2812 // overDirtyExtent.Union(renderArea);
2813 renderArea->Empty();
2814 // childRenderArea.Free();
2816 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2821 for(child = children.last; child; child = child.prev)
2823 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2825 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2830 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2832 bool opaque = IsOpaque();
2833 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2835 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2836 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2838 offsetX -= rootWindow.clientStart.x;
2839 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2843 for(child = children.last; child; child = child.prev)
2845 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2847 ColorAlpha background = *(ColorAlpha *)&child.background;
2848 bool opaque = child.IsOpaque();
2849 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2853 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2854 // Adjust renderArea to the root window level
2856 renderArea.Copy(child.dirtyArea);
2857 renderArea.Offset(offsetX, offsetY);
2858 dirtyExtent.Union(renderArea);
2859 overDirtyExtent.Union(renderArea);
2865 for(child = children.last; child; child = child.prev)
2867 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2869 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2873 if(backBufferUpdate != null)
2875 renderArea.Copy(backBufferUpdate);
2876 renderArea.Offset(-offsetX, -offsetY);
2878 overRenderArea.Copy(backBufferUpdate);
2879 overRenderArea.Offset(-offsetX, -offsetY);
2885 renderArea.Copy(dirtyArea);
2887 overRenderArea.Copy(dirtyArea);
2890 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2891 dirtyExtentWindow->Copy(dirtyExtent);
2892 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2893 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2894 dirtyExtentWindow->Empty();
2896 // Intersect with the clip extent
2897 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2900 if(renderArea.count > 10)
2903 printf("\nToo many extents (%d):\n", renderArea.count);
2905 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2906 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2911 for(c = 0; c<10; c++)
2914 FASTLIST_LOOP(renderArea, extentBox)
2916 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2918 renderArea.Copy(extent);
2920 FASTLIST_LOOP(renderArea, extentBox)
2923 printf("(%d, %d) - (%d, %d)\n",
2924 extentBox.box.left, extentBox.box.top,
2925 extentBox.box.right, extentBox.box.bottom);
2929 printf("\nNow %d\n", renderArea.count);
2935 // WHY WAS THIS COMMENTED ??
2937 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2938 dirtyExtentWindow->Copy(overDirtyExtent);
2939 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2940 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2941 dirtyExtentWindow->Empty();
2943 // Intersect with the clip extent
2944 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2950 if(scrollExtent.count)
2952 // Subtract render extent from scrolling extent
2953 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2955 if(backBufferUpdate == null)
2957 Extent * dirty = &rootWindow.tempExtents[3];
2960 // Intersect scrolling extent with clip extent
2961 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2963 // offset this scroll to be at the root window level
2964 scrollExtent.Offset(offsetX, offsetY);
2965 // Add area that was scrolled to the dirty extents of the back buffer
2966 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2970 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2971 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2972 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2977 scrollExtent.Empty();
2979 // Add the exposed extent to the window render area
2980 dirty->Offset(-offsetX, -offsetY);
2981 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2986 // Subtract the window's box from the transparency forced extent
2987 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2993 renderArea.Copy(this.renderArea);
2994 renderArea.Offset(offsetX, offsetY);
2995 dirtyExtent.Union(renderArea);
3001 Extent renderArea { };
3003 renderArea.Copy(overRenderArea);
3004 renderArea.Offset(offsetX, offsetY);
3005 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3010 if(backBufferUpdate != null)
3012 // Remove render area from dirty area
3013 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3015 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3022 // Remove the window render area from the dirty extents of the back buffer
3023 rootWindow.dirtyBack.Exclusion(renderArea);
3027 void Render(Extent updateExtent)
3031 Window rootWindow = this.rootWindow;
3032 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3033 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3035 offsetX -= rootWindow.clientStart.x;
3036 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3039 if(rootWindow.fullRender)
3048 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3049 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3054 /*if(renderArea.count)
3055 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3058 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3060 Box box = extentBox.box;
3063 /*printf("(%d, %d) - (%d, %d)\n",
3064 extentBox.box.left, extentBox.box.top,
3065 extentBox.box.right, extentBox.box.bottom);*/
3070 box.left += offsetX;
3072 box.right += offsetX;
3073 box.bottom += offsetY;
3075 if(updateExtent != null)
3076 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3080 for(child = children.first; child; child = child.next)
3081 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3082 child.Render(updateExtent);
3084 if(rootWindow.fullRender)
3085 DrawOverChildren(box);
3088 // TO DO: There's an issue about draw over children...
3089 // TO DO: Don't wanna go through this if method isn't used
3090 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3091 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3093 Box box = extentBox.box;
3095 DrawOverChildren(box);
3097 box.left += offsetX;
3099 box.right += offsetX;
3100 box.bottom += offsetY;
3102 if(updateExtent != null)
3103 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3106 for(child = children.first; child; child = child.next)
3107 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3108 child.Render(updateExtent);
3111 overRenderArea.Empty();
3114 public void UpdateDisplay(void)
3116 if(!manageDisplay) { OnRedraw(null);return; }
3117 if(rootWindow && this != rootWindow)
3118 rootWindow.UpdateDisplay();
3121 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3122 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3125 dirtyExtent.Clear();
3128 clipExtent.AddBox(box);
3130 display.StartUpdate();
3132 if(!rootWindow.fullRender)
3134 ComputeClipExtents();
3135 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3136 ComputeRenderArea(dirtyExtent, overExtent, null);
3139 clipExtent.Free(null);
3141 dirtyExtent.Free(null);
3142 overExtent.Free(null);
3144 if(display.flags.flipping)
3147 display.Update(null);
3151 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3152 updateExtent.Clear();
3154 Render(updateExtent);
3156 updateExtent.UnionBox(this.box, tempExtents[0]);
3159 //printf("\n\nUpdate:\n------------------------------------------\n");
3162 //FASTLIST_LOOP(updateExtent, extentBox)
3163 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3166 /*printf("Updating (%d, %d) - (%d, %d)\n",
3167 extentBox.box.left, extentBox.box.top,
3168 extentBox.box.right, extentBox.box.bottom);*/
3171 display.Update(extentBox.box);
3174 updateExtent.Free(null);
3177 display.EndUpdate();
3185 void UpdateBackDisplay(Box box)
3191 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3193 //printf("UpdateBackDisplay going through!\n");
3194 display.StartUpdate();
3198 intersection.Copy(dirtyBack);
3199 intersection.IntersectBox(box);
3201 dirtyExtent.Clear();
3204 clipExtent.AddBox(box);
3206 if(!rootWindow.fullRender)
3208 ComputeClipExtents();
3209 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3212 clipExtent.Free(null);
3214 intersection.Free(null);
3215 dirtyExtent.Free(null);
3216 overExtent.Free(null);
3221 if(display.flags.flipping)
3222 display.Update(null);
3225 rootWindow.display.Update(box);
3228 display.EndUpdate();
3232 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3233 if(dirtyBack.count > MAX_DIRTY_BACK)
3235 BoxItem extentBox, next;
3236 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3237 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3239 next = (BoxItem)extentBox.next;
3240 if(extentBox != first)
3242 if(extentBox.box.left < first.box.left)
3243 first.box.left = extentBox.box.left;
3244 if(extentBox.box.top < first.box.top)
3245 first.box.top = extentBox.box.top;
3246 if(extentBox.box.right > first.box.right)
3247 first.box.right = extentBox.box.right;
3248 if(extentBox.box.bottom > first.box.bottom)
3249 first.box.bottom = extentBox.box.bottom;
3250 dirtyBack.Delete(extentBox);
3259 // --- Window positioning ---
3260 // --- Window identification ---
3262 // Returns window at position "Position"
3263 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3265 Window child, result = null;
3267 box.left += absPosition.x;
3268 box.right += absPosition.x;
3269 box.top += absPosition.y;
3270 box.bottom += absPosition.y;
3272 if(!destroyed && visible && (acceptDisabled || !disabled))
3274 int lx = x - absPosition.x;
3275 int ly = y - absPosition.y;
3276 if(IsInside(lx, ly))
3277 // if(box.IsPointInside(Point{x, y}))
3279 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3280 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3283 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3284 Window ancestor = null;
3286 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3287 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3289 if(child != statusBar && child.rootWindow == rootWindow)
3291 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3298 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3300 if(child != statusBar && child.rootWindow == rootWindow)
3302 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3309 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3317 Window FindModal(void)
3319 Window modalWindow = this, check;
3320 Window check2 = null;
3321 for(check = this; check.master; check = check.master)
3323 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3325 modalWindow = check.master.modalSlave;
3326 check = modalWindow;
3328 // TESTING THIS FOR DROPBOX...
3329 if(!rootWindow || !rootWindow.style.interim)
3331 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3333 if(check2.modalSlave && check2.modalSlave.created)
3335 modalWindow = check2.modalSlave;
3343 if(modalWindow == this)
3345 for(check = this; check.activeChild; check = check.activeChild)
3347 if(check.modalSlave)
3349 modalWindow = check.modalSlave;
3355 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3356 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3359 void StopMoving(void)
3361 if(this == guiApp.windowMoving)
3363 guiApp.windowMoving = null;
3364 UpdateDecorations();
3365 SetMouseRange(null);
3368 if(rootWindow.active)
3369 guiApp.interfaceDriver.StopMoving(rootWindow);
3371 guiApp.windowCaptured.ReleaseCapture();
3372 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3373 guiApp.windowIsResizing = false;
3377 void SelectMouseCursor(void)
3382 Window cursorWindow = null;
3383 bool rx, ry, rex, rey;
3385 guiApp.desktop.GetMousePosition(&x, &y);
3386 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3388 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3389 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3390 else if(mouseWindow)
3392 modalWindow = mouseWindow.FindModal();
3393 x -= mouseWindow.absPosition.x;
3394 y -= mouseWindow.absPosition.y;
3395 if(guiApp.windowIsResizing)
3397 rex = guiApp.resizeEndX;
3398 rey = guiApp.resizeEndY;
3399 rx = guiApp.resizeX;
3400 ry = guiApp.resizeY;
3401 if((rex && rey) || (rx && ry))
3402 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3403 else if((rex && ry) || (rx && rey))
3404 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3405 else if((ry || rey) && (!rx && !rex))
3406 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3407 else if((rx || rex) && (!ry && !rey))
3408 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3410 else if(!modalWindow && !guiApp.windowCaptured &&
3411 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3412 &rx, &ry, &rex, &rey))
3414 if((rex && rey) || (rx && ry))
3415 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3416 else if((rex && ry) || (rx && rey))
3417 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3418 else if((ry || rey) && (!rx && !rex))
3419 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3420 else if((rx || rex) && (!ry && !rey))
3421 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3423 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3425 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3426 mouseWindow.rootWindow != mouseWindow)
3427 cursorWindow = mouseWindow.parent;
3429 cursorWindow = mouseWindow;
3431 else if(!guiApp.interimWindow)
3432 cursorWindow = guiApp.windowCaptured;
3435 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3436 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3438 else if(modalWindow)
3440 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3442 else if(guiApp.interimWindow)
3444 if(guiApp.interimWindow.cursor)
3445 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3447 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3452 // --- State based input ---
3453 bool AcquireInputEx(bool state)
3458 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3459 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3461 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3463 guiApp.acquiredWindow = state ? this : null;
3466 SetMouseRangeToClient();
3467 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3472 SelectMouseCursor();
3474 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3478 // --- Window activation ---
3479 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3482 if(!parent || !parent.style.inactive)
3484 Window parent = this.parent;
3487 if(rootWindow == this)
3488 Log(active ? "active\n" : "inactive\n");
3490 if(active && requireRemaximize)
3492 if(state == maximized)
3494 property::state = normal;
3495 property::state = maximized;
3497 requireRemaximize = false;
3500 // Testing this here...
3501 if(!parent || parent == guiApp.desktop || parent.active)
3503 this.active = active;
3506 // TESTING THIS HERE
3507 UpdateDecorations();
3508 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3509 result = NotifyActivate(master, this, active, previous);
3512 this.active = !active;
3517 if(!parent || parent == guiApp.desktop || parent.active)
3519 this.active = active;
3521 AcquireInputEx(active);
3522 if(active && isEnabled)
3526 if(guiApp.caretOwner)
3530 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3531 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3532 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3533 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3535 guiApp.caretOwner.Update(extent);
3538 if(visible || !guiApp.caretOwner)
3539 guiApp.caretOwner = this;
3540 UpdateCaret(false, false);
3546 this.active = false;
3548 AcquireInputEx(active);
3550 if(!active && guiApp.caretOwner == this)
3552 UpdateCaret(false, true);
3553 guiApp.caretOwner = null;
3554 guiApp.interfaceDriver.SetCaret(0,0,0);
3555 guiApp.caretEnabled = false;
3560 if(!active && parent && parent.activeChild && parent.activeChild != this)
3561 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3567 if(!active && menuBar)
3570 menuBar.OnActivate(false, null, &goOn, true);
3571 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3576 Window aChild = activeChild;
3578 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3590 void ConsequentialMouseMove(bool kbMoving)
3594 if(kbMoving || !guiApp.windowMoving)
3598 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3600 if(guiApp.interfaceDriver)
3601 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3603 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3604 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3610 bool IsDescendantOf(Window ancestor)
3613 for(window = this; window && window != ancestor; window = window.parent);
3614 return window == ancestor;
3617 bool IsSlaveOf(Window master)
3620 for(window = this; window && window != master; window = window.master);
3621 return window == master;
3624 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3628 if(this && !destroyed /*&& state != Hidden*/)
3630 Window swap = externalSwap;
3638 if(activateParent &&
3639 (parent.activeChild != this ||
3640 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3641 active && _isModal &&
3642 parent != master && master)
3643 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3649 bool real = parent.activeChild != this;
3651 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3652 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3653 !IsDescendantOf(guiApp.interimWindow) &&
3654 !IsSlaveOf(guiApp.interimWindow))
3656 Window interimWindow = guiApp.interimWindow;
3657 while(interimWindow && interimWindow != this)
3659 Window master = interimWindow.master;
3661 guiApp.interimWindow = null;
3662 if(guiApp.caretOwner)
3663 guiApp.caretOwner.UpdateCaret(false, false);
3665 incref interimWindow;
3666 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3671 delete interimWindow;
3672 interimWindow = (master && master.style.interim) ? master : null;
3677 guiApp.interimWindow = this;
3678 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3679 guiApp.caretEnabled = false;*/
3680 UpdateCaret(false, true);
3685 //bool acquireInput = false;
3687 parent.activeChild &&
3688 parent.activeChild.state == maximized &&
3689 parent != guiApp.desktop;
3691 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3696 swap = parent.activeChild;
3697 if(swap && swap.destroyed) swap = null;
3698 if(swap && swap != this)
3701 if(!swap.PropagateActive(false, this, &goOn, true))
3702 swap = parent.activeChild;
3713 if(!parent || parent.activeChild != this || style.interim)
3716 result = PropagateActive(true, swap, &goOn, true);
3717 if(!result && !goOn)
3722 //acquireInput = true;
3726 if(style.hasMaximize && parent != guiApp.desktop)
3729 SetState(maximized, false, 0);
3730 else if(state != maximized)
3733 for(child = parent.children.first; child; child = child.next)
3735 if(this != child && child.state == maximized)
3736 child.SetState(normal, false, 0);
3743 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3745 Window previous = parent.activeClient;
3746 parent.activeChild = this;
3747 if(!style.nonClient /*&& style.isActiveClient*/)
3751 if(style.isActiveClient)
3752 parent.activeClient = this;
3753 // Moved UpdateActiveDocument inside hidden check
3754 // To prevent activating previous window while creating a new one
3755 // (It was messing up the privateModule in the CodeEditor)
3756 parent.UpdateActiveDocument(previous);
3762 //if(!style.isRemote)
3764 if(rootWindow != this)
3766 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3767 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3769 else if(!guiApp.fullScreenMode)
3771 Window modalRoot = FindModal();
3772 if(!modalRoot) modalRoot = this;
3773 if(!modalRoot.isForegroundWindow)
3775 modalRoot.isForegroundWindow = true;
3776 // To check : Why is parent null?
3777 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3779 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3781 modalRoot.isForegroundWindow = false;
3786 if(result && real && (!style.inactive || moveInactive) && parent)
3788 Window last = parent.children.last;
3790 if(!style.stayOnTop)
3791 for(; last && last.style.stayOnTop; last = last.prev);
3793 parent.children.Move(this, last);
3795 // Definitely don't want that: why not?
3799 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3805 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3812 parent.activeChild = null;
3813 if(!style.nonClient /*&& style.isActiveClient*/)
3815 Window previous = parent.activeClient;
3816 if(style.isActiveClient)
3817 parent.activeClient = null;
3818 parent.UpdateActiveDocument(previous);
3822 if(this == guiApp.interimWindow)
3824 guiApp.interimWindow = null;
3825 if(guiApp.caretOwner)
3826 guiApp.caretOwner.UpdateCaret(false, false);
3828 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3835 if(!active || !swap)
3836 UpdateDecorations();
3838 swap.UpdateDecorations();
3840 if(active && rootWindow != this)
3841 ConsequentialMouseMove(false);
3848 // --- Input Messages ---
3849 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3851 static bool reEntrancy = false;
3852 if(reEntrancy) return;
3856 guiApp.cursorUpdate = true;
3857 if(guiApp.windowScrolling && !consequential)
3859 guiApp.windowScrolling.SetScrollPosition(
3860 (guiApp.windowScrolling.sbh) ?
3861 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3862 (guiApp.windowScrolling.sbv) ?
3863 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3865 if(guiApp.windowMoving)
3867 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3869 Window window = guiApp.windowMoving;
3871 int w = window.size.w;
3872 int h = window.size.h;
3877 rx = mouseX - guiApp.windowMovingStart.x;
3878 ry = mouseY - guiApp.windowMovingStart.y;
3881 window.GetDecorationsSize(&ew, &eh);
3883 if(guiApp.windowIsResizing)
3885 x = window.scrolledPos.x;
3886 y = window.scrolledPos.y;
3890 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3891 rx = guiApp.windowResizingBefore.w - aw;
3892 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3893 w = guiApp.windowResizingBefore.w - rx;
3897 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3898 ry = guiApp.windowResizingBefore.h - ah;
3899 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3900 ry = Max(ry, -guiApp.windowMovingBefore.y);
3901 h = guiApp.windowResizingBefore.h - ry;
3903 if(guiApp.resizeEndX)
3905 w = guiApp.windowResizingBefore.w + rx;
3908 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3916 w = Max(w, window.minSize.w);
3917 h = Max(h, window.minSize.h);
3918 w = Min(w, window.maxSize.w);
3919 h = Min(h, window.maxSize.h);
3921 if(!window.OnResizing(&w, &h))
3923 w = window.clientSize.w;
3924 h = window.clientSize.h;
3927 w = Max(w, window.skinMinSize.w);
3928 h = Max(h, window.skinMinSize.h);
3935 SNAPDOWN(w, textCellW);
3936 SNAPDOWN(h, textCellH);
3941 aw = Max(w,window.skinMinSize.w);
3942 rx = guiApp.windowResizingBefore.w - aw;
3943 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3944 w = guiApp.windowResizingBefore.w - rx;
3948 ah = Max(h,window.skinMinSize.h);
3949 ry = guiApp.windowResizingBefore.h - ah;
3950 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3951 ry = Max(ry, -guiApp.windowMovingBefore.y);
3952 h = guiApp.windowResizingBefore.h - ry;
3957 if(!guiApp.windowIsResizing || guiApp.resizeX)
3958 x = guiApp.windowMovingBefore.x + rx;
3959 if(!guiApp.windowIsResizing || guiApp.resizeY)
3960 y = guiApp.windowMovingBefore.y + ry;
3962 if(!guiApp.windowIsResizing)
3965 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3967 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3968 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3969 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3970 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3974 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3975 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3981 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3983 if(!window.OnMoving(&x, &y, w, h))
3985 x = window.scrolledPos.x;
3986 y = window.scrolledPos.y;
3992 SNAPDOWN(x, textCellW);
3993 SNAPDOWN(y, textCellH);
3996 if(!window.style.nonClient)
3998 if(!window.style.fixed /*|| window.style.isDocument*/)
4000 if(!window.style.dontScrollHorz)
4001 x += window.parent.scroll.x;
4002 if(!window.style.dontScrollVert)
4003 y += window.parent.scroll.y;
4007 // Break the anchors for moveable/resizable windows
4008 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4009 if(window.style.fixed)
4011 if(window.state == normal)
4013 window.normalAnchor = Anchor { left = x, top = y };
4014 window.normalSizeAnchor = SizeAnchor { { w, h } };
4015 window.anchored = false;
4019 window.stateAnchor = Anchor { left = x, top = y };
4020 window.stateSizeAnchor = SizeAnchor { { w, h } };
4022 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4023 // TOCHECK: Investigate why the following only redraws the scrollbars
4024 //window.Position(x, y, w, h, false, true, true, true, false, true);
4026 guiApp.movingLast.x = mouseX;
4027 guiApp.movingLast.y = mouseY;
4033 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4036 bool wasMoving = guiApp.windowMoving ? true : false;
4037 bool wasScrolling = guiApp.windowScrolling ? true : false;
4039 while(result && w != this)
4041 Window msgWindow = GetAtPosition(x,y, false, true, w);
4042 Window trueWindow = GetAtPosition(x,y, false, false, w);
4043 bool windowDragged = false;
4048 window = (w && !w.disabled) ? w : null;
4050 if(trueWindow) incref trueWindow;
4052 if(consequential) mods->isSideEffect = true;
4054 UpdateMouseMove(x, y, consequential);
4056 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4058 if(!guiApp.windowCaptured.isEnabled)
4059 guiApp.windowCaptured.ReleaseCapture();
4061 window = guiApp.windowCaptured;
4064 if(trueWindow && activate &&
4065 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4066 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4067 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4068 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4070 if(mods->alt && !mods->ctrl && !mods->shift)
4072 Window moved = trueWindow;
4073 for(moved = trueWindow; moved; moved = moved.parent)
4074 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4079 windowDragged = true;
4081 // Cancel the ALT menu toggling...
4082 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4087 if(window && activate &&
4088 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4089 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4090 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4091 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4093 Window modalWindow = window.FindModal();
4095 /*if(mods->alt && !mods->shift && !mods->ctrl)
4097 Window moved = window;
4098 for(moved = window; moved; moved = moved.parent)
4099 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4104 windowDragged = true;
4106 // Cancel the ALT menu toggling...
4107 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4113 Window activateWindow = modalWindow ? modalWindow : window;
4114 if(activateWindow && !activateWindow.isRemote)
4116 bool doActivation = true;
4117 //bool needToDoActivation = false;
4118 Window check = activateWindow;
4120 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4122 if(!check.style.inactive)
4124 //needToDoActivation = true;
4126 doActivation = false;
4131 if(!needToDoActivation)
4132 doActivation = false;
4135 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4136 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4138 // Let the OnLeftButtonDown do the activating instead
4139 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4147 incref activateWindow;
4148 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4150 delete activateWindow;
4154 if(activateWindow._refCount == 1)
4156 delete activateWindow;
4160 delete activateWindow;
4161 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4164 mods->isActivate = true;
4168 if(!modalWindow && window && !window.destroyed)
4170 if(!guiApp.windowCaptured || windowDragged)
4172 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4174 bool moving = ((window.state != maximized &&
4175 window.IsMouseMoving(
4176 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4177 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4179 if(!moving && window.IsMouseResizing(
4180 x - window.absPosition.x,
4181 y - window.absPosition.y,
4182 window.size.w, window.size.h,
4183 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4185 guiApp.windowIsResizing = true;
4186 guiApp.windowResizingBefore.w = window.size.w;
4187 guiApp.windowResizingBefore.h = window.size.h;
4189 if(guiApp.windowIsResizing || windowDragged || moving)
4192 guiApp.windowMoving = window;
4193 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4194 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4195 guiApp.windowMovingBefore.x = window.position.x;//s;
4196 guiApp.windowMovingBefore.y = window.position.y;//s;
4197 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4198 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4201 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4203 if(window.style.fixed &&
4205 window.IsMouseMoving(
4206 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4208 window.ShowSysMenu(x, y);
4212 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4214 if(window.sbv || window.sbh)
4217 guiApp.windowScrolling = window;
4218 guiApp.windowScrollingStart.x = x;
4219 guiApp.windowScrollingStart.y = y;
4220 guiApp.windowScrollingBefore.x = window.scroll.x;
4221 guiApp.windowScrollingBefore.y = window.scroll.y;
4224 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4226 if(window.style.hasMaximize &&
4227 window.IsMouseMoving(
4228 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4231 (window.state == maximized) ? normal : maximized, false, *mods);
4239 if(guiApp.windowMoving)
4241 if(guiApp.windowMoving.parent)
4243 if(guiApp.windowMoving.style.nonClient)
4244 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4246 guiApp.windowMoving.parent.SetMouseRangeToClient();
4250 window.UpdateDecorations();
4253 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4255 // Log("\n*** LEFT BUTTON UP ***\n");
4256 if(guiApp.windowMoving)
4257 guiApp.windowMoving.StopMoving();
4259 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4261 if(guiApp.windowScrolling)
4263 Window windowScrolling = guiApp.windowScrolling;
4264 guiApp.windowScrolling = null;
4265 windowScrolling.ReleaseCapture();
4269 if(!result || (window && window.destroyed)) window = null;
4271 if(window && window.FindModal())
4274 if(trueWindow && trueWindow.FindModal())
4282 msgWindow = GetAtPosition(x,y, true, false);
4284 msgWindow.SelectMouseCursor();
4287 if(guiApp.windowCaptured || trueWindow)
4289 Window prevWindow = guiApp.prevWindow;
4290 List<Window> overWindows = guiApp.overWindows;
4291 Iterator<Window> it { overWindows };
4296 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4299 result = w.OnMouseLeave(*mods);
4301 overWindows.TakeOut(w);
4305 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4307 guiApp.prevWindow.mouseInside = false;
4308 guiApp.prevWindow = null;
4312 if(trueWindow.IsDescendantOf(prevWindow))
4314 if(!overWindows.Find(prevWindow))
4315 overWindows.Add(prevWindow);
4317 // Eventually fix this not to include captured?
4318 else if(!prevWindow.OnMouseLeave(*mods))
4322 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4324 Box box = trueWindow.box;
4325 box.left += trueWindow.absPosition.x;
4326 box.right += trueWindow.absPosition.x;
4327 box.top += trueWindow.absPosition.y;
4328 box.bottom += trueWindow.absPosition.y;
4330 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4332 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4333 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4335 overX = Max(Min(overX, 32767),-32768);
4336 overY = Max(Min(overY, 32767),-32768);
4338 trueWindow.mouseInside = true;
4339 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4343 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4345 for(w : guiApp.overWindows; w == trueWindow)
4348 guiApp.overWindows.TakeOut(w);
4351 guiApp.prevWindow = trueWindow;
4354 guiApp.prevWindow = null;
4356 SelectMouseCursor();
4358 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4359 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4361 int clientX = x - (window.absPosition.x + window.clientStart.x);
4362 int clientY = y - (window.absPosition.y + window.clientStart.y);
4364 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4366 clientX = Max(Min(clientX, 32767),-32768);
4367 clientY = Max(Min(clientY, 32767),-32768);
4369 MouseMethod = (void *)window._vTbl[method];
4371 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4374 if(!MouseMethod(window, clientX, clientY, *mods))
4378 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4379 window.OnMouseLeave(*mods);
4386 if(result && w && w.clickThrough && w.parent)
4391 if(!result || !w || !w.clickThrough)
4398 // --- Mouse cursor management ---
4400 bool KeyMessage(uint method, Key key, unichar character)
4405 if(guiApp.interimWindow)
4406 this = guiApp.interimWindow;
4409 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4413 if(!style.inactive || rootWindow != this)
4415 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4416 Window modalWindow = FindModal();
4417 Window interimMaster = master ? master.rootWindow : null;
4421 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4422 status = OnSysKeyDown(key, character);
4423 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4424 status = OnSysKeyHit(key, character);
4425 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4426 status = OnSysKeyUp(key, character);
4433 // Process Key Message for Internal UI Keyboard actions
4434 if(status && !destroyed && menuBar && state != minimized)
4437 if((SmartKey)key != alt)
4438 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4441 SmartKey sk = (SmartKey) key;
4442 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4444 status = menuBar.KeyMessage(method, key, character);
4449 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4450 menuBar.OnKeyHit(escape, 0);
4452 if(!menuBar.focus && guiApp.caretOwner)
4453 guiApp.caretOwner.UpdateCaret(true, false);
4456 if(!destroyed && status)
4458 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4462 case left: case up: case right: case down:
4463 if(guiApp.windowMoving == this)
4466 int w = guiApp.windowMoving.size.w;
4467 int h = guiApp.windowMoving.size.h;
4468 int x = guiApp.windowMoving.scrolledPos.x;
4469 int y = guiApp.windowMoving.scrolledPos.y;
4473 if(key == down || key == up)
4474 step = Max(step, textCellH);
4476 step = Max(step, textCellW);
4479 if(guiApp.windowIsResizing)
4483 case left: w-=step; break;
4484 case right: w+=step; break;
4485 case up: h-=step; break;
4486 case down: h+=step; break;
4493 case left: x-=step; break;
4494 case right: x+=step; break;
4495 case up: y-=step; break;
4496 case down: y+=step; break;
4500 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4501 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4503 if(!guiApp.windowIsResizing || guiApp.resizeX)
4504 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4506 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4508 if(!guiApp.windowIsResizing || guiApp.resizeY)
4509 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4511 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4513 guiApp.interfaceDriver.SetMousePosition(x, y);
4514 ConsequentialMouseMove(true);
4522 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4524 guiApp.windowMoving.StopMoving();
4525 ConsequentialMouseMove(false);
4533 ShowSysMenu(absPosition.x, absPosition.y);
4541 if(!destroyed && status && state != minimized)
4543 // Process all the way down the children
4544 if(activeChild && !activeChild.disabled)
4546 status = activeChild.KeyMessage(method, key, character);
4548 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4549 key.code != left && key.code != right && key.code != up && key.code != down)
4551 status = activeClient.KeyMessage(method, key, character);
4555 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4557 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4558 // && defaultControl != activeChild)
4560 delete previousActive;
4561 previousActive = activeChild;
4562 if(previousActive) incref previousActive;
4564 ConsequentialMouseMove(false);
4565 if((defaultControl.active ||
4566 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4567 defaultControl.KeyMessage(method, defaultKey, character);
4573 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4575 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4582 ShowSysMenu(absPosition.x, absPosition.y);
4589 if(this != guiApp.desktop)
4591 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4593 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4595 MenuMoveOrSize(key.shift, true);
4599 else if(guiApp.windowMoving)
4601 guiApp.windowMoving.StopMoving();
4602 ConsequentialMouseMove(false);
4610 if(!destroyed && status && state != minimized)
4612 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4616 case tab: case shiftTab:
4618 Window cycleParent = this;
4619 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4620 cycleParent = master.parent;
4622 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4624 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4627 Window child = cycleParent.activeChild;
4629 // Scroll the window to include the active control
4630 if(cycleParent.sbh && !child.style.dontScrollHorz)
4632 if(child.scrolledPos.x < 0)
4633 cycleParent.sbh.Action(Position,
4634 cycleParent.scroll.x + child.scrolledPos.x, 0);
4635 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4636 cycleParent.sbh.Action(Position,
4637 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4639 if(cycleParent.sbv && !child.style.dontScrollVert)
4641 if(child.scrolledPos.y < 0)
4642 cycleParent.sbv.Action(Position,
4643 cycleParent.scroll.y + child.scrolledPos.y, 0);
4644 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4645 cycleParent.sbv.Action(Position,
4646 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4649 cycleParent.ConsequentialMouseMove(false);
4655 case f6: case shiftF6:
4656 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4658 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4659 if(parent == guiApp.desktop)
4660 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4670 if(CycleChildren(key.shift, true, false, true))
4678 // mIRC Style Window Shortcuts
4679 case alt1: case alt2: case alt3: case alt4: case alt5:
4680 case alt6: case alt7: case alt8: case alt9: case alt0:
4685 for(document = children.first; document; document = document.next)
4687 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4689 if(document == activeChild)
4691 if(document.state == minimized)
4692 document.SetState(normal, false, key);
4695 document.SetState(minimized, false, key);
4696 CycleChildren(false, true, false);
4701 if(activeChild.state == maximized && document.style.hasMaximize)
4702 document.SetState(maximized, false, key);
4703 else if(document.state == minimized)
4704 document.SetState(normal, false, key);
4705 document.Activate();
4720 if(!destroyed && status)
4722 if(state == minimized)
4727 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4729 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4731 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4732 previousActive.ActivateEx(true, false, false, true, null, null);
4733 delete previousActive;
4739 if(!destroyed && status)
4741 status = ProcessHotKeys(method, key, character);
4743 if(!destroyed && status && !modalWindow && state != minimized)
4746 status = KeyMethod(this, key, character);
4747 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4748 status = OnKeyHit(key, character);
4749 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4751 bool result = false;
4754 case ctrlUp: case ctrlDown:
4755 if(sbv && !guiApp.windowScrolling)
4756 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4758 case wheelUp: case wheelDown:
4759 if(sbv && !guiApp.windowScrolling)
4761 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4762 // Do we want to do a consequential move regardless of result in this case?
4763 ConsequentialMouseMove(false);
4766 case ctrlPageUp: case ctrlPageDown:
4767 if(sbh && !guiApp.windowScrolling)
4768 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4773 ConsequentialMouseMove(false);
4778 if(status && !destroyed && menuBar && state != minimized)
4779 status = menuBar.KeyMessage(method, key, character);
4781 if(style.interim && /*destroyed && */status && interimMaster)
4783 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4784 status = interimMaster.KeyMessage(method, key, character);
4791 bool ProcessHotKeys(uint method, Key key, unichar character)
4796 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4797 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4798 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4800 Window hotKeyWindow = hotKey.window;
4801 Window parent = hotKeyWindow.parent;
4802 Window prevActiveWindow = activeChild;
4803 // For when sys buttons are placed inside the menu bar
4804 if(parent && parent._class == class(PopupMenu))
4805 parent = parent.parent;
4807 // 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
4808 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4811 if(prevActiveWindow) incref prevActiveWindow;
4812 incref hotKeyWindow;
4813 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4814 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4817 delete hotKeyWindow;
4818 delete prevActiveWindow;
4822 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4823 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4824 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4826 // ********* WORKING ON THIS ***********
4827 if(prevActiveWindow && !guiApp.interimWindow)
4828 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4831 else if(hotKeyWindow.style.inactive)
4832 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4834 delete prevActiveWindow;
4835 delete hotKeyWindow;
4836 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4837 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4841 if(status && tabCycle)
4844 for(child = children.first; child; child = child.next)
4846 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4857 // --- Windows and graphics initialization / termination ---
4858 bool SetupRoot(void)
4862 // Setup relationship with outside world (bb root || !bb)
4863 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4864 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4868 tempExtents = new0 Extent[4];
4873 /*if(guiApp.fullScreenMode)
4874 rootWindow = guiApp.desktop;
4876 //rootWindow = parent.created ? parent.rootWindow : null;
4877 rootWindow = parent.rootWindow;
4880 against = &parent.box;
4882 against = &parent.clientArea;
4885 for(child = children.first; child; child = child.next)
4888 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4891 bool Setup(bool positionChildren)
4893 bool result = false;
4896 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4898 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4899 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4902 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4904 // This was here, is it really needed?
4905 //guiApp.interfaceDriver.ActivateRootWindow(this);
4909 displaySystem = DisplaySystem {};
4910 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4912 delete displaySystem;
4917 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4918 if(display.Create(displaySystem, windowHandle))
4925 // Sometimes icon does not show up on Windows XP if we set here...
4926 // guiApp.interfaceDriver.SetIcon(this, icon);
4928 else if(this != guiApp.desktop)
4930 display = rootWindow ? rootWindow.display : null;
4936 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4937 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4939 for(child = children.first; child; child = child.next)
4941 if(child.created && !child.Setup(false))
4944 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4945 child.UpdateCaption();
4950 bool SetupDisplay(void)
4952 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4953 if(is3D) return Window3D_SetupDisplay(this); else
4960 class_data void ** pureVTbl;
4962 bool LoadGraphics(bool creation, bool resetAnchors)
4964 bool result = false;
4965 bool success = false;
4967 WindowState stateBackup = state;
4969 if(((subclass(Window))_class).pureVTbl)
4971 if(_vTbl == _class._vTbl)
4973 _vTbl = ((subclass(Window))_class).pureVTbl;
4978 for(m = 0; m < _class.vTblSize; m++)
4980 if(_vTbl[m] == _class._vTbl[m])
4981 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4985 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4987 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4989 _vTbl = _class._vTbl;
4994 for(m = 0; m < _class.vTblSize; m++)
4996 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4997 _vTbl[m] = _class._vTbl[m];
5002 if(guiApp.fullScreenMode || this != guiApp.desktop)
5004 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5010 display.Lock(false);
5011 if(rootWindow == this)
5013 // Set Color Palette
5014 display.SetPalette(palette, true);
5018 if(guiApp.fullScreenMode && this == guiApp.desktop)
5023 for(c=0; c<SystemCursor::enumSize; c++)
5024 if(!guiApp.systemCursors[c].bitmap)
5026 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5027 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5028 if(guiApp.systemCursors[c].bitmapName)
5030 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5031 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5032 if(guiApp.systemCursors[c].bitmap)
5033 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5038 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5040 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5041 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5043 cursor.bitmap.paletteShades = cursor.paletteShades;
5047 guiApp.cursorUpdate = true;
5050 ConsequentialMouseMove(false);
5056 // Load Window Graphic Resources
5059 if(usedFont == setFont || usedFont == window.systemFont)
5060 RemoveResource(usedFont);
5063 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5066 RemoveResource(systemFont);
5069 RemoveResource(captionFont);
5071 for(ptr = resources.first; ptr; ptr = ptr.next)
5073 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5074 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5077 AddResource(setFont);
5079 AddResource(systemFont);
5081 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5088 //if(master && master.font)
5089 if(parent && parent.font)
5093 faceName = parent.font.faceName,
5094 size = parent.font.size,
5095 bold = parent.font.bold,
5096 italic = parent.font.italic,
5097 underline = parent.font.underline
5099 //font = parent.font;
5100 watch(parent) { font { } };
5103 font = guiApp.currentSkin.SystemFont();
5110 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5111 AddResource(captionFont);
5113 if(OnLoadGraphics())
5119 //SetScrollLineStep(sbStep.x, sbStep.y);
5121 if(this != guiApp.desktop)
5125 normalAnchor = anchor;
5126 normalSizeAnchor = sizeAnchor;
5129 // Break the anchors for moveable/resizable windows
5131 if(style.fixed && style.isDocument)
5133 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5145 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5146 stateSizeAnchor = SizeAnchor {};
5151 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5156 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5157 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5160 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5164 stateAnchor = normalAnchor;
5165 stateSizeAnchor = normalSizeAnchor;
5168 position = Point { };
5169 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5180 if(Position(x, y, w, h, true, false, true, true, true, true))
5182 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5185 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5202 success = result = true;
5205 if(!creation && result)
5207 // Load menu bar first because sys buttons are on it...
5210 if(!menuBar.LoadGraphics(false, resetAnchors))
5216 for(child = children.first; child; child = child.next)
5218 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5225 CreateSystemChildren();
5229 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5232 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5235 LogErrorCode(graphicsLoadingFailed, _class.name);
5237 // Do this here to avoid problems on Windows
5238 if(rootWindow == this && parent && stateBackup == maximized)
5239 property::state = maximized;
5243 void UnloadGraphics(bool destroyWindows)
5247 // Free children's graphics
5248 for(child = children.first; child; child = child.next)
5249 child.UnloadGraphics(destroyWindows);
5252 display.Lock(false);
5255 if(guiApp.fullScreenMode && this == guiApp.desktop)
5260 for(c=0; c<SystemCursor::enumSize; c++)
5261 if(guiApp.systemCursors[c].bitmap)
5262 delete guiApp.systemCursors[c].bitmap;
5264 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5265 delete cursor.bitmap;
5267 guiApp.cursorBackground.Free();
5270 if(display && display.displaySystem)
5274 for(ptr = resources.first; ptr; ptr = ptr.next)
5278 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5283 // Free window graphics
5286 // Free skin graphics
5287 if(rootWindow == this)
5289 DisplaySystem displaySystem = display.displaySystem;
5292 display.driverData = null;
5293 display.displaySystem = null;
5297 if(displaySystem && !displaySystem.numDisplays && !is3D)
5298 delete displaySystem;
5307 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5308 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5310 if(this == guiApp.desktop || parent == guiApp.desktop)
5312 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5313 guiApp.interfaceDriver.DestroyRootWindow(this);
5317 // --- Window Hiding ---
5319 void SetVisibility(bool state)
5321 bool visible = (style.hidden || !created) ? false : state;
5322 if(visible != this.visible)
5326 this.visible = visible;
5327 for(child = children.first; child; child = child.next)
5328 child.SetVisibility(visible);
5330 ConsequentialMouseMove(false);
5331 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5335 // --- Windows and graphics initialization / termination ---
5337 bool DisplayModeChanged(void)
5339 bool result = false;
5340 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5342 guiApp.modeSwitching = true;
5343 UnloadGraphics(false);
5345 if(LoadGraphics(false, false))
5347 guiApp.modeSwitching = false;
5352 // --- Window updates system ---
5354 void UpdateDirty(Box updateBox)
5356 if(!manageDisplay) { OnRedraw(null);return; }
5359 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5362 if(display.flags.flipping)
5365 rootWindow.UpdateDisplay();
5368 UpdateBackDisplay(updateBox);
5370 if(guiApp.fullScreenMode)
5372 guiApp.cursorUpdate = true;
5373 guiApp.PreserveAndDrawCursor();
5375 if(guiApp.fullScreenMode)
5376 guiApp.RestoreCursorBackground();
5382 // This function is strictly called as a result of system window activation
5383 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5386 Window interimMaster = null;
5387 Window interimWindow = guiApp.interimWindow;
5388 if(interimWindow && interimWindow.master)
5389 interimMaster = interimWindow.master.rootWindow;
5391 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5392 // SetState(normal, false, 0);
5393 SetState(lastState, false, 0);
5395 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5399 /* WTH is this doing here?
5400 while(swap && swap.activeChild)
5402 swap = swap.activeChild;
5405 // TESTING THIS BEFORE...
5406 if(interimWindow && this == interimMaster)
5410 // Window interimSwap = this;
5411 Window menuBar = this.menuBar;
5412 if(menuBar && interimWindow.master == menuBar)
5415 while(interimSwap && interimSwap.activeChild)
5416 interimSwap = interimSwap.activeChild;
5418 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5419 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5421 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5422 //result = ActivateEx(true, true, false, activateRoot, window, null);
5427 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5428 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5430 if(interimWindow == this && interimMaster && !active)
5432 while(interimMaster && interimMaster.interim && interimMaster.master)
5434 // printf("Going up one master %s\n", interimMaster._class.name);
5435 interimMaster = interimMaster.master.rootWindow;
5437 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5438 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5444 bool DestroyEx(int64 returnCode)
5447 Timer timer, nextTimer;
5449 OldLink prevOrder = null;
5450 Window client = null;
5452 if(parent) stopwatching(parent, font);
5454 // if(window.modalSlave) return false;
5455 if(destroyed || !created)
5462 OldLink slave = master.slaves.FindLink(this);
5463 master.slaves.Delete(slave);
5466 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5472 this.returnCode = (DialogResult)returnCode;
5474 AcquireInput(false);
5479 master.hotKeys.Delete(hotKey);
5483 if(guiApp.prevWindow == this)
5485 guiApp.prevWindow = null;
5490 for(w : guiApp.overWindows; w == this)
5493 guiApp.overWindows.TakeOut(w);
5497 if(guiApp.caretOwner == this)
5499 guiApp.interfaceDriver.SetCaret(0,0,0);
5500 UpdateCaret(false, true);
5501 guiApp.caretEnabled = false;
5506 parent.childrenCycle.Remove(cycle);
5510 OldLink tmpPrev = order.prev;
5511 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5512 prevOrder = tmpPrev;
5515 client = tmpPrev ? tmpPrev.data : null;
5516 if(client == this) { client = null; break; }
5517 if(client && (client.style.hidden || client.destroyed || !client.created))
5518 tmpPrev = client.order.prev;
5522 prevOrder = tmpPrev;
5527 // If this window can be an active client, make sure the next window we activate can also be one
5528 if(!style.nonClient && style.isActiveClient)
5530 tmpPrev = prevOrder;
5533 client = tmpPrev ? tmpPrev.data : null;
5534 if(client == this) { client = null; break; }
5535 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5536 tmpPrev = client.order.prev;
5540 prevOrder = tmpPrev;
5544 if(client && client.style.hidden) client = null;
5546 // parent.childrenOrder.Remove(order);
5549 if(parent && style.isActiveClient && visible)
5551 if(state == minimized) parent.numIcons--;
5552 parent.numPositions--;
5555 // TESTING THIS HERE!
5559 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5560 // to create a window inside a rootwindow that's being destroyed)
5561 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5563 if(master && !master.destroyed /*&&
5564 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5566 if(master.defaultControl == this)
5567 master.defaultControl = null;
5570 parent.OnChildAddedOrRemoved(this, true);
5571 if(parent && !parent.destroyed /*&&
5572 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5574 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5576 if(order && prevOrder && prevOrder.data != this && active)
5578 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5580 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5581 if(parent.activeClient == this)
5583 parent.activeClient = null;
5584 parent.UpdateActiveDocument(null);
5589 if(guiApp.interimWindow == this)
5592 PropagateActive(false, null, &goOn, true);
5596 //if(window.parent.activeChild == window)
5597 parent.activeChild = null;
5598 if(!style.nonClient /*&& style.isActiveClient*/)
5600 Window previous = parent.activeClient;
5601 if(style.isActiveClient)
5602 parent.activeClient = null;
5603 parent.UpdateActiveDocument(previous);
5608 else if(parent.activeClient == this)
5610 parent.activeClient = client;
5611 parent.UpdateActiveDocument(this);
5615 if(guiApp.interimWindow == this)
5617 guiApp.interimWindow = null;
5618 if(guiApp.caretOwner)
5620 Window desktop = guiApp.desktop;
5621 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5622 guiApp.caretOwner.UpdateCaret(false, false);
5627 if(_isModal && master && master.modalSlave == this)
5628 master.modalSlave = null;
5632 if(!guiApp.caretOwner && parent.caretSize)
5634 guiApp.caretOwner = parent;
5635 parent.UpdateCaret(false, false);
5636 parent.Update(null);
5639 // Why was this commented out?
5640 GetRidOfVirtualArea();
5646 dirtyArea.Free(null);
5647 dirtyBack.Free(null);
5648 scrollExtent.Free(null);
5650 /* ATTEMPTING TO MOVE THAT ABOVE
5659 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5660 for(;(child = window.children.first);)
5662 for(; child && (child.destroyed || !child.created); child = child.next);
5671 UnloadGraphics(true);
5674 delete previousActive;
5677 // statusBar = null;
5680 if(master && !master.destroyed)
5682 //master.NotifyDestroyed(this, this.returnCode);
5683 NotifyDestroyed(master, this, this.returnCode);
5686 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5688 nextTimer = timer.next;
5689 if(timer.window == this)
5691 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5692 // timer.window = null;
5698 if(this == guiApp.windowMoving)
5701 if(guiApp.windowCaptured == this)
5703 //guiApp.windowCaptured = null;
5705 if(rootWindow != this && rootWindow)
5706 rootWindow.ConsequentialMouseMove(false);
5714 //for(child = children.first; next = child ? child.next : null, child; child = next)
5715 for(;(child = children.first); )
5717 for(; child && (child.destroyed || !child.created); child = child.next);
5727 /* // MOVED THIS UP...
5730 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5731 for(;(child = window.children.first); )
5733 for(; child && (child.destroyed || !child.created); child = child.next);
5742 while((slave = slaves.first))
5744 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5746 ((Window)slave.data).DestroyEx(0);
5751 if(guiApp.caretOwner == this)
5752 guiApp.caretOwner = null;
5754 sysButtons[0] = null;
5755 sysButtons[1] = null;
5756 sysButtons[2] = null;
5759 if(rootWindow != this)
5761 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5764 box.left -= parent.clientStart.x;
5765 box.top -= parent.clientStart.y;
5766 box.right -= parent.clientStart.x;
5767 box.bottom -= parent.clientStart.y;
5769 if(parent) parent.Update(box);
5774 OldLink slave = master.slaves.FindVoid(this);
5775 master.slaves.Delete(slave);
5781 parent.children.Remove(this);
5786 //autoCreate = false;
5789 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5790 if(((subclass(Window))_class).pureVTbl)
5792 if(_vTbl == _class._vTbl)
5794 _vTbl = ((subclass(Window))_class).pureVTbl;
5799 for(m = 0; m < _class.vTblSize; m++)
5801 if(_vTbl[m] == _class._vTbl[m])
5802 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5811 void SetStateEx(WindowState newState, bool activate)
5814 WindowState prevState = state;
5818 if(prevState != newState)
5819 lastState = prevState;
5821 if(rootWindow != this || !nativeDecorations || !windowHandle)
5823 if(style.isActiveClient && !style.hidden && prevState == minimized)
5826 // This block used to be at the end of the function... moved it for flicker problem in X
5827 // ------------------------------------------------------
5831 stateAnchor = normalAnchor;
5832 stateSizeAnchor = normalSizeAnchor;
5835 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5836 stateSizeAnchor = SizeAnchor {};
5840 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5843 byte * idBuffer = new0 byte[size];
5845 for(child = parent.children.first; child; child = child.next)
5847 if(child != this && child.state == minimized)
5849 if(child.iconID > size - 2)
5851 idBuffer = renew0 idBuffer byte[size*2];
5852 memset(idBuffer + size, 0, size);
5855 idBuffer[child.iconID] = (byte)bool::true;
5858 for(c = 0; c<size; c++)
5863 if(style.isActiveClient && !style.hidden)
5866 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5867 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5871 // TOCHECK: Why was this here?
5872 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5873 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5874 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5876 Position(x, y, w, h, true, true, true, true, false, true);
5878 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5879 parent.UpdateActiveDocument(null);
5882 CreateSystemChildren();
5883 // ------------------------------------------------------
5886 int GetPositionID(Window forChild)
5890 byte * idBuffer = new0 byte[size];
5893 for(child = children.first; child; child = child.next)
5895 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5897 if(child.positionID > size - 2)
5899 idBuffer = renew0 idBuffer byte[size*2];
5900 memset(idBuffer + size, 0, size);
5903 idBuffer[child.positionID] = (byte)bool::true;
5906 for(c = 0; c<size; c++)
5913 // --- Window related graphics ---
5915 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5917 palette = newPalette;
5918 if(rootWindow.display)
5919 rootWindow.display.SetPalette(palette, colorMatch);
5922 public bool AcquireInput(bool acquired)
5925 if(acquiredInput != acquired)
5927 if(active || (!visible && creationActivation == activate))
5928 result = AcquireInputEx(acquired);
5933 acquiredInput = acquired ? result : !result;
5938 void ListChildren(ListBox listBox)
5942 for(child = children.first; child; child = child.next)
5944 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5946 DataRow row = listBox.AddRow();
5947 row.tag = (int64)(intptr)child;
5948 child.FigureCaption(caption);
5949 row.SetData(null, caption);
5954 void UpdateVisual(Box extent)
5956 if(guiApp.driver != null)
5958 if(guiApp.fullScreenMode && guiApp.desktop.display)
5960 guiApp.desktop.mutex.Wait();
5961 guiApp.desktop.display.Lock(true);
5964 if(guiApp.desktop.active)
5966 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5968 if(guiApp.desktop.display.flags.flipping)
5969 guiApp.desktop.Update(null);
5970 guiApp.desktop.UpdateDisplay();
5971 guiApp.cursorUpdate = true;
5973 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5975 guiApp.PreserveAndDrawCursor();
5976 // guiApp.desktop.display.ShowScreen();
5977 guiApp.cursorUpdate = false;
5978 guiApp.desktop.dirty = false;
5979 guiApp.RestoreCursorBackground();
5983 guiApp.desktop.display.Unlock();
5984 guiApp.desktop.mutex.Release();
5988 Window rootWindow = this.rootWindow;
5989 rootWindow.mutex.Wait();
5994 guiApp.SignalEvent();
5997 guiApp.waitMutex.Wait();
5998 guiApp.interfaceDriver.Lock(rootWindow);
5999 if(!rootWindow.style.hidden && rootWindow.dirty)
6001 if(rootWindow.display)
6003 rootWindow.UpdateDisplay();
6004 //rootWindow.display.ShowScreen(null);
6006 rootWindow.dirty = false;
6008 guiApp.interfaceDriver.Unlock(rootWindow);
6009 guiApp.waitMutex.Release();
6012 rootWindow.mutex.Release();
6017 void UnlockDisplay(void)
6019 guiApp.interfaceDriver.Unlock(rootWindow);
6022 void LockDisplay(void)
6024 guiApp.interfaceDriver.Lock(rootWindow);
6027 Surface GetSurface(Box box)
6029 return Redraw((box == null) ? this.box : box);
6032 void SetMousePosition(int x, int y)
6034 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6038 void IntegrationActivate(bool active)
6040 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6042 isForegroundWindow = true;
6043 ActivateEx(active, active, false, false, null, null);
6044 isForegroundWindow = false;
6049 Window QueryCapture(void)
6051 return guiApp.windowCaptured;
6054 int GetDocumentID(void)
6058 byte * idBuffer = new0 byte[size];
6061 for(child = children.first; child; child = child.next)
6063 // TO CHECK: Do we want a documentID when we already have a file name?
6064 if(child.style.isDocument && !child.fileName)
6066 if(child.documentID-1 > size - 2)
6068 idBuffer = renew0 idBuffer byte[size*2];
6069 memset(idBuffer + size, 0, size);
6072 idBuffer[child.documentID-1] = 1;
6075 for(c = 0; c<size; c++)
6083 void SetInitSize(Size size)
6086 sizeAnchor.size = size;
6087 normalSizeAnchor = sizeAnchor;
6089 // Break the anchors for moveable/resizable windows
6090 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6092 stateAnchor = normalAnchor;
6093 stateSizeAnchor = normalSizeAnchor;
6095 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6096 Position(x,y, w, h, true, true, true, true, false, true);
6100 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6102 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6104 guiApp.windowIsResizing = resize;
6105 guiApp.windowMoving = this;
6106 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6107 if(guiApp.windowIsResizing)
6109 guiApp.windowMovingStart.x += size.w - 1;
6110 guiApp.windowMovingStart.y += size.h - 1;
6112 guiApp.windowMovingBefore = scrolledPos;
6113 guiApp.windowResizingBefore = size;
6114 guiApp.windowMoving.UpdateDecorations();
6115 if(guiApp.windowIsResizing)
6116 guiApp.resizeEndX = guiApp.resizeEndY = true;
6118 if(setCursorPosition)
6119 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6123 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6124 guiApp.windowMovingStart.x += x - absPosition.x;
6125 guiApp.windowMovingStart.y += y - absPosition.y;
6128 if(guiApp.windowMoving)
6130 if(guiApp.windowMoving.style.nonClient)
6131 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6133 guiApp.windowMoving.parent.SetMouseRangeToClient();
6138 if(this == rootWindow)
6139 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6143 void SetupFileMonitor()
6147 fileMonitor = FileMonitor
6149 this, FileChange { modified = true };
6151 bool OnFileNotify(FileChange action, const char * param)
6154 fileMonitor.StopMonitoring();
6155 if(OnFileModified(action, param))
6156 fileMonitor.StartMonitoring();
6169 bool result = false;
6173 else if(guiApp && guiApp.driver != null)
6175 OldLink slaveHolder;
6177 bool visible = !style.hidden;
6181 systemParent = parent;
6182 parent = guiApp.desktop;
6184 last = parent ? parent.children.last : null;
6186 if((parent && parent != guiApp.desktop && !parent.created) ||
6187 (master && master != guiApp.desktop && !master.created))
6191 stopwatching(parent, font);
6194 property::parent = guiApp.desktop;
6195 if(!master) master = parent;
6197 if(_isModal && master.modalSlave)
6198 property::master = master.modalSlave;
6202 parent.children.Remove(this);
6205 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6206 if(slaveHolder.data == this)
6208 master.slaves.Delete(slaveHolder);
6213 if(parent == guiApp.desktop && !mutex)
6216 if(style.isDocument)
6219 parent.numDocuments--;
6220 documentID = parent.GetDocumentID();
6223 if(!style.stayOnTop)
6224 for(; last && last.style.stayOnTop; last = last.prev);
6226 parent.children.Insert((last == this) ? null : last, this);
6227 //parent.children.Add(this);
6230 dispDriver = parent.dispDriver;
6233 master.modalSlave = this;
6235 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6240 master.slaves.Add(slaveHolder = OldLink { data = this });
6245 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6247 if(style.isDefault && !master.defaultControl)
6248 master.defaultControl = this;
6250 stateAnchor = normalAnchor = anchor;
6251 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6253 // TOCHECK: Why is this here?
6254 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6255 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6257 this.visible = false;
6258 style.hidden = true;
6261 // autoCreate = true;
6269 if(parent == guiApp.desktop)
6270 Log("LoadGraphics %s\n", caption);
6272 if(LoadGraphics(true, false))
6280 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6287 if(style.hasMenuBar /*&& menu*/)
6293 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6294 interim = false, inactive = true, nonClient = true, size.h = 24
6302 // Create the system buttons
6303 CreateSystemChildren();
6305 UpdateActiveDocument(null);
6307 if(style.isDocument)
6311 MenuItem item = menu.FindItem(MenuFileSave, 0);
6312 if(item) item.disabled = !modifiedDocument && fileName;
6317 if(parent == guiApp.desktop)
6318 Log("Preemptive SetState %s\n", caption);
6321 // Preemptive Set State to ensure proper anchoring
6322 SetStateEx(state, false);
6324 style.hidden = true;
6330 for(child = children.first; child; child = next)
6333 if(!child.created && (child.autoCreate || child.wasCreated))
6340 for(link = slaves.first; link; link = next)
6342 Window slave = link.data;
6344 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6347 // Things might have happened that invalidated 'next'...
6348 // Start over the search for slaves to create.
6349 // (Added this to fix crash with Stacker & Toolbar)
6350 next = slaves.first;
6359 if(parent == guiApp.desktop)
6360 Log("Real SetState %s\n", caption);
6363 if(isActiveClient && visible)
6365 parent.numPositions--;
6366 if(state == minimized) parent.numIcons--;
6369 parent.OnChildAddedOrRemoved(this, false);
6371 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6373 // Real set state & activate for proper display & activation
6374 property::visible = visible;
6375 // SetState(state & 0x00000003, true, 0);
6376 guiApp.interfaceDriver.SetIcon(this, icon);
6381 /*if(rootWindow == this)
6382 guiApp.interfaceDriver.ActivateRootWindow(this);
6384 if(creationActivation == activate && guiApp.desktop.active)
6385 ActivateEx(true, false, true, true, null, null);
6386 else if(creationActivation == activate || creationActivation == flash)
6389 if(this == rootWindow)
6395 rootWindow.ConsequentialMouseMove(false);
6406 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6412 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6414 //style.hidden = true; // !visible;
6415 style.hidden = !visible;
6416 if(master.modalSlave == this)
6417 master.modalSlave = null;
6424 void WriteCaption(Surface surface, int x, int y)
6427 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6430 void Update(Box region)
6436 rootWindow = this.rootWindow;
6438 // rootWindow.mutex.Wait();
6439 if(!destroyed && visible && display)
6444 // Testing this to avoid repetitve full update to take time...
6445 if(rootWindow.fullRender)
6447 rootWindow.dirty = true;
6450 if(dirtyArea.count == 1)
6452 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6453 if(item.box.left <= box.left &&
6454 item.box.top <= box.top &&
6455 item.box.right >= box.right &&
6456 item.box.bottom >= box.bottom)
6458 rootWindow.dirty = true;
6463 if(display.flags.flipping && !rootWindow.dirty)
6465 if(this == rootWindow)
6469 rootWindow.Update(null);
6474 rootWindow.dirty = true;
6479 realBox.left += clientStart.x;
6480 realBox.top += clientStart.y;
6481 realBox.right += clientStart.x;
6482 realBox.bottom += clientStart.y;
6488 if(realBox.right >= realBox.left &&
6489 realBox.bottom >= realBox.top)
6491 // if(!rootWindow.fullRender)
6492 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6494 for(child = children.first; child; child = child.next)
6499 box.left -= child.absPosition.x - absPosition.x;
6500 box.top -= child.absPosition.y - absPosition.y;
6501 box.right -= child.absPosition.x - absPosition.x;
6502 box.bottom -= child.absPosition.y - absPosition.y;
6503 if(box.right >= child.box.left && box.left <= child.box.right &&
6504 box.bottom >= child.box.top && box.top <= child.box.bottom)
6506 box.left -= child.clientStart.x;
6507 box.top -= child.clientStart.y;
6508 box.right -= child.clientStart.x;
6509 box.bottom -= child.clientStart.y;
6515 realBox.left += absPosition.x - rootWindow.absPosition.x;
6516 realBox.top += absPosition.y - rootWindow.absPosition.y;
6517 realBox.right += absPosition.x - rootWindow.absPosition.x;
6518 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6519 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6522 else if(this == guiApp.desktop)
6525 for(window = children.first; window; window = window.next)
6531 Box childBox = region;
6533 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6534 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6535 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6536 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6538 window.Update(childBox);
6541 window.Update(null);
6546 // rootWindow.mutex.Release();
6553 if(guiApp.windowCaptured != this)
6555 if(guiApp.windowCaptured)
6559 //Logf("Captured %s (%s)\n", caption, class.name);
6560 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6561 guiApp.windowCaptured = this;
6567 bool Destroy(int64 code)
6572 if(!destroyed && !CloseConfirmation(false)) return false;
6576 // TOCHECK: Should autoCreate be set to false here?
6587 void Move(int x, int y, int w, int h)
6589 normalAnchor = Anchor { left = x, top = y };
6590 normalSizeAnchor = SizeAnchor { size = { w, h } };
6592 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6594 if(destroyed) return;
6596 stateAnchor = normalAnchor;
6597 stateSizeAnchor = normalSizeAnchor;
6599 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6600 Position(x,y, w, h, true, true, true, true, false, true);
6604 DialogResult Modal(void)
6610 // FIXES MEMORY LEAK IF Create() FAILED
6616 void SetScrollArea(int width, int height, bool snapToStep)
6620 int stepX = sbStep.x, stepY = sbStep.y;
6621 // Needed to make snapped down position match the skin's check of client area
6622 // against realvirtual
6625 SNAPDOWN(stepX, textCellW);
6626 SNAPDOWN(stepY, textCellH);
6627 stepX = Max(stepX, textCellW);
6628 stepY = Max(stepY, textCellH);
6630 if(scrollFlags.snapX)
6631 SNAPUP(width, stepX);
6632 if(scrollFlags.snapY)
6633 SNAPUP(height, stepY);
6636 reqScrollArea.w = width;
6637 reqScrollArea.h = height;
6638 noAutoScrollArea = (width > 0 || height > 0);
6640 UpdateScrollBars(true, true);
6643 void SetScrollPosition(int x, int y)
6646 sbh.Action(setPosition, x, 0);
6650 int seen = clientSize.w, total = reqScrollArea.w;
6652 if(scrollFlags.snapX)
6653 SNAPDOWN(seen, sbStep.x);
6655 if(!total) total = seen;
6656 range = total - seen + 1;
6657 range = Max(range, 1);
6659 if(x >= range) x = range - 1;
6661 if(scrollFlags.snapX)
6662 SNAPUP(x, sbStep.x);
6665 OnHScroll(setPosition, x, 0);
6669 SNAPDOWN(x, textCellW);
6675 sbv.Action(setPosition, y, 0);
6679 int seen = clientSize.h, total = reqScrollArea.h;
6682 if(scrollFlags.snapY)
6683 SNAPDOWN(seen, sbStep.y);
6685 if(!total) total = seen;
6686 range = total - seen + 1;
6687 range = Max(range, 1);
6689 if(y >= range) y = range - 1;
6691 if(scrollFlags.snapY)
6692 SNAPUP(y, sbStep.y);
6695 OnVScroll(setPosition, y, 0);
6698 SNAPDOWN(y, textCellH);
6703 UpdateCaret(false, false);
6706 void SetScrollLineStep(int stepX, int stepY)
6712 SNAPDOWN(stepX, textCellW);
6713 SNAPDOWN(stepY, textCellH);
6714 stepX = Max(stepX, textCellW);
6715 stepY = Max(stepY, textCellH);
6718 sbh.lineStep = stepX;
6720 sbv.lineStep = stepY;
6723 void SetState(WindowState newState, bool activate, Modifiers mods)
6727 if(state == newState || OnStateChange(newState, mods))
6729 //WindowState prevState = state;
6733 // This used to be at the end of the brackets... moved for X, testing...
6734 // This has the effect of activating the window through the system...
6735 if(rootWindow == this)
6736 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6738 SetStateEx(newState, activate);
6740 if(rootWindow == this && !rootWindow.nativeDecorations)
6742 int x = position.x, y = position.y;
6745 x -= guiApp.desktop.absPosition.x;
6746 y -= guiApp.desktop.absPosition.y;
6748 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6752 //state = prevState;
6754 if(state != maximized && style.hasMaximize)
6757 for(child = parent.children.first; child; child = child.next)
6759 if(child != this && child.state == maximized)
6760 child.SetStateEx(normal, false);
6764 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6765 parent.UpdateScrollBars(true, true);
6768 // Do we really need this stuff here?
6769 // Shouldn't the Activate stuff take care of it?
6770 if(parent.rootWindow == parent && style)
6773 parent.FigureCaption(caption);
6774 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6775 parent.UpdateDecorations();
6779 rootWindow.ConsequentialMouseMove(false);
6786 BitmapResource GetIcon(SkinBitmap iconID)
6788 return guiApp.currentSkin.GetBitmap(iconID);
6791 void SetMouseRange(Box range)
6793 if(range || guiApp.fullScreenMode)
6798 clip.left = range.left + absPosition.x + clientStart.x;
6799 clip.top = range.top + absPosition.y + clientStart.y;
6800 clip.right = range.right + absPosition.x + clientStart.x;
6801 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6805 clip.left = guiApp.desktop.box.left;
6806 clip.top = guiApp.desktop.box.top;
6807 clip.right = guiApp.desktop.box.right;
6808 clip.bottom = guiApp.desktop.box.bottom;
6810 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6813 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6816 void SetMouseRangeToClient(void)
6818 if(guiApp.fullScreenMode || this != guiApp.desktop)
6820 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6821 box.Clip(clientArea);
6825 SetMouseRange(null);
6828 void SetMouseRangeToWindow(void)
6830 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6831 if(this == guiApp.desktop)
6832 SetMouseRangeToClient();
6837 // x, y: Desktop Coordinates
6838 void ShowSysMenu(int x, int y)
6841 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6844 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6845 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6849 menu, $"Move", m, NotifySelect = MenuWindowMove,
6850 disabled = !style.fixed || state == maximized
6854 menu, $"Size", s, NotifySelect = MenuWindowSize,
6855 disabled = !style.sizable || state != normal
6859 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6860 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6864 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6865 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6869 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6870 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6872 MenuDivider { menu };
6875 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6876 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6878 windowMenu.Create();
6883 ActivateEx(true, true, true, true, null, null);
6886 void MakeActive(void)
6888 ActivateEx(true, false, true, false, null, null);
6891 void SoftActivate(void)
6893 if(guiApp.desktop.active)
6898 if(this == rootWindow)
6903 void Deactivate(void)
6905 ActivateEx(false, true, true, true, null, null);
6910 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6913 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6915 bool result = false;
6916 if(activeChild && activeChild.cycle)
6918 Window modalWindow, child = activeChild;
6919 if(!clientOnly /*&& parent.tabCycle*/)
6921 Window next = child;
6924 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6928 if(parent && parent.CycleChildren(backward, false, true, true))
6936 next = next.cycle.prev.data;
6938 next = next.cycle.next.data;
6939 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6944 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6945 parent.tabCycle && parent.CycleChildren(backward, false, false))
6949 if(tabCycleOnly && !tabCycle) return false;
6956 child = child.cycle.prev.data;
6958 child = child.cycle.next.data;
6959 if(child == child.parent.activeChild)
6961 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6964 modalWindow = child.FindModal();
6967 // Scroll the window to include the active control
6968 if(sbh && !child.style.dontScrollHorz)
6970 if(child.scrolledPos.x < 0)
6971 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6972 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6973 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6975 if(sbv && !child.style.dontScrollVert)
6977 if(child.scrolledPos.y < 0)
6978 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6979 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6980 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6984 child = modalWindow ? modalWindow : child;
6985 child.ActivateEx(true, true, true, true, null, null);
6986 if(child.tabCycle && child.childrenCycle.first)
6987 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6995 ConsequentialMouseMove(false);
6999 void AddResource(Resource resource)
7003 ResPtr ptr { resource = resource };
7007 // Load Graphics here if window is created already
7008 if(/*created && */display)
7010 display.Lock(false);
7011 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7012 ptr.loaded = display.displaySystem.LoadResource(resource);
7016 // Temporary hack to load font right away for listbox in dropbox ...
7017 else if(master && master.display)
7019 master.display.Lock(false);
7020 master.display.displaySystem.LoadResource(resource);
7021 master.display.Unlock();
7027 void RemoveResource(Resource resource)
7032 for(ptr = resources.first; ptr; ptr = ptr.next)
7034 if(ptr.resource == resource)
7040 // Unload Graphics here if window is created already
7041 if(/*created && */display)
7045 display.Lock(false);
7046 display.displaySystem.UnloadResource(resource, ptr.loaded);
7052 resources.Delete(ptr);
7057 void SetCaret(int x, int y, int size)
7064 if(active && !style.interim && isEnabled)
7066 if(visible || !guiApp.caretOwner)
7067 guiApp.caretOwner = size ? this : null;
7069 UpdateCaret(false, false);
7072 guiApp.interfaceDriver.SetCaret(0,0,0);
7073 UpdateCaret(false, true);
7074 guiApp.caretEnabled = false;
7077 else if(style.inactive && active)
7079 guiApp.interfaceDriver.SetCaret(0,0,0);
7080 UpdateCaret(false, true);
7081 guiApp.caretEnabled = false;
7086 void Scroll(int x, int y)
7088 bool opaque = !style.drawBehind || background.a;
7089 if(opaque && display && display.flags.scrolling)
7091 Box box = clientArea;
7092 box.left += clientStart.x;
7093 box.top += clientStart.y;
7094 box.right += clientStart.x;
7095 box.bottom += clientStart.y;
7097 //scrollExtent.Free(null);
7098 scrollExtent.AddBox(box);
7099 scrolledArea.x += x;
7100 scrolledArea.y += y;
7102 //scrollExtent.Free();
7103 //scrollExtent.AddBox(clientArea);
7104 //scrollExtent.Offset(clientStart.x, clientStart.y);
7105 //scrolledArea.x = x;
7106 //scrolledArea.y = y;
7112 rootWindow.dirty = true;
7115 void ReleaseCapture()
7117 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7119 Window oldCaptured = guiApp.windowCaptured;
7120 guiApp.windowCaptured = null;
7121 guiApp.prevWindow = null;
7124 //guiApp.Log("Released Capture\n");
7126 guiApp.interfaceDriver.SetMouseCapture(null);
7128 //oldCaptured.OnMouseCaptureLost();
7131 oldCaptured.ConsequentialMouseMove(false);
7136 private void _SetCaption(const char * format, va_list args)
7143 char caption[MAX_F_STRING];
7144 vsnprintf(caption, sizeof(caption), format, args);
7145 caption[sizeof(caption)-1] = 0;
7147 this.caption = CopyString(caption);
7152 firewatchers caption;
7156 /*deprecated*/ void SetText(const char * format, ...)
7159 va_start(args, format);
7160 _SetCaption(format, args);
7164 void SetCaption(const char * format, ...)
7167 va_start(args, format);
7168 _SetCaption(format, args);
7172 bool Grab(Bitmap bitmap, Box box, bool decorations)
7174 bool result = false;
7175 if(display || this == guiApp.desktop)
7177 Box clip = {MININT, MININT, MAXINT, MAXINT};
7183 clip.Clip(clientArea);
7185 clip.Clip(this.box);
7187 if(rootWindow != this)
7189 clip.left += absPosition.y;
7190 clip.top += absPosition.y;
7191 clip.right += absPosition.x;
7192 clip.bottom += absPosition.y;
7195 clip.left += decorations ? 0 : clientStart.x;
7196 clip.top += decorations ? 0 : clientStart.y;
7197 clip.right += decorations ? 0 : clientStart.x;
7198 clip.bottom += decorations ? 0 : clientStart.y;
7200 if(display && display.flags.flipping)
7202 rootWindow.Update(null);
7203 rootWindow.UpdateDisplay();
7210 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7211 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7215 result = display.Grab(bitmap, clip.left, clip.top,
7216 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7218 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7220 if(!bitmap.Convert(null, pixelFormat888, null))
7227 void GetMousePosition(int * x, int * y)
7229 int mouseX = 0, mouseY = 0;
7230 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7233 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7234 if(this != guiApp.desktop)
7236 mouseX -= absPosition.x + clientStart.x;
7237 mouseY -= absPosition.y + clientStart.y;
7244 DialogResult DoModal()
7246 DialogResult returnCode = 0;
7247 int terminated = terminateX;
7250 while(!destroyed && guiApp.driver != null)
7252 if(terminateX != terminated)
7254 terminated = terminateX;
7255 guiApp.desktop.Destroy(0);
7256 if(guiApp.desktop.created)
7259 //printf("Resetting terminate X to 0\n");
7265 guiApp.UpdateDisplay();
7266 if(!guiApp.ProcessInput(false))
7269 returnCode = this.returnCode;
7282 return !destroyed && guiApp.driver != null && terminateX < 2;
7285 DialogResult DoModalEnd()
7287 DialogResult returnCode = this.returnCode;
7292 // --- Window manipulation ---
7293 /*bool GetDisabled()
7295 bool disabled = this.disabled;
7297 for(window = this; (window = window.master); )
7308 // --- Mouse Manipulation ---
7309 void GetNCMousePosition(int * x, int * y)
7311 GetMousePosition(x, y);
7312 if(x) *x += clientStart.x;
7313 if(y) *y += clientStart.y;
7316 // --- Carets manipulation ---
7317 void GetCaretPosition(Point caretPos)
7319 caretPos = this.caretPos;
7322 int GetCaretSize(void)
7327 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7333 bool CloseConfirmation(bool parentClosing)
7346 if(!OnClose(parentClosing))
7349 // If you want to skip this, simply set modifiedDocument to false in OnClose
7350 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7352 DialogResult dialogRes;
7355 sprintf(message, $"Save changes to %s?", fileName);
7357 sprintf(message, $"Save changes to Untitled %d?", documentID);
7359 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7361 if(dialogRes == yes)
7363 // TOFIX: Precomp error if brackets are taken out
7364 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7366 else if(dialogRes == cancel)
7372 for(slave = slaves.first; slave; slave = slave.next)
7374 Window w = slave.data;
7375 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7383 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7386 for(child = children.first; child; child = child.next)
7387 if(child.isActiveClient && !child.CloseConfirmation(true))
7395 for(child = children.first; child; child = child.next)
7396 if(!child.isActiveClient && !child.CloseConfirmation(true))
7406 // Static methods... move them somewhere else?
7407 void ::RestoreCaret()
7409 if(guiApp.caretOwner)
7410 guiApp.caretOwner.UpdateCaret(false, false);
7413 void ::FreeMouseRange()
7415 guiApp.interfaceDriver.SetMouseRange(null, null);
7419 bool MenuFileClose(MenuItem selection, Modifiers mods)
7421 Window document = activeChild;
7423 document.Destroy(0);
7427 bool MenuFileExit(MenuItem selection, Modifiers mods)
7433 bool MenuFileSave(MenuItem selection, Modifiers mods)
7438 fileMonitor.fileName = null;
7441 if(OnSaveFile(fileName))
7443 //if(OnFileModified != Window::OnFileModified)
7446 fileMonitor.fileName = fileName;
7452 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7453 DialogResult answer = dialog.Modal();
7455 if(answer != yes) return (bool)answer;
7458 return MenuFileSaveAs(selection, mods);
7461 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7463 DialogResult result = (DialogResult)bool::true;
7464 FileDialog fileDialog = saveDialog;
7469 fileDialog = FileDialog {};
7474 fileDialog.filePath = fileName;
7477 char filePath[MAX_FILENAME];
7478 sprintf(filePath, "Untitled %d", documentID);
7479 fileDialog.filePath = filePath;
7481 fileMonitor.fileName = null;
7483 fileDialog.type = save;
7484 fileDialog.text = $"Save As";
7488 fileDialog.master = master.parent ? master : this;
7489 if(fileDialog.Modal() == ok)
7491 const char * filePath = fileDialog.filePath;
7493 if(OnSaveFile(filePath))
7496 property::fileName = filePath;
7497 NotifySaved(master, this, filePath);
7502 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7503 DialogResult answer = dialog.Modal();
7518 //if(OnFileModified != Window::OnFileModified && fileName)
7521 fileMonitor.fileName = fileName;
7525 return (bool)result; // Actually returning result from Yes/NoCancel message box
7528 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7530 Window document = activeChild;
7532 for(document = children.first; document; document = next)
7534 next = document.next;
7535 if(document.style.isDocument || document.fileName)
7536 document.MenuFileSave(selection, mods);
7541 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7545 for(document = children.first; document; document = document.next)
7546 //if(document.style.isDocument && document.state == minimized)
7547 if(document.style.isActiveClient && document.state == minimized)
7548 document.SetState(minimized, false, mods);
7552 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7554 Window document = activeChild;
7557 Window firstDocument = null;
7559 OldLink cycle = document.cycle.prev;
7564 if(child.style.isActiveClient && !child.style.hidden)
7568 firstDocument = child;
7569 if(child.state == minimized)
7570 child.SetState(minimized, false, mods);
7573 child.positionID = id++;
7574 child.SetState(normal, false, mods);
7575 child.anchor.left.type = cascade;
7578 child.normalSizeAnchor = *&child.sizeAnchor;
7579 child.normalAnchor = child.anchor;
7581 // Break the anchors for moveable/resizable windows
7582 if(child.style.fixed)
7584 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7586 (*&child.normalAnchor).left = x;
7587 (*&child.normalAnchor).top = y;
7588 (*&child.normalAnchor).right.type = none;
7589 (*&child.normalAnchor).bottom.type = none;
7590 (*&child.normalSizeAnchor).isClientW = false;
7591 (*&child.normalSizeAnchor).isClientH = false;
7592 (*&child.normalSizeAnchor).size.w = w;
7593 (*&child.normalSizeAnchor).size.h = h;
7594 child.anchored = false;
7597 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7599 child.stateAnchor = child.normalAnchor;
7600 child.stateSizeAnchor = child.normalSizeAnchor;
7602 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7603 child.Position(x, y, w, h, true, true, true, true, false, false);
7608 last = children.last;
7609 if(!child.style.stayOnTop)
7610 for(; last && last.style.stayOnTop; last = last.prev);
7611 children.Move(child, last);
7612 childrenOrder.Move(child.order, childrenOrder.last);
7614 if(cycle == document.cycle) break;
7618 firstDocument.Activate();
7623 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7630 // Close all closes all active clients, not all documents
7631 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7633 Window next, document;
7635 for(document = children.first; document; document = next)
7637 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7638 if(document.style.isActiveClient)
7639 if(!document.Destroy(0) && !document.style.hidden)
7645 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7647 if(style.hasMaximize && state != maximized)
7648 SetState(maximized, 0, 0);
7652 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7654 if(style.hasMinimize && state != minimized)
7656 SetState(minimized, 0, 0);
7657 parent.CycleChildren(false, true, false, true);
7662 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7664 MenuMoveOrSize(false, selection ? true : false);
7668 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7670 CycleChildren(false, true, false, true);
7674 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7676 CycleChildren(true, true, false, true);
7680 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7682 MenuMoveOrSize(true, true);
7686 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7689 SetState(normal, 0, 0);
7693 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7696 int64 id = selection.id;
7697 OldLink cycle = activeClient.cycle;
7699 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7702 Window sibling = cycle.data;
7703 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7711 document = cycle.data;
7712 document.Activate();
7714 //if(activeChild.state == maximized)
7715 // document.SetState(maximized, false, mods);
7716 //else if(document.state == minimized)
7717 // document.SetState(normal, false, mods);
7721 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7723 stayOnTop = !style.stayOnTop;
7727 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7729 Window document = activeChild;
7732 Window firstDocument = null;
7733 OldLink cycle = document.cycle;
7737 Window child = cycle.data;
7738 if(child.style.isActiveClient && !child.style.hidden)
7740 if(!firstDocument) firstDocument = child;
7741 if(child.state == minimized)
7742 child.SetState(minimized, false, mods);
7745 child.positionID = id++;
7746 child.SetState(normal, false, mods);
7747 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7749 child.anchor.left.type = hTiled;
7752 child.normalSizeAnchor = *&child.sizeAnchor;
7753 child.normalAnchor = child.anchor;
7755 // Break the anchors for moveable/resizable windows
7756 if(child.style.fixed)
7758 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7760 (*&child.normalAnchor).left = x;
7761 (*&child.normalAnchor).top = y;
7762 (*&child.normalAnchor).right.type = none;
7763 (*&child.normalAnchor).bottom.type = none;
7764 (*&child.normalSizeAnchor).isClientW = false;
7765 (*&child.normalSizeAnchor).isClientH = false;
7766 (*&child.normalSizeAnchor).size.w = w;
7767 (*&child.normalSizeAnchor).size.h = h;
7768 child.anchored = false;
7771 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7773 child.stateAnchor = child.normalAnchor;
7774 child.stateSizeAnchor = child.normalSizeAnchor;
7776 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7777 child.Position(x,y, w, h, true, true, true, true, false, true);
7782 if((cycle = cycle.next) == document.cycle) break;
7785 firstDocument.Activate();
7790 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7792 Window document = activeChild;
7795 Window firstDocument = null;
7797 OldLink cycle = document.cycle;
7802 //if(child.style.isDocument)
7803 if(child.style.isActiveClient && !child.style.hidden)
7805 if(!firstDocument) firstDocument = child;
7806 if(child.state == minimized)
7807 child.SetState(minimized, false, mods);
7810 child.positionID = id++;
7811 child.SetState(normal, false, mods);
7812 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7814 child.anchor.left.type = vTiled;
7817 child.normalSizeAnchor = *&child.sizeAnchor;
7818 child.normalAnchor = child.anchor;
7820 // Break the anchors for moveable/resizable windows
7821 if(child.style.fixed)
7823 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7825 (*&child.normalAnchor).left = x;
7826 (*&child.normalAnchor).top = y;
7827 (*&child.normalAnchor).right.type = none;
7828 (*&child.normalAnchor).bottom.type = none;
7829 (*&child.normalSizeAnchor).isClientW = false;
7830 (*&child.normalSizeAnchor).isClientH = false;
7831 (*&child.normalSizeAnchor).size.w = w;
7832 (*&child.normalSizeAnchor).size.h = h;
7833 child.anchored = false;
7836 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7838 child.stateAnchor = child.normalAnchor;
7839 child.stateSizeAnchor = child.normalSizeAnchor;
7841 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7842 child.Position(x,y, w, h, true, true, true, true, false, true);
7847 if((cycle = cycle.next) == document.cycle) break;
7850 firstDocument.Activate();
7855 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7857 WindowList dialog { master = this };
7858 Window document = (Window)(intptr)dialog.Modal();
7861 if(activeChild.state == maximized)
7862 document.SetState(maximized, false, mods);
7863 else if(document.state == minimized)
7864 document.SetState(normal, false, mods);
7865 document.Activate();
7871 virtual bool OnCreate(void);
7872 virtual void OnDestroy(void);
7873 virtual void OnDestroyed(void);
7874 virtual bool OnClose(bool parentClosing);
7875 virtual bool OnStateChange(WindowState state, Modifiers mods);
7876 virtual bool OnPostCreate(void);
7877 virtual bool OnMoving(int *x, int *y, int w, int h);
7878 virtual bool OnResizing(int *width, int *height);
7879 virtual void OnResize(int width, int height);
7880 virtual void OnPosition(int x, int y, int width, int height);
7881 virtual bool OnLoadGraphics(void);
7882 virtual void OnApplyGraphics(void);
7883 virtual void OnUnloadGraphics(void);
7884 virtual void OnRedraw(Surface surface);
7885 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7886 virtual void OnActivateClient(Window client, Window previous);
7887 virtual bool OnKeyDown(Key key, unichar ch);
7888 virtual bool OnKeyUp(Key key, unichar ch);
7889 virtual bool OnKeyHit(Key key, unichar ch);
7890 virtual bool OnSysKeyDown(Key key, unichar ch);
7891 virtual bool OnSysKeyUp(Key key, unichar ch);
7892 virtual bool OnSysKeyHit(Key key, unichar ch);
7893 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7894 virtual bool OnMouseLeave(Modifiers mods);
7895 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7896 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7897 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7898 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7899 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7900 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7901 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7902 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7903 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7904 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7905 virtual void OnMouseCaptureLost(void);
7906 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7907 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7908 virtual void OnDrawOverChildren(Surface surface);
7909 virtual bool OnFileModified(FileChange fileChange, const char * param);
7910 virtual bool OnSaveFile(const char * fileName);
7912 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7913 // Note: A 'client' would refer to isActiveClient, rather than
7914 // being confined to the 'client area' (nonClient == false)
7915 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7916 virtual void OnChildVisibilityToggled(Window child, bool visible);
7917 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7919 // Skins Virtual Functions
7920 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7921 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7922 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7927 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7928 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7929 virtual bool IsMouseMoving(int x, int y, int w, int h)
7933 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7937 virtual void UpdateNonClient();
7938 virtual void SetBox(Box box); // This is used in the MySkin skin
7939 virtual bool IsInside(int x, int y)
7941 return box.IsPointInside({x, y});
7943 virtual bool IsOpaque()
7945 return (!style.drawBehind || background.a == 255);
7949 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7950 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7951 virtual void Window::NotifySaved(Window window, const char * filePath);
7956 property Window parent
7958 property_category $"Layout"
7961 if(value || guiApp.desktop)
7964 Window oldParent = parent;
7965 Anchor anchor = this.anchor;
7967 if(value && value.IsDescendantOf(this)) return;
7968 if(value && value == this)
7970 if(!value) value = guiApp.desktop;
7972 if(value == oldParent) return;
7974 if(!master || (master == this.parent && master == guiApp.desktop))
7975 property::master = value;
7979 parent.children.Remove(this);
7983 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7984 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7985 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7986 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7990 last = value.children.last;
7992 if(style.isDocument)
7995 parent.numDocuments--;
7996 documentID = value.GetDocumentID();
7999 if(style.isActiveClient && !style.hidden)
8001 if(parent && parent != guiApp.desktop && !(style.hidden))
8003 if(state == minimized) parent.numIcons--;
8004 parent.numPositions--;
8008 if(!style.stayOnTop)
8009 for(; last && last.style.stayOnTop; last = last.prev);
8011 value.children.Insert(last, this);
8013 // *** NEW HERE: ***
8015 parent.childrenCycle.Delete(cycle);
8017 parent.childrenOrder.Delete(order);
8020 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8021 // Should something else be done?
8022 if(parent && parent.activeChild == this)
8023 parent.activeChild = null;
8024 if(parent && parent.activeClient == this)
8025 parent.activeClient = null;
8031 int x = position.x, y = position.y, w = size.w, h = size.h;
8035 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8036 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8038 vpw = value.clientSize.w;
8039 vph = value.clientSize.h;
8045 else if(style.fixed)
8047 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8048 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8051 anchor = this.anchor;
8053 if(anchor.left.type == offset) anchor.left.distance = x;
8054 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8055 if(anchor.top.type == offset) anchor.top.distance = y;
8056 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8057 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8058 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8059 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8060 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8061 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8062 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8064 if(!anchor.left.type && !anchor.right.type)
8066 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8067 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8069 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8070 if(!anchor.top.type && !anchor.bottom.type)
8072 anchor.vert.distance = (y + h / 2) - (vph / 2);
8073 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8075 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8078 parent.OnChildAddedOrRemoved(this, false);
8084 parent.childrenCycle.Insert(
8085 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8086 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8088 cycle = OldLink { data = this });
8089 parent.childrenOrder.Insert(
8090 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8091 order = OldLink { data = this });
8094 if(!style.hidden && style.isActiveClient)
8096 positionID = parent.GetPositionID(this);
8097 parent.numPositions++;
8098 if(state == minimized) parent.numIcons--;
8101 // *** FONT INHERITANCE ***
8102 if(!setFont && oldParent)
8103 stopwatching(oldParent, font);
8107 RemoveResource(systemFont);
8110 // TESTING WITH WATCHERS:
8111 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8112 // usedFont = setFont ? setFont : (systemFont);
8116 if(guiApp.currentSkin)
8118 systemFont = guiApp.currentSkin.SystemFont();
8121 usedFont = systemFont;
8122 AddResource(systemFont);
8130 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8139 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8141 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8142 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8145 UnloadGraphics(false);
8148 LoadGraphics(false, false);
8151 if(value.rootWindow != rootWindow)
8152 DisplayModeChanged();
8156 scrolledPos.x = MININT; // Prevent parent update
8158 bool anchored = this.anchored;
8159 property::anchor = anchor;
8160 this.anchored = anchored;
8165 if(guiApp.currentSkin)
8166 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8168 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8169 Position(x, y, w, h, true, true, true, true, false, true);
8174 // else parent = value;
8176 oldParent.OnChildAddedOrRemoved(this, true);
8179 get { return parent; }
8182 property Window master
8184 property_category $"Behavior"
8187 //if(this == value) return;
8188 if(value && value.IsSlaveOf(this)) return;
8194 OldLink slaveHolder;
8195 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8196 if(slaveHolder.data == this)
8198 master.slaves.Delete(slaveHolder);
8205 value.slaves.Add(OldLink { data = this });
8210 master.hotKeys.Remove(hotKey);
8211 value.hotKeys.Add(hotKey);
8214 if(master && master.defaultControl == this)
8215 master.defaultControl = null;
8217 if(style.isDefault && !value.defaultControl)
8218 value.defaultControl = this;
8223 get { return master ? master : parent; }
8226 property const char * caption
8228 property_category $"Appearance"
8235 caption = new char[strlen(value)+1];
8237 strcpy(caption, value);
8242 get { return caption; }
8247 property_category $"Behavior"
8256 master.hotKeys.Add(hotKey = HotKeySlot { });
8260 hotKey.window = this;
8265 master.hotKeys.Delete(hotKey);
8270 get { return hotKey ? hotKey.key : 0; }
8273 property Color background
8275 property_category $"Appearance"
8278 background.color = value;
8283 if(this == rootWindow)
8284 guiApp.interfaceDriver.SetRootWindowColor(this);
8287 get { return background.color; }
8290 property Percentage opacity
8292 property_category $"Appearance"
8295 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8296 drawBehind = (background.a == 255) ? false : true;
8298 get { return background.a / 255.0f; }
8301 property Color foreground
8303 property_category $"Appearance"
8311 get { return foreground; }
8314 property BorderStyle borderStyle
8316 property_category $"Appearance"
8319 if(!((BorderBits)value).fixed)
8321 style.hasClose = false;
8322 style.hasMaximize = false;
8323 style.hasMinimize = false;
8324 nativeDecorations = false;
8326 style.borderBits = value;
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);
8334 CreateSystemChildren();
8337 get { return (BorderStyle)style.borderBits; }
8340 property Size minClientSize
8342 property_category $"Layout"
8343 set { minSize = value; }
8344 get { value = minSize; }
8347 property Size maxClientSize
8349 property_category $"Layout"
8350 set { maxSize = value; }
8351 get { value = maxSize; }
8354 property bool hasMaximize
8356 property_category $"Window Style"
8359 style.hasMaximize = value;
8360 if(value) { style.fixed = true; style.contour = true; }
8364 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8366 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8367 Position(x, y, w, h, true, true, true, true, false, true);
8369 CreateSystemChildren();
8372 get { return style.hasMaximize; }
8375 property bool hasMinimize
8377 property_category $"Window Style"
8380 style.hasMinimize = value;
8381 if(value) { style.fixed = true; style.contour = true; }
8385 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8387 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8388 Position(x, y, w, h, true, true, true, true, false, true);
8390 CreateSystemChildren();
8393 get { return style.hasMinimize; }
8396 property bool hasClose
8398 property_category $"Window Style"
8401 style.hasClose = value;
8402 if(value) { style.fixed = true; style.contour = true; }
8406 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8407 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8408 Position(x, y, w, h, true, true, true, true, false, true);
8409 CreateSystemChildren();
8412 get { return style.hasClose; }
8415 property bool nonClient
8417 property_category $"Layout"
8420 style.nonClient = value;
8422 style.stayOnTop = true;
8424 get { return style.nonClient; }
8427 property bool inactive
8429 property_category $"Behavior"
8434 // *** NEW HERE: ***
8438 parent.childrenCycle.Delete(cycle);
8440 parent.childrenOrder.Delete(order);
8447 active = false; // true;
8448 if(parent.activeChild == this)
8449 parent.activeChild = null;
8450 if(parent.activeClient == this)
8451 parent.activeClient = null;
8460 parent.childrenCycle.Insert(
8461 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8462 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8464 cycle = OldLink { data = this });
8466 parent.childrenOrder.Insert(
8467 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8468 order = OldLink { data = this });
8471 style.inactive = value;
8473 get { return style.inactive; }
8476 property bool clickThrough
8478 property_category $"Behavior"
8479 set { style.clickThrough = value; }
8480 get { return style.clickThrough; }
8483 property bool isRemote
8485 property_category $"Behavior"
8486 set { style.isRemote = value; }
8487 get { return style.isRemote; }
8490 property bool noCycle
8492 property_category $"Behavior"
8493 set { style.noCycle = value; }
8494 get { return style.noCycle; }
8497 property bool isModal
8499 property_category $"Behavior"
8500 set { style.modal = value; }
8501 get { return style.modal; }
8504 property bool interim
8506 property_category $"Behavior"
8507 set { style.interim = value; }
8508 get { return style.interim; }
8511 property bool tabCycle
8513 property_category $"Behavior"
8514 set { style.tabCycle = value; }
8515 get { return style.tabCycle; }
8518 property bool isDefault
8520 property_category $"Behavior"
8528 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8529 if(sibling != this && sibling.style.isDefault)
8530 sibling.style.isDefault = false;*/
8531 if(master.defaultControl)
8532 master.defaultControl.style.isDefault = false;
8533 master.defaultControl = this;
8535 else if(master.defaultControl == this)
8536 master.defaultControl = null;
8540 style.isDefault = value;
8542 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8544 get { return style.isDefault; }
8547 property bool drawBehind
8549 property_category $"Window Style"
8550 set { style.drawBehind = value; }
8551 get { return style.drawBehind; }
8554 property bool hasMenuBar
8556 property_category $"Window Style"
8566 if(created && !menuBar)
8573 anchor = Anchor { top = 23, left = 1, right = 1 },
8575 inactive = true, nonClient = true
8580 else if(created && menuBar)
8585 style.hasMenuBar = value;
8587 get { return style.hasMenuBar; }
8590 property bool hasStatusBar
8592 property_category $"Window Style"
8599 statusBar = StatusBar { this };
8607 style.hasStatusBar = value;
8609 get { return style.hasStatusBar; }
8611 property bool stayOnTop
8613 property_category $"Window Style"
8618 if(created && !style.stayOnTop)
8620 if(rootWindow == this)
8621 guiApp.interfaceDriver.OrderRootWindow(this, true);
8622 else if(parent.children.last != this)
8624 parent.children.Move(this, parent.children.last);
8628 style.stayOnTop = true;
8632 if(created && style.stayOnTop)
8634 if(rootWindow == this)
8635 guiApp.interfaceDriver.OrderRootWindow(this, false);
8642 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8643 order && ((Window)order.data).style.stayOnTop;
8644 order = (order == parent.childrenOrder.first) ? null : order.prev);
8645 last = order ? order.data : null;
8649 for(last = parent.children.last;
8650 last && last.style.stayOnTop;
8654 parent.children.Move(this, last);
8658 style.stayOnTop = false;
8661 get { return style.stayOnTop; }
8666 property_category $"Window Style"
8676 if(menuBar && !value)
8683 if(!menuBar && style.hasMenuBar && value)
8687 this, menu = value, isMenuBar = true,
8688 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8689 inactive = true, nonClient = true
8693 UpdateActiveDocument(null);
8696 get { return menu; }
8699 property FontResource font
8701 property_category $"Appearance"
8703 isset { return setFont ? true : false; }
8708 if(value && !setFont) { stopwatching(parent, font); }
8709 else if(!value && setFont)
8715 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8724 RemoveResource(setFont);
8729 RemoveResource(systemFont);
8736 AddResource(setFont);
8739 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8742 systemFont = guiApp.currentSkin.SystemFont();
8744 usedFont = systemFont;
8745 AddResource(systemFont);
8753 get { return usedFont; }
8756 property SizeAnchor sizeAnchor
8758 property_category $"Layout"
8761 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8762 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8763 sizeAnchor.isClientW != sizeAnchor.isClientH;
8770 normalSizeAnchor = sizeAnchor;
8772 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8774 stateAnchor = normalAnchor;
8775 stateSizeAnchor = normalSizeAnchor;
8777 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8778 Position(x,y, w, h, true, true, true, true, false, true);
8785 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8786 sizeAnchor.isClientW,
8787 sizeAnchor.isClientH
8794 property_category $"Layout"
8797 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8798 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8799 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8805 sizeAnchor.isClientW = false;
8806 sizeAnchor.isClientH = false;
8807 sizeAnchor.size = value;
8809 normalSizeAnchor = sizeAnchor;
8811 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8813 stateAnchor = normalAnchor;
8814 stateSizeAnchor = normalSizeAnchor;
8816 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8817 Position(x, y, w, h, true, true, true, true, false, true);
8818 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8821 get { value = size; }
8824 property Size clientSize
8826 property_category $"Layout"
8829 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8830 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8831 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8836 sizeAnchor.isClientW = true;
8837 sizeAnchor.isClientH = true;
8838 sizeAnchor.size = value;
8840 normalSizeAnchor = sizeAnchor;
8842 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8844 stateAnchor = normalAnchor;
8845 stateSizeAnchor = normalSizeAnchor;
8847 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8848 Position(x,y, w, h, true, true, true, true, false, true);
8849 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8852 get { value = this ? clientSize : { 0, 0 }; }
8855 property Size initSize { get { value = sizeAnchor.size; } };
8857 property Anchor anchor
8859 property_category $"Layout"
8860 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8866 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8868 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8869 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8871 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8873 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8874 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8878 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8880 anchor.left.distance = 0;
8881 anchor.horz.type = 0;
8883 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8885 anchor.top.distance = 0;
8886 anchor.vert.type = 0;
8895 normalAnchor = anchor;
8897 // Break the anchors for moveable/resizable windows
8898 /*if(style.fixed ) //&& value.left.type == cascade)
8900 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8902 this.anchor = normalAnchor = Anchor { left = x, top = y };
8903 normalSizeAnchor = SizeAnchor { { w, h } };
8906 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8908 stateAnchor = normalAnchor;
8909 stateSizeAnchor = normalSizeAnchor;
8911 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8912 Position(x, y, w, h, true, true, true, true, false, true);
8921 get { value = this ? anchor : Anchor { }; }
8924 property Point position
8926 property_category $"Layout"
8929 if(value == null) return;
8931 anchor.left = value.x;
8932 anchor.top = value.y;
8933 anchor.right.type = none;
8934 anchor.bottom.type = none;
8939 normalAnchor = anchor;
8941 // Break the anchors for moveable/resizable windows
8945 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8947 normalAnchor.left = x;
8948 normalAnchor.top = y;
8949 normalAnchor.right.type = none;
8950 normalAnchor.bottom.type = none;
8951 normalSizeAnchor.size.width = w;
8952 normalSizeAnchor.size.height = h;
8956 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8958 stateAnchor = normalAnchor;
8959 stateSizeAnchor = normalSizeAnchor;
8961 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8962 Position(x,y, w, h, true, true, true, true, false, true);
8966 get { value = position; }
8969 property bool disabled
8971 property_category $"Behavior"
8974 if(this && disabled != value)
8981 get { return (bool)disabled; }
8984 property bool isEnabled
8989 for(parent = this; parent; parent = parent.parent)
8996 property WindowState state
8998 property_category $"Behavior"
8999 set { SetState(value, false, 0); }
9000 get { return this ? state : 0; }
9003 property bool visible
9005 property_category $"Behavior"
9008 if(this && !value && !style.hidden && parent)
9010 bool wasActiveChild = parent.activeChild == this;
9011 Window client = null;
9013 style.hidden = true;
9014 if(style.isActiveClient)
9016 parent.numPositions--;
9017 if(state == minimized) parent.numIcons--;
9022 OldLink prevOrder = null;
9024 if(rootWindow == this)
9025 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9028 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9031 box.left -= parent.clientStart.x;
9032 box.top -= parent.clientStart.y;
9033 box.right -= parent.clientStart.x;
9034 box.bottom -= parent.clientStart.y;
9038 if(_isModal && master && master.modalSlave == this)
9039 master.modalSlave = null;
9043 OldLink tmpPrev = order.prev;
9044 client = tmpPrev ? tmpPrev.data : null;
9045 if(client && !client.style.hidden && !client.destroyed && client.created)
9046 prevOrder = tmpPrev;
9049 client = tmpPrev ? tmpPrev.data : null;
9050 if(client == this) { client = null; break; }
9051 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9053 tmpPrev = client.order.prev;
9058 prevOrder = tmpPrev;
9063 // If this window can be an active client, make sure the next window we activate can also be one
9064 if(!style.nonClient && style.isActiveClient)
9066 tmpPrev = prevOrder;
9069 client = tmpPrev ? tmpPrev.data : null;
9070 if(client == this) { client = null; break; }
9071 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9073 tmpPrev = client.order.prev;
9078 prevOrder = tmpPrev;
9082 if(client && client.style.hidden) client = null;
9086 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9088 if(order && prevOrder && prevOrder.data != this)
9089 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9091 ActivateEx(false, false, false, true, null, null);
9093 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9094 if(parent.activeClient == this)
9096 parent.activeClient = null;
9097 parent.UpdateActiveDocument(null);
9100 else if(parent.activeClient == this)
9102 parent.activeClient = client;
9103 parent.UpdateActiveDocument(this);
9106 // *** Not doing this anymore ***
9109 parent.childrenCycle.Delete(cycle);
9111 parent.childrenOrder.Delete(order);
9116 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9121 else if(this && value && style.hidden)
9123 style.hidden = false;
9126 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9127 if(rootWindow == this)
9128 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9130 if(_isModal && master)
9131 master.modalSlave = this;
9133 if(style.isActiveClient)
9135 positionID = parent.GetPositionID(this);
9136 parent.numPositions++;
9137 if(state == minimized) parent.numIcons++;
9140 // *** NOT DOING THIS ANYMORE ***
9142 if(!(style.inactive))
9144 if(!(style.noCycle))
9146 cycle = parent.childrenCycle.AddAfter(
9147 (parent.activeChild && parent.activeChild.cycle) ?
9148 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9151 order = parent.childrenOrder.AddAfter(
9152 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9159 if(true || !parent.activeChild)
9160 ActivateEx(true, false, true, true, null, null);
9162 if(creationActivation == activate && guiApp.desktop.active)
9163 ActivateEx(true, false, true, true, null, null);
9164 else if((creationActivation == activate || creationActivation == flash) && !object)
9167 if(this == rootWindow)
9171 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9175 ConsequentialMouseMove(false);
9181 style.hidden = !value;
9184 get { return (style.hidden || !setVisible) ? false : true; }
9187 property bool isDocument
9189 property_category $"Document"
9190 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9191 get { return style.isDocument; }
9194 property bool mergeMenus
9196 property_category $"Window Style"
9197 set { mergeMenus = value; }
9198 get { return (bool)mergeMenus; }
9201 property bool hasHorzScroll
9203 property_category $"Window Style"
9208 if(!style.hasHorzScroll && created)
9210 CreateSystemChildren();
9211 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9214 else if(style.hasHorzScroll)
9218 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9220 style.hasHorzScroll = value;
9223 get { return style.hasHorzScroll; }
9226 property bool hasVertScroll
9228 property_category $"Window Style"
9233 if(!style.hasVertScroll && created)
9235 style.hasVertScroll = true;
9236 CreateSystemChildren();
9237 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9240 else if(style.hasVertScroll)
9244 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9246 style.hasVertScroll = value;
9248 get { return style.hasVertScroll; }
9251 property bool dontHideScroll
9253 property_category $"Behavior"
9256 scrollFlags.dontHide = value;
9259 //UpdateScrollBars(true, true);
9260 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9264 // UpdateScrollBars(true, true);
9265 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9268 get { return scrollFlags.dontHide; }
9271 property bool dontScrollVert
9273 property_category $"Behavior"
9274 set { style.dontScrollVert = value; }
9275 get { return style.dontScrollVert; }
9277 property bool dontScrollHorz
9279 property_category $"Behavior"
9280 set { style.dontScrollHorz = value; }
9281 get { return style.dontScrollHorz; }
9284 property bool snapVertScroll
9286 property_category $"Behavior"
9289 scrollFlags.snapY = value;
9290 if(sbv) sbv.snap = value;
9292 get { return scrollFlags.snapY; }
9294 property bool snapHorzScroll
9296 property_category $"Behavior"
9299 scrollFlags.snapX = value;
9300 if(sbh) sbh.snap = value;
9302 get { return scrollFlags.snapX; }
9305 property Point scroll
9307 property_category $"Behavior"
9308 set { if(this) SetScrollPosition(value.x, value.y); }
9309 get { value = scroll; }
9312 property bool modifyVirtualArea
9314 property_category $"Behavior"
9315 set { modifyVirtArea = value; }
9316 get { return (bool)modifyVirtArea; }
9319 property bool dontAutoScrollArea
9321 property_category $"Behavior"
9322 // Activating a child control out of view will automatically scroll to make it in view
9323 set { noAutoScrollArea = value; }
9324 get { return (bool)noAutoScrollArea; }
9327 property const char * fileName
9329 property_category $"Document"
9334 if(menu && ((!fileName && value) || (fileName && !value)))
9336 MenuItem item = menu.FindItem(MenuFileSave, 0);
9337 if(item) item.disabled = !modifiedDocument && value;
9342 if(value && value[0])
9343 fileName = CopyString(value);
9345 if(parent && this == parent.activeClient)
9346 parent.UpdateActiveDocument(null);
9350 // if(style.isDocument)
9352 fileMonitor.fileName = value;
9354 get { return fileName; }
9359 property_category $"Data"
9364 property bool modifiedDocument
9366 property_category $"Document"
9369 if(style.isDocument || fileName)
9373 MenuItem item = menu.FindItem(MenuFileSave, 0);
9374 if(item) item.disabled = !value && fileName;
9378 if(modifiedDocument != value)
9380 modifiedDocument = value;
9381 if(style.isDocument || fileName)
9385 get { return (bool)modifiedDocument; }
9388 property bool showInTaskBar
9390 property_category $"Window Style"
9391 set { style.showInTaskBar = value; }
9392 get { return style.showInTaskBar; }
9394 property FileDialog saveDialog { set { saveDialog = value; } };
9395 property bool isActiveClient
9397 property_category $"Behavior"
9400 if(parent && style.isActiveClient != value && !style.hidden)
9404 if(state == minimized) parent.numIcons++;
9405 parent.numPositions++;
9409 if(state == minimized) parent.numIcons--;
9410 parent.numPositions--;
9413 style.isActiveClient = value;
9415 get { return style.isActiveClient; }
9418 property Cursor cursor
9420 property_category $"Appearance"
9424 SelectMouseCursor();
9426 get { return cursor; }
9429 //#if !defined(ECERE_VANILLA)
9430 property const char * name
9432 property_category $"Design"
9435 return (this && object) ? object.name : null;
9440 activeDesigner.RenameObject(object, value);
9444 property const char * displayDriver
9446 property_category $"Behavior"
9449 dispDriver = GetDisplayDriver(value);
9450 //DisplayModeChanged();
9454 return dispDriver ? dispDriver.name : null;
9458 // RUNTIME PROPERTIES
9459 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9460 property Size scrollArea
9462 property_category $"Behavior"
9466 SetScrollArea(value.w, value.h, false);
9468 SetScrollArea(0,0, true);
9470 get { value = scrollArea; }
9473 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9478 property_category $"Layout"
9479 set { if(this) is3D = value; }
9480 get { return (bool)is3D; }
9483 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9485 // Will be merged with font later
9486 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9487 property Point clientStart { get { value = clientStart; } };
9488 property Point absPosition { get { value = absPosition; } };
9489 property Anchor normalAnchor { get { value = normalAnchor; } };
9490 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9491 property bool active { get { return (bool)active; } };
9492 property bool created { get { return (bool)created; } };
9493 property bool destroyed { get { return (bool)destroyed; } };
9494 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9495 property Window firstChild { get { return children.first; } };
9496 property Window lastChild { get { return children.last; } };
9497 property Window activeClient { get { return activeClient; } };
9498 property Window activeChild { get { return activeChild; } };
9499 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9500 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9501 property ScrollBar horzScroll { get { return sbh; } };
9502 property ScrollBar vertScroll { get { return sbv; } };
9503 property StatusBar statusBar { get { return statusBar; } };
9504 property Window rootWindow { get { return rootWindow; } };
9505 property bool closing { get { return (bool)closing; } set { closing = value; } };
9506 property int documentID { get { return documentID; } };
9507 property Window previous { get { return prev; } }
9508 property Window next { get { return next; } }
9509 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9510 property PopupMenu menuBar { get { return menuBar; } }
9511 property ScrollBar sbv { get { return sbv; } }
9512 property ScrollBar sbh { get { return sbh; } }
9513 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9514 property void * systemHandle { get { return windowHandle; } }
9515 property Button minimizeButton { get { return sysButtons[0]; } };
9516 property Button maximizeButton { get { return sysButtons[1]; } };
9517 property Button closeButton { get { return sysButtons[2]; } };
9518 property BitmapResource icon
9520 get { return icon; }
9524 if(icon) incref icon;
9526 guiApp.interfaceDriver.SetIcon(this, value);
9529 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9530 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9531 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9532 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9533 property bool nativeDecorations
9535 get { return (bool)nativeDecorations; }
9536 set { nativeDecorations = value; }
9537 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9540 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9541 bool result = false;
9542 if(nativeDecorations)
9544 if(rootWindow == this)
9548 if(formDesigner && activeDesigner)
9550 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9551 Window form = cd ? cd.form : null;
9552 if(form && parent == form.parent)
9557 return result != style.fixed;
9561 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9563 property const char * text
9565 property_category $"Deprecated"
9567 set { property::caption = value; }
9568 get { return property::caption; }
9574 WindowBits style; // Window Style
9575 char * caption; // Name / Caption
9576 Window parent; // Parent window
9577 OldList children; // List of children in Z order
9578 Window activeChild; // Child window having focus
9579 Window activeClient;
9580 Window previousActive; // Child active prior to activating the default child
9581 Window master; // Window owning and receiving notifications concerning this window
9582 OldList slaves; // List of windows belonging to this window
9583 Display display; // Display this window is drawn into
9585 Point position; // Position in parent window client area
9586 Point absPosition; // Absolute position
9587 Point clientStart; // Client area position from (0,0) in this window
9589 Size clientSize; // Client area size
9590 Size scrollArea; // Virtual Scroll area size
9591 Size reqScrollArea; // Requested virtual area size
9592 Point scroll; // Virtual area scrolling position
9593 ScrollBar sbh, sbv; // Scrollbar window handles
9594 Cursor cursor; // Mouse cursor used for this window
9597 StatusBar statusBar;
9598 Button sysButtons[3];
9600 Box clientArea; // Client Area box clipped to parent
9602 HotKeySlot hotKey; // HotKey for this window
9606 ScrollFlags scrollFlags;// Window Scrollbar Flags
9607 int64 id; // Control ID
9609 ColorAlpha background; // Background color used to draw the window area
9611 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9612 OldList childrenCycle; // Cycling order
9613 OldLink cycle; // Element of parent's cycling order
9614 OldList childrenOrder; // Circular Z-Order
9615 OldLink order; // Element of parent's circular Z-Order
9616 Window modalSlave; // Slave window blocking this window's interaction
9618 Window rootWindow; // Topmost system managed window
9619 void * windowHandle; // System window handle
9621 DialogResult returnCode;// Return code for modal windows
9623 Point sbStep; // Scrollbar line scrolling steps
9626 SizeAnchor stateSizeAnchor;
9628 Anchor normalAnchor;
9629 SizeAnchor normalSizeAnchor;
9631 Size skinMinSize; // Minimal window size based on style
9632 Point scrolledPos; // Scrolled position
9633 Box box; // Window box clipped to parent
9634 Box * against; // What to clip the box to
9636 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9637 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9638 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9639 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9640 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9641 Point scrolledArea; // Distance to scroll area by
9642 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9644 OldList hotKeys; // List of the hotkeys of all children
9645 Window defaultControl; // Default child control
9649 ColorAlpha * palette; // Color palette used for this window
9651 int caretSize; // Size of caret, non zero if a caret is present
9652 Point caretPos; // Caret position
9654 void * systemParent; // Parent System Window for embedded windows
9661 WindowState lastState;
9663 FileMonitor fileMonitor;
9665 FontResource setFont, systemFont;
9666 FontResource usedFont;
9667 FontResource captionFont;
9669 FileDialog saveDialog;
9671 SizeAnchor sizeAnchor;
9673 // FormDesigner data
9676 Extent * tempExtents; //[4];
9677 BitmapResource icon;
9679 CreationActivationOption creationActivation;
9682 bool active:1; // true if window and ancestors are active
9683 bool acquiredInput:1; // true if the window is processing state based input
9684 bool modifiedDocument:1;
9685 bool disabled:1; // true if window cannot interact
9686 bool isForegroundWindow:1;// true while a root window is being activated
9687 bool visible:1; // Visibility flag
9688 bool destroyed:1; // true if window is being destroyed
9689 bool anchored:1; // true if this window is repositioned when the parent resizes
9690 bool dirty:1; // Flag set to true if any descendant must be redrawn
9696 bool modifyVirtArea:1;
9697 bool noAutoScrollArea:1;
9700 bool setVisible:1; // FOR FORM DESIGNER
9706 bool useSharedMemory:1;
9709 bool nativeDecorations:1;
9710 bool manageDisplay:1;
9711 bool formDesigner:1; // True if we this is running in the form editor
9712 bool requireRemaximize:1;
9715 // Checks used internally for them not to take effect in FormDesigner
9716 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9717 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9719 WindowController controller;
9720 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9723 public class CommonControl : Window
9725 // creationActivation = doNothing;
9728 public property const String toolTip
9730 property_category $"Appearance"
9733 if(created) CommonControl::OnDestroy();
9735 toolTip = value ? ToolTip { tip = value; } : null;
9737 if(created) CommonControl::OnCreate();
9739 get { return toolTip ? toolTip.tip : null; }
9745 // (Very) Ugly work around for the fact that the parent watcher
9746 // won't fire when it's already been disconnected...
9747 eInstance_FireSelfWatchers(toolTip,
9748 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9754 toolTip.parent = this;
9763 public class Percentage : float
9765 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9769 sprintf(string, "%.2f", this);
9770 c = strlen(string)-1;
9773 if(string[c] != '0')
9774 last = Max(last, c);
9775 if(string[c] == '.')
9788 public void ApplySkin(Class c, const char * name, void ** vTbl)
9790 char className[1024];
9795 subclass(Window) wc = (subclass(Window))c;
9796 subclass(Window) base = (subclass(Window))c.base;
9798 sprintf(className, "%sSkin_%s", name, c.name);
9799 wc.pureVTbl = c._vTbl;
9800 c._vTbl = new void *[c.vTblSize];
9801 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9802 sc = eSystem_FindClass(c.module.application, className);
9806 for(m = 0; m < c.base.vTblSize; m++)
9808 if(c._vTbl[m] == base.pureVTbl[m])
9809 c._vTbl[m] = vTbl[m];
9814 for(m = 0; m < c.vTblSize; m++)
9816 if(sc._vTbl[m] != wc.pureVTbl[m])
9817 c._vTbl[m] = sc._vTbl[m];
9821 for(d = c.derivatives.first; d; d = d.next)
9823 ApplySkin(d.data, name, c._vTbl);
9827 public void UnapplySkin(Class c)
9829 subclass(Window) wc = (subclass(Window))c;
9832 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9835 c._vTbl = wc.pureVTbl;
9839 for(d = c.derivatives.first; d; d = d.next)
9841 UnapplySkin(d.data);
9845 void CheckFontIntegrity(Window window)
9850 if(window.usedFont && window.usedFont.font == 0xecececec)
9852 FontResource uf = window.usedFont;
9853 char * className = window._class.name;
9854 char * text = window.text;
9857 for(c = window.firstChild; c; c = c.next)
9858 CheckFontIntegrity(c);
9862 public class ControllableWindow : Window
9864 /*WindowController controller;
9865 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9866 ~ControllableWindow() { delete controller; }*/
9869 class WindowControllerInterface : ControllableWindow
9871 bool OnKeyDown(Key key, unichar ch)
9873 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9876 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9877 result = onKeyDown ? onKeyDown(controller.window, key, ch) : true;
9882 bool OnKeyUp(Key key, unichar ch)
9884 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9887 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
9888 result = onKeyUp ? onKeyUp(controller.window, key, ch) : true;
9893 bool OnKeyHit(Key key, unichar ch)
9895 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9898 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
9899 result = onKeyHit ? onKeyHit(controller.window, key, ch) : true;
9904 bool OnMouseMove(int x, int y, Modifiers mods)
9906 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9908 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9912 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9914 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9916 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9920 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9922 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9924 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9928 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9930 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9932 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9936 bool OnRightButtonDown(int x, int y, Modifiers mods)
9938 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9940 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9944 bool OnRightButtonUp(int x, int y, Modifiers mods)
9946 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9948 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9952 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9954 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9956 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9960 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9962 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9964 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9968 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9970 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9972 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9976 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9978 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9980 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9984 void OnResize(int width, int height)
9986 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9987 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9990 void OnRedraw(Surface surface)
9992 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9993 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9998 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
10000 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
10004 bool OnLoadGraphics()
10006 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
10008 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
10012 void OnUnloadGraphics()
10014 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10015 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
10019 public class WindowController<class V>
10022 property Window window
10026 uint size = class(Window).vTblSize;
10029 windowVTbl = new void *[size];
10030 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10031 if(value._vTbl == value._class._vTbl)
10033 value._vTbl = new void *[value._class.vTblSize];
10034 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10038 for(c = 0; c < size; c++)
10040 void * function = class(WindowControllerInterface)._vTbl[c];
10041 if(function && function != DefaultFunction)
10042 value._vTbl[c] = function;
10044 value._vTbl[c] = windowVTbl[c];
10049 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10052 get { return window; }
10054 property V controlled
10056 set { controlled = value; }
10057 get { return controlled; }
10059 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10060 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10061 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10062 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10063 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10064 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10065 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10066 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10067 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10068 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10069 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10070 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10071 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10072 virtual void V::OnResize(WindowController controller, int width, int height);
10073 virtual void V::OnRedraw(WindowController controller, Surface surface);
10074 virtual bool V::OnCreate(WindowController controller);
10075 virtual bool V::OnLoadGraphics(WindowController controller);
10076 virtual void V::OnUnloadGraphics(WindowController controller);
10079 int (** windowVTbl)();
10083 ~WindowController()