7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
573 stopwatching(parent, font);
574 if(parent.activeChild == this)
575 parent.activeChild = null;
576 if(parent.activeClient == this)
577 parent.activeClient = null;
582 // Prevent destructor from being called again...
588 /////////////////////////////////
591 OldLink slave = master.slaves.FindLink(this);
592 master.slaves.Delete(slave);
599 parent.childrenCycle.Remove(cycle);
601 parent.childrenOrder.Remove(order);
602 parent.children.Remove(this);
607 /////////////////////////////////
609 while(ptr = resources.first)
612 resources.Delete(ptr);
619 for(child = children.first; child; child = child.next)
621 // child.stopwatching(this, font);
623 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
624 // Don't want property here
625 *&child.parent = null;
628 while(slave = slaves.first)
630 // Don't want property here
631 *&((Window)slave.data).master = null;
632 slaves.Delete(slave);
635 // Because we do a decref in DestroyEx...
643 // Why was this commented?
644 //if(this != guiApp.desktop)
657 if(((subclass(Window))_class).pureVTbl)
659 if(_vTbl == _class._vTbl)
661 _vTbl = ((subclass(Window))_class).pureVTbl;
666 for(m = 0; m < _class.vTblSize; m++)
668 if(_vTbl[m] == _class._vTbl[m])
669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
673 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
676 dirtyArea.Free(null);
677 renderArea.Free(null);
678 overRenderArea.Free(null);
679 clipExtent.Free(null);
680 scrollExtent.Free(null);
681 dirtyBack.Free(null);
685 tempExtents[0].Free(null);
686 tempExtents[1].Free(null);
687 tempExtents[2].Free(null);
688 tempExtents[3].Free(null);
693 //#if !defined(ECERE_VANILLA)
694 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
696 if(this == activeDesigner)
700 char * name = property::name;
701 return name ? name : "";
706 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
707 bool OnGetDataFromString(char * string)
709 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
712 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
713 this = designer.form;
714 else if(!strcmpi(string, "(Desktop)"))
715 this = activeDesigner;
717 return activeDesigner.FindObject(&this, string);
723 // --- Window updates system ---
725 // Setup a bitmap for Redrawing on client area of Window
726 Surface Redraw(Box box)
728 Surface surface = null;
730 Box clientArea = this.clientArea;
734 mox.left -= clientStart.x;
735 mox.top -= clientStart.y;
736 mox.right -= clientStart.x;
737 mox.bottom -= clientStart.y;
739 mox.Clip(clientArea);
740 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
742 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
744 int x = absPosition.x + clientStart.x;
745 int y = absPosition.y + clientStart.y;
746 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
748 x -= rootWindow.clientStart.x;
749 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
751 if(!guiApp.fullScreenMode || is3D)
753 x -= rootWindow.absPosition.x;
754 y -= rootWindow.absPosition.y;
758 x += rootWindow.parent.clientStart.x;
759 y += rootWindow.parent.clientStart.y;
761 mox.left += rootWindow.parent.clientStart.x;
762 mox.top += rootWindow.parent.clientStart.y;
763 mox.right += rootWindow.parent.clientStart.x;
764 mox.bottom += rootWindow.parent.clientStart.y;
769 surface = display.GetSurface(x, y, mox);
772 surface.width = clientSize.w;
773 surface.height = clientSize.h;
779 // Setup a bitmap for Redrawing on full Window
780 Surface RedrawFull(Box box)
782 Surface surface = null;
790 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
792 int x = absPosition.x;
793 int y = absPosition.y;
794 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
796 x -= rootWindow.clientStart.x;
797 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
799 if(!guiApp.fullScreenMode || is3D)
801 x -= rootWindow.absPosition.x;
802 y -= rootWindow.absPosition.y;
805 x += rootWindow.parent.clientStart.x;
806 y += rootWindow.parent.clientStart.y;
808 mox.left += rootWindow.parent.clientStart.x;
809 mox.top += rootWindow.parent.clientStart.y;
810 mox.right += rootWindow.parent.clientStart.x;
811 mox.bottom += rootWindow.parent.clientStart.y;
816 surface = display.GetSurface(x, y, mox);
819 surface.width = size.w;
820 surface.height = size.h;
826 void FigureCaption(char * caption)
828 Window activeClient = null;
832 strcpy(caption, this.caption);
833 if(style.isDocument || fileName)
835 if(caption[0]) strcat(caption, " - ");
837 strcat(caption, fileName);
841 sprintf(title, "Untitled %d", documentID);
842 strcat(caption, title);
845 strcat(caption, " *");
850 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
852 if(activeClient && activeClient.state == maximized)
854 if(activeClient.caption)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, activeClient.caption);
859 if(activeClient.style.isDocument || activeClient.fileName)
861 if(caption[0]) strcat(caption, " - ");
862 strcat(caption, "[");
863 if(activeClient.fileName)
864 strcat(caption, activeClient.fileName);
868 sprintf(title, "Untitled %d", activeClient.documentID);
869 strcat(caption, title);
871 if(activeClient.modifiedDocument)
872 strcat(caption, " *");
873 strcat(caption, "]");
878 // Code for returning dirty from ScrollDisplay:
880 for(d = 0; d<scrollExtent.count; d++)
882 Box * box = &scrollExtent.boxes[d];
888 Min(box.right, box.left-scroll.x),box.bottom
890 dirtyArea.UnionBox(update);
896 Max(box.left, box.right-scroll.x), box.top,
897 box.right, box.bottom
899 dirtyArea.UnionBox(update);
907 box.right, Min(box.bottom, box.top-scroll.y),
909 dirtyArea.UnionBox(update);
915 box.left, Max(box.top, box.bottom-scroll.y),
916 box.right, box.bottom
918 dirtyArea.UnionBox(update);
923 void UpdateDecorations(void)
925 // TODO: *** TEMPORARY HACK ***
932 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
934 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
936 Update({ -clientStart.x,0, -1, clientSize.h-1 });
938 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
941 // Returns w & h for Position
942 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
944 Window parent = this.parent ? this.parent : guiApp.desktop;
945 int vpw = parent ? parent.clientSize.w : 0;
946 int vph = parent ? parent.clientSize.h : 0;
947 int pw = parent ? parent.clientSize.w : 0;
948 int ph = parent ? parent.clientSize.h : 0;
949 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
950 int x = anchor.left.distance, y = anchor.top.distance;
952 MinMaxValue ew = 0, eh = 0;
954 float cascadeW, cascadeH;
956 int tilingW, tilingH, tilingSplit, tilingLastH;
957 int addX = 0, addY = 0;
959 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
961 Window masterWindow = this;
962 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
965 if(master == guiApp.desktop)
966 masterWindow = guiApp.desktop.activeChild;
968 masterWindow = master.rootWindow;
969 if(!masterWindow) masterWindow = this;
971 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
972 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
975 pw = vpw = box.right - box.left + 1;
977 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
980 ph = vph = box.bottom - box.top + 1;
996 vpw = pw = parent.size.w;
997 vph = ph = parent.size.h;
999 else if(!style.fixed /*|| style.isDocument*/)
1001 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1002 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1004 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1007 Desktop3D_FixSize(&pw, &ph);
1008 Desktop3D_FixSize(&vpw, &vph);
1011 if(pw < skinMinSize.w) pw = skinMinSize.w;
1012 if(ph < skinMinSize.h) ph = skinMinSize.h;
1013 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1014 if(vph < skinMinSize.h) vph = skinMinSize.h;
1016 // TODO: Must fix what we're snapping
1019 if(anchor.left.type)
1021 SNAPUP(x, textCellW);
1023 else if(anchor.right.type)
1025 SNAPDOWN(x, textCellW);
1030 SNAPUP(y, textCellH);
1032 else if(anchor.bottom.type)
1034 SNAPDOWN(y, textCellH);
1038 // This is required to get proper initial decoration size using native decorations on Windows
1039 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1040 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1041 GetDecorationsSize(&ew, &eh);
1043 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1045 if(parent.sbv && !parent.sbv.style.hidden)
1046 pw += guiApp.currentSkin.VerticalSBW();
1047 if(parent.sbh && !parent.sbh.style.hidden)
1048 ph += guiApp.currentSkin.HorizontalSBH();
1050 if(anchor.left.type == cascade)
1052 w = (int)(pw * 0.80);
1053 h = (int)(ph * 0.80);
1055 else if(anchor.left.type >= vTiled)
1060 numTiling = parent.numPositions - parent.numIcons;
1061 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1062 if(anchor.left.type == vTiled)
1064 tilingH = (int)sqrt(numTiling);
1065 tilingW = numTiling / tilingH;
1069 tilingW = (int)sqrt(numTiling);
1070 tilingH = numTiling / tilingW;
1073 leftOver = numTiling - tilingH * tilingW;
1076 tilingSplit = (tilingW - leftOver) * tilingH;
1077 tilingLastH = tilingH+1;
1080 tilingSplit = numTiling;
1082 if(positionID >= tilingSplit)
1084 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1085 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1086 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1087 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1091 x = pw * (positionID / tilingH) / tilingW;
1092 y = ph * (positionID % tilingH) / tilingH;
1093 x2 = pw * (positionID / tilingH + 1) / tilingW;
1094 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1098 SNAPDOWN(x, textCellW);
1099 SNAPDOWN(y, textCellH);
1100 SNAPDOWN(x2, textCellW);
1101 SNAPDOWN(y2, textCellH);
1109 if(sizeAnchor.isClientW) w += ew;
1110 if(sizeAnchor.isClientH) h += eh;
1112 if(anchor.left.type == offset)
1113 x = anchor.left.distance;
1114 else if(anchor.left.type == relative)
1115 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1116 else if(anchor.right.type == relative)
1117 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1118 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1119 else if(anchor.right.type == offset)
1120 ex = vpw - anchor.right.distance;
1122 if(anchor.top.type == offset)
1123 y = anchor.top.distance;
1124 else if(anchor.top.type == relative)
1125 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1126 else if(anchor.bottom.type == relative)
1127 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1128 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1129 else if(anchor.bottom.type == offset)
1130 ey = vph - anchor.bottom.distance;
1132 if(anchor.left.type && anchor.right.type)
1134 switch(anchor.right.type)
1137 ex = pw * (1.0f-anchor.right.percent);
1138 w = Max((int)(ex + 0.5) - x, 0);
1141 ex = vpw - anchor.right.distance;
1142 w = Max((int)(ex + 0.5) - x, 0);
1146 if(anchor.top.type && anchor.bottom.type)
1148 switch(anchor.bottom.type)
1151 ey = ph * (1.0f-anchor.bottom.percent);
1152 h = Max((int)(ey + 0.5) - y, 0);
1155 ey = vph - anchor.bottom.distance;
1156 h = Max((int)(ey + 0.5) - y, 0);
1165 if(state == normal /*|| state == Hidden*/)
1167 bool addSbV = false, addSbH = false;
1169 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1170 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1172 w = Max(w, minSize.w);
1173 h = Max(h, minSize.h);
1174 w = Min(w, maxSize.w);
1175 h = Min(h, maxSize.h);
1177 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1179 if(w) w -= guiApp.currentSkin.VerticalSBW();
1182 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1184 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1188 if(!OnResizing(&w, &h))
1194 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1195 w += guiApp.currentSkin.VerticalSBW();
1196 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1197 h += guiApp.currentSkin.HorizontalSBH();
1199 w = Max(w, skinMinSize.w);
1200 h = Max(h, skinMinSize.h);
1213 SNAPDOWN(w, textCellW);
1214 SNAPDOWN(h, textCellH);
1217 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1219 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1222 (pw - w) / CASCADE_SPACE,
1223 (ph - h) / CASCADE_SPACE);
1229 cascW = (pw - w) / (numCascade-1);
1230 cascH = (ph - h) / (numCascade-1);
1231 SNAPDOWN(cascW, textCellW);
1232 SNAPDOWN(cascH, textCellH);
1233 cascadeW = (float)cascW;
1234 cascadeH = (float)cascH;
1238 numCascade = Max(numCascade, 2);
1239 cascadeW = (float)(pw - w) / (numCascade-1);
1240 cascadeH = (float)(ph - h) / (numCascade-1);
1243 x = (int)((positionID % numCascade) * cascadeW);
1244 y = (int)((positionID % numCascade) * cascadeH);
1246 else if(anchor.left.type < vTiled)
1248 if(!anchor.left.type || anchor.horz.type == middleRelative)
1250 if(!anchor.right.type)
1252 if(anchor.horz.type == middleRelative)
1253 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1255 x = vpw / 2 + anchor.horz.distance - w / 2;
1261 // case A_EDGE: x = x - w; break;
1263 if(!anchor.top.type || anchor.vert.type == middleRelative)
1265 if(!anchor.bottom.type)
1267 if(anchor.vert.type == middleRelative)
1268 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1270 y = vph / 2 + anchor.vert.distance - h / 2;
1276 // case A_EDGE: y = y - h; break;
1279 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1287 SNAPDOWN(x, textCellW);
1288 SNAPDOWN(y, textCellH);
1300 if(anchored && style.fixed && style.isActiveClient)
1305 void UpdateCaret(bool forceUpdate, bool erase)
1307 static Window lastWindow = null;
1308 static int caretX, caretY, caretSize;
1310 if(guiApp && guiApp.caretOwner == this)
1312 int x = caretPos.x - scroll.x;
1313 int y = caretPos.y - scroll.y;
1315 if((erase || this.caretSize) &&
1316 x >= clientArea.left && x <= clientArea.right &&
1317 y >= clientArea.top && y <= clientArea.bottom)
1321 guiApp.interfaceDriver.SetCaret(
1322 x + absPosition.x + clientStart.x,
1323 y + absPosition.y + clientStart.y, this.caretSize);
1324 guiApp.caretEnabled = true;
1326 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1330 if(lastWindow != this)
1332 updateBox.left = x + 1;
1334 updateBox.right = x + 2;
1335 updateBox.bottom = y + this.caretSize - 1;
1339 updateBox.left = Min(x + 1, caretX + 1);
1340 updateBox.top = Min(y, caretY);
1341 updateBox.right = Max(x + 2, caretX + 2);
1342 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1345 guiApp.caretOwner.Update(updateBox);
1352 caretSize = this.caretSize;
1358 guiApp.interfaceDriver.SetCaret(0,0,0);
1359 guiApp.caretEnabled = false;
1365 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1370 scrolledPos.x = position.x = x;
1371 scrolledPos.y = position.y = y;
1373 clientSize.w = size.w = w;
1374 clientSize.h = size.h = h;
1376 if(parent && !style.nonClient)
1378 //if(!style.fixed || style.isDocument)
1380 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1381 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1385 clientStart.x = clientStart.y = 0;
1387 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1389 //if(!activeClient || activeClient.state != maximized)
1390 if(!noAutoScrollArea)
1392 // Check if scroll area must be modified
1393 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1395 bool foundChild = false;
1397 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1398 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1399 for(child = children.first; child; child = child.next)
1401 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1402 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1404 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1405 w = Max(w, child.position.x + child.size.w);
1406 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1407 w = Max(w, Max(child.position.x, 0) + child.size.w);
1408 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1409 h = Max(h, child.position.y + child.size.h);
1410 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1411 h = Max(h, Max(child.position.y, 0) + child.size.h);
1416 if(foundChild && (w > cw || h > ch))
1418 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1420 int stepX = sbStep.x, stepY = sbStep.y;
1421 // Needed to make snapped down position match the skin's check of client area
1422 // against realvirtual
1425 SNAPDOWN(stepX, textCellW);
1426 SNAPDOWN(stepY, textCellH);
1427 stepX = Max(stepX, textCellW);
1428 stepY = Max(stepY, textCellH);
1430 if(scrollFlags.snapX)
1432 if(scrollFlags.snapY)
1435 reqScrollArea.w = w;
1436 reqScrollArea.h = h;
1439 else if(reqScrollArea.w || reqScrollArea.h)
1441 reqScrollArea.w = 0;
1442 reqScrollArea.h = 0;
1443 SetScrollPosition(0,0);
1448 // Automatic MDI Client Scrolling Area Adjustment
1449 if(parent && !parent.noAutoScrollArea)
1451 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1452 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1454 Window parent = this.parent;
1455 int w = parent.reqScrollArea.w;
1456 int h = parent.reqScrollArea.h;
1458 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1459 w = Max(w, position.x + size.w);
1460 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1461 w = Max(w, Max(position.x, 0) + size.w);
1462 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1463 h = Max(h, position.y + size.h);
1464 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1465 h = Max(h, Max(position.y, 0) + size.h);
1467 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1468 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1470 /*bool resize = false;
1471 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1472 // Needed to make snapped down position match the skin's check of client area
1473 // against realvirtual
1476 SNAPDOWN(stepX, textCellW);
1477 SNAPDOWN(stepY, textCellH);
1478 stepX = Max(stepX, textCellW);
1479 stepY = Max(stepY, textCellH);
1481 if(parent.scrollFlags.snapX)
1483 if(parent.scrollFlags.snapY)
1485 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1487 parent.reqScrollArea.w = w;
1488 parent.reqScrollArea.h = h;*/
1490 // parent.UpdateScrollBars(true, true);
1491 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1492 false, true, true, true, false, false);
1497 GetRidOfVirtualArea();
1501 UpdateScrollBars(modifyThisArea, false);
1502 else if(guiApp.currentSkin)
1505 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1507 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1508 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1509 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1510 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1513 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1514 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1516 absPosition = scrolledPos;
1517 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1518 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1520 if(this != guiApp.desktop && parent)
1522 absPosition.x += parent.absPosition.x;
1523 absPosition.y += parent.absPosition.y;
1524 if(!style.nonClient && this != guiApp.desktop)
1526 absPosition.x += parent.clientStart.x;
1527 absPosition.y += parent.clientStart.y;
1531 box = Box { 0, 0, size.w - 1, size.h - 1 };
1536 // Clip against parent's client area
1537 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1539 // Compute client area in this window coordinate system
1540 clientArea.left = 0;
1542 clientArea.right = clientSize.w - 1;
1543 clientArea.bottom = clientSize.h - 1;
1545 // Clip against parent's client area
1547 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1551 //absPosition.x -= parent.clientStart.x;
1552 //absPosition.y -= parent.clientStart.y;
1555 // Adjust all children
1556 for(child = children.first; child; child = child.next)
1557 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1559 UpdateCaret(false, false);
1562 void GetRidOfVirtualArea(void)
1564 if(parent && !parent.destroyed && style.fixed &&
1565 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1566 parent.reqScrollArea.w && parent.reqScrollArea.h)
1568 if(!parent.noAutoScrollArea)
1572 for(child = children.first; child; child = child.next)
1574 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1576 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1577 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1586 Window parent = this.parent;
1588 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1589 false, true, true, true, false, false);
1591 parent.SetScrollArea(0,0,true);
1592 parent.SetScrollPosition(0,0);
1598 public void ExternalPosition(int x, int y, int w, int h)
1600 Position(x, y, w, h, false, true, true, true, false, false);
1603 // (w, h): Full window size
1604 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1606 bool result = false;
1607 int oldCW = clientSize.w, oldCH = clientSize.h;
1608 bool clientResized, windowResized, windowMoved;
1610 bool realResized = size.w != w || size.h != h;
1612 // TOCHECK: This wasn't in ecere.dll
1613 //if(!parent) return true;
1614 if(destroyed) return false;
1616 windowMoved = position.x != x || position.y != y || force;
1618 // windowResized = realResized || force;
1619 windowResized = size.w != w || size.h != h || force;
1621 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1627 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1628 scrolledPos.x - parent.clientStart.x + this.box.right,
1629 scrolledPos.y - parent.clientStart.y + this.box.bottom
1635 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1640 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1642 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1643 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1644 windowResized = true;
1646 if(display && rootWindow != this)
1649 if(guiApp && guiApp.windowMoving)
1651 if(guiApp.windowMoving.style.nonClient)
1652 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1654 guiApp.windowMoving.parent.SetMouseRangeToClient();
1664 // Buttons bitmap resources crash if we do this while switching mode
1665 if(!guiApp || !guiApp.modeSwitching)
1668 // Process Anchored Children
1672 for(child = children.first; child; child = child.next)
1675 ((child.stateAnchor.left.type != offset ||
1676 child.stateAnchor.top.type != offset ||
1677 child.stateAnchor.right.type != none ||
1678 child.stateAnchor.bottom.type != none) ||
1679 child.state == maximized || child.state == minimized))
1681 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1683 // child.Position(x, y, w, h, false, true, true, true, false);
1684 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1685 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1691 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1692 //if(updateScrollBars)
1694 OnResize(clientSize.w, clientSize.h);
1696 if((clientResized || windowMoved) && created)
1697 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1699 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1701 Window master = guiApp.interimWindow.master;
1702 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1705 if(rootWindow == this && !is3D)
1709 x -= guiApp.desktop.absPosition.x;
1710 y -= guiApp.desktop.absPosition.y;
1712 //guiApp.Log("Position %s\n", caption);
1715 if(windowResized || windowMoved)
1716 if(display && !display.flags.memBackBuffer && changeRootWindow)
1717 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1719 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1720 for(child = parent.children.first; child && child != this; child = child.next)
1721 if(child.rootWindow)
1722 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1727 if(windowMoved || windowResized)
1729 display.Lock(true /*false*/);
1732 display.Position(absPosition.x, absPosition.y);
1733 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1736 // result = realResized ? display.Resize(size.w, size.h) : true;
1737 if(nativeDecorations && rootWindow.windowHandle)
1739 int w = clientSize.w, h = clientSize.h;
1740 if(hasMenuBar) h += skinMenuHeight;
1741 if(hasStatusBar) h += statusBarHeight;
1742 if(sbv && sbv.visible) w += sbv.size.w;
1743 if(sbh && sbh.visible) h += sbh.size.h;
1744 result = manageDisplay ? display.Resize(w, h) : true;
1747 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1751 else if(clientResized)
1753 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1756 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1760 if(windowMoved || windowResized)
1765 if(guiApp.driver && changeRootWindow && windowHandle)
1767 if(windowResized || windowMoved)
1768 if(!display || display.flags.memBackBuffer)
1769 guiApp.interfaceDriver.PositionRootWindow(this,
1770 x, y, w, h, windowMoved, windowResized);
1771 guiApp.interfaceDriver.UpdateRootWindow(this);
1773 for(child = children.first; child; child = child.next)
1775 if(child.is3D && child.created)
1777 // Copy Display Content
1778 child.display.displaySystem = display.displaySystem;
1779 child.display.window = display.window;
1780 child.display.current = display.current;
1781 child.display.width = display.width;
1782 child.display.height = display.height;
1783 child.display.driverData = display.driverData;
1784 child.display.mutex = null;
1795 void UpdateScrollBars(bool flag, bool fullThing)
1798 bool resizeH = false, resizeV = false;
1799 bool scrolled = false;
1800 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1801 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1803 if(destroyed) return;
1804 if(guiApp.currentSkin)
1806 MinMaxValue cw = 0, ch = 0;
1807 bool sbvVisible, sbhVisible;
1809 int positionH, positionV;
1811 // First get client area with no respect to scroll bars
1816 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1818 if(scrollFlags.dontHide)
1821 cw -= guiApp.currentSkin.VerticalSBW();
1823 ch -= guiApp.currentSkin.HorizontalSBH();
1825 // Update the scrollbar visibility
1831 sbh.disabled = rangeH <= 1;
1832 if(sbh.style.hidden)
1842 sbv.disabled = rangeV <= 1;
1843 if(sbv.style.hidden)
1851 int oldHRange = sbh ? sbh.range : 0;
1852 int oldVRange = sbv ? sbv.range : 0;
1853 // Then start off with horizontal scrollbar range
1856 positionH = sbh.thumbPosition;
1863 SBSetTotal(sbh, rvw);
1866 ch -= guiApp.currentSkin.HorizontalSBH();
1869 // Do the same for vertical scrollbar
1872 positionV = sbv.thumbPosition;
1878 SBSetTotal(sbv, rvh);
1882 cw -= guiApp.currentSkin.VerticalSBW();
1883 // Maybe we need to set the range on the horizontal scrollbar again
1891 SBSetTotal(sbh, rvw);
1892 //sbh.Action(setRange, positionH, 0);
1893 if(rangeH <= 1 && sbh.range > 1)
1895 ch -= guiApp.currentSkin.HorizontalSBH();
1901 SBSetTotal(sbv, rvh);
1903 //sbv.Action(setRange, positionV, 0);
1908 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1909 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1912 // Update the scrollbar visibility
1913 if(!scrollFlags.dontHide)
1915 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1919 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1926 if(guiApp.currentSkin)
1933 sbhVisible = sbh.style.hidden ? true : false;
1935 sbvVisible = sbv.style.hidden ? true : false;
1937 // Do our resize here
1938 if(flag && (resizeH || resizeV) && fullThing)
1940 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1945 OnResize(clientSize.w, clientSize.h);
1951 sbh.visible = sbhVisible;
1953 sbv.visible = sbvVisible;
1955 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1956 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1959 sbh.pageStep = clientSize.w;
1961 sbv.pageStep = clientSize.h;
1963 // Notify doesn't handle setRange anymore... process it here
1966 int positionH = sbh.thumbPosition;
1967 if(scroll.x != positionH)
1969 OnHScroll(setRange, positionH, 0);
1973 SNAPDOWN(positionH, textCellW);
1974 scroll.x = positionH;
1980 int seen = clientSize.w, total = reqScrollArea.w;
1983 if(scrollFlags.snapX)
1984 SNAPDOWN(seen, sbStep.x);
1986 if(!total) total = seen;
1987 range = total - seen + 1;
1989 range = Max(range, 1);
1991 if(x >= range) x = range - 1;
1993 if(scrollFlags.snapX)
1994 SNAPUP(x, sbStep.x);
1998 OnHScroll(setRange, x, 0);
2003 SNAPDOWN(x, textCellW);
2009 int positionV = sbv.thumbPosition;
2010 if(scroll.y != positionV)
2012 OnVScroll(setRange, positionV, 0);
2016 SNAPDOWN(positionV, textCellH);
2017 scroll.y = positionV;
2023 int seen = clientSize.h, total = reqScrollArea.h;
2026 if(scrollFlags.snapY)
2027 SNAPDOWN(seen, sbStep.y);
2029 if(!total) total = seen;
2030 range = total - seen + 1;
2031 range = Max(range, 1);
2033 if(y >= range) y = range - 1;
2035 if(scrollFlags.snapY)
2036 SNAPUP(y, sbStep.y);
2040 OnVScroll(setRange, y, 0);
2045 SNAPDOWN(y, textCellH);
2051 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2054 for(child = children.first; child; child = child.next)
2056 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2059 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2060 child.Position(x, y, w, h, false, true, false, true, false, false);
2067 // Process Scrollbars
2069 if(sbh) // && !sbh.style.hidden
2072 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2073 // Need to set the range again (should improve...) since the scrollbars didn't have
2074 // the right size when UpdateScrollArea set the range on it
2077 sbh.seen = clientSize.w;
2081 if(sbv) // && !sbv.state.hidden
2084 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2085 // Need to set the range again (should improve...) since the scrollbars didn't have
2086 // the right size when UpdateScrollArea set the range on it
2089 sbv.seen = clientSize.h;
2094 // TESTING THIS LOWER
2095 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2098 for(child = children.first; child; child = child.next)
2100 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2103 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2104 child.Position(x, y, w, h, false, true, false, true, false, false);
2110 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2112 SetState(maximized, false, mods);
2116 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2118 SetState(normal, false, mods);
2122 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2124 SetState(minimized, false, mods);
2125 parent.CycleChildren(false, true, false, true);
2129 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2132 // Scroll bar notifications
2133 if(action != setRange)
2135 bool changed = false;
2139 if(scroll.x != position)
2141 OnHScroll(action, position, keyFlags);
2146 SNAPDOWN(position, textCellW);
2148 scroll.x = position;
2152 if(scroll.y != position)
2154 OnVScroll(action, position, keyFlags);
2159 SNAPDOWN(position, textCellH);
2161 scroll.y = position;
2165 bool childMove = false;
2166 for(child = children.first; child; child = child.next)
2168 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2171 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2172 child.Position(x, y, w, h, false, true, false, true, false, false);
2176 // Testing this patch out to solve MDI workspace redraw bugs
2177 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2178 // Scroll offsets to blame?
2182 UpdateCaret(false, false);
2186 // Testing this patch out to solve MDI workspace redraw bugs
2187 for(child = children.first; child; child = child.next)
2189 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2198 Window GetParentMenuBar()
2200 Window menuBarParent;
2201 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2203 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2204 if(menuBarParent && !menuBarParent.isActiveClient)
2210 void CreateSystemChildren(void)
2212 Window parent = this;
2213 bool scrollBarChanged = false;
2214 bool hasClose = false, hasMaxMin = false;
2215 Point scroll = this.scroll;
2217 if(state == maximized)
2219 parent = GetParentMenuBar();
2220 if(!parent && nativeDecorations)
2221 parent = rootWindow;
2226 if(style.hasClose) hasClose = true;
2227 if(style.hasMaximize || style.hasMinimize)
2234 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2236 sysButtons[2].Destroy(0);
2237 sysButtons[2] = null;
2239 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2241 sysButtons[1].Destroy(0);
2242 sysButtons[1] = null;
2244 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2246 sysButtons[0].Destroy(0);
2247 sysButtons[0] = null;
2250 if(hasClose && parent)
2257 parent, master = this,
2258 inactive = true, nonClient = true, visible = false;
2260 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2266 if(this.parent == guiApp.desktop)
2267 sysButtons[2].hotKey = altF4;
2268 else if(style.isActiveClient)
2269 sysButtons[2].hotKey = ctrlF4;
2270 sysButtons[2].Create();
2273 sysButtons[2].symbol = 'X';
2274 sysButtons[2].disabled = !style.hasClose;
2277 if(hasMaxMin && parent)
2281 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2282 if(state == maximized)
2285 method = RestoreButtonClicked;
2291 method = MaximizeButtonClicked;
2299 parent, master = this,
2300 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2302 sysButtons[1].Create();
2304 sysButtons[1].NotifyClicked = method;
2306 sysButtons[1].symbol = symbol;
2307 sysButtons[1].disabled = !style.hasMaximize;
2310 if(hasMaxMin && parent)
2314 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2315 if (state == minimized)
2318 method = RestoreButtonClicked;
2324 method = MinimizeButtonClicked;
2332 parent, master = this,
2333 hotKey = altM, inactive = true, nonClient = true, visible = false
2335 sysButtons[0].Create();
2337 sysButtons[0].NotifyClicked = method;
2339 sysButtons[0].symbol = symbol;
2340 sysButtons[0].disabled = !style.hasMinimize;
2343 // Create the scrollbars
2344 if(style.hasHorzScroll && !sbh)
2350 direction = horizontal,
2354 snap = scrollFlags.snapX,
2355 NotifyScrolling = ScrollBarNotification
2358 scrollBarChanged = true;
2360 else if(sbh && !style.hasHorzScroll)
2366 if(style.hasVertScroll && !sbv)
2372 direction = vertical,
2376 snap = scrollFlags.snapY,
2377 NotifyScrolling = ScrollBarNotification
2380 scrollBarChanged = true;
2382 else if(sbv && !style.hasVertScroll)
2387 if(scrollBarChanged)
2389 SetScrollLineStep(sbStep.x, sbStep.y);
2390 UpdateScrollBars(true, true);
2394 if(scrollBarChanged)
2396 if(sbh) sbh.thumbPosition = scroll.x;
2397 if(sbv) sbv.thumbPosition = scroll.y;
2401 void UpdateCaption(void)
2403 if(rootWindow == this)
2406 FigureCaption(caption);
2407 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2409 UpdateDecorations();
2412 if(parent.activeClient == this) // Added this last check
2414 if(parent.rootWindow == parent)
2417 parent.FigureCaption(caption);
2418 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2421 parent.UpdateCaption();
2423 parent.UpdateDecorations();
2427 void UpdateActiveDocument(Window previous)
2429 Window activeClient = this.activeClient;
2430 Window activeChild = this.activeChild;
2437 activeClient.CreateSystemChildren();
2439 previous.CreateSystemChildren();
2451 // Build window list
2454 Menu windowMenu = menu.FindMenu("Window");
2459 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2462 Window document = cycle.data;
2463 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2465 char name[2048], caption[2048];
2466 document.FigureCaption(caption);
2467 sprintf(name, "%d %s", id+1, caption);
2468 windowMenu.AddDynamic(MenuItem
2470 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2471 NotifySelect = MenuWindowSelectWindow
2475 if(activeClient.cycle == cycle) break;
2480 if((!previous && activeClient) || !activeClient)
2486 item = menu.FindItem(MenuWindowCloseAll, 0);
2487 if(item) item.disabled = false;
2488 item = menu.FindItem(MenuWindowNext, 0);
2489 if(item) item.disabled = false;
2490 item = menu.FindItem(MenuWindowPrevious, 0);
2491 if(item) item.disabled = false;
2492 item = menu.FindItem(MenuWindowCascade, 0);
2493 if(item) item.disabled = false;
2494 item = menu.FindItem(MenuWindowTileHorz, 0);
2495 if(item) item.disabled = false;
2496 item = menu.FindItem(MenuWindowTileVert, 0);
2497 if(item) item.disabled = false;
2498 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2499 if(item) item.disabled = false;
2500 item = menu.FindItem(MenuWindowWindows, 0);
2501 if(item) item.disabled = false;
2504 item = menu.FindItem(MenuFileClose, 0);
2505 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2506 item = menu.FindItem(MenuFileSaveAll, 0);
2507 if(item) item.disabled = numDocuments < 1;
2509 if(activeClient && activeClient.menu && activeClient.state != minimized)
2513 //activeClient.menu.Clean(activeClient);
2514 menu.Merge(activeClient.menu, true, activeClient);
2518 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2521 menu.Merge(activeChild.menu, true, activeChild);
2524 // This is called again for a child window change, with same active client
2525 OnActivateClient(activeClient, previous);
2526 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2527 parent.UpdateActiveDocument(null);
2530 void _ShowDecorations(Box box, bool post)
2532 if(rootWindow == this && nativeDecorations) return;
2533 if(visible && this != guiApp.desktop)
2535 Surface surface = RedrawFull(box);
2539 FigureCaption(caption);
2542 ShowDecorations(captionFont.font,
2545 active, //parent.activeClient == this
2546 guiApp.windowMoving == this);
2548 PreShowDecorations(captionFont.font,
2551 active, //parent.activeClient == this
2552 guiApp.windowMoving == this);
2559 void UpdateExtent(Box refresh)
2561 Surface surface = null;
2563 if(!manageDisplay) { OnRedraw(null);return; }
2564 _ShowDecorations(refresh, false);
2566 surface = Redraw(refresh);
2567 // Opaque background: just fill before EW_REDRAW (clear?)
2570 surface.SetBackground(background);
2571 surface.SetForeground(foreground);
2572 surface.DrawingChar(' ');
2573 if(this == rootWindow)
2575 if(style.drawBehind || background.a)
2577 int a = background.a;
2578 // Premultiply alpha for clear color
2579 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2580 surface.Clear(colorBuffer);
2581 surface.SetBackground(background);
2584 else if(background.a)
2588 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2589 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2592 if(display.flags.alpha && background.a < 255 && background)
2594 surface.Area(0,0,clientSize.w, clientSize.h);
2595 /*if(style.clearDepthBuffer)
2596 surface.Clear(depthBuffer);*/
2598 else if(/*style.clearDepthBuffer || */background.a)
2600 int a = background.a;
2601 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2602 // Premultiply alpha for clear color
2603 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2604 surface.Clear(colorBuffer);
2605 surface.SetBackground(background);
2610 surface.TextFont(usedFont.font);
2611 surface.TextOpacity(false);
2615 // Draw the caret ...
2616 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2618 // surface.SetBackground(0xFFFFFF - background.color);
2619 surface.SetBackground(~background.color);
2621 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2622 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2628 void DrawOverChildren(Box refresh)
2630 Surface surface = Redraw(refresh);
2634 surface.DrawingChar(' ');
2635 surface.SetBackground(background);
2636 surface.SetForeground(foreground);
2638 surface.TextFont(usedFont.font);
2639 surface.TextOpacity(false);
2641 OnDrawOverChildren(surface);
2646 _ShowDecorations(refresh, true);
2649 void ComputeClipExtents(void)
2652 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2654 clipExtent.Copy(this.clipExtent);
2656 for(child = children.last; child; child = child.prev)
2658 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2660 bool opaque = child.IsOpaque(); // TODO: acess background directly
2661 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2663 child.clipExtent.Copy(clipExtent);
2664 child.clipExtent.Offset(-dx, -dy);
2665 child.clipExtent.IntersectBox(child.box);
2667 child.ComputeClipExtents();
2669 if(opaque && !child.style.nonClient)
2671 // Adjust the box for the parent:
2672 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2673 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2678 // ??? Only do this for overlapped window or if parent has with clip children flag
2680 // Do this if window has clip children flag on (default false?)
2681 // this.clipExtent = clipExtent;
2683 clipExtent.Free(null);
2686 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2688 bool opaque = IsOpaque();
2690 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2691 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2693 offsetX -= rootWindow.clientStart.x;
2694 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2698 for(child = children.last; child; child = child.prev)
2700 ColorAlpha background = *(ColorAlpha *)&child.background;
2701 bool opaque = child.IsOpaque();
2702 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2706 // Adjust renderArea to the root window level
2707 Extent * renderArea = &rootWindow.tempExtents[3];
2709 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2710 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2711 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2713 offsetX -= child.rootWindow.clientStart.x;
2714 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2718 Extent childRenderArea;
2720 if(backBufferUpdate != null)
2722 childRenderArea.Copy(backBufferUpdate);
2723 childRenderArea.Offset(-offsetX, -offsetY);
2726 childRenderArea.Copy(child.dirtyArea);
2728 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2729 renderArea.Copy(dirtyExtent);
2730 renderArea.Offset(-offsetX, -offsetY);
2731 childRenderArea.Union(renderArea);
2734 // Intersect with the clip extent
2735 childRenderArea.Intersection(child.clipExtent);
2738 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2740 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2741 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2743 renderArea->Offset(offsetX, offsetY);
2745 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2746 // overDirtyExtent.Union(renderArea);
2747 renderArea->Empty();
2748 // childRenderArea.Free();
2750 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2755 for(child = children.last; child; child = child.prev)
2757 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2759 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2764 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2766 bool opaque = IsOpaque();
2767 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2769 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2770 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2772 offsetX -= rootWindow.clientStart.x;
2773 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2777 for(child = children.last; child; child = child.prev)
2779 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2781 ColorAlpha background = *(ColorAlpha *)&child.background;
2782 bool opaque = child.IsOpaque();
2783 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2787 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2788 // Adjust renderArea to the root window level
2790 renderArea.Copy(child.dirtyArea);
2791 renderArea.Offset(offsetX, offsetY);
2792 dirtyExtent.Union(renderArea);
2793 overDirtyExtent.Union(renderArea);
2799 for(child = children.last; child; child = child.prev)
2801 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2803 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2807 if(backBufferUpdate != null)
2809 renderArea.Copy(backBufferUpdate);
2810 renderArea.Offset(-offsetX, -offsetY);
2812 overRenderArea.Copy(backBufferUpdate);
2813 overRenderArea.Offset(-offsetX, -offsetY);
2819 renderArea.Copy(dirtyArea);
2821 overRenderArea.Copy(dirtyArea);
2824 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2825 dirtyExtentWindow->Copy(dirtyExtent);
2826 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2827 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2828 dirtyExtentWindow->Empty();
2830 // Intersect with the clip extent
2831 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2834 if(renderArea.count > 10)
2837 printf("\nToo many extents (%d):\n", renderArea.count);
2839 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2840 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2845 for(c = 0; c<10; c++)
2848 FASTLIST_LOOP(renderArea, extentBox)
2850 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2852 renderArea.Copy(extent);
2854 FASTLIST_LOOP(renderArea, extentBox)
2857 printf("(%d, %d) - (%d, %d)\n",
2858 extentBox.box.left, extentBox.box.top,
2859 extentBox.box.right, extentBox.box.bottom);
2863 printf("\nNow %d\n", renderArea.count);
2869 // WHY WAS THIS COMMENTED ??
2871 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2872 dirtyExtentWindow->Copy(overDirtyExtent);
2873 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2874 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2875 dirtyExtentWindow->Empty();
2877 // Intersect with the clip extent
2878 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2884 if(scrollExtent.count)
2886 // Subtract render extent from scrolling extent
2887 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2889 if(backBufferUpdate == null)
2891 Extent * dirty = &rootWindow.tempExtents[3];
2894 // Intersect scrolling extent with clip extent
2895 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2897 // offset this scroll to be at the root window level
2898 scrollExtent.Offset(offsetX, offsetY);
2899 // Add area that was scrolled to the dirty extents of the back buffer
2900 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2904 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2905 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2906 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2911 scrollExtent.Empty();
2913 // Add the exposed extent to the window render area
2914 dirty->Offset(-offsetX, -offsetY);
2915 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2920 // Subtract the window's box from the transparency forced extent
2921 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2927 renderArea.Copy(this.renderArea);
2928 renderArea.Offset(offsetX, offsetY);
2929 dirtyExtent.Union(renderArea);
2935 Extent renderArea { };
2937 renderArea.Copy(overRenderArea);
2938 renderArea.Offset(offsetX, offsetY);
2939 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2944 if(backBufferUpdate != null)
2946 // Remove render area from dirty area
2947 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2949 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2956 // Remove the window render area from the dirty extents of the back buffer
2957 rootWindow.dirtyBack.Exclusion(renderArea);
2961 void Render(Extent updateExtent)
2965 Window rootWindow = this.rootWindow;
2966 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2967 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2969 offsetX -= rootWindow.clientStart.x;
2970 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2973 if(rootWindow.fullRender)
2982 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2983 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2988 /*if(renderArea.count)
2989 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2992 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2994 Box box = extentBox.box;
2997 /*printf("(%d, %d) - (%d, %d)\n",
2998 extentBox.box.left, extentBox.box.top,
2999 extentBox.box.right, extentBox.box.bottom);*/
3004 box.left += offsetX;
3006 box.right += offsetX;
3007 box.bottom += offsetY;
3009 if(updateExtent != null)
3010 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3014 for(child = children.first; child; child = child.next)
3015 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3016 child.Render(updateExtent);
3018 if(rootWindow.fullRender)
3019 DrawOverChildren(box);
3022 // TO DO: There's an issue about draw over children...
3023 // TO DO: Don't wanna go through this if method isn't used
3024 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3025 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3027 Box box = extentBox.box;
3029 DrawOverChildren(box);
3031 box.left += offsetX;
3033 box.right += offsetX;
3034 box.bottom += offsetY;
3036 if(updateExtent != null)
3037 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3040 for(child = children.first; child; child = child.next)
3041 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3042 child.Render(updateExtent);
3045 overRenderArea.Empty();
3048 public void UpdateDisplay(void)
3050 if(!manageDisplay) { OnRedraw(null);return; }
3051 if(rootWindow && this != rootWindow)
3052 rootWindow.UpdateDisplay();
3055 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3056 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3059 dirtyExtent.Clear();
3062 clipExtent.AddBox(box);
3064 display.StartUpdate();
3066 if(!rootWindow.fullRender)
3068 ComputeClipExtents();
3069 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3070 ComputeRenderArea(dirtyExtent, overExtent, null);
3073 clipExtent.Free(null);
3075 dirtyExtent.Free(null);
3076 overExtent.Free(null);
3078 if(display.flags.flipping)
3081 display.Update(null);
3085 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3086 updateExtent.Clear();
3088 Render(updateExtent);
3090 updateExtent.UnionBox(this.box, tempExtents[0]);
3093 //printf("\n\nUpdate:\n------------------------------------------\n");
3096 //FASTLIST_LOOP(updateExtent, extentBox)
3097 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3100 /*printf("Updating (%d, %d) - (%d, %d)\n",
3101 extentBox.box.left, extentBox.box.top,
3102 extentBox.box.right, extentBox.box.bottom);*/
3105 display.Update(extentBox.box);
3108 updateExtent.Free(null);
3111 display.EndUpdate();
3119 void UpdateBackDisplay(Box box)
3125 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3127 //printf("UpdateBackDisplay going through!\n");
3128 display.StartUpdate();
3132 intersection.Copy(dirtyBack);
3133 intersection.IntersectBox(box);
3135 dirtyExtent.Clear();
3138 clipExtent.AddBox(box);
3140 if(!rootWindow.fullRender)
3142 ComputeClipExtents();
3143 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3146 clipExtent.Free(null);
3148 intersection.Free(null);
3149 dirtyExtent.Free(null);
3150 overExtent.Free(null);
3155 if(display.flags.flipping)
3156 display.Update(null);
3159 rootWindow.display.Update(box);
3162 display.EndUpdate();
3166 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3167 if(dirtyBack.count > MAX_DIRTY_BACK)
3169 BoxItem extentBox, next;
3170 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3171 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3173 next = (BoxItem)extentBox.next;
3174 if(extentBox != first)
3176 if(extentBox.box.left < first.box.left)
3177 first.box.left = extentBox.box.left;
3178 if(extentBox.box.top < first.box.top)
3179 first.box.top = extentBox.box.top;
3180 if(extentBox.box.right > first.box.right)
3181 first.box.right = extentBox.box.right;
3182 if(extentBox.box.bottom > first.box.bottom)
3183 first.box.bottom = extentBox.box.bottom;
3184 dirtyBack.Delete(extentBox);
3193 // --- Window positioning ---
3194 // --- Window identification ---
3196 // Returns window at position "Position"
3197 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3199 Window child, result = null;
3201 box.left += absPosition.x;
3202 box.right += absPosition.x;
3203 box.top += absPosition.y;
3204 box.bottom += absPosition.y;
3206 if(!destroyed && visible && (acceptDisabled || !disabled))
3208 int lx = x - absPosition.x;
3209 int ly = y - absPosition.y;
3210 if(IsInside(lx, ly))
3211 // if(box.IsPointInside(Point{x, y}))
3213 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3214 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3217 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3218 Window ancestor = null;
3220 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3221 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3222 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3224 if(child != statusBar && child.rootWindow == rootWindow)
3226 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3233 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3234 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3236 if(child != statusBar && child.rootWindow == rootWindow)
3238 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3245 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3253 Window FindModal(void)
3255 Window modalWindow = this, check;
3256 Window check2 = null;
3257 for(check = this; check.master; check = check.master)
3259 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3261 modalWindow = check.master.modalSlave;
3262 check = modalWindow;
3264 // TESTING THIS FOR DROPBOX...
3265 if(!rootWindow || !rootWindow.style.interim)
3267 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3269 if(check2.modalSlave && check2.modalSlave.created)
3271 modalWindow = check2.modalSlave;
3279 if(modalWindow == this)
3281 for(check = this; check.activeChild; check = check.activeChild)
3283 if(check.modalSlave)
3285 modalWindow = check.modalSlave;
3291 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3292 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3295 void StopMoving(void)
3297 if(this == guiApp.windowMoving)
3299 guiApp.windowMoving = null;
3300 UpdateDecorations();
3301 SetMouseRange(null);
3304 if(rootWindow.active)
3305 guiApp.interfaceDriver.StopMoving(rootWindow);
3308 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3309 guiApp.windowIsResizing = false;
3313 void SelectMouseCursor(void)
3318 Window cursorWindow = null;
3319 bool rx, ry, rex, rey;
3321 guiApp.desktop.GetMousePosition(&x, &y);
3322 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3324 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3325 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3326 else if(mouseWindow)
3328 modalWindow = mouseWindow.FindModal();
3329 x -= mouseWindow.absPosition.x;
3330 y -= mouseWindow.absPosition.y;
3331 if(guiApp.windowIsResizing)
3333 rex = guiApp.resizeEndX;
3334 rey = guiApp.resizeEndY;
3335 rx = guiApp.resizeX;
3336 ry = guiApp.resizeY;
3337 if((rex && rey) || (rx && ry))
3338 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3339 else if((rex && ry) || (rx && rey))
3340 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3341 else if((ry || rey) && (!rx && !rex))
3342 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3343 else if((rx || rex) && (!ry && !rey))
3344 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3346 else if(!modalWindow && !guiApp.windowCaptured &&
3347 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3348 &rx, &ry, &rex, &rey))
3350 if((rex && rey) || (rx && ry))
3351 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3352 else if((rex && ry) || (rx && rey))
3353 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3354 else if((ry || rey) && (!rx && !rex))
3355 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3356 else if((rx || rex) && (!ry && !rey))
3357 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3359 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3361 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3362 cursorWindow = mouseWindow.parent;
3364 cursorWindow = mouseWindow;
3366 else if(!guiApp.interimWindow)
3367 cursorWindow = guiApp.windowCaptured;
3370 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3371 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3373 else if(modalWindow)
3375 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3377 else if(guiApp.interimWindow)
3379 if(guiApp.interimWindow.cursor)
3380 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3382 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3387 // --- State based input ---
3388 bool AcquireInputEx(bool state)
3393 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3394 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3396 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3398 guiApp.acquiredWindow = state ? this : null;
3401 SetMouseRangeToClient();
3402 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3407 SelectMouseCursor();
3409 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3413 // --- Window activation ---
3414 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3417 if(!parent || !parent.style.inactive)
3419 Window parent = this.parent;
3422 if(rootWindow == this)
3423 Log(active ? "active\n" : "inactive\n");
3426 // Testing this here...
3427 if(!parent || parent == guiApp.desktop || parent.active)
3429 this.active = active;
3432 // TESTING THIS HERE
3433 UpdateDecorations();
3434 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3435 result = NotifyActivate(master, this, active, previous);
3438 this.active = !active;
3443 if(!parent || parent == guiApp.desktop || parent.active)
3445 this.active = active;
3447 AcquireInputEx(active);
3452 if(guiApp.caretOwner)
3456 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3457 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3458 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3459 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3461 guiApp.caretOwner.Update(extent);
3464 if(visible || !guiApp.caretOwner)
3465 guiApp.caretOwner = this;
3466 UpdateCaret(false, false);
3472 this.active = false;
3474 AcquireInputEx(active);
3476 if(!active && guiApp.caretOwner == this)
3478 UpdateCaret(false, true);
3479 guiApp.caretOwner = null;
3480 guiApp.interfaceDriver.SetCaret(0,0,0);
3481 guiApp.caretEnabled = false;
3486 if(!active && parent && parent.activeChild && parent.activeChild != this)
3487 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3493 if(!active && menuBar)
3496 menuBar.OnActivate(false, null, &goOn, true);
3497 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3502 Window aChild = activeChild;
3504 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3516 void ConsequentialMouseMove(bool kbMoving)
3520 if(kbMoving || !guiApp.windowMoving)
3524 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3526 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3528 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3529 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3535 bool IsDescendantOf(Window ancestor)
3538 for(window = this; window && window != ancestor; window = window.parent);
3539 return window == ancestor;
3542 bool IsSlaveOf(Window master)
3545 for(window = this; window && window != master; window = window.master);
3546 return window == master;
3549 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3553 if(this && !destroyed /*&& state != Hidden*/)
3555 Window swap = externalSwap;
3563 if(activateParent &&
3564 (parent.activeChild != this ||
3565 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3566 active && _isModal &&
3567 parent != master && master)
3568 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3574 bool real = parent.activeChild != this;
3576 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3577 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3578 !IsDescendantOf(guiApp.interimWindow) &&
3579 !IsSlaveOf(guiApp.interimWindow))
3581 Window interimWindow = guiApp.interimWindow;
3582 while(interimWindow && interimWindow != this)
3584 Window master = interimWindow.master;
3586 guiApp.interimWindow = null;
3587 if(guiApp.caretOwner)
3588 guiApp.caretOwner.UpdateCaret(false, false);
3590 incref interimWindow;
3591 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3596 delete interimWindow;
3597 interimWindow = (master && master.style.interim) ? master : null;
3602 guiApp.interimWindow = this;
3603 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3604 guiApp.caretEnabled = false;*/
3605 UpdateCaret(false, true);
3610 bool acquireInput = false;
3612 parent.activeChild &&
3613 parent.activeChild.state == maximized &&
3614 parent != guiApp.desktop;
3616 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3621 swap = parent.activeChild;
3622 if(swap && swap.destroyed) swap = null;
3623 if(swap && swap != this)
3626 if(!swap.PropagateActive(false, this, &goOn, true))
3627 swap = parent.activeChild;
3638 if(!parent || parent.activeChild != this || style.interim)
3641 result = PropagateActive(true, swap, &goOn, true);
3642 if(!result && !goOn)
3647 acquireInput = true;
3651 if(style.hasMaximize && parent != guiApp.desktop)
3654 SetState(maximized, false, 0);
3655 else if(state != maximized)
3658 for(child = parent.children.first; child; child = child.next)
3660 if(this != child && child.state == maximized)
3661 child.SetState(normal, false, 0);
3668 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3670 Window previous = parent.activeClient;
3671 parent.activeChild = this;
3672 if(!style.nonClient /*&& style.isActiveClient*/)
3676 if(style.isActiveClient)
3677 parent.activeClient = this;
3678 // Moved UpdateActiveDocument inside hidden check
3679 // To prevent activating previous window while creating a new one
3680 // (It was messing up the privateModule in the CodeEditor)
3681 parent.UpdateActiveDocument(previous);
3687 //if(!style.isRemote)
3689 if(rootWindow != this)
3691 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3692 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3694 else if(!guiApp.fullScreenMode)
3696 Window modalRoot = FindModal();
3697 if(!modalRoot) modalRoot = this;
3698 if(!modalRoot.isForegroundWindow)
3700 modalRoot.isForegroundWindow = true;
3701 // To check : Why is parent null?
3702 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3704 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3706 modalRoot.isForegroundWindow = false;
3711 if(result && real && (!style.inactive || moveInactive) && parent)
3713 Window last = parent.children.last;
3715 if(!style.stayOnTop)
3716 for(; last && last.style.stayOnTop; last = last.prev);
3718 parent.children.Move(this, last);
3720 // Definitely don't want that: why not?
3724 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3730 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3737 parent.activeChild = null;
3738 if(!style.nonClient /*&& style.isActiveClient*/)
3740 Window previous = parent.activeClient;
3741 if(style.isActiveClient)
3742 parent.activeClient = null;
3743 parent.UpdateActiveDocument(previous);
3747 if(this == guiApp.interimWindow)
3749 guiApp.interimWindow = null;
3750 if(guiApp.caretOwner)
3751 guiApp.caretOwner.UpdateCaret(false, false);
3753 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3760 if(!active || !swap)
3761 UpdateDecorations();
3763 swap.UpdateDecorations();
3765 if(active && rootWindow != this)
3766 ConsequentialMouseMove(false);
3773 // --- Input Messages ---
3774 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3776 static bool reEntrancy = false;
3777 if(reEntrancy) return;
3781 guiApp.cursorUpdate = true;
3782 if(guiApp.windowScrolling && !consequential)
3784 guiApp.windowScrolling.SetScrollPosition(
3785 (guiApp.windowScrolling.sbh) ?
3786 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3787 (guiApp.windowScrolling.sbv) ?
3788 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3790 if(guiApp.windowMoving)
3792 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3794 Window window = guiApp.windowMoving;
3796 int w = window.size.w;
3797 int h = window.size.h;
3802 rx = mouseX - guiApp.windowMovingStart.x;
3803 ry = mouseY - guiApp.windowMovingStart.y;
3806 window.GetDecorationsSize(&ew, &eh);
3808 if(guiApp.windowIsResizing)
3810 x = window.scrolledPos.x;
3811 y = window.scrolledPos.y;
3815 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3816 rx = guiApp.windowResizingBefore.w - aw;
3817 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3818 w = guiApp.windowResizingBefore.w - rx;
3822 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3823 ry = guiApp.windowResizingBefore.h - ah;
3824 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3825 ry = Max(ry, -guiApp.windowMovingBefore.y);
3826 h = guiApp.windowResizingBefore.h - ry;
3828 if(guiApp.resizeEndX)
3830 w = guiApp.windowResizingBefore.w + rx;
3833 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3841 w = Max(w, window.minSize.w);
3842 h = Max(h, window.minSize.h);
3843 w = Min(w, window.maxSize.w);
3844 h = Min(h, window.maxSize.h);
3846 if(!window.OnResizing(&w, &h))
3848 w = window.clientSize.w;
3849 h = window.clientSize.h;
3852 w = Max(w, window.skinMinSize.w);
3853 h = Max(h, window.skinMinSize.h);
3860 SNAPDOWN(w, textCellW);
3861 SNAPDOWN(h, textCellH);
3866 aw = Max(w,window.skinMinSize.w);
3867 rx = guiApp.windowResizingBefore.w - aw;
3868 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3869 w = guiApp.windowResizingBefore.w - rx;
3873 ah = Max(h,window.skinMinSize.h);
3874 ry = guiApp.windowResizingBefore.h - ah;
3875 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3876 ry = Max(ry, -guiApp.windowMovingBefore.y);
3877 h = guiApp.windowResizingBefore.h - ry;
3882 if(!guiApp.windowIsResizing || guiApp.resizeX)
3883 x = guiApp.windowMovingBefore.x + rx;
3884 if(!guiApp.windowIsResizing || guiApp.resizeY)
3885 y = guiApp.windowMovingBefore.y + ry;
3887 if(!guiApp.windowIsResizing)
3890 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3892 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3893 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3894 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3895 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3899 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3900 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3906 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3908 if(!window.OnMoving(&x, &y, w, h))
3910 x = window.scrolledPos.x;
3911 y = window.scrolledPos.y;
3917 SNAPDOWN(x, textCellW);
3918 SNAPDOWN(y, textCellH);
3921 if(!window.style.nonClient)
3923 if(!window.style.fixed /*|| window.style.isDocument*/)
3925 if(!window.style.dontScrollHorz)
3926 x += window.parent.scroll.x;
3927 if(!window.style.dontScrollVert)
3928 y += window.parent.scroll.y;
3932 // Break the anchors for moveable/resizable windows
3933 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3934 if(window.style.fixed)
3936 if(window.state == normal)
3938 window.normalAnchor = Anchor { left = x, top = y };
3939 window.normalSizeAnchor = SizeAnchor { { w, h } };
3940 window.anchored = false;
3944 window.stateAnchor = Anchor { left = x, top = y };
3945 window.stateSizeAnchor = SizeAnchor { { w, h } };
3947 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3948 // TOCHECK: Investigate why the following only redraws the scrollbars
3949 //window.Position(x, y, w, h, false, true, true, true, false, true);
3951 guiApp.movingLast.x = mouseX;
3952 guiApp.movingLast.y = mouseY;
3958 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3961 bool wasMoving = guiApp.windowMoving ? true : false;
3962 bool wasScrolling = guiApp.windowScrolling ? true : false;
3964 while(result && w != this)
3966 Window msgWindow = GetAtPosition(x,y, false, true, w);
3967 Window trueWindow = GetAtPosition(x,y, false, false, w);
3968 bool windowDragged = false;
3973 window = (w && !w.disabled) ? w : null;
3975 if(trueWindow) incref trueWindow;
3977 if(consequential) mods->isSideEffect = true;
3979 UpdateMouseMove(x, y, consequential);
3981 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3983 if(!guiApp.windowCaptured.isEnabled)
3984 guiApp.windowCaptured.ReleaseCapture();
3986 window = guiApp.windowCaptured;
3989 if(trueWindow && 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 if(mods->alt && !mods->ctrl && !mods->shift)
3997 Window moved = trueWindow;
3998 for(moved = trueWindow; moved; moved = moved.parent)
3999 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4004 windowDragged = true;
4006 // Cancel the ALT menu toggling...
4007 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4012 if(window && activate &&
4013 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4014 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4015 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4016 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4018 Window modalWindow = window.FindModal();
4020 /*if(mods->alt && !mods->shift && !mods->ctrl)
4022 Window moved = window;
4023 for(moved = window; moved; moved = moved.parent)
4024 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4029 windowDragged = true;
4031 // Cancel the ALT menu toggling...
4032 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4038 Window activateWindow = modalWindow ? modalWindow : window;
4039 if(activateWindow && !activateWindow.isRemote)
4041 bool doActivation = true;
4042 //bool needToDoActivation = false;
4043 Window check = activateWindow;
4045 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4047 if(!check.style.inactive)
4049 //needToDoActivation = true;
4051 doActivation = false;
4056 if(!needToDoActivation)
4057 doActivation = false;
4060 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4061 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4063 // Let the OnLeftButtonDown do the activating instead
4064 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4072 incref activateWindow;
4073 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4075 delete activateWindow;
4079 if(activateWindow._refCount == 1)
4081 delete activateWindow;
4085 delete activateWindow;
4086 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4089 mods->isActivate = true;
4093 if(!modalWindow && window && !window.destroyed)
4095 if(!guiApp.windowCaptured || windowDragged)
4097 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4099 bool moving = ((window.state != maximized &&
4100 window.IsMouseMoving(
4101 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4102 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4104 if(!moving && window.IsMouseResizing(
4105 x - window.absPosition.x,
4106 y - window.absPosition.y,
4107 window.size.w, window.size.h,
4108 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4110 guiApp.windowIsResizing = true;
4111 guiApp.windowResizingBefore.w = window.size.w;
4112 guiApp.windowResizingBefore.h = window.size.h;
4114 if(guiApp.windowIsResizing || windowDragged || moving)
4117 guiApp.windowMoving = window;
4118 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4119 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4120 guiApp.windowMovingBefore.x = window.position.x;//s;
4121 guiApp.windowMovingBefore.y = window.position.y;//s;
4122 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4123 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4126 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4128 if(window.style.fixed &&
4130 window.IsMouseMoving(
4131 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4133 window.ShowSysMenu(x, y);
4137 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4139 if(window.sbv || window.sbh)
4142 guiApp.windowScrolling = window;
4143 guiApp.windowScrollingStart.x = x;
4144 guiApp.windowScrollingStart.y = y;
4145 guiApp.windowScrollingBefore.x = window.scroll.x;
4146 guiApp.windowScrollingBefore.y = window.scroll.y;
4149 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4151 if(window.style.hasMaximize &&
4152 window.IsMouseMoving(
4153 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4156 (window.state == maximized) ? normal : maximized, false, *mods);
4164 if(guiApp.windowMoving)
4166 if(guiApp.windowMoving.parent)
4168 if(guiApp.windowMoving.style.nonClient)
4169 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4171 guiApp.windowMoving.parent.SetMouseRangeToClient();
4175 window.UpdateDecorations();
4178 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4180 // Log("\n*** LEFT BUTTON UP ***\n");
4181 if(guiApp.windowMoving)
4182 guiApp.windowMoving.StopMoving();
4184 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4186 if(guiApp.windowScrolling)
4188 Window windowScrolling = guiApp.windowScrolling;
4189 guiApp.windowScrolling = null;
4190 windowScrolling.ReleaseCapture();
4194 if(!result || (window && window.destroyed)) window = null;
4196 if(window && window.FindModal())
4199 if(trueWindow && trueWindow.FindModal())
4207 msgWindow = GetAtPosition(x,y, true, false);
4209 msgWindow.SelectMouseCursor();
4212 if(guiApp.windowCaptured || trueWindow)
4214 Window prevWindow = guiApp.prevWindow;
4215 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4217 guiApp.prevWindow.mouseInside = false;
4218 guiApp.prevWindow = null;
4220 // Eventually fix this not to include captured?
4221 if(!prevWindow.OnMouseLeave(*mods))
4224 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4226 Box box = trueWindow.box;
4227 box.left += trueWindow.absPosition.x;
4228 box.right += trueWindow.absPosition.x;
4229 box.top += trueWindow.absPosition.y;
4230 box.bottom += trueWindow.absPosition.y;
4232 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4234 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4235 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4237 overX = Max(Min(overX, 32767),-32768);
4238 overY = Max(Min(overY, 32767),-32768);
4240 trueWindow.mouseInside = true;
4241 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4245 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4246 guiApp.prevWindow = trueWindow;
4248 guiApp.prevWindow = null;
4250 SelectMouseCursor();
4252 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4254 int clientX = x - (window.absPosition.x + window.clientStart.x);
4255 int clientY = y - (window.absPosition.y + window.clientStart.y);
4257 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4259 clientX = Max(Min(clientX, 32767),-32768);
4260 clientY = Max(Min(clientY, 32767),-32768);
4262 MouseMethod = (void *)window._vTbl[method];
4264 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4267 if(!MouseMethod(window, clientX, clientY, *mods))
4274 if(result && w && w.clickThrough && w.parent)
4279 if(!result || !w || !w.clickThrough)
4286 // --- Mouse cursor management ---
4288 bool KeyMessage(uint method, Key key, unichar character)
4293 if(guiApp.interimWindow)
4294 this = guiApp.interimWindow;
4297 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4301 if(!style.inactive || rootWindow != this)
4303 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4304 Window modalWindow = FindModal();
4305 Window interimMaster = master ? master.rootWindow : null;
4309 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4310 status = OnSysKeyDown(key, character);
4311 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4312 status = OnSysKeyHit(key, character);
4313 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4314 status = OnSysKeyUp(key, character);
4321 // Process Key Message for Internal UI Keyboard actions
4322 if(status && !destroyed && menuBar && state != minimized)
4325 if((SmartKey)key != alt)
4326 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4329 SmartKey sk = (SmartKey) key;
4330 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4332 status = menuBar.KeyMessage(method, key, character);
4337 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4338 menuBar.OnKeyHit(escape, 0);
4340 if(!menuBar.focus && guiApp.caretOwner)
4341 guiApp.caretOwner.UpdateCaret(true, false);
4344 if(!destroyed && status)
4346 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4350 case left: case up: case right: case down:
4351 if(guiApp.windowMoving == this)
4354 int w = guiApp.windowMoving.size.w;
4355 int h = guiApp.windowMoving.size.h;
4356 int x = guiApp.windowMoving.scrolledPos.x;
4357 int y = guiApp.windowMoving.scrolledPos.y;
4361 if(key == down || key == up)
4362 step = Max(step, textCellH);
4364 step = Max(step, textCellW);
4367 if(guiApp.windowIsResizing)
4371 case left: w-=step; break;
4372 case right: w+=step; break;
4373 case up: h-=step; break;
4374 case down: h+=step; break;
4381 case left: x-=step; break;
4382 case right: x+=step; break;
4383 case up: y-=step; break;
4384 case down: y+=step; break;
4388 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4389 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4391 if(!guiApp.windowIsResizing || guiApp.resizeX)
4392 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4394 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4396 if(!guiApp.windowIsResizing || guiApp.resizeY)
4397 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4399 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4401 guiApp.interfaceDriver.SetMousePosition(x, y);
4402 ConsequentialMouseMove(true);
4410 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4412 guiApp.windowMoving.StopMoving();
4413 ConsequentialMouseMove(false);
4421 ShowSysMenu(absPosition.x, absPosition.y);
4429 if(!destroyed && status && state != minimized)
4431 // Process all the way down the children
4432 if(activeChild && !activeChild.disabled)
4434 status = activeChild.KeyMessage(method, key, character);
4436 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4437 key.code != left && key.code != right && key.code != up && key.code != down)
4439 status = activeClient.KeyMessage(method, key, character);
4443 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4445 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4446 // && defaultControl != activeChild)
4448 delete previousActive;
4449 previousActive = activeChild;
4450 if(previousActive) incref previousActive;
4452 ConsequentialMouseMove(false);
4453 if((defaultControl.active ||
4454 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4455 defaultControl.KeyMessage(method, defaultKey, character);
4461 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4463 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4470 ShowSysMenu(absPosition.x, absPosition.y);
4477 if(this != guiApp.desktop)
4479 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4481 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4483 MenuMoveOrSize(key.shift, true);
4487 else if(guiApp.windowMoving)
4489 guiApp.windowMoving.StopMoving();
4490 ConsequentialMouseMove(false);
4498 if(!destroyed && status && state != minimized)
4500 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4504 case tab: case shiftTab:
4506 Window cycleParent = this;
4507 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4508 cycleParent = master.parent;
4510 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4512 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4514 Window child = cycleParent.activeChild;
4516 // Scroll the window to include the active control
4518 if(cycleParent.sbh && !child.style.dontScrollHorz)
4520 if(child.scrolledPos.x < 0)
4521 cycleParent.sbh.Action(Position,
4522 cycleParent.scroll.x + child.scrolledPos.x, 0);
4523 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4524 cycleParent.sbh.Action(Position,
4525 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4527 if(cycleParent.sbv && !child.style.dontScrollVert)
4529 if(child.scrolledPos.y < 0)
4530 cycleParent.sbv.Action(Position,
4531 cycleParent.scroll.y + child.scrolledPos.y, 0);
4532 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4533 cycleParent.sbv.Action(Position,
4534 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4537 cycleParent.ConsequentialMouseMove(false);
4543 case f6: case shiftF6:
4544 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4546 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4547 if(parent == guiApp.desktop)
4548 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4558 if(CycleChildren(key.shift, true, false, true))
4566 // mIRC Style Window Shortcuts
4567 case alt1: case alt2: case alt3: case alt4: case alt5:
4568 case alt6: case alt7: case alt8: case alt9: case alt0:
4573 for(document = children.first; document; document = document.next)
4575 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4577 if(document == activeChild)
4579 if(document.state == minimized)
4580 document.SetState(normal, false, key);
4583 document.SetState(minimized, false, key);
4584 CycleChildren(false, true, false);
4589 if(activeChild.state == maximized && document.style.hasMaximize)
4590 document.SetState(maximized, false, key);
4591 else if(document.state == minimized)
4592 document.SetState(normal, false, key);
4593 document.Activate();
4608 if(!destroyed && status)
4610 if(state == minimized)
4615 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4617 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4619 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4620 previousActive.ActivateEx(true, false, false, true, null, null);
4621 delete previousActive;
4627 if(!destroyed && status)
4629 status = ProcessHotKeys(method, key, character);
4631 if(!destroyed && status && !modalWindow && state != minimized)
4634 status = KeyMethod(this, key, character);
4635 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4636 status = OnKeyHit(key, character);
4637 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4639 bool result = false;
4642 case ctrlUp: case ctrlDown:
4643 if(sbv && !guiApp.windowScrolling)
4644 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4646 case wheelUp: case wheelDown:
4647 if(sbv && !guiApp.windowScrolling)
4649 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4650 // Do we want to do a consequential move regardless of result in this case?
4651 ConsequentialMouseMove(false);
4654 case ctrlPageUp: case ctrlPageDown:
4655 if(sbh && !guiApp.windowScrolling)
4656 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4661 ConsequentialMouseMove(false);
4666 if(status && !destroyed && menuBar && state != minimized)
4667 status = menuBar.KeyMessage(method, key, character);
4669 if(style.interim && /*destroyed && */status && interimMaster)
4671 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4672 status = interimMaster.KeyMessage(method, key, character);
4679 bool ProcessHotKeys(uint method, Key key, unichar character)
4684 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4685 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4686 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4688 Window hotKeyWindow = hotKey.window;
4689 Window parent = hotKeyWindow.parent;
4690 Window prevActiveWindow = activeChild;
4691 // For when sys buttons are placed inside the menu bar
4692 if(parent && parent._class == class(PopupMenu))
4693 parent = parent.parent;
4695 // 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
4696 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4699 if(prevActiveWindow) incref prevActiveWindow;
4700 incref hotKeyWindow;
4701 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4702 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4705 delete hotKeyWindow;
4706 delete prevActiveWindow;
4710 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4711 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4712 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4714 // ********* WORKING ON THIS ***********
4715 if(prevActiveWindow && !guiApp.interimWindow)
4716 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4719 else if(hotKeyWindow.style.inactive)
4720 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4722 delete prevActiveWindow;
4723 delete hotKeyWindow;
4724 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4725 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4729 if(status && tabCycle)
4732 for(child = children.first; child; child = child.next)
4734 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4745 // --- Windows and graphics initialization / termination ---
4746 bool SetupRoot(void)
4750 // Setup relationship with outside world (bb root || !bb)
4751 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4752 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4756 tempExtents = new0 Extent[4];
4761 /*if(guiApp.fullScreenMode)
4762 rootWindow = guiApp.desktop;
4764 //rootWindow = parent.created ? parent.rootWindow : null;
4765 rootWindow = parent.rootWindow;
4768 against = &parent.box;
4770 against = &parent.clientArea;
4773 for(child = children.first; child; child = child.next)
4776 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4779 bool Setup(bool positionChildren)
4781 bool result = false;
4784 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4786 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4787 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4789 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4791 // This was here, is it really needed?
4792 //guiApp.interfaceDriver.ActivateRootWindow(this);
4796 displaySystem = DisplaySystem {};
4797 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4799 delete displaySystem;
4804 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4805 if(display.Create(displaySystem, windowHandle))
4812 // Sometimes icon does not show up on Windows XP if we set here...
4813 // guiApp.interfaceDriver.SetIcon(this, icon);
4815 else if(this != guiApp.desktop)
4817 display = rootWindow ? rootWindow.display : null;
4823 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4824 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4826 for(child = children.first; child; child = child.next)
4828 if(child.created && !child.Setup(false))
4834 bool SetupDisplay(void)
4836 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4837 if(is3D) return Window3D_SetupDisplay(this); else
4844 class_data void ** pureVTbl;
4846 bool LoadGraphics(bool creation, bool resetAnchors)
4848 bool result = false;
4849 bool success = false;
4851 WindowState stateBackup = state;
4853 if(((subclass(Window))_class).pureVTbl)
4855 if(_vTbl == _class._vTbl)
4857 _vTbl = ((subclass(Window))_class).pureVTbl;
4862 for(m = 0; m < _class.vTblSize; m++)
4864 if(_vTbl[m] == _class._vTbl[m])
4865 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4869 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4871 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4873 _vTbl = _class._vTbl;
4878 for(m = 0; m < _class.vTblSize; m++)
4880 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4881 _vTbl[m] = _class._vTbl[m];
4886 if(guiApp.fullScreenMode || this != guiApp.desktop)
4888 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4894 display.Lock(false);
4895 if(rootWindow == this)
4897 // Set Color Palette
4898 display.SetPalette(palette, true);
4902 if(guiApp.fullScreenMode && this == guiApp.desktop)
4907 for(c=0; c<SystemCursor::enumSize; c++)
4908 if(!guiApp.systemCursors[c].bitmap)
4910 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4911 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4912 if(guiApp.systemCursors[c].bitmapName)
4914 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4915 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4916 if(guiApp.systemCursors[c].bitmap)
4917 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4922 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4924 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4925 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4927 cursor.bitmap.paletteShades = cursor.paletteShades;
4931 guiApp.cursorUpdate = true;
4934 ConsequentialMouseMove(false);
4940 // Load Window Graphic Resources
4943 if(usedFont == setFont || usedFont == window.systemFont)
4944 RemoveResource(usedFont);
4947 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4950 RemoveResource(systemFont);
4953 RemoveResource(captionFont);
4955 for(ptr = resources.first; ptr; ptr = ptr.next)
4957 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4960 AddResource(setFont);
4962 AddResource(systemFont);
4964 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4971 //if(master && master.font)
4972 if(parent && parent.font)
4976 faceName = parent.font.faceName,
4977 size = parent.font.size,
4978 bold = parent.font.bold,
4979 italic = parent.font.italic,
4980 underline = parent.font.underline
4982 //font = parent.font;
4983 watch(parent) { font { } };
4986 font = guiApp.currentSkin.SystemFont();
4993 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4994 AddResource(captionFont);
4996 if(OnLoadGraphics())
5002 //SetScrollLineStep(sbStep.x, sbStep.y);
5004 if(this != guiApp.desktop)
5008 normalAnchor = anchor;
5009 normalSizeAnchor = sizeAnchor;
5012 // Break the anchors for moveable/resizable windows
5014 if(style.fixed && style.isDocument)
5016 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5028 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5029 stateSizeAnchor = SizeAnchor {};
5034 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5039 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5040 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5043 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5047 stateAnchor = normalAnchor;
5048 stateSizeAnchor = normalSizeAnchor;
5051 position = Point { };
5052 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5063 if(Position(x, y, w, h, true, false, true, true, true, true))
5065 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5068 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5085 success = result = true;
5088 if(!creation && result)
5090 // Load menu bar first because sys buttons are on it...
5093 if(!menuBar.LoadGraphics(false, resetAnchors))
5099 for(child = children.first; child; child = child.next)
5101 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5108 CreateSystemChildren();
5112 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5115 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5120 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5121 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5124 // Do this here to avoid problems on Windows
5125 if(stateBackup == maximized)
5126 property::state = maximized;
5130 void UnloadGraphics(bool destroyWindows)
5134 // Free children's graphics
5135 for(child = children.first; child; child = child.next)
5136 child.UnloadGraphics(destroyWindows);
5139 display.Lock(false);
5142 if(guiApp.fullScreenMode && this == guiApp.desktop)
5147 for(c=0; c<SystemCursor::enumSize; c++)
5148 if(guiApp.systemCursors[c].bitmap)
5149 delete guiApp.systemCursors[c].bitmap;
5151 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5152 delete cursor.bitmap;
5154 guiApp.cursorBackground.Free();
5157 if(display && display.displaySystem)
5161 for(ptr = resources.first; ptr; ptr = ptr.next)
5165 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5170 // Free window graphics
5173 // Free skin graphics
5174 if(rootWindow == this)
5176 DisplaySystem displaySystem = display.displaySystem;
5179 display.driverData = null;
5180 display.displaySystem = null;
5184 if(displaySystem && !displaySystem.numDisplays && !is3D)
5185 delete displaySystem;
5194 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5195 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5197 if(this == guiApp.desktop || parent == guiApp.desktop)
5199 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5200 guiApp.interfaceDriver.DestroyRootWindow(this);
5204 // --- Window Hiding ---
5206 void SetVisibility(bool state)
5208 bool visible = (style.hidden || !created) ? false : state;
5209 if(visible != this.visible)
5213 this.visible = visible;
5214 for(child = children.first; child; child = child.next)
5215 child.SetVisibility(visible);
5217 ConsequentialMouseMove(false);
5218 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5222 // --- Windows and graphics initialization / termination ---
5224 bool DisplayModeChanged(void)
5226 bool result = false;
5227 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5229 guiApp.modeSwitching = true;
5230 UnloadGraphics(false);
5232 if(LoadGraphics(false, false))
5234 guiApp.modeSwitching = false;
5239 // --- Window updates system ---
5241 void UpdateDirty(Box updateBox)
5243 if(!manageDisplay) { OnRedraw(null);return; }
5246 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5249 if(display.flags.flipping)
5252 rootWindow.UpdateDisplay();
5255 UpdateBackDisplay(updateBox);
5257 if(guiApp.fullScreenMode)
5259 guiApp.cursorUpdate = true;
5260 guiApp.PreserveAndDrawCursor();
5262 if(guiApp.fullScreenMode)
5263 guiApp.RestoreCursorBackground();
5269 // This function is strictly called as a result of system window activation
5270 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5273 Window interimMaster = null;
5274 Window interimWindow = guiApp.interimWindow;
5275 if(interimWindow && interimWindow.master)
5276 interimMaster = interimWindow.master.rootWindow;
5278 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5279 // SetState(normal, false, 0);
5280 SetState(lastState, false, 0);
5282 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5286 /* WTH is this doing here?
5287 while(swap && swap.activeChild)
5289 swap = swap.activeChild;
5292 // TESTING THIS BEFORE...
5293 if(interimWindow && this == interimMaster)
5297 // Window interimSwap = this;
5298 Window menuBar = this.menuBar;
5299 if(menuBar && interimWindow.master == menuBar)
5302 while(interimSwap && interimSwap.activeChild)
5303 interimSwap = interimSwap.activeChild;
5305 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5306 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5308 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5309 //result = ActivateEx(true, true, false, activateRoot, window, null);
5314 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5315 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5317 if(interimWindow == this && interimMaster && !active)
5319 while(interimMaster && interimMaster.interim && interimMaster.master)
5321 // printf("Going up one master %s\n", interimMaster._class.name);
5322 interimMaster = interimMaster.master.rootWindow;
5324 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5325 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5331 bool DestroyEx(int64 returnCode)
5334 Timer timer, nextTimer;
5336 OldLink prevOrder = null;
5337 Window client = null;
5339 if(parent) stopwatching(parent, font);
5341 // if(window.modalSlave) return false;
5342 if(destroyed || !created)
5349 OldLink slave = master.slaves.FindLink(this);
5350 master.slaves.Delete(slave);
5353 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5359 this.returnCode = (DialogResult)returnCode;
5361 AcquireInput(false);
5366 master.hotKeys.Delete(hotKey);
5370 if(guiApp.prevWindow == this)
5372 guiApp.prevWindow = null;
5375 if(guiApp.caretOwner == this)
5377 guiApp.interfaceDriver.SetCaret(0,0,0);
5378 UpdateCaret(false, true);
5379 guiApp.caretEnabled = false;
5384 parent.childrenCycle.Remove(cycle);
5388 OldLink tmpPrev = order.prev;
5389 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5390 prevOrder = tmpPrev;
5393 client = tmpPrev ? tmpPrev.data : null;
5394 if(client == this) { client = null; break; }
5395 if(client && (client.style.hidden || client.destroyed || !client.created))
5396 tmpPrev = client.order.prev;
5400 prevOrder = tmpPrev;
5405 // If this window can be an active client, make sure the next window we activate can also be one
5406 if(!style.nonClient && style.isActiveClient)
5408 tmpPrev = prevOrder;
5411 client = tmpPrev ? tmpPrev.data : null;
5412 if(client == this) { client = null; break; }
5413 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5414 tmpPrev = client.order.prev;
5418 prevOrder = tmpPrev;
5422 if(client && client.style.hidden) client = null;
5424 // parent.childrenOrder.Remove(order);
5427 if(parent && style.isActiveClient && visible)
5429 if(state == minimized) parent.numIcons--;
5430 parent.numPositions--;
5433 // TESTING THIS HERE!
5437 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5438 // to create a window inside a rootwindow that's being destroyed)
5439 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5441 if(master && !master.destroyed /*&&
5442 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5444 if(master.defaultControl == this)
5445 master.defaultControl = null;
5448 parent.OnChildAddedOrRemoved(this, true);
5449 if(parent && !parent.destroyed /*&&
5450 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5452 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5454 if(order && prevOrder && prevOrder.data != this && active)
5456 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5458 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5459 if(parent.activeClient == this)
5461 parent.activeClient = null;
5462 parent.UpdateActiveDocument(null);
5467 if(guiApp.interimWindow == this)
5470 PropagateActive(false, null, &goOn, true);
5474 //if(window.parent.activeChild == window)
5475 parent.activeChild = null;
5476 if(!style.nonClient /*&& style.isActiveClient*/)
5478 Window previous = parent.activeClient;
5479 if(style.isActiveClient)
5480 parent.activeClient = null;
5481 parent.UpdateActiveDocument(previous);
5486 else if(parent.activeClient == this)
5488 parent.activeClient = client;
5489 parent.UpdateActiveDocument(this);
5493 if(guiApp.interimWindow == this)
5495 guiApp.interimWindow = null;
5496 if(guiApp.caretOwner)
5498 Window desktop = guiApp.desktop;
5499 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5500 guiApp.caretOwner.UpdateCaret(false, false);
5505 if(_isModal && master && master.modalSlave == this)
5506 master.modalSlave = null;
5510 if(!guiApp.caretOwner && parent.caretSize)
5512 guiApp.caretOwner = parent;
5513 parent.UpdateCaret(false, false);
5514 parent.Update(null);
5517 // Why was this commented out?
5518 GetRidOfVirtualArea();
5524 dirtyArea.Free(null);
5525 dirtyBack.Free(null);
5526 scrollExtent.Free(null);
5528 /* ATTEMPTING TO MOVE THAT ABOVE
5537 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5538 for(;(child = window.children.first);)
5540 for(; child && (child.destroyed || !child.created); child = child.next);
5549 UnloadGraphics(true);
5552 delete previousActive;
5555 // statusBar = null;
5558 if(master && !master.destroyed)
5560 //master.NotifyDestroyed(this, this.returnCode);
5561 NotifyDestroyed(master, this, this.returnCode);
5564 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5566 nextTimer = timer.next;
5567 if(timer.window == this)
5569 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5570 // timer.window = null;
5576 if(this == guiApp.windowMoving)
5579 if(guiApp.windowCaptured == this)
5581 //guiApp.windowCaptured = null;
5583 if(rootWindow != this && rootWindow)
5584 rootWindow.ConsequentialMouseMove(false);
5592 //for(child = children.first; next = child ? child.next : null, child; child = next)
5593 for(;(child = children.first); )
5595 for(; child && (child.destroyed || !child.created); child = child.next);
5605 /* // MOVED THIS UP...
5608 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5609 for(;(child = window.children.first); )
5611 for(; child && (child.destroyed || !child.created); child = child.next);
5620 while((slave = slaves.first))
5622 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5624 ((Window)slave.data).DestroyEx(0);
5629 if(guiApp.caretOwner == this)
5630 guiApp.caretOwner = null;
5632 sysButtons[0] = null;
5633 sysButtons[1] = null;
5634 sysButtons[2] = null;
5637 if(rootWindow != this)
5639 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5642 box.left -= parent.clientStart.x;
5643 box.top -= parent.clientStart.y;
5644 box.right -= parent.clientStart.x;
5645 box.bottom -= parent.clientStart.y;
5647 if(parent) parent.Update(box);
5652 OldLink slave = master.slaves.FindVoid(this);
5653 master.slaves.Delete(slave);
5659 parent.children.Remove(this);
5664 //autoCreate = false;
5667 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5668 if(((subclass(Window))_class).pureVTbl)
5670 if(_vTbl == _class._vTbl)
5672 _vTbl = ((subclass(Window))_class).pureVTbl;
5677 for(m = 0; m < _class.vTblSize; m++)
5679 if(_vTbl[m] == _class._vTbl[m])
5680 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5689 void SetStateEx(WindowState newState, bool activate)
5692 WindowState prevState = state;
5696 if(prevState != newState)
5697 lastState = prevState;
5699 if(rootWindow != this || !nativeDecorations || !windowHandle)
5701 if(style.isActiveClient && !style.hidden && prevState == minimized)
5704 // This block used to be at the end of the function... moved it for flicker problem in X
5705 // ------------------------------------------------------
5709 stateAnchor = normalAnchor;
5710 stateSizeAnchor = normalSizeAnchor;
5713 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5714 stateSizeAnchor = SizeAnchor {};
5718 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5721 byte * idBuffer = new0 byte[size];
5723 for(child = parent.children.first; child; child = child.next)
5725 if(child != this && child.state == minimized)
5727 if(child.iconID > size - 2)
5729 idBuffer = renew0 idBuffer byte[size*2];
5730 memset(idBuffer + size, 0, size);
5733 idBuffer[child.iconID] = (byte)bool::true;
5736 for(c = 0; c<size; c++)
5741 if(style.isActiveClient && !style.hidden)
5744 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5745 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5749 // TOCHECK: Why was this here?
5750 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5751 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5752 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5754 Position(x, y, w, h, true, true, true, true, false, true);
5756 if(!style.inactive && !style.interim && this == parent.activeClient)
5757 parent.UpdateActiveDocument(null);
5760 CreateSystemChildren();
5761 // ------------------------------------------------------
5764 int GetPositionID(Window forChild)
5768 byte * idBuffer = new0 byte[size];
5771 for(child = children.first; child; child = child.next)
5773 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5775 if(child.positionID > size - 2)
5777 idBuffer = renew0 idBuffer byte[size*2];
5778 memset(idBuffer + size, 0, size);
5781 idBuffer[child.positionID] = (byte)bool::true;
5784 for(c = 0; c<size; c++)
5791 // --- Window related graphics ---
5793 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5795 palette = newPalette;
5796 if(rootWindow.display)
5797 rootWindow.display.SetPalette(palette, colorMatch);
5800 public bool AcquireInput(bool acquired)
5803 if(acquiredInput != acquired)
5805 if(active || (!visible && creationActivation == activate))
5806 result = AcquireInputEx(acquired);
5811 acquiredInput = acquired ? result : !result;
5816 void ListChildren(ListBox listBox)
5820 for(child = children.first; child; child = child.next)
5822 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5824 DataRow row = listBox.AddRow();
5825 row.tag = (int64)child;
5826 child.FigureCaption(caption);
5827 row.SetData(null, caption);
5832 void UpdateVisual(Box extent)
5834 if(guiApp.driver != null)
5836 if(guiApp.fullScreenMode && guiApp.desktop.display)
5838 guiApp.desktop.mutex.Wait();
5839 guiApp.desktop.display.Lock(true);
5842 if(guiApp.desktop.active)
5844 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5846 if(guiApp.desktop.display.flags.flipping)
5847 guiApp.desktop.Update(null);
5848 guiApp.desktop.UpdateDisplay();
5849 guiApp.cursorUpdate = true;
5851 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5853 guiApp.PreserveAndDrawCursor();
5854 // guiApp.desktop.display.ShowScreen();
5855 guiApp.cursorUpdate = false;
5856 guiApp.desktop.dirty = false;
5857 guiApp.RestoreCursorBackground();
5861 guiApp.desktop.display.Unlock();
5862 guiApp.desktop.mutex.Release();
5866 Window rootWindow = this.rootWindow;
5867 rootWindow.mutex.Wait();
5872 guiApp.SignalEvent();
5875 guiApp.waitMutex.Wait();
5876 guiApp.interfaceDriver.Lock(rootWindow);
5877 if(!rootWindow.style.hidden && rootWindow.dirty)
5879 if(rootWindow.display)
5881 rootWindow.UpdateDisplay();
5882 //rootWindow.display.ShowScreen(null);
5884 rootWindow.dirty = false;
5886 guiApp.interfaceDriver.Unlock(rootWindow);
5887 guiApp.waitMutex.Release();
5890 rootWindow.mutex.Release();
5895 void UnlockDisplay(void)
5897 guiApp.interfaceDriver.Unlock(rootWindow);
5900 void LockDisplay(void)
5902 guiApp.interfaceDriver.Lock(rootWindow);
5905 Surface GetSurface(Box box)
5907 return Redraw((box == null) ? this.box : box);
5910 void SetMousePosition(int x, int y)
5912 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5916 void IntegrationActivate(bool active)
5918 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5920 isForegroundWindow = true;
5921 ActivateEx(active, active, false, false, null, null);
5922 isForegroundWindow = false;
5927 Window QueryCapture(void)
5929 return guiApp.windowCaptured;
5932 int GetDocumentID(void)
5936 byte * idBuffer = new0 byte[size];
5939 for(child = children.first; child; child = child.next)
5941 // TO CHECK: Do we want a documentID when we already have a file name?
5942 if(child.style.isDocument && !child.fileName)
5944 if(child.documentID-1 > size - 2)
5946 idBuffer = renew0 idBuffer byte[size*2];
5947 memset(idBuffer + size, 0, size);
5950 idBuffer[child.documentID-1] = 1;
5953 for(c = 0; c<size; c++)
5961 void SetInitSize(Size size)
5964 sizeAnchor.size = size;
5965 normalSizeAnchor = sizeAnchor;
5967 // Break the anchors for moveable/resizable windows
5968 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5970 stateAnchor = normalAnchor;
5971 stateSizeAnchor = normalSizeAnchor;
5973 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5974 Position(x,y, w, h, true, true, true, true, false, true);
5978 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5980 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5982 guiApp.windowIsResizing = resize;
5983 guiApp.windowMoving = this;
5984 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5985 if(guiApp.windowIsResizing)
5987 guiApp.windowMovingStart.x += size.w - 1;
5988 guiApp.windowMovingStart.y += size.h - 1;
5990 guiApp.windowMovingBefore = scrolledPos;
5991 guiApp.windowResizingBefore = size;
5992 guiApp.windowMoving.UpdateDecorations();
5993 if(guiApp.windowIsResizing)
5994 guiApp.resizeEndX = guiApp.resizeEndY = true;
5996 if(setCursorPosition)
5997 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
6001 guiApp.interfaceDriver.GetMousePosition(&x, &y);
6002 guiApp.windowMovingStart.x += x - absPosition.x;
6003 guiApp.windowMovingStart.y += y - absPosition.y;
6006 if(guiApp.windowMoving)
6008 if(guiApp.windowMoving.style.nonClient)
6009 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6011 guiApp.windowMoving.parent.SetMouseRangeToClient();
6016 if(this == rootWindow)
6017 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6025 bool result = false;
6029 else if(guiApp && guiApp.driver != null)
6031 void * systemParent = null;
6032 OldLink slaveHolder;
6034 bool visible = !style.hidden;
6038 systemParent = parent;
6039 parent = guiApp.desktop;
6041 last = parent ? parent.children.last : null;
6043 if((parent && parent != guiApp.desktop && !parent.created) ||
6044 (master && master != guiApp.desktop && !master.created))
6048 stopwatching(parent, font);
6051 property::parent = guiApp.desktop;
6052 if(!master) master = parent;
6054 if(_isModal && master.modalSlave)
6055 property::master = master.modalSlave;
6059 parent.children.Remove(this);
6062 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6063 if(slaveHolder.data == this)
6065 master.slaves.Delete(slaveHolder);
6070 if(parent == guiApp.desktop && !mutex)
6073 if(style.isDocument)
6076 parent.numDocuments--;
6077 documentID = parent.GetDocumentID();
6080 if(!style.stayOnTop)
6081 for(; last && last.style.stayOnTop; last = last.prev);
6083 parent.children.Insert((last == this) ? null : last, this);
6084 //parent.children.Add(this);
6087 dispDriver = parent.dispDriver;
6090 master.modalSlave = this;
6092 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6097 master.slaves.Add(slaveHolder = OldLink { data = this });
6102 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6104 if(style.isDefault && !master.defaultControl)
6105 master.defaultControl = this;
6107 stateAnchor = normalAnchor = anchor;
6108 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6110 // TOCHECK: Why is this here?
6111 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6112 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6114 this.visible = false;
6115 style.hidden = true;
6118 // autoCreate = true;
6126 if(parent == guiApp.desktop)
6127 Log("LoadGraphics %s\n", caption);
6129 if(LoadGraphics(true, false))
6137 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6144 if(style.hasMenuBar /*&& menu*/)
6150 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6151 interim = false, inactive = true, nonClient = true, size.h = 24
6159 // Create the system buttons
6160 CreateSystemChildren();
6162 UpdateActiveDocument(null);
6164 if(style.isDocument)
6168 MenuItem item = menu.FindItem(MenuFileSave, 0);
6169 if(item) item.disabled = !modifiedDocument && fileName;
6174 if(parent == guiApp.desktop)
6175 Log("Preemptive SetState %s\n", caption);
6178 // Preemptive Set State to ensure proper anchoring
6179 SetStateEx(state, false);
6181 style.hidden = true;
6187 for(child = children.first; child; child = next)
6190 if(!child.created && (child.autoCreate || child.wasCreated))
6197 for(link = slaves.first; link; link = next)
6199 Window slave = link.data;
6201 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6204 // Things might have happened that invalidated 'next'...
6205 // Start over the search for slaves to create.
6206 // (Added this to fix crash with Stacker & Toolbar)
6207 next = slaves.first;
6216 if(parent == guiApp.desktop)
6217 Log("Real SetState %s\n", caption);
6220 if(isActiveClient && visible)
6222 parent.numPositions--;
6223 if(state == minimized) parent.numIcons--;
6226 parent.OnChildAddedOrRemoved(this, false);
6228 // Real set state & activate for proper display & activation
6229 property::visible = visible;
6230 // SetState(state & 0x00000003, true, 0);
6231 guiApp.interfaceDriver.SetIcon(this, icon);
6236 /*if(rootWindow == this)
6237 guiApp.interfaceDriver.ActivateRootWindow(this);
6239 if(creationActivation == activate)
6240 ActivateEx(true, false, true, true, null, null);
6241 else if(creationActivation == flash)
6246 rootWindow.ConsequentialMouseMove(false);
6257 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6263 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6265 //style.hidden = true; // !visible;
6266 style.hidden = !visible;
6267 if(master.modalSlave == this)
6268 master.modalSlave = null;
6275 void WriteCaption(Surface surface, int x, int y)
6278 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6281 void Update(Box region)
6287 rootWindow = this.rootWindow;
6289 // rootWindow.mutex.Wait();
6290 if(!destroyed && visible && display)
6295 // Testing this to avoid repetitve full update to take time...
6296 if(dirtyArea.count == 1)
6298 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6299 if(item.box.left <= box.left &&
6300 item.box.top <= box.top &&
6301 item.box.right >= box.right &&
6302 item.box.bottom >= box.bottom)
6304 rootWindow.dirty = true;
6309 if(display.flags.flipping && !rootWindow.dirty)
6311 if(this == rootWindow)
6315 rootWindow.Update(null);
6320 rootWindow.dirty = true;
6325 realBox.left += clientStart.x;
6326 realBox.top += clientStart.y;
6327 realBox.right += clientStart.x;
6328 realBox.bottom += clientStart.y;
6334 if(realBox.right >= realBox.left &&
6335 realBox.bottom >= realBox.top)
6337 // if(!rootWindow.fullRender)
6338 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6340 for(child = children.first; child; child = child.next)
6345 box.left -= child.absPosition.x - absPosition.x;
6346 box.top -= child.absPosition.y - absPosition.y;
6347 box.right -= child.absPosition.x - absPosition.x;
6348 box.bottom -= child.absPosition.y - absPosition.y;
6349 if(box.right >= child.box.left && box.left <= child.box.right &&
6350 box.bottom >= child.box.top && box.top <= child.box.bottom)
6352 box.left -= child.clientStart.x;
6353 box.top -= child.clientStart.y;
6354 box.right -= child.clientStart.x;
6355 box.bottom -= child.clientStart.y;
6361 realBox.left += absPosition.x - rootWindow.absPosition.x;
6362 realBox.top += absPosition.y - rootWindow.absPosition.y;
6363 realBox.right += absPosition.x - rootWindow.absPosition.x;
6364 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6365 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6368 else if(this == guiApp.desktop)
6371 for(window = children.first; window; window = window.next)
6377 Box childBox = region;
6379 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6380 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6381 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6382 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6384 window.Update(childBox);
6387 window.Update(null);
6392 // rootWindow.mutex.Release();
6399 if(guiApp.windowCaptured != this)
6401 if(guiApp.windowCaptured)
6405 //Logf("Captured %s (%s)\n", caption, class.name);
6406 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6407 guiApp.windowCaptured = this;
6413 bool Destroy(int64 code)
6418 if(!destroyed && !CloseConfirmation(false)) return false;
6422 // TOCHECK: Should autoCreate be set to false here?
6433 void Move(int x, int y, int w, int h)
6435 normalAnchor = Anchor { left = x, top = y };
6436 normalSizeAnchor = SizeAnchor { size = { w, h } };
6438 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6440 if(destroyed) return;
6442 stateAnchor = normalAnchor;
6443 stateSizeAnchor = normalSizeAnchor;
6445 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6446 Position(x,y, w, h, true, true, true, true, false, true);
6450 DialogResult Modal(void)
6456 // FIXES MEMORY LEAK IF Create() FAILED
6462 void SetScrollArea(int width, int height, bool snapToStep)
6464 bool resize = false;
6467 int stepX = sbStep.x, stepY = sbStep.y;
6468 // Needed to make snapped down position match the skin's check of client area
6469 // against realvirtual
6472 SNAPDOWN(stepX, textCellW);
6473 SNAPDOWN(stepY, textCellH);
6474 stepX = Max(stepX, textCellW);
6475 stepY = Max(stepY, textCellH);
6477 if(scrollFlags.snapX)
6478 SNAPUP(width, stepX);
6479 if(scrollFlags.snapY)
6480 SNAPUP(height, stepY);
6483 reqScrollArea.w = width;
6484 reqScrollArea.h = height;
6485 noAutoScrollArea = (width > 0 || height > 0);
6487 UpdateScrollBars(true, true);
6490 void SetScrollPosition(int x, int y)
6493 sbh.Action(setPosition, x, 0);
6497 int seen = clientSize.w, total = reqScrollArea.w;
6499 if(scrollFlags.snapX)
6500 SNAPDOWN(seen, sbStep.x);
6502 if(!total) total = seen;
6503 range = total - seen + 1;
6504 range = Max(range, 1);
6506 if(x >= range) x = range - 1;
6508 if(scrollFlags.snapX)
6509 SNAPUP(x, sbStep.x);
6512 OnHScroll(setPosition, x, 0);
6516 SNAPDOWN(x, textCellW);
6522 sbv.Action(setPosition, y, 0);
6526 int seen = clientSize.h, total = reqScrollArea.h;
6529 if(scrollFlags.snapY)
6530 SNAPDOWN(seen, sbStep.y);
6532 if(!total) total = seen;
6533 range = total - seen + 1;
6534 range = Max(range, 1);
6536 if(y >= range) y = range - 1;
6538 if(scrollFlags.snapY)
6539 SNAPUP(y, sbStep.y);
6542 OnVScroll(setPosition, y, 0);
6545 SNAPDOWN(y, textCellH);
6550 UpdateCaret(false, false);
6553 void SetScrollLineStep(int stepX, int stepY)
6559 SNAPDOWN(stepX, textCellW);
6560 SNAPDOWN(stepY, textCellH);
6561 stepX = Max(stepX, textCellW);
6562 stepY = Max(stepY, textCellH);
6565 sbh.lineStep = stepX;
6567 sbv.lineStep = stepY;
6570 void SetState(WindowState newState, bool activate, Modifiers mods)
6574 if(state == newState || OnStateChange(newState, mods))
6576 WindowState prevState = state;
6580 // This used to be at the end of the brackets... moved for X, testing...
6581 // This has the effect of activating the window through the system...
6582 if(rootWindow == this)
6583 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6585 SetStateEx(newState, activate);
6587 if(rootWindow == this && !rootWindow.nativeDecorations)
6589 int x = position.x, y = position.y;
6592 x -= guiApp.desktop.absPosition.x;
6593 y -= guiApp.desktop.absPosition.y;
6595 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6599 //state = prevState;
6601 if(state != maximized && style.hasMaximize)
6604 for(child = parent.children.first; child; child = child.next)
6606 if(child != this && child.state == maximized)
6607 child.SetStateEx(normal, false);
6611 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6612 parent.UpdateScrollBars(true, true);
6615 // Do we really need this stuff here?
6616 // Shouldn't the Activate stuff take care of it?
6617 if(parent.rootWindow == parent && style)
6620 parent.FigureCaption(caption);
6621 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6622 parent.UpdateDecorations();
6626 rootWindow.ConsequentialMouseMove(false);
6633 BitmapResource GetIcon(SkinBitmap iconID)
6635 return guiApp.currentSkin.GetBitmap(iconID);
6638 void SetMouseRange(Box range)
6640 if(range || guiApp.fullScreenMode)
6645 clip.left = range.left + absPosition.x + clientStart.x;
6646 clip.top = range.top + absPosition.y + clientStart.y;
6647 clip.right = range.right + absPosition.x + clientStart.x;
6648 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6652 clip.left = guiApp.desktop.box.left;
6653 clip.top = guiApp.desktop.box.top;
6654 clip.right = guiApp.desktop.box.right;
6655 clip.bottom = guiApp.desktop.box.bottom;
6657 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6660 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6663 void SetMouseRangeToClient(void)
6665 if(guiApp.fullScreenMode || this != guiApp.desktop)
6667 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6668 box.Clip(clientArea);
6672 SetMouseRange(null);
6675 void SetMouseRangeToWindow(void)
6677 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6678 if(this == guiApp.desktop)
6679 SetMouseRangeToClient();
6684 // x, y: Desktop Coordinates
6685 void ShowSysMenu(int x, int y)
6688 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6691 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6692 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6696 menu, $"Move", m, NotifySelect = MenuWindowMove,
6697 disabled = !style.fixed || state == maximized
6701 menu, $"Size", s, NotifySelect = MenuWindowSize,
6702 disabled = !style.sizable || state != normal
6706 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6707 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6711 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6712 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6716 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6717 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6719 MenuDivider { menu };
6722 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6723 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6725 windowMenu.Create();
6730 ActivateEx(true, true, true, true, null, null);
6733 void MakeActive(void)
6735 ActivateEx(true, false, true, false, null, null);
6738 void SoftActivate(void)
6740 if(guiApp.desktop.active)
6746 void Deactivate(void)
6748 ActivateEx(false, true, true, true, null, null);
6753 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6756 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6758 bool result = false;
6759 if(activeChild && activeChild.cycle)
6761 Window modalWindow, child = activeChild;
6762 if(!clientOnly /*&& parent.tabCycle*/)
6764 Window next = child;
6767 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6771 if(parent && parent.CycleChildren(backward, false, true, true))
6779 next = next.cycle.prev.data;
6781 next = next.cycle.next.data;
6782 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6787 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6788 parent.tabCycle && parent.CycleChildren(backward, false, false))
6792 if(tabCycleOnly && !tabCycle) return false;
6799 child = child.cycle.prev.data;
6801 child = child.cycle.next.data;
6802 if(child == child.parent.activeChild)
6804 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6807 modalWindow = child.FindModal();
6810 // Scroll the window to include the active control
6811 if(sbh && !child.style.dontScrollHorz)
6813 if(child.scrolledPos.x < 0)
6814 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6815 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6816 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6818 if(sbv && !child.style.dontScrollVert)
6820 if(child.scrolledPos.y < 0)
6821 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6822 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6823 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6827 child = modalWindow ? modalWindow : child;
6828 child.ActivateEx(true, true, true, true, null, null);
6829 if(child.tabCycle && child.childrenCycle.first)
6830 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6838 ConsequentialMouseMove(false);
6842 void AddResource(Resource resource)
6846 ResPtr ptr { resource = resource };
6850 // Load Graphics here if window is created already
6851 if(/*created && */display)
6853 display.Lock(false);
6854 ptr.loaded = display.displaySystem.LoadResource(resource);
6858 // Temporary hack to load font right away for listbox in dropbox ...
6859 else if(master && master.display)
6861 master.display.Lock(false);
6862 master.display.displaySystem.LoadResource(resource);
6863 master.display.Unlock();
6869 void RemoveResource(Resource resource)
6874 for(ptr = resources.first; ptr; ptr = ptr.next)
6876 if(ptr.resource == resource)
6882 // Unload Graphics here if window is created already
6883 if(/*created && */display)
6887 display.Lock(false);
6888 display.displaySystem.UnloadResource(resource, ptr.loaded);
6894 resources.Delete(ptr);
6899 void SetCaret(int x, int y, int size)
6906 if(active && !style.interim)
6908 if(visible || !guiApp.caretOwner)
6909 guiApp.caretOwner = size ? this : null;
6911 UpdateCaret(false, false);
6914 guiApp.interfaceDriver.SetCaret(0,0,0);
6915 UpdateCaret(false, true);
6916 guiApp.caretEnabled = false;
6919 else if(style.inactive && active)
6921 guiApp.interfaceDriver.SetCaret(0,0,0);
6922 UpdateCaret(false, true);
6923 guiApp.caretEnabled = false;
6928 void Scroll(int x, int y)
6930 bool opaque = !style.drawBehind || background.a;
6931 if(opaque && display && display.flags.scrolling)
6933 Box box = clientArea;
6934 box.left += clientStart.x;
6935 box.top += clientStart.y;
6936 box.right += clientStart.x;
6937 box.bottom += clientStart.y;
6939 //scrollExtent.Free(null);
6940 scrollExtent.AddBox(box);
6941 scrolledArea.x += x;
6942 scrolledArea.y += y;
6944 //scrollExtent.Free();
6945 //scrollExtent.AddBox(clientArea);
6946 //scrollExtent.Offset(clientStart.x, clientStart.y);
6947 //scrolledArea.x = x;
6948 //scrolledArea.y = y;
6954 rootWindow.dirty = true;
6957 void ReleaseCapture()
6959 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6961 Window oldCaptured = guiApp.windowCaptured;
6962 guiApp.windowCaptured = null;
6963 guiApp.prevWindow = null;
6966 //guiApp.Log("Released Capture\n");
6968 guiApp.interfaceDriver.SetMouseCapture(null);
6970 //oldCaptured.OnMouseCaptureLost();
6973 oldCaptured.ConsequentialMouseMove(false);
6978 private void _SetCaption(char * format, va_list args)
6985 char caption[MAX_F_STRING];
6986 vsnprintf(caption, sizeof(caption), format, args);
6987 caption[sizeof(caption)-1] = 0;
6989 this.caption = CopyString(caption);
6994 firewatchers caption;
6998 /*deprecated*/ void SetText(char * format, ...)
7001 va_start(args, format);
7002 _SetCaption(format, args);
7006 void SetCaption(char * format, ...)
7009 va_start(args, format);
7010 _SetCaption(format, args);
7014 bool Grab(Bitmap bitmap, Box box, bool decorations)
7016 bool result = false;
7017 if(display || this == guiApp.desktop)
7019 Box clip = {MININT, MININT, MAXINT, MAXINT};
7025 clip.Clip(clientArea);
7027 clip.Clip(this.box);
7029 if(rootWindow != this)
7031 clip.left += absPosition.y;
7032 clip.top += absPosition.y;
7033 clip.right += absPosition.x;
7034 clip.bottom += absPosition.y;
7037 clip.left += decorations ? 0 : clientStart.x;
7038 clip.top += decorations ? 0 : clientStart.y;
7039 clip.right += decorations ? 0 : clientStart.x;
7040 clip.bottom += decorations ? 0 : clientStart.y;
7042 if(display && display.flags.flipping)
7044 rootWindow.Update(null);
7045 rootWindow.UpdateDisplay();
7052 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7053 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7057 result = display.Grab(bitmap, clip.left, clip.top,
7058 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7060 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7062 if(!bitmap.Convert(null, pixelFormat888, null))
7069 void GetMousePosition(int * x, int * y)
7071 int mouseX = 0, mouseY = 0;
7072 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7075 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7076 if(this != guiApp.desktop)
7078 mouseX -= absPosition.x + clientStart.x;
7079 mouseY -= absPosition.y + clientStart.y;
7086 DialogResult DoModal()
7088 DialogResult returnCode = 0;
7089 int terminated = terminateX;
7092 while(!destroyed && guiApp.driver != null)
7094 if(terminateX != terminated)
7096 terminated = terminateX;
7097 guiApp.desktop.Destroy(0);
7098 if(guiApp.desktop.created)
7101 //printf("Resetting terminate X to 0\n");
7107 guiApp.UpdateDisplay();
7108 if(!guiApp.ProcessInput(false))
7111 returnCode = this.returnCode;
7124 return !destroyed && guiApp.driver != null && terminateX < 2;
7127 DialogResult DoModalEnd()
7129 DialogResult returnCode = this.returnCode;
7134 // --- Window manipulation ---
7135 /*bool GetDisabled()
7137 bool disabled = this.disabled;
7139 for(window = this; (window = window.master); )
7150 // --- Mouse Manipulation ---
7151 void GetNCMousePosition(int * x, int * y)
7153 GetMousePosition(x, y);
7154 if(x) *x += clientStart.x;
7155 if(y) *y += clientStart.y;
7158 // --- Carets manipulation ---
7159 void GetCaretPosition(Point caretPos)
7161 caretPos = this.caretPos;
7164 int GetCaretSize(void)
7169 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7175 bool CloseConfirmation(bool parentClosing)
7188 if(!OnClose(parentClosing))
7191 // If you want to skip this, simply set modifiedDocument to false in OnClose
7192 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7194 DialogResult dialogRes;
7197 sprintf(message, $"Save changes to %s?", fileName);
7199 sprintf(message, $"Save changes to Untitled %d?", documentID);
7201 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7203 if(dialogRes == yes)
7205 // TOFIX: Precomp error if brackets are taken out
7206 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7208 else if(dialogRes == cancel)
7214 for(slave = slaves.first; slave; slave = slave.next)
7216 Window w = slave.data;
7217 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7219 // ((Window)slave.data).CloseConfirmation(true);
7228 for(child = children.first; child; child = child.next)
7229 if(child.master != this && !child.CloseConfirmation(true))
7239 // Static methods... move them somewhere else?
7240 void ::RestoreCaret()
7242 if(guiApp.caretOwner)
7243 guiApp.caretOwner.UpdateCaret(false, false);
7246 void ::FreeMouseRange()
7248 guiApp.interfaceDriver.SetMouseRange(null, null);
7252 bool MenuFileClose(MenuItem selection, Modifiers mods)
7254 Window document = activeChild;
7256 document.Destroy(0);
7260 bool MenuFileExit(MenuItem selection, Modifiers mods)
7266 bool MenuFileSave(MenuItem selection, Modifiers mods)
7270 fileMonitor.fileName = null;
7273 if(OnSaveFile(fileName))
7275 //if(OnFileModified != Window::OnFileModified)
7278 fileMonitor.fileName = fileName;
7284 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7285 DialogResult answer = dialog.Modal();
7287 if(answer != yes) return (bool)answer;
7290 return MenuFileSaveAs(selection, mods);
7293 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7295 DialogResult result = (DialogResult)bool::true;
7296 FileDialog fileDialog = saveDialog;
7299 fileDialog = FileDialog {};
7304 fileDialog.filePath = fileName;
7307 char filePath[MAX_FILENAME];
7308 sprintf(filePath, "Untitled %d", documentID);
7309 fileDialog.filePath = filePath;
7311 fileMonitor.fileName = null;
7313 fileDialog.type = save;
7314 fileDialog.text = $"Save As";
7318 fileDialog.master = master.parent ? master : this;
7319 if(fileDialog.Modal() == ok)
7321 char * filePath = fileDialog.filePath;
7323 if(OnSaveFile(filePath))
7326 property::fileName = filePath;
7327 NotifySaved(master, this, filePath);
7332 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7333 DialogResult answer = dialog.Modal();
7348 //if(OnFileModified != Window::OnFileModified && fileName)
7351 fileMonitor.fileName = fileName;
7355 return (bool)result; // Actually returning result from Yes/NoCancel message box
7358 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7360 Window document = activeChild;
7362 for(document = children.first; document; document = next)
7364 next = document.next;
7365 if(document.style.isDocument || document.fileName)
7366 document.MenuFileSave(selection, mods);
7371 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7375 for(document = children.first; document; document = document.next)
7376 //if(document.style.isDocument && document.state == minimized)
7377 if(document.style.isActiveClient && document.state == minimized)
7378 document.SetState(minimized, false, mods);
7382 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7384 Window document = activeChild;
7387 Window firstDocument = null;
7389 OldLink cycle = document.cycle.prev;
7394 if(child.style.isActiveClient && !child.style.hidden)
7398 firstDocument = child;
7399 if(child.state == minimized)
7400 child.SetState(minimized, false, mods);
7403 child.positionID = id++;
7404 child.SetState(normal, false, mods);
7405 child.anchor.left.type = cascade;
7408 child.normalSizeAnchor = *&child.sizeAnchor;
7409 child.normalAnchor = child.anchor;
7411 // Break the anchors for moveable/resizable windows
7412 if(child.style.fixed)
7414 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7416 (*&child.normalAnchor).left = x;
7417 (*&child.normalAnchor).top = y;
7418 (*&child.normalAnchor).right.type = none;
7419 (*&child.normalAnchor).bottom.type = none;
7421 child.normalSizeAnchor.isClientW = false;
7422 child.normalSizeAnchor.isClientH = false;
7423 child.normalSizeAnchor.size.w = w;
7424 child.normalSizeAnchor.size.h = h;
7425 child.anchored = false;
7428 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7430 child.stateAnchor = child.normalAnchor;
7431 child.stateSizeAnchor = child.normalSizeAnchor;
7433 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7434 child.Position(x, y, w, h, true, true, true, true, false, false);
7439 last = children.last;
7440 if(!child.style.stayOnTop)
7441 for(; last && last.style.stayOnTop; last = last.prev);
7442 children.Move(child, last);
7443 childrenOrder.Move(child.order, childrenOrder.last);
7445 if(cycle == document.cycle) break;
7449 firstDocument.Activate();
7454 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7461 // Close all closes all active clients, not all documents
7462 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7464 Window next, document;
7466 for(document = children.first; document; document = next)
7468 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7469 if(document.style.isActiveClient)
7470 if(!document.Destroy(0) && !document.style.hidden)
7476 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7478 if(style.hasMaximize && state != maximized)
7479 SetState(maximized, 0, 0);
7483 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7485 if(style.hasMinimize && state != minimized)
7487 SetState(minimized, 0, 0);
7488 parent.CycleChildren(false, true, false, true);
7493 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7495 MenuMoveOrSize(false, selection ? true : false);
7499 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7501 CycleChildren(false, true, false, true);
7505 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7507 CycleChildren(true, true, false, true);
7511 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7513 MenuMoveOrSize(true, true);
7517 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7520 SetState(normal, 0, 0);
7524 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7527 int64 id = selection.id;
7528 OldLink cycle = activeClient.cycle;
7530 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7533 Window sibling = cycle.data;
7534 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7542 document = cycle.data;
7543 document.Activate();
7545 //if(activeChild.state == maximized)
7546 // document.SetState(maximized, false, mods);
7547 //else if(document.state == minimized)
7548 // document.SetState(normal, false, mods);
7552 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7554 stayOnTop = !style.stayOnTop;
7558 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7560 Window document = activeChild;
7563 Window firstDocument = null;
7564 OldLink cycle = document.cycle;
7568 Window child = cycle.data;
7569 if(child.style.isActiveClient && !child.style.hidden)
7571 if(!firstDocument) firstDocument = child;
7572 if(child.state == minimized)
7573 child.SetState(minimized, false, mods);
7576 child.positionID = id++;
7577 child.SetState(normal, false, mods);
7578 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7580 child.anchor.left.type = hTiled;
7583 child.normalSizeAnchor = *&child.sizeAnchor;
7584 child.normalAnchor = child.anchor;
7586 // Break the anchors for moveable/resizable windows
7587 if(child.style.fixed)
7589 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7591 (*&child.normalAnchor).left = x;
7592 (*&child.normalAnchor).top = y;
7593 (*&child.normalAnchor).right.type = none;
7594 (*&child.normalAnchor).bottom.type = none;
7595 child.normalSizeAnchor.isClientW = false;
7596 child.normalSizeAnchor.isClientH = false;
7597 child.normalSizeAnchor.size.w = w;
7598 child.normalSizeAnchor.size.h = h;
7599 child.anchored = false;
7602 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7604 child.stateAnchor = child.normalAnchor;
7605 child.stateSizeAnchor = child.normalSizeAnchor;
7607 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7608 child.Position(x,y, w, h, true, true, true, true, false, true);
7613 if((cycle = cycle.next) == document.cycle) break;
7616 firstDocument.Activate();
7621 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7623 Window document = activeChild;
7626 Window firstDocument = null;
7628 OldLink cycle = document.cycle;
7633 //if(child.style.isDocument)
7634 if(child.style.isActiveClient && !child.style.hidden)
7636 if(!firstDocument) firstDocument = child;
7637 if(child.state == minimized)
7638 child.SetState(minimized, false, mods);
7641 child.positionID = id++;
7642 child.SetState(normal, false, mods);
7643 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7645 child.anchor.left.type = vTiled;
7648 child.normalSizeAnchor = *&child.sizeAnchor;
7649 child.normalAnchor = child.anchor;
7651 // Break the anchors for moveable/resizable windows
7652 if(child.style.fixed)
7654 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7656 (*&child.normalAnchor).left = x;
7657 (*&child.normalAnchor).top = y;
7658 (*&child.normalAnchor).right.type = none;
7659 (*&child.normalAnchor).bottom.type = none;
7660 child.normalSizeAnchor.isClientW = false;
7661 child.normalSizeAnchor.isClientH = false;
7662 child.normalSizeAnchor.size.w = w;
7663 child.normalSizeAnchor.size.h = h;
7664 child.anchored = false;
7667 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7669 child.stateAnchor = child.normalAnchor;
7670 child.stateSizeAnchor = child.normalSizeAnchor;
7672 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7673 child.Position(x,y, w, h, true, true, true, true, false, true);
7678 if((cycle = cycle.next) == document.cycle) break;
7681 firstDocument.Activate();
7686 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7688 WindowList dialog { master = this };
7689 Window document = (Window)dialog.Modal();
7692 if(activeChild.state == maximized)
7693 document.SetState(maximized, false, mods);
7694 else if(document.state == minimized)
7695 document.SetState(normal, false, mods);
7696 document.Activate();
7702 virtual bool OnCreate(void);
7703 virtual void OnDestroy(void);
7704 virtual void OnDestroyed(void);
7705 virtual bool OnClose(bool parentClosing);
7706 virtual bool OnStateChange(WindowState state, Modifiers mods);
7707 virtual bool OnPostCreate(void);
7708 virtual bool OnMoving(int *x, int *y, int w, int h);
7709 virtual bool OnResizing(int *width, int *height);
7710 virtual void OnResize(int width, int height);
7711 virtual void OnPosition(int x, int y, int width, int height);
7712 virtual bool OnLoadGraphics(void);
7713 virtual void OnApplyGraphics(void);
7714 virtual void OnUnloadGraphics(void);
7715 virtual void OnRedraw(Surface surface);
7716 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7717 virtual void OnActivateClient(Window client, Window previous);
7718 virtual bool OnKeyDown(Key key, unichar ch);
7719 virtual bool OnKeyUp(Key key, unichar ch);
7720 virtual bool OnKeyHit(Key key, unichar ch);
7721 virtual bool OnSysKeyDown(Key key, unichar ch);
7722 virtual bool OnSysKeyUp(Key key, unichar ch);
7723 virtual bool OnSysKeyHit(Key key, unichar ch);
7724 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7725 virtual bool OnMouseLeave(Modifiers mods);
7726 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7727 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7728 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7729 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7730 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7731 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7732 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7733 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7734 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7735 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7736 virtual void OnMouseCaptureLost(void);
7737 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7738 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7739 virtual void OnDrawOverChildren(Surface surface);
7740 virtual bool OnFileModified(FileChange fileChange, char * param);
7741 virtual bool OnSaveFile(char * fileName);
7743 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7744 // Note: A 'client' would refer to isActiveClient, rather than
7745 // being confined to the 'client area' (nonClient == false)
7746 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7747 virtual void OnChildVisibilityToggled(Window child, bool visible);
7748 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7750 // Skins Virtual Functions
7751 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7752 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7753 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7758 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7759 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7760 virtual bool IsMouseMoving(int x, int y, int w, int h)
7764 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7768 virtual void UpdateNonClient();
7769 virtual void SetBox(Box box);
7770 virtual bool IsInside(int x, int y)
7772 return box.IsPointInside({x, y});
7774 virtual bool IsOpaque()
7776 return (!style.drawBehind || background.a == 255);
7780 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7781 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7782 virtual void Window::NotifySaved(Window window, char * filePath);
7787 property Window parent
7789 property_category $"Layout"
7792 if(value || guiApp.desktop)
7795 Window oldParent = parent;
7796 Anchor anchor = this.anchor;
7798 if(value && value.IsDescendantOf(this)) return;
7799 if(value && value == this)
7801 if(!value) value = guiApp.desktop;
7803 if(value == oldParent) return;
7805 if(!master || (master == this.parent && master == guiApp.desktop))
7806 property::master = value;
7810 parent.children.Remove(this);
7814 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7815 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7816 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7817 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7821 last = value.children.last;
7823 if(style.isDocument)
7826 parent.numDocuments--;
7827 documentID = value.GetDocumentID();
7830 if(style.isActiveClient && !style.hidden)
7832 if(parent && parent != guiApp.desktop && !(style.hidden))
7834 if(state == minimized) parent.numIcons--;
7835 parent.numPositions--;
7839 if(!style.stayOnTop)
7840 for(; last && last.style.stayOnTop; last = last.prev);
7842 value.children.Insert(last, this);
7844 // *** NEW HERE: ***
7846 parent.childrenCycle.Delete(cycle);
7848 parent.childrenOrder.Delete(order);
7851 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7852 // Should something else be done?
7853 if(parent && parent.activeChild == this)
7854 parent.activeChild = null;
7855 if(parent && parent.activeClient == this)
7856 parent.activeClient = null;
7862 int x = position.x, y = position.y, w = size.w, h = size.h;
7866 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7867 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7869 vpw = value.clientSize.w;
7870 vph = value.clientSize.h;
7876 else if(style.fixed)
7878 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7879 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7882 anchor = this.anchor;
7884 if(anchor.left.type == offset) anchor.left.distance = x;
7885 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7886 if(anchor.top.type == offset) anchor.top.distance = y;
7887 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7888 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7889 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7890 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7891 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7892 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7893 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7895 if(!anchor.left.type && !anchor.right.type)
7897 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7898 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7900 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7901 if(!anchor.top.type && !anchor.bottom.type)
7903 anchor.vert.distance = (y + h / 2) - (vph / 2);
7904 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7906 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7909 parent.OnChildAddedOrRemoved(this, false);
7915 parent.childrenCycle.Insert(
7916 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7917 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7919 cycle = OldLink { data = this });
7920 parent.childrenOrder.Insert(
7921 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7922 order = OldLink { data = this });
7925 if(!style.hidden && style.isActiveClient)
7927 positionID = parent.GetPositionID(this);
7928 parent.numPositions++;
7929 if(state == minimized) parent.numIcons--;
7932 // *** FONT INHERITANCE ***
7933 if(!setFont && oldParent)
7934 stopwatching(oldParent, font);
7938 RemoveResource(systemFont);
7941 // TESTING WITH WATCHERS:
7942 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7943 // usedFont = setFont ? setFont : (systemFont);
7947 if(guiApp.currentSkin)
7949 systemFont = guiApp.currentSkin.SystemFont();
7952 usedFont = systemFont;
7953 AddResource(systemFont);
7961 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7970 if(value.rootWindow && value.rootWindow.display && rootWindow)
7972 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7973 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7976 UnloadGraphics(false);
7979 LoadGraphics(false, false);
7982 if(value.rootWindow != rootWindow)
7983 DisplayModeChanged();
7987 scrolledPos.x = MININT; // Prevent parent update
7989 bool anchored = this.anchored;
7990 property::anchor = anchor;
7991 this.anchored = anchored;
7996 if(guiApp.currentSkin)
7997 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7999 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8000 Position(x, y, w, h, true, true, true, true, false, true);
8005 // else parent = value;
8007 oldParent.OnChildAddedOrRemoved(this, true);
8010 get { return parent; }
8013 property Window master
8015 property_category $"Behavior"
8018 //if(this == value) return;
8019 if(value && value.IsSlaveOf(this)) return;
8025 OldLink slaveHolder;
8026 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8027 if(slaveHolder.data == this)
8029 master.slaves.Delete(slaveHolder);
8036 value.slaves.Add(OldLink { data = this });
8041 master.hotKeys.Remove(hotKey);
8042 value.hotKeys.Add(hotKey);
8045 if(master && master.defaultControl == this)
8046 master.defaultControl = null;
8048 if(style.isDefault && !value.defaultControl)
8049 value.defaultControl = this;
8054 get { return master ? master : parent; }
8057 property char * caption
8059 property_category $"Appearance"
8066 caption = new char[strlen(value)+1];
8068 strcpy(caption, value);
8073 get { return caption; }
8078 property_category $"Behavior"
8087 master.hotKeys.Add(hotKey = HotKeySlot { });
8091 hotKey.window = this;
8096 master.hotKeys.Delete(hotKey);
8101 get { return hotKey ? hotKey.key : 0; }
8104 property Color background
8106 property_category $"Appearance"
8109 background.color = value;
8114 if(this == rootWindow)
8115 guiApp.interfaceDriver.SetRootWindowColor(this);
8118 get { return background.color; }
8121 property Percentage opacity
8123 property_category $"Appearance"
8126 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8127 drawBehind = (background.a == 255) ? false : true;
8129 get { return background.a / 255.0f; }
8132 property Color foreground
8134 property_category $"Appearance"
8142 get { return foreground; }
8145 property BorderStyle borderStyle
8147 property_category $"Appearance"
8150 if(!((BorderBits)value).fixed)
8152 style.hasClose = false;
8153 style.hasMaximize = false;
8154 style.hasMinimize = false;
8155 nativeDecorations = false;
8157 style.borderBits = value;
8161 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8163 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8164 Position(x, y, w, h, true, true, true, true, false, true);
8165 CreateSystemChildren();
8168 get { return (BorderStyle)style.borderBits; }
8171 property Size minClientSize
8173 property_category $"Layout"
8174 set { minSize = value; }
8175 get { value = minSize; }
8178 property Size maxClientSize
8180 property_category $"Layout"
8181 set { maxSize = value; }
8182 get { value = maxSize; }
8185 property bool hasMaximize
8187 property_category $"Window Style"
8190 style.hasMaximize = value;
8191 if(value) { style.fixed = true; style.contour = true; }
8195 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8197 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8198 Position(x, y, w, h, true, true, true, true, false, true);
8200 CreateSystemChildren();
8203 get { return style.hasMaximize; }
8206 property bool hasMinimize
8208 property_category $"Window Style"
8211 style.hasMinimize = value;
8212 if(value) { style.fixed = true; style.contour = true; }
8216 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8218 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8219 Position(x, y, w, h, true, true, true, true, false, true);
8221 CreateSystemChildren();
8224 get { return style.hasMinimize; }
8227 property bool hasClose
8229 property_category $"Window Style"
8232 style.hasClose = value;
8233 if(value) { style.fixed = true; style.contour = true; }
8237 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8238 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8239 Position(x, y, w, h, true, true, true, true, false, true);
8240 CreateSystemChildren();
8243 get { return style.hasClose; }
8246 property bool nonClient
8248 property_category $"Layout"
8251 style.nonClient = value;
8253 style.stayOnTop = true;
8255 get { return style.nonClient; }
8258 property bool inactive
8260 property_category $"Behavior"
8265 // *** NEW HERE: ***
8269 parent.childrenCycle.Delete(cycle);
8271 parent.childrenOrder.Delete(order);
8278 active = false; // true;
8279 if(parent.activeChild == this)
8280 parent.activeChild = null;
8281 if(parent.activeClient == this)
8282 parent.activeClient = null;
8291 parent.childrenCycle.Insert(
8292 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8293 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8295 cycle = OldLink { data = this });
8297 parent.childrenOrder.Insert(
8298 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8299 order = OldLink { data = this });
8302 style.inactive = value;
8304 get { return style.inactive; }
8307 property bool clickThrough
8309 property_category $"Behavior"
8310 set { style.clickThrough = value; }
8311 get { return style.clickThrough; }
8314 property bool isRemote
8316 property_category $"Behavior"
8317 set { style.isRemote = value; }
8318 get { return style.isRemote; }
8321 property bool noCycle
8323 property_category $"Behavior"
8324 set { style.noCycle = value; }
8325 get { return style.noCycle; }
8328 property bool isModal
8330 property_category $"Behavior"
8331 set { style.modal = value; }
8332 get { return style.modal; }
8335 property bool interim
8337 property_category $"Behavior"
8338 set { style.interim = value; }
8339 get { return style.interim; }
8342 property bool tabCycle
8344 property_category $"Behavior"
8345 set { style.tabCycle = value; }
8346 get { return style.tabCycle; }
8349 property bool isDefault
8351 property_category $"Behavior"
8359 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8360 if(sibling != this && sibling.style.isDefault)
8361 sibling.style.isDefault = false;*/
8362 if(master.defaultControl)
8363 master.defaultControl.style.isDefault = false;
8364 master.defaultControl = this;
8366 else if(master.defaultControl == this)
8367 master.defaultControl = null;
8371 style.isDefault = value;
8373 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8375 get { return style.isDefault; }
8378 property bool drawBehind
8380 property_category $"Window Style"
8381 set { style.drawBehind = value; }
8382 get { return style.drawBehind; }
8385 property bool hasMenuBar
8387 property_category $"Window Style"
8397 if(created && !menuBar)
8404 anchor = Anchor { top = 23, left = 1, right = 1 },
8406 inactive = true, nonClient = true
8411 else if(created && menuBar)
8416 style.hasMenuBar = value;
8418 get { return style.hasMenuBar; }
8421 property bool hasStatusBar
8423 property_category $"Window Style"
8430 statusBar = StatusBar { this };
8438 style.hasStatusBar = value;
8440 get { return style.hasStatusBar; }
8442 property bool stayOnTop
8444 property_category $"Window Style"
8449 if(created && !style.stayOnTop)
8451 if(rootWindow == this)
8452 guiApp.interfaceDriver.OrderRootWindow(this, true);
8453 else if(parent.children.last != this)
8455 parent.children.Move(this, parent.children.last);
8459 style.stayOnTop = true;
8463 if(created && style.stayOnTop)
8465 if(rootWindow == this)
8466 guiApp.interfaceDriver.OrderRootWindow(this, false);
8473 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8474 order && ((Window)order.data).style.stayOnTop;
8475 order = (order == parent.childrenOrder.first) ? null : order.prev);
8476 last = order ? order.data : null;
8480 for(last = parent.children.last;
8481 last && last.style.stayOnTop;
8485 parent.children.Move(this, last);
8489 style.stayOnTop = false;
8492 get { return style.stayOnTop; }
8497 property_category $"Window Style"
8507 if(menuBar && !value)
8514 if(!menuBar && style.hasMenuBar && value)
8518 this, menu = value, isMenuBar = true,
8519 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8520 inactive = true, nonClient = true
8524 UpdateActiveDocument(null);
8527 get { return menu; }
8530 property FontResource font
8532 property_category $"Appearance"
8534 isset { return setFont ? true : false; }
8539 if(value && !setFont) { stopwatching(parent, font); }
8540 else if(!value && setFont)
8546 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8555 RemoveResource(setFont);
8560 RemoveResource(systemFont);
8567 AddResource(setFont);
8570 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8573 systemFont = guiApp.currentSkin.SystemFont();
8575 usedFont = systemFont;
8576 AddResource(systemFont);
8584 get { return usedFont; }
8587 property SizeAnchor sizeAnchor
8589 property_category $"Layout"
8592 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8593 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8594 sizeAnchor.isClientW != sizeAnchor.isClientH;
8601 normalSizeAnchor = sizeAnchor;
8603 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8605 stateAnchor = normalAnchor;
8606 stateSizeAnchor = normalSizeAnchor;
8608 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8609 Position(x,y, w, h, true, true, true, true, false, true);
8616 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8617 sizeAnchor.isClientW,
8618 sizeAnchor.isClientH
8625 property_category $"Layout"
8628 Anchor thisAnchor = anchor;
8629 SizeAnchor thisSizeAnchor = sizeAnchor;
8630 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8631 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8632 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8633 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8634 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8635 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8641 sizeAnchor.isClientW = false;
8642 sizeAnchor.isClientH = false;
8643 sizeAnchor.size = value;
8645 normalSizeAnchor = sizeAnchor;
8647 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8649 stateAnchor = normalAnchor;
8650 stateSizeAnchor = normalSizeAnchor;
8652 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8653 Position(x, y, w, h, true, true, true, true, false, true);
8654 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8657 get { value = size; }
8660 property Size clientSize
8662 property_category $"Layout"
8665 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8666 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8667 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8672 sizeAnchor.isClientW = true;
8673 sizeAnchor.isClientH = true;
8674 sizeAnchor.size = value;
8676 normalSizeAnchor = sizeAnchor;
8678 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8680 stateAnchor = normalAnchor;
8681 stateSizeAnchor = normalSizeAnchor;
8683 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8684 Position(x,y, w, h, true, true, true, true, false, true);
8687 get { value = clientSize; }
8690 property Size initSize { get { value = sizeAnchor.size; } };
8692 property Anchor anchor
8694 property_category $"Layout"
8695 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8701 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8703 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8704 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8706 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8708 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8709 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8713 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8715 anchor.left.distance = 0;
8716 anchor.horz.type = 0;
8718 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8720 anchor.top.distance = 0;
8721 anchor.vert.type = 0;
8730 normalAnchor = anchor;
8732 // Break the anchors for moveable/resizable windows
8733 /*if(style.fixed ) //&& value.left.type == cascade)
8735 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8737 this.anchor = normalAnchor = Anchor { left = x, top = y };
8738 normalSizeAnchor = SizeAnchor { { w, h } };
8741 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8743 stateAnchor = normalAnchor;
8744 stateSizeAnchor = normalSizeAnchor;
8746 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8747 Position(x, y, w, h, true, true, true, true, false, true);
8756 get { value = this ? anchor : Anchor { }; }
8759 property Point position
8761 property_category $"Layout"
8764 if(value == null) return;
8766 anchor.left = value.x;
8767 anchor.top = value.y;
8768 anchor.right.type = none;
8769 anchor.bottom.type = none;
8774 normalAnchor = anchor;
8776 // Break the anchors for moveable/resizable windows
8780 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8782 normalAnchor.left = x;
8783 normalAnchor.top = y;
8784 normalAnchor.right.type = none;
8785 normalAnchor.bottom.type = none;
8786 normalSizeAnchor.size.width = w;
8787 normalSizeAnchor.size.height = h;
8791 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8793 stateAnchor = normalAnchor;
8794 stateSizeAnchor = normalSizeAnchor;
8796 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8797 Position(x,y, w, h, true, true, true, true, false, true);
8801 get { value = position; }
8804 property bool disabled
8806 property_category $"Behavior"
8809 if(this && disabled != value)
8816 get { return (bool)disabled; }
8819 property bool isEnabled
8824 for(parent = this; parent; parent = parent.parent)
8831 property WindowState state
8833 property_category $"Behavior"
8834 set { SetState(value, false, 0); }
8835 get { return this ? state : 0; }
8838 property bool visible
8840 property_category $"Behavior"
8843 if(this && !value && !style.hidden && parent)
8845 bool wasActiveChild = parent.activeChild == this;
8846 Window client = null;
8848 style.hidden = true;
8849 if(style.isActiveClient)
8851 parent.numPositions--;
8852 if(state == minimized) parent.numIcons--;
8857 OldLink prevOrder = null;
8859 if(rootWindow == this)
8860 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8863 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8866 box.left -= parent.clientStart.x;
8867 box.top -= parent.clientStart.y;
8868 box.right -= parent.clientStart.x;
8869 box.bottom -= parent.clientStart.y;
8873 if(_isModal && master && master.modalSlave == this)
8874 master.modalSlave = null;
8878 OldLink tmpPrev = order.prev;
8879 client = tmpPrev ? tmpPrev.data : null;
8880 if(client && !client.style.hidden && !client.destroyed && client.created)
8881 prevOrder = tmpPrev;
8884 client = tmpPrev ? tmpPrev.data : null;
8885 if(client == this) { client = null; break; }
8886 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8888 tmpPrev = client.order.prev;
8893 prevOrder = tmpPrev;
8898 // If this window can be an active client, make sure the next window we activate can also be one
8899 if(!style.nonClient && style.isActiveClient)
8901 tmpPrev = prevOrder;
8904 client = tmpPrev ? tmpPrev.data : null;
8905 if(client == this) { client = null; break; }
8906 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8908 tmpPrev = client.order.prev;
8913 prevOrder = tmpPrev;
8917 if(client && client.style.hidden) client = null;
8921 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8923 if(order && prevOrder && prevOrder.data != this)
8924 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8926 ActivateEx(false, false, false, true, null, null);
8928 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8929 if(parent.activeClient == this)
8931 parent.activeClient = null;
8932 parent.UpdateActiveDocument(null);
8935 else if(parent.activeClient == this)
8937 parent.activeClient = client;
8938 parent.UpdateActiveDocument(this);
8941 // *** Not doing this anymore ***
8944 parent.childrenCycle.Delete(cycle);
8946 parent.childrenOrder.Delete(order);
8951 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8956 else if(this && value && style.hidden)
8958 style.hidden = false;
8961 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8962 if(rootWindow == this)
8963 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8965 if(_isModal && master)
8966 master.modalSlave = this;
8968 if(style.isActiveClient)
8970 positionID = parent.GetPositionID(this);
8971 parent.numPositions++;
8972 if(state == minimized) parent.numIcons++;
8975 // *** NOT DOING THIS ANYMORE ***
8977 if(!(style.inactive))
8979 if(!(style.noCycle))
8981 cycle = parent.childrenCycle.AddAfter(
8982 (parent.activeChild && parent.activeChild.cycle) ?
8983 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8986 order = parent.childrenOrder.AddAfter(
8987 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8994 if(true || !parent.activeChild)
8995 ActivateEx(true, false, true, true, null, null);
8997 if(creationActivation == activate)
8998 ActivateEx(true, false, true, true, null, null);
8999 else if(creationActivation == flash && !object)
9002 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9006 ConsequentialMouseMove(false);
9012 style.hidden = !value;
9015 get { return (style.hidden || !setVisible) ? false : true; }
9018 property bool isDocument
9020 property_category $"Document"
9021 set { style.isDocument = value; }
9022 get { return style.isDocument; }
9025 property bool mergeMenus
9027 property_category $"Window Style"
9028 set { mergeMenus = value; }
9029 get { return (bool)mergeMenus; }
9032 property bool hasHorzScroll
9034 property_category $"Window Style"
9039 if(!style.hasHorzScroll && created)
9041 CreateSystemChildren();
9042 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9045 else if(style.hasHorzScroll)
9049 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9051 style.hasHorzScroll = value;
9054 get { return style.hasHorzScroll; }
9057 property bool hasVertScroll
9059 property_category $"Window Style"
9064 if(!style.hasVertScroll && created)
9066 style.hasVertScroll = true;
9067 CreateSystemChildren();
9068 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9071 else if(style.hasVertScroll)
9075 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9077 style.hasVertScroll = value;
9079 get { return style.hasVertScroll; }
9082 property bool dontHideScroll
9084 property_category $"Behavior"
9087 scrollFlags.dontHide = value;
9090 //UpdateScrollBars(true, true);
9091 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9095 // UpdateScrollBars(true, true);
9096 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9099 get { return scrollFlags.dontHide; }
9102 property bool dontScrollVert
9104 property_category $"Behavior"
9105 set { style.dontScrollVert = value; }
9106 get { return style.dontScrollVert; }
9108 property bool dontScrollHorz
9110 property_category $"Behavior"
9111 set { style.dontScrollHorz = value; }
9112 get { return style.dontScrollHorz; }
9115 property bool snapVertScroll
9117 property_category $"Behavior"
9120 scrollFlags.snapY = value;
9121 if(sbv) sbv.snap = value;
9123 get { return scrollFlags.snapY; }
9125 property bool snapHorzScroll
9127 property_category $"Behavior"
9130 scrollFlags.snapX = value;
9131 if(sbh) sbh.snap = value;
9133 get { return scrollFlags.snapX; }
9136 property Point scroll
9138 property_category $"Behavior"
9139 set { SetScrollPosition(value.x, value.y); }
9140 get { value = scroll; }
9143 property bool modifyVirtualArea
9145 property_category $"Behavior"
9146 set { modifyVirtArea = value; }
9147 get { return (bool)modifyVirtArea; }
9150 property bool dontAutoScrollArea
9152 property_category $"Behavior"
9153 // Activating a child control out of view will automatically scroll to make it in view
9154 set { noAutoScrollArea = value; }
9155 get { return (bool)noAutoScrollArea; }
9158 property char * fileName
9160 property_category $"Document"
9163 if(menu && ((!fileName && value) || (fileName && !value)))
9165 MenuItem item = menu.FindItem(MenuFileSave, 0);
9166 if(item) item.disabled = !modifiedDocument && value;
9171 if(value && value[0])
9172 fileName = CopyString(value);
9174 if(parent && this == parent.activeClient)
9175 parent.UpdateActiveDocument(null);
9179 // if(style.isDocument)
9181 fileMonitor.fileName = value;
9183 get { return fileName; }
9188 property_category $"Data"
9193 property bool modifiedDocument
9195 property_category $"Document"
9198 if(style.isDocument || fileName)
9202 MenuItem item = menu.FindItem(MenuFileSave, 0);
9203 if(item) item.disabled = !value && fileName;
9207 if(modifiedDocument != value)
9209 modifiedDocument = value;
9210 if(style.isDocument || fileName)
9214 get { return (bool)modifiedDocument; }
9217 property bool showInTaskBar
9219 property_category $"Window Style"
9220 set { style.showInTaskBar = value; }
9221 get { return (style.showInTaskBar; }
9223 property FileDialog saveDialog { set { saveDialog = value; } };
9224 property bool isActiveClient
9226 property_category $"Behavior"
9227 set { style.isActiveClient = value; }
9228 get { return style.isActiveClient; }
9231 property Cursor cursor
9233 property_category $"Appearance"
9237 SelectMouseCursor();
9239 get { return cursor; }
9242 //#if !defined(ECERE_VANILLA)
9243 property char * name
9245 property_category $"Design"
9248 return (this && object) ? object.name : null;
9253 activeDesigner.RenameObject(object, value);
9257 property char * displayDriver
9259 property_category $"Behavior"
9262 dispDriver = GetDisplayDriver(value);
9263 //DisplayModeChanged();
9267 return dispDriver ? dispDriver.name : null;
9271 // RUNTIME PROPERTIES
9272 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9273 property Size scrollArea
9275 property_category $"Behavior"
9279 SetScrollArea(value.w, value.h, false);
9281 SetScrollArea(0,0, true);
9283 get { value = scrollArea; }
9286 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9291 property_category $"Layout"
9292 set { if(this) is3D = value; }
9293 get { return (bool)is3D; }
9296 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9298 // Will be merged with font later
9299 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9300 property Point clientStart { get { value = clientStart; } };
9301 property Point absPosition { get { value = absPosition; } };
9302 property Anchor normalAnchor { get {value = normalAnchor; } };
9303 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9304 property bool active { get { return (bool)active; } };
9305 property bool created { get { return (bool)created; } };
9306 property bool destroyed { get { return (bool)destroyed; } };
9307 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9308 property Window firstChild { get { return children.first; } };
9309 property Window lastChild { get { return children.last; } };
9310 property Window activeClient { get { return activeClient; } };
9311 property Window activeChild { get { return activeChild; } };
9312 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9313 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9314 property ScrollBar horzScroll { get { return sbh; } };
9315 property ScrollBar vertScroll { get { return sbv; } };
9316 property StatusBar statusBar { get { return statusBar; } };
9317 property Window rootWindow { get { return rootWindow; } };
9318 property bool closing { get { return (bool)closing; } set { closing = value; } };
9319 property int documentID { get { return documentID; } };
9320 property Window previous { get { return prev; } }
9321 property Window next { get { return next; } }
9322 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9323 property PopupMenu menuBar { get { return menuBar; } }
9324 property ScrollBar sbv { get { return sbv; } }
9325 property ScrollBar sbh { get { return sbh; } }
9326 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9327 property void * systemHandle { get { return windowHandle; } }
9328 property Button minimizeButton { get { return sysButtons[0]; } };
9329 property Button maximizeButton { get { return sysButtons[1]; } };
9330 property Button closeButton { get { return sysButtons[2]; } };
9331 property BitmapResource icon
9333 get { return icon; }
9337 if(icon) incref icon;
9339 guiApp.interfaceDriver.SetIcon(this, value);
9342 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9343 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9344 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9345 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9346 property bool nativeDecorations
9348 get { return (bool)nativeDecorations; }
9349 set { nativeDecorations = value; }
9350 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9353 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9354 bool result = false;
9355 if(nativeDecorations)
9357 if(rootWindow == this)
9361 if(formDesigner && activeDesigner)
9363 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9364 Window form = cd ? cd.form : null;
9365 if(form && parent == form.parent)
9370 return result != style.fixed;
9374 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9376 property char * text
9378 property_category $"Deprecated"
9380 set { property::caption = value; }
9381 get { return property::caption; }
9387 WindowBits style; // Window Style
9388 char * caption; // Name / Caption
9389 Window parent; // Parent window
9390 OldList children; // List of children in Z order
9391 Window activeChild; // Child window having focus
9392 Window activeClient;
9393 Window previousActive; // Child active prior to activating the default child
9394 Window master; // Window owning and receiving notifications concerning this window
9395 OldList slaves; // List of windows belonging to this window
9396 Display display; // Display this window is drawn into
9398 Point position; // Position in parent window client area
9399 Point absPosition; // Absolute position
9400 Point clientStart; // Client area position from (0,0) in this window
9402 Size clientSize; // Client area size
9403 Size scrollArea; // Virtual Scroll area size
9404 Size reqScrollArea; // Requested virtual area size
9405 Point scroll; // Virtual area scrolling position
9406 ScrollBar sbh, sbv; // Scrollbar window handles
9407 Cursor cursor; // Mouse cursor used for this window
9410 StatusBar statusBar;
9411 Button sysButtons[3];
9413 Box clientArea; // Client Area box clipped to parent
9415 HotKeySlot hotKey; // HotKey for this window
9419 ScrollFlags scrollFlags;// Window Scrollbar Flags
9420 int64 id; // Control ID
9422 ColorAlpha background; // Background color used to draw the window area
9424 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9425 OldList childrenCycle; // Cycling order
9426 OldLink cycle; // Element of parent's cycling order
9427 OldList childrenOrder; // Circular Z-Order
9428 OldLink order; // Element of parent's circular Z-Order
9429 Window modalSlave; // Slave window blocking this window's interaction
9431 Window rootWindow; // Topmost system managed window
9432 void * windowHandle; // System window handle
9434 DialogResult returnCode;// Return code for modal windows
9436 Point sbStep; // Scrollbar line scrolling steps
9439 SizeAnchor stateSizeAnchor;
9441 Anchor normalAnchor;
9442 SizeAnchor normalSizeAnchor;
9444 Size skinMinSize; // Minimal window size based on style
9445 Point scrolledPos; // Scrolled position
9446 Box box; // Window box clipped to parent
9447 Box * against; // What to clip the box to
9449 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9450 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9451 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9452 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9453 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9454 Point scrolledArea; // Distance to scroll area by
9455 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9457 OldList hotKeys; // List of the hotkeys of all children
9458 Window defaultControl; // Default child control
9462 ColorAlpha * palette; // Color palette used for this window
9464 int caretSize; // Size of caret, non zero if a caret is present
9465 Point caretPos; // Caret position
9467 void * systemParent; // Parent System Window for embedded windows
9474 WindowState lastState;
9476 FileMonitor fileMonitor
9478 this, FileChange { modified = true };
9480 bool OnFileNotify(FileChange action, char * param)
9483 fileMonitor.StopMonitoring();
9484 if(OnFileModified(action, param))
9485 fileMonitor.StartMonitoring();
9490 FontResource setFont, systemFont;
9491 FontResource usedFont;
9492 FontResource captionFont;
9494 FileDialog saveDialog;
9496 SizeAnchor sizeAnchor;
9498 // FormDesigner data
9501 Extent * tempExtents; //[4];
9502 BitmapResource icon;
9504 CreationActivationOption creationActivation;
9507 bool active:1; // true if window and ancestors are active
9508 bool acquiredInput:1; // true if the window is processing state based input
9509 bool modifiedDocument:1;
9510 bool disabled:1; // true if window cannot interact
9511 bool isForegroundWindow:1;// true while a root window is being activated
9512 bool visible:1; // Visibility flag
9513 bool destroyed:1; // true if window is being destroyed
9514 bool anchored:1; // true if this window is repositioned when the parent resizes
9515 bool dirty:1; // Flag set to true if any descendant must be redrawn
9521 bool modifyVirtArea:1;
9522 bool noAutoScrollArea:1;
9525 bool setVisible:1; // FOR FORM DESIGNER
9531 bool useSharedMemory:1;
9534 bool nativeDecorations:1;
9535 bool manageDisplay:1;
9536 bool formDesigner:1; // True if we this is running in the form editor
9539 // Checks used internally for them not to take effect in FormDesigner
9540 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9541 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9543 WindowController controller;
9544 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9547 public class CommonControl : Window
9549 // creationActivation = doNothing;
9552 public property String toolTip
9554 property_category $"Appearance"
9557 if(created) CommonControl::OnDestroy();
9559 toolTip = value ? ToolTip { tip = value; } : null;
9561 if(created) CommonControl::OnCreate();
9563 get { return toolTip ? toolTip.tip : null; }
9569 // (Very) Ugly work around for the fact that the parent watcher
9570 // won't fire when it's already been disconnected...
9571 eInstance_FireSelfWatchers(toolTip,
9572 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9578 toolTip.parent = this;
9587 public class Percentage : float
9589 char * OnGetString(char * string, float * fieldData, bool * needClass)
9593 sprintf(string, "%.2f", this);
9594 c = strlen(string)-1;
9597 if(string[c] != '0')
9598 last = Max(last, c);
9599 if(string[c] == '.')
9612 public void ApplySkin(Class c, char * name, void ** vTbl)
9614 char className[1024];
9619 subclass(Window) wc = (subclass(Window))c;
9620 subclass(Window) base = (subclass(Window))c.base;
9622 sprintf(className, "%sSkin_%s", name, c.name);
9623 wc.pureVTbl = c._vTbl;
9624 c._vTbl = new void *[c.vTblSize];
9625 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9626 sc = eSystem_FindClass(c.module.application, className);
9630 for(m = 0; m < c.base.vTblSize; m++)
9632 if(c._vTbl[m] == base.pureVTbl[m])
9633 c._vTbl[m] = vTbl[m];
9638 for(m = 0; m < c.vTblSize; m++)
9640 if(sc._vTbl[m] != wc.pureVTbl[m])
9641 c._vTbl[m] = sc._vTbl[m];
9645 for(d = c.derivatives.first; d; d = d.next)
9647 ApplySkin(d.data, name, c._vTbl);
9651 public void UnapplySkin(Class c)
9653 char className[1024];
9655 subclass(Window) wc = (subclass(Window))c;
9656 subclass(Window) base = (subclass(Window))c.base;
9659 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9662 c._vTbl = wc.pureVTbl;
9666 for(d = c.derivatives.first; d; d = d.next)
9668 UnapplySkin(d.data);
9672 void CheckFontIntegrity(Window window)
9677 if(window.usedFont && window.usedFont.font == 0xecececec)
9679 FontResource uf = window.usedFont;
9680 char * className = window._class.name;
9681 char * text = window.text;
9684 for(c = window.firstChild; c; c = c.next)
9685 CheckFontIntegrity(c);
9689 public class ControllableWindow : Window
9691 /*WindowController controller;
9692 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9693 ~ControllableWindow() { delete controller; }*/
9696 class WindowControllerInterface : ControllableWindow
9698 bool OnKeyDown(Key key, unichar ch)
9700 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9702 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9706 bool OnKeyUp(Key key, unichar ch)
9708 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9710 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9714 bool OnKeyHit(Key key, unichar ch)
9716 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9718 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9722 bool OnMouseMove(int x, int y, Modifiers mods)
9724 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9726 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9730 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9732 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9734 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9738 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9740 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9742 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9746 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9748 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9750 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9754 bool OnRightButtonDown(int x, int y, Modifiers mods)
9756 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9758 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9762 bool OnRightButtonUp(int x, int y, Modifiers mods)
9764 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9766 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9770 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9772 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9774 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9778 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9780 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9782 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9786 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9788 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9790 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9794 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9796 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9798 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9802 void OnResize(int width, int height)
9804 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9805 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9808 void OnRedraw(Surface surface)
9810 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9811 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9816 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9818 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9822 bool OnLoadGraphics()
9824 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9826 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9830 void OnUnloadGraphics()
9832 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9833 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9837 public class WindowController<class V>
9840 property Window window
9844 uint size = class(Window).vTblSize;
9847 windowVTbl = new void *[size];
9848 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9849 if(value._vTbl == value._class._vTbl)
9851 value._vTbl = new void *[value._class.vTblSize];
9852 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9856 for(c = 0; c < size; c++)
9858 void * function = class(WindowControllerInterface)._vTbl[c];
9859 if(function != DefaultFunction)
9860 value._vTbl[c] = function;
9862 value._vTbl[c] = windowVTbl[c];
9867 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9870 get { return window; }
9872 property V controlled
9874 set { controlled = value; }
9875 get { return controlled; }
9877 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9878 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9879 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9880 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9881 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9882 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9883 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9884 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9885 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9886 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9887 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9888 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9889 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9890 virtual void V::OnResize(WindowController controller, int width, int height);
9891 virtual void V::OnRedraw(WindowController controller, Surface surface);
9892 virtual bool V::OnCreate(WindowController controller);
9893 virtual bool V::OnLoadGraphics(WindowController controller);
9894 virtual void V::OnUnloadGraphics(WindowController controller);
9897 int (** windowVTbl)();