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);
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))
4381 if(result && w && w.clickThrough && w.parent)
4386 if(!result || !w || !w.clickThrough)
4393 // --- Mouse cursor management ---
4395 bool KeyMessage(uint method, Key key, unichar character)
4400 if(guiApp.interimWindow)
4401 this = guiApp.interimWindow;
4404 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4408 if(!style.inactive || rootWindow != this)
4410 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4411 Window modalWindow = FindModal();
4412 Window interimMaster = master ? master.rootWindow : null;
4416 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4417 status = OnSysKeyDown(key, character);
4418 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4419 status = OnSysKeyHit(key, character);
4420 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4421 status = OnSysKeyUp(key, character);
4428 // Process Key Message for Internal UI Keyboard actions
4429 if(status && !destroyed && menuBar && state != minimized)
4432 if((SmartKey)key != alt)
4433 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4436 SmartKey sk = (SmartKey) key;
4437 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4439 status = menuBar.KeyMessage(method, key, character);
4444 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4445 menuBar.OnKeyHit(escape, 0);
4447 if(!menuBar.focus && guiApp.caretOwner)
4448 guiApp.caretOwner.UpdateCaret(true, false);
4451 if(!destroyed && status)
4453 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4457 case left: case up: case right: case down:
4458 if(guiApp.windowMoving == this)
4461 int w = guiApp.windowMoving.size.w;
4462 int h = guiApp.windowMoving.size.h;
4463 int x = guiApp.windowMoving.scrolledPos.x;
4464 int y = guiApp.windowMoving.scrolledPos.y;
4468 if(key == down || key == up)
4469 step = Max(step, textCellH);
4471 step = Max(step, textCellW);
4474 if(guiApp.windowIsResizing)
4478 case left: w-=step; break;
4479 case right: w+=step; break;
4480 case up: h-=step; break;
4481 case down: h+=step; break;
4488 case left: x-=step; break;
4489 case right: x+=step; break;
4490 case up: y-=step; break;
4491 case down: y+=step; break;
4495 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4496 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4498 if(!guiApp.windowIsResizing || guiApp.resizeX)
4499 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4501 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4503 if(!guiApp.windowIsResizing || guiApp.resizeY)
4504 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4506 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4508 guiApp.interfaceDriver.SetMousePosition(x, y);
4509 ConsequentialMouseMove(true);
4517 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4519 guiApp.windowMoving.StopMoving();
4520 ConsequentialMouseMove(false);
4528 ShowSysMenu(absPosition.x, absPosition.y);
4536 if(!destroyed && status && state != minimized)
4538 // Process all the way down the children
4539 if(activeChild && !activeChild.disabled)
4541 status = activeChild.KeyMessage(method, key, character);
4543 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4544 key.code != left && key.code != right && key.code != up && key.code != down)
4546 status = activeClient.KeyMessage(method, key, character);
4550 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4552 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4553 // && defaultControl != activeChild)
4555 delete previousActive;
4556 previousActive = activeChild;
4557 if(previousActive) incref previousActive;
4559 ConsequentialMouseMove(false);
4560 if((defaultControl.active ||
4561 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4562 defaultControl.KeyMessage(method, defaultKey, character);
4568 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4570 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4577 ShowSysMenu(absPosition.x, absPosition.y);
4584 if(this != guiApp.desktop)
4586 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4588 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4590 MenuMoveOrSize(key.shift, true);
4594 else if(guiApp.windowMoving)
4596 guiApp.windowMoving.StopMoving();
4597 ConsequentialMouseMove(false);
4605 if(!destroyed && status && state != minimized)
4607 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4611 case tab: case shiftTab:
4613 Window cycleParent = this;
4614 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4615 cycleParent = master.parent;
4617 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4619 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4622 Window child = cycleParent.activeChild;
4624 // Scroll the window to include the active control
4625 if(cycleParent.sbh && !child.style.dontScrollHorz)
4627 if(child.scrolledPos.x < 0)
4628 cycleParent.sbh.Action(Position,
4629 cycleParent.scroll.x + child.scrolledPos.x, 0);
4630 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4631 cycleParent.sbh.Action(Position,
4632 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4634 if(cycleParent.sbv && !child.style.dontScrollVert)
4636 if(child.scrolledPos.y < 0)
4637 cycleParent.sbv.Action(Position,
4638 cycleParent.scroll.y + child.scrolledPos.y, 0);
4639 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4640 cycleParent.sbv.Action(Position,
4641 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4644 cycleParent.ConsequentialMouseMove(false);
4650 case f6: case shiftF6:
4651 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4653 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4654 if(parent == guiApp.desktop)
4655 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4665 if(CycleChildren(key.shift, true, false, true))
4673 // mIRC Style Window Shortcuts
4674 case alt1: case alt2: case alt3: case alt4: case alt5:
4675 case alt6: case alt7: case alt8: case alt9: case alt0:
4680 for(document = children.first; document; document = document.next)
4682 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4684 if(document == activeChild)
4686 if(document.state == minimized)
4687 document.SetState(normal, false, key);
4690 document.SetState(minimized, false, key);
4691 CycleChildren(false, true, false);
4696 if(activeChild.state == maximized && document.style.hasMaximize)
4697 document.SetState(maximized, false, key);
4698 else if(document.state == minimized)
4699 document.SetState(normal, false, key);
4700 document.Activate();
4715 if(!destroyed && status)
4717 if(state == minimized)
4722 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4724 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4726 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4727 previousActive.ActivateEx(true, false, false, true, null, null);
4728 delete previousActive;
4734 if(!destroyed && status)
4736 status = ProcessHotKeys(method, key, character);
4738 if(!destroyed && status && !modalWindow && state != minimized)
4741 status = KeyMethod(this, key, character);
4742 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4743 status = OnKeyHit(key, character);
4744 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4746 bool result = false;
4749 case ctrlUp: case ctrlDown:
4750 if(sbv && !guiApp.windowScrolling)
4751 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4753 case wheelUp: case wheelDown:
4754 if(sbv && !guiApp.windowScrolling)
4756 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4757 // Do we want to do a consequential move regardless of result in this case?
4758 ConsequentialMouseMove(false);
4761 case ctrlPageUp: case ctrlPageDown:
4762 if(sbh && !guiApp.windowScrolling)
4763 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4768 ConsequentialMouseMove(false);
4773 if(status && !destroyed && menuBar && state != minimized)
4774 status = menuBar.KeyMessage(method, key, character);
4776 if(style.interim && /*destroyed && */status && interimMaster)
4778 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4779 status = interimMaster.KeyMessage(method, key, character);
4786 bool ProcessHotKeys(uint method, Key key, unichar character)
4791 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4792 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4793 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4795 Window hotKeyWindow = hotKey.window;
4796 Window parent = hotKeyWindow.parent;
4797 Window prevActiveWindow = activeChild;
4798 // For when sys buttons are placed inside the menu bar
4799 if(parent && parent._class == class(PopupMenu))
4800 parent = parent.parent;
4802 // 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
4803 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4806 if(prevActiveWindow) incref prevActiveWindow;
4807 incref hotKeyWindow;
4808 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4809 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4812 delete hotKeyWindow;
4813 delete prevActiveWindow;
4817 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4818 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4819 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4821 // ********* WORKING ON THIS ***********
4822 if(prevActiveWindow && !guiApp.interimWindow)
4823 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4826 else if(hotKeyWindow.style.inactive)
4827 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4829 delete prevActiveWindow;
4830 delete hotKeyWindow;
4831 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4832 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4836 if(status && tabCycle)
4839 for(child = children.first; child; child = child.next)
4841 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4852 // --- Windows and graphics initialization / termination ---
4853 bool SetupRoot(void)
4857 // Setup relationship with outside world (bb root || !bb)
4858 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4859 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4863 tempExtents = new0 Extent[4];
4868 /*if(guiApp.fullScreenMode)
4869 rootWindow = guiApp.desktop;
4871 //rootWindow = parent.created ? parent.rootWindow : null;
4872 rootWindow = parent.rootWindow;
4875 against = &parent.box;
4877 against = &parent.clientArea;
4880 for(child = children.first; child; child = child.next)
4883 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4886 bool Setup(bool positionChildren)
4888 bool result = false;
4891 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4893 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4894 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4897 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4899 // This was here, is it really needed?
4900 //guiApp.interfaceDriver.ActivateRootWindow(this);
4904 displaySystem = DisplaySystem {};
4905 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4907 delete displaySystem;
4912 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4913 if(display.Create(displaySystem, windowHandle))
4920 // Sometimes icon does not show up on Windows XP if we set here...
4921 // guiApp.interfaceDriver.SetIcon(this, icon);
4923 else if(this != guiApp.desktop)
4925 display = rootWindow ? rootWindow.display : null;
4931 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4932 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4934 for(child = children.first; child; child = child.next)
4936 if(child.created && !child.Setup(false))
4939 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4940 child.UpdateCaption();
4945 bool SetupDisplay(void)
4947 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4948 if(is3D) return Window3D_SetupDisplay(this); else
4955 class_data void ** pureVTbl;
4957 bool LoadGraphics(bool creation, bool resetAnchors)
4959 bool result = false;
4960 bool success = false;
4962 WindowState stateBackup = state;
4964 if(((subclass(Window))_class).pureVTbl)
4966 if(_vTbl == _class._vTbl)
4968 _vTbl = ((subclass(Window))_class).pureVTbl;
4973 for(m = 0; m < _class.vTblSize; m++)
4975 if(_vTbl[m] == _class._vTbl[m])
4976 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4980 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4982 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4984 _vTbl = _class._vTbl;
4989 for(m = 0; m < _class.vTblSize; m++)
4991 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4992 _vTbl[m] = _class._vTbl[m];
4997 if(guiApp.fullScreenMode || this != guiApp.desktop)
4999 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5005 display.Lock(false);
5006 if(rootWindow == this)
5008 // Set Color Palette
5009 display.SetPalette(palette, true);
5013 if(guiApp.fullScreenMode && this == guiApp.desktop)
5018 for(c=0; c<SystemCursor::enumSize; c++)
5019 if(!guiApp.systemCursors[c].bitmap)
5021 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5022 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5023 if(guiApp.systemCursors[c].bitmapName)
5025 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5026 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5027 if(guiApp.systemCursors[c].bitmap)
5028 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5033 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5035 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5036 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5038 cursor.bitmap.paletteShades = cursor.paletteShades;
5042 guiApp.cursorUpdate = true;
5045 ConsequentialMouseMove(false);
5051 // Load Window Graphic Resources
5054 if(usedFont == setFont || usedFont == window.systemFont)
5055 RemoveResource(usedFont);
5058 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5061 RemoveResource(systemFont);
5064 RemoveResource(captionFont);
5066 for(ptr = resources.first; ptr; ptr = ptr.next)
5068 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5069 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5072 AddResource(setFont);
5074 AddResource(systemFont);
5076 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5083 //if(master && master.font)
5084 if(parent && parent.font)
5088 faceName = parent.font.faceName,
5089 size = parent.font.size,
5090 bold = parent.font.bold,
5091 italic = parent.font.italic,
5092 underline = parent.font.underline
5094 //font = parent.font;
5095 watch(parent) { font { } };
5098 font = guiApp.currentSkin.SystemFont();
5105 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5106 AddResource(captionFont);
5108 if(OnLoadGraphics())
5114 //SetScrollLineStep(sbStep.x, sbStep.y);
5116 if(this != guiApp.desktop)
5120 normalAnchor = anchor;
5121 normalSizeAnchor = sizeAnchor;
5124 // Break the anchors for moveable/resizable windows
5126 if(style.fixed && style.isDocument)
5128 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5140 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5141 stateSizeAnchor = SizeAnchor {};
5146 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5151 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5152 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5155 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5159 stateAnchor = normalAnchor;
5160 stateSizeAnchor = normalSizeAnchor;
5163 position = Point { };
5164 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5175 if(Position(x, y, w, h, true, false, true, true, true, true))
5177 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5180 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5197 success = result = true;
5200 if(!creation && result)
5202 // Load menu bar first because sys buttons are on it...
5205 if(!menuBar.LoadGraphics(false, resetAnchors))
5211 for(child = children.first; child; child = child.next)
5213 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5220 CreateSystemChildren();
5224 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5227 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5230 LogErrorCode(graphicsLoadingFailed, _class.name);
5232 // Do this here to avoid problems on Windows
5233 if(rootWindow == this && parent && stateBackup == maximized)
5234 property::state = maximized;
5238 void UnloadGraphics(bool destroyWindows)
5242 // Free children's graphics
5243 for(child = children.first; child; child = child.next)
5244 child.UnloadGraphics(destroyWindows);
5247 display.Lock(false);
5250 if(guiApp.fullScreenMode && this == guiApp.desktop)
5255 for(c=0; c<SystemCursor::enumSize; c++)
5256 if(guiApp.systemCursors[c].bitmap)
5257 delete guiApp.systemCursors[c].bitmap;
5259 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5260 delete cursor.bitmap;
5262 guiApp.cursorBackground.Free();
5265 if(display && display.displaySystem)
5269 for(ptr = resources.first; ptr; ptr = ptr.next)
5273 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5278 // Free window graphics
5281 // Free skin graphics
5282 if(rootWindow == this)
5284 DisplaySystem displaySystem = display.displaySystem;
5287 display.driverData = null;
5288 display.displaySystem = null;
5292 if(displaySystem && !displaySystem.numDisplays && !is3D)
5293 delete displaySystem;
5302 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5303 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5305 if(this == guiApp.desktop || parent == guiApp.desktop)
5307 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5308 guiApp.interfaceDriver.DestroyRootWindow(this);
5312 // --- Window Hiding ---
5314 void SetVisibility(bool state)
5316 bool visible = (style.hidden || !created) ? false : state;
5317 if(visible != this.visible)
5321 this.visible = visible;
5322 for(child = children.first; child; child = child.next)
5323 child.SetVisibility(visible);
5325 ConsequentialMouseMove(false);
5326 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5330 // --- Windows and graphics initialization / termination ---
5332 bool DisplayModeChanged(void)
5334 bool result = false;
5335 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5337 guiApp.modeSwitching = true;
5338 UnloadGraphics(false);
5340 if(LoadGraphics(false, false))
5342 guiApp.modeSwitching = false;
5347 // --- Window updates system ---
5349 void UpdateDirty(Box updateBox)
5351 if(!manageDisplay) { OnRedraw(null);return; }
5354 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5357 if(display.flags.flipping)
5360 rootWindow.UpdateDisplay();
5363 UpdateBackDisplay(updateBox);
5365 if(guiApp.fullScreenMode)
5367 guiApp.cursorUpdate = true;
5368 guiApp.PreserveAndDrawCursor();
5370 if(guiApp.fullScreenMode)
5371 guiApp.RestoreCursorBackground();
5377 // This function is strictly called as a result of system window activation
5378 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5381 Window interimMaster = null;
5382 Window interimWindow = guiApp.interimWindow;
5383 if(interimWindow && interimWindow.master)
5384 interimMaster = interimWindow.master.rootWindow;
5386 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5387 // SetState(normal, false, 0);
5388 SetState(lastState, false, 0);
5390 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5394 /* WTH is this doing here?
5395 while(swap && swap.activeChild)
5397 swap = swap.activeChild;
5400 // TESTING THIS BEFORE...
5401 if(interimWindow && this == interimMaster)
5405 // Window interimSwap = this;
5406 Window menuBar = this.menuBar;
5407 if(menuBar && interimWindow.master == menuBar)
5410 while(interimSwap && interimSwap.activeChild)
5411 interimSwap = interimSwap.activeChild;
5413 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5414 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5416 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5417 //result = ActivateEx(true, true, false, activateRoot, window, null);
5422 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5423 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5425 if(interimWindow == this && interimMaster && !active)
5427 while(interimMaster && interimMaster.interim && interimMaster.master)
5429 // printf("Going up one master %s\n", interimMaster._class.name);
5430 interimMaster = interimMaster.master.rootWindow;
5432 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5433 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5439 bool DestroyEx(int64 returnCode)
5442 Timer timer, nextTimer;
5444 OldLink prevOrder = null;
5445 Window client = null;
5447 if(parent) stopwatching(parent, font);
5449 // if(window.modalSlave) return false;
5450 if(destroyed || !created)
5457 OldLink slave = master.slaves.FindLink(this);
5458 master.slaves.Delete(slave);
5461 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5467 this.returnCode = (DialogResult)returnCode;
5469 AcquireInput(false);
5474 master.hotKeys.Delete(hotKey);
5478 if(guiApp.prevWindow == this)
5480 guiApp.prevWindow = null;
5485 for(w : guiApp.overWindows; w == this)
5488 guiApp.overWindows.TakeOut(w);
5492 if(guiApp.caretOwner == this)
5494 guiApp.interfaceDriver.SetCaret(0,0,0);
5495 UpdateCaret(false, true);
5496 guiApp.caretEnabled = false;
5501 parent.childrenCycle.Remove(cycle);
5505 OldLink tmpPrev = order.prev;
5506 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5507 prevOrder = tmpPrev;
5510 client = tmpPrev ? tmpPrev.data : null;
5511 if(client == this) { client = null; break; }
5512 if(client && (client.style.hidden || client.destroyed || !client.created))
5513 tmpPrev = client.order.prev;
5517 prevOrder = tmpPrev;
5522 // If this window can be an active client, make sure the next window we activate can also be one
5523 if(!style.nonClient && style.isActiveClient)
5525 tmpPrev = prevOrder;
5528 client = tmpPrev ? tmpPrev.data : null;
5529 if(client == this) { client = null; break; }
5530 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5531 tmpPrev = client.order.prev;
5535 prevOrder = tmpPrev;
5539 if(client && client.style.hidden) client = null;
5541 // parent.childrenOrder.Remove(order);
5544 if(parent && style.isActiveClient && visible)
5546 if(state == minimized) parent.numIcons--;
5547 parent.numPositions--;
5550 // TESTING THIS HERE!
5554 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5555 // to create a window inside a rootwindow that's being destroyed)
5556 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5558 if(master && !master.destroyed /*&&
5559 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5561 if(master.defaultControl == this)
5562 master.defaultControl = null;
5565 parent.OnChildAddedOrRemoved(this, true);
5566 if(parent && !parent.destroyed /*&&
5567 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5569 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5571 if(order && prevOrder && prevOrder.data != this && active)
5573 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5575 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5576 if(parent.activeClient == this)
5578 parent.activeClient = null;
5579 parent.UpdateActiveDocument(null);
5584 if(guiApp.interimWindow == this)
5587 PropagateActive(false, null, &goOn, true);
5591 //if(window.parent.activeChild == window)
5592 parent.activeChild = null;
5593 if(!style.nonClient /*&& style.isActiveClient*/)
5595 Window previous = parent.activeClient;
5596 if(style.isActiveClient)
5597 parent.activeClient = null;
5598 parent.UpdateActiveDocument(previous);
5603 else if(parent.activeClient == this)
5605 parent.activeClient = client;
5606 parent.UpdateActiveDocument(this);
5610 if(guiApp.interimWindow == this)
5612 guiApp.interimWindow = null;
5613 if(guiApp.caretOwner)
5615 Window desktop = guiApp.desktop;
5616 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5617 guiApp.caretOwner.UpdateCaret(false, false);
5622 if(_isModal && master && master.modalSlave == this)
5623 master.modalSlave = null;
5627 if(!guiApp.caretOwner && parent.caretSize)
5629 guiApp.caretOwner = parent;
5630 parent.UpdateCaret(false, false);
5631 parent.Update(null);
5634 // Why was this commented out?
5635 GetRidOfVirtualArea();
5641 dirtyArea.Free(null);
5642 dirtyBack.Free(null);
5643 scrollExtent.Free(null);
5645 /* ATTEMPTING TO MOVE THAT ABOVE
5654 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5655 for(;(child = window.children.first);)
5657 for(; child && (child.destroyed || !child.created); child = child.next);
5666 UnloadGraphics(true);
5669 delete previousActive;
5672 // statusBar = null;
5675 if(master && !master.destroyed)
5677 //master.NotifyDestroyed(this, this.returnCode);
5678 NotifyDestroyed(master, this, this.returnCode);
5681 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5683 nextTimer = timer.next;
5684 if(timer.window == this)
5686 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5687 // timer.window = null;
5693 if(this == guiApp.windowMoving)
5696 if(guiApp.windowCaptured == this)
5698 //guiApp.windowCaptured = null;
5700 if(rootWindow != this && rootWindow)
5701 rootWindow.ConsequentialMouseMove(false);
5709 //for(child = children.first; next = child ? child.next : null, child; child = next)
5710 for(;(child = children.first); )
5712 for(; child && (child.destroyed || !child.created); child = child.next);
5722 /* // MOVED THIS UP...
5725 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5726 for(;(child = window.children.first); )
5728 for(; child && (child.destroyed || !child.created); child = child.next);
5737 while((slave = slaves.first))
5739 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5741 ((Window)slave.data).DestroyEx(0);
5746 if(guiApp.caretOwner == this)
5747 guiApp.caretOwner = null;
5749 sysButtons[0] = null;
5750 sysButtons[1] = null;
5751 sysButtons[2] = null;
5754 if(rootWindow != this)
5756 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5759 box.left -= parent.clientStart.x;
5760 box.top -= parent.clientStart.y;
5761 box.right -= parent.clientStart.x;
5762 box.bottom -= parent.clientStart.y;
5764 if(parent) parent.Update(box);
5769 OldLink slave = master.slaves.FindVoid(this);
5770 master.slaves.Delete(slave);
5776 parent.children.Remove(this);
5781 //autoCreate = false;
5784 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5785 if(((subclass(Window))_class).pureVTbl)
5787 if(_vTbl == _class._vTbl)
5789 _vTbl = ((subclass(Window))_class).pureVTbl;
5794 for(m = 0; m < _class.vTblSize; m++)
5796 if(_vTbl[m] == _class._vTbl[m])
5797 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5806 void SetStateEx(WindowState newState, bool activate)
5809 WindowState prevState = state;
5813 if(prevState != newState)
5814 lastState = prevState;
5816 if(rootWindow != this || !nativeDecorations || !windowHandle)
5818 if(style.isActiveClient && !style.hidden && prevState == minimized)
5821 // This block used to be at the end of the function... moved it for flicker problem in X
5822 // ------------------------------------------------------
5826 stateAnchor = normalAnchor;
5827 stateSizeAnchor = normalSizeAnchor;
5830 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5831 stateSizeAnchor = SizeAnchor {};
5835 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5838 byte * idBuffer = new0 byte[size];
5840 for(child = parent.children.first; child; child = child.next)
5842 if(child != this && child.state == minimized)
5844 if(child.iconID > size - 2)
5846 idBuffer = renew0 idBuffer byte[size*2];
5847 memset(idBuffer + size, 0, size);
5850 idBuffer[child.iconID] = (byte)bool::true;
5853 for(c = 0; c<size; c++)
5858 if(style.isActiveClient && !style.hidden)
5861 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5862 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5866 // TOCHECK: Why was this here?
5867 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5868 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5869 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5871 Position(x, y, w, h, true, true, true, true, false, true);
5873 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5874 parent.UpdateActiveDocument(null);
5877 CreateSystemChildren();
5878 // ------------------------------------------------------
5881 int GetPositionID(Window forChild)
5885 byte * idBuffer = new0 byte[size];
5888 for(child = children.first; child; child = child.next)
5890 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5892 if(child.positionID > size - 2)
5894 idBuffer = renew0 idBuffer byte[size*2];
5895 memset(idBuffer + size, 0, size);
5898 idBuffer[child.positionID] = (byte)bool::true;
5901 for(c = 0; c<size; c++)
5908 // --- Window related graphics ---
5910 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5912 palette = newPalette;
5913 if(rootWindow.display)
5914 rootWindow.display.SetPalette(palette, colorMatch);
5917 public bool AcquireInput(bool acquired)
5920 if(acquiredInput != acquired)
5922 if(active || (!visible && creationActivation == activate))
5923 result = AcquireInputEx(acquired);
5928 acquiredInput = acquired ? result : !result;
5933 void ListChildren(ListBox listBox)
5937 for(child = children.first; child; child = child.next)
5939 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5941 DataRow row = listBox.AddRow();
5942 row.tag = (int64)(intptr)child;
5943 child.FigureCaption(caption);
5944 row.SetData(null, caption);
5949 void UpdateVisual(Box extent)
5951 if(guiApp.driver != null)
5953 if(guiApp.fullScreenMode && guiApp.desktop.display)
5955 guiApp.desktop.mutex.Wait();
5956 guiApp.desktop.display.Lock(true);
5959 if(guiApp.desktop.active)
5961 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5963 if(guiApp.desktop.display.flags.flipping)
5964 guiApp.desktop.Update(null);
5965 guiApp.desktop.UpdateDisplay();
5966 guiApp.cursorUpdate = true;
5968 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5970 guiApp.PreserveAndDrawCursor();
5971 // guiApp.desktop.display.ShowScreen();
5972 guiApp.cursorUpdate = false;
5973 guiApp.desktop.dirty = false;
5974 guiApp.RestoreCursorBackground();
5978 guiApp.desktop.display.Unlock();
5979 guiApp.desktop.mutex.Release();
5983 Window rootWindow = this.rootWindow;
5984 rootWindow.mutex.Wait();
5989 guiApp.SignalEvent();
5992 guiApp.waitMutex.Wait();
5993 guiApp.interfaceDriver.Lock(rootWindow);
5994 if(!rootWindow.style.hidden && rootWindow.dirty)
5996 if(rootWindow.display)
5998 rootWindow.UpdateDisplay();
5999 //rootWindow.display.ShowScreen(null);
6001 rootWindow.dirty = false;
6003 guiApp.interfaceDriver.Unlock(rootWindow);
6004 guiApp.waitMutex.Release();
6007 rootWindow.mutex.Release();
6012 void UnlockDisplay(void)
6014 guiApp.interfaceDriver.Unlock(rootWindow);
6017 void LockDisplay(void)
6019 guiApp.interfaceDriver.Lock(rootWindow);
6022 Surface GetSurface(Box box)
6024 return Redraw((box == null) ? this.box : box);
6027 void SetMousePosition(int x, int y)
6029 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6033 void IntegrationActivate(bool active)
6035 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6037 isForegroundWindow = true;
6038 ActivateEx(active, active, false, false, null, null);
6039 isForegroundWindow = false;
6044 Window QueryCapture(void)
6046 return guiApp.windowCaptured;
6049 int GetDocumentID(void)
6053 byte * idBuffer = new0 byte[size];
6056 for(child = children.first; child; child = child.next)
6058 // TO CHECK: Do we want a documentID when we already have a file name?
6059 if(child.style.isDocument && !child.fileName)
6061 if(child.documentID-1 > size - 2)
6063 idBuffer = renew0 idBuffer byte[size*2];
6064 memset(idBuffer + size, 0, size);
6067 idBuffer[child.documentID-1] = 1;
6070 for(c = 0; c<size; c++)
6078 void SetInitSize(Size size)
6081 sizeAnchor.size = size;
6082 normalSizeAnchor = sizeAnchor;
6084 // Break the anchors for moveable/resizable windows
6085 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6087 stateAnchor = normalAnchor;
6088 stateSizeAnchor = normalSizeAnchor;
6090 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6091 Position(x,y, w, h, true, true, true, true, false, true);
6095 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6097 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6099 guiApp.windowIsResizing = resize;
6100 guiApp.windowMoving = this;
6101 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6102 if(guiApp.windowIsResizing)
6104 guiApp.windowMovingStart.x += size.w - 1;
6105 guiApp.windowMovingStart.y += size.h - 1;
6107 guiApp.windowMovingBefore = scrolledPos;
6108 guiApp.windowResizingBefore = size;
6109 guiApp.windowMoving.UpdateDecorations();
6110 if(guiApp.windowIsResizing)
6111 guiApp.resizeEndX = guiApp.resizeEndY = true;
6113 if(setCursorPosition)
6114 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6118 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6119 guiApp.windowMovingStart.x += x - absPosition.x;
6120 guiApp.windowMovingStart.y += y - absPosition.y;
6123 if(guiApp.windowMoving)
6125 if(guiApp.windowMoving.style.nonClient)
6126 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6128 guiApp.windowMoving.parent.SetMouseRangeToClient();
6133 if(this == rootWindow)
6134 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6138 void SetupFileMonitor()
6142 fileMonitor = FileMonitor
6144 this, FileChange { modified = true };
6146 bool OnFileNotify(FileChange action, const char * param)
6149 fileMonitor.StopMonitoring();
6150 if(OnFileModified(action, param))
6151 fileMonitor.StartMonitoring();
6164 bool result = false;
6168 else if(guiApp && guiApp.driver != null)
6170 OldLink slaveHolder;
6172 bool visible = !style.hidden;
6176 systemParent = parent;
6177 parent = guiApp.desktop;
6179 last = parent ? parent.children.last : null;
6181 if((parent && parent != guiApp.desktop && !parent.created) ||
6182 (master && master != guiApp.desktop && !master.created))
6186 stopwatching(parent, font);
6189 property::parent = guiApp.desktop;
6190 if(!master) master = parent;
6192 if(_isModal && master.modalSlave)
6193 property::master = master.modalSlave;
6197 parent.children.Remove(this);
6200 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6201 if(slaveHolder.data == this)
6203 master.slaves.Delete(slaveHolder);
6208 if(parent == guiApp.desktop && !mutex)
6211 if(style.isDocument)
6214 parent.numDocuments--;
6215 documentID = parent.GetDocumentID();
6218 if(!style.stayOnTop)
6219 for(; last && last.style.stayOnTop; last = last.prev);
6221 parent.children.Insert((last == this) ? null : last, this);
6222 //parent.children.Add(this);
6225 dispDriver = parent.dispDriver;
6228 master.modalSlave = this;
6230 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6235 master.slaves.Add(slaveHolder = OldLink { data = this });
6240 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6242 if(style.isDefault && !master.defaultControl)
6243 master.defaultControl = this;
6245 stateAnchor = normalAnchor = anchor;
6246 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6248 // TOCHECK: Why is this here?
6249 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6250 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6252 this.visible = false;
6253 style.hidden = true;
6256 // autoCreate = true;
6264 if(parent == guiApp.desktop)
6265 Log("LoadGraphics %s\n", caption);
6267 if(LoadGraphics(true, false))
6275 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6282 if(style.hasMenuBar /*&& menu*/)
6288 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6289 interim = false, inactive = true, nonClient = true, size.h = 24
6297 // Create the system buttons
6298 CreateSystemChildren();
6300 UpdateActiveDocument(null);
6302 if(style.isDocument)
6306 MenuItem item = menu.FindItem(MenuFileSave, 0);
6307 if(item) item.disabled = !modifiedDocument && fileName;
6312 if(parent == guiApp.desktop)
6313 Log("Preemptive SetState %s\n", caption);
6316 // Preemptive Set State to ensure proper anchoring
6317 SetStateEx(state, false);
6319 style.hidden = true;
6325 for(child = children.first; child; child = next)
6328 if(!child.created && (child.autoCreate || child.wasCreated))
6335 for(link = slaves.first; link; link = next)
6337 Window slave = link.data;
6339 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6342 // Things might have happened that invalidated 'next'...
6343 // Start over the search for slaves to create.
6344 // (Added this to fix crash with Stacker & Toolbar)
6345 next = slaves.first;
6354 if(parent == guiApp.desktop)
6355 Log("Real SetState %s\n", caption);
6358 if(isActiveClient && visible)
6360 parent.numPositions--;
6361 if(state == minimized) parent.numIcons--;
6364 parent.OnChildAddedOrRemoved(this, false);
6366 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6368 // Real set state & activate for proper display & activation
6369 property::visible = visible;
6370 // SetState(state & 0x00000003, true, 0);
6371 guiApp.interfaceDriver.SetIcon(this, icon);
6376 /*if(rootWindow == this)
6377 guiApp.interfaceDriver.ActivateRootWindow(this);
6379 if(creationActivation == activate && guiApp.desktop.active)
6380 ActivateEx(true, false, true, true, null, null);
6381 else if(creationActivation == activate || creationActivation == flash)
6384 if(this == rootWindow)
6390 rootWindow.ConsequentialMouseMove(false);
6401 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6407 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6409 //style.hidden = true; // !visible;
6410 style.hidden = !visible;
6411 if(master.modalSlave == this)
6412 master.modalSlave = null;
6419 void WriteCaption(Surface surface, int x, int y)
6422 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6425 void Update(Box region)
6431 rootWindow = this.rootWindow;
6433 // rootWindow.mutex.Wait();
6434 if(!destroyed && visible && display)
6439 // Testing this to avoid repetitve full update to take time...
6440 if(dirtyArea.count == 1)
6442 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6443 if(item.box.left <= box.left &&
6444 item.box.top <= box.top &&
6445 item.box.right >= box.right &&
6446 item.box.bottom >= box.bottom)
6448 rootWindow.dirty = true;
6453 if(display.flags.flipping && !rootWindow.dirty)
6455 if(this == rootWindow)
6459 rootWindow.Update(null);
6464 rootWindow.dirty = true;
6469 realBox.left += clientStart.x;
6470 realBox.top += clientStart.y;
6471 realBox.right += clientStart.x;
6472 realBox.bottom += clientStart.y;
6478 if(realBox.right >= realBox.left &&
6479 realBox.bottom >= realBox.top)
6481 // if(!rootWindow.fullRender)
6482 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6484 for(child = children.first; child; child = child.next)
6489 box.left -= child.absPosition.x - absPosition.x;
6490 box.top -= child.absPosition.y - absPosition.y;
6491 box.right -= child.absPosition.x - absPosition.x;
6492 box.bottom -= child.absPosition.y - absPosition.y;
6493 if(box.right >= child.box.left && box.left <= child.box.right &&
6494 box.bottom >= child.box.top && box.top <= child.box.bottom)
6496 box.left -= child.clientStart.x;
6497 box.top -= child.clientStart.y;
6498 box.right -= child.clientStart.x;
6499 box.bottom -= child.clientStart.y;
6505 realBox.left += absPosition.x - rootWindow.absPosition.x;
6506 realBox.top += absPosition.y - rootWindow.absPosition.y;
6507 realBox.right += absPosition.x - rootWindow.absPosition.x;
6508 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6509 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6512 else if(this == guiApp.desktop)
6515 for(window = children.first; window; window = window.next)
6521 Box childBox = region;
6523 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6524 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6525 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6526 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6528 window.Update(childBox);
6531 window.Update(null);
6536 // rootWindow.mutex.Release();
6543 if(guiApp.windowCaptured != this)
6545 if(guiApp.windowCaptured)
6549 //Logf("Captured %s (%s)\n", caption, class.name);
6550 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6551 guiApp.windowCaptured = this;
6557 bool Destroy(int64 code)
6562 if(!destroyed && !CloseConfirmation(false)) return false;
6566 // TOCHECK: Should autoCreate be set to false here?
6577 void Move(int x, int y, int w, int h)
6579 normalAnchor = Anchor { left = x, top = y };
6580 normalSizeAnchor = SizeAnchor { size = { w, h } };
6582 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6584 if(destroyed) return;
6586 stateAnchor = normalAnchor;
6587 stateSizeAnchor = normalSizeAnchor;
6589 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6590 Position(x,y, w, h, true, true, true, true, false, true);
6594 DialogResult Modal(void)
6600 // FIXES MEMORY LEAK IF Create() FAILED
6606 void SetScrollArea(int width, int height, bool snapToStep)
6610 int stepX = sbStep.x, stepY = sbStep.y;
6611 // Needed to make snapped down position match the skin's check of client area
6612 // against realvirtual
6615 SNAPDOWN(stepX, textCellW);
6616 SNAPDOWN(stepY, textCellH);
6617 stepX = Max(stepX, textCellW);
6618 stepY = Max(stepY, textCellH);
6620 if(scrollFlags.snapX)
6621 SNAPUP(width, stepX);
6622 if(scrollFlags.snapY)
6623 SNAPUP(height, stepY);
6626 reqScrollArea.w = width;
6627 reqScrollArea.h = height;
6628 noAutoScrollArea = (width > 0 || height > 0);
6630 UpdateScrollBars(true, true);
6633 void SetScrollPosition(int x, int y)
6636 sbh.Action(setPosition, x, 0);
6640 int seen = clientSize.w, total = reqScrollArea.w;
6642 if(scrollFlags.snapX)
6643 SNAPDOWN(seen, sbStep.x);
6645 if(!total) total = seen;
6646 range = total - seen + 1;
6647 range = Max(range, 1);
6649 if(x >= range) x = range - 1;
6651 if(scrollFlags.snapX)
6652 SNAPUP(x, sbStep.x);
6655 OnHScroll(setPosition, x, 0);
6659 SNAPDOWN(x, textCellW);
6665 sbv.Action(setPosition, y, 0);
6669 int seen = clientSize.h, total = reqScrollArea.h;
6672 if(scrollFlags.snapY)
6673 SNAPDOWN(seen, sbStep.y);
6675 if(!total) total = seen;
6676 range = total - seen + 1;
6677 range = Max(range, 1);
6679 if(y >= range) y = range - 1;
6681 if(scrollFlags.snapY)
6682 SNAPUP(y, sbStep.y);
6685 OnVScroll(setPosition, y, 0);
6688 SNAPDOWN(y, textCellH);
6693 UpdateCaret(false, false);
6696 void SetScrollLineStep(int stepX, int stepY)
6702 SNAPDOWN(stepX, textCellW);
6703 SNAPDOWN(stepY, textCellH);
6704 stepX = Max(stepX, textCellW);
6705 stepY = Max(stepY, textCellH);
6708 sbh.lineStep = stepX;
6710 sbv.lineStep = stepY;
6713 void SetState(WindowState newState, bool activate, Modifiers mods)
6717 if(state == newState || OnStateChange(newState, mods))
6719 //WindowState prevState = state;
6723 // This used to be at the end of the brackets... moved for X, testing...
6724 // This has the effect of activating the window through the system...
6725 if(rootWindow == this)
6726 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6728 SetStateEx(newState, activate);
6730 if(rootWindow == this && !rootWindow.nativeDecorations)
6732 int x = position.x, y = position.y;
6735 x -= guiApp.desktop.absPosition.x;
6736 y -= guiApp.desktop.absPosition.y;
6738 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6742 //state = prevState;
6744 if(state != maximized && style.hasMaximize)
6747 for(child = parent.children.first; child; child = child.next)
6749 if(child != this && child.state == maximized)
6750 child.SetStateEx(normal, false);
6754 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6755 parent.UpdateScrollBars(true, true);
6758 // Do we really need this stuff here?
6759 // Shouldn't the Activate stuff take care of it?
6760 if(parent.rootWindow == parent && style)
6763 parent.FigureCaption(caption);
6764 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6765 parent.UpdateDecorations();
6769 rootWindow.ConsequentialMouseMove(false);
6776 BitmapResource GetIcon(SkinBitmap iconID)
6778 return guiApp.currentSkin.GetBitmap(iconID);
6781 void SetMouseRange(Box range)
6783 if(range || guiApp.fullScreenMode)
6788 clip.left = range.left + absPosition.x + clientStart.x;
6789 clip.top = range.top + absPosition.y + clientStart.y;
6790 clip.right = range.right + absPosition.x + clientStart.x;
6791 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6795 clip.left = guiApp.desktop.box.left;
6796 clip.top = guiApp.desktop.box.top;
6797 clip.right = guiApp.desktop.box.right;
6798 clip.bottom = guiApp.desktop.box.bottom;
6800 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6803 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6806 void SetMouseRangeToClient(void)
6808 if(guiApp.fullScreenMode || this != guiApp.desktop)
6810 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6811 box.Clip(clientArea);
6815 SetMouseRange(null);
6818 void SetMouseRangeToWindow(void)
6820 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6821 if(this == guiApp.desktop)
6822 SetMouseRangeToClient();
6827 // x, y: Desktop Coordinates
6828 void ShowSysMenu(int x, int y)
6831 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6834 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6835 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6839 menu, $"Move", m, NotifySelect = MenuWindowMove,
6840 disabled = !style.fixed || state == maximized
6844 menu, $"Size", s, NotifySelect = MenuWindowSize,
6845 disabled = !style.sizable || state != normal
6849 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6850 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6854 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6855 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6859 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6860 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6862 MenuDivider { menu };
6865 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6866 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6868 windowMenu.Create();
6873 ActivateEx(true, true, true, true, null, null);
6876 void MakeActive(void)
6878 ActivateEx(true, false, true, false, null, null);
6881 void SoftActivate(void)
6883 if(guiApp.desktop.active)
6888 if(this == rootWindow)
6893 void Deactivate(void)
6895 ActivateEx(false, true, true, true, null, null);
6900 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6903 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6905 bool result = false;
6906 if(activeChild && activeChild.cycle)
6908 Window modalWindow, child = activeChild;
6909 if(!clientOnly /*&& parent.tabCycle*/)
6911 Window next = child;
6914 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6918 if(parent && parent.CycleChildren(backward, false, true, true))
6926 next = next.cycle.prev.data;
6928 next = next.cycle.next.data;
6929 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6934 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6935 parent.tabCycle && parent.CycleChildren(backward, false, false))
6939 if(tabCycleOnly && !tabCycle) return false;
6946 child = child.cycle.prev.data;
6948 child = child.cycle.next.data;
6949 if(child == child.parent.activeChild)
6951 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6954 modalWindow = child.FindModal();
6957 // Scroll the window to include the active control
6958 if(sbh && !child.style.dontScrollHorz)
6960 if(child.scrolledPos.x < 0)
6961 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6962 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6963 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6965 if(sbv && !child.style.dontScrollVert)
6967 if(child.scrolledPos.y < 0)
6968 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6969 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6970 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6974 child = modalWindow ? modalWindow : child;
6975 child.ActivateEx(true, true, true, true, null, null);
6976 if(child.tabCycle && child.childrenCycle.first)
6977 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6985 ConsequentialMouseMove(false);
6989 void AddResource(Resource resource)
6993 ResPtr ptr { resource = resource };
6997 // Load Graphics here if window is created already
6998 if(/*created && */display)
7000 display.Lock(false);
7001 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7002 ptr.loaded = display.displaySystem.LoadResource(resource);
7006 // Temporary hack to load font right away for listbox in dropbox ...
7007 else if(master && master.display)
7009 master.display.Lock(false);
7010 master.display.displaySystem.LoadResource(resource);
7011 master.display.Unlock();
7017 void RemoveResource(Resource resource)
7022 for(ptr = resources.first; ptr; ptr = ptr.next)
7024 if(ptr.resource == resource)
7030 // Unload Graphics here if window is created already
7031 if(/*created && */display)
7035 display.Lock(false);
7036 display.displaySystem.UnloadResource(resource, ptr.loaded);
7042 resources.Delete(ptr);
7047 void SetCaret(int x, int y, int size)
7054 if(active && !style.interim && isEnabled)
7056 if(visible || !guiApp.caretOwner)
7057 guiApp.caretOwner = size ? this : null;
7059 UpdateCaret(false, false);
7062 guiApp.interfaceDriver.SetCaret(0,0,0);
7063 UpdateCaret(false, true);
7064 guiApp.caretEnabled = false;
7067 else if(style.inactive && active)
7069 guiApp.interfaceDriver.SetCaret(0,0,0);
7070 UpdateCaret(false, true);
7071 guiApp.caretEnabled = false;
7076 void Scroll(int x, int y)
7078 bool opaque = !style.drawBehind || background.a;
7079 if(opaque && display && display.flags.scrolling)
7081 Box box = clientArea;
7082 box.left += clientStart.x;
7083 box.top += clientStart.y;
7084 box.right += clientStart.x;
7085 box.bottom += clientStart.y;
7087 //scrollExtent.Free(null);
7088 scrollExtent.AddBox(box);
7089 scrolledArea.x += x;
7090 scrolledArea.y += y;
7092 //scrollExtent.Free();
7093 //scrollExtent.AddBox(clientArea);
7094 //scrollExtent.Offset(clientStart.x, clientStart.y);
7095 //scrolledArea.x = x;
7096 //scrolledArea.y = y;
7102 rootWindow.dirty = true;
7105 void ReleaseCapture()
7107 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7109 Window oldCaptured = guiApp.windowCaptured;
7110 guiApp.windowCaptured = null;
7111 guiApp.prevWindow = null;
7114 //guiApp.Log("Released Capture\n");
7116 guiApp.interfaceDriver.SetMouseCapture(null);
7118 //oldCaptured.OnMouseCaptureLost();
7121 oldCaptured.ConsequentialMouseMove(false);
7126 private void _SetCaption(const char * format, va_list args)
7133 char caption[MAX_F_STRING];
7134 vsnprintf(caption, sizeof(caption), format, args);
7135 caption[sizeof(caption)-1] = 0;
7137 this.caption = CopyString(caption);
7142 firewatchers caption;
7146 /*deprecated*/ void SetText(const char * format, ...)
7149 va_start(args, format);
7150 _SetCaption(format, args);
7154 void SetCaption(const char * format, ...)
7157 va_start(args, format);
7158 _SetCaption(format, args);
7162 bool Grab(Bitmap bitmap, Box box, bool decorations)
7164 bool result = false;
7165 if(display || this == guiApp.desktop)
7167 Box clip = {MININT, MININT, MAXINT, MAXINT};
7173 clip.Clip(clientArea);
7175 clip.Clip(this.box);
7177 if(rootWindow != this)
7179 clip.left += absPosition.y;
7180 clip.top += absPosition.y;
7181 clip.right += absPosition.x;
7182 clip.bottom += absPosition.y;
7185 clip.left += decorations ? 0 : clientStart.x;
7186 clip.top += decorations ? 0 : clientStart.y;
7187 clip.right += decorations ? 0 : clientStart.x;
7188 clip.bottom += decorations ? 0 : clientStart.y;
7190 if(display && display.flags.flipping)
7192 rootWindow.Update(null);
7193 rootWindow.UpdateDisplay();
7200 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7201 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7205 result = display.Grab(bitmap, clip.left, clip.top,
7206 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7208 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7210 if(!bitmap.Convert(null, pixelFormat888, null))
7217 void GetMousePosition(int * x, int * y)
7219 int mouseX = 0, mouseY = 0;
7220 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7223 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7224 if(this != guiApp.desktop)
7226 mouseX -= absPosition.x + clientStart.x;
7227 mouseY -= absPosition.y + clientStart.y;
7234 DialogResult DoModal()
7236 DialogResult returnCode = 0;
7237 int terminated = terminateX;
7240 while(!destroyed && guiApp.driver != null)
7242 if(terminateX != terminated)
7244 terminated = terminateX;
7245 guiApp.desktop.Destroy(0);
7246 if(guiApp.desktop.created)
7249 //printf("Resetting terminate X to 0\n");
7255 guiApp.UpdateDisplay();
7256 if(!guiApp.ProcessInput(false))
7259 returnCode = this.returnCode;
7272 return !destroyed && guiApp.driver != null && terminateX < 2;
7275 DialogResult DoModalEnd()
7277 DialogResult returnCode = this.returnCode;
7282 // --- Window manipulation ---
7283 /*bool GetDisabled()
7285 bool disabled = this.disabled;
7287 for(window = this; (window = window.master); )
7298 // --- Mouse Manipulation ---
7299 void GetNCMousePosition(int * x, int * y)
7301 GetMousePosition(x, y);
7302 if(x) *x += clientStart.x;
7303 if(y) *y += clientStart.y;
7306 // --- Carets manipulation ---
7307 void GetCaretPosition(Point caretPos)
7309 caretPos = this.caretPos;
7312 int GetCaretSize(void)
7317 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7323 bool CloseConfirmation(bool parentClosing)
7336 if(!OnClose(parentClosing))
7339 // If you want to skip this, simply set modifiedDocument to false in OnClose
7340 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7342 DialogResult dialogRes;
7345 sprintf(message, $"Save changes to %s?", fileName);
7347 sprintf(message, $"Save changes to Untitled %d?", documentID);
7349 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7351 if(dialogRes == yes)
7353 // TOFIX: Precomp error if brackets are taken out
7354 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7356 else if(dialogRes == cancel)
7362 for(slave = slaves.first; slave; slave = slave.next)
7364 Window w = slave.data;
7365 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7373 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7376 for(child = children.first; child; child = child.next)
7377 if(child.isActiveClient && !child.CloseConfirmation(true))
7385 for(child = children.first; child; child = child.next)
7386 if(!child.isActiveClient && !child.CloseConfirmation(true))
7396 // Static methods... move them somewhere else?
7397 void ::RestoreCaret()
7399 if(guiApp.caretOwner)
7400 guiApp.caretOwner.UpdateCaret(false, false);
7403 void ::FreeMouseRange()
7405 guiApp.interfaceDriver.SetMouseRange(null, null);
7409 bool MenuFileClose(MenuItem selection, Modifiers mods)
7411 Window document = activeChild;
7413 document.Destroy(0);
7417 bool MenuFileExit(MenuItem selection, Modifiers mods)
7423 bool MenuFileSave(MenuItem selection, Modifiers mods)
7428 fileMonitor.fileName = null;
7431 if(OnSaveFile(fileName))
7433 //if(OnFileModified != Window::OnFileModified)
7436 fileMonitor.fileName = fileName;
7442 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7443 DialogResult answer = dialog.Modal();
7445 if(answer != yes) return (bool)answer;
7448 return MenuFileSaveAs(selection, mods);
7451 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7453 DialogResult result = (DialogResult)bool::true;
7454 FileDialog fileDialog = saveDialog;
7459 fileDialog = FileDialog {};
7464 fileDialog.filePath = fileName;
7467 char filePath[MAX_FILENAME];
7468 sprintf(filePath, "Untitled %d", documentID);
7469 fileDialog.filePath = filePath;
7471 fileMonitor.fileName = null;
7473 fileDialog.type = save;
7474 fileDialog.text = $"Save As";
7478 fileDialog.master = master.parent ? master : this;
7479 if(fileDialog.Modal() == ok)
7481 const char * filePath = fileDialog.filePath;
7483 if(OnSaveFile(filePath))
7486 property::fileName = filePath;
7487 NotifySaved(master, this, filePath);
7492 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7493 DialogResult answer = dialog.Modal();
7508 //if(OnFileModified != Window::OnFileModified && fileName)
7511 fileMonitor.fileName = fileName;
7515 return (bool)result; // Actually returning result from Yes/NoCancel message box
7518 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7520 Window document = activeChild;
7522 for(document = children.first; document; document = next)
7524 next = document.next;
7525 if(document.style.isDocument || document.fileName)
7526 document.MenuFileSave(selection, mods);
7531 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7535 for(document = children.first; document; document = document.next)
7536 //if(document.style.isDocument && document.state == minimized)
7537 if(document.style.isActiveClient && document.state == minimized)
7538 document.SetState(minimized, false, mods);
7542 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7544 Window document = activeChild;
7547 Window firstDocument = null;
7549 OldLink cycle = document.cycle.prev;
7554 if(child.style.isActiveClient && !child.style.hidden)
7558 firstDocument = child;
7559 if(child.state == minimized)
7560 child.SetState(minimized, false, mods);
7563 child.positionID = id++;
7564 child.SetState(normal, false, mods);
7565 child.anchor.left.type = cascade;
7568 child.normalSizeAnchor = *&child.sizeAnchor;
7569 child.normalAnchor = child.anchor;
7571 // Break the anchors for moveable/resizable windows
7572 if(child.style.fixed)
7574 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7576 (*&child.normalAnchor).left = x;
7577 (*&child.normalAnchor).top = y;
7578 (*&child.normalAnchor).right.type = none;
7579 (*&child.normalAnchor).bottom.type = none;
7581 child.normalSizeAnchor.isClientW = false;
7582 child.normalSizeAnchor.isClientH = false;
7583 child.normalSizeAnchor.size.w = w;
7584 child.normalSizeAnchor.size.h = h;
7585 child.anchored = false;
7588 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7590 child.stateAnchor = child.normalAnchor;
7591 child.stateSizeAnchor = child.normalSizeAnchor;
7593 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7594 child.Position(x, y, w, h, true, true, true, true, false, false);
7599 last = children.last;
7600 if(!child.style.stayOnTop)
7601 for(; last && last.style.stayOnTop; last = last.prev);
7602 children.Move(child, last);
7603 childrenOrder.Move(child.order, childrenOrder.last);
7605 if(cycle == document.cycle) break;
7609 firstDocument.Activate();
7614 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7621 // Close all closes all active clients, not all documents
7622 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7624 Window next, document;
7626 for(document = children.first; document; document = next)
7628 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7629 if(document.style.isActiveClient)
7630 if(!document.Destroy(0) && !document.style.hidden)
7636 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7638 if(style.hasMaximize && state != maximized)
7639 SetState(maximized, 0, 0);
7643 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7645 if(style.hasMinimize && state != minimized)
7647 SetState(minimized, 0, 0);
7648 parent.CycleChildren(false, true, false, true);
7653 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7655 MenuMoveOrSize(false, selection ? true : false);
7659 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7661 CycleChildren(false, true, false, true);
7665 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7667 CycleChildren(true, true, false, true);
7671 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7673 MenuMoveOrSize(true, true);
7677 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7680 SetState(normal, 0, 0);
7684 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7687 int64 id = selection.id;
7688 OldLink cycle = activeClient.cycle;
7690 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7693 Window sibling = cycle.data;
7694 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7702 document = cycle.data;
7703 document.Activate();
7705 //if(activeChild.state == maximized)
7706 // document.SetState(maximized, false, mods);
7707 //else if(document.state == minimized)
7708 // document.SetState(normal, false, mods);
7712 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7714 stayOnTop = !style.stayOnTop;
7718 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7720 Window document = activeChild;
7723 Window firstDocument = null;
7724 OldLink cycle = document.cycle;
7728 Window child = cycle.data;
7729 if(child.style.isActiveClient && !child.style.hidden)
7731 if(!firstDocument) firstDocument = child;
7732 if(child.state == minimized)
7733 child.SetState(minimized, false, mods);
7736 child.positionID = id++;
7737 child.SetState(normal, false, mods);
7738 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7740 child.anchor.left.type = hTiled;
7743 child.normalSizeAnchor = *&child.sizeAnchor;
7744 child.normalAnchor = child.anchor;
7746 // Break the anchors for moveable/resizable windows
7747 if(child.style.fixed)
7749 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7751 (*&child.normalAnchor).left = x;
7752 (*&child.normalAnchor).top = y;
7753 (*&child.normalAnchor).right.type = none;
7754 (*&child.normalAnchor).bottom.type = none;
7755 child.normalSizeAnchor.isClientW = false;
7756 child.normalSizeAnchor.isClientH = false;
7757 child.normalSizeAnchor.size.w = w;
7758 child.normalSizeAnchor.size.h = h;
7759 child.anchored = false;
7762 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7764 child.stateAnchor = child.normalAnchor;
7765 child.stateSizeAnchor = child.normalSizeAnchor;
7767 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7768 child.Position(x,y, w, h, true, true, true, true, false, true);
7773 if((cycle = cycle.next) == document.cycle) break;
7776 firstDocument.Activate();
7781 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7783 Window document = activeChild;
7786 Window firstDocument = null;
7788 OldLink cycle = document.cycle;
7793 //if(child.style.isDocument)
7794 if(child.style.isActiveClient && !child.style.hidden)
7796 if(!firstDocument) firstDocument = child;
7797 if(child.state == minimized)
7798 child.SetState(minimized, false, mods);
7801 child.positionID = id++;
7802 child.SetState(normal, false, mods);
7803 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7805 child.anchor.left.type = vTiled;
7808 child.normalSizeAnchor = *&child.sizeAnchor;
7809 child.normalAnchor = child.anchor;
7811 // Break the anchors for moveable/resizable windows
7812 if(child.style.fixed)
7814 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7816 (*&child.normalAnchor).left = x;
7817 (*&child.normalAnchor).top = y;
7818 (*&child.normalAnchor).right.type = none;
7819 (*&child.normalAnchor).bottom.type = none;
7820 child.normalSizeAnchor.isClientW = false;
7821 child.normalSizeAnchor.isClientH = false;
7822 child.normalSizeAnchor.size.w = w;
7823 child.normalSizeAnchor.size.h = h;
7824 child.anchored = false;
7827 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7829 child.stateAnchor = child.normalAnchor;
7830 child.stateSizeAnchor = child.normalSizeAnchor;
7832 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7833 child.Position(x,y, w, h, true, true, true, true, false, true);
7838 if((cycle = cycle.next) == document.cycle) break;
7841 firstDocument.Activate();
7846 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7848 WindowList dialog { master = this };
7849 Window document = (Window)(intptr)dialog.Modal();
7852 if(activeChild.state == maximized)
7853 document.SetState(maximized, false, mods);
7854 else if(document.state == minimized)
7855 document.SetState(normal, false, mods);
7856 document.Activate();
7862 virtual bool OnCreate(void);
7863 virtual void OnDestroy(void);
7864 virtual void OnDestroyed(void);
7865 virtual bool OnClose(bool parentClosing);
7866 virtual bool OnStateChange(WindowState state, Modifiers mods);
7867 virtual bool OnPostCreate(void);
7868 virtual bool OnMoving(int *x, int *y, int w, int h);
7869 virtual bool OnResizing(int *width, int *height);
7870 virtual void OnResize(int width, int height);
7871 virtual void OnPosition(int x, int y, int width, int height);
7872 virtual bool OnLoadGraphics(void);
7873 virtual void OnApplyGraphics(void);
7874 virtual void OnUnloadGraphics(void);
7875 virtual void OnRedraw(Surface surface);
7876 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7877 virtual void OnActivateClient(Window client, Window previous);
7878 virtual bool OnKeyDown(Key key, unichar ch);
7879 virtual bool OnKeyUp(Key key, unichar ch);
7880 virtual bool OnKeyHit(Key key, unichar ch);
7881 virtual bool OnSysKeyDown(Key key, unichar ch);
7882 virtual bool OnSysKeyUp(Key key, unichar ch);
7883 virtual bool OnSysKeyHit(Key key, unichar ch);
7884 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7885 virtual bool OnMouseLeave(Modifiers mods);
7886 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7887 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7888 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7889 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7890 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7891 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7892 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7893 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7894 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7895 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7896 virtual void OnMouseCaptureLost(void);
7897 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7898 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7899 virtual void OnDrawOverChildren(Surface surface);
7900 virtual bool OnFileModified(FileChange fileChange, const char * param);
7901 virtual bool OnSaveFile(const char * fileName);
7903 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7904 // Note: A 'client' would refer to isActiveClient, rather than
7905 // being confined to the 'client area' (nonClient == false)
7906 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7907 virtual void OnChildVisibilityToggled(Window child, bool visible);
7908 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7910 // Skins Virtual Functions
7911 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7912 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7913 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7918 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7919 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7920 virtual bool IsMouseMoving(int x, int y, int w, int h)
7924 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7928 virtual void UpdateNonClient();
7929 virtual void SetBox(Box box); // This is used in the MySkin skin
7930 virtual bool IsInside(int x, int y)
7932 return box.IsPointInside({x, y});
7934 virtual bool IsOpaque()
7936 return (!style.drawBehind || background.a == 255);
7940 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7941 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7942 virtual void Window::NotifySaved(Window window, const char * filePath);
7947 property Window parent
7949 property_category $"Layout"
7952 if(value || guiApp.desktop)
7955 Window oldParent = parent;
7956 Anchor anchor = this.anchor;
7958 if(value && value.IsDescendantOf(this)) return;
7959 if(value && value == this)
7961 if(!value) value = guiApp.desktop;
7963 if(value == oldParent) return;
7965 if(!master || (master == this.parent && master == guiApp.desktop))
7966 property::master = value;
7970 parent.children.Remove(this);
7974 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7975 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7976 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7977 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7981 last = value.children.last;
7983 if(style.isDocument)
7986 parent.numDocuments--;
7987 documentID = value.GetDocumentID();
7990 if(style.isActiveClient && !style.hidden)
7992 if(parent && parent != guiApp.desktop && !(style.hidden))
7994 if(state == minimized) parent.numIcons--;
7995 parent.numPositions--;
7999 if(!style.stayOnTop)
8000 for(; last && last.style.stayOnTop; last = last.prev);
8002 value.children.Insert(last, this);
8004 // *** NEW HERE: ***
8006 parent.childrenCycle.Delete(cycle);
8008 parent.childrenOrder.Delete(order);
8011 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8012 // Should something else be done?
8013 if(parent && parent.activeChild == this)
8014 parent.activeChild = null;
8015 if(parent && parent.activeClient == this)
8016 parent.activeClient = null;
8022 int x = position.x, y = position.y, w = size.w, h = size.h;
8026 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8027 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8029 vpw = value.clientSize.w;
8030 vph = value.clientSize.h;
8036 else if(style.fixed)
8038 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8039 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8042 anchor = this.anchor;
8044 if(anchor.left.type == offset) anchor.left.distance = x;
8045 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8046 if(anchor.top.type == offset) anchor.top.distance = y;
8047 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8048 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8049 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8050 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8051 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8052 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8053 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8055 if(!anchor.left.type && !anchor.right.type)
8057 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8058 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8060 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8061 if(!anchor.top.type && !anchor.bottom.type)
8063 anchor.vert.distance = (y + h / 2) - (vph / 2);
8064 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8066 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8069 parent.OnChildAddedOrRemoved(this, false);
8075 parent.childrenCycle.Insert(
8076 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8077 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8079 cycle = OldLink { data = this });
8080 parent.childrenOrder.Insert(
8081 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8082 order = OldLink { data = this });
8085 if(!style.hidden && style.isActiveClient)
8087 positionID = parent.GetPositionID(this);
8088 parent.numPositions++;
8089 if(state == minimized) parent.numIcons--;
8092 // *** FONT INHERITANCE ***
8093 if(!setFont && oldParent)
8094 stopwatching(oldParent, font);
8098 RemoveResource(systemFont);
8101 // TESTING WITH WATCHERS:
8102 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8103 // usedFont = setFont ? setFont : (systemFont);
8107 if(guiApp.currentSkin)
8109 systemFont = guiApp.currentSkin.SystemFont();
8112 usedFont = systemFont;
8113 AddResource(systemFont);
8121 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8130 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8132 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8133 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8136 UnloadGraphics(false);
8139 LoadGraphics(false, false);
8142 if(value.rootWindow != rootWindow)
8143 DisplayModeChanged();
8147 scrolledPos.x = MININT; // Prevent parent update
8149 bool anchored = this.anchored;
8150 property::anchor = anchor;
8151 this.anchored = anchored;
8156 if(guiApp.currentSkin)
8157 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8159 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8160 Position(x, y, w, h, true, true, true, true, false, true);
8165 // else parent = value;
8167 oldParent.OnChildAddedOrRemoved(this, true);
8170 get { return parent; }
8173 property Window master
8175 property_category $"Behavior"
8178 //if(this == value) return;
8179 if(value && value.IsSlaveOf(this)) return;
8185 OldLink slaveHolder;
8186 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8187 if(slaveHolder.data == this)
8189 master.slaves.Delete(slaveHolder);
8196 value.slaves.Add(OldLink { data = this });
8201 master.hotKeys.Remove(hotKey);
8202 value.hotKeys.Add(hotKey);
8205 if(master && master.defaultControl == this)
8206 master.defaultControl = null;
8208 if(style.isDefault && !value.defaultControl)
8209 value.defaultControl = this;
8214 get { return master ? master : parent; }
8217 property const char * caption
8219 property_category $"Appearance"
8226 caption = new char[strlen(value)+1];
8228 strcpy(caption, value);
8233 get { return caption; }
8238 property_category $"Behavior"
8247 master.hotKeys.Add(hotKey = HotKeySlot { });
8251 hotKey.window = this;
8256 master.hotKeys.Delete(hotKey);
8261 get { return hotKey ? hotKey.key : 0; }
8264 property Color background
8266 property_category $"Appearance"
8269 background.color = value;
8274 if(this == rootWindow)
8275 guiApp.interfaceDriver.SetRootWindowColor(this);
8278 get { return background.color; }
8281 property Percentage opacity
8283 property_category $"Appearance"
8286 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8287 drawBehind = (background.a == 255) ? false : true;
8289 get { return background.a / 255.0f; }
8292 property Color foreground
8294 property_category $"Appearance"
8302 get { return foreground; }
8305 property BorderStyle borderStyle
8307 property_category $"Appearance"
8310 if(!((BorderBits)value).fixed)
8312 style.hasClose = false;
8313 style.hasMaximize = false;
8314 style.hasMinimize = false;
8315 nativeDecorations = false;
8317 style.borderBits = value;
8321 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8323 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8324 Position(x, y, w, h, true, true, true, true, false, true);
8325 CreateSystemChildren();
8328 get { return (BorderStyle)style.borderBits; }
8331 property Size minClientSize
8333 property_category $"Layout"
8334 set { minSize = value; }
8335 get { value = minSize; }
8338 property Size maxClientSize
8340 property_category $"Layout"
8341 set { maxSize = value; }
8342 get { value = maxSize; }
8345 property bool hasMaximize
8347 property_category $"Window Style"
8350 style.hasMaximize = value;
8351 if(value) { style.fixed = true; style.contour = true; }
8355 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8357 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8358 Position(x, y, w, h, true, true, true, true, false, true);
8360 CreateSystemChildren();
8363 get { return style.hasMaximize; }
8366 property bool hasMinimize
8368 property_category $"Window Style"
8371 style.hasMinimize = value;
8372 if(value) { style.fixed = true; style.contour = true; }
8376 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8378 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8379 Position(x, y, w, h, true, true, true, true, false, true);
8381 CreateSystemChildren();
8384 get { return style.hasMinimize; }
8387 property bool hasClose
8389 property_category $"Window Style"
8392 style.hasClose = value;
8393 if(value) { style.fixed = true; style.contour = true; }
8397 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8398 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8399 Position(x, y, w, h, true, true, true, true, false, true);
8400 CreateSystemChildren();
8403 get { return style.hasClose; }
8406 property bool nonClient
8408 property_category $"Layout"
8411 style.nonClient = value;
8413 style.stayOnTop = true;
8415 get { return style.nonClient; }
8418 property bool inactive
8420 property_category $"Behavior"
8425 // *** NEW HERE: ***
8429 parent.childrenCycle.Delete(cycle);
8431 parent.childrenOrder.Delete(order);
8438 active = false; // true;
8439 if(parent.activeChild == this)
8440 parent.activeChild = null;
8441 if(parent.activeClient == this)
8442 parent.activeClient = null;
8451 parent.childrenCycle.Insert(
8452 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8453 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8455 cycle = OldLink { data = this });
8457 parent.childrenOrder.Insert(
8458 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8459 order = OldLink { data = this });
8462 style.inactive = value;
8464 get { return style.inactive; }
8467 property bool clickThrough
8469 property_category $"Behavior"
8470 set { style.clickThrough = value; }
8471 get { return style.clickThrough; }
8474 property bool isRemote
8476 property_category $"Behavior"
8477 set { style.isRemote = value; }
8478 get { return style.isRemote; }
8481 property bool noCycle
8483 property_category $"Behavior"
8484 set { style.noCycle = value; }
8485 get { return style.noCycle; }
8488 property bool isModal
8490 property_category $"Behavior"
8491 set { style.modal = value; }
8492 get { return style.modal; }
8495 property bool interim
8497 property_category $"Behavior"
8498 set { style.interim = value; }
8499 get { return style.interim; }
8502 property bool tabCycle
8504 property_category $"Behavior"
8505 set { style.tabCycle = value; }
8506 get { return style.tabCycle; }
8509 property bool isDefault
8511 property_category $"Behavior"
8519 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8520 if(sibling != this && sibling.style.isDefault)
8521 sibling.style.isDefault = false;*/
8522 if(master.defaultControl)
8523 master.defaultControl.style.isDefault = false;
8524 master.defaultControl = this;
8526 else if(master.defaultControl == this)
8527 master.defaultControl = null;
8531 style.isDefault = value;
8533 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8535 get { return style.isDefault; }
8538 property bool drawBehind
8540 property_category $"Window Style"
8541 set { style.drawBehind = value; }
8542 get { return style.drawBehind; }
8545 property bool hasMenuBar
8547 property_category $"Window Style"
8557 if(created && !menuBar)
8564 anchor = Anchor { top = 23, left = 1, right = 1 },
8566 inactive = true, nonClient = true
8571 else if(created && menuBar)
8576 style.hasMenuBar = value;
8578 get { return style.hasMenuBar; }
8581 property bool hasStatusBar
8583 property_category $"Window Style"
8590 statusBar = StatusBar { this };
8598 style.hasStatusBar = value;
8600 get { return style.hasStatusBar; }
8602 property bool stayOnTop
8604 property_category $"Window Style"
8609 if(created && !style.stayOnTop)
8611 if(rootWindow == this)
8612 guiApp.interfaceDriver.OrderRootWindow(this, true);
8613 else if(parent.children.last != this)
8615 parent.children.Move(this, parent.children.last);
8619 style.stayOnTop = true;
8623 if(created && style.stayOnTop)
8625 if(rootWindow == this)
8626 guiApp.interfaceDriver.OrderRootWindow(this, false);
8633 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8634 order && ((Window)order.data).style.stayOnTop;
8635 order = (order == parent.childrenOrder.first) ? null : order.prev);
8636 last = order ? order.data : null;
8640 for(last = parent.children.last;
8641 last && last.style.stayOnTop;
8645 parent.children.Move(this, last);
8649 style.stayOnTop = false;
8652 get { return style.stayOnTop; }
8657 property_category $"Window Style"
8667 if(menuBar && !value)
8674 if(!menuBar && style.hasMenuBar && value)
8678 this, menu = value, isMenuBar = true,
8679 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8680 inactive = true, nonClient = true
8684 UpdateActiveDocument(null);
8687 get { return menu; }
8690 property FontResource font
8692 property_category $"Appearance"
8694 isset { return setFont ? true : false; }
8699 if(value && !setFont) { stopwatching(parent, font); }
8700 else if(!value && setFont)
8706 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8715 RemoveResource(setFont);
8720 RemoveResource(systemFont);
8727 AddResource(setFont);
8730 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8733 systemFont = guiApp.currentSkin.SystemFont();
8735 usedFont = systemFont;
8736 AddResource(systemFont);
8744 get { return usedFont; }
8747 property SizeAnchor sizeAnchor
8749 property_category $"Layout"
8752 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8753 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8754 sizeAnchor.isClientW != sizeAnchor.isClientH;
8761 normalSizeAnchor = sizeAnchor;
8763 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8765 stateAnchor = normalAnchor;
8766 stateSizeAnchor = normalSizeAnchor;
8768 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8769 Position(x,y, w, h, true, true, true, true, false, true);
8776 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8777 sizeAnchor.isClientW,
8778 sizeAnchor.isClientH
8785 property_category $"Layout"
8788 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8789 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8790 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8796 sizeAnchor.isClientW = false;
8797 sizeAnchor.isClientH = false;
8798 sizeAnchor.size = value;
8800 normalSizeAnchor = sizeAnchor;
8802 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8804 stateAnchor = normalAnchor;
8805 stateSizeAnchor = normalSizeAnchor;
8807 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8808 Position(x, y, w, h, true, true, true, true, false, true);
8809 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8812 get { value = size; }
8815 property Size clientSize
8817 property_category $"Layout"
8820 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8821 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8822 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8827 sizeAnchor.isClientW = true;
8828 sizeAnchor.isClientH = true;
8829 sizeAnchor.size = value;
8831 normalSizeAnchor = sizeAnchor;
8833 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8835 stateAnchor = normalAnchor;
8836 stateSizeAnchor = normalSizeAnchor;
8838 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8839 Position(x,y, w, h, true, true, true, true, false, true);
8840 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8843 get { value = this ? clientSize : { 0, 0 }; }
8846 property Size initSize { get { value = sizeAnchor.size; } };
8848 property Anchor anchor
8850 property_category $"Layout"
8851 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8857 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8859 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8860 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8862 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8864 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8865 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8869 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8871 anchor.left.distance = 0;
8872 anchor.horz.type = 0;
8874 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8876 anchor.top.distance = 0;
8877 anchor.vert.type = 0;
8886 normalAnchor = anchor;
8888 // Break the anchors for moveable/resizable windows
8889 /*if(style.fixed ) //&& value.left.type == cascade)
8891 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8893 this.anchor = normalAnchor = Anchor { left = x, top = y };
8894 normalSizeAnchor = SizeAnchor { { w, h } };
8897 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8899 stateAnchor = normalAnchor;
8900 stateSizeAnchor = normalSizeAnchor;
8902 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8903 Position(x, y, w, h, true, true, true, true, false, true);
8912 get { value = this ? anchor : Anchor { }; }
8915 property Point position
8917 property_category $"Layout"
8920 if(value == null) return;
8922 anchor.left = value.x;
8923 anchor.top = value.y;
8924 anchor.right.type = none;
8925 anchor.bottom.type = none;
8930 normalAnchor = anchor;
8932 // Break the anchors for moveable/resizable windows
8936 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8938 normalAnchor.left = x;
8939 normalAnchor.top = y;
8940 normalAnchor.right.type = none;
8941 normalAnchor.bottom.type = none;
8942 normalSizeAnchor.size.width = w;
8943 normalSizeAnchor.size.height = h;
8947 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8949 stateAnchor = normalAnchor;
8950 stateSizeAnchor = normalSizeAnchor;
8952 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8953 Position(x,y, w, h, true, true, true, true, false, true);
8957 get { value = position; }
8960 property bool disabled
8962 property_category $"Behavior"
8965 if(this && disabled != value)
8972 get { return (bool)disabled; }
8975 property bool isEnabled
8980 for(parent = this; parent; parent = parent.parent)
8987 property WindowState state
8989 property_category $"Behavior"
8990 set { SetState(value, false, 0); }
8991 get { return this ? state : 0; }
8994 property bool visible
8996 property_category $"Behavior"
8999 if(this && !value && !style.hidden && parent)
9001 bool wasActiveChild = parent.activeChild == this;
9002 Window client = null;
9004 style.hidden = true;
9005 if(style.isActiveClient)
9007 parent.numPositions--;
9008 if(state == minimized) parent.numIcons--;
9013 OldLink prevOrder = null;
9015 if(rootWindow == this)
9016 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9019 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9022 box.left -= parent.clientStart.x;
9023 box.top -= parent.clientStart.y;
9024 box.right -= parent.clientStart.x;
9025 box.bottom -= parent.clientStart.y;
9029 if(_isModal && master && master.modalSlave == this)
9030 master.modalSlave = null;
9034 OldLink tmpPrev = order.prev;
9035 client = tmpPrev ? tmpPrev.data : null;
9036 if(client && !client.style.hidden && !client.destroyed && client.created)
9037 prevOrder = tmpPrev;
9040 client = tmpPrev ? tmpPrev.data : null;
9041 if(client == this) { client = null; break; }
9042 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9044 tmpPrev = client.order.prev;
9049 prevOrder = tmpPrev;
9054 // If this window can be an active client, make sure the next window we activate can also be one
9055 if(!style.nonClient && style.isActiveClient)
9057 tmpPrev = prevOrder;
9060 client = tmpPrev ? tmpPrev.data : null;
9061 if(client == this) { client = null; break; }
9062 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9064 tmpPrev = client.order.prev;
9069 prevOrder = tmpPrev;
9073 if(client && client.style.hidden) client = null;
9077 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9079 if(order && prevOrder && prevOrder.data != this)
9080 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9082 ActivateEx(false, false, false, true, null, null);
9084 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9085 if(parent.activeClient == this)
9087 parent.activeClient = null;
9088 parent.UpdateActiveDocument(null);
9091 else if(parent.activeClient == this)
9093 parent.activeClient = client;
9094 parent.UpdateActiveDocument(this);
9097 // *** Not doing this anymore ***
9100 parent.childrenCycle.Delete(cycle);
9102 parent.childrenOrder.Delete(order);
9107 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9112 else if(this && value && style.hidden)
9114 style.hidden = false;
9117 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9118 if(rootWindow == this)
9119 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9121 if(_isModal && master)
9122 master.modalSlave = this;
9124 if(style.isActiveClient)
9126 positionID = parent.GetPositionID(this);
9127 parent.numPositions++;
9128 if(state == minimized) parent.numIcons++;
9131 // *** NOT DOING THIS ANYMORE ***
9133 if(!(style.inactive))
9135 if(!(style.noCycle))
9137 cycle = parent.childrenCycle.AddAfter(
9138 (parent.activeChild && parent.activeChild.cycle) ?
9139 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9142 order = parent.childrenOrder.AddAfter(
9143 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9150 if(true || !parent.activeChild)
9151 ActivateEx(true, false, true, true, null, null);
9153 if(creationActivation == activate && guiApp.desktop.active)
9154 ActivateEx(true, false, true, true, null, null);
9155 else if((creationActivation == activate || creationActivation == flash) && !object)
9158 if(this == rootWindow)
9162 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9166 ConsequentialMouseMove(false);
9172 style.hidden = !value;
9175 get { return (style.hidden || !setVisible) ? false : true; }
9178 property bool isDocument
9180 property_category $"Document"
9181 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9182 get { return style.isDocument; }
9185 property bool mergeMenus
9187 property_category $"Window Style"
9188 set { mergeMenus = value; }
9189 get { return (bool)mergeMenus; }
9192 property bool hasHorzScroll
9194 property_category $"Window Style"
9199 if(!style.hasHorzScroll && created)
9201 CreateSystemChildren();
9202 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9205 else if(style.hasHorzScroll)
9209 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9211 style.hasHorzScroll = value;
9214 get { return style.hasHorzScroll; }
9217 property bool hasVertScroll
9219 property_category $"Window Style"
9224 if(!style.hasVertScroll && created)
9226 style.hasVertScroll = true;
9227 CreateSystemChildren();
9228 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9231 else if(style.hasVertScroll)
9235 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9237 style.hasVertScroll = value;
9239 get { return style.hasVertScroll; }
9242 property bool dontHideScroll
9244 property_category $"Behavior"
9247 scrollFlags.dontHide = value;
9250 //UpdateScrollBars(true, true);
9251 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9255 // UpdateScrollBars(true, true);
9256 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9259 get { return scrollFlags.dontHide; }
9262 property bool dontScrollVert
9264 property_category $"Behavior"
9265 set { style.dontScrollVert = value; }
9266 get { return style.dontScrollVert; }
9268 property bool dontScrollHorz
9270 property_category $"Behavior"
9271 set { style.dontScrollHorz = value; }
9272 get { return style.dontScrollHorz; }
9275 property bool snapVertScroll
9277 property_category $"Behavior"
9280 scrollFlags.snapY = value;
9281 if(sbv) sbv.snap = value;
9283 get { return scrollFlags.snapY; }
9285 property bool snapHorzScroll
9287 property_category $"Behavior"
9290 scrollFlags.snapX = value;
9291 if(sbh) sbh.snap = value;
9293 get { return scrollFlags.snapX; }
9296 property Point scroll
9298 property_category $"Behavior"
9299 set { if(this) SetScrollPosition(value.x, value.y); }
9300 get { value = scroll; }
9303 property bool modifyVirtualArea
9305 property_category $"Behavior"
9306 set { modifyVirtArea = value; }
9307 get { return (bool)modifyVirtArea; }
9310 property bool dontAutoScrollArea
9312 property_category $"Behavior"
9313 // Activating a child control out of view will automatically scroll to make it in view
9314 set { noAutoScrollArea = value; }
9315 get { return (bool)noAutoScrollArea; }
9318 property const char * fileName
9320 property_category $"Document"
9325 if(menu && ((!fileName && value) || (fileName && !value)))
9327 MenuItem item = menu.FindItem(MenuFileSave, 0);
9328 if(item) item.disabled = !modifiedDocument && value;
9333 if(value && value[0])
9334 fileName = CopyString(value);
9336 if(parent && this == parent.activeClient)
9337 parent.UpdateActiveDocument(null);
9341 // if(style.isDocument)
9343 fileMonitor.fileName = value;
9345 get { return fileName; }
9350 property_category $"Data"
9355 property bool modifiedDocument
9357 property_category $"Document"
9360 if(style.isDocument || fileName)
9364 MenuItem item = menu.FindItem(MenuFileSave, 0);
9365 if(item) item.disabled = !value && fileName;
9369 if(modifiedDocument != value)
9371 modifiedDocument = value;
9372 if(style.isDocument || fileName)
9376 get { return (bool)modifiedDocument; }
9379 property bool showInTaskBar
9381 property_category $"Window Style"
9382 set { style.showInTaskBar = value; }
9383 get { return style.showInTaskBar; }
9385 property FileDialog saveDialog { set { saveDialog = value; } };
9386 property bool isActiveClient
9388 property_category $"Behavior"
9391 if(parent && style.isActiveClient != value && !style.hidden)
9395 if(state == minimized) parent.numIcons++;
9396 parent.numPositions++;
9400 if(state == minimized) parent.numIcons--;
9401 parent.numPositions--;
9404 style.isActiveClient = value;
9406 get { return style.isActiveClient; }
9409 property Cursor cursor
9411 property_category $"Appearance"
9415 SelectMouseCursor();
9417 get { return cursor; }
9420 //#if !defined(ECERE_VANILLA)
9421 property const char * name
9423 property_category $"Design"
9426 return (this && object) ? object.name : null;
9431 activeDesigner.RenameObject(object, value);
9435 property const char * displayDriver
9437 property_category $"Behavior"
9440 dispDriver = GetDisplayDriver(value);
9441 //DisplayModeChanged();
9445 return dispDriver ? dispDriver.name : null;
9449 // RUNTIME PROPERTIES
9450 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9451 property Size scrollArea
9453 property_category $"Behavior"
9457 SetScrollArea(value.w, value.h, false);
9459 SetScrollArea(0,0, true);
9461 get { value = scrollArea; }
9464 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9469 property_category $"Layout"
9470 set { if(this) is3D = value; }
9471 get { return (bool)is3D; }
9474 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9476 // Will be merged with font later
9477 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9478 property Point clientStart { get { value = clientStart; } };
9479 property Point absPosition { get { value = absPosition; } };
9480 property Anchor normalAnchor { get { value = normalAnchor; } };
9481 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9482 property bool active { get { return (bool)active; } };
9483 property bool created { get { return (bool)created; } };
9484 property bool destroyed { get { return (bool)destroyed; } };
9485 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9486 property Window firstChild { get { return children.first; } };
9487 property Window lastChild { get { return children.last; } };
9488 property Window activeClient { get { return activeClient; } };
9489 property Window activeChild { get { return activeChild; } };
9490 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9491 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9492 property ScrollBar horzScroll { get { return sbh; } };
9493 property ScrollBar vertScroll { get { return sbv; } };
9494 property StatusBar statusBar { get { return statusBar; } };
9495 property Window rootWindow { get { return rootWindow; } };
9496 property bool closing { get { return (bool)closing; } set { closing = value; } };
9497 property int documentID { get { return documentID; } };
9498 property Window previous { get { return prev; } }
9499 property Window next { get { return next; } }
9500 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9501 property PopupMenu menuBar { get { return menuBar; } }
9502 property ScrollBar sbv { get { return sbv; } }
9503 property ScrollBar sbh { get { return sbh; } }
9504 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9505 property void * systemHandle { get { return windowHandle; } }
9506 property Button minimizeButton { get { return sysButtons[0]; } };
9507 property Button maximizeButton { get { return sysButtons[1]; } };
9508 property Button closeButton { get { return sysButtons[2]; } };
9509 property BitmapResource icon
9511 get { return icon; }
9515 if(icon) incref icon;
9517 guiApp.interfaceDriver.SetIcon(this, value);
9520 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9521 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9522 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9523 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9524 property bool nativeDecorations
9526 get { return (bool)nativeDecorations; }
9527 set { nativeDecorations = value; }
9528 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9531 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9532 bool result = false;
9533 if(nativeDecorations)
9535 if(rootWindow == this)
9539 if(formDesigner && activeDesigner)
9541 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9542 Window form = cd ? cd.form : null;
9543 if(form && parent == form.parent)
9548 return result != style.fixed;
9552 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9554 property const char * text
9556 property_category $"Deprecated"
9558 set { property::caption = value; }
9559 get { return property::caption; }
9565 WindowBits style; // Window Style
9566 char * caption; // Name / Caption
9567 Window parent; // Parent window
9568 OldList children; // List of children in Z order
9569 Window activeChild; // Child window having focus
9570 Window activeClient;
9571 Window previousActive; // Child active prior to activating the default child
9572 Window master; // Window owning and receiving notifications concerning this window
9573 OldList slaves; // List of windows belonging to this window
9574 Display display; // Display this window is drawn into
9576 Point position; // Position in parent window client area
9577 Point absPosition; // Absolute position
9578 Point clientStart; // Client area position from (0,0) in this window
9580 Size clientSize; // Client area size
9581 Size scrollArea; // Virtual Scroll area size
9582 Size reqScrollArea; // Requested virtual area size
9583 Point scroll; // Virtual area scrolling position
9584 ScrollBar sbh, sbv; // Scrollbar window handles
9585 Cursor cursor; // Mouse cursor used for this window
9588 StatusBar statusBar;
9589 Button sysButtons[3];
9591 Box clientArea; // Client Area box clipped to parent
9593 HotKeySlot hotKey; // HotKey for this window
9597 ScrollFlags scrollFlags;// Window Scrollbar Flags
9598 int64 id; // Control ID
9600 ColorAlpha background; // Background color used to draw the window area
9602 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9603 OldList childrenCycle; // Cycling order
9604 OldLink cycle; // Element of parent's cycling order
9605 OldList childrenOrder; // Circular Z-Order
9606 OldLink order; // Element of parent's circular Z-Order
9607 Window modalSlave; // Slave window blocking this window's interaction
9609 Window rootWindow; // Topmost system managed window
9610 void * windowHandle; // System window handle
9612 DialogResult returnCode;// Return code for modal windows
9614 Point sbStep; // Scrollbar line scrolling steps
9617 SizeAnchor stateSizeAnchor;
9619 Anchor normalAnchor;
9620 SizeAnchor normalSizeAnchor;
9622 Size skinMinSize; // Minimal window size based on style
9623 Point scrolledPos; // Scrolled position
9624 Box box; // Window box clipped to parent
9625 Box * against; // What to clip the box to
9627 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9628 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9629 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9630 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9631 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9632 Point scrolledArea; // Distance to scroll area by
9633 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9635 OldList hotKeys; // List of the hotkeys of all children
9636 Window defaultControl; // Default child control
9640 ColorAlpha * palette; // Color palette used for this window
9642 int caretSize; // Size of caret, non zero if a caret is present
9643 Point caretPos; // Caret position
9645 void * systemParent; // Parent System Window for embedded windows
9652 WindowState lastState;
9654 FileMonitor fileMonitor;
9656 FontResource setFont, systemFont;
9657 FontResource usedFont;
9658 FontResource captionFont;
9660 FileDialog saveDialog;
9662 SizeAnchor sizeAnchor;
9664 // FormDesigner data
9667 Extent * tempExtents; //[4];
9668 BitmapResource icon;
9670 CreationActivationOption creationActivation;
9673 bool active:1; // true if window and ancestors are active
9674 bool acquiredInput:1; // true if the window is processing state based input
9675 bool modifiedDocument:1;
9676 bool disabled:1; // true if window cannot interact
9677 bool isForegroundWindow:1;// true while a root window is being activated
9678 bool visible:1; // Visibility flag
9679 bool destroyed:1; // true if window is being destroyed
9680 bool anchored:1; // true if this window is repositioned when the parent resizes
9681 bool dirty:1; // Flag set to true if any descendant must be redrawn
9687 bool modifyVirtArea:1;
9688 bool noAutoScrollArea:1;
9691 bool setVisible:1; // FOR FORM DESIGNER
9697 bool useSharedMemory:1;
9700 bool nativeDecorations:1;
9701 bool manageDisplay:1;
9702 bool formDesigner:1; // True if we this is running in the form editor
9703 bool requireRemaximize:1;
9706 // Checks used internally for them not to take effect in FormDesigner
9707 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9708 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9710 WindowController controller;
9711 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9714 public class CommonControl : Window
9716 // creationActivation = doNothing;
9719 public property const String toolTip
9721 property_category $"Appearance"
9724 if(created) CommonControl::OnDestroy();
9726 toolTip = value ? ToolTip { tip = value; } : null;
9728 if(created) CommonControl::OnCreate();
9730 get { return toolTip ? toolTip.tip : null; }
9736 // (Very) Ugly work around for the fact that the parent watcher
9737 // won't fire when it's already been disconnected...
9738 eInstance_FireSelfWatchers(toolTip,
9739 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9745 toolTip.parent = this;
9754 public class Percentage : float
9756 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9760 sprintf(string, "%.2f", this);
9761 c = strlen(string)-1;
9764 if(string[c] != '0')
9765 last = Max(last, c);
9766 if(string[c] == '.')
9779 public void ApplySkin(Class c, const char * name, void ** vTbl)
9781 char className[1024];
9786 subclass(Window) wc = (subclass(Window))c;
9787 subclass(Window) base = (subclass(Window))c.base;
9789 sprintf(className, "%sSkin_%s", name, c.name);
9790 wc.pureVTbl = c._vTbl;
9791 c._vTbl = new void *[c.vTblSize];
9792 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9793 sc = eSystem_FindClass(c.module.application, className);
9797 for(m = 0; m < c.base.vTblSize; m++)
9799 if(c._vTbl[m] == base.pureVTbl[m])
9800 c._vTbl[m] = vTbl[m];
9805 for(m = 0; m < c.vTblSize; m++)
9807 if(sc._vTbl[m] != wc.pureVTbl[m])
9808 c._vTbl[m] = sc._vTbl[m];
9812 for(d = c.derivatives.first; d; d = d.next)
9814 ApplySkin(d.data, name, c._vTbl);
9818 public void UnapplySkin(Class c)
9820 subclass(Window) wc = (subclass(Window))c;
9823 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9826 c._vTbl = wc.pureVTbl;
9830 for(d = c.derivatives.first; d; d = d.next)
9832 UnapplySkin(d.data);
9836 void CheckFontIntegrity(Window window)
9841 if(window.usedFont && window.usedFont.font == 0xecececec)
9843 FontResource uf = window.usedFont;
9844 char * className = window._class.name;
9845 char * text = window.text;
9848 for(c = window.firstChild; c; c = c.next)
9849 CheckFontIntegrity(c);
9853 public class ControllableWindow : Window
9855 /*WindowController controller;
9856 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9857 ~ControllableWindow() { delete controller; }*/
9860 class WindowControllerInterface : ControllableWindow
9862 bool OnKeyDown(Key key, unichar ch)
9864 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9866 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9870 bool OnKeyUp(Key key, unichar ch)
9872 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9874 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9878 bool OnKeyHit(Key key, unichar ch)
9880 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9882 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9886 bool OnMouseMove(int x, int y, Modifiers mods)
9888 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9890 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9894 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9896 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9898 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9902 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9904 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9906 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9910 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9912 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9914 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9918 bool OnRightButtonDown(int x, int y, Modifiers mods)
9920 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9922 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9926 bool OnRightButtonUp(int x, int y, Modifiers mods)
9928 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9930 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9934 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9936 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9938 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9942 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9944 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9946 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9950 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9952 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9954 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9958 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9960 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9962 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9966 void OnResize(int width, int height)
9968 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9969 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9972 void OnRedraw(Surface surface)
9974 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9975 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9980 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9982 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9986 bool OnLoadGraphics()
9988 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9990 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9994 void OnUnloadGraphics()
9996 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9997 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
10001 public class WindowController<class V>
10004 property Window window
10008 uint size = class(Window).vTblSize;
10011 windowVTbl = new void *[size];
10012 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10013 if(value._vTbl == value._class._vTbl)
10015 value._vTbl = new void *[value._class.vTblSize];
10016 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10020 for(c = 0; c < size; c++)
10022 void * function = class(WindowControllerInterface)._vTbl[c];
10023 if(function != DefaultFunction)
10024 value._vTbl[c] = function;
10026 value._vTbl[c] = windowVTbl[c];
10031 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10034 get { return window; }
10036 property V controlled
10038 set { controlled = value; }
10039 get { return controlled; }
10041 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10042 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10043 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10044 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10045 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10046 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10047 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10048 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10049 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10050 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10051 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10052 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10053 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10054 virtual void V::OnResize(WindowController controller, int width, int height);
10055 virtual void V::OnRedraw(WindowController controller, Surface surface);
10056 virtual bool V::OnCreate(WindowController controller);
10057 virtual bool V::OnLoadGraphics(WindowController controller);
10058 virtual void V::OnUnloadGraphics(WindowController controller);
10061 int (** windowVTbl)();
10065 ~WindowController()