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 bool switchMode = true;
502 #if defined(__ANDROID__)
506 guiApp.Initialize(switchMode);
508 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
510 if(_vTbl == ((subclass(Window))_class).pureVTbl)
512 _vTbl = _class._vTbl;
514 else if(_vTbl != _class._vTbl)
517 for(m = 0; m < _class.vTblSize; m++)
519 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
520 _vTbl[m] = _class._vTbl[m];
525 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
526 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
527 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
528 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
532 // caption = CopyString(class.name);
534 children.offset = (byte*)&prev - (byte*)this;
535 childrenOrder.circ = true;
536 childrenCycle.circ = true;
538 maxSize = Size { MAXINT, MAXINT };
542 //style.isActiveClient = true;
545 modifyVirtArea = true;
546 manageDisplay = true;
547 nativeDecorations = true;
549 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
550 sbStep.x = sbStep.y = 8;
552 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
554 cursor = guiApp.GetCursor(arrow);
555 property::parent = guiApp.desktop;
567 stopwatching(parent, font);
568 if(parent.activeChild == this)
569 parent.activeChild = null;
570 if(parent.activeClient == this)
571 parent.activeClient = null;
576 // Prevent destructor from being called again...
582 /////////////////////////////////
585 OldLink slave = master.slaves.FindLink(this);
586 master.slaves.Delete(slave);
593 parent.childrenCycle.Remove(cycle);
595 parent.childrenOrder.Remove(order);
596 parent.children.Remove(this);
601 /////////////////////////////////
603 while(ptr = resources.first)
606 resources.Delete(ptr);
613 for(child = children.first; child; child = child.next)
615 // child.stopwatching(this, font);
617 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
618 // Don't want property here
619 *&child.parent = null;
622 while(slave = slaves.first)
624 // Don't want property here
625 *&((Window)slave.data).master = null;
626 slaves.Delete(slave);
629 // Because we do a decref in DestroyEx...
637 // Why was this commented?
638 //if(this != guiApp.desktop)
651 if(((subclass(Window))_class).pureVTbl)
653 if(_vTbl == _class._vTbl)
655 _vTbl = ((subclass(Window))_class).pureVTbl;
660 for(m = 0; m < _class.vTblSize; m++)
662 if(_vTbl[m] == _class._vTbl[m])
663 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
667 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
670 dirtyArea.Free(null);
671 renderArea.Free(null);
672 overRenderArea.Free(null);
673 clipExtent.Free(null);
674 scrollExtent.Free(null);
675 dirtyBack.Free(null);
679 tempExtents[0].Free(null);
680 tempExtents[1].Free(null);
681 tempExtents[2].Free(null);
682 tempExtents[3].Free(null);
687 //#if !defined(ECERE_VANILLA)
688 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
690 if(this == activeDesigner)
694 char * name = property::name;
695 return name ? name : "";
700 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
701 bool OnGetDataFromString(char * string)
703 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
706 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
707 this = designer.form;
708 else if(!strcmpi(string, "(Desktop)"))
709 this = activeDesigner;
711 return activeDesigner.FindObject(&this, string);
717 // --- Window updates system ---
719 // Setup a bitmap for Redrawing on client area of Window
720 Surface Redraw(Box box)
722 Surface surface = null;
724 Box clientArea = this.clientArea;
728 mox.left -= clientStart.x;
729 mox.top -= clientStart.y;
730 mox.right -= clientStart.x;
731 mox.bottom -= clientStart.y;
733 mox.Clip(clientArea);
734 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
736 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
738 int x = absPosition.x + clientStart.x;
739 int y = absPosition.y + clientStart.y;
740 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
742 x -= rootWindow.clientStart.x;
743 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
745 if(!guiApp.fullScreenMode || is3D)
747 x -= rootWindow.absPosition.x;
748 y -= rootWindow.absPosition.y;
752 x += rootWindow.parent.clientStart.x;
753 y += rootWindow.parent.clientStart.y;
755 mox.left += rootWindow.parent.clientStart.x;
756 mox.top += rootWindow.parent.clientStart.y;
757 mox.right += rootWindow.parent.clientStart.x;
758 mox.bottom += rootWindow.parent.clientStart.y;
763 surface = display.GetSurface(x, y, mox);
766 surface.width = clientSize.w;
767 surface.height = clientSize.h;
773 // Setup a bitmap for Redrawing on full Window
774 Surface RedrawFull(Box box)
776 Surface surface = null;
784 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
786 int x = absPosition.x;
787 int y = absPosition.y;
788 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
790 x -= rootWindow.clientStart.x;
791 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
793 if(!guiApp.fullScreenMode || is3D)
795 x -= rootWindow.absPosition.x;
796 y -= rootWindow.absPosition.y;
799 x += rootWindow.parent.clientStart.x;
800 y += rootWindow.parent.clientStart.y;
802 mox.left += rootWindow.parent.clientStart.x;
803 mox.top += rootWindow.parent.clientStart.y;
804 mox.right += rootWindow.parent.clientStart.x;
805 mox.bottom += rootWindow.parent.clientStart.y;
810 surface = display.GetSurface(x, y, mox);
813 surface.width = size.w;
814 surface.height = size.h;
820 void FigureCaption(char * caption)
822 Window activeClient = null;
826 strcpy(caption, this.caption);
827 if(style.isDocument || fileName)
829 if(caption[0]) strcat(caption, " - ");
831 strcat(caption, fileName);
835 sprintf(title, "Untitled %d", documentID);
836 strcat(caption, title);
839 strcat(caption, " *");
844 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
846 if(activeClient && activeClient.state == maximized)
848 if(activeClient.caption)
850 if(caption[0]) strcat(caption, " - ");
851 strcat(caption, activeClient.caption);
853 if(activeClient.style.isDocument || activeClient.fileName)
855 if(caption[0]) strcat(caption, " - ");
856 strcat(caption, "[");
857 if(activeClient.fileName)
858 strcat(caption, activeClient.fileName);
862 sprintf(title, "Untitled %d", activeClient.documentID);
863 strcat(caption, title);
865 if(activeClient.modifiedDocument)
866 strcat(caption, " *");
867 strcat(caption, "]");
872 // Code for returning dirty from ScrollDisplay:
874 for(d = 0; d<scrollExtent.count; d++)
876 Box * box = &scrollExtent.boxes[d];
882 Min(box.right, box.left-scroll.x),box.bottom
884 dirtyArea.UnionBox(update);
890 Max(box.left, box.right-scroll.x), box.top,
891 box.right, box.bottom
893 dirtyArea.UnionBox(update);
901 box.right, Min(box.bottom, box.top-scroll.y),
903 dirtyArea.UnionBox(update);
909 box.left, Max(box.top, box.bottom-scroll.y),
910 box.right, box.bottom
912 dirtyArea.UnionBox(update);
917 void UpdateDecorations(void)
919 // TODO: *** TEMPORARY HACK ***
926 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
928 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
930 Update({ -clientStart.x,0, -1, clientSize.h-1 });
932 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
935 // Returns w & h for Position
936 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
938 Window parent = this.parent ? this.parent : guiApp.desktop;
939 int vpw = parent ? parent.clientSize.w : 0;
940 int vph = parent ? parent.clientSize.h : 0;
941 int pw = parent ? parent.clientSize.w : 0;
942 int ph = parent ? parent.clientSize.h : 0;
943 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
944 int x = anchor.left.distance, y = anchor.top.distance;
946 MinMaxValue ew = 0, eh = 0;
948 float cascadeW, cascadeH;
950 int tilingW, tilingH, tilingSplit, tilingLastH;
951 int addX = 0, addY = 0;
953 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
955 Window masterWindow = this;
956 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
959 if(master == guiApp.desktop)
960 masterWindow = guiApp.desktop.activeChild;
962 masterWindow = master.rootWindow;
963 if(!masterWindow) masterWindow = this;
965 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
966 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
969 pw = vpw = box.right - box.left + 1;
971 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
974 ph = vph = box.bottom - box.top + 1;
990 vpw = pw = parent.size.w;
991 vph = ph = parent.size.h;
993 else if(!style.fixed /*|| style.isDocument*/)
995 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
996 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
998 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1001 Desktop3D_FixSize(&pw, &ph);
1002 Desktop3D_FixSize(&vpw, &vph);
1005 if(pw < skinMinSize.w) pw = skinMinSize.w;
1006 if(ph < skinMinSize.h) ph = skinMinSize.h;
1007 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1008 if(vph < skinMinSize.h) vph = skinMinSize.h;
1010 // TODO: Must fix what we're snapping
1013 if(anchor.left.type)
1015 SNAPUP(x, textCellW);
1017 else if(anchor.right.type)
1019 SNAPDOWN(x, textCellW);
1024 SNAPUP(y, textCellH);
1026 else if(anchor.bottom.type)
1028 SNAPDOWN(y, textCellH);
1032 // This is required to get proper initial decoration size using native decorations on Windows
1033 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1034 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1035 GetDecorationsSize(&ew, &eh);
1037 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1039 if(parent.sbv && !parent.sbv.style.hidden)
1040 pw += guiApp.currentSkin.VerticalSBW();
1041 if(parent.sbh && !parent.sbh.style.hidden)
1042 ph += guiApp.currentSkin.HorizontalSBH();
1044 if(anchor.left.type == cascade)
1046 w = (int)(pw * 0.80);
1047 h = (int)(ph * 0.80);
1049 else if(anchor.left.type >= vTiled)
1054 numTiling = parent.numPositions - parent.numIcons;
1055 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1056 if(anchor.left.type == vTiled)
1058 tilingH = (int)sqrt(numTiling);
1059 tilingW = numTiling / tilingH;
1063 tilingW = (int)sqrt(numTiling);
1064 tilingH = numTiling / tilingW;
1067 leftOver = numTiling - tilingH * tilingW;
1070 tilingSplit = (tilingW - leftOver) * tilingH;
1071 tilingLastH = tilingH+1;
1074 tilingSplit = numTiling;
1076 if(positionID >= tilingSplit)
1078 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1079 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1080 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1081 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1085 x = pw * (positionID / tilingH) / tilingW;
1086 y = ph * (positionID % tilingH) / tilingH;
1087 x2 = pw * (positionID / tilingH + 1) / tilingW;
1088 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1092 SNAPDOWN(x, textCellW);
1093 SNAPDOWN(y, textCellH);
1094 SNAPDOWN(x2, textCellW);
1095 SNAPDOWN(y2, textCellH);
1103 if(sizeAnchor.isClientW) w += ew;
1104 if(sizeAnchor.isClientH) h += eh;
1106 if(anchor.left.type == offset)
1107 x = anchor.left.distance;
1108 else if(anchor.left.type == relative)
1109 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1110 else if(anchor.right.type == relative)
1111 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1112 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1113 else if(anchor.right.type == offset)
1114 ex = vpw - anchor.right.distance;
1116 if(anchor.top.type == offset)
1117 y = anchor.top.distance;
1118 else if(anchor.top.type == relative)
1119 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1120 else if(anchor.bottom.type == relative)
1121 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1122 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1123 else if(anchor.bottom.type == offset)
1124 ey = vph - anchor.bottom.distance;
1126 if(anchor.left.type && anchor.right.type)
1128 switch(anchor.right.type)
1131 ex = pw * (1.0f-anchor.right.percent);
1132 w = Max((int)(ex + 0.5) - x, 0);
1135 ex = vpw - anchor.right.distance;
1136 w = Max((int)(ex + 0.5) - x, 0);
1140 if(anchor.top.type && anchor.bottom.type)
1142 switch(anchor.bottom.type)
1145 ey = ph * (1.0f-anchor.bottom.percent);
1146 h = Max((int)(ey + 0.5) - y, 0);
1149 ey = vph - anchor.bottom.distance;
1150 h = Max((int)(ey + 0.5) - y, 0);
1159 if(state == normal /*|| state == Hidden*/)
1161 bool addSbV = false, addSbH = false;
1163 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1164 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1166 w = Max(w, minSize.w);
1167 h = Max(h, minSize.h);
1168 w = Min(w, maxSize.w);
1169 h = Min(h, maxSize.h);
1171 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1173 if(w) w -= guiApp.currentSkin.VerticalSBW();
1176 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1178 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1182 if(!OnResizing(&w, &h))
1188 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1189 w += guiApp.currentSkin.VerticalSBW();
1190 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1191 h += guiApp.currentSkin.HorizontalSBH();
1193 w = Max(w, skinMinSize.w);
1194 h = Max(h, skinMinSize.h);
1207 SNAPDOWN(w, textCellW);
1208 SNAPDOWN(h, textCellH);
1211 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1213 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1216 (pw - w) / CASCADE_SPACE,
1217 (ph - h) / CASCADE_SPACE);
1223 cascW = (pw - w) / (numCascade-1);
1224 cascH = (ph - h) / (numCascade-1);
1225 SNAPDOWN(cascW, textCellW);
1226 SNAPDOWN(cascH, textCellH);
1227 cascadeW = (float)cascW;
1228 cascadeH = (float)cascH;
1232 numCascade = Max(numCascade, 2);
1233 cascadeW = (float)(pw - w) / (numCascade-1);
1234 cascadeH = (float)(ph - h) / (numCascade-1);
1237 x = (int)((positionID % numCascade) * cascadeW);
1238 y = (int)((positionID % numCascade) * cascadeH);
1240 else if(anchor.left.type < vTiled)
1242 if(!anchor.left.type || anchor.horz.type == middleRelative)
1244 if(!anchor.right.type)
1246 if(anchor.horz.type == middleRelative)
1247 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1249 x = vpw / 2 + anchor.horz.distance - w / 2;
1255 // case A_EDGE: x = x - w; break;
1257 if(!anchor.top.type || anchor.vert.type == middleRelative)
1259 if(!anchor.bottom.type)
1261 if(anchor.vert.type == middleRelative)
1262 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1264 y = vph / 2 + anchor.vert.distance - h / 2;
1270 // case A_EDGE: y = y - h; break;
1273 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1281 SNAPDOWN(x, textCellW);
1282 SNAPDOWN(y, textCellH);
1294 if(anchored && style.fixed && style.isActiveClient)
1299 void UpdateCaret(bool forceUpdate, bool erase)
1301 static Window lastWindow = null;
1302 static int caretX, caretY, caretSize;
1304 if(guiApp && guiApp.caretOwner == this)
1306 int x = caretPos.x - scroll.x;
1307 int y = caretPos.y - scroll.y;
1309 if((erase || this.caretSize) &&
1310 x >= clientArea.left && x <= clientArea.right &&
1311 y >= clientArea.top && y <= clientArea.bottom)
1315 guiApp.interfaceDriver.SetCaret(
1316 x + absPosition.x + clientStart.x,
1317 y + absPosition.y + clientStart.y, this.caretSize);
1318 guiApp.caretEnabled = true;
1320 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1324 if(lastWindow != this)
1326 updateBox.left = x + 1;
1328 updateBox.right = x + 2;
1329 updateBox.bottom = y + this.caretSize - 1;
1333 updateBox.left = Min(x + 1, caretX + 1);
1334 updateBox.top = Min(y, caretY);
1335 updateBox.right = Max(x + 2, caretX + 2);
1336 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1339 guiApp.caretOwner.Update(updateBox);
1346 caretSize = this.caretSize;
1352 guiApp.interfaceDriver.SetCaret(0,0,0);
1353 guiApp.caretEnabled = false;
1359 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1364 scrolledPos.x = position.x = x;
1365 scrolledPos.y = position.y = y;
1367 clientSize.w = size.w = w;
1368 clientSize.h = size.h = h;
1370 if(parent && !style.nonClient)
1372 //if(!style.fixed || style.isDocument)
1374 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1375 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1379 clientStart.x = clientStart.y = 0;
1381 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1383 //if(!activeClient || activeClient.state != maximized)
1384 if(!noAutoScrollArea)
1386 // Check if scroll area must be modified
1387 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1389 bool foundChild = false;
1391 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1392 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1393 for(child = children.first; child; child = child.next)
1395 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1396 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1398 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1399 w = Max(w, child.position.x + child.size.w);
1400 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1401 w = Max(w, Max(child.position.x, 0) + child.size.w);
1402 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1403 h = Max(h, child.position.y + child.size.h);
1404 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1405 h = Max(h, Max(child.position.y, 0) + child.size.h);
1410 if(foundChild && (w > cw || h > ch))
1412 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1414 int stepX = sbStep.x, stepY = sbStep.y;
1415 // Needed to make snapped down position match the skin's check of client area
1416 // against realvirtual
1419 SNAPDOWN(stepX, textCellW);
1420 SNAPDOWN(stepY, textCellH);
1421 stepX = Max(stepX, textCellW);
1422 stepY = Max(stepY, textCellH);
1424 if(scrollFlags.snapX)
1426 if(scrollFlags.snapY)
1429 reqScrollArea.w = w;
1430 reqScrollArea.h = h;
1433 else if(reqScrollArea.w || reqScrollArea.h)
1435 reqScrollArea.w = 0;
1436 reqScrollArea.h = 0;
1437 SetScrollPosition(0,0);
1442 // Automatic MDI Client Scrolling Area Adjustment
1443 if(parent && !parent.noAutoScrollArea)
1445 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1446 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1448 Window parent = this.parent;
1449 int w = parent.reqScrollArea.w;
1450 int h = parent.reqScrollArea.h;
1452 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1453 w = Max(w, position.x + size.w);
1454 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1455 w = Max(w, Max(position.x, 0) + size.w);
1456 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1457 h = Max(h, position.y + size.h);
1458 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1459 h = Max(h, Max(position.y, 0) + size.h);
1461 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1462 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1464 /*bool resize = false;
1465 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1466 // Needed to make snapped down position match the skin's check of client area
1467 // against realvirtual
1470 SNAPDOWN(stepX, textCellW);
1471 SNAPDOWN(stepY, textCellH);
1472 stepX = Max(stepX, textCellW);
1473 stepY = Max(stepY, textCellH);
1475 if(parent.scrollFlags.snapX)
1477 if(parent.scrollFlags.snapY)
1479 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1481 parent.reqScrollArea.w = w;
1482 parent.reqScrollArea.h = h;*/
1484 // parent.UpdateScrollBars(true, true);
1485 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1486 false, true, true, true, false, false);
1491 GetRidOfVirtualArea();
1495 UpdateScrollBars(modifyThisArea, false);
1496 else if(guiApp.currentSkin)
1499 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1501 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1502 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1503 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1504 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1507 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1508 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1510 absPosition = scrolledPos;
1511 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1512 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1514 if(this != guiApp.desktop && parent)
1516 absPosition.x += parent.absPosition.x;
1517 absPosition.y += parent.absPosition.y;
1518 if(!style.nonClient && this != guiApp.desktop)
1520 absPosition.x += parent.clientStart.x;
1521 absPosition.y += parent.clientStart.y;
1525 box = Box { 0, 0, size.w - 1, size.h - 1 };
1530 // Clip against parent's client area
1531 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1533 // Compute client area in this window coordinate system
1534 clientArea.left = 0;
1536 clientArea.right = clientSize.w - 1;
1537 clientArea.bottom = clientSize.h - 1;
1539 // Clip against parent's client area
1541 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1545 //absPosition.x -= parent.clientStart.x;
1546 //absPosition.y -= parent.clientStart.y;
1549 // Adjust all children
1550 for(child = children.first; child; child = child.next)
1551 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1553 UpdateCaret(false, false);
1556 void GetRidOfVirtualArea(void)
1558 if(parent && !parent.destroyed && style.fixed &&
1559 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1560 parent.reqScrollArea.w && parent.reqScrollArea.h)
1562 if(!parent.noAutoScrollArea)
1566 for(child = children.first; child; child = child.next)
1568 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1570 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1571 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1580 Window parent = this.parent;
1582 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1583 false, true, true, true, false, false);
1585 parent.SetScrollArea(0,0,true);
1586 parent.SetScrollPosition(0,0);
1592 public void ExternalPosition(int x, int y, int w, int h)
1594 Position(x, y, w, h, false, true, true, true, false, false);
1597 // (w, h): Full window size
1598 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1600 bool result = false;
1601 int oldCW = clientSize.w, oldCH = clientSize.h;
1602 bool clientResized, windowResized, windowMoved;
1604 bool realResized = size.w != w || size.h != h;
1606 // TOCHECK: This wasn't in ecere.dll
1607 //if(!parent) return true;
1608 if(destroyed) return false;
1610 windowMoved = position.x != x || position.y != y || force;
1612 // windowResized = realResized || force;
1613 windowResized = size.w != w || size.h != h || force;
1615 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1621 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1622 scrolledPos.x - parent.clientStart.x + this.box.right,
1623 scrolledPos.y - parent.clientStart.y + this.box.bottom
1629 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1634 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1636 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1637 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1638 windowResized = true;
1640 if(display && rootWindow != this)
1643 if(guiApp && guiApp.windowMoving)
1645 if(guiApp.windowMoving.style.nonClient)
1646 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1648 guiApp.windowMoving.parent.SetMouseRangeToClient();
1658 // Buttons bitmap resources crash if we do this while switching mode
1659 if(!guiApp || !guiApp.modeSwitching)
1662 // Process Anchored Children
1666 for(child = children.first; child; child = child.next)
1669 ((child.stateAnchor.left.type != offset ||
1670 child.stateAnchor.top.type != offset ||
1671 child.stateAnchor.right.type != none ||
1672 child.stateAnchor.bottom.type != none) ||
1673 child.state == maximized || child.state == minimized))
1675 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1677 // child.Position(x, y, w, h, false, true, true, true, false);
1678 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1679 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1685 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1686 //if(updateScrollBars)
1688 OnResize(clientSize.w, clientSize.h);
1690 if((clientResized || windowMoved) && created)
1691 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1693 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1695 Window master = guiApp.interimWindow.master;
1696 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1699 if(rootWindow == this && !is3D)
1703 x -= guiApp.desktop.absPosition.x;
1704 y -= guiApp.desktop.absPosition.y;
1706 //guiApp.Log("Position %s\n", caption);
1709 if(windowResized || windowMoved)
1710 if(display && !display.flags.memBackBuffer && changeRootWindow)
1711 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1713 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1714 for(child = parent.children.first; child && child != this; child = child.next)
1715 if(child.rootWindow)
1716 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1721 if(windowMoved || windowResized)
1723 display.Lock(true /*false*/);
1726 display.Position(absPosition.x, absPosition.y);
1727 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1730 // result = realResized ? display.Resize(size.w, size.h) : true;
1731 if(nativeDecorations && rootWindow.windowHandle)
1733 int w = clientSize.w, h = clientSize.h;
1734 if(hasMenuBar) h += skinMenuHeight;
1735 if(hasStatusBar) h += statusBarHeight;
1736 if(sbv && sbv.visible) w += sbv.size.w;
1737 if(sbh && sbh.visible) h += sbh.size.h;
1738 result = manageDisplay ? display.Resize(w, h) : true;
1741 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1745 else if(clientResized)
1747 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1750 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1754 if(windowMoved || windowResized)
1759 if(guiApp.driver && changeRootWindow && windowHandle)
1761 if(windowResized || windowMoved)
1762 if(!display || display.flags.memBackBuffer)
1763 guiApp.interfaceDriver.PositionRootWindow(this,
1764 x, y, w, h, windowMoved, windowResized);
1765 guiApp.interfaceDriver.UpdateRootWindow(this);
1767 for(child = children.first; child; child = child.next)
1769 if(child.is3D && child.created)
1771 // Copy Display Content
1772 child.display.displaySystem = display.displaySystem;
1773 child.display.window = display.window;
1774 child.display.current = display.current;
1775 child.display.width = display.width;
1776 child.display.height = display.height;
1777 child.display.driverData = display.driverData;
1778 child.display.mutex = null;
1789 void UpdateScrollBars(bool flag, bool fullThing)
1792 bool resizeH = false, resizeV = false;
1793 bool scrolled = false;
1794 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1795 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1797 if(destroyed) return;
1798 if(guiApp.currentSkin)
1800 MinMaxValue cw = 0, ch = 0;
1801 bool sbvVisible, sbhVisible;
1803 int positionH, positionV;
1805 // First get client area with no respect to scroll bars
1810 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1812 if(scrollFlags.dontHide)
1815 cw -= guiApp.currentSkin.VerticalSBW();
1817 ch -= guiApp.currentSkin.HorizontalSBH();
1819 // Update the scrollbar visibility
1825 sbh.disabled = rangeH <= 1;
1826 if(sbh.style.hidden)
1836 sbv.disabled = rangeV <= 1;
1837 if(sbv.style.hidden)
1845 int oldHRange = sbh ? sbh.range : 0;
1846 int oldVRange = sbv ? sbv.range : 0;
1847 // Then start off with horizontal scrollbar range
1850 positionH = sbh.thumbPosition;
1857 SBSetTotal(sbh, rvw);
1860 ch -= guiApp.currentSkin.HorizontalSBH();
1863 // Do the same for vertical scrollbar
1866 positionV = sbv.thumbPosition;
1872 SBSetTotal(sbv, rvh);
1876 cw -= guiApp.currentSkin.VerticalSBW();
1877 // Maybe we need to set the range on the horizontal scrollbar again
1885 SBSetTotal(sbh, rvw);
1886 //sbh.Action(setRange, positionH, 0);
1887 if(rangeH <= 1 && sbh.range > 1)
1889 ch -= guiApp.currentSkin.HorizontalSBH();
1895 SBSetTotal(sbv, rvh);
1897 //sbv.Action(setRange, positionV, 0);
1902 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1903 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1906 // Update the scrollbar visibility
1907 if(!scrollFlags.dontHide)
1909 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1913 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1920 if(guiApp.currentSkin)
1927 sbhVisible = sbh.style.hidden ? true : false;
1929 sbvVisible = sbv.style.hidden ? true : false;
1931 // Do our resize here
1932 if(flag && (resizeH || resizeV) && fullThing)
1934 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1939 OnResize(clientSize.w, clientSize.h);
1945 sbh.visible = sbhVisible;
1947 sbv.visible = sbvVisible;
1949 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1950 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1953 sbh.pageStep = clientSize.w;
1955 sbv.pageStep = clientSize.h;
1957 // Notify doesn't handle setRange anymore... process it here
1960 int positionH = sbh.thumbPosition;
1961 if(scroll.x != positionH)
1963 OnHScroll(setRange, positionH, 0);
1967 SNAPDOWN(positionH, textCellW);
1968 scroll.x = positionH;
1974 int seen = clientSize.w, total = reqScrollArea.w;
1977 if(scrollFlags.snapX)
1978 SNAPDOWN(seen, sbStep.x);
1980 if(!total) total = seen;
1981 range = total - seen + 1;
1983 range = Max(range, 1);
1985 if(x >= range) x = range - 1;
1987 if(scrollFlags.snapX)
1988 SNAPUP(x, sbStep.x);
1992 OnHScroll(setRange, x, 0);
1997 SNAPDOWN(x, textCellW);
2003 int positionV = sbv.thumbPosition;
2004 if(scroll.y != positionV)
2006 OnVScroll(setRange, positionV, 0);
2010 SNAPDOWN(positionV, textCellH);
2011 scroll.y = positionV;
2017 int seen = clientSize.h, total = reqScrollArea.h;
2020 if(scrollFlags.snapY)
2021 SNAPDOWN(seen, sbStep.y);
2023 if(!total) total = seen;
2024 range = total - seen + 1;
2025 range = Max(range, 1);
2027 if(y >= range) y = range - 1;
2029 if(scrollFlags.snapY)
2030 SNAPUP(y, sbStep.y);
2034 OnVScroll(setRange, y, 0);
2039 SNAPDOWN(y, textCellH);
2045 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2048 for(child = children.first; child; child = child.next)
2050 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2053 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2054 child.Position(x, y, w, h, false, true, false, true, false, false);
2061 // Process Scrollbars
2063 if(sbh) // && !sbh.style.hidden
2066 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2067 // Need to set the range again (should improve...) since the scrollbars didn't have
2068 // the right size when UpdateScrollArea set the range on it
2071 sbh.seen = clientSize.w;
2075 if(sbv) // && !sbv.state.hidden
2078 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2079 // Need to set the range again (should improve...) since the scrollbars didn't have
2080 // the right size when UpdateScrollArea set the range on it
2083 sbv.seen = clientSize.h;
2088 // TESTING THIS LOWER
2089 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2092 for(child = children.first; child; child = child.next)
2094 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2097 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2098 child.Position(x, y, w, h, false, true, false, true, false, false);
2104 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2106 SetState(maximized, false, mods);
2110 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2112 SetState(normal, false, mods);
2116 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2118 SetState(minimized, false, mods);
2119 parent.CycleChildren(false, true, false, true);
2123 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2126 // Scroll bar notifications
2127 if(action != setRange)
2129 bool changed = false;
2133 if(scroll.x != position)
2135 OnHScroll(action, position, keyFlags);
2140 SNAPDOWN(position, textCellW);
2142 scroll.x = position;
2146 if(scroll.y != position)
2148 OnVScroll(action, position, keyFlags);
2153 SNAPDOWN(position, textCellH);
2155 scroll.y = position;
2159 bool childMove = false;
2160 for(child = children.first; child; child = child.next)
2162 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2165 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2166 child.Position(x, y, w, h, false, true, false, true, false, false);
2170 // Testing this patch out to solve MDI workspace redraw bugs
2171 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2172 // Scroll offsets to blame?
2176 UpdateCaret(false, false);
2180 // Testing this patch out to solve MDI workspace redraw bugs
2181 for(child = children.first; child; child = child.next)
2183 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2192 Window GetParentMenuBar()
2194 Window result = this;
2195 bool notActiveClient = false;
2196 Window menuBarParent;
2197 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2199 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2200 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2201 notActiveClient = true;
2206 void CreateSystemChildren(void)
2208 Window parent = this;
2209 bool scrollBarChanged = false;
2210 bool hasClose = false, hasMaxMin = false;
2211 Point scroll = this.scroll;
2213 if(state == maximized)
2214 parent = GetParentMenuBar();
2218 if(style.hasClose) hasClose = true;
2219 if(style.hasMaximize || style.hasMinimize)
2226 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2228 sysButtons[2].Destroy(0);
2229 sysButtons[2] = null;
2231 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2233 sysButtons[1].Destroy(0);
2234 sysButtons[1] = null;
2236 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2238 sysButtons[0].Destroy(0);
2239 sysButtons[0] = null;
2242 if(hasClose && parent)
2249 parent, master = this,
2250 inactive = true, nonClient = true, visible = false;
2252 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2258 if(this.parent == guiApp.desktop)
2259 sysButtons[2].hotKey = altF4;
2260 else if(style.isActiveClient)
2261 sysButtons[2].hotKey = ctrlF4;
2262 sysButtons[2].Create();
2265 sysButtons[2].symbol = 'X';
2266 sysButtons[2].disabled = !style.hasClose;
2269 if(hasMaxMin && parent)
2273 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2274 if(state == maximized)
2277 method = RestoreButtonClicked;
2283 method = MaximizeButtonClicked;
2291 parent, master = this,
2292 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2294 sysButtons[1].Create();
2296 sysButtons[1].NotifyClicked = method;
2298 sysButtons[1].symbol = symbol;
2299 sysButtons[1].disabled = !style.hasMaximize;
2302 if(hasMaxMin && parent)
2306 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2307 if (state == minimized)
2310 method = RestoreButtonClicked;
2316 method = MinimizeButtonClicked;
2324 parent, master = this,
2325 hotKey = altM, inactive = true, nonClient = true, visible = false
2327 sysButtons[0].Create();
2329 sysButtons[0].NotifyClicked = method;
2331 sysButtons[0].symbol = symbol;
2332 sysButtons[0].disabled = !style.hasMinimize;
2335 // Create the scrollbars
2336 if(style.hasHorzScroll && !sbh)
2342 direction = horizontal,
2346 snap = scrollFlags.snapX,
2347 NotifyScrolling = ScrollBarNotification
2350 scrollBarChanged = true;
2352 else if(sbh && !style.hasHorzScroll)
2358 if(style.hasVertScroll && !sbv)
2364 direction = vertical,
2368 snap = scrollFlags.snapY,
2369 NotifyScrolling = ScrollBarNotification
2372 scrollBarChanged = true;
2374 else if(sbv && !style.hasVertScroll)
2379 if(scrollBarChanged)
2381 SetScrollLineStep(sbStep.x, sbStep.y);
2382 UpdateScrollBars(true, true);
2386 if(scrollBarChanged)
2388 if(sbh) sbh.thumbPosition = scroll.x;
2389 if(sbv) sbv.thumbPosition = scroll.y;
2393 void UpdateCaption(void)
2395 if(rootWindow == this)
2398 FigureCaption(caption);
2399 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2401 UpdateDecorations();
2404 if(parent.activeClient == this) // Added this last check
2406 if(parent.rootWindow == parent)
2409 parent.FigureCaption(caption);
2410 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2413 parent.UpdateCaption();
2415 parent.UpdateDecorations();
2419 void UpdateActiveDocument(Window previous)
2421 Window activeClient = this.activeClient;
2422 Window activeChild = this.activeChild;
2429 activeClient.CreateSystemChildren();
2431 previous.CreateSystemChildren();
2443 // Build window list
2446 Menu windowMenu = menu.FindMenu("Window");
2451 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2454 Window document = cycle.data;
2455 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2457 char name[2048], caption[2048];
2458 document.FigureCaption(caption);
2459 sprintf(name, "%d %s", id+1, caption);
2460 windowMenu.AddDynamic(MenuItem
2462 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2463 NotifySelect = MenuWindowSelectWindow
2467 if(activeClient.cycle == cycle) break;
2472 if((!previous && activeClient) || !activeClient)
2478 item = menu.FindItem(MenuWindowCloseAll, 0);
2479 if(item) item.disabled = false;
2480 item = menu.FindItem(MenuWindowNext, 0);
2481 if(item) item.disabled = false;
2482 item = menu.FindItem(MenuWindowPrevious, 0);
2483 if(item) item.disabled = false;
2484 item = menu.FindItem(MenuWindowCascade, 0);
2485 if(item) item.disabled = false;
2486 item = menu.FindItem(MenuWindowTileHorz, 0);
2487 if(item) item.disabled = false;
2488 item = menu.FindItem(MenuWindowTileVert, 0);
2489 if(item) item.disabled = false;
2490 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2491 if(item) item.disabled = false;
2492 item = menu.FindItem(MenuWindowWindows, 0);
2493 if(item) item.disabled = false;
2496 item = menu.FindItem(MenuFileClose, 0);
2497 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2498 item = menu.FindItem(MenuFileSaveAll, 0);
2499 if(item) item.disabled = numDocuments < 1;
2501 if(activeClient && activeClient.menu && activeClient.state != minimized)
2505 //activeClient.menu.Clean(activeClient);
2506 menu.Merge(activeClient.menu, true, activeClient);
2510 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2513 menu.Merge(activeChild.menu, true, activeChild);
2516 // This is called again for a child window change, with same active client
2517 OnActivateClient(activeClient, previous);
2518 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2519 parent.UpdateActiveDocument(null);
2522 void _ShowDecorations(Box box, bool post)
2524 if(rootWindow == this && nativeDecorations) return;
2525 if(visible && this != guiApp.desktop)
2527 Surface surface = RedrawFull(box);
2531 FigureCaption(caption);
2534 ShowDecorations(captionFont.font,
2537 active, //parent.activeClient == this
2538 guiApp.windowMoving == this);
2540 PreShowDecorations(captionFont.font,
2543 active, //parent.activeClient == this
2544 guiApp.windowMoving == this);
2551 void UpdateExtent(Box refresh)
2553 Surface surface = null;
2555 if(!manageDisplay) { OnRedraw(null);return; }
2556 _ShowDecorations(refresh, false);
2558 surface = Redraw(refresh);
2559 // Opaque background: just fill before EW_REDRAW (clear?)
2562 surface.SetBackground(background);
2563 surface.SetForeground(foreground);
2564 surface.DrawingChar(' ');
2565 if(this == rootWindow)
2567 if(style.drawBehind || background.a)
2569 int a = background.a;
2570 // Premultiply alpha for clear color
2571 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2572 surface.Clear(colorBuffer);
2573 surface.SetBackground(background);
2576 else if(background.a)
2580 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2581 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2584 if(display.flags.alpha && background.a < 255 && background)
2586 surface.Area(0,0,clientSize.w, clientSize.h);
2587 /*if(style.clearDepthBuffer)
2588 surface.Clear(depthBuffer);*/
2590 else if(/*style.clearDepthBuffer || */background.a)
2592 int a = background.a;
2593 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2594 // Premultiply alpha for clear color
2595 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2596 surface.Clear(colorBuffer);
2597 surface.SetBackground(background);
2602 surface.TextFont(usedFont.font);
2603 surface.TextOpacity(false);
2607 // Draw the caret ...
2608 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2610 // surface.SetBackground(0xFFFFFF - background.color);
2611 surface.SetBackground(~background.color);
2613 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2614 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2620 void DrawOverChildren(Box refresh)
2622 Surface surface = Redraw(refresh);
2626 surface.DrawingChar(' ');
2627 surface.SetBackground(background);
2628 surface.SetForeground(foreground);
2630 surface.TextFont(usedFont.font);
2631 surface.TextOpacity(false);
2633 OnDrawOverChildren(surface);
2638 _ShowDecorations(refresh, true);
2641 void ComputeClipExtents(void)
2644 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2646 clipExtent.Copy(this.clipExtent);
2648 for(child = children.last; child; child = child.prev)
2650 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2652 bool opaque = child.IsOpaque(); // TODO: acess background directly
2653 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2655 child.clipExtent.Copy(clipExtent);
2656 child.clipExtent.Offset(-dx, -dy);
2657 child.clipExtent.IntersectBox(child.box);
2659 child.ComputeClipExtents();
2661 if(opaque && !child.style.nonClient)
2663 // Adjust the box for the parent:
2664 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2665 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2670 // ??? Only do this for overlapped window or if parent has with clip children flag
2672 // Do this if window has clip children flag on (default false?)
2673 // this.clipExtent = clipExtent;
2675 clipExtent.Free(null);
2678 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2680 bool opaque = IsOpaque();
2682 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2683 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2685 offsetX -= rootWindow.clientStart.x;
2686 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2690 for(child = children.last; child; child = child.prev)
2692 ColorAlpha background = *(ColorAlpha *)&child.background;
2693 bool opaque = child.IsOpaque();
2694 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2698 // Adjust renderArea to the root window level
2699 Extent * renderArea = &rootWindow.tempExtents[1];
2701 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2702 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2704 offsetX -= child.rootWindow.clientStart.x;
2705 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2709 Extent childRenderArea;
2711 if(backBufferUpdate != null)
2713 childRenderArea.Copy(backBufferUpdate);
2714 childRenderArea.Offset(-offsetX, -offsetY);
2717 childRenderArea.Copy(child.dirtyArea);
2719 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2720 renderArea.Copy(dirtyExtent);
2721 renderArea.Offset(-offsetX, -offsetY);
2722 childRenderArea.Union(renderArea);
2725 // Intersect with the clip extent
2726 childRenderArea.Intersection(child.clipExtent);
2729 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2730 renderArea->Offset(offsetX, offsetY);
2731 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2732 // overDirtyExtent.Union(renderArea);
2733 renderArea->Empty();
2734 // childRenderArea.Free();
2736 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2741 for(child = children.last; child; child = child.prev)
2743 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2745 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2750 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2752 bool opaque = IsOpaque();
2753 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2755 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2756 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2758 offsetX -= rootWindow.clientStart.x;
2759 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2763 for(child = children.last; child; child = child.prev)
2765 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2767 ColorAlpha background = *(ColorAlpha *)&child.background;
2768 bool opaque = child.IsOpaque();
2769 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2773 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2774 // Adjust renderArea to the root window level
2776 renderArea.Copy(child.dirtyArea);
2777 renderArea.Offset(offsetX, offsetY);
2778 dirtyExtent.Union(renderArea);
2779 overDirtyExtent.Union(renderArea);
2785 for(child = children.last; child; child = child.prev)
2787 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2789 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2793 if(backBufferUpdate != null)
2795 renderArea.Copy(backBufferUpdate);
2796 renderArea.Offset(-offsetX, -offsetY);
2798 overRenderArea.Copy(backBufferUpdate);
2799 overRenderArea.Offset(-offsetX, -offsetY);
2805 renderArea.Copy(dirtyArea);
2807 overRenderArea.Copy(dirtyArea);
2810 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2811 dirtyExtentWindow->Copy(dirtyExtent);
2812 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2813 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2814 dirtyExtentWindow->Empty();
2816 // Intersect with the clip extent
2817 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2820 if(renderArea.count > 10)
2823 printf("\nToo many extents (%d):\n", renderArea.count);
2825 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2826 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2831 for(c = 0; c<10; c++)
2834 FASTLIST_LOOP(renderArea, extentBox)
2836 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2838 renderArea.Copy(extent);
2840 FASTLIST_LOOP(renderArea, extentBox)
2843 printf("(%d, %d) - (%d, %d)\n",
2844 extentBox.box.left, extentBox.box.top,
2845 extentBox.box.right, extentBox.box.bottom);
2849 printf("\nNow %d\n", renderArea.count);
2855 // WHY WAS THIS COMMENTED ??
2857 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2858 dirtyExtentWindow->Copy(overDirtyExtent);
2859 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2860 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2861 dirtyExtentWindow->Empty();
2863 // Intersect with the clip extent
2864 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2870 if(scrollExtent.count)
2872 // Subtract render extent from scrolling extent
2873 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2875 if(backBufferUpdate == null)
2877 Extent * dirty = &rootWindow.tempExtents[3];
2880 // Intersect scrolling extent with clip extent
2881 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2883 // offset this scroll to be at the root window level
2884 scrollExtent.Offset(offsetX, offsetY);
2885 // Add area that was scrolled to the dirty extents of the back buffer
2886 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2890 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2891 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2892 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2897 scrollExtent.Empty();
2899 // Add the exposed extent to the window render area
2900 dirty->Offset(-offsetX, -offsetY);
2901 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2906 // Subtract the window's box from the transparency forced extent
2907 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2913 renderArea.Copy(this.renderArea);
2914 renderArea.Offset(offsetX, offsetY);
2915 dirtyExtent.Union(renderArea);
2921 Extent renderArea { };
2923 renderArea.Copy(overRenderArea);
2924 renderArea.Offset(offsetX, offsetY);
2925 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2930 if(backBufferUpdate != null)
2932 // Remove render area from dirty area
2933 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2935 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2942 // Remove the window render area from the dirty extents of the back buffer
2943 rootWindow.dirtyBack.Exclusion(renderArea);
2947 void Render(Extent updateExtent)
2951 Window rootWindow = this.rootWindow;
2952 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2953 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2955 offsetX -= rootWindow.clientStart.x;
2956 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2959 if(rootWindow.fullRender)
2968 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2969 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2974 /*if(renderArea.count)
2975 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2978 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2980 Box box = extentBox.box;
2983 /*printf("(%d, %d) - (%d, %d)\n",
2984 extentBox.box.left, extentBox.box.top,
2985 extentBox.box.right, extentBox.box.bottom);*/
2990 box.left += offsetX;
2992 box.right += offsetX;
2993 box.bottom += offsetY;
2995 if(updateExtent != null)
2996 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3000 for(child = children.first; child; child = child.next)
3001 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3002 child.Render(updateExtent);
3004 if(rootWindow.fullRender)
3005 DrawOverChildren(box);
3008 // TO DO: There's an issue about draw over children...
3009 // TO DO: Don't wanna go through this if method isn't used
3010 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3011 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3013 Box box = extentBox.box;
3015 DrawOverChildren(box);
3017 box.left += offsetX;
3019 box.right += offsetX;
3020 box.bottom += offsetY;
3022 if(updateExtent != null)
3023 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3026 for(child = children.first; child; child = child.next)
3027 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3028 child.Render(updateExtent);
3031 overRenderArea.Empty();
3034 public void UpdateDisplay(void)
3036 if(!manageDisplay) { OnRedraw(null);return; }
3037 if(rootWindow && this != rootWindow)
3038 rootWindow.UpdateDisplay();
3041 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3042 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3045 dirtyExtent.Clear();
3048 clipExtent.AddBox(box);
3050 display.StartUpdate();
3052 if(!rootWindow.fullRender)
3054 ComputeClipExtents();
3055 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3056 ComputeRenderArea(dirtyExtent, overExtent, null);
3059 clipExtent.Free(null);
3061 dirtyExtent.Free(null);
3062 overExtent.Free(null);
3064 if(display.flags.flipping)
3067 display.Update(null);
3071 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3072 updateExtent.Clear();
3074 Render(updateExtent);
3076 updateExtent.UnionBox(this.box, tempExtents[0]);
3079 //printf("\n\nUpdate:\n------------------------------------------\n");
3082 //FASTLIST_LOOP(updateExtent, extentBox)
3083 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3086 /*printf("Updating (%d, %d) - (%d, %d)\n",
3087 extentBox.box.left, extentBox.box.top,
3088 extentBox.box.right, extentBox.box.bottom);*/
3091 display.Update(extentBox.box);
3094 updateExtent.Free(null);
3097 display.EndUpdate();
3105 void UpdateBackDisplay(Box box)
3111 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3113 //printf("UpdateBackDisplay going through!\n");
3114 display.StartUpdate();
3118 intersection.Copy(dirtyBack);
3119 intersection.IntersectBox(box);
3121 dirtyExtent.Clear();
3124 clipExtent.AddBox(box);
3126 if(!rootWindow.fullRender)
3128 ComputeClipExtents();
3129 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3132 clipExtent.Free(null);
3134 intersection.Free(null);
3135 dirtyExtent.Free(null);
3136 overExtent.Free(null);
3141 if(display.flags.flipping)
3142 display.Update(null);
3145 rootWindow.display.Update(box);
3148 display.EndUpdate();
3152 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3153 if(dirtyBack.count > MAX_DIRTY_BACK)
3155 BoxItem extentBox, next;
3156 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3157 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3159 next = (BoxItem)extentBox.next;
3160 if(extentBox != first)
3162 if(extentBox.box.left < first.box.left)
3163 first.box.left = extentBox.box.left;
3164 if(extentBox.box.top < first.box.top)
3165 first.box.top = extentBox.box.top;
3166 if(extentBox.box.right > first.box.right)
3167 first.box.right = extentBox.box.right;
3168 if(extentBox.box.bottom > first.box.bottom)
3169 first.box.bottom = extentBox.box.bottom;
3170 dirtyBack.Delete(extentBox);
3179 // --- Window positioning ---
3180 // --- Window identification ---
3182 // Returns window at position "Position"
3183 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3185 Window child, result = null;
3187 box.left += absPosition.x;
3188 box.right += absPosition.x;
3189 box.top += absPosition.y;
3190 box.bottom += absPosition.y;
3192 if(!destroyed && visible && (acceptDisabled || !disabled))
3194 int lx = x - absPosition.x;
3195 int ly = y - absPosition.y;
3196 if(IsInside(lx, ly))
3197 // if(box.IsPointInside(Point{x, y}))
3199 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3200 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3203 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3205 if(child != statusBar && child.rootWindow == rootWindow)
3207 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3214 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3216 if(child != statusBar && child.rootWindow == rootWindow)
3218 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3230 Window FindModal(void)
3232 Window modalWindow = this, check;
3233 Window check2 = null;
3234 for(check = this; check.master; check = check.master)
3236 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3238 modalWindow = check.master.modalSlave;
3239 check = modalWindow;
3241 // TESTING THIS FOR DROPBOX...
3242 if(!rootWindow || !rootWindow.style.interim)
3244 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3246 if(check2.modalSlave && check2.modalSlave.created)
3248 modalWindow = check2.modalSlave;
3256 if(modalWindow == this)
3258 for(check = this; check.activeChild; check = check.activeChild)
3260 if(check.modalSlave)
3262 modalWindow = check.modalSlave;
3268 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3269 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3272 void StopMoving(void)
3274 if(this == guiApp.windowMoving)
3276 guiApp.windowMoving = null;
3277 UpdateDecorations();
3278 SetMouseRange(null);
3281 if(rootWindow.active)
3282 guiApp.interfaceDriver.StopMoving(rootWindow);
3285 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3286 guiApp.windowIsResizing = false;
3290 void SelectMouseCursor(void)
3295 Window cursorWindow = null;
3296 bool rx, ry, rex, rey;
3298 guiApp.desktop.GetMousePosition(&x, &y);
3299 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3301 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3302 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3303 else if(mouseWindow)
3305 modalWindow = mouseWindow.FindModal();
3306 x -= mouseWindow.absPosition.x;
3307 y -= mouseWindow.absPosition.y;
3308 if(guiApp.windowIsResizing)
3310 rex = guiApp.resizeEndX;
3311 rey = guiApp.resizeEndY;
3312 rx = guiApp.resizeX;
3313 ry = guiApp.resizeY;
3314 if((rex && rey) || (rx && ry))
3315 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3316 else if((rex && ry) || (rx && rey))
3317 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3318 else if((ry || rey) && (!rx && !rex))
3319 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3320 else if((rx || rex) && (!ry && !rey))
3321 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3323 else if(!modalWindow && !guiApp.windowCaptured &&
3324 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3325 &rx, &ry, &rex, &rey))
3327 if((rex && rey) || (rx && ry))
3328 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3329 else if((rex && ry) || (rx && rey))
3330 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3331 else if((ry || rey) && (!rx && !rex))
3332 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3333 else if((rx || rex) && (!ry && !rey))
3334 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3336 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3338 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3339 cursorWindow = mouseWindow.parent;
3341 cursorWindow = mouseWindow;
3343 else if(!guiApp.interimWindow)
3344 cursorWindow = guiApp.windowCaptured;
3347 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3348 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3350 else if(modalWindow)
3352 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3354 else if(guiApp.interimWindow)
3356 if(guiApp.interimWindow.cursor)
3357 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3359 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3364 // --- State based input ---
3365 bool AcquireInputEx(bool state)
3370 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3371 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3373 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3375 guiApp.acquiredWindow = state ? this : null;
3378 SetMouseRangeToClient();
3379 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3384 SelectMouseCursor();
3386 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3390 // --- Window activation ---
3391 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3394 if(!parent || !parent.style.inactive)
3396 Window parent = this.parent;
3399 if(rootWindow == this)
3400 Log(active ? "active\n" : "inactive\n");
3403 // Testing this here...
3404 if(!parent || parent == guiApp.desktop || parent.active)
3406 this.active = active;
3409 // TESTING THIS HERE
3410 UpdateDecorations();
3411 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3412 result = NotifyActivate(master, this, active, previous);
3415 this.active = !active;
3420 if(!parent || parent == guiApp.desktop || parent.active)
3422 this.active = active;
3424 AcquireInputEx(active);
3429 if(guiApp.caretOwner)
3433 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3434 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3435 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3436 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3438 guiApp.caretOwner.Update(extent);
3441 if(visible || !guiApp.caretOwner)
3442 guiApp.caretOwner = this;
3443 UpdateCaret(false, false);
3449 this.active = false;
3451 AcquireInputEx(active);
3453 if(!active && guiApp.caretOwner == this)
3455 UpdateCaret(false, true);
3456 guiApp.caretOwner = null;
3457 guiApp.interfaceDriver.SetCaret(0,0,0);
3458 guiApp.caretEnabled = false;
3463 if(!active && parent && parent.activeChild && parent.activeChild != this)
3464 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3470 if(!active && menuBar)
3473 menuBar.OnActivate(false, null, &goOn, true);
3474 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3479 Window aChild = activeChild;
3481 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3493 void ConsequentialMouseMove(bool kbMoving)
3497 if(kbMoving || !guiApp.windowMoving)
3501 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3503 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3505 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3506 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3512 bool IsDescendantOf(Window ancestor)
3515 for(window = this; window && window != ancestor; window = window.parent);
3516 return window == ancestor;
3519 bool IsSlaveOf(Window master)
3522 for(window = this; window && window != master; window = window.master);
3523 return window == master;
3526 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3530 if(this && !destroyed /*&& state != Hidden*/)
3532 Window swap = externalSwap;
3540 if(activateParent &&
3541 (parent.activeChild != this ||
3542 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3543 active && _isModal &&
3544 parent != master && master)
3545 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3551 bool real = parent.activeChild != this;
3553 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3554 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3555 !IsDescendantOf(guiApp.interimWindow) &&
3556 !IsSlaveOf(guiApp.interimWindow))
3558 Window interimWindow = guiApp.interimWindow;
3559 while(interimWindow && interimWindow != this)
3561 Window master = interimWindow.master;
3563 guiApp.interimWindow = null;
3564 if(guiApp.caretOwner)
3565 guiApp.caretOwner.UpdateCaret(false, false);
3567 incref interimWindow;
3568 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3573 delete interimWindow;
3574 interimWindow = (master && master.style.interim) ? master : null;
3579 guiApp.interimWindow = this;
3580 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3581 guiApp.caretEnabled = false;*/
3582 UpdateCaret(false, true);
3587 bool acquireInput = false;
3589 parent.activeChild &&
3590 parent.activeChild.state == maximized &&
3591 parent != guiApp.desktop;
3593 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3598 swap = parent.activeChild;
3599 if(swap && swap.destroyed) swap = null;
3600 if(swap && swap != this)
3603 if(!swap.PropagateActive(false, this, &goOn, true))
3604 swap = parent.activeChild;
3615 if(!parent || parent.activeChild != this || style.interim)
3618 result = PropagateActive(true, swap, &goOn, true);
3619 if(!result && !goOn)
3624 acquireInput = true;
3628 if(style.hasMaximize && parent != guiApp.desktop)
3631 SetState(maximized, false, 0);
3632 else if(state != maximized)
3635 for(child = parent.children.first; child; child = child.next)
3637 if(this != child && child.state == maximized)
3638 child.SetState(normal, false, 0);
3645 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3647 Window previous = parent.activeClient;
3648 parent.activeChild = this;
3649 if(!style.nonClient /*&& style.isActiveClient*/)
3653 if(style.isActiveClient)
3654 parent.activeClient = this;
3655 // Moved UpdateActiveDocument inside hidden check
3656 // To prevent activating previous window while creating a new one
3657 // (It was messing up the privateModule in the CodeEditor)
3658 parent.UpdateActiveDocument(previous);
3664 //if(!style.isRemote)
3666 if(rootWindow != this)
3668 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3669 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3671 else if(!guiApp.fullScreenMode)
3673 Window modalRoot = FindModal();
3674 if(!modalRoot) modalRoot = this;
3675 if(!modalRoot.isForegroundWindow)
3677 modalRoot.isForegroundWindow = true;
3678 // To check : Why is parent null?
3679 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3681 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3683 modalRoot.isForegroundWindow = false;
3688 if(result && real && (!style.inactive || moveInactive) && parent)
3690 Window last = parent.children.last;
3692 if(!style.stayOnTop)
3693 for(; last && last.style.stayOnTop; last = last.prev);
3695 parent.children.Move(this, last);
3697 // Definitely don't want that: why not?
3701 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3707 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3714 parent.activeChild = null;
3715 if(!style.nonClient /*&& style.isActiveClient*/)
3717 Window previous = parent.activeClient;
3718 if(style.isActiveClient)
3719 parent.activeClient = null;
3720 parent.UpdateActiveDocument(previous);
3724 if(this == guiApp.interimWindow)
3726 guiApp.interimWindow = null;
3727 if(guiApp.caretOwner)
3728 guiApp.caretOwner.UpdateCaret(false, false);
3730 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3737 if(!active || !swap)
3738 UpdateDecorations();
3740 swap.UpdateDecorations();
3742 if(active && rootWindow != this)
3743 ConsequentialMouseMove(false);
3750 // --- Input Messages ---
3751 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3753 static bool reEntrancy = false;
3754 if(reEntrancy) return;
3758 guiApp.cursorUpdate = true;
3759 if(guiApp.windowScrolling && !consequential)
3761 guiApp.windowScrolling.SetScrollPosition(
3762 (guiApp.windowScrolling.sbh) ?
3763 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3764 (guiApp.windowScrolling.sbv) ?
3765 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3767 if(guiApp.windowMoving)
3769 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3771 Window window = guiApp.windowMoving;
3773 int w = window.size.w;
3774 int h = window.size.h;
3779 rx = mouseX - guiApp.windowMovingStart.x;
3780 ry = mouseY - guiApp.windowMovingStart.y;
3783 window.GetDecorationsSize(&ew, &eh);
3785 if(guiApp.windowIsResizing)
3787 x = window.scrolledPos.x;
3788 y = window.scrolledPos.y;
3792 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3793 rx = guiApp.windowResizingBefore.w - aw;
3794 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3795 w = guiApp.windowResizingBefore.w - rx;
3799 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3800 ry = guiApp.windowResizingBefore.h - ah;
3801 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3802 ry = Max(ry, -guiApp.windowMovingBefore.y);
3803 h = guiApp.windowResizingBefore.h - ry;
3805 if(guiApp.resizeEndX)
3807 w = guiApp.windowResizingBefore.w + rx;
3810 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3818 w = Max(w, window.minSize.w);
3819 h = Max(h, window.minSize.h);
3820 w = Min(w, window.maxSize.w);
3821 h = Min(h, window.maxSize.h);
3823 if(!window.OnResizing(&w, &h))
3825 w = window.clientSize.w;
3826 h = window.clientSize.h;
3829 w = Max(w, window.skinMinSize.w);
3830 h = Max(h, window.skinMinSize.h);
3837 SNAPDOWN(w, textCellW);
3838 SNAPDOWN(h, textCellH);
3843 aw = Max(w,window.skinMinSize.w);
3844 rx = guiApp.windowResizingBefore.w - aw;
3845 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3846 w = guiApp.windowResizingBefore.w - rx;
3850 ah = Max(h,window.skinMinSize.h);
3851 ry = guiApp.windowResizingBefore.h - ah;
3852 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3853 ry = Max(ry, -guiApp.windowMovingBefore.y);
3854 h = guiApp.windowResizingBefore.h - ry;
3859 if(!guiApp.windowIsResizing || guiApp.resizeX)
3860 x = guiApp.windowMovingBefore.x + rx;
3861 if(!guiApp.windowIsResizing || guiApp.resizeY)
3862 y = guiApp.windowMovingBefore.y + ry;
3864 if(!guiApp.windowIsResizing)
3867 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3869 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3870 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3871 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3872 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3876 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3877 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3883 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3885 if(!window.OnMoving(&x, &y, w, h))
3887 x = window.scrolledPos.x;
3888 y = window.scrolledPos.y;
3894 SNAPDOWN(x, textCellW);
3895 SNAPDOWN(y, textCellH);
3898 if(!window.style.nonClient)
3900 if(!window.style.fixed /*|| window.style.isDocument*/)
3902 if(!window.style.dontScrollHorz)
3903 x += window.parent.scroll.x;
3904 if(!window.style.dontScrollVert)
3905 y += window.parent.scroll.y;
3909 // Break the anchors for moveable/resizable windows
3910 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3911 if(window.style.fixed)
3913 if(window.state == normal)
3915 window.normalAnchor = Anchor { left = x, top = y };
3916 window.normalSizeAnchor = SizeAnchor { { w, h } };
3917 window.anchored = false;
3921 window.stateAnchor = Anchor { left = x, top = y };
3922 window.stateSizeAnchor = SizeAnchor { { w, h } };
3924 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3925 // TOCHECK: Investigate why the following only redraws the scrollbars
3926 //window.Position(x, y, w, h, false, true, true, true, false, true);
3928 guiApp.movingLast.x = mouseX;
3929 guiApp.movingLast.y = mouseY;
3935 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3938 bool wasMoving = guiApp.windowMoving ? true : false;
3939 bool wasScrolling = guiApp.windowScrolling ? true : false;
3941 while(result && w != this)
3943 Window msgWindow = GetAtPosition(x,y, false, true, w);
3944 Window trueWindow = GetAtPosition(x,y, false, false, w);
3945 bool windowDragged = false;
3950 window = (w && !w.disabled) ? w : null;
3952 if(trueWindow) incref trueWindow;
3954 if(consequential) mods->isSideEffect = true;
3956 UpdateMouseMove(x, y, consequential);
3958 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3960 if(!guiApp.windowCaptured.isEnabled)
3961 guiApp.windowCaptured.ReleaseCapture();
3963 window = guiApp.windowCaptured;
3966 if(trueWindow && activate &&
3967 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3968 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3969 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3970 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3972 if(mods->alt && !mods->ctrl && !mods->shift)
3974 Window moved = trueWindow;
3975 for(moved = trueWindow; moved; moved = moved.parent)
3976 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3981 windowDragged = true;
3983 // Cancel the ALT menu toggling...
3984 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3989 if(window && activate &&
3990 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3991 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3992 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3993 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3995 Window modalWindow = window.FindModal();
3997 /*if(mods->alt && !mods->shift && !mods->ctrl)
3999 Window moved = window;
4000 for(moved = window; moved; moved = moved.parent)
4001 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4006 windowDragged = true;
4008 // Cancel the ALT menu toggling...
4009 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4015 Window activateWindow = modalWindow ? modalWindow : window;
4016 if(activateWindow && !activateWindow.isRemote)
4018 bool doActivation = true;
4019 //bool needToDoActivation = false;
4020 Window check = activateWindow;
4022 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4024 if(!check.style.inactive)
4026 //needToDoActivation = true;
4028 doActivation = false;
4033 if(!needToDoActivation)
4034 doActivation = false;
4037 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4038 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4040 // Let the OnLeftButtonDown do the activating instead
4041 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4049 incref activateWindow;
4050 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4052 delete activateWindow;
4056 if(activateWindow._refCount == 1)
4058 delete activateWindow;
4062 delete activateWindow;
4064 mods->isActivate = true;
4068 if(!modalWindow && window && !window.destroyed)
4070 if(!guiApp.windowCaptured || windowDragged)
4072 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4074 bool moving = ((window.state != maximized &&
4075 window.IsMouseMoving(
4076 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4077 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4079 if(!moving && window.IsMouseResizing(
4080 x - window.absPosition.x,
4081 y - window.absPosition.y,
4082 window.size.w, window.size.h,
4083 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4085 guiApp.windowIsResizing = true;
4086 guiApp.windowResizingBefore.w = window.size.w;
4087 guiApp.windowResizingBefore.h = window.size.h;
4089 if(guiApp.windowIsResizing || windowDragged || moving)
4092 guiApp.windowMoving = window;
4093 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4094 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4095 guiApp.windowMovingBefore.x = window.position.x;//s;
4096 guiApp.windowMovingBefore.y = window.position.y;//s;
4097 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4098 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4101 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4103 if(window.style.fixed &&
4105 window.IsMouseMoving(
4106 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4108 window.ShowSysMenu(x, y);
4112 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4114 if(window.sbv || window.sbh)
4117 guiApp.windowScrolling = window;
4118 guiApp.windowScrollingStart.x = x;
4119 guiApp.windowScrollingStart.y = y;
4120 guiApp.windowScrollingBefore.x = window.scroll.x;
4121 guiApp.windowScrollingBefore.y = window.scroll.y;
4124 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4126 if(window.style.hasMaximize &&
4127 window.IsMouseMoving(
4128 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4131 (window.state == maximized) ? normal : maximized, false, *mods);
4139 if(guiApp.windowMoving)
4141 if(guiApp.windowMoving.parent)
4143 if(guiApp.windowMoving.style.nonClient)
4144 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4146 guiApp.windowMoving.parent.SetMouseRangeToClient();
4150 window.UpdateDecorations();
4153 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4155 // Log("\n*** LEFT BUTTON UP ***\n");
4156 if(guiApp.windowMoving)
4157 guiApp.windowMoving.StopMoving();
4159 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4161 if(guiApp.windowScrolling)
4163 Window windowScrolling = guiApp.windowScrolling;
4164 guiApp.windowScrolling = null;
4165 windowScrolling.ReleaseCapture();
4169 if(!result || (window && window.destroyed)) window = null;
4171 if(window && window.FindModal())
4174 if(trueWindow && trueWindow.FindModal())
4182 msgWindow = GetAtPosition(x,y, true, false);
4184 msgWindow.SelectMouseCursor();
4187 if(guiApp.windowCaptured || trueWindow)
4189 Window prevWindow = guiApp.prevWindow;
4190 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4192 guiApp.prevWindow.mouseInside = false;
4193 guiApp.prevWindow = null;
4195 // Eventually fix this not to include captured?
4196 if(!prevWindow.OnMouseLeave(*mods))
4199 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4201 Box box = trueWindow.box;
4202 box.left += trueWindow.absPosition.x;
4203 box.right += trueWindow.absPosition.x;
4204 box.top += trueWindow.absPosition.y;
4205 box.bottom += trueWindow.absPosition.y;
4207 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4209 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4210 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4212 overX = Max(Min(overX, 32767),-32768);
4213 overY = Max(Min(overY, 32767),-32768);
4215 trueWindow.mouseInside = true;
4216 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4220 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4221 guiApp.prevWindow = trueWindow;
4223 guiApp.prevWindow = null;
4225 SelectMouseCursor();
4227 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4229 int clientX = x - (window.absPosition.x + window.clientStart.x);
4230 int clientY = y - (window.absPosition.y + window.clientStart.y);
4232 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4234 clientX = Max(Min(clientX, 32767),-32768);
4235 clientY = Max(Min(clientY, 32767),-32768);
4237 MouseMethod = (void *)window._vTbl[method];
4239 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4242 if(!MouseMethod(window, clientX, clientY, *mods))
4249 if(result && w && w.clickThrough && w.parent)
4254 if(!result || !w || !w.clickThrough)
4261 // --- Mouse cursor management ---
4263 bool KeyMessage(uint method, Key key, unichar character)
4268 if(guiApp.interimWindow)
4269 this = guiApp.interimWindow;
4272 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4276 if(!style.inactive || rootWindow != this)
4278 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4279 Window modalWindow = FindModal();
4280 Window interimMaster = master ? master.rootWindow : null;
4284 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4285 status = OnSysKeyDown(key, character);
4286 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4287 status = OnSysKeyHit(key, character);
4288 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4289 status = OnSysKeyUp(key, character);
4296 // Process Key Message for Internal UI Keyboard actions
4297 if(status && !destroyed && menuBar && state != minimized)
4300 if((SmartKey)key != alt)
4301 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4304 SmartKey sk = (SmartKey) key;
4305 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4307 status = menuBar.KeyMessage(method, key, character);
4312 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4313 menuBar.OnKeyHit(escape, 0);
4315 if(!menuBar.focus && guiApp.caretOwner)
4316 guiApp.caretOwner.UpdateCaret(true, false);
4319 if(!destroyed && status)
4321 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4325 case left: case up: case right: case down:
4326 if(guiApp.windowMoving == this)
4329 int w = guiApp.windowMoving.size.w;
4330 int h = guiApp.windowMoving.size.h;
4331 int x = guiApp.windowMoving.scrolledPos.x;
4332 int y = guiApp.windowMoving.scrolledPos.y;
4336 if(key == down || key == up)
4337 step = Max(step, textCellH);
4339 step = Max(step, textCellW);
4342 if(guiApp.windowIsResizing)
4346 case left: w-=step; break;
4347 case right: w+=step; break;
4348 case up: h-=step; break;
4349 case down: h+=step; break;
4356 case left: x-=step; break;
4357 case right: x+=step; break;
4358 case up: y-=step; break;
4359 case down: y+=step; break;
4363 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4364 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4366 if(!guiApp.windowIsResizing || guiApp.resizeX)
4367 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4369 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4371 if(!guiApp.windowIsResizing || guiApp.resizeY)
4372 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4374 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4376 guiApp.interfaceDriver.SetMousePosition(x, y);
4377 ConsequentialMouseMove(true);
4385 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4387 guiApp.windowMoving.StopMoving();
4388 ConsequentialMouseMove(false);
4396 ShowSysMenu(absPosition.x, absPosition.y);
4404 if(!destroyed && status && state != minimized)
4406 // Process all the way down the children
4407 if(activeChild && !activeChild.disabled)
4409 status = activeChild.KeyMessage(method, key, character);
4411 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4412 key.code != left && key.code != right && key.code != up && key.code != down)
4414 status = activeClient.KeyMessage(method, key, character);
4418 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4420 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4421 // && defaultControl != activeChild)
4423 delete previousActive;
4424 previousActive = activeChild;
4425 if(previousActive) incref previousActive;
4427 ConsequentialMouseMove(false);
4428 if((defaultControl.active ||
4429 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4430 defaultControl.KeyMessage(method, defaultKey, character);
4436 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4438 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4445 ShowSysMenu(absPosition.x, absPosition.y);
4452 if(this != guiApp.desktop)
4454 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4456 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4458 MenuMoveOrSize(key.shift, true);
4462 else if(guiApp.windowMoving)
4464 guiApp.windowMoving.StopMoving();
4465 ConsequentialMouseMove(false);
4473 if(!destroyed && status && state != minimized)
4475 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4479 case tab: case shiftTab:
4481 Window cycleParent = this;
4482 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4483 cycleParent = master.parent;
4485 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4487 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4489 Window child = cycleParent.activeChild;
4491 // Scroll the window to include the active control
4493 if(cycleParent.sbh && !child.style.dontScrollHorz)
4495 if(child.scrolledPos.x < 0)
4496 cycleParent.sbh.Action(Position,
4497 cycleParent.scroll.x + child.scrolledPos.x, 0);
4498 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4499 cycleParent.sbh.Action(Position,
4500 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4502 if(cycleParent.sbv && !child.style.dontScrollVert)
4504 if(child.scrolledPos.y < 0)
4505 cycleParent.sbv.Action(Position,
4506 cycleParent.scroll.y + child.scrolledPos.y, 0);
4507 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4508 cycleParent.sbv.Action(Position,
4509 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4512 cycleParent.ConsequentialMouseMove(false);
4518 case f6: case shiftF6:
4519 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4521 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4522 if(parent == guiApp.desktop)
4523 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4533 if(CycleChildren(key.shift, true, false, true))
4541 // mIRC Style Window Shortcuts
4542 case alt1: case alt2: case alt3: case alt4: case alt5:
4543 case alt6: case alt7: case alt8: case alt9: case alt0:
4548 for(document = children.first; document; document = document.next)
4550 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4552 if(document == activeChild)
4554 if(document.state == minimized)
4555 document.SetState(normal, false, key);
4558 document.SetState(minimized, false, key);
4559 CycleChildren(false, true, false);
4564 if(activeChild.state == maximized && document.style.hasMaximize)
4565 document.SetState(maximized, false, key);
4566 else if(document.state == minimized)
4567 document.SetState(normal, false, key);
4568 document.Activate();
4583 if(!destroyed && status)
4585 if(state == minimized)
4590 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4592 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4594 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4595 previousActive.ActivateEx(true, false, false, true, null, null);
4596 delete previousActive;
4602 if(!destroyed && status)
4604 status = ProcessHotKeys(method, key, character);
4606 if(!destroyed && status && !modalWindow && state != minimized)
4609 status = KeyMethod(this, key, character);
4610 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4611 status = OnKeyHit(key, character);
4612 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4614 bool result = false;
4617 case ctrlUp: case ctrlDown:
4618 if(sbv && !guiApp.windowScrolling)
4619 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4621 case wheelUp: case wheelDown:
4622 if(sbv && !guiApp.windowScrolling)
4624 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4625 // Do we want to do a consequential move regardless of result in this case?
4626 ConsequentialMouseMove(false);
4629 case ctrlPageUp: case ctrlPageDown:
4630 if(sbh && !guiApp.windowScrolling)
4631 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4636 ConsequentialMouseMove(false);
4641 if(status && !destroyed && menuBar && state != minimized)
4642 status = menuBar.KeyMessage(method, key, character);
4644 if(style.interim && /*destroyed && */status && interimMaster)
4646 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4647 status = interimMaster.KeyMessage(method, key, character);
4654 bool ProcessHotKeys(uint method, Key key, unichar character)
4659 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4660 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4661 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4663 Window hotKeyWindow = hotKey.window;
4664 Window parent = hotKeyWindow.parent;
4665 Window prevActiveWindow = activeChild;
4666 // For when sys buttons are placed inside the menu bar
4667 if(parent && parent._class == class(PopupMenu))
4668 parent = parent.parent;
4670 // 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
4671 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4674 if(prevActiveWindow) incref prevActiveWindow;
4675 incref hotKeyWindow;
4676 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4677 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4680 delete hotKeyWindow;
4681 delete prevActiveWindow;
4685 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4686 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4687 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4689 // ********* WORKING ON THIS ***********
4690 if(prevActiveWindow && !guiApp.interimWindow)
4691 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4694 else if(hotKeyWindow.style.inactive)
4695 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4697 delete prevActiveWindow;
4698 delete hotKeyWindow;
4699 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4700 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4704 if(status && tabCycle)
4707 for(child = children.first; child; child = child.next)
4709 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4720 // --- Windows and graphics initialization / termination ---
4721 bool SetupRoot(void)
4725 // Setup relationship with outside world (bb root || !bb)
4726 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4727 (_displayDriver && dispDriver != parent.dispDriver))
4731 tempExtents = new0 Extent[4];
4736 /*if(guiApp.fullScreenMode)
4737 rootWindow = guiApp.desktop;
4739 //rootWindow = parent.created ? parent.rootWindow : null;
4740 rootWindow = parent.rootWindow;
4743 against = &parent.box;
4745 against = &parent.clientArea;
4748 for(child = children.first; child; child = child.next)
4751 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4754 bool Setup(bool positionChildren)
4756 bool result = false;
4759 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && dispDriver != parent.dispDriver))))
4761 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4762 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4764 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4766 // This was here, is it really needed?
4767 //guiApp.interfaceDriver.ActivateRootWindow(this);
4771 displaySystem = DisplaySystem {};
4772 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4774 delete displaySystem;
4779 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4780 if(display.Create(displaySystem, windowHandle))
4787 // Sometimes icon does not show up on Windows XP if we set here...
4788 // guiApp.interfaceDriver.SetIcon(this, icon);
4790 else if(this != guiApp.desktop)
4792 display = rootWindow ? rootWindow.display : null;
4798 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4799 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4801 for(child = children.first; child; child = child.next)
4803 if(child.created && !child.Setup(false))
4809 bool SetupDisplay(void)
4811 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4812 if(is3D) return Window3D_SetupDisplay(this); else
4819 class_data void ** pureVTbl;
4821 bool LoadGraphics(bool creation, bool resetAnchors)
4823 bool result = false;
4824 bool success = false;
4826 WindowState stateBackup = state;
4828 if(((subclass(Window))_class).pureVTbl)
4830 if(_vTbl == _class._vTbl)
4832 _vTbl = ((subclass(Window))_class).pureVTbl;
4837 for(m = 0; m < _class.vTblSize; m++)
4839 if(_vTbl[m] == _class._vTbl[m])
4840 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4844 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4846 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4848 _vTbl = _class._vTbl;
4853 for(m = 0; m < _class.vTblSize; m++)
4855 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4856 _vTbl[m] = _class._vTbl[m];
4861 if(guiApp.fullScreenMode || this != guiApp.desktop)
4863 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4869 display.Lock(false);
4870 if(rootWindow == this)
4872 // Set Color Palette
4873 display.SetPalette(palette, true);
4877 if(guiApp.fullScreenMode && this == guiApp.desktop)
4882 for(c=0; c<SystemCursor::enumSize; c++)
4883 if(!guiApp.systemCursors[c].bitmap)
4885 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4886 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4887 if(guiApp.systemCursors[c].bitmapName)
4889 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4890 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4891 if(guiApp.systemCursors[c].bitmap)
4892 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4897 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4899 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4900 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4902 cursor.bitmap.paletteShades = cursor.paletteShades;
4906 guiApp.cursorUpdate = true;
4909 ConsequentialMouseMove(false);
4915 // Load Window Graphic Resources
4918 if(usedFont == setFont || usedFont == window.systemFont)
4919 RemoveResource(usedFont);
4922 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4925 RemoveResource(systemFont);
4928 RemoveResource(captionFont);
4930 for(ptr = resources.first; ptr; ptr = ptr.next)
4932 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4935 AddResource(setFont);
4937 AddResource(systemFont);
4939 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4946 //if(master && master.font)
4947 if(parent && parent.font)
4951 faceName = parent.font.faceName,
4952 size = parent.font.size,
4953 bold = parent.font.bold,
4954 italic = parent.font.italic,
4955 underline = parent.font.underline
4957 //font = parent.font;
4958 watch(parent) { font { } };
4961 font = guiApp.currentSkin.SystemFont();
4968 captionFont = guiApp.currentSkin.CaptionFont();
4969 AddResource(captionFont);
4971 if(OnLoadGraphics())
4977 //SetScrollLineStep(sbStep.x, sbStep.y);
4979 if(this != guiApp.desktop)
4983 normalAnchor = anchor;
4984 normalSizeAnchor = sizeAnchor;
4987 // Break the anchors for moveable/resizable windows
4989 if(style.fixed && style.isDocument)
4991 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5003 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5004 stateSizeAnchor = SizeAnchor {};
5009 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5014 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5015 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5018 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5022 stateAnchor = normalAnchor;
5023 stateSizeAnchor = normalSizeAnchor;
5026 position = Point { };
5027 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5038 if(Position(x, y, w, h, true, false, true, true, true, true))
5040 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5043 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5060 success = result = true;
5063 if(!creation && result)
5065 // Load menu bar first because sys buttons are on it...
5068 if(!menuBar.LoadGraphics(false, resetAnchors))
5074 for(child = children.first; child; child = child.next)
5076 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5083 CreateSystemChildren();
5087 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5090 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5095 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5096 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5099 // Do this here to avoid problems on Windows
5100 if(stateBackup == maximized)
5101 property::state = maximized;
5105 void UnloadGraphics(bool destroyWindows)
5109 // Free children's graphics
5110 for(child = children.first; child; child = child.next)
5111 child.UnloadGraphics(destroyWindows);
5114 display.Lock(false);
5117 if(guiApp.fullScreenMode && this == guiApp.desktop)
5122 for(c=0; c<SystemCursor::enumSize; c++)
5123 if(guiApp.systemCursors[c].bitmap)
5124 delete guiApp.systemCursors[c].bitmap;
5126 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5127 delete cursor.bitmap;
5129 guiApp.cursorBackground.Free();
5132 if(display && display.displaySystem)
5136 for(ptr = resources.first; ptr; ptr = ptr.next)
5140 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5145 // Free window graphics
5148 // Free skin graphics
5149 if(rootWindow == this)
5151 DisplaySystem displaySystem = display.displaySystem;
5154 display.driverData = null;
5155 display.displaySystem = null;
5159 if(displaySystem && !displaySystem.numDisplays && !is3D)
5160 delete displaySystem;
5169 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5170 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5172 if(this == guiApp.desktop || parent == guiApp.desktop)
5174 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5175 guiApp.interfaceDriver.DestroyRootWindow(this);
5179 // --- Window Hiding ---
5181 void SetVisibility(bool state)
5183 bool visible = (style.hidden || !created) ? false : state;
5184 if(visible != this.visible)
5188 this.visible = visible;
5189 for(child = children.first; child; child = child.next)
5190 child.SetVisibility(visible);
5192 ConsequentialMouseMove(false);
5193 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5197 // --- Windows and graphics initialization / termination ---
5199 bool DisplayModeChanged(void)
5201 bool result = false;
5202 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5204 guiApp.modeSwitching = true;
5205 UnloadGraphics(false);
5207 if(LoadGraphics(false, false))
5209 guiApp.modeSwitching = false;
5214 // --- Window updates system ---
5216 void UpdateDirty(Box updateBox)
5218 if(!manageDisplay) { OnRedraw(null);return; }
5221 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5224 if(display.flags.flipping)
5227 rootWindow.UpdateDisplay();
5230 UpdateBackDisplay(updateBox);
5232 if(guiApp.fullScreenMode)
5234 guiApp.cursorUpdate = true;
5235 guiApp.PreserveAndDrawCursor();
5237 if(guiApp.fullScreenMode)
5238 guiApp.RestoreCursorBackground();
5244 // This function is strictly called as a result of system window activation
5245 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5248 Window interimMaster = null;
5249 Window interimWindow = guiApp.interimWindow;
5250 if(interimWindow && interimWindow.master)
5251 interimMaster = interimWindow.master.rootWindow;
5253 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5254 // SetState(normal, false, 0);
5255 SetState(lastState, false, 0);
5257 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5261 /* WTH is this doing here?
5262 while(swap && swap.activeChild)
5264 swap = swap.activeChild;
5267 // TESTING THIS BEFORE...
5268 if(interimWindow && this == interimMaster)
5272 // Window interimSwap = this;
5273 Window menuBar = this.menuBar;
5274 if(menuBar && interimWindow.master == menuBar)
5277 while(interimSwap && interimSwap.activeChild)
5278 interimSwap = interimSwap.activeChild;
5280 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5281 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5283 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5284 //result = ActivateEx(true, true, false, activateRoot, window, null);
5289 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5290 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5292 if(interimWindow == this && interimMaster && !active)
5294 while(interimMaster && interimMaster.interim && interimMaster.master)
5296 // printf("Going up one master %s\n", interimMaster._class.name);
5297 interimMaster = interimMaster.master.rootWindow;
5299 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5300 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5306 bool DestroyEx(int returnCode)
5309 Timer timer, nextTimer;
5311 OldLink prevOrder = null;
5312 Window client = null;
5314 if(parent) stopwatching(parent, font);
5316 // if(window.modalSlave) return false;
5317 if(destroyed || !created)
5324 OldLink slave = master.slaves.FindLink(this);
5325 master.slaves.Delete(slave);
5328 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5334 this.returnCode = (DialogResult)returnCode;
5336 AcquireInput(false);
5341 master.hotKeys.Delete(hotKey);
5345 if(guiApp.prevWindow == this)
5347 guiApp.prevWindow = null;
5350 if(guiApp.caretOwner == this)
5352 guiApp.interfaceDriver.SetCaret(0,0,0);
5353 UpdateCaret(false, true);
5354 guiApp.caretEnabled = false;
5359 parent.childrenCycle.Remove(cycle);
5363 OldLink tmpPrev = order.prev;
5364 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5365 prevOrder = tmpPrev;
5368 client = tmpPrev ? tmpPrev.data : null;
5369 if(client == this) { client = null; break; }
5370 if(client && (client.style.hidden || client.destroyed || !client.created))
5371 tmpPrev = client.order.prev;
5375 prevOrder = tmpPrev;
5380 // If this window can be an active client, make sure the next window we activate can also be one
5381 if(!style.nonClient && style.isActiveClient)
5383 tmpPrev = prevOrder;
5386 client = tmpPrev ? tmpPrev.data : null;
5387 if(client == this) { client = null; break; }
5388 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5389 tmpPrev = client.order.prev;
5393 prevOrder = tmpPrev;
5397 if(client && client.style.hidden) client = null;
5399 // parent.childrenOrder.Remove(order);
5402 if(parent && style.isActiveClient && visible)
5404 if(state == minimized) parent.numIcons--;
5405 parent.numPositions--;
5408 // TESTING THIS HERE!
5412 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5413 // to create a window inside a rootwindow that's being destroyed)
5414 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5416 if(master && !master.destroyed /*&&
5417 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5419 if(master.defaultControl == this)
5420 master.defaultControl = null;
5423 parent.OnChildAddedOrRemoved(this, true);
5424 if(parent && !parent.destroyed /*&&
5425 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5427 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5429 if(order && prevOrder && prevOrder.data != this && active)
5431 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5433 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5434 if(parent.activeClient == this)
5436 parent.activeClient = null;
5437 parent.UpdateActiveDocument(null);
5442 if(guiApp.interimWindow == this)
5445 PropagateActive(false, null, &goOn, true);
5449 //if(window.parent.activeChild == window)
5450 parent.activeChild = null;
5451 if(!style.nonClient /*&& style.isActiveClient*/)
5453 Window previous = parent.activeClient;
5454 if(style.isActiveClient)
5455 parent.activeClient = null;
5456 parent.UpdateActiveDocument(previous);
5461 else if(parent.activeClient == this)
5463 parent.activeClient = client;
5464 parent.UpdateActiveDocument(this);
5468 if(guiApp.interimWindow == this)
5470 guiApp.interimWindow = null;
5471 if(guiApp.caretOwner)
5473 Window desktop = guiApp.desktop;
5474 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5475 guiApp.caretOwner.UpdateCaret(false, false);
5480 if(_isModal && master && master.modalSlave == this)
5481 master.modalSlave = null;
5485 if(!guiApp.caretOwner && parent.caretSize)
5487 guiApp.caretOwner = parent;
5488 parent.UpdateCaret(false, false);
5489 parent.Update(null);
5492 // Why was this commented out?
5493 GetRidOfVirtualArea();
5499 dirtyArea.Free(null);
5500 dirtyBack.Free(null);
5501 scrollExtent.Free(null);
5503 /* ATTEMPTING TO MOVE THAT ABOVE
5512 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5513 for(;(child = window.children.first);)
5515 for(; child && (child.destroyed || !child.created); child = child.next);
5524 UnloadGraphics(true);
5527 delete previousActive;
5530 // statusBar = null;
5533 if(master && !master.destroyed)
5535 //master.NotifyDestroyed(this, this.returnCode);
5536 NotifyDestroyed(master, this, this.returnCode);
5539 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5541 nextTimer = timer.next;
5542 if(timer.window == this)
5544 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5545 // timer.window = null;
5551 if(this == guiApp.windowMoving)
5554 if(guiApp.windowCaptured == this)
5556 //guiApp.windowCaptured = null;
5558 if(rootWindow != this && rootWindow)
5559 rootWindow.ConsequentialMouseMove(false);
5567 //for(child = children.first; next = child ? child.next : null, child; child = next)
5568 for(;(child = children.first); )
5570 for(; child && (child.destroyed || !child.created); child = child.next);
5580 /* // MOVED THIS UP...
5583 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5584 for(;(child = window.children.first); )
5586 for(; child && (child.destroyed || !child.created); child = child.next);
5595 while((slave = slaves.first))
5597 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5599 ((Window)slave.data).DestroyEx(0);
5604 if(guiApp.caretOwner == this)
5605 guiApp.caretOwner = null;
5607 sysButtons[0] = null;
5608 sysButtons[1] = null;
5609 sysButtons[2] = null;
5612 if(rootWindow != this)
5614 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5617 box.left -= parent.clientStart.x;
5618 box.top -= parent.clientStart.y;
5619 box.right -= parent.clientStart.x;
5620 box.bottom -= parent.clientStart.y;
5622 if(parent) parent.Update(box);
5627 OldLink slave = master.slaves.FindVoid(this);
5628 master.slaves.Delete(slave);
5634 parent.children.Remove(this);
5639 //autoCreate = false;
5642 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5643 if(((subclass(Window))_class).pureVTbl)
5645 if(_vTbl == _class._vTbl)
5647 _vTbl = ((subclass(Window))_class).pureVTbl;
5652 for(m = 0; m < _class.vTblSize; m++)
5654 if(_vTbl[m] == _class._vTbl[m])
5655 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5664 void SetStateEx(WindowState newState, bool activate)
5667 WindowState prevState = state;
5671 if(prevState != newState)
5672 lastState = prevState;
5674 if(rootWindow != this || !nativeDecorations || !windowHandle)
5676 if(style.isActiveClient && !style.hidden && prevState == minimized)
5679 // This block used to be at the end of the function... moved it for flicker problem in X
5680 // ------------------------------------------------------
5684 stateAnchor = normalAnchor;
5685 stateSizeAnchor = normalSizeAnchor;
5688 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5689 stateSizeAnchor = SizeAnchor {};
5693 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5696 byte * idBuffer = new0 byte[size];
5698 for(child = parent.children.first; child; child = child.next)
5700 if(child != this && child.state == minimized)
5702 if(child.iconID > size - 2)
5704 idBuffer = renew0 idBuffer byte[size*2];
5705 memset(idBuffer + size, 0, size);
5708 idBuffer[child.iconID] = (byte)bool::true;
5711 for(c = 0; c<size; c++)
5716 if(style.isActiveClient && !style.hidden)
5719 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5720 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5724 // TOCHECK: Why was this here?
5725 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5726 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5727 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5729 Position(x, y, w, h, true, true, true, true, false, true);
5731 if(!style.inactive && !style.interim && this == parent.activeClient)
5732 parent.UpdateActiveDocument(null);
5735 CreateSystemChildren();
5736 // ------------------------------------------------------
5739 int GetPositionID(Window forChild)
5743 byte * idBuffer = new0 byte[size];
5746 for(child = children.first; child; child = child.next)
5748 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5750 if(child.positionID > size - 2)
5752 idBuffer = renew0 idBuffer byte[size*2];
5753 memset(idBuffer + size, 0, size);
5756 idBuffer[child.positionID] = (byte)bool::true;
5759 for(c = 0; c<size; c++)
5766 // --- Window related graphics ---
5768 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5770 palette = newPalette;
5771 if(rootWindow.display)
5772 rootWindow.display.SetPalette(palette, colorMatch);
5775 public bool AcquireInput(bool acquired)
5778 if(acquiredInput != acquired)
5780 if(active || (!visible && creationActivation == activate))
5781 result = AcquireInputEx(acquired);
5786 acquiredInput = acquired ? result : !result;
5791 void ListChildren(ListBox listBox)
5795 for(child = children.first; child; child = child.next)
5797 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5799 DataRow row = listBox.AddRow();
5800 row.tag = (int)child;
5801 child.FigureCaption(caption);
5802 row.SetData(null, caption);
5807 void UpdateVisual(Box extent)
5809 if(guiApp.driver != null)
5811 if(guiApp.fullScreenMode && guiApp.desktop.display)
5813 guiApp.desktop.mutex.Wait();
5814 guiApp.desktop.display.Lock(true);
5817 if(guiApp.desktop.active)
5819 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5821 if(guiApp.desktop.display.flags.flipping)
5822 guiApp.desktop.Update(null);
5823 guiApp.desktop.UpdateDisplay();
5824 guiApp.cursorUpdate = true;
5826 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5828 guiApp.PreserveAndDrawCursor();
5829 // guiApp.desktop.display.ShowScreen();
5830 guiApp.cursorUpdate = false;
5831 guiApp.desktop.dirty = false;
5832 guiApp.RestoreCursorBackground();
5836 guiApp.desktop.display.Unlock();
5837 guiApp.desktop.mutex.Release();
5841 Window rootWindow = this.rootWindow;
5842 rootWindow.mutex.Wait();
5847 guiApp.SignalEvent();
5850 guiApp.waitMutex.Wait();
5851 guiApp.interfaceDriver.Lock(rootWindow);
5852 if(!rootWindow.style.hidden && rootWindow.dirty)
5854 if(rootWindow.display)
5856 rootWindow.UpdateDisplay();
5857 //rootWindow.display.ShowScreen(null);
5859 rootWindow.dirty = false;
5861 guiApp.interfaceDriver.Unlock(rootWindow);
5862 guiApp.waitMutex.Release();
5865 rootWindow.mutex.Release();
5870 void UnlockDisplay(void)
5872 guiApp.interfaceDriver.Unlock(rootWindow);
5875 void LockDisplay(void)
5877 guiApp.interfaceDriver.Lock(rootWindow);
5880 Surface GetSurface(Box box)
5882 return Redraw((box == null) ? this.box : box);
5885 void SetMousePosition(int x, int y)
5887 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5891 void IntegrationActivate(bool active)
5893 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5895 isForegroundWindow = true;
5896 ActivateEx(active, active, false, false, null, null);
5897 isForegroundWindow = false;
5902 Window QueryCapture(void)
5904 return guiApp.windowCaptured;
5907 int GetDocumentID(void)
5911 byte * idBuffer = new0 byte[size];
5914 for(child = children.first; child; child = child.next)
5916 // TO CHECK: Do we want a documentID when we already have a file name?
5917 if(child.style.isDocument && !child.fileName)
5919 if(child.documentID-1 > size - 2)
5921 idBuffer = renew0 idBuffer byte[size*2];
5922 memset(idBuffer + size, 0, size);
5925 idBuffer[child.documentID-1] = 1;
5928 for(c = 0; c<size; c++)
5936 void SetInitSize(Size size)
5939 sizeAnchor.size = size;
5940 normalSizeAnchor = sizeAnchor;
5942 // Break the anchors for moveable/resizable windows
5943 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5945 stateAnchor = normalAnchor;
5946 stateSizeAnchor = normalSizeAnchor;
5948 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5949 Position(x,y, w, h, true, true, true, true, false, true);
5953 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5955 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5957 guiApp.windowIsResizing = resize;
5958 guiApp.windowMoving = this;
5959 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5960 if(guiApp.windowIsResizing)
5962 guiApp.windowMovingStart.x += size.w - 1;
5963 guiApp.windowMovingStart.y += size.h - 1;
5965 guiApp.windowMovingBefore = scrolledPos;
5966 guiApp.windowResizingBefore = size;
5967 guiApp.windowMoving.UpdateDecorations();
5968 if(guiApp.windowIsResizing)
5969 guiApp.resizeEndX = guiApp.resizeEndY = true;
5971 if(setCursorPosition)
5972 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5976 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5977 guiApp.windowMovingStart.x += x - absPosition.x;
5978 guiApp.windowMovingStart.y += y - absPosition.y;
5981 if(guiApp.windowMoving)
5983 if(guiApp.windowMoving.style.nonClient)
5984 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5986 guiApp.windowMoving.parent.SetMouseRangeToClient();
5991 if(this == rootWindow)
5992 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6000 bool result = false;
6004 else if(guiApp && guiApp.driver != null)
6006 void * systemParent = null;
6007 OldLink slaveHolder;
6009 bool visible = !style.hidden;
6013 systemParent = parent;
6014 parent = guiApp.desktop;
6016 last = parent ? parent.children.last : null;
6018 if((parent && parent != guiApp.desktop && !parent.created) ||
6019 (master && master != guiApp.desktop && !master.created))
6023 stopwatching(parent, font);
6026 property::parent = guiApp.desktop;
6027 if(!master) master = parent;
6029 if(_isModal && master.modalSlave)
6030 property::master = master.modalSlave;
6034 parent.children.Remove(this);
6037 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6038 if(slaveHolder.data == this)
6040 master.slaves.Delete(slaveHolder);
6045 if(parent == guiApp.desktop && !mutex)
6048 if(style.isDocument)
6051 parent.numDocuments--;
6052 documentID = parent.GetDocumentID();
6055 if(!style.stayOnTop)
6056 for(; last && last.style.stayOnTop; last = last.prev);
6058 parent.children.Insert((last == this) ? null : last, this);
6059 //parent.children.Add(this);
6062 dispDriver = parent.dispDriver;
6065 master.modalSlave = this;
6067 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6072 master.slaves.Add(slaveHolder = OldLink { data = this });
6077 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6079 if(style.isDefault && !master.defaultControl)
6080 master.defaultControl = this;
6082 stateAnchor = normalAnchor = anchor;
6083 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6085 // TOCHECK: Why is this here?
6086 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6087 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6089 this.visible = false;
6090 style.hidden = true;
6093 // autoCreate = true;
6101 if(parent == guiApp.desktop)
6102 Log("LoadGraphics %s\n", caption);
6104 if(LoadGraphics(true, false))
6112 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6119 if(style.hasMenuBar /*&& menu*/)
6125 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6126 interim = false, inactive = true, nonClient = true, size.h = 24
6134 // Create the system buttons
6135 CreateSystemChildren();
6137 UpdateActiveDocument(null);
6139 if(style.isDocument)
6143 MenuItem item = menu.FindItem(MenuFileSave, 0);
6144 if(item) item.disabled = !modifiedDocument && fileName;
6149 if(parent == guiApp.desktop)
6150 Log("Preemptive SetState %s\n", caption);
6153 // Preemptive Set State to ensure proper anchoring
6154 SetStateEx(state, false);
6156 style.hidden = true;
6162 for(child = children.first; child; child = next)
6165 if(!child.created && (child.autoCreate || child.wasCreated))
6172 for(link = slaves.first; link; link = next)
6174 Window slave = link.data;
6176 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6179 // Things might have happened that invalidated 'next'...
6180 // Start over the search for slaves to create.
6181 // (Added this to fix crash with Stacker & Toolbar)
6182 next = slaves.first;
6191 if(parent == guiApp.desktop)
6192 Log("Real SetState %s\n", caption);
6195 if(isActiveClient && visible)
6197 parent.numPositions--;
6198 if(state == minimized) parent.numIcons--;
6201 parent.OnChildAddedOrRemoved(this, false);
6203 // Real set state & activate for proper display & activation
6204 property::visible = visible;
6205 // SetState(state & 0x00000003, true, 0);
6206 guiApp.interfaceDriver.SetIcon(this, icon);
6211 /*if(rootWindow == this)
6212 guiApp.interfaceDriver.ActivateRootWindow(this);
6214 if(creationActivation == activate)
6215 ActivateEx(true, false, true, true, null, null);
6216 else if(creationActivation == flash)
6221 rootWindow.ConsequentialMouseMove(false);
6232 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6238 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6240 //style.hidden = true; // !visible;
6241 style.hidden = !visible;
6242 if(master.modalSlave == this)
6243 master.modalSlave = null;
6250 void WriteCaption(Surface surface, int x, int y)
6253 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6256 void Update(Box region)
6262 rootWindow = this.rootWindow;
6264 // rootWindow.mutex.Wait();
6265 if(!destroyed && visible && display)
6270 // Testing this to avoid repetitve full update to take time...
6271 if(dirtyArea.count == 1)
6273 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6274 if(item.box.left <= box.left &&
6275 item.box.top <= box.top &&
6276 item.box.right >= box.right &&
6277 item.box.bottom >= box.bottom)
6279 rootWindow.dirty = true;
6284 if(display.flags.flipping && !rootWindow.dirty)
6286 if(this == rootWindow)
6290 rootWindow.Update(null);
6295 rootWindow.dirty = true;
6300 realBox.left += clientStart.x;
6301 realBox.top += clientStart.y;
6302 realBox.right += clientStart.x;
6303 realBox.bottom += clientStart.y;
6309 if(realBox.right >= realBox.left &&
6310 realBox.bottom >= realBox.top)
6312 // if(!rootWindow.fullRender)
6313 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6315 for(child = children.first; child; child = child.next)
6320 box.left -= child.absPosition.x - absPosition.x;
6321 box.top -= child.absPosition.y - absPosition.y;
6322 box.right -= child.absPosition.x - absPosition.x;
6323 box.bottom -= child.absPosition.y - absPosition.y;
6324 if(box.right >= child.box.left && box.left <= child.box.right &&
6325 box.bottom >= child.box.top && box.top <= child.box.bottom)
6327 box.left -= child.clientStart.x;
6328 box.top -= child.clientStart.y;
6329 box.right -= child.clientStart.x;
6330 box.bottom -= child.clientStart.y;
6336 realBox.left += absPosition.x - rootWindow.absPosition.x;
6337 realBox.top += absPosition.y - rootWindow.absPosition.y;
6338 realBox.right += absPosition.x - rootWindow.absPosition.x;
6339 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6340 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6343 else if(this == guiApp.desktop)
6346 for(window = children.first; window; window = window.next)
6352 Box childBox = region;
6354 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6355 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6356 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6357 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6359 window.Update(childBox);
6362 window.Update(null);
6367 // rootWindow.mutex.Release();
6374 if(guiApp.windowCaptured != this)
6376 if(guiApp.windowCaptured)
6380 //Logf("Captured %s (%s)\n", caption, class.name);
6381 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6382 guiApp.windowCaptured = this;
6388 bool Destroy(int code)
6393 if(!destroyed && !CloseConfirmation(false)) return false;
6397 // TOCHECK: Should autoCreate be set to false here?
6408 void Move(int x, int y, int w, int h)
6410 normalAnchor = Anchor { left = x, top = y };
6411 normalSizeAnchor = SizeAnchor { size = { w, h } };
6413 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6415 if(destroyed) return;
6417 stateAnchor = normalAnchor;
6418 stateSizeAnchor = normalSizeAnchor;
6420 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6421 Position(x,y, w, h, true, true, true, true, false, true);
6425 DialogResult Modal(void)
6431 // FIXES MEMORY LEAK IF Create() FAILED
6437 void SetScrollArea(int width, int height, bool snapToStep)
6439 bool resize = false;
6442 int stepX = sbStep.x, stepY = sbStep.y;
6443 // Needed to make snapped down position match the skin's check of client area
6444 // against realvirtual
6447 SNAPDOWN(stepX, textCellW);
6448 SNAPDOWN(stepY, textCellH);
6449 stepX = Max(stepX, textCellW);
6450 stepY = Max(stepY, textCellH);
6452 if(scrollFlags.snapX)
6453 SNAPUP(width, stepX);
6454 if(scrollFlags.snapY)
6455 SNAPUP(height, stepY);
6458 reqScrollArea.w = width;
6459 reqScrollArea.h = height;
6460 noAutoScrollArea = (width > 0 || height > 0);
6462 UpdateScrollBars(true, true);
6465 void SetScrollPosition(int x, int y)
6468 sbh.Action(setPosition, x, 0);
6472 int seen = clientSize.w, total = reqScrollArea.w;
6474 if(scrollFlags.snapX)
6475 SNAPDOWN(seen, sbStep.x);
6477 if(!total) total = seen;
6478 range = total - seen + 1;
6479 range = Max(range, 1);
6481 if(x >= range) x = range - 1;
6483 if(scrollFlags.snapX)
6484 SNAPUP(x, sbStep.x);
6487 OnHScroll(setPosition, x, 0);
6491 SNAPDOWN(x, textCellW);
6497 sbv.Action(setPosition, y, 0);
6501 int seen = clientSize.h, total = reqScrollArea.h;
6504 if(scrollFlags.snapY)
6505 SNAPDOWN(seen, sbStep.y);
6507 if(!total) total = seen;
6508 range = total - seen + 1;
6509 range = Max(range, 1);
6511 if(y >= range) y = range - 1;
6513 if(scrollFlags.snapY)
6514 SNAPUP(y, sbStep.y);
6517 OnVScroll(setPosition, y, 0);
6520 SNAPDOWN(y, textCellH);
6525 UpdateCaret(false, false);
6528 void SetScrollLineStep(int stepX, int stepY)
6534 SNAPDOWN(stepX, textCellW);
6535 SNAPDOWN(stepY, textCellH);
6536 stepX = Max(stepX, textCellW);
6537 stepY = Max(stepY, textCellH);
6540 sbh.lineStep = stepX;
6542 sbv.lineStep = stepY;
6545 void SetState(WindowState newState, bool activate, Modifiers mods)
6549 if(state == newState || OnStateChange(newState, mods))
6551 WindowState prevState = state;
6555 // This used to be at the end of the brackets... moved for X, testing...
6556 // This has the effect of activating the window through the system...
6557 if(rootWindow == this)
6558 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6560 SetStateEx(newState, activate);
6562 if(rootWindow == this && !rootWindow.nativeDecorations)
6564 int x = position.x, y = position.y;
6567 x -= guiApp.desktop.absPosition.x;
6568 y -= guiApp.desktop.absPosition.y;
6570 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6574 //state = prevState;
6576 if(state != maximized && style.hasMaximize)
6579 for(child = parent.children.first; child; child = child.next)
6581 if(child != this && child.state == maximized)
6582 child.SetStateEx(normal, false);
6586 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6587 parent.UpdateScrollBars(true, true);
6590 // Do we really need this stuff here?
6591 // Shouldn't the Activate stuff take care of it?
6592 if(parent.rootWindow == parent && style)
6595 parent.FigureCaption(caption);
6596 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6597 parent.UpdateDecorations();
6601 rootWindow.ConsequentialMouseMove(false);
6608 BitmapResource GetIcon(SkinBitmap iconID)
6610 return guiApp.currentSkin.GetBitmap(iconID);
6613 void SetMouseRange(Box range)
6615 if(range || guiApp.fullScreenMode)
6620 clip.left = range.left + absPosition.x + clientStart.x;
6621 clip.top = range.top + absPosition.y + clientStart.y;
6622 clip.right = range.right + absPosition.x + clientStart.x;
6623 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6627 clip.left = guiApp.desktop.box.left;
6628 clip.top = guiApp.desktop.box.top;
6629 clip.right = guiApp.desktop.box.right;
6630 clip.bottom = guiApp.desktop.box.bottom;
6632 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6635 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6638 void SetMouseRangeToClient(void)
6640 if(guiApp.fullScreenMode || this != guiApp.desktop)
6642 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6643 box.Clip(clientArea);
6647 SetMouseRange(null);
6650 void SetMouseRangeToWindow(void)
6652 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6653 if(this == guiApp.desktop)
6654 SetMouseRangeToClient();
6659 // x, y: Desktop Coordinates
6660 void ShowSysMenu(int x, int y)
6663 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6666 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6667 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6671 menu, $"Move", m, NotifySelect = MenuWindowMove,
6672 disabled = !style.fixed || state == maximized
6676 menu, $"Size", s, NotifySelect = MenuWindowSize,
6677 disabled = !style.sizable || state != normal
6681 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6682 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6686 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6687 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6691 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6692 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6694 MenuDivider { menu };
6697 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6698 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6700 windowMenu.Create();
6705 ActivateEx(true, true, true, true, null, null);
6708 void MakeActive(void)
6710 ActivateEx(true, false, true, false, null, null);
6713 void SoftActivate(void)
6715 if(guiApp.desktop.active)
6721 void Deactivate(void)
6723 ActivateEx(false, true, true, true, null, null);
6728 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6731 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6733 bool result = false;
6734 if(activeChild && activeChild.cycle)
6736 Window modalWindow, child = activeChild;
6737 if(!clientOnly /*&& parent.tabCycle*/)
6739 Window next = child;
6742 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6746 if(parent && parent.CycleChildren(backward, false, true, true))
6754 next = next.cycle.prev.data;
6756 next = next.cycle.next.data;
6757 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6762 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6763 parent.tabCycle && parent.CycleChildren(backward, false, false))
6767 if(tabCycleOnly && !tabCycle) return false;
6774 child = child.cycle.prev.data;
6776 child = child.cycle.next.data;
6777 if(child == child.parent.activeChild)
6779 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6782 modalWindow = child.FindModal();
6785 // Scroll the window to include the active control
6786 if(sbh && !child.style.dontScrollHorz)
6788 if(child.scrolledPos.x < 0)
6789 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6790 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6791 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6793 if(sbv && !child.style.dontScrollVert)
6795 if(child.scrolledPos.y < 0)
6796 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6797 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6798 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6802 child = modalWindow ? modalWindow : child;
6803 child.ActivateEx(true, true, true, true, null, null);
6804 if(child.tabCycle && child.childrenCycle.first)
6805 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6813 ConsequentialMouseMove(false);
6817 void AddResource(Resource resource)
6821 ResPtr ptr { resource = resource };
6825 // Load Graphics here if window is created already
6826 if(/*created && */display)
6828 display.Lock(false);
6829 ptr.loaded = display.displaySystem.LoadResource(resource);
6833 // Temporary hack to load font right away for listbox in dropbox ...
6834 else if(master && master.display)
6836 master.display.Lock(false);
6837 master.display.displaySystem.LoadResource(resource);
6838 master.display.Unlock();
6844 void RemoveResource(Resource resource)
6849 for(ptr = resources.first; ptr; ptr = ptr.next)
6851 if(ptr.resource == resource)
6857 // Unload Graphics here if window is created already
6858 if(/*created && */display)
6862 display.Lock(false);
6863 display.displaySystem.UnloadResource(resource, ptr.loaded);
6869 resources.Delete(ptr);
6874 void SetCaret(int x, int y, int size)
6881 if(active && !style.interim)
6883 if(visible || !guiApp.caretOwner)
6884 guiApp.caretOwner = size ? this : null;
6886 UpdateCaret(false, false);
6889 guiApp.interfaceDriver.SetCaret(0,0,0);
6890 UpdateCaret(false, true);
6891 guiApp.caretEnabled = false;
6894 else if(style.inactive && active)
6896 guiApp.interfaceDriver.SetCaret(0,0,0);
6897 UpdateCaret(false, true);
6898 guiApp.caretEnabled = false;
6903 void Scroll(int x, int y)
6905 bool opaque = !style.drawBehind || background.a;
6906 if(opaque && display && display.flags.scrolling)
6908 Box box = clientArea;
6909 box.left += clientStart.x;
6910 box.top += clientStart.y;
6911 box.right += clientStart.x;
6912 box.bottom += clientStart.y;
6914 //scrollExtent.Free(null);
6915 scrollExtent.AddBox(box);
6916 scrolledArea.x += x;
6917 scrolledArea.y += y;
6919 //scrollExtent.Free();
6920 //scrollExtent.AddBox(clientArea);
6921 //scrollExtent.Offset(clientStart.x, clientStart.y);
6922 //scrolledArea.x = x;
6923 //scrolledArea.y = y;
6929 rootWindow.dirty = true;
6932 void ReleaseCapture()
6934 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6936 Window oldCaptured = guiApp.windowCaptured;
6937 guiApp.windowCaptured = null;
6938 guiApp.prevWindow = null;
6941 //guiApp.Log("Released Capture\n");
6943 guiApp.interfaceDriver.SetMouseCapture(null);
6945 //oldCaptured.OnMouseCaptureLost();
6948 oldCaptured.ConsequentialMouseMove(false);
6953 void SetText(char * format, ...)
6960 char caption[MAX_F_STRING];
6962 va_start(args, format);
6963 vsnprintf(caption, sizeof(caption), format, args);
6964 caption[sizeof(caption)-1] = 0;
6967 this.caption = CopyString(caption);
6976 bool Grab(Bitmap bitmap, Box box, bool decorations)
6978 bool result = false;
6979 if(display || this == guiApp.desktop)
6981 Box clip = {MININT, MININT, MAXINT, MAXINT};
6987 clip.Clip(clientArea);
6989 clip.Clip(this.box);
6991 if(rootWindow != this)
6993 clip.left += absPosition.y;
6994 clip.top += absPosition.y;
6995 clip.right += absPosition.x;
6996 clip.bottom += absPosition.y;
6999 clip.left += decorations ? 0 : clientStart.x;
7000 clip.top += decorations ? 0 : clientStart.y;
7001 clip.right += decorations ? 0 : clientStart.x;
7002 clip.bottom += decorations ? 0 : clientStart.y;
7004 if(display && display.flags.flipping)
7006 rootWindow.Update(null);
7007 rootWindow.UpdateDisplay();
7014 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7015 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7019 result = display.Grab(bitmap, clip.left, clip.top,
7020 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7022 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7024 if(!bitmap.Convert(null, pixelFormat888, null))
7031 void GetMousePosition(int * x, int * y)
7033 int mouseX = 0, mouseY = 0;
7034 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7037 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7038 if(this != guiApp.desktop)
7040 mouseX -= absPosition.x + clientStart.x;
7041 mouseY -= absPosition.y + clientStart.y;
7048 DialogResult DoModal()
7050 DialogResult returnCode = 0;
7051 int terminated = terminateX;
7054 while(!destroyed && guiApp.driver != null)
7056 if(terminateX != terminated)
7058 terminated = terminateX;
7059 guiApp.desktop.Destroy(0);
7060 if(guiApp.desktop.created)
7063 //printf("Resetting terminate X to 0\n");
7069 guiApp.UpdateDisplay();
7070 if(!guiApp.ProcessInput(false))
7073 returnCode = this.returnCode;
7086 return !destroyed && guiApp.driver != null && terminateX < 2;
7089 DialogResult DoModalEnd()
7091 DialogResult returnCode = this.returnCode;
7096 // --- Window manipulation ---
7097 /*bool GetDisabled()
7099 bool disabled = this.disabled;
7101 for(window = this; (window = window.master); )
7112 // --- Mouse Manipulation ---
7113 void GetNCMousePosition(int * x, int * y)
7115 GetMousePosition(x, y);
7116 if(x) *x += clientStart.x;
7117 if(y) *y += clientStart.y;
7120 // --- Carets manipulation ---
7121 void GetCaretPosition(Point caretPos)
7123 caretPos = this.caretPos;
7126 int GetCaretSize(void)
7131 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7137 bool CloseConfirmation(bool parentClosing)
7150 if(!OnClose(parentClosing))
7153 // If you want to skip this, simply set modifiedDocument to false in OnClose
7154 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7156 DialogResult dialogRes;
7159 sprintf(message, $"Save changes to %s?", fileName);
7161 sprintf(message, $"Save changes to Untitled %d?", documentID);
7163 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7165 if(dialogRes == yes)
7167 // TOFIX: Precomp error if brackets are taken out
7168 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7170 else if(dialogRes == cancel)
7176 for(slave = slaves.first; slave; slave = slave.next)
7178 Window w = slave.data;
7179 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7181 // ((Window)slave.data).CloseConfirmation(true);
7190 for(child = children.first; child; child = child.next)
7191 if(child.master != this && !child.CloseConfirmation(true))
7201 // Static methods... move them somewhere else?
7202 void ::RestoreCaret()
7204 if(guiApp.caretOwner)
7205 guiApp.caretOwner.UpdateCaret(false, false);
7208 void ::FreeMouseRange()
7210 guiApp.interfaceDriver.SetMouseRange(null, null);
7214 bool MenuFileClose(MenuItem selection, Modifiers mods)
7216 Window document = activeChild;
7218 document.Destroy(0);
7222 bool MenuFileExit(MenuItem selection, Modifiers mods)
7228 bool MenuFileSave(MenuItem selection, Modifiers mods)
7232 fileMonitor.fileName = null;
7235 if(OnSaveFile(fileName))
7237 //if(OnFileModified != Window::OnFileModified)
7240 fileMonitor.fileName = fileName;
7246 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7247 DialogResult answer = dialog.Modal();
7249 if(answer != yes) return (bool)answer;
7252 return MenuFileSaveAs(selection, mods);
7255 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7257 DialogResult result = (DialogResult)bool::true;
7258 FileDialog fileDialog = saveDialog;
7261 fileDialog = FileDialog {};
7266 fileDialog.filePath = fileName;
7269 char filePath[MAX_FILENAME];
7270 sprintf(filePath, "Untitled %d", documentID);
7271 fileDialog.filePath = filePath;
7273 fileMonitor.fileName = null;
7275 fileDialog.type = save;
7276 fileDialog.text = $"Save As";
7280 fileDialog.master = master.parent ? master : this;
7281 if(fileDialog.Modal() == ok)
7283 char * filePath = fileDialog.filePath;
7285 if(OnSaveFile(filePath))
7288 property::fileName = filePath;
7289 NotifySaved(master, this, filePath);
7294 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7295 DialogResult answer = dialog.Modal();
7310 //if(OnFileModified != Window::OnFileModified && fileName)
7313 fileMonitor.fileName = fileName;
7317 return (bool)result; // Actually returning result from Yes/NoCancel message box
7320 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7322 Window document = activeChild;
7324 for(document = children.first; document; document = next)
7326 next = document.next;
7327 if(document.style.isDocument || document.fileName)
7328 document.MenuFileSave(selection, mods);
7333 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7337 for(document = children.first; document; document = document.next)
7338 //if(document.style.isDocument && document.state == minimized)
7339 if(document.style.isActiveClient && document.state == minimized)
7340 document.SetState(minimized, false, mods);
7344 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7346 Window document = activeChild;
7349 Window firstDocument = null;
7351 OldLink cycle = document.cycle.prev;
7356 if(child.style.isActiveClient && !child.style.hidden)
7360 firstDocument = child;
7361 if(child.state == minimized)
7362 child.SetState(minimized, false, mods);
7365 child.positionID = id++;
7366 child.SetState(normal, false, mods);
7367 child.anchor.left.type = cascade;
7370 child.normalSizeAnchor = *&child.sizeAnchor;
7371 child.normalAnchor = child.anchor;
7373 // Break the anchors for moveable/resizable windows
7374 if(child.style.fixed)
7376 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7378 (*&child.normalAnchor).left = x;
7379 (*&child.normalAnchor).top = y;
7380 (*&child.normalAnchor).right.type = none;
7381 (*&child.normalAnchor).bottom.type = none;
7383 child.normalSizeAnchor.isClientW = false;
7384 child.normalSizeAnchor.isClientH = false;
7385 child.normalSizeAnchor.size.w = w;
7386 child.normalSizeAnchor.size.h = h;
7387 child.anchored = false;
7390 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7392 child.stateAnchor = child.normalAnchor;
7393 child.stateSizeAnchor = child.normalSizeAnchor;
7395 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7396 child.Position(x, y, w, h, true, true, true, true, false, false);
7401 last = children.last;
7402 if(!child.style.stayOnTop)
7403 for(; last && last.style.stayOnTop; last = last.prev);
7404 children.Move(child, last);
7405 childrenOrder.Move(child.order, childrenOrder.last);
7407 if(cycle == document.cycle) break;
7411 firstDocument.Activate();
7416 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7423 // Close all closes all active clients, not all documents
7424 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7426 Window next, document;
7428 for(document = children.first; document; document = next)
7430 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7431 if(document.style.isActiveClient)
7432 if(!document.Destroy(0) && !document.style.hidden)
7438 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7440 if(style.hasMaximize && state != maximized)
7441 SetState(maximized, 0, 0);
7445 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7447 if(style.hasMinimize && state != minimized)
7449 SetState(minimized, 0, 0);
7450 parent.CycleChildren(false, true, false, true);
7455 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7457 MenuMoveOrSize(false, selection ? true : false);
7461 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7463 CycleChildren(false, true, false, true);
7467 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7469 CycleChildren(true, true, false, true);
7473 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7475 MenuMoveOrSize(true, true);
7479 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7482 SetState(normal, 0, 0);
7486 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7489 int id = selection.id;
7490 OldLink cycle = activeClient.cycle;
7492 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7495 Window sibling = cycle.data;
7496 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7504 document = cycle.data;
7505 document.Activate();
7507 //if(activeChild.state == maximized)
7508 // document.SetState(maximized, false, mods);
7509 //else if(document.state == minimized)
7510 // document.SetState(normal, false, mods);
7514 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7516 stayOnTop = !style.stayOnTop;
7520 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7522 Window document = activeChild;
7525 Window firstDocument = null;
7526 OldLink cycle = document.cycle;
7530 Window child = cycle.data;
7531 if(child.style.isActiveClient && !child.style.hidden)
7533 if(!firstDocument) firstDocument = child;
7534 if(child.state == minimized)
7535 child.SetState(minimized, false, mods);
7538 child.positionID = id++;
7539 child.SetState(normal, false, mods);
7540 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7542 child.anchor.left.type = hTiled;
7545 child.normalSizeAnchor = *&child.sizeAnchor;
7546 child.normalAnchor = child.anchor;
7548 // Break the anchors for moveable/resizable windows
7549 if(child.style.fixed)
7551 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7553 (*&child.normalAnchor).left = x;
7554 (*&child.normalAnchor).top = y;
7555 (*&child.normalAnchor).right.type = none;
7556 (*&child.normalAnchor).bottom.type = none;
7557 child.normalSizeAnchor.isClientW = false;
7558 child.normalSizeAnchor.isClientH = false;
7559 child.normalSizeAnchor.size.w = w;
7560 child.normalSizeAnchor.size.h = h;
7561 child.anchored = false;
7564 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7566 child.stateAnchor = child.normalAnchor;
7567 child.stateSizeAnchor = child.normalSizeAnchor;
7569 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7570 child.Position(x,y, w, h, true, true, true, true, false, true);
7575 if((cycle = cycle.next) == document.cycle) break;
7578 firstDocument.Activate();
7583 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7585 Window document = activeChild;
7588 Window firstDocument = null;
7590 OldLink cycle = document.cycle;
7595 //if(child.style.isDocument)
7596 if(child.style.isActiveClient && !child.style.hidden)
7598 if(!firstDocument) firstDocument = child;
7599 if(child.state == minimized)
7600 child.SetState(minimized, false, mods);
7603 child.positionID = id++;
7604 child.SetState(normal, false, mods);
7605 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7607 child.anchor.left.type = vTiled;
7610 child.normalSizeAnchor = *&child.sizeAnchor;
7611 child.normalAnchor = child.anchor;
7613 // Break the anchors for moveable/resizable windows
7614 if(child.style.fixed)
7616 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7618 (*&child.normalAnchor).left = x;
7619 (*&child.normalAnchor).top = y;
7620 (*&child.normalAnchor).right.type = none;
7621 (*&child.normalAnchor).bottom.type = none;
7622 child.normalSizeAnchor.isClientW = false;
7623 child.normalSizeAnchor.isClientH = false;
7624 child.normalSizeAnchor.size.w = w;
7625 child.normalSizeAnchor.size.h = h;
7626 child.anchored = false;
7629 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7631 child.stateAnchor = child.normalAnchor;
7632 child.stateSizeAnchor = child.normalSizeAnchor;
7634 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7635 child.Position(x,y, w, h, true, true, true, true, false, true);
7640 if((cycle = cycle.next) == document.cycle) break;
7643 firstDocument.Activate();
7648 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7650 WindowList dialog { master = this };
7651 Window document = (Window)dialog.Modal();
7654 if(activeChild.state == maximized)
7655 document.SetState(maximized, false, mods);
7656 else if(document.state == minimized)
7657 document.SetState(normal, false, mods);
7658 document.Activate();
7664 virtual bool OnCreate(void);
7665 virtual void OnDestroy(void);
7666 virtual void OnDestroyed(void);
7667 virtual bool OnClose(bool parentClosing);
7668 virtual bool OnStateChange(WindowState state, Modifiers mods);
7669 virtual bool OnPostCreate(void);
7670 virtual bool OnMoving(int *x, int *y, int w, int h);
7671 virtual bool OnResizing(int *width, int *height);
7672 virtual void OnResize(int width, int height);
7673 virtual void OnPosition(int x, int y, int width, int height);
7674 virtual bool OnLoadGraphics(void);
7675 virtual void OnApplyGraphics(void);
7676 virtual void OnUnloadGraphics(void);
7677 virtual void OnRedraw(Surface surface);
7678 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7679 virtual void OnActivateClient(Window client, Window previous);
7680 virtual bool OnKeyDown(Key key, unichar ch);
7681 virtual bool OnKeyUp(Key key, unichar ch);
7682 virtual bool OnKeyHit(Key key, unichar ch);
7683 virtual bool OnSysKeyDown(Key key, unichar ch);
7684 virtual bool OnSysKeyUp(Key key, unichar ch);
7685 virtual bool OnSysKeyHit(Key key, unichar ch);
7686 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7687 virtual bool OnMouseLeave(Modifiers mods);
7688 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7689 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7690 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7691 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7692 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7693 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7694 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7695 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7696 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7697 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7698 virtual void OnMouseCaptureLost(void);
7699 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7700 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7701 virtual void OnDrawOverChildren(Surface surface);
7702 virtual bool OnFileModified(FileChange fileChange, char * param);
7703 virtual bool OnSaveFile(char * fileName);
7705 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7706 // Note: A 'client' would refer to isActiveClient, rather than
7707 // being confined to the 'client area' (nonClient == false)
7708 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7709 virtual void OnChildVisibilityToggled(Window child, bool visible);
7710 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7712 // Skins Virtual Functions
7713 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7714 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7715 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7720 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7721 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7722 virtual bool IsMouseMoving(int x, int y, int w, int h)
7726 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7730 virtual void UpdateNonClient();
7731 virtual void SetBox(Box box);
7732 virtual bool IsInside(int x, int y)
7734 return box.IsPointInside({x, y});
7736 virtual bool IsOpaque()
7738 return (!style.drawBehind || background.a == 255);
7742 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7743 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7744 virtual void Window::NotifySaved(Window window, char * filePath);
7749 property Window parent
7751 property_category $"Layout"
7754 if(value || guiApp.desktop)
7757 Window oldParent = parent;
7758 Anchor anchor = this.anchor;
7760 if(value && value.IsDescendantOf(this)) return;
7761 if(value && value == this)
7763 if(!value) value = guiApp.desktop;
7765 if(value == oldParent) return;
7767 if(!master || (master == this.parent && master == guiApp.desktop))
7768 property::master = value;
7772 parent.children.Remove(this);
7776 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7777 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7778 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7779 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7783 last = value.children.last;
7785 if(style.isDocument)
7788 parent.numDocuments--;
7789 documentID = value.GetDocumentID();
7792 if(style.isActiveClient && !style.hidden)
7794 if(parent && parent != guiApp.desktop && !(style.hidden))
7796 if(state == minimized) parent.numIcons--;
7797 parent.numPositions--;
7801 if(!style.stayOnTop)
7802 for(; last && last.style.stayOnTop; last = last.prev);
7804 value.children.Insert(last, this);
7806 // *** NEW HERE: ***
7808 parent.childrenCycle.Delete(cycle);
7810 parent.childrenOrder.Delete(order);
7813 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7814 // Should something else be done?
7815 if(parent && parent.activeChild == this)
7816 parent.activeChild = null;
7817 if(parent && parent.activeClient == this)
7818 parent.activeClient = null;
7824 int x = position.x, y = position.y, w = size.w, h = size.h;
7828 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7829 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7831 vpw = value.clientSize.w;
7832 vph = value.clientSize.h;
7838 else if(style.fixed)
7840 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7841 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7844 anchor = this.anchor;
7846 if(anchor.left.type == offset) anchor.left.distance = x;
7847 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7848 if(anchor.top.type == offset) anchor.top.distance = y;
7849 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7850 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7851 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7852 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7853 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7854 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7855 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7857 if(!anchor.left.type && !anchor.right.type)
7859 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7860 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7862 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7863 if(!anchor.top.type && !anchor.bottom.type)
7865 anchor.vert.distance = (y + h / 2) - (vph / 2);
7866 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7868 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7871 parent.OnChildAddedOrRemoved(this, false);
7877 parent.childrenCycle.Insert(
7878 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7879 cycle = OldLink { data = this });
7880 parent.childrenOrder.Insert(
7881 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7882 order = OldLink { data = this });
7885 if(!style.hidden && style.isActiveClient)
7887 positionID = parent.GetPositionID(this);
7888 parent.numPositions++;
7889 if(state == minimized) parent.numIcons--;
7892 // *** FONT INHERITANCE ***
7893 if(!setFont && oldParent)
7894 stopwatching(oldParent, font);
7898 RemoveResource(systemFont);
7901 // TESTING WITH WATCHERS:
7902 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7903 // usedFont = setFont ? setFont : (systemFont);
7907 if(guiApp.currentSkin)
7909 systemFont = guiApp.currentSkin.SystemFont();
7912 usedFont = systemFont;
7913 AddResource(systemFont);
7921 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7930 if(value.rootWindow && value.rootWindow.display && rootWindow)
7932 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7933 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7936 UnloadGraphics(false);
7939 LoadGraphics(false, false);
7942 if(value.rootWindow != rootWindow)
7943 DisplayModeChanged();
7947 scrolledPos.x = MININT; // Prevent parent update
7949 bool anchored = this.anchored;
7950 property::anchor = anchor;
7951 this.anchored = anchored;
7956 if(guiApp.currentSkin)
7957 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7959 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7960 Position(x, y, w, h, true, true, true, true, false, true);
7965 // else parent = value;
7967 oldParent.OnChildAddedOrRemoved(this, true);
7970 get { return parent; }
7973 property Window master
7975 property_category $"Behavior"
7978 //if(this == value) return;
7979 if(value && value.IsSlaveOf(this)) return;
7985 OldLink slaveHolder;
7986 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7987 if(slaveHolder.data == this)
7989 master.slaves.Delete(slaveHolder);
7996 value.slaves.Add(OldLink { data = this });
8001 master.hotKeys.Remove(hotKey);
8002 value.hotKeys.Add(hotKey);
8005 if(master && master.defaultControl == this)
8006 master.defaultControl = null;
8008 if(style.isDefault && !value.defaultControl)
8009 value.defaultControl = this;
8014 get { return master ? master : parent; }
8017 property char * caption
8019 property_category $"Appearance"
8026 caption = new char[strlen(value)+1];
8028 strcpy(caption, value);
8033 get { return caption; }
8038 property_category $"Behavior"
8047 master.hotKeys.Add(hotKey = HotKeySlot { });
8051 hotKey.window = this;
8056 master.hotKeys.Delete(hotKey);
8061 get { return hotKey ? hotKey.key : 0; }
8064 property Color background
8066 property_category $"Appearance"
8069 background.color = value;
8074 if(this == rootWindow)
8075 guiApp.interfaceDriver.SetRootWindowColor(this);
8078 get { return background.color; }
8081 property Percentage opacity
8083 property_category $"Appearance"
8086 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8087 drawBehind = (background.a == 255) ? false : true;
8089 get { return background.a / 255.0f; }
8092 property Color foreground
8094 property_category $"Appearance"
8102 get { return foreground; }
8105 property BorderStyle borderStyle
8107 property_category $"Appearance"
8110 if(!((BorderBits)value).fixed)
8112 style.hasClose = false;
8113 style.hasMaximize = false;
8114 style.hasMinimize = false;
8115 nativeDecorations = false;
8117 style.borderBits = value;
8121 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8123 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8124 Position(x, y, w, h, true, true, true, true, false, true);
8125 CreateSystemChildren();
8128 get { return (BorderStyle)style.borderBits; }
8131 property Size minClientSize
8133 property_category $"Layout"
8134 set { minSize = value; }
8135 get { value = minSize; }
8138 property Size maxClientSize
8140 property_category $"Layout"
8141 set { maxSize = value; }
8142 get { value = maxSize; }
8145 property bool hasMaximize
8147 property_category $"Window Style"
8150 style.hasMaximize = value;
8151 if(value) { style.fixed = true; style.contour = true; }
8155 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8157 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8158 Position(x, y, w, h, true, true, true, true, false, true);
8160 CreateSystemChildren();
8163 get { return style.hasMaximize; }
8166 property bool hasMinimize
8168 property_category $"Window Style"
8171 style.hasMinimize = value;
8172 if(value) { style.fixed = true; style.contour = true; }
8176 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8178 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8179 Position(x, y, w, h, true, true, true, true, false, true);
8181 CreateSystemChildren();
8184 get { return style.hasMinimize; }
8187 property bool hasClose
8189 property_category $"Window Style"
8192 style.hasClose = value;
8193 if(value) { style.fixed = true; style.contour = true; }
8197 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8198 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8199 Position(x, y, w, h, true, true, true, true, false, true);
8200 CreateSystemChildren();
8203 get { return style.hasClose; }
8206 property bool nonClient
8208 property_category $"Layout"
8211 style.nonClient = value;
8213 style.stayOnTop = true;
8215 get { return style.nonClient; }
8218 property bool inactive
8220 property_category $"Behavior"
8225 // *** NEW HERE: ***
8229 parent.childrenCycle.Delete(cycle);
8231 parent.childrenOrder.Delete(order);
8238 active = false; // true;
8239 if(parent.activeChild == this)
8240 parent.activeChild = null;
8241 if(parent.activeClient == this)
8242 parent.activeClient = null;
8251 parent.childrenCycle.Insert(
8252 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8253 cycle = OldLink { data = this });
8255 parent.childrenOrder.Insert(
8256 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8257 order = OldLink { data = this });
8260 style.inactive = value;
8262 get { return style.inactive; }
8265 property bool clickThrough
8267 property_category $"Behavior"
8268 set { style.clickThrough = value; }
8269 get { return style.clickThrough; }
8272 property bool isRemote
8274 property_category $"Behavior"
8275 set { style.isRemote = value; }
8276 get { return style.isRemote; }
8279 property bool noCycle
8281 property_category $"Behavior"
8282 set { style.noCycle = value; }
8283 get { return style.noCycle; }
8286 property bool isModal
8288 property_category $"Behavior"
8289 set { style.modal = value; }
8290 get { return style.modal; }
8293 property bool interim
8295 property_category $"Behavior"
8296 set { style.interim = value; }
8297 get { return style.interim; }
8300 property bool tabCycle
8302 property_category $"Behavior"
8303 set { style.tabCycle = value; }
8304 get { return style.tabCycle; }
8307 property bool isDefault
8309 property_category $"Behavior"
8317 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8318 if(sibling != this && sibling.style.isDefault)
8319 sibling.style.isDefault = false;*/
8320 if(master.defaultControl)
8321 master.defaultControl.style.isDefault = false;
8322 master.defaultControl = this;
8324 else if(master.defaultControl == this)
8325 master.defaultControl = null;
8329 style.isDefault = value;
8331 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8333 get { return style.isDefault; }
8336 property bool drawBehind
8338 property_category $"Window Style"
8339 set { style.drawBehind = value; }
8340 get { return style.drawBehind; }
8343 property bool hasMenuBar
8345 property_category $"Window Style"
8355 if(created && !menuBar)
8362 anchor = Anchor { top = 23, left = 1, right = 1 },
8364 inactive = true, nonClient = true
8369 else if(created && menuBar)
8374 style.hasMenuBar = value;
8376 get { return style.hasMenuBar; }
8379 property bool hasStatusBar
8381 property_category $"Window Style"
8388 statusBar = StatusBar { this };
8396 style.hasStatusBar = value;
8398 get { return style.hasStatusBar; }
8400 property bool stayOnTop
8402 property_category $"Window Style"
8407 if(created && !style.stayOnTop)
8409 if(rootWindow == this)
8410 guiApp.interfaceDriver.OrderRootWindow(this, true);
8411 else if(parent.children.last != this)
8413 parent.children.Move(this, parent.children.last);
8417 style.stayOnTop = true;
8421 if(created && style.stayOnTop)
8423 if(rootWindow == this)
8424 guiApp.interfaceDriver.OrderRootWindow(this, false);
8431 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8432 order && ((Window)order.data).style.stayOnTop;
8433 order = (order == parent.childrenOrder.first) ? null : order.prev);
8434 last = order ? order.data : null;
8438 for(last = parent.children.last;
8439 last && last.style.stayOnTop;
8443 parent.children.Move(this, last);
8447 style.stayOnTop = false;
8450 get { return style.stayOnTop; }
8455 property_category $"Window Style"
8465 if(menuBar && !value)
8472 if(!menuBar && style.hasMenuBar && value)
8476 this, menu = value, isMenuBar = true,
8477 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8478 inactive = true, nonClient = true
8482 UpdateActiveDocument(null);
8485 get { return menu; }
8488 property FontResource font
8490 property_category $"Appearance"
8492 isset { return setFont ? true : false; }
8497 if(value && !setFont) { stopwatching(parent, font); }
8498 else if(!value && setFont)
8504 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8513 RemoveResource(setFont);
8518 RemoveResource(systemFont);
8525 AddResource(setFont);
8528 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8531 systemFont = guiApp.currentSkin.SystemFont();
8533 usedFont = systemFont;
8534 AddResource(systemFont);
8542 get { return usedFont; }
8545 property SizeAnchor sizeAnchor
8547 property_category $"Layout"
8550 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8551 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8552 sizeAnchor.isClientW != sizeAnchor.isClientH;
8559 normalSizeAnchor = sizeAnchor;
8561 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8563 stateAnchor = normalAnchor;
8564 stateSizeAnchor = normalSizeAnchor;
8566 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8567 Position(x,y, w, h, true, true, true, true, false, true);
8574 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8575 sizeAnchor.isClientW,
8576 sizeAnchor.isClientH
8583 property_category $"Layout"
8586 Anchor thisAnchor = anchor;
8587 SizeAnchor thisSizeAnchor = sizeAnchor;
8588 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8589 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8590 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8591 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8592 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8593 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8599 sizeAnchor.isClientW = false;
8600 sizeAnchor.isClientH = false;
8601 sizeAnchor.size = value;
8603 normalSizeAnchor = sizeAnchor;
8605 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8607 stateAnchor = normalAnchor;
8608 stateSizeAnchor = normalSizeAnchor;
8610 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8611 Position(x, y, w, h, true, true, true, true, false, true);
8612 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8615 get { value = size; }
8618 property Size clientSize
8620 property_category $"Layout"
8623 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8624 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8625 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8630 sizeAnchor.isClientW = true;
8631 sizeAnchor.isClientH = true;
8632 sizeAnchor.size = value;
8634 normalSizeAnchor = sizeAnchor;
8636 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8638 stateAnchor = normalAnchor;
8639 stateSizeAnchor = normalSizeAnchor;
8641 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8642 Position(x,y, w, h, true, true, true, true, false, true);
8645 get { value = clientSize; }
8648 property Size initSize { get { value = sizeAnchor.size; } };
8650 property Anchor anchor
8652 property_category $"Layout"
8653 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8659 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8661 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8662 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8664 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8666 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8667 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8671 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8673 anchor.left.distance = 0;
8674 anchor.horz.type = 0;
8676 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8678 anchor.top.distance = 0;
8679 anchor.vert.type = 0;
8688 normalAnchor = anchor;
8690 // Break the anchors for moveable/resizable windows
8691 /*if(style.fixed ) //&& value.left.type == cascade)
8693 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8695 this.anchor = normalAnchor = Anchor { left = x, top = y };
8696 normalSizeAnchor = SizeAnchor { { w, h } };
8699 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8701 stateAnchor = normalAnchor;
8702 stateSizeAnchor = normalSizeAnchor;
8704 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8705 Position(x, y, w, h, true, true, true, true, false, true);
8714 get { value = this ? anchor : Anchor { }; }
8717 property Point position
8719 property_category $"Layout"
8722 if(value == null) return;
8724 anchor.left = value.x;
8725 anchor.top = value.y;
8726 anchor.right.type = none;
8727 anchor.bottom.type = none;
8732 normalAnchor = anchor;
8734 // Break the anchors for moveable/resizable windows
8738 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8740 normalAnchor.left = x;
8741 normalAnchor.top = y;
8742 normalAnchor.right.type = none;
8743 normalAnchor.bottom.type = none;
8744 normalSizeAnchor.size.width = w;
8745 normalSizeAnchor.size.height = h;
8749 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8751 stateAnchor = normalAnchor;
8752 stateSizeAnchor = normalSizeAnchor;
8754 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8755 Position(x,y, w, h, true, true, true, true, false, true);
8759 get { value = position; }
8762 property bool disabled
8764 property_category $"Behavior"
8767 if(this && disabled != value)
8774 get { return (bool)disabled; }
8777 property bool isEnabled
8782 for(parent = this; parent; parent = parent.parent)
8789 property WindowState state
8791 property_category $"Behavior"
8792 set { SetState(value, false, 0); }
8793 get { return this ? state : 0; }
8796 property bool visible
8798 property_category $"Behavior"
8801 if(this && !value && !style.hidden && parent)
8803 bool wasActiveChild = parent.activeChild == this;
8804 Window client = null;
8806 style.hidden = true;
8807 if(style.isActiveClient)
8809 parent.numPositions--;
8810 if(state == minimized) parent.numIcons--;
8815 OldLink prevOrder = null;
8817 if(rootWindow == this)
8818 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8821 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8824 box.left -= parent.clientStart.x;
8825 box.top -= parent.clientStart.y;
8826 box.right -= parent.clientStart.x;
8827 box.bottom -= parent.clientStart.y;
8831 if(_isModal && master && master.modalSlave == this)
8832 master.modalSlave = null;
8836 OldLink tmpPrev = order.prev;
8837 client = tmpPrev ? tmpPrev.data : null;
8838 if(client && !client.style.hidden && !client.destroyed && client.created)
8839 prevOrder = tmpPrev;
8842 client = tmpPrev ? tmpPrev.data : null;
8843 if(client == this) { client = null; break; }
8844 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8846 tmpPrev = client.order.prev;
8851 prevOrder = tmpPrev;
8856 // If this window can be an active client, make sure the next window we activate can also be one
8857 if(!style.nonClient && style.isActiveClient)
8859 tmpPrev = prevOrder;
8862 client = tmpPrev ? tmpPrev.data : null;
8863 if(client == this) { client = null; break; }
8864 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8866 tmpPrev = client.order.prev;
8871 prevOrder = tmpPrev;
8875 if(client && client.style.hidden) client = null;
8879 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8881 if(order && prevOrder && prevOrder.data != this)
8882 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8884 ActivateEx(false, false, false, true, null, null);
8886 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8887 if(parent.activeClient == this)
8889 parent.activeClient = null;
8890 parent.UpdateActiveDocument(null);
8893 else if(parent.activeClient == this)
8895 parent.activeClient = client;
8896 parent.UpdateActiveDocument(this);
8899 // *** Not doing this anymore ***
8902 parent.childrenCycle.Delete(cycle);
8904 parent.childrenOrder.Delete(order);
8909 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8914 else if(this && value && style.hidden)
8916 style.hidden = false;
8919 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8920 if(rootWindow == this)
8921 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8923 if(_isModal && master)
8924 master.modalSlave = this;
8926 if(style.isActiveClient)
8928 positionID = parent.GetPositionID(this);
8929 parent.numPositions++;
8930 if(state == minimized) parent.numIcons++;
8933 // *** NOT DOING THIS ANYMORE ***
8935 if(!(style.inactive))
8937 if(!(style.noCycle))
8939 cycle = parent.childrenCycle.AddAfter(
8940 (parent.activeChild && parent.activeChild.cycle) ?
8941 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8944 order = parent.childrenOrder.AddAfter(
8945 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8952 if(true || !parent.activeChild)
8953 ActivateEx(true, false, true, true, null, null);
8955 if(creationActivation == activate)
8956 ActivateEx(true, false, true, true, null, null);
8957 else if(creationActivation == flash && !object)
8960 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8964 ConsequentialMouseMove(false);
8970 style.hidden = !value;
8973 get { return (style.hidden || !setVisible) ? false : true; }
8976 property bool isDocument
8978 property_category $"Document"
8979 set { style.isDocument = value; }
8980 get { return style.isDocument; }
8983 property bool mergeMenus
8985 property_category $"Window Style"
8986 set { mergeMenus = value; }
8987 get { return (bool)mergeMenus; }
8990 property bool hasHorzScroll
8992 property_category $"Window Style"
8997 if(!style.hasHorzScroll && created)
8999 CreateSystemChildren();
9000 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9003 else if(style.hasHorzScroll)
9007 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9009 style.hasHorzScroll = value;
9012 get { return style.hasHorzScroll; }
9015 property bool hasVertScroll
9017 property_category $"Window Style"
9022 if(!style.hasVertScroll && created)
9024 style.hasVertScroll = true;
9025 CreateSystemChildren();
9026 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9029 else if(style.hasVertScroll)
9033 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9035 style.hasVertScroll = value;
9037 get { return style.hasVertScroll; }
9040 property bool dontHideScroll
9042 property_category $"Behavior"
9045 scrollFlags.dontHide = value;
9048 //UpdateScrollBars(true, true);
9049 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9053 // UpdateScrollBars(true, true);
9054 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9057 get { return scrollFlags.dontHide; }
9060 property bool dontScrollVert
9062 property_category $"Behavior"
9063 set { style.dontScrollVert = value; }
9064 get { return style.dontScrollVert; }
9066 property bool dontScrollHorz
9068 property_category $"Behavior"
9069 set { style.dontScrollHorz = value; }
9070 get { return style.dontScrollHorz; }
9073 property bool snapVertScroll
9075 property_category $"Behavior"
9078 scrollFlags.snapY = value;
9079 if(sbv) sbv.snap = value;
9081 get { return scrollFlags.snapY; }
9083 property bool snapHorzScroll
9085 property_category $"Behavior"
9088 scrollFlags.snapX = value;
9089 if(sbh) sbh.snap = value;
9091 get { return scrollFlags.snapX; }
9094 property Point scroll
9096 property_category $"Behavior"
9097 set { SetScrollPosition(value.x, value.y); }
9098 get { value = scroll; }
9101 property bool modifyVirtualArea
9103 property_category $"Behavior"
9104 set { modifyVirtArea = value; }
9105 get { return (bool)modifyVirtArea; }
9108 property bool dontAutoScrollArea
9110 property_category $"Behavior"
9111 // Activating a child control out of view will automatically scroll to make it in view
9112 set { noAutoScrollArea = value; }
9113 get { return (bool)noAutoScrollArea; }
9116 property char * fileName
9118 property_category $"Document"
9121 if(menu && ((!fileName && value) || (fileName && !value)))
9123 MenuItem item = menu.FindItem(MenuFileSave, 0);
9124 if(item) item.disabled = !modifiedDocument && value;
9129 if(value && value[0])
9130 fileName = CopyString(value);
9132 if(parent && this == parent.activeClient)
9133 parent.UpdateActiveDocument(null);
9137 // if(style.isDocument)
9139 fileMonitor.fileName = value;
9141 get { return fileName; }
9146 property_category $"Data"
9151 property bool modifiedDocument
9153 property_category $"Document"
9156 if(style.isDocument || fileName)
9160 MenuItem item = menu.FindItem(MenuFileSave, 0);
9161 if(item) item.disabled = !value && fileName;
9165 if(modifiedDocument != value)
9167 modifiedDocument = value;
9168 if(style.isDocument || fileName)
9172 get { return (bool)modifiedDocument; }
9175 property bool showInTaskBar
9177 property_category $"Window Style"
9178 set { style.showInTaskBar = value; }
9179 get { return (style.showInTaskBar; }
9181 property FileDialog saveDialog { set { saveDialog = value; } };
9182 property bool isActiveClient
9184 property_category $"Behavior"
9185 set { style.isActiveClient = value; }
9186 get { return style.isActiveClient; }
9189 property Cursor cursor
9191 property_category $"Appearance"
9195 SelectMouseCursor();
9197 get { return cursor; }
9200 //#if !defined(ECERE_VANILLA)
9201 property char * name
9203 property_category $"Design"
9206 return (this && object) ? object.name : null;
9211 activeDesigner.RenameObject(object, value);
9215 property char * displayDriver
9217 property_category $"Behavior"
9220 dispDriver = GetDisplayDriver(value);
9221 //DisplayModeChanged();
9225 return dispDriver ? dispDriver.name : null;
9229 // RUNTIME PROPERTIES
9230 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9231 property Size scrollArea
9233 property_category $"Behavior"
9237 SetScrollArea(value.w, value.h, false);
9239 SetScrollArea(0,0, true);
9241 get { value = scrollArea; }
9244 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9249 property_category $"Layout"
9250 set { if(this) is3D = value; }
9251 get { return (bool)is3D; }
9254 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9256 // Will be merged with font later
9257 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9258 property Point clientStart { get { value = clientStart; } };
9259 property Point absPosition { get { value = absPosition; } };
9260 property Anchor normalAnchor { get {value = normalAnchor; } };
9261 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9262 property bool active { get { return (bool)active; } };
9263 property bool created { get { return (bool)created; } };
9264 property bool destroyed { get { return (bool)destroyed; } };
9265 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9266 property Window firstChild { get { return children.first; } };
9267 property Window lastChild { get { return children.last; } };
9268 property Window activeClient { get { return activeClient; } };
9269 property Window activeChild { get { return activeChild; } };
9270 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9271 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9272 property ScrollBar horzScroll { get { return sbh; } };
9273 property ScrollBar vertScroll { get { return sbv; } };
9274 property StatusBar statusBar { get { return statusBar; } };
9275 property Window rootWindow { get { return rootWindow; } };
9276 property bool closing { get { return (bool)closing; } set { closing = value; } };
9277 property int documentID { get { return documentID; } };
9278 property Window previous { get { return prev; } }
9279 property Window next { get { return next; } }
9280 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9281 property PopupMenu menuBar { get { return menuBar; } }
9282 property ScrollBar sbv { get { return sbv; } }
9283 property ScrollBar sbh { get { return sbh; } }
9284 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9285 property void * systemHandle { get { return windowHandle; } }
9286 property Button minimizeButton { get { return sysButtons[0]; } };
9287 property Button maximizeButton { get { return sysButtons[1]; } };
9288 property Button closeButton { get { return sysButtons[2]; } };
9289 property BitmapResource icon
9291 get { return icon; }
9295 if(icon) incref icon;
9297 guiApp.interfaceDriver.SetIcon(this, value);
9300 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9301 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9302 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9303 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9304 property bool nativeDecorations
9306 get { return (bool)nativeDecorations; }
9307 set { nativeDecorations = value; }
9308 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9311 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9312 bool result = false;
9313 if(nativeDecorations)
9315 if(rootWindow == this)
9319 if(formDesigner && activeDesigner)
9321 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9322 Window form = cd ? cd.form : null;
9323 if(form && parent == form.parent)
9328 return result != style.fixed;
9332 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9334 property char * text
9336 property_category $"Deprecated"
9338 set { property::caption = value; }
9339 get { return property::caption; }
9345 WindowBits style; // Window Style
9346 char * caption; // Name / Caption
9347 Window parent; // Parent window
9348 OldList children; // List of children in Z order
9349 Window activeChild; // Child window having focus
9350 Window activeClient;
9351 Window previousActive; // Child active prior to activating the default child
9352 Window master; // Window owning and receiving notifications concerning this window
9353 OldList slaves; // List of windows belonging to this window
9354 Display display; // Display this window is drawn into
9356 Point position; // Position in parent window client area
9357 Point absPosition; // Absolute position
9358 Point clientStart; // Client area position from (0,0) in this window
9360 Size clientSize; // Client area size
9361 Size scrollArea; // Virtual Scroll area size
9362 Size reqScrollArea; // Requested virtual area size
9363 Point scroll; // Virtual area scrolling position
9364 public ScrollBar sbh, sbv; // Scrollbar window handles
9365 Cursor cursor; // Mouse cursor used for this window
9368 StatusBar statusBar;
9369 Button sysButtons[3];
9371 Box clientArea; // Client Area box clipped to parent
9373 HotKeySlot hotKey; // HotKey for this window
9377 ScrollFlags scrollFlags;// Window Scrollbar Flags
9378 int id; // Control ID
9380 ColorAlpha background; // Background color used to draw the window area
9382 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9383 OldList childrenCycle; // Cycling order
9384 OldLink cycle; // Element of parent's cycling order
9385 OldList childrenOrder; // Circular Z-Order
9386 OldLink order; // Element of parent's circular Z-Order
9387 Window modalSlave; // Slave window blocking this window's interaction
9389 Window rootWindow; // Topmost system managed window
9390 void * windowHandle; // System window handle
9392 DialogResult returnCode;// Return code for modal windows
9394 Point sbStep; // Scrollbar line scrolling steps
9397 SizeAnchor stateSizeAnchor;
9399 Anchor normalAnchor;
9400 SizeAnchor normalSizeAnchor;
9402 Size skinMinSize; // Minimal window size based on style
9403 Point scrolledPos; // Scrolled position
9404 Box box; // Window box clipped to parent
9405 Box * against; // What to clip the box to
9407 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9408 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9409 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9410 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9411 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9412 Point scrolledArea; // Distance to scroll area by
9413 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9415 OldList hotKeys; // List of the hotkeys of all children
9416 Window defaultControl; // Default child control
9420 ColorAlpha * palette; // Color palette used for this window
9422 int caretSize; // Size of caret, non zero if a caret is present
9423 Point caretPos; // Caret position
9425 void * systemParent; // Parent System Window for embedded windows
9432 WindowState lastState;
9434 FileMonitor fileMonitor
9436 this, FileChange { modified = true };
9438 bool OnFileNotify(FileChange action, char * param)
9441 fileMonitor.StopMonitoring();
9442 if(OnFileModified(action, param))
9443 fileMonitor.StartMonitoring();
9448 FontResource setFont, systemFont;
9449 FontResource usedFont;
9450 FontResource captionFont;
9452 FileDialog saveDialog;
9454 SizeAnchor sizeAnchor;
9456 // FormDesigner data
9459 Extent * tempExtents; //[4];
9460 BitmapResource icon;
9462 CreationActivationOption creationActivation;
9465 bool active:1; // true if window and ancestors are active
9466 bool acquiredInput:1; // true if the window is processing state based input
9467 bool modifiedDocument:1;
9468 bool disabled:1; // true if window cannot interact
9469 bool isForegroundWindow:1;// true while a root window is being activated
9470 bool visible:1; // Visibility flag
9471 bool destroyed:1; // true if window is being destroyed
9472 bool anchored:1; // true if this window is repositioned when the parent resizes
9473 bool dirty:1; // Flag set to true if any descendant must be redrawn
9479 bool modifyVirtArea:1;
9480 bool noAutoScrollArea:1;
9483 bool setVisible:1; // FOR FORM DESIGNER
9489 bool useSharedMemory:1;
9492 bool nativeDecorations:1;
9493 bool manageDisplay:1;
9494 bool formDesigner:1; // True if we this is running in the form editor
9497 // Checks used internally for them not to take effect in FormDesigner
9498 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9499 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9501 WindowController controller;
9502 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9505 public class CommonControl : Window
9507 // creationActivation = doNothing;
9510 public property String toolTip
9512 property_category $"Appearance"
9515 if(created) CommonControl::OnDestroy();
9517 toolTip = value ? ToolTip { tip = value; } : null;
9519 if(created) CommonControl::OnCreate();
9521 get { return toolTip ? toolTip.tip : null; }
9527 // (Very) Ugly work around for the fact that the parent watcher
9528 // won't fire when it's already been disconnected...
9529 eInstance_FireSelfWatchers(toolTip,
9530 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9536 toolTip.parent = this;
9545 public class Percentage : float
9547 char * OnGetString(char * string, float * fieldData, bool * needClass)
9551 sprintf(string, "%.2f", this);
9552 c = strlen(string)-1;
9555 if(string[c] != '0')
9556 last = Max(last, c);
9557 if(string[c] == '.')
9570 public void ApplySkin(Class c, char * name, void ** vTbl)
9572 char className[1024];
9577 subclass(Window) wc = (subclass(Window))c;
9578 subclass(Window) base = (subclass(Window))c.base;
9580 sprintf(className, "%sSkin_%s", name, c.name);
9581 wc.pureVTbl = c._vTbl;
9582 c._vTbl = new void *[c.vTblSize];
9583 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9584 sc = eSystem_FindClass(c.module.application, className);
9588 for(m = 0; m < c.base.vTblSize; m++)
9590 if(c._vTbl[m] == base.pureVTbl[m])
9591 c._vTbl[m] = vTbl[m];
9596 for(m = 0; m < c.vTblSize; m++)
9598 if(sc._vTbl[m] != wc.pureVTbl[m])
9599 c._vTbl[m] = sc._vTbl[m];
9603 for(d = c.derivatives.first; d; d = d.next)
9605 ApplySkin(d.data, name, c._vTbl);
9609 public void UnapplySkin(Class c)
9611 char className[1024];
9613 subclass(Window) wc = (subclass(Window))c;
9614 subclass(Window) base = (subclass(Window))c.base;
9617 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9620 c._vTbl = wc.pureVTbl;
9624 for(d = c.derivatives.first; d; d = d.next)
9626 UnapplySkin(d.data);
9630 void CheckFontIntegrity(Window window)
9635 if(window.usedFont && window.usedFont.font == 0xecececec)
9637 FontResource uf = window.usedFont;
9638 char * className = window._class.name;
9639 char * text = window.text;
9642 for(c = window.firstChild; c; c = c.next)
9643 CheckFontIntegrity(c);
9647 public class ControllableWindow : Window
9649 /*WindowController controller;
9650 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9651 ~ControllableWindow() { delete controller; }*/
9654 class WindowControllerInterface : ControllableWindow
9656 bool OnKeyDown(Key key, unichar ch)
9658 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9660 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9664 bool OnKeyUp(Key key, unichar ch)
9666 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9668 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9672 bool OnKeyHit(Key key, unichar ch)
9674 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9676 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9680 bool OnMouseMove(int x, int y, Modifiers mods)
9682 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9684 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9688 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9690 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9692 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9696 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9698 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9700 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9704 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9706 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9708 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9712 bool OnRightButtonDown(int x, int y, Modifiers mods)
9714 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9716 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9720 bool OnRightButtonUp(int x, int y, Modifiers mods)
9722 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9724 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9728 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9730 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9732 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9736 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9738 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9740 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9744 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9746 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9748 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9752 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9754 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9756 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9760 void OnResize(int width, int height)
9762 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9763 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9766 void OnRedraw(Surface surface)
9768 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9769 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9774 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9776 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9780 bool OnLoadGraphics()
9782 bool result = ((int(*)())(void *)controller.OnLoadGraphics)((void *)controller.controlled, (void *)controller);
9784 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics](controller.window);
9788 void OnUnloadGraphics()
9790 ((int(*)())(void *)controller.OnUnloadGraphics)((void *)controller.controlled, (void *)controller);
9791 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics](controller.window);
9795 public class WindowController<class V>
9798 property Window window
9802 uint size = class(Window).vTblSize;
9805 windowVTbl = new void *[size];
9806 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9807 if(value._vTbl == value._class._vTbl)
9809 value._vTbl = new void *[value._class.vTblSize];
9810 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9814 for(c = 0; c < size; c++)
9816 void * function = class(WindowControllerInterface)._vTbl[c];
9817 if(function != DefaultFunction)
9818 value._vTbl[c] = function;
9820 value._vTbl[c] = windowVTbl[c];
9825 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9828 get { return window; }
9830 property V controlled
9832 set { controlled = value; }
9833 get { return controlled; }
9835 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9836 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9837 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9838 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9839 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9840 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9841 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9842 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9843 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9844 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9845 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9846 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9847 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9848 virtual void V::OnResize(WindowController controller, int width, int height);
9849 virtual void V::OnRedraw(WindowController controller, Surface surface);
9850 virtual bool V::OnCreate(WindowController controller);
9851 virtual bool V::OnLoadGraphics(WindowController controller);
9852 virtual void V::OnUnloadGraphics(WindowController controller);
9855 int (** windowVTbl)();