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 GetDecorationsSize(&ew, &eh);
1007 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1009 if(parent.sbv && !parent.sbv.style.hidden)
1010 pw += guiApp.currentSkin.VerticalSBW();
1011 if(parent.sbh && !parent.sbh.style.hidden)
1012 ph += guiApp.currentSkin.HorizontalSBH();
1014 if(anchor.left.type == cascade)
1016 w = (int)(pw * 0.80);
1017 h = (int)(ph * 0.80);
1019 else if(anchor.left.type >= vTiled)
1024 numTiling = parent.numPositions - parent.numIcons;
1025 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1026 if(anchor.left.type == vTiled)
1028 tilingH = (int)sqrt(numTiling);
1029 tilingW = numTiling / tilingH;
1033 tilingW = (int)sqrt(numTiling);
1034 tilingH = numTiling / tilingW;
1037 leftOver = numTiling - tilingH * tilingW;
1040 tilingSplit = (tilingW - leftOver) * tilingH;
1041 tilingLastH = tilingH+1;
1044 tilingSplit = numTiling;
1046 if(positionID >= tilingSplit)
1048 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1049 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1050 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1051 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1055 x = pw * (positionID / tilingH) / tilingW;
1056 y = ph * (positionID % tilingH) / tilingH;
1057 x2 = pw * (positionID / tilingH + 1) / tilingW;
1058 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1062 SNAPDOWN(x, textCellW);
1063 SNAPDOWN(y, textCellH);
1064 SNAPDOWN(x2, textCellW);
1065 SNAPDOWN(y2, textCellH);
1073 if(sizeAnchor.isClientW) w += ew;
1074 if(sizeAnchor.isClientH) h += eh;
1076 if(anchor.left.type == offset)
1077 x = anchor.left.distance;
1078 else if(anchor.left.type == relative)
1079 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1080 else if(anchor.right.type == relative)
1081 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1082 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1083 else if(anchor.right.type == offset)
1084 ex = vpw - anchor.right.distance;
1086 if(anchor.top.type == offset)
1087 y = anchor.top.distance;
1088 else if(anchor.top.type == relative)
1089 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1090 else if(anchor.bottom.type == relative)
1091 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1092 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1093 else if(anchor.bottom.type == offset)
1094 ey = vph - anchor.bottom.distance;
1096 if(anchor.left.type && anchor.right.type)
1098 switch(anchor.right.type)
1101 ex = pw * (1.0f-anchor.right.percent);
1102 w = Max((int)(ex + 0.5) - x, 0);
1105 ex = vpw - anchor.right.distance;
1106 w = Max((int)(ex + 0.5) - x, 0);
1110 if(anchor.top.type && anchor.bottom.type)
1112 switch(anchor.bottom.type)
1115 ey = ph * (1.0f-anchor.bottom.percent);
1116 h = Max((int)(ey + 0.5) - y, 0);
1119 ey = vph - anchor.bottom.distance;
1120 h = Max((int)(ey + 0.5) - y, 0);
1129 if(state == normal /*|| state == Hidden*/)
1131 bool addSbV = false, addSbH = false;
1133 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1134 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1136 w = Max(w, minSize.w);
1137 h = Max(h, minSize.h);
1138 w = Min(w, maxSize.w);
1139 h = Min(h, maxSize.h);
1141 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1143 if(w) w -= guiApp.currentSkin.VerticalSBW();
1146 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1148 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1152 if(!OnResizing(&w, &h))
1158 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1159 w += guiApp.currentSkin.VerticalSBW();
1160 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1161 h += guiApp.currentSkin.HorizontalSBH();
1163 w = Max(w, skinMinSize.w);
1164 h = Max(h, skinMinSize.h);
1177 SNAPDOWN(w, textCellW);
1178 SNAPDOWN(h, textCellH);
1181 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1183 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1186 (pw - w) / CASCADE_SPACE,
1187 (ph - h) / CASCADE_SPACE);
1193 cascW = (pw - w) / (numCascade-1);
1194 cascH = (ph - h) / (numCascade-1);
1195 SNAPDOWN(cascW, textCellW);
1196 SNAPDOWN(cascH, textCellH);
1197 cascadeW = (float)cascW;
1198 cascadeH = (float)cascH;
1202 numCascade = Max(numCascade, 2);
1203 cascadeW = (float)(pw - w) / (numCascade-1);
1204 cascadeH = (float)(ph - h) / (numCascade-1);
1207 x = (int)((positionID % numCascade) * cascadeW);
1208 y = (int)((positionID % numCascade) * cascadeH);
1210 else if(anchor.left.type < vTiled)
1212 if(!anchor.left.type || anchor.horz.type == middleRelative)
1214 if(!anchor.right.type)
1216 if(anchor.horz.type == middleRelative)
1217 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1219 x = vpw / 2 + anchor.horz.distance - w / 2;
1225 // case A_EDGE: x = x - w; break;
1227 if(!anchor.top.type || anchor.vert.type == middleRelative)
1229 if(!anchor.bottom.type)
1231 if(anchor.vert.type == middleRelative)
1232 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1234 y = vph / 2 + anchor.vert.distance - h / 2;
1240 // case A_EDGE: y = y - h; break;
1243 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1251 SNAPDOWN(x, textCellW);
1252 SNAPDOWN(y, textCellH);
1264 if(anchored && style.fixed && style.isActiveClient)
1269 void UpdateCaret(bool forceUpdate, bool erase)
1271 static Window lastWindow = null;
1272 static int caretX, caretY, caretSize;
1274 if(guiApp && guiApp.caretOwner == this)
1276 int x = caretPos.x - scroll.x;
1277 int y = caretPos.y - scroll.y;
1279 if((erase || this.caretSize) &&
1280 x >= clientArea.left && x <= clientArea.right &&
1281 y >= clientArea.top && y <= clientArea.bottom)
1285 guiApp.interfaceDriver.SetCaret(
1286 x + absPosition.x + clientStart.x,
1287 y + absPosition.y + clientStart.y, this.caretSize);
1288 guiApp.caretEnabled = true;
1290 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1294 if(lastWindow != this)
1296 updateBox.left = x + 1;
1298 updateBox.right = x + 2;
1299 updateBox.bottom = y + this.caretSize - 1;
1303 updateBox.left = Min(x + 1, caretX + 1);
1304 updateBox.top = Min(y, caretY);
1305 updateBox.right = Max(x + 2, caretX + 2);
1306 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1309 guiApp.caretOwner.Update(updateBox);
1316 caretSize = this.caretSize;
1322 guiApp.interfaceDriver.SetCaret(0,0,0);
1323 guiApp.caretEnabled = false;
1329 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1334 scrolledPos.x = position.x = x;
1335 scrolledPos.y = position.y = y;
1337 clientSize.w = size.w = w;
1338 clientSize.h = size.h = h;
1340 if(parent && !style.nonClient)
1342 //if(!style.fixed || style.isDocument)
1344 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1345 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1349 clientStart.x = clientStart.y = 0;
1351 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1353 //if(!activeClient || activeClient.state != maximized)
1354 if(!noAutoScrollArea)
1356 // Check if scroll area must be modified
1357 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1359 bool foundChild = false;
1361 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1362 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1363 for(child = children.first; child; child = child.next)
1365 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1366 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1368 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1369 w = Max(w, child.position.x + child.size.w);
1370 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1371 w = Max(w, Max(child.position.x, 0) + child.size.w);
1372 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1373 h = Max(h, child.position.y + child.size.h);
1374 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1375 h = Max(h, Max(child.position.y, 0) + child.size.h);
1380 if(foundChild && (w > cw || h > ch))
1382 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1384 int stepX = sbStep.x, stepY = sbStep.y;
1385 // Needed to make snapped down position match the skin's check of client area
1386 // against realvirtual
1389 SNAPDOWN(stepX, textCellW);
1390 SNAPDOWN(stepY, textCellH);
1391 stepX = Max(stepX, textCellW);
1392 stepY = Max(stepY, textCellH);
1394 if(scrollFlags.snapX)
1396 if(scrollFlags.snapY)
1399 reqScrollArea.w = w;
1400 reqScrollArea.h = h;
1403 else if(reqScrollArea.w || reqScrollArea.h)
1405 reqScrollArea.w = 0;
1406 reqScrollArea.h = 0;
1407 SetScrollPosition(0,0);
1412 // Automatic MDI Client Scrolling Area Adjustment
1413 if(parent && !parent.noAutoScrollArea)
1415 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1416 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1418 Window parent = this.parent;
1419 int w = parent.reqScrollArea.w;
1420 int h = parent.reqScrollArea.h;
1422 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1423 w = Max(w, position.x + size.w);
1424 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1425 w = Max(w, Max(position.x, 0) + size.w);
1426 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1427 h = Max(h, position.y + size.h);
1428 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1429 h = Max(h, Max(position.y, 0) + size.h);
1431 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1432 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1434 /*bool resize = false;
1435 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1436 // Needed to make snapped down position match the skin's check of client area
1437 // against realvirtual
1440 SNAPDOWN(stepX, textCellW);
1441 SNAPDOWN(stepY, textCellH);
1442 stepX = Max(stepX, textCellW);
1443 stepY = Max(stepY, textCellH);
1445 if(parent.scrollFlags.snapX)
1447 if(parent.scrollFlags.snapY)
1449 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1451 parent.reqScrollArea.w = w;
1452 parent.reqScrollArea.h = h;*/
1454 // parent.UpdateScrollBars(true, true);
1455 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1456 false, true, true, true, false, false);
1461 GetRidOfVirtualArea();
1465 UpdateScrollBars(modifyThisArea, false);
1466 else if(guiApp.currentSkin)
1469 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1471 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1472 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1473 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1474 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1477 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1478 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1480 absPosition = scrolledPos;
1481 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1482 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1484 if(this != guiApp.desktop && parent)
1486 absPosition.x += parent.absPosition.x;
1487 absPosition.y += parent.absPosition.y;
1488 if(!style.nonClient && this != guiApp.desktop)
1490 absPosition.x += parent.clientStart.x;
1491 absPosition.y += parent.clientStart.y;
1495 box = Box { 0, 0, size.w - 1, size.h - 1 };
1500 // Clip against parent's client area
1501 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1503 // Compute client area in this window coordinate system
1504 clientArea.left = 0;
1506 clientArea.right = clientSize.w - 1;
1507 clientArea.bottom = clientSize.h - 1;
1509 // Clip against parent's client area
1511 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1515 //absPosition.x -= parent.clientStart.x;
1516 //absPosition.y -= parent.clientStart.y;
1519 // Adjust all children
1520 for(child = children.first; child; child = child.next)
1521 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1523 UpdateCaret(false, false);
1526 void GetRidOfVirtualArea(void)
1528 if(parent && !parent.destroyed && style.fixed &&
1529 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1530 parent.reqScrollArea.w && parent.reqScrollArea.h)
1532 if(!parent.noAutoScrollArea)
1536 for(child = children.first; child; child = child.next)
1538 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1540 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1541 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1550 Window parent = this.parent;
1552 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1553 false, true, true, true, false, false);
1555 parent.SetScrollArea(0,0,true);
1556 parent.SetScrollPosition(0,0);
1562 public void ExternalPosition(int x, int y, int w, int h)
1564 Position(x, y, w, h, false, true, true, true, false, false);
1567 // (w, h): Full window size
1568 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1570 bool result = false;
1571 int oldCW = clientSize.w, oldCH = clientSize.h;
1572 bool clientResized, windowResized, windowMoved;
1574 bool realResized = size.w != w || size.h != h;
1576 // TOCHECK: This wasn't in ecere.dll
1577 //if(!parent) return true;
1578 if(destroyed) return false;
1580 windowMoved = position.x != x || position.y != y || force;
1582 // windowResized = realResized || force;
1583 windowResized = size.w != w || size.h != h || force;
1585 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1591 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1592 scrolledPos.x - parent.clientStart.x + this.box.right,
1593 scrolledPos.y - parent.clientStart.y + this.box.bottom
1599 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1604 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1606 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1608 if(display && rootWindow != this)
1611 if(guiApp && guiApp.windowMoving)
1613 if(guiApp.windowMoving.style.nonClient)
1614 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1616 guiApp.windowMoving.parent.SetMouseRangeToClient();
1628 // Process Anchored Children
1632 for(child = children.first; child; child = child.next)
1635 ((child.stateAnchor.left.type != offset ||
1636 child.stateAnchor.top.type != offset ||
1637 child.stateAnchor.right.type != none ||
1638 child.stateAnchor.bottom.type != none) ||
1639 child.state == maximized || child.state == minimized))
1641 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1643 // child.Position(x, y, w, h, false, true, true, true, false);
1644 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1645 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1651 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1652 //if(updateScrollBars)
1654 OnResize(clientSize.w, clientSize.h);
1656 if((clientResized || windowMoved) && created)
1657 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1659 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1661 Window master = guiApp.interimWindow.master;
1662 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1665 if(rootWindow == this && !is3D)
1669 x -= guiApp.desktop.absPosition.x;
1670 y -= guiApp.desktop.absPosition.y;
1672 //guiApp.Log("Position %s\n", caption);
1673 if(windowResized || windowMoved)
1674 if(display && !display.flags.memBackBuffer && changeRootWindow)
1675 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1677 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1678 for(child = parent.children.first; child && child != this; child = child.next)
1679 if(child.rootWindow)
1680 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1684 if(windowMoved || windowResized)
1686 display.Lock(true /*false*/);
1689 display.Position(absPosition.x, absPosition.y);
1692 // result = realResized ? display.Resize(size.w, size.h) : true;
1693 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1697 else if(clientResized)
1699 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1702 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1706 if(windowMoved || windowResized)
1711 if(guiApp.driver && changeRootWindow)
1713 if(windowResized || windowMoved)
1714 if(!display || display.flags.memBackBuffer)
1715 guiApp.interfaceDriver.PositionRootWindow(this,
1716 x, y, w, h, windowMoved, windowResized);
1717 guiApp.interfaceDriver.UpdateRootWindow(this);
1719 for(child = children.first; child; child = child.next)
1721 if(child.is3D && child.created)
1723 // Copy Display Content
1724 child.display.displaySystem = display.displaySystem;
1725 child.display.window = display.window;
1726 child.display.current = display.current;
1727 child.display.width = display.width;
1728 child.display.height = display.height;
1729 child.display.driverData = display.driverData;
1730 child.display.mutex = null;
1741 void UpdateScrollBars(bool flag, bool fullThing)
1744 bool resizeH = false, resizeV = false;
1745 bool scrolled = false;
1746 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1747 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1749 if(destroyed) return;
1750 if(guiApp.currentSkin)
1752 MinMaxValue cw = 0, ch = 0;
1753 bool sbvVisible, sbhVisible;
1755 int positionH, positionV;
1757 // First get client area with no respect to scroll bars
1762 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1764 if(scrollFlags.dontHide)
1767 cw -= guiApp.currentSkin.VerticalSBW();
1769 ch -= guiApp.currentSkin.HorizontalSBH();
1771 // Update the scrollbar visibility
1777 sbh.disabled = rangeH <= 1;
1778 if(sbh.style.hidden)
1788 sbv.disabled = rangeV <= 1;
1789 if(sbv.style.hidden)
1797 // Then start off with horizontal scrollbar range
1800 positionH = sbh.thumbPosition;
1805 ch -= guiApp.currentSkin.HorizontalSBH();
1808 // Do the same for vertical scrollbar
1811 positionV = sbv.thumbPosition;
1817 cw -= guiApp.currentSkin.VerticalSBW();
1818 // Maybe we need to set the range on the horizontal scrollbar again
1823 sbh.Action(setRange, positionH, 0);
1824 if(rangeH <= 1 && sbh.range > 1)
1826 ch -= guiApp.currentSkin.HorizontalSBH();
1830 sbv.Action(setRange, positionV, 0);
1837 // Update the scrollbar visibility
1838 if(!scrollFlags.dontHide)
1840 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1844 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1851 if(guiApp.currentSkin)
1858 sbhVisible = sbh.style.hidden ? true : false;
1860 sbvVisible = sbv.style.hidden ? true : false;
1862 // Do our resize here
1863 if(flag && (resizeH || resizeV) && fullThing)
1865 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1870 OnResize(clientSize.w, clientSize.h);
1876 sbh.visible = sbhVisible;
1878 sbv.visible = sbvVisible;
1880 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1881 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1884 sbh.pageStep = clientSize.w;
1886 sbv.pageStep = clientSize.h;
1888 // Notify doesn't handle setRange anymore... process it here
1891 int positionH = sbh.thumbPosition;
1892 if(scroll.x != positionH)
1894 OnHScroll(setRange, positionH, 0);
1898 SNAPDOWN(positionH, textCellW);
1899 scroll.x = positionH;
1905 int seen = clientSize.w, total = reqScrollArea.w;
1908 if(scrollFlags.snapX)
1909 SNAPDOWN(seen, sbStep.x);
1911 if(!total) total = seen;
1912 range = total - seen + 1;
1914 range = Max(range, 1);
1916 if(x >= range) x = range - 1;
1918 if(scrollFlags.snapX)
1919 SNAPUP(x, sbStep.x);
1923 OnHScroll(setRange, x, 0);
1928 SNAPDOWN(x, textCellW);
1934 int positionV = sbv.thumbPosition;
1935 if(scroll.y != positionV)
1937 OnVScroll(setRange, positionV, 0);
1941 SNAPDOWN(positionV, textCellH);
1942 scroll.y = positionV;
1948 int seen = clientSize.h, total = reqScrollArea.h;
1951 if(scrollFlags.snapY)
1952 SNAPDOWN(seen, sbStep.y);
1954 if(!total) total = seen;
1955 range = total - seen + 1;
1956 range = Max(range, 1);
1958 if(y >= range) y = range - 1;
1960 if(scrollFlags.snapY)
1961 SNAPUP(y, sbStep.y);
1965 OnVScroll(setRange, y, 0);
1970 SNAPDOWN(y, textCellH);
1976 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
1979 for(child = children.first; child; child = child.next)
1981 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
1984 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
1985 child.Position(x, y, w, h, false, true, false, true, false, false);
1992 // Process Scrollbars
1994 if(sbh) // && !sbh.style.hidden
1996 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
1997 // Need to set the range again (should improve...) since the scrollbars didn't have
1998 // the right size when UpdateScrollArea set the range on it
2001 sbh.seen = clientSize.w;
2005 if(sbv) // && !sbv.state.hidden
2007 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2008 // Need to set the range again (should improve...) since the scrollbars didn't have
2009 // the right size when UpdateScrollArea set the range on it
2012 sbv.seen = clientSize.h;
2017 // TESTING THIS LOWER
2018 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2021 for(child = children.first; child; child = child.next)
2023 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2026 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2027 child.Position(x, y, w, h, false, true, false, true, false, false);
2033 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2035 SetState(maximized, false, mods);
2039 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2041 SetState(normal, false, mods);
2045 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2047 SetState(minimized, false, mods);
2048 parent.CycleChildren(false, true, false, true);
2052 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2055 // Scroll bar notifications
2056 if(action != setRange)
2058 bool changed = false;
2062 if(scroll.x != position)
2064 OnHScroll(action, position, keyFlags);
2069 SNAPDOWN(position, textCellW);
2071 scroll.x = position;
2075 if(scroll.y != position)
2077 OnVScroll(action, position, keyFlags);
2082 SNAPDOWN(position, textCellH);
2084 scroll.y = position;
2088 bool childMove = false;
2089 for(child = children.first; child; child = child.next)
2091 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2094 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2095 child.Position(x, y, w, h, false, true, false, true, false, false);
2099 // Testing this patch out to solve MDI workspace redraw bugs
2100 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2101 // Scroll offsets to blame?
2105 UpdateCaret(false, false);
2109 // Testing this patch out to solve MDI workspace redraw bugs
2110 for(child = children.first; child; child = child.next)
2112 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2121 void CreateSystemChildren(void)
2123 Window parent = this;
2124 bool scrollBarChanged = false;
2125 bool hasClose = false, hasMaxMin = false;
2126 Point scroll = this.scroll;
2128 if(state == maximized && this.parent.menuBar)
2130 if(this.parent.activeClient == this)
2131 parent = this.parent.menuBar;
2138 if(style.hasClose) hasClose = true;
2139 if(style.hasMaximize || style.hasMinimize)
2146 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2148 sysButtons[2].Destroy(0);
2149 sysButtons[2] = null;
2151 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2153 sysButtons[1].Destroy(0);
2154 sysButtons[1] = null;
2156 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2158 sysButtons[0].Destroy(0);
2159 sysButtons[0] = null;
2162 if(hasClose && parent)
2169 parent, master = this,
2170 inactive = true, nonClient = true, visible = false;
2172 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2178 if(this.parent == guiApp.desktop)
2179 sysButtons[2].hotKey = altF4;
2180 else if(style.isActiveClient)
2181 sysButtons[2].hotKey = ctrlF4;
2182 sysButtons[2].Create();
2185 sysButtons[2].symbol = 'X';
2186 sysButtons[2].disabled = !style.hasClose;
2189 if(hasMaxMin && parent)
2193 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2194 if(state == maximized)
2197 method = RestoreButtonClicked;
2203 method = MaximizeButtonClicked;
2211 parent, master = this,
2212 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2214 sysButtons[1].Create();
2216 sysButtons[1].NotifyClicked = method;
2218 sysButtons[1].symbol = symbol;
2219 sysButtons[1].disabled = !style.hasMaximize;
2222 if(hasMaxMin && parent)
2226 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2227 if (state == minimized)
2230 method = RestoreButtonClicked;
2236 method = MinimizeButtonClicked;
2244 parent, master = this,
2245 hotKey = altM, inactive = true, nonClient = true, visible = false
2247 sysButtons[0].Create();
2249 sysButtons[0].NotifyClicked = method;
2251 sysButtons[0].symbol = symbol;
2252 sysButtons[0].disabled = !style.hasMinimize;
2255 // Create the scrollbars
2256 if(style.hasHorzScroll && !sbh)
2262 direction = horizontal,
2266 snap = scrollFlags.snapX,
2267 NotifyScrolling = ScrollBarNotification
2270 scrollBarChanged = true;
2272 else if(sbh && !style.hasHorzScroll)
2278 if(style.hasVertScroll && !sbv)
2284 direction = vertical,
2288 snap = scrollFlags.snapY,
2289 NotifyScrolling = ScrollBarNotification
2292 scrollBarChanged = true;
2294 else if(sbv && !style.hasVertScroll)
2299 if(scrollBarChanged)
2301 SetScrollLineStep(sbStep.x, sbStep.y);
2302 UpdateScrollBars(true, true);
2306 if(scrollBarChanged)
2308 if(sbh) sbh.thumbPosition = scroll.x;
2309 if(sbv) sbv.thumbPosition = scroll.y;
2313 void UpdateCaption(void)
2315 if(rootWindow == this)
2318 FigureCaption(caption);
2319 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2321 UpdateDecorations();
2324 if(parent.rootWindow == parent && parent.activeClient == this) // Added this last check
2327 parent.FigureCaption(caption);
2328 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2330 parent.UpdateDecorations();
2334 void UpdateActiveDocument(Window previous)
2336 Window activeClient = this.activeClient;
2337 Window activeChild = this.activeChild;
2344 activeClient.CreateSystemChildren();
2346 previous.CreateSystemChildren();
2357 if(activeClient && activeClient.menu && activeClient.state != minimized)
2361 //activeClient.menu.Clean(activeClient);
2362 menu.Merge(activeClient.menu, true, activeClient);
2366 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2369 menu.Merge(activeChild.menu, true, activeChild);
2372 // Build window list
2375 Menu windowMenu = menu.FindMenu("Window");
2380 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2383 Window document = cycle.data;
2384 if(!document.style.nonClient && document.style.isActiveClient)
2386 char name[2048], caption[2048];
2387 document.FigureCaption(caption);
2388 sprintf(name, "%d %s", id+1, caption);
2389 windowMenu.AddDynamic(MenuItem
2391 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2392 NotifySelect = MenuWindowSelectWindow
2396 if(activeClient.cycle == cycle) break;
2401 if((!previous && activeClient) || !activeClient)
2407 item = menu.FindItem(MenuWindowCloseAll, 0);
2408 if(item) item.disabled = false;
2409 item = menu.FindItem(MenuWindowNext, 0);
2410 if(item) item.disabled = false;
2411 item = menu.FindItem(MenuWindowPrevious, 0);
2412 if(item) item.disabled = false;
2413 item = menu.FindItem(MenuWindowCascade, 0);
2414 if(item) item.disabled = false;
2415 item = menu.FindItem(MenuWindowTileHorz, 0);
2416 if(item) item.disabled = false;
2417 item = menu.FindItem(MenuWindowTileVert, 0);
2418 if(item) item.disabled = false;
2419 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2420 if(item) item.disabled = false;
2421 item = menu.FindItem(MenuWindowWindows, 0);
2422 if(item) item.disabled = false;
2425 item = menu.FindItem(MenuFileClose, 0);
2426 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2427 item = menu.FindItem(MenuFileSaveAll, 0);
2428 if(item) item.disabled = numDocuments < 1;
2430 // This is called again for a child window change, with same active client
2431 OnActivateClient(activeClient, previous);
2434 void _ShowDecorations(Box box, bool post)
2436 if(nativeDecorations) return;
2437 if(visible && this != guiApp.desktop)
2439 Surface surface = RedrawFull(box);
2443 FigureCaption(caption);
2446 ShowDecorations(captionFont.font,
2449 active, //parent.activeClient == this
2450 guiApp.windowMoving == this);
2452 PreShowDecorations(captionFont.font,
2455 active, //parent.activeClient == this
2456 guiApp.windowMoving == this);
2463 void UpdateExtent(Box refresh)
2465 Surface surface = null;
2467 if(!manageDisplay) { OnRedraw(null);return; }
2468 _ShowDecorations(refresh, false);
2470 surface = Redraw(refresh);
2471 // Opaque background: just fill before EW_REDRAW (clear?)
2474 surface.SetBackground(background);
2475 surface.SetForeground(foreground);
2476 surface.DrawingChar(' ');
2477 if(this == rootWindow)
2479 if(style.drawBehind || background.a)
2480 surface.Clear(colorBuffer);
2482 else if(background.a)
2486 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2487 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2490 if(display.flags.alpha && background.a < 255 && background)
2492 surface.Area(0,0,clientSize.w, clientSize.h);
2493 /*if(style.clearDepthBuffer)
2494 surface.Clear(depthBuffer);*/
2496 else if(/*style.clearDepthBuffer || */background.a)
2498 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2499 surface.Clear(colorBuffer);
2504 surface.TextFont(usedFont.font);
2505 surface.TextOpacity(false);
2509 // Draw the caret ...
2510 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2512 // surface.SetBackground(0xFFFFFF - background.color);
2513 surface.SetBackground(~background.color);
2515 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2516 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2522 void DrawOverChildren(Box refresh)
2524 Surface surface = Redraw(refresh);
2528 surface.DrawingChar(' ');
2529 surface.SetBackground(background);
2530 surface.SetForeground(foreground);
2532 surface.TextFont(usedFont.font);
2533 surface.TextOpacity(false);
2535 OnDrawOverChildren(surface);
2540 _ShowDecorations(refresh, true);
2543 void ComputeClipExtents(void)
2546 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2548 clipExtent.Copy(this.clipExtent);
2550 for(child = children.last; child; child = child.prev)
2552 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2554 bool opaque = child.IsOpaque(); // TODO: acess background directly
2555 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2557 child.clipExtent.Copy(clipExtent);
2558 child.clipExtent.Offset(-dx, -dy);
2559 child.clipExtent.IntersectBox(child.box);
2561 child.ComputeClipExtents();
2563 if(opaque && !child.style.nonClient)
2565 // Adjust the box for the parent:
2566 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2567 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2572 // ??? Only do this for overlapped window or if parent has with clip children flag
2574 // Do this if window has clip children flag on (default false?)
2575 // this.clipExtent = clipExtent;
2577 clipExtent.Free(null);
2580 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2582 bool opaque = IsOpaque();
2584 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2585 if(rootWindow.nativeDecorations)
2587 offsetX -= rootWindow.clientStart.x;
2588 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2592 for(child = children.last; child; child = child.prev)
2594 ColorAlpha background = *(ColorAlpha *)&child.background;
2595 bool opaque = child.IsOpaque();
2596 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2600 // Adjust renderArea to the root window level
2601 Extent * renderArea = &rootWindow.tempExtents[1];
2603 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2604 if(child.rootWindow.nativeDecorations)
2606 offsetX -= child.rootWindow.clientStart.x;
2607 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2611 Extent childRenderArea;
2613 if(backBufferUpdate != null)
2615 childRenderArea.Copy(backBufferUpdate);
2616 childRenderArea.Offset(-offsetX, -offsetY);
2619 childRenderArea.Copy(child.dirtyArea);
2621 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2622 renderArea.Copy(dirtyExtent);
2623 renderArea.Offset(-offsetX, -offsetY);
2624 childRenderArea.Union(renderArea);
2627 // Intersect with the clip extent
2628 childRenderArea.Intersection(child.clipExtent);
2631 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2632 renderArea->Offset(offsetX, offsetY);
2633 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2634 // overDirtyExtent.Union(renderArea);
2635 renderArea->Empty();
2636 // childRenderArea.Free();
2638 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2643 for(child = children.last; child; child = child.prev)
2645 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2647 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2652 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2654 bool opaque = IsOpaque();
2655 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2657 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2658 if(rootWindow.nativeDecorations)
2660 offsetX -= rootWindow.clientStart.x;
2661 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2665 for(child = children.last; child; child = child.prev)
2667 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2669 ColorAlpha background = *(ColorAlpha *)&child.background;
2670 bool opaque = child.IsOpaque();
2671 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2675 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2676 // Adjust renderArea to the root window level
2678 renderArea.Copy(child.dirtyArea);
2679 renderArea.Offset(offsetX, offsetY);
2680 dirtyExtent.Union(renderArea);
2681 overDirtyExtent.Union(renderArea);
2687 for(child = children.last; child; child = child.prev)
2689 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2691 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2695 if(backBufferUpdate != null)
2697 renderArea.Copy(backBufferUpdate);
2698 renderArea.Offset(-offsetX, -offsetY);
2700 overRenderArea.Copy(backBufferUpdate);
2701 overRenderArea.Offset(-offsetX, -offsetY);
2707 renderArea.Copy(dirtyArea);
2709 overRenderArea.Copy(dirtyArea);
2712 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2713 dirtyExtentWindow->Copy(dirtyExtent);
2714 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2715 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2716 dirtyExtentWindow->Empty();
2718 // Intersect with the clip extent
2719 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2722 if(renderArea.count > 10)
2725 printf("\nToo many extents (%d):\n", renderArea.count);
2727 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2728 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2733 for(c = 0; c<10; c++)
2736 FASTLIST_LOOP(renderArea, extentBox)
2738 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2740 renderArea.Copy(extent);
2742 FASTLIST_LOOP(renderArea, extentBox)
2745 printf("(%d, %d) - (%d, %d)\n",
2746 extentBox.box.left, extentBox.box.top,
2747 extentBox.box.right, extentBox.box.bottom);
2751 printf("\nNow %d\n", renderArea.count);
2757 // WHY WAS THIS COMMENTED ??
2759 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2760 dirtyExtentWindow->Copy(overDirtyExtent);
2761 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2762 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2763 dirtyExtentWindow->Empty();
2765 // Intersect with the clip extent
2766 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2772 if(scrollExtent.count)
2774 // Subtract render extent from scrolling extent
2775 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2777 if(backBufferUpdate == null)
2779 Extent * dirty = &rootWindow.tempExtents[3];
2782 // Intersect scrolling extent with clip extent
2783 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2785 // offset this scroll to be at the root window level
2786 scrollExtent.Offset(offsetX, offsetY);
2787 // Add area that was scrolled to the dirty extents of the back buffer
2788 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2792 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2793 FASTLIST_LOOP(scrollExtent, scrollBox)
2794 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2799 scrollExtent.Empty();
2801 // Add the exposed extent to the window render area
2802 dirty->Offset(-offsetX, -offsetY);
2803 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2808 // Subtract the window's box from the transparency forced extent
2809 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2815 renderArea.Copy(this.renderArea);
2816 renderArea.Offset(offsetX, offsetY);
2817 dirtyExtent.Union(renderArea);
2823 Extent renderArea { };
2825 renderArea.Copy(overRenderArea);
2826 renderArea.Offset(offsetX, offsetY);
2827 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2832 if(backBufferUpdate != null)
2834 // Remove render area from dirty area
2835 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2837 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2844 // Remove the window render area from the dirty extents of the back buffer
2845 rootWindow.dirtyBack.Exclusion(renderArea);
2849 void Render(Extent updateExtent)
2853 Window rootWindow = this.rootWindow;
2854 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2855 if(rootWindow.nativeDecorations)
2857 offsetX -= rootWindow.clientStart.x;
2858 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2861 if(rootWindow.fullRender)
2870 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2871 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2876 /*if(renderArea.count)
2877 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2880 FASTLIST_LOOP(renderArea, extentBox)
2882 Box box = extentBox.box;
2885 /*printf("(%d, %d) - (%d, %d)\n",
2886 extentBox.box.left, extentBox.box.top,
2887 extentBox.box.right, extentBox.box.bottom);*/
2892 box.left += offsetX;
2894 box.right += offsetX;
2895 box.bottom += offsetY;
2897 if(updateExtent != null)
2898 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2902 for(child = children.first; child; child = child.next)
2903 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
2904 child.Render(updateExtent);
2906 if(rootWindow.fullRender)
2907 DrawOverChildren(box);
2910 // TO DO: There's an issue about draw over children...
2911 // TO DO: Don't wanna go through this if method isn't used
2912 FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
2914 Box box = extentBox.box;
2916 DrawOverChildren(box);
2918 box.left += offsetX;
2920 box.right += offsetX;
2921 box.bottom += offsetY;
2923 if(updateExtent != null)
2924 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2927 for(child = children.first; child; child = child.next)
2928 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
2929 child.Render(updateExtent);
2932 overRenderArea.Empty();
2935 public void UpdateDisplay(void)
2937 if(!manageDisplay) { OnRedraw(null);return; }
2938 if(rootWindow && this != rootWindow)
2939 rootWindow.UpdateDisplay();
2942 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
2943 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
2946 dirtyExtent.Clear();
2949 clipExtent.AddBox(box);
2951 display.StartUpdate();
2953 if(!rootWindow.fullRender)
2955 ComputeClipExtents();
2956 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
2957 ComputeRenderArea(dirtyExtent, overExtent, null);
2960 clipExtent.Free(null);
2962 dirtyExtent.Free(null);
2963 overExtent.Free(null);
2965 if(display.flags.flipping)
2968 display.Update(null);
2972 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
2973 updateExtent.Clear();
2975 Render(updateExtent);
2977 updateExtent.UnionBox(this.box, tempExtents[0]);
2980 //printf("\n\nUpdate:\n------------------------------------------\n");
2983 FASTLIST_LOOP(updateExtent, extentBox)
2986 /*printf("Updating (%d, %d) - (%d, %d)\n",
2987 extentBox.box.left, extentBox.box.top,
2988 extentBox.box.right, extentBox.box.bottom);*/
2991 display.Update(extentBox.box);
2994 updateExtent.Free(null);
2997 display.EndUpdate();
3005 void UpdateBackDisplay(Box box)
3011 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3013 //printf("UpdateBackDisplay going through!\n");
3014 display.StartUpdate();
3018 intersection.Copy(dirtyBack);
3019 intersection.IntersectBox(box);
3021 dirtyExtent.Clear();
3024 clipExtent.AddBox(box);
3026 if(!rootWindow.fullRender)
3028 ComputeClipExtents();
3029 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3032 clipExtent.Free(null);
3034 intersection.Free(null);
3035 dirtyExtent.Free(null);
3036 overExtent.Free(null);
3041 if(display.flags.flipping)
3042 display.Update(null);
3045 rootWindow.display.Update(box);
3048 display.EndUpdate();
3052 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3053 if(dirtyBack.count > MAX_DIRTY_BACK)
3055 BoxItem extentBox, next;
3056 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3057 FASTLIST_LOOPN(dirtyBack, extentBox, next)
3059 if(extentBox != first)
3061 if(extentBox.box.left < first.box.left)
3062 first.box.left = extentBox.box.left;
3063 if(extentBox.box.top < first.box.top)
3064 first.box.top = extentBox.box.top;
3065 if(extentBox.box.right > first.box.right)
3066 first.box.right = extentBox.box.right;
3067 if(extentBox.box.bottom > first.box.bottom)
3068 first.box.bottom = extentBox.box.bottom;
3069 dirtyBack.Delete(extentBox);
3078 // --- Window positioning ---
3079 // --- Window identification ---
3081 // Returns window at position "Position"
3082 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3084 Window child, result = null;
3086 box.left += absPosition.x;
3087 box.right += absPosition.x;
3088 box.top += absPosition.y;
3089 box.bottom += absPosition.y;
3091 if(!destroyed && visible && (acceptDisabled || !disabled))
3093 int lx = x - absPosition.x;
3094 int ly = y - absPosition.y;
3095 if(IsInside(lx, ly))
3096 // if(box.IsPointInside(Point{x, y}))
3098 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3099 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3102 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3104 if(child != statusBar && child.rootWindow == rootWindow)
3106 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3113 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3115 if(child != statusBar && child.rootWindow == rootWindow)
3117 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3129 Window FindModal(void)
3131 Window modalWindow = this, check;
3132 Window check2 = null;
3133 for(check = this; check.master; check = check.master)
3135 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3137 modalWindow = check.master.modalSlave;
3138 check = modalWindow;
3140 // TESTING THIS FOR DROPBOX...
3141 if(!rootWindow || !rootWindow.style.interim)
3143 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3145 if(check2.modalSlave && check2.modalSlave.created)
3147 modalWindow = check2.modalSlave;
3155 if(modalWindow == this)
3157 for(check = this; check.activeChild; check = check.activeChild)
3159 if(check.modalSlave)
3161 modalWindow = check.modalSlave;
3167 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3168 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3171 void StopMoving(void)
3173 if(this == guiApp.windowMoving)
3175 guiApp.windowMoving = null;
3176 UpdateDecorations();
3177 SetMouseRange(null);
3180 if(rootWindow.active)
3181 guiApp.interfaceDriver.StopMoving(rootWindow);
3184 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3185 guiApp.windowIsResizing = false;
3189 void SelectMouseCursor(void)
3194 Window cursorWindow = null;
3195 bool rx, ry, rex, rey;
3197 guiApp.desktop.GetMousePosition(&x, &y);
3198 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3200 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3201 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3202 else if(mouseWindow)
3204 modalWindow = mouseWindow.FindModal();
3205 x -= mouseWindow.absPosition.x;
3206 y -= mouseWindow.absPosition.y;
3207 if(guiApp.windowIsResizing)
3209 rex = guiApp.resizeEndX;
3210 rey = guiApp.resizeEndY;
3211 rx = guiApp.resizeX;
3212 ry = guiApp.resizeY;
3213 if((rex && rey) || (rx && ry))
3214 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3215 else if((rex && ry) || (rx && rey))
3216 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3217 else if((ry || rey) && (!rx && !rex))
3218 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3219 else if((rx || rex) && (!ry && !rey))
3220 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3222 else if(!modalWindow && !guiApp.windowCaptured &&
3223 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3224 &rx, &ry, &rex, &rey))
3226 if((rex && rey) || (rx && ry))
3227 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3228 else if((rex && ry) || (rx && rey))
3229 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3230 else if((ry || rey) && (!rx && !rex))
3231 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3232 else if((rx || rex) && (!ry && !rey))
3233 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3235 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3237 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3238 cursorWindow = mouseWindow.parent;
3240 cursorWindow = mouseWindow;
3242 else if(!guiApp.interimWindow)
3243 cursorWindow = guiApp.windowCaptured;
3246 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3247 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3249 else if(modalWindow)
3251 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3253 else if(guiApp.interimWindow)
3255 if(guiApp.interimWindow.cursor)
3256 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3258 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3263 // --- State based input ---
3264 bool AcquireInputEx(bool state)
3269 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3270 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3272 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3274 guiApp.acquiredWindow = state ? this : null;
3277 SetMouseRangeToClient();
3278 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3283 SelectMouseCursor();
3285 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3289 // --- Window activation ---
3290 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3293 if(!parent || !parent.style.inactive)
3295 Window parent = this.parent;
3298 if(rootWindow == this)
3299 Log(active ? "active\n" : "inactive\n");
3302 // Testing this here...
3303 if(!parent || parent == guiApp.desktop || parent.active)
3305 this.active = active;
3308 // TESTING THIS HERE
3309 UpdateDecorations();
3310 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3311 result = NotifyActivate(master, this, active, previous);
3314 this.active = !active;
3319 if(!parent || parent == guiApp.desktop || parent.active)
3321 this.active = active;
3323 AcquireInputEx(active);
3328 if(guiApp.caretOwner)
3332 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3333 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3334 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3335 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3337 guiApp.caretOwner.Update(extent);
3340 if(visible || !guiApp.caretOwner)
3341 guiApp.caretOwner = this;
3342 UpdateCaret(false, false);
3348 this.active = false;
3350 AcquireInputEx(active);
3352 if(!active && guiApp.caretOwner == this)
3354 UpdateCaret(false, true);
3355 guiApp.caretOwner = null;
3356 guiApp.interfaceDriver.SetCaret(0,0,0);
3357 guiApp.caretEnabled = false;
3362 if(!active && parent && parent.activeChild && parent.activeChild != this)
3363 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3369 if(!active && menuBar)
3372 menuBar.OnActivate(false, null, &goOn, true);
3373 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3377 if(!activeChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3386 void ConsequentialMouseMove(bool kbMoving)
3390 if(kbMoving || !guiApp.windowMoving)
3394 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3396 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3398 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3399 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3405 bool IsDescendantOf(Window ancestor)
3408 for(window = this; window && window != ancestor; window = window.parent);
3409 return window == ancestor;
3412 bool IsSlaveOf(Window master)
3415 for(window = this; window && window != master; window = window.master);
3416 return window == master;
3419 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3423 if(this && !destroyed /*&& state != Hidden*/)
3425 Window swap = externalSwap;
3433 if(activateParent &&
3434 (parent.activeChild != this ||
3435 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3436 active && style.modal &&
3437 parent != master && master)
3438 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3444 bool real = parent.activeChild != this;
3446 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3447 if(/*activateParent && */guiApp.interimWindow &&
3448 !IsDescendantOf(guiApp.interimWindow) &&
3449 !IsSlaveOf(guiApp.interimWindow))
3451 Window interimWindow = guiApp.interimWindow;
3452 while(interimWindow && interimWindow != this)
3454 Window master = interimWindow.master;
3456 guiApp.interimWindow = null;
3457 if(guiApp.caretOwner)
3458 guiApp.caretOwner.UpdateCaret(false, false);
3460 incref interimWindow;
3461 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3466 delete interimWindow;
3467 interimWindow = (master && master.style.interim) ? master : null;
3472 guiApp.interimWindow = this;
3473 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3474 guiApp.caretEnabled = false;*/
3475 UpdateCaret(false, true);
3480 bool acquireInput = false;
3482 parent.activeChild &&
3483 parent.activeChild.state == maximized &&
3484 parent != guiApp.desktop;
3486 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3491 swap = parent.activeChild;
3492 if(swap && swap.destroyed) swap = null;
3493 if(swap && swap != this)
3496 if(!swap.PropagateActive(false, this, &goOn, true))
3497 swap = parent.activeChild;
3508 if(!parent || parent.activeChild != this || style.interim)
3511 result = PropagateActive(true, swap, &goOn, true);
3512 if(!result && !goOn)
3517 acquireInput = true;
3521 if(style.hasMaximize && parent != guiApp.desktop)
3524 SetState(maximized, false, 0);
3525 else if(state != maximized)
3528 for(child = parent.children.first; child; child = child.next)
3530 if(this != child && child.state == maximized)
3531 child.SetState(normal, false, 0);
3538 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3540 Window previous = parent.activeClient;
3541 parent.activeChild = this;
3542 if(!style.nonClient /*&& style.isActiveClient*/)
3544 if(style.isActiveClient && !style.hidden)
3545 parent.activeClient = this;
3546 parent.UpdateActiveDocument(previous);
3551 //if(!style.isRemote)
3553 if(rootWindow != this)
3555 if(activateParent && !parent.active /*parent != parent.parent.activeChild*/)
3556 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3558 else if(!guiApp.fullScreenMode)
3560 Window modalRoot = FindModal();
3561 if(!modalRoot) modalRoot = this;
3562 if(!modalRoot.isForegroundWindow)
3564 modalRoot.isForegroundWindow = true;
3565 // To check : Why is parent null?
3566 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3568 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3570 modalRoot.isForegroundWindow = false;
3575 if(result && real && (!style.inactive || moveInactive) && parent)
3577 Window last = parent.children.last;
3579 if(!style.stayOnTop)
3580 for(; last && last.style.stayOnTop; last = last.prev);
3582 parent.children.Move(this, last);
3584 // Definitely don't want that: why not?
3588 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3594 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3601 parent.activeChild = null;
3602 if(!style.nonClient /*&& style.isActiveClient*/)
3604 Window previous = parent.activeClient;
3605 if(style.isActiveClient)
3606 parent.activeClient = null;
3607 parent.UpdateActiveDocument(previous);
3611 if(this == guiApp.interimWindow)
3613 guiApp.interimWindow = null;
3614 if(guiApp.caretOwner)
3615 guiApp.caretOwner.UpdateCaret(false, false);
3617 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3624 if(!active || !swap)
3625 UpdateDecorations();
3627 swap.UpdateDecorations();
3629 if(active && rootWindow != this)
3630 ConsequentialMouseMove(false);
3637 // --- Input Messages ---
3638 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3640 static bool reEntrancy = false;
3641 if(reEntrancy) return;
3645 guiApp.cursorUpdate = true;
3646 if(guiApp.windowScrolling && !consequential)
3648 guiApp.windowScrolling.SetScrollPosition(
3649 (guiApp.windowScrolling.sbh) ?
3650 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3651 (guiApp.windowScrolling.sbv) ?
3652 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3654 if(guiApp.windowMoving)
3656 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3658 Window window = guiApp.windowMoving;
3660 int w = window.size.w;
3661 int h = window.size.h;
3666 rx = mouseX - guiApp.windowMovingStart.x;
3667 ry = mouseY - guiApp.windowMovingStart.y;
3670 window.GetDecorationsSize(&ew, &eh);
3672 if(guiApp.windowIsResizing)
3674 x = window.scrolledPos.x;
3675 y = window.scrolledPos.y;
3679 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3680 rx = guiApp.windowResizingBefore.w - aw;
3681 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3682 w = guiApp.windowResizingBefore.w - rx;
3686 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3687 ry = guiApp.windowResizingBefore.h - ah;
3688 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3689 ry = Max(ry, -guiApp.windowMovingBefore.y);
3690 h = guiApp.windowResizingBefore.h - ry;
3692 if(guiApp.resizeEndX)
3694 w = guiApp.windowResizingBefore.w + rx;
3697 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3705 w = Max(w, window.minSize.w);
3706 h = Max(h, window.minSize.h);
3707 w = Min(w, window.maxSize.w);
3708 h = Min(h, window.maxSize.h);
3710 if(!window.OnResizing(&w, &h))
3712 w = window.clientSize.w;
3713 h = window.clientSize.h;
3716 w = Max(w, window.skinMinSize.w);
3717 h = Max(h, window.skinMinSize.h);
3724 SNAPDOWN(w, textCellW);
3725 SNAPDOWN(h, textCellH);
3730 aw = Max(w,window.skinMinSize.w);
3731 rx = guiApp.windowResizingBefore.w - aw;
3732 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3733 w = guiApp.windowResizingBefore.w - rx;
3737 ah = Max(h,window.skinMinSize.h);
3738 ry = guiApp.windowResizingBefore.h - ah;
3739 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3740 ry = Max(ry, -guiApp.windowMovingBefore.y);
3741 h = guiApp.windowResizingBefore.h - ry;
3746 if(!guiApp.windowIsResizing || guiApp.resizeX)
3747 x = guiApp.windowMovingBefore.x + rx;
3748 if(!guiApp.windowIsResizing || guiApp.resizeY)
3749 y = guiApp.windowMovingBefore.y + ry;
3751 if(!guiApp.windowIsResizing)
3754 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3756 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3757 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3758 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3759 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3763 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3764 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3770 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3772 if(!window.OnMoving(&x, &y, w, h))
3774 x = window.scrolledPos.x;
3775 y = window.scrolledPos.y;
3781 SNAPDOWN(x, textCellW);
3782 SNAPDOWN(y, textCellH);
3785 if(!window.style.nonClient)
3787 if(!window.style.fixed /*|| window.style.isDocument*/)
3789 if(!window.style.dontScrollHorz)
3790 x += window.parent.scroll.x;
3791 if(!window.style.dontScrollVert)
3792 y += window.parent.scroll.y;
3796 // Break the anchors for moveable/resizable windows
3797 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3798 if(window.style.fixed)
3800 if(window.state == normal)
3802 window.normalAnchor = Anchor { left = x, top = y };
3803 window.normalSizeAnchor = SizeAnchor { { w, h } };
3804 window.anchored = false;
3808 window.stateAnchor = Anchor { left = x, top = y };
3809 window.stateSizeAnchor = SizeAnchor { { w, h } };
3811 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3812 // TOCHECK: Investigate why the following only redraws the scrollbars
3813 //window.Position(x, y, w, h, false, true, true, true, false, true);
3815 guiApp.movingLast.x = mouseX;
3816 guiApp.movingLast.y = mouseY;
3822 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3825 bool wasMoving = guiApp.windowMoving ? true : false;
3826 bool wasScrolling = guiApp.windowScrolling ? true : false;
3828 while(result && w != this)
3830 Window msgWindow = GetAtPosition(x,y, false, true, w);
3831 Window trueWindow = GetAtPosition(x,y, false, false, w);
3832 bool windowDragged = false;
3837 window = (w && !w.disabled) ? w : null;
3839 if(trueWindow) incref trueWindow;
3841 if(consequential) mods->isSideEffect = true;
3843 UpdateMouseMove(x, y, consequential);
3845 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3847 if(!guiApp.windowCaptured.isEnabled)
3848 guiApp.windowCaptured.ReleaseCapture();
3850 window = guiApp.windowCaptured;
3853 if(trueWindow && activate &&
3854 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3855 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3856 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3857 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3859 Window modalWindow = trueWindow.FindModal();
3861 if(mods->alt && !mods->ctrl && !mods->shift)
3863 Window moved = trueWindow;
3864 for(moved = trueWindow; moved; moved = moved.parent)
3865 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3870 windowDragged = true;
3872 // Cancel the ALT menu toggling...
3873 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3878 if(window && activate &&
3879 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3880 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3881 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3882 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3884 Window modalWindow = window.FindModal();
3886 /*if(mods->alt && !mods->shift && !mods->ctrl)
3888 Window moved = window;
3889 for(moved = window; moved; moved = moved.parent)
3890 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3895 windowDragged = true;
3897 // Cancel the ALT menu toggling...
3898 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
3904 Window activateWindow = modalWindow ? modalWindow : window;
3905 if(activateWindow && !activateWindow.isRemote)
3907 bool doActivation = true;
3908 //bool needToDoActivation = false;
3909 Window check = activateWindow;
3911 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
3913 if(!check.style.inactive)
3915 //needToDoActivation = true;
3917 doActivation = false;
3922 if(!needToDoActivation)
3923 doActivation = false;
3926 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
3927 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
3931 incref activateWindow;
3932 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
3934 delete activateWindow;
3938 if(activateWindow._refCount == 1)
3940 delete activateWindow;
3944 delete activateWindow;
3946 mods->isActivate = true;
3950 if(!modalWindow && window && !window.destroyed)
3952 if(!guiApp.windowCaptured || windowDragged)
3954 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
3956 bool moving = ((window.state != maximized &&
3957 window.IsMouseMoving(
3958 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
3959 || (guiApp.windowMoving && !guiApp.windowIsResizing);
3961 if(!moving && window.IsMouseResizing(
3962 x - window.absPosition.x,
3963 y - window.absPosition.y,
3964 window.size.w, window.size.h,
3965 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
3967 guiApp.windowIsResizing = true;
3968 guiApp.windowResizingBefore.w = window.size.w;
3969 guiApp.windowResizingBefore.h = window.size.h;
3971 if(guiApp.windowIsResizing || windowDragged || moving)
3974 guiApp.windowMoving = window;
3975 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
3976 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
3977 guiApp.windowMovingBefore.x = window.position.x;//s;
3978 guiApp.windowMovingBefore.y = window.position.y;//s;
3979 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
3980 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
3983 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
3985 if(window.style.fixed &&
3987 window.IsMouseMoving(
3988 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
3990 window.ShowSysMenu(x, y);
3994 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
3996 if(window.sbv || window.sbh)
3999 guiApp.windowScrolling = window;
4000 guiApp.windowScrollingStart.x = x;
4001 guiApp.windowScrollingStart.y = y;
4002 guiApp.windowScrollingBefore.x = window.scroll.x;
4003 guiApp.windowScrollingBefore.y = window.scroll.y;
4006 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4008 if(window.style.hasMaximize &&
4009 window.IsMouseMoving(
4010 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4013 (window.state == maximized) ? normal : maximized, false, *mods);
4021 if(guiApp.windowMoving)
4023 if(guiApp.windowMoving.parent)
4025 if(guiApp.windowMoving.style.nonClient)
4026 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4028 guiApp.windowMoving.parent.SetMouseRangeToClient();
4032 window.UpdateDecorations();
4035 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4037 // Log("\n*** LEFT BUTTON UP ***\n");
4038 if(guiApp.windowMoving)
4039 guiApp.windowMoving.StopMoving();
4041 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4043 if(guiApp.windowScrolling)
4045 Window windowScrolling = guiApp.windowScrolling;
4046 guiApp.windowScrolling = null;
4047 windowScrolling.ReleaseCapture();
4051 if(!result || (window && window.destroyed)) window = null;
4053 if(window && window.FindModal())
4056 if(trueWindow && trueWindow.FindModal())
4064 msgWindow = GetAtPosition(x,y, true, false);
4066 msgWindow.SelectMouseCursor();
4069 if(guiApp.windowCaptured || trueWindow)
4071 Window prevWindow = guiApp.prevWindow;
4072 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4074 guiApp.prevWindow.mouseInside = false;
4075 guiApp.prevWindow = null;
4077 // Eventually fix this not to include captured?
4078 if(!prevWindow.OnMouseLeave(*mods))
4081 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4083 Box box = trueWindow.box;
4084 box.left += trueWindow.absPosition.x;
4085 box.right += trueWindow.absPosition.x;
4086 box.top += trueWindow.absPosition.y;
4087 box.bottom += trueWindow.absPosition.y;
4089 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4091 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4092 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4094 overX = Max(Min(overX, 32767),-32768);
4095 overY = Max(Min(overY, 32767),-32768);
4097 trueWindow.mouseInside = true;
4098 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4102 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4103 guiApp.prevWindow = trueWindow;
4105 guiApp.prevWindow = null;
4107 SelectMouseCursor();
4109 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4111 int clientX = x - (window.absPosition.x + window.clientStart.x);
4112 int clientY = y - (window.absPosition.y + window.clientStart.y);
4114 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4116 clientX = Max(Min(clientX, 32767),-32768);
4117 clientY = Max(Min(clientY, 32767),-32768);
4119 MouseMethod = (void *)window._vTbl[method];
4121 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4124 if(!MouseMethod(window, clientX, clientY, *mods))
4131 if(result && w && w.clickThrough && w.parent)
4136 if(!result || !w || !w.clickThrough)
4143 // --- Mouse cursor management ---
4145 bool KeyMessage(uint method, Key key, unichar character)
4150 if(guiApp.interimWindow)
4151 this = guiApp.interimWindow;
4154 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4158 if(!style.inactive || rootWindow != this)
4160 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4161 Window modalWindow = FindModal();
4162 Window interimMaster = master ? master.rootWindow : null;
4166 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4167 status = OnSysKeyDown(key, character);
4168 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4169 status = OnSysKeyHit(key, character);
4170 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4171 status = OnSysKeyUp(key, character);
4178 // Process Key Message for Internal UI Keyboard actions
4179 if(status && !destroyed && menuBar && state != minimized)
4182 if((SmartKey)key != alt)
4183 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4186 SmartKey sk = (SmartKey) key;
4187 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4189 status = menuBar.KeyMessage(method, key, character);
4194 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4195 menuBar.OnKeyHit(escape, 0);
4197 if(!menuBar.focus && guiApp.caretOwner)
4198 guiApp.caretOwner.UpdateCaret(true, false);
4201 if(!destroyed && status)
4203 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4207 case left: case up: case right: case down:
4208 if(guiApp.windowMoving == this)
4211 int w = guiApp.windowMoving.size.w;
4212 int h = guiApp.windowMoving.size.h;
4213 int x = guiApp.windowMoving.scrolledPos.x;
4214 int y = guiApp.windowMoving.scrolledPos.y;
4218 if(key == down || key == up)
4219 step = Max(step, textCellH);
4221 step = Max(step, textCellW);
4224 if(guiApp.windowIsResizing)
4228 case left: w-=step; break;
4229 case right: w+=step; break;
4230 case up: h-=step; break;
4231 case down: h+=step; break;
4238 case left: x-=step; break;
4239 case right: x+=step; break;
4240 case up: y-=step; break;
4241 case down: y+=step; break;
4245 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4246 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4248 if(!guiApp.windowIsResizing || guiApp.resizeX)
4249 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4251 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4253 if(!guiApp.windowIsResizing || guiApp.resizeY)
4254 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4256 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4258 guiApp.interfaceDriver.SetMousePosition(x, y);
4259 ConsequentialMouseMove(true);
4267 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4269 guiApp.windowMoving.StopMoving();
4270 ConsequentialMouseMove(false);
4278 ShowSysMenu(absPosition.x, absPosition.y);
4286 if(!destroyed && status && state != minimized)
4288 // Process all the way down the children
4289 if(activeChild && !activeChild.disabled)
4291 status = activeChild.KeyMessage(method, key, character);
4293 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4294 key.code != left && key.code != right && key.code != up && key.code != down)
4296 status = activeClient.KeyMessage(method, key, character);
4300 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4302 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4303 // && defaultControl != activeChild)
4305 delete previousActive;
4306 previousActive = activeChild;
4307 if(previousActive) incref previousActive;
4309 ConsequentialMouseMove(false);
4310 if((defaultControl.active ||
4311 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4312 defaultControl.KeyMessage(method, defaultKey, character);
4318 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4320 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4327 ShowSysMenu(absPosition.x, absPosition.y);
4334 if(this != guiApp.desktop)
4336 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4338 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4340 MenuMoveOrSize(key.shift, true);
4344 else if(guiApp.windowMoving)
4346 guiApp.windowMoving.StopMoving();
4347 ConsequentialMouseMove(false);
4355 if(!destroyed && status && state != minimized)
4357 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4361 case tab: case shiftTab:
4363 Window cycleParent = this;
4364 if(this == guiApp.interimWindow && !master.style.interim && !cycleParent.style.tabCycle)
4365 cycleParent = master.parent;
4367 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4369 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4371 Window child = cycleParent.activeChild;
4373 // Scroll the window to include the active control
4375 if(cycleParent.sbh && !child.style.dontScrollHorz)
4377 if(child.scrolledPos.x < 0)
4378 cycleParent.sbh.Action(Position,
4379 cycleParent.scroll.x + child.scrolledPos.x, 0);
4380 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4381 cycleParent.sbh.Action(Position,
4382 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4384 if(cycleParent.sbv && !child.style.dontScrollVert)
4386 if(child.scrolledPos.y < 0)
4387 cycleParent.sbv.Action(Position,
4388 cycleParent.scroll.y + child.scrolledPos.y, 0);
4389 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4390 cycleParent.sbv.Action(Position,
4391 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4394 cycleParent.ConsequentialMouseMove(false);
4400 case f6: case shiftF6:
4401 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4403 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4404 if(parent == guiApp.desktop)
4405 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4410 if(style.tabCycle ||
4411 CycleChildren(key.shift, true, false, true))
4419 // mIRC Style Window Shortcuts
4420 case alt1: case alt2: case alt3: case alt4: case alt5:
4421 case alt6: case alt7: case alt8: case alt9: case alt0:
4426 for(document = children.first; document; document = document.next)
4428 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4430 if(document == activeChild)
4432 if(document.state == minimized)
4433 document.SetState(normal, false, key);
4436 document.SetState(minimized, false, key);
4437 CycleChildren(false, true, false);
4442 if(activeChild.state == maximized && document.style.hasMaximize)
4443 document.SetState(maximized, false, key);
4444 else if(document.state == minimized)
4445 document.SetState(normal, false, key);
4446 document.Activate();
4461 if(!destroyed && status)
4463 if(state == minimized)
4468 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4470 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4472 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4473 previousActive.ActivateEx(true, false, false, true, null, null);
4474 delete previousActive;
4480 if(!destroyed && status)
4482 status = ProcessHotKeys(method, key, character);
4484 if(!destroyed && status && !modalWindow && state != minimized)
4487 status = KeyMethod(this, key, character);
4488 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4489 status = OnKeyHit(key, character);
4490 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4492 bool result = false;
4495 case ctrlUp: case ctrlDown:
4496 if(sbv && !guiApp.windowScrolling)
4497 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4499 case wheelUp: case wheelDown:
4500 if(sbv && !guiApp.windowScrolling)
4502 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4503 // Do we want to do a consequential move regardless of result in this case?
4504 ConsequentialMouseMove(false);
4507 case ctrlPageUp: case ctrlPageDown:
4508 if(sbh && !guiApp.windowScrolling)
4509 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4514 ConsequentialMouseMove(false);
4519 if(status && !destroyed && menuBar && state != minimized)
4520 status = menuBar.KeyMessage(method, key, character);
4522 if(style.interim && /*destroyed && */status && interimMaster)
4524 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4525 status = interimMaster.KeyMessage(method, key, character);
4532 bool ProcessHotKeys(uint method, Key key, unichar character)
4537 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4538 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4539 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4541 Window hotKeyWindow = hotKey.window;
4542 Window parent = hotKeyWindow.parent;
4543 Window prevActiveWindow = activeChild;
4545 // Don't process non-visible buttons, but make an exception for the Alt-F4 with Native Decorations turned on
4546 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || hotKeyWindow != parent.sysButtons[2]))
4549 if(prevActiveWindow) incref prevActiveWindow;
4550 incref hotKeyWindow;
4551 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4552 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4555 delete hotKeyWindow;
4556 delete prevActiveWindow;
4560 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4561 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4562 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4564 // ********* WORKING ON THIS ***********
4565 if(prevActiveWindow && !guiApp.interimWindow)
4566 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4569 else if(hotKeyWindow.style.inactive)
4570 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4572 delete prevActiveWindow;
4573 delete hotKeyWindow;
4574 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4575 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4579 if(status && tabCycle)
4582 for(child = children.first; child; child = child.next)
4584 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4595 // --- Windows and graphics initialization / termination ---
4596 bool SetupRoot(void)
4600 // Setup relationship with outside world (bb root || !bb)
4601 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4602 (displayDriver && displayDriver != parent.displayDriver))
4606 tempExtents = new0 Extent[4];
4611 /*if(guiApp.fullScreenMode)
4612 rootWindow = guiApp.desktop;
4614 //rootWindow = parent.created ? parent.rootWindow : null;
4615 rootWindow = parent.rootWindow;
4618 against = &parent.box;
4620 against = &parent.clientArea;
4623 for(child = children.first; child; child = child.next)
4626 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4629 bool Setup(bool positionChildren)
4631 bool result = false;
4634 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (displayDriver && displayDriver != parent.displayDriver))))
4636 subclass(DisplayDriver) dDriver = dispDriver ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4637 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4639 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4641 // This was here, is it really needed?
4642 //guiApp.interfaceDriver.ActivateRootWindow(this);
4646 displaySystem = DisplaySystem {};
4647 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4649 delete displaySystem;
4654 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4655 if(display.Create(displaySystem, windowHandle))
4662 guiApp.interfaceDriver.SetIcon(this, icon);
4664 else if(this != guiApp.desktop)
4666 display = rootWindow ? rootWindow.display : null;
4672 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4673 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4675 for(child = children.first; child; child = child.next)
4677 if(child.created && !child.Setup(false))
4683 bool SetupDisplay(void)
4685 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4686 if(is3D) return Window3D_SetupDisplay(this); else
4693 class_data void ** pureVTbl;
4695 bool LoadGraphics(bool creation, bool resetAnchors)
4697 bool result = false;
4698 bool success = false;
4702 if(!rootWindow.created)
4706 if(((subclass(Window))_class).pureVTbl)
4708 if(_vTbl == _class._vTbl)
4710 _vTbl = ((subclass(Window))_class).pureVTbl;
4715 for(m = 0; m < _class.vTblSize; m++)
4717 if(_vTbl[m] == _class._vTbl[m])
4718 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4722 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4724 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4726 _vTbl = _class._vTbl;
4731 for(m = 0; m < _class.vTblSize; m++)
4733 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4734 _vTbl[m] = _class._vTbl[m];
4739 if(guiApp.fullScreenMode || this != guiApp.desktop)
4741 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4747 display.Lock(false);
4748 if(rootWindow == this)
4750 // Set Color Palette
4751 display.SetPalette(palette, true);
4755 if(guiApp.fullScreenMode && this == guiApp.desktop)
4760 for(c=0; c<SystemCursor::enumSize; c++)
4761 if(!guiApp.systemCursors[c].bitmap)
4763 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4764 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4765 if(guiApp.systemCursors[c].bitmapName)
4767 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4768 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4769 if(guiApp.systemCursors[c].bitmap)
4770 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4775 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4777 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4778 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4780 cursor.bitmap.paletteShades = cursor.paletteShades;
4784 guiApp.cursorUpdate = true;
4787 ConsequentialMouseMove(false);
4793 // Load Window Graphic Resources
4796 if(usedFont == setFont || usedFont == window.systemFont)
4797 RemoveResource(usedFont);
4800 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4803 RemoveResource(systemFont);
4806 RemoveResource(captionFont);
4808 for(ptr = resources.first; ptr; ptr = ptr.next)
4810 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4813 AddResource(setFont);
4815 AddResource(systemFont);
4817 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4824 //if(master && master.font)
4825 if(parent && parent.font)
4829 faceName = parent.font.faceName,
4830 size = parent.font.size,
4831 bold = parent.font.bold,
4832 italic = parent.font.italic,
4833 underline = parent.font.underline
4835 //font = parent.font;
4836 watch(parent) { font { } };
4839 font = guiApp.currentSkin.SystemFont();
4846 captionFont = guiApp.currentSkin.CaptionFont();
4847 AddResource(captionFont);
4849 if(OnLoadGraphics())
4855 //SetScrollLineStep(sbStep.x, sbStep.y);
4857 if(this != guiApp.desktop)
4861 normalAnchor = anchor;
4862 normalSizeAnchor = sizeAnchor;
4865 // Break the anchors for moveable/resizable windows
4867 if(style.fixed && style.isDocument)
4869 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
4881 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
4882 stateSizeAnchor = SizeAnchor {};
4887 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
4892 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
4893 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
4896 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
4900 stateAnchor = normalAnchor;
4901 stateSizeAnchor = normalSizeAnchor;
4904 position = Point { };
4905 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
4916 if(Position(x, y, w, h, true, false, true, true, true, true))
4918 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
4921 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
4938 success = result = true;
4941 if(!creation && result)
4943 // Load menu bar first because sys buttons are on it...
4946 if(!menuBar.LoadGraphics(false, resetAnchors))
4952 for(child = children.first; child; child = child.next)
4954 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
4961 CreateSystemChildren();
4965 if(this == guiApp.desktop && !guiApp.fullScreenMode)
4968 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
4973 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
4974 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
4979 void UnloadGraphics(bool destroyWindows)
4983 // Free children's graphics
4984 for(child = children.first; child; child = child.next)
4985 child.UnloadGraphics(destroyWindows);
4988 display.Lock(false);
4991 if(guiApp.fullScreenMode && this == guiApp.desktop)
4996 for(c=0; c<SystemCursor::enumSize; c++)
4997 if(guiApp.systemCursors[c].bitmap)
4998 delete guiApp.systemCursors[c].bitmap;
5000 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5001 delete cursor.bitmap;
5003 guiApp.cursorBackground.Free();
5006 if(display && display.displaySystem)
5010 for(ptr = resources.first; ptr; ptr = ptr.next)
5014 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5019 // Free window graphics
5022 // Free skin graphics
5023 if(rootWindow == this)
5025 DisplaySystem displaySystem = display.displaySystem;
5028 display.driverData = null;
5029 display.displaySystem = null;
5033 if(displaySystem && !displaySystem.numDisplays && !is3D)
5034 delete displaySystem;
5043 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5044 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5046 if(this == guiApp.desktop || parent == guiApp.desktop)
5048 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5049 guiApp.interfaceDriver.DestroyRootWindow(this);
5053 // --- Window Hiding ---
5055 void SetVisibility(bool state)
5057 bool visible = (style.hidden || !created) ? false : state;
5058 if(visible != this.visible)
5062 this.visible = visible;
5063 for(child = children.first; child; child = child.next)
5064 child.SetVisibility(visible);
5066 ConsequentialMouseMove(false);
5070 // --- Windows and graphics initialization / termination ---
5072 bool DisplayModeChanged(void)
5074 bool result = false;
5075 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5077 guiApp.modeSwitching = true;
5078 UnloadGraphics(false);
5080 if(LoadGraphics(false, false))
5082 guiApp.modeSwitching = false;
5087 // --- Window updates system ---
5089 void UpdateDirty(Box updateBox)
5091 if(!manageDisplay) { OnRedraw(null);return; }
5094 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5097 if(display.flags.flipping)
5100 rootWindow.UpdateDisplay();
5103 UpdateBackDisplay(updateBox);
5105 if(guiApp.fullScreenMode)
5107 guiApp.cursorUpdate = true;
5108 guiApp.PreserveAndDrawCursor();
5110 if(guiApp.fullScreenMode)
5111 guiApp.RestoreCursorBackground();
5117 // This function is strictly called as a result of system window activation
5118 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5121 Window interimMaster = null;
5122 Window interimWindow = guiApp.interimWindow;
5123 if(interimWindow && interimWindow.master)
5124 interimMaster = interimWindow.master.rootWindow;
5126 if(active && state == minimized)
5127 // SetState(normal, false, 0);
5128 SetState(lastState, false, 0);
5130 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5134 /* WTH is this doing here?
5135 while(swap && swap.activeChild)
5137 swap = swap.activeChild;
5140 // TESTING THIS BEFORE...
5141 if(interimWindow && this == interimMaster)
5145 // Window interimSwap = this;
5146 Window menuBar = this.menuBar;
5147 if(menuBar && interimWindow.master == menuBar)
5150 while(interimSwap && interimSwap.activeChild)
5151 interimSwap = interimSwap.activeChild;
5153 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5154 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5156 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5157 //result = ActivateEx(true, true, false, activateRoot, window, null);
5162 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5163 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5165 if(interimWindow == this && interimMaster && !active)
5167 while(interimMaster && interimMaster.interim && interimMaster.master)
5169 // printf("Going up one master %s\n", interimMaster._class.name);
5170 interimMaster = interimMaster.master.rootWindow;
5172 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5173 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5179 bool DestroyEx(int returnCode)
5182 Timer timer, nextTimer;
5184 OldLink prevOrder = null;
5185 Window client = null;
5187 if(parent) stopwatching(parent, font);
5189 // if(window.modalSlave) return false;
5190 if(destroyed || !created)
5197 OldLink slave = master.slaves.FindVoid(this);
5198 master.slaves.Delete(slave);
5201 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5207 this.returnCode = (DialogResult)returnCode;
5209 AcquireInput(false);
5214 master.hotKeys.Delete(hotKey);
5218 if(guiApp.prevWindow == this)
5220 guiApp.prevWindow = null;
5223 if(guiApp.caretOwner == this)
5225 guiApp.interfaceDriver.SetCaret(0,0,0);
5226 UpdateCaret(false, true);
5227 guiApp.caretEnabled = false;
5232 parent.childrenCycle.Remove(cycle);
5236 OldLink tmpPrev = order.prev;
5237 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5238 prevOrder = tmpPrev;
5241 client = tmpPrev ? tmpPrev.data : null;
5242 if(client == this) { client = null; break; }
5243 if(client && (client.style.hidden || client.destroyed || !client.created))
5244 tmpPrev = client.order.prev;
5248 prevOrder = tmpPrev;
5253 // If this window can be an active client, make sure the next window we activate can also be one
5254 if(!style.nonClient && style.isActiveClient)
5256 tmpPrev = prevOrder;
5259 client = tmpPrev ? tmpPrev.data : null;
5260 if(client == this) { client = null; break; }
5261 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5262 tmpPrev = client.order.prev;
5266 prevOrder = tmpPrev;
5270 if(client && client.style.hidden) client = null;
5272 // parent.childrenOrder.Remove(order);
5275 // TESTING THIS HERE!
5279 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5280 // to create a window inside a rootwindow that's being destroyed)
5281 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5283 if(master && !master.destroyed /*&&
5284 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5286 if(master.defaultControl == this)
5287 master.defaultControl = null;
5289 if(parent && !parent.destroyed /*&&
5290 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5292 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5294 if(order && prevOrder && prevOrder.data != this && active)
5296 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5298 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5299 if(parent.activeClient == this)
5301 parent.activeClient = null;
5302 parent.UpdateActiveDocument(null);
5307 if(guiApp.interimWindow == this)
5310 PropagateActive(false, null, &goOn, true);
5314 //if(window.parent.activeChild == window)
5315 parent.activeChild = null;
5316 if(!style.nonClient /*&& style.isActiveClient*/)
5318 Window previous = parent.activeClient;
5319 if(style.isActiveClient)
5320 parent.activeClient = null;
5321 parent.UpdateActiveDocument(previous);
5326 else if(parent.activeClient == this)
5328 parent.activeClient = client;
5329 parent.UpdateActiveDocument(this);
5333 if(guiApp.interimWindow == this)
5335 guiApp.interimWindow = null;
5336 if(guiApp.caretOwner)
5338 Window desktop = guiApp.desktop;
5339 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5340 guiApp.caretOwner.UpdateCaret(false, false);
5345 if(style.modal && master && master.modalSlave == this)
5346 master.modalSlave = null;
5350 if(!guiApp.caretOwner && parent.caretSize)
5352 guiApp.caretOwner = parent;
5353 parent.UpdateCaret(false, false);
5354 parent.Update(null);
5357 if(style.isActiveClient && visible)
5359 if(state == minimized) parent.numIcons--;
5360 parent.numPositions--;
5362 // Why was this commented out?
5363 GetRidOfVirtualArea();
5369 dirtyArea.Free(null);
5370 dirtyBack.Free(null);
5371 scrollExtent.Free(null);
5373 /* ATTEMPTING TO MOVE THAT ABOVE
5382 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5383 for(;(child = window.children.first);)
5385 for(; child && (child.destroyed || !child.created); child = child.next);
5394 UnloadGraphics(true);
5397 delete previousActive;
5400 // statusBar = null;
5403 if(master && !master.destroyed)
5405 //master.NotifyDestroyed(this, this.returnCode);
5406 NotifyDestroyed(master, this, this.returnCode);
5409 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5411 nextTimer = timer.next;
5412 if(timer.window == this)
5414 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5415 // timer.window = null;
5421 if(this == guiApp.windowMoving)
5424 if(guiApp.windowCaptured == this)
5426 //guiApp.windowCaptured = null;
5428 if(rootWindow != this && rootWindow)
5429 rootWindow.ConsequentialMouseMove(false);
5437 //for(child = children.first; next = child ? child.next : null, child; child = next)
5438 for(;(child = children.first); )
5440 for(; child && (child.destroyed || !child.created); child = child.next);
5450 /* // MOVED THIS UP...
5453 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5454 for(;(child = window.children.first); )
5456 for(; child && (child.destroyed || !child.created); child = child.next);
5465 while((slave = slaves.first))
5467 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5469 ((Window)slave.data).DestroyEx(0);
5474 if(guiApp.caretOwner == this)
5475 guiApp.caretOwner = null;
5477 sysButtons[0] = null;
5478 sysButtons[1] = null;
5479 sysButtons[2] = null;
5482 if(rootWindow != this)
5484 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5487 box.left -= parent.clientStart.x;
5488 box.top -= parent.clientStart.y;
5489 box.right -= parent.clientStart.x;
5490 box.bottom -= parent.clientStart.y;
5492 if(parent) parent.Update(box);
5497 OldLink slave = master.slaves.FindVoid(this);
5498 master.slaves.Delete(slave);
5504 parent.children.Remove(this);
5509 //autoCreate = false;
5512 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5513 if(((subclass(Window))_class).pureVTbl)
5515 if(_vTbl == _class._vTbl)
5517 _vTbl = ((subclass(Window))_class).pureVTbl;
5522 for(m = 0; m < _class.vTblSize; m++)
5524 if(_vTbl[m] == _class._vTbl[m])
5525 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5534 void SetStateEx(WindowState newState, bool activate)
5537 WindowState prevState = state;
5540 if(nativeDecorations)
5543 if(prevState != newState)
5544 lastState = prevState;
5545 if(style.isActiveClient && !style.hidden && prevState == minimized)
5548 // This block used to be at the end of the function... moved it for flicker problem in X
5549 // ------------------------------------------------------
5553 stateAnchor = normalAnchor;
5554 stateSizeAnchor = normalSizeAnchor;
5557 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5558 stateSizeAnchor = SizeAnchor {};
5562 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5565 byte * idBuffer = new0 byte[size];
5567 for(child = parent.children.first; child; child = child.next)
5569 if(child != this && child.state == minimized)
5571 if(child.iconID > size - 2)
5573 idBuffer = renew0 idBuffer byte[size*2];
5574 memset(idBuffer + size, 0, size);
5577 idBuffer[child.iconID] = (byte)bool::true;
5580 for(c = 0; c<size; c++)
5585 if(style.isActiveClient && !style.hidden)
5588 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5589 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5593 // TOCHECK: Why was this here?
5594 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5595 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5596 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5598 Position(x, y, w, h, true, true, true, true, false, true);
5600 if(!style.inactive && !style.interim && this == parent.activeClient)
5601 parent.UpdateActiveDocument(null);
5603 CreateSystemChildren();
5604 // ------------------------------------------------------
5607 int GetPositionID(Window forChild)
5611 byte * idBuffer = new0 byte[size];
5614 for(child = children.first; child; child = child.next)
5616 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5618 if(child.positionID > size - 2)
5620 idBuffer = renew0 idBuffer byte[size*2];
5621 memset(idBuffer + size, 0, size);
5624 idBuffer[child.positionID] = (byte)bool::true;
5627 for(c = 0; c<size; c++)
5634 // --- Window related graphics ---
5636 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5638 palette = newPalette;
5639 if(rootWindow.display)
5640 rootWindow.display.SetPalette(palette, colorMatch);
5643 public bool AcquireInput(bool acquired)
5646 if(acquiredInput != acquired)
5648 if(active || (!visible && creationActivation == activate))
5649 result = AcquireInputEx(acquired);
5654 acquiredInput = acquired ? result : !result;
5659 void ListChildren(ListBox listBox)
5663 for(child = children.first; child; child = child.next)
5665 if(child.cycle && !child.style.nonClient && child.style.isActiveClient)
5667 DataRow row = listBox.AddRow();
5668 row.tag = (int)child;
5669 child.FigureCaption(caption);
5670 row.SetData(null, caption);
5675 void UpdateVisual(Box extent)
5677 if(guiApp.driver != null)
5679 if(guiApp.fullScreenMode && guiApp.desktop.display)
5681 guiApp.desktop.mutex.Wait();
5682 guiApp.desktop.display.Lock(true);
5685 if(guiApp.desktop.active)
5687 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5689 if(guiApp.desktop.display.flags.flipping)
5690 guiApp.desktop.Update(null);
5691 guiApp.desktop.UpdateDisplay();
5692 guiApp.cursorUpdate = true;
5694 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5696 guiApp.PreserveAndDrawCursor();
5697 // guiApp.desktop.display.ShowScreen();
5698 guiApp.cursorUpdate = false;
5699 guiApp.desktop.dirty = false;
5700 guiApp.RestoreCursorBackground();
5704 guiApp.desktop.display.Unlock();
5705 guiApp.desktop.mutex.Release();
5709 Window rootWindow = this.rootWindow;
5710 rootWindow.mutex.Wait();
5715 guiApp.SignalEvent();
5718 guiApp.waitMutex.Wait();
5719 guiApp.interfaceDriver.Lock(rootWindow);
5720 if(!rootWindow.style.hidden && rootWindow.dirty)
5722 if(rootWindow.display)
5724 rootWindow.UpdateDisplay();
5725 //rootWindow.display.ShowScreen(null);
5727 rootWindow.dirty = false;
5729 guiApp.interfaceDriver.Unlock(rootWindow);
5730 guiApp.waitMutex.Release();
5733 rootWindow.mutex.Release();
5738 void UnlockDisplay(void)
5740 guiApp.interfaceDriver.Unlock(rootWindow);
5743 void LockDisplay(void)
5745 guiApp.interfaceDriver.Lock(rootWindow);
5748 Surface GetSurface(Box box)
5750 return Redraw((box == null) ? this.box : box);
5753 void SetMousePosition(int x, int y)
5755 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5759 void IntegrationActivate(bool active)
5761 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5763 isForegroundWindow = true;
5764 ActivateEx(active, active, false, false, null, null);
5765 isForegroundWindow = false;
5770 Window QueryCapture(void)
5772 return guiApp.windowCaptured;
5775 int GetDocumentID(void)
5779 byte * idBuffer = new0 byte[size];
5782 for(child = children.first; child; child = child.next)
5784 if(child.style.isDocument)
5786 if(child.documentID-1 > size - 2)
5788 idBuffer = renew0 idBuffer byte[size*2];
5789 memset(idBuffer + size, 0, size);
5792 idBuffer[child.documentID-1] = 1;
5795 for(c = 0; c<size; c++)
5803 void SetInitSize(Size size)
5806 sizeAnchor.size = size;
5807 normalSizeAnchor = sizeAnchor;
5809 // Break the anchors for moveable/resizable windows
5810 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5812 stateAnchor = normalAnchor;
5813 stateSizeAnchor = normalSizeAnchor;
5815 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5816 Position(x,y, w, h, true, true, true, true, false, true);
5820 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5822 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5824 guiApp.windowIsResizing = resize;
5825 guiApp.windowMoving = this;
5826 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5827 if(guiApp.windowIsResizing)
5829 guiApp.windowMovingStart.x += size.w - 1;
5830 guiApp.windowMovingStart.y += size.h - 1;
5832 guiApp.windowMovingBefore = scrolledPos;
5833 guiApp.windowResizingBefore = size;
5834 guiApp.windowMoving.UpdateDecorations();
5835 if(guiApp.windowIsResizing)
5836 guiApp.resizeEndX = guiApp.resizeEndY = true;
5838 if(setCursorPosition)
5839 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5843 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5844 guiApp.windowMovingStart.x += x - absPosition.x;
5845 guiApp.windowMovingStart.y += y - absPosition.y;
5848 if(guiApp.windowMoving)
5850 if(guiApp.windowMoving.style.nonClient)
5851 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5853 guiApp.windowMoving.parent.SetMouseRangeToClient();
5858 if(this == rootWindow)
5859 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
5867 bool result = false;
5871 else if(guiApp && guiApp.driver != null)
5873 void * systemParent = null;
5874 OldLink slaveHolder;
5876 bool visible = !style.hidden;
5880 systemParent = parent;
5881 parent = guiApp.desktop;
5883 last = parent ? parent.children.last : null;
5885 if((parent && parent != guiApp.desktop && !parent.created) ||
5886 (master && master != guiApp.desktop && !master.created))
5890 property::parent = guiApp.desktop;
5891 if(!master) master = parent;
5893 if(style.modal && master.modalSlave)
5897 parent.children.Remove(this);
5900 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
5901 if(slaveHolder.data == this)
5903 master.slaves.Delete(slaveHolder);
5908 if(parent == guiApp.desktop && !mutex)
5911 if(style.isDocument)
5914 parent.numDocuments--;
5915 documentID = parent.GetDocumentID();
5918 if(!style.stayOnTop)
5919 for(; last && last.style.stayOnTop; last = last.prev);
5921 parent.children.Insert((last == this) ? null : last, this);
5922 //parent.children.Add(this);
5925 dispDriver = parent.dispDriver;
5928 master.modalSlave = this;
5930 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
5935 master.slaves.Add(slaveHolder = OldLink { data = this });
5940 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
5942 if(style.isDefault && !master.defaultControl)
5943 master.defaultControl = this;
5945 stateAnchor = normalAnchor = anchor;
5946 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
5948 // TOCHECK: Why is this here?
5949 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
5950 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
5952 this.visible = false;
5953 style.hidden = true;
5956 // autoCreate = true;
5964 if(parent == guiApp.desktop)
5965 Log("LoadGraphics %s\n", caption);
5967 if(LoadGraphics(true, false))
5975 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
5982 if(style.hasMenuBar /*&& menu*/)
5988 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
5989 interim = false, inactive = true, nonClient = true, size.h = 24
5997 // Create the system buttons
5998 CreateSystemChildren();
6000 UpdateActiveDocument(null);
6002 if(style.isDocument)
6006 MenuItem item = menu.FindItem(MenuFileSave, 0);
6007 if(item) item.disabled = !modifiedDocument && fileName;
6012 if(parent == guiApp.desktop)
6013 Log("Preemptive SetState %s\n", caption);
6016 // Preemptive Set State to ensure proper anchoring
6017 SetStateEx(state, false);
6019 style.hidden = true;
6025 for(child = children.first; child; child = next)
6028 if(!child.created && (child.autoCreate || child.wasCreated))
6035 for(link = slaves.first; link; link = next)
6037 Window slave = link.data;
6039 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6048 if(parent == guiApp.desktop)
6049 Log("Real SetState %s\n", caption);
6052 if(isActiveClient && visible)
6054 parent.numPositions--;
6055 if(state == minimized) parent.numIcons--;
6058 // Real set state & activate for proper display & activation
6059 property::visible = visible;
6060 // SetState(state & 0x00000003, true, 0);
6065 /*if(rootWindow == this)
6066 guiApp.interfaceDriver.ActivateRootWindow(this);
6068 if(creationActivation == activate)
6069 ActivateEx(true, false, true, true, null, null);
6070 else if(creationActivation == flash)
6075 rootWindow.ConsequentialMouseMove(false);
6086 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6092 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6094 //style.hidden = true; // !visible;
6095 style.hidden = !visible;
6096 if(master.modalSlave == this)
6097 master.modalSlave = null;
6104 void WriteCaption(Surface surface, int x, int y)
6107 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6110 void Update(Box region)
6116 rootWindow = this.rootWindow;
6118 // rootWindow.mutex.Wait();
6119 if(!destroyed && visible && display)
6124 // Testing this to avoid repetitve full update to take time...
6125 if(dirtyArea.count == 1)
6127 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6128 if(item.box.left <= box.left &&
6129 item.box.top <= box.top &&
6130 item.box.right >= box.right &&
6131 item.box.bottom >= box.bottom)
6133 rootWindow.dirty = true;
6138 if(display.flags.flipping && !rootWindow.dirty)
6140 if(this == rootWindow)
6144 rootWindow.Update(null);
6149 rootWindow.dirty = true;
6154 realBox.left += clientStart.x;
6155 realBox.top += clientStart.y;
6156 realBox.right += clientStart.x;
6157 realBox.bottom += clientStart.y;
6163 if(realBox.right >= realBox.left &&
6164 realBox.bottom >= realBox.top)
6166 // if(!rootWindow.fullRender)
6167 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6169 for(child = children.first; child; child = child.next)
6174 box.left -= child.absPosition.x - absPosition.x;
6175 box.top -= child.absPosition.y - absPosition.y;
6176 box.right -= child.absPosition.x - absPosition.x;
6177 box.bottom -= child.absPosition.y - absPosition.y;
6178 if(box.right >= child.box.left && box.left <= child.box.right &&
6179 box.bottom >= child.box.top && box.top <= child.box.bottom)
6181 box.left -= child.clientStart.x;
6182 box.top -= child.clientStart.y;
6183 box.right -= child.clientStart.x;
6184 box.bottom -= child.clientStart.y;
6190 realBox.left += absPosition.x - rootWindow.absPosition.x;
6191 realBox.top += absPosition.y - rootWindow.absPosition.y;
6192 realBox.right += absPosition.x - rootWindow.absPosition.x;
6193 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6194 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6197 else if(this == guiApp.desktop)
6200 for(window = children.first; window; window = window.next)
6206 Box childBox = region;
6208 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6209 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6210 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6211 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6213 window.Update(childBox);
6216 window.Update(null);
6221 // rootWindow.mutex.Release();
6228 if(guiApp.windowCaptured != this)
6230 if(guiApp.windowCaptured)
6234 //Logf("Captured %s (%s)\n", caption, class.name);
6235 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6236 guiApp.windowCaptured = this;
6242 bool Destroy(int code)
6247 if(!CloseConfirmation(false)) return false;
6251 // TOCHECK: Should autoCreate be set to false here?
6254 // Is this needed here? DestroyEx should decref already...
6263 void Move(int x, int y, int w, int h)
6265 normalAnchor = Anchor { left = x, top = y };
6266 normalSizeAnchor = SizeAnchor { size = { w, h } };
6268 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6270 if(destroyed) return;
6272 stateAnchor = normalAnchor;
6273 stateSizeAnchor = normalSizeAnchor;
6275 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6276 Position(x,y, w, h, true, true, true, true, false, true);
6280 DialogResult Modal(void)
6286 // FIXES MEMORY LEAK IF Create() FAILED
6292 void SetScrollArea(int width, int height, bool snapToStep)
6294 bool resize = false;
6297 int stepX = sbStep.x, stepY = sbStep.y;
6298 // Needed to make snapped down position match the skin's check of client area
6299 // against realvirtual
6302 SNAPDOWN(stepX, textCellW);
6303 SNAPDOWN(stepY, textCellH);
6304 stepX = Max(stepX, textCellW);
6305 stepY = Max(stepY, textCellH);
6307 if(scrollFlags.snapX)
6308 SNAPUP(width, stepX);
6309 if(scrollFlags.snapY)
6310 SNAPUP(height, stepY);
6313 reqScrollArea.w = width;
6314 reqScrollArea.h = height;
6315 noAutoScrollArea = (width > 0 || height > 0);
6317 UpdateScrollBars(true, true);
6320 void SetScrollPosition(int x, int y)
6323 sbh.Action(setPosition, x, 0);
6327 int seen = clientSize.w, total = reqScrollArea.w;
6329 if(scrollFlags.snapX)
6330 SNAPDOWN(seen, sbStep.x);
6332 if(!total) total = seen;
6333 range = total - seen + 1;
6334 range = Max(range, 1);
6336 if(x >= range) x = range - 1;
6338 if(scrollFlags.snapX)
6339 SNAPUP(x, sbStep.x);
6342 OnHScroll(setPosition, x, 0);
6346 SNAPDOWN(x, textCellW);
6352 sbv.Action(setPosition, y, 0);
6356 int seen = clientSize.h, total = reqScrollArea.h;
6359 if(scrollFlags.snapY)
6360 SNAPDOWN(seen, sbStep.y);
6362 if(!total) total = seen;
6363 range = total - seen + 1;
6364 range = Max(range, 1);
6366 if(y >= range) y = range - 1;
6368 if(scrollFlags.snapY)
6369 SNAPUP(y, sbStep.y);
6372 OnVScroll(setPosition, y, 0);
6375 SNAPDOWN(y, textCellH);
6380 UpdateCaret(false, false);
6383 void SetScrollLineStep(int stepX, int stepY)
6389 SNAPDOWN(stepX, textCellW);
6390 SNAPDOWN(stepY, textCellH);
6391 stepX = Max(stepX, textCellW);
6392 stepY = Max(stepY, textCellH);
6395 sbh.lineStep = stepX;
6397 sbv.lineStep = stepY;
6400 void SetState(WindowState newState, bool activate, Modifiers mods)
6404 if(state == newState || OnStateChange(newState, mods))
6406 WindowState prevState = state;
6410 // This used to be at the end of the brackets... moved for X, testing...
6411 // This has the effect of activating the window through the system...
6412 if(rootWindow == this)
6413 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6415 SetStateEx(newState, activate);
6417 if(rootWindow == this && !rootWindow.nativeDecorations)
6419 int x = position.x, y = position.y;
6422 x -= guiApp.desktop.absPosition.x;
6423 y -= guiApp.desktop.absPosition.y;
6425 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6429 //state = prevState;
6431 if(state != maximized && style.hasMaximize)
6434 for(child = parent.children.first; child; child = child.next)
6436 if(child != this && child.state == maximized)
6437 child.SetStateEx(normal, false);
6441 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6442 parent.UpdateScrollBars(true, true);
6445 // Do we really need this stuff here?
6446 // Shouldn't the Activate stuff take care of it?
6447 if(parent.rootWindow == parent && style)
6450 parent.FigureCaption(caption);
6451 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6452 parent.UpdateDecorations();
6456 rootWindow.ConsequentialMouseMove(false);
6463 BitmapResource GetIcon(SkinBitmap iconID)
6465 return guiApp.currentSkin.GetBitmap(iconID);
6468 void SetMouseRange(Box range)
6470 if(range || guiApp.fullScreenMode)
6475 clip.left = range.left + absPosition.x + clientStart.x;
6476 clip.top = range.top + absPosition.y + clientStart.y;
6477 clip.right = range.right + absPosition.x + clientStart.x;
6478 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6482 clip.left = guiApp.desktop.box.left;
6483 clip.top = guiApp.desktop.box.top;
6484 clip.right = guiApp.desktop.box.right;
6485 clip.bottom = guiApp.desktop.box.bottom;
6487 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6490 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6493 void SetMouseRangeToClient(void)
6495 if(guiApp.fullScreenMode || this != guiApp.desktop)
6497 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6498 box.Clip(clientArea);
6502 SetMouseRange(null);
6505 void SetMouseRangeToWindow(void)
6507 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6508 if(this == guiApp.desktop)
6509 SetMouseRangeToClient();
6514 // x, y: Desktop Coordinates
6515 void ShowSysMenu(int x, int y)
6518 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6521 menu, "Restore", r, NotifySelect = MenuWindowRestore,
6522 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6526 menu, "Move", m, NotifySelect = MenuWindowMove,
6527 disabled = !style.fixed || state == maximized
6531 menu, "Size", s, NotifySelect = MenuWindowSize,
6532 disabled = !style.sizable || state != normal
6536 menu, "Minimize", n, NotifySelect = MenuWindowMinimize,
6537 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6541 menu, "Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6542 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6546 menu, "Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6547 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6549 MenuDivider { menu };
6552 menu, "Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6553 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6555 windowMenu.Create();
6560 ActivateEx(true, true, true, true, null, null);
6563 void MakeActive(void)
6565 ActivateEx(true, false, true, false, null, null);
6568 void SoftActivate(void)
6570 if(guiApp.desktop.active)
6576 void Deactivate(void)
6578 ActivateEx(false, true, true, true, null, null);
6583 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6586 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6588 bool result = false;
6589 if(activeChild && activeChild.cycle)
6591 Window modalWindow, child = activeChild;
6592 if(!clientOnly /*&& parent.tabCycle*/)
6594 Window next = child;
6597 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6601 if(parent && parent.CycleChildren(backward, false, true, true))
6609 next = next.cycle.prev.data;
6611 next = next.cycle.next.data;
6612 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6617 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6618 parent.tabCycle && parent.CycleChildren(backward, false, false))
6622 if(tabCycleOnly && !tabCycle) return false;
6629 child = child.cycle.prev.data;
6631 child = child.cycle.next.data;
6632 if(child == child.parent.activeChild)
6634 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6637 modalWindow = child.FindModal();
6640 // Scroll the window to include the active control
6641 if(sbh && !child.style.dontScrollHorz)
6643 if(child.scrolledPos.x < 0)
6644 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6645 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6646 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6648 if(sbv && !child.style.dontScrollVert)
6650 if(child.scrolledPos.y < 0)
6651 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6652 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6653 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6657 child = modalWindow ? modalWindow : child;
6658 child.ActivateEx(true, true, true, true, null, null);
6659 if(child.tabCycle && child.childrenCycle.first)
6660 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6668 ConsequentialMouseMove(false);
6672 void AddResource(Resource resource)
6676 ResPtr ptr { resource = resource };
6680 // Load Graphics here if window is created already
6681 if(/*created && */display)
6683 display.Lock(false);
6684 ptr.loaded = display.displaySystem.LoadResource(resource);
6688 // Temporary hack to load font right away for listbox in dropbox ...
6689 else if(master && master.display)
6691 master.display.Lock(false);
6692 master.display.displaySystem.LoadResource(resource);
6693 master.display.Unlock();
6699 void RemoveResource(Resource resource)
6704 for(ptr = resources.first; ptr; ptr = ptr.next)
6706 if(ptr.resource == resource)
6712 // Unload Graphics here if window is created already
6713 if(/*created && */display)
6717 display.Lock(false);
6718 display.displaySystem.UnloadResource(resource, ptr.loaded);
6724 resources.Delete(ptr);
6729 void SetCaret(int x, int y, int size)
6736 if(active && !style.interim)
6738 if(visible || !guiApp.caretOwner)
6739 guiApp.caretOwner = size ? this : null;
6741 UpdateCaret(false, false);
6744 guiApp.interfaceDriver.SetCaret(0,0,0);
6745 UpdateCaret(false, true);
6746 guiApp.caretEnabled = false;
6749 else if(style.inactive && active)
6751 guiApp.interfaceDriver.SetCaret(0,0,0);
6752 UpdateCaret(false, true);
6753 guiApp.caretEnabled = false;
6758 void Scroll(int x, int y)
6760 bool opaque = !style.drawBehind || background.a;
6761 if(opaque && display && display.flags.scrolling)
6763 Box box = clientArea;
6764 box.left += clientStart.x;
6765 box.top += clientStart.y;
6766 box.right += clientStart.x;
6767 box.bottom += clientStart.y;
6769 //scrollExtent.Free(null);
6770 scrollExtent.AddBox(box);
6771 scrolledArea.x += x;
6772 scrolledArea.y += y;
6774 //scrollExtent.Free();
6775 //scrollExtent.AddBox(clientArea);
6776 //scrollExtent.Offset(clientStart.x, clientStart.y);
6777 //scrolledArea.x = x;
6778 //scrolledArea.y = y;
6784 rootWindow.dirty = true;
6787 void ReleaseCapture()
6789 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6791 Window oldCaptured = guiApp.windowCaptured;
6792 guiApp.windowCaptured = null;
6793 guiApp.prevWindow = null;
6796 //guiApp.Log("Released Capture\n");
6798 guiApp.interfaceDriver.SetMouseCapture(null);
6800 //oldCaptured.OnMouseCaptureLost();
6803 oldCaptured.ConsequentialMouseMove(false);
6808 void SetText(char * format, ...)
6815 char caption[MAX_F_STRING];
6817 va_start(args, format);
6818 vsprintf(caption, format, args);
6821 this.caption = new char[strlen(caption)+1];
6823 strcpy(this.caption, caption);
6832 bool Grab(Bitmap bitmap, Box box, bool decorations)
6834 bool result = false;
6835 if(display || this == guiApp.desktop)
6837 Box clip = {MININT, MININT, MAXINT, MAXINT};
6843 clip.Clip(clientArea);
6845 clip.Clip(this.box);
6847 if(rootWindow != this)
6849 clip.left += absPosition.y;
6850 clip.top += absPosition.y;
6851 clip.right += absPosition.x;
6852 clip.bottom += absPosition.y;
6855 clip.left += decorations ? 0 : clientStart.x;
6856 clip.top += decorations ? 0 : clientStart.y;
6857 clip.right += decorations ? 0 : clientStart.x;
6858 clip.bottom += decorations ? 0 : clientStart.y;
6860 if(display && display.flags.flipping)
6862 rootWindow.Update(null);
6863 rootWindow.UpdateDisplay();
6870 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
6871 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
6875 result = display.Grab(bitmap, clip.left, clip.top,
6876 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
6878 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
6880 if(!bitmap.Convert(null, pixelFormat888, null))
6887 void GetMousePosition(int * x, int * y)
6889 int mouseX = 0, mouseY = 0;
6890 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
6893 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
6894 if(this != guiApp.desktop)
6896 mouseX -= absPosition.x + clientStart.x;
6897 mouseY -= absPosition.y + clientStart.y;
6904 DialogResult DoModal()
6906 DialogResult returnCode = 0;
6907 int terminated = terminateX;
6910 while(!destroyed && guiApp.driver != null)
6912 if(terminateX != terminated)
6914 terminated = terminateX;
6915 guiApp.desktop.Destroy(0);
6916 if(guiApp.desktop.created)
6919 //printf("Resetting terminate X to 0\n");
6925 guiApp.UpdateDisplay();
6926 if(!guiApp.ProcessInput(false))
6929 returnCode = this.returnCode;
6942 return !destroyed && guiApp.driver != null && terminateX < 2;
6945 DialogResult DoModalEnd()
6947 DialogResult returnCode = this.returnCode;
6952 // --- Window manipulation ---
6953 /*bool GetDisabled()
6955 bool disabled = this.disabled;
6957 for(window = this; (window = window.master); )
6968 // --- Mouse Manipulation ---
6969 void GetNCMousePosition(int * x, int * y)
6971 GetMousePosition(x, y);
6972 if(x) *x += clientStart.x;
6973 if(y) *y += clientStart.y;
6976 // --- Carets manipulation ---
6977 void GetCaretPosition(Point caretPos)
6979 caretPos = this.caretPos;
6982 int GetCaretSize(void)
6987 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
6993 bool CloseConfirmation(bool parentClosing)
7006 if(!OnClose(parentClosing))
7009 // If you want to skip this, simply set modifiedDocument to false in OnClose
7010 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7012 DialogResult dialogRes;
7015 sprintf(message, "Save changes to %s?", fileName);
7017 sprintf(message, "Save changes to Untitled %d?", documentID);
7019 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption, contents = message }.Modal();
7021 if(dialogRes == yes)
7023 // TOFIX: Precomp error if brackets are taken out
7024 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7026 else if(dialogRes == cancel)
7032 for(slave = slaves.first; slave; slave = slave.next)
7033 if(!((Window)slave.data).CloseConfirmation(true))
7035 // ((Window)slave.data).CloseConfirmation(true);
7043 for(child = children.first; child; child = child.next)
7044 if(child.master != this && !child.CloseConfirmation(true))
7054 // Static methods... move them somewhere else?
7055 void ::RestoreCaret()
7057 if(guiApp.caretOwner)
7058 guiApp.caretOwner.UpdateCaret(false, false);
7061 void ::FreeMouseRange()
7063 guiApp.interfaceDriver.SetMouseRange(null, null);
7067 bool MenuFileClose(MenuItem selection, Modifiers mods)
7069 Window document = activeChild;
7071 document.Destroy(0);
7075 bool MenuFileExit(MenuItem selection, Modifiers mods)
7081 bool MenuFileSave(MenuItem selection, Modifiers mods)
7085 fileMonitor.fileName = null;
7088 if(OnSaveFile(fileName))
7090 //if(OnFileModified != Window::OnFileModified)
7093 fileMonitor.fileName = fileName;
7099 MessageBox dialog { master = master, type = yesNoCancel, text = "Error writing file", contents = "Save as a different file?" };
7100 DialogResult answer = dialog.Modal();
7102 if(answer != yes) return (bool)answer;
7105 return MenuFileSaveAs(selection, mods);
7108 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7110 DialogResult result = (DialogResult)bool::true;
7111 FileDialog fileDialog = saveDialog;
7114 fileDialog = FileDialog {};
7119 fileDialog.filePath = fileName;
7122 char filePath[MAX_FILENAME];
7123 sprintf(filePath, "Untitled %d", documentID);
7124 fileDialog.filePath = filePath;
7126 fileMonitor.fileName = null;
7128 fileDialog.type = save;
7129 fileDialog.text = "Save As";
7133 fileDialog.master = master.parent ? master : this;
7134 if(fileDialog.Modal() == ok)
7136 char * filePath = fileDialog.filePath;
7138 if(OnSaveFile(filePath))
7141 property::fileName = filePath;
7142 NotifySaved(master, this, filePath);
7147 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = "Error writing file", contents = "Save as a different file?" };
7148 DialogResult answer = dialog.Modal();
7163 //if(OnFileModified != Window::OnFileModified && fileName)
7166 fileMonitor.fileName = fileName;
7170 return (bool)result; // Actually returning result from Yes/NoCancel message box
7173 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7175 Window document = activeChild;
7177 for(document = children.first; document; document = next)
7179 next = document.next;
7180 if(document.style.isDocument || document.fileName)
7181 document.MenuFileSave(selection, mods);
7186 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7190 for(document = children.first; document; document = document.next)
7191 //if(document.style.isDocument && document.state == minimized)
7192 if(document.style.isActiveClient && document.state == minimized)
7193 document.SetState(minimized, false, mods);
7197 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7199 Window document = activeChild;
7202 Window firstDocument = null;
7204 OldLink cycle = document.cycle.prev;
7209 if(child.style.isActiveClient && !child.style.hidden)
7213 firstDocument = child;
7214 if(child.state == minimized)
7215 child.SetState(minimized, false, mods);
7218 child.positionID = id++;
7219 child.SetState(normal, false, mods);
7220 child.anchor.left.type = cascade;
7223 child.normalSizeAnchor = *&child.sizeAnchor;
7224 child.normalAnchor = child.anchor;
7226 // Break the anchors for moveable/resizable windows
7227 if(child.style.fixed)
7229 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7231 (*&child.normalAnchor).left = x;
7232 (*&child.normalAnchor).top = y;
7233 (*&child.normalAnchor).right.type = none;
7234 (*&child.normalAnchor).bottom.type = none;
7236 child.normalSizeAnchor.isClientW = false;
7237 child.normalSizeAnchor.isClientH = false;
7238 child.normalSizeAnchor.size.w = w;
7239 child.normalSizeAnchor.size.h = h;
7240 child.anchored = false;
7243 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7245 child.stateAnchor = child.normalAnchor;
7246 child.stateSizeAnchor = child.normalSizeAnchor;
7248 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7249 child.Position(x, y, w, h, true, true, true, true, false, false);
7254 last = children.last;
7255 if(!child.style.stayOnTop)
7256 for(; last && last.style.stayOnTop; last = last.prev);
7257 children.Move(child, last);
7258 childrenOrder.Move(child.order, childrenOrder.last);
7260 if(cycle == document.cycle) break;
7264 firstDocument.Activate();
7269 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7276 // Close all closes all active clients, not all documents
7277 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7279 Window next, document;
7281 for(document = children.first; document; document = next)
7283 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7284 if(document.style.isActiveClient)
7285 if(!document.Destroy(0) && !document.style.hidden)
7291 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7293 if(style.hasMaximize && state != maximized)
7294 SetState(maximized, 0, 0);
7298 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7300 if(style.hasMinimize && state != minimized)
7302 SetState(minimized, 0, 0);
7303 parent.CycleChildren(false, true, false, true);
7308 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7310 MenuMoveOrSize(false, selection ? true : false);
7314 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7316 CycleChildren(false, true, false, true);
7320 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7322 CycleChildren(true, true, false, true);
7326 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7328 MenuMoveOrSize(true, true);
7332 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7335 SetState(normal, 0, 0);
7339 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7342 int id = selection.id;
7343 OldLink cycle = activeClient.cycle;
7345 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7348 Window sibling = cycle.data;
7349 if(sibling.style.isActiveClient)
7357 document = cycle.data;
7358 document.Activate();
7360 //if(activeChild.state == maximized)
7361 // document.SetState(maximized, false, mods);
7362 //else if(document.state == minimized)
7363 // document.SetState(normal, false, mods);
7367 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7369 stayOnTop = !style.stayOnTop;
7373 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7375 Window document = activeChild;
7378 Window firstDocument = null;
7379 OldLink cycle = document.cycle;
7383 Window child = cycle.data;
7384 if(child.style.isActiveClient && !child.style.hidden)
7386 if(!firstDocument) firstDocument = child;
7387 if(child.state == minimized)
7388 child.SetState(minimized, false, mods);
7391 child.positionID = id++;
7392 child.SetState(normal, false, mods);
7393 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7395 child.anchor.left.type = hTiled;
7398 child.normalSizeAnchor = *&child.sizeAnchor;
7399 child.normalAnchor = child.anchor;
7401 // Break the anchors for moveable/resizable windows
7402 if(child.style.fixed)
7404 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7406 (*&child.normalAnchor).left = x;
7407 (*&child.normalAnchor).top = y;
7408 (*&child.normalAnchor).right.type = none;
7409 (*&child.normalAnchor).bottom.type = none;
7410 child.normalSizeAnchor.isClientW = false;
7411 child.normalSizeAnchor.isClientH = false;
7412 child.normalSizeAnchor.size.w = w;
7413 child.normalSizeAnchor.size.h = h;
7414 child.anchored = false;
7417 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7419 child.stateAnchor = child.normalAnchor;
7420 child.stateSizeAnchor = child.normalSizeAnchor;
7422 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7423 child.Position(x,y, w, h, true, true, true, true, false, true);
7428 if((cycle = cycle.next) == document.cycle) break;
7431 firstDocument.Activate();
7436 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7438 Window document = activeChild;
7441 Window firstDocument = null;
7443 OldLink cycle = document.cycle;
7448 //if(child.style.isDocument)
7449 if(child.style.isActiveClient && !child.style.hidden)
7451 if(!firstDocument) firstDocument = child;
7452 if(child.state == minimized)
7453 child.SetState(minimized, false, mods);
7456 child.positionID = id++;
7457 child.SetState(normal, false, mods);
7458 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7460 child.anchor.left.type = vTiled;
7463 child.normalSizeAnchor = *&child.sizeAnchor;
7464 child.normalAnchor = child.anchor;
7466 // Break the anchors for moveable/resizable windows
7467 if(child.style.fixed)
7469 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7471 (*&child.normalAnchor).left = x;
7472 (*&child.normalAnchor).top = y;
7473 (*&child.normalAnchor).right.type = none;
7474 (*&child.normalAnchor).bottom.type = none;
7475 child.normalSizeAnchor.isClientW = false;
7476 child.normalSizeAnchor.isClientH = false;
7477 child.normalSizeAnchor.size.w = w;
7478 child.normalSizeAnchor.size.h = h;
7479 child.anchored = false;
7482 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7484 child.stateAnchor = child.normalAnchor;
7485 child.stateSizeAnchor = child.normalSizeAnchor;
7487 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7488 child.Position(x,y, w, h, true, true, true, true, false, true);
7493 if((cycle = cycle.next) == document.cycle) break;
7496 firstDocument.Activate();
7501 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7503 WindowList dialog { master = this };
7504 Window document = (Window)dialog.Modal();
7507 if(activeChild.state == maximized)
7508 document.SetState(maximized, false, mods);
7509 else if(document.state == minimized)
7510 document.SetState(normal, false, mods);
7511 document.Activate();
7517 virtual bool OnCreate(void);
7518 virtual void OnDestroy(void);
7519 virtual void OnDestroyed(void);
7520 virtual bool OnClose(bool parentClosing);
7521 virtual bool OnStateChange(WindowState state, Modifiers mods);
7522 virtual bool OnPostCreate(void);
7523 virtual bool OnMoving(int *x, int *y, int w, int h);
7524 virtual bool OnResizing(int *width, int *height);
7525 virtual void OnResize(int width, int height);
7526 virtual void OnPosition(int x, int y, int width, int height);
7527 virtual bool OnLoadGraphics(void);
7528 virtual void OnApplyGraphics(void);
7529 virtual void OnUnloadGraphics(void);
7530 virtual void OnRedraw(Surface surface);
7531 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7532 virtual void OnActivateClient(Window client, Window previous);
7533 virtual bool OnKeyDown(Key key, unichar ch);
7534 virtual bool OnKeyUp(Key key, unichar ch);
7535 virtual bool OnKeyHit(Key key, unichar ch);
7536 virtual bool OnSysKeyDown(Key key, unichar ch);
7537 virtual bool OnSysKeyUp(Key key, unichar ch);
7538 virtual bool OnSysKeyHit(Key key, unichar ch);
7539 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7540 virtual bool OnMouseLeave(Modifiers mods);
7541 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7542 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7543 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7544 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7545 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7546 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7547 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7548 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7549 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7550 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7551 virtual void OnMouseCaptureLost(void);
7552 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7553 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7554 virtual void OnDrawOverChildren(Surface surface);
7555 virtual bool OnFileModified(FileChange fileChange, char * param);
7556 virtual bool OnSaveFile(char * fileName);
7558 // Skins Virtual Functions
7559 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7560 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7561 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7566 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7567 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7568 virtual bool IsMouseMoving(int x, int y, int w, int h);
7569 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY);
7570 virtual void UpdateNonClient();
7571 virtual void SetBox(Box box);
7572 virtual bool IsInside(int x, int y)
7574 return box.IsPointInside({x, y});
7576 virtual bool IsOpaque()
7578 return (!style.drawBehind || background.a == 255);
7582 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7583 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7584 virtual void Window::NotifySaved(Window window, char * filePath);
7589 property Window parent
7591 property_category "Layout"
7594 if(value || guiApp.desktop)
7597 Window oldParent = parent;
7598 Anchor anchor = this.anchor;
7600 if(value && value.IsDescendantOf(this)) return;
7601 if(value && value == this)
7603 if(!value) value = guiApp.desktop;
7605 if(value == oldParent) return;
7607 if(!master || (master == this.parent && master == guiApp.desktop))
7608 property::master = value;
7612 parent.children.Remove(this);
7616 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7617 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7618 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7619 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7623 last = value.children.last;
7625 if(style.isDocument)
7628 parent.numDocuments--;
7629 documentID = value.GetDocumentID();
7632 if(style.isActiveClient && !style.hidden)
7634 if(parent && parent != guiApp.desktop && !(style.hidden))
7636 if(state == minimized) parent.numIcons--;
7637 parent.numPositions--;
7641 if(!style.stayOnTop)
7642 for(; last && last.style.stayOnTop; last = last.prev);
7644 value.children.Insert(last, this);
7646 // *** NEW HERE: ***
7648 parent.childrenCycle.Delete(cycle);
7650 parent.childrenOrder.Delete(order);
7658 int x = position.x, y = position.y, w = size.w, h = size.h;
7662 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7663 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7665 vpw = value.clientSize.w;
7666 vph = value.clientSize.h;
7672 else if(style.fixed)
7674 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7675 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7678 anchor = this.anchor;
7680 if(anchor.left.type == offset) anchor.left.distance = x;
7681 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7682 if(anchor.top.type == offset) anchor.top.distance = y;
7683 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7684 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7685 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7686 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7687 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7688 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7689 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7691 if(!anchor.left.type && !anchor.right.type)
7693 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7694 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7696 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7697 if(!anchor.top.type && !anchor.bottom.type)
7699 anchor.vert.distance = (y + h / 2) - (vph / 2);
7700 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7702 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7710 parent.childrenCycle.Insert(
7711 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7712 cycle = OldLink { data = this });
7713 parent.childrenOrder.Insert(
7714 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7715 order = OldLink { data = this });
7718 if(!style.hidden && style.isActiveClient)
7720 positionID = parent.GetPositionID(this);
7721 parent.numPositions++;
7722 if(state == minimized) parent.numIcons--;
7725 // *** FONT INHERITANCE ***
7726 if(!setFont && oldParent)
7727 stopwatching(oldParent, font);
7731 RemoveResource(systemFont);
7734 // TESTING WITH WATCHERS:
7735 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7736 // usedFont = setFont ? setFont : (systemFont);
7740 if(guiApp.currentSkin)
7742 systemFont = guiApp.currentSkin.SystemFont();
7745 usedFont = systemFont;
7746 AddResource(systemFont);
7754 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7763 if(value.rootWindow && value.rootWindow.display && rootWindow)
7765 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7766 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7769 UnloadGraphics(false);
7772 LoadGraphics(false, false);
7775 if(value.rootWindow != rootWindow)
7776 DisplayModeChanged();
7780 scrolledPos.x = MININT; // Prevent parent update
7781 property::anchor = anchor;
7785 if(guiApp.currentSkin)
7786 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7788 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7789 Position(x, y, w, h, true, true, true, true, false, true);
7794 // else parent = value;
7797 get { return parent; }
7800 property Window master
7802 property_category "Behavior"
7805 //if(this == value) return;
7806 if(value && value.IsSlaveOf(this)) return;
7812 OldLink slaveHolder;
7813 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7814 if(slaveHolder.data == this)
7816 master.slaves.Delete(slaveHolder);
7823 value.slaves.Add(OldLink { data = this });
7828 master.hotKeys.Remove(hotKey);
7829 value.hotKeys.Add(hotKey);
7832 if(master && master.defaultControl == this)
7833 master.defaultControl = null;
7835 if(style.isDefault && !value.defaultControl)
7836 value.defaultControl = this;
7842 get { return master ? master : parent; }
7845 property char * text
7847 property_category "Appearance"
7854 caption = new char[strlen(value)+1];
7856 strcpy(caption, value);
7861 get { return caption; }
7866 property_category "Behavior"
7875 master.hotKeys.Add(hotKey = HotKeySlot { });
7879 hotKey.window = this;
7884 master.hotKeys.Delete(hotKey);
7889 get { return hotKey ? hotKey.key : 0; }
7892 property Color background
7894 property_category "Appearance"
7897 background.color = value;
7902 if(this == rootWindow)
7903 guiApp.interfaceDriver.SetRootWindowColor(this);
7906 get { return background.color; }
7909 property Percentage opacity
7911 property_category "Appearance"
7914 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
7915 drawBehind = background.a ? false : true;
7917 get { return background.a / 255.0f; }
7920 property Color foreground
7922 property_category "Appearance"
7930 get { return foreground; }
7933 property BorderStyle borderStyle
7935 property_category "Appearance"
7938 if(!((BorderBits)value).fixed)
7940 style.hasClose = false;
7941 style.hasMaximize = false;
7942 style.hasMinimize = false;
7944 style.borderBits = value;
7948 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
7950 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7951 Position(x, y, w, h, true, true, true, true, false, true);
7952 CreateSystemChildren();
7955 get { return (BorderStyle)style.borderBits; }
7958 property Size minClientSize
7960 property_category "Layout"
7961 set { minSize = value; }
7962 get { value = minSize; }
7965 property Size maxClientSize
7967 property_category "Layout"
7968 set { maxSize = value; }
7969 get { value = maxSize; }
7972 property bool hasMaximize
7974 property_category "Window Style"
7977 style.hasMaximize = value;
7978 if(value) { style.fixed = true; style.contour = true; }
7982 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
7984 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7985 Position(x, y, w, h, true, true, true, true, false, true);
7987 CreateSystemChildren();
7990 get { return style.hasMaximize; }
7993 property bool hasMinimize
7995 property_category "Window Style"
7998 style.hasMinimize = value;
7999 if(value) { style.fixed = true; style.contour = true; }
8003 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8005 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8006 Position(x, y, w, h, true, true, true, true, false, true);
8008 CreateSystemChildren();
8011 get { return style.hasMinimize; }
8014 property bool hasClose
8016 property_category "Window Style"
8019 style.hasClose = value;
8020 if(value) { style.fixed = true; style.contour = true; }
8024 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8025 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8026 Position(x, y, w, h, true, true, true, true, false, true);
8027 CreateSystemChildren();
8030 get { return style.hasClose; }
8033 property bool nonClient
8035 property_category "Layout"
8038 style.nonClient = value;
8040 style.stayOnTop = true;
8042 get { return style.nonClient; }
8045 property bool inactive
8047 property_category "Behavior"
8052 // *** NEW HERE: ***
8056 parent.childrenCycle.Delete(cycle);
8058 parent.childrenOrder.Delete(order);
8065 active = false; // true;
8066 if(parent.activeChild == this)
8067 parent.activeChild = null;
8068 if(parent.activeClient == this)
8069 parent.activeClient = null;
8078 parent.childrenCycle.Insert(
8079 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8080 cycle = OldLink { data = this });
8082 parent.childrenOrder.Insert(
8083 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8084 order = OldLink { data = this });
8087 style.inactive = value;
8089 get { return style.inactive; }
8092 property bool clickThrough
8094 property_category "Behavior"
8095 set { style.clickThrough = value; }
8096 get { return style.clickThrough; }
8099 property bool isRemote
8101 property_category "Behavior"
8102 set { style.isRemote = value; }
8103 get { return style.isRemote; }
8106 property bool noCycle
8108 property_category "Behavior"
8109 set { style.noCycle = value; }
8110 get { return style.noCycle; }
8113 property bool isModal
8115 property_category "Behavior"
8116 set { style.modal = value; }
8117 get { return style.modal; }
8120 property bool interim
8122 property_category "Behavior"
8123 set { style.interim = value; }
8124 get { return style.interim; }
8127 property bool tabCycle
8129 property_category "Behavior"
8130 set { style.tabCycle = value; }
8131 get { return style.tabCycle; }
8134 property bool isDefault
8136 property_category "Behavior"
8144 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8145 if(sibling != this && sibling.style.isDefault)
8146 sibling.style.isDefault = false;*/
8147 if(master.defaultControl)
8148 master.defaultControl.style.isDefault = false;
8149 master.defaultControl = this;
8151 else if(master.defaultControl == this)
8152 master.defaultControl = null;
8156 style.isDefault = value;
8158 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8160 get { return style.isDefault; }
8163 property bool drawBehind
8165 property_category "Window Style"
8166 set { style.drawBehind = value; }
8167 get { return style.drawBehind; }
8170 property bool hasMenuBar
8172 property_category "Window Style"
8182 if(created && !menuBar)
8189 anchor = Anchor { top = 23, left = 1, right = 1 },
8191 inactive = true, nonClient = true
8196 else if(created && menuBar)
8201 style.hasMenuBar = value;
8203 get { return style.hasMenuBar; }
8206 property bool hasStatusBar
8208 property_category "Window Style"
8215 statusBar = StatusBar { this };
8223 style.hasStatusBar = value;
8225 get { return style.hasStatusBar; }
8227 property bool stayOnTop
8229 property_category "Window Style"
8234 if(created && !style.stayOnTop)
8236 if(rootWindow == this)
8237 guiApp.interfaceDriver.OrderRootWindow(this, true);
8238 else if(parent.children.last != this)
8240 parent.children.Move(this, parent.children.last);
8244 style.stayOnTop = true;
8248 if(created && style.stayOnTop)
8250 if(rootWindow == this)
8251 guiApp.interfaceDriver.OrderRootWindow(this, false);
8258 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8259 order && ((Window)order.data).style.stayOnTop;
8260 order = (order == parent.childrenOrder.first) ? null : order.prev);
8261 last = order ? order.data : null;
8265 for(last = parent.children.last;
8266 last && last.style.stayOnTop;
8270 parent.children.Move(this, last);
8274 style.stayOnTop = false;
8277 get { return style.stayOnTop; }
8282 property_category "Window Style"
8292 if(menuBar && !value)
8299 if(!menuBar && style.hasMenuBar && value)
8303 this, menu = value, isMenuBar = true,
8304 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8305 inactive = true, nonClient = true
8309 UpdateActiveDocument(null);
8312 get { return menu; }
8315 property FontResource font
8317 property_category "Appearance"
8319 isset { return setFont ? true : false; }
8324 if(value && !setFont) { stopwatching(parent, font); }
8325 else if(!value && setFont)
8331 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8340 RemoveResource(setFont);
8345 RemoveResource(systemFont);
8352 AddResource(setFont);
8355 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8358 systemFont = guiApp.currentSkin.SystemFont();
8360 usedFont = systemFont;
8361 AddResource(systemFont);
8369 get { return usedFont; }
8372 property SizeAnchor sizeAnchor
8374 property_category "Layout"
8377 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8378 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8379 sizeAnchor.isClientW != sizeAnchor.isClientH;
8386 normalSizeAnchor = sizeAnchor;
8388 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8390 stateAnchor = normalAnchor;
8391 stateSizeAnchor = normalSizeAnchor;
8393 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8394 Position(x,y, w, h, true, true, true, true, false, true);
8401 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8402 sizeAnchor.isClientW,
8403 sizeAnchor.isClientH
8410 property_category "Layout"
8413 Anchor thisAnchor = anchor;
8414 SizeAnchor thisSizeAnchor = sizeAnchor;
8415 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8416 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8417 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8418 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8419 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8420 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8426 sizeAnchor.isClientW = false;
8427 sizeAnchor.isClientH = false;
8428 sizeAnchor.size = value;
8430 normalSizeAnchor = sizeAnchor;
8432 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8434 stateAnchor = normalAnchor;
8435 stateSizeAnchor = normalSizeAnchor;
8437 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8438 Position(x, y, w, h, true, true, true, true, false, true);
8441 get { value = size; }
8444 property Size clientSize
8446 property_category "Layout"
8449 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8450 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8451 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8456 sizeAnchor.isClientW = true;
8457 sizeAnchor.isClientH = true;
8458 sizeAnchor.size = value;
8460 normalSizeAnchor = sizeAnchor;
8462 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8464 stateAnchor = normalAnchor;
8465 stateSizeAnchor = normalSizeAnchor;
8467 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8468 Position(x,y, w, h, true, true, true, true, false, true);
8471 get { value = clientSize; }
8474 property Size initSize { get { value = sizeAnchor.size; } };
8476 property Anchor anchor
8478 property_category "Layout"
8479 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8485 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8487 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8488 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8490 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8492 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8493 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8497 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8499 anchor.left.distance = 0;
8500 anchor.horz.type = 0;
8502 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8504 anchor.top.distance = 0;
8505 anchor.vert.type = 0;
8514 normalAnchor = anchor;
8516 // Break the anchors for moveable/resizable windows
8517 /*if(style.fixed ) //&& value.left.type == cascade)
8519 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8521 this.anchor = normalAnchor = Anchor { left = x, top = y };
8522 normalSizeAnchor = SizeAnchor { { w, h } };
8525 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8527 stateAnchor = normalAnchor;
8528 stateSizeAnchor = normalSizeAnchor;
8530 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8531 Position(x, y, w, h, true, true, true, true, false, true);
8540 get { value = this ? anchor : Anchor { }; }
8543 property Point position
8545 property_category "Layout"
8548 if(value == null) return;
8550 anchor.left = value.x;
8551 anchor.top = value.y;
8552 anchor.right.type = none;
8553 anchor.bottom.type = none;
8558 normalAnchor = anchor;
8560 // Break the anchors for moveable/resizable windows
8564 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8566 normalAnchor.left = x;
8567 normalAnchor.top = y;
8568 normalAnchor.right.type = none;
8569 normalAnchor.bottom.type = none;
8570 normalSizeAnchor.size.width = w;
8571 normalSizeAnchor.size.height = h;
8575 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8577 stateAnchor = normalAnchor;
8578 stateSizeAnchor = normalSizeAnchor;
8580 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8581 Position(x,y, w, h, true, true, true, true, false, true);
8585 get { value = position; }
8588 property bool disabled
8590 property_category "Behavior"
8593 if(this && disabled != value)
8600 get { return (bool)disabled; }
8603 property bool isEnabled
8608 for(parent = this; parent; parent = parent.parent)
8615 property WindowState state
8617 property_category "Behavior"
8618 set { SetState(value, false, 0); }
8619 get { return this ? state : 0; }
8622 property bool visible
8624 property_category "Behavior"
8627 if(this && !value && !style.hidden && parent)
8629 Window client = null;
8631 style.hidden = true;
8634 OldLink prevOrder = null;
8636 if(rootWindow == this)
8637 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8640 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8643 box.left -= parent.clientStart.x;
8644 box.top -= parent.clientStart.y;
8645 box.right -= parent.clientStart.x;
8646 box.bottom -= parent.clientStart.y;
8650 if(style.modal && master && master.modalSlave == this)
8651 master.modalSlave = null;
8653 if(style.isActiveClient)
8655 parent.numPositions--;
8656 if(state == minimized) parent.numIcons--;
8661 OldLink tmpPrev = order.prev;
8662 client = tmpPrev ? tmpPrev.data : null;
8663 if(client && !client.style.hidden && !client.destroyed && client.created)
8664 prevOrder = tmpPrev;
8667 client = tmpPrev ? tmpPrev.data : null;
8668 if(client == this) { client = null; break; }
8669 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8671 tmpPrev = client.order.prev;
8676 prevOrder = tmpPrev;
8681 // If this window can be an active client, make sure the next window we activate can also be one
8682 if(!style.nonClient && style.isActiveClient)
8684 tmpPrev = prevOrder;
8687 client = tmpPrev ? tmpPrev.data : null;
8688 if(client == this) { client = null; break; }
8689 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8691 tmpPrev = client.order.prev;
8696 prevOrder = tmpPrev;
8700 if(client && client.style.hidden) client = null;
8704 if((parent.activeChild == this || guiApp.interimWindow == this) && true /*activate*/)
8706 if(order && prevOrder && prevOrder.data != this)
8707 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8709 ActivateEx(false, false, false, true, null, null);
8711 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8712 if(parent.activeClient == this)
8714 parent.activeClient = null;
8715 parent.UpdateActiveDocument(null);
8718 else if(parent.activeClient == this)
8720 parent.activeClient = client;
8721 parent.UpdateActiveDocument(this);
8724 // *** Not doing this anymore ***
8727 parent.childrenCycle.Delete(cycle);
8729 parent.childrenOrder.Delete(order);
8734 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8739 else if(this && value && style.hidden)
8741 style.hidden = false;
8744 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8745 if(rootWindow == this)
8746 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8748 if(style.modal && master)
8749 master.modalSlave = this;
8751 if(style.isActiveClient)
8753 positionID = parent.GetPositionID(this);
8754 parent.numPositions++;
8755 if(state == minimized) parent.numIcons++;
8758 // *** NOT DOING THIS ANYMORE ***
8760 if(!(style.inactive))
8762 if(!(style.noCycle))
8764 cycle = parent.childrenCycle.AddAfter(
8765 (parent.activeChild && parent.activeChild.cycle) ?
8766 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8769 order = parent.childrenOrder.AddAfter(
8770 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8777 if(true || !parent.activeChild)
8778 ActivateEx(true, false, true, true, null, null);
8780 if(creationActivation == activate)
8781 ActivateEx(true, false, true, true, null, null);
8782 else if(creationActivation == flash && !object)
8785 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8789 ConsequentialMouseMove(false);
8796 get { return (style.hidden || !setVisible) ? false : true; }
8799 property bool isDocument
8801 property_category "Document"
8802 set { style.isDocument = value; }
8803 get { return style.isDocument; }
8806 property bool mergeMenus
8808 property_category "Window Style"
8809 set { mergeMenus = value; }
8810 get { return (bool)mergeMenus; }
8813 property bool hasHorzScroll
8815 property_category "Window Style"
8820 if(!style.hasHorzScroll && created)
8822 CreateSystemChildren();
8823 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8826 else if(style.hasHorzScroll)
8830 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8832 style.hasHorzScroll = value;
8835 get { return style.hasHorzScroll; }
8838 property bool hasVertScroll
8840 property_category "Window Style"
8845 if(!style.hasVertScroll && created)
8847 style.hasVertScroll = true;
8848 CreateSystemChildren();
8849 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8852 else if(style.hasVertScroll)
8856 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8858 style.hasVertScroll = value;
8860 get { return style.hasVertScroll; }
8863 property bool dontHideScroll
8865 property_category "Behavior"
8868 scrollFlags.dontHide = value;
8871 //UpdateScrollBars(true, true);
8872 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
8876 // UpdateScrollBars(true, true);
8877 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
8880 get { return scrollFlags.dontHide; }
8883 property bool dontScrollVert
8885 property_category "Behavior"
8886 set { style.dontScrollVert = value; }
8887 get { return style.dontScrollVert; }
8889 property bool dontScrollHorz
8891 property_category "Behavior"
8892 set { style.dontScrollHorz = value; }
8893 get { return style.dontScrollHorz; }
8896 property bool snapVertScroll
8898 property_category "Behavior"
8901 scrollFlags.snapY = value;
8902 if(sbv) sbv.snap = value;
8904 get { return scrollFlags.snapY; }
8906 property bool snapHorzScroll
8908 property_category "Behavior"
8911 scrollFlags.snapX = value;
8912 if(sbh) sbh.snap = value;
8914 get { return scrollFlags.snapX; }
8917 property Point scroll
8919 property_category "Behavior"
8923 // TESTING THIS IMPLEMENTATION:
8924 SetScrollPosition(value.x, value.y);
8926 get { value = scroll; }
8929 property bool modifyVirtualArea
8931 property_category "Behavior"
8932 set { modifyVirtArea = value; }
8933 get { return (bool)modifyVirtArea; }
8936 property char * fileName
8938 property_category "Document"
8941 if(menu && ((!fileName && value) || (fileName && !value)))
8943 MenuItem item = menu.FindItem(MenuFileSave, 0);
8944 if(item) item.disabled = !modifiedDocument && value;
8949 if(value && value[0])
8950 fileName = CopyString(value);
8952 if(parent && this == parent.activeClient)
8953 parent.UpdateActiveDocument(null);
8957 // if(style.isDocument)
8959 fileMonitor.fileName = value;
8961 get { return fileName; }
8966 property_category "Data"
8971 property bool modifiedDocument
8973 property_category "Document"
8976 if(style.isDocument || fileName)
8980 MenuItem item = menu.FindItem(MenuFileSave, 0);
8981 if(item) item.disabled = !value && fileName;
8985 if(modifiedDocument != value)
8987 modifiedDocument = value;
8988 if(style.isDocument || fileName)
8992 get { return (bool)modifiedDocument; }
8995 property bool showInTaskBar
8997 property_category "Window Style"
8998 set { style.showInTaskBar = value; }
8999 get { return (style.showInTaskBar; }
9001 property FileDialog saveDialog { set { saveDialog = value; } };
9002 property bool isActiveClient
9004 property_category "Behavior"
9005 set { style.isActiveClient = value; }
9006 get { return style.isActiveClient; }
9009 property Cursor cursor
9011 property_category "Appearance"
9015 SelectMouseCursor();
9017 get { return cursor; }
9020 //#if !defined(ECERE_VANILLA)
9021 property char * name
9023 property_category "Design"
9026 return (this && object) ? object.name : null;
9031 activeDesigner.RenameObject(object, value);
9035 property char * displayDriver
9037 property_category "Behavior"
9040 dispDriver = GetDisplayDriver(value);
9041 //DisplayModeChanged();
9045 return dispDriver ? dispDriver.name : null;
9049 // RUNTIME PROPERTIES
9050 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9051 property Size scrollArea
9053 property_category "Behavior"
9057 SetScrollArea(value.w, value.h, false);
9059 SetScrollArea(0,0, true);
9061 get { value = scrollArea; }
9064 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9069 property_category "Layout"
9070 set { if(this) is3D = value; }
9071 get { return (bool)is3D; }
9074 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9076 // Will be merged with font later
9077 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9078 property Point clientStart { get { value = clientStart; } };
9079 property Point absPosition { get { value = absPosition; } };
9080 property Anchor normalAnchor { get {value = normalAnchor; } };
9081 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9082 property bool active { get { return (bool)active; } };
9083 property bool created { get { return (bool)created; } };
9084 property bool destroyed { get { return (bool)destroyed; } };
9085 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9086 property Window firstChild { get { return children.first; } };
9087 property Window lastChild { get { return children.last; } };
9088 property Window activeClient { get { return activeClient; } };
9089 property Window activeChild { get { return activeChild; } };
9090 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9091 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9092 property ScrollBar horzScroll { get { return sbh; } };
9093 property ScrollBar vertScroll { get { return sbv; } };
9094 property StatusBar statusBar { get { return statusBar; } };
9095 property Window rootWindow { get { return rootWindow; } };
9096 property bool closing { get { return (bool)closing; } set { closing = value; } };
9097 property int documentID { get { return documentID; } };
9098 property Window previous { get { return prev; } }
9099 property Window next { get { return next; } }
9100 property Window nextSlave { get { OldLink link = master.slaves.FindLink(this); return (link && link.next) ? link.next.data : null; } }
9101 property PopupMenu menuBar { get { return menuBar; } }
9102 property ScrollBar sbv { get { return sbv; } }
9103 property ScrollBar sbh { get { return sbh; } }
9104 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9105 property void * systemHandle { get { return windowHandle; } }
9106 property Button minimizeButton { get { return sysButtons[0]; } };
9107 property Button maximizeButton { get { return sysButtons[1]; } };
9108 property Button closeButton { get { return sysButtons[2]; } };
9109 property BitmapResource icon
9111 get { return icon; }
9117 guiApp.interfaceDriver.SetIcon(this, value);
9120 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9121 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9122 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9123 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9124 property bool nativeDecorations { get { return (bool)nativeDecorations; } set { nativeDecorations = value; } };
9125 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9131 WindowBits style; // Window Style
9132 char * caption; // Name / Caption
9133 Window parent; // Parent window
9134 OldList children; // List of children in Z order
9135 Window activeChild; // Child window having focus
9136 Window activeClient;
9137 Window previousActive; // Child active prior to activating the default child
9138 Window master; // Window owning and receiving notifications concerning this window
9139 OldList slaves; // List of windows belonging to this window
9140 Display display; // Display this window is drawn into
9142 Point position; // Position in parent window client area
9143 Point absPosition; // Absolute position
9144 Point clientStart; // Client area position from (0,0) in this window
9146 Size clientSize; // Client area size
9147 Size scrollArea; // Virtual Scroll area size
9148 Size reqScrollArea; // Requested virtual area size
9149 Point scroll; // Virtual area scrolling position
9150 public ScrollBar sbh, sbv; // Scrollbar window handles
9151 Cursor cursor; // Mouse cursor used for this window
9154 StatusBar statusBar;
9155 Button sysButtons[3];
9157 Box clientArea; // Client Area box clipped to parent
9159 HotKeySlot hotKey; // HotKey for this window
9163 ScrollFlags scrollFlags;// Window Scrollbar Flags
9164 int id; // Control ID
9166 ColorAlpha background; // Background color used to draw the window area
9168 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9169 OldList childrenCycle; // Cycling order
9170 OldLink cycle; // Element of parent's cycling order
9171 OldList childrenOrder; // Circular Z-Order
9172 OldLink order; // Element of parent's circular Z-Order
9173 Window modalSlave; // Slave window blocking this window's interaction
9175 Window rootWindow; // Topmost system managed window
9176 void * windowHandle; // System window handle
9178 DialogResult returnCode;// Return code for modal windows
9180 Point sbStep; // Scrollbar line scrolling steps
9183 SizeAnchor stateSizeAnchor;
9185 Anchor normalAnchor;
9186 SizeAnchor normalSizeAnchor;
9188 Size skinMinSize; // Minimal window size based on style
9189 Point scrolledPos; // Scrolled position
9190 Box box; // Window box clipped to parent
9191 Box * against; // What to clip the box to
9193 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9194 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9195 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9196 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9197 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9198 Point scrolledArea; // Distance to scroll area by
9199 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9201 OldList hotKeys; // List of the hotkeys of all children
9202 Window defaultControl; // Default child control
9206 ColorAlpha * palette; // Color palette used for this window
9208 int caretSize; // Size of caret, non zero if a caret is present
9209 Point caretPos; // Caret position
9211 void * systemParent; // Parent System Window for embedded windows
9218 WindowState lastState;
9220 FileMonitor fileMonitor
9222 this, FileChange { modified = true };
9224 bool OnFileNotify(FileChange action, char * param)
9227 fileMonitor.StopMonitoring();
9228 if(OnFileModified(action, param))
9229 fileMonitor.StartMonitoring();
9234 FontResource setFont, systemFont;
9235 FontResource usedFont;
9236 FontResource captionFont;
9238 FileDialog saveDialog;
9240 SizeAnchor sizeAnchor;
9242 // FormDesigner data
9245 Extent * tempExtents; //[4];
9246 BitmapResource icon;
9248 CreationActivationOption creationActivation;
9251 bool active:1; // true if window and ancestors are active
9252 bool acquiredInput:1; // true if the window is processing state based input
9253 bool modifiedDocument:1;
9254 bool disabled:1; // true if window cannot interact
9255 bool isForegroundWindow:1;// true while a root window is being activated
9256 bool visible:1; // Visibility flag
9257 bool destroyed:1; // true if window is being destroyed
9258 bool anchored:1; // true if this window is repositioned when the parent resizes
9259 bool dirty:1; // Flag set to true if any descendant must be redrawn
9265 bool modifyVirtArea:1;
9266 bool noAutoScrollArea:1;
9269 bool setVisible:1; // FOR FORM DESIGNER
9275 bool useSharedMemory:1;
9278 bool nativeDecorations:1;
9279 bool manageDisplay:1;
9282 WindowController controller;
9283 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9286 public class CommonControl : Window
9288 // creationActivation = doNothing;
9291 public class Percentage : float
9293 char * OnGetString(char * string, float * fieldData, bool * needClass)
9297 sprintf(string, "%.2f", this);
9298 c = strlen(string)-1;
9301 if(string[c] != '0')
9302 last = Max(last, c);
9303 if(string[c] == '.')
9316 public void ApplySkin(Class c, char * name, void ** vTbl)
9318 char className[1024];
9323 subclass(Window) wc = (subclass(Window))c;
9324 subclass(Window) base = (subclass(Window))c.base;
9326 sprintf(className, "%sSkin_%s", name, c.name);
9327 wc.pureVTbl = c._vTbl;
9328 c._vTbl = new void *[c.vTblSize];
9329 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9330 sc = eSystem_FindClass(c.module.application, className);
9334 for(m = 0; m < c.base.vTblSize; m++)
9336 if(c._vTbl[m] == base.pureVTbl[m])
9337 c._vTbl[m] = vTbl[m];
9342 for(m = 0; m < c.vTblSize; m++)
9344 if(sc._vTbl[m] != wc.pureVTbl[m])
9345 c._vTbl[m] = sc._vTbl[m];
9349 for(d = c.derivatives.first; d; d = d.next)
9351 ApplySkin(d.data, name, c._vTbl);
9355 public void UnapplySkin(Class c)
9357 char className[1024];
9359 subclass(Window) wc = (subclass(Window))c;
9360 subclass(Window) base = (subclass(Window))c.base;
9363 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9366 c._vTbl = wc.pureVTbl;
9370 for(d = c.derivatives.first; d; d = d.next)
9372 UnapplySkin(d.data);
9376 void CheckFontIntegrity(Window window)
9381 if(window.usedFont && window.usedFont.font == 0xecececec)
9383 FontResource uf = window.usedFont;
9384 char * className = window._class.name;
9385 char * text = window.text;
9388 for(c = window.firstChild; c; c = c.next)
9389 CheckFontIntegrity(c);
9393 public class ControllableWindow : Window
9395 /*WindowController controller;
9396 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9397 ~ControllableWindow() { delete controller; }*/
9400 class WindowControllerInterface : ControllableWindow
9402 bool OnKeyDown(Key key, unichar ch)
9404 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9406 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9410 bool OnKeyUp(Key key, unichar ch)
9412 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9414 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9418 bool OnKeyHit(Key key, unichar ch)
9420 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9422 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9426 bool OnMouseMove(int x, int y, Modifiers mods)
9428 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9430 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9434 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9436 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9438 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9442 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9444 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9446 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9450 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9452 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9454 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9458 bool OnRightButtonDown(int x, int y, Modifiers mods)
9460 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9462 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9466 bool OnRightButtonUp(int x, int y, Modifiers mods)
9468 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9470 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9474 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9476 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9478 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9482 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9484 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9486 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9490 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9492 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9494 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9498 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9500 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9502 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9506 void OnResize(int width, int height)
9508 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9509 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9512 void OnRedraw(Surface surface)
9514 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9515 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9520 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9522 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9527 public class WindowController<class V>
9530 property Window window
9534 uint size = class(Window).vTblSize;
9537 windowVTbl = new void *[size];
9538 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9539 if(value._vTbl == value._class._vTbl)
9541 value._vTbl = new void *[value._class.vTblSize];
9542 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9546 for(c = 0; c < size; c++)
9548 void * function = class(WindowControllerInterface)._vTbl[c];
9549 if(function != DefaultFunction)
9550 value._vTbl[c] = function;
9552 value._vTbl[c] = windowVTbl[c];
9557 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9560 get { return window; }
9562 property V controlled
9564 set { controlled = value; }
9565 get { return controlled; }
9567 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9568 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9569 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9570 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9571 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9572 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9573 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9574 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9575 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9576 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9577 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9578 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9579 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9580 virtual void V::OnResize(WindowController controller, int width, int height);
9581 virtual void V::OnRedraw(WindowController controller, Surface surface);
9582 virtual bool V::OnCreate(WindowController controller);
9585 int (** windowVTbl)();