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;
560 // Stop the timer in case it was started while the window was not created...
563 Timer timer, nextTimer;
564 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
566 nextTimer = timer.next;
567 if(timer.window == this)
574 stopwatching(parent, font);
575 if(parent.activeChild == this)
576 parent.activeChild = null;
577 if(parent.activeClient == this)
578 parent.activeClient = null;
583 // Prevent destructor from being called again...
589 /////////////////////////////////
592 OldLink slave = master.slaves.FindLink(this);
593 master.slaves.Delete(slave);
600 parent.childrenCycle.Remove(cycle);
602 parent.childrenOrder.Remove(order);
603 parent.children.Remove(this);
608 /////////////////////////////////
610 while(ptr = resources.first)
613 resources.Delete(ptr);
620 for(child = children.first; child; child = child.next)
622 // child.stopwatching(this, font);
624 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
625 // Don't want property here
626 *&child.parent = null;
629 while(slave = slaves.first)
631 // Don't want property here
632 *&((Window)slave.data).master = null;
633 slaves.Delete(slave);
636 // Because we do a decref in DestroyEx...
644 // Why was this commented?
645 //if(this != guiApp.desktop)
658 if(((subclass(Window))_class).pureVTbl)
660 if(_vTbl == _class._vTbl)
662 _vTbl = ((subclass(Window))_class).pureVTbl;
667 for(m = 0; m < _class.vTblSize; m++)
669 if(_vTbl[m] == _class._vTbl[m])
670 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
674 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
677 dirtyArea.Free(null);
678 renderArea.Free(null);
679 overRenderArea.Free(null);
680 clipExtent.Free(null);
681 scrollExtent.Free(null);
682 dirtyBack.Free(null);
686 tempExtents[0].Free(null);
687 tempExtents[1].Free(null);
688 tempExtents[2].Free(null);
689 tempExtents[3].Free(null);
694 //#if !defined(ECERE_VANILLA)
695 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
697 if(this == activeDesigner)
701 char * name = property::name;
702 return name ? name : "";
707 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
708 bool OnGetDataFromString(char * string)
710 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
713 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
714 this = designer.form;
715 else if(!strcmpi(string, "(Desktop)"))
716 this = activeDesigner;
718 return activeDesigner.FindObject(&this, string);
724 // --- Window updates system ---
726 // Setup a bitmap for Redrawing on client area of Window
727 Surface Redraw(Box box)
729 Surface surface = null;
731 Box clientArea = this.clientArea;
735 mox.left -= clientStart.x;
736 mox.top -= clientStart.y;
737 mox.right -= clientStart.x;
738 mox.bottom -= clientStart.y;
740 mox.Clip(clientArea);
741 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
743 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
745 int x = absPosition.x + clientStart.x;
746 int y = absPosition.y + clientStart.y;
747 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
749 x -= rootWindow.clientStart.x;
750 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
752 if(!guiApp.fullScreenMode || is3D)
754 x -= rootWindow.absPosition.x;
755 y -= rootWindow.absPosition.y;
759 x += rootWindow.parent.clientStart.x;
760 y += rootWindow.parent.clientStart.y;
762 mox.left += rootWindow.parent.clientStart.x;
763 mox.top += rootWindow.parent.clientStart.y;
764 mox.right += rootWindow.parent.clientStart.x;
765 mox.bottom += rootWindow.parent.clientStart.y;
770 surface = display.GetSurface(x, y, mox);
773 surface.width = clientSize.w;
774 surface.height = clientSize.h;
780 // Setup a bitmap for Redrawing on full Window
781 Surface RedrawFull(Box box)
783 Surface surface = null;
791 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
793 int x = absPosition.x;
794 int y = absPosition.y;
795 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
797 x -= rootWindow.clientStart.x;
798 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
800 if(!guiApp.fullScreenMode || is3D)
802 x -= rootWindow.absPosition.x;
803 y -= rootWindow.absPosition.y;
806 x += rootWindow.parent.clientStart.x;
807 y += rootWindow.parent.clientStart.y;
809 mox.left += rootWindow.parent.clientStart.x;
810 mox.top += rootWindow.parent.clientStart.y;
811 mox.right += rootWindow.parent.clientStart.x;
812 mox.bottom += rootWindow.parent.clientStart.y;
817 surface = display.GetSurface(x, y, mox);
820 surface.width = size.w;
821 surface.height = size.h;
827 void FigureCaption(char * caption)
829 Window activeClient = null;
833 strcpy(caption, this.caption);
834 if(style.isDocument || fileName)
836 if(caption[0]) strcat(caption, " - ");
838 strcat(caption, fileName);
842 sprintf(title, "Untitled %d", documentID);
843 strcat(caption, title);
846 strcat(caption, " *");
851 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
853 if(activeClient && activeClient.state == maximized)
855 if(activeClient.caption)
857 if(caption[0]) strcat(caption, " - ");
858 strcat(caption, activeClient.caption);
860 if(activeClient.style.isDocument || activeClient.fileName)
862 if(caption[0]) strcat(caption, " - ");
863 strcat(caption, "[");
864 if(activeClient.fileName)
865 strcat(caption, activeClient.fileName);
869 sprintf(title, "Untitled %d", activeClient.documentID);
870 strcat(caption, title);
872 if(activeClient.modifiedDocument)
873 strcat(caption, " *");
874 strcat(caption, "]");
879 // Code for returning dirty from ScrollDisplay:
881 for(d = 0; d<scrollExtent.count; d++)
883 Box * box = &scrollExtent.boxes[d];
889 Min(box.right, box.left-scroll.x),box.bottom
891 dirtyArea.UnionBox(update);
897 Max(box.left, box.right-scroll.x), box.top,
898 box.right, box.bottom
900 dirtyArea.UnionBox(update);
908 box.right, Min(box.bottom, box.top-scroll.y),
910 dirtyArea.UnionBox(update);
916 box.left, Max(box.top, box.bottom-scroll.y),
917 box.right, box.bottom
919 dirtyArea.UnionBox(update);
924 void UpdateDecorations(void)
926 // TODO: *** TEMPORARY HACK ***
933 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
935 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
937 Update({ -clientStart.x,0, -1, clientSize.h-1 });
939 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
942 // Returns w & h for Position
943 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
945 Window parent = this.parent ? this.parent : guiApp.desktop;
946 int vpw = parent ? parent.clientSize.w : 0;
947 int vph = parent ? parent.clientSize.h : 0;
948 int pw = parent ? parent.clientSize.w : 0;
949 int ph = parent ? parent.clientSize.h : 0;
950 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
951 int x = anchor.left.distance, y = anchor.top.distance;
953 MinMaxValue ew = 0, eh = 0;
955 float cascadeW, cascadeH;
957 int tilingW, tilingH, tilingSplit, tilingLastH;
958 int addX = 0, addY = 0;
960 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
962 Window masterWindow = this;
963 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
966 if(master == guiApp.desktop)
967 masterWindow = guiApp.desktop.activeChild;
969 masterWindow = master.rootWindow;
970 if(!masterWindow) masterWindow = this;
972 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
973 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
976 pw = vpw = box.right - box.left + 1;
978 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
981 ph = vph = box.bottom - box.top + 1;
997 vpw = pw = parent.size.w;
998 vph = ph = parent.size.h;
1000 else if(!style.fixed /*|| style.isDocument*/)
1002 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1003 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1005 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1008 Desktop3D_FixSize(&pw, &ph);
1009 Desktop3D_FixSize(&vpw, &vph);
1012 if(pw < skinMinSize.w) pw = skinMinSize.w;
1013 if(ph < skinMinSize.h) ph = skinMinSize.h;
1014 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1015 if(vph < skinMinSize.h) vph = skinMinSize.h;
1017 // TODO: Must fix what we're snapping
1020 if(anchor.left.type)
1022 SNAPUP(x, textCellW);
1024 else if(anchor.right.type)
1026 SNAPDOWN(x, textCellW);
1031 SNAPUP(y, textCellH);
1033 else if(anchor.bottom.type)
1035 SNAPDOWN(y, textCellH);
1039 // This is required to get proper initial decoration size using native decorations on Windows
1040 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1041 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1042 GetDecorationsSize(&ew, &eh);
1044 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1046 if(parent.sbv && !parent.sbv.style.hidden)
1047 pw += guiApp.currentSkin.VerticalSBW();
1048 if(parent.sbh && !parent.sbh.style.hidden)
1049 ph += guiApp.currentSkin.HorizontalSBH();
1051 if(anchor.left.type == cascade)
1053 w = (int)(pw * 0.80);
1054 h = (int)(ph * 0.80);
1056 else if(anchor.left.type >= vTiled)
1061 numTiling = parent.numPositions - parent.numIcons;
1062 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1063 if(anchor.left.type == vTiled)
1065 tilingH = (int)sqrt(numTiling);
1066 tilingW = numTiling / tilingH;
1070 tilingW = (int)sqrt(numTiling);
1071 tilingH = numTiling / tilingW;
1074 leftOver = numTiling - tilingH * tilingW;
1077 tilingSplit = (tilingW - leftOver) * tilingH;
1078 tilingLastH = tilingH+1;
1081 tilingSplit = numTiling;
1083 if(positionID >= tilingSplit)
1085 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1086 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1087 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1088 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1092 x = pw * (positionID / tilingH) / tilingW;
1093 y = ph * (positionID % tilingH) / tilingH;
1094 x2 = pw * (positionID / tilingH + 1) / tilingW;
1095 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1099 SNAPDOWN(x, textCellW);
1100 SNAPDOWN(y, textCellH);
1101 SNAPDOWN(x2, textCellW);
1102 SNAPDOWN(y2, textCellH);
1110 if(sizeAnchor.isClientW) w += ew;
1111 if(sizeAnchor.isClientH) h += eh;
1113 if(anchor.left.type == offset)
1114 x = anchor.left.distance;
1115 else if(anchor.left.type == relative)
1116 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1117 else if(anchor.right.type == relative)
1118 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1119 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1120 else if(anchor.right.type == offset)
1121 ex = vpw - anchor.right.distance;
1123 if(anchor.top.type == offset)
1124 y = anchor.top.distance;
1125 else if(anchor.top.type == relative)
1126 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1127 else if(anchor.bottom.type == relative)
1128 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1129 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1130 else if(anchor.bottom.type == offset)
1131 ey = vph - anchor.bottom.distance;
1133 if(anchor.left.type && anchor.right.type)
1135 switch(anchor.right.type)
1138 ex = pw * (1.0f-anchor.right.percent);
1139 w = Max((int)(ex + 0.5) - x, 0);
1142 ex = vpw - anchor.right.distance;
1143 w = Max((int)(ex + 0.5) - x, 0);
1147 if(anchor.top.type && anchor.bottom.type)
1149 switch(anchor.bottom.type)
1152 ey = ph * (1.0f-anchor.bottom.percent);
1153 h = Max((int)(ey + 0.5) - y, 0);
1156 ey = vph - anchor.bottom.distance;
1157 h = Max((int)(ey + 0.5) - y, 0);
1166 if(state == normal /*|| state == Hidden*/)
1168 bool addSbV = false, addSbH = false;
1170 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1171 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1173 w = Max(w, minSize.w);
1174 h = Max(h, minSize.h);
1175 w = Min(w, maxSize.w);
1176 h = Min(h, maxSize.h);
1178 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1180 if(w) w -= guiApp.currentSkin.VerticalSBW();
1183 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1185 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1189 if(!OnResizing(&w, &h))
1195 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1196 w += guiApp.currentSkin.VerticalSBW();
1197 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1198 h += guiApp.currentSkin.HorizontalSBH();
1200 w = Max(w, skinMinSize.w);
1201 h = Max(h, skinMinSize.h);
1214 SNAPDOWN(w, textCellW);
1215 SNAPDOWN(h, textCellH);
1218 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1220 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1223 (pw - w) / CASCADE_SPACE,
1224 (ph - h) / CASCADE_SPACE);
1230 cascW = (pw - w) / (numCascade-1);
1231 cascH = (ph - h) / (numCascade-1);
1232 SNAPDOWN(cascW, textCellW);
1233 SNAPDOWN(cascH, textCellH);
1234 cascadeW = (float)cascW;
1235 cascadeH = (float)cascH;
1239 numCascade = Max(numCascade, 2);
1240 cascadeW = (float)(pw - w) / (numCascade-1);
1241 cascadeH = (float)(ph - h) / (numCascade-1);
1244 x = (int)((positionID % numCascade) * cascadeW);
1245 y = (int)((positionID % numCascade) * cascadeH);
1247 else if(anchor.left.type < vTiled)
1249 if(!anchor.left.type || anchor.horz.type == middleRelative)
1251 if(!anchor.right.type)
1253 if(anchor.horz.type == middleRelative)
1254 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1256 x = vpw / 2 + anchor.horz.distance - w / 2;
1262 // case A_EDGE: x = x - w; break;
1264 if(!anchor.top.type || anchor.vert.type == middleRelative)
1266 if(!anchor.bottom.type)
1268 if(anchor.vert.type == middleRelative)
1269 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1271 y = vph / 2 + anchor.vert.distance - h / 2;
1277 // case A_EDGE: y = y - h; break;
1280 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1288 SNAPDOWN(x, textCellW);
1289 SNAPDOWN(y, textCellH);
1301 if(anchored && style.fixed && style.isActiveClient)
1306 void UpdateCaret(bool forceUpdate, bool erase)
1308 static Window lastWindow = null;
1309 static int caretX, caretY, caretSize;
1311 if(guiApp && guiApp.caretOwner == this)
1313 int x = caretPos.x - scroll.x;
1314 int y = caretPos.y - scroll.y;
1316 if((erase || this.caretSize) &&
1317 x >= clientArea.left && x <= clientArea.right &&
1318 y >= clientArea.top && y <= clientArea.bottom)
1322 guiApp.interfaceDriver.SetCaret(
1323 x + absPosition.x + clientStart.x,
1324 y + absPosition.y + clientStart.y, this.caretSize);
1325 guiApp.caretEnabled = true;
1327 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1331 if(lastWindow != this)
1333 updateBox.left = x + 1;
1335 updateBox.right = x + 2;
1336 updateBox.bottom = y + this.caretSize - 1;
1340 updateBox.left = Min(x + 1, caretX + 1);
1341 updateBox.top = Min(y, caretY);
1342 updateBox.right = Max(x + 2, caretX + 2);
1343 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1346 guiApp.caretOwner.Update(updateBox);
1353 caretSize = this.caretSize;
1359 guiApp.interfaceDriver.SetCaret(0,0,0);
1360 guiApp.caretEnabled = false;
1366 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1371 scrolledPos.x = position.x = x;
1372 scrolledPos.y = position.y = y;
1374 clientSize.w = size.w = w;
1375 clientSize.h = size.h = h;
1377 if(parent && !style.nonClient)
1379 //if(!style.fixed || style.isDocument)
1381 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1382 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1386 clientStart.x = clientStart.y = 0;
1388 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1390 //if(!activeClient || activeClient.state != maximized)
1391 if(!noAutoScrollArea)
1393 // Check if scroll area must be modified
1394 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1396 bool foundChild = false;
1398 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1399 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1400 for(child = children.first; child; child = child.next)
1402 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1403 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1405 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1406 w = Max(w, child.position.x + child.size.w);
1407 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1408 w = Max(w, Max(child.position.x, 0) + child.size.w);
1409 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1410 h = Max(h, child.position.y + child.size.h);
1411 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1412 h = Max(h, Max(child.position.y, 0) + child.size.h);
1417 if(foundChild && (w > cw || h > ch))
1419 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1421 int stepX = sbStep.x, stepY = sbStep.y;
1422 // Needed to make snapped down position match the skin's check of client area
1423 // against realvirtual
1426 SNAPDOWN(stepX, textCellW);
1427 SNAPDOWN(stepY, textCellH);
1428 stepX = Max(stepX, textCellW);
1429 stepY = Max(stepY, textCellH);
1431 if(scrollFlags.snapX)
1433 if(scrollFlags.snapY)
1436 reqScrollArea.w = w;
1437 reqScrollArea.h = h;
1440 else if(reqScrollArea.w || reqScrollArea.h)
1442 reqScrollArea.w = 0;
1443 reqScrollArea.h = 0;
1444 SetScrollPosition(0,0);
1449 // Automatic MDI Client Scrolling Area Adjustment
1450 if(parent && !parent.noAutoScrollArea)
1452 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1453 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1455 Window parent = this.parent;
1456 int w = parent.reqScrollArea.w;
1457 int h = parent.reqScrollArea.h;
1459 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1460 w = Max(w, position.x + size.w);
1461 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1462 w = Max(w, Max(position.x, 0) + size.w);
1463 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1464 h = Max(h, position.y + size.h);
1465 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1466 h = Max(h, Max(position.y, 0) + size.h);
1468 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1469 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1471 /*bool resize = false;
1472 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1473 // Needed to make snapped down position match the skin's check of client area
1474 // against realvirtual
1477 SNAPDOWN(stepX, textCellW);
1478 SNAPDOWN(stepY, textCellH);
1479 stepX = Max(stepX, textCellW);
1480 stepY = Max(stepY, textCellH);
1482 if(parent.scrollFlags.snapX)
1484 if(parent.scrollFlags.snapY)
1486 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1488 parent.reqScrollArea.w = w;
1489 parent.reqScrollArea.h = h;*/
1491 // parent.UpdateScrollBars(true, true);
1492 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1493 false, true, true, true, false, false);
1498 GetRidOfVirtualArea();
1502 UpdateScrollBars(modifyThisArea, false);
1503 else if(guiApp.currentSkin)
1506 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1508 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1509 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1510 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1511 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1514 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1515 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1517 absPosition = scrolledPos;
1518 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1519 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1521 if(this != guiApp.desktop && parent)
1523 absPosition.x += parent.absPosition.x;
1524 absPosition.y += parent.absPosition.y;
1525 if(!style.nonClient && this != guiApp.desktop)
1527 absPosition.x += parent.clientStart.x;
1528 absPosition.y += parent.clientStart.y;
1532 box = Box { 0, 0, size.w - 1, size.h - 1 };
1537 // Clip against parent's client area
1538 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1540 // Compute client area in this window coordinate system
1541 clientArea.left = 0;
1543 clientArea.right = clientSize.w - 1;
1544 clientArea.bottom = clientSize.h - 1;
1546 // Clip against parent's client area
1548 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1552 //absPosition.x -= parent.clientStart.x;
1553 //absPosition.y -= parent.clientStart.y;
1556 // Adjust all children
1557 for(child = children.first; child; child = child.next)
1558 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1560 UpdateCaret(false, false);
1563 void GetRidOfVirtualArea(void)
1565 if(parent && !parent.destroyed && style.fixed &&
1566 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1567 parent.reqScrollArea.w && parent.reqScrollArea.h)
1569 if(!parent.noAutoScrollArea)
1573 for(child = children.first; child; child = child.next)
1575 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1577 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1578 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1587 Window parent = this.parent;
1589 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1590 false, true, true, true, false, false);
1592 parent.SetScrollArea(0,0,true);
1593 parent.SetScrollPosition(0,0);
1599 public void ExternalPosition(int x, int y, int w, int h)
1601 Position(x, y, w, h, false, true, true, true, false, false);
1604 // (w, h): Full window size
1605 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1607 bool result = false;
1608 int oldCW = clientSize.w, oldCH = clientSize.h;
1609 bool clientResized, windowResized, windowMoved;
1611 bool realResized = size.w != w || size.h != h;
1613 // TOCHECK: This wasn't in ecere.dll
1614 //if(!parent) return true;
1615 if(destroyed) return false;
1617 windowMoved = position.x != x || position.y != y || force;
1619 // windowResized = realResized || force;
1620 windowResized = size.w != w || size.h != h || force;
1622 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1628 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1629 scrolledPos.x - parent.clientStart.x + this.box.right,
1630 scrolledPos.y - parent.clientStart.y + this.box.bottom
1636 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1641 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1643 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1644 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1645 windowResized = true;
1647 if(display && rootWindow != this)
1650 if(guiApp && guiApp.windowMoving)
1652 if(guiApp.windowMoving.style.nonClient)
1653 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1655 guiApp.windowMoving.parent.SetMouseRangeToClient();
1665 // Buttons bitmap resources crash if we do this while switching mode
1666 if(!guiApp || !guiApp.modeSwitching)
1669 // Process Anchored Children
1673 for(child = children.first; child; child = child.next)
1676 ((child.stateAnchor.left.type != offset ||
1677 child.stateAnchor.top.type != offset ||
1678 child.stateAnchor.right.type != none ||
1679 child.stateAnchor.bottom.type != none) ||
1680 child.state == maximized || child.state == minimized))
1682 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1684 // child.Position(x, y, w, h, false, true, true, true, false);
1685 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1686 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1692 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1693 //if(updateScrollBars)
1695 OnResize(clientSize.w, clientSize.h);
1697 if((clientResized || windowMoved) && created)
1698 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1700 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1702 Window master = guiApp.interimWindow.master;
1703 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1706 if(rootWindow == this && !is3D)
1710 x -= guiApp.desktop.absPosition.x;
1711 y -= guiApp.desktop.absPosition.y;
1713 //guiApp.Log("Position %s\n", caption);
1716 if(windowResized || windowMoved)
1717 if(display && !display.flags.memBackBuffer && changeRootWindow)
1718 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1720 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1721 for(child = parent.children.first; child && child != this; child = child.next)
1722 if(child.rootWindow)
1723 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1728 if(windowMoved || windowResized)
1730 display.Lock(true /*false*/);
1733 display.Position(absPosition.x, absPosition.y);
1734 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1737 // result = realResized ? display.Resize(size.w, size.h) : true;
1738 if(nativeDecorations && rootWindow.windowHandle)
1740 int w = clientSize.w, h = clientSize.h;
1741 if(hasMenuBar) h += skinMenuHeight;
1742 if(hasStatusBar) h += statusBarHeight;
1743 if(sbv && sbv.visible) w += sbv.size.w;
1744 if(sbh && sbh.visible) h += sbh.size.h;
1745 result = manageDisplay ? display.Resize(w, h) : true;
1748 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1752 else if(clientResized)
1754 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1757 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1761 if(windowMoved || windowResized)
1766 if(guiApp.driver && changeRootWindow && windowHandle)
1768 if(windowResized || windowMoved)
1769 if(!display || display.flags.memBackBuffer)
1770 guiApp.interfaceDriver.PositionRootWindow(this,
1771 x, y, w, h, windowMoved, windowResized);
1772 guiApp.interfaceDriver.UpdateRootWindow(this);
1774 for(child = children.first; child; child = child.next)
1776 if(child.is3D && child.created)
1778 // Copy Display Content
1779 child.display.displaySystem = display.displaySystem;
1780 child.display.window = display.window;
1781 child.display.current = display.current;
1782 child.display.width = display.width;
1783 child.display.height = display.height;
1784 child.display.driverData = display.driverData;
1785 child.display.mutex = null;
1796 void UpdateScrollBars(bool flag, bool fullThing)
1799 bool resizeH = false, resizeV = false;
1800 bool scrolled = false;
1801 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1802 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1804 if(destroyed) return;
1805 if(guiApp.currentSkin)
1807 MinMaxValue cw = 0, ch = 0;
1808 bool sbvVisible, sbhVisible;
1810 int positionH, positionV;
1812 // First get client area with no respect to scroll bars
1817 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1819 if(scrollFlags.dontHide)
1822 cw -= guiApp.currentSkin.VerticalSBW();
1824 ch -= guiApp.currentSkin.HorizontalSBH();
1826 // Update the scrollbar visibility
1832 sbh.disabled = rangeH <= 1;
1833 if(sbh.style.hidden)
1843 sbv.disabled = rangeV <= 1;
1844 if(sbv.style.hidden)
1852 int oldHRange = sbh ? sbh.range : 0;
1853 int oldVRange = sbv ? sbv.range : 0;
1854 // Then start off with horizontal scrollbar range
1857 positionH = sbh.thumbPosition;
1864 SBSetTotal(sbh, rvw);
1867 ch -= guiApp.currentSkin.HorizontalSBH();
1870 // Do the same for vertical scrollbar
1873 positionV = sbv.thumbPosition;
1879 SBSetTotal(sbv, rvh);
1883 cw -= guiApp.currentSkin.VerticalSBW();
1884 // Maybe we need to set the range on the horizontal scrollbar again
1892 SBSetTotal(sbh, rvw);
1893 //sbh.Action(setRange, positionH, 0);
1894 if(rangeH <= 1 && sbh.range > 1)
1896 ch -= guiApp.currentSkin.HorizontalSBH();
1902 SBSetTotal(sbv, rvh);
1904 //sbv.Action(setRange, positionV, 0);
1909 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1910 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1913 // Update the scrollbar visibility
1914 if(!scrollFlags.dontHide)
1916 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1920 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1927 if(guiApp.currentSkin)
1934 sbhVisible = sbh.style.hidden ? true : false;
1936 sbvVisible = sbv.style.hidden ? true : false;
1938 // Do our resize here
1939 if(flag && (resizeH || resizeV) && fullThing)
1941 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1946 OnResize(clientSize.w, clientSize.h);
1952 sbh.visible = sbhVisible;
1954 sbv.visible = sbvVisible;
1956 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1957 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1960 sbh.pageStep = clientSize.w;
1962 sbv.pageStep = clientSize.h;
1964 // Notify doesn't handle setRange anymore... process it here
1967 int positionH = sbh.thumbPosition;
1968 if(scroll.x != positionH)
1970 OnHScroll(setRange, positionH, 0);
1974 SNAPDOWN(positionH, textCellW);
1975 scroll.x = positionH;
1981 int seen = clientSize.w, total = reqScrollArea.w;
1984 if(scrollFlags.snapX)
1985 SNAPDOWN(seen, sbStep.x);
1987 if(!total) total = seen;
1988 range = total - seen + 1;
1990 range = Max(range, 1);
1992 if(x >= range) x = range - 1;
1994 if(scrollFlags.snapX)
1995 SNAPUP(x, sbStep.x);
1999 OnHScroll(setRange, x, 0);
2004 SNAPDOWN(x, textCellW);
2010 int positionV = sbv.thumbPosition;
2011 if(scroll.y != positionV)
2013 OnVScroll(setRange, positionV, 0);
2017 SNAPDOWN(positionV, textCellH);
2018 scroll.y = positionV;
2024 int seen = clientSize.h, total = reqScrollArea.h;
2027 if(scrollFlags.snapY)
2028 SNAPDOWN(seen, sbStep.y);
2030 if(!total) total = seen;
2031 range = total - seen + 1;
2032 range = Max(range, 1);
2034 if(y >= range) y = range - 1;
2036 if(scrollFlags.snapY)
2037 SNAPUP(y, sbStep.y);
2041 OnVScroll(setRange, y, 0);
2046 SNAPDOWN(y, textCellH);
2052 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2055 for(child = children.first; child; child = child.next)
2057 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2060 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2061 child.Position(x, y, w, h, false, true, false, true, false, false);
2068 // Process Scrollbars
2070 if(sbh) // && !sbh.style.hidden
2073 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2074 // Need to set the range again (should improve...) since the scrollbars didn't have
2075 // the right size when UpdateScrollArea set the range on it
2078 sbh.seen = clientSize.w;
2082 if(sbv) // && !sbv.state.hidden
2085 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2086 // Need to set the range again (should improve...) since the scrollbars didn't have
2087 // the right size when UpdateScrollArea set the range on it
2090 sbv.seen = clientSize.h;
2095 // TESTING THIS LOWER
2096 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2099 for(child = children.first; child; child = child.next)
2101 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2104 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2105 child.Position(x, y, w, h, false, true, false, true, false, false);
2111 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2113 SetState(maximized, false, mods);
2117 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2119 SetState(normal, false, mods);
2123 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2125 SetState(minimized, false, mods);
2126 parent.CycleChildren(false, true, false, true);
2130 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2133 // Scroll bar notifications
2134 if(action != setRange)
2136 bool changed = false;
2140 if(scroll.x != position)
2142 OnHScroll(action, position, keyFlags);
2147 SNAPDOWN(position, textCellW);
2149 scroll.x = position;
2153 if(scroll.y != position)
2155 OnVScroll(action, position, keyFlags);
2160 SNAPDOWN(position, textCellH);
2162 scroll.y = position;
2166 bool childMove = false;
2167 for(child = children.first; child; child = child.next)
2169 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2172 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2173 child.Position(x, y, w, h, false, true, false, true, false, false);
2177 // Testing this patch out to solve MDI workspace redraw bugs
2178 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2179 // Scroll offsets to blame?
2183 UpdateCaret(false, false);
2187 // Testing this patch out to solve MDI workspace redraw bugs
2188 for(child = children.first; child; child = child.next)
2190 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2199 Window GetParentMenuBar()
2201 Window result = this;
2202 bool notActiveClient = false;
2203 Window menuBarParent;
2204 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2206 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2207 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2208 notActiveClient = true;
2213 void CreateSystemChildren(void)
2215 Window parent = this;
2216 bool scrollBarChanged = false;
2217 bool hasClose = false, hasMaxMin = false;
2218 Point scroll = this.scroll;
2220 if(state == maximized)
2221 parent = GetParentMenuBar();
2225 if(style.hasClose) hasClose = true;
2226 if(style.hasMaximize || style.hasMinimize)
2233 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2235 sysButtons[2].Destroy(0);
2236 sysButtons[2] = null;
2238 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2240 sysButtons[1].Destroy(0);
2241 sysButtons[1] = null;
2243 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2245 sysButtons[0].Destroy(0);
2246 sysButtons[0] = null;
2249 if(hasClose && parent)
2256 parent, master = this,
2257 inactive = true, nonClient = true, visible = false;
2259 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2265 if(this.parent == guiApp.desktop)
2266 sysButtons[2].hotKey = altF4;
2267 else if(style.isActiveClient)
2268 sysButtons[2].hotKey = ctrlF4;
2269 sysButtons[2].Create();
2272 sysButtons[2].symbol = 'X';
2273 sysButtons[2].disabled = !style.hasClose;
2276 if(hasMaxMin && parent)
2280 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2281 if(state == maximized)
2284 method = RestoreButtonClicked;
2290 method = MaximizeButtonClicked;
2298 parent, master = this,
2299 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2301 sysButtons[1].Create();
2303 sysButtons[1].NotifyClicked = method;
2305 sysButtons[1].symbol = symbol;
2306 sysButtons[1].disabled = !style.hasMaximize;
2309 if(hasMaxMin && parent)
2313 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2314 if (state == minimized)
2317 method = RestoreButtonClicked;
2323 method = MinimizeButtonClicked;
2331 parent, master = this,
2332 hotKey = altM, inactive = true, nonClient = true, visible = false
2334 sysButtons[0].Create();
2336 sysButtons[0].NotifyClicked = method;
2338 sysButtons[0].symbol = symbol;
2339 sysButtons[0].disabled = !style.hasMinimize;
2342 // Create the scrollbars
2343 if(style.hasHorzScroll && !sbh)
2349 direction = horizontal,
2353 snap = scrollFlags.snapX,
2354 NotifyScrolling = ScrollBarNotification
2357 scrollBarChanged = true;
2359 else if(sbh && !style.hasHorzScroll)
2365 if(style.hasVertScroll && !sbv)
2371 direction = vertical,
2375 snap = scrollFlags.snapY,
2376 NotifyScrolling = ScrollBarNotification
2379 scrollBarChanged = true;
2381 else if(sbv && !style.hasVertScroll)
2386 if(scrollBarChanged)
2388 SetScrollLineStep(sbStep.x, sbStep.y);
2389 UpdateScrollBars(true, true);
2393 if(scrollBarChanged)
2395 if(sbh) sbh.thumbPosition = scroll.x;
2396 if(sbv) sbv.thumbPosition = scroll.y;
2400 void UpdateCaption(void)
2402 if(rootWindow == this)
2405 FigureCaption(caption);
2406 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2408 UpdateDecorations();
2411 if(parent.activeClient == this) // Added this last check
2413 if(parent.rootWindow == parent)
2416 parent.FigureCaption(caption);
2417 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2420 parent.UpdateCaption();
2422 parent.UpdateDecorations();
2426 void UpdateActiveDocument(Window previous)
2428 Window activeClient = this.activeClient;
2429 Window activeChild = this.activeChild;
2436 activeClient.CreateSystemChildren();
2438 previous.CreateSystemChildren();
2450 // Build window list
2453 Menu windowMenu = menu.FindMenu("Window");
2458 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2461 Window document = cycle.data;
2462 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2464 char name[2048], caption[2048];
2465 document.FigureCaption(caption);
2466 sprintf(name, "%d %s", id+1, caption);
2467 windowMenu.AddDynamic(MenuItem
2469 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2470 NotifySelect = MenuWindowSelectWindow
2474 if(activeClient.cycle == cycle) break;
2479 if((!previous && activeClient) || !activeClient)
2485 item = menu.FindItem(MenuWindowCloseAll, 0);
2486 if(item) item.disabled = false;
2487 item = menu.FindItem(MenuWindowNext, 0);
2488 if(item) item.disabled = false;
2489 item = menu.FindItem(MenuWindowPrevious, 0);
2490 if(item) item.disabled = false;
2491 item = menu.FindItem(MenuWindowCascade, 0);
2492 if(item) item.disabled = false;
2493 item = menu.FindItem(MenuWindowTileHorz, 0);
2494 if(item) item.disabled = false;
2495 item = menu.FindItem(MenuWindowTileVert, 0);
2496 if(item) item.disabled = false;
2497 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2498 if(item) item.disabled = false;
2499 item = menu.FindItem(MenuWindowWindows, 0);
2500 if(item) item.disabled = false;
2503 item = menu.FindItem(MenuFileClose, 0);
2504 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2505 item = menu.FindItem(MenuFileSaveAll, 0);
2506 if(item) item.disabled = numDocuments < 1;
2508 if(activeClient && activeClient.menu && activeClient.state != minimized)
2512 //activeClient.menu.Clean(activeClient);
2513 menu.Merge(activeClient.menu, true, activeClient);
2517 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2520 menu.Merge(activeChild.menu, true, activeChild);
2523 // This is called again for a child window change, with same active client
2524 OnActivateClient(activeClient, previous);
2525 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2526 parent.UpdateActiveDocument(null);
2529 void _ShowDecorations(Box box, bool post)
2531 if(rootWindow == this && nativeDecorations) return;
2532 if(visible && this != guiApp.desktop)
2534 Surface surface = RedrawFull(box);
2538 FigureCaption(caption);
2541 ShowDecorations(captionFont.font,
2544 active, //parent.activeClient == this
2545 guiApp.windowMoving == this);
2547 PreShowDecorations(captionFont.font,
2550 active, //parent.activeClient == this
2551 guiApp.windowMoving == this);
2558 void UpdateExtent(Box refresh)
2560 Surface surface = null;
2562 if(!manageDisplay) { OnRedraw(null);return; }
2563 _ShowDecorations(refresh, false);
2565 surface = Redraw(refresh);
2566 // Opaque background: just fill before EW_REDRAW (clear?)
2569 surface.SetBackground(background);
2570 surface.SetForeground(foreground);
2571 surface.DrawingChar(' ');
2572 if(this == rootWindow)
2574 if(style.drawBehind || background.a)
2576 int a = background.a;
2577 // Premultiply alpha for clear color
2578 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2579 surface.Clear(colorBuffer);
2580 surface.SetBackground(background);
2583 else if(background.a)
2587 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2588 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2591 if(display.flags.alpha && background.a < 255 && background)
2593 surface.Area(0,0,clientSize.w, clientSize.h);
2594 /*if(style.clearDepthBuffer)
2595 surface.Clear(depthBuffer);*/
2597 else if(/*style.clearDepthBuffer || */background.a)
2599 int a = background.a;
2600 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2601 // Premultiply alpha for clear color
2602 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2603 surface.Clear(colorBuffer);
2604 surface.SetBackground(background);
2609 surface.TextFont(usedFont.font);
2610 surface.TextOpacity(false);
2614 // Draw the caret ...
2615 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2617 // surface.SetBackground(0xFFFFFF - background.color);
2618 surface.SetBackground(~background.color);
2620 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2621 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2627 void DrawOverChildren(Box refresh)
2629 Surface surface = Redraw(refresh);
2633 surface.DrawingChar(' ');
2634 surface.SetBackground(background);
2635 surface.SetForeground(foreground);
2637 surface.TextFont(usedFont.font);
2638 surface.TextOpacity(false);
2640 OnDrawOverChildren(surface);
2645 _ShowDecorations(refresh, true);
2648 void ComputeClipExtents(void)
2651 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2653 clipExtent.Copy(this.clipExtent);
2655 for(child = children.last; child; child = child.prev)
2657 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2659 bool opaque = child.IsOpaque(); // TODO: acess background directly
2660 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2662 child.clipExtent.Copy(clipExtent);
2663 child.clipExtent.Offset(-dx, -dy);
2664 child.clipExtent.IntersectBox(child.box);
2666 child.ComputeClipExtents();
2668 if(opaque && !child.style.nonClient)
2670 // Adjust the box for the parent:
2671 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2672 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2677 // ??? Only do this for overlapped window or if parent has with clip children flag
2679 // Do this if window has clip children flag on (default false?)
2680 // this.clipExtent = clipExtent;
2682 clipExtent.Free(null);
2685 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2687 bool opaque = IsOpaque();
2689 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2690 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2692 offsetX -= rootWindow.clientStart.x;
2693 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2697 for(child = children.last; child; child = child.prev)
2699 ColorAlpha background = *(ColorAlpha *)&child.background;
2700 bool opaque = child.IsOpaque();
2701 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2705 // Adjust renderArea to the root window level
2706 Extent * renderArea = &rootWindow.tempExtents[1];
2708 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2709 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2711 offsetX -= child.rootWindow.clientStart.x;
2712 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2716 Extent childRenderArea;
2718 if(backBufferUpdate != null)
2720 childRenderArea.Copy(backBufferUpdate);
2721 childRenderArea.Offset(-offsetX, -offsetY);
2724 childRenderArea.Copy(child.dirtyArea);
2726 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2727 renderArea.Copy(dirtyExtent);
2728 renderArea.Offset(-offsetX, -offsetY);
2729 childRenderArea.Union(renderArea);
2732 // Intersect with the clip extent
2733 childRenderArea.Intersection(child.clipExtent);
2736 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2737 renderArea->Offset(offsetX, offsetY);
2738 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2739 // overDirtyExtent.Union(renderArea);
2740 renderArea->Empty();
2741 // childRenderArea.Free();
2743 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2748 for(child = children.last; child; child = child.prev)
2750 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2752 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2757 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2759 bool opaque = IsOpaque();
2760 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2762 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2763 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2765 offsetX -= rootWindow.clientStart.x;
2766 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2770 for(child = children.last; child; child = child.prev)
2772 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2774 ColorAlpha background = *(ColorAlpha *)&child.background;
2775 bool opaque = child.IsOpaque();
2776 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2780 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2781 // Adjust renderArea to the root window level
2783 renderArea.Copy(child.dirtyArea);
2784 renderArea.Offset(offsetX, offsetY);
2785 dirtyExtent.Union(renderArea);
2786 overDirtyExtent.Union(renderArea);
2792 for(child = children.last; child; child = child.prev)
2794 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2796 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2800 if(backBufferUpdate != null)
2802 renderArea.Copy(backBufferUpdate);
2803 renderArea.Offset(-offsetX, -offsetY);
2805 overRenderArea.Copy(backBufferUpdate);
2806 overRenderArea.Offset(-offsetX, -offsetY);
2812 renderArea.Copy(dirtyArea);
2814 overRenderArea.Copy(dirtyArea);
2817 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2818 dirtyExtentWindow->Copy(dirtyExtent);
2819 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2820 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2821 dirtyExtentWindow->Empty();
2823 // Intersect with the clip extent
2824 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2827 if(renderArea.count > 10)
2830 printf("\nToo many extents (%d):\n", renderArea.count);
2832 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2833 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2838 for(c = 0; c<10; c++)
2841 FASTLIST_LOOP(renderArea, extentBox)
2843 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2845 renderArea.Copy(extent);
2847 FASTLIST_LOOP(renderArea, extentBox)
2850 printf("(%d, %d) - (%d, %d)\n",
2851 extentBox.box.left, extentBox.box.top,
2852 extentBox.box.right, extentBox.box.bottom);
2856 printf("\nNow %d\n", renderArea.count);
2862 // WHY WAS THIS COMMENTED ??
2864 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2865 dirtyExtentWindow->Copy(overDirtyExtent);
2866 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2867 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2868 dirtyExtentWindow->Empty();
2870 // Intersect with the clip extent
2871 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2877 if(scrollExtent.count)
2879 // Subtract render extent from scrolling extent
2880 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2882 if(backBufferUpdate == null)
2884 Extent * dirty = &rootWindow.tempExtents[3];
2887 // Intersect scrolling extent with clip extent
2888 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2890 // offset this scroll to be at the root window level
2891 scrollExtent.Offset(offsetX, offsetY);
2892 // Add area that was scrolled to the dirty extents of the back buffer
2893 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2897 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2898 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2899 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2904 scrollExtent.Empty();
2906 // Add the exposed extent to the window render area
2907 dirty->Offset(-offsetX, -offsetY);
2908 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2913 // Subtract the window's box from the transparency forced extent
2914 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2920 renderArea.Copy(this.renderArea);
2921 renderArea.Offset(offsetX, offsetY);
2922 dirtyExtent.Union(renderArea);
2928 Extent renderArea { };
2930 renderArea.Copy(overRenderArea);
2931 renderArea.Offset(offsetX, offsetY);
2932 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2937 if(backBufferUpdate != null)
2939 // Remove render area from dirty area
2940 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2942 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2949 // Remove the window render area from the dirty extents of the back buffer
2950 rootWindow.dirtyBack.Exclusion(renderArea);
2954 void Render(Extent updateExtent)
2958 Window rootWindow = this.rootWindow;
2959 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2960 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2962 offsetX -= rootWindow.clientStart.x;
2963 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2966 if(rootWindow.fullRender)
2975 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2976 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2981 /*if(renderArea.count)
2982 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2985 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2987 Box box = extentBox.box;
2990 /*printf("(%d, %d) - (%d, %d)\n",
2991 extentBox.box.left, extentBox.box.top,
2992 extentBox.box.right, extentBox.box.bottom);*/
2997 box.left += offsetX;
2999 box.right += offsetX;
3000 box.bottom += offsetY;
3002 if(updateExtent != null)
3003 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3007 for(child = children.first; child; child = child.next)
3008 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3009 child.Render(updateExtent);
3011 if(rootWindow.fullRender)
3012 DrawOverChildren(box);
3015 // TO DO: There's an issue about draw over children...
3016 // TO DO: Don't wanna go through this if method isn't used
3017 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3018 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3020 Box box = extentBox.box;
3022 DrawOverChildren(box);
3024 box.left += offsetX;
3026 box.right += offsetX;
3027 box.bottom += offsetY;
3029 if(updateExtent != null)
3030 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3033 for(child = children.first; child; child = child.next)
3034 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3035 child.Render(updateExtent);
3038 overRenderArea.Empty();
3041 public void UpdateDisplay(void)
3043 if(!manageDisplay) { OnRedraw(null);return; }
3044 if(rootWindow && this != rootWindow)
3045 rootWindow.UpdateDisplay();
3048 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3049 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3052 dirtyExtent.Clear();
3055 clipExtent.AddBox(box);
3057 display.StartUpdate();
3059 if(!rootWindow.fullRender)
3061 ComputeClipExtents();
3062 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3063 ComputeRenderArea(dirtyExtent, overExtent, null);
3066 clipExtent.Free(null);
3068 dirtyExtent.Free(null);
3069 overExtent.Free(null);
3071 if(display.flags.flipping)
3074 display.Update(null);
3078 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3079 updateExtent.Clear();
3081 Render(updateExtent);
3083 updateExtent.UnionBox(this.box, tempExtents[0]);
3086 //printf("\n\nUpdate:\n------------------------------------------\n");
3089 //FASTLIST_LOOP(updateExtent, extentBox)
3090 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3093 /*printf("Updating (%d, %d) - (%d, %d)\n",
3094 extentBox.box.left, extentBox.box.top,
3095 extentBox.box.right, extentBox.box.bottom);*/
3098 display.Update(extentBox.box);
3101 updateExtent.Free(null);
3104 display.EndUpdate();
3112 void UpdateBackDisplay(Box box)
3118 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3120 //printf("UpdateBackDisplay going through!\n");
3121 display.StartUpdate();
3125 intersection.Copy(dirtyBack);
3126 intersection.IntersectBox(box);
3128 dirtyExtent.Clear();
3131 clipExtent.AddBox(box);
3133 if(!rootWindow.fullRender)
3135 ComputeClipExtents();
3136 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3139 clipExtent.Free(null);
3141 intersection.Free(null);
3142 dirtyExtent.Free(null);
3143 overExtent.Free(null);
3148 if(display.flags.flipping)
3149 display.Update(null);
3152 rootWindow.display.Update(box);
3155 display.EndUpdate();
3159 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3160 if(dirtyBack.count > MAX_DIRTY_BACK)
3162 BoxItem extentBox, next;
3163 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3164 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3166 next = (BoxItem)extentBox.next;
3167 if(extentBox != first)
3169 if(extentBox.box.left < first.box.left)
3170 first.box.left = extentBox.box.left;
3171 if(extentBox.box.top < first.box.top)
3172 first.box.top = extentBox.box.top;
3173 if(extentBox.box.right > first.box.right)
3174 first.box.right = extentBox.box.right;
3175 if(extentBox.box.bottom > first.box.bottom)
3176 first.box.bottom = extentBox.box.bottom;
3177 dirtyBack.Delete(extentBox);
3186 // --- Window positioning ---
3187 // --- Window identification ---
3189 // Returns window at position "Position"
3190 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3192 Window child, result = null;
3194 box.left += absPosition.x;
3195 box.right += absPosition.x;
3196 box.top += absPosition.y;
3197 box.bottom += absPosition.y;
3199 if(!destroyed && visible && (acceptDisabled || !disabled))
3201 int lx = x - absPosition.x;
3202 int ly = y - absPosition.y;
3203 if(IsInside(lx, ly))
3204 // if(box.IsPointInside(Point{x, y}))
3206 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3207 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3210 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3212 if(child != statusBar && child.rootWindow == rootWindow)
3214 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3221 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3223 if(child != statusBar && child.rootWindow == rootWindow)
3225 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3237 Window FindModal(void)
3239 Window modalWindow = this, check;
3240 Window check2 = null;
3241 for(check = this; check.master; check = check.master)
3243 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3245 modalWindow = check.master.modalSlave;
3246 check = modalWindow;
3248 // TESTING THIS FOR DROPBOX...
3249 if(!rootWindow || !rootWindow.style.interim)
3251 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3253 if(check2.modalSlave && check2.modalSlave.created)
3255 modalWindow = check2.modalSlave;
3263 if(modalWindow == this)
3265 for(check = this; check.activeChild; check = check.activeChild)
3267 if(check.modalSlave)
3269 modalWindow = check.modalSlave;
3275 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3276 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3279 void StopMoving(void)
3281 if(this == guiApp.windowMoving)
3283 guiApp.windowMoving = null;
3284 UpdateDecorations();
3285 SetMouseRange(null);
3288 if(rootWindow.active)
3289 guiApp.interfaceDriver.StopMoving(rootWindow);
3292 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3293 guiApp.windowIsResizing = false;
3297 void SelectMouseCursor(void)
3302 Window cursorWindow = null;
3303 bool rx, ry, rex, rey;
3305 guiApp.desktop.GetMousePosition(&x, &y);
3306 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3308 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3309 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3310 else if(mouseWindow)
3312 modalWindow = mouseWindow.FindModal();
3313 x -= mouseWindow.absPosition.x;
3314 y -= mouseWindow.absPosition.y;
3315 if(guiApp.windowIsResizing)
3317 rex = guiApp.resizeEndX;
3318 rey = guiApp.resizeEndY;
3319 rx = guiApp.resizeX;
3320 ry = guiApp.resizeY;
3321 if((rex && rey) || (rx && ry))
3322 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3323 else if((rex && ry) || (rx && rey))
3324 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3325 else if((ry || rey) && (!rx && !rex))
3326 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3327 else if((rx || rex) && (!ry && !rey))
3328 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3330 else if(!modalWindow && !guiApp.windowCaptured &&
3331 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3332 &rx, &ry, &rex, &rey))
3334 if((rex && rey) || (rx && ry))
3335 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3336 else if((rex && ry) || (rx && rey))
3337 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3338 else if((ry || rey) && (!rx && !rex))
3339 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3340 else if((rx || rex) && (!ry && !rey))
3341 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3343 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3345 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3346 cursorWindow = mouseWindow.parent;
3348 cursorWindow = mouseWindow;
3350 else if(!guiApp.interimWindow)
3351 cursorWindow = guiApp.windowCaptured;
3354 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3355 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3357 else if(modalWindow)
3359 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3361 else if(guiApp.interimWindow)
3363 if(guiApp.interimWindow.cursor)
3364 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3366 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3371 // --- State based input ---
3372 bool AcquireInputEx(bool state)
3377 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3378 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3380 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3382 guiApp.acquiredWindow = state ? this : null;
3385 SetMouseRangeToClient();
3386 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3391 SelectMouseCursor();
3393 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3397 // --- Window activation ---
3398 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3401 if(!parent || !parent.style.inactive)
3403 Window parent = this.parent;
3406 if(rootWindow == this)
3407 Log(active ? "active\n" : "inactive\n");
3410 // Testing this here...
3411 if(!parent || parent == guiApp.desktop || parent.active)
3413 this.active = active;
3416 // TESTING THIS HERE
3417 UpdateDecorations();
3418 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3419 result = NotifyActivate(master, this, active, previous);
3422 this.active = !active;
3427 if(!parent || parent == guiApp.desktop || parent.active)
3429 this.active = active;
3431 AcquireInputEx(active);
3436 if(guiApp.caretOwner)
3440 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3441 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3442 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3443 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3445 guiApp.caretOwner.Update(extent);
3448 if(visible || !guiApp.caretOwner)
3449 guiApp.caretOwner = this;
3450 UpdateCaret(false, false);
3456 this.active = false;
3458 AcquireInputEx(active);
3460 if(!active && guiApp.caretOwner == this)
3462 UpdateCaret(false, true);
3463 guiApp.caretOwner = null;
3464 guiApp.interfaceDriver.SetCaret(0,0,0);
3465 guiApp.caretEnabled = false;
3470 if(!active && parent && parent.activeChild && parent.activeChild != this)
3471 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3477 if(!active && menuBar)
3480 menuBar.OnActivate(false, null, &goOn, true);
3481 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3486 Window aChild = activeChild;
3488 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3500 void ConsequentialMouseMove(bool kbMoving)
3504 if(kbMoving || !guiApp.windowMoving)
3508 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3510 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3512 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3513 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3519 bool IsDescendantOf(Window ancestor)
3522 for(window = this; window && window != ancestor; window = window.parent);
3523 return window == ancestor;
3526 bool IsSlaveOf(Window master)
3529 for(window = this; window && window != master; window = window.master);
3530 return window == master;
3533 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3537 if(this && !destroyed /*&& state != Hidden*/)
3539 Window swap = externalSwap;
3547 if(activateParent &&
3548 (parent.activeChild != this ||
3549 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3550 active && _isModal &&
3551 parent != master && master)
3552 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3558 bool real = parent.activeChild != this;
3560 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3561 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3562 !IsDescendantOf(guiApp.interimWindow) &&
3563 !IsSlaveOf(guiApp.interimWindow))
3565 Window interimWindow = guiApp.interimWindow;
3566 while(interimWindow && interimWindow != this)
3568 Window master = interimWindow.master;
3570 guiApp.interimWindow = null;
3571 if(guiApp.caretOwner)
3572 guiApp.caretOwner.UpdateCaret(false, false);
3574 incref interimWindow;
3575 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3580 delete interimWindow;
3581 interimWindow = (master && master.style.interim) ? master : null;
3586 guiApp.interimWindow = this;
3587 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3588 guiApp.caretEnabled = false;*/
3589 UpdateCaret(false, true);
3594 bool acquireInput = false;
3596 parent.activeChild &&
3597 parent.activeChild.state == maximized &&
3598 parent != guiApp.desktop;
3600 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3605 swap = parent.activeChild;
3606 if(swap && swap.destroyed) swap = null;
3607 if(swap && swap != this)
3610 if(!swap.PropagateActive(false, this, &goOn, true))
3611 swap = parent.activeChild;
3622 if(!parent || parent.activeChild != this || style.interim)
3625 result = PropagateActive(true, swap, &goOn, true);
3626 if(!result && !goOn)
3631 acquireInput = true;
3635 if(style.hasMaximize && parent != guiApp.desktop)
3638 SetState(maximized, false, 0);
3639 else if(state != maximized)
3642 for(child = parent.children.first; child; child = child.next)
3644 if(this != child && child.state == maximized)
3645 child.SetState(normal, false, 0);
3652 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3654 Window previous = parent.activeClient;
3655 parent.activeChild = this;
3656 if(!style.nonClient /*&& style.isActiveClient*/)
3660 if(style.isActiveClient)
3661 parent.activeClient = this;
3662 // Moved UpdateActiveDocument inside hidden check
3663 // To prevent activating previous window while creating a new one
3664 // (It was messing up the privateModule in the CodeEditor)
3665 parent.UpdateActiveDocument(previous);
3671 //if(!style.isRemote)
3673 if(rootWindow != this)
3675 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3676 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3678 else if(!guiApp.fullScreenMode)
3680 Window modalRoot = FindModal();
3681 if(!modalRoot) modalRoot = this;
3682 if(!modalRoot.isForegroundWindow)
3684 modalRoot.isForegroundWindow = true;
3685 // To check : Why is parent null?
3686 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3688 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3690 modalRoot.isForegroundWindow = false;
3695 if(result && real && (!style.inactive || moveInactive) && parent)
3697 Window last = parent.children.last;
3699 if(!style.stayOnTop)
3700 for(; last && last.style.stayOnTop; last = last.prev);
3702 parent.children.Move(this, last);
3704 // Definitely don't want that: why not?
3708 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3714 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3721 parent.activeChild = null;
3722 if(!style.nonClient /*&& style.isActiveClient*/)
3724 Window previous = parent.activeClient;
3725 if(style.isActiveClient)
3726 parent.activeClient = null;
3727 parent.UpdateActiveDocument(previous);
3731 if(this == guiApp.interimWindow)
3733 guiApp.interimWindow = null;
3734 if(guiApp.caretOwner)
3735 guiApp.caretOwner.UpdateCaret(false, false);
3737 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3744 if(!active || !swap)
3745 UpdateDecorations();
3747 swap.UpdateDecorations();
3749 if(active && rootWindow != this)
3750 ConsequentialMouseMove(false);
3757 // --- Input Messages ---
3758 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3760 static bool reEntrancy = false;
3761 if(reEntrancy) return;
3765 guiApp.cursorUpdate = true;
3766 if(guiApp.windowScrolling && !consequential)
3768 guiApp.windowScrolling.SetScrollPosition(
3769 (guiApp.windowScrolling.sbh) ?
3770 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3771 (guiApp.windowScrolling.sbv) ?
3772 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3774 if(guiApp.windowMoving)
3776 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3778 Window window = guiApp.windowMoving;
3780 int w = window.size.w;
3781 int h = window.size.h;
3786 rx = mouseX - guiApp.windowMovingStart.x;
3787 ry = mouseY - guiApp.windowMovingStart.y;
3790 window.GetDecorationsSize(&ew, &eh);
3792 if(guiApp.windowIsResizing)
3794 x = window.scrolledPos.x;
3795 y = window.scrolledPos.y;
3799 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3800 rx = guiApp.windowResizingBefore.w - aw;
3801 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3802 w = guiApp.windowResizingBefore.w - rx;
3806 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3807 ry = guiApp.windowResizingBefore.h - ah;
3808 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3809 ry = Max(ry, -guiApp.windowMovingBefore.y);
3810 h = guiApp.windowResizingBefore.h - ry;
3812 if(guiApp.resizeEndX)
3814 w = guiApp.windowResizingBefore.w + rx;
3817 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3825 w = Max(w, window.minSize.w);
3826 h = Max(h, window.minSize.h);
3827 w = Min(w, window.maxSize.w);
3828 h = Min(h, window.maxSize.h);
3830 if(!window.OnResizing(&w, &h))
3832 w = window.clientSize.w;
3833 h = window.clientSize.h;
3836 w = Max(w, window.skinMinSize.w);
3837 h = Max(h, window.skinMinSize.h);
3844 SNAPDOWN(w, textCellW);
3845 SNAPDOWN(h, textCellH);
3850 aw = Max(w,window.skinMinSize.w);
3851 rx = guiApp.windowResizingBefore.w - aw;
3852 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3853 w = guiApp.windowResizingBefore.w - rx;
3857 ah = Max(h,window.skinMinSize.h);
3858 ry = guiApp.windowResizingBefore.h - ah;
3859 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3860 ry = Max(ry, -guiApp.windowMovingBefore.y);
3861 h = guiApp.windowResizingBefore.h - ry;
3866 if(!guiApp.windowIsResizing || guiApp.resizeX)
3867 x = guiApp.windowMovingBefore.x + rx;
3868 if(!guiApp.windowIsResizing || guiApp.resizeY)
3869 y = guiApp.windowMovingBefore.y + ry;
3871 if(!guiApp.windowIsResizing)
3874 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3876 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3877 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3878 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3879 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3883 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3884 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3890 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3892 if(!window.OnMoving(&x, &y, w, h))
3894 x = window.scrolledPos.x;
3895 y = window.scrolledPos.y;
3901 SNAPDOWN(x, textCellW);
3902 SNAPDOWN(y, textCellH);
3905 if(!window.style.nonClient)
3907 if(!window.style.fixed /*|| window.style.isDocument*/)
3909 if(!window.style.dontScrollHorz)
3910 x += window.parent.scroll.x;
3911 if(!window.style.dontScrollVert)
3912 y += window.parent.scroll.y;
3916 // Break the anchors for moveable/resizable windows
3917 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3918 if(window.style.fixed)
3920 if(window.state == normal)
3922 window.normalAnchor = Anchor { left = x, top = y };
3923 window.normalSizeAnchor = SizeAnchor { { w, h } };
3924 window.anchored = false;
3928 window.stateAnchor = Anchor { left = x, top = y };
3929 window.stateSizeAnchor = SizeAnchor { { w, h } };
3931 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3932 // TOCHECK: Investigate why the following only redraws the scrollbars
3933 //window.Position(x, y, w, h, false, true, true, true, false, true);
3935 guiApp.movingLast.x = mouseX;
3936 guiApp.movingLast.y = mouseY;
3942 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3945 bool wasMoving = guiApp.windowMoving ? true : false;
3946 bool wasScrolling = guiApp.windowScrolling ? true : false;
3948 while(result && w != this)
3950 Window msgWindow = GetAtPosition(x,y, false, true, w);
3951 Window trueWindow = GetAtPosition(x,y, false, false, w);
3952 bool windowDragged = false;
3957 window = (w && !w.disabled) ? w : null;
3959 if(trueWindow) incref trueWindow;
3961 if(consequential) mods->isSideEffect = true;
3963 UpdateMouseMove(x, y, consequential);
3965 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3967 if(!guiApp.windowCaptured.isEnabled)
3968 guiApp.windowCaptured.ReleaseCapture();
3970 window = guiApp.windowCaptured;
3973 if(trueWindow && activate &&
3974 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3975 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3976 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3977 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3979 if(mods->alt && !mods->ctrl && !mods->shift)
3981 Window moved = trueWindow;
3982 for(moved = trueWindow; moved; moved = moved.parent)
3983 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3988 windowDragged = true;
3990 // Cancel the ALT menu toggling...
3991 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3996 if(window && activate &&
3997 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3998 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3999 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4000 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4002 Window modalWindow = window.FindModal();
4004 /*if(mods->alt && !mods->shift && !mods->ctrl)
4006 Window moved = window;
4007 for(moved = window; moved; moved = moved.parent)
4008 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4013 windowDragged = true;
4015 // Cancel the ALT menu toggling...
4016 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4022 Window activateWindow = modalWindow ? modalWindow : window;
4023 if(activateWindow && !activateWindow.isRemote)
4025 bool doActivation = true;
4026 //bool needToDoActivation = false;
4027 Window check = activateWindow;
4029 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4031 if(!check.style.inactive)
4033 //needToDoActivation = true;
4035 doActivation = false;
4040 if(!needToDoActivation)
4041 doActivation = false;
4044 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4045 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4047 // Let the OnLeftButtonDown do the activating instead
4048 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4056 incref activateWindow;
4057 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4059 delete activateWindow;
4063 if(activateWindow._refCount == 1)
4065 delete activateWindow;
4069 delete activateWindow;
4071 mods->isActivate = true;
4075 if(!modalWindow && window && !window.destroyed)
4077 if(!guiApp.windowCaptured || windowDragged)
4079 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4081 bool moving = ((window.state != maximized &&
4082 window.IsMouseMoving(
4083 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4084 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4086 if(!moving && window.IsMouseResizing(
4087 x - window.absPosition.x,
4088 y - window.absPosition.y,
4089 window.size.w, window.size.h,
4090 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4092 guiApp.windowIsResizing = true;
4093 guiApp.windowResizingBefore.w = window.size.w;
4094 guiApp.windowResizingBefore.h = window.size.h;
4096 if(guiApp.windowIsResizing || windowDragged || moving)
4099 guiApp.windowMoving = window;
4100 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4101 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4102 guiApp.windowMovingBefore.x = window.position.x;//s;
4103 guiApp.windowMovingBefore.y = window.position.y;//s;
4104 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4105 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4108 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4110 if(window.style.fixed &&
4112 window.IsMouseMoving(
4113 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4115 window.ShowSysMenu(x, y);
4119 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4121 if(window.sbv || window.sbh)
4124 guiApp.windowScrolling = window;
4125 guiApp.windowScrollingStart.x = x;
4126 guiApp.windowScrollingStart.y = y;
4127 guiApp.windowScrollingBefore.x = window.scroll.x;
4128 guiApp.windowScrollingBefore.y = window.scroll.y;
4131 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4133 if(window.style.hasMaximize &&
4134 window.IsMouseMoving(
4135 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4138 (window.state == maximized) ? normal : maximized, false, *mods);
4146 if(guiApp.windowMoving)
4148 if(guiApp.windowMoving.parent)
4150 if(guiApp.windowMoving.style.nonClient)
4151 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4153 guiApp.windowMoving.parent.SetMouseRangeToClient();
4157 window.UpdateDecorations();
4160 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4162 // Log("\n*** LEFT BUTTON UP ***\n");
4163 if(guiApp.windowMoving)
4164 guiApp.windowMoving.StopMoving();
4166 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4168 if(guiApp.windowScrolling)
4170 Window windowScrolling = guiApp.windowScrolling;
4171 guiApp.windowScrolling = null;
4172 windowScrolling.ReleaseCapture();
4176 if(!result || (window && window.destroyed)) window = null;
4178 if(window && window.FindModal())
4181 if(trueWindow && trueWindow.FindModal())
4189 msgWindow = GetAtPosition(x,y, true, false);
4191 msgWindow.SelectMouseCursor();
4194 if(guiApp.windowCaptured || trueWindow)
4196 Window prevWindow = guiApp.prevWindow;
4197 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4199 guiApp.prevWindow.mouseInside = false;
4200 guiApp.prevWindow = null;
4202 // Eventually fix this not to include captured?
4203 if(!prevWindow.OnMouseLeave(*mods))
4206 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4208 Box box = trueWindow.box;
4209 box.left += trueWindow.absPosition.x;
4210 box.right += trueWindow.absPosition.x;
4211 box.top += trueWindow.absPosition.y;
4212 box.bottom += trueWindow.absPosition.y;
4214 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4216 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4217 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4219 overX = Max(Min(overX, 32767),-32768);
4220 overY = Max(Min(overY, 32767),-32768);
4222 trueWindow.mouseInside = true;
4223 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4227 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4228 guiApp.prevWindow = trueWindow;
4230 guiApp.prevWindow = null;
4232 SelectMouseCursor();
4234 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4236 int clientX = x - (window.absPosition.x + window.clientStart.x);
4237 int clientY = y - (window.absPosition.y + window.clientStart.y);
4239 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4241 clientX = Max(Min(clientX, 32767),-32768);
4242 clientY = Max(Min(clientY, 32767),-32768);
4244 MouseMethod = (void *)window._vTbl[method];
4246 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4249 if(!MouseMethod(window, clientX, clientY, *mods))
4256 if(result && w && w.clickThrough && w.parent)
4261 if(!result || !w || !w.clickThrough)
4268 // --- Mouse cursor management ---
4270 bool KeyMessage(uint method, Key key, unichar character)
4275 if(guiApp.interimWindow)
4276 this = guiApp.interimWindow;
4279 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4283 if(!style.inactive || rootWindow != this)
4285 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4286 Window modalWindow = FindModal();
4287 Window interimMaster = master ? master.rootWindow : null;
4291 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4292 status = OnSysKeyDown(key, character);
4293 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4294 status = OnSysKeyHit(key, character);
4295 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4296 status = OnSysKeyUp(key, character);
4303 // Process Key Message for Internal UI Keyboard actions
4304 if(status && !destroyed && menuBar && state != minimized)
4307 if((SmartKey)key != alt)
4308 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4311 SmartKey sk = (SmartKey) key;
4312 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4314 status = menuBar.KeyMessage(method, key, character);
4319 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4320 menuBar.OnKeyHit(escape, 0);
4322 if(!menuBar.focus && guiApp.caretOwner)
4323 guiApp.caretOwner.UpdateCaret(true, false);
4326 if(!destroyed && status)
4328 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4332 case left: case up: case right: case down:
4333 if(guiApp.windowMoving == this)
4336 int w = guiApp.windowMoving.size.w;
4337 int h = guiApp.windowMoving.size.h;
4338 int x = guiApp.windowMoving.scrolledPos.x;
4339 int y = guiApp.windowMoving.scrolledPos.y;
4343 if(key == down || key == up)
4344 step = Max(step, textCellH);
4346 step = Max(step, textCellW);
4349 if(guiApp.windowIsResizing)
4353 case left: w-=step; break;
4354 case right: w+=step; break;
4355 case up: h-=step; break;
4356 case down: h+=step; break;
4363 case left: x-=step; break;
4364 case right: x+=step; break;
4365 case up: y-=step; break;
4366 case down: y+=step; break;
4370 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4371 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4373 if(!guiApp.windowIsResizing || guiApp.resizeX)
4374 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4376 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4378 if(!guiApp.windowIsResizing || guiApp.resizeY)
4379 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4381 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4383 guiApp.interfaceDriver.SetMousePosition(x, y);
4384 ConsequentialMouseMove(true);
4392 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4394 guiApp.windowMoving.StopMoving();
4395 ConsequentialMouseMove(false);
4403 ShowSysMenu(absPosition.x, absPosition.y);
4411 if(!destroyed && status && state != minimized)
4413 // Process all the way down the children
4414 if(activeChild && !activeChild.disabled)
4416 status = activeChild.KeyMessage(method, key, character);
4418 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4419 key.code != left && key.code != right && key.code != up && key.code != down)
4421 status = activeClient.KeyMessage(method, key, character);
4425 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4427 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4428 // && defaultControl != activeChild)
4430 delete previousActive;
4431 previousActive = activeChild;
4432 if(previousActive) incref previousActive;
4434 ConsequentialMouseMove(false);
4435 if((defaultControl.active ||
4436 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4437 defaultControl.KeyMessage(method, defaultKey, character);
4443 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4445 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4452 ShowSysMenu(absPosition.x, absPosition.y);
4459 if(this != guiApp.desktop)
4461 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4463 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4465 MenuMoveOrSize(key.shift, true);
4469 else if(guiApp.windowMoving)
4471 guiApp.windowMoving.StopMoving();
4472 ConsequentialMouseMove(false);
4480 if(!destroyed && status && state != minimized)
4482 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4486 case tab: case shiftTab:
4488 Window cycleParent = this;
4489 if(this == guiApp.interimWindow && !master.style.interim && !cycleParent.style.tabCycle)
4490 cycleParent = master.parent;
4492 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4494 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4496 Window child = cycleParent.activeChild;
4498 // Scroll the window to include the active control
4500 if(cycleParent.sbh && !child.style.dontScrollHorz)
4502 if(child.scrolledPos.x < 0)
4503 cycleParent.sbh.Action(Position,
4504 cycleParent.scroll.x + child.scrolledPos.x, 0);
4505 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4506 cycleParent.sbh.Action(Position,
4507 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4509 if(cycleParent.sbv && !child.style.dontScrollVert)
4511 if(child.scrolledPos.y < 0)
4512 cycleParent.sbv.Action(Position,
4513 cycleParent.scroll.y + child.scrolledPos.y, 0);
4514 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4515 cycleParent.sbv.Action(Position,
4516 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4519 cycleParent.ConsequentialMouseMove(false);
4525 case f6: case shiftF6:
4526 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4528 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4529 if(parent == guiApp.desktop)
4530 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4540 if(CycleChildren(key.shift, true, false, true))
4548 // mIRC Style Window Shortcuts
4549 case alt1: case alt2: case alt3: case alt4: case alt5:
4550 case alt6: case alt7: case alt8: case alt9: case alt0:
4555 for(document = children.first; document; document = document.next)
4557 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4559 if(document == activeChild)
4561 if(document.state == minimized)
4562 document.SetState(normal, false, key);
4565 document.SetState(minimized, false, key);
4566 CycleChildren(false, true, false);
4571 if(activeChild.state == maximized && document.style.hasMaximize)
4572 document.SetState(maximized, false, key);
4573 else if(document.state == minimized)
4574 document.SetState(normal, false, key);
4575 document.Activate();
4590 if(!destroyed && status)
4592 if(state == minimized)
4597 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4599 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4601 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4602 previousActive.ActivateEx(true, false, false, true, null, null);
4603 delete previousActive;
4609 if(!destroyed && status)
4611 status = ProcessHotKeys(method, key, character);
4613 if(!destroyed && status && !modalWindow && state != minimized)
4616 status = KeyMethod(this, key, character);
4617 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4618 status = OnKeyHit(key, character);
4619 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4621 bool result = false;
4624 case ctrlUp: case ctrlDown:
4625 if(sbv && !guiApp.windowScrolling)
4626 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4628 case wheelUp: case wheelDown:
4629 if(sbv && !guiApp.windowScrolling)
4631 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4632 // Do we want to do a consequential move regardless of result in this case?
4633 ConsequentialMouseMove(false);
4636 case ctrlPageUp: case ctrlPageDown:
4637 if(sbh && !guiApp.windowScrolling)
4638 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4643 ConsequentialMouseMove(false);
4648 if(status && !destroyed && menuBar && state != minimized)
4649 status = menuBar.KeyMessage(method, key, character);
4651 if(style.interim && /*destroyed && */status && interimMaster)
4653 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4654 status = interimMaster.KeyMessage(method, key, character);
4661 bool ProcessHotKeys(uint method, Key key, unichar character)
4666 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4667 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4668 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4670 Window hotKeyWindow = hotKey.window;
4671 Window parent = hotKeyWindow.parent;
4672 Window prevActiveWindow = activeChild;
4673 // For when sys buttons are placed inside the menu bar
4674 if(parent && parent._class == class(PopupMenu))
4675 parent = parent.parent;
4677 // 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
4678 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4681 if(prevActiveWindow) incref prevActiveWindow;
4682 incref hotKeyWindow;
4683 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4684 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4687 delete hotKeyWindow;
4688 delete prevActiveWindow;
4692 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4693 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4694 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4696 // ********* WORKING ON THIS ***********
4697 if(prevActiveWindow && !guiApp.interimWindow)
4698 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4701 else if(hotKeyWindow.style.inactive)
4702 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4704 delete prevActiveWindow;
4705 delete hotKeyWindow;
4706 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4707 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4711 if(status && tabCycle)
4714 for(child = children.first; child; child = child.next)
4716 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4727 // --- Windows and graphics initialization / termination ---
4728 bool SetupRoot(void)
4732 // Setup relationship with outside world (bb root || !bb)
4733 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4734 (_displayDriver && dispDriver != parent.dispDriver))
4738 tempExtents = new0 Extent[4];
4743 /*if(guiApp.fullScreenMode)
4744 rootWindow = guiApp.desktop;
4746 //rootWindow = parent.created ? parent.rootWindow : null;
4747 rootWindow = parent.rootWindow;
4750 against = &parent.box;
4752 against = &parent.clientArea;
4755 for(child = children.first; child; child = child.next)
4758 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4761 bool Setup(bool positionChildren)
4763 bool result = false;
4766 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && dispDriver != parent.dispDriver))))
4768 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4769 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4771 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4773 // This was here, is it really needed?
4774 //guiApp.interfaceDriver.ActivateRootWindow(this);
4778 displaySystem = DisplaySystem {};
4779 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4781 delete displaySystem;
4786 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4787 if(display.Create(displaySystem, windowHandle))
4794 // Sometimes icon does not show up on Windows XP if we set here...
4795 // guiApp.interfaceDriver.SetIcon(this, icon);
4797 else if(this != guiApp.desktop)
4799 display = rootWindow ? rootWindow.display : null;
4805 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4806 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4808 for(child = children.first; child; child = child.next)
4810 if(child.created && !child.Setup(false))
4816 bool SetupDisplay(void)
4818 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4819 if(is3D) return Window3D_SetupDisplay(this); else
4826 class_data void ** pureVTbl;
4828 bool LoadGraphics(bool creation, bool resetAnchors)
4830 bool result = false;
4831 bool success = false;
4833 WindowState stateBackup = state;
4836 if(!rootWindow.created)
4840 if(((subclass(Window))_class).pureVTbl)
4842 if(_vTbl == _class._vTbl)
4844 _vTbl = ((subclass(Window))_class).pureVTbl;
4849 for(m = 0; m < _class.vTblSize; m++)
4851 if(_vTbl[m] == _class._vTbl[m])
4852 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4856 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4858 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4860 _vTbl = _class._vTbl;
4865 for(m = 0; m < _class.vTblSize; m++)
4867 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4868 _vTbl[m] = _class._vTbl[m];
4873 if(guiApp.fullScreenMode || this != guiApp.desktop)
4875 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4881 display.Lock(false);
4882 if(rootWindow == this)
4884 // Set Color Palette
4885 display.SetPalette(palette, true);
4889 if(guiApp.fullScreenMode && this == guiApp.desktop)
4894 for(c=0; c<SystemCursor::enumSize; c++)
4895 if(!guiApp.systemCursors[c].bitmap)
4897 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4898 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4899 if(guiApp.systemCursors[c].bitmapName)
4901 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4902 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4903 if(guiApp.systemCursors[c].bitmap)
4904 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4909 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4911 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4912 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4914 cursor.bitmap.paletteShades = cursor.paletteShades;
4918 guiApp.cursorUpdate = true;
4921 ConsequentialMouseMove(false);
4927 // Load Window Graphic Resources
4930 if(usedFont == setFont || usedFont == window.systemFont)
4931 RemoveResource(usedFont);
4934 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4937 RemoveResource(systemFont);
4940 RemoveResource(captionFont);
4942 for(ptr = resources.first; ptr; ptr = ptr.next)
4944 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4947 AddResource(setFont);
4949 AddResource(systemFont);
4951 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4958 //if(master && master.font)
4959 if(parent && parent.font)
4963 faceName = parent.font.faceName,
4964 size = parent.font.size,
4965 bold = parent.font.bold,
4966 italic = parent.font.italic,
4967 underline = parent.font.underline
4969 //font = parent.font;
4970 watch(parent) { font { } };
4973 font = guiApp.currentSkin.SystemFont();
4980 captionFont = guiApp.currentSkin.CaptionFont();
4981 AddResource(captionFont);
4983 if(OnLoadGraphics())
4989 //SetScrollLineStep(sbStep.x, sbStep.y);
4991 if(this != guiApp.desktop)
4995 normalAnchor = anchor;
4996 normalSizeAnchor = sizeAnchor;
4999 // Break the anchors for moveable/resizable windows
5001 if(style.fixed && style.isDocument)
5003 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5015 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5016 stateSizeAnchor = SizeAnchor {};
5021 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5026 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5027 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5030 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5034 stateAnchor = normalAnchor;
5035 stateSizeAnchor = normalSizeAnchor;
5038 position = Point { };
5039 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5050 if(Position(x, y, w, h, true, false, true, true, true, true))
5052 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5055 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5072 success = result = true;
5075 if(!creation && result)
5077 // Load menu bar first because sys buttons are on it...
5080 if(!menuBar.LoadGraphics(false, resetAnchors))
5086 for(child = children.first; child; child = child.next)
5088 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5095 CreateSystemChildren();
5099 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5102 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5107 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5108 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5111 // Do this here to avoid problems on Windows
5112 if(stateBackup == maximized)
5113 property::state = maximized;
5117 void UnloadGraphics(bool destroyWindows)
5121 // Free children's graphics
5122 for(child = children.first; child; child = child.next)
5123 child.UnloadGraphics(destroyWindows);
5126 display.Lock(false);
5129 if(guiApp.fullScreenMode && this == guiApp.desktop)
5134 for(c=0; c<SystemCursor::enumSize; c++)
5135 if(guiApp.systemCursors[c].bitmap)
5136 delete guiApp.systemCursors[c].bitmap;
5138 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5139 delete cursor.bitmap;
5141 guiApp.cursorBackground.Free();
5144 if(display && display.displaySystem)
5148 for(ptr = resources.first; ptr; ptr = ptr.next)
5152 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5157 // Free window graphics
5160 // Free skin graphics
5161 if(rootWindow == this)
5163 DisplaySystem displaySystem = display.displaySystem;
5166 display.driverData = null;
5167 display.displaySystem = null;
5171 if(displaySystem && !displaySystem.numDisplays && !is3D)
5172 delete displaySystem;
5181 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5182 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5184 if(this == guiApp.desktop || parent == guiApp.desktop)
5186 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5187 guiApp.interfaceDriver.DestroyRootWindow(this);
5191 // --- Window Hiding ---
5193 void SetVisibility(bool state)
5195 bool visible = (style.hidden || !created) ? false : state;
5196 if(visible != this.visible)
5200 this.visible = visible;
5201 for(child = children.first; child; child = child.next)
5202 child.SetVisibility(visible);
5204 ConsequentialMouseMove(false);
5205 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5209 // --- Windows and graphics initialization / termination ---
5211 bool DisplayModeChanged(void)
5213 bool result = false;
5214 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5216 guiApp.modeSwitching = true;
5217 UnloadGraphics(false);
5219 if(LoadGraphics(false, false))
5221 guiApp.modeSwitching = false;
5226 // --- Window updates system ---
5228 void UpdateDirty(Box updateBox)
5230 if(!manageDisplay) { OnRedraw(null);return; }
5233 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5236 if(display.flags.flipping)
5239 rootWindow.UpdateDisplay();
5242 UpdateBackDisplay(updateBox);
5244 if(guiApp.fullScreenMode)
5246 guiApp.cursorUpdate = true;
5247 guiApp.PreserveAndDrawCursor();
5249 if(guiApp.fullScreenMode)
5250 guiApp.RestoreCursorBackground();
5256 // This function is strictly called as a result of system window activation
5257 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5260 Window interimMaster = null;
5261 Window interimWindow = guiApp.interimWindow;
5262 if(interimWindow && interimWindow.master)
5263 interimMaster = interimWindow.master.rootWindow;
5265 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5266 // SetState(normal, false, 0);
5267 SetState(lastState, false, 0);
5269 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5273 /* WTH is this doing here?
5274 while(swap && swap.activeChild)
5276 swap = swap.activeChild;
5279 // TESTING THIS BEFORE...
5280 if(interimWindow && this == interimMaster)
5284 // Window interimSwap = this;
5285 Window menuBar = this.menuBar;
5286 if(menuBar && interimWindow.master == menuBar)
5289 while(interimSwap && interimSwap.activeChild)
5290 interimSwap = interimSwap.activeChild;
5292 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5293 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5295 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5296 //result = ActivateEx(true, true, false, activateRoot, window, null);
5301 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5302 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5304 if(interimWindow == this && interimMaster && !active)
5306 while(interimMaster && interimMaster.interim && interimMaster.master)
5308 // printf("Going up one master %s\n", interimMaster._class.name);
5309 interimMaster = interimMaster.master.rootWindow;
5311 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5312 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5318 bool DestroyEx(int returnCode)
5321 Timer timer, nextTimer;
5323 OldLink prevOrder = null;
5324 Window client = null;
5326 if(parent) stopwatching(parent, font);
5328 // if(window.modalSlave) return false;
5329 if(destroyed || !created)
5336 OldLink slave = master.slaves.FindLink(this);
5337 master.slaves.Delete(slave);
5340 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5346 this.returnCode = (DialogResult)returnCode;
5348 AcquireInput(false);
5353 master.hotKeys.Delete(hotKey);
5357 if(guiApp.prevWindow == this)
5359 guiApp.prevWindow = null;
5362 if(guiApp.caretOwner == this)
5364 guiApp.interfaceDriver.SetCaret(0,0,0);
5365 UpdateCaret(false, true);
5366 guiApp.caretEnabled = false;
5371 parent.childrenCycle.Remove(cycle);
5375 OldLink tmpPrev = order.prev;
5376 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5377 prevOrder = tmpPrev;
5380 client = tmpPrev ? tmpPrev.data : null;
5381 if(client == this) { client = null; break; }
5382 if(client && (client.style.hidden || client.destroyed || !client.created))
5383 tmpPrev = client.order.prev;
5387 prevOrder = tmpPrev;
5392 // If this window can be an active client, make sure the next window we activate can also be one
5393 if(!style.nonClient && style.isActiveClient)
5395 tmpPrev = prevOrder;
5398 client = tmpPrev ? tmpPrev.data : null;
5399 if(client == this) { client = null; break; }
5400 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5401 tmpPrev = client.order.prev;
5405 prevOrder = tmpPrev;
5409 if(client && client.style.hidden) client = null;
5411 // parent.childrenOrder.Remove(order);
5414 if(parent && style.isActiveClient && visible)
5416 if(state == minimized) parent.numIcons--;
5417 parent.numPositions--;
5420 // TESTING THIS HERE!
5424 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5425 // to create a window inside a rootwindow that's being destroyed)
5426 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5428 if(master && !master.destroyed /*&&
5429 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5431 if(master.defaultControl == this)
5432 master.defaultControl = null;
5435 parent.OnChildAddedOrRemoved(this, true);
5436 if(parent && !parent.destroyed /*&&
5437 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5439 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5441 if(order && prevOrder && prevOrder.data != this && active)
5443 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5445 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5446 if(parent.activeClient == this)
5448 parent.activeClient = null;
5449 parent.UpdateActiveDocument(null);
5454 if(guiApp.interimWindow == this)
5457 PropagateActive(false, null, &goOn, true);
5461 //if(window.parent.activeChild == window)
5462 parent.activeChild = null;
5463 if(!style.nonClient /*&& style.isActiveClient*/)
5465 Window previous = parent.activeClient;
5466 if(style.isActiveClient)
5467 parent.activeClient = null;
5468 parent.UpdateActiveDocument(previous);
5473 else if(parent.activeClient == this)
5475 parent.activeClient = client;
5476 parent.UpdateActiveDocument(this);
5480 if(guiApp.interimWindow == this)
5482 guiApp.interimWindow = null;
5483 if(guiApp.caretOwner)
5485 Window desktop = guiApp.desktop;
5486 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5487 guiApp.caretOwner.UpdateCaret(false, false);
5492 if(_isModal && master && master.modalSlave == this)
5493 master.modalSlave = null;
5497 if(!guiApp.caretOwner && parent.caretSize)
5499 guiApp.caretOwner = parent;
5500 parent.UpdateCaret(false, false);
5501 parent.Update(null);
5504 // Why was this commented out?
5505 GetRidOfVirtualArea();
5511 dirtyArea.Free(null);
5512 dirtyBack.Free(null);
5513 scrollExtent.Free(null);
5515 /* ATTEMPTING TO MOVE THAT ABOVE
5524 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5525 for(;(child = window.children.first);)
5527 for(; child && (child.destroyed || !child.created); child = child.next);
5536 UnloadGraphics(true);
5539 delete previousActive;
5542 // statusBar = null;
5545 if(master && !master.destroyed)
5547 //master.NotifyDestroyed(this, this.returnCode);
5548 NotifyDestroyed(master, this, this.returnCode);
5551 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5553 nextTimer = timer.next;
5554 if(timer.window == this)
5556 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5557 // timer.window = null;
5563 if(this == guiApp.windowMoving)
5566 if(guiApp.windowCaptured == this)
5568 //guiApp.windowCaptured = null;
5570 if(rootWindow != this && rootWindow)
5571 rootWindow.ConsequentialMouseMove(false);
5579 //for(child = children.first; next = child ? child.next : null, child; child = next)
5580 for(;(child = children.first); )
5582 for(; child && (child.destroyed || !child.created); child = child.next);
5592 /* // MOVED THIS UP...
5595 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5596 for(;(child = window.children.first); )
5598 for(; child && (child.destroyed || !child.created); child = child.next);
5607 while((slave = slaves.first))
5609 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5611 ((Window)slave.data).DestroyEx(0);
5616 if(guiApp.caretOwner == this)
5617 guiApp.caretOwner = null;
5619 sysButtons[0] = null;
5620 sysButtons[1] = null;
5621 sysButtons[2] = null;
5624 if(rootWindow != this)
5626 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5629 box.left -= parent.clientStart.x;
5630 box.top -= parent.clientStart.y;
5631 box.right -= parent.clientStart.x;
5632 box.bottom -= parent.clientStart.y;
5634 if(parent) parent.Update(box);
5639 OldLink slave = master.slaves.FindVoid(this);
5640 master.slaves.Delete(slave);
5646 parent.children.Remove(this);
5651 //autoCreate = false;
5654 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5655 if(((subclass(Window))_class).pureVTbl)
5657 if(_vTbl == _class._vTbl)
5659 _vTbl = ((subclass(Window))_class).pureVTbl;
5664 for(m = 0; m < _class.vTblSize; m++)
5666 if(_vTbl[m] == _class._vTbl[m])
5667 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5676 void SetStateEx(WindowState newState, bool activate)
5679 WindowState prevState = state;
5683 if(prevState != newState)
5684 lastState = prevState;
5686 if(rootWindow != this || !nativeDecorations || !windowHandle)
5688 if(style.isActiveClient && !style.hidden && prevState == minimized)
5691 // This block used to be at the end of the function... moved it for flicker problem in X
5692 // ------------------------------------------------------
5696 stateAnchor = normalAnchor;
5697 stateSizeAnchor = normalSizeAnchor;
5700 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5701 stateSizeAnchor = SizeAnchor {};
5705 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5708 byte * idBuffer = new0 byte[size];
5710 for(child = parent.children.first; child; child = child.next)
5712 if(child != this && child.state == minimized)
5714 if(child.iconID > size - 2)
5716 idBuffer = renew0 idBuffer byte[size*2];
5717 memset(idBuffer + size, 0, size);
5720 idBuffer[child.iconID] = (byte)bool::true;
5723 for(c = 0; c<size; c++)
5728 if(style.isActiveClient && !style.hidden)
5731 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5732 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5736 // TOCHECK: Why was this here?
5737 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5738 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5739 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5741 Position(x, y, w, h, true, true, true, true, false, true);
5743 if(!style.inactive && !style.interim && this == parent.activeClient)
5744 parent.UpdateActiveDocument(null);
5747 CreateSystemChildren();
5748 // ------------------------------------------------------
5751 int GetPositionID(Window forChild)
5755 byte * idBuffer = new0 byte[size];
5758 for(child = children.first; child; child = child.next)
5760 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5762 if(child.positionID > size - 2)
5764 idBuffer = renew0 idBuffer byte[size*2];
5765 memset(idBuffer + size, 0, size);
5768 idBuffer[child.positionID] = (byte)bool::true;
5771 for(c = 0; c<size; c++)
5778 // --- Window related graphics ---
5780 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5782 palette = newPalette;
5783 if(rootWindow.display)
5784 rootWindow.display.SetPalette(palette, colorMatch);
5787 public bool AcquireInput(bool acquired)
5790 if(acquiredInput != acquired)
5792 if(active || (!visible && creationActivation == activate))
5793 result = AcquireInputEx(acquired);
5798 acquiredInput = acquired ? result : !result;
5803 void ListChildren(ListBox listBox)
5807 for(child = children.first; child; child = child.next)
5809 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5811 DataRow row = listBox.AddRow();
5812 row.tag = (int)child;
5813 child.FigureCaption(caption);
5814 row.SetData(null, caption);
5819 void UpdateVisual(Box extent)
5821 if(guiApp.driver != null)
5823 if(guiApp.fullScreenMode && guiApp.desktop.display)
5825 guiApp.desktop.mutex.Wait();
5826 guiApp.desktop.display.Lock(true);
5829 if(guiApp.desktop.active)
5831 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5833 if(guiApp.desktop.display.flags.flipping)
5834 guiApp.desktop.Update(null);
5835 guiApp.desktop.UpdateDisplay();
5836 guiApp.cursorUpdate = true;
5838 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5840 guiApp.PreserveAndDrawCursor();
5841 // guiApp.desktop.display.ShowScreen();
5842 guiApp.cursorUpdate = false;
5843 guiApp.desktop.dirty = false;
5844 guiApp.RestoreCursorBackground();
5848 guiApp.desktop.display.Unlock();
5849 guiApp.desktop.mutex.Release();
5853 Window rootWindow = this.rootWindow;
5854 rootWindow.mutex.Wait();
5859 guiApp.SignalEvent();
5862 guiApp.waitMutex.Wait();
5863 guiApp.interfaceDriver.Lock(rootWindow);
5864 if(!rootWindow.style.hidden && rootWindow.dirty)
5866 if(rootWindow.display)
5868 rootWindow.UpdateDisplay();
5869 //rootWindow.display.ShowScreen(null);
5871 rootWindow.dirty = false;
5873 guiApp.interfaceDriver.Unlock(rootWindow);
5874 guiApp.waitMutex.Release();
5877 rootWindow.mutex.Release();
5882 void UnlockDisplay(void)
5884 guiApp.interfaceDriver.Unlock(rootWindow);
5887 void LockDisplay(void)
5889 guiApp.interfaceDriver.Lock(rootWindow);
5892 Surface GetSurface(Box box)
5894 return Redraw((box == null) ? this.box : box);
5897 void SetMousePosition(int x, int y)
5899 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5903 void IntegrationActivate(bool active)
5905 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5907 isForegroundWindow = true;
5908 ActivateEx(active, active, false, false, null, null);
5909 isForegroundWindow = false;
5914 Window QueryCapture(void)
5916 return guiApp.windowCaptured;
5919 int GetDocumentID(void)
5923 byte * idBuffer = new0 byte[size];
5926 for(child = children.first; child; child = child.next)
5928 // TO CHECK: Do we want a documentID when we already have a file name?
5929 if(child.style.isDocument && !child.fileName)
5931 if(child.documentID-1 > size - 2)
5933 idBuffer = renew0 idBuffer byte[size*2];
5934 memset(idBuffer + size, 0, size);
5937 idBuffer[child.documentID-1] = 1;
5940 for(c = 0; c<size; c++)
5948 void SetInitSize(Size size)
5951 sizeAnchor.size = size;
5952 normalSizeAnchor = sizeAnchor;
5954 // Break the anchors for moveable/resizable windows
5955 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5957 stateAnchor = normalAnchor;
5958 stateSizeAnchor = normalSizeAnchor;
5960 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5961 Position(x,y, w, h, true, true, true, true, false, true);
5965 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5967 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5969 guiApp.windowIsResizing = resize;
5970 guiApp.windowMoving = this;
5971 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5972 if(guiApp.windowIsResizing)
5974 guiApp.windowMovingStart.x += size.w - 1;
5975 guiApp.windowMovingStart.y += size.h - 1;
5977 guiApp.windowMovingBefore = scrolledPos;
5978 guiApp.windowResizingBefore = size;
5979 guiApp.windowMoving.UpdateDecorations();
5980 if(guiApp.windowIsResizing)
5981 guiApp.resizeEndX = guiApp.resizeEndY = true;
5983 if(setCursorPosition)
5984 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5988 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5989 guiApp.windowMovingStart.x += x - absPosition.x;
5990 guiApp.windowMovingStart.y += y - absPosition.y;
5993 if(guiApp.windowMoving)
5995 if(guiApp.windowMoving.style.nonClient)
5996 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5998 guiApp.windowMoving.parent.SetMouseRangeToClient();
6003 if(this == rootWindow)
6004 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6012 bool result = false;
6016 else if(guiApp && guiApp.driver != null)
6018 void * systemParent = null;
6019 OldLink slaveHolder;
6021 bool visible = !style.hidden;
6025 systemParent = parent;
6026 parent = guiApp.desktop;
6028 last = parent ? parent.children.last : null;
6030 if((parent && parent != guiApp.desktop && !parent.created) ||
6031 (master && master != guiApp.desktop && !master.created))
6035 stopwatching(parent, font);
6038 property::parent = guiApp.desktop;
6039 if(!master) master = parent;
6041 if(_isModal && master.modalSlave)
6042 property::master = master.modalSlave;
6046 parent.children.Remove(this);
6049 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6050 if(slaveHolder.data == this)
6052 master.slaves.Delete(slaveHolder);
6057 if(parent == guiApp.desktop && !mutex)
6060 if(style.isDocument)
6063 parent.numDocuments--;
6064 documentID = parent.GetDocumentID();
6067 if(!style.stayOnTop)
6068 for(; last && last.style.stayOnTop; last = last.prev);
6070 parent.children.Insert((last == this) ? null : last, this);
6071 //parent.children.Add(this);
6074 dispDriver = parent.dispDriver;
6077 master.modalSlave = this;
6079 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6084 master.slaves.Add(slaveHolder = OldLink { data = this });
6089 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6091 if(style.isDefault && !master.defaultControl)
6092 master.defaultControl = this;
6094 stateAnchor = normalAnchor = anchor;
6095 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6097 // TOCHECK: Why is this here?
6098 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6099 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6101 this.visible = false;
6102 style.hidden = true;
6105 // autoCreate = true;
6113 if(parent == guiApp.desktop)
6114 Log("LoadGraphics %s\n", caption);
6116 if(LoadGraphics(true, false))
6124 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6131 if(style.hasMenuBar /*&& menu*/)
6137 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6138 interim = false, inactive = true, nonClient = true, size.h = 24
6146 // Create the system buttons
6147 CreateSystemChildren();
6149 UpdateActiveDocument(null);
6151 if(style.isDocument)
6155 MenuItem item = menu.FindItem(MenuFileSave, 0);
6156 if(item) item.disabled = !modifiedDocument && fileName;
6161 if(parent == guiApp.desktop)
6162 Log("Preemptive SetState %s\n", caption);
6165 // Preemptive Set State to ensure proper anchoring
6166 SetStateEx(state, false);
6168 style.hidden = true;
6174 for(child = children.first; child; child = next)
6177 if(!child.created && (child.autoCreate || child.wasCreated))
6184 for(link = slaves.first; link; link = next)
6186 Window slave = link.data;
6188 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6191 // Things might have happened that invalidated 'next'...
6192 // Start over the search for slaves to create.
6193 // (Added this to fix crash with Stacker & Toolbar)
6194 next = slaves.first;
6203 if(parent == guiApp.desktop)
6204 Log("Real SetState %s\n", caption);
6207 if(isActiveClient && visible)
6209 parent.numPositions--;
6210 if(state == minimized) parent.numIcons--;
6213 parent.OnChildAddedOrRemoved(this, false);
6215 // Real set state & activate for proper display & activation
6216 property::visible = visible;
6217 // SetState(state & 0x00000003, true, 0);
6218 guiApp.interfaceDriver.SetIcon(this, icon);
6223 /*if(rootWindow == this)
6224 guiApp.interfaceDriver.ActivateRootWindow(this);
6226 if(creationActivation == activate)
6227 ActivateEx(true, false, true, true, null, null);
6228 else if(creationActivation == flash)
6233 rootWindow.ConsequentialMouseMove(false);
6244 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6250 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6252 //style.hidden = true; // !visible;
6253 style.hidden = !visible;
6254 if(master.modalSlave == this)
6255 master.modalSlave = null;
6262 void WriteCaption(Surface surface, int x, int y)
6265 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6268 void Update(Box region)
6274 rootWindow = this.rootWindow;
6276 // rootWindow.mutex.Wait();
6277 if(!destroyed && visible && display)
6282 // Testing this to avoid repetitve full update to take time...
6283 if(dirtyArea.count == 1)
6285 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6286 if(item.box.left <= box.left &&
6287 item.box.top <= box.top &&
6288 item.box.right >= box.right &&
6289 item.box.bottom >= box.bottom)
6291 rootWindow.dirty = true;
6296 if(display.flags.flipping && !rootWindow.dirty)
6298 if(this == rootWindow)
6302 rootWindow.Update(null);
6307 rootWindow.dirty = true;
6312 realBox.left += clientStart.x;
6313 realBox.top += clientStart.y;
6314 realBox.right += clientStart.x;
6315 realBox.bottom += clientStart.y;
6321 if(realBox.right >= realBox.left &&
6322 realBox.bottom >= realBox.top)
6324 // if(!rootWindow.fullRender)
6325 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6327 for(child = children.first; child; child = child.next)
6332 box.left -= child.absPosition.x - absPosition.x;
6333 box.top -= child.absPosition.y - absPosition.y;
6334 box.right -= child.absPosition.x - absPosition.x;
6335 box.bottom -= child.absPosition.y - absPosition.y;
6336 if(box.right >= child.box.left && box.left <= child.box.right &&
6337 box.bottom >= child.box.top && box.top <= child.box.bottom)
6339 box.left -= child.clientStart.x;
6340 box.top -= child.clientStart.y;
6341 box.right -= child.clientStart.x;
6342 box.bottom -= child.clientStart.y;
6348 realBox.left += absPosition.x - rootWindow.absPosition.x;
6349 realBox.top += absPosition.y - rootWindow.absPosition.y;
6350 realBox.right += absPosition.x - rootWindow.absPosition.x;
6351 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6352 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6355 else if(this == guiApp.desktop)
6358 for(window = children.first; window; window = window.next)
6364 Box childBox = region;
6366 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6367 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6368 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6369 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6371 window.Update(childBox);
6374 window.Update(null);
6379 // rootWindow.mutex.Release();
6386 if(guiApp.windowCaptured != this)
6388 if(guiApp.windowCaptured)
6392 //Logf("Captured %s (%s)\n", caption, class.name);
6393 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6394 guiApp.windowCaptured = this;
6400 bool Destroy(int code)
6405 if(!destroyed && !CloseConfirmation(false)) return false;
6409 // TOCHECK: Should autoCreate be set to false here?
6420 void Move(int x, int y, int w, int h)
6422 normalAnchor = Anchor { left = x, top = y };
6423 normalSizeAnchor = SizeAnchor { size = { w, h } };
6425 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6427 if(destroyed) return;
6429 stateAnchor = normalAnchor;
6430 stateSizeAnchor = normalSizeAnchor;
6432 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6433 Position(x,y, w, h, true, true, true, true, false, true);
6437 DialogResult Modal(void)
6443 // FIXES MEMORY LEAK IF Create() FAILED
6449 void SetScrollArea(int width, int height, bool snapToStep)
6451 bool resize = false;
6454 int stepX = sbStep.x, stepY = sbStep.y;
6455 // Needed to make snapped down position match the skin's check of client area
6456 // against realvirtual
6459 SNAPDOWN(stepX, textCellW);
6460 SNAPDOWN(stepY, textCellH);
6461 stepX = Max(stepX, textCellW);
6462 stepY = Max(stepY, textCellH);
6464 if(scrollFlags.snapX)
6465 SNAPUP(width, stepX);
6466 if(scrollFlags.snapY)
6467 SNAPUP(height, stepY);
6470 reqScrollArea.w = width;
6471 reqScrollArea.h = height;
6472 noAutoScrollArea = (width > 0 || height > 0);
6474 UpdateScrollBars(true, true);
6477 void SetScrollPosition(int x, int y)
6480 sbh.Action(setPosition, x, 0);
6484 int seen = clientSize.w, total = reqScrollArea.w;
6486 if(scrollFlags.snapX)
6487 SNAPDOWN(seen, sbStep.x);
6489 if(!total) total = seen;
6490 range = total - seen + 1;
6491 range = Max(range, 1);
6493 if(x >= range) x = range - 1;
6495 if(scrollFlags.snapX)
6496 SNAPUP(x, sbStep.x);
6499 OnHScroll(setPosition, x, 0);
6503 SNAPDOWN(x, textCellW);
6509 sbv.Action(setPosition, y, 0);
6513 int seen = clientSize.h, total = reqScrollArea.h;
6516 if(scrollFlags.snapY)
6517 SNAPDOWN(seen, sbStep.y);
6519 if(!total) total = seen;
6520 range = total - seen + 1;
6521 range = Max(range, 1);
6523 if(y >= range) y = range - 1;
6525 if(scrollFlags.snapY)
6526 SNAPUP(y, sbStep.y);
6529 OnVScroll(setPosition, y, 0);
6532 SNAPDOWN(y, textCellH);
6537 UpdateCaret(false, false);
6540 void SetScrollLineStep(int stepX, int stepY)
6546 SNAPDOWN(stepX, textCellW);
6547 SNAPDOWN(stepY, textCellH);
6548 stepX = Max(stepX, textCellW);
6549 stepY = Max(stepY, textCellH);
6552 sbh.lineStep = stepX;
6554 sbv.lineStep = stepY;
6557 void SetState(WindowState newState, bool activate, Modifiers mods)
6561 if(state == newState || OnStateChange(newState, mods))
6563 WindowState prevState = state;
6567 // This used to be at the end of the brackets... moved for X, testing...
6568 // This has the effect of activating the window through the system...
6569 if(rootWindow == this)
6570 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6572 SetStateEx(newState, activate);
6574 if(rootWindow == this && !rootWindow.nativeDecorations)
6576 int x = position.x, y = position.y;
6579 x -= guiApp.desktop.absPosition.x;
6580 y -= guiApp.desktop.absPosition.y;
6582 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6586 //state = prevState;
6588 if(state != maximized && style.hasMaximize)
6591 for(child = parent.children.first; child; child = child.next)
6593 if(child != this && child.state == maximized)
6594 child.SetStateEx(normal, false);
6598 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6599 parent.UpdateScrollBars(true, true);
6602 // Do we really need this stuff here?
6603 // Shouldn't the Activate stuff take care of it?
6604 if(parent.rootWindow == parent && style)
6607 parent.FigureCaption(caption);
6608 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6609 parent.UpdateDecorations();
6613 rootWindow.ConsequentialMouseMove(false);
6620 BitmapResource GetIcon(SkinBitmap iconID)
6622 return guiApp.currentSkin.GetBitmap(iconID);
6625 void SetMouseRange(Box range)
6627 if(range || guiApp.fullScreenMode)
6632 clip.left = range.left + absPosition.x + clientStart.x;
6633 clip.top = range.top + absPosition.y + clientStart.y;
6634 clip.right = range.right + absPosition.x + clientStart.x;
6635 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6639 clip.left = guiApp.desktop.box.left;
6640 clip.top = guiApp.desktop.box.top;
6641 clip.right = guiApp.desktop.box.right;
6642 clip.bottom = guiApp.desktop.box.bottom;
6644 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6647 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6650 void SetMouseRangeToClient(void)
6652 if(guiApp.fullScreenMode || this != guiApp.desktop)
6654 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6655 box.Clip(clientArea);
6659 SetMouseRange(null);
6662 void SetMouseRangeToWindow(void)
6664 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6665 if(this == guiApp.desktop)
6666 SetMouseRangeToClient();
6671 // x, y: Desktop Coordinates
6672 void ShowSysMenu(int x, int y)
6675 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6678 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6679 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6683 menu, $"Move", m, NotifySelect = MenuWindowMove,
6684 disabled = !style.fixed || state == maximized
6688 menu, $"Size", s, NotifySelect = MenuWindowSize,
6689 disabled = !style.sizable || state != normal
6693 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6694 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6698 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6699 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6703 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6704 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6706 MenuDivider { menu };
6709 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6710 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6712 windowMenu.Create();
6717 ActivateEx(true, true, true, true, null, null);
6720 void MakeActive(void)
6722 ActivateEx(true, false, true, false, null, null);
6725 void SoftActivate(void)
6727 if(guiApp.desktop.active)
6733 void Deactivate(void)
6735 ActivateEx(false, true, true, true, null, null);
6740 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6743 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6745 bool result = false;
6746 if(activeChild && activeChild.cycle)
6748 Window modalWindow, child = activeChild;
6749 if(!clientOnly /*&& parent.tabCycle*/)
6751 Window next = child;
6754 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6758 if(parent && parent.CycleChildren(backward, false, true, true))
6766 next = next.cycle.prev.data;
6768 next = next.cycle.next.data;
6769 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6774 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6775 parent.tabCycle && parent.CycleChildren(backward, false, false))
6779 if(tabCycleOnly && !tabCycle) return false;
6786 child = child.cycle.prev.data;
6788 child = child.cycle.next.data;
6789 if(child == child.parent.activeChild)
6791 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6794 modalWindow = child.FindModal();
6797 // Scroll the window to include the active control
6798 if(sbh && !child.style.dontScrollHorz)
6800 if(child.scrolledPos.x < 0)
6801 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6802 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6803 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6805 if(sbv && !child.style.dontScrollVert)
6807 if(child.scrolledPos.y < 0)
6808 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6809 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6810 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6814 child = modalWindow ? modalWindow : child;
6815 child.ActivateEx(true, true, true, true, null, null);
6816 if(child.tabCycle && child.childrenCycle.first)
6817 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6825 ConsequentialMouseMove(false);
6829 void AddResource(Resource resource)
6833 ResPtr ptr { resource = resource };
6837 // Load Graphics here if window is created already
6838 if(/*created && */display)
6840 display.Lock(false);
6841 ptr.loaded = display.displaySystem.LoadResource(resource);
6845 // Temporary hack to load font right away for listbox in dropbox ...
6846 else if(master && master.display)
6848 master.display.Lock(false);
6849 master.display.displaySystem.LoadResource(resource);
6850 master.display.Unlock();
6856 void RemoveResource(Resource resource)
6861 for(ptr = resources.first; ptr; ptr = ptr.next)
6863 if(ptr.resource == resource)
6869 // Unload Graphics here if window is created already
6870 if(/*created && */display)
6874 display.Lock(false);
6875 display.displaySystem.UnloadResource(resource, ptr.loaded);
6881 resources.Delete(ptr);
6886 void SetCaret(int x, int y, int size)
6893 if(active && !style.interim)
6895 if(visible || !guiApp.caretOwner)
6896 guiApp.caretOwner = size ? this : null;
6898 UpdateCaret(false, false);
6901 guiApp.interfaceDriver.SetCaret(0,0,0);
6902 UpdateCaret(false, true);
6903 guiApp.caretEnabled = false;
6906 else if(style.inactive && active)
6908 guiApp.interfaceDriver.SetCaret(0,0,0);
6909 UpdateCaret(false, true);
6910 guiApp.caretEnabled = false;
6915 void Scroll(int x, int y)
6917 bool opaque = !style.drawBehind || background.a;
6918 if(opaque && display && display.flags.scrolling)
6920 Box box = clientArea;
6921 box.left += clientStart.x;
6922 box.top += clientStart.y;
6923 box.right += clientStart.x;
6924 box.bottom += clientStart.y;
6926 //scrollExtent.Free(null);
6927 scrollExtent.AddBox(box);
6928 scrolledArea.x += x;
6929 scrolledArea.y += y;
6931 //scrollExtent.Free();
6932 //scrollExtent.AddBox(clientArea);
6933 //scrollExtent.Offset(clientStart.x, clientStart.y);
6934 //scrolledArea.x = x;
6935 //scrolledArea.y = y;
6941 rootWindow.dirty = true;
6944 void ReleaseCapture()
6946 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6948 Window oldCaptured = guiApp.windowCaptured;
6949 guiApp.windowCaptured = null;
6950 guiApp.prevWindow = null;
6953 //guiApp.Log("Released Capture\n");
6955 guiApp.interfaceDriver.SetMouseCapture(null);
6957 //oldCaptured.OnMouseCaptureLost();
6960 oldCaptured.ConsequentialMouseMove(false);
6965 void SetText(char * format, ...)
6972 char caption[MAX_F_STRING];
6974 va_start(args, format);
6975 vsprintf(caption, format, args);
6978 this.caption = new char[strlen(caption)+1];
6980 strcpy(this.caption, caption);
6989 bool Grab(Bitmap bitmap, Box box, bool decorations)
6991 bool result = false;
6992 if(display || this == guiApp.desktop)
6994 Box clip = {MININT, MININT, MAXINT, MAXINT};
7000 clip.Clip(clientArea);
7002 clip.Clip(this.box);
7004 if(rootWindow != this)
7006 clip.left += absPosition.y;
7007 clip.top += absPosition.y;
7008 clip.right += absPosition.x;
7009 clip.bottom += absPosition.y;
7012 clip.left += decorations ? 0 : clientStart.x;
7013 clip.top += decorations ? 0 : clientStart.y;
7014 clip.right += decorations ? 0 : clientStart.x;
7015 clip.bottom += decorations ? 0 : clientStart.y;
7017 if(display && display.flags.flipping)
7019 rootWindow.Update(null);
7020 rootWindow.UpdateDisplay();
7027 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7028 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7032 result = display.Grab(bitmap, clip.left, clip.top,
7033 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7035 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7037 if(!bitmap.Convert(null, pixelFormat888, null))
7044 void GetMousePosition(int * x, int * y)
7046 int mouseX = 0, mouseY = 0;
7047 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7050 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7051 if(this != guiApp.desktop)
7053 mouseX -= absPosition.x + clientStart.x;
7054 mouseY -= absPosition.y + clientStart.y;
7061 DialogResult DoModal()
7063 DialogResult returnCode = 0;
7064 int terminated = terminateX;
7067 while(!destroyed && guiApp.driver != null)
7069 if(terminateX != terminated)
7071 terminated = terminateX;
7072 guiApp.desktop.Destroy(0);
7073 if(guiApp.desktop.created)
7076 //printf("Resetting terminate X to 0\n");
7082 guiApp.UpdateDisplay();
7083 if(!guiApp.ProcessInput(false))
7086 returnCode = this.returnCode;
7099 return !destroyed && guiApp.driver != null && terminateX < 2;
7102 DialogResult DoModalEnd()
7104 DialogResult returnCode = this.returnCode;
7109 // --- Window manipulation ---
7110 /*bool GetDisabled()
7112 bool disabled = this.disabled;
7114 for(window = this; (window = window.master); )
7125 // --- Mouse Manipulation ---
7126 void GetNCMousePosition(int * x, int * y)
7128 GetMousePosition(x, y);
7129 if(x) *x += clientStart.x;
7130 if(y) *y += clientStart.y;
7133 // --- Carets manipulation ---
7134 void GetCaretPosition(Point caretPos)
7136 caretPos = this.caretPos;
7139 int GetCaretSize(void)
7144 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7150 bool CloseConfirmation(bool parentClosing)
7163 if(!OnClose(parentClosing))
7166 // If you want to skip this, simply set modifiedDocument to false in OnClose
7167 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7169 DialogResult dialogRes;
7172 sprintf(message, $"Save changes to %s?", fileName);
7174 sprintf(message, $"Save changes to Untitled %d?", documentID);
7176 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7178 if(dialogRes == yes)
7180 // TOFIX: Precomp error if brackets are taken out
7181 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7183 else if(dialogRes == cancel)
7189 for(slave = slaves.first; slave; slave = slave.next)
7191 Window w = slave.data;
7192 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7194 // ((Window)slave.data).CloseConfirmation(true);
7203 for(child = children.first; child; child = child.next)
7204 if(child.master != this && !child.CloseConfirmation(true))
7214 // Static methods... move them somewhere else?
7215 void ::RestoreCaret()
7217 if(guiApp.caretOwner)
7218 guiApp.caretOwner.UpdateCaret(false, false);
7221 void ::FreeMouseRange()
7223 guiApp.interfaceDriver.SetMouseRange(null, null);
7227 bool MenuFileClose(MenuItem selection, Modifiers mods)
7229 Window document = activeChild;
7231 document.Destroy(0);
7235 bool MenuFileExit(MenuItem selection, Modifiers mods)
7241 bool MenuFileSave(MenuItem selection, Modifiers mods)
7245 fileMonitor.fileName = null;
7248 if(OnSaveFile(fileName))
7250 //if(OnFileModified != Window::OnFileModified)
7253 fileMonitor.fileName = fileName;
7259 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7260 DialogResult answer = dialog.Modal();
7262 if(answer != yes) return (bool)answer;
7265 return MenuFileSaveAs(selection, mods);
7268 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7270 DialogResult result = (DialogResult)bool::true;
7271 FileDialog fileDialog = saveDialog;
7274 fileDialog = FileDialog {};
7279 fileDialog.filePath = fileName;
7282 char filePath[MAX_FILENAME];
7283 sprintf(filePath, "Untitled %d", documentID);
7284 fileDialog.filePath = filePath;
7286 fileMonitor.fileName = null;
7288 fileDialog.type = save;
7289 fileDialog.text = $"Save As";
7293 fileDialog.master = master.parent ? master : this;
7294 if(fileDialog.Modal() == ok)
7296 char * filePath = fileDialog.filePath;
7298 if(OnSaveFile(filePath))
7301 property::fileName = filePath;
7302 NotifySaved(master, this, filePath);
7307 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7308 DialogResult answer = dialog.Modal();
7323 //if(OnFileModified != Window::OnFileModified && fileName)
7326 fileMonitor.fileName = fileName;
7330 return (bool)result; // Actually returning result from Yes/NoCancel message box
7333 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7335 Window document = activeChild;
7337 for(document = children.first; document; document = next)
7339 next = document.next;
7340 if(document.style.isDocument || document.fileName)
7341 document.MenuFileSave(selection, mods);
7346 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7350 for(document = children.first; document; document = document.next)
7351 //if(document.style.isDocument && document.state == minimized)
7352 if(document.style.isActiveClient && document.state == minimized)
7353 document.SetState(minimized, false, mods);
7357 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7359 Window document = activeChild;
7362 Window firstDocument = null;
7364 OldLink cycle = document.cycle.prev;
7369 if(child.style.isActiveClient && !child.style.hidden)
7373 firstDocument = child;
7374 if(child.state == minimized)
7375 child.SetState(minimized, false, mods);
7378 child.positionID = id++;
7379 child.SetState(normal, false, mods);
7380 child.anchor.left.type = cascade;
7383 child.normalSizeAnchor = *&child.sizeAnchor;
7384 child.normalAnchor = child.anchor;
7386 // Break the anchors for moveable/resizable windows
7387 if(child.style.fixed)
7389 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7391 (*&child.normalAnchor).left = x;
7392 (*&child.normalAnchor).top = y;
7393 (*&child.normalAnchor).right.type = none;
7394 (*&child.normalAnchor).bottom.type = none;
7396 child.normalSizeAnchor.isClientW = false;
7397 child.normalSizeAnchor.isClientH = false;
7398 child.normalSizeAnchor.size.w = w;
7399 child.normalSizeAnchor.size.h = h;
7400 child.anchored = false;
7403 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7405 child.stateAnchor = child.normalAnchor;
7406 child.stateSizeAnchor = child.normalSizeAnchor;
7408 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7409 child.Position(x, y, w, h, true, true, true, true, false, false);
7414 last = children.last;
7415 if(!child.style.stayOnTop)
7416 for(; last && last.style.stayOnTop; last = last.prev);
7417 children.Move(child, last);
7418 childrenOrder.Move(child.order, childrenOrder.last);
7420 if(cycle == document.cycle) break;
7424 firstDocument.Activate();
7429 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7436 // Close all closes all active clients, not all documents
7437 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7439 Window next, document;
7441 for(document = children.first; document; document = next)
7443 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7444 if(document.style.isActiveClient)
7445 if(!document.Destroy(0) && !document.style.hidden)
7451 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7453 if(style.hasMaximize && state != maximized)
7454 SetState(maximized, 0, 0);
7458 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7460 if(style.hasMinimize && state != minimized)
7462 SetState(minimized, 0, 0);
7463 parent.CycleChildren(false, true, false, true);
7468 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7470 MenuMoveOrSize(false, selection ? true : false);
7474 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7476 CycleChildren(false, true, false, true);
7480 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7482 CycleChildren(true, true, false, true);
7486 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7488 MenuMoveOrSize(true, true);
7492 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7495 SetState(normal, 0, 0);
7499 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7502 int id = selection.id;
7503 OldLink cycle = activeClient.cycle;
7505 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7508 Window sibling = cycle.data;
7509 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7517 document = cycle.data;
7518 document.Activate();
7520 //if(activeChild.state == maximized)
7521 // document.SetState(maximized, false, mods);
7522 //else if(document.state == minimized)
7523 // document.SetState(normal, false, mods);
7527 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7529 stayOnTop = !style.stayOnTop;
7533 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7535 Window document = activeChild;
7538 Window firstDocument = null;
7539 OldLink cycle = document.cycle;
7543 Window child = cycle.data;
7544 if(child.style.isActiveClient && !child.style.hidden)
7546 if(!firstDocument) firstDocument = child;
7547 if(child.state == minimized)
7548 child.SetState(minimized, false, mods);
7551 child.positionID = id++;
7552 child.SetState(normal, false, mods);
7553 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7555 child.anchor.left.type = hTiled;
7558 child.normalSizeAnchor = *&child.sizeAnchor;
7559 child.normalAnchor = child.anchor;
7561 // Break the anchors for moveable/resizable windows
7562 if(child.style.fixed)
7564 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7566 (*&child.normalAnchor).left = x;
7567 (*&child.normalAnchor).top = y;
7568 (*&child.normalAnchor).right.type = none;
7569 (*&child.normalAnchor).bottom.type = none;
7570 child.normalSizeAnchor.isClientW = false;
7571 child.normalSizeAnchor.isClientH = false;
7572 child.normalSizeAnchor.size.w = w;
7573 child.normalSizeAnchor.size.h = h;
7574 child.anchored = false;
7577 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7579 child.stateAnchor = child.normalAnchor;
7580 child.stateSizeAnchor = child.normalSizeAnchor;
7582 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7583 child.Position(x,y, w, h, true, true, true, true, false, true);
7588 if((cycle = cycle.next) == document.cycle) break;
7591 firstDocument.Activate();
7596 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7598 Window document = activeChild;
7601 Window firstDocument = null;
7603 OldLink cycle = document.cycle;
7608 //if(child.style.isDocument)
7609 if(child.style.isActiveClient && !child.style.hidden)
7611 if(!firstDocument) firstDocument = child;
7612 if(child.state == minimized)
7613 child.SetState(minimized, false, mods);
7616 child.positionID = id++;
7617 child.SetState(normal, false, mods);
7618 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7620 child.anchor.left.type = vTiled;
7623 child.normalSizeAnchor = *&child.sizeAnchor;
7624 child.normalAnchor = child.anchor;
7626 // Break the anchors for moveable/resizable windows
7627 if(child.style.fixed)
7629 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7631 (*&child.normalAnchor).left = x;
7632 (*&child.normalAnchor).top = y;
7633 (*&child.normalAnchor).right.type = none;
7634 (*&child.normalAnchor).bottom.type = none;
7635 child.normalSizeAnchor.isClientW = false;
7636 child.normalSizeAnchor.isClientH = false;
7637 child.normalSizeAnchor.size.w = w;
7638 child.normalSizeAnchor.size.h = h;
7639 child.anchored = false;
7642 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7644 child.stateAnchor = child.normalAnchor;
7645 child.stateSizeAnchor = child.normalSizeAnchor;
7647 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7648 child.Position(x,y, w, h, true, true, true, true, false, true);
7653 if((cycle = cycle.next) == document.cycle) break;
7656 firstDocument.Activate();
7661 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7663 WindowList dialog { master = this };
7664 Window document = (Window)dialog.Modal();
7667 if(activeChild.state == maximized)
7668 document.SetState(maximized, false, mods);
7669 else if(document.state == minimized)
7670 document.SetState(normal, false, mods);
7671 document.Activate();
7677 virtual bool OnCreate(void);
7678 virtual void OnDestroy(void);
7679 virtual void OnDestroyed(void);
7680 virtual bool OnClose(bool parentClosing);
7681 virtual bool OnStateChange(WindowState state, Modifiers mods);
7682 virtual bool OnPostCreate(void);
7683 virtual bool OnMoving(int *x, int *y, int w, int h);
7684 virtual bool OnResizing(int *width, int *height);
7685 virtual void OnResize(int width, int height);
7686 virtual void OnPosition(int x, int y, int width, int height);
7687 virtual bool OnLoadGraphics(void);
7688 virtual void OnApplyGraphics(void);
7689 virtual void OnUnloadGraphics(void);
7690 virtual void OnRedraw(Surface surface);
7691 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7692 virtual void OnActivateClient(Window client, Window previous);
7693 virtual bool OnKeyDown(Key key, unichar ch);
7694 virtual bool OnKeyUp(Key key, unichar ch);
7695 virtual bool OnKeyHit(Key key, unichar ch);
7696 virtual bool OnSysKeyDown(Key key, unichar ch);
7697 virtual bool OnSysKeyUp(Key key, unichar ch);
7698 virtual bool OnSysKeyHit(Key key, unichar ch);
7699 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7700 virtual bool OnMouseLeave(Modifiers mods);
7701 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7702 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7703 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7704 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7705 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7706 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7707 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7708 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7709 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7710 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7711 virtual void OnMouseCaptureLost(void);
7712 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7713 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7714 virtual void OnDrawOverChildren(Surface surface);
7715 virtual bool OnFileModified(FileChange fileChange, char * param);
7716 virtual bool OnSaveFile(char * fileName);
7718 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7719 // Note: A 'client' would refer to isActiveClient, rather than
7720 // being confined to the 'client area' (nonClient == false)
7721 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7722 virtual void OnChildVisibilityToggled(Window child, bool visible);
7723 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7725 // Skins Virtual Functions
7726 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7727 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7728 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7733 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7734 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7735 virtual bool IsMouseMoving(int x, int y, int w, int h);
7736 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY);
7737 virtual void UpdateNonClient();
7738 virtual void SetBox(Box box);
7739 virtual bool IsInside(int x, int y)
7741 return box.IsPointInside({x, y});
7743 virtual bool IsOpaque()
7745 return (!style.drawBehind || background.a == 255);
7749 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7750 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7751 virtual void Window::NotifySaved(Window window, char * filePath);
7756 property Window parent
7758 property_category $"Layout"
7761 if(value || guiApp.desktop)
7764 Window oldParent = parent;
7765 Anchor anchor = this.anchor;
7767 if(value && value.IsDescendantOf(this)) return;
7768 if(value && value == this)
7770 if(!value) value = guiApp.desktop;
7772 if(value == oldParent) return;
7774 if(!master || (master == this.parent && master == guiApp.desktop))
7775 property::master = value;
7779 parent.children.Remove(this);
7783 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7784 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7785 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7786 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7790 last = value.children.last;
7792 if(style.isDocument)
7795 parent.numDocuments--;
7796 documentID = value.GetDocumentID();
7799 if(style.isActiveClient && !style.hidden)
7801 if(parent && parent != guiApp.desktop && !(style.hidden))
7803 if(state == minimized) parent.numIcons--;
7804 parent.numPositions--;
7808 if(!style.stayOnTop)
7809 for(; last && last.style.stayOnTop; last = last.prev);
7811 value.children.Insert(last, this);
7813 // *** NEW HERE: ***
7815 parent.childrenCycle.Delete(cycle);
7817 parent.childrenOrder.Delete(order);
7820 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7821 // Should something else be done?
7822 if(parent && parent.activeChild == this)
7823 parent.activeChild = null;
7824 if(parent && parent.activeClient == this)
7825 parent.activeClient = null;
7831 int x = position.x, y = position.y, w = size.w, h = size.h;
7835 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7836 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7838 vpw = value.clientSize.w;
7839 vph = value.clientSize.h;
7845 else if(style.fixed)
7847 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7848 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7851 anchor = this.anchor;
7853 if(anchor.left.type == offset) anchor.left.distance = x;
7854 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7855 if(anchor.top.type == offset) anchor.top.distance = y;
7856 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7857 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7858 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7859 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7860 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7861 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7862 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7864 if(!anchor.left.type && !anchor.right.type)
7866 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7867 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7869 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7870 if(!anchor.top.type && !anchor.bottom.type)
7872 anchor.vert.distance = (y + h / 2) - (vph / 2);
7873 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7875 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7878 parent.OnChildAddedOrRemoved(this, false);
7884 parent.childrenCycle.Insert(
7885 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7886 cycle = OldLink { data = this });
7887 parent.childrenOrder.Insert(
7888 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7889 order = OldLink { data = this });
7892 if(!style.hidden && style.isActiveClient)
7894 positionID = parent.GetPositionID(this);
7895 parent.numPositions++;
7896 if(state == minimized) parent.numIcons--;
7899 // *** FONT INHERITANCE ***
7900 if(!setFont && oldParent)
7901 stopwatching(oldParent, font);
7905 RemoveResource(systemFont);
7908 // TESTING WITH WATCHERS:
7909 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7910 // usedFont = setFont ? setFont : (systemFont);
7914 if(guiApp.currentSkin)
7916 systemFont = guiApp.currentSkin.SystemFont();
7919 usedFont = systemFont;
7920 AddResource(systemFont);
7928 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7937 if(value.rootWindow && value.rootWindow.display && rootWindow)
7939 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7940 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7943 UnloadGraphics(false);
7946 LoadGraphics(false, false);
7949 if(value.rootWindow != rootWindow)
7950 DisplayModeChanged();
7954 scrolledPos.x = MININT; // Prevent parent update
7956 bool anchored = this.anchored;
7957 property::anchor = anchor;
7958 this.anchored = anchored;
7963 if(guiApp.currentSkin)
7964 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7966 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7967 Position(x, y, w, h, true, true, true, true, false, true);
7972 // else parent = value;
7974 oldParent.OnChildAddedOrRemoved(this, true);
7977 get { return parent; }
7980 property Window master
7982 property_category $"Behavior"
7985 //if(this == value) return;
7986 if(value && value.IsSlaveOf(this)) return;
7992 OldLink slaveHolder;
7993 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7994 if(slaveHolder.data == this)
7996 master.slaves.Delete(slaveHolder);
8003 value.slaves.Add(OldLink { data = this });
8008 master.hotKeys.Remove(hotKey);
8009 value.hotKeys.Add(hotKey);
8012 if(master && master.defaultControl == this)
8013 master.defaultControl = null;
8015 if(style.isDefault && !value.defaultControl)
8016 value.defaultControl = this;
8021 get { return master ? master : parent; }
8024 property char * caption
8026 property_category $"Appearance"
8033 caption = new char[strlen(value)+1];
8035 strcpy(caption, value);
8040 get { return caption; }
8045 property_category $"Behavior"
8054 master.hotKeys.Add(hotKey = HotKeySlot { });
8058 hotKey.window = this;
8063 master.hotKeys.Delete(hotKey);
8068 get { return hotKey ? hotKey.key : 0; }
8071 property Color background
8073 property_category $"Appearance"
8076 background.color = value;
8081 if(this == rootWindow)
8082 guiApp.interfaceDriver.SetRootWindowColor(this);
8085 get { return background.color; }
8088 property Percentage opacity
8090 property_category $"Appearance"
8093 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8094 drawBehind = (background.a == 255) ? false : true;
8096 get { return background.a / 255.0f; }
8099 property Color foreground
8101 property_category $"Appearance"
8109 get { return foreground; }
8112 property BorderStyle borderStyle
8114 property_category $"Appearance"
8117 if(!((BorderBits)value).fixed)
8119 style.hasClose = false;
8120 style.hasMaximize = false;
8121 style.hasMinimize = false;
8122 nativeDecorations = false;
8124 style.borderBits = value;
8128 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8130 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8131 Position(x, y, w, h, true, true, true, true, false, true);
8132 CreateSystemChildren();
8135 get { return (BorderStyle)style.borderBits; }
8138 property Size minClientSize
8140 property_category $"Layout"
8141 set { minSize = value; }
8142 get { value = minSize; }
8145 property Size maxClientSize
8147 property_category $"Layout"
8148 set { maxSize = value; }
8149 get { value = maxSize; }
8152 property bool hasMaximize
8154 property_category $"Window Style"
8157 style.hasMaximize = value;
8158 if(value) { style.fixed = true; style.contour = true; }
8162 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8164 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8165 Position(x, y, w, h, true, true, true, true, false, true);
8167 CreateSystemChildren();
8170 get { return style.hasMaximize; }
8173 property bool hasMinimize
8175 property_category $"Window Style"
8178 style.hasMinimize = value;
8179 if(value) { style.fixed = true; style.contour = true; }
8183 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8185 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8186 Position(x, y, w, h, true, true, true, true, false, true);
8188 CreateSystemChildren();
8191 get { return style.hasMinimize; }
8194 property bool hasClose
8196 property_category $"Window Style"
8199 style.hasClose = value;
8200 if(value) { style.fixed = true; style.contour = true; }
8204 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8205 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8206 Position(x, y, w, h, true, true, true, true, false, true);
8207 CreateSystemChildren();
8210 get { return style.hasClose; }
8213 property bool nonClient
8215 property_category $"Layout"
8218 style.nonClient = value;
8220 style.stayOnTop = true;
8222 get { return style.nonClient; }
8225 property bool inactive
8227 property_category $"Behavior"
8232 // *** NEW HERE: ***
8236 parent.childrenCycle.Delete(cycle);
8238 parent.childrenOrder.Delete(order);
8245 active = false; // true;
8246 if(parent.activeChild == this)
8247 parent.activeChild = null;
8248 if(parent.activeClient == this)
8249 parent.activeClient = null;
8258 parent.childrenCycle.Insert(
8259 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8260 cycle = OldLink { data = this });
8262 parent.childrenOrder.Insert(
8263 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8264 order = OldLink { data = this });
8267 style.inactive = value;
8269 get { return style.inactive; }
8272 property bool clickThrough
8274 property_category $"Behavior"
8275 set { style.clickThrough = value; }
8276 get { return style.clickThrough; }
8279 property bool isRemote
8281 property_category $"Behavior"
8282 set { style.isRemote = value; }
8283 get { return style.isRemote; }
8286 property bool noCycle
8288 property_category $"Behavior"
8289 set { style.noCycle = value; }
8290 get { return style.noCycle; }
8293 property bool isModal
8295 property_category $"Behavior"
8296 set { style.modal = value; }
8297 get { return style.modal; }
8300 property bool interim
8302 property_category $"Behavior"
8303 set { style.interim = value; }
8304 get { return style.interim; }
8307 property bool tabCycle
8309 property_category $"Behavior"
8310 set { style.tabCycle = value; }
8311 get { return style.tabCycle; }
8314 property bool isDefault
8316 property_category $"Behavior"
8324 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8325 if(sibling != this && sibling.style.isDefault)
8326 sibling.style.isDefault = false;*/
8327 if(master.defaultControl)
8328 master.defaultControl.style.isDefault = false;
8329 master.defaultControl = this;
8331 else if(master.defaultControl == this)
8332 master.defaultControl = null;
8336 style.isDefault = value;
8338 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8340 get { return style.isDefault; }
8343 property bool drawBehind
8345 property_category $"Window Style"
8346 set { style.drawBehind = value; }
8347 get { return style.drawBehind; }
8350 property bool hasMenuBar
8352 property_category $"Window Style"
8362 if(created && !menuBar)
8369 anchor = Anchor { top = 23, left = 1, right = 1 },
8371 inactive = true, nonClient = true
8376 else if(created && menuBar)
8381 style.hasMenuBar = value;
8383 get { return style.hasMenuBar; }
8386 property bool hasStatusBar
8388 property_category $"Window Style"
8395 statusBar = StatusBar { this };
8403 style.hasStatusBar = value;
8405 get { return style.hasStatusBar; }
8407 property bool stayOnTop
8409 property_category $"Window Style"
8414 if(created && !style.stayOnTop)
8416 if(rootWindow == this)
8417 guiApp.interfaceDriver.OrderRootWindow(this, true);
8418 else if(parent.children.last != this)
8420 parent.children.Move(this, parent.children.last);
8424 style.stayOnTop = true;
8428 if(created && style.stayOnTop)
8430 if(rootWindow == this)
8431 guiApp.interfaceDriver.OrderRootWindow(this, false);
8438 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8439 order && ((Window)order.data).style.stayOnTop;
8440 order = (order == parent.childrenOrder.first) ? null : order.prev);
8441 last = order ? order.data : null;
8445 for(last = parent.children.last;
8446 last && last.style.stayOnTop;
8450 parent.children.Move(this, last);
8454 style.stayOnTop = false;
8457 get { return style.stayOnTop; }
8462 property_category $"Window Style"
8472 if(menuBar && !value)
8479 if(!menuBar && style.hasMenuBar && value)
8483 this, menu = value, isMenuBar = true,
8484 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8485 inactive = true, nonClient = true
8489 UpdateActiveDocument(null);
8492 get { return menu; }
8495 property FontResource font
8497 property_category $"Appearance"
8499 isset { return setFont ? true : false; }
8504 if(value && !setFont) { stopwatching(parent, font); }
8505 else if(!value && setFont)
8511 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8520 RemoveResource(setFont);
8525 RemoveResource(systemFont);
8532 AddResource(setFont);
8535 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8538 systemFont = guiApp.currentSkin.SystemFont();
8540 usedFont = systemFont;
8541 AddResource(systemFont);
8549 get { return usedFont; }
8552 property SizeAnchor sizeAnchor
8554 property_category $"Layout"
8557 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8558 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8559 sizeAnchor.isClientW != sizeAnchor.isClientH;
8566 normalSizeAnchor = sizeAnchor;
8568 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8570 stateAnchor = normalAnchor;
8571 stateSizeAnchor = normalSizeAnchor;
8573 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8574 Position(x,y, w, h, true, true, true, true, false, true);
8581 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8582 sizeAnchor.isClientW,
8583 sizeAnchor.isClientH
8590 property_category $"Layout"
8593 Anchor thisAnchor = anchor;
8594 SizeAnchor thisSizeAnchor = sizeAnchor;
8595 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8596 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8597 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8598 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8599 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8600 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8606 sizeAnchor.isClientW = false;
8607 sizeAnchor.isClientH = false;
8608 sizeAnchor.size = value;
8610 normalSizeAnchor = sizeAnchor;
8612 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8614 stateAnchor = normalAnchor;
8615 stateSizeAnchor = normalSizeAnchor;
8617 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8618 Position(x, y, w, h, true, true, true, true, false, true);
8619 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8622 get { value = size; }
8625 property Size clientSize
8627 property_category $"Layout"
8630 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8631 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8632 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8637 sizeAnchor.isClientW = true;
8638 sizeAnchor.isClientH = true;
8639 sizeAnchor.size = value;
8641 normalSizeAnchor = sizeAnchor;
8643 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8645 stateAnchor = normalAnchor;
8646 stateSizeAnchor = normalSizeAnchor;
8648 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8649 Position(x,y, w, h, true, true, true, true, false, true);
8652 get { value = clientSize; }
8655 property Size initSize { get { value = sizeAnchor.size; } };
8657 property Anchor anchor
8659 property_category $"Layout"
8660 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8666 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8668 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8669 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8671 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8673 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8674 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8678 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8680 anchor.left.distance = 0;
8681 anchor.horz.type = 0;
8683 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8685 anchor.top.distance = 0;
8686 anchor.vert.type = 0;
8695 normalAnchor = anchor;
8697 // Break the anchors for moveable/resizable windows
8698 /*if(style.fixed ) //&& value.left.type == cascade)
8700 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8702 this.anchor = normalAnchor = Anchor { left = x, top = y };
8703 normalSizeAnchor = SizeAnchor { { w, h } };
8706 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8708 stateAnchor = normalAnchor;
8709 stateSizeAnchor = normalSizeAnchor;
8711 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8712 Position(x, y, w, h, true, true, true, true, false, true);
8721 get { value = this ? anchor : Anchor { }; }
8724 property Point position
8726 property_category $"Layout"
8729 if(value == null) return;
8731 anchor.left = value.x;
8732 anchor.top = value.y;
8733 anchor.right.type = none;
8734 anchor.bottom.type = none;
8739 normalAnchor = anchor;
8741 // Break the anchors for moveable/resizable windows
8745 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8747 normalAnchor.left = x;
8748 normalAnchor.top = y;
8749 normalAnchor.right.type = none;
8750 normalAnchor.bottom.type = none;
8751 normalSizeAnchor.size.width = w;
8752 normalSizeAnchor.size.height = h;
8756 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8758 stateAnchor = normalAnchor;
8759 stateSizeAnchor = normalSizeAnchor;
8761 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8762 Position(x,y, w, h, true, true, true, true, false, true);
8766 get { value = position; }
8769 property bool disabled
8771 property_category $"Behavior"
8774 if(this && disabled != value)
8781 get { return (bool)disabled; }
8784 property bool isEnabled
8789 for(parent = this; parent; parent = parent.parent)
8796 property WindowState state
8798 property_category $"Behavior"
8799 set { SetState(value, false, 0); }
8800 get { return this ? state : 0; }
8803 property bool visible
8805 property_category $"Behavior"
8808 if(this && !value && !style.hidden && parent)
8810 bool wasActiveChild = parent.activeChild == this;
8811 Window client = null;
8813 style.hidden = true;
8814 if(style.isActiveClient)
8816 parent.numPositions--;
8817 if(state == minimized) parent.numIcons--;
8822 OldLink prevOrder = null;
8824 if(rootWindow == this)
8825 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8828 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8831 box.left -= parent.clientStart.x;
8832 box.top -= parent.clientStart.y;
8833 box.right -= parent.clientStart.x;
8834 box.bottom -= parent.clientStart.y;
8838 if(_isModal && master && master.modalSlave == this)
8839 master.modalSlave = null;
8843 OldLink tmpPrev = order.prev;
8844 client = tmpPrev ? tmpPrev.data : null;
8845 if(client && !client.style.hidden && !client.destroyed && client.created)
8846 prevOrder = tmpPrev;
8849 client = tmpPrev ? tmpPrev.data : null;
8850 if(client == this) { client = null; break; }
8851 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8853 tmpPrev = client.order.prev;
8858 prevOrder = tmpPrev;
8863 // If this window can be an active client, make sure the next window we activate can also be one
8864 if(!style.nonClient && style.isActiveClient)
8866 tmpPrev = prevOrder;
8869 client = tmpPrev ? tmpPrev.data : null;
8870 if(client == this) { client = null; break; }
8871 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8873 tmpPrev = client.order.prev;
8878 prevOrder = tmpPrev;
8882 if(client && client.style.hidden) client = null;
8886 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8888 if(order && prevOrder && prevOrder.data != this)
8889 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8891 ActivateEx(false, false, false, true, null, null);
8893 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8894 if(parent.activeClient == this)
8896 parent.activeClient = null;
8897 parent.UpdateActiveDocument(null);
8900 else if(parent.activeClient == this)
8902 parent.activeClient = client;
8903 parent.UpdateActiveDocument(this);
8906 // *** Not doing this anymore ***
8909 parent.childrenCycle.Delete(cycle);
8911 parent.childrenOrder.Delete(order);
8916 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8921 else if(this && value && style.hidden)
8923 style.hidden = false;
8926 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8927 if(rootWindow == this)
8928 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8930 if(_isModal && master)
8931 master.modalSlave = this;
8933 if(style.isActiveClient)
8935 positionID = parent.GetPositionID(this);
8936 parent.numPositions++;
8937 if(state == minimized) parent.numIcons++;
8940 // *** NOT DOING THIS ANYMORE ***
8942 if(!(style.inactive))
8944 if(!(style.noCycle))
8946 cycle = parent.childrenCycle.AddAfter(
8947 (parent.activeChild && parent.activeChild.cycle) ?
8948 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8951 order = parent.childrenOrder.AddAfter(
8952 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8959 if(true || !parent.activeChild)
8960 ActivateEx(true, false, true, true, null, null);
8962 if(creationActivation == activate)
8963 ActivateEx(true, false, true, true, null, null);
8964 else if(creationActivation == flash && !object)
8967 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8971 ConsequentialMouseMove(false);
8977 style.hidden = !value;
8980 get { return (style.hidden || !setVisible) ? false : true; }
8983 property bool isDocument
8985 property_category $"Document"
8986 set { style.isDocument = value; }
8987 get { return style.isDocument; }
8990 property bool mergeMenus
8992 property_category $"Window Style"
8993 set { mergeMenus = value; }
8994 get { return (bool)mergeMenus; }
8997 property bool hasHorzScroll
8999 property_category $"Window Style"
9004 if(!style.hasHorzScroll && created)
9006 CreateSystemChildren();
9007 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9010 else if(style.hasHorzScroll)
9014 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9016 style.hasHorzScroll = value;
9019 get { return style.hasHorzScroll; }
9022 property bool hasVertScroll
9024 property_category $"Window Style"
9029 if(!style.hasVertScroll && created)
9031 style.hasVertScroll = true;
9032 CreateSystemChildren();
9033 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9036 else if(style.hasVertScroll)
9040 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9042 style.hasVertScroll = value;
9044 get { return style.hasVertScroll; }
9047 property bool dontHideScroll
9049 property_category $"Behavior"
9052 scrollFlags.dontHide = value;
9055 //UpdateScrollBars(true, true);
9056 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9060 // UpdateScrollBars(true, true);
9061 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9064 get { return scrollFlags.dontHide; }
9067 property bool dontScrollVert
9069 property_category $"Behavior"
9070 set { style.dontScrollVert = value; }
9071 get { return style.dontScrollVert; }
9073 property bool dontScrollHorz
9075 property_category $"Behavior"
9076 set { style.dontScrollHorz = value; }
9077 get { return style.dontScrollHorz; }
9080 property bool snapVertScroll
9082 property_category $"Behavior"
9085 scrollFlags.snapY = value;
9086 if(sbv) sbv.snap = value;
9088 get { return scrollFlags.snapY; }
9090 property bool snapHorzScroll
9092 property_category $"Behavior"
9095 scrollFlags.snapX = value;
9096 if(sbh) sbh.snap = value;
9098 get { return scrollFlags.snapX; }
9101 property Point scroll
9103 property_category $"Behavior"
9104 set { SetScrollPosition(value.x, value.y); }
9105 get { value = scroll; }
9108 property bool modifyVirtualArea
9110 property_category $"Behavior"
9111 set { modifyVirtArea = value; }
9112 get { return (bool)modifyVirtArea; }
9115 property bool dontAutoScrollArea
9117 property_category $"Behavior"
9118 // Activating a child control out of view will automatically scroll to make it in view
9119 set { noAutoScrollArea = value; }
9120 get { return (bool)noAutoScrollArea; }
9123 property char * fileName
9125 property_category $"Document"
9128 if(menu && ((!fileName && value) || (fileName && !value)))
9130 MenuItem item = menu.FindItem(MenuFileSave, 0);
9131 if(item) item.disabled = !modifiedDocument && value;
9136 if(value && value[0])
9137 fileName = CopyString(value);
9139 if(parent && this == parent.activeClient)
9140 parent.UpdateActiveDocument(null);
9144 // if(style.isDocument)
9146 fileMonitor.fileName = value;
9148 get { return fileName; }
9153 property_category $"Data"
9158 property bool modifiedDocument
9160 property_category $"Document"
9163 if(style.isDocument || fileName)
9167 MenuItem item = menu.FindItem(MenuFileSave, 0);
9168 if(item) item.disabled = !value && fileName;
9172 if(modifiedDocument != value)
9174 modifiedDocument = value;
9175 if(style.isDocument || fileName)
9179 get { return (bool)modifiedDocument; }
9182 property bool showInTaskBar
9184 property_category $"Window Style"
9185 set { style.showInTaskBar = value; }
9186 get { return (style.showInTaskBar; }
9188 property FileDialog saveDialog { set { saveDialog = value; } };
9189 property bool isActiveClient
9191 property_category $"Behavior"
9192 set { style.isActiveClient = value; }
9193 get { return style.isActiveClient; }
9196 property Cursor cursor
9198 property_category $"Appearance"
9202 SelectMouseCursor();
9204 get { return cursor; }
9207 //#if !defined(ECERE_VANILLA)
9208 property char * name
9210 property_category $"Design"
9213 return (this && object) ? object.name : null;
9218 activeDesigner.RenameObject(object, value);
9222 property char * displayDriver
9224 property_category $"Behavior"
9227 dispDriver = GetDisplayDriver(value);
9228 //DisplayModeChanged();
9232 return dispDriver ? dispDriver.name : null;
9236 // RUNTIME PROPERTIES
9237 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9238 property Size scrollArea
9240 property_category $"Behavior"
9244 SetScrollArea(value.w, value.h, false);
9246 SetScrollArea(0,0, true);
9248 get { value = scrollArea; }
9251 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9256 property_category $"Layout"
9257 set { if(this) is3D = value; }
9258 get { return (bool)is3D; }
9261 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9263 // Will be merged with font later
9264 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9265 property Point clientStart { get { value = clientStart; } };
9266 property Point absPosition { get { value = absPosition; } };
9267 property Anchor normalAnchor { get {value = normalAnchor; } };
9268 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9269 property bool active { get { return (bool)active; } };
9270 property bool created { get { return (bool)created; } };
9271 property bool destroyed { get { return (bool)destroyed; } };
9272 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9273 property Window firstChild { get { return children.first; } };
9274 property Window lastChild { get { return children.last; } };
9275 property Window activeClient { get { return activeClient; } };
9276 property Window activeChild { get { return activeChild; } };
9277 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9278 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9279 property ScrollBar horzScroll { get { return sbh; } };
9280 property ScrollBar vertScroll { get { return sbv; } };
9281 property StatusBar statusBar { get { return statusBar; } };
9282 property Window rootWindow { get { return rootWindow; } };
9283 property bool closing { get { return (bool)closing; } set { closing = value; } };
9284 property int documentID { get { return documentID; } };
9285 property Window previous { get { return prev; } }
9286 property Window next { get { return next; } }
9287 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9288 property PopupMenu menuBar { get { return menuBar; } }
9289 property ScrollBar sbv { get { return sbv; } }
9290 property ScrollBar sbh { get { return sbh; } }
9291 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9292 property void * systemHandle { get { return windowHandle; } }
9293 property Button minimizeButton { get { return sysButtons[0]; } };
9294 property Button maximizeButton { get { return sysButtons[1]; } };
9295 property Button closeButton { get { return sysButtons[2]; } };
9296 property BitmapResource icon
9298 get { return icon; }
9302 if(icon) incref icon;
9304 guiApp.interfaceDriver.SetIcon(this, value);
9307 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9308 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9309 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9310 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9311 property bool nativeDecorations
9313 get { return (bool)nativeDecorations; }
9314 set { nativeDecorations = value; }
9315 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9318 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9319 bool result = false;
9320 if(nativeDecorations)
9322 if(rootWindow == this)
9326 if(formDesigner && activeDesigner)
9328 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9329 Window form = cd ? cd.form : null;
9330 if(form && parent == form.parent)
9335 return result != style.fixed;
9339 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9341 property char * text
9343 property_category $"Deprecated"
9345 set { property::caption = value; }
9346 get { return property::caption; }
9352 WindowBits style; // Window Style
9353 char * caption; // Name / Caption
9354 Window parent; // Parent window
9355 OldList children; // List of children in Z order
9356 Window activeChild; // Child window having focus
9357 Window activeClient;
9358 Window previousActive; // Child active prior to activating the default child
9359 Window master; // Window owning and receiving notifications concerning this window
9360 OldList slaves; // List of windows belonging to this window
9361 Display display; // Display this window is drawn into
9363 Point position; // Position in parent window client area
9364 Point absPosition; // Absolute position
9365 Point clientStart; // Client area position from (0,0) in this window
9367 Size clientSize; // Client area size
9368 Size scrollArea; // Virtual Scroll area size
9369 Size reqScrollArea; // Requested virtual area size
9370 Point scroll; // Virtual area scrolling position
9371 public ScrollBar sbh, sbv; // Scrollbar window handles
9372 Cursor cursor; // Mouse cursor used for this window
9375 StatusBar statusBar;
9376 Button sysButtons[3];
9378 Box clientArea; // Client Area box clipped to parent
9380 HotKeySlot hotKey; // HotKey for this window
9384 ScrollFlags scrollFlags;// Window Scrollbar Flags
9385 int id; // Control ID
9387 ColorAlpha background; // Background color used to draw the window area
9389 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9390 OldList childrenCycle; // Cycling order
9391 OldLink cycle; // Element of parent's cycling order
9392 OldList childrenOrder; // Circular Z-Order
9393 OldLink order; // Element of parent's circular Z-Order
9394 Window modalSlave; // Slave window blocking this window's interaction
9396 Window rootWindow; // Topmost system managed window
9397 void * windowHandle; // System window handle
9399 DialogResult returnCode;// Return code for modal windows
9401 Point sbStep; // Scrollbar line scrolling steps
9404 SizeAnchor stateSizeAnchor;
9406 Anchor normalAnchor;
9407 SizeAnchor normalSizeAnchor;
9409 Size skinMinSize; // Minimal window size based on style
9410 Point scrolledPos; // Scrolled position
9411 Box box; // Window box clipped to parent
9412 Box * against; // What to clip the box to
9414 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9415 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9416 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9417 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9418 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9419 Point scrolledArea; // Distance to scroll area by
9420 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9422 OldList hotKeys; // List of the hotkeys of all children
9423 Window defaultControl; // Default child control
9427 ColorAlpha * palette; // Color palette used for this window
9429 int caretSize; // Size of caret, non zero if a caret is present
9430 Point caretPos; // Caret position
9432 void * systemParent; // Parent System Window for embedded windows
9439 WindowState lastState;
9441 FileMonitor fileMonitor
9443 this, FileChange { modified = true };
9445 bool OnFileNotify(FileChange action, char * param)
9448 fileMonitor.StopMonitoring();
9449 if(OnFileModified(action, param))
9450 fileMonitor.StartMonitoring();
9455 FontResource setFont, systemFont;
9456 FontResource usedFont;
9457 FontResource captionFont;
9459 FileDialog saveDialog;
9461 SizeAnchor sizeAnchor;
9463 // FormDesigner data
9466 Extent * tempExtents; //[4];
9467 BitmapResource icon;
9469 CreationActivationOption creationActivation;
9472 bool active:1; // true if window and ancestors are active
9473 bool acquiredInput:1; // true if the window is processing state based input
9474 bool modifiedDocument:1;
9475 bool disabled:1; // true if window cannot interact
9476 bool isForegroundWindow:1;// true while a root window is being activated
9477 bool visible:1; // Visibility flag
9478 bool destroyed:1; // true if window is being destroyed
9479 bool anchored:1; // true if this window is repositioned when the parent resizes
9480 bool dirty:1; // Flag set to true if any descendant must be redrawn
9486 bool modifyVirtArea:1;
9487 bool noAutoScrollArea:1;
9490 bool setVisible:1; // FOR FORM DESIGNER
9496 bool useSharedMemory:1;
9499 bool nativeDecorations:1;
9500 bool manageDisplay:1;
9501 bool formDesigner:1; // True if we this is running in the form editor
9504 // Checks used internally for them not to take effect in FormDesigner
9505 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9506 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9508 WindowController controller;
9509 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9512 public class CommonControl : Window
9514 // creationActivation = doNothing;
9517 public property String toolTip
9519 property_category $"Appearance"
9522 if(created) CommonControl::OnDestroy();
9524 toolTip = value ? ToolTip { tip = value; } : null;
9526 if(created) CommonControl::OnCreate();
9528 get { return toolTip ? toolTip.tip : null; }
9534 // (Very) Ugly work around for the fact that the parent watcher
9535 // won't fire when it's already been disconnected...
9536 eInstance_FireSelfWatchers(toolTip,
9537 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9543 toolTip.parent = this;
9552 public class Percentage : float
9554 char * OnGetString(char * string, float * fieldData, bool * needClass)
9558 sprintf(string, "%.2f", this);
9559 c = strlen(string)-1;
9562 if(string[c] != '0')
9563 last = Max(last, c);
9564 if(string[c] == '.')
9577 public void ApplySkin(Class c, char * name, void ** vTbl)
9579 char className[1024];
9584 subclass(Window) wc = (subclass(Window))c;
9585 subclass(Window) base = (subclass(Window))c.base;
9587 sprintf(className, "%sSkin_%s", name, c.name);
9588 wc.pureVTbl = c._vTbl;
9589 c._vTbl = new void *[c.vTblSize];
9590 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9591 sc = eSystem_FindClass(c.module.application, className);
9595 for(m = 0; m < c.base.vTblSize; m++)
9597 if(c._vTbl[m] == base.pureVTbl[m])
9598 c._vTbl[m] = vTbl[m];
9603 for(m = 0; m < c.vTblSize; m++)
9605 if(sc._vTbl[m] != wc.pureVTbl[m])
9606 c._vTbl[m] = sc._vTbl[m];
9610 for(d = c.derivatives.first; d; d = d.next)
9612 ApplySkin(d.data, name, c._vTbl);
9616 public void UnapplySkin(Class c)
9618 char className[1024];
9620 subclass(Window) wc = (subclass(Window))c;
9621 subclass(Window) base = (subclass(Window))c.base;
9624 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9627 c._vTbl = wc.pureVTbl;
9631 for(d = c.derivatives.first; d; d = d.next)
9633 UnapplySkin(d.data);
9637 void CheckFontIntegrity(Window window)
9642 if(window.usedFont && window.usedFont.font == 0xecececec)
9644 FontResource uf = window.usedFont;
9645 char * className = window._class.name;
9646 char * text = window.text;
9649 for(c = window.firstChild; c; c = c.next)
9650 CheckFontIntegrity(c);
9654 public class ControllableWindow : Window
9656 /*WindowController controller;
9657 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9658 ~ControllableWindow() { delete controller; }*/
9661 class WindowControllerInterface : ControllableWindow
9663 bool OnKeyDown(Key key, unichar ch)
9665 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9667 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9671 bool OnKeyUp(Key key, unichar ch)
9673 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9675 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9679 bool OnKeyHit(Key key, unichar ch)
9681 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9683 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9687 bool OnMouseMove(int x, int y, Modifiers mods)
9689 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9691 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9695 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9697 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9699 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9703 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9705 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9707 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9711 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9713 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9715 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9719 bool OnRightButtonDown(int x, int y, Modifiers mods)
9721 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9723 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9727 bool OnRightButtonUp(int x, int y, Modifiers mods)
9729 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9731 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9735 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9737 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9739 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9743 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9745 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9747 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9751 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9753 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9755 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9759 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9761 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9763 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9767 void OnResize(int width, int height)
9769 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9770 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9773 void OnRedraw(Surface surface)
9775 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9776 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9781 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9783 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9787 bool OnLoadGraphics()
9789 bool result = ((int(*)())(void *)controller.OnLoadGraphics)((void *)controller.controlled, (void *)controller);
9791 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics](controller.window);
9795 void OnUnloadGraphics()
9797 ((int(*)())(void *)controller.OnUnloadGraphics)((void *)controller.controlled, (void *)controller);
9798 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics](controller.window);
9802 public class WindowController<class V>
9805 property Window window
9809 uint size = class(Window).vTblSize;
9812 windowVTbl = new void *[size];
9813 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9814 if(value._vTbl == value._class._vTbl)
9816 value._vTbl = new void *[value._class.vTblSize];
9817 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9821 for(c = 0; c < size; c++)
9823 void * function = class(WindowControllerInterface)._vTbl[c];
9824 if(function != DefaultFunction)
9825 value._vTbl[c] = function;
9827 value._vTbl[c] = windowVTbl[c];
9832 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9835 get { return window; }
9837 property V controlled
9839 set { controlled = value; }
9840 get { return controlled; }
9842 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9843 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9844 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9845 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9846 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9847 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9848 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9849 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9850 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9851 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9852 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9853 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9854 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9855 virtual void V::OnResize(WindowController controller, int width, int height);
9856 virtual void V::OnRedraw(WindowController controller, Surface surface);
9857 virtual bool V::OnCreate(WindowController controller);
9858 virtual bool V::OnLoadGraphics(WindowController controller);
9859 virtual void V::OnUnloadGraphics(WindowController controller);
9862 int (** windowVTbl)();