7 import "GuiApplication"
28 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
32 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
41 // Had to define this here for native decorations support, because the menu bar is part of total decoration's size, but not part of the system decorations
43 define skinMenuHeight = 40;
44 define statusBarHeight = 30;
46 define skinMenuHeight = 25;
47 define statusBarHeight = 18;
50 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
52 public enum DialogResult : int64 { cancel, yes, no, ok };
54 public class MouseButtons
57 bool left:1, right:1, middle:1;
60 public struct SizeAnchor
63 bool isClientW, isClientH;
68 #define SNAPDOWN(x, d) \
71 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
74 #define SNAPUP(x, d) \
77 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
80 /*static */define MAX_DIRTY_BACK = 10;
82 /////////////////////////////////////////////////////////////////////////////
83 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
84 /////////////////////////////////////////////////////////////////////////////
86 #define ACCESS_ITEM(l, id) \
89 #define FASTLIST_LOOP(l, v) \
90 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
92 #define FASTLIST_LOOPN(l, v, n) \
93 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
96 #define ACCESS_ITEM(l, id) \
97 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
99 #define FASTLIST_LOOP(l, v) \
100 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
102 #define FASTLIST_LOOPN(l, v, n) \
103 for( v = (void *)ACCESS_ITEM((l), (l).first), \
104 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
105 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
108 private class FastItem : struct
113 private struct FastList
118 int count, size, itemSize;
125 first = last = free = -1;
133 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
136 FastItem Add(uint itemSize)
139 if(free == -1 || !size)
146 newSize = (size + (size >> 1));
147 items = (FastItem)renew items byte[newSize * itemSize];
152 this.itemSize = itemSize;
153 items = (FastItem)new byte[newSize * itemSize];
156 for(c = size; c<newSize-1; c++)
158 ACCESS_ITEM(this, c).prev = -1;
159 ACCESS_ITEM(this, c).next = c+1;
161 ACCESS_ITEM(this, c).prev = -1;
162 ACCESS_ITEM(this, c).next = -1;
166 item = ACCESS_ITEM(this, free);
169 ACCESS_ITEM(this, item.prev).next = free;
179 void Delete(FastItem item)
182 ACCESS_ITEM(this, item.prev).next = item.next;
184 ACCESS_ITEM(this, item.next).prev = item.prev;
186 if(ACCESS_ITEM(this, first) == item)
188 if(ACCESS_ITEM(this, last) == item)
193 free = ((byte *)item - (byte *)items) / itemSize;
201 free = first = last = -1;
205 private class BoxItem : Item //FastItem
210 public /*private */struct Extent : OldList //FastList
219 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
220 Add(BoxItem { box = box });
223 void Copy(Extent source)
229 //FASTLIST_LOOP(source, extentBox)
230 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
231 AddBox(extentBox.box);
234 void IntersectBox(Box box)
236 // Clip all boxes of extent against inside of the new box
237 BoxItem extentBox, next;
239 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
240 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
242 next = (BoxItem)extentBox.next;
243 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
244 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
245 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
246 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
247 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
252 void ExcludeBox(Box box, Extent temp)
259 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
261 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
262 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
265 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
269 extentBox.box.left, extentBox.box.top,
270 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
276 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
280 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
281 extentBox.box.right, extentBox.box.bottom
287 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
290 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
294 extentBox.box.left, Max(extentBox.box.top, box.top),
295 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
301 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
305 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
306 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
314 AddBox(extentBox.box);
320 void UnionBox(Box box, Extent temp)
322 BoxItem extentBox, next;
324 // First pass: check if this box is not already covered by one of the extent's box
325 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
327 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
328 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
335 // Second pass: only keep boxes not completely covered in the new box
336 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
338 next = (BoxItem)extentBox.next;
339 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
340 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
344 // Add the exclusion to the extent
345 ExcludeBox(box, temp);
348 if(box.bottom >= box.top && box.right >= box.left)
350 // Optimization: if the resulting boxes touch, add them smarter
351 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
353 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
355 if(Abs(box.right - extentBox.box.left) <= 1)
357 extentBox.box.left = box.left;
360 else if(Abs(box.left - extentBox.box.right) <= 1)
362 extentBox.box.right = box.right;
366 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
368 if(Abs(box.bottom - extentBox.box.top) <= 1)
370 extentBox.box.top = box.top;
373 else if(Abs(box.top - extentBox.box.bottom) <= 1)
375 extentBox.box.bottom = box.bottom;
387 void Union(Extent b, Extent temp)
391 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
392 UnionBox(extentBox.box, temp);
395 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
402 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
405 temp2.IntersectBox(extentBox.box);
412 void Exclusion(Extent b, Extent temp)
415 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
416 ExcludeBox(extentBox.box, temp);
419 void Offset(int x, int y)
422 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
424 extentBox.box.left += x;
425 extentBox.box.top += y;
426 extentBox.box.right += x;
427 extentBox.box.bottom += y;
432 private define MINIMIZED_WIDTH = 160;
433 private define CASCADE_SPACE = 16;
435 // namespace Windows;
437 private class ScrollFlags
439 bool snapX:1, snapY:1, dontHide:1;
442 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
444 class WindowBits : BorderBits
446 BorderBits borderBits:6:0;
447 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
448 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
449 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
452 public enum BorderStyle : BorderBits
455 contour = BorderBits { contour = true },
456 fixed = BorderBits { fixed = true } | contour,
457 sizable = BorderBits { sizable = true } | fixed,
458 thin = BorderBits { fixed = true, thin = true } | contour,
459 sizableThin = BorderBits { sizable = true } | thin,
460 deep = BorderBits { deep = true },
461 bevel = BorderBits { bevel = true },
462 sizableDeep = sizable|deep,
463 sizableBevel = sizable|bevel,
464 fixedDeep = fixed|deep,
465 fixedBevel = fixed|bevel,
466 deepContour = deep|contour
469 public enum CreationActivationOption
471 activate, flash, doNothing
474 public enum WindowState { normal, minimized, maximized };
476 private class ResPtr : struct
483 private class HotKeySlot : struct
485 HotKeySlot prev, next;
493 class_data char * icon;
495 class_default_property caption;
496 // class_initialize GuiApplication::Initialize;
497 class_designer FormDesigner;
498 class_property char * icon
500 set { class_data(icon) = value; }
501 get { return class_data(icon); }
506 bool switchMode = true;
507 #if defined(__ANDROID__)
512 guiApp.Initialize(switchMode);
514 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
516 if(_vTbl == ((subclass(Window))_class).pureVTbl)
518 _vTbl = _class._vTbl;
520 else if(_vTbl != _class._vTbl)
523 for(m = 0; m < _class.vTblSize; m++)
525 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
526 _vTbl[m] = _class._vTbl[m];
531 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
532 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
533 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
534 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
538 // caption = CopyString(class.name);
540 children.offset = (byte*)&prev - (byte*)this;
541 childrenOrder.circ = true;
542 childrenCycle.circ = true;
544 maxSize = Size { MAXINT, MAXINT };
548 //style.isActiveClient = true;
551 modifyVirtArea = true;
552 manageDisplay = true;
553 nativeDecorations = true;
555 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
556 sbStep.x = sbStep.y = 8;
558 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
560 cursor = guiApp.GetCursor(arrow);
561 property::parent = guiApp.desktop;
573 stopwatching(parent, font);
574 if(parent.activeChild == this)
575 parent.activeChild = null;
576 if(parent.activeClient == this)
577 parent.activeClient = null;
582 // Prevent destructor from being called again...
588 /////////////////////////////////
591 OldLink slave = master.slaves.FindLink(this);
592 master.slaves.Delete(slave);
599 parent.childrenCycle.Remove(cycle);
601 parent.childrenOrder.Remove(order);
602 parent.children.Remove(this);
607 /////////////////////////////////
609 while(ptr = resources.first)
612 resources.Delete(ptr);
619 for(child = children.first; child; child = child.next)
621 // child.stopwatching(this, font);
623 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
624 // Don't want property here
625 *&child.parent = null;
628 while(slave = slaves.first)
630 // Don't want property here
631 *&((Window)slave.data).master = null;
632 slaves.Delete(slave);
635 // Because we do a decref in DestroyEx...
643 // Why was this commented?
644 //if(this != guiApp.desktop)
657 if(((subclass(Window))_class).pureVTbl)
659 if(_vTbl == _class._vTbl)
661 _vTbl = ((subclass(Window))_class).pureVTbl;
666 for(m = 0; m < _class.vTblSize; m++)
668 if(_vTbl[m] == _class._vTbl[m])
669 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
673 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
676 dirtyArea.Free(null);
677 renderArea.Free(null);
678 overRenderArea.Free(null);
679 clipExtent.Free(null);
680 scrollExtent.Free(null);
681 dirtyBack.Free(null);
685 tempExtents[0].Free(null);
686 tempExtents[1].Free(null);
687 tempExtents[2].Free(null);
688 tempExtents[3].Free(null);
693 //#if !defined(ECERE_VANILLA)
694 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
696 if(this == activeDesigner)
700 char * name = property::name;
701 return name ? name : "";
706 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
707 bool OnGetDataFromString(char * string)
709 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
712 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
713 this = designer.form;
714 else if(!strcmpi(string, "(Desktop)"))
715 this = activeDesigner;
717 return activeDesigner.FindObject(&this, string);
723 // --- Window updates system ---
725 // Setup a bitmap for Redrawing on client area of Window
726 Surface Redraw(Box box)
728 Surface surface = null;
730 Box clientArea = this.clientArea;
734 mox.left -= clientStart.x;
735 mox.top -= clientStart.y;
736 mox.right -= clientStart.x;
737 mox.bottom -= clientStart.y;
739 mox.Clip(clientArea);
740 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
742 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
744 int x = absPosition.x + clientStart.x;
745 int y = absPosition.y + clientStart.y;
746 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
748 x -= rootWindow.clientStart.x;
749 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
751 if(!guiApp.fullScreenMode || is3D)
753 x -= rootWindow.absPosition.x;
754 y -= rootWindow.absPosition.y;
758 x += rootWindow.parent.clientStart.x;
759 y += rootWindow.parent.clientStart.y;
761 mox.left += rootWindow.parent.clientStart.x;
762 mox.top += rootWindow.parent.clientStart.y;
763 mox.right += rootWindow.parent.clientStart.x;
764 mox.bottom += rootWindow.parent.clientStart.y;
769 surface = display.GetSurface(x, y, mox);
772 surface.width = clientSize.w;
773 surface.height = clientSize.h;
779 // Setup a bitmap for Redrawing on full Window
780 Surface RedrawFull(Box box)
782 Surface surface = null;
790 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
792 int x = absPosition.x;
793 int y = absPosition.y;
794 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
796 x -= rootWindow.clientStart.x;
797 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
799 if(!guiApp.fullScreenMode || is3D)
801 x -= rootWindow.absPosition.x;
802 y -= rootWindow.absPosition.y;
805 x += rootWindow.parent.clientStart.x;
806 y += rootWindow.parent.clientStart.y;
808 mox.left += rootWindow.parent.clientStart.x;
809 mox.top += rootWindow.parent.clientStart.y;
810 mox.right += rootWindow.parent.clientStart.x;
811 mox.bottom += rootWindow.parent.clientStart.y;
816 surface = display.GetSurface(x, y, mox);
819 surface.width = size.w;
820 surface.height = size.h;
826 void FigureCaption(char * caption)
828 Window activeClient = null;
832 strcpy(caption, this.caption);
833 if(style.isDocument || fileName)
835 if(caption[0]) strcat(caption, " - ");
837 strcat(caption, fileName);
841 sprintf(title, "Untitled %d", documentID);
842 strcat(caption, title);
845 strcat(caption, " *");
850 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
852 if(activeClient && activeClient.state == maximized)
854 if(activeClient.caption)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, activeClient.caption);
859 if(activeClient.style.isDocument || activeClient.fileName)
861 if(caption[0]) strcat(caption, " - ");
862 strcat(caption, "[");
863 if(activeClient.fileName)
864 strcat(caption, activeClient.fileName);
868 sprintf(title, "Untitled %d", activeClient.documentID);
869 strcat(caption, title);
871 if(activeClient.modifiedDocument)
872 strcat(caption, " *");
873 strcat(caption, "]");
878 // Code for returning dirty from ScrollDisplay:
880 for(d = 0; d<scrollExtent.count; d++)
882 Box * box = &scrollExtent.boxes[d];
888 Min(box.right, box.left-scroll.x),box.bottom
890 dirtyArea.UnionBox(update);
896 Max(box.left, box.right-scroll.x), box.top,
897 box.right, box.bottom
899 dirtyArea.UnionBox(update);
907 box.right, Min(box.bottom, box.top-scroll.y),
909 dirtyArea.UnionBox(update);
915 box.left, Max(box.top, box.bottom-scroll.y),
916 box.right, box.bottom
918 dirtyArea.UnionBox(update);
923 void UpdateDecorations(void)
925 // TODO: *** TEMPORARY HACK ***
932 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
934 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
936 Update({ -clientStart.x,0, -1, clientSize.h-1 });
938 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
941 // Returns w & h for Position
942 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
944 Window parent = this.parent ? this.parent : guiApp.desktop;
945 int vpw = parent ? parent.clientSize.w : 0;
946 int vph = parent ? parent.clientSize.h : 0;
947 int pw = parent ? parent.clientSize.w : 0;
948 int ph = parent ? parent.clientSize.h : 0;
949 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
950 int x = anchor.left.distance, y = anchor.top.distance;
952 MinMaxValue ew = 0, eh = 0;
954 float cascadeW, cascadeH;
956 int tilingW, tilingH, tilingSplit, tilingLastH;
957 int addX = 0, addY = 0;
959 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
961 Window masterWindow = this;
962 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
965 if(master == guiApp.desktop)
966 masterWindow = guiApp.desktop.activeChild;
968 masterWindow = master.rootWindow;
969 if(!masterWindow) masterWindow = this;
971 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
972 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
975 pw = vpw = box.right - box.left + 1;
977 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
980 ph = vph = box.bottom - box.top + 1;
996 vpw = pw = parent.size.w;
997 vph = ph = parent.size.h;
999 else if(!style.fixed /*|| style.isDocument*/)
1001 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
1002 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
1004 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1007 Desktop3D_FixSize(&pw, &ph);
1008 Desktop3D_FixSize(&vpw, &vph);
1011 if(pw < skinMinSize.w) pw = skinMinSize.w;
1012 if(ph < skinMinSize.h) ph = skinMinSize.h;
1013 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1014 if(vph < skinMinSize.h) vph = skinMinSize.h;
1016 // TODO: Must fix what we're snapping
1019 if(anchor.left.type)
1021 SNAPUP(x, textCellW);
1023 else if(anchor.right.type)
1025 SNAPDOWN(x, textCellW);
1030 SNAPUP(y, textCellH);
1032 else if(anchor.bottom.type)
1034 SNAPDOWN(y, textCellH);
1038 // This is required to get proper initial decoration size using native decorations on Windows
1039 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1040 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1041 GetDecorationsSize(&ew, &eh);
1043 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1045 if(parent.sbv && !parent.sbv.style.hidden)
1046 pw += guiApp.currentSkin.VerticalSBW();
1047 if(parent.sbh && !parent.sbh.style.hidden)
1048 ph += guiApp.currentSkin.HorizontalSBH();
1050 if(anchor.left.type == cascade)
1052 w = (int)(pw * 0.80);
1053 h = (int)(ph * 0.80);
1055 else if(anchor.left.type >= vTiled)
1060 numTiling = parent.numPositions - parent.numIcons;
1061 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1062 if(anchor.left.type == vTiled)
1064 tilingH = (int)sqrt(numTiling);
1065 tilingW = numTiling / tilingH;
1069 tilingW = (int)sqrt(numTiling);
1070 tilingH = numTiling / tilingW;
1073 leftOver = numTiling - tilingH * tilingW;
1076 tilingSplit = (tilingW - leftOver) * tilingH;
1077 tilingLastH = tilingH+1;
1080 tilingSplit = numTiling;
1082 if(positionID >= tilingSplit)
1084 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1085 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1086 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1087 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1091 x = pw * (positionID / tilingH) / tilingW;
1092 y = ph * (positionID % tilingH) / tilingH;
1093 x2 = pw * (positionID / tilingH + 1) / tilingW;
1094 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1098 SNAPDOWN(x, textCellW);
1099 SNAPDOWN(y, textCellH);
1100 SNAPDOWN(x2, textCellW);
1101 SNAPDOWN(y2, textCellH);
1109 if(sizeAnchor.isClientW) w += ew;
1110 if(sizeAnchor.isClientH) h += eh;
1112 if(anchor.left.type == offset)
1113 x = anchor.left.distance;
1114 else if(anchor.left.type == relative)
1115 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1116 else if(anchor.right.type == relative)
1117 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1118 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1119 else if(anchor.right.type == offset)
1120 ex = vpw - anchor.right.distance;
1122 if(anchor.top.type == offset)
1123 y = anchor.top.distance;
1124 else if(anchor.top.type == relative)
1125 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1126 else if(anchor.bottom.type == relative)
1127 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1128 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1129 else if(anchor.bottom.type == offset)
1130 ey = vph - anchor.bottom.distance;
1132 if(anchor.left.type && anchor.right.type)
1134 switch(anchor.right.type)
1137 ex = pw * (1.0f-anchor.right.percent);
1138 w = Max((int)(ex + 0.5) - x, 0);
1141 ex = vpw - anchor.right.distance;
1142 w = Max((int)(ex + 0.5) - x, 0);
1146 if(anchor.top.type && anchor.bottom.type)
1148 switch(anchor.bottom.type)
1151 ey = ph * (1.0f-anchor.bottom.percent);
1152 h = Max((int)(ey + 0.5) - y, 0);
1155 ey = vph - anchor.bottom.distance;
1156 h = Max((int)(ey + 0.5) - y, 0);
1165 if(state == normal /*|| state == Hidden*/)
1167 bool addSbV = false, addSbH = false;
1169 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1170 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1172 w = Max(w, minSize.w);
1173 h = Max(h, minSize.h);
1174 w = Min(w, maxSize.w);
1175 h = Min(h, maxSize.h);
1177 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1179 if(w) w -= guiApp.currentSkin.VerticalSBW();
1182 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1184 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1188 if(!OnResizing(&w, &h))
1194 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1195 w += guiApp.currentSkin.VerticalSBW();
1196 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1197 h += guiApp.currentSkin.HorizontalSBH();
1199 w = Max(w, skinMinSize.w);
1200 h = Max(h, skinMinSize.h);
1213 SNAPDOWN(w, textCellW);
1214 SNAPDOWN(h, textCellH);
1217 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1219 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1222 (pw - w) / CASCADE_SPACE,
1223 (ph - h) / CASCADE_SPACE);
1229 cascW = (pw - w) / (numCascade-1);
1230 cascH = (ph - h) / (numCascade-1);
1231 SNAPDOWN(cascW, textCellW);
1232 SNAPDOWN(cascH, textCellH);
1233 cascadeW = (float)cascW;
1234 cascadeH = (float)cascH;
1238 numCascade = Max(numCascade, 2);
1239 cascadeW = (float)(pw - w) / (numCascade-1);
1240 cascadeH = (float)(ph - h) / (numCascade-1);
1243 x = (int)((positionID % numCascade) * cascadeW);
1244 y = (int)((positionID % numCascade) * cascadeH);
1246 else if(anchor.left.type < vTiled)
1248 if(!anchor.left.type || anchor.horz.type == middleRelative)
1250 if(!anchor.right.type)
1252 if(anchor.horz.type == middleRelative)
1253 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1255 x = vpw / 2 + anchor.horz.distance - w / 2;
1261 // case A_EDGE: x = x - w; break;
1263 if(!anchor.top.type || anchor.vert.type == middleRelative)
1265 if(!anchor.bottom.type)
1267 if(anchor.vert.type == middleRelative)
1268 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1270 y = vph / 2 + anchor.vert.distance - h / 2;
1276 // case A_EDGE: y = y - h; break;
1279 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1287 SNAPDOWN(x, textCellW);
1288 SNAPDOWN(y, textCellH);
1300 if(anchored && style.fixed && style.isActiveClient)
1305 void UpdateCaret(bool forceUpdate, bool erase)
1307 static Window lastWindow = null;
1308 static int caretX, caretY, caretSize;
1310 if(guiApp && guiApp.caretOwner == this)
1312 int x = caretPos.x - scroll.x;
1313 int y = caretPos.y - scroll.y;
1315 if((erase || this.caretSize) &&
1316 x >= clientArea.left && x <= clientArea.right &&
1317 y >= clientArea.top && y <= clientArea.bottom)
1321 guiApp.interfaceDriver.SetCaret(
1322 x + absPosition.x + clientStart.x,
1323 y + absPosition.y + clientStart.y, this.caretSize);
1324 guiApp.caretEnabled = true;
1326 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1330 if(lastWindow != this)
1332 updateBox.left = x + 1;
1334 updateBox.right = x + 2;
1335 updateBox.bottom = y + this.caretSize - 1;
1339 updateBox.left = Min(x + 1, caretX + 1);
1340 updateBox.top = Min(y, caretY);
1341 updateBox.right = Max(x + 2, caretX + 2);
1342 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1345 guiApp.caretOwner.Update(updateBox);
1352 caretSize = this.caretSize;
1358 guiApp.interfaceDriver.SetCaret(0,0,0);
1359 guiApp.caretEnabled = false;
1365 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1370 scrolledPos.x = position.x = x;
1371 scrolledPos.y = position.y = y;
1373 clientSize.w = size.w = w;
1374 clientSize.h = size.h = h;
1376 if(parent && !style.nonClient)
1378 //if(!style.fixed || style.isDocument)
1380 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1381 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1385 clientStart.x = clientStart.y = 0;
1387 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1389 //if(!activeClient || activeClient.state != maximized)
1390 if(!noAutoScrollArea)
1392 // Check if scroll area must be modified
1393 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1395 bool foundChild = false;
1397 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1398 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1399 for(child = children.first; child; child = child.next)
1401 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1402 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1404 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1405 w = Max(w, child.position.x + child.size.w);
1406 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1407 w = Max(w, Max(child.position.x, 0) + child.size.w);
1408 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1409 h = Max(h, child.position.y + child.size.h);
1410 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1411 h = Max(h, Max(child.position.y, 0) + child.size.h);
1416 if(foundChild && (w > cw || h > ch))
1418 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1420 int stepX = sbStep.x, stepY = sbStep.y;
1421 // Needed to make snapped down position match the skin's check of client area
1422 // against realvirtual
1425 SNAPDOWN(stepX, textCellW);
1426 SNAPDOWN(stepY, textCellH);
1427 stepX = Max(stepX, textCellW);
1428 stepY = Max(stepY, textCellH);
1430 if(scrollFlags.snapX)
1432 if(scrollFlags.snapY)
1435 reqScrollArea.w = w;
1436 reqScrollArea.h = h;
1439 else if(reqScrollArea.w || reqScrollArea.h)
1441 reqScrollArea.w = 0;
1442 reqScrollArea.h = 0;
1443 SetScrollPosition(0,0);
1448 // Automatic MDI Client Scrolling Area Adjustment
1449 if(parent && !parent.noAutoScrollArea)
1451 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1452 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1454 Window parent = this.parent;
1455 int w = parent.reqScrollArea.w;
1456 int h = parent.reqScrollArea.h;
1458 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1459 w = Max(w, position.x + size.w);
1460 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1461 w = Max(w, Max(position.x, 0) + size.w);
1462 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1463 h = Max(h, position.y + size.h);
1464 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1465 h = Max(h, Max(position.y, 0) + size.h);
1467 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1468 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1470 /*bool resize = false;
1471 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1472 // Needed to make snapped down position match the skin's check of client area
1473 // against realvirtual
1476 SNAPDOWN(stepX, textCellW);
1477 SNAPDOWN(stepY, textCellH);
1478 stepX = Max(stepX, textCellW);
1479 stepY = Max(stepY, textCellH);
1481 if(parent.scrollFlags.snapX)
1483 if(parent.scrollFlags.snapY)
1485 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1487 parent.reqScrollArea.w = w;
1488 parent.reqScrollArea.h = h;*/
1490 // parent.UpdateScrollBars(true, true);
1491 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1492 false, true, true, true, false, false);
1497 GetRidOfVirtualArea();
1501 UpdateScrollBars(modifyThisArea, false);
1502 else if(guiApp.currentSkin)
1505 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1507 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1508 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1509 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1510 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1513 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1514 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1516 absPosition = scrolledPos;
1517 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1518 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1520 if(this != guiApp.desktop && parent)
1522 absPosition.x += parent.absPosition.x;
1523 absPosition.y += parent.absPosition.y;
1524 if(!style.nonClient && this != guiApp.desktop)
1526 absPosition.x += parent.clientStart.x;
1527 absPosition.y += parent.clientStart.y;
1531 box = Box { 0, 0, size.w - 1, size.h - 1 };
1536 // Clip against parent's client area
1537 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1539 // Compute client area in this window coordinate system
1540 clientArea.left = 0;
1542 clientArea.right = clientSize.w - 1;
1543 clientArea.bottom = clientSize.h - 1;
1545 // Clip against parent's client area
1547 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1551 //absPosition.x -= parent.clientStart.x;
1552 //absPosition.y -= parent.clientStart.y;
1555 // Adjust all children
1556 for(child = children.first; child; child = child.next)
1557 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1559 UpdateCaret(false, false);
1562 void GetRidOfVirtualArea(void)
1564 if(parent && !parent.destroyed && style.fixed &&
1565 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1566 parent.reqScrollArea.w && parent.reqScrollArea.h)
1568 if(!parent.noAutoScrollArea)
1572 for(child = children.first; child; child = child.next)
1574 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1576 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1577 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1586 Window parent = this.parent;
1588 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1589 false, true, true, true, false, false);
1591 parent.SetScrollArea(0,0,true);
1592 parent.SetScrollPosition(0,0);
1598 public void ExternalPosition(int x, int y, int w, int h)
1600 Position(x, y, w, h, false, true, true, true, false, false);
1603 // (w, h): Full window size
1604 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1606 bool result = false;
1607 int oldCW = clientSize.w, oldCH = clientSize.h;
1608 bool clientResized, windowResized, windowMoved;
1610 bool realResized = size.w != w || size.h != h;
1612 // TOCHECK: This wasn't in ecere.dll
1613 //if(!parent) return true;
1614 if(destroyed) return false;
1616 windowMoved = position.x != x || position.y != y || force;
1618 // windowResized = realResized || force;
1619 windowResized = size.w != w || size.h != h || force;
1621 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1627 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1628 scrolledPos.x - parent.clientStart.x + this.box.right,
1629 scrolledPos.y - parent.clientStart.y + this.box.bottom
1635 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1640 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1642 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1643 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1644 windowResized = true;
1646 if(display && rootWindow != this)
1649 if(guiApp && guiApp.windowMoving)
1651 if(guiApp.windowMoving.style.nonClient)
1652 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1654 guiApp.windowMoving.parent.SetMouseRangeToClient();
1664 // Buttons bitmap resources crash if we do this while switching mode
1665 if(!guiApp || !guiApp.modeSwitching)
1668 // Process Anchored Children
1672 for(child = children.first; child; child = child.next)
1675 ((child.stateAnchor.left.type != offset ||
1676 child.stateAnchor.top.type != offset ||
1677 child.stateAnchor.right.type != none ||
1678 child.stateAnchor.bottom.type != none) ||
1679 child.state == maximized || child.state == minimized))
1681 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1683 // child.Position(x, y, w, h, false, true, true, true, false);
1684 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1685 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1691 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1692 //if(updateScrollBars)
1694 OnResize(clientSize.w, clientSize.h);
1696 if((clientResized || windowMoved) && created)
1697 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1699 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1701 Window master = guiApp.interimWindow.master;
1702 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1705 if(rootWindow == this && !is3D)
1709 x -= guiApp.desktop.absPosition.x;
1710 y -= guiApp.desktop.absPosition.y;
1712 //guiApp.Log("Position %s\n", caption);
1715 if(windowResized || windowMoved)
1716 if(display && !display.flags.memBackBuffer && changeRootWindow)
1717 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1719 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1720 for(child = parent.children.first; child && child != this; child = child.next)
1721 if(child.rootWindow)
1722 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1727 if(windowMoved || windowResized)
1729 display.Lock(true /*false*/);
1732 display.Position(absPosition.x, absPosition.y);
1733 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1736 // result = realResized ? display.Resize(size.w, size.h) : true;
1737 if(nativeDecorations && rootWindow.windowHandle)
1739 int w = clientSize.w, h = clientSize.h;
1740 if(hasMenuBar) h += skinMenuHeight;
1741 if(hasStatusBar) h += statusBarHeight;
1742 if(sbv && sbv.visible) w += sbv.size.w;
1743 if(sbh && sbh.visible) h += sbh.size.h;
1744 result = manageDisplay ? display.Resize(w, h) : true;
1747 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1751 else if(clientResized)
1753 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1756 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1760 if(windowMoved || windowResized)
1765 if(guiApp.driver && changeRootWindow && windowHandle)
1767 if(windowResized || windowMoved)
1768 if(!display || display.flags.memBackBuffer)
1769 guiApp.interfaceDriver.PositionRootWindow(this,
1770 x, y, w, h, windowMoved, windowResized);
1771 guiApp.interfaceDriver.UpdateRootWindow(this);
1773 for(child = children.first; child; child = child.next)
1775 if(child.is3D && child.created)
1777 // Copy Display Content
1778 child.display.displaySystem = display.displaySystem;
1779 child.display.window = display.window;
1780 child.display.current = display.current;
1781 child.display.width = display.width;
1782 child.display.height = display.height;
1783 child.display.driverData = display.driverData;
1784 child.display.mutex = null;
1795 void UpdateScrollBars(bool flag, bool fullThing)
1798 bool resizeH = false, resizeV = false;
1799 bool scrolled = false;
1800 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1801 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1803 if(destroyed) return;
1804 if(guiApp.currentSkin)
1806 MinMaxValue cw = 0, ch = 0;
1807 bool sbvVisible, sbhVisible;
1809 int positionH, positionV;
1811 // First get client area with no respect to scroll bars
1816 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1818 if(scrollFlags.dontHide)
1821 cw -= guiApp.currentSkin.VerticalSBW();
1823 ch -= guiApp.currentSkin.HorizontalSBH();
1825 // Update the scrollbar visibility
1831 sbh.disabled = rangeH <= 1;
1832 if(sbh.style.hidden)
1842 sbv.disabled = rangeV <= 1;
1843 if(sbv.style.hidden)
1851 int oldHRange = sbh ? sbh.range : 0;
1852 int oldVRange = sbv ? sbv.range : 0;
1853 // Then start off with horizontal scrollbar range
1856 positionH = sbh.thumbPosition;
1863 SBSetTotal(sbh, rvw);
1866 ch -= guiApp.currentSkin.HorizontalSBH();
1869 // Do the same for vertical scrollbar
1872 positionV = sbv.thumbPosition;
1878 SBSetTotal(sbv, rvh);
1882 cw -= guiApp.currentSkin.VerticalSBW();
1883 // Maybe we need to set the range on the horizontal scrollbar again
1891 SBSetTotal(sbh, rvw);
1892 //sbh.Action(setRange, positionH, 0);
1893 if(rangeH <= 1 && sbh.range > 1)
1895 ch -= guiApp.currentSkin.HorizontalSBH();
1901 SBSetTotal(sbv, rvh);
1903 //sbv.Action(setRange, positionV, 0);
1908 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1909 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1912 // Update the scrollbar visibility
1913 if(!scrollFlags.dontHide)
1915 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1919 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1926 if(guiApp.currentSkin)
1933 sbhVisible = sbh.style.hidden ? true : false;
1935 sbvVisible = sbv.style.hidden ? true : false;
1937 // Do our resize here
1938 if(flag && (resizeH || resizeV) && fullThing)
1940 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1945 OnResize(clientSize.w, clientSize.h);
1951 sbh.visible = sbhVisible;
1953 sbv.visible = sbvVisible;
1955 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1956 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1959 sbh.pageStep = clientSize.w;
1961 sbv.pageStep = clientSize.h;
1963 // Notify doesn't handle setRange anymore... process it here
1966 int positionH = sbh.thumbPosition;
1967 if(scroll.x != positionH)
1969 OnHScroll(setRange, positionH, 0);
1973 SNAPDOWN(positionH, textCellW);
1974 scroll.x = positionH;
1980 int seen = clientSize.w, total = reqScrollArea.w;
1983 if(scrollFlags.snapX)
1984 SNAPDOWN(seen, sbStep.x);
1986 if(!total) total = seen;
1987 range = total - seen + 1;
1989 range = Max(range, 1);
1991 if(x >= range) x = range - 1;
1993 if(scrollFlags.snapX)
1994 SNAPUP(x, sbStep.x);
1998 OnHScroll(setRange, x, 0);
2003 SNAPDOWN(x, textCellW);
2009 int positionV = sbv.thumbPosition;
2010 if(scroll.y != positionV)
2012 OnVScroll(setRange, positionV, 0);
2016 SNAPDOWN(positionV, textCellH);
2017 scroll.y = positionV;
2023 int seen = clientSize.h, total = reqScrollArea.h;
2026 if(scrollFlags.snapY)
2027 SNAPDOWN(seen, sbStep.y);
2029 if(!total) total = seen;
2030 range = total - seen + 1;
2031 range = Max(range, 1);
2033 if(y >= range) y = range - 1;
2035 if(scrollFlags.snapY)
2036 SNAPUP(y, sbStep.y);
2040 OnVScroll(setRange, y, 0);
2045 SNAPDOWN(y, textCellH);
2051 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2054 for(child = children.first; child; child = child.next)
2056 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2059 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2060 child.Position(x, y, w, h, false, true, false, true, false, false);
2067 // Process Scrollbars
2069 if(sbh) // && !sbh.style.hidden
2072 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2073 // Need to set the range again (should improve...) since the scrollbars didn't have
2074 // the right size when UpdateScrollArea set the range on it
2077 sbh.seen = clientSize.w;
2081 if(sbv) // && !sbv.state.hidden
2084 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2085 // Need to set the range again (should improve...) since the scrollbars didn't have
2086 // the right size when UpdateScrollArea set the range on it
2089 sbv.seen = clientSize.h;
2094 // TESTING THIS LOWER
2095 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2098 for(child = children.first; child; child = child.next)
2100 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2103 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2104 child.Position(x, y, w, h, false, true, false, true, false, false);
2110 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2112 SetState(maximized, false, mods);
2116 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2118 SetState(normal, false, mods);
2122 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2124 SetState(minimized, false, mods);
2125 parent.CycleChildren(false, true, false, true);
2129 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2132 // Scroll bar notifications
2133 if(action != setRange)
2135 bool changed = false;
2139 if(scroll.x != position)
2141 OnHScroll(action, position, keyFlags);
2146 SNAPDOWN(position, textCellW);
2148 scroll.x = position;
2152 if(scroll.y != position)
2154 OnVScroll(action, position, keyFlags);
2159 SNAPDOWN(position, textCellH);
2161 scroll.y = position;
2165 bool childMove = false;
2166 for(child = children.first; child; child = child.next)
2168 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2171 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2172 child.Position(x, y, w, h, false, true, false, true, false, false);
2176 // Testing this patch out to solve MDI workspace redraw bugs
2177 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2178 // Scroll offsets to blame?
2182 UpdateCaret(false, false);
2186 // Testing this patch out to solve MDI workspace redraw bugs
2187 for(child = children.first; child; child = child.next)
2189 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2198 Window GetParentMenuBar()
2200 Window result = this;
2201 bool notActiveClient = false;
2202 Window menuBarParent;
2203 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2205 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2206 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2207 notActiveClient = true;
2212 void CreateSystemChildren(void)
2214 Window parent = this;
2215 bool scrollBarChanged = false;
2216 bool hasClose = false, hasMaxMin = false;
2217 Point scroll = this.scroll;
2219 if(state == maximized)
2220 parent = GetParentMenuBar();
2224 if(style.hasClose) hasClose = true;
2225 if(style.hasMaximize || style.hasMinimize)
2232 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2234 sysButtons[2].Destroy(0);
2235 sysButtons[2] = null;
2237 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2239 sysButtons[1].Destroy(0);
2240 sysButtons[1] = null;
2242 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2244 sysButtons[0].Destroy(0);
2245 sysButtons[0] = null;
2248 if(hasClose && parent)
2255 parent, master = this,
2256 inactive = true, nonClient = true, visible = false;
2258 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2264 if(this.parent == guiApp.desktop)
2265 sysButtons[2].hotKey = altF4;
2266 else if(style.isActiveClient)
2267 sysButtons[2].hotKey = ctrlF4;
2268 sysButtons[2].Create();
2271 sysButtons[2].symbol = 'X';
2272 sysButtons[2].disabled = !style.hasClose;
2275 if(hasMaxMin && parent)
2279 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2280 if(state == maximized)
2283 method = RestoreButtonClicked;
2289 method = MaximizeButtonClicked;
2297 parent, master = this,
2298 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2300 sysButtons[1].Create();
2302 sysButtons[1].NotifyClicked = method;
2304 sysButtons[1].symbol = symbol;
2305 sysButtons[1].disabled = !style.hasMaximize;
2308 if(hasMaxMin && parent)
2312 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2313 if (state == minimized)
2316 method = RestoreButtonClicked;
2322 method = MinimizeButtonClicked;
2330 parent, master = this,
2331 hotKey = altM, inactive = true, nonClient = true, visible = false
2333 sysButtons[0].Create();
2335 sysButtons[0].NotifyClicked = method;
2337 sysButtons[0].symbol = symbol;
2338 sysButtons[0].disabled = !style.hasMinimize;
2341 // Create the scrollbars
2342 if(style.hasHorzScroll && !sbh)
2348 direction = horizontal,
2352 snap = scrollFlags.snapX,
2353 NotifyScrolling = ScrollBarNotification
2356 scrollBarChanged = true;
2358 else if(sbh && !style.hasHorzScroll)
2364 if(style.hasVertScroll && !sbv)
2370 direction = vertical,
2374 snap = scrollFlags.snapY,
2375 NotifyScrolling = ScrollBarNotification
2378 scrollBarChanged = true;
2380 else if(sbv && !style.hasVertScroll)
2385 if(scrollBarChanged)
2387 SetScrollLineStep(sbStep.x, sbStep.y);
2388 UpdateScrollBars(true, true);
2392 if(scrollBarChanged)
2394 if(sbh) sbh.thumbPosition = scroll.x;
2395 if(sbv) sbv.thumbPosition = scroll.y;
2399 void UpdateCaption(void)
2401 if(rootWindow == this)
2404 FigureCaption(caption);
2405 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2407 UpdateDecorations();
2410 if(parent.activeClient == this) // Added this last check
2412 if(parent.rootWindow == parent)
2415 parent.FigureCaption(caption);
2416 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2419 parent.UpdateCaption();
2421 parent.UpdateDecorations();
2425 void UpdateActiveDocument(Window previous)
2427 Window activeClient = this.activeClient;
2428 Window activeChild = this.activeChild;
2435 activeClient.CreateSystemChildren();
2437 previous.CreateSystemChildren();
2449 // Build window list
2452 Menu windowMenu = menu.FindMenu("Window");
2457 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2460 Window document = cycle.data;
2461 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2463 char name[2048], caption[2048];
2464 document.FigureCaption(caption);
2465 sprintf(name, "%d %s", id+1, caption);
2466 windowMenu.AddDynamic(MenuItem
2468 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2469 NotifySelect = MenuWindowSelectWindow
2473 if(activeClient.cycle == cycle) break;
2478 if((!previous && activeClient) || !activeClient)
2484 item = menu.FindItem(MenuWindowCloseAll, 0);
2485 if(item) item.disabled = false;
2486 item = menu.FindItem(MenuWindowNext, 0);
2487 if(item) item.disabled = false;
2488 item = menu.FindItem(MenuWindowPrevious, 0);
2489 if(item) item.disabled = false;
2490 item = menu.FindItem(MenuWindowCascade, 0);
2491 if(item) item.disabled = false;
2492 item = menu.FindItem(MenuWindowTileHorz, 0);
2493 if(item) item.disabled = false;
2494 item = menu.FindItem(MenuWindowTileVert, 0);
2495 if(item) item.disabled = false;
2496 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2497 if(item) item.disabled = false;
2498 item = menu.FindItem(MenuWindowWindows, 0);
2499 if(item) item.disabled = false;
2502 item = menu.FindItem(MenuFileClose, 0);
2503 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2504 item = menu.FindItem(MenuFileSaveAll, 0);
2505 if(item) item.disabled = numDocuments < 1;
2507 if(activeClient && activeClient.menu && activeClient.state != minimized)
2511 //activeClient.menu.Clean(activeClient);
2512 menu.Merge(activeClient.menu, true, activeClient);
2516 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2519 menu.Merge(activeChild.menu, true, activeChild);
2522 // This is called again for a child window change, with same active client
2523 OnActivateClient(activeClient, previous);
2524 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2525 parent.UpdateActiveDocument(null);
2528 void _ShowDecorations(Box box, bool post)
2530 if(rootWindow == this && nativeDecorations) return;
2531 if(visible && this != guiApp.desktop)
2533 Surface surface = RedrawFull(box);
2537 FigureCaption(caption);
2540 ShowDecorations(captionFont.font,
2543 active, //parent.activeClient == this
2544 guiApp.windowMoving == this);
2546 PreShowDecorations(captionFont.font,
2549 active, //parent.activeClient == this
2550 guiApp.windowMoving == this);
2557 void UpdateExtent(Box refresh)
2559 Surface surface = null;
2561 if(!manageDisplay) { OnRedraw(null);return; }
2562 _ShowDecorations(refresh, false);
2564 surface = Redraw(refresh);
2565 // Opaque background: just fill before EW_REDRAW (clear?)
2568 surface.SetBackground(background);
2569 surface.SetForeground(foreground);
2570 surface.DrawingChar(' ');
2571 if(this == rootWindow)
2573 if(style.drawBehind || background.a)
2575 int a = background.a;
2576 // Premultiply alpha for clear color
2577 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2578 surface.Clear(colorBuffer);
2579 surface.SetBackground(background);
2582 else if(background.a)
2586 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2587 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2590 if(display.flags.alpha && background.a < 255 && background)
2592 surface.Area(0,0,clientSize.w, clientSize.h);
2593 /*if(style.clearDepthBuffer)
2594 surface.Clear(depthBuffer);*/
2596 else if(/*style.clearDepthBuffer || */background.a)
2598 int a = background.a;
2599 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2600 // Premultiply alpha for clear color
2601 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2602 surface.Clear(colorBuffer);
2603 surface.SetBackground(background);
2608 surface.TextFont(usedFont.font);
2609 surface.TextOpacity(false);
2613 // Draw the caret ...
2614 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2616 // surface.SetBackground(0xFFFFFF - background.color);
2617 surface.SetBackground(~background.color);
2619 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2620 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2626 void DrawOverChildren(Box refresh)
2628 Surface surface = Redraw(refresh);
2632 surface.DrawingChar(' ');
2633 surface.SetBackground(background);
2634 surface.SetForeground(foreground);
2636 surface.TextFont(usedFont.font);
2637 surface.TextOpacity(false);
2639 OnDrawOverChildren(surface);
2644 _ShowDecorations(refresh, true);
2647 void ComputeClipExtents(void)
2650 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2652 clipExtent.Copy(this.clipExtent);
2654 for(child = children.last; child; child = child.prev)
2656 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2658 bool opaque = child.IsOpaque(); // TODO: acess background directly
2659 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2661 child.clipExtent.Copy(clipExtent);
2662 child.clipExtent.Offset(-dx, -dy);
2663 child.clipExtent.IntersectBox(child.box);
2665 child.ComputeClipExtents();
2667 if(opaque && !child.style.nonClient)
2669 // Adjust the box for the parent:
2670 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2671 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2676 // ??? Only do this for overlapped window or if parent has with clip children flag
2678 // Do this if window has clip children flag on (default false?)
2679 // this.clipExtent = clipExtent;
2681 clipExtent.Free(null);
2684 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2686 bool opaque = IsOpaque();
2688 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2689 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2691 offsetX -= rootWindow.clientStart.x;
2692 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2696 for(child = children.last; child; child = child.prev)
2698 ColorAlpha background = *(ColorAlpha *)&child.background;
2699 bool opaque = child.IsOpaque();
2700 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2704 // Adjust renderArea to the root window level
2705 Extent * renderArea = &rootWindow.tempExtents[1];
2707 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2708 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2710 offsetX -= child.rootWindow.clientStart.x;
2711 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2715 Extent childRenderArea;
2717 if(backBufferUpdate != null)
2719 childRenderArea.Copy(backBufferUpdate);
2720 childRenderArea.Offset(-offsetX, -offsetY);
2723 childRenderArea.Copy(child.dirtyArea);
2725 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2726 renderArea.Copy(dirtyExtent);
2727 renderArea.Offset(-offsetX, -offsetY);
2728 childRenderArea.Union(renderArea);
2731 // Intersect with the clip extent
2732 childRenderArea.Intersection(child.clipExtent);
2735 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2736 renderArea->Offset(offsetX, offsetY);
2737 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2738 // overDirtyExtent.Union(renderArea);
2739 renderArea->Empty();
2740 // childRenderArea.Free();
2742 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2747 for(child = children.last; child; child = child.prev)
2749 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2751 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2756 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2758 bool opaque = IsOpaque();
2759 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2761 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2762 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2764 offsetX -= rootWindow.clientStart.x;
2765 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2769 for(child = children.last; child; child = child.prev)
2771 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2773 ColorAlpha background = *(ColorAlpha *)&child.background;
2774 bool opaque = child.IsOpaque();
2775 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2779 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2780 // Adjust renderArea to the root window level
2782 renderArea.Copy(child.dirtyArea);
2783 renderArea.Offset(offsetX, offsetY);
2784 dirtyExtent.Union(renderArea);
2785 overDirtyExtent.Union(renderArea);
2791 for(child = children.last; child; child = child.prev)
2793 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2795 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2799 if(backBufferUpdate != null)
2801 renderArea.Copy(backBufferUpdate);
2802 renderArea.Offset(-offsetX, -offsetY);
2804 overRenderArea.Copy(backBufferUpdate);
2805 overRenderArea.Offset(-offsetX, -offsetY);
2811 renderArea.Copy(dirtyArea);
2813 overRenderArea.Copy(dirtyArea);
2816 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2817 dirtyExtentWindow->Copy(dirtyExtent);
2818 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2819 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2820 dirtyExtentWindow->Empty();
2822 // Intersect with the clip extent
2823 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2826 if(renderArea.count > 10)
2829 printf("\nToo many extents (%d):\n", renderArea.count);
2831 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2832 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2837 for(c = 0; c<10; c++)
2840 FASTLIST_LOOP(renderArea, extentBox)
2842 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2844 renderArea.Copy(extent);
2846 FASTLIST_LOOP(renderArea, extentBox)
2849 printf("(%d, %d) - (%d, %d)\n",
2850 extentBox.box.left, extentBox.box.top,
2851 extentBox.box.right, extentBox.box.bottom);
2855 printf("\nNow %d\n", renderArea.count);
2861 // WHY WAS THIS COMMENTED ??
2863 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2864 dirtyExtentWindow->Copy(overDirtyExtent);
2865 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2866 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2867 dirtyExtentWindow->Empty();
2869 // Intersect with the clip extent
2870 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2876 if(scrollExtent.count)
2878 // Subtract render extent from scrolling extent
2879 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2881 if(backBufferUpdate == null)
2883 Extent * dirty = &rootWindow.tempExtents[3];
2886 // Intersect scrolling extent with clip extent
2887 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2889 // offset this scroll to be at the root window level
2890 scrollExtent.Offset(offsetX, offsetY);
2891 // Add area that was scrolled to the dirty extents of the back buffer
2892 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2896 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2897 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2898 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2903 scrollExtent.Empty();
2905 // Add the exposed extent to the window render area
2906 dirty->Offset(-offsetX, -offsetY);
2907 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2912 // Subtract the window's box from the transparency forced extent
2913 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2919 renderArea.Copy(this.renderArea);
2920 renderArea.Offset(offsetX, offsetY);
2921 dirtyExtent.Union(renderArea);
2927 Extent renderArea { };
2929 renderArea.Copy(overRenderArea);
2930 renderArea.Offset(offsetX, offsetY);
2931 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2936 if(backBufferUpdate != null)
2938 // Remove render area from dirty area
2939 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2941 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2948 // Remove the window render area from the dirty extents of the back buffer
2949 rootWindow.dirtyBack.Exclusion(renderArea);
2953 void Render(Extent updateExtent)
2957 Window rootWindow = this.rootWindow;
2958 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2959 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2961 offsetX -= rootWindow.clientStart.x;
2962 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2965 if(rootWindow.fullRender)
2974 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2975 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2980 /*if(renderArea.count)
2981 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2984 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2986 Box box = extentBox.box;
2989 /*printf("(%d, %d) - (%d, %d)\n",
2990 extentBox.box.left, extentBox.box.top,
2991 extentBox.box.right, extentBox.box.bottom);*/
2996 box.left += offsetX;
2998 box.right += offsetX;
2999 box.bottom += offsetY;
3001 if(updateExtent != null)
3002 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3006 for(child = children.first; child; child = child.next)
3007 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3008 child.Render(updateExtent);
3010 if(rootWindow.fullRender)
3011 DrawOverChildren(box);
3014 // TO DO: There's an issue about draw over children...
3015 // TO DO: Don't wanna go through this if method isn't used
3016 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3017 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3019 Box box = extentBox.box;
3021 DrawOverChildren(box);
3023 box.left += offsetX;
3025 box.right += offsetX;
3026 box.bottom += offsetY;
3028 if(updateExtent != null)
3029 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3032 for(child = children.first; child; child = child.next)
3033 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3034 child.Render(updateExtent);
3037 overRenderArea.Empty();
3040 public void UpdateDisplay(void)
3042 if(!manageDisplay) { OnRedraw(null);return; }
3043 if(rootWindow && this != rootWindow)
3044 rootWindow.UpdateDisplay();
3047 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3048 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3051 dirtyExtent.Clear();
3054 clipExtent.AddBox(box);
3056 display.StartUpdate();
3058 if(!rootWindow.fullRender)
3060 ComputeClipExtents();
3061 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3062 ComputeRenderArea(dirtyExtent, overExtent, null);
3065 clipExtent.Free(null);
3067 dirtyExtent.Free(null);
3068 overExtent.Free(null);
3070 if(display.flags.flipping)
3073 display.Update(null);
3077 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3078 updateExtent.Clear();
3080 Render(updateExtent);
3082 updateExtent.UnionBox(this.box, tempExtents[0]);
3085 //printf("\n\nUpdate:\n------------------------------------------\n");
3088 //FASTLIST_LOOP(updateExtent, extentBox)
3089 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3092 /*printf("Updating (%d, %d) - (%d, %d)\n",
3093 extentBox.box.left, extentBox.box.top,
3094 extentBox.box.right, extentBox.box.bottom);*/
3097 display.Update(extentBox.box);
3100 updateExtent.Free(null);
3103 display.EndUpdate();
3111 void UpdateBackDisplay(Box box)
3117 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3119 //printf("UpdateBackDisplay going through!\n");
3120 display.StartUpdate();
3124 intersection.Copy(dirtyBack);
3125 intersection.IntersectBox(box);
3127 dirtyExtent.Clear();
3130 clipExtent.AddBox(box);
3132 if(!rootWindow.fullRender)
3134 ComputeClipExtents();
3135 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3138 clipExtent.Free(null);
3140 intersection.Free(null);
3141 dirtyExtent.Free(null);
3142 overExtent.Free(null);
3147 if(display.flags.flipping)
3148 display.Update(null);
3151 rootWindow.display.Update(box);
3154 display.EndUpdate();
3158 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3159 if(dirtyBack.count > MAX_DIRTY_BACK)
3161 BoxItem extentBox, next;
3162 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3163 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3165 next = (BoxItem)extentBox.next;
3166 if(extentBox != first)
3168 if(extentBox.box.left < first.box.left)
3169 first.box.left = extentBox.box.left;
3170 if(extentBox.box.top < first.box.top)
3171 first.box.top = extentBox.box.top;
3172 if(extentBox.box.right > first.box.right)
3173 first.box.right = extentBox.box.right;
3174 if(extentBox.box.bottom > first.box.bottom)
3175 first.box.bottom = extentBox.box.bottom;
3176 dirtyBack.Delete(extentBox);
3185 // --- Window positioning ---
3186 // --- Window identification ---
3188 // Returns window at position "Position"
3189 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3191 Window child, result = null;
3193 box.left += absPosition.x;
3194 box.right += absPosition.x;
3195 box.top += absPosition.y;
3196 box.bottom += absPosition.y;
3198 if(!destroyed && visible && (acceptDisabled || !disabled))
3200 int lx = x - absPosition.x;
3201 int ly = y - absPosition.y;
3202 if(IsInside(lx, ly))
3203 // if(box.IsPointInside(Point{x, y}))
3205 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3206 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3209 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3211 if(child != statusBar && child.rootWindow == rootWindow)
3213 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3220 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3222 if(child != statusBar && child.rootWindow == rootWindow)
3224 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3236 Window FindModal(void)
3238 Window modalWindow = this, check;
3239 Window check2 = null;
3240 for(check = this; check.master; check = check.master)
3242 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3244 modalWindow = check.master.modalSlave;
3245 check = modalWindow;
3247 // TESTING THIS FOR DROPBOX...
3248 if(!rootWindow || !rootWindow.style.interim)
3250 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3252 if(check2.modalSlave && check2.modalSlave.created)
3254 modalWindow = check2.modalSlave;
3262 if(modalWindow == this)
3264 for(check = this; check.activeChild; check = check.activeChild)
3266 if(check.modalSlave)
3268 modalWindow = check.modalSlave;
3274 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3275 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3278 void StopMoving(void)
3280 if(this == guiApp.windowMoving)
3282 guiApp.windowMoving = null;
3283 UpdateDecorations();
3284 SetMouseRange(null);
3287 if(rootWindow.active)
3288 guiApp.interfaceDriver.StopMoving(rootWindow);
3291 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3292 guiApp.windowIsResizing = false;
3296 void SelectMouseCursor(void)
3301 Window cursorWindow = null;
3302 bool rx, ry, rex, rey;
3304 guiApp.desktop.GetMousePosition(&x, &y);
3305 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3307 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3308 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3309 else if(mouseWindow)
3311 modalWindow = mouseWindow.FindModal();
3312 x -= mouseWindow.absPosition.x;
3313 y -= mouseWindow.absPosition.y;
3314 if(guiApp.windowIsResizing)
3316 rex = guiApp.resizeEndX;
3317 rey = guiApp.resizeEndY;
3318 rx = guiApp.resizeX;
3319 ry = guiApp.resizeY;
3320 if((rex && rey) || (rx && ry))
3321 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3322 else if((rex && ry) || (rx && rey))
3323 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3324 else if((ry || rey) && (!rx && !rex))
3325 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3326 else if((rx || rex) && (!ry && !rey))
3327 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3329 else if(!modalWindow && !guiApp.windowCaptured &&
3330 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3331 &rx, &ry, &rex, &rey))
3333 if((rex && rey) || (rx && ry))
3334 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3335 else if((rex && ry) || (rx && rey))
3336 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3337 else if((ry || rey) && (!rx && !rex))
3338 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3339 else if((rx || rex) && (!ry && !rey))
3340 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3342 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3344 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3345 cursorWindow = mouseWindow.parent;
3347 cursorWindow = mouseWindow;
3349 else if(!guiApp.interimWindow)
3350 cursorWindow = guiApp.windowCaptured;
3353 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3354 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3356 else if(modalWindow)
3358 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3360 else if(guiApp.interimWindow)
3362 if(guiApp.interimWindow.cursor)
3363 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3365 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3370 // --- State based input ---
3371 bool AcquireInputEx(bool state)
3376 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3377 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3379 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3381 guiApp.acquiredWindow = state ? this : null;
3384 SetMouseRangeToClient();
3385 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3390 SelectMouseCursor();
3392 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3396 // --- Window activation ---
3397 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3400 if(!parent || !parent.style.inactive)
3402 Window parent = this.parent;
3405 if(rootWindow == this)
3406 Log(active ? "active\n" : "inactive\n");
3409 // Testing this here...
3410 if(!parent || parent == guiApp.desktop || parent.active)
3412 this.active = active;
3415 // TESTING THIS HERE
3416 UpdateDecorations();
3417 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3418 result = NotifyActivate(master, this, active, previous);
3421 this.active = !active;
3426 if(!parent || parent == guiApp.desktop || parent.active)
3428 this.active = active;
3430 AcquireInputEx(active);
3435 if(guiApp.caretOwner)
3439 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3440 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3441 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3442 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3444 guiApp.caretOwner.Update(extent);
3447 if(visible || !guiApp.caretOwner)
3448 guiApp.caretOwner = this;
3449 UpdateCaret(false, false);
3455 this.active = false;
3457 AcquireInputEx(active);
3459 if(!active && guiApp.caretOwner == this)
3461 UpdateCaret(false, true);
3462 guiApp.caretOwner = null;
3463 guiApp.interfaceDriver.SetCaret(0,0,0);
3464 guiApp.caretEnabled = false;
3469 if(!active && parent && parent.activeChild && parent.activeChild != this)
3470 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3476 if(!active && menuBar)
3479 menuBar.OnActivate(false, null, &goOn, true);
3480 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3485 Window aChild = activeChild;
3487 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3499 void ConsequentialMouseMove(bool kbMoving)
3503 if(kbMoving || !guiApp.windowMoving)
3507 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3509 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3511 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3512 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3518 bool IsDescendantOf(Window ancestor)
3521 for(window = this; window && window != ancestor; window = window.parent);
3522 return window == ancestor;
3525 bool IsSlaveOf(Window master)
3528 for(window = this; window && window != master; window = window.master);
3529 return window == master;
3532 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3536 if(this && !destroyed /*&& state != Hidden*/)
3538 Window swap = externalSwap;
3546 if(activateParent &&
3547 (parent.activeChild != this ||
3548 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3549 active && _isModal &&
3550 parent != master && master)
3551 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3557 bool real = parent.activeChild != this;
3559 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3560 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3561 !IsDescendantOf(guiApp.interimWindow) &&
3562 !IsSlaveOf(guiApp.interimWindow))
3564 Window interimWindow = guiApp.interimWindow;
3565 while(interimWindow && interimWindow != this)
3567 Window master = interimWindow.master;
3569 guiApp.interimWindow = null;
3570 if(guiApp.caretOwner)
3571 guiApp.caretOwner.UpdateCaret(false, false);
3573 incref interimWindow;
3574 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3579 delete interimWindow;
3580 interimWindow = (master && master.style.interim) ? master : null;
3585 guiApp.interimWindow = this;
3586 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3587 guiApp.caretEnabled = false;*/
3588 UpdateCaret(false, true);
3593 bool acquireInput = false;
3595 parent.activeChild &&
3596 parent.activeChild.state == maximized &&
3597 parent != guiApp.desktop;
3599 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3604 swap = parent.activeChild;
3605 if(swap && swap.destroyed) swap = null;
3606 if(swap && swap != this)
3609 if(!swap.PropagateActive(false, this, &goOn, true))
3610 swap = parent.activeChild;
3621 if(!parent || parent.activeChild != this || style.interim)
3624 result = PropagateActive(true, swap, &goOn, true);
3625 if(!result && !goOn)
3630 acquireInput = true;
3634 if(style.hasMaximize && parent != guiApp.desktop)
3637 SetState(maximized, false, 0);
3638 else if(state != maximized)
3641 for(child = parent.children.first; child; child = child.next)
3643 if(this != child && child.state == maximized)
3644 child.SetState(normal, false, 0);
3651 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3653 Window previous = parent.activeClient;
3654 parent.activeChild = this;
3655 if(!style.nonClient /*&& style.isActiveClient*/)
3659 if(style.isActiveClient)
3660 parent.activeClient = this;
3661 // Moved UpdateActiveDocument inside hidden check
3662 // To prevent activating previous window while creating a new one
3663 // (It was messing up the privateModule in the CodeEditor)
3664 parent.UpdateActiveDocument(previous);
3670 //if(!style.isRemote)
3672 if(rootWindow != this)
3674 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3675 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3677 else if(!guiApp.fullScreenMode)
3679 Window modalRoot = FindModal();
3680 if(!modalRoot) modalRoot = this;
3681 if(!modalRoot.isForegroundWindow)
3683 modalRoot.isForegroundWindow = true;
3684 // To check : Why is parent null?
3685 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3687 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3689 modalRoot.isForegroundWindow = false;
3694 if(result && real && (!style.inactive || moveInactive) && parent)
3696 Window last = parent.children.last;
3698 if(!style.stayOnTop)
3699 for(; last && last.style.stayOnTop; last = last.prev);
3701 parent.children.Move(this, last);
3703 // Definitely don't want that: why not?
3707 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3713 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3720 parent.activeChild = null;
3721 if(!style.nonClient /*&& style.isActiveClient*/)
3723 Window previous = parent.activeClient;
3724 if(style.isActiveClient)
3725 parent.activeClient = null;
3726 parent.UpdateActiveDocument(previous);
3730 if(this == guiApp.interimWindow)
3732 guiApp.interimWindow = null;
3733 if(guiApp.caretOwner)
3734 guiApp.caretOwner.UpdateCaret(false, false);
3736 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3743 if(!active || !swap)
3744 UpdateDecorations();
3746 swap.UpdateDecorations();
3748 if(active && rootWindow != this)
3749 ConsequentialMouseMove(false);
3756 // --- Input Messages ---
3757 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3759 static bool reEntrancy = false;
3760 if(reEntrancy) return;
3764 guiApp.cursorUpdate = true;
3765 if(guiApp.windowScrolling && !consequential)
3767 guiApp.windowScrolling.SetScrollPosition(
3768 (guiApp.windowScrolling.sbh) ?
3769 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3770 (guiApp.windowScrolling.sbv) ?
3771 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3773 if(guiApp.windowMoving)
3775 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3777 Window window = guiApp.windowMoving;
3779 int w = window.size.w;
3780 int h = window.size.h;
3785 rx = mouseX - guiApp.windowMovingStart.x;
3786 ry = mouseY - guiApp.windowMovingStart.y;
3789 window.GetDecorationsSize(&ew, &eh);
3791 if(guiApp.windowIsResizing)
3793 x = window.scrolledPos.x;
3794 y = window.scrolledPos.y;
3798 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3799 rx = guiApp.windowResizingBefore.w - aw;
3800 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3801 w = guiApp.windowResizingBefore.w - rx;
3805 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3806 ry = guiApp.windowResizingBefore.h - ah;
3807 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3808 ry = Max(ry, -guiApp.windowMovingBefore.y);
3809 h = guiApp.windowResizingBefore.h - ry;
3811 if(guiApp.resizeEndX)
3813 w = guiApp.windowResizingBefore.w + rx;
3816 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3824 w = Max(w, window.minSize.w);
3825 h = Max(h, window.minSize.h);
3826 w = Min(w, window.maxSize.w);
3827 h = Min(h, window.maxSize.h);
3829 if(!window.OnResizing(&w, &h))
3831 w = window.clientSize.w;
3832 h = window.clientSize.h;
3835 w = Max(w, window.skinMinSize.w);
3836 h = Max(h, window.skinMinSize.h);
3843 SNAPDOWN(w, textCellW);
3844 SNAPDOWN(h, textCellH);
3849 aw = Max(w,window.skinMinSize.w);
3850 rx = guiApp.windowResizingBefore.w - aw;
3851 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3852 w = guiApp.windowResizingBefore.w - rx;
3856 ah = Max(h,window.skinMinSize.h);
3857 ry = guiApp.windowResizingBefore.h - ah;
3858 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3859 ry = Max(ry, -guiApp.windowMovingBefore.y);
3860 h = guiApp.windowResizingBefore.h - ry;
3865 if(!guiApp.windowIsResizing || guiApp.resizeX)
3866 x = guiApp.windowMovingBefore.x + rx;
3867 if(!guiApp.windowIsResizing || guiApp.resizeY)
3868 y = guiApp.windowMovingBefore.y + ry;
3870 if(!guiApp.windowIsResizing)
3873 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3875 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3876 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3877 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3878 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3882 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3883 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3889 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3891 if(!window.OnMoving(&x, &y, w, h))
3893 x = window.scrolledPos.x;
3894 y = window.scrolledPos.y;
3900 SNAPDOWN(x, textCellW);
3901 SNAPDOWN(y, textCellH);
3904 if(!window.style.nonClient)
3906 if(!window.style.fixed /*|| window.style.isDocument*/)
3908 if(!window.style.dontScrollHorz)
3909 x += window.parent.scroll.x;
3910 if(!window.style.dontScrollVert)
3911 y += window.parent.scroll.y;
3915 // Break the anchors for moveable/resizable windows
3916 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3917 if(window.style.fixed)
3919 if(window.state == normal)
3921 window.normalAnchor = Anchor { left = x, top = y };
3922 window.normalSizeAnchor = SizeAnchor { { w, h } };
3923 window.anchored = false;
3927 window.stateAnchor = Anchor { left = x, top = y };
3928 window.stateSizeAnchor = SizeAnchor { { w, h } };
3930 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3931 // TOCHECK: Investigate why the following only redraws the scrollbars
3932 //window.Position(x, y, w, h, false, true, true, true, false, true);
3934 guiApp.movingLast.x = mouseX;
3935 guiApp.movingLast.y = mouseY;
3941 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3944 bool wasMoving = guiApp.windowMoving ? true : false;
3945 bool wasScrolling = guiApp.windowScrolling ? true : false;
3947 while(result && w != this)
3949 Window msgWindow = GetAtPosition(x,y, false, true, w);
3950 Window trueWindow = GetAtPosition(x,y, false, false, w);
3951 bool windowDragged = false;
3956 window = (w && !w.disabled) ? w : null;
3958 if(trueWindow) incref trueWindow;
3960 if(consequential) mods->isSideEffect = true;
3962 UpdateMouseMove(x, y, consequential);
3964 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3966 if(!guiApp.windowCaptured.isEnabled)
3967 guiApp.windowCaptured.ReleaseCapture();
3969 window = guiApp.windowCaptured;
3972 if(trueWindow && activate &&
3973 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3974 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3975 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3976 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3978 if(mods->alt && !mods->ctrl && !mods->shift)
3980 Window moved = trueWindow;
3981 for(moved = trueWindow; moved; moved = moved.parent)
3982 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3987 windowDragged = true;
3989 // Cancel the ALT menu toggling...
3990 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3995 if(window && activate &&
3996 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3997 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3998 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3999 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
4001 Window modalWindow = window.FindModal();
4003 /*if(mods->alt && !mods->shift && !mods->ctrl)
4005 Window moved = window;
4006 for(moved = window; moved; moved = moved.parent)
4007 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4012 windowDragged = true;
4014 // Cancel the ALT menu toggling...
4015 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4021 Window activateWindow = modalWindow ? modalWindow : window;
4022 if(activateWindow && !activateWindow.isRemote)
4024 bool doActivation = true;
4025 //bool needToDoActivation = false;
4026 Window check = activateWindow;
4028 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4030 if(!check.style.inactive)
4032 //needToDoActivation = true;
4034 doActivation = false;
4039 if(!needToDoActivation)
4040 doActivation = false;
4043 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4044 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4046 // Let the OnLeftButtonDown do the activating instead
4047 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4055 incref activateWindow;
4056 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4058 delete activateWindow;
4062 if(activateWindow._refCount == 1)
4064 delete activateWindow;
4068 delete activateWindow;
4070 mods->isActivate = true;
4074 if(!modalWindow && window && !window.destroyed)
4076 if(!guiApp.windowCaptured || windowDragged)
4078 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4080 bool moving = ((window.state != maximized &&
4081 window.IsMouseMoving(
4082 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4083 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4085 if(!moving && window.IsMouseResizing(
4086 x - window.absPosition.x,
4087 y - window.absPosition.y,
4088 window.size.w, window.size.h,
4089 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4091 guiApp.windowIsResizing = true;
4092 guiApp.windowResizingBefore.w = window.size.w;
4093 guiApp.windowResizingBefore.h = window.size.h;
4095 if(guiApp.windowIsResizing || windowDragged || moving)
4098 guiApp.windowMoving = window;
4099 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4100 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4101 guiApp.windowMovingBefore.x = window.position.x;//s;
4102 guiApp.windowMovingBefore.y = window.position.y;//s;
4103 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4104 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4107 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4109 if(window.style.fixed &&
4111 window.IsMouseMoving(
4112 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4114 window.ShowSysMenu(x, y);
4118 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4120 if(window.sbv || window.sbh)
4123 guiApp.windowScrolling = window;
4124 guiApp.windowScrollingStart.x = x;
4125 guiApp.windowScrollingStart.y = y;
4126 guiApp.windowScrollingBefore.x = window.scroll.x;
4127 guiApp.windowScrollingBefore.y = window.scroll.y;
4130 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4132 if(window.style.hasMaximize &&
4133 window.IsMouseMoving(
4134 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4137 (window.state == maximized) ? normal : maximized, false, *mods);
4145 if(guiApp.windowMoving)
4147 if(guiApp.windowMoving.parent)
4149 if(guiApp.windowMoving.style.nonClient)
4150 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4152 guiApp.windowMoving.parent.SetMouseRangeToClient();
4156 window.UpdateDecorations();
4159 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4161 // Log("\n*** LEFT BUTTON UP ***\n");
4162 if(guiApp.windowMoving)
4163 guiApp.windowMoving.StopMoving();
4165 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4167 if(guiApp.windowScrolling)
4169 Window windowScrolling = guiApp.windowScrolling;
4170 guiApp.windowScrolling = null;
4171 windowScrolling.ReleaseCapture();
4175 if(!result || (window && window.destroyed)) window = null;
4177 if(window && window.FindModal())
4180 if(trueWindow && trueWindow.FindModal())
4188 msgWindow = GetAtPosition(x,y, true, false);
4190 msgWindow.SelectMouseCursor();
4193 if(guiApp.windowCaptured || trueWindow)
4195 Window prevWindow = guiApp.prevWindow;
4196 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4198 guiApp.prevWindow.mouseInside = false;
4199 guiApp.prevWindow = null;
4201 // Eventually fix this not to include captured?
4202 if(!prevWindow.OnMouseLeave(*mods))
4205 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4207 Box box = trueWindow.box;
4208 box.left += trueWindow.absPosition.x;
4209 box.right += trueWindow.absPosition.x;
4210 box.top += trueWindow.absPosition.y;
4211 box.bottom += trueWindow.absPosition.y;
4213 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4215 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4216 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4218 overX = Max(Min(overX, 32767),-32768);
4219 overY = Max(Min(overY, 32767),-32768);
4221 trueWindow.mouseInside = true;
4222 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4226 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4227 guiApp.prevWindow = trueWindow;
4229 guiApp.prevWindow = null;
4231 SelectMouseCursor();
4233 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4235 int clientX = x - (window.absPosition.x + window.clientStart.x);
4236 int clientY = y - (window.absPosition.y + window.clientStart.y);
4238 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4240 clientX = Max(Min(clientX, 32767),-32768);
4241 clientY = Max(Min(clientY, 32767),-32768);
4243 MouseMethod = (void *)window._vTbl[method];
4245 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4248 if(!MouseMethod(window, clientX, clientY, *mods))
4255 if(result && w && w.clickThrough && w.parent)
4260 if(!result || !w || !w.clickThrough)
4267 // --- Mouse cursor management ---
4269 bool KeyMessage(uint method, Key key, unichar character)
4274 if(guiApp.interimWindow)
4275 this = guiApp.interimWindow;
4278 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4282 if(!style.inactive || rootWindow != this)
4284 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4285 Window modalWindow = FindModal();
4286 Window interimMaster = master ? master.rootWindow : null;
4290 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4291 status = OnSysKeyDown(key, character);
4292 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4293 status = OnSysKeyHit(key, character);
4294 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4295 status = OnSysKeyUp(key, character);
4302 // Process Key Message for Internal UI Keyboard actions
4303 if(status && !destroyed && menuBar && state != minimized)
4306 if((SmartKey)key != alt)
4307 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4310 SmartKey sk = (SmartKey) key;
4311 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4313 status = menuBar.KeyMessage(method, key, character);
4318 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4319 menuBar.OnKeyHit(escape, 0);
4321 if(!menuBar.focus && guiApp.caretOwner)
4322 guiApp.caretOwner.UpdateCaret(true, false);
4325 if(!destroyed && status)
4327 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4331 case left: case up: case right: case down:
4332 if(guiApp.windowMoving == this)
4335 int w = guiApp.windowMoving.size.w;
4336 int h = guiApp.windowMoving.size.h;
4337 int x = guiApp.windowMoving.scrolledPos.x;
4338 int y = guiApp.windowMoving.scrolledPos.y;
4342 if(key == down || key == up)
4343 step = Max(step, textCellH);
4345 step = Max(step, textCellW);
4348 if(guiApp.windowIsResizing)
4352 case left: w-=step; break;
4353 case right: w+=step; break;
4354 case up: h-=step; break;
4355 case down: h+=step; break;
4362 case left: x-=step; break;
4363 case right: x+=step; break;
4364 case up: y-=step; break;
4365 case down: y+=step; break;
4369 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4370 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4372 if(!guiApp.windowIsResizing || guiApp.resizeX)
4373 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4375 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4377 if(!guiApp.windowIsResizing || guiApp.resizeY)
4378 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4380 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4382 guiApp.interfaceDriver.SetMousePosition(x, y);
4383 ConsequentialMouseMove(true);
4391 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4393 guiApp.windowMoving.StopMoving();
4394 ConsequentialMouseMove(false);
4402 ShowSysMenu(absPosition.x, absPosition.y);
4410 if(!destroyed && status && state != minimized)
4412 // Process all the way down the children
4413 if(activeChild && !activeChild.disabled)
4415 status = activeChild.KeyMessage(method, key, character);
4417 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4418 key.code != left && key.code != right && key.code != up && key.code != down)
4420 status = activeClient.KeyMessage(method, key, character);
4424 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4426 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4427 // && defaultControl != activeChild)
4429 delete previousActive;
4430 previousActive = activeChild;
4431 if(previousActive) incref previousActive;
4433 ConsequentialMouseMove(false);
4434 if((defaultControl.active ||
4435 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4436 defaultControl.KeyMessage(method, defaultKey, character);
4442 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4444 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4451 ShowSysMenu(absPosition.x, absPosition.y);
4458 if(this != guiApp.desktop)
4460 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4462 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4464 MenuMoveOrSize(key.shift, true);
4468 else if(guiApp.windowMoving)
4470 guiApp.windowMoving.StopMoving();
4471 ConsequentialMouseMove(false);
4479 if(!destroyed && status && state != minimized)
4481 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4485 case tab: case shiftTab:
4487 Window cycleParent = this;
4488 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4489 cycleParent = master.parent;
4491 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4493 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4495 Window child = cycleParent.activeChild;
4497 // Scroll the window to include the active control
4499 if(cycleParent.sbh && !child.style.dontScrollHorz)
4501 if(child.scrolledPos.x < 0)
4502 cycleParent.sbh.Action(Position,
4503 cycleParent.scroll.x + child.scrolledPos.x, 0);
4504 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4505 cycleParent.sbh.Action(Position,
4506 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4508 if(cycleParent.sbv && !child.style.dontScrollVert)
4510 if(child.scrolledPos.y < 0)
4511 cycleParent.sbv.Action(Position,
4512 cycleParent.scroll.y + child.scrolledPos.y, 0);
4513 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4514 cycleParent.sbv.Action(Position,
4515 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4518 cycleParent.ConsequentialMouseMove(false);
4524 case f6: case shiftF6:
4525 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4527 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4528 if(parent == guiApp.desktop)
4529 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4539 if(CycleChildren(key.shift, true, false, true))
4547 // mIRC Style Window Shortcuts
4548 case alt1: case alt2: case alt3: case alt4: case alt5:
4549 case alt6: case alt7: case alt8: case alt9: case alt0:
4554 for(document = children.first; document; document = document.next)
4556 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4558 if(document == activeChild)
4560 if(document.state == minimized)
4561 document.SetState(normal, false, key);
4564 document.SetState(minimized, false, key);
4565 CycleChildren(false, true, false);
4570 if(activeChild.state == maximized && document.style.hasMaximize)
4571 document.SetState(maximized, false, key);
4572 else if(document.state == minimized)
4573 document.SetState(normal, false, key);
4574 document.Activate();
4589 if(!destroyed && status)
4591 if(state == minimized)
4596 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4598 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4600 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4601 previousActive.ActivateEx(true, false, false, true, null, null);
4602 delete previousActive;
4608 if(!destroyed && status)
4610 status = ProcessHotKeys(method, key, character);
4612 if(!destroyed && status && !modalWindow && state != minimized)
4615 status = KeyMethod(this, key, character);
4616 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4617 status = OnKeyHit(key, character);
4618 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4620 bool result = false;
4623 case ctrlUp: case ctrlDown:
4624 if(sbv && !guiApp.windowScrolling)
4625 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4627 case wheelUp: case wheelDown:
4628 if(sbv && !guiApp.windowScrolling)
4630 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4631 // Do we want to do a consequential move regardless of result in this case?
4632 ConsequentialMouseMove(false);
4635 case ctrlPageUp: case ctrlPageDown:
4636 if(sbh && !guiApp.windowScrolling)
4637 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4642 ConsequentialMouseMove(false);
4647 if(status && !destroyed && menuBar && state != minimized)
4648 status = menuBar.KeyMessage(method, key, character);
4650 if(style.interim && /*destroyed && */status && interimMaster)
4652 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4653 status = interimMaster.KeyMessage(method, key, character);
4660 bool ProcessHotKeys(uint method, Key key, unichar character)
4665 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4666 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4667 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4669 Window hotKeyWindow = hotKey.window;
4670 Window parent = hotKeyWindow.parent;
4671 Window prevActiveWindow = activeChild;
4672 // For when sys buttons are placed inside the menu bar
4673 if(parent && parent._class == class(PopupMenu))
4674 parent = parent.parent;
4676 // 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
4677 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4680 if(prevActiveWindow) incref prevActiveWindow;
4681 incref hotKeyWindow;
4682 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4683 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4686 delete hotKeyWindow;
4687 delete prevActiveWindow;
4691 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4692 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4693 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4695 // ********* WORKING ON THIS ***********
4696 if(prevActiveWindow && !guiApp.interimWindow)
4697 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4700 else if(hotKeyWindow.style.inactive)
4701 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4703 delete prevActiveWindow;
4704 delete hotKeyWindow;
4705 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4706 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4710 if(status && tabCycle)
4713 for(child = children.first; child; child = child.next)
4715 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4726 // --- Windows and graphics initialization / termination ---
4727 bool SetupRoot(void)
4731 // Setup relationship with outside world (bb root || !bb)
4732 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4733 (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
4737 tempExtents = new0 Extent[4];
4742 /*if(guiApp.fullScreenMode)
4743 rootWindow = guiApp.desktop;
4745 //rootWindow = parent.created ? parent.rootWindow : null;
4746 rootWindow = parent.rootWindow;
4749 against = &parent.box;
4751 against = &parent.clientArea;
4754 for(child = children.first; child; child = child.next)
4757 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4760 bool Setup(bool positionChildren)
4762 bool result = false;
4765 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))))
4767 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4768 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4770 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4772 // This was here, is it really needed?
4773 //guiApp.interfaceDriver.ActivateRootWindow(this);
4777 displaySystem = DisplaySystem {};
4778 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4780 delete displaySystem;
4785 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4786 if(display.Create(displaySystem, windowHandle))
4793 // Sometimes icon does not show up on Windows XP if we set here...
4794 // guiApp.interfaceDriver.SetIcon(this, icon);
4796 else if(this != guiApp.desktop)
4798 display = rootWindow ? rootWindow.display : null;
4804 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4805 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4807 for(child = children.first; child; child = child.next)
4809 if(child.created && !child.Setup(false))
4815 bool SetupDisplay(void)
4817 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4818 if(is3D) return Window3D_SetupDisplay(this); else
4825 class_data void ** pureVTbl;
4827 bool LoadGraphics(bool creation, bool resetAnchors)
4829 bool result = false;
4830 bool success = false;
4832 WindowState stateBackup = state;
4834 if(((subclass(Window))_class).pureVTbl)
4836 if(_vTbl == _class._vTbl)
4838 _vTbl = ((subclass(Window))_class).pureVTbl;
4843 for(m = 0; m < _class.vTblSize; m++)
4845 if(_vTbl[m] == _class._vTbl[m])
4846 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4850 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4852 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4854 _vTbl = _class._vTbl;
4859 for(m = 0; m < _class.vTblSize; m++)
4861 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4862 _vTbl[m] = _class._vTbl[m];
4867 if(guiApp.fullScreenMode || this != guiApp.desktop)
4869 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4875 display.Lock(false);
4876 if(rootWindow == this)
4878 // Set Color Palette
4879 display.SetPalette(palette, true);
4883 if(guiApp.fullScreenMode && this == guiApp.desktop)
4888 for(c=0; c<SystemCursor::enumSize; c++)
4889 if(!guiApp.systemCursors[c].bitmap)
4891 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4892 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4893 if(guiApp.systemCursors[c].bitmapName)
4895 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4896 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4897 if(guiApp.systemCursors[c].bitmap)
4898 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4903 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4905 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4906 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4908 cursor.bitmap.paletteShades = cursor.paletteShades;
4912 guiApp.cursorUpdate = true;
4915 ConsequentialMouseMove(false);
4921 // Load Window Graphic Resources
4924 if(usedFont == setFont || usedFont == window.systemFont)
4925 RemoveResource(usedFont);
4928 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4931 RemoveResource(systemFont);
4934 RemoveResource(captionFont);
4936 for(ptr = resources.first; ptr; ptr = ptr.next)
4938 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4941 AddResource(setFont);
4943 AddResource(systemFont);
4945 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4952 //if(master && master.font)
4953 if(parent && parent.font)
4957 faceName = parent.font.faceName,
4958 size = parent.font.size,
4959 bold = parent.font.bold,
4960 italic = parent.font.italic,
4961 underline = parent.font.underline
4963 //font = parent.font;
4964 watch(parent) { font { } };
4967 font = guiApp.currentSkin.SystemFont();
4974 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4975 AddResource(captionFont);
4977 if(OnLoadGraphics())
4983 //SetScrollLineStep(sbStep.x, sbStep.y);
4985 if(this != guiApp.desktop)
4989 normalAnchor = anchor;
4990 normalSizeAnchor = sizeAnchor;
4993 // Break the anchors for moveable/resizable windows
4995 if(style.fixed && style.isDocument)
4997 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5009 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5010 stateSizeAnchor = SizeAnchor {};
5015 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5020 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5021 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5024 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5028 stateAnchor = normalAnchor;
5029 stateSizeAnchor = normalSizeAnchor;
5032 position = Point { };
5033 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5044 if(Position(x, y, w, h, true, false, true, true, true, true))
5046 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5049 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5066 success = result = true;
5069 if(!creation && result)
5071 // Load menu bar first because sys buttons are on it...
5074 if(!menuBar.LoadGraphics(false, resetAnchors))
5080 for(child = children.first; child; child = child.next)
5082 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5089 CreateSystemChildren();
5093 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5096 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5101 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5102 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5105 // Do this here to avoid problems on Windows
5106 if(stateBackup == maximized)
5107 property::state = maximized;
5111 void UnloadGraphics(bool destroyWindows)
5115 // Free children's graphics
5116 for(child = children.first; child; child = child.next)
5117 child.UnloadGraphics(destroyWindows);
5120 display.Lock(false);
5123 if(guiApp.fullScreenMode && this == guiApp.desktop)
5128 for(c=0; c<SystemCursor::enumSize; c++)
5129 if(guiApp.systemCursors[c].bitmap)
5130 delete guiApp.systemCursors[c].bitmap;
5132 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5133 delete cursor.bitmap;
5135 guiApp.cursorBackground.Free();
5138 if(display && display.displaySystem)
5142 for(ptr = resources.first; ptr; ptr = ptr.next)
5146 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5151 // Free window graphics
5154 // Free skin graphics
5155 if(rootWindow == this)
5157 DisplaySystem displaySystem = display.displaySystem;
5160 display.driverData = null;
5161 display.displaySystem = null;
5165 if(displaySystem && !displaySystem.numDisplays && !is3D)
5166 delete displaySystem;
5175 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5176 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5178 if(this == guiApp.desktop || parent == guiApp.desktop)
5180 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5181 guiApp.interfaceDriver.DestroyRootWindow(this);
5185 // --- Window Hiding ---
5187 void SetVisibility(bool state)
5189 bool visible = (style.hidden || !created) ? false : state;
5190 if(visible != this.visible)
5194 this.visible = visible;
5195 for(child = children.first; child; child = child.next)
5196 child.SetVisibility(visible);
5198 ConsequentialMouseMove(false);
5199 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5203 // --- Windows and graphics initialization / termination ---
5205 bool DisplayModeChanged(void)
5207 bool result = false;
5208 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5210 guiApp.modeSwitching = true;
5211 UnloadGraphics(false);
5213 if(LoadGraphics(false, false))
5215 guiApp.modeSwitching = false;
5220 // --- Window updates system ---
5222 void UpdateDirty(Box updateBox)
5224 if(!manageDisplay) { OnRedraw(null);return; }
5227 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5230 if(display.flags.flipping)
5233 rootWindow.UpdateDisplay();
5236 UpdateBackDisplay(updateBox);
5238 if(guiApp.fullScreenMode)
5240 guiApp.cursorUpdate = true;
5241 guiApp.PreserveAndDrawCursor();
5243 if(guiApp.fullScreenMode)
5244 guiApp.RestoreCursorBackground();
5250 // This function is strictly called as a result of system window activation
5251 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5254 Window interimMaster = null;
5255 Window interimWindow = guiApp.interimWindow;
5256 if(interimWindow && interimWindow.master)
5257 interimMaster = interimWindow.master.rootWindow;
5259 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5260 // SetState(normal, false, 0);
5261 SetState(lastState, false, 0);
5263 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5267 /* WTH is this doing here?
5268 while(swap && swap.activeChild)
5270 swap = swap.activeChild;
5273 // TESTING THIS BEFORE...
5274 if(interimWindow && this == interimMaster)
5278 // Window interimSwap = this;
5279 Window menuBar = this.menuBar;
5280 if(menuBar && interimWindow.master == menuBar)
5283 while(interimSwap && interimSwap.activeChild)
5284 interimSwap = interimSwap.activeChild;
5286 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5287 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5289 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5290 //result = ActivateEx(true, true, false, activateRoot, window, null);
5295 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5296 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5298 if(interimWindow == this && interimMaster && !active)
5300 while(interimMaster && interimMaster.interim && interimMaster.master)
5302 // printf("Going up one master %s\n", interimMaster._class.name);
5303 interimMaster = interimMaster.master.rootWindow;
5305 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5306 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5312 bool DestroyEx(int64 returnCode)
5315 Timer timer, nextTimer;
5317 OldLink prevOrder = null;
5318 Window client = null;
5320 if(parent) stopwatching(parent, font);
5322 // if(window.modalSlave) return false;
5323 if(destroyed || !created)
5330 OldLink slave = master.slaves.FindLink(this);
5331 master.slaves.Delete(slave);
5334 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5340 this.returnCode = (DialogResult)returnCode;
5342 AcquireInput(false);
5347 master.hotKeys.Delete(hotKey);
5351 if(guiApp.prevWindow == this)
5353 guiApp.prevWindow = null;
5356 if(guiApp.caretOwner == this)
5358 guiApp.interfaceDriver.SetCaret(0,0,0);
5359 UpdateCaret(false, true);
5360 guiApp.caretEnabled = false;
5365 parent.childrenCycle.Remove(cycle);
5369 OldLink tmpPrev = order.prev;
5370 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5371 prevOrder = tmpPrev;
5374 client = tmpPrev ? tmpPrev.data : null;
5375 if(client == this) { client = null; break; }
5376 if(client && (client.style.hidden || client.destroyed || !client.created))
5377 tmpPrev = client.order.prev;
5381 prevOrder = tmpPrev;
5386 // If this window can be an active client, make sure the next window we activate can also be one
5387 if(!style.nonClient && style.isActiveClient)
5389 tmpPrev = prevOrder;
5392 client = tmpPrev ? tmpPrev.data : null;
5393 if(client == this) { client = null; break; }
5394 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5395 tmpPrev = client.order.prev;
5399 prevOrder = tmpPrev;
5403 if(client && client.style.hidden) client = null;
5405 // parent.childrenOrder.Remove(order);
5408 if(parent && style.isActiveClient && visible)
5410 if(state == minimized) parent.numIcons--;
5411 parent.numPositions--;
5414 // TESTING THIS HERE!
5418 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5419 // to create a window inside a rootwindow that's being destroyed)
5420 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5422 if(master && !master.destroyed /*&&
5423 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5425 if(master.defaultControl == this)
5426 master.defaultControl = null;
5429 parent.OnChildAddedOrRemoved(this, true);
5430 if(parent && !parent.destroyed /*&&
5431 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5433 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5435 if(order && prevOrder && prevOrder.data != this && active)
5437 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5439 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5440 if(parent.activeClient == this)
5442 parent.activeClient = null;
5443 parent.UpdateActiveDocument(null);
5448 if(guiApp.interimWindow == this)
5451 PropagateActive(false, null, &goOn, true);
5455 //if(window.parent.activeChild == window)
5456 parent.activeChild = null;
5457 if(!style.nonClient /*&& style.isActiveClient*/)
5459 Window previous = parent.activeClient;
5460 if(style.isActiveClient)
5461 parent.activeClient = null;
5462 parent.UpdateActiveDocument(previous);
5467 else if(parent.activeClient == this)
5469 parent.activeClient = client;
5470 parent.UpdateActiveDocument(this);
5474 if(guiApp.interimWindow == this)
5476 guiApp.interimWindow = null;
5477 if(guiApp.caretOwner)
5479 Window desktop = guiApp.desktop;
5480 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5481 guiApp.caretOwner.UpdateCaret(false, false);
5486 if(_isModal && master && master.modalSlave == this)
5487 master.modalSlave = null;
5491 if(!guiApp.caretOwner && parent.caretSize)
5493 guiApp.caretOwner = parent;
5494 parent.UpdateCaret(false, false);
5495 parent.Update(null);
5498 // Why was this commented out?
5499 GetRidOfVirtualArea();
5505 dirtyArea.Free(null);
5506 dirtyBack.Free(null);
5507 scrollExtent.Free(null);
5509 /* ATTEMPTING TO MOVE THAT ABOVE
5518 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5519 for(;(child = window.children.first);)
5521 for(; child && (child.destroyed || !child.created); child = child.next);
5530 UnloadGraphics(true);
5533 delete previousActive;
5536 // statusBar = null;
5539 if(master && !master.destroyed)
5541 //master.NotifyDestroyed(this, this.returnCode);
5542 NotifyDestroyed(master, this, this.returnCode);
5545 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5547 nextTimer = timer.next;
5548 if(timer.window == this)
5550 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5551 // timer.window = null;
5557 if(this == guiApp.windowMoving)
5560 if(guiApp.windowCaptured == this)
5562 //guiApp.windowCaptured = null;
5564 if(rootWindow != this && rootWindow)
5565 rootWindow.ConsequentialMouseMove(false);
5573 //for(child = children.first; next = child ? child.next : null, child; child = next)
5574 for(;(child = children.first); )
5576 for(; child && (child.destroyed || !child.created); child = child.next);
5586 /* // MOVED THIS UP...
5589 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5590 for(;(child = window.children.first); )
5592 for(; child && (child.destroyed || !child.created); child = child.next);
5601 while((slave = slaves.first))
5603 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5605 ((Window)slave.data).DestroyEx(0);
5610 if(guiApp.caretOwner == this)
5611 guiApp.caretOwner = null;
5613 sysButtons[0] = null;
5614 sysButtons[1] = null;
5615 sysButtons[2] = null;
5618 if(rootWindow != this)
5620 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5623 box.left -= parent.clientStart.x;
5624 box.top -= parent.clientStart.y;
5625 box.right -= parent.clientStart.x;
5626 box.bottom -= parent.clientStart.y;
5628 if(parent) parent.Update(box);
5633 OldLink slave = master.slaves.FindVoid(this);
5634 master.slaves.Delete(slave);
5640 parent.children.Remove(this);
5645 //autoCreate = false;
5648 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5649 if(((subclass(Window))_class).pureVTbl)
5651 if(_vTbl == _class._vTbl)
5653 _vTbl = ((subclass(Window))_class).pureVTbl;
5658 for(m = 0; m < _class.vTblSize; m++)
5660 if(_vTbl[m] == _class._vTbl[m])
5661 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5670 void SetStateEx(WindowState newState, bool activate)
5673 WindowState prevState = state;
5677 if(prevState != newState)
5678 lastState = prevState;
5680 if(rootWindow != this || !nativeDecorations || !windowHandle)
5682 if(style.isActiveClient && !style.hidden && prevState == minimized)
5685 // This block used to be at the end of the function... moved it for flicker problem in X
5686 // ------------------------------------------------------
5690 stateAnchor = normalAnchor;
5691 stateSizeAnchor = normalSizeAnchor;
5694 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5695 stateSizeAnchor = SizeAnchor {};
5699 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5702 byte * idBuffer = new0 byte[size];
5704 for(child = parent.children.first; child; child = child.next)
5706 if(child != this && child.state == minimized)
5708 if(child.iconID > size - 2)
5710 idBuffer = renew0 idBuffer byte[size*2];
5711 memset(idBuffer + size, 0, size);
5714 idBuffer[child.iconID] = (byte)bool::true;
5717 for(c = 0; c<size; c++)
5722 if(style.isActiveClient && !style.hidden)
5725 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5726 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5730 // TOCHECK: Why was this here?
5731 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5732 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5733 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5735 Position(x, y, w, h, true, true, true, true, false, true);
5737 if(!style.inactive && !style.interim && this == parent.activeClient)
5738 parent.UpdateActiveDocument(null);
5741 CreateSystemChildren();
5742 // ------------------------------------------------------
5745 int GetPositionID(Window forChild)
5749 byte * idBuffer = new0 byte[size];
5752 for(child = children.first; child; child = child.next)
5754 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5756 if(child.positionID > size - 2)
5758 idBuffer = renew0 idBuffer byte[size*2];
5759 memset(idBuffer + size, 0, size);
5762 idBuffer[child.positionID] = (byte)bool::true;
5765 for(c = 0; c<size; c++)
5772 // --- Window related graphics ---
5774 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5776 palette = newPalette;
5777 if(rootWindow.display)
5778 rootWindow.display.SetPalette(palette, colorMatch);
5781 public bool AcquireInput(bool acquired)
5784 if(acquiredInput != acquired)
5786 if(active || (!visible && creationActivation == activate))
5787 result = AcquireInputEx(acquired);
5792 acquiredInput = acquired ? result : !result;
5797 void ListChildren(ListBox listBox)
5801 for(child = children.first; child; child = child.next)
5803 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5805 DataRow row = listBox.AddRow();
5806 row.tag = (int64)child;
5807 child.FigureCaption(caption);
5808 row.SetData(null, caption);
5813 void UpdateVisual(Box extent)
5815 if(guiApp.driver != null)
5817 if(guiApp.fullScreenMode && guiApp.desktop.display)
5819 guiApp.desktop.mutex.Wait();
5820 guiApp.desktop.display.Lock(true);
5823 if(guiApp.desktop.active)
5825 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5827 if(guiApp.desktop.display.flags.flipping)
5828 guiApp.desktop.Update(null);
5829 guiApp.desktop.UpdateDisplay();
5830 guiApp.cursorUpdate = true;
5832 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5834 guiApp.PreserveAndDrawCursor();
5835 // guiApp.desktop.display.ShowScreen();
5836 guiApp.cursorUpdate = false;
5837 guiApp.desktop.dirty = false;
5838 guiApp.RestoreCursorBackground();
5842 guiApp.desktop.display.Unlock();
5843 guiApp.desktop.mutex.Release();
5847 Window rootWindow = this.rootWindow;
5848 rootWindow.mutex.Wait();
5853 guiApp.SignalEvent();
5856 guiApp.waitMutex.Wait();
5857 guiApp.interfaceDriver.Lock(rootWindow);
5858 if(!rootWindow.style.hidden && rootWindow.dirty)
5860 if(rootWindow.display)
5862 rootWindow.UpdateDisplay();
5863 //rootWindow.display.ShowScreen(null);
5865 rootWindow.dirty = false;
5867 guiApp.interfaceDriver.Unlock(rootWindow);
5868 guiApp.waitMutex.Release();
5871 rootWindow.mutex.Release();
5876 void UnlockDisplay(void)
5878 guiApp.interfaceDriver.Unlock(rootWindow);
5881 void LockDisplay(void)
5883 guiApp.interfaceDriver.Lock(rootWindow);
5886 Surface GetSurface(Box box)
5888 return Redraw((box == null) ? this.box : box);
5891 void SetMousePosition(int x, int y)
5893 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5897 void IntegrationActivate(bool active)
5899 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5901 isForegroundWindow = true;
5902 ActivateEx(active, active, false, false, null, null);
5903 isForegroundWindow = false;
5908 Window QueryCapture(void)
5910 return guiApp.windowCaptured;
5913 int GetDocumentID(void)
5917 byte * idBuffer = new0 byte[size];
5920 for(child = children.first; child; child = child.next)
5922 // TO CHECK: Do we want a documentID when we already have a file name?
5923 if(child.style.isDocument && !child.fileName)
5925 if(child.documentID-1 > size - 2)
5927 idBuffer = renew0 idBuffer byte[size*2];
5928 memset(idBuffer + size, 0, size);
5931 idBuffer[child.documentID-1] = 1;
5934 for(c = 0; c<size; c++)
5942 void SetInitSize(Size size)
5945 sizeAnchor.size = size;
5946 normalSizeAnchor = sizeAnchor;
5948 // Break the anchors for moveable/resizable windows
5949 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5951 stateAnchor = normalAnchor;
5952 stateSizeAnchor = normalSizeAnchor;
5954 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5955 Position(x,y, w, h, true, true, true, true, false, true);
5959 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5961 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5963 guiApp.windowIsResizing = resize;
5964 guiApp.windowMoving = this;
5965 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5966 if(guiApp.windowIsResizing)
5968 guiApp.windowMovingStart.x += size.w - 1;
5969 guiApp.windowMovingStart.y += size.h - 1;
5971 guiApp.windowMovingBefore = scrolledPos;
5972 guiApp.windowResizingBefore = size;
5973 guiApp.windowMoving.UpdateDecorations();
5974 if(guiApp.windowIsResizing)
5975 guiApp.resizeEndX = guiApp.resizeEndY = true;
5977 if(setCursorPosition)
5978 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5982 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5983 guiApp.windowMovingStart.x += x - absPosition.x;
5984 guiApp.windowMovingStart.y += y - absPosition.y;
5987 if(guiApp.windowMoving)
5989 if(guiApp.windowMoving.style.nonClient)
5990 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5992 guiApp.windowMoving.parent.SetMouseRangeToClient();
5997 if(this == rootWindow)
5998 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6006 bool result = false;
6010 else if(guiApp && guiApp.driver != null)
6012 void * systemParent = null;
6013 OldLink slaveHolder;
6015 bool visible = !style.hidden;
6019 systemParent = parent;
6020 parent = guiApp.desktop;
6022 last = parent ? parent.children.last : null;
6024 if((parent && parent != guiApp.desktop && !parent.created) ||
6025 (master && master != guiApp.desktop && !master.created))
6029 stopwatching(parent, font);
6032 property::parent = guiApp.desktop;
6033 if(!master) master = parent;
6035 if(_isModal && master.modalSlave)
6036 property::master = master.modalSlave;
6040 parent.children.Remove(this);
6043 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6044 if(slaveHolder.data == this)
6046 master.slaves.Delete(slaveHolder);
6051 if(parent == guiApp.desktop && !mutex)
6054 if(style.isDocument)
6057 parent.numDocuments--;
6058 documentID = parent.GetDocumentID();
6061 if(!style.stayOnTop)
6062 for(; last && last.style.stayOnTop; last = last.prev);
6064 parent.children.Insert((last == this) ? null : last, this);
6065 //parent.children.Add(this);
6068 dispDriver = parent.dispDriver;
6071 master.modalSlave = this;
6073 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6078 master.slaves.Add(slaveHolder = OldLink { data = this });
6083 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6085 if(style.isDefault && !master.defaultControl)
6086 master.defaultControl = this;
6088 stateAnchor = normalAnchor = anchor;
6089 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6091 // TOCHECK: Why is this here?
6092 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6093 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6095 this.visible = false;
6096 style.hidden = true;
6099 // autoCreate = true;
6107 if(parent == guiApp.desktop)
6108 Log("LoadGraphics %s\n", caption);
6110 if(LoadGraphics(true, false))
6118 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6125 if(style.hasMenuBar /*&& menu*/)
6131 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6132 interim = false, inactive = true, nonClient = true, size.h = 24
6140 // Create the system buttons
6141 CreateSystemChildren();
6143 UpdateActiveDocument(null);
6145 if(style.isDocument)
6149 MenuItem item = menu.FindItem(MenuFileSave, 0);
6150 if(item) item.disabled = !modifiedDocument && fileName;
6155 if(parent == guiApp.desktop)
6156 Log("Preemptive SetState %s\n", caption);
6159 // Preemptive Set State to ensure proper anchoring
6160 SetStateEx(state, false);
6162 style.hidden = true;
6168 for(child = children.first; child; child = next)
6171 if(!child.created && (child.autoCreate || child.wasCreated))
6178 for(link = slaves.first; link; link = next)
6180 Window slave = link.data;
6182 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6185 // Things might have happened that invalidated 'next'...
6186 // Start over the search for slaves to create.
6187 // (Added this to fix crash with Stacker & Toolbar)
6188 next = slaves.first;
6197 if(parent == guiApp.desktop)
6198 Log("Real SetState %s\n", caption);
6201 if(isActiveClient && visible)
6203 parent.numPositions--;
6204 if(state == minimized) parent.numIcons--;
6207 parent.OnChildAddedOrRemoved(this, false);
6209 // Real set state & activate for proper display & activation
6210 property::visible = visible;
6211 // SetState(state & 0x00000003, true, 0);
6212 guiApp.interfaceDriver.SetIcon(this, icon);
6217 /*if(rootWindow == this)
6218 guiApp.interfaceDriver.ActivateRootWindow(this);
6220 if(creationActivation == activate)
6221 ActivateEx(true, false, true, true, null, null);
6222 else if(creationActivation == flash)
6227 rootWindow.ConsequentialMouseMove(false);
6238 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6244 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6246 //style.hidden = true; // !visible;
6247 style.hidden = !visible;
6248 if(master.modalSlave == this)
6249 master.modalSlave = null;
6256 void WriteCaption(Surface surface, int x, int y)
6259 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6262 void Update(Box region)
6268 rootWindow = this.rootWindow;
6270 // rootWindow.mutex.Wait();
6271 if(!destroyed && visible && display)
6276 // Testing this to avoid repetitve full update to take time...
6277 if(dirtyArea.count == 1)
6279 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6280 if(item.box.left <= box.left &&
6281 item.box.top <= box.top &&
6282 item.box.right >= box.right &&
6283 item.box.bottom >= box.bottom)
6285 rootWindow.dirty = true;
6290 if(display.flags.flipping && !rootWindow.dirty)
6292 if(this == rootWindow)
6296 rootWindow.Update(null);
6301 rootWindow.dirty = true;
6306 realBox.left += clientStart.x;
6307 realBox.top += clientStart.y;
6308 realBox.right += clientStart.x;
6309 realBox.bottom += clientStart.y;
6315 if(realBox.right >= realBox.left &&
6316 realBox.bottom >= realBox.top)
6318 // if(!rootWindow.fullRender)
6319 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6321 for(child = children.first; child; child = child.next)
6326 box.left -= child.absPosition.x - absPosition.x;
6327 box.top -= child.absPosition.y - absPosition.y;
6328 box.right -= child.absPosition.x - absPosition.x;
6329 box.bottom -= child.absPosition.y - absPosition.y;
6330 if(box.right >= child.box.left && box.left <= child.box.right &&
6331 box.bottom >= child.box.top && box.top <= child.box.bottom)
6333 box.left -= child.clientStart.x;
6334 box.top -= child.clientStart.y;
6335 box.right -= child.clientStart.x;
6336 box.bottom -= child.clientStart.y;
6342 realBox.left += absPosition.x - rootWindow.absPosition.x;
6343 realBox.top += absPosition.y - rootWindow.absPosition.y;
6344 realBox.right += absPosition.x - rootWindow.absPosition.x;
6345 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6346 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6349 else if(this == guiApp.desktop)
6352 for(window = children.first; window; window = window.next)
6358 Box childBox = region;
6360 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6361 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6362 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6363 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6365 window.Update(childBox);
6368 window.Update(null);
6373 // rootWindow.mutex.Release();
6380 if(guiApp.windowCaptured != this)
6382 if(guiApp.windowCaptured)
6386 //Logf("Captured %s (%s)\n", caption, class.name);
6387 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6388 guiApp.windowCaptured = this;
6394 bool Destroy(int64 code)
6399 if(!destroyed && !CloseConfirmation(false)) return false;
6403 // TOCHECK: Should autoCreate be set to false here?
6414 void Move(int x, int y, int w, int h)
6416 normalAnchor = Anchor { left = x, top = y };
6417 normalSizeAnchor = SizeAnchor { size = { w, h } };
6419 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6421 if(destroyed) return;
6423 stateAnchor = normalAnchor;
6424 stateSizeAnchor = normalSizeAnchor;
6426 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6427 Position(x,y, w, h, true, true, true, true, false, true);
6431 DialogResult Modal(void)
6437 // FIXES MEMORY LEAK IF Create() FAILED
6443 void SetScrollArea(int width, int height, bool snapToStep)
6445 bool resize = false;
6448 int stepX = sbStep.x, stepY = sbStep.y;
6449 // Needed to make snapped down position match the skin's check of client area
6450 // against realvirtual
6453 SNAPDOWN(stepX, textCellW);
6454 SNAPDOWN(stepY, textCellH);
6455 stepX = Max(stepX, textCellW);
6456 stepY = Max(stepY, textCellH);
6458 if(scrollFlags.snapX)
6459 SNAPUP(width, stepX);
6460 if(scrollFlags.snapY)
6461 SNAPUP(height, stepY);
6464 reqScrollArea.w = width;
6465 reqScrollArea.h = height;
6466 noAutoScrollArea = (width > 0 || height > 0);
6468 UpdateScrollBars(true, true);
6471 void SetScrollPosition(int x, int y)
6474 sbh.Action(setPosition, x, 0);
6478 int seen = clientSize.w, total = reqScrollArea.w;
6480 if(scrollFlags.snapX)
6481 SNAPDOWN(seen, sbStep.x);
6483 if(!total) total = seen;
6484 range = total - seen + 1;
6485 range = Max(range, 1);
6487 if(x >= range) x = range - 1;
6489 if(scrollFlags.snapX)
6490 SNAPUP(x, sbStep.x);
6493 OnHScroll(setPosition, x, 0);
6497 SNAPDOWN(x, textCellW);
6503 sbv.Action(setPosition, y, 0);
6507 int seen = clientSize.h, total = reqScrollArea.h;
6510 if(scrollFlags.snapY)
6511 SNAPDOWN(seen, sbStep.y);
6513 if(!total) total = seen;
6514 range = total - seen + 1;
6515 range = Max(range, 1);
6517 if(y >= range) y = range - 1;
6519 if(scrollFlags.snapY)
6520 SNAPUP(y, sbStep.y);
6523 OnVScroll(setPosition, y, 0);
6526 SNAPDOWN(y, textCellH);
6531 UpdateCaret(false, false);
6534 void SetScrollLineStep(int stepX, int stepY)
6540 SNAPDOWN(stepX, textCellW);
6541 SNAPDOWN(stepY, textCellH);
6542 stepX = Max(stepX, textCellW);
6543 stepY = Max(stepY, textCellH);
6546 sbh.lineStep = stepX;
6548 sbv.lineStep = stepY;
6551 void SetState(WindowState newState, bool activate, Modifiers mods)
6555 if(state == newState || OnStateChange(newState, mods))
6557 WindowState prevState = state;
6561 // This used to be at the end of the brackets... moved for X, testing...
6562 // This has the effect of activating the window through the system...
6563 if(rootWindow == this)
6564 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6566 SetStateEx(newState, activate);
6568 if(rootWindow == this && !rootWindow.nativeDecorations)
6570 int x = position.x, y = position.y;
6573 x -= guiApp.desktop.absPosition.x;
6574 y -= guiApp.desktop.absPosition.y;
6576 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6580 //state = prevState;
6582 if(state != maximized && style.hasMaximize)
6585 for(child = parent.children.first; child; child = child.next)
6587 if(child != this && child.state == maximized)
6588 child.SetStateEx(normal, false);
6592 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6593 parent.UpdateScrollBars(true, true);
6596 // Do we really need this stuff here?
6597 // Shouldn't the Activate stuff take care of it?
6598 if(parent.rootWindow == parent && style)
6601 parent.FigureCaption(caption);
6602 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6603 parent.UpdateDecorations();
6607 rootWindow.ConsequentialMouseMove(false);
6614 BitmapResource GetIcon(SkinBitmap iconID)
6616 return guiApp.currentSkin.GetBitmap(iconID);
6619 void SetMouseRange(Box range)
6621 if(range || guiApp.fullScreenMode)
6626 clip.left = range.left + absPosition.x + clientStart.x;
6627 clip.top = range.top + absPosition.y + clientStart.y;
6628 clip.right = range.right + absPosition.x + clientStart.x;
6629 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6633 clip.left = guiApp.desktop.box.left;
6634 clip.top = guiApp.desktop.box.top;
6635 clip.right = guiApp.desktop.box.right;
6636 clip.bottom = guiApp.desktop.box.bottom;
6638 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6641 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6644 void SetMouseRangeToClient(void)
6646 if(guiApp.fullScreenMode || this != guiApp.desktop)
6648 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6649 box.Clip(clientArea);
6653 SetMouseRange(null);
6656 void SetMouseRangeToWindow(void)
6658 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6659 if(this == guiApp.desktop)
6660 SetMouseRangeToClient();
6665 // x, y: Desktop Coordinates
6666 void ShowSysMenu(int x, int y)
6669 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6672 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6673 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6677 menu, $"Move", m, NotifySelect = MenuWindowMove,
6678 disabled = !style.fixed || state == maximized
6682 menu, $"Size", s, NotifySelect = MenuWindowSize,
6683 disabled = !style.sizable || state != normal
6687 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6688 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6692 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6693 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6697 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6698 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6700 MenuDivider { menu };
6703 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6704 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6706 windowMenu.Create();
6711 ActivateEx(true, true, true, true, null, null);
6714 void MakeActive(void)
6716 ActivateEx(true, false, true, false, null, null);
6719 void SoftActivate(void)
6721 if(guiApp.desktop.active)
6727 void Deactivate(void)
6729 ActivateEx(false, true, true, true, null, null);
6734 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6737 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6739 bool result = false;
6740 if(activeChild && activeChild.cycle)
6742 Window modalWindow, child = activeChild;
6743 if(!clientOnly /*&& parent.tabCycle*/)
6745 Window next = child;
6748 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6752 if(parent && parent.CycleChildren(backward, false, true, true))
6760 next = next.cycle.prev.data;
6762 next = next.cycle.next.data;
6763 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6768 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6769 parent.tabCycle && parent.CycleChildren(backward, false, false))
6773 if(tabCycleOnly && !tabCycle) return false;
6780 child = child.cycle.prev.data;
6782 child = child.cycle.next.data;
6783 if(child == child.parent.activeChild)
6785 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6788 modalWindow = child.FindModal();
6791 // Scroll the window to include the active control
6792 if(sbh && !child.style.dontScrollHorz)
6794 if(child.scrolledPos.x < 0)
6795 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6796 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6797 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6799 if(sbv && !child.style.dontScrollVert)
6801 if(child.scrolledPos.y < 0)
6802 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6803 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6804 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6808 child = modalWindow ? modalWindow : child;
6809 child.ActivateEx(true, true, true, true, null, null);
6810 if(child.tabCycle && child.childrenCycle.first)
6811 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6819 ConsequentialMouseMove(false);
6823 void AddResource(Resource resource)
6827 ResPtr ptr { resource = resource };
6831 // Load Graphics here if window is created already
6832 if(/*created && */display)
6834 display.Lock(false);
6835 ptr.loaded = display.displaySystem.LoadResource(resource);
6839 // Temporary hack to load font right away for listbox in dropbox ...
6840 else if(master && master.display)
6842 master.display.Lock(false);
6843 master.display.displaySystem.LoadResource(resource);
6844 master.display.Unlock();
6850 void RemoveResource(Resource resource)
6855 for(ptr = resources.first; ptr; ptr = ptr.next)
6857 if(ptr.resource == resource)
6863 // Unload Graphics here if window is created already
6864 if(/*created && */display)
6868 display.Lock(false);
6869 display.displaySystem.UnloadResource(resource, ptr.loaded);
6875 resources.Delete(ptr);
6880 void SetCaret(int x, int y, int size)
6887 if(active && !style.interim)
6889 if(visible || !guiApp.caretOwner)
6890 guiApp.caretOwner = size ? this : null;
6892 UpdateCaret(false, false);
6895 guiApp.interfaceDriver.SetCaret(0,0,0);
6896 UpdateCaret(false, true);
6897 guiApp.caretEnabled = false;
6900 else if(style.inactive && active)
6902 guiApp.interfaceDriver.SetCaret(0,0,0);
6903 UpdateCaret(false, true);
6904 guiApp.caretEnabled = false;
6909 void Scroll(int x, int y)
6911 bool opaque = !style.drawBehind || background.a;
6912 if(opaque && display && display.flags.scrolling)
6914 Box box = clientArea;
6915 box.left += clientStart.x;
6916 box.top += clientStart.y;
6917 box.right += clientStart.x;
6918 box.bottom += clientStart.y;
6920 //scrollExtent.Free(null);
6921 scrollExtent.AddBox(box);
6922 scrolledArea.x += x;
6923 scrolledArea.y += y;
6925 //scrollExtent.Free();
6926 //scrollExtent.AddBox(clientArea);
6927 //scrollExtent.Offset(clientStart.x, clientStart.y);
6928 //scrolledArea.x = x;
6929 //scrolledArea.y = y;
6935 rootWindow.dirty = true;
6938 void ReleaseCapture()
6940 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6942 Window oldCaptured = guiApp.windowCaptured;
6943 guiApp.windowCaptured = null;
6944 guiApp.prevWindow = null;
6947 //guiApp.Log("Released Capture\n");
6949 guiApp.interfaceDriver.SetMouseCapture(null);
6951 //oldCaptured.OnMouseCaptureLost();
6954 oldCaptured.ConsequentialMouseMove(false);
6959 void SetText(char * format, ...)
6966 char caption[MAX_F_STRING];
6968 va_start(args, format);
6969 vsnprintf(caption, sizeof(caption), format, args);
6970 caption[sizeof(caption)-1] = 0;
6973 this.caption = CopyString(caption);
6982 bool Grab(Bitmap bitmap, Box box, bool decorations)
6984 bool result = false;
6985 if(display || this == guiApp.desktop)
6987 Box clip = {MININT, MININT, MAXINT, MAXINT};
6993 clip.Clip(clientArea);
6995 clip.Clip(this.box);
6997 if(rootWindow != this)
6999 clip.left += absPosition.y;
7000 clip.top += absPosition.y;
7001 clip.right += absPosition.x;
7002 clip.bottom += absPosition.y;
7005 clip.left += decorations ? 0 : clientStart.x;
7006 clip.top += decorations ? 0 : clientStart.y;
7007 clip.right += decorations ? 0 : clientStart.x;
7008 clip.bottom += decorations ? 0 : clientStart.y;
7010 if(display && display.flags.flipping)
7012 rootWindow.Update(null);
7013 rootWindow.UpdateDisplay();
7020 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7021 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7025 result = display.Grab(bitmap, clip.left, clip.top,
7026 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7028 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7030 if(!bitmap.Convert(null, pixelFormat888, null))
7037 void GetMousePosition(int * x, int * y)
7039 int mouseX = 0, mouseY = 0;
7040 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7043 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7044 if(this != guiApp.desktop)
7046 mouseX -= absPosition.x + clientStart.x;
7047 mouseY -= absPosition.y + clientStart.y;
7054 DialogResult DoModal()
7056 DialogResult returnCode = 0;
7057 int terminated = terminateX;
7060 while(!destroyed && guiApp.driver != null)
7062 if(terminateX != terminated)
7064 terminated = terminateX;
7065 guiApp.desktop.Destroy(0);
7066 if(guiApp.desktop.created)
7069 //printf("Resetting terminate X to 0\n");
7075 guiApp.UpdateDisplay();
7076 if(!guiApp.ProcessInput(false))
7079 returnCode = this.returnCode;
7092 return !destroyed && guiApp.driver != null && terminateX < 2;
7095 DialogResult DoModalEnd()
7097 DialogResult returnCode = this.returnCode;
7102 // --- Window manipulation ---
7103 /*bool GetDisabled()
7105 bool disabled = this.disabled;
7107 for(window = this; (window = window.master); )
7118 // --- Mouse Manipulation ---
7119 void GetNCMousePosition(int * x, int * y)
7121 GetMousePosition(x, y);
7122 if(x) *x += clientStart.x;
7123 if(y) *y += clientStart.y;
7126 // --- Carets manipulation ---
7127 void GetCaretPosition(Point caretPos)
7129 caretPos = this.caretPos;
7132 int GetCaretSize(void)
7137 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7143 bool CloseConfirmation(bool parentClosing)
7156 if(!OnClose(parentClosing))
7159 // If you want to skip this, simply set modifiedDocument to false in OnClose
7160 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7162 DialogResult dialogRes;
7165 sprintf(message, $"Save changes to %s?", fileName);
7167 sprintf(message, $"Save changes to Untitled %d?", documentID);
7169 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7171 if(dialogRes == yes)
7173 // TOFIX: Precomp error if brackets are taken out
7174 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7176 else if(dialogRes == cancel)
7182 for(slave = slaves.first; slave; slave = slave.next)
7184 Window w = slave.data;
7185 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7187 // ((Window)slave.data).CloseConfirmation(true);
7196 for(child = children.first; child; child = child.next)
7197 if(child.master != this && !child.CloseConfirmation(true))
7207 // Static methods... move them somewhere else?
7208 void ::RestoreCaret()
7210 if(guiApp.caretOwner)
7211 guiApp.caretOwner.UpdateCaret(false, false);
7214 void ::FreeMouseRange()
7216 guiApp.interfaceDriver.SetMouseRange(null, null);
7220 bool MenuFileClose(MenuItem selection, Modifiers mods)
7222 Window document = activeChild;
7224 document.Destroy(0);
7228 bool MenuFileExit(MenuItem selection, Modifiers mods)
7234 bool MenuFileSave(MenuItem selection, Modifiers mods)
7238 fileMonitor.fileName = null;
7241 if(OnSaveFile(fileName))
7243 //if(OnFileModified != Window::OnFileModified)
7246 fileMonitor.fileName = fileName;
7252 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7253 DialogResult answer = dialog.Modal();
7255 if(answer != yes) return (bool)answer;
7258 return MenuFileSaveAs(selection, mods);
7261 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7263 DialogResult result = (DialogResult)bool::true;
7264 FileDialog fileDialog = saveDialog;
7267 fileDialog = FileDialog {};
7272 fileDialog.filePath = fileName;
7275 char filePath[MAX_FILENAME];
7276 sprintf(filePath, "Untitled %d", documentID);
7277 fileDialog.filePath = filePath;
7279 fileMonitor.fileName = null;
7281 fileDialog.type = save;
7282 fileDialog.text = $"Save As";
7286 fileDialog.master = master.parent ? master : this;
7287 if(fileDialog.Modal() == ok)
7289 char * filePath = fileDialog.filePath;
7291 if(OnSaveFile(filePath))
7294 property::fileName = filePath;
7295 NotifySaved(master, this, filePath);
7300 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7301 DialogResult answer = dialog.Modal();
7316 //if(OnFileModified != Window::OnFileModified && fileName)
7319 fileMonitor.fileName = fileName;
7323 return (bool)result; // Actually returning result from Yes/NoCancel message box
7326 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7328 Window document = activeChild;
7330 for(document = children.first; document; document = next)
7332 next = document.next;
7333 if(document.style.isDocument || document.fileName)
7334 document.MenuFileSave(selection, mods);
7339 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7343 for(document = children.first; document; document = document.next)
7344 //if(document.style.isDocument && document.state == minimized)
7345 if(document.style.isActiveClient && document.state == minimized)
7346 document.SetState(minimized, false, mods);
7350 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7352 Window document = activeChild;
7355 Window firstDocument = null;
7357 OldLink cycle = document.cycle.prev;
7362 if(child.style.isActiveClient && !child.style.hidden)
7366 firstDocument = child;
7367 if(child.state == minimized)
7368 child.SetState(minimized, false, mods);
7371 child.positionID = id++;
7372 child.SetState(normal, false, mods);
7373 child.anchor.left.type = cascade;
7376 child.normalSizeAnchor = *&child.sizeAnchor;
7377 child.normalAnchor = child.anchor;
7379 // Break the anchors for moveable/resizable windows
7380 if(child.style.fixed)
7382 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7384 (*&child.normalAnchor).left = x;
7385 (*&child.normalAnchor).top = y;
7386 (*&child.normalAnchor).right.type = none;
7387 (*&child.normalAnchor).bottom.type = none;
7389 child.normalSizeAnchor.isClientW = false;
7390 child.normalSizeAnchor.isClientH = false;
7391 child.normalSizeAnchor.size.w = w;
7392 child.normalSizeAnchor.size.h = h;
7393 child.anchored = false;
7396 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7398 child.stateAnchor = child.normalAnchor;
7399 child.stateSizeAnchor = child.normalSizeAnchor;
7401 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7402 child.Position(x, y, w, h, true, true, true, true, false, false);
7407 last = children.last;
7408 if(!child.style.stayOnTop)
7409 for(; last && last.style.stayOnTop; last = last.prev);
7410 children.Move(child, last);
7411 childrenOrder.Move(child.order, childrenOrder.last);
7413 if(cycle == document.cycle) break;
7417 firstDocument.Activate();
7422 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7429 // Close all closes all active clients, not all documents
7430 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7432 Window next, document;
7434 for(document = children.first; document; document = next)
7436 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7437 if(document.style.isActiveClient)
7438 if(!document.Destroy(0) && !document.style.hidden)
7444 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7446 if(style.hasMaximize && state != maximized)
7447 SetState(maximized, 0, 0);
7451 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7453 if(style.hasMinimize && state != minimized)
7455 SetState(minimized, 0, 0);
7456 parent.CycleChildren(false, true, false, true);
7461 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7463 MenuMoveOrSize(false, selection ? true : false);
7467 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7469 CycleChildren(false, true, false, true);
7473 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7475 CycleChildren(true, true, false, true);
7479 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7481 MenuMoveOrSize(true, true);
7485 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7488 SetState(normal, 0, 0);
7492 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7495 int64 id = selection.id;
7496 OldLink cycle = activeClient.cycle;
7498 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7501 Window sibling = cycle.data;
7502 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7510 document = cycle.data;
7511 document.Activate();
7513 //if(activeChild.state == maximized)
7514 // document.SetState(maximized, false, mods);
7515 //else if(document.state == minimized)
7516 // document.SetState(normal, false, mods);
7520 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7522 stayOnTop = !style.stayOnTop;
7526 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7528 Window document = activeChild;
7531 Window firstDocument = null;
7532 OldLink cycle = document.cycle;
7536 Window child = cycle.data;
7537 if(child.style.isActiveClient && !child.style.hidden)
7539 if(!firstDocument) firstDocument = child;
7540 if(child.state == minimized)
7541 child.SetState(minimized, false, mods);
7544 child.positionID = id++;
7545 child.SetState(normal, false, mods);
7546 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7548 child.anchor.left.type = hTiled;
7551 child.normalSizeAnchor = *&child.sizeAnchor;
7552 child.normalAnchor = child.anchor;
7554 // Break the anchors for moveable/resizable windows
7555 if(child.style.fixed)
7557 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7559 (*&child.normalAnchor).left = x;
7560 (*&child.normalAnchor).top = y;
7561 (*&child.normalAnchor).right.type = none;
7562 (*&child.normalAnchor).bottom.type = none;
7563 child.normalSizeAnchor.isClientW = false;
7564 child.normalSizeAnchor.isClientH = false;
7565 child.normalSizeAnchor.size.w = w;
7566 child.normalSizeAnchor.size.h = h;
7567 child.anchored = false;
7570 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7572 child.stateAnchor = child.normalAnchor;
7573 child.stateSizeAnchor = child.normalSizeAnchor;
7575 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7576 child.Position(x,y, w, h, true, true, true, true, false, true);
7581 if((cycle = cycle.next) == document.cycle) break;
7584 firstDocument.Activate();
7589 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7591 Window document = activeChild;
7594 Window firstDocument = null;
7596 OldLink cycle = document.cycle;
7601 //if(child.style.isDocument)
7602 if(child.style.isActiveClient && !child.style.hidden)
7604 if(!firstDocument) firstDocument = child;
7605 if(child.state == minimized)
7606 child.SetState(minimized, false, mods);
7609 child.positionID = id++;
7610 child.SetState(normal, false, mods);
7611 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7613 child.anchor.left.type = vTiled;
7616 child.normalSizeAnchor = *&child.sizeAnchor;
7617 child.normalAnchor = child.anchor;
7619 // Break the anchors for moveable/resizable windows
7620 if(child.style.fixed)
7622 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7624 (*&child.normalAnchor).left = x;
7625 (*&child.normalAnchor).top = y;
7626 (*&child.normalAnchor).right.type = none;
7627 (*&child.normalAnchor).bottom.type = none;
7628 child.normalSizeAnchor.isClientW = false;
7629 child.normalSizeAnchor.isClientH = false;
7630 child.normalSizeAnchor.size.w = w;
7631 child.normalSizeAnchor.size.h = h;
7632 child.anchored = false;
7635 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7637 child.stateAnchor = child.normalAnchor;
7638 child.stateSizeAnchor = child.normalSizeAnchor;
7640 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7641 child.Position(x,y, w, h, true, true, true, true, false, true);
7646 if((cycle = cycle.next) == document.cycle) break;
7649 firstDocument.Activate();
7654 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7656 WindowList dialog { master = this };
7657 Window document = (Window)dialog.Modal();
7660 if(activeChild.state == maximized)
7661 document.SetState(maximized, false, mods);
7662 else if(document.state == minimized)
7663 document.SetState(normal, false, mods);
7664 document.Activate();
7670 virtual bool OnCreate(void);
7671 virtual void OnDestroy(void);
7672 virtual void OnDestroyed(void);
7673 virtual bool OnClose(bool parentClosing);
7674 virtual bool OnStateChange(WindowState state, Modifiers mods);
7675 virtual bool OnPostCreate(void);
7676 virtual bool OnMoving(int *x, int *y, int w, int h);
7677 virtual bool OnResizing(int *width, int *height);
7678 virtual void OnResize(int width, int height);
7679 virtual void OnPosition(int x, int y, int width, int height);
7680 virtual bool OnLoadGraphics(void);
7681 virtual void OnApplyGraphics(void);
7682 virtual void OnUnloadGraphics(void);
7683 virtual void OnRedraw(Surface surface);
7684 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7685 virtual void OnActivateClient(Window client, Window previous);
7686 virtual bool OnKeyDown(Key key, unichar ch);
7687 virtual bool OnKeyUp(Key key, unichar ch);
7688 virtual bool OnKeyHit(Key key, unichar ch);
7689 virtual bool OnSysKeyDown(Key key, unichar ch);
7690 virtual bool OnSysKeyUp(Key key, unichar ch);
7691 virtual bool OnSysKeyHit(Key key, unichar ch);
7692 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7693 virtual bool OnMouseLeave(Modifiers mods);
7694 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7695 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7696 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7697 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7698 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7699 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7700 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7701 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7702 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7703 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7704 virtual void OnMouseCaptureLost(void);
7705 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7706 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7707 virtual void OnDrawOverChildren(Surface surface);
7708 virtual bool OnFileModified(FileChange fileChange, char * param);
7709 virtual bool OnSaveFile(char * fileName);
7711 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7712 // Note: A 'client' would refer to isActiveClient, rather than
7713 // being confined to the 'client area' (nonClient == false)
7714 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7715 virtual void OnChildVisibilityToggled(Window child, bool visible);
7716 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7718 // Skins Virtual Functions
7719 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7720 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7721 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7726 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7727 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7728 virtual bool IsMouseMoving(int x, int y, int w, int h)
7732 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7736 virtual void UpdateNonClient();
7737 virtual void SetBox(Box box);
7738 virtual bool IsInside(int x, int y)
7740 return box.IsPointInside({x, y});
7742 virtual bool IsOpaque()
7744 return (!style.drawBehind || background.a == 255);
7748 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7749 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7750 virtual void Window::NotifySaved(Window window, char * filePath);
7755 property Window parent
7757 property_category $"Layout"
7760 if(value || guiApp.desktop)
7763 Window oldParent = parent;
7764 Anchor anchor = this.anchor;
7766 if(value && value.IsDescendantOf(this)) return;
7767 if(value && value == this)
7769 if(!value) value = guiApp.desktop;
7771 if(value == oldParent) return;
7773 if(!master || (master == this.parent && master == guiApp.desktop))
7774 property::master = value;
7778 parent.children.Remove(this);
7782 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7783 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7784 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7785 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7789 last = value.children.last;
7791 if(style.isDocument)
7794 parent.numDocuments--;
7795 documentID = value.GetDocumentID();
7798 if(style.isActiveClient && !style.hidden)
7800 if(parent && parent != guiApp.desktop && !(style.hidden))
7802 if(state == minimized) parent.numIcons--;
7803 parent.numPositions--;
7807 if(!style.stayOnTop)
7808 for(; last && last.style.stayOnTop; last = last.prev);
7810 value.children.Insert(last, this);
7812 // *** NEW HERE: ***
7814 parent.childrenCycle.Delete(cycle);
7816 parent.childrenOrder.Delete(order);
7819 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7820 // Should something else be done?
7821 if(parent && parent.activeChild == this)
7822 parent.activeChild = null;
7823 if(parent && parent.activeClient == this)
7824 parent.activeClient = null;
7830 int x = position.x, y = position.y, w = size.w, h = size.h;
7834 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7835 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7837 vpw = value.clientSize.w;
7838 vph = value.clientSize.h;
7844 else if(style.fixed)
7846 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7847 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7850 anchor = this.anchor;
7852 if(anchor.left.type == offset) anchor.left.distance = x;
7853 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7854 if(anchor.top.type == offset) anchor.top.distance = y;
7855 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7856 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7857 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7858 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7859 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7860 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7861 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7863 if(!anchor.left.type && !anchor.right.type)
7865 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7866 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7868 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7869 if(!anchor.top.type && !anchor.bottom.type)
7871 anchor.vert.distance = (y + h / 2) - (vph / 2);
7872 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7874 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7877 parent.OnChildAddedOrRemoved(this, false);
7883 parent.childrenCycle.Insert(
7884 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7885 cycle = OldLink { data = this });
7886 parent.childrenOrder.Insert(
7887 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7888 order = OldLink { data = this });
7891 if(!style.hidden && style.isActiveClient)
7893 positionID = parent.GetPositionID(this);
7894 parent.numPositions++;
7895 if(state == minimized) parent.numIcons--;
7898 // *** FONT INHERITANCE ***
7899 if(!setFont && oldParent)
7900 stopwatching(oldParent, font);
7904 RemoveResource(systemFont);
7907 // TESTING WITH WATCHERS:
7908 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7909 // usedFont = setFont ? setFont : (systemFont);
7913 if(guiApp.currentSkin)
7915 systemFont = guiApp.currentSkin.SystemFont();
7918 usedFont = systemFont;
7919 AddResource(systemFont);
7927 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7936 if(value.rootWindow && value.rootWindow.display && rootWindow)
7938 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7939 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7942 UnloadGraphics(false);
7945 LoadGraphics(false, false);
7948 if(value.rootWindow != rootWindow)
7949 DisplayModeChanged();
7953 scrolledPos.x = MININT; // Prevent parent update
7955 bool anchored = this.anchored;
7956 property::anchor = anchor;
7957 this.anchored = anchored;
7962 if(guiApp.currentSkin)
7963 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7965 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7966 Position(x, y, w, h, true, true, true, true, false, true);
7971 // else parent = value;
7973 oldParent.OnChildAddedOrRemoved(this, true);
7976 get { return parent; }
7979 property Window master
7981 property_category $"Behavior"
7984 //if(this == value) return;
7985 if(value && value.IsSlaveOf(this)) return;
7991 OldLink slaveHolder;
7992 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7993 if(slaveHolder.data == this)
7995 master.slaves.Delete(slaveHolder);
8002 value.slaves.Add(OldLink { data = this });
8007 master.hotKeys.Remove(hotKey);
8008 value.hotKeys.Add(hotKey);
8011 if(master && master.defaultControl == this)
8012 master.defaultControl = null;
8014 if(style.isDefault && !value.defaultControl)
8015 value.defaultControl = this;
8020 get { return master ? master : parent; }
8023 property char * caption
8025 property_category $"Appearance"
8032 caption = new char[strlen(value)+1];
8034 strcpy(caption, value);
8039 get { return caption; }
8044 property_category $"Behavior"
8053 master.hotKeys.Add(hotKey = HotKeySlot { });
8057 hotKey.window = this;
8062 master.hotKeys.Delete(hotKey);
8067 get { return hotKey ? hotKey.key : 0; }
8070 property Color background
8072 property_category $"Appearance"
8075 background.color = value;
8080 if(this == rootWindow)
8081 guiApp.interfaceDriver.SetRootWindowColor(this);
8084 get { return background.color; }
8087 property Percentage opacity
8089 property_category $"Appearance"
8092 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8093 drawBehind = (background.a == 255) ? false : true;
8095 get { return background.a / 255.0f; }
8098 property Color foreground
8100 property_category $"Appearance"
8108 get { return foreground; }
8111 property BorderStyle borderStyle
8113 property_category $"Appearance"
8116 if(!((BorderBits)value).fixed)
8118 style.hasClose = false;
8119 style.hasMaximize = false;
8120 style.hasMinimize = false;
8121 nativeDecorations = false;
8123 style.borderBits = value;
8127 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8129 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8130 Position(x, y, w, h, true, true, true, true, false, true);
8131 CreateSystemChildren();
8134 get { return (BorderStyle)style.borderBits; }
8137 property Size minClientSize
8139 property_category $"Layout"
8140 set { minSize = value; }
8141 get { value = minSize; }
8144 property Size maxClientSize
8146 property_category $"Layout"
8147 set { maxSize = value; }
8148 get { value = maxSize; }
8151 property bool hasMaximize
8153 property_category $"Window Style"
8156 style.hasMaximize = value;
8157 if(value) { style.fixed = true; style.contour = true; }
8161 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8163 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8164 Position(x, y, w, h, true, true, true, true, false, true);
8166 CreateSystemChildren();
8169 get { return style.hasMaximize; }
8172 property bool hasMinimize
8174 property_category $"Window Style"
8177 style.hasMinimize = 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.hasMinimize; }
8193 property bool hasClose
8195 property_category $"Window Style"
8198 style.hasClose = value;
8199 if(value) { style.fixed = true; style.contour = true; }
8203 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8204 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8205 Position(x, y, w, h, true, true, true, true, false, true);
8206 CreateSystemChildren();
8209 get { return style.hasClose; }
8212 property bool nonClient
8214 property_category $"Layout"
8217 style.nonClient = value;
8219 style.stayOnTop = true;
8221 get { return style.nonClient; }
8224 property bool inactive
8226 property_category $"Behavior"
8231 // *** NEW HERE: ***
8235 parent.childrenCycle.Delete(cycle);
8237 parent.childrenOrder.Delete(order);
8244 active = false; // true;
8245 if(parent.activeChild == this)
8246 parent.activeChild = null;
8247 if(parent.activeClient == this)
8248 parent.activeClient = null;
8257 parent.childrenCycle.Insert(
8258 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8259 cycle = OldLink { data = this });
8261 parent.childrenOrder.Insert(
8262 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8263 order = OldLink { data = this });
8266 style.inactive = value;
8268 get { return style.inactive; }
8271 property bool clickThrough
8273 property_category $"Behavior"
8274 set { style.clickThrough = value; }
8275 get { return style.clickThrough; }
8278 property bool isRemote
8280 property_category $"Behavior"
8281 set { style.isRemote = value; }
8282 get { return style.isRemote; }
8285 property bool noCycle
8287 property_category $"Behavior"
8288 set { style.noCycle = value; }
8289 get { return style.noCycle; }
8292 property bool isModal
8294 property_category $"Behavior"
8295 set { style.modal = value; }
8296 get { return style.modal; }
8299 property bool interim
8301 property_category $"Behavior"
8302 set { style.interim = value; }
8303 get { return style.interim; }
8306 property bool tabCycle
8308 property_category $"Behavior"
8309 set { style.tabCycle = value; }
8310 get { return style.tabCycle; }
8313 property bool isDefault
8315 property_category $"Behavior"
8323 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8324 if(sibling != this && sibling.style.isDefault)
8325 sibling.style.isDefault = false;*/
8326 if(master.defaultControl)
8327 master.defaultControl.style.isDefault = false;
8328 master.defaultControl = this;
8330 else if(master.defaultControl == this)
8331 master.defaultControl = null;
8335 style.isDefault = value;
8337 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8339 get { return style.isDefault; }
8342 property bool drawBehind
8344 property_category $"Window Style"
8345 set { style.drawBehind = value; }
8346 get { return style.drawBehind; }
8349 property bool hasMenuBar
8351 property_category $"Window Style"
8361 if(created && !menuBar)
8368 anchor = Anchor { top = 23, left = 1, right = 1 },
8370 inactive = true, nonClient = true
8375 else if(created && menuBar)
8380 style.hasMenuBar = value;
8382 get { return style.hasMenuBar; }
8385 property bool hasStatusBar
8387 property_category $"Window Style"
8394 statusBar = StatusBar { this };
8402 style.hasStatusBar = value;
8404 get { return style.hasStatusBar; }
8406 property bool stayOnTop
8408 property_category $"Window Style"
8413 if(created && !style.stayOnTop)
8415 if(rootWindow == this)
8416 guiApp.interfaceDriver.OrderRootWindow(this, true);
8417 else if(parent.children.last != this)
8419 parent.children.Move(this, parent.children.last);
8423 style.stayOnTop = true;
8427 if(created && style.stayOnTop)
8429 if(rootWindow == this)
8430 guiApp.interfaceDriver.OrderRootWindow(this, false);
8437 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8438 order && ((Window)order.data).style.stayOnTop;
8439 order = (order == parent.childrenOrder.first) ? null : order.prev);
8440 last = order ? order.data : null;
8444 for(last = parent.children.last;
8445 last && last.style.stayOnTop;
8449 parent.children.Move(this, last);
8453 style.stayOnTop = false;
8456 get { return style.stayOnTop; }
8461 property_category $"Window Style"
8471 if(menuBar && !value)
8478 if(!menuBar && style.hasMenuBar && value)
8482 this, menu = value, isMenuBar = true,
8483 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8484 inactive = true, nonClient = true
8488 UpdateActiveDocument(null);
8491 get { return menu; }
8494 property FontResource font
8496 property_category $"Appearance"
8498 isset { return setFont ? true : false; }
8503 if(value && !setFont) { stopwatching(parent, font); }
8504 else if(!value && setFont)
8510 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8519 RemoveResource(setFont);
8524 RemoveResource(systemFont);
8531 AddResource(setFont);
8534 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8537 systemFont = guiApp.currentSkin.SystemFont();
8539 usedFont = systemFont;
8540 AddResource(systemFont);
8548 get { return usedFont; }
8551 property SizeAnchor sizeAnchor
8553 property_category $"Layout"
8556 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8557 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8558 sizeAnchor.isClientW != sizeAnchor.isClientH;
8565 normalSizeAnchor = sizeAnchor;
8567 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8569 stateAnchor = normalAnchor;
8570 stateSizeAnchor = normalSizeAnchor;
8572 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8573 Position(x,y, w, h, true, true, true, true, false, true);
8580 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8581 sizeAnchor.isClientW,
8582 sizeAnchor.isClientH
8589 property_category $"Layout"
8592 Anchor thisAnchor = anchor;
8593 SizeAnchor thisSizeAnchor = sizeAnchor;
8594 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8595 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8596 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8597 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8598 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8599 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8605 sizeAnchor.isClientW = false;
8606 sizeAnchor.isClientH = false;
8607 sizeAnchor.size = value;
8609 normalSizeAnchor = sizeAnchor;
8611 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8613 stateAnchor = normalAnchor;
8614 stateSizeAnchor = normalSizeAnchor;
8616 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8617 Position(x, y, w, h, true, true, true, true, false, true);
8618 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8621 get { value = size; }
8624 property Size clientSize
8626 property_category $"Layout"
8629 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8630 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8631 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8636 sizeAnchor.isClientW = true;
8637 sizeAnchor.isClientH = true;
8638 sizeAnchor.size = value;
8640 normalSizeAnchor = sizeAnchor;
8642 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8644 stateAnchor = normalAnchor;
8645 stateSizeAnchor = normalSizeAnchor;
8647 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8648 Position(x,y, w, h, true, true, true, true, false, true);
8651 get { value = clientSize; }
8654 property Size initSize { get { value = sizeAnchor.size; } };
8656 property Anchor anchor
8658 property_category $"Layout"
8659 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8665 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8667 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8668 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8670 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8672 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8673 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8677 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8679 anchor.left.distance = 0;
8680 anchor.horz.type = 0;
8682 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8684 anchor.top.distance = 0;
8685 anchor.vert.type = 0;
8694 normalAnchor = anchor;
8696 // Break the anchors for moveable/resizable windows
8697 /*if(style.fixed ) //&& value.left.type == cascade)
8699 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8701 this.anchor = normalAnchor = Anchor { left = x, top = y };
8702 normalSizeAnchor = SizeAnchor { { w, h } };
8705 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8707 stateAnchor = normalAnchor;
8708 stateSizeAnchor = normalSizeAnchor;
8710 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8711 Position(x, y, w, h, true, true, true, true, false, true);
8720 get { value = this ? anchor : Anchor { }; }
8723 property Point position
8725 property_category $"Layout"
8728 if(value == null) return;
8730 anchor.left = value.x;
8731 anchor.top = value.y;
8732 anchor.right.type = none;
8733 anchor.bottom.type = none;
8738 normalAnchor = anchor;
8740 // Break the anchors for moveable/resizable windows
8744 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8746 normalAnchor.left = x;
8747 normalAnchor.top = y;
8748 normalAnchor.right.type = none;
8749 normalAnchor.bottom.type = none;
8750 normalSizeAnchor.size.width = w;
8751 normalSizeAnchor.size.height = h;
8755 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8757 stateAnchor = normalAnchor;
8758 stateSizeAnchor = normalSizeAnchor;
8760 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8761 Position(x,y, w, h, true, true, true, true, false, true);
8765 get { value = position; }
8768 property bool disabled
8770 property_category $"Behavior"
8773 if(this && disabled != value)
8780 get { return (bool)disabled; }
8783 property bool isEnabled
8788 for(parent = this; parent; parent = parent.parent)
8795 property WindowState state
8797 property_category $"Behavior"
8798 set { SetState(value, false, 0); }
8799 get { return this ? state : 0; }
8802 property bool visible
8804 property_category $"Behavior"
8807 if(this && !value && !style.hidden && parent)
8809 bool wasActiveChild = parent.activeChild == this;
8810 Window client = null;
8812 style.hidden = true;
8813 if(style.isActiveClient)
8815 parent.numPositions--;
8816 if(state == minimized) parent.numIcons--;
8821 OldLink prevOrder = null;
8823 if(rootWindow == this)
8824 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8827 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8830 box.left -= parent.clientStart.x;
8831 box.top -= parent.clientStart.y;
8832 box.right -= parent.clientStart.x;
8833 box.bottom -= parent.clientStart.y;
8837 if(_isModal && master && master.modalSlave == this)
8838 master.modalSlave = null;
8842 OldLink tmpPrev = order.prev;
8843 client = tmpPrev ? tmpPrev.data : null;
8844 if(client && !client.style.hidden && !client.destroyed && client.created)
8845 prevOrder = tmpPrev;
8848 client = tmpPrev ? tmpPrev.data : null;
8849 if(client == this) { client = null; break; }
8850 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8852 tmpPrev = client.order.prev;
8857 prevOrder = tmpPrev;
8862 // If this window can be an active client, make sure the next window we activate can also be one
8863 if(!style.nonClient && style.isActiveClient)
8865 tmpPrev = prevOrder;
8868 client = tmpPrev ? tmpPrev.data : null;
8869 if(client == this) { client = null; break; }
8870 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8872 tmpPrev = client.order.prev;
8877 prevOrder = tmpPrev;
8881 if(client && client.style.hidden) client = null;
8885 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8887 if(order && prevOrder && prevOrder.data != this)
8888 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8890 ActivateEx(false, false, false, true, null, null);
8892 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8893 if(parent.activeClient == this)
8895 parent.activeClient = null;
8896 parent.UpdateActiveDocument(null);
8899 else if(parent.activeClient == this)
8901 parent.activeClient = client;
8902 parent.UpdateActiveDocument(this);
8905 // *** Not doing this anymore ***
8908 parent.childrenCycle.Delete(cycle);
8910 parent.childrenOrder.Delete(order);
8915 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8920 else if(this && value && style.hidden)
8922 style.hidden = false;
8925 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8926 if(rootWindow == this)
8927 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8929 if(_isModal && master)
8930 master.modalSlave = this;
8932 if(style.isActiveClient)
8934 positionID = parent.GetPositionID(this);
8935 parent.numPositions++;
8936 if(state == minimized) parent.numIcons++;
8939 // *** NOT DOING THIS ANYMORE ***
8941 if(!(style.inactive))
8943 if(!(style.noCycle))
8945 cycle = parent.childrenCycle.AddAfter(
8946 (parent.activeChild && parent.activeChild.cycle) ?
8947 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8950 order = parent.childrenOrder.AddAfter(
8951 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8958 if(true || !parent.activeChild)
8959 ActivateEx(true, false, true, true, null, null);
8961 if(creationActivation == activate)
8962 ActivateEx(true, false, true, true, null, null);
8963 else if(creationActivation == flash && !object)
8966 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8970 ConsequentialMouseMove(false);
8976 style.hidden = !value;
8979 get { return (style.hidden || !setVisible) ? false : true; }
8982 property bool isDocument
8984 property_category $"Document"
8985 set { style.isDocument = value; }
8986 get { return style.isDocument; }
8989 property bool mergeMenus
8991 property_category $"Window Style"
8992 set { mergeMenus = value; }
8993 get { return (bool)mergeMenus; }
8996 property bool hasHorzScroll
8998 property_category $"Window Style"
9003 if(!style.hasHorzScroll && created)
9005 CreateSystemChildren();
9006 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9009 else if(style.hasHorzScroll)
9013 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9015 style.hasHorzScroll = value;
9018 get { return style.hasHorzScroll; }
9021 property bool hasVertScroll
9023 property_category $"Window Style"
9028 if(!style.hasVertScroll && created)
9030 style.hasVertScroll = true;
9031 CreateSystemChildren();
9032 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9035 else if(style.hasVertScroll)
9039 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9041 style.hasVertScroll = value;
9043 get { return style.hasVertScroll; }
9046 property bool dontHideScroll
9048 property_category $"Behavior"
9051 scrollFlags.dontHide = value;
9054 //UpdateScrollBars(true, true);
9055 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9059 // UpdateScrollBars(true, true);
9060 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9063 get { return scrollFlags.dontHide; }
9066 property bool dontScrollVert
9068 property_category $"Behavior"
9069 set { style.dontScrollVert = value; }
9070 get { return style.dontScrollVert; }
9072 property bool dontScrollHorz
9074 property_category $"Behavior"
9075 set { style.dontScrollHorz = value; }
9076 get { return style.dontScrollHorz; }
9079 property bool snapVertScroll
9081 property_category $"Behavior"
9084 scrollFlags.snapY = value;
9085 if(sbv) sbv.snap = value;
9087 get { return scrollFlags.snapY; }
9089 property bool snapHorzScroll
9091 property_category $"Behavior"
9094 scrollFlags.snapX = value;
9095 if(sbh) sbh.snap = value;
9097 get { return scrollFlags.snapX; }
9100 property Point scroll
9102 property_category $"Behavior"
9103 set { SetScrollPosition(value.x, value.y); }
9104 get { value = scroll; }
9107 property bool modifyVirtualArea
9109 property_category $"Behavior"
9110 set { modifyVirtArea = value; }
9111 get { return (bool)modifyVirtArea; }
9114 property bool dontAutoScrollArea
9116 property_category $"Behavior"
9117 // Activating a child control out of view will automatically scroll to make it in view
9118 set { noAutoScrollArea = value; }
9119 get { return (bool)noAutoScrollArea; }
9122 property char * fileName
9124 property_category $"Document"
9127 if(menu && ((!fileName && value) || (fileName && !value)))
9129 MenuItem item = menu.FindItem(MenuFileSave, 0);
9130 if(item) item.disabled = !modifiedDocument && value;
9135 if(value && value[0])
9136 fileName = CopyString(value);
9138 if(parent && this == parent.activeClient)
9139 parent.UpdateActiveDocument(null);
9143 // if(style.isDocument)
9145 fileMonitor.fileName = value;
9147 get { return fileName; }
9152 property_category $"Data"
9157 property bool modifiedDocument
9159 property_category $"Document"
9162 if(style.isDocument || fileName)
9166 MenuItem item = menu.FindItem(MenuFileSave, 0);
9167 if(item) item.disabled = !value && fileName;
9171 if(modifiedDocument != value)
9173 modifiedDocument = value;
9174 if(style.isDocument || fileName)
9178 get { return (bool)modifiedDocument; }
9181 property bool showInTaskBar
9183 property_category $"Window Style"
9184 set { style.showInTaskBar = value; }
9185 get { return (style.showInTaskBar; }
9187 property FileDialog saveDialog { set { saveDialog = value; } };
9188 property bool isActiveClient
9190 property_category $"Behavior"
9191 set { style.isActiveClient = value; }
9192 get { return style.isActiveClient; }
9195 property Cursor cursor
9197 property_category $"Appearance"
9201 SelectMouseCursor();
9203 get { return cursor; }
9206 //#if !defined(ECERE_VANILLA)
9207 property char * name
9209 property_category $"Design"
9212 return (this && object) ? object.name : null;
9217 activeDesigner.RenameObject(object, value);
9221 property char * displayDriver
9223 property_category $"Behavior"
9226 dispDriver = GetDisplayDriver(value);
9227 //DisplayModeChanged();
9231 return dispDriver ? dispDriver.name : null;
9235 // RUNTIME PROPERTIES
9236 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9237 property Size scrollArea
9239 property_category $"Behavior"
9243 SetScrollArea(value.w, value.h, false);
9245 SetScrollArea(0,0, true);
9247 get { value = scrollArea; }
9250 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9255 property_category $"Layout"
9256 set { if(this) is3D = value; }
9257 get { return (bool)is3D; }
9260 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9262 // Will be merged with font later
9263 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9264 property Point clientStart { get { value = clientStart; } };
9265 property Point absPosition { get { value = absPosition; } };
9266 property Anchor normalAnchor { get {value = normalAnchor; } };
9267 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9268 property bool active { get { return (bool)active; } };
9269 property bool created { get { return (bool)created; } };
9270 property bool destroyed { get { return (bool)destroyed; } };
9271 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9272 property Window firstChild { get { return children.first; } };
9273 property Window lastChild { get { return children.last; } };
9274 property Window activeClient { get { return activeClient; } };
9275 property Window activeChild { get { return activeChild; } };
9276 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9277 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9278 property ScrollBar horzScroll { get { return sbh; } };
9279 property ScrollBar vertScroll { get { return sbv; } };
9280 property StatusBar statusBar { get { return statusBar; } };
9281 property Window rootWindow { get { return rootWindow; } };
9282 property bool closing { get { return (bool)closing; } set { closing = value; } };
9283 property int documentID { get { return documentID; } };
9284 property Window previous { get { return prev; } }
9285 property Window next { get { return next; } }
9286 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9287 property PopupMenu menuBar { get { return menuBar; } }
9288 property ScrollBar sbv { get { return sbv; } }
9289 property ScrollBar sbh { get { return sbh; } }
9290 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9291 property void * systemHandle { get { return windowHandle; } }
9292 property Button minimizeButton { get { return sysButtons[0]; } };
9293 property Button maximizeButton { get { return sysButtons[1]; } };
9294 property Button closeButton { get { return sysButtons[2]; } };
9295 property BitmapResource icon
9297 get { return icon; }
9301 if(icon) incref icon;
9303 guiApp.interfaceDriver.SetIcon(this, value);
9306 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9307 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9308 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9309 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9310 property bool nativeDecorations
9312 get { return (bool)nativeDecorations; }
9313 set { nativeDecorations = value; }
9314 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9317 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9318 bool result = false;
9319 if(nativeDecorations)
9321 if(rootWindow == this)
9325 if(formDesigner && activeDesigner)
9327 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9328 Window form = cd ? cd.form : null;
9329 if(form && parent == form.parent)
9334 return result != style.fixed;
9338 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9340 property char * text
9342 property_category $"Deprecated"
9344 set { property::caption = value; }
9345 get { return property::caption; }
9351 WindowBits style; // Window Style
9352 char * caption; // Name / Caption
9353 Window parent; // Parent window
9354 OldList children; // List of children in Z order
9355 Window activeChild; // Child window having focus
9356 Window activeClient;
9357 Window previousActive; // Child active prior to activating the default child
9358 Window master; // Window owning and receiving notifications concerning this window
9359 OldList slaves; // List of windows belonging to this window
9360 Display display; // Display this window is drawn into
9362 Point position; // Position in parent window client area
9363 Point absPosition; // Absolute position
9364 Point clientStart; // Client area position from (0,0) in this window
9366 Size clientSize; // Client area size
9367 Size scrollArea; // Virtual Scroll area size
9368 Size reqScrollArea; // Requested virtual area size
9369 Point scroll; // Virtual area scrolling position
9370 public ScrollBar sbh, sbv; // Scrollbar window handles
9371 Cursor cursor; // Mouse cursor used for this window
9374 StatusBar statusBar;
9375 Button sysButtons[3];
9377 Box clientArea; // Client Area box clipped to parent
9379 HotKeySlot hotKey; // HotKey for this window
9383 ScrollFlags scrollFlags;// Window Scrollbar Flags
9384 int64 id; // Control ID
9386 ColorAlpha background; // Background color used to draw the window area
9388 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9389 OldList childrenCycle; // Cycling order
9390 OldLink cycle; // Element of parent's cycling order
9391 OldList childrenOrder; // Circular Z-Order
9392 OldLink order; // Element of parent's circular Z-Order
9393 Window modalSlave; // Slave window blocking this window's interaction
9395 Window rootWindow; // Topmost system managed window
9396 void * windowHandle; // System window handle
9398 DialogResult returnCode;// Return code for modal windows
9400 Point sbStep; // Scrollbar line scrolling steps
9403 SizeAnchor stateSizeAnchor;
9405 Anchor normalAnchor;
9406 SizeAnchor normalSizeAnchor;
9408 Size skinMinSize; // Minimal window size based on style
9409 Point scrolledPos; // Scrolled position
9410 Box box; // Window box clipped to parent
9411 Box * against; // What to clip the box to
9413 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9414 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9415 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9416 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9417 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9418 Point scrolledArea; // Distance to scroll area by
9419 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9421 OldList hotKeys; // List of the hotkeys of all children
9422 Window defaultControl; // Default child control
9426 ColorAlpha * palette; // Color palette used for this window
9428 int caretSize; // Size of caret, non zero if a caret is present
9429 Point caretPos; // Caret position
9431 void * systemParent; // Parent System Window for embedded windows
9438 WindowState lastState;
9440 FileMonitor fileMonitor
9442 this, FileChange { modified = true };
9444 bool OnFileNotify(FileChange action, char * param)
9447 fileMonitor.StopMonitoring();
9448 if(OnFileModified(action, param))
9449 fileMonitor.StartMonitoring();
9454 FontResource setFont, systemFont;
9455 FontResource usedFont;
9456 FontResource captionFont;
9458 FileDialog saveDialog;
9460 SizeAnchor sizeAnchor;
9462 // FormDesigner data
9465 Extent * tempExtents; //[4];
9466 BitmapResource icon;
9468 CreationActivationOption creationActivation;
9471 bool active:1; // true if window and ancestors are active
9472 bool acquiredInput:1; // true if the window is processing state based input
9473 bool modifiedDocument:1;
9474 bool disabled:1; // true if window cannot interact
9475 bool isForegroundWindow:1;// true while a root window is being activated
9476 bool visible:1; // Visibility flag
9477 bool destroyed:1; // true if window is being destroyed
9478 bool anchored:1; // true if this window is repositioned when the parent resizes
9479 bool dirty:1; // Flag set to true if any descendant must be redrawn
9485 bool modifyVirtArea:1;
9486 bool noAutoScrollArea:1;
9489 bool setVisible:1; // FOR FORM DESIGNER
9495 bool useSharedMemory:1;
9498 bool nativeDecorations:1;
9499 bool manageDisplay:1;
9500 bool formDesigner:1; // True if we this is running in the form editor
9503 // Checks used internally for them not to take effect in FormDesigner
9504 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9505 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9507 WindowController controller;
9508 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9511 public class CommonControl : Window
9513 // creationActivation = doNothing;
9516 public property String toolTip
9518 property_category $"Appearance"
9521 if(created) CommonControl::OnDestroy();
9523 toolTip = value ? ToolTip { tip = value; } : null;
9525 if(created) CommonControl::OnCreate();
9527 get { return toolTip ? toolTip.tip : null; }
9533 // (Very) Ugly work around for the fact that the parent watcher
9534 // won't fire when it's already been disconnected...
9535 eInstance_FireSelfWatchers(toolTip,
9536 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9542 toolTip.parent = this;
9551 public class Percentage : float
9553 char * OnGetString(char * string, float * fieldData, bool * needClass)
9557 sprintf(string, "%.2f", this);
9558 c = strlen(string)-1;
9561 if(string[c] != '0')
9562 last = Max(last, c);
9563 if(string[c] == '.')
9576 public void ApplySkin(Class c, char * name, void ** vTbl)
9578 char className[1024];
9583 subclass(Window) wc = (subclass(Window))c;
9584 subclass(Window) base = (subclass(Window))c.base;
9586 sprintf(className, "%sSkin_%s", name, c.name);
9587 wc.pureVTbl = c._vTbl;
9588 c._vTbl = new void *[c.vTblSize];
9589 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9590 sc = eSystem_FindClass(c.module.application, className);
9594 for(m = 0; m < c.base.vTblSize; m++)
9596 if(c._vTbl[m] == base.pureVTbl[m])
9597 c._vTbl[m] = vTbl[m];
9602 for(m = 0; m < c.vTblSize; m++)
9604 if(sc._vTbl[m] != wc.pureVTbl[m])
9605 c._vTbl[m] = sc._vTbl[m];
9609 for(d = c.derivatives.first; d; d = d.next)
9611 ApplySkin(d.data, name, c._vTbl);
9615 public void UnapplySkin(Class c)
9617 char className[1024];
9619 subclass(Window) wc = (subclass(Window))c;
9620 subclass(Window) base = (subclass(Window))c.base;
9623 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9626 c._vTbl = wc.pureVTbl;
9630 for(d = c.derivatives.first; d; d = d.next)
9632 UnapplySkin(d.data);
9636 void CheckFontIntegrity(Window window)
9641 if(window.usedFont && window.usedFont.font == 0xecececec)
9643 FontResource uf = window.usedFont;
9644 char * className = window._class.name;
9645 char * text = window.text;
9648 for(c = window.firstChild; c; c = c.next)
9649 CheckFontIntegrity(c);
9653 public class ControllableWindow : Window
9655 /*WindowController controller;
9656 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9657 ~ControllableWindow() { delete controller; }*/
9660 class WindowControllerInterface : ControllableWindow
9662 bool OnKeyDown(Key key, unichar ch)
9664 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9666 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9670 bool OnKeyUp(Key key, unichar ch)
9672 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9674 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9678 bool OnKeyHit(Key key, unichar ch)
9680 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9682 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9686 bool OnMouseMove(int x, int y, Modifiers mods)
9688 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9690 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9694 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9696 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9698 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9702 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9704 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9706 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9710 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9712 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9714 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9718 bool OnRightButtonDown(int x, int y, Modifiers mods)
9720 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9722 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9726 bool OnRightButtonUp(int x, int y, Modifiers mods)
9728 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9730 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9734 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9736 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9738 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9742 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9744 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9746 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9750 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9752 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9754 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9758 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9760 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9762 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9766 void OnResize(int width, int height)
9768 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9769 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9772 void OnRedraw(Surface surface)
9774 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9775 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9780 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9782 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9786 bool OnLoadGraphics()
9788 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9790 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9794 void OnUnloadGraphics()
9796 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9797 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9801 public class WindowController<class V>
9804 property Window window
9808 uint size = class(Window).vTblSize;
9811 windowVTbl = new void *[size];
9812 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9813 if(value._vTbl == value._class._vTbl)
9815 value._vTbl = new void *[value._class.vTblSize];
9816 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9820 for(c = 0; c < size; c++)
9822 void * function = class(WindowControllerInterface)._vTbl[c];
9823 if(function != DefaultFunction)
9824 value._vTbl[c] = function;
9826 value._vTbl[c] = windowVTbl[c];
9831 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9834 get { return window; }
9836 property V controlled
9838 set { controlled = value; }
9839 get { return controlled; }
9841 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9842 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9843 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9844 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9845 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9846 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9847 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9848 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9849 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9850 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9851 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9852 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9853 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9854 virtual void V::OnResize(WindowController controller, int width, int height);
9855 virtual void V::OnRedraw(WindowController controller, Surface surface);
9856 virtual bool V::OnCreate(WindowController controller);
9857 virtual bool V::OnLoadGraphics(WindowController controller);
9858 virtual void V::OnUnloadGraphics(WindowController controller);
9861 int (** windowVTbl)();