7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
573 stopwatching(parent, font);
574 if(parent.activeChild == this)
575 parent.activeChild = null;
576 if(parent.activeClient == this)
577 parent.activeClient = null;
582 // Prevent destructor from being called again...
588 /////////////////////////////////
591 OldLink slave = master.slaves.FindLink(this);
592 master.slaves.Delete(slave);
599 parent.childrenCycle.Remove(cycle);
601 parent.childrenOrder.Remove(order);
602 parent.children.Remove(this);
607 /////////////////////////////////
609 while(ptr = resources.first)
612 resources.Delete(ptr);
619 for(child = children.first; child; child = child.next)
621 // child.stopwatching(this, font);
623 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
624 // Don't want property here
625 *&child.parent = null;
628 while(slave = slaves.first)
630 // Don't want property here
631 *&((Window)slave.data).master = null;
632 slaves.Delete(slave);
635 // Because we do a decref in DestroyEx...
643 // Why was this commented?
644 //if(this != guiApp.desktop)
657 if(((subclass(Window))_class).pureVTbl)
659 if(_vTbl == _class._vTbl)
661 _vTbl = ((subclass(Window))_class).pureVTbl;
666 for(m = 0; m < _class.vTblSize; m++)
668 if(_vTbl[m] == _class._vTbl[m])
669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
673 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
676 dirtyArea.Free(null);
677 renderArea.Free(null);
678 overRenderArea.Free(null);
679 clipExtent.Free(null);
680 scrollExtent.Free(null);
681 dirtyBack.Free(null);
685 tempExtents[0].Free(null);
686 tempExtents[1].Free(null);
687 tempExtents[2].Free(null);
688 tempExtents[3].Free(null);
693 //#if !defined(ECERE_VANILLA)
694 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
696 if(this == activeDesigner)
700 char * name = property::name;
701 return name ? name : "";
706 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
707 bool OnGetDataFromString(char * string)
709 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
712 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
713 this = designer.form;
714 else if(!strcmpi(string, "(Desktop)"))
715 this = activeDesigner;
717 return activeDesigner.FindObject(&this, string);
723 // --- Window updates system ---
725 // Setup a bitmap for Redrawing on client area of Window
726 Surface Redraw(Box box)
728 Surface surface = null;
730 Box clientArea = this.clientArea;
734 mox.left -= clientStart.x;
735 mox.top -= clientStart.y;
736 mox.right -= clientStart.x;
737 mox.bottom -= clientStart.y;
739 mox.Clip(clientArea);
740 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
742 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
744 int x = absPosition.x + clientStart.x;
745 int y = absPosition.y + clientStart.y;
746 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
748 x -= rootWindow.clientStart.x;
749 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
751 if(!guiApp.fullScreenMode || is3D)
753 x -= rootWindow.absPosition.x;
754 y -= rootWindow.absPosition.y;
758 x += rootWindow.parent.clientStart.x;
759 y += rootWindow.parent.clientStart.y;
761 mox.left += rootWindow.parent.clientStart.x;
762 mox.top += rootWindow.parent.clientStart.y;
763 mox.right += rootWindow.parent.clientStart.x;
764 mox.bottom += rootWindow.parent.clientStart.y;
769 surface = display.GetSurface(x, y, mox);
772 surface.width = clientSize.w;
773 surface.height = clientSize.h;
779 // Setup a bitmap for Redrawing on full Window
780 Surface RedrawFull(Box box)
782 Surface surface = null;
790 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
792 int x = absPosition.x;
793 int y = absPosition.y;
794 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
796 x -= rootWindow.clientStart.x;
797 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
799 if(!guiApp.fullScreenMode || is3D)
801 x -= rootWindow.absPosition.x;
802 y -= rootWindow.absPosition.y;
805 x += rootWindow.parent.clientStart.x;
806 y += rootWindow.parent.clientStart.y;
808 mox.left += rootWindow.parent.clientStart.x;
809 mox.top += rootWindow.parent.clientStart.y;
810 mox.right += rootWindow.parent.clientStart.x;
811 mox.bottom += rootWindow.parent.clientStart.y;
816 surface = display.GetSurface(x, y, mox);
819 surface.width = size.w;
820 surface.height = size.h;
826 void FigureCaption(char * caption)
828 Window activeClient = null;
832 strcpy(caption, this.caption);
833 if(style.isDocument || fileName)
835 if(caption[0]) strcat(caption, " - ");
837 strcat(caption, fileName);
841 sprintf(title, "Untitled %d", documentID);
842 strcat(caption, title);
845 strcat(caption, " *");
850 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
852 if(activeClient && activeClient.state == maximized)
854 if(activeClient.caption)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, activeClient.caption);
859 if(activeClient.style.isDocument || activeClient.fileName)
861 if(caption[0]) strcat(caption, " - ");
862 strcat(caption, "[");
863 if(activeClient.fileName)
864 strcat(caption, activeClient.fileName);
868 sprintf(title, "Untitled %d", activeClient.documentID);
869 strcat(caption, title);
871 if(activeClient.modifiedDocument)
872 strcat(caption, " *");
873 strcat(caption, "]");
878 // Code for returning dirty from ScrollDisplay:
880 for(d = 0; d<scrollExtent.count; d++)
882 Box * box = &scrollExtent.boxes[d];
888 Min(box.right, box.left-scroll.x),box.bottom
890 dirtyArea.UnionBox(update);
896 Max(box.left, box.right-scroll.x), box.top,
897 box.right, box.bottom
899 dirtyArea.UnionBox(update);
907 box.right, Min(box.bottom, box.top-scroll.y),
909 dirtyArea.UnionBox(update);
915 box.left, Max(box.top, box.bottom-scroll.y),
916 box.right, box.bottom
918 dirtyArea.UnionBox(update);
923 void UpdateDecorations(void)
925 // TODO: *** TEMPORARY HACK ***
932 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
934 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
936 Update({ -clientStart.x,0, -1, clientSize.h-1 });
938 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
941 // Returns w & h for Position
942 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
944 Window parent = this.parent ? this.parent : guiApp.desktop;
945 int vpw = parent ? parent.clientSize.w : 0;
946 int vph = parent ? parent.clientSize.h : 0;
947 int pw = parent ? parent.clientSize.w : 0;
948 int ph = parent ? parent.clientSize.h : 0;
949 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
950 int x = anchor.left.distance, y = anchor.top.distance;
952 MinMaxValue ew = 0, eh = 0;
954 float cascadeW, cascadeH;
956 int tilingW, tilingH, tilingSplit, tilingLastH;
957 int addX = 0, addY = 0;
959 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
961 Window masterWindow = this;
962 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
965 if(master == guiApp.desktop)
966 masterWindow = guiApp.desktop.activeChild;
968 masterWindow = master.rootWindow;
969 if(!masterWindow) masterWindow = this;
971 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
972 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
975 pw = vpw = box.right - box.left + 1;
977 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
980 ph = vph = box.bottom - box.top + 1;
996 vpw = pw = parent.size.w;
997 vph = ph = parent.size.h;
999 else if(!style.fixed /*|| style.isDocument*/)
1001 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1002 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1004 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1007 Desktop3D_FixSize(&pw, &ph);
1008 Desktop3D_FixSize(&vpw, &vph);
1011 if(pw < skinMinSize.w) pw = skinMinSize.w;
1012 if(ph < skinMinSize.h) ph = skinMinSize.h;
1013 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1014 if(vph < skinMinSize.h) vph = skinMinSize.h;
1016 // TODO: Must fix what we're snapping
1019 if(anchor.left.type)
1021 SNAPUP(x, textCellW);
1023 else if(anchor.right.type)
1025 SNAPDOWN(x, textCellW);
1030 SNAPUP(y, textCellH);
1032 else if(anchor.bottom.type)
1034 SNAPDOWN(y, textCellH);
1038 // This is required to get proper initial decoration size using native decorations on Windows
1039 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1040 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1041 GetDecorationsSize(&ew, &eh);
1043 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1045 if(parent.sbv && !parent.sbv.style.hidden)
1046 pw += guiApp.currentSkin.VerticalSBW();
1047 if(parent.sbh && !parent.sbh.style.hidden)
1048 ph += guiApp.currentSkin.HorizontalSBH();
1050 if(anchor.left.type == cascade)
1052 w = (int)(pw * 0.80);
1053 h = (int)(ph * 0.80);
1055 else if(anchor.left.type >= vTiled)
1060 numTiling = parent.numPositions - parent.numIcons;
1061 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1062 if(anchor.left.type == vTiled)
1064 tilingH = (int)sqrt(numTiling);
1065 tilingW = numTiling / tilingH;
1069 tilingW = (int)sqrt(numTiling);
1070 tilingH = numTiling / tilingW;
1073 leftOver = numTiling - tilingH * tilingW;
1076 tilingSplit = (tilingW - leftOver) * tilingH;
1077 tilingLastH = tilingH+1;
1080 tilingSplit = numTiling;
1082 if(positionID >= tilingSplit)
1084 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1085 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1086 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1087 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1091 x = pw * (positionID / tilingH) / tilingW;
1092 y = ph * (positionID % tilingH) / tilingH;
1093 x2 = pw * (positionID / tilingH + 1) / tilingW;
1094 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1098 SNAPDOWN(x, textCellW);
1099 SNAPDOWN(y, textCellH);
1100 SNAPDOWN(x2, textCellW);
1101 SNAPDOWN(y2, textCellH);
1109 if(sizeAnchor.isClientW) w += ew;
1110 if(sizeAnchor.isClientH) h += eh;
1112 if(anchor.left.type == offset)
1113 x = anchor.left.distance;
1114 else if(anchor.left.type == relative)
1115 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1116 else if(anchor.right.type == relative)
1117 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1118 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1119 else if(anchor.right.type == offset)
1120 ex = vpw - anchor.right.distance;
1122 if(anchor.top.type == offset)
1123 y = anchor.top.distance;
1124 else if(anchor.top.type == relative)
1125 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1126 else if(anchor.bottom.type == relative)
1127 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1128 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1129 else if(anchor.bottom.type == offset)
1130 ey = vph - anchor.bottom.distance;
1132 if(anchor.left.type && anchor.right.type)
1134 switch(anchor.right.type)
1137 ex = pw * (1.0f-anchor.right.percent);
1138 w = Max((int)(ex + 0.5) - x, 0);
1141 ex = vpw - anchor.right.distance;
1142 w = Max((int)(ex + 0.5) - x, 0);
1146 if(anchor.top.type && anchor.bottom.type)
1148 switch(anchor.bottom.type)
1151 ey = ph * (1.0f-anchor.bottom.percent);
1152 h = Max((int)(ey + 0.5) - y, 0);
1155 ey = vph - anchor.bottom.distance;
1156 h = Max((int)(ey + 0.5) - y, 0);
1165 if(state == normal /*|| state == Hidden*/)
1167 bool addSbV = false, addSbH = false;
1169 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1170 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1172 w = Max(w, minSize.w);
1173 h = Max(h, minSize.h);
1174 w = Min(w, maxSize.w);
1175 h = Min(h, maxSize.h);
1177 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1179 if(w) w -= guiApp.currentSkin.VerticalSBW();
1182 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1184 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1188 if(!OnResizing(&w, &h))
1194 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1195 w += guiApp.currentSkin.VerticalSBW();
1196 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1197 h += guiApp.currentSkin.HorizontalSBH();
1199 w = Max(w, skinMinSize.w);
1200 h = Max(h, skinMinSize.h);
1213 SNAPDOWN(w, textCellW);
1214 SNAPDOWN(h, textCellH);
1217 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1219 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1222 (pw - w) / CASCADE_SPACE,
1223 (ph - h) / CASCADE_SPACE);
1229 cascW = (pw - w) / (numCascade-1);
1230 cascH = (ph - h) / (numCascade-1);
1231 SNAPDOWN(cascW, textCellW);
1232 SNAPDOWN(cascH, textCellH);
1233 cascadeW = (float)cascW;
1234 cascadeH = (float)cascH;
1238 numCascade = Max(numCascade, 2);
1239 cascadeW = (float)(pw - w) / (numCascade-1);
1240 cascadeH = (float)(ph - h) / (numCascade-1);
1243 x = (int)((positionID % numCascade) * cascadeW);
1244 y = (int)((positionID % numCascade) * cascadeH);
1246 else if(anchor.left.type < vTiled)
1248 if(!anchor.left.type || anchor.horz.type == middleRelative)
1250 if(!anchor.right.type)
1252 if(anchor.horz.type == middleRelative)
1253 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1255 x = vpw / 2 + anchor.horz.distance - w / 2;
1261 // case A_EDGE: x = x - w; break;
1263 if(!anchor.top.type || anchor.vert.type == middleRelative)
1265 if(!anchor.bottom.type)
1267 if(anchor.vert.type == middleRelative)
1268 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1270 y = vph / 2 + anchor.vert.distance - h / 2;
1276 // case A_EDGE: y = y - h; break;
1279 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1287 SNAPDOWN(x, textCellW);
1288 SNAPDOWN(y, textCellH);
1300 if(anchored && style.fixed && style.isActiveClient)
1305 void UpdateCaret(bool forceUpdate, bool erase)
1307 static Window lastWindow = null;
1308 static int caretX, caretY, caretSize;
1310 if(guiApp && guiApp.caretOwner == this)
1312 int x = caretPos.x - scroll.x;
1313 int y = caretPos.y - scroll.y;
1315 if((erase || this.caretSize) &&
1316 x >= clientArea.left && x <= clientArea.right &&
1317 y >= clientArea.top && y <= clientArea.bottom)
1321 guiApp.interfaceDriver.SetCaret(
1322 x + absPosition.x + clientStart.x,
1323 y + absPosition.y + clientStart.y, this.caretSize);
1324 guiApp.caretEnabled = true;
1326 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1330 if(lastWindow != this)
1332 updateBox.left = x + 1;
1334 updateBox.right = x + 2;
1335 updateBox.bottom = y + this.caretSize - 1;
1339 updateBox.left = Min(x + 1, caretX + 1);
1340 updateBox.top = Min(y, caretY);
1341 updateBox.right = Max(x + 2, caretX + 2);
1342 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1345 guiApp.caretOwner.Update(updateBox);
1352 caretSize = this.caretSize;
1358 guiApp.interfaceDriver.SetCaret(0,0,0);
1359 guiApp.caretEnabled = false;
1365 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1370 scrolledPos.x = position.x = x;
1371 scrolledPos.y = position.y = y;
1373 clientSize.w = size.w = w;
1374 clientSize.h = size.h = h;
1376 if(parent && !style.nonClient)
1378 //if(!style.fixed || style.isDocument)
1380 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1381 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1385 clientStart.x = clientStart.y = 0;
1387 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1389 //if(!activeClient || activeClient.state != maximized)
1390 if(!noAutoScrollArea)
1392 // Check if scroll area must be modified
1393 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1395 bool foundChild = false;
1397 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1398 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1399 for(child = children.first; child; child = child.next)
1401 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1402 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1404 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1405 w = Max(w, child.position.x + child.size.w);
1406 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1407 w = Max(w, Max(child.position.x, 0) + child.size.w);
1408 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1409 h = Max(h, child.position.y + child.size.h);
1410 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1411 h = Max(h, Max(child.position.y, 0) + child.size.h);
1416 if(foundChild && (w > cw || h > ch))
1418 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1420 int stepX = sbStep.x, stepY = sbStep.y;
1421 // Needed to make snapped down position match the skin's check of client area
1422 // against realvirtual
1425 SNAPDOWN(stepX, textCellW);
1426 SNAPDOWN(stepY, textCellH);
1427 stepX = Max(stepX, textCellW);
1428 stepY = Max(stepY, textCellH);
1430 if(scrollFlags.snapX)
1432 if(scrollFlags.snapY)
1435 reqScrollArea.w = w;
1436 reqScrollArea.h = h;
1439 else if(reqScrollArea.w || reqScrollArea.h)
1441 reqScrollArea.w = 0;
1442 reqScrollArea.h = 0;
1443 SetScrollPosition(0,0);
1448 // Automatic MDI Client Scrolling Area Adjustment
1449 if(parent && !parent.noAutoScrollArea)
1451 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1452 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1454 Window parent = this.parent;
1455 int w = parent.reqScrollArea.w;
1456 int h = parent.reqScrollArea.h;
1458 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1459 w = Max(w, position.x + size.w);
1460 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1461 w = Max(w, Max(position.x, 0) + size.w);
1462 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1463 h = Max(h, position.y + size.h);
1464 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1465 h = Max(h, Max(position.y, 0) + size.h);
1467 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1468 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1470 /*bool resize = false;
1471 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1472 // Needed to make snapped down position match the skin's check of client area
1473 // against realvirtual
1476 SNAPDOWN(stepX, textCellW);
1477 SNAPDOWN(stepY, textCellH);
1478 stepX = Max(stepX, textCellW);
1479 stepY = Max(stepY, textCellH);
1481 if(parent.scrollFlags.snapX)
1483 if(parent.scrollFlags.snapY)
1485 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1487 parent.reqScrollArea.w = w;
1488 parent.reqScrollArea.h = h;*/
1490 // parent.UpdateScrollBars(true, true);
1491 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1492 false, true, true, true, false, false);
1497 GetRidOfVirtualArea();
1501 UpdateScrollBars(modifyThisArea, false);
1502 else if(guiApp.currentSkin)
1505 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1507 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1508 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1509 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1510 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1513 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1514 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1516 absPosition = scrolledPos;
1517 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1518 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1520 if(this != guiApp.desktop && parent)
1522 absPosition.x += parent.absPosition.x;
1523 absPosition.y += parent.absPosition.y;
1524 if(!style.nonClient && this != guiApp.desktop)
1526 absPosition.x += parent.clientStart.x;
1527 absPosition.y += parent.clientStart.y;
1531 box = Box { 0, 0, size.w - 1, size.h - 1 };
1536 // Clip against parent's client area
1537 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1539 // Compute client area in this window coordinate system
1540 clientArea.left = 0;
1542 clientArea.right = clientSize.w - 1;
1543 clientArea.bottom = clientSize.h - 1;
1545 // Clip against parent's client area
1547 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1551 //absPosition.x -= parent.clientStart.x;
1552 //absPosition.y -= parent.clientStart.y;
1555 // Adjust all children
1556 for(child = children.first; child; child = child.next)
1557 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1559 UpdateCaret(false, false);
1562 void GetRidOfVirtualArea(void)
1564 if(parent && !parent.destroyed && style.fixed &&
1565 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1566 parent.reqScrollArea.w && parent.reqScrollArea.h)
1568 if(!parent.noAutoScrollArea)
1572 for(child = children.first; child; child = child.next)
1574 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1576 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1577 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1586 Window parent = this.parent;
1588 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1589 false, true, true, true, false, false);
1591 parent.SetScrollArea(0,0,true);
1592 parent.SetScrollPosition(0,0);
1598 public void ExternalPosition(int x, int y, int w, int h)
1600 Position(x, y, w, h, false, true, true, true, false, false);
1603 // (w, h): Full window size
1604 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1606 bool result = false;
1607 int oldCW = clientSize.w, oldCH = clientSize.h;
1608 bool clientResized, windowResized, windowMoved;
1610 bool realResized = size.w != w || size.h != h;
1612 // TOCHECK: This wasn't in ecere.dll
1613 //if(!parent) return true;
1614 if(destroyed) return false;
1616 windowMoved = position.x != x || position.y != y || force;
1618 // windowResized = realResized || force;
1619 windowResized = size.w != w || size.h != h || force;
1621 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1627 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1628 scrolledPos.x - parent.clientStart.x + this.box.right,
1629 scrolledPos.y - parent.clientStart.y + this.box.bottom
1635 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1640 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1642 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1643 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1644 windowResized = true;
1646 if(display && rootWindow != this)
1649 if(guiApp && guiApp.windowMoving)
1651 if(guiApp.windowMoving.style.nonClient)
1652 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1654 guiApp.windowMoving.parent.SetMouseRangeToClient();
1664 // Buttons bitmap resources crash if we do this while switching mode
1665 if(!guiApp || !guiApp.modeSwitching)
1668 // Process Anchored Children
1672 for(child = children.first; child; child = child.next)
1675 ((child.stateAnchor.left.type != offset ||
1676 child.stateAnchor.top.type != offset ||
1677 child.stateAnchor.right.type != none ||
1678 child.stateAnchor.bottom.type != none) ||
1679 child.state == maximized || child.state == minimized))
1681 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1683 // child.Position(x, y, w, h, false, true, true, true, false);
1684 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1685 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1691 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1692 //if(updateScrollBars)
1694 OnResize(clientSize.w, clientSize.h);
1696 if((clientResized || windowMoved) && created)
1697 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1699 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1701 Window master = guiApp.interimWindow.master;
1702 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1705 if(rootWindow == this && !is3D)
1709 x -= guiApp.desktop.absPosition.x;
1710 y -= guiApp.desktop.absPosition.y;
1712 //guiApp.Log("Position %s\n", caption);
1715 if(windowResized || windowMoved)
1716 if(display && !display.flags.memBackBuffer && changeRootWindow)
1717 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1719 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1720 for(child = parent.children.first; child && child != this; child = child.next)
1721 if(child.rootWindow)
1722 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1727 if(windowMoved || windowResized)
1729 display.Lock(true /*false*/);
1732 display.Position(absPosition.x, absPosition.y);
1733 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1736 // result = realResized ? display.Resize(size.w, size.h) : true;
1737 if(nativeDecorations && rootWindow.windowHandle)
1739 int w = clientSize.w, h = clientSize.h;
1740 if(hasMenuBar) h += skinMenuHeight;
1741 if(hasStatusBar) h += statusBarHeight;
1742 if(sbv && sbv.visible) w += sbv.size.w;
1743 if(sbh && sbh.visible) h += sbh.size.h;
1744 result = manageDisplay ? display.Resize(w, h) : true;
1747 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1751 else if(clientResized)
1753 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1756 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1760 if(windowMoved || windowResized)
1765 if(guiApp.driver && changeRootWindow && windowHandle)
1767 if(windowResized || windowMoved)
1768 if(!display || display.flags.memBackBuffer)
1769 guiApp.interfaceDriver.PositionRootWindow(this,
1770 x, y, w, h, windowMoved, windowResized);
1771 guiApp.interfaceDriver.UpdateRootWindow(this);
1773 for(child = children.first; child; child = child.next)
1775 if(child.is3D && child.created)
1777 // Copy Display Content
1778 child.display.displaySystem = display.displaySystem;
1779 child.display.window = display.window;
1780 child.display.current = display.current;
1781 child.display.width = display.width;
1782 child.display.height = display.height;
1783 child.display.driverData = display.driverData;
1784 child.display.mutex = null;
1795 void UpdateScrollBars(bool flag, bool fullThing)
1798 bool resizeH = false, resizeV = false;
1799 bool scrolled = false;
1800 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1801 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1803 if(destroyed) return;
1804 if(guiApp.currentSkin)
1806 MinMaxValue cw = 0, ch = 0;
1807 bool sbvVisible, sbhVisible;
1809 int positionH, positionV;
1811 // First get client area with no respect to scroll bars
1816 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1818 if(scrollFlags.dontHide)
1821 cw -= guiApp.currentSkin.VerticalSBW();
1823 ch -= guiApp.currentSkin.HorizontalSBH();
1825 // Update the scrollbar visibility
1831 sbh.disabled = rangeH <= 1;
1832 if(sbh.style.hidden)
1842 sbv.disabled = rangeV <= 1;
1843 if(sbv.style.hidden)
1851 int oldHRange = sbh ? sbh.range : 0;
1852 int oldVRange = sbv ? sbv.range : 0;
1853 // Then start off with horizontal scrollbar range
1856 positionH = sbh.thumbPosition;
1863 SBSetTotal(sbh, rvw);
1866 ch -= guiApp.currentSkin.HorizontalSBH();
1869 // Do the same for vertical scrollbar
1872 positionV = sbv.thumbPosition;
1878 SBSetTotal(sbv, rvh);
1882 cw -= guiApp.currentSkin.VerticalSBW();
1883 // Maybe we need to set the range on the horizontal scrollbar again
1891 SBSetTotal(sbh, rvw);
1892 //sbh.Action(setRange, positionH, 0);
1893 if(rangeH <= 1 && sbh.range > 1)
1895 ch -= guiApp.currentSkin.HorizontalSBH();
1901 SBSetTotal(sbv, rvh);
1903 //sbv.Action(setRange, positionV, 0);
1908 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1909 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1912 // Update the scrollbar visibility
1913 if(!scrollFlags.dontHide)
1915 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1919 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1926 if(guiApp.currentSkin)
1933 sbhVisible = sbh.style.hidden ? true : false;
1935 sbvVisible = sbv.style.hidden ? true : false;
1937 // Do our resize here
1938 if(flag && (resizeH || resizeV) && fullThing)
1940 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1945 OnResize(clientSize.w, clientSize.h);
1951 sbh.visible = sbhVisible;
1953 sbv.visible = sbvVisible;
1955 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1956 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1959 sbh.pageStep = clientSize.w;
1961 sbv.pageStep = clientSize.h;
1963 // Notify doesn't handle setRange anymore... process it here
1966 int positionH = sbh.thumbPosition;
1967 if(scroll.x != positionH)
1969 OnHScroll(setRange, positionH, 0);
1973 SNAPDOWN(positionH, textCellW);
1974 scroll.x = positionH;
1980 int seen = clientSize.w, total = reqScrollArea.w;
1983 if(scrollFlags.snapX)
1984 SNAPDOWN(seen, sbStep.x);
1986 if(!total) total = seen;
1987 range = total - seen + 1;
1989 range = Max(range, 1);
1991 if(x >= range) x = range - 1;
1993 if(scrollFlags.snapX)
1994 SNAPUP(x, sbStep.x);
1998 OnHScroll(setRange, x, 0);
2003 SNAPDOWN(x, textCellW);
2009 int positionV = sbv.thumbPosition;
2010 if(scroll.y != positionV)
2012 OnVScroll(setRange, positionV, 0);
2016 SNAPDOWN(positionV, textCellH);
2017 scroll.y = positionV;
2023 int seen = clientSize.h, total = reqScrollArea.h;
2026 if(scrollFlags.snapY)
2027 SNAPDOWN(seen, sbStep.y);
2029 if(!total) total = seen;
2030 range = total - seen + 1;
2031 range = Max(range, 1);
2033 if(y >= range) y = range - 1;
2035 if(scrollFlags.snapY)
2036 SNAPUP(y, sbStep.y);
2040 OnVScroll(setRange, y, 0);
2045 SNAPDOWN(y, textCellH);
2051 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2054 for(child = children.first; child; child = child.next)
2056 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2059 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2060 child.Position(x, y, w, h, false, true, false, true, false, false);
2067 // Process Scrollbars
2069 if(sbh) // && !sbh.style.hidden
2072 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2073 // Need to set the range again (should improve...) since the scrollbars didn't have
2074 // the right size when UpdateScrollArea set the range on it
2077 sbh.seen = clientSize.w;
2081 if(sbv) // && !sbv.state.hidden
2084 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2085 // Need to set the range again (should improve...) since the scrollbars didn't have
2086 // the right size when UpdateScrollArea set the range on it
2089 sbv.seen = clientSize.h;
2094 // TESTING THIS LOWER
2095 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2098 for(child = children.first; child; child = child.next)
2100 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2103 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2104 child.Position(x, y, w, h, false, true, false, true, false, false);
2110 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2112 SetState(maximized, false, mods);
2116 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2118 SetState(normal, false, mods);
2122 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2124 SetState(minimized, false, mods);
2125 parent.CycleChildren(false, true, false, true);
2129 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2132 // Scroll bar notifications
2133 if(action != setRange)
2135 bool changed = false;
2139 if(scroll.x != position)
2141 OnHScroll(action, position, keyFlags);
2146 SNAPDOWN(position, textCellW);
2148 scroll.x = position;
2152 if(scroll.y != position)
2154 OnVScroll(action, position, keyFlags);
2159 SNAPDOWN(position, textCellH);
2161 scroll.y = position;
2165 bool childMove = false;
2166 for(child = children.first; child; child = child.next)
2168 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2171 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2172 child.Position(x, y, w, h, false, true, false, true, false, false);
2176 // Testing this patch out to solve MDI workspace redraw bugs
2177 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2178 // Scroll offsets to blame?
2182 UpdateCaret(false, false);
2186 // Testing this patch out to solve MDI workspace redraw bugs
2187 for(child = children.first; child; child = child.next)
2189 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2198 Window GetParentMenuBar()
2200 Window menuBarParent;
2201 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2203 if(menuBarParent.menuBar) return menuBarParent.menuBar;
2204 if(menuBarParent && !menuBarParent.isActiveClient)
2210 void CreateSystemChildren(void)
2212 Window parent = this;
2213 bool scrollBarChanged = false;
2214 bool hasClose = false, hasMaxMin = false;
2215 Point scroll = this.scroll;
2217 if(state == maximized)
2218 parent = GetParentMenuBar();
2222 if(style.hasClose) hasClose = true;
2223 if(style.hasMaximize || style.hasMinimize)
2230 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2232 sysButtons[2].Destroy(0);
2233 sysButtons[2] = null;
2235 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2237 sysButtons[1].Destroy(0);
2238 sysButtons[1] = null;
2240 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2242 sysButtons[0].Destroy(0);
2243 sysButtons[0] = null;
2246 if(hasClose && parent)
2253 parent, master = this,
2254 inactive = true, nonClient = true, visible = false;
2256 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2262 if(this.parent == guiApp.desktop)
2263 sysButtons[2].hotKey = altF4;
2264 else if(style.isActiveClient)
2265 sysButtons[2].hotKey = ctrlF4;
2266 sysButtons[2].Create();
2269 sysButtons[2].symbol = 'X';
2270 sysButtons[2].disabled = !style.hasClose;
2273 if(hasMaxMin && parent)
2277 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2278 if(state == maximized)
2281 method = RestoreButtonClicked;
2287 method = MaximizeButtonClicked;
2295 parent, master = this,
2296 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2298 sysButtons[1].Create();
2300 sysButtons[1].NotifyClicked = method;
2302 sysButtons[1].symbol = symbol;
2303 sysButtons[1].disabled = !style.hasMaximize;
2306 if(hasMaxMin && parent)
2310 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2311 if (state == minimized)
2314 method = RestoreButtonClicked;
2320 method = MinimizeButtonClicked;
2328 parent, master = this,
2329 hotKey = altM, inactive = true, nonClient = true, visible = false
2331 sysButtons[0].Create();
2333 sysButtons[0].NotifyClicked = method;
2335 sysButtons[0].symbol = symbol;
2336 sysButtons[0].disabled = !style.hasMinimize;
2339 // Create the scrollbars
2340 if(style.hasHorzScroll && !sbh)
2346 direction = horizontal,
2350 snap = scrollFlags.snapX,
2351 NotifyScrolling = ScrollBarNotification
2354 scrollBarChanged = true;
2356 else if(sbh && !style.hasHorzScroll)
2362 if(style.hasVertScroll && !sbv)
2368 direction = vertical,
2372 snap = scrollFlags.snapY,
2373 NotifyScrolling = ScrollBarNotification
2376 scrollBarChanged = true;
2378 else if(sbv && !style.hasVertScroll)
2383 if(scrollBarChanged)
2385 SetScrollLineStep(sbStep.x, sbStep.y);
2386 UpdateScrollBars(true, true);
2390 if(scrollBarChanged)
2392 if(sbh) sbh.thumbPosition = scroll.x;
2393 if(sbv) sbv.thumbPosition = scroll.y;
2397 void UpdateCaption(void)
2399 if(rootWindow == this)
2402 FigureCaption(caption);
2403 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2405 UpdateDecorations();
2408 if(parent.activeClient == this) // Added this last check
2410 if(parent.rootWindow == parent)
2413 parent.FigureCaption(caption);
2414 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2417 parent.UpdateCaption();
2419 parent.UpdateDecorations();
2423 void UpdateActiveDocument(Window previous)
2425 Window activeClient = this.activeClient;
2426 Window activeChild = this.activeChild;
2433 activeClient.CreateSystemChildren();
2435 previous.CreateSystemChildren();
2447 // Build window list
2450 Menu windowMenu = menu.FindMenu("Window");
2455 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2458 Window document = cycle.data;
2459 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2461 char name[2048], caption[2048];
2462 document.FigureCaption(caption);
2463 sprintf(name, "%d %s", id+1, caption);
2464 windowMenu.AddDynamic(MenuItem
2466 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2467 NotifySelect = MenuWindowSelectWindow
2471 if(activeClient.cycle == cycle) break;
2476 if((!previous && activeClient) || !activeClient)
2482 item = menu.FindItem(MenuWindowCloseAll, 0);
2483 if(item) item.disabled = false;
2484 item = menu.FindItem(MenuWindowNext, 0);
2485 if(item) item.disabled = false;
2486 item = menu.FindItem(MenuWindowPrevious, 0);
2487 if(item) item.disabled = false;
2488 item = menu.FindItem(MenuWindowCascade, 0);
2489 if(item) item.disabled = false;
2490 item = menu.FindItem(MenuWindowTileHorz, 0);
2491 if(item) item.disabled = false;
2492 item = menu.FindItem(MenuWindowTileVert, 0);
2493 if(item) item.disabled = false;
2494 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2495 if(item) item.disabled = false;
2496 item = menu.FindItem(MenuWindowWindows, 0);
2497 if(item) item.disabled = false;
2500 item = menu.FindItem(MenuFileClose, 0);
2501 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2502 item = menu.FindItem(MenuFileSaveAll, 0);
2503 if(item) item.disabled = numDocuments < 1;
2505 if(activeClient && activeClient.menu && activeClient.state != minimized)
2509 //activeClient.menu.Clean(activeClient);
2510 menu.Merge(activeClient.menu, true, activeClient);
2514 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2517 menu.Merge(activeChild.menu, true, activeChild);
2520 // This is called again for a child window change, with same active client
2521 OnActivateClient(activeClient, previous);
2522 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2523 parent.UpdateActiveDocument(null);
2526 void _ShowDecorations(Box box, bool post)
2528 if(rootWindow == this && nativeDecorations) return;
2529 if(visible && this != guiApp.desktop)
2531 Surface surface = RedrawFull(box);
2535 FigureCaption(caption);
2538 ShowDecorations(captionFont.font,
2541 active, //parent.activeClient == this
2542 guiApp.windowMoving == this);
2544 PreShowDecorations(captionFont.font,
2547 active, //parent.activeClient == this
2548 guiApp.windowMoving == this);
2555 void UpdateExtent(Box refresh)
2557 Surface surface = null;
2559 if(!manageDisplay) { OnRedraw(null);return; }
2560 _ShowDecorations(refresh, false);
2562 surface = Redraw(refresh);
2563 // Opaque background: just fill before EW_REDRAW (clear?)
2566 surface.SetBackground(background);
2567 surface.SetForeground(foreground);
2568 surface.DrawingChar(' ');
2569 if(this == rootWindow)
2571 if(style.drawBehind || background.a)
2573 int a = background.a;
2574 // Premultiply alpha for clear color
2575 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2576 surface.Clear(colorBuffer);
2577 surface.SetBackground(background);
2580 else if(background.a)
2584 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2585 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2588 if(display.flags.alpha && background.a < 255 && background)
2590 surface.Area(0,0,clientSize.w, clientSize.h);
2591 /*if(style.clearDepthBuffer)
2592 surface.Clear(depthBuffer);*/
2594 else if(/*style.clearDepthBuffer || */background.a)
2596 int a = background.a;
2597 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2598 // Premultiply alpha for clear color
2599 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2600 surface.Clear(colorBuffer);
2601 surface.SetBackground(background);
2606 surface.TextFont(usedFont.font);
2607 surface.TextOpacity(false);
2611 // Draw the caret ...
2612 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2614 // surface.SetBackground(0xFFFFFF - background.color);
2615 surface.SetBackground(~background.color);
2617 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2618 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2624 void DrawOverChildren(Box refresh)
2626 Surface surface = Redraw(refresh);
2630 surface.DrawingChar(' ');
2631 surface.SetBackground(background);
2632 surface.SetForeground(foreground);
2634 surface.TextFont(usedFont.font);
2635 surface.TextOpacity(false);
2637 OnDrawOverChildren(surface);
2642 _ShowDecorations(refresh, true);
2645 void ComputeClipExtents(void)
2648 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2650 clipExtent.Copy(this.clipExtent);
2652 for(child = children.last; child; child = child.prev)
2654 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2656 bool opaque = child.IsOpaque(); // TODO: acess background directly
2657 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2659 child.clipExtent.Copy(clipExtent);
2660 child.clipExtent.Offset(-dx, -dy);
2661 child.clipExtent.IntersectBox(child.box);
2663 child.ComputeClipExtents();
2665 if(opaque && !child.style.nonClient)
2667 // Adjust the box for the parent:
2668 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2669 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2674 // ??? Only do this for overlapped window or if parent has with clip children flag
2676 // Do this if window has clip children flag on (default false?)
2677 // this.clipExtent = clipExtent;
2679 clipExtent.Free(null);
2682 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2684 bool opaque = IsOpaque();
2686 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2687 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2689 offsetX -= rootWindow.clientStart.x;
2690 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2694 for(child = children.last; child; child = child.prev)
2696 ColorAlpha background = *(ColorAlpha *)&child.background;
2697 bool opaque = child.IsOpaque();
2698 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2702 // Adjust renderArea to the root window level
2703 Extent * renderArea = &rootWindow.tempExtents[1];
2705 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2706 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2708 offsetX -= child.rootWindow.clientStart.x;
2709 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2713 Extent childRenderArea;
2715 if(backBufferUpdate != null)
2717 childRenderArea.Copy(backBufferUpdate);
2718 childRenderArea.Offset(-offsetX, -offsetY);
2721 childRenderArea.Copy(child.dirtyArea);
2723 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2724 renderArea.Copy(dirtyExtent);
2725 renderArea.Offset(-offsetX, -offsetY);
2726 childRenderArea.Union(renderArea);
2729 // Intersect with the clip extent
2730 childRenderArea.Intersection(child.clipExtent);
2733 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2734 renderArea->Offset(offsetX, offsetY);
2735 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2736 // overDirtyExtent.Union(renderArea);
2737 renderArea->Empty();
2738 // childRenderArea.Free();
2740 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2745 for(child = children.last; child; child = child.prev)
2747 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2749 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2754 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2756 bool opaque = IsOpaque();
2757 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2759 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2760 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2762 offsetX -= rootWindow.clientStart.x;
2763 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2767 for(child = children.last; child; child = child.prev)
2769 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2771 ColorAlpha background = *(ColorAlpha *)&child.background;
2772 bool opaque = child.IsOpaque();
2773 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2777 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2778 // Adjust renderArea to the root window level
2780 renderArea.Copy(child.dirtyArea);
2781 renderArea.Offset(offsetX, offsetY);
2782 dirtyExtent.Union(renderArea);
2783 overDirtyExtent.Union(renderArea);
2789 for(child = children.last; child; child = child.prev)
2791 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2793 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2797 if(backBufferUpdate != null)
2799 renderArea.Copy(backBufferUpdate);
2800 renderArea.Offset(-offsetX, -offsetY);
2802 overRenderArea.Copy(backBufferUpdate);
2803 overRenderArea.Offset(-offsetX, -offsetY);
2809 renderArea.Copy(dirtyArea);
2811 overRenderArea.Copy(dirtyArea);
2814 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2815 dirtyExtentWindow->Copy(dirtyExtent);
2816 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2817 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2818 dirtyExtentWindow->Empty();
2820 // Intersect with the clip extent
2821 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2824 if(renderArea.count > 10)
2827 printf("\nToo many extents (%d):\n", renderArea.count);
2829 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2830 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2835 for(c = 0; c<10; c++)
2838 FASTLIST_LOOP(renderArea, extentBox)
2840 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2842 renderArea.Copy(extent);
2844 FASTLIST_LOOP(renderArea, extentBox)
2847 printf("(%d, %d) - (%d, %d)\n",
2848 extentBox.box.left, extentBox.box.top,
2849 extentBox.box.right, extentBox.box.bottom);
2853 printf("\nNow %d\n", renderArea.count);
2859 // WHY WAS THIS COMMENTED ??
2861 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2862 dirtyExtentWindow->Copy(overDirtyExtent);
2863 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2864 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2865 dirtyExtentWindow->Empty();
2867 // Intersect with the clip extent
2868 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2874 if(scrollExtent.count)
2876 // Subtract render extent from scrolling extent
2877 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2879 if(backBufferUpdate == null)
2881 Extent * dirty = &rootWindow.tempExtents[3];
2884 // Intersect scrolling extent with clip extent
2885 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2887 // offset this scroll to be at the root window level
2888 scrollExtent.Offset(offsetX, offsetY);
2889 // Add area that was scrolled to the dirty extents of the back buffer
2890 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2894 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2895 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2896 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2901 scrollExtent.Empty();
2903 // Add the exposed extent to the window render area
2904 dirty->Offset(-offsetX, -offsetY);
2905 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2910 // Subtract the window's box from the transparency forced extent
2911 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2917 renderArea.Copy(this.renderArea);
2918 renderArea.Offset(offsetX, offsetY);
2919 dirtyExtent.Union(renderArea);
2925 Extent renderArea { };
2927 renderArea.Copy(overRenderArea);
2928 renderArea.Offset(offsetX, offsetY);
2929 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2934 if(backBufferUpdate != null)
2936 // Remove render area from dirty area
2937 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2939 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2946 // Remove the window render area from the dirty extents of the back buffer
2947 rootWindow.dirtyBack.Exclusion(renderArea);
2951 void Render(Extent updateExtent)
2955 Window rootWindow = this.rootWindow;
2956 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2957 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2959 offsetX -= rootWindow.clientStart.x;
2960 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2963 if(rootWindow.fullRender)
2972 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2973 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2978 /*if(renderArea.count)
2979 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2982 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2984 Box box = extentBox.box;
2987 /*printf("(%d, %d) - (%d, %d)\n",
2988 extentBox.box.left, extentBox.box.top,
2989 extentBox.box.right, extentBox.box.bottom);*/
2994 box.left += offsetX;
2996 box.right += offsetX;
2997 box.bottom += offsetY;
2999 if(updateExtent != null)
3000 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3004 for(child = children.first; child; child = child.next)
3005 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3006 child.Render(updateExtent);
3008 if(rootWindow.fullRender)
3009 DrawOverChildren(box);
3012 // TO DO: There's an issue about draw over children...
3013 // TO DO: Don't wanna go through this if method isn't used
3014 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3015 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3017 Box box = extentBox.box;
3019 DrawOverChildren(box);
3021 box.left += offsetX;
3023 box.right += offsetX;
3024 box.bottom += offsetY;
3026 if(updateExtent != null)
3027 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3030 for(child = children.first; child; child = child.next)
3031 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3032 child.Render(updateExtent);
3035 overRenderArea.Empty();
3038 public void UpdateDisplay(void)
3040 if(!manageDisplay) { OnRedraw(null);return; }
3041 if(rootWindow && this != rootWindow)
3042 rootWindow.UpdateDisplay();
3045 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3046 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3049 dirtyExtent.Clear();
3052 clipExtent.AddBox(box);
3054 display.StartUpdate();
3056 if(!rootWindow.fullRender)
3058 ComputeClipExtents();
3059 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3060 ComputeRenderArea(dirtyExtent, overExtent, null);
3063 clipExtent.Free(null);
3065 dirtyExtent.Free(null);
3066 overExtent.Free(null);
3068 if(display.flags.flipping)
3071 display.Update(null);
3075 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3076 updateExtent.Clear();
3078 Render(updateExtent);
3080 updateExtent.UnionBox(this.box, tempExtents[0]);
3083 //printf("\n\nUpdate:\n------------------------------------------\n");
3086 //FASTLIST_LOOP(updateExtent, extentBox)
3087 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3090 /*printf("Updating (%d, %d) - (%d, %d)\n",
3091 extentBox.box.left, extentBox.box.top,
3092 extentBox.box.right, extentBox.box.bottom);*/
3095 display.Update(extentBox.box);
3098 updateExtent.Free(null);
3101 display.EndUpdate();
3109 void UpdateBackDisplay(Box box)
3115 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3117 //printf("UpdateBackDisplay going through!\n");
3118 display.StartUpdate();
3122 intersection.Copy(dirtyBack);
3123 intersection.IntersectBox(box);
3125 dirtyExtent.Clear();
3128 clipExtent.AddBox(box);
3130 if(!rootWindow.fullRender)
3132 ComputeClipExtents();
3133 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3136 clipExtent.Free(null);
3138 intersection.Free(null);
3139 dirtyExtent.Free(null);
3140 overExtent.Free(null);
3145 if(display.flags.flipping)
3146 display.Update(null);
3149 rootWindow.display.Update(box);
3152 display.EndUpdate();
3156 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3157 if(dirtyBack.count > MAX_DIRTY_BACK)
3159 BoxItem extentBox, next;
3160 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3161 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3163 next = (BoxItem)extentBox.next;
3164 if(extentBox != first)
3166 if(extentBox.box.left < first.box.left)
3167 first.box.left = extentBox.box.left;
3168 if(extentBox.box.top < first.box.top)
3169 first.box.top = extentBox.box.top;
3170 if(extentBox.box.right > first.box.right)
3171 first.box.right = extentBox.box.right;
3172 if(extentBox.box.bottom > first.box.bottom)
3173 first.box.bottom = extentBox.box.bottom;
3174 dirtyBack.Delete(extentBox);
3183 // --- Window positioning ---
3184 // --- Window identification ---
3186 // Returns window at position "Position"
3187 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3189 Window child, result = null;
3191 box.left += absPosition.x;
3192 box.right += absPosition.x;
3193 box.top += absPosition.y;
3194 box.bottom += absPosition.y;
3196 if(!destroyed && visible && (acceptDisabled || !disabled))
3198 int lx = x - absPosition.x;
3199 int ly = y - absPosition.y;
3200 if(IsInside(lx, ly))
3201 // if(box.IsPointInside(Point{x, y}))
3203 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3204 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3207 bool isD = (last && last != this && last.IsDescendantOf(this)); // Fix for WSMS (#844)
3208 Window ancestor = null;
3210 for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
3211 // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3212 for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
3214 if(child != statusBar && child.rootWindow == rootWindow)
3216 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3223 //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
3224 for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
3226 if(child != statusBar && child.rootWindow == rootWindow)
3228 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3240 Window FindModal(void)
3242 Window modalWindow = this, check;
3243 Window check2 = null;
3244 for(check = this; check.master; check = check.master)
3246 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3248 modalWindow = check.master.modalSlave;
3249 check = modalWindow;
3251 // TESTING THIS FOR DROPBOX...
3252 if(!rootWindow || !rootWindow.style.interim)
3254 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3256 if(check2.modalSlave && check2.modalSlave.created)
3258 modalWindow = check2.modalSlave;
3266 if(modalWindow == this)
3268 for(check = this; check.activeChild; check = check.activeChild)
3270 if(check.modalSlave)
3272 modalWindow = check.modalSlave;
3278 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3279 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3282 void StopMoving(void)
3284 if(this == guiApp.windowMoving)
3286 guiApp.windowMoving = null;
3287 UpdateDecorations();
3288 SetMouseRange(null);
3291 if(rootWindow.active)
3292 guiApp.interfaceDriver.StopMoving(rootWindow);
3295 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3296 guiApp.windowIsResizing = false;
3300 void SelectMouseCursor(void)
3305 Window cursorWindow = null;
3306 bool rx, ry, rex, rey;
3308 guiApp.desktop.GetMousePosition(&x, &y);
3309 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3311 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3312 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3313 else if(mouseWindow)
3315 modalWindow = mouseWindow.FindModal();
3316 x -= mouseWindow.absPosition.x;
3317 y -= mouseWindow.absPosition.y;
3318 if(guiApp.windowIsResizing)
3320 rex = guiApp.resizeEndX;
3321 rey = guiApp.resizeEndY;
3322 rx = guiApp.resizeX;
3323 ry = guiApp.resizeY;
3324 if((rex && rey) || (rx && ry))
3325 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3326 else if((rex && ry) || (rx && rey))
3327 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3328 else if((ry || rey) && (!rx && !rex))
3329 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3330 else if((rx || rex) && (!ry && !rey))
3331 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3333 else if(!modalWindow && !guiApp.windowCaptured &&
3334 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3335 &rx, &ry, &rex, &rey))
3337 if((rex && rey) || (rx && ry))
3338 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3339 else if((rex && ry) || (rx && rey))
3340 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3341 else if((ry || rey) && (!rx && !rex))
3342 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3343 else if((rx || rex) && (!ry && !rey))
3344 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3346 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3348 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3349 cursorWindow = mouseWindow.parent;
3351 cursorWindow = mouseWindow;
3353 else if(!guiApp.interimWindow)
3354 cursorWindow = guiApp.windowCaptured;
3357 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3358 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3360 else if(modalWindow)
3362 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3364 else if(guiApp.interimWindow)
3366 if(guiApp.interimWindow.cursor)
3367 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3369 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3374 // --- State based input ---
3375 bool AcquireInputEx(bool state)
3380 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3381 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3383 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3385 guiApp.acquiredWindow = state ? this : null;
3388 SetMouseRangeToClient();
3389 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3394 SelectMouseCursor();
3396 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3400 // --- Window activation ---
3401 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3404 if(!parent || !parent.style.inactive)
3406 Window parent = this.parent;
3409 if(rootWindow == this)
3410 Log(active ? "active\n" : "inactive\n");
3413 // Testing this here...
3414 if(!parent || parent == guiApp.desktop || parent.active)
3416 this.active = active;
3419 // TESTING THIS HERE
3420 UpdateDecorations();
3421 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3422 result = NotifyActivate(master, this, active, previous);
3425 this.active = !active;
3430 if(!parent || parent == guiApp.desktop || parent.active)
3432 this.active = active;
3434 AcquireInputEx(active);
3439 if(guiApp.caretOwner)
3443 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3444 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3445 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3446 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3448 guiApp.caretOwner.Update(extent);
3451 if(visible || !guiApp.caretOwner)
3452 guiApp.caretOwner = this;
3453 UpdateCaret(false, false);
3459 this.active = false;
3461 AcquireInputEx(active);
3463 if(!active && guiApp.caretOwner == this)
3465 UpdateCaret(false, true);
3466 guiApp.caretOwner = null;
3467 guiApp.interfaceDriver.SetCaret(0,0,0);
3468 guiApp.caretEnabled = false;
3473 if(!active && parent && parent.activeChild && parent.activeChild != this)
3474 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3480 if(!active && menuBar)
3483 menuBar.OnActivate(false, null, &goOn, true);
3484 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3489 Window aChild = activeChild;
3491 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3503 void ConsequentialMouseMove(bool kbMoving)
3507 if(kbMoving || !guiApp.windowMoving)
3511 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3513 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3515 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3516 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3522 bool IsDescendantOf(Window ancestor)
3525 for(window = this; window && window != ancestor; window = window.parent);
3526 return window == ancestor;
3529 bool IsSlaveOf(Window master)
3532 for(window = this; window && window != master; window = window.master);
3533 return window == master;
3536 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3540 if(this && !destroyed /*&& state != Hidden*/)
3542 Window swap = externalSwap;
3550 if(activateParent &&
3551 (parent.activeChild != this ||
3552 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3553 active && _isModal &&
3554 parent != master && master)
3555 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3561 bool real = parent.activeChild != this;
3563 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3564 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3565 !IsDescendantOf(guiApp.interimWindow) &&
3566 !IsSlaveOf(guiApp.interimWindow))
3568 Window interimWindow = guiApp.interimWindow;
3569 while(interimWindow && interimWindow != this)
3571 Window master = interimWindow.master;
3573 guiApp.interimWindow = null;
3574 if(guiApp.caretOwner)
3575 guiApp.caretOwner.UpdateCaret(false, false);
3577 incref interimWindow;
3578 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3583 delete interimWindow;
3584 interimWindow = (master && master.style.interim) ? master : null;
3589 guiApp.interimWindow = this;
3590 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3591 guiApp.caretEnabled = false;*/
3592 UpdateCaret(false, true);
3597 bool acquireInput = false;
3599 parent.activeChild &&
3600 parent.activeChild.state == maximized &&
3601 parent != guiApp.desktop;
3603 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3608 swap = parent.activeChild;
3609 if(swap && swap.destroyed) swap = null;
3610 if(swap && swap != this)
3613 if(!swap.PropagateActive(false, this, &goOn, true))
3614 swap = parent.activeChild;
3625 if(!parent || parent.activeChild != this || style.interim)
3628 result = PropagateActive(true, swap, &goOn, true);
3629 if(!result && !goOn)
3634 acquireInput = true;
3638 if(style.hasMaximize && parent != guiApp.desktop)
3641 SetState(maximized, false, 0);
3642 else if(state != maximized)
3645 for(child = parent.children.first; child; child = child.next)
3647 if(this != child && child.state == maximized)
3648 child.SetState(normal, false, 0);
3655 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3657 Window previous = parent.activeClient;
3658 parent.activeChild = this;
3659 if(!style.nonClient /*&& style.isActiveClient*/)
3663 if(style.isActiveClient)
3664 parent.activeClient = this;
3665 // Moved UpdateActiveDocument inside hidden check
3666 // To prevent activating previous window while creating a new one
3667 // (It was messing up the privateModule in the CodeEditor)
3668 parent.UpdateActiveDocument(previous);
3674 //if(!style.isRemote)
3676 if(rootWindow != this)
3678 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3679 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3681 else if(!guiApp.fullScreenMode)
3683 Window modalRoot = FindModal();
3684 if(!modalRoot) modalRoot = this;
3685 if(!modalRoot.isForegroundWindow)
3687 modalRoot.isForegroundWindow = true;
3688 // To check : Why is parent null?
3689 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3691 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3693 modalRoot.isForegroundWindow = false;
3698 if(result && real && (!style.inactive || moveInactive) && parent)
3700 Window last = parent.children.last;
3702 if(!style.stayOnTop)
3703 for(; last && last.style.stayOnTop; last = last.prev);
3705 parent.children.Move(this, last);
3707 // Definitely don't want that: why not?
3711 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3717 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3724 parent.activeChild = null;
3725 if(!style.nonClient /*&& style.isActiveClient*/)
3727 Window previous = parent.activeClient;
3728 if(style.isActiveClient)
3729 parent.activeClient = null;
3730 parent.UpdateActiveDocument(previous);
3734 if(this == guiApp.interimWindow)
3736 guiApp.interimWindow = null;
3737 if(guiApp.caretOwner)
3738 guiApp.caretOwner.UpdateCaret(false, false);
3740 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3747 if(!active || !swap)
3748 UpdateDecorations();
3750 swap.UpdateDecorations();
3752 if(active && rootWindow != this)
3753 ConsequentialMouseMove(false);
3760 // --- Input Messages ---
3761 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3763 static bool reEntrancy = false;
3764 if(reEntrancy) return;
3768 guiApp.cursorUpdate = true;
3769 if(guiApp.windowScrolling && !consequential)
3771 guiApp.windowScrolling.SetScrollPosition(
3772 (guiApp.windowScrolling.sbh) ?
3773 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3774 (guiApp.windowScrolling.sbv) ?
3775 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3777 if(guiApp.windowMoving)
3779 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3781 Window window = guiApp.windowMoving;
3783 int w = window.size.w;
3784 int h = window.size.h;
3789 rx = mouseX - guiApp.windowMovingStart.x;
3790 ry = mouseY - guiApp.windowMovingStart.y;
3793 window.GetDecorationsSize(&ew, &eh);
3795 if(guiApp.windowIsResizing)
3797 x = window.scrolledPos.x;
3798 y = window.scrolledPos.y;
3802 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3803 rx = guiApp.windowResizingBefore.w - aw;
3804 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3805 w = guiApp.windowResizingBefore.w - rx;
3809 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3810 ry = guiApp.windowResizingBefore.h - ah;
3811 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3812 ry = Max(ry, -guiApp.windowMovingBefore.y);
3813 h = guiApp.windowResizingBefore.h - ry;
3815 if(guiApp.resizeEndX)
3817 w = guiApp.windowResizingBefore.w + rx;
3820 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3828 w = Max(w, window.minSize.w);
3829 h = Max(h, window.minSize.h);
3830 w = Min(w, window.maxSize.w);
3831 h = Min(h, window.maxSize.h);
3833 if(!window.OnResizing(&w, &h))
3835 w = window.clientSize.w;
3836 h = window.clientSize.h;
3839 w = Max(w, window.skinMinSize.w);
3840 h = Max(h, window.skinMinSize.h);
3847 SNAPDOWN(w, textCellW);
3848 SNAPDOWN(h, textCellH);
3853 aw = Max(w,window.skinMinSize.w);
3854 rx = guiApp.windowResizingBefore.w - aw;
3855 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3856 w = guiApp.windowResizingBefore.w - rx;
3860 ah = Max(h,window.skinMinSize.h);
3861 ry = guiApp.windowResizingBefore.h - ah;
3862 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3863 ry = Max(ry, -guiApp.windowMovingBefore.y);
3864 h = guiApp.windowResizingBefore.h - ry;
3869 if(!guiApp.windowIsResizing || guiApp.resizeX)
3870 x = guiApp.windowMovingBefore.x + rx;
3871 if(!guiApp.windowIsResizing || guiApp.resizeY)
3872 y = guiApp.windowMovingBefore.y + ry;
3874 if(!guiApp.windowIsResizing)
3877 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3879 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3880 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3881 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3882 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3886 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3887 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3893 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3895 if(!window.OnMoving(&x, &y, w, h))
3897 x = window.scrolledPos.x;
3898 y = window.scrolledPos.y;
3904 SNAPDOWN(x, textCellW);
3905 SNAPDOWN(y, textCellH);
3908 if(!window.style.nonClient)
3910 if(!window.style.fixed /*|| window.style.isDocument*/)
3912 if(!window.style.dontScrollHorz)
3913 x += window.parent.scroll.x;
3914 if(!window.style.dontScrollVert)
3915 y += window.parent.scroll.y;
3919 // Break the anchors for moveable/resizable windows
3920 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3921 if(window.style.fixed)
3923 if(window.state == normal)
3925 window.normalAnchor = Anchor { left = x, top = y };
3926 window.normalSizeAnchor = SizeAnchor { { w, h } };
3927 window.anchored = false;
3931 window.stateAnchor = Anchor { left = x, top = y };
3932 window.stateSizeAnchor = SizeAnchor { { w, h } };
3934 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3935 // TOCHECK: Investigate why the following only redraws the scrollbars
3936 //window.Position(x, y, w, h, false, true, true, true, false, true);
3938 guiApp.movingLast.x = mouseX;
3939 guiApp.movingLast.y = mouseY;
3945 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3948 bool wasMoving = guiApp.windowMoving ? true : false;
3949 bool wasScrolling = guiApp.windowScrolling ? true : false;
3951 while(result && w != this)
3953 Window msgWindow = GetAtPosition(x,y, false, true, w);
3954 Window trueWindow = GetAtPosition(x,y, false, false, w);
3955 bool windowDragged = false;
3960 window = (w && !w.disabled) ? w : null;
3962 if(trueWindow) incref trueWindow;
3964 if(consequential) mods->isSideEffect = true;
3966 UpdateMouseMove(x, y, consequential);
3968 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3970 if(!guiApp.windowCaptured.isEnabled)
3971 guiApp.windowCaptured.ReleaseCapture();
3973 window = guiApp.windowCaptured;
3976 if(trueWindow && activate &&
3977 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3978 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3979 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3980 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3982 if(mods->alt && !mods->ctrl && !mods->shift)
3984 Window moved = trueWindow;
3985 for(moved = trueWindow; moved; moved = moved.parent)
3986 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3991 windowDragged = true;
3993 // Cancel the ALT menu toggling...
3994 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3999 if(window && activate &&
4000 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
4001 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
4002 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
4003 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4005 Window modalWindow = window.FindModal();
4007 /*if(mods->alt && !mods->shift && !mods->ctrl)
4009 Window moved = window;
4010 for(moved = window; moved; moved = moved.parent)
4011 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4016 windowDragged = true;
4018 // Cancel the ALT menu toggling...
4019 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4025 Window activateWindow = modalWindow ? modalWindow : window;
4026 if(activateWindow && !activateWindow.isRemote)
4028 bool doActivation = true;
4029 //bool needToDoActivation = false;
4030 Window check = activateWindow;
4032 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4034 if(!check.style.inactive)
4036 //needToDoActivation = true;
4038 doActivation = false;
4043 if(!needToDoActivation)
4044 doActivation = false;
4047 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4048 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4050 // Let the OnLeftButtonDown do the activating instead
4051 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4059 incref activateWindow;
4060 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4062 delete activateWindow;
4066 if(activateWindow._refCount == 1)
4068 delete activateWindow;
4072 delete activateWindow;
4073 // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
4076 mods->isActivate = true;
4080 if(!modalWindow && window && !window.destroyed)
4082 if(!guiApp.windowCaptured || windowDragged)
4084 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4086 bool moving = ((window.state != maximized &&
4087 window.IsMouseMoving(
4088 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4089 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4091 if(!moving && window.IsMouseResizing(
4092 x - window.absPosition.x,
4093 y - window.absPosition.y,
4094 window.size.w, window.size.h,
4095 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4097 guiApp.windowIsResizing = true;
4098 guiApp.windowResizingBefore.w = window.size.w;
4099 guiApp.windowResizingBefore.h = window.size.h;
4101 if(guiApp.windowIsResizing || windowDragged || moving)
4104 guiApp.windowMoving = window;
4105 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4106 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4107 guiApp.windowMovingBefore.x = window.position.x;//s;
4108 guiApp.windowMovingBefore.y = window.position.y;//s;
4109 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4110 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4113 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4115 if(window.style.fixed &&
4117 window.IsMouseMoving(
4118 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4120 window.ShowSysMenu(x, y);
4124 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4126 if(window.sbv || window.sbh)
4129 guiApp.windowScrolling = window;
4130 guiApp.windowScrollingStart.x = x;
4131 guiApp.windowScrollingStart.y = y;
4132 guiApp.windowScrollingBefore.x = window.scroll.x;
4133 guiApp.windowScrollingBefore.y = window.scroll.y;
4136 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4138 if(window.style.hasMaximize &&
4139 window.IsMouseMoving(
4140 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4143 (window.state == maximized) ? normal : maximized, false, *mods);
4151 if(guiApp.windowMoving)
4153 if(guiApp.windowMoving.parent)
4155 if(guiApp.windowMoving.style.nonClient)
4156 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4158 guiApp.windowMoving.parent.SetMouseRangeToClient();
4162 window.UpdateDecorations();
4165 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4167 // Log("\n*** LEFT BUTTON UP ***\n");
4168 if(guiApp.windowMoving)
4169 guiApp.windowMoving.StopMoving();
4171 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4173 if(guiApp.windowScrolling)
4175 Window windowScrolling = guiApp.windowScrolling;
4176 guiApp.windowScrolling = null;
4177 windowScrolling.ReleaseCapture();
4181 if(!result || (window && window.destroyed)) window = null;
4183 if(window && window.FindModal())
4186 if(trueWindow && trueWindow.FindModal())
4194 msgWindow = GetAtPosition(x,y, true, false);
4196 msgWindow.SelectMouseCursor();
4199 if(guiApp.windowCaptured || trueWindow)
4201 Window prevWindow = guiApp.prevWindow;
4202 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4204 guiApp.prevWindow.mouseInside = false;
4205 guiApp.prevWindow = null;
4207 // Eventually fix this not to include captured?
4208 if(!prevWindow.OnMouseLeave(*mods))
4211 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4213 Box box = trueWindow.box;
4214 box.left += trueWindow.absPosition.x;
4215 box.right += trueWindow.absPosition.x;
4216 box.top += trueWindow.absPosition.y;
4217 box.bottom += trueWindow.absPosition.y;
4219 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4221 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4222 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4224 overX = Max(Min(overX, 32767),-32768);
4225 overY = Max(Min(overY, 32767),-32768);
4227 trueWindow.mouseInside = true;
4228 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4232 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4233 guiApp.prevWindow = trueWindow;
4235 guiApp.prevWindow = null;
4237 SelectMouseCursor();
4239 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4241 int clientX = x - (window.absPosition.x + window.clientStart.x);
4242 int clientY = y - (window.absPosition.y + window.clientStart.y);
4244 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4246 clientX = Max(Min(clientX, 32767),-32768);
4247 clientY = Max(Min(clientY, 32767),-32768);
4249 MouseMethod = (void *)window._vTbl[method];
4251 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4254 if(!MouseMethod(window, clientX, clientY, *mods))
4261 if(result && w && w.clickThrough && w.parent)
4266 if(!result || !w || !w.clickThrough)
4273 // --- Mouse cursor management ---
4275 bool KeyMessage(uint method, Key key, unichar character)
4280 if(guiApp.interimWindow)
4281 this = guiApp.interimWindow;
4284 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4288 if(!style.inactive || rootWindow != this)
4290 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4291 Window modalWindow = FindModal();
4292 Window interimMaster = master ? master.rootWindow : null;
4296 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4297 status = OnSysKeyDown(key, character);
4298 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4299 status = OnSysKeyHit(key, character);
4300 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4301 status = OnSysKeyUp(key, character);
4308 // Process Key Message for Internal UI Keyboard actions
4309 if(status && !destroyed && menuBar && state != minimized)
4312 if((SmartKey)key != alt)
4313 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4316 SmartKey sk = (SmartKey) key;
4317 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4319 status = menuBar.KeyMessage(method, key, character);
4324 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4325 menuBar.OnKeyHit(escape, 0);
4327 if(!menuBar.focus && guiApp.caretOwner)
4328 guiApp.caretOwner.UpdateCaret(true, false);
4331 if(!destroyed && status)
4333 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4337 case left: case up: case right: case down:
4338 if(guiApp.windowMoving == this)
4341 int w = guiApp.windowMoving.size.w;
4342 int h = guiApp.windowMoving.size.h;
4343 int x = guiApp.windowMoving.scrolledPos.x;
4344 int y = guiApp.windowMoving.scrolledPos.y;
4348 if(key == down || key == up)
4349 step = Max(step, textCellH);
4351 step = Max(step, textCellW);
4354 if(guiApp.windowIsResizing)
4358 case left: w-=step; break;
4359 case right: w+=step; break;
4360 case up: h-=step; break;
4361 case down: h+=step; break;
4368 case left: x-=step; break;
4369 case right: x+=step; break;
4370 case up: y-=step; break;
4371 case down: y+=step; break;
4375 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4376 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4378 if(!guiApp.windowIsResizing || guiApp.resizeX)
4379 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4381 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4383 if(!guiApp.windowIsResizing || guiApp.resizeY)
4384 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4386 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4388 guiApp.interfaceDriver.SetMousePosition(x, y);
4389 ConsequentialMouseMove(true);
4397 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4399 guiApp.windowMoving.StopMoving();
4400 ConsequentialMouseMove(false);
4408 ShowSysMenu(absPosition.x, absPosition.y);
4416 if(!destroyed && status && state != minimized)
4418 // Process all the way down the children
4419 if(activeChild && !activeChild.disabled)
4421 status = activeChild.KeyMessage(method, key, character);
4423 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4424 key.code != left && key.code != right && key.code != up && key.code != down)
4426 status = activeClient.KeyMessage(method, key, character);
4430 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4432 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4433 // && defaultControl != activeChild)
4435 delete previousActive;
4436 previousActive = activeChild;
4437 if(previousActive) incref previousActive;
4439 ConsequentialMouseMove(false);
4440 if((defaultControl.active ||
4441 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4442 defaultControl.KeyMessage(method, defaultKey, character);
4448 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4450 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4457 ShowSysMenu(absPosition.x, absPosition.y);
4464 if(this != guiApp.desktop)
4466 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4468 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4470 MenuMoveOrSize(key.shift, true);
4474 else if(guiApp.windowMoving)
4476 guiApp.windowMoving.StopMoving();
4477 ConsequentialMouseMove(false);
4485 if(!destroyed && status && state != minimized)
4487 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4491 case tab: case shiftTab:
4493 Window cycleParent = this;
4494 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4495 cycleParent = master.parent;
4497 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4499 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4501 Window child = cycleParent.activeChild;
4503 // Scroll the window to include the active control
4505 if(cycleParent.sbh && !child.style.dontScrollHorz)
4507 if(child.scrolledPos.x < 0)
4508 cycleParent.sbh.Action(Position,
4509 cycleParent.scroll.x + child.scrolledPos.x, 0);
4510 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4511 cycleParent.sbh.Action(Position,
4512 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4514 if(cycleParent.sbv && !child.style.dontScrollVert)
4516 if(child.scrolledPos.y < 0)
4517 cycleParent.sbv.Action(Position,
4518 cycleParent.scroll.y + child.scrolledPos.y, 0);
4519 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4520 cycleParent.sbv.Action(Position,
4521 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4524 cycleParent.ConsequentialMouseMove(false);
4530 case f6: case shiftF6:
4531 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4533 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4534 if(parent == guiApp.desktop)
4535 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4545 if(CycleChildren(key.shift, true, false, true))
4553 // mIRC Style Window Shortcuts
4554 case alt1: case alt2: case alt3: case alt4: case alt5:
4555 case alt6: case alt7: case alt8: case alt9: case alt0:
4560 for(document = children.first; document; document = document.next)
4562 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4564 if(document == activeChild)
4566 if(document.state == minimized)
4567 document.SetState(normal, false, key);
4570 document.SetState(minimized, false, key);
4571 CycleChildren(false, true, false);
4576 if(activeChild.state == maximized && document.style.hasMaximize)
4577 document.SetState(maximized, false, key);
4578 else if(document.state == minimized)
4579 document.SetState(normal, false, key);
4580 document.Activate();
4595 if(!destroyed && status)
4597 if(state == minimized)
4602 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4604 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4606 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4607 previousActive.ActivateEx(true, false, false, true, null, null);
4608 delete previousActive;
4614 if(!destroyed && status)
4616 status = ProcessHotKeys(method, key, character);
4618 if(!destroyed && status && !modalWindow && state != minimized)
4621 status = KeyMethod(this, key, character);
4622 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4623 status = OnKeyHit(key, character);
4624 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4626 bool result = false;
4629 case ctrlUp: case ctrlDown:
4630 if(sbv && !guiApp.windowScrolling)
4631 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4633 case wheelUp: case wheelDown:
4634 if(sbv && !guiApp.windowScrolling)
4636 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4637 // Do we want to do a consequential move regardless of result in this case?
4638 ConsequentialMouseMove(false);
4641 case ctrlPageUp: case ctrlPageDown:
4642 if(sbh && !guiApp.windowScrolling)
4643 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4648 ConsequentialMouseMove(false);
4653 if(status && !destroyed && menuBar && state != minimized)
4654 status = menuBar.KeyMessage(method, key, character);
4656 if(style.interim && /*destroyed && */status && interimMaster)
4658 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4659 status = interimMaster.KeyMessage(method, key, character);
4666 bool ProcessHotKeys(uint method, Key key, unichar character)
4671 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4672 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4673 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4675 Window hotKeyWindow = hotKey.window;
4676 Window parent = hotKeyWindow.parent;
4677 Window prevActiveWindow = activeChild;
4678 // For when sys buttons are placed inside the menu bar
4679 if(parent && parent._class == class(PopupMenu))
4680 parent = parent.parent;
4682 // 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
4683 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4686 if(prevActiveWindow) incref prevActiveWindow;
4687 incref hotKeyWindow;
4688 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4689 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4692 delete hotKeyWindow;
4693 delete prevActiveWindow;
4697 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4698 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4699 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4701 // ********* WORKING ON THIS ***********
4702 if(prevActiveWindow && !guiApp.interimWindow)
4703 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4706 else if(hotKeyWindow.style.inactive)
4707 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4709 delete prevActiveWindow;
4710 delete hotKeyWindow;
4711 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4712 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4716 if(status && tabCycle)
4719 for(child = children.first; child; child = child.next)
4721 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4732 // --- Windows and graphics initialization / termination ---
4733 bool SetupRoot(void)
4737 // Setup relationship with outside world (bb root || !bb)
4738 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4739 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4743 tempExtents = new0 Extent[4];
4748 /*if(guiApp.fullScreenMode)
4749 rootWindow = guiApp.desktop;
4751 //rootWindow = parent.created ? parent.rootWindow : null;
4752 rootWindow = parent.rootWindow;
4755 against = &parent.box;
4757 against = &parent.clientArea;
4760 for(child = children.first; child; child = child.next)
4763 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4766 bool Setup(bool positionChildren)
4768 bool result = false;
4771 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4773 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4774 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4776 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4778 // This was here, is it really needed?
4779 //guiApp.interfaceDriver.ActivateRootWindow(this);
4783 displaySystem = DisplaySystem {};
4784 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4786 delete displaySystem;
4791 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4792 if(display.Create(displaySystem, windowHandle))
4799 // Sometimes icon does not show up on Windows XP if we set here...
4800 // guiApp.interfaceDriver.SetIcon(this, icon);
4802 else if(this != guiApp.desktop)
4804 display = rootWindow ? rootWindow.display : null;
4810 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4811 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4813 for(child = children.first; child; child = child.next)
4815 if(child.created && !child.Setup(false))
4821 bool SetupDisplay(void)
4823 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4824 if(is3D) return Window3D_SetupDisplay(this); else
4831 class_data void ** pureVTbl;
4833 bool LoadGraphics(bool creation, bool resetAnchors)
4835 bool result = false;
4836 bool success = false;
4838 WindowState stateBackup = state;
4840 if(((subclass(Window))_class).pureVTbl)
4842 if(_vTbl == _class._vTbl)
4844 _vTbl = ((subclass(Window))_class).pureVTbl;
4849 for(m = 0; m < _class.vTblSize; m++)
4851 if(_vTbl[m] == _class._vTbl[m])
4852 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4856 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4858 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4860 _vTbl = _class._vTbl;
4865 for(m = 0; m < _class.vTblSize; m++)
4867 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4868 _vTbl[m] = _class._vTbl[m];
4873 if(guiApp.fullScreenMode || this != guiApp.desktop)
4875 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4881 display.Lock(false);
4882 if(rootWindow == this)
4884 // Set Color Palette
4885 display.SetPalette(palette, true);
4889 if(guiApp.fullScreenMode && this == guiApp.desktop)
4894 for(c=0; c<SystemCursor::enumSize; c++)
4895 if(!guiApp.systemCursors[c].bitmap)
4897 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4898 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4899 if(guiApp.systemCursors[c].bitmapName)
4901 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4902 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4903 if(guiApp.systemCursors[c].bitmap)
4904 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4909 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4911 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4912 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4914 cursor.bitmap.paletteShades = cursor.paletteShades;
4918 guiApp.cursorUpdate = true;
4921 ConsequentialMouseMove(false);
4927 // Load Window Graphic Resources
4930 if(usedFont == setFont || usedFont == window.systemFont)
4931 RemoveResource(usedFont);
4934 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4937 RemoveResource(systemFont);
4940 RemoveResource(captionFont);
4942 for(ptr = resources.first; ptr; ptr = ptr.next)
4944 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4947 AddResource(setFont);
4949 AddResource(systemFont);
4951 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4958 //if(master && master.font)
4959 if(parent && parent.font)
4963 faceName = parent.font.faceName,
4964 size = parent.font.size,
4965 bold = parent.font.bold,
4966 italic = parent.font.italic,
4967 underline = parent.font.underline
4969 //font = parent.font;
4970 watch(parent) { font { } };
4973 font = guiApp.currentSkin.SystemFont();
4980 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4981 AddResource(captionFont);
4983 if(OnLoadGraphics())
4989 //SetScrollLineStep(sbStep.x, sbStep.y);
4991 if(this != guiApp.desktop)
4995 normalAnchor = anchor;
4996 normalSizeAnchor = sizeAnchor;
4999 // Break the anchors for moveable/resizable windows
5001 if(style.fixed && style.isDocument)
5003 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5015 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5016 stateSizeAnchor = SizeAnchor {};
5021 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5026 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5027 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5030 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5034 stateAnchor = normalAnchor;
5035 stateSizeAnchor = normalSizeAnchor;
5038 position = Point { };
5039 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5050 if(Position(x, y, w, h, true, false, true, true, true, true))
5052 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5055 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5072 success = result = true;
5075 if(!creation && result)
5077 // Load menu bar first because sys buttons are on it...
5080 if(!menuBar.LoadGraphics(false, resetAnchors))
5086 for(child = children.first; child; child = child.next)
5088 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5095 CreateSystemChildren();
5099 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5102 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5107 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5108 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5111 // Do this here to avoid problems on Windows
5112 if(stateBackup == maximized)
5113 property::state = maximized;
5117 void UnloadGraphics(bool destroyWindows)
5121 // Free children's graphics
5122 for(child = children.first; child; child = child.next)
5123 child.UnloadGraphics(destroyWindows);
5126 display.Lock(false);
5129 if(guiApp.fullScreenMode && this == guiApp.desktop)
5134 for(c=0; c<SystemCursor::enumSize; c++)
5135 if(guiApp.systemCursors[c].bitmap)
5136 delete guiApp.systemCursors[c].bitmap;
5138 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5139 delete cursor.bitmap;
5141 guiApp.cursorBackground.Free();
5144 if(display && display.displaySystem)
5148 for(ptr = resources.first; ptr; ptr = ptr.next)
5152 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5157 // Free window graphics
5160 // Free skin graphics
5161 if(rootWindow == this)
5163 DisplaySystem displaySystem = display.displaySystem;
5166 display.driverData = null;
5167 display.displaySystem = null;
5171 if(displaySystem && !displaySystem.numDisplays && !is3D)
5172 delete displaySystem;
5181 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5182 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5184 if(this == guiApp.desktop || parent == guiApp.desktop)
5186 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5187 guiApp.interfaceDriver.DestroyRootWindow(this);
5191 // --- Window Hiding ---
5193 void SetVisibility(bool state)
5195 bool visible = (style.hidden || !created) ? false : state;
5196 if(visible != this.visible)
5200 this.visible = visible;
5201 for(child = children.first; child; child = child.next)
5202 child.SetVisibility(visible);
5204 ConsequentialMouseMove(false);
5205 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5209 // --- Windows and graphics initialization / termination ---
5211 bool DisplayModeChanged(void)
5213 bool result = false;
5214 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5216 guiApp.modeSwitching = true;
5217 UnloadGraphics(false);
5219 if(LoadGraphics(false, false))
5221 guiApp.modeSwitching = false;
5226 // --- Window updates system ---
5228 void UpdateDirty(Box updateBox)
5230 if(!manageDisplay) { OnRedraw(null);return; }
5233 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5236 if(display.flags.flipping)
5239 rootWindow.UpdateDisplay();
5242 UpdateBackDisplay(updateBox);
5244 if(guiApp.fullScreenMode)
5246 guiApp.cursorUpdate = true;
5247 guiApp.PreserveAndDrawCursor();
5249 if(guiApp.fullScreenMode)
5250 guiApp.RestoreCursorBackground();
5256 // This function is strictly called as a result of system window activation
5257 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5260 Window interimMaster = null;
5261 Window interimWindow = guiApp.interimWindow;
5262 if(interimWindow && interimWindow.master)
5263 interimMaster = interimWindow.master.rootWindow;
5265 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5266 // SetState(normal, false, 0);
5267 SetState(lastState, false, 0);
5269 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5273 /* WTH is this doing here?
5274 while(swap && swap.activeChild)
5276 swap = swap.activeChild;
5279 // TESTING THIS BEFORE...
5280 if(interimWindow && this == interimMaster)
5284 // Window interimSwap = this;
5285 Window menuBar = this.menuBar;
5286 if(menuBar && interimWindow.master == menuBar)
5289 while(interimSwap && interimSwap.activeChild)
5290 interimSwap = interimSwap.activeChild;
5292 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5293 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5295 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5296 //result = ActivateEx(true, true, false, activateRoot, window, null);
5301 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5302 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5304 if(interimWindow == this && interimMaster && !active)
5306 while(interimMaster && interimMaster.interim && interimMaster.master)
5308 // printf("Going up one master %s\n", interimMaster._class.name);
5309 interimMaster = interimMaster.master.rootWindow;
5311 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5312 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5318 bool DestroyEx(int64 returnCode)
5321 Timer timer, nextTimer;
5323 OldLink prevOrder = null;
5324 Window client = null;
5326 if(parent) stopwatching(parent, font);
5328 // if(window.modalSlave) return false;
5329 if(destroyed || !created)
5336 OldLink slave = master.slaves.FindLink(this);
5337 master.slaves.Delete(slave);
5340 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5346 this.returnCode = (DialogResult)returnCode;
5348 AcquireInput(false);
5353 master.hotKeys.Delete(hotKey);
5357 if(guiApp.prevWindow == this)
5359 guiApp.prevWindow = null;
5362 if(guiApp.caretOwner == this)
5364 guiApp.interfaceDriver.SetCaret(0,0,0);
5365 UpdateCaret(false, true);
5366 guiApp.caretEnabled = false;
5371 parent.childrenCycle.Remove(cycle);
5375 OldLink tmpPrev = order.prev;
5376 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5377 prevOrder = tmpPrev;
5380 client = tmpPrev ? tmpPrev.data : null;
5381 if(client == this) { client = null; break; }
5382 if(client && (client.style.hidden || client.destroyed || !client.created))
5383 tmpPrev = client.order.prev;
5387 prevOrder = tmpPrev;
5392 // If this window can be an active client, make sure the next window we activate can also be one
5393 if(!style.nonClient && style.isActiveClient)
5395 tmpPrev = prevOrder;
5398 client = tmpPrev ? tmpPrev.data : null;
5399 if(client == this) { client = null; break; }
5400 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5401 tmpPrev = client.order.prev;
5405 prevOrder = tmpPrev;
5409 if(client && client.style.hidden) client = null;
5411 // parent.childrenOrder.Remove(order);
5414 if(parent && style.isActiveClient && visible)
5416 if(state == minimized) parent.numIcons--;
5417 parent.numPositions--;
5420 // TESTING THIS HERE!
5424 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5425 // to create a window inside a rootwindow that's being destroyed)
5426 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5428 if(master && !master.destroyed /*&&
5429 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5431 if(master.defaultControl == this)
5432 master.defaultControl = null;
5435 parent.OnChildAddedOrRemoved(this, true);
5436 if(parent && !parent.destroyed /*&&
5437 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5439 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5441 if(order && prevOrder && prevOrder.data != this && active)
5443 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5445 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5446 if(parent.activeClient == this)
5448 parent.activeClient = null;
5449 parent.UpdateActiveDocument(null);
5454 if(guiApp.interimWindow == this)
5457 PropagateActive(false, null, &goOn, true);
5461 //if(window.parent.activeChild == window)
5462 parent.activeChild = null;
5463 if(!style.nonClient /*&& style.isActiveClient*/)
5465 Window previous = parent.activeClient;
5466 if(style.isActiveClient)
5467 parent.activeClient = null;
5468 parent.UpdateActiveDocument(previous);
5473 else if(parent.activeClient == this)
5475 parent.activeClient = client;
5476 parent.UpdateActiveDocument(this);
5480 if(guiApp.interimWindow == this)
5482 guiApp.interimWindow = null;
5483 if(guiApp.caretOwner)
5485 Window desktop = guiApp.desktop;
5486 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5487 guiApp.caretOwner.UpdateCaret(false, false);
5492 if(_isModal && master && master.modalSlave == this)
5493 master.modalSlave = null;
5497 if(!guiApp.caretOwner && parent.caretSize)
5499 guiApp.caretOwner = parent;
5500 parent.UpdateCaret(false, false);
5501 parent.Update(null);
5504 // Why was this commented out?
5505 GetRidOfVirtualArea();
5511 dirtyArea.Free(null);
5512 dirtyBack.Free(null);
5513 scrollExtent.Free(null);
5515 /* ATTEMPTING TO MOVE THAT ABOVE
5524 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5525 for(;(child = window.children.first);)
5527 for(; child && (child.destroyed || !child.created); child = child.next);
5536 UnloadGraphics(true);
5539 delete previousActive;
5542 // statusBar = null;
5545 if(master && !master.destroyed)
5547 //master.NotifyDestroyed(this, this.returnCode);
5548 NotifyDestroyed(master, this, this.returnCode);
5551 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5553 nextTimer = timer.next;
5554 if(timer.window == this)
5556 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5557 // timer.window = null;
5563 if(this == guiApp.windowMoving)
5566 if(guiApp.windowCaptured == this)
5568 //guiApp.windowCaptured = null;
5570 if(rootWindow != this && rootWindow)
5571 rootWindow.ConsequentialMouseMove(false);
5579 //for(child = children.first; next = child ? child.next : null, child; child = next)
5580 for(;(child = children.first); )
5582 for(; child && (child.destroyed || !child.created); child = child.next);
5592 /* // MOVED THIS UP...
5595 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5596 for(;(child = window.children.first); )
5598 for(; child && (child.destroyed || !child.created); child = child.next);
5607 while((slave = slaves.first))
5609 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5611 ((Window)slave.data).DestroyEx(0);
5616 if(guiApp.caretOwner == this)
5617 guiApp.caretOwner = null;
5619 sysButtons[0] = null;
5620 sysButtons[1] = null;
5621 sysButtons[2] = null;
5624 if(rootWindow != this)
5626 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5629 box.left -= parent.clientStart.x;
5630 box.top -= parent.clientStart.y;
5631 box.right -= parent.clientStart.x;
5632 box.bottom -= parent.clientStart.y;
5634 if(parent) parent.Update(box);
5639 OldLink slave = master.slaves.FindVoid(this);
5640 master.slaves.Delete(slave);
5646 parent.children.Remove(this);
5651 //autoCreate = false;
5654 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5655 if(((subclass(Window))_class).pureVTbl)
5657 if(_vTbl == _class._vTbl)
5659 _vTbl = ((subclass(Window))_class).pureVTbl;
5664 for(m = 0; m < _class.vTblSize; m++)
5666 if(_vTbl[m] == _class._vTbl[m])
5667 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5676 void SetStateEx(WindowState newState, bool activate)
5679 WindowState prevState = state;
5683 if(prevState != newState)
5684 lastState = prevState;
5686 if(rootWindow != this || !nativeDecorations || !windowHandle)
5688 if(style.isActiveClient && !style.hidden && prevState == minimized)
5691 // This block used to be at the end of the function... moved it for flicker problem in X
5692 // ------------------------------------------------------
5696 stateAnchor = normalAnchor;
5697 stateSizeAnchor = normalSizeAnchor;
5700 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5701 stateSizeAnchor = SizeAnchor {};
5705 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5708 byte * idBuffer = new0 byte[size];
5710 for(child = parent.children.first; child; child = child.next)
5712 if(child != this && child.state == minimized)
5714 if(child.iconID > size - 2)
5716 idBuffer = renew0 idBuffer byte[size*2];
5717 memset(idBuffer + size, 0, size);
5720 idBuffer[child.iconID] = (byte)bool::true;
5723 for(c = 0; c<size; c++)
5728 if(style.isActiveClient && !style.hidden)
5731 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5732 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5736 // TOCHECK: Why was this here?
5737 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5738 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5739 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5741 Position(x, y, w, h, true, true, true, true, false, true);
5743 if(!style.inactive && !style.interim && this == parent.activeClient)
5744 parent.UpdateActiveDocument(null);
5747 CreateSystemChildren();
5748 // ------------------------------------------------------
5751 int GetPositionID(Window forChild)
5755 byte * idBuffer = new0 byte[size];
5758 for(child = children.first; child; child = child.next)
5760 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5762 if(child.positionID > size - 2)
5764 idBuffer = renew0 idBuffer byte[size*2];
5765 memset(idBuffer + size, 0, size);
5768 idBuffer[child.positionID] = (byte)bool::true;
5771 for(c = 0; c<size; c++)
5778 // --- Window related graphics ---
5780 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5782 palette = newPalette;
5783 if(rootWindow.display)
5784 rootWindow.display.SetPalette(palette, colorMatch);
5787 public bool AcquireInput(bool acquired)
5790 if(acquiredInput != acquired)
5792 if(active || (!visible && creationActivation == activate))
5793 result = AcquireInputEx(acquired);
5798 acquiredInput = acquired ? result : !result;
5803 void ListChildren(ListBox listBox)
5807 for(child = children.first; child; child = child.next)
5809 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5811 DataRow row = listBox.AddRow();
5812 row.tag = (int64)child;
5813 child.FigureCaption(caption);
5814 row.SetData(null, caption);
5819 void UpdateVisual(Box extent)
5821 if(guiApp.driver != null)
5823 if(guiApp.fullScreenMode && guiApp.desktop.display)
5825 guiApp.desktop.mutex.Wait();
5826 guiApp.desktop.display.Lock(true);
5829 if(guiApp.desktop.active)
5831 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5833 if(guiApp.desktop.display.flags.flipping)
5834 guiApp.desktop.Update(null);
5835 guiApp.desktop.UpdateDisplay();
5836 guiApp.cursorUpdate = true;
5838 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5840 guiApp.PreserveAndDrawCursor();
5841 // guiApp.desktop.display.ShowScreen();
5842 guiApp.cursorUpdate = false;
5843 guiApp.desktop.dirty = false;
5844 guiApp.RestoreCursorBackground();
5848 guiApp.desktop.display.Unlock();
5849 guiApp.desktop.mutex.Release();
5853 Window rootWindow = this.rootWindow;
5854 rootWindow.mutex.Wait();
5859 guiApp.SignalEvent();
5862 guiApp.waitMutex.Wait();
5863 guiApp.interfaceDriver.Lock(rootWindow);
5864 if(!rootWindow.style.hidden && rootWindow.dirty)
5866 if(rootWindow.display)
5868 rootWindow.UpdateDisplay();
5869 //rootWindow.display.ShowScreen(null);
5871 rootWindow.dirty = false;
5873 guiApp.interfaceDriver.Unlock(rootWindow);
5874 guiApp.waitMutex.Release();
5877 rootWindow.mutex.Release();
5882 void UnlockDisplay(void)
5884 guiApp.interfaceDriver.Unlock(rootWindow);
5887 void LockDisplay(void)
5889 guiApp.interfaceDriver.Lock(rootWindow);
5892 Surface GetSurface(Box box)
5894 return Redraw((box == null) ? this.box : box);
5897 void SetMousePosition(int x, int y)
5899 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5903 void IntegrationActivate(bool active)
5905 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5907 isForegroundWindow = true;
5908 ActivateEx(active, active, false, false, null, null);
5909 isForegroundWindow = false;
5914 Window QueryCapture(void)
5916 return guiApp.windowCaptured;
5919 int GetDocumentID(void)
5923 byte * idBuffer = new0 byte[size];
5926 for(child = children.first; child; child = child.next)
5928 // TO CHECK: Do we want a documentID when we already have a file name?
5929 if(child.style.isDocument && !child.fileName)
5931 if(child.documentID-1 > size - 2)
5933 idBuffer = renew0 idBuffer byte[size*2];
5934 memset(idBuffer + size, 0, size);
5937 idBuffer[child.documentID-1] = 1;
5940 for(c = 0; c<size; c++)
5948 void SetInitSize(Size size)
5951 sizeAnchor.size = size;
5952 normalSizeAnchor = sizeAnchor;
5954 // Break the anchors for moveable/resizable windows
5955 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5957 stateAnchor = normalAnchor;
5958 stateSizeAnchor = normalSizeAnchor;
5960 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5961 Position(x,y, w, h, true, true, true, true, false, true);
5965 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5967 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5969 guiApp.windowIsResizing = resize;
5970 guiApp.windowMoving = this;
5971 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5972 if(guiApp.windowIsResizing)
5974 guiApp.windowMovingStart.x += size.w - 1;
5975 guiApp.windowMovingStart.y += size.h - 1;
5977 guiApp.windowMovingBefore = scrolledPos;
5978 guiApp.windowResizingBefore = size;
5979 guiApp.windowMoving.UpdateDecorations();
5980 if(guiApp.windowIsResizing)
5981 guiApp.resizeEndX = guiApp.resizeEndY = true;
5983 if(setCursorPosition)
5984 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5988 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5989 guiApp.windowMovingStart.x += x - absPosition.x;
5990 guiApp.windowMovingStart.y += y - absPosition.y;
5993 if(guiApp.windowMoving)
5995 if(guiApp.windowMoving.style.nonClient)
5996 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5998 guiApp.windowMoving.parent.SetMouseRangeToClient();
6003 if(this == rootWindow)
6004 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6012 bool result = false;
6016 else if(guiApp && guiApp.driver != null)
6018 void * systemParent = null;
6019 OldLink slaveHolder;
6021 bool visible = !style.hidden;
6025 systemParent = parent;
6026 parent = guiApp.desktop;
6028 last = parent ? parent.children.last : null;
6030 if((parent && parent != guiApp.desktop && !parent.created) ||
6031 (master && master != guiApp.desktop && !master.created))
6035 stopwatching(parent, font);
6038 property::parent = guiApp.desktop;
6039 if(!master) master = parent;
6041 if(_isModal && master.modalSlave)
6042 property::master = master.modalSlave;
6046 parent.children.Remove(this);
6049 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6050 if(slaveHolder.data == this)
6052 master.slaves.Delete(slaveHolder);
6057 if(parent == guiApp.desktop && !mutex)
6060 if(style.isDocument)
6063 parent.numDocuments--;
6064 documentID = parent.GetDocumentID();
6067 if(!style.stayOnTop)
6068 for(; last && last.style.stayOnTop; last = last.prev);
6070 parent.children.Insert((last == this) ? null : last, this);
6071 //parent.children.Add(this);
6074 dispDriver = parent.dispDriver;
6077 master.modalSlave = this;
6079 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6084 master.slaves.Add(slaveHolder = OldLink { data = this });
6089 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6091 if(style.isDefault && !master.defaultControl)
6092 master.defaultControl = this;
6094 stateAnchor = normalAnchor = anchor;
6095 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6097 // TOCHECK: Why is this here?
6098 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6099 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6101 this.visible = false;
6102 style.hidden = true;
6105 // autoCreate = true;
6113 if(parent == guiApp.desktop)
6114 Log("LoadGraphics %s\n", caption);
6116 if(LoadGraphics(true, false))
6124 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6131 if(style.hasMenuBar /*&& menu*/)
6137 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6138 interim = false, inactive = true, nonClient = true, size.h = 24
6146 // Create the system buttons
6147 CreateSystemChildren();
6149 UpdateActiveDocument(null);
6151 if(style.isDocument)
6155 MenuItem item = menu.FindItem(MenuFileSave, 0);
6156 if(item) item.disabled = !modifiedDocument && fileName;
6161 if(parent == guiApp.desktop)
6162 Log("Preemptive SetState %s\n", caption);
6165 // Preemptive Set State to ensure proper anchoring
6166 SetStateEx(state, false);
6168 style.hidden = true;
6174 for(child = children.first; child; child = next)
6177 if(!child.created && (child.autoCreate || child.wasCreated))
6184 for(link = slaves.first; link; link = next)
6186 Window slave = link.data;
6188 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6191 // Things might have happened that invalidated 'next'...
6192 // Start over the search for slaves to create.
6193 // (Added this to fix crash with Stacker & Toolbar)
6194 next = slaves.first;
6203 if(parent == guiApp.desktop)
6204 Log("Real SetState %s\n", caption);
6207 if(isActiveClient && visible)
6209 parent.numPositions--;
6210 if(state == minimized) parent.numIcons--;
6213 parent.OnChildAddedOrRemoved(this, false);
6215 // Real set state & activate for proper display & activation
6216 property::visible = visible;
6217 // SetState(state & 0x00000003, true, 0);
6218 guiApp.interfaceDriver.SetIcon(this, icon);
6223 /*if(rootWindow == this)
6224 guiApp.interfaceDriver.ActivateRootWindow(this);
6226 if(creationActivation == activate)
6227 ActivateEx(true, false, true, true, null, null);
6228 else if(creationActivation == flash)
6233 rootWindow.ConsequentialMouseMove(false);
6244 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6250 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6252 //style.hidden = true; // !visible;
6253 style.hidden = !visible;
6254 if(master.modalSlave == this)
6255 master.modalSlave = null;
6262 void WriteCaption(Surface surface, int x, int y)
6265 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6268 void Update(Box region)
6274 rootWindow = this.rootWindow;
6276 // rootWindow.mutex.Wait();
6277 if(!destroyed && visible && display)
6282 // Testing this to avoid repetitve full update to take time...
6283 if(dirtyArea.count == 1)
6285 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6286 if(item.box.left <= box.left &&
6287 item.box.top <= box.top &&
6288 item.box.right >= box.right &&
6289 item.box.bottom >= box.bottom)
6291 rootWindow.dirty = true;
6296 if(display.flags.flipping && !rootWindow.dirty)
6298 if(this == rootWindow)
6302 rootWindow.Update(null);
6307 rootWindow.dirty = true;
6312 realBox.left += clientStart.x;
6313 realBox.top += clientStart.y;
6314 realBox.right += clientStart.x;
6315 realBox.bottom += clientStart.y;
6321 if(realBox.right >= realBox.left &&
6322 realBox.bottom >= realBox.top)
6324 // if(!rootWindow.fullRender)
6325 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6327 for(child = children.first; child; child = child.next)
6332 box.left -= child.absPosition.x - absPosition.x;
6333 box.top -= child.absPosition.y - absPosition.y;
6334 box.right -= child.absPosition.x - absPosition.x;
6335 box.bottom -= child.absPosition.y - absPosition.y;
6336 if(box.right >= child.box.left && box.left <= child.box.right &&
6337 box.bottom >= child.box.top && box.top <= child.box.bottom)
6339 box.left -= child.clientStart.x;
6340 box.top -= child.clientStart.y;
6341 box.right -= child.clientStart.x;
6342 box.bottom -= child.clientStart.y;
6348 realBox.left += absPosition.x - rootWindow.absPosition.x;
6349 realBox.top += absPosition.y - rootWindow.absPosition.y;
6350 realBox.right += absPosition.x - rootWindow.absPosition.x;
6351 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6352 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6355 else if(this == guiApp.desktop)
6358 for(window = children.first; window; window = window.next)
6364 Box childBox = region;
6366 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6367 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6368 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6369 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6371 window.Update(childBox);
6374 window.Update(null);
6379 // rootWindow.mutex.Release();
6386 if(guiApp.windowCaptured != this)
6388 if(guiApp.windowCaptured)
6392 //Logf("Captured %s (%s)\n", caption, class.name);
6393 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6394 guiApp.windowCaptured = this;
6400 bool Destroy(int64 code)
6405 if(!destroyed && !CloseConfirmation(false)) return false;
6409 // TOCHECK: Should autoCreate be set to false here?
6420 void Move(int x, int y, int w, int h)
6422 normalAnchor = Anchor { left = x, top = y };
6423 normalSizeAnchor = SizeAnchor { size = { w, h } };
6425 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6427 if(destroyed) return;
6429 stateAnchor = normalAnchor;
6430 stateSizeAnchor = normalSizeAnchor;
6432 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6433 Position(x,y, w, h, true, true, true, true, false, true);
6437 DialogResult Modal(void)
6443 // FIXES MEMORY LEAK IF Create() FAILED
6449 void SetScrollArea(int width, int height, bool snapToStep)
6451 bool resize = false;
6454 int stepX = sbStep.x, stepY = sbStep.y;
6455 // Needed to make snapped down position match the skin's check of client area
6456 // against realvirtual
6459 SNAPDOWN(stepX, textCellW);
6460 SNAPDOWN(stepY, textCellH);
6461 stepX = Max(stepX, textCellW);
6462 stepY = Max(stepY, textCellH);
6464 if(scrollFlags.snapX)
6465 SNAPUP(width, stepX);
6466 if(scrollFlags.snapY)
6467 SNAPUP(height, stepY);
6470 reqScrollArea.w = width;
6471 reqScrollArea.h = height;
6472 noAutoScrollArea = (width > 0 || height > 0);
6474 UpdateScrollBars(true, true);
6477 void SetScrollPosition(int x, int y)
6480 sbh.Action(setPosition, x, 0);
6484 int seen = clientSize.w, total = reqScrollArea.w;
6486 if(scrollFlags.snapX)
6487 SNAPDOWN(seen, sbStep.x);
6489 if(!total) total = seen;
6490 range = total - seen + 1;
6491 range = Max(range, 1);
6493 if(x >= range) x = range - 1;
6495 if(scrollFlags.snapX)
6496 SNAPUP(x, sbStep.x);
6499 OnHScroll(setPosition, x, 0);
6503 SNAPDOWN(x, textCellW);
6509 sbv.Action(setPosition, y, 0);
6513 int seen = clientSize.h, total = reqScrollArea.h;
6516 if(scrollFlags.snapY)
6517 SNAPDOWN(seen, sbStep.y);
6519 if(!total) total = seen;
6520 range = total - seen + 1;
6521 range = Max(range, 1);
6523 if(y >= range) y = range - 1;
6525 if(scrollFlags.snapY)
6526 SNAPUP(y, sbStep.y);
6529 OnVScroll(setPosition, y, 0);
6532 SNAPDOWN(y, textCellH);
6537 UpdateCaret(false, false);
6540 void SetScrollLineStep(int stepX, int stepY)
6546 SNAPDOWN(stepX, textCellW);
6547 SNAPDOWN(stepY, textCellH);
6548 stepX = Max(stepX, textCellW);
6549 stepY = Max(stepY, textCellH);
6552 sbh.lineStep = stepX;
6554 sbv.lineStep = stepY;
6557 void SetState(WindowState newState, bool activate, Modifiers mods)
6561 if(state == newState || OnStateChange(newState, mods))
6563 WindowState prevState = state;
6567 // This used to be at the end of the brackets... moved for X, testing...
6568 // This has the effect of activating the window through the system...
6569 if(rootWindow == this)
6570 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6572 SetStateEx(newState, activate);
6574 if(rootWindow == this && !rootWindow.nativeDecorations)
6576 int x = position.x, y = position.y;
6579 x -= guiApp.desktop.absPosition.x;
6580 y -= guiApp.desktop.absPosition.y;
6582 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6586 //state = prevState;
6588 if(state != maximized && style.hasMaximize)
6591 for(child = parent.children.first; child; child = child.next)
6593 if(child != this && child.state == maximized)
6594 child.SetStateEx(normal, false);
6598 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6599 parent.UpdateScrollBars(true, true);
6602 // Do we really need this stuff here?
6603 // Shouldn't the Activate stuff take care of it?
6604 if(parent.rootWindow == parent && style)
6607 parent.FigureCaption(caption);
6608 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6609 parent.UpdateDecorations();
6613 rootWindow.ConsequentialMouseMove(false);
6620 BitmapResource GetIcon(SkinBitmap iconID)
6622 return guiApp.currentSkin.GetBitmap(iconID);
6625 void SetMouseRange(Box range)
6627 if(range || guiApp.fullScreenMode)
6632 clip.left = range.left + absPosition.x + clientStart.x;
6633 clip.top = range.top + absPosition.y + clientStart.y;
6634 clip.right = range.right + absPosition.x + clientStart.x;
6635 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6639 clip.left = guiApp.desktop.box.left;
6640 clip.top = guiApp.desktop.box.top;
6641 clip.right = guiApp.desktop.box.right;
6642 clip.bottom = guiApp.desktop.box.bottom;
6644 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6647 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6650 void SetMouseRangeToClient(void)
6652 if(guiApp.fullScreenMode || this != guiApp.desktop)
6654 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6655 box.Clip(clientArea);
6659 SetMouseRange(null);
6662 void SetMouseRangeToWindow(void)
6664 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6665 if(this == guiApp.desktop)
6666 SetMouseRangeToClient();
6671 // x, y: Desktop Coordinates
6672 void ShowSysMenu(int x, int y)
6675 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6678 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6679 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6683 menu, $"Move", m, NotifySelect = MenuWindowMove,
6684 disabled = !style.fixed || state == maximized
6688 menu, $"Size", s, NotifySelect = MenuWindowSize,
6689 disabled = !style.sizable || state != normal
6693 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6694 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6698 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6699 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6703 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6704 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6706 MenuDivider { menu };
6709 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6710 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6712 windowMenu.Create();
6717 ActivateEx(true, true, true, true, null, null);
6720 void MakeActive(void)
6722 ActivateEx(true, false, true, false, null, null);
6725 void SoftActivate(void)
6727 if(guiApp.desktop.active)
6733 void Deactivate(void)
6735 ActivateEx(false, true, true, true, null, null);
6740 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6743 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6745 bool result = false;
6746 if(activeChild && activeChild.cycle)
6748 Window modalWindow, child = activeChild;
6749 if(!clientOnly /*&& parent.tabCycle*/)
6751 Window next = child;
6754 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6758 if(parent && parent.CycleChildren(backward, false, true, true))
6766 next = next.cycle.prev.data;
6768 next = next.cycle.next.data;
6769 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6774 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6775 parent.tabCycle && parent.CycleChildren(backward, false, false))
6779 if(tabCycleOnly && !tabCycle) return false;
6786 child = child.cycle.prev.data;
6788 child = child.cycle.next.data;
6789 if(child == child.parent.activeChild)
6791 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6794 modalWindow = child.FindModal();
6797 // Scroll the window to include the active control
6798 if(sbh && !child.style.dontScrollHorz)
6800 if(child.scrolledPos.x < 0)
6801 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6802 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6803 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6805 if(sbv && !child.style.dontScrollVert)
6807 if(child.scrolledPos.y < 0)
6808 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6809 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6810 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6814 child = modalWindow ? modalWindow : child;
6815 child.ActivateEx(true, true, true, true, null, null);
6816 if(child.tabCycle && child.childrenCycle.first)
6817 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6825 ConsequentialMouseMove(false);
6829 void AddResource(Resource resource)
6833 ResPtr ptr { resource = resource };
6837 // Load Graphics here if window is created already
6838 if(/*created && */display)
6840 display.Lock(false);
6841 ptr.loaded = display.displaySystem.LoadResource(resource);
6845 // Temporary hack to load font right away for listbox in dropbox ...
6846 else if(master && master.display)
6848 master.display.Lock(false);
6849 master.display.displaySystem.LoadResource(resource);
6850 master.display.Unlock();
6856 void RemoveResource(Resource resource)
6861 for(ptr = resources.first; ptr; ptr = ptr.next)
6863 if(ptr.resource == resource)
6869 // Unload Graphics here if window is created already
6870 if(/*created && */display)
6874 display.Lock(false);
6875 display.displaySystem.UnloadResource(resource, ptr.loaded);
6881 resources.Delete(ptr);
6886 void SetCaret(int x, int y, int size)
6893 if(active && !style.interim)
6895 if(visible || !guiApp.caretOwner)
6896 guiApp.caretOwner = size ? this : null;
6898 UpdateCaret(false, false);
6901 guiApp.interfaceDriver.SetCaret(0,0,0);
6902 UpdateCaret(false, true);
6903 guiApp.caretEnabled = false;
6906 else if(style.inactive && active)
6908 guiApp.interfaceDriver.SetCaret(0,0,0);
6909 UpdateCaret(false, true);
6910 guiApp.caretEnabled = false;
6915 void Scroll(int x, int y)
6917 bool opaque = !style.drawBehind || background.a;
6918 if(opaque && display && display.flags.scrolling)
6920 Box box = clientArea;
6921 box.left += clientStart.x;
6922 box.top += clientStart.y;
6923 box.right += clientStart.x;
6924 box.bottom += clientStart.y;
6926 //scrollExtent.Free(null);
6927 scrollExtent.AddBox(box);
6928 scrolledArea.x += x;
6929 scrolledArea.y += y;
6931 //scrollExtent.Free();
6932 //scrollExtent.AddBox(clientArea);
6933 //scrollExtent.Offset(clientStart.x, clientStart.y);
6934 //scrolledArea.x = x;
6935 //scrolledArea.y = y;
6941 rootWindow.dirty = true;
6944 void ReleaseCapture()
6946 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6948 Window oldCaptured = guiApp.windowCaptured;
6949 guiApp.windowCaptured = null;
6950 guiApp.prevWindow = null;
6953 //guiApp.Log("Released Capture\n");
6955 guiApp.interfaceDriver.SetMouseCapture(null);
6957 //oldCaptured.OnMouseCaptureLost();
6960 oldCaptured.ConsequentialMouseMove(false);
6965 private void _SetCaption(char * format, va_list args)
6972 char caption[MAX_F_STRING];
6973 vsnprintf(caption, sizeof(caption), format, args);
6974 caption[sizeof(caption)-1] = 0;
6976 this.caption = CopyString(caption);
6981 firewatchers caption;
6985 /*deprecated*/ void SetText(char * format, ...)
6988 va_start(args, format);
6989 _SetCaption(format, args);
6993 void SetCaption(char * format, ...)
6996 va_start(args, format);
6997 _SetCaption(format, args);
7001 bool Grab(Bitmap bitmap, Box box, bool decorations)
7003 bool result = false;
7004 if(display || this == guiApp.desktop)
7006 Box clip = {MININT, MININT, MAXINT, MAXINT};
7012 clip.Clip(clientArea);
7014 clip.Clip(this.box);
7016 if(rootWindow != this)
7018 clip.left += absPosition.y;
7019 clip.top += absPosition.y;
7020 clip.right += absPosition.x;
7021 clip.bottom += absPosition.y;
7024 clip.left += decorations ? 0 : clientStart.x;
7025 clip.top += decorations ? 0 : clientStart.y;
7026 clip.right += decorations ? 0 : clientStart.x;
7027 clip.bottom += decorations ? 0 : clientStart.y;
7029 if(display && display.flags.flipping)
7031 rootWindow.Update(null);
7032 rootWindow.UpdateDisplay();
7039 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7040 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7044 result = display.Grab(bitmap, clip.left, clip.top,
7045 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7047 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7049 if(!bitmap.Convert(null, pixelFormat888, null))
7056 void GetMousePosition(int * x, int * y)
7058 int mouseX = 0, mouseY = 0;
7059 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7062 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7063 if(this != guiApp.desktop)
7065 mouseX -= absPosition.x + clientStart.x;
7066 mouseY -= absPosition.y + clientStart.y;
7073 DialogResult DoModal()
7075 DialogResult returnCode = 0;
7076 int terminated = terminateX;
7079 while(!destroyed && guiApp.driver != null)
7081 if(terminateX != terminated)
7083 terminated = terminateX;
7084 guiApp.desktop.Destroy(0);
7085 if(guiApp.desktop.created)
7088 //printf("Resetting terminate X to 0\n");
7094 guiApp.UpdateDisplay();
7095 if(!guiApp.ProcessInput(false))
7098 returnCode = this.returnCode;
7111 return !destroyed && guiApp.driver != null && terminateX < 2;
7114 DialogResult DoModalEnd()
7116 DialogResult returnCode = this.returnCode;
7121 // --- Window manipulation ---
7122 /*bool GetDisabled()
7124 bool disabled = this.disabled;
7126 for(window = this; (window = window.master); )
7137 // --- Mouse Manipulation ---
7138 void GetNCMousePosition(int * x, int * y)
7140 GetMousePosition(x, y);
7141 if(x) *x += clientStart.x;
7142 if(y) *y += clientStart.y;
7145 // --- Carets manipulation ---
7146 void GetCaretPosition(Point caretPos)
7148 caretPos = this.caretPos;
7151 int GetCaretSize(void)
7156 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7162 bool CloseConfirmation(bool parentClosing)
7175 if(!OnClose(parentClosing))
7178 // If you want to skip this, simply set modifiedDocument to false in OnClose
7179 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7181 DialogResult dialogRes;
7184 sprintf(message, $"Save changes to %s?", fileName);
7186 sprintf(message, $"Save changes to Untitled %d?", documentID);
7188 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7190 if(dialogRes == yes)
7192 // TOFIX: Precomp error if brackets are taken out
7193 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7195 else if(dialogRes == cancel)
7201 for(slave = slaves.first; slave; slave = slave.next)
7203 Window w = slave.data;
7204 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7206 // ((Window)slave.data).CloseConfirmation(true);
7215 for(child = children.first; child; child = child.next)
7216 if(child.master != this && !child.CloseConfirmation(true))
7226 // Static methods... move them somewhere else?
7227 void ::RestoreCaret()
7229 if(guiApp.caretOwner)
7230 guiApp.caretOwner.UpdateCaret(false, false);
7233 void ::FreeMouseRange()
7235 guiApp.interfaceDriver.SetMouseRange(null, null);
7239 bool MenuFileClose(MenuItem selection, Modifiers mods)
7241 Window document = activeChild;
7243 document.Destroy(0);
7247 bool MenuFileExit(MenuItem selection, Modifiers mods)
7253 bool MenuFileSave(MenuItem selection, Modifiers mods)
7257 fileMonitor.fileName = null;
7260 if(OnSaveFile(fileName))
7262 //if(OnFileModified != Window::OnFileModified)
7265 fileMonitor.fileName = fileName;
7271 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7272 DialogResult answer = dialog.Modal();
7274 if(answer != yes) return (bool)answer;
7277 return MenuFileSaveAs(selection, mods);
7280 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7282 DialogResult result = (DialogResult)bool::true;
7283 FileDialog fileDialog = saveDialog;
7286 fileDialog = FileDialog {};
7291 fileDialog.filePath = fileName;
7294 char filePath[MAX_FILENAME];
7295 sprintf(filePath, "Untitled %d", documentID);
7296 fileDialog.filePath = filePath;
7298 fileMonitor.fileName = null;
7300 fileDialog.type = save;
7301 fileDialog.text = $"Save As";
7305 fileDialog.master = master.parent ? master : this;
7306 if(fileDialog.Modal() == ok)
7308 char * filePath = fileDialog.filePath;
7310 if(OnSaveFile(filePath))
7313 property::fileName = filePath;
7314 NotifySaved(master, this, filePath);
7319 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7320 DialogResult answer = dialog.Modal();
7335 //if(OnFileModified != Window::OnFileModified && fileName)
7338 fileMonitor.fileName = fileName;
7342 return (bool)result; // Actually returning result from Yes/NoCancel message box
7345 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7347 Window document = activeChild;
7349 for(document = children.first; document; document = next)
7351 next = document.next;
7352 if(document.style.isDocument || document.fileName)
7353 document.MenuFileSave(selection, mods);
7358 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7362 for(document = children.first; document; document = document.next)
7363 //if(document.style.isDocument && document.state == minimized)
7364 if(document.style.isActiveClient && document.state == minimized)
7365 document.SetState(minimized, false, mods);
7369 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7371 Window document = activeChild;
7374 Window firstDocument = null;
7376 OldLink cycle = document.cycle.prev;
7381 if(child.style.isActiveClient && !child.style.hidden)
7385 firstDocument = child;
7386 if(child.state == minimized)
7387 child.SetState(minimized, false, mods);
7390 child.positionID = id++;
7391 child.SetState(normal, false, mods);
7392 child.anchor.left.type = cascade;
7395 child.normalSizeAnchor = *&child.sizeAnchor;
7396 child.normalAnchor = child.anchor;
7398 // Break the anchors for moveable/resizable windows
7399 if(child.style.fixed)
7401 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7403 (*&child.normalAnchor).left = x;
7404 (*&child.normalAnchor).top = y;
7405 (*&child.normalAnchor).right.type = none;
7406 (*&child.normalAnchor).bottom.type = none;
7408 child.normalSizeAnchor.isClientW = false;
7409 child.normalSizeAnchor.isClientH = false;
7410 child.normalSizeAnchor.size.w = w;
7411 child.normalSizeAnchor.size.h = h;
7412 child.anchored = false;
7415 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7417 child.stateAnchor = child.normalAnchor;
7418 child.stateSizeAnchor = child.normalSizeAnchor;
7420 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7421 child.Position(x, y, w, h, true, true, true, true, false, false);
7426 last = children.last;
7427 if(!child.style.stayOnTop)
7428 for(; last && last.style.stayOnTop; last = last.prev);
7429 children.Move(child, last);
7430 childrenOrder.Move(child.order, childrenOrder.last);
7432 if(cycle == document.cycle) break;
7436 firstDocument.Activate();
7441 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7448 // Close all closes all active clients, not all documents
7449 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7451 Window next, document;
7453 for(document = children.first; document; document = next)
7455 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7456 if(document.style.isActiveClient)
7457 if(!document.Destroy(0) && !document.style.hidden)
7463 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7465 if(style.hasMaximize && state != maximized)
7466 SetState(maximized, 0, 0);
7470 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7472 if(style.hasMinimize && state != minimized)
7474 SetState(minimized, 0, 0);
7475 parent.CycleChildren(false, true, false, true);
7480 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7482 MenuMoveOrSize(false, selection ? true : false);
7486 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7488 CycleChildren(false, true, false, true);
7492 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7494 CycleChildren(true, true, false, true);
7498 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7500 MenuMoveOrSize(true, true);
7504 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7507 SetState(normal, 0, 0);
7511 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7514 int64 id = selection.id;
7515 OldLink cycle = activeClient.cycle;
7517 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7520 Window sibling = cycle.data;
7521 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7529 document = cycle.data;
7530 document.Activate();
7532 //if(activeChild.state == maximized)
7533 // document.SetState(maximized, false, mods);
7534 //else if(document.state == minimized)
7535 // document.SetState(normal, false, mods);
7539 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7541 stayOnTop = !style.stayOnTop;
7545 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7547 Window document = activeChild;
7550 Window firstDocument = null;
7551 OldLink cycle = document.cycle;
7555 Window child = cycle.data;
7556 if(child.style.isActiveClient && !child.style.hidden)
7558 if(!firstDocument) firstDocument = child;
7559 if(child.state == minimized)
7560 child.SetState(minimized, false, mods);
7563 child.positionID = id++;
7564 child.SetState(normal, false, mods);
7565 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7567 child.anchor.left.type = hTiled;
7570 child.normalSizeAnchor = *&child.sizeAnchor;
7571 child.normalAnchor = child.anchor;
7573 // Break the anchors for moveable/resizable windows
7574 if(child.style.fixed)
7576 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7578 (*&child.normalAnchor).left = x;
7579 (*&child.normalAnchor).top = y;
7580 (*&child.normalAnchor).right.type = none;
7581 (*&child.normalAnchor).bottom.type = none;
7582 child.normalSizeAnchor.isClientW = false;
7583 child.normalSizeAnchor.isClientH = false;
7584 child.normalSizeAnchor.size.w = w;
7585 child.normalSizeAnchor.size.h = h;
7586 child.anchored = false;
7589 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7591 child.stateAnchor = child.normalAnchor;
7592 child.stateSizeAnchor = child.normalSizeAnchor;
7594 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7595 child.Position(x,y, w, h, true, true, true, true, false, true);
7600 if((cycle = cycle.next) == document.cycle) break;
7603 firstDocument.Activate();
7608 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7610 Window document = activeChild;
7613 Window firstDocument = null;
7615 OldLink cycle = document.cycle;
7620 //if(child.style.isDocument)
7621 if(child.style.isActiveClient && !child.style.hidden)
7623 if(!firstDocument) firstDocument = child;
7624 if(child.state == minimized)
7625 child.SetState(minimized, false, mods);
7628 child.positionID = id++;
7629 child.SetState(normal, false, mods);
7630 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7632 child.anchor.left.type = vTiled;
7635 child.normalSizeAnchor = *&child.sizeAnchor;
7636 child.normalAnchor = child.anchor;
7638 // Break the anchors for moveable/resizable windows
7639 if(child.style.fixed)
7641 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7643 (*&child.normalAnchor).left = x;
7644 (*&child.normalAnchor).top = y;
7645 (*&child.normalAnchor).right.type = none;
7646 (*&child.normalAnchor).bottom.type = none;
7647 child.normalSizeAnchor.isClientW = false;
7648 child.normalSizeAnchor.isClientH = false;
7649 child.normalSizeAnchor.size.w = w;
7650 child.normalSizeAnchor.size.h = h;
7651 child.anchored = false;
7654 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7656 child.stateAnchor = child.normalAnchor;
7657 child.stateSizeAnchor = child.normalSizeAnchor;
7659 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7660 child.Position(x,y, w, h, true, true, true, true, false, true);
7665 if((cycle = cycle.next) == document.cycle) break;
7668 firstDocument.Activate();
7673 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7675 WindowList dialog { master = this };
7676 Window document = (Window)dialog.Modal();
7679 if(activeChild.state == maximized)
7680 document.SetState(maximized, false, mods);
7681 else if(document.state == minimized)
7682 document.SetState(normal, false, mods);
7683 document.Activate();
7689 virtual bool OnCreate(void);
7690 virtual void OnDestroy(void);
7691 virtual void OnDestroyed(void);
7692 virtual bool OnClose(bool parentClosing);
7693 virtual bool OnStateChange(WindowState state, Modifiers mods);
7694 virtual bool OnPostCreate(void);
7695 virtual bool OnMoving(int *x, int *y, int w, int h);
7696 virtual bool OnResizing(int *width, int *height);
7697 virtual void OnResize(int width, int height);
7698 virtual void OnPosition(int x, int y, int width, int height);
7699 virtual bool OnLoadGraphics(void);
7700 virtual void OnApplyGraphics(void);
7701 virtual void OnUnloadGraphics(void);
7702 virtual void OnRedraw(Surface surface);
7703 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7704 virtual void OnActivateClient(Window client, Window previous);
7705 virtual bool OnKeyDown(Key key, unichar ch);
7706 virtual bool OnKeyUp(Key key, unichar ch);
7707 virtual bool OnKeyHit(Key key, unichar ch);
7708 virtual bool OnSysKeyDown(Key key, unichar ch);
7709 virtual bool OnSysKeyUp(Key key, unichar ch);
7710 virtual bool OnSysKeyHit(Key key, unichar ch);
7711 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7712 virtual bool OnMouseLeave(Modifiers mods);
7713 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7714 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7715 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7716 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7717 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7718 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7719 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7720 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7721 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7722 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7723 virtual void OnMouseCaptureLost(void);
7724 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7725 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7726 virtual void OnDrawOverChildren(Surface surface);
7727 virtual bool OnFileModified(FileChange fileChange, char * param);
7728 virtual bool OnSaveFile(char * fileName);
7730 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7731 // Note: A 'client' would refer to isActiveClient, rather than
7732 // being confined to the 'client area' (nonClient == false)
7733 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7734 virtual void OnChildVisibilityToggled(Window child, bool visible);
7735 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7737 // Skins Virtual Functions
7738 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7739 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7740 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7745 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7746 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7747 virtual bool IsMouseMoving(int x, int y, int w, int h)
7751 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7755 virtual void UpdateNonClient();
7756 virtual void SetBox(Box box);
7757 virtual bool IsInside(int x, int y)
7759 return box.IsPointInside({x, y});
7761 virtual bool IsOpaque()
7763 return (!style.drawBehind || background.a == 255);
7767 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7768 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7769 virtual void Window::NotifySaved(Window window, char * filePath);
7774 property Window parent
7776 property_category $"Layout"
7779 if(value || guiApp.desktop)
7782 Window oldParent = parent;
7783 Anchor anchor = this.anchor;
7785 if(value && value.IsDescendantOf(this)) return;
7786 if(value && value == this)
7788 if(!value) value = guiApp.desktop;
7790 if(value == oldParent) return;
7792 if(!master || (master == this.parent && master == guiApp.desktop))
7793 property::master = value;
7797 parent.children.Remove(this);
7801 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7802 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7803 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7804 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7808 last = value.children.last;
7810 if(style.isDocument)
7813 parent.numDocuments--;
7814 documentID = value.GetDocumentID();
7817 if(style.isActiveClient && !style.hidden)
7819 if(parent && parent != guiApp.desktop && !(style.hidden))
7821 if(state == minimized) parent.numIcons--;
7822 parent.numPositions--;
7826 if(!style.stayOnTop)
7827 for(; last && last.style.stayOnTop; last = last.prev);
7829 value.children.Insert(last, this);
7831 // *** NEW HERE: ***
7833 parent.childrenCycle.Delete(cycle);
7835 parent.childrenOrder.Delete(order);
7838 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7839 // Should something else be done?
7840 if(parent && parent.activeChild == this)
7841 parent.activeChild = null;
7842 if(parent && parent.activeClient == this)
7843 parent.activeClient = null;
7849 int x = position.x, y = position.y, w = size.w, h = size.h;
7853 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7854 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7856 vpw = value.clientSize.w;
7857 vph = value.clientSize.h;
7863 else if(style.fixed)
7865 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7866 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7869 anchor = this.anchor;
7871 if(anchor.left.type == offset) anchor.left.distance = x;
7872 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7873 if(anchor.top.type == offset) anchor.top.distance = y;
7874 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7875 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7876 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7877 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7878 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7879 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7880 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7882 if(!anchor.left.type && !anchor.right.type)
7884 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7885 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7887 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7888 if(!anchor.top.type && !anchor.bottom.type)
7890 anchor.vert.distance = (y + h / 2) - (vph / 2);
7891 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7893 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7896 parent.OnChildAddedOrRemoved(this, false);
7902 parent.childrenCycle.Insert(
7903 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
7904 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7906 cycle = OldLink { data = this });
7907 parent.childrenOrder.Insert(
7908 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7909 order = OldLink { data = this });
7912 if(!style.hidden && style.isActiveClient)
7914 positionID = parent.GetPositionID(this);
7915 parent.numPositions++;
7916 if(state == minimized) parent.numIcons--;
7919 // *** FONT INHERITANCE ***
7920 if(!setFont && oldParent)
7921 stopwatching(oldParent, font);
7925 RemoveResource(systemFont);
7928 // TESTING WITH WATCHERS:
7929 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7930 // usedFont = setFont ? setFont : (systemFont);
7934 if(guiApp.currentSkin)
7936 systemFont = guiApp.currentSkin.SystemFont();
7939 usedFont = systemFont;
7940 AddResource(systemFont);
7948 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7957 if(value.rootWindow && value.rootWindow.display && rootWindow)
7959 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7960 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7963 UnloadGraphics(false);
7966 LoadGraphics(false, false);
7969 if(value.rootWindow != rootWindow)
7970 DisplayModeChanged();
7974 scrolledPos.x = MININT; // Prevent parent update
7976 bool anchored = this.anchored;
7977 property::anchor = anchor;
7978 this.anchored = anchored;
7983 if(guiApp.currentSkin)
7984 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7986 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7987 Position(x, y, w, h, true, true, true, true, false, true);
7992 // else parent = value;
7994 oldParent.OnChildAddedOrRemoved(this, true);
7997 get { return parent; }
8000 property Window master
8002 property_category $"Behavior"
8005 //if(this == value) return;
8006 if(value && value.IsSlaveOf(this)) return;
8012 OldLink slaveHolder;
8013 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
8014 if(slaveHolder.data == this)
8016 master.slaves.Delete(slaveHolder);
8023 value.slaves.Add(OldLink { data = this });
8028 master.hotKeys.Remove(hotKey);
8029 value.hotKeys.Add(hotKey);
8032 if(master && master.defaultControl == this)
8033 master.defaultControl = null;
8035 if(style.isDefault && !value.defaultControl)
8036 value.defaultControl = this;
8041 get { return master ? master : parent; }
8044 property char * caption
8046 property_category $"Appearance"
8053 caption = new char[strlen(value)+1];
8055 strcpy(caption, value);
8060 get { return caption; }
8065 property_category $"Behavior"
8074 master.hotKeys.Add(hotKey = HotKeySlot { });
8078 hotKey.window = this;
8083 master.hotKeys.Delete(hotKey);
8088 get { return hotKey ? hotKey.key : 0; }
8091 property Color background
8093 property_category $"Appearance"
8096 background.color = value;
8101 if(this == rootWindow)
8102 guiApp.interfaceDriver.SetRootWindowColor(this);
8105 get { return background.color; }
8108 property Percentage opacity
8110 property_category $"Appearance"
8113 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8114 drawBehind = (background.a == 255) ? false : true;
8116 get { return background.a / 255.0f; }
8119 property Color foreground
8121 property_category $"Appearance"
8129 get { return foreground; }
8132 property BorderStyle borderStyle
8134 property_category $"Appearance"
8137 if(!((BorderBits)value).fixed)
8139 style.hasClose = false;
8140 style.hasMaximize = false;
8141 style.hasMinimize = false;
8142 nativeDecorations = false;
8144 style.borderBits = value;
8148 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8150 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8151 Position(x, y, w, h, true, true, true, true, false, true);
8152 CreateSystemChildren();
8155 get { return (BorderStyle)style.borderBits; }
8158 property Size minClientSize
8160 property_category $"Layout"
8161 set { minSize = value; }
8162 get { value = minSize; }
8165 property Size maxClientSize
8167 property_category $"Layout"
8168 set { maxSize = value; }
8169 get { value = maxSize; }
8172 property bool hasMaximize
8174 property_category $"Window Style"
8177 style.hasMaximize = value;
8178 if(value) { style.fixed = true; style.contour = true; }
8182 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8184 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8185 Position(x, y, w, h, true, true, true, true, false, true);
8187 CreateSystemChildren();
8190 get { return style.hasMaximize; }
8193 property bool hasMinimize
8195 property_category $"Window Style"
8198 style.hasMinimize = value;
8199 if(value) { style.fixed = true; style.contour = true; }
8203 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8205 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8206 Position(x, y, w, h, true, true, true, true, false, true);
8208 CreateSystemChildren();
8211 get { return style.hasMinimize; }
8214 property bool hasClose
8216 property_category $"Window Style"
8219 style.hasClose = value;
8220 if(value) { style.fixed = true; style.contour = true; }
8224 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8225 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8226 Position(x, y, w, h, true, true, true, true, false, true);
8227 CreateSystemChildren();
8230 get { return style.hasClose; }
8233 property bool nonClient
8235 property_category $"Layout"
8238 style.nonClient = value;
8240 style.stayOnTop = true;
8242 get { return style.nonClient; }
8245 property bool inactive
8247 property_category $"Behavior"
8252 // *** NEW HERE: ***
8256 parent.childrenCycle.Delete(cycle);
8258 parent.childrenOrder.Delete(order);
8265 active = false; // true;
8266 if(parent.activeChild == this)
8267 parent.activeChild = null;
8268 if(parent.activeClient == this)
8269 parent.activeClient = null;
8278 parent.childrenCycle.Insert(
8279 // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
8280 //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8282 cycle = OldLink { data = this });
8284 parent.childrenOrder.Insert(
8285 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8286 order = OldLink { data = this });
8289 style.inactive = value;
8291 get { return style.inactive; }
8294 property bool clickThrough
8296 property_category $"Behavior"
8297 set { style.clickThrough = value; }
8298 get { return style.clickThrough; }
8301 property bool isRemote
8303 property_category $"Behavior"
8304 set { style.isRemote = value; }
8305 get { return style.isRemote; }
8308 property bool noCycle
8310 property_category $"Behavior"
8311 set { style.noCycle = value; }
8312 get { return style.noCycle; }
8315 property bool isModal
8317 property_category $"Behavior"
8318 set { style.modal = value; }
8319 get { return style.modal; }
8322 property bool interim
8324 property_category $"Behavior"
8325 set { style.interim = value; }
8326 get { return style.interim; }
8329 property bool tabCycle
8331 property_category $"Behavior"
8332 set { style.tabCycle = value; }
8333 get { return style.tabCycle; }
8336 property bool isDefault
8338 property_category $"Behavior"
8346 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8347 if(sibling != this && sibling.style.isDefault)
8348 sibling.style.isDefault = false;*/
8349 if(master.defaultControl)
8350 master.defaultControl.style.isDefault = false;
8351 master.defaultControl = this;
8353 else if(master.defaultControl == this)
8354 master.defaultControl = null;
8358 style.isDefault = value;
8360 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8362 get { return style.isDefault; }
8365 property bool drawBehind
8367 property_category $"Window Style"
8368 set { style.drawBehind = value; }
8369 get { return style.drawBehind; }
8372 property bool hasMenuBar
8374 property_category $"Window Style"
8384 if(created && !menuBar)
8391 anchor = Anchor { top = 23, left = 1, right = 1 },
8393 inactive = true, nonClient = true
8398 else if(created && menuBar)
8403 style.hasMenuBar = value;
8405 get { return style.hasMenuBar; }
8408 property bool hasStatusBar
8410 property_category $"Window Style"
8417 statusBar = StatusBar { this };
8425 style.hasStatusBar = value;
8427 get { return style.hasStatusBar; }
8429 property bool stayOnTop
8431 property_category $"Window Style"
8436 if(created && !style.stayOnTop)
8438 if(rootWindow == this)
8439 guiApp.interfaceDriver.OrderRootWindow(this, true);
8440 else if(parent.children.last != this)
8442 parent.children.Move(this, parent.children.last);
8446 style.stayOnTop = true;
8450 if(created && style.stayOnTop)
8452 if(rootWindow == this)
8453 guiApp.interfaceDriver.OrderRootWindow(this, false);
8460 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8461 order && ((Window)order.data).style.stayOnTop;
8462 order = (order == parent.childrenOrder.first) ? null : order.prev);
8463 last = order ? order.data : null;
8467 for(last = parent.children.last;
8468 last && last.style.stayOnTop;
8472 parent.children.Move(this, last);
8476 style.stayOnTop = false;
8479 get { return style.stayOnTop; }
8484 property_category $"Window Style"
8494 if(menuBar && !value)
8501 if(!menuBar && style.hasMenuBar && value)
8505 this, menu = value, isMenuBar = true,
8506 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8507 inactive = true, nonClient = true
8511 UpdateActiveDocument(null);
8514 get { return menu; }
8517 property FontResource font
8519 property_category $"Appearance"
8521 isset { return setFont ? true : false; }
8526 if(value && !setFont) { stopwatching(parent, font); }
8527 else if(!value && setFont)
8533 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8542 RemoveResource(setFont);
8547 RemoveResource(systemFont);
8554 AddResource(setFont);
8557 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8560 systemFont = guiApp.currentSkin.SystemFont();
8562 usedFont = systemFont;
8563 AddResource(systemFont);
8571 get { return usedFont; }
8574 property SizeAnchor sizeAnchor
8576 property_category $"Layout"
8579 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8580 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8581 sizeAnchor.isClientW != sizeAnchor.isClientH;
8588 normalSizeAnchor = sizeAnchor;
8590 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8592 stateAnchor = normalAnchor;
8593 stateSizeAnchor = normalSizeAnchor;
8595 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8596 Position(x,y, w, h, true, true, true, true, false, true);
8603 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8604 sizeAnchor.isClientW,
8605 sizeAnchor.isClientH
8612 property_category $"Layout"
8615 Anchor thisAnchor = anchor;
8616 SizeAnchor thisSizeAnchor = sizeAnchor;
8617 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8618 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8619 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8620 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8621 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8622 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8628 sizeAnchor.isClientW = false;
8629 sizeAnchor.isClientH = false;
8630 sizeAnchor.size = value;
8632 normalSizeAnchor = sizeAnchor;
8634 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8636 stateAnchor = normalAnchor;
8637 stateSizeAnchor = normalSizeAnchor;
8639 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8640 Position(x, y, w, h, true, true, true, true, false, true);
8641 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8644 get { value = size; }
8647 property Size clientSize
8649 property_category $"Layout"
8652 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8653 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8654 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8659 sizeAnchor.isClientW = true;
8660 sizeAnchor.isClientH = true;
8661 sizeAnchor.size = value;
8663 normalSizeAnchor = sizeAnchor;
8665 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8667 stateAnchor = normalAnchor;
8668 stateSizeAnchor = normalSizeAnchor;
8670 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8671 Position(x,y, w, h, true, true, true, true, false, true);
8674 get { value = clientSize; }
8677 property Size initSize { get { value = sizeAnchor.size; } };
8679 property Anchor anchor
8681 property_category $"Layout"
8682 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8688 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8690 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8691 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8693 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8695 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8696 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8700 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8702 anchor.left.distance = 0;
8703 anchor.horz.type = 0;
8705 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8707 anchor.top.distance = 0;
8708 anchor.vert.type = 0;
8717 normalAnchor = anchor;
8719 // Break the anchors for moveable/resizable windows
8720 /*if(style.fixed ) //&& value.left.type == cascade)
8722 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8724 this.anchor = normalAnchor = Anchor { left = x, top = y };
8725 normalSizeAnchor = SizeAnchor { { w, h } };
8728 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8730 stateAnchor = normalAnchor;
8731 stateSizeAnchor = normalSizeAnchor;
8733 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8734 Position(x, y, w, h, true, true, true, true, false, true);
8743 get { value = this ? anchor : Anchor { }; }
8746 property Point position
8748 property_category $"Layout"
8751 if(value == null) return;
8753 anchor.left = value.x;
8754 anchor.top = value.y;
8755 anchor.right.type = none;
8756 anchor.bottom.type = none;
8761 normalAnchor = anchor;
8763 // Break the anchors for moveable/resizable windows
8767 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8769 normalAnchor.left = x;
8770 normalAnchor.top = y;
8771 normalAnchor.right.type = none;
8772 normalAnchor.bottom.type = none;
8773 normalSizeAnchor.size.width = w;
8774 normalSizeAnchor.size.height = h;
8778 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8780 stateAnchor = normalAnchor;
8781 stateSizeAnchor = normalSizeAnchor;
8783 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8784 Position(x,y, w, h, true, true, true, true, false, true);
8788 get { value = position; }
8791 property bool disabled
8793 property_category $"Behavior"
8796 if(this && disabled != value)
8803 get { return (bool)disabled; }
8806 property bool isEnabled
8811 for(parent = this; parent; parent = parent.parent)
8818 property WindowState state
8820 property_category $"Behavior"
8821 set { SetState(value, false, 0); }
8822 get { return this ? state : 0; }
8825 property bool visible
8827 property_category $"Behavior"
8830 if(this && !value && !style.hidden && parent)
8832 bool wasActiveChild = parent.activeChild == this;
8833 Window client = null;
8835 style.hidden = true;
8836 if(style.isActiveClient)
8838 parent.numPositions--;
8839 if(state == minimized) parent.numIcons--;
8844 OldLink prevOrder = null;
8846 if(rootWindow == this)
8847 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8850 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8853 box.left -= parent.clientStart.x;
8854 box.top -= parent.clientStart.y;
8855 box.right -= parent.clientStart.x;
8856 box.bottom -= parent.clientStart.y;
8860 if(_isModal && master && master.modalSlave == this)
8861 master.modalSlave = null;
8865 OldLink tmpPrev = order.prev;
8866 client = tmpPrev ? tmpPrev.data : null;
8867 if(client && !client.style.hidden && !client.destroyed && client.created)
8868 prevOrder = tmpPrev;
8871 client = tmpPrev ? tmpPrev.data : null;
8872 if(client == this) { client = null; break; }
8873 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8875 tmpPrev = client.order.prev;
8880 prevOrder = tmpPrev;
8885 // If this window can be an active client, make sure the next window we activate can also be one
8886 if(!style.nonClient && style.isActiveClient)
8888 tmpPrev = prevOrder;
8891 client = tmpPrev ? tmpPrev.data : null;
8892 if(client == this) { client = null; break; }
8893 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8895 tmpPrev = client.order.prev;
8900 prevOrder = tmpPrev;
8904 if(client && client.style.hidden) client = null;
8908 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8910 if(order && prevOrder && prevOrder.data != this)
8911 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8913 ActivateEx(false, false, false, true, null, null);
8915 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8916 if(parent.activeClient == this)
8918 parent.activeClient = null;
8919 parent.UpdateActiveDocument(null);
8922 else if(parent.activeClient == this)
8924 parent.activeClient = client;
8925 parent.UpdateActiveDocument(this);
8928 // *** Not doing this anymore ***
8931 parent.childrenCycle.Delete(cycle);
8933 parent.childrenOrder.Delete(order);
8938 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8943 else if(this && value && style.hidden)
8945 style.hidden = false;
8948 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8949 if(rootWindow == this)
8950 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8952 if(_isModal && master)
8953 master.modalSlave = this;
8955 if(style.isActiveClient)
8957 positionID = parent.GetPositionID(this);
8958 parent.numPositions++;
8959 if(state == minimized) parent.numIcons++;
8962 // *** NOT DOING THIS ANYMORE ***
8964 if(!(style.inactive))
8966 if(!(style.noCycle))
8968 cycle = parent.childrenCycle.AddAfter(
8969 (parent.activeChild && parent.activeChild.cycle) ?
8970 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8973 order = parent.childrenOrder.AddAfter(
8974 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8981 if(true || !parent.activeChild)
8982 ActivateEx(true, false, true, true, null, null);
8984 if(creationActivation == activate)
8985 ActivateEx(true, false, true, true, null, null);
8986 else if(creationActivation == flash && !object)
8989 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8993 ConsequentialMouseMove(false);
8999 style.hidden = !value;
9002 get { return (style.hidden || !setVisible) ? false : true; }
9005 property bool isDocument
9007 property_category $"Document"
9008 set { style.isDocument = value; }
9009 get { return style.isDocument; }
9012 property bool mergeMenus
9014 property_category $"Window Style"
9015 set { mergeMenus = value; }
9016 get { return (bool)mergeMenus; }
9019 property bool hasHorzScroll
9021 property_category $"Window Style"
9026 if(!style.hasHorzScroll && created)
9028 CreateSystemChildren();
9029 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9032 else if(style.hasHorzScroll)
9036 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9038 style.hasHorzScroll = value;
9041 get { return style.hasHorzScroll; }
9044 property bool hasVertScroll
9046 property_category $"Window Style"
9051 if(!style.hasVertScroll && created)
9053 style.hasVertScroll = true;
9054 CreateSystemChildren();
9055 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9058 else if(style.hasVertScroll)
9062 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9064 style.hasVertScroll = value;
9066 get { return style.hasVertScroll; }
9069 property bool dontHideScroll
9071 property_category $"Behavior"
9074 scrollFlags.dontHide = value;
9077 //UpdateScrollBars(true, true);
9078 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9082 // UpdateScrollBars(true, true);
9083 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9086 get { return scrollFlags.dontHide; }
9089 property bool dontScrollVert
9091 property_category $"Behavior"
9092 set { style.dontScrollVert = value; }
9093 get { return style.dontScrollVert; }
9095 property bool dontScrollHorz
9097 property_category $"Behavior"
9098 set { style.dontScrollHorz = value; }
9099 get { return style.dontScrollHorz; }
9102 property bool snapVertScroll
9104 property_category $"Behavior"
9107 scrollFlags.snapY = value;
9108 if(sbv) sbv.snap = value;
9110 get { return scrollFlags.snapY; }
9112 property bool snapHorzScroll
9114 property_category $"Behavior"
9117 scrollFlags.snapX = value;
9118 if(sbh) sbh.snap = value;
9120 get { return scrollFlags.snapX; }
9123 property Point scroll
9125 property_category $"Behavior"
9126 set { SetScrollPosition(value.x, value.y); }
9127 get { value = scroll; }
9130 property bool modifyVirtualArea
9132 property_category $"Behavior"
9133 set { modifyVirtArea = value; }
9134 get { return (bool)modifyVirtArea; }
9137 property bool dontAutoScrollArea
9139 property_category $"Behavior"
9140 // Activating a child control out of view will automatically scroll to make it in view
9141 set { noAutoScrollArea = value; }
9142 get { return (bool)noAutoScrollArea; }
9145 property char * fileName
9147 property_category $"Document"
9150 if(menu && ((!fileName && value) || (fileName && !value)))
9152 MenuItem item = menu.FindItem(MenuFileSave, 0);
9153 if(item) item.disabled = !modifiedDocument && value;
9158 if(value && value[0])
9159 fileName = CopyString(value);
9161 if(parent && this == parent.activeClient)
9162 parent.UpdateActiveDocument(null);
9166 // if(style.isDocument)
9168 fileMonitor.fileName = value;
9170 get { return fileName; }
9175 property_category $"Data"
9180 property bool modifiedDocument
9182 property_category $"Document"
9185 if(style.isDocument || fileName)
9189 MenuItem item = menu.FindItem(MenuFileSave, 0);
9190 if(item) item.disabled = !value && fileName;
9194 if(modifiedDocument != value)
9196 modifiedDocument = value;
9197 if(style.isDocument || fileName)
9201 get { return (bool)modifiedDocument; }
9204 property bool showInTaskBar
9206 property_category $"Window Style"
9207 set { style.showInTaskBar = value; }
9208 get { return (style.showInTaskBar; }
9210 property FileDialog saveDialog { set { saveDialog = value; } };
9211 property bool isActiveClient
9213 property_category $"Behavior"
9214 set { style.isActiveClient = value; }
9215 get { return style.isActiveClient; }
9218 property Cursor cursor
9220 property_category $"Appearance"
9224 SelectMouseCursor();
9226 get { return cursor; }
9229 //#if !defined(ECERE_VANILLA)
9230 property char * name
9232 property_category $"Design"
9235 return (this && object) ? object.name : null;
9240 activeDesigner.RenameObject(object, value);
9244 property char * displayDriver
9246 property_category $"Behavior"
9249 dispDriver = GetDisplayDriver(value);
9250 //DisplayModeChanged();
9254 return dispDriver ? dispDriver.name : null;
9258 // RUNTIME PROPERTIES
9259 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9260 property Size scrollArea
9262 property_category $"Behavior"
9266 SetScrollArea(value.w, value.h, false);
9268 SetScrollArea(0,0, true);
9270 get { value = scrollArea; }
9273 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9278 property_category $"Layout"
9279 set { if(this) is3D = value; }
9280 get { return (bool)is3D; }
9283 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9285 // Will be merged with font later
9286 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9287 property Point clientStart { get { value = clientStart; } };
9288 property Point absPosition { get { value = absPosition; } };
9289 property Anchor normalAnchor { get {value = normalAnchor; } };
9290 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9291 property bool active { get { return (bool)active; } };
9292 property bool created { get { return (bool)created; } };
9293 property bool destroyed { get { return (bool)destroyed; } };
9294 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9295 property Window firstChild { get { return children.first; } };
9296 property Window lastChild { get { return children.last; } };
9297 property Window activeClient { get { return activeClient; } };
9298 property Window activeChild { get { return activeChild; } };
9299 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9300 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9301 property ScrollBar horzScroll { get { return sbh; } };
9302 property ScrollBar vertScroll { get { return sbv; } };
9303 property StatusBar statusBar { get { return statusBar; } };
9304 property Window rootWindow { get { return rootWindow; } };
9305 property bool closing { get { return (bool)closing; } set { closing = value; } };
9306 property int documentID { get { return documentID; } };
9307 property Window previous { get { return prev; } }
9308 property Window next { get { return next; } }
9309 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9310 property PopupMenu menuBar { get { return menuBar; } }
9311 property ScrollBar sbv { get { return sbv; } }
9312 property ScrollBar sbh { get { return sbh; } }
9313 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9314 property void * systemHandle { get { return windowHandle; } }
9315 property Button minimizeButton { get { return sysButtons[0]; } };
9316 property Button maximizeButton { get { return sysButtons[1]; } };
9317 property Button closeButton { get { return sysButtons[2]; } };
9318 property BitmapResource icon
9320 get { return icon; }
9324 if(icon) incref icon;
9326 guiApp.interfaceDriver.SetIcon(this, value);
9329 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9330 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9331 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9332 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9333 property bool nativeDecorations
9335 get { return (bool)nativeDecorations; }
9336 set { nativeDecorations = value; }
9337 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9340 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9341 bool result = false;
9342 if(nativeDecorations)
9344 if(rootWindow == this)
9348 if(formDesigner && activeDesigner)
9350 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9351 Window form = cd ? cd.form : null;
9352 if(form && parent == form.parent)
9357 return result != style.fixed;
9361 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9363 property char * text
9365 property_category $"Deprecated"
9367 set { property::caption = value; }
9368 get { return property::caption; }
9374 WindowBits style; // Window Style
9375 char * caption; // Name / Caption
9376 Window parent; // Parent window
9377 OldList children; // List of children in Z order
9378 Window activeChild; // Child window having focus
9379 Window activeClient;
9380 Window previousActive; // Child active prior to activating the default child
9381 Window master; // Window owning and receiving notifications concerning this window
9382 OldList slaves; // List of windows belonging to this window
9383 Display display; // Display this window is drawn into
9385 Point position; // Position in parent window client area
9386 Point absPosition; // Absolute position
9387 Point clientStart; // Client area position from (0,0) in this window
9389 Size clientSize; // Client area size
9390 Size scrollArea; // Virtual Scroll area size
9391 Size reqScrollArea; // Requested virtual area size
9392 Point scroll; // Virtual area scrolling position
9393 ScrollBar sbh, sbv; // Scrollbar window handles
9394 Cursor cursor; // Mouse cursor used for this window
9397 StatusBar statusBar;
9398 Button sysButtons[3];
9400 Box clientArea; // Client Area box clipped to parent
9402 HotKeySlot hotKey; // HotKey for this window
9406 ScrollFlags scrollFlags;// Window Scrollbar Flags
9407 int64 id; // Control ID
9409 ColorAlpha background; // Background color used to draw the window area
9411 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9412 OldList childrenCycle; // Cycling order
9413 OldLink cycle; // Element of parent's cycling order
9414 OldList childrenOrder; // Circular Z-Order
9415 OldLink order; // Element of parent's circular Z-Order
9416 Window modalSlave; // Slave window blocking this window's interaction
9418 Window rootWindow; // Topmost system managed window
9419 void * windowHandle; // System window handle
9421 DialogResult returnCode;// Return code for modal windows
9423 Point sbStep; // Scrollbar line scrolling steps
9426 SizeAnchor stateSizeAnchor;
9428 Anchor normalAnchor;
9429 SizeAnchor normalSizeAnchor;
9431 Size skinMinSize; // Minimal window size based on style
9432 Point scrolledPos; // Scrolled position
9433 Box box; // Window box clipped to parent
9434 Box * against; // What to clip the box to
9436 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9437 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9438 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9439 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9440 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9441 Point scrolledArea; // Distance to scroll area by
9442 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9444 OldList hotKeys; // List of the hotkeys of all children
9445 Window defaultControl; // Default child control
9449 ColorAlpha * palette; // Color palette used for this window
9451 int caretSize; // Size of caret, non zero if a caret is present
9452 Point caretPos; // Caret position
9454 void * systemParent; // Parent System Window for embedded windows
9461 WindowState lastState;
9463 FileMonitor fileMonitor
9465 this, FileChange { modified = true };
9467 bool OnFileNotify(FileChange action, char * param)
9470 fileMonitor.StopMonitoring();
9471 if(OnFileModified(action, param))
9472 fileMonitor.StartMonitoring();
9477 FontResource setFont, systemFont;
9478 FontResource usedFont;
9479 FontResource captionFont;
9481 FileDialog saveDialog;
9483 SizeAnchor sizeAnchor;
9485 // FormDesigner data
9488 Extent * tempExtents; //[4];
9489 BitmapResource icon;
9491 CreationActivationOption creationActivation;
9494 bool active:1; // true if window and ancestors are active
9495 bool acquiredInput:1; // true if the window is processing state based input
9496 bool modifiedDocument:1;
9497 bool disabled:1; // true if window cannot interact
9498 bool isForegroundWindow:1;// true while a root window is being activated
9499 bool visible:1; // Visibility flag
9500 bool destroyed:1; // true if window is being destroyed
9501 bool anchored:1; // true if this window is repositioned when the parent resizes
9502 bool dirty:1; // Flag set to true if any descendant must be redrawn
9508 bool modifyVirtArea:1;
9509 bool noAutoScrollArea:1;
9512 bool setVisible:1; // FOR FORM DESIGNER
9518 bool useSharedMemory:1;
9521 bool nativeDecorations:1;
9522 bool manageDisplay:1;
9523 bool formDesigner:1; // True if we this is running in the form editor
9526 // Checks used internally for them not to take effect in FormDesigner
9527 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9528 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9530 WindowController controller;
9531 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9534 public class CommonControl : Window
9536 // creationActivation = doNothing;
9539 public property String toolTip
9541 property_category $"Appearance"
9544 if(created) CommonControl::OnDestroy();
9546 toolTip = value ? ToolTip { tip = value; } : null;
9548 if(created) CommonControl::OnCreate();
9550 get { return toolTip ? toolTip.tip : null; }
9556 // (Very) Ugly work around for the fact that the parent watcher
9557 // won't fire when it's already been disconnected...
9558 eInstance_FireSelfWatchers(toolTip,
9559 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9565 toolTip.parent = this;
9574 public class Percentage : float
9576 char * OnGetString(char * string, float * fieldData, bool * needClass)
9580 sprintf(string, "%.2f", this);
9581 c = strlen(string)-1;
9584 if(string[c] != '0')
9585 last = Max(last, c);
9586 if(string[c] == '.')
9599 public void ApplySkin(Class c, char * name, void ** vTbl)
9601 char className[1024];
9606 subclass(Window) wc = (subclass(Window))c;
9607 subclass(Window) base = (subclass(Window))c.base;
9609 sprintf(className, "%sSkin_%s", name, c.name);
9610 wc.pureVTbl = c._vTbl;
9611 c._vTbl = new void *[c.vTblSize];
9612 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9613 sc = eSystem_FindClass(c.module.application, className);
9617 for(m = 0; m < c.base.vTblSize; m++)
9619 if(c._vTbl[m] == base.pureVTbl[m])
9620 c._vTbl[m] = vTbl[m];
9625 for(m = 0; m < c.vTblSize; m++)
9627 if(sc._vTbl[m] != wc.pureVTbl[m])
9628 c._vTbl[m] = sc._vTbl[m];
9632 for(d = c.derivatives.first; d; d = d.next)
9634 ApplySkin(d.data, name, c._vTbl);
9638 public void UnapplySkin(Class c)
9640 char className[1024];
9642 subclass(Window) wc = (subclass(Window))c;
9643 subclass(Window) base = (subclass(Window))c.base;
9646 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9649 c._vTbl = wc.pureVTbl;
9653 for(d = c.derivatives.first; d; d = d.next)
9655 UnapplySkin(d.data);
9659 void CheckFontIntegrity(Window window)
9664 if(window.usedFont && window.usedFont.font == 0xecececec)
9666 FontResource uf = window.usedFont;
9667 char * className = window._class.name;
9668 char * text = window.text;
9671 for(c = window.firstChild; c; c = c.next)
9672 CheckFontIntegrity(c);
9676 public class ControllableWindow : Window
9678 /*WindowController controller;
9679 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9680 ~ControllableWindow() { delete controller; }*/
9683 class WindowControllerInterface : ControllableWindow
9685 bool OnKeyDown(Key key, unichar ch)
9687 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9689 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9693 bool OnKeyUp(Key key, unichar ch)
9695 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9697 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9701 bool OnKeyHit(Key key, unichar ch)
9703 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9705 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9709 bool OnMouseMove(int x, int y, Modifiers mods)
9711 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9713 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9717 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9719 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9721 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9725 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9727 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9729 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9733 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9735 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9737 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9741 bool OnRightButtonDown(int x, int y, Modifiers mods)
9743 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9745 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9749 bool OnRightButtonUp(int x, int y, Modifiers mods)
9751 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9753 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9757 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9759 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9761 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9765 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9767 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9769 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9773 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9775 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9777 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9781 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9783 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9785 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9789 void OnResize(int width, int height)
9791 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9792 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9795 void OnRedraw(Surface surface)
9797 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9798 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9803 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9805 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9809 bool OnLoadGraphics()
9811 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9813 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9817 void OnUnloadGraphics()
9819 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9820 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9824 public class WindowController<class V>
9827 property Window window
9831 uint size = class(Window).vTblSize;
9834 windowVTbl = new void *[size];
9835 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9836 if(value._vTbl == value._class._vTbl)
9838 value._vTbl = new void *[value._class.vTblSize];
9839 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9843 for(c = 0; c < size; c++)
9845 void * function = class(WindowControllerInterface)._vTbl[c];
9846 if(function != DefaultFunction)
9847 value._vTbl[c] = function;
9849 value._vTbl[c] = windowVTbl[c];
9854 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9857 get { return window; }
9859 property V controlled
9861 set { controlled = value; }
9862 get { return controlled; }
9864 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9865 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9866 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9867 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9868 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9869 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9870 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9871 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9872 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9873 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9874 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9875 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9876 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9877 virtual void V::OnResize(WindowController controller, int width, int height);
9878 virtual void V::OnRedraw(WindowController controller, Surface surface);
9879 virtual bool V::OnCreate(WindowController controller);
9880 virtual bool V::OnLoadGraphics(WindowController controller);
9881 virtual void V::OnUnloadGraphics(WindowController controller);
9884 int (** windowVTbl)();