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)
2218 parent = GetParentMenuBar();
2222 if(style.hasClose) hasClose = true;
2223 if(style.hasMaximize || style.hasMinimize)
2230 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2232 sysButtons[2].Destroy(0);
2233 sysButtons[2] = null;
2235 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2237 sysButtons[1].Destroy(0);
2238 sysButtons[1] = null;
2240 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2242 sysButtons[0].Destroy(0);
2243 sysButtons[0] = null;
2246 if(hasClose && parent)
2253 parent, master = this,
2254 inactive = true, nonClient = true, visible = false;
2256 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2262 if(this.parent == guiApp.desktop)
2263 sysButtons[2].hotKey = altF4;
2264 else if(style.isActiveClient)
2265 sysButtons[2].hotKey = ctrlF4;
2266 sysButtons[2].Create();
2269 sysButtons[2].symbol = 'X';
2270 sysButtons[2].disabled = !style.hasClose;
2273 if(hasMaxMin && parent)
2277 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2278 if(state == maximized)
2281 method = RestoreButtonClicked;
2287 method = MaximizeButtonClicked;
2295 parent, master = this,
2296 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2298 sysButtons[1].Create();
2300 sysButtons[1].NotifyClicked = method;
2302 sysButtons[1].symbol = symbol;
2303 sysButtons[1].disabled = !style.hasMaximize;
2306 if(hasMaxMin && parent)
2310 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2311 if (state == minimized)
2314 method = RestoreButtonClicked;
2320 method = MinimizeButtonClicked;
2328 parent, master = this,
2329 hotKey = altM, inactive = true, nonClient = true, visible = false
2331 sysButtons[0].Create();
2333 sysButtons[0].NotifyClicked = method;
2335 sysButtons[0].symbol = symbol;
2336 sysButtons[0].disabled = !style.hasMinimize;
2339 // Create the scrollbars
2340 if(style.hasHorzScroll && !sbh)
2346 direction = horizontal,
2350 snap = scrollFlags.snapX,
2351 NotifyScrolling = ScrollBarNotification
2354 scrollBarChanged = true;
2356 else if(sbh && !style.hasHorzScroll)
2362 if(style.hasVertScroll && !sbv)
2368 direction = vertical,
2372 snap = scrollFlags.snapY,
2373 NotifyScrolling = ScrollBarNotification
2376 scrollBarChanged = true;
2378 else if(sbv && !style.hasVertScroll)
2383 if(scrollBarChanged)
2385 SetScrollLineStep(sbStep.x, sbStep.y);
2386 UpdateScrollBars(true, true);
2390 if(scrollBarChanged)
2392 if(sbh) sbh.thumbPosition = scroll.x;
2393 if(sbv) sbv.thumbPosition = scroll.y;
2397 void UpdateCaption(void)
2399 if(rootWindow == this)
2402 FigureCaption(caption);
2403 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2405 UpdateDecorations();
2408 if(parent.activeClient == this) // Added this last check
2410 if(parent.rootWindow == parent)
2413 parent.FigureCaption(caption);
2414 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2417 parent.UpdateCaption();
2419 parent.UpdateDecorations();
2423 void UpdateActiveDocument(Window previous)
2425 Window activeClient = this.activeClient;
2426 Window activeChild = this.activeChild;
2433 activeClient.CreateSystemChildren();
2435 previous.CreateSystemChildren();
2447 // Build window list
2450 Menu windowMenu = menu.FindMenu("Window");
2455 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2458 Window document = cycle.data;
2459 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2461 char name[2048], caption[2048];
2462 document.FigureCaption(caption);
2463 sprintf(name, "%d %s", id+1, caption);
2464 windowMenu.AddDynamic(MenuItem
2466 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2467 NotifySelect = MenuWindowSelectWindow
2471 if(activeClient.cycle == cycle) break;
2476 if((!previous && activeClient) || !activeClient)
2482 item = menu.FindItem(MenuWindowCloseAll, 0);
2483 if(item) item.disabled = false;
2484 item = menu.FindItem(MenuWindowNext, 0);
2485 if(item) item.disabled = false;
2486 item = menu.FindItem(MenuWindowPrevious, 0);
2487 if(item) item.disabled = false;
2488 item = menu.FindItem(MenuWindowCascade, 0);
2489 if(item) item.disabled = false;
2490 item = menu.FindItem(MenuWindowTileHorz, 0);
2491 if(item) item.disabled = false;
2492 item = menu.FindItem(MenuWindowTileVert, 0);
2493 if(item) item.disabled = false;
2494 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2495 if(item) item.disabled = false;
2496 item = menu.FindItem(MenuWindowWindows, 0);
2497 if(item) item.disabled = false;
2500 item = menu.FindItem(MenuFileClose, 0);
2501 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2502 item = menu.FindItem(MenuFileSaveAll, 0);
2503 if(item) item.disabled = numDocuments < 1;
2505 if(activeClient && activeClient.menu && activeClient.state != minimized)
2509 //activeClient.menu.Clean(activeClient);
2510 menu.Merge(activeClient.menu, true, activeClient);
2514 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2517 menu.Merge(activeChild.menu, true, activeChild);
2520 // This is called again for a child window change, with same active client
2521 OnActivateClient(activeClient, previous);
2522 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2523 parent.UpdateActiveDocument(null);
2526 void _ShowDecorations(Box box, bool post)
2528 if(rootWindow == this && nativeDecorations) return;
2529 if(visible && this != guiApp.desktop)
2531 Surface surface = RedrawFull(box);
2535 FigureCaption(caption);
2538 ShowDecorations(captionFont.font,
2541 active, //parent.activeClient == this
2542 guiApp.windowMoving == this);
2544 PreShowDecorations(captionFont.font,
2547 active, //parent.activeClient == this
2548 guiApp.windowMoving == this);
2555 void UpdateExtent(Box refresh)
2557 Surface surface = null;
2559 if(!manageDisplay) { OnRedraw(null);return; }
2560 _ShowDecorations(refresh, false);
2562 surface = Redraw(refresh);
2563 // Opaque background: just fill before EW_REDRAW (clear?)
2566 surface.SetBackground(background);
2567 surface.SetForeground(foreground);
2568 surface.DrawingChar(' ');
2569 if(this == rootWindow)
2571 if(style.drawBehind || background.a)
2573 int a = background.a;
2574 // Premultiply alpha for clear color
2575 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2576 surface.Clear(colorBuffer);
2577 surface.SetBackground(background);
2580 else if(background.a)
2584 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2585 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2588 if(display.flags.alpha && background.a < 255 && background)
2590 surface.Area(0,0,clientSize.w, clientSize.h);
2591 /*if(style.clearDepthBuffer)
2592 surface.Clear(depthBuffer);*/
2594 else if(/*style.clearDepthBuffer || */background.a)
2596 int a = background.a;
2597 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2598 // Premultiply alpha for clear color
2599 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2600 surface.Clear(colorBuffer);
2601 surface.SetBackground(background);
2606 surface.TextFont(usedFont.font);
2607 surface.TextOpacity(false);
2611 // Draw the caret ...
2612 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2614 // surface.SetBackground(0xFFFFFF - background.color);
2615 surface.SetBackground(~background.color);
2617 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2618 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2624 void DrawOverChildren(Box refresh)
2626 Surface surface = Redraw(refresh);
2630 surface.DrawingChar(' ');
2631 surface.SetBackground(background);
2632 surface.SetForeground(foreground);
2634 surface.TextFont(usedFont.font);
2635 surface.TextOpacity(false);
2637 OnDrawOverChildren(surface);
2642 _ShowDecorations(refresh, true);
2645 void ComputeClipExtents(void)
2648 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2650 clipExtent.Copy(this.clipExtent);
2652 for(child = children.last; child; child = child.prev)
2654 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2656 bool opaque = child.IsOpaque(); // TODO: acess background directly
2657 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2659 child.clipExtent.Copy(clipExtent);
2660 child.clipExtent.Offset(-dx, -dy);
2661 child.clipExtent.IntersectBox(child.box);
2663 child.ComputeClipExtents();
2665 if(opaque && !child.style.nonClient)
2667 // Adjust the box for the parent:
2668 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2669 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2674 // ??? Only do this for overlapped window or if parent has with clip children flag
2676 // Do this if window has clip children flag on (default false?)
2677 // this.clipExtent = clipExtent;
2679 clipExtent.Free(null);
2682 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2684 bool opaque = IsOpaque();
2686 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2687 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2689 offsetX -= rootWindow.clientStart.x;
2690 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2694 for(child = children.last; child; child = child.prev)
2696 ColorAlpha background = *(ColorAlpha *)&child.background;
2697 bool opaque = child.IsOpaque();
2698 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2702 // Adjust renderArea to the root window level
2703 Extent * renderArea = &rootWindow.tempExtents[3];
2705 int offsetX = child.absPosition.x - rootWindow.absPosition.x;
2706 int offsetY = child.absPosition.y - rootWindow.absPosition.y;
2707 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2709 offsetX -= child.rootWindow.clientStart.x;
2710 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2714 Extent childRenderArea;
2716 if(backBufferUpdate != null)
2718 childRenderArea.Copy(backBufferUpdate);
2719 childRenderArea.Offset(-offsetX, -offsetY);
2722 childRenderArea.Copy(child.dirtyArea);
2724 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2725 renderArea.Copy(dirtyExtent);
2726 renderArea.Offset(-offsetX, -offsetY);
2727 childRenderArea.Union(renderArea);
2730 // Intersect with the clip extent
2731 childRenderArea.Intersection(child.clipExtent);
2734 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2736 // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
2737 renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2739 renderArea->Offset(offsetX, offsetY);
2741 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2742 // overDirtyExtent.Union(renderArea);
2743 renderArea->Empty();
2744 // childRenderArea.Free();
2746 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2751 for(child = children.last; child; child = child.prev)
2753 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2755 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2760 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2762 bool opaque = IsOpaque();
2763 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2765 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2766 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2768 offsetX -= rootWindow.clientStart.x;
2769 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2773 for(child = children.last; child; child = child.prev)
2775 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2777 ColorAlpha background = *(ColorAlpha *)&child.background;
2778 bool opaque = child.IsOpaque();
2779 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2783 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2784 // Adjust renderArea to the root window level
2786 renderArea.Copy(child.dirtyArea);
2787 renderArea.Offset(offsetX, offsetY);
2788 dirtyExtent.Union(renderArea);
2789 overDirtyExtent.Union(renderArea);
2795 for(child = children.last; child; child = child.prev)
2797 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2799 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2803 if(backBufferUpdate != null)
2805 renderArea.Copy(backBufferUpdate);
2806 renderArea.Offset(-offsetX, -offsetY);
2808 overRenderArea.Copy(backBufferUpdate);
2809 overRenderArea.Offset(-offsetX, -offsetY);
2815 renderArea.Copy(dirtyArea);
2817 overRenderArea.Copy(dirtyArea);
2820 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2821 dirtyExtentWindow->Copy(dirtyExtent);
2822 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2823 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2824 dirtyExtentWindow->Empty();
2826 // Intersect with the clip extent
2827 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2830 if(renderArea.count > 10)
2833 printf("\nToo many extents (%d):\n", renderArea.count);
2835 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2836 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2841 for(c = 0; c<10; c++)
2844 FASTLIST_LOOP(renderArea, extentBox)
2846 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2848 renderArea.Copy(extent);
2850 FASTLIST_LOOP(renderArea, extentBox)
2853 printf("(%d, %d) - (%d, %d)\n",
2854 extentBox.box.left, extentBox.box.top,
2855 extentBox.box.right, extentBox.box.bottom);
2859 printf("\nNow %d\n", renderArea.count);
2865 // WHY WAS THIS COMMENTED ??
2867 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2868 dirtyExtentWindow->Copy(overDirtyExtent);
2869 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2870 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2871 dirtyExtentWindow->Empty();
2873 // Intersect with the clip extent
2874 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2880 if(scrollExtent.count)
2882 // Subtract render extent from scrolling extent
2883 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2885 if(backBufferUpdate == null)
2887 Extent * dirty = &rootWindow.tempExtents[3];
2890 // Intersect scrolling extent with clip extent
2891 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2893 // offset this scroll to be at the root window level
2894 scrollExtent.Offset(offsetX, offsetY);
2895 // Add area that was scrolled to the dirty extents of the back buffer
2896 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2900 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2901 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2902 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2907 scrollExtent.Empty();
2909 // Add the exposed extent to the window render area
2910 dirty->Offset(-offsetX, -offsetY);
2911 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2916 // Subtract the window's box from the transparency forced extent
2917 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2923 renderArea.Copy(this.renderArea);
2924 renderArea.Offset(offsetX, offsetY);
2925 dirtyExtent.Union(renderArea);
2931 Extent renderArea { };
2933 renderArea.Copy(overRenderArea);
2934 renderArea.Offset(offsetX, offsetY);
2935 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2940 if(backBufferUpdate != null)
2942 // Remove render area from dirty area
2943 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2945 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2952 // Remove the window render area from the dirty extents of the back buffer
2953 rootWindow.dirtyBack.Exclusion(renderArea);
2957 void Render(Extent updateExtent)
2961 Window rootWindow = this.rootWindow;
2962 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2963 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2965 offsetX -= rootWindow.clientStart.x;
2966 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2969 if(rootWindow.fullRender)
2978 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2979 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2984 /*if(renderArea.count)
2985 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2988 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2990 Box box = extentBox.box;
2993 /*printf("(%d, %d) - (%d, %d)\n",
2994 extentBox.box.left, extentBox.box.top,
2995 extentBox.box.right, extentBox.box.bottom);*/
3000 box.left += offsetX;
3002 box.right += offsetX;
3003 box.bottom += offsetY;
3005 if(updateExtent != null)
3006 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3010 for(child = children.first; child; child = child.next)
3011 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3012 child.Render(updateExtent);
3014 if(rootWindow.fullRender)
3015 DrawOverChildren(box);
3018 // TO DO: There's an issue about draw over children...
3019 // TO DO: Don't wanna go through this if method isn't used
3020 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3021 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3023 Box box = extentBox.box;
3025 DrawOverChildren(box);
3027 box.left += offsetX;
3029 box.right += offsetX;
3030 box.bottom += offsetY;
3032 if(updateExtent != null)
3033 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3036 for(child = children.first; child; child = child.next)
3037 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3038 child.Render(updateExtent);
3041 overRenderArea.Empty();
3044 public void UpdateDisplay(void)
3046 if(!manageDisplay) { OnRedraw(null);return; }
3047 if(rootWindow && this != rootWindow)
3048 rootWindow.UpdateDisplay();
3051 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3052 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3055 dirtyExtent.Clear();
3058 clipExtent.AddBox(box);
3060 display.StartUpdate();
3062 if(!rootWindow.fullRender)
3064 ComputeClipExtents();
3065 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3066 ComputeRenderArea(dirtyExtent, overExtent, null);
3069 clipExtent.Free(null);
3071 dirtyExtent.Free(null);
3072 overExtent.Free(null);
3074 if(display.flags.flipping)
3077 display.Update(null);
3081 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3082 updateExtent.Clear();
3084 Render(updateExtent);
3086 updateExtent.UnionBox(this.box, tempExtents[0]);
3089 //printf("\n\nUpdate:\n------------------------------------------\n");
3092 //FASTLIST_LOOP(updateExtent, extentBox)
3093 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3096 /*printf("Updating (%d, %d) - (%d, %d)\n",
3097 extentBox.box.left, extentBox.box.top,
3098 extentBox.box.right, extentBox.box.bottom);*/
3101 display.Update(extentBox.box);
3104 updateExtent.Free(null);
3107 display.EndUpdate();
3115 void UpdateBackDisplay(Box box)
3121 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3123 //printf("UpdateBackDisplay going through!\n");
3124 display.StartUpdate();
3128 intersection.Copy(dirtyBack);
3129 intersection.IntersectBox(box);
3131 dirtyExtent.Clear();
3134 clipExtent.AddBox(box);
3136 if(!rootWindow.fullRender)
3138 ComputeClipExtents();
3139 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3142 clipExtent.Free(null);
3144 intersection.Free(null);
3145 dirtyExtent.Free(null);
3146 overExtent.Free(null);
3151 if(display.flags.flipping)
3152 display.Update(null);
3155 rootWindow.display.Update(box);
3158 display.EndUpdate();
3162 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3163 if(dirtyBack.count > MAX_DIRTY_BACK)
3165 BoxItem extentBox, next;
3166 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3167 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3169 next = (BoxItem)extentBox.next;
3170 if(extentBox != first)
3172 if(extentBox.box.left < first.box.left)
3173 first.box.left = extentBox.box.left;
3174 if(extentBox.box.top < first.box.top)
3175 first.box.top = extentBox.box.top;
3176 if(extentBox.box.right > first.box.right)
3177 first.box.right = extentBox.box.right;
3178 if(extentBox.box.bottom > first.box.bottom)
3179 first.box.bottom = extentBox.box.bottom;
3180 dirtyBack.Delete(extentBox);
3189 // --- Window positioning ---
3190 // --- Window identification ---
3192 // Returns window at position "Position"
3193 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3195 Window child, result = null;
3197 box.left += absPosition.x;
3198 box.right += absPosition.x;
3199 box.top += absPosition.y;
3200 box.bottom += absPosition.y;
3202 if(!destroyed && visible && (acceptDisabled || !disabled))
3204 int lx = x - absPosition.x;
3205 int ly = y - absPosition.y;
3206 if(IsInside(lx, ly))
3207 // if(box.IsPointInside(Point{x, y}))
3209 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3210 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3213 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3214 Window ancestor = null;
3216 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3217 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3218 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3220 if(child != statusBar && child.rootWindow == rootWindow)
3222 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3229 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3230 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3232 if(child != statusBar && child.rootWindow == rootWindow)
3234 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3241 if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
3249 Window FindModal(void)
3251 Window modalWindow = this, check;
3252 Window check2 = null;
3253 for(check = this; check.master; check = check.master)
3255 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3257 modalWindow = check.master.modalSlave;
3258 check = modalWindow;
3260 // TESTING THIS FOR DROPBOX...
3261 if(!rootWindow || !rootWindow.style.interim)
3263 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3265 if(check2.modalSlave && check2.modalSlave.created)
3267 modalWindow = check2.modalSlave;
3275 if(modalWindow == this)
3277 for(check = this; check.activeChild; check = check.activeChild)
3279 if(check.modalSlave)
3281 modalWindow = check.modalSlave;
3287 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3288 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3291 void StopMoving(void)
3293 if(this == guiApp.windowMoving)
3295 guiApp.windowMoving = null;
3296 UpdateDecorations();
3297 SetMouseRange(null);
3300 if(rootWindow.active)
3301 guiApp.interfaceDriver.StopMoving(rootWindow);
3304 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3305 guiApp.windowIsResizing = false;
3309 void SelectMouseCursor(void)
3314 Window cursorWindow = null;
3315 bool rx, ry, rex, rey;
3317 guiApp.desktop.GetMousePosition(&x, &y);
3318 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3320 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3321 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3322 else if(mouseWindow)
3324 modalWindow = mouseWindow.FindModal();
3325 x -= mouseWindow.absPosition.x;
3326 y -= mouseWindow.absPosition.y;
3327 if(guiApp.windowIsResizing)
3329 rex = guiApp.resizeEndX;
3330 rey = guiApp.resizeEndY;
3331 rx = guiApp.resizeX;
3332 ry = guiApp.resizeY;
3333 if((rex && rey) || (rx && ry))
3334 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3335 else if((rex && ry) || (rx && rey))
3336 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3337 else if((ry || rey) && (!rx && !rex))
3338 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3339 else if((rx || rex) && (!ry && !rey))
3340 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3342 else if(!modalWindow && !guiApp.windowCaptured &&
3343 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3344 &rx, &ry, &rex, &rey))
3346 if((rex && rey) || (rx && ry))
3347 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3348 else if((rex && ry) || (rx && rey))
3349 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3350 else if((ry || rey) && (!rx && !rex))
3351 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3352 else if((rx || rex) && (!ry && !rey))
3353 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3355 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3357 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3358 cursorWindow = mouseWindow.parent;
3360 cursorWindow = mouseWindow;
3362 else if(!guiApp.interimWindow)
3363 cursorWindow = guiApp.windowCaptured;
3366 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3367 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3369 else if(modalWindow)
3371 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3373 else if(guiApp.interimWindow)
3375 if(guiApp.interimWindow.cursor)
3376 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3378 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3383 // --- State based input ---
3384 bool AcquireInputEx(bool state)
3389 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3390 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3392 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3394 guiApp.acquiredWindow = state ? this : null;
3397 SetMouseRangeToClient();
3398 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3403 SelectMouseCursor();
3405 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3409 // --- Window activation ---
3410 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3413 if(!parent || !parent.style.inactive)
3415 Window parent = this.parent;
3418 if(rootWindow == this)
3419 Log(active ? "active\n" : "inactive\n");
3422 // Testing this here...
3423 if(!parent || parent == guiApp.desktop || parent.active)
3425 this.active = active;
3428 // TESTING THIS HERE
3429 UpdateDecorations();
3430 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3431 result = NotifyActivate(master, this, active, previous);
3434 this.active = !active;
3439 if(!parent || parent == guiApp.desktop || parent.active)
3441 this.active = active;
3443 AcquireInputEx(active);
3448 if(guiApp.caretOwner)
3452 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3453 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3454 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3455 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3457 guiApp.caretOwner.Update(extent);
3460 if(visible || !guiApp.caretOwner)
3461 guiApp.caretOwner = this;
3462 UpdateCaret(false, false);
3468 this.active = false;
3470 AcquireInputEx(active);
3472 if(!active && guiApp.caretOwner == this)
3474 UpdateCaret(false, true);
3475 guiApp.caretOwner = null;
3476 guiApp.interfaceDriver.SetCaret(0,0,0);
3477 guiApp.caretEnabled = false;
3482 if(!active && parent && parent.activeChild && parent.activeChild != this)
3483 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3489 if(!active && menuBar)
3492 menuBar.OnActivate(false, null, &goOn, true);
3493 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3498 Window aChild = activeChild;
3500 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3512 void ConsequentialMouseMove(bool kbMoving)
3516 if(kbMoving || !guiApp.windowMoving)
3520 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3522 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3524 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3525 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3531 bool IsDescendantOf(Window ancestor)
3534 for(window = this; window && window != ancestor; window = window.parent);
3535 return window == ancestor;
3538 bool IsSlaveOf(Window master)
3541 for(window = this; window && window != master; window = window.master);
3542 return window == master;
3545 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3549 if(this && !destroyed /*&& state != Hidden*/)
3551 Window swap = externalSwap;
3559 if(activateParent &&
3560 (parent.activeChild != this ||
3561 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3562 active && _isModal &&
3563 parent != master && master)
3564 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3570 bool real = parent.activeChild != this;
3572 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3573 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3574 !IsDescendantOf(guiApp.interimWindow) &&
3575 !IsSlaveOf(guiApp.interimWindow))
3577 Window interimWindow = guiApp.interimWindow;
3578 while(interimWindow && interimWindow != this)
3580 Window master = interimWindow.master;
3582 guiApp.interimWindow = null;
3583 if(guiApp.caretOwner)
3584 guiApp.caretOwner.UpdateCaret(false, false);
3586 incref interimWindow;
3587 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3592 delete interimWindow;
3593 interimWindow = (master && master.style.interim) ? master : null;
3598 guiApp.interimWindow = this;
3599 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3600 guiApp.caretEnabled = false;*/
3601 UpdateCaret(false, true);
3606 bool acquireInput = false;
3608 parent.activeChild &&
3609 parent.activeChild.state == maximized &&
3610 parent != guiApp.desktop;
3612 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3617 swap = parent.activeChild;
3618 if(swap && swap.destroyed) swap = null;
3619 if(swap && swap != this)
3622 if(!swap.PropagateActive(false, this, &goOn, true))
3623 swap = parent.activeChild;
3634 if(!parent || parent.activeChild != this || style.interim)
3637 result = PropagateActive(true, swap, &goOn, true);
3638 if(!result && !goOn)
3643 acquireInput = true;
3647 if(style.hasMaximize && parent != guiApp.desktop)
3650 SetState(maximized, false, 0);
3651 else if(state != maximized)
3654 for(child = parent.children.first; child; child = child.next)
3656 if(this != child && child.state == maximized)
3657 child.SetState(normal, false, 0);
3664 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3666 Window previous = parent.activeClient;
3667 parent.activeChild = this;
3668 if(!style.nonClient /*&& style.isActiveClient*/)
3672 if(style.isActiveClient)
3673 parent.activeClient = this;
3674 // Moved UpdateActiveDocument inside hidden check
3675 // To prevent activating previous window while creating a new one
3676 // (It was messing up the privateModule in the CodeEditor)
3677 parent.UpdateActiveDocument(previous);
3683 //if(!style.isRemote)
3685 if(rootWindow != this)
3687 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3688 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3690 else if(!guiApp.fullScreenMode)
3692 Window modalRoot = FindModal();
3693 if(!modalRoot) modalRoot = this;
3694 if(!modalRoot.isForegroundWindow)
3696 modalRoot.isForegroundWindow = true;
3697 // To check : Why is parent null?
3698 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3700 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3702 modalRoot.isForegroundWindow = false;
3707 if(result && real && (!style.inactive || moveInactive) && parent)
3709 Window last = parent.children.last;
3711 if(!style.stayOnTop)
3712 for(; last && last.style.stayOnTop; last = last.prev);
3714 parent.children.Move(this, last);
3716 // Definitely don't want that: why not?
3720 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3726 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3733 parent.activeChild = null;
3734 if(!style.nonClient /*&& style.isActiveClient*/)
3736 Window previous = parent.activeClient;
3737 if(style.isActiveClient)
3738 parent.activeClient = null;
3739 parent.UpdateActiveDocument(previous);
3743 if(this == guiApp.interimWindow)
3745 guiApp.interimWindow = null;
3746 if(guiApp.caretOwner)
3747 guiApp.caretOwner.UpdateCaret(false, false);
3749 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3756 if(!active || !swap)
3757 UpdateDecorations();
3759 swap.UpdateDecorations();
3761 if(active && rootWindow != this)
3762 ConsequentialMouseMove(false);
3769 // --- Input Messages ---
3770 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3772 static bool reEntrancy = false;
3773 if(reEntrancy) return;
3777 guiApp.cursorUpdate = true;
3778 if(guiApp.windowScrolling && !consequential)
3780 guiApp.windowScrolling.SetScrollPosition(
3781 (guiApp.windowScrolling.sbh) ?
3782 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3783 (guiApp.windowScrolling.sbv) ?
3784 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3786 if(guiApp.windowMoving)
3788 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3790 Window window = guiApp.windowMoving;
3792 int w = window.size.w;
3793 int h = window.size.h;
3798 rx = mouseX - guiApp.windowMovingStart.x;
3799 ry = mouseY - guiApp.windowMovingStart.y;
3802 window.GetDecorationsSize(&ew, &eh);
3804 if(guiApp.windowIsResizing)
3806 x = window.scrolledPos.x;
3807 y = window.scrolledPos.y;
3811 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3812 rx = guiApp.windowResizingBefore.w - aw;
3813 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3814 w = guiApp.windowResizingBefore.w - rx;
3818 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3819 ry = guiApp.windowResizingBefore.h - ah;
3820 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3821 ry = Max(ry, -guiApp.windowMovingBefore.y);
3822 h = guiApp.windowResizingBefore.h - ry;
3824 if(guiApp.resizeEndX)
3826 w = guiApp.windowResizingBefore.w + rx;
3829 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3837 w = Max(w, window.minSize.w);
3838 h = Max(h, window.minSize.h);
3839 w = Min(w, window.maxSize.w);
3840 h = Min(h, window.maxSize.h);
3842 if(!window.OnResizing(&w, &h))
3844 w = window.clientSize.w;
3845 h = window.clientSize.h;
3848 w = Max(w, window.skinMinSize.w);
3849 h = Max(h, window.skinMinSize.h);
3856 SNAPDOWN(w, textCellW);
3857 SNAPDOWN(h, textCellH);
3862 aw = Max(w,window.skinMinSize.w);
3863 rx = guiApp.windowResizingBefore.w - aw;
3864 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3865 w = guiApp.windowResizingBefore.w - rx;
3869 ah = Max(h,window.skinMinSize.h);
3870 ry = guiApp.windowResizingBefore.h - ah;
3871 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3872 ry = Max(ry, -guiApp.windowMovingBefore.y);
3873 h = guiApp.windowResizingBefore.h - ry;
3878 if(!guiApp.windowIsResizing || guiApp.resizeX)
3879 x = guiApp.windowMovingBefore.x + rx;
3880 if(!guiApp.windowIsResizing || guiApp.resizeY)
3881 y = guiApp.windowMovingBefore.y + ry;
3883 if(!guiApp.windowIsResizing)
3886 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3888 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3889 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3890 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3891 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3895 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3896 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3902 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3904 if(!window.OnMoving(&x, &y, w, h))
3906 x = window.scrolledPos.x;
3907 y = window.scrolledPos.y;
3913 SNAPDOWN(x, textCellW);
3914 SNAPDOWN(y, textCellH);
3917 if(!window.style.nonClient)
3919 if(!window.style.fixed /*|| window.style.isDocument*/)
3921 if(!window.style.dontScrollHorz)
3922 x += window.parent.scroll.x;
3923 if(!window.style.dontScrollVert)
3924 y += window.parent.scroll.y;
3928 // Break the anchors for moveable/resizable windows
3929 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3930 if(window.style.fixed)
3932 if(window.state == normal)
3934 window.normalAnchor = Anchor { left = x, top = y };
3935 window.normalSizeAnchor = SizeAnchor { { w, h } };
3936 window.anchored = false;
3940 window.stateAnchor = Anchor { left = x, top = y };
3941 window.stateSizeAnchor = SizeAnchor { { w, h } };
3943 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3944 // TOCHECK: Investigate why the following only redraws the scrollbars
3945 //window.Position(x, y, w, h, false, true, true, true, false, true);
3947 guiApp.movingLast.x = mouseX;
3948 guiApp.movingLast.y = mouseY;
3954 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3957 bool wasMoving = guiApp.windowMoving ? true : false;
3958 bool wasScrolling = guiApp.windowScrolling ? true : false;
3960 while(result && w != this)
3962 Window msgWindow = GetAtPosition(x,y, false, true, w);
3963 Window trueWindow = GetAtPosition(x,y, false, false, w);
3964 bool windowDragged = false;
3969 window = (w && !w.disabled) ? w : null;
3971 if(trueWindow) incref trueWindow;
3973 if(consequential) mods->isSideEffect = true;
3975 UpdateMouseMove(x, y, consequential);
3977 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3979 if(!guiApp.windowCaptured.isEnabled)
3980 guiApp.windowCaptured.ReleaseCapture();
3982 window = guiApp.windowCaptured;
3985 if(trueWindow && activate &&
3986 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3987 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3988 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3989 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3991 if(mods->alt && !mods->ctrl && !mods->shift)
3993 Window moved = trueWindow;
3994 for(moved = trueWindow; moved; moved = moved.parent)
3995 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4000 windowDragged = true;
4002 // Cancel the ALT menu toggling...
4003 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4008 if(window && activate &&
4009 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4010 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4011 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4012 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4014 Window modalWindow = window.FindModal();
4016 /*if(mods->alt && !mods->shift && !mods->ctrl)
4018 Window moved = window;
4019 for(moved = window; moved; moved = moved.parent)
4020 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4025 windowDragged = true;
4027 // Cancel the ALT menu toggling...
4028 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4034 Window activateWindow = modalWindow ? modalWindow : window;
4035 if(activateWindow && !activateWindow.isRemote)
4037 bool doActivation = true;
4038 //bool needToDoActivation = false;
4039 Window check = activateWindow;
4041 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4043 if(!check.style.inactive)
4045 //needToDoActivation = true;
4047 doActivation = false;
4052 if(!needToDoActivation)
4053 doActivation = false;
4056 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4057 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4059 // Let the OnLeftButtonDown do the activating instead
4060 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4068 incref activateWindow;
4069 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4071 delete activateWindow;
4075 if(activateWindow._refCount == 1)
4077 delete activateWindow;
4081 delete activateWindow;
4082 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4085 mods->isActivate = true;
4089 if(!modalWindow && window && !window.destroyed)
4091 if(!guiApp.windowCaptured || windowDragged)
4093 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4095 bool moving = ((window.state != maximized &&
4096 window.IsMouseMoving(
4097 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4098 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4100 if(!moving && window.IsMouseResizing(
4101 x - window.absPosition.x,
4102 y - window.absPosition.y,
4103 window.size.w, window.size.h,
4104 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4106 guiApp.windowIsResizing = true;
4107 guiApp.windowResizingBefore.w = window.size.w;
4108 guiApp.windowResizingBefore.h = window.size.h;
4110 if(guiApp.windowIsResizing || windowDragged || moving)
4113 guiApp.windowMoving = window;
4114 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4115 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4116 guiApp.windowMovingBefore.x = window.position.x;//s;
4117 guiApp.windowMovingBefore.y = window.position.y;//s;
4118 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4119 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4122 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4124 if(window.style.fixed &&
4126 window.IsMouseMoving(
4127 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4129 window.ShowSysMenu(x, y);
4133 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4135 if(window.sbv || window.sbh)
4138 guiApp.windowScrolling = window;
4139 guiApp.windowScrollingStart.x = x;
4140 guiApp.windowScrollingStart.y = y;
4141 guiApp.windowScrollingBefore.x = window.scroll.x;
4142 guiApp.windowScrollingBefore.y = window.scroll.y;
4145 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4147 if(window.style.hasMaximize &&
4148 window.IsMouseMoving(
4149 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4152 (window.state == maximized) ? normal : maximized, false, *mods);
4160 if(guiApp.windowMoving)
4162 if(guiApp.windowMoving.parent)
4164 if(guiApp.windowMoving.style.nonClient)
4165 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4167 guiApp.windowMoving.parent.SetMouseRangeToClient();
4171 window.UpdateDecorations();
4174 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4176 // Log("\n*** LEFT BUTTON UP ***\n");
4177 if(guiApp.windowMoving)
4178 guiApp.windowMoving.StopMoving();
4180 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4182 if(guiApp.windowScrolling)
4184 Window windowScrolling = guiApp.windowScrolling;
4185 guiApp.windowScrolling = null;
4186 windowScrolling.ReleaseCapture();
4190 if(!result || (window && window.destroyed)) window = null;
4192 if(window && window.FindModal())
4195 if(trueWindow && trueWindow.FindModal())
4203 msgWindow = GetAtPosition(x,y, true, false);
4205 msgWindow.SelectMouseCursor();
4208 if(guiApp.windowCaptured || trueWindow)
4210 Window prevWindow = guiApp.prevWindow;
4211 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4213 guiApp.prevWindow.mouseInside = false;
4214 guiApp.prevWindow = null;
4216 // Eventually fix this not to include captured?
4217 if(!prevWindow.OnMouseLeave(*mods))
4220 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4222 Box box = trueWindow.box;
4223 box.left += trueWindow.absPosition.x;
4224 box.right += trueWindow.absPosition.x;
4225 box.top += trueWindow.absPosition.y;
4226 box.bottom += trueWindow.absPosition.y;
4228 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4230 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4231 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4233 overX = Max(Min(overX, 32767),-32768);
4234 overY = Max(Min(overY, 32767),-32768);
4236 trueWindow.mouseInside = true;
4237 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4241 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4242 guiApp.prevWindow = trueWindow;
4244 guiApp.prevWindow = null;
4246 SelectMouseCursor();
4248 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4250 int clientX = x - (window.absPosition.x + window.clientStart.x);
4251 int clientY = y - (window.absPosition.y + window.clientStart.y);
4253 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4255 clientX = Max(Min(clientX, 32767),-32768);
4256 clientY = Max(Min(clientY, 32767),-32768);
4258 MouseMethod = (void *)window._vTbl[method];
4260 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4263 if(!MouseMethod(window, clientX, clientY, *mods))
4270 if(result && w && w.clickThrough && w.parent)
4275 if(!result || !w || !w.clickThrough)
4282 // --- Mouse cursor management ---
4284 bool KeyMessage(uint method, Key key, unichar character)
4289 if(guiApp.interimWindow)
4290 this = guiApp.interimWindow;
4293 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4297 if(!style.inactive || rootWindow != this)
4299 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4300 Window modalWindow = FindModal();
4301 Window interimMaster = master ? master.rootWindow : null;
4305 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4306 status = OnSysKeyDown(key, character);
4307 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4308 status = OnSysKeyHit(key, character);
4309 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4310 status = OnSysKeyUp(key, character);
4317 // Process Key Message for Internal UI Keyboard actions
4318 if(status && !destroyed && menuBar && state != minimized)
4321 if((SmartKey)key != alt)
4322 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4325 SmartKey sk = (SmartKey) key;
4326 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4328 status = menuBar.KeyMessage(method, key, character);
4333 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4334 menuBar.OnKeyHit(escape, 0);
4336 if(!menuBar.focus && guiApp.caretOwner)
4337 guiApp.caretOwner.UpdateCaret(true, false);
4340 if(!destroyed && status)
4342 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4346 case left: case up: case right: case down:
4347 if(guiApp.windowMoving == this)
4350 int w = guiApp.windowMoving.size.w;
4351 int h = guiApp.windowMoving.size.h;
4352 int x = guiApp.windowMoving.scrolledPos.x;
4353 int y = guiApp.windowMoving.scrolledPos.y;
4357 if(key == down || key == up)
4358 step = Max(step, textCellH);
4360 step = Max(step, textCellW);
4363 if(guiApp.windowIsResizing)
4367 case left: w-=step; break;
4368 case right: w+=step; break;
4369 case up: h-=step; break;
4370 case down: h+=step; break;
4377 case left: x-=step; break;
4378 case right: x+=step; break;
4379 case up: y-=step; break;
4380 case down: y+=step; break;
4384 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4385 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4387 if(!guiApp.windowIsResizing || guiApp.resizeX)
4388 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4390 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4392 if(!guiApp.windowIsResizing || guiApp.resizeY)
4393 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4395 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4397 guiApp.interfaceDriver.SetMousePosition(x, y);
4398 ConsequentialMouseMove(true);
4406 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4408 guiApp.windowMoving.StopMoving();
4409 ConsequentialMouseMove(false);
4417 ShowSysMenu(absPosition.x, absPosition.y);
4425 if(!destroyed && status && state != minimized)
4427 // Process all the way down the children
4428 if(activeChild && !activeChild.disabled)
4430 status = activeChild.KeyMessage(method, key, character);
4432 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4433 key.code != left && key.code != right && key.code != up && key.code != down)
4435 status = activeClient.KeyMessage(method, key, character);
4439 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4441 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4442 // && defaultControl != activeChild)
4444 delete previousActive;
4445 previousActive = activeChild;
4446 if(previousActive) incref previousActive;
4448 ConsequentialMouseMove(false);
4449 if((defaultControl.active ||
4450 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4451 defaultControl.KeyMessage(method, defaultKey, character);
4457 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4459 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4466 ShowSysMenu(absPosition.x, absPosition.y);
4473 if(this != guiApp.desktop)
4475 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4477 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4479 MenuMoveOrSize(key.shift, true);
4483 else if(guiApp.windowMoving)
4485 guiApp.windowMoving.StopMoving();
4486 ConsequentialMouseMove(false);
4494 if(!destroyed && status && state != minimized)
4496 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4500 case tab: case shiftTab:
4502 Window cycleParent = this;
4503 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4504 cycleParent = master.parent;
4506 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4508 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4510 Window child = cycleParent.activeChild;
4512 // Scroll the window to include the active control
4514 if(cycleParent.sbh && !child.style.dontScrollHorz)
4516 if(child.scrolledPos.x < 0)
4517 cycleParent.sbh.Action(Position,
4518 cycleParent.scroll.x + child.scrolledPos.x, 0);
4519 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4520 cycleParent.sbh.Action(Position,
4521 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4523 if(cycleParent.sbv && !child.style.dontScrollVert)
4525 if(child.scrolledPos.y < 0)
4526 cycleParent.sbv.Action(Position,
4527 cycleParent.scroll.y + child.scrolledPos.y, 0);
4528 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4529 cycleParent.sbv.Action(Position,
4530 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4533 cycleParent.ConsequentialMouseMove(false);
4539 case f6: case shiftF6:
4540 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4542 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4543 if(parent == guiApp.desktop)
4544 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4554 if(CycleChildren(key.shift, true, false, true))
4562 // mIRC Style Window Shortcuts
4563 case alt1: case alt2: case alt3: case alt4: case alt5:
4564 case alt6: case alt7: case alt8: case alt9: case alt0:
4569 for(document = children.first; document; document = document.next)
4571 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4573 if(document == activeChild)
4575 if(document.state == minimized)
4576 document.SetState(normal, false, key);
4579 document.SetState(minimized, false, key);
4580 CycleChildren(false, true, false);
4585 if(activeChild.state == maximized && document.style.hasMaximize)
4586 document.SetState(maximized, false, key);
4587 else if(document.state == minimized)
4588 document.SetState(normal, false, key);
4589 document.Activate();
4604 if(!destroyed && status)
4606 if(state == minimized)
4611 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4613 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4615 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4616 previousActive.ActivateEx(true, false, false, true, null, null);
4617 delete previousActive;
4623 if(!destroyed && status)
4625 status = ProcessHotKeys(method, key, character);
4627 if(!destroyed && status && !modalWindow && state != minimized)
4630 status = KeyMethod(this, key, character);
4631 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4632 status = OnKeyHit(key, character);
4633 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4635 bool result = false;
4638 case ctrlUp: case ctrlDown:
4639 if(sbv && !guiApp.windowScrolling)
4640 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4642 case wheelUp: case wheelDown:
4643 if(sbv && !guiApp.windowScrolling)
4645 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4646 // Do we want to do a consequential move regardless of result in this case?
4647 ConsequentialMouseMove(false);
4650 case ctrlPageUp: case ctrlPageDown:
4651 if(sbh && !guiApp.windowScrolling)
4652 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4657 ConsequentialMouseMove(false);
4662 if(status && !destroyed && menuBar && state != minimized)
4663 status = menuBar.KeyMessage(method, key, character);
4665 if(style.interim && /*destroyed && */status && interimMaster)
4667 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4668 status = interimMaster.KeyMessage(method, key, character);
4675 bool ProcessHotKeys(uint method, Key key, unichar character)
4680 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4681 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4682 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4684 Window hotKeyWindow = hotKey.window;
4685 Window parent = hotKeyWindow.parent;
4686 Window prevActiveWindow = activeChild;
4687 // For when sys buttons are placed inside the menu bar
4688 if(parent && parent._class == class(PopupMenu))
4689 parent = parent.parent;
4691 // 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
4692 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4695 if(prevActiveWindow) incref prevActiveWindow;
4696 incref hotKeyWindow;
4697 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4698 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4701 delete hotKeyWindow;
4702 delete prevActiveWindow;
4706 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4707 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4708 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4710 // ********* WORKING ON THIS ***********
4711 if(prevActiveWindow && !guiApp.interimWindow)
4712 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4715 else if(hotKeyWindow.style.inactive)
4716 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4718 delete prevActiveWindow;
4719 delete hotKeyWindow;
4720 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4721 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4725 if(status && tabCycle)
4728 for(child = children.first; child; child = child.next)
4730 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4741 // --- Windows and graphics initialization / termination ---
4742 bool SetupRoot(void)
4746 // Setup relationship with outside world (bb root || !bb)
4747 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4748 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4752 tempExtents = new0 Extent[4];
4757 /*if(guiApp.fullScreenMode)
4758 rootWindow = guiApp.desktop;
4760 //rootWindow = parent.created ? parent.rootWindow : null;
4761 rootWindow = parent.rootWindow;
4764 against = &parent.box;
4766 against = &parent.clientArea;
4769 for(child = children.first; child; child = child.next)
4772 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4775 bool Setup(bool positionChildren)
4777 bool result = false;
4780 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4782 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4783 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4785 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4787 // This was here, is it really needed?
4788 //guiApp.interfaceDriver.ActivateRootWindow(this);
4792 displaySystem = DisplaySystem {};
4793 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4795 delete displaySystem;
4800 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4801 if(display.Create(displaySystem, windowHandle))
4808 // Sometimes icon does not show up on Windows XP if we set here...
4809 // guiApp.interfaceDriver.SetIcon(this, icon);
4811 else if(this != guiApp.desktop)
4813 display = rootWindow ? rootWindow.display : null;
4819 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4820 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4822 for(child = children.first; child; child = child.next)
4824 if(child.created && !child.Setup(false))
4830 bool SetupDisplay(void)
4832 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4833 if(is3D) return Window3D_SetupDisplay(this); else
4840 class_data void ** pureVTbl;
4842 bool LoadGraphics(bool creation, bool resetAnchors)
4844 bool result = false;
4845 bool success = false;
4847 WindowState stateBackup = state;
4849 if(((subclass(Window))_class).pureVTbl)
4851 if(_vTbl == _class._vTbl)
4853 _vTbl = ((subclass(Window))_class).pureVTbl;
4858 for(m = 0; m < _class.vTblSize; m++)
4860 if(_vTbl[m] == _class._vTbl[m])
4861 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4865 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4867 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4869 _vTbl = _class._vTbl;
4874 for(m = 0; m < _class.vTblSize; m++)
4876 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4877 _vTbl[m] = _class._vTbl[m];
4882 if(guiApp.fullScreenMode || this != guiApp.desktop)
4884 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4890 display.Lock(false);
4891 if(rootWindow == this)
4893 // Set Color Palette
4894 display.SetPalette(palette, true);
4898 if(guiApp.fullScreenMode && this == guiApp.desktop)
4903 for(c=0; c<SystemCursor::enumSize; c++)
4904 if(!guiApp.systemCursors[c].bitmap)
4906 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4907 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4908 if(guiApp.systemCursors[c].bitmapName)
4910 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4911 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4912 if(guiApp.systemCursors[c].bitmap)
4913 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4918 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4920 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4921 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4923 cursor.bitmap.paletteShades = cursor.paletteShades;
4927 guiApp.cursorUpdate = true;
4930 ConsequentialMouseMove(false);
4936 // Load Window Graphic Resources
4939 if(usedFont == setFont || usedFont == window.systemFont)
4940 RemoveResource(usedFont);
4943 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4946 RemoveResource(systemFont);
4949 RemoveResource(captionFont);
4951 for(ptr = resources.first; ptr; ptr = ptr.next)
4953 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4956 AddResource(setFont);
4958 AddResource(systemFont);
4960 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4967 //if(master && master.font)
4968 if(parent && parent.font)
4972 faceName = parent.font.faceName,
4973 size = parent.font.size,
4974 bold = parent.font.bold,
4975 italic = parent.font.italic,
4976 underline = parent.font.underline
4978 //font = parent.font;
4979 watch(parent) { font { } };
4982 font = guiApp.currentSkin.SystemFont();
4989 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4990 AddResource(captionFont);
4992 if(OnLoadGraphics())
4998 //SetScrollLineStep(sbStep.x, sbStep.y);
5000 if(this != guiApp.desktop)
5004 normalAnchor = anchor;
5005 normalSizeAnchor = sizeAnchor;
5008 // Break the anchors for moveable/resizable windows
5010 if(style.fixed && style.isDocument)
5012 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5024 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5025 stateSizeAnchor = SizeAnchor {};
5030 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5035 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5036 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5039 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5043 stateAnchor = normalAnchor;
5044 stateSizeAnchor = normalSizeAnchor;
5047 position = Point { };
5048 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5059 if(Position(x, y, w, h, true, false, true, true, true, true))
5061 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5064 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5081 success = result = true;
5084 if(!creation && result)
5086 // Load menu bar first because sys buttons are on it...
5089 if(!menuBar.LoadGraphics(false, resetAnchors))
5095 for(child = children.first; child; child = child.next)
5097 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5104 CreateSystemChildren();
5108 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5111 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5116 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5117 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5120 // Do this here to avoid problems on Windows
5121 if(stateBackup == maximized)
5122 property::state = maximized;
5126 void UnloadGraphics(bool destroyWindows)
5130 // Free children's graphics
5131 for(child = children.first; child; child = child.next)
5132 child.UnloadGraphics(destroyWindows);
5135 display.Lock(false);
5138 if(guiApp.fullScreenMode && this == guiApp.desktop)
5143 for(c=0; c<SystemCursor::enumSize; c++)
5144 if(guiApp.systemCursors[c].bitmap)
5145 delete guiApp.systemCursors[c].bitmap;
5147 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5148 delete cursor.bitmap;
5150 guiApp.cursorBackground.Free();
5153 if(display && display.displaySystem)
5157 for(ptr = resources.first; ptr; ptr = ptr.next)
5161 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5166 // Free window graphics
5169 // Free skin graphics
5170 if(rootWindow == this)
5172 DisplaySystem displaySystem = display.displaySystem;
5175 display.driverData = null;
5176 display.displaySystem = null;
5180 if(displaySystem && !displaySystem.numDisplays && !is3D)
5181 delete displaySystem;
5190 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5191 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5193 if(this == guiApp.desktop || parent == guiApp.desktop)
5195 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5196 guiApp.interfaceDriver.DestroyRootWindow(this);
5200 // --- Window Hiding ---
5202 void SetVisibility(bool state)
5204 bool visible = (style.hidden || !created) ? false : state;
5205 if(visible != this.visible)
5209 this.visible = visible;
5210 for(child = children.first; child; child = child.next)
5211 child.SetVisibility(visible);
5213 ConsequentialMouseMove(false);
5214 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5218 // --- Windows and graphics initialization / termination ---
5220 bool DisplayModeChanged(void)
5222 bool result = false;
5223 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5225 guiApp.modeSwitching = true;
5226 UnloadGraphics(false);
5228 if(LoadGraphics(false, false))
5230 guiApp.modeSwitching = false;
5235 // --- Window updates system ---
5237 void UpdateDirty(Box updateBox)
5239 if(!manageDisplay) { OnRedraw(null);return; }
5242 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5245 if(display.flags.flipping)
5248 rootWindow.UpdateDisplay();
5251 UpdateBackDisplay(updateBox);
5253 if(guiApp.fullScreenMode)
5255 guiApp.cursorUpdate = true;
5256 guiApp.PreserveAndDrawCursor();
5258 if(guiApp.fullScreenMode)
5259 guiApp.RestoreCursorBackground();
5265 // This function is strictly called as a result of system window activation
5266 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5269 Window interimMaster = null;
5270 Window interimWindow = guiApp.interimWindow;
5271 if(interimWindow && interimWindow.master)
5272 interimMaster = interimWindow.master.rootWindow;
5274 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5275 // SetState(normal, false, 0);
5276 SetState(lastState, false, 0);
5278 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5282 /* WTH is this doing here?
5283 while(swap && swap.activeChild)
5285 swap = swap.activeChild;
5288 // TESTING THIS BEFORE...
5289 if(interimWindow && this == interimMaster)
5293 // Window interimSwap = this;
5294 Window menuBar = this.menuBar;
5295 if(menuBar && interimWindow.master == menuBar)
5298 while(interimSwap && interimSwap.activeChild)
5299 interimSwap = interimSwap.activeChild;
5301 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5302 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5304 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5305 //result = ActivateEx(true, true, false, activateRoot, window, null);
5310 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5311 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5313 if(interimWindow == this && interimMaster && !active)
5315 while(interimMaster && interimMaster.interim && interimMaster.master)
5317 // printf("Going up one master %s\n", interimMaster._class.name);
5318 interimMaster = interimMaster.master.rootWindow;
5320 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5321 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5327 bool DestroyEx(int64 returnCode)
5330 Timer timer, nextTimer;
5332 OldLink prevOrder = null;
5333 Window client = null;
5335 if(parent) stopwatching(parent, font);
5337 // if(window.modalSlave) return false;
5338 if(destroyed || !created)
5345 OldLink slave = master.slaves.FindLink(this);
5346 master.slaves.Delete(slave);
5349 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5355 this.returnCode = (DialogResult)returnCode;
5357 AcquireInput(false);
5362 master.hotKeys.Delete(hotKey);
5366 if(guiApp.prevWindow == this)
5368 guiApp.prevWindow = null;
5371 if(guiApp.caretOwner == this)
5373 guiApp.interfaceDriver.SetCaret(0,0,0);
5374 UpdateCaret(false, true);
5375 guiApp.caretEnabled = false;
5380 parent.childrenCycle.Remove(cycle);
5384 OldLink tmpPrev = order.prev;
5385 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5386 prevOrder = tmpPrev;
5389 client = tmpPrev ? tmpPrev.data : null;
5390 if(client == this) { client = null; break; }
5391 if(client && (client.style.hidden || client.destroyed || !client.created))
5392 tmpPrev = client.order.prev;
5396 prevOrder = tmpPrev;
5401 // If this window can be an active client, make sure the next window we activate can also be one
5402 if(!style.nonClient && style.isActiveClient)
5404 tmpPrev = prevOrder;
5407 client = tmpPrev ? tmpPrev.data : null;
5408 if(client == this) { client = null; break; }
5409 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5410 tmpPrev = client.order.prev;
5414 prevOrder = tmpPrev;
5418 if(client && client.style.hidden) client = null;
5420 // parent.childrenOrder.Remove(order);
5423 if(parent && style.isActiveClient && visible)
5425 if(state == minimized) parent.numIcons--;
5426 parent.numPositions--;
5429 // TESTING THIS HERE!
5433 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5434 // to create a window inside a rootwindow that's being destroyed)
5435 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5437 if(master && !master.destroyed /*&&
5438 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5440 if(master.defaultControl == this)
5441 master.defaultControl = null;
5444 parent.OnChildAddedOrRemoved(this, true);
5445 if(parent && !parent.destroyed /*&&
5446 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5448 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5450 if(order && prevOrder && prevOrder.data != this && active)
5452 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5454 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5455 if(parent.activeClient == this)
5457 parent.activeClient = null;
5458 parent.UpdateActiveDocument(null);
5463 if(guiApp.interimWindow == this)
5466 PropagateActive(false, null, &goOn, true);
5470 //if(window.parent.activeChild == window)
5471 parent.activeChild = null;
5472 if(!style.nonClient /*&& style.isActiveClient*/)
5474 Window previous = parent.activeClient;
5475 if(style.isActiveClient)
5476 parent.activeClient = null;
5477 parent.UpdateActiveDocument(previous);
5482 else if(parent.activeClient == this)
5484 parent.activeClient = client;
5485 parent.UpdateActiveDocument(this);
5489 if(guiApp.interimWindow == this)
5491 guiApp.interimWindow = null;
5492 if(guiApp.caretOwner)
5494 Window desktop = guiApp.desktop;
5495 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5496 guiApp.caretOwner.UpdateCaret(false, false);
5501 if(_isModal && master && master.modalSlave == this)
5502 master.modalSlave = null;
5506 if(!guiApp.caretOwner && parent.caretSize)
5508 guiApp.caretOwner = parent;
5509 parent.UpdateCaret(false, false);
5510 parent.Update(null);
5513 // Why was this commented out?
5514 GetRidOfVirtualArea();
5520 dirtyArea.Free(null);
5521 dirtyBack.Free(null);
5522 scrollExtent.Free(null);
5524 /* ATTEMPTING TO MOVE THAT ABOVE
5533 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5534 for(;(child = window.children.first);)
5536 for(; child && (child.destroyed || !child.created); child = child.next);
5545 UnloadGraphics(true);
5548 delete previousActive;
5551 // statusBar = null;
5554 if(master && !master.destroyed)
5556 //master.NotifyDestroyed(this, this.returnCode);
5557 NotifyDestroyed(master, this, this.returnCode);
5560 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5562 nextTimer = timer.next;
5563 if(timer.window == this)
5565 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5566 // timer.window = null;
5572 if(this == guiApp.windowMoving)
5575 if(guiApp.windowCaptured == this)
5577 //guiApp.windowCaptured = null;
5579 if(rootWindow != this && rootWindow)
5580 rootWindow.ConsequentialMouseMove(false);
5588 //for(child = children.first; next = child ? child.next : null, child; child = next)
5589 for(;(child = children.first); )
5591 for(; child && (child.destroyed || !child.created); child = child.next);
5601 /* // MOVED THIS UP...
5604 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5605 for(;(child = window.children.first); )
5607 for(; child && (child.destroyed || !child.created); child = child.next);
5616 while((slave = slaves.first))
5618 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5620 ((Window)slave.data).DestroyEx(0);
5625 if(guiApp.caretOwner == this)
5626 guiApp.caretOwner = null;
5628 sysButtons[0] = null;
5629 sysButtons[1] = null;
5630 sysButtons[2] = null;
5633 if(rootWindow != this)
5635 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5638 box.left -= parent.clientStart.x;
5639 box.top -= parent.clientStart.y;
5640 box.right -= parent.clientStart.x;
5641 box.bottom -= parent.clientStart.y;
5643 if(parent) parent.Update(box);
5648 OldLink slave = master.slaves.FindVoid(this);
5649 master.slaves.Delete(slave);
5655 parent.children.Remove(this);
5660 //autoCreate = false;
5663 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5664 if(((subclass(Window))_class).pureVTbl)
5666 if(_vTbl == _class._vTbl)
5668 _vTbl = ((subclass(Window))_class).pureVTbl;
5673 for(m = 0; m < _class.vTblSize; m++)
5675 if(_vTbl[m] == _class._vTbl[m])
5676 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5685 void SetStateEx(WindowState newState, bool activate)
5688 WindowState prevState = state;
5692 if(prevState != newState)
5693 lastState = prevState;
5695 if(rootWindow != this || !nativeDecorations || !windowHandle)
5697 if(style.isActiveClient && !style.hidden && prevState == minimized)
5700 // This block used to be at the end of the function... moved it for flicker problem in X
5701 // ------------------------------------------------------
5705 stateAnchor = normalAnchor;
5706 stateSizeAnchor = normalSizeAnchor;
5709 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5710 stateSizeAnchor = SizeAnchor {};
5714 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5717 byte * idBuffer = new0 byte[size];
5719 for(child = parent.children.first; child; child = child.next)
5721 if(child != this && child.state == minimized)
5723 if(child.iconID > size - 2)
5725 idBuffer = renew0 idBuffer byte[size*2];
5726 memset(idBuffer + size, 0, size);
5729 idBuffer[child.iconID] = (byte)bool::true;
5732 for(c = 0; c<size; c++)
5737 if(style.isActiveClient && !style.hidden)
5740 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5741 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5745 // TOCHECK: Why was this here?
5746 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5747 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5748 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5750 Position(x, y, w, h, true, true, true, true, false, true);
5752 if(!style.inactive && !style.interim && this == parent.activeClient)
5753 parent.UpdateActiveDocument(null);
5756 CreateSystemChildren();
5757 // ------------------------------------------------------
5760 int GetPositionID(Window forChild)
5764 byte * idBuffer = new0 byte[size];
5767 for(child = children.first; child; child = child.next)
5769 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5771 if(child.positionID > size - 2)
5773 idBuffer = renew0 idBuffer byte[size*2];
5774 memset(idBuffer + size, 0, size);
5777 idBuffer[child.positionID] = (byte)bool::true;
5780 for(c = 0; c<size; c++)
5787 // --- Window related graphics ---
5789 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5791 palette = newPalette;
5792 if(rootWindow.display)
5793 rootWindow.display.SetPalette(palette, colorMatch);
5796 public bool AcquireInput(bool acquired)
5799 if(acquiredInput != acquired)
5801 if(active || (!visible && creationActivation == activate))
5802 result = AcquireInputEx(acquired);
5807 acquiredInput = acquired ? result : !result;
5812 void ListChildren(ListBox listBox)
5816 for(child = children.first; child; child = child.next)
5818 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5820 DataRow row = listBox.AddRow();
5821 row.tag = (int64)child;
5822 child.FigureCaption(caption);
5823 row.SetData(null, caption);
5828 void UpdateVisual(Box extent)
5830 if(guiApp.driver != null)
5832 if(guiApp.fullScreenMode && guiApp.desktop.display)
5834 guiApp.desktop.mutex.Wait();
5835 guiApp.desktop.display.Lock(true);
5838 if(guiApp.desktop.active)
5840 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5842 if(guiApp.desktop.display.flags.flipping)
5843 guiApp.desktop.Update(null);
5844 guiApp.desktop.UpdateDisplay();
5845 guiApp.cursorUpdate = true;
5847 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5849 guiApp.PreserveAndDrawCursor();
5850 // guiApp.desktop.display.ShowScreen();
5851 guiApp.cursorUpdate = false;
5852 guiApp.desktop.dirty = false;
5853 guiApp.RestoreCursorBackground();
5857 guiApp.desktop.display.Unlock();
5858 guiApp.desktop.mutex.Release();
5862 Window rootWindow = this.rootWindow;
5863 rootWindow.mutex.Wait();
5868 guiApp.SignalEvent();
5871 guiApp.waitMutex.Wait();
5872 guiApp.interfaceDriver.Lock(rootWindow);
5873 if(!rootWindow.style.hidden && rootWindow.dirty)
5875 if(rootWindow.display)
5877 rootWindow.UpdateDisplay();
5878 //rootWindow.display.ShowScreen(null);
5880 rootWindow.dirty = false;
5882 guiApp.interfaceDriver.Unlock(rootWindow);
5883 guiApp.waitMutex.Release();
5886 rootWindow.mutex.Release();
5891 void UnlockDisplay(void)
5893 guiApp.interfaceDriver.Unlock(rootWindow);
5896 void LockDisplay(void)
5898 guiApp.interfaceDriver.Lock(rootWindow);
5901 Surface GetSurface(Box box)
5903 return Redraw((box == null) ? this.box : box);
5906 void SetMousePosition(int x, int y)
5908 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5912 void IntegrationActivate(bool active)
5914 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5916 isForegroundWindow = true;
5917 ActivateEx(active, active, false, false, null, null);
5918 isForegroundWindow = false;
5923 Window QueryCapture(void)
5925 return guiApp.windowCaptured;
5928 int GetDocumentID(void)
5932 byte * idBuffer = new0 byte[size];
5935 for(child = children.first; child; child = child.next)
5937 // TO CHECK: Do we want a documentID when we already have a file name?
5938 if(child.style.isDocument && !child.fileName)
5940 if(child.documentID-1 > size - 2)
5942 idBuffer = renew0 idBuffer byte[size*2];
5943 memset(idBuffer + size, 0, size);
5946 idBuffer[child.documentID-1] = 1;
5949 for(c = 0; c<size; c++)
5957 void SetInitSize(Size size)
5960 sizeAnchor.size = size;
5961 normalSizeAnchor = sizeAnchor;
5963 // Break the anchors for moveable/resizable windows
5964 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5966 stateAnchor = normalAnchor;
5967 stateSizeAnchor = normalSizeAnchor;
5969 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5970 Position(x,y, w, h, true, true, true, true, false, true);
5974 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5976 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5978 guiApp.windowIsResizing = resize;
5979 guiApp.windowMoving = this;
5980 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5981 if(guiApp.windowIsResizing)
5983 guiApp.windowMovingStart.x += size.w - 1;
5984 guiApp.windowMovingStart.y += size.h - 1;
5986 guiApp.windowMovingBefore = scrolledPos;
5987 guiApp.windowResizingBefore = size;
5988 guiApp.windowMoving.UpdateDecorations();
5989 if(guiApp.windowIsResizing)
5990 guiApp.resizeEndX = guiApp.resizeEndY = true;
5992 if(setCursorPosition)
5993 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5997 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5998 guiApp.windowMovingStart.x += x - absPosition.x;
5999 guiApp.windowMovingStart.y += y - absPosition.y;
6002 if(guiApp.windowMoving)
6004 if(guiApp.windowMoving.style.nonClient)
6005 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6007 guiApp.windowMoving.parent.SetMouseRangeToClient();
6012 if(this == rootWindow)
6013 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6021 bool result = false;
6025 else if(guiApp && guiApp.driver != null)
6027 void * systemParent = null;
6028 OldLink slaveHolder;
6030 bool visible = !style.hidden;
6034 systemParent = parent;
6035 parent = guiApp.desktop;
6037 last = parent ? parent.children.last : null;
6039 if((parent && parent != guiApp.desktop && !parent.created) ||
6040 (master && master != guiApp.desktop && !master.created))
6044 stopwatching(parent, font);
6047 property::parent = guiApp.desktop;
6048 if(!master) master = parent;
6050 if(_isModal && master.modalSlave)
6051 property::master = master.modalSlave;
6055 parent.children.Remove(this);
6058 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6059 if(slaveHolder.data == this)
6061 master.slaves.Delete(slaveHolder);
6066 if(parent == guiApp.desktop && !mutex)
6069 if(style.isDocument)
6072 parent.numDocuments--;
6073 documentID = parent.GetDocumentID();
6076 if(!style.stayOnTop)
6077 for(; last && last.style.stayOnTop; last = last.prev);
6079 parent.children.Insert((last == this) ? null : last, this);
6080 //parent.children.Add(this);
6083 dispDriver = parent.dispDriver;
6086 master.modalSlave = this;
6088 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6093 master.slaves.Add(slaveHolder = OldLink { data = this });
6098 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6100 if(style.isDefault && !master.defaultControl)
6101 master.defaultControl = this;
6103 stateAnchor = normalAnchor = anchor;
6104 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6106 // TOCHECK: Why is this here?
6107 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6108 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6110 this.visible = false;
6111 style.hidden = true;
6114 // autoCreate = true;
6122 if(parent == guiApp.desktop)
6123 Log("LoadGraphics %s\n", caption);
6125 if(LoadGraphics(true, false))
6133 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6140 if(style.hasMenuBar /*&& menu*/)
6146 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6147 interim = false, inactive = true, nonClient = true, size.h = 24
6155 // Create the system buttons
6156 CreateSystemChildren();
6158 UpdateActiveDocument(null);
6160 if(style.isDocument)
6164 MenuItem item = menu.FindItem(MenuFileSave, 0);
6165 if(item) item.disabled = !modifiedDocument && fileName;
6170 if(parent == guiApp.desktop)
6171 Log("Preemptive SetState %s\n", caption);
6174 // Preemptive Set State to ensure proper anchoring
6175 SetStateEx(state, false);
6177 style.hidden = true;
6183 for(child = children.first; child; child = next)
6186 if(!child.created && (child.autoCreate || child.wasCreated))
6193 for(link = slaves.first; link; link = next)
6195 Window slave = link.data;
6197 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6200 // Things might have happened that invalidated 'next'...
6201 // Start over the search for slaves to create.
6202 // (Added this to fix crash with Stacker & Toolbar)
6203 next = slaves.first;
6212 if(parent == guiApp.desktop)
6213 Log("Real SetState %s\n", caption);
6216 if(isActiveClient && visible)
6218 parent.numPositions--;
6219 if(state == minimized) parent.numIcons--;
6222 parent.OnChildAddedOrRemoved(this, false);
6224 // Real set state & activate for proper display & activation
6225 property::visible = visible;
6226 // SetState(state & 0x00000003, true, 0);
6227 guiApp.interfaceDriver.SetIcon(this, icon);
6232 /*if(rootWindow == this)
6233 guiApp.interfaceDriver.ActivateRootWindow(this);
6235 if(creationActivation == activate)
6236 ActivateEx(true, false, true, true, null, null);
6237 else if(creationActivation == flash)
6242 rootWindow.ConsequentialMouseMove(false);
6253 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6259 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6261 //style.hidden = true; // !visible;
6262 style.hidden = !visible;
6263 if(master.modalSlave == this)
6264 master.modalSlave = null;
6271 void WriteCaption(Surface surface, int x, int y)
6274 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6277 void Update(Box region)
6283 rootWindow = this.rootWindow;
6285 // rootWindow.mutex.Wait();
6286 if(!destroyed && visible && display)
6291 // Testing this to avoid repetitve full update to take time...
6292 if(dirtyArea.count == 1)
6294 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6295 if(item.box.left <= box.left &&
6296 item.box.top <= box.top &&
6297 item.box.right >= box.right &&
6298 item.box.bottom >= box.bottom)
6300 rootWindow.dirty = true;
6305 if(display.flags.flipping && !rootWindow.dirty)
6307 if(this == rootWindow)
6311 rootWindow.Update(null);
6316 rootWindow.dirty = true;
6321 realBox.left += clientStart.x;
6322 realBox.top += clientStart.y;
6323 realBox.right += clientStart.x;
6324 realBox.bottom += clientStart.y;
6330 if(realBox.right >= realBox.left &&
6331 realBox.bottom >= realBox.top)
6333 // if(!rootWindow.fullRender)
6334 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6336 for(child = children.first; child; child = child.next)
6341 box.left -= child.absPosition.x - absPosition.x;
6342 box.top -= child.absPosition.y - absPosition.y;
6343 box.right -= child.absPosition.x - absPosition.x;
6344 box.bottom -= child.absPosition.y - absPosition.y;
6345 if(box.right >= child.box.left && box.left <= child.box.right &&
6346 box.bottom >= child.box.top && box.top <= child.box.bottom)
6348 box.left -= child.clientStart.x;
6349 box.top -= child.clientStart.y;
6350 box.right -= child.clientStart.x;
6351 box.bottom -= child.clientStart.y;
6357 realBox.left += absPosition.x - rootWindow.absPosition.x;
6358 realBox.top += absPosition.y - rootWindow.absPosition.y;
6359 realBox.right += absPosition.x - rootWindow.absPosition.x;
6360 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6361 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6364 else if(this == guiApp.desktop)
6367 for(window = children.first; window; window = window.next)
6373 Box childBox = region;
6375 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6376 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6377 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6378 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6380 window.Update(childBox);
6383 window.Update(null);
6388 // rootWindow.mutex.Release();
6395 if(guiApp.windowCaptured != this)
6397 if(guiApp.windowCaptured)
6401 //Logf("Captured %s (%s)\n", caption, class.name);
6402 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6403 guiApp.windowCaptured = this;
6409 bool Destroy(int64 code)
6414 if(!destroyed && !CloseConfirmation(false)) return false;
6418 // TOCHECK: Should autoCreate be set to false here?
6429 void Move(int x, int y, int w, int h)
6431 normalAnchor = Anchor { left = x, top = y };
6432 normalSizeAnchor = SizeAnchor { size = { w, h } };
6434 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6436 if(destroyed) return;
6438 stateAnchor = normalAnchor;
6439 stateSizeAnchor = normalSizeAnchor;
6441 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6442 Position(x,y, w, h, true, true, true, true, false, true);
6446 DialogResult Modal(void)
6452 // FIXES MEMORY LEAK IF Create() FAILED
6458 void SetScrollArea(int width, int height, bool snapToStep)
6460 bool resize = false;
6463 int stepX = sbStep.x, stepY = sbStep.y;
6464 // Needed to make snapped down position match the skin's check of client area
6465 // against realvirtual
6468 SNAPDOWN(stepX, textCellW);
6469 SNAPDOWN(stepY, textCellH);
6470 stepX = Max(stepX, textCellW);
6471 stepY = Max(stepY, textCellH);
6473 if(scrollFlags.snapX)
6474 SNAPUP(width, stepX);
6475 if(scrollFlags.snapY)
6476 SNAPUP(height, stepY);
6479 reqScrollArea.w = width;
6480 reqScrollArea.h = height;
6481 noAutoScrollArea = (width > 0 || height > 0);
6483 UpdateScrollBars(true, true);
6486 void SetScrollPosition(int x, int y)
6489 sbh.Action(setPosition, x, 0);
6493 int seen = clientSize.w, total = reqScrollArea.w;
6495 if(scrollFlags.snapX)
6496 SNAPDOWN(seen, sbStep.x);
6498 if(!total) total = seen;
6499 range = total - seen + 1;
6500 range = Max(range, 1);
6502 if(x >= range) x = range - 1;
6504 if(scrollFlags.snapX)
6505 SNAPUP(x, sbStep.x);
6508 OnHScroll(setPosition, x, 0);
6512 SNAPDOWN(x, textCellW);
6518 sbv.Action(setPosition, y, 0);
6522 int seen = clientSize.h, total = reqScrollArea.h;
6525 if(scrollFlags.snapY)
6526 SNAPDOWN(seen, sbStep.y);
6528 if(!total) total = seen;
6529 range = total - seen + 1;
6530 range = Max(range, 1);
6532 if(y >= range) y = range - 1;
6534 if(scrollFlags.snapY)
6535 SNAPUP(y, sbStep.y);
6538 OnVScroll(setPosition, y, 0);
6541 SNAPDOWN(y, textCellH);
6546 UpdateCaret(false, false);
6549 void SetScrollLineStep(int stepX, int stepY)
6555 SNAPDOWN(stepX, textCellW);
6556 SNAPDOWN(stepY, textCellH);
6557 stepX = Max(stepX, textCellW);
6558 stepY = Max(stepY, textCellH);
6561 sbh.lineStep = stepX;
6563 sbv.lineStep = stepY;
6566 void SetState(WindowState newState, bool activate, Modifiers mods)
6570 if(state == newState || OnStateChange(newState, mods))
6572 WindowState prevState = state;
6576 // This used to be at the end of the brackets... moved for X, testing...
6577 // This has the effect of activating the window through the system...
6578 if(rootWindow == this)
6579 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6581 SetStateEx(newState, activate);
6583 if(rootWindow == this && !rootWindow.nativeDecorations)
6585 int x = position.x, y = position.y;
6588 x -= guiApp.desktop.absPosition.x;
6589 y -= guiApp.desktop.absPosition.y;
6591 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6595 //state = prevState;
6597 if(state != maximized && style.hasMaximize)
6600 for(child = parent.children.first; child; child = child.next)
6602 if(child != this && child.state == maximized)
6603 child.SetStateEx(normal, false);
6607 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6608 parent.UpdateScrollBars(true, true);
6611 // Do we really need this stuff here?
6612 // Shouldn't the Activate stuff take care of it?
6613 if(parent.rootWindow == parent && style)
6616 parent.FigureCaption(caption);
6617 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6618 parent.UpdateDecorations();
6622 rootWindow.ConsequentialMouseMove(false);
6629 BitmapResource GetIcon(SkinBitmap iconID)
6631 return guiApp.currentSkin.GetBitmap(iconID);
6634 void SetMouseRange(Box range)
6636 if(range || guiApp.fullScreenMode)
6641 clip.left = range.left + absPosition.x + clientStart.x;
6642 clip.top = range.top + absPosition.y + clientStart.y;
6643 clip.right = range.right + absPosition.x + clientStart.x;
6644 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6648 clip.left = guiApp.desktop.box.left;
6649 clip.top = guiApp.desktop.box.top;
6650 clip.right = guiApp.desktop.box.right;
6651 clip.bottom = guiApp.desktop.box.bottom;
6653 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6656 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6659 void SetMouseRangeToClient(void)
6661 if(guiApp.fullScreenMode || this != guiApp.desktop)
6663 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6664 box.Clip(clientArea);
6668 SetMouseRange(null);
6671 void SetMouseRangeToWindow(void)
6673 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6674 if(this == guiApp.desktop)
6675 SetMouseRangeToClient();
6680 // x, y: Desktop Coordinates
6681 void ShowSysMenu(int x, int y)
6684 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6687 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6688 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6692 menu, $"Move", m, NotifySelect = MenuWindowMove,
6693 disabled = !style.fixed || state == maximized
6697 menu, $"Size", s, NotifySelect = MenuWindowSize,
6698 disabled = !style.sizable || state != normal
6702 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6703 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6707 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6708 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6712 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6713 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6715 MenuDivider { menu };
6718 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6719 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6721 windowMenu.Create();
6726 ActivateEx(true, true, true, true, null, null);
6729 void MakeActive(void)
6731 ActivateEx(true, false, true, false, null, null);
6734 void SoftActivate(void)
6736 if(guiApp.desktop.active)
6742 void Deactivate(void)
6744 ActivateEx(false, true, true, true, null, null);
6749 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6752 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6754 bool result = false;
6755 if(activeChild && activeChild.cycle)
6757 Window modalWindow, child = activeChild;
6758 if(!clientOnly /*&& parent.tabCycle*/)
6760 Window next = child;
6763 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6767 if(parent && parent.CycleChildren(backward, false, true, true))
6775 next = next.cycle.prev.data;
6777 next = next.cycle.next.data;
6778 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6783 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6784 parent.tabCycle && parent.CycleChildren(backward, false, false))
6788 if(tabCycleOnly && !tabCycle) return false;
6795 child = child.cycle.prev.data;
6797 child = child.cycle.next.data;
6798 if(child == child.parent.activeChild)
6800 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6803 modalWindow = child.FindModal();
6806 // Scroll the window to include the active control
6807 if(sbh && !child.style.dontScrollHorz)
6809 if(child.scrolledPos.x < 0)
6810 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6811 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6812 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6814 if(sbv && !child.style.dontScrollVert)
6816 if(child.scrolledPos.y < 0)
6817 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6818 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6819 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6823 child = modalWindow ? modalWindow : child;
6824 child.ActivateEx(true, true, true, true, null, null);
6825 if(child.tabCycle && child.childrenCycle.first)
6826 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6834 ConsequentialMouseMove(false);
6838 void AddResource(Resource resource)
6842 ResPtr ptr { resource = resource };
6846 // Load Graphics here if window is created already
6847 if(/*created && */display)
6849 display.Lock(false);
6850 ptr.loaded = display.displaySystem.LoadResource(resource);
6854 // Temporary hack to load font right away for listbox in dropbox ...
6855 else if(master && master.display)
6857 master.display.Lock(false);
6858 master.display.displaySystem.LoadResource(resource);
6859 master.display.Unlock();
6865 void RemoveResource(Resource resource)
6870 for(ptr = resources.first; ptr; ptr = ptr.next)
6872 if(ptr.resource == resource)
6878 // Unload Graphics here if window is created already
6879 if(/*created && */display)
6883 display.Lock(false);
6884 display.displaySystem.UnloadResource(resource, ptr.loaded);
6890 resources.Delete(ptr);
6895 void SetCaret(int x, int y, int size)
6902 if(active && !style.interim)
6904 if(visible || !guiApp.caretOwner)
6905 guiApp.caretOwner = size ? this : null;
6907 UpdateCaret(false, false);
6910 guiApp.interfaceDriver.SetCaret(0,0,0);
6911 UpdateCaret(false, true);
6912 guiApp.caretEnabled = false;
6915 else if(style.inactive && active)
6917 guiApp.interfaceDriver.SetCaret(0,0,0);
6918 UpdateCaret(false, true);
6919 guiApp.caretEnabled = false;
6924 void Scroll(int x, int y)
6926 bool opaque = !style.drawBehind || background.a;
6927 if(opaque && display && display.flags.scrolling)
6929 Box box = clientArea;
6930 box.left += clientStart.x;
6931 box.top += clientStart.y;
6932 box.right += clientStart.x;
6933 box.bottom += clientStart.y;
6935 //scrollExtent.Free(null);
6936 scrollExtent.AddBox(box);
6937 scrolledArea.x += x;
6938 scrolledArea.y += y;
6940 //scrollExtent.Free();
6941 //scrollExtent.AddBox(clientArea);
6942 //scrollExtent.Offset(clientStart.x, clientStart.y);
6943 //scrolledArea.x = x;
6944 //scrolledArea.y = y;
6950 rootWindow.dirty = true;
6953 void ReleaseCapture()
6955 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6957 Window oldCaptured = guiApp.windowCaptured;
6958 guiApp.windowCaptured = null;
6959 guiApp.prevWindow = null;
6962 //guiApp.Log("Released Capture\n");
6964 guiApp.interfaceDriver.SetMouseCapture(null);
6966 //oldCaptured.OnMouseCaptureLost();
6969 oldCaptured.ConsequentialMouseMove(false);
6974 private void _SetCaption(char * format, va_list args)
6981 char caption[MAX_F_STRING];
6982 vsnprintf(caption, sizeof(caption), format, args);
6983 caption[sizeof(caption)-1] = 0;
6985 this.caption = CopyString(caption);
6990 firewatchers caption;
6994 /*deprecated*/ void SetText(char * format, ...)
6997 va_start(args, format);
6998 _SetCaption(format, args);
7002 void SetCaption(char * format, ...)
7005 va_start(args, format);
7006 _SetCaption(format, args);
7010 bool Grab(Bitmap bitmap, Box box, bool decorations)
7012 bool result = false;
7013 if(display || this == guiApp.desktop)
7015 Box clip = {MININT, MININT, MAXINT, MAXINT};
7021 clip.Clip(clientArea);
7023 clip.Clip(this.box);
7025 if(rootWindow != this)
7027 clip.left += absPosition.y;
7028 clip.top += absPosition.y;
7029 clip.right += absPosition.x;
7030 clip.bottom += absPosition.y;
7033 clip.left += decorations ? 0 : clientStart.x;
7034 clip.top += decorations ? 0 : clientStart.y;
7035 clip.right += decorations ? 0 : clientStart.x;
7036 clip.bottom += decorations ? 0 : clientStart.y;
7038 if(display && display.flags.flipping)
7040 rootWindow.Update(null);
7041 rootWindow.UpdateDisplay();
7048 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7049 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7053 result = display.Grab(bitmap, clip.left, clip.top,
7054 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7056 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7058 if(!bitmap.Convert(null, pixelFormat888, null))
7065 void GetMousePosition(int * x, int * y)
7067 int mouseX = 0, mouseY = 0;
7068 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7071 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7072 if(this != guiApp.desktop)
7074 mouseX -= absPosition.x + clientStart.x;
7075 mouseY -= absPosition.y + clientStart.y;
7082 DialogResult DoModal()
7084 DialogResult returnCode = 0;
7085 int terminated = terminateX;
7088 while(!destroyed && guiApp.driver != null)
7090 if(terminateX != terminated)
7092 terminated = terminateX;
7093 guiApp.desktop.Destroy(0);
7094 if(guiApp.desktop.created)
7097 //printf("Resetting terminate X to 0\n");
7103 guiApp.UpdateDisplay();
7104 if(!guiApp.ProcessInput(false))
7107 returnCode = this.returnCode;
7120 return !destroyed && guiApp.driver != null && terminateX < 2;
7123 DialogResult DoModalEnd()
7125 DialogResult returnCode = this.returnCode;
7130 // --- Window manipulation ---
7131 /*bool GetDisabled()
7133 bool disabled = this.disabled;
7135 for(window = this; (window = window.master); )
7146 // --- Mouse Manipulation ---
7147 void GetNCMousePosition(int * x, int * y)
7149 GetMousePosition(x, y);
7150 if(x) *x += clientStart.x;
7151 if(y) *y += clientStart.y;
7154 // --- Carets manipulation ---
7155 void GetCaretPosition(Point caretPos)
7157 caretPos = this.caretPos;
7160 int GetCaretSize(void)
7165 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7171 bool CloseConfirmation(bool parentClosing)
7184 if(!OnClose(parentClosing))
7187 // If you want to skip this, simply set modifiedDocument to false in OnClose
7188 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7190 DialogResult dialogRes;
7193 sprintf(message, $"Save changes to %s?", fileName);
7195 sprintf(message, $"Save changes to Untitled %d?", documentID);
7197 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7199 if(dialogRes == yes)
7201 // TOFIX: Precomp error if brackets are taken out
7202 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7204 else if(dialogRes == cancel)
7210 for(slave = slaves.first; slave; slave = slave.next)
7212 Window w = slave.data;
7213 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7215 // ((Window)slave.data).CloseConfirmation(true);
7224 for(child = children.first; child; child = child.next)
7225 if(child.master != this && !child.CloseConfirmation(true))
7235 // Static methods... move them somewhere else?
7236 void ::RestoreCaret()
7238 if(guiApp.caretOwner)
7239 guiApp.caretOwner.UpdateCaret(false, false);
7242 void ::FreeMouseRange()
7244 guiApp.interfaceDriver.SetMouseRange(null, null);
7248 bool MenuFileClose(MenuItem selection, Modifiers mods)
7250 Window document = activeChild;
7252 document.Destroy(0);
7256 bool MenuFileExit(MenuItem selection, Modifiers mods)
7262 bool MenuFileSave(MenuItem selection, Modifiers mods)
7266 fileMonitor.fileName = null;
7269 if(OnSaveFile(fileName))
7271 //if(OnFileModified != Window::OnFileModified)
7274 fileMonitor.fileName = fileName;
7280 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7281 DialogResult answer = dialog.Modal();
7283 if(answer != yes) return (bool)answer;
7286 return MenuFileSaveAs(selection, mods);
7289 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7291 DialogResult result = (DialogResult)bool::true;
7292 FileDialog fileDialog = saveDialog;
7295 fileDialog = FileDialog {};
7300 fileDialog.filePath = fileName;
7303 char filePath[MAX_FILENAME];
7304 sprintf(filePath, "Untitled %d", documentID);
7305 fileDialog.filePath = filePath;
7307 fileMonitor.fileName = null;
7309 fileDialog.type = save;
7310 fileDialog.text = $"Save As";
7314 fileDialog.master = master.parent ? master : this;
7315 if(fileDialog.Modal() == ok)
7317 char * filePath = fileDialog.filePath;
7319 if(OnSaveFile(filePath))
7322 property::fileName = filePath;
7323 NotifySaved(master, this, filePath);
7328 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7329 DialogResult answer = dialog.Modal();
7344 //if(OnFileModified != Window::OnFileModified && fileName)
7347 fileMonitor.fileName = fileName;
7351 return (bool)result; // Actually returning result from Yes/NoCancel message box
7354 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7356 Window document = activeChild;
7358 for(document = children.first; document; document = next)
7360 next = document.next;
7361 if(document.style.isDocument || document.fileName)
7362 document.MenuFileSave(selection, mods);
7367 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7371 for(document = children.first; document; document = document.next)
7372 //if(document.style.isDocument && document.state == minimized)
7373 if(document.style.isActiveClient && document.state == minimized)
7374 document.SetState(minimized, false, mods);
7378 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7380 Window document = activeChild;
7383 Window firstDocument = null;
7385 OldLink cycle = document.cycle.prev;
7390 if(child.style.isActiveClient && !child.style.hidden)
7394 firstDocument = child;
7395 if(child.state == minimized)
7396 child.SetState(minimized, false, mods);
7399 child.positionID = id++;
7400 child.SetState(normal, false, mods);
7401 child.anchor.left.type = cascade;
7404 child.normalSizeAnchor = *&child.sizeAnchor;
7405 child.normalAnchor = child.anchor;
7407 // Break the anchors for moveable/resizable windows
7408 if(child.style.fixed)
7410 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7412 (*&child.normalAnchor).left = x;
7413 (*&child.normalAnchor).top = y;
7414 (*&child.normalAnchor).right.type = none;
7415 (*&child.normalAnchor).bottom.type = none;
7417 child.normalSizeAnchor.isClientW = false;
7418 child.normalSizeAnchor.isClientH = false;
7419 child.normalSizeAnchor.size.w = w;
7420 child.normalSizeAnchor.size.h = h;
7421 child.anchored = false;
7424 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7426 child.stateAnchor = child.normalAnchor;
7427 child.stateSizeAnchor = child.normalSizeAnchor;
7429 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7430 child.Position(x, y, w, h, true, true, true, true, false, false);
7435 last = children.last;
7436 if(!child.style.stayOnTop)
7437 for(; last && last.style.stayOnTop; last = last.prev);
7438 children.Move(child, last);
7439 childrenOrder.Move(child.order, childrenOrder.last);
7441 if(cycle == document.cycle) break;
7445 firstDocument.Activate();
7450 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7457 // Close all closes all active clients, not all documents
7458 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7460 Window next, document;
7462 for(document = children.first; document; document = next)
7464 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7465 if(document.style.isActiveClient)
7466 if(!document.Destroy(0) && !document.style.hidden)
7472 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7474 if(style.hasMaximize && state != maximized)
7475 SetState(maximized, 0, 0);
7479 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7481 if(style.hasMinimize && state != minimized)
7483 SetState(minimized, 0, 0);
7484 parent.CycleChildren(false, true, false, true);
7489 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7491 MenuMoveOrSize(false, selection ? true : false);
7495 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7497 CycleChildren(false, true, false, true);
7501 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7503 CycleChildren(true, true, false, true);
7507 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7509 MenuMoveOrSize(true, true);
7513 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7516 SetState(normal, 0, 0);
7520 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7523 int64 id = selection.id;
7524 OldLink cycle = activeClient.cycle;
7526 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7529 Window sibling = cycle.data;
7530 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7538 document = cycle.data;
7539 document.Activate();
7541 //if(activeChild.state == maximized)
7542 // document.SetState(maximized, false, mods);
7543 //else if(document.state == minimized)
7544 // document.SetState(normal, false, mods);
7548 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7550 stayOnTop = !style.stayOnTop;
7554 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7556 Window document = activeChild;
7559 Window firstDocument = null;
7560 OldLink cycle = document.cycle;
7564 Window child = cycle.data;
7565 if(child.style.isActiveClient && !child.style.hidden)
7567 if(!firstDocument) firstDocument = child;
7568 if(child.state == minimized)
7569 child.SetState(minimized, false, mods);
7572 child.positionID = id++;
7573 child.SetState(normal, false, mods);
7574 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7576 child.anchor.left.type = hTiled;
7579 child.normalSizeAnchor = *&child.sizeAnchor;
7580 child.normalAnchor = child.anchor;
7582 // Break the anchors for moveable/resizable windows
7583 if(child.style.fixed)
7585 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7587 (*&child.normalAnchor).left = x;
7588 (*&child.normalAnchor).top = y;
7589 (*&child.normalAnchor).right.type = none;
7590 (*&child.normalAnchor).bottom.type = none;
7591 child.normalSizeAnchor.isClientW = false;
7592 child.normalSizeAnchor.isClientH = false;
7593 child.normalSizeAnchor.size.w = w;
7594 child.normalSizeAnchor.size.h = h;
7595 child.anchored = false;
7598 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7600 child.stateAnchor = child.normalAnchor;
7601 child.stateSizeAnchor = child.normalSizeAnchor;
7603 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7604 child.Position(x,y, w, h, true, true, true, true, false, true);
7609 if((cycle = cycle.next) == document.cycle) break;
7612 firstDocument.Activate();
7617 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7619 Window document = activeChild;
7622 Window firstDocument = null;
7624 OldLink cycle = document.cycle;
7629 //if(child.style.isDocument)
7630 if(child.style.isActiveClient && !child.style.hidden)
7632 if(!firstDocument) firstDocument = child;
7633 if(child.state == minimized)
7634 child.SetState(minimized, false, mods);
7637 child.positionID = id++;
7638 child.SetState(normal, false, mods);
7639 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7641 child.anchor.left.type = vTiled;
7644 child.normalSizeAnchor = *&child.sizeAnchor;
7645 child.normalAnchor = child.anchor;
7647 // Break the anchors for moveable/resizable windows
7648 if(child.style.fixed)
7650 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7652 (*&child.normalAnchor).left = x;
7653 (*&child.normalAnchor).top = y;
7654 (*&child.normalAnchor).right.type = none;
7655 (*&child.normalAnchor).bottom.type = none;
7656 child.normalSizeAnchor.isClientW = false;
7657 child.normalSizeAnchor.isClientH = false;
7658 child.normalSizeAnchor.size.w = w;
7659 child.normalSizeAnchor.size.h = h;
7660 child.anchored = false;
7663 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7665 child.stateAnchor = child.normalAnchor;
7666 child.stateSizeAnchor = child.normalSizeAnchor;
7668 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7669 child.Position(x,y, w, h, true, true, true, true, false, true);
7674 if((cycle = cycle.next) == document.cycle) break;
7677 firstDocument.Activate();
7682 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7684 WindowList dialog { master = this };
7685 Window document = (Window)dialog.Modal();
7688 if(activeChild.state == maximized)
7689 document.SetState(maximized, false, mods);
7690 else if(document.state == minimized)
7691 document.SetState(normal, false, mods);
7692 document.Activate();
7698 virtual bool OnCreate(void);
7699 virtual void OnDestroy(void);
7700 virtual void OnDestroyed(void);
7701 virtual bool OnClose(bool parentClosing);
7702 virtual bool OnStateChange(WindowState state, Modifiers mods);
7703 virtual bool OnPostCreate(void);
7704 virtual bool OnMoving(int *x, int *y, int w, int h);
7705 virtual bool OnResizing(int *width, int *height);
7706 virtual void OnResize(int width, int height);
7707 virtual void OnPosition(int x, int y, int width, int height);
7708 virtual bool OnLoadGraphics(void);
7709 virtual void OnApplyGraphics(void);
7710 virtual void OnUnloadGraphics(void);
7711 virtual void OnRedraw(Surface surface);
7712 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7713 virtual void OnActivateClient(Window client, Window previous);
7714 virtual bool OnKeyDown(Key key, unichar ch);
7715 virtual bool OnKeyUp(Key key, unichar ch);
7716 virtual bool OnKeyHit(Key key, unichar ch);
7717 virtual bool OnSysKeyDown(Key key, unichar ch);
7718 virtual bool OnSysKeyUp(Key key, unichar ch);
7719 virtual bool OnSysKeyHit(Key key, unichar ch);
7720 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7721 virtual bool OnMouseLeave(Modifiers mods);
7722 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7723 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7724 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7725 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7726 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7727 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7728 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7729 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7730 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7731 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7732 virtual void OnMouseCaptureLost(void);
7733 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7734 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7735 virtual void OnDrawOverChildren(Surface surface);
7736 virtual bool OnFileModified(FileChange fileChange, char * param);
7737 virtual bool OnSaveFile(char * fileName);
7739 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7740 // Note: A 'client' would refer to isActiveClient, rather than
7741 // being confined to the 'client area' (nonClient == false)
7742 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7743 virtual void OnChildVisibilityToggled(Window child, bool visible);
7744 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7746 // Skins Virtual Functions
7747 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7748 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7749 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7754 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7755 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7756 virtual bool IsMouseMoving(int x, int y, int w, int h)
7760 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7764 virtual void UpdateNonClient();
7765 virtual void SetBox(Box box);
7766 virtual bool IsInside(int x, int y)
7768 return box.IsPointInside({x, y});
7770 virtual bool IsOpaque()
7772 return (!style.drawBehind || background.a == 255);
7776 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7777 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7778 virtual void Window::NotifySaved(Window window, char * filePath);
7783 property Window parent
7785 property_category $"Layout"
7788 if(value || guiApp.desktop)
7791 Window oldParent = parent;
7792 Anchor anchor = this.anchor;
7794 if(value && value.IsDescendantOf(this)) return;
7795 if(value && value == this)
7797 if(!value) value = guiApp.desktop;
7799 if(value == oldParent) return;
7801 if(!master || (master == this.parent && master == guiApp.desktop))
7802 property::master = value;
7806 parent.children.Remove(this);
7810 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7811 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7812 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7813 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7817 last = value.children.last;
7819 if(style.isDocument)
7822 parent.numDocuments--;
7823 documentID = value.GetDocumentID();
7826 if(style.isActiveClient && !style.hidden)
7828 if(parent && parent != guiApp.desktop && !(style.hidden))
7830 if(state == minimized) parent.numIcons--;
7831 parent.numPositions--;
7835 if(!style.stayOnTop)
7836 for(; last && last.style.stayOnTop; last = last.prev);
7838 value.children.Insert(last, this);
7840 // *** NEW HERE: ***
7842 parent.childrenCycle.Delete(cycle);
7844 parent.childrenOrder.Delete(order);
7847 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7848 // Should something else be done?
7849 if(parent && parent.activeChild == this)
7850 parent.activeChild = null;
7851 if(parent && parent.activeClient == this)
7852 parent.activeClient = null;
7858 int x = position.x, y = position.y, w = size.w, h = size.h;
7862 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7863 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7865 vpw = value.clientSize.w;
7866 vph = value.clientSize.h;
7872 else if(style.fixed)
7874 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7875 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7878 anchor = this.anchor;
7880 if(anchor.left.type == offset) anchor.left.distance = x;
7881 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7882 if(anchor.top.type == offset) anchor.top.distance = y;
7883 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7884 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7885 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7886 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7887 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7888 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7889 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7891 if(!anchor.left.type && !anchor.right.type)
7893 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7894 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7896 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7897 if(!anchor.top.type && !anchor.bottom.type)
7899 anchor.vert.distance = (y + h / 2) - (vph / 2);
7900 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7902 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7905 parent.OnChildAddedOrRemoved(this, false);
7911 parent.childrenCycle.Insert(
7912 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7913 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7915 cycle = OldLink { data = this });
7916 parent.childrenOrder.Insert(
7917 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7918 order = OldLink { data = this });
7921 if(!style.hidden && style.isActiveClient)
7923 positionID = parent.GetPositionID(this);
7924 parent.numPositions++;
7925 if(state == minimized) parent.numIcons--;
7928 // *** FONT INHERITANCE ***
7929 if(!setFont && oldParent)
7930 stopwatching(oldParent, font);
7934 RemoveResource(systemFont);
7937 // TESTING WITH WATCHERS:
7938 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7939 // usedFont = setFont ? setFont : (systemFont);
7943 if(guiApp.currentSkin)
7945 systemFont = guiApp.currentSkin.SystemFont();
7948 usedFont = systemFont;
7949 AddResource(systemFont);
7957 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7966 if(value.rootWindow && value.rootWindow.display && rootWindow)
7968 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7969 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7972 UnloadGraphics(false);
7975 LoadGraphics(false, false);
7978 if(value.rootWindow != rootWindow)
7979 DisplayModeChanged();
7983 scrolledPos.x = MININT; // Prevent parent update
7985 bool anchored = this.anchored;
7986 property::anchor = anchor;
7987 this.anchored = anchored;
7992 if(guiApp.currentSkin)
7993 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7995 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7996 Position(x, y, w, h, true, true, true, true, false, true);
8001 // else parent = value;
8003 oldParent.OnChildAddedOrRemoved(this, true);
8006 get { return parent; }
8009 property Window master
8011 property_category $"Behavior"
8014 //if(this == value) return;
8015 if(value && value.IsSlaveOf(this)) return;
8021 OldLink slaveHolder;
8022 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8023 if(slaveHolder.data == this)
8025 master.slaves.Delete(slaveHolder);
8032 value.slaves.Add(OldLink { data = this });
8037 master.hotKeys.Remove(hotKey);
8038 value.hotKeys.Add(hotKey);
8041 if(master && master.defaultControl == this)
8042 master.defaultControl = null;
8044 if(style.isDefault && !value.defaultControl)
8045 value.defaultControl = this;
8050 get { return master ? master : parent; }
8053 property char * caption
8055 property_category $"Appearance"
8062 caption = new char[strlen(value)+1];
8064 strcpy(caption, value);
8069 get { return caption; }
8074 property_category $"Behavior"
8083 master.hotKeys.Add(hotKey = HotKeySlot { });
8087 hotKey.window = this;
8092 master.hotKeys.Delete(hotKey);
8097 get { return hotKey ? hotKey.key : 0; }
8100 property Color background
8102 property_category $"Appearance"
8105 background.color = value;
8110 if(this == rootWindow)
8111 guiApp.interfaceDriver.SetRootWindowColor(this);
8114 get { return background.color; }
8117 property Percentage opacity
8119 property_category $"Appearance"
8122 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8123 drawBehind = (background.a == 255) ? false : true;
8125 get { return background.a / 255.0f; }
8128 property Color foreground
8130 property_category $"Appearance"
8138 get { return foreground; }
8141 property BorderStyle borderStyle
8143 property_category $"Appearance"
8146 if(!((BorderBits)value).fixed)
8148 style.hasClose = false;
8149 style.hasMaximize = false;
8150 style.hasMinimize = false;
8151 nativeDecorations = false;
8153 style.borderBits = value;
8157 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8159 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8160 Position(x, y, w, h, true, true, true, true, false, true);
8161 CreateSystemChildren();
8164 get { return (BorderStyle)style.borderBits; }
8167 property Size minClientSize
8169 property_category $"Layout"
8170 set { minSize = value; }
8171 get { value = minSize; }
8174 property Size maxClientSize
8176 property_category $"Layout"
8177 set { maxSize = value; }
8178 get { value = maxSize; }
8181 property bool hasMaximize
8183 property_category $"Window Style"
8186 style.hasMaximize = value;
8187 if(value) { style.fixed = true; style.contour = true; }
8191 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8193 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8194 Position(x, y, w, h, true, true, true, true, false, true);
8196 CreateSystemChildren();
8199 get { return style.hasMaximize; }
8202 property bool hasMinimize
8204 property_category $"Window Style"
8207 style.hasMinimize = value;
8208 if(value) { style.fixed = true; style.contour = true; }
8212 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8214 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8215 Position(x, y, w, h, true, true, true, true, false, true);
8217 CreateSystemChildren();
8220 get { return style.hasMinimize; }
8223 property bool hasClose
8225 property_category $"Window Style"
8228 style.hasClose = value;
8229 if(value) { style.fixed = true; style.contour = true; }
8233 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8234 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8235 Position(x, y, w, h, true, true, true, true, false, true);
8236 CreateSystemChildren();
8239 get { return style.hasClose; }
8242 property bool nonClient
8244 property_category $"Layout"
8247 style.nonClient = value;
8249 style.stayOnTop = true;
8251 get { return style.nonClient; }
8254 property bool inactive
8256 property_category $"Behavior"
8261 // *** NEW HERE: ***
8265 parent.childrenCycle.Delete(cycle);
8267 parent.childrenOrder.Delete(order);
8274 active = false; // true;
8275 if(parent.activeChild == this)
8276 parent.activeChild = null;
8277 if(parent.activeClient == this)
8278 parent.activeClient = null;
8287 parent.childrenCycle.Insert(
8288 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8289 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8291 cycle = OldLink { data = this });
8293 parent.childrenOrder.Insert(
8294 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8295 order = OldLink { data = this });
8298 style.inactive = value;
8300 get { return style.inactive; }
8303 property bool clickThrough
8305 property_category $"Behavior"
8306 set { style.clickThrough = value; }
8307 get { return style.clickThrough; }
8310 property bool isRemote
8312 property_category $"Behavior"
8313 set { style.isRemote = value; }
8314 get { return style.isRemote; }
8317 property bool noCycle
8319 property_category $"Behavior"
8320 set { style.noCycle = value; }
8321 get { return style.noCycle; }
8324 property bool isModal
8326 property_category $"Behavior"
8327 set { style.modal = value; }
8328 get { return style.modal; }
8331 property bool interim
8333 property_category $"Behavior"
8334 set { style.interim = value; }
8335 get { return style.interim; }
8338 property bool tabCycle
8340 property_category $"Behavior"
8341 set { style.tabCycle = value; }
8342 get { return style.tabCycle; }
8345 property bool isDefault
8347 property_category $"Behavior"
8355 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8356 if(sibling != this && sibling.style.isDefault)
8357 sibling.style.isDefault = false;*/
8358 if(master.defaultControl)
8359 master.defaultControl.style.isDefault = false;
8360 master.defaultControl = this;
8362 else if(master.defaultControl == this)
8363 master.defaultControl = null;
8367 style.isDefault = value;
8369 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8371 get { return style.isDefault; }
8374 property bool drawBehind
8376 property_category $"Window Style"
8377 set { style.drawBehind = value; }
8378 get { return style.drawBehind; }
8381 property bool hasMenuBar
8383 property_category $"Window Style"
8393 if(created && !menuBar)
8400 anchor = Anchor { top = 23, left = 1, right = 1 },
8402 inactive = true, nonClient = true
8407 else if(created && menuBar)
8412 style.hasMenuBar = value;
8414 get { return style.hasMenuBar; }
8417 property bool hasStatusBar
8419 property_category $"Window Style"
8426 statusBar = StatusBar { this };
8434 style.hasStatusBar = value;
8436 get { return style.hasStatusBar; }
8438 property bool stayOnTop
8440 property_category $"Window Style"
8445 if(created && !style.stayOnTop)
8447 if(rootWindow == this)
8448 guiApp.interfaceDriver.OrderRootWindow(this, true);
8449 else if(parent.children.last != this)
8451 parent.children.Move(this, parent.children.last);
8455 style.stayOnTop = true;
8459 if(created && style.stayOnTop)
8461 if(rootWindow == this)
8462 guiApp.interfaceDriver.OrderRootWindow(this, false);
8469 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8470 order && ((Window)order.data).style.stayOnTop;
8471 order = (order == parent.childrenOrder.first) ? null : order.prev);
8472 last = order ? order.data : null;
8476 for(last = parent.children.last;
8477 last && last.style.stayOnTop;
8481 parent.children.Move(this, last);
8485 style.stayOnTop = false;
8488 get { return style.stayOnTop; }
8493 property_category $"Window Style"
8503 if(menuBar && !value)
8510 if(!menuBar && style.hasMenuBar && value)
8514 this, menu = value, isMenuBar = true,
8515 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8516 inactive = true, nonClient = true
8520 UpdateActiveDocument(null);
8523 get { return menu; }
8526 property FontResource font
8528 property_category $"Appearance"
8530 isset { return setFont ? true : false; }
8535 if(value && !setFont) { stopwatching(parent, font); }
8536 else if(!value && setFont)
8542 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8551 RemoveResource(setFont);
8556 RemoveResource(systemFont);
8563 AddResource(setFont);
8566 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8569 systemFont = guiApp.currentSkin.SystemFont();
8571 usedFont = systemFont;
8572 AddResource(systemFont);
8580 get { return usedFont; }
8583 property SizeAnchor sizeAnchor
8585 property_category $"Layout"
8588 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8589 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8590 sizeAnchor.isClientW != sizeAnchor.isClientH;
8597 normalSizeAnchor = sizeAnchor;
8599 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8601 stateAnchor = normalAnchor;
8602 stateSizeAnchor = normalSizeAnchor;
8604 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8605 Position(x,y, w, h, true, true, true, true, false, true);
8612 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8613 sizeAnchor.isClientW,
8614 sizeAnchor.isClientH
8621 property_category $"Layout"
8624 Anchor thisAnchor = anchor;
8625 SizeAnchor thisSizeAnchor = sizeAnchor;
8626 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8627 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8628 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8629 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8630 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8631 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8637 sizeAnchor.isClientW = false;
8638 sizeAnchor.isClientH = false;
8639 sizeAnchor.size = value;
8641 normalSizeAnchor = sizeAnchor;
8643 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8645 stateAnchor = normalAnchor;
8646 stateSizeAnchor = normalSizeAnchor;
8648 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8649 Position(x, y, w, h, true, true, true, true, false, true);
8650 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8653 get { value = size; }
8656 property Size clientSize
8658 property_category $"Layout"
8661 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8662 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8663 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8668 sizeAnchor.isClientW = true;
8669 sizeAnchor.isClientH = true;
8670 sizeAnchor.size = value;
8672 normalSizeAnchor = sizeAnchor;
8674 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8676 stateAnchor = normalAnchor;
8677 stateSizeAnchor = normalSizeAnchor;
8679 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8680 Position(x,y, w, h, true, true, true, true, false, true);
8683 get { value = clientSize; }
8686 property Size initSize { get { value = sizeAnchor.size; } };
8688 property Anchor anchor
8690 property_category $"Layout"
8691 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8697 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8699 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8700 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8702 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8704 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8705 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8709 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8711 anchor.left.distance = 0;
8712 anchor.horz.type = 0;
8714 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8716 anchor.top.distance = 0;
8717 anchor.vert.type = 0;
8726 normalAnchor = anchor;
8728 // Break the anchors for moveable/resizable windows
8729 /*if(style.fixed ) //&& value.left.type == cascade)
8731 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8733 this.anchor = normalAnchor = Anchor { left = x, top = y };
8734 normalSizeAnchor = SizeAnchor { { w, h } };
8737 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8739 stateAnchor = normalAnchor;
8740 stateSizeAnchor = normalSizeAnchor;
8742 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8743 Position(x, y, w, h, true, true, true, true, false, true);
8752 get { value = this ? anchor : Anchor { }; }
8755 property Point position
8757 property_category $"Layout"
8760 if(value == null) return;
8762 anchor.left = value.x;
8763 anchor.top = value.y;
8764 anchor.right.type = none;
8765 anchor.bottom.type = none;
8770 normalAnchor = anchor;
8772 // Break the anchors for moveable/resizable windows
8776 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8778 normalAnchor.left = x;
8779 normalAnchor.top = y;
8780 normalAnchor.right.type = none;
8781 normalAnchor.bottom.type = none;
8782 normalSizeAnchor.size.width = w;
8783 normalSizeAnchor.size.height = h;
8787 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8789 stateAnchor = normalAnchor;
8790 stateSizeAnchor = normalSizeAnchor;
8792 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8793 Position(x,y, w, h, true, true, true, true, false, true);
8797 get { value = position; }
8800 property bool disabled
8802 property_category $"Behavior"
8805 if(this && disabled != value)
8812 get { return (bool)disabled; }
8815 property bool isEnabled
8820 for(parent = this; parent; parent = parent.parent)
8827 property WindowState state
8829 property_category $"Behavior"
8830 set { SetState(value, false, 0); }
8831 get { return this ? state : 0; }
8834 property bool visible
8836 property_category $"Behavior"
8839 if(this && !value && !style.hidden && parent)
8841 bool wasActiveChild = parent.activeChild == this;
8842 Window client = null;
8844 style.hidden = true;
8845 if(style.isActiveClient)
8847 parent.numPositions--;
8848 if(state == minimized) parent.numIcons--;
8853 OldLink prevOrder = null;
8855 if(rootWindow == this)
8856 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8859 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8862 box.left -= parent.clientStart.x;
8863 box.top -= parent.clientStart.y;
8864 box.right -= parent.clientStart.x;
8865 box.bottom -= parent.clientStart.y;
8869 if(_isModal && master && master.modalSlave == this)
8870 master.modalSlave = null;
8874 OldLink tmpPrev = order.prev;
8875 client = tmpPrev ? tmpPrev.data : null;
8876 if(client && !client.style.hidden && !client.destroyed && client.created)
8877 prevOrder = tmpPrev;
8880 client = tmpPrev ? tmpPrev.data : null;
8881 if(client == this) { client = null; break; }
8882 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8884 tmpPrev = client.order.prev;
8889 prevOrder = tmpPrev;
8894 // If this window can be an active client, make sure the next window we activate can also be one
8895 if(!style.nonClient && style.isActiveClient)
8897 tmpPrev = prevOrder;
8900 client = tmpPrev ? tmpPrev.data : null;
8901 if(client == this) { client = null; break; }
8902 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8904 tmpPrev = client.order.prev;
8909 prevOrder = tmpPrev;
8913 if(client && client.style.hidden) client = null;
8917 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8919 if(order && prevOrder && prevOrder.data != this)
8920 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8922 ActivateEx(false, false, false, true, null, null);
8924 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8925 if(parent.activeClient == this)
8927 parent.activeClient = null;
8928 parent.UpdateActiveDocument(null);
8931 else if(parent.activeClient == this)
8933 parent.activeClient = client;
8934 parent.UpdateActiveDocument(this);
8937 // *** Not doing this anymore ***
8940 parent.childrenCycle.Delete(cycle);
8942 parent.childrenOrder.Delete(order);
8947 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8952 else if(this && value && style.hidden)
8954 style.hidden = false;
8957 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8958 if(rootWindow == this)
8959 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8961 if(_isModal && master)
8962 master.modalSlave = this;
8964 if(style.isActiveClient)
8966 positionID = parent.GetPositionID(this);
8967 parent.numPositions++;
8968 if(state == minimized) parent.numIcons++;
8971 // *** NOT DOING THIS ANYMORE ***
8973 if(!(style.inactive))
8975 if(!(style.noCycle))
8977 cycle = parent.childrenCycle.AddAfter(
8978 (parent.activeChild && parent.activeChild.cycle) ?
8979 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8982 order = parent.childrenOrder.AddAfter(
8983 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8990 if(true || !parent.activeChild)
8991 ActivateEx(true, false, true, true, null, null);
8993 if(creationActivation == activate)
8994 ActivateEx(true, false, true, true, null, null);
8995 else if(creationActivation == flash && !object)
8998 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
9002 ConsequentialMouseMove(false);
9008 style.hidden = !value;
9011 get { return (style.hidden || !setVisible) ? false : true; }
9014 property bool isDocument
9016 property_category $"Document"
9017 set { style.isDocument = value; }
9018 get { return style.isDocument; }
9021 property bool mergeMenus
9023 property_category $"Window Style"
9024 set { mergeMenus = value; }
9025 get { return (bool)mergeMenus; }
9028 property bool hasHorzScroll
9030 property_category $"Window Style"
9035 if(!style.hasHorzScroll && created)
9037 CreateSystemChildren();
9038 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9041 else if(style.hasHorzScroll)
9045 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9047 style.hasHorzScroll = value;
9050 get { return style.hasHorzScroll; }
9053 property bool hasVertScroll
9055 property_category $"Window Style"
9060 if(!style.hasVertScroll && created)
9062 style.hasVertScroll = true;
9063 CreateSystemChildren();
9064 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9067 else if(style.hasVertScroll)
9071 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9073 style.hasVertScroll = value;
9075 get { return style.hasVertScroll; }
9078 property bool dontHideScroll
9080 property_category $"Behavior"
9083 scrollFlags.dontHide = value;
9086 //UpdateScrollBars(true, true);
9087 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9091 // UpdateScrollBars(true, true);
9092 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9095 get { return scrollFlags.dontHide; }
9098 property bool dontScrollVert
9100 property_category $"Behavior"
9101 set { style.dontScrollVert = value; }
9102 get { return style.dontScrollVert; }
9104 property bool dontScrollHorz
9106 property_category $"Behavior"
9107 set { style.dontScrollHorz = value; }
9108 get { return style.dontScrollHorz; }
9111 property bool snapVertScroll
9113 property_category $"Behavior"
9116 scrollFlags.snapY = value;
9117 if(sbv) sbv.snap = value;
9119 get { return scrollFlags.snapY; }
9121 property bool snapHorzScroll
9123 property_category $"Behavior"
9126 scrollFlags.snapX = value;
9127 if(sbh) sbh.snap = value;
9129 get { return scrollFlags.snapX; }
9132 property Point scroll
9134 property_category $"Behavior"
9135 set { SetScrollPosition(value.x, value.y); }
9136 get { value = scroll; }
9139 property bool modifyVirtualArea
9141 property_category $"Behavior"
9142 set { modifyVirtArea = value; }
9143 get { return (bool)modifyVirtArea; }
9146 property bool dontAutoScrollArea
9148 property_category $"Behavior"
9149 // Activating a child control out of view will automatically scroll to make it in view
9150 set { noAutoScrollArea = value; }
9151 get { return (bool)noAutoScrollArea; }
9154 property char * fileName
9156 property_category $"Document"
9159 if(menu && ((!fileName && value) || (fileName && !value)))
9161 MenuItem item = menu.FindItem(MenuFileSave, 0);
9162 if(item) item.disabled = !modifiedDocument && value;
9167 if(value && value[0])
9168 fileName = CopyString(value);
9170 if(parent && this == parent.activeClient)
9171 parent.UpdateActiveDocument(null);
9175 // if(style.isDocument)
9177 fileMonitor.fileName = value;
9179 get { return fileName; }
9184 property_category $"Data"
9189 property bool modifiedDocument
9191 property_category $"Document"
9194 if(style.isDocument || fileName)
9198 MenuItem item = menu.FindItem(MenuFileSave, 0);
9199 if(item) item.disabled = !value && fileName;
9203 if(modifiedDocument != value)
9205 modifiedDocument = value;
9206 if(style.isDocument || fileName)
9210 get { return (bool)modifiedDocument; }
9213 property bool showInTaskBar
9215 property_category $"Window Style"
9216 set { style.showInTaskBar = value; }
9217 get { return (style.showInTaskBar; }
9219 property FileDialog saveDialog { set { saveDialog = value; } };
9220 property bool isActiveClient
9222 property_category $"Behavior"
9223 set { style.isActiveClient = value; }
9224 get { return style.isActiveClient; }
9227 property Cursor cursor
9229 property_category $"Appearance"
9233 SelectMouseCursor();
9235 get { return cursor; }
9238 //#if !defined(ECERE_VANILLA)
9239 property char * name
9241 property_category $"Design"
9244 return (this && object) ? object.name : null;
9249 activeDesigner.RenameObject(object, value);
9253 property char * displayDriver
9255 property_category $"Behavior"
9258 dispDriver = GetDisplayDriver(value);
9259 //DisplayModeChanged();
9263 return dispDriver ? dispDriver.name : null;
9267 // RUNTIME PROPERTIES
9268 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9269 property Size scrollArea
9271 property_category $"Behavior"
9275 SetScrollArea(value.w, value.h, false);
9277 SetScrollArea(0,0, true);
9279 get { value = scrollArea; }
9282 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9287 property_category $"Layout"
9288 set { if(this) is3D = value; }
9289 get { return (bool)is3D; }
9292 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9294 // Will be merged with font later
9295 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9296 property Point clientStart { get { value = clientStart; } };
9297 property Point absPosition { get { value = absPosition; } };
9298 property Anchor normalAnchor { get {value = normalAnchor; } };
9299 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9300 property bool active { get { return (bool)active; } };
9301 property bool created { get { return (bool)created; } };
9302 property bool destroyed { get { return (bool)destroyed; } };
9303 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9304 property Window firstChild { get { return children.first; } };
9305 property Window lastChild { get { return children.last; } };
9306 property Window activeClient { get { return activeClient; } };
9307 property Window activeChild { get { return activeChild; } };
9308 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9309 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9310 property ScrollBar horzScroll { get { return sbh; } };
9311 property ScrollBar vertScroll { get { return sbv; } };
9312 property StatusBar statusBar { get { return statusBar; } };
9313 property Window rootWindow { get { return rootWindow; } };
9314 property bool closing { get { return (bool)closing; } set { closing = value; } };
9315 property int documentID { get { return documentID; } };
9316 property Window previous { get { return prev; } }
9317 property Window next { get { return next; } }
9318 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9319 property PopupMenu menuBar { get { return menuBar; } }
9320 property ScrollBar sbv { get { return sbv; } }
9321 property ScrollBar sbh { get { return sbh; } }
9322 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9323 property void * systemHandle { get { return windowHandle; } }
9324 property Button minimizeButton { get { return sysButtons[0]; } };
9325 property Button maximizeButton { get { return sysButtons[1]; } };
9326 property Button closeButton { get { return sysButtons[2]; } };
9327 property BitmapResource icon
9329 get { return icon; }
9333 if(icon) incref icon;
9335 guiApp.interfaceDriver.SetIcon(this, value);
9338 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9339 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9340 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9341 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9342 property bool nativeDecorations
9344 get { return (bool)nativeDecorations; }
9345 set { nativeDecorations = value; }
9346 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9349 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9350 bool result = false;
9351 if(nativeDecorations)
9353 if(rootWindow == this)
9357 if(formDesigner && activeDesigner)
9359 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9360 Window form = cd ? cd.form : null;
9361 if(form && parent == form.parent)
9366 return result != style.fixed;
9370 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9372 property char * text
9374 property_category $"Deprecated"
9376 set { property::caption = value; }
9377 get { return property::caption; }
9383 WindowBits style; // Window Style
9384 char * caption; // Name / Caption
9385 Window parent; // Parent window
9386 OldList children; // List of children in Z order
9387 Window activeChild; // Child window having focus
9388 Window activeClient;
9389 Window previousActive; // Child active prior to activating the default child
9390 Window master; // Window owning and receiving notifications concerning this window
9391 OldList slaves; // List of windows belonging to this window
9392 Display display; // Display this window is drawn into
9394 Point position; // Position in parent window client area
9395 Point absPosition; // Absolute position
9396 Point clientStart; // Client area position from (0,0) in this window
9398 Size clientSize; // Client area size
9399 Size scrollArea; // Virtual Scroll area size
9400 Size reqScrollArea; // Requested virtual area size
9401 Point scroll; // Virtual area scrolling position
9402 ScrollBar sbh, sbv; // Scrollbar window handles
9403 Cursor cursor; // Mouse cursor used for this window
9406 StatusBar statusBar;
9407 Button sysButtons[3];
9409 Box clientArea; // Client Area box clipped to parent
9411 HotKeySlot hotKey; // HotKey for this window
9415 ScrollFlags scrollFlags;// Window Scrollbar Flags
9416 int64 id; // Control ID
9418 ColorAlpha background; // Background color used to draw the window area
9420 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9421 OldList childrenCycle; // Cycling order
9422 OldLink cycle; // Element of parent's cycling order
9423 OldList childrenOrder; // Circular Z-Order
9424 OldLink order; // Element of parent's circular Z-Order
9425 Window modalSlave; // Slave window blocking this window's interaction
9427 Window rootWindow; // Topmost system managed window
9428 void * windowHandle; // System window handle
9430 DialogResult returnCode;// Return code for modal windows
9432 Point sbStep; // Scrollbar line scrolling steps
9435 SizeAnchor stateSizeAnchor;
9437 Anchor normalAnchor;
9438 SizeAnchor normalSizeAnchor;
9440 Size skinMinSize; // Minimal window size based on style
9441 Point scrolledPos; // Scrolled position
9442 Box box; // Window box clipped to parent
9443 Box * against; // What to clip the box to
9445 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9446 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9447 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9448 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9449 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9450 Point scrolledArea; // Distance to scroll area by
9451 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9453 OldList hotKeys; // List of the hotkeys of all children
9454 Window defaultControl; // Default child control
9458 ColorAlpha * palette; // Color palette used for this window
9460 int caretSize; // Size of caret, non zero if a caret is present
9461 Point caretPos; // Caret position
9463 void * systemParent; // Parent System Window for embedded windows
9470 WindowState lastState;
9472 FileMonitor fileMonitor
9474 this, FileChange { modified = true };
9476 bool OnFileNotify(FileChange action, char * param)
9479 fileMonitor.StopMonitoring();
9480 if(OnFileModified(action, param))
9481 fileMonitor.StartMonitoring();
9486 FontResource setFont, systemFont;
9487 FontResource usedFont;
9488 FontResource captionFont;
9490 FileDialog saveDialog;
9492 SizeAnchor sizeAnchor;
9494 // FormDesigner data
9497 Extent * tempExtents; //[4];
9498 BitmapResource icon;
9500 CreationActivationOption creationActivation;
9503 bool active:1; // true if window and ancestors are active
9504 bool acquiredInput:1; // true if the window is processing state based input
9505 bool modifiedDocument:1;
9506 bool disabled:1; // true if window cannot interact
9507 bool isForegroundWindow:1;// true while a root window is being activated
9508 bool visible:1; // Visibility flag
9509 bool destroyed:1; // true if window is being destroyed
9510 bool anchored:1; // true if this window is repositioned when the parent resizes
9511 bool dirty:1; // Flag set to true if any descendant must be redrawn
9517 bool modifyVirtArea:1;
9518 bool noAutoScrollArea:1;
9521 bool setVisible:1; // FOR FORM DESIGNER
9527 bool useSharedMemory:1;
9530 bool nativeDecorations:1;
9531 bool manageDisplay:1;
9532 bool formDesigner:1; // True if we this is running in the form editor
9535 // Checks used internally for them not to take effect in FormDesigner
9536 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9537 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9539 WindowController controller;
9540 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9543 public class CommonControl : Window
9545 // creationActivation = doNothing;
9548 public property String toolTip
9550 property_category $"Appearance"
9553 if(created) CommonControl::OnDestroy();
9555 toolTip = value ? ToolTip { tip = value; } : null;
9557 if(created) CommonControl::OnCreate();
9559 get { return toolTip ? toolTip.tip : null; }
9565 // (Very) Ugly work around for the fact that the parent watcher
9566 // won't fire when it's already been disconnected...
9567 eInstance_FireSelfWatchers(toolTip,
9568 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9574 toolTip.parent = this;
9583 public class Percentage : float
9585 char * OnGetString(char * string, float * fieldData, bool * needClass)
9589 sprintf(string, "%.2f", this);
9590 c = strlen(string)-1;
9593 if(string[c] != '0')
9594 last = Max(last, c);
9595 if(string[c] == '.')
9608 public void ApplySkin(Class c, char * name, void ** vTbl)
9610 char className[1024];
9615 subclass(Window) wc = (subclass(Window))c;
9616 subclass(Window) base = (subclass(Window))c.base;
9618 sprintf(className, "%sSkin_%s", name, c.name);
9619 wc.pureVTbl = c._vTbl;
9620 c._vTbl = new void *[c.vTblSize];
9621 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9622 sc = eSystem_FindClass(c.module.application, className);
9626 for(m = 0; m < c.base.vTblSize; m++)
9628 if(c._vTbl[m] == base.pureVTbl[m])
9629 c._vTbl[m] = vTbl[m];
9634 for(m = 0; m < c.vTblSize; m++)
9636 if(sc._vTbl[m] != wc.pureVTbl[m])
9637 c._vTbl[m] = sc._vTbl[m];
9641 for(d = c.derivatives.first; d; d = d.next)
9643 ApplySkin(d.data, name, c._vTbl);
9647 public void UnapplySkin(Class c)
9649 char className[1024];
9651 subclass(Window) wc = (subclass(Window))c;
9652 subclass(Window) base = (subclass(Window))c.base;
9655 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9658 c._vTbl = wc.pureVTbl;
9662 for(d = c.derivatives.first; d; d = d.next)
9664 UnapplySkin(d.data);
9668 void CheckFontIntegrity(Window window)
9673 if(window.usedFont && window.usedFont.font == 0xecececec)
9675 FontResource uf = window.usedFont;
9676 char * className = window._class.name;
9677 char * text = window.text;
9680 for(c = window.firstChild; c; c = c.next)
9681 CheckFontIntegrity(c);
9685 public class ControllableWindow : Window
9687 /*WindowController controller;
9688 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9689 ~ControllableWindow() { delete controller; }*/
9692 class WindowControllerInterface : ControllableWindow
9694 bool OnKeyDown(Key key, unichar ch)
9696 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9698 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9702 bool OnKeyUp(Key key, unichar ch)
9704 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9706 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9710 bool OnKeyHit(Key key, unichar ch)
9712 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9714 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9718 bool OnMouseMove(int x, int y, Modifiers mods)
9720 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9722 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9726 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9728 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9730 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9734 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9736 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9738 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9742 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9744 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9746 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9750 bool OnRightButtonDown(int x, int y, Modifiers mods)
9752 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9754 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9758 bool OnRightButtonUp(int x, int y, Modifiers mods)
9760 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9762 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9766 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9768 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9770 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9774 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9776 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9778 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9782 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9784 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9786 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9790 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9792 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9794 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9798 void OnResize(int width, int height)
9800 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9801 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9804 void OnRedraw(Surface surface)
9806 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9807 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9812 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9814 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9818 bool OnLoadGraphics()
9820 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9822 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9826 void OnUnloadGraphics()
9828 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9829 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9833 public class WindowController<class V>
9836 property Window window
9840 uint size = class(Window).vTblSize;
9843 windowVTbl = new void *[size];
9844 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9845 if(value._vTbl == value._class._vTbl)
9847 value._vTbl = new void *[value._class.vTblSize];
9848 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9852 for(c = 0; c < size; c++)
9854 void * function = class(WindowControllerInterface)._vTbl[c];
9855 if(function != DefaultFunction)
9856 value._vTbl[c] = function;
9858 value._vTbl[c] = windowVTbl[c];
9863 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9866 get { return window; }
9868 property V controlled
9870 set { controlled = value; }
9871 get { return controlled; }
9873 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9874 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9875 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9876 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9877 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9878 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9879 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9880 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9881 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9882 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9883 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9884 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9885 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9886 virtual void V::OnResize(WindowController controller, int width, int height);
9887 virtual void V::OnRedraw(WindowController controller, Surface surface);
9888 virtual bool V::OnCreate(WindowController controller);
9889 virtual bool V::OnLoadGraphics(WindowController controller);
9890 virtual void V::OnUnloadGraphics(WindowController controller);
9893 int (** windowVTbl)();