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 result = this;
2201 bool notActiveClient = false;
2202 Window menuBarParent;
2203 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2205 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2206 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2207 notActiveClient = true;
2212 void CreateSystemChildren(void)
2214 Window parent = this;
2215 bool scrollBarChanged = false;
2216 bool hasClose = false, hasMaxMin = false;
2217 Point scroll = this.scroll;
2219 if(state == maximized)
2220 parent = GetParentMenuBar();
2224 if(style.hasClose) hasClose = true;
2225 if(style.hasMaximize || style.hasMinimize)
2232 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2234 sysButtons[2].Destroy(0);
2235 sysButtons[2] = null;
2237 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2239 sysButtons[1].Destroy(0);
2240 sysButtons[1] = null;
2242 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2244 sysButtons[0].Destroy(0);
2245 sysButtons[0] = null;
2248 if(hasClose && parent)
2255 parent, master = this,
2256 inactive = true, nonClient = true, visible = false;
2258 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2264 if(this.parent == guiApp.desktop)
2265 sysButtons[2].hotKey = altF4;
2266 else if(style.isActiveClient)
2267 sysButtons[2].hotKey = ctrlF4;
2268 sysButtons[2].Create();
2271 sysButtons[2].symbol = 'X';
2272 sysButtons[2].disabled = !style.hasClose;
2275 if(hasMaxMin && parent)
2279 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2280 if(state == maximized)
2283 method = RestoreButtonClicked;
2289 method = MaximizeButtonClicked;
2297 parent, master = this,
2298 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2300 sysButtons[1].Create();
2302 sysButtons[1].NotifyClicked = method;
2304 sysButtons[1].symbol = symbol;
2305 sysButtons[1].disabled = !style.hasMaximize;
2308 if(hasMaxMin && parent)
2312 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2313 if (state == minimized)
2316 method = RestoreButtonClicked;
2322 method = MinimizeButtonClicked;
2330 parent, master = this,
2331 hotKey = altM, inactive = true, nonClient = true, visible = false
2333 sysButtons[0].Create();
2335 sysButtons[0].NotifyClicked = method;
2337 sysButtons[0].symbol = symbol;
2338 sysButtons[0].disabled = !style.hasMinimize;
2341 // Create the scrollbars
2342 if(style.hasHorzScroll && !sbh)
2348 direction = horizontal,
2352 snap = scrollFlags.snapX,
2353 NotifyScrolling = ScrollBarNotification
2356 scrollBarChanged = true;
2358 else if(sbh && !style.hasHorzScroll)
2364 if(style.hasVertScroll && !sbv)
2370 direction = vertical,
2374 snap = scrollFlags.snapY,
2375 NotifyScrolling = ScrollBarNotification
2378 scrollBarChanged = true;
2380 else if(sbv && !style.hasVertScroll)
2385 if(scrollBarChanged)
2387 SetScrollLineStep(sbStep.x, sbStep.y);
2388 UpdateScrollBars(true, true);
2392 if(scrollBarChanged)
2394 if(sbh) sbh.thumbPosition = scroll.x;
2395 if(sbv) sbv.thumbPosition = scroll.y;
2399 void UpdateCaption(void)
2401 if(rootWindow == this)
2404 FigureCaption(caption);
2405 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2407 UpdateDecorations();
2410 if(parent.activeClient == this) // Added this last check
2412 if(parent.rootWindow == parent)
2415 parent.FigureCaption(caption);
2416 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2419 parent.UpdateCaption();
2421 parent.UpdateDecorations();
2425 void UpdateActiveDocument(Window previous)
2427 Window activeClient = this.activeClient;
2428 Window activeChild = this.activeChild;
2435 activeClient.CreateSystemChildren();
2437 previous.CreateSystemChildren();
2449 // Build window list
2452 Menu windowMenu = menu.FindMenu("Window");
2457 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2460 Window document = cycle.data;
2461 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2463 char name[2048], caption[2048];
2464 document.FigureCaption(caption);
2465 sprintf(name, "%d %s", id+1, caption);
2466 windowMenu.AddDynamic(MenuItem
2468 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2469 NotifySelect = MenuWindowSelectWindow
2473 if(activeClient.cycle == cycle) break;
2478 if((!previous && activeClient) || !activeClient)
2484 item = menu.FindItem(MenuWindowCloseAll, 0);
2485 if(item) item.disabled = false;
2486 item = menu.FindItem(MenuWindowNext, 0);
2487 if(item) item.disabled = false;
2488 item = menu.FindItem(MenuWindowPrevious, 0);
2489 if(item) item.disabled = false;
2490 item = menu.FindItem(MenuWindowCascade, 0);
2491 if(item) item.disabled = false;
2492 item = menu.FindItem(MenuWindowTileHorz, 0);
2493 if(item) item.disabled = false;
2494 item = menu.FindItem(MenuWindowTileVert, 0);
2495 if(item) item.disabled = false;
2496 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2497 if(item) item.disabled = false;
2498 item = menu.FindItem(MenuWindowWindows, 0);
2499 if(item) item.disabled = false;
2502 item = menu.FindItem(MenuFileClose, 0);
2503 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2504 item = menu.FindItem(MenuFileSaveAll, 0);
2505 if(item) item.disabled = numDocuments < 1;
2507 if(activeClient && activeClient.menu && activeClient.state != minimized)
2511 //activeClient.menu.Clean(activeClient);
2512 menu.Merge(activeClient.menu, true, activeClient);
2516 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2519 menu.Merge(activeChild.menu, true, activeChild);
2522 // This is called again for a child window change, with same active client
2523 OnActivateClient(activeClient, previous);
2524 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2525 parent.UpdateActiveDocument(null);
2528 void _ShowDecorations(Box box, bool post)
2530 if(rootWindow == this && nativeDecorations) return;
2531 if(visible && this != guiApp.desktop)
2533 Surface surface = RedrawFull(box);
2537 FigureCaption(caption);
2540 ShowDecorations(captionFont.font,
2543 active, //parent.activeClient == this
2544 guiApp.windowMoving == this);
2546 PreShowDecorations(captionFont.font,
2549 active, //parent.activeClient == this
2550 guiApp.windowMoving == this);
2557 void UpdateExtent(Box refresh)
2559 Surface surface = null;
2561 if(!manageDisplay) { OnRedraw(null);return; }
2562 _ShowDecorations(refresh, false);
2564 surface = Redraw(refresh);
2565 // Opaque background: just fill before EW_REDRAW (clear?)
2568 surface.SetBackground(background);
2569 surface.SetForeground(foreground);
2570 surface.DrawingChar(' ');
2571 if(this == rootWindow)
2573 if(style.drawBehind || background.a)
2575 int a = background.a;
2576 // Premultiply alpha for clear color
2577 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2578 surface.Clear(colorBuffer);
2579 surface.SetBackground(background);
2582 else if(background.a)
2586 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2587 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2590 if(display.flags.alpha && background.a < 255 && background)
2592 surface.Area(0,0,clientSize.w, clientSize.h);
2593 /*if(style.clearDepthBuffer)
2594 surface.Clear(depthBuffer);*/
2596 else if(/*style.clearDepthBuffer || */background.a)
2598 int a = background.a;
2599 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2600 // Premultiply alpha for clear color
2601 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2602 surface.Clear(colorBuffer);
2603 surface.SetBackground(background);
2608 surface.TextFont(usedFont.font);
2609 surface.TextOpacity(false);
2613 // Draw the caret ...
2614 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2616 // surface.SetBackground(0xFFFFFF - background.color);
2617 surface.SetBackground(~background.color);
2619 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2620 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2626 void DrawOverChildren(Box refresh)
2628 Surface surface = Redraw(refresh);
2632 surface.DrawingChar(' ');
2633 surface.SetBackground(background);
2634 surface.SetForeground(foreground);
2636 surface.TextFont(usedFont.font);
2637 surface.TextOpacity(false);
2639 OnDrawOverChildren(surface);
2644 _ShowDecorations(refresh, true);
2647 void ComputeClipExtents(void)
2650 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2652 clipExtent.Copy(this.clipExtent);
2654 for(child = children.last; child; child = child.prev)
2656 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2658 bool opaque = child.IsOpaque(); // TODO: acess background directly
2659 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2661 child.clipExtent.Copy(clipExtent);
2662 child.clipExtent.Offset(-dx, -dy);
2663 child.clipExtent.IntersectBox(child.box);
2665 child.ComputeClipExtents();
2667 if(opaque && !child.style.nonClient)
2669 // Adjust the box for the parent:
2670 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2671 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2676 // ??? Only do this for overlapped window or if parent has with clip children flag
2678 // Do this if window has clip children flag on (default false?)
2679 // this.clipExtent = clipExtent;
2681 clipExtent.Free(null);
2684 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2686 bool opaque = IsOpaque();
2688 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2689 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2691 offsetX -= rootWindow.clientStart.x;
2692 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2696 for(child = children.last; child; child = child.prev)
2698 ColorAlpha background = *(ColorAlpha *)&child.background;
2699 bool opaque = child.IsOpaque();
2700 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2704 // Adjust renderArea to the root window level
2705 Extent * renderArea = &rootWindow.tempExtents[1];
2707 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2708 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2710 offsetX -= child.rootWindow.clientStart.x;
2711 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2715 Extent childRenderArea;
2717 if(backBufferUpdate != null)
2719 childRenderArea.Copy(backBufferUpdate);
2720 childRenderArea.Offset(-offsetX, -offsetY);
2723 childRenderArea.Copy(child.dirtyArea);
2725 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2726 renderArea.Copy(dirtyExtent);
2727 renderArea.Offset(-offsetX, -offsetY);
2728 childRenderArea.Union(renderArea);
2731 // Intersect with the clip extent
2732 childRenderArea.Intersection(child.clipExtent);
2735 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2736 renderArea->Offset(offsetX, offsetY);
2737 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2738 // overDirtyExtent.Union(renderArea);
2739 renderArea->Empty();
2740 // childRenderArea.Free();
2742 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2747 for(child = children.last; child; child = child.prev)
2749 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2751 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2756 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2758 bool opaque = IsOpaque();
2759 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2761 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2762 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2764 offsetX -= rootWindow.clientStart.x;
2765 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2769 for(child = children.last; child; child = child.prev)
2771 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2773 ColorAlpha background = *(ColorAlpha *)&child.background;
2774 bool opaque = child.IsOpaque();
2775 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2779 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2780 // Adjust renderArea to the root window level
2782 renderArea.Copy(child.dirtyArea);
2783 renderArea.Offset(offsetX, offsetY);
2784 dirtyExtent.Union(renderArea);
2785 overDirtyExtent.Union(renderArea);
2791 for(child = children.last; child; child = child.prev)
2793 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2795 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2799 if(backBufferUpdate != null)
2801 renderArea.Copy(backBufferUpdate);
2802 renderArea.Offset(-offsetX, -offsetY);
2804 overRenderArea.Copy(backBufferUpdate);
2805 overRenderArea.Offset(-offsetX, -offsetY);
2811 renderArea.Copy(dirtyArea);
2813 overRenderArea.Copy(dirtyArea);
2816 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2817 dirtyExtentWindow->Copy(dirtyExtent);
2818 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2819 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2820 dirtyExtentWindow->Empty();
2822 // Intersect with the clip extent
2823 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2826 if(renderArea.count > 10)
2829 printf("\nToo many extents (%d):\n", renderArea.count);
2831 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2832 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2837 for(c = 0; c<10; c++)
2840 FASTLIST_LOOP(renderArea, extentBox)
2842 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2844 renderArea.Copy(extent);
2846 FASTLIST_LOOP(renderArea, extentBox)
2849 printf("(%d, %d) - (%d, %d)\n",
2850 extentBox.box.left, extentBox.box.top,
2851 extentBox.box.right, extentBox.box.bottom);
2855 printf("\nNow %d\n", renderArea.count);
2861 // WHY WAS THIS COMMENTED ??
2863 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2864 dirtyExtentWindow->Copy(overDirtyExtent);
2865 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2866 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2867 dirtyExtentWindow->Empty();
2869 // Intersect with the clip extent
2870 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2876 if(scrollExtent.count)
2878 // Subtract render extent from scrolling extent
2879 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2881 if(backBufferUpdate == null)
2883 Extent * dirty = &rootWindow.tempExtents[3];
2886 // Intersect scrolling extent with clip extent
2887 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2889 // offset this scroll to be at the root window level
2890 scrollExtent.Offset(offsetX, offsetY);
2891 // Add area that was scrolled to the dirty extents of the back buffer
2892 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2896 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2897 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2898 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2903 scrollExtent.Empty();
2905 // Add the exposed extent to the window render area
2906 dirty->Offset(-offsetX, -offsetY);
2907 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2912 // Subtract the window's box from the transparency forced extent
2913 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2919 renderArea.Copy(this.renderArea);
2920 renderArea.Offset(offsetX, offsetY);
2921 dirtyExtent.Union(renderArea);
2927 Extent renderArea { };
2929 renderArea.Copy(overRenderArea);
2930 renderArea.Offset(offsetX, offsetY);
2931 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2936 if(backBufferUpdate != null)
2938 // Remove render area from dirty area
2939 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2941 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2948 // Remove the window render area from the dirty extents of the back buffer
2949 rootWindow.dirtyBack.Exclusion(renderArea);
2953 void Render(Extent updateExtent)
2957 Window rootWindow = this.rootWindow;
2958 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2959 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2961 offsetX -= rootWindow.clientStart.x;
2962 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2965 if(rootWindow.fullRender)
2974 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2975 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2980 /*if(renderArea.count)
2981 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2984 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2986 Box box = extentBox.box;
2989 /*printf("(%d, %d) - (%d, %d)\n",
2990 extentBox.box.left, extentBox.box.top,
2991 extentBox.box.right, extentBox.box.bottom);*/
2996 box.left += offsetX;
2998 box.right += offsetX;
2999 box.bottom += offsetY;
3001 if(updateExtent != null)
3002 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3006 for(child = children.first; child; child = child.next)
3007 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3008 child.Render(updateExtent);
3010 if(rootWindow.fullRender)
3011 DrawOverChildren(box);
3014 // TO DO: There's an issue about draw over children...
3015 // TO DO: Don't wanna go through this if method isn't used
3016 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3017 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3019 Box box = extentBox.box;
3021 DrawOverChildren(box);
3023 box.left += offsetX;
3025 box.right += offsetX;
3026 box.bottom += offsetY;
3028 if(updateExtent != null)
3029 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3032 for(child = children.first; child; child = child.next)
3033 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3034 child.Render(updateExtent);
3037 overRenderArea.Empty();
3040 public void UpdateDisplay(void)
3042 if(!manageDisplay) { OnRedraw(null);return; }
3043 if(rootWindow && this != rootWindow)
3044 rootWindow.UpdateDisplay();
3047 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3048 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3051 dirtyExtent.Clear();
3054 clipExtent.AddBox(box);
3056 display.StartUpdate();
3058 if(!rootWindow.fullRender)
3060 ComputeClipExtents();
3061 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3062 ComputeRenderArea(dirtyExtent, overExtent, null);
3065 clipExtent.Free(null);
3067 dirtyExtent.Free(null);
3068 overExtent.Free(null);
3070 if(display.flags.flipping)
3073 display.Update(null);
3077 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3078 updateExtent.Clear();
3080 Render(updateExtent);
3082 updateExtent.UnionBox(this.box, tempExtents[0]);
3085 //printf("\n\nUpdate:\n------------------------------------------\n");
3088 //FASTLIST_LOOP(updateExtent, extentBox)
3089 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3092 /*printf("Updating (%d, %d) - (%d, %d)\n",
3093 extentBox.box.left, extentBox.box.top,
3094 extentBox.box.right, extentBox.box.bottom);*/
3097 display.Update(extentBox.box);
3100 updateExtent.Free(null);
3103 display.EndUpdate();
3111 void UpdateBackDisplay(Box box)
3117 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3119 //printf("UpdateBackDisplay going through!\n");
3120 display.StartUpdate();
3124 intersection.Copy(dirtyBack);
3125 intersection.IntersectBox(box);
3127 dirtyExtent.Clear();
3130 clipExtent.AddBox(box);
3132 if(!rootWindow.fullRender)
3134 ComputeClipExtents();
3135 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3138 clipExtent.Free(null);
3140 intersection.Free(null);
3141 dirtyExtent.Free(null);
3142 overExtent.Free(null);
3147 if(display.flags.flipping)
3148 display.Update(null);
3151 rootWindow.display.Update(box);
3154 display.EndUpdate();
3158 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3159 if(dirtyBack.count > MAX_DIRTY_BACK)
3161 BoxItem extentBox, next;
3162 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3163 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3165 next = (BoxItem)extentBox.next;
3166 if(extentBox != first)
3168 if(extentBox.box.left < first.box.left)
3169 first.box.left = extentBox.box.left;
3170 if(extentBox.box.top < first.box.top)
3171 first.box.top = extentBox.box.top;
3172 if(extentBox.box.right > first.box.right)
3173 first.box.right = extentBox.box.right;
3174 if(extentBox.box.bottom > first.box.bottom)
3175 first.box.bottom = extentBox.box.bottom;
3176 dirtyBack.Delete(extentBox);
3185 // --- Window positioning ---
3186 // --- Window identification ---
3188 // Returns window at position "Position"
3189 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3191 Window child, result = null;
3193 box.left += absPosition.x;
3194 box.right += absPosition.x;
3195 box.top += absPosition.y;
3196 box.bottom += absPosition.y;
3198 if(!destroyed && visible && (acceptDisabled || !disabled))
3200 int lx = x - absPosition.x;
3201 int ly = y - absPosition.y;
3202 if(IsInside(lx, ly))
3203 // if(box.IsPointInside(Point{x, y}))
3205 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3206 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3209 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3210 Window ancestor = null;
3212 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3213 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3214 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3216 if(child != statusBar && child.rootWindow == rootWindow)
3218 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3225 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3226 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3228 if(child != statusBar && child.rootWindow == rootWindow)
3230 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3242 Window FindModal(void)
3244 Window modalWindow = this, check;
3245 Window check2 = null;
3246 for(check = this; check.master; check = check.master)
3248 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3250 modalWindow = check.master.modalSlave;
3251 check = modalWindow;
3253 // TESTING THIS FOR DROPBOX...
3254 if(!rootWindow || !rootWindow.style.interim)
3256 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3258 if(check2.modalSlave && check2.modalSlave.created)
3260 modalWindow = check2.modalSlave;
3268 if(modalWindow == this)
3270 for(check = this; check.activeChild; check = check.activeChild)
3272 if(check.modalSlave)
3274 modalWindow = check.modalSlave;
3280 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3281 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3284 void StopMoving(void)
3286 if(this == guiApp.windowMoving)
3288 guiApp.windowMoving = null;
3289 UpdateDecorations();
3290 SetMouseRange(null);
3293 if(rootWindow.active)
3294 guiApp.interfaceDriver.StopMoving(rootWindow);
3297 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3298 guiApp.windowIsResizing = false;
3302 void SelectMouseCursor(void)
3307 Window cursorWindow = null;
3308 bool rx, ry, rex, rey;
3310 guiApp.desktop.GetMousePosition(&x, &y);
3311 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3313 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3314 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3315 else if(mouseWindow)
3317 modalWindow = mouseWindow.FindModal();
3318 x -= mouseWindow.absPosition.x;
3319 y -= mouseWindow.absPosition.y;
3320 if(guiApp.windowIsResizing)
3322 rex = guiApp.resizeEndX;
3323 rey = guiApp.resizeEndY;
3324 rx = guiApp.resizeX;
3325 ry = guiApp.resizeY;
3326 if((rex && rey) || (rx && ry))
3327 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3328 else if((rex && ry) || (rx && rey))
3329 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3330 else if((ry || rey) && (!rx && !rex))
3331 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3332 else if((rx || rex) && (!ry && !rey))
3333 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3335 else if(!modalWindow && !guiApp.windowCaptured &&
3336 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3337 &rx, &ry, &rex, &rey))
3339 if((rex && rey) || (rx && ry))
3340 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3341 else if((rex && ry) || (rx && rey))
3342 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3343 else if((ry || rey) && (!rx && !rex))
3344 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3345 else if((rx || rex) && (!ry && !rey))
3346 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3348 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3350 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3351 cursorWindow = mouseWindow.parent;
3353 cursorWindow = mouseWindow;
3355 else if(!guiApp.interimWindow)
3356 cursorWindow = guiApp.windowCaptured;
3359 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3360 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3362 else if(modalWindow)
3364 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3366 else if(guiApp.interimWindow)
3368 if(guiApp.interimWindow.cursor)
3369 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3371 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3376 // --- State based input ---
3377 bool AcquireInputEx(bool state)
3382 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3383 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3385 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3387 guiApp.acquiredWindow = state ? this : null;
3390 SetMouseRangeToClient();
3391 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3396 SelectMouseCursor();
3398 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3402 // --- Window activation ---
3403 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3406 if(!parent || !parent.style.inactive)
3408 Window parent = this.parent;
3411 if(rootWindow == this)
3412 Log(active ? "active\n" : "inactive\n");
3415 // Testing this here...
3416 if(!parent || parent == guiApp.desktop || parent.active)
3418 this.active = active;
3421 // TESTING THIS HERE
3422 UpdateDecorations();
3423 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3424 result = NotifyActivate(master, this, active, previous);
3427 this.active = !active;
3432 if(!parent || parent == guiApp.desktop || parent.active)
3434 this.active = active;
3436 AcquireInputEx(active);
3441 if(guiApp.caretOwner)
3445 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3446 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3447 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3448 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3450 guiApp.caretOwner.Update(extent);
3453 if(visible || !guiApp.caretOwner)
3454 guiApp.caretOwner = this;
3455 UpdateCaret(false, false);
3461 this.active = false;
3463 AcquireInputEx(active);
3465 if(!active && guiApp.caretOwner == this)
3467 UpdateCaret(false, true);
3468 guiApp.caretOwner = null;
3469 guiApp.interfaceDriver.SetCaret(0,0,0);
3470 guiApp.caretEnabled = false;
3475 if(!active && parent && parent.activeChild && parent.activeChild != this)
3476 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3482 if(!active && menuBar)
3485 menuBar.OnActivate(false, null, &goOn, true);
3486 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3491 Window aChild = activeChild;
3493 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3505 void ConsequentialMouseMove(bool kbMoving)
3509 if(kbMoving || !guiApp.windowMoving)
3513 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3515 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3517 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3518 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3524 bool IsDescendantOf(Window ancestor)
3527 for(window = this; window && window != ancestor; window = window.parent);
3528 return window == ancestor;
3531 bool IsSlaveOf(Window master)
3534 for(window = this; window && window != master; window = window.master);
3535 return window == master;
3538 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3542 if(this && !destroyed /*&& state != Hidden*/)
3544 Window swap = externalSwap;
3552 if(activateParent &&
3553 (parent.activeChild != this ||
3554 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3555 active && _isModal &&
3556 parent != master && master)
3557 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3563 bool real = parent.activeChild != this;
3565 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3566 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3567 !IsDescendantOf(guiApp.interimWindow) &&
3568 !IsSlaveOf(guiApp.interimWindow))
3570 Window interimWindow = guiApp.interimWindow;
3571 while(interimWindow && interimWindow != this)
3573 Window master = interimWindow.master;
3575 guiApp.interimWindow = null;
3576 if(guiApp.caretOwner)
3577 guiApp.caretOwner.UpdateCaret(false, false);
3579 incref interimWindow;
3580 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3585 delete interimWindow;
3586 interimWindow = (master && master.style.interim) ? master : null;
3591 guiApp.interimWindow = this;
3592 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3593 guiApp.caretEnabled = false;*/
3594 UpdateCaret(false, true);
3599 bool acquireInput = false;
3601 parent.activeChild &&
3602 parent.activeChild.state == maximized &&
3603 parent != guiApp.desktop;
3605 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3610 swap = parent.activeChild;
3611 if(swap && swap.destroyed) swap = null;
3612 if(swap && swap != this)
3615 if(!swap.PropagateActive(false, this, &goOn, true))
3616 swap = parent.activeChild;
3627 if(!parent || parent.activeChild != this || style.interim)
3630 result = PropagateActive(true, swap, &goOn, true);
3631 if(!result && !goOn)
3636 acquireInput = true;
3640 if(style.hasMaximize && parent != guiApp.desktop)
3643 SetState(maximized, false, 0);
3644 else if(state != maximized)
3647 for(child = parent.children.first; child; child = child.next)
3649 if(this != child && child.state == maximized)
3650 child.SetState(normal, false, 0);
3657 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3659 Window previous = parent.activeClient;
3660 parent.activeChild = this;
3661 if(!style.nonClient /*&& style.isActiveClient*/)
3665 if(style.isActiveClient)
3666 parent.activeClient = this;
3667 // Moved UpdateActiveDocument inside hidden check
3668 // To prevent activating previous window while creating a new one
3669 // (It was messing up the privateModule in the CodeEditor)
3670 parent.UpdateActiveDocument(previous);
3676 //if(!style.isRemote)
3678 if(rootWindow != this)
3680 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3681 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3683 else if(!guiApp.fullScreenMode)
3685 Window modalRoot = FindModal();
3686 if(!modalRoot) modalRoot = this;
3687 if(!modalRoot.isForegroundWindow)
3689 modalRoot.isForegroundWindow = true;
3690 // To check : Why is parent null?
3691 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3693 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3695 modalRoot.isForegroundWindow = false;
3700 if(result && real && (!style.inactive || moveInactive) && parent)
3702 Window last = parent.children.last;
3704 if(!style.stayOnTop)
3705 for(; last && last.style.stayOnTop; last = last.prev);
3707 parent.children.Move(this, last);
3709 // Definitely don't want that: why not?
3713 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3719 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3726 parent.activeChild = null;
3727 if(!style.nonClient /*&& style.isActiveClient*/)
3729 Window previous = parent.activeClient;
3730 if(style.isActiveClient)
3731 parent.activeClient = null;
3732 parent.UpdateActiveDocument(previous);
3736 if(this == guiApp.interimWindow)
3738 guiApp.interimWindow = null;
3739 if(guiApp.caretOwner)
3740 guiApp.caretOwner.UpdateCaret(false, false);
3742 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3749 if(!active || !swap)
3750 UpdateDecorations();
3752 swap.UpdateDecorations();
3754 if(active && rootWindow != this)
3755 ConsequentialMouseMove(false);
3762 // --- Input Messages ---
3763 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3765 static bool reEntrancy = false;
3766 if(reEntrancy) return;
3770 guiApp.cursorUpdate = true;
3771 if(guiApp.windowScrolling && !consequential)
3773 guiApp.windowScrolling.SetScrollPosition(
3774 (guiApp.windowScrolling.sbh) ?
3775 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3776 (guiApp.windowScrolling.sbv) ?
3777 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3779 if(guiApp.windowMoving)
3781 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3783 Window window = guiApp.windowMoving;
3785 int w = window.size.w;
3786 int h = window.size.h;
3791 rx = mouseX - guiApp.windowMovingStart.x;
3792 ry = mouseY - guiApp.windowMovingStart.y;
3795 window.GetDecorationsSize(&ew, &eh);
3797 if(guiApp.windowIsResizing)
3799 x = window.scrolledPos.x;
3800 y = window.scrolledPos.y;
3804 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3805 rx = guiApp.windowResizingBefore.w - aw;
3806 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3807 w = guiApp.windowResizingBefore.w - rx;
3811 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3812 ry = guiApp.windowResizingBefore.h - ah;
3813 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3814 ry = Max(ry, -guiApp.windowMovingBefore.y);
3815 h = guiApp.windowResizingBefore.h - ry;
3817 if(guiApp.resizeEndX)
3819 w = guiApp.windowResizingBefore.w + rx;
3822 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3830 w = Max(w, window.minSize.w);
3831 h = Max(h, window.minSize.h);
3832 w = Min(w, window.maxSize.w);
3833 h = Min(h, window.maxSize.h);
3835 if(!window.OnResizing(&w, &h))
3837 w = window.clientSize.w;
3838 h = window.clientSize.h;
3841 w = Max(w, window.skinMinSize.w);
3842 h = Max(h, window.skinMinSize.h);
3849 SNAPDOWN(w, textCellW);
3850 SNAPDOWN(h, textCellH);
3855 aw = Max(w,window.skinMinSize.w);
3856 rx = guiApp.windowResizingBefore.w - aw;
3857 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3858 w = guiApp.windowResizingBefore.w - rx;
3862 ah = Max(h,window.skinMinSize.h);
3863 ry = guiApp.windowResizingBefore.h - ah;
3864 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3865 ry = Max(ry, -guiApp.windowMovingBefore.y);
3866 h = guiApp.windowResizingBefore.h - ry;
3871 if(!guiApp.windowIsResizing || guiApp.resizeX)
3872 x = guiApp.windowMovingBefore.x + rx;
3873 if(!guiApp.windowIsResizing || guiApp.resizeY)
3874 y = guiApp.windowMovingBefore.y + ry;
3876 if(!guiApp.windowIsResizing)
3879 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3881 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3882 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3883 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3884 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3888 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3889 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3895 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3897 if(!window.OnMoving(&x, &y, w, h))
3899 x = window.scrolledPos.x;
3900 y = window.scrolledPos.y;
3906 SNAPDOWN(x, textCellW);
3907 SNAPDOWN(y, textCellH);
3910 if(!window.style.nonClient)
3912 if(!window.style.fixed /*|| window.style.isDocument*/)
3914 if(!window.style.dontScrollHorz)
3915 x += window.parent.scroll.x;
3916 if(!window.style.dontScrollVert)
3917 y += window.parent.scroll.y;
3921 // Break the anchors for moveable/resizable windows
3922 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3923 if(window.style.fixed)
3925 if(window.state == normal)
3927 window.normalAnchor = Anchor { left = x, top = y };
3928 window.normalSizeAnchor = SizeAnchor { { w, h } };
3929 window.anchored = false;
3933 window.stateAnchor = Anchor { left = x, top = y };
3934 window.stateSizeAnchor = SizeAnchor { { w, h } };
3936 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3937 // TOCHECK: Investigate why the following only redraws the scrollbars
3938 //window.Position(x, y, w, h, false, true, true, true, false, true);
3940 guiApp.movingLast.x = mouseX;
3941 guiApp.movingLast.y = mouseY;
3947 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3950 bool wasMoving = guiApp.windowMoving ? true : false;
3951 bool wasScrolling = guiApp.windowScrolling ? true : false;
3953 while(result && w != this)
3955 Window msgWindow = GetAtPosition(x,y, false, true, w);
3956 Window trueWindow = GetAtPosition(x,y, false, false, w);
3957 bool windowDragged = false;
3962 window = (w && !w.disabled) ? w : null;
3964 if(trueWindow) incref trueWindow;
3966 if(consequential) mods->isSideEffect = true;
3968 UpdateMouseMove(x, y, consequential);
3970 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3972 if(!guiApp.windowCaptured.isEnabled)
3973 guiApp.windowCaptured.ReleaseCapture();
3975 window = guiApp.windowCaptured;
3978 if(trueWindow && activate &&
3979 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3980 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3981 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3982 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3984 if(mods->alt && !mods->ctrl && !mods->shift)
3986 Window moved = trueWindow;
3987 for(moved = trueWindow; moved; moved = moved.parent)
3988 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3993 windowDragged = true;
3995 // Cancel the ALT menu toggling...
3996 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4001 if(window && activate &&
4002 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4003 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4004 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4005 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4007 Window modalWindow = window.FindModal();
4009 /*if(mods->alt && !mods->shift && !mods->ctrl)
4011 Window moved = window;
4012 for(moved = window; moved; moved = moved.parent)
4013 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4018 windowDragged = true;
4020 // Cancel the ALT menu toggling...
4021 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4027 Window activateWindow = modalWindow ? modalWindow : window;
4028 if(activateWindow && !activateWindow.isRemote)
4030 bool doActivation = true;
4031 //bool needToDoActivation = false;
4032 Window check = activateWindow;
4034 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4036 if(!check.style.inactive)
4038 //needToDoActivation = true;
4040 doActivation = false;
4045 if(!needToDoActivation)
4046 doActivation = false;
4049 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4050 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4052 // Let the OnLeftButtonDown do the activating instead
4053 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4061 incref activateWindow;
4062 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4064 delete activateWindow;
4068 if(activateWindow._refCount == 1)
4070 delete activateWindow;
4074 delete activateWindow;
4075 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4078 mods->isActivate = true;
4082 if(!modalWindow && window && !window.destroyed)
4084 if(!guiApp.windowCaptured || windowDragged)
4086 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4088 bool moving = ((window.state != maximized &&
4089 window.IsMouseMoving(
4090 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4091 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4093 if(!moving && window.IsMouseResizing(
4094 x - window.absPosition.x,
4095 y - window.absPosition.y,
4096 window.size.w, window.size.h,
4097 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4099 guiApp.windowIsResizing = true;
4100 guiApp.windowResizingBefore.w = window.size.w;
4101 guiApp.windowResizingBefore.h = window.size.h;
4103 if(guiApp.windowIsResizing || windowDragged || moving)
4106 guiApp.windowMoving = window;
4107 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4108 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4109 guiApp.windowMovingBefore.x = window.position.x;//s;
4110 guiApp.windowMovingBefore.y = window.position.y;//s;
4111 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4112 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4115 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4117 if(window.style.fixed &&
4119 window.IsMouseMoving(
4120 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4122 window.ShowSysMenu(x, y);
4126 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4128 if(window.sbv || window.sbh)
4131 guiApp.windowScrolling = window;
4132 guiApp.windowScrollingStart.x = x;
4133 guiApp.windowScrollingStart.y = y;
4134 guiApp.windowScrollingBefore.x = window.scroll.x;
4135 guiApp.windowScrollingBefore.y = window.scroll.y;
4138 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4140 if(window.style.hasMaximize &&
4141 window.IsMouseMoving(
4142 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4145 (window.state == maximized) ? normal : maximized, false, *mods);
4153 if(guiApp.windowMoving)
4155 if(guiApp.windowMoving.parent)
4157 if(guiApp.windowMoving.style.nonClient)
4158 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4160 guiApp.windowMoving.parent.SetMouseRangeToClient();
4164 window.UpdateDecorations();
4167 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4169 // Log("\n*** LEFT BUTTON UP ***\n");
4170 if(guiApp.windowMoving)
4171 guiApp.windowMoving.StopMoving();
4173 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4175 if(guiApp.windowScrolling)
4177 Window windowScrolling = guiApp.windowScrolling;
4178 guiApp.windowScrolling = null;
4179 windowScrolling.ReleaseCapture();
4183 if(!result || (window && window.destroyed)) window = null;
4185 if(window && window.FindModal())
4188 if(trueWindow && trueWindow.FindModal())
4196 msgWindow = GetAtPosition(x,y, true, false);
4198 msgWindow.SelectMouseCursor();
4201 if(guiApp.windowCaptured || trueWindow)
4203 Window prevWindow = guiApp.prevWindow;
4204 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4206 guiApp.prevWindow.mouseInside = false;
4207 guiApp.prevWindow = null;
4209 // Eventually fix this not to include captured?
4210 if(!prevWindow.OnMouseLeave(*mods))
4213 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4215 Box box = trueWindow.box;
4216 box.left += trueWindow.absPosition.x;
4217 box.right += trueWindow.absPosition.x;
4218 box.top += trueWindow.absPosition.y;
4219 box.bottom += trueWindow.absPosition.y;
4221 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4223 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4224 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4226 overX = Max(Min(overX, 32767),-32768);
4227 overY = Max(Min(overY, 32767),-32768);
4229 trueWindow.mouseInside = true;
4230 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4234 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4235 guiApp.prevWindow = trueWindow;
4237 guiApp.prevWindow = null;
4239 SelectMouseCursor();
4241 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4243 int clientX = x - (window.absPosition.x + window.clientStart.x);
4244 int clientY = y - (window.absPosition.y + window.clientStart.y);
4246 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4248 clientX = Max(Min(clientX, 32767),-32768);
4249 clientY = Max(Min(clientY, 32767),-32768);
4251 MouseMethod = (void *)window._vTbl[method];
4253 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4256 if(!MouseMethod(window, clientX, clientY, *mods))
4263 if(result && w && w.clickThrough && w.parent)
4268 if(!result || !w || !w.clickThrough)
4275 // --- Mouse cursor management ---
4277 bool KeyMessage(uint method, Key key, unichar character)
4282 if(guiApp.interimWindow)
4283 this = guiApp.interimWindow;
4286 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4290 if(!style.inactive || rootWindow != this)
4292 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4293 Window modalWindow = FindModal();
4294 Window interimMaster = master ? master.rootWindow : null;
4298 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4299 status = OnSysKeyDown(key, character);
4300 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4301 status = OnSysKeyHit(key, character);
4302 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4303 status = OnSysKeyUp(key, character);
4310 // Process Key Message for Internal UI Keyboard actions
4311 if(status && !destroyed && menuBar && state != minimized)
4314 if((SmartKey)key != alt)
4315 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4318 SmartKey sk = (SmartKey) key;
4319 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4321 status = menuBar.KeyMessage(method, key, character);
4326 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4327 menuBar.OnKeyHit(escape, 0);
4329 if(!menuBar.focus && guiApp.caretOwner)
4330 guiApp.caretOwner.UpdateCaret(true, false);
4333 if(!destroyed && status)
4335 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4339 case left: case up: case right: case down:
4340 if(guiApp.windowMoving == this)
4343 int w = guiApp.windowMoving.size.w;
4344 int h = guiApp.windowMoving.size.h;
4345 int x = guiApp.windowMoving.scrolledPos.x;
4346 int y = guiApp.windowMoving.scrolledPos.y;
4350 if(key == down || key == up)
4351 step = Max(step, textCellH);
4353 step = Max(step, textCellW);
4356 if(guiApp.windowIsResizing)
4360 case left: w-=step; break;
4361 case right: w+=step; break;
4362 case up: h-=step; break;
4363 case down: h+=step; break;
4370 case left: x-=step; break;
4371 case right: x+=step; break;
4372 case up: y-=step; break;
4373 case down: y+=step; break;
4377 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4378 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4380 if(!guiApp.windowIsResizing || guiApp.resizeX)
4381 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4383 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4385 if(!guiApp.windowIsResizing || guiApp.resizeY)
4386 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4388 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4390 guiApp.interfaceDriver.SetMousePosition(x, y);
4391 ConsequentialMouseMove(true);
4399 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4401 guiApp.windowMoving.StopMoving();
4402 ConsequentialMouseMove(false);
4410 ShowSysMenu(absPosition.x, absPosition.y);
4418 if(!destroyed && status && state != minimized)
4420 // Process all the way down the children
4421 if(activeChild && !activeChild.disabled)
4423 status = activeChild.KeyMessage(method, key, character);
4425 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4426 key.code != left && key.code != right && key.code != up && key.code != down)
4428 status = activeClient.KeyMessage(method, key, character);
4432 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4434 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4435 // && defaultControl != activeChild)
4437 delete previousActive;
4438 previousActive = activeChild;
4439 if(previousActive) incref previousActive;
4441 ConsequentialMouseMove(false);
4442 if((defaultControl.active ||
4443 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4444 defaultControl.KeyMessage(method, defaultKey, character);
4450 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4452 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4459 ShowSysMenu(absPosition.x, absPosition.y);
4466 if(this != guiApp.desktop)
4468 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4470 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4472 MenuMoveOrSize(key.shift, true);
4476 else if(guiApp.windowMoving)
4478 guiApp.windowMoving.StopMoving();
4479 ConsequentialMouseMove(false);
4487 if(!destroyed && status && state != minimized)
4489 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4493 case tab: case shiftTab:
4495 Window cycleParent = this;
4496 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4497 cycleParent = master.parent;
4499 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4501 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4503 Window child = cycleParent.activeChild;
4505 // Scroll the window to include the active control
4507 if(cycleParent.sbh && !child.style.dontScrollHorz)
4509 if(child.scrolledPos.x < 0)
4510 cycleParent.sbh.Action(Position,
4511 cycleParent.scroll.x + child.scrolledPos.x, 0);
4512 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4513 cycleParent.sbh.Action(Position,
4514 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4516 if(cycleParent.sbv && !child.style.dontScrollVert)
4518 if(child.scrolledPos.y < 0)
4519 cycleParent.sbv.Action(Position,
4520 cycleParent.scroll.y + child.scrolledPos.y, 0);
4521 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4522 cycleParent.sbv.Action(Position,
4523 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4526 cycleParent.ConsequentialMouseMove(false);
4532 case f6: case shiftF6:
4533 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4535 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4536 if(parent == guiApp.desktop)
4537 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4547 if(CycleChildren(key.shift, true, false, true))
4555 // mIRC Style Window Shortcuts
4556 case alt1: case alt2: case alt3: case alt4: case alt5:
4557 case alt6: case alt7: case alt8: case alt9: case alt0:
4562 for(document = children.first; document; document = document.next)
4564 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4566 if(document == activeChild)
4568 if(document.state == minimized)
4569 document.SetState(normal, false, key);
4572 document.SetState(minimized, false, key);
4573 CycleChildren(false, true, false);
4578 if(activeChild.state == maximized && document.style.hasMaximize)
4579 document.SetState(maximized, false, key);
4580 else if(document.state == minimized)
4581 document.SetState(normal, false, key);
4582 document.Activate();
4597 if(!destroyed && status)
4599 if(state == minimized)
4604 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4606 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4608 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4609 previousActive.ActivateEx(true, false, false, true, null, null);
4610 delete previousActive;
4616 if(!destroyed && status)
4618 status = ProcessHotKeys(method, key, character);
4620 if(!destroyed && status && !modalWindow && state != minimized)
4623 status = KeyMethod(this, key, character);
4624 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4625 status = OnKeyHit(key, character);
4626 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4628 bool result = false;
4631 case ctrlUp: case ctrlDown:
4632 if(sbv && !guiApp.windowScrolling)
4633 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4635 case wheelUp: case wheelDown:
4636 if(sbv && !guiApp.windowScrolling)
4638 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4639 // Do we want to do a consequential move regardless of result in this case?
4640 ConsequentialMouseMove(false);
4643 case ctrlPageUp: case ctrlPageDown:
4644 if(sbh && !guiApp.windowScrolling)
4645 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4650 ConsequentialMouseMove(false);
4655 if(status && !destroyed && menuBar && state != minimized)
4656 status = menuBar.KeyMessage(method, key, character);
4658 if(style.interim && /*destroyed && */status && interimMaster)
4660 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4661 status = interimMaster.KeyMessage(method, key, character);
4668 bool ProcessHotKeys(uint method, Key key, unichar character)
4673 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4674 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4675 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4677 Window hotKeyWindow = hotKey.window;
4678 Window parent = hotKeyWindow.parent;
4679 Window prevActiveWindow = activeChild;
4680 // For when sys buttons are placed inside the menu bar
4681 if(parent && parent._class == class(PopupMenu))
4682 parent = parent.parent;
4684 // 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
4685 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4688 if(prevActiveWindow) incref prevActiveWindow;
4689 incref hotKeyWindow;
4690 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4691 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4694 delete hotKeyWindow;
4695 delete prevActiveWindow;
4699 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4700 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4701 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4703 // ********* WORKING ON THIS ***********
4704 if(prevActiveWindow && !guiApp.interimWindow)
4705 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4708 else if(hotKeyWindow.style.inactive)
4709 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4711 delete prevActiveWindow;
4712 delete hotKeyWindow;
4713 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4714 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4718 if(status && tabCycle)
4721 for(child = children.first; child; child = child.next)
4723 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4734 // --- Windows and graphics initialization / termination ---
4735 bool SetupRoot(void)
4739 // Setup relationship with outside world (bb root || !bb)
4740 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4741 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4745 tempExtents = new0 Extent[4];
4750 /*if(guiApp.fullScreenMode)
4751 rootWindow = guiApp.desktop;
4753 //rootWindow = parent.created ? parent.rootWindow : null;
4754 rootWindow = parent.rootWindow;
4757 against = &parent.box;
4759 against = &parent.clientArea;
4762 for(child = children.first; child; child = child.next)
4765 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4768 bool Setup(bool positionChildren)
4770 bool result = false;
4773 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4775 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4776 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4778 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4780 // This was here, is it really needed?
4781 //guiApp.interfaceDriver.ActivateRootWindow(this);
4785 displaySystem = DisplaySystem {};
4786 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4788 delete displaySystem;
4793 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4794 if(display.Create(displaySystem, windowHandle))
4801 // Sometimes icon does not show up on Windows XP if we set here...
4802 // guiApp.interfaceDriver.SetIcon(this, icon);
4804 else if(this != guiApp.desktop)
4806 display = rootWindow ? rootWindow.display : null;
4812 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4813 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4815 for(child = children.first; child; child = child.next)
4817 if(child.created && !child.Setup(false))
4823 bool SetupDisplay(void)
4825 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4826 if(is3D) return Window3D_SetupDisplay(this); else
4833 class_data void ** pureVTbl;
4835 bool LoadGraphics(bool creation, bool resetAnchors)
4837 bool result = false;
4838 bool success = false;
4840 WindowState stateBackup = state;
4842 if(((subclass(Window))_class).pureVTbl)
4844 if(_vTbl == _class._vTbl)
4846 _vTbl = ((subclass(Window))_class).pureVTbl;
4851 for(m = 0; m < _class.vTblSize; m++)
4853 if(_vTbl[m] == _class._vTbl[m])
4854 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4858 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4860 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4862 _vTbl = _class._vTbl;
4867 for(m = 0; m < _class.vTblSize; m++)
4869 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4870 _vTbl[m] = _class._vTbl[m];
4875 if(guiApp.fullScreenMode || this != guiApp.desktop)
4877 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4883 display.Lock(false);
4884 if(rootWindow == this)
4886 // Set Color Palette
4887 display.SetPalette(palette, true);
4891 if(guiApp.fullScreenMode && this == guiApp.desktop)
4896 for(c=0; c<SystemCursor::enumSize; c++)
4897 if(!guiApp.systemCursors[c].bitmap)
4899 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4900 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4901 if(guiApp.systemCursors[c].bitmapName)
4903 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4904 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4905 if(guiApp.systemCursors[c].bitmap)
4906 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4911 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4913 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4914 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4916 cursor.bitmap.paletteShades = cursor.paletteShades;
4920 guiApp.cursorUpdate = true;
4923 ConsequentialMouseMove(false);
4929 // Load Window Graphic Resources
4932 if(usedFont == setFont || usedFont == window.systemFont)
4933 RemoveResource(usedFont);
4936 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4939 RemoveResource(systemFont);
4942 RemoveResource(captionFont);
4944 for(ptr = resources.first; ptr; ptr = ptr.next)
4946 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4949 AddResource(setFont);
4951 AddResource(systemFont);
4953 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4960 //if(master && master.font)
4961 if(parent && parent.font)
4965 faceName = parent.font.faceName,
4966 size = parent.font.size,
4967 bold = parent.font.bold,
4968 italic = parent.font.italic,
4969 underline = parent.font.underline
4971 //font = parent.font;
4972 watch(parent) { font { } };
4975 font = guiApp.currentSkin.SystemFont();
4982 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4983 AddResource(captionFont);
4985 if(OnLoadGraphics())
4991 //SetScrollLineStep(sbStep.x, sbStep.y);
4993 if(this != guiApp.desktop)
4997 normalAnchor = anchor;
4998 normalSizeAnchor = sizeAnchor;
5001 // Break the anchors for moveable/resizable windows
5003 if(style.fixed && style.isDocument)
5005 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5017 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5018 stateSizeAnchor = SizeAnchor {};
5023 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5028 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5029 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5032 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5036 stateAnchor = normalAnchor;
5037 stateSizeAnchor = normalSizeAnchor;
5040 position = Point { };
5041 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5052 if(Position(x, y, w, h, true, false, true, true, true, true))
5054 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5057 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5074 success = result = true;
5077 if(!creation && result)
5079 // Load menu bar first because sys buttons are on it...
5082 if(!menuBar.LoadGraphics(false, resetAnchors))
5088 for(child = children.first; child; child = child.next)
5090 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5097 CreateSystemChildren();
5101 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5104 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5109 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5110 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5113 // Do this here to avoid problems on Windows
5114 if(stateBackup == maximized)
5115 property::state = maximized;
5119 void UnloadGraphics(bool destroyWindows)
5123 // Free children's graphics
5124 for(child = children.first; child; child = child.next)
5125 child.UnloadGraphics(destroyWindows);
5128 display.Lock(false);
5131 if(guiApp.fullScreenMode && this == guiApp.desktop)
5136 for(c=0; c<SystemCursor::enumSize; c++)
5137 if(guiApp.systemCursors[c].bitmap)
5138 delete guiApp.systemCursors[c].bitmap;
5140 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5141 delete cursor.bitmap;
5143 guiApp.cursorBackground.Free();
5146 if(display && display.displaySystem)
5150 for(ptr = resources.first; ptr; ptr = ptr.next)
5154 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5159 // Free window graphics
5162 // Free skin graphics
5163 if(rootWindow == this)
5165 DisplaySystem displaySystem = display.displaySystem;
5168 display.driverData = null;
5169 display.displaySystem = null;
5173 if(displaySystem && !displaySystem.numDisplays && !is3D)
5174 delete displaySystem;
5183 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5184 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5186 if(this == guiApp.desktop || parent == guiApp.desktop)
5188 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5189 guiApp.interfaceDriver.DestroyRootWindow(this);
5193 // --- Window Hiding ---
5195 void SetVisibility(bool state)
5197 bool visible = (style.hidden || !created) ? false : state;
5198 if(visible != this.visible)
5202 this.visible = visible;
5203 for(child = children.first; child; child = child.next)
5204 child.SetVisibility(visible);
5206 ConsequentialMouseMove(false);
5207 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5211 // --- Windows and graphics initialization / termination ---
5213 bool DisplayModeChanged(void)
5215 bool result = false;
5216 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5218 guiApp.modeSwitching = true;
5219 UnloadGraphics(false);
5221 if(LoadGraphics(false, false))
5223 guiApp.modeSwitching = false;
5228 // --- Window updates system ---
5230 void UpdateDirty(Box updateBox)
5232 if(!manageDisplay) { OnRedraw(null);return; }
5235 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5238 if(display.flags.flipping)
5241 rootWindow.UpdateDisplay();
5244 UpdateBackDisplay(updateBox);
5246 if(guiApp.fullScreenMode)
5248 guiApp.cursorUpdate = true;
5249 guiApp.PreserveAndDrawCursor();
5251 if(guiApp.fullScreenMode)
5252 guiApp.RestoreCursorBackground();
5258 // This function is strictly called as a result of system window activation
5259 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5262 Window interimMaster = null;
5263 Window interimWindow = guiApp.interimWindow;
5264 if(interimWindow && interimWindow.master)
5265 interimMaster = interimWindow.master.rootWindow;
5267 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5268 // SetState(normal, false, 0);
5269 SetState(lastState, false, 0);
5271 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5275 /* WTH is this doing here?
5276 while(swap && swap.activeChild)
5278 swap = swap.activeChild;
5281 // TESTING THIS BEFORE...
5282 if(interimWindow && this == interimMaster)
5286 // Window interimSwap = this;
5287 Window menuBar = this.menuBar;
5288 if(menuBar && interimWindow.master == menuBar)
5291 while(interimSwap && interimSwap.activeChild)
5292 interimSwap = interimSwap.activeChild;
5294 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5295 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5297 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5298 //result = ActivateEx(true, true, false, activateRoot, window, null);
5303 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5304 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5306 if(interimWindow == this && interimMaster && !active)
5308 while(interimMaster && interimMaster.interim && interimMaster.master)
5310 // printf("Going up one master %s\n", interimMaster._class.name);
5311 interimMaster = interimMaster.master.rootWindow;
5313 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5314 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5320 bool DestroyEx(int64 returnCode)
5323 Timer timer, nextTimer;
5325 OldLink prevOrder = null;
5326 Window client = null;
5328 if(parent) stopwatching(parent, font);
5330 // if(window.modalSlave) return false;
5331 if(destroyed || !created)
5338 OldLink slave = master.slaves.FindLink(this);
5339 master.slaves.Delete(slave);
5342 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5348 this.returnCode = (DialogResult)returnCode;
5350 AcquireInput(false);
5355 master.hotKeys.Delete(hotKey);
5359 if(guiApp.prevWindow == this)
5361 guiApp.prevWindow = null;
5364 if(guiApp.caretOwner == this)
5366 guiApp.interfaceDriver.SetCaret(0,0,0);
5367 UpdateCaret(false, true);
5368 guiApp.caretEnabled = false;
5373 parent.childrenCycle.Remove(cycle);
5377 OldLink tmpPrev = order.prev;
5378 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5379 prevOrder = tmpPrev;
5382 client = tmpPrev ? tmpPrev.data : null;
5383 if(client == this) { client = null; break; }
5384 if(client && (client.style.hidden || client.destroyed || !client.created))
5385 tmpPrev = client.order.prev;
5389 prevOrder = tmpPrev;
5394 // If this window can be an active client, make sure the next window we activate can also be one
5395 if(!style.nonClient && style.isActiveClient)
5397 tmpPrev = prevOrder;
5400 client = tmpPrev ? tmpPrev.data : null;
5401 if(client == this) { client = null; break; }
5402 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5403 tmpPrev = client.order.prev;
5407 prevOrder = tmpPrev;
5411 if(client && client.style.hidden) client = null;
5413 // parent.childrenOrder.Remove(order);
5416 if(parent && style.isActiveClient && visible)
5418 if(state == minimized) parent.numIcons--;
5419 parent.numPositions--;
5422 // TESTING THIS HERE!
5426 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5427 // to create a window inside a rootwindow that's being destroyed)
5428 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5430 if(master && !master.destroyed /*&&
5431 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5433 if(master.defaultControl == this)
5434 master.defaultControl = null;
5437 parent.OnChildAddedOrRemoved(this, true);
5438 if(parent && !parent.destroyed /*&&
5439 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5441 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5443 if(order && prevOrder && prevOrder.data != this && active)
5445 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5447 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5448 if(parent.activeClient == this)
5450 parent.activeClient = null;
5451 parent.UpdateActiveDocument(null);
5456 if(guiApp.interimWindow == this)
5459 PropagateActive(false, null, &goOn, true);
5463 //if(window.parent.activeChild == window)
5464 parent.activeChild = null;
5465 if(!style.nonClient /*&& style.isActiveClient*/)
5467 Window previous = parent.activeClient;
5468 if(style.isActiveClient)
5469 parent.activeClient = null;
5470 parent.UpdateActiveDocument(previous);
5475 else if(parent.activeClient == this)
5477 parent.activeClient = client;
5478 parent.UpdateActiveDocument(this);
5482 if(guiApp.interimWindow == this)
5484 guiApp.interimWindow = null;
5485 if(guiApp.caretOwner)
5487 Window desktop = guiApp.desktop;
5488 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5489 guiApp.caretOwner.UpdateCaret(false, false);
5494 if(_isModal && master && master.modalSlave == this)
5495 master.modalSlave = null;
5499 if(!guiApp.caretOwner && parent.caretSize)
5501 guiApp.caretOwner = parent;
5502 parent.UpdateCaret(false, false);
5503 parent.Update(null);
5506 // Why was this commented out?
5507 GetRidOfVirtualArea();
5513 dirtyArea.Free(null);
5514 dirtyBack.Free(null);
5515 scrollExtent.Free(null);
5517 /* ATTEMPTING TO MOVE THAT ABOVE
5526 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5527 for(;(child = window.children.first);)
5529 for(; child && (child.destroyed || !child.created); child = child.next);
5538 UnloadGraphics(true);
5541 delete previousActive;
5544 // statusBar = null;
5547 if(master && !master.destroyed)
5549 //master.NotifyDestroyed(this, this.returnCode);
5550 NotifyDestroyed(master, this, this.returnCode);
5553 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5555 nextTimer = timer.next;
5556 if(timer.window == this)
5558 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5559 // timer.window = null;
5565 if(this == guiApp.windowMoving)
5568 if(guiApp.windowCaptured == this)
5570 //guiApp.windowCaptured = null;
5572 if(rootWindow != this && rootWindow)
5573 rootWindow.ConsequentialMouseMove(false);
5581 //for(child = children.first; next = child ? child.next : null, child; child = next)
5582 for(;(child = children.first); )
5584 for(; child && (child.destroyed || !child.created); child = child.next);
5594 /* // MOVED THIS UP...
5597 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5598 for(;(child = window.children.first); )
5600 for(; child && (child.destroyed || !child.created); child = child.next);
5609 while((slave = slaves.first))
5611 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5613 ((Window)slave.data).DestroyEx(0);
5618 if(guiApp.caretOwner == this)
5619 guiApp.caretOwner = null;
5621 sysButtons[0] = null;
5622 sysButtons[1] = null;
5623 sysButtons[2] = null;
5626 if(rootWindow != this)
5628 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5631 box.left -= parent.clientStart.x;
5632 box.top -= parent.clientStart.y;
5633 box.right -= parent.clientStart.x;
5634 box.bottom -= parent.clientStart.y;
5636 if(parent) parent.Update(box);
5641 OldLink slave = master.slaves.FindVoid(this);
5642 master.slaves.Delete(slave);
5648 parent.children.Remove(this);
5653 //autoCreate = false;
5656 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5657 if(((subclass(Window))_class).pureVTbl)
5659 if(_vTbl == _class._vTbl)
5661 _vTbl = ((subclass(Window))_class).pureVTbl;
5666 for(m = 0; m < _class.vTblSize; m++)
5668 if(_vTbl[m] == _class._vTbl[m])
5669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5678 void SetStateEx(WindowState newState, bool activate)
5681 WindowState prevState = state;
5685 if(prevState != newState)
5686 lastState = prevState;
5688 if(rootWindow != this || !nativeDecorations || !windowHandle)
5690 if(style.isActiveClient && !style.hidden && prevState == minimized)
5693 // This block used to be at the end of the function... moved it for flicker problem in X
5694 // ------------------------------------------------------
5698 stateAnchor = normalAnchor;
5699 stateSizeAnchor = normalSizeAnchor;
5702 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5703 stateSizeAnchor = SizeAnchor {};
5707 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5710 byte * idBuffer = new0 byte[size];
5712 for(child = parent.children.first; child; child = child.next)
5714 if(child != this && child.state == minimized)
5716 if(child.iconID > size - 2)
5718 idBuffer = renew0 idBuffer byte[size*2];
5719 memset(idBuffer + size, 0, size);
5722 idBuffer[child.iconID] = (byte)bool::true;
5725 for(c = 0; c<size; c++)
5730 if(style.isActiveClient && !style.hidden)
5733 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5734 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5738 // TOCHECK: Why was this here?
5739 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5740 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5741 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5743 Position(x, y, w, h, true, true, true, true, false, true);
5745 if(!style.inactive && !style.interim && this == parent.activeClient)
5746 parent.UpdateActiveDocument(null);
5749 CreateSystemChildren();
5750 // ------------------------------------------------------
5753 int GetPositionID(Window forChild)
5757 byte * idBuffer = new0 byte[size];
5760 for(child = children.first; child; child = child.next)
5762 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5764 if(child.positionID > size - 2)
5766 idBuffer = renew0 idBuffer byte[size*2];
5767 memset(idBuffer + size, 0, size);
5770 idBuffer[child.positionID] = (byte)bool::true;
5773 for(c = 0; c<size; c++)
5780 // --- Window related graphics ---
5782 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5784 palette = newPalette;
5785 if(rootWindow.display)
5786 rootWindow.display.SetPalette(palette, colorMatch);
5789 public bool AcquireInput(bool acquired)
5792 if(acquiredInput != acquired)
5794 if(active || (!visible && creationActivation == activate))
5795 result = AcquireInputEx(acquired);
5800 acquiredInput = acquired ? result : !result;
5805 void ListChildren(ListBox listBox)
5809 for(child = children.first; child; child = child.next)
5811 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5813 DataRow row = listBox.AddRow();
5814 row.tag = (int64)child;
5815 child.FigureCaption(caption);
5816 row.SetData(null, caption);
5821 void UpdateVisual(Box extent)
5823 if(guiApp.driver != null)
5825 if(guiApp.fullScreenMode && guiApp.desktop.display)
5827 guiApp.desktop.mutex.Wait();
5828 guiApp.desktop.display.Lock(true);
5831 if(guiApp.desktop.active)
5833 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5835 if(guiApp.desktop.display.flags.flipping)
5836 guiApp.desktop.Update(null);
5837 guiApp.desktop.UpdateDisplay();
5838 guiApp.cursorUpdate = true;
5840 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5842 guiApp.PreserveAndDrawCursor();
5843 // guiApp.desktop.display.ShowScreen();
5844 guiApp.cursorUpdate = false;
5845 guiApp.desktop.dirty = false;
5846 guiApp.RestoreCursorBackground();
5850 guiApp.desktop.display.Unlock();
5851 guiApp.desktop.mutex.Release();
5855 Window rootWindow = this.rootWindow;
5856 rootWindow.mutex.Wait();
5861 guiApp.SignalEvent();
5864 guiApp.waitMutex.Wait();
5865 guiApp.interfaceDriver.Lock(rootWindow);
5866 if(!rootWindow.style.hidden && rootWindow.dirty)
5868 if(rootWindow.display)
5870 rootWindow.UpdateDisplay();
5871 //rootWindow.display.ShowScreen(null);
5873 rootWindow.dirty = false;
5875 guiApp.interfaceDriver.Unlock(rootWindow);
5876 guiApp.waitMutex.Release();
5879 rootWindow.mutex.Release();
5884 void UnlockDisplay(void)
5886 guiApp.interfaceDriver.Unlock(rootWindow);
5889 void LockDisplay(void)
5891 guiApp.interfaceDriver.Lock(rootWindow);
5894 Surface GetSurface(Box box)
5896 return Redraw((box == null) ? this.box : box);
5899 void SetMousePosition(int x, int y)
5901 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5905 void IntegrationActivate(bool active)
5907 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5909 isForegroundWindow = true;
5910 ActivateEx(active, active, false, false, null, null);
5911 isForegroundWindow = false;
5916 Window QueryCapture(void)
5918 return guiApp.windowCaptured;
5921 int GetDocumentID(void)
5925 byte * idBuffer = new0 byte[size];
5928 for(child = children.first; child; child = child.next)
5930 // TO CHECK: Do we want a documentID when we already have a file name?
5931 if(child.style.isDocument && !child.fileName)
5933 if(child.documentID-1 > size - 2)
5935 idBuffer = renew0 idBuffer byte[size*2];
5936 memset(idBuffer + size, 0, size);
5939 idBuffer[child.documentID-1] = 1;
5942 for(c = 0; c<size; c++)
5950 void SetInitSize(Size size)
5953 sizeAnchor.size = size;
5954 normalSizeAnchor = sizeAnchor;
5956 // Break the anchors for moveable/resizable windows
5957 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5959 stateAnchor = normalAnchor;
5960 stateSizeAnchor = normalSizeAnchor;
5962 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5963 Position(x,y, w, h, true, true, true, true, false, true);
5967 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5969 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5971 guiApp.windowIsResizing = resize;
5972 guiApp.windowMoving = this;
5973 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5974 if(guiApp.windowIsResizing)
5976 guiApp.windowMovingStart.x += size.w - 1;
5977 guiApp.windowMovingStart.y += size.h - 1;
5979 guiApp.windowMovingBefore = scrolledPos;
5980 guiApp.windowResizingBefore = size;
5981 guiApp.windowMoving.UpdateDecorations();
5982 if(guiApp.windowIsResizing)
5983 guiApp.resizeEndX = guiApp.resizeEndY = true;
5985 if(setCursorPosition)
5986 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5990 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5991 guiApp.windowMovingStart.x += x - absPosition.x;
5992 guiApp.windowMovingStart.y += y - absPosition.y;
5995 if(guiApp.windowMoving)
5997 if(guiApp.windowMoving.style.nonClient)
5998 guiApp.windowMoving.parent.SetMouseRangeToWindow();
6000 guiApp.windowMoving.parent.SetMouseRangeToClient();
6005 if(this == rootWindow)
6006 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6014 bool result = false;
6018 else if(guiApp && guiApp.driver != null)
6020 void * systemParent = null;
6021 OldLink slaveHolder;
6023 bool visible = !style.hidden;
6027 systemParent = parent;
6028 parent = guiApp.desktop;
6030 last = parent ? parent.children.last : null;
6032 if((parent && parent != guiApp.desktop && !parent.created) ||
6033 (master && master != guiApp.desktop && !master.created))
6037 stopwatching(parent, font);
6040 property::parent = guiApp.desktop;
6041 if(!master) master = parent;
6043 if(_isModal && master.modalSlave)
6044 property::master = master.modalSlave;
6048 parent.children.Remove(this);
6051 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6052 if(slaveHolder.data == this)
6054 master.slaves.Delete(slaveHolder);
6059 if(parent == guiApp.desktop && !mutex)
6062 if(style.isDocument)
6065 parent.numDocuments--;
6066 documentID = parent.GetDocumentID();
6069 if(!style.stayOnTop)
6070 for(; last && last.style.stayOnTop; last = last.prev);
6072 parent.children.Insert((last == this) ? null : last, this);
6073 //parent.children.Add(this);
6076 dispDriver = parent.dispDriver;
6079 master.modalSlave = this;
6081 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6086 master.slaves.Add(slaveHolder = OldLink { data = this });
6091 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6093 if(style.isDefault && !master.defaultControl)
6094 master.defaultControl = this;
6096 stateAnchor = normalAnchor = anchor;
6097 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6099 // TOCHECK: Why is this here?
6100 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6101 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6103 this.visible = false;
6104 style.hidden = true;
6107 // autoCreate = true;
6115 if(parent == guiApp.desktop)
6116 Log("LoadGraphics %s\n", caption);
6118 if(LoadGraphics(true, false))
6126 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6133 if(style.hasMenuBar /*&& menu*/)
6139 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6140 interim = false, inactive = true, nonClient = true, size.h = 24
6148 // Create the system buttons
6149 CreateSystemChildren();
6151 UpdateActiveDocument(null);
6153 if(style.isDocument)
6157 MenuItem item = menu.FindItem(MenuFileSave, 0);
6158 if(item) item.disabled = !modifiedDocument && fileName;
6163 if(parent == guiApp.desktop)
6164 Log("Preemptive SetState %s\n", caption);
6167 // Preemptive Set State to ensure proper anchoring
6168 SetStateEx(state, false);
6170 style.hidden = true;
6176 for(child = children.first; child; child = next)
6179 if(!child.created && (child.autoCreate || child.wasCreated))
6186 for(link = slaves.first; link; link = next)
6188 Window slave = link.data;
6190 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6193 // Things might have happened that invalidated 'next'...
6194 // Start over the search for slaves to create.
6195 // (Added this to fix crash with Stacker & Toolbar)
6196 next = slaves.first;
6205 if(parent == guiApp.desktop)
6206 Log("Real SetState %s\n", caption);
6209 if(isActiveClient && visible)
6211 parent.numPositions--;
6212 if(state == minimized) parent.numIcons--;
6215 parent.OnChildAddedOrRemoved(this, false);
6217 // Real set state & activate for proper display & activation
6218 property::visible = visible;
6219 // SetState(state & 0x00000003, true, 0);
6220 guiApp.interfaceDriver.SetIcon(this, icon);
6225 /*if(rootWindow == this)
6226 guiApp.interfaceDriver.ActivateRootWindow(this);
6228 if(creationActivation == activate)
6229 ActivateEx(true, false, true, true, null, null);
6230 else if(creationActivation == flash)
6235 rootWindow.ConsequentialMouseMove(false);
6246 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6252 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6254 //style.hidden = true; // !visible;
6255 style.hidden = !visible;
6256 if(master.modalSlave == this)
6257 master.modalSlave = null;
6264 void WriteCaption(Surface surface, int x, int y)
6267 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6270 void Update(Box region)
6276 rootWindow = this.rootWindow;
6278 // rootWindow.mutex.Wait();
6279 if(!destroyed && visible && display)
6284 // Testing this to avoid repetitve full update to take time...
6285 if(dirtyArea.count == 1)
6287 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6288 if(item.box.left <= box.left &&
6289 item.box.top <= box.top &&
6290 item.box.right >= box.right &&
6291 item.box.bottom >= box.bottom)
6293 rootWindow.dirty = true;
6298 if(display.flags.flipping && !rootWindow.dirty)
6300 if(this == rootWindow)
6304 rootWindow.Update(null);
6309 rootWindow.dirty = true;
6314 realBox.left += clientStart.x;
6315 realBox.top += clientStart.y;
6316 realBox.right += clientStart.x;
6317 realBox.bottom += clientStart.y;
6323 if(realBox.right >= realBox.left &&
6324 realBox.bottom >= realBox.top)
6326 // if(!rootWindow.fullRender)
6327 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6329 for(child = children.first; child; child = child.next)
6334 box.left -= child.absPosition.x - absPosition.x;
6335 box.top -= child.absPosition.y - absPosition.y;
6336 box.right -= child.absPosition.x - absPosition.x;
6337 box.bottom -= child.absPosition.y - absPosition.y;
6338 if(box.right >= child.box.left && box.left <= child.box.right &&
6339 box.bottom >= child.box.top && box.top <= child.box.bottom)
6341 box.left -= child.clientStart.x;
6342 box.top -= child.clientStart.y;
6343 box.right -= child.clientStart.x;
6344 box.bottom -= child.clientStart.y;
6350 realBox.left += absPosition.x - rootWindow.absPosition.x;
6351 realBox.top += absPosition.y - rootWindow.absPosition.y;
6352 realBox.right += absPosition.x - rootWindow.absPosition.x;
6353 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6354 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6357 else if(this == guiApp.desktop)
6360 for(window = children.first; window; window = window.next)
6366 Box childBox = region;
6368 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6369 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6370 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6371 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6373 window.Update(childBox);
6376 window.Update(null);
6381 // rootWindow.mutex.Release();
6388 if(guiApp.windowCaptured != this)
6390 if(guiApp.windowCaptured)
6394 //Logf("Captured %s (%s)\n", caption, class.name);
6395 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6396 guiApp.windowCaptured = this;
6402 bool Destroy(int64 code)
6407 if(!destroyed && !CloseConfirmation(false)) return false;
6411 // TOCHECK: Should autoCreate be set to false here?
6422 void Move(int x, int y, int w, int h)
6424 normalAnchor = Anchor { left = x, top = y };
6425 normalSizeAnchor = SizeAnchor { size = { w, h } };
6427 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6429 if(destroyed) return;
6431 stateAnchor = normalAnchor;
6432 stateSizeAnchor = normalSizeAnchor;
6434 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6435 Position(x,y, w, h, true, true, true, true, false, true);
6439 DialogResult Modal(void)
6445 // FIXES MEMORY LEAK IF Create() FAILED
6451 void SetScrollArea(int width, int height, bool snapToStep)
6453 bool resize = false;
6456 int stepX = sbStep.x, stepY = sbStep.y;
6457 // Needed to make snapped down position match the skin's check of client area
6458 // against realvirtual
6461 SNAPDOWN(stepX, textCellW);
6462 SNAPDOWN(stepY, textCellH);
6463 stepX = Max(stepX, textCellW);
6464 stepY = Max(stepY, textCellH);
6466 if(scrollFlags.snapX)
6467 SNAPUP(width, stepX);
6468 if(scrollFlags.snapY)
6469 SNAPUP(height, stepY);
6472 reqScrollArea.w = width;
6473 reqScrollArea.h = height;
6474 noAutoScrollArea = (width > 0 || height > 0);
6476 UpdateScrollBars(true, true);
6479 void SetScrollPosition(int x, int y)
6482 sbh.Action(setPosition, x, 0);
6486 int seen = clientSize.w, total = reqScrollArea.w;
6488 if(scrollFlags.snapX)
6489 SNAPDOWN(seen, sbStep.x);
6491 if(!total) total = seen;
6492 range = total - seen + 1;
6493 range = Max(range, 1);
6495 if(x >= range) x = range - 1;
6497 if(scrollFlags.snapX)
6498 SNAPUP(x, sbStep.x);
6501 OnHScroll(setPosition, x, 0);
6505 SNAPDOWN(x, textCellW);
6511 sbv.Action(setPosition, y, 0);
6515 int seen = clientSize.h, total = reqScrollArea.h;
6518 if(scrollFlags.snapY)
6519 SNAPDOWN(seen, sbStep.y);
6521 if(!total) total = seen;
6522 range = total - seen + 1;
6523 range = Max(range, 1);
6525 if(y >= range) y = range - 1;
6527 if(scrollFlags.snapY)
6528 SNAPUP(y, sbStep.y);
6531 OnVScroll(setPosition, y, 0);
6534 SNAPDOWN(y, textCellH);
6539 UpdateCaret(false, false);
6542 void SetScrollLineStep(int stepX, int stepY)
6548 SNAPDOWN(stepX, textCellW);
6549 SNAPDOWN(stepY, textCellH);
6550 stepX = Max(stepX, textCellW);
6551 stepY = Max(stepY, textCellH);
6554 sbh.lineStep = stepX;
6556 sbv.lineStep = stepY;
6559 void SetState(WindowState newState, bool activate, Modifiers mods)
6563 if(state == newState || OnStateChange(newState, mods))
6565 WindowState prevState = state;
6569 // This used to be at the end of the brackets... moved for X, testing...
6570 // This has the effect of activating the window through the system...
6571 if(rootWindow == this)
6572 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6574 SetStateEx(newState, activate);
6576 if(rootWindow == this && !rootWindow.nativeDecorations)
6578 int x = position.x, y = position.y;
6581 x -= guiApp.desktop.absPosition.x;
6582 y -= guiApp.desktop.absPosition.y;
6584 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6588 //state = prevState;
6590 if(state != maximized && style.hasMaximize)
6593 for(child = parent.children.first; child; child = child.next)
6595 if(child != this && child.state == maximized)
6596 child.SetStateEx(normal, false);
6600 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6601 parent.UpdateScrollBars(true, true);
6604 // Do we really need this stuff here?
6605 // Shouldn't the Activate stuff take care of it?
6606 if(parent.rootWindow == parent && style)
6609 parent.FigureCaption(caption);
6610 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6611 parent.UpdateDecorations();
6615 rootWindow.ConsequentialMouseMove(false);
6622 BitmapResource GetIcon(SkinBitmap iconID)
6624 return guiApp.currentSkin.GetBitmap(iconID);
6627 void SetMouseRange(Box range)
6629 if(range || guiApp.fullScreenMode)
6634 clip.left = range.left + absPosition.x + clientStart.x;
6635 clip.top = range.top + absPosition.y + clientStart.y;
6636 clip.right = range.right + absPosition.x + clientStart.x;
6637 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6641 clip.left = guiApp.desktop.box.left;
6642 clip.top = guiApp.desktop.box.top;
6643 clip.right = guiApp.desktop.box.right;
6644 clip.bottom = guiApp.desktop.box.bottom;
6646 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6649 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6652 void SetMouseRangeToClient(void)
6654 if(guiApp.fullScreenMode || this != guiApp.desktop)
6656 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6657 box.Clip(clientArea);
6661 SetMouseRange(null);
6664 void SetMouseRangeToWindow(void)
6666 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6667 if(this == guiApp.desktop)
6668 SetMouseRangeToClient();
6673 // x, y: Desktop Coordinates
6674 void ShowSysMenu(int x, int y)
6677 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6680 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6681 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6685 menu, $"Move", m, NotifySelect = MenuWindowMove,
6686 disabled = !style.fixed || state == maximized
6690 menu, $"Size", s, NotifySelect = MenuWindowSize,
6691 disabled = !style.sizable || state != normal
6695 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6696 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6700 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6701 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6705 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6706 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6708 MenuDivider { menu };
6711 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6712 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6714 windowMenu.Create();
6719 ActivateEx(true, true, true, true, null, null);
6722 void MakeActive(void)
6724 ActivateEx(true, false, true, false, null, null);
6727 void SoftActivate(void)
6729 if(guiApp.desktop.active)
6735 void Deactivate(void)
6737 ActivateEx(false, true, true, true, null, null);
6742 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6745 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6747 bool result = false;
6748 if(activeChild && activeChild.cycle)
6750 Window modalWindow, child = activeChild;
6751 if(!clientOnly /*&& parent.tabCycle*/)
6753 Window next = child;
6756 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6760 if(parent && parent.CycleChildren(backward, false, true, true))
6768 next = next.cycle.prev.data;
6770 next = next.cycle.next.data;
6771 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6776 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6777 parent.tabCycle && parent.CycleChildren(backward, false, false))
6781 if(tabCycleOnly && !tabCycle) return false;
6788 child = child.cycle.prev.data;
6790 child = child.cycle.next.data;
6791 if(child == child.parent.activeChild)
6793 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6796 modalWindow = child.FindModal();
6799 // Scroll the window to include the active control
6800 if(sbh && !child.style.dontScrollHorz)
6802 if(child.scrolledPos.x < 0)
6803 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6804 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6805 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6807 if(sbv && !child.style.dontScrollVert)
6809 if(child.scrolledPos.y < 0)
6810 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6811 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6812 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6816 child = modalWindow ? modalWindow : child;
6817 child.ActivateEx(true, true, true, true, null, null);
6818 if(child.tabCycle && child.childrenCycle.first)
6819 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6827 ConsequentialMouseMove(false);
6831 void AddResource(Resource resource)
6835 ResPtr ptr { resource = resource };
6839 // Load Graphics here if window is created already
6840 if(/*created && */display)
6842 display.Lock(false);
6843 ptr.loaded = display.displaySystem.LoadResource(resource);
6847 // Temporary hack to load font right away for listbox in dropbox ...
6848 else if(master && master.display)
6850 master.display.Lock(false);
6851 master.display.displaySystem.LoadResource(resource);
6852 master.display.Unlock();
6858 void RemoveResource(Resource resource)
6863 for(ptr = resources.first; ptr; ptr = ptr.next)
6865 if(ptr.resource == resource)
6871 // Unload Graphics here if window is created already
6872 if(/*created && */display)
6876 display.Lock(false);
6877 display.displaySystem.UnloadResource(resource, ptr.loaded);
6883 resources.Delete(ptr);
6888 void SetCaret(int x, int y, int size)
6895 if(active && !style.interim)
6897 if(visible || !guiApp.caretOwner)
6898 guiApp.caretOwner = size ? this : null;
6900 UpdateCaret(false, false);
6903 guiApp.interfaceDriver.SetCaret(0,0,0);
6904 UpdateCaret(false, true);
6905 guiApp.caretEnabled = false;
6908 else if(style.inactive && active)
6910 guiApp.interfaceDriver.SetCaret(0,0,0);
6911 UpdateCaret(false, true);
6912 guiApp.caretEnabled = false;
6917 void Scroll(int x, int y)
6919 bool opaque = !style.drawBehind || background.a;
6920 if(opaque && display && display.flags.scrolling)
6922 Box box = clientArea;
6923 box.left += clientStart.x;
6924 box.top += clientStart.y;
6925 box.right += clientStart.x;
6926 box.bottom += clientStart.y;
6928 //scrollExtent.Free(null);
6929 scrollExtent.AddBox(box);
6930 scrolledArea.x += x;
6931 scrolledArea.y += y;
6933 //scrollExtent.Free();
6934 //scrollExtent.AddBox(clientArea);
6935 //scrollExtent.Offset(clientStart.x, clientStart.y);
6936 //scrolledArea.x = x;
6937 //scrolledArea.y = y;
6943 rootWindow.dirty = true;
6946 void ReleaseCapture()
6948 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6950 Window oldCaptured = guiApp.windowCaptured;
6951 guiApp.windowCaptured = null;
6952 guiApp.prevWindow = null;
6955 //guiApp.Log("Released Capture\n");
6957 guiApp.interfaceDriver.SetMouseCapture(null);
6959 //oldCaptured.OnMouseCaptureLost();
6962 oldCaptured.ConsequentialMouseMove(false);
6967 private void _SetCaption(char * format, va_list args)
6974 char caption[MAX_F_STRING];
6975 vsnprintf(caption, sizeof(caption), format, args);
6976 caption[sizeof(caption)-1] = 0;
6978 this.caption = CopyString(caption);
6983 firewatchers caption;
6987 /*deprecated*/ void SetText(char * format, ...)
6990 va_start(args, format);
6991 _SetCaption(format, args);
6995 void SetCaption(char * format, ...)
6998 va_start(args, format);
6999 _SetCaption(format, args);
7003 bool Grab(Bitmap bitmap, Box box, bool decorations)
7005 bool result = false;
7006 if(display || this == guiApp.desktop)
7008 Box clip = {MININT, MININT, MAXINT, MAXINT};
7014 clip.Clip(clientArea);
7016 clip.Clip(this.box);
7018 if(rootWindow != this)
7020 clip.left += absPosition.y;
7021 clip.top += absPosition.y;
7022 clip.right += absPosition.x;
7023 clip.bottom += absPosition.y;
7026 clip.left += decorations ? 0 : clientStart.x;
7027 clip.top += decorations ? 0 : clientStart.y;
7028 clip.right += decorations ? 0 : clientStart.x;
7029 clip.bottom += decorations ? 0 : clientStart.y;
7031 if(display && display.flags.flipping)
7033 rootWindow.Update(null);
7034 rootWindow.UpdateDisplay();
7041 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7042 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7046 result = display.Grab(bitmap, clip.left, clip.top,
7047 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7049 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7051 if(!bitmap.Convert(null, pixelFormat888, null))
7058 void GetMousePosition(int * x, int * y)
7060 int mouseX = 0, mouseY = 0;
7061 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7064 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7065 if(this != guiApp.desktop)
7067 mouseX -= absPosition.x + clientStart.x;
7068 mouseY -= absPosition.y + clientStart.y;
7075 DialogResult DoModal()
7077 DialogResult returnCode = 0;
7078 int terminated = terminateX;
7081 while(!destroyed && guiApp.driver != null)
7083 if(terminateX != terminated)
7085 terminated = terminateX;
7086 guiApp.desktop.Destroy(0);
7087 if(guiApp.desktop.created)
7090 //printf("Resetting terminate X to 0\n");
7096 guiApp.UpdateDisplay();
7097 if(!guiApp.ProcessInput(false))
7100 returnCode = this.returnCode;
7113 return !destroyed && guiApp.driver != null && terminateX < 2;
7116 DialogResult DoModalEnd()
7118 DialogResult returnCode = this.returnCode;
7123 // --- Window manipulation ---
7124 /*bool GetDisabled()
7126 bool disabled = this.disabled;
7128 for(window = this; (window = window.master); )
7139 // --- Mouse Manipulation ---
7140 void GetNCMousePosition(int * x, int * y)
7142 GetMousePosition(x, y);
7143 if(x) *x += clientStart.x;
7144 if(y) *y += clientStart.y;
7147 // --- Carets manipulation ---
7148 void GetCaretPosition(Point caretPos)
7150 caretPos = this.caretPos;
7153 int GetCaretSize(void)
7158 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7164 bool CloseConfirmation(bool parentClosing)
7177 if(!OnClose(parentClosing))
7180 // If you want to skip this, simply set modifiedDocument to false in OnClose
7181 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7183 DialogResult dialogRes;
7186 sprintf(message, $"Save changes to %s?", fileName);
7188 sprintf(message, $"Save changes to Untitled %d?", documentID);
7190 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7192 if(dialogRes == yes)
7194 // TOFIX: Precomp error if brackets are taken out
7195 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7197 else if(dialogRes == cancel)
7203 for(slave = slaves.first; slave; slave = slave.next)
7205 Window w = slave.data;
7206 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7208 // ((Window)slave.data).CloseConfirmation(true);
7217 for(child = children.first; child; child = child.next)
7218 if(child.master != this && !child.CloseConfirmation(true))
7228 // Static methods... move them somewhere else?
7229 void ::RestoreCaret()
7231 if(guiApp.caretOwner)
7232 guiApp.caretOwner.UpdateCaret(false, false);
7235 void ::FreeMouseRange()
7237 guiApp.interfaceDriver.SetMouseRange(null, null);
7241 bool MenuFileClose(MenuItem selection, Modifiers mods)
7243 Window document = activeChild;
7245 document.Destroy(0);
7249 bool MenuFileExit(MenuItem selection, Modifiers mods)
7255 bool MenuFileSave(MenuItem selection, Modifiers mods)
7259 fileMonitor.fileName = null;
7262 if(OnSaveFile(fileName))
7264 //if(OnFileModified != Window::OnFileModified)
7267 fileMonitor.fileName = fileName;
7273 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7274 DialogResult answer = dialog.Modal();
7276 if(answer != yes) return (bool)answer;
7279 return MenuFileSaveAs(selection, mods);
7282 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7284 DialogResult result = (DialogResult)bool::true;
7285 FileDialog fileDialog = saveDialog;
7288 fileDialog = FileDialog {};
7293 fileDialog.filePath = fileName;
7296 char filePath[MAX_FILENAME];
7297 sprintf(filePath, "Untitled %d", documentID);
7298 fileDialog.filePath = filePath;
7300 fileMonitor.fileName = null;
7302 fileDialog.type = save;
7303 fileDialog.text = $"Save As";
7307 fileDialog.master = master.parent ? master : this;
7308 if(fileDialog.Modal() == ok)
7310 char * filePath = fileDialog.filePath;
7312 if(OnSaveFile(filePath))
7315 property::fileName = filePath;
7316 NotifySaved(master, this, filePath);
7321 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7322 DialogResult answer = dialog.Modal();
7337 //if(OnFileModified != Window::OnFileModified && fileName)
7340 fileMonitor.fileName = fileName;
7344 return (bool)result; // Actually returning result from Yes/NoCancel message box
7347 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7349 Window document = activeChild;
7351 for(document = children.first; document; document = next)
7353 next = document.next;
7354 if(document.style.isDocument || document.fileName)
7355 document.MenuFileSave(selection, mods);
7360 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7364 for(document = children.first; document; document = document.next)
7365 //if(document.style.isDocument && document.state == minimized)
7366 if(document.style.isActiveClient && document.state == minimized)
7367 document.SetState(minimized, false, mods);
7371 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7373 Window document = activeChild;
7376 Window firstDocument = null;
7378 OldLink cycle = document.cycle.prev;
7383 if(child.style.isActiveClient && !child.style.hidden)
7387 firstDocument = child;
7388 if(child.state == minimized)
7389 child.SetState(minimized, false, mods);
7392 child.positionID = id++;
7393 child.SetState(normal, false, mods);
7394 child.anchor.left.type = cascade;
7397 child.normalSizeAnchor = *&child.sizeAnchor;
7398 child.normalAnchor = child.anchor;
7400 // Break the anchors for moveable/resizable windows
7401 if(child.style.fixed)
7403 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7405 (*&child.normalAnchor).left = x;
7406 (*&child.normalAnchor).top = y;
7407 (*&child.normalAnchor).right.type = none;
7408 (*&child.normalAnchor).bottom.type = none;
7410 child.normalSizeAnchor.isClientW = false;
7411 child.normalSizeAnchor.isClientH = false;
7412 child.normalSizeAnchor.size.w = w;
7413 child.normalSizeAnchor.size.h = h;
7414 child.anchored = false;
7417 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7419 child.stateAnchor = child.normalAnchor;
7420 child.stateSizeAnchor = child.normalSizeAnchor;
7422 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7423 child.Position(x, y, w, h, true, true, true, true, false, false);
7428 last = children.last;
7429 if(!child.style.stayOnTop)
7430 for(; last && last.style.stayOnTop; last = last.prev);
7431 children.Move(child, last);
7432 childrenOrder.Move(child.order, childrenOrder.last);
7434 if(cycle == document.cycle) break;
7438 firstDocument.Activate();
7443 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7450 // Close all closes all active clients, not all documents
7451 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7453 Window next, document;
7455 for(document = children.first; document; document = next)
7457 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7458 if(document.style.isActiveClient)
7459 if(!document.Destroy(0) && !document.style.hidden)
7465 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7467 if(style.hasMaximize && state != maximized)
7468 SetState(maximized, 0, 0);
7472 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7474 if(style.hasMinimize && state != minimized)
7476 SetState(minimized, 0, 0);
7477 parent.CycleChildren(false, true, false, true);
7482 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7484 MenuMoveOrSize(false, selection ? true : false);
7488 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7490 CycleChildren(false, true, false, true);
7494 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7496 CycleChildren(true, true, false, true);
7500 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7502 MenuMoveOrSize(true, true);
7506 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7509 SetState(normal, 0, 0);
7513 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7516 int64 id = selection.id;
7517 OldLink cycle = activeClient.cycle;
7519 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7522 Window sibling = cycle.data;
7523 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7531 document = cycle.data;
7532 document.Activate();
7534 //if(activeChild.state == maximized)
7535 // document.SetState(maximized, false, mods);
7536 //else if(document.state == minimized)
7537 // document.SetState(normal, false, mods);
7541 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7543 stayOnTop = !style.stayOnTop;
7547 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7549 Window document = activeChild;
7552 Window firstDocument = null;
7553 OldLink cycle = document.cycle;
7557 Window child = cycle.data;
7558 if(child.style.isActiveClient && !child.style.hidden)
7560 if(!firstDocument) firstDocument = child;
7561 if(child.state == minimized)
7562 child.SetState(minimized, false, mods);
7565 child.positionID = id++;
7566 child.SetState(normal, false, mods);
7567 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7569 child.anchor.left.type = hTiled;
7572 child.normalSizeAnchor = *&child.sizeAnchor;
7573 child.normalAnchor = child.anchor;
7575 // Break the anchors for moveable/resizable windows
7576 if(child.style.fixed)
7578 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7580 (*&child.normalAnchor).left = x;
7581 (*&child.normalAnchor).top = y;
7582 (*&child.normalAnchor).right.type = none;
7583 (*&child.normalAnchor).bottom.type = none;
7584 child.normalSizeAnchor.isClientW = false;
7585 child.normalSizeAnchor.isClientH = false;
7586 child.normalSizeAnchor.size.w = w;
7587 child.normalSizeAnchor.size.h = h;
7588 child.anchored = false;
7591 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7593 child.stateAnchor = child.normalAnchor;
7594 child.stateSizeAnchor = child.normalSizeAnchor;
7596 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7597 child.Position(x,y, w, h, true, true, true, true, false, true);
7602 if((cycle = cycle.next) == document.cycle) break;
7605 firstDocument.Activate();
7610 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7612 Window document = activeChild;
7615 Window firstDocument = null;
7617 OldLink cycle = document.cycle;
7622 //if(child.style.isDocument)
7623 if(child.style.isActiveClient && !child.style.hidden)
7625 if(!firstDocument) firstDocument = child;
7626 if(child.state == minimized)
7627 child.SetState(minimized, false, mods);
7630 child.positionID = id++;
7631 child.SetState(normal, false, mods);
7632 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7634 child.anchor.left.type = vTiled;
7637 child.normalSizeAnchor = *&child.sizeAnchor;
7638 child.normalAnchor = child.anchor;
7640 // Break the anchors for moveable/resizable windows
7641 if(child.style.fixed)
7643 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7645 (*&child.normalAnchor).left = x;
7646 (*&child.normalAnchor).top = y;
7647 (*&child.normalAnchor).right.type = none;
7648 (*&child.normalAnchor).bottom.type = none;
7649 child.normalSizeAnchor.isClientW = false;
7650 child.normalSizeAnchor.isClientH = false;
7651 child.normalSizeAnchor.size.w = w;
7652 child.normalSizeAnchor.size.h = h;
7653 child.anchored = false;
7656 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7658 child.stateAnchor = child.normalAnchor;
7659 child.stateSizeAnchor = child.normalSizeAnchor;
7661 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7662 child.Position(x,y, w, h, true, true, true, true, false, true);
7667 if((cycle = cycle.next) == document.cycle) break;
7670 firstDocument.Activate();
7675 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7677 WindowList dialog { master = this };
7678 Window document = (Window)dialog.Modal();
7681 if(activeChild.state == maximized)
7682 document.SetState(maximized, false, mods);
7683 else if(document.state == minimized)
7684 document.SetState(normal, false, mods);
7685 document.Activate();
7691 virtual bool OnCreate(void);
7692 virtual void OnDestroy(void);
7693 virtual void OnDestroyed(void);
7694 virtual bool OnClose(bool parentClosing);
7695 virtual bool OnStateChange(WindowState state, Modifiers mods);
7696 virtual bool OnPostCreate(void);
7697 virtual bool OnMoving(int *x, int *y, int w, int h);
7698 virtual bool OnResizing(int *width, int *height);
7699 virtual void OnResize(int width, int height);
7700 virtual void OnPosition(int x, int y, int width, int height);
7701 virtual bool OnLoadGraphics(void);
7702 virtual void OnApplyGraphics(void);
7703 virtual void OnUnloadGraphics(void);
7704 virtual void OnRedraw(Surface surface);
7705 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7706 virtual void OnActivateClient(Window client, Window previous);
7707 virtual bool OnKeyDown(Key key, unichar ch);
7708 virtual bool OnKeyUp(Key key, unichar ch);
7709 virtual bool OnKeyHit(Key key, unichar ch);
7710 virtual bool OnSysKeyDown(Key key, unichar ch);
7711 virtual bool OnSysKeyUp(Key key, unichar ch);
7712 virtual bool OnSysKeyHit(Key key, unichar ch);
7713 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7714 virtual bool OnMouseLeave(Modifiers mods);
7715 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7716 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7717 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7718 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7719 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7720 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7721 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7722 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7723 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7724 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7725 virtual void OnMouseCaptureLost(void);
7726 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7727 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7728 virtual void OnDrawOverChildren(Surface surface);
7729 virtual bool OnFileModified(FileChange fileChange, char * param);
7730 virtual bool OnSaveFile(char * fileName);
7732 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7733 // Note: A 'client' would refer to isActiveClient, rather than
7734 // being confined to the 'client area' (nonClient == false)
7735 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7736 virtual void OnChildVisibilityToggled(Window child, bool visible);
7737 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7739 // Skins Virtual Functions
7740 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7741 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7742 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7747 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7748 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7749 virtual bool IsMouseMoving(int x, int y, int w, int h)
7753 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7757 virtual void UpdateNonClient();
7758 virtual void SetBox(Box box);
7759 virtual bool IsInside(int x, int y)
7761 return box.IsPointInside({x, y});
7763 virtual bool IsOpaque()
7765 return (!style.drawBehind || background.a == 255);
7769 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7770 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7771 virtual void Window::NotifySaved(Window window, char * filePath);
7776 property Window parent
7778 property_category $"Layout"
7781 if(value || guiApp.desktop)
7784 Window oldParent = parent;
7785 Anchor anchor = this.anchor;
7787 if(value && value.IsDescendantOf(this)) return;
7788 if(value && value == this)
7790 if(!value) value = guiApp.desktop;
7792 if(value == oldParent) return;
7794 if(!master || (master == this.parent && master == guiApp.desktop))
7795 property::master = value;
7799 parent.children.Remove(this);
7803 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7804 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7805 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7806 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7810 last = value.children.last;
7812 if(style.isDocument)
7815 parent.numDocuments--;
7816 documentID = value.GetDocumentID();
7819 if(style.isActiveClient && !style.hidden)
7821 if(parent && parent != guiApp.desktop && !(style.hidden))
7823 if(state == minimized) parent.numIcons--;
7824 parent.numPositions--;
7828 if(!style.stayOnTop)
7829 for(; last && last.style.stayOnTop; last = last.prev);
7831 value.children.Insert(last, this);
7833 // *** NEW HERE: ***
7835 parent.childrenCycle.Delete(cycle);
7837 parent.childrenOrder.Delete(order);
7840 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7841 // Should something else be done?
7842 if(parent && parent.activeChild == this)
7843 parent.activeChild = null;
7844 if(parent && parent.activeClient == this)
7845 parent.activeClient = null;
7851 int x = position.x, y = position.y, w = size.w, h = size.h;
7855 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7856 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7858 vpw = value.clientSize.w;
7859 vph = value.clientSize.h;
7865 else if(style.fixed)
7867 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7868 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7871 anchor = this.anchor;
7873 if(anchor.left.type == offset) anchor.left.distance = x;
7874 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7875 if(anchor.top.type == offset) anchor.top.distance = y;
7876 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7877 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7878 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7879 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7880 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7881 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7882 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7884 if(!anchor.left.type && !anchor.right.type)
7886 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7887 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7889 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7890 if(!anchor.top.type && !anchor.bottom.type)
7892 anchor.vert.distance = (y + h / 2) - (vph / 2);
7893 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7895 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7898 parent.OnChildAddedOrRemoved(this, false);
7904 parent.childrenCycle.Insert(
7905 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7906 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7908 cycle = OldLink { data = this });
7909 parent.childrenOrder.Insert(
7910 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7911 order = OldLink { data = this });
7914 if(!style.hidden && style.isActiveClient)
7916 positionID = parent.GetPositionID(this);
7917 parent.numPositions++;
7918 if(state == minimized) parent.numIcons--;
7921 // *** FONT INHERITANCE ***
7922 if(!setFont && oldParent)
7923 stopwatching(oldParent, font);
7927 RemoveResource(systemFont);
7930 // TESTING WITH WATCHERS:
7931 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7932 // usedFont = setFont ? setFont : (systemFont);
7936 if(guiApp.currentSkin)
7938 systemFont = guiApp.currentSkin.SystemFont();
7941 usedFont = systemFont;
7942 AddResource(systemFont);
7950 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7959 if(value.rootWindow && value.rootWindow.display && rootWindow)
7961 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7962 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7965 UnloadGraphics(false);
7968 LoadGraphics(false, false);
7971 if(value.rootWindow != rootWindow)
7972 DisplayModeChanged();
7976 scrolledPos.x = MININT; // Prevent parent update
7978 bool anchored = this.anchored;
7979 property::anchor = anchor;
7980 this.anchored = anchored;
7985 if(guiApp.currentSkin)
7986 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7988 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7989 Position(x, y, w, h, true, true, true, true, false, true);
7994 // else parent = value;
7996 oldParent.OnChildAddedOrRemoved(this, true);
7999 get { return parent; }
8002 property Window master
8004 property_category $"Behavior"
8007 //if(this == value) return;
8008 if(value && value.IsSlaveOf(this)) return;
8014 OldLink slaveHolder;
8015 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8016 if(slaveHolder.data == this)
8018 master.slaves.Delete(slaveHolder);
8025 value.slaves.Add(OldLink { data = this });
8030 master.hotKeys.Remove(hotKey);
8031 value.hotKeys.Add(hotKey);
8034 if(master && master.defaultControl == this)
8035 master.defaultControl = null;
8037 if(style.isDefault && !value.defaultControl)
8038 value.defaultControl = this;
8043 get { return master ? master : parent; }
8046 property char * caption
8048 property_category $"Appearance"
8055 caption = new char[strlen(value)+1];
8057 strcpy(caption, value);
8062 get { return caption; }
8067 property_category $"Behavior"
8076 master.hotKeys.Add(hotKey = HotKeySlot { });
8080 hotKey.window = this;
8085 master.hotKeys.Delete(hotKey);
8090 get { return hotKey ? hotKey.key : 0; }
8093 property Color background
8095 property_category $"Appearance"
8098 background.color = value;
8103 if(this == rootWindow)
8104 guiApp.interfaceDriver.SetRootWindowColor(this);
8107 get { return background.color; }
8110 property Percentage opacity
8112 property_category $"Appearance"
8115 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8116 drawBehind = (background.a == 255) ? false : true;
8118 get { return background.a / 255.0f; }
8121 property Color foreground
8123 property_category $"Appearance"
8131 get { return foreground; }
8134 property BorderStyle borderStyle
8136 property_category $"Appearance"
8139 if(!((BorderBits)value).fixed)
8141 style.hasClose = false;
8142 style.hasMaximize = false;
8143 style.hasMinimize = false;
8144 nativeDecorations = false;
8146 style.borderBits = value;
8150 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8152 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8153 Position(x, y, w, h, true, true, true, true, false, true);
8154 CreateSystemChildren();
8157 get { return (BorderStyle)style.borderBits; }
8160 property Size minClientSize
8162 property_category $"Layout"
8163 set { minSize = value; }
8164 get { value = minSize; }
8167 property Size maxClientSize
8169 property_category $"Layout"
8170 set { maxSize = value; }
8171 get { value = maxSize; }
8174 property bool hasMaximize
8176 property_category $"Window Style"
8179 style.hasMaximize = value;
8180 if(value) { style.fixed = true; style.contour = true; }
8184 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8186 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8187 Position(x, y, w, h, true, true, true, true, false, true);
8189 CreateSystemChildren();
8192 get { return style.hasMaximize; }
8195 property bool hasMinimize
8197 property_category $"Window Style"
8200 style.hasMinimize = value;
8201 if(value) { style.fixed = true; style.contour = true; }
8205 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8207 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8208 Position(x, y, w, h, true, true, true, true, false, true);
8210 CreateSystemChildren();
8213 get { return style.hasMinimize; }
8216 property bool hasClose
8218 property_category $"Window Style"
8221 style.hasClose = value;
8222 if(value) { style.fixed = true; style.contour = true; }
8226 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8227 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8228 Position(x, y, w, h, true, true, true, true, false, true);
8229 CreateSystemChildren();
8232 get { return style.hasClose; }
8235 property bool nonClient
8237 property_category $"Layout"
8240 style.nonClient = value;
8242 style.stayOnTop = true;
8244 get { return style.nonClient; }
8247 property bool inactive
8249 property_category $"Behavior"
8254 // *** NEW HERE: ***
8258 parent.childrenCycle.Delete(cycle);
8260 parent.childrenOrder.Delete(order);
8267 active = false; // true;
8268 if(parent.activeChild == this)
8269 parent.activeChild = null;
8270 if(parent.activeClient == this)
8271 parent.activeClient = null;
8280 parent.childrenCycle.Insert(
8281 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8282 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8284 cycle = OldLink { data = this });
8286 parent.childrenOrder.Insert(
8287 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8288 order = OldLink { data = this });
8291 style.inactive = value;
8293 get { return style.inactive; }
8296 property bool clickThrough
8298 property_category $"Behavior"
8299 set { style.clickThrough = value; }
8300 get { return style.clickThrough; }
8303 property bool isRemote
8305 property_category $"Behavior"
8306 set { style.isRemote = value; }
8307 get { return style.isRemote; }
8310 property bool noCycle
8312 property_category $"Behavior"
8313 set { style.noCycle = value; }
8314 get { return style.noCycle; }
8317 property bool isModal
8319 property_category $"Behavior"
8320 set { style.modal = value; }
8321 get { return style.modal; }
8324 property bool interim
8326 property_category $"Behavior"
8327 set { style.interim = value; }
8328 get { return style.interim; }
8331 property bool tabCycle
8333 property_category $"Behavior"
8334 set { style.tabCycle = value; }
8335 get { return style.tabCycle; }
8338 property bool isDefault
8340 property_category $"Behavior"
8348 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8349 if(sibling != this && sibling.style.isDefault)
8350 sibling.style.isDefault = false;*/
8351 if(master.defaultControl)
8352 master.defaultControl.style.isDefault = false;
8353 master.defaultControl = this;
8355 else if(master.defaultControl == this)
8356 master.defaultControl = null;
8360 style.isDefault = value;
8362 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8364 get { return style.isDefault; }
8367 property bool drawBehind
8369 property_category $"Window Style"
8370 set { style.drawBehind = value; }
8371 get { return style.drawBehind; }
8374 property bool hasMenuBar
8376 property_category $"Window Style"
8386 if(created && !menuBar)
8393 anchor = Anchor { top = 23, left = 1, right = 1 },
8395 inactive = true, nonClient = true
8400 else if(created && menuBar)
8405 style.hasMenuBar = value;
8407 get { return style.hasMenuBar; }
8410 property bool hasStatusBar
8412 property_category $"Window Style"
8419 statusBar = StatusBar { this };
8427 style.hasStatusBar = value;
8429 get { return style.hasStatusBar; }
8431 property bool stayOnTop
8433 property_category $"Window Style"
8438 if(created && !style.stayOnTop)
8440 if(rootWindow == this)
8441 guiApp.interfaceDriver.OrderRootWindow(this, true);
8442 else if(parent.children.last != this)
8444 parent.children.Move(this, parent.children.last);
8448 style.stayOnTop = true;
8452 if(created && style.stayOnTop)
8454 if(rootWindow == this)
8455 guiApp.interfaceDriver.OrderRootWindow(this, false);
8462 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8463 order && ((Window)order.data).style.stayOnTop;
8464 order = (order == parent.childrenOrder.first) ? null : order.prev);
8465 last = order ? order.data : null;
8469 for(last = parent.children.last;
8470 last && last.style.stayOnTop;
8474 parent.children.Move(this, last);
8478 style.stayOnTop = false;
8481 get { return style.stayOnTop; }
8486 property_category $"Window Style"
8496 if(menuBar && !value)
8503 if(!menuBar && style.hasMenuBar && value)
8507 this, menu = value, isMenuBar = true,
8508 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8509 inactive = true, nonClient = true
8513 UpdateActiveDocument(null);
8516 get { return menu; }
8519 property FontResource font
8521 property_category $"Appearance"
8523 isset { return setFont ? true : false; }
8528 if(value && !setFont) { stopwatching(parent, font); }
8529 else if(!value && setFont)
8535 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8544 RemoveResource(setFont);
8549 RemoveResource(systemFont);
8556 AddResource(setFont);
8559 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8562 systemFont = guiApp.currentSkin.SystemFont();
8564 usedFont = systemFont;
8565 AddResource(systemFont);
8573 get { return usedFont; }
8576 property SizeAnchor sizeAnchor
8578 property_category $"Layout"
8581 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8582 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8583 sizeAnchor.isClientW != sizeAnchor.isClientH;
8590 normalSizeAnchor = sizeAnchor;
8592 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8594 stateAnchor = normalAnchor;
8595 stateSizeAnchor = normalSizeAnchor;
8597 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8598 Position(x,y, w, h, true, true, true, true, false, true);
8605 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8606 sizeAnchor.isClientW,
8607 sizeAnchor.isClientH
8614 property_category $"Layout"
8617 Anchor thisAnchor = anchor;
8618 SizeAnchor thisSizeAnchor = sizeAnchor;
8619 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8620 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8621 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8622 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8623 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8624 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8630 sizeAnchor.isClientW = false;
8631 sizeAnchor.isClientH = false;
8632 sizeAnchor.size = value;
8634 normalSizeAnchor = sizeAnchor;
8636 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8638 stateAnchor = normalAnchor;
8639 stateSizeAnchor = normalSizeAnchor;
8641 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8642 Position(x, y, w, h, true, true, true, true, false, true);
8643 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8646 get { value = size; }
8649 property Size clientSize
8651 property_category $"Layout"
8654 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8655 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8656 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8661 sizeAnchor.isClientW = true;
8662 sizeAnchor.isClientH = true;
8663 sizeAnchor.size = value;
8665 normalSizeAnchor = sizeAnchor;
8667 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8669 stateAnchor = normalAnchor;
8670 stateSizeAnchor = normalSizeAnchor;
8672 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8673 Position(x,y, w, h, true, true, true, true, false, true);
8676 get { value = clientSize; }
8679 property Size initSize { get { value = sizeAnchor.size; } };
8681 property Anchor anchor
8683 property_category $"Layout"
8684 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8690 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8692 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8693 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8695 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8697 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8698 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8702 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8704 anchor.left.distance = 0;
8705 anchor.horz.type = 0;
8707 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8709 anchor.top.distance = 0;
8710 anchor.vert.type = 0;
8719 normalAnchor = anchor;
8721 // Break the anchors for moveable/resizable windows
8722 /*if(style.fixed ) //&& value.left.type == cascade)
8724 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8726 this.anchor = normalAnchor = Anchor { left = x, top = y };
8727 normalSizeAnchor = SizeAnchor { { w, h } };
8730 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8732 stateAnchor = normalAnchor;
8733 stateSizeAnchor = normalSizeAnchor;
8735 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8736 Position(x, y, w, h, true, true, true, true, false, true);
8745 get { value = this ? anchor : Anchor { }; }
8748 property Point position
8750 property_category $"Layout"
8753 if(value == null) return;
8755 anchor.left = value.x;
8756 anchor.top = value.y;
8757 anchor.right.type = none;
8758 anchor.bottom.type = none;
8763 normalAnchor = anchor;
8765 // Break the anchors for moveable/resizable windows
8769 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8771 normalAnchor.left = x;
8772 normalAnchor.top = y;
8773 normalAnchor.right.type = none;
8774 normalAnchor.bottom.type = none;
8775 normalSizeAnchor.size.width = w;
8776 normalSizeAnchor.size.height = h;
8780 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8782 stateAnchor = normalAnchor;
8783 stateSizeAnchor = normalSizeAnchor;
8785 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8786 Position(x,y, w, h, true, true, true, true, false, true);
8790 get { value = position; }
8793 property bool disabled
8795 property_category $"Behavior"
8798 if(this && disabled != value)
8805 get { return (bool)disabled; }
8808 property bool isEnabled
8813 for(parent = this; parent; parent = parent.parent)
8820 property WindowState state
8822 property_category $"Behavior"
8823 set { SetState(value, false, 0); }
8824 get { return this ? state : 0; }
8827 property bool visible
8829 property_category $"Behavior"
8832 if(this && !value && !style.hidden && parent)
8834 bool wasActiveChild = parent.activeChild == this;
8835 Window client = null;
8837 style.hidden = true;
8838 if(style.isActiveClient)
8840 parent.numPositions--;
8841 if(state == minimized) parent.numIcons--;
8846 OldLink prevOrder = null;
8848 if(rootWindow == this)
8849 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8852 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8855 box.left -= parent.clientStart.x;
8856 box.top -= parent.clientStart.y;
8857 box.right -= parent.clientStart.x;
8858 box.bottom -= parent.clientStart.y;
8862 if(_isModal && master && master.modalSlave == this)
8863 master.modalSlave = null;
8867 OldLink tmpPrev = order.prev;
8868 client = tmpPrev ? tmpPrev.data : null;
8869 if(client && !client.style.hidden && !client.destroyed && client.created)
8870 prevOrder = tmpPrev;
8873 client = tmpPrev ? tmpPrev.data : null;
8874 if(client == this) { client = null; break; }
8875 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8877 tmpPrev = client.order.prev;
8882 prevOrder = tmpPrev;
8887 // If this window can be an active client, make sure the next window we activate can also be one
8888 if(!style.nonClient && style.isActiveClient)
8890 tmpPrev = prevOrder;
8893 client = tmpPrev ? tmpPrev.data : null;
8894 if(client == this) { client = null; break; }
8895 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8897 tmpPrev = client.order.prev;
8902 prevOrder = tmpPrev;
8906 if(client && client.style.hidden) client = null;
8910 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8912 if(order && prevOrder && prevOrder.data != this)
8913 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8915 ActivateEx(false, false, false, true, null, null);
8917 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8918 if(parent.activeClient == this)
8920 parent.activeClient = null;
8921 parent.UpdateActiveDocument(null);
8924 else if(parent.activeClient == this)
8926 parent.activeClient = client;
8927 parent.UpdateActiveDocument(this);
8930 // *** Not doing this anymore ***
8933 parent.childrenCycle.Delete(cycle);
8935 parent.childrenOrder.Delete(order);
8940 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8945 else if(this && value && style.hidden)
8947 style.hidden = false;
8950 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8951 if(rootWindow == this)
8952 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8954 if(_isModal && master)
8955 master.modalSlave = this;
8957 if(style.isActiveClient)
8959 positionID = parent.GetPositionID(this);
8960 parent.numPositions++;
8961 if(state == minimized) parent.numIcons++;
8964 // *** NOT DOING THIS ANYMORE ***
8966 if(!(style.inactive))
8968 if(!(style.noCycle))
8970 cycle = parent.childrenCycle.AddAfter(
8971 (parent.activeChild && parent.activeChild.cycle) ?
8972 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8975 order = parent.childrenOrder.AddAfter(
8976 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8983 if(true || !parent.activeChild)
8984 ActivateEx(true, false, true, true, null, null);
8986 if(creationActivation == activate)
8987 ActivateEx(true, false, true, true, null, null);
8988 else if(creationActivation == flash && !object)
8991 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8995 ConsequentialMouseMove(false);
9001 style.hidden = !value;
9004 get { return (style.hidden || !setVisible) ? false : true; }
9007 property bool isDocument
9009 property_category $"Document"
9010 set { style.isDocument = value; }
9011 get { return style.isDocument; }
9014 property bool mergeMenus
9016 property_category $"Window Style"
9017 set { mergeMenus = value; }
9018 get { return (bool)mergeMenus; }
9021 property bool hasHorzScroll
9023 property_category $"Window Style"
9028 if(!style.hasHorzScroll && created)
9030 CreateSystemChildren();
9031 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9034 else if(style.hasHorzScroll)
9038 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9040 style.hasHorzScroll = value;
9043 get { return style.hasHorzScroll; }
9046 property bool hasVertScroll
9048 property_category $"Window Style"
9053 if(!style.hasVertScroll && created)
9055 style.hasVertScroll = true;
9056 CreateSystemChildren();
9057 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9060 else if(style.hasVertScroll)
9064 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9066 style.hasVertScroll = value;
9068 get { return style.hasVertScroll; }
9071 property bool dontHideScroll
9073 property_category $"Behavior"
9076 scrollFlags.dontHide = value;
9079 //UpdateScrollBars(true, true);
9080 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9084 // UpdateScrollBars(true, true);
9085 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9088 get { return scrollFlags.dontHide; }
9091 property bool dontScrollVert
9093 property_category $"Behavior"
9094 set { style.dontScrollVert = value; }
9095 get { return style.dontScrollVert; }
9097 property bool dontScrollHorz
9099 property_category $"Behavior"
9100 set { style.dontScrollHorz = value; }
9101 get { return style.dontScrollHorz; }
9104 property bool snapVertScroll
9106 property_category $"Behavior"
9109 scrollFlags.snapY = value;
9110 if(sbv) sbv.snap = value;
9112 get { return scrollFlags.snapY; }
9114 property bool snapHorzScroll
9116 property_category $"Behavior"
9119 scrollFlags.snapX = value;
9120 if(sbh) sbh.snap = value;
9122 get { return scrollFlags.snapX; }
9125 property Point scroll
9127 property_category $"Behavior"
9128 set { SetScrollPosition(value.x, value.y); }
9129 get { value = scroll; }
9132 property bool modifyVirtualArea
9134 property_category $"Behavior"
9135 set { modifyVirtArea = value; }
9136 get { return (bool)modifyVirtArea; }
9139 property bool dontAutoScrollArea
9141 property_category $"Behavior"
9142 // Activating a child control out of view will automatically scroll to make it in view
9143 set { noAutoScrollArea = value; }
9144 get { return (bool)noAutoScrollArea; }
9147 property char * fileName
9149 property_category $"Document"
9152 if(menu && ((!fileName && value) || (fileName && !value)))
9154 MenuItem item = menu.FindItem(MenuFileSave, 0);
9155 if(item) item.disabled = !modifiedDocument && value;
9160 if(value && value[0])
9161 fileName = CopyString(value);
9163 if(parent && this == parent.activeClient)
9164 parent.UpdateActiveDocument(null);
9168 // if(style.isDocument)
9170 fileMonitor.fileName = value;
9172 get { return fileName; }
9177 property_category $"Data"
9182 property bool modifiedDocument
9184 property_category $"Document"
9187 if(style.isDocument || fileName)
9191 MenuItem item = menu.FindItem(MenuFileSave, 0);
9192 if(item) item.disabled = !value && fileName;
9196 if(modifiedDocument != value)
9198 modifiedDocument = value;
9199 if(style.isDocument || fileName)
9203 get { return (bool)modifiedDocument; }
9206 property bool showInTaskBar
9208 property_category $"Window Style"
9209 set { style.showInTaskBar = value; }
9210 get { return (style.showInTaskBar; }
9212 property FileDialog saveDialog { set { saveDialog = value; } };
9213 property bool isActiveClient
9215 property_category $"Behavior"
9216 set { style.isActiveClient = value; }
9217 get { return style.isActiveClient; }
9220 property Cursor cursor
9222 property_category $"Appearance"
9226 SelectMouseCursor();
9228 get { return cursor; }
9231 //#if !defined(ECERE_VANILLA)
9232 property char * name
9234 property_category $"Design"
9237 return (this && object) ? object.name : null;
9242 activeDesigner.RenameObject(object, value);
9246 property char * displayDriver
9248 property_category $"Behavior"
9251 dispDriver = GetDisplayDriver(value);
9252 //DisplayModeChanged();
9256 return dispDriver ? dispDriver.name : null;
9260 // RUNTIME PROPERTIES
9261 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9262 property Size scrollArea
9264 property_category $"Behavior"
9268 SetScrollArea(value.w, value.h, false);
9270 SetScrollArea(0,0, true);
9272 get { value = scrollArea; }
9275 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9280 property_category $"Layout"
9281 set { if(this) is3D = value; }
9282 get { return (bool)is3D; }
9285 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9287 // Will be merged with font later
9288 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9289 property Point clientStart { get { value = clientStart; } };
9290 property Point absPosition { get { value = absPosition; } };
9291 property Anchor normalAnchor { get {value = normalAnchor; } };
9292 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9293 property bool active { get { return (bool)active; } };
9294 property bool created { get { return (bool)created; } };
9295 property bool destroyed { get { return (bool)destroyed; } };
9296 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9297 property Window firstChild { get { return children.first; } };
9298 property Window lastChild { get { return children.last; } };
9299 property Window activeClient { get { return activeClient; } };
9300 property Window activeChild { get { return activeChild; } };
9301 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9302 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9303 property ScrollBar horzScroll { get { return sbh; } };
9304 property ScrollBar vertScroll { get { return sbv; } };
9305 property StatusBar statusBar { get { return statusBar; } };
9306 property Window rootWindow { get { return rootWindow; } };
9307 property bool closing { get { return (bool)closing; } set { closing = value; } };
9308 property int documentID { get { return documentID; } };
9309 property Window previous { get { return prev; } }
9310 property Window next { get { return next; } }
9311 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9312 property PopupMenu menuBar { get { return menuBar; } }
9313 property ScrollBar sbv { get { return sbv; } }
9314 property ScrollBar sbh { get { return sbh; } }
9315 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9316 property void * systemHandle { get { return windowHandle; } }
9317 property Button minimizeButton { get { return sysButtons[0]; } };
9318 property Button maximizeButton { get { return sysButtons[1]; } };
9319 property Button closeButton { get { return sysButtons[2]; } };
9320 property BitmapResource icon
9322 get { return icon; }
9326 if(icon) incref icon;
9328 guiApp.interfaceDriver.SetIcon(this, value);
9331 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9332 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9333 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9334 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9335 property bool nativeDecorations
9337 get { return (bool)nativeDecorations; }
9338 set { nativeDecorations = value; }
9339 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9342 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9343 bool result = false;
9344 if(nativeDecorations)
9346 if(rootWindow == this)
9350 if(formDesigner && activeDesigner)
9352 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9353 Window form = cd ? cd.form : null;
9354 if(form && parent == form.parent)
9359 return result != style.fixed;
9363 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9365 property char * text
9367 property_category $"Deprecated"
9369 set { property::caption = value; }
9370 get { return property::caption; }
9376 WindowBits style; // Window Style
9377 char * caption; // Name / Caption
9378 Window parent; // Parent window
9379 OldList children; // List of children in Z order
9380 Window activeChild; // Child window having focus
9381 Window activeClient;
9382 Window previousActive; // Child active prior to activating the default child
9383 Window master; // Window owning and receiving notifications concerning this window
9384 OldList slaves; // List of windows belonging to this window
9385 Display display; // Display this window is drawn into
9387 Point position; // Position in parent window client area
9388 Point absPosition; // Absolute position
9389 Point clientStart; // Client area position from (0,0) in this window
9391 Size clientSize; // Client area size
9392 Size scrollArea; // Virtual Scroll area size
9393 Size reqScrollArea; // Requested virtual area size
9394 Point scroll; // Virtual area scrolling position
9395 ScrollBar sbh, sbv; // Scrollbar window handles
9396 Cursor cursor; // Mouse cursor used for this window
9399 StatusBar statusBar;
9400 Button sysButtons[3];
9402 Box clientArea; // Client Area box clipped to parent
9404 HotKeySlot hotKey; // HotKey for this window
9408 ScrollFlags scrollFlags;// Window Scrollbar Flags
9409 int64 id; // Control ID
9411 ColorAlpha background; // Background color used to draw the window area
9413 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9414 OldList childrenCycle; // Cycling order
9415 OldLink cycle; // Element of parent's cycling order
9416 OldList childrenOrder; // Circular Z-Order
9417 OldLink order; // Element of parent's circular Z-Order
9418 Window modalSlave; // Slave window blocking this window's interaction
9420 Window rootWindow; // Topmost system managed window
9421 void * windowHandle; // System window handle
9423 DialogResult returnCode;// Return code for modal windows
9425 Point sbStep; // Scrollbar line scrolling steps
9428 SizeAnchor stateSizeAnchor;
9430 Anchor normalAnchor;
9431 SizeAnchor normalSizeAnchor;
9433 Size skinMinSize; // Minimal window size based on style
9434 Point scrolledPos; // Scrolled position
9435 Box box; // Window box clipped to parent
9436 Box * against; // What to clip the box to
9438 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9439 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9440 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9441 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9442 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9443 Point scrolledArea; // Distance to scroll area by
9444 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9446 OldList hotKeys; // List of the hotkeys of all children
9447 Window defaultControl; // Default child control
9451 ColorAlpha * palette; // Color palette used for this window
9453 int caretSize; // Size of caret, non zero if a caret is present
9454 Point caretPos; // Caret position
9456 void * systemParent; // Parent System Window for embedded windows
9463 WindowState lastState;
9465 FileMonitor fileMonitor
9467 this, FileChange { modified = true };
9469 bool OnFileNotify(FileChange action, char * param)
9472 fileMonitor.StopMonitoring();
9473 if(OnFileModified(action, param))
9474 fileMonitor.StartMonitoring();
9479 FontResource setFont, systemFont;
9480 FontResource usedFont;
9481 FontResource captionFont;
9483 FileDialog saveDialog;
9485 SizeAnchor sizeAnchor;
9487 // FormDesigner data
9490 Extent * tempExtents; //[4];
9491 BitmapResource icon;
9493 CreationActivationOption creationActivation;
9496 bool active:1; // true if window and ancestors are active
9497 bool acquiredInput:1; // true if the window is processing state based input
9498 bool modifiedDocument:1;
9499 bool disabled:1; // true if window cannot interact
9500 bool isForegroundWindow:1;// true while a root window is being activated
9501 bool visible:1; // Visibility flag
9502 bool destroyed:1; // true if window is being destroyed
9503 bool anchored:1; // true if this window is repositioned when the parent resizes
9504 bool dirty:1; // Flag set to true if any descendant must be redrawn
9510 bool modifyVirtArea:1;
9511 bool noAutoScrollArea:1;
9514 bool setVisible:1; // FOR FORM DESIGNER
9520 bool useSharedMemory:1;
9523 bool nativeDecorations:1;
9524 bool manageDisplay:1;
9525 bool formDesigner:1; // True if we this is running in the form editor
9528 // Checks used internally for them not to take effect in FormDesigner
9529 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9530 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9532 WindowController controller;
9533 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9536 public class CommonControl : Window
9538 // creationActivation = doNothing;
9541 public property String toolTip
9543 property_category $"Appearance"
9546 if(created) CommonControl::OnDestroy();
9548 toolTip = value ? ToolTip { tip = value; } : null;
9550 if(created) CommonControl::OnCreate();
9552 get { return toolTip ? toolTip.tip : null; }
9558 // (Very) Ugly work around for the fact that the parent watcher
9559 // won't fire when it's already been disconnected...
9560 eInstance_FireSelfWatchers(toolTip,
9561 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9567 toolTip.parent = this;
9576 public class Percentage : float
9578 char * OnGetString(char * string, float * fieldData, bool * needClass)
9582 sprintf(string, "%.2f", this);
9583 c = strlen(string)-1;
9586 if(string[c] != '0')
9587 last = Max(last, c);
9588 if(string[c] == '.')
9601 public void ApplySkin(Class c, char * name, void ** vTbl)
9603 char className[1024];
9608 subclass(Window) wc = (subclass(Window))c;
9609 subclass(Window) base = (subclass(Window))c.base;
9611 sprintf(className, "%sSkin_%s", name, c.name);
9612 wc.pureVTbl = c._vTbl;
9613 c._vTbl = new void *[c.vTblSize];
9614 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9615 sc = eSystem_FindClass(c.module.application, className);
9619 for(m = 0; m < c.base.vTblSize; m++)
9621 if(c._vTbl[m] == base.pureVTbl[m])
9622 c._vTbl[m] = vTbl[m];
9627 for(m = 0; m < c.vTblSize; m++)
9629 if(sc._vTbl[m] != wc.pureVTbl[m])
9630 c._vTbl[m] = sc._vTbl[m];
9634 for(d = c.derivatives.first; d; d = d.next)
9636 ApplySkin(d.data, name, c._vTbl);
9640 public void UnapplySkin(Class c)
9642 char className[1024];
9644 subclass(Window) wc = (subclass(Window))c;
9645 subclass(Window) base = (subclass(Window))c.base;
9648 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9651 c._vTbl = wc.pureVTbl;
9655 for(d = c.derivatives.first; d; d = d.next)
9657 UnapplySkin(d.data);
9661 void CheckFontIntegrity(Window window)
9666 if(window.usedFont && window.usedFont.font == 0xecececec)
9668 FontResource uf = window.usedFont;
9669 char * className = window._class.name;
9670 char * text = window.text;
9673 for(c = window.firstChild; c; c = c.next)
9674 CheckFontIntegrity(c);
9678 public class ControllableWindow : Window
9680 /*WindowController controller;
9681 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9682 ~ControllableWindow() { delete controller; }*/
9685 class WindowControllerInterface : ControllableWindow
9687 bool OnKeyDown(Key key, unichar ch)
9689 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9691 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9695 bool OnKeyUp(Key key, unichar ch)
9697 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9699 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9703 bool OnKeyHit(Key key, unichar ch)
9705 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9707 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9711 bool OnMouseMove(int x, int y, Modifiers mods)
9713 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9715 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9719 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9721 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9723 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9727 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9729 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9731 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9735 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9737 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9739 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9743 bool OnRightButtonDown(int x, int y, Modifiers mods)
9745 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9747 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9751 bool OnRightButtonUp(int x, int y, Modifiers mods)
9753 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9755 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9759 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9761 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9763 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9767 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9769 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9771 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9775 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9777 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9779 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9783 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9785 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9787 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9791 void OnResize(int width, int height)
9793 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9794 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9797 void OnRedraw(Surface surface)
9799 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9800 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9805 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9807 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9811 bool OnLoadGraphics()
9813 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9815 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9819 void OnUnloadGraphics()
9821 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9822 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9826 public class WindowController<class V>
9829 property Window window
9833 uint size = class(Window).vTblSize;
9836 windowVTbl = new void *[size];
9837 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9838 if(value._vTbl == value._class._vTbl)
9840 value._vTbl = new void *[value._class.vTblSize];
9841 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9845 for(c = 0; c < size; c++)
9847 void * function = class(WindowControllerInterface)._vTbl[c];
9848 if(function != DefaultFunction)
9849 value._vTbl[c] = function;
9851 value._vTbl[c] = windowVTbl[c];
9856 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9859 get { return window; }
9861 property V controlled
9863 set { controlled = value; }
9864 get { return controlled; }
9866 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9867 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9868 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9869 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9870 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9871 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9872 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9873 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9874 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9875 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9876 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9877 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9878 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9879 virtual void V::OnResize(WindowController controller, int width, int height);
9880 virtual void V::OnRedraw(WindowController controller, Surface surface);
9881 virtual bool V::OnCreate(WindowController controller);
9882 virtual bool V::OnLoadGraphics(WindowController controller);
9883 virtual void V::OnUnloadGraphics(WindowController controller);
9886 int (** windowVTbl)();