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
42 define skinMenuHeight = 25;
43 define statusBarHeight = 18;
45 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
47 public enum DialogResult { cancel, yes, no, ok };
49 public class MouseButtons
52 bool left:1, right:1, middle:1;
55 public struct SizeAnchor
58 bool isClientW, isClientH;
63 #define SNAPDOWN(x, d) \
66 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
69 #define SNAPUP(x, d) \
72 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
75 /*static */define MAX_DIRTY_BACK = 10;
77 /////////////////////////////////////////////////////////////////////////////
78 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
79 /////////////////////////////////////////////////////////////////////////////
81 #define ACCESS_ITEM(l, id) \
84 #define FASTLIST_LOOP(l, v) \
85 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
87 #define FASTLIST_LOOPN(l, v, n) \
88 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
91 #define ACCESS_ITEM(l, id) \
92 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
94 #define FASTLIST_LOOP(l, v) \
95 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
97 #define FASTLIST_LOOPN(l, v, n) \
98 for( v = (void *)ACCESS_ITEM((l), (l).first), \
99 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
100 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
103 private class FastItem : struct
108 private struct FastList
113 int count, size, itemSize;
120 first = last = free = -1;
128 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
131 FastItem Add(uint itemSize)
134 if(free == -1 || !size)
141 newSize = (size + (size >> 1));
142 items = (FastItem)renew items byte[newSize * itemSize];
147 this.itemSize = itemSize;
148 items = (FastItem)new byte[newSize * itemSize];
151 for(c = size; c<newSize-1; c++)
153 ACCESS_ITEM(this, c).prev = -1;
154 ACCESS_ITEM(this, c).next = c+1;
156 ACCESS_ITEM(this, c).prev = -1;
157 ACCESS_ITEM(this, c).next = -1;
161 item = ACCESS_ITEM(this, free);
164 ACCESS_ITEM(this, item.prev).next = free;
174 void Delete(FastItem item)
177 ACCESS_ITEM(this, item.prev).next = item.next;
179 ACCESS_ITEM(this, item.next).prev = item.prev;
181 if(ACCESS_ITEM(this, first) == item)
183 if(ACCESS_ITEM(this, last) == item)
188 free = ((byte *)item - (byte *)items) / itemSize;
196 free = first = last = -1;
200 private class BoxItem : Item //FastItem
205 public /*private */struct Extent : OldList //FastList
214 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
215 Add(BoxItem { box = box });
218 void Copy(Extent source)
224 //FASTLIST_LOOP(source, extentBox)
225 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
226 AddBox(extentBox.box);
229 void IntersectBox(Box box)
231 // Clip all boxes of extent against inside of the new box
232 BoxItem extentBox, next;
234 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
235 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
237 next = (BoxItem)extentBox.next;
238 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
239 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
240 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
241 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
242 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
247 void ExcludeBox(Box box, Extent temp)
254 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
256 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
257 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
260 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
264 extentBox.box.left, extentBox.box.top,
265 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
271 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
275 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
276 extentBox.box.right, extentBox.box.bottom
282 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
285 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
289 extentBox.box.left, Max(extentBox.box.top, box.top),
290 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
296 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
300 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
301 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
309 AddBox(extentBox.box);
315 void UnionBox(Box box, Extent temp)
317 BoxItem extentBox, next;
319 // First pass: check if this box is not already covered by one of the extent's box
320 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
322 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
323 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
330 // Second pass: only keep boxes not completely covered in the new box
331 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
333 next = (BoxItem)extentBox.next;
334 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
335 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
339 // Add the exclusion to the extent
340 ExcludeBox(box, temp);
343 if(box.bottom >= box.top && box.right >= box.left)
345 // Optimization: if the resulting boxes touch, add them smarter
346 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
348 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
350 if(Abs(box.right - extentBox.box.left) <= 1)
352 extentBox.box.left = box.left;
355 else if(Abs(box.left - extentBox.box.right) <= 1)
357 extentBox.box.right = box.right;
361 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
363 if(Abs(box.bottom - extentBox.box.top) <= 1)
365 extentBox.box.top = box.top;
368 else if(Abs(box.top - extentBox.box.bottom) <= 1)
370 extentBox.box.bottom = box.bottom;
382 void Union(Extent b, Extent temp)
386 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
387 UnionBox(extentBox.box, temp);
390 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
397 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
400 temp2.IntersectBox(extentBox.box);
407 void Exclusion(Extent b, Extent temp)
410 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
411 ExcludeBox(extentBox.box, temp);
414 void Offset(int x, int y)
417 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
419 extentBox.box.left += x;
420 extentBox.box.top += y;
421 extentBox.box.right += x;
422 extentBox.box.bottom += y;
427 private define MINIMIZED_WIDTH = 160;
428 private define CASCADE_SPACE = 16;
430 // namespace Windows;
432 private class ScrollFlags
434 bool snapX:1, snapY:1, dontHide:1;
437 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
439 class WindowBits : BorderBits
441 BorderBits borderBits:6:0;
442 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
443 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
444 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
447 public enum BorderStyle : BorderBits
450 contour = BorderBits { contour = true },
451 fixed = BorderBits { fixed = true } | contour,
452 sizable = BorderBits { sizable = true } | fixed,
453 thin = BorderBits { fixed = true, thin = true } | contour,
454 sizableThin = BorderBits { sizable = true } | thin,
455 deep = BorderBits { deep = true },
456 bevel = BorderBits { bevel = true },
457 sizableDeep = sizable|deep,
458 sizableBevel = sizable|bevel,
459 fixedDeep = fixed|deep,
460 fixedBevel = fixed|bevel,
461 deepContour = deep|contour
464 public enum CreationActivationOption
466 activate, flash, doNothing
469 public enum WindowState { normal, minimized, maximized };
471 private class ResPtr : struct
478 private class HotKeySlot : struct
480 HotKeySlot prev, next;
488 class_data char * icon;
490 class_default_property caption;
491 // class_initialize GuiApplication::Initialize;
492 class_designer FormDesigner;
493 class_property char * icon
495 set { class_data(icon) = value; }
496 get { return class_data(icon); }
501 if(guiApp) guiApp.Initialize(true);
503 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
505 if(_vTbl == ((subclass(Window))_class).pureVTbl)
507 _vTbl = _class._vTbl;
509 else if(_vTbl != _class._vTbl)
512 for(m = 0; m < _class.vTblSize; m++)
514 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
515 _vTbl[m] = _class._vTbl[m];
520 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
521 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
522 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
523 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
527 // caption = CopyString(class.name);
529 children.offset = (byte*)&prev - (byte*)this;
530 childrenOrder.circ = true;
531 childrenCycle.circ = true;
533 maxSize = Size { MAXINT, MAXINT };
537 //style.isActiveClient = true;
540 modifyVirtArea = true;
541 manageDisplay = true;
542 nativeDecorations = true;
544 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
545 sbStep.x = sbStep.y = 8;
547 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
549 cursor = guiApp.GetCursor(arrow);
550 property::parent = guiApp.desktop;
562 stopwatching(parent, font);
563 if(parent.activeChild == this)
564 parent.activeChild = null;
565 if(parent.activeClient == this)
566 parent.activeClient = null;
571 // Prevent destructor from being called again...
577 /////////////////////////////////
580 OldLink slave = master.slaves.FindLink(this);
581 master.slaves.Delete(slave);
588 parent.childrenCycle.Remove(cycle);
590 parent.childrenOrder.Remove(order);
591 parent.children.Remove(this);
596 /////////////////////////////////
598 while(ptr = resources.first)
601 resources.Delete(ptr);
608 for(child = children.first; child; child = child.next)
610 // child.stopwatching(this, font);
612 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
613 // Don't want property here
614 *&child.parent = null;
617 while(slave = slaves.first)
619 // Don't want property here
620 *&((Window)slave.data).master = null;
621 slaves.Delete(slave);
624 // Because we do a decref in DestroyEx...
632 // Why was this commented?
633 //if(this != guiApp.desktop)
646 if(((subclass(Window))_class).pureVTbl)
648 if(_vTbl == _class._vTbl)
650 _vTbl = ((subclass(Window))_class).pureVTbl;
655 for(m = 0; m < _class.vTblSize; m++)
657 if(_vTbl[m] == _class._vTbl[m])
658 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
662 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
665 dirtyArea.Free(null);
666 renderArea.Free(null);
667 overRenderArea.Free(null);
668 clipExtent.Free(null);
669 scrollExtent.Free(null);
670 dirtyBack.Free(null);
674 tempExtents[0].Free(null);
675 tempExtents[1].Free(null);
676 tempExtents[2].Free(null);
677 tempExtents[3].Free(null);
682 //#if !defined(ECERE_VANILLA)
683 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
685 if(this == activeDesigner)
689 char * name = property::name;
690 return name ? name : "";
695 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
696 bool OnGetDataFromString(char * string)
698 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
701 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
702 this = designer.form;
703 else if(!strcmpi(string, "(Desktop)"))
704 this = activeDesigner;
706 return activeDesigner.FindObject(&this, string);
712 // --- Window updates system ---
714 // Setup a bitmap for Redrawing on client area of Window
715 Surface Redraw(Box box)
717 Surface surface = null;
719 Box clientArea = this.clientArea;
723 mox.left -= clientStart.x;
724 mox.top -= clientStart.y;
725 mox.right -= clientStart.x;
726 mox.bottom -= clientStart.y;
728 mox.Clip(clientArea);
729 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
731 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
733 int x = absPosition.x + clientStart.x;
734 int y = absPosition.y + clientStart.y;
735 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
737 x -= rootWindow.clientStart.x;
738 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
740 if(!guiApp.fullScreenMode || is3D)
742 x -= rootWindow.absPosition.x;
743 y -= rootWindow.absPosition.y;
747 x += rootWindow.parent.clientStart.x;
748 y += rootWindow.parent.clientStart.y;
750 mox.left += rootWindow.parent.clientStart.x;
751 mox.top += rootWindow.parent.clientStart.y;
752 mox.right += rootWindow.parent.clientStart.x;
753 mox.bottom += rootWindow.parent.clientStart.y;
758 surface = display.GetSurface(x, y, mox);
761 surface.width = clientSize.w;
762 surface.height = clientSize.h;
768 // Setup a bitmap for Redrawing on full Window
769 Surface RedrawFull(Box box)
771 Surface surface = null;
779 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
781 int x = absPosition.x;
782 int y = absPosition.y;
783 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
785 x -= rootWindow.clientStart.x;
786 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
788 if(!guiApp.fullScreenMode || is3D)
790 x -= rootWindow.absPosition.x;
791 y -= rootWindow.absPosition.y;
794 x += rootWindow.parent.clientStart.x;
795 y += rootWindow.parent.clientStart.y;
797 mox.left += rootWindow.parent.clientStart.x;
798 mox.top += rootWindow.parent.clientStart.y;
799 mox.right += rootWindow.parent.clientStart.x;
800 mox.bottom += rootWindow.parent.clientStart.y;
805 surface = display.GetSurface(x, y, mox);
808 surface.width = size.w;
809 surface.height = size.h;
815 void FigureCaption(char * caption)
817 Window activeClient = null;
821 strcpy(caption, this.caption);
822 if(style.isDocument || fileName)
824 if(caption[0]) strcat(caption, " - ");
826 strcat(caption, fileName);
830 sprintf(title, "Untitled %d", documentID);
831 strcat(caption, title);
834 strcat(caption, " *");
839 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
841 if(activeClient && activeClient.state == maximized)
843 if(activeClient.caption)
845 if(caption[0]) strcat(caption, " - ");
846 strcat(caption, activeClient.caption);
848 if(activeClient.style.isDocument || activeClient.fileName)
850 if(caption[0]) strcat(caption, " - ");
851 strcat(caption, "[");
852 if(activeClient.fileName)
853 strcat(caption, activeClient.fileName);
857 sprintf(title, "Untitled %d", activeClient.documentID);
858 strcat(caption, title);
860 if(activeClient.modifiedDocument)
861 strcat(caption, " *");
862 strcat(caption, "]");
867 // Code for returning dirty from ScrollDisplay:
869 for(d = 0; d<scrollExtent.count; d++)
871 Box * box = &scrollExtent.boxes[d];
877 Min(box.right, box.left-scroll.x),box.bottom
879 dirtyArea.UnionBox(update);
885 Max(box.left, box.right-scroll.x), box.top,
886 box.right, box.bottom
888 dirtyArea.UnionBox(update);
896 box.right, Min(box.bottom, box.top-scroll.y),
898 dirtyArea.UnionBox(update);
904 box.left, Max(box.top, box.bottom-scroll.y),
905 box.right, box.bottom
907 dirtyArea.UnionBox(update);
912 void UpdateDecorations(void)
914 // TODO: *** TEMPORARY HACK ***
921 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
923 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
925 Update({ -clientStart.x,0, -1, clientSize.h-1 });
927 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
930 // Returns w & h for Position
931 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
933 Window parent = this.parent ? this.parent : guiApp.desktop;
934 int vpw = parent ? parent.clientSize.w : 0;
935 int vph = parent ? parent.clientSize.h : 0;
936 int pw = parent ? parent.clientSize.w : 0;
937 int ph = parent ? parent.clientSize.h : 0;
938 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
939 int x = anchor.left.distance, y = anchor.top.distance;
941 MinMaxValue ew = 0, eh = 0;
943 float cascadeW, cascadeH;
945 int tilingW, tilingH, tilingSplit, tilingLastH;
946 int addX = 0, addY = 0;
948 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
950 Window masterWindow = this;
951 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
954 if(master == guiApp.desktop)
955 masterWindow = guiApp.desktop.activeChild;
957 masterWindow = master.rootWindow;
958 if(!masterWindow) masterWindow = this;
960 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
961 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
964 pw = vpw = box.right - box.left + 1;
966 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
969 ph = vph = box.bottom - box.top + 1;
985 vpw = pw = parent.size.w;
986 vph = ph = parent.size.h;
988 else if(!style.fixed /*|| style.isDocument*/)
990 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
991 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
993 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
996 Desktop3D_FixSize(&pw, &ph);
997 Desktop3D_FixSize(&vpw, &vph);
1000 if(pw < skinMinSize.w) pw = skinMinSize.w;
1001 if(ph < skinMinSize.h) ph = skinMinSize.h;
1002 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1003 if(vph < skinMinSize.h) vph = skinMinSize.h;
1005 // TODO: Must fix what we're snapping
1008 if(anchor.left.type)
1010 SNAPUP(x, textCellW);
1012 else if(anchor.right.type)
1014 SNAPDOWN(x, textCellW);
1019 SNAPUP(y, textCellH);
1021 else if(anchor.bottom.type)
1023 SNAPDOWN(y, textCellH);
1027 // This is required to get proper initial decoration size using native decorations on Windows
1028 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1029 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1030 GetDecorationsSize(&ew, &eh);
1032 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1034 if(parent.sbv && !parent.sbv.style.hidden)
1035 pw += guiApp.currentSkin.VerticalSBW();
1036 if(parent.sbh && !parent.sbh.style.hidden)
1037 ph += guiApp.currentSkin.HorizontalSBH();
1039 if(anchor.left.type == cascade)
1041 w = (int)(pw * 0.80);
1042 h = (int)(ph * 0.80);
1044 else if(anchor.left.type >= vTiled)
1049 numTiling = parent.numPositions - parent.numIcons;
1050 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1051 if(anchor.left.type == vTiled)
1053 tilingH = (int)sqrt(numTiling);
1054 tilingW = numTiling / tilingH;
1058 tilingW = (int)sqrt(numTiling);
1059 tilingH = numTiling / tilingW;
1062 leftOver = numTiling - tilingH * tilingW;
1065 tilingSplit = (tilingW - leftOver) * tilingH;
1066 tilingLastH = tilingH+1;
1069 tilingSplit = numTiling;
1071 if(positionID >= tilingSplit)
1073 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1074 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1075 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1076 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1080 x = pw * (positionID / tilingH) / tilingW;
1081 y = ph * (positionID % tilingH) / tilingH;
1082 x2 = pw * (positionID / tilingH + 1) / tilingW;
1083 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1087 SNAPDOWN(x, textCellW);
1088 SNAPDOWN(y, textCellH);
1089 SNAPDOWN(x2, textCellW);
1090 SNAPDOWN(y2, textCellH);
1098 if(sizeAnchor.isClientW) w += ew;
1099 if(sizeAnchor.isClientH) h += eh;
1101 if(anchor.left.type == offset)
1102 x = anchor.left.distance;
1103 else if(anchor.left.type == relative)
1104 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1105 else if(anchor.right.type == relative)
1106 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1107 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1108 else if(anchor.right.type == offset)
1109 ex = vpw - anchor.right.distance;
1111 if(anchor.top.type == offset)
1112 y = anchor.top.distance;
1113 else if(anchor.top.type == relative)
1114 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1115 else if(anchor.bottom.type == relative)
1116 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1117 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1118 else if(anchor.bottom.type == offset)
1119 ey = vph - anchor.bottom.distance;
1121 if(anchor.left.type && anchor.right.type)
1123 switch(anchor.right.type)
1126 ex = pw * (1.0f-anchor.right.percent);
1127 w = Max((int)(ex + 0.5) - x, 0);
1130 ex = vpw - anchor.right.distance;
1131 w = Max((int)(ex + 0.5) - x, 0);
1135 if(anchor.top.type && anchor.bottom.type)
1137 switch(anchor.bottom.type)
1140 ey = ph * (1.0f-anchor.bottom.percent);
1141 h = Max((int)(ey + 0.5) - y, 0);
1144 ey = vph - anchor.bottom.distance;
1145 h = Max((int)(ey + 0.5) - y, 0);
1154 if(state == normal /*|| state == Hidden*/)
1156 bool addSbV = false, addSbH = false;
1158 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1159 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1161 w = Max(w, minSize.w);
1162 h = Max(h, minSize.h);
1163 w = Min(w, maxSize.w);
1164 h = Min(h, maxSize.h);
1166 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1168 if(w) w -= guiApp.currentSkin.VerticalSBW();
1171 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1173 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1177 if(!OnResizing(&w, &h))
1183 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1184 w += guiApp.currentSkin.VerticalSBW();
1185 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1186 h += guiApp.currentSkin.HorizontalSBH();
1188 w = Max(w, skinMinSize.w);
1189 h = Max(h, skinMinSize.h);
1202 SNAPDOWN(w, textCellW);
1203 SNAPDOWN(h, textCellH);
1206 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1208 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1211 (pw - w) / CASCADE_SPACE,
1212 (ph - h) / CASCADE_SPACE);
1218 cascW = (pw - w) / (numCascade-1);
1219 cascH = (ph - h) / (numCascade-1);
1220 SNAPDOWN(cascW, textCellW);
1221 SNAPDOWN(cascH, textCellH);
1222 cascadeW = (float)cascW;
1223 cascadeH = (float)cascH;
1227 numCascade = Max(numCascade, 2);
1228 cascadeW = (float)(pw - w) / (numCascade-1);
1229 cascadeH = (float)(ph - h) / (numCascade-1);
1232 x = (int)((positionID % numCascade) * cascadeW);
1233 y = (int)((positionID % numCascade) * cascadeH);
1235 else if(anchor.left.type < vTiled)
1237 if(!anchor.left.type || anchor.horz.type == middleRelative)
1239 if(!anchor.right.type)
1241 if(anchor.horz.type == middleRelative)
1242 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1244 x = vpw / 2 + anchor.horz.distance - w / 2;
1250 // case A_EDGE: x = x - w; break;
1252 if(!anchor.top.type || anchor.vert.type == middleRelative)
1254 if(!anchor.bottom.type)
1256 if(anchor.vert.type == middleRelative)
1257 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1259 y = vph / 2 + anchor.vert.distance - h / 2;
1265 // case A_EDGE: y = y - h; break;
1268 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1276 SNAPDOWN(x, textCellW);
1277 SNAPDOWN(y, textCellH);
1289 if(anchored && style.fixed && style.isActiveClient)
1294 void UpdateCaret(bool forceUpdate, bool erase)
1296 static Window lastWindow = null;
1297 static int caretX, caretY, caretSize;
1299 if(guiApp && guiApp.caretOwner == this)
1301 int x = caretPos.x - scroll.x;
1302 int y = caretPos.y - scroll.y;
1304 if((erase || this.caretSize) &&
1305 x >= clientArea.left && x <= clientArea.right &&
1306 y >= clientArea.top && y <= clientArea.bottom)
1310 guiApp.interfaceDriver.SetCaret(
1311 x + absPosition.x + clientStart.x,
1312 y + absPosition.y + clientStart.y, this.caretSize);
1313 guiApp.caretEnabled = true;
1315 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1319 if(lastWindow != this)
1321 updateBox.left = x + 1;
1323 updateBox.right = x + 2;
1324 updateBox.bottom = y + this.caretSize - 1;
1328 updateBox.left = Min(x + 1, caretX + 1);
1329 updateBox.top = Min(y, caretY);
1330 updateBox.right = Max(x + 2, caretX + 2);
1331 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1334 guiApp.caretOwner.Update(updateBox);
1341 caretSize = this.caretSize;
1347 guiApp.interfaceDriver.SetCaret(0,0,0);
1348 guiApp.caretEnabled = false;
1354 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1359 scrolledPos.x = position.x = x;
1360 scrolledPos.y = position.y = y;
1362 clientSize.w = size.w = w;
1363 clientSize.h = size.h = h;
1365 if(parent && !style.nonClient)
1367 //if(!style.fixed || style.isDocument)
1369 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1370 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1374 clientStart.x = clientStart.y = 0;
1376 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1378 //if(!activeClient || activeClient.state != maximized)
1379 if(!noAutoScrollArea)
1381 // Check if scroll area must be modified
1382 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1384 bool foundChild = false;
1386 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1387 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1388 for(child = children.first; child; child = child.next)
1390 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1391 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1393 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1394 w = Max(w, child.position.x + child.size.w);
1395 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1396 w = Max(w, Max(child.position.x, 0) + child.size.w);
1397 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1398 h = Max(h, child.position.y + child.size.h);
1399 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1400 h = Max(h, Max(child.position.y, 0) + child.size.h);
1405 if(foundChild && (w > cw || h > ch))
1407 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1409 int stepX = sbStep.x, stepY = sbStep.y;
1410 // Needed to make snapped down position match the skin's check of client area
1411 // against realvirtual
1414 SNAPDOWN(stepX, textCellW);
1415 SNAPDOWN(stepY, textCellH);
1416 stepX = Max(stepX, textCellW);
1417 stepY = Max(stepY, textCellH);
1419 if(scrollFlags.snapX)
1421 if(scrollFlags.snapY)
1424 reqScrollArea.w = w;
1425 reqScrollArea.h = h;
1428 else if(reqScrollArea.w || reqScrollArea.h)
1430 reqScrollArea.w = 0;
1431 reqScrollArea.h = 0;
1432 SetScrollPosition(0,0);
1437 // Automatic MDI Client Scrolling Area Adjustment
1438 if(parent && !parent.noAutoScrollArea)
1440 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1441 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1443 Window parent = this.parent;
1444 int w = parent.reqScrollArea.w;
1445 int h = parent.reqScrollArea.h;
1447 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1448 w = Max(w, position.x + size.w);
1449 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1450 w = Max(w, Max(position.x, 0) + size.w);
1451 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1452 h = Max(h, position.y + size.h);
1453 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1454 h = Max(h, Max(position.y, 0) + size.h);
1456 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1457 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1459 /*bool resize = false;
1460 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1461 // Needed to make snapped down position match the skin's check of client area
1462 // against realvirtual
1465 SNAPDOWN(stepX, textCellW);
1466 SNAPDOWN(stepY, textCellH);
1467 stepX = Max(stepX, textCellW);
1468 stepY = Max(stepY, textCellH);
1470 if(parent.scrollFlags.snapX)
1472 if(parent.scrollFlags.snapY)
1474 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1476 parent.reqScrollArea.w = w;
1477 parent.reqScrollArea.h = h;*/
1479 // parent.UpdateScrollBars(true, true);
1480 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1481 false, true, true, true, false, false);
1486 GetRidOfVirtualArea();
1490 UpdateScrollBars(modifyThisArea, false);
1491 else if(guiApp.currentSkin)
1494 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1496 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1497 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1498 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1499 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1502 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1503 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1505 absPosition = scrolledPos;
1506 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1507 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1509 if(this != guiApp.desktop && parent)
1511 absPosition.x += parent.absPosition.x;
1512 absPosition.y += parent.absPosition.y;
1513 if(!style.nonClient && this != guiApp.desktop)
1515 absPosition.x += parent.clientStart.x;
1516 absPosition.y += parent.clientStart.y;
1520 box = Box { 0, 0, size.w - 1, size.h - 1 };
1525 // Clip against parent's client area
1526 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1528 // Compute client area in this window coordinate system
1529 clientArea.left = 0;
1531 clientArea.right = clientSize.w - 1;
1532 clientArea.bottom = clientSize.h - 1;
1534 // Clip against parent's client area
1536 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1540 //absPosition.x -= parent.clientStart.x;
1541 //absPosition.y -= parent.clientStart.y;
1544 // Adjust all children
1545 for(child = children.first; child; child = child.next)
1546 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1548 UpdateCaret(false, false);
1551 void GetRidOfVirtualArea(void)
1553 if(parent && !parent.destroyed && style.fixed &&
1554 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1555 parent.reqScrollArea.w && parent.reqScrollArea.h)
1557 if(!parent.noAutoScrollArea)
1561 for(child = children.first; child; child = child.next)
1563 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1565 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1566 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1575 Window parent = this.parent;
1577 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1578 false, true, true, true, false, false);
1580 parent.SetScrollArea(0,0,true);
1581 parent.SetScrollPosition(0,0);
1587 public void ExternalPosition(int x, int y, int w, int h)
1589 Position(x, y, w, h, false, true, true, true, false, false);
1592 // (w, h): Full window size
1593 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1595 bool result = false;
1596 int oldCW = clientSize.w, oldCH = clientSize.h;
1597 bool clientResized, windowResized, windowMoved;
1599 bool realResized = size.w != w || size.h != h;
1601 // TOCHECK: This wasn't in ecere.dll
1602 //if(!parent) return true;
1603 if(destroyed) return false;
1605 windowMoved = position.x != x || position.y != y || force;
1607 // windowResized = realResized || force;
1608 windowResized = size.w != w || size.h != h || force;
1610 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1616 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1617 scrolledPos.x - parent.clientStart.x + this.box.right,
1618 scrolledPos.y - parent.clientStart.y + this.box.bottom
1624 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1629 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1631 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1632 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1633 windowResized = true;
1635 if(display && rootWindow != this)
1638 if(guiApp && guiApp.windowMoving)
1640 if(guiApp.windowMoving.style.nonClient)
1641 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1643 guiApp.windowMoving.parent.SetMouseRangeToClient();
1653 // Buttons bitmap resources crash if we do this while switching mode
1654 if(!guiApp || !guiApp.modeSwitching)
1657 // Process Anchored Children
1661 for(child = children.first; child; child = child.next)
1664 ((child.stateAnchor.left.type != offset ||
1665 child.stateAnchor.top.type != offset ||
1666 child.stateAnchor.right.type != none ||
1667 child.stateAnchor.bottom.type != none) ||
1668 child.state == maximized || child.state == minimized))
1670 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1672 // child.Position(x, y, w, h, false, true, true, true, false);
1673 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1674 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1680 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1681 //if(updateScrollBars)
1683 OnResize(clientSize.w, clientSize.h);
1685 if((clientResized || windowMoved) && created)
1686 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1688 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1690 Window master = guiApp.interimWindow.master;
1691 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1694 if(rootWindow == this && !is3D)
1698 x -= guiApp.desktop.absPosition.x;
1699 y -= guiApp.desktop.absPosition.y;
1701 //guiApp.Log("Position %s\n", caption);
1704 if(windowResized || windowMoved)
1705 if(display && !display.flags.memBackBuffer && changeRootWindow)
1706 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1708 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1709 for(child = parent.children.first; child && child != this; child = child.next)
1710 if(child.rootWindow)
1711 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1716 if(windowMoved || windowResized)
1718 display.Lock(true /*false*/);
1721 display.Position(absPosition.x, absPosition.y);
1722 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1725 // result = realResized ? display.Resize(size.w, size.h) : true;
1726 if(nativeDecorations && rootWindow.windowHandle)
1728 int w = clientSize.w, h = clientSize.h;
1729 if(hasMenuBar) h += skinMenuHeight;
1730 if(hasStatusBar) h += statusBarHeight;
1731 if(sbv && sbv.visible) w += sbv.size.w;
1732 if(sbh && sbh.visible) h += sbh.size.h;
1733 result = manageDisplay ? display.Resize(w, h) : true;
1736 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1740 else if(clientResized)
1742 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1745 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1749 if(windowMoved || windowResized)
1754 if(guiApp.driver && changeRootWindow && windowHandle)
1756 if(windowResized || windowMoved)
1757 if(!display || display.flags.memBackBuffer)
1758 guiApp.interfaceDriver.PositionRootWindow(this,
1759 x, y, w, h, windowMoved, windowResized);
1760 guiApp.interfaceDriver.UpdateRootWindow(this);
1762 for(child = children.first; child; child = child.next)
1764 if(child.is3D && child.created)
1766 // Copy Display Content
1767 child.display.displaySystem = display.displaySystem;
1768 child.display.window = display.window;
1769 child.display.current = display.current;
1770 child.display.width = display.width;
1771 child.display.height = display.height;
1772 child.display.driverData = display.driverData;
1773 child.display.mutex = null;
1784 void UpdateScrollBars(bool flag, bool fullThing)
1787 bool resizeH = false, resizeV = false;
1788 bool scrolled = false;
1789 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1790 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1792 if(destroyed) return;
1793 if(guiApp.currentSkin)
1795 MinMaxValue cw = 0, ch = 0;
1796 bool sbvVisible, sbhVisible;
1798 int positionH, positionV;
1800 // First get client area with no respect to scroll bars
1805 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1807 if(scrollFlags.dontHide)
1810 cw -= guiApp.currentSkin.VerticalSBW();
1812 ch -= guiApp.currentSkin.HorizontalSBH();
1814 // Update the scrollbar visibility
1820 sbh.disabled = rangeH <= 1;
1821 if(sbh.style.hidden)
1831 sbv.disabled = rangeV <= 1;
1832 if(sbv.style.hidden)
1840 int oldHRange = sbh ? sbh.range : 0;
1841 int oldVRange = sbv ? sbv.range : 0;
1842 // Then start off with horizontal scrollbar range
1845 positionH = sbh.thumbPosition;
1852 SBSetTotal(sbh, rvw);
1855 ch -= guiApp.currentSkin.HorizontalSBH();
1858 // Do the same for vertical scrollbar
1861 positionV = sbv.thumbPosition;
1867 SBSetTotal(sbv, rvh);
1871 cw -= guiApp.currentSkin.VerticalSBW();
1872 // Maybe we need to set the range on the horizontal scrollbar again
1880 SBSetTotal(sbh, rvw);
1881 //sbh.Action(setRange, positionH, 0);
1882 if(rangeH <= 1 && sbh.range > 1)
1884 ch -= guiApp.currentSkin.HorizontalSBH();
1890 SBSetTotal(sbv, rvh);
1892 //sbv.Action(setRange, positionV, 0);
1897 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1898 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1901 // Update the scrollbar visibility
1902 if(!scrollFlags.dontHide)
1904 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1908 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1915 if(guiApp.currentSkin)
1922 sbhVisible = sbh.style.hidden ? true : false;
1924 sbvVisible = sbv.style.hidden ? true : false;
1926 // Do our resize here
1927 if(flag && (resizeH || resizeV) && fullThing)
1929 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1934 OnResize(clientSize.w, clientSize.h);
1940 sbh.visible = sbhVisible;
1942 sbv.visible = sbvVisible;
1944 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1945 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1948 sbh.pageStep = clientSize.w;
1950 sbv.pageStep = clientSize.h;
1952 // Notify doesn't handle setRange anymore... process it here
1955 int positionH = sbh.thumbPosition;
1956 if(scroll.x != positionH)
1958 OnHScroll(setRange, positionH, 0);
1962 SNAPDOWN(positionH, textCellW);
1963 scroll.x = positionH;
1969 int seen = clientSize.w, total = reqScrollArea.w;
1972 if(scrollFlags.snapX)
1973 SNAPDOWN(seen, sbStep.x);
1975 if(!total) total = seen;
1976 range = total - seen + 1;
1978 range = Max(range, 1);
1980 if(x >= range) x = range - 1;
1982 if(scrollFlags.snapX)
1983 SNAPUP(x, sbStep.x);
1987 OnHScroll(setRange, x, 0);
1992 SNAPDOWN(x, textCellW);
1998 int positionV = sbv.thumbPosition;
1999 if(scroll.y != positionV)
2001 OnVScroll(setRange, positionV, 0);
2005 SNAPDOWN(positionV, textCellH);
2006 scroll.y = positionV;
2012 int seen = clientSize.h, total = reqScrollArea.h;
2015 if(scrollFlags.snapY)
2016 SNAPDOWN(seen, sbStep.y);
2018 if(!total) total = seen;
2019 range = total - seen + 1;
2020 range = Max(range, 1);
2022 if(y >= range) y = range - 1;
2024 if(scrollFlags.snapY)
2025 SNAPUP(y, sbStep.y);
2029 OnVScroll(setRange, y, 0);
2034 SNAPDOWN(y, textCellH);
2040 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2043 for(child = children.first; child; child = child.next)
2045 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2048 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2049 child.Position(x, y, w, h, false, true, false, true, false, false);
2056 // Process Scrollbars
2058 if(sbh) // && !sbh.style.hidden
2060 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2061 // Need to set the range again (should improve...) since the scrollbars didn't have
2062 // the right size when UpdateScrollArea set the range on it
2065 sbh.seen = clientSize.w;
2069 if(sbv) // && !sbv.state.hidden
2071 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2072 // Need to set the range again (should improve...) since the scrollbars didn't have
2073 // the right size when UpdateScrollArea set the range on it
2076 sbv.seen = clientSize.h;
2081 // TESTING THIS LOWER
2082 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2085 for(child = children.first; child; child = child.next)
2087 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2090 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2091 child.Position(x, y, w, h, false, true, false, true, false, false);
2097 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2099 SetState(maximized, false, mods);
2103 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2105 SetState(normal, false, mods);
2109 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2111 SetState(minimized, false, mods);
2112 parent.CycleChildren(false, true, false, true);
2116 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2119 // Scroll bar notifications
2120 if(action != setRange)
2122 bool changed = false;
2126 if(scroll.x != position)
2128 OnHScroll(action, position, keyFlags);
2133 SNAPDOWN(position, textCellW);
2135 scroll.x = position;
2139 if(scroll.y != position)
2141 OnVScroll(action, position, keyFlags);
2146 SNAPDOWN(position, textCellH);
2148 scroll.y = position;
2152 bool childMove = false;
2153 for(child = children.first; child; child = child.next)
2155 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2158 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2159 child.Position(x, y, w, h, false, true, false, true, false, false);
2163 // Testing this patch out to solve MDI workspace redraw bugs
2164 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2165 // Scroll offsets to blame?
2169 UpdateCaret(false, false);
2173 // Testing this patch out to solve MDI workspace redraw bugs
2174 for(child = children.first; child; child = child.next)
2176 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2185 Window GetParentMenuBar()
2187 Window result = this;
2188 bool notActiveClient = false;
2189 Window menuBarParent;
2190 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2192 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2193 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2194 notActiveClient = true;
2199 void CreateSystemChildren(void)
2201 Window parent = this;
2202 bool scrollBarChanged = false;
2203 bool hasClose = false, hasMaxMin = false;
2204 Point scroll = this.scroll;
2206 if(state == maximized)
2207 parent = GetParentMenuBar();
2211 if(style.hasClose) hasClose = true;
2212 if(style.hasMaximize || style.hasMinimize)
2219 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2221 sysButtons[2].Destroy(0);
2222 sysButtons[2] = null;
2224 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2226 sysButtons[1].Destroy(0);
2227 sysButtons[1] = null;
2229 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2231 sysButtons[0].Destroy(0);
2232 sysButtons[0] = null;
2235 if(hasClose && parent)
2242 parent, master = this,
2243 inactive = true, nonClient = true, visible = false;
2245 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2251 if(this.parent == guiApp.desktop)
2252 sysButtons[2].hotKey = altF4;
2253 else if(style.isActiveClient)
2254 sysButtons[2].hotKey = ctrlF4;
2255 sysButtons[2].Create();
2258 sysButtons[2].symbol = 'X';
2259 sysButtons[2].disabled = !style.hasClose;
2262 if(hasMaxMin && parent)
2266 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2267 if(state == maximized)
2270 method = RestoreButtonClicked;
2276 method = MaximizeButtonClicked;
2284 parent, master = this,
2285 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2287 sysButtons[1].Create();
2289 sysButtons[1].NotifyClicked = method;
2291 sysButtons[1].symbol = symbol;
2292 sysButtons[1].disabled = !style.hasMaximize;
2295 if(hasMaxMin && parent)
2299 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2300 if (state == minimized)
2303 method = RestoreButtonClicked;
2309 method = MinimizeButtonClicked;
2317 parent, master = this,
2318 hotKey = altM, inactive = true, nonClient = true, visible = false
2320 sysButtons[0].Create();
2322 sysButtons[0].NotifyClicked = method;
2324 sysButtons[0].symbol = symbol;
2325 sysButtons[0].disabled = !style.hasMinimize;
2328 // Create the scrollbars
2329 if(style.hasHorzScroll && !sbh)
2335 direction = horizontal,
2339 snap = scrollFlags.snapX,
2340 NotifyScrolling = ScrollBarNotification
2343 scrollBarChanged = true;
2345 else if(sbh && !style.hasHorzScroll)
2351 if(style.hasVertScroll && !sbv)
2357 direction = vertical,
2361 snap = scrollFlags.snapY,
2362 NotifyScrolling = ScrollBarNotification
2365 scrollBarChanged = true;
2367 else if(sbv && !style.hasVertScroll)
2372 if(scrollBarChanged)
2374 SetScrollLineStep(sbStep.x, sbStep.y);
2375 UpdateScrollBars(true, true);
2379 if(scrollBarChanged)
2381 if(sbh) sbh.thumbPosition = scroll.x;
2382 if(sbv) sbv.thumbPosition = scroll.y;
2386 void UpdateCaption(void)
2388 if(rootWindow == this)
2391 FigureCaption(caption);
2392 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2394 UpdateDecorations();
2397 if(parent.activeClient == this) // Added this last check
2399 if(parent.rootWindow == parent)
2402 parent.FigureCaption(caption);
2403 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2406 parent.UpdateCaption();
2408 parent.UpdateDecorations();
2412 void UpdateActiveDocument(Window previous)
2414 Window activeClient = this.activeClient;
2415 Window activeChild = this.activeChild;
2422 activeClient.CreateSystemChildren();
2424 previous.CreateSystemChildren();
2436 // Build window list
2439 Menu windowMenu = menu.FindMenu("Window");
2444 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2447 Window document = cycle.data;
2448 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2450 char name[2048], caption[2048];
2451 document.FigureCaption(caption);
2452 sprintf(name, "%d %s", id+1, caption);
2453 windowMenu.AddDynamic(MenuItem
2455 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2456 NotifySelect = MenuWindowSelectWindow
2460 if(activeClient.cycle == cycle) break;
2465 if((!previous && activeClient) || !activeClient)
2471 item = menu.FindItem(MenuWindowCloseAll, 0);
2472 if(item) item.disabled = false;
2473 item = menu.FindItem(MenuWindowNext, 0);
2474 if(item) item.disabled = false;
2475 item = menu.FindItem(MenuWindowPrevious, 0);
2476 if(item) item.disabled = false;
2477 item = menu.FindItem(MenuWindowCascade, 0);
2478 if(item) item.disabled = false;
2479 item = menu.FindItem(MenuWindowTileHorz, 0);
2480 if(item) item.disabled = false;
2481 item = menu.FindItem(MenuWindowTileVert, 0);
2482 if(item) item.disabled = false;
2483 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2484 if(item) item.disabled = false;
2485 item = menu.FindItem(MenuWindowWindows, 0);
2486 if(item) item.disabled = false;
2489 item = menu.FindItem(MenuFileClose, 0);
2490 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2491 item = menu.FindItem(MenuFileSaveAll, 0);
2492 if(item) item.disabled = numDocuments < 1;
2494 if(activeClient && activeClient.menu && activeClient.state != minimized)
2498 //activeClient.menu.Clean(activeClient);
2499 menu.Merge(activeClient.menu, true, activeClient);
2503 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2506 menu.Merge(activeChild.menu, true, activeChild);
2509 // This is called again for a child window change, with same active client
2510 OnActivateClient(activeClient, previous);
2511 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2512 parent.UpdateActiveDocument(null);
2515 void _ShowDecorations(Box box, bool post)
2517 if(rootWindow == this && nativeDecorations) return;
2518 if(visible && this != guiApp.desktop)
2520 Surface surface = RedrawFull(box);
2524 FigureCaption(caption);
2527 ShowDecorations(captionFont.font,
2530 active, //parent.activeClient == this
2531 guiApp.windowMoving == this);
2533 PreShowDecorations(captionFont.font,
2536 active, //parent.activeClient == this
2537 guiApp.windowMoving == this);
2544 void UpdateExtent(Box refresh)
2546 Surface surface = null;
2548 if(!manageDisplay) { OnRedraw(null);return; }
2549 _ShowDecorations(refresh, false);
2551 surface = Redraw(refresh);
2552 // Opaque background: just fill before EW_REDRAW (clear?)
2555 surface.SetBackground(background);
2556 surface.SetForeground(foreground);
2557 surface.DrawingChar(' ');
2558 if(this == rootWindow)
2560 if(style.drawBehind || background.a)
2562 int a = background.a;
2563 // Premultiply alpha for clear color
2564 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2565 surface.Clear(colorBuffer);
2566 surface.SetBackground(background);
2569 else if(background.a)
2573 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2574 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2577 if(display.flags.alpha && background.a < 255 && background)
2579 surface.Area(0,0,clientSize.w, clientSize.h);
2580 /*if(style.clearDepthBuffer)
2581 surface.Clear(depthBuffer);*/
2583 else if(/*style.clearDepthBuffer || */background.a)
2585 int a = background.a;
2586 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2587 // Premultiply alpha for clear color
2588 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2589 surface.Clear(colorBuffer);
2590 surface.SetBackground(background);
2595 surface.TextFont(usedFont.font);
2596 surface.TextOpacity(false);
2600 // Draw the caret ...
2601 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2603 // surface.SetBackground(0xFFFFFF - background.color);
2604 surface.SetBackground(~background.color);
2606 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2607 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2613 void DrawOverChildren(Box refresh)
2615 Surface surface = Redraw(refresh);
2619 surface.DrawingChar(' ');
2620 surface.SetBackground(background);
2621 surface.SetForeground(foreground);
2623 surface.TextFont(usedFont.font);
2624 surface.TextOpacity(false);
2626 OnDrawOverChildren(surface);
2631 _ShowDecorations(refresh, true);
2634 void ComputeClipExtents(void)
2637 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2639 clipExtent.Copy(this.clipExtent);
2641 for(child = children.last; child; child = child.prev)
2643 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2645 bool opaque = child.IsOpaque(); // TODO: acess background directly
2646 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2648 child.clipExtent.Copy(clipExtent);
2649 child.clipExtent.Offset(-dx, -dy);
2650 child.clipExtent.IntersectBox(child.box);
2652 child.ComputeClipExtents();
2654 if(opaque && !child.style.nonClient)
2656 // Adjust the box for the parent:
2657 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2658 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2663 // ??? Only do this for overlapped window or if parent has with clip children flag
2665 // Do this if window has clip children flag on (default false?)
2666 // this.clipExtent = clipExtent;
2668 clipExtent.Free(null);
2671 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2673 bool opaque = IsOpaque();
2675 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2676 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2678 offsetX -= rootWindow.clientStart.x;
2679 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2683 for(child = children.last; child; child = child.prev)
2685 ColorAlpha background = *(ColorAlpha *)&child.background;
2686 bool opaque = child.IsOpaque();
2687 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2691 // Adjust renderArea to the root window level
2692 Extent * renderArea = &rootWindow.tempExtents[1];
2694 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2695 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2697 offsetX -= child.rootWindow.clientStart.x;
2698 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2702 Extent childRenderArea;
2704 if(backBufferUpdate != null)
2706 childRenderArea.Copy(backBufferUpdate);
2707 childRenderArea.Offset(-offsetX, -offsetY);
2710 childRenderArea.Copy(child.dirtyArea);
2712 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2713 renderArea.Copy(dirtyExtent);
2714 renderArea.Offset(-offsetX, -offsetY);
2715 childRenderArea.Union(renderArea);
2718 // Intersect with the clip extent
2719 childRenderArea.Intersection(child.clipExtent);
2722 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2723 renderArea->Offset(offsetX, offsetY);
2724 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2725 // overDirtyExtent.Union(renderArea);
2726 renderArea->Empty();
2727 // childRenderArea.Free();
2729 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2734 for(child = children.last; child; child = child.prev)
2736 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2738 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2743 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2745 bool opaque = IsOpaque();
2746 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2748 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2749 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2751 offsetX -= rootWindow.clientStart.x;
2752 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2756 for(child = children.last; child; child = child.prev)
2758 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2760 ColorAlpha background = *(ColorAlpha *)&child.background;
2761 bool opaque = child.IsOpaque();
2762 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2766 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2767 // Adjust renderArea to the root window level
2769 renderArea.Copy(child.dirtyArea);
2770 renderArea.Offset(offsetX, offsetY);
2771 dirtyExtent.Union(renderArea);
2772 overDirtyExtent.Union(renderArea);
2778 for(child = children.last; child; child = child.prev)
2780 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2782 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2786 if(backBufferUpdate != null)
2788 renderArea.Copy(backBufferUpdate);
2789 renderArea.Offset(-offsetX, -offsetY);
2791 overRenderArea.Copy(backBufferUpdate);
2792 overRenderArea.Offset(-offsetX, -offsetY);
2798 renderArea.Copy(dirtyArea);
2800 overRenderArea.Copy(dirtyArea);
2803 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2804 dirtyExtentWindow->Copy(dirtyExtent);
2805 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2806 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2807 dirtyExtentWindow->Empty();
2809 // Intersect with the clip extent
2810 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2813 if(renderArea.count > 10)
2816 printf("\nToo many extents (%d):\n", renderArea.count);
2818 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2819 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2824 for(c = 0; c<10; c++)
2827 FASTLIST_LOOP(renderArea, extentBox)
2829 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2831 renderArea.Copy(extent);
2833 FASTLIST_LOOP(renderArea, extentBox)
2836 printf("(%d, %d) - (%d, %d)\n",
2837 extentBox.box.left, extentBox.box.top,
2838 extentBox.box.right, extentBox.box.bottom);
2842 printf("\nNow %d\n", renderArea.count);
2848 // WHY WAS THIS COMMENTED ??
2850 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2851 dirtyExtentWindow->Copy(overDirtyExtent);
2852 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2853 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2854 dirtyExtentWindow->Empty();
2856 // Intersect with the clip extent
2857 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2863 if(scrollExtent.count)
2865 // Subtract render extent from scrolling extent
2866 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2868 if(backBufferUpdate == null)
2870 Extent * dirty = &rootWindow.tempExtents[3];
2873 // Intersect scrolling extent with clip extent
2874 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2876 // offset this scroll to be at the root window level
2877 scrollExtent.Offset(offsetX, offsetY);
2878 // Add area that was scrolled to the dirty extents of the back buffer
2879 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2883 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2884 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2885 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2890 scrollExtent.Empty();
2892 // Add the exposed extent to the window render area
2893 dirty->Offset(-offsetX, -offsetY);
2894 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2899 // Subtract the window's box from the transparency forced extent
2900 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2906 renderArea.Copy(this.renderArea);
2907 renderArea.Offset(offsetX, offsetY);
2908 dirtyExtent.Union(renderArea);
2914 Extent renderArea { };
2916 renderArea.Copy(overRenderArea);
2917 renderArea.Offset(offsetX, offsetY);
2918 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2923 if(backBufferUpdate != null)
2925 // Remove render area from dirty area
2926 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2928 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2935 // Remove the window render area from the dirty extents of the back buffer
2936 rootWindow.dirtyBack.Exclusion(renderArea);
2940 void Render(Extent updateExtent)
2944 Window rootWindow = this.rootWindow;
2945 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2946 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2948 offsetX -= rootWindow.clientStart.x;
2949 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2952 if(rootWindow.fullRender)
2961 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2962 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2967 /*if(renderArea.count)
2968 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2971 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2973 Box box = extentBox.box;
2976 /*printf("(%d, %d) - (%d, %d)\n",
2977 extentBox.box.left, extentBox.box.top,
2978 extentBox.box.right, extentBox.box.bottom);*/
2983 box.left += offsetX;
2985 box.right += offsetX;
2986 box.bottom += offsetY;
2988 if(updateExtent != null)
2989 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2993 for(child = children.first; child; child = child.next)
2994 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
2995 child.Render(updateExtent);
2997 if(rootWindow.fullRender)
2998 DrawOverChildren(box);
3001 // TO DO: There's an issue about draw over children...
3002 // TO DO: Don't wanna go through this if method isn't used
3003 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3004 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3006 Box box = extentBox.box;
3008 DrawOverChildren(box);
3010 box.left += offsetX;
3012 box.right += offsetX;
3013 box.bottom += offsetY;
3015 if(updateExtent != null)
3016 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3019 for(child = children.first; child; child = child.next)
3020 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3021 child.Render(updateExtent);
3024 overRenderArea.Empty();
3027 public void UpdateDisplay(void)
3029 if(!manageDisplay) { OnRedraw(null);return; }
3030 if(rootWindow && this != rootWindow)
3031 rootWindow.UpdateDisplay();
3034 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3035 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3038 dirtyExtent.Clear();
3041 clipExtent.AddBox(box);
3043 display.StartUpdate();
3045 if(!rootWindow.fullRender)
3047 ComputeClipExtents();
3048 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3049 ComputeRenderArea(dirtyExtent, overExtent, null);
3052 clipExtent.Free(null);
3054 dirtyExtent.Free(null);
3055 overExtent.Free(null);
3057 if(display.flags.flipping)
3060 display.Update(null);
3064 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3065 updateExtent.Clear();
3067 Render(updateExtent);
3069 updateExtent.UnionBox(this.box, tempExtents[0]);
3072 //printf("\n\nUpdate:\n------------------------------------------\n");
3075 //FASTLIST_LOOP(updateExtent, extentBox)
3076 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3079 /*printf("Updating (%d, %d) - (%d, %d)\n",
3080 extentBox.box.left, extentBox.box.top,
3081 extentBox.box.right, extentBox.box.bottom);*/
3084 display.Update(extentBox.box);
3087 updateExtent.Free(null);
3090 display.EndUpdate();
3098 void UpdateBackDisplay(Box box)
3104 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3106 //printf("UpdateBackDisplay going through!\n");
3107 display.StartUpdate();
3111 intersection.Copy(dirtyBack);
3112 intersection.IntersectBox(box);
3114 dirtyExtent.Clear();
3117 clipExtent.AddBox(box);
3119 if(!rootWindow.fullRender)
3121 ComputeClipExtents();
3122 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3125 clipExtent.Free(null);
3127 intersection.Free(null);
3128 dirtyExtent.Free(null);
3129 overExtent.Free(null);
3134 if(display.flags.flipping)
3135 display.Update(null);
3138 rootWindow.display.Update(box);
3141 display.EndUpdate();
3145 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3146 if(dirtyBack.count > MAX_DIRTY_BACK)
3148 BoxItem extentBox, next;
3149 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3150 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3152 next = (BoxItem)extentBox.next;
3153 if(extentBox != first)
3155 if(extentBox.box.left < first.box.left)
3156 first.box.left = extentBox.box.left;
3157 if(extentBox.box.top < first.box.top)
3158 first.box.top = extentBox.box.top;
3159 if(extentBox.box.right > first.box.right)
3160 first.box.right = extentBox.box.right;
3161 if(extentBox.box.bottom > first.box.bottom)
3162 first.box.bottom = extentBox.box.bottom;
3163 dirtyBack.Delete(extentBox);
3172 // --- Window positioning ---
3173 // --- Window identification ---
3175 // Returns window at position "Position"
3176 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3178 Window child, result = null;
3180 box.left += absPosition.x;
3181 box.right += absPosition.x;
3182 box.top += absPosition.y;
3183 box.bottom += absPosition.y;
3185 if(!destroyed && visible && (acceptDisabled || !disabled))
3187 int lx = x - absPosition.x;
3188 int ly = y - absPosition.y;
3189 if(IsInside(lx, ly))
3190 // if(box.IsPointInside(Point{x, y}))
3192 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3193 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3196 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3198 if(child != statusBar && child.rootWindow == rootWindow)
3200 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3207 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3209 if(child != statusBar && child.rootWindow == rootWindow)
3211 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3223 Window FindModal(void)
3225 Window modalWindow = this, check;
3226 Window check2 = null;
3227 for(check = this; check.master; check = check.master)
3229 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3231 modalWindow = check.master.modalSlave;
3232 check = modalWindow;
3234 // TESTING THIS FOR DROPBOX...
3235 if(!rootWindow || !rootWindow.style.interim)
3237 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3239 if(check2.modalSlave && check2.modalSlave.created)
3241 modalWindow = check2.modalSlave;
3249 if(modalWindow == this)
3251 for(check = this; check.activeChild; check = check.activeChild)
3253 if(check.modalSlave)
3255 modalWindow = check.modalSlave;
3261 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3262 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3265 void StopMoving(void)
3267 if(this == guiApp.windowMoving)
3269 guiApp.windowMoving = null;
3270 UpdateDecorations();
3271 SetMouseRange(null);
3274 if(rootWindow.active)
3275 guiApp.interfaceDriver.StopMoving(rootWindow);
3278 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3279 guiApp.windowIsResizing = false;
3283 void SelectMouseCursor(void)
3288 Window cursorWindow = null;
3289 bool rx, ry, rex, rey;
3291 guiApp.desktop.GetMousePosition(&x, &y);
3292 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3294 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3295 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3296 else if(mouseWindow)
3298 modalWindow = mouseWindow.FindModal();
3299 x -= mouseWindow.absPosition.x;
3300 y -= mouseWindow.absPosition.y;
3301 if(guiApp.windowIsResizing)
3303 rex = guiApp.resizeEndX;
3304 rey = guiApp.resizeEndY;
3305 rx = guiApp.resizeX;
3306 ry = guiApp.resizeY;
3307 if((rex && rey) || (rx && ry))
3308 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3309 else if((rex && ry) || (rx && rey))
3310 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3311 else if((ry || rey) && (!rx && !rex))
3312 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3313 else if((rx || rex) && (!ry && !rey))
3314 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3316 else if(!modalWindow && !guiApp.windowCaptured &&
3317 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3318 &rx, &ry, &rex, &rey))
3320 if((rex && rey) || (rx && ry))
3321 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3322 else if((rex && ry) || (rx && rey))
3323 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3324 else if((ry || rey) && (!rx && !rex))
3325 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3326 else if((rx || rex) && (!ry && !rey))
3327 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3329 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3331 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3332 cursorWindow = mouseWindow.parent;
3334 cursorWindow = mouseWindow;
3336 else if(!guiApp.interimWindow)
3337 cursorWindow = guiApp.windowCaptured;
3340 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3341 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3343 else if(modalWindow)
3345 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3347 else if(guiApp.interimWindow)
3349 if(guiApp.interimWindow.cursor)
3350 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3352 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3357 // --- State based input ---
3358 bool AcquireInputEx(bool state)
3363 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3364 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3366 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3368 guiApp.acquiredWindow = state ? this : null;
3371 SetMouseRangeToClient();
3372 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3377 SelectMouseCursor();
3379 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3383 // --- Window activation ---
3384 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3387 if(!parent || !parent.style.inactive)
3389 Window parent = this.parent;
3392 if(rootWindow == this)
3393 Log(active ? "active\n" : "inactive\n");
3396 // Testing this here...
3397 if(!parent || parent == guiApp.desktop || parent.active)
3399 this.active = active;
3402 // TESTING THIS HERE
3403 UpdateDecorations();
3404 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3405 result = NotifyActivate(master, this, active, previous);
3408 this.active = !active;
3413 if(!parent || parent == guiApp.desktop || parent.active)
3415 this.active = active;
3417 AcquireInputEx(active);
3422 if(guiApp.caretOwner)
3426 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3427 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3428 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3429 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3431 guiApp.caretOwner.Update(extent);
3434 if(visible || !guiApp.caretOwner)
3435 guiApp.caretOwner = this;
3436 UpdateCaret(false, false);
3442 this.active = false;
3444 AcquireInputEx(active);
3446 if(!active && guiApp.caretOwner == this)
3448 UpdateCaret(false, true);
3449 guiApp.caretOwner = null;
3450 guiApp.interfaceDriver.SetCaret(0,0,0);
3451 guiApp.caretEnabled = false;
3456 if(!active && parent && parent.activeChild && parent.activeChild != this)
3457 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3463 if(!active && menuBar)
3466 menuBar.OnActivate(false, null, &goOn, true);
3467 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3472 Window aChild = activeChild;
3474 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3486 void ConsequentialMouseMove(bool kbMoving)
3490 if(kbMoving || !guiApp.windowMoving)
3494 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3496 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3498 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3499 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3505 bool IsDescendantOf(Window ancestor)
3508 for(window = this; window && window != ancestor; window = window.parent);
3509 return window == ancestor;
3512 bool IsSlaveOf(Window master)
3515 for(window = this; window && window != master; window = window.master);
3516 return window == master;
3519 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3523 if(this && !destroyed /*&& state != Hidden*/)
3525 Window swap = externalSwap;
3533 if(activateParent &&
3534 (parent.activeChild != this ||
3535 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3536 active && _isModal &&
3537 parent != master && master)
3538 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3544 bool real = parent.activeChild != this;
3546 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3547 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3548 !IsDescendantOf(guiApp.interimWindow) &&
3549 !IsSlaveOf(guiApp.interimWindow))
3551 Window interimWindow = guiApp.interimWindow;
3552 while(interimWindow && interimWindow != this)
3554 Window master = interimWindow.master;
3556 guiApp.interimWindow = null;
3557 if(guiApp.caretOwner)
3558 guiApp.caretOwner.UpdateCaret(false, false);
3560 incref interimWindow;
3561 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3566 delete interimWindow;
3567 interimWindow = (master && master.style.interim) ? master : null;
3572 guiApp.interimWindow = this;
3573 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3574 guiApp.caretEnabled = false;*/
3575 UpdateCaret(false, true);
3580 bool acquireInput = false;
3582 parent.activeChild &&
3583 parent.activeChild.state == maximized &&
3584 parent != guiApp.desktop;
3586 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3591 swap = parent.activeChild;
3592 if(swap && swap.destroyed) swap = null;
3593 if(swap && swap != this)
3596 if(!swap.PropagateActive(false, this, &goOn, true))
3597 swap = parent.activeChild;
3608 if(!parent || parent.activeChild != this || style.interim)
3611 result = PropagateActive(true, swap, &goOn, true);
3612 if(!result && !goOn)
3617 acquireInput = true;
3621 if(style.hasMaximize && parent != guiApp.desktop)
3624 SetState(maximized, false, 0);
3625 else if(state != maximized)
3628 for(child = parent.children.first; child; child = child.next)
3630 if(this != child && child.state == maximized)
3631 child.SetState(normal, false, 0);
3638 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3640 Window previous = parent.activeClient;
3641 parent.activeChild = this;
3642 if(!style.nonClient /*&& style.isActiveClient*/)
3646 if(style.isActiveClient)
3647 parent.activeClient = this;
3648 // Moved UpdateActiveDocument inside hidden check
3649 // To prevent activating previous window while creating a new one
3650 // (It was messing up the privateModule in the CodeEditor)
3651 parent.UpdateActiveDocument(previous);
3657 //if(!style.isRemote)
3659 if(rootWindow != this)
3661 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3662 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3664 else if(!guiApp.fullScreenMode)
3666 Window modalRoot = FindModal();
3667 if(!modalRoot) modalRoot = this;
3668 if(!modalRoot.isForegroundWindow)
3670 modalRoot.isForegroundWindow = true;
3671 // To check : Why is parent null?
3672 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3674 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3676 modalRoot.isForegroundWindow = false;
3681 if(result && real && (!style.inactive || moveInactive) && parent)
3683 Window last = parent.children.last;
3685 if(!style.stayOnTop)
3686 for(; last && last.style.stayOnTop; last = last.prev);
3688 parent.children.Move(this, last);
3690 // Definitely don't want that: why not?
3694 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3700 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3707 parent.activeChild = null;
3708 if(!style.nonClient /*&& style.isActiveClient*/)
3710 Window previous = parent.activeClient;
3711 if(style.isActiveClient)
3712 parent.activeClient = null;
3713 parent.UpdateActiveDocument(previous);
3717 if(this == guiApp.interimWindow)
3719 guiApp.interimWindow = null;
3720 if(guiApp.caretOwner)
3721 guiApp.caretOwner.UpdateCaret(false, false);
3723 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3730 if(!active || !swap)
3731 UpdateDecorations();
3733 swap.UpdateDecorations();
3735 if(active && rootWindow != this)
3736 ConsequentialMouseMove(false);
3743 // --- Input Messages ---
3744 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3746 static bool reEntrancy = false;
3747 if(reEntrancy) return;
3751 guiApp.cursorUpdate = true;
3752 if(guiApp.windowScrolling && !consequential)
3754 guiApp.windowScrolling.SetScrollPosition(
3755 (guiApp.windowScrolling.sbh) ?
3756 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3757 (guiApp.windowScrolling.sbv) ?
3758 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3760 if(guiApp.windowMoving)
3762 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3764 Window window = guiApp.windowMoving;
3766 int w = window.size.w;
3767 int h = window.size.h;
3772 rx = mouseX - guiApp.windowMovingStart.x;
3773 ry = mouseY - guiApp.windowMovingStart.y;
3776 window.GetDecorationsSize(&ew, &eh);
3778 if(guiApp.windowIsResizing)
3780 x = window.scrolledPos.x;
3781 y = window.scrolledPos.y;
3785 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3786 rx = guiApp.windowResizingBefore.w - aw;
3787 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3788 w = guiApp.windowResizingBefore.w - rx;
3792 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3793 ry = guiApp.windowResizingBefore.h - ah;
3794 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3795 ry = Max(ry, -guiApp.windowMovingBefore.y);
3796 h = guiApp.windowResizingBefore.h - ry;
3798 if(guiApp.resizeEndX)
3800 w = guiApp.windowResizingBefore.w + rx;
3803 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3811 w = Max(w, window.minSize.w);
3812 h = Max(h, window.minSize.h);
3813 w = Min(w, window.maxSize.w);
3814 h = Min(h, window.maxSize.h);
3816 if(!window.OnResizing(&w, &h))
3818 w = window.clientSize.w;
3819 h = window.clientSize.h;
3822 w = Max(w, window.skinMinSize.w);
3823 h = Max(h, window.skinMinSize.h);
3830 SNAPDOWN(w, textCellW);
3831 SNAPDOWN(h, textCellH);
3836 aw = Max(w,window.skinMinSize.w);
3837 rx = guiApp.windowResizingBefore.w - aw;
3838 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3839 w = guiApp.windowResizingBefore.w - rx;
3843 ah = Max(h,window.skinMinSize.h);
3844 ry = guiApp.windowResizingBefore.h - ah;
3845 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3846 ry = Max(ry, -guiApp.windowMovingBefore.y);
3847 h = guiApp.windowResizingBefore.h - ry;
3852 if(!guiApp.windowIsResizing || guiApp.resizeX)
3853 x = guiApp.windowMovingBefore.x + rx;
3854 if(!guiApp.windowIsResizing || guiApp.resizeY)
3855 y = guiApp.windowMovingBefore.y + ry;
3857 if(!guiApp.windowIsResizing)
3860 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3862 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3863 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3864 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3865 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3869 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3870 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3876 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3878 if(!window.OnMoving(&x, &y, w, h))
3880 x = window.scrolledPos.x;
3881 y = window.scrolledPos.y;
3887 SNAPDOWN(x, textCellW);
3888 SNAPDOWN(y, textCellH);
3891 if(!window.style.nonClient)
3893 if(!window.style.fixed /*|| window.style.isDocument*/)
3895 if(!window.style.dontScrollHorz)
3896 x += window.parent.scroll.x;
3897 if(!window.style.dontScrollVert)
3898 y += window.parent.scroll.y;
3902 // Break the anchors for moveable/resizable windows
3903 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3904 if(window.style.fixed)
3906 if(window.state == normal)
3908 window.normalAnchor = Anchor { left = x, top = y };
3909 window.normalSizeAnchor = SizeAnchor { { w, h } };
3910 window.anchored = false;
3914 window.stateAnchor = Anchor { left = x, top = y };
3915 window.stateSizeAnchor = SizeAnchor { { w, h } };
3917 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3918 // TOCHECK: Investigate why the following only redraws the scrollbars
3919 //window.Position(x, y, w, h, false, true, true, true, false, true);
3921 guiApp.movingLast.x = mouseX;
3922 guiApp.movingLast.y = mouseY;
3928 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3931 bool wasMoving = guiApp.windowMoving ? true : false;
3932 bool wasScrolling = guiApp.windowScrolling ? true : false;
3934 while(result && w != this)
3936 Window msgWindow = GetAtPosition(x,y, false, true, w);
3937 Window trueWindow = GetAtPosition(x,y, false, false, w);
3938 bool windowDragged = false;
3943 window = (w && !w.disabled) ? w : null;
3945 if(trueWindow) incref trueWindow;
3947 if(consequential) mods->isSideEffect = true;
3949 UpdateMouseMove(x, y, consequential);
3951 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3953 if(!guiApp.windowCaptured.isEnabled)
3954 guiApp.windowCaptured.ReleaseCapture();
3956 window = guiApp.windowCaptured;
3959 if(trueWindow && activate &&
3960 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3961 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3962 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3963 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3965 if(mods->alt && !mods->ctrl && !mods->shift)
3967 Window moved = trueWindow;
3968 for(moved = trueWindow; moved; moved = moved.parent)
3969 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3974 windowDragged = true;
3976 // Cancel the ALT menu toggling...
3977 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3982 if(window && activate &&
3983 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3984 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3985 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3986 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3988 Window modalWindow = window.FindModal();
3990 /*if(mods->alt && !mods->shift && !mods->ctrl)
3992 Window moved = window;
3993 for(moved = window; moved; moved = moved.parent)
3994 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3999 windowDragged = true;
4001 // Cancel the ALT menu toggling...
4002 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4008 Window activateWindow = modalWindow ? modalWindow : window;
4009 if(activateWindow && !activateWindow.isRemote)
4011 bool doActivation = true;
4012 //bool needToDoActivation = false;
4013 Window check = activateWindow;
4015 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4017 if(!check.style.inactive)
4019 //needToDoActivation = true;
4021 doActivation = false;
4026 if(!needToDoActivation)
4027 doActivation = false;
4030 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4031 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4033 // Let the OnLeftButtonDown do the activating instead
4034 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4042 incref activateWindow;
4043 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4045 delete activateWindow;
4049 if(activateWindow._refCount == 1)
4051 delete activateWindow;
4055 delete activateWindow;
4057 mods->isActivate = true;
4061 if(!modalWindow && window && !window.destroyed)
4063 if(!guiApp.windowCaptured || windowDragged)
4065 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4067 bool moving = ((window.state != maximized &&
4068 window.IsMouseMoving(
4069 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4070 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4072 if(!moving && window.IsMouseResizing(
4073 x - window.absPosition.x,
4074 y - window.absPosition.y,
4075 window.size.w, window.size.h,
4076 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4078 guiApp.windowIsResizing = true;
4079 guiApp.windowResizingBefore.w = window.size.w;
4080 guiApp.windowResizingBefore.h = window.size.h;
4082 if(guiApp.windowIsResizing || windowDragged || moving)
4085 guiApp.windowMoving = window;
4086 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4087 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4088 guiApp.windowMovingBefore.x = window.position.x;//s;
4089 guiApp.windowMovingBefore.y = window.position.y;//s;
4090 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4091 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4094 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4096 if(window.style.fixed &&
4098 window.IsMouseMoving(
4099 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4101 window.ShowSysMenu(x, y);
4105 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4107 if(window.sbv || window.sbh)
4110 guiApp.windowScrolling = window;
4111 guiApp.windowScrollingStart.x = x;
4112 guiApp.windowScrollingStart.y = y;
4113 guiApp.windowScrollingBefore.x = window.scroll.x;
4114 guiApp.windowScrollingBefore.y = window.scroll.y;
4117 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4119 if(window.style.hasMaximize &&
4120 window.IsMouseMoving(
4121 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4124 (window.state == maximized) ? normal : maximized, false, *mods);
4132 if(guiApp.windowMoving)
4134 if(guiApp.windowMoving.parent)
4136 if(guiApp.windowMoving.style.nonClient)
4137 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4139 guiApp.windowMoving.parent.SetMouseRangeToClient();
4143 window.UpdateDecorations();
4146 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4148 // Log("\n*** LEFT BUTTON UP ***\n");
4149 if(guiApp.windowMoving)
4150 guiApp.windowMoving.StopMoving();
4152 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4154 if(guiApp.windowScrolling)
4156 Window windowScrolling = guiApp.windowScrolling;
4157 guiApp.windowScrolling = null;
4158 windowScrolling.ReleaseCapture();
4162 if(!result || (window && window.destroyed)) window = null;
4164 if(window && window.FindModal())
4167 if(trueWindow && trueWindow.FindModal())
4175 msgWindow = GetAtPosition(x,y, true, false);
4177 msgWindow.SelectMouseCursor();
4180 if(guiApp.windowCaptured || trueWindow)
4182 Window prevWindow = guiApp.prevWindow;
4183 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4185 guiApp.prevWindow.mouseInside = false;
4186 guiApp.prevWindow = null;
4188 // Eventually fix this not to include captured?
4189 if(!prevWindow.OnMouseLeave(*mods))
4192 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4194 Box box = trueWindow.box;
4195 box.left += trueWindow.absPosition.x;
4196 box.right += trueWindow.absPosition.x;
4197 box.top += trueWindow.absPosition.y;
4198 box.bottom += trueWindow.absPosition.y;
4200 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4202 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4203 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4205 overX = Max(Min(overX, 32767),-32768);
4206 overY = Max(Min(overY, 32767),-32768);
4208 trueWindow.mouseInside = true;
4209 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4213 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4214 guiApp.prevWindow = trueWindow;
4216 guiApp.prevWindow = null;
4218 SelectMouseCursor();
4220 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4222 int clientX = x - (window.absPosition.x + window.clientStart.x);
4223 int clientY = y - (window.absPosition.y + window.clientStart.y);
4225 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4227 clientX = Max(Min(clientX, 32767),-32768);
4228 clientY = Max(Min(clientY, 32767),-32768);
4230 MouseMethod = (void *)window._vTbl[method];
4232 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4235 if(!MouseMethod(window, clientX, clientY, *mods))
4242 if(result && w && w.clickThrough && w.parent)
4247 if(!result || !w || !w.clickThrough)
4254 // --- Mouse cursor management ---
4256 bool KeyMessage(uint method, Key key, unichar character)
4261 if(guiApp.interimWindow)
4262 this = guiApp.interimWindow;
4265 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4269 if(!style.inactive || rootWindow != this)
4271 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4272 Window modalWindow = FindModal();
4273 Window interimMaster = master ? master.rootWindow : null;
4277 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4278 status = OnSysKeyDown(key, character);
4279 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4280 status = OnSysKeyHit(key, character);
4281 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4282 status = OnSysKeyUp(key, character);
4289 // Process Key Message for Internal UI Keyboard actions
4290 if(status && !destroyed && menuBar && state != minimized)
4293 if((SmartKey)key != alt)
4294 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4297 SmartKey sk = (SmartKey) key;
4298 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4300 status = menuBar.KeyMessage(method, key, character);
4305 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4306 menuBar.OnKeyHit(escape, 0);
4308 if(!menuBar.focus && guiApp.caretOwner)
4309 guiApp.caretOwner.UpdateCaret(true, false);
4312 if(!destroyed && status)
4314 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4318 case left: case up: case right: case down:
4319 if(guiApp.windowMoving == this)
4322 int w = guiApp.windowMoving.size.w;
4323 int h = guiApp.windowMoving.size.h;
4324 int x = guiApp.windowMoving.scrolledPos.x;
4325 int y = guiApp.windowMoving.scrolledPos.y;
4329 if(key == down || key == up)
4330 step = Max(step, textCellH);
4332 step = Max(step, textCellW);
4335 if(guiApp.windowIsResizing)
4339 case left: w-=step; break;
4340 case right: w+=step; break;
4341 case up: h-=step; break;
4342 case down: h+=step; break;
4349 case left: x-=step; break;
4350 case right: x+=step; break;
4351 case up: y-=step; break;
4352 case down: y+=step; break;
4356 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4357 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4359 if(!guiApp.windowIsResizing || guiApp.resizeX)
4360 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4362 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4364 if(!guiApp.windowIsResizing || guiApp.resizeY)
4365 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4367 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4369 guiApp.interfaceDriver.SetMousePosition(x, y);
4370 ConsequentialMouseMove(true);
4378 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4380 guiApp.windowMoving.StopMoving();
4381 ConsequentialMouseMove(false);
4389 ShowSysMenu(absPosition.x, absPosition.y);
4397 if(!destroyed && status && state != minimized)
4399 // Process all the way down the children
4400 if(activeChild && !activeChild.disabled)
4402 status = activeChild.KeyMessage(method, key, character);
4404 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4405 key.code != left && key.code != right && key.code != up && key.code != down)
4407 status = activeClient.KeyMessage(method, key, character);
4411 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4413 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4414 // && defaultControl != activeChild)
4416 delete previousActive;
4417 previousActive = activeChild;
4418 if(previousActive) incref previousActive;
4420 ConsequentialMouseMove(false);
4421 if((defaultControl.active ||
4422 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4423 defaultControl.KeyMessage(method, defaultKey, character);
4429 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4431 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4438 ShowSysMenu(absPosition.x, absPosition.y);
4445 if(this != guiApp.desktop)
4447 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4449 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4451 MenuMoveOrSize(key.shift, true);
4455 else if(guiApp.windowMoving)
4457 guiApp.windowMoving.StopMoving();
4458 ConsequentialMouseMove(false);
4466 if(!destroyed && status && state != minimized)
4468 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4472 case tab: case shiftTab:
4474 Window cycleParent = this;
4475 if(this == guiApp.interimWindow && !master.style.interim && !cycleParent.style.tabCycle)
4476 cycleParent = master.parent;
4478 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4480 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4482 Window child = cycleParent.activeChild;
4484 // Scroll the window to include the active control
4486 if(cycleParent.sbh && !child.style.dontScrollHorz)
4488 if(child.scrolledPos.x < 0)
4489 cycleParent.sbh.Action(Position,
4490 cycleParent.scroll.x + child.scrolledPos.x, 0);
4491 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4492 cycleParent.sbh.Action(Position,
4493 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4495 if(cycleParent.sbv && !child.style.dontScrollVert)
4497 if(child.scrolledPos.y < 0)
4498 cycleParent.sbv.Action(Position,
4499 cycleParent.scroll.y + child.scrolledPos.y, 0);
4500 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4501 cycleParent.sbv.Action(Position,
4502 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4505 cycleParent.ConsequentialMouseMove(false);
4511 case f6: case shiftF6:
4512 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4514 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4515 if(parent == guiApp.desktop)
4516 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4526 if(CycleChildren(key.shift, true, false, true))
4534 // mIRC Style Window Shortcuts
4535 case alt1: case alt2: case alt3: case alt4: case alt5:
4536 case alt6: case alt7: case alt8: case alt9: case alt0:
4541 for(document = children.first; document; document = document.next)
4543 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4545 if(document == activeChild)
4547 if(document.state == minimized)
4548 document.SetState(normal, false, key);
4551 document.SetState(minimized, false, key);
4552 CycleChildren(false, true, false);
4557 if(activeChild.state == maximized && document.style.hasMaximize)
4558 document.SetState(maximized, false, key);
4559 else if(document.state == minimized)
4560 document.SetState(normal, false, key);
4561 document.Activate();
4576 if(!destroyed && status)
4578 if(state == minimized)
4583 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4585 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4587 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4588 previousActive.ActivateEx(true, false, false, true, null, null);
4589 delete previousActive;
4595 if(!destroyed && status)
4597 status = ProcessHotKeys(method, key, character);
4599 if(!destroyed && status && !modalWindow && state != minimized)
4602 status = KeyMethod(this, key, character);
4603 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4604 status = OnKeyHit(key, character);
4605 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4607 bool result = false;
4610 case ctrlUp: case ctrlDown:
4611 if(sbv && !guiApp.windowScrolling)
4612 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4614 case wheelUp: case wheelDown:
4615 if(sbv && !guiApp.windowScrolling)
4617 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4618 // Do we want to do a consequential move regardless of result in this case?
4619 ConsequentialMouseMove(false);
4622 case ctrlPageUp: case ctrlPageDown:
4623 if(sbh && !guiApp.windowScrolling)
4624 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4629 ConsequentialMouseMove(false);
4634 if(status && !destroyed && menuBar && state != minimized)
4635 status = menuBar.KeyMessage(method, key, character);
4637 if(style.interim && /*destroyed && */status && interimMaster)
4639 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4640 status = interimMaster.KeyMessage(method, key, character);
4647 bool ProcessHotKeys(uint method, Key key, unichar character)
4652 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4653 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4654 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4656 Window hotKeyWindow = hotKey.window;
4657 Window parent = hotKeyWindow.parent;
4658 Window prevActiveWindow = activeChild;
4659 // For when sys buttons are placed inside the menu bar
4660 if(parent && parent._class == class(PopupMenu))
4661 parent = parent.parent;
4663 // 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
4664 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4667 if(prevActiveWindow) incref prevActiveWindow;
4668 incref hotKeyWindow;
4669 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4670 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4673 delete hotKeyWindow;
4674 delete prevActiveWindow;
4678 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4679 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4680 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4682 // ********* WORKING ON THIS ***********
4683 if(prevActiveWindow && !guiApp.interimWindow)
4684 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4687 else if(hotKeyWindow.style.inactive)
4688 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4690 delete prevActiveWindow;
4691 delete hotKeyWindow;
4692 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4693 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4697 if(status && tabCycle)
4700 for(child = children.first; child; child = child.next)
4702 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4713 // --- Windows and graphics initialization / termination ---
4714 bool SetupRoot(void)
4718 // Setup relationship with outside world (bb root || !bb)
4719 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4720 (_displayDriver && dispDriver != parent.dispDriver))
4724 tempExtents = new0 Extent[4];
4729 /*if(guiApp.fullScreenMode)
4730 rootWindow = guiApp.desktop;
4732 //rootWindow = parent.created ? parent.rootWindow : null;
4733 rootWindow = parent.rootWindow;
4736 against = &parent.box;
4738 against = &parent.clientArea;
4741 for(child = children.first; child; child = child.next)
4744 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4747 bool Setup(bool positionChildren)
4749 bool result = false;
4752 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && dispDriver != parent.dispDriver))))
4754 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4755 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4757 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4759 // This was here, is it really needed?
4760 //guiApp.interfaceDriver.ActivateRootWindow(this);
4764 displaySystem = DisplaySystem {};
4765 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4767 delete displaySystem;
4772 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4773 if(display.Create(displaySystem, windowHandle))
4780 // Sometimes icon does not show up on Windows XP if we set here...
4781 // guiApp.interfaceDriver.SetIcon(this, icon);
4783 else if(this != guiApp.desktop)
4785 display = rootWindow ? rootWindow.display : null;
4791 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4792 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4794 for(child = children.first; child; child = child.next)
4796 if(child.created && !child.Setup(false))
4802 bool SetupDisplay(void)
4804 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4805 if(is3D) return Window3D_SetupDisplay(this); else
4812 class_data void ** pureVTbl;
4814 bool LoadGraphics(bool creation, bool resetAnchors)
4816 bool result = false;
4817 bool success = false;
4819 WindowState stateBackup = state;
4822 if(!rootWindow.created)
4826 if(((subclass(Window))_class).pureVTbl)
4828 if(_vTbl == _class._vTbl)
4830 _vTbl = ((subclass(Window))_class).pureVTbl;
4835 for(m = 0; m < _class.vTblSize; m++)
4837 if(_vTbl[m] == _class._vTbl[m])
4838 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4842 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4844 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4846 _vTbl = _class._vTbl;
4851 for(m = 0; m < _class.vTblSize; m++)
4853 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4854 _vTbl[m] = _class._vTbl[m];
4859 if(guiApp.fullScreenMode || this != guiApp.desktop)
4861 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4867 display.Lock(false);
4868 if(rootWindow == this)
4870 // Set Color Palette
4871 display.SetPalette(palette, true);
4875 if(guiApp.fullScreenMode && this == guiApp.desktop)
4880 for(c=0; c<SystemCursor::enumSize; c++)
4881 if(!guiApp.systemCursors[c].bitmap)
4883 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4884 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4885 if(guiApp.systemCursors[c].bitmapName)
4887 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4888 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4889 if(guiApp.systemCursors[c].bitmap)
4890 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4895 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4897 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4898 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4900 cursor.bitmap.paletteShades = cursor.paletteShades;
4904 guiApp.cursorUpdate = true;
4907 ConsequentialMouseMove(false);
4913 // Load Window Graphic Resources
4916 if(usedFont == setFont || usedFont == window.systemFont)
4917 RemoveResource(usedFont);
4920 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4923 RemoveResource(systemFont);
4926 RemoveResource(captionFont);
4928 for(ptr = resources.first; ptr; ptr = ptr.next)
4930 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4933 AddResource(setFont);
4935 AddResource(systemFont);
4937 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4944 //if(master && master.font)
4945 if(parent && parent.font)
4949 faceName = parent.font.faceName,
4950 size = parent.font.size,
4951 bold = parent.font.bold,
4952 italic = parent.font.italic,
4953 underline = parent.font.underline
4955 //font = parent.font;
4956 watch(parent) { font { } };
4959 font = guiApp.currentSkin.SystemFont();
4966 captionFont = guiApp.currentSkin.CaptionFont();
4967 AddResource(captionFont);
4969 if(OnLoadGraphics())
4975 //SetScrollLineStep(sbStep.x, sbStep.y);
4977 if(this != guiApp.desktop)
4981 normalAnchor = anchor;
4982 normalSizeAnchor = sizeAnchor;
4985 // Break the anchors for moveable/resizable windows
4987 if(style.fixed && style.isDocument)
4989 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5001 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5002 stateSizeAnchor = SizeAnchor {};
5007 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5012 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5013 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5016 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5020 stateAnchor = normalAnchor;
5021 stateSizeAnchor = normalSizeAnchor;
5024 position = Point { };
5025 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5036 if(Position(x, y, w, h, true, false, true, true, true, true))
5038 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5041 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5058 success = result = true;
5061 if(!creation && result)
5063 // Load menu bar first because sys buttons are on it...
5066 if(!menuBar.LoadGraphics(false, resetAnchors))
5072 for(child = children.first; child; child = child.next)
5074 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5081 CreateSystemChildren();
5085 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5088 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5093 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5094 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5097 // Do this here to avoid problems on Windows
5098 if(stateBackup == maximized)
5099 property::state = maximized;
5103 void UnloadGraphics(bool destroyWindows)
5107 // Free children's graphics
5108 for(child = children.first; child; child = child.next)
5109 child.UnloadGraphics(destroyWindows);
5112 display.Lock(false);
5115 if(guiApp.fullScreenMode && this == guiApp.desktop)
5120 for(c=0; c<SystemCursor::enumSize; c++)
5121 if(guiApp.systemCursors[c].bitmap)
5122 delete guiApp.systemCursors[c].bitmap;
5124 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5125 delete cursor.bitmap;
5127 guiApp.cursorBackground.Free();
5130 if(display && display.displaySystem)
5134 for(ptr = resources.first; ptr; ptr = ptr.next)
5138 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5143 // Free window graphics
5146 // Free skin graphics
5147 if(rootWindow == this)
5149 DisplaySystem displaySystem = display.displaySystem;
5152 display.driverData = null;
5153 display.displaySystem = null;
5157 if(displaySystem && !displaySystem.numDisplays && !is3D)
5158 delete displaySystem;
5167 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5168 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5170 if(this == guiApp.desktop || parent == guiApp.desktop)
5172 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5173 guiApp.interfaceDriver.DestroyRootWindow(this);
5177 // --- Window Hiding ---
5179 void SetVisibility(bool state)
5181 bool visible = (style.hidden || !created) ? false : state;
5182 if(visible != this.visible)
5186 this.visible = visible;
5187 for(child = children.first; child; child = child.next)
5188 child.SetVisibility(visible);
5190 ConsequentialMouseMove(false);
5191 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5195 // --- Windows and graphics initialization / termination ---
5197 bool DisplayModeChanged(void)
5199 bool result = false;
5200 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5202 guiApp.modeSwitching = true;
5203 UnloadGraphics(false);
5205 if(LoadGraphics(false, false))
5207 guiApp.modeSwitching = false;
5212 // --- Window updates system ---
5214 void UpdateDirty(Box updateBox)
5216 if(!manageDisplay) { OnRedraw(null);return; }
5219 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5222 if(display.flags.flipping)
5225 rootWindow.UpdateDisplay();
5228 UpdateBackDisplay(updateBox);
5230 if(guiApp.fullScreenMode)
5232 guiApp.cursorUpdate = true;
5233 guiApp.PreserveAndDrawCursor();
5235 if(guiApp.fullScreenMode)
5236 guiApp.RestoreCursorBackground();
5242 // This function is strictly called as a result of system window activation
5243 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5246 Window interimMaster = null;
5247 Window interimWindow = guiApp.interimWindow;
5248 if(interimWindow && interimWindow.master)
5249 interimMaster = interimWindow.master.rootWindow;
5251 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5252 // SetState(normal, false, 0);
5253 SetState(lastState, false, 0);
5255 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5259 /* WTH is this doing here?
5260 while(swap && swap.activeChild)
5262 swap = swap.activeChild;
5265 // TESTING THIS BEFORE...
5266 if(interimWindow && this == interimMaster)
5270 // Window interimSwap = this;
5271 Window menuBar = this.menuBar;
5272 if(menuBar && interimWindow.master == menuBar)
5275 while(interimSwap && interimSwap.activeChild)
5276 interimSwap = interimSwap.activeChild;
5278 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5279 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5281 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5282 //result = ActivateEx(true, true, false, activateRoot, window, null);
5287 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5288 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5290 if(interimWindow == this && interimMaster && !active)
5292 while(interimMaster && interimMaster.interim && interimMaster.master)
5294 // printf("Going up one master %s\n", interimMaster._class.name);
5295 interimMaster = interimMaster.master.rootWindow;
5297 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5298 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5304 bool DestroyEx(int returnCode)
5307 Timer timer, nextTimer;
5309 OldLink prevOrder = null;
5310 Window client = null;
5312 if(parent) stopwatching(parent, font);
5314 // if(window.modalSlave) return false;
5315 if(destroyed || !created)
5322 OldLink slave = master.slaves.FindLink(this);
5323 master.slaves.Delete(slave);
5326 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5332 this.returnCode = (DialogResult)returnCode;
5334 AcquireInput(false);
5339 master.hotKeys.Delete(hotKey);
5343 if(guiApp.prevWindow == this)
5345 guiApp.prevWindow = null;
5348 if(guiApp.caretOwner == this)
5350 guiApp.interfaceDriver.SetCaret(0,0,0);
5351 UpdateCaret(false, true);
5352 guiApp.caretEnabled = false;
5357 parent.childrenCycle.Remove(cycle);
5361 OldLink tmpPrev = order.prev;
5362 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5363 prevOrder = tmpPrev;
5366 client = tmpPrev ? tmpPrev.data : null;
5367 if(client == this) { client = null; break; }
5368 if(client && (client.style.hidden || client.destroyed || !client.created))
5369 tmpPrev = client.order.prev;
5373 prevOrder = tmpPrev;
5378 // If this window can be an active client, make sure the next window we activate can also be one
5379 if(!style.nonClient && style.isActiveClient)
5381 tmpPrev = prevOrder;
5384 client = tmpPrev ? tmpPrev.data : null;
5385 if(client == this) { client = null; break; }
5386 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5387 tmpPrev = client.order.prev;
5391 prevOrder = tmpPrev;
5395 if(client && client.style.hidden) client = null;
5397 // parent.childrenOrder.Remove(order);
5400 if(parent && style.isActiveClient && visible)
5402 if(state == minimized) parent.numIcons--;
5403 parent.numPositions--;
5406 // TESTING THIS HERE!
5410 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5411 // to create a window inside a rootwindow that's being destroyed)
5412 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5414 if(master && !master.destroyed /*&&
5415 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5417 if(master.defaultControl == this)
5418 master.defaultControl = null;
5420 if(parent && !parent.destroyed /*&&
5421 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5423 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5425 if(order && prevOrder && prevOrder.data != this && active)
5427 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5429 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5430 if(parent.activeClient == this)
5432 parent.activeClient = null;
5433 parent.UpdateActiveDocument(null);
5438 if(guiApp.interimWindow == this)
5441 PropagateActive(false, null, &goOn, true);
5445 //if(window.parent.activeChild == window)
5446 parent.activeChild = null;
5447 if(!style.nonClient /*&& style.isActiveClient*/)
5449 Window previous = parent.activeClient;
5450 if(style.isActiveClient)
5451 parent.activeClient = null;
5452 parent.UpdateActiveDocument(previous);
5457 else if(parent.activeClient == this)
5459 parent.activeClient = client;
5460 parent.UpdateActiveDocument(this);
5464 if(guiApp.interimWindow == this)
5466 guiApp.interimWindow = null;
5467 if(guiApp.caretOwner)
5469 Window desktop = guiApp.desktop;
5470 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5471 guiApp.caretOwner.UpdateCaret(false, false);
5476 if(_isModal && master && master.modalSlave == this)
5477 master.modalSlave = null;
5481 if(!guiApp.caretOwner && parent.caretSize)
5483 guiApp.caretOwner = parent;
5484 parent.UpdateCaret(false, false);
5485 parent.Update(null);
5488 // Why was this commented out?
5489 GetRidOfVirtualArea();
5495 dirtyArea.Free(null);
5496 dirtyBack.Free(null);
5497 scrollExtent.Free(null);
5499 /* ATTEMPTING TO MOVE THAT ABOVE
5508 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5509 for(;(child = window.children.first);)
5511 for(; child && (child.destroyed || !child.created); child = child.next);
5520 UnloadGraphics(true);
5523 delete previousActive;
5526 // statusBar = null;
5529 if(master && !master.destroyed)
5531 //master.NotifyDestroyed(this, this.returnCode);
5532 NotifyDestroyed(master, this, this.returnCode);
5535 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5537 nextTimer = timer.next;
5538 if(timer.window == this)
5540 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5541 // timer.window = null;
5547 if(this == guiApp.windowMoving)
5550 if(guiApp.windowCaptured == this)
5552 //guiApp.windowCaptured = null;
5554 if(rootWindow != this && rootWindow)
5555 rootWindow.ConsequentialMouseMove(false);
5563 //for(child = children.first; next = child ? child.next : null, child; child = next)
5564 for(;(child = children.first); )
5566 for(; child && (child.destroyed || !child.created); child = child.next);
5576 /* // MOVED THIS UP...
5579 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5580 for(;(child = window.children.first); )
5582 for(; child && (child.destroyed || !child.created); child = child.next);
5591 while((slave = slaves.first))
5593 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5595 ((Window)slave.data).DestroyEx(0);
5600 if(guiApp.caretOwner == this)
5601 guiApp.caretOwner = null;
5603 sysButtons[0] = null;
5604 sysButtons[1] = null;
5605 sysButtons[2] = null;
5608 if(rootWindow != this)
5610 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5613 box.left -= parent.clientStart.x;
5614 box.top -= parent.clientStart.y;
5615 box.right -= parent.clientStart.x;
5616 box.bottom -= parent.clientStart.y;
5618 if(parent) parent.Update(box);
5623 OldLink slave = master.slaves.FindVoid(this);
5624 master.slaves.Delete(slave);
5630 parent.children.Remove(this);
5635 //autoCreate = false;
5638 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5639 if(((subclass(Window))_class).pureVTbl)
5641 if(_vTbl == _class._vTbl)
5643 _vTbl = ((subclass(Window))_class).pureVTbl;
5648 for(m = 0; m < _class.vTblSize; m++)
5650 if(_vTbl[m] == _class._vTbl[m])
5651 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5660 void SetStateEx(WindowState newState, bool activate)
5663 WindowState prevState = state;
5667 if(prevState != newState)
5668 lastState = prevState;
5670 if(rootWindow != this || !nativeDecorations || !windowHandle)
5672 if(style.isActiveClient && !style.hidden && prevState == minimized)
5675 // This block used to be at the end of the function... moved it for flicker problem in X
5676 // ------------------------------------------------------
5680 stateAnchor = normalAnchor;
5681 stateSizeAnchor = normalSizeAnchor;
5684 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5685 stateSizeAnchor = SizeAnchor {};
5689 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5692 byte * idBuffer = new0 byte[size];
5694 for(child = parent.children.first; child; child = child.next)
5696 if(child != this && child.state == minimized)
5698 if(child.iconID > size - 2)
5700 idBuffer = renew0 idBuffer byte[size*2];
5701 memset(idBuffer + size, 0, size);
5704 idBuffer[child.iconID] = (byte)bool::true;
5707 for(c = 0; c<size; c++)
5712 if(style.isActiveClient && !style.hidden)
5715 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5716 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5720 // TOCHECK: Why was this here?
5721 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5722 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5723 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5725 Position(x, y, w, h, true, true, true, true, false, true);
5727 if(!style.inactive && !style.interim && this == parent.activeClient)
5728 parent.UpdateActiveDocument(null);
5731 CreateSystemChildren();
5732 // ------------------------------------------------------
5735 int GetPositionID(Window forChild)
5739 byte * idBuffer = new0 byte[size];
5742 for(child = children.first; child; child = child.next)
5744 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5746 if(child.positionID > size - 2)
5748 idBuffer = renew0 idBuffer byte[size*2];
5749 memset(idBuffer + size, 0, size);
5752 idBuffer[child.positionID] = (byte)bool::true;
5755 for(c = 0; c<size; c++)
5762 // --- Window related graphics ---
5764 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5766 palette = newPalette;
5767 if(rootWindow.display)
5768 rootWindow.display.SetPalette(palette, colorMatch);
5771 public bool AcquireInput(bool acquired)
5774 if(acquiredInput != acquired)
5776 if(active || (!visible && creationActivation == activate))
5777 result = AcquireInputEx(acquired);
5782 acquiredInput = acquired ? result : !result;
5787 void ListChildren(ListBox listBox)
5791 for(child = children.first; child; child = child.next)
5793 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5795 DataRow row = listBox.AddRow();
5796 row.tag = (int)child;
5797 child.FigureCaption(caption);
5798 row.SetData(null, caption);
5803 void UpdateVisual(Box extent)
5805 if(guiApp.driver != null)
5807 if(guiApp.fullScreenMode && guiApp.desktop.display)
5809 guiApp.desktop.mutex.Wait();
5810 guiApp.desktop.display.Lock(true);
5813 if(guiApp.desktop.active)
5815 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5817 if(guiApp.desktop.display.flags.flipping)
5818 guiApp.desktop.Update(null);
5819 guiApp.desktop.UpdateDisplay();
5820 guiApp.cursorUpdate = true;
5822 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5824 guiApp.PreserveAndDrawCursor();
5825 // guiApp.desktop.display.ShowScreen();
5826 guiApp.cursorUpdate = false;
5827 guiApp.desktop.dirty = false;
5828 guiApp.RestoreCursorBackground();
5832 guiApp.desktop.display.Unlock();
5833 guiApp.desktop.mutex.Release();
5837 Window rootWindow = this.rootWindow;
5838 rootWindow.mutex.Wait();
5843 guiApp.SignalEvent();
5846 guiApp.waitMutex.Wait();
5847 guiApp.interfaceDriver.Lock(rootWindow);
5848 if(!rootWindow.style.hidden && rootWindow.dirty)
5850 if(rootWindow.display)
5852 rootWindow.UpdateDisplay();
5853 //rootWindow.display.ShowScreen(null);
5855 rootWindow.dirty = false;
5857 guiApp.interfaceDriver.Unlock(rootWindow);
5858 guiApp.waitMutex.Release();
5861 rootWindow.mutex.Release();
5866 void UnlockDisplay(void)
5868 guiApp.interfaceDriver.Unlock(rootWindow);
5871 void LockDisplay(void)
5873 guiApp.interfaceDriver.Lock(rootWindow);
5876 Surface GetSurface(Box box)
5878 return Redraw((box == null) ? this.box : box);
5881 void SetMousePosition(int x, int y)
5883 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5887 void IntegrationActivate(bool active)
5889 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5891 isForegroundWindow = true;
5892 ActivateEx(active, active, false, false, null, null);
5893 isForegroundWindow = false;
5898 Window QueryCapture(void)
5900 return guiApp.windowCaptured;
5903 int GetDocumentID(void)
5907 byte * idBuffer = new0 byte[size];
5910 for(child = children.first; child; child = child.next)
5912 // TO CHECK: Do we want a documentID when we already have a file name?
5913 if(child.style.isDocument && !child.fileName)
5915 if(child.documentID-1 > size - 2)
5917 idBuffer = renew0 idBuffer byte[size*2];
5918 memset(idBuffer + size, 0, size);
5921 idBuffer[child.documentID-1] = 1;
5924 for(c = 0; c<size; c++)
5932 void SetInitSize(Size size)
5935 sizeAnchor.size = size;
5936 normalSizeAnchor = sizeAnchor;
5938 // Break the anchors for moveable/resizable windows
5939 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5941 stateAnchor = normalAnchor;
5942 stateSizeAnchor = normalSizeAnchor;
5944 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5945 Position(x,y, w, h, true, true, true, true, false, true);
5949 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5951 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5953 guiApp.windowIsResizing = resize;
5954 guiApp.windowMoving = this;
5955 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5956 if(guiApp.windowIsResizing)
5958 guiApp.windowMovingStart.x += size.w - 1;
5959 guiApp.windowMovingStart.y += size.h - 1;
5961 guiApp.windowMovingBefore = scrolledPos;
5962 guiApp.windowResizingBefore = size;
5963 guiApp.windowMoving.UpdateDecorations();
5964 if(guiApp.windowIsResizing)
5965 guiApp.resizeEndX = guiApp.resizeEndY = true;
5967 if(setCursorPosition)
5968 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5972 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5973 guiApp.windowMovingStart.x += x - absPosition.x;
5974 guiApp.windowMovingStart.y += y - absPosition.y;
5977 if(guiApp.windowMoving)
5979 if(guiApp.windowMoving.style.nonClient)
5980 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5982 guiApp.windowMoving.parent.SetMouseRangeToClient();
5987 if(this == rootWindow)
5988 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
5996 bool result = false;
6000 else if(guiApp && guiApp.driver != null)
6002 void * systemParent = null;
6003 OldLink slaveHolder;
6005 bool visible = !style.hidden;
6009 systemParent = parent;
6010 parent = guiApp.desktop;
6012 last = parent ? parent.children.last : null;
6014 if((parent && parent != guiApp.desktop && !parent.created) ||
6015 (master && master != guiApp.desktop && !master.created))
6019 stopwatching(parent, font);
6022 property::parent = guiApp.desktop;
6023 if(!master) master = parent;
6025 if(_isModal && master.modalSlave)
6026 property::master = master.modalSlave;
6030 parent.children.Remove(this);
6033 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6034 if(slaveHolder.data == this)
6036 master.slaves.Delete(slaveHolder);
6041 if(parent == guiApp.desktop && !mutex)
6044 if(style.isDocument)
6047 parent.numDocuments--;
6048 documentID = parent.GetDocumentID();
6051 if(!style.stayOnTop)
6052 for(; last && last.style.stayOnTop; last = last.prev);
6054 parent.children.Insert((last == this) ? null : last, this);
6055 //parent.children.Add(this);
6058 dispDriver = parent.dispDriver;
6061 master.modalSlave = this;
6063 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6068 master.slaves.Add(slaveHolder = OldLink { data = this });
6073 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6075 if(style.isDefault && !master.defaultControl)
6076 master.defaultControl = this;
6078 stateAnchor = normalAnchor = anchor;
6079 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6081 // TOCHECK: Why is this here?
6082 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6083 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6085 this.visible = false;
6086 style.hidden = true;
6089 // autoCreate = true;
6097 if(parent == guiApp.desktop)
6098 Log("LoadGraphics %s\n", caption);
6100 if(LoadGraphics(true, false))
6108 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6115 if(style.hasMenuBar /*&& menu*/)
6121 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6122 interim = false, inactive = true, nonClient = true, size.h = 24
6130 // Create the system buttons
6131 CreateSystemChildren();
6133 UpdateActiveDocument(null);
6135 if(style.isDocument)
6139 MenuItem item = menu.FindItem(MenuFileSave, 0);
6140 if(item) item.disabled = !modifiedDocument && fileName;
6145 if(parent == guiApp.desktop)
6146 Log("Preemptive SetState %s\n", caption);
6149 // Preemptive Set State to ensure proper anchoring
6150 SetStateEx(state, false);
6152 style.hidden = true;
6158 for(child = children.first; child; child = next)
6161 if(!child.created && (child.autoCreate || child.wasCreated))
6168 for(link = slaves.first; link; link = next)
6170 Window slave = link.data;
6172 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6175 // Things might have happened that invalidated 'next'...
6176 // Start over the search for slaves to create.
6177 // (Added this to fix crash with Stacker & Toolbar)
6178 next = slaves.first;
6187 if(parent == guiApp.desktop)
6188 Log("Real SetState %s\n", caption);
6191 if(isActiveClient && visible)
6193 parent.numPositions--;
6194 if(state == minimized) parent.numIcons--;
6197 // Real set state & activate for proper display & activation
6198 property::visible = visible;
6199 // SetState(state & 0x00000003, true, 0);
6200 guiApp.interfaceDriver.SetIcon(this, icon);
6205 /*if(rootWindow == this)
6206 guiApp.interfaceDriver.ActivateRootWindow(this);
6208 if(creationActivation == activate)
6209 ActivateEx(true, false, true, true, null, null);
6210 else if(creationActivation == flash)
6215 rootWindow.ConsequentialMouseMove(false);
6226 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6232 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6234 //style.hidden = true; // !visible;
6235 style.hidden = !visible;
6236 if(master.modalSlave == this)
6237 master.modalSlave = null;
6244 void WriteCaption(Surface surface, int x, int y)
6247 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6250 void Update(Box region)
6256 rootWindow = this.rootWindow;
6258 // rootWindow.mutex.Wait();
6259 if(!destroyed && visible && display)
6264 // Testing this to avoid repetitve full update to take time...
6265 if(dirtyArea.count == 1)
6267 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6268 if(item.box.left <= box.left &&
6269 item.box.top <= box.top &&
6270 item.box.right >= box.right &&
6271 item.box.bottom >= box.bottom)
6273 rootWindow.dirty = true;
6278 if(display.flags.flipping && !rootWindow.dirty)
6280 if(this == rootWindow)
6284 rootWindow.Update(null);
6289 rootWindow.dirty = true;
6294 realBox.left += clientStart.x;
6295 realBox.top += clientStart.y;
6296 realBox.right += clientStart.x;
6297 realBox.bottom += clientStart.y;
6303 if(realBox.right >= realBox.left &&
6304 realBox.bottom >= realBox.top)
6306 // if(!rootWindow.fullRender)
6307 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6309 for(child = children.first; child; child = child.next)
6314 box.left -= child.absPosition.x - absPosition.x;
6315 box.top -= child.absPosition.y - absPosition.y;
6316 box.right -= child.absPosition.x - absPosition.x;
6317 box.bottom -= child.absPosition.y - absPosition.y;
6318 if(box.right >= child.box.left && box.left <= child.box.right &&
6319 box.bottom >= child.box.top && box.top <= child.box.bottom)
6321 box.left -= child.clientStart.x;
6322 box.top -= child.clientStart.y;
6323 box.right -= child.clientStart.x;
6324 box.bottom -= child.clientStart.y;
6330 realBox.left += absPosition.x - rootWindow.absPosition.x;
6331 realBox.top += absPosition.y - rootWindow.absPosition.y;
6332 realBox.right += absPosition.x - rootWindow.absPosition.x;
6333 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6334 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6337 else if(this == guiApp.desktop)
6340 for(window = children.first; window; window = window.next)
6346 Box childBox = region;
6348 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6349 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6350 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6351 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6353 window.Update(childBox);
6356 window.Update(null);
6361 // rootWindow.mutex.Release();
6368 if(guiApp.windowCaptured != this)
6370 if(guiApp.windowCaptured)
6374 //Logf("Captured %s (%s)\n", caption, class.name);
6375 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6376 guiApp.windowCaptured = this;
6382 bool Destroy(int code)
6387 if(!destroyed && !CloseConfirmation(false)) return false;
6391 // TOCHECK: Should autoCreate be set to false here?
6402 void Move(int x, int y, int w, int h)
6404 normalAnchor = Anchor { left = x, top = y };
6405 normalSizeAnchor = SizeAnchor { size = { w, h } };
6407 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6409 if(destroyed) return;
6411 stateAnchor = normalAnchor;
6412 stateSizeAnchor = normalSizeAnchor;
6414 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6415 Position(x,y, w, h, true, true, true, true, false, true);
6419 DialogResult Modal(void)
6425 // FIXES MEMORY LEAK IF Create() FAILED
6431 void SetScrollArea(int width, int height, bool snapToStep)
6433 bool resize = false;
6436 int stepX = sbStep.x, stepY = sbStep.y;
6437 // Needed to make snapped down position match the skin's check of client area
6438 // against realvirtual
6441 SNAPDOWN(stepX, textCellW);
6442 SNAPDOWN(stepY, textCellH);
6443 stepX = Max(stepX, textCellW);
6444 stepY = Max(stepY, textCellH);
6446 if(scrollFlags.snapX)
6447 SNAPUP(width, stepX);
6448 if(scrollFlags.snapY)
6449 SNAPUP(height, stepY);
6452 reqScrollArea.w = width;
6453 reqScrollArea.h = height;
6454 noAutoScrollArea = (width > 0 || height > 0);
6456 UpdateScrollBars(true, true);
6459 void SetScrollPosition(int x, int y)
6462 sbh.Action(setPosition, x, 0);
6466 int seen = clientSize.w, total = reqScrollArea.w;
6468 if(scrollFlags.snapX)
6469 SNAPDOWN(seen, sbStep.x);
6471 if(!total) total = seen;
6472 range = total - seen + 1;
6473 range = Max(range, 1);
6475 if(x >= range) x = range - 1;
6477 if(scrollFlags.snapX)
6478 SNAPUP(x, sbStep.x);
6481 OnHScroll(setPosition, x, 0);
6485 SNAPDOWN(x, textCellW);
6491 sbv.Action(setPosition, y, 0);
6495 int seen = clientSize.h, total = reqScrollArea.h;
6498 if(scrollFlags.snapY)
6499 SNAPDOWN(seen, sbStep.y);
6501 if(!total) total = seen;
6502 range = total - seen + 1;
6503 range = Max(range, 1);
6505 if(y >= range) y = range - 1;
6507 if(scrollFlags.snapY)
6508 SNAPUP(y, sbStep.y);
6511 OnVScroll(setPosition, y, 0);
6514 SNAPDOWN(y, textCellH);
6519 UpdateCaret(false, false);
6522 void SetScrollLineStep(int stepX, int stepY)
6528 SNAPDOWN(stepX, textCellW);
6529 SNAPDOWN(stepY, textCellH);
6530 stepX = Max(stepX, textCellW);
6531 stepY = Max(stepY, textCellH);
6534 sbh.lineStep = stepX;
6536 sbv.lineStep = stepY;
6539 void SetState(WindowState newState, bool activate, Modifiers mods)
6543 if(state == newState || OnStateChange(newState, mods))
6545 WindowState prevState = state;
6549 // This used to be at the end of the brackets... moved for X, testing...
6550 // This has the effect of activating the window through the system...
6551 if(rootWindow == this)
6552 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6554 SetStateEx(newState, activate);
6556 if(rootWindow == this && !rootWindow.nativeDecorations)
6558 int x = position.x, y = position.y;
6561 x -= guiApp.desktop.absPosition.x;
6562 y -= guiApp.desktop.absPosition.y;
6564 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6568 //state = prevState;
6570 if(state != maximized && style.hasMaximize)
6573 for(child = parent.children.first; child; child = child.next)
6575 if(child != this && child.state == maximized)
6576 child.SetStateEx(normal, false);
6580 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6581 parent.UpdateScrollBars(true, true);
6584 // Do we really need this stuff here?
6585 // Shouldn't the Activate stuff take care of it?
6586 if(parent.rootWindow == parent && style)
6589 parent.FigureCaption(caption);
6590 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6591 parent.UpdateDecorations();
6595 rootWindow.ConsequentialMouseMove(false);
6602 BitmapResource GetIcon(SkinBitmap iconID)
6604 return guiApp.currentSkin.GetBitmap(iconID);
6607 void SetMouseRange(Box range)
6609 if(range || guiApp.fullScreenMode)
6614 clip.left = range.left + absPosition.x + clientStart.x;
6615 clip.top = range.top + absPosition.y + clientStart.y;
6616 clip.right = range.right + absPosition.x + clientStart.x;
6617 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6621 clip.left = guiApp.desktop.box.left;
6622 clip.top = guiApp.desktop.box.top;
6623 clip.right = guiApp.desktop.box.right;
6624 clip.bottom = guiApp.desktop.box.bottom;
6626 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6629 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6632 void SetMouseRangeToClient(void)
6634 if(guiApp.fullScreenMode || this != guiApp.desktop)
6636 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6637 box.Clip(clientArea);
6641 SetMouseRange(null);
6644 void SetMouseRangeToWindow(void)
6646 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6647 if(this == guiApp.desktop)
6648 SetMouseRangeToClient();
6653 // x, y: Desktop Coordinates
6654 void ShowSysMenu(int x, int y)
6657 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6660 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6661 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6665 menu, $"Move", m, NotifySelect = MenuWindowMove,
6666 disabled = !style.fixed || state == maximized
6670 menu, $"Size", s, NotifySelect = MenuWindowSize,
6671 disabled = !style.sizable || state != normal
6675 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6676 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6680 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6681 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6685 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6686 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6688 MenuDivider { menu };
6691 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6692 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6694 windowMenu.Create();
6699 ActivateEx(true, true, true, true, null, null);
6702 void MakeActive(void)
6704 ActivateEx(true, false, true, false, null, null);
6707 void SoftActivate(void)
6709 if(guiApp.desktop.active)
6715 void Deactivate(void)
6717 ActivateEx(false, true, true, true, null, null);
6722 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6725 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6727 bool result = false;
6728 if(activeChild && activeChild.cycle)
6730 Window modalWindow, child = activeChild;
6731 if(!clientOnly /*&& parent.tabCycle*/)
6733 Window next = child;
6736 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6740 if(parent && parent.CycleChildren(backward, false, true, true))
6748 next = next.cycle.prev.data;
6750 next = next.cycle.next.data;
6751 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6756 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6757 parent.tabCycle && parent.CycleChildren(backward, false, false))
6761 if(tabCycleOnly && !tabCycle) return false;
6768 child = child.cycle.prev.data;
6770 child = child.cycle.next.data;
6771 if(child == child.parent.activeChild)
6773 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6776 modalWindow = child.FindModal();
6779 // Scroll the window to include the active control
6780 if(sbh && !child.style.dontScrollHorz)
6782 if(child.scrolledPos.x < 0)
6783 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6784 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6785 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6787 if(sbv && !child.style.dontScrollVert)
6789 if(child.scrolledPos.y < 0)
6790 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6791 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6792 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6796 child = modalWindow ? modalWindow : child;
6797 child.ActivateEx(true, true, true, true, null, null);
6798 if(child.tabCycle && child.childrenCycle.first)
6799 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6807 ConsequentialMouseMove(false);
6811 void AddResource(Resource resource)
6815 ResPtr ptr { resource = resource };
6819 // Load Graphics here if window is created already
6820 if(/*created && */display)
6822 display.Lock(false);
6823 ptr.loaded = display.displaySystem.LoadResource(resource);
6827 // Temporary hack to load font right away for listbox in dropbox ...
6828 else if(master && master.display)
6830 master.display.Lock(false);
6831 master.display.displaySystem.LoadResource(resource);
6832 master.display.Unlock();
6838 void RemoveResource(Resource resource)
6843 for(ptr = resources.first; ptr; ptr = ptr.next)
6845 if(ptr.resource == resource)
6851 // Unload Graphics here if window is created already
6852 if(/*created && */display)
6856 display.Lock(false);
6857 display.displaySystem.UnloadResource(resource, ptr.loaded);
6863 resources.Delete(ptr);
6868 void SetCaret(int x, int y, int size)
6875 if(active && !style.interim)
6877 if(visible || !guiApp.caretOwner)
6878 guiApp.caretOwner = size ? this : null;
6880 UpdateCaret(false, false);
6883 guiApp.interfaceDriver.SetCaret(0,0,0);
6884 UpdateCaret(false, true);
6885 guiApp.caretEnabled = false;
6888 else if(style.inactive && active)
6890 guiApp.interfaceDriver.SetCaret(0,0,0);
6891 UpdateCaret(false, true);
6892 guiApp.caretEnabled = false;
6897 void Scroll(int x, int y)
6899 bool opaque = !style.drawBehind || background.a;
6900 if(opaque && display && display.flags.scrolling)
6902 Box box = clientArea;
6903 box.left += clientStart.x;
6904 box.top += clientStart.y;
6905 box.right += clientStart.x;
6906 box.bottom += clientStart.y;
6908 //scrollExtent.Free(null);
6909 scrollExtent.AddBox(box);
6910 scrolledArea.x += x;
6911 scrolledArea.y += y;
6913 //scrollExtent.Free();
6914 //scrollExtent.AddBox(clientArea);
6915 //scrollExtent.Offset(clientStart.x, clientStart.y);
6916 //scrolledArea.x = x;
6917 //scrolledArea.y = y;
6923 rootWindow.dirty = true;
6926 void ReleaseCapture()
6928 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6930 Window oldCaptured = guiApp.windowCaptured;
6931 guiApp.windowCaptured = null;
6932 guiApp.prevWindow = null;
6935 //guiApp.Log("Released Capture\n");
6937 guiApp.interfaceDriver.SetMouseCapture(null);
6939 //oldCaptured.OnMouseCaptureLost();
6942 oldCaptured.ConsequentialMouseMove(false);
6947 void SetText(char * format, ...)
6954 char caption[MAX_F_STRING];
6956 va_start(args, format);
6957 vsprintf(caption, format, args);
6960 this.caption = new char[strlen(caption)+1];
6962 strcpy(this.caption, caption);
6971 bool Grab(Bitmap bitmap, Box box, bool decorations)
6973 bool result = false;
6974 if(display || this == guiApp.desktop)
6976 Box clip = {MININT, MININT, MAXINT, MAXINT};
6982 clip.Clip(clientArea);
6984 clip.Clip(this.box);
6986 if(rootWindow != this)
6988 clip.left += absPosition.y;
6989 clip.top += absPosition.y;
6990 clip.right += absPosition.x;
6991 clip.bottom += absPosition.y;
6994 clip.left += decorations ? 0 : clientStart.x;
6995 clip.top += decorations ? 0 : clientStart.y;
6996 clip.right += decorations ? 0 : clientStart.x;
6997 clip.bottom += decorations ? 0 : clientStart.y;
6999 if(display && display.flags.flipping)
7001 rootWindow.Update(null);
7002 rootWindow.UpdateDisplay();
7009 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7010 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7014 result = display.Grab(bitmap, clip.left, clip.top,
7015 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7017 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7019 if(!bitmap.Convert(null, pixelFormat888, null))
7026 void GetMousePosition(int * x, int * y)
7028 int mouseX = 0, mouseY = 0;
7029 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7032 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7033 if(this != guiApp.desktop)
7035 mouseX -= absPosition.x + clientStart.x;
7036 mouseY -= absPosition.y + clientStart.y;
7043 DialogResult DoModal()
7045 DialogResult returnCode = 0;
7046 int terminated = terminateX;
7049 while(!destroyed && guiApp.driver != null)
7051 if(terminateX != terminated)
7053 terminated = terminateX;
7054 guiApp.desktop.Destroy(0);
7055 if(guiApp.desktop.created)
7058 //printf("Resetting terminate X to 0\n");
7064 guiApp.UpdateDisplay();
7065 if(!guiApp.ProcessInput(false))
7068 returnCode = this.returnCode;
7081 return !destroyed && guiApp.driver != null && terminateX < 2;
7084 DialogResult DoModalEnd()
7086 DialogResult returnCode = this.returnCode;
7091 // --- Window manipulation ---
7092 /*bool GetDisabled()
7094 bool disabled = this.disabled;
7096 for(window = this; (window = window.master); )
7107 // --- Mouse Manipulation ---
7108 void GetNCMousePosition(int * x, int * y)
7110 GetMousePosition(x, y);
7111 if(x) *x += clientStart.x;
7112 if(y) *y += clientStart.y;
7115 // --- Carets manipulation ---
7116 void GetCaretPosition(Point caretPos)
7118 caretPos = this.caretPos;
7121 int GetCaretSize(void)
7126 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7132 bool CloseConfirmation(bool parentClosing)
7145 if(!OnClose(parentClosing))
7148 // If you want to skip this, simply set modifiedDocument to false in OnClose
7149 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7151 DialogResult dialogRes;
7154 sprintf(message, $"Save changes to %s?", fileName);
7156 sprintf(message, $"Save changes to Untitled %d?", documentID);
7158 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7160 if(dialogRes == yes)
7162 // TOFIX: Precomp error if brackets are taken out
7163 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7165 else if(dialogRes == cancel)
7171 for(slave = slaves.first; slave; slave = slave.next)
7173 Window w = slave.data;
7174 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7176 // ((Window)slave.data).CloseConfirmation(true);
7185 for(child = children.first; child; child = child.next)
7186 if(child.master != this && !child.CloseConfirmation(true))
7196 // Static methods... move them somewhere else?
7197 void ::RestoreCaret()
7199 if(guiApp.caretOwner)
7200 guiApp.caretOwner.UpdateCaret(false, false);
7203 void ::FreeMouseRange()
7205 guiApp.interfaceDriver.SetMouseRange(null, null);
7209 bool MenuFileClose(MenuItem selection, Modifiers mods)
7211 Window document = activeChild;
7213 document.Destroy(0);
7217 bool MenuFileExit(MenuItem selection, Modifiers mods)
7223 bool MenuFileSave(MenuItem selection, Modifiers mods)
7227 fileMonitor.fileName = null;
7230 if(OnSaveFile(fileName))
7232 //if(OnFileModified != Window::OnFileModified)
7235 fileMonitor.fileName = fileName;
7241 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7242 DialogResult answer = dialog.Modal();
7244 if(answer != yes) return (bool)answer;
7247 return MenuFileSaveAs(selection, mods);
7250 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7252 DialogResult result = (DialogResult)bool::true;
7253 FileDialog fileDialog = saveDialog;
7256 fileDialog = FileDialog {};
7261 fileDialog.filePath = fileName;
7264 char filePath[MAX_FILENAME];
7265 sprintf(filePath, "Untitled %d", documentID);
7266 fileDialog.filePath = filePath;
7268 fileMonitor.fileName = null;
7270 fileDialog.type = save;
7271 fileDialog.text = $"Save As";
7275 fileDialog.master = master.parent ? master : this;
7276 if(fileDialog.Modal() == ok)
7278 char * filePath = fileDialog.filePath;
7280 if(OnSaveFile(filePath))
7283 property::fileName = filePath;
7284 NotifySaved(master, this, filePath);
7289 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7290 DialogResult answer = dialog.Modal();
7305 //if(OnFileModified != Window::OnFileModified && fileName)
7308 fileMonitor.fileName = fileName;
7312 return (bool)result; // Actually returning result from Yes/NoCancel message box
7315 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7317 Window document = activeChild;
7319 for(document = children.first; document; document = next)
7321 next = document.next;
7322 if(document.style.isDocument || document.fileName)
7323 document.MenuFileSave(selection, mods);
7328 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7332 for(document = children.first; document; document = document.next)
7333 //if(document.style.isDocument && document.state == minimized)
7334 if(document.style.isActiveClient && document.state == minimized)
7335 document.SetState(minimized, false, mods);
7339 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7341 Window document = activeChild;
7344 Window firstDocument = null;
7346 OldLink cycle = document.cycle.prev;
7351 if(child.style.isActiveClient && !child.style.hidden)
7355 firstDocument = child;
7356 if(child.state == minimized)
7357 child.SetState(minimized, false, mods);
7360 child.positionID = id++;
7361 child.SetState(normal, false, mods);
7362 child.anchor.left.type = cascade;
7365 child.normalSizeAnchor = *&child.sizeAnchor;
7366 child.normalAnchor = child.anchor;
7368 // Break the anchors for moveable/resizable windows
7369 if(child.style.fixed)
7371 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7373 (*&child.normalAnchor).left = x;
7374 (*&child.normalAnchor).top = y;
7375 (*&child.normalAnchor).right.type = none;
7376 (*&child.normalAnchor).bottom.type = none;
7378 child.normalSizeAnchor.isClientW = false;
7379 child.normalSizeAnchor.isClientH = false;
7380 child.normalSizeAnchor.size.w = w;
7381 child.normalSizeAnchor.size.h = h;
7382 child.anchored = false;
7385 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7387 child.stateAnchor = child.normalAnchor;
7388 child.stateSizeAnchor = child.normalSizeAnchor;
7390 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7391 child.Position(x, y, w, h, true, true, true, true, false, false);
7396 last = children.last;
7397 if(!child.style.stayOnTop)
7398 for(; last && last.style.stayOnTop; last = last.prev);
7399 children.Move(child, last);
7400 childrenOrder.Move(child.order, childrenOrder.last);
7402 if(cycle == document.cycle) break;
7406 firstDocument.Activate();
7411 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7418 // Close all closes all active clients, not all documents
7419 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7421 Window next, document;
7423 for(document = children.first; document; document = next)
7425 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7426 if(document.style.isActiveClient)
7427 if(!document.Destroy(0) && !document.style.hidden)
7433 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7435 if(style.hasMaximize && state != maximized)
7436 SetState(maximized, 0, 0);
7440 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7442 if(style.hasMinimize && state != minimized)
7444 SetState(minimized, 0, 0);
7445 parent.CycleChildren(false, true, false, true);
7450 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7452 MenuMoveOrSize(false, selection ? true : false);
7456 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7458 CycleChildren(false, true, false, true);
7462 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7464 CycleChildren(true, true, false, true);
7468 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7470 MenuMoveOrSize(true, true);
7474 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7477 SetState(normal, 0, 0);
7481 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7484 int id = selection.id;
7485 OldLink cycle = activeClient.cycle;
7487 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7490 Window sibling = cycle.data;
7491 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7499 document = cycle.data;
7500 document.Activate();
7502 //if(activeChild.state == maximized)
7503 // document.SetState(maximized, false, mods);
7504 //else if(document.state == minimized)
7505 // document.SetState(normal, false, mods);
7509 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7511 stayOnTop = !style.stayOnTop;
7515 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7517 Window document = activeChild;
7520 Window firstDocument = null;
7521 OldLink cycle = document.cycle;
7525 Window child = cycle.data;
7526 if(child.style.isActiveClient && !child.style.hidden)
7528 if(!firstDocument) firstDocument = child;
7529 if(child.state == minimized)
7530 child.SetState(minimized, false, mods);
7533 child.positionID = id++;
7534 child.SetState(normal, false, mods);
7535 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7537 child.anchor.left.type = hTiled;
7540 child.normalSizeAnchor = *&child.sizeAnchor;
7541 child.normalAnchor = child.anchor;
7543 // Break the anchors for moveable/resizable windows
7544 if(child.style.fixed)
7546 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7548 (*&child.normalAnchor).left = x;
7549 (*&child.normalAnchor).top = y;
7550 (*&child.normalAnchor).right.type = none;
7551 (*&child.normalAnchor).bottom.type = none;
7552 child.normalSizeAnchor.isClientW = false;
7553 child.normalSizeAnchor.isClientH = false;
7554 child.normalSizeAnchor.size.w = w;
7555 child.normalSizeAnchor.size.h = h;
7556 child.anchored = false;
7559 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7561 child.stateAnchor = child.normalAnchor;
7562 child.stateSizeAnchor = child.normalSizeAnchor;
7564 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7565 child.Position(x,y, w, h, true, true, true, true, false, true);
7570 if((cycle = cycle.next) == document.cycle) break;
7573 firstDocument.Activate();
7578 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7580 Window document = activeChild;
7583 Window firstDocument = null;
7585 OldLink cycle = document.cycle;
7590 //if(child.style.isDocument)
7591 if(child.style.isActiveClient && !child.style.hidden)
7593 if(!firstDocument) firstDocument = child;
7594 if(child.state == minimized)
7595 child.SetState(minimized, false, mods);
7598 child.positionID = id++;
7599 child.SetState(normal, false, mods);
7600 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7602 child.anchor.left.type = vTiled;
7605 child.normalSizeAnchor = *&child.sizeAnchor;
7606 child.normalAnchor = child.anchor;
7608 // Break the anchors for moveable/resizable windows
7609 if(child.style.fixed)
7611 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7613 (*&child.normalAnchor).left = x;
7614 (*&child.normalAnchor).top = y;
7615 (*&child.normalAnchor).right.type = none;
7616 (*&child.normalAnchor).bottom.type = none;
7617 child.normalSizeAnchor.isClientW = false;
7618 child.normalSizeAnchor.isClientH = false;
7619 child.normalSizeAnchor.size.w = w;
7620 child.normalSizeAnchor.size.h = h;
7621 child.anchored = false;
7624 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7626 child.stateAnchor = child.normalAnchor;
7627 child.stateSizeAnchor = child.normalSizeAnchor;
7629 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7630 child.Position(x,y, w, h, true, true, true, true, false, true);
7635 if((cycle = cycle.next) == document.cycle) break;
7638 firstDocument.Activate();
7643 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7645 WindowList dialog { master = this };
7646 Window document = (Window)dialog.Modal();
7649 if(activeChild.state == maximized)
7650 document.SetState(maximized, false, mods);
7651 else if(document.state == minimized)
7652 document.SetState(normal, false, mods);
7653 document.Activate();
7659 virtual bool OnCreate(void);
7660 virtual void OnDestroy(void);
7661 virtual void OnDestroyed(void);
7662 virtual bool OnClose(bool parentClosing);
7663 virtual bool OnStateChange(WindowState state, Modifiers mods);
7664 virtual bool OnPostCreate(void);
7665 virtual bool OnMoving(int *x, int *y, int w, int h);
7666 virtual bool OnResizing(int *width, int *height);
7667 virtual void OnResize(int width, int height);
7668 virtual void OnPosition(int x, int y, int width, int height);
7669 virtual bool OnLoadGraphics(void);
7670 virtual void OnApplyGraphics(void);
7671 virtual void OnUnloadGraphics(void);
7672 virtual void OnRedraw(Surface surface);
7673 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7674 virtual void OnActivateClient(Window client, Window previous);
7675 virtual bool OnKeyDown(Key key, unichar ch);
7676 virtual bool OnKeyUp(Key key, unichar ch);
7677 virtual bool OnKeyHit(Key key, unichar ch);
7678 virtual bool OnSysKeyDown(Key key, unichar ch);
7679 virtual bool OnSysKeyUp(Key key, unichar ch);
7680 virtual bool OnSysKeyHit(Key key, unichar ch);
7681 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7682 virtual bool OnMouseLeave(Modifiers mods);
7683 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7684 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7685 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7686 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7687 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7688 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7689 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7690 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7691 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7692 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7693 virtual void OnMouseCaptureLost(void);
7694 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7695 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7696 virtual void OnDrawOverChildren(Surface surface);
7697 virtual bool OnFileModified(FileChange fileChange, char * param);
7698 virtual bool OnSaveFile(char * fileName);
7700 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7701 // Note: A 'client' would refer to isActiveClient, rather than
7702 // being confined to the 'client area' (nonClient == false)
7703 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7704 virtual void OnChildVisibilityToggled(Window child, bool visible);
7705 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7707 // Skins Virtual Functions
7708 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7709 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7710 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7715 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7716 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7717 virtual bool IsMouseMoving(int x, int y, int w, int h);
7718 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY);
7719 virtual void UpdateNonClient();
7720 virtual void SetBox(Box box);
7721 virtual bool IsInside(int x, int y)
7723 return box.IsPointInside({x, y});
7725 virtual bool IsOpaque()
7727 return (!style.drawBehind || background.a == 255);
7731 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7732 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7733 virtual void Window::NotifySaved(Window window, char * filePath);
7738 property Window parent
7740 property_category $"Layout"
7743 if(value || guiApp.desktop)
7746 Window oldParent = parent;
7747 Anchor anchor = this.anchor;
7749 if(value && value.IsDescendantOf(this)) return;
7750 if(value && value == this)
7752 if(!value) value = guiApp.desktop;
7754 if(value == oldParent) return;
7756 if(!master || (master == this.parent && master == guiApp.desktop))
7757 property::master = value;
7761 parent.children.Remove(this);
7762 parent.OnChildAddedOrRemoved(this, true);
7766 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7767 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7768 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7769 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7773 last = value.children.last;
7775 if(style.isDocument)
7778 parent.numDocuments--;
7779 documentID = value.GetDocumentID();
7782 if(style.isActiveClient && !style.hidden)
7784 if(parent && parent != guiApp.desktop && !(style.hidden))
7786 if(state == minimized) parent.numIcons--;
7787 parent.numPositions--;
7791 if(!style.stayOnTop)
7792 for(; last && last.style.stayOnTop; last = last.prev);
7794 value.children.Insert(last, this);
7796 // *** NEW HERE: ***
7798 parent.childrenCycle.Delete(cycle);
7800 parent.childrenOrder.Delete(order);
7803 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7804 // Should something else be done?
7805 if(parent && parent.activeChild == this)
7806 parent.activeChild = null;
7807 if(parent && parent.activeClient == this)
7808 parent.activeClient = null;
7814 int x = position.x, y = position.y, w = size.w, h = size.h;
7818 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7819 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7821 vpw = value.clientSize.w;
7822 vph = value.clientSize.h;
7828 else if(style.fixed)
7830 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7831 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7834 anchor = this.anchor;
7836 if(anchor.left.type == offset) anchor.left.distance = x;
7837 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7838 if(anchor.top.type == offset) anchor.top.distance = y;
7839 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7840 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7841 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7842 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7843 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7844 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7845 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7847 if(!anchor.left.type && !anchor.right.type)
7849 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7850 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7852 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7853 if(!anchor.top.type && !anchor.bottom.type)
7855 anchor.vert.distance = (y + h / 2) - (vph / 2);
7856 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7858 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7861 parent.OnChildAddedOrRemoved(this, false);
7867 parent.childrenCycle.Insert(
7868 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7869 cycle = OldLink { data = this });
7870 parent.childrenOrder.Insert(
7871 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7872 order = OldLink { data = this });
7875 if(!style.hidden && style.isActiveClient)
7877 positionID = parent.GetPositionID(this);
7878 parent.numPositions++;
7879 if(state == minimized) parent.numIcons--;
7882 // *** FONT INHERITANCE ***
7883 if(!setFont && oldParent)
7884 stopwatching(oldParent, font);
7888 RemoveResource(systemFont);
7891 // TESTING WITH WATCHERS:
7892 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7893 // usedFont = setFont ? setFont : (systemFont);
7897 if(guiApp.currentSkin)
7899 systemFont = guiApp.currentSkin.SystemFont();
7902 usedFont = systemFont;
7903 AddResource(systemFont);
7911 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7920 if(value.rootWindow && value.rootWindow.display && rootWindow)
7922 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7923 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7926 UnloadGraphics(false);
7929 LoadGraphics(false, false);
7932 if(value.rootWindow != rootWindow)
7933 DisplayModeChanged();
7937 scrolledPos.x = MININT; // Prevent parent update
7938 property::anchor = anchor;
7942 if(guiApp.currentSkin)
7943 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7945 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7946 Position(x, y, w, h, true, true, true, true, false, true);
7951 // else parent = value;
7954 get { return parent; }
7957 property Window master
7959 property_category $"Behavior"
7962 //if(this == value) return;
7963 if(value && value.IsSlaveOf(this)) return;
7969 OldLink slaveHolder;
7970 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7971 if(slaveHolder.data == this)
7973 master.slaves.Delete(slaveHolder);
7980 value.slaves.Add(OldLink { data = this });
7985 master.hotKeys.Remove(hotKey);
7986 value.hotKeys.Add(hotKey);
7989 if(master && master.defaultControl == this)
7990 master.defaultControl = null;
7992 if(style.isDefault && !value.defaultControl)
7993 value.defaultControl = this;
7998 get { return master ? master : parent; }
8001 property char * caption
8003 property_category $"Appearance"
8010 caption = new char[strlen(value)+1];
8012 strcpy(caption, value);
8017 get { return caption; }
8022 property_category $"Behavior"
8031 master.hotKeys.Add(hotKey = HotKeySlot { });
8035 hotKey.window = this;
8040 master.hotKeys.Delete(hotKey);
8045 get { return hotKey ? hotKey.key : 0; }
8048 property Color background
8050 property_category $"Appearance"
8053 background.color = value;
8058 if(this == rootWindow)
8059 guiApp.interfaceDriver.SetRootWindowColor(this);
8062 get { return background.color; }
8065 property Percentage opacity
8067 property_category $"Appearance"
8070 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8071 drawBehind = (background.a == 255) ? false : true;
8073 get { return background.a / 255.0f; }
8076 property Color foreground
8078 property_category $"Appearance"
8086 get { return foreground; }
8089 property BorderStyle borderStyle
8091 property_category $"Appearance"
8094 if(!((BorderBits)value).fixed)
8096 style.hasClose = false;
8097 style.hasMaximize = false;
8098 style.hasMinimize = false;
8099 nativeDecorations = false;
8101 style.borderBits = value;
8105 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8107 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8108 Position(x, y, w, h, true, true, true, true, false, true);
8109 CreateSystemChildren();
8112 get { return (BorderStyle)style.borderBits; }
8115 property Size minClientSize
8117 property_category $"Layout"
8118 set { minSize = value; }
8119 get { value = minSize; }
8122 property Size maxClientSize
8124 property_category $"Layout"
8125 set { maxSize = value; }
8126 get { value = maxSize; }
8129 property bool hasMaximize
8131 property_category $"Window Style"
8134 style.hasMaximize = value;
8135 if(value) { style.fixed = true; style.contour = true; }
8139 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8141 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8142 Position(x, y, w, h, true, true, true, true, false, true);
8144 CreateSystemChildren();
8147 get { return style.hasMaximize; }
8150 property bool hasMinimize
8152 property_category $"Window Style"
8155 style.hasMinimize = value;
8156 if(value) { style.fixed = true; style.contour = true; }
8160 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8162 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8163 Position(x, y, w, h, true, true, true, true, false, true);
8165 CreateSystemChildren();
8168 get { return style.hasMinimize; }
8171 property bool hasClose
8173 property_category $"Window Style"
8176 style.hasClose = value;
8177 if(value) { style.fixed = true; style.contour = true; }
8181 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8182 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8183 Position(x, y, w, h, true, true, true, true, false, true);
8184 CreateSystemChildren();
8187 get { return style.hasClose; }
8190 property bool nonClient
8192 property_category $"Layout"
8195 style.nonClient = value;
8197 style.stayOnTop = true;
8199 get { return style.nonClient; }
8202 property bool inactive
8204 property_category $"Behavior"
8209 // *** NEW HERE: ***
8213 parent.childrenCycle.Delete(cycle);
8215 parent.childrenOrder.Delete(order);
8222 active = false; // true;
8223 if(parent.activeChild == this)
8224 parent.activeChild = null;
8225 if(parent.activeClient == this)
8226 parent.activeClient = null;
8235 parent.childrenCycle.Insert(
8236 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8237 cycle = OldLink { data = this });
8239 parent.childrenOrder.Insert(
8240 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8241 order = OldLink { data = this });
8244 style.inactive = value;
8246 get { return style.inactive; }
8249 property bool clickThrough
8251 property_category $"Behavior"
8252 set { style.clickThrough = value; }
8253 get { return style.clickThrough; }
8256 property bool isRemote
8258 property_category $"Behavior"
8259 set { style.isRemote = value; }
8260 get { return style.isRemote; }
8263 property bool noCycle
8265 property_category $"Behavior"
8266 set { style.noCycle = value; }
8267 get { return style.noCycle; }
8270 property bool isModal
8272 property_category $"Behavior"
8273 set { style.modal = value; }
8274 get { return style.modal; }
8277 property bool interim
8279 property_category $"Behavior"
8280 set { style.interim = value; }
8281 get { return style.interim; }
8284 property bool tabCycle
8286 property_category $"Behavior"
8287 set { style.tabCycle = value; }
8288 get { return style.tabCycle; }
8291 property bool isDefault
8293 property_category $"Behavior"
8301 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8302 if(sibling != this && sibling.style.isDefault)
8303 sibling.style.isDefault = false;*/
8304 if(master.defaultControl)
8305 master.defaultControl.style.isDefault = false;
8306 master.defaultControl = this;
8308 else if(master.defaultControl == this)
8309 master.defaultControl = null;
8313 style.isDefault = value;
8315 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8317 get { return style.isDefault; }
8320 property bool drawBehind
8322 property_category $"Window Style"
8323 set { style.drawBehind = value; }
8324 get { return style.drawBehind; }
8327 property bool hasMenuBar
8329 property_category $"Window Style"
8339 if(created && !menuBar)
8346 anchor = Anchor { top = 23, left = 1, right = 1 },
8348 inactive = true, nonClient = true
8353 else if(created && menuBar)
8358 style.hasMenuBar = value;
8360 get { return style.hasMenuBar; }
8363 property bool hasStatusBar
8365 property_category $"Window Style"
8372 statusBar = StatusBar { this };
8380 style.hasStatusBar = value;
8382 get { return style.hasStatusBar; }
8384 property bool stayOnTop
8386 property_category $"Window Style"
8391 if(created && !style.stayOnTop)
8393 if(rootWindow == this)
8394 guiApp.interfaceDriver.OrderRootWindow(this, true);
8395 else if(parent.children.last != this)
8397 parent.children.Move(this, parent.children.last);
8401 style.stayOnTop = true;
8405 if(created && style.stayOnTop)
8407 if(rootWindow == this)
8408 guiApp.interfaceDriver.OrderRootWindow(this, false);
8415 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8416 order && ((Window)order.data).style.stayOnTop;
8417 order = (order == parent.childrenOrder.first) ? null : order.prev);
8418 last = order ? order.data : null;
8422 for(last = parent.children.last;
8423 last && last.style.stayOnTop;
8427 parent.children.Move(this, last);
8431 style.stayOnTop = false;
8434 get { return style.stayOnTop; }
8439 property_category $"Window Style"
8449 if(menuBar && !value)
8456 if(!menuBar && style.hasMenuBar && value)
8460 this, menu = value, isMenuBar = true,
8461 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8462 inactive = true, nonClient = true
8466 UpdateActiveDocument(null);
8469 get { return menu; }
8472 property FontResource font
8474 property_category $"Appearance"
8476 isset { return setFont ? true : false; }
8481 if(value && !setFont) { stopwatching(parent, font); }
8482 else if(!value && setFont)
8488 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8497 RemoveResource(setFont);
8502 RemoveResource(systemFont);
8509 AddResource(setFont);
8512 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8515 systemFont = guiApp.currentSkin.SystemFont();
8517 usedFont = systemFont;
8518 AddResource(systemFont);
8526 get { return usedFont; }
8529 property SizeAnchor sizeAnchor
8531 property_category $"Layout"
8534 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8535 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8536 sizeAnchor.isClientW != sizeAnchor.isClientH;
8543 normalSizeAnchor = sizeAnchor;
8545 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8547 stateAnchor = normalAnchor;
8548 stateSizeAnchor = normalSizeAnchor;
8550 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8551 Position(x,y, w, h, true, true, true, true, false, true);
8558 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8559 sizeAnchor.isClientW,
8560 sizeAnchor.isClientH
8567 property_category $"Layout"
8570 Anchor thisAnchor = anchor;
8571 SizeAnchor thisSizeAnchor = sizeAnchor;
8572 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8573 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8574 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8575 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8576 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8577 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8583 sizeAnchor.isClientW = false;
8584 sizeAnchor.isClientH = false;
8585 sizeAnchor.size = value;
8587 normalSizeAnchor = sizeAnchor;
8589 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8591 stateAnchor = normalAnchor;
8592 stateSizeAnchor = normalSizeAnchor;
8594 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8595 Position(x, y, w, h, true, true, true, true, false, true);
8596 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8599 get { value = size; }
8602 property Size clientSize
8604 property_category $"Layout"
8607 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8608 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8609 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8614 sizeAnchor.isClientW = true;
8615 sizeAnchor.isClientH = true;
8616 sizeAnchor.size = value;
8618 normalSizeAnchor = sizeAnchor;
8620 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8622 stateAnchor = normalAnchor;
8623 stateSizeAnchor = normalSizeAnchor;
8625 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8626 Position(x,y, w, h, true, true, true, true, false, true);
8629 get { value = clientSize; }
8632 property Size initSize { get { value = sizeAnchor.size; } };
8634 property Anchor anchor
8636 property_category $"Layout"
8637 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8643 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8645 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8646 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8648 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8650 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8651 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8655 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8657 anchor.left.distance = 0;
8658 anchor.horz.type = 0;
8660 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8662 anchor.top.distance = 0;
8663 anchor.vert.type = 0;
8672 normalAnchor = anchor;
8674 // Break the anchors for moveable/resizable windows
8675 /*if(style.fixed ) //&& value.left.type == cascade)
8677 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8679 this.anchor = normalAnchor = Anchor { left = x, top = y };
8680 normalSizeAnchor = SizeAnchor { { w, h } };
8683 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8685 stateAnchor = normalAnchor;
8686 stateSizeAnchor = normalSizeAnchor;
8688 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8689 Position(x, y, w, h, true, true, true, true, false, true);
8698 get { value = this ? anchor : Anchor { }; }
8701 property Point position
8703 property_category $"Layout"
8706 if(value == null) return;
8708 anchor.left = value.x;
8709 anchor.top = value.y;
8710 anchor.right.type = none;
8711 anchor.bottom.type = none;
8716 normalAnchor = anchor;
8718 // Break the anchors for moveable/resizable windows
8722 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8724 normalAnchor.left = x;
8725 normalAnchor.top = y;
8726 normalAnchor.right.type = none;
8727 normalAnchor.bottom.type = none;
8728 normalSizeAnchor.size.width = w;
8729 normalSizeAnchor.size.height = h;
8733 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8735 stateAnchor = normalAnchor;
8736 stateSizeAnchor = normalSizeAnchor;
8738 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8739 Position(x,y, w, h, true, true, true, true, false, true);
8743 get { value = position; }
8746 property bool disabled
8748 property_category $"Behavior"
8751 if(this && disabled != value)
8758 get { return (bool)disabled; }
8761 property bool isEnabled
8766 for(parent = this; parent; parent = parent.parent)
8773 property WindowState state
8775 property_category $"Behavior"
8776 set { SetState(value, false, 0); }
8777 get { return this ? state : 0; }
8780 property bool visible
8782 property_category $"Behavior"
8785 if(this && !value && !style.hidden && parent)
8787 bool wasActiveChild = parent.activeChild == this;
8788 Window client = null;
8790 style.hidden = true;
8791 if(style.isActiveClient)
8793 parent.numPositions--;
8794 if(state == minimized) parent.numIcons--;
8799 OldLink prevOrder = null;
8801 if(rootWindow == this)
8802 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8805 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8808 box.left -= parent.clientStart.x;
8809 box.top -= parent.clientStart.y;
8810 box.right -= parent.clientStart.x;
8811 box.bottom -= parent.clientStart.y;
8815 if(_isModal && master && master.modalSlave == this)
8816 master.modalSlave = null;
8820 OldLink tmpPrev = order.prev;
8821 client = tmpPrev ? tmpPrev.data : null;
8822 if(client && !client.style.hidden && !client.destroyed && client.created)
8823 prevOrder = tmpPrev;
8826 client = tmpPrev ? tmpPrev.data : null;
8827 if(client == this) { client = null; break; }
8828 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8830 tmpPrev = client.order.prev;
8835 prevOrder = tmpPrev;
8840 // If this window can be an active client, make sure the next window we activate can also be one
8841 if(!style.nonClient && style.isActiveClient)
8843 tmpPrev = prevOrder;
8846 client = tmpPrev ? tmpPrev.data : null;
8847 if(client == this) { client = null; break; }
8848 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8850 tmpPrev = client.order.prev;
8855 prevOrder = tmpPrev;
8859 if(client && client.style.hidden) client = null;
8863 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8865 if(order && prevOrder && prevOrder.data != this)
8866 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8868 ActivateEx(false, false, false, true, null, null);
8870 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8871 if(parent.activeClient == this)
8873 parent.activeClient = null;
8874 parent.UpdateActiveDocument(null);
8877 else if(parent.activeClient == this)
8879 parent.activeClient = client;
8880 parent.UpdateActiveDocument(this);
8883 // *** Not doing this anymore ***
8886 parent.childrenCycle.Delete(cycle);
8888 parent.childrenOrder.Delete(order);
8893 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8898 else if(this && value && style.hidden)
8900 style.hidden = false;
8903 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8904 if(rootWindow == this)
8905 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8907 if(_isModal && master)
8908 master.modalSlave = this;
8910 if(style.isActiveClient)
8912 positionID = parent.GetPositionID(this);
8913 parent.numPositions++;
8914 if(state == minimized) parent.numIcons++;
8917 // *** NOT DOING THIS ANYMORE ***
8919 if(!(style.inactive))
8921 if(!(style.noCycle))
8923 cycle = parent.childrenCycle.AddAfter(
8924 (parent.activeChild && parent.activeChild.cycle) ?
8925 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8928 order = parent.childrenOrder.AddAfter(
8929 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8936 if(true || !parent.activeChild)
8937 ActivateEx(true, false, true, true, null, null);
8939 if(creationActivation == activate)
8940 ActivateEx(true, false, true, true, null, null);
8941 else if(creationActivation == flash && !object)
8944 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8948 ConsequentialMouseMove(false);
8954 style.hidden = !value;
8957 get { return (style.hidden || !setVisible) ? false : true; }
8960 property bool isDocument
8962 property_category $"Document"
8963 set { style.isDocument = value; }
8964 get { return style.isDocument; }
8967 property bool mergeMenus
8969 property_category $"Window Style"
8970 set { mergeMenus = value; }
8971 get { return (bool)mergeMenus; }
8974 property bool hasHorzScroll
8976 property_category $"Window Style"
8981 if(!style.hasHorzScroll && created)
8983 CreateSystemChildren();
8984 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8987 else if(style.hasHorzScroll)
8991 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8993 style.hasHorzScroll = value;
8996 get { return style.hasHorzScroll; }
8999 property bool hasVertScroll
9001 property_category $"Window Style"
9006 if(!style.hasVertScroll && created)
9008 style.hasVertScroll = true;
9009 CreateSystemChildren();
9010 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9013 else if(style.hasVertScroll)
9017 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9019 style.hasVertScroll = value;
9021 get { return style.hasVertScroll; }
9024 property bool dontHideScroll
9026 property_category $"Behavior"
9029 scrollFlags.dontHide = value;
9032 //UpdateScrollBars(true, true);
9033 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9037 // UpdateScrollBars(true, true);
9038 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9041 get { return scrollFlags.dontHide; }
9044 property bool dontScrollVert
9046 property_category $"Behavior"
9047 set { style.dontScrollVert = value; }
9048 get { return style.dontScrollVert; }
9050 property bool dontScrollHorz
9052 property_category $"Behavior"
9053 set { style.dontScrollHorz = value; }
9054 get { return style.dontScrollHorz; }
9057 property bool snapVertScroll
9059 property_category $"Behavior"
9062 scrollFlags.snapY = value;
9063 if(sbv) sbv.snap = value;
9065 get { return scrollFlags.snapY; }
9067 property bool snapHorzScroll
9069 property_category $"Behavior"
9072 scrollFlags.snapX = value;
9073 if(sbh) sbh.snap = value;
9075 get { return scrollFlags.snapX; }
9078 property Point scroll
9080 property_category $"Behavior"
9084 // TESTING THIS IMPLEMENTATION:
9085 SetScrollPosition(value.x, value.y);
9087 get { value = scroll; }
9090 property bool modifyVirtualArea
9092 property_category $"Behavior"
9093 set { modifyVirtArea = value; }
9094 get { return (bool)modifyVirtArea; }
9097 property bool dontAutoScrollArea
9099 property_category $"Behavior"
9100 // Activating a child control out of view will automatically scroll to make it in view
9101 set { noAutoScrollArea = value; }
9102 get { return (bool)noAutoScrollArea; }
9105 property char * fileName
9107 property_category $"Document"
9110 if(menu && ((!fileName && value) || (fileName && !value)))
9112 MenuItem item = menu.FindItem(MenuFileSave, 0);
9113 if(item) item.disabled = !modifiedDocument && value;
9118 if(value && value[0])
9119 fileName = CopyString(value);
9121 if(parent && this == parent.activeClient)
9122 parent.UpdateActiveDocument(null);
9126 // if(style.isDocument)
9128 fileMonitor.fileName = value;
9130 get { return fileName; }
9135 property_category $"Data"
9140 property bool modifiedDocument
9142 property_category $"Document"
9145 if(style.isDocument || fileName)
9149 MenuItem item = menu.FindItem(MenuFileSave, 0);
9150 if(item) item.disabled = !value && fileName;
9154 if(modifiedDocument != value)
9156 modifiedDocument = value;
9157 if(style.isDocument || fileName)
9161 get { return (bool)modifiedDocument; }
9164 property bool showInTaskBar
9166 property_category $"Window Style"
9167 set { style.showInTaskBar = value; }
9168 get { return (style.showInTaskBar; }
9170 property FileDialog saveDialog { set { saveDialog = value; } };
9171 property bool isActiveClient
9173 property_category $"Behavior"
9174 set { style.isActiveClient = value; }
9175 get { return style.isActiveClient; }
9178 property Cursor cursor
9180 property_category $"Appearance"
9184 SelectMouseCursor();
9186 get { return cursor; }
9189 //#if !defined(ECERE_VANILLA)
9190 property char * name
9192 property_category $"Design"
9195 return (this && object) ? object.name : null;
9200 activeDesigner.RenameObject(object, value);
9204 property char * displayDriver
9206 property_category $"Behavior"
9209 dispDriver = GetDisplayDriver(value);
9210 //DisplayModeChanged();
9214 return dispDriver ? dispDriver.name : null;
9218 // RUNTIME PROPERTIES
9219 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9220 property Size scrollArea
9222 property_category $"Behavior"
9226 SetScrollArea(value.w, value.h, false);
9228 SetScrollArea(0,0, true);
9230 get { value = scrollArea; }
9233 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9238 property_category $"Layout"
9239 set { if(this) is3D = value; }
9240 get { return (bool)is3D; }
9243 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9245 // Will be merged with font later
9246 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9247 property Point clientStart { get { value = clientStart; } };
9248 property Point absPosition { get { value = absPosition; } };
9249 property Anchor normalAnchor { get {value = normalAnchor; } };
9250 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9251 property bool active { get { return (bool)active; } };
9252 property bool created { get { return (bool)created; } };
9253 property bool destroyed { get { return (bool)destroyed; } };
9254 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9255 property Window firstChild { get { return children.first; } };
9256 property Window lastChild { get { return children.last; } };
9257 property Window activeClient { get { return activeClient; } };
9258 property Window activeChild { get { return activeChild; } };
9259 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9260 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9261 property ScrollBar horzScroll { get { return sbh; } };
9262 property ScrollBar vertScroll { get { return sbv; } };
9263 property StatusBar statusBar { get { return statusBar; } };
9264 property Window rootWindow { get { return rootWindow; } };
9265 property bool closing { get { return (bool)closing; } set { closing = value; } };
9266 property int documentID { get { return documentID; } };
9267 property Window previous { get { return prev; } }
9268 property Window next { get { return next; } }
9269 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9270 property PopupMenu menuBar { get { return menuBar; } }
9271 property ScrollBar sbv { get { return sbv; } }
9272 property ScrollBar sbh { get { return sbh; } }
9273 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9274 property void * systemHandle { get { return windowHandle; } }
9275 property Button minimizeButton { get { return sysButtons[0]; } };
9276 property Button maximizeButton { get { return sysButtons[1]; } };
9277 property Button closeButton { get { return sysButtons[2]; } };
9278 property BitmapResource icon
9280 get { return icon; }
9284 if(icon) incref icon;
9286 guiApp.interfaceDriver.SetIcon(this, value);
9289 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9290 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9291 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9292 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9293 property bool nativeDecorations
9295 get { return (bool)nativeDecorations; }
9296 set { nativeDecorations = value; }
9297 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9298 isset { return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed; }
9301 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9303 property char * text
9305 property_category $"Deprecated"
9307 set { property::caption = value; }
9308 get { return property::caption; }
9314 WindowBits style; // Window Style
9315 char * caption; // Name / Caption
9316 Window parent; // Parent window
9317 OldList children; // List of children in Z order
9318 Window activeChild; // Child window having focus
9319 Window activeClient;
9320 Window previousActive; // Child active prior to activating the default child
9321 Window master; // Window owning and receiving notifications concerning this window
9322 OldList slaves; // List of windows belonging to this window
9323 Display display; // Display this window is drawn into
9325 Point position; // Position in parent window client area
9326 Point absPosition; // Absolute position
9327 Point clientStart; // Client area position from (0,0) in this window
9329 Size clientSize; // Client area size
9330 Size scrollArea; // Virtual Scroll area size
9331 Size reqScrollArea; // Requested virtual area size
9332 Point scroll; // Virtual area scrolling position
9333 public ScrollBar sbh, sbv; // Scrollbar window handles
9334 Cursor cursor; // Mouse cursor used for this window
9337 StatusBar statusBar;
9338 Button sysButtons[3];
9340 Box clientArea; // Client Area box clipped to parent
9342 HotKeySlot hotKey; // HotKey for this window
9346 ScrollFlags scrollFlags;// Window Scrollbar Flags
9347 int id; // Control ID
9349 ColorAlpha background; // Background color used to draw the window area
9351 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9352 OldList childrenCycle; // Cycling order
9353 OldLink cycle; // Element of parent's cycling order
9354 OldList childrenOrder; // Circular Z-Order
9355 OldLink order; // Element of parent's circular Z-Order
9356 Window modalSlave; // Slave window blocking this window's interaction
9358 Window rootWindow; // Topmost system managed window
9359 void * windowHandle; // System window handle
9361 DialogResult returnCode;// Return code for modal windows
9363 Point sbStep; // Scrollbar line scrolling steps
9366 SizeAnchor stateSizeAnchor;
9368 Anchor normalAnchor;
9369 SizeAnchor normalSizeAnchor;
9371 Size skinMinSize; // Minimal window size based on style
9372 Point scrolledPos; // Scrolled position
9373 Box box; // Window box clipped to parent
9374 Box * against; // What to clip the box to
9376 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9377 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9378 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9379 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9380 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9381 Point scrolledArea; // Distance to scroll area by
9382 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9384 OldList hotKeys; // List of the hotkeys of all children
9385 Window defaultControl; // Default child control
9389 ColorAlpha * palette; // Color palette used for this window
9391 int caretSize; // Size of caret, non zero if a caret is present
9392 Point caretPos; // Caret position
9394 void * systemParent; // Parent System Window for embedded windows
9401 WindowState lastState;
9403 FileMonitor fileMonitor
9405 this, FileChange { modified = true };
9407 bool OnFileNotify(FileChange action, char * param)
9410 fileMonitor.StopMonitoring();
9411 if(OnFileModified(action, param))
9412 fileMonitor.StartMonitoring();
9417 FontResource setFont, systemFont;
9418 FontResource usedFont;
9419 FontResource captionFont;
9421 FileDialog saveDialog;
9423 SizeAnchor sizeAnchor;
9425 // FormDesigner data
9428 Extent * tempExtents; //[4];
9429 BitmapResource icon;
9431 CreationActivationOption creationActivation;
9434 bool active:1; // true if window and ancestors are active
9435 bool acquiredInput:1; // true if the window is processing state based input
9436 bool modifiedDocument:1;
9437 bool disabled:1; // true if window cannot interact
9438 bool isForegroundWindow:1;// true while a root window is being activated
9439 bool visible:1; // Visibility flag
9440 bool destroyed:1; // true if window is being destroyed
9441 bool anchored:1; // true if this window is repositioned when the parent resizes
9442 bool dirty:1; // Flag set to true if any descendant must be redrawn
9448 bool modifyVirtArea:1;
9449 bool noAutoScrollArea:1;
9452 bool setVisible:1; // FOR FORM DESIGNER
9458 bool useSharedMemory:1;
9461 bool nativeDecorations:1;
9462 bool manageDisplay:1;
9463 bool formDesigner:1; // True if we this is running in the form editor
9466 // Checks used internally for them not to take effect in FormDesigner
9467 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9468 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9470 WindowController controller;
9471 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9474 public class CommonControl : Window
9476 // creationActivation = doNothing;
9479 public property String toolTip
9481 property_category $"Appearance"
9484 if(created) CommonControl::OnDestroy();
9486 toolTip = value ? ToolTip { tip = value; } : null;
9488 if(created) CommonControl::OnCreate();
9490 get { return toolTip ? toolTip.tip : null; }
9496 // (Very) Ugly work around for the fact that the parent watcher
9497 // won't fire when it's already been disconnected...
9498 eInstance_FireSelfWatchers(toolTip,
9499 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9505 toolTip.parent = this;
9514 public class Percentage : float
9516 char * OnGetString(char * string, float * fieldData, bool * needClass)
9520 sprintf(string, "%.2f", this);
9521 c = strlen(string)-1;
9524 if(string[c] != '0')
9525 last = Max(last, c);
9526 if(string[c] == '.')
9539 public void ApplySkin(Class c, char * name, void ** vTbl)
9541 char className[1024];
9546 subclass(Window) wc = (subclass(Window))c;
9547 subclass(Window) base = (subclass(Window))c.base;
9549 sprintf(className, "%sSkin_%s", name, c.name);
9550 wc.pureVTbl = c._vTbl;
9551 c._vTbl = new void *[c.vTblSize];
9552 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9553 sc = eSystem_FindClass(c.module.application, className);
9557 for(m = 0; m < c.base.vTblSize; m++)
9559 if(c._vTbl[m] == base.pureVTbl[m])
9560 c._vTbl[m] = vTbl[m];
9565 for(m = 0; m < c.vTblSize; m++)
9567 if(sc._vTbl[m] != wc.pureVTbl[m])
9568 c._vTbl[m] = sc._vTbl[m];
9572 for(d = c.derivatives.first; d; d = d.next)
9574 ApplySkin(d.data, name, c._vTbl);
9578 public void UnapplySkin(Class c)
9580 char className[1024];
9582 subclass(Window) wc = (subclass(Window))c;
9583 subclass(Window) base = (subclass(Window))c.base;
9586 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9589 c._vTbl = wc.pureVTbl;
9593 for(d = c.derivatives.first; d; d = d.next)
9595 UnapplySkin(d.data);
9599 void CheckFontIntegrity(Window window)
9604 if(window.usedFont && window.usedFont.font == 0xecececec)
9606 FontResource uf = window.usedFont;
9607 char * className = window._class.name;
9608 char * text = window.text;
9611 for(c = window.firstChild; c; c = c.next)
9612 CheckFontIntegrity(c);
9616 public class ControllableWindow : Window
9618 /*WindowController controller;
9619 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9620 ~ControllableWindow() { delete controller; }*/
9623 class WindowControllerInterface : ControllableWindow
9625 bool OnKeyDown(Key key, unichar ch)
9627 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9629 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9633 bool OnKeyUp(Key key, unichar ch)
9635 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9637 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9641 bool OnKeyHit(Key key, unichar ch)
9643 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9645 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9649 bool OnMouseMove(int x, int y, Modifiers mods)
9651 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9653 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9657 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9659 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9661 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9665 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9667 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9669 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9673 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9675 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9677 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9681 bool OnRightButtonDown(int x, int y, Modifiers mods)
9683 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9685 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9689 bool OnRightButtonUp(int x, int y, Modifiers mods)
9691 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9693 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9697 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9699 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9701 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9705 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9707 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9709 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9713 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9715 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9717 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9721 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9723 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9725 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9729 void OnResize(int width, int height)
9731 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9732 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9735 void OnRedraw(Surface surface)
9737 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9738 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9743 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9745 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9749 bool OnLoadGraphics()
9751 bool result = ((int(*)())(void *)controller.OnLoadGraphics)((void *)controller.controlled, (void *)controller);
9753 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics](controller.window);
9757 void OnUnloadGraphics()
9759 ((int(*)())(void *)controller.OnUnloadGraphics)((void *)controller.controlled, (void *)controller);
9760 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics](controller.window);
9764 public class WindowController<class V>
9767 property Window window
9771 uint size = class(Window).vTblSize;
9774 windowVTbl = new void *[size];
9775 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9776 if(value._vTbl == value._class._vTbl)
9778 value._vTbl = new void *[value._class.vTblSize];
9779 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9783 for(c = 0; c < size; c++)
9785 void * function = class(WindowControllerInterface)._vTbl[c];
9786 if(function != DefaultFunction)
9787 value._vTbl[c] = function;
9789 value._vTbl[c] = windowVTbl[c];
9794 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9797 get { return window; }
9799 property V controlled
9801 set { controlled = value; }
9802 get { return controlled; }
9804 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9805 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9806 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9807 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9808 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9809 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9810 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9811 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9812 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9813 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9814 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9815 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9816 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9817 virtual void V::OnResize(WindowController controller, int width, int height);
9818 virtual void V::OnRedraw(WindowController controller, Surface surface);
9819 virtual bool V::OnCreate(WindowController controller);
9820 virtual bool V::OnLoadGraphics(WindowController controller);
9821 virtual void V::OnUnloadGraphics(WindowController controller);
9824 int (** windowVTbl)();