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);
3246 Window FindModal(void)
3248 Window modalWindow = this, check;
3249 Window check2 = null;
3250 for(check = this; check.master; check = check.master)
3252 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3254 modalWindow = check.master.modalSlave;
3255 check = modalWindow;
3257 // TESTING THIS FOR DROPBOX...
3258 if(!rootWindow || !rootWindow.style.interim)
3260 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3262 if(check2.modalSlave && check2.modalSlave.created)
3264 modalWindow = check2.modalSlave;
3272 if(modalWindow == this)
3274 for(check = this; check.activeChild; check = check.activeChild)
3276 if(check.modalSlave)
3278 modalWindow = check.modalSlave;
3284 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3285 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3288 void StopMoving(void)
3290 if(this == guiApp.windowMoving)
3292 guiApp.windowMoving = null;
3293 UpdateDecorations();
3294 SetMouseRange(null);
3297 if(rootWindow.active)
3298 guiApp.interfaceDriver.StopMoving(rootWindow);
3301 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3302 guiApp.windowIsResizing = false;
3306 void SelectMouseCursor(void)
3311 Window cursorWindow = null;
3312 bool rx, ry, rex, rey;
3314 guiApp.desktop.GetMousePosition(&x, &y);
3315 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3317 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3318 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3319 else if(mouseWindow)
3321 modalWindow = mouseWindow.FindModal();
3322 x -= mouseWindow.absPosition.x;
3323 y -= mouseWindow.absPosition.y;
3324 if(guiApp.windowIsResizing)
3326 rex = guiApp.resizeEndX;
3327 rey = guiApp.resizeEndY;
3328 rx = guiApp.resizeX;
3329 ry = guiApp.resizeY;
3330 if((rex && rey) || (rx && ry))
3331 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3332 else if((rex && ry) || (rx && rey))
3333 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3334 else if((ry || rey) && (!rx && !rex))
3335 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3336 else if((rx || rex) && (!ry && !rey))
3337 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3339 else if(!modalWindow && !guiApp.windowCaptured &&
3340 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3341 &rx, &ry, &rex, &rey))
3343 if((rex && rey) || (rx && ry))
3344 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3345 else if((rex && ry) || (rx && rey))
3346 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3347 else if((ry || rey) && (!rx && !rex))
3348 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3349 else if((rx || rex) && (!ry && !rey))
3350 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3352 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3354 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3355 cursorWindow = mouseWindow.parent;
3357 cursorWindow = mouseWindow;
3359 else if(!guiApp.interimWindow)
3360 cursorWindow = guiApp.windowCaptured;
3363 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3364 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3366 else if(modalWindow)
3368 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3370 else if(guiApp.interimWindow)
3372 if(guiApp.interimWindow.cursor)
3373 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3375 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3380 // --- State based input ---
3381 bool AcquireInputEx(bool state)
3386 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3387 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3389 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3391 guiApp.acquiredWindow = state ? this : null;
3394 SetMouseRangeToClient();
3395 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3400 SelectMouseCursor();
3402 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3406 // --- Window activation ---
3407 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3410 if(!parent || !parent.style.inactive)
3412 Window parent = this.parent;
3415 if(rootWindow == this)
3416 Log(active ? "active\n" : "inactive\n");
3419 // Testing this here...
3420 if(!parent || parent == guiApp.desktop || parent.active)
3422 this.active = active;
3425 // TESTING THIS HERE
3426 UpdateDecorations();
3427 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3428 result = NotifyActivate(master, this, active, previous);
3431 this.active = !active;
3436 if(!parent || parent == guiApp.desktop || parent.active)
3438 this.active = active;
3440 AcquireInputEx(active);
3445 if(guiApp.caretOwner)
3449 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3450 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3451 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3452 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3454 guiApp.caretOwner.Update(extent);
3457 if(visible || !guiApp.caretOwner)
3458 guiApp.caretOwner = this;
3459 UpdateCaret(false, false);
3465 this.active = false;
3467 AcquireInputEx(active);
3469 if(!active && guiApp.caretOwner == this)
3471 UpdateCaret(false, true);
3472 guiApp.caretOwner = null;
3473 guiApp.interfaceDriver.SetCaret(0,0,0);
3474 guiApp.caretEnabled = false;
3479 if(!active && parent && parent.activeChild && parent.activeChild != this)
3480 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3486 if(!active && menuBar)
3489 menuBar.OnActivate(false, null, &goOn, true);
3490 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3495 Window aChild = activeChild;
3497 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3509 void ConsequentialMouseMove(bool kbMoving)
3513 if(kbMoving || !guiApp.windowMoving)
3517 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3519 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3521 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3522 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3528 bool IsDescendantOf(Window ancestor)
3531 for(window = this; window && window != ancestor; window = window.parent);
3532 return window == ancestor;
3535 bool IsSlaveOf(Window master)
3538 for(window = this; window && window != master; window = window.master);
3539 return window == master;
3542 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3546 if(this && !destroyed /*&& state != Hidden*/)
3548 Window swap = externalSwap;
3556 if(activateParent &&
3557 (parent.activeChild != this ||
3558 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3559 active && _isModal &&
3560 parent != master && master)
3561 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3567 bool real = parent.activeChild != this;
3569 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3570 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3571 !IsDescendantOf(guiApp.interimWindow) &&
3572 !IsSlaveOf(guiApp.interimWindow))
3574 Window interimWindow = guiApp.interimWindow;
3575 while(interimWindow && interimWindow != this)
3577 Window master = interimWindow.master;
3579 guiApp.interimWindow = null;
3580 if(guiApp.caretOwner)
3581 guiApp.caretOwner.UpdateCaret(false, false);
3583 incref interimWindow;
3584 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3589 delete interimWindow;
3590 interimWindow = (master && master.style.interim) ? master : null;
3595 guiApp.interimWindow = this;
3596 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3597 guiApp.caretEnabled = false;*/
3598 UpdateCaret(false, true);
3603 bool acquireInput = false;
3605 parent.activeChild &&
3606 parent.activeChild.state == maximized &&
3607 parent != guiApp.desktop;
3609 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3614 swap = parent.activeChild;
3615 if(swap && swap.destroyed) swap = null;
3616 if(swap && swap != this)
3619 if(!swap.PropagateActive(false, this, &goOn, true))
3620 swap = parent.activeChild;
3631 if(!parent || parent.activeChild != this || style.interim)
3634 result = PropagateActive(true, swap, &goOn, true);
3635 if(!result && !goOn)
3640 acquireInput = true;
3644 if(style.hasMaximize && parent != guiApp.desktop)
3647 SetState(maximized, false, 0);
3648 else if(state != maximized)
3651 for(child = parent.children.first; child; child = child.next)
3653 if(this != child && child.state == maximized)
3654 child.SetState(normal, false, 0);
3661 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3663 Window previous = parent.activeClient;
3664 parent.activeChild = this;
3665 if(!style.nonClient /*&& style.isActiveClient*/)
3669 if(style.isActiveClient)
3670 parent.activeClient = this;
3671 // Moved UpdateActiveDocument inside hidden check
3672 // To prevent activating previous window while creating a new one
3673 // (It was messing up the privateModule in the CodeEditor)
3674 parent.UpdateActiveDocument(previous);
3680 //if(!style.isRemote)
3682 if(rootWindow != this)
3684 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3685 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3687 else if(!guiApp.fullScreenMode)
3689 Window modalRoot = FindModal();
3690 if(!modalRoot) modalRoot = this;
3691 if(!modalRoot.isForegroundWindow)
3693 modalRoot.isForegroundWindow = true;
3694 // To check : Why is parent null?
3695 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3697 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3699 modalRoot.isForegroundWindow = false;
3704 if(result && real && (!style.inactive || moveInactive) && parent)
3706 Window last = parent.children.last;
3708 if(!style.stayOnTop)
3709 for(; last && last.style.stayOnTop; last = last.prev);
3711 parent.children.Move(this, last);
3713 // Definitely don't want that: why not?
3717 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3723 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3730 parent.activeChild = null;
3731 if(!style.nonClient /*&& style.isActiveClient*/)
3733 Window previous = parent.activeClient;
3734 if(style.isActiveClient)
3735 parent.activeClient = null;
3736 parent.UpdateActiveDocument(previous);
3740 if(this == guiApp.interimWindow)
3742 guiApp.interimWindow = null;
3743 if(guiApp.caretOwner)
3744 guiApp.caretOwner.UpdateCaret(false, false);
3746 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3753 if(!active || !swap)
3754 UpdateDecorations();
3756 swap.UpdateDecorations();
3758 if(active && rootWindow != this)
3759 ConsequentialMouseMove(false);
3766 // --- Input Messages ---
3767 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3769 static bool reEntrancy = false;
3770 if(reEntrancy) return;
3774 guiApp.cursorUpdate = true;
3775 if(guiApp.windowScrolling && !consequential)
3777 guiApp.windowScrolling.SetScrollPosition(
3778 (guiApp.windowScrolling.sbh) ?
3779 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3780 (guiApp.windowScrolling.sbv) ?
3781 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3783 if(guiApp.windowMoving)
3785 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3787 Window window = guiApp.windowMoving;
3789 int w = window.size.w;
3790 int h = window.size.h;
3795 rx = mouseX - guiApp.windowMovingStart.x;
3796 ry = mouseY - guiApp.windowMovingStart.y;
3799 window.GetDecorationsSize(&ew, &eh);
3801 if(guiApp.windowIsResizing)
3803 x = window.scrolledPos.x;
3804 y = window.scrolledPos.y;
3808 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3809 rx = guiApp.windowResizingBefore.w - aw;
3810 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3811 w = guiApp.windowResizingBefore.w - rx;
3815 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3816 ry = guiApp.windowResizingBefore.h - ah;
3817 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3818 ry = Max(ry, -guiApp.windowMovingBefore.y);
3819 h = guiApp.windowResizingBefore.h - ry;
3821 if(guiApp.resizeEndX)
3823 w = guiApp.windowResizingBefore.w + rx;
3826 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3834 w = Max(w, window.minSize.w);
3835 h = Max(h, window.minSize.h);
3836 w = Min(w, window.maxSize.w);
3837 h = Min(h, window.maxSize.h);
3839 if(!window.OnResizing(&w, &h))
3841 w = window.clientSize.w;
3842 h = window.clientSize.h;
3845 w = Max(w, window.skinMinSize.w);
3846 h = Max(h, window.skinMinSize.h);
3853 SNAPDOWN(w, textCellW);
3854 SNAPDOWN(h, textCellH);
3859 aw = Max(w,window.skinMinSize.w);
3860 rx = guiApp.windowResizingBefore.w - aw;
3861 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3862 w = guiApp.windowResizingBefore.w - rx;
3866 ah = Max(h,window.skinMinSize.h);
3867 ry = guiApp.windowResizingBefore.h - ah;
3868 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3869 ry = Max(ry, -guiApp.windowMovingBefore.y);
3870 h = guiApp.windowResizingBefore.h - ry;
3875 if(!guiApp.windowIsResizing || guiApp.resizeX)
3876 x = guiApp.windowMovingBefore.x + rx;
3877 if(!guiApp.windowIsResizing || guiApp.resizeY)
3878 y = guiApp.windowMovingBefore.y + ry;
3880 if(!guiApp.windowIsResizing)
3883 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3885 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3886 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3887 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3888 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3892 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3893 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3899 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3901 if(!window.OnMoving(&x, &y, w, h))
3903 x = window.scrolledPos.x;
3904 y = window.scrolledPos.y;
3910 SNAPDOWN(x, textCellW);
3911 SNAPDOWN(y, textCellH);
3914 if(!window.style.nonClient)
3916 if(!window.style.fixed /*|| window.style.isDocument*/)
3918 if(!window.style.dontScrollHorz)
3919 x += window.parent.scroll.x;
3920 if(!window.style.dontScrollVert)
3921 y += window.parent.scroll.y;
3925 // Break the anchors for moveable/resizable windows
3926 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3927 if(window.style.fixed)
3929 if(window.state == normal)
3931 window.normalAnchor = Anchor { left = x, top = y };
3932 window.normalSizeAnchor = SizeAnchor { { w, h } };
3933 window.anchored = false;
3937 window.stateAnchor = Anchor { left = x, top = y };
3938 window.stateSizeAnchor = SizeAnchor { { w, h } };
3940 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3941 // TOCHECK: Investigate why the following only redraws the scrollbars
3942 //window.Position(x, y, w, h, false, true, true, true, false, true);
3944 guiApp.movingLast.x = mouseX;
3945 guiApp.movingLast.y = mouseY;
3951 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3954 bool wasMoving = guiApp.windowMoving ? true : false;
3955 bool wasScrolling = guiApp.windowScrolling ? true : false;
3957 while(result && w != this)
3959 Window msgWindow = GetAtPosition(x,y, false, true, w);
3960 Window trueWindow = GetAtPosition(x,y, false, false, w);
3961 bool windowDragged = false;
3966 window = (w && !w.disabled) ? w : null;
3968 if(trueWindow) incref trueWindow;
3970 if(consequential) mods->isSideEffect = true;
3972 UpdateMouseMove(x, y, consequential);
3974 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3976 if(!guiApp.windowCaptured.isEnabled)
3977 guiApp.windowCaptured.ReleaseCapture();
3979 window = guiApp.windowCaptured;
3982 if(trueWindow && activate &&
3983 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3984 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3985 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3986 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3988 if(mods->alt && !mods->ctrl && !mods->shift)
3990 Window moved = trueWindow;
3991 for(moved = trueWindow; moved; moved = moved.parent)
3992 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3997 windowDragged = true;
3999 // Cancel the ALT menu toggling...
4000 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4005 if(window && activate &&
4006 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4007 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4008 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4009 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4011 Window modalWindow = window.FindModal();
4013 /*if(mods->alt && !mods->shift && !mods->ctrl)
4015 Window moved = window;
4016 for(moved = window; moved; moved = moved.parent)
4017 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4022 windowDragged = true;
4024 // Cancel the ALT menu toggling...
4025 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4031 Window activateWindow = modalWindow ? modalWindow : window;
4032 if(activateWindow && !activateWindow.isRemote)
4034 bool doActivation = true;
4035 //bool needToDoActivation = false;
4036 Window check = activateWindow;
4038 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4040 if(!check.style.inactive)
4042 //needToDoActivation = true;
4044 doActivation = false;
4049 if(!needToDoActivation)
4050 doActivation = false;
4053 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4054 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4056 // Let the OnLeftButtonDown do the activating instead
4057 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4065 incref activateWindow;
4066 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4068 delete activateWindow;
4072 if(activateWindow._refCount == 1)
4074 delete activateWindow;
4078 delete activateWindow;
4079 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4082 mods->isActivate = true;
4086 if(!modalWindow && window && !window.destroyed)
4088 if(!guiApp.windowCaptured || windowDragged)
4090 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4092 bool moving = ((window.state != maximized &&
4093 window.IsMouseMoving(
4094 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4095 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4097 if(!moving && window.IsMouseResizing(
4098 x - window.absPosition.x,
4099 y - window.absPosition.y,
4100 window.size.w, window.size.h,
4101 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4103 guiApp.windowIsResizing = true;
4104 guiApp.windowResizingBefore.w = window.size.w;
4105 guiApp.windowResizingBefore.h = window.size.h;
4107 if(guiApp.windowIsResizing || windowDragged || moving)
4110 guiApp.windowMoving = window;
4111 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4112 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4113 guiApp.windowMovingBefore.x = window.position.x;//s;
4114 guiApp.windowMovingBefore.y = window.position.y;//s;
4115 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4116 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4119 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4121 if(window.style.fixed &&
4123 window.IsMouseMoving(
4124 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4126 window.ShowSysMenu(x, y);
4130 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4132 if(window.sbv || window.sbh)
4135 guiApp.windowScrolling = window;
4136 guiApp.windowScrollingStart.x = x;
4137 guiApp.windowScrollingStart.y = y;
4138 guiApp.windowScrollingBefore.x = window.scroll.x;
4139 guiApp.windowScrollingBefore.y = window.scroll.y;
4142 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4144 if(window.style.hasMaximize &&
4145 window.IsMouseMoving(
4146 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4149 (window.state == maximized) ? normal : maximized, false, *mods);
4157 if(guiApp.windowMoving)
4159 if(guiApp.windowMoving.parent)
4161 if(guiApp.windowMoving.style.nonClient)
4162 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4164 guiApp.windowMoving.parent.SetMouseRangeToClient();
4168 window.UpdateDecorations();
4171 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4173 // Log("\n*** LEFT BUTTON UP ***\n");
4174 if(guiApp.windowMoving)
4175 guiApp.windowMoving.StopMoving();
4177 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4179 if(guiApp.windowScrolling)
4181 Window windowScrolling = guiApp.windowScrolling;
4182 guiApp.windowScrolling = null;
4183 windowScrolling.ReleaseCapture();
4187 if(!result || (window && window.destroyed)) window = null;
4189 if(window && window.FindModal())
4192 if(trueWindow && trueWindow.FindModal())
4200 msgWindow = GetAtPosition(x,y, true, false);
4202 msgWindow.SelectMouseCursor();
4205 if(guiApp.windowCaptured || trueWindow)
4207 Window prevWindow = guiApp.prevWindow;
4208 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4210 guiApp.prevWindow.mouseInside = false;
4211 guiApp.prevWindow = null;
4213 // Eventually fix this not to include captured?
4214 if(!prevWindow.OnMouseLeave(*mods))
4217 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4219 Box box = trueWindow.box;
4220 box.left += trueWindow.absPosition.x;
4221 box.right += trueWindow.absPosition.x;
4222 box.top += trueWindow.absPosition.y;
4223 box.bottom += trueWindow.absPosition.y;
4225 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4227 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4228 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4230 overX = Max(Min(overX, 32767),-32768);
4231 overY = Max(Min(overY, 32767),-32768);
4233 trueWindow.mouseInside = true;
4234 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4238 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4239 guiApp.prevWindow = trueWindow;
4241 guiApp.prevWindow = null;
4243 SelectMouseCursor();
4245 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4247 int clientX = x - (window.absPosition.x + window.clientStart.x);
4248 int clientY = y - (window.absPosition.y + window.clientStart.y);
4250 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4252 clientX = Max(Min(clientX, 32767),-32768);
4253 clientY = Max(Min(clientY, 32767),-32768);
4255 MouseMethod = (void *)window._vTbl[method];
4257 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4260 if(!MouseMethod(window, clientX, clientY, *mods))
4267 if(result && w && w.clickThrough && w.parent)
4272 if(!result || !w || !w.clickThrough)
4279 // --- Mouse cursor management ---
4281 bool KeyMessage(uint method, Key key, unichar character)
4286 if(guiApp.interimWindow)
4287 this = guiApp.interimWindow;
4290 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4294 if(!style.inactive || rootWindow != this)
4296 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4297 Window modalWindow = FindModal();
4298 Window interimMaster = master ? master.rootWindow : null;
4302 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4303 status = OnSysKeyDown(key, character);
4304 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4305 status = OnSysKeyHit(key, character);
4306 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4307 status = OnSysKeyUp(key, character);
4314 // Process Key Message for Internal UI Keyboard actions
4315 if(status && !destroyed && menuBar && state != minimized)
4318 if((SmartKey)key != alt)
4319 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4322 SmartKey sk = (SmartKey) key;
4323 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4325 status = menuBar.KeyMessage(method, key, character);
4330 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4331 menuBar.OnKeyHit(escape, 0);
4333 if(!menuBar.focus && guiApp.caretOwner)
4334 guiApp.caretOwner.UpdateCaret(true, false);
4337 if(!destroyed && status)
4339 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4343 case left: case up: case right: case down:
4344 if(guiApp.windowMoving == this)
4347 int w = guiApp.windowMoving.size.w;
4348 int h = guiApp.windowMoving.size.h;
4349 int x = guiApp.windowMoving.scrolledPos.x;
4350 int y = guiApp.windowMoving.scrolledPos.y;
4354 if(key == down || key == up)
4355 step = Max(step, textCellH);
4357 step = Max(step, textCellW);
4360 if(guiApp.windowIsResizing)
4364 case left: w-=step; break;
4365 case right: w+=step; break;
4366 case up: h-=step; break;
4367 case down: h+=step; break;
4374 case left: x-=step; break;
4375 case right: x+=step; break;
4376 case up: y-=step; break;
4377 case down: y+=step; break;
4381 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4382 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4384 if(!guiApp.windowIsResizing || guiApp.resizeX)
4385 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4387 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4389 if(!guiApp.windowIsResizing || guiApp.resizeY)
4390 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4392 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4394 guiApp.interfaceDriver.SetMousePosition(x, y);
4395 ConsequentialMouseMove(true);
4403 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4405 guiApp.windowMoving.StopMoving();
4406 ConsequentialMouseMove(false);
4414 ShowSysMenu(absPosition.x, absPosition.y);
4422 if(!destroyed && status && state != minimized)
4424 // Process all the way down the children
4425 if(activeChild && !activeChild.disabled)
4427 status = activeChild.KeyMessage(method, key, character);
4429 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4430 key.code != left && key.code != right && key.code != up && key.code != down)
4432 status = activeClient.KeyMessage(method, key, character);
4436 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4438 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4439 // && defaultControl != activeChild)
4441 delete previousActive;
4442 previousActive = activeChild;
4443 if(previousActive) incref previousActive;
4445 ConsequentialMouseMove(false);
4446 if((defaultControl.active ||
4447 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4448 defaultControl.KeyMessage(method, defaultKey, character);
4454 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4456 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4463 ShowSysMenu(absPosition.x, absPosition.y);
4470 if(this != guiApp.desktop)
4472 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4474 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4476 MenuMoveOrSize(key.shift, true);
4480 else if(guiApp.windowMoving)
4482 guiApp.windowMoving.StopMoving();
4483 ConsequentialMouseMove(false);
4491 if(!destroyed && status && state != minimized)
4493 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4497 case tab: case shiftTab:
4499 Window cycleParent = this;
4500 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4501 cycleParent = master.parent;
4503 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4505 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4507 Window child = cycleParent.activeChild;
4509 // Scroll the window to include the active control
4511 if(cycleParent.sbh && !child.style.dontScrollHorz)
4513 if(child.scrolledPos.x < 0)
4514 cycleParent.sbh.Action(Position,
4515 cycleParent.scroll.x + child.scrolledPos.x, 0);
4516 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4517 cycleParent.sbh.Action(Position,
4518 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4520 if(cycleParent.sbv && !child.style.dontScrollVert)
4522 if(child.scrolledPos.y < 0)
4523 cycleParent.sbv.Action(Position,
4524 cycleParent.scroll.y + child.scrolledPos.y, 0);
4525 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4526 cycleParent.sbv.Action(Position,
4527 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4530 cycleParent.ConsequentialMouseMove(false);
4536 case f6: case shiftF6:
4537 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4539 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4540 if(parent == guiApp.desktop)
4541 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4551 if(CycleChildren(key.shift, true, false, true))
4559 // mIRC Style Window Shortcuts
4560 case alt1: case alt2: case alt3: case alt4: case alt5:
4561 case alt6: case alt7: case alt8: case alt9: case alt0:
4566 for(document = children.first; document; document = document.next)
4568 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4570 if(document == activeChild)
4572 if(document.state == minimized)
4573 document.SetState(normal, false, key);
4576 document.SetState(minimized, false, key);
4577 CycleChildren(false, true, false);
4582 if(activeChild.state == maximized && document.style.hasMaximize)
4583 document.SetState(maximized, false, key);
4584 else if(document.state == minimized)
4585 document.SetState(normal, false, key);
4586 document.Activate();
4601 if(!destroyed && status)
4603 if(state == minimized)
4608 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4610 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4612 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4613 previousActive.ActivateEx(true, false, false, true, null, null);
4614 delete previousActive;
4620 if(!destroyed && status)
4622 status = ProcessHotKeys(method, key, character);
4624 if(!destroyed && status && !modalWindow && state != minimized)
4627 status = KeyMethod(this, key, character);
4628 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4629 status = OnKeyHit(key, character);
4630 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4632 bool result = false;
4635 case ctrlUp: case ctrlDown:
4636 if(sbv && !guiApp.windowScrolling)
4637 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4639 case wheelUp: case wheelDown:
4640 if(sbv && !guiApp.windowScrolling)
4642 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4643 // Do we want to do a consequential move regardless of result in this case?
4644 ConsequentialMouseMove(false);
4647 case ctrlPageUp: case ctrlPageDown:
4648 if(sbh && !guiApp.windowScrolling)
4649 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4654 ConsequentialMouseMove(false);
4659 if(status && !destroyed && menuBar && state != minimized)
4660 status = menuBar.KeyMessage(method, key, character);
4662 if(style.interim && /*destroyed && */status && interimMaster)
4664 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4665 status = interimMaster.KeyMessage(method, key, character);
4672 bool ProcessHotKeys(uint method, Key key, unichar character)
4677 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4678 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4679 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4681 Window hotKeyWindow = hotKey.window;
4682 Window parent = hotKeyWindow.parent;
4683 Window prevActiveWindow = activeChild;
4684 // For when sys buttons are placed inside the menu bar
4685 if(parent && parent._class == class(PopupMenu))
4686 parent = parent.parent;
4688 // 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
4689 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4692 if(prevActiveWindow) incref prevActiveWindow;
4693 incref hotKeyWindow;
4694 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4695 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4698 delete hotKeyWindow;
4699 delete prevActiveWindow;
4703 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4704 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4705 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4707 // ********* WORKING ON THIS ***********
4708 if(prevActiveWindow && !guiApp.interimWindow)
4709 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4712 else if(hotKeyWindow.style.inactive)
4713 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4715 delete prevActiveWindow;
4716 delete hotKeyWindow;
4717 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4718 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4722 if(status && tabCycle)
4725 for(child = children.first; child; child = child.next)
4727 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4738 // --- Windows and graphics initialization / termination ---
4739 bool SetupRoot(void)
4743 // Setup relationship with outside world (bb root || !bb)
4744 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4745 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4749 tempExtents = new0 Extent[4];
4754 /*if(guiApp.fullScreenMode)
4755 rootWindow = guiApp.desktop;
4757 //rootWindow = parent.created ? parent.rootWindow : null;
4758 rootWindow = parent.rootWindow;
4761 against = &parent.box;
4763 against = &parent.clientArea;
4766 for(child = children.first; child; child = child.next)
4769 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4772 bool Setup(bool positionChildren)
4774 bool result = false;
4777 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4779 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4780 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4782 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4784 // This was here, is it really needed?
4785 //guiApp.interfaceDriver.ActivateRootWindow(this);
4789 displaySystem = DisplaySystem {};
4790 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4792 delete displaySystem;
4797 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4798 if(display.Create(displaySystem, windowHandle))
4805 // Sometimes icon does not show up on Windows XP if we set here...
4806 // guiApp.interfaceDriver.SetIcon(this, icon);
4808 else if(this != guiApp.desktop)
4810 display = rootWindow ? rootWindow.display : null;
4816 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4817 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4819 for(child = children.first; child; child = child.next)
4821 if(child.created && !child.Setup(false))
4827 bool SetupDisplay(void)
4829 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4830 if(is3D) return Window3D_SetupDisplay(this); else
4837 class_data void ** pureVTbl;
4839 bool LoadGraphics(bool creation, bool resetAnchors)
4841 bool result = false;
4842 bool success = false;
4844 WindowState stateBackup = state;
4846 if(((subclass(Window))_class).pureVTbl)
4848 if(_vTbl == _class._vTbl)
4850 _vTbl = ((subclass(Window))_class).pureVTbl;
4855 for(m = 0; m < _class.vTblSize; m++)
4857 if(_vTbl[m] == _class._vTbl[m])
4858 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4862 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4864 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4866 _vTbl = _class._vTbl;
4871 for(m = 0; m < _class.vTblSize; m++)
4873 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4874 _vTbl[m] = _class._vTbl[m];
4879 if(guiApp.fullScreenMode || this != guiApp.desktop)
4881 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4887 display.Lock(false);
4888 if(rootWindow == this)
4890 // Set Color Palette
4891 display.SetPalette(palette, true);
4895 if(guiApp.fullScreenMode && this == guiApp.desktop)
4900 for(c=0; c<SystemCursor::enumSize; c++)
4901 if(!guiApp.systemCursors[c].bitmap)
4903 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4904 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4905 if(guiApp.systemCursors[c].bitmapName)
4907 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4908 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4909 if(guiApp.systemCursors[c].bitmap)
4910 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4915 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4917 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4918 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4920 cursor.bitmap.paletteShades = cursor.paletteShades;
4924 guiApp.cursorUpdate = true;
4927 ConsequentialMouseMove(false);
4933 // Load Window Graphic Resources
4936 if(usedFont == setFont || usedFont == window.systemFont)
4937 RemoveResource(usedFont);
4940 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4943 RemoveResource(systemFont);
4946 RemoveResource(captionFont);
4948 for(ptr = resources.first; ptr; ptr = ptr.next)
4950 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4953 AddResource(setFont);
4955 AddResource(systemFont);
4957 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4964 //if(master && master.font)
4965 if(parent && parent.font)
4969 faceName = parent.font.faceName,
4970 size = parent.font.size,
4971 bold = parent.font.bold,
4972 italic = parent.font.italic,
4973 underline = parent.font.underline
4975 //font = parent.font;
4976 watch(parent) { font { } };
4979 font = guiApp.currentSkin.SystemFont();
4986 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4987 AddResource(captionFont);
4989 if(OnLoadGraphics())
4995 //SetScrollLineStep(sbStep.x, sbStep.y);
4997 if(this != guiApp.desktop)
5001 normalAnchor = anchor;
5002 normalSizeAnchor = sizeAnchor;
5005 // Break the anchors for moveable/resizable windows
5007 if(style.fixed && style.isDocument)
5009 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5021 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5022 stateSizeAnchor = SizeAnchor {};
5027 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5032 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5033 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5036 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5040 stateAnchor = normalAnchor;
5041 stateSizeAnchor = normalSizeAnchor;
5044 position = Point { };
5045 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5056 if(Position(x, y, w, h, true, false, true, true, true, true))
5058 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5061 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5078 success = result = true;
5081 if(!creation && result)
5083 // Load menu bar first because sys buttons are on it...
5086 if(!menuBar.LoadGraphics(false, resetAnchors))
5092 for(child = children.first; child; child = child.next)
5094 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5101 CreateSystemChildren();
5105 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5108 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5113 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5114 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5117 // Do this here to avoid problems on Windows
5118 if(stateBackup == maximized)
5119 property::state = maximized;
5123 void UnloadGraphics(bool destroyWindows)
5127 // Free children's graphics
5128 for(child = children.first; child; child = child.next)
5129 child.UnloadGraphics(destroyWindows);
5132 display.Lock(false);
5135 if(guiApp.fullScreenMode && this == guiApp.desktop)
5140 for(c=0; c<SystemCursor::enumSize; c++)
5141 if(guiApp.systemCursors[c].bitmap)
5142 delete guiApp.systemCursors[c].bitmap;
5144 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5145 delete cursor.bitmap;
5147 guiApp.cursorBackground.Free();
5150 if(display && display.displaySystem)
5154 for(ptr = resources.first; ptr; ptr = ptr.next)
5158 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5163 // Free window graphics
5166 // Free skin graphics
5167 if(rootWindow == this)
5169 DisplaySystem displaySystem = display.displaySystem;
5172 display.driverData = null;
5173 display.displaySystem = null;
5177 if(displaySystem && !displaySystem.numDisplays && !is3D)
5178 delete displaySystem;
5187 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5188 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5190 if(this == guiApp.desktop || parent == guiApp.desktop)
5192 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5193 guiApp.interfaceDriver.DestroyRootWindow(this);
5197 // --- Window Hiding ---
5199 void SetVisibility(bool state)
5201 bool visible = (style.hidden || !created) ? false : state;
5202 if(visible != this.visible)
5206 this.visible = visible;
5207 for(child = children.first; child; child = child.next)
5208 child.SetVisibility(visible);
5210 ConsequentialMouseMove(false);
5211 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5215 // --- Windows and graphics initialization / termination ---
5217 bool DisplayModeChanged(void)
5219 bool result = false;
5220 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5222 guiApp.modeSwitching = true;
5223 UnloadGraphics(false);
5225 if(LoadGraphics(false, false))
5227 guiApp.modeSwitching = false;
5232 // --- Window updates system ---
5234 void UpdateDirty(Box updateBox)
5236 if(!manageDisplay) { OnRedraw(null);return; }
5239 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5242 if(display.flags.flipping)
5245 rootWindow.UpdateDisplay();
5248 UpdateBackDisplay(updateBox);
5250 if(guiApp.fullScreenMode)
5252 guiApp.cursorUpdate = true;
5253 guiApp.PreserveAndDrawCursor();
5255 if(guiApp.fullScreenMode)
5256 guiApp.RestoreCursorBackground();
5262 // This function is strictly called as a result of system window activation
5263 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5266 Window interimMaster = null;
5267 Window interimWindow = guiApp.interimWindow;
5268 if(interimWindow && interimWindow.master)
5269 interimMaster = interimWindow.master.rootWindow;
5271 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5272 // SetState(normal, false, 0);
5273 SetState(lastState, false, 0);
5275 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5279 /* WTH is this doing here?
5280 while(swap && swap.activeChild)
5282 swap = swap.activeChild;
5285 // TESTING THIS BEFORE...
5286 if(interimWindow && this == interimMaster)
5290 // Window interimSwap = this;
5291 Window menuBar = this.menuBar;
5292 if(menuBar && interimWindow.master == menuBar)
5295 while(interimSwap && interimSwap.activeChild)
5296 interimSwap = interimSwap.activeChild;
5298 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5299 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5301 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5302 //result = ActivateEx(true, true, false, activateRoot, window, null);
5307 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5308 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5310 if(interimWindow == this && interimMaster && !active)
5312 while(interimMaster && interimMaster.interim && interimMaster.master)
5314 // printf("Going up one master %s\n", interimMaster._class.name);
5315 interimMaster = interimMaster.master.rootWindow;
5317 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5318 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5324 bool DestroyEx(int64 returnCode)
5327 Timer timer, nextTimer;
5329 OldLink prevOrder = null;
5330 Window client = null;
5332 if(parent) stopwatching(parent, font);
5334 // if(window.modalSlave) return false;
5335 if(destroyed || !created)
5342 OldLink slave = master.slaves.FindLink(this);
5343 master.slaves.Delete(slave);
5346 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5352 this.returnCode = (DialogResult)returnCode;
5354 AcquireInput(false);
5359 master.hotKeys.Delete(hotKey);
5363 if(guiApp.prevWindow == this)
5365 guiApp.prevWindow = null;
5368 if(guiApp.caretOwner == this)
5370 guiApp.interfaceDriver.SetCaret(0,0,0);
5371 UpdateCaret(false, true);
5372 guiApp.caretEnabled = false;
5377 parent.childrenCycle.Remove(cycle);
5381 OldLink tmpPrev = order.prev;
5382 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5383 prevOrder = tmpPrev;
5386 client = tmpPrev ? tmpPrev.data : null;
5387 if(client == this) { client = null; break; }
5388 if(client && (client.style.hidden || client.destroyed || !client.created))
5389 tmpPrev = client.order.prev;
5393 prevOrder = tmpPrev;
5398 // If this window can be an active client, make sure the next window we activate can also be one
5399 if(!style.nonClient && style.isActiveClient)
5401 tmpPrev = prevOrder;
5404 client = tmpPrev ? tmpPrev.data : null;
5405 if(client == this) { client = null; break; }
5406 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5407 tmpPrev = client.order.prev;
5411 prevOrder = tmpPrev;
5415 if(client && client.style.hidden) client = null;
5417 // parent.childrenOrder.Remove(order);
5420 if(parent && style.isActiveClient && visible)
5422 if(state == minimized) parent.numIcons--;
5423 parent.numPositions--;
5426 // TESTING THIS HERE!
5430 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5431 // to create a window inside a rootwindow that's being destroyed)
5432 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5434 if(master && !master.destroyed /*&&
5435 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5437 if(master.defaultControl == this)
5438 master.defaultControl = null;
5441 parent.OnChildAddedOrRemoved(this, true);
5442 if(parent && !parent.destroyed /*&&
5443 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5445 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5447 if(order && prevOrder && prevOrder.data != this && active)
5449 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5451 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5452 if(parent.activeClient == this)
5454 parent.activeClient = null;
5455 parent.UpdateActiveDocument(null);
5460 if(guiApp.interimWindow == this)
5463 PropagateActive(false, null, &goOn, true);
5467 //if(window.parent.activeChild == window)
5468 parent.activeChild = null;
5469 if(!style.nonClient /*&& style.isActiveClient*/)
5471 Window previous = parent.activeClient;
5472 if(style.isActiveClient)
5473 parent.activeClient = null;
5474 parent.UpdateActiveDocument(previous);
5479 else if(parent.activeClient == this)
5481 parent.activeClient = client;
5482 parent.UpdateActiveDocument(this);
5486 if(guiApp.interimWindow == this)
5488 guiApp.interimWindow = null;
5489 if(guiApp.caretOwner)
5491 Window desktop = guiApp.desktop;
5492 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5493 guiApp.caretOwner.UpdateCaret(false, false);
5498 if(_isModal && master && master.modalSlave == this)
5499 master.modalSlave = null;
5503 if(!guiApp.caretOwner && parent.caretSize)
5505 guiApp.caretOwner = parent;
5506 parent.UpdateCaret(false, false);
5507 parent.Update(null);
5510 // Why was this commented out?
5511 GetRidOfVirtualArea();
5517 dirtyArea.Free(null);
5518 dirtyBack.Free(null);
5519 scrollExtent.Free(null);
5521 /* ATTEMPTING TO MOVE THAT ABOVE
5530 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5531 for(;(child = window.children.first);)
5533 for(; child && (child.destroyed || !child.created); child = child.next);
5542 UnloadGraphics(true);
5545 delete previousActive;
5548 // statusBar = null;
5551 if(master && !master.destroyed)
5553 //master.NotifyDestroyed(this, this.returnCode);
5554 NotifyDestroyed(master, this, this.returnCode);
5557 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5559 nextTimer = timer.next;
5560 if(timer.window == this)
5562 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5563 // timer.window = null;
5569 if(this == guiApp.windowMoving)
5572 if(guiApp.windowCaptured == this)
5574 //guiApp.windowCaptured = null;
5576 if(rootWindow != this && rootWindow)
5577 rootWindow.ConsequentialMouseMove(false);
5585 //for(child = children.first; next = child ? child.next : null, child; child = next)
5586 for(;(child = children.first); )
5588 for(; child && (child.destroyed || !child.created); child = child.next);
5598 /* // MOVED THIS UP...
5601 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5602 for(;(child = window.children.first); )
5604 for(; child && (child.destroyed || !child.created); child = child.next);
5613 while((slave = slaves.first))
5615 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5617 ((Window)slave.data).DestroyEx(0);
5622 if(guiApp.caretOwner == this)
5623 guiApp.caretOwner = null;
5625 sysButtons[0] = null;
5626 sysButtons[1] = null;
5627 sysButtons[2] = null;
5630 if(rootWindow != this)
5632 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5635 box.left -= parent.clientStart.x;
5636 box.top -= parent.clientStart.y;
5637 box.right -= parent.clientStart.x;
5638 box.bottom -= parent.clientStart.y;
5640 if(parent) parent.Update(box);
5645 OldLink slave = master.slaves.FindVoid(this);
5646 master.slaves.Delete(slave);
5652 parent.children.Remove(this);
5657 //autoCreate = false;
5660 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5661 if(((subclass(Window))_class).pureVTbl)
5663 if(_vTbl == _class._vTbl)
5665 _vTbl = ((subclass(Window))_class).pureVTbl;
5670 for(m = 0; m < _class.vTblSize; m++)
5672 if(_vTbl[m] == _class._vTbl[m])
5673 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5682 void SetStateEx(WindowState newState, bool activate)
5685 WindowState prevState = state;
5689 if(prevState != newState)
5690 lastState = prevState;
5692 if(rootWindow != this || !nativeDecorations || !windowHandle)
5694 if(style.isActiveClient && !style.hidden && prevState == minimized)
5697 // This block used to be at the end of the function... moved it for flicker problem in X
5698 // ------------------------------------------------------
5702 stateAnchor = normalAnchor;
5703 stateSizeAnchor = normalSizeAnchor;
5706 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5707 stateSizeAnchor = SizeAnchor {};
5711 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5714 byte * idBuffer = new0 byte[size];
5716 for(child = parent.children.first; child; child = child.next)
5718 if(child != this && child.state == minimized)
5720 if(child.iconID > size - 2)
5722 idBuffer = renew0 idBuffer byte[size*2];
5723 memset(idBuffer + size, 0, size);
5726 idBuffer[child.iconID] = (byte)bool::true;
5729 for(c = 0; c<size; c++)
5734 if(style.isActiveClient && !style.hidden)
5737 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5738 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5742 // TOCHECK: Why was this here?
5743 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5744 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5745 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5747 Position(x, y, w, h, true, true, true, true, false, true);
5749 if(!style.inactive && !style.interim && this == parent.activeClient)
5750 parent.UpdateActiveDocument(null);
5753 CreateSystemChildren();
5754 // ------------------------------------------------------
5757 int GetPositionID(Window forChild)
5761 byte * idBuffer = new0 byte[size];
5764 for(child = children.first; child; child = child.next)
5766 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5768 if(child.positionID > size - 2)
5770 idBuffer = renew0 idBuffer byte[size*2];
5771 memset(idBuffer + size, 0, size);
5774 idBuffer[child.positionID] = (byte)bool::true;
5777 for(c = 0; c<size; c++)
5784 // --- Window related graphics ---
5786 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5788 palette = newPalette;
5789 if(rootWindow.display)
5790 rootWindow.display.SetPalette(palette, colorMatch);
5793 public bool AcquireInput(bool acquired)
5796 if(acquiredInput != acquired)
5798 if(active || (!visible && creationActivation == activate))
5799 result = AcquireInputEx(acquired);
5804 acquiredInput = acquired ? result : !result;
5809 void ListChildren(ListBox listBox)
5813 for(child = children.first; child; child = child.next)
5815 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5817 DataRow row = listBox.AddRow();
5818 row.tag = (int64)child;
5819 child.FigureCaption(caption);
5820 row.SetData(null, caption);
5825 void UpdateVisual(Box extent)
5827 if(guiApp.driver != null)
5829 if(guiApp.fullScreenMode && guiApp.desktop.display)
5831 guiApp.desktop.mutex.Wait();
5832 guiApp.desktop.display.Lock(true);
5835 if(guiApp.desktop.active)
5837 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5839 if(guiApp.desktop.display.flags.flipping)
5840 guiApp.desktop.Update(null);
5841 guiApp.desktop.UpdateDisplay();
5842 guiApp.cursorUpdate = true;
5844 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5846 guiApp.PreserveAndDrawCursor();
5847 // guiApp.desktop.display.ShowScreen();
5848 guiApp.cursorUpdate = false;
5849 guiApp.desktop.dirty = false;
5850 guiApp.RestoreCursorBackground();
5854 guiApp.desktop.display.Unlock();
5855 guiApp.desktop.mutex.Release();
5859 Window rootWindow = this.rootWindow;
5860 rootWindow.mutex.Wait();
5865 guiApp.SignalEvent();
5868 guiApp.waitMutex.Wait();
5869 guiApp.interfaceDriver.Lock(rootWindow);
5870 if(!rootWindow.style.hidden && rootWindow.dirty)
5872 if(rootWindow.display)
5874 rootWindow.UpdateDisplay();
5875 //rootWindow.display.ShowScreen(null);
5877 rootWindow.dirty = false;
5879 guiApp.interfaceDriver.Unlock(rootWindow);
5880 guiApp.waitMutex.Release();
5883 rootWindow.mutex.Release();
5888 void UnlockDisplay(void)
5890 guiApp.interfaceDriver.Unlock(rootWindow);
5893 void LockDisplay(void)
5895 guiApp.interfaceDriver.Lock(rootWindow);
5898 Surface GetSurface(Box box)
5900 return Redraw((box == null) ? this.box : box);
5903 void SetMousePosition(int x, int y)
5905 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5909 void IntegrationActivate(bool active)
5911 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5913 isForegroundWindow = true;
5914 ActivateEx(active, active, false, false, null, null);
5915 isForegroundWindow = false;
5920 Window QueryCapture(void)
5922 return guiApp.windowCaptured;
5925 int GetDocumentID(void)
5929 byte * idBuffer = new0 byte[size];
5932 for(child = children.first; child; child = child.next)
5934 // TO CHECK: Do we want a documentID when we already have a file name?
5935 if(child.style.isDocument && !child.fileName)
5937 if(child.documentID-1 > size - 2)
5939 idBuffer = renew0 idBuffer byte[size*2];
5940 memset(idBuffer + size, 0, size);
5943 idBuffer[child.documentID-1] = 1;
5946 for(c = 0; c<size; c++)
5954 void SetInitSize(Size size)
5957 sizeAnchor.size = size;
5958 normalSizeAnchor = sizeAnchor;
5960 // Break the anchors for moveable/resizable windows
5961 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5963 stateAnchor = normalAnchor;
5964 stateSizeAnchor = normalSizeAnchor;
5966 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5967 Position(x,y, w, h, true, true, true, true, false, true);
5971 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5973 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5975 guiApp.windowIsResizing = resize;
5976 guiApp.windowMoving = this;
5977 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5978 if(guiApp.windowIsResizing)
5980 guiApp.windowMovingStart.x += size.w - 1;
5981 guiApp.windowMovingStart.y += size.h - 1;
5983 guiApp.windowMovingBefore = scrolledPos;
5984 guiApp.windowResizingBefore = size;
5985 guiApp.windowMoving.UpdateDecorations();
5986 if(guiApp.windowIsResizing)
5987 guiApp.resizeEndX = guiApp.resizeEndY = true;
5989 if(setCursorPosition)
5990 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5994 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5995 guiApp.windowMovingStart.x += x - absPosition.x;
5996 guiApp.windowMovingStart.y += y - absPosition.y;
5999 if(guiApp.windowMoving)
6001 if(guiApp.windowMoving.style.nonClient)
6002 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6004 guiApp.windowMoving.parent.SetMouseRangeToClient();
6009 if(this == rootWindow)
6010 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6018 bool result = false;
6022 else if(guiApp && guiApp.driver != null)
6024 void * systemParent = null;
6025 OldLink slaveHolder;
6027 bool visible = !style.hidden;
6031 systemParent = parent;
6032 parent = guiApp.desktop;
6034 last = parent ? parent.children.last : null;
6036 if((parent && parent != guiApp.desktop && !parent.created) ||
6037 (master && master != guiApp.desktop && !master.created))
6041 stopwatching(parent, font);
6044 property::parent = guiApp.desktop;
6045 if(!master) master = parent;
6047 if(_isModal && master.modalSlave)
6048 property::master = master.modalSlave;
6052 parent.children.Remove(this);
6055 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6056 if(slaveHolder.data == this)
6058 master.slaves.Delete(slaveHolder);
6063 if(parent == guiApp.desktop && !mutex)
6066 if(style.isDocument)
6069 parent.numDocuments--;
6070 documentID = parent.GetDocumentID();
6073 if(!style.stayOnTop)
6074 for(; last && last.style.stayOnTop; last = last.prev);
6076 parent.children.Insert((last == this) ? null : last, this);
6077 //parent.children.Add(this);
6080 dispDriver = parent.dispDriver;
6083 master.modalSlave = this;
6085 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6090 master.slaves.Add(slaveHolder = OldLink { data = this });
6095 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6097 if(style.isDefault && !master.defaultControl)
6098 master.defaultControl = this;
6100 stateAnchor = normalAnchor = anchor;
6101 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6103 // TOCHECK: Why is this here?
6104 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6105 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6107 this.visible = false;
6108 style.hidden = true;
6111 // autoCreate = true;
6119 if(parent == guiApp.desktop)
6120 Log("LoadGraphics %s\n", caption);
6122 if(LoadGraphics(true, false))
6130 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6137 if(style.hasMenuBar /*&& menu*/)
6143 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6144 interim = false, inactive = true, nonClient = true, size.h = 24
6152 // Create the system buttons
6153 CreateSystemChildren();
6155 UpdateActiveDocument(null);
6157 if(style.isDocument)
6161 MenuItem item = menu.FindItem(MenuFileSave, 0);
6162 if(item) item.disabled = !modifiedDocument && fileName;
6167 if(parent == guiApp.desktop)
6168 Log("Preemptive SetState %s\n", caption);
6171 // Preemptive Set State to ensure proper anchoring
6172 SetStateEx(state, false);
6174 style.hidden = true;
6180 for(child = children.first; child; child = next)
6183 if(!child.created && (child.autoCreate || child.wasCreated))
6190 for(link = slaves.first; link; link = next)
6192 Window slave = link.data;
6194 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6197 // Things might have happened that invalidated 'next'...
6198 // Start over the search for slaves to create.
6199 // (Added this to fix crash with Stacker & Toolbar)
6200 next = slaves.first;
6209 if(parent == guiApp.desktop)
6210 Log("Real SetState %s\n", caption);
6213 if(isActiveClient && visible)
6215 parent.numPositions--;
6216 if(state == minimized) parent.numIcons--;
6219 parent.OnChildAddedOrRemoved(this, false);
6221 // Real set state & activate for proper display & activation
6222 property::visible = visible;
6223 // SetState(state & 0x00000003, true, 0);
6224 guiApp.interfaceDriver.SetIcon(this, icon);
6229 /*if(rootWindow == this)
6230 guiApp.interfaceDriver.ActivateRootWindow(this);
6232 if(creationActivation == activate)
6233 ActivateEx(true, false, true, true, null, null);
6234 else if(creationActivation == flash)
6239 rootWindow.ConsequentialMouseMove(false);
6250 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6256 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6258 //style.hidden = true; // !visible;
6259 style.hidden = !visible;
6260 if(master.modalSlave == this)
6261 master.modalSlave = null;
6268 void WriteCaption(Surface surface, int x, int y)
6271 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6274 void Update(Box region)
6280 rootWindow = this.rootWindow;
6282 // rootWindow.mutex.Wait();
6283 if(!destroyed && visible && display)
6288 // Testing this to avoid repetitve full update to take time...
6289 if(dirtyArea.count == 1)
6291 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6292 if(item.box.left <= box.left &&
6293 item.box.top <= box.top &&
6294 item.box.right >= box.right &&
6295 item.box.bottom >= box.bottom)
6297 rootWindow.dirty = true;
6302 if(display.flags.flipping && !rootWindow.dirty)
6304 if(this == rootWindow)
6308 rootWindow.Update(null);
6313 rootWindow.dirty = true;
6318 realBox.left += clientStart.x;
6319 realBox.top += clientStart.y;
6320 realBox.right += clientStart.x;
6321 realBox.bottom += clientStart.y;
6327 if(realBox.right >= realBox.left &&
6328 realBox.bottom >= realBox.top)
6330 // if(!rootWindow.fullRender)
6331 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6333 for(child = children.first; child; child = child.next)
6338 box.left -= child.absPosition.x - absPosition.x;
6339 box.top -= child.absPosition.y - absPosition.y;
6340 box.right -= child.absPosition.x - absPosition.x;
6341 box.bottom -= child.absPosition.y - absPosition.y;
6342 if(box.right >= child.box.left && box.left <= child.box.right &&
6343 box.bottom >= child.box.top && box.top <= child.box.bottom)
6345 box.left -= child.clientStart.x;
6346 box.top -= child.clientStart.y;
6347 box.right -= child.clientStart.x;
6348 box.bottom -= child.clientStart.y;
6354 realBox.left += absPosition.x - rootWindow.absPosition.x;
6355 realBox.top += absPosition.y - rootWindow.absPosition.y;
6356 realBox.right += absPosition.x - rootWindow.absPosition.x;
6357 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6358 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6361 else if(this == guiApp.desktop)
6364 for(window = children.first; window; window = window.next)
6370 Box childBox = region;
6372 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6373 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6374 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6375 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6377 window.Update(childBox);
6380 window.Update(null);
6385 // rootWindow.mutex.Release();
6392 if(guiApp.windowCaptured != this)
6394 if(guiApp.windowCaptured)
6398 //Logf("Captured %s (%s)\n", caption, class.name);
6399 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6400 guiApp.windowCaptured = this;
6406 bool Destroy(int64 code)
6411 if(!destroyed && !CloseConfirmation(false)) return false;
6415 // TOCHECK: Should autoCreate be set to false here?
6426 void Move(int x, int y, int w, int h)
6428 normalAnchor = Anchor { left = x, top = y };
6429 normalSizeAnchor = SizeAnchor { size = { w, h } };
6431 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6433 if(destroyed) return;
6435 stateAnchor = normalAnchor;
6436 stateSizeAnchor = normalSizeAnchor;
6438 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6439 Position(x,y, w, h, true, true, true, true, false, true);
6443 DialogResult Modal(void)
6449 // FIXES MEMORY LEAK IF Create() FAILED
6455 void SetScrollArea(int width, int height, bool snapToStep)
6457 bool resize = false;
6460 int stepX = sbStep.x, stepY = sbStep.y;
6461 // Needed to make snapped down position match the skin's check of client area
6462 // against realvirtual
6465 SNAPDOWN(stepX, textCellW);
6466 SNAPDOWN(stepY, textCellH);
6467 stepX = Max(stepX, textCellW);
6468 stepY = Max(stepY, textCellH);
6470 if(scrollFlags.snapX)
6471 SNAPUP(width, stepX);
6472 if(scrollFlags.snapY)
6473 SNAPUP(height, stepY);
6476 reqScrollArea.w = width;
6477 reqScrollArea.h = height;
6478 noAutoScrollArea = (width > 0 || height > 0);
6480 UpdateScrollBars(true, true);
6483 void SetScrollPosition(int x, int y)
6486 sbh.Action(setPosition, x, 0);
6490 int seen = clientSize.w, total = reqScrollArea.w;
6492 if(scrollFlags.snapX)
6493 SNAPDOWN(seen, sbStep.x);
6495 if(!total) total = seen;
6496 range = total - seen + 1;
6497 range = Max(range, 1);
6499 if(x >= range) x = range - 1;
6501 if(scrollFlags.snapX)
6502 SNAPUP(x, sbStep.x);
6505 OnHScroll(setPosition, x, 0);
6509 SNAPDOWN(x, textCellW);
6515 sbv.Action(setPosition, y, 0);
6519 int seen = clientSize.h, total = reqScrollArea.h;
6522 if(scrollFlags.snapY)
6523 SNAPDOWN(seen, sbStep.y);
6525 if(!total) total = seen;
6526 range = total - seen + 1;
6527 range = Max(range, 1);
6529 if(y >= range) y = range - 1;
6531 if(scrollFlags.snapY)
6532 SNAPUP(y, sbStep.y);
6535 OnVScroll(setPosition, y, 0);
6538 SNAPDOWN(y, textCellH);
6543 UpdateCaret(false, false);
6546 void SetScrollLineStep(int stepX, int stepY)
6552 SNAPDOWN(stepX, textCellW);
6553 SNAPDOWN(stepY, textCellH);
6554 stepX = Max(stepX, textCellW);
6555 stepY = Max(stepY, textCellH);
6558 sbh.lineStep = stepX;
6560 sbv.lineStep = stepY;
6563 void SetState(WindowState newState, bool activate, Modifiers mods)
6567 if(state == newState || OnStateChange(newState, mods))
6569 WindowState prevState = state;
6573 // This used to be at the end of the brackets... moved for X, testing...
6574 // This has the effect of activating the window through the system...
6575 if(rootWindow == this)
6576 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6578 SetStateEx(newState, activate);
6580 if(rootWindow == this && !rootWindow.nativeDecorations)
6582 int x = position.x, y = position.y;
6585 x -= guiApp.desktop.absPosition.x;
6586 y -= guiApp.desktop.absPosition.y;
6588 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6592 //state = prevState;
6594 if(state != maximized && style.hasMaximize)
6597 for(child = parent.children.first; child; child = child.next)
6599 if(child != this && child.state == maximized)
6600 child.SetStateEx(normal, false);
6604 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6605 parent.UpdateScrollBars(true, true);
6608 // Do we really need this stuff here?
6609 // Shouldn't the Activate stuff take care of it?
6610 if(parent.rootWindow == parent && style)
6613 parent.FigureCaption(caption);
6614 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6615 parent.UpdateDecorations();
6619 rootWindow.ConsequentialMouseMove(false);
6626 BitmapResource GetIcon(SkinBitmap iconID)
6628 return guiApp.currentSkin.GetBitmap(iconID);
6631 void SetMouseRange(Box range)
6633 if(range || guiApp.fullScreenMode)
6638 clip.left = range.left + absPosition.x + clientStart.x;
6639 clip.top = range.top + absPosition.y + clientStart.y;
6640 clip.right = range.right + absPosition.x + clientStart.x;
6641 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6645 clip.left = guiApp.desktop.box.left;
6646 clip.top = guiApp.desktop.box.top;
6647 clip.right = guiApp.desktop.box.right;
6648 clip.bottom = guiApp.desktop.box.bottom;
6650 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6653 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6656 void SetMouseRangeToClient(void)
6658 if(guiApp.fullScreenMode || this != guiApp.desktop)
6660 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6661 box.Clip(clientArea);
6665 SetMouseRange(null);
6668 void SetMouseRangeToWindow(void)
6670 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6671 if(this == guiApp.desktop)
6672 SetMouseRangeToClient();
6677 // x, y: Desktop Coordinates
6678 void ShowSysMenu(int x, int y)
6681 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6684 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6685 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6689 menu, $"Move", m, NotifySelect = MenuWindowMove,
6690 disabled = !style.fixed || state == maximized
6694 menu, $"Size", s, NotifySelect = MenuWindowSize,
6695 disabled = !style.sizable || state != normal
6699 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6700 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6704 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6705 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6709 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6710 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6712 MenuDivider { menu };
6715 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6716 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6718 windowMenu.Create();
6723 ActivateEx(true, true, true, true, null, null);
6726 void MakeActive(void)
6728 ActivateEx(true, false, true, false, null, null);
6731 void SoftActivate(void)
6733 if(guiApp.desktop.active)
6739 void Deactivate(void)
6741 ActivateEx(false, true, true, true, null, null);
6746 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6749 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6751 bool result = false;
6752 if(activeChild && activeChild.cycle)
6754 Window modalWindow, child = activeChild;
6755 if(!clientOnly /*&& parent.tabCycle*/)
6757 Window next = child;
6760 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6764 if(parent && parent.CycleChildren(backward, false, true, true))
6772 next = next.cycle.prev.data;
6774 next = next.cycle.next.data;
6775 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6780 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6781 parent.tabCycle && parent.CycleChildren(backward, false, false))
6785 if(tabCycleOnly && !tabCycle) return false;
6792 child = child.cycle.prev.data;
6794 child = child.cycle.next.data;
6795 if(child == child.parent.activeChild)
6797 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6800 modalWindow = child.FindModal();
6803 // Scroll the window to include the active control
6804 if(sbh && !child.style.dontScrollHorz)
6806 if(child.scrolledPos.x < 0)
6807 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6808 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6809 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6811 if(sbv && !child.style.dontScrollVert)
6813 if(child.scrolledPos.y < 0)
6814 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6815 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6816 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6820 child = modalWindow ? modalWindow : child;
6821 child.ActivateEx(true, true, true, true, null, null);
6822 if(child.tabCycle && child.childrenCycle.first)
6823 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6831 ConsequentialMouseMove(false);
6835 void AddResource(Resource resource)
6839 ResPtr ptr { resource = resource };
6843 // Load Graphics here if window is created already
6844 if(/*created && */display)
6846 display.Lock(false);
6847 ptr.loaded = display.displaySystem.LoadResource(resource);
6851 // Temporary hack to load font right away for listbox in dropbox ...
6852 else if(master && master.display)
6854 master.display.Lock(false);
6855 master.display.displaySystem.LoadResource(resource);
6856 master.display.Unlock();
6862 void RemoveResource(Resource resource)
6867 for(ptr = resources.first; ptr; ptr = ptr.next)
6869 if(ptr.resource == resource)
6875 // Unload Graphics here if window is created already
6876 if(/*created && */display)
6880 display.Lock(false);
6881 display.displaySystem.UnloadResource(resource, ptr.loaded);
6887 resources.Delete(ptr);
6892 void SetCaret(int x, int y, int size)
6899 if(active && !style.interim)
6901 if(visible || !guiApp.caretOwner)
6902 guiApp.caretOwner = size ? this : null;
6904 UpdateCaret(false, false);
6907 guiApp.interfaceDriver.SetCaret(0,0,0);
6908 UpdateCaret(false, true);
6909 guiApp.caretEnabled = false;
6912 else if(style.inactive && active)
6914 guiApp.interfaceDriver.SetCaret(0,0,0);
6915 UpdateCaret(false, true);
6916 guiApp.caretEnabled = false;
6921 void Scroll(int x, int y)
6923 bool opaque = !style.drawBehind || background.a;
6924 if(opaque && display && display.flags.scrolling)
6926 Box box = clientArea;
6927 box.left += clientStart.x;
6928 box.top += clientStart.y;
6929 box.right += clientStart.x;
6930 box.bottom += clientStart.y;
6932 //scrollExtent.Free(null);
6933 scrollExtent.AddBox(box);
6934 scrolledArea.x += x;
6935 scrolledArea.y += y;
6937 //scrollExtent.Free();
6938 //scrollExtent.AddBox(clientArea);
6939 //scrollExtent.Offset(clientStart.x, clientStart.y);
6940 //scrolledArea.x = x;
6941 //scrolledArea.y = y;
6947 rootWindow.dirty = true;
6950 void ReleaseCapture()
6952 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6954 Window oldCaptured = guiApp.windowCaptured;
6955 guiApp.windowCaptured = null;
6956 guiApp.prevWindow = null;
6959 //guiApp.Log("Released Capture\n");
6961 guiApp.interfaceDriver.SetMouseCapture(null);
6963 //oldCaptured.OnMouseCaptureLost();
6966 oldCaptured.ConsequentialMouseMove(false);
6971 private void _SetCaption(char * format, va_list args)
6978 char caption[MAX_F_STRING];
6979 vsnprintf(caption, sizeof(caption), format, args);
6980 caption[sizeof(caption)-1] = 0;
6982 this.caption = CopyString(caption);
6987 firewatchers caption;
6991 /*deprecated*/ void SetText(char * format, ...)
6994 va_start(args, format);
6995 _SetCaption(format, args);
6999 void SetCaption(char * format, ...)
7002 va_start(args, format);
7003 _SetCaption(format, args);
7007 bool Grab(Bitmap bitmap, Box box, bool decorations)
7009 bool result = false;
7010 if(display || this == guiApp.desktop)
7012 Box clip = {MININT, MININT, MAXINT, MAXINT};
7018 clip.Clip(clientArea);
7020 clip.Clip(this.box);
7022 if(rootWindow != this)
7024 clip.left += absPosition.y;
7025 clip.top += absPosition.y;
7026 clip.right += absPosition.x;
7027 clip.bottom += absPosition.y;
7030 clip.left += decorations ? 0 : clientStart.x;
7031 clip.top += decorations ? 0 : clientStart.y;
7032 clip.right += decorations ? 0 : clientStart.x;
7033 clip.bottom += decorations ? 0 : clientStart.y;
7035 if(display && display.flags.flipping)
7037 rootWindow.Update(null);
7038 rootWindow.UpdateDisplay();
7045 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7046 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7050 result = display.Grab(bitmap, clip.left, clip.top,
7051 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7053 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7055 if(!bitmap.Convert(null, pixelFormat888, null))
7062 void GetMousePosition(int * x, int * y)
7064 int mouseX = 0, mouseY = 0;
7065 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7068 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7069 if(this != guiApp.desktop)
7071 mouseX -= absPosition.x + clientStart.x;
7072 mouseY -= absPosition.y + clientStart.y;
7079 DialogResult DoModal()
7081 DialogResult returnCode = 0;
7082 int terminated = terminateX;
7085 while(!destroyed && guiApp.driver != null)
7087 if(terminateX != terminated)
7089 terminated = terminateX;
7090 guiApp.desktop.Destroy(0);
7091 if(guiApp.desktop.created)
7094 //printf("Resetting terminate X to 0\n");
7100 guiApp.UpdateDisplay();
7101 if(!guiApp.ProcessInput(false))
7104 returnCode = this.returnCode;
7117 return !destroyed && guiApp.driver != null && terminateX < 2;
7120 DialogResult DoModalEnd()
7122 DialogResult returnCode = this.returnCode;
7127 // --- Window manipulation ---
7128 /*bool GetDisabled()
7130 bool disabled = this.disabled;
7132 for(window = this; (window = window.master); )
7143 // --- Mouse Manipulation ---
7144 void GetNCMousePosition(int * x, int * y)
7146 GetMousePosition(x, y);
7147 if(x) *x += clientStart.x;
7148 if(y) *y += clientStart.y;
7151 // --- Carets manipulation ---
7152 void GetCaretPosition(Point caretPos)
7154 caretPos = this.caretPos;
7157 int GetCaretSize(void)
7162 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7168 bool CloseConfirmation(bool parentClosing)
7181 if(!OnClose(parentClosing))
7184 // If you want to skip this, simply set modifiedDocument to false in OnClose
7185 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7187 DialogResult dialogRes;
7190 sprintf(message, $"Save changes to %s?", fileName);
7192 sprintf(message, $"Save changes to Untitled %d?", documentID);
7194 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7196 if(dialogRes == yes)
7198 // TOFIX: Precomp error if brackets are taken out
7199 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7201 else if(dialogRes == cancel)
7207 for(slave = slaves.first; slave; slave = slave.next)
7209 Window w = slave.data;
7210 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7212 // ((Window)slave.data).CloseConfirmation(true);
7221 for(child = children.first; child; child = child.next)
7222 if(child.master != this && !child.CloseConfirmation(true))
7232 // Static methods... move them somewhere else?
7233 void ::RestoreCaret()
7235 if(guiApp.caretOwner)
7236 guiApp.caretOwner.UpdateCaret(false, false);
7239 void ::FreeMouseRange()
7241 guiApp.interfaceDriver.SetMouseRange(null, null);
7245 bool MenuFileClose(MenuItem selection, Modifiers mods)
7247 Window document = activeChild;
7249 document.Destroy(0);
7253 bool MenuFileExit(MenuItem selection, Modifiers mods)
7259 bool MenuFileSave(MenuItem selection, Modifiers mods)
7263 fileMonitor.fileName = null;
7266 if(OnSaveFile(fileName))
7268 //if(OnFileModified != Window::OnFileModified)
7271 fileMonitor.fileName = fileName;
7277 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7278 DialogResult answer = dialog.Modal();
7280 if(answer != yes) return (bool)answer;
7283 return MenuFileSaveAs(selection, mods);
7286 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7288 DialogResult result = (DialogResult)bool::true;
7289 FileDialog fileDialog = saveDialog;
7292 fileDialog = FileDialog {};
7297 fileDialog.filePath = fileName;
7300 char filePath[MAX_FILENAME];
7301 sprintf(filePath, "Untitled %d", documentID);
7302 fileDialog.filePath = filePath;
7304 fileMonitor.fileName = null;
7306 fileDialog.type = save;
7307 fileDialog.text = $"Save As";
7311 fileDialog.master = master.parent ? master : this;
7312 if(fileDialog.Modal() == ok)
7314 char * filePath = fileDialog.filePath;
7316 if(OnSaveFile(filePath))
7319 property::fileName = filePath;
7320 NotifySaved(master, this, filePath);
7325 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7326 DialogResult answer = dialog.Modal();
7341 //if(OnFileModified != Window::OnFileModified && fileName)
7344 fileMonitor.fileName = fileName;
7348 return (bool)result; // Actually returning result from Yes/NoCancel message box
7351 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7353 Window document = activeChild;
7355 for(document = children.first; document; document = next)
7357 next = document.next;
7358 if(document.style.isDocument || document.fileName)
7359 document.MenuFileSave(selection, mods);
7364 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7368 for(document = children.first; document; document = document.next)
7369 //if(document.style.isDocument && document.state == minimized)
7370 if(document.style.isActiveClient && document.state == minimized)
7371 document.SetState(minimized, false, mods);
7375 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7377 Window document = activeChild;
7380 Window firstDocument = null;
7382 OldLink cycle = document.cycle.prev;
7387 if(child.style.isActiveClient && !child.style.hidden)
7391 firstDocument = child;
7392 if(child.state == minimized)
7393 child.SetState(minimized, false, mods);
7396 child.positionID = id++;
7397 child.SetState(normal, false, mods);
7398 child.anchor.left.type = cascade;
7401 child.normalSizeAnchor = *&child.sizeAnchor;
7402 child.normalAnchor = child.anchor;
7404 // Break the anchors for moveable/resizable windows
7405 if(child.style.fixed)
7407 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7409 (*&child.normalAnchor).left = x;
7410 (*&child.normalAnchor).top = y;
7411 (*&child.normalAnchor).right.type = none;
7412 (*&child.normalAnchor).bottom.type = none;
7414 child.normalSizeAnchor.isClientW = false;
7415 child.normalSizeAnchor.isClientH = false;
7416 child.normalSizeAnchor.size.w = w;
7417 child.normalSizeAnchor.size.h = h;
7418 child.anchored = false;
7421 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7423 child.stateAnchor = child.normalAnchor;
7424 child.stateSizeAnchor = child.normalSizeAnchor;
7426 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7427 child.Position(x, y, w, h, true, true, true, true, false, false);
7432 last = children.last;
7433 if(!child.style.stayOnTop)
7434 for(; last && last.style.stayOnTop; last = last.prev);
7435 children.Move(child, last);
7436 childrenOrder.Move(child.order, childrenOrder.last);
7438 if(cycle == document.cycle) break;
7442 firstDocument.Activate();
7447 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7454 // Close all closes all active clients, not all documents
7455 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7457 Window next, document;
7459 for(document = children.first; document; document = next)
7461 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7462 if(document.style.isActiveClient)
7463 if(!document.Destroy(0) && !document.style.hidden)
7469 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7471 if(style.hasMaximize && state != maximized)
7472 SetState(maximized, 0, 0);
7476 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7478 if(style.hasMinimize && state != minimized)
7480 SetState(minimized, 0, 0);
7481 parent.CycleChildren(false, true, false, true);
7486 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7488 MenuMoveOrSize(false, selection ? true : false);
7492 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7494 CycleChildren(false, true, false, true);
7498 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7500 CycleChildren(true, true, false, true);
7504 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7506 MenuMoveOrSize(true, true);
7510 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7513 SetState(normal, 0, 0);
7517 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7520 int64 id = selection.id;
7521 OldLink cycle = activeClient.cycle;
7523 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7526 Window sibling = cycle.data;
7527 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7535 document = cycle.data;
7536 document.Activate();
7538 //if(activeChild.state == maximized)
7539 // document.SetState(maximized, false, mods);
7540 //else if(document.state == minimized)
7541 // document.SetState(normal, false, mods);
7545 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7547 stayOnTop = !style.stayOnTop;
7551 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7553 Window document = activeChild;
7556 Window firstDocument = null;
7557 OldLink cycle = document.cycle;
7561 Window child = cycle.data;
7562 if(child.style.isActiveClient && !child.style.hidden)
7564 if(!firstDocument) firstDocument = child;
7565 if(child.state == minimized)
7566 child.SetState(minimized, false, mods);
7569 child.positionID = id++;
7570 child.SetState(normal, false, mods);
7571 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7573 child.anchor.left.type = hTiled;
7576 child.normalSizeAnchor = *&child.sizeAnchor;
7577 child.normalAnchor = child.anchor;
7579 // Break the anchors for moveable/resizable windows
7580 if(child.style.fixed)
7582 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7584 (*&child.normalAnchor).left = x;
7585 (*&child.normalAnchor).top = y;
7586 (*&child.normalAnchor).right.type = none;
7587 (*&child.normalAnchor).bottom.type = none;
7588 child.normalSizeAnchor.isClientW = false;
7589 child.normalSizeAnchor.isClientH = false;
7590 child.normalSizeAnchor.size.w = w;
7591 child.normalSizeAnchor.size.h = h;
7592 child.anchored = false;
7595 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7597 child.stateAnchor = child.normalAnchor;
7598 child.stateSizeAnchor = child.normalSizeAnchor;
7600 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7601 child.Position(x,y, w, h, true, true, true, true, false, true);
7606 if((cycle = cycle.next) == document.cycle) break;
7609 firstDocument.Activate();
7614 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7616 Window document = activeChild;
7619 Window firstDocument = null;
7621 OldLink cycle = document.cycle;
7626 //if(child.style.isDocument)
7627 if(child.style.isActiveClient && !child.style.hidden)
7629 if(!firstDocument) firstDocument = child;
7630 if(child.state == minimized)
7631 child.SetState(minimized, false, mods);
7634 child.positionID = id++;
7635 child.SetState(normal, false, mods);
7636 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7638 child.anchor.left.type = vTiled;
7641 child.normalSizeAnchor = *&child.sizeAnchor;
7642 child.normalAnchor = child.anchor;
7644 // Break the anchors for moveable/resizable windows
7645 if(child.style.fixed)
7647 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7649 (*&child.normalAnchor).left = x;
7650 (*&child.normalAnchor).top = y;
7651 (*&child.normalAnchor).right.type = none;
7652 (*&child.normalAnchor).bottom.type = none;
7653 child.normalSizeAnchor.isClientW = false;
7654 child.normalSizeAnchor.isClientH = false;
7655 child.normalSizeAnchor.size.w = w;
7656 child.normalSizeAnchor.size.h = h;
7657 child.anchored = false;
7660 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7662 child.stateAnchor = child.normalAnchor;
7663 child.stateSizeAnchor = child.normalSizeAnchor;
7665 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7666 child.Position(x,y, w, h, true, true, true, true, false, true);
7671 if((cycle = cycle.next) == document.cycle) break;
7674 firstDocument.Activate();
7679 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7681 WindowList dialog { master = this };
7682 Window document = (Window)dialog.Modal();
7685 if(activeChild.state == maximized)
7686 document.SetState(maximized, false, mods);
7687 else if(document.state == minimized)
7688 document.SetState(normal, false, mods);
7689 document.Activate();
7695 virtual bool OnCreate(void);
7696 virtual void OnDestroy(void);
7697 virtual void OnDestroyed(void);
7698 virtual bool OnClose(bool parentClosing);
7699 virtual bool OnStateChange(WindowState state, Modifiers mods);
7700 virtual bool OnPostCreate(void);
7701 virtual bool OnMoving(int *x, int *y, int w, int h);
7702 virtual bool OnResizing(int *width, int *height);
7703 virtual void OnResize(int width, int height);
7704 virtual void OnPosition(int x, int y, int width, int height);
7705 virtual bool OnLoadGraphics(void);
7706 virtual void OnApplyGraphics(void);
7707 virtual void OnUnloadGraphics(void);
7708 virtual void OnRedraw(Surface surface);
7709 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7710 virtual void OnActivateClient(Window client, Window previous);
7711 virtual bool OnKeyDown(Key key, unichar ch);
7712 virtual bool OnKeyUp(Key key, unichar ch);
7713 virtual bool OnKeyHit(Key key, unichar ch);
7714 virtual bool OnSysKeyDown(Key key, unichar ch);
7715 virtual bool OnSysKeyUp(Key key, unichar ch);
7716 virtual bool OnSysKeyHit(Key key, unichar ch);
7717 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7718 virtual bool OnMouseLeave(Modifiers mods);
7719 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7720 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7721 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7722 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7723 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7724 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7725 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7726 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7727 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7728 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7729 virtual void OnMouseCaptureLost(void);
7730 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7731 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7732 virtual void OnDrawOverChildren(Surface surface);
7733 virtual bool OnFileModified(FileChange fileChange, char * param);
7734 virtual bool OnSaveFile(char * fileName);
7736 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7737 // Note: A 'client' would refer to isActiveClient, rather than
7738 // being confined to the 'client area' (nonClient == false)
7739 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7740 virtual void OnChildVisibilityToggled(Window child, bool visible);
7741 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7743 // Skins Virtual Functions
7744 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7745 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7746 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7751 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7752 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7753 virtual bool IsMouseMoving(int x, int y, int w, int h)
7757 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7761 virtual void UpdateNonClient();
7762 virtual void SetBox(Box box);
7763 virtual bool IsInside(int x, int y)
7765 return box.IsPointInside({x, y});
7767 virtual bool IsOpaque()
7769 return (!style.drawBehind || background.a == 255);
7773 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7774 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7775 virtual void Window::NotifySaved(Window window, char * filePath);
7780 property Window parent
7782 property_category $"Layout"
7785 if(value || guiApp.desktop)
7788 Window oldParent = parent;
7789 Anchor anchor = this.anchor;
7791 if(value && value.IsDescendantOf(this)) return;
7792 if(value && value == this)
7794 if(!value) value = guiApp.desktop;
7796 if(value == oldParent) return;
7798 if(!master || (master == this.parent && master == guiApp.desktop))
7799 property::master = value;
7803 parent.children.Remove(this);
7807 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7808 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7809 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7810 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7814 last = value.children.last;
7816 if(style.isDocument)
7819 parent.numDocuments--;
7820 documentID = value.GetDocumentID();
7823 if(style.isActiveClient && !style.hidden)
7825 if(parent && parent != guiApp.desktop && !(style.hidden))
7827 if(state == minimized) parent.numIcons--;
7828 parent.numPositions--;
7832 if(!style.stayOnTop)
7833 for(; last && last.style.stayOnTop; last = last.prev);
7835 value.children.Insert(last, this);
7837 // *** NEW HERE: ***
7839 parent.childrenCycle.Delete(cycle);
7841 parent.childrenOrder.Delete(order);
7844 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7845 // Should something else be done?
7846 if(parent && parent.activeChild == this)
7847 parent.activeChild = null;
7848 if(parent && parent.activeClient == this)
7849 parent.activeClient = null;
7855 int x = position.x, y = position.y, w = size.w, h = size.h;
7859 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7860 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7862 vpw = value.clientSize.w;
7863 vph = value.clientSize.h;
7869 else if(style.fixed)
7871 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7872 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7875 anchor = this.anchor;
7877 if(anchor.left.type == offset) anchor.left.distance = x;
7878 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7879 if(anchor.top.type == offset) anchor.top.distance = y;
7880 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7881 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7882 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7883 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7884 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7885 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7886 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7888 if(!anchor.left.type && !anchor.right.type)
7890 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7891 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7893 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7894 if(!anchor.top.type && !anchor.bottom.type)
7896 anchor.vert.distance = (y + h / 2) - (vph / 2);
7897 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7899 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7902 parent.OnChildAddedOrRemoved(this, false);
7908 parent.childrenCycle.Insert(
7909 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7910 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7912 cycle = OldLink { data = this });
7913 parent.childrenOrder.Insert(
7914 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7915 order = OldLink { data = this });
7918 if(!style.hidden && style.isActiveClient)
7920 positionID = parent.GetPositionID(this);
7921 parent.numPositions++;
7922 if(state == minimized) parent.numIcons--;
7925 // *** FONT INHERITANCE ***
7926 if(!setFont && oldParent)
7927 stopwatching(oldParent, font);
7931 RemoveResource(systemFont);
7934 // TESTING WITH WATCHERS:
7935 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7936 // usedFont = setFont ? setFont : (systemFont);
7940 if(guiApp.currentSkin)
7942 systemFont = guiApp.currentSkin.SystemFont();
7945 usedFont = systemFont;
7946 AddResource(systemFont);
7954 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7963 if(value.rootWindow && value.rootWindow.display && rootWindow)
7965 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7966 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7969 UnloadGraphics(false);
7972 LoadGraphics(false, false);
7975 if(value.rootWindow != rootWindow)
7976 DisplayModeChanged();
7980 scrolledPos.x = MININT; // Prevent parent update
7982 bool anchored = this.anchored;
7983 property::anchor = anchor;
7984 this.anchored = anchored;
7989 if(guiApp.currentSkin)
7990 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7992 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7993 Position(x, y, w, h, true, true, true, true, false, true);
7998 // else parent = value;
8000 oldParent.OnChildAddedOrRemoved(this, true);
8003 get { return parent; }
8006 property Window master
8008 property_category $"Behavior"
8011 //if(this == value) return;
8012 if(value && value.IsSlaveOf(this)) return;
8018 OldLink slaveHolder;
8019 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8020 if(slaveHolder.data == this)
8022 master.slaves.Delete(slaveHolder);
8029 value.slaves.Add(OldLink { data = this });
8034 master.hotKeys.Remove(hotKey);
8035 value.hotKeys.Add(hotKey);
8038 if(master && master.defaultControl == this)
8039 master.defaultControl = null;
8041 if(style.isDefault && !value.defaultControl)
8042 value.defaultControl = this;
8047 get { return master ? master : parent; }
8050 property char * caption
8052 property_category $"Appearance"
8059 caption = new char[strlen(value)+1];
8061 strcpy(caption, value);
8066 get { return caption; }
8071 property_category $"Behavior"
8080 master.hotKeys.Add(hotKey = HotKeySlot { });
8084 hotKey.window = this;
8089 master.hotKeys.Delete(hotKey);
8094 get { return hotKey ? hotKey.key : 0; }
8097 property Color background
8099 property_category $"Appearance"
8102 background.color = value;
8107 if(this == rootWindow)
8108 guiApp.interfaceDriver.SetRootWindowColor(this);
8111 get { return background.color; }
8114 property Percentage opacity
8116 property_category $"Appearance"
8119 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8120 drawBehind = (background.a == 255) ? false : true;
8122 get { return background.a / 255.0f; }
8125 property Color foreground
8127 property_category $"Appearance"
8135 get { return foreground; }
8138 property BorderStyle borderStyle
8140 property_category $"Appearance"
8143 if(!((BorderBits)value).fixed)
8145 style.hasClose = false;
8146 style.hasMaximize = false;
8147 style.hasMinimize = false;
8148 nativeDecorations = false;
8150 style.borderBits = value;
8154 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8156 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8157 Position(x, y, w, h, true, true, true, true, false, true);
8158 CreateSystemChildren();
8161 get { return (BorderStyle)style.borderBits; }
8164 property Size minClientSize
8166 property_category $"Layout"
8167 set { minSize = value; }
8168 get { value = minSize; }
8171 property Size maxClientSize
8173 property_category $"Layout"
8174 set { maxSize = value; }
8175 get { value = maxSize; }
8178 property bool hasMaximize
8180 property_category $"Window Style"
8183 style.hasMaximize = value;
8184 if(value) { style.fixed = true; style.contour = true; }
8188 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8190 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8191 Position(x, y, w, h, true, true, true, true, false, true);
8193 CreateSystemChildren();
8196 get { return style.hasMaximize; }
8199 property bool hasMinimize
8201 property_category $"Window Style"
8204 style.hasMinimize = value;
8205 if(value) { style.fixed = true; style.contour = true; }
8209 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8211 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8212 Position(x, y, w, h, true, true, true, true, false, true);
8214 CreateSystemChildren();
8217 get { return style.hasMinimize; }
8220 property bool hasClose
8222 property_category $"Window Style"
8225 style.hasClose = value;
8226 if(value) { style.fixed = true; style.contour = true; }
8230 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8231 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8232 Position(x, y, w, h, true, true, true, true, false, true);
8233 CreateSystemChildren();
8236 get { return style.hasClose; }
8239 property bool nonClient
8241 property_category $"Layout"
8244 style.nonClient = value;
8246 style.stayOnTop = true;
8248 get { return style.nonClient; }
8251 property bool inactive
8253 property_category $"Behavior"
8258 // *** NEW HERE: ***
8262 parent.childrenCycle.Delete(cycle);
8264 parent.childrenOrder.Delete(order);
8271 active = false; // true;
8272 if(parent.activeChild == this)
8273 parent.activeChild = null;
8274 if(parent.activeClient == this)
8275 parent.activeClient = null;
8284 parent.childrenCycle.Insert(
8285 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8286 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8288 cycle = OldLink { data = this });
8290 parent.childrenOrder.Insert(
8291 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8292 order = OldLink { data = this });
8295 style.inactive = value;
8297 get { return style.inactive; }
8300 property bool clickThrough
8302 property_category $"Behavior"
8303 set { style.clickThrough = value; }
8304 get { return style.clickThrough; }
8307 property bool isRemote
8309 property_category $"Behavior"
8310 set { style.isRemote = value; }
8311 get { return style.isRemote; }
8314 property bool noCycle
8316 property_category $"Behavior"
8317 set { style.noCycle = value; }
8318 get { return style.noCycle; }
8321 property bool isModal
8323 property_category $"Behavior"
8324 set { style.modal = value; }
8325 get { return style.modal; }
8328 property bool interim
8330 property_category $"Behavior"
8331 set { style.interim = value; }
8332 get { return style.interim; }
8335 property bool tabCycle
8337 property_category $"Behavior"
8338 set { style.tabCycle = value; }
8339 get { return style.tabCycle; }
8342 property bool isDefault
8344 property_category $"Behavior"
8352 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8353 if(sibling != this && sibling.style.isDefault)
8354 sibling.style.isDefault = false;*/
8355 if(master.defaultControl)
8356 master.defaultControl.style.isDefault = false;
8357 master.defaultControl = this;
8359 else if(master.defaultControl == this)
8360 master.defaultControl = null;
8364 style.isDefault = value;
8366 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8368 get { return style.isDefault; }
8371 property bool drawBehind
8373 property_category $"Window Style"
8374 set { style.drawBehind = value; }
8375 get { return style.drawBehind; }
8378 property bool hasMenuBar
8380 property_category $"Window Style"
8390 if(created && !menuBar)
8397 anchor = Anchor { top = 23, left = 1, right = 1 },
8399 inactive = true, nonClient = true
8404 else if(created && menuBar)
8409 style.hasMenuBar = value;
8411 get { return style.hasMenuBar; }
8414 property bool hasStatusBar
8416 property_category $"Window Style"
8423 statusBar = StatusBar { this };
8431 style.hasStatusBar = value;
8433 get { return style.hasStatusBar; }
8435 property bool stayOnTop
8437 property_category $"Window Style"
8442 if(created && !style.stayOnTop)
8444 if(rootWindow == this)
8445 guiApp.interfaceDriver.OrderRootWindow(this, true);
8446 else if(parent.children.last != this)
8448 parent.children.Move(this, parent.children.last);
8452 style.stayOnTop = true;
8456 if(created && style.stayOnTop)
8458 if(rootWindow == this)
8459 guiApp.interfaceDriver.OrderRootWindow(this, false);
8466 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8467 order && ((Window)order.data).style.stayOnTop;
8468 order = (order == parent.childrenOrder.first) ? null : order.prev);
8469 last = order ? order.data : null;
8473 for(last = parent.children.last;
8474 last && last.style.stayOnTop;
8478 parent.children.Move(this, last);
8482 style.stayOnTop = false;
8485 get { return style.stayOnTop; }
8490 property_category $"Window Style"
8500 if(menuBar && !value)
8507 if(!menuBar && style.hasMenuBar && value)
8511 this, menu = value, isMenuBar = true,
8512 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8513 inactive = true, nonClient = true
8517 UpdateActiveDocument(null);
8520 get { return menu; }
8523 property FontResource font
8525 property_category $"Appearance"
8527 isset { return setFont ? true : false; }
8532 if(value && !setFont) { stopwatching(parent, font); }
8533 else if(!value && setFont)
8539 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8548 RemoveResource(setFont);
8553 RemoveResource(systemFont);
8560 AddResource(setFont);
8563 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8566 systemFont = guiApp.currentSkin.SystemFont();
8568 usedFont = systemFont;
8569 AddResource(systemFont);
8577 get { return usedFont; }
8580 property SizeAnchor sizeAnchor
8582 property_category $"Layout"
8585 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8586 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8587 sizeAnchor.isClientW != sizeAnchor.isClientH;
8594 normalSizeAnchor = sizeAnchor;
8596 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8598 stateAnchor = normalAnchor;
8599 stateSizeAnchor = normalSizeAnchor;
8601 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8602 Position(x,y, w, h, true, true, true, true, false, true);
8609 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8610 sizeAnchor.isClientW,
8611 sizeAnchor.isClientH
8618 property_category $"Layout"
8621 Anchor thisAnchor = anchor;
8622 SizeAnchor thisSizeAnchor = sizeAnchor;
8623 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8624 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8625 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8626 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8627 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8628 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8634 sizeAnchor.isClientW = false;
8635 sizeAnchor.isClientH = false;
8636 sizeAnchor.size = value;
8638 normalSizeAnchor = sizeAnchor;
8640 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8642 stateAnchor = normalAnchor;
8643 stateSizeAnchor = normalSizeAnchor;
8645 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8646 Position(x, y, w, h, true, true, true, true, false, true);
8647 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8650 get { value = size; }
8653 property Size clientSize
8655 property_category $"Layout"
8658 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8659 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8660 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8665 sizeAnchor.isClientW = true;
8666 sizeAnchor.isClientH = true;
8667 sizeAnchor.size = value;
8669 normalSizeAnchor = sizeAnchor;
8671 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8673 stateAnchor = normalAnchor;
8674 stateSizeAnchor = normalSizeAnchor;
8676 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8677 Position(x,y, w, h, true, true, true, true, false, true);
8680 get { value = clientSize; }
8683 property Size initSize { get { value = sizeAnchor.size; } };
8685 property Anchor anchor
8687 property_category $"Layout"
8688 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8694 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8696 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8697 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8699 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8701 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8702 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8706 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8708 anchor.left.distance = 0;
8709 anchor.horz.type = 0;
8711 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8713 anchor.top.distance = 0;
8714 anchor.vert.type = 0;
8723 normalAnchor = anchor;
8725 // Break the anchors for moveable/resizable windows
8726 /*if(style.fixed ) //&& value.left.type == cascade)
8728 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8730 this.anchor = normalAnchor = Anchor { left = x, top = y };
8731 normalSizeAnchor = SizeAnchor { { w, h } };
8734 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8736 stateAnchor = normalAnchor;
8737 stateSizeAnchor = normalSizeAnchor;
8739 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8740 Position(x, y, w, h, true, true, true, true, false, true);
8749 get { value = this ? anchor : Anchor { }; }
8752 property Point position
8754 property_category $"Layout"
8757 if(value == null) return;
8759 anchor.left = value.x;
8760 anchor.top = value.y;
8761 anchor.right.type = none;
8762 anchor.bottom.type = none;
8767 normalAnchor = anchor;
8769 // Break the anchors for moveable/resizable windows
8773 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8775 normalAnchor.left = x;
8776 normalAnchor.top = y;
8777 normalAnchor.right.type = none;
8778 normalAnchor.bottom.type = none;
8779 normalSizeAnchor.size.width = w;
8780 normalSizeAnchor.size.height = h;
8784 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8786 stateAnchor = normalAnchor;
8787 stateSizeAnchor = normalSizeAnchor;
8789 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8790 Position(x,y, w, h, true, true, true, true, false, true);
8794 get { value = position; }
8797 property bool disabled
8799 property_category $"Behavior"
8802 if(this && disabled != value)
8809 get { return (bool)disabled; }
8812 property bool isEnabled
8817 for(parent = this; parent; parent = parent.parent)
8824 property WindowState state
8826 property_category $"Behavior"
8827 set { SetState(value, false, 0); }
8828 get { return this ? state : 0; }
8831 property bool visible
8833 property_category $"Behavior"
8836 if(this && !value && !style.hidden && parent)
8838 bool wasActiveChild = parent.activeChild == this;
8839 Window client = null;
8841 style.hidden = true;
8842 if(style.isActiveClient)
8844 parent.numPositions--;
8845 if(state == minimized) parent.numIcons--;
8850 OldLink prevOrder = null;
8852 if(rootWindow == this)
8853 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8856 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8859 box.left -= parent.clientStart.x;
8860 box.top -= parent.clientStart.y;
8861 box.right -= parent.clientStart.x;
8862 box.bottom -= parent.clientStart.y;
8866 if(_isModal && master && master.modalSlave == this)
8867 master.modalSlave = null;
8871 OldLink tmpPrev = order.prev;
8872 client = tmpPrev ? tmpPrev.data : null;
8873 if(client && !client.style.hidden && !client.destroyed && client.created)
8874 prevOrder = tmpPrev;
8877 client = tmpPrev ? tmpPrev.data : null;
8878 if(client == this) { client = null; break; }
8879 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8881 tmpPrev = client.order.prev;
8886 prevOrder = tmpPrev;
8891 // If this window can be an active client, make sure the next window we activate can also be one
8892 if(!style.nonClient && style.isActiveClient)
8894 tmpPrev = prevOrder;
8897 client = tmpPrev ? tmpPrev.data : null;
8898 if(client == this) { client = null; break; }
8899 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8901 tmpPrev = client.order.prev;
8906 prevOrder = tmpPrev;
8910 if(client && client.style.hidden) client = null;
8914 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8916 if(order && prevOrder && prevOrder.data != this)
8917 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8919 ActivateEx(false, false, false, true, null, null);
8921 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8922 if(parent.activeClient == this)
8924 parent.activeClient = null;
8925 parent.UpdateActiveDocument(null);
8928 else if(parent.activeClient == this)
8930 parent.activeClient = client;
8931 parent.UpdateActiveDocument(this);
8934 // *** Not doing this anymore ***
8937 parent.childrenCycle.Delete(cycle);
8939 parent.childrenOrder.Delete(order);
8944 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8949 else if(this && value && style.hidden)
8951 style.hidden = false;
8954 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8955 if(rootWindow == this)
8956 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8958 if(_isModal && master)
8959 master.modalSlave = this;
8961 if(style.isActiveClient)
8963 positionID = parent.GetPositionID(this);
8964 parent.numPositions++;
8965 if(state == minimized) parent.numIcons++;
8968 // *** NOT DOING THIS ANYMORE ***
8970 if(!(style.inactive))
8972 if(!(style.noCycle))
8974 cycle = parent.childrenCycle.AddAfter(
8975 (parent.activeChild && parent.activeChild.cycle) ?
8976 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8979 order = parent.childrenOrder.AddAfter(
8980 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8987 if(true || !parent.activeChild)
8988 ActivateEx(true, false, true, true, null, null);
8990 if(creationActivation == activate)
8991 ActivateEx(true, false, true, true, null, null);
8992 else if(creationActivation == flash && !object)
8995 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8999 ConsequentialMouseMove(false);
9005 style.hidden = !value;
9008 get { return (style.hidden || !setVisible) ? false : true; }
9011 property bool isDocument
9013 property_category $"Document"
9014 set { style.isDocument = value; }
9015 get { return style.isDocument; }
9018 property bool mergeMenus
9020 property_category $"Window Style"
9021 set { mergeMenus = value; }
9022 get { return (bool)mergeMenus; }
9025 property bool hasHorzScroll
9027 property_category $"Window Style"
9032 if(!style.hasHorzScroll && created)
9034 CreateSystemChildren();
9035 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9038 else if(style.hasHorzScroll)
9042 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9044 style.hasHorzScroll = value;
9047 get { return style.hasHorzScroll; }
9050 property bool hasVertScroll
9052 property_category $"Window Style"
9057 if(!style.hasVertScroll && created)
9059 style.hasVertScroll = true;
9060 CreateSystemChildren();
9061 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9064 else if(style.hasVertScroll)
9068 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9070 style.hasVertScroll = value;
9072 get { return style.hasVertScroll; }
9075 property bool dontHideScroll
9077 property_category $"Behavior"
9080 scrollFlags.dontHide = value;
9083 //UpdateScrollBars(true, true);
9084 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9088 // UpdateScrollBars(true, true);
9089 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9092 get { return scrollFlags.dontHide; }
9095 property bool dontScrollVert
9097 property_category $"Behavior"
9098 set { style.dontScrollVert = value; }
9099 get { return style.dontScrollVert; }
9101 property bool dontScrollHorz
9103 property_category $"Behavior"
9104 set { style.dontScrollHorz = value; }
9105 get { return style.dontScrollHorz; }
9108 property bool snapVertScroll
9110 property_category $"Behavior"
9113 scrollFlags.snapY = value;
9114 if(sbv) sbv.snap = value;
9116 get { return scrollFlags.snapY; }
9118 property bool snapHorzScroll
9120 property_category $"Behavior"
9123 scrollFlags.snapX = value;
9124 if(sbh) sbh.snap = value;
9126 get { return scrollFlags.snapX; }
9129 property Point scroll
9131 property_category $"Behavior"
9132 set { SetScrollPosition(value.x, value.y); }
9133 get { value = scroll; }
9136 property bool modifyVirtualArea
9138 property_category $"Behavior"
9139 set { modifyVirtArea = value; }
9140 get { return (bool)modifyVirtArea; }
9143 property bool dontAutoScrollArea
9145 property_category $"Behavior"
9146 // Activating a child control out of view will automatically scroll to make it in view
9147 set { noAutoScrollArea = value; }
9148 get { return (bool)noAutoScrollArea; }
9151 property char * fileName
9153 property_category $"Document"
9156 if(menu && ((!fileName && value) || (fileName && !value)))
9158 MenuItem item = menu.FindItem(MenuFileSave, 0);
9159 if(item) item.disabled = !modifiedDocument && value;
9164 if(value && value[0])
9165 fileName = CopyString(value);
9167 if(parent && this == parent.activeClient)
9168 parent.UpdateActiveDocument(null);
9172 // if(style.isDocument)
9174 fileMonitor.fileName = value;
9176 get { return fileName; }
9181 property_category $"Data"
9186 property bool modifiedDocument
9188 property_category $"Document"
9191 if(style.isDocument || fileName)
9195 MenuItem item = menu.FindItem(MenuFileSave, 0);
9196 if(item) item.disabled = !value && fileName;
9200 if(modifiedDocument != value)
9202 modifiedDocument = value;
9203 if(style.isDocument || fileName)
9207 get { return (bool)modifiedDocument; }
9210 property bool showInTaskBar
9212 property_category $"Window Style"
9213 set { style.showInTaskBar = value; }
9214 get { return (style.showInTaskBar; }
9216 property FileDialog saveDialog { set { saveDialog = value; } };
9217 property bool isActiveClient
9219 property_category $"Behavior"
9220 set { style.isActiveClient = value; }
9221 get { return style.isActiveClient; }
9224 property Cursor cursor
9226 property_category $"Appearance"
9230 SelectMouseCursor();
9232 get { return cursor; }
9235 //#if !defined(ECERE_VANILLA)
9236 property char * name
9238 property_category $"Design"
9241 return (this && object) ? object.name : null;
9246 activeDesigner.RenameObject(object, value);
9250 property char * displayDriver
9252 property_category $"Behavior"
9255 dispDriver = GetDisplayDriver(value);
9256 //DisplayModeChanged();
9260 return dispDriver ? dispDriver.name : null;
9264 // RUNTIME PROPERTIES
9265 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9266 property Size scrollArea
9268 property_category $"Behavior"
9272 SetScrollArea(value.w, value.h, false);
9274 SetScrollArea(0,0, true);
9276 get { value = scrollArea; }
9279 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9284 property_category $"Layout"
9285 set { if(this) is3D = value; }
9286 get { return (bool)is3D; }
9289 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9291 // Will be merged with font later
9292 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9293 property Point clientStart { get { value = clientStart; } };
9294 property Point absPosition { get { value = absPosition; } };
9295 property Anchor normalAnchor { get {value = normalAnchor; } };
9296 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9297 property bool active { get { return (bool)active; } };
9298 property bool created { get { return (bool)created; } };
9299 property bool destroyed { get { return (bool)destroyed; } };
9300 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9301 property Window firstChild { get { return children.first; } };
9302 property Window lastChild { get { return children.last; } };
9303 property Window activeClient { get { return activeClient; } };
9304 property Window activeChild { get { return activeChild; } };
9305 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9306 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9307 property ScrollBar horzScroll { get { return sbh; } };
9308 property ScrollBar vertScroll { get { return sbv; } };
9309 property StatusBar statusBar { get { return statusBar; } };
9310 property Window rootWindow { get { return rootWindow; } };
9311 property bool closing { get { return (bool)closing; } set { closing = value; } };
9312 property int documentID { get { return documentID; } };
9313 property Window previous { get { return prev; } }
9314 property Window next { get { return next; } }
9315 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9316 property PopupMenu menuBar { get { return menuBar; } }
9317 property ScrollBar sbv { get { return sbv; } }
9318 property ScrollBar sbh { get { return sbh; } }
9319 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9320 property void * systemHandle { get { return windowHandle; } }
9321 property Button minimizeButton { get { return sysButtons[0]; } };
9322 property Button maximizeButton { get { return sysButtons[1]; } };
9323 property Button closeButton { get { return sysButtons[2]; } };
9324 property BitmapResource icon
9326 get { return icon; }
9330 if(icon) incref icon;
9332 guiApp.interfaceDriver.SetIcon(this, value);
9335 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9336 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9337 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9338 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9339 property bool nativeDecorations
9341 get { return (bool)nativeDecorations; }
9342 set { nativeDecorations = value; }
9343 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9346 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9347 bool result = false;
9348 if(nativeDecorations)
9350 if(rootWindow == this)
9354 if(formDesigner && activeDesigner)
9356 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9357 Window form = cd ? cd.form : null;
9358 if(form && parent == form.parent)
9363 return result != style.fixed;
9367 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9369 property char * text
9371 property_category $"Deprecated"
9373 set { property::caption = value; }
9374 get { return property::caption; }
9380 WindowBits style; // Window Style
9381 char * caption; // Name / Caption
9382 Window parent; // Parent window
9383 OldList children; // List of children in Z order
9384 Window activeChild; // Child window having focus
9385 Window activeClient;
9386 Window previousActive; // Child active prior to activating the default child
9387 Window master; // Window owning and receiving notifications concerning this window
9388 OldList slaves; // List of windows belonging to this window
9389 Display display; // Display this window is drawn into
9391 Point position; // Position in parent window client area
9392 Point absPosition; // Absolute position
9393 Point clientStart; // Client area position from (0,0) in this window
9395 Size clientSize; // Client area size
9396 Size scrollArea; // Virtual Scroll area size
9397 Size reqScrollArea; // Requested virtual area size
9398 Point scroll; // Virtual area scrolling position
9399 ScrollBar sbh, sbv; // Scrollbar window handles
9400 Cursor cursor; // Mouse cursor used for this window
9403 StatusBar statusBar;
9404 Button sysButtons[3];
9406 Box clientArea; // Client Area box clipped to parent
9408 HotKeySlot hotKey; // HotKey for this window
9412 ScrollFlags scrollFlags;// Window Scrollbar Flags
9413 int64 id; // Control ID
9415 ColorAlpha background; // Background color used to draw the window area
9417 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9418 OldList childrenCycle; // Cycling order
9419 OldLink cycle; // Element of parent's cycling order
9420 OldList childrenOrder; // Circular Z-Order
9421 OldLink order; // Element of parent's circular Z-Order
9422 Window modalSlave; // Slave window blocking this window's interaction
9424 Window rootWindow; // Topmost system managed window
9425 void * windowHandle; // System window handle
9427 DialogResult returnCode;// Return code for modal windows
9429 Point sbStep; // Scrollbar line scrolling steps
9432 SizeAnchor stateSizeAnchor;
9434 Anchor normalAnchor;
9435 SizeAnchor normalSizeAnchor;
9437 Size skinMinSize; // Minimal window size based on style
9438 Point scrolledPos; // Scrolled position
9439 Box box; // Window box clipped to parent
9440 Box * against; // What to clip the box to
9442 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9443 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9444 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9445 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9446 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9447 Point scrolledArea; // Distance to scroll area by
9448 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9450 OldList hotKeys; // List of the hotkeys of all children
9451 Window defaultControl; // Default child control
9455 ColorAlpha * palette; // Color palette used for this window
9457 int caretSize; // Size of caret, non zero if a caret is present
9458 Point caretPos; // Caret position
9460 void * systemParent; // Parent System Window for embedded windows
9467 WindowState lastState;
9469 FileMonitor fileMonitor
9471 this, FileChange { modified = true };
9473 bool OnFileNotify(FileChange action, char * param)
9476 fileMonitor.StopMonitoring();
9477 if(OnFileModified(action, param))
9478 fileMonitor.StartMonitoring();
9483 FontResource setFont, systemFont;
9484 FontResource usedFont;
9485 FontResource captionFont;
9487 FileDialog saveDialog;
9489 SizeAnchor sizeAnchor;
9491 // FormDesigner data
9494 Extent * tempExtents; //[4];
9495 BitmapResource icon;
9497 CreationActivationOption creationActivation;
9500 bool active:1; // true if window and ancestors are active
9501 bool acquiredInput:1; // true if the window is processing state based input
9502 bool modifiedDocument:1;
9503 bool disabled:1; // true if window cannot interact
9504 bool isForegroundWindow:1;// true while a root window is being activated
9505 bool visible:1; // Visibility flag
9506 bool destroyed:1; // true if window is being destroyed
9507 bool anchored:1; // true if this window is repositioned when the parent resizes
9508 bool dirty:1; // Flag set to true if any descendant must be redrawn
9514 bool modifyVirtArea:1;
9515 bool noAutoScrollArea:1;
9518 bool setVisible:1; // FOR FORM DESIGNER
9524 bool useSharedMemory:1;
9527 bool nativeDecorations:1;
9528 bool manageDisplay:1;
9529 bool formDesigner:1; // True if we this is running in the form editor
9532 // Checks used internally for them not to take effect in FormDesigner
9533 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9534 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9536 WindowController controller;
9537 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9540 public class CommonControl : Window
9542 // creationActivation = doNothing;
9545 public property String toolTip
9547 property_category $"Appearance"
9550 if(created) CommonControl::OnDestroy();
9552 toolTip = value ? ToolTip { tip = value; } : null;
9554 if(created) CommonControl::OnCreate();
9556 get { return toolTip ? toolTip.tip : null; }
9562 // (Very) Ugly work around for the fact that the parent watcher
9563 // won't fire when it's already been disconnected...
9564 eInstance_FireSelfWatchers(toolTip,
9565 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9571 toolTip.parent = this;
9580 public class Percentage : float
9582 char * OnGetString(char * string, float * fieldData, bool * needClass)
9586 sprintf(string, "%.2f", this);
9587 c = strlen(string)-1;
9590 if(string[c] != '0')
9591 last = Max(last, c);
9592 if(string[c] == '.')
9605 public void ApplySkin(Class c, char * name, void ** vTbl)
9607 char className[1024];
9612 subclass(Window) wc = (subclass(Window))c;
9613 subclass(Window) base = (subclass(Window))c.base;
9615 sprintf(className, "%sSkin_%s", name, c.name);
9616 wc.pureVTbl = c._vTbl;
9617 c._vTbl = new void *[c.vTblSize];
9618 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9619 sc = eSystem_FindClass(c.module.application, className);
9623 for(m = 0; m < c.base.vTblSize; m++)
9625 if(c._vTbl[m] == base.pureVTbl[m])
9626 c._vTbl[m] = vTbl[m];
9631 for(m = 0; m < c.vTblSize; m++)
9633 if(sc._vTbl[m] != wc.pureVTbl[m])
9634 c._vTbl[m] = sc._vTbl[m];
9638 for(d = c.derivatives.first; d; d = d.next)
9640 ApplySkin(d.data, name, c._vTbl);
9644 public void UnapplySkin(Class c)
9646 char className[1024];
9648 subclass(Window) wc = (subclass(Window))c;
9649 subclass(Window) base = (subclass(Window))c.base;
9652 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9655 c._vTbl = wc.pureVTbl;
9659 for(d = c.derivatives.first; d; d = d.next)
9661 UnapplySkin(d.data);
9665 void CheckFontIntegrity(Window window)
9670 if(window.usedFont && window.usedFont.font == 0xecececec)
9672 FontResource uf = window.usedFont;
9673 char * className = window._class.name;
9674 char * text = window.text;
9677 for(c = window.firstChild; c; c = c.next)
9678 CheckFontIntegrity(c);
9682 public class ControllableWindow : Window
9684 /*WindowController controller;
9685 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9686 ~ControllableWindow() { delete controller; }*/
9689 class WindowControllerInterface : ControllableWindow
9691 bool OnKeyDown(Key key, unichar ch)
9693 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9695 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9699 bool OnKeyUp(Key key, unichar ch)
9701 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9703 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9707 bool OnKeyHit(Key key, unichar ch)
9709 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9711 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9715 bool OnMouseMove(int x, int y, Modifiers mods)
9717 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9719 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9723 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9725 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9727 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9731 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9733 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9735 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9739 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9741 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9743 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9747 bool OnRightButtonDown(int x, int y, Modifiers mods)
9749 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9751 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9755 bool OnRightButtonUp(int x, int y, Modifiers mods)
9757 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9759 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9763 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9765 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9767 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9771 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9773 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9775 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9779 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9781 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9783 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9787 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9789 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9791 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9795 void OnResize(int width, int height)
9797 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9798 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9801 void OnRedraw(Surface surface)
9803 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9804 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9809 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9811 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9815 bool OnLoadGraphics()
9817 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9819 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9823 void OnUnloadGraphics()
9825 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9826 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9830 public class WindowController<class V>
9833 property Window window
9837 uint size = class(Window).vTblSize;
9840 windowVTbl = new void *[size];
9841 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9842 if(value._vTbl == value._class._vTbl)
9844 value._vTbl = new void *[value._class.vTblSize];
9845 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9849 for(c = 0; c < size; c++)
9851 void * function = class(WindowControllerInterface)._vTbl[c];
9852 if(function != DefaultFunction)
9853 value._vTbl[c] = function;
9855 value._vTbl[c] = windowVTbl[c];
9860 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9863 get { return window; }
9865 property V controlled
9867 set { controlled = value; }
9868 get { return controlled; }
9870 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9871 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9872 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9873 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9874 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9875 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9876 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9877 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9878 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9879 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9880 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9881 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9882 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9883 virtual void V::OnResize(WindowController controller, int width, int height);
9884 virtual void V::OnRedraw(WindowController controller, Surface surface);
9885 virtual bool V::OnCreate(WindowController controller);
9886 virtual bool V::OnLoadGraphics(WindowController controller);
9887 virtual void V::OnUnloadGraphics(WindowController controller);
9890 int (** windowVTbl)();