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);
1667 /* TO REVIEW: Redj's code trying to fix position saving
1672 normalAnchor = Anchor { left = x, top = y };
1673 normalSizeAnchor = SizeAnchor { { w, h } };
1680 // (w, h): Full window size
1681 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1683 bool result = false;
1684 int oldCW = clientSize.w, oldCH = clientSize.h;
1685 bool clientResized, windowResized, windowMoved;
1687 //bool realResized = size.w != w || size.h != h;
1689 // TOCHECK: This wasn't in ecere.dll
1690 //if(!parent) return true;
1691 if(destroyed) return false;
1693 windowMoved = position.x != x || position.y != y || force;
1695 // windowResized = realResized || force;
1696 windowResized = size.w != w || size.h != h || force;
1698 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1704 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1705 scrolledPos.x - parent.clientStart.x + this.box.right,
1706 scrolledPos.y - parent.clientStart.y + this.box.bottom
1712 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1717 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1719 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1720 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1721 windowResized = true;
1723 if(display && rootWindow != this)
1726 if(guiApp && guiApp.windowMoving)
1728 if(guiApp.windowMoving.style.nonClient)
1729 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1731 guiApp.windowMoving.parent.SetMouseRangeToClient();
1741 // Buttons bitmap resources crash if we do this while switching mode
1742 if(!guiApp || !guiApp.modeSwitching)
1745 // Process Anchored Children
1749 for(child = children.first; child; child = child.next)
1752 ((child.stateAnchor.left.type != offset ||
1753 child.stateAnchor.top.type != offset ||
1754 child.stateAnchor.right.type != none ||
1755 child.stateAnchor.bottom.type != none) ||
1756 child.state == maximized || child.state == minimized))
1758 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1760 // child.Position(x, y, w, h, false, true, true, true, false);
1761 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1762 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1768 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1769 //if(updateScrollBars)
1771 OnResize(clientSize.w, clientSize.h);
1773 if((clientResized || windowMoved) && created)
1774 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1776 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1778 Window master = guiApp.interimWindow.master;
1779 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1782 if(rootWindow == this && !is3D)
1786 x -= guiApp.desktop.absPosition.x;
1787 y -= guiApp.desktop.absPosition.y;
1789 //guiApp.Log("Position %s\n", caption);
1792 if(windowResized || windowMoved)
1793 if(display && !display.flags.memBackBuffer && changeRootWindow)
1794 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1796 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1797 for(child = parent.children.first; child && child != this; child = child.next)
1798 if(child.rootWindow)
1799 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1804 if(windowMoved || windowResized)
1806 display.Lock(true /*false*/);
1809 display.Position(absPosition.x, absPosition.y);
1810 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1813 // result = realResized ? display.Resize(size.w, size.h) : true;
1814 if(nativeDecorations && rootWindow.windowHandle)
1816 int w = clientSize.w, h = clientSize.h;
1817 if(hasMenuBar) h += skinMenuHeight;
1818 if(hasStatusBar) h += statusBarHeight;
1819 if(sbv && sbv.visible) w += sbv.size.w;
1820 if(sbh && sbh.visible) h += sbh.size.h;
1821 result = manageDisplay ? display.Resize(w, h) : true;
1824 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1828 else if(clientResized)
1830 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1833 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1837 if(windowMoved || windowResized)
1842 if(guiApp.driver && changeRootWindow && windowHandle)
1844 if(windowResized || windowMoved)
1845 if(!display || display.flags.memBackBuffer)
1846 guiApp.interfaceDriver.PositionRootWindow(this,
1847 x, y, w, h, windowMoved, windowResized);
1848 guiApp.interfaceDriver.UpdateRootWindow(this);
1850 for(child = children.first; child; child = child.next)
1852 if(child.is3D && child.created)
1854 // Copy Display Content
1855 child.display.displaySystem = display.displaySystem;
1856 child.display.window = display.window;
1857 child.display.current = display.current;
1858 child.display.width = display.width;
1859 child.display.height = display.height;
1860 child.display.driverData = display.driverData;
1861 child.display.mutex = null;
1872 void UpdateScrollBars(bool flag, bool fullThing)
1875 bool resizeH = false, resizeV = false;
1876 bool scrolled = false;
1877 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1878 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1880 if(destroyed) return;
1881 if(guiApp.currentSkin)
1883 MinMaxValue cw = 0, ch = 0;
1884 bool sbvVisible, sbhVisible;
1885 int rangeH = 0, rangeV = 0;
1886 int positionH = 0, positionV;
1888 // First get client area with no respect to scroll bars
1893 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1895 if(scrollFlags.dontHide)
1898 cw -= guiApp.currentSkin.VerticalSBW();
1900 ch -= guiApp.currentSkin.HorizontalSBH();
1902 // Update the scrollbar visibility
1908 sbh.disabled = rangeH <= 1;
1909 if(sbh.style.hidden)
1919 sbv.disabled = rangeV <= 1;
1920 if(sbv.style.hidden)
1928 int oldHRange = sbh ? sbh.range : 0;
1929 int oldVRange = sbv ? sbv.range : 0;
1930 // Then start off with horizontal scrollbar range
1933 positionH = sbh.thumbPosition;
1940 SBSetTotal(sbh, rvw);
1943 ch -= guiApp.currentSkin.HorizontalSBH();
1946 // Do the same for vertical scrollbar
1949 positionV = sbv.thumbPosition;
1955 SBSetTotal(sbv, rvh);
1959 cw -= guiApp.currentSkin.VerticalSBW();
1960 // Maybe we need to set the range on the horizontal scrollbar again
1968 SBSetTotal(sbh, rvw);
1969 //sbh.Action(setRange, positionH, 0);
1970 if(rangeH <= 1 && sbh.range > 1)
1972 ch -= guiApp.currentSkin.HorizontalSBH();
1978 SBSetTotal(sbv, rvh);
1980 //sbv.Action(setRange, positionV, 0);
1985 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1986 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1989 // Update the scrollbar visibility
1990 if(!scrollFlags.dontHide)
1992 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1996 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
2003 if(guiApp.currentSkin)
2010 sbhVisible = sbh.style.hidden ? true : false;
2012 sbvVisible = sbv.style.hidden ? true : false;
2014 // Do our resize here
2015 if(flag && (resizeH || resizeV) && fullThing)
2017 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
2022 OnResize(clientSize.w, clientSize.h);
2028 sbh.visible = sbhVisible;
2030 sbv.visible = sbvVisible;
2032 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2033 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2036 sbh.pageStep = clientSize.w;
2038 sbv.pageStep = clientSize.h;
2040 // Notify doesn't handle setRange anymore... process it here
2043 int positionH = sbh.thumbPosition;
2044 if(scroll.x != positionH)
2046 OnHScroll(setRange, positionH, 0);
2050 SNAPDOWN(positionH, textCellW);
2051 scroll.x = positionH;
2057 int seen = clientSize.w, total = reqScrollArea.w;
2060 if(scrollFlags.snapX)
2061 SNAPDOWN(seen, sbStep.x);
2063 if(!total) total = seen;
2064 range = total - seen + 1;
2066 range = Max(range, 1);
2068 if(x >= range) x = range - 1;
2070 if(scrollFlags.snapX)
2071 SNAPUP(x, sbStep.x);
2075 OnHScroll(setRange, x, 0);
2080 SNAPDOWN(x, textCellW);
2086 int positionV = sbv.thumbPosition;
2087 if(scroll.y != positionV)
2089 OnVScroll(setRange, positionV, 0);
2093 SNAPDOWN(positionV, textCellH);
2094 scroll.y = positionV;
2100 int seen = clientSize.h, total = reqScrollArea.h;
2103 if(scrollFlags.snapY)
2104 SNAPDOWN(seen, sbStep.y);
2106 if(!total) total = seen;
2107 range = total - seen + 1;
2108 range = Max(range, 1);
2110 if(y >= range) y = range - 1;
2112 if(scrollFlags.snapY)
2113 SNAPUP(y, sbStep.y);
2117 OnVScroll(setRange, y, 0);
2122 SNAPDOWN(y, textCellH);
2128 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2131 for(child = children.first; child; child = child.next)
2133 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2136 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2137 child.Position(x, y, w, h, false, true, false, true, false, false);
2144 // Process Scrollbars
2146 if(sbh) // && !sbh.style.hidden
2149 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2150 // Need to set the range again (should improve...) since the scrollbars didn't have
2151 // the right size when UpdateScrollArea set the range on it
2154 sbh.seen = clientSize.w;
2158 if(sbv) // && !sbv.state.hidden
2161 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2162 // Need to set the range again (should improve...) since the scrollbars didn't have
2163 // the right size when UpdateScrollArea set the range on it
2166 sbv.seen = clientSize.h;
2171 // TESTING THIS LOWER
2172 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2175 for(child = children.first; child; child = child.next)
2177 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2180 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2181 child.Position(x, y, w, h, false, true, false, true, false, false);
2187 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2189 SetState(maximized, false, mods);
2193 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2195 SetState(normal, false, mods);
2199 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2201 SetState(minimized, false, mods);
2202 parent.CycleChildren(false, true, false, true);
2206 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2209 // Scroll bar notifications
2210 if(action != setRange)
2212 bool changed = false;
2216 if(scroll.x != position)
2218 OnHScroll(action, position, keyFlags);
2223 SNAPDOWN(position, textCellW);
2225 scroll.x = position;
2229 if(scroll.y != position)
2231 OnVScroll(action, position, keyFlags);
2236 SNAPDOWN(position, textCellH);
2238 scroll.y = position;
2242 bool childMove = false;
2243 for(child = children.first; child; child = child.next)
2245 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2248 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2249 child.Position(x, y, w, h, false, true, false, true, false, false);
2253 // Testing this patch out to solve MDI workspace redraw bugs
2254 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2255 // Scroll offsets to blame?
2259 UpdateCaret(false, false);
2263 // Testing this patch out to solve MDI workspace redraw bugs
2264 for(child = children.first; child; child = child.next)
2266 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2275 Window GetParentMenuBar()
2277 Window menuBarParent;
2278 if(formDesigner) return null;
2279 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2281 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2282 if(menuBarParent && !menuBarParent.isActiveClient)
2288 void CreateSystemChildren(void)
2290 Window parent = this;
2291 bool scrollBarChanged = false;
2292 bool hasClose = false, hasMaxMin = false;
2293 Point scroll = this.scroll;
2295 if(state == maximized)
2297 parent = GetParentMenuBar();
2304 if(style.hasClose) hasClose = true;
2305 if(style.hasMaximize || style.hasMinimize)
2312 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2314 sysButtons[2].Destroy(0);
2315 sysButtons[2] = null;
2317 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2319 sysButtons[1].Destroy(0);
2320 sysButtons[1] = null;
2322 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2324 sysButtons[0].Destroy(0);
2325 sysButtons[0] = null;
2328 if(hasClose && parent)
2335 parent, master = this,
2336 inactive = true, nonClient = true, visible = false;
2338 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2344 if(this.parent == guiApp.desktop)
2345 sysButtons[2].hotKey = altF4;
2346 else if(style.isActiveClient)
2347 sysButtons[2].hotKey = ctrlF4;
2348 sysButtons[2].Create();
2351 sysButtons[2].symbol = 'X';
2352 sysButtons[2].disabled = !style.hasClose;
2355 if(hasMaxMin && parent)
2359 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2360 if(state == maximized)
2363 method = RestoreButtonClicked;
2369 method = MaximizeButtonClicked;
2377 parent, master = this,
2378 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2380 sysButtons[1].Create();
2382 sysButtons[1].NotifyClicked = method;
2384 sysButtons[1].symbol = symbol;
2385 sysButtons[1].disabled = !style.hasMaximize;
2388 if(hasMaxMin && parent)
2392 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2393 if (state == minimized)
2396 method = RestoreButtonClicked;
2402 method = MinimizeButtonClicked;
2410 parent, master = this,
2411 hotKey = altM, inactive = true, nonClient = true, visible = false
2413 sysButtons[0].Create();
2415 sysButtons[0].NotifyClicked = method;
2417 sysButtons[0].symbol = symbol;
2418 sysButtons[0].disabled = !style.hasMinimize;
2421 // Create the scrollbars
2422 if(style.hasHorzScroll && !sbh)
2428 direction = horizontal,
2432 snap = scrollFlags.snapX,
2433 NotifyScrolling = ScrollBarNotification
2436 scrollBarChanged = true;
2438 else if(sbh && !style.hasHorzScroll)
2444 if(style.hasVertScroll && !sbv)
2450 direction = vertical,
2454 snap = scrollFlags.snapY,
2455 NotifyScrolling = ScrollBarNotification
2458 scrollBarChanged = true;
2460 else if(sbv && !style.hasVertScroll)
2465 if(scrollBarChanged)
2467 SetScrollLineStep(sbStep.x, sbStep.y);
2468 UpdateScrollBars(true, true);
2472 if(scrollBarChanged)
2474 if(sbh) sbh.thumbPosition = scroll.x;
2475 if(sbv) sbv.thumbPosition = scroll.y;
2479 void UpdateCaption(void)
2481 if(rootWindow == this)
2484 FigureCaption(caption);
2485 if(guiApp.interfaceDriver)
2486 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2488 UpdateDecorations();
2491 if(parent.activeClient == this) // Added this last check
2493 if(parent.rootWindow == parent)
2496 parent.FigureCaption(caption);
2497 if(guiApp.interfaceDriver)
2498 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2501 parent.UpdateCaption();
2503 parent.UpdateDecorations();
2507 void UpdateActiveDocument(Window previous)
2509 Window activeClient = this.activeClient;
2510 Window activeChild = this.activeChild;
2517 activeClient.CreateSystemChildren();
2519 previous.CreateSystemChildren();
2531 // Build window list
2534 Menu windowMenu = menu.FindMenu("Window");
2539 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2541 Window document = cycle.data;
2542 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2544 char name[2048], caption[2048];
2545 document.FigureCaption(caption);
2546 sprintf(name, "%d %s", id+1, caption);
2547 windowMenu.AddDynamic(MenuItem
2549 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2550 NotifySelect = MenuWindowSelectWindow
2554 if(activeClient.cycle == cycle) break;
2559 if((!previous && activeClient) || !activeClient)
2565 item = menu.FindItem(MenuWindowCloseAll, 0);
2566 if(item) item.disabled = false;
2567 item = menu.FindItem(MenuWindowNext, 0);
2568 if(item) item.disabled = false;
2569 item = menu.FindItem(MenuWindowPrevious, 0);
2570 if(item) item.disabled = false;
2571 item = menu.FindItem(MenuWindowCascade, 0);
2572 if(item) item.disabled = false;
2573 item = menu.FindItem(MenuWindowTileHorz, 0);
2574 if(item) item.disabled = false;
2575 item = menu.FindItem(MenuWindowTileVert, 0);
2576 if(item) item.disabled = false;
2577 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2578 if(item) item.disabled = false;
2579 item = menu.FindItem(MenuWindowWindows, 0);
2580 if(item) item.disabled = false;
2583 item = menu.FindItem(MenuFileClose, 0);
2584 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2585 item = menu.FindItem(MenuFileSaveAll, 0);
2586 if(item) item.disabled = numDocuments < 1;
2588 if(activeClient && activeClient.menu && activeClient.state != minimized)
2592 //activeClient.menu.Clean(activeClient);
2593 menu.Merge(activeClient.menu, true, activeClient);
2597 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2600 menu.Merge(activeChild.menu, true, activeChild);
2603 // This is called again for a child window change, with same active client
2604 OnActivateClient(activeClient, previous);
2605 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2606 parent.UpdateActiveDocument(null);
2609 void _ShowDecorations(Box box, bool post)
2611 if(rootWindow == this && nativeDecorations && !is3D) return;
2612 if(visible && this != guiApp.desktop)
2614 Surface surface = RedrawFull(box);
2618 FigureCaption(caption);
2621 ShowDecorations(captionFont.font,
2624 active, //parent.activeClient == this
2625 guiApp.windowMoving == this);
2627 PreShowDecorations(captionFont.font,
2630 active, //parent.activeClient == this
2631 guiApp.windowMoving == this);
2638 void UpdateExtent(Box refresh)
2640 Surface surface = null;
2642 if(!manageDisplay) { OnRedraw(null);return; }
2643 _ShowDecorations(refresh, false);
2645 surface = Redraw(refresh);
2646 // Opaque background: just fill before EW_REDRAW (clear?)
2649 surface.SetBackground(background);
2650 surface.SetForeground(foreground);
2651 surface.DrawingChar(' ');
2652 if(this == rootWindow)
2654 if(style.drawBehind || background.a)
2656 int a = background.a;
2657 // Premultiply alpha for clear color
2658 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2659 surface.Clear(colorBuffer);
2660 surface.SetBackground(background);
2663 else if(background.a)
2667 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2668 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2671 if(display.flags.alpha && background.a < 255 && background)
2673 surface.Area(0,0,clientSize.w, clientSize.h);
2674 /*if(style.clearDepthBuffer)
2675 surface.Clear(depthBuffer);*/
2677 else if(/*style.clearDepthBuffer || */background.a)
2679 int a = background.a;
2680 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2681 // Premultiply alpha for clear color
2682 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2683 surface.Clear(colorBuffer);
2684 surface.SetBackground(background);
2689 surface.TextFont(usedFont.font);
2690 surface.TextOpacity(false);
2694 // Draw the caret ...
2695 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2697 // surface.SetBackground(0xFFFFFF - background.color);
2698 surface.SetBackground(~background.color);
2700 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2701 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2707 void DrawOverChildren(Box refresh)
2709 Surface surface = Redraw(refresh);
2713 surface.DrawingChar(' ');
2714 surface.SetBackground(background);
2715 surface.SetForeground(foreground);
2717 surface.TextFont(usedFont.font);
2718 surface.TextOpacity(false);
2720 OnDrawOverChildren(surface);
2725 _ShowDecorations(refresh, true);
2728 void ComputeClipExtents(void)
2731 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2733 clipExtent.Copy(this.clipExtent);
2735 for(child = children.last; child; child = child.prev)
2737 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2739 bool opaque = child.IsOpaque(); // TODO: acess background directly
2740 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2742 child.clipExtent.Copy(clipExtent);
2743 child.clipExtent.Offset(-dx, -dy);
2744 child.clipExtent.IntersectBox(child.box);
2746 child.ComputeClipExtents();
2748 if(opaque && !child.style.nonClient)
2750 // Adjust the box for the parent:
2751 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2752 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2757 // ??? Only do this for overlapped window or if parent has with clip children flag
2759 // Do this if window has clip children flag on (default false?)
2760 // this.clipExtent = clipExtent;
2762 clipExtent.Free(null);
2765 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2768 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2769 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2771 offsetX -= rootWindow.clientStart.x;
2772 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2776 for(child = children.last; child; child = child.prev)
2778 bool opaque = child.IsOpaque();
2779 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2783 // Adjust renderArea to the root window level
2784 Extent * renderArea = &rootWindow.tempExtents[3];
2786 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2787 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2788 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2790 offsetX -= child.rootWindow.clientStart.x;
2791 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2795 Extent childRenderArea;
2797 if(backBufferUpdate != null)
2799 childRenderArea.Copy(backBufferUpdate);
2800 childRenderArea.Offset(-offsetX, -offsetY);
2803 childRenderArea.Copy(child.dirtyArea);
2805 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2806 renderArea.Copy(dirtyExtent);
2807 renderArea.Offset(-offsetX, -offsetY);
2808 childRenderArea.Union(renderArea);
2811 // Intersect with the clip extent
2812 childRenderArea.Intersection(child.clipExtent);
2815 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2817 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2818 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2820 renderArea->Offset(offsetX, offsetY);
2822 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2823 // overDirtyExtent.Union(renderArea);
2824 renderArea->Empty();
2825 // childRenderArea.Free();
2827 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2832 for(child = children.last; child; child = child.prev)
2834 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2836 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2841 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2843 bool opaque = IsOpaque();
2844 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2846 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2847 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2849 offsetX -= rootWindow.clientStart.x;
2850 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2854 for(child = children.last; child; child = child.prev)
2856 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2858 ColorAlpha background = *(ColorAlpha *)&child.background;
2859 bool opaque = child.IsOpaque();
2860 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2864 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2865 // Adjust renderArea to the root window level
2867 renderArea.Copy(child.dirtyArea);
2868 renderArea.Offset(offsetX, offsetY);
2869 dirtyExtent.Union(renderArea);
2870 overDirtyExtent.Union(renderArea);
2876 for(child = children.last; child; child = child.prev)
2878 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2880 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2884 if(backBufferUpdate != null)
2886 renderArea.Copy(backBufferUpdate);
2887 renderArea.Offset(-offsetX, -offsetY);
2889 overRenderArea.Copy(backBufferUpdate);
2890 overRenderArea.Offset(-offsetX, -offsetY);
2896 renderArea.Copy(dirtyArea);
2898 overRenderArea.Copy(dirtyArea);
2901 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2902 dirtyExtentWindow->Copy(dirtyExtent);
2903 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2904 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2905 dirtyExtentWindow->Empty();
2907 // Intersect with the clip extent
2908 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2911 if(renderArea.count > 10)
2914 printf("\nToo many extents (%d):\n", renderArea.count);
2916 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2917 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2922 for(c = 0; c<10; c++)
2925 FASTLIST_LOOP(renderArea, extentBox)
2927 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2929 renderArea.Copy(extent);
2931 FASTLIST_LOOP(renderArea, extentBox)
2934 printf("(%d, %d) - (%d, %d)\n",
2935 extentBox.box.left, extentBox.box.top,
2936 extentBox.box.right, extentBox.box.bottom);
2940 printf("\nNow %d\n", renderArea.count);
2946 // WHY WAS THIS COMMENTED ??
2948 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2949 dirtyExtentWindow->Copy(overDirtyExtent);
2950 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2951 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2952 dirtyExtentWindow->Empty();
2954 // Intersect with the clip extent
2955 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2961 if(scrollExtent.count)
2963 // Subtract render extent from scrolling extent
2964 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2966 if(backBufferUpdate == null)
2968 Extent * dirty = &rootWindow.tempExtents[3];
2971 // Intersect scrolling extent with clip extent
2972 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2974 // offset this scroll to be at the root window level
2975 scrollExtent.Offset(offsetX, offsetY);
2976 // Add area that was scrolled to the dirty extents of the back buffer
2977 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2981 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2982 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2983 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2988 scrollExtent.Empty();
2990 // Add the exposed extent to the window render area
2991 dirty->Offset(-offsetX, -offsetY);
2992 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2997 // Subtract the window's box from the transparency forced extent
2998 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
3004 renderArea.Copy(this.renderArea);
3005 renderArea.Offset(offsetX, offsetY);
3006 dirtyExtent.Union(renderArea);
3012 Extent renderArea { };
3014 renderArea.Copy(overRenderArea);
3015 renderArea.Offset(offsetX, offsetY);
3016 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
3021 if(backBufferUpdate != null)
3023 // Remove render area from dirty area
3024 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
3026 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3033 // Remove the window render area from the dirty extents of the back buffer
3034 rootWindow.dirtyBack.Exclusion(renderArea);
3038 void Render(Extent updateExtent)
3042 Window rootWindow = this.rootWindow;
3043 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3044 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3046 offsetX -= rootWindow.clientStart.x;
3047 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3050 if(rootWindow.fullRender)
3059 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3060 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3065 /*if(renderArea.count)
3066 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3069 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3071 Box box = extentBox.box;
3074 /*printf("(%d, %d) - (%d, %d)\n",
3075 extentBox.box.left, extentBox.box.top,
3076 extentBox.box.right, extentBox.box.bottom);*/
3081 box.left += offsetX;
3083 box.right += offsetX;
3084 box.bottom += offsetY;
3086 if(updateExtent != null)
3087 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3091 for(child = children.first; child; child = child.next)
3092 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3093 child.Render(updateExtent);
3095 if(rootWindow.fullRender)
3096 DrawOverChildren(box);
3099 // TO DO: There's an issue about draw over children...
3100 // TO DO: Don't wanna go through this if method isn't used
3101 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3102 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3104 Box box = extentBox.box;
3106 DrawOverChildren(box);
3108 box.left += offsetX;
3110 box.right += offsetX;
3111 box.bottom += offsetY;
3113 if(updateExtent != null)
3114 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3117 for(child = children.first; child; child = child.next)
3118 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3119 child.Render(updateExtent);
3122 overRenderArea.Empty();
3125 public void UpdateDisplay(void)
3127 if(!manageDisplay) { OnRedraw(null);return; }
3128 if(rootWindow && this != rootWindow)
3129 rootWindow.UpdateDisplay();
3132 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3133 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3136 dirtyExtent.Clear();
3139 clipExtent.AddBox(box);
3141 display.StartUpdate();
3143 if(!rootWindow.fullRender)
3145 ComputeClipExtents();
3146 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3147 ComputeRenderArea(dirtyExtent, overExtent, null);
3150 clipExtent.Free(null);
3152 dirtyExtent.Free(null);
3153 overExtent.Free(null);
3155 if(display.flags.flipping)
3158 display.Update(null);
3162 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3163 updateExtent.Clear();
3165 Render(updateExtent);
3167 updateExtent.UnionBox(this.box, tempExtents[0]);
3170 //printf("\n\nUpdate:\n------------------------------------------\n");
3173 //FASTLIST_LOOP(updateExtent, extentBox)
3174 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3177 /*printf("Updating (%d, %d) - (%d, %d)\n",
3178 extentBox.box.left, extentBox.box.top,
3179 extentBox.box.right, extentBox.box.bottom);*/
3182 display.Update(extentBox.box);
3185 updateExtent.Free(null);
3188 display.EndUpdate();
3196 void UpdateBackDisplay(Box box)
3202 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3204 //printf("UpdateBackDisplay going through!\n");
3205 display.StartUpdate();
3209 intersection.Copy(dirtyBack);
3210 intersection.IntersectBox(box);
3212 dirtyExtent.Clear();
3215 clipExtent.AddBox(box);
3217 if(!rootWindow.fullRender)
3219 ComputeClipExtents();
3220 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3223 clipExtent.Free(null);
3225 intersection.Free(null);
3226 dirtyExtent.Free(null);
3227 overExtent.Free(null);
3232 if(display.flags.flipping)
3233 display.Update(null);
3236 rootWindow.display.Update(box);
3239 display.EndUpdate();
3243 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3244 if(dirtyBack.count > MAX_DIRTY_BACK)
3246 BoxItem extentBox, next;
3247 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3248 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3250 next = (BoxItem)extentBox.next;
3251 if(extentBox != first)
3253 if(extentBox.box.left < first.box.left)
3254 first.box.left = extentBox.box.left;
3255 if(extentBox.box.top < first.box.top)
3256 first.box.top = extentBox.box.top;
3257 if(extentBox.box.right > first.box.right)
3258 first.box.right = extentBox.box.right;
3259 if(extentBox.box.bottom > first.box.bottom)
3260 first.box.bottom = extentBox.box.bottom;
3261 dirtyBack.Delete(extentBox);
3270 // --- Window positioning ---
3271 // --- Window identification ---
3273 // Returns window at position "Position"
3274 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3276 Window child, result = null;
3278 box.left += absPosition.x;
3279 box.right += absPosition.x;
3280 box.top += absPosition.y;
3281 box.bottom += absPosition.y;
3283 if(!destroyed && visible && (acceptDisabled || !disabled))
3285 int lx = x - absPosition.x;
3286 int ly = y - absPosition.y;
3287 if(IsInside(lx, ly))
3288 // if(box.IsPointInside(Point{x, y}))
3290 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3291 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3294 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3295 Window ancestor = null;
3297 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3298 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3300 if(child != statusBar && child.rootWindow == rootWindow)
3302 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3309 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3311 if(child != statusBar && child.rootWindow == rootWindow)
3313 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3320 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3328 Window FindModal(void)
3330 Window modalWindow = this, check;
3331 Window check2 = null;
3332 for(check = this; check.master; check = check.master)
3334 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3336 modalWindow = check.master.modalSlave;
3337 check = modalWindow;
3339 // TESTING THIS FOR DROPBOX...
3340 if(!rootWindow || !rootWindow.style.interim)
3342 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3344 if(check2.modalSlave && check2.modalSlave.created)
3346 modalWindow = check2.modalSlave;
3354 if(modalWindow == this)
3356 for(check = this; check.activeChild; check = check.activeChild)
3358 if(check.modalSlave)
3360 modalWindow = check.modalSlave;
3366 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3367 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3370 void StopMoving(void)
3372 if(this == guiApp.windowMoving)
3374 guiApp.windowMoving = null;
3375 UpdateDecorations();
3376 SetMouseRange(null);
3379 if(rootWindow.active)
3380 guiApp.interfaceDriver.StopMoving(rootWindow);
3382 guiApp.windowCaptured.ReleaseCapture();
3383 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3384 guiApp.windowIsResizing = false;
3388 void SelectMouseCursor(void)
3393 Window cursorWindow = null;
3394 bool rx, ry, rex, rey;
3396 guiApp.desktop.GetMousePosition(&x, &y);
3397 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3399 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3400 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3401 else if(mouseWindow)
3403 modalWindow = mouseWindow.FindModal();
3404 x -= mouseWindow.absPosition.x;
3405 y -= mouseWindow.absPosition.y;
3406 if(guiApp.windowIsResizing)
3408 rex = guiApp.resizeEndX;
3409 rey = guiApp.resizeEndY;
3410 rx = guiApp.resizeX;
3411 ry = guiApp.resizeY;
3412 if((rex && rey) || (rx && ry))
3413 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3414 else if((rex && ry) || (rx && rey))
3415 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3416 else if((ry || rey) && (!rx && !rex))
3417 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3418 else if((rx || rex) && (!ry && !rey))
3419 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3421 else if(!modalWindow && !guiApp.windowCaptured &&
3422 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3423 &rx, &ry, &rex, &rey))
3425 if((rex && rey) || (rx && ry))
3426 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3427 else if((rex && ry) || (rx && rey))
3428 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3429 else if((ry || rey) && (!rx && !rex))
3430 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3431 else if((rx || rex) && (!ry && !rey))
3432 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3434 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3436 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3437 mouseWindow.rootWindow != mouseWindow)
3438 cursorWindow = mouseWindow.parent;
3440 cursorWindow = mouseWindow;
3442 else if(!guiApp.interimWindow)
3443 cursorWindow = guiApp.windowCaptured;
3446 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3447 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3449 else if(modalWindow)
3451 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3453 else if(guiApp.interimWindow)
3455 if(guiApp.interimWindow.cursor)
3456 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3458 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3463 // --- State based input ---
3464 bool AcquireInputEx(bool state)
3469 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3470 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3472 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3474 guiApp.acquiredWindow = state ? this : null;
3477 SetMouseRangeToClient();
3478 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3483 SelectMouseCursor();
3485 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3489 // --- Window activation ---
3490 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3493 if(!parent || !parent.style.inactive)
3495 Window parent = this.parent;
3498 if(rootWindow == this)
3499 Log(active ? "active\n" : "inactive\n");
3501 if(active && requireRemaximize)
3503 if(state == maximized)
3505 property::state = normal;
3506 property::state = maximized;
3508 requireRemaximize = false;
3511 // Testing this here...
3512 if(!parent || parent == guiApp.desktop || parent.active)
3514 this.active = active;
3517 // TESTING THIS HERE
3518 UpdateDecorations();
3519 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3520 result = NotifyActivate(master, this, active, previous);
3523 this.active = !active;
3528 if(!parent || parent == guiApp.desktop || parent.active)
3530 this.active = active;
3532 AcquireInputEx(active);
3533 if(active && isEnabled)
3537 if(guiApp.caretOwner)
3541 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3542 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3543 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3544 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3546 guiApp.caretOwner.Update(extent);
3549 if(visible || !guiApp.caretOwner)
3550 guiApp.caretOwner = this;
3551 UpdateCaret(false, false);
3557 this.active = false;
3559 AcquireInputEx(active);
3561 if(!active && guiApp.caretOwner == this)
3563 UpdateCaret(false, true);
3564 guiApp.caretOwner = null;
3565 guiApp.interfaceDriver.SetCaret(0,0,0);
3566 guiApp.caretEnabled = false;
3571 if(!active && parent && parent.activeChild && parent.activeChild != this)
3572 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3578 if(!active && menuBar)
3581 menuBar.OnActivate(false, null, &goOn, true);
3582 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3587 Window aChild = activeChild;
3589 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3601 void ConsequentialMouseMove(bool kbMoving)
3605 if(kbMoving || !guiApp.windowMoving)
3609 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3611 if(guiApp.interfaceDriver)
3612 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3614 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3615 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3621 bool IsDescendantOf(Window ancestor)
3624 for(window = this; window && window != ancestor; window = window.parent);
3625 return window == ancestor;
3628 bool IsSlaveOf(Window master)
3631 for(window = this; window && window != master; window = window.master);
3632 return window == master;
3635 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3639 if(this && !destroyed /*&& state != Hidden*/)
3641 Window swap = externalSwap;
3649 if(activateParent &&
3650 (parent.activeChild != this ||
3651 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3652 active && _isModal &&
3653 parent != master && master)
3654 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3660 bool real = parent.activeChild != this;
3662 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3663 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3664 !IsDescendantOf(guiApp.interimWindow) &&
3665 !IsSlaveOf(guiApp.interimWindow))
3667 Window interimWindow = guiApp.interimWindow;
3668 while(interimWindow && interimWindow != this)
3670 Window master = interimWindow.master;
3672 guiApp.interimWindow = null;
3673 if(guiApp.caretOwner)
3674 guiApp.caretOwner.UpdateCaret(false, false);
3676 incref interimWindow;
3677 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3682 delete interimWindow;
3683 interimWindow = (master && master.style.interim) ? master : null;
3688 guiApp.interimWindow = this;
3689 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3690 guiApp.caretEnabled = false;*/
3691 UpdateCaret(false, true);
3696 //bool acquireInput = false;
3698 parent.activeChild &&
3699 parent.activeChild.state == maximized &&
3700 parent != guiApp.desktop;
3702 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3707 swap = parent.activeChild;
3708 if(swap && swap.destroyed) swap = null;
3709 if(swap && swap != this)
3712 if(!swap.PropagateActive(false, this, &goOn, true))
3713 swap = parent.activeChild;
3724 if(!parent || parent.activeChild != this || style.interim)
3727 result = PropagateActive(true, swap, &goOn, true);
3728 if(!result && !goOn)
3733 //acquireInput = true;
3737 if(style.hasMaximize && parent != guiApp.desktop)
3740 SetState(maximized, false, 0);
3741 else if(state != maximized)
3744 for(child = parent.children.first; child; child = child.next)
3746 if(this != child && child.state == maximized)
3747 child.SetState(normal, false, 0);
3754 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3756 Window previous = parent.activeClient;
3757 parent.activeChild = this;
3758 if(!style.nonClient /*&& style.isActiveClient*/)
3762 if(style.isActiveClient)
3763 parent.activeClient = this;
3764 // Moved UpdateActiveDocument inside hidden check
3765 // To prevent activating previous window while creating a new one
3766 // (It was messing up the privateModule in the CodeEditor)
3767 parent.UpdateActiveDocument(previous);
3773 //if(!style.isRemote)
3775 if(rootWindow != this)
3777 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3778 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3780 else if(!guiApp.fullScreenMode)
3782 Window modalRoot = FindModal();
3783 if(!modalRoot) modalRoot = this;
3784 if(!modalRoot.isForegroundWindow)
3786 modalRoot.isForegroundWindow = true;
3787 // To check : Why is parent null?
3788 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3790 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3792 modalRoot.isForegroundWindow = false;
3797 if(result && real && (!style.inactive || moveInactive) && parent)
3799 Window last = parent.children.last;
3801 if(!style.stayOnTop)
3802 for(; last && last.style.stayOnTop; last = last.prev);
3804 parent.children.Move(this, last);
3806 // Definitely don't want that: why not?
3810 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3816 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3823 parent.activeChild = null;
3824 if(!style.nonClient /*&& style.isActiveClient*/)
3826 Window previous = parent.activeClient;
3827 if(style.isActiveClient)
3828 parent.activeClient = null;
3829 parent.UpdateActiveDocument(previous);
3833 if(this == guiApp.interimWindow)
3835 guiApp.interimWindow = null;
3836 if(guiApp.caretOwner)
3837 guiApp.caretOwner.UpdateCaret(false, false);
3839 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3846 if(!active || !swap)
3847 UpdateDecorations();
3849 swap.UpdateDecorations();
3851 if(active && rootWindow != this)
3852 ConsequentialMouseMove(false);
3859 // --- Input Messages ---
3860 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3862 static bool reEntrancy = false;
3863 if(reEntrancy) return;
3867 guiApp.cursorUpdate = true;
3868 if(guiApp.windowScrolling && !consequential)
3870 guiApp.windowScrolling.SetScrollPosition(
3871 (guiApp.windowScrolling.sbh) ?
3872 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3873 (guiApp.windowScrolling.sbv) ?
3874 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3876 if(guiApp.windowMoving)
3878 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3880 Window window = guiApp.windowMoving;
3882 int w = window.size.w;
3883 int h = window.size.h;
3888 rx = mouseX - guiApp.windowMovingStart.x;
3889 ry = mouseY - guiApp.windowMovingStart.y;
3892 window.GetDecorationsSize(&ew, &eh);
3894 if(guiApp.windowIsResizing)
3896 x = window.scrolledPos.x;
3897 y = window.scrolledPos.y;
3901 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3902 rx = guiApp.windowResizingBefore.w - aw;
3903 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3904 w = guiApp.windowResizingBefore.w - rx;
3908 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3909 ry = guiApp.windowResizingBefore.h - ah;
3910 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3911 ry = Max(ry, -guiApp.windowMovingBefore.y);
3912 h = guiApp.windowResizingBefore.h - ry;
3914 if(guiApp.resizeEndX)
3916 w = guiApp.windowResizingBefore.w + rx;
3919 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3927 w = Max(w, window.minSize.w);
3928 h = Max(h, window.minSize.h);
3929 w = Min(w, window.maxSize.w);
3930 h = Min(h, window.maxSize.h);
3932 if(!window.OnResizing(&w, &h))
3934 w = window.clientSize.w;
3935 h = window.clientSize.h;
3938 w = Max(w, window.skinMinSize.w);
3939 h = Max(h, window.skinMinSize.h);
3946 SNAPDOWN(w, textCellW);
3947 SNAPDOWN(h, textCellH);
3952 aw = Max(w,window.skinMinSize.w);
3953 rx = guiApp.windowResizingBefore.w - aw;
3954 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3955 w = guiApp.windowResizingBefore.w - rx;
3959 ah = Max(h,window.skinMinSize.h);
3960 ry = guiApp.windowResizingBefore.h - ah;
3961 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3962 ry = Max(ry, -guiApp.windowMovingBefore.y);
3963 h = guiApp.windowResizingBefore.h - ry;
3968 if(!guiApp.windowIsResizing || guiApp.resizeX)
3969 x = guiApp.windowMovingBefore.x + rx;
3970 if(!guiApp.windowIsResizing || guiApp.resizeY)
3971 y = guiApp.windowMovingBefore.y + ry;
3973 if(!guiApp.windowIsResizing)
3976 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3978 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3979 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3980 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3981 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3985 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3986 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3992 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3994 if(!window.OnMoving(&x, &y, w, h))
3996 x = window.scrolledPos.x;
3997 y = window.scrolledPos.y;
4003 SNAPDOWN(x, textCellW);
4004 SNAPDOWN(y, textCellH);
4007 if(!window.style.nonClient)
4009 if(!window.style.fixed /*|| window.style.isDocument*/)
4011 if(!window.style.dontScrollHorz)
4012 x += window.parent.scroll.x;
4013 if(!window.style.dontScrollVert)
4014 y += window.parent.scroll.y;
4018 // Break the anchors for moveable/resizable windows
4019 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
4020 if(window.style.fixed)
4022 if(window.state == normal)
4024 window.normalAnchor = Anchor { left = x, top = y };
4025 window.normalSizeAnchor = SizeAnchor { { w, h } };
4026 window.anchored = false;
4030 window.stateAnchor = Anchor { left = x, top = y };
4031 window.stateSizeAnchor = SizeAnchor { { w, h } };
4033 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4034 // TOCHECK: Investigate why the following only redraws the scrollbars
4035 //window.Position(x, y, w, h, false, true, true, true, false, true);
4037 guiApp.movingLast.x = mouseX;
4038 guiApp.movingLast.y = mouseY;
4044 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4047 bool wasMoving = guiApp.windowMoving ? true : false;
4048 bool wasScrolling = guiApp.windowScrolling ? true : false;
4050 while(result && w != this)
4052 Window msgWindow = GetAtPosition(x,y, false, true, w);
4053 Window trueWindow = GetAtPosition(x,y, false, false, w);
4054 bool windowDragged = false;
4059 window = (w && !w.disabled) ? w : null;
4061 if(trueWindow) incref trueWindow;
4063 if(consequential) mods->isSideEffect = true;
4065 UpdateMouseMove(x, y, consequential);
4067 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4069 if(!guiApp.windowCaptured.isEnabled)
4070 guiApp.windowCaptured.ReleaseCapture();
4072 window = guiApp.windowCaptured;
4075 if(trueWindow && activate &&
4076 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4077 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4078 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4079 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4081 if(mods->alt && !mods->ctrl && !mods->shift)
4083 Window moved = trueWindow;
4084 for(moved = trueWindow; moved; moved = moved.parent)
4085 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4090 windowDragged = true;
4092 // Cancel the ALT menu toggling...
4093 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4098 if(window && activate &&
4099 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4100 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4101 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4102 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4104 Window modalWindow = window.FindModal();
4106 /*if(mods->alt && !mods->shift && !mods->ctrl)
4108 Window moved = window;
4109 for(moved = window; moved; moved = moved.parent)
4110 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4115 windowDragged = true;
4117 // Cancel the ALT menu toggling...
4118 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4124 Window activateWindow = modalWindow ? modalWindow : window;
4125 if(activateWindow && !activateWindow.isRemote)
4127 bool doActivation = true;
4128 //bool needToDoActivation = false;
4129 Window check = activateWindow;
4131 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4133 if(!check.style.inactive)
4135 //needToDoActivation = true;
4137 doActivation = false;
4142 if(!needToDoActivation)
4143 doActivation = false;
4146 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4147 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4149 // Let the OnLeftButtonDown do the activating instead
4150 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4158 incref activateWindow;
4159 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4161 delete activateWindow;
4165 if(activateWindow._refCount == 1)
4167 delete activateWindow;
4171 delete activateWindow;
4172 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4175 mods->isActivate = true;
4179 if(!modalWindow && window && !window.destroyed)
4181 if(!guiApp.windowCaptured || windowDragged)
4183 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4185 bool moving = ((window.state != maximized &&
4186 window.IsMouseMoving(
4187 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4188 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4190 if(!moving && window.IsMouseResizing(
4191 x - window.absPosition.x,
4192 y - window.absPosition.y,
4193 window.size.w, window.size.h,
4194 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4196 guiApp.windowIsResizing = true;
4197 guiApp.windowResizingBefore.w = window.size.w;
4198 guiApp.windowResizingBefore.h = window.size.h;
4200 if(guiApp.windowIsResizing || windowDragged || moving)
4203 guiApp.windowMoving = window;
4204 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4205 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4206 guiApp.windowMovingBefore.x = window.position.x;//s;
4207 guiApp.windowMovingBefore.y = window.position.y;//s;
4208 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4209 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4212 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4214 if(window.style.fixed &&
4216 window.IsMouseMoving(
4217 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4219 window.ShowSysMenu(x, y);
4223 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4225 if(window.sbv || window.sbh)
4228 guiApp.windowScrolling = window;
4229 guiApp.windowScrollingStart.x = x;
4230 guiApp.windowScrollingStart.y = y;
4231 guiApp.windowScrollingBefore.x = window.scroll.x;
4232 guiApp.windowScrollingBefore.y = window.scroll.y;
4235 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4237 if(window.style.hasMaximize &&
4238 window.IsMouseMoving(
4239 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4242 (window.state == maximized) ? normal : maximized, false, *mods);
4250 if(guiApp.windowMoving)
4252 if(guiApp.windowMoving.parent)
4254 if(guiApp.windowMoving.style.nonClient)
4255 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4257 guiApp.windowMoving.parent.SetMouseRangeToClient();
4261 window.UpdateDecorations();
4264 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4266 // Log("\n*** LEFT BUTTON UP ***\n");
4267 if(guiApp.windowMoving)
4268 guiApp.windowMoving.StopMoving();
4270 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4272 if(guiApp.windowScrolling)
4274 Window windowScrolling = guiApp.windowScrolling;
4275 guiApp.windowScrolling = null;
4276 windowScrolling.ReleaseCapture();
4280 if(!result || (window && window.destroyed)) window = null;
4282 if(window && window.FindModal())
4285 if(trueWindow && trueWindow.FindModal())
4293 msgWindow = GetAtPosition(x,y, true, false);
4295 msgWindow.SelectMouseCursor();
4298 if(guiApp.windowCaptured || trueWindow)
4300 Window prevWindow = guiApp.prevWindow;
4301 List<Window> overWindows = guiApp.overWindows;
4302 Iterator<Window> it { overWindows };
4307 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4310 result = w.OnMouseLeave(*mods);
4312 overWindows.TakeOut(w);
4316 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4318 guiApp.prevWindow.mouseInside = false;
4319 guiApp.prevWindow = null;
4323 if(trueWindow.IsDescendantOf(prevWindow))
4325 if(!overWindows.Find(prevWindow))
4326 overWindows.Add(prevWindow);
4328 // Eventually fix this not to include captured?
4329 else if(!prevWindow.OnMouseLeave(*mods))
4333 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4335 Box box = trueWindow.box;
4336 box.left += trueWindow.absPosition.x;
4337 box.right += trueWindow.absPosition.x;
4338 box.top += trueWindow.absPosition.y;
4339 box.bottom += trueWindow.absPosition.y;
4341 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4343 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4344 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4346 overX = Max(Min(overX, 32767),-32768);
4347 overY = Max(Min(overY, 32767),-32768);
4349 trueWindow.mouseInside = true;
4350 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4354 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4356 for(w : guiApp.overWindows; w == trueWindow)
4359 guiApp.overWindows.TakeOut(w);
4362 guiApp.prevWindow = trueWindow;
4365 guiApp.prevWindow = null;
4367 SelectMouseCursor();
4369 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4370 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4372 int clientX = x - (window.absPosition.x + window.clientStart.x);
4373 int clientY = y - (window.absPosition.y + window.clientStart.y);
4375 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4377 clientX = Max(Min(clientX, 32767),-32768);
4378 clientY = Max(Min(clientY, 32767),-32768);
4380 MouseMethod = (void *)window._vTbl[method];
4382 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4385 if(!MouseMethod(window, clientX, clientY, *mods))
4389 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4390 window.OnMouseLeave(*mods);
4397 if(result && w && w.clickThrough && w.parent)
4402 if(!result || !w || !w.clickThrough)
4409 // --- Mouse cursor management ---
4411 bool KeyMessage(uint method, Key key, unichar character)
4416 if(guiApp.interimWindow)
4417 this = guiApp.interimWindow;
4420 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4424 if(!style.inactive || rootWindow != this)
4426 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4427 Window modalWindow = FindModal();
4428 Window interimMaster = master ? master.rootWindow : null;
4432 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4433 status = OnSysKeyDown(key, character);
4434 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4435 status = OnSysKeyHit(key, character);
4436 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4437 status = OnSysKeyUp(key, character);
4444 // Process Key Message for Internal UI Keyboard actions
4445 if(status && !destroyed && menuBar && state != minimized)
4448 if((SmartKey)key != alt)
4449 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4452 SmartKey sk = (SmartKey) key;
4453 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4455 status = menuBar.KeyMessage(method, key, character);
4460 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4461 menuBar.OnKeyHit(escape, 0);
4463 if(!menuBar.focus && guiApp.caretOwner)
4464 guiApp.caretOwner.UpdateCaret(true, false);
4467 if(!destroyed && status)
4469 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4473 case left: case up: case right: case down:
4474 if(guiApp.windowMoving == this)
4477 int w = guiApp.windowMoving.size.w;
4478 int h = guiApp.windowMoving.size.h;
4479 int x = guiApp.windowMoving.scrolledPos.x;
4480 int y = guiApp.windowMoving.scrolledPos.y;
4484 if(key == down || key == up)
4485 step = Max(step, textCellH);
4487 step = Max(step, textCellW);
4490 if(guiApp.windowIsResizing)
4494 case left: w-=step; break;
4495 case right: w+=step; break;
4496 case up: h-=step; break;
4497 case down: h+=step; break;
4504 case left: x-=step; break;
4505 case right: x+=step; break;
4506 case up: y-=step; break;
4507 case down: y+=step; break;
4511 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4512 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4514 if(!guiApp.windowIsResizing || guiApp.resizeX)
4515 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4517 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4519 if(!guiApp.windowIsResizing || guiApp.resizeY)
4520 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4522 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4524 guiApp.interfaceDriver.SetMousePosition(x, y);
4525 ConsequentialMouseMove(true);
4533 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4535 guiApp.windowMoving.StopMoving();
4536 ConsequentialMouseMove(false);
4544 ShowSysMenu(absPosition.x, absPosition.y);
4552 if(!destroyed && status && state != minimized)
4554 // Process all the way down the children
4555 if(activeChild && !activeChild.disabled)
4557 status = activeChild.KeyMessage(method, key, character);
4559 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4560 key.code != left && key.code != right && key.code != up && key.code != down)
4562 status = activeClient.KeyMessage(method, key, character);
4566 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4568 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4569 // && defaultControl != activeChild)
4571 delete previousActive;
4572 previousActive = activeChild;
4573 if(previousActive) incref previousActive;
4575 ConsequentialMouseMove(false);
4576 if((defaultControl.active ||
4577 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4578 defaultControl.KeyMessage(method, defaultKey, character);
4584 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4586 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4593 ShowSysMenu(absPosition.x, absPosition.y);
4600 if(this != guiApp.desktop)
4602 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4604 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4606 MenuMoveOrSize(key.shift, true);
4610 else if(guiApp.windowMoving)
4612 guiApp.windowMoving.StopMoving();
4613 ConsequentialMouseMove(false);
4621 if(!destroyed && status && state != minimized)
4623 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4627 case tab: case shiftTab:
4629 Window cycleParent = this;
4630 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4631 cycleParent = master.parent;
4633 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4635 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4638 Window child = cycleParent.activeChild;
4640 // Scroll the window to include the active control
4641 if(cycleParent.sbh && !child.style.dontScrollHorz)
4643 if(child.scrolledPos.x < 0)
4644 cycleParent.sbh.Action(Position,
4645 cycleParent.scroll.x + child.scrolledPos.x, 0);
4646 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4647 cycleParent.sbh.Action(Position,
4648 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4650 if(cycleParent.sbv && !child.style.dontScrollVert)
4652 if(child.scrolledPos.y < 0)
4653 cycleParent.sbv.Action(Position,
4654 cycleParent.scroll.y + child.scrolledPos.y, 0);
4655 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4656 cycleParent.sbv.Action(Position,
4657 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4660 cycleParent.ConsequentialMouseMove(false);
4666 case f6: case shiftF6:
4667 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4669 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4670 if(parent == guiApp.desktop)
4671 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4681 if(CycleChildren(key.shift, true, false, true))
4689 // mIRC Style Window Shortcuts
4690 case alt1: case alt2: case alt3: case alt4: case alt5:
4691 case alt6: case alt7: case alt8: case alt9: case alt0:
4696 for(document = children.first; document; document = document.next)
4698 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4700 if(document == activeChild)
4702 if(document.state == minimized)
4703 document.SetState(normal, false, key);
4706 document.SetState(minimized, false, key);
4707 CycleChildren(false, true, false);
4712 if(activeChild.state == maximized && document.style.hasMaximize)
4713 document.SetState(maximized, false, key);
4714 else if(document.state == minimized)
4715 document.SetState(normal, false, key);
4716 document.Activate();
4731 if(!destroyed && status)
4733 if(state == minimized)
4738 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4740 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4742 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4743 previousActive.ActivateEx(true, false, false, true, null, null);
4744 delete previousActive;
4750 if(!destroyed && status)
4752 status = ProcessHotKeys(method, key, character);
4754 if(!destroyed && status && !modalWindow && state != minimized)
4757 status = KeyMethod(this, key, character);
4758 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4759 status = OnKeyHit(key, character);
4760 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4762 bool result = false;
4765 case ctrlUp: case ctrlDown:
4766 if(sbv && !guiApp.windowScrolling)
4767 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4769 case wheelUp: case wheelDown:
4770 if(sbv && !guiApp.windowScrolling)
4772 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4773 // Do we want to do a consequential move regardless of result in this case?
4774 ConsequentialMouseMove(false);
4777 case ctrlPageUp: case ctrlPageDown:
4778 if(sbh && !guiApp.windowScrolling)
4779 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4784 ConsequentialMouseMove(false);
4789 if(status && !destroyed && menuBar && state != minimized)
4790 status = menuBar.KeyMessage(method, key, character);
4792 if(style.interim && /*destroyed && */status && interimMaster)
4794 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4795 status = interimMaster.KeyMessage(method, key, character);
4802 bool ProcessHotKeys(uint method, Key key, unichar character)
4807 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4808 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4809 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4811 Window hotKeyWindow = hotKey.window;
4812 Window parent = hotKeyWindow.parent;
4813 Window prevActiveWindow = activeChild;
4814 // For when sys buttons are placed inside the menu bar
4815 if(parent && parent._class == class(PopupMenu))
4816 parent = parent.parent;
4818 // 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
4819 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4822 if(prevActiveWindow) incref prevActiveWindow;
4823 incref hotKeyWindow;
4824 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4825 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4828 delete hotKeyWindow;
4829 delete prevActiveWindow;
4833 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4834 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4835 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4837 // ********* WORKING ON THIS ***********
4838 if(prevActiveWindow && !guiApp.interimWindow)
4839 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4842 else if(hotKeyWindow.style.inactive)
4843 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4845 delete prevActiveWindow;
4846 delete hotKeyWindow;
4847 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4848 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4852 if(status && tabCycle)
4855 for(child = children.first; child; child = child.next)
4857 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4868 // --- Windows and graphics initialization / termination ---
4869 bool SetupRoot(void)
4873 // Setup relationship with outside world (bb root || !bb)
4874 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4875 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4879 tempExtents = new0 Extent[4];
4884 /*if(guiApp.fullScreenMode)
4885 rootWindow = guiApp.desktop;
4887 //rootWindow = parent.created ? parent.rootWindow : null;
4888 rootWindow = parent.rootWindow;
4891 against = &parent.box;
4893 against = &parent.clientArea;
4896 for(child = children.first; child; child = child.next)
4899 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4902 bool Setup(bool positionChildren)
4904 bool result = false;
4907 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4909 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4910 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4913 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4915 // This was here, is it really needed?
4916 //guiApp.interfaceDriver.ActivateRootWindow(this);
4920 displaySystem = DisplaySystem {};
4921 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4923 delete displaySystem;
4928 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4929 if(display.Create(displaySystem, windowHandle))
4936 // Sometimes icon does not show up on Windows XP if we set here...
4937 // guiApp.interfaceDriver.SetIcon(this, icon);
4939 else if(this != guiApp.desktop)
4941 display = rootWindow ? rootWindow.display : null;
4947 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4948 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4950 for(child = children.first; child; child = child.next)
4952 if(child.created && !child.Setup(false))
4955 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4956 child.UpdateCaption();
4961 bool SetupDisplay(void)
4963 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4964 if(is3D) return Window3D_SetupDisplay(this); else
4971 class_data void ** pureVTbl;
4973 bool LoadGraphics(bool creation, bool resetAnchors)
4975 bool result = false;
4976 bool success = false;
4978 WindowState stateBackup = state;
4980 if(((subclass(Window))_class).pureVTbl)
4982 if(_vTbl == _class._vTbl)
4984 _vTbl = ((subclass(Window))_class).pureVTbl;
4989 for(m = 0; m < _class.vTblSize; m++)
4991 if(_vTbl[m] == _class._vTbl[m])
4992 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4996 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4998 if(_vTbl == ((subclass(Window))_class).pureVTbl)
5000 _vTbl = _class._vTbl;
5005 for(m = 0; m < _class.vTblSize; m++)
5007 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
5008 _vTbl[m] = _class._vTbl[m];
5013 if(guiApp.fullScreenMode || this != guiApp.desktop)
5015 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
5021 display.Lock(false);
5022 if(rootWindow == this)
5024 // Set Color Palette
5025 display.SetPalette(palette, true);
5029 if(guiApp.fullScreenMode && this == guiApp.desktop)
5034 for(c=0; c<SystemCursor::enumSize; c++)
5035 if(!guiApp.systemCursors[c].bitmap)
5037 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5038 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5039 if(guiApp.systemCursors[c].bitmapName)
5041 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5042 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5043 if(guiApp.systemCursors[c].bitmap)
5044 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5049 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5051 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5052 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5054 cursor.bitmap.paletteShades = cursor.paletteShades;
5058 guiApp.cursorUpdate = true;
5061 ConsequentialMouseMove(false);
5067 // Load Window Graphic Resources
5070 if(usedFont == setFont || usedFont == window.systemFont)
5071 RemoveResource(usedFont);
5074 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5077 RemoveResource(systemFont);
5080 RemoveResource(captionFont);
5082 for(ptr = resources.first; ptr; ptr = ptr.next)
5084 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5085 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5088 AddResource(setFont);
5090 AddResource(systemFont);
5092 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5099 //if(master && master.font)
5100 if(parent && parent.font)
5104 faceName = parent.font.faceName,
5105 size = parent.font.size,
5106 bold = parent.font.bold,
5107 italic = parent.font.italic,
5108 underline = parent.font.underline
5110 //font = parent.font;
5111 watch(parent) { font { } };
5114 font = guiApp.currentSkin.SystemFont();
5121 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5122 AddResource(captionFont);
5124 if(OnLoadGraphics())
5130 //SetScrollLineStep(sbStep.x, sbStep.y);
5132 if(this != guiApp.desktop)
5136 normalAnchor = anchor;
5137 normalSizeAnchor = sizeAnchor;
5140 // Break the anchors for moveable/resizable windows
5142 if(style.fixed && style.isDocument)
5144 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5156 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5157 stateSizeAnchor = SizeAnchor {};
5162 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5167 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5168 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5171 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5175 stateAnchor = normalAnchor;
5176 stateSizeAnchor = normalSizeAnchor;
5179 position = Point { };
5180 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5191 if(Position(x, y, w, h, true, false, true, true, true, true))
5193 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5196 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5213 success = result = true;
5216 if(!creation && result)
5218 // Load menu bar first because sys buttons are on it...
5221 if(!menuBar.LoadGraphics(false, resetAnchors))
5227 for(child = children.first; child; child = child.next)
5229 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5236 CreateSystemChildren();
5240 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5243 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5246 LogErrorCode(graphicsLoadingFailed, _class.name);
5248 // Do this here to avoid problems on Windows
5249 if(rootWindow == this && parent && stateBackup == maximized)
5250 property::state = maximized;
5254 void UnloadGraphics(bool destroyWindows)
5258 // Free children's graphics
5259 for(child = children.first; child; child = child.next)
5260 child.UnloadGraphics(destroyWindows);
5263 display.Lock(false);
5266 if(guiApp.fullScreenMode && this == guiApp.desktop)
5271 for(c=0; c<SystemCursor::enumSize; c++)
5272 if(guiApp.systemCursors[c].bitmap)
5273 delete guiApp.systemCursors[c].bitmap;
5275 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5276 delete cursor.bitmap;
5278 guiApp.cursorBackground.Free();
5281 if(display && display.displaySystem)
5285 for(ptr = resources.first; ptr; ptr = ptr.next)
5289 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5294 // Free window graphics
5297 // Free skin graphics
5298 if(rootWindow == this)
5300 DisplaySystem displaySystem = display.displaySystem;
5303 display.driverData = null;
5304 display.displaySystem = null;
5308 if(displaySystem && !displaySystem.numDisplays && !is3D)
5309 delete displaySystem;
5318 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5319 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5321 if(this == guiApp.desktop || parent == guiApp.desktop)
5323 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5324 guiApp.interfaceDriver.DestroyRootWindow(this);
5328 // --- Window Hiding ---
5330 void SetVisibility(bool state)
5332 bool visible = (style.hidden || !created) ? false : state;
5333 if(visible != this.visible)
5337 this.visible = visible;
5338 for(child = children.first; child; child = child.next)
5339 child.SetVisibility(visible);
5341 ConsequentialMouseMove(false);
5342 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5346 // --- Windows and graphics initialization / termination ---
5348 bool DisplayModeChanged(void)
5350 bool result = false;
5351 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5353 guiApp.modeSwitching = true;
5354 UnloadGraphics(false);
5356 if(LoadGraphics(false, false))
5358 guiApp.modeSwitching = false;
5363 // --- Window updates system ---
5365 void UpdateDirty(Box updateBox)
5367 if(!manageDisplay) { OnRedraw(null);return; }
5370 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5373 if(display.flags.flipping)
5376 rootWindow.UpdateDisplay();
5379 UpdateBackDisplay(updateBox);
5381 if(guiApp.fullScreenMode)
5383 guiApp.cursorUpdate = true;
5384 guiApp.PreserveAndDrawCursor();
5386 if(guiApp.fullScreenMode)
5387 guiApp.RestoreCursorBackground();
5393 // This function is strictly called as a result of system window activation
5394 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5397 Window interimMaster = null;
5398 Window interimWindow = guiApp.interimWindow;
5399 if(interimWindow && interimWindow.master)
5400 interimMaster = interimWindow.master.rootWindow;
5402 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5403 // SetState(normal, false, 0);
5404 SetState(lastState, false, 0);
5406 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5410 /* WTH is this doing here?
5411 while(swap && swap.activeChild)
5413 swap = swap.activeChild;
5416 // TESTING THIS BEFORE...
5417 if(interimWindow && this == interimMaster)
5421 // Window interimSwap = this;
5422 Window menuBar = this.menuBar;
5423 if(menuBar && interimWindow.master == menuBar)
5426 while(interimSwap && interimSwap.activeChild)
5427 interimSwap = interimSwap.activeChild;
5429 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5430 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5432 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5433 //result = ActivateEx(true, true, false, activateRoot, window, null);
5438 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5439 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5441 if(interimWindow == this && interimMaster && !active)
5443 while(interimMaster && interimMaster.interim && interimMaster.master)
5445 // printf("Going up one master %s\n", interimMaster._class.name);
5446 interimMaster = interimMaster.master.rootWindow;
5448 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5449 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5455 bool DestroyEx(int64 returnCode)
5458 Timer timer, nextTimer;
5460 OldLink prevOrder = null;
5461 Window client = null;
5463 if(parent) stopwatching(parent, font);
5465 // if(window.modalSlave) return false;
5466 if(destroyed || !created)
5473 OldLink slave = master.slaves.FindLink(this);
5474 master.slaves.Delete(slave);
5477 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5483 this.returnCode = (DialogResult)returnCode;
5485 AcquireInput(false);
5490 master.hotKeys.Delete(hotKey);
5494 if(guiApp.prevWindow == this)
5496 guiApp.prevWindow = null;
5501 for(w : guiApp.overWindows; w == this)
5504 guiApp.overWindows.TakeOut(w);
5508 if(guiApp.caretOwner == this)
5510 guiApp.interfaceDriver.SetCaret(0,0,0);
5511 UpdateCaret(false, true);
5512 guiApp.caretEnabled = false;
5517 parent.childrenCycle.Remove(cycle);
5521 OldLink tmpPrev = order.prev;
5522 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5523 prevOrder = tmpPrev;
5526 client = tmpPrev ? tmpPrev.data : null;
5527 if(client == this) { client = null; break; }
5528 if(client && (client.style.hidden || client.destroyed || !client.created))
5529 tmpPrev = client.order.prev;
5533 prevOrder = tmpPrev;
5538 // If this window can be an active client, make sure the next window we activate can also be one
5539 if(!style.nonClient && style.isActiveClient)
5541 tmpPrev = prevOrder;
5544 client = tmpPrev ? tmpPrev.data : null;
5545 if(client == this) { client = null; break; }
5546 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5547 tmpPrev = client.order.prev;
5551 prevOrder = tmpPrev;
5555 if(client && client.style.hidden) client = null;
5557 // parent.childrenOrder.Remove(order);
5560 if(parent && style.isActiveClient && visible)
5562 if(state == minimized) parent.numIcons--;
5563 parent.numPositions--;
5566 // TESTING THIS HERE!
5570 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5571 // to create a window inside a rootwindow that's being destroyed)
5572 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5574 if(master && !master.destroyed /*&&
5575 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5577 if(master.defaultControl == this)
5578 master.defaultControl = null;
5581 parent.OnChildAddedOrRemoved(this, true);
5582 if(parent && !parent.destroyed /*&&
5583 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5585 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5587 if(order && prevOrder && prevOrder.data != this && active)
5589 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5591 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5592 if(parent.activeClient == this)
5594 parent.activeClient = null;
5595 parent.UpdateActiveDocument(null);
5600 if(guiApp.interimWindow == this)
5603 PropagateActive(false, null, &goOn, true);
5607 //if(window.parent.activeChild == window)
5608 parent.activeChild = null;
5609 if(!style.nonClient /*&& style.isActiveClient*/)
5611 Window previous = parent.activeClient;
5612 if(style.isActiveClient)
5613 parent.activeClient = null;
5614 parent.UpdateActiveDocument(previous);
5619 else if(parent.activeClient == this)
5621 parent.activeClient = client;
5622 parent.UpdateActiveDocument(this);
5626 if(guiApp.interimWindow == this)
5628 guiApp.interimWindow = null;
5629 if(guiApp.caretOwner)
5631 Window desktop = guiApp.desktop;
5632 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5633 guiApp.caretOwner.UpdateCaret(false, false);
5638 if(_isModal && master && master.modalSlave == this)
5639 master.modalSlave = null;
5643 if(!guiApp.caretOwner && parent.caretSize)
5645 guiApp.caretOwner = parent;
5646 parent.UpdateCaret(false, false);
5647 parent.Update(null);
5650 // Why was this commented out?
5651 GetRidOfVirtualArea();
5657 dirtyArea.Free(null);
5658 dirtyBack.Free(null);
5659 scrollExtent.Free(null);
5661 /* ATTEMPTING TO MOVE THAT ABOVE
5670 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5671 for(;(child = window.children.first);)
5673 for(; child && (child.destroyed || !child.created); child = child.next);
5682 UnloadGraphics(true);
5685 delete previousActive;
5688 // statusBar = null;
5691 if(master && !master.destroyed)
5693 //master.NotifyDestroyed(this, this.returnCode);
5694 NotifyDestroyed(master, this, this.returnCode);
5697 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5699 nextTimer = timer.next;
5700 if(timer.window == this)
5702 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5703 // timer.window = null;
5709 if(this == guiApp.windowMoving)
5712 if(guiApp.windowCaptured == this)
5714 //guiApp.windowCaptured = null;
5716 if(rootWindow != this && rootWindow)
5717 rootWindow.ConsequentialMouseMove(false);
5725 //for(child = children.first; next = child ? child.next : null, child; child = next)
5726 for(;(child = children.first); )
5728 for(; child && (child.destroyed || !child.created); child = child.next);
5738 /* // MOVED THIS UP...
5741 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5742 for(;(child = window.children.first); )
5744 for(; child && (child.destroyed || !child.created); child = child.next);
5753 while((slave = slaves.first))
5755 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5757 ((Window)slave.data).DestroyEx(0);
5762 if(guiApp.caretOwner == this)
5763 guiApp.caretOwner = null;
5765 sysButtons[0] = null;
5766 sysButtons[1] = null;
5767 sysButtons[2] = null;
5770 if(rootWindow != this)
5772 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5775 box.left -= parent.clientStart.x;
5776 box.top -= parent.clientStart.y;
5777 box.right -= parent.clientStart.x;
5778 box.bottom -= parent.clientStart.y;
5780 if(parent) parent.Update(box);
5785 OldLink slave = master.slaves.FindVoid(this);
5786 master.slaves.Delete(slave);
5792 parent.children.Remove(this);
5797 //autoCreate = false;
5800 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5801 if(((subclass(Window))_class).pureVTbl)
5803 if(_vTbl == _class._vTbl)
5805 _vTbl = ((subclass(Window))_class).pureVTbl;
5810 for(m = 0; m < _class.vTblSize; m++)
5812 if(_vTbl[m] == _class._vTbl[m])
5813 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5822 void SetStateEx(WindowState newState, bool activate)
5825 WindowState prevState = state;
5829 if(prevState != newState)
5830 lastState = prevState;
5832 if(rootWindow != this || !nativeDecorations || !windowHandle)
5834 if(style.isActiveClient && !style.hidden && prevState == minimized)
5837 // This block used to be at the end of the function... moved it for flicker problem in X
5838 // ------------------------------------------------------
5842 stateAnchor = normalAnchor;
5843 stateSizeAnchor = normalSizeAnchor;
5846 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5847 stateSizeAnchor = SizeAnchor {};
5851 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5854 byte * idBuffer = new0 byte[size];
5856 for(child = parent.children.first; child; child = child.next)
5858 if(child != this && child.state == minimized)
5860 if(child.iconID > size - 2)
5862 idBuffer = renew0 idBuffer byte[size*2];
5863 memset(idBuffer + size, 0, size);
5866 idBuffer[child.iconID] = (byte)bool::true;
5869 for(c = 0; c<size; c++)
5874 if(style.isActiveClient && !style.hidden)
5877 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5878 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5882 // TOCHECK: Why was this here?
5883 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5884 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5885 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5887 Position(x, y, w, h, true, true, true, true, false, true);
5889 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5890 parent.UpdateActiveDocument(null);
5893 CreateSystemChildren();
5894 // ------------------------------------------------------
5897 int GetPositionID(Window forChild)
5901 byte * idBuffer = new0 byte[size];
5904 for(child = children.first; child; child = child.next)
5906 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5908 if(child.positionID > size - 2)
5910 idBuffer = renew0 idBuffer byte[size*2];
5911 memset(idBuffer + size, 0, size);
5914 idBuffer[child.positionID] = (byte)bool::true;
5917 for(c = 0; c<size; c++)
5924 // --- Window related graphics ---
5926 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5928 palette = newPalette;
5929 if(rootWindow.display)
5930 rootWindow.display.SetPalette(palette, colorMatch);
5933 public bool AcquireInput(bool acquired)
5936 if(acquiredInput != acquired)
5938 if(active || (!visible && creationActivation == activate))
5939 result = AcquireInputEx(acquired);
5944 acquiredInput = acquired ? result : !result;
5949 void ListChildren(ListBox listBox)
5953 for(child = children.first; child; child = child.next)
5955 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5957 DataRow row = listBox.AddRow();
5958 row.tag = (int64)(intptr)child;
5959 child.FigureCaption(caption);
5960 row.SetData(null, caption);
5965 void UpdateVisual(Box extent)
5967 if(guiApp.driver != null)
5969 if(guiApp.fullScreenMode && guiApp.desktop.display)
5971 guiApp.desktop.mutex.Wait();
5972 guiApp.desktop.display.Lock(true);
5975 if(guiApp.desktop.active)
5977 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5979 if(guiApp.desktop.display.flags.flipping)
5980 guiApp.desktop.Update(null);
5981 guiApp.desktop.UpdateDisplay();
5982 guiApp.cursorUpdate = true;
5984 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5986 guiApp.PreserveAndDrawCursor();
5987 // guiApp.desktop.display.ShowScreen();
5988 guiApp.cursorUpdate = false;
5989 guiApp.desktop.dirty = false;
5990 guiApp.RestoreCursorBackground();
5994 guiApp.desktop.display.Unlock();
5995 guiApp.desktop.mutex.Release();
5999 Window rootWindow = this.rootWindow;
6000 rootWindow.mutex.Wait();
6005 guiApp.SignalEvent();
6008 guiApp.waitMutex.Wait();
6009 guiApp.interfaceDriver.Lock(rootWindow);
6010 if(!rootWindow.style.hidden && rootWindow.dirty)
6012 if(rootWindow.display)
6014 rootWindow.UpdateDisplay();
6015 //rootWindow.display.ShowScreen(null);
6017 rootWindow.dirty = false;
6019 guiApp.interfaceDriver.Unlock(rootWindow);
6020 guiApp.waitMutex.Release();
6023 rootWindow.mutex.Release();
6028 void UnlockDisplay(void)
6030 guiApp.interfaceDriver.Unlock(rootWindow);
6033 void LockDisplay(void)
6035 guiApp.interfaceDriver.Lock(rootWindow);
6038 Surface GetSurface(Box box)
6040 return Redraw((box == null) ? this.box : box);
6043 void SetMousePosition(int x, int y)
6045 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6049 void IntegrationActivate(bool active)
6051 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6053 isForegroundWindow = true;
6054 ActivateEx(active, active, false, false, null, null);
6055 isForegroundWindow = false;
6060 Window QueryCapture(void)
6062 return guiApp.windowCaptured;
6065 int GetDocumentID(void)
6069 byte * idBuffer = new0 byte[size];
6072 for(child = children.first; child; child = child.next)
6074 // TO CHECK: Do we want a documentID when we already have a file name?
6075 if(child.style.isDocument && !child.fileName)
6077 if(child.documentID-1 > size - 2)
6079 idBuffer = renew0 idBuffer byte[size*2];
6080 memset(idBuffer + size, 0, size);
6083 idBuffer[child.documentID-1] = 1;
6086 for(c = 0; c<size; c++)
6094 void SetInitSize(Size size)
6097 sizeAnchor.size = size;
6098 normalSizeAnchor = sizeAnchor;
6100 // Break the anchors for moveable/resizable windows
6101 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6103 stateAnchor = normalAnchor;
6104 stateSizeAnchor = normalSizeAnchor;
6106 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6107 Position(x,y, w, h, true, true, true, true, false, true);
6111 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6113 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6115 guiApp.windowIsResizing = resize;
6116 guiApp.windowMoving = this;
6117 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6118 if(guiApp.windowIsResizing)
6120 guiApp.windowMovingStart.x += size.w - 1;
6121 guiApp.windowMovingStart.y += size.h - 1;
6123 guiApp.windowMovingBefore = scrolledPos;
6124 guiApp.windowResizingBefore = size;
6125 guiApp.windowMoving.UpdateDecorations();
6126 if(guiApp.windowIsResizing)
6127 guiApp.resizeEndX = guiApp.resizeEndY = true;
6129 if(setCursorPosition)
6130 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6134 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6135 guiApp.windowMovingStart.x += x - absPosition.x;
6136 guiApp.windowMovingStart.y += y - absPosition.y;
6139 if(guiApp.windowMoving)
6141 if(guiApp.windowMoving.style.nonClient)
6142 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6144 guiApp.windowMoving.parent.SetMouseRangeToClient();
6149 if(this == rootWindow)
6150 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6154 void SetupFileMonitor()
6158 fileMonitor = FileMonitor
6160 this, FileChange { modified = true };
6162 bool OnFileNotify(FileChange action, const char * param)
6165 fileMonitor.StopMonitoring();
6166 if(OnFileModified(action, param))
6167 fileMonitor.StartMonitoring();
6180 bool result = false;
6184 else if(guiApp && guiApp.driver != null)
6186 OldLink slaveHolder;
6188 bool visible = !style.hidden;
6192 systemParent = parent;
6193 parent = guiApp.desktop;
6195 last = parent ? parent.children.last : null;
6197 if((parent && parent != guiApp.desktop && !parent.created) ||
6198 (master && master != guiApp.desktop && !master.created))
6202 stopwatching(parent, font);
6205 property::parent = guiApp.desktop;
6206 if(!master) master = parent;
6208 if(_isModal && master.modalSlave)
6209 property::master = master.modalSlave;
6213 parent.children.Remove(this);
6216 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6217 if(slaveHolder.data == this)
6219 master.slaves.Delete(slaveHolder);
6224 if(parent == guiApp.desktop && !mutex)
6227 if(style.isDocument)
6230 parent.numDocuments--;
6231 documentID = parent.GetDocumentID();
6234 if(!style.stayOnTop)
6235 for(; last && last.style.stayOnTop; last = last.prev);
6237 parent.children.Insert((last == this) ? null : last, this);
6238 //parent.children.Add(this);
6241 dispDriver = parent.dispDriver;
6244 master.modalSlave = this;
6246 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6251 master.slaves.Add(slaveHolder = OldLink { data = this });
6256 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6258 if(style.isDefault && !master.defaultControl)
6259 master.defaultControl = this;
6261 stateAnchor = normalAnchor = anchor;
6262 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6264 // TOCHECK: Why is this here?
6265 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6266 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6268 this.visible = false;
6269 style.hidden = true;
6272 // autoCreate = true;
6280 if(parent == guiApp.desktop)
6281 Log("LoadGraphics %s\n", caption);
6283 if(LoadGraphics(true, false))
6291 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6298 if(style.hasMenuBar /*&& menu*/)
6304 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6305 interim = false, inactive = true, nonClient = true, size.h = 24
6313 // Create the system buttons
6314 CreateSystemChildren();
6316 UpdateActiveDocument(null);
6318 if(style.isDocument)
6322 MenuItem item = menu.FindItem(MenuFileSave, 0);
6323 if(item) item.disabled = !modifiedDocument && fileName;
6328 if(parent == guiApp.desktop)
6329 Log("Preemptive SetState %s\n", caption);
6332 // Preemptive Set State to ensure proper anchoring
6333 SetStateEx(state, false);
6335 style.hidden = true;
6341 for(child = children.first; child; child = next)
6344 if(!child.created && (child.autoCreate || child.wasCreated))
6351 for(link = slaves.first; link; link = next)
6353 Window slave = link.data;
6355 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6358 // Things might have happened that invalidated 'next'...
6359 // Start over the search for slaves to create.
6360 // (Added this to fix crash with Stacker & Toolbar)
6361 next = slaves.first;
6370 if(parent == guiApp.desktop)
6371 Log("Real SetState %s\n", caption);
6374 if(isActiveClient && visible)
6376 parent.numPositions--;
6377 if(state == minimized) parent.numIcons--;
6380 parent.OnChildAddedOrRemoved(this, false);
6382 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6384 // Real set state & activate for proper display & activation
6385 property::visible = visible;
6386 // SetState(state & 0x00000003, true, 0);
6387 guiApp.interfaceDriver.SetIcon(this, icon);
6392 /*if(rootWindow == this)
6393 guiApp.interfaceDriver.ActivateRootWindow(this);
6395 if(creationActivation == activate && guiApp.desktop.active)
6396 ActivateEx(true, false, true, true, null, null);
6397 else if(creationActivation == activate || creationActivation == flash)
6400 if(this == rootWindow)
6406 rootWindow.ConsequentialMouseMove(false);
6417 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6423 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6425 //style.hidden = true; // !visible;
6426 style.hidden = !visible;
6427 if(master.modalSlave == this)
6428 master.modalSlave = null;
6435 void WriteCaption(Surface surface, int x, int y)
6438 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6441 void Update(Box region)
6447 rootWindow = this.rootWindow;
6449 // rootWindow.mutex.Wait();
6450 if(!destroyed && visible && display)
6455 // Testing this to avoid repetitve full update to take time...
6456 if(rootWindow.fullRender)
6458 rootWindow.dirty = true;
6461 if(dirtyArea.count == 1)
6463 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6464 if(item.box.left <= box.left &&
6465 item.box.top <= box.top &&
6466 item.box.right >= box.right &&
6467 item.box.bottom >= box.bottom)
6469 rootWindow.dirty = true;
6474 if(display.flags.flipping && !rootWindow.dirty)
6476 if(this == rootWindow)
6480 rootWindow.Update(null);
6485 rootWindow.dirty = true;
6490 realBox.left += clientStart.x;
6491 realBox.top += clientStart.y;
6492 realBox.right += clientStart.x;
6493 realBox.bottom += clientStart.y;
6499 if(realBox.right >= realBox.left &&
6500 realBox.bottom >= realBox.top)
6502 // if(!rootWindow.fullRender)
6503 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6505 for(child = children.first; child; child = child.next)
6510 box.left -= child.absPosition.x - absPosition.x;
6511 box.top -= child.absPosition.y - absPosition.y;
6512 box.right -= child.absPosition.x - absPosition.x;
6513 box.bottom -= child.absPosition.y - absPosition.y;
6514 if(box.right >= child.box.left && box.left <= child.box.right &&
6515 box.bottom >= child.box.top && box.top <= child.box.bottom)
6517 box.left -= child.clientStart.x;
6518 box.top -= child.clientStart.y;
6519 box.right -= child.clientStart.x;
6520 box.bottom -= child.clientStart.y;
6526 realBox.left += absPosition.x - rootWindow.absPosition.x;
6527 realBox.top += absPosition.y - rootWindow.absPosition.y;
6528 realBox.right += absPosition.x - rootWindow.absPosition.x;
6529 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6530 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6533 else if(this == guiApp.desktop)
6536 for(window = children.first; window; window = window.next)
6542 Box childBox = region;
6544 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6545 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6546 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6547 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6549 window.Update(childBox);
6552 window.Update(null);
6557 // rootWindow.mutex.Release();
6564 if(guiApp.windowCaptured != this)
6566 if(guiApp.windowCaptured)
6570 //Logf("Captured %s (%s)\n", caption, class.name);
6571 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6572 guiApp.windowCaptured = this;
6578 bool Destroy(int64 code)
6583 if(!destroyed && !CloseConfirmation(false)) return false;
6587 // TOCHECK: Should autoCreate be set to false here?
6598 void Move(int x, int y, int w, int h)
6600 normalAnchor = Anchor { left = x, top = y };
6601 normalSizeAnchor = SizeAnchor { size = { w, h } };
6603 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6605 if(destroyed) return;
6607 stateAnchor = normalAnchor;
6608 stateSizeAnchor = normalSizeAnchor;
6610 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6611 Position(x,y, w, h, true, true, true, true, false, true);
6615 DialogResult Modal(void)
6621 // FIXES MEMORY LEAK IF Create() FAILED
6627 void SetScrollArea(int width, int height, bool snapToStep)
6631 int stepX = sbStep.x, stepY = sbStep.y;
6632 // Needed to make snapped down position match the skin's check of client area
6633 // against realvirtual
6636 SNAPDOWN(stepX, textCellW);
6637 SNAPDOWN(stepY, textCellH);
6638 stepX = Max(stepX, textCellW);
6639 stepY = Max(stepY, textCellH);
6641 if(scrollFlags.snapX)
6642 SNAPUP(width, stepX);
6643 if(scrollFlags.snapY)
6644 SNAPUP(height, stepY);
6647 reqScrollArea.w = width;
6648 reqScrollArea.h = height;
6649 noAutoScrollArea = (width > 0 || height > 0);
6651 UpdateScrollBars(true, true);
6654 void SetScrollPosition(int x, int y)
6657 sbh.Action(setPosition, x, 0);
6661 int seen = clientSize.w, total = reqScrollArea.w;
6663 if(scrollFlags.snapX)
6664 SNAPDOWN(seen, sbStep.x);
6666 if(!total) total = seen;
6667 range = total - seen + 1;
6668 range = Max(range, 1);
6670 if(x >= range) x = range - 1;
6672 if(scrollFlags.snapX)
6673 SNAPUP(x, sbStep.x);
6676 OnHScroll(setPosition, x, 0);
6680 SNAPDOWN(x, textCellW);
6686 sbv.Action(setPosition, y, 0);
6690 int seen = clientSize.h, total = reqScrollArea.h;
6693 if(scrollFlags.snapY)
6694 SNAPDOWN(seen, sbStep.y);
6696 if(!total) total = seen;
6697 range = total - seen + 1;
6698 range = Max(range, 1);
6700 if(y >= range) y = range - 1;
6702 if(scrollFlags.snapY)
6703 SNAPUP(y, sbStep.y);
6706 OnVScroll(setPosition, y, 0);
6709 SNAPDOWN(y, textCellH);
6714 UpdateCaret(false, false);
6717 void SetScrollLineStep(int stepX, int stepY)
6723 SNAPDOWN(stepX, textCellW);
6724 SNAPDOWN(stepY, textCellH);
6725 stepX = Max(stepX, textCellW);
6726 stepY = Max(stepY, textCellH);
6729 sbh.lineStep = stepX;
6731 sbv.lineStep = stepY;
6734 void SetState(WindowState newState, bool activate, Modifiers mods)
6738 if(state == newState || OnStateChange(newState, mods))
6740 //WindowState prevState = state;
6744 // This used to be at the end of the brackets... moved for X, testing...
6745 // This has the effect of activating the window through the system...
6746 if(rootWindow == this)
6747 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6749 SetStateEx(newState, activate);
6751 if(rootWindow == this && !rootWindow.nativeDecorations)
6753 int x = position.x, y = position.y;
6756 x -= guiApp.desktop.absPosition.x;
6757 y -= guiApp.desktop.absPosition.y;
6759 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6763 //state = prevState;
6765 if(state != maximized && style.hasMaximize)
6768 for(child = parent.children.first; child; child = child.next)
6770 if(child != this && child.state == maximized)
6771 child.SetStateEx(normal, false);
6775 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6776 parent.UpdateScrollBars(true, true);
6779 // Do we really need this stuff here?
6780 // Shouldn't the Activate stuff take care of it?
6781 if(parent.rootWindow == parent && style)
6784 parent.FigureCaption(caption);
6785 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6786 parent.UpdateDecorations();
6790 rootWindow.ConsequentialMouseMove(false);
6797 BitmapResource GetIcon(SkinBitmap iconID)
6799 return guiApp.currentSkin.GetBitmap(iconID);
6802 void SetMouseRange(Box range)
6804 if(range || guiApp.fullScreenMode)
6809 clip.left = range.left + absPosition.x + clientStart.x;
6810 clip.top = range.top + absPosition.y + clientStart.y;
6811 clip.right = range.right + absPosition.x + clientStart.x;
6812 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6816 clip.left = guiApp.desktop.box.left;
6817 clip.top = guiApp.desktop.box.top;
6818 clip.right = guiApp.desktop.box.right;
6819 clip.bottom = guiApp.desktop.box.bottom;
6821 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6824 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6827 void SetMouseRangeToClient(void)
6829 if(guiApp.fullScreenMode || this != guiApp.desktop)
6831 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6832 box.Clip(clientArea);
6836 SetMouseRange(null);
6839 void SetMouseRangeToWindow(void)
6841 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6842 if(this == guiApp.desktop)
6843 SetMouseRangeToClient();
6848 // x, y: Desktop Coordinates
6849 void ShowSysMenu(int x, int y)
6852 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6855 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6856 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6860 menu, $"Move", m, NotifySelect = MenuWindowMove,
6861 disabled = !style.fixed || state == maximized
6865 menu, $"Size", s, NotifySelect = MenuWindowSize,
6866 disabled = !style.sizable || state != normal
6870 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6871 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6875 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6876 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6880 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6881 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6883 MenuDivider { menu };
6886 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6887 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6889 windowMenu.Create();
6894 ActivateEx(true, true, true, true, null, null);
6897 void MakeActive(void)
6899 ActivateEx(true, false, true, false, null, null);
6902 void SoftActivate(void)
6904 if(guiApp.desktop.active)
6909 if(this == rootWindow)
6914 void Deactivate(void)
6916 ActivateEx(false, true, true, true, null, null);
6921 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6924 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6926 bool result = false;
6927 if(activeChild && activeChild.cycle)
6929 Window modalWindow, child = activeChild;
6930 if(!clientOnly /*&& parent.tabCycle*/)
6932 Window next = child;
6935 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6939 if(parent && parent.CycleChildren(backward, false, true, true))
6947 next = next.cycle.prev.data;
6949 next = next.cycle.next.data;
6950 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6955 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6956 parent.tabCycle && parent.CycleChildren(backward, false, false))
6960 if(tabCycleOnly && !tabCycle) return false;
6967 child = child.cycle.prev.data;
6969 child = child.cycle.next.data;
6970 if(child == child.parent.activeChild)
6972 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6975 modalWindow = child.FindModal();
6978 // Scroll the window to include the active control
6979 if(sbh && !child.style.dontScrollHorz)
6981 if(child.scrolledPos.x < 0)
6982 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6983 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6984 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6986 if(sbv && !child.style.dontScrollVert)
6988 if(child.scrolledPos.y < 0)
6989 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6990 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6991 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6995 child = modalWindow ? modalWindow : child;
6996 child.ActivateEx(true, true, true, true, null, null);
6997 if(child.tabCycle && child.childrenCycle.first)
6998 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
7006 ConsequentialMouseMove(false);
7010 void AddResource(Resource resource)
7014 ResPtr ptr { resource = resource };
7018 // Load Graphics here if window is created already
7019 if(/*created && */display)
7021 display.Lock(false);
7022 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
7023 ptr.loaded = display.displaySystem.LoadResource(resource);
7027 // Temporary hack to load font right away for listbox in dropbox ...
7028 else if(master && master.display)
7030 master.display.Lock(false);
7031 master.display.displaySystem.LoadResource(resource);
7032 master.display.Unlock();
7038 void RemoveResource(Resource resource)
7043 for(ptr = resources.first; ptr; ptr = ptr.next)
7045 if(ptr.resource == resource)
7051 // Unload Graphics here if window is created already
7052 if(/*created && */display)
7056 display.Lock(false);
7057 display.displaySystem.UnloadResource(resource, ptr.loaded);
7063 resources.Delete(ptr);
7068 void SetCaret(int x, int y, int size)
7075 if(active && !style.interim && isEnabled)
7077 if(visible || !guiApp.caretOwner)
7078 guiApp.caretOwner = size ? this : null;
7080 UpdateCaret(false, false);
7083 guiApp.interfaceDriver.SetCaret(0,0,0);
7084 UpdateCaret(false, true);
7085 guiApp.caretEnabled = false;
7088 else if(style.inactive && active)
7090 guiApp.interfaceDriver.SetCaret(0,0,0);
7091 UpdateCaret(false, true);
7092 guiApp.caretEnabled = false;
7097 void Scroll(int x, int y)
7099 bool opaque = !style.drawBehind || background.a;
7100 if(opaque && display && display.flags.scrolling)
7102 Box box = clientArea;
7103 box.left += clientStart.x;
7104 box.top += clientStart.y;
7105 box.right += clientStart.x;
7106 box.bottom += clientStart.y;
7108 //scrollExtent.Free(null);
7109 scrollExtent.AddBox(box);
7110 scrolledArea.x += x;
7111 scrolledArea.y += y;
7113 //scrollExtent.Free();
7114 //scrollExtent.AddBox(clientArea);
7115 //scrollExtent.Offset(clientStart.x, clientStart.y);
7116 //scrolledArea.x = x;
7117 //scrolledArea.y = y;
7123 rootWindow.dirty = true;
7126 void ReleaseCapture()
7128 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7130 Window oldCaptured = guiApp.windowCaptured;
7131 guiApp.windowCaptured = null;
7132 guiApp.prevWindow = null;
7135 //guiApp.Log("Released Capture\n");
7137 guiApp.interfaceDriver.SetMouseCapture(null);
7139 //oldCaptured.OnMouseCaptureLost();
7142 oldCaptured.ConsequentialMouseMove(false);
7147 private void _SetCaption(const char * format, va_list args)
7154 char caption[MAX_F_STRING];
7155 vsnprintf(caption, sizeof(caption), format, args);
7156 caption[sizeof(caption)-1] = 0;
7158 this.caption = CopyString(caption);
7163 firewatchers caption;
7167 /*deprecated*/ void SetText(const char * format, ...)
7170 va_start(args, format);
7171 _SetCaption(format, args);
7175 void SetCaption(const char * format, ...)
7178 va_start(args, format);
7179 _SetCaption(format, args);
7183 bool Grab(Bitmap bitmap, Box box, bool decorations)
7185 bool result = false;
7186 if(display || this == guiApp.desktop)
7188 Box clip = {MININT, MININT, MAXINT, MAXINT};
7194 clip.Clip(clientArea);
7196 clip.Clip(this.box);
7198 if(rootWindow != this)
7200 clip.left += absPosition.y;
7201 clip.top += absPosition.y;
7202 clip.right += absPosition.x;
7203 clip.bottom += absPosition.y;
7206 clip.left += decorations ? 0 : clientStart.x;
7207 clip.top += decorations ? 0 : clientStart.y;
7208 clip.right += decorations ? 0 : clientStart.x;
7209 clip.bottom += decorations ? 0 : clientStart.y;
7211 if(display && display.flags.flipping)
7213 rootWindow.Update(null);
7214 rootWindow.UpdateDisplay();
7221 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7222 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7226 result = display.Grab(bitmap, clip.left, clip.top,
7227 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7229 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7231 if(!bitmap.Convert(null, pixelFormat888, null))
7238 void GetMousePosition(int * x, int * y)
7240 int mouseX = 0, mouseY = 0;
7241 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7244 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7245 if(this != guiApp.desktop)
7247 mouseX -= absPosition.x + clientStart.x;
7248 mouseY -= absPosition.y + clientStart.y;
7255 DialogResult DoModal()
7257 DialogResult returnCode = 0;
7258 int terminated = terminateX;
7261 while(!destroyed && guiApp.driver != null)
7263 if(terminateX != terminated)
7265 terminated = terminateX;
7266 guiApp.desktop.Destroy(0);
7267 if(guiApp.desktop.created)
7270 //printf("Resetting terminate X to 0\n");
7276 guiApp.UpdateDisplay();
7277 if(!guiApp.ProcessInput(false))
7280 returnCode = this.returnCode;
7293 return !destroyed && guiApp.driver != null && terminateX < 2;
7296 DialogResult DoModalEnd()
7298 DialogResult returnCode = this.returnCode;
7303 // --- Window manipulation ---
7304 /*bool GetDisabled()
7306 bool disabled = this.disabled;
7308 for(window = this; (window = window.master); )
7319 // --- Mouse Manipulation ---
7320 void GetNCMousePosition(int * x, int * y)
7322 GetMousePosition(x, y);
7323 if(x) *x += clientStart.x;
7324 if(y) *y += clientStart.y;
7327 // --- Carets manipulation ---
7328 void GetCaretPosition(Point caretPos)
7330 caretPos = this.caretPos;
7333 int GetCaretSize(void)
7338 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7344 bool CloseConfirmation(bool parentClosing)
7357 if(!OnClose(parentClosing))
7360 // If you want to skip this, simply set modifiedDocument to false in OnClose
7361 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7363 DialogResult dialogRes;
7366 sprintf(message, $"Save changes to %s?", fileName);
7368 sprintf(message, $"Save changes to Untitled %d?", documentID);
7370 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7372 if(dialogRes == yes)
7374 // TOFIX: Precomp error if brackets are taken out
7375 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7377 else if(dialogRes == cancel)
7383 for(slave = slaves.first; slave; slave = slave.next)
7385 Window w = slave.data;
7386 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7394 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7397 for(child = children.first; child; child = child.next)
7398 if(child.isActiveClient && !child.CloseConfirmation(true))
7406 for(child = children.first; child; child = child.next)
7407 if(!child.isActiveClient && !child.CloseConfirmation(true))
7417 // Static methods... move them somewhere else?
7418 void ::RestoreCaret()
7420 if(guiApp.caretOwner)
7421 guiApp.caretOwner.UpdateCaret(false, false);
7424 void ::FreeMouseRange()
7426 guiApp.interfaceDriver.SetMouseRange(null, null);
7430 bool MenuFileClose(MenuItem selection, Modifiers mods)
7432 Window document = activeChild;
7434 document.Destroy(0);
7438 bool MenuFileExit(MenuItem selection, Modifiers mods)
7444 bool MenuFileSave(MenuItem selection, Modifiers mods)
7449 fileMonitor.fileName = null;
7452 if(OnSaveFile(fileName))
7454 //if(OnFileModified != Window::OnFileModified)
7457 fileMonitor.fileName = fileName;
7463 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7464 DialogResult answer = dialog.Modal();
7466 if(answer != yes) return (bool)answer;
7469 return MenuFileSaveAs(selection, mods);
7472 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7474 DialogResult result = (DialogResult)bool::true;
7475 FileDialog fileDialog = saveDialog;
7480 fileDialog = FileDialog {};
7485 fileDialog.filePath = fileName;
7488 char filePath[MAX_FILENAME];
7489 sprintf(filePath, "Untitled %d", documentID);
7490 fileDialog.filePath = filePath;
7492 fileMonitor.fileName = null;
7494 fileDialog.type = save;
7495 fileDialog.text = $"Save As";
7499 fileDialog.master = master.parent ? master : this;
7500 if(fileDialog.Modal() == ok)
7502 const char * filePath = fileDialog.filePath;
7504 if(OnSaveFile(filePath))
7507 property::fileName = filePath;
7508 NotifySaved(master, this, filePath);
7513 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7514 DialogResult answer = dialog.Modal();
7529 //if(OnFileModified != Window::OnFileModified && fileName)
7532 fileMonitor.fileName = fileName;
7536 return (bool)result; // Actually returning result from Yes/NoCancel message box
7539 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7541 Window document = activeChild;
7543 for(document = children.first; document; document = next)
7545 next = document.next;
7546 if(document.style.isDocument || document.fileName)
7547 document.MenuFileSave(selection, mods);
7552 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7556 for(document = children.first; document; document = document.next)
7557 //if(document.style.isDocument && document.state == minimized)
7558 if(document.style.isActiveClient && document.state == minimized)
7559 document.SetState(minimized, false, mods);
7563 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7565 Window document = activeChild;
7568 Window firstDocument = null;
7570 OldLink cycle = document.cycle.prev;
7575 if(child.style.isActiveClient && !child.style.hidden)
7579 firstDocument = child;
7580 if(child.state == minimized)
7581 child.SetState(minimized, false, mods);
7584 child.positionID = id++;
7585 child.SetState(normal, false, mods);
7586 child.anchor.left.type = cascade;
7589 child.normalSizeAnchor = *&child.sizeAnchor;
7590 child.normalAnchor = child.anchor;
7592 // Break the anchors for moveable/resizable windows
7593 if(child.style.fixed)
7595 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7597 (*&child.normalAnchor).left = x;
7598 (*&child.normalAnchor).top = y;
7599 (*&child.normalAnchor).right.type = none;
7600 (*&child.normalAnchor).bottom.type = none;
7602 (*&child.normalSizeAnchor).isClientW = false;
7603 (*&child.normalSizeAnchor).isClientH = false;
7604 (*&child.normalSizeAnchor).size.w = w;
7605 (*&child.normalSizeAnchor).size.h = h;
7606 child.anchored = false;
7609 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7611 child.stateAnchor = child.normalAnchor;
7612 child.stateSizeAnchor = child.normalSizeAnchor;
7614 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7615 child.Position(x, y, w, h, true, true, true, true, false, false);
7620 last = children.last;
7621 if(!child.style.stayOnTop)
7622 for(; last && last.style.stayOnTop; last = last.prev);
7623 children.Move(child, last);
7624 childrenOrder.Move(child.order, childrenOrder.last);
7626 if(cycle == document.cycle) break;
7630 firstDocument.Activate();
7635 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7642 // Close all closes all active clients, not all documents
7643 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7645 Window next, document;
7647 for(document = children.first; document; document = next)
7649 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7650 if(document.style.isActiveClient)
7651 if(!document.Destroy(0) && !document.style.hidden)
7657 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7659 if(style.hasMaximize && state != maximized)
7660 SetState(maximized, 0, 0);
7664 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7666 if(style.hasMinimize && state != minimized)
7668 SetState(minimized, 0, 0);
7669 parent.CycleChildren(false, true, false, true);
7674 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7676 MenuMoveOrSize(false, selection ? true : false);
7680 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7682 CycleChildren(false, true, false, true);
7686 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7688 CycleChildren(true, true, false, true);
7692 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7694 MenuMoveOrSize(true, true);
7698 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7701 SetState(normal, 0, 0);
7705 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7708 int64 id = selection.id;
7709 OldLink cycle = activeClient.cycle;
7711 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7714 Window sibling = cycle.data;
7715 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7723 document = cycle.data;
7724 document.Activate();
7726 //if(activeChild.state == maximized)
7727 // document.SetState(maximized, false, mods);
7728 //else if(document.state == minimized)
7729 // document.SetState(normal, false, mods);
7733 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7735 stayOnTop = !style.stayOnTop;
7739 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7741 Window document = activeChild;
7744 Window firstDocument = null;
7745 OldLink cycle = document.cycle;
7749 Window child = cycle.data;
7750 if(child.style.isActiveClient && !child.style.hidden)
7752 if(!firstDocument) firstDocument = child;
7753 if(child.state == minimized)
7754 child.SetState(minimized, false, mods);
7757 child.positionID = id++;
7758 child.SetState(normal, false, mods);
7759 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7761 child.anchor.left.type = hTiled;
7764 child.normalSizeAnchor = *&child.sizeAnchor;
7765 child.normalAnchor = child.anchor;
7767 // Break the anchors for moveable/resizable windows
7768 if(child.style.fixed)
7770 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7772 (*&child.normalAnchor).left = x;
7773 (*&child.normalAnchor).top = y;
7774 (*&child.normalAnchor).right.type = none;
7775 (*&child.normalAnchor).bottom.type = none;
7776 (*&child.normalSizeAnchor).isClientW = false;
7777 (*&child.normalSizeAnchor).isClientH = false;
7778 (*&child.normalSizeAnchor).size.w = w;
7779 (*&child.normalSizeAnchor).size.h = h;
7780 child.anchored = false;
7783 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7785 child.stateAnchor = child.normalAnchor;
7786 child.stateSizeAnchor = child.normalSizeAnchor;
7788 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7789 child.Position(x,y, w, h, true, true, true, true, false, true);
7794 if((cycle = cycle.next) == document.cycle) break;
7797 firstDocument.Activate();
7802 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7804 Window document = activeChild;
7807 Window firstDocument = null;
7809 OldLink cycle = document.cycle;
7814 //if(child.style.isDocument)
7815 if(child.style.isActiveClient && !child.style.hidden)
7817 if(!firstDocument) firstDocument = child;
7818 if(child.state == minimized)
7819 child.SetState(minimized, false, mods);
7822 child.positionID = id++;
7823 child.SetState(normal, false, mods);
7824 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7826 child.anchor.left.type = vTiled;
7829 child.normalSizeAnchor = *&child.sizeAnchor;
7830 child.normalAnchor = child.anchor;
7832 // Break the anchors for moveable/resizable windows
7833 if(child.style.fixed)
7835 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7837 (*&child.normalAnchor).left = x;
7838 (*&child.normalAnchor).top = y;
7839 (*&child.normalAnchor).right.type = none;
7840 (*&child.normalAnchor).bottom.type = none;
7841 (*&child.normalSizeAnchor).isClientW = false;
7842 (*&child.normalSizeAnchor).isClientH = false;
7843 (*&child.normalSizeAnchor).size.w = w;
7844 (*&child.normalSizeAnchor).size.h = h;
7845 child.anchored = false;
7848 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7850 child.stateAnchor = child.normalAnchor;
7851 child.stateSizeAnchor = child.normalSizeAnchor;
7853 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7854 child.Position(x,y, w, h, true, true, true, true, false, true);
7859 if((cycle = cycle.next) == document.cycle) break;
7862 firstDocument.Activate();
7867 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7869 WindowList dialog { master = this };
7870 Window document = (Window)(intptr)dialog.Modal();
7873 if(activeChild.state == maximized)
7874 document.SetState(maximized, false, mods);
7875 else if(document.state == minimized)
7876 document.SetState(normal, false, mods);
7877 document.Activate();
7883 virtual bool OnCreate(void);
7884 virtual void OnDestroy(void);
7885 virtual void OnDestroyed(void);
7886 virtual bool OnClose(bool parentClosing);
7887 virtual bool OnStateChange(WindowState state, Modifiers mods);
7888 virtual bool OnPostCreate(void);
7889 virtual bool OnMoving(int *x, int *y, int w, int h);
7890 virtual bool OnResizing(int *width, int *height);
7891 virtual void OnResize(int width, int height);
7892 virtual void OnPosition(int x, int y, int width, int height);
7893 virtual bool OnLoadGraphics(void);
7894 virtual void OnApplyGraphics(void);
7895 virtual void OnUnloadGraphics(void);
7896 virtual void OnRedraw(Surface surface);
7897 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7898 virtual void OnActivateClient(Window client, Window previous);
7899 virtual bool OnKeyDown(Key key, unichar ch);
7900 virtual bool OnKeyUp(Key key, unichar ch);
7901 virtual bool OnKeyHit(Key key, unichar ch);
7902 virtual bool OnSysKeyDown(Key key, unichar ch);
7903 virtual bool OnSysKeyUp(Key key, unichar ch);
7904 virtual bool OnSysKeyHit(Key key, unichar ch);
7905 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7906 virtual bool OnMouseLeave(Modifiers mods);
7907 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7908 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7909 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7910 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7911 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7912 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7913 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7914 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7915 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7916 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7917 virtual void OnMouseCaptureLost(void);
7918 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7919 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7920 virtual void OnDrawOverChildren(Surface surface);
7921 virtual bool OnFileModified(FileChange fileChange, const char * param);
7922 virtual bool OnSaveFile(const char * fileName);
7924 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7925 // Note: A 'client' would refer to isActiveClient, rather than
7926 // being confined to the 'client area' (nonClient == false)
7927 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7928 virtual void OnChildVisibilityToggled(Window child, bool visible);
7929 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7931 // Skins Virtual Functions
7932 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7933 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7934 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7939 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7940 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7941 virtual bool IsMouseMoving(int x, int y, int w, int h)
7945 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7949 virtual void UpdateNonClient();
7950 virtual void SetBox(Box box); // This is used in the MySkin skin
7951 virtual bool IsInside(int x, int y)
7953 return box.IsPointInside({x, y});
7955 virtual bool IsOpaque()
7957 return (!style.drawBehind || background.a == 255);
7961 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7962 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7963 virtual void Window::NotifySaved(Window window, const char * filePath);
7968 property Window parent
7970 property_category $"Layout"
7973 if(value || guiApp.desktop)
7976 Window oldParent = parent;
7977 Anchor anchor = this.anchor;
7979 if(value && value.IsDescendantOf(this)) return;
7980 if(value && value == this)
7982 if(!value) value = guiApp.desktop;
7984 if(value == oldParent) return;
7986 if(!master || (master == this.parent && master == guiApp.desktop))
7987 property::master = value;
7991 parent.children.Remove(this);
7995 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7996 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7997 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7998 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
8002 last = value.children.last;
8004 if(style.isDocument)
8007 parent.numDocuments--;
8008 documentID = value.GetDocumentID();
8011 if(style.isActiveClient && !style.hidden)
8013 if(parent && parent != guiApp.desktop && !(style.hidden))
8015 if(state == minimized) parent.numIcons--;
8016 parent.numPositions--;
8020 if(!style.stayOnTop)
8021 for(; last && last.style.stayOnTop; last = last.prev);
8023 value.children.Insert(last, this);
8025 // *** NEW HERE: ***
8027 parent.childrenCycle.Delete(cycle);
8029 parent.childrenOrder.Delete(order);
8032 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
8033 // Should something else be done?
8034 if(parent && parent.activeChild == this)
8035 parent.activeChild = null;
8036 if(parent && parent.activeClient == this)
8037 parent.activeClient = null;
8043 int x = position.x, y = position.y, w = size.w, h = size.h;
8047 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8048 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8050 vpw = value.clientSize.w;
8051 vph = value.clientSize.h;
8057 else if(style.fixed)
8059 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8060 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8063 anchor = this.anchor;
8065 if(anchor.left.type == offset) anchor.left.distance = x;
8066 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8067 if(anchor.top.type == offset) anchor.top.distance = y;
8068 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8069 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8070 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8071 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8072 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8073 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8074 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8076 if(!anchor.left.type && !anchor.right.type)
8078 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8079 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8081 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8082 if(!anchor.top.type && !anchor.bottom.type)
8084 anchor.vert.distance = (y + h / 2) - (vph / 2);
8085 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8087 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8090 parent.OnChildAddedOrRemoved(this, false);
8096 parent.childrenCycle.Insert(
8097 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8098 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8100 cycle = OldLink { data = this });
8101 parent.childrenOrder.Insert(
8102 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8103 order = OldLink { data = this });
8106 if(!style.hidden && style.isActiveClient)
8108 positionID = parent.GetPositionID(this);
8109 parent.numPositions++;
8110 if(state == minimized) parent.numIcons--;
8113 // *** FONT INHERITANCE ***
8114 if(!setFont && oldParent)
8115 stopwatching(oldParent, font);
8119 RemoveResource(systemFont);
8122 // TESTING WITH WATCHERS:
8123 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8124 // usedFont = setFont ? setFont : (systemFont);
8128 if(guiApp.currentSkin)
8130 systemFont = guiApp.currentSkin.SystemFont();
8133 usedFont = systemFont;
8134 AddResource(systemFont);
8142 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8151 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8153 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8154 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8157 UnloadGraphics(false);
8160 LoadGraphics(false, false);
8163 if(value.rootWindow != rootWindow)
8164 DisplayModeChanged();
8168 scrolledPos.x = MININT; // Prevent parent update
8170 bool anchored = this.anchored;
8171 property::anchor = anchor;
8172 this.anchored = anchored;
8177 if(guiApp.currentSkin)
8178 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8180 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8181 Position(x, y, w, h, true, true, true, true, false, true);
8186 // else parent = value;
8188 oldParent.OnChildAddedOrRemoved(this, true);
8191 get { return parent; }
8194 property Window master
8196 property_category $"Behavior"
8199 //if(this == value) return;
8200 if(value && value.IsSlaveOf(this)) return;
8206 OldLink slaveHolder;
8207 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8208 if(slaveHolder.data == this)
8210 master.slaves.Delete(slaveHolder);
8217 value.slaves.Add(OldLink { data = this });
8222 master.hotKeys.Remove(hotKey);
8223 value.hotKeys.Add(hotKey);
8226 if(master && master.defaultControl == this)
8227 master.defaultControl = null;
8229 if(style.isDefault && !value.defaultControl)
8230 value.defaultControl = this;
8235 get { return master ? master : parent; }
8238 property const char * caption
8240 property_category $"Appearance"
8247 caption = new char[strlen(value)+1];
8249 strcpy(caption, value);
8254 get { return caption; }
8259 property_category $"Behavior"
8268 master.hotKeys.Add(hotKey = HotKeySlot { });
8272 hotKey.window = this;
8277 master.hotKeys.Delete(hotKey);
8282 get { return hotKey ? hotKey.key : 0; }
8285 property Color background
8287 property_category $"Appearance"
8290 background.color = value;
8295 if(this == rootWindow)
8296 guiApp.interfaceDriver.SetRootWindowColor(this);
8299 get { return background.color; }
8302 property Percentage opacity
8304 property_category $"Appearance"
8307 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8308 drawBehind = (background.a == 255) ? false : true;
8310 get { return background.a / 255.0f; }
8313 property Color foreground
8315 property_category $"Appearance"
8323 get { return foreground; }
8326 property BorderStyle borderStyle
8328 property_category $"Appearance"
8331 if(!((BorderBits)value).fixed)
8333 style.hasClose = false;
8334 style.hasMaximize = false;
8335 style.hasMinimize = false;
8336 nativeDecorations = false;
8338 style.borderBits = value;
8342 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8344 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8345 Position(x, y, w, h, true, true, true, true, false, true);
8346 CreateSystemChildren();
8349 get { return (BorderStyle)style.borderBits; }
8352 property Size minClientSize
8354 property_category $"Layout"
8355 set { minSize = value; }
8356 get { value = minSize; }
8359 property Size maxClientSize
8361 property_category $"Layout"
8362 set { maxSize = value; }
8363 get { value = maxSize; }
8366 property bool hasMaximize
8368 property_category $"Window Style"
8371 style.hasMaximize = value;
8372 if(value) { style.fixed = true; style.contour = true; }
8376 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8378 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8379 Position(x, y, w, h, true, true, true, true, false, true);
8381 CreateSystemChildren();
8384 get { return style.hasMaximize; }
8387 property bool hasMinimize
8389 property_category $"Window Style"
8392 style.hasMinimize = value;
8393 if(value) { style.fixed = true; style.contour = true; }
8397 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8399 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8400 Position(x, y, w, h, true, true, true, true, false, true);
8402 CreateSystemChildren();
8405 get { return style.hasMinimize; }
8408 property bool hasClose
8410 property_category $"Window Style"
8413 style.hasClose = value;
8414 if(value) { style.fixed = true; style.contour = true; }
8418 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8419 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8420 Position(x, y, w, h, true, true, true, true, false, true);
8421 CreateSystemChildren();
8424 get { return style.hasClose; }
8427 property bool nonClient
8429 property_category $"Layout"
8432 style.nonClient = value;
8434 style.stayOnTop = true;
8436 get { return style.nonClient; }
8439 property bool inactive
8441 property_category $"Behavior"
8446 // *** NEW HERE: ***
8450 parent.childrenCycle.Delete(cycle);
8452 parent.childrenOrder.Delete(order);
8459 active = false; // true;
8460 if(parent.activeChild == this)
8461 parent.activeChild = null;
8462 if(parent.activeClient == this)
8463 parent.activeClient = null;
8472 parent.childrenCycle.Insert(
8473 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8474 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8476 cycle = OldLink { data = this });
8478 parent.childrenOrder.Insert(
8479 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8480 order = OldLink { data = this });
8483 style.inactive = value;
8485 get { return style.inactive; }
8488 property bool clickThrough
8490 property_category $"Behavior"
8491 set { style.clickThrough = value; }
8492 get { return style.clickThrough; }
8495 property bool isRemote
8497 property_category $"Behavior"
8498 set { style.isRemote = value; }
8499 get { return style.isRemote; }
8502 property bool noCycle
8504 property_category $"Behavior"
8505 set { style.noCycle = value; }
8506 get { return style.noCycle; }
8509 property bool isModal
8511 property_category $"Behavior"
8512 set { style.modal = value; }
8513 get { return style.modal; }
8516 property bool interim
8518 property_category $"Behavior"
8519 set { style.interim = value; }
8520 get { return style.interim; }
8523 property bool tabCycle
8525 property_category $"Behavior"
8526 set { style.tabCycle = value; }
8527 get { return style.tabCycle; }
8530 property bool isDefault
8532 property_category $"Behavior"
8540 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8541 if(sibling != this && sibling.style.isDefault)
8542 sibling.style.isDefault = false;*/
8543 if(master.defaultControl)
8544 master.defaultControl.style.isDefault = false;
8545 master.defaultControl = this;
8547 else if(master.defaultControl == this)
8548 master.defaultControl = null;
8552 style.isDefault = value;
8554 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8556 get { return style.isDefault; }
8559 property bool drawBehind
8561 property_category $"Window Style"
8562 set { style.drawBehind = value; }
8563 get { return style.drawBehind; }
8566 property bool hasMenuBar
8568 property_category $"Window Style"
8578 if(created && !menuBar)
8585 anchor = Anchor { top = 23, left = 1, right = 1 },
8587 inactive = true, nonClient = true
8592 else if(created && menuBar)
8597 style.hasMenuBar = value;
8599 get { return style.hasMenuBar; }
8602 property bool hasStatusBar
8604 property_category $"Window Style"
8611 statusBar = StatusBar { this };
8619 style.hasStatusBar = value;
8621 get { return style.hasStatusBar; }
8623 property bool stayOnTop
8625 property_category $"Window Style"
8630 if(created && !style.stayOnTop)
8632 if(rootWindow == this)
8633 guiApp.interfaceDriver.OrderRootWindow(this, true);
8634 else if(parent.children.last != this)
8636 parent.children.Move(this, parent.children.last);
8640 style.stayOnTop = true;
8644 if(created && style.stayOnTop)
8646 if(rootWindow == this)
8647 guiApp.interfaceDriver.OrderRootWindow(this, false);
8654 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8655 order && ((Window)order.data).style.stayOnTop;
8656 order = (order == parent.childrenOrder.first) ? null : order.prev);
8657 last = order ? order.data : null;
8661 for(last = parent.children.last;
8662 last && last.style.stayOnTop;
8666 parent.children.Move(this, last);
8670 style.stayOnTop = false;
8673 get { return style.stayOnTop; }
8678 property_category $"Window Style"
8688 if(menuBar && !value)
8695 if(!menuBar && style.hasMenuBar && value)
8699 this, menu = value, isMenuBar = true,
8700 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8701 inactive = true, nonClient = true
8705 UpdateActiveDocument(null);
8708 get { return menu; }
8711 property FontResource font
8713 property_category $"Appearance"
8715 isset { return setFont ? true : false; }
8720 if(value && !setFont) { stopwatching(parent, font); }
8721 else if(!value && setFont)
8727 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8736 RemoveResource(setFont);
8741 RemoveResource(systemFont);
8748 AddResource(setFont);
8751 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8754 systemFont = guiApp.currentSkin.SystemFont();
8756 usedFont = systemFont;
8757 AddResource(systemFont);
8765 get { return usedFont; }
8768 property SizeAnchor sizeAnchor
8770 property_category $"Layout"
8773 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8774 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8775 sizeAnchor.isClientW != sizeAnchor.isClientH;
8782 normalSizeAnchor = sizeAnchor;
8784 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8786 stateAnchor = normalAnchor;
8787 stateSizeAnchor = normalSizeAnchor;
8789 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8790 Position(x,y, w, h, true, true, true, true, false, true);
8797 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8798 sizeAnchor.isClientW,
8799 sizeAnchor.isClientH
8806 property_category $"Layout"
8809 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8810 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8811 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8817 sizeAnchor.isClientW = false;
8818 sizeAnchor.isClientH = false;
8819 sizeAnchor.size = value;
8821 normalSizeAnchor = sizeAnchor;
8823 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8825 stateAnchor = normalAnchor;
8826 stateSizeAnchor = normalSizeAnchor;
8828 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8829 Position(x, y, w, h, true, true, true, true, false, true);
8830 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8833 get { value = size; }
8836 property Size clientSize
8838 property_category $"Layout"
8841 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8842 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8843 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8848 sizeAnchor.isClientW = true;
8849 sizeAnchor.isClientH = true;
8850 sizeAnchor.size = value;
8852 normalSizeAnchor = sizeAnchor;
8854 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8856 stateAnchor = normalAnchor;
8857 stateSizeAnchor = normalSizeAnchor;
8859 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8860 Position(x,y, w, h, true, true, true, true, false, true);
8861 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8864 get { value = this ? clientSize : { 0, 0 }; }
8867 property Size initSize { get { value = sizeAnchor.size; } };
8869 property Anchor anchor
8871 property_category $"Layout"
8872 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8878 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8880 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8881 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8883 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8885 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8886 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8890 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8892 anchor.left.distance = 0;
8893 anchor.horz.type = 0;
8895 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8897 anchor.top.distance = 0;
8898 anchor.vert.type = 0;
8907 normalAnchor = anchor;
8909 // Break the anchors for moveable/resizable windows
8910 /*if(style.fixed ) //&& value.left.type == cascade)
8912 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8914 this.anchor = normalAnchor = Anchor { left = x, top = y };
8915 normalSizeAnchor = SizeAnchor { { w, h } };
8918 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8920 stateAnchor = normalAnchor;
8921 stateSizeAnchor = normalSizeAnchor;
8923 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8924 Position(x, y, w, h, true, true, true, true, false, true);
8933 get { value = this ? anchor : Anchor { }; }
8936 property Point position
8938 property_category $"Layout"
8941 if(value == null) return;
8943 anchor.left = value.x;
8944 anchor.top = value.y;
8945 anchor.right.type = none;
8946 anchor.bottom.type = none;
8951 normalAnchor = anchor;
8953 // Break the anchors for moveable/resizable windows
8957 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8959 normalAnchor.left = x;
8960 normalAnchor.top = y;
8961 normalAnchor.right.type = none;
8962 normalAnchor.bottom.type = none;
8963 normalSizeAnchor.size.width = w;
8964 normalSizeAnchor.size.height = h;
8968 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8970 stateAnchor = normalAnchor;
8971 stateSizeAnchor = normalSizeAnchor;
8973 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8974 Position(x,y, w, h, true, true, true, true, false, true);
8978 get { value = position; }
8981 property bool disabled
8983 property_category $"Behavior"
8986 if(this && disabled != value)
8993 get { return (bool)disabled; }
8996 property bool isEnabled
9001 for(parent = this; parent; parent = parent.parent)
9008 property WindowState state
9010 property_category $"Behavior"
9011 set { SetState(value, false, 0); }
9012 get { return this ? state : 0; }
9015 property bool visible
9017 property_category $"Behavior"
9020 if(this && !value && !style.hidden && parent)
9022 bool wasActiveChild = parent.activeChild == this;
9023 Window client = null;
9025 style.hidden = true;
9026 if(style.isActiveClient)
9028 parent.numPositions--;
9029 if(state == minimized) parent.numIcons--;
9034 OldLink prevOrder = null;
9036 if(rootWindow == this)
9037 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9040 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9043 box.left -= parent.clientStart.x;
9044 box.top -= parent.clientStart.y;
9045 box.right -= parent.clientStart.x;
9046 box.bottom -= parent.clientStart.y;
9050 if(_isModal && master && master.modalSlave == this)
9051 master.modalSlave = null;
9055 OldLink tmpPrev = order.prev;
9056 client = tmpPrev ? tmpPrev.data : null;
9057 if(client && !client.style.hidden && !client.destroyed && client.created)
9058 prevOrder = tmpPrev;
9061 client = tmpPrev ? tmpPrev.data : null;
9062 if(client == this) { client = null; break; }
9063 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9065 tmpPrev = client.order.prev;
9070 prevOrder = tmpPrev;
9075 // If this window can be an active client, make sure the next window we activate can also be one
9076 if(!style.nonClient && style.isActiveClient)
9078 tmpPrev = prevOrder;
9081 client = tmpPrev ? tmpPrev.data : null;
9082 if(client == this) { client = null; break; }
9083 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9085 tmpPrev = client.order.prev;
9090 prevOrder = tmpPrev;
9094 if(client && client.style.hidden) client = null;
9098 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9100 if(order && prevOrder && prevOrder.data != this)
9101 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9103 ActivateEx(false, false, false, true, null, null);
9105 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9106 if(parent.activeClient == this)
9108 parent.activeClient = null;
9109 parent.UpdateActiveDocument(null);
9112 else if(parent.activeClient == this)
9114 parent.activeClient = client;
9115 parent.UpdateActiveDocument(this);
9118 // *** Not doing this anymore ***
9121 parent.childrenCycle.Delete(cycle);
9123 parent.childrenOrder.Delete(order);
9128 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9133 else if(this && value && style.hidden)
9135 style.hidden = false;
9138 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9139 if(rootWindow == this)
9140 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9142 if(_isModal && master)
9143 master.modalSlave = this;
9145 if(style.isActiveClient)
9147 positionID = parent.GetPositionID(this);
9148 parent.numPositions++;
9149 if(state == minimized) parent.numIcons++;
9152 // *** NOT DOING THIS ANYMORE ***
9154 if(!(style.inactive))
9156 if(!(style.noCycle))
9158 cycle = parent.childrenCycle.AddAfter(
9159 (parent.activeChild && parent.activeChild.cycle) ?
9160 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9163 order = parent.childrenOrder.AddAfter(
9164 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9171 if(true || !parent.activeChild)
9172 ActivateEx(true, false, true, true, null, null);
9174 if(creationActivation == activate && guiApp.desktop.active)
9175 ActivateEx(true, false, true, true, null, null);
9176 else if((creationActivation == activate || creationActivation == flash) && !object)
9179 if(this == rootWindow)
9183 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9187 ConsequentialMouseMove(false);
9193 style.hidden = !value;
9196 get { return (style.hidden || !setVisible) ? false : true; }
9199 property bool isDocument
9201 property_category $"Document"
9202 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9203 get { return style.isDocument; }
9206 property bool mergeMenus
9208 property_category $"Window Style"
9209 set { mergeMenus = value; }
9210 get { return (bool)mergeMenus; }
9213 property bool hasHorzScroll
9215 property_category $"Window Style"
9220 if(!style.hasHorzScroll && created)
9222 CreateSystemChildren();
9223 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9226 else if(style.hasHorzScroll)
9230 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9232 style.hasHorzScroll = value;
9235 get { return style.hasHorzScroll; }
9238 property bool hasVertScroll
9240 property_category $"Window Style"
9245 if(!style.hasVertScroll && created)
9247 style.hasVertScroll = true;
9248 CreateSystemChildren();
9249 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9252 else if(style.hasVertScroll)
9256 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9258 style.hasVertScroll = value;
9260 get { return style.hasVertScroll; }
9263 property bool dontHideScroll
9265 property_category $"Behavior"
9268 scrollFlags.dontHide = value;
9271 //UpdateScrollBars(true, true);
9272 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9276 // UpdateScrollBars(true, true);
9277 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9280 get { return scrollFlags.dontHide; }
9283 property bool dontScrollVert
9285 property_category $"Behavior"
9286 set { style.dontScrollVert = value; }
9287 get { return style.dontScrollVert; }
9289 property bool dontScrollHorz
9291 property_category $"Behavior"
9292 set { style.dontScrollHorz = value; }
9293 get { return style.dontScrollHorz; }
9296 property bool snapVertScroll
9298 property_category $"Behavior"
9301 scrollFlags.snapY = value;
9302 if(sbv) sbv.snap = value;
9304 get { return scrollFlags.snapY; }
9306 property bool snapHorzScroll
9308 property_category $"Behavior"
9311 scrollFlags.snapX = value;
9312 if(sbh) sbh.snap = value;
9314 get { return scrollFlags.snapX; }
9317 property Point scroll
9319 property_category $"Behavior"
9320 set { if(this) SetScrollPosition(value.x, value.y); }
9321 get { value = scroll; }
9324 property bool modifyVirtualArea
9326 property_category $"Behavior"
9327 set { modifyVirtArea = value; }
9328 get { return (bool)modifyVirtArea; }
9331 property bool dontAutoScrollArea
9333 property_category $"Behavior"
9334 // Activating a child control out of view will automatically scroll to make it in view
9335 set { noAutoScrollArea = value; }
9336 get { return (bool)noAutoScrollArea; }
9339 property const char * fileName
9341 property_category $"Document"
9346 if(menu && ((!fileName && value) || (fileName && !value)))
9348 MenuItem item = menu.FindItem(MenuFileSave, 0);
9349 if(item) item.disabled = !modifiedDocument && value;
9354 if(value && value[0])
9355 fileName = CopyString(value);
9357 if(parent && this == parent.activeClient)
9358 parent.UpdateActiveDocument(null);
9362 // if(style.isDocument)
9364 fileMonitor.fileName = value;
9366 get { return fileName; }
9371 property_category $"Data"
9376 property bool modifiedDocument
9378 property_category $"Document"
9381 if(style.isDocument || fileName)
9385 MenuItem item = menu.FindItem(MenuFileSave, 0);
9386 if(item) item.disabled = !value && fileName;
9390 if(modifiedDocument != value)
9392 modifiedDocument = value;
9393 if(style.isDocument || fileName)
9397 get { return (bool)modifiedDocument; }
9400 property bool showInTaskBar
9402 property_category $"Window Style"
9403 set { style.showInTaskBar = value; }
9404 get { return style.showInTaskBar; }
9406 property FileDialog saveDialog { set { saveDialog = value; } };
9407 property bool isActiveClient
9409 property_category $"Behavior"
9412 if(parent && style.isActiveClient != value && !style.hidden)
9416 if(state == minimized) parent.numIcons++;
9417 parent.numPositions++;
9421 if(state == minimized) parent.numIcons--;
9422 parent.numPositions--;
9425 style.isActiveClient = value;
9427 get { return style.isActiveClient; }
9430 property Cursor cursor
9432 property_category $"Appearance"
9436 SelectMouseCursor();
9438 get { return cursor; }
9441 //#if !defined(ECERE_VANILLA)
9442 property const char * name
9444 property_category $"Design"
9447 return (this && object) ? object.name : null;
9452 activeDesigner.RenameObject(object, value);
9456 property const char * displayDriver
9458 property_category $"Behavior"
9461 dispDriver = GetDisplayDriver(value);
9462 //DisplayModeChanged();
9466 return dispDriver ? dispDriver.name : null;
9470 // RUNTIME PROPERTIES
9471 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9472 property Size scrollArea
9474 property_category $"Behavior"
9478 SetScrollArea(value.w, value.h, false);
9480 SetScrollArea(0,0, true);
9482 get { value = scrollArea; }
9485 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9490 property_category $"Layout"
9491 set { if(this) is3D = value; }
9492 get { return (bool)is3D; }
9495 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9497 // Will be merged with font later
9498 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9499 property Point clientStart { get { value = clientStart; } };
9500 property Point absPosition { get { value = absPosition; } };
9501 property Anchor normalAnchor { get { value = normalAnchor; } };
9502 property SizeAnchor normalSizeAnchor { get { value = normalSizeAnchor; } };
9503 property bool active { get { return (bool)active; } };
9504 property bool created { get { return (bool)created; } };
9505 property bool destroyed { get { return (bool)destroyed; } };
9506 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9507 property Window firstChild { get { return children.first; } };
9508 property Window lastChild { get { return children.last; } };
9509 property Window activeClient { get { return activeClient; } };
9510 property Window activeChild { get { return activeChild; } };
9511 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9512 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9513 property ScrollBar horzScroll { get { return sbh; } };
9514 property ScrollBar vertScroll { get { return sbv; } };
9515 property StatusBar statusBar { get { return statusBar; } };
9516 property Window rootWindow { get { return rootWindow; } };
9517 property bool closing { get { return (bool)closing; } set { closing = value; } };
9518 property int documentID { get { return documentID; } };
9519 property Window previous { get { return prev; } }
9520 property Window next { get { return next; } }
9521 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9522 property PopupMenu menuBar { get { return menuBar; } }
9523 property ScrollBar sbv { get { return sbv; } }
9524 property ScrollBar sbh { get { return sbh; } }
9525 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9526 property void * systemHandle { get { return windowHandle; } }
9527 property Button minimizeButton { get { return sysButtons[0]; } };
9528 property Button maximizeButton { get { return sysButtons[1]; } };
9529 property Button closeButton { get { return sysButtons[2]; } };
9530 property BitmapResource icon
9532 get { return icon; }
9536 if(icon) incref icon;
9538 guiApp.interfaceDriver.SetIcon(this, value);
9541 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9542 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9543 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9544 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9545 property bool nativeDecorations
9547 get { return (bool)nativeDecorations; }
9548 set { nativeDecorations = value; }
9549 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9552 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9553 bool result = false;
9554 if(nativeDecorations)
9556 if(rootWindow == this)
9560 if(formDesigner && activeDesigner)
9562 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9563 Window form = cd ? cd.form : null;
9564 if(form && parent == form.parent)
9569 return result != style.fixed;
9573 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9575 property const char * text
9577 property_category $"Deprecated"
9579 set { property::caption = value; }
9580 get { return property::caption; }
9586 WindowBits style; // Window Style
9587 char * caption; // Name / Caption
9588 Window parent; // Parent window
9589 OldList children; // List of children in Z order
9590 Window activeChild; // Child window having focus
9591 Window activeClient;
9592 Window previousActive; // Child active prior to activating the default child
9593 Window master; // Window owning and receiving notifications concerning this window
9594 OldList slaves; // List of windows belonging to this window
9595 Display display; // Display this window is drawn into
9597 Point position; // Position in parent window client area
9598 Point absPosition; // Absolute position
9599 Point clientStart; // Client area position from (0,0) in this window
9601 Size clientSize; // Client area size
9602 Size scrollArea; // Virtual Scroll area size
9603 Size reqScrollArea; // Requested virtual area size
9604 Point scroll; // Virtual area scrolling position
9605 ScrollBar sbh, sbv; // Scrollbar window handles
9606 Cursor cursor; // Mouse cursor used for this window
9609 StatusBar statusBar;
9610 Button sysButtons[3];
9612 Box clientArea; // Client Area box clipped to parent
9614 HotKeySlot hotKey; // HotKey for this window
9618 ScrollFlags scrollFlags;// Window Scrollbar Flags
9619 int64 id; // Control ID
9621 ColorAlpha background; // Background color used to draw the window area
9623 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9624 OldList childrenCycle; // Cycling order
9625 OldLink cycle; // Element of parent's cycling order
9626 OldList childrenOrder; // Circular Z-Order
9627 OldLink order; // Element of parent's circular Z-Order
9628 Window modalSlave; // Slave window blocking this window's interaction
9630 Window rootWindow; // Topmost system managed window
9631 void * windowHandle; // System window handle
9633 DialogResult returnCode;// Return code for modal windows
9635 Point sbStep; // Scrollbar line scrolling steps
9638 SizeAnchor stateSizeAnchor;
9640 Anchor normalAnchor;
9641 SizeAnchor normalSizeAnchor;
9643 Size skinMinSize; // Minimal window size based on style
9644 Point scrolledPos; // Scrolled position
9645 Box box; // Window box clipped to parent
9646 Box * against; // What to clip the box to
9648 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9649 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9650 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9651 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9652 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9653 Point scrolledArea; // Distance to scroll area by
9654 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9656 OldList hotKeys; // List of the hotkeys of all children
9657 Window defaultControl; // Default child control
9661 ColorAlpha * palette; // Color palette used for this window
9663 int caretSize; // Size of caret, non zero if a caret is present
9664 Point caretPos; // Caret position
9666 void * systemParent; // Parent System Window for embedded windows
9673 WindowState lastState;
9675 FileMonitor fileMonitor;
9677 FontResource setFont, systemFont;
9678 FontResource usedFont;
9679 FontResource captionFont;
9681 FileDialog saveDialog;
9683 SizeAnchor sizeAnchor;
9685 // FormDesigner data
9688 Extent * tempExtents; //[4];
9689 BitmapResource icon;
9691 CreationActivationOption creationActivation;
9694 bool active:1; // true if window and ancestors are active
9695 bool acquiredInput:1; // true if the window is processing state based input
9696 bool modifiedDocument:1;
9697 bool disabled:1; // true if window cannot interact
9698 bool isForegroundWindow:1;// true while a root window is being activated
9699 bool visible:1; // Visibility flag
9700 bool destroyed:1; // true if window is being destroyed
9701 bool anchored:1; // true if this window is repositioned when the parent resizes
9702 bool dirty:1; // Flag set to true if any descendant must be redrawn
9708 bool modifyVirtArea:1;
9709 bool noAutoScrollArea:1;
9712 bool setVisible:1; // FOR FORM DESIGNER
9718 bool useSharedMemory:1;
9721 bool nativeDecorations:1;
9722 bool manageDisplay:1;
9723 bool formDesigner:1; // True if we this is running in the form editor
9724 bool requireRemaximize:1;
9727 // Checks used internally for them not to take effect in FormDesigner
9728 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9729 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9731 WindowController controller;
9732 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9735 public class CommonControl : Window
9737 // creationActivation = doNothing;
9740 public property const String toolTip
9742 property_category $"Appearance"
9745 if(created) CommonControl::OnDestroy();
9747 toolTip = value ? ToolTip { tip = value; } : null;
9749 if(created) CommonControl::OnCreate();
9751 get { return toolTip ? toolTip.tip : null; }
9757 // (Very) Ugly work around for the fact that the parent watcher
9758 // won't fire when it's already been disconnected...
9759 eInstance_FireSelfWatchers(toolTip,
9760 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9766 toolTip.parent = this;
9775 public class Percentage : float
9777 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9781 sprintf(string, "%.2f", this);
9782 c = strlen(string)-1;
9785 if(string[c] != '0')
9786 last = Max(last, c);
9787 if(string[c] == '.')
9800 public void ApplySkin(Class c, const char * name, void ** vTbl)
9802 char className[1024];
9807 subclass(Window) wc = (subclass(Window))c;
9808 subclass(Window) base = (subclass(Window))c.base;
9810 sprintf(className, "%sSkin_%s", name, c.name);
9811 wc.pureVTbl = c._vTbl;
9812 c._vTbl = new void *[c.vTblSize];
9813 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9814 sc = eSystem_FindClass(c.module.application, className);
9818 for(m = 0; m < c.base.vTblSize; m++)
9820 if(c._vTbl[m] == base.pureVTbl[m])
9821 c._vTbl[m] = vTbl[m];
9826 for(m = 0; m < c.vTblSize; m++)
9828 if(sc._vTbl[m] != wc.pureVTbl[m])
9829 c._vTbl[m] = sc._vTbl[m];
9833 for(d = c.derivatives.first; d; d = d.next)
9835 ApplySkin(d.data, name, c._vTbl);
9839 public void UnapplySkin(Class c)
9841 subclass(Window) wc = (subclass(Window))c;
9844 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9847 c._vTbl = wc.pureVTbl;
9851 for(d = c.derivatives.first; d; d = d.next)
9853 UnapplySkin(d.data);
9857 void CheckFontIntegrity(Window window)
9862 if(window.usedFont && window.usedFont.font == 0xecececec)
9864 FontResource uf = window.usedFont;
9865 char * className = window._class.name;
9866 char * text = window.text;
9869 for(c = window.firstChild; c; c = c.next)
9870 CheckFontIntegrity(c);
9874 public class ControllableWindow : Window
9876 /*WindowController controller;
9877 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9878 ~ControllableWindow() { delete controller; }*/
9881 class WindowControllerInterface : ControllableWindow
9883 bool OnKeyDown(Key key, unichar ch)
9885 bool result = controller.OnKeyDown ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch) : true;
9888 bool (* onKeyDown)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown];
9890 result = onKeyDown(controller.window, key, ch);
9895 bool OnKeyUp(Key key, unichar ch)
9897 bool result = controller.OnKeyUp ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch) : true;
9900 bool (* onKeyUp)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp];
9902 result = onKeyUp(controller.window, key, ch);
9907 bool OnKeyHit(Key key, unichar ch)
9909 bool result = controller.OnKeyHit ? ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch) : true;
9912 bool (* onKeyHit)(Window, Key, unichar) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit];
9914 result = onKeyHit(controller.window, key, ch);
9919 bool OnMouseMove(int x, int y, Modifiers mods)
9921 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9924 bool(* onMouseMove)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove];
9926 result = onMouseMove(controller.window, x, y, mods);
9931 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9933 bool result = controller.OnLeftButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
9936 bool(* onLeftButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown];
9937 if(onLeftButtonDown)
9938 result = onLeftButtonDown(controller.window, x, y, mods);
9943 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9945 bool result = controller.OnLeftButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
9948 bool(* onLeftButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp];
9950 result = onLeftButtonUp(controller.window, x, y, mods);
9955 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9957 bool result = controller.OnLeftDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
9960 bool(* onLeftDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick];
9961 if(onLeftDoubleClick)
9962 result = onLeftDoubleClick(controller.window, x, y, mods);
9967 bool OnRightButtonDown(int x, int y, Modifiers mods)
9969 bool result = controller.OnRightButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
9972 bool(* onRightButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown];
9973 if(onRightButtonDown)
9974 result = onRightButtonDown(controller.window, x, y, mods);
9979 bool OnRightButtonUp(int x, int y, Modifiers mods)
9981 bool result = controller.OnRightButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
9984 bool(* onRightButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp];
9986 result = onRightButtonUp(controller.window, x, y, mods);
9991 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9993 bool result = controller.OnRightDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
9996 bool(* onRightDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick];
9997 if(onRightDoubleClick)
9998 result = onRightDoubleClick(controller.window, x, y, mods);
10003 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
10005 bool result = controller.OnMiddleButtonDown ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods) : true;
10008 bool(* onMiddleButtonDown)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown];
10009 if(onMiddleButtonDown)
10010 result = onMiddleButtonDown(controller.window, x, y, mods);
10015 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
10017 bool result = controller.OnMiddleButtonUp ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods) : true;
10020 bool(* onMiddleButtonUp)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp];
10021 if(onMiddleButtonUp)
10022 result = onMiddleButtonUp(controller.window, x, y, mods);
10027 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
10029 bool result = controller.OnMiddleDoubleClick ? ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods) : true;
10032 bool(* onMiddleDoubleClick)(Window, int, int, Modifiers) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick];
10033 if(onMiddleDoubleClick)
10034 onMiddleDoubleClick(controller.window, x, y, mods);
10039 void OnResize(int width, int height)
10041 if(controller.OnResize)
10042 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
10044 void(* onResize)(Window, int, int) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize];
10046 onResize(controller.window, width, height);
10050 void OnRedraw(Surface surface)
10052 if(controller.OnRedraw)
10053 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
10055 void(* onRedraw)(Window, Surface) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw];
10057 onRedraw(controller.window, surface);
10063 bool result = controller.OnCreate ? ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller) : true;
10066 bool(* onCreate)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate];
10068 result = onCreate(controller.window);
10073 bool OnLoadGraphics()
10075 bool result = controller.OnLoadGraphics ? ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller) : true;
10078 bool(* onLoadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics];
10080 result = onLoadGraphics(controller.window);
10085 void OnUnloadGraphics()
10087 if(controller.OnUnloadGraphics)
10088 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
10090 void(* onUnloadGraphics)(Window) = (void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics];
10091 if(onUnloadGraphics)
10092 onUnloadGraphics(controller.window);
10097 public class WindowController<class V>
10100 property Window window
10104 uint size = class(Window).vTblSize;
10107 windowVTbl = new void *[size];
10108 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
10109 if(value._vTbl == value._class._vTbl)
10111 value._vTbl = new void *[value._class.vTblSize];
10112 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10116 for(c = 0; c < size; c++)
10118 void * function = class(WindowControllerInterface)._vTbl[c];
10119 if(function && function != DefaultFunction)
10120 value._vTbl[c] = function;
10122 value._vTbl[c] = windowVTbl[c];
10127 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10130 get { return window; }
10132 property V controlled
10134 set { controlled = value; }
10135 get { return controlled; }
10137 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10138 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10139 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10140 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10141 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10142 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10143 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10144 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10145 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10146 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10147 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10148 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10149 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10150 virtual void V::OnResize(WindowController controller, int width, int height);
10151 virtual void V::OnRedraw(WindowController controller, Surface surface);
10152 virtual bool V::OnCreate(WindowController controller);
10153 virtual bool V::OnLoadGraphics(WindowController controller);
10154 virtual void V::OnUnloadGraphics(WindowController controller);
10157 int (** windowVTbl)();
10161 ~WindowController()