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);
1671 normalAnchor = Anchor { left = x, top = y };
1672 normalSizeAnchor = SizeAnchor { { w, h } };
1678 // (w, h): Full window size
1679 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1681 bool result = false;
1682 int oldCW = clientSize.w, oldCH = clientSize.h;
1683 bool clientResized, windowResized, windowMoved;
1685 //bool realResized = size.w != w || size.h != h;
1687 // TOCHECK: This wasn't in ecere.dll
1688 //if(!parent) return true;
1689 if(destroyed) return false;
1691 windowMoved = position.x != x || position.y != y || force;
1693 // windowResized = realResized || force;
1694 windowResized = size.w != w || size.h != h || force;
1696 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1702 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1703 scrolledPos.x - parent.clientStart.x + this.box.right,
1704 scrolledPos.y - parent.clientStart.y + this.box.bottom
1710 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1715 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1717 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1718 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1719 windowResized = true;
1721 if(display && rootWindow != this)
1724 if(guiApp && guiApp.windowMoving)
1726 if(guiApp.windowMoving.style.nonClient)
1727 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1729 guiApp.windowMoving.parent.SetMouseRangeToClient();
1739 // Buttons bitmap resources crash if we do this while switching mode
1740 if(!guiApp || !guiApp.modeSwitching)
1743 // Process Anchored Children
1747 for(child = children.first; child; child = child.next)
1750 ((child.stateAnchor.left.type != offset ||
1751 child.stateAnchor.top.type != offset ||
1752 child.stateAnchor.right.type != none ||
1753 child.stateAnchor.bottom.type != none) ||
1754 child.state == maximized || child.state == minimized))
1756 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1758 // child.Position(x, y, w, h, false, true, true, true, false);
1759 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1760 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1766 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1767 //if(updateScrollBars)
1769 OnResize(clientSize.w, clientSize.h);
1771 if((clientResized || windowMoved) && created)
1772 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1774 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1776 Window master = guiApp.interimWindow.master;
1777 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1780 if(rootWindow == this && !is3D)
1784 x -= guiApp.desktop.absPosition.x;
1785 y -= guiApp.desktop.absPosition.y;
1787 //guiApp.Log("Position %s\n", caption);
1790 if(windowResized || windowMoved)
1791 if(display && !display.flags.memBackBuffer && changeRootWindow)
1792 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1794 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1795 for(child = parent.children.first; child && child != this; child = child.next)
1796 if(child.rootWindow)
1797 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1802 if(windowMoved || windowResized)
1804 display.Lock(true /*false*/);
1807 display.Position(absPosition.x, absPosition.y);
1808 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1811 // result = realResized ? display.Resize(size.w, size.h) : true;
1812 if(nativeDecorations && rootWindow.windowHandle)
1814 int w = clientSize.w, h = clientSize.h;
1815 if(hasMenuBar) h += skinMenuHeight;
1816 if(hasStatusBar) h += statusBarHeight;
1817 if(sbv && sbv.visible) w += sbv.size.w;
1818 if(sbh && sbh.visible) h += sbh.size.h;
1819 result = manageDisplay ? display.Resize(w, h) : true;
1822 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1826 else if(clientResized)
1828 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1831 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1835 if(windowMoved || windowResized)
1840 if(guiApp.driver && changeRootWindow && windowHandle)
1842 if(windowResized || windowMoved)
1843 if(!display || display.flags.memBackBuffer)
1844 guiApp.interfaceDriver.PositionRootWindow(this,
1845 x, y, w, h, windowMoved, windowResized);
1846 guiApp.interfaceDriver.UpdateRootWindow(this);
1848 for(child = children.first; child; child = child.next)
1850 if(child.is3D && child.created)
1852 // Copy Display Content
1853 child.display.displaySystem = display.displaySystem;
1854 child.display.window = display.window;
1855 child.display.current = display.current;
1856 child.display.width = display.width;
1857 child.display.height = display.height;
1858 child.display.driverData = display.driverData;
1859 child.display.mutex = null;
1870 void UpdateScrollBars(bool flag, bool fullThing)
1873 bool resizeH = false, resizeV = false;
1874 bool scrolled = false;
1875 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1876 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1878 if(destroyed) return;
1879 if(guiApp.currentSkin)
1881 MinMaxValue cw = 0, ch = 0;
1882 bool sbvVisible, sbhVisible;
1883 int rangeH = 0, rangeV = 0;
1884 int positionH = 0, positionV;
1886 // First get client area with no respect to scroll bars
1891 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1893 if(scrollFlags.dontHide)
1896 cw -= guiApp.currentSkin.VerticalSBW();
1898 ch -= guiApp.currentSkin.HorizontalSBH();
1900 // Update the scrollbar visibility
1906 sbh.disabled = rangeH <= 1;
1907 if(sbh.style.hidden)
1917 sbv.disabled = rangeV <= 1;
1918 if(sbv.style.hidden)
1926 int oldHRange = sbh ? sbh.range : 0;
1927 int oldVRange = sbv ? sbv.range : 0;
1928 // Then start off with horizontal scrollbar range
1931 positionH = sbh.thumbPosition;
1938 SBSetTotal(sbh, rvw);
1941 ch -= guiApp.currentSkin.HorizontalSBH();
1944 // Do the same for vertical scrollbar
1947 positionV = sbv.thumbPosition;
1953 SBSetTotal(sbv, rvh);
1957 cw -= guiApp.currentSkin.VerticalSBW();
1958 // Maybe we need to set the range on the horizontal scrollbar again
1966 SBSetTotal(sbh, rvw);
1967 //sbh.Action(setRange, positionH, 0);
1968 if(rangeH <= 1 && sbh.range > 1)
1970 ch -= guiApp.currentSkin.HorizontalSBH();
1976 SBSetTotal(sbv, rvh);
1978 //sbv.Action(setRange, positionV, 0);
1983 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1984 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1987 // Update the scrollbar visibility
1988 if(!scrollFlags.dontHide)
1990 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1994 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2001 if(guiApp.currentSkin)
2008 sbhVisible = sbh.style.hidden ? true : false;
2010 sbvVisible = sbv.style.hidden ? true : false;
2012 // Do our resize here
2013 if(flag && (resizeH || resizeV) && fullThing)
2015 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2020 OnResize(clientSize.w, clientSize.h);
2026 sbh.visible = sbhVisible;
2028 sbv.visible = sbvVisible;
2030 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2031 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2034 sbh.pageStep = clientSize.w;
2036 sbv.pageStep = clientSize.h;
2038 // Notify doesn't handle setRange anymore... process it here
2041 int positionH = sbh.thumbPosition;
2042 if(scroll.x != positionH)
2044 OnHScroll(setRange, positionH, 0);
2048 SNAPDOWN(positionH, textCellW);
2049 scroll.x = positionH;
2055 int seen = clientSize.w, total = reqScrollArea.w;
2058 if(scrollFlags.snapX)
2059 SNAPDOWN(seen, sbStep.x);
2061 if(!total) total = seen;
2062 range = total - seen + 1;
2064 range = Max(range, 1);
2066 if(x >= range) x = range - 1;
2068 if(scrollFlags.snapX)
2069 SNAPUP(x, sbStep.x);
2073 OnHScroll(setRange, x, 0);
2078 SNAPDOWN(x, textCellW);
2084 int positionV = sbv.thumbPosition;
2085 if(scroll.y != positionV)
2087 OnVScroll(setRange, positionV, 0);
2091 SNAPDOWN(positionV, textCellH);
2092 scroll.y = positionV;
2098 int seen = clientSize.h, total = reqScrollArea.h;
2101 if(scrollFlags.snapY)
2102 SNAPDOWN(seen, sbStep.y);
2104 if(!total) total = seen;
2105 range = total - seen + 1;
2106 range = Max(range, 1);
2108 if(y >= range) y = range - 1;
2110 if(scrollFlags.snapY)
2111 SNAPUP(y, sbStep.y);
2115 OnVScroll(setRange, y, 0);
2120 SNAPDOWN(y, textCellH);
2126 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2129 for(child = children.first; child; child = child.next)
2131 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2134 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2135 child.Position(x, y, w, h, false, true, false, true, false, false);
2142 // Process Scrollbars
2144 if(sbh) // && !sbh.style.hidden
2147 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2148 // Need to set the range again (should improve...) since the scrollbars didn't have
2149 // the right size when UpdateScrollArea set the range on it
2152 sbh.seen = clientSize.w;
2156 if(sbv) // && !sbv.state.hidden
2159 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2160 // Need to set the range again (should improve...) since the scrollbars didn't have
2161 // the right size when UpdateScrollArea set the range on it
2164 sbv.seen = clientSize.h;
2169 // TESTING THIS LOWER
2170 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2173 for(child = children.first; child; child = child.next)
2175 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2178 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2179 child.Position(x, y, w, h, false, true, false, true, false, false);
2185 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2187 SetState(maximized, false, mods);
2191 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2193 SetState(normal, false, mods);
2197 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2199 SetState(minimized, false, mods);
2200 parent.CycleChildren(false, true, false, true);
2204 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2207 // Scroll bar notifications
2208 if(action != setRange)
2210 bool changed = false;
2214 if(scroll.x != position)
2216 OnHScroll(action, position, keyFlags);
2221 SNAPDOWN(position, textCellW);
2223 scroll.x = position;
2227 if(scroll.y != position)
2229 OnVScroll(action, position, keyFlags);
2234 SNAPDOWN(position, textCellH);
2236 scroll.y = position;
2240 bool childMove = false;
2241 for(child = children.first; child; child = child.next)
2243 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2246 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2247 child.Position(x, y, w, h, false, true, false, true, false, false);
2251 // Testing this patch out to solve MDI workspace redraw bugs
2252 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2253 // Scroll offsets to blame?
2257 UpdateCaret(false, false);
2261 // Testing this patch out to solve MDI workspace redraw bugs
2262 for(child = children.first; child; child = child.next)
2264 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2273 Window GetParentMenuBar()
2275 Window menuBarParent;
2276 if(formDesigner) return null;
2277 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2279 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2280 if(menuBarParent && !menuBarParent.isActiveClient)
2286 void CreateSystemChildren(void)
2288 Window parent = this;
2289 bool scrollBarChanged = false;
2290 bool hasClose = false, hasMaxMin = false;
2291 Point scroll = this.scroll;
2293 if(state == maximized)
2295 parent = GetParentMenuBar();
2302 if(style.hasClose) hasClose = true;
2303 if(style.hasMaximize || style.hasMinimize)
2310 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2312 sysButtons[2].Destroy(0);
2313 sysButtons[2] = null;
2315 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2317 sysButtons[1].Destroy(0);
2318 sysButtons[1] = null;
2320 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2322 sysButtons[0].Destroy(0);
2323 sysButtons[0] = null;
2326 if(hasClose && parent)
2333 parent, master = this,
2334 inactive = true, nonClient = true, visible = false;
2336 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2342 if(this.parent == guiApp.desktop)
2343 sysButtons[2].hotKey = altF4;
2344 else if(style.isActiveClient)
2345 sysButtons[2].hotKey = ctrlF4;
2346 sysButtons[2].Create();
2349 sysButtons[2].symbol = 'X';
2350 sysButtons[2].disabled = !style.hasClose;
2353 if(hasMaxMin && parent)
2357 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2358 if(state == maximized)
2361 method = RestoreButtonClicked;
2367 method = MaximizeButtonClicked;
2375 parent, master = this,
2376 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2378 sysButtons[1].Create();
2380 sysButtons[1].NotifyClicked = method;
2382 sysButtons[1].symbol = symbol;
2383 sysButtons[1].disabled = !style.hasMaximize;
2386 if(hasMaxMin && parent)
2390 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2391 if (state == minimized)
2394 method = RestoreButtonClicked;
2400 method = MinimizeButtonClicked;
2408 parent, master = this,
2409 hotKey = altM, inactive = true, nonClient = true, visible = false
2411 sysButtons[0].Create();
2413 sysButtons[0].NotifyClicked = method;
2415 sysButtons[0].symbol = symbol;
2416 sysButtons[0].disabled = !style.hasMinimize;
2419 // Create the scrollbars
2420 if(style.hasHorzScroll && !sbh)
2426 direction = horizontal,
2430 snap = scrollFlags.snapX,
2431 NotifyScrolling = ScrollBarNotification
2434 scrollBarChanged = true;
2436 else if(sbh && !style.hasHorzScroll)
2442 if(style.hasVertScroll && !sbv)
2448 direction = vertical,
2452 snap = scrollFlags.snapY,
2453 NotifyScrolling = ScrollBarNotification
2456 scrollBarChanged = true;
2458 else if(sbv && !style.hasVertScroll)
2463 if(scrollBarChanged)
2465 SetScrollLineStep(sbStep.x, sbStep.y);
2466 UpdateScrollBars(true, true);
2470 if(scrollBarChanged)
2472 if(sbh) sbh.thumbPosition = scroll.x;
2473 if(sbv) sbv.thumbPosition = scroll.y;
2477 void UpdateCaption(void)
2479 if(rootWindow == this)
2482 FigureCaption(caption);
2483 if(guiApp.interfaceDriver)
2484 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2486 UpdateDecorations();
2489 if(parent.activeClient == this) // Added this last check
2491 if(parent.rootWindow == parent)
2494 parent.FigureCaption(caption);
2495 if(guiApp.interfaceDriver)
2496 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2499 parent.UpdateCaption();
2501 parent.UpdateDecorations();
2505 void UpdateActiveDocument(Window previous)
2507 Window activeClient = this.activeClient;
2508 Window activeChild = this.activeChild;
2515 activeClient.CreateSystemChildren();
2517 previous.CreateSystemChildren();
2529 // Build window list
2532 Menu windowMenu = menu.FindMenu("Window");
2537 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2539 Window document = cycle.data;
2540 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2542 char name[2048], caption[2048];
2543 document.FigureCaption(caption);
2544 sprintf(name, "%d %s", id+1, caption);
2545 windowMenu.AddDynamic(MenuItem
2547 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2548 NotifySelect = MenuWindowSelectWindow
2552 if(activeClient.cycle == cycle) break;
2557 if((!previous && activeClient) || !activeClient)
2563 item = menu.FindItem(MenuWindowCloseAll, 0);
2564 if(item) item.disabled = false;
2565 item = menu.FindItem(MenuWindowNext, 0);
2566 if(item) item.disabled = false;
2567 item = menu.FindItem(MenuWindowPrevious, 0);
2568 if(item) item.disabled = false;
2569 item = menu.FindItem(MenuWindowCascade, 0);
2570 if(item) item.disabled = false;
2571 item = menu.FindItem(MenuWindowTileHorz, 0);
2572 if(item) item.disabled = false;
2573 item = menu.FindItem(MenuWindowTileVert, 0);
2574 if(item) item.disabled = false;
2575 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2576 if(item) item.disabled = false;
2577 item = menu.FindItem(MenuWindowWindows, 0);
2578 if(item) item.disabled = false;
2581 item = menu.FindItem(MenuFileClose, 0);
2582 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2583 item = menu.FindItem(MenuFileSaveAll, 0);
2584 if(item) item.disabled = numDocuments < 1;
2586 if(activeClient && activeClient.menu && activeClient.state != minimized)
2590 //activeClient.menu.Clean(activeClient);
2591 menu.Merge(activeClient.menu, true, activeClient);
2595 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2598 menu.Merge(activeChild.menu, true, activeChild);
2601 // This is called again for a child window change, with same active client
2602 OnActivateClient(activeClient, previous);
2603 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2604 parent.UpdateActiveDocument(null);
2607 void _ShowDecorations(Box box, bool post)
2609 if(rootWindow == this && nativeDecorations && !is3D) return;
2610 if(visible && this != guiApp.desktop)
2612 Surface surface = RedrawFull(box);
2616 FigureCaption(caption);
2619 ShowDecorations(captionFont.font,
2622 active, //parent.activeClient == this
2623 guiApp.windowMoving == this);
2625 PreShowDecorations(captionFont.font,
2628 active, //parent.activeClient == this
2629 guiApp.windowMoving == this);
2636 void UpdateExtent(Box refresh)
2638 Surface surface = null;
2640 if(!manageDisplay) { OnRedraw(null);return; }
2641 _ShowDecorations(refresh, false);
2643 surface = Redraw(refresh);
2644 // Opaque background: just fill before EW_REDRAW (clear?)
2647 surface.SetBackground(background);
2648 surface.SetForeground(foreground);
2649 surface.DrawingChar(' ');
2650 if(this == rootWindow)
2652 if(style.drawBehind || background.a)
2654 int a = background.a;
2655 // Premultiply alpha for clear color
2656 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2657 surface.Clear(colorBuffer);
2658 surface.SetBackground(background);
2661 else if(background.a)
2665 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2666 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2669 if(display.flags.alpha && background.a < 255 && background)
2671 surface.Area(0,0,clientSize.w, clientSize.h);
2672 /*if(style.clearDepthBuffer)
2673 surface.Clear(depthBuffer);*/
2675 else if(/*style.clearDepthBuffer || */background.a)
2677 int a = background.a;
2678 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2679 // Premultiply alpha for clear color
2680 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2681 surface.Clear(colorBuffer);
2682 surface.SetBackground(background);
2687 surface.TextFont(usedFont.font);
2688 surface.TextOpacity(false);
2692 // Draw the caret ...
2693 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2695 // surface.SetBackground(0xFFFFFF - background.color);
2696 surface.SetBackground(~background.color);
2698 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2699 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2705 void DrawOverChildren(Box refresh)
2707 Surface surface = Redraw(refresh);
2711 surface.DrawingChar(' ');
2712 surface.SetBackground(background);
2713 surface.SetForeground(foreground);
2715 surface.TextFont(usedFont.font);
2716 surface.TextOpacity(false);
2718 OnDrawOverChildren(surface);
2723 _ShowDecorations(refresh, true);
2726 void ComputeClipExtents(void)
2729 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2731 clipExtent.Copy(this.clipExtent);
2733 for(child = children.last; child; child = child.prev)
2735 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2737 bool opaque = child.IsOpaque(); // TODO: acess background directly
2738 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2740 child.clipExtent.Copy(clipExtent);
2741 child.clipExtent.Offset(-dx, -dy);
2742 child.clipExtent.IntersectBox(child.box);
2744 child.ComputeClipExtents();
2746 if(opaque && !child.style.nonClient)
2748 // Adjust the box for the parent:
2749 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2750 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2755 // ??? Only do this for overlapped window or if parent has with clip children flag
2757 // Do this if window has clip children flag on (default false?)
2758 // this.clipExtent = clipExtent;
2760 clipExtent.Free(null);
2763 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2766 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2767 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2769 offsetX -= rootWindow.clientStart.x;
2770 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2774 for(child = children.last; child; child = child.prev)
2776 bool opaque = child.IsOpaque();
2777 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2781 // Adjust renderArea to the root window level
2782 Extent * renderArea = &rootWindow.tempExtents[3];
2784 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2785 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2786 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2788 offsetX -= child.rootWindow.clientStart.x;
2789 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2793 Extent childRenderArea;
2795 if(backBufferUpdate != null)
2797 childRenderArea.Copy(backBufferUpdate);
2798 childRenderArea.Offset(-offsetX, -offsetY);
2801 childRenderArea.Copy(child.dirtyArea);
2803 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2804 renderArea.Copy(dirtyExtent);
2805 renderArea.Offset(-offsetX, -offsetY);
2806 childRenderArea.Union(renderArea);
2809 // Intersect with the clip extent
2810 childRenderArea.Intersection(child.clipExtent);
2813 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2815 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2816 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2818 renderArea->Offset(offsetX, offsetY);
2820 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2821 // overDirtyExtent.Union(renderArea);
2822 renderArea->Empty();
2823 // childRenderArea.Free();
2825 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2830 for(child = children.last; child; child = child.prev)
2832 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2834 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2839 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2841 bool opaque = IsOpaque();
2842 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2844 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2845 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2847 offsetX -= rootWindow.clientStart.x;
2848 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2852 for(child = children.last; child; child = child.prev)
2854 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2856 ColorAlpha background = *(ColorAlpha *)&child.background;
2857 bool opaque = child.IsOpaque();
2858 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2862 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2863 // Adjust renderArea to the root window level
2865 renderArea.Copy(child.dirtyArea);
2866 renderArea.Offset(offsetX, offsetY);
2867 dirtyExtent.Union(renderArea);
2868 overDirtyExtent.Union(renderArea);
2874 for(child = children.last; child; child = child.prev)
2876 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2878 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2882 if(backBufferUpdate != null)
2884 renderArea.Copy(backBufferUpdate);
2885 renderArea.Offset(-offsetX, -offsetY);
2887 overRenderArea.Copy(backBufferUpdate);
2888 overRenderArea.Offset(-offsetX, -offsetY);
2894 renderArea.Copy(dirtyArea);
2896 overRenderArea.Copy(dirtyArea);
2899 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2900 dirtyExtentWindow->Copy(dirtyExtent);
2901 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2902 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2903 dirtyExtentWindow->Empty();
2905 // Intersect with the clip extent
2906 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2909 if(renderArea.count > 10)
2912 printf("\nToo many extents (%d):\n", renderArea.count);
2914 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2915 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2920 for(c = 0; c<10; c++)
2923 FASTLIST_LOOP(renderArea, extentBox)
2925 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2927 renderArea.Copy(extent);
2929 FASTLIST_LOOP(renderArea, extentBox)
2932 printf("(%d, %d) - (%d, %d)\n",
2933 extentBox.box.left, extentBox.box.top,
2934 extentBox.box.right, extentBox.box.bottom);
2938 printf("\nNow %d\n", renderArea.count);
2944 // WHY WAS THIS COMMENTED ??
2946 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2947 dirtyExtentWindow->Copy(overDirtyExtent);
2948 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2949 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2950 dirtyExtentWindow->Empty();
2952 // Intersect with the clip extent
2953 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2959 if(scrollExtent.count)
2961 // Subtract render extent from scrolling extent
2962 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2964 if(backBufferUpdate == null)
2966 Extent * dirty = &rootWindow.tempExtents[3];
2969 // Intersect scrolling extent with clip extent
2970 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2972 // offset this scroll to be at the root window level
2973 scrollExtent.Offset(offsetX, offsetY);
2974 // Add area that was scrolled to the dirty extents of the back buffer
2975 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2979 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2980 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2981 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2986 scrollExtent.Empty();
2988 // Add the exposed extent to the window render area
2989 dirty->Offset(-offsetX, -offsetY);
2990 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2995 // Subtract the window's box from the transparency forced extent
2996 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3002 renderArea.Copy(this.renderArea);
3003 renderArea.Offset(offsetX, offsetY);
3004 dirtyExtent.Union(renderArea);
3010 Extent renderArea { };
3012 renderArea.Copy(overRenderArea);
3013 renderArea.Offset(offsetX, offsetY);
3014 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3019 if(backBufferUpdate != null)
3021 // Remove render area from dirty area
3022 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3024 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3031 // Remove the window render area from the dirty extents of the back buffer
3032 rootWindow.dirtyBack.Exclusion(renderArea);
3036 void Render(Extent updateExtent)
3040 Window rootWindow = this.rootWindow;
3041 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3042 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3044 offsetX -= rootWindow.clientStart.x;
3045 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3048 if(rootWindow.fullRender)
3057 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3058 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3063 /*if(renderArea.count)
3064 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3067 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3069 Box box = extentBox.box;
3072 /*printf("(%d, %d) - (%d, %d)\n",
3073 extentBox.box.left, extentBox.box.top,
3074 extentBox.box.right, extentBox.box.bottom);*/
3079 box.left += offsetX;
3081 box.right += offsetX;
3082 box.bottom += offsetY;
3084 if(updateExtent != null)
3085 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3089 for(child = children.first; child; child = child.next)
3090 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3091 child.Render(updateExtent);
3093 if(rootWindow.fullRender)
3094 DrawOverChildren(box);
3097 // TO DO: There's an issue about draw over children...
3098 // TO DO: Don't wanna go through this if method isn't used
3099 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3100 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3102 Box box = extentBox.box;
3104 DrawOverChildren(box);
3106 box.left += offsetX;
3108 box.right += offsetX;
3109 box.bottom += offsetY;
3111 if(updateExtent != null)
3112 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3115 for(child = children.first; child; child = child.next)
3116 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3117 child.Render(updateExtent);
3120 overRenderArea.Empty();
3123 public void UpdateDisplay(void)
3125 if(!manageDisplay) { OnRedraw(null);return; }
3126 if(rootWindow && this != rootWindow)
3127 rootWindow.UpdateDisplay();
3130 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3131 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3134 dirtyExtent.Clear();
3137 clipExtent.AddBox(box);
3139 display.StartUpdate();
3141 if(!rootWindow.fullRender)
3143 ComputeClipExtents();
3144 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3145 ComputeRenderArea(dirtyExtent, overExtent, null);
3148 clipExtent.Free(null);
3150 dirtyExtent.Free(null);
3151 overExtent.Free(null);
3153 if(display.flags.flipping)
3156 display.Update(null);
3160 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3161 updateExtent.Clear();
3163 Render(updateExtent);
3165 updateExtent.UnionBox(this.box, tempExtents[0]);
3168 //printf("\n\nUpdate:\n------------------------------------------\n");
3171 //FASTLIST_LOOP(updateExtent, extentBox)
3172 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3175 /*printf("Updating (%d, %d) - (%d, %d)\n",
3176 extentBox.box.left, extentBox.box.top,
3177 extentBox.box.right, extentBox.box.bottom);*/
3180 display.Update(extentBox.box);
3183 updateExtent.Free(null);
3186 display.EndUpdate();
3194 void UpdateBackDisplay(Box box)
3200 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3202 //printf("UpdateBackDisplay going through!\n");
3203 display.StartUpdate();
3207 intersection.Copy(dirtyBack);
3208 intersection.IntersectBox(box);
3210 dirtyExtent.Clear();
3213 clipExtent.AddBox(box);
3215 if(!rootWindow.fullRender)
3217 ComputeClipExtents();
3218 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3221 clipExtent.Free(null);
3223 intersection.Free(null);
3224 dirtyExtent.Free(null);
3225 overExtent.Free(null);
3230 if(display.flags.flipping)
3231 display.Update(null);
3234 rootWindow.display.Update(box);
3237 display.EndUpdate();
3241 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3242 if(dirtyBack.count > MAX_DIRTY_BACK)
3244 BoxItem extentBox, next;
3245 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3246 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3248 next = (BoxItem)extentBox.next;
3249 if(extentBox != first)
3251 if(extentBox.box.left < first.box.left)
3252 first.box.left = extentBox.box.left;
3253 if(extentBox.box.top < first.box.top)
3254 first.box.top = extentBox.box.top;
3255 if(extentBox.box.right > first.box.right)
3256 first.box.right = extentBox.box.right;
3257 if(extentBox.box.bottom > first.box.bottom)
3258 first.box.bottom = extentBox.box.bottom;
3259 dirtyBack.Delete(extentBox);
3268 // --- Window positioning ---
3269 // --- Window identification ---
3271 // Returns window at position "Position"
3272 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3274 Window child, result = null;
3276 box.left += absPosition.x;
3277 box.right += absPosition.x;
3278 box.top += absPosition.y;
3279 box.bottom += absPosition.y;
3281 if(!destroyed && visible && (acceptDisabled || !disabled))
3283 int lx = x - absPosition.x;
3284 int ly = y - absPosition.y;
3285 if(IsInside(lx, ly))
3286 // if(box.IsPointInside(Point{x, y}))
3288 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3289 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3292 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3293 Window ancestor = null;
3295 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3296 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3298 if(child != statusBar && child.rootWindow == rootWindow)
3300 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3307 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3309 if(child != statusBar && child.rootWindow == rootWindow)
3311 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3318 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3326 Window FindModal(void)
3328 Window modalWindow = this, check;
3329 Window check2 = null;
3330 for(check = this; check.master; check = check.master)
3332 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3334 modalWindow = check.master.modalSlave;
3335 check = modalWindow;
3337 // TESTING THIS FOR DROPBOX...
3338 if(!rootWindow || !rootWindow.style.interim)
3340 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3342 if(check2.modalSlave && check2.modalSlave.created)
3344 modalWindow = check2.modalSlave;
3352 if(modalWindow == this)
3354 for(check = this; check.activeChild; check = check.activeChild)
3356 if(check.modalSlave)
3358 modalWindow = check.modalSlave;
3364 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3365 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3368 void StopMoving(void)
3370 if(this == guiApp.windowMoving)
3372 guiApp.windowMoving = null;
3373 UpdateDecorations();
3374 SetMouseRange(null);
3377 if(rootWindow.active)
3378 guiApp.interfaceDriver.StopMoving(rootWindow);
3380 guiApp.windowCaptured.ReleaseCapture();
3381 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3382 guiApp.windowIsResizing = false;
3386 void SelectMouseCursor(void)
3391 Window cursorWindow = null;
3392 bool rx, ry, rex, rey;
3394 guiApp.desktop.GetMousePosition(&x, &y);
3395 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3397 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3398 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3399 else if(mouseWindow)
3401 modalWindow = mouseWindow.FindModal();
3402 x -= mouseWindow.absPosition.x;
3403 y -= mouseWindow.absPosition.y;
3404 if(guiApp.windowIsResizing)
3406 rex = guiApp.resizeEndX;
3407 rey = guiApp.resizeEndY;
3408 rx = guiApp.resizeX;
3409 ry = guiApp.resizeY;
3410 if((rex && rey) || (rx && ry))
3411 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3412 else if((rex && ry) || (rx && rey))
3413 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3414 else if((ry || rey) && (!rx && !rex))
3415 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3416 else if((rx || rex) && (!ry && !rey))
3417 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3419 else if(!modalWindow && !guiApp.windowCaptured &&
3420 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3421 &rx, &ry, &rex, &rey))
3423 if((rex && rey) || (rx && ry))
3424 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3425 else if((rex && ry) || (rx && rey))
3426 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3427 else if((ry || rey) && (!rx && !rex))
3428 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3429 else if((rx || rex) && (!ry && !rey))
3430 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3432 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3434 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3435 mouseWindow.rootWindow != mouseWindow)
3436 cursorWindow = mouseWindow.parent;
3438 cursorWindow = mouseWindow;
3440 else if(!guiApp.interimWindow)
3441 cursorWindow = guiApp.windowCaptured;
3444 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3445 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3447 else if(modalWindow)
3449 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3451 else if(guiApp.interimWindow)
3453 if(guiApp.interimWindow.cursor)
3454 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3456 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3461 // --- State based input ---
3462 bool AcquireInputEx(bool state)
3467 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3468 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3470 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3472 guiApp.acquiredWindow = state ? this : null;
3475 SetMouseRangeToClient();
3476 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3481 SelectMouseCursor();
3483 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3487 // --- Window activation ---
3488 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3491 if(!parent || !parent.style.inactive)
3493 Window parent = this.parent;
3496 if(rootWindow == this)
3497 Log(active ? "active\n" : "inactive\n");
3499 if(active && requireRemaximize)
3501 if(state == maximized)
3503 property::state = normal;
3504 property::state = maximized;
3506 requireRemaximize = false;
3509 // Testing this here...
3510 if(!parent || parent == guiApp.desktop || parent.active)
3512 this.active = active;
3515 // TESTING THIS HERE
3516 UpdateDecorations();
3517 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3518 result = NotifyActivate(master, this, active, previous);
3521 this.active = !active;
3526 if(!parent || parent == guiApp.desktop || parent.active)
3528 this.active = active;
3530 AcquireInputEx(active);
3531 if(active && isEnabled)
3535 if(guiApp.caretOwner)
3539 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3540 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3541 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3542 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3544 guiApp.caretOwner.Update(extent);
3547 if(visible || !guiApp.caretOwner)
3548 guiApp.caretOwner = this;
3549 UpdateCaret(false, false);
3555 this.active = false;
3557 AcquireInputEx(active);
3559 if(!active && guiApp.caretOwner == this)
3561 UpdateCaret(false, true);
3562 guiApp.caretOwner = null;
3563 guiApp.interfaceDriver.SetCaret(0,0,0);
3564 guiApp.caretEnabled = false;
3569 if(!active && parent && parent.activeChild && parent.activeChild != this)
3570 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3576 if(!active && menuBar)
3579 menuBar.OnActivate(false, null, &goOn, true);
3580 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3585 Window aChild = activeChild;
3587 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3599 void ConsequentialMouseMove(bool kbMoving)
3603 if(kbMoving || !guiApp.windowMoving)
3607 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3609 if(guiApp.interfaceDriver)
3610 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3612 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3613 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3619 bool IsDescendantOf(Window ancestor)
3622 for(window = this; window && window != ancestor; window = window.parent);
3623 return window == ancestor;
3626 bool IsSlaveOf(Window master)
3629 for(window = this; window && window != master; window = window.master);
3630 return window == master;
3633 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3637 if(this && !destroyed /*&& state != Hidden*/)
3639 Window swap = externalSwap;
3647 if(activateParent &&
3648 (parent.activeChild != this ||
3649 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3650 active && _isModal &&
3651 parent != master && master)
3652 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3658 bool real = parent.activeChild != this;
3660 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3661 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3662 !IsDescendantOf(guiApp.interimWindow) &&
3663 !IsSlaveOf(guiApp.interimWindow))
3665 Window interimWindow = guiApp.interimWindow;
3666 while(interimWindow && interimWindow != this)
3668 Window master = interimWindow.master;
3670 guiApp.interimWindow = null;
3671 if(guiApp.caretOwner)
3672 guiApp.caretOwner.UpdateCaret(false, false);
3674 incref interimWindow;
3675 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3680 delete interimWindow;
3681 interimWindow = (master && master.style.interim) ? master : null;
3686 guiApp.interimWindow = this;
3687 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3688 guiApp.caretEnabled = false;*/
3689 UpdateCaret(false, true);
3694 //bool acquireInput = false;
3696 parent.activeChild &&
3697 parent.activeChild.state == maximized &&
3698 parent != guiApp.desktop;
3700 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3705 swap = parent.activeChild;
3706 if(swap && swap.destroyed) swap = null;
3707 if(swap && swap != this)
3710 if(!swap.PropagateActive(false, this, &goOn, true))
3711 swap = parent.activeChild;
3722 if(!parent || parent.activeChild != this || style.interim)
3725 result = PropagateActive(true, swap, &goOn, true);
3726 if(!result && !goOn)
3731 //acquireInput = true;
3735 if(style.hasMaximize && parent != guiApp.desktop)
3738 SetState(maximized, false, 0);
3739 else if(state != maximized)
3742 for(child = parent.children.first; child; child = child.next)
3744 if(this != child && child.state == maximized)
3745 child.SetState(normal, false, 0);
3752 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3754 Window previous = parent.activeClient;
3755 parent.activeChild = this;
3756 if(!style.nonClient /*&& style.isActiveClient*/)
3760 if(style.isActiveClient)
3761 parent.activeClient = this;
3762 // Moved UpdateActiveDocument inside hidden check
3763 // To prevent activating previous window while creating a new one
3764 // (It was messing up the privateModule in the CodeEditor)
3765 parent.UpdateActiveDocument(previous);
3771 //if(!style.isRemote)
3773 if(rootWindow != this)
3775 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3776 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3778 else if(!guiApp.fullScreenMode)
3780 Window modalRoot = FindModal();
3781 if(!modalRoot) modalRoot = this;
3782 if(!modalRoot.isForegroundWindow)
3784 modalRoot.isForegroundWindow = true;
3785 // To check : Why is parent null?
3786 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3788 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3790 modalRoot.isForegroundWindow = false;
3795 if(result && real && (!style.inactive || moveInactive) && parent)
3797 Window last = parent.children.last;
3799 if(!style.stayOnTop)
3800 for(; last && last.style.stayOnTop; last = last.prev);
3802 parent.children.Move(this, last);
3804 // Definitely don't want that: why not?
3808 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3814 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3821 parent.activeChild = null;
3822 if(!style.nonClient /*&& style.isActiveClient*/)
3824 Window previous = parent.activeClient;
3825 if(style.isActiveClient)
3826 parent.activeClient = null;
3827 parent.UpdateActiveDocument(previous);
3831 if(this == guiApp.interimWindow)
3833 guiApp.interimWindow = null;
3834 if(guiApp.caretOwner)
3835 guiApp.caretOwner.UpdateCaret(false, false);
3837 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3844 if(!active || !swap)
3845 UpdateDecorations();
3847 swap.UpdateDecorations();
3849 if(active && rootWindow != this)
3850 ConsequentialMouseMove(false);
3857 // --- Input Messages ---
3858 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3860 static bool reEntrancy = false;
3861 if(reEntrancy) return;
3865 guiApp.cursorUpdate = true;
3866 if(guiApp.windowScrolling && !consequential)
3868 guiApp.windowScrolling.SetScrollPosition(
3869 (guiApp.windowScrolling.sbh) ?
3870 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3871 (guiApp.windowScrolling.sbv) ?
3872 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3874 if(guiApp.windowMoving)
3876 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3878 Window window = guiApp.windowMoving;
3880 int w = window.size.w;
3881 int h = window.size.h;
3886 rx = mouseX - guiApp.windowMovingStart.x;
3887 ry = mouseY - guiApp.windowMovingStart.y;
3890 window.GetDecorationsSize(&ew, &eh);
3892 if(guiApp.windowIsResizing)
3894 x = window.scrolledPos.x;
3895 y = window.scrolledPos.y;
3899 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3900 rx = guiApp.windowResizingBefore.w - aw;
3901 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3902 w = guiApp.windowResizingBefore.w - rx;
3906 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3907 ry = guiApp.windowResizingBefore.h - ah;
3908 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3909 ry = Max(ry, -guiApp.windowMovingBefore.y);
3910 h = guiApp.windowResizingBefore.h - ry;
3912 if(guiApp.resizeEndX)
3914 w = guiApp.windowResizingBefore.w + rx;
3917 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3925 w = Max(w, window.minSize.w);
3926 h = Max(h, window.minSize.h);
3927 w = Min(w, window.maxSize.w);
3928 h = Min(h, window.maxSize.h);
3930 if(!window.OnResizing(&w, &h))
3932 w = window.clientSize.w;
3933 h = window.clientSize.h;
3936 w = Max(w, window.skinMinSize.w);
3937 h = Max(h, window.skinMinSize.h);
3944 SNAPDOWN(w, textCellW);
3945 SNAPDOWN(h, textCellH);
3950 aw = Max(w,window.skinMinSize.w);
3951 rx = guiApp.windowResizingBefore.w - aw;
3952 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3953 w = guiApp.windowResizingBefore.w - rx;
3957 ah = Max(h,window.skinMinSize.h);
3958 ry = guiApp.windowResizingBefore.h - ah;
3959 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3960 ry = Max(ry, -guiApp.windowMovingBefore.y);
3961 h = guiApp.windowResizingBefore.h - ry;
3966 if(!guiApp.windowIsResizing || guiApp.resizeX)
3967 x = guiApp.windowMovingBefore.x + rx;
3968 if(!guiApp.windowIsResizing || guiApp.resizeY)
3969 y = guiApp.windowMovingBefore.y + ry;
3971 if(!guiApp.windowIsResizing)
3974 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3976 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3977 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3978 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3979 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3983 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3984 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3990 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3992 if(!window.OnMoving(&x, &y, w, h))
3994 x = window.scrolledPos.x;
3995 y = window.scrolledPos.y;
4001 SNAPDOWN(x, textCellW);
4002 SNAPDOWN(y, textCellH);
4005 if(!window.style.nonClient)
4007 if(!window.style.fixed /*|| window.style.isDocument*/)
4009 if(!window.style.dontScrollHorz)
4010 x += window.parent.scroll.x;
4011 if(!window.style.dontScrollVert)
4012 y += window.parent.scroll.y;
4016 // Break the anchors for moveable/resizable windows
4017 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4018 if(window.style.fixed)
4020 if(window.state == normal)
4022 window.normalAnchor = Anchor { left = x, top = y };
4023 window.normalSizeAnchor = SizeAnchor { { w, h } };
4024 window.anchored = false;
4028 window.stateAnchor = Anchor { left = x, top = y };
4029 window.stateSizeAnchor = SizeAnchor { { w, h } };
4031 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4032 // TOCHECK: Investigate why the following only redraws the scrollbars
4033 //window.Position(x, y, w, h, false, true, true, true, false, true);
4035 guiApp.movingLast.x = mouseX;
4036 guiApp.movingLast.y = mouseY;
4042 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4045 bool wasMoving = guiApp.windowMoving ? true : false;
4046 bool wasScrolling = guiApp.windowScrolling ? true : false;
4048 while(result && w != this)
4050 Window msgWindow = GetAtPosition(x,y, false, true, w);
4051 Window trueWindow = GetAtPosition(x,y, false, false, w);
4052 bool windowDragged = false;
4057 window = (w && !w.disabled) ? w : null;
4059 if(trueWindow) incref trueWindow;
4061 if(consequential) mods->isSideEffect = true;
4063 UpdateMouseMove(x, y, consequential);
4065 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4067 if(!guiApp.windowCaptured.isEnabled)
4068 guiApp.windowCaptured.ReleaseCapture();
4070 window = guiApp.windowCaptured;
4073 if(trueWindow && activate &&
4074 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4075 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4076 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4077 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4079 if(mods->alt && !mods->ctrl && !mods->shift)
4081 Window moved = trueWindow;
4082 for(moved = trueWindow; moved; moved = moved.parent)
4083 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4088 windowDragged = true;
4090 // Cancel the ALT menu toggling...
4091 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4096 if(window && activate &&
4097 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4098 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4099 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4100 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4102 Window modalWindow = window.FindModal();
4104 /*if(mods->alt && !mods->shift && !mods->ctrl)
4106 Window moved = window;
4107 for(moved = window; moved; moved = moved.parent)
4108 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4113 windowDragged = true;
4115 // Cancel the ALT menu toggling...
4116 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4122 Window activateWindow = modalWindow ? modalWindow : window;
4123 if(activateWindow && !activateWindow.isRemote)
4125 bool doActivation = true;
4126 //bool needToDoActivation = false;
4127 Window check = activateWindow;
4129 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4131 if(!check.style.inactive)
4133 //needToDoActivation = true;
4135 doActivation = false;
4140 if(!needToDoActivation)
4141 doActivation = false;
4144 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4145 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4147 // Let the OnLeftButtonDown do the activating instead
4148 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4156 incref activateWindow;
4157 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4159 delete activateWindow;
4163 if(activateWindow._refCount == 1)
4165 delete activateWindow;
4169 delete activateWindow;
4170 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4173 mods->isActivate = true;
4177 if(!modalWindow && window && !window.destroyed)
4179 if(!guiApp.windowCaptured || windowDragged)
4181 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4183 bool moving = ((window.state != maximized &&
4184 window.IsMouseMoving(
4185 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4186 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4188 if(!moving && window.IsMouseResizing(
4189 x - window.absPosition.x,
4190 y - window.absPosition.y,
4191 window.size.w, window.size.h,
4192 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4194 guiApp.windowIsResizing = true;
4195 guiApp.windowResizingBefore.w = window.size.w;
4196 guiApp.windowResizingBefore.h = window.size.h;
4198 if(guiApp.windowIsResizing || windowDragged || moving)
4201 guiApp.windowMoving = window;
4202 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4203 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4204 guiApp.windowMovingBefore.x = window.position.x;//s;
4205 guiApp.windowMovingBefore.y = window.position.y;//s;
4206 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4207 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4210 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4212 if(window.style.fixed &&
4214 window.IsMouseMoving(
4215 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4217 window.ShowSysMenu(x, y);
4221 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4223 if(window.sbv || window.sbh)
4226 guiApp.windowScrolling = window;
4227 guiApp.windowScrollingStart.x = x;
4228 guiApp.windowScrollingStart.y = y;
4229 guiApp.windowScrollingBefore.x = window.scroll.x;
4230 guiApp.windowScrollingBefore.y = window.scroll.y;
4233 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4235 if(window.style.hasMaximize &&
4236 window.IsMouseMoving(
4237 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4240 (window.state == maximized) ? normal : maximized, false, *mods);
4248 if(guiApp.windowMoving)
4250 if(guiApp.windowMoving.parent)
4252 if(guiApp.windowMoving.style.nonClient)
4253 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4255 guiApp.windowMoving.parent.SetMouseRangeToClient();
4259 window.UpdateDecorations();
4262 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4264 // Log("\n*** LEFT BUTTON UP ***\n");
4265 if(guiApp.windowMoving)
4266 guiApp.windowMoving.StopMoving();
4268 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4270 if(guiApp.windowScrolling)
4272 Window windowScrolling = guiApp.windowScrolling;
4273 guiApp.windowScrolling = null;
4274 windowScrolling.ReleaseCapture();
4278 if(!result || (window && window.destroyed)) window = null;
4280 if(window && window.FindModal())
4283 if(trueWindow && trueWindow.FindModal())
4291 msgWindow = GetAtPosition(x,y, true, false);
4293 msgWindow.SelectMouseCursor();
4296 if(guiApp.windowCaptured || trueWindow)
4298 Window prevWindow = guiApp.prevWindow;
4299 List<Window> overWindows = guiApp.overWindows;
4300 Iterator<Window> it { overWindows };
4305 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4308 result = w.OnMouseLeave(*mods);
4310 overWindows.TakeOut(w);
4314 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4316 guiApp.prevWindow.mouseInside = false;
4317 guiApp.prevWindow = null;
4321 if(trueWindow.IsDescendantOf(prevWindow))
4323 if(!overWindows.Find(prevWindow))
4324 overWindows.Add(prevWindow);
4326 // Eventually fix this not to include captured?
4327 else if(!prevWindow.OnMouseLeave(*mods))
4331 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4333 Box box = trueWindow.box;
4334 box.left += trueWindow.absPosition.x;
4335 box.right += trueWindow.absPosition.x;
4336 box.top += trueWindow.absPosition.y;
4337 box.bottom += trueWindow.absPosition.y;
4339 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4341 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4342 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4344 overX = Max(Min(overX, 32767),-32768);
4345 overY = Max(Min(overY, 32767),-32768);
4347 trueWindow.mouseInside = true;
4348 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4352 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4354 for(w : guiApp.overWindows; w == trueWindow)
4357 guiApp.overWindows.TakeOut(w);
4360 guiApp.prevWindow = trueWindow;
4363 guiApp.prevWindow = null;
4365 SelectMouseCursor();
4367 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4368 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4370 int clientX = x - (window.absPosition.x + window.clientStart.x);
4371 int clientY = y - (window.absPosition.y + window.clientStart.y);
4373 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4375 clientX = Max(Min(clientX, 32767),-32768);
4376 clientY = Max(Min(clientY, 32767),-32768);
4378 MouseMethod = (void *)window._vTbl[method];
4380 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4383 if(!MouseMethod(window, clientX, clientY, *mods))
4387 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4388 window.OnMouseLeave(*mods);
4395 if(result && w && w.clickThrough && w.parent)
4400 if(!result || !w || !w.clickThrough)
4407 // --- Mouse cursor management ---
4409 bool KeyMessage(uint method, Key key, unichar character)
4414 if(guiApp.interimWindow)
4415 this = guiApp.interimWindow;
4418 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4422 if(!style.inactive || rootWindow != this)
4424 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4425 Window modalWindow = FindModal();
4426 Window interimMaster = master ? master.rootWindow : null;
4430 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4431 status = OnSysKeyDown(key, character);
4432 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4433 status = OnSysKeyHit(key, character);
4434 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4435 status = OnSysKeyUp(key, character);
4442 // Process Key Message for Internal UI Keyboard actions
4443 if(status && !destroyed && menuBar && state != minimized)
4446 if((SmartKey)key != alt)
4447 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4450 SmartKey sk = (SmartKey) key;
4451 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4453 status = menuBar.KeyMessage(method, key, character);
4458 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4459 menuBar.OnKeyHit(escape, 0);
4461 if(!menuBar.focus && guiApp.caretOwner)
4462 guiApp.caretOwner.UpdateCaret(true, false);
4465 if(!destroyed && status)
4467 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4471 case left: case up: case right: case down:
4472 if(guiApp.windowMoving == this)
4475 int w = guiApp.windowMoving.size.w;
4476 int h = guiApp.windowMoving.size.h;
4477 int x = guiApp.windowMoving.scrolledPos.x;
4478 int y = guiApp.windowMoving.scrolledPos.y;
4482 if(key == down || key == up)
4483 step = Max(step, textCellH);
4485 step = Max(step, textCellW);
4488 if(guiApp.windowIsResizing)
4492 case left: w-=step; break;
4493 case right: w+=step; break;
4494 case up: h-=step; break;
4495 case down: h+=step; break;
4502 case left: x-=step; break;
4503 case right: x+=step; break;
4504 case up: y-=step; break;
4505 case down: y+=step; break;
4509 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4510 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4512 if(!guiApp.windowIsResizing || guiApp.resizeX)
4513 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4515 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4517 if(!guiApp.windowIsResizing || guiApp.resizeY)
4518 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4520 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4522 guiApp.interfaceDriver.SetMousePosition(x, y);
4523 ConsequentialMouseMove(true);
4531 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4533 guiApp.windowMoving.StopMoving();
4534 ConsequentialMouseMove(false);
4542 ShowSysMenu(absPosition.x, absPosition.y);
4550 if(!destroyed && status && state != minimized)
4552 // Process all the way down the children
4553 if(activeChild && !activeChild.disabled)
4555 status = activeChild.KeyMessage(method, key, character);
4557 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4558 key.code != left && key.code != right && key.code != up && key.code != down)
4560 status = activeClient.KeyMessage(method, key, character);
4564 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4566 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4567 // && defaultControl != activeChild)
4569 delete previousActive;
4570 previousActive = activeChild;
4571 if(previousActive) incref previousActive;
4573 ConsequentialMouseMove(false);
4574 if((defaultControl.active ||
4575 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4576 defaultControl.KeyMessage(method, defaultKey, character);
4582 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4584 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4591 ShowSysMenu(absPosition.x, absPosition.y);
4598 if(this != guiApp.desktop)
4600 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4602 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4604 MenuMoveOrSize(key.shift, true);
4608 else if(guiApp.windowMoving)
4610 guiApp.windowMoving.StopMoving();
4611 ConsequentialMouseMove(false);
4619 if(!destroyed && status && state != minimized)
4621 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4625 case tab: case shiftTab:
4627 Window cycleParent = this;
4628 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4629 cycleParent = master.parent;
4631 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4633 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4636 Window child = cycleParent.activeChild;
4638 // Scroll the window to include the active control
4639 if(cycleParent.sbh && !child.style.dontScrollHorz)
4641 if(child.scrolledPos.x < 0)
4642 cycleParent.sbh.Action(Position,
4643 cycleParent.scroll.x + child.scrolledPos.x, 0);
4644 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4645 cycleParent.sbh.Action(Position,
4646 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4648 if(cycleParent.sbv && !child.style.dontScrollVert)
4650 if(child.scrolledPos.y < 0)
4651 cycleParent.sbv.Action(Position,
4652 cycleParent.scroll.y + child.scrolledPos.y, 0);
4653 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4654 cycleParent.sbv.Action(Position,
4655 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4658 cycleParent.ConsequentialMouseMove(false);
4664 case f6: case shiftF6:
4665 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4667 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4668 if(parent == guiApp.desktop)
4669 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4679 if(CycleChildren(key.shift, true, false, true))
4687 // mIRC Style Window Shortcuts
4688 case alt1: case alt2: case alt3: case alt4: case alt5:
4689 case alt6: case alt7: case alt8: case alt9: case alt0:
4694 for(document = children.first; document; document = document.next)
4696 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4698 if(document == activeChild)
4700 if(document.state == minimized)
4701 document.SetState(normal, false, key);
4704 document.SetState(minimized, false, key);
4705 CycleChildren(false, true, false);
4710 if(activeChild.state == maximized && document.style.hasMaximize)
4711 document.SetState(maximized, false, key);
4712 else if(document.state == minimized)
4713 document.SetState(normal, false, key);
4714 document.Activate();
4729 if(!destroyed && status)
4731 if(state == minimized)
4736 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4738 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4740 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4741 previousActive.ActivateEx(true, false, false, true, null, null);
4742 delete previousActive;
4748 if(!destroyed && status)
4750 status = ProcessHotKeys(method, key, character);
4752 if(!destroyed && status && !modalWindow && state != minimized)
4755 status = KeyMethod(this, key, character);
4756 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4757 status = OnKeyHit(key, character);
4758 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4760 bool result = false;
4763 case ctrlUp: case ctrlDown:
4764 if(sbv && !guiApp.windowScrolling)
4765 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4767 case wheelUp: case wheelDown:
4768 if(sbv && !guiApp.windowScrolling)
4770 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4771 // Do we want to do a consequential move regardless of result in this case?
4772 ConsequentialMouseMove(false);
4775 case ctrlPageUp: case ctrlPageDown:
4776 if(sbh && !guiApp.windowScrolling)
4777 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4782 ConsequentialMouseMove(false);
4787 if(status && !destroyed && menuBar && state != minimized)
4788 status = menuBar.KeyMessage(method, key, character);
4790 if(style.interim && /*destroyed && */status && interimMaster)
4792 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4793 status = interimMaster.KeyMessage(method, key, character);
4800 bool ProcessHotKeys(uint method, Key key, unichar character)
4805 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4806 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4807 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4809 Window hotKeyWindow = hotKey.window;
4810 Window parent = hotKeyWindow.parent;
4811 Window prevActiveWindow = activeChild;
4812 // For when sys buttons are placed inside the menu bar
4813 if(parent && parent._class == class(PopupMenu))
4814 parent = parent.parent;
4816 // 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
4817 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4820 if(prevActiveWindow) incref prevActiveWindow;
4821 incref hotKeyWindow;
4822 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4823 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4826 delete hotKeyWindow;
4827 delete prevActiveWindow;
4831 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4832 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4833 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4835 // ********* WORKING ON THIS ***********
4836 if(prevActiveWindow && !guiApp.interimWindow)
4837 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4840 else if(hotKeyWindow.style.inactive)
4841 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4843 delete prevActiveWindow;
4844 delete hotKeyWindow;
4845 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4846 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4850 if(status && tabCycle)
4853 for(child = children.first; child; child = child.next)
4855 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4866 // --- Windows and graphics initialization / termination ---
4867 bool SetupRoot(void)
4871 // Setup relationship with outside world (bb root || !bb)
4872 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4873 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4877 tempExtents = new0 Extent[4];
4882 /*if(guiApp.fullScreenMode)
4883 rootWindow = guiApp.desktop;
4885 //rootWindow = parent.created ? parent.rootWindow : null;
4886 rootWindow = parent.rootWindow;
4889 against = &parent.box;
4891 against = &parent.clientArea;
4894 for(child = children.first; child; child = child.next)
4897 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4900 bool Setup(bool positionChildren)
4902 bool result = false;
4905 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4907 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4908 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4911 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4913 // This was here, is it really needed?
4914 //guiApp.interfaceDriver.ActivateRootWindow(this);
4918 displaySystem = DisplaySystem {};
4919 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4921 delete displaySystem;
4926 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4927 if(display.Create(displaySystem, windowHandle))
4934 // Sometimes icon does not show up on Windows XP if we set here...
4935 // guiApp.interfaceDriver.SetIcon(this, icon);
4937 else if(this != guiApp.desktop)
4939 display = rootWindow ? rootWindow.display : null;
4945 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4946 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4948 for(child = children.first; child; child = child.next)
4950 if(child.created && !child.Setup(false))
4953 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4954 child.UpdateCaption();
4959 bool SetupDisplay(void)
4961 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4962 if(is3D) return Window3D_SetupDisplay(this); else
4969 class_data void ** pureVTbl;
4971 bool LoadGraphics(bool creation, bool resetAnchors)
4973 bool result = false;
4974 bool success = false;
4976 WindowState stateBackup = state;
4978 if(((subclass(Window))_class).pureVTbl)
4980 if(_vTbl == _class._vTbl)
4982 _vTbl = ((subclass(Window))_class).pureVTbl;
4987 for(m = 0; m < _class.vTblSize; m++)
4989 if(_vTbl[m] == _class._vTbl[m])
4990 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4994 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4996 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4998 _vTbl = _class._vTbl;
5003 for(m = 0; m < _class.vTblSize; m++)
5005 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5006 _vTbl[m] = _class._vTbl[m];
5011 if(guiApp.fullScreenMode || this != guiApp.desktop)
5013 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5019 display.Lock(false);
5020 if(rootWindow == this)
5022 // Set Color Palette
5023 display.SetPalette(palette, true);
5027 if(guiApp.fullScreenMode && this == guiApp.desktop)
5032 for(c=0; c<SystemCursor::enumSize; c++)
5033 if(!guiApp.systemCursors[c].bitmap)
5035 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5036 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5037 if(guiApp.systemCursors[c].bitmapName)
5039 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5040 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5041 if(guiApp.systemCursors[c].bitmap)
5042 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5047 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5049 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5050 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5052 cursor.bitmap.paletteShades = cursor.paletteShades;
5056 guiApp.cursorUpdate = true;
5059 ConsequentialMouseMove(false);
5065 // Load Window Graphic Resources
5068 if(usedFont == setFont || usedFont == window.systemFont)
5069 RemoveResource(usedFont);
5072 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5075 RemoveResource(systemFont);
5078 RemoveResource(captionFont);
5080 for(ptr = resources.first; ptr; ptr = ptr.next)
5082 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5083 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5086 AddResource(setFont);
5088 AddResource(systemFont);
5090 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5097 //if(master && master.font)
5098 if(parent && parent.font)
5102 faceName = parent.font.faceName,
5103 size = parent.font.size,
5104 bold = parent.font.bold,
5105 italic = parent.font.italic,
5106 underline = parent.font.underline
5108 //font = parent.font;
5109 watch(parent) { font { } };
5112 font = guiApp.currentSkin.SystemFont();
5119 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5120 AddResource(captionFont);
5122 if(OnLoadGraphics())
5128 //SetScrollLineStep(sbStep.x, sbStep.y);
5130 if(this != guiApp.desktop)
5134 normalAnchor = anchor;
5135 normalSizeAnchor = sizeAnchor;
5138 // Break the anchors for moveable/resizable windows
5140 if(style.fixed && style.isDocument)
5142 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5154 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5155 stateSizeAnchor = SizeAnchor {};
5160 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5165 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5166 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5169 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5173 stateAnchor = normalAnchor;
5174 stateSizeAnchor = normalSizeAnchor;
5177 position = Point { };
5178 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5189 if(Position(x, y, w, h, true, false, true, true, true, true))
5191 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5194 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5211 success = result = true;
5214 if(!creation && result)
5216 // Load menu bar first because sys buttons are on it...
5219 if(!menuBar.LoadGraphics(false, resetAnchors))
5225 for(child = children.first; child; child = child.next)
5227 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5234 CreateSystemChildren();
5238 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5241 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5244 LogErrorCode(graphicsLoadingFailed, _class.name);
5246 // Do this here to avoid problems on Windows
5247 if(rootWindow == this && parent && stateBackup == maximized)
5248 property::state = maximized;
5252 void UnloadGraphics(bool destroyWindows)
5256 // Free children's graphics
5257 for(child = children.first; child; child = child.next)
5258 child.UnloadGraphics(destroyWindows);
5261 display.Lock(false);
5264 if(guiApp.fullScreenMode && this == guiApp.desktop)
5269 for(c=0; c<SystemCursor::enumSize; c++)
5270 if(guiApp.systemCursors[c].bitmap)
5271 delete guiApp.systemCursors[c].bitmap;
5273 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5274 delete cursor.bitmap;
5276 guiApp.cursorBackground.Free();
5279 if(display && display.displaySystem)
5283 for(ptr = resources.first; ptr; ptr = ptr.next)
5287 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5292 // Free window graphics
5295 // Free skin graphics
5296 if(rootWindow == this)
5298 DisplaySystem displaySystem = display.displaySystem;
5301 display.driverData = null;
5302 display.displaySystem = null;
5306 if(displaySystem && !displaySystem.numDisplays && !is3D)
5307 delete displaySystem;
5316 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5317 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5319 if(this == guiApp.desktop || parent == guiApp.desktop)
5321 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5322 guiApp.interfaceDriver.DestroyRootWindow(this);
5326 // --- Window Hiding ---
5328 void SetVisibility(bool state)
5330 bool visible = (style.hidden || !created) ? false : state;
5331 if(visible != this.visible)
5335 this.visible = visible;
5336 for(child = children.first; child; child = child.next)
5337 child.SetVisibility(visible);
5339 ConsequentialMouseMove(false);
5340 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5344 // --- Windows and graphics initialization / termination ---
5346 bool DisplayModeChanged(void)
5348 bool result = false;
5349 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5351 guiApp.modeSwitching = true;
5352 UnloadGraphics(false);
5354 if(LoadGraphics(false, false))
5356 guiApp.modeSwitching = false;
5361 // --- Window updates system ---
5363 void UpdateDirty(Box updateBox)
5365 if(!manageDisplay) { OnRedraw(null);return; }
5368 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5371 if(display.flags.flipping)
5374 rootWindow.UpdateDisplay();
5377 UpdateBackDisplay(updateBox);
5379 if(guiApp.fullScreenMode)
5381 guiApp.cursorUpdate = true;
5382 guiApp.PreserveAndDrawCursor();
5384 if(guiApp.fullScreenMode)
5385 guiApp.RestoreCursorBackground();
5391 // This function is strictly called as a result of system window activation
5392 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5395 Window interimMaster = null;
5396 Window interimWindow = guiApp.interimWindow;
5397 if(interimWindow && interimWindow.master)
5398 interimMaster = interimWindow.master.rootWindow;
5400 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5401 // SetState(normal, false, 0);
5402 SetState(lastState, false, 0);
5404 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5408 /* WTH is this doing here?
5409 while(swap && swap.activeChild)
5411 swap = swap.activeChild;
5414 // TESTING THIS BEFORE...
5415 if(interimWindow && this == interimMaster)
5419 // Window interimSwap = this;
5420 Window menuBar = this.menuBar;
5421 if(menuBar && interimWindow.master == menuBar)
5424 while(interimSwap && interimSwap.activeChild)
5425 interimSwap = interimSwap.activeChild;
5427 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5428 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5430 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5431 //result = ActivateEx(true, true, false, activateRoot, window, null);
5436 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5437 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5439 if(interimWindow == this && interimMaster && !active)
5441 while(interimMaster && interimMaster.interim && interimMaster.master)
5443 // printf("Going up one master %s\n", interimMaster._class.name);
5444 interimMaster = interimMaster.master.rootWindow;
5446 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5447 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5453 bool DestroyEx(int64 returnCode)
5456 Timer timer, nextTimer;
5458 OldLink prevOrder = null;
5459 Window client = null;
5461 if(parent) stopwatching(parent, font);
5463 // if(window.modalSlave) return false;
5464 if(destroyed || !created)
5471 OldLink slave = master.slaves.FindLink(this);
5472 master.slaves.Delete(slave);
5475 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5481 this.returnCode = (DialogResult)returnCode;
5483 AcquireInput(false);
5488 master.hotKeys.Delete(hotKey);
5492 if(guiApp.prevWindow == this)
5494 guiApp.prevWindow = null;
5499 for(w : guiApp.overWindows; w == this)
5502 guiApp.overWindows.TakeOut(w);
5506 if(guiApp.caretOwner == this)
5508 guiApp.interfaceDriver.SetCaret(0,0,0);
5509 UpdateCaret(false, true);
5510 guiApp.caretEnabled = false;
5515 parent.childrenCycle.Remove(cycle);
5519 OldLink tmpPrev = order.prev;
5520 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5521 prevOrder = tmpPrev;
5524 client = tmpPrev ? tmpPrev.data : null;
5525 if(client == this) { client = null; break; }
5526 if(client && (client.style.hidden || client.destroyed || !client.created))
5527 tmpPrev = client.order.prev;
5531 prevOrder = tmpPrev;
5536 // If this window can be an active client, make sure the next window we activate can also be one
5537 if(!style.nonClient && style.isActiveClient)
5539 tmpPrev = prevOrder;
5542 client = tmpPrev ? tmpPrev.data : null;
5543 if(client == this) { client = null; break; }
5544 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5545 tmpPrev = client.order.prev;
5549 prevOrder = tmpPrev;
5553 if(client && client.style.hidden) client = null;
5555 // parent.childrenOrder.Remove(order);
5558 if(parent && style.isActiveClient && visible)
5560 if(state == minimized) parent.numIcons--;
5561 parent.numPositions--;
5564 // TESTING THIS HERE!
5568 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5569 // to create a window inside a rootwindow that's being destroyed)
5570 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5572 if(master && !master.destroyed /*&&
5573 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5575 if(master.defaultControl == this)
5576 master.defaultControl = null;
5579 parent.OnChildAddedOrRemoved(this, true);
5580 if(parent && !parent.destroyed /*&&
5581 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5583 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5585 if(order && prevOrder && prevOrder.data != this && active)
5587 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5589 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5590 if(parent.activeClient == this)
5592 parent.activeClient = null;
5593 parent.UpdateActiveDocument(null);
5598 if(guiApp.interimWindow == this)
5601 PropagateActive(false, null, &goOn, true);
5605 //if(window.parent.activeChild == window)
5606 parent.activeChild = null;
5607 if(!style.nonClient /*&& style.isActiveClient*/)
5609 Window previous = parent.activeClient;
5610 if(style.isActiveClient)
5611 parent.activeClient = null;
5612 parent.UpdateActiveDocument(previous);
5617 else if(parent.activeClient == this)
5619 parent.activeClient = client;
5620 parent.UpdateActiveDocument(this);
5624 if(guiApp.interimWindow == this)
5626 guiApp.interimWindow = null;
5627 if(guiApp.caretOwner)
5629 Window desktop = guiApp.desktop;
5630 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5631 guiApp.caretOwner.UpdateCaret(false, false);
5636 if(_isModal && master && master.modalSlave == this)
5637 master.modalSlave = null;
5641 if(!guiApp.caretOwner && parent.caretSize)
5643 guiApp.caretOwner = parent;
5644 parent.UpdateCaret(false, false);
5645 parent.Update(null);
5648 // Why was this commented out?
5649 GetRidOfVirtualArea();
5655 dirtyArea.Free(null);
5656 dirtyBack.Free(null);
5657 scrollExtent.Free(null);
5659 /* ATTEMPTING TO MOVE THAT ABOVE
5668 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5669 for(;(child = window.children.first);)
5671 for(; child && (child.destroyed || !child.created); child = child.next);
5680 UnloadGraphics(true);
5683 delete previousActive;
5686 // statusBar = null;
5689 if(master && !master.destroyed)
5691 //master.NotifyDestroyed(this, this.returnCode);
5692 NotifyDestroyed(master, this, this.returnCode);
5695 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5697 nextTimer = timer.next;
5698 if(timer.window == this)
5700 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5701 // timer.window = null;
5707 if(this == guiApp.windowMoving)
5710 if(guiApp.windowCaptured == this)
5712 //guiApp.windowCaptured = null;
5714 if(rootWindow != this && rootWindow)
5715 rootWindow.ConsequentialMouseMove(false);
5723 //for(child = children.first; next = child ? child.next : null, child; child = next)
5724 for(;(child = children.first); )
5726 for(; child && (child.destroyed || !child.created); child = child.next);
5736 /* // MOVED THIS UP...
5739 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5740 for(;(child = window.children.first); )
5742 for(; child && (child.destroyed || !child.created); child = child.next);
5751 while((slave = slaves.first))
5753 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5755 ((Window)slave.data).DestroyEx(0);
5760 if(guiApp.caretOwner == this)
5761 guiApp.caretOwner = null;
5763 sysButtons[0] = null;
5764 sysButtons[1] = null;
5765 sysButtons[2] = null;
5768 if(rootWindow != this)
5770 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5773 box.left -= parent.clientStart.x;
5774 box.top -= parent.clientStart.y;
5775 box.right -= parent.clientStart.x;
5776 box.bottom -= parent.clientStart.y;
5778 if(parent) parent.Update(box);
5783 OldLink slave = master.slaves.FindVoid(this);
5784 master.slaves.Delete(slave);
5790 parent.children.Remove(this);
5795 //autoCreate = false;
5798 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5799 if(((subclass(Window))_class).pureVTbl)
5801 if(_vTbl == _class._vTbl)
5803 _vTbl = ((subclass(Window))_class).pureVTbl;
5808 for(m = 0; m < _class.vTblSize; m++)
5810 if(_vTbl[m] == _class._vTbl[m])
5811 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5820 void SetStateEx(WindowState newState, bool activate)
5823 WindowState prevState = state;
5827 if(prevState != newState)
5828 lastState = prevState;
5830 if(rootWindow != this || !nativeDecorations || !windowHandle)
5832 if(style.isActiveClient && !style.hidden && prevState == minimized)
5835 // This block used to be at the end of the function... moved it for flicker problem in X
5836 // ------------------------------------------------------
5840 stateAnchor = normalAnchor;
5841 stateSizeAnchor = normalSizeAnchor;
5844 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5845 stateSizeAnchor = SizeAnchor {};
5849 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5852 byte * idBuffer = new0 byte[size];
5854 for(child = parent.children.first; child; child = child.next)
5856 if(child != this && child.state == minimized)
5858 if(child.iconID > size - 2)
5860 idBuffer = renew0 idBuffer byte[size*2];
5861 memset(idBuffer + size, 0, size);
5864 idBuffer[child.iconID] = (byte)bool::true;
5867 for(c = 0; c<size; c++)
5872 if(style.isActiveClient && !style.hidden)
5875 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5876 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5880 // TOCHECK: Why was this here?
5881 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5882 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5883 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5885 Position(x, y, w, h, true, true, true, true, false, true);
5887 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5888 parent.UpdateActiveDocument(null);
5891 CreateSystemChildren();
5892 // ------------------------------------------------------
5895 int GetPositionID(Window forChild)
5899 byte * idBuffer = new0 byte[size];
5902 for(child = children.first; child; child = child.next)
5904 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5906 if(child.positionID > size - 2)
5908 idBuffer = renew0 idBuffer byte[size*2];
5909 memset(idBuffer + size, 0, size);
5912 idBuffer[child.positionID] = (byte)bool::true;
5915 for(c = 0; c<size; c++)
5922 // --- Window related graphics ---
5924 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5926 palette = newPalette;
5927 if(rootWindow.display)
5928 rootWindow.display.SetPalette(palette, colorMatch);
5931 public bool AcquireInput(bool acquired)
5934 if(acquiredInput != acquired)
5936 if(active || (!visible && creationActivation == activate))
5937 result = AcquireInputEx(acquired);
5942 acquiredInput = acquired ? result : !result;
5947 void ListChildren(ListBox listBox)
5951 for(child = children.first; child; child = child.next)
5953 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5955 DataRow row = listBox.AddRow();
5956 row.tag = (int64)(intptr)child;
5957 child.FigureCaption(caption);
5958 row.SetData(null, caption);
5963 void UpdateVisual(Box extent)
5965 if(guiApp.driver != null)
5967 if(guiApp.fullScreenMode && guiApp.desktop.display)
5969 guiApp.desktop.mutex.Wait();
5970 guiApp.desktop.display.Lock(true);
5973 if(guiApp.desktop.active)
5975 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5977 if(guiApp.desktop.display.flags.flipping)
5978 guiApp.desktop.Update(null);
5979 guiApp.desktop.UpdateDisplay();
5980 guiApp.cursorUpdate = true;
5982 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5984 guiApp.PreserveAndDrawCursor();
5985 // guiApp.desktop.display.ShowScreen();
5986 guiApp.cursorUpdate = false;
5987 guiApp.desktop.dirty = false;
5988 guiApp.RestoreCursorBackground();
5992 guiApp.desktop.display.Unlock();
5993 guiApp.desktop.mutex.Release();
5997 Window rootWindow = this.rootWindow;
5998 rootWindow.mutex.Wait();
6003 guiApp.SignalEvent();
6006 guiApp.waitMutex.Wait();
6007 guiApp.interfaceDriver.Lock(rootWindow);
6008 if(!rootWindow.style.hidden && rootWindow.dirty)
6010 if(rootWindow.display)
6012 rootWindow.UpdateDisplay();
6013 //rootWindow.display.ShowScreen(null);
6015 rootWindow.dirty = false;
6017 guiApp.interfaceDriver.Unlock(rootWindow);
6018 guiApp.waitMutex.Release();
6021 rootWindow.mutex.Release();
6026 void UnlockDisplay(void)
6028 guiApp.interfaceDriver.Unlock(rootWindow);
6031 void LockDisplay(void)
6033 guiApp.interfaceDriver.Lock(rootWindow);
6036 Surface GetSurface(Box box)
6038 return Redraw((box == null) ? this.box : box);
6041 void SetMousePosition(int x, int y)
6043 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6047 void IntegrationActivate(bool active)
6049 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6051 isForegroundWindow = true;
6052 ActivateEx(active, active, false, false, null, null);
6053 isForegroundWindow = false;
6058 Window QueryCapture(void)
6060 return guiApp.windowCaptured;
6063 int GetDocumentID(void)
6067 byte * idBuffer = new0 byte[size];
6070 for(child = children.first; child; child = child.next)
6072 // TO CHECK: Do we want a documentID when we already have a file name?
6073 if(child.style.isDocument && !child.fileName)
6075 if(child.documentID-1 > size - 2)
6077 idBuffer = renew0 idBuffer byte[size*2];
6078 memset(idBuffer + size, 0, size);
6081 idBuffer[child.documentID-1] = 1;
6084 for(c = 0; c<size; c++)
6092 void SetInitSize(Size size)
6095 sizeAnchor.size = size;
6096 normalSizeAnchor = sizeAnchor;
6098 // Break the anchors for moveable/resizable windows
6099 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6101 stateAnchor = normalAnchor;
6102 stateSizeAnchor = normalSizeAnchor;
6104 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6105 Position(x,y, w, h, true, true, true, true, false, true);
6109 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6111 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6113 guiApp.windowIsResizing = resize;
6114 guiApp.windowMoving = this;
6115 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6116 if(guiApp.windowIsResizing)
6118 guiApp.windowMovingStart.x += size.w - 1;
6119 guiApp.windowMovingStart.y += size.h - 1;
6121 guiApp.windowMovingBefore = scrolledPos;
6122 guiApp.windowResizingBefore = size;
6123 guiApp.windowMoving.UpdateDecorations();
6124 if(guiApp.windowIsResizing)
6125 guiApp.resizeEndX = guiApp.resizeEndY = true;
6127 if(setCursorPosition)
6128 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6132 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6133 guiApp.windowMovingStart.x += x - absPosition.x;
6134 guiApp.windowMovingStart.y += y - absPosition.y;
6137 if(guiApp.windowMoving)
6139 if(guiApp.windowMoving.style.nonClient)
6140 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6142 guiApp.windowMoving.parent.SetMouseRangeToClient();
6147 if(this == rootWindow)
6148 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6152 void SetupFileMonitor()
6156 fileMonitor = FileMonitor
6158 this, FileChange { modified = true };
6160 bool OnFileNotify(FileChange action, const char * param)
6163 fileMonitor.StopMonitoring();
6164 if(OnFileModified(action, param))
6165 fileMonitor.StartMonitoring();
6178 bool result = false;
6182 else if(guiApp && guiApp.driver != null)
6184 OldLink slaveHolder;
6186 bool visible = !style.hidden;
6190 systemParent = parent;
6191 parent = guiApp.desktop;
6193 last = parent ? parent.children.last : null;
6195 if((parent && parent != guiApp.desktop && !parent.created) ||
6196 (master && master != guiApp.desktop && !master.created))
6200 stopwatching(parent, font);
6203 property::parent = guiApp.desktop;
6204 if(!master) master = parent;
6206 if(_isModal && master.modalSlave)
6207 property::master = master.modalSlave;
6211 parent.children.Remove(this);
6214 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6215 if(slaveHolder.data == this)
6217 master.slaves.Delete(slaveHolder);
6222 if(parent == guiApp.desktop && !mutex)
6225 if(style.isDocument)
6228 parent.numDocuments--;
6229 documentID = parent.GetDocumentID();
6232 if(!style.stayOnTop)
6233 for(; last && last.style.stayOnTop; last = last.prev);
6235 parent.children.Insert((last == this) ? null : last, this);
6236 //parent.children.Add(this);
6239 dispDriver = parent.dispDriver;
6242 master.modalSlave = this;
6244 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6249 master.slaves.Add(slaveHolder = OldLink { data = this });
6254 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6256 if(style.isDefault && !master.defaultControl)
6257 master.defaultControl = this;
6259 stateAnchor = normalAnchor = anchor;
6260 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6262 // TOCHECK: Why is this here?
6263 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6264 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6266 this.visible = false;
6267 style.hidden = true;
6270 // autoCreate = true;
6278 if(parent == guiApp.desktop)
6279 Log("LoadGraphics %s\n", caption);
6281 if(LoadGraphics(true, false))
6289 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6296 if(style.hasMenuBar /*&& menu*/)
6302 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6303 interim = false, inactive = true, nonClient = true, size.h = 24
6311 // Create the system buttons
6312 CreateSystemChildren();
6314 UpdateActiveDocument(null);
6316 if(style.isDocument)
6320 MenuItem item = menu.FindItem(MenuFileSave, 0);
6321 if(item) item.disabled = !modifiedDocument && fileName;
6326 if(parent == guiApp.desktop)
6327 Log("Preemptive SetState %s\n", caption);
6330 // Preemptive Set State to ensure proper anchoring
6331 SetStateEx(state, false);
6333 style.hidden = true;
6339 for(child = children.first; child; child = next)
6342 if(!child.created && (child.autoCreate || child.wasCreated))
6349 for(link = slaves.first; link; link = next)
6351 Window slave = link.data;
6353 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6356 // Things might have happened that invalidated 'next'...
6357 // Start over the search for slaves to create.
6358 // (Added this to fix crash with Stacker & Toolbar)
6359 next = slaves.first;
6368 if(parent == guiApp.desktop)
6369 Log("Real SetState %s\n", caption);
6372 if(isActiveClient && visible)
6374 parent.numPositions--;
6375 if(state == minimized) parent.numIcons--;
6378 parent.OnChildAddedOrRemoved(this, false);
6380 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6382 // Real set state & activate for proper display & activation
6383 property::visible = visible;
6384 // SetState(state & 0x00000003, true, 0);
6385 guiApp.interfaceDriver.SetIcon(this, icon);
6390 /*if(rootWindow == this)
6391 guiApp.interfaceDriver.ActivateRootWindow(this);
6393 if(creationActivation == activate && guiApp.desktop.active)
6394 ActivateEx(true, false, true, true, null, null);
6395 else if(creationActivation == activate || creationActivation == flash)
6398 if(this == rootWindow)
6404 rootWindow.ConsequentialMouseMove(false);
6415 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6421 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6423 //style.hidden = true; // !visible;
6424 style.hidden = !visible;
6425 if(master.modalSlave == this)
6426 master.modalSlave = null;
6433 void WriteCaption(Surface surface, int x, int y)
6436 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6439 void Update(Box region)
6445 rootWindow = this.rootWindow;
6447 // rootWindow.mutex.Wait();
6448 if(!destroyed && visible && display)
6453 // Testing this to avoid repetitve full update to take time...
6454 if(rootWindow.fullRender)
6456 rootWindow.dirty = true;
6459 if(dirtyArea.count == 1)
6461 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6462 if(item.box.left <= box.left &&
6463 item.box.top <= box.top &&
6464 item.box.right >= box.right &&
6465 item.box.bottom >= box.bottom)
6467 rootWindow.dirty = true;
6472 if(display.flags.flipping && !rootWindow.dirty)
6474 if(this == rootWindow)
6478 rootWindow.Update(null);
6483 rootWindow.dirty = true;
6488 realBox.left += clientStart.x;
6489 realBox.top += clientStart.y;
6490 realBox.right += clientStart.x;
6491 realBox.bottom += clientStart.y;
6497 if(realBox.right >= realBox.left &&
6498 realBox.bottom >= realBox.top)
6500 // if(!rootWindow.fullRender)
6501 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6503 for(child = children.first; child; child = child.next)
6508 box.left -= child.absPosition.x - absPosition.x;
6509 box.top -= child.absPosition.y - absPosition.y;
6510 box.right -= child.absPosition.x - absPosition.x;
6511 box.bottom -= child.absPosition.y - absPosition.y;
6512 if(box.right >= child.box.left && box.left <= child.box.right &&
6513 box.bottom >= child.box.top && box.top <= child.box.bottom)
6515 box.left -= child.clientStart.x;
6516 box.top -= child.clientStart.y;
6517 box.right -= child.clientStart.x;
6518 box.bottom -= child.clientStart.y;
6524 realBox.left += absPosition.x - rootWindow.absPosition.x;
6525 realBox.top += absPosition.y - rootWindow.absPosition.y;
6526 realBox.right += absPosition.x - rootWindow.absPosition.x;
6527 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6528 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6531 else if(this == guiApp.desktop)
6534 for(window = children.first; window; window = window.next)
6540 Box childBox = region;
6542 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6543 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6544 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6545 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6547 window.Update(childBox);
6550 window.Update(null);
6555 // rootWindow.mutex.Release();
6562 if(guiApp.windowCaptured != this)
6564 if(guiApp.windowCaptured)
6568 //Logf("Captured %s (%s)\n", caption, class.name);
6569 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6570 guiApp.windowCaptured = this;
6576 bool Destroy(int64 code)
6581 if(!destroyed && !CloseConfirmation(false)) return false;
6585 // TOCHECK: Should autoCreate be set to false here?
6596 void Move(int x, int y, int w, int h)
6598 normalAnchor = Anchor { left = x, top = y };
6599 normalSizeAnchor = SizeAnchor { size = { w, h } };
6601 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6603 if(destroyed) return;
6605 stateAnchor = normalAnchor;
6606 stateSizeAnchor = normalSizeAnchor;
6608 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6609 Position(x,y, w, h, true, true, true, true, false, true);
6613 DialogResult Modal(void)
6619 // FIXES MEMORY LEAK IF Create() FAILED
6625 void SetScrollArea(int width, int height, bool snapToStep)
6629 int stepX = sbStep.x, stepY = sbStep.y;
6630 // Needed to make snapped down position match the skin's check of client area
6631 // against realvirtual
6634 SNAPDOWN(stepX, textCellW);
6635 SNAPDOWN(stepY, textCellH);
6636 stepX = Max(stepX, textCellW);
6637 stepY = Max(stepY, textCellH);
6639 if(scrollFlags.snapX)
6640 SNAPUP(width, stepX);
6641 if(scrollFlags.snapY)
6642 SNAPUP(height, stepY);
6645 reqScrollArea.w = width;
6646 reqScrollArea.h = height;
6647 noAutoScrollArea = (width > 0 || height > 0);
6649 UpdateScrollBars(true, true);
6652 void SetScrollPosition(int x, int y)
6655 sbh.Action(setPosition, x, 0);
6659 int seen = clientSize.w, total = reqScrollArea.w;
6661 if(scrollFlags.snapX)
6662 SNAPDOWN(seen, sbStep.x);
6664 if(!total) total = seen;
6665 range = total - seen + 1;
6666 range = Max(range, 1);
6668 if(x >= range) x = range - 1;
6670 if(scrollFlags.snapX)
6671 SNAPUP(x, sbStep.x);
6674 OnHScroll(setPosition, x, 0);
6678 SNAPDOWN(x, textCellW);
6684 sbv.Action(setPosition, y, 0);
6688 int seen = clientSize.h, total = reqScrollArea.h;
6691 if(scrollFlags.snapY)
6692 SNAPDOWN(seen, sbStep.y);
6694 if(!total) total = seen;
6695 range = total - seen + 1;
6696 range = Max(range, 1);
6698 if(y >= range) y = range - 1;
6700 if(scrollFlags.snapY)
6701 SNAPUP(y, sbStep.y);
6704 OnVScroll(setPosition, y, 0);
6707 SNAPDOWN(y, textCellH);
6712 UpdateCaret(false, false);
6715 void SetScrollLineStep(int stepX, int stepY)
6721 SNAPDOWN(stepX, textCellW);
6722 SNAPDOWN(stepY, textCellH);
6723 stepX = Max(stepX, textCellW);
6724 stepY = Max(stepY, textCellH);
6727 sbh.lineStep = stepX;
6729 sbv.lineStep = stepY;
6732 void SetState(WindowState newState, bool activate, Modifiers mods)
6736 if(state == newState || OnStateChange(newState, mods))
6738 //WindowState prevState = state;
6742 // This used to be at the end of the brackets... moved for X, testing...
6743 // This has the effect of activating the window through the system...
6744 if(rootWindow == this)
6745 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6747 SetStateEx(newState, activate);
6749 if(rootWindow == this && !rootWindow.nativeDecorations)
6751 int x = position.x, y = position.y;
6754 x -= guiApp.desktop.absPosition.x;
6755 y -= guiApp.desktop.absPosition.y;
6757 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6761 //state = prevState;
6763 if(state != maximized && style.hasMaximize)
6766 for(child = parent.children.first; child; child = child.next)
6768 if(child != this && child.state == maximized)
6769 child.SetStateEx(normal, false);
6773 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6774 parent.UpdateScrollBars(true, true);
6777 // Do we really need this stuff here?
6778 // Shouldn't the Activate stuff take care of it?
6779 if(parent.rootWindow == parent && style)
6782 parent.FigureCaption(caption);
6783 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6784 parent.UpdateDecorations();
6788 rootWindow.ConsequentialMouseMove(false);
6795 BitmapResource GetIcon(SkinBitmap iconID)
6797 return guiApp.currentSkin.GetBitmap(iconID);
6800 void SetMouseRange(Box range)
6802 if(range || guiApp.fullScreenMode)
6807 clip.left = range.left + absPosition.x + clientStart.x;
6808 clip.top = range.top + absPosition.y + clientStart.y;
6809 clip.right = range.right + absPosition.x + clientStart.x;
6810 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6814 clip.left = guiApp.desktop.box.left;
6815 clip.top = guiApp.desktop.box.top;
6816 clip.right = guiApp.desktop.box.right;
6817 clip.bottom = guiApp.desktop.box.bottom;
6819 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6822 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6825 void SetMouseRangeToClient(void)
6827 if(guiApp.fullScreenMode || this != guiApp.desktop)
6829 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6830 box.Clip(clientArea);
6834 SetMouseRange(null);
6837 void SetMouseRangeToWindow(void)
6839 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6840 if(this == guiApp.desktop)
6841 SetMouseRangeToClient();
6846 // x, y: Desktop Coordinates
6847 void ShowSysMenu(int x, int y)
6850 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6853 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6854 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6858 menu, $"Move", m, NotifySelect = MenuWindowMove,
6859 disabled = !style.fixed || state == maximized
6863 menu, $"Size", s, NotifySelect = MenuWindowSize,
6864 disabled = !style.sizable || state != normal
6868 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6869 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6873 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6874 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6878 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6879 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6881 MenuDivider { menu };
6884 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6885 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6887 windowMenu.Create();
6892 ActivateEx(true, true, true, true, null, null);
6895 void MakeActive(void)
6897 ActivateEx(true, false, true, false, null, null);
6900 void SoftActivate(void)
6902 if(guiApp.desktop.active)
6907 if(this == rootWindow)
6912 void Deactivate(void)
6914 ActivateEx(false, true, true, true, null, null);
6919 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6922 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6924 bool result = false;
6925 if(activeChild && activeChild.cycle)
6927 Window modalWindow, child = activeChild;
6928 if(!clientOnly /*&& parent.tabCycle*/)
6930 Window next = child;
6933 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6937 if(parent && parent.CycleChildren(backward, false, true, true))
6945 next = next.cycle.prev.data;
6947 next = next.cycle.next.data;
6948 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6953 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6954 parent.tabCycle && parent.CycleChildren(backward, false, false))
6958 if(tabCycleOnly && !tabCycle) return false;
6965 child = child.cycle.prev.data;
6967 child = child.cycle.next.data;
6968 if(child == child.parent.activeChild)
6970 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6973 modalWindow = child.FindModal();
6976 // Scroll the window to include the active control
6977 if(sbh && !child.style.dontScrollHorz)
6979 if(child.scrolledPos.x < 0)
6980 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6981 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6982 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6984 if(sbv && !child.style.dontScrollVert)
6986 if(child.scrolledPos.y < 0)
6987 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6988 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6989 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6993 child = modalWindow ? modalWindow : child;
6994 child.ActivateEx(true, true, true, true, null, null);
6995 if(child.tabCycle && child.childrenCycle.first)
6996 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7004 ConsequentialMouseMove(false);
7008 void AddResource(Resource resource)
7012 ResPtr ptr { resource = resource };
7016 // Load Graphics here if window is created already
7017 if(/*created && */display)
7019 display.Lock(false);
7020 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7021 ptr.loaded = display.displaySystem.LoadResource(resource);
7025 // Temporary hack to load font right away for listbox in dropbox ...
7026 else if(master && master.display)
7028 master.display.Lock(false);
7029 master.display.displaySystem.LoadResource(resource);
7030 master.display.Unlock();
7036 void RemoveResource(Resource resource)
7041 for(ptr = resources.first; ptr; ptr = ptr.next)
7043 if(ptr.resource == resource)
7049 // Unload Graphics here if window is created already
7050 if(/*created && */display)
7054 display.Lock(false);
7055 display.displaySystem.UnloadResource(resource, ptr.loaded);
7061 resources.Delete(ptr);
7066 void SetCaret(int x, int y, int size)
7073 if(active && !style.interim && isEnabled)
7075 if(visible || !guiApp.caretOwner)
7076 guiApp.caretOwner = size ? this : null;
7078 UpdateCaret(false, false);
7081 guiApp.interfaceDriver.SetCaret(0,0,0);
7082 UpdateCaret(false, true);
7083 guiApp.caretEnabled = false;
7086 else if(style.inactive && active)
7088 guiApp.interfaceDriver.SetCaret(0,0,0);
7089 UpdateCaret(false, true);
7090 guiApp.caretEnabled = false;
7095 void Scroll(int x, int y)
7097 bool opaque = !style.drawBehind || background.a;
7098 if(opaque && display && display.flags.scrolling)
7100 Box box = clientArea;
7101 box.left += clientStart.x;
7102 box.top += clientStart.y;
7103 box.right += clientStart.x;
7104 box.bottom += clientStart.y;
7106 //scrollExtent.Free(null);
7107 scrollExtent.AddBox(box);
7108 scrolledArea.x += x;
7109 scrolledArea.y += y;
7111 //scrollExtent.Free();
7112 //scrollExtent.AddBox(clientArea);
7113 //scrollExtent.Offset(clientStart.x, clientStart.y);
7114 //scrolledArea.x = x;
7115 //scrolledArea.y = y;
7121 rootWindow.dirty = true;
7124 void ReleaseCapture()
7126 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7128 Window oldCaptured = guiApp.windowCaptured;
7129 guiApp.windowCaptured = null;
7130 guiApp.prevWindow = null;
7133 //guiApp.Log("Released Capture\n");
7135 guiApp.interfaceDriver.SetMouseCapture(null);
7137 //oldCaptured.OnMouseCaptureLost();
7140 oldCaptured.ConsequentialMouseMove(false);
7145 private void _SetCaption(const char * format, va_list args)
7152 char caption[MAX_F_STRING];
7153 vsnprintf(caption, sizeof(caption), format, args);
7154 caption[sizeof(caption)-1] = 0;
7156 this.caption = CopyString(caption);
7161 firewatchers caption;
7165 /*deprecated*/ void SetText(const char * format, ...)
7168 va_start(args, format);
7169 _SetCaption(format, args);
7173 void SetCaption(const char * format, ...)
7176 va_start(args, format);
7177 _SetCaption(format, args);
7181 bool Grab(Bitmap bitmap, Box box, bool decorations)
7183 bool result = false;
7184 if(display || this == guiApp.desktop)
7186 Box clip = {MININT, MININT, MAXINT, MAXINT};
7192 clip.Clip(clientArea);
7194 clip.Clip(this.box);
7196 if(rootWindow != this)
7198 clip.left += absPosition.y;
7199 clip.top += absPosition.y;
7200 clip.right += absPosition.x;
7201 clip.bottom += absPosition.y;
7204 clip.left += decorations ? 0 : clientStart.x;
7205 clip.top += decorations ? 0 : clientStart.y;
7206 clip.right += decorations ? 0 : clientStart.x;
7207 clip.bottom += decorations ? 0 : clientStart.y;
7209 if(display && display.flags.flipping)
7211 rootWindow.Update(null);
7212 rootWindow.UpdateDisplay();
7219 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7220 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7224 result = display.Grab(bitmap, clip.left, clip.top,
7225 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7227 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7229 if(!bitmap.Convert(null, pixelFormat888, null))
7236 void GetMousePosition(int * x, int * y)
7238 int mouseX = 0, mouseY = 0;
7239 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7242 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7243 if(this != guiApp.desktop)
7245 mouseX -= absPosition.x + clientStart.x;
7246 mouseY -= absPosition.y + clientStart.y;
7253 DialogResult DoModal()
7255 DialogResult returnCode = 0;
7256 int terminated = terminateX;
7259 while(!destroyed && guiApp.driver != null)
7261 if(terminateX != terminated)
7263 terminated = terminateX;
7264 guiApp.desktop.Destroy(0);
7265 if(guiApp.desktop.created)
7268 //printf("Resetting terminate X to 0\n");
7274 guiApp.UpdateDisplay();
7275 if(!guiApp.ProcessInput(false))
7278 returnCode = this.returnCode;
7291 return !destroyed && guiApp.driver != null && terminateX < 2;
7294 DialogResult DoModalEnd()
7296 DialogResult returnCode = this.returnCode;
7301 // --- Window manipulation ---
7302 /*bool GetDisabled()
7304 bool disabled = this.disabled;
7306 for(window = this; (window = window.master); )
7317 // --- Mouse Manipulation ---
7318 void GetNCMousePosition(int * x, int * y)
7320 GetMousePosition(x, y);
7321 if(x) *x += clientStart.x;
7322 if(y) *y += clientStart.y;
7325 // --- Carets manipulation ---
7326 void GetCaretPosition(Point caretPos)
7328 caretPos = this.caretPos;
7331 int GetCaretSize(void)
7336 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7342 bool CloseConfirmation(bool parentClosing)
7355 if(!OnClose(parentClosing))
7358 // If you want to skip this, simply set modifiedDocument to false in OnClose
7359 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7361 DialogResult dialogRes;
7364 sprintf(message, $"Save changes to %s?", fileName);
7366 sprintf(message, $"Save changes to Untitled %d?", documentID);
7368 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7370 if(dialogRes == yes)
7372 // TOFIX: Precomp error if brackets are taken out
7373 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7375 else if(dialogRes == cancel)
7381 for(slave = slaves.first; slave; slave = slave.next)
7383 Window w = slave.data;
7384 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7392 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7395 for(child = children.first; child; child = child.next)
7396 if(child.isActiveClient && !child.CloseConfirmation(true))
7404 for(child = children.first; child; child = child.next)
7405 if(!child.isActiveClient && !child.CloseConfirmation(true))
7415 // Static methods... move them somewhere else?
7416 void ::RestoreCaret()
7418 if(guiApp.caretOwner)
7419 guiApp.caretOwner.UpdateCaret(false, false);
7422 void ::FreeMouseRange()
7424 guiApp.interfaceDriver.SetMouseRange(null, null);
7428 bool MenuFileClose(MenuItem selection, Modifiers mods)
7430 Window document = activeChild;
7432 document.Destroy(0);
7436 bool MenuFileExit(MenuItem selection, Modifiers mods)
7442 bool MenuFileSave(MenuItem selection, Modifiers mods)
7447 fileMonitor.fileName = null;
7450 if(OnSaveFile(fileName))
7452 //if(OnFileModified != Window::OnFileModified)
7455 fileMonitor.fileName = fileName;
7461 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7462 DialogResult answer = dialog.Modal();
7464 if(answer != yes) return (bool)answer;
7467 return MenuFileSaveAs(selection, mods);
7470 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7472 DialogResult result = (DialogResult)bool::true;
7473 FileDialog fileDialog = saveDialog;
7478 fileDialog = FileDialog {};
7483 fileDialog.filePath = fileName;
7486 char filePath[MAX_FILENAME];
7487 sprintf(filePath, "Untitled %d", documentID);
7488 fileDialog.filePath = filePath;
7490 fileMonitor.fileName = null;
7492 fileDialog.type = save;
7493 fileDialog.text = $"Save As";
7497 fileDialog.master = master.parent ? master : this;
7498 if(fileDialog.Modal() == ok)
7500 const char * filePath = fileDialog.filePath;
7502 if(OnSaveFile(filePath))
7505 property::fileName = filePath;
7506 NotifySaved(master, this, filePath);
7511 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7512 DialogResult answer = dialog.Modal();
7527 //if(OnFileModified != Window::OnFileModified && fileName)
7530 fileMonitor.fileName = fileName;
7534 return (bool)result; // Actually returning result from Yes/NoCancel message box
7537 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7539 Window document = activeChild;
7541 for(document = children.first; document; document = next)
7543 next = document.next;
7544 if(document.style.isDocument || document.fileName)
7545 document.MenuFileSave(selection, mods);
7550 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7554 for(document = children.first; document; document = document.next)
7555 //if(document.style.isDocument && document.state == minimized)
7556 if(document.style.isActiveClient && document.state == minimized)
7557 document.SetState(minimized, false, mods);
7561 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7563 Window document = activeChild;
7566 Window firstDocument = null;
7568 OldLink cycle = document.cycle.prev;
7573 if(child.style.isActiveClient && !child.style.hidden)
7577 firstDocument = child;
7578 if(child.state == minimized)
7579 child.SetState(minimized, false, mods);
7582 child.positionID = id++;
7583 child.SetState(normal, false, mods);
7584 child.anchor.left.type = cascade;
7587 child.normalSizeAnchor = *&child.sizeAnchor;
7588 child.normalAnchor = child.anchor;
7590 // Break the anchors for moveable/resizable windows
7591 if(child.style.fixed)
7593 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7595 (*&child.normalAnchor).left = x;
7596 (*&child.normalAnchor).top = y;
7597 (*&child.normalAnchor).right.type = none;
7598 (*&child.normalAnchor).bottom.type = none;
7599 (*&child.normalSizeAnchor).isClientW = false;
7600 (*&child.normalSizeAnchor).isClientH = false;
7601 (*&child.normalSizeAnchor).size.w = w;
7602 (*&child.normalSizeAnchor).size.h = h;
7603 child.anchored = false;
7606 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7608 child.stateAnchor = child.normalAnchor;
7609 child.stateSizeAnchor = child.normalSizeAnchor;
7611 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7612 child.Position(x, y, w, h, true, true, true, true, false, false);
7617 last = children.last;
7618 if(!child.style.stayOnTop)
7619 for(; last && last.style.stayOnTop; last = last.prev);
7620 children.Move(child, last);
7621 childrenOrder.Move(child.order, childrenOrder.last);
7623 if(cycle == document.cycle) break;
7627 firstDocument.Activate();
7632 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7639 // Close all closes all active clients, not all documents
7640 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7642 Window next, document;
7644 for(document = children.first; document; document = next)
7646 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7647 if(document.style.isActiveClient)
7648 if(!document.Destroy(0) && !document.style.hidden)
7654 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7656 if(style.hasMaximize && state != maximized)
7657 SetState(maximized, 0, 0);
7661 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7663 if(style.hasMinimize && state != minimized)
7665 SetState(minimized, 0, 0);
7666 parent.CycleChildren(false, true, false, true);
7671 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7673 MenuMoveOrSize(false, selection ? true : false);
7677 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7679 CycleChildren(false, true, false, true);
7683 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7685 CycleChildren(true, true, false, true);
7689 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7691 MenuMoveOrSize(true, true);
7695 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7698 SetState(normal, 0, 0);
7702 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7705 int64 id = selection.id;
7706 OldLink cycle = activeClient.cycle;
7708 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7711 Window sibling = cycle.data;
7712 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7720 document = cycle.data;
7721 document.Activate();
7723 //if(activeChild.state == maximized)
7724 // document.SetState(maximized, false, mods);
7725 //else if(document.state == minimized)
7726 // document.SetState(normal, false, mods);
7730 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7732 stayOnTop = !style.stayOnTop;
7736 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7738 Window document = activeChild;
7741 Window firstDocument = null;
7742 OldLink cycle = document.cycle;
7746 Window child = cycle.data;
7747 if(child.style.isActiveClient && !child.style.hidden)
7749 if(!firstDocument) firstDocument = child;
7750 if(child.state == minimized)
7751 child.SetState(minimized, false, mods);
7754 child.positionID = id++;
7755 child.SetState(normal, false, mods);
7756 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7758 child.anchor.left.type = hTiled;
7761 child.normalSizeAnchor = *&child.sizeAnchor;
7762 child.normalAnchor = child.anchor;
7764 // Break the anchors for moveable/resizable windows
7765 if(child.style.fixed)
7767 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7769 (*&child.normalAnchor).left = x;
7770 (*&child.normalAnchor).top = y;
7771 (*&child.normalAnchor).right.type = none;
7772 (*&child.normalAnchor).bottom.type = none;
7773 (*&child.normalSizeAnchor).isClientW = false;
7774 (*&child.normalSizeAnchor).isClientH = false;
7775 (*&child.normalSizeAnchor).size.w = w;
7776 (*&child.normalSizeAnchor).size.h = h;
7777 child.anchored = false;
7780 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7782 child.stateAnchor = child.normalAnchor;
7783 child.stateSizeAnchor = child.normalSizeAnchor;
7785 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7786 child.Position(x,y, w, h, true, true, true, true, false, true);
7791 if((cycle = cycle.next) == document.cycle) break;
7794 firstDocument.Activate();
7799 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7801 Window document = activeChild;
7804 Window firstDocument = null;
7806 OldLink cycle = document.cycle;
7811 //if(child.style.isDocument)
7812 if(child.style.isActiveClient && !child.style.hidden)
7814 if(!firstDocument) firstDocument = child;
7815 if(child.state == minimized)
7816 child.SetState(minimized, false, mods);
7819 child.positionID = id++;
7820 child.SetState(normal, false, mods);
7821 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7823 child.anchor.left.type = vTiled;
7826 child.normalSizeAnchor = *&child.sizeAnchor;
7827 child.normalAnchor = child.anchor;
7829 // Break the anchors for moveable/resizable windows
7830 if(child.style.fixed)
7832 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7834 (*&child.normalAnchor).left = x;
7835 (*&child.normalAnchor).top = y;
7836 (*&child.normalAnchor).right.type = none;
7837 (*&child.normalAnchor).bottom.type = none;
7838 (*&child.normalSizeAnchor).isClientW = false;
7839 (*&child.normalSizeAnchor).isClientH = false;
7840 (*&child.normalSizeAnchor).size.w = w;
7841 (*&child.normalSizeAnchor).size.h = h;
7842 child.anchored = false;
7845 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7847 child.stateAnchor = child.normalAnchor;
7848 child.stateSizeAnchor = child.normalSizeAnchor;
7850 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7851 child.Position(x,y, w, h, true, true, true, true, false, true);
7856 if((cycle = cycle.next) == document.cycle) break;
7859 firstDocument.Activate();
7864 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7866 WindowList dialog { master = this };
7867 Window document = (Window)(intptr)dialog.Modal();
7870 if(activeChild.state == maximized)
7871 document.SetState(maximized, false, mods);
7872 else if(document.state == minimized)
7873 document.SetState(normal, false, mods);
7874 document.Activate();
7880 virtual bool OnCreate(void);
7881 virtual void OnDestroy(void);
7882 virtual void OnDestroyed(void);
7883 virtual bool OnClose(bool parentClosing);
7884 virtual bool OnStateChange(WindowState state, Modifiers mods);
7885 virtual bool OnPostCreate(void);
7886 virtual bool OnMoving(int *x, int *y, int w, int h);
7887 virtual bool OnResizing(int *width, int *height);
7888 virtual void OnResize(int width, int height);
7889 virtual void OnPosition(int x, int y, int width, int height);
7890 virtual bool OnLoadGraphics(void);
7891 virtual void OnApplyGraphics(void);
7892 virtual void OnUnloadGraphics(void);
7893 virtual void OnRedraw(Surface surface);
7894 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7895 virtual void OnActivateClient(Window client, Window previous);
7896 virtual bool OnKeyDown(Key key, unichar ch);
7897 virtual bool OnKeyUp(Key key, unichar ch);
7898 virtual bool OnKeyHit(Key key, unichar ch);
7899 virtual bool OnSysKeyDown(Key key, unichar ch);
7900 virtual bool OnSysKeyUp(Key key, unichar ch);
7901 virtual bool OnSysKeyHit(Key key, unichar ch);
7902 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7903 virtual bool OnMouseLeave(Modifiers mods);
7904 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7905 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7906 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7907 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7908 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7909 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7910 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7911 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7912 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7913 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7914 virtual void OnMouseCaptureLost(void);
7915 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7916 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7917 virtual void OnDrawOverChildren(Surface surface);
7918 virtual bool OnFileModified(FileChange fileChange, const char * param);
7919 virtual bool OnSaveFile(const char * fileName);
7921 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7922 // Note: A 'client' would refer to isActiveClient, rather than
7923 // being confined to the 'client area' (nonClient == false)
7924 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7925 virtual void OnChildVisibilityToggled(Window child, bool visible);
7926 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7928 // Skins Virtual Functions
7929 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7930 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7931 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7936 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7937 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7938 virtual bool IsMouseMoving(int x, int y, int w, int h)
7942 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7946 virtual void UpdateNonClient();
7947 virtual void SetBox(Box box); // This is used in the MySkin skin
7948 virtual bool IsInside(int x, int y)
7950 return box.IsPointInside({x, y});
7952 virtual bool IsOpaque()
7954 return (!style.drawBehind || background.a == 255);
7958 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7959 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7960 virtual void Window::NotifySaved(Window window, const char * filePath);
7965 property Window parent
7967 property_category $"Layout"
7970 if(value || guiApp.desktop)
7973 Window oldParent = parent;
7974 Anchor anchor = this.anchor;
7976 if(value && value.IsDescendantOf(this)) return;
7977 if(value && value == this)
7979 if(!value) value = guiApp.desktop;
7981 if(value == oldParent) return;
7983 if(!master || (master == this.parent && master == guiApp.desktop))
7984 property::master = value;
7988 parent.children.Remove(this);
7992 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7993 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7994 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7995 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7999 last = value.children.last;
8001 if(style.isDocument)
8004 parent.numDocuments--;
8005 documentID = value.GetDocumentID();
8008 if(style.isActiveClient && !style.hidden)
8010 if(parent && parent != guiApp.desktop && !(style.hidden))
8012 if(state == minimized) parent.numIcons--;
8013 parent.numPositions--;
8017 if(!style.stayOnTop)
8018 for(; last && last.style.stayOnTop; last = last.prev);
8020 value.children.Insert(last, this);
8022 // *** NEW HERE: ***
8024 parent.childrenCycle.Delete(cycle);
8026 parent.childrenOrder.Delete(order);
8029 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8030 // Should something else be done?
8031 if(parent && parent.activeChild == this)
8032 parent.activeChild = null;
8033 if(parent && parent.activeClient == this)
8034 parent.activeClient = null;
8040 int x = position.x, y = position.y, w = size.w, h = size.h;
8044 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8045 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8047 vpw = value.clientSize.w;
8048 vph = value.clientSize.h;
8054 else if(style.fixed)
8056 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8057 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8060 anchor = this.anchor;
8062 if(anchor.left.type == offset) anchor.left.distance = x;
8063 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8064 if(anchor.top.type == offset) anchor.top.distance = y;
8065 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8066 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8067 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8068 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8069 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8070 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8071 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8073 if(!anchor.left.type && !anchor.right.type)
8075 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8076 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8078 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8079 if(!anchor.top.type && !anchor.bottom.type)
8081 anchor.vert.distance = (y + h / 2) - (vph / 2);
8082 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8084 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8087 parent.OnChildAddedOrRemoved(this, false);
8093 parent.childrenCycle.Insert(
8094 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8095 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8097 cycle = OldLink { data = this });
8098 parent.childrenOrder.Insert(
8099 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8100 order = OldLink { data = this });
8103 if(!style.hidden && style.isActiveClient)
8105 positionID = parent.GetPositionID(this);
8106 parent.numPositions++;
8107 if(state == minimized) parent.numIcons--;
8110 // *** FONT INHERITANCE ***
8111 if(!setFont && oldParent)
8112 stopwatching(oldParent, font);
8116 RemoveResource(systemFont);
8119 // TESTING WITH WATCHERS:
8120 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8121 // usedFont = setFont ? setFont : (systemFont);
8125 if(guiApp.currentSkin)
8127 systemFont = guiApp.currentSkin.SystemFont();
8130 usedFont = systemFont;
8131 AddResource(systemFont);
8139 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8148 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8150 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8151 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8154 UnloadGraphics(false);
8157 LoadGraphics(false, false);
8160 if(value.rootWindow != rootWindow)
8161 DisplayModeChanged();
8165 scrolledPos.x = MININT; // Prevent parent update
8167 bool anchored = this.anchored;
8168 property::anchor = anchor;
8169 this.anchored = anchored;
8174 if(guiApp.currentSkin)
8175 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8177 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8178 Position(x, y, w, h, true, true, true, true, false, true);
8183 // else parent = value;
8185 oldParent.OnChildAddedOrRemoved(this, true);
8188 get { return parent; }
8191 property Window master
8193 property_category $"Behavior"
8196 //if(this == value) return;
8197 if(value && value.IsSlaveOf(this)) return;
8203 OldLink slaveHolder;
8204 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8205 if(slaveHolder.data == this)
8207 master.slaves.Delete(slaveHolder);
8214 value.slaves.Add(OldLink { data = this });
8219 master.hotKeys.Remove(hotKey);
8220 value.hotKeys.Add(hotKey);
8223 if(master && master.defaultControl == this)
8224 master.defaultControl = null;
8226 if(style.isDefault && !value.defaultControl)
8227 value.defaultControl = this;
8232 get { return master ? master : parent; }
8235 property const char * caption
8237 property_category $"Appearance"
8244 caption = new char[strlen(value)+1];
8246 strcpy(caption, value);
8251 get { return caption; }
8256 property_category $"Behavior"
8265 master.hotKeys.Add(hotKey = HotKeySlot { });
8269 hotKey.window = this;
8274 master.hotKeys.Delete(hotKey);
8279 get { return hotKey ? hotKey.key : 0; }
8282 property Color background
8284 property_category $"Appearance"
8287 background.color = value;
8292 if(this == rootWindow)
8293 guiApp.interfaceDriver.SetRootWindowColor(this);
8296 get { return background.color; }
8299 property Percentage opacity
8301 property_category $"Appearance"
8304 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8305 drawBehind = (background.a == 255) ? false : true;
8307 get { return background.a / 255.0f; }
8310 property Color foreground
8312 property_category $"Appearance"
8320 get { return foreground; }
8323 property BorderStyle borderStyle
8325 property_category $"Appearance"
8328 if(!((BorderBits)value).fixed)
8330 style.hasClose = false;
8331 style.hasMaximize = false;
8332 style.hasMinimize = false;
8333 nativeDecorations = false;
8335 style.borderBits = value;
8339 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8341 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8342 Position(x, y, w, h, true, true, true, true, false, true);
8343 CreateSystemChildren();
8346 get { return (BorderStyle)style.borderBits; }
8349 property Size minClientSize
8351 property_category $"Layout"
8352 set { minSize = value; }
8353 get { value = minSize; }
8356 property Size maxClientSize
8358 property_category $"Layout"
8359 set { maxSize = value; }
8360 get { value = maxSize; }
8363 property bool hasMaximize
8365 property_category $"Window Style"
8368 style.hasMaximize = value;
8369 if(value) { style.fixed = true; style.contour = true; }
8373 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8375 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8376 Position(x, y, w, h, true, true, true, true, false, true);
8378 CreateSystemChildren();
8381 get { return style.hasMaximize; }
8384 property bool hasMinimize
8386 property_category $"Window Style"
8389 style.hasMinimize = value;
8390 if(value) { style.fixed = true; style.contour = true; }
8394 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8396 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8397 Position(x, y, w, h, true, true, true, true, false, true);
8399 CreateSystemChildren();
8402 get { return style.hasMinimize; }
8405 property bool hasClose
8407 property_category $"Window Style"
8410 style.hasClose = value;
8411 if(value) { style.fixed = true; style.contour = true; }
8415 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8416 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8417 Position(x, y, w, h, true, true, true, true, false, true);
8418 CreateSystemChildren();
8421 get { return style.hasClose; }
8424 property bool nonClient
8426 property_category $"Layout"
8429 style.nonClient = value;
8431 style.stayOnTop = true;
8433 get { return style.nonClient; }
8436 property bool inactive
8438 property_category $"Behavior"
8443 // *** NEW HERE: ***
8447 parent.childrenCycle.Delete(cycle);
8449 parent.childrenOrder.Delete(order);
8456 active = false; // true;
8457 if(parent.activeChild == this)
8458 parent.activeChild = null;
8459 if(parent.activeClient == this)
8460 parent.activeClient = null;
8469 parent.childrenCycle.Insert(
8470 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8471 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8473 cycle = OldLink { data = this });
8475 parent.childrenOrder.Insert(
8476 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8477 order = OldLink { data = this });
8480 style.inactive = value;
8482 get { return style.inactive; }
8485 property bool clickThrough
8487 property_category $"Behavior"
8488 set { style.clickThrough = value; }
8489 get { return style.clickThrough; }
8492 property bool isRemote
8494 property_category $"Behavior"
8495 set { style.isRemote = value; }
8496 get { return style.isRemote; }
8499 property bool noCycle
8501 property_category $"Behavior"
8502 set { style.noCycle = value; }
8503 get { return style.noCycle; }
8506 property bool isModal
8508 property_category $"Behavior"
8509 set { style.modal = value; }
8510 get { return style.modal; }
8513 property bool interim
8515 property_category $"Behavior"
8516 set { style.interim = value; }
8517 get { return style.interim; }
8520 property bool tabCycle
8522 property_category $"Behavior"
8523 set { style.tabCycle = value; }
8524 get { return style.tabCycle; }
8527 property bool isDefault
8529 property_category $"Behavior"
8537 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8538 if(sibling != this && sibling.style.isDefault)
8539 sibling.style.isDefault = false;*/
8540 if(master.defaultControl)
8541 master.defaultControl.style.isDefault = false;
8542 master.defaultControl = this;
8544 else if(master.defaultControl == this)
8545 master.defaultControl = null;
8549 style.isDefault = value;
8551 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8553 get { return style.isDefault; }
8556 property bool drawBehind
8558 property_category $"Window Style"
8559 set { style.drawBehind = value; }
8560 get { return style.drawBehind; }
8563 property bool hasMenuBar
8565 property_category $"Window Style"
8575 if(created && !menuBar)
8582 anchor = Anchor { top = 23, left = 1, right = 1 },
8584 inactive = true, nonClient = true
8589 else if(created && menuBar)
8594 style.hasMenuBar = value;
8596 get { return style.hasMenuBar; }
8599 property bool hasStatusBar
8601 property_category $"Window Style"
8608 statusBar = StatusBar { this };
8616 style.hasStatusBar = value;
8618 get { return style.hasStatusBar; }
8620 property bool stayOnTop
8622 property_category $"Window Style"
8627 if(created && !style.stayOnTop)
8629 if(rootWindow == this)
8630 guiApp.interfaceDriver.OrderRootWindow(this, true);
8631 else if(parent.children.last != this)
8633 parent.children.Move(this, parent.children.last);
8637 style.stayOnTop = true;
8641 if(created && style.stayOnTop)
8643 if(rootWindow == this)
8644 guiApp.interfaceDriver.OrderRootWindow(this, false);
8651 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8652 order && ((Window)order.data).style.stayOnTop;
8653 order = (order == parent.childrenOrder.first) ? null : order.prev);
8654 last = order ? order.data : null;
8658 for(last = parent.children.last;
8659 last && last.style.stayOnTop;
8663 parent.children.Move(this, last);
8667 style.stayOnTop = false;
8670 get { return style.stayOnTop; }
8675 property_category $"Window Style"
8685 if(menuBar && !value)
8692 if(!menuBar && style.hasMenuBar && value)
8696 this, menu = value, isMenuBar = true,
8697 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8698 inactive = true, nonClient = true
8702 UpdateActiveDocument(null);
8705 get { return menu; }
8708 property FontResource font
8710 property_category $"Appearance"
8712 isset { return setFont ? true : false; }
8717 if(value && !setFont) { stopwatching(parent, font); }
8718 else if(!value && setFont)
8724 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8733 RemoveResource(setFont);
8738 RemoveResource(systemFont);
8745 AddResource(setFont);
8748 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8751 systemFont = guiApp.currentSkin.SystemFont();
8753 usedFont = systemFont;
8754 AddResource(systemFont);
8762 get { return usedFont; }
8765 property SizeAnchor sizeAnchor
8767 property_category $"Layout"
8770 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8771 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8772 sizeAnchor.isClientW != sizeAnchor.isClientH;
8779 normalSizeAnchor = sizeAnchor;
8781 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8783 stateAnchor = normalAnchor;
8784 stateSizeAnchor = normalSizeAnchor;
8786 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8787 Position(x,y, w, h, true, true, true, true, false, true);
8794 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8795 sizeAnchor.isClientW,
8796 sizeAnchor.isClientH
8803 property_category $"Layout"
8806 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8807 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8808 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8814 sizeAnchor.isClientW = false;
8815 sizeAnchor.isClientH = false;
8816 sizeAnchor.size = value;
8818 normalSizeAnchor = sizeAnchor;
8820 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8822 stateAnchor = normalAnchor;
8823 stateSizeAnchor = normalSizeAnchor;
8825 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8826 Position(x, y, w, h, true, true, true, true, false, true);
8827 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8830 get { value = size; }
8833 property Size clientSize
8835 property_category $"Layout"
8838 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8839 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8840 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8845 sizeAnchor.isClientW = true;
8846 sizeAnchor.isClientH = true;
8847 sizeAnchor.size = value;
8849 normalSizeAnchor = sizeAnchor;
8851 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8853 stateAnchor = normalAnchor;
8854 stateSizeAnchor = normalSizeAnchor;
8856 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8857 Position(x,y, w, h, true, true, true, true, false, true);
8858 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8861 get { value = this ? clientSize : { 0, 0 }; }
8864 property Size initSize { get { value = sizeAnchor.size; } };
8866 property Anchor anchor
8868 property_category $"Layout"
8869 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8875 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8877 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8878 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8880 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8882 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8883 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8887 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8889 anchor.left.distance = 0;
8890 anchor.horz.type = 0;
8892 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8894 anchor.top.distance = 0;
8895 anchor.vert.type = 0;
8904 normalAnchor = anchor;
8906 // Break the anchors for moveable/resizable windows
8907 /*if(style.fixed ) //&& value.left.type == cascade)
8909 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8911 this.anchor = normalAnchor = Anchor { left = x, top = y };
8912 normalSizeAnchor = SizeAnchor { { w, h } };
8915 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8917 stateAnchor = normalAnchor;
8918 stateSizeAnchor = normalSizeAnchor;
8920 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8921 Position(x, y, w, h, true, true, true, true, false, true);
8930 get { value = this ? anchor : Anchor { }; }
8933 property Point position
8935 property_category $"Layout"
8938 if(value == null) return;
8940 anchor.left = value.x;
8941 anchor.top = value.y;
8942 anchor.right.type = none;
8943 anchor.bottom.type = none;
8948 normalAnchor = anchor;
8950 // Break the anchors for moveable/resizable windows
8954 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8956 normalAnchor.left = x;
8957 normalAnchor.top = y;
8958 normalAnchor.right.type = none;
8959 normalAnchor.bottom.type = none;
8960 normalSizeAnchor.size.width = w;
8961 normalSizeAnchor.size.height = h;
8965 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8967 stateAnchor = normalAnchor;
8968 stateSizeAnchor = normalSizeAnchor;
8970 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8971 Position(x,y, w, h, true, true, true, true, false, true);
8975 get { value = position; }
8978 property bool disabled
8980 property_category $"Behavior"
8983 if(this && disabled != value)
8990 get { return (bool)disabled; }
8993 property bool isEnabled
8998 for(parent = this; parent; parent = parent.parent)
9005 property WindowState state
9007 property_category $"Behavior"
9008 set { SetState(value, false, 0); }
9009 get { return this ? state : 0; }
9012 property bool visible
9014 property_category $"Behavior"
9017 if(this && !value && !style.hidden && parent)
9019 bool wasActiveChild = parent.activeChild == this;
9020 Window client = null;
9022 style.hidden = true;
9023 if(style.isActiveClient)
9025 parent.numPositions--;
9026 if(state == minimized) parent.numIcons--;
9031 OldLink prevOrder = null;
9033 if(rootWindow == this)
9034 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9037 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9040 box.left -= parent.clientStart.x;
9041 box.top -= parent.clientStart.y;
9042 box.right -= parent.clientStart.x;
9043 box.bottom -= parent.clientStart.y;
9047 if(_isModal && master && master.modalSlave == this)
9048 master.modalSlave = null;
9052 OldLink tmpPrev = order.prev;
9053 client = tmpPrev ? tmpPrev.data : null;
9054 if(client && !client.style.hidden && !client.destroyed && client.created)
9055 prevOrder = tmpPrev;
9058 client = tmpPrev ? tmpPrev.data : null;
9059 if(client == this) { client = null; break; }
9060 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9062 tmpPrev = client.order.prev;
9067 prevOrder = tmpPrev;
9072 // If this window can be an active client, make sure the next window we activate can also be one
9073 if(!style.nonClient && style.isActiveClient)
9075 tmpPrev = prevOrder;
9078 client = tmpPrev ? tmpPrev.data : null;
9079 if(client == this) { client = null; break; }
9080 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9082 tmpPrev = client.order.prev;
9087 prevOrder = tmpPrev;
9091 if(client && client.style.hidden) client = null;
9095 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9097 if(order && prevOrder && prevOrder.data != this)
9098 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9100 ActivateEx(false, false, false, true, null, null);
9102 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9103 if(parent.activeClient == this)
9105 parent.activeClient = null;
9106 parent.UpdateActiveDocument(null);
9109 else if(parent.activeClient == this)
9111 parent.activeClient = client;
9112 parent.UpdateActiveDocument(this);
9115 // *** Not doing this anymore ***
9118 parent.childrenCycle.Delete(cycle);
9120 parent.childrenOrder.Delete(order);
9125 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9130 else if(this && value && style.hidden)
9132 style.hidden = false;
9135 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9136 if(rootWindow == this)
9137 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9139 if(_isModal && master)
9140 master.modalSlave = this;
9142 if(style.isActiveClient)
9144 positionID = parent.GetPositionID(this);
9145 parent.numPositions++;
9146 if(state == minimized) parent.numIcons++;
9149 // *** NOT DOING THIS ANYMORE ***
9151 if(!(style.inactive))
9153 if(!(style.noCycle))
9155 cycle = parent.childrenCycle.AddAfter(
9156 (parent.activeChild && parent.activeChild.cycle) ?
9157 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9160 order = parent.childrenOrder.AddAfter(
9161 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9168 if(true || !parent.activeChild)
9169 ActivateEx(true, false, true, true, null, null);
9171 if(creationActivation == activate && guiApp.desktop.active)
9172 ActivateEx(true, false, true, true, null, null);
9173 else if((creationActivation == activate || creationActivation == flash) && !object)
9176 if(this == rootWindow)
9180 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9184 ConsequentialMouseMove(false);
9190 style.hidden = !value;
9193 get { return (style.hidden || !setVisible) ? false : true; }
9196 property bool isDocument
9198 property_category $"Document"
9199 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9200 get { return style.isDocument; }
9203 property bool mergeMenus
9205 property_category $"Window Style"
9206 set { mergeMenus = value; }
9207 get { return (bool)mergeMenus; }
9210 property bool hasHorzScroll
9212 property_category $"Window Style"
9217 if(!style.hasHorzScroll && created)
9219 CreateSystemChildren();
9220 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9223 else if(style.hasHorzScroll)
9227 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9229 style.hasHorzScroll = value;
9232 get { return style.hasHorzScroll; }
9235 property bool hasVertScroll
9237 property_category $"Window Style"
9242 if(!style.hasVertScroll && created)
9244 style.hasVertScroll = true;
9245 CreateSystemChildren();
9246 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9249 else if(style.hasVertScroll)
9253 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9255 style.hasVertScroll = value;
9257 get { return style.hasVertScroll; }
9260 property bool dontHideScroll
9262 property_category $"Behavior"
9265 scrollFlags.dontHide = value;
9268 //UpdateScrollBars(true, true);
9269 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9273 // UpdateScrollBars(true, true);
9274 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9277 get { return scrollFlags.dontHide; }
9280 property bool dontScrollVert
9282 property_category $"Behavior"
9283 set { style.dontScrollVert = value; }
9284 get { return style.dontScrollVert; }
9286 property bool dontScrollHorz
9288 property_category $"Behavior"
9289 set { style.dontScrollHorz = value; }
9290 get { return style.dontScrollHorz; }
9293 property bool snapVertScroll
9295 property_category $"Behavior"
9298 scrollFlags.snapY = value;
9299 if(sbv) sbv.snap = value;
9301 get { return scrollFlags.snapY; }
9303 property bool snapHorzScroll
9305 property_category $"Behavior"
9308 scrollFlags.snapX = value;
9309 if(sbh) sbh.snap = value;
9311 get { return scrollFlags.snapX; }
9314 property Point scroll
9316 property_category $"Behavior"
9317 set { if(this) SetScrollPosition(value.x, value.y); }
9318 get { value = scroll; }
9321 property bool modifyVirtualArea
9323 property_category $"Behavior"
9324 set { modifyVirtArea = value; }
9325 get { return (bool)modifyVirtArea; }
9328 property bool dontAutoScrollArea
9330 property_category $"Behavior"
9331 // Activating a child control out of view will automatically scroll to make it in view
9332 set { noAutoScrollArea = value; }
9333 get { return (bool)noAutoScrollArea; }
9336 property const char * fileName
9338 property_category $"Document"
9343 if(menu && ((!fileName && value) || (fileName && !value)))
9345 MenuItem item = menu.FindItem(MenuFileSave, 0);
9346 if(item) item.disabled = !modifiedDocument && value;
9351 if(value && value[0])
9352 fileName = CopyString(value);
9354 if(parent && this == parent.activeClient)
9355 parent.UpdateActiveDocument(null);
9359 // if(style.isDocument)
9361 fileMonitor.fileName = value;
9363 get { return fileName; }
9368 property_category $"Data"
9373 property bool modifiedDocument
9375 property_category $"Document"
9378 if(style.isDocument || fileName)
9382 MenuItem item = menu.FindItem(MenuFileSave, 0);
9383 if(item) item.disabled = !value && fileName;
9387 if(modifiedDocument != value)
9389 modifiedDocument = value;
9390 if(style.isDocument || fileName)
9394 get { return (bool)modifiedDocument; }
9397 property bool showInTaskBar
9399 property_category $"Window Style"
9400 set { style.showInTaskBar = value; }
9401 get { return style.showInTaskBar; }
9403 property FileDialog saveDialog { set { saveDialog = value; } };
9404 property bool isActiveClient
9406 property_category $"Behavior"
9409 if(parent && style.isActiveClient != value && !style.hidden)
9413 if(state == minimized) parent.numIcons++;
9414 parent.numPositions++;
9418 if(state == minimized) parent.numIcons--;
9419 parent.numPositions--;
9422 style.isActiveClient = value;
9424 get { return style.isActiveClient; }
9427 property Cursor cursor
9429 property_category $"Appearance"
9433 SelectMouseCursor();
9435 get { return cursor; }
9438 //#if !defined(ECERE_VANILLA)
9439 property const char * name
9441 property_category $"Design"
9444 return (this && object) ? object.name : null;
9449 activeDesigner.RenameObject(object, value);
9453 property const char * displayDriver
9455 property_category $"Behavior"
9458 dispDriver = GetDisplayDriver(value);
9459 //DisplayModeChanged();
9463 return dispDriver ? dispDriver.name : null;
9467 // RUNTIME PROPERTIES
9468 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9469 property Size scrollArea
9471 property_category $"Behavior"
9475 SetScrollArea(value.w, value.h, false);
9477 SetScrollArea(0,0, true);
9479 get { value = scrollArea; }
9482 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9487 property_category $"Layout"
9488 set { if(this) is3D = value; }
9489 get { return (bool)is3D; }
9492 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9494 // Will be merged with font later
9495 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9496 property Point clientStart { get { value = clientStart; } };
9497 property Point absPosition { get { value = absPosition; } };
9498 property Anchor normalAnchor { get { value = normalAnchor; } };
9499 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9500 property bool active { get { return (bool)active; } };
9501 property bool created { get { return (bool)created; } };
9502 property bool destroyed { get { return (bool)destroyed; } };
9503 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9504 property Window firstChild { get { return children.first; } };
9505 property Window lastChild { get { return children.last; } };
9506 property Window activeClient { get { return activeClient; } };
9507 property Window activeChild { get { return activeChild; } };
9508 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9509 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9510 property ScrollBar horzScroll { get { return sbh; } };
9511 property ScrollBar vertScroll { get { return sbv; } };
9512 property StatusBar statusBar { get { return statusBar; } };
9513 property Window rootWindow { get { return rootWindow; } };
9514 property bool closing { get { return (bool)closing; } set { closing = value; } };
9515 property int documentID { get { return documentID; } };
9516 property Window previous { get { return prev; } }
9517 property Window next { get { return next; } }
9518 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9519 property PopupMenu menuBar { get { return menuBar; } }
9520 property ScrollBar sbv { get { return sbv; } }
9521 property ScrollBar sbh { get { return sbh; } }
9522 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9523 property void * systemHandle { get { return windowHandle; } }
9524 property Button minimizeButton { get { return sysButtons[0]; } };
9525 property Button maximizeButton { get { return sysButtons[1]; } };
9526 property Button closeButton { get { return sysButtons[2]; } };
9527 property BitmapResource icon
9529 get { return icon; }
9533 if(icon) incref icon;
9535 guiApp.interfaceDriver.SetIcon(this, value);
9538 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9539 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9540 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9541 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9542 property bool nativeDecorations
9544 get { return (bool)nativeDecorations; }
9545 set { nativeDecorations = value; }
9546 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9549 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9550 bool result = false;
9551 if(nativeDecorations)
9553 if(rootWindow == this)
9557 if(formDesigner && activeDesigner)
9559 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9560 Window form = cd ? cd.form : null;
9561 if(form && parent == form.parent)
9566 return result != style.fixed;
9570 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9572 property const char * text
9574 property_category $"Deprecated"
9576 set { property::caption = value; }
9577 get { return property::caption; }
9583 WindowBits style; // Window Style
9584 char * caption; // Name / Caption
9585 Window parent; // Parent window
9586 OldList children; // List of children in Z order
9587 Window activeChild; // Child window having focus
9588 Window activeClient;
9589 Window previousActive; // Child active prior to activating the default child
9590 Window master; // Window owning and receiving notifications concerning this window
9591 OldList slaves; // List of windows belonging to this window
9592 Display display; // Display this window is drawn into
9594 Point position; // Position in parent window client area
9595 Point absPosition; // Absolute position
9596 Point clientStart; // Client area position from (0,0) in this window
9598 Size clientSize; // Client area size
9599 Size scrollArea; // Virtual Scroll area size
9600 Size reqScrollArea; // Requested virtual area size
9601 Point scroll; // Virtual area scrolling position
9602 ScrollBar sbh, sbv; // Scrollbar window handles
9603 Cursor cursor; // Mouse cursor used for this window
9606 StatusBar statusBar;
9607 Button sysButtons[3];
9609 Box clientArea; // Client Area box clipped to parent
9611 HotKeySlot hotKey; // HotKey for this window
9615 ScrollFlags scrollFlags;// Window Scrollbar Flags
9616 int64 id; // Control ID
9618 ColorAlpha background; // Background color used to draw the window area
9620 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9621 OldList childrenCycle; // Cycling order
9622 OldLink cycle; // Element of parent's cycling order
9623 OldList childrenOrder; // Circular Z-Order
9624 OldLink order; // Element of parent's circular Z-Order
9625 Window modalSlave; // Slave window blocking this window's interaction
9627 Window rootWindow; // Topmost system managed window
9628 void * windowHandle; // System window handle
9630 DialogResult returnCode;// Return code for modal windows
9632 Point sbStep; // Scrollbar line scrolling steps
9635 SizeAnchor stateSizeAnchor;
9637 Anchor normalAnchor;
9638 SizeAnchor normalSizeAnchor;
9640 Size skinMinSize; // Minimal window size based on style
9641 Point scrolledPos; // Scrolled position
9642 Box box; // Window box clipped to parent
9643 Box * against; // What to clip the box to
9645 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9646 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9647 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9648 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9649 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9650 Point scrolledArea; // Distance to scroll area by
9651 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9653 OldList hotKeys; // List of the hotkeys of all children
9654 Window defaultControl; // Default child control
9658 ColorAlpha * palette; // Color palette used for this window
9660 int caretSize; // Size of caret, non zero if a caret is present
9661 Point caretPos; // Caret position
9663 void * systemParent; // Parent System Window for embedded windows
9670 WindowState lastState;
9672 FileMonitor fileMonitor;
9674 FontResource setFont, systemFont;
9675 FontResource usedFont;
9676 FontResource captionFont;
9678 FileDialog saveDialog;
9680 SizeAnchor sizeAnchor;
9682 // FormDesigner data
9685 Extent * tempExtents; //[4];
9686 BitmapResource icon;
9688 CreationActivationOption creationActivation;
9691 bool active:1; // true if window and ancestors are active
9692 bool acquiredInput:1; // true if the window is processing state based input
9693 bool modifiedDocument:1;
9694 bool disabled:1; // true if window cannot interact
9695 bool isForegroundWindow:1;// true while a root window is being activated
9696 bool visible:1; // Visibility flag
9697 bool destroyed:1; // true if window is being destroyed
9698 bool anchored:1; // true if this window is repositioned when the parent resizes
9699 bool dirty:1; // Flag set to true if any descendant must be redrawn
9705 bool modifyVirtArea:1;
9706 bool noAutoScrollArea:1;
9709 bool setVisible:1; // FOR FORM DESIGNER
9715 bool useSharedMemory:1;
9718 bool nativeDecorations:1;
9719 bool manageDisplay:1;
9720 bool formDesigner:1; // True if we this is running in the form editor
9721 bool requireRemaximize:1;
9724 // Checks used internally for them not to take effect in FormDesigner
9725 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9726 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9728 WindowController controller;
9729 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9732 public class CommonControl : Window
9734 // creationActivation = doNothing;
9737 public property const String toolTip
9739 property_category $"Appearance"
9742 if(created) CommonControl::OnDestroy();
9744 toolTip = value ? ToolTip { tip = value; } : null;
9746 if(created) CommonControl::OnCreate();
9748 get { return toolTip ? toolTip.tip : null; }
9754 // (Very) Ugly work around for the fact that the parent watcher
9755 // won't fire when it's already been disconnected...
9756 eInstance_FireSelfWatchers(toolTip,
9757 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9763 toolTip.parent = this;
9772 public class Percentage : float
9774 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9778 sprintf(string, "%.2f", this);
9779 c = strlen(string)-1;
9782 if(string[c] != '0')
9783 last = Max(last, c);
9784 if(string[c] == '.')
9797 public void ApplySkin(Class c, const char * name, void ** vTbl)
9799 char className[1024];
9804 subclass(Window) wc = (subclass(Window))c;
9805 subclass(Window) base = (subclass(Window))c.base;
9807 sprintf(className, "%sSkin_%s", name, c.name);
9808 wc.pureVTbl = c._vTbl;
9809 c._vTbl = new void *[c.vTblSize];
9810 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9811 sc = eSystem_FindClass(c.module.application, className);
9815 for(m = 0; m < c.base.vTblSize; m++)
9817 if(c._vTbl[m] == base.pureVTbl[m])
9818 c._vTbl[m] = vTbl[m];
9823 for(m = 0; m < c.vTblSize; m++)
9825 if(sc._vTbl[m] != wc.pureVTbl[m])
9826 c._vTbl[m] = sc._vTbl[m];
9830 for(d = c.derivatives.first; d; d = d.next)
9832 ApplySkin(d.data, name, c._vTbl);
9836 public void UnapplySkin(Class c)
9838 subclass(Window) wc = (subclass(Window))c;
9841 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9844 c._vTbl = wc.pureVTbl;
9848 for(d = c.derivatives.first; d; d = d.next)
9850 UnapplySkin(d.data);
9854 void CheckFontIntegrity(Window window)
9859 if(window.usedFont && window.usedFont.font == 0xecececec)
9861 FontResource uf = window.usedFont;
9862 char * className = window._class.name;
9863 char * text = window.text;
9866 for(c = window.firstChild; c; c = c.next)
9867 CheckFontIntegrity(c);
9871 public class ControllableWindow : Window
9873 /*WindowController controller;
9874 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9875 ~ControllableWindow() { delete controller; }*/
9878 class WindowControllerInterface : ControllableWindow
9880 bool OnKeyDown(Key key, unichar ch)
9882 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9885 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9887 result = onKeyDown(controller.window, key, ch);
9892 bool OnKeyUp(Key key, unichar ch)
9894 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
9897 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
9899 result = onKeyUp(controller.window, key, ch);
9904 bool OnKeyHit(Key key, unichar ch)
9906 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
9909 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
9911 result = onKeyHit(controller.window, key, ch);
9916 bool OnMouseMove(int x, int y, Modifiers mods)
9918 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9921 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
9923 result = onMouseMove(controller.window, x, y, mods);
9928 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9930 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
9933 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
9934 if(onLeftButtonDown)
9935 result = onLeftButtonDown(controller.window, x, y, mods);
9940 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9942 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
9945 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
9947 result = onLeftButtonUp(controller.window, x, y, mods);
9952 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9954 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
9957 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
9958 if(onLeftDoubleClick)
9959 result = onLeftDoubleClick(controller.window, x, y, mods);
9964 bool OnRightButtonDown(int x, int y, Modifiers mods)
9966 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
9969 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
9970 if(onRightButtonDown)
9971 result = onRightButtonDown(controller.window, x, y, mods);
9976 bool OnRightButtonUp(int x, int y, Modifiers mods)
9978 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
9981 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
9983 result = onRightButtonUp(controller.window, x, y, mods);
9988 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9990 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
9993 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
9994 if(onRightDoubleClick)
9995 result = onRightDoubleClick(controller.window, x, y, mods);
10000 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10002 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10005 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10006 if(onMiddleButtonDown)
10007 result = onMiddleButtonDown(controller.window, x, y, mods);
10012 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10014 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10017 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10018 if(onMiddleButtonUp)
10019 result = onMiddleButtonUp(controller.window, x, y, mods);
10024 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10026 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10029 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10030 if(onMiddleDoubleClick)
10031 onMiddleDoubleClick(controller.window, x, y, mods);
10036 void OnResize(int width, int height)
10038 if(controller.OnResize)
10039 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10041 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10043 onResize(controller.window, width, height);
10047 void OnRedraw(Surface surface)
10049 if(controller.OnRedraw)
10050 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10052 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10054 onRedraw(controller.window, surface);
10060 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10063 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10065 result = onCreate(controller.window);
10070 bool OnLoadGraphics()
10072 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10075 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10077 result = onLoadGraphics(controller.window);
10082 void OnUnloadGraphics()
10084 if(controller.OnUnloadGraphics)
10085 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10087 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10088 if(onUnloadGraphics)
10089 onUnloadGraphics(controller.window);
10094 public class WindowController<class V>
10097 property Window window
10101 uint size = class(Window).vTblSize;
10104 windowVTbl = new void *[size];
10105 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10106 if(value._vTbl == value._class._vTbl)
10108 value._vTbl = new void *[value._class.vTblSize];
10109 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10113 for(c = 0; c < size; c++)
10115 void * function = class(WindowControllerInterface)._vTbl[c];
10116 if(function && function != DefaultFunction)
10117 value._vTbl[c] = function;
10119 value._vTbl[c] = windowVTbl[c];
10124 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10127 get { return window; }
10129 property V controlled
10131 set { controlled = value; }
10132 get { return controlled; }
10134 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10135 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10136 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10137 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10138 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10139 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10140 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10141 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10142 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10143 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10144 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10145 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10146 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10147 virtual void V::OnResize(WindowController controller, int width, int height);
10148 virtual void V::OnRedraw(WindowController controller, Surface surface);
10149 virtual bool V::OnCreate(WindowController controller);
10150 virtual bool V::OnLoadGraphics(WindowController controller);
10151 virtual void V::OnUnloadGraphics(WindowController controller);
10154 int (** windowVTbl)();
10158 ~WindowController()