7 import "GuiApplication"
27 #if !defined(ECERE_VANILLA) && !defined(ECERE_NO3D)
31 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
39 // 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
40 define skinMenuHeight = 25;
42 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
44 public enum DialogResult { cancel, yes, no, ok };
46 public class MouseButtons
49 bool left:1, right:1, middle:1;
52 public struct SizeAnchor
55 bool isClientW, isClientH;
60 #define SNAPDOWN(x, d) \
63 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
66 #define SNAPUP(x, d) \
69 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
72 /*static */define MAX_DIRTY_BACK = 10;
74 /////////////////////////////////////////////////////////////////////////////
75 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
76 /////////////////////////////////////////////////////////////////////////////
78 #define ACCESS_ITEM(l, id) \
81 #define FASTLIST_LOOP(l, v) \
82 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
84 #define FASTLIST_LOOPN(l, v, n) \
85 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
88 #define ACCESS_ITEM(l, id) \
89 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
91 #define FASTLIST_LOOP(l, v) \
92 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
94 #define FASTLIST_LOOPN(l, v, n) \
95 for( v = (void *)ACCESS_ITEM((l), (l).first), \
96 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
97 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
100 private class FastItem : struct
105 private struct FastList
110 int count, size, itemSize;
117 first = last = free = -1;
125 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
128 FastItem Add(uint itemSize)
131 if(free == -1 || !size)
138 newSize = (size + (size >> 1));
139 items = (FastItem)renew items byte[newSize * itemSize];
144 this.itemSize = itemSize;
145 items = (FastItem)new byte[newSize * itemSize];
148 for(c = size; c<newSize-1; c++)
150 ACCESS_ITEM(this, c).prev = -1;
151 ACCESS_ITEM(this, c).next = c+1;
153 ACCESS_ITEM(this, c).prev = -1;
154 ACCESS_ITEM(this, c).next = -1;
158 item = ACCESS_ITEM(this, free);
161 ACCESS_ITEM(this, item.prev).next = free;
171 void Delete(FastItem item)
174 ACCESS_ITEM(this, item.prev).next = item.next;
176 ACCESS_ITEM(this, item.next).prev = item.prev;
178 if(ACCESS_ITEM(this, first) == item)
180 if(ACCESS_ITEM(this, last) == item)
185 free = ((byte *)item - (byte *)items) / itemSize;
193 free = first = last = -1;
197 private class BoxItem : Item //FastItem
202 public /*private */struct Extent : OldList //FastList
211 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
212 Add(BoxItem { box = box });
215 void Copy(Extent source)
221 FASTLIST_LOOP(source, extentBox)
222 AddBox(extentBox.box);
225 void IntersectBox(Box box)
227 // Clip all boxes of extent against inside of the new box
228 BoxItem extentBox, next;
230 FASTLIST_LOOPN(this, extentBox, next)
232 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
233 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
234 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
235 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
236 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
241 void ExcludeBox(Box box, Extent temp)
248 FASTLIST_LOOP(temp, extentBox)
250 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
251 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
254 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
258 extentBox.box.left, extentBox.box.top,
259 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
265 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
269 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
270 extentBox.box.right, extentBox.box.bottom
276 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
279 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
283 extentBox.box.left, Max(extentBox.box.top, box.top),
284 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
290 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
294 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
295 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
303 AddBox(extentBox.box);
309 void UnionBox(Box box, Extent temp)
311 BoxItem extentBox, next;
313 // First pass: check if this box is not already covered by one of the extent's box
314 FASTLIST_LOOP(this, extentBox)
316 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
317 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
324 // Second pass: only keep boxes not completely covered in the new box
325 FASTLIST_LOOPN(this, extentBox, next)
327 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
328 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
332 // Add the exclusion to the extent
333 ExcludeBox(box, temp);
336 if(box.bottom >= box.top && box.right >= box.left)
338 // Optimization: if the resulting boxes touch, add them smarter
339 FASTLIST_LOOP(this, extentBox)
341 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
343 if(Abs(box.right - extentBox.box.left) <= 1)
345 extentBox.box.left = box.left;
348 else if(Abs(box.left - extentBox.box.right) <= 1)
350 extentBox.box.right = box.right;
354 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
356 if(Abs(box.bottom - extentBox.box.top) <= 1)
358 extentBox.box.top = box.top;
361 else if(Abs(box.top - extentBox.box.bottom) <= 1)
363 extentBox.box.bottom = box.bottom;
375 void Union(Extent b, Extent temp)
379 FASTLIST_LOOP(b, extentBox)
380 UnionBox(extentBox.box, temp);
383 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
390 FASTLIST_LOOP(b, extentBox)
393 temp2.IntersectBox(extentBox.box);
400 void Exclusion(Extent b, Extent temp)
403 FASTLIST_LOOP(b, extentBox)
404 ExcludeBox(extentBox.box, temp);
407 void Offset(int x, int y)
410 FASTLIST_LOOP(this, extentBox)
412 extentBox.box.left += x;
413 extentBox.box.top += y;
414 extentBox.box.right += x;
415 extentBox.box.bottom += y;
420 private define MINIMIZED_WIDTH = 160;
421 private define CASCADE_SPACE = 16;
423 // namespace Windows;
425 private class ScrollFlags
427 bool snapX:1, snapY:1, dontHide:1;
430 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1; };
432 class WindowBits : BorderBits
434 BorderBits borderBits:5:0;
435 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, unused1:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
436 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
437 bool embedded:1, unused2:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
440 public enum BorderStyle : BorderBits
443 contour = BorderBits { contour = true },
444 fixed = BorderBits { fixed = true } | contour,
445 sizable = BorderBits { sizable = true } | fixed,
446 deep = BorderBits { deep = true },
447 bevel = BorderBits { bevel = true },
448 sizableDeep = sizable|deep,
449 sizableBevel = sizable|bevel,
450 fixedDeep = fixed|deep,
451 fixedBevel = fixed|bevel,
452 deepContour = deep|contour
455 public enum CreationActivationOption
457 activate, flash, doNothing
460 public enum WindowState { normal, minimized, maximized };
462 private class ResPtr : struct
469 private class HotKeySlot : struct
471 HotKeySlot prev, next;
479 class_data char * icon;
481 class_default_property text;
482 // class_initialize GuiApplication::Initialize;
483 class_designer FormDesigner;
484 class_property char * icon
486 set { class_data(icon) = value; }
487 get { return class_data(icon); }
492 if(guiApp) guiApp.Initialize(true);
494 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
496 if(_vTbl == ((subclass(Window))_class).pureVTbl)
498 _vTbl = _class._vTbl;
500 else if(_vTbl != _class._vTbl)
503 for(m = 0; m < _class.vTblSize; m++)
505 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
506 _vTbl[m] = _class._vTbl[m];
511 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
512 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
513 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
514 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
518 // caption = CopyString(class.name);
520 children.offset = (byte*)&prev - (byte*)this;
521 childrenOrder.circ = true;
522 childrenCycle.circ = true;
524 maxSize = Size { MAXINT, MAXINT };
528 //style.isActiveClient = true;
531 modifyVirtArea = true;
532 manageDisplay = true;
534 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
535 sbStep.x = sbStep.y = 8;
537 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
539 cursor = guiApp.GetCursor(arrow);
540 property::parent = guiApp.desktop;
551 stopwatching(parent, font);
555 // Prevent destructor from being called again...
561 /////////////////////////////////
564 OldLink slave = master.slaves.FindLink(this);
565 master.slaves.Delete(slave);
572 parent.childrenCycle.Remove(cycle);
574 parent.childrenOrder.Remove(order);
575 parent.children.Remove(this);
580 /////////////////////////////////
582 while(ptr = resources.first)
585 resources.Delete(ptr);
592 for(child = children.first; child; child = child.next)
594 // child.stopwatching(this, font);
596 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
597 // Don't want property here
598 *&child.parent = null;
601 while(slave = slaves.first)
603 // Don't want property here
604 *&((Window)slave.data).master = null;
605 slaves.Delete(slave);
608 // Because we do a decref in DestroyEx...
616 // Why was this commented?
617 //if(this != guiApp.desktop)
630 if(((subclass(Window))_class).pureVTbl)
632 if(_vTbl == _class._vTbl)
634 _vTbl = ((subclass(Window))_class).pureVTbl;
639 for(m = 0; m < _class.vTblSize; m++)
641 if(_vTbl[m] == _class._vTbl[m])
642 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
646 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
649 dirtyArea.Free(null);
650 renderArea.Free(null);
651 overRenderArea.Free(null);
652 clipExtent.Free(null);
653 scrollExtent.Free(null);
654 dirtyBack.Free(null);
658 tempExtents[0].Free(null);
659 tempExtents[1].Free(null);
660 tempExtents[2].Free(null);
661 tempExtents[3].Free(null);
666 //#if !defined(ECERE_VANILLA)
667 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
669 if(this == activeDesigner)
673 char * name = property::name;
674 return name ? name : "";
679 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
680 bool OnGetDataFromString(char * string)
682 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
685 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
686 this = designer.form;
687 else if(!strcmpi(string, "(Desktop)"))
688 this = activeDesigner;
690 return activeDesigner.FindObject(&this, string);
696 // --- Window updates system ---
698 // Setup a bitmap for Redrawing on client area of Window
699 Surface Redraw(Box box)
701 Surface surface = null;
703 Box clientArea = this.clientArea;
707 mox.left -= clientStart.x;
708 mox.top -= clientStart.y;
709 mox.right -= clientStart.x;
710 mox.bottom -= clientStart.y;
712 mox.Clip(clientArea);
713 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
715 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
717 int x = absPosition.x + clientStart.x;
718 int y = absPosition.y + clientStart.y;
719 if(rootWindow.nativeDecorations)
721 x -= rootWindow.clientStart.x;
722 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
724 if(!guiApp.fullScreenMode || is3D)
726 x -= rootWindow.absPosition.x;
727 y -= rootWindow.absPosition.y;
731 x += rootWindow.parent.clientStart.x;
732 y += rootWindow.parent.clientStart.y;
734 mox.left += rootWindow.parent.clientStart.x;
735 mox.top += rootWindow.parent.clientStart.y;
736 mox.right += rootWindow.parent.clientStart.x;
737 mox.bottom += rootWindow.parent.clientStart.y;
742 surface = display.GetSurface(x, y, mox);
745 surface.width = clientSize.w;
746 surface.height = clientSize.h;
752 // Setup a bitmap for Redrawing on full Window
753 Surface RedrawFull(Box box)
755 Surface surface = null;
763 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
765 int x = absPosition.x;
766 int y = absPosition.y;
767 if(rootWindow.nativeDecorations)
769 x -= rootWindow.clientStart.x;
770 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
772 if(!guiApp.fullScreenMode || is3D)
774 x -= rootWindow.absPosition.x;
775 y -= rootWindow.absPosition.y;
778 x += rootWindow.parent.clientStart.x;
779 y += rootWindow.parent.clientStart.y;
781 mox.left += rootWindow.parent.clientStart.x;
782 mox.top += rootWindow.parent.clientStart.y;
783 mox.right += rootWindow.parent.clientStart.x;
784 mox.bottom += rootWindow.parent.clientStart.y;
789 surface = display.GetSurface(x, y, mox);
792 surface.width = size.w;
793 surface.height = size.h;
799 void FigureCaption(char * caption)
803 strcpy(caption, this.caption);
804 if(style.isDocument || fileName)
806 if(caption[0]) strcat(caption, " - ");
808 strcat(caption, fileName);
812 sprintf(title, "Untitled %d", documentID);
813 strcat(caption, title);
816 strcat(caption, " *");
818 if(activeClient && menuBar &&
819 activeClient.state == maximized)
821 if(activeClient.caption)
823 if(caption[0]) strcat(caption, " - ");
824 strcat(caption, activeClient.caption);
826 if(activeClient.style.isDocument || activeClient.fileName)
828 if(caption[0]) strcat(caption, " - ");
829 strcat(caption, "[");
830 if(activeClient.fileName)
831 strcat(caption, activeClient.fileName);
835 sprintf(title, "Untitled %d", activeClient.documentID);
836 strcat(caption, title);
838 if(activeClient.modifiedDocument)
839 strcat(caption, " *");
840 strcat(caption, "]");
845 // Code for returning dirty from ScrollDisplay:
847 for(d = 0; d<scrollExtent.count; d++)
849 Box * box = &scrollExtent.boxes[d];
855 Min(box.right, box.left-scroll.x),box.bottom
857 dirtyArea.UnionBox(update);
863 Max(box.left, box.right-scroll.x), box.top,
864 box.right, box.bottom
866 dirtyArea.UnionBox(update);
874 box.right, Min(box.bottom, box.top-scroll.y),
876 dirtyArea.UnionBox(update);
882 box.left, Max(box.top, box.bottom-scroll.y),
883 box.right, box.bottom
885 dirtyArea.UnionBox(update);
890 void UpdateDecorations(void)
892 // TODO: *** TEMPORARY HACK ***
899 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
901 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
903 Update({ -clientStart.x,0, -1, clientSize.h-1 });
905 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
908 // Returns w & h for Position
909 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
911 Window parent = this.parent ? this.parent : guiApp.desktop;
912 int vpw = parent ? parent.clientSize.w : 0;
913 int vph = parent ? parent.clientSize.h : 0;
914 int pw = parent ? parent.clientSize.w : 0;
915 int ph = parent ? parent.clientSize.h : 0;
916 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
917 int x = anchor.left.distance, y = anchor.top.distance;
919 MinMaxValue ew = 0, eh = 0;
921 float cascadeW, cascadeH;
923 int tilingW, tilingH, tilingSplit, tilingLastH;
924 int addX = 0, addY = 0;
926 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
928 Window masterWindow = this;
929 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
932 if(master == guiApp.desktop)
933 masterWindow = guiApp.desktop.activeChild;
935 masterWindow = master.rootWindow;
936 if(!masterWindow) masterWindow = this;
938 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
939 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
942 pw = vpw = box.right - box.left + 1;
944 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
947 ph = vph = box.bottom - box.top + 1;
963 vpw = pw = parent.size.w;
964 vph = ph = parent.size.h;
966 else if(!style.fixed /*|| style.isDocument*/)
968 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
969 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
971 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
974 Desktop3D_FixSize(&pw, &ph);
975 Desktop3D_FixSize(&vpw, &vph);
978 if(pw < skinMinSize.w) pw = skinMinSize.w;
979 if(ph < skinMinSize.h) ph = skinMinSize.h;
980 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
981 if(vph < skinMinSize.h) vph = skinMinSize.h;
983 // TODO: Must fix what we're snapping
988 SNAPUP(x, textCellW);
990 else if(anchor.right.type)
992 SNAPDOWN(x, textCellW);
997 SNAPUP(y, textCellH);
999 else if(anchor.bottom.type)
1001 SNAPDOWN(y, textCellH);
1005 // This is required to get proper initial decoration size using native decorations on Windows
1006 if(nativeDecorations && guiApp && guiApp.interfaceDriver && !visible)
1007 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
1008 GetDecorationsSize(&ew, &eh);
1010 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1012 if(parent.sbv && !parent.sbv.style.hidden)
1013 pw += guiApp.currentSkin.VerticalSBW();
1014 if(parent.sbh && !parent.sbh.style.hidden)
1015 ph += guiApp.currentSkin.HorizontalSBH();
1017 if(anchor.left.type == cascade)
1019 w = (int)(pw * 0.80);
1020 h = (int)(ph * 0.80);
1022 else if(anchor.left.type >= vTiled)
1027 numTiling = parent.numPositions - parent.numIcons;
1028 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1029 if(anchor.left.type == vTiled)
1031 tilingH = (int)sqrt(numTiling);
1032 tilingW = numTiling / tilingH;
1036 tilingW = (int)sqrt(numTiling);
1037 tilingH = numTiling / tilingW;
1040 leftOver = numTiling - tilingH * tilingW;
1043 tilingSplit = (tilingW - leftOver) * tilingH;
1044 tilingLastH = tilingH+1;
1047 tilingSplit = numTiling;
1049 if(positionID >= tilingSplit)
1051 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1052 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1053 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1054 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1058 x = pw * (positionID / tilingH) / tilingW;
1059 y = ph * (positionID % tilingH) / tilingH;
1060 x2 = pw * (positionID / tilingH + 1) / tilingW;
1061 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1065 SNAPDOWN(x, textCellW);
1066 SNAPDOWN(y, textCellH);
1067 SNAPDOWN(x2, textCellW);
1068 SNAPDOWN(y2, textCellH);
1076 if(sizeAnchor.isClientW) w += ew;
1077 if(sizeAnchor.isClientH) h += eh;
1079 if(anchor.left.type == offset)
1080 x = anchor.left.distance;
1081 else if(anchor.left.type == relative)
1082 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1083 else if(anchor.right.type == relative)
1084 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1085 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1086 else if(anchor.right.type == offset)
1087 ex = vpw - anchor.right.distance;
1089 if(anchor.top.type == offset)
1090 y = anchor.top.distance;
1091 else if(anchor.top.type == relative)
1092 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1093 else if(anchor.bottom.type == relative)
1094 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1095 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1096 else if(anchor.bottom.type == offset)
1097 ey = vph - anchor.bottom.distance;
1099 if(anchor.left.type && anchor.right.type)
1101 switch(anchor.right.type)
1104 ex = pw * (1.0f-anchor.right.percent);
1105 w = Max((int)(ex + 0.5) - x, 0);
1108 ex = vpw - anchor.right.distance;
1109 w = Max((int)(ex + 0.5) - x, 0);
1113 if(anchor.top.type && anchor.bottom.type)
1115 switch(anchor.bottom.type)
1118 ey = ph * (1.0f-anchor.bottom.percent);
1119 h = Max((int)(ey + 0.5) - y, 0);
1122 ey = vph - anchor.bottom.distance;
1123 h = Max((int)(ey + 0.5) - y, 0);
1132 if(state == normal /*|| state == Hidden*/)
1134 bool addSbV = false, addSbH = false;
1136 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1137 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1139 w = Max(w, minSize.w);
1140 h = Max(h, minSize.h);
1141 w = Min(w, maxSize.w);
1142 h = Min(h, maxSize.h);
1144 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1146 if(w) w -= guiApp.currentSkin.VerticalSBW();
1149 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1151 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1155 if(!OnResizing(&w, &h))
1161 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1162 w += guiApp.currentSkin.VerticalSBW();
1163 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1164 h += guiApp.currentSkin.HorizontalSBH();
1166 w = Max(w, skinMinSize.w);
1167 h = Max(h, skinMinSize.h);
1180 SNAPDOWN(w, textCellW);
1181 SNAPDOWN(h, textCellH);
1184 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1186 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1189 (pw - w) / CASCADE_SPACE,
1190 (ph - h) / CASCADE_SPACE);
1196 cascW = (pw - w) / (numCascade-1);
1197 cascH = (ph - h) / (numCascade-1);
1198 SNAPDOWN(cascW, textCellW);
1199 SNAPDOWN(cascH, textCellH);
1200 cascadeW = (float)cascW;
1201 cascadeH = (float)cascH;
1205 numCascade = Max(numCascade, 2);
1206 cascadeW = (float)(pw - w) / (numCascade-1);
1207 cascadeH = (float)(ph - h) / (numCascade-1);
1210 x = (int)((positionID % numCascade) * cascadeW);
1211 y = (int)((positionID % numCascade) * cascadeH);
1213 else if(anchor.left.type < vTiled)
1215 if(!anchor.left.type || anchor.horz.type == middleRelative)
1217 if(!anchor.right.type)
1219 if(anchor.horz.type == middleRelative)
1220 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1222 x = vpw / 2 + anchor.horz.distance - w / 2;
1228 // case A_EDGE: x = x - w; break;
1230 if(!anchor.top.type || anchor.vert.type == middleRelative)
1232 if(!anchor.bottom.type)
1234 if(anchor.vert.type == middleRelative)
1235 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1237 y = vph / 2 + anchor.vert.distance - h / 2;
1243 // case A_EDGE: y = y - h; break;
1246 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1254 SNAPDOWN(x, textCellW);
1255 SNAPDOWN(y, textCellH);
1267 if(anchored && style.fixed && style.isActiveClient)
1272 void UpdateCaret(bool forceUpdate, bool erase)
1274 static Window lastWindow = null;
1275 static int caretX, caretY, caretSize;
1277 if(guiApp && guiApp.caretOwner == this)
1279 int x = caretPos.x - scroll.x;
1280 int y = caretPos.y - scroll.y;
1282 if((erase || this.caretSize) &&
1283 x >= clientArea.left && x <= clientArea.right &&
1284 y >= clientArea.top && y <= clientArea.bottom)
1288 guiApp.interfaceDriver.SetCaret(
1289 x + absPosition.x + clientStart.x,
1290 y + absPosition.y + clientStart.y, this.caretSize);
1291 guiApp.caretEnabled = true;
1293 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1297 if(lastWindow != this)
1299 updateBox.left = x + 1;
1301 updateBox.right = x + 2;
1302 updateBox.bottom = y + this.caretSize - 1;
1306 updateBox.left = Min(x + 1, caretX + 1);
1307 updateBox.top = Min(y, caretY);
1308 updateBox.right = Max(x + 2, caretX + 2);
1309 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1312 guiApp.caretOwner.Update(updateBox);
1319 caretSize = this.caretSize;
1325 guiApp.interfaceDriver.SetCaret(0,0,0);
1326 guiApp.caretEnabled = false;
1332 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1337 scrolledPos.x = position.x = x;
1338 scrolledPos.y = position.y = y;
1340 clientSize.w = size.w = w;
1341 clientSize.h = size.h = h;
1343 if(parent && !style.nonClient)
1345 //if(!style.fixed || style.isDocument)
1347 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1348 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1352 clientStart.x = clientStart.y = 0;
1354 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1356 //if(!activeClient || activeClient.state != maximized)
1357 if(!noAutoScrollArea)
1359 // Check if scroll area must be modified
1360 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1362 bool foundChild = false;
1364 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1365 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1366 for(child = children.first; child; child = child.next)
1368 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1369 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1371 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1372 w = Max(w, child.position.x + child.size.w);
1373 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1374 w = Max(w, Max(child.position.x, 0) + child.size.w);
1375 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1376 h = Max(h, child.position.y + child.size.h);
1377 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1378 h = Max(h, Max(child.position.y, 0) + child.size.h);
1383 if(foundChild && (w > cw || h > ch))
1385 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1387 int stepX = sbStep.x, stepY = sbStep.y;
1388 // Needed to make snapped down position match the skin's check of client area
1389 // against realvirtual
1392 SNAPDOWN(stepX, textCellW);
1393 SNAPDOWN(stepY, textCellH);
1394 stepX = Max(stepX, textCellW);
1395 stepY = Max(stepY, textCellH);
1397 if(scrollFlags.snapX)
1399 if(scrollFlags.snapY)
1402 reqScrollArea.w = w;
1403 reqScrollArea.h = h;
1406 else if(reqScrollArea.w || reqScrollArea.h)
1408 reqScrollArea.w = 0;
1409 reqScrollArea.h = 0;
1410 SetScrollPosition(0,0);
1415 // Automatic MDI Client Scrolling Area Adjustment
1416 if(parent && !parent.noAutoScrollArea)
1418 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1419 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1421 Window parent = this.parent;
1422 int w = parent.reqScrollArea.w;
1423 int h = parent.reqScrollArea.h;
1425 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1426 w = Max(w, position.x + size.w);
1427 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1428 w = Max(w, Max(position.x, 0) + size.w);
1429 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1430 h = Max(h, position.y + size.h);
1431 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1432 h = Max(h, Max(position.y, 0) + size.h);
1434 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1435 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1437 /*bool resize = false;
1438 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1439 // Needed to make snapped down position match the skin's check of client area
1440 // against realvirtual
1443 SNAPDOWN(stepX, textCellW);
1444 SNAPDOWN(stepY, textCellH);
1445 stepX = Max(stepX, textCellW);
1446 stepY = Max(stepY, textCellH);
1448 if(parent.scrollFlags.snapX)
1450 if(parent.scrollFlags.snapY)
1452 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1454 parent.reqScrollArea.w = w;
1455 parent.reqScrollArea.h = h;*/
1457 // parent.UpdateScrollBars(true, true);
1458 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1459 false, true, true, true, false, false);
1464 GetRidOfVirtualArea();
1468 UpdateScrollBars(modifyThisArea, false);
1469 else if(guiApp.currentSkin)
1472 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1474 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1475 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1476 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1477 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1480 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1481 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1483 absPosition = scrolledPos;
1484 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1485 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1487 if(this != guiApp.desktop && parent)
1489 absPosition.x += parent.absPosition.x;
1490 absPosition.y += parent.absPosition.y;
1491 if(!style.nonClient && this != guiApp.desktop)
1493 absPosition.x += parent.clientStart.x;
1494 absPosition.y += parent.clientStart.y;
1498 box = Box { 0, 0, size.w - 1, size.h - 1 };
1503 // Clip against parent's client area
1504 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1506 // Compute client area in this window coordinate system
1507 clientArea.left = 0;
1509 clientArea.right = clientSize.w - 1;
1510 clientArea.bottom = clientSize.h - 1;
1512 // Clip against parent's client area
1514 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1518 //absPosition.x -= parent.clientStart.x;
1519 //absPosition.y -= parent.clientStart.y;
1522 // Adjust all children
1523 for(child = children.first; child; child = child.next)
1524 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1526 UpdateCaret(false, false);
1529 void GetRidOfVirtualArea(void)
1531 if(parent && !parent.destroyed && style.fixed &&
1532 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1533 parent.reqScrollArea.w && parent.reqScrollArea.h)
1535 if(!parent.noAutoScrollArea)
1539 for(child = children.first; child; child = child.next)
1541 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1543 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1544 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1553 Window parent = this.parent;
1555 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1556 false, true, true, true, false, false);
1558 parent.SetScrollArea(0,0,true);
1559 parent.SetScrollPosition(0,0);
1565 public void ExternalPosition(int x, int y, int w, int h)
1567 Position(x, y, w, h, false, true, true, true, false, false);
1570 // (w, h): Full window size
1571 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1573 bool result = false;
1574 int oldCW = clientSize.w, oldCH = clientSize.h;
1575 bool clientResized, windowResized, windowMoved;
1577 bool realResized = size.w != w || size.h != h;
1579 // TOCHECK: This wasn't in ecere.dll
1580 //if(!parent) return true;
1581 if(destroyed) return false;
1583 windowMoved = position.x != x || position.y != y || force;
1585 // windowResized = realResized || force;
1586 windowResized = size.w != w || size.h != h || force;
1588 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1594 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1595 scrolledPos.x - parent.clientStart.x + this.box.right,
1596 scrolledPos.y - parent.clientStart.y + this.box.bottom
1602 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1607 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1609 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1611 if(display && rootWindow != this)
1614 if(guiApp && guiApp.windowMoving)
1616 if(guiApp.windowMoving.style.nonClient)
1617 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1619 guiApp.windowMoving.parent.SetMouseRangeToClient();
1631 // Process Anchored Children
1635 for(child = children.first; child; child = child.next)
1638 ((child.stateAnchor.left.type != offset ||
1639 child.stateAnchor.top.type != offset ||
1640 child.stateAnchor.right.type != none ||
1641 child.stateAnchor.bottom.type != none) ||
1642 child.state == maximized || child.state == minimized))
1644 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1646 // child.Position(x, y, w, h, false, true, true, true, false);
1647 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1648 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1654 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1655 //if(updateScrollBars)
1657 OnResize(clientSize.w, clientSize.h);
1659 if((clientResized || windowMoved) && created)
1660 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1662 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1664 Window master = guiApp.interimWindow.master;
1665 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1668 if(rootWindow == this && !is3D)
1672 x -= guiApp.desktop.absPosition.x;
1673 y -= guiApp.desktop.absPosition.y;
1675 //guiApp.Log("Position %s\n", caption);
1676 if(windowResized || windowMoved)
1677 if(display && !display.flags.memBackBuffer && changeRootWindow)
1678 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1680 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1681 for(child = parent.children.first; child && child != this; child = child.next)
1682 if(child.rootWindow)
1683 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1687 if(windowMoved || windowResized)
1689 display.Lock(true /*false*/);
1692 display.Position(absPosition.x, absPosition.y);
1695 // result = realResized ? display.Resize(size.w, size.h) : true;
1696 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1700 else if(clientResized)
1702 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1705 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1709 if(windowMoved || windowResized)
1714 if(guiApp.driver && changeRootWindow)
1716 if(windowResized || windowMoved)
1717 if(!display || display.flags.memBackBuffer)
1718 guiApp.interfaceDriver.PositionRootWindow(this,
1719 x, y, w, h, windowMoved, windowResized);
1720 guiApp.interfaceDriver.UpdateRootWindow(this);
1722 for(child = children.first; child; child = child.next)
1724 if(child.is3D && child.created)
1726 // Copy Display Content
1727 child.display.displaySystem = display.displaySystem;
1728 child.display.window = display.window;
1729 child.display.current = display.current;
1730 child.display.width = display.width;
1731 child.display.height = display.height;
1732 child.display.driverData = display.driverData;
1733 child.display.mutex = null;
1744 void UpdateScrollBars(bool flag, bool fullThing)
1747 bool resizeH = false, resizeV = false;
1748 bool scrolled = false;
1749 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1750 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1752 if(destroyed) return;
1753 if(guiApp.currentSkin)
1755 MinMaxValue cw = 0, ch = 0;
1756 bool sbvVisible, sbhVisible;
1758 int positionH, positionV;
1760 // First get client area with no respect to scroll bars
1765 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1767 if(scrollFlags.dontHide)
1770 cw -= guiApp.currentSkin.VerticalSBW();
1772 ch -= guiApp.currentSkin.HorizontalSBH();
1774 // Update the scrollbar visibility
1780 sbh.disabled = rangeH <= 1;
1781 if(sbh.style.hidden)
1791 sbv.disabled = rangeV <= 1;
1792 if(sbv.style.hidden)
1800 // Then start off with horizontal scrollbar range
1803 positionH = sbh.thumbPosition;
1808 ch -= guiApp.currentSkin.HorizontalSBH();
1811 // Do the same for vertical scrollbar
1814 positionV = sbv.thumbPosition;
1820 cw -= guiApp.currentSkin.VerticalSBW();
1821 // Maybe we need to set the range on the horizontal scrollbar again
1826 sbh.Action(setRange, positionH, 0);
1827 if(rangeH <= 1 && sbh.range > 1)
1829 ch -= guiApp.currentSkin.HorizontalSBH();
1833 sbv.Action(setRange, positionV, 0);
1840 // Update the scrollbar visibility
1841 if(!scrollFlags.dontHide)
1843 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1847 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1854 if(guiApp.currentSkin)
1861 sbhVisible = sbh.style.hidden ? true : false;
1863 sbvVisible = sbv.style.hidden ? true : false;
1865 // Do our resize here
1866 if(flag && (resizeH || resizeV) && fullThing)
1868 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1873 OnResize(clientSize.w, clientSize.h);
1879 sbh.visible = sbhVisible;
1881 sbv.visible = sbvVisible;
1883 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1884 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1887 sbh.pageStep = clientSize.w;
1889 sbv.pageStep = clientSize.h;
1891 // Notify doesn't handle setRange anymore... process it here
1894 int positionH = sbh.thumbPosition;
1895 if(scroll.x != positionH)
1897 OnHScroll(setRange, positionH, 0);
1901 SNAPDOWN(positionH, textCellW);
1902 scroll.x = positionH;
1908 int seen = clientSize.w, total = reqScrollArea.w;
1911 if(scrollFlags.snapX)
1912 SNAPDOWN(seen, sbStep.x);
1914 if(!total) total = seen;
1915 range = total - seen + 1;
1917 range = Max(range, 1);
1919 if(x >= range) x = range - 1;
1921 if(scrollFlags.snapX)
1922 SNAPUP(x, sbStep.x);
1926 OnHScroll(setRange, x, 0);
1931 SNAPDOWN(x, textCellW);
1937 int positionV = sbv.thumbPosition;
1938 if(scroll.y != positionV)
1940 OnVScroll(setRange, positionV, 0);
1944 SNAPDOWN(positionV, textCellH);
1945 scroll.y = positionV;
1951 int seen = clientSize.h, total = reqScrollArea.h;
1954 if(scrollFlags.snapY)
1955 SNAPDOWN(seen, sbStep.y);
1957 if(!total) total = seen;
1958 range = total - seen + 1;
1959 range = Max(range, 1);
1961 if(y >= range) y = range - 1;
1963 if(scrollFlags.snapY)
1964 SNAPUP(y, sbStep.y);
1968 OnVScroll(setRange, y, 0);
1973 SNAPDOWN(y, textCellH);
1979 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
1982 for(child = children.first; child; child = child.next)
1984 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
1987 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
1988 child.Position(x, y, w, h, false, true, false, true, false, false);
1995 // Process Scrollbars
1997 if(sbh) // && !sbh.style.hidden
1999 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2000 // Need to set the range again (should improve...) since the scrollbars didn't have
2001 // the right size when UpdateScrollArea set the range on it
2004 sbh.seen = clientSize.w;
2008 if(sbv) // && !sbv.state.hidden
2010 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2011 // Need to set the range again (should improve...) since the scrollbars didn't have
2012 // the right size when UpdateScrollArea set the range on it
2015 sbv.seen = clientSize.h;
2020 // TESTING THIS LOWER
2021 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2024 for(child = children.first; child; child = child.next)
2026 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2029 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2030 child.Position(x, y, w, h, false, true, false, true, false, false);
2036 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2038 SetState(maximized, false, mods);
2042 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2044 SetState(normal, false, mods);
2048 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2050 SetState(minimized, false, mods);
2051 parent.CycleChildren(false, true, false, true);
2055 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2058 // Scroll bar notifications
2059 if(action != setRange)
2061 bool changed = false;
2065 if(scroll.x != position)
2067 OnHScroll(action, position, keyFlags);
2072 SNAPDOWN(position, textCellW);
2074 scroll.x = position;
2078 if(scroll.y != position)
2080 OnVScroll(action, position, keyFlags);
2085 SNAPDOWN(position, textCellH);
2087 scroll.y = position;
2091 bool childMove = false;
2092 for(child = children.first; child; child = child.next)
2094 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2097 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2098 child.Position(x, y, w, h, false, true, false, true, false, false);
2102 // Testing this patch out to solve MDI workspace redraw bugs
2103 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2104 // Scroll offsets to blame?
2108 UpdateCaret(false, false);
2112 // Testing this patch out to solve MDI workspace redraw bugs
2113 for(child = children.first; child; child = child.next)
2115 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2124 void CreateSystemChildren(void)
2126 Window parent = this;
2127 bool scrollBarChanged = false;
2128 bool hasClose = false, hasMaxMin = false;
2129 Point scroll = this.scroll;
2131 if(state == maximized && this.parent.menuBar)
2133 if(this.parent.activeClient == this)
2134 parent = this.parent.menuBar;
2141 if(style.hasClose) hasClose = true;
2142 if(style.hasMaximize || style.hasMinimize)
2149 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2151 sysButtons[2].Destroy(0);
2152 sysButtons[2] = null;
2154 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2156 sysButtons[1].Destroy(0);
2157 sysButtons[1] = null;
2159 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2161 sysButtons[0].Destroy(0);
2162 sysButtons[0] = null;
2165 if(hasClose && parent)
2172 parent, master = this,
2173 inactive = true, nonClient = true, visible = false;
2175 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2181 if(this.parent == guiApp.desktop)
2182 sysButtons[2].hotKey = altF4;
2183 else if(style.isActiveClient)
2184 sysButtons[2].hotKey = ctrlF4;
2185 sysButtons[2].Create();
2188 sysButtons[2].symbol = 'X';
2189 sysButtons[2].disabled = !style.hasClose;
2192 if(hasMaxMin && parent)
2196 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2197 if(state == maximized)
2200 method = RestoreButtonClicked;
2206 method = MaximizeButtonClicked;
2214 parent, master = this,
2215 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2217 sysButtons[1].Create();
2219 sysButtons[1].NotifyClicked = method;
2221 sysButtons[1].symbol = symbol;
2222 sysButtons[1].disabled = !style.hasMaximize;
2225 if(hasMaxMin && parent)
2229 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2230 if (state == minimized)
2233 method = RestoreButtonClicked;
2239 method = MinimizeButtonClicked;
2247 parent, master = this,
2248 hotKey = altM, inactive = true, nonClient = true, visible = false
2250 sysButtons[0].Create();
2252 sysButtons[0].NotifyClicked = method;
2254 sysButtons[0].symbol = symbol;
2255 sysButtons[0].disabled = !style.hasMinimize;
2258 // Create the scrollbars
2259 if(style.hasHorzScroll && !sbh)
2265 direction = horizontal,
2269 snap = scrollFlags.snapX,
2270 NotifyScrolling = ScrollBarNotification
2273 scrollBarChanged = true;
2275 else if(sbh && !style.hasHorzScroll)
2281 if(style.hasVertScroll && !sbv)
2287 direction = vertical,
2291 snap = scrollFlags.snapY,
2292 NotifyScrolling = ScrollBarNotification
2295 scrollBarChanged = true;
2297 else if(sbv && !style.hasVertScroll)
2302 if(scrollBarChanged)
2304 SetScrollLineStep(sbStep.x, sbStep.y);
2305 UpdateScrollBars(true, true);
2309 if(scrollBarChanged)
2311 if(sbh) sbh.thumbPosition = scroll.x;
2312 if(sbv) sbv.thumbPosition = scroll.y;
2316 void UpdateCaption(void)
2318 if(rootWindow == this)
2321 FigureCaption(caption);
2322 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2324 UpdateDecorations();
2327 if(parent.rootWindow == parent && parent.activeClient == this) // Added this last check
2330 parent.FigureCaption(caption);
2331 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2333 parent.UpdateDecorations();
2337 void UpdateActiveDocument(Window previous)
2339 Window activeClient = this.activeClient;
2340 Window activeChild = this.activeChild;
2347 activeClient.CreateSystemChildren();
2349 previous.CreateSystemChildren();
2360 if(activeClient && activeClient.menu && activeClient.state != minimized)
2364 //activeClient.menu.Clean(activeClient);
2365 menu.Merge(activeClient.menu, true, activeClient);
2369 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2372 menu.Merge(activeChild.menu, true, activeChild);
2375 // Build window list
2378 Menu windowMenu = menu.FindMenu("Window");
2383 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2386 Window document = cycle.data;
2387 if(!document.style.nonClient && document.style.isActiveClient)
2389 char name[2048], caption[2048];
2390 document.FigureCaption(caption);
2391 sprintf(name, "%d %s", id+1, caption);
2392 windowMenu.AddDynamic(MenuItem
2394 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2395 NotifySelect = MenuWindowSelectWindow
2399 if(activeClient.cycle == cycle) break;
2404 if((!previous && activeClient) || !activeClient)
2410 item = menu.FindItem(MenuWindowCloseAll, 0);
2411 if(item) item.disabled = false;
2412 item = menu.FindItem(MenuWindowNext, 0);
2413 if(item) item.disabled = false;
2414 item = menu.FindItem(MenuWindowPrevious, 0);
2415 if(item) item.disabled = false;
2416 item = menu.FindItem(MenuWindowCascade, 0);
2417 if(item) item.disabled = false;
2418 item = menu.FindItem(MenuWindowTileHorz, 0);
2419 if(item) item.disabled = false;
2420 item = menu.FindItem(MenuWindowTileVert, 0);
2421 if(item) item.disabled = false;
2422 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2423 if(item) item.disabled = false;
2424 item = menu.FindItem(MenuWindowWindows, 0);
2425 if(item) item.disabled = false;
2428 item = menu.FindItem(MenuFileClose, 0);
2429 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2430 item = menu.FindItem(MenuFileSaveAll, 0);
2431 if(item) item.disabled = numDocuments < 1;
2433 // This is called again for a child window change, with same active client
2434 OnActivateClient(activeClient, previous);
2437 void _ShowDecorations(Box box, bool post)
2439 if(rootWindow == this && nativeDecorations) return;
2440 if(visible && this != guiApp.desktop)
2442 Surface surface = RedrawFull(box);
2446 FigureCaption(caption);
2449 ShowDecorations(captionFont.font,
2452 active, //parent.activeClient == this
2453 guiApp.windowMoving == this);
2455 PreShowDecorations(captionFont.font,
2458 active, //parent.activeClient == this
2459 guiApp.windowMoving == this);
2466 void UpdateExtent(Box refresh)
2468 Surface surface = null;
2470 if(!manageDisplay) { OnRedraw(null);return; }
2471 _ShowDecorations(refresh, false);
2473 surface = Redraw(refresh);
2474 // Opaque background: just fill before EW_REDRAW (clear?)
2477 surface.SetBackground(background);
2478 surface.SetForeground(foreground);
2479 surface.DrawingChar(' ');
2480 if(this == rootWindow)
2482 if(style.drawBehind || background.a)
2483 surface.Clear(colorBuffer);
2485 else if(background.a)
2489 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2490 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2493 if(display.flags.alpha && background.a < 255 && background)
2495 surface.Area(0,0,clientSize.w, clientSize.h);
2496 /*if(style.clearDepthBuffer)
2497 surface.Clear(depthBuffer);*/
2499 else if(/*style.clearDepthBuffer || */background.a)
2501 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2502 surface.Clear(colorBuffer);
2507 surface.TextFont(usedFont.font);
2508 surface.TextOpacity(false);
2512 // Draw the caret ...
2513 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2515 // surface.SetBackground(0xFFFFFF - background.color);
2516 surface.SetBackground(~background.color);
2518 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2519 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2525 void DrawOverChildren(Box refresh)
2527 Surface surface = Redraw(refresh);
2531 surface.DrawingChar(' ');
2532 surface.SetBackground(background);
2533 surface.SetForeground(foreground);
2535 surface.TextFont(usedFont.font);
2536 surface.TextOpacity(false);
2538 OnDrawOverChildren(surface);
2543 _ShowDecorations(refresh, true);
2546 void ComputeClipExtents(void)
2549 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2551 clipExtent.Copy(this.clipExtent);
2553 for(child = children.last; child; child = child.prev)
2555 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2557 bool opaque = child.IsOpaque(); // TODO: acess background directly
2558 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2560 child.clipExtent.Copy(clipExtent);
2561 child.clipExtent.Offset(-dx, -dy);
2562 child.clipExtent.IntersectBox(child.box);
2564 child.ComputeClipExtents();
2566 if(opaque && !child.style.nonClient)
2568 // Adjust the box for the parent:
2569 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2570 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2575 // ??? Only do this for overlapped window or if parent has with clip children flag
2577 // Do this if window has clip children flag on (default false?)
2578 // this.clipExtent = clipExtent;
2580 clipExtent.Free(null);
2583 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2585 bool opaque = IsOpaque();
2587 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2588 if(rootWindow.nativeDecorations)
2590 offsetX -= rootWindow.clientStart.x;
2591 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2595 for(child = children.last; child; child = child.prev)
2597 ColorAlpha background = *(ColorAlpha *)&child.background;
2598 bool opaque = child.IsOpaque();
2599 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2603 // Adjust renderArea to the root window level
2604 Extent * renderArea = &rootWindow.tempExtents[1];
2606 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2607 if(child.rootWindow.nativeDecorations)
2609 offsetX -= child.rootWindow.clientStart.x;
2610 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2614 Extent childRenderArea;
2616 if(backBufferUpdate != null)
2618 childRenderArea.Copy(backBufferUpdate);
2619 childRenderArea.Offset(-offsetX, -offsetY);
2622 childRenderArea.Copy(child.dirtyArea);
2624 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2625 renderArea.Copy(dirtyExtent);
2626 renderArea.Offset(-offsetX, -offsetY);
2627 childRenderArea.Union(renderArea);
2630 // Intersect with the clip extent
2631 childRenderArea.Intersection(child.clipExtent);
2634 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2635 renderArea->Offset(offsetX, offsetY);
2636 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2637 // overDirtyExtent.Union(renderArea);
2638 renderArea->Empty();
2639 // childRenderArea.Free();
2641 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2646 for(child = children.last; child; child = child.prev)
2648 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2650 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2655 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2657 bool opaque = IsOpaque();
2658 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2660 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2661 if(rootWindow.nativeDecorations)
2663 offsetX -= rootWindow.clientStart.x;
2664 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2668 for(child = children.last; child; child = child.prev)
2670 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2672 ColorAlpha background = *(ColorAlpha *)&child.background;
2673 bool opaque = child.IsOpaque();
2674 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2678 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2679 // Adjust renderArea to the root window level
2681 renderArea.Copy(child.dirtyArea);
2682 renderArea.Offset(offsetX, offsetY);
2683 dirtyExtent.Union(renderArea);
2684 overDirtyExtent.Union(renderArea);
2690 for(child = children.last; child; child = child.prev)
2692 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2694 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2698 if(backBufferUpdate != null)
2700 renderArea.Copy(backBufferUpdate);
2701 renderArea.Offset(-offsetX, -offsetY);
2703 overRenderArea.Copy(backBufferUpdate);
2704 overRenderArea.Offset(-offsetX, -offsetY);
2710 renderArea.Copy(dirtyArea);
2712 overRenderArea.Copy(dirtyArea);
2715 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2716 dirtyExtentWindow->Copy(dirtyExtent);
2717 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2718 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2719 dirtyExtentWindow->Empty();
2721 // Intersect with the clip extent
2722 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2725 if(renderArea.count > 10)
2728 printf("\nToo many extents (%d):\n", renderArea.count);
2730 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2731 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2736 for(c = 0; c<10; c++)
2739 FASTLIST_LOOP(renderArea, extentBox)
2741 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2743 renderArea.Copy(extent);
2745 FASTLIST_LOOP(renderArea, extentBox)
2748 printf("(%d, %d) - (%d, %d)\n",
2749 extentBox.box.left, extentBox.box.top,
2750 extentBox.box.right, extentBox.box.bottom);
2754 printf("\nNow %d\n", renderArea.count);
2760 // WHY WAS THIS COMMENTED ??
2762 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2763 dirtyExtentWindow->Copy(overDirtyExtent);
2764 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2765 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2766 dirtyExtentWindow->Empty();
2768 // Intersect with the clip extent
2769 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2775 if(scrollExtent.count)
2777 // Subtract render extent from scrolling extent
2778 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2780 if(backBufferUpdate == null)
2782 Extent * dirty = &rootWindow.tempExtents[3];
2785 // Intersect scrolling extent with clip extent
2786 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2788 // offset this scroll to be at the root window level
2789 scrollExtent.Offset(offsetX, offsetY);
2790 // Add area that was scrolled to the dirty extents of the back buffer
2791 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2795 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2796 FASTLIST_LOOP(scrollExtent, scrollBox)
2797 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2802 scrollExtent.Empty();
2804 // Add the exposed extent to the window render area
2805 dirty->Offset(-offsetX, -offsetY);
2806 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2811 // Subtract the window's box from the transparency forced extent
2812 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2818 renderArea.Copy(this.renderArea);
2819 renderArea.Offset(offsetX, offsetY);
2820 dirtyExtent.Union(renderArea);
2826 Extent renderArea { };
2828 renderArea.Copy(overRenderArea);
2829 renderArea.Offset(offsetX, offsetY);
2830 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2835 if(backBufferUpdate != null)
2837 // Remove render area from dirty area
2838 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2840 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2847 // Remove the window render area from the dirty extents of the back buffer
2848 rootWindow.dirtyBack.Exclusion(renderArea);
2852 void Render(Extent updateExtent)
2856 Window rootWindow = this.rootWindow;
2857 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2858 if(rootWindow.nativeDecorations)
2860 offsetX -= rootWindow.clientStart.x;
2861 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2864 if(rootWindow.fullRender)
2873 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2874 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2879 /*if(renderArea.count)
2880 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2883 FASTLIST_LOOP(renderArea, extentBox)
2885 Box box = extentBox.box;
2888 /*printf("(%d, %d) - (%d, %d)\n",
2889 extentBox.box.left, extentBox.box.top,
2890 extentBox.box.right, extentBox.box.bottom);*/
2895 box.left += offsetX;
2897 box.right += offsetX;
2898 box.bottom += offsetY;
2900 if(updateExtent != null)
2901 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2905 for(child = children.first; child; child = child.next)
2906 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
2907 child.Render(updateExtent);
2909 if(rootWindow.fullRender)
2910 DrawOverChildren(box);
2913 // TO DO: There's an issue about draw over children...
2914 // TO DO: Don't wanna go through this if method isn't used
2915 FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
2917 Box box = extentBox.box;
2919 DrawOverChildren(box);
2921 box.left += offsetX;
2923 box.right += offsetX;
2924 box.bottom += offsetY;
2926 if(updateExtent != null)
2927 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2930 for(child = children.first; child; child = child.next)
2931 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
2932 child.Render(updateExtent);
2935 overRenderArea.Empty();
2938 public void UpdateDisplay(void)
2940 if(!manageDisplay) { OnRedraw(null);return; }
2941 if(rootWindow && this != rootWindow)
2942 rootWindow.UpdateDisplay();
2945 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
2946 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
2949 dirtyExtent.Clear();
2952 clipExtent.AddBox(box);
2954 display.StartUpdate();
2956 if(!rootWindow.fullRender)
2958 ComputeClipExtents();
2959 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
2960 ComputeRenderArea(dirtyExtent, overExtent, null);
2963 clipExtent.Free(null);
2965 dirtyExtent.Free(null);
2966 overExtent.Free(null);
2968 if(display.flags.flipping)
2971 display.Update(null);
2975 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
2976 updateExtent.Clear();
2978 Render(updateExtent);
2980 updateExtent.UnionBox(this.box, tempExtents[0]);
2983 //printf("\n\nUpdate:\n------------------------------------------\n");
2986 FASTLIST_LOOP(updateExtent, extentBox)
2989 /*printf("Updating (%d, %d) - (%d, %d)\n",
2990 extentBox.box.left, extentBox.box.top,
2991 extentBox.box.right, extentBox.box.bottom);*/
2994 display.Update(extentBox.box);
2997 updateExtent.Free(null);
3000 display.EndUpdate();
3008 void UpdateBackDisplay(Box box)
3014 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3016 //printf("UpdateBackDisplay going through!\n");
3017 display.StartUpdate();
3021 intersection.Copy(dirtyBack);
3022 intersection.IntersectBox(box);
3024 dirtyExtent.Clear();
3027 clipExtent.AddBox(box);
3029 if(!rootWindow.fullRender)
3031 ComputeClipExtents();
3032 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3035 clipExtent.Free(null);
3037 intersection.Free(null);
3038 dirtyExtent.Free(null);
3039 overExtent.Free(null);
3044 if(display.flags.flipping)
3045 display.Update(null);
3048 rootWindow.display.Update(box);
3051 display.EndUpdate();
3055 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3056 if(dirtyBack.count > MAX_DIRTY_BACK)
3058 BoxItem extentBox, next;
3059 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3060 FASTLIST_LOOPN(dirtyBack, extentBox, next)
3062 if(extentBox != first)
3064 if(extentBox.box.left < first.box.left)
3065 first.box.left = extentBox.box.left;
3066 if(extentBox.box.top < first.box.top)
3067 first.box.top = extentBox.box.top;
3068 if(extentBox.box.right > first.box.right)
3069 first.box.right = extentBox.box.right;
3070 if(extentBox.box.bottom > first.box.bottom)
3071 first.box.bottom = extentBox.box.bottom;
3072 dirtyBack.Delete(extentBox);
3081 // --- Window positioning ---
3082 // --- Window identification ---
3084 // Returns window at position "Position"
3085 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3087 Window child, result = null;
3089 box.left += absPosition.x;
3090 box.right += absPosition.x;
3091 box.top += absPosition.y;
3092 box.bottom += absPosition.y;
3094 if(!destroyed && visible && (acceptDisabled || !disabled))
3096 int lx = x - absPosition.x;
3097 int ly = y - absPosition.y;
3098 if(IsInside(lx, ly))
3099 // if(box.IsPointInside(Point{x, y}))
3101 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3102 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3105 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3107 if(child != statusBar && child.rootWindow == rootWindow)
3109 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3116 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3118 if(child != statusBar && child.rootWindow == rootWindow)
3120 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3132 Window FindModal(void)
3134 Window modalWindow = this, check;
3135 Window check2 = null;
3136 for(check = this; check.master; check = check.master)
3138 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3140 modalWindow = check.master.modalSlave;
3141 check = modalWindow;
3143 // TESTING THIS FOR DROPBOX...
3144 if(!rootWindow || !rootWindow.style.interim)
3146 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3148 if(check2.modalSlave && check2.modalSlave.created)
3150 modalWindow = check2.modalSlave;
3158 if(modalWindow == this)
3160 for(check = this; check.activeChild; check = check.activeChild)
3162 if(check.modalSlave)
3164 modalWindow = check.modalSlave;
3170 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3171 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3174 void StopMoving(void)
3176 if(this == guiApp.windowMoving)
3178 guiApp.windowMoving = null;
3179 UpdateDecorations();
3180 SetMouseRange(null);
3183 if(rootWindow.active)
3184 guiApp.interfaceDriver.StopMoving(rootWindow);
3187 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3188 guiApp.windowIsResizing = false;
3192 void SelectMouseCursor(void)
3197 Window cursorWindow = null;
3198 bool rx, ry, rex, rey;
3200 guiApp.desktop.GetMousePosition(&x, &y);
3201 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3203 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3204 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3205 else if(mouseWindow)
3207 modalWindow = mouseWindow.FindModal();
3208 x -= mouseWindow.absPosition.x;
3209 y -= mouseWindow.absPosition.y;
3210 if(guiApp.windowIsResizing)
3212 rex = guiApp.resizeEndX;
3213 rey = guiApp.resizeEndY;
3214 rx = guiApp.resizeX;
3215 ry = guiApp.resizeY;
3216 if((rex && rey) || (rx && ry))
3217 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3218 else if((rex && ry) || (rx && rey))
3219 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3220 else if((ry || rey) && (!rx && !rex))
3221 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3222 else if((rx || rex) && (!ry && !rey))
3223 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3225 else if(!modalWindow && !guiApp.windowCaptured &&
3226 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3227 &rx, &ry, &rex, &rey))
3229 if((rex && rey) || (rx && ry))
3230 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3231 else if((rex && ry) || (rx && rey))
3232 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3233 else if((ry || rey) && (!rx && !rex))
3234 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3235 else if((rx || rex) && (!ry && !rey))
3236 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3238 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3240 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3241 cursorWindow = mouseWindow.parent;
3243 cursorWindow = mouseWindow;
3245 else if(!guiApp.interimWindow)
3246 cursorWindow = guiApp.windowCaptured;
3249 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3250 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3252 else if(modalWindow)
3254 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3256 else if(guiApp.interimWindow)
3258 if(guiApp.interimWindow.cursor)
3259 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3261 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3266 // --- State based input ---
3267 bool AcquireInputEx(bool state)
3272 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3273 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3275 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3277 guiApp.acquiredWindow = state ? this : null;
3280 SetMouseRangeToClient();
3281 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3286 SelectMouseCursor();
3288 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3292 // --- Window activation ---
3293 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3296 if(!parent || !parent.style.inactive)
3298 Window parent = this.parent;
3301 if(rootWindow == this)
3302 Log(active ? "active\n" : "inactive\n");
3305 // Testing this here...
3306 if(!parent || parent == guiApp.desktop || parent.active)
3308 this.active = active;
3311 // TESTING THIS HERE
3312 UpdateDecorations();
3313 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3314 result = NotifyActivate(master, this, active, previous);
3317 this.active = !active;
3322 if(!parent || parent == guiApp.desktop || parent.active)
3324 this.active = active;
3326 AcquireInputEx(active);
3331 if(guiApp.caretOwner)
3335 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3336 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3337 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3338 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3340 guiApp.caretOwner.Update(extent);
3343 if(visible || !guiApp.caretOwner)
3344 guiApp.caretOwner = this;
3345 UpdateCaret(false, false);
3351 this.active = false;
3353 AcquireInputEx(active);
3355 if(!active && guiApp.caretOwner == this)
3357 UpdateCaret(false, true);
3358 guiApp.caretOwner = null;
3359 guiApp.interfaceDriver.SetCaret(0,0,0);
3360 guiApp.caretEnabled = false;
3365 if(!active && parent && parent.activeChild && parent.activeChild != this)
3366 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3372 if(!active && menuBar)
3375 menuBar.OnActivate(false, null, &goOn, true);
3376 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3380 if(!activeChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3389 void ConsequentialMouseMove(bool kbMoving)
3393 if(kbMoving || !guiApp.windowMoving)
3397 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3399 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3401 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3402 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3408 bool IsDescendantOf(Window ancestor)
3411 for(window = this; window && window != ancestor; window = window.parent);
3412 return window == ancestor;
3415 bool IsSlaveOf(Window master)
3418 for(window = this; window && window != master; window = window.master);
3419 return window == master;
3422 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3426 if(this && !destroyed /*&& state != Hidden*/)
3428 Window swap = externalSwap;
3436 if(activateParent &&
3437 (parent.activeChild != this ||
3438 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3439 active && style.modal &&
3440 parent != master && master)
3441 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3447 bool real = parent.activeChild != this;
3449 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3450 if(/*activateParent && */guiApp.interimWindow &&
3451 !IsDescendantOf(guiApp.interimWindow) &&
3452 !IsSlaveOf(guiApp.interimWindow))
3454 Window interimWindow = guiApp.interimWindow;
3455 while(interimWindow && interimWindow != this)
3457 Window master = interimWindow.master;
3459 guiApp.interimWindow = null;
3460 if(guiApp.caretOwner)
3461 guiApp.caretOwner.UpdateCaret(false, false);
3463 incref interimWindow;
3464 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3469 delete interimWindow;
3470 interimWindow = (master && master.style.interim) ? master : null;
3475 guiApp.interimWindow = this;
3476 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3477 guiApp.caretEnabled = false;*/
3478 UpdateCaret(false, true);
3483 bool acquireInput = false;
3485 parent.activeChild &&
3486 parent.activeChild.state == maximized &&
3487 parent != guiApp.desktop;
3489 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3494 swap = parent.activeChild;
3495 if(swap && swap.destroyed) swap = null;
3496 if(swap && swap != this)
3499 if(!swap.PropagateActive(false, this, &goOn, true))
3500 swap = parent.activeChild;
3511 if(!parent || parent.activeChild != this || style.interim)
3514 result = PropagateActive(true, swap, &goOn, true);
3515 if(!result && !goOn)
3520 acquireInput = true;
3524 if(style.hasMaximize && parent != guiApp.desktop)
3527 SetState(maximized, false, 0);
3528 else if(state != maximized)
3531 for(child = parent.children.first; child; child = child.next)
3533 if(this != child && child.state == maximized)
3534 child.SetState(normal, false, 0);
3541 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3543 Window previous = parent.activeClient;
3544 parent.activeChild = this;
3545 if(!style.nonClient /*&& style.isActiveClient*/)
3547 if(style.isActiveClient && !style.hidden)
3548 parent.activeClient = this;
3549 parent.UpdateActiveDocument(previous);
3554 //if(!style.isRemote)
3556 if(rootWindow != this)
3558 if(activateParent && !parent.active /*parent != parent.parent.activeChild*/)
3559 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3561 else if(!guiApp.fullScreenMode)
3563 Window modalRoot = FindModal();
3564 if(!modalRoot) modalRoot = this;
3565 if(!modalRoot.isForegroundWindow)
3567 modalRoot.isForegroundWindow = true;
3568 // To check : Why is parent null?
3569 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3571 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3573 modalRoot.isForegroundWindow = false;
3578 if(result && real && (!style.inactive || moveInactive) && parent)
3580 Window last = parent.children.last;
3582 if(!style.stayOnTop)
3583 for(; last && last.style.stayOnTop; last = last.prev);
3585 parent.children.Move(this, last);
3587 // Definitely don't want that: why not?
3591 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3597 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3604 parent.activeChild = null;
3605 if(!style.nonClient /*&& style.isActiveClient*/)
3607 Window previous = parent.activeClient;
3608 if(style.isActiveClient)
3609 parent.activeClient = null;
3610 parent.UpdateActiveDocument(previous);
3614 if(this == guiApp.interimWindow)
3616 guiApp.interimWindow = null;
3617 if(guiApp.caretOwner)
3618 guiApp.caretOwner.UpdateCaret(false, false);
3620 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3627 if(!active || !swap)
3628 UpdateDecorations();
3630 swap.UpdateDecorations();
3632 if(active && rootWindow != this)
3633 ConsequentialMouseMove(false);
3640 // --- Input Messages ---
3641 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3643 static bool reEntrancy = false;
3644 if(reEntrancy) return;
3648 guiApp.cursorUpdate = true;
3649 if(guiApp.windowScrolling && !consequential)
3651 guiApp.windowScrolling.SetScrollPosition(
3652 (guiApp.windowScrolling.sbh) ?
3653 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3654 (guiApp.windowScrolling.sbv) ?
3655 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3657 if(guiApp.windowMoving)
3659 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3661 Window window = guiApp.windowMoving;
3663 int w = window.size.w;
3664 int h = window.size.h;
3669 rx = mouseX - guiApp.windowMovingStart.x;
3670 ry = mouseY - guiApp.windowMovingStart.y;
3673 window.GetDecorationsSize(&ew, &eh);
3675 if(guiApp.windowIsResizing)
3677 x = window.scrolledPos.x;
3678 y = window.scrolledPos.y;
3682 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3683 rx = guiApp.windowResizingBefore.w - aw;
3684 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3685 w = guiApp.windowResizingBefore.w - rx;
3689 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3690 ry = guiApp.windowResizingBefore.h - ah;
3691 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3692 ry = Max(ry, -guiApp.windowMovingBefore.y);
3693 h = guiApp.windowResizingBefore.h - ry;
3695 if(guiApp.resizeEndX)
3697 w = guiApp.windowResizingBefore.w + rx;
3700 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3708 w = Max(w, window.minSize.w);
3709 h = Max(h, window.minSize.h);
3710 w = Min(w, window.maxSize.w);
3711 h = Min(h, window.maxSize.h);
3713 if(!window.OnResizing(&w, &h))
3715 w = window.clientSize.w;
3716 h = window.clientSize.h;
3719 w = Max(w, window.skinMinSize.w);
3720 h = Max(h, window.skinMinSize.h);
3727 SNAPDOWN(w, textCellW);
3728 SNAPDOWN(h, textCellH);
3733 aw = Max(w,window.skinMinSize.w);
3734 rx = guiApp.windowResizingBefore.w - aw;
3735 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3736 w = guiApp.windowResizingBefore.w - rx;
3740 ah = Max(h,window.skinMinSize.h);
3741 ry = guiApp.windowResizingBefore.h - ah;
3742 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3743 ry = Max(ry, -guiApp.windowMovingBefore.y);
3744 h = guiApp.windowResizingBefore.h - ry;
3749 if(!guiApp.windowIsResizing || guiApp.resizeX)
3750 x = guiApp.windowMovingBefore.x + rx;
3751 if(!guiApp.windowIsResizing || guiApp.resizeY)
3752 y = guiApp.windowMovingBefore.y + ry;
3754 if(!guiApp.windowIsResizing)
3757 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3759 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3760 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3761 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3762 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3766 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3767 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3773 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3775 if(!window.OnMoving(&x, &y, w, h))
3777 x = window.scrolledPos.x;
3778 y = window.scrolledPos.y;
3784 SNAPDOWN(x, textCellW);
3785 SNAPDOWN(y, textCellH);
3788 if(!window.style.nonClient)
3790 if(!window.style.fixed /*|| window.style.isDocument*/)
3792 if(!window.style.dontScrollHorz)
3793 x += window.parent.scroll.x;
3794 if(!window.style.dontScrollVert)
3795 y += window.parent.scroll.y;
3799 // Break the anchors for moveable/resizable windows
3800 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3801 if(window.style.fixed)
3803 if(window.state == normal)
3805 window.normalAnchor = Anchor { left = x, top = y };
3806 window.normalSizeAnchor = SizeAnchor { { w, h } };
3807 window.anchored = false;
3811 window.stateAnchor = Anchor { left = x, top = y };
3812 window.stateSizeAnchor = SizeAnchor { { w, h } };
3814 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3815 // TOCHECK: Investigate why the following only redraws the scrollbars
3816 //window.Position(x, y, w, h, false, true, true, true, false, true);
3818 guiApp.movingLast.x = mouseX;
3819 guiApp.movingLast.y = mouseY;
3825 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3828 bool wasMoving = guiApp.windowMoving ? true : false;
3829 bool wasScrolling = guiApp.windowScrolling ? true : false;
3831 while(result && w != this)
3833 Window msgWindow = GetAtPosition(x,y, false, true, w);
3834 Window trueWindow = GetAtPosition(x,y, false, false, w);
3835 bool windowDragged = false;
3840 window = (w && !w.disabled) ? w : null;
3842 if(trueWindow) incref trueWindow;
3844 if(consequential) mods->isSideEffect = true;
3846 UpdateMouseMove(x, y, consequential);
3848 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3850 if(!guiApp.windowCaptured.isEnabled)
3851 guiApp.windowCaptured.ReleaseCapture();
3853 window = guiApp.windowCaptured;
3856 if(trueWindow && activate &&
3857 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3858 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3859 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3860 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3862 Window modalWindow = trueWindow.FindModal();
3864 if(mods->alt && !mods->ctrl && !mods->shift)
3866 Window moved = trueWindow;
3867 for(moved = trueWindow; moved; moved = moved.parent)
3868 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3873 windowDragged = true;
3875 // Cancel the ALT menu toggling...
3876 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3881 if(window && activate &&
3882 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3883 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3884 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3885 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3887 Window modalWindow = window.FindModal();
3889 /*if(mods->alt && !mods->shift && !mods->ctrl)
3891 Window moved = window;
3892 for(moved = window; moved; moved = moved.parent)
3893 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3898 windowDragged = true;
3900 // Cancel the ALT menu toggling...
3901 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
3907 Window activateWindow = modalWindow ? modalWindow : window;
3908 if(activateWindow && !activateWindow.isRemote)
3910 bool doActivation = true;
3911 //bool needToDoActivation = false;
3912 Window check = activateWindow;
3914 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
3916 if(!check.style.inactive)
3918 //needToDoActivation = true;
3920 doActivation = false;
3925 if(!needToDoActivation)
3926 doActivation = false;
3929 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
3930 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
3934 incref activateWindow;
3935 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
3937 delete activateWindow;
3941 if(activateWindow._refCount == 1)
3943 delete activateWindow;
3947 delete activateWindow;
3949 mods->isActivate = true;
3953 if(!modalWindow && window && !window.destroyed)
3955 if(!guiApp.windowCaptured || windowDragged)
3957 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
3959 bool moving = ((window.state != maximized &&
3960 window.IsMouseMoving(
3961 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
3962 || (guiApp.windowMoving && !guiApp.windowIsResizing);
3964 if(!moving && window.IsMouseResizing(
3965 x - window.absPosition.x,
3966 y - window.absPosition.y,
3967 window.size.w, window.size.h,
3968 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
3970 guiApp.windowIsResizing = true;
3971 guiApp.windowResizingBefore.w = window.size.w;
3972 guiApp.windowResizingBefore.h = window.size.h;
3974 if(guiApp.windowIsResizing || windowDragged || moving)
3977 guiApp.windowMoving = window;
3978 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
3979 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
3980 guiApp.windowMovingBefore.x = window.position.x;//s;
3981 guiApp.windowMovingBefore.y = window.position.y;//s;
3982 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
3983 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
3986 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
3988 if(window.style.fixed &&
3990 window.IsMouseMoving(
3991 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
3993 window.ShowSysMenu(x, y);
3997 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
3999 if(window.sbv || window.sbh)
4002 guiApp.windowScrolling = window;
4003 guiApp.windowScrollingStart.x = x;
4004 guiApp.windowScrollingStart.y = y;
4005 guiApp.windowScrollingBefore.x = window.scroll.x;
4006 guiApp.windowScrollingBefore.y = window.scroll.y;
4009 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4011 if(window.style.hasMaximize &&
4012 window.IsMouseMoving(
4013 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4016 (window.state == maximized) ? normal : maximized, false, *mods);
4024 if(guiApp.windowMoving)
4026 if(guiApp.windowMoving.parent)
4028 if(guiApp.windowMoving.style.nonClient)
4029 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4031 guiApp.windowMoving.parent.SetMouseRangeToClient();
4035 window.UpdateDecorations();
4038 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4040 // Log("\n*** LEFT BUTTON UP ***\n");
4041 if(guiApp.windowMoving)
4042 guiApp.windowMoving.StopMoving();
4044 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4046 if(guiApp.windowScrolling)
4048 Window windowScrolling = guiApp.windowScrolling;
4049 guiApp.windowScrolling = null;
4050 windowScrolling.ReleaseCapture();
4054 if(!result || (window && window.destroyed)) window = null;
4056 if(window && window.FindModal())
4059 if(trueWindow && trueWindow.FindModal())
4067 msgWindow = GetAtPosition(x,y, true, false);
4069 msgWindow.SelectMouseCursor();
4072 if(guiApp.windowCaptured || trueWindow)
4074 Window prevWindow = guiApp.prevWindow;
4075 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4077 guiApp.prevWindow.mouseInside = false;
4078 guiApp.prevWindow = null;
4080 // Eventually fix this not to include captured?
4081 if(!prevWindow.OnMouseLeave(*mods))
4084 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4086 Box box = trueWindow.box;
4087 box.left += trueWindow.absPosition.x;
4088 box.right += trueWindow.absPosition.x;
4089 box.top += trueWindow.absPosition.y;
4090 box.bottom += trueWindow.absPosition.y;
4092 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4094 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4095 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4097 overX = Max(Min(overX, 32767),-32768);
4098 overY = Max(Min(overY, 32767),-32768);
4100 trueWindow.mouseInside = true;
4101 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4105 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4106 guiApp.prevWindow = trueWindow;
4108 guiApp.prevWindow = null;
4110 SelectMouseCursor();
4112 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4114 int clientX = x - (window.absPosition.x + window.clientStart.x);
4115 int clientY = y - (window.absPosition.y + window.clientStart.y);
4117 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4119 clientX = Max(Min(clientX, 32767),-32768);
4120 clientY = Max(Min(clientY, 32767),-32768);
4122 MouseMethod = (void *)window._vTbl[method];
4124 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4127 if(!MouseMethod(window, clientX, clientY, *mods))
4134 if(result && w && w.clickThrough && w.parent)
4139 if(!result || !w || !w.clickThrough)
4146 // --- Mouse cursor management ---
4148 bool KeyMessage(uint method, Key key, unichar character)
4153 if(guiApp.interimWindow)
4154 this = guiApp.interimWindow;
4157 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4161 if(!style.inactive || rootWindow != this)
4163 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4164 Window modalWindow = FindModal();
4165 Window interimMaster = master ? master.rootWindow : null;
4169 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4170 status = OnSysKeyDown(key, character);
4171 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4172 status = OnSysKeyHit(key, character);
4173 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4174 status = OnSysKeyUp(key, character);
4181 // Process Key Message for Internal UI Keyboard actions
4182 if(status && !destroyed && menuBar && state != minimized)
4185 if((SmartKey)key != alt)
4186 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4189 SmartKey sk = (SmartKey) key;
4190 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4192 status = menuBar.KeyMessage(method, key, character);
4197 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4198 menuBar.OnKeyHit(escape, 0);
4200 if(!menuBar.focus && guiApp.caretOwner)
4201 guiApp.caretOwner.UpdateCaret(true, false);
4204 if(!destroyed && status)
4206 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4210 case left: case up: case right: case down:
4211 if(guiApp.windowMoving == this)
4214 int w = guiApp.windowMoving.size.w;
4215 int h = guiApp.windowMoving.size.h;
4216 int x = guiApp.windowMoving.scrolledPos.x;
4217 int y = guiApp.windowMoving.scrolledPos.y;
4221 if(key == down || key == up)
4222 step = Max(step, textCellH);
4224 step = Max(step, textCellW);
4227 if(guiApp.windowIsResizing)
4231 case left: w-=step; break;
4232 case right: w+=step; break;
4233 case up: h-=step; break;
4234 case down: h+=step; break;
4241 case left: x-=step; break;
4242 case right: x+=step; break;
4243 case up: y-=step; break;
4244 case down: y+=step; break;
4248 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4249 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4251 if(!guiApp.windowIsResizing || guiApp.resizeX)
4252 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4254 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4256 if(!guiApp.windowIsResizing || guiApp.resizeY)
4257 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4259 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4261 guiApp.interfaceDriver.SetMousePosition(x, y);
4262 ConsequentialMouseMove(true);
4270 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4272 guiApp.windowMoving.StopMoving();
4273 ConsequentialMouseMove(false);
4281 ShowSysMenu(absPosition.x, absPosition.y);
4289 if(!destroyed && status && state != minimized)
4291 // Process all the way down the children
4292 if(activeChild && !activeChild.disabled)
4294 status = activeChild.KeyMessage(method, key, character);
4296 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4297 key.code != left && key.code != right && key.code != up && key.code != down)
4299 status = activeClient.KeyMessage(method, key, character);
4303 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4305 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4306 // && defaultControl != activeChild)
4308 delete previousActive;
4309 previousActive = activeChild;
4310 if(previousActive) incref previousActive;
4312 ConsequentialMouseMove(false);
4313 if((defaultControl.active ||
4314 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4315 defaultControl.KeyMessage(method, defaultKey, character);
4321 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4323 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4330 ShowSysMenu(absPosition.x, absPosition.y);
4337 if(this != guiApp.desktop)
4339 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4341 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4343 MenuMoveOrSize(key.shift, true);
4347 else if(guiApp.windowMoving)
4349 guiApp.windowMoving.StopMoving();
4350 ConsequentialMouseMove(false);
4358 if(!destroyed && status && state != minimized)
4360 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4364 case tab: case shiftTab:
4366 Window cycleParent = this;
4367 if(this == guiApp.interimWindow && !master.style.interim && !cycleParent.style.tabCycle)
4368 cycleParent = master.parent;
4370 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4372 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4374 Window child = cycleParent.activeChild;
4376 // Scroll the window to include the active control
4378 if(cycleParent.sbh && !child.style.dontScrollHorz)
4380 if(child.scrolledPos.x < 0)
4381 cycleParent.sbh.Action(Position,
4382 cycleParent.scroll.x + child.scrolledPos.x, 0);
4383 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4384 cycleParent.sbh.Action(Position,
4385 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4387 if(cycleParent.sbv && !child.style.dontScrollVert)
4389 if(child.scrolledPos.y < 0)
4390 cycleParent.sbv.Action(Position,
4391 cycleParent.scroll.y + child.scrolledPos.y, 0);
4392 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4393 cycleParent.sbv.Action(Position,
4394 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4397 cycleParent.ConsequentialMouseMove(false);
4403 case f6: case shiftF6:
4404 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4406 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4407 if(parent == guiApp.desktop)
4408 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4413 if(style.tabCycle ||
4414 CycleChildren(key.shift, true, false, true))
4422 // mIRC Style Window Shortcuts
4423 case alt1: case alt2: case alt3: case alt4: case alt5:
4424 case alt6: case alt7: case alt8: case alt9: case alt0:
4429 for(document = children.first; document; document = document.next)
4431 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4433 if(document == activeChild)
4435 if(document.state == minimized)
4436 document.SetState(normal, false, key);
4439 document.SetState(minimized, false, key);
4440 CycleChildren(false, true, false);
4445 if(activeChild.state == maximized && document.style.hasMaximize)
4446 document.SetState(maximized, false, key);
4447 else if(document.state == minimized)
4448 document.SetState(normal, false, key);
4449 document.Activate();
4464 if(!destroyed && status)
4466 if(state == minimized)
4471 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4473 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4475 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4476 previousActive.ActivateEx(true, false, false, true, null, null);
4477 delete previousActive;
4483 if(!destroyed && status)
4485 status = ProcessHotKeys(method, key, character);
4487 if(!destroyed && status && !modalWindow && state != minimized)
4490 status = KeyMethod(this, key, character);
4491 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4492 status = OnKeyHit(key, character);
4493 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4495 bool result = false;
4498 case ctrlUp: case ctrlDown:
4499 if(sbv && !guiApp.windowScrolling)
4500 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4502 case wheelUp: case wheelDown:
4503 if(sbv && !guiApp.windowScrolling)
4505 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4506 // Do we want to do a consequential move regardless of result in this case?
4507 ConsequentialMouseMove(false);
4510 case ctrlPageUp: case ctrlPageDown:
4511 if(sbh && !guiApp.windowScrolling)
4512 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4517 ConsequentialMouseMove(false);
4522 if(status && !destroyed && menuBar && state != minimized)
4523 status = menuBar.KeyMessage(method, key, character);
4525 if(style.interim && /*destroyed && */status && interimMaster)
4527 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4528 status = interimMaster.KeyMessage(method, key, character);
4535 bool ProcessHotKeys(uint method, Key key, unichar character)
4540 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4541 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4542 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4544 Window hotKeyWindow = hotKey.window;
4545 Window parent = hotKeyWindow.parent;
4546 Window prevActiveWindow = activeChild;
4548 // Don't process non-visible buttons, but make an exception for the Alt-F4 with Native Decorations turned on
4549 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || hotKeyWindow != parent.sysButtons[2]))
4552 if(prevActiveWindow) incref prevActiveWindow;
4553 incref hotKeyWindow;
4554 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4555 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4558 delete hotKeyWindow;
4559 delete prevActiveWindow;
4563 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4564 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4565 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4567 // ********* WORKING ON THIS ***********
4568 if(prevActiveWindow && !guiApp.interimWindow)
4569 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4572 else if(hotKeyWindow.style.inactive)
4573 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4575 delete prevActiveWindow;
4576 delete hotKeyWindow;
4577 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4578 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4582 if(status && tabCycle)
4585 for(child = children.first; child; child = child.next)
4587 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4598 // --- Windows and graphics initialization / termination ---
4599 bool SetupRoot(void)
4603 // Setup relationship with outside world (bb root || !bb)
4604 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4605 (displayDriver && displayDriver != parent.displayDriver))
4609 tempExtents = new0 Extent[4];
4614 /*if(guiApp.fullScreenMode)
4615 rootWindow = guiApp.desktop;
4617 //rootWindow = parent.created ? parent.rootWindow : null;
4618 rootWindow = parent.rootWindow;
4621 against = &parent.box;
4623 against = &parent.clientArea;
4626 for(child = children.first; child; child = child.next)
4629 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4632 bool Setup(bool positionChildren)
4634 bool result = false;
4637 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (displayDriver && displayDriver != parent.displayDriver))))
4639 subclass(DisplayDriver) dDriver = dispDriver ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4640 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4642 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4644 // This was here, is it really needed?
4645 //guiApp.interfaceDriver.ActivateRootWindow(this);
4649 displaySystem = DisplaySystem {};
4650 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4652 delete displaySystem;
4657 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4658 if(display.Create(displaySystem, windowHandle))
4665 guiApp.interfaceDriver.SetIcon(this, icon);
4667 else if(this != guiApp.desktop)
4669 display = rootWindow ? rootWindow.display : null;
4675 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4676 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4678 for(child = children.first; child; child = child.next)
4680 if(child.created && !child.Setup(false))
4686 bool SetupDisplay(void)
4688 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4689 if(is3D) return Window3D_SetupDisplay(this); else
4696 class_data void ** pureVTbl;
4698 bool LoadGraphics(bool creation, bool resetAnchors)
4700 bool result = false;
4701 bool success = false;
4705 if(!rootWindow.created)
4709 if(((subclass(Window))_class).pureVTbl)
4711 if(_vTbl == _class._vTbl)
4713 _vTbl = ((subclass(Window))_class).pureVTbl;
4718 for(m = 0; m < _class.vTblSize; m++)
4720 if(_vTbl[m] == _class._vTbl[m])
4721 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4725 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4727 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4729 _vTbl = _class._vTbl;
4734 for(m = 0; m < _class.vTblSize; m++)
4736 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4737 _vTbl[m] = _class._vTbl[m];
4742 if(guiApp.fullScreenMode || this != guiApp.desktop)
4744 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4750 display.Lock(false);
4751 if(rootWindow == this)
4753 // Set Color Palette
4754 display.SetPalette(palette, true);
4758 if(guiApp.fullScreenMode && this == guiApp.desktop)
4763 for(c=0; c<SystemCursor::enumSize; c++)
4764 if(!guiApp.systemCursors[c].bitmap)
4766 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4767 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4768 if(guiApp.systemCursors[c].bitmapName)
4770 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4771 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4772 if(guiApp.systemCursors[c].bitmap)
4773 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4778 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4780 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4781 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4783 cursor.bitmap.paletteShades = cursor.paletteShades;
4787 guiApp.cursorUpdate = true;
4790 ConsequentialMouseMove(false);
4796 // Load Window Graphic Resources
4799 if(usedFont == setFont || usedFont == window.systemFont)
4800 RemoveResource(usedFont);
4803 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4806 RemoveResource(systemFont);
4809 RemoveResource(captionFont);
4811 for(ptr = resources.first; ptr; ptr = ptr.next)
4813 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4816 AddResource(setFont);
4818 AddResource(systemFont);
4820 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4827 //if(master && master.font)
4828 if(parent && parent.font)
4832 faceName = parent.font.faceName,
4833 size = parent.font.size,
4834 bold = parent.font.bold,
4835 italic = parent.font.italic,
4836 underline = parent.font.underline
4838 //font = parent.font;
4839 watch(parent) { font { } };
4842 font = guiApp.currentSkin.SystemFont();
4849 captionFont = guiApp.currentSkin.CaptionFont();
4850 AddResource(captionFont);
4852 if(OnLoadGraphics())
4858 //SetScrollLineStep(sbStep.x, sbStep.y);
4860 if(this != guiApp.desktop)
4864 normalAnchor = anchor;
4865 normalSizeAnchor = sizeAnchor;
4868 // Break the anchors for moveable/resizable windows
4870 if(style.fixed && style.isDocument)
4872 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
4884 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
4885 stateSizeAnchor = SizeAnchor {};
4890 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
4895 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
4896 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
4899 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
4903 stateAnchor = normalAnchor;
4904 stateSizeAnchor = normalSizeAnchor;
4907 position = Point { };
4908 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
4919 if(Position(x, y, w, h, true, false, true, true, true, true))
4921 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
4924 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
4941 success = result = true;
4944 if(!creation && result)
4946 // Load menu bar first because sys buttons are on it...
4949 if(!menuBar.LoadGraphics(false, resetAnchors))
4955 for(child = children.first; child; child = child.next)
4957 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
4964 CreateSystemChildren();
4968 if(this == guiApp.desktop && !guiApp.fullScreenMode)
4971 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
4976 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
4977 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
4982 void UnloadGraphics(bool destroyWindows)
4986 // Free children's graphics
4987 for(child = children.first; child; child = child.next)
4988 child.UnloadGraphics(destroyWindows);
4991 display.Lock(false);
4994 if(guiApp.fullScreenMode && this == guiApp.desktop)
4999 for(c=0; c<SystemCursor::enumSize; c++)
5000 if(guiApp.systemCursors[c].bitmap)
5001 delete guiApp.systemCursors[c].bitmap;
5003 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5004 delete cursor.bitmap;
5006 guiApp.cursorBackground.Free();
5009 if(display && display.displaySystem)
5013 for(ptr = resources.first; ptr; ptr = ptr.next)
5017 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5022 // Free window graphics
5025 // Free skin graphics
5026 if(rootWindow == this)
5028 DisplaySystem displaySystem = display.displaySystem;
5031 display.driverData = null;
5032 display.displaySystem = null;
5036 if(displaySystem && !displaySystem.numDisplays && !is3D)
5037 delete displaySystem;
5046 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5047 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5049 if(this == guiApp.desktop || parent == guiApp.desktop)
5051 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5052 guiApp.interfaceDriver.DestroyRootWindow(this);
5056 // --- Window Hiding ---
5058 void SetVisibility(bool state)
5060 bool visible = (style.hidden || !created) ? false : state;
5061 if(visible != this.visible)
5065 this.visible = visible;
5066 for(child = children.first; child; child = child.next)
5067 child.SetVisibility(visible);
5069 ConsequentialMouseMove(false);
5073 // --- Windows and graphics initialization / termination ---
5075 bool DisplayModeChanged(void)
5077 bool result = false;
5078 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5080 guiApp.modeSwitching = true;
5081 UnloadGraphics(false);
5083 if(LoadGraphics(false, false))
5085 guiApp.modeSwitching = false;
5090 // --- Window updates system ---
5092 void UpdateDirty(Box updateBox)
5094 if(!manageDisplay) { OnRedraw(null);return; }
5097 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5100 if(display.flags.flipping)
5103 rootWindow.UpdateDisplay();
5106 UpdateBackDisplay(updateBox);
5108 if(guiApp.fullScreenMode)
5110 guiApp.cursorUpdate = true;
5111 guiApp.PreserveAndDrawCursor();
5113 if(guiApp.fullScreenMode)
5114 guiApp.RestoreCursorBackground();
5120 // This function is strictly called as a result of system window activation
5121 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5124 Window interimMaster = null;
5125 Window interimWindow = guiApp.interimWindow;
5126 if(interimWindow && interimWindow.master)
5127 interimMaster = interimWindow.master.rootWindow;
5129 if(active && state == minimized)
5130 // SetState(normal, false, 0);
5131 SetState(lastState, false, 0);
5133 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5137 /* WTH is this doing here?
5138 while(swap && swap.activeChild)
5140 swap = swap.activeChild;
5143 // TESTING THIS BEFORE...
5144 if(interimWindow && this == interimMaster)
5148 // Window interimSwap = this;
5149 Window menuBar = this.menuBar;
5150 if(menuBar && interimWindow.master == menuBar)
5153 while(interimSwap && interimSwap.activeChild)
5154 interimSwap = interimSwap.activeChild;
5156 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5157 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5159 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5160 //result = ActivateEx(true, true, false, activateRoot, window, null);
5165 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5166 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5168 if(interimWindow == this && interimMaster && !active)
5170 while(interimMaster && interimMaster.interim && interimMaster.master)
5172 // printf("Going up one master %s\n", interimMaster._class.name);
5173 interimMaster = interimMaster.master.rootWindow;
5175 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5176 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5182 bool DestroyEx(int returnCode)
5185 Timer timer, nextTimer;
5187 OldLink prevOrder = null;
5188 Window client = null;
5190 if(parent) stopwatching(parent, font);
5192 // if(window.modalSlave) return false;
5193 if(destroyed || !created)
5200 OldLink slave = master.slaves.FindVoid(this);
5201 master.slaves.Delete(slave);
5204 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5210 this.returnCode = (DialogResult)returnCode;
5212 AcquireInput(false);
5217 master.hotKeys.Delete(hotKey);
5221 if(guiApp.prevWindow == this)
5223 guiApp.prevWindow = null;
5226 if(guiApp.caretOwner == this)
5228 guiApp.interfaceDriver.SetCaret(0,0,0);
5229 UpdateCaret(false, true);
5230 guiApp.caretEnabled = false;
5235 parent.childrenCycle.Remove(cycle);
5239 OldLink tmpPrev = order.prev;
5240 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5241 prevOrder = tmpPrev;
5244 client = tmpPrev ? tmpPrev.data : null;
5245 if(client == this) { client = null; break; }
5246 if(client && (client.style.hidden || client.destroyed || !client.created))
5247 tmpPrev = client.order.prev;
5251 prevOrder = tmpPrev;
5256 // If this window can be an active client, make sure the next window we activate can also be one
5257 if(!style.nonClient && style.isActiveClient)
5259 tmpPrev = prevOrder;
5262 client = tmpPrev ? tmpPrev.data : null;
5263 if(client == this) { client = null; break; }
5264 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5265 tmpPrev = client.order.prev;
5269 prevOrder = tmpPrev;
5273 if(client && client.style.hidden) client = null;
5275 // parent.childrenOrder.Remove(order);
5278 // TESTING THIS HERE!
5282 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5283 // to create a window inside a rootwindow that's being destroyed)
5284 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5286 if(master && !master.destroyed /*&&
5287 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5289 if(master.defaultControl == this)
5290 master.defaultControl = null;
5292 if(parent && !parent.destroyed /*&&
5293 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5295 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5297 if(order && prevOrder && prevOrder.data != this && active)
5299 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5301 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5302 if(parent.activeClient == this)
5304 parent.activeClient = null;
5305 parent.UpdateActiveDocument(null);
5310 if(guiApp.interimWindow == this)
5313 PropagateActive(false, null, &goOn, true);
5317 //if(window.parent.activeChild == window)
5318 parent.activeChild = null;
5319 if(!style.nonClient /*&& style.isActiveClient*/)
5321 Window previous = parent.activeClient;
5322 if(style.isActiveClient)
5323 parent.activeClient = null;
5324 parent.UpdateActiveDocument(previous);
5329 else if(parent.activeClient == this)
5331 parent.activeClient = client;
5332 parent.UpdateActiveDocument(this);
5336 if(guiApp.interimWindow == this)
5338 guiApp.interimWindow = null;
5339 if(guiApp.caretOwner)
5341 Window desktop = guiApp.desktop;
5342 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5343 guiApp.caretOwner.UpdateCaret(false, false);
5348 if(style.modal && master && master.modalSlave == this)
5349 master.modalSlave = null;
5353 if(!guiApp.caretOwner && parent.caretSize)
5355 guiApp.caretOwner = parent;
5356 parent.UpdateCaret(false, false);
5357 parent.Update(null);
5360 if(style.isActiveClient && visible)
5362 if(state == minimized) parent.numIcons--;
5363 parent.numPositions--;
5365 // Why was this commented out?
5366 GetRidOfVirtualArea();
5372 dirtyArea.Free(null);
5373 dirtyBack.Free(null);
5374 scrollExtent.Free(null);
5376 /* ATTEMPTING TO MOVE THAT ABOVE
5385 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5386 for(;(child = window.children.first);)
5388 for(; child && (child.destroyed || !child.created); child = child.next);
5397 UnloadGraphics(true);
5400 delete previousActive;
5403 // statusBar = null;
5406 if(master && !master.destroyed)
5408 //master.NotifyDestroyed(this, this.returnCode);
5409 NotifyDestroyed(master, this, this.returnCode);
5412 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5414 nextTimer = timer.next;
5415 if(timer.window == this)
5417 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5418 // timer.window = null;
5424 if(this == guiApp.windowMoving)
5427 if(guiApp.windowCaptured == this)
5429 //guiApp.windowCaptured = null;
5431 if(rootWindow != this && rootWindow)
5432 rootWindow.ConsequentialMouseMove(false);
5440 //for(child = children.first; next = child ? child.next : null, child; child = next)
5441 for(;(child = children.first); )
5443 for(; child && (child.destroyed || !child.created); child = child.next);
5453 /* // MOVED THIS UP...
5456 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5457 for(;(child = window.children.first); )
5459 for(; child && (child.destroyed || !child.created); child = child.next);
5468 while((slave = slaves.first))
5470 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5472 ((Window)slave.data).DestroyEx(0);
5477 if(guiApp.caretOwner == this)
5478 guiApp.caretOwner = null;
5480 sysButtons[0] = null;
5481 sysButtons[1] = null;
5482 sysButtons[2] = null;
5485 if(rootWindow != this)
5487 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5490 box.left -= parent.clientStart.x;
5491 box.top -= parent.clientStart.y;
5492 box.right -= parent.clientStart.x;
5493 box.bottom -= parent.clientStart.y;
5495 if(parent) parent.Update(box);
5500 OldLink slave = master.slaves.FindVoid(this);
5501 master.slaves.Delete(slave);
5507 parent.children.Remove(this);
5512 //autoCreate = false;
5515 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5516 if(((subclass(Window))_class).pureVTbl)
5518 if(_vTbl == _class._vTbl)
5520 _vTbl = ((subclass(Window))_class).pureVTbl;
5525 for(m = 0; m < _class.vTblSize; m++)
5527 if(_vTbl[m] == _class._vTbl[m])
5528 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5537 void SetStateEx(WindowState newState, bool activate)
5540 WindowState prevState = state;
5543 if(rootWindow == this && nativeDecorations)
5546 if(prevState != newState)
5547 lastState = prevState;
5548 if(style.isActiveClient && !style.hidden && prevState == minimized)
5551 // This block used to be at the end of the function... moved it for flicker problem in X
5552 // ------------------------------------------------------
5556 stateAnchor = normalAnchor;
5557 stateSizeAnchor = normalSizeAnchor;
5560 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5561 stateSizeAnchor = SizeAnchor {};
5565 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5568 byte * idBuffer = new0 byte[size];
5570 for(child = parent.children.first; child; child = child.next)
5572 if(child != this && child.state == minimized)
5574 if(child.iconID > size - 2)
5576 idBuffer = renew0 idBuffer byte[size*2];
5577 memset(idBuffer + size, 0, size);
5580 idBuffer[child.iconID] = (byte)bool::true;
5583 for(c = 0; c<size; c++)
5588 if(style.isActiveClient && !style.hidden)
5591 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5592 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5596 // TOCHECK: Why was this here?
5597 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5598 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5599 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5601 Position(x, y, w, h, true, true, true, true, false, true);
5603 if(!style.inactive && !style.interim && this == parent.activeClient)
5604 parent.UpdateActiveDocument(null);
5606 CreateSystemChildren();
5607 // ------------------------------------------------------
5610 int GetPositionID(Window forChild)
5614 byte * idBuffer = new0 byte[size];
5617 for(child = children.first; child; child = child.next)
5619 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5621 if(child.positionID > size - 2)
5623 idBuffer = renew0 idBuffer byte[size*2];
5624 memset(idBuffer + size, 0, size);
5627 idBuffer[child.positionID] = (byte)bool::true;
5630 for(c = 0; c<size; c++)
5637 // --- Window related graphics ---
5639 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5641 palette = newPalette;
5642 if(rootWindow.display)
5643 rootWindow.display.SetPalette(palette, colorMatch);
5646 public bool AcquireInput(bool acquired)
5649 if(acquiredInput != acquired)
5651 if(active || (!visible && creationActivation == activate))
5652 result = AcquireInputEx(acquired);
5657 acquiredInput = acquired ? result : !result;
5662 void ListChildren(ListBox listBox)
5666 for(child = children.first; child; child = child.next)
5668 if(child.cycle && !child.style.nonClient && child.style.isActiveClient)
5670 DataRow row = listBox.AddRow();
5671 row.tag = (int)child;
5672 child.FigureCaption(caption);
5673 row.SetData(null, caption);
5678 void UpdateVisual(Box extent)
5680 if(guiApp.driver != null)
5682 if(guiApp.fullScreenMode && guiApp.desktop.display)
5684 guiApp.desktop.mutex.Wait();
5685 guiApp.desktop.display.Lock(true);
5688 if(guiApp.desktop.active)
5690 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5692 if(guiApp.desktop.display.flags.flipping)
5693 guiApp.desktop.Update(null);
5694 guiApp.desktop.UpdateDisplay();
5695 guiApp.cursorUpdate = true;
5697 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5699 guiApp.PreserveAndDrawCursor();
5700 // guiApp.desktop.display.ShowScreen();
5701 guiApp.cursorUpdate = false;
5702 guiApp.desktop.dirty = false;
5703 guiApp.RestoreCursorBackground();
5707 guiApp.desktop.display.Unlock();
5708 guiApp.desktop.mutex.Release();
5712 Window rootWindow = this.rootWindow;
5713 rootWindow.mutex.Wait();
5718 guiApp.SignalEvent();
5721 guiApp.waitMutex.Wait();
5722 guiApp.interfaceDriver.Lock(rootWindow);
5723 if(!rootWindow.style.hidden && rootWindow.dirty)
5725 if(rootWindow.display)
5727 rootWindow.UpdateDisplay();
5728 //rootWindow.display.ShowScreen(null);
5730 rootWindow.dirty = false;
5732 guiApp.interfaceDriver.Unlock(rootWindow);
5733 guiApp.waitMutex.Release();
5736 rootWindow.mutex.Release();
5741 void UnlockDisplay(void)
5743 guiApp.interfaceDriver.Unlock(rootWindow);
5746 void LockDisplay(void)
5748 guiApp.interfaceDriver.Lock(rootWindow);
5751 Surface GetSurface(Box box)
5753 return Redraw((box == null) ? this.box : box);
5756 void SetMousePosition(int x, int y)
5758 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5762 void IntegrationActivate(bool active)
5764 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5766 isForegroundWindow = true;
5767 ActivateEx(active, active, false, false, null, null);
5768 isForegroundWindow = false;
5773 Window QueryCapture(void)
5775 return guiApp.windowCaptured;
5778 int GetDocumentID(void)
5782 byte * idBuffer = new0 byte[size];
5785 for(child = children.first; child; child = child.next)
5787 if(child.style.isDocument)
5789 if(child.documentID-1 > size - 2)
5791 idBuffer = renew0 idBuffer byte[size*2];
5792 memset(idBuffer + size, 0, size);
5795 idBuffer[child.documentID-1] = 1;
5798 for(c = 0; c<size; c++)
5806 void SetInitSize(Size size)
5809 sizeAnchor.size = size;
5810 normalSizeAnchor = sizeAnchor;
5812 // Break the anchors for moveable/resizable windows
5813 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5815 stateAnchor = normalAnchor;
5816 stateSizeAnchor = normalSizeAnchor;
5818 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5819 Position(x,y, w, h, true, true, true, true, false, true);
5823 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5825 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5827 guiApp.windowIsResizing = resize;
5828 guiApp.windowMoving = this;
5829 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5830 if(guiApp.windowIsResizing)
5832 guiApp.windowMovingStart.x += size.w - 1;
5833 guiApp.windowMovingStart.y += size.h - 1;
5835 guiApp.windowMovingBefore = scrolledPos;
5836 guiApp.windowResizingBefore = size;
5837 guiApp.windowMoving.UpdateDecorations();
5838 if(guiApp.windowIsResizing)
5839 guiApp.resizeEndX = guiApp.resizeEndY = true;
5841 if(setCursorPosition)
5842 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5846 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5847 guiApp.windowMovingStart.x += x - absPosition.x;
5848 guiApp.windowMovingStart.y += y - absPosition.y;
5851 if(guiApp.windowMoving)
5853 if(guiApp.windowMoving.style.nonClient)
5854 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5856 guiApp.windowMoving.parent.SetMouseRangeToClient();
5861 if(this == rootWindow)
5862 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
5870 bool result = false;
5874 else if(guiApp && guiApp.driver != null)
5876 void * systemParent = null;
5877 OldLink slaveHolder;
5879 bool visible = !style.hidden;
5883 systemParent = parent;
5884 parent = guiApp.desktop;
5886 last = parent ? parent.children.last : null;
5888 if((parent && parent != guiApp.desktop && !parent.created) ||
5889 (master && master != guiApp.desktop && !master.created))
5893 property::parent = guiApp.desktop;
5894 if(!master) master = parent;
5896 if(style.modal && master.modalSlave)
5900 parent.children.Remove(this);
5903 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
5904 if(slaveHolder.data == this)
5906 master.slaves.Delete(slaveHolder);
5911 if(parent == guiApp.desktop && !mutex)
5914 if(style.isDocument)
5917 parent.numDocuments--;
5918 documentID = parent.GetDocumentID();
5921 if(!style.stayOnTop)
5922 for(; last && last.style.stayOnTop; last = last.prev);
5924 parent.children.Insert((last == this) ? null : last, this);
5925 //parent.children.Add(this);
5928 dispDriver = parent.dispDriver;
5931 master.modalSlave = this;
5933 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
5938 master.slaves.Add(slaveHolder = OldLink { data = this });
5943 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
5945 if(style.isDefault && !master.defaultControl)
5946 master.defaultControl = this;
5948 stateAnchor = normalAnchor = anchor;
5949 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
5951 // TOCHECK: Why is this here?
5952 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
5953 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
5955 this.visible = false;
5956 style.hidden = true;
5959 // autoCreate = true;
5967 if(parent == guiApp.desktop)
5968 Log("LoadGraphics %s\n", caption);
5970 if(LoadGraphics(true, false))
5978 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
5985 if(style.hasMenuBar /*&& menu*/)
5991 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
5992 interim = false, inactive = true, nonClient = true, size.h = 24
6000 // Create the system buttons
6001 CreateSystemChildren();
6003 UpdateActiveDocument(null);
6005 if(style.isDocument)
6009 MenuItem item = menu.FindItem(MenuFileSave, 0);
6010 if(item) item.disabled = !modifiedDocument && fileName;
6015 if(parent == guiApp.desktop)
6016 Log("Preemptive SetState %s\n", caption);
6019 // Preemptive Set State to ensure proper anchoring
6020 SetStateEx(state, false);
6022 style.hidden = true;
6028 for(child = children.first; child; child = next)
6031 if(!child.created && (child.autoCreate || child.wasCreated))
6038 for(link = slaves.first; link; link = next)
6040 Window slave = link.data;
6042 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6051 if(parent == guiApp.desktop)
6052 Log("Real SetState %s\n", caption);
6055 if(isActiveClient && visible)
6057 parent.numPositions--;
6058 if(state == minimized) parent.numIcons--;
6061 // Real set state & activate for proper display & activation
6062 property::visible = visible;
6063 // SetState(state & 0x00000003, true, 0);
6068 /*if(rootWindow == this)
6069 guiApp.interfaceDriver.ActivateRootWindow(this);
6071 if(creationActivation == activate)
6072 ActivateEx(true, false, true, true, null, null);
6073 else if(creationActivation == flash)
6078 rootWindow.ConsequentialMouseMove(false);
6089 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6095 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6097 //style.hidden = true; // !visible;
6098 style.hidden = !visible;
6099 if(master.modalSlave == this)
6100 master.modalSlave = null;
6107 void WriteCaption(Surface surface, int x, int y)
6110 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6113 void Update(Box region)
6119 rootWindow = this.rootWindow;
6121 // rootWindow.mutex.Wait();
6122 if(!destroyed && visible && display)
6127 // Testing this to avoid repetitve full update to take time...
6128 if(dirtyArea.count == 1)
6130 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6131 if(item.box.left <= box.left &&
6132 item.box.top <= box.top &&
6133 item.box.right >= box.right &&
6134 item.box.bottom >= box.bottom)
6136 rootWindow.dirty = true;
6141 if(display.flags.flipping && !rootWindow.dirty)
6143 if(this == rootWindow)
6147 rootWindow.Update(null);
6152 rootWindow.dirty = true;
6157 realBox.left += clientStart.x;
6158 realBox.top += clientStart.y;
6159 realBox.right += clientStart.x;
6160 realBox.bottom += clientStart.y;
6166 if(realBox.right >= realBox.left &&
6167 realBox.bottom >= realBox.top)
6169 // if(!rootWindow.fullRender)
6170 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6172 for(child = children.first; child; child = child.next)
6177 box.left -= child.absPosition.x - absPosition.x;
6178 box.top -= child.absPosition.y - absPosition.y;
6179 box.right -= child.absPosition.x - absPosition.x;
6180 box.bottom -= child.absPosition.y - absPosition.y;
6181 if(box.right >= child.box.left && box.left <= child.box.right &&
6182 box.bottom >= child.box.top && box.top <= child.box.bottom)
6184 box.left -= child.clientStart.x;
6185 box.top -= child.clientStart.y;
6186 box.right -= child.clientStart.x;
6187 box.bottom -= child.clientStart.y;
6193 realBox.left += absPosition.x - rootWindow.absPosition.x;
6194 realBox.top += absPosition.y - rootWindow.absPosition.y;
6195 realBox.right += absPosition.x - rootWindow.absPosition.x;
6196 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6197 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6200 else if(this == guiApp.desktop)
6203 for(window = children.first; window; window = window.next)
6209 Box childBox = region;
6211 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6212 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6213 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6214 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6216 window.Update(childBox);
6219 window.Update(null);
6224 // rootWindow.mutex.Release();
6231 if(guiApp.windowCaptured != this)
6233 if(guiApp.windowCaptured)
6237 //Logf("Captured %s (%s)\n", caption, class.name);
6238 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6239 guiApp.windowCaptured = this;
6245 bool Destroy(int code)
6250 if(!CloseConfirmation(false)) return false;
6254 // TOCHECK: Should autoCreate be set to false here?
6257 // Is this needed here? DestroyEx should decref already...
6266 void Move(int x, int y, int w, int h)
6268 normalAnchor = Anchor { left = x, top = y };
6269 normalSizeAnchor = SizeAnchor { size = { w, h } };
6271 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6273 if(destroyed) return;
6275 stateAnchor = normalAnchor;
6276 stateSizeAnchor = normalSizeAnchor;
6278 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6279 Position(x,y, w, h, true, true, true, true, false, true);
6283 DialogResult Modal(void)
6289 // FIXES MEMORY LEAK IF Create() FAILED
6295 void SetScrollArea(int width, int height, bool snapToStep)
6297 bool resize = false;
6300 int stepX = sbStep.x, stepY = sbStep.y;
6301 // Needed to make snapped down position match the skin's check of client area
6302 // against realvirtual
6305 SNAPDOWN(stepX, textCellW);
6306 SNAPDOWN(stepY, textCellH);
6307 stepX = Max(stepX, textCellW);
6308 stepY = Max(stepY, textCellH);
6310 if(scrollFlags.snapX)
6311 SNAPUP(width, stepX);
6312 if(scrollFlags.snapY)
6313 SNAPUP(height, stepY);
6316 reqScrollArea.w = width;
6317 reqScrollArea.h = height;
6318 noAutoScrollArea = (width > 0 || height > 0);
6320 UpdateScrollBars(true, true);
6323 void SetScrollPosition(int x, int y)
6326 sbh.Action(setPosition, x, 0);
6330 int seen = clientSize.w, total = reqScrollArea.w;
6332 if(scrollFlags.snapX)
6333 SNAPDOWN(seen, sbStep.x);
6335 if(!total) total = seen;
6336 range = total - seen + 1;
6337 range = Max(range, 1);
6339 if(x >= range) x = range - 1;
6341 if(scrollFlags.snapX)
6342 SNAPUP(x, sbStep.x);
6345 OnHScroll(setPosition, x, 0);
6349 SNAPDOWN(x, textCellW);
6355 sbv.Action(setPosition, y, 0);
6359 int seen = clientSize.h, total = reqScrollArea.h;
6362 if(scrollFlags.snapY)
6363 SNAPDOWN(seen, sbStep.y);
6365 if(!total) total = seen;
6366 range = total - seen + 1;
6367 range = Max(range, 1);
6369 if(y >= range) y = range - 1;
6371 if(scrollFlags.snapY)
6372 SNAPUP(y, sbStep.y);
6375 OnVScroll(setPosition, y, 0);
6378 SNAPDOWN(y, textCellH);
6383 UpdateCaret(false, false);
6386 void SetScrollLineStep(int stepX, int stepY)
6392 SNAPDOWN(stepX, textCellW);
6393 SNAPDOWN(stepY, textCellH);
6394 stepX = Max(stepX, textCellW);
6395 stepY = Max(stepY, textCellH);
6398 sbh.lineStep = stepX;
6400 sbv.lineStep = stepY;
6403 void SetState(WindowState newState, bool activate, Modifiers mods)
6407 if(state == newState || OnStateChange(newState, mods))
6409 WindowState prevState = state;
6413 // This used to be at the end of the brackets... moved for X, testing...
6414 // This has the effect of activating the window through the system...
6415 if(rootWindow == this)
6416 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6418 SetStateEx(newState, activate);
6420 if(rootWindow == this && !rootWindow.nativeDecorations)
6422 int x = position.x, y = position.y;
6425 x -= guiApp.desktop.absPosition.x;
6426 y -= guiApp.desktop.absPosition.y;
6428 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6432 //state = prevState;
6434 if(state != maximized && style.hasMaximize)
6437 for(child = parent.children.first; child; child = child.next)
6439 if(child != this && child.state == maximized)
6440 child.SetStateEx(normal, false);
6444 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6445 parent.UpdateScrollBars(true, true);
6448 // Do we really need this stuff here?
6449 // Shouldn't the Activate stuff take care of it?
6450 if(parent.rootWindow == parent && style)
6453 parent.FigureCaption(caption);
6454 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6455 parent.UpdateDecorations();
6459 rootWindow.ConsequentialMouseMove(false);
6466 BitmapResource GetIcon(SkinBitmap iconID)
6468 return guiApp.currentSkin.GetBitmap(iconID);
6471 void SetMouseRange(Box range)
6473 if(range || guiApp.fullScreenMode)
6478 clip.left = range.left + absPosition.x + clientStart.x;
6479 clip.top = range.top + absPosition.y + clientStart.y;
6480 clip.right = range.right + absPosition.x + clientStart.x;
6481 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6485 clip.left = guiApp.desktop.box.left;
6486 clip.top = guiApp.desktop.box.top;
6487 clip.right = guiApp.desktop.box.right;
6488 clip.bottom = guiApp.desktop.box.bottom;
6490 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6493 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6496 void SetMouseRangeToClient(void)
6498 if(guiApp.fullScreenMode || this != guiApp.desktop)
6500 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6501 box.Clip(clientArea);
6505 SetMouseRange(null);
6508 void SetMouseRangeToWindow(void)
6510 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6511 if(this == guiApp.desktop)
6512 SetMouseRangeToClient();
6517 // x, y: Desktop Coordinates
6518 void ShowSysMenu(int x, int y)
6521 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6524 menu, "Restore", r, NotifySelect = MenuWindowRestore,
6525 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6529 menu, "Move", m, NotifySelect = MenuWindowMove,
6530 disabled = !style.fixed || state == maximized
6534 menu, "Size", s, NotifySelect = MenuWindowSize,
6535 disabled = !style.sizable || state != normal
6539 menu, "Minimize", n, NotifySelect = MenuWindowMinimize,
6540 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6544 menu, "Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6545 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6549 menu, "Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6550 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6552 MenuDivider { menu };
6555 menu, "Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6556 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6558 windowMenu.Create();
6563 ActivateEx(true, true, true, true, null, null);
6566 void MakeActive(void)
6568 ActivateEx(true, false, true, false, null, null);
6571 void SoftActivate(void)
6573 if(guiApp.desktop.active)
6579 void Deactivate(void)
6581 ActivateEx(false, true, true, true, null, null);
6586 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6589 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6591 bool result = false;
6592 if(activeChild && activeChild.cycle)
6594 Window modalWindow, child = activeChild;
6595 if(!clientOnly /*&& parent.tabCycle*/)
6597 Window next = child;
6600 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6604 if(parent && parent.CycleChildren(backward, false, true, true))
6612 next = next.cycle.prev.data;
6614 next = next.cycle.next.data;
6615 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6620 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6621 parent.tabCycle && parent.CycleChildren(backward, false, false))
6625 if(tabCycleOnly && !tabCycle) return false;
6632 child = child.cycle.prev.data;
6634 child = child.cycle.next.data;
6635 if(child == child.parent.activeChild)
6637 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6640 modalWindow = child.FindModal();
6643 // Scroll the window to include the active control
6644 if(sbh && !child.style.dontScrollHorz)
6646 if(child.scrolledPos.x < 0)
6647 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6648 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6649 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6651 if(sbv && !child.style.dontScrollVert)
6653 if(child.scrolledPos.y < 0)
6654 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6655 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6656 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6660 child = modalWindow ? modalWindow : child;
6661 child.ActivateEx(true, true, true, true, null, null);
6662 if(child.tabCycle && child.childrenCycle.first)
6663 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6671 ConsequentialMouseMove(false);
6675 void AddResource(Resource resource)
6679 ResPtr ptr { resource = resource };
6683 // Load Graphics here if window is created already
6684 if(/*created && */display)
6686 display.Lock(false);
6687 ptr.loaded = display.displaySystem.LoadResource(resource);
6691 // Temporary hack to load font right away for listbox in dropbox ...
6692 else if(master && master.display)
6694 master.display.Lock(false);
6695 master.display.displaySystem.LoadResource(resource);
6696 master.display.Unlock();
6702 void RemoveResource(Resource resource)
6707 for(ptr = resources.first; ptr; ptr = ptr.next)
6709 if(ptr.resource == resource)
6715 // Unload Graphics here if window is created already
6716 if(/*created && */display)
6720 display.Lock(false);
6721 display.displaySystem.UnloadResource(resource, ptr.loaded);
6727 resources.Delete(ptr);
6732 void SetCaret(int x, int y, int size)
6739 if(active && !style.interim)
6741 if(visible || !guiApp.caretOwner)
6742 guiApp.caretOwner = size ? this : null;
6744 UpdateCaret(false, false);
6747 guiApp.interfaceDriver.SetCaret(0,0,0);
6748 UpdateCaret(false, true);
6749 guiApp.caretEnabled = false;
6752 else if(style.inactive && active)
6754 guiApp.interfaceDriver.SetCaret(0,0,0);
6755 UpdateCaret(false, true);
6756 guiApp.caretEnabled = false;
6761 void Scroll(int x, int y)
6763 bool opaque = !style.drawBehind || background.a;
6764 if(opaque && display && display.flags.scrolling)
6766 Box box = clientArea;
6767 box.left += clientStart.x;
6768 box.top += clientStart.y;
6769 box.right += clientStart.x;
6770 box.bottom += clientStart.y;
6772 //scrollExtent.Free(null);
6773 scrollExtent.AddBox(box);
6774 scrolledArea.x += x;
6775 scrolledArea.y += y;
6777 //scrollExtent.Free();
6778 //scrollExtent.AddBox(clientArea);
6779 //scrollExtent.Offset(clientStart.x, clientStart.y);
6780 //scrolledArea.x = x;
6781 //scrolledArea.y = y;
6787 rootWindow.dirty = true;
6790 void ReleaseCapture()
6792 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6794 Window oldCaptured = guiApp.windowCaptured;
6795 guiApp.windowCaptured = null;
6796 guiApp.prevWindow = null;
6799 //guiApp.Log("Released Capture\n");
6801 guiApp.interfaceDriver.SetMouseCapture(null);
6803 //oldCaptured.OnMouseCaptureLost();
6806 oldCaptured.ConsequentialMouseMove(false);
6811 void SetText(char * format, ...)
6818 char caption[MAX_F_STRING];
6820 va_start(args, format);
6821 vsprintf(caption, format, args);
6824 this.caption = new char[strlen(caption)+1];
6826 strcpy(this.caption, caption);
6835 bool Grab(Bitmap bitmap, Box box, bool decorations)
6837 bool result = false;
6838 if(display || this == guiApp.desktop)
6840 Box clip = {MININT, MININT, MAXINT, MAXINT};
6846 clip.Clip(clientArea);
6848 clip.Clip(this.box);
6850 if(rootWindow != this)
6852 clip.left += absPosition.y;
6853 clip.top += absPosition.y;
6854 clip.right += absPosition.x;
6855 clip.bottom += absPosition.y;
6858 clip.left += decorations ? 0 : clientStart.x;
6859 clip.top += decorations ? 0 : clientStart.y;
6860 clip.right += decorations ? 0 : clientStart.x;
6861 clip.bottom += decorations ? 0 : clientStart.y;
6863 if(display && display.flags.flipping)
6865 rootWindow.Update(null);
6866 rootWindow.UpdateDisplay();
6873 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
6874 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
6878 result = display.Grab(bitmap, clip.left, clip.top,
6879 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
6881 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
6883 if(!bitmap.Convert(null, pixelFormat888, null))
6890 void GetMousePosition(int * x, int * y)
6892 int mouseX = 0, mouseY = 0;
6893 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
6896 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
6897 if(this != guiApp.desktop)
6899 mouseX -= absPosition.x + clientStart.x;
6900 mouseY -= absPosition.y + clientStart.y;
6907 DialogResult DoModal()
6909 DialogResult returnCode = 0;
6910 int terminated = terminateX;
6913 while(!destroyed && guiApp.driver != null)
6915 if(terminateX != terminated)
6917 terminated = terminateX;
6918 guiApp.desktop.Destroy(0);
6919 if(guiApp.desktop.created)
6922 //printf("Resetting terminate X to 0\n");
6928 guiApp.UpdateDisplay();
6929 if(!guiApp.ProcessInput(false))
6932 returnCode = this.returnCode;
6945 return !destroyed && guiApp.driver != null && terminateX < 2;
6948 DialogResult DoModalEnd()
6950 DialogResult returnCode = this.returnCode;
6955 // --- Window manipulation ---
6956 /*bool GetDisabled()
6958 bool disabled = this.disabled;
6960 for(window = this; (window = window.master); )
6971 // --- Mouse Manipulation ---
6972 void GetNCMousePosition(int * x, int * y)
6974 GetMousePosition(x, y);
6975 if(x) *x += clientStart.x;
6976 if(y) *y += clientStart.y;
6979 // --- Carets manipulation ---
6980 void GetCaretPosition(Point caretPos)
6982 caretPos = this.caretPos;
6985 int GetCaretSize(void)
6990 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
6996 bool CloseConfirmation(bool parentClosing)
7009 if(!OnClose(parentClosing))
7012 // If you want to skip this, simply set modifiedDocument to false in OnClose
7013 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7015 DialogResult dialogRes;
7018 sprintf(message, "Save changes to %s?", fileName);
7020 sprintf(message, "Save changes to Untitled %d?", documentID);
7022 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption, contents = message }.Modal();
7024 if(dialogRes == yes)
7026 // TOFIX: Precomp error if brackets are taken out
7027 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7029 else if(dialogRes == cancel)
7035 for(slave = slaves.first; slave; slave = slave.next)
7036 if(!((Window)slave.data).CloseConfirmation(true))
7038 // ((Window)slave.data).CloseConfirmation(true);
7046 for(child = children.first; child; child = child.next)
7047 if(child.master != this && !child.CloseConfirmation(true))
7057 // Static methods... move them somewhere else?
7058 void ::RestoreCaret()
7060 if(guiApp.caretOwner)
7061 guiApp.caretOwner.UpdateCaret(false, false);
7064 void ::FreeMouseRange()
7066 guiApp.interfaceDriver.SetMouseRange(null, null);
7070 bool MenuFileClose(MenuItem selection, Modifiers mods)
7072 Window document = activeChild;
7074 document.Destroy(0);
7078 bool MenuFileExit(MenuItem selection, Modifiers mods)
7084 bool MenuFileSave(MenuItem selection, Modifiers mods)
7088 fileMonitor.fileName = null;
7091 if(OnSaveFile(fileName))
7093 //if(OnFileModified != Window::OnFileModified)
7096 fileMonitor.fileName = fileName;
7102 MessageBox dialog { master = master, type = yesNoCancel, text = "Error writing file", contents = "Save as a different file?" };
7103 DialogResult answer = dialog.Modal();
7105 if(answer != yes) return (bool)answer;
7108 return MenuFileSaveAs(selection, mods);
7111 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7113 DialogResult result = (DialogResult)bool::true;
7114 FileDialog fileDialog = saveDialog;
7117 fileDialog = FileDialog {};
7122 fileDialog.filePath = fileName;
7125 char filePath[MAX_FILENAME];
7126 sprintf(filePath, "Untitled %d", documentID);
7127 fileDialog.filePath = filePath;
7129 fileMonitor.fileName = null;
7131 fileDialog.type = save;
7132 fileDialog.text = "Save As";
7136 fileDialog.master = master.parent ? master : this;
7137 if(fileDialog.Modal() == ok)
7139 char * filePath = fileDialog.filePath;
7141 if(OnSaveFile(filePath))
7144 property::fileName = filePath;
7145 NotifySaved(master, this, filePath);
7150 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = "Error writing file", contents = "Save as a different file?" };
7151 DialogResult answer = dialog.Modal();
7166 //if(OnFileModified != Window::OnFileModified && fileName)
7169 fileMonitor.fileName = fileName;
7173 return (bool)result; // Actually returning result from Yes/NoCancel message box
7176 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7178 Window document = activeChild;
7180 for(document = children.first; document; document = next)
7182 next = document.next;
7183 if(document.style.isDocument || document.fileName)
7184 document.MenuFileSave(selection, mods);
7189 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7193 for(document = children.first; document; document = document.next)
7194 //if(document.style.isDocument && document.state == minimized)
7195 if(document.style.isActiveClient && document.state == minimized)
7196 document.SetState(minimized, false, mods);
7200 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7202 Window document = activeChild;
7205 Window firstDocument = null;
7207 OldLink cycle = document.cycle.prev;
7212 if(child.style.isActiveClient && !child.style.hidden)
7216 firstDocument = child;
7217 if(child.state == minimized)
7218 child.SetState(minimized, false, mods);
7221 child.positionID = id++;
7222 child.SetState(normal, false, mods);
7223 child.anchor.left.type = cascade;
7226 child.normalSizeAnchor = *&child.sizeAnchor;
7227 child.normalAnchor = child.anchor;
7229 // Break the anchors for moveable/resizable windows
7230 if(child.style.fixed)
7232 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7234 (*&child.normalAnchor).left = x;
7235 (*&child.normalAnchor).top = y;
7236 (*&child.normalAnchor).right.type = none;
7237 (*&child.normalAnchor).bottom.type = none;
7239 child.normalSizeAnchor.isClientW = false;
7240 child.normalSizeAnchor.isClientH = false;
7241 child.normalSizeAnchor.size.w = w;
7242 child.normalSizeAnchor.size.h = h;
7243 child.anchored = false;
7246 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7248 child.stateAnchor = child.normalAnchor;
7249 child.stateSizeAnchor = child.normalSizeAnchor;
7251 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7252 child.Position(x, y, w, h, true, true, true, true, false, false);
7257 last = children.last;
7258 if(!child.style.stayOnTop)
7259 for(; last && last.style.stayOnTop; last = last.prev);
7260 children.Move(child, last);
7261 childrenOrder.Move(child.order, childrenOrder.last);
7263 if(cycle == document.cycle) break;
7267 firstDocument.Activate();
7272 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7279 // Close all closes all active clients, not all documents
7280 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7282 Window next, document;
7284 for(document = children.first; document; document = next)
7286 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7287 if(document.style.isActiveClient)
7288 if(!document.Destroy(0) && !document.style.hidden)
7294 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7296 if(style.hasMaximize && state != maximized)
7297 SetState(maximized, 0, 0);
7301 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7303 if(style.hasMinimize && state != minimized)
7305 SetState(minimized, 0, 0);
7306 parent.CycleChildren(false, true, false, true);
7311 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7313 MenuMoveOrSize(false, selection ? true : false);
7317 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7319 CycleChildren(false, true, false, true);
7323 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7325 CycleChildren(true, true, false, true);
7329 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7331 MenuMoveOrSize(true, true);
7335 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7338 SetState(normal, 0, 0);
7342 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7345 int id = selection.id;
7346 OldLink cycle = activeClient.cycle;
7348 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7351 Window sibling = cycle.data;
7352 if(sibling.style.isActiveClient)
7360 document = cycle.data;
7361 document.Activate();
7363 //if(activeChild.state == maximized)
7364 // document.SetState(maximized, false, mods);
7365 //else if(document.state == minimized)
7366 // document.SetState(normal, false, mods);
7370 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7372 stayOnTop = !style.stayOnTop;
7376 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7378 Window document = activeChild;
7381 Window firstDocument = null;
7382 OldLink cycle = document.cycle;
7386 Window child = cycle.data;
7387 if(child.style.isActiveClient && !child.style.hidden)
7389 if(!firstDocument) firstDocument = child;
7390 if(child.state == minimized)
7391 child.SetState(minimized, false, mods);
7394 child.positionID = id++;
7395 child.SetState(normal, false, mods);
7396 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7398 child.anchor.left.type = hTiled;
7401 child.normalSizeAnchor = *&child.sizeAnchor;
7402 child.normalAnchor = child.anchor;
7404 // Break the anchors for moveable/resizable windows
7405 if(child.style.fixed)
7407 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7409 (*&child.normalAnchor).left = x;
7410 (*&child.normalAnchor).top = y;
7411 (*&child.normalAnchor).right.type = none;
7412 (*&child.normalAnchor).bottom.type = none;
7413 child.normalSizeAnchor.isClientW = false;
7414 child.normalSizeAnchor.isClientH = false;
7415 child.normalSizeAnchor.size.w = w;
7416 child.normalSizeAnchor.size.h = h;
7417 child.anchored = false;
7420 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7422 child.stateAnchor = child.normalAnchor;
7423 child.stateSizeAnchor = child.normalSizeAnchor;
7425 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7426 child.Position(x,y, w, h, true, true, true, true, false, true);
7431 if((cycle = cycle.next) == document.cycle) break;
7434 firstDocument.Activate();
7439 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7441 Window document = activeChild;
7444 Window firstDocument = null;
7446 OldLink cycle = document.cycle;
7451 //if(child.style.isDocument)
7452 if(child.style.isActiveClient && !child.style.hidden)
7454 if(!firstDocument) firstDocument = child;
7455 if(child.state == minimized)
7456 child.SetState(minimized, false, mods);
7459 child.positionID = id++;
7460 child.SetState(normal, false, mods);
7461 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7463 child.anchor.left.type = vTiled;
7466 child.normalSizeAnchor = *&child.sizeAnchor;
7467 child.normalAnchor = child.anchor;
7469 // Break the anchors for moveable/resizable windows
7470 if(child.style.fixed)
7472 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7474 (*&child.normalAnchor).left = x;
7475 (*&child.normalAnchor).top = y;
7476 (*&child.normalAnchor).right.type = none;
7477 (*&child.normalAnchor).bottom.type = none;
7478 child.normalSizeAnchor.isClientW = false;
7479 child.normalSizeAnchor.isClientH = false;
7480 child.normalSizeAnchor.size.w = w;
7481 child.normalSizeAnchor.size.h = h;
7482 child.anchored = false;
7485 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7487 child.stateAnchor = child.normalAnchor;
7488 child.stateSizeAnchor = child.normalSizeAnchor;
7490 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7491 child.Position(x,y, w, h, true, true, true, true, false, true);
7496 if((cycle = cycle.next) == document.cycle) break;
7499 firstDocument.Activate();
7504 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7506 WindowList dialog { master = this };
7507 Window document = (Window)dialog.Modal();
7510 if(activeChild.state == maximized)
7511 document.SetState(maximized, false, mods);
7512 else if(document.state == minimized)
7513 document.SetState(normal, false, mods);
7514 document.Activate();
7520 virtual bool OnCreate(void);
7521 virtual void OnDestroy(void);
7522 virtual void OnDestroyed(void);
7523 virtual bool OnClose(bool parentClosing);
7524 virtual bool OnStateChange(WindowState state, Modifiers mods);
7525 virtual bool OnPostCreate(void);
7526 virtual bool OnMoving(int *x, int *y, int w, int h);
7527 virtual bool OnResizing(int *width, int *height);
7528 virtual void OnResize(int width, int height);
7529 virtual void OnPosition(int x, int y, int width, int height);
7530 virtual bool OnLoadGraphics(void);
7531 virtual void OnApplyGraphics(void);
7532 virtual void OnUnloadGraphics(void);
7533 virtual void OnRedraw(Surface surface);
7534 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7535 virtual void OnActivateClient(Window client, Window previous);
7536 virtual bool OnKeyDown(Key key, unichar ch);
7537 virtual bool OnKeyUp(Key key, unichar ch);
7538 virtual bool OnKeyHit(Key key, unichar ch);
7539 virtual bool OnSysKeyDown(Key key, unichar ch);
7540 virtual bool OnSysKeyUp(Key key, unichar ch);
7541 virtual bool OnSysKeyHit(Key key, unichar ch);
7542 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7543 virtual bool OnMouseLeave(Modifiers mods);
7544 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7545 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7546 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7547 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7548 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7549 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7550 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7551 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7552 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7553 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7554 virtual void OnMouseCaptureLost(void);
7555 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7556 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7557 virtual void OnDrawOverChildren(Surface surface);
7558 virtual bool OnFileModified(FileChange fileChange, char * param);
7559 virtual bool OnSaveFile(char * fileName);
7561 // Skins Virtual Functions
7562 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7563 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7564 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7569 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7570 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7571 virtual bool IsMouseMoving(int x, int y, int w, int h);
7572 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY);
7573 virtual void UpdateNonClient();
7574 virtual void SetBox(Box box);
7575 virtual bool IsInside(int x, int y)
7577 return box.IsPointInside({x, y});
7579 virtual bool IsOpaque()
7581 return (!style.drawBehind || background.a == 255);
7585 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7586 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7587 virtual void Window::NotifySaved(Window window, char * filePath);
7592 property Window parent
7594 property_category "Layout"
7597 if(value || guiApp.desktop)
7600 Window oldParent = parent;
7601 Anchor anchor = this.anchor;
7603 if(value && value.IsDescendantOf(this)) return;
7604 if(value && value == this)
7606 if(!value) value = guiApp.desktop;
7608 if(value == oldParent) return;
7610 if(!master || (master == this.parent && master == guiApp.desktop))
7611 property::master = value;
7615 parent.children.Remove(this);
7619 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7620 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7621 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7622 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7626 last = value.children.last;
7628 if(style.isDocument)
7631 parent.numDocuments--;
7632 documentID = value.GetDocumentID();
7635 if(style.isActiveClient && !style.hidden)
7637 if(parent && parent != guiApp.desktop && !(style.hidden))
7639 if(state == minimized) parent.numIcons--;
7640 parent.numPositions--;
7644 if(!style.stayOnTop)
7645 for(; last && last.style.stayOnTop; last = last.prev);
7647 value.children.Insert(last, this);
7649 // *** NEW HERE: ***
7651 parent.childrenCycle.Delete(cycle);
7653 parent.childrenOrder.Delete(order);
7661 int x = position.x, y = position.y, w = size.w, h = size.h;
7665 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7666 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7668 vpw = value.clientSize.w;
7669 vph = value.clientSize.h;
7675 else if(style.fixed)
7677 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7678 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7681 anchor = this.anchor;
7683 if(anchor.left.type == offset) anchor.left.distance = x;
7684 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7685 if(anchor.top.type == offset) anchor.top.distance = y;
7686 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7687 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7688 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7689 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7690 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7691 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7692 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7694 if(!anchor.left.type && !anchor.right.type)
7696 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7697 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7699 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7700 if(!anchor.top.type && !anchor.bottom.type)
7702 anchor.vert.distance = (y + h / 2) - (vph / 2);
7703 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7705 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7713 parent.childrenCycle.Insert(
7714 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7715 cycle = OldLink { data = this });
7716 parent.childrenOrder.Insert(
7717 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7718 order = OldLink { data = this });
7721 if(!style.hidden && style.isActiveClient)
7723 positionID = parent.GetPositionID(this);
7724 parent.numPositions++;
7725 if(state == minimized) parent.numIcons--;
7728 // *** FONT INHERITANCE ***
7729 if(!setFont && oldParent)
7730 stopwatching(oldParent, font);
7734 RemoveResource(systemFont);
7737 // TESTING WITH WATCHERS:
7738 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7739 // usedFont = setFont ? setFont : (systemFont);
7743 if(guiApp.currentSkin)
7745 systemFont = guiApp.currentSkin.SystemFont();
7748 usedFont = systemFont;
7749 AddResource(systemFont);
7757 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7766 if(value.rootWindow && value.rootWindow.display && rootWindow)
7768 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7769 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7772 UnloadGraphics(false);
7775 LoadGraphics(false, false);
7778 if(value.rootWindow != rootWindow)
7779 DisplayModeChanged();
7783 scrolledPos.x = MININT; // Prevent parent update
7784 property::anchor = anchor;
7788 if(guiApp.currentSkin)
7789 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7791 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7792 Position(x, y, w, h, true, true, true, true, false, true);
7797 // else parent = value;
7800 get { return parent; }
7803 property Window master
7805 property_category "Behavior"
7808 //if(this == value) return;
7809 if(value && value.IsSlaveOf(this)) return;
7815 OldLink slaveHolder;
7816 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7817 if(slaveHolder.data == this)
7819 master.slaves.Delete(slaveHolder);
7826 value.slaves.Add(OldLink { data = this });
7831 master.hotKeys.Remove(hotKey);
7832 value.hotKeys.Add(hotKey);
7835 if(master && master.defaultControl == this)
7836 master.defaultControl = null;
7838 if(style.isDefault && !value.defaultControl)
7839 value.defaultControl = this;
7845 get { return master ? master : parent; }
7848 property char * text
7850 property_category "Appearance"
7857 caption = new char[strlen(value)+1];
7859 strcpy(caption, value);
7864 get { return caption; }
7869 property_category "Behavior"
7878 master.hotKeys.Add(hotKey = HotKeySlot { });
7882 hotKey.window = this;
7887 master.hotKeys.Delete(hotKey);
7892 get { return hotKey ? hotKey.key : 0; }
7895 property Color background
7897 property_category "Appearance"
7900 background.color = value;
7905 if(this == rootWindow)
7906 guiApp.interfaceDriver.SetRootWindowColor(this);
7909 get { return background.color; }
7912 property Percentage opacity
7914 property_category "Appearance"
7917 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
7918 drawBehind = background.a ? false : true;
7920 get { return background.a / 255.0f; }
7923 property Color foreground
7925 property_category "Appearance"
7933 get { return foreground; }
7936 property BorderStyle borderStyle
7938 property_category "Appearance"
7941 if(!((BorderBits)value).fixed)
7943 style.hasClose = false;
7944 style.hasMaximize = false;
7945 style.hasMinimize = false;
7947 style.borderBits = value;
7951 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
7953 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7954 Position(x, y, w, h, true, true, true, true, false, true);
7955 CreateSystemChildren();
7958 get { return (BorderStyle)style.borderBits; }
7961 property Size minClientSize
7963 property_category "Layout"
7964 set { minSize = value; }
7965 get { value = minSize; }
7968 property Size maxClientSize
7970 property_category "Layout"
7971 set { maxSize = value; }
7972 get { value = maxSize; }
7975 property bool hasMaximize
7977 property_category "Window Style"
7980 style.hasMaximize = value;
7981 if(value) { style.fixed = true; style.contour = true; }
7985 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
7987 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7988 Position(x, y, w, h, true, true, true, true, false, true);
7990 CreateSystemChildren();
7993 get { return style.hasMaximize; }
7996 property bool hasMinimize
7998 property_category "Window Style"
8001 style.hasMinimize = value;
8002 if(value) { style.fixed = true; style.contour = true; }
8006 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8008 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8009 Position(x, y, w, h, true, true, true, true, false, true);
8011 CreateSystemChildren();
8014 get { return style.hasMinimize; }
8017 property bool hasClose
8019 property_category "Window Style"
8022 style.hasClose = value;
8023 if(value) { style.fixed = true; style.contour = true; }
8027 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8028 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8029 Position(x, y, w, h, true, true, true, true, false, true);
8030 CreateSystemChildren();
8033 get { return style.hasClose; }
8036 property bool nonClient
8038 property_category "Layout"
8041 style.nonClient = value;
8043 style.stayOnTop = true;
8045 get { return style.nonClient; }
8048 property bool inactive
8050 property_category "Behavior"
8055 // *** NEW HERE: ***
8059 parent.childrenCycle.Delete(cycle);
8061 parent.childrenOrder.Delete(order);
8068 active = false; // true;
8069 if(parent.activeChild == this)
8070 parent.activeChild = null;
8071 if(parent.activeClient == this)
8072 parent.activeClient = null;
8081 parent.childrenCycle.Insert(
8082 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8083 cycle = OldLink { data = this });
8085 parent.childrenOrder.Insert(
8086 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8087 order = OldLink { data = this });
8090 style.inactive = value;
8092 get { return style.inactive; }
8095 property bool clickThrough
8097 property_category "Behavior"
8098 set { style.clickThrough = value; }
8099 get { return style.clickThrough; }
8102 property bool isRemote
8104 property_category "Behavior"
8105 set { style.isRemote = value; }
8106 get { return style.isRemote; }
8109 property bool noCycle
8111 property_category "Behavior"
8112 set { style.noCycle = value; }
8113 get { return style.noCycle; }
8116 property bool isModal
8118 property_category "Behavior"
8119 set { style.modal = value; }
8120 get { return style.modal; }
8123 property bool interim
8125 property_category "Behavior"
8126 set { style.interim = value; }
8127 get { return style.interim; }
8130 property bool tabCycle
8132 property_category "Behavior"
8133 set { style.tabCycle = value; }
8134 get { return style.tabCycle; }
8137 property bool isDefault
8139 property_category "Behavior"
8147 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8148 if(sibling != this && sibling.style.isDefault)
8149 sibling.style.isDefault = false;*/
8150 if(master.defaultControl)
8151 master.defaultControl.style.isDefault = false;
8152 master.defaultControl = this;
8154 else if(master.defaultControl == this)
8155 master.defaultControl = null;
8159 style.isDefault = value;
8161 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8163 get { return style.isDefault; }
8166 property bool drawBehind
8168 property_category "Window Style"
8169 set { style.drawBehind = value; }
8170 get { return style.drawBehind; }
8173 property bool hasMenuBar
8175 property_category "Window Style"
8185 if(created && !menuBar)
8192 anchor = Anchor { top = 23, left = 1, right = 1 },
8194 inactive = true, nonClient = true
8199 else if(created && menuBar)
8204 style.hasMenuBar = value;
8206 get { return style.hasMenuBar; }
8209 property bool hasStatusBar
8211 property_category "Window Style"
8218 statusBar = StatusBar { this };
8226 style.hasStatusBar = value;
8228 get { return style.hasStatusBar; }
8230 property bool stayOnTop
8232 property_category "Window Style"
8237 if(created && !style.stayOnTop)
8239 if(rootWindow == this)
8240 guiApp.interfaceDriver.OrderRootWindow(this, true);
8241 else if(parent.children.last != this)
8243 parent.children.Move(this, parent.children.last);
8247 style.stayOnTop = true;
8251 if(created && style.stayOnTop)
8253 if(rootWindow == this)
8254 guiApp.interfaceDriver.OrderRootWindow(this, false);
8261 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8262 order && ((Window)order.data).style.stayOnTop;
8263 order = (order == parent.childrenOrder.first) ? null : order.prev);
8264 last = order ? order.data : null;
8268 for(last = parent.children.last;
8269 last && last.style.stayOnTop;
8273 parent.children.Move(this, last);
8277 style.stayOnTop = false;
8280 get { return style.stayOnTop; }
8285 property_category "Window Style"
8295 if(menuBar && !value)
8302 if(!menuBar && style.hasMenuBar && value)
8306 this, menu = value, isMenuBar = true,
8307 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8308 inactive = true, nonClient = true
8312 UpdateActiveDocument(null);
8315 get { return menu; }
8318 property FontResource font
8320 property_category "Appearance"
8322 isset { return setFont ? true : false; }
8327 if(value && !setFont) { stopwatching(parent, font); }
8328 else if(!value && setFont)
8334 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8343 RemoveResource(setFont);
8348 RemoveResource(systemFont);
8355 AddResource(setFont);
8358 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8361 systemFont = guiApp.currentSkin.SystemFont();
8363 usedFont = systemFont;
8364 AddResource(systemFont);
8372 get { return usedFont; }
8375 property SizeAnchor sizeAnchor
8377 property_category "Layout"
8380 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8381 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8382 sizeAnchor.isClientW != sizeAnchor.isClientH;
8389 normalSizeAnchor = sizeAnchor;
8391 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8393 stateAnchor = normalAnchor;
8394 stateSizeAnchor = normalSizeAnchor;
8396 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8397 Position(x,y, w, h, true, true, true, true, false, true);
8404 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8405 sizeAnchor.isClientW,
8406 sizeAnchor.isClientH
8413 property_category "Layout"
8416 Anchor thisAnchor = anchor;
8417 SizeAnchor thisSizeAnchor = sizeAnchor;
8418 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8419 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8420 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8421 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8422 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8423 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8429 sizeAnchor.isClientW = false;
8430 sizeAnchor.isClientH = false;
8431 sizeAnchor.size = value;
8433 normalSizeAnchor = sizeAnchor;
8435 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8437 stateAnchor = normalAnchor;
8438 stateSizeAnchor = normalSizeAnchor;
8440 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8441 Position(x, y, w, h, true, true, true, true, false, true);
8444 get { value = size; }
8447 property Size clientSize
8449 property_category "Layout"
8452 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8453 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8454 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8459 sizeAnchor.isClientW = true;
8460 sizeAnchor.isClientH = true;
8461 sizeAnchor.size = value;
8463 normalSizeAnchor = sizeAnchor;
8465 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8467 stateAnchor = normalAnchor;
8468 stateSizeAnchor = normalSizeAnchor;
8470 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8471 Position(x,y, w, h, true, true, true, true, false, true);
8474 get { value = clientSize; }
8477 property Size initSize { get { value = sizeAnchor.size; } };
8479 property Anchor anchor
8481 property_category "Layout"
8482 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8488 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8490 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8491 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8493 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8495 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8496 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8500 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8502 anchor.left.distance = 0;
8503 anchor.horz.type = 0;
8505 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8507 anchor.top.distance = 0;
8508 anchor.vert.type = 0;
8517 normalAnchor = anchor;
8519 // Break the anchors for moveable/resizable windows
8520 /*if(style.fixed ) //&& value.left.type == cascade)
8522 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8524 this.anchor = normalAnchor = Anchor { left = x, top = y };
8525 normalSizeAnchor = SizeAnchor { { w, h } };
8528 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8530 stateAnchor = normalAnchor;
8531 stateSizeAnchor = normalSizeAnchor;
8533 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8534 Position(x, y, w, h, true, true, true, true, false, true);
8543 get { value = this ? anchor : Anchor { }; }
8546 property Point position
8548 property_category "Layout"
8551 if(value == null) return;
8553 anchor.left = value.x;
8554 anchor.top = value.y;
8555 anchor.right.type = none;
8556 anchor.bottom.type = none;
8561 normalAnchor = anchor;
8563 // Break the anchors for moveable/resizable windows
8567 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8569 normalAnchor.left = x;
8570 normalAnchor.top = y;
8571 normalAnchor.right.type = none;
8572 normalAnchor.bottom.type = none;
8573 normalSizeAnchor.size.width = w;
8574 normalSizeAnchor.size.height = h;
8578 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8580 stateAnchor = normalAnchor;
8581 stateSizeAnchor = normalSizeAnchor;
8583 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8584 Position(x,y, w, h, true, true, true, true, false, true);
8588 get { value = position; }
8591 property bool disabled
8593 property_category "Behavior"
8596 if(this && disabled != value)
8603 get { return (bool)disabled; }
8606 property bool isEnabled
8611 for(parent = this; parent; parent = parent.parent)
8618 property WindowState state
8620 property_category "Behavior"
8621 set { SetState(value, false, 0); }
8622 get { return this ? state : 0; }
8625 property bool visible
8627 property_category "Behavior"
8630 if(this && !value && !style.hidden && parent)
8632 Window client = null;
8634 style.hidden = true;
8637 OldLink prevOrder = null;
8639 if(rootWindow == this)
8640 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8643 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8646 box.left -= parent.clientStart.x;
8647 box.top -= parent.clientStart.y;
8648 box.right -= parent.clientStart.x;
8649 box.bottom -= parent.clientStart.y;
8653 if(style.modal && master && master.modalSlave == this)
8654 master.modalSlave = null;
8656 if(style.isActiveClient)
8658 parent.numPositions--;
8659 if(state == minimized) parent.numIcons--;
8664 OldLink tmpPrev = order.prev;
8665 client = tmpPrev ? tmpPrev.data : null;
8666 if(client && !client.style.hidden && !client.destroyed && client.created)
8667 prevOrder = tmpPrev;
8670 client = tmpPrev ? tmpPrev.data : null;
8671 if(client == this) { client = null; break; }
8672 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8674 tmpPrev = client.order.prev;
8679 prevOrder = tmpPrev;
8684 // If this window can be an active client, make sure the next window we activate can also be one
8685 if(!style.nonClient && style.isActiveClient)
8687 tmpPrev = prevOrder;
8690 client = tmpPrev ? tmpPrev.data : null;
8691 if(client == this) { client = null; break; }
8692 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8694 tmpPrev = client.order.prev;
8699 prevOrder = tmpPrev;
8703 if(client && client.style.hidden) client = null;
8707 if((parent.activeChild == this || guiApp.interimWindow == this) && true /*activate*/)
8709 if(order && prevOrder && prevOrder.data != this)
8710 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8712 ActivateEx(false, false, false, true, null, null);
8714 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8715 if(parent.activeClient == this)
8717 parent.activeClient = null;
8718 parent.UpdateActiveDocument(null);
8721 else if(parent.activeClient == this)
8723 parent.activeClient = client;
8724 parent.UpdateActiveDocument(this);
8727 // *** Not doing this anymore ***
8730 parent.childrenCycle.Delete(cycle);
8732 parent.childrenOrder.Delete(order);
8737 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8742 else if(this && value && style.hidden)
8744 style.hidden = false;
8747 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8748 if(rootWindow == this)
8749 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8751 if(style.modal && master)
8752 master.modalSlave = this;
8754 if(style.isActiveClient)
8756 positionID = parent.GetPositionID(this);
8757 parent.numPositions++;
8758 if(state == minimized) parent.numIcons++;
8761 // *** NOT DOING THIS ANYMORE ***
8763 if(!(style.inactive))
8765 if(!(style.noCycle))
8767 cycle = parent.childrenCycle.AddAfter(
8768 (parent.activeChild && parent.activeChild.cycle) ?
8769 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8772 order = parent.childrenOrder.AddAfter(
8773 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8780 if(true || !parent.activeChild)
8781 ActivateEx(true, false, true, true, null, null);
8783 if(creationActivation == activate)
8784 ActivateEx(true, false, true, true, null, null);
8785 else if(creationActivation == flash && !object)
8788 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8792 ConsequentialMouseMove(false);
8799 get { return (style.hidden || !setVisible) ? false : true; }
8802 property bool isDocument
8804 property_category "Document"
8805 set { style.isDocument = value; }
8806 get { return style.isDocument; }
8809 property bool mergeMenus
8811 property_category "Window Style"
8812 set { mergeMenus = value; }
8813 get { return (bool)mergeMenus; }
8816 property bool hasHorzScroll
8818 property_category "Window Style"
8823 if(!style.hasHorzScroll && created)
8825 CreateSystemChildren();
8826 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8829 else if(style.hasHorzScroll)
8833 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8835 style.hasHorzScroll = value;
8838 get { return style.hasHorzScroll; }
8841 property bool hasVertScroll
8843 property_category "Window Style"
8848 if(!style.hasVertScroll && created)
8850 style.hasVertScroll = true;
8851 CreateSystemChildren();
8852 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8855 else if(style.hasVertScroll)
8859 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8861 style.hasVertScroll = value;
8863 get { return style.hasVertScroll; }
8866 property bool dontHideScroll
8868 property_category "Behavior"
8871 scrollFlags.dontHide = value;
8874 //UpdateScrollBars(true, true);
8875 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
8879 // UpdateScrollBars(true, true);
8880 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
8883 get { return scrollFlags.dontHide; }
8886 property bool dontScrollVert
8888 property_category "Behavior"
8889 set { style.dontScrollVert = value; }
8890 get { return style.dontScrollVert; }
8892 property bool dontScrollHorz
8894 property_category "Behavior"
8895 set { style.dontScrollHorz = value; }
8896 get { return style.dontScrollHorz; }
8899 property bool snapVertScroll
8901 property_category "Behavior"
8904 scrollFlags.snapY = value;
8905 if(sbv) sbv.snap = value;
8907 get { return scrollFlags.snapY; }
8909 property bool snapHorzScroll
8911 property_category "Behavior"
8914 scrollFlags.snapX = value;
8915 if(sbh) sbh.snap = value;
8917 get { return scrollFlags.snapX; }
8920 property Point scroll
8922 property_category "Behavior"
8926 // TESTING THIS IMPLEMENTATION:
8927 SetScrollPosition(value.x, value.y);
8929 get { value = scroll; }
8932 property bool modifyVirtualArea
8934 property_category "Behavior"
8935 set { modifyVirtArea = value; }
8936 get { return (bool)modifyVirtArea; }
8939 property char * fileName
8941 property_category "Document"
8944 if(menu && ((!fileName && value) || (fileName && !value)))
8946 MenuItem item = menu.FindItem(MenuFileSave, 0);
8947 if(item) item.disabled = !modifiedDocument && value;
8952 if(value && value[0])
8953 fileName = CopyString(value);
8955 if(parent && this == parent.activeClient)
8956 parent.UpdateActiveDocument(null);
8960 // if(style.isDocument)
8962 fileMonitor.fileName = value;
8964 get { return fileName; }
8969 property_category "Data"
8974 property bool modifiedDocument
8976 property_category "Document"
8979 if(style.isDocument || fileName)
8983 MenuItem item = menu.FindItem(MenuFileSave, 0);
8984 if(item) item.disabled = !value && fileName;
8988 if(modifiedDocument != value)
8990 modifiedDocument = value;
8991 if(style.isDocument || fileName)
8995 get { return (bool)modifiedDocument; }
8998 property bool showInTaskBar
9000 property_category "Window Style"
9001 set { style.showInTaskBar = value; }
9002 get { return (style.showInTaskBar; }
9004 property FileDialog saveDialog { set { saveDialog = value; } };
9005 property bool isActiveClient
9007 property_category "Behavior"
9008 set { style.isActiveClient = value; }
9009 get { return style.isActiveClient; }
9012 property Cursor cursor
9014 property_category "Appearance"
9018 SelectMouseCursor();
9020 get { return cursor; }
9023 //#if !defined(ECERE_VANILLA)
9024 property char * name
9026 property_category "Design"
9029 return (this && object) ? object.name : null;
9034 activeDesigner.RenameObject(object, value);
9038 property char * displayDriver
9040 property_category "Behavior"
9043 dispDriver = GetDisplayDriver(value);
9044 //DisplayModeChanged();
9048 return dispDriver ? dispDriver.name : null;
9052 // RUNTIME PROPERTIES
9053 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9054 property Size scrollArea
9056 property_category "Behavior"
9060 SetScrollArea(value.w, value.h, false);
9062 SetScrollArea(0,0, true);
9064 get { value = scrollArea; }
9067 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9072 property_category "Layout"
9073 set { if(this) is3D = value; }
9074 get { return (bool)is3D; }
9077 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9079 // Will be merged with font later
9080 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9081 property Point clientStart { get { value = clientStart; } };
9082 property Point absPosition { get { value = absPosition; } };
9083 property Anchor normalAnchor { get {value = normalAnchor; } };
9084 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9085 property bool active { get { return (bool)active; } };
9086 property bool created { get { return (bool)created; } };
9087 property bool destroyed { get { return (bool)destroyed; } };
9088 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9089 property Window firstChild { get { return children.first; } };
9090 property Window lastChild { get { return children.last; } };
9091 property Window activeClient { get { return activeClient; } };
9092 property Window activeChild { get { return activeChild; } };
9093 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9094 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9095 property ScrollBar horzScroll { get { return sbh; } };
9096 property ScrollBar vertScroll { get { return sbv; } };
9097 property StatusBar statusBar { get { return statusBar; } };
9098 property Window rootWindow { get { return rootWindow; } };
9099 property bool closing { get { return (bool)closing; } set { closing = value; } };
9100 property int documentID { get { return documentID; } };
9101 property Window previous { get { return prev; } }
9102 property Window next { get { return next; } }
9103 property Window nextSlave { get { OldLink link = master.slaves.FindLink(this); return (link && link.next) ? link.next.data : null; } }
9104 property PopupMenu menuBar { get { return menuBar; } }
9105 property ScrollBar sbv { get { return sbv; } }
9106 property ScrollBar sbh { get { return sbh; } }
9107 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9108 property void * systemHandle { get { return windowHandle; } }
9109 property Button minimizeButton { get { return sysButtons[0]; } };
9110 property Button maximizeButton { get { return sysButtons[1]; } };
9111 property Button closeButton { get { return sysButtons[2]; } };
9112 property BitmapResource icon
9114 get { return icon; }
9120 guiApp.interfaceDriver.SetIcon(this, value);
9123 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9124 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9125 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9126 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9127 property bool nativeDecorations { get { return (bool)nativeDecorations && rootWindow == this; } set { nativeDecorations = value; } };
9128 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9134 WindowBits style; // Window Style
9135 char * caption; // Name / Caption
9136 Window parent; // Parent window
9137 OldList children; // List of children in Z order
9138 Window activeChild; // Child window having focus
9139 Window activeClient;
9140 Window previousActive; // Child active prior to activating the default child
9141 Window master; // Window owning and receiving notifications concerning this window
9142 OldList slaves; // List of windows belonging to this window
9143 Display display; // Display this window is drawn into
9145 Point position; // Position in parent window client area
9146 Point absPosition; // Absolute position
9147 Point clientStart; // Client area position from (0,0) in this window
9149 Size clientSize; // Client area size
9150 Size scrollArea; // Virtual Scroll area size
9151 Size reqScrollArea; // Requested virtual area size
9152 Point scroll; // Virtual area scrolling position
9153 public ScrollBar sbh, sbv; // Scrollbar window handles
9154 Cursor cursor; // Mouse cursor used for this window
9157 StatusBar statusBar;
9158 Button sysButtons[3];
9160 Box clientArea; // Client Area box clipped to parent
9162 HotKeySlot hotKey; // HotKey for this window
9166 ScrollFlags scrollFlags;// Window Scrollbar Flags
9167 int id; // Control ID
9169 ColorAlpha background; // Background color used to draw the window area
9171 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9172 OldList childrenCycle; // Cycling order
9173 OldLink cycle; // Element of parent's cycling order
9174 OldList childrenOrder; // Circular Z-Order
9175 OldLink order; // Element of parent's circular Z-Order
9176 Window modalSlave; // Slave window blocking this window's interaction
9178 Window rootWindow; // Topmost system managed window
9179 void * windowHandle; // System window handle
9181 DialogResult returnCode;// Return code for modal windows
9183 Point sbStep; // Scrollbar line scrolling steps
9186 SizeAnchor stateSizeAnchor;
9188 Anchor normalAnchor;
9189 SizeAnchor normalSizeAnchor;
9191 Size skinMinSize; // Minimal window size based on style
9192 Point scrolledPos; // Scrolled position
9193 Box box; // Window box clipped to parent
9194 Box * against; // What to clip the box to
9196 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9197 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9198 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9199 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9200 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9201 Point scrolledArea; // Distance to scroll area by
9202 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9204 OldList hotKeys; // List of the hotkeys of all children
9205 Window defaultControl; // Default child control
9209 ColorAlpha * palette; // Color palette used for this window
9211 int caretSize; // Size of caret, non zero if a caret is present
9212 Point caretPos; // Caret position
9214 void * systemParent; // Parent System Window for embedded windows
9221 WindowState lastState;
9223 FileMonitor fileMonitor
9225 this, FileChange { modified = true };
9227 bool OnFileNotify(FileChange action, char * param)
9230 fileMonitor.StopMonitoring();
9231 if(OnFileModified(action, param))
9232 fileMonitor.StartMonitoring();
9237 FontResource setFont, systemFont;
9238 FontResource usedFont;
9239 FontResource captionFont;
9241 FileDialog saveDialog;
9243 SizeAnchor sizeAnchor;
9245 // FormDesigner data
9248 Extent * tempExtents; //[4];
9249 BitmapResource icon;
9251 CreationActivationOption creationActivation;
9254 bool active:1; // true if window and ancestors are active
9255 bool acquiredInput:1; // true if the window is processing state based input
9256 bool modifiedDocument:1;
9257 bool disabled:1; // true if window cannot interact
9258 bool isForegroundWindow:1;// true while a root window is being activated
9259 bool visible:1; // Visibility flag
9260 bool destroyed:1; // true if window is being destroyed
9261 bool anchored:1; // true if this window is repositioned when the parent resizes
9262 bool dirty:1; // Flag set to true if any descendant must be redrawn
9268 bool modifyVirtArea:1;
9269 bool noAutoScrollArea:1;
9272 bool setVisible:1; // FOR FORM DESIGNER
9278 bool useSharedMemory:1;
9281 bool nativeDecorations:1;
9282 bool manageDisplay:1;
9285 WindowController controller;
9286 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9289 public class CommonControl : Window
9291 // creationActivation = doNothing;
9294 public class Percentage : float
9296 char * OnGetString(char * string, float * fieldData, bool * needClass)
9300 sprintf(string, "%.2f", this);
9301 c = strlen(string)-1;
9304 if(string[c] != '0')
9305 last = Max(last, c);
9306 if(string[c] == '.')
9319 public void ApplySkin(Class c, char * name, void ** vTbl)
9321 char className[1024];
9326 subclass(Window) wc = (subclass(Window))c;
9327 subclass(Window) base = (subclass(Window))c.base;
9329 sprintf(className, "%sSkin_%s", name, c.name);
9330 wc.pureVTbl = c._vTbl;
9331 c._vTbl = new void *[c.vTblSize];
9332 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9333 sc = eSystem_FindClass(c.module.application, className);
9337 for(m = 0; m < c.base.vTblSize; m++)
9339 if(c._vTbl[m] == base.pureVTbl[m])
9340 c._vTbl[m] = vTbl[m];
9345 for(m = 0; m < c.vTblSize; m++)
9347 if(sc._vTbl[m] != wc.pureVTbl[m])
9348 c._vTbl[m] = sc._vTbl[m];
9352 for(d = c.derivatives.first; d; d = d.next)
9354 ApplySkin(d.data, name, c._vTbl);
9358 public void UnapplySkin(Class c)
9360 char className[1024];
9362 subclass(Window) wc = (subclass(Window))c;
9363 subclass(Window) base = (subclass(Window))c.base;
9366 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9369 c._vTbl = wc.pureVTbl;
9373 for(d = c.derivatives.first; d; d = d.next)
9375 UnapplySkin(d.data);
9379 void CheckFontIntegrity(Window window)
9384 if(window.usedFont && window.usedFont.font == 0xecececec)
9386 FontResource uf = window.usedFont;
9387 char * className = window._class.name;
9388 char * text = window.text;
9391 for(c = window.firstChild; c; c = c.next)
9392 CheckFontIntegrity(c);
9396 public class ControllableWindow : Window
9398 /*WindowController controller;
9399 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9400 ~ControllableWindow() { delete controller; }*/
9403 class WindowControllerInterface : ControllableWindow
9405 bool OnKeyDown(Key key, unichar ch)
9407 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9409 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9413 bool OnKeyUp(Key key, unichar ch)
9415 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9417 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9421 bool OnKeyHit(Key key, unichar ch)
9423 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9425 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9429 bool OnMouseMove(int x, int y, Modifiers mods)
9431 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9433 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9437 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9439 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9441 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9445 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9447 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9449 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9453 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9455 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9457 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9461 bool OnRightButtonDown(int x, int y, Modifiers mods)
9463 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9465 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9469 bool OnRightButtonUp(int x, int y, Modifiers mods)
9471 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9473 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9477 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9479 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9481 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9485 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9487 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9489 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9493 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9495 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9497 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9501 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9503 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9505 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9509 void OnResize(int width, int height)
9511 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9512 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9515 void OnRedraw(Surface surface)
9517 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9518 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9523 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9525 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9530 public class WindowController<class V>
9533 property Window window
9537 uint size = class(Window).vTblSize;
9540 windowVTbl = new void *[size];
9541 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9542 if(value._vTbl == value._class._vTbl)
9544 value._vTbl = new void *[value._class.vTblSize];
9545 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9549 for(c = 0; c < size; c++)
9551 void * function = class(WindowControllerInterface)._vTbl[c];
9552 if(function != DefaultFunction)
9553 value._vTbl[c] = function;
9555 value._vTbl[c] = windowVTbl[c];
9560 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9563 get { return window; }
9565 property V controlled
9567 set { controlled = value; }
9568 get { return controlled; }
9570 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9571 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9572 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9573 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9574 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9575 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9576 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9577 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9578 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9579 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9580 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9581 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9582 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9583 virtual void V::OnResize(WindowController controller, int width, int height);
9584 virtual void V::OnRedraw(WindowController controller, Surface surface);
9585 virtual bool V::OnCreate(WindowController controller);
9588 int (** windowVTbl)();