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
42 define skinMenuHeight = 25;
43 define statusBarHeight = 18;
45 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
47 public enum DialogResult : int64 { cancel, yes, no, ok };
49 public class MouseButtons
52 bool left:1, right:1, middle:1;
55 public struct SizeAnchor
58 bool isClientW, isClientH;
63 #define SNAPDOWN(x, d) \
66 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
69 #define SNAPUP(x, d) \
72 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
75 /*static */define MAX_DIRTY_BACK = 10;
77 /////////////////////////////////////////////////////////////////////////////
78 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
79 /////////////////////////////////////////////////////////////////////////////
81 #define ACCESS_ITEM(l, id) \
84 #define FASTLIST_LOOP(l, v) \
85 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
87 #define FASTLIST_LOOPN(l, v, n) \
88 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
91 #define ACCESS_ITEM(l, id) \
92 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
94 #define FASTLIST_LOOP(l, v) \
95 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
97 #define FASTLIST_LOOPN(l, v, n) \
98 for( v = (void *)ACCESS_ITEM((l), (l).first), \
99 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
100 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
103 private class FastItem : struct
108 private struct FastList
113 int count, size, itemSize;
120 first = last = free = -1;
128 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
131 FastItem Add(uint itemSize)
134 if(free == -1 || !size)
141 newSize = (size + (size >> 1));
142 items = (FastItem)renew items byte[newSize * itemSize];
147 this.itemSize = itemSize;
148 items = (FastItem)new byte[newSize * itemSize];
151 for(c = size; c<newSize-1; c++)
153 ACCESS_ITEM(this, c).prev = -1;
154 ACCESS_ITEM(this, c).next = c+1;
156 ACCESS_ITEM(this, c).prev = -1;
157 ACCESS_ITEM(this, c).next = -1;
161 item = ACCESS_ITEM(this, free);
164 ACCESS_ITEM(this, item.prev).next = free;
174 void Delete(FastItem item)
177 ACCESS_ITEM(this, item.prev).next = item.next;
179 ACCESS_ITEM(this, item.next).prev = item.prev;
181 if(ACCESS_ITEM(this, first) == item)
183 if(ACCESS_ITEM(this, last) == item)
188 free = ((byte *)item - (byte *)items) / itemSize;
196 free = first = last = -1;
200 private class BoxItem : Item //FastItem
205 public /*private */struct Extent : OldList //FastList
214 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
215 Add(BoxItem { box = box });
218 void Copy(Extent source)
224 //FASTLIST_LOOP(source, extentBox)
225 for(extentBox = (BoxItem)source.first; extentBox; extentBox = (BoxItem)extentBox.next)
226 AddBox(extentBox.box);
229 void IntersectBox(Box box)
231 // Clip all boxes of extent against inside of the new box
232 BoxItem extentBox, next;
234 //FASTLIST_LOOPN(this, extentBox, next) // Macros still mess up the parser!
235 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
237 next = (BoxItem)extentBox.next;
238 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
239 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
240 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
241 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
242 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
247 void ExcludeBox(Box box, Extent temp)
254 for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
256 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
257 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
260 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
264 extentBox.box.left, extentBox.box.top,
265 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
271 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
275 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
276 extentBox.box.right, extentBox.box.bottom
282 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
285 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
289 extentBox.box.left, Max(extentBox.box.top, box.top),
290 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
296 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
300 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
301 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
309 AddBox(extentBox.box);
315 void UnionBox(Box box, Extent temp)
317 BoxItem extentBox, next;
319 // First pass: check if this box is not already covered by one of the extent's box
320 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
322 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
323 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
330 // Second pass: only keep boxes not completely covered in the new box
331 for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
333 next = (BoxItem)extentBox.next;
334 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
335 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
339 // Add the exclusion to the extent
340 ExcludeBox(box, temp);
343 if(box.bottom >= box.top && box.right >= box.left)
345 // Optimization: if the resulting boxes touch, add them smarter
346 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
348 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
350 if(Abs(box.right - extentBox.box.left) <= 1)
352 extentBox.box.left = box.left;
355 else if(Abs(box.left - extentBox.box.right) <= 1)
357 extentBox.box.right = box.right;
361 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
363 if(Abs(box.bottom - extentBox.box.top) <= 1)
365 extentBox.box.top = box.top;
368 else if(Abs(box.top - extentBox.box.bottom) <= 1)
370 extentBox.box.bottom = box.bottom;
382 void Union(Extent b, Extent temp)
386 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
387 UnionBox(extentBox.box, temp);
390 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
397 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
400 temp2.IntersectBox(extentBox.box);
407 void Exclusion(Extent b, Extent temp)
410 for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
411 ExcludeBox(extentBox.box, temp);
414 void Offset(int x, int y)
417 for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
419 extentBox.box.left += x;
420 extentBox.box.top += y;
421 extentBox.box.right += x;
422 extentBox.box.bottom += y;
427 private define MINIMIZED_WIDTH = 160;
428 private define CASCADE_SPACE = 16;
430 // namespace Windows;
432 private class ScrollFlags
434 bool snapX:1, snapY:1, dontHide:1;
437 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
439 class WindowBits : BorderBits
441 BorderBits borderBits:6:0;
442 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
443 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
444 bool embedded:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
447 public enum BorderStyle : BorderBits
450 contour = BorderBits { contour = true },
451 fixed = BorderBits { fixed = true } | contour,
452 sizable = BorderBits { sizable = true } | fixed,
453 thin = BorderBits { fixed = true, thin = true } | contour,
454 sizableThin = BorderBits { sizable = true } | thin,
455 deep = BorderBits { deep = true },
456 bevel = BorderBits { bevel = true },
457 sizableDeep = sizable|deep,
458 sizableBevel = sizable|bevel,
459 fixedDeep = fixed|deep,
460 fixedBevel = fixed|bevel,
461 deepContour = deep|contour
464 public enum CreationActivationOption
466 activate, flash, doNothing
469 public enum WindowState { normal, minimized, maximized };
471 private class ResPtr : struct
478 private class HotKeySlot : struct
480 HotKeySlot prev, next;
488 class_data char * icon;
490 class_default_property caption;
491 // class_initialize GuiApplication::Initialize;
492 class_designer FormDesigner;
493 class_property char * icon
495 set { class_data(icon) = value; }
496 get { return class_data(icon); }
501 bool switchMode = true;
502 #if defined(__ANDROID__)
507 guiApp.Initialize(switchMode);
509 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
511 if(_vTbl == ((subclass(Window))_class).pureVTbl)
513 _vTbl = _class._vTbl;
515 else if(_vTbl != _class._vTbl)
518 for(m = 0; m < _class.vTblSize; m++)
520 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
521 _vTbl[m] = _class._vTbl[m];
526 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
527 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
528 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
529 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
533 // caption = CopyString(class.name);
535 children.offset = (byte*)&prev - (byte*)this;
536 childrenOrder.circ = true;
537 childrenCycle.circ = true;
539 maxSize = Size { MAXINT, MAXINT };
543 //style.isActiveClient = true;
546 modifyVirtArea = true;
547 manageDisplay = true;
548 nativeDecorations = true;
550 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
551 sbStep.x = sbStep.y = 8;
553 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
555 cursor = guiApp.GetCursor(arrow);
556 property::parent = guiApp.desktop;
568 stopwatching(parent, font);
569 if(parent.activeChild == this)
570 parent.activeChild = null;
571 if(parent.activeClient == this)
572 parent.activeClient = null;
577 // Prevent destructor from being called again...
583 /////////////////////////////////
586 OldLink slave = master.slaves.FindLink(this);
587 master.slaves.Delete(slave);
594 parent.childrenCycle.Remove(cycle);
596 parent.childrenOrder.Remove(order);
597 parent.children.Remove(this);
602 /////////////////////////////////
604 while(ptr = resources.first)
607 resources.Delete(ptr);
614 for(child = children.first; child; child = child.next)
616 // child.stopwatching(this, font);
618 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
619 // Don't want property here
620 *&child.parent = null;
623 while(slave = slaves.first)
625 // Don't want property here
626 *&((Window)slave.data).master = null;
627 slaves.Delete(slave);
630 // Because we do a decref in DestroyEx...
638 // Why was this commented?
639 //if(this != guiApp.desktop)
652 if(((subclass(Window))_class).pureVTbl)
654 if(_vTbl == _class._vTbl)
656 _vTbl = ((subclass(Window))_class).pureVTbl;
661 for(m = 0; m < _class.vTblSize; m++)
663 if(_vTbl[m] == _class._vTbl[m])
664 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
668 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
671 dirtyArea.Free(null);
672 renderArea.Free(null);
673 overRenderArea.Free(null);
674 clipExtent.Free(null);
675 scrollExtent.Free(null);
676 dirtyBack.Free(null);
680 tempExtents[0].Free(null);
681 tempExtents[1].Free(null);
682 tempExtents[2].Free(null);
683 tempExtents[3].Free(null);
688 //#if !defined(ECERE_VANILLA)
689 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
691 if(this == activeDesigner)
695 char * name = property::name;
696 return name ? name : "";
701 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
702 bool OnGetDataFromString(char * string)
704 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
707 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
708 this = designer.form;
709 else if(!strcmpi(string, "(Desktop)"))
710 this = activeDesigner;
712 return activeDesigner.FindObject(&this, string);
718 // --- Window updates system ---
720 // Setup a bitmap for Redrawing on client area of Window
721 Surface Redraw(Box box)
723 Surface surface = null;
725 Box clientArea = this.clientArea;
729 mox.left -= clientStart.x;
730 mox.top -= clientStart.y;
731 mox.right -= clientStart.x;
732 mox.bottom -= clientStart.y;
734 mox.Clip(clientArea);
735 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
737 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
739 int x = absPosition.x + clientStart.x;
740 int y = absPosition.y + clientStart.y;
741 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
743 x -= rootWindow.clientStart.x;
744 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
746 if(!guiApp.fullScreenMode || is3D)
748 x -= rootWindow.absPosition.x;
749 y -= rootWindow.absPosition.y;
753 x += rootWindow.parent.clientStart.x;
754 y += rootWindow.parent.clientStart.y;
756 mox.left += rootWindow.parent.clientStart.x;
757 mox.top += rootWindow.parent.clientStart.y;
758 mox.right += rootWindow.parent.clientStart.x;
759 mox.bottom += rootWindow.parent.clientStart.y;
764 surface = display.GetSurface(x, y, mox);
767 surface.width = clientSize.w;
768 surface.height = clientSize.h;
774 // Setup a bitmap for Redrawing on full Window
775 Surface RedrawFull(Box box)
777 Surface surface = null;
785 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
787 int x = absPosition.x;
788 int y = absPosition.y;
789 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
791 x -= rootWindow.clientStart.x;
792 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
794 if(!guiApp.fullScreenMode || is3D)
796 x -= rootWindow.absPosition.x;
797 y -= rootWindow.absPosition.y;
800 x += rootWindow.parent.clientStart.x;
801 y += rootWindow.parent.clientStart.y;
803 mox.left += rootWindow.parent.clientStart.x;
804 mox.top += rootWindow.parent.clientStart.y;
805 mox.right += rootWindow.parent.clientStart.x;
806 mox.bottom += rootWindow.parent.clientStart.y;
811 surface = display.GetSurface(x, y, mox);
814 surface.width = size.w;
815 surface.height = size.h;
821 void FigureCaption(char * caption)
823 Window activeClient = null;
827 strcpy(caption, this.caption);
828 if(style.isDocument || fileName)
830 if(caption[0]) strcat(caption, " - ");
832 strcat(caption, fileName);
836 sprintf(title, "Untitled %d", documentID);
837 strcat(caption, title);
840 strcat(caption, " *");
845 for(activeClient = this.activeClient; activeClient && !((BorderBits)activeClient.borderStyle).fixed; activeClient = activeClient.activeClient);
847 if(activeClient && activeClient.state == maximized)
849 if(activeClient.caption)
851 if(caption[0]) strcat(caption, " - ");
852 strcat(caption, activeClient.caption);
854 if(activeClient.style.isDocument || activeClient.fileName)
856 if(caption[0]) strcat(caption, " - ");
857 strcat(caption, "[");
858 if(activeClient.fileName)
859 strcat(caption, activeClient.fileName);
863 sprintf(title, "Untitled %d", activeClient.documentID);
864 strcat(caption, title);
866 if(activeClient.modifiedDocument)
867 strcat(caption, " *");
868 strcat(caption, "]");
873 // Code for returning dirty from ScrollDisplay:
875 for(d = 0; d<scrollExtent.count; d++)
877 Box * box = &scrollExtent.boxes[d];
883 Min(box.right, box.left-scroll.x),box.bottom
885 dirtyArea.UnionBox(update);
891 Max(box.left, box.right-scroll.x), box.top,
892 box.right, box.bottom
894 dirtyArea.UnionBox(update);
902 box.right, Min(box.bottom, box.top-scroll.y),
904 dirtyArea.UnionBox(update);
910 box.left, Max(box.top, box.bottom-scroll.y),
911 box.right, box.bottom
913 dirtyArea.UnionBox(update);
918 void UpdateDecorations(void)
920 // TODO: *** TEMPORARY HACK ***
927 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
929 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
931 Update({ -clientStart.x,0, -1, clientSize.h-1 });
933 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
936 // Returns w & h for Position
937 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
939 Window parent = this.parent ? this.parent : guiApp.desktop;
940 int vpw = parent ? parent.clientSize.w : 0;
941 int vph = parent ? parent.clientSize.h : 0;
942 int pw = parent ? parent.clientSize.w : 0;
943 int ph = parent ? parent.clientSize.h : 0;
944 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
945 int x = anchor.left.distance, y = anchor.top.distance;
947 MinMaxValue ew = 0, eh = 0;
949 float cascadeW, cascadeH;
951 int tilingW, tilingH, tilingSplit, tilingLastH;
952 int addX = 0, addY = 0;
954 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
956 Window masterWindow = this;
957 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
960 if(master == guiApp.desktop)
961 masterWindow = guiApp.desktop.activeChild;
963 masterWindow = master.rootWindow;
964 if(!masterWindow) masterWindow = this;
966 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
967 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
970 pw = vpw = box.right - box.left + 1;
972 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
975 ph = vph = box.bottom - box.top + 1;
991 vpw = pw = parent.size.w;
992 vph = ph = parent.size.h;
994 else if(!style.fixed /*|| style.isDocument*/)
996 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
997 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
999 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
1002 Desktop3D_FixSize(&pw, &ph);
1003 Desktop3D_FixSize(&vpw, &vph);
1006 if(pw < skinMinSize.w) pw = skinMinSize.w;
1007 if(ph < skinMinSize.h) ph = skinMinSize.h;
1008 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
1009 if(vph < skinMinSize.h) vph = skinMinSize.h;
1011 // TODO: Must fix what we're snapping
1014 if(anchor.left.type)
1016 SNAPUP(x, textCellW);
1018 else if(anchor.right.type)
1020 SNAPDOWN(x, textCellW);
1025 SNAPUP(y, textCellH);
1027 else if(anchor.bottom.type)
1029 SNAPDOWN(y, textCellH);
1033 // This is required to get proper initial decoration size using native decorations on Windows
1034 if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
1035 guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
1036 GetDecorationsSize(&ew, &eh);
1038 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1040 if(parent.sbv && !parent.sbv.style.hidden)
1041 pw += guiApp.currentSkin.VerticalSBW();
1042 if(parent.sbh && !parent.sbh.style.hidden)
1043 ph += guiApp.currentSkin.HorizontalSBH();
1045 if(anchor.left.type == cascade)
1047 w = (int)(pw * 0.80);
1048 h = (int)(ph * 0.80);
1050 else if(anchor.left.type >= vTiled)
1055 numTiling = parent.numPositions - parent.numIcons;
1056 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1057 if(anchor.left.type == vTiled)
1059 tilingH = (int)sqrt(numTiling);
1060 tilingW = numTiling / tilingH;
1064 tilingW = (int)sqrt(numTiling);
1065 tilingH = numTiling / tilingW;
1068 leftOver = numTiling - tilingH * tilingW;
1071 tilingSplit = (tilingW - leftOver) * tilingH;
1072 tilingLastH = tilingH+1;
1075 tilingSplit = numTiling;
1077 if(positionID >= tilingSplit)
1079 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1080 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1081 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1082 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1086 x = pw * (positionID / tilingH) / tilingW;
1087 y = ph * (positionID % tilingH) / tilingH;
1088 x2 = pw * (positionID / tilingH + 1) / tilingW;
1089 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1093 SNAPDOWN(x, textCellW);
1094 SNAPDOWN(y, textCellH);
1095 SNAPDOWN(x2, textCellW);
1096 SNAPDOWN(y2, textCellH);
1104 if(sizeAnchor.isClientW) w += ew;
1105 if(sizeAnchor.isClientH) h += eh;
1107 if(anchor.left.type == offset)
1108 x = anchor.left.distance;
1109 else if(anchor.left.type == relative)
1110 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1111 else if(anchor.right.type == relative)
1112 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1113 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1114 else if(anchor.right.type == offset)
1115 ex = vpw - anchor.right.distance;
1117 if(anchor.top.type == offset)
1118 y = anchor.top.distance;
1119 else if(anchor.top.type == relative)
1120 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1121 else if(anchor.bottom.type == relative)
1122 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1123 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1124 else if(anchor.bottom.type == offset)
1125 ey = vph - anchor.bottom.distance;
1127 if(anchor.left.type && anchor.right.type)
1129 switch(anchor.right.type)
1132 ex = pw * (1.0f-anchor.right.percent);
1133 w = Max((int)(ex + 0.5) - x, 0);
1136 ex = vpw - anchor.right.distance;
1137 w = Max((int)(ex + 0.5) - x, 0);
1141 if(anchor.top.type && anchor.bottom.type)
1143 switch(anchor.bottom.type)
1146 ey = ph * (1.0f-anchor.bottom.percent);
1147 h = Max((int)(ey + 0.5) - y, 0);
1150 ey = vph - anchor.bottom.distance;
1151 h = Max((int)(ey + 0.5) - y, 0);
1160 if(state == normal /*|| state == Hidden*/)
1162 bool addSbV = false, addSbH = false;
1164 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1165 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1167 w = Max(w, minSize.w);
1168 h = Max(h, minSize.h);
1169 w = Min(w, maxSize.w);
1170 h = Min(h, maxSize.h);
1172 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1174 if(w) w -= guiApp.currentSkin.VerticalSBW();
1177 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1179 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1183 if(!OnResizing(&w, &h))
1189 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1190 w += guiApp.currentSkin.VerticalSBW();
1191 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1192 h += guiApp.currentSkin.HorizontalSBH();
1194 w = Max(w, skinMinSize.w);
1195 h = Max(h, skinMinSize.h);
1208 SNAPDOWN(w, textCellW);
1209 SNAPDOWN(h, textCellH);
1212 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1214 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1217 (pw - w) / CASCADE_SPACE,
1218 (ph - h) / CASCADE_SPACE);
1224 cascW = (pw - w) / (numCascade-1);
1225 cascH = (ph - h) / (numCascade-1);
1226 SNAPDOWN(cascW, textCellW);
1227 SNAPDOWN(cascH, textCellH);
1228 cascadeW = (float)cascW;
1229 cascadeH = (float)cascH;
1233 numCascade = Max(numCascade, 2);
1234 cascadeW = (float)(pw - w) / (numCascade-1);
1235 cascadeH = (float)(ph - h) / (numCascade-1);
1238 x = (int)((positionID % numCascade) * cascadeW);
1239 y = (int)((positionID % numCascade) * cascadeH);
1241 else if(anchor.left.type < vTiled)
1243 if(!anchor.left.type || anchor.horz.type == middleRelative)
1245 if(!anchor.right.type)
1247 if(anchor.horz.type == middleRelative)
1248 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1250 x = vpw / 2 + anchor.horz.distance - w / 2;
1256 // case A_EDGE: x = x - w; break;
1258 if(!anchor.top.type || anchor.vert.type == middleRelative)
1260 if(!anchor.bottom.type)
1262 if(anchor.vert.type == middleRelative)
1263 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1265 y = vph / 2 + anchor.vert.distance - h / 2;
1271 // case A_EDGE: y = y - h; break;
1274 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1282 SNAPDOWN(x, textCellW);
1283 SNAPDOWN(y, textCellH);
1295 if(anchored && style.fixed && style.isActiveClient)
1300 void UpdateCaret(bool forceUpdate, bool erase)
1302 static Window lastWindow = null;
1303 static int caretX, caretY, caretSize;
1305 if(guiApp && guiApp.caretOwner == this)
1307 int x = caretPos.x - scroll.x;
1308 int y = caretPos.y - scroll.y;
1310 if((erase || this.caretSize) &&
1311 x >= clientArea.left && x <= clientArea.right &&
1312 y >= clientArea.top && y <= clientArea.bottom)
1316 guiApp.interfaceDriver.SetCaret(
1317 x + absPosition.x + clientStart.x,
1318 y + absPosition.y + clientStart.y, this.caretSize);
1319 guiApp.caretEnabled = true;
1321 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1325 if(lastWindow != this)
1327 updateBox.left = x + 1;
1329 updateBox.right = x + 2;
1330 updateBox.bottom = y + this.caretSize - 1;
1334 updateBox.left = Min(x + 1, caretX + 1);
1335 updateBox.top = Min(y, caretY);
1336 updateBox.right = Max(x + 2, caretX + 2);
1337 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1340 guiApp.caretOwner.Update(updateBox);
1347 caretSize = this.caretSize;
1353 guiApp.interfaceDriver.SetCaret(0,0,0);
1354 guiApp.caretEnabled = false;
1360 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1365 scrolledPos.x = position.x = x;
1366 scrolledPos.y = position.y = y;
1368 clientSize.w = size.w = w;
1369 clientSize.h = size.h = h;
1371 if(parent && !style.nonClient)
1373 //if(!style.fixed || style.isDocument)
1375 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1376 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1380 clientStart.x = clientStart.y = 0;
1382 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1384 //if(!activeClient || activeClient.state != maximized)
1385 if(!noAutoScrollArea)
1387 // Check if scroll area must be modified
1388 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1390 bool foundChild = false;
1392 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1393 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1394 for(child = children.first; child; child = child.next)
1396 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1397 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1399 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1400 w = Max(w, child.position.x + child.size.w);
1401 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1402 w = Max(w, Max(child.position.x, 0) + child.size.w);
1403 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1404 h = Max(h, child.position.y + child.size.h);
1405 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1406 h = Max(h, Max(child.position.y, 0) + child.size.h);
1411 if(foundChild && (w > cw || h > ch))
1413 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1415 int stepX = sbStep.x, stepY = sbStep.y;
1416 // Needed to make snapped down position match the skin's check of client area
1417 // against realvirtual
1420 SNAPDOWN(stepX, textCellW);
1421 SNAPDOWN(stepY, textCellH);
1422 stepX = Max(stepX, textCellW);
1423 stepY = Max(stepY, textCellH);
1425 if(scrollFlags.snapX)
1427 if(scrollFlags.snapY)
1430 reqScrollArea.w = w;
1431 reqScrollArea.h = h;
1434 else if(reqScrollArea.w || reqScrollArea.h)
1436 reqScrollArea.w = 0;
1437 reqScrollArea.h = 0;
1438 SetScrollPosition(0,0);
1443 // Automatic MDI Client Scrolling Area Adjustment
1444 if(parent && !parent.noAutoScrollArea)
1446 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1447 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1449 Window parent = this.parent;
1450 int w = parent.reqScrollArea.w;
1451 int h = parent.reqScrollArea.h;
1453 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1454 w = Max(w, position.x + size.w);
1455 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1456 w = Max(w, Max(position.x, 0) + size.w);
1457 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1458 h = Max(h, position.y + size.h);
1459 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1460 h = Max(h, Max(position.y, 0) + size.h);
1462 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1463 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1465 /*bool resize = false;
1466 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1467 // Needed to make snapped down position match the skin's check of client area
1468 // against realvirtual
1471 SNAPDOWN(stepX, textCellW);
1472 SNAPDOWN(stepY, textCellH);
1473 stepX = Max(stepX, textCellW);
1474 stepY = Max(stepY, textCellH);
1476 if(parent.scrollFlags.snapX)
1478 if(parent.scrollFlags.snapY)
1480 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1482 parent.reqScrollArea.w = w;
1483 parent.reqScrollArea.h = h;*/
1485 // parent.UpdateScrollBars(true, true);
1486 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1487 false, true, true, true, false, false);
1492 GetRidOfVirtualArea();
1496 UpdateScrollBars(modifyThisArea, false);
1497 else if(guiApp.currentSkin)
1500 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1502 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1503 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1504 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1505 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1508 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1509 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1511 absPosition = scrolledPos;
1512 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1513 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1515 if(this != guiApp.desktop && parent)
1517 absPosition.x += parent.absPosition.x;
1518 absPosition.y += parent.absPosition.y;
1519 if(!style.nonClient && this != guiApp.desktop)
1521 absPosition.x += parent.clientStart.x;
1522 absPosition.y += parent.clientStart.y;
1526 box = Box { 0, 0, size.w - 1, size.h - 1 };
1531 // Clip against parent's client area
1532 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1534 // Compute client area in this window coordinate system
1535 clientArea.left = 0;
1537 clientArea.right = clientSize.w - 1;
1538 clientArea.bottom = clientSize.h - 1;
1540 // Clip against parent's client area
1542 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1546 //absPosition.x -= parent.clientStart.x;
1547 //absPosition.y -= parent.clientStart.y;
1550 // Adjust all children
1551 for(child = children.first; child; child = child.next)
1552 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1554 UpdateCaret(false, false);
1557 void GetRidOfVirtualArea(void)
1559 if(parent && !parent.destroyed && style.fixed &&
1560 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1561 parent.reqScrollArea.w && parent.reqScrollArea.h)
1563 if(!parent.noAutoScrollArea)
1567 for(child = children.first; child; child = child.next)
1569 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1571 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1572 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1581 Window parent = this.parent;
1583 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1584 false, true, true, true, false, false);
1586 parent.SetScrollArea(0,0,true);
1587 parent.SetScrollPosition(0,0);
1593 public void ExternalPosition(int x, int y, int w, int h)
1595 Position(x, y, w, h, false, true, true, true, false, false);
1598 // (w, h): Full window size
1599 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1601 bool result = false;
1602 int oldCW = clientSize.w, oldCH = clientSize.h;
1603 bool clientResized, windowResized, windowMoved;
1605 bool realResized = size.w != w || size.h != h;
1607 // TOCHECK: This wasn't in ecere.dll
1608 //if(!parent) return true;
1609 if(destroyed) return false;
1611 windowMoved = position.x != x || position.y != y || force;
1613 // windowResized = realResized || force;
1614 windowResized = size.w != w || size.h != h || force;
1616 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1622 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1623 scrolledPos.x - parent.clientStart.x + this.box.right,
1624 scrolledPos.y - parent.clientStart.y + this.box.bottom
1630 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1635 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1637 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1638 if(clientResized && this == rootWindow && nativeDecorations && rootWindow.windowHandle)
1639 windowResized = true;
1641 if(display && rootWindow != this)
1644 if(guiApp && guiApp.windowMoving)
1646 if(guiApp.windowMoving.style.nonClient)
1647 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1649 guiApp.windowMoving.parent.SetMouseRangeToClient();
1659 // Buttons bitmap resources crash if we do this while switching mode
1660 if(!guiApp || !guiApp.modeSwitching)
1663 // Process Anchored Children
1667 for(child = children.first; child; child = child.next)
1670 ((child.stateAnchor.left.type != offset ||
1671 child.stateAnchor.top.type != offset ||
1672 child.stateAnchor.right.type != none ||
1673 child.stateAnchor.bottom.type != none) ||
1674 child.state == maximized || child.state == minimized))
1676 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1678 // child.Position(x, y, w, h, false, true, true, true, false);
1679 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1680 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1686 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1687 //if(updateScrollBars)
1689 OnResize(clientSize.w, clientSize.h);
1691 if((clientResized || windowMoved) && created)
1692 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1694 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1696 Window master = guiApp.interimWindow.master;
1697 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1700 if(rootWindow == this && !is3D)
1704 x -= guiApp.desktop.absPosition.x;
1705 y -= guiApp.desktop.absPosition.y;
1707 //guiApp.Log("Position %s\n", caption);
1710 if(windowResized || windowMoved)
1711 if(display && !display.flags.memBackBuffer && changeRootWindow)
1712 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1714 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1715 for(child = parent.children.first; child && child != this; child = child.next)
1716 if(child.rootWindow)
1717 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1722 if(windowMoved || windowResized)
1724 display.Lock(true /*false*/);
1727 display.Position(absPosition.x, absPosition.y);
1728 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1731 // result = realResized ? display.Resize(size.w, size.h) : true;
1732 if(nativeDecorations && rootWindow.windowHandle)
1734 int w = clientSize.w, h = clientSize.h;
1735 if(hasMenuBar) h += skinMenuHeight;
1736 if(hasStatusBar) h += statusBarHeight;
1737 if(sbv && sbv.visible) w += sbv.size.w;
1738 if(sbh && sbh.visible) h += sbh.size.h;
1739 result = manageDisplay ? display.Resize(w, h) : true;
1742 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1746 else if(clientResized)
1748 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1751 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1755 if(windowMoved || windowResized)
1760 if(guiApp.driver && changeRootWindow && windowHandle)
1762 if(windowResized || windowMoved)
1763 if(!display || display.flags.memBackBuffer)
1764 guiApp.interfaceDriver.PositionRootWindow(this,
1765 x, y, w, h, windowMoved, windowResized);
1766 guiApp.interfaceDriver.UpdateRootWindow(this);
1768 for(child = children.first; child; child = child.next)
1770 if(child.is3D && child.created)
1772 // Copy Display Content
1773 child.display.displaySystem = display.displaySystem;
1774 child.display.window = display.window;
1775 child.display.current = display.current;
1776 child.display.width = display.width;
1777 child.display.height = display.height;
1778 child.display.driverData = display.driverData;
1779 child.display.mutex = null;
1790 void UpdateScrollBars(bool flag, bool fullThing)
1793 bool resizeH = false, resizeV = false;
1794 bool scrolled = false;
1795 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1796 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1798 if(destroyed) return;
1799 if(guiApp.currentSkin)
1801 MinMaxValue cw = 0, ch = 0;
1802 bool sbvVisible, sbhVisible;
1804 int positionH, positionV;
1806 // First get client area with no respect to scroll bars
1811 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1813 if(scrollFlags.dontHide)
1816 cw -= guiApp.currentSkin.VerticalSBW();
1818 ch -= guiApp.currentSkin.HorizontalSBH();
1820 // Update the scrollbar visibility
1826 sbh.disabled = rangeH <= 1;
1827 if(sbh.style.hidden)
1837 sbv.disabled = rangeV <= 1;
1838 if(sbv.style.hidden)
1846 int oldHRange = sbh ? sbh.range : 0;
1847 int oldVRange = sbv ? sbv.range : 0;
1848 // Then start off with horizontal scrollbar range
1851 positionH = sbh.thumbPosition;
1858 SBSetTotal(sbh, rvw);
1861 ch -= guiApp.currentSkin.HorizontalSBH();
1864 // Do the same for vertical scrollbar
1867 positionV = sbv.thumbPosition;
1873 SBSetTotal(sbv, rvh);
1877 cw -= guiApp.currentSkin.VerticalSBW();
1878 // Maybe we need to set the range on the horizontal scrollbar again
1886 SBSetTotal(sbh, rvw);
1887 //sbh.Action(setRange, positionH, 0);
1888 if(rangeH <= 1 && sbh.range > 1)
1890 ch -= guiApp.currentSkin.HorizontalSBH();
1896 SBSetTotal(sbv, rvh);
1898 //sbv.Action(setRange, positionV, 0);
1903 if(sbh && sbh.range != oldHRange) sbh.Action(setRange, positionH, 0);
1904 if(sbv && sbv.range != oldVRange) sbv.Action(setRange, positionV, 0);
1907 // Update the scrollbar visibility
1908 if(!scrollFlags.dontHide)
1910 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1914 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1921 if(guiApp.currentSkin)
1928 sbhVisible = sbh.style.hidden ? true : false;
1930 sbvVisible = sbv.style.hidden ? true : false;
1932 // Do our resize here
1933 if(flag && (resizeH || resizeV) && fullThing)
1935 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1940 OnResize(clientSize.w, clientSize.h);
1946 sbh.visible = sbhVisible;
1948 sbv.visible = sbvVisible;
1950 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1951 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1954 sbh.pageStep = clientSize.w;
1956 sbv.pageStep = clientSize.h;
1958 // Notify doesn't handle setRange anymore... process it here
1961 int positionH = sbh.thumbPosition;
1962 if(scroll.x != positionH)
1964 OnHScroll(setRange, positionH, 0);
1968 SNAPDOWN(positionH, textCellW);
1969 scroll.x = positionH;
1975 int seen = clientSize.w, total = reqScrollArea.w;
1978 if(scrollFlags.snapX)
1979 SNAPDOWN(seen, sbStep.x);
1981 if(!total) total = seen;
1982 range = total - seen + 1;
1984 range = Max(range, 1);
1986 if(x >= range) x = range - 1;
1988 if(scrollFlags.snapX)
1989 SNAPUP(x, sbStep.x);
1993 OnHScroll(setRange, x, 0);
1998 SNAPDOWN(x, textCellW);
2004 int positionV = sbv.thumbPosition;
2005 if(scroll.y != positionV)
2007 OnVScroll(setRange, positionV, 0);
2011 SNAPDOWN(positionV, textCellH);
2012 scroll.y = positionV;
2018 int seen = clientSize.h, total = reqScrollArea.h;
2021 if(scrollFlags.snapY)
2022 SNAPDOWN(seen, sbStep.y);
2024 if(!total) total = seen;
2025 range = total - seen + 1;
2026 range = Max(range, 1);
2028 if(y >= range) y = range - 1;
2030 if(scrollFlags.snapY)
2031 SNAPUP(y, sbStep.y);
2035 OnVScroll(setRange, y, 0);
2040 SNAPDOWN(y, textCellH);
2046 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2049 for(child = children.first; child; child = child.next)
2051 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2054 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2055 child.Position(x, y, w, h, false, true, false, true, false, false);
2062 // Process Scrollbars
2064 if(sbh) // && !sbh.style.hidden
2067 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2068 // Need to set the range again (should improve...) since the scrollbars didn't have
2069 // the right size when UpdateScrollArea set the range on it
2072 sbh.seen = clientSize.w;
2076 if(sbv) // && !sbv.state.hidden
2079 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2080 // Need to set the range again (should improve...) since the scrollbars didn't have
2081 // the right size when UpdateScrollArea set the range on it
2084 sbv.seen = clientSize.h;
2089 // TESTING THIS LOWER
2090 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2093 for(child = children.first; child; child = child.next)
2095 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2098 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2099 child.Position(x, y, w, h, false, true, false, true, false, false);
2105 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2107 SetState(maximized, false, mods);
2111 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2113 SetState(normal, false, mods);
2117 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2119 SetState(minimized, false, mods);
2120 parent.CycleChildren(false, true, false, true);
2124 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2127 // Scroll bar notifications
2128 if(action != setRange)
2130 bool changed = false;
2134 if(scroll.x != position)
2136 OnHScroll(action, position, keyFlags);
2141 SNAPDOWN(position, textCellW);
2143 scroll.x = position;
2147 if(scroll.y != position)
2149 OnVScroll(action, position, keyFlags);
2154 SNAPDOWN(position, textCellH);
2156 scroll.y = position;
2160 bool childMove = false;
2161 for(child = children.first; child; child = child.next)
2163 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2166 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2167 child.Position(x, y, w, h, false, true, false, true, false, false);
2171 // Testing this patch out to solve MDI workspace redraw bugs
2172 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2173 // Scroll offsets to blame?
2177 UpdateCaret(false, false);
2181 // Testing this patch out to solve MDI workspace redraw bugs
2182 for(child = children.first; child; child = child.next)
2184 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2193 Window GetParentMenuBar()
2195 Window result = this;
2196 bool notActiveClient = false;
2197 Window menuBarParent;
2198 for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
2200 if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
2201 if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
2202 notActiveClient = true;
2207 void CreateSystemChildren(void)
2209 Window parent = this;
2210 bool scrollBarChanged = false;
2211 bool hasClose = false, hasMaxMin = false;
2212 Point scroll = this.scroll;
2214 if(state == maximized)
2215 parent = GetParentMenuBar();
2219 if(style.hasClose) hasClose = true;
2220 if(style.hasMaximize || style.hasMinimize)
2227 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2229 sysButtons[2].Destroy(0);
2230 sysButtons[2] = null;
2232 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2234 sysButtons[1].Destroy(0);
2235 sysButtons[1] = null;
2237 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2239 sysButtons[0].Destroy(0);
2240 sysButtons[0] = null;
2243 if(hasClose && parent)
2250 parent, master = this,
2251 inactive = true, nonClient = true, visible = false;
2253 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2259 if(this.parent == guiApp.desktop)
2260 sysButtons[2].hotKey = altF4;
2261 else if(style.isActiveClient)
2262 sysButtons[2].hotKey = ctrlF4;
2263 sysButtons[2].Create();
2266 sysButtons[2].symbol = 'X';
2267 sysButtons[2].disabled = !style.hasClose;
2270 if(hasMaxMin && parent)
2274 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2275 if(state == maximized)
2278 method = RestoreButtonClicked;
2284 method = MaximizeButtonClicked;
2292 parent, master = this,
2293 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2295 sysButtons[1].Create();
2297 sysButtons[1].NotifyClicked = method;
2299 sysButtons[1].symbol = symbol;
2300 sysButtons[1].disabled = !style.hasMaximize;
2303 if(hasMaxMin && parent)
2307 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2308 if (state == minimized)
2311 method = RestoreButtonClicked;
2317 method = MinimizeButtonClicked;
2325 parent, master = this,
2326 hotKey = altM, inactive = true, nonClient = true, visible = false
2328 sysButtons[0].Create();
2330 sysButtons[0].NotifyClicked = method;
2332 sysButtons[0].symbol = symbol;
2333 sysButtons[0].disabled = !style.hasMinimize;
2336 // Create the scrollbars
2337 if(style.hasHorzScroll && !sbh)
2343 direction = horizontal,
2347 snap = scrollFlags.snapX,
2348 NotifyScrolling = ScrollBarNotification
2351 scrollBarChanged = true;
2353 else if(sbh && !style.hasHorzScroll)
2359 if(style.hasVertScroll && !sbv)
2365 direction = vertical,
2369 snap = scrollFlags.snapY,
2370 NotifyScrolling = ScrollBarNotification
2373 scrollBarChanged = true;
2375 else if(sbv && !style.hasVertScroll)
2380 if(scrollBarChanged)
2382 SetScrollLineStep(sbStep.x, sbStep.y);
2383 UpdateScrollBars(true, true);
2387 if(scrollBarChanged)
2389 if(sbh) sbh.thumbPosition = scroll.x;
2390 if(sbv) sbv.thumbPosition = scroll.y;
2394 void UpdateCaption(void)
2396 if(rootWindow == this)
2399 FigureCaption(caption);
2400 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2402 UpdateDecorations();
2405 if(parent.activeClient == this) // Added this last check
2407 if(parent.rootWindow == parent)
2410 parent.FigureCaption(caption);
2411 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2414 parent.UpdateCaption();
2416 parent.UpdateDecorations();
2420 void UpdateActiveDocument(Window previous)
2422 Window activeClient = this.activeClient;
2423 Window activeChild = this.activeChild;
2430 activeClient.CreateSystemChildren();
2432 previous.CreateSystemChildren();
2444 // Build window list
2447 Menu windowMenu = menu.FindMenu("Window");
2452 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2455 Window document = cycle.data;
2456 if(!document.style.nonClient && document.style.isActiveClient && document.visible)
2458 char name[2048], caption[2048];
2459 document.FigureCaption(caption);
2460 sprintf(name, "%d %s", id+1, caption);
2461 windowMenu.AddDynamic(MenuItem
2463 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2464 NotifySelect = MenuWindowSelectWindow
2468 if(activeClient.cycle == cycle) break;
2473 if((!previous && activeClient) || !activeClient)
2479 item = menu.FindItem(MenuWindowCloseAll, 0);
2480 if(item) item.disabled = false;
2481 item = menu.FindItem(MenuWindowNext, 0);
2482 if(item) item.disabled = false;
2483 item = menu.FindItem(MenuWindowPrevious, 0);
2484 if(item) item.disabled = false;
2485 item = menu.FindItem(MenuWindowCascade, 0);
2486 if(item) item.disabled = false;
2487 item = menu.FindItem(MenuWindowTileHorz, 0);
2488 if(item) item.disabled = false;
2489 item = menu.FindItem(MenuWindowTileVert, 0);
2490 if(item) item.disabled = false;
2491 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2492 if(item) item.disabled = false;
2493 item = menu.FindItem(MenuWindowWindows, 0);
2494 if(item) item.disabled = false;
2497 item = menu.FindItem(MenuFileClose, 0);
2498 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2499 item = menu.FindItem(MenuFileSaveAll, 0);
2500 if(item) item.disabled = numDocuments < 1;
2502 if(activeClient && activeClient.menu && activeClient.state != minimized)
2506 //activeClient.menu.Clean(activeClient);
2507 menu.Merge(activeClient.menu, true, activeClient);
2511 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2514 menu.Merge(activeChild.menu, true, activeChild);
2517 // This is called again for a child window change, with same active client
2518 OnActivateClient(activeClient, previous);
2519 if(!menuBar && !((BorderBits)borderStyle).fixed && parent && parent.activeClient == this)
2520 parent.UpdateActiveDocument(null);
2523 void _ShowDecorations(Box box, bool post)
2525 if(rootWindow == this && nativeDecorations) return;
2526 if(visible && this != guiApp.desktop)
2528 Surface surface = RedrawFull(box);
2532 FigureCaption(caption);
2535 ShowDecorations(captionFont.font,
2538 active, //parent.activeClient == this
2539 guiApp.windowMoving == this);
2541 PreShowDecorations(captionFont.font,
2544 active, //parent.activeClient == this
2545 guiApp.windowMoving == this);
2552 void UpdateExtent(Box refresh)
2554 Surface surface = null;
2556 if(!manageDisplay) { OnRedraw(null);return; }
2557 _ShowDecorations(refresh, false);
2559 surface = Redraw(refresh);
2560 // Opaque background: just fill before EW_REDRAW (clear?)
2563 surface.SetBackground(background);
2564 surface.SetForeground(foreground);
2565 surface.DrawingChar(' ');
2566 if(this == rootWindow)
2568 if(style.drawBehind || background.a)
2570 int a = background.a;
2571 // Premultiply alpha for clear color
2572 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2573 surface.Clear(colorBuffer);
2574 surface.SetBackground(background);
2577 else if(background.a)
2581 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2582 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2585 if(display.flags.alpha && background.a < 255 && background)
2587 surface.Area(0,0,clientSize.w, clientSize.h);
2588 /*if(style.clearDepthBuffer)
2589 surface.Clear(depthBuffer);*/
2591 else if(/*style.clearDepthBuffer || */background.a)
2593 int a = background.a;
2594 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2595 // Premultiply alpha for clear color
2596 surface.SetBackground({ (byte)a, { (byte)(a*background.color.r/255), (byte)(a*background.color.g/255), (byte)(a*background.color.b/255) } });
2597 surface.Clear(colorBuffer);
2598 surface.SetBackground(background);
2603 surface.TextFont(usedFont.font);
2604 surface.TextOpacity(false);
2608 // Draw the caret ...
2609 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2611 // surface.SetBackground(0xFFFFFF - background.color);
2612 surface.SetBackground(~background.color);
2614 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2615 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2621 void DrawOverChildren(Box refresh)
2623 Surface surface = Redraw(refresh);
2627 surface.DrawingChar(' ');
2628 surface.SetBackground(background);
2629 surface.SetForeground(foreground);
2631 surface.TextFont(usedFont.font);
2632 surface.TextOpacity(false);
2634 OnDrawOverChildren(surface);
2639 _ShowDecorations(refresh, true);
2642 void ComputeClipExtents(void)
2645 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2647 clipExtent.Copy(this.clipExtent);
2649 for(child = children.last; child; child = child.prev)
2651 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2653 bool opaque = child.IsOpaque(); // TODO: acess background directly
2654 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2656 child.clipExtent.Copy(clipExtent);
2657 child.clipExtent.Offset(-dx, -dy);
2658 child.clipExtent.IntersectBox(child.box);
2660 child.ComputeClipExtents();
2662 if(opaque && !child.style.nonClient)
2664 // Adjust the box for the parent:
2665 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2666 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2671 // ??? Only do this for overlapped window or if parent has with clip children flag
2673 // Do this if window has clip children flag on (default false?)
2674 // this.clipExtent = clipExtent;
2676 clipExtent.Free(null);
2679 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2681 bool opaque = IsOpaque();
2683 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2684 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2686 offsetX -= rootWindow.clientStart.x;
2687 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2691 for(child = children.last; child; child = child.prev)
2693 ColorAlpha background = *(ColorAlpha *)&child.background;
2694 bool opaque = child.IsOpaque();
2695 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2699 // Adjust renderArea to the root window level
2700 Extent * renderArea = &rootWindow.tempExtents[1];
2702 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2703 if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
2705 offsetX -= child.rootWindow.clientStart.x;
2706 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2710 Extent childRenderArea;
2712 if(backBufferUpdate != null)
2714 childRenderArea.Copy(backBufferUpdate);
2715 childRenderArea.Offset(-offsetX, -offsetY);
2718 childRenderArea.Copy(child.dirtyArea);
2720 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2721 renderArea.Copy(dirtyExtent);
2722 renderArea.Offset(-offsetX, -offsetY);
2723 childRenderArea.Union(renderArea);
2726 // Intersect with the clip extent
2727 childRenderArea.Intersection(child.clipExtent);
2730 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2731 renderArea->Offset(offsetX, offsetY);
2732 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2733 // overDirtyExtent.Union(renderArea);
2734 renderArea->Empty();
2735 // childRenderArea.Free();
2737 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2742 for(child = children.last; child; child = child.prev)
2744 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2746 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2751 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2753 bool opaque = IsOpaque();
2754 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2756 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2757 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2759 offsetX -= rootWindow.clientStart.x;
2760 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2764 for(child = children.last; child; child = child.prev)
2766 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2768 ColorAlpha background = *(ColorAlpha *)&child.background;
2769 bool opaque = child.IsOpaque();
2770 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2774 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2775 // Adjust renderArea to the root window level
2777 renderArea.Copy(child.dirtyArea);
2778 renderArea.Offset(offsetX, offsetY);
2779 dirtyExtent.Union(renderArea);
2780 overDirtyExtent.Union(renderArea);
2786 for(child = children.last; child; child = child.prev)
2788 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2790 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2794 if(backBufferUpdate != null)
2796 renderArea.Copy(backBufferUpdate);
2797 renderArea.Offset(-offsetX, -offsetY);
2799 overRenderArea.Copy(backBufferUpdate);
2800 overRenderArea.Offset(-offsetX, -offsetY);
2806 renderArea.Copy(dirtyArea);
2808 overRenderArea.Copy(dirtyArea);
2811 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2812 dirtyExtentWindow->Copy(dirtyExtent);
2813 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2814 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2815 dirtyExtentWindow->Empty();
2817 // Intersect with the clip extent
2818 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2821 if(renderArea.count > 10)
2824 printf("\nToo many extents (%d):\n", renderArea.count);
2826 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2827 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2832 for(c = 0; c<10; c++)
2835 FASTLIST_LOOP(renderArea, extentBox)
2837 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2839 renderArea.Copy(extent);
2841 FASTLIST_LOOP(renderArea, extentBox)
2844 printf("(%d, %d) - (%d, %d)\n",
2845 extentBox.box.left, extentBox.box.top,
2846 extentBox.box.right, extentBox.box.bottom);
2850 printf("\nNow %d\n", renderArea.count);
2856 // WHY WAS THIS COMMENTED ??
2858 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2859 dirtyExtentWindow->Copy(overDirtyExtent);
2860 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2861 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2862 dirtyExtentWindow->Empty();
2864 // Intersect with the clip extent
2865 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2871 if(scrollExtent.count)
2873 // Subtract render extent from scrolling extent
2874 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2876 if(backBufferUpdate == null)
2878 Extent * dirty = &rootWindow.tempExtents[3];
2881 // Intersect scrolling extent with clip extent
2882 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2884 // offset this scroll to be at the root window level
2885 scrollExtent.Offset(offsetX, offsetY);
2886 // Add area that was scrolled to the dirty extents of the back buffer
2887 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2891 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2892 for(scrollBox = (BoxItem)scrollExtent.first; scrollBox; scrollBox = (BoxItem)scrollBox.next)
2893 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2898 scrollExtent.Empty();
2900 // Add the exposed extent to the window render area
2901 dirty->Offset(-offsetX, -offsetY);
2902 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2907 // Subtract the window's box from the transparency forced extent
2908 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2914 renderArea.Copy(this.renderArea);
2915 renderArea.Offset(offsetX, offsetY);
2916 dirtyExtent.Union(renderArea);
2922 Extent renderArea { };
2924 renderArea.Copy(overRenderArea);
2925 renderArea.Offset(offsetX, offsetY);
2926 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2931 if(backBufferUpdate != null)
2933 // Remove render area from dirty area
2934 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2936 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2943 // Remove the window render area from the dirty extents of the back buffer
2944 rootWindow.dirtyBack.Exclusion(renderArea);
2948 void Render(Extent updateExtent)
2952 Window rootWindow = this.rootWindow;
2953 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2954 if(rootWindow.nativeDecorations && rootWindow.windowHandle)
2956 offsetX -= rootWindow.clientStart.x;
2957 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2960 if(rootWindow.fullRender)
2969 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2970 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2975 /*if(renderArea.count)
2976 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2979 for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
2981 Box box = extentBox.box;
2984 /*printf("(%d, %d) - (%d, %d)\n",
2985 extentBox.box.left, extentBox.box.top,
2986 extentBox.box.right, extentBox.box.bottom);*/
2991 box.left += offsetX;
2993 box.right += offsetX;
2994 box.bottom += offsetY;
2996 if(updateExtent != null)
2997 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3001 for(child = children.first; child; child = child.next)
3002 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
3003 child.Render(updateExtent);
3005 if(rootWindow.fullRender)
3006 DrawOverChildren(box);
3009 // TO DO: There's an issue about draw over children...
3010 // TO DO: Don't wanna go through this if method isn't used
3011 for(extentBox = (BoxItem)overRenderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
3012 //FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
3014 Box box = extentBox.box;
3016 DrawOverChildren(box);
3018 box.left += offsetX;
3020 box.right += offsetX;
3021 box.bottom += offsetY;
3023 if(updateExtent != null)
3024 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
3027 for(child = children.first; child; child = child.next)
3028 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
3029 child.Render(updateExtent);
3032 overRenderArea.Empty();
3035 public void UpdateDisplay(void)
3037 if(!manageDisplay) { OnRedraw(null);return; }
3038 if(rootWindow && this != rootWindow)
3039 rootWindow.UpdateDisplay();
3042 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
3043 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
3046 dirtyExtent.Clear();
3049 clipExtent.AddBox(box);
3051 display.StartUpdate();
3053 if(!rootWindow.fullRender)
3055 ComputeClipExtents();
3056 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
3057 ComputeRenderArea(dirtyExtent, overExtent, null);
3060 clipExtent.Free(null);
3062 dirtyExtent.Free(null);
3063 overExtent.Free(null);
3065 if(display.flags.flipping)
3068 display.Update(null);
3072 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
3073 updateExtent.Clear();
3075 Render(updateExtent);
3077 updateExtent.UnionBox(this.box, tempExtents[0]);
3080 //printf("\n\nUpdate:\n------------------------------------------\n");
3083 //FASTLIST_LOOP(updateExtent, extentBox)
3084 for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
3087 /*printf("Updating (%d, %d) - (%d, %d)\n",
3088 extentBox.box.left, extentBox.box.top,
3089 extentBox.box.right, extentBox.box.bottom);*/
3092 display.Update(extentBox.box);
3095 updateExtent.Free(null);
3098 display.EndUpdate();
3106 void UpdateBackDisplay(Box box)
3112 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3114 //printf("UpdateBackDisplay going through!\n");
3115 display.StartUpdate();
3119 intersection.Copy(dirtyBack);
3120 intersection.IntersectBox(box);
3122 dirtyExtent.Clear();
3125 clipExtent.AddBox(box);
3127 if(!rootWindow.fullRender)
3129 ComputeClipExtents();
3130 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3133 clipExtent.Free(null);
3135 intersection.Free(null);
3136 dirtyExtent.Free(null);
3137 overExtent.Free(null);
3142 if(display.flags.flipping)
3143 display.Update(null);
3146 rootWindow.display.Update(box);
3149 display.EndUpdate();
3153 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3154 if(dirtyBack.count > MAX_DIRTY_BACK)
3156 BoxItem extentBox, next;
3157 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3158 for(extentBox = (BoxItem)dirtyBack.first; extentBox; extentBox = next)
3160 next = (BoxItem)extentBox.next;
3161 if(extentBox != first)
3163 if(extentBox.box.left < first.box.left)
3164 first.box.left = extentBox.box.left;
3165 if(extentBox.box.top < first.box.top)
3166 first.box.top = extentBox.box.top;
3167 if(extentBox.box.right > first.box.right)
3168 first.box.right = extentBox.box.right;
3169 if(extentBox.box.bottom > first.box.bottom)
3170 first.box.bottom = extentBox.box.bottom;
3171 dirtyBack.Delete(extentBox);
3180 // --- Window positioning ---
3181 // --- Window identification ---
3183 // Returns window at position "Position"
3184 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3186 Window child, result = null;
3188 box.left += absPosition.x;
3189 box.right += absPosition.x;
3190 box.top += absPosition.y;
3191 box.bottom += absPosition.y;
3193 if(!destroyed && visible && (acceptDisabled || !disabled))
3195 int lx = x - absPosition.x;
3196 int ly = y - absPosition.y;
3197 if(IsInside(lx, ly))
3198 // if(box.IsPointInside(Point{x, y}))
3200 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3201 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3204 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3206 if(child != statusBar && child.rootWindow == rootWindow)
3208 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3215 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3217 if(child != statusBar && child.rootWindow == rootWindow)
3219 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3231 Window FindModal(void)
3233 Window modalWindow = this, check;
3234 Window check2 = null;
3235 for(check = this; check.master; check = check.master)
3237 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3239 modalWindow = check.master.modalSlave;
3240 check = modalWindow;
3242 // TESTING THIS FOR DROPBOX...
3243 if(!rootWindow || !rootWindow.style.interim)
3245 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3247 if(check2.modalSlave && check2.modalSlave.created)
3249 modalWindow = check2.modalSlave;
3257 if(modalWindow == this)
3259 for(check = this; check.activeChild; check = check.activeChild)
3261 if(check.modalSlave)
3263 modalWindow = check.modalSlave;
3269 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3270 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3273 void StopMoving(void)
3275 if(this == guiApp.windowMoving)
3277 guiApp.windowMoving = null;
3278 UpdateDecorations();
3279 SetMouseRange(null);
3282 if(rootWindow.active)
3283 guiApp.interfaceDriver.StopMoving(rootWindow);
3286 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3287 guiApp.windowIsResizing = false;
3291 void SelectMouseCursor(void)
3296 Window cursorWindow = null;
3297 bool rx, ry, rex, rey;
3299 guiApp.desktop.GetMousePosition(&x, &y);
3300 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3302 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3303 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3304 else if(mouseWindow)
3306 modalWindow = mouseWindow.FindModal();
3307 x -= mouseWindow.absPosition.x;
3308 y -= mouseWindow.absPosition.y;
3309 if(guiApp.windowIsResizing)
3311 rex = guiApp.resizeEndX;
3312 rey = guiApp.resizeEndY;
3313 rx = guiApp.resizeX;
3314 ry = guiApp.resizeY;
3315 if((rex && rey) || (rx && ry))
3316 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3317 else if((rex && ry) || (rx && rey))
3318 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3319 else if((ry || rey) && (!rx && !rex))
3320 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3321 else if((rx || rex) && (!ry && !rey))
3322 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3324 else if(!modalWindow && !guiApp.windowCaptured &&
3325 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3326 &rx, &ry, &rex, &rey))
3328 if((rex && rey) || (rx && ry))
3329 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3330 else if((rex && ry) || (rx && rey))
3331 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3332 else if((ry || rey) && (!rx && !rex))
3333 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3334 else if((rx || rex) && (!ry && !rey))
3335 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3337 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3339 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3340 cursorWindow = mouseWindow.parent;
3342 cursorWindow = mouseWindow;
3344 else if(!guiApp.interimWindow)
3345 cursorWindow = guiApp.windowCaptured;
3348 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3349 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3351 else if(modalWindow)
3353 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3355 else if(guiApp.interimWindow)
3357 if(guiApp.interimWindow.cursor)
3358 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3360 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3365 // --- State based input ---
3366 bool AcquireInputEx(bool state)
3371 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3372 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3374 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3376 guiApp.acquiredWindow = state ? this : null;
3379 SetMouseRangeToClient();
3380 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3385 SelectMouseCursor();
3387 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3391 // --- Window activation ---
3392 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3395 if(!parent || !parent.style.inactive)
3397 Window parent = this.parent;
3400 if(rootWindow == this)
3401 Log(active ? "active\n" : "inactive\n");
3404 // Testing this here...
3405 if(!parent || parent == guiApp.desktop || parent.active)
3407 this.active = active;
3410 // TESTING THIS HERE
3411 UpdateDecorations();
3412 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3413 result = NotifyActivate(master, this, active, previous);
3416 this.active = !active;
3421 if(!parent || parent == guiApp.desktop || parent.active)
3423 this.active = active;
3425 AcquireInputEx(active);
3430 if(guiApp.caretOwner)
3434 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3435 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3436 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3437 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3439 guiApp.caretOwner.Update(extent);
3442 if(visible || !guiApp.caretOwner)
3443 guiApp.caretOwner = this;
3444 UpdateCaret(false, false);
3450 this.active = false;
3452 AcquireInputEx(active);
3454 if(!active && guiApp.caretOwner == this)
3456 UpdateCaret(false, true);
3457 guiApp.caretOwner = null;
3458 guiApp.interfaceDriver.SetCaret(0,0,0);
3459 guiApp.caretEnabled = false;
3464 if(!active && parent && parent.activeChild && parent.activeChild != this)
3465 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3471 if(!active && menuBar)
3474 menuBar.OnActivate(false, null, &goOn, true);
3475 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3480 Window aChild = activeChild;
3482 if(!aChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3494 void ConsequentialMouseMove(bool kbMoving)
3498 if(kbMoving || !guiApp.windowMoving)
3502 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3504 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3506 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3507 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3513 bool IsDescendantOf(Window ancestor)
3516 for(window = this; window && window != ancestor; window = window.parent);
3517 return window == ancestor;
3520 bool IsSlaveOf(Window master)
3523 for(window = this; window && window != master; window = window.master);
3524 return window == master;
3527 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3531 if(this && !destroyed /*&& state != Hidden*/)
3533 Window swap = externalSwap;
3541 if(activateParent &&
3542 (parent.activeChild != this ||
3543 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3544 active && _isModal &&
3545 parent != master && master)
3546 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3552 bool real = parent.activeChild != this;
3554 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3555 if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
3556 !IsDescendantOf(guiApp.interimWindow) &&
3557 !IsSlaveOf(guiApp.interimWindow))
3559 Window interimWindow = guiApp.interimWindow;
3560 while(interimWindow && interimWindow != this)
3562 Window master = interimWindow.master;
3564 guiApp.interimWindow = null;
3565 if(guiApp.caretOwner)
3566 guiApp.caretOwner.UpdateCaret(false, false);
3568 incref interimWindow;
3569 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3574 delete interimWindow;
3575 interimWindow = (master && master.style.interim) ? master : null;
3580 guiApp.interimWindow = this;
3581 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3582 guiApp.caretEnabled = false;*/
3583 UpdateCaret(false, true);
3588 bool acquireInput = false;
3590 parent.activeChild &&
3591 parent.activeChild.state == maximized &&
3592 parent != guiApp.desktop;
3594 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3599 swap = parent.activeChild;
3600 if(swap && swap.destroyed) swap = null;
3601 if(swap && swap != this)
3604 if(!swap.PropagateActive(false, this, &goOn, true))
3605 swap = parent.activeChild;
3616 if(!parent || parent.activeChild != this || style.interim)
3619 result = PropagateActive(true, swap, &goOn, true);
3620 if(!result && !goOn)
3625 acquireInput = true;
3629 if(style.hasMaximize && parent != guiApp.desktop)
3632 SetState(maximized, false, 0);
3633 else if(state != maximized)
3636 for(child = parent.children.first; child; child = child.next)
3638 if(this != child && child.state == maximized)
3639 child.SetState(normal, false, 0);
3646 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3648 Window previous = parent.activeClient;
3649 parent.activeChild = this;
3650 if(!style.nonClient /*&& style.isActiveClient*/)
3654 if(style.isActiveClient)
3655 parent.activeClient = this;
3656 // Moved UpdateActiveDocument inside hidden check
3657 // To prevent activating previous window while creating a new one
3658 // (It was messing up the privateModule in the CodeEditor)
3659 parent.UpdateActiveDocument(previous);
3665 //if(!style.isRemote)
3667 if(rootWindow != this)
3669 if(activateParent && parent && !parent.active /*parent != parent.parent.activeChild*/)
3670 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3672 else if(!guiApp.fullScreenMode)
3674 Window modalRoot = FindModal();
3675 if(!modalRoot) modalRoot = this;
3676 if(!modalRoot.isForegroundWindow)
3678 modalRoot.isForegroundWindow = true;
3679 // To check : Why is parent null?
3680 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3682 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3684 modalRoot.isForegroundWindow = false;
3689 if(result && real && (!style.inactive || moveInactive) && parent)
3691 Window last = parent.children.last;
3693 if(!style.stayOnTop)
3694 for(; last && last.style.stayOnTop; last = last.prev);
3696 parent.children.Move(this, last);
3698 // Definitely don't want that: why not?
3702 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3708 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3715 parent.activeChild = null;
3716 if(!style.nonClient /*&& style.isActiveClient*/)
3718 Window previous = parent.activeClient;
3719 if(style.isActiveClient)
3720 parent.activeClient = null;
3721 parent.UpdateActiveDocument(previous);
3725 if(this == guiApp.interimWindow)
3727 guiApp.interimWindow = null;
3728 if(guiApp.caretOwner)
3729 guiApp.caretOwner.UpdateCaret(false, false);
3731 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3738 if(!active || !swap)
3739 UpdateDecorations();
3741 swap.UpdateDecorations();
3743 if(active && rootWindow != this)
3744 ConsequentialMouseMove(false);
3751 // --- Input Messages ---
3752 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3754 static bool reEntrancy = false;
3755 if(reEntrancy) return;
3759 guiApp.cursorUpdate = true;
3760 if(guiApp.windowScrolling && !consequential)
3762 guiApp.windowScrolling.SetScrollPosition(
3763 (guiApp.windowScrolling.sbh) ?
3764 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3765 (guiApp.windowScrolling.sbv) ?
3766 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3768 if(guiApp.windowMoving)
3770 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3772 Window window = guiApp.windowMoving;
3774 int w = window.size.w;
3775 int h = window.size.h;
3780 rx = mouseX - guiApp.windowMovingStart.x;
3781 ry = mouseY - guiApp.windowMovingStart.y;
3784 window.GetDecorationsSize(&ew, &eh);
3786 if(guiApp.windowIsResizing)
3788 x = window.scrolledPos.x;
3789 y = window.scrolledPos.y;
3793 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3794 rx = guiApp.windowResizingBefore.w - aw;
3795 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3796 w = guiApp.windowResizingBefore.w - rx;
3800 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3801 ry = guiApp.windowResizingBefore.h - ah;
3802 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3803 ry = Max(ry, -guiApp.windowMovingBefore.y);
3804 h = guiApp.windowResizingBefore.h - ry;
3806 if(guiApp.resizeEndX)
3808 w = guiApp.windowResizingBefore.w + rx;
3811 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3819 w = Max(w, window.minSize.w);
3820 h = Max(h, window.minSize.h);
3821 w = Min(w, window.maxSize.w);
3822 h = Min(h, window.maxSize.h);
3824 if(!window.OnResizing(&w, &h))
3826 w = window.clientSize.w;
3827 h = window.clientSize.h;
3830 w = Max(w, window.skinMinSize.w);
3831 h = Max(h, window.skinMinSize.h);
3838 SNAPDOWN(w, textCellW);
3839 SNAPDOWN(h, textCellH);
3844 aw = Max(w,window.skinMinSize.w);
3845 rx = guiApp.windowResizingBefore.w - aw;
3846 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3847 w = guiApp.windowResizingBefore.w - rx;
3851 ah = Max(h,window.skinMinSize.h);
3852 ry = guiApp.windowResizingBefore.h - ah;
3853 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3854 ry = Max(ry, -guiApp.windowMovingBefore.y);
3855 h = guiApp.windowResizingBefore.h - ry;
3860 if(!guiApp.windowIsResizing || guiApp.resizeX)
3861 x = guiApp.windowMovingBefore.x + rx;
3862 if(!guiApp.windowIsResizing || guiApp.resizeY)
3863 y = guiApp.windowMovingBefore.y + ry;
3865 if(!guiApp.windowIsResizing)
3868 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3870 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3871 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3872 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3873 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3877 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3878 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3884 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3886 if(!window.OnMoving(&x, &y, w, h))
3888 x = window.scrolledPos.x;
3889 y = window.scrolledPos.y;
3895 SNAPDOWN(x, textCellW);
3896 SNAPDOWN(y, textCellH);
3899 if(!window.style.nonClient)
3901 if(!window.style.fixed /*|| window.style.isDocument*/)
3903 if(!window.style.dontScrollHorz)
3904 x += window.parent.scroll.x;
3905 if(!window.style.dontScrollVert)
3906 y += window.parent.scroll.y;
3910 // Break the anchors for moveable/resizable windows
3911 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3912 if(window.style.fixed)
3914 if(window.state == normal)
3916 window.normalAnchor = Anchor { left = x, top = y };
3917 window.normalSizeAnchor = SizeAnchor { { w, h } };
3918 window.anchored = false;
3922 window.stateAnchor = Anchor { left = x, top = y };
3923 window.stateSizeAnchor = SizeAnchor { { w, h } };
3925 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3926 // TOCHECK: Investigate why the following only redraws the scrollbars
3927 //window.Position(x, y, w, h, false, true, true, true, false, true);
3929 guiApp.movingLast.x = mouseX;
3930 guiApp.movingLast.y = mouseY;
3936 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3939 bool wasMoving = guiApp.windowMoving ? true : false;
3940 bool wasScrolling = guiApp.windowScrolling ? true : false;
3942 while(result && w != this)
3944 Window msgWindow = GetAtPosition(x,y, false, true, w);
3945 Window trueWindow = GetAtPosition(x,y, false, false, w);
3946 bool windowDragged = false;
3951 window = (w && !w.disabled) ? w : null;
3953 if(trueWindow) incref trueWindow;
3955 if(consequential) mods->isSideEffect = true;
3957 UpdateMouseMove(x, y, consequential);
3959 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3961 if(!guiApp.windowCaptured.isEnabled)
3962 guiApp.windowCaptured.ReleaseCapture();
3964 window = guiApp.windowCaptured;
3967 if(trueWindow && activate &&
3968 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3969 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3970 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3971 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3973 if(mods->alt && !mods->ctrl && !mods->shift)
3975 Window moved = trueWindow;
3976 for(moved = trueWindow; moved; moved = moved.parent)
3977 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3982 windowDragged = true;
3984 // Cancel the ALT menu toggling...
3985 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3990 if(window && activate &&
3991 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3992 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3993 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3994 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3996 Window modalWindow = window.FindModal();
3998 /*if(mods->alt && !mods->shift && !mods->ctrl)
4000 Window moved = window;
4001 for(moved = window; moved; moved = moved.parent)
4002 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
4007 windowDragged = true;
4009 // Cancel the ALT menu toggling...
4010 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
4016 Window activateWindow = modalWindow ? modalWindow : window;
4017 if(activateWindow && !activateWindow.isRemote)
4019 bool doActivation = true;
4020 //bool needToDoActivation = false;
4021 Window check = activateWindow;
4023 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
4025 if(!check.style.inactive)
4027 //needToDoActivation = true;
4029 doActivation = false;
4034 if(!needToDoActivation)
4035 doActivation = false;
4038 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
4039 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
4041 // Let the OnLeftButtonDown do the activating instead
4042 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4050 incref activateWindow;
4051 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
4053 delete activateWindow;
4057 if(activateWindow._refCount == 1)
4059 delete activateWindow;
4063 delete activateWindow;
4065 mods->isActivate = true;
4069 if(!modalWindow && window && !window.destroyed)
4071 if(!guiApp.windowCaptured || windowDragged)
4073 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
4075 bool moving = ((window.state != maximized &&
4076 window.IsMouseMoving(
4077 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4078 || (guiApp.windowMoving && !guiApp.windowIsResizing);
4080 if(!moving && window.IsMouseResizing(
4081 x - window.absPosition.x,
4082 y - window.absPosition.y,
4083 window.size.w, window.size.h,
4084 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
4086 guiApp.windowIsResizing = true;
4087 guiApp.windowResizingBefore.w = window.size.w;
4088 guiApp.windowResizingBefore.h = window.size.h;
4090 if(guiApp.windowIsResizing || windowDragged || moving)
4093 guiApp.windowMoving = window;
4094 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
4095 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
4096 guiApp.windowMovingBefore.x = window.position.x;//s;
4097 guiApp.windowMovingBefore.y = window.position.y;//s;
4098 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
4099 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
4102 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4104 if(window.style.fixed &&
4106 window.IsMouseMoving(
4107 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4109 window.ShowSysMenu(x, y);
4113 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4115 if(window.sbv || window.sbh)
4118 guiApp.windowScrolling = window;
4119 guiApp.windowScrollingStart.x = x;
4120 guiApp.windowScrollingStart.y = y;
4121 guiApp.windowScrollingBefore.x = window.scroll.x;
4122 guiApp.windowScrollingBefore.y = window.scroll.y;
4125 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4127 if(window.style.hasMaximize &&
4128 window.IsMouseMoving(
4129 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4132 (window.state == maximized) ? normal : maximized, false, *mods);
4140 if(guiApp.windowMoving)
4142 if(guiApp.windowMoving.parent)
4144 if(guiApp.windowMoving.style.nonClient)
4145 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4147 guiApp.windowMoving.parent.SetMouseRangeToClient();
4151 window.UpdateDecorations();
4154 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4156 // Log("\n*** LEFT BUTTON UP ***\n");
4157 if(guiApp.windowMoving)
4158 guiApp.windowMoving.StopMoving();
4160 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4162 if(guiApp.windowScrolling)
4164 Window windowScrolling = guiApp.windowScrolling;
4165 guiApp.windowScrolling = null;
4166 windowScrolling.ReleaseCapture();
4170 if(!result || (window && window.destroyed)) window = null;
4172 if(window && window.FindModal())
4175 if(trueWindow && trueWindow.FindModal())
4183 msgWindow = GetAtPosition(x,y, true, false);
4185 msgWindow.SelectMouseCursor();
4188 if(guiApp.windowCaptured || trueWindow)
4190 Window prevWindow = guiApp.prevWindow;
4191 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4193 guiApp.prevWindow.mouseInside = false;
4194 guiApp.prevWindow = null;
4196 // Eventually fix this not to include captured?
4197 if(!prevWindow.OnMouseLeave(*mods))
4200 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4202 Box box = trueWindow.box;
4203 box.left += trueWindow.absPosition.x;
4204 box.right += trueWindow.absPosition.x;
4205 box.top += trueWindow.absPosition.y;
4206 box.bottom += trueWindow.absPosition.y;
4208 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4210 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4211 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4213 overX = Max(Min(overX, 32767),-32768);
4214 overY = Max(Min(overY, 32767),-32768);
4216 trueWindow.mouseInside = true;
4217 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4221 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4222 guiApp.prevWindow = trueWindow;
4224 guiApp.prevWindow = null;
4226 SelectMouseCursor();
4228 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4230 int clientX = x - (window.absPosition.x + window.clientStart.x);
4231 int clientY = y - (window.absPosition.y + window.clientStart.y);
4233 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4235 clientX = Max(Min(clientX, 32767),-32768);
4236 clientY = Max(Min(clientY, 32767),-32768);
4238 MouseMethod = (void *)window._vTbl[method];
4240 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4243 if(!MouseMethod(window, clientX, clientY, *mods))
4250 if(result && w && w.clickThrough && w.parent)
4255 if(!result || !w || !w.clickThrough)
4262 // --- Mouse cursor management ---
4264 bool KeyMessage(uint method, Key key, unichar character)
4269 if(guiApp.interimWindow)
4270 this = guiApp.interimWindow;
4273 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4277 if(!style.inactive || rootWindow != this)
4279 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4280 Window modalWindow = FindModal();
4281 Window interimMaster = master ? master.rootWindow : null;
4285 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4286 status = OnSysKeyDown(key, character);
4287 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4288 status = OnSysKeyHit(key, character);
4289 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4290 status = OnSysKeyUp(key, character);
4297 // Process Key Message for Internal UI Keyboard actions
4298 if(status && !destroyed && menuBar && state != minimized)
4301 if((SmartKey)key != alt)
4302 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4305 SmartKey sk = (SmartKey) key;
4306 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4308 status = menuBar.KeyMessage(method, key, character);
4313 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4314 menuBar.OnKeyHit(escape, 0);
4316 if(!menuBar.focus && guiApp.caretOwner)
4317 guiApp.caretOwner.UpdateCaret(true, false);
4320 if(!destroyed && status)
4322 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4326 case left: case up: case right: case down:
4327 if(guiApp.windowMoving == this)
4330 int w = guiApp.windowMoving.size.w;
4331 int h = guiApp.windowMoving.size.h;
4332 int x = guiApp.windowMoving.scrolledPos.x;
4333 int y = guiApp.windowMoving.scrolledPos.y;
4337 if(key == down || key == up)
4338 step = Max(step, textCellH);
4340 step = Max(step, textCellW);
4343 if(guiApp.windowIsResizing)
4347 case left: w-=step; break;
4348 case right: w+=step; break;
4349 case up: h-=step; break;
4350 case down: h+=step; break;
4357 case left: x-=step; break;
4358 case right: x+=step; break;
4359 case up: y-=step; break;
4360 case down: y+=step; break;
4364 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4365 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4367 if(!guiApp.windowIsResizing || guiApp.resizeX)
4368 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4370 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4372 if(!guiApp.windowIsResizing || guiApp.resizeY)
4373 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4375 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4377 guiApp.interfaceDriver.SetMousePosition(x, y);
4378 ConsequentialMouseMove(true);
4386 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4388 guiApp.windowMoving.StopMoving();
4389 ConsequentialMouseMove(false);
4397 ShowSysMenu(absPosition.x, absPosition.y);
4405 if(!destroyed && status && state != minimized)
4407 // Process all the way down the children
4408 if(activeChild && !activeChild.disabled)
4410 status = activeChild.KeyMessage(method, key, character);
4412 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4413 key.code != left && key.code != right && key.code != up && key.code != down)
4415 status = activeClient.KeyMessage(method, key, character);
4419 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4421 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4422 // && defaultControl != activeChild)
4424 delete previousActive;
4425 previousActive = activeChild;
4426 if(previousActive) incref previousActive;
4428 ConsequentialMouseMove(false);
4429 if((defaultControl.active ||
4430 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4431 defaultControl.KeyMessage(method, defaultKey, character);
4437 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4439 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4446 ShowSysMenu(absPosition.x, absPosition.y);
4453 if(this != guiApp.desktop)
4455 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4457 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4459 MenuMoveOrSize(key.shift, true);
4463 else if(guiApp.windowMoving)
4465 guiApp.windowMoving.StopMoving();
4466 ConsequentialMouseMove(false);
4474 if(!destroyed && status && state != minimized)
4476 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4480 case tab: case shiftTab:
4482 Window cycleParent = this;
4483 if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
4484 cycleParent = master.parent;
4486 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4488 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4490 Window child = cycleParent.activeChild;
4492 // Scroll the window to include the active control
4494 if(cycleParent.sbh && !child.style.dontScrollHorz)
4496 if(child.scrolledPos.x < 0)
4497 cycleParent.sbh.Action(Position,
4498 cycleParent.scroll.x + child.scrolledPos.x, 0);
4499 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4500 cycleParent.sbh.Action(Position,
4501 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4503 if(cycleParent.sbv && !child.style.dontScrollVert)
4505 if(child.scrolledPos.y < 0)
4506 cycleParent.sbv.Action(Position,
4507 cycleParent.scroll.y + child.scrolledPos.y, 0);
4508 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4509 cycleParent.sbv.Action(Position,
4510 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4513 cycleParent.ConsequentialMouseMove(false);
4519 case f6: case shiftF6:
4520 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4522 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4523 if(parent == guiApp.desktop)
4524 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4534 if(CycleChildren(key.shift, true, false, true))
4542 // mIRC Style Window Shortcuts
4543 case alt1: case alt2: case alt3: case alt4: case alt5:
4544 case alt6: case alt7: case alt8: case alt9: case alt0:
4549 for(document = children.first; document; document = document.next)
4551 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4553 if(document == activeChild)
4555 if(document.state == minimized)
4556 document.SetState(normal, false, key);
4559 document.SetState(minimized, false, key);
4560 CycleChildren(false, true, false);
4565 if(activeChild.state == maximized && document.style.hasMaximize)
4566 document.SetState(maximized, false, key);
4567 else if(document.state == minimized)
4568 document.SetState(normal, false, key);
4569 document.Activate();
4584 if(!destroyed && status)
4586 if(state == minimized)
4591 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4593 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4595 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4596 previousActive.ActivateEx(true, false, false, true, null, null);
4597 delete previousActive;
4603 if(!destroyed && status)
4605 status = ProcessHotKeys(method, key, character);
4607 if(!destroyed && status && !modalWindow && state != minimized)
4610 status = KeyMethod(this, key, character);
4611 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4612 status = OnKeyHit(key, character);
4613 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4615 bool result = false;
4618 case ctrlUp: case ctrlDown:
4619 if(sbv && !guiApp.windowScrolling)
4620 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4622 case wheelUp: case wheelDown:
4623 if(sbv && !guiApp.windowScrolling)
4625 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4626 // Do we want to do a consequential move regardless of result in this case?
4627 ConsequentialMouseMove(false);
4630 case ctrlPageUp: case ctrlPageDown:
4631 if(sbh && !guiApp.windowScrolling)
4632 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4637 ConsequentialMouseMove(false);
4642 if(status && !destroyed && menuBar && state != minimized)
4643 status = menuBar.KeyMessage(method, key, character);
4645 if(style.interim && /*destroyed && */status && interimMaster)
4647 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4648 status = interimMaster.KeyMessage(method, key, character);
4655 bool ProcessHotKeys(uint method, Key key, unichar character)
4660 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4661 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4662 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4664 Window hotKeyWindow = hotKey.window;
4665 Window parent = hotKeyWindow.parent;
4666 Window prevActiveWindow = activeChild;
4667 // For when sys buttons are placed inside the menu bar
4668 if(parent && parent._class == class(PopupMenu))
4669 parent = parent.parent;
4671 // 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
4672 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || (hotKeyWindow != parent.sysButtons[2] && hotKeyWindow != parent.sysButtons[1])))
4675 if(prevActiveWindow) incref prevActiveWindow;
4676 incref hotKeyWindow;
4677 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4678 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4681 delete hotKeyWindow;
4682 delete prevActiveWindow;
4686 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4687 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4688 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4690 // ********* WORKING ON THIS ***********
4691 if(prevActiveWindow && !guiApp.interimWindow)
4692 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4695 else if(hotKeyWindow.style.inactive)
4696 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4698 delete prevActiveWindow;
4699 delete hotKeyWindow;
4700 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4701 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4705 if(status && tabCycle)
4708 for(child = children.first; child; child = child.next)
4710 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4721 // --- Windows and graphics initialization / termination ---
4722 bool SetupRoot(void)
4726 // Setup relationship with outside world (bb root || !bb)
4727 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4728 (_displayDriver && dispDriver != parent.dispDriver))
4732 tempExtents = new0 Extent[4];
4737 /*if(guiApp.fullScreenMode)
4738 rootWindow = guiApp.desktop;
4740 //rootWindow = parent.created ? parent.rootWindow : null;
4741 rootWindow = parent.rootWindow;
4744 against = &parent.box;
4746 against = &parent.clientArea;
4749 for(child = children.first; child; child = child.next)
4752 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4755 bool Setup(bool positionChildren)
4757 bool result = false;
4760 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (_displayDriver && dispDriver != parent.dispDriver))))
4762 subclass(DisplayDriver) dDriver = (dispDriver && !formDesigner) ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4763 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4765 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4767 // This was here, is it really needed?
4768 //guiApp.interfaceDriver.ActivateRootWindow(this);
4772 displaySystem = DisplaySystem {};
4773 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4775 delete displaySystem;
4780 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4781 if(display.Create(displaySystem, windowHandle))
4788 // Sometimes icon does not show up on Windows XP if we set here...
4789 // guiApp.interfaceDriver.SetIcon(this, icon);
4791 else if(this != guiApp.desktop)
4793 display = rootWindow ? rootWindow.display : null;
4799 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4800 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4802 for(child = children.first; child; child = child.next)
4804 if(child.created && !child.Setup(false))
4810 bool SetupDisplay(void)
4812 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4813 if(is3D) return Window3D_SetupDisplay(this); else
4820 class_data void ** pureVTbl;
4822 bool LoadGraphics(bool creation, bool resetAnchors)
4824 bool result = false;
4825 bool success = false;
4827 WindowState stateBackup = state;
4829 if(((subclass(Window))_class).pureVTbl)
4831 if(_vTbl == _class._vTbl)
4833 _vTbl = ((subclass(Window))_class).pureVTbl;
4838 for(m = 0; m < _class.vTblSize; m++)
4840 if(_vTbl[m] == _class._vTbl[m])
4841 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4845 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4847 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4849 _vTbl = _class._vTbl;
4854 for(m = 0; m < _class.vTblSize; m++)
4856 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4857 _vTbl[m] = _class._vTbl[m];
4862 if(guiApp.fullScreenMode || this != guiApp.desktop)
4864 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4870 display.Lock(false);
4871 if(rootWindow == this)
4873 // Set Color Palette
4874 display.SetPalette(palette, true);
4878 if(guiApp.fullScreenMode && this == guiApp.desktop)
4883 for(c=0; c<SystemCursor::enumSize; c++)
4884 if(!guiApp.systemCursors[c].bitmap)
4886 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4887 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4888 if(guiApp.systemCursors[c].bitmapName)
4890 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4891 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4892 if(guiApp.systemCursors[c].bitmap)
4893 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4898 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4900 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4901 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4903 cursor.bitmap.paletteShades = cursor.paletteShades;
4907 guiApp.cursorUpdate = true;
4910 ConsequentialMouseMove(false);
4916 // Load Window Graphic Resources
4919 if(usedFont == setFont || usedFont == window.systemFont)
4920 RemoveResource(usedFont);
4923 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4926 RemoveResource(systemFont);
4929 RemoveResource(captionFont);
4931 for(ptr = resources.first; ptr; ptr = ptr.next)
4933 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4936 AddResource(setFont);
4938 AddResource(systemFont);
4940 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4947 //if(master && master.font)
4948 if(parent && parent.font)
4952 faceName = parent.font.faceName,
4953 size = parent.font.size,
4954 bold = parent.font.bold,
4955 italic = parent.font.italic,
4956 underline = parent.font.underline
4958 //font = parent.font;
4959 watch(parent) { font { } };
4962 font = guiApp.currentSkin.SystemFont();
4969 captionFont = guiApp.currentSkin ? guiApp.currentSkin.CaptionFont() : null;
4970 AddResource(captionFont);
4972 if(OnLoadGraphics())
4978 //SetScrollLineStep(sbStep.x, sbStep.y);
4980 if(this != guiApp.desktop)
4984 normalAnchor = anchor;
4985 normalSizeAnchor = sizeAnchor;
4988 // Break the anchors for moveable/resizable windows
4990 if(style.fixed && style.isDocument)
4992 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
5004 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5005 stateSizeAnchor = SizeAnchor {};
5010 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5015 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
5016 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
5019 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5023 stateAnchor = normalAnchor;
5024 stateSizeAnchor = normalSizeAnchor;
5027 position = Point { };
5028 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5039 if(Position(x, y, w, h, true, false, true, true, true, true))
5041 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
5044 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
5061 success = result = true;
5064 if(!creation && result)
5066 // Load menu bar first because sys buttons are on it...
5069 if(!menuBar.LoadGraphics(false, resetAnchors))
5075 for(child = children.first; child; child = child.next)
5077 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
5084 CreateSystemChildren();
5088 if(this == guiApp.desktop && !guiApp.fullScreenMode)
5091 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
5096 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
5097 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
5100 // Do this here to avoid problems on Windows
5101 if(stateBackup == maximized)
5102 property::state = maximized;
5106 void UnloadGraphics(bool destroyWindows)
5110 // Free children's graphics
5111 for(child = children.first; child; child = child.next)
5112 child.UnloadGraphics(destroyWindows);
5115 display.Lock(false);
5118 if(guiApp.fullScreenMode && this == guiApp.desktop)
5123 for(c=0; c<SystemCursor::enumSize; c++)
5124 if(guiApp.systemCursors[c].bitmap)
5125 delete guiApp.systemCursors[c].bitmap;
5127 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5128 delete cursor.bitmap;
5130 guiApp.cursorBackground.Free();
5133 if(display && display.displaySystem)
5137 for(ptr = resources.first; ptr; ptr = ptr.next)
5141 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5146 // Free window graphics
5149 // Free skin graphics
5150 if(rootWindow == this)
5152 DisplaySystem displaySystem = display.displaySystem;
5155 display.driverData = null;
5156 display.displaySystem = null;
5160 if(displaySystem && !displaySystem.numDisplays && !is3D)
5161 delete displaySystem;
5170 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5171 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5173 if(this == guiApp.desktop || parent == guiApp.desktop)
5175 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5176 guiApp.interfaceDriver.DestroyRootWindow(this);
5180 // --- Window Hiding ---
5182 void SetVisibility(bool state)
5184 bool visible = (style.hidden || !created) ? false : state;
5185 if(visible != this.visible)
5189 this.visible = visible;
5190 for(child = children.first; child; child = child.next)
5191 child.SetVisibility(visible);
5193 ConsequentialMouseMove(false);
5194 if(parent && !nonClient) parent.OnChildVisibilityToggled(this, visible);
5198 // --- Windows and graphics initialization / termination ---
5200 bool DisplayModeChanged(void)
5202 bool result = false;
5203 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5205 guiApp.modeSwitching = true;
5206 UnloadGraphics(false);
5208 if(LoadGraphics(false, false))
5210 guiApp.modeSwitching = false;
5215 // --- Window updates system ---
5217 void UpdateDirty(Box updateBox)
5219 if(!manageDisplay) { OnRedraw(null);return; }
5222 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5225 if(display.flags.flipping)
5228 rootWindow.UpdateDisplay();
5231 UpdateBackDisplay(updateBox);
5233 if(guiApp.fullScreenMode)
5235 guiApp.cursorUpdate = true;
5236 guiApp.PreserveAndDrawCursor();
5238 if(guiApp.fullScreenMode)
5239 guiApp.RestoreCursorBackground();
5245 // This function is strictly called as a result of system window activation
5246 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5249 Window interimMaster = null;
5250 Window interimWindow = guiApp.interimWindow;
5251 if(interimWindow && interimWindow.master)
5252 interimMaster = interimWindow.master.rootWindow;
5254 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5255 // SetState(normal, false, 0);
5256 SetState(lastState, false, 0);
5258 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5262 /* WTH is this doing here?
5263 while(swap && swap.activeChild)
5265 swap = swap.activeChild;
5268 // TESTING THIS BEFORE...
5269 if(interimWindow && this == interimMaster)
5273 // Window interimSwap = this;
5274 Window menuBar = this.menuBar;
5275 if(menuBar && interimWindow.master == menuBar)
5278 while(interimSwap && interimSwap.activeChild)
5279 interimSwap = interimSwap.activeChild;
5281 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5282 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5284 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5285 //result = ActivateEx(true, true, false, activateRoot, window, null);
5290 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5291 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5293 if(interimWindow == this && interimMaster && !active)
5295 while(interimMaster && interimMaster.interim && interimMaster.master)
5297 // printf("Going up one master %s\n", interimMaster._class.name);
5298 interimMaster = interimMaster.master.rootWindow;
5300 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5301 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5307 bool DestroyEx(int64 returnCode)
5310 Timer timer, nextTimer;
5312 OldLink prevOrder = null;
5313 Window client = null;
5315 if(parent) stopwatching(parent, font);
5317 // if(window.modalSlave) return false;
5318 if(destroyed || !created)
5325 OldLink slave = master.slaves.FindLink(this);
5326 master.slaves.Delete(slave);
5329 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5335 this.returnCode = (DialogResult)returnCode;
5337 AcquireInput(false);
5342 master.hotKeys.Delete(hotKey);
5346 if(guiApp.prevWindow == this)
5348 guiApp.prevWindow = null;
5351 if(guiApp.caretOwner == this)
5353 guiApp.interfaceDriver.SetCaret(0,0,0);
5354 UpdateCaret(false, true);
5355 guiApp.caretEnabled = false;
5360 parent.childrenCycle.Remove(cycle);
5364 OldLink tmpPrev = order.prev;
5365 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5366 prevOrder = tmpPrev;
5369 client = tmpPrev ? tmpPrev.data : null;
5370 if(client == this) { client = null; break; }
5371 if(client && (client.style.hidden || client.destroyed || !client.created))
5372 tmpPrev = client.order.prev;
5376 prevOrder = tmpPrev;
5381 // If this window can be an active client, make sure the next window we activate can also be one
5382 if(!style.nonClient && style.isActiveClient)
5384 tmpPrev = prevOrder;
5387 client = tmpPrev ? tmpPrev.data : null;
5388 if(client == this) { client = null; break; }
5389 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5390 tmpPrev = client.order.prev;
5394 prevOrder = tmpPrev;
5398 if(client && client.style.hidden) client = null;
5400 // parent.childrenOrder.Remove(order);
5403 if(parent && style.isActiveClient && visible)
5405 if(state == minimized) parent.numIcons--;
5406 parent.numPositions--;
5409 // TESTING THIS HERE!
5413 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5414 // to create a window inside a rootwindow that's being destroyed)
5415 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5417 if(master && !master.destroyed /*&&
5418 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5420 if(master.defaultControl == this)
5421 master.defaultControl = null;
5424 parent.OnChildAddedOrRemoved(this, true);
5425 if(parent && !parent.destroyed /*&&
5426 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5428 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5430 if(order && prevOrder && prevOrder.data != this && active)
5432 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5434 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5435 if(parent.activeClient == this)
5437 parent.activeClient = null;
5438 parent.UpdateActiveDocument(null);
5443 if(guiApp.interimWindow == this)
5446 PropagateActive(false, null, &goOn, true);
5450 //if(window.parent.activeChild == window)
5451 parent.activeChild = null;
5452 if(!style.nonClient /*&& style.isActiveClient*/)
5454 Window previous = parent.activeClient;
5455 if(style.isActiveClient)
5456 parent.activeClient = null;
5457 parent.UpdateActiveDocument(previous);
5462 else if(parent.activeClient == this)
5464 parent.activeClient = client;
5465 parent.UpdateActiveDocument(this);
5469 if(guiApp.interimWindow == this)
5471 guiApp.interimWindow = null;
5472 if(guiApp.caretOwner)
5474 Window desktop = guiApp.desktop;
5475 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5476 guiApp.caretOwner.UpdateCaret(false, false);
5481 if(_isModal && master && master.modalSlave == this)
5482 master.modalSlave = null;
5486 if(!guiApp.caretOwner && parent.caretSize)
5488 guiApp.caretOwner = parent;
5489 parent.UpdateCaret(false, false);
5490 parent.Update(null);
5493 // Why was this commented out?
5494 GetRidOfVirtualArea();
5500 dirtyArea.Free(null);
5501 dirtyBack.Free(null);
5502 scrollExtent.Free(null);
5504 /* ATTEMPTING TO MOVE THAT ABOVE
5513 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5514 for(;(child = window.children.first);)
5516 for(; child && (child.destroyed || !child.created); child = child.next);
5525 UnloadGraphics(true);
5528 delete previousActive;
5531 // statusBar = null;
5534 if(master && !master.destroyed)
5536 //master.NotifyDestroyed(this, this.returnCode);
5537 NotifyDestroyed(master, this, this.returnCode);
5540 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5542 nextTimer = timer.next;
5543 if(timer.window == this)
5545 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5546 // timer.window = null;
5552 if(this == guiApp.windowMoving)
5555 if(guiApp.windowCaptured == this)
5557 //guiApp.windowCaptured = null;
5559 if(rootWindow != this && rootWindow)
5560 rootWindow.ConsequentialMouseMove(false);
5568 //for(child = children.first; next = child ? child.next : null, child; child = next)
5569 for(;(child = children.first); )
5571 for(; child && (child.destroyed || !child.created); child = child.next);
5581 /* // MOVED THIS UP...
5584 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5585 for(;(child = window.children.first); )
5587 for(; child && (child.destroyed || !child.created); child = child.next);
5596 while((slave = slaves.first))
5598 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5600 ((Window)slave.data).DestroyEx(0);
5605 if(guiApp.caretOwner == this)
5606 guiApp.caretOwner = null;
5608 sysButtons[0] = null;
5609 sysButtons[1] = null;
5610 sysButtons[2] = null;
5613 if(rootWindow != this)
5615 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5618 box.left -= parent.clientStart.x;
5619 box.top -= parent.clientStart.y;
5620 box.right -= parent.clientStart.x;
5621 box.bottom -= parent.clientStart.y;
5623 if(parent) parent.Update(box);
5628 OldLink slave = master.slaves.FindVoid(this);
5629 master.slaves.Delete(slave);
5635 parent.children.Remove(this);
5640 //autoCreate = false;
5643 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5644 if(((subclass(Window))_class).pureVTbl)
5646 if(_vTbl == _class._vTbl)
5648 _vTbl = ((subclass(Window))_class).pureVTbl;
5653 for(m = 0; m < _class.vTblSize; m++)
5655 if(_vTbl[m] == _class._vTbl[m])
5656 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5665 void SetStateEx(WindowState newState, bool activate)
5668 WindowState prevState = state;
5672 if(prevState != newState)
5673 lastState = prevState;
5675 if(rootWindow != this || !nativeDecorations || !windowHandle)
5677 if(style.isActiveClient && !style.hidden && prevState == minimized)
5680 // This block used to be at the end of the function... moved it for flicker problem in X
5681 // ------------------------------------------------------
5685 stateAnchor = normalAnchor;
5686 stateSizeAnchor = normalSizeAnchor;
5689 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5690 stateSizeAnchor = SizeAnchor {};
5694 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5697 byte * idBuffer = new0 byte[size];
5699 for(child = parent.children.first; child; child = child.next)
5701 if(child != this && child.state == minimized)
5703 if(child.iconID > size - 2)
5705 idBuffer = renew0 idBuffer byte[size*2];
5706 memset(idBuffer + size, 0, size);
5709 idBuffer[child.iconID] = (byte)bool::true;
5712 for(c = 0; c<size; c++)
5717 if(style.isActiveClient && !style.hidden)
5720 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5721 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5725 // TOCHECK: Why was this here?
5726 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5727 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5728 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5730 Position(x, y, w, h, true, true, true, true, false, true);
5732 if(!style.inactive && !style.interim && this == parent.activeClient)
5733 parent.UpdateActiveDocument(null);
5736 CreateSystemChildren();
5737 // ------------------------------------------------------
5740 int GetPositionID(Window forChild)
5744 byte * idBuffer = new0 byte[size];
5747 for(child = children.first; child; child = child.next)
5749 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5751 if(child.positionID > size - 2)
5753 idBuffer = renew0 idBuffer byte[size*2];
5754 memset(idBuffer + size, 0, size);
5757 idBuffer[child.positionID] = (byte)bool::true;
5760 for(c = 0; c<size; c++)
5767 // --- Window related graphics ---
5769 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5771 palette = newPalette;
5772 if(rootWindow.display)
5773 rootWindow.display.SetPalette(palette, colorMatch);
5776 public bool AcquireInput(bool acquired)
5779 if(acquiredInput != acquired)
5781 if(active || (!visible && creationActivation == activate))
5782 result = AcquireInputEx(acquired);
5787 acquiredInput = acquired ? result : !result;
5792 void ListChildren(ListBox listBox)
5796 for(child = children.first; child; child = child.next)
5798 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5800 DataRow row = listBox.AddRow();
5801 row.tag = (int64)child;
5802 child.FigureCaption(caption);
5803 row.SetData(null, caption);
5808 void UpdateVisual(Box extent)
5810 if(guiApp.driver != null)
5812 if(guiApp.fullScreenMode && guiApp.desktop.display)
5814 guiApp.desktop.mutex.Wait();
5815 guiApp.desktop.display.Lock(true);
5818 if(guiApp.desktop.active)
5820 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5822 if(guiApp.desktop.display.flags.flipping)
5823 guiApp.desktop.Update(null);
5824 guiApp.desktop.UpdateDisplay();
5825 guiApp.cursorUpdate = true;
5827 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5829 guiApp.PreserveAndDrawCursor();
5830 // guiApp.desktop.display.ShowScreen();
5831 guiApp.cursorUpdate = false;
5832 guiApp.desktop.dirty = false;
5833 guiApp.RestoreCursorBackground();
5837 guiApp.desktop.display.Unlock();
5838 guiApp.desktop.mutex.Release();
5842 Window rootWindow = this.rootWindow;
5843 rootWindow.mutex.Wait();
5848 guiApp.SignalEvent();
5851 guiApp.waitMutex.Wait();
5852 guiApp.interfaceDriver.Lock(rootWindow);
5853 if(!rootWindow.style.hidden && rootWindow.dirty)
5855 if(rootWindow.display)
5857 rootWindow.UpdateDisplay();
5858 //rootWindow.display.ShowScreen(null);
5860 rootWindow.dirty = false;
5862 guiApp.interfaceDriver.Unlock(rootWindow);
5863 guiApp.waitMutex.Release();
5866 rootWindow.mutex.Release();
5871 void UnlockDisplay(void)
5873 guiApp.interfaceDriver.Unlock(rootWindow);
5876 void LockDisplay(void)
5878 guiApp.interfaceDriver.Lock(rootWindow);
5881 Surface GetSurface(Box box)
5883 return Redraw((box == null) ? this.box : box);
5886 void SetMousePosition(int x, int y)
5888 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5892 void IntegrationActivate(bool active)
5894 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5896 isForegroundWindow = true;
5897 ActivateEx(active, active, false, false, null, null);
5898 isForegroundWindow = false;
5903 Window QueryCapture(void)
5905 return guiApp.windowCaptured;
5908 int GetDocumentID(void)
5912 byte * idBuffer = new0 byte[size];
5915 for(child = children.first; child; child = child.next)
5917 // TO CHECK: Do we want a documentID when we already have a file name?
5918 if(child.style.isDocument && !child.fileName)
5920 if(child.documentID-1 > size - 2)
5922 idBuffer = renew0 idBuffer byte[size*2];
5923 memset(idBuffer + size, 0, size);
5926 idBuffer[child.documentID-1] = 1;
5929 for(c = 0; c<size; c++)
5937 void SetInitSize(Size size)
5940 sizeAnchor.size = size;
5941 normalSizeAnchor = sizeAnchor;
5943 // Break the anchors for moveable/resizable windows
5944 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5946 stateAnchor = normalAnchor;
5947 stateSizeAnchor = normalSizeAnchor;
5949 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5950 Position(x,y, w, h, true, true, true, true, false, true);
5954 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5956 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5958 guiApp.windowIsResizing = resize;
5959 guiApp.windowMoving = this;
5960 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5961 if(guiApp.windowIsResizing)
5963 guiApp.windowMovingStart.x += size.w - 1;
5964 guiApp.windowMovingStart.y += size.h - 1;
5966 guiApp.windowMovingBefore = scrolledPos;
5967 guiApp.windowResizingBefore = size;
5968 guiApp.windowMoving.UpdateDecorations();
5969 if(guiApp.windowIsResizing)
5970 guiApp.resizeEndX = guiApp.resizeEndY = true;
5972 if(setCursorPosition)
5973 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5977 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5978 guiApp.windowMovingStart.x += x - absPosition.x;
5979 guiApp.windowMovingStart.y += y - absPosition.y;
5982 if(guiApp.windowMoving)
5984 if(guiApp.windowMoving.style.nonClient)
5985 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5987 guiApp.windowMoving.parent.SetMouseRangeToClient();
5992 if(this == rootWindow)
5993 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
6001 bool result = false;
6005 else if(guiApp && guiApp.driver != null)
6007 void * systemParent = null;
6008 OldLink slaveHolder;
6010 bool visible = !style.hidden;
6014 systemParent = parent;
6015 parent = guiApp.desktop;
6017 last = parent ? parent.children.last : null;
6019 if((parent && parent != guiApp.desktop && !parent.created) ||
6020 (master && master != guiApp.desktop && !master.created))
6024 stopwatching(parent, font);
6027 property::parent = guiApp.desktop;
6028 if(!master) master = parent;
6030 if(_isModal && master.modalSlave)
6031 property::master = master.modalSlave;
6035 parent.children.Remove(this);
6038 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
6039 if(slaveHolder.data == this)
6041 master.slaves.Delete(slaveHolder);
6046 if(parent == guiApp.desktop && !mutex)
6049 if(style.isDocument)
6052 parent.numDocuments--;
6053 documentID = parent.GetDocumentID();
6056 if(!style.stayOnTop)
6057 for(; last && last.style.stayOnTop; last = last.prev);
6059 parent.children.Insert((last == this) ? null : last, this);
6060 //parent.children.Add(this);
6063 dispDriver = parent.dispDriver;
6066 master.modalSlave = this;
6068 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
6073 master.slaves.Add(slaveHolder = OldLink { data = this });
6078 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
6080 if(style.isDefault && !master.defaultControl)
6081 master.defaultControl = this;
6083 stateAnchor = normalAnchor = anchor;
6084 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
6086 // TOCHECK: Why is this here?
6087 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
6088 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
6090 this.visible = false;
6091 style.hidden = true;
6094 // autoCreate = true;
6102 if(parent == guiApp.desktop)
6103 Log("LoadGraphics %s\n", caption);
6105 if(LoadGraphics(true, false))
6113 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6120 if(style.hasMenuBar /*&& menu*/)
6126 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6127 interim = false, inactive = true, nonClient = true, size.h = 24
6135 // Create the system buttons
6136 CreateSystemChildren();
6138 UpdateActiveDocument(null);
6140 if(style.isDocument)
6144 MenuItem item = menu.FindItem(MenuFileSave, 0);
6145 if(item) item.disabled = !modifiedDocument && fileName;
6150 if(parent == guiApp.desktop)
6151 Log("Preemptive SetState %s\n", caption);
6154 // Preemptive Set State to ensure proper anchoring
6155 SetStateEx(state, false);
6157 style.hidden = true;
6163 for(child = children.first; child; child = next)
6166 if(!child.created && (child.autoCreate || child.wasCreated))
6173 for(link = slaves.first; link; link = next)
6175 Window slave = link.data;
6177 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6180 // Things might have happened that invalidated 'next'...
6181 // Start over the search for slaves to create.
6182 // (Added this to fix crash with Stacker & Toolbar)
6183 next = slaves.first;
6192 if(parent == guiApp.desktop)
6193 Log("Real SetState %s\n", caption);
6196 if(isActiveClient && visible)
6198 parent.numPositions--;
6199 if(state == minimized) parent.numIcons--;
6202 parent.OnChildAddedOrRemoved(this, false);
6204 // Real set state & activate for proper display & activation
6205 property::visible = visible;
6206 // SetState(state & 0x00000003, true, 0);
6207 guiApp.interfaceDriver.SetIcon(this, icon);
6212 /*if(rootWindow == this)
6213 guiApp.interfaceDriver.ActivateRootWindow(this);
6215 if(creationActivation == activate)
6216 ActivateEx(true, false, true, true, null, null);
6217 else if(creationActivation == flash)
6222 rootWindow.ConsequentialMouseMove(false);
6233 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6239 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6241 //style.hidden = true; // !visible;
6242 style.hidden = !visible;
6243 if(master.modalSlave == this)
6244 master.modalSlave = null;
6251 void WriteCaption(Surface surface, int x, int y)
6254 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6257 void Update(Box region)
6263 rootWindow = this.rootWindow;
6265 // rootWindow.mutex.Wait();
6266 if(!destroyed && visible && display)
6271 // Testing this to avoid repetitve full update to take time...
6272 if(dirtyArea.count == 1)
6274 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6275 if(item.box.left <= box.left &&
6276 item.box.top <= box.top &&
6277 item.box.right >= box.right &&
6278 item.box.bottom >= box.bottom)
6280 rootWindow.dirty = true;
6285 if(display.flags.flipping && !rootWindow.dirty)
6287 if(this == rootWindow)
6291 rootWindow.Update(null);
6296 rootWindow.dirty = true;
6301 realBox.left += clientStart.x;
6302 realBox.top += clientStart.y;
6303 realBox.right += clientStart.x;
6304 realBox.bottom += clientStart.y;
6310 if(realBox.right >= realBox.left &&
6311 realBox.bottom >= realBox.top)
6313 // if(!rootWindow.fullRender)
6314 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6316 for(child = children.first; child; child = child.next)
6321 box.left -= child.absPosition.x - absPosition.x;
6322 box.top -= child.absPosition.y - absPosition.y;
6323 box.right -= child.absPosition.x - absPosition.x;
6324 box.bottom -= child.absPosition.y - absPosition.y;
6325 if(box.right >= child.box.left && box.left <= child.box.right &&
6326 box.bottom >= child.box.top && box.top <= child.box.bottom)
6328 box.left -= child.clientStart.x;
6329 box.top -= child.clientStart.y;
6330 box.right -= child.clientStart.x;
6331 box.bottom -= child.clientStart.y;
6337 realBox.left += absPosition.x - rootWindow.absPosition.x;
6338 realBox.top += absPosition.y - rootWindow.absPosition.y;
6339 realBox.right += absPosition.x - rootWindow.absPosition.x;
6340 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6341 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6344 else if(this == guiApp.desktop)
6347 for(window = children.first; window; window = window.next)
6353 Box childBox = region;
6355 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6356 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6357 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6358 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6360 window.Update(childBox);
6363 window.Update(null);
6368 // rootWindow.mutex.Release();
6375 if(guiApp.windowCaptured != this)
6377 if(guiApp.windowCaptured)
6381 //Logf("Captured %s (%s)\n", caption, class.name);
6382 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6383 guiApp.windowCaptured = this;
6389 bool Destroy(int64 code)
6394 if(!destroyed && !CloseConfirmation(false)) return false;
6398 // TOCHECK: Should autoCreate be set to false here?
6409 void Move(int x, int y, int w, int h)
6411 normalAnchor = Anchor { left = x, top = y };
6412 normalSizeAnchor = SizeAnchor { size = { w, h } };
6414 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6416 if(destroyed) return;
6418 stateAnchor = normalAnchor;
6419 stateSizeAnchor = normalSizeAnchor;
6421 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6422 Position(x,y, w, h, true, true, true, true, false, true);
6426 DialogResult Modal(void)
6432 // FIXES MEMORY LEAK IF Create() FAILED
6438 void SetScrollArea(int width, int height, bool snapToStep)
6440 bool resize = false;
6443 int stepX = sbStep.x, stepY = sbStep.y;
6444 // Needed to make snapped down position match the skin's check of client area
6445 // against realvirtual
6448 SNAPDOWN(stepX, textCellW);
6449 SNAPDOWN(stepY, textCellH);
6450 stepX = Max(stepX, textCellW);
6451 stepY = Max(stepY, textCellH);
6453 if(scrollFlags.snapX)
6454 SNAPUP(width, stepX);
6455 if(scrollFlags.snapY)
6456 SNAPUP(height, stepY);
6459 reqScrollArea.w = width;
6460 reqScrollArea.h = height;
6461 noAutoScrollArea = (width > 0 || height > 0);
6463 UpdateScrollBars(true, true);
6466 void SetScrollPosition(int x, int y)
6469 sbh.Action(setPosition, x, 0);
6473 int seen = clientSize.w, total = reqScrollArea.w;
6475 if(scrollFlags.snapX)
6476 SNAPDOWN(seen, sbStep.x);
6478 if(!total) total = seen;
6479 range = total - seen + 1;
6480 range = Max(range, 1);
6482 if(x >= range) x = range - 1;
6484 if(scrollFlags.snapX)
6485 SNAPUP(x, sbStep.x);
6488 OnHScroll(setPosition, x, 0);
6492 SNAPDOWN(x, textCellW);
6498 sbv.Action(setPosition, y, 0);
6502 int seen = clientSize.h, total = reqScrollArea.h;
6505 if(scrollFlags.snapY)
6506 SNAPDOWN(seen, sbStep.y);
6508 if(!total) total = seen;
6509 range = total - seen + 1;
6510 range = Max(range, 1);
6512 if(y >= range) y = range - 1;
6514 if(scrollFlags.snapY)
6515 SNAPUP(y, sbStep.y);
6518 OnVScroll(setPosition, y, 0);
6521 SNAPDOWN(y, textCellH);
6526 UpdateCaret(false, false);
6529 void SetScrollLineStep(int stepX, int stepY)
6535 SNAPDOWN(stepX, textCellW);
6536 SNAPDOWN(stepY, textCellH);
6537 stepX = Max(stepX, textCellW);
6538 stepY = Max(stepY, textCellH);
6541 sbh.lineStep = stepX;
6543 sbv.lineStep = stepY;
6546 void SetState(WindowState newState, bool activate, Modifiers mods)
6550 if(state == newState || OnStateChange(newState, mods))
6552 WindowState prevState = state;
6556 // This used to be at the end of the brackets... moved for X, testing...
6557 // This has the effect of activating the window through the system...
6558 if(rootWindow == this)
6559 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6561 SetStateEx(newState, activate);
6563 if(rootWindow == this && !rootWindow.nativeDecorations)
6565 int x = position.x, y = position.y;
6568 x -= guiApp.desktop.absPosition.x;
6569 y -= guiApp.desktop.absPosition.y;
6571 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6575 //state = prevState;
6577 if(state != maximized && style.hasMaximize)
6580 for(child = parent.children.first; child; child = child.next)
6582 if(child != this && child.state == maximized)
6583 child.SetStateEx(normal, false);
6587 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6588 parent.UpdateScrollBars(true, true);
6591 // Do we really need this stuff here?
6592 // Shouldn't the Activate stuff take care of it?
6593 if(parent.rootWindow == parent && style)
6596 parent.FigureCaption(caption);
6597 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6598 parent.UpdateDecorations();
6602 rootWindow.ConsequentialMouseMove(false);
6609 BitmapResource GetIcon(SkinBitmap iconID)
6611 return guiApp.currentSkin.GetBitmap(iconID);
6614 void SetMouseRange(Box range)
6616 if(range || guiApp.fullScreenMode)
6621 clip.left = range.left + absPosition.x + clientStart.x;
6622 clip.top = range.top + absPosition.y + clientStart.y;
6623 clip.right = range.right + absPosition.x + clientStart.x;
6624 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6628 clip.left = guiApp.desktop.box.left;
6629 clip.top = guiApp.desktop.box.top;
6630 clip.right = guiApp.desktop.box.right;
6631 clip.bottom = guiApp.desktop.box.bottom;
6633 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6636 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6639 void SetMouseRangeToClient(void)
6641 if(guiApp.fullScreenMode || this != guiApp.desktop)
6643 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6644 box.Clip(clientArea);
6648 SetMouseRange(null);
6651 void SetMouseRangeToWindow(void)
6653 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6654 if(this == guiApp.desktop)
6655 SetMouseRangeToClient();
6660 // x, y: Desktop Coordinates
6661 void ShowSysMenu(int x, int y)
6664 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6667 menu, $"Restore", r, NotifySelect = MenuWindowRestore,
6668 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6672 menu, $"Move", m, NotifySelect = MenuWindowMove,
6673 disabled = !style.fixed || state == maximized
6677 menu, $"Size", s, NotifySelect = MenuWindowSize,
6678 disabled = !style.sizable || state != normal
6682 menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
6683 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6687 menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6688 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6692 menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6693 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6695 MenuDivider { menu };
6698 menu, $"Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6699 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6701 windowMenu.Create();
6706 ActivateEx(true, true, true, true, null, null);
6709 void MakeActive(void)
6711 ActivateEx(true, false, true, false, null, null);
6714 void SoftActivate(void)
6716 if(guiApp.desktop.active)
6722 void Deactivate(void)
6724 ActivateEx(false, true, true, true, null, null);
6729 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6732 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6734 bool result = false;
6735 if(activeChild && activeChild.cycle)
6737 Window modalWindow, child = activeChild;
6738 if(!clientOnly /*&& parent.tabCycle*/)
6740 Window next = child;
6743 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6747 if(parent && parent.CycleChildren(backward, false, true, true))
6755 next = next.cycle.prev.data;
6757 next = next.cycle.next.data;
6758 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6763 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6764 parent.tabCycle && parent.CycleChildren(backward, false, false))
6768 if(tabCycleOnly && !tabCycle) return false;
6775 child = child.cycle.prev.data;
6777 child = child.cycle.next.data;
6778 if(child == child.parent.activeChild)
6780 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6783 modalWindow = child.FindModal();
6786 // Scroll the window to include the active control
6787 if(sbh && !child.style.dontScrollHorz)
6789 if(child.scrolledPos.x < 0)
6790 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6791 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6792 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6794 if(sbv && !child.style.dontScrollVert)
6796 if(child.scrolledPos.y < 0)
6797 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6798 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6799 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6803 child = modalWindow ? modalWindow : child;
6804 child.ActivateEx(true, true, true, true, null, null);
6805 if(child.tabCycle && child.childrenCycle.first)
6806 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6814 ConsequentialMouseMove(false);
6818 void AddResource(Resource resource)
6822 ResPtr ptr { resource = resource };
6826 // Load Graphics here if window is created already
6827 if(/*created && */display)
6829 display.Lock(false);
6830 ptr.loaded = display.displaySystem.LoadResource(resource);
6834 // Temporary hack to load font right away for listbox in dropbox ...
6835 else if(master && master.display)
6837 master.display.Lock(false);
6838 master.display.displaySystem.LoadResource(resource);
6839 master.display.Unlock();
6845 void RemoveResource(Resource resource)
6850 for(ptr = resources.first; ptr; ptr = ptr.next)
6852 if(ptr.resource == resource)
6858 // Unload Graphics here if window is created already
6859 if(/*created && */display)
6863 display.Lock(false);
6864 display.displaySystem.UnloadResource(resource, ptr.loaded);
6870 resources.Delete(ptr);
6875 void SetCaret(int x, int y, int size)
6882 if(active && !style.interim)
6884 if(visible || !guiApp.caretOwner)
6885 guiApp.caretOwner = size ? this : null;
6887 UpdateCaret(false, false);
6890 guiApp.interfaceDriver.SetCaret(0,0,0);
6891 UpdateCaret(false, true);
6892 guiApp.caretEnabled = false;
6895 else if(style.inactive && active)
6897 guiApp.interfaceDriver.SetCaret(0,0,0);
6898 UpdateCaret(false, true);
6899 guiApp.caretEnabled = false;
6904 void Scroll(int x, int y)
6906 bool opaque = !style.drawBehind || background.a;
6907 if(opaque && display && display.flags.scrolling)
6909 Box box = clientArea;
6910 box.left += clientStart.x;
6911 box.top += clientStart.y;
6912 box.right += clientStart.x;
6913 box.bottom += clientStart.y;
6915 //scrollExtent.Free(null);
6916 scrollExtent.AddBox(box);
6917 scrolledArea.x += x;
6918 scrolledArea.y += y;
6920 //scrollExtent.Free();
6921 //scrollExtent.AddBox(clientArea);
6922 //scrollExtent.Offset(clientStart.x, clientStart.y);
6923 //scrolledArea.x = x;
6924 //scrolledArea.y = y;
6930 rootWindow.dirty = true;
6933 void ReleaseCapture()
6935 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6937 Window oldCaptured = guiApp.windowCaptured;
6938 guiApp.windowCaptured = null;
6939 guiApp.prevWindow = null;
6942 //guiApp.Log("Released Capture\n");
6944 guiApp.interfaceDriver.SetMouseCapture(null);
6946 //oldCaptured.OnMouseCaptureLost();
6949 oldCaptured.ConsequentialMouseMove(false);
6954 void SetText(char * format, ...)
6961 char caption[MAX_F_STRING];
6963 va_start(args, format);
6964 vsnprintf(caption, sizeof(caption), format, args);
6965 caption[sizeof(caption)-1] = 0;
6968 this.caption = CopyString(caption);
6977 bool Grab(Bitmap bitmap, Box box, bool decorations)
6979 bool result = false;
6980 if(display || this == guiApp.desktop)
6982 Box clip = {MININT, MININT, MAXINT, MAXINT};
6988 clip.Clip(clientArea);
6990 clip.Clip(this.box);
6992 if(rootWindow != this)
6994 clip.left += absPosition.y;
6995 clip.top += absPosition.y;
6996 clip.right += absPosition.x;
6997 clip.bottom += absPosition.y;
7000 clip.left += decorations ? 0 : clientStart.x;
7001 clip.top += decorations ? 0 : clientStart.y;
7002 clip.right += decorations ? 0 : clientStart.x;
7003 clip.bottom += decorations ? 0 : clientStart.y;
7005 if(display && display.flags.flipping)
7007 rootWindow.Update(null);
7008 rootWindow.UpdateDisplay();
7015 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
7016 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7020 result = display.Grab(bitmap, clip.left, clip.top,
7021 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
7023 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
7025 if(!bitmap.Convert(null, pixelFormat888, null))
7032 void GetMousePosition(int * x, int * y)
7034 int mouseX = 0, mouseY = 0;
7035 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
7038 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
7039 if(this != guiApp.desktop)
7041 mouseX -= absPosition.x + clientStart.x;
7042 mouseY -= absPosition.y + clientStart.y;
7049 DialogResult DoModal()
7051 DialogResult returnCode = 0;
7052 int terminated = terminateX;
7055 while(!destroyed && guiApp.driver != null)
7057 if(terminateX != terminated)
7059 terminated = terminateX;
7060 guiApp.desktop.Destroy(0);
7061 if(guiApp.desktop.created)
7064 //printf("Resetting terminate X to 0\n");
7070 guiApp.UpdateDisplay();
7071 if(!guiApp.ProcessInput(false))
7074 returnCode = this.returnCode;
7087 return !destroyed && guiApp.driver != null && terminateX < 2;
7090 DialogResult DoModalEnd()
7092 DialogResult returnCode = this.returnCode;
7097 // --- Window manipulation ---
7098 /*bool GetDisabled()
7100 bool disabled = this.disabled;
7102 for(window = this; (window = window.master); )
7113 // --- Mouse Manipulation ---
7114 void GetNCMousePosition(int * x, int * y)
7116 GetMousePosition(x, y);
7117 if(x) *x += clientStart.x;
7118 if(y) *y += clientStart.y;
7121 // --- Carets manipulation ---
7122 void GetCaretPosition(Point caretPos)
7124 caretPos = this.caretPos;
7127 int GetCaretSize(void)
7132 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7138 bool CloseConfirmation(bool parentClosing)
7151 if(!OnClose(parentClosing))
7154 // If you want to skip this, simply set modifiedDocument to false in OnClose
7155 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7157 DialogResult dialogRes;
7160 sprintf(message, $"Save changes to %s?", fileName);
7162 sprintf(message, $"Save changes to Untitled %d?", documentID);
7164 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption ? parent.caption : rootWindow.caption, contents = message }.Modal();
7166 if(dialogRes == yes)
7168 // TOFIX: Precomp error if brackets are taken out
7169 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7171 else if(dialogRes == cancel)
7177 for(slave = slaves.first; slave; slave = slave.next)
7179 Window w = slave.data;
7180 if((w.parent == this || !w.IsDescendantOf(this)) && !w.CloseConfirmation(true))
7182 // ((Window)slave.data).CloseConfirmation(true);
7191 for(child = children.first; child; child = child.next)
7192 if(child.master != this && !child.CloseConfirmation(true))
7202 // Static methods... move them somewhere else?
7203 void ::RestoreCaret()
7205 if(guiApp.caretOwner)
7206 guiApp.caretOwner.UpdateCaret(false, false);
7209 void ::FreeMouseRange()
7211 guiApp.interfaceDriver.SetMouseRange(null, null);
7215 bool MenuFileClose(MenuItem selection, Modifiers mods)
7217 Window document = activeChild;
7219 document.Destroy(0);
7223 bool MenuFileExit(MenuItem selection, Modifiers mods)
7229 bool MenuFileSave(MenuItem selection, Modifiers mods)
7233 fileMonitor.fileName = null;
7236 if(OnSaveFile(fileName))
7238 //if(OnFileModified != Window::OnFileModified)
7241 fileMonitor.fileName = fileName;
7247 MessageBox dialog { master = master, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7248 DialogResult answer = dialog.Modal();
7250 if(answer != yes) return (bool)answer;
7253 return MenuFileSaveAs(selection, mods);
7256 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7258 DialogResult result = (DialogResult)bool::true;
7259 FileDialog fileDialog = saveDialog;
7262 fileDialog = FileDialog {};
7267 fileDialog.filePath = fileName;
7270 char filePath[MAX_FILENAME];
7271 sprintf(filePath, "Untitled %d", documentID);
7272 fileDialog.filePath = filePath;
7274 fileMonitor.fileName = null;
7276 fileDialog.type = save;
7277 fileDialog.text = $"Save As";
7281 fileDialog.master = master.parent ? master : this;
7282 if(fileDialog.Modal() == ok)
7284 char * filePath = fileDialog.filePath;
7286 if(OnSaveFile(filePath))
7289 property::fileName = filePath;
7290 NotifySaved(master, this, filePath);
7295 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
7296 DialogResult answer = dialog.Modal();
7311 //if(OnFileModified != Window::OnFileModified && fileName)
7314 fileMonitor.fileName = fileName;
7318 return (bool)result; // Actually returning result from Yes/NoCancel message box
7321 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7323 Window document = activeChild;
7325 for(document = children.first; document; document = next)
7327 next = document.next;
7328 if(document.style.isDocument || document.fileName)
7329 document.MenuFileSave(selection, mods);
7334 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7338 for(document = children.first; document; document = document.next)
7339 //if(document.style.isDocument && document.state == minimized)
7340 if(document.style.isActiveClient && document.state == minimized)
7341 document.SetState(minimized, false, mods);
7345 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7347 Window document = activeChild;
7350 Window firstDocument = null;
7352 OldLink cycle = document.cycle.prev;
7357 if(child.style.isActiveClient && !child.style.hidden)
7361 firstDocument = child;
7362 if(child.state == minimized)
7363 child.SetState(minimized, false, mods);
7366 child.positionID = id++;
7367 child.SetState(normal, false, mods);
7368 child.anchor.left.type = cascade;
7371 child.normalSizeAnchor = *&child.sizeAnchor;
7372 child.normalAnchor = child.anchor;
7374 // Break the anchors for moveable/resizable windows
7375 if(child.style.fixed)
7377 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7379 (*&child.normalAnchor).left = x;
7380 (*&child.normalAnchor).top = y;
7381 (*&child.normalAnchor).right.type = none;
7382 (*&child.normalAnchor).bottom.type = none;
7384 child.normalSizeAnchor.isClientW = false;
7385 child.normalSizeAnchor.isClientH = false;
7386 child.normalSizeAnchor.size.w = w;
7387 child.normalSizeAnchor.size.h = h;
7388 child.anchored = false;
7391 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7393 child.stateAnchor = child.normalAnchor;
7394 child.stateSizeAnchor = child.normalSizeAnchor;
7396 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7397 child.Position(x, y, w, h, true, true, true, true, false, false);
7402 last = children.last;
7403 if(!child.style.stayOnTop)
7404 for(; last && last.style.stayOnTop; last = last.prev);
7405 children.Move(child, last);
7406 childrenOrder.Move(child.order, childrenOrder.last);
7408 if(cycle == document.cycle) break;
7412 firstDocument.Activate();
7417 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7424 // Close all closes all active clients, not all documents
7425 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7427 Window next, document;
7429 for(document = children.first; document; document = next)
7431 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7432 if(document.style.isActiveClient)
7433 if(!document.Destroy(0) && !document.style.hidden)
7439 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7441 if(style.hasMaximize && state != maximized)
7442 SetState(maximized, 0, 0);
7446 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7448 if(style.hasMinimize && state != minimized)
7450 SetState(minimized, 0, 0);
7451 parent.CycleChildren(false, true, false, true);
7456 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7458 MenuMoveOrSize(false, selection ? true : false);
7462 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7464 CycleChildren(false, true, false, true);
7468 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7470 CycleChildren(true, true, false, true);
7474 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7476 MenuMoveOrSize(true, true);
7480 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7483 SetState(normal, 0, 0);
7487 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7490 int64 id = selection.id;
7491 OldLink cycle = activeClient.cycle;
7493 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7496 Window sibling = cycle.data;
7497 if(sibling.style.isActiveClient && sibling.visible && !sibling.style.nonClient)
7505 document = cycle.data;
7506 document.Activate();
7508 //if(activeChild.state == maximized)
7509 // document.SetState(maximized, false, mods);
7510 //else if(document.state == minimized)
7511 // document.SetState(normal, false, mods);
7515 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7517 stayOnTop = !style.stayOnTop;
7521 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7523 Window document = activeChild;
7526 Window firstDocument = null;
7527 OldLink cycle = document.cycle;
7531 Window child = cycle.data;
7532 if(child.style.isActiveClient && !child.style.hidden)
7534 if(!firstDocument) firstDocument = child;
7535 if(child.state == minimized)
7536 child.SetState(minimized, false, mods);
7539 child.positionID = id++;
7540 child.SetState(normal, false, mods);
7541 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7543 child.anchor.left.type = hTiled;
7546 child.normalSizeAnchor = *&child.sizeAnchor;
7547 child.normalAnchor = child.anchor;
7549 // Break the anchors for moveable/resizable windows
7550 if(child.style.fixed)
7552 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7554 (*&child.normalAnchor).left = x;
7555 (*&child.normalAnchor).top = y;
7556 (*&child.normalAnchor).right.type = none;
7557 (*&child.normalAnchor).bottom.type = none;
7558 child.normalSizeAnchor.isClientW = false;
7559 child.normalSizeAnchor.isClientH = false;
7560 child.normalSizeAnchor.size.w = w;
7561 child.normalSizeAnchor.size.h = h;
7562 child.anchored = false;
7565 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7567 child.stateAnchor = child.normalAnchor;
7568 child.stateSizeAnchor = child.normalSizeAnchor;
7570 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7571 child.Position(x,y, w, h, true, true, true, true, false, true);
7576 if((cycle = cycle.next) == document.cycle) break;
7579 firstDocument.Activate();
7584 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7586 Window document = activeChild;
7589 Window firstDocument = null;
7591 OldLink cycle = document.cycle;
7596 //if(child.style.isDocument)
7597 if(child.style.isActiveClient && !child.style.hidden)
7599 if(!firstDocument) firstDocument = child;
7600 if(child.state == minimized)
7601 child.SetState(minimized, false, mods);
7604 child.positionID = id++;
7605 child.SetState(normal, false, mods);
7606 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7608 child.anchor.left.type = vTiled;
7611 child.normalSizeAnchor = *&child.sizeAnchor;
7612 child.normalAnchor = child.anchor;
7614 // Break the anchors for moveable/resizable windows
7615 if(child.style.fixed)
7617 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7619 (*&child.normalAnchor).left = x;
7620 (*&child.normalAnchor).top = y;
7621 (*&child.normalAnchor).right.type = none;
7622 (*&child.normalAnchor).bottom.type = none;
7623 child.normalSizeAnchor.isClientW = false;
7624 child.normalSizeAnchor.isClientH = false;
7625 child.normalSizeAnchor.size.w = w;
7626 child.normalSizeAnchor.size.h = h;
7627 child.anchored = false;
7630 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7632 child.stateAnchor = child.normalAnchor;
7633 child.stateSizeAnchor = child.normalSizeAnchor;
7635 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7636 child.Position(x,y, w, h, true, true, true, true, false, true);
7641 if((cycle = cycle.next) == document.cycle) break;
7644 firstDocument.Activate();
7649 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7651 WindowList dialog { master = this };
7652 Window document = (Window)dialog.Modal();
7655 if(activeChild.state == maximized)
7656 document.SetState(maximized, false, mods);
7657 else if(document.state == minimized)
7658 document.SetState(normal, false, mods);
7659 document.Activate();
7665 virtual bool OnCreate(void);
7666 virtual void OnDestroy(void);
7667 virtual void OnDestroyed(void);
7668 virtual bool OnClose(bool parentClosing);
7669 virtual bool OnStateChange(WindowState state, Modifiers mods);
7670 virtual bool OnPostCreate(void);
7671 virtual bool OnMoving(int *x, int *y, int w, int h);
7672 virtual bool OnResizing(int *width, int *height);
7673 virtual void OnResize(int width, int height);
7674 virtual void OnPosition(int x, int y, int width, int height);
7675 virtual bool OnLoadGraphics(void);
7676 virtual void OnApplyGraphics(void);
7677 virtual void OnUnloadGraphics(void);
7678 virtual void OnRedraw(Surface surface);
7679 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7680 virtual void OnActivateClient(Window client, Window previous);
7681 virtual bool OnKeyDown(Key key, unichar ch);
7682 virtual bool OnKeyUp(Key key, unichar ch);
7683 virtual bool OnKeyHit(Key key, unichar ch);
7684 virtual bool OnSysKeyDown(Key key, unichar ch);
7685 virtual bool OnSysKeyUp(Key key, unichar ch);
7686 virtual bool OnSysKeyHit(Key key, unichar ch);
7687 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7688 virtual bool OnMouseLeave(Modifiers mods);
7689 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7690 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7691 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7692 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7693 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7694 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7695 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7696 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7697 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7698 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7699 virtual void OnMouseCaptureLost(void);
7700 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7701 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7702 virtual void OnDrawOverChildren(Surface surface);
7703 virtual bool OnFileModified(FileChange fileChange, char * param);
7704 virtual bool OnSaveFile(char * fileName);
7706 // Virtual Methods -- Children management (To support Stacker, for lack of built-in auto-layout)
7707 // Note: A 'client' would refer to isActiveClient, rather than
7708 // being confined to the 'client area' (nonClient == false)
7709 virtual void OnChildAddedOrRemoved(Window child, bool removed);
7710 virtual void OnChildVisibilityToggled(Window child, bool visible);
7711 virtual void OnChildResized(Window child, int x, int y, int w, int h);
7713 // Skins Virtual Functions
7714 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7715 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7716 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7721 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7722 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7723 virtual bool IsMouseMoving(int x, int y, int w, int h)
7727 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY)
7731 virtual void UpdateNonClient();
7732 virtual void SetBox(Box box);
7733 virtual bool IsInside(int x, int y)
7735 return box.IsPointInside({x, y});
7737 virtual bool IsOpaque()
7739 return (!style.drawBehind || background.a == 255);
7743 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7744 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7745 virtual void Window::NotifySaved(Window window, char * filePath);
7750 property Window parent
7752 property_category $"Layout"
7755 if(value || guiApp.desktop)
7758 Window oldParent = parent;
7759 Anchor anchor = this.anchor;
7761 if(value && value.IsDescendantOf(this)) return;
7762 if(value && value == this)
7764 if(!value) value = guiApp.desktop;
7766 if(value == oldParent) return;
7768 if(!master || (master == this.parent && master == guiApp.desktop))
7769 property::master = value;
7773 parent.children.Remove(this);
7777 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7778 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7779 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7780 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7784 last = value.children.last;
7786 if(style.isDocument)
7789 parent.numDocuments--;
7790 documentID = value.GetDocumentID();
7793 if(style.isActiveClient && !style.hidden)
7795 if(parent && parent != guiApp.desktop && !(style.hidden))
7797 if(state == minimized) parent.numIcons--;
7798 parent.numPositions--;
7802 if(!style.stayOnTop)
7803 for(; last && last.style.stayOnTop; last = last.prev);
7805 value.children.Insert(last, this);
7807 // *** NEW HERE: ***
7809 parent.childrenCycle.Delete(cycle);
7811 parent.childrenOrder.Delete(order);
7814 // *** TODO: Added this here to solve crash on setting parent to null before destroying/destructing ***
7815 // Should something else be done?
7816 if(parent && parent.activeChild == this)
7817 parent.activeChild = null;
7818 if(parent && parent.activeClient == this)
7819 parent.activeClient = null;
7825 int x = position.x, y = position.y, w = size.w, h = size.h;
7829 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7830 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7832 vpw = value.clientSize.w;
7833 vph = value.clientSize.h;
7839 else if(style.fixed)
7841 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7842 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7845 anchor = this.anchor;
7847 if(anchor.left.type == offset) anchor.left.distance = x;
7848 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7849 if(anchor.top.type == offset) anchor.top.distance = y;
7850 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7851 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7852 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7853 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7854 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7855 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7856 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7858 if(!anchor.left.type && !anchor.right.type)
7860 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7861 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7863 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7864 if(!anchor.top.type && !anchor.bottom.type)
7866 anchor.vert.distance = (y + h / 2) - (vph / 2);
7867 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7869 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7872 parent.OnChildAddedOrRemoved(this, false);
7878 parent.childrenCycle.Insert(
7879 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7880 cycle = OldLink { data = this });
7881 parent.childrenOrder.Insert(
7882 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7883 order = OldLink { data = this });
7886 if(!style.hidden && style.isActiveClient)
7888 positionID = parent.GetPositionID(this);
7889 parent.numPositions++;
7890 if(state == minimized) parent.numIcons--;
7893 // *** FONT INHERITANCE ***
7894 if(!setFont && oldParent)
7895 stopwatching(oldParent, font);
7899 RemoveResource(systemFont);
7902 // TESTING WITH WATCHERS:
7903 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7904 // usedFont = setFont ? setFont : (systemFont);
7908 if(guiApp.currentSkin)
7910 systemFont = guiApp.currentSkin.SystemFont();
7913 usedFont = systemFont;
7914 AddResource(systemFont);
7922 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7931 if(value.rootWindow && value.rootWindow.display && rootWindow)
7933 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7934 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7937 UnloadGraphics(false);
7940 LoadGraphics(false, false);
7943 if(value.rootWindow != rootWindow)
7944 DisplayModeChanged();
7948 scrolledPos.x = MININT; // Prevent parent update
7950 bool anchored = this.anchored;
7951 property::anchor = anchor;
7952 this.anchored = anchored;
7957 if(guiApp.currentSkin)
7958 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7960 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7961 Position(x, y, w, h, true, true, true, true, false, true);
7966 // else parent = value;
7968 oldParent.OnChildAddedOrRemoved(this, true);
7971 get { return parent; }
7974 property Window master
7976 property_category $"Behavior"
7979 //if(this == value) return;
7980 if(value && value.IsSlaveOf(this)) return;
7986 OldLink slaveHolder;
7987 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7988 if(slaveHolder.data == this)
7990 master.slaves.Delete(slaveHolder);
7997 value.slaves.Add(OldLink { data = this });
8002 master.hotKeys.Remove(hotKey);
8003 value.hotKeys.Add(hotKey);
8006 if(master && master.defaultControl == this)
8007 master.defaultControl = null;
8009 if(style.isDefault && !value.defaultControl)
8010 value.defaultControl = this;
8015 get { return master ? master : parent; }
8018 property char * caption
8020 property_category $"Appearance"
8027 caption = new char[strlen(value)+1];
8029 strcpy(caption, value);
8034 get { return caption; }
8039 property_category $"Behavior"
8048 master.hotKeys.Add(hotKey = HotKeySlot { });
8052 hotKey.window = this;
8057 master.hotKeys.Delete(hotKey);
8062 get { return hotKey ? hotKey.key : 0; }
8065 property Color background
8067 property_category $"Appearance"
8070 background.color = value;
8075 if(this == rootWindow)
8076 guiApp.interfaceDriver.SetRootWindowColor(this);
8079 get { return background.color; }
8082 property Percentage opacity
8084 property_category $"Appearance"
8087 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
8088 drawBehind = (background.a == 255) ? false : true;
8090 get { return background.a / 255.0f; }
8093 property Color foreground
8095 property_category $"Appearance"
8103 get { return foreground; }
8106 property BorderStyle borderStyle
8108 property_category $"Appearance"
8111 if(!((BorderBits)value).fixed)
8113 style.hasClose = false;
8114 style.hasMaximize = false;
8115 style.hasMinimize = false;
8116 nativeDecorations = false;
8118 style.borderBits = value;
8122 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8124 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8125 Position(x, y, w, h, true, true, true, true, false, true);
8126 CreateSystemChildren();
8129 get { return (BorderStyle)style.borderBits; }
8132 property Size minClientSize
8134 property_category $"Layout"
8135 set { minSize = value; }
8136 get { value = minSize; }
8139 property Size maxClientSize
8141 property_category $"Layout"
8142 set { maxSize = value; }
8143 get { value = maxSize; }
8146 property bool hasMaximize
8148 property_category $"Window Style"
8151 style.hasMaximize = value;
8152 if(value) { style.fixed = true; style.contour = true; }
8156 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8158 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8159 Position(x, y, w, h, true, true, true, true, false, true);
8161 CreateSystemChildren();
8164 get { return style.hasMaximize; }
8167 property bool hasMinimize
8169 property_category $"Window Style"
8172 style.hasMinimize = value;
8173 if(value) { style.fixed = true; style.contour = true; }
8177 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8179 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8180 Position(x, y, w, h, true, true, true, true, false, true);
8182 CreateSystemChildren();
8185 get { return style.hasMinimize; }
8188 property bool hasClose
8190 property_category $"Window Style"
8193 style.hasClose = value;
8194 if(value) { style.fixed = true; style.contour = true; }
8198 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8199 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8200 Position(x, y, w, h, true, true, true, true, false, true);
8201 CreateSystemChildren();
8204 get { return style.hasClose; }
8207 property bool nonClient
8209 property_category $"Layout"
8212 style.nonClient = value;
8214 style.stayOnTop = true;
8216 get { return style.nonClient; }
8219 property bool inactive
8221 property_category $"Behavior"
8226 // *** NEW HERE: ***
8230 parent.childrenCycle.Delete(cycle);
8232 parent.childrenOrder.Delete(order);
8239 active = false; // true;
8240 if(parent.activeChild == this)
8241 parent.activeChild = null;
8242 if(parent.activeClient == this)
8243 parent.activeClient = null;
8252 parent.childrenCycle.Insert(
8253 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8254 cycle = OldLink { data = this });
8256 parent.childrenOrder.Insert(
8257 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8258 order = OldLink { data = this });
8261 style.inactive = value;
8263 get { return style.inactive; }
8266 property bool clickThrough
8268 property_category $"Behavior"
8269 set { style.clickThrough = value; }
8270 get { return style.clickThrough; }
8273 property bool isRemote
8275 property_category $"Behavior"
8276 set { style.isRemote = value; }
8277 get { return style.isRemote; }
8280 property bool noCycle
8282 property_category $"Behavior"
8283 set { style.noCycle = value; }
8284 get { return style.noCycle; }
8287 property bool isModal
8289 property_category $"Behavior"
8290 set { style.modal = value; }
8291 get { return style.modal; }
8294 property bool interim
8296 property_category $"Behavior"
8297 set { style.interim = value; }
8298 get { return style.interim; }
8301 property bool tabCycle
8303 property_category $"Behavior"
8304 set { style.tabCycle = value; }
8305 get { return style.tabCycle; }
8308 property bool isDefault
8310 property_category $"Behavior"
8318 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8319 if(sibling != this && sibling.style.isDefault)
8320 sibling.style.isDefault = false;*/
8321 if(master.defaultControl)
8322 master.defaultControl.style.isDefault = false;
8323 master.defaultControl = this;
8325 else if(master.defaultControl == this)
8326 master.defaultControl = null;
8330 style.isDefault = value;
8332 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8334 get { return style.isDefault; }
8337 property bool drawBehind
8339 property_category $"Window Style"
8340 set { style.drawBehind = value; }
8341 get { return style.drawBehind; }
8344 property bool hasMenuBar
8346 property_category $"Window Style"
8356 if(created && !menuBar)
8363 anchor = Anchor { top = 23, left = 1, right = 1 },
8365 inactive = true, nonClient = true
8370 else if(created && menuBar)
8375 style.hasMenuBar = value;
8377 get { return style.hasMenuBar; }
8380 property bool hasStatusBar
8382 property_category $"Window Style"
8389 statusBar = StatusBar { this };
8397 style.hasStatusBar = value;
8399 get { return style.hasStatusBar; }
8401 property bool stayOnTop
8403 property_category $"Window Style"
8408 if(created && !style.stayOnTop)
8410 if(rootWindow == this)
8411 guiApp.interfaceDriver.OrderRootWindow(this, true);
8412 else if(parent.children.last != this)
8414 parent.children.Move(this, parent.children.last);
8418 style.stayOnTop = true;
8422 if(created && style.stayOnTop)
8424 if(rootWindow == this)
8425 guiApp.interfaceDriver.OrderRootWindow(this, false);
8432 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8433 order && ((Window)order.data).style.stayOnTop;
8434 order = (order == parent.childrenOrder.first) ? null : order.prev);
8435 last = order ? order.data : null;
8439 for(last = parent.children.last;
8440 last && last.style.stayOnTop;
8444 parent.children.Move(this, last);
8448 style.stayOnTop = false;
8451 get { return style.stayOnTop; }
8456 property_category $"Window Style"
8466 if(menuBar && !value)
8473 if(!menuBar && style.hasMenuBar && value)
8477 this, menu = value, isMenuBar = true,
8478 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8479 inactive = true, nonClient = true
8483 UpdateActiveDocument(null);
8486 get { return menu; }
8489 property FontResource font
8491 property_category $"Appearance"
8493 isset { return setFont ? true : false; }
8498 if(value && !setFont) { stopwatching(parent, font); }
8499 else if(!value && setFont)
8505 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8514 RemoveResource(setFont);
8519 RemoveResource(systemFont);
8526 AddResource(setFont);
8529 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8532 systemFont = guiApp.currentSkin.SystemFont();
8534 usedFont = systemFont;
8535 AddResource(systemFont);
8543 get { return usedFont; }
8546 property SizeAnchor sizeAnchor
8548 property_category $"Layout"
8551 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8552 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8553 sizeAnchor.isClientW != sizeAnchor.isClientH;
8560 normalSizeAnchor = sizeAnchor;
8562 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8564 stateAnchor = normalAnchor;
8565 stateSizeAnchor = normalSizeAnchor;
8567 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8568 Position(x,y, w, h, true, true, true, true, false, true);
8575 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8576 sizeAnchor.isClientW,
8577 sizeAnchor.isClientH
8584 property_category $"Layout"
8587 Anchor thisAnchor = anchor;
8588 SizeAnchor thisSizeAnchor = sizeAnchor;
8589 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8590 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8591 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8592 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8593 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8594 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8600 sizeAnchor.isClientW = false;
8601 sizeAnchor.isClientH = false;
8602 sizeAnchor.size = value;
8604 normalSizeAnchor = sizeAnchor;
8606 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8608 stateAnchor = normalAnchor;
8609 stateSizeAnchor = normalSizeAnchor;
8611 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8612 Position(x, y, w, h, true, true, true, true, false, true);
8613 if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
8616 get { value = size; }
8619 property Size clientSize
8621 property_category $"Layout"
8624 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8625 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8626 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8631 sizeAnchor.isClientW = true;
8632 sizeAnchor.isClientH = true;
8633 sizeAnchor.size = value;
8635 normalSizeAnchor = sizeAnchor;
8637 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8639 stateAnchor = normalAnchor;
8640 stateSizeAnchor = normalSizeAnchor;
8642 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8643 Position(x,y, w, h, true, true, true, true, false, true);
8646 get { value = clientSize; }
8649 property Size initSize { get { value = sizeAnchor.size; } };
8651 property Anchor anchor
8653 property_category $"Layout"
8654 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8660 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8662 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8663 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8665 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8667 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8668 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8672 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8674 anchor.left.distance = 0;
8675 anchor.horz.type = 0;
8677 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8679 anchor.top.distance = 0;
8680 anchor.vert.type = 0;
8689 normalAnchor = anchor;
8691 // Break the anchors for moveable/resizable windows
8692 /*if(style.fixed ) //&& value.left.type == cascade)
8694 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8696 this.anchor = normalAnchor = Anchor { left = x, top = y };
8697 normalSizeAnchor = SizeAnchor { { w, h } };
8700 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8702 stateAnchor = normalAnchor;
8703 stateSizeAnchor = normalSizeAnchor;
8705 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8706 Position(x, y, w, h, true, true, true, true, false, true);
8715 get { value = this ? anchor : Anchor { }; }
8718 property Point position
8720 property_category $"Layout"
8723 if(value == null) return;
8725 anchor.left = value.x;
8726 anchor.top = value.y;
8727 anchor.right.type = none;
8728 anchor.bottom.type = none;
8733 normalAnchor = anchor;
8735 // Break the anchors for moveable/resizable windows
8739 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8741 normalAnchor.left = x;
8742 normalAnchor.top = y;
8743 normalAnchor.right.type = none;
8744 normalAnchor.bottom.type = none;
8745 normalSizeAnchor.size.width = w;
8746 normalSizeAnchor.size.height = h;
8750 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8752 stateAnchor = normalAnchor;
8753 stateSizeAnchor = normalSizeAnchor;
8755 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8756 Position(x,y, w, h, true, true, true, true, false, true);
8760 get { value = position; }
8763 property bool disabled
8765 property_category $"Behavior"
8768 if(this && disabled != value)
8775 get { return (bool)disabled; }
8778 property bool isEnabled
8783 for(parent = this; parent; parent = parent.parent)
8790 property WindowState state
8792 property_category $"Behavior"
8793 set { SetState(value, false, 0); }
8794 get { return this ? state : 0; }
8797 property bool visible
8799 property_category $"Behavior"
8802 if(this && !value && !style.hidden && parent)
8804 bool wasActiveChild = parent.activeChild == this;
8805 Window client = null;
8807 style.hidden = true;
8808 if(style.isActiveClient)
8810 parent.numPositions--;
8811 if(state == minimized) parent.numIcons--;
8816 OldLink prevOrder = null;
8818 if(rootWindow == this)
8819 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8822 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8825 box.left -= parent.clientStart.x;
8826 box.top -= parent.clientStart.y;
8827 box.right -= parent.clientStart.x;
8828 box.bottom -= parent.clientStart.y;
8832 if(_isModal && master && master.modalSlave == this)
8833 master.modalSlave = null;
8837 OldLink tmpPrev = order.prev;
8838 client = tmpPrev ? tmpPrev.data : null;
8839 if(client && !client.style.hidden && !client.destroyed && client.created)
8840 prevOrder = tmpPrev;
8843 client = tmpPrev ? tmpPrev.data : null;
8844 if(client == this) { client = null; break; }
8845 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8847 tmpPrev = client.order.prev;
8852 prevOrder = tmpPrev;
8857 // If this window can be an active client, make sure the next window we activate can also be one
8858 if(!style.nonClient && style.isActiveClient)
8860 tmpPrev = prevOrder;
8863 client = tmpPrev ? tmpPrev.data : null;
8864 if(client == this) { client = null; break; }
8865 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8867 tmpPrev = client.order.prev;
8872 prevOrder = tmpPrev;
8876 if(client && client.style.hidden) client = null;
8880 if((wasActiveChild /*parent.activeChild == this*/ || guiApp.interimWindow == this) && true /*activate*/)
8882 if(order && prevOrder && prevOrder.data != this)
8883 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8885 ActivateEx(false, false, false, true, null, null);
8887 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8888 if(parent.activeClient == this)
8890 parent.activeClient = null;
8891 parent.UpdateActiveDocument(null);
8894 else if(parent.activeClient == this)
8896 parent.activeClient = client;
8897 parent.UpdateActiveDocument(this);
8900 // *** Not doing this anymore ***
8903 parent.childrenCycle.Delete(cycle);
8905 parent.childrenOrder.Delete(order);
8910 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8915 else if(this && value && style.hidden)
8917 style.hidden = false;
8920 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8921 if(rootWindow == this)
8922 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8924 if(_isModal && master)
8925 master.modalSlave = this;
8927 if(style.isActiveClient)
8929 positionID = parent.GetPositionID(this);
8930 parent.numPositions++;
8931 if(state == minimized) parent.numIcons++;
8934 // *** NOT DOING THIS ANYMORE ***
8936 if(!(style.inactive))
8938 if(!(style.noCycle))
8940 cycle = parent.childrenCycle.AddAfter(
8941 (parent.activeChild && parent.activeChild.cycle) ?
8942 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8945 order = parent.childrenOrder.AddAfter(
8946 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8953 if(true || !parent.activeChild)
8954 ActivateEx(true, false, true, true, null, null);
8956 if(creationActivation == activate)
8957 ActivateEx(true, false, true, true, null, null);
8958 else if(creationActivation == flash && !object)
8961 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8965 ConsequentialMouseMove(false);
8971 style.hidden = !value;
8974 get { return (style.hidden || !setVisible) ? false : true; }
8977 property bool isDocument
8979 property_category $"Document"
8980 set { style.isDocument = value; }
8981 get { return style.isDocument; }
8984 property bool mergeMenus
8986 property_category $"Window Style"
8987 set { mergeMenus = value; }
8988 get { return (bool)mergeMenus; }
8991 property bool hasHorzScroll
8993 property_category $"Window Style"
8998 if(!style.hasHorzScroll && created)
9000 CreateSystemChildren();
9001 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9004 else if(style.hasHorzScroll)
9008 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9010 style.hasHorzScroll = value;
9013 get { return style.hasHorzScroll; }
9016 property bool hasVertScroll
9018 property_category $"Window Style"
9023 if(!style.hasVertScroll && created)
9025 style.hasVertScroll = true;
9026 CreateSystemChildren();
9027 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9030 else if(style.hasVertScroll)
9034 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
9036 style.hasVertScroll = value;
9038 get { return style.hasVertScroll; }
9041 property bool dontHideScroll
9043 property_category $"Behavior"
9046 scrollFlags.dontHide = value;
9049 //UpdateScrollBars(true, true);
9050 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9054 // UpdateScrollBars(true, true);
9055 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
9058 get { return scrollFlags.dontHide; }
9061 property bool dontScrollVert
9063 property_category $"Behavior"
9064 set { style.dontScrollVert = value; }
9065 get { return style.dontScrollVert; }
9067 property bool dontScrollHorz
9069 property_category $"Behavior"
9070 set { style.dontScrollHorz = value; }
9071 get { return style.dontScrollHorz; }
9074 property bool snapVertScroll
9076 property_category $"Behavior"
9079 scrollFlags.snapY = value;
9080 if(sbv) sbv.snap = value;
9082 get { return scrollFlags.snapY; }
9084 property bool snapHorzScroll
9086 property_category $"Behavior"
9089 scrollFlags.snapX = value;
9090 if(sbh) sbh.snap = value;
9092 get { return scrollFlags.snapX; }
9095 property Point scroll
9097 property_category $"Behavior"
9098 set { SetScrollPosition(value.x, value.y); }
9099 get { value = scroll; }
9102 property bool modifyVirtualArea
9104 property_category $"Behavior"
9105 set { modifyVirtArea = value; }
9106 get { return (bool)modifyVirtArea; }
9109 property bool dontAutoScrollArea
9111 property_category $"Behavior"
9112 // Activating a child control out of view will automatically scroll to make it in view
9113 set { noAutoScrollArea = value; }
9114 get { return (bool)noAutoScrollArea; }
9117 property char * fileName
9119 property_category $"Document"
9122 if(menu && ((!fileName && value) || (fileName && !value)))
9124 MenuItem item = menu.FindItem(MenuFileSave, 0);
9125 if(item) item.disabled = !modifiedDocument && value;
9130 if(value && value[0])
9131 fileName = CopyString(value);
9133 if(parent && this == parent.activeClient)
9134 parent.UpdateActiveDocument(null);
9138 // if(style.isDocument)
9140 fileMonitor.fileName = value;
9142 get { return fileName; }
9147 property_category $"Data"
9152 property bool modifiedDocument
9154 property_category $"Document"
9157 if(style.isDocument || fileName)
9161 MenuItem item = menu.FindItem(MenuFileSave, 0);
9162 if(item) item.disabled = !value && fileName;
9166 if(modifiedDocument != value)
9168 modifiedDocument = value;
9169 if(style.isDocument || fileName)
9173 get { return (bool)modifiedDocument; }
9176 property bool showInTaskBar
9178 property_category $"Window Style"
9179 set { style.showInTaskBar = value; }
9180 get { return (style.showInTaskBar; }
9182 property FileDialog saveDialog { set { saveDialog = value; } };
9183 property bool isActiveClient
9185 property_category $"Behavior"
9186 set { style.isActiveClient = value; }
9187 get { return style.isActiveClient; }
9190 property Cursor cursor
9192 property_category $"Appearance"
9196 SelectMouseCursor();
9198 get { return cursor; }
9201 //#if !defined(ECERE_VANILLA)
9202 property char * name
9204 property_category $"Design"
9207 return (this && object) ? object.name : null;
9212 activeDesigner.RenameObject(object, value);
9216 property char * displayDriver
9218 property_category $"Behavior"
9221 dispDriver = GetDisplayDriver(value);
9222 //DisplayModeChanged();
9226 return dispDriver ? dispDriver.name : null;
9230 // RUNTIME PROPERTIES
9231 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9232 property Size scrollArea
9234 property_category $"Behavior"
9238 SetScrollArea(value.w, value.h, false);
9240 SetScrollArea(0,0, true);
9242 get { value = scrollArea; }
9245 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9250 property_category $"Layout"
9251 set { if(this) is3D = value; }
9252 get { return (bool)is3D; }
9255 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9257 // Will be merged with font later
9258 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9259 property Point clientStart { get { value = clientStart; } };
9260 property Point absPosition { get { value = absPosition; } };
9261 property Anchor normalAnchor { get {value = normalAnchor; } };
9262 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9263 property bool active { get { return (bool)active; } };
9264 property bool created { get { return (bool)created; } };
9265 property bool destroyed { get { return (bool)destroyed; } };
9266 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9267 property Window firstChild { get { return children.first; } };
9268 property Window lastChild { get { return children.last; } };
9269 property Window activeClient { get { return activeClient; } };
9270 property Window activeChild { get { return activeChild; } };
9271 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9272 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9273 property ScrollBar horzScroll { get { return sbh; } };
9274 property ScrollBar vertScroll { get { return sbv; } };
9275 property StatusBar statusBar { get { return statusBar; } };
9276 property Window rootWindow { get { return rootWindow; } };
9277 property bool closing { get { return (bool)closing; } set { closing = value; } };
9278 property int documentID { get { return documentID; } };
9279 property Window previous { get { return prev; } }
9280 property Window next { get { return next; } }
9281 property Window nextSlave { get { OldLink link = master ? master.slaves.FindLink(this) : null; return (link && link.next) ? link.next.data : null; } }
9282 property PopupMenu menuBar { get { return menuBar; } }
9283 property ScrollBar sbv { get { return sbv; } }
9284 property ScrollBar sbh { get { return sbh; } }
9285 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9286 property void * systemHandle { get { return windowHandle; } }
9287 property Button minimizeButton { get { return sysButtons[0]; } };
9288 property Button maximizeButton { get { return sysButtons[1]; } };
9289 property Button closeButton { get { return sysButtons[2]; } };
9290 property BitmapResource icon
9292 get { return icon; }
9296 if(icon) incref icon;
9298 guiApp.interfaceDriver.SetIcon(this, value);
9301 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9302 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9303 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9304 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9305 property bool nativeDecorations
9307 get { return (bool)nativeDecorations; }
9308 set { nativeDecorations = value; }
9309 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
9312 //return (nativeDecorations && (rootWindow == this || (formDesigner && activeDesigner && ((FormDesigner)activeDesigner.classDesigner).form && parent == ((FormDesigner)activeDesigner.classDesigner).form.parent))) != style.fixed;
9313 bool result = false;
9314 if(nativeDecorations)
9316 if(rootWindow == this)
9320 if(formDesigner && activeDesigner)
9322 FormDesigner cd = (FormDesigner)activeDesigner.classDesigner;
9323 Window form = cd ? cd.form : null;
9324 if(form && parent == form.parent)
9329 return result != style.fixed;
9333 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9335 property char * text
9337 property_category $"Deprecated"
9339 set { property::caption = value; }
9340 get { return property::caption; }
9346 WindowBits style; // Window Style
9347 char * caption; // Name / Caption
9348 Window parent; // Parent window
9349 OldList children; // List of children in Z order
9350 Window activeChild; // Child window having focus
9351 Window activeClient;
9352 Window previousActive; // Child active prior to activating the default child
9353 Window master; // Window owning and receiving notifications concerning this window
9354 OldList slaves; // List of windows belonging to this window
9355 Display display; // Display this window is drawn into
9357 Point position; // Position in parent window client area
9358 Point absPosition; // Absolute position
9359 Point clientStart; // Client area position from (0,0) in this window
9361 Size clientSize; // Client area size
9362 Size scrollArea; // Virtual Scroll area size
9363 Size reqScrollArea; // Requested virtual area size
9364 Point scroll; // Virtual area scrolling position
9365 public ScrollBar sbh, sbv; // Scrollbar window handles
9366 Cursor cursor; // Mouse cursor used for this window
9369 StatusBar statusBar;
9370 Button sysButtons[3];
9372 Box clientArea; // Client Area box clipped to parent
9374 HotKeySlot hotKey; // HotKey for this window
9378 ScrollFlags scrollFlags;// Window Scrollbar Flags
9379 int64 id; // Control ID
9381 ColorAlpha background; // Background color used to draw the window area
9383 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9384 OldList childrenCycle; // Cycling order
9385 OldLink cycle; // Element of parent's cycling order
9386 OldList childrenOrder; // Circular Z-Order
9387 OldLink order; // Element of parent's circular Z-Order
9388 Window modalSlave; // Slave window blocking this window's interaction
9390 Window rootWindow; // Topmost system managed window
9391 void * windowHandle; // System window handle
9393 DialogResult returnCode;// Return code for modal windows
9395 Point sbStep; // Scrollbar line scrolling steps
9398 SizeAnchor stateSizeAnchor;
9400 Anchor normalAnchor;
9401 SizeAnchor normalSizeAnchor;
9403 Size skinMinSize; // Minimal window size based on style
9404 Point scrolledPos; // Scrolled position
9405 Box box; // Window box clipped to parent
9406 Box * against; // What to clip the box to
9408 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9409 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9410 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9411 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9412 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9413 Point scrolledArea; // Distance to scroll area by
9414 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9416 OldList hotKeys; // List of the hotkeys of all children
9417 Window defaultControl; // Default child control
9421 ColorAlpha * palette; // Color palette used for this window
9423 int caretSize; // Size of caret, non zero if a caret is present
9424 Point caretPos; // Caret position
9426 void * systemParent; // Parent System Window for embedded windows
9433 WindowState lastState;
9435 FileMonitor fileMonitor
9437 this, FileChange { modified = true };
9439 bool OnFileNotify(FileChange action, char * param)
9442 fileMonitor.StopMonitoring();
9443 if(OnFileModified(action, param))
9444 fileMonitor.StartMonitoring();
9449 FontResource setFont, systemFont;
9450 FontResource usedFont;
9451 FontResource captionFont;
9453 FileDialog saveDialog;
9455 SizeAnchor sizeAnchor;
9457 // FormDesigner data
9460 Extent * tempExtents; //[4];
9461 BitmapResource icon;
9463 CreationActivationOption creationActivation;
9466 bool active:1; // true if window and ancestors are active
9467 bool acquiredInput:1; // true if the window is processing state based input
9468 bool modifiedDocument:1;
9469 bool disabled:1; // true if window cannot interact
9470 bool isForegroundWindow:1;// true while a root window is being activated
9471 bool visible:1; // Visibility flag
9472 bool destroyed:1; // true if window is being destroyed
9473 bool anchored:1; // true if this window is repositioned when the parent resizes
9474 bool dirty:1; // Flag set to true if any descendant must be redrawn
9480 bool modifyVirtArea:1;
9481 bool noAutoScrollArea:1;
9484 bool setVisible:1; // FOR FORM DESIGNER
9490 bool useSharedMemory:1;
9493 bool nativeDecorations:1;
9494 bool manageDisplay:1;
9495 bool formDesigner:1; // True if we this is running in the form editor
9498 // Checks used internally for them not to take effect in FormDesigner
9499 property bool _isModal { get { return !formDesigner ? style.modal : false; } }
9500 property subclass(DisplayDriver) _displayDriver { get { return !formDesigner ? dispDriver : null; } }
9502 WindowController controller;
9503 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9506 public class CommonControl : Window
9508 // creationActivation = doNothing;
9511 public property String toolTip
9513 property_category $"Appearance"
9516 if(created) CommonControl::OnDestroy();
9518 toolTip = value ? ToolTip { tip = value; } : null;
9520 if(created) CommonControl::OnCreate();
9522 get { return toolTip ? toolTip.tip : null; }
9528 // (Very) Ugly work around for the fact that the parent watcher
9529 // won't fire when it's already been disconnected...
9530 eInstance_FireSelfWatchers(toolTip,
9531 __ecereProp___ecereNameSpace__ecere__gui__Window_parent);
9537 toolTip.parent = this;
9546 public class Percentage : float
9548 char * OnGetString(char * string, float * fieldData, bool * needClass)
9552 sprintf(string, "%.2f", this);
9553 c = strlen(string)-1;
9556 if(string[c] != '0')
9557 last = Max(last, c);
9558 if(string[c] == '.')
9571 public void ApplySkin(Class c, char * name, void ** vTbl)
9573 char className[1024];
9578 subclass(Window) wc = (subclass(Window))c;
9579 subclass(Window) base = (subclass(Window))c.base;
9581 sprintf(className, "%sSkin_%s", name, c.name);
9582 wc.pureVTbl = c._vTbl;
9583 c._vTbl = new void *[c.vTblSize];
9584 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9585 sc = eSystem_FindClass(c.module.application, className);
9589 for(m = 0; m < c.base.vTblSize; m++)
9591 if(c._vTbl[m] == base.pureVTbl[m])
9592 c._vTbl[m] = vTbl[m];
9597 for(m = 0; m < c.vTblSize; m++)
9599 if(sc._vTbl[m] != wc.pureVTbl[m])
9600 c._vTbl[m] = sc._vTbl[m];
9604 for(d = c.derivatives.first; d; d = d.next)
9606 ApplySkin(d.data, name, c._vTbl);
9610 public void UnapplySkin(Class c)
9612 char className[1024];
9614 subclass(Window) wc = (subclass(Window))c;
9615 subclass(Window) base = (subclass(Window))c.base;
9618 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9621 c._vTbl = wc.pureVTbl;
9625 for(d = c.derivatives.first; d; d = d.next)
9627 UnapplySkin(d.data);
9631 void CheckFontIntegrity(Window window)
9636 if(window.usedFont && window.usedFont.font == 0xecececec)
9638 FontResource uf = window.usedFont;
9639 char * className = window._class.name;
9640 char * text = window.text;
9643 for(c = window.firstChild; c; c = c.next)
9644 CheckFontIntegrity(c);
9648 public class ControllableWindow : Window
9650 /*WindowController controller;
9651 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9652 ~ControllableWindow() { delete controller; }*/
9655 class WindowControllerInterface : ControllableWindow
9657 bool OnKeyDown(Key key, unichar ch)
9659 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyDown)((Window)controller.controlled, controller, key, ch);
9661 result = ((bool (*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown])(controller.window, key, ch);
9665 bool OnKeyUp(Key key, unichar ch)
9667 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyUp)((Window)controller.controlled, controller, key, ch);
9669 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp])(controller.window, key, ch);
9673 bool OnKeyHit(Key key, unichar ch)
9675 bool result = ((bool(*)(Window, WindowController, Key, unichar))(void *)controller.OnKeyHit)((Window)controller.controlled, controller, key, ch);
9677 result = ((bool(*)(Window, Key, unichar))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit])(controller.window, key, ch);
9681 bool OnMouseMove(int x, int y, Modifiers mods)
9683 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMouseMove)((Window)controller.controlled, controller, x, y, mods);
9685 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove])(controller.window, x, y, mods);
9689 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9691 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonDown)((Window)controller.controlled, controller, x, y, mods);
9693 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown])(controller.window, x, y, mods);
9697 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9699 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftButtonUp)((Window)controller.controlled, controller, x, y, mods);
9701 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp])(controller.window, x, y, mods);
9705 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9707 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnLeftDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9709 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick])(controller.window, x, y, mods);
9713 bool OnRightButtonDown(int x, int y, Modifiers mods)
9715 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonDown)((Window)controller.controlled, controller, x, y, mods);
9717 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown])(controller.window, x, y, mods);
9721 bool OnRightButtonUp(int x, int y, Modifiers mods)
9723 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightButtonUp)((Window)controller.controlled, controller, x, y, mods);
9725 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp])(controller.window, x, y, mods);
9729 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9731 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnRightDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9733 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick])(controller.window, x, y, mods);
9737 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9739 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonDown)((Window)controller.controlled, controller, x, y, mods);
9741 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown])(controller.window, x, y, mods);
9745 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9747 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleButtonUp)((Window)controller.controlled, controller, x, y, mods);
9749 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp])(controller.window, x, y, mods);
9753 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9755 bool result = ((bool(*)(Window, WindowController, int, int, Modifiers))(void *)controller.OnMiddleDoubleClick)((Window)controller.controlled, controller, x, y, mods);
9757 result = ((bool(*)(Window, int, int, Modifiers))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick])(controller.window, x, y, mods);
9761 void OnResize(int width, int height)
9763 ((void(*)(Window, WindowController, int, int))(void *)controller.OnResize)((Window)controller.controlled, controller, width, height);
9764 ((void(*)(Window, int, int))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize])(controller.window, width, height);
9767 void OnRedraw(Surface surface)
9769 ((void(*)(Window, WindowController, Surface))(void *)controller.OnRedraw)((Window)controller.controlled, controller, surface);
9770 ((void(*)(Window, Surface))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw])(controller.window, surface);
9775 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnCreate)((Window)controller.controlled, controller);
9777 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate])(controller.window);
9781 bool OnLoadGraphics()
9783 bool result = ((bool(*)(Window, WindowController))(void *)controller.OnLoadGraphics)((Window)controller.controlled, controller);
9785 result = ((bool(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLoadGraphics])(controller.window);
9789 void OnUnloadGraphics()
9791 ((void(*)(Window, WindowController))(void *)controller.OnUnloadGraphics)((Window)controller.controlled, controller);
9792 ((void(*)(Window))(void *)controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnUnloadGraphics])(controller.window);
9796 public class WindowController<class V>
9799 property Window window
9803 uint size = class(Window).vTblSize;
9806 windowVTbl = new void *[size];
9807 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9808 if(value._vTbl == value._class._vTbl)
9810 value._vTbl = new void *[value._class.vTblSize];
9811 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9815 for(c = 0; c < size; c++)
9817 void * function = class(WindowControllerInterface)._vTbl[c];
9818 if(function != DefaultFunction)
9819 value._vTbl[c] = function;
9821 value._vTbl[c] = windowVTbl[c];
9826 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9829 get { return window; }
9831 property V controlled
9833 set { controlled = value; }
9834 get { return controlled; }
9836 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9837 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9838 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9839 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9840 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9841 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9842 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9843 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9844 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9845 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9846 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9847 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9848 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9849 virtual void V::OnResize(WindowController controller, int width, int height);
9850 virtual void V::OnRedraw(WindowController controller, Surface surface);
9851 virtual bool V::OnCreate(WindowController controller);
9852 virtual bool V::OnLoadGraphics(WindowController controller);
9853 virtual void V::OnUnloadGraphics(WindowController controller);
9856 int (** windowVTbl)();