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 x += rootWindow.parent.clientStart.x;
771 y += rootWindow.parent.clientStart.y;
773 mox.left += rootWindow.parent.clientStart.x;
774 mox.top += rootWindow.parent.clientStart.y;
775 mox.right += rootWindow.parent.clientStart.x;
776 mox.bottom += rootWindow.parent.clientStart.y;
781 surface = display.GetSurface(x, y, mox);
784 surface.width = clientSize.w;
785 surface.height = clientSize.h;
791 // Setup a bitmap for Redrawing on full Window
792 Surface RedrawFull(Box box)
794 Surface surface = null;
802 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
804 int x = absPosition.x;
805 int y = absPosition.y;
806 if(rootWindow.nativeDecorations && rootWindow.windowHandle && !is3D)
808 x -= rootWindow.clientStart.x;
809 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
811 if(!guiApp.fullScreenMode || is3D)
813 x -= rootWindow.absPosition.x;
814 y -= rootWindow.absPosition.y;
817 x += rootWindow.parent.clientStart.x;
818 y += rootWindow.parent.clientStart.y;
820 mox.left += rootWindow.parent.clientStart.x;
821 mox.top += rootWindow.parent.clientStart.y;
822 mox.right += rootWindow.parent.clientStart.x;
823 mox.bottom += rootWindow.parent.clientStart.y;
828 surface = display.GetSurface(x, y, mox);
831 surface.width = size.w;
832 surface.height = size.h;
838 void FigureCaption(char * caption)
840 Window activeClient = null;
844 strcpy(caption, this.caption);
845 if(style.isDocument || fileName)
847 if(caption[0]) strcat(caption, " - ");
849 strcat(caption, fileName);
853 sprintf(title, "Untitled %d", documentID);
854 strcat(caption, title);
857 strcat(caption, " *");
862 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
864 if(activeClient && activeClient.state == maximized)
866 if(activeClient.caption)
868 if(caption[0]) strcat(caption, " - ");
869 strcat(caption, activeClient.caption);
871 if(activeClient.style.isDocument || activeClient.fileName)
873 if(caption[0]) strcat(caption, " - ");
874 strcat(caption, "[");
875 if(activeClient.fileName)
876 strcat(caption, activeClient.fileName);
880 sprintf(title, "Untitled %d", activeClient.documentID);
881 strcat(caption, title);
883 if(activeClient.modifiedDocument)
884 strcat(caption, " *");
885 strcat(caption, "]");
890 // Code for returning dirty from ScrollDisplay:
892 for(d = 0; d<scrollExtent.count; d++)
894 Box * box = &scrollExtent.boxes[d];
900 Min(box.right, box.left-scroll.x),box.bottom
902 dirtyArea.UnionBox(update);
908 Max(box.left, box.right-scroll.x), box.top,
909 box.right, box.bottom
911 dirtyArea.UnionBox(update);
919 box.right, Min(box.bottom, box.top-scroll.y),
921 dirtyArea.UnionBox(update);
927 box.left, Max(box.top, box.bottom-scroll.y),
928 box.right, box.bottom
930 dirtyArea.UnionBox(update);
935 void UpdateDecorations(void)
937 // TODO: *** TEMPORARY HACK ***
944 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
946 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
948 Update({ -clientStart.x,0, -1, clientSize.h-1 });
950 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
953 // Returns w & h for Position
954 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
956 Window parent = this.parent ? this.parent : guiApp.desktop;
957 int xOffset = 0, yOffset = 0;
958 int vpw = parent ? parent.clientSize.w : 0;
959 int vph = parent ? parent.clientSize.h : 0;
960 int pw = parent ? parent.clientSize.w : 0;
961 int ph = parent ? parent.clientSize.h : 0;
962 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
963 int x = anchor.left.distance, y = anchor.top.distance;
964 float ex = 0, ey = 0;
965 MinMaxValue ew = 0, eh = 0;
967 float cascadeW, cascadeH;
969 int tilingW, tilingH, tilingSplit, tilingLastH = 0;
970 int addX = 0, addY = 0;
972 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
974 Window masterWindow = this;
975 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
978 if(master == guiApp.desktop)
979 masterWindow = guiApp.desktop.activeChild;
981 masterWindow = master.rootWindow;
982 if(!masterWindow) masterWindow = this;
984 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
985 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
988 pw = vpw = box.right - box.left + 1;
990 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
993 ph = vph = box.bottom - box.top + 1;
1009 vpw = pw = parent.size.w;
1010 vph = ph = parent.size.h;
1012 else if(!style.fixed /*|| style.isDocument*/)
1014 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1015 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1017 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1020 Desktop3D_FixSize(&pw, &ph);
1021 Desktop3D_FixSize(&vpw, &vph);
1024 if(pw < skinMinSize.w) pw = skinMinSize.w;
1025 if(ph < skinMinSize.h) ph = skinMinSize.h;
1026 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1027 if(vph < skinMinSize.h) vph = skinMinSize.h;
1029 // TODO: Must fix what we're snapping
1032 if(anchor.left.type)
1034 SNAPUP(x, textCellW);
1036 else if(anchor.right.type)
1038 SNAPDOWN(x, textCellW);
1043 SNAPUP(y, textCellH);
1045 else if(anchor.bottom.type)
1047 SNAPDOWN(y, textCellH);
1051 // This is required to get proper initial decoration size using native decorations on Windows
1052 #if defined(__WIN32__)
1053 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1054 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1056 GetDecorationsSize(&ew, &eh);
1058 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1060 // Leave room for non client windows (eventually dockable panels)
1062 int loX = 0, loY = 0, hiX = pw, hiY = ph;
1063 for(win = parent.children.first; win; win = win.next)
1065 if(!win.nonClient && !win.isActiveClient && win.visible)
1067 Size size = win.size;
1068 Point pos = win.position;
1069 int left = pos.x, top = pos.y;
1070 int right = pos.x + size.w, bottom = pos.y + size.h;
1071 if(win.size.w > win.size.h)
1074 loY = Max(loY, bottom);
1075 else if(top > ph - ph / 4)
1076 hiY = Min(hiY, top);
1081 loX = Max(loX, right);
1082 else if(left > pw - pw / 4)
1083 hiX = Min(hiX, left);
1092 if(parent.sbv && !parent.sbv.style.hidden)
1093 pw += guiApp.currentSkin.VerticalSBW();
1094 if(parent.sbh && !parent.sbh.style.hidden)
1095 ph += guiApp.currentSkin.HorizontalSBH();
1097 if(anchor.left.type == cascade)
1099 w = (int)(pw * 0.80);
1100 h = (int)(ph * 0.80);
1102 else if(anchor.left.type >= vTiled)
1107 numTiling = parent.numPositions - parent.numIcons;
1108 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1109 if(anchor.left.type == vTiled)
1111 tilingH = (int)sqrt(numTiling);
1112 tilingW = numTiling / tilingH;
1116 tilingW = (int)sqrt(numTiling);
1117 tilingH = numTiling / tilingW;
1120 leftOver = numTiling - tilingH * tilingW;
1123 tilingSplit = (tilingW - leftOver) * tilingH;
1124 tilingLastH = tilingH+1;
1127 tilingSplit = numTiling;
1129 if(positionID >= tilingSplit)
1131 x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1132 y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1133 x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1134 y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1138 x = xOffset + pw * (positionID / tilingH) / tilingW;
1139 y = yOffset + ph * (positionID % tilingH) / tilingH;
1140 x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
1141 y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
1145 SNAPDOWN(x, textCellW);
1146 SNAPDOWN(y, textCellH);
1147 SNAPDOWN(x2, textCellW);
1148 SNAPDOWN(y2, textCellH);
1156 if(sizeAnchor.isClientW) w += ew;
1157 if(sizeAnchor.isClientH) h += eh;
1159 if(anchor.left.type == offset)
1160 x = anchor.left.distance;
1161 else if(anchor.left.type == relative)
1162 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1163 else if(anchor.right.type == relative)
1164 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1165 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1166 else if(anchor.right.type == offset)
1167 ex = vpw - anchor.right.distance;
1169 if(anchor.top.type == offset)
1170 y = anchor.top.distance;
1171 else if(anchor.top.type == relative)
1172 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1173 else if(anchor.bottom.type == relative)
1174 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1175 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1176 else if(anchor.bottom.type == offset)
1177 ey = vph - anchor.bottom.distance;
1179 if(anchor.left.type && anchor.right.type)
1181 switch(anchor.right.type)
1184 ex = pw * (1.0f-anchor.right.percent);
1185 w = Max((int)(ex + 0.5) - x, 0);
1188 ex = vpw - anchor.right.distance;
1189 w = Max((int)(ex + 0.5) - x, 0);
1193 if(anchor.top.type && anchor.bottom.type)
1195 switch(anchor.bottom.type)
1198 ey = ph * (1.0f-anchor.bottom.percent);
1199 h = Max((int)(ey + 0.5) - y, 0);
1202 ey = vph - anchor.bottom.distance;
1203 h = Max((int)(ey + 0.5) - y, 0);
1212 if(state == normal /*|| state == Hidden*/)
1214 bool addSbV = false, addSbH = false;
1216 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1217 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1219 w = Max(w, minSize.w);
1220 h = Max(h, minSize.h);
1221 w = Min(w, maxSize.w);
1222 h = Min(h, maxSize.h);
1224 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1226 if(w) w -= guiApp.currentSkin.VerticalSBW();
1229 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1231 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1235 if(!OnResizing(&w, &h))
1241 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1242 w += guiApp.currentSkin.VerticalSBW();
1243 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1244 h += guiApp.currentSkin.HorizontalSBH();
1246 w = Max(w, skinMinSize.w);
1247 h = Max(h, skinMinSize.h);
1260 SNAPDOWN(w, textCellW);
1261 SNAPDOWN(h, textCellH);
1264 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1266 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1269 (pw - w) / CASCADE_SPACE,
1270 (ph - h) / CASCADE_SPACE);
1276 cascW = (pw - w) / (numCascade-1);
1277 cascH = (ph - h) / (numCascade-1);
1278 SNAPDOWN(cascW, textCellW);
1279 SNAPDOWN(cascH, textCellH);
1280 cascadeW = (float)cascW;
1281 cascadeH = (float)cascH;
1285 numCascade = Max(numCascade, 2);
1286 cascadeW = (float)(pw - w) / (numCascade-1);
1287 cascadeH = (float)(ph - h) / (numCascade-1);
1290 x = (int)((positionID % numCascade) * cascadeW) + xOffset;
1291 y = (int)((positionID % numCascade) * cascadeH) + yOffset;
1293 else if(anchor.left.type < vTiled)
1295 if(!anchor.left.type || anchor.horz.type == middleRelative)
1297 if(!anchor.right.type)
1299 if(anchor.horz.type == middleRelative)
1300 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1302 x = vpw / 2 + anchor.horz.distance - w / 2;
1308 // case A_EDGE: x = x - w; break;
1310 if(!anchor.top.type || anchor.vert.type == middleRelative)
1312 if(!anchor.bottom.type)
1314 if(anchor.vert.type == middleRelative)
1315 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1317 y = vph / 2 + anchor.vert.distance - h / 2;
1323 // case A_EDGE: y = y - h; break;
1326 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1334 SNAPDOWN(x, textCellW);
1335 SNAPDOWN(y, textCellH);
1347 if(anchored && style.fixed && style.isActiveClient)
1352 void UpdateCaret(bool forceUpdate, bool erase)
1354 static Window lastWindow = null;
1355 static int caretX, caretY, caretSize;
1357 if(guiApp && guiApp.caretOwner == this)
1359 int x = caretPos.x - scroll.x;
1360 int y = caretPos.y - scroll.y;
1362 if((erase || this.caretSize) &&
1363 x >= clientArea.left && x <= clientArea.right &&
1364 y >= clientArea.top && y <= clientArea.bottom)
1368 guiApp.interfaceDriver.SetCaret(
1369 x + absPosition.x + clientStart.x,
1370 y + absPosition.y + clientStart.y, this.caretSize);
1371 guiApp.caretEnabled = true;
1373 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1377 if(lastWindow != this)
1379 updateBox.left = x + 1;
1381 updateBox.right = x + 2;
1382 updateBox.bottom = y + this.caretSize - 1;
1386 updateBox.left = Min(x + 1, caretX + 1);
1387 updateBox.top = Min(y, caretY);
1388 updateBox.right = Max(x + 2, caretX + 2);
1389 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1392 guiApp.caretOwner.Update(updateBox);
1399 caretSize = this.caretSize;
1405 guiApp.interfaceDriver.SetCaret(0,0,0);
1406 guiApp.caretEnabled = false;
1412 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1417 scrolledPos.x = position.x = x;
1418 scrolledPos.y = position.y = y;
1420 clientSize.w = size.w = w;
1421 clientSize.h = size.h = h;
1423 if(parent && !style.nonClient)
1425 //if(!style.fixed || style.isDocument)
1427 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1428 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1432 clientStart.x = clientStart.y = 0;
1434 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1436 //if(!activeClient || activeClient.state != maximized)
1437 if(!noAutoScrollArea)
1439 // Check if scroll area must be modified
1440 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1442 bool foundChild = false;
1444 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1445 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1446 for(child = children.first; child; child = child.next)
1448 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1449 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1451 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1452 w = Max(w, child.position.x + child.size.w);
1453 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1454 w = Max(w, Max(child.position.x, 0) + child.size.w);
1455 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1456 h = Max(h, child.position.y + child.size.h);
1457 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1458 h = Max(h, Max(child.position.y, 0) + child.size.h);
1463 if(foundChild && (w > cw || h > ch))
1465 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1467 int stepX = sbStep.x, stepY = sbStep.y;
1468 // Needed to make snapped down position match the skin's check of client area
1469 // against realvirtual
1472 SNAPDOWN(stepX, textCellW);
1473 SNAPDOWN(stepY, textCellH);
1474 stepX = Max(stepX, textCellW);
1475 stepY = Max(stepY, textCellH);
1477 if(scrollFlags.snapX)
1479 if(scrollFlags.snapY)
1482 reqScrollArea.w = w;
1483 reqScrollArea.h = h;
1486 else if(reqScrollArea.w || reqScrollArea.h)
1488 reqScrollArea.w = 0;
1489 reqScrollArea.h = 0;
1490 SetScrollPosition(0,0);
1495 // Automatic MDI Client Scrolling Area Adjustment
1496 if(parent && !parent.noAutoScrollArea)
1498 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1499 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1501 Window parent = this.parent;
1502 int w = parent.reqScrollArea.w;
1503 int h = parent.reqScrollArea.h;
1505 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1506 w = Max(w, position.x + size.w);
1507 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1508 w = Max(w, Max(position.x, 0) + size.w);
1509 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1510 h = Max(h, position.y + size.h);
1511 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1512 h = Max(h, Max(position.y, 0) + size.h);
1514 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1515 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1517 /*bool resize = false;
1518 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1519 // Needed to make snapped down position match the skin's check of client area
1520 // against realvirtual
1523 SNAPDOWN(stepX, textCellW);
1524 SNAPDOWN(stepY, textCellH);
1525 stepX = Max(stepX, textCellW);
1526 stepY = Max(stepY, textCellH);
1528 if(parent.scrollFlags.snapX)
1530 if(parent.scrollFlags.snapY)
1532 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1534 parent.reqScrollArea.w = w;
1535 parent.reqScrollArea.h = h;*/
1537 // parent.UpdateScrollBars(true, true);
1538 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1539 false, true, true, true, false, false);
1544 GetRidOfVirtualArea();
1548 UpdateScrollBars(modifyThisArea, false);
1549 else if(guiApp.currentSkin)
1552 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1554 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1555 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1556 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1557 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1560 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1561 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1563 absPosition = scrolledPos;
1564 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1565 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1567 if(this != guiApp.desktop && parent)
1569 absPosition.x += parent.absPosition.x;
1570 absPosition.y += parent.absPosition.y;
1571 if(!style.nonClient && this != guiApp.desktop)
1573 absPosition.x += parent.clientStart.x;
1574 absPosition.y += parent.clientStart.y;
1578 box = Box { 0, 0, size.w - 1, size.h - 1 };
1583 // Clip against parent's client area
1584 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1586 // Compute client area in this window coordinate system
1587 clientArea.left = 0;
1589 clientArea.right = clientSize.w - 1;
1590 clientArea.bottom = clientSize.h - 1;
1592 // Clip against parent's client area
1594 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1598 //absPosition.x -= parent.clientStart.x;
1599 //absPosition.y -= parent.clientStart.y;
1602 // Adjust all children
1603 for(child = children.first; child; child = child.next)
1604 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1606 UpdateCaret(false, false);
1609 void GetRidOfVirtualArea(void)
1611 if(parent && !parent.destroyed && style.fixed &&
1612 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1613 parent.reqScrollArea.w && parent.reqScrollArea.h)
1615 if(!parent.noAutoScrollArea)
1617 // TODO: Review the logic of all this? Each child is going to reposition the parent?
1621 for(child = children.first; child; child = child.next)
1623 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1625 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1626 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1636 Window parent = this.parent;
1638 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1639 false, true, true, true, false, false);
1641 parent.SetScrollArea(0,0,true);
1642 parent.SetScrollPosition(0,0);
1648 public void ExternalPosition(int x, int y, int w, int h)
1650 Position(x, y, w, h, false, true, true, true, false, false);
1653 // (w, h): Full window size
1654 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1656 bool result = false;
1657 int oldCW = clientSize.w, oldCH = clientSize.h;
1658 bool clientResized, windowResized, windowMoved;
1660 //bool realResized = size.w != w || size.h != h;
1662 // TOCHECK: This wasn't in ecere.dll
1663 //if(!parent) return true;
1664 if(destroyed) return false;
1666 windowMoved = position.x != x || position.y != y || force;
1668 // windowResized = realResized || force;
1669 windowResized = size.w != w || size.h != h || force;
1671 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1677 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1678 scrolledPos.x - parent.clientStart.x + this.box.right,
1679 scrolledPos.y - parent.clientStart.y + this.box.bottom
1685 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1690 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1692 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1693 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1694 windowResized = true;
1696 if(display && rootWindow != this)
1699 if(guiApp && guiApp.windowMoving)
1701 if(guiApp.windowMoving.style.nonClient)
1702 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1704 guiApp.windowMoving.parent.SetMouseRangeToClient();
1714 // Buttons bitmap resources crash if we do this while switching mode
1715 if(!guiApp || !guiApp.modeSwitching)
1718 // Process Anchored Children
1722 for(child = children.first; child; child = child.next)
1725 ((child.stateAnchor.left.type != offset ||
1726 child.stateAnchor.top.type != offset ||
1727 child.stateAnchor.right.type != none ||
1728 child.stateAnchor.bottom.type != none) ||
1729 child.state == maximized || child.state == minimized))
1731 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1733 // child.Position(x, y, w, h, false, true, true, true, false);
1734 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1735 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1741 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1742 //if(updateScrollBars)
1744 OnResize(clientSize.w, clientSize.h);
1746 if((clientResized || windowMoved) && created)
1747 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1749 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1751 Window master = guiApp.interimWindow.master;
1752 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1755 if(rootWindow == this && !is3D)
1759 x -= guiApp.desktop.absPosition.x;
1760 y -= guiApp.desktop.absPosition.y;
1762 //guiApp.Log("Position %s\n", caption);
1765 if(windowResized || windowMoved)
1766 if(display && !display.flags.memBackBuffer && changeRootWindow)
1767 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1769 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1770 for(child = parent.children.first; child && child != this; child = child.next)
1771 if(child.rootWindow)
1772 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1777 if(windowMoved || windowResized)
1779 display.Lock(true /*false*/);
1782 display.Position(absPosition.x, absPosition.y);
1783 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1786 // result = realResized ? display.Resize(size.w, size.h) : true;
1787 if(nativeDecorations && rootWindow.windowHandle)
1789 int w = clientSize.w, h = clientSize.h;
1790 if(hasMenuBar) h += skinMenuHeight;
1791 if(hasStatusBar) h += statusBarHeight;
1792 if(sbv && sbv.visible) w += sbv.size.w;
1793 if(sbh && sbh.visible) h += sbh.size.h;
1794 result = manageDisplay ? display.Resize(w, h) : true;
1797 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1801 else if(clientResized)
1803 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1806 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1810 if(windowMoved || windowResized)
1815 if(guiApp.driver && changeRootWindow && windowHandle)
1817 if(windowResized || windowMoved)
1818 if(!display || display.flags.memBackBuffer)
1819 guiApp.interfaceDriver.PositionRootWindow(this,
1820 x, y, w, h, windowMoved, windowResized);
1821 guiApp.interfaceDriver.UpdateRootWindow(this);
1823 for(child = children.first; child; child = child.next)
1825 if(child.is3D && child.created)
1827 // Copy Display Content
1828 child.display.displaySystem = display.displaySystem;
1829 child.display.window = display.window;
1830 child.display.current = display.current;
1831 child.display.width = display.width;
1832 child.display.height = display.height;
1833 child.display.driverData = display.driverData;
1834 child.display.mutex = null;
1845 void UpdateScrollBars(bool flag, bool fullThing)
1848 bool resizeH = false, resizeV = false;
1849 bool scrolled = false;
1850 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1851 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1853 if(destroyed) return;
1854 if(guiApp.currentSkin)
1856 MinMaxValue cw = 0, ch = 0;
1857 bool sbvVisible, sbhVisible;
1858 int rangeH = 0, rangeV = 0;
1859 int positionH = 0, positionV;
1861 // First get client area with no respect to scroll bars
1866 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1868 if(scrollFlags.dontHide)
1871 cw -= guiApp.currentSkin.VerticalSBW();
1873 ch -= guiApp.currentSkin.HorizontalSBH();
1875 // Update the scrollbar visibility
1881 sbh.disabled = rangeH <= 1;
1882 if(sbh.style.hidden)
1892 sbv.disabled = rangeV <= 1;
1893 if(sbv.style.hidden)
1901 int oldHRange = sbh ? sbh.range : 0;
1902 int oldVRange = sbv ? sbv.range : 0;
1903 // Then start off with horizontal scrollbar range
1906 positionH = sbh.thumbPosition;
1913 SBSetTotal(sbh, rvw);
1916 ch -= guiApp.currentSkin.HorizontalSBH();
1919 // Do the same for vertical scrollbar
1922 positionV = sbv.thumbPosition;
1928 SBSetTotal(sbv, rvh);
1932 cw -= guiApp.currentSkin.VerticalSBW();
1933 // Maybe we need to set the range on the horizontal scrollbar again
1941 SBSetTotal(sbh, rvw);
1942 //sbh.Action(setRange, positionH, 0);
1943 if(rangeH <= 1 && sbh.range > 1)
1945 ch -= guiApp.currentSkin.HorizontalSBH();
1951 SBSetTotal(sbv, rvh);
1953 //sbv.Action(setRange, positionV, 0);
1958 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1959 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1962 // Update the scrollbar visibility
1963 if(!scrollFlags.dontHide)
1965 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1969 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1976 if(guiApp.currentSkin)
1983 sbhVisible = sbh.style.hidden ? true : false;
1985 sbvVisible = sbv.style.hidden ? true : false;
1987 // Do our resize here
1988 if(flag && (resizeH || resizeV) && fullThing)
1990 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1995 OnResize(clientSize.w, clientSize.h);
2001 sbh.visible = sbhVisible;
2003 sbv.visible = sbvVisible;
2005 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
2006 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
2009 sbh.pageStep = clientSize.w;
2011 sbv.pageStep = clientSize.h;
2013 // Notify doesn't handle setRange anymore... process it here
2016 int positionH = sbh.thumbPosition;
2017 if(scroll.x != positionH)
2019 OnHScroll(setRange, positionH, 0);
2023 SNAPDOWN(positionH, textCellW);
2024 scroll.x = positionH;
2030 int seen = clientSize.w, total = reqScrollArea.w;
2033 if(scrollFlags.snapX)
2034 SNAPDOWN(seen, sbStep.x);
2036 if(!total) total = seen;
2037 range = total - seen + 1;
2039 range = Max(range, 1);
2041 if(x >= range) x = range - 1;
2043 if(scrollFlags.snapX)
2044 SNAPUP(x, sbStep.x);
2048 OnHScroll(setRange, x, 0);
2053 SNAPDOWN(x, textCellW);
2059 int positionV = sbv.thumbPosition;
2060 if(scroll.y != positionV)
2062 OnVScroll(setRange, positionV, 0);
2066 SNAPDOWN(positionV, textCellH);
2067 scroll.y = positionV;
2073 int seen = clientSize.h, total = reqScrollArea.h;
2076 if(scrollFlags.snapY)
2077 SNAPDOWN(seen, sbStep.y);
2079 if(!total) total = seen;
2080 range = total - seen + 1;
2081 range = Max(range, 1);
2083 if(y >= range) y = range - 1;
2085 if(scrollFlags.snapY)
2086 SNAPUP(y, sbStep.y);
2090 OnVScroll(setRange, y, 0);
2095 SNAPDOWN(y, textCellH);
2101 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2104 for(child = children.first; child; child = child.next)
2106 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2109 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2110 child.Position(x, y, w, h, false, true, false, true, false, false);
2117 // Process Scrollbars
2119 if(sbh) // && !sbh.style.hidden
2122 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2123 // Need to set the range again (should improve...) since the scrollbars didn't have
2124 // the right size when UpdateScrollArea set the range on it
2127 sbh.seen = clientSize.w;
2131 if(sbv) // && !sbv.state.hidden
2134 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2135 // Need to set the range again (should improve...) since the scrollbars didn't have
2136 // the right size when UpdateScrollArea set the range on it
2139 sbv.seen = clientSize.h;
2144 // TESTING THIS LOWER
2145 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2148 for(child = children.first; child; child = child.next)
2150 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2153 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2154 child.Position(x, y, w, h, false, true, false, true, false, false);
2160 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2162 SetState(maximized, false, mods);
2166 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2168 SetState(normal, false, mods);
2172 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2174 SetState(minimized, false, mods);
2175 parent.CycleChildren(false, true, false, true);
2179 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2182 // Scroll bar notifications
2183 if(action != setRange)
2185 bool changed = false;
2189 if(scroll.x != position)
2191 OnHScroll(action, position, keyFlags);
2196 SNAPDOWN(position, textCellW);
2198 scroll.x = position;
2202 if(scroll.y != position)
2204 OnVScroll(action, position, keyFlags);
2209 SNAPDOWN(position, textCellH);
2211 scroll.y = position;
2215 bool childMove = false;
2216 for(child = children.first; child; child = child.next)
2218 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2221 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2222 child.Position(x, y, w, h, false, true, false, true, false, false);
2226 // Testing this patch out to solve MDI workspace redraw bugs
2227 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2228 // Scroll offsets to blame?
2232 UpdateCaret(false, false);
2236 // Testing this patch out to solve MDI workspace redraw bugs
2237 for(child = children.first; child; child = child.next)
2239 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2248 Window GetParentMenuBar()
2250 Window menuBarParent;
2251 if(formDesigner) return null;
2252 for(menuBarParent = this ? parent : null; menuBarParent; menuBarParent = menuBarParent.parent)
2254 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2255 if(menuBarParent && !menuBarParent.isActiveClient)
2261 void CreateSystemChildren(void)
2263 Window parent = this;
2264 bool scrollBarChanged = false;
2265 bool hasClose = false, hasMaxMin = false;
2266 Point scroll = this.scroll;
2268 if(state == maximized)
2270 parent = GetParentMenuBar();
2277 if(style.hasClose) hasClose = true;
2278 if(style.hasMaximize || style.hasMinimize)
2285 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2287 sysButtons[2].Destroy(0);
2288 sysButtons[2] = null;
2290 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2292 sysButtons[1].Destroy(0);
2293 sysButtons[1] = null;
2295 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2297 sysButtons[0].Destroy(0);
2298 sysButtons[0] = null;
2301 if(hasClose && parent)
2308 parent, master = this,
2309 inactive = true, nonClient = true, visible = false;
2311 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2317 if(this.parent == guiApp.desktop)
2318 sysButtons[2].hotKey = altF4;
2319 else if(style.isActiveClient)
2320 sysButtons[2].hotKey = ctrlF4;
2321 sysButtons[2].Create();
2324 sysButtons[2].symbol = 'X';
2325 sysButtons[2].disabled = !style.hasClose;
2328 if(hasMaxMin && parent)
2332 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2333 if(state == maximized)
2336 method = RestoreButtonClicked;
2342 method = MaximizeButtonClicked;
2350 parent, master = this,
2351 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2353 sysButtons[1].Create();
2355 sysButtons[1].NotifyClicked = method;
2357 sysButtons[1].symbol = symbol;
2358 sysButtons[1].disabled = !style.hasMaximize;
2361 if(hasMaxMin && parent)
2365 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2366 if (state == minimized)
2369 method = RestoreButtonClicked;
2375 method = MinimizeButtonClicked;
2383 parent, master = this,
2384 hotKey = altM, inactive = true, nonClient = true, visible = false
2386 sysButtons[0].Create();
2388 sysButtons[0].NotifyClicked = method;
2390 sysButtons[0].symbol = symbol;
2391 sysButtons[0].disabled = !style.hasMinimize;
2394 // Create the scrollbars
2395 if(style.hasHorzScroll && !sbh)
2401 direction = horizontal,
2405 snap = scrollFlags.snapX,
2406 NotifyScrolling = ScrollBarNotification
2409 scrollBarChanged = true;
2411 else if(sbh && !style.hasHorzScroll)
2417 if(style.hasVertScroll && !sbv)
2423 direction = vertical,
2427 snap = scrollFlags.snapY,
2428 NotifyScrolling = ScrollBarNotification
2431 scrollBarChanged = true;
2433 else if(sbv && !style.hasVertScroll)
2438 if(scrollBarChanged)
2440 SetScrollLineStep(sbStep.x, sbStep.y);
2441 UpdateScrollBars(true, true);
2445 if(scrollBarChanged)
2447 if(sbh) sbh.thumbPosition = scroll.x;
2448 if(sbv) sbv.thumbPosition = scroll.y;
2452 void UpdateCaption(void)
2454 if(rootWindow == this)
2457 FigureCaption(caption);
2458 if(guiApp.interfaceDriver)
2459 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2461 UpdateDecorations();
2464 if(parent.activeClient == this) // Added this last check
2466 if(parent.rootWindow == parent)
2469 parent.FigureCaption(caption);
2470 if(guiApp.interfaceDriver)
2471 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2474 parent.UpdateCaption();
2476 parent.UpdateDecorations();
2480 void UpdateActiveDocument(Window previous)
2482 Window activeClient = this.activeClient;
2483 Window activeChild = this.activeChild;
2490 activeClient.CreateSystemChildren();
2492 previous.CreateSystemChildren();
2504 // Build window list
2507 Menu windowMenu = menu.FindMenu("Window");
2512 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2514 Window document = cycle.data;
2515 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2517 char name[2048], caption[2048];
2518 document.FigureCaption(caption);
2519 sprintf(name, "%d %s", id+1, caption);
2520 windowMenu.AddDynamic(MenuItem
2522 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2523 NotifySelect = MenuWindowSelectWindow
2527 if(activeClient.cycle == cycle) break;
2532 if((!previous && activeClient) || !activeClient)
2538 item = menu.FindItem(MenuWindowCloseAll, 0);
2539 if(item) item.disabled = false;
2540 item = menu.FindItem(MenuWindowNext, 0);
2541 if(item) item.disabled = false;
2542 item = menu.FindItem(MenuWindowPrevious, 0);
2543 if(item) item.disabled = false;
2544 item = menu.FindItem(MenuWindowCascade, 0);
2545 if(item) item.disabled = false;
2546 item = menu.FindItem(MenuWindowTileHorz, 0);
2547 if(item) item.disabled = false;
2548 item = menu.FindItem(MenuWindowTileVert, 0);
2549 if(item) item.disabled = false;
2550 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2551 if(item) item.disabled = false;
2552 item = menu.FindItem(MenuWindowWindows, 0);
2553 if(item) item.disabled = false;
2556 item = menu.FindItem(MenuFileClose, 0);
2557 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2558 item = menu.FindItem(MenuFileSaveAll, 0);
2559 if(item) item.disabled = numDocuments < 1;
2561 if(activeClient && activeClient.menu && activeClient.state != minimized)
2565 //activeClient.menu.Clean(activeClient);
2566 menu.Merge(activeClient.menu, true, activeClient);
2570 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2573 menu.Merge(activeChild.menu, true, activeChild);
2576 // This is called again for a child window change, with same active client
2577 OnActivateClient(activeClient, previous);
2578 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2579 parent.UpdateActiveDocument(null);
2582 void _ShowDecorations(Box box, bool post)
2584 if(rootWindow == this && nativeDecorations && !is3D) return;
2585 if(visible && this != guiApp.desktop)
2587 Surface surface = RedrawFull(box);
2591 FigureCaption(caption);
2594 ShowDecorations(captionFont.font,
2597 active, //parent.activeClient == this
2598 guiApp.windowMoving == this);
2600 PreShowDecorations(captionFont.font,
2603 active, //parent.activeClient == this
2604 guiApp.windowMoving == this);
2611 void UpdateExtent(Box refresh)
2613 Surface surface = null;
2615 if(!manageDisplay) { OnRedraw(null);return; }
2616 _ShowDecorations(refresh, false);
2618 surface = Redraw(refresh);
2619 // Opaque background: just fill before EW_REDRAW (clear?)
2622 surface.SetBackground(background);
2623 surface.SetForeground(foreground);
2624 surface.DrawingChar(' ');
2625 if(this == rootWindow)
2627 if(style.drawBehind || background.a)
2629 int a = background.a;
2630 // Premultiply alpha for clear color
2631 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2632 surface.Clear(colorBuffer);
2633 surface.SetBackground(background);
2636 else if(background.a)
2640 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2641 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2644 if(display.flags.alpha && background.a < 255 && background)
2646 surface.Area(0,0,clientSize.w, clientSize.h);
2647 /*if(style.clearDepthBuffer)
2648 surface.Clear(depthBuffer);*/
2650 else if(/*style.clearDepthBuffer || */background.a)
2652 int a = background.a;
2653 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2654 // Premultiply alpha for clear color
2655 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2656 surface.Clear(colorBuffer);
2657 surface.SetBackground(background);
2662 surface.TextFont(usedFont.font);
2663 surface.TextOpacity(false);
2667 // Draw the caret ...
2668 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2670 // surface.SetBackground(0xFFFFFF - background.color);
2671 surface.SetBackground(~background.color);
2673 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2674 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2680 void DrawOverChildren(Box refresh)
2682 Surface surface = Redraw(refresh);
2686 surface.DrawingChar(' ');
2687 surface.SetBackground(background);
2688 surface.SetForeground(foreground);
2690 surface.TextFont(usedFont.font);
2691 surface.TextOpacity(false);
2693 OnDrawOverChildren(surface);
2698 _ShowDecorations(refresh, true);
2701 void ComputeClipExtents(void)
2704 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2706 clipExtent.Copy(this.clipExtent);
2708 for(child = children.last; child; child = child.prev)
2710 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2712 bool opaque = child.IsOpaque(); // TODO: acess background directly
2713 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2715 child.clipExtent.Copy(clipExtent);
2716 child.clipExtent.Offset(-dx, -dy);
2717 child.clipExtent.IntersectBox(child.box);
2719 child.ComputeClipExtents();
2721 if(opaque && !child.style.nonClient)
2723 // Adjust the box for the parent:
2724 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2725 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2730 // ??? Only do this for overlapped window or if parent has with clip children flag
2732 // Do this if window has clip children flag on (default false?)
2733 // this.clipExtent = clipExtent;
2735 clipExtent.Free(null);
2738 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2741 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2742 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2744 offsetX -= rootWindow.clientStart.x;
2745 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2749 for(child = children.last; child; child = child.prev)
2751 bool opaque = child.IsOpaque();
2752 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2756 // Adjust renderArea to the root window level
2757 Extent * renderArea = &rootWindow.tempExtents[3];
2759 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2760 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2761 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2763 offsetX -= child.rootWindow.clientStart.x;
2764 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2768 Extent childRenderArea;
2770 if(backBufferUpdate != null)
2772 childRenderArea.Copy(backBufferUpdate);
2773 childRenderArea.Offset(-offsetX, -offsetY);
2776 childRenderArea.Copy(child.dirtyArea);
2778 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2779 renderArea.Copy(dirtyExtent);
2780 renderArea.Offset(-offsetX, -offsetY);
2781 childRenderArea.Union(renderArea);
2784 // Intersect with the clip extent
2785 childRenderArea.Intersection(child.clipExtent);
2788 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2790 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2791 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2793 renderArea->Offset(offsetX, offsetY);
2795 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2796 // overDirtyExtent.Union(renderArea);
2797 renderArea->Empty();
2798 // childRenderArea.Free();
2800 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2805 for(child = children.last; child; child = child.prev)
2807 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2809 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2814 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2816 bool opaque = IsOpaque();
2817 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2819 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2820 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2822 offsetX -= rootWindow.clientStart.x;
2823 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2827 for(child = children.last; child; child = child.prev)
2829 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2831 ColorAlpha background = *(ColorAlpha *)&child.background;
2832 bool opaque = child.IsOpaque();
2833 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2837 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2838 // Adjust renderArea to the root window level
2840 renderArea.Copy(child.dirtyArea);
2841 renderArea.Offset(offsetX, offsetY);
2842 dirtyExtent.Union(renderArea);
2843 overDirtyExtent.Union(renderArea);
2849 for(child = children.last; child; child = child.prev)
2851 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2853 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2857 if(backBufferUpdate != null)
2859 renderArea.Copy(backBufferUpdate);
2860 renderArea.Offset(-offsetX, -offsetY);
2862 overRenderArea.Copy(backBufferUpdate);
2863 overRenderArea.Offset(-offsetX, -offsetY);
2869 renderArea.Copy(dirtyArea);
2871 overRenderArea.Copy(dirtyArea);
2874 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2875 dirtyExtentWindow->Copy(dirtyExtent);
2876 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2877 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2878 dirtyExtentWindow->Empty();
2880 // Intersect with the clip extent
2881 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2884 if(renderArea.count > 10)
2887 printf("\nToo many extents (%d):\n", renderArea.count);
2889 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2890 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2895 for(c = 0; c<10; c++)
2898 FASTLIST_LOOP(renderArea, extentBox)
2900 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2902 renderArea.Copy(extent);
2904 FASTLIST_LOOP(renderArea, extentBox)
2907 printf("(%d, %d) - (%d, %d)\n",
2908 extentBox.box.left, extentBox.box.top,
2909 extentBox.box.right, extentBox.box.bottom);
2913 printf("\nNow %d\n", renderArea.count);
2919 // WHY WAS THIS COMMENTED ??
2921 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2922 dirtyExtentWindow->Copy(overDirtyExtent);
2923 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2924 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2925 dirtyExtentWindow->Empty();
2927 // Intersect with the clip extent
2928 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2934 if(scrollExtent.count)
2936 // Subtract render extent from scrolling extent
2937 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2939 if(backBufferUpdate == null)
2941 Extent * dirty = &rootWindow.tempExtents[3];
2944 // Intersect scrolling extent with clip extent
2945 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2947 // offset this scroll to be at the root window level
2948 scrollExtent.Offset(offsetX, offsetY);
2949 // Add area that was scrolled to the dirty extents of the back buffer
2950 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2954 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2955 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2956 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2961 scrollExtent.Empty();
2963 // Add the exposed extent to the window render area
2964 dirty->Offset(-offsetX, -offsetY);
2965 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2970 // Subtract the window's box from the transparency forced extent
2971 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2977 renderArea.Copy(this.renderArea);
2978 renderArea.Offset(offsetX, offsetY);
2979 dirtyExtent.Union(renderArea);
2985 Extent renderArea { };
2987 renderArea.Copy(overRenderArea);
2988 renderArea.Offset(offsetX, offsetY);
2989 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2994 if(backBufferUpdate != null)
2996 // Remove render area from dirty area
2997 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2999 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
3006 // Remove the window render area from the dirty extents of the back buffer
3007 rootWindow.dirtyBack.Exclusion(renderArea);
3011 void Render(Extent updateExtent)
3015 Window rootWindow = this.rootWindow;
3016 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
3017 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
3019 offsetX -= rootWindow.clientStart.x;
3020 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
3023 if(rootWindow.fullRender)
3032 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
3033 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
3038 /*if(renderArea.count)
3039 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
3042 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3044 Box box = extentBox.box;
3047 /*printf("(%d, %d) - (%d, %d)\n",
3048 extentBox.box.left, extentBox.box.top,
3049 extentBox.box.right, extentBox.box.bottom);*/
3054 box.left += offsetX;
3056 box.right += offsetX;
3057 box.bottom += offsetY;
3059 if(updateExtent != null)
3060 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3064 for(child = children.first; child; child = child.next)
3065 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3066 child.Render(updateExtent);
3068 if(rootWindow.fullRender)
3069 DrawOverChildren(box);
3072 // TO DO: There's an issue about draw over children...
3073 // TO DO: Don't wanna go through this if method isn't used
3074 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3075 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3077 Box box = extentBox.box;
3079 DrawOverChildren(box);
3081 box.left += offsetX;
3083 box.right += offsetX;
3084 box.bottom += offsetY;
3086 if(updateExtent != null)
3087 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3090 for(child = children.first; child; child = child.next)
3091 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3092 child.Render(updateExtent);
3095 overRenderArea.Empty();
3098 public void UpdateDisplay(void)
3100 if(!manageDisplay) { OnRedraw(null);return; }
3101 if(rootWindow && this != rootWindow)
3102 rootWindow.UpdateDisplay();
3105 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3106 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3109 dirtyExtent.Clear();
3112 clipExtent.AddBox(box);
3114 display.StartUpdate();
3116 if(!rootWindow.fullRender)
3118 ComputeClipExtents();
3119 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3120 ComputeRenderArea(dirtyExtent, overExtent, null);
3123 clipExtent.Free(null);
3125 dirtyExtent.Free(null);
3126 overExtent.Free(null);
3128 if(display.flags.flipping)
3131 display.Update(null);
3135 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3136 updateExtent.Clear();
3138 Render(updateExtent);
3140 updateExtent.UnionBox(this.box, tempExtents[0]);
3143 //printf("\n\nUpdate:\n------------------------------------------\n");
3146 //FASTLIST_LOOP(updateExtent, extentBox)
3147 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3150 /*printf("Updating (%d, %d) - (%d, %d)\n",
3151 extentBox.box.left, extentBox.box.top,
3152 extentBox.box.right, extentBox.box.bottom);*/
3155 display.Update(extentBox.box);
3158 updateExtent.Free(null);
3161 display.EndUpdate();
3169 void UpdateBackDisplay(Box box)
3175 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3177 //printf("UpdateBackDisplay going through!\n");
3178 display.StartUpdate();
3182 intersection.Copy(dirtyBack);
3183 intersection.IntersectBox(box);
3185 dirtyExtent.Clear();
3188 clipExtent.AddBox(box);
3190 if(!rootWindow.fullRender)
3192 ComputeClipExtents();
3193 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3196 clipExtent.Free(null);
3198 intersection.Free(null);
3199 dirtyExtent.Free(null);
3200 overExtent.Free(null);
3205 if(display.flags.flipping)
3206 display.Update(null);
3209 rootWindow.display.Update(box);
3212 display.EndUpdate();
3216 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3217 if(dirtyBack.count > MAX_DIRTY_BACK)
3219 BoxItem extentBox, next;
3220 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3221 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3223 next = (BoxItem)extentBox.next;
3224 if(extentBox != first)
3226 if(extentBox.box.left < first.box.left)
3227 first.box.left = extentBox.box.left;
3228 if(extentBox.box.top < first.box.top)
3229 first.box.top = extentBox.box.top;
3230 if(extentBox.box.right > first.box.right)
3231 first.box.right = extentBox.box.right;
3232 if(extentBox.box.bottom > first.box.bottom)
3233 first.box.bottom = extentBox.box.bottom;
3234 dirtyBack.Delete(extentBox);
3243 // --- Window positioning ---
3244 // --- Window identification ---
3246 // Returns window at position "Position"
3247 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3249 Window child, result = null;
3251 box.left += absPosition.x;
3252 box.right += absPosition.x;
3253 box.top += absPosition.y;
3254 box.bottom += absPosition.y;
3256 if(!destroyed && visible && (acceptDisabled || !disabled))
3258 int lx = x - absPosition.x;
3259 int ly = y - absPosition.y;
3260 if(IsInside(lx, ly))
3261 // if(box.IsPointInside(Point{x, y}))
3263 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3264 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3267 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3268 Window ancestor = null;
3270 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3271 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3273 if(child != statusBar && child.rootWindow == rootWindow)
3275 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3282 for(child = (isD ? (last != ancestor ? ancestor : ancestor.previous) : children.last); child; child = child.prev)
3284 if(child != statusBar && child.rootWindow == rootWindow)
3286 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3293 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3301 Window FindModal(void)
3303 Window modalWindow = this, check;
3304 Window check2 = null;
3305 for(check = this; check.master; check = check.master)
3307 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3309 modalWindow = check.master.modalSlave;
3310 check = modalWindow;
3312 // TESTING THIS FOR DROPBOX...
3313 if(!rootWindow || !rootWindow.style.interim)
3315 for(check2 = check; check2 /*.activeChild*/; check2 = check2.activeChild)
3317 if(check2.modalSlave && check2.modalSlave.created)
3319 modalWindow = check2.modalSlave;
3327 if(modalWindow == this)
3329 for(check = this; check.activeChild; check = check.activeChild)
3331 if(check.modalSlave)
3333 modalWindow = check.modalSlave;
3339 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3340 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3343 void StopMoving(void)
3345 if(this == guiApp.windowMoving)
3347 guiApp.windowMoving = null;
3348 UpdateDecorations();
3349 SetMouseRange(null);
3352 if(rootWindow.active)
3353 guiApp.interfaceDriver.StopMoving(rootWindow);
3356 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3357 guiApp.windowIsResizing = false;
3361 void SelectMouseCursor(void)
3366 Window cursorWindow = null;
3367 bool rx, ry, rex, rey;
3369 guiApp.desktop.GetMousePosition(&x, &y);
3370 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3372 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3373 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
3374 else if(mouseWindow)
3376 modalWindow = mouseWindow.FindModal();
3377 x -= mouseWindow.absPosition.x;
3378 y -= mouseWindow.absPosition.y;
3379 if(guiApp.windowIsResizing)
3381 rex = guiApp.resizeEndX;
3382 rey = guiApp.resizeEndY;
3383 rx = guiApp.resizeX;
3384 ry = guiApp.resizeY;
3385 if((rex && rey) || (rx && ry))
3386 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3387 else if((rex && ry) || (rx && rey))
3388 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3389 else if((ry || rey) && (!rx && !rex))
3390 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3391 else if((rx || rex) && (!ry && !rey))
3392 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3394 else if(!modalWindow && !guiApp.windowCaptured &&
3395 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3396 &rx, &ry, &rex, &rey))
3398 if((rex && rey) || (rx && ry))
3399 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
3400 else if((rex && ry) || (rx && rey))
3401 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
3402 else if((ry || rey) && (!rx && !rex))
3403 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
3404 else if((rx || rex) && (!ry && !rey))
3405 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
3407 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3409 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
3410 mouseWindow.rootWindow != mouseWindow)
3411 cursorWindow = mouseWindow.parent;
3413 cursorWindow = mouseWindow;
3415 else if(!guiApp.interimWindow)
3416 cursorWindow = guiApp.windowCaptured;
3419 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
3420 guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3422 else if(modalWindow)
3424 guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
3426 else if(guiApp.interimWindow)
3428 if(guiApp.interimWindow.cursor)
3429 guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
3431 guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3436 // --- State based input ---
3437 bool AcquireInputEx(bool state)
3442 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3443 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3445 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3447 guiApp.acquiredWindow = state ? this : null;
3450 SetMouseRangeToClient();
3451 guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
3456 SelectMouseCursor();
3458 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3462 // --- Window activation ---
3463 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3466 if(!parent || !parent.style.inactive)
3468 Window parent = this.parent;
3471 if(rootWindow == this)
3472 Log(active ? "active\n" : "inactive\n");
3474 if(active && requireRemaximize)
3476 if(state == maximized)
3478 property::state = normal;
3479 property::state = maximized;
3481 requireRemaximize = false;
3484 // Testing this here...
3485 if(!parent || parent == guiApp.desktop || parent.active)
3487 this.active = active;
3490 // TESTING THIS HERE
3491 UpdateDecorations();
3492 if((result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master))
3493 result = NotifyActivate(master, this, active, previous);
3496 this.active = !active;
3501 if(!parent || parent == guiApp.desktop || parent.active)
3503 this.active = active;
3505 AcquireInputEx(active);
3506 if(active && isEnabled)
3510 if(guiApp.caretOwner)
3514 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3515 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3516 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3517 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3519 guiApp.caretOwner.Update(extent);
3522 if(visible || !guiApp.caretOwner)
3523 guiApp.caretOwner = this;
3524 UpdateCaret(false, false);
3530 this.active = false;
3532 AcquireInputEx(active);
3534 if(!active && guiApp.caretOwner == this)
3536 UpdateCaret(false, true);
3537 guiApp.caretOwner = null;
3538 guiApp.interfaceDriver.SetCaret(0,0,0);
3539 guiApp.caretEnabled = false;
3544 if(!active && parent && parent.activeChild && parent.activeChild != this)
3545 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3551 if(!active && menuBar)
3554 menuBar.OnActivate(false, null, &goOn, true);
3555 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3560 Window aChild = activeChild;
3562 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3574 void ConsequentialMouseMove(bool kbMoving)
3578 if(kbMoving || !guiApp.windowMoving)
3582 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3584 if(guiApp.interfaceDriver)
3585 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3587 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3588 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3594 bool IsDescendantOf(Window ancestor)
3597 for(window = this; window && window != ancestor; window = window.parent);
3598 return window == ancestor;
3601 bool IsSlaveOf(Window master)
3604 for(window = this; window && window != master; window = window.master);
3605 return window == master;
3608 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3612 if(this && !destroyed /*&& state != Hidden*/)
3614 Window swap = externalSwap;
3622 if(activateParent &&
3623 (parent.activeChild != this ||
3624 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3625 active && _isModal &&
3626 parent != master && master)
3627 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3633 bool real = parent.activeChild != this;
3635 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3636 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3637 !IsDescendantOf(guiApp.interimWindow) &&
3638 !IsSlaveOf(guiApp.interimWindow))
3640 Window interimWindow = guiApp.interimWindow;
3641 while(interimWindow && interimWindow != this)
3643 Window master = interimWindow.master;
3645 guiApp.interimWindow = null;
3646 if(guiApp.caretOwner)
3647 guiApp.caretOwner.UpdateCaret(false, false);
3649 incref interimWindow;
3650 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3655 delete interimWindow;
3656 interimWindow = (master && master.style.interim) ? master : null;
3661 guiApp.interimWindow = this;
3662 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3663 guiApp.caretEnabled = false;*/
3664 UpdateCaret(false, true);
3669 //bool acquireInput = false;
3671 parent.activeChild &&
3672 parent.activeChild.state == maximized &&
3673 parent != guiApp.desktop;
3675 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3680 swap = parent.activeChild;
3681 if(swap && swap.destroyed) swap = null;
3682 if(swap && swap != this)
3685 if(!swap.PropagateActive(false, this, &goOn, true))
3686 swap = parent.activeChild;
3697 if(!parent || parent.activeChild != this || style.interim)
3700 result = PropagateActive(true, swap, &goOn, true);
3701 if(!result && !goOn)
3706 //acquireInput = true;
3710 if(style.hasMaximize && parent != guiApp.desktop)
3713 SetState(maximized, false, 0);
3714 else if(state != maximized)
3717 for(child = parent.children.first; child; child = child.next)
3719 if(this != child && child.state == maximized)
3720 child.SetState(normal, false, 0);
3727 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3729 Window previous = parent.activeClient;
3730 parent.activeChild = this;
3731 if(!style.nonClient /*&& style.isActiveClient*/)
3735 if(style.isActiveClient)
3736 parent.activeClient = this;
3737 // Moved UpdateActiveDocument inside hidden check
3738 // To prevent activating previous window while creating a new one
3739 // (It was messing up the privateModule in the CodeEditor)
3740 parent.UpdateActiveDocument(previous);
3746 //if(!style.isRemote)
3748 if(rootWindow != this)
3750 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3751 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3753 else if(!guiApp.fullScreenMode)
3755 Window modalRoot = FindModal();
3756 if(!modalRoot) modalRoot = this;
3757 if(!modalRoot.isForegroundWindow)
3759 modalRoot.isForegroundWindow = true;
3760 // To check : Why is parent null?
3761 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3763 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3765 modalRoot.isForegroundWindow = false;
3770 if(result && real && (!style.inactive || moveInactive) && parent)
3772 Window last = parent.children.last;
3774 if(!style.stayOnTop)
3775 for(; last && last.style.stayOnTop; last = last.prev);
3777 parent.children.Move(this, last);
3779 // Definitely don't want that: why not?
3783 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3789 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3796 parent.activeChild = null;
3797 if(!style.nonClient /*&& style.isActiveClient*/)
3799 Window previous = parent.activeClient;
3800 if(style.isActiveClient)
3801 parent.activeClient = null;
3802 parent.UpdateActiveDocument(previous);
3806 if(this == guiApp.interimWindow)
3808 guiApp.interimWindow = null;
3809 if(guiApp.caretOwner)
3810 guiApp.caretOwner.UpdateCaret(false, false);
3812 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3819 if(!active || !swap)
3820 UpdateDecorations();
3822 swap.UpdateDecorations();
3824 if(active && rootWindow != this)
3825 ConsequentialMouseMove(false);
3832 // --- Input Messages ---
3833 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3835 static bool reEntrancy = false;
3836 if(reEntrancy) return;
3840 guiApp.cursorUpdate = true;
3841 if(guiApp.windowScrolling && !consequential)
3843 guiApp.windowScrolling.SetScrollPosition(
3844 (guiApp.windowScrolling.sbh) ?
3845 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3846 (guiApp.windowScrolling.sbv) ?
3847 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3849 if(guiApp.windowMoving)
3851 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3853 Window window = guiApp.windowMoving;
3855 int w = window.size.w;
3856 int h = window.size.h;
3861 rx = mouseX - guiApp.windowMovingStart.x;
3862 ry = mouseY - guiApp.windowMovingStart.y;
3865 window.GetDecorationsSize(&ew, &eh);
3867 if(guiApp.windowIsResizing)
3869 x = window.scrolledPos.x;
3870 y = window.scrolledPos.y;
3874 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3875 rx = guiApp.windowResizingBefore.w - aw;
3876 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3877 w = guiApp.windowResizingBefore.w - rx;
3881 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3882 ry = guiApp.windowResizingBefore.h - ah;
3883 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3884 ry = Max(ry, -guiApp.windowMovingBefore.y);
3885 h = guiApp.windowResizingBefore.h - ry;
3887 if(guiApp.resizeEndX)
3889 w = guiApp.windowResizingBefore.w + rx;
3892 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3900 w = Max(w, window.minSize.w);
3901 h = Max(h, window.minSize.h);
3902 w = Min(w, window.maxSize.w);
3903 h = Min(h, window.maxSize.h);
3905 if(!window.OnResizing(&w, &h))
3907 w = window.clientSize.w;
3908 h = window.clientSize.h;
3911 w = Max(w, window.skinMinSize.w);
3912 h = Max(h, window.skinMinSize.h);
3919 SNAPDOWN(w, textCellW);
3920 SNAPDOWN(h, textCellH);
3925 aw = Max(w,window.skinMinSize.w);
3926 rx = guiApp.windowResizingBefore.w - aw;
3927 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3928 w = guiApp.windowResizingBefore.w - rx;
3932 ah = Max(h,window.skinMinSize.h);
3933 ry = guiApp.windowResizingBefore.h - ah;
3934 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3935 ry = Max(ry, -guiApp.windowMovingBefore.y);
3936 h = guiApp.windowResizingBefore.h - ry;
3941 if(!guiApp.windowIsResizing || guiApp.resizeX)
3942 x = guiApp.windowMovingBefore.x + rx;
3943 if(!guiApp.windowIsResizing || guiApp.resizeY)
3944 y = guiApp.windowMovingBefore.y + ry;
3946 if(!guiApp.windowIsResizing)
3949 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3951 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3952 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3953 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3954 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3958 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3959 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3965 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3967 if(!window.OnMoving(&x, &y, w, h))
3969 x = window.scrolledPos.x;
3970 y = window.scrolledPos.y;
3976 SNAPDOWN(x, textCellW);
3977 SNAPDOWN(y, textCellH);
3980 if(!window.style.nonClient)
3982 if(!window.style.fixed /*|| window.style.isDocument*/)
3984 if(!window.style.dontScrollHorz)
3985 x += window.parent.scroll.x;
3986 if(!window.style.dontScrollVert)
3987 y += window.parent.scroll.y;
3991 // Break the anchors for moveable/resizable windows
3992 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3993 if(window.style.fixed)
3995 if(window.state == normal)
3997 window.normalAnchor = Anchor { left = x, top = y };
3998 window.normalSizeAnchor = SizeAnchor { { w, h } };
3999 window.anchored = false;
4003 window.stateAnchor = Anchor { left = x, top = y };
4004 window.stateSizeAnchor = SizeAnchor { { w, h } };
4006 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
4007 // TOCHECK: Investigate why the following only redraws the scrollbars
4008 //window.Position(x, y, w, h, false, true, true, true, false, true);
4010 guiApp.movingLast.x = mouseX;
4011 guiApp.movingLast.y = mouseY;
4017 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
4020 bool wasMoving = guiApp.windowMoving ? true : false;
4021 bool wasScrolling = guiApp.windowScrolling ? true : false;
4023 while(result && w != this)
4025 Window msgWindow = GetAtPosition(x,y, false, true, w);
4026 Window trueWindow = GetAtPosition(x,y, false, false, w);
4027 bool windowDragged = false;
4032 window = (w && !w.disabled) ? w : null;
4034 if(trueWindow) incref trueWindow;
4036 if(consequential) mods->isSideEffect = true;
4038 UpdateMouseMove(x, y, consequential);
4040 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
4042 if(!guiApp.windowCaptured.isEnabled)
4043 guiApp.windowCaptured.ReleaseCapture();
4045 window = guiApp.windowCaptured;
4048 if(trueWindow && activate &&
4049 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4050 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4051 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4052 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4054 if(mods->alt && !mods->ctrl && !mods->shift)
4056 Window moved = trueWindow;
4057 for(moved = trueWindow; moved; moved = moved.parent)
4058 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4063 windowDragged = true;
4065 // Cancel the ALT menu toggling...
4066 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4071 if(window && activate &&
4072 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4073 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4074 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4075 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4077 Window modalWindow = window.FindModal();
4079 /*if(mods->alt && !mods->shift && !mods->ctrl)
4081 Window moved = window;
4082 for(moved = window; moved; moved = moved.parent)
4083 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4088 windowDragged = true;
4090 // Cancel the ALT menu toggling...
4091 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4097 Window activateWindow = modalWindow ? modalWindow : window;
4098 if(activateWindow && !activateWindow.isRemote)
4100 bool doActivation = true;
4101 //bool needToDoActivation = false;
4102 Window check = activateWindow;
4104 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4106 if(!check.style.inactive)
4108 //needToDoActivation = true;
4110 doActivation = false;
4115 if(!needToDoActivation)
4116 doActivation = false;
4119 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4120 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4122 // Let the OnLeftButtonDown do the activating instead
4123 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4131 incref activateWindow;
4132 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4134 delete activateWindow;
4138 if(activateWindow._refCount == 1)
4140 delete activateWindow;
4144 delete activateWindow;
4145 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4148 mods->isActivate = true;
4152 if(!modalWindow && window && !window.destroyed)
4154 if(!guiApp.windowCaptured || windowDragged)
4156 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4158 bool moving = ((window.state != maximized &&
4159 window.IsMouseMoving(
4160 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4161 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4163 if(!moving && window.IsMouseResizing(
4164 x - window.absPosition.x,
4165 y - window.absPosition.y,
4166 window.size.w, window.size.h,
4167 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4169 guiApp.windowIsResizing = true;
4170 guiApp.windowResizingBefore.w = window.size.w;
4171 guiApp.windowResizingBefore.h = window.size.h;
4173 if(guiApp.windowIsResizing || windowDragged || moving)
4176 guiApp.windowMoving = window;
4177 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4178 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4179 guiApp.windowMovingBefore.x = window.position.x;//s;
4180 guiApp.windowMovingBefore.y = window.position.y;//s;
4181 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4182 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4185 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4187 if(window.style.fixed &&
4189 window.IsMouseMoving(
4190 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4192 window.ShowSysMenu(x, y);
4196 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4198 if(window.sbv || window.sbh)
4201 guiApp.windowScrolling = window;
4202 guiApp.windowScrollingStart.x = x;
4203 guiApp.windowScrollingStart.y = y;
4204 guiApp.windowScrollingBefore.x = window.scroll.x;
4205 guiApp.windowScrollingBefore.y = window.scroll.y;
4208 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4210 if(window.style.hasMaximize &&
4211 window.IsMouseMoving(
4212 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4215 (window.state == maximized) ? normal : maximized, false, *mods);
4223 if(guiApp.windowMoving)
4225 if(guiApp.windowMoving.parent)
4227 if(guiApp.windowMoving.style.nonClient)
4228 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4230 guiApp.windowMoving.parent.SetMouseRangeToClient();
4234 window.UpdateDecorations();
4237 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4239 // Log("\n*** LEFT BUTTON UP ***\n");
4240 if(guiApp.windowMoving)
4241 guiApp.windowMoving.StopMoving();
4243 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4245 if(guiApp.windowScrolling)
4247 Window windowScrolling = guiApp.windowScrolling;
4248 guiApp.windowScrolling = null;
4249 windowScrolling.ReleaseCapture();
4253 if(!result || (window && window.destroyed)) window = null;
4255 if(window && window.FindModal())
4258 if(trueWindow && trueWindow.FindModal())
4266 msgWindow = GetAtPosition(x,y, true, false);
4268 msgWindow.SelectMouseCursor();
4271 if(guiApp.windowCaptured || trueWindow)
4273 Window prevWindow = guiApp.prevWindow;
4274 List<Window> overWindows = guiApp.overWindows;
4275 Iterator<Window> it { overWindows };
4280 if(trueWindow != w && !trueWindow.IsDescendantOf(w))
4283 result = w.OnMouseLeave(*mods);
4285 overWindows.TakeOut(w);
4289 if(result && guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4291 guiApp.prevWindow.mouseInside = false;
4292 guiApp.prevWindow = null;
4296 if(trueWindow.IsDescendantOf(prevWindow))
4298 if(!overWindows.Find(prevWindow))
4299 overWindows.Add(prevWindow);
4301 // Eventually fix this not to include captured?
4302 else if(!prevWindow.OnMouseLeave(*mods))
4306 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4308 Box box = trueWindow.box;
4309 box.left += trueWindow.absPosition.x;
4310 box.right += trueWindow.absPosition.x;
4311 box.top += trueWindow.absPosition.y;
4312 box.bottom += trueWindow.absPosition.y;
4314 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4316 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4317 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4319 overX = Max(Min(overX, 32767),-32768);
4320 overY = Max(Min(overY, 32767),-32768);
4322 trueWindow.mouseInside = true;
4323 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4327 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4329 for(w : guiApp.overWindows; w == trueWindow)
4332 guiApp.overWindows.TakeOut(w);
4335 guiApp.prevWindow = trueWindow;
4338 guiApp.prevWindow = null;
4340 SelectMouseCursor();
4342 if(window && ((!guiApp.windowMoving && !wasMoving) ||
4343 (wasMoving && guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp)) && !wasScrolling)
4345 int clientX = x - (window.absPosition.x + window.clientStart.x);
4346 int clientY = y - (window.absPosition.y + window.clientStart.y);
4348 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4350 clientX = Max(Min(clientX, 32767),-32768);
4351 clientY = Max(Min(clientY, 32767),-32768);
4353 MouseMethod = (void *)window._vTbl[method];
4355 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4358 if(!MouseMethod(window, clientX, clientY, *mods))
4365 if(result && w && w.clickThrough && w.parent)
4370 if(!result || !w || !w.clickThrough)
4377 // --- Mouse cursor management ---
4379 bool KeyMessage(uint method, Key key, unichar character)
4384 if(guiApp.interimWindow)
4385 this = guiApp.interimWindow;
4388 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4392 if(!style.inactive || rootWindow != this)
4394 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4395 Window modalWindow = FindModal();
4396 Window interimMaster = master ? master.rootWindow : null;
4400 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4401 status = OnSysKeyDown(key, character);
4402 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4403 status = OnSysKeyHit(key, character);
4404 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4405 status = OnSysKeyUp(key, character);
4412 // Process Key Message for Internal UI Keyboard actions
4413 if(status && !destroyed && menuBar && state != minimized)
4416 if((SmartKey)key != alt)
4417 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4420 SmartKey sk = (SmartKey) key;
4421 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4423 status = menuBar.KeyMessage(method, key, character);
4428 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4429 menuBar.OnKeyHit(escape, 0);
4431 if(!menuBar.focus && guiApp.caretOwner)
4432 guiApp.caretOwner.UpdateCaret(true, false);
4435 if(!destroyed && status)
4437 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4441 case left: case up: case right: case down:
4442 if(guiApp.windowMoving == this)
4445 int w = guiApp.windowMoving.size.w;
4446 int h = guiApp.windowMoving.size.h;
4447 int x = guiApp.windowMoving.scrolledPos.x;
4448 int y = guiApp.windowMoving.scrolledPos.y;
4452 if(key == down || key == up)
4453 step = Max(step, textCellH);
4455 step = Max(step, textCellW);
4458 if(guiApp.windowIsResizing)
4462 case left: w-=step; break;
4463 case right: w+=step; break;
4464 case up: h-=step; break;
4465 case down: h+=step; break;
4472 case left: x-=step; break;
4473 case right: x+=step; break;
4474 case up: y-=step; break;
4475 case down: y+=step; break;
4479 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4480 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4482 if(!guiApp.windowIsResizing || guiApp.resizeX)
4483 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4485 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4487 if(!guiApp.windowIsResizing || guiApp.resizeY)
4488 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4490 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4492 guiApp.interfaceDriver.SetMousePosition(x, y);
4493 ConsequentialMouseMove(true);
4501 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4503 guiApp.windowMoving.StopMoving();
4504 ConsequentialMouseMove(false);
4512 ShowSysMenu(absPosition.x, absPosition.y);
4520 if(!destroyed && status && state != minimized)
4522 // Process all the way down the children
4523 if(activeChild && !activeChild.disabled)
4525 status = activeChild.KeyMessage(method, key, character);
4527 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4528 key.code != left && key.code != right && key.code != up && key.code != down)
4530 status = activeClient.KeyMessage(method, key, character);
4534 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4536 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4537 // && defaultControl != activeChild)
4539 delete previousActive;
4540 previousActive = activeChild;
4541 if(previousActive) incref previousActive;
4543 ConsequentialMouseMove(false);
4544 if((defaultControl.active ||
4545 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4546 defaultControl.KeyMessage(method, defaultKey, character);
4552 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4554 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4561 ShowSysMenu(absPosition.x, absPosition.y);
4568 if(this != guiApp.desktop)
4570 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4572 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4574 MenuMoveOrSize(key.shift, true);
4578 else if(guiApp.windowMoving)
4580 guiApp.windowMoving.StopMoving();
4581 ConsequentialMouseMove(false);
4589 if(!destroyed && status && state != minimized)
4591 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4595 case tab: case shiftTab:
4597 Window cycleParent = this;
4598 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4599 cycleParent = master.parent;
4601 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4603 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4606 Window child = cycleParent.activeChild;
4608 // Scroll the window to include the active control
4609 if(cycleParent.sbh && !child.style.dontScrollHorz)
4611 if(child.scrolledPos.x < 0)
4612 cycleParent.sbh.Action(Position,
4613 cycleParent.scroll.x + child.scrolledPos.x, 0);
4614 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4615 cycleParent.sbh.Action(Position,
4616 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4618 if(cycleParent.sbv && !child.style.dontScrollVert)
4620 if(child.scrolledPos.y < 0)
4621 cycleParent.sbv.Action(Position,
4622 cycleParent.scroll.y + child.scrolledPos.y, 0);
4623 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4624 cycleParent.sbv.Action(Position,
4625 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4628 cycleParent.ConsequentialMouseMove(false);
4634 case f6: case shiftF6:
4635 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4637 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4638 if(parent == guiApp.desktop)
4639 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4649 if(CycleChildren(key.shift, true, false, true))
4657 // mIRC Style Window Shortcuts
4658 case alt1: case alt2: case alt3: case alt4: case alt5:
4659 case alt6: case alt7: case alt8: case alt9: case alt0:
4664 for(document = children.first; document; document = document.next)
4666 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4668 if(document == activeChild)
4670 if(document.state == minimized)
4671 document.SetState(normal, false, key);
4674 document.SetState(minimized, false, key);
4675 CycleChildren(false, true, false);
4680 if(activeChild.state == maximized && document.style.hasMaximize)
4681 document.SetState(maximized, false, key);
4682 else if(document.state == minimized)
4683 document.SetState(normal, false, key);
4684 document.Activate();
4699 if(!destroyed && status)
4701 if(state == minimized)
4706 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4708 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4710 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4711 previousActive.ActivateEx(true, false, false, true, null, null);
4712 delete previousActive;
4718 if(!destroyed && status)
4720 status = ProcessHotKeys(method, key, character);
4722 if(!destroyed && status && !modalWindow && state != minimized)
4725 status = KeyMethod(this, key, character);
4726 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4727 status = OnKeyHit(key, character);
4728 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4730 bool result = false;
4733 case ctrlUp: case ctrlDown:
4734 if(sbv && !guiApp.windowScrolling)
4735 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4737 case wheelUp: case wheelDown:
4738 if(sbv && !guiApp.windowScrolling)
4740 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4741 // Do we want to do a consequential move regardless of result in this case?
4742 ConsequentialMouseMove(false);
4745 case ctrlPageUp: case ctrlPageDown:
4746 if(sbh && !guiApp.windowScrolling)
4747 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4752 ConsequentialMouseMove(false);
4757 if(status && !destroyed && menuBar && state != minimized)
4758 status = menuBar.KeyMessage(method, key, character);
4760 if(style.interim && /*destroyed && */status && interimMaster)
4762 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4763 status = interimMaster.KeyMessage(method, key, character);
4770 bool ProcessHotKeys(uint method, Key key, unichar character)
4775 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4776 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4777 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4779 Window hotKeyWindow = hotKey.window;
4780 Window parent = hotKeyWindow.parent;
4781 Window prevActiveWindow = activeChild;
4782 // For when sys buttons are placed inside the menu bar
4783 if(parent && parent._class == class(PopupMenu))
4784 parent = parent.parent;
4786 // 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
4787 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4790 if(prevActiveWindow) incref prevActiveWindow;
4791 incref hotKeyWindow;
4792 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
4793 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4796 delete hotKeyWindow;
4797 delete prevActiveWindow;
4801 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4802 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4803 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4805 // ********* WORKING ON THIS ***********
4806 if(prevActiveWindow && !guiApp.interimWindow)
4807 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4810 else if(hotKeyWindow.style.inactive)
4811 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4813 delete prevActiveWindow;
4814 delete hotKeyWindow;
4815 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4816 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4820 if(status && tabCycle)
4823 for(child = children.first; child; child = child.next)
4825 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4836 // --- Windows and graphics initialization / termination ---
4837 bool SetupRoot(void)
4841 // Setup relationship with outside world (bb root || !bb)
4842 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4843 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4847 tempExtents = new0 Extent[4];
4852 /*if(guiApp.fullScreenMode)
4853 rootWindow = guiApp.desktop;
4855 //rootWindow = parent.created ? parent.rootWindow : null;
4856 rootWindow = parent.rootWindow;
4859 against = &parent.box;
4861 against = &parent.clientArea;
4864 for(child = children.first; child; child = child.next)
4867 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4870 bool Setup(bool positionChildren)
4872 bool result = false;
4875 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4877 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4878 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4881 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4883 // This was here, is it really needed?
4884 //guiApp.interfaceDriver.ActivateRootWindow(this);
4888 displaySystem = DisplaySystem {};
4889 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4891 delete displaySystem;
4896 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4897 if(display.Create(displaySystem, windowHandle))
4904 // Sometimes icon does not show up on Windows XP if we set here...
4905 // guiApp.interfaceDriver.SetIcon(this, icon);
4907 else if(this != guiApp.desktop)
4909 display = rootWindow ? rootWindow.display : null;
4915 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4916 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4918 for(child = children.first; child; child = child.next)
4920 if(child.created && !child.Setup(false))
4923 if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
4924 child.UpdateCaption();
4929 bool SetupDisplay(void)
4931 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4932 if(is3D) return Window3D_SetupDisplay(this); else
4939 class_data void ** pureVTbl;
4941 bool LoadGraphics(bool creation, bool resetAnchors)
4943 bool result = false;
4944 bool success = false;
4946 WindowState stateBackup = state;
4948 if(((subclass(Window))_class).pureVTbl)
4950 if(_vTbl == _class._vTbl)
4952 _vTbl = ((subclass(Window))_class).pureVTbl;
4957 for(m = 0; m < _class.vTblSize; m++)
4959 if(_vTbl[m] == _class._vTbl[m])
4960 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4964 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4966 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4968 _vTbl = _class._vTbl;
4973 for(m = 0; m < _class.vTblSize; m++)
4975 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4976 _vTbl[m] = _class._vTbl[m];
4981 if(guiApp.fullScreenMode || this != guiApp.desktop)
4983 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4989 display.Lock(false);
4990 if(rootWindow == this)
4992 // Set Color Palette
4993 display.SetPalette(palette, true);
4997 if(guiApp.fullScreenMode && this == guiApp.desktop)
5002 for(c=0; c<SystemCursor::enumSize; c++)
5003 if(!guiApp.systemCursors[c].bitmap)
5005 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
5006 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
5007 if(guiApp.systemCursors[c].bitmapName)
5009 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
5010 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
5011 if(guiApp.systemCursors[c].bitmap)
5012 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
5017 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5019 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
5020 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
5022 cursor.bitmap.paletteShades = cursor.paletteShades;
5026 guiApp.cursorUpdate = true;
5029 ConsequentialMouseMove(false);
5035 // Load Window Graphic Resources
5038 if(usedFont == setFont || usedFont == window.systemFont)
5039 RemoveResource(usedFont);
5042 RemoveResource(setFont); // TESTING setFont instead of usedFont);
5045 RemoveResource(systemFont);
5048 RemoveResource(captionFont);
5050 for(ptr = resources.first; ptr; ptr = ptr.next)
5052 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
5053 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
5056 AddResource(setFont);
5058 AddResource(systemFont);
5060 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
5067 //if(master && master.font)
5068 if(parent && parent.font)
5072 faceName = parent.font.faceName,
5073 size = parent.font.size,
5074 bold = parent.font.bold,
5075 italic = parent.font.italic,
5076 underline = parent.font.underline
5078 //font = parent.font;
5079 watch(parent) { font { } };
5082 font = guiApp.currentSkin.SystemFont();
5089 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
5090 AddResource(captionFont);
5092 if(OnLoadGraphics())
5098 //SetScrollLineStep(sbStep.x, sbStep.y);
5100 if(this != guiApp.desktop)
5104 normalAnchor = anchor;
5105 normalSizeAnchor = sizeAnchor;
5108 // Break the anchors for moveable/resizable windows
5110 if(style.fixed && style.isDocument)
5112 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5124 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5125 stateSizeAnchor = SizeAnchor {};
5130 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5135 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5136 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5139 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5143 stateAnchor = normalAnchor;
5144 stateSizeAnchor = normalSizeAnchor;
5147 position = Point { };
5148 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5159 if(Position(x, y, w, h, true, false, true, true, true, true))
5161 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5164 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5181 success = result = true;
5184 if(!creation && result)
5186 // Load menu bar first because sys buttons are on it...
5189 if(!menuBar.LoadGraphics(false, resetAnchors))
5195 for(child = children.first; child; child = child.next)
5197 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5204 CreateSystemChildren();
5208 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5211 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5214 LogErrorCode(graphicsLoadingFailed, _class.name);
5216 // Do this here to avoid problems on Windows
5217 if(rootWindow == this && parent && stateBackup == maximized)
5218 property::state = maximized;
5222 void UnloadGraphics(bool destroyWindows)
5226 // Free children's graphics
5227 for(child = children.first; child; child = child.next)
5228 child.UnloadGraphics(destroyWindows);
5231 display.Lock(false);
5234 if(guiApp.fullScreenMode && this == guiApp.desktop)
5239 for(c=0; c<SystemCursor::enumSize; c++)
5240 if(guiApp.systemCursors[c].bitmap)
5241 delete guiApp.systemCursors[c].bitmap;
5243 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5244 delete cursor.bitmap;
5246 guiApp.cursorBackground.Free();
5249 if(display && display.displaySystem)
5253 for(ptr = resources.first; ptr; ptr = ptr.next)
5257 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5262 // Free window graphics
5265 // Free skin graphics
5266 if(rootWindow == this)
5268 DisplaySystem displaySystem = display.displaySystem;
5271 display.driverData = null;
5272 display.displaySystem = null;
5276 if(displaySystem && !displaySystem.numDisplays && !is3D)
5277 delete displaySystem;
5286 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5287 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5289 if(this == guiApp.desktop || parent == guiApp.desktop)
5291 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5292 guiApp.interfaceDriver.DestroyRootWindow(this);
5296 // --- Window Hiding ---
5298 void SetVisibility(bool state)
5300 bool visible = (style.hidden || !created) ? false : state;
5301 if(visible != this.visible)
5305 this.visible = visible;
5306 for(child = children.first; child; child = child.next)
5307 child.SetVisibility(visible);
5309 ConsequentialMouseMove(false);
5310 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5314 // --- Windows and graphics initialization / termination ---
5316 bool DisplayModeChanged(void)
5318 bool result = false;
5319 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5321 guiApp.modeSwitching = true;
5322 UnloadGraphics(false);
5324 if(LoadGraphics(false, false))
5326 guiApp.modeSwitching = false;
5331 // --- Window updates system ---
5333 void UpdateDirty(Box updateBox)
5335 if(!manageDisplay) { OnRedraw(null);return; }
5338 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5341 if(display.flags.flipping)
5344 rootWindow.UpdateDisplay();
5347 UpdateBackDisplay(updateBox);
5349 if(guiApp.fullScreenMode)
5351 guiApp.cursorUpdate = true;
5352 guiApp.PreserveAndDrawCursor();
5354 if(guiApp.fullScreenMode)
5355 guiApp.RestoreCursorBackground();
5361 // This function is strictly called as a result of system window activation
5362 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5365 Window interimMaster = null;
5366 Window interimWindow = guiApp.interimWindow;
5367 if(interimWindow && interimWindow.master)
5368 interimMaster = interimWindow.master.rootWindow;
5370 if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
5371 // SetState(normal, false, 0);
5372 SetState(lastState, false, 0);
5374 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5378 /* WTH is this doing here?
5379 while(swap && swap.activeChild)
5381 swap = swap.activeChild;
5384 // TESTING THIS BEFORE...
5385 if(interimWindow && this == interimMaster)
5389 // Window interimSwap = this;
5390 Window menuBar = this.menuBar;
5391 if(menuBar && interimWindow.master == menuBar)
5394 while(interimSwap && interimSwap.activeChild)
5395 interimSwap = interimSwap.activeChild;
5397 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5398 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5400 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5401 //result = ActivateEx(true, true, false, activateRoot, window, null);
5406 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5407 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5409 if(interimWindow == this && interimMaster && !active)
5411 while(interimMaster && interimMaster.interim && interimMaster.master)
5413 // printf("Going up one master %s\n", interimMaster._class.name);
5414 interimMaster = interimMaster.master.rootWindow;
5416 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5417 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5423 bool DestroyEx(int64 returnCode)
5426 Timer timer, nextTimer;
5428 OldLink prevOrder = null;
5429 Window client = null;
5431 if(parent) stopwatching(parent, font);
5433 // if(window.modalSlave) return false;
5434 if(destroyed || !created)
5441 OldLink slave = master.slaves.FindLink(this);
5442 master.slaves.Delete(slave);
5445 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5451 this.returnCode = (DialogResult)returnCode;
5453 AcquireInput(false);
5458 master.hotKeys.Delete(hotKey);
5462 if(guiApp.prevWindow == this)
5464 guiApp.prevWindow = null;
5469 for(w : guiApp.overWindows; w == this)
5472 guiApp.overWindows.TakeOut(w);
5476 if(guiApp.caretOwner == this)
5478 guiApp.interfaceDriver.SetCaret(0,0,0);
5479 UpdateCaret(false, true);
5480 guiApp.caretEnabled = false;
5485 parent.childrenCycle.Remove(cycle);
5489 OldLink tmpPrev = order.prev;
5490 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5491 prevOrder = tmpPrev;
5494 client = tmpPrev ? tmpPrev.data : null;
5495 if(client == this) { client = null; break; }
5496 if(client && (client.style.hidden || client.destroyed || !client.created))
5497 tmpPrev = client.order.prev;
5501 prevOrder = tmpPrev;
5506 // If this window can be an active client, make sure the next window we activate can also be one
5507 if(!style.nonClient && style.isActiveClient)
5509 tmpPrev = prevOrder;
5512 client = tmpPrev ? tmpPrev.data : null;
5513 if(client == this) { client = null; break; }
5514 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5515 tmpPrev = client.order.prev;
5519 prevOrder = tmpPrev;
5523 if(client && client.style.hidden) client = null;
5525 // parent.childrenOrder.Remove(order);
5528 if(parent && style.isActiveClient && visible)
5530 if(state == minimized) parent.numIcons--;
5531 parent.numPositions--;
5534 // TESTING THIS HERE!
5538 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5539 // to create a window inside a rootwindow that's being destroyed)
5540 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5542 if(master && !master.destroyed /*&&
5543 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5545 if(master.defaultControl == this)
5546 master.defaultControl = null;
5549 parent.OnChildAddedOrRemoved(this, true);
5550 if(parent && !parent.destroyed /*&&
5551 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5553 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5555 if(order && prevOrder && prevOrder.data != this && active)
5557 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5559 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5560 if(parent.activeClient == this)
5562 parent.activeClient = null;
5563 parent.UpdateActiveDocument(null);
5568 if(guiApp.interimWindow == this)
5571 PropagateActive(false, null, &goOn, true);
5575 //if(window.parent.activeChild == window)
5576 parent.activeChild = null;
5577 if(!style.nonClient /*&& style.isActiveClient*/)
5579 Window previous = parent.activeClient;
5580 if(style.isActiveClient)
5581 parent.activeClient = null;
5582 parent.UpdateActiveDocument(previous);
5587 else if(parent.activeClient == this)
5589 parent.activeClient = client;
5590 parent.UpdateActiveDocument(this);
5594 if(guiApp.interimWindow == this)
5596 guiApp.interimWindow = null;
5597 if(guiApp.caretOwner)
5599 Window desktop = guiApp.desktop;
5600 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5601 guiApp.caretOwner.UpdateCaret(false, false);
5606 if(_isModal && master && master.modalSlave == this)
5607 master.modalSlave = null;
5611 if(!guiApp.caretOwner && parent.caretSize)
5613 guiApp.caretOwner = parent;
5614 parent.UpdateCaret(false, false);
5615 parent.Update(null);
5618 // Why was this commented out?
5619 GetRidOfVirtualArea();
5625 dirtyArea.Free(null);
5626 dirtyBack.Free(null);
5627 scrollExtent.Free(null);
5629 /* ATTEMPTING TO MOVE THAT ABOVE
5638 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5639 for(;(child = window.children.first);)
5641 for(; child && (child.destroyed || !child.created); child = child.next);
5650 UnloadGraphics(true);
5653 delete previousActive;
5656 // statusBar = null;
5659 if(master && !master.destroyed)
5661 //master.NotifyDestroyed(this, this.returnCode);
5662 NotifyDestroyed(master, this, this.returnCode);
5665 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5667 nextTimer = timer.next;
5668 if(timer.window == this)
5670 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5671 // timer.window = null;
5677 if(this == guiApp.windowMoving)
5680 if(guiApp.windowCaptured == this)
5682 //guiApp.windowCaptured = null;
5684 if(rootWindow != this && rootWindow)
5685 rootWindow.ConsequentialMouseMove(false);
5693 //for(child = children.first; next = child ? child.next : null, child; child = next)
5694 for(;(child = children.first); )
5696 for(; child && (child.destroyed || !child.created); child = child.next);
5706 /* // MOVED THIS UP...
5709 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5710 for(;(child = window.children.first); )
5712 for(; child && (child.destroyed || !child.created); child = child.next);
5721 while((slave = slaves.first))
5723 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5725 ((Window)slave.data).DestroyEx(0);
5730 if(guiApp.caretOwner == this)
5731 guiApp.caretOwner = null;
5733 sysButtons[0] = null;
5734 sysButtons[1] = null;
5735 sysButtons[2] = null;
5738 if(rootWindow != this)
5740 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5743 box.left -= parent.clientStart.x;
5744 box.top -= parent.clientStart.y;
5745 box.right -= parent.clientStart.x;
5746 box.bottom -= parent.clientStart.y;
5748 if(parent) parent.Update(box);
5753 OldLink slave = master.slaves.FindVoid(this);
5754 master.slaves.Delete(slave);
5760 parent.children.Remove(this);
5765 //autoCreate = false;
5768 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5769 if(((subclass(Window))_class).pureVTbl)
5771 if(_vTbl == _class._vTbl)
5773 _vTbl = ((subclass(Window))_class).pureVTbl;
5778 for(m = 0; m < _class.vTblSize; m++)
5780 if(_vTbl[m] == _class._vTbl[m])
5781 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5790 void SetStateEx(WindowState newState, bool activate)
5793 WindowState prevState = state;
5797 if(prevState != newState)
5798 lastState = prevState;
5800 if(rootWindow != this || !nativeDecorations || !windowHandle)
5802 if(style.isActiveClient && !style.hidden && prevState == minimized)
5805 // This block used to be at the end of the function... moved it for flicker problem in X
5806 // ------------------------------------------------------
5810 stateAnchor = normalAnchor;
5811 stateSizeAnchor = normalSizeAnchor;
5814 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5815 stateSizeAnchor = SizeAnchor {};
5819 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5822 byte * idBuffer = new0 byte[size];
5824 for(child = parent.children.first; child; child = child.next)
5826 if(child != this && child.state == minimized)
5828 if(child.iconID > size - 2)
5830 idBuffer = renew0 idBuffer byte[size*2];
5831 memset(idBuffer + size, 0, size);
5834 idBuffer[child.iconID] = (byte)bool::true;
5837 for(c = 0; c<size; c++)
5842 if(style.isActiveClient && !style.hidden)
5845 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5846 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5850 // TOCHECK: Why was this here?
5851 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5852 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5853 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5855 Position(x, y, w, h, true, true, true, true, false, true);
5857 if(!style.inactive && !style.interim && parent && this == parent.activeClient)
5858 parent.UpdateActiveDocument(null);
5861 CreateSystemChildren();
5862 // ------------------------------------------------------
5865 int GetPositionID(Window forChild)
5869 byte * idBuffer = new0 byte[size];
5872 for(child = children.first; child; child = child.next)
5874 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5876 if(child.positionID > size - 2)
5878 idBuffer = renew0 idBuffer byte[size*2];
5879 memset(idBuffer + size, 0, size);
5882 idBuffer[child.positionID] = (byte)bool::true;
5885 for(c = 0; c<size; c++)
5892 // --- Window related graphics ---
5894 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5896 palette = newPalette;
5897 if(rootWindow.display)
5898 rootWindow.display.SetPalette(palette, colorMatch);
5901 public bool AcquireInput(bool acquired)
5904 if(acquiredInput != acquired)
5906 if(active || (!visible && creationActivation == activate))
5907 result = AcquireInputEx(acquired);
5912 acquiredInput = acquired ? result : !result;
5917 void ListChildren(ListBox listBox)
5921 for(child = children.first; child; child = child.next)
5923 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5925 DataRow row = listBox.AddRow();
5926 row.tag = (int64)(intptr)child;
5927 child.FigureCaption(caption);
5928 row.SetData(null, caption);
5933 void UpdateVisual(Box extent)
5935 if(guiApp.driver != null)
5937 if(guiApp.fullScreenMode && guiApp.desktop.display)
5939 guiApp.desktop.mutex.Wait();
5940 guiApp.desktop.display.Lock(true);
5943 if(guiApp.desktop.active)
5945 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5947 if(guiApp.desktop.display.flags.flipping)
5948 guiApp.desktop.Update(null);
5949 guiApp.desktop.UpdateDisplay();
5950 guiApp.cursorUpdate = true;
5952 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5954 guiApp.PreserveAndDrawCursor();
5955 // guiApp.desktop.display.ShowScreen();
5956 guiApp.cursorUpdate = false;
5957 guiApp.desktop.dirty = false;
5958 guiApp.RestoreCursorBackground();
5962 guiApp.desktop.display.Unlock();
5963 guiApp.desktop.mutex.Release();
5967 Window rootWindow = this.rootWindow;
5968 rootWindow.mutex.Wait();
5973 guiApp.SignalEvent();
5976 guiApp.waitMutex.Wait();
5977 guiApp.interfaceDriver.Lock(rootWindow);
5978 if(!rootWindow.style.hidden && rootWindow.dirty)
5980 if(rootWindow.display)
5982 rootWindow.UpdateDisplay();
5983 //rootWindow.display.ShowScreen(null);
5985 rootWindow.dirty = false;
5987 guiApp.interfaceDriver.Unlock(rootWindow);
5988 guiApp.waitMutex.Release();
5991 rootWindow.mutex.Release();
5996 void UnlockDisplay(void)
5998 guiApp.interfaceDriver.Unlock(rootWindow);
6001 void LockDisplay(void)
6003 guiApp.interfaceDriver.Lock(rootWindow);
6006 Surface GetSurface(Box box)
6008 return Redraw((box == null) ? this.box : box);
6011 void SetMousePosition(int x, int y)
6013 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
6017 void IntegrationActivate(bool active)
6019 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
6021 isForegroundWindow = true;
6022 ActivateEx(active, active, false, false, null, null);
6023 isForegroundWindow = false;
6028 Window QueryCapture(void)
6030 return guiApp.windowCaptured;
6033 int GetDocumentID(void)
6037 byte * idBuffer = new0 byte[size];
6040 for(child = children.first; child; child = child.next)
6042 // TO CHECK: Do we want a documentID when we already have a file name?
6043 if(child.style.isDocument && !child.fileName)
6045 if(child.documentID-1 > size - 2)
6047 idBuffer = renew0 idBuffer byte[size*2];
6048 memset(idBuffer + size, 0, size);
6051 idBuffer[child.documentID-1] = 1;
6054 for(c = 0; c<size; c++)
6062 void SetInitSize(Size size)
6065 sizeAnchor.size = size;
6066 normalSizeAnchor = sizeAnchor;
6068 // Break the anchors for moveable/resizable windows
6069 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6071 stateAnchor = normalAnchor;
6072 stateSizeAnchor = normalSizeAnchor;
6074 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6075 Position(x,y, w, h, true, true, true, true, false, true);
6079 void MenuMoveOrSize(bool resize, bool setCursorPosition)
6081 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
6083 guiApp.windowIsResizing = resize;
6084 guiApp.windowMoving = this;
6085 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
6086 if(guiApp.windowIsResizing)
6088 guiApp.windowMovingStart.x += size.w - 1;
6089 guiApp.windowMovingStart.y += size.h - 1;
6091 guiApp.windowMovingBefore = scrolledPos;
6092 guiApp.windowResizingBefore = size;
6093 guiApp.windowMoving.UpdateDecorations();
6094 if(guiApp.windowIsResizing)
6095 guiApp.resizeEndX = guiApp.resizeEndY = true;
6097 if(setCursorPosition)
6098 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6102 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6103 guiApp.windowMovingStart.x += x - absPosition.x;
6104 guiApp.windowMovingStart.y += y - absPosition.y;
6107 if(guiApp.windowMoving)
6109 if(guiApp.windowMoving.style.nonClient)
6110 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6112 guiApp.windowMoving.parent.SetMouseRangeToClient();
6117 if(this == rootWindow)
6118 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6122 void SetupFileMonitor()
6126 fileMonitor = FileMonitor
6128 this, FileChange { modified = true };
6130 bool OnFileNotify(FileChange action, const char * param)
6133 fileMonitor.StopMonitoring();
6134 if(OnFileModified(action, param))
6135 fileMonitor.StartMonitoring();
6148 bool result = false;
6152 else if(guiApp && guiApp.driver != null)
6154 OldLink slaveHolder;
6156 bool visible = !style.hidden;
6160 systemParent = parent;
6161 parent = guiApp.desktop;
6163 last = parent ? parent.children.last : null;
6165 if((parent && parent != guiApp.desktop && !parent.created) ||
6166 (master && master != guiApp.desktop && !master.created))
6170 stopwatching(parent, font);
6173 property::parent = guiApp.desktop;
6174 if(!master) master = parent;
6176 if(_isModal && master.modalSlave)
6177 property::master = master.modalSlave;
6181 parent.children.Remove(this);
6184 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6185 if(slaveHolder.data == this)
6187 master.slaves.Delete(slaveHolder);
6192 if(parent == guiApp.desktop && !mutex)
6195 if(style.isDocument)
6198 parent.numDocuments--;
6199 documentID = parent.GetDocumentID();
6202 if(!style.stayOnTop)
6203 for(; last && last.style.stayOnTop; last = last.prev);
6205 parent.children.Insert((last == this) ? null : last, this);
6206 //parent.children.Add(this);
6209 dispDriver = parent.dispDriver;
6212 master.modalSlave = this;
6214 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6219 master.slaves.Add(slaveHolder = OldLink { data = this });
6224 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6226 if(style.isDefault && !master.defaultControl)
6227 master.defaultControl = this;
6229 stateAnchor = normalAnchor = anchor;
6230 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6232 // TOCHECK: Why is this here?
6233 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6234 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6236 this.visible = false;
6237 style.hidden = true;
6240 // autoCreate = true;
6248 if(parent == guiApp.desktop)
6249 Log("LoadGraphics %s\n", caption);
6251 if(LoadGraphics(true, false))
6259 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6266 if(style.hasMenuBar /*&& menu*/)
6272 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6273 interim = false, inactive = true, nonClient = true, size.h = 24
6281 // Create the system buttons
6282 CreateSystemChildren();
6284 UpdateActiveDocument(null);
6286 if(style.isDocument)
6290 MenuItem item = menu.FindItem(MenuFileSave, 0);
6291 if(item) item.disabled = !modifiedDocument && fileName;
6296 if(parent == guiApp.desktop)
6297 Log("Preemptive SetState %s\n", caption);
6300 // Preemptive Set State to ensure proper anchoring
6301 SetStateEx(state, false);
6303 style.hidden = true;
6309 for(child = children.first; child; child = next)
6312 if(!child.created && (child.autoCreate || child.wasCreated))
6319 for(link = slaves.first; link; link = next)
6321 Window slave = link.data;
6323 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6326 // Things might have happened that invalidated 'next'...
6327 // Start over the search for slaves to create.
6328 // (Added this to fix crash with Stacker & Toolbar)
6329 next = slaves.first;
6338 if(parent == guiApp.desktop)
6339 Log("Real SetState %s\n", caption);
6342 if(isActiveClient && visible)
6344 parent.numPositions--;
6345 if(state == minimized) parent.numIcons--;
6348 parent.OnChildAddedOrRemoved(this, false);
6350 if(rootWindow == this && visible) // So that X11 windows don't show as 'unknown'
6352 // Real set state & activate for proper display & activation
6353 property::visible = visible;
6354 // SetState(state & 0x00000003, true, 0);
6355 guiApp.interfaceDriver.SetIcon(this, icon);
6360 /*if(rootWindow == this)
6361 guiApp.interfaceDriver.ActivateRootWindow(this);
6363 if(creationActivation == activate && guiApp.desktop.active)
6364 ActivateEx(true, false, true, true, null, null);
6365 else if(creationActivation == activate || creationActivation == flash)
6368 if(this == rootWindow)
6374 rootWindow.ConsequentialMouseMove(false);
6385 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6391 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6393 //style.hidden = true; // !visible;
6394 style.hidden = !visible;
6395 if(master.modalSlave == this)
6396 master.modalSlave = null;
6403 void WriteCaption(Surface surface, int x, int y)
6406 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6409 void Update(Box region)
6415 rootWindow = this.rootWindow;
6417 // rootWindow.mutex.Wait();
6418 if(!destroyed && visible && display)
6423 // Testing this to avoid repetitve full update to take time...
6424 if(dirtyArea.count == 1)
6426 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6427 if(item.box.left <= box.left &&
6428 item.box.top <= box.top &&
6429 item.box.right >= box.right &&
6430 item.box.bottom >= box.bottom)
6432 rootWindow.dirty = true;
6437 if(display.flags.flipping && !rootWindow.dirty)
6439 if(this == rootWindow)
6443 rootWindow.Update(null);
6448 rootWindow.dirty = true;
6453 realBox.left += clientStart.x;
6454 realBox.top += clientStart.y;
6455 realBox.right += clientStart.x;
6456 realBox.bottom += clientStart.y;
6462 if(realBox.right >= realBox.left &&
6463 realBox.bottom >= realBox.top)
6465 // if(!rootWindow.fullRender)
6466 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6468 for(child = children.first; child; child = child.next)
6473 box.left -= child.absPosition.x - absPosition.x;
6474 box.top -= child.absPosition.y - absPosition.y;
6475 box.right -= child.absPosition.x - absPosition.x;
6476 box.bottom -= child.absPosition.y - absPosition.y;
6477 if(box.right >= child.box.left && box.left <= child.box.right &&
6478 box.bottom >= child.box.top && box.top <= child.box.bottom)
6480 box.left -= child.clientStart.x;
6481 box.top -= child.clientStart.y;
6482 box.right -= child.clientStart.x;
6483 box.bottom -= child.clientStart.y;
6489 realBox.left += absPosition.x - rootWindow.absPosition.x;
6490 realBox.top += absPosition.y - rootWindow.absPosition.y;
6491 realBox.right += absPosition.x - rootWindow.absPosition.x;
6492 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6493 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6496 else if(this == guiApp.desktop)
6499 for(window = children.first; window; window = window.next)
6505 Box childBox = region;
6507 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6508 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6509 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6510 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6512 window.Update(childBox);
6515 window.Update(null);
6520 // rootWindow.mutex.Release();
6527 if(guiApp.windowCaptured != this)
6529 if(guiApp.windowCaptured)
6533 //Logf("Captured %s (%s)\n", caption, class.name);
6534 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6535 guiApp.windowCaptured = this;
6541 bool Destroy(int64 code)
6546 if(!destroyed && !CloseConfirmation(false)) return false;
6550 // TOCHECK: Should autoCreate be set to false here?
6561 void Move(int x, int y, int w, int h)
6563 normalAnchor = Anchor { left = x, top = y };
6564 normalSizeAnchor = SizeAnchor { size = { w, h } };
6566 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6568 if(destroyed) return;
6570 stateAnchor = normalAnchor;
6571 stateSizeAnchor = normalSizeAnchor;
6573 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6574 Position(x,y, w, h, true, true, true, true, false, true);
6578 DialogResult Modal(void)
6584 // FIXES MEMORY LEAK IF Create() FAILED
6590 void SetScrollArea(int width, int height, bool snapToStep)
6594 int stepX = sbStep.x, stepY = sbStep.y;
6595 // Needed to make snapped down position match the skin's check of client area
6596 // against realvirtual
6599 SNAPDOWN(stepX, textCellW);
6600 SNAPDOWN(stepY, textCellH);
6601 stepX = Max(stepX, textCellW);
6602 stepY = Max(stepY, textCellH);
6604 if(scrollFlags.snapX)
6605 SNAPUP(width, stepX);
6606 if(scrollFlags.snapY)
6607 SNAPUP(height, stepY);
6610 reqScrollArea.w = width;
6611 reqScrollArea.h = height;
6612 noAutoScrollArea = (width > 0 || height > 0);
6614 UpdateScrollBars(true, true);
6617 void SetScrollPosition(int x, int y)
6620 sbh.Action(setPosition, x, 0);
6624 int seen = clientSize.w, total = reqScrollArea.w;
6626 if(scrollFlags.snapX)
6627 SNAPDOWN(seen, sbStep.x);
6629 if(!total) total = seen;
6630 range = total - seen + 1;
6631 range = Max(range, 1);
6633 if(x >= range) x = range - 1;
6635 if(scrollFlags.snapX)
6636 SNAPUP(x, sbStep.x);
6639 OnHScroll(setPosition, x, 0);
6643 SNAPDOWN(x, textCellW);
6649 sbv.Action(setPosition, y, 0);
6653 int seen = clientSize.h, total = reqScrollArea.h;
6656 if(scrollFlags.snapY)
6657 SNAPDOWN(seen, sbStep.y);
6659 if(!total) total = seen;
6660 range = total - seen + 1;
6661 range = Max(range, 1);
6663 if(y >= range) y = range - 1;
6665 if(scrollFlags.snapY)
6666 SNAPUP(y, sbStep.y);
6669 OnVScroll(setPosition, y, 0);
6672 SNAPDOWN(y, textCellH);
6677 UpdateCaret(false, false);
6680 void SetScrollLineStep(int stepX, int stepY)
6686 SNAPDOWN(stepX, textCellW);
6687 SNAPDOWN(stepY, textCellH);
6688 stepX = Max(stepX, textCellW);
6689 stepY = Max(stepY, textCellH);
6692 sbh.lineStep = stepX;
6694 sbv.lineStep = stepY;
6697 void SetState(WindowState newState, bool activate, Modifiers mods)
6701 if(state == newState || OnStateChange(newState, mods))
6703 //WindowState prevState = state;
6707 // This used to be at the end of the brackets... moved for X, testing...
6708 // This has the effect of activating the window through the system...
6709 if(rootWindow == this)
6710 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6712 SetStateEx(newState, activate);
6714 if(rootWindow == this && !rootWindow.nativeDecorations)
6716 int x = position.x, y = position.y;
6719 x -= guiApp.desktop.absPosition.x;
6720 y -= guiApp.desktop.absPosition.y;
6722 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6726 //state = prevState;
6728 if(state != maximized && style.hasMaximize)
6731 for(child = parent.children.first; child; child = child.next)
6733 if(child != this && child.state == maximized)
6734 child.SetStateEx(normal, false);
6738 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6739 parent.UpdateScrollBars(true, true);
6742 // Do we really need this stuff here?
6743 // Shouldn't the Activate stuff take care of it?
6744 if(parent.rootWindow == parent && style)
6747 parent.FigureCaption(caption);
6748 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6749 parent.UpdateDecorations();
6753 rootWindow.ConsequentialMouseMove(false);
6760 BitmapResource GetIcon(SkinBitmap iconID)
6762 return guiApp.currentSkin.GetBitmap(iconID);
6765 void SetMouseRange(Box range)
6767 if(range || guiApp.fullScreenMode)
6772 clip.left = range.left + absPosition.x + clientStart.x;
6773 clip.top = range.top + absPosition.y + clientStart.y;
6774 clip.right = range.right + absPosition.x + clientStart.x;
6775 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6779 clip.left = guiApp.desktop.box.left;
6780 clip.top = guiApp.desktop.box.top;
6781 clip.right = guiApp.desktop.box.right;
6782 clip.bottom = guiApp.desktop.box.bottom;
6784 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6787 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6790 void SetMouseRangeToClient(void)
6792 if(guiApp.fullScreenMode || this != guiApp.desktop)
6794 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6795 box.Clip(clientArea);
6799 SetMouseRange(null);
6802 void SetMouseRangeToWindow(void)
6804 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6805 if(this == guiApp.desktop)
6806 SetMouseRangeToClient();
6811 // x, y: Desktop Coordinates
6812 void ShowSysMenu(int x, int y)
6815 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6818 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6819 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6823 menu, $"Move", m, NotifySelect = MenuWindowMove,
6824 disabled = !style.fixed || state == maximized
6828 menu, $"Size", s, NotifySelect = MenuWindowSize,
6829 disabled = !style.sizable || state != normal
6833 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6834 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6838 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6839 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6843 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6844 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6846 MenuDivider { menu };
6849 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6850 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6852 windowMenu.Create();
6857 ActivateEx(true, true, true, true, null, null);
6860 void MakeActive(void)
6862 ActivateEx(true, false, true, false, null, null);
6865 void SoftActivate(void)
6867 if(guiApp.desktop.active)
6872 if(this == rootWindow)
6877 void Deactivate(void)
6879 ActivateEx(false, true, true, true, null, null);
6884 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6887 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6889 bool result = false;
6890 if(activeChild && activeChild.cycle)
6892 Window modalWindow, child = activeChild;
6893 if(!clientOnly /*&& parent.tabCycle*/)
6895 Window next = child;
6898 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6902 if(parent && parent.CycleChildren(backward, false, true, true))
6910 next = next.cycle.prev.data;
6912 next = next.cycle.next.data;
6913 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6918 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6919 parent.tabCycle && parent.CycleChildren(backward, false, false))
6923 if(tabCycleOnly && !tabCycle) return false;
6930 child = child.cycle.prev.data;
6932 child = child.cycle.next.data;
6933 if(child == child.parent.activeChild)
6935 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6938 modalWindow = child.FindModal();
6941 // Scroll the window to include the active control
6942 if(sbh && !child.style.dontScrollHorz)
6944 if(child.scrolledPos.x < 0)
6945 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6946 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6947 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6949 if(sbv && !child.style.dontScrollVert)
6951 if(child.scrolledPos.y < 0)
6952 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6953 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6954 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6958 child = modalWindow ? modalWindow : child;
6959 child.ActivateEx(true, true, true, true, null, null);
6960 if(child.tabCycle && child.childrenCycle.first)
6961 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6969 ConsequentialMouseMove(false);
6973 void AddResource(Resource resource)
6977 ResPtr ptr { resource = resource };
6981 // Load Graphics here if window is created already
6982 if(/*created && */display)
6984 display.Lock(false);
6985 if(!ptr.loaded) // This check prevents a leak in case a watcher on 'font' calls AddResource (ListBox FontResource leak)
6986 ptr.loaded = display.displaySystem.LoadResource(resource);
6990 // Temporary hack to load font right away for listbox in dropbox ...
6991 else if(master && master.display)
6993 master.display.Lock(false);
6994 master.display.displaySystem.LoadResource(resource);
6995 master.display.Unlock();
7001 void RemoveResource(Resource resource)
7006 for(ptr = resources.first; ptr; ptr = ptr.next)
7008 if(ptr.resource == resource)
7014 // Unload Graphics here if window is created already
7015 if(/*created && */display)
7019 display.Lock(false);
7020 display.displaySystem.UnloadResource(resource, ptr.loaded);
7026 resources.Delete(ptr);
7031 void SetCaret(int x, int y, int size)
7038 if(active && !style.interim && isEnabled)
7040 if(visible || !guiApp.caretOwner)
7041 guiApp.caretOwner = size ? this : null;
7043 UpdateCaret(false, false);
7046 guiApp.interfaceDriver.SetCaret(0,0,0);
7047 UpdateCaret(false, true);
7048 guiApp.caretEnabled = false;
7051 else if(style.inactive && active)
7053 guiApp.interfaceDriver.SetCaret(0,0,0);
7054 UpdateCaret(false, true);
7055 guiApp.caretEnabled = false;
7060 void Scroll(int x, int y)
7062 bool opaque = !style.drawBehind || background.a;
7063 if(opaque && display && display.flags.scrolling)
7065 Box box = clientArea;
7066 box.left += clientStart.x;
7067 box.top += clientStart.y;
7068 box.right += clientStart.x;
7069 box.bottom += clientStart.y;
7071 //scrollExtent.Free(null);
7072 scrollExtent.AddBox(box);
7073 scrolledArea.x += x;
7074 scrolledArea.y += y;
7076 //scrollExtent.Free();
7077 //scrollExtent.AddBox(clientArea);
7078 //scrollExtent.Offset(clientStart.x, clientStart.y);
7079 //scrolledArea.x = x;
7080 //scrolledArea.y = y;
7086 rootWindow.dirty = true;
7089 void ReleaseCapture()
7091 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
7093 Window oldCaptured = guiApp.windowCaptured;
7094 guiApp.windowCaptured = null;
7095 guiApp.prevWindow = null;
7098 //guiApp.Log("Released Capture\n");
7100 guiApp.interfaceDriver.SetMouseCapture(null);
7102 //oldCaptured.OnMouseCaptureLost();
7105 oldCaptured.ConsequentialMouseMove(false);
7110 private void _SetCaption(const char * format, va_list args)
7117 char caption[MAX_F_STRING];
7118 vsnprintf(caption, sizeof(caption), format, args);
7119 caption[sizeof(caption)-1] = 0;
7121 this.caption = CopyString(caption);
7126 firewatchers caption;
7130 /*deprecated*/ void SetText(const char * format, ...)
7133 va_start(args, format);
7134 _SetCaption(format, args);
7138 void SetCaption(const char * format, ...)
7141 va_start(args, format);
7142 _SetCaption(format, args);
7146 bool Grab(Bitmap bitmap, Box box, bool decorations)
7148 bool result = false;
7149 if(display || this == guiApp.desktop)
7151 Box clip = {MININT, MININT, MAXINT, MAXINT};
7157 clip.Clip(clientArea);
7159 clip.Clip(this.box);
7161 if(rootWindow != this)
7163 clip.left += absPosition.y;
7164 clip.top += absPosition.y;
7165 clip.right += absPosition.x;
7166 clip.bottom += absPosition.y;
7169 clip.left += decorations ? 0 : clientStart.x;
7170 clip.top += decorations ? 0 : clientStart.y;
7171 clip.right += decorations ? 0 : clientStart.x;
7172 clip.bottom += decorations ? 0 : clientStart.y;
7174 if(display && display.flags.flipping)
7176 rootWindow.Update(null);
7177 rootWindow.UpdateDisplay();
7184 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7185 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7189 result = display.Grab(bitmap, clip.left, clip.top,
7190 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7192 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7194 if(!bitmap.Convert(null, pixelFormat888, null))
7201 void GetMousePosition(int * x, int * y)
7203 int mouseX = 0, mouseY = 0;
7204 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7207 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7208 if(this != guiApp.desktop)
7210 mouseX -= absPosition.x + clientStart.x;
7211 mouseY -= absPosition.y + clientStart.y;
7218 DialogResult DoModal()
7220 DialogResult returnCode = 0;
7221 int terminated = terminateX;
7224 while(!destroyed && guiApp.driver != null)
7226 if(terminateX != terminated)
7228 terminated = terminateX;
7229 guiApp.desktop.Destroy(0);
7230 if(guiApp.desktop.created)
7233 //printf("Resetting terminate X to 0\n");
7239 guiApp.UpdateDisplay();
7240 if(!guiApp.ProcessInput(false))
7243 returnCode = this.returnCode;
7256 return !destroyed && guiApp.driver != null && terminateX < 2;
7259 DialogResult DoModalEnd()
7261 DialogResult returnCode = this.returnCode;
7266 // --- Window manipulation ---
7267 /*bool GetDisabled()
7269 bool disabled = this.disabled;
7271 for(window = this; (window = window.master); )
7282 // --- Mouse Manipulation ---
7283 void GetNCMousePosition(int * x, int * y)
7285 GetMousePosition(x, y);
7286 if(x) *x += clientStart.x;
7287 if(y) *y += clientStart.y;
7290 // --- Carets manipulation ---
7291 void GetCaretPosition(Point caretPos)
7293 caretPos = this.caretPos;
7296 int GetCaretSize(void)
7301 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7307 bool CloseConfirmation(bool parentClosing)
7320 if(!OnClose(parentClosing))
7323 // If you want to skip this, simply set modifiedDocument to false in OnClose
7324 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7326 DialogResult dialogRes;
7329 sprintf(message, $"Save changes to %s?", fileName);
7331 sprintf(message, $"Save changes to Untitled %d?", documentID);
7333 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7335 if(dialogRes == yes)
7337 // TOFIX: Precomp error if brackets are taken out
7338 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7340 else if(dialogRes == cancel)
7346 for(slave = slaves.first; slave; slave = slave.next)
7348 Window w = slave.data;
7349 if(w.parent != this && !w.IsDescendantOf(this) && !w.CloseConfirmation(true))
7357 // Confirm closure of active clients first (We use OnClose() to hide instead of destroy in the IDE)
7360 for(child = children.first; child; child = child.next)
7361 if(child.isActiveClient && !child.CloseConfirmation(true))
7369 for(child = children.first; child; child = child.next)
7370 if(!child.isActiveClient && !child.CloseConfirmation(true))
7380 // Static methods... move them somewhere else?
7381 void ::RestoreCaret()
7383 if(guiApp.caretOwner)
7384 guiApp.caretOwner.UpdateCaret(false, false);
7387 void ::FreeMouseRange()
7389 guiApp.interfaceDriver.SetMouseRange(null, null);
7393 bool MenuFileClose(MenuItem selection, Modifiers mods)
7395 Window document = activeChild;
7397 document.Destroy(0);
7401 bool MenuFileExit(MenuItem selection, Modifiers mods)
7407 bool MenuFileSave(MenuItem selection, Modifiers mods)
7412 fileMonitor.fileName = null;
7415 if(OnSaveFile(fileName))
7417 //if(OnFileModified != Window::OnFileModified)
7420 fileMonitor.fileName = fileName;
7426 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7427 DialogResult answer = dialog.Modal();
7429 if(answer != yes) return (bool)answer;
7432 return MenuFileSaveAs(selection, mods);
7435 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7437 DialogResult result = (DialogResult)bool::true;
7438 FileDialog fileDialog = saveDialog;
7443 fileDialog = FileDialog {};
7448 fileDialog.filePath = fileName;
7451 char filePath[MAX_FILENAME];
7452 sprintf(filePath, "Untitled %d", documentID);
7453 fileDialog.filePath = filePath;
7455 fileMonitor.fileName = null;
7457 fileDialog.type = save;
7458 fileDialog.text = $"Save As";
7462 fileDialog.master = master.parent ? master : this;
7463 if(fileDialog.Modal() == ok)
7465 const char * filePath = fileDialog.filePath;
7467 if(OnSaveFile(filePath))
7470 property::fileName = filePath;
7471 NotifySaved(master, this, filePath);
7476 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7477 DialogResult answer = dialog.Modal();
7492 //if(OnFileModified != Window::OnFileModified && fileName)
7495 fileMonitor.fileName = fileName;
7499 return (bool)result; // Actually returning result from Yes/NoCancel message box
7502 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7504 Window document = activeChild;
7506 for(document = children.first; document; document = next)
7508 next = document.next;
7509 if(document.style.isDocument || document.fileName)
7510 document.MenuFileSave(selection, mods);
7515 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7519 for(document = children.first; document; document = document.next)
7520 //if(document.style.isDocument && document.state == minimized)
7521 if(document.style.isActiveClient && document.state == minimized)
7522 document.SetState(minimized, false, mods);
7526 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7528 Window document = activeChild;
7531 Window firstDocument = null;
7533 OldLink cycle = document.cycle.prev;
7538 if(child.style.isActiveClient && !child.style.hidden)
7542 firstDocument = child;
7543 if(child.state == minimized)
7544 child.SetState(minimized, false, mods);
7547 child.positionID = id++;
7548 child.SetState(normal, false, mods);
7549 child.anchor.left.type = cascade;
7552 child.normalSizeAnchor = *&child.sizeAnchor;
7553 child.normalAnchor = child.anchor;
7555 // Break the anchors for moveable/resizable windows
7556 if(child.style.fixed)
7558 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7560 (*&child.normalAnchor).left = x;
7561 (*&child.normalAnchor).top = y;
7562 (*&child.normalAnchor).right.type = none;
7563 (*&child.normalAnchor).bottom.type = none;
7565 child.normalSizeAnchor.isClientW = false;
7566 child.normalSizeAnchor.isClientH = false;
7567 child.normalSizeAnchor.size.w = w;
7568 child.normalSizeAnchor.size.h = h;
7569 child.anchored = false;
7572 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7574 child.stateAnchor = child.normalAnchor;
7575 child.stateSizeAnchor = child.normalSizeAnchor;
7577 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7578 child.Position(x, y, w, h, true, true, true, true, false, false);
7583 last = children.last;
7584 if(!child.style.stayOnTop)
7585 for(; last && last.style.stayOnTop; last = last.prev);
7586 children.Move(child, last);
7587 childrenOrder.Move(child.order, childrenOrder.last);
7589 if(cycle == document.cycle) break;
7593 firstDocument.Activate();
7598 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7605 // Close all closes all active clients, not all documents
7606 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7608 Window next, document;
7610 for(document = children.first; document; document = next)
7612 for(next = document.next; next && !next.style.isActiveClient; next = next.next);
7613 if(document.style.isActiveClient)
7614 if(!document.Destroy(0) && !document.style.hidden)
7620 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7622 if(style.hasMaximize && state != maximized)
7623 SetState(maximized, 0, 0);
7627 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7629 if(style.hasMinimize && state != minimized)
7631 SetState(minimized, 0, 0);
7632 parent.CycleChildren(false, true, false, true);
7637 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7639 MenuMoveOrSize(false, selection ? true : false);
7643 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7645 CycleChildren(false, true, false, true);
7649 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7651 CycleChildren(true, true, false, true);
7655 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7657 MenuMoveOrSize(true, true);
7661 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7664 SetState(normal, 0, 0);
7668 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7671 int64 id = selection.id;
7672 OldLink cycle = activeClient.cycle;
7674 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7677 Window sibling = cycle.data;
7678 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7686 document = cycle.data;
7687 document.Activate();
7689 //if(activeChild.state == maximized)
7690 // document.SetState(maximized, false, mods);
7691 //else if(document.state == minimized)
7692 // document.SetState(normal, false, mods);
7696 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7698 stayOnTop = !style.stayOnTop;
7702 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7704 Window document = activeChild;
7707 Window firstDocument = null;
7708 OldLink cycle = document.cycle;
7712 Window child = cycle.data;
7713 if(child.style.isActiveClient && !child.style.hidden)
7715 if(!firstDocument) firstDocument = child;
7716 if(child.state == minimized)
7717 child.SetState(minimized, false, mods);
7720 child.positionID = id++;
7721 child.SetState(normal, false, mods);
7722 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7724 child.anchor.left.type = hTiled;
7727 child.normalSizeAnchor = *&child.sizeAnchor;
7728 child.normalAnchor = child.anchor;
7730 // Break the anchors for moveable/resizable windows
7731 if(child.style.fixed)
7733 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7735 (*&child.normalAnchor).left = x;
7736 (*&child.normalAnchor).top = y;
7737 (*&child.normalAnchor).right.type = none;
7738 (*&child.normalAnchor).bottom.type = none;
7739 child.normalSizeAnchor.isClientW = false;
7740 child.normalSizeAnchor.isClientH = false;
7741 child.normalSizeAnchor.size.w = w;
7742 child.normalSizeAnchor.size.h = h;
7743 child.anchored = false;
7746 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7748 child.stateAnchor = child.normalAnchor;
7749 child.stateSizeAnchor = child.normalSizeAnchor;
7751 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7752 child.Position(x,y, w, h, true, true, true, true, false, true);
7757 if((cycle = cycle.next) == document.cycle) break;
7760 firstDocument.Activate();
7765 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7767 Window document = activeChild;
7770 Window firstDocument = null;
7772 OldLink cycle = document.cycle;
7777 //if(child.style.isDocument)
7778 if(child.style.isActiveClient && !child.style.hidden)
7780 if(!firstDocument) firstDocument = child;
7781 if(child.state == minimized)
7782 child.SetState(minimized, false, mods);
7785 child.positionID = id++;
7786 child.SetState(normal, false, mods);
7787 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7789 child.anchor.left.type = vTiled;
7792 child.normalSizeAnchor = *&child.sizeAnchor;
7793 child.normalAnchor = child.anchor;
7795 // Break the anchors for moveable/resizable windows
7796 if(child.style.fixed)
7798 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7800 (*&child.normalAnchor).left = x;
7801 (*&child.normalAnchor).top = y;
7802 (*&child.normalAnchor).right.type = none;
7803 (*&child.normalAnchor).bottom.type = none;
7804 child.normalSizeAnchor.isClientW = false;
7805 child.normalSizeAnchor.isClientH = false;
7806 child.normalSizeAnchor.size.w = w;
7807 child.normalSizeAnchor.size.h = h;
7808 child.anchored = false;
7811 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7813 child.stateAnchor = child.normalAnchor;
7814 child.stateSizeAnchor = child.normalSizeAnchor;
7816 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7817 child.Position(x,y, w, h, true, true, true, true, false, true);
7822 if((cycle = cycle.next) == document.cycle) break;
7825 firstDocument.Activate();
7830 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7832 WindowList dialog { master = this };
7833 Window document = (Window)(intptr)dialog.Modal();
7836 if(activeChild.state == maximized)
7837 document.SetState(maximized, false, mods);
7838 else if(document.state == minimized)
7839 document.SetState(normal, false, mods);
7840 document.Activate();
7846 virtual bool OnCreate(void);
7847 virtual void OnDestroy(void);
7848 virtual void OnDestroyed(void);
7849 virtual bool OnClose(bool parentClosing);
7850 virtual bool OnStateChange(WindowState state, Modifiers mods);
7851 virtual bool OnPostCreate(void);
7852 virtual bool OnMoving(int *x, int *y, int w, int h);
7853 virtual bool OnResizing(int *width, int *height);
7854 virtual void OnResize(int width, int height);
7855 virtual void OnPosition(int x, int y, int width, int height);
7856 virtual bool OnLoadGraphics(void);
7857 virtual void OnApplyGraphics(void);
7858 virtual void OnUnloadGraphics(void);
7859 virtual void OnRedraw(Surface surface);
7860 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7861 virtual void OnActivateClient(Window client, Window previous);
7862 virtual bool OnKeyDown(Key key, unichar ch);
7863 virtual bool OnKeyUp(Key key, unichar ch);
7864 virtual bool OnKeyHit(Key key, unichar ch);
7865 virtual bool OnSysKeyDown(Key key, unichar ch);
7866 virtual bool OnSysKeyUp(Key key, unichar ch);
7867 virtual bool OnSysKeyHit(Key key, unichar ch);
7868 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7869 virtual bool OnMouseLeave(Modifiers mods);
7870 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7871 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7872 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7873 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7874 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7875 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7876 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7877 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7878 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7879 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7880 virtual void OnMouseCaptureLost(void);
7881 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7882 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7883 virtual void OnDrawOverChildren(Surface surface);
7884 virtual bool OnFileModified(FileChange fileChange, const char * param);
7885 virtual bool OnSaveFile(const char * fileName);
7887 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7888 // Note: A 'client' would refer to isActiveClient, rather than
7889 // being confined to the 'client area' (nonClient == false)
7890 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7891 virtual void OnChildVisibilityToggled(Window child, bool visible);
7892 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7894 // Skins Virtual Functions
7895 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7896 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7897 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7902 virtual void ShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7903 virtual void PreShowDecorations(Font captionFont, Surface surface, const char * name, bool active, bool moving);
7904 virtual bool IsMouseMoving(int x, int y, int w, int h)
7908 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7912 virtual void UpdateNonClient();
7913 virtual void SetBox(Box box); // This is used in the MySkin skin
7914 virtual bool IsInside(int x, int y)
7916 return box.IsPointInside({x, y});
7918 virtual bool IsOpaque()
7920 return (!style.drawBehind || background.a == 255);
7924 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7925 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7926 virtual void Window::NotifySaved(Window window, const char * filePath);
7931 property Window parent
7933 property_category $"Layout"
7936 if(value || guiApp.desktop)
7939 Window oldParent = parent;
7940 Anchor anchor = this.anchor;
7942 if(value && value.IsDescendantOf(this)) return;
7943 if(value && value == this)
7945 if(!value) value = guiApp.desktop;
7947 if(value == oldParent) return;
7949 if(!master || (master == this.parent && master == guiApp.desktop))
7950 property::master = value;
7954 parent.children.Remove(this);
7958 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7959 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7960 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7961 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7965 last = value.children.last;
7967 if(style.isDocument)
7970 parent.numDocuments--;
7971 documentID = value.GetDocumentID();
7974 if(style.isActiveClient && !style.hidden)
7976 if(parent && parent != guiApp.desktop && !(style.hidden))
7978 if(state == minimized) parent.numIcons--;
7979 parent.numPositions--;
7983 if(!style.stayOnTop)
7984 for(; last && last.style.stayOnTop; last = last.prev);
7986 value.children.Insert(last, this);
7988 // *** NEW HERE: ***
7990 parent.childrenCycle.Delete(cycle);
7992 parent.childrenOrder.Delete(order);
7995 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7996 // Should something else be done?
7997 if(parent && parent.activeChild == this)
7998 parent.activeChild = null;
7999 if(parent && parent.activeClient == this)
8000 parent.activeClient = null;
8006 int x = position.x, y = position.y, w = size.w, h = size.h;
8010 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
8011 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
8013 vpw = value.clientSize.w;
8014 vph = value.clientSize.h;
8020 else if(style.fixed)
8022 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
8023 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
8026 anchor = this.anchor;
8028 if(anchor.left.type == offset) anchor.left.distance = x;
8029 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
8030 if(anchor.top.type == offset) anchor.top.distance = y;
8031 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
8032 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
8033 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
8034 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
8035 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
8036 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
8037 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
8039 if(!anchor.left.type && !anchor.right.type)
8041 anchor.horz.distance = (x + w / 2) - (vpw / 2);
8042 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
8044 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
8045 if(!anchor.top.type && !anchor.bottom.type)
8047 anchor.vert.distance = (y + h / 2) - (vph / 2);
8048 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
8050 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
8053 parent.OnChildAddedOrRemoved(this, false);
8059 parent.childrenCycle.Insert(
8060 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8061 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8063 cycle = OldLink { data = this });
8064 parent.childrenOrder.Insert(
8065 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8066 order = OldLink { data = this });
8069 if(!style.hidden && style.isActiveClient)
8071 positionID = parent.GetPositionID(this);
8072 parent.numPositions++;
8073 if(state == minimized) parent.numIcons--;
8076 // *** FONT INHERITANCE ***
8077 if(!setFont && oldParent)
8078 stopwatching(oldParent, font);
8082 RemoveResource(systemFont);
8085 // TESTING WITH WATCHERS:
8086 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8087 // usedFont = setFont ? setFont : (systemFont);
8091 if(guiApp.currentSkin)
8093 systemFont = guiApp.currentSkin.SystemFont();
8096 usedFont = systemFont;
8097 AddResource(systemFont);
8105 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8114 if(value.rootWindow && value.rootWindow.display && rootWindow && created)
8116 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
8117 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
8120 UnloadGraphics(false);
8123 LoadGraphics(false, false);
8126 if(value.rootWindow != rootWindow)
8127 DisplayModeChanged();
8131 scrolledPos.x = MININT; // Prevent parent update
8133 bool anchored = this.anchored;
8134 property::anchor = anchor;
8135 this.anchored = anchored;
8140 if(guiApp.currentSkin)
8141 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
8143 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8144 Position(x, y, w, h, true, true, true, true, false, true);
8149 // else parent = value;
8151 oldParent.OnChildAddedOrRemoved(this, true);
8154 get { return parent; }
8157 property Window master
8159 property_category $"Behavior"
8162 //if(this == value) return;
8163 if(value && value.IsSlaveOf(this)) return;
8169 OldLink slaveHolder;
8170 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8171 if(slaveHolder.data == this)
8173 master.slaves.Delete(slaveHolder);
8180 value.slaves.Add(OldLink { data = this });
8185 master.hotKeys.Remove(hotKey);
8186 value.hotKeys.Add(hotKey);
8189 if(master && master.defaultControl == this)
8190 master.defaultControl = null;
8192 if(style.isDefault && !value.defaultControl)
8193 value.defaultControl = this;
8198 get { return master ? master : parent; }
8201 property const char * caption
8203 property_category $"Appearance"
8210 caption = new char[strlen(value)+1];
8212 strcpy(caption, value);
8217 get { return caption; }
8222 property_category $"Behavior"
8231 master.hotKeys.Add(hotKey = HotKeySlot { });
8235 hotKey.window = this;
8240 master.hotKeys.Delete(hotKey);
8245 get { return hotKey ? hotKey.key : 0; }
8248 property Color background
8250 property_category $"Appearance"
8253 background.color = value;
8258 if(this == rootWindow)
8259 guiApp.interfaceDriver.SetRootWindowColor(this);
8262 get { return background.color; }
8265 property Percentage opacity
8267 property_category $"Appearance"
8270 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8271 drawBehind = (background.a == 255) ? false : true;
8273 get { return background.a / 255.0f; }
8276 property Color foreground
8278 property_category $"Appearance"
8286 get { return foreground; }
8289 property BorderStyle borderStyle
8291 property_category $"Appearance"
8294 if(!((BorderBits)value).fixed)
8296 style.hasClose = false;
8297 style.hasMaximize = false;
8298 style.hasMinimize = false;
8299 nativeDecorations = false;
8301 style.borderBits = value;
8305 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8307 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8308 Position(x, y, w, h, true, true, true, true, false, true);
8309 CreateSystemChildren();
8312 get { return (BorderStyle)style.borderBits; }
8315 property Size minClientSize
8317 property_category $"Layout"
8318 set { minSize = value; }
8319 get { value = minSize; }
8322 property Size maxClientSize
8324 property_category $"Layout"
8325 set { maxSize = value; }
8326 get { value = maxSize; }
8329 property bool hasMaximize
8331 property_category $"Window Style"
8334 style.hasMaximize = value;
8335 if(value) { style.fixed = true; style.contour = true; }
8339 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8341 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8342 Position(x, y, w, h, true, true, true, true, false, true);
8344 CreateSystemChildren();
8347 get { return style.hasMaximize; }
8350 property bool hasMinimize
8352 property_category $"Window Style"
8355 style.hasMinimize = value;
8356 if(value) { style.fixed = true; style.contour = true; }
8360 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8362 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8363 Position(x, y, w, h, true, true, true, true, false, true);
8365 CreateSystemChildren();
8368 get { return style.hasMinimize; }
8371 property bool hasClose
8373 property_category $"Window Style"
8376 style.hasClose = value;
8377 if(value) { style.fixed = true; style.contour = true; }
8381 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8382 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8383 Position(x, y, w, h, true, true, true, true, false, true);
8384 CreateSystemChildren();
8387 get { return style.hasClose; }
8390 property bool nonClient
8392 property_category $"Layout"
8395 style.nonClient = value;
8397 style.stayOnTop = true;
8399 get { return style.nonClient; }
8402 property bool inactive
8404 property_category $"Behavior"
8409 // *** NEW HERE: ***
8413 parent.childrenCycle.Delete(cycle);
8415 parent.childrenOrder.Delete(order);
8422 active = false; // true;
8423 if(parent.activeChild == this)
8424 parent.activeChild = null;
8425 if(parent.activeClient == this)
8426 parent.activeClient = null;
8435 parent.childrenCycle.Insert(
8436 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8437 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8439 cycle = OldLink { data = this });
8441 parent.childrenOrder.Insert(
8442 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8443 order = OldLink { data = this });
8446 style.inactive = value;
8448 get { return style.inactive; }
8451 property bool clickThrough
8453 property_category $"Behavior"
8454 set { style.clickThrough = value; }
8455 get { return style.clickThrough; }
8458 property bool isRemote
8460 property_category $"Behavior"
8461 set { style.isRemote = value; }
8462 get { return style.isRemote; }
8465 property bool noCycle
8467 property_category $"Behavior"
8468 set { style.noCycle = value; }
8469 get { return style.noCycle; }
8472 property bool isModal
8474 property_category $"Behavior"
8475 set { style.modal = value; }
8476 get { return style.modal; }
8479 property bool interim
8481 property_category $"Behavior"
8482 set { style.interim = value; }
8483 get { return style.interim; }
8486 property bool tabCycle
8488 property_category $"Behavior"
8489 set { style.tabCycle = value; }
8490 get { return style.tabCycle; }
8493 property bool isDefault
8495 property_category $"Behavior"
8503 for(sibling = parent.children.first; sibling; sibling = sibling.next)
8504 if(sibling != this && sibling.style.isDefault)
8505 sibling.style.isDefault = false;*/
8506 if(master.defaultControl)
8507 master.defaultControl.style.isDefault = false;
8508 master.defaultControl = this;
8510 else if(master.defaultControl == this)
8511 master.defaultControl = null;
8515 style.isDefault = value;
8517 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8519 get { return style.isDefault; }
8522 property bool drawBehind
8524 property_category $"Window Style"
8525 set { style.drawBehind = value; }
8526 get { return style.drawBehind; }
8529 property bool hasMenuBar
8531 property_category $"Window Style"
8541 if(created && !menuBar)
8548 anchor = Anchor { top = 23, left = 1, right = 1 },
8550 inactive = true, nonClient = true
8555 else if(created && menuBar)
8560 style.hasMenuBar = value;
8562 get { return style.hasMenuBar; }
8565 property bool hasStatusBar
8567 property_category $"Window Style"
8574 statusBar = StatusBar { this };
8582 style.hasStatusBar = value;
8584 get { return style.hasStatusBar; }
8586 property bool stayOnTop
8588 property_category $"Window Style"
8593 if(created && !style.stayOnTop)
8595 if(rootWindow == this)
8596 guiApp.interfaceDriver.OrderRootWindow(this, true);
8597 else if(parent.children.last != this)
8599 parent.children.Move(this, parent.children.last);
8603 style.stayOnTop = true;
8607 if(created && style.stayOnTop)
8609 if(rootWindow == this)
8610 guiApp.interfaceDriver.OrderRootWindow(this, false);
8617 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8618 order && ((Window)order.data).style.stayOnTop;
8619 order = (order == parent.childrenOrder.first) ? null : order.prev);
8620 last = order ? order.data : null;
8624 for(last = parent.children.last;
8625 last && last.style.stayOnTop;
8629 parent.children.Move(this, last);
8633 style.stayOnTop = false;
8636 get { return style.stayOnTop; }
8641 property_category $"Window Style"
8651 if(menuBar && !value)
8658 if(!menuBar && style.hasMenuBar && value)
8662 this, menu = value, isMenuBar = true,
8663 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8664 inactive = true, nonClient = true
8668 UpdateActiveDocument(null);
8671 get { return menu; }
8674 property FontResource font
8676 property_category $"Appearance"
8678 isset { return setFont ? true : false; }
8683 if(value && !setFont) { stopwatching(parent, font); }
8684 else if(!value && setFont)
8690 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8699 RemoveResource(setFont);
8704 RemoveResource(systemFont);
8711 AddResource(setFont);
8714 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8717 systemFont = guiApp.currentSkin.SystemFont();
8719 usedFont = systemFont;
8720 AddResource(systemFont);
8728 get { return usedFont; }
8731 property SizeAnchor sizeAnchor
8733 property_category $"Layout"
8736 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8737 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8738 sizeAnchor.isClientW != sizeAnchor.isClientH;
8745 normalSizeAnchor = sizeAnchor;
8747 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8749 stateAnchor = normalAnchor;
8750 stateSizeAnchor = normalSizeAnchor;
8752 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8753 Position(x,y, w, h, true, true, true, true, false, true);
8760 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8761 sizeAnchor.isClientW,
8762 sizeAnchor.isClientH
8769 property_category $"Layout"
8772 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8773 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8774 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8780 sizeAnchor.isClientW = false;
8781 sizeAnchor.isClientH = false;
8782 sizeAnchor.size = value;
8784 normalSizeAnchor = sizeAnchor;
8786 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8788 stateAnchor = normalAnchor;
8789 stateSizeAnchor = normalSizeAnchor;
8791 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8792 Position(x, y, w, h, true, true, true, true, false, true);
8793 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8796 get { value = size; }
8799 property Size clientSize
8801 property_category $"Layout"
8804 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8805 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8806 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8811 sizeAnchor.isClientW = true;
8812 sizeAnchor.isClientH = true;
8813 sizeAnchor.size = value;
8815 normalSizeAnchor = sizeAnchor;
8817 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8819 stateAnchor = normalAnchor;
8820 stateSizeAnchor = normalSizeAnchor;
8822 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8823 Position(x,y, w, h, true, true, true, true, false, true);
8824 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8827 get { value = this ? clientSize : { 0, 0 }; }
8830 property Size initSize { get { value = sizeAnchor.size; } };
8832 property Anchor anchor
8834 property_category $"Layout"
8835 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8841 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8843 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8844 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8846 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8848 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8849 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8853 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8855 anchor.left.distance = 0;
8856 anchor.horz.type = 0;
8858 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8860 anchor.top.distance = 0;
8861 anchor.vert.type = 0;
8870 normalAnchor = anchor;
8872 // Break the anchors for moveable/resizable windows
8873 /*if(style.fixed ) //&& value.left.type == cascade)
8875 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8877 this.anchor = normalAnchor = Anchor { left = x, top = y };
8878 normalSizeAnchor = SizeAnchor { { w, h } };
8881 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8883 stateAnchor = normalAnchor;
8884 stateSizeAnchor = normalSizeAnchor;
8886 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8887 Position(x, y, w, h, true, true, true, true, false, true);
8896 get { value = this ? anchor : Anchor { }; }
8899 property Point position
8901 property_category $"Layout"
8904 if(value == null) return;
8906 anchor.left = value.x;
8907 anchor.top = value.y;
8908 anchor.right.type = none;
8909 anchor.bottom.type = none;
8914 normalAnchor = anchor;
8916 // Break the anchors for moveable/resizable windows
8920 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8922 normalAnchor.left = x;
8923 normalAnchor.top = y;
8924 normalAnchor.right.type = none;
8925 normalAnchor.bottom.type = none;
8926 normalSizeAnchor.size.width = w;
8927 normalSizeAnchor.size.height = h;
8931 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8933 stateAnchor = normalAnchor;
8934 stateSizeAnchor = normalSizeAnchor;
8936 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8937 Position(x,y, w, h, true, true, true, true, false, true);
8941 get { value = position; }
8944 property bool disabled
8946 property_category $"Behavior"
8949 if(this && disabled != value)
8956 get { return (bool)disabled; }
8959 property bool isEnabled
8964 for(parent = this; parent; parent = parent.parent)
8971 property WindowState state
8973 property_category $"Behavior"
8974 set { SetState(value, false, 0); }
8975 get { return this ? state : 0; }
8978 property bool visible
8980 property_category $"Behavior"
8983 if(this && !value && !style.hidden && parent)
8985 bool wasActiveChild = parent.activeChild == this;
8986 Window client = null;
8988 style.hidden = true;
8989 if(style.isActiveClient)
8991 parent.numPositions--;
8992 if(state == minimized) parent.numIcons--;
8997 OldLink prevOrder = null;
8999 if(rootWindow == this)
9000 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
9003 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
9006 box.left -= parent.clientStart.x;
9007 box.top -= parent.clientStart.y;
9008 box.right -= parent.clientStart.x;
9009 box.bottom -= parent.clientStart.y;
9013 if(_isModal && master && master.modalSlave == this)
9014 master.modalSlave = null;
9018 OldLink tmpPrev = order.prev;
9019 client = tmpPrev ? tmpPrev.data : null;
9020 if(client && !client.style.hidden && !client.destroyed && client.created)
9021 prevOrder = tmpPrev;
9024 client = tmpPrev ? tmpPrev.data : null;
9025 if(client == this) { client = null; break; }
9026 if(client && ((client.style.hidden) || client.destroyed || !client.created))
9028 tmpPrev = client.order.prev;
9033 prevOrder = tmpPrev;
9038 // If this window can be an active client, make sure the next window we activate can also be one
9039 if(!style.nonClient && style.isActiveClient)
9041 tmpPrev = prevOrder;
9044 client = tmpPrev ? tmpPrev.data : null;
9045 if(client == this) { client = null; break; }
9046 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
9048 tmpPrev = client.order.prev;
9053 prevOrder = tmpPrev;
9057 if(client && client.style.hidden) client = null;
9061 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
9063 if(order && prevOrder && prevOrder.data != this)
9064 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
9066 ActivateEx(false, false, false, true, null, null);
9068 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
9069 if(parent.activeClient == this)
9071 parent.activeClient = null;
9072 parent.UpdateActiveDocument(null);
9075 else if(parent.activeClient == this)
9077 parent.activeClient = client;
9078 parent.UpdateActiveDocument(this);
9081 // *** Not doing this anymore ***
9084 parent.childrenCycle.Delete(cycle);
9086 parent.childrenOrder.Delete(order);
9091 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9096 else if(this && value && style.hidden)
9098 style.hidden = false;
9101 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9102 if(rootWindow == this)
9103 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
9105 if(_isModal && master)
9106 master.modalSlave = this;
9108 if(style.isActiveClient)
9110 positionID = parent.GetPositionID(this);
9111 parent.numPositions++;
9112 if(state == minimized) parent.numIcons++;
9115 // *** NOT DOING THIS ANYMORE ***
9117 if(!(style.inactive))
9119 if(!(style.noCycle))
9121 cycle = parent.childrenCycle.AddAfter(
9122 (parent.activeChild && parent.activeChild.cycle) ?
9123 parent.activeChild.cycle.prev : null, sizeof(OldLink));
9126 order = parent.childrenOrder.AddAfter(
9127 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
9134 if(true || !parent.activeChild)
9135 ActivateEx(true, false, true, true, null, null);
9137 if(creationActivation == activate && guiApp.desktop.active)
9138 ActivateEx(true, false, true, true, null, null);
9139 else if((creationActivation == activate || creationActivation == flash) && !object)
9142 if(this == rootWindow)
9146 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9150 ConsequentialMouseMove(false);
9156 style.hidden = !value;
9159 get { return (style.hidden || !setVisible) ? false : true; }
9162 property bool isDocument
9164 property_category $"Document"
9165 set { style.isDocument = value; if(value) SetupFileMonitor(); }
9166 get { return style.isDocument; }
9169 property bool mergeMenus
9171 property_category $"Window Style"
9172 set { mergeMenus = value; }
9173 get { return (bool)mergeMenus; }
9176 property bool hasHorzScroll
9178 property_category $"Window Style"
9183 if(!style.hasHorzScroll && created)
9185 CreateSystemChildren();
9186 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9189 else if(style.hasHorzScroll)
9193 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9195 style.hasHorzScroll = value;
9198 get { return style.hasHorzScroll; }
9201 property bool hasVertScroll
9203 property_category $"Window Style"
9208 if(!style.hasVertScroll && created)
9210 style.hasVertScroll = true;
9211 CreateSystemChildren();
9212 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9215 else if(style.hasVertScroll)
9219 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9221 style.hasVertScroll = value;
9223 get { return style.hasVertScroll; }
9226 property bool dontHideScroll
9228 property_category $"Behavior"
9231 scrollFlags.dontHide = value;
9234 //UpdateScrollBars(true, true);
9235 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9239 // UpdateScrollBars(true, true);
9240 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9243 get { return scrollFlags.dontHide; }
9246 property bool dontScrollVert
9248 property_category $"Behavior"
9249 set { style.dontScrollVert = value; }
9250 get { return style.dontScrollVert; }
9252 property bool dontScrollHorz
9254 property_category $"Behavior"
9255 set { style.dontScrollHorz = value; }
9256 get { return style.dontScrollHorz; }
9259 property bool snapVertScroll
9261 property_category $"Behavior"
9264 scrollFlags.snapY = value;
9265 if(sbv) sbv.snap = value;
9267 get { return scrollFlags.snapY; }
9269 property bool snapHorzScroll
9271 property_category $"Behavior"
9274 scrollFlags.snapX = value;
9275 if(sbh) sbh.snap = value;
9277 get { return scrollFlags.snapX; }
9280 property Point scroll
9282 property_category $"Behavior"
9283 set { if(this) SetScrollPosition(value.x, value.y); }
9284 get { value = scroll; }
9287 property bool modifyVirtualArea
9289 property_category $"Behavior"
9290 set { modifyVirtArea = value; }
9291 get { return (bool)modifyVirtArea; }
9294 property bool dontAutoScrollArea
9296 property_category $"Behavior"
9297 // Activating a child control out of view will automatically scroll to make it in view
9298 set { noAutoScrollArea = value; }
9299 get { return (bool)noAutoScrollArea; }
9302 property const char * fileName
9304 property_category $"Document"
9309 if(menu && ((!fileName && value) || (fileName && !value)))
9311 MenuItem item = menu.FindItem(MenuFileSave, 0);
9312 if(item) item.disabled = !modifiedDocument && value;
9317 if(value && value[0])
9318 fileName = CopyString(value);
9320 if(parent && this == parent.activeClient)
9321 parent.UpdateActiveDocument(null);
9325 // if(style.isDocument)
9327 fileMonitor.fileName = value;
9329 get { return fileName; }
9334 property_category $"Data"
9339 property bool modifiedDocument
9341 property_category $"Document"
9344 if(style.isDocument || fileName)
9348 MenuItem item = menu.FindItem(MenuFileSave, 0);
9349 if(item) item.disabled = !value && fileName;
9353 if(modifiedDocument != value)
9355 modifiedDocument = value;
9356 if(style.isDocument || fileName)
9360 get { return (bool)modifiedDocument; }
9363 property bool showInTaskBar
9365 property_category $"Window Style"
9366 set { style.showInTaskBar = value; }
9367 get { return style.showInTaskBar; }
9369 property FileDialog saveDialog { set { saveDialog = value; } };
9370 property bool isActiveClient
9372 property_category $"Behavior"
9375 if(parent && style.isActiveClient != value && !style.hidden)
9379 if(state == minimized) parent.numIcons++;
9380 parent.numPositions++;
9384 if(state == minimized) parent.numIcons--;
9385 parent.numPositions--;
9388 style.isActiveClient = value;
9390 get { return style.isActiveClient; }
9393 property Cursor cursor
9395 property_category $"Appearance"
9399 SelectMouseCursor();
9401 get { return cursor; }
9404 //#if !defined(ECERE_VANILLA)
9405 property const char * name
9407 property_category $"Design"
9410 return (this && object) ? object.name : null;
9415 activeDesigner.RenameObject(object, value);
9419 property const char * displayDriver
9421 property_category $"Behavior"
9424 dispDriver = GetDisplayDriver(value);
9425 //DisplayModeChanged();
9429 return dispDriver ? dispDriver.name : null;
9433 // RUNTIME PROPERTIES
9434 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9435 property Size scrollArea
9437 property_category $"Behavior"
9441 SetScrollArea(value.w, value.h, false);
9443 SetScrollArea(0,0, true);
9445 get { value = scrollArea; }
9448 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9453 property_category $"Layout"
9454 set { if(this) is3D = value; }
9455 get { return (bool)is3D; }
9458 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9460 // Will be merged with font later
9461 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9462 property Point clientStart { get { value = clientStart; } };
9463 property Point absPosition { get { value = absPosition; } };
9464 property Anchor normalAnchor { get { value = normalAnchor; } };
9465 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9466 property bool active { get { return (bool)active; } };
9467 property bool created { get { return (bool)created; } };
9468 property bool destroyed { get { return (bool)destroyed; } };
9469 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9470 property Window firstChild { get { return children.first; } };
9471 property Window lastChild { get { return children.last; } };
9472 property Window activeClient { get { return activeClient; } };
9473 property Window activeChild { get { return activeChild; } };
9474 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9475 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9476 property ScrollBar horzScroll { get { return sbh; } };
9477 property ScrollBar vertScroll { get { return sbv; } };
9478 property StatusBar statusBar { get { return statusBar; } };
9479 property Window rootWindow { get { return rootWindow; } };
9480 property bool closing { get { return (bool)closing; } set { closing = value; } };
9481 property int documentID { get { return documentID; } };
9482 property Window previous { get { return prev; } }
9483 property Window next { get { return next; } }
9484 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9485 property PopupMenu menuBar { get { return menuBar; } }
9486 property ScrollBar sbv { get { return sbv; } }
9487 property ScrollBar sbh { get { return sbh; } }
9488 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9489 property void * systemHandle { get { return windowHandle; } }
9490 property Button minimizeButton { get { return sysButtons[0]; } };
9491 property Button maximizeButton { get { return sysButtons[1]; } };
9492 property Button closeButton { get { return sysButtons[2]; } };
9493 property BitmapResource icon
9495 get { return icon; }
9499 if(icon) incref icon;
9501 guiApp.interfaceDriver.SetIcon(this, value);
9504 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9505 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9506 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9507 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9508 property bool nativeDecorations
9510 get { return (bool)nativeDecorations; }
9511 set { nativeDecorations = value; }
9512 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9515 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9516 bool result = false;
9517 if(nativeDecorations)
9519 if(rootWindow == this)
9523 if(formDesigner && activeDesigner)
9525 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9526 Window form = cd ? cd.form : null;
9527 if(form && parent == form.parent)
9532 return result != style.fixed;
9536 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9538 property const char * text
9540 property_category $"Deprecated"
9542 set { property::caption = value; }
9543 get { return property::caption; }
9549 WindowBits style; // Window Style
9550 char * caption; // Name / Caption
9551 Window parent; // Parent window
9552 OldList children; // List of children in Z order
9553 Window activeChild; // Child window having focus
9554 Window activeClient;
9555 Window previousActive; // Child active prior to activating the default child
9556 Window master; // Window owning and receiving notifications concerning this window
9557 OldList slaves; // List of windows belonging to this window
9558 Display display; // Display this window is drawn into
9560 Point position; // Position in parent window client area
9561 Point absPosition; // Absolute position
9562 Point clientStart; // Client area position from (0,0) in this window
9564 Size clientSize; // Client area size
9565 Size scrollArea; // Virtual Scroll area size
9566 Size reqScrollArea; // Requested virtual area size
9567 Point scroll; // Virtual area scrolling position
9568 ScrollBar sbh, sbv; // Scrollbar window handles
9569 Cursor cursor; // Mouse cursor used for this window
9572 StatusBar statusBar;
9573 Button sysButtons[3];
9575 Box clientArea; // Client Area box clipped to parent
9577 HotKeySlot hotKey; // HotKey for this window
9581 ScrollFlags scrollFlags;// Window Scrollbar Flags
9582 int64 id; // Control ID
9584 ColorAlpha background; // Background color used to draw the window area
9586 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9587 OldList childrenCycle; // Cycling order
9588 OldLink cycle; // Element of parent's cycling order
9589 OldList childrenOrder; // Circular Z-Order
9590 OldLink order; // Element of parent's circular Z-Order
9591 Window modalSlave; // Slave window blocking this window's interaction
9593 Window rootWindow; // Topmost system managed window
9594 void * windowHandle; // System window handle
9596 DialogResult returnCode;// Return code for modal windows
9598 Point sbStep; // Scrollbar line scrolling steps
9601 SizeAnchor stateSizeAnchor;
9603 Anchor normalAnchor;
9604 SizeAnchor normalSizeAnchor;
9606 Size skinMinSize; // Minimal window size based on style
9607 Point scrolledPos; // Scrolled position
9608 Box box; // Window box clipped to parent
9609 Box * against; // What to clip the box to
9611 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9612 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9613 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9614 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9615 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9616 Point scrolledArea; // Distance to scroll area by
9617 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9619 OldList hotKeys; // List of the hotkeys of all children
9620 Window defaultControl; // Default child control
9624 ColorAlpha * palette; // Color palette used for this window
9626 int caretSize; // Size of caret, non zero if a caret is present
9627 Point caretPos; // Caret position
9629 void * systemParent; // Parent System Window for embedded windows
9636 WindowState lastState;
9638 FileMonitor fileMonitor;
9640 FontResource setFont, systemFont;
9641 FontResource usedFont;
9642 FontResource captionFont;
9644 FileDialog saveDialog;
9646 SizeAnchor sizeAnchor;
9648 // FormDesigner data
9651 Extent * tempExtents; //[4];
9652 BitmapResource icon;
9654 CreationActivationOption creationActivation;
9657 bool active:1; // true if window and ancestors are active
9658 bool acquiredInput:1; // true if the window is processing state based input
9659 bool modifiedDocument:1;
9660 bool disabled:1; // true if window cannot interact
9661 bool isForegroundWindow:1;// true while a root window is being activated
9662 bool visible:1; // Visibility flag
9663 bool destroyed:1; // true if window is being destroyed
9664 bool anchored:1; // true if this window is repositioned when the parent resizes
9665 bool dirty:1; // Flag set to true if any descendant must be redrawn
9671 bool modifyVirtArea:1;
9672 bool noAutoScrollArea:1;
9675 bool setVisible:1; // FOR FORM DESIGNER
9681 bool useSharedMemory:1;
9684 bool nativeDecorations:1;
9685 bool manageDisplay:1;
9686 bool formDesigner:1; // True if we this is running in the form editor
9687 bool requireRemaximize:1;
9690 // Checks used internally for them not to take effect in FormDesigner
9691 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9692 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9694 WindowController controller;
9695 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9698 public class CommonControl : Window
9700 // creationActivation = doNothing;
9703 public property const String toolTip
9705 property_category $"Appearance"
9708 if(created) CommonControl::OnDestroy();
9710 toolTip = value ? ToolTip { tip = value; } : null;
9712 if(created) CommonControl::OnCreate();
9714 get { return toolTip ? toolTip.tip : null; }
9720 // (Very) Ugly work around for the fact that the parent watcher
9721 // won't fire when it's already been disconnected...
9722 eInstance_FireSelfWatchers(toolTip,
9723 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9729 toolTip.parent = this;
9738 public class Percentage : float
9740 const char * OnGetString(char * string, float * fieldData, bool * needClass)
9744 sprintf(string, "%.2f", this);
9745 c = strlen(string)-1;
9748 if(string[c] != '0')
9749 last = Max(last, c);
9750 if(string[c] == '.')
9763 public void ApplySkin(Class c, const char * name, void ** vTbl)
9765 char className[1024];
9770 subclass(Window) wc = (subclass(Window))c;
9771 subclass(Window) base = (subclass(Window))c.base;
9773 sprintf(className, "%sSkin_%s", name, c.name);
9774 wc.pureVTbl = c._vTbl;
9775 c._vTbl = new void *[c.vTblSize];
9776 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9777 sc = eSystem_FindClass(c.module.application, className);
9781 for(m = 0; m < c.base.vTblSize; m++)
9783 if(c._vTbl[m] == base.pureVTbl[m])
9784 c._vTbl[m] = vTbl[m];
9789 for(m = 0; m < c.vTblSize; m++)
9791 if(sc._vTbl[m] != wc.pureVTbl[m])
9792 c._vTbl[m] = sc._vTbl[m];
9796 for(d = c.derivatives.first; d; d = d.next)
9798 ApplySkin(d.data, name, c._vTbl);
9802 public void UnapplySkin(Class c)
9804 subclass(Window) wc = (subclass(Window))c;
9807 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9810 c._vTbl = wc.pureVTbl;
9814 for(d = c.derivatives.first; d; d = d.next)
9816 UnapplySkin(d.data);
9820 void CheckFontIntegrity(Window window)
9825 if(window.usedFont && window.usedFont.font == 0xecececec)
9827 FontResource uf = window.usedFont;
9828 char * className = window._class.name;
9829 char * text = window.text;
9832 for(c = window.firstChild; c; c = c.next)
9833 CheckFontIntegrity(c);
9837 public class ControllableWindow : Window
9839 /*WindowController controller;
9840 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9841 ~ControllableWindow() { delete controller; }*/
9844 class WindowControllerInterface : ControllableWindow
9846 bool OnKeyDown(Key key, unichar ch)
9848 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9850 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9854 bool OnKeyUp(Key key, unichar ch)
9856 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9858 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9862 bool OnKeyHit(Key key, unichar ch)
9864 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9866 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9870 bool OnMouseMove(int x, int y, Modifiers mods)
9872 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9874 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9878 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9880 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9882 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9886 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9888 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9890 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9894 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9896 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9898 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9902 bool OnRightButtonDown(int x, int y, Modifiers mods)
9904 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9906 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9910 bool OnRightButtonUp(int x, int y, Modifiers mods)
9912 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9914 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9918 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9920 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9922 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9926 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9928 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9930 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9934 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9936 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9938 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9942 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9944 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9946 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9950 void OnResize(int width, int height)
9952 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9953 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9956 void OnRedraw(Surface surface)
9958 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9959 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9964 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9966 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9970 bool OnLoadGraphics()
9972 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9974 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9978 void OnUnloadGraphics()
9980 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9981 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9985 public class WindowController<class V>
9988 property Window window
9992 uint size = class(Window).vTblSize;
9995 windowVTbl = new void *[size];
9996 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9997 if(value._vTbl == value._class._vTbl)
9999 value._vTbl = new void *[value._class.vTblSize];
10000 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
10004 for(c = 0; c < size; c++)
10006 void * function = class(WindowControllerInterface)._vTbl[c];
10007 if(function != DefaultFunction)
10008 value._vTbl[c] = function;
10010 value._vTbl[c] = windowVTbl[c];
10015 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
10018 get { return window; }
10020 property V controlled
10022 set { controlled = value; }
10023 get { return controlled; }
10025 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
10026 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
10027 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
10028 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
10029 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
10030 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
10031 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10032 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
10033 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
10034 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10035 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
10036 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
10037 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
10038 virtual void V::OnResize(WindowController controller, int width, int height);
10039 virtual void V::OnRedraw(WindowController controller, Surface surface);
10040 virtual bool V::OnCreate(WindowController controller);
10041 virtual bool V::OnLoadGraphics(WindowController controller);
10042 virtual void V::OnUnloadGraphics(WindowController controller);
10045 int (** windowVTbl)();
10049 ~WindowController()