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;
41 define statusBarHeight = 18;
43 default extern int __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
45 public enum DialogResult { cancel, yes, no, ok };
47 public class MouseButtons
50 bool left:1, right:1, middle:1;
53 public struct SizeAnchor
56 bool isClientW, isClientH;
61 #define SNAPDOWN(x, d) \
64 if(x < 0) x -= ((d) - Abs(x) % (d)); else x -= x % (d); \
67 #define SNAPUP(x, d) \
70 if(x > 0) x += ((d) - Abs(x) % (d)); else x += x % (d); \
73 /*static */define MAX_DIRTY_BACK = 10;
75 /////////////////////////////////////////////////////////////////////////////
76 ////////// EXTENT MANIPULATION //////////////////////////////////////////////
77 /////////////////////////////////////////////////////////////////////////////
79 #define ACCESS_ITEM(l, id) \
82 #define FASTLIST_LOOP(l, v) \
83 for(v = (BoxItem)l.first; v; v = (BoxItem)v.next)
85 #define FASTLIST_LOOPN(l, v, n) \
86 for(v = (BoxItem)l.first, n = (BoxItem)(v ? v.next : null); v; v = (BoxItem)next, n = (BoxItem)(v ? v.next : null))
89 #define ACCESS_ITEM(l, id) \
90 ((FastItem)(((id) == -1) ? null : (((byte *)((l).items)) + (id) * (l).itemSize)))
92 #define FASTLIST_LOOP(l, v) \
93 for(v = (void *)ACCESS_ITEM((l), (l).first); v; v = (void *)ACCESS_ITEM((l), v.next))
95 #define FASTLIST_LOOPN(l, v, n) \
96 for( v = (void *)ACCESS_ITEM((l), (l).first), \
97 n = v ? ((void *)ACCESS_ITEM((l), v.next)): null; \
98 v; v = n, n = n ? (void *)ACCESS_ITEM((l), n.next) : null)
101 private class FastItem : struct
106 private struct FastList
111 int count, size, itemSize;
118 first = last = free = -1;
126 // FASTLIST_LOOPN(this, item, next) { Delete(item); };
129 FastItem Add(uint itemSize)
132 if(free == -1 || !size)
139 newSize = (size + (size >> 1));
140 items = (FastItem)renew items byte[newSize * itemSize];
145 this.itemSize = itemSize;
146 items = (FastItem)new byte[newSize * itemSize];
149 for(c = size; c<newSize-1; c++)
151 ACCESS_ITEM(this, c).prev = -1;
152 ACCESS_ITEM(this, c).next = c+1;
154 ACCESS_ITEM(this, c).prev = -1;
155 ACCESS_ITEM(this, c).next = -1;
159 item = ACCESS_ITEM(this, free);
162 ACCESS_ITEM(this, item.prev).next = free;
172 void Delete(FastItem item)
175 ACCESS_ITEM(this, item.prev).next = item.next;
177 ACCESS_ITEM(this, item.next).prev = item.prev;
179 if(ACCESS_ITEM(this, first) == item)
181 if(ACCESS_ITEM(this, last) == item)
186 free = ((byte *)item - (byte *)items) / itemSize;
194 free = first = last = -1;
198 private class BoxItem : Item //FastItem
203 public /*private */struct Extent : OldList //FastList
212 //BoxItem extentBox = (BoxItem)Add(sizeof(class BoxItem));
213 Add(BoxItem { box = box });
216 void Copy(Extent source)
222 FASTLIST_LOOP(source, extentBox)
223 AddBox(extentBox.box);
226 void IntersectBox(Box box)
228 // Clip all boxes of extent against inside of the new box
229 BoxItem extentBox, next;
231 FASTLIST_LOOPN(this, extentBox, next)
233 if(box.left > extentBox.box.left) extentBox.box.left = box.left;
234 if(box.top > extentBox.box.top) extentBox.box.top = box.top;
235 if(box.right < extentBox.box.right) extentBox.box.right = box.right;
236 if(box.bottom < extentBox.box.bottom) extentBox.box.bottom = box.bottom;
237 if(extentBox.box.right < extentBox.box.left || extentBox.box.bottom < extentBox.box.top)
242 void ExcludeBox(Box box, Extent temp)
249 FASTLIST_LOOP(temp, extentBox)
251 if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
252 extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
255 if(extentBox.box.top < box.top && extentBox.box.bottom >= box.top)
259 extentBox.box.left, extentBox.box.top,
260 extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
266 if(extentBox.box.bottom > box.bottom && extentBox.box.top <= box.bottom)
270 extentBox.box.left, Max(extentBox.box.top,box.bottom +1),
271 extentBox.box.right, extentBox.box.bottom
277 if(extentBox.box.bottom >= box.top && extentBox.box.top <= box.bottom)
280 if(extentBox.box.left < box.left && extentBox.box.right >= box.left)
284 extentBox.box.left, Max(extentBox.box.top, box.top),
285 Min(extentBox.box.right, box.left-1), Min(extentBox.box.bottom, box.bottom)
291 if(extentBox.box.right > box.right && extentBox.box.left <= box.right)
295 Max(extentBox.box.left, box.right+1), Max(extentBox.box.top, box.top),
296 extentBox.box.right, Min(extentBox.box.bottom, box.bottom)
304 AddBox(extentBox.box);
310 void UnionBox(Box box, Extent temp)
312 BoxItem extentBox, next;
314 // First pass: check if this box is not already covered by one of the extent's box
315 FASTLIST_LOOP(this, extentBox)
317 if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
318 extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
325 // Second pass: only keep boxes not completely covered in the new box
326 FASTLIST_LOOPN(this, extentBox, next)
328 if(extentBox.box.left >= box.left && extentBox.box.right <= box.right &&
329 extentBox.box.top >= box.top && extentBox.box.bottom <= box.bottom)
333 // Add the exclusion to the extent
334 ExcludeBox(box, temp);
337 if(box.bottom >= box.top && box.right >= box.left)
339 // Optimization: if the resulting boxes touch, add them smarter
340 FASTLIST_LOOP(this, extentBox)
342 if(box.top == extentBox.box.top && box.bottom == extentBox.box.bottom)
344 if(Abs(box.right - extentBox.box.left) <= 1)
346 extentBox.box.left = box.left;
349 else if(Abs(box.left - extentBox.box.right) <= 1)
351 extentBox.box.right = box.right;
355 else if(box.left == extentBox.box.left && box.right == extentBox.box.right)
357 if(Abs(box.bottom - extentBox.box.top) <= 1)
359 extentBox.box.top = box.top;
362 else if(Abs(box.top - extentBox.box.bottom) <= 1)
364 extentBox.box.bottom = box.bottom;
376 void Union(Extent b, Extent temp)
380 FASTLIST_LOOP(b, extentBox)
381 UnionBox(extentBox.box, temp);
384 void Intersection(Extent b, Extent temp, Extent temp2, Extent temp3)
391 FASTLIST_LOOP(b, extentBox)
394 temp2.IntersectBox(extentBox.box);
401 void Exclusion(Extent b, Extent temp)
404 FASTLIST_LOOP(b, extentBox)
405 ExcludeBox(extentBox.box, temp);
408 void Offset(int x, int y)
411 FASTLIST_LOOP(this, extentBox)
413 extentBox.box.left += x;
414 extentBox.box.top += y;
415 extentBox.box.right += x;
416 extentBox.box.bottom += y;
421 private define MINIMIZED_WIDTH = 160;
422 private define CASCADE_SPACE = 16;
424 // namespace Windows;
426 private class ScrollFlags
428 bool snapX:1, snapY:1, dontHide:1;
431 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1; };
433 class WindowBits : BorderBits
435 BorderBits borderBits:5:0;
436 bool hidden:1, isActiveClient:1, hasHorzScroll:1, hasVertScroll:1, stayOnTop:1, modal:1, unused1:1, isDefault:1, inactive:1, isRemote:1, drawBehind:1;
437 bool interim:1, tabCycle:1, noCycle:1, dontScrollHorz:1, dontScrollVert:1, hasMaximize:1, hasMinimize:1, hasClose:1;
438 bool embedded:1, unused2:1, hasMenuBar:1, isDocument:1, showInTaskBar:1, hasStatusBar:1, nonClient:1, clickThrough:1;
441 public enum BorderStyle : BorderBits
444 contour = BorderBits { contour = true },
445 fixed = BorderBits { fixed = true } | contour,
446 sizable = BorderBits { sizable = true } | fixed,
447 deep = BorderBits { deep = true },
448 bevel = BorderBits { bevel = true },
449 sizableDeep = sizable|deep,
450 sizableBevel = sizable|bevel,
451 fixedDeep = fixed|deep,
452 fixedBevel = fixed|bevel,
453 deepContour = deep|contour
456 public enum CreationActivationOption
458 activate, flash, doNothing
461 public enum WindowState { normal, minimized, maximized };
463 private class ResPtr : struct
470 private class HotKeySlot : struct
472 HotKeySlot prev, next;
480 class_data char * icon;
482 class_default_property text;
483 // class_initialize GuiApplication::Initialize;
484 class_designer FormDesigner;
485 class_property char * icon
487 set { class_data(icon) = value; }
488 get { return class_data(icon); }
493 if(guiApp) guiApp.Initialize(true);
495 if(guiApp && guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
497 if(_vTbl == ((subclass(Window))_class).pureVTbl)
499 _vTbl = _class._vTbl;
501 else if(_vTbl != _class._vTbl)
504 for(m = 0; m < _class.vTblSize; m++)
506 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
507 _vTbl[m] = _class._vTbl[m];
512 //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
513 //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
514 //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
515 //tempExtents[3] = { /*first = -1, last = -1, free = -1*/ };
519 // caption = CopyString(class.name);
521 children.offset = (byte*)&prev - (byte*)this;
522 childrenOrder.circ = true;
523 childrenCycle.circ = true;
525 maxSize = Size { MAXINT, MAXINT };
529 //style.isActiveClient = true;
532 modifyVirtArea = true;
533 manageDisplay = true;
535 // scrollFlags = ScrollFlags { snapX = true, snapY = true };
536 sbStep.x = sbStep.y = 8;
538 if(guiApp) // dynamic_cast<GuiApplication>(thisModule)
540 cursor = guiApp.GetCursor(arrow);
541 property::parent = guiApp.desktop;
552 stopwatching(parent, font);
556 // Prevent destructor from being called again...
562 /////////////////////////////////
565 OldLink slave = master.slaves.FindLink(this);
566 master.slaves.Delete(slave);
573 parent.childrenCycle.Remove(cycle);
575 parent.childrenOrder.Remove(order);
576 parent.children.Remove(this);
581 /////////////////////////////////
583 while(ptr = resources.first)
586 resources.Delete(ptr);
593 for(child = children.first; child; child = child.next)
595 // child.stopwatching(this, font);
597 eInstance_StopWatching(this, __ecereProp___ecereNameSpace__ecere__gui__Window_font, child);
598 // Don't want property here
599 *&child.parent = null;
602 while(slave = slaves.first)
604 // Don't want property here
605 *&((Window)slave.data).master = null;
606 slaves.Delete(slave);
609 // Because we do a decref in DestroyEx...
617 // Why was this commented?
618 //if(this != guiApp.desktop)
631 if(((subclass(Window))_class).pureVTbl)
633 if(_vTbl == _class._vTbl)
635 _vTbl = ((subclass(Window))_class).pureVTbl;
640 for(m = 0; m < _class.vTblSize; m++)
642 if(_vTbl[m] == _class._vTbl[m])
643 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
647 if(_vTbl == ((subclass(Window))_class).pureVTbl || _vTbl == _class._vTbl)
650 dirtyArea.Free(null);
651 renderArea.Free(null);
652 overRenderArea.Free(null);
653 clipExtent.Free(null);
654 scrollExtent.Free(null);
655 dirtyBack.Free(null);
659 tempExtents[0].Free(null);
660 tempExtents[1].Free(null);
661 tempExtents[2].Free(null);
662 tempExtents[3].Free(null);
667 //#if !defined(ECERE_VANILLA)
668 char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
670 if(this == activeDesigner)
674 char * name = property::name;
675 return name ? name : "";
680 #if !defined(ECERE_VANILLA) && !defined(ECERE_NOTRUETYPE)
681 bool OnGetDataFromString(char * string)
683 FormDesigner designer = (FormDesigner)activeDesigner.classDesigner;
686 if(!strcmp(string, "this") || !strcmp(string, designer.form.name))
687 this = designer.form;
688 else if(!strcmpi(string, "(Desktop)"))
689 this = activeDesigner;
691 return activeDesigner.FindObject(&this, string);
697 // --- Window updates system ---
699 // Setup a bitmap for Redrawing on client area of Window
700 Surface Redraw(Box box)
702 Surface surface = null;
704 Box clientArea = this.clientArea;
708 mox.left -= clientStart.x;
709 mox.top -= clientStart.y;
710 mox.right -= clientStart.x;
711 mox.bottom -= clientStart.y;
713 mox.Clip(clientArea);
714 // mox.ClipOffset(against, scrolledPos.x, scrolledPos.y);
716 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && mox.right >= mox.left && mox.bottom >= mox.top)
718 int x = absPosition.x + clientStart.x;
719 int y = absPosition.y + clientStart.y;
720 if(rootWindow.nativeDecorations)
722 x -= rootWindow.clientStart.x;
723 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
725 if(!guiApp.fullScreenMode || is3D)
727 x -= rootWindow.absPosition.x;
728 y -= rootWindow.absPosition.y;
732 x += rootWindow.parent.clientStart.x;
733 y += rootWindow.parent.clientStart.y;
735 mox.left += rootWindow.parent.clientStart.x;
736 mox.top += rootWindow.parent.clientStart.y;
737 mox.right += rootWindow.parent.clientStart.x;
738 mox.bottom += rootWindow.parent.clientStart.y;
743 surface = display.GetSurface(x, y, mox);
746 surface.width = clientSize.w;
747 surface.height = clientSize.h;
753 // Setup a bitmap for Redrawing on full Window
754 Surface RedrawFull(Box box)
756 Surface surface = null;
764 if((!guiApp.fullScreenMode || guiApp.desktop.active) && display && box.right >= box.left && box.bottom >= box.top)
766 int x = absPosition.x;
767 int y = absPosition.y;
768 if(rootWindow.nativeDecorations)
770 x -= rootWindow.clientStart.x;
771 y -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
773 if(!guiApp.fullScreenMode || is3D)
775 x -= rootWindow.absPosition.x;
776 y -= rootWindow.absPosition.y;
779 x += rootWindow.parent.clientStart.x;
780 y += rootWindow.parent.clientStart.y;
782 mox.left += rootWindow.parent.clientStart.x;
783 mox.top += rootWindow.parent.clientStart.y;
784 mox.right += rootWindow.parent.clientStart.x;
785 mox.bottom += rootWindow.parent.clientStart.y;
790 surface = display.GetSurface(x, y, mox);
793 surface.width = size.w;
794 surface.height = size.h;
800 void FigureCaption(char * caption)
804 strcpy(caption, this.caption);
805 if(style.isDocument || fileName)
807 if(caption[0]) strcat(caption, " - ");
809 strcat(caption, fileName);
813 sprintf(title, "Untitled %d", documentID);
814 strcat(caption, title);
817 strcat(caption, " *");
819 if(activeClient && menuBar &&
820 activeClient.state == maximized)
822 if(activeClient.caption)
824 if(caption[0]) strcat(caption, " - ");
825 strcat(caption, activeClient.caption);
827 if(activeClient.style.isDocument || activeClient.fileName)
829 if(caption[0]) strcat(caption, " - ");
830 strcat(caption, "[");
831 if(activeClient.fileName)
832 strcat(caption, activeClient.fileName);
836 sprintf(title, "Untitled %d", activeClient.documentID);
837 strcat(caption, title);
839 if(activeClient.modifiedDocument)
840 strcat(caption, " *");
841 strcat(caption, "]");
846 // Code for returning dirty from ScrollDisplay:
848 for(d = 0; d<scrollExtent.count; d++)
850 Box * box = &scrollExtent.boxes[d];
856 Min(box.right, box.left-scroll.x),box.bottom
858 dirtyArea.UnionBox(update);
864 Max(box.left, box.right-scroll.x), box.top,
865 box.right, box.bottom
867 dirtyArea.UnionBox(update);
875 box.right, Min(box.bottom, box.top-scroll.y),
877 dirtyArea.UnionBox(update);
883 box.left, Max(box.top, box.bottom-scroll.y),
884 box.right, box.bottom
886 dirtyArea.UnionBox(update);
891 void UpdateDecorations(void)
893 // TODO: *** TEMPORARY HACK ***
900 Update({ -clientStart.x, -clientStart.y, -clientStart.x + size.w-1, 0 });
902 Update({ -clientStart.x, clientSize.h, -clientStart.x + size.w-1, -clientStart.y + size.h-1 });
904 Update({ -clientStart.x,0, -1, clientSize.h-1 });
906 Update({ clientSize.w, 0, -clientStart.x + size.w-1, clientSize.h-1 });
909 // Returns w & h for Position
910 void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
912 Window parent = this.parent ? this.parent : guiApp.desktop;
913 int vpw = parent ? parent.clientSize.w : 0;
914 int vph = parent ? parent.clientSize.h : 0;
915 int pw = parent ? parent.clientSize.w : 0;
916 int ph = parent ? parent.clientSize.h : 0;
917 int w = sizeAnchor.size.w, h = sizeAnchor.size.h;
918 int x = anchor.left.distance, y = anchor.top.distance;
920 MinMaxValue ew = 0, eh = 0;
922 float cascadeW, cascadeH;
924 int tilingW, tilingH, tilingSplit, tilingLastH;
925 int addX = 0, addY = 0;
927 if(parent && rootWindow == this && guiApp && guiApp.interfaceDriver)
929 Window masterWindow = this;
930 Box box { addX, addY, addX + vpw - 1, addY + vph - 1 };
933 if(master == guiApp.desktop)
934 masterWindow = guiApp.desktop.activeChild;
936 masterWindow = master.rootWindow;
937 if(!masterWindow) masterWindow = this;
939 guiApp.interfaceDriver.GetScreenArea(masterWindow, box);
940 if((anchor.left.type == offset && anchor.right.type == offset) || anchor.left.type == none)
943 pw = vpw = box.right - box.left + 1;
945 if((anchor.top.type == offset && anchor.bottom.type == offset) || anchor.top.type == none)
948 ph = vph = box.bottom - box.top + 1;
964 vpw = pw = parent.size.w;
965 vph = ph = parent.size.h;
967 else if(!style.fixed /*|| style.isDocument*/)
969 if(!style.dontScrollHorz && parent.scrollArea.w) vpw = parent.scrollArea.w;
970 if(!style.dontScrollVert && parent.scrollArea.h) vph = parent.scrollArea.h;
972 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
975 Desktop3D_FixSize(&pw, &ph);
976 Desktop3D_FixSize(&vpw, &vph);
979 if(pw < skinMinSize.w) pw = skinMinSize.w;
980 if(ph < skinMinSize.h) ph = skinMinSize.h;
981 if(vpw < skinMinSize.w) vpw = skinMinSize.w;
982 if(vph < skinMinSize.h) vph = skinMinSize.h;
984 // TODO: Must fix what we're snapping
989 SNAPUP(x, textCellW);
991 else if(anchor.right.type)
993 SNAPDOWN(x, textCellW);
998 SNAPUP(y, textCellH);
1000 else if(anchor.bottom.type)
1002 SNAPDOWN(y, textCellH);
1006 // This is required to get proper initial decoration size using native decorations on Windows
1007 if(nativeDecorations && guiApp && guiApp.interfaceDriver && !visible)
1008 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
1009 GetDecorationsSize(&ew, &eh);
1011 if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
1013 if(parent.sbv && !parent.sbv.style.hidden)
1014 pw += guiApp.currentSkin.VerticalSBW();
1015 if(parent.sbh && !parent.sbh.style.hidden)
1016 ph += guiApp.currentSkin.HorizontalSBH();
1018 if(anchor.left.type == cascade)
1020 w = (int)(pw * 0.80);
1021 h = (int)(ph * 0.80);
1023 else if(anchor.left.type >= vTiled)
1028 numTiling = parent.numPositions - parent.numIcons;
1029 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1030 if(anchor.left.type == vTiled)
1032 tilingH = (int)sqrt(numTiling);
1033 tilingW = numTiling / tilingH;
1037 tilingW = (int)sqrt(numTiling);
1038 tilingH = numTiling / tilingW;
1041 leftOver = numTiling - tilingH * tilingW;
1044 tilingSplit = (tilingW - leftOver) * tilingH;
1045 tilingLastH = tilingH+1;
1048 tilingSplit = numTiling;
1050 if(positionID >= tilingSplit)
1052 x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
1053 y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
1054 x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
1055 y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
1059 x = pw * (positionID / tilingH) / tilingW;
1060 y = ph * (positionID % tilingH) / tilingH;
1061 x2 = pw * (positionID / tilingH + 1) / tilingW;
1062 y2 = ph * ((positionID % tilingH) + 1) / tilingH;
1066 SNAPDOWN(x, textCellW);
1067 SNAPDOWN(y, textCellH);
1068 SNAPDOWN(x2, textCellW);
1069 SNAPDOWN(y2, textCellH);
1077 if(sizeAnchor.isClientW) w += ew;
1078 if(sizeAnchor.isClientH) h += eh;
1080 if(anchor.left.type == offset)
1081 x = anchor.left.distance;
1082 else if(anchor.left.type == relative)
1083 x = (anchor.left.percent < 0) ? ((int)(vpw * anchor.left.percent - 0.5)) : (int)(vpw * anchor.left.percent + 0.5);
1084 else if(anchor.right.type == relative)
1085 // ex = (anchor.right.percent < 0) ? ((int)(vpw * anchor.right.percent + 0)) : ((int)(vpw * anchor.right.percent + 0));
1086 ex = (anchor.right.percent < 0) ? ((int)(vpw * (1.0-anchor.right.percent) + 0)) : ((int)(vpw * (1.0-anchor.right.percent) + 0));
1087 else if(anchor.right.type == offset)
1088 ex = vpw - anchor.right.distance;
1090 if(anchor.top.type == offset)
1091 y = anchor.top.distance;
1092 else if(anchor.top.type == relative)
1093 y = (anchor.top.percent < 0) ? ((int)(vph * anchor.top.percent - 0.5)) : ((int)(vph * anchor.top.percent + 0.5));
1094 else if(anchor.bottom.type == relative)
1095 //ey = (anchor.bottom.percent < 0) ? ((int)(vph * anchor.bottom.percent + 0)) : ((int)(vph * anchor.bottom.percent + 0));
1096 ey = (anchor.bottom.percent < 0) ? ((int)(vph * (1.0-anchor.bottom.percent) + 0)) : ((int)(vph * (1.0-anchor.bottom.percent) + 0));
1097 else if(anchor.bottom.type == offset)
1098 ey = vph - anchor.bottom.distance;
1100 if(anchor.left.type && anchor.right.type)
1102 switch(anchor.right.type)
1105 ex = pw * (1.0f-anchor.right.percent);
1106 w = Max((int)(ex + 0.5) - x, 0);
1109 ex = vpw - anchor.right.distance;
1110 w = Max((int)(ex + 0.5) - x, 0);
1114 if(anchor.top.type && anchor.bottom.type)
1116 switch(anchor.bottom.type)
1119 ey = ph * (1.0f-anchor.bottom.percent);
1120 h = Max((int)(ey + 0.5) - y, 0);
1123 ey = vph - anchor.bottom.distance;
1124 h = Max((int)(ey + 0.5) - y, 0);
1133 if(state == normal /*|| state == Hidden*/)
1135 bool addSbV = false, addSbH = false;
1137 if(sizeAnchor.isClientW || (anchor.left.type && anchor.right.type)) w = Max(w, 1); else w = Max(w, 0);
1138 if(sizeAnchor.isClientH || (anchor.top.type && anchor.bottom.type)) h = Max(h, 1); else h = Max(h, 0);
1140 w = Max(w, minSize.w);
1141 h = Max(h, minSize.h);
1142 w = Min(w, maxSize.w);
1143 h = Min(h, maxSize.h);
1145 if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
1147 if(w) w -= guiApp.currentSkin.VerticalSBW();
1150 if((sizeAnchor.isClientH || !h || (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
1152 if(h) h -= guiApp.currentSkin.HorizontalSBH();
1156 if(!OnResizing(&w, &h))
1162 if((addSbV)) // || reqScrollArea.h > h) && sbv)
1163 w += guiApp.currentSkin.VerticalSBW();
1164 if((addSbH)) // || reqScrollArea.w > w) && sbh)
1165 h += guiApp.currentSkin.HorizontalSBH();
1167 w = Max(w, skinMinSize.w);
1168 h = Max(h, skinMinSize.h);
1181 SNAPDOWN(w, textCellW);
1182 SNAPDOWN(h, textCellH);
1185 if(anchor.left.type == cascade && (state == normal /*|| state == Hidden*/))
1187 if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
1190 (pw - w) / CASCADE_SPACE,
1191 (ph - h) / CASCADE_SPACE);
1197 cascW = (pw - w) / (numCascade-1);
1198 cascH = (ph - h) / (numCascade-1);
1199 SNAPDOWN(cascW, textCellW);
1200 SNAPDOWN(cascH, textCellH);
1201 cascadeW = (float)cascW;
1202 cascadeH = (float)cascH;
1206 numCascade = Max(numCascade, 2);
1207 cascadeW = (float)(pw - w) / (numCascade-1);
1208 cascadeH = (float)(ph - h) / (numCascade-1);
1211 x = (int)((positionID % numCascade) * cascadeW);
1212 y = (int)((positionID % numCascade) * cascadeH);
1214 else if(anchor.left.type < vTiled)
1216 if(!anchor.left.type || anchor.horz.type == middleRelative)
1218 if(!anchor.right.type)
1220 if(anchor.horz.type == middleRelative)
1221 x = (int)(vpw * (0.5 + anchor.horz.percent) - w / 2);
1223 x = vpw / 2 + anchor.horz.distance - w / 2;
1229 // case A_EDGE: x = x - w; break;
1231 if(!anchor.top.type || anchor.vert.type == middleRelative)
1233 if(!anchor.bottom.type)
1235 if(anchor.vert.type == middleRelative)
1236 y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
1238 y = vph / 2 + anchor.vert.distance - h / 2;
1244 // case A_EDGE: y = y - h; break;
1247 if((state == normal /*|| state == Hidden*/) && !OnMoving(&x, &y, w, h))
1255 SNAPDOWN(x, textCellW);
1256 SNAPDOWN(y, textCellH);
1268 if(anchored && style.fixed && style.isActiveClient)
1273 void UpdateCaret(bool forceUpdate, bool erase)
1275 static Window lastWindow = null;
1276 static int caretX, caretY, caretSize;
1278 if(guiApp && guiApp.caretOwner == this)
1280 int x = caretPos.x - scroll.x;
1281 int y = caretPos.y - scroll.y;
1283 if((erase || this.caretSize) &&
1284 x >= clientArea.left && x <= clientArea.right &&
1285 y >= clientArea.top && y <= clientArea.bottom)
1289 guiApp.interfaceDriver.SetCaret(
1290 x + absPosition.x + clientStart.x,
1291 y + absPosition.y + clientStart.y, this.caretSize);
1292 guiApp.caretEnabled = true;
1294 if(erase || lastWindow != this || caretX != x || caretY != y || caretSize != this.caretSize || forceUpdate)
1298 if(lastWindow != this)
1300 updateBox.left = x + 1;
1302 updateBox.right = x + 2;
1303 updateBox.bottom = y + this.caretSize - 1;
1307 updateBox.left = Min(x + 1, caretX + 1);
1308 updateBox.top = Min(y, caretY);
1309 updateBox.right = Max(x + 2, caretX + 2);
1310 updateBox.bottom = Max(y + this.caretSize - 1, caretY + caretSize - 1);
1313 guiApp.caretOwner.Update(updateBox);
1320 caretSize = this.caretSize;
1326 guiApp.interfaceDriver.SetCaret(0,0,0);
1327 guiApp.caretEnabled = false;
1333 void SetPosition(int x, int y, int w, int h, bool modifyArea, bool modifyThisArea, bool modifyClientArea)
1338 scrolledPos.x = position.x = x;
1339 scrolledPos.y = position.y = y;
1341 clientSize.w = size.w = w;
1342 clientSize.h = size.h = h;
1344 if(parent && !style.nonClient)
1346 //if(!style.fixed || style.isDocument)
1348 if(!style.dontScrollHorz) scrolledPos.x -= parent.scroll.x;
1349 if(!style.dontScrollVert) scrolledPos.y -= parent.scroll.y;
1353 clientStart.x = clientStart.y = 0;
1355 SetWindowArea(&clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1357 //if(!activeClient || activeClient.state != maximized)
1358 if(!noAutoScrollArea)
1360 // Check if scroll area must be modified
1361 if(guiApp && !guiApp.modeSwitching && (sbv || sbh))
1363 bool foundChild = false;
1365 int cw = clientSize.w;// + ((!sbv || sbv.range > 1) ? guiApp.currentSkin.VerticalSBW() : 0);
1366 int ch = clientSize.h;// + ((!sbh || sbh.rangw > 1) ? guiApp.currentSkin.HorizontalSBH() : 0);
1367 for(child = children.first; child; child = child.next)
1369 if(child.modifyVirtArea && !child.style.hidden && child.created && /*!child.anchored &&*/
1370 !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1372 if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == offset)
1373 w = Max(w, child.position.x + child.size.w);
1374 else if(child.stateAnchor.right.type == none && child.stateAnchor.left.type == none)
1375 w = Max(w, Max(child.position.x, 0) + child.size.w);
1376 if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == offset)
1377 h = Max(h, child.position.y + child.size.h);
1378 else if(child.stateAnchor.bottom.type == none && child.stateAnchor.top.type == none)
1379 h = Max(h, Max(child.position.y, 0) + child.size.h);
1384 if(foundChild && (w > cw || h > ch))
1386 //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
1388 int stepX = sbStep.x, stepY = sbStep.y;
1389 // Needed to make snapped down position match the skin's check of client area
1390 // against realvirtual
1393 SNAPDOWN(stepX, textCellW);
1394 SNAPDOWN(stepY, textCellH);
1395 stepX = Max(stepX, textCellW);
1396 stepY = Max(stepY, textCellH);
1398 if(scrollFlags.snapX)
1400 if(scrollFlags.snapY)
1403 reqScrollArea.w = w;
1404 reqScrollArea.h = h;
1407 else if(reqScrollArea.w || reqScrollArea.h)
1409 reqScrollArea.w = 0;
1410 reqScrollArea.h = 0;
1411 SetScrollPosition(0,0);
1416 // Automatic MDI Client Scrolling Area Adjustment
1417 if(parent && !parent.noAutoScrollArea)
1419 if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
1420 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
1422 Window parent = this.parent;
1423 int w = parent.reqScrollArea.w;
1424 int h = parent.reqScrollArea.h;
1426 if(stateAnchor.right.type == none && stateAnchor.left.type == offset)
1427 w = Max(w, position.x + size.w);
1428 else if(stateAnchor.right.type == none && stateAnchor.left.type == none)
1429 w = Max(w, Max(position.x, 0) + size.w);
1430 if(stateAnchor.bottom.type == none && stateAnchor.top.type == offset)
1431 h = Max(h, position.y + size.h);
1432 else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
1433 h = Max(h, Max(position.y, 0) + size.h);
1435 if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
1436 (h > parent.clientSize.h && h > parent.reqScrollArea.h))
1438 /*bool resize = false;
1439 int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
1440 // Needed to make snapped down position match the skin's check of client area
1441 // against realvirtual
1444 SNAPDOWN(stepX, textCellW);
1445 SNAPDOWN(stepY, textCellH);
1446 stepX = Max(stepX, textCellW);
1447 stepY = Max(stepY, textCellH);
1449 if(parent.scrollFlags.snapX)
1451 if(parent.scrollFlags.snapY)
1453 if(parent.reqScrollArea.w != w || parent.reqScrollArea.h != h)
1455 parent.reqScrollArea.w = w;
1456 parent.reqScrollArea.h = h;*/
1458 // parent.UpdateScrollBars(true, true);
1459 parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1460 false, true, true, true, false, false);
1465 GetRidOfVirtualArea();
1469 UpdateScrollBars(modifyThisArea, false);
1470 else if(guiApp.currentSkin)
1473 &clientStart.x, &clientStart.y, &size.w, &size.h, &clientSize.w, &clientSize.h);
1475 if(sbv && (scrollFlags.dontHide || sbv.range > 1))
1476 clientSize.w -= guiApp.currentSkin.VerticalSBW();
1477 if(sbh && (scrollFlags.dontHide || sbh.range > 1))
1478 clientSize.h -= guiApp.currentSkin.HorizontalSBH();
1481 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1482 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1484 absPosition = scrolledPos;
1485 if(guiApp && guiApp.driver != null && guiApp.interfaceDriver)
1486 guiApp.interfaceDriver.OffsetWindow(this, &absPosition.x, &absPosition.y);
1488 if(this != guiApp.desktop && parent)
1490 absPosition.x += parent.absPosition.x;
1491 absPosition.y += parent.absPosition.y;
1492 if(!style.nonClient && this != guiApp.desktop)
1494 absPosition.x += parent.clientStart.x;
1495 absPosition.y += parent.clientStart.y;
1499 box = Box { 0, 0, size.w - 1, size.h - 1 };
1504 // Clip against parent's client area
1505 box.ClipOffset(against, scrolledPos.x, scrolledPos.y);
1507 // Compute client area in this window coordinate system
1508 clientArea.left = 0;
1510 clientArea.right = clientSize.w - 1;
1511 clientArea.bottom = clientSize.h - 1;
1513 // Clip against parent's client area
1515 clientArea.ClipOffset(against, scrolledPos.x + clientStart.x, scrolledPos.y + clientStart.y);
1519 //absPosition.x -= parent.clientStart.x;
1520 //absPosition.y -= parent.clientStart.y;
1523 // Adjust all children
1524 for(child = children.first; child; child = child.next)
1525 child.SetPosition(child.position.x, child.position.y, child.size.w, child.size.h, false, true, true);
1527 UpdateCaret(false, false);
1530 void GetRidOfVirtualArea(void)
1532 if(parent && !parent.destroyed && style.fixed &&
1533 !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient &&
1534 parent.reqScrollArea.w && parent.reqScrollArea.h)
1536 if(!parent.noAutoScrollArea)
1540 for(child = children.first; child; child = child.next)
1542 if(child.modifyVirtArea && !child.style.dontScrollHorz && !child.style.dontScrollVert && !child.style.nonClient)
1544 if(child.position.x + child.size.w > parent.clientSize.w + ((!parent.sbv || parent.sbv.style.hidden) ? 0 : guiApp.currentSkin.VerticalSBW()) ||
1545 child.position.y + child.size.h > parent.clientSize.h + ((!parent.sbh || parent.sbh.style.hidden) ? 0 : guiApp.currentSkin.HorizontalSBH()))
1554 Window parent = this.parent;
1556 parent.position.x, parent.position.y, parent.size.w, parent.size.h,
1557 false, true, true, true, false, false);
1559 parent.SetScrollArea(0,0,true);
1560 parent.SetScrollPosition(0,0);
1566 public void ExternalPosition(int x, int y, int w, int h)
1568 Position(x, y, w, h, false, true, true, true, false, false);
1571 // (w, h): Full window size
1572 bool Position(int x, int y, int w, int h, bool force, bool processAnchors, bool modifyArea, bool updateScrollBars, bool thisOnly, bool changeRootWindow)
1574 bool result = false;
1575 int oldCW = clientSize.w, oldCH = clientSize.h;
1576 bool clientResized, windowResized, windowMoved;
1578 bool realResized = size.w != w || size.h != h;
1580 // TOCHECK: This wasn't in ecere.dll
1581 //if(!parent) return true;
1582 if(destroyed) return false;
1584 windowMoved = position.x != x || position.y != y || force;
1586 // windowResized = realResized || force;
1587 windowResized = size.w != w || size.h != h || force;
1589 if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
1595 scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
1596 scrolledPos.x - parent.clientStart.x + this.box.right,
1597 scrolledPos.y - parent.clientStart.y + this.box.bottom
1603 Box box { scrolledPos.x + this.box.left, scrolledPos.y + this.box.top, scrolledPos.x + this.box.right, scrolledPos.y + this.box.bottom};
1608 SetPosition(x, y, w, h, true, modifyArea, updateScrollBars);
1610 clientResized = oldCW != clientSize.w || oldCH != clientSize.h || force;
1612 if(display && rootWindow != this)
1615 if(guiApp && guiApp.windowMoving)
1617 if(guiApp.windowMoving.style.nonClient)
1618 guiApp.windowMoving.parent.SetMouseRangeToWindow();
1620 guiApp.windowMoving.parent.SetMouseRangeToClient();
1632 // Process Anchored Children
1636 for(child = children.first; child; child = child.next)
1639 ((child.stateAnchor.left.type != offset ||
1640 child.stateAnchor.top.type != offset ||
1641 child.stateAnchor.right.type != none ||
1642 child.stateAnchor.bottom.type != none) ||
1643 child.state == maximized || child.state == minimized))
1645 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor,
1647 // child.Position(x, y, w, h, false, true, true, true, false);
1648 // This must be true cuz otherwise we're gonna miss everything since we SetPosition recursively already
1649 child.Position(x, y, w, h, true, true, true, true, false, true /*false*/);
1655 // Is this gonna cause other problems? Commented out for the FileDialog end bevel bug
1656 //if(updateScrollBars)
1658 OnResize(clientSize.w, clientSize.h);
1660 if((clientResized || windowMoved) && created)
1661 OnPosition(position.x, position.y, clientSize.w, clientSize.h);
1663 if(guiApp.interimWindow && guiApp.interimWindow.master.rootWindow == this)
1665 Window master = guiApp.interimWindow.master;
1666 master.OnPosition(master.position.x, master.position.y, master.clientSize.w, master.clientSize.h);
1669 if(rootWindow == this && !is3D)
1673 x -= guiApp.desktop.absPosition.x;
1674 y -= guiApp.desktop.absPosition.y;
1676 //guiApp.Log("Position %s\n", caption);
1677 if(windowResized || windowMoved)
1678 if(display && !display.flags.memBackBuffer && changeRootWindow)
1679 guiApp.interfaceDriver.PositionRootWindow(this, x, y, w, h, windowMoved, windowResized); //realResized);
1681 if(!guiApp.fullScreenMode && this != guiApp.desktop && (windowResized || windowMoved))
1682 for(child = parent.children.first; child && child != this; child = child.next)
1683 if(child.rootWindow)
1684 guiApp.interfaceDriver.UpdateRootWindow(child.rootWindow);
1688 if(windowMoved || windowResized)
1690 display.Lock(true /*false*/);
1693 display.Position(absPosition.x, absPosition.y);
1694 //display.Position(absPosition.x + clientStart.x, absPosition.y + clientStart.y);
1697 // result = realResized ? display.Resize(size.w, size.h) : true;
1698 if(nativeDecorations)
1700 int w = clientSize.w, h = clientSize.h;
1701 if(hasMenuBar) h += skinMenuHeight;
1702 if(hasStatusBar) h += statusBarHeight;
1703 if(sbv && sbv.visible) w += sbv.size.w;
1704 if(sbh && sbh.visible) h += sbh.size.h;
1705 result = manageDisplay ? display.Resize(w, h) : true;
1708 result = manageDisplay ? display.Resize(size.w, size.h) : true;
1712 else if(clientResized)
1714 // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
1717 if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
1721 if(windowMoved || windowResized)
1726 if(guiApp.driver && changeRootWindow)
1728 if(windowResized || windowMoved)
1729 if(!display || display.flags.memBackBuffer)
1730 guiApp.interfaceDriver.PositionRootWindow(this,
1731 x, y, w, h, windowMoved, windowResized);
1732 guiApp.interfaceDriver.UpdateRootWindow(this);
1734 for(child = children.first; child; child = child.next)
1736 if(child.is3D && child.created)
1738 // Copy Display Content
1739 child.display.displaySystem = display.displaySystem;
1740 child.display.window = display.window;
1741 child.display.current = display.current;
1742 child.display.width = display.width;
1743 child.display.height = display.height;
1744 child.display.driverData = display.driverData;
1745 child.display.mutex = null;
1756 void UpdateScrollBars(bool flag, bool fullThing)
1759 bool resizeH = false, resizeV = false;
1760 bool scrolled = false;
1761 rvw = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.w;
1762 rvh = (activeChild && activeChild.state == maximized) ? 0 : reqScrollArea.h;
1764 if(destroyed) return;
1765 if(guiApp.currentSkin)
1767 MinMaxValue cw = 0, ch = 0;
1768 bool sbvVisible, sbhVisible;
1770 int positionH, positionV;
1772 // First get client area with no respect to scroll bars
1777 &clientStart.x, &clientStart.y, &size.w, &size.h, &cw, &ch);
1779 if(scrollFlags.dontHide)
1782 cw -= guiApp.currentSkin.VerticalSBW();
1784 ch -= guiApp.currentSkin.HorizontalSBH();
1786 // Update the scrollbar visibility
1792 sbh.disabled = rangeH <= 1;
1793 if(sbh.style.hidden)
1803 sbv.disabled = rangeV <= 1;
1804 if(sbv.style.hidden)
1812 // Then start off with horizontal scrollbar range
1815 positionH = sbh.thumbPosition;
1820 ch -= guiApp.currentSkin.HorizontalSBH();
1823 // Do the same for vertical scrollbar
1826 positionV = sbv.thumbPosition;
1832 cw -= guiApp.currentSkin.VerticalSBW();
1833 // Maybe we need to set the range on the horizontal scrollbar again
1838 sbh.Action(setRange, positionH, 0);
1839 if(rangeH <= 1 && sbh.range > 1)
1841 ch -= guiApp.currentSkin.HorizontalSBH();
1845 sbv.Action(setRange, positionV, 0);
1852 // Update the scrollbar visibility
1853 if(!scrollFlags.dontHide)
1855 if(sbh && ((rangeH <= 1 && !sbh.style.hidden) || (rangeH > 1 && sbh.style.hidden)))
1859 if(sbv && ((rangeV <= 1 && !sbv.style.hidden) || (rangeV > 1 && sbv.style.hidden)))
1866 if(guiApp.currentSkin)
1873 sbhVisible = sbh.style.hidden ? true : false;
1875 sbvVisible = sbv.style.hidden ? true : false;
1877 // Do our resize here
1878 if(flag && (resizeH || resizeV) && fullThing)
1880 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
1885 OnResize(clientSize.w, clientSize.h);
1891 sbh.visible = sbhVisible;
1893 sbv.visible = sbvVisible;
1895 scrollArea.w = Max(clientSize.w, reqScrollArea.w);
1896 scrollArea.h = Max(clientSize.h, reqScrollArea.h);
1899 sbh.pageStep = clientSize.w;
1901 sbv.pageStep = clientSize.h;
1903 // Notify doesn't handle setRange anymore... process it here
1906 int positionH = sbh.thumbPosition;
1907 if(scroll.x != positionH)
1909 OnHScroll(setRange, positionH, 0);
1913 SNAPDOWN(positionH, textCellW);
1914 scroll.x = positionH;
1920 int seen = clientSize.w, total = reqScrollArea.w;
1923 if(scrollFlags.snapX)
1924 SNAPDOWN(seen, sbStep.x);
1926 if(!total) total = seen;
1927 range = total - seen + 1;
1929 range = Max(range, 1);
1931 if(x >= range) x = range - 1;
1933 if(scrollFlags.snapX)
1934 SNAPUP(x, sbStep.x);
1938 OnHScroll(setRange, x, 0);
1943 SNAPDOWN(x, textCellW);
1949 int positionV = sbv.thumbPosition;
1950 if(scroll.y != positionV)
1952 OnVScroll(setRange, positionV, 0);
1956 SNAPDOWN(positionV, textCellH);
1957 scroll.y = positionV;
1963 int seen = clientSize.h, total = reqScrollArea.h;
1966 if(scrollFlags.snapY)
1967 SNAPDOWN(seen, sbStep.y);
1969 if(!total) total = seen;
1970 range = total - seen + 1;
1971 range = Max(range, 1);
1973 if(y >= range) y = range - 1;
1975 if(scrollFlags.snapY)
1976 SNAPUP(y, sbStep.y);
1980 OnVScroll(setRange, y, 0);
1985 SNAPDOWN(y, textCellH);
1991 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
1994 for(child = children.first; child; child = child.next)
1996 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
1999 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2000 child.Position(x, y, w, h, false, true, false, true, false, false);
2007 // Process Scrollbars
2009 if(sbh) // && !sbh.style.hidden
2011 sbh.Move(clientStart.x, clientStart.y + clientSize.h, clientSize.w,0);
2012 // Need to set the range again (should improve...) since the scrollbars didn't have
2013 // the right size when UpdateScrollArea set the range on it
2016 sbh.seen = clientSize.w;
2020 if(sbv) // && !sbv.state.hidden
2022 sbv.Move(clientStart.x + clientSize.w, clientStart.y, 0, clientSize.h);
2023 // Need to set the range again (should improve...) since the scrollbars didn't have
2024 // the right size when UpdateScrollArea set the range on it
2027 sbv.seen = clientSize.h;
2032 // TESTING THIS LOWER
2033 if(scrolled || (resizeH || resizeV)) // This ensures children anchored to bottom/right gets repositioned correctly
2036 for(child = children.first; child; child = child.next)
2038 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2041 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2042 child.Position(x, y, w, h, false, true, false, true, false, false);
2048 bool MaximizeButtonClicked(Button button, int x, int y, Modifiers mods)
2050 SetState(maximized, false, mods);
2054 bool RestoreButtonClicked(Button button, int x, int y, Modifiers mods)
2056 SetState(normal, false, mods);
2060 bool MinimizeButtonClicked(Button button, int x, int y, Modifiers mods)
2062 SetState(minimized, false, mods);
2063 parent.CycleChildren(false, true, false, true);
2067 void ScrollBarNotification(ScrollBar control, ScrollBarAction action, int position, Key keyFlags)
2070 // Scroll bar notifications
2071 if(action != setRange)
2073 bool changed = false;
2077 if(scroll.x != position)
2079 OnHScroll(action, position, keyFlags);
2084 SNAPDOWN(position, textCellW);
2086 scroll.x = position;
2090 if(scroll.y != position)
2092 OnVScroll(action, position, keyFlags);
2097 SNAPDOWN(position, textCellH);
2099 scroll.y = position;
2103 bool childMove = false;
2104 for(child = children.first; child; child = child.next)
2106 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2109 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
2110 child.Position(x, y, w, h, false, true, false, true, false, false);
2114 // Testing this patch out to solve MDI workspace redraw bugs
2115 // We were already supposed to be updating parent's affected area in Position() but it doesn't seem to be working
2116 // Scroll offsets to blame?
2120 UpdateCaret(false, false);
2124 // Testing this patch out to solve MDI workspace redraw bugs
2125 for(child = children.first; child; child = child.next)
2127 if(!child.style.nonClient && child.state != maximized && (!child.style.dontScrollHorz || !child.style.dontScrollVert))
2136 void CreateSystemChildren(void)
2138 Window parent = this;
2139 bool scrollBarChanged = false;
2140 bool hasClose = false, hasMaxMin = false;
2141 Point scroll = this.scroll;
2143 if(state == maximized && this.parent.menuBar)
2145 if(this.parent.activeClient == this)
2146 parent = this.parent.menuBar;
2153 if(style.hasClose) hasClose = true;
2154 if(style.hasMaximize || style.hasMinimize)
2161 if(sysButtons[2] && (!hasClose || sysButtons[2].parent != parent))
2163 sysButtons[2].Destroy(0);
2164 sysButtons[2] = null;
2166 if(sysButtons[1] && (!hasMaxMin || sysButtons[1].parent != parent))
2168 sysButtons[1].Destroy(0);
2169 sysButtons[1] = null;
2171 if(sysButtons[0] && (!hasMaxMin || sysButtons[0].parent != parent))
2173 sysButtons[0].Destroy(0);
2174 sysButtons[0] = null;
2177 if(hasClose && parent)
2184 parent, master = this,
2185 inactive = true, nonClient = true, visible = false;
2187 bool NotifyClicked(Button button, int x, int y, Modifiers mods)
2193 if(this.parent == guiApp.desktop)
2194 sysButtons[2].hotKey = altF4;
2195 else if(style.isActiveClient)
2196 sysButtons[2].hotKey = ctrlF4;
2197 sysButtons[2].Create();
2200 sysButtons[2].symbol = 'X';
2201 sysButtons[2].disabled = !style.hasClose;
2204 if(hasMaxMin && parent)
2208 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2209 if(state == maximized)
2212 method = RestoreButtonClicked;
2218 method = MaximizeButtonClicked;
2226 parent, master = this,
2227 hotKey = altEnter, inactive = true, nonClient = true, visible = false
2229 sysButtons[1].Create();
2231 sysButtons[1].NotifyClicked = method;
2233 sysButtons[1].symbol = symbol;
2234 sysButtons[1].disabled = !style.hasMaximize;
2237 if(hasMaxMin && parent)
2241 bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
2242 if (state == minimized)
2245 method = RestoreButtonClicked;
2251 method = MinimizeButtonClicked;
2259 parent, master = this,
2260 hotKey = altM, inactive = true, nonClient = true, visible = false
2262 sysButtons[0].Create();
2264 sysButtons[0].NotifyClicked = method;
2266 sysButtons[0].symbol = symbol;
2267 sysButtons[0].disabled = !style.hasMinimize;
2270 // Create the scrollbars
2271 if(style.hasHorzScroll && !sbh)
2277 direction = horizontal,
2281 snap = scrollFlags.snapX,
2282 NotifyScrolling = ScrollBarNotification
2285 scrollBarChanged = true;
2287 else if(sbh && !style.hasHorzScroll)
2293 if(style.hasVertScroll && !sbv)
2299 direction = vertical,
2303 snap = scrollFlags.snapY,
2304 NotifyScrolling = ScrollBarNotification
2307 scrollBarChanged = true;
2309 else if(sbv && !style.hasVertScroll)
2314 if(scrollBarChanged)
2316 SetScrollLineStep(sbStep.x, sbStep.y);
2317 UpdateScrollBars(true, true);
2321 if(scrollBarChanged)
2323 if(sbh) sbh.thumbPosition = scroll.x;
2324 if(sbv) sbv.thumbPosition = scroll.y;
2328 void UpdateCaption(void)
2330 if(rootWindow == this)
2333 FigureCaption(caption);
2334 guiApp.interfaceDriver.SetRootWindowCaption(this, caption);
2336 UpdateDecorations();
2339 if(parent.rootWindow == parent && parent.activeClient == this) // Added this last check
2342 parent.FigureCaption(caption);
2343 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
2345 parent.UpdateDecorations();
2349 void UpdateActiveDocument(Window previous)
2351 Window activeClient = this.activeClient;
2352 Window activeChild = this.activeChild;
2359 activeClient.CreateSystemChildren();
2361 previous.CreateSystemChildren();
2372 if(activeClient && activeClient.menu && activeClient.state != minimized)
2376 //activeClient.menu.Clean(activeClient);
2377 menu.Merge(activeClient.menu, true, activeClient);
2381 if(activeChild && activeChild != activeClient && activeChild.menu && activeChild.state != minimized)
2384 menu.Merge(activeChild.menu, true, activeChild);
2387 // Build window list
2390 Menu windowMenu = menu.FindMenu("Window");
2395 for(id = 0, cycle = activeClient.cycle; cycle && id<10;)
2398 Window document = cycle.data;
2399 if(!document.style.nonClient && document.style.isActiveClient)
2401 char name[2048], caption[2048];
2402 document.FigureCaption(caption);
2403 sprintf(name, "%d %s", id+1, caption);
2404 windowMenu.AddDynamic(MenuItem
2406 copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
2407 NotifySelect = MenuWindowSelectWindow
2411 if(activeClient.cycle == cycle) break;
2416 if((!previous && activeClient) || !activeClient)
2422 item = menu.FindItem(MenuWindowCloseAll, 0);
2423 if(item) item.disabled = false;
2424 item = menu.FindItem(MenuWindowNext, 0);
2425 if(item) item.disabled = false;
2426 item = menu.FindItem(MenuWindowPrevious, 0);
2427 if(item) item.disabled = false;
2428 item = menu.FindItem(MenuWindowCascade, 0);
2429 if(item) item.disabled = false;
2430 item = menu.FindItem(MenuWindowTileHorz, 0);
2431 if(item) item.disabled = false;
2432 item = menu.FindItem(MenuWindowTileVert, 0);
2433 if(item) item.disabled = false;
2434 item = menu.FindItem(MenuWindowArrangeIcons, 0);
2435 if(item) item.disabled = false;
2436 item = menu.FindItem(MenuWindowWindows, 0);
2437 if(item) item.disabled = false;
2440 item = menu.FindItem(MenuFileClose, 0);
2441 if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
2442 item = menu.FindItem(MenuFileSaveAll, 0);
2443 if(item) item.disabled = numDocuments < 1;
2445 // This is called again for a child window change, with same active client
2446 OnActivateClient(activeClient, previous);
2449 void _ShowDecorations(Box box, bool post)
2451 if(rootWindow == this && nativeDecorations) return;
2452 if(visible && this != guiApp.desktop)
2454 Surface surface = RedrawFull(box);
2458 FigureCaption(caption);
2461 ShowDecorations(captionFont.font,
2464 active, //parent.activeClient == this
2465 guiApp.windowMoving == this);
2467 PreShowDecorations(captionFont.font,
2470 active, //parent.activeClient == this
2471 guiApp.windowMoving == this);
2478 void UpdateExtent(Box refresh)
2480 Surface surface = null;
2482 if(!manageDisplay) { OnRedraw(null);return; }
2483 _ShowDecorations(refresh, false);
2485 surface = Redraw(refresh);
2486 // Opaque background: just fill before EW_REDRAW (clear?)
2489 surface.SetBackground(background);
2490 surface.SetForeground(foreground);
2491 surface.DrawingChar(' ');
2492 if(this == rootWindow)
2494 if(style.drawBehind || background.a)
2495 surface.Clear(colorBuffer);
2497 else if(background.a)
2501 background.color = { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2502 surface.SetForeground((background.color.r > 128 || background.color.g > 128) ? black : white);
2505 if(display.flags.alpha && background.a < 255 && background)
2507 surface.Area(0,0,clientSize.w, clientSize.h);
2508 /*if(style.clearDepthBuffer)
2509 surface.Clear(depthBuffer);*/
2511 else if(/*style.clearDepthBuffer || */background.a)
2513 // surface.Clear((style.clearDepthBuffer ? depthBuffer : 0) | (background.a ? colorBuffer : 0));
2514 surface.Clear(colorBuffer);
2519 surface.TextFont(usedFont.font);
2520 surface.TextOpacity(false);
2524 // Draw the caret ...
2525 if(!disabled && this == guiApp.caretOwner && guiApp.caretEnabled /*&& !guiApp.interimWindow*/ && !guiApp.currentSkin.textMode)
2527 // surface.SetBackground(0xFFFFFF - background.color);
2528 surface.SetBackground(~background.color);
2530 caretPos.x - scroll.x + 1, caretPos.y - scroll.y,
2531 caretPos.x - scroll.x + 2, caretPos.y - scroll.y + caretSize - 1);
2537 void DrawOverChildren(Box refresh)
2539 Surface surface = Redraw(refresh);
2543 surface.DrawingChar(' ');
2544 surface.SetBackground(background);
2545 surface.SetForeground(foreground);
2547 surface.TextFont(usedFont.font);
2548 surface.TextOpacity(false);
2550 OnDrawOverChildren(surface);
2555 _ShowDecorations(refresh, true);
2558 void ComputeClipExtents(void)
2561 Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
2563 clipExtent.Copy(this.clipExtent);
2565 for(child = children.last; child; child = child.prev)
2567 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2569 bool opaque = child.IsOpaque(); // TODO: acess background directly
2570 int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
2572 child.clipExtent.Copy(clipExtent);
2573 child.clipExtent.Offset(-dx, -dy);
2574 child.clipExtent.IntersectBox(child.box);
2576 child.ComputeClipExtents();
2578 if(opaque && !child.style.nonClient)
2580 // Adjust the box for the parent:
2581 Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
2582 clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
2587 // ??? Only do this for overlapped window or if parent has with clip children flag
2589 // Do this if window has clip children flag on (default false?)
2590 // this.clipExtent = clipExtent;
2592 clipExtent.Free(null);
2595 void ComputeRenderAreaNonOpaque(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2597 bool opaque = IsOpaque();
2599 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2600 if(rootWindow.nativeDecorations)
2602 offsetX -= rootWindow.clientStart.x;
2603 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2607 for(child = children.last; child; child = child.prev)
2609 ColorAlpha background = *(ColorAlpha *)&child.background;
2610 bool opaque = child.IsOpaque();
2611 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2615 // Adjust renderArea to the root window level
2616 Extent * renderArea = &rootWindow.tempExtents[1];
2618 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2619 if(child.rootWindow.nativeDecorations)
2621 offsetX -= child.rootWindow.clientStart.x;
2622 offsetY -= child.rootWindow.clientStart.y - (child.rootWindow.hasMenuBar ? skinMenuHeight : 0);
2626 Extent childRenderArea;
2628 if(backBufferUpdate != null)
2630 childRenderArea.Copy(backBufferUpdate);
2631 childRenderArea.Offset(-offsetX, -offsetY);
2634 childRenderArea.Copy(child.dirtyArea);
2636 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2637 renderArea.Copy(dirtyExtent);
2638 renderArea.Offset(-offsetX, -offsetY);
2639 childRenderArea.Union(renderArea);
2642 // Intersect with the clip extent
2643 childRenderArea.Intersection(child.clipExtent);
2646 renderArea->Copy(child.dirtyArea /*childRenderArea*/);
2647 renderArea->Offset(offsetX, offsetY);
2648 dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2649 // overDirtyExtent.Union(renderArea);
2650 renderArea->Empty();
2651 // childRenderArea.Free();
2653 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2658 for(child = children.last; child; child = child.prev)
2660 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2662 child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2667 void ComputeRenderArea(Extent dirtyExtent, Extent overDirtyExtent, Extent backBufferUpdate)
2669 bool opaque = IsOpaque();
2670 Extent * dirtyExtentWindow = &rootWindow.tempExtents[1];
2672 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2673 if(rootWindow.nativeDecorations)
2675 offsetX -= rootWindow.clientStart.x;
2676 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2680 for(child = children.last; child; child = child.prev)
2682 //child.ComputeRenderAreaNonOpaque(dirtyExtent, overDirtyExtent, backBufferUpdate);
2684 ColorAlpha background = *(ColorAlpha *)&child.background;
2685 bool opaque = child.IsOpaque();
2686 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2690 int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
2691 // Adjust renderArea to the root window level
2693 renderArea.Copy(child.dirtyArea);
2694 renderArea.Offset(offsetX, offsetY);
2695 dirtyExtent.Union(renderArea);
2696 overDirtyExtent.Union(renderArea);
2702 for(child = children.last; child; child = child.prev)
2704 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
2706 child.ComputeRenderArea(dirtyExtent, overDirtyExtent, backBufferUpdate);
2710 if(backBufferUpdate != null)
2712 renderArea.Copy(backBufferUpdate);
2713 renderArea.Offset(-offsetX, -offsetY);
2715 overRenderArea.Copy(backBufferUpdate);
2716 overRenderArea.Offset(-offsetX, -offsetY);
2722 renderArea.Copy(dirtyArea);
2724 overRenderArea.Copy(dirtyArea);
2727 // Add extent forced by transparency to the dirty area, adjusting dirty extent to the window
2728 dirtyExtentWindow->Copy(dirtyExtent);
2729 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2730 renderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2731 dirtyExtentWindow->Empty();
2733 // Intersect with the clip extent
2734 renderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2737 if(renderArea.count > 10)
2740 printf("\nToo many extents (%d):\n", renderArea.count);
2742 //extent.UnionBox({ 112, 6, 304, 7 }, rootWindow.tempExtents[0]);
2743 //extent.UnionBox({ 112, 8, 304, 17 }, rootWindow.tempExtents[0]);
2748 for(c = 0; c<10; c++)
2751 FASTLIST_LOOP(renderArea, extentBox)
2753 extent.UnionBox(extentBox.box, rootWindow.tempExtents[0]);
2755 renderArea.Copy(extent);
2757 FASTLIST_LOOP(renderArea, extentBox)
2760 printf("(%d, %d) - (%d, %d)\n",
2761 extentBox.box.left, extentBox.box.top,
2762 extentBox.box.right, extentBox.box.bottom);
2766 printf("\nNow %d\n", renderArea.count);
2772 // WHY WAS THIS COMMENTED ??
2774 // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
2775 dirtyExtentWindow->Copy(overDirtyExtent);
2776 dirtyExtentWindow->Offset(-offsetX, -offsetY);
2777 overRenderArea.Union(dirtyExtentWindow, rootWindow.tempExtents[0]);
2778 dirtyExtentWindow->Empty();
2780 // Intersect with the clip extent
2781 overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2787 if(scrollExtent.count)
2789 // Subtract render extent from scrolling extent
2790 scrollExtent.Exclusion(renderArea, rootWindow.tempExtents[0]);
2792 if(backBufferUpdate == null)
2794 Extent * dirty = &rootWindow.tempExtents[3];
2797 // Intersect scrolling extent with clip extent
2798 scrollExtent.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
2800 // offset this scroll to be at the root window level
2801 scrollExtent.Offset(offsetX, offsetY);
2802 // Add area that was scrolled to the dirty extents of the back buffer
2803 rootWindow.dirtyBack.Union(scrollExtent, rootWindow.tempExtents[0]);
2807 // Will need scrolledArea.x & scrolledArea.y to support multiple scrolls
2808 FASTLIST_LOOP(scrollExtent, scrollBox)
2809 display.Scroll(scrollBox.box, scrolledArea.x, scrolledArea.y, dirty);
2814 scrollExtent.Empty();
2816 // Add the exposed extent to the window render area
2817 dirty->Offset(-offsetX, -offsetY);
2818 renderArea.Union(dirty, rootWindow.tempExtents[0]);
2823 // Subtract the window's box from the transparency forced extent
2824 dirtyExtent.ExcludeBox({box.left + offsetX, box.top + offsetY, box.right + offsetX, box.bottom + offsetY }, rootWindow.tempExtents[0]);
2830 renderArea.Copy(this.renderArea);
2831 renderArea.Offset(offsetX, offsetY);
2832 dirtyExtent.Union(renderArea);
2838 Extent renderArea { };
2840 renderArea.Copy(overRenderArea);
2841 renderArea.Offset(offsetX, offsetY);
2842 overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
2847 if(backBufferUpdate != null)
2849 // Remove render area from dirty area
2850 dirtyArea.Exclusion(renderArea, rootWindow.tempExtents[0]);
2852 dirtyArea.Exclusion(overRenderArea, rootWindow.tempExtents[0]);
2859 // Remove the window render area from the dirty extents of the back buffer
2860 rootWindow.dirtyBack.Exclusion(renderArea);
2864 void Render(Extent updateExtent)
2868 Window rootWindow = this.rootWindow;
2869 int offsetX = absPosition.x - rootWindow.absPosition.x, offsetY = absPosition.y - rootWindow.absPosition.y;
2870 if(rootWindow.nativeDecorations)
2872 offsetX -= rootWindow.clientStart.x;
2873 offsetY -= rootWindow.clientStart.y - (rootWindow.hasMenuBar ? skinMenuHeight : 0);
2876 if(rootWindow.fullRender)
2885 background = Color { (byte)GetRandom(0,255), (byte)GetRandom(0,255), (byte)GetRandom(0,255) };
2886 foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
2891 /*if(renderArea.count)
2892 printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
2895 FASTLIST_LOOP(renderArea, extentBox)
2897 Box box = extentBox.box;
2900 /*printf("(%d, %d) - (%d, %d)\n",
2901 extentBox.box.left, extentBox.box.top,
2902 extentBox.box.right, extentBox.box.bottom);*/
2907 box.left += offsetX;
2909 box.right += offsetX;
2910 box.bottom += offsetY;
2912 if(updateExtent != null)
2913 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2917 for(child = children.first; child; child = child.next)
2918 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && !child.nonClient)
2919 child.Render(updateExtent);
2921 if(rootWindow.fullRender)
2922 DrawOverChildren(box);
2925 // TO DO: There's an issue about draw over children...
2926 // TO DO: Don't wanna go through this if method isn't used
2927 FASTLIST_LOOP(/*renderArea */overRenderArea, extentBox)
2929 Box box = extentBox.box;
2931 DrawOverChildren(box);
2933 box.left += offsetX;
2935 box.right += offsetX;
2936 box.bottom += offsetY;
2938 if(updateExtent != null)
2939 updateExtent.UnionBox(box, rootWindow.tempExtents[0]);
2942 for(child = children.first; child; child = child.next)
2943 if(!child.style.hidden && child.created && !child.is3D && child.rootWindow && child.nonClient)
2944 child.Render(updateExtent);
2947 overRenderArea.Empty();
2950 public void UpdateDisplay(void)
2952 if(!manageDisplay) { OnRedraw(null);return; }
2953 if(rootWindow && this != rootWindow)
2954 rootWindow.UpdateDisplay();
2957 Extent dirtyExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be forced due to transparency
2958 Extent overExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that forced for DrawOverChildren
2961 dirtyExtent.Clear();
2964 clipExtent.AddBox(box);
2966 display.StartUpdate();
2968 if(!rootWindow.fullRender)
2970 ComputeClipExtents();
2971 ComputeRenderAreaNonOpaque(dirtyExtent, overExtent, null);
2972 ComputeRenderArea(dirtyExtent, overExtent, null);
2975 clipExtent.Free(null);
2977 dirtyExtent.Free(null);
2978 overExtent.Free(null);
2980 if(display.flags.flipping)
2983 display.Update(null);
2987 Extent updateExtent { /*first = -1, last = -1, free = -1*/ }; // Extent that needs to be updated
2988 updateExtent.Clear();
2990 Render(updateExtent);
2992 updateExtent.UnionBox(this.box, tempExtents[0]);
2995 //printf("\n\nUpdate:\n------------------------------------------\n");
2998 FASTLIST_LOOP(updateExtent, extentBox)
3001 /*printf("Updating (%d, %d) - (%d, %d)\n",
3002 extentBox.box.left, extentBox.box.top,
3003 extentBox.box.right, extentBox.box.bottom);*/
3006 display.Update(extentBox.box);
3009 updateExtent.Free(null);
3012 display.EndUpdate();
3020 void UpdateBackDisplay(Box box)
3026 Extent intersection { /*first = -1, last = -1, free = -1*/ };
3028 //printf("UpdateBackDisplay going through!\n");
3029 display.StartUpdate();
3033 intersection.Copy(dirtyBack);
3034 intersection.IntersectBox(box);
3036 dirtyExtent.Clear();
3039 clipExtent.AddBox(box);
3041 if(!rootWindow.fullRender)
3043 ComputeClipExtents();
3044 ComputeRenderArea(dirtyExtent, overExtent, intersection);
3047 clipExtent.Free(null);
3049 intersection.Free(null);
3050 dirtyExtent.Free(null);
3051 overExtent.Free(null);
3056 if(display.flags.flipping)
3057 display.Update(null);
3060 rootWindow.display.Update(box);
3063 display.EndUpdate();
3067 dirtyBack.ExcludeBox(box, rootWindow.tempExtents[0]);
3068 if(dirtyBack.count > MAX_DIRTY_BACK)
3070 BoxItem extentBox, next;
3071 BoxItem first = (BoxItem)ACCESS_ITEM(dirtyBack, dirtyBack.first);
3072 FASTLIST_LOOPN(dirtyBack, extentBox, next)
3074 if(extentBox != first)
3076 if(extentBox.box.left < first.box.left)
3077 first.box.left = extentBox.box.left;
3078 if(extentBox.box.top < first.box.top)
3079 first.box.top = extentBox.box.top;
3080 if(extentBox.box.right > first.box.right)
3081 first.box.right = extentBox.box.right;
3082 if(extentBox.box.bottom > first.box.bottom)
3083 first.box.bottom = extentBox.box.bottom;
3084 dirtyBack.Delete(extentBox);
3093 // --- Window positioning ---
3094 // --- Window identification ---
3096 // Returns window at position "Position"
3097 Window GetAtPosition(int x, int y, bool clickThru, bool acceptDisabled, Window last)
3099 Window child, result = null;
3101 box.left += absPosition.x;
3102 box.right += absPosition.x;
3103 box.top += absPosition.y;
3104 box.bottom += absPosition.y;
3106 if(!destroyed && visible && (acceptDisabled || !disabled))
3108 int lx = x - absPosition.x;
3109 int ly = y - absPosition.y;
3110 if(IsInside(lx, ly))
3111 // if(box.IsPointInside(Point{x, y}))
3113 if(!clickThru || !style.clickThrough) result = (this == last) ? null : this;
3114 // If the window is disabled, stop looking in children (for acceptDisabled mode)
3117 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3119 if(child != statusBar && child.rootWindow == rootWindow)
3121 Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
3128 for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
3130 if(child != statusBar && child.rootWindow == rootWindow)
3132 Window childResult = child.GetAtPosition(x, y, false, acceptDisabled, last);
3144 Window FindModal(void)
3146 Window modalWindow = this, check;
3147 Window check2 = null;
3148 for(check = this; check.master; check = check.master)
3150 if(check.master.modalSlave && check.master.modalSlave.created && check != check.master.modalSlave)
3152 modalWindow = check.master.modalSlave;
3153 check = modalWindow;
3155 // TESTING THIS FOR DROPBOX...
3156 if(!rootWindow || !rootWindow.style.interim)
3158 for(check2 = check; check2.activeChild; check2 = check2.activeChild)
3160 if(check2.modalSlave && check2.modalSlave.created)
3162 modalWindow = check2.modalSlave;
3170 if(modalWindow == this)
3172 for(check = this; check.activeChild; check = check.activeChild)
3174 if(check.modalSlave)
3176 modalWindow = check.modalSlave;
3182 for(; modalWindow.modalSlave && modalWindow.modalSlave.created; modalWindow = modalWindow.modalSlave);
3183 return (modalWindow == this || this == guiApp.interimWindow || IsDescendantOf(modalWindow)) ? null : modalWindow;
3186 void StopMoving(void)
3188 if(this == guiApp.windowMoving)
3190 guiApp.windowMoving = null;
3191 UpdateDecorations();
3192 SetMouseRange(null);
3195 if(rootWindow.active)
3196 guiApp.interfaceDriver.StopMoving(rootWindow);
3199 guiApp.resizeX = guiApp.resizeY = guiApp.resizeEndX = guiApp.resizeEndY = false;
3200 guiApp.windowIsResizing = false;
3204 void SelectMouseCursor(void)
3209 Window cursorWindow = null;
3210 bool rx, ry, rex, rey;
3212 guiApp.desktop.GetMousePosition(&x, &y);
3213 mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
3215 if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
3216 guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
3217 else if(mouseWindow)
3219 modalWindow = mouseWindow.FindModal();
3220 x -= mouseWindow.absPosition.x;
3221 y -= mouseWindow.absPosition.y;
3222 if(guiApp.windowIsResizing)
3224 rex = guiApp.resizeEndX;
3225 rey = guiApp.resizeEndY;
3226 rx = guiApp.resizeX;
3227 ry = guiApp.resizeY;
3228 if((rex && rey) || (rx && ry))
3229 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3230 else if((rex && ry) || (rx && rey))
3231 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3232 else if((ry || rey) && (!rx && !rex))
3233 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3234 else if((rx || rex) && (!ry && !rey))
3235 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3237 else if(!modalWindow && !guiApp.windowCaptured &&
3238 mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
3239 &rx, &ry, &rex, &rey))
3241 if((rex && rey) || (rx && ry))
3242 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
3243 else if((rex && ry) || (rx && rey))
3244 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
3245 else if((ry || rey) && (!rx && !rex))
3246 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
3247 else if((rx || rex) && (!ry && !rey))
3248 guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
3250 else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
3252 if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
3253 cursorWindow = mouseWindow.parent;
3255 cursorWindow = mouseWindow;
3257 else if(!guiApp.interimWindow)
3258 cursorWindow = guiApp.windowCaptured;
3261 for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
3262 guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
3264 else if(modalWindow)
3266 guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
3268 else if(guiApp.interimWindow)
3270 if(guiApp.interimWindow.cursor)
3271 guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
3273 guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
3278 // --- State based input ---
3279 bool AcquireInputEx(bool state)
3284 guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
3285 guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
3287 result = guiApp.interfaceDriver.AcquireInput(rootWindow, state);
3289 guiApp.acquiredWindow = state ? this : null;
3292 SetMouseRangeToClient();
3293 guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
3298 SelectMouseCursor();
3300 if(!state) guiApp.interfaceDriver.SetMousePosition(guiApp.acquiredMouseX, guiApp.acquiredMouseY);
3304 // --- Window activation ---
3305 bool PropagateActive(bool active, Window previous, bool * goOnWithActivation, bool direct)
3308 if(!parent || !parent.style.inactive)
3310 Window parent = this.parent;
3313 if(rootWindow == this)
3314 Log(active ? "active\n" : "inactive\n");
3317 // Testing this here...
3318 if(!parent || parent == guiApp.desktop || parent.active)
3320 this.active = active;
3323 // TESTING THIS HERE
3324 UpdateDecorations();
3325 if(result = OnActivate(active, previous, goOnWithActivation, direct) && *goOnWithActivation && master)
3326 result = NotifyActivate(master, this, active, previous);
3329 this.active = !active;
3334 if(!parent || parent == guiApp.desktop || parent.active)
3336 this.active = active;
3338 AcquireInputEx(active);
3343 if(guiApp.caretOwner)
3347 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
3348 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
3349 guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
3350 guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
3352 guiApp.caretOwner.Update(extent);
3355 if(visible || !guiApp.caretOwner)
3356 guiApp.caretOwner = this;
3357 UpdateCaret(false, false);
3363 this.active = false;
3365 AcquireInputEx(active);
3367 if(!active && guiApp.caretOwner == this)
3369 UpdateCaret(false, true);
3370 guiApp.caretOwner = null;
3371 guiApp.interfaceDriver.SetCaret(0,0,0);
3372 guiApp.caretEnabled = false;
3377 if(!active && parent && parent.activeChild && parent.activeChild != this)
3378 if(!parent.activeChild.PropagateActive(false, previous, goOnWithActivation, true) || !*goOnWithActivation)
3384 if(!active && menuBar)
3387 menuBar.OnActivate(false, null, &goOn, true);
3388 menuBar.NotifyActivate(menuBar.master, menuBar, false, null);
3392 if(!activeChild.PropagateActive(active, previous, goOnWithActivation, false) || !*goOnWithActivation)
3401 void ConsequentialMouseMove(bool kbMoving)
3405 if(kbMoving || !guiApp.windowMoving)
3409 if(rootWindow == guiApp.desktop || rootWindow.parent == guiApp.desktop)
3411 guiApp.interfaceDriver.GetMousePosition(&x, &y);
3413 if(guiApp.windowMoving || rootWindow.GetAtPosition(x, y, true, false, null))
3414 rootWindow.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &mods, true, false);
3420 bool IsDescendantOf(Window ancestor)
3423 for(window = this; window && window != ancestor; window = window.parent);
3424 return window == ancestor;
3427 bool IsSlaveOf(Window master)
3430 for(window = this; window && window != master; window = window.master);
3431 return window == master;
3434 bool ActivateEx(bool active, bool activateParent, bool moveInactive, bool activateRoot, Window external, Window externalSwap)
3438 if(this && !destroyed /*&& state != Hidden*/)
3440 Window swap = externalSwap;
3448 if(activateParent &&
3449 (parent.activeChild != this ||
3450 (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
3451 active && style.modal &&
3452 parent != master && master)
3453 master.ActivateEx(true, true, false, activateRoot, external, externalSwap);
3459 bool real = parent.activeChild != this;
3461 // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
3462 if(/*activateParent && */guiApp.interimWindow &&
3463 !IsDescendantOf(guiApp.interimWindow) &&
3464 !IsSlaveOf(guiApp.interimWindow))
3466 Window interimWindow = guiApp.interimWindow;
3467 while(interimWindow && interimWindow != this)
3469 Window master = interimWindow.master;
3471 guiApp.interimWindow = null;
3472 if(guiApp.caretOwner)
3473 guiApp.caretOwner.UpdateCaret(false, false);
3475 incref interimWindow;
3476 if(!interimWindow.PropagateActive(false, this, &goOn, true))
3481 delete interimWindow;
3482 interimWindow = (master && master.style.interim) ? master : null;
3487 guiApp.interimWindow = this;
3488 /*guiApp.interfaceDriver.SetCaret(0,0,0);
3489 guiApp.caretEnabled = false;*/
3490 UpdateCaret(false, true);
3495 bool acquireInput = false;
3497 parent.activeChild &&
3498 parent.activeChild.state == maximized &&
3499 parent != guiApp.desktop;
3501 if(!style.inactive) // (!style.isRemote || parent.active || parent.style.hidden))
3506 swap = parent.activeChild;
3507 if(swap && swap.destroyed) swap = null;
3508 if(swap && swap != this)
3511 if(!swap.PropagateActive(false, this, &goOn, true))
3512 swap = parent.activeChild;
3523 if(!parent || parent.activeChild != this || style.interim)
3526 result = PropagateActive(true, swap, &goOn, true);
3527 if(!result && !goOn)
3532 acquireInput = true;
3536 if(style.hasMaximize && parent != guiApp.desktop)
3539 SetState(maximized, false, 0);
3540 else if(state != maximized)
3543 for(child = parent.children.first; child; child = child.next)
3545 if(this != child && child.state == maximized)
3546 child.SetState(normal, false, 0);
3553 if(!style.inactive && !style.interim /*&& (!style.isRemote || parent.active || parent.style.hidden)*/)
3555 Window previous = parent.activeClient;
3556 parent.activeChild = this;
3557 if(!style.nonClient /*&& style.isActiveClient*/)
3559 if(style.isActiveClient && !style.hidden)
3560 parent.activeClient = this;
3561 parent.UpdateActiveDocument(previous);
3566 //if(!style.isRemote)
3568 if(rootWindow != this)
3570 if(activateParent && !parent.active /*parent != parent.parent.activeChild*/)
3571 parent.ActivateEx(true, true, moveInactive, activateRoot, external, externalSwap);
3573 else if(!guiApp.fullScreenMode)
3575 Window modalRoot = FindModal();
3576 if(!modalRoot) modalRoot = this;
3577 if(!modalRoot.isForegroundWindow)
3579 modalRoot.isForegroundWindow = true;
3580 // To check : Why is parent null?
3581 if(activateRoot && modalRoot.parent && !modalRoot.parent.display && external != modalRoot)
3583 guiApp.interfaceDriver.ActivateRootWindow(modalRoot);
3585 modalRoot.isForegroundWindow = false;
3590 if(result && real && (!style.inactive || moveInactive) && parent)
3592 Window last = parent.children.last;
3594 if(!style.stayOnTop)
3595 for(; last && last.style.stayOnTop; last = last.prev);
3597 parent.children.Move(this, last);
3599 // Definitely don't want that: why not?
3603 parent.childrenOrder.Move(order, parent.childrenOrder.last);
3609 if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
3616 parent.activeChild = null;
3617 if(!style.nonClient /*&& style.isActiveClient*/)
3619 Window previous = parent.activeClient;
3620 if(style.isActiveClient)
3621 parent.activeClient = null;
3622 parent.UpdateActiveDocument(previous);
3626 if(this == guiApp.interimWindow)
3628 guiApp.interimWindow = null;
3629 if(guiApp.caretOwner)
3630 guiApp.caretOwner.UpdateCaret(false, false);
3632 if(!PropagateActive(false, externalSwap, &goOn, true) || !goOn)
3639 if(!active || !swap)
3640 UpdateDecorations();
3642 swap.UpdateDecorations();
3644 if(active && rootWindow != this)
3645 ConsequentialMouseMove(false);
3652 // --- Input Messages ---
3653 void ::UpdateMouseMove(int mouseX, int mouseY, bool consequential)
3655 static bool reEntrancy = false;
3656 if(reEntrancy) return;
3660 guiApp.cursorUpdate = true;
3661 if(guiApp.windowScrolling && !consequential)
3663 guiApp.windowScrolling.SetScrollPosition(
3664 (guiApp.windowScrolling.sbh) ?
3665 (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
3666 (guiApp.windowScrolling.sbv) ?
3667 (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
3669 if(guiApp.windowMoving)
3671 if(mouseX != guiApp.movingLast.x || mouseY != guiApp.movingLast.y)
3673 Window window = guiApp.windowMoving;
3675 int w = window.size.w;
3676 int h = window.size.h;
3681 rx = mouseX - guiApp.windowMovingStart.x;
3682 ry = mouseY - guiApp.windowMovingStart.y;
3685 window.GetDecorationsSize(&ew, &eh);
3687 if(guiApp.windowIsResizing)
3689 x = window.scrolledPos.x;
3690 y = window.scrolledPos.y;
3694 aw = Max(guiApp.windowResizingBefore.w - rx,window.skinMinSize.w);
3695 rx = guiApp.windowResizingBefore.w - aw;
3696 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3697 w = guiApp.windowResizingBefore.w - rx;
3701 ah = Max(guiApp.windowResizingBefore.h - ry,window.skinMinSize.h);
3702 ry = guiApp.windowResizingBefore.h - ah;
3703 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3704 ry = Max(ry, -guiApp.windowMovingBefore.y);
3705 h = guiApp.windowResizingBefore.h - ry;
3707 if(guiApp.resizeEndX)
3709 w = guiApp.windowResizingBefore.w + rx;
3712 if(guiApp.resizeEndY) h = guiApp.windowResizingBefore.h + ry;
3720 w = Max(w, window.minSize.w);
3721 h = Max(h, window.minSize.h);
3722 w = Min(w, window.maxSize.w);
3723 h = Min(h, window.maxSize.h);
3725 if(!window.OnResizing(&w, &h))
3727 w = window.clientSize.w;
3728 h = window.clientSize.h;
3731 w = Max(w, window.skinMinSize.w);
3732 h = Max(h, window.skinMinSize.h);
3739 SNAPDOWN(w, textCellW);
3740 SNAPDOWN(h, textCellH);
3745 aw = Max(w,window.skinMinSize.w);
3746 rx = guiApp.windowResizingBefore.w - aw;
3747 rx = Min(guiApp.windowMovingBefore.x + rx, window.parent.clientSize.w-1) - guiApp.windowMovingBefore.x;
3748 w = guiApp.windowResizingBefore.w - rx;
3752 ah = Max(h,window.skinMinSize.h);
3753 ry = guiApp.windowResizingBefore.h - ah;
3754 ry = Min(guiApp.windowMovingBefore.y + ry, window.parent.clientSize.h-1) - guiApp.windowMovingBefore.y;
3755 ry = Max(ry, -guiApp.windowMovingBefore.y);
3756 h = guiApp.windowResizingBefore.h - ry;
3761 if(!guiApp.windowIsResizing || guiApp.resizeX)
3762 x = guiApp.windowMovingBefore.x + rx;
3763 if(!guiApp.windowIsResizing || guiApp.resizeY)
3764 y = guiApp.windowMovingBefore.y + ry;
3766 if(!guiApp.windowIsResizing)
3769 if(window.parent == guiApp.desktop && guiApp.virtualScreen.w)
3771 x = Min(x, (guiApp.virtualScreen.w + guiApp.virtualScreenPos.x) -1);
3772 y = Min(y, (guiApp.virtualScreen.h + guiApp.virtualScreenPos.y) -1);
3773 x = Max(x,-(w-1) + guiApp.virtualScreenPos.x);
3774 y = Max(y,-(h-1) + guiApp.virtualScreenPos.y);
3778 x = Min(x, (window.parent.reqScrollArea.w ? window.parent.reqScrollArea.w : window.parent.clientSize.w) -1);
3779 y = Min(y, (window.parent.reqScrollArea.h ? window.parent.reqScrollArea.h : window.parent.clientSize.h) -1);
3785 if(!guiApp.windowIsResizing || (guiApp.resizeX || guiApp.resizeY))
3787 if(!window.OnMoving(&x, &y, w, h))
3789 x = window.scrolledPos.x;
3790 y = window.scrolledPos.y;
3796 SNAPDOWN(x, textCellW);
3797 SNAPDOWN(y, textCellH);
3800 if(!window.style.nonClient)
3802 if(!window.style.fixed /*|| window.style.isDocument*/)
3804 if(!window.style.dontScrollHorz)
3805 x += window.parent.scroll.x;
3806 if(!window.style.dontScrollVert)
3807 y += window.parent.scroll.y;
3811 // Break the anchors for moveable/resizable windows
3812 // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
3813 if(window.style.fixed)
3815 if(window.state == normal)
3817 window.normalAnchor = Anchor { left = x, top = y };
3818 window.normalSizeAnchor = SizeAnchor { { w, h } };
3819 window.anchored = false;
3823 window.stateAnchor = Anchor { left = x, top = y };
3824 window.stateSizeAnchor = SizeAnchor { { w, h } };
3826 window.Position(x, y, w, h, false, true, guiApp.windowIsResizing, guiApp.windowIsResizing, false, true);
3827 // TOCHECK: Investigate why the following only redraws the scrollbars
3828 //window.Position(x, y, w, h, false, true, true, true, false, true);
3830 guiApp.movingLast.x = mouseX;
3831 guiApp.movingLast.y = mouseY;
3837 public bool MouseMessage(uint method, int x, int y, Modifiers * mods, bool consequential, bool activate)
3840 bool wasMoving = guiApp.windowMoving ? true : false;
3841 bool wasScrolling = guiApp.windowScrolling ? true : false;
3843 while(result && w != this)
3845 Window msgWindow = GetAtPosition(x,y, false, true, w);
3846 Window trueWindow = GetAtPosition(x,y, false, false, w);
3847 bool windowDragged = false;
3852 window = (w && !w.disabled) ? w : null;
3854 if(trueWindow) incref trueWindow;
3856 if(consequential) mods->isSideEffect = true;
3858 UpdateMouseMove(x, y, consequential);
3860 if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
3862 if(!guiApp.windowCaptured.isEnabled)
3863 guiApp.windowCaptured.ReleaseCapture();
3865 window = guiApp.windowCaptured;
3868 if(trueWindow && activate &&
3869 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3870 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3871 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3872 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3874 Window modalWindow = trueWindow.FindModal();
3876 if(mods->alt && !mods->ctrl && !mods->shift)
3878 Window moved = trueWindow;
3879 for(moved = trueWindow; moved; moved = moved.parent)
3880 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3885 windowDragged = true;
3887 // Cancel the ALT menu toggling...
3888 window.rootWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
3893 if(window && activate &&
3894 (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown ||
3895 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown ||
3896 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown ||
3897 method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick))
3899 Window modalWindow = window.FindModal();
3901 /*if(mods->alt && !mods->shift && !mods->ctrl)
3903 Window moved = window;
3904 for(moved = window; moved; moved = moved.parent)
3905 if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
3910 windowDragged = true;
3912 // Cancel the ALT menu toggling...
3913 window.rootWindow.KeyMessage(OnKeyDown, 0, 0);
3919 Window activateWindow = modalWindow ? modalWindow : window;
3920 if(activateWindow && !activateWindow.isRemote)
3922 bool doActivation = true;
3923 //bool needToDoActivation = false;
3924 Window check = activateWindow;
3926 for(check = activateWindow; check && check != guiApp.desktop; check = check.parent)
3928 if(!check.style.inactive)
3930 //needToDoActivation = true;
3932 doActivation = false;
3937 if(!needToDoActivation)
3938 doActivation = false;
3941 if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
3942 (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
3946 incref activateWindow;
3947 if(!activateWindow.ActivateEx(true, true, false, true, null, null))
3949 delete activateWindow;
3953 if(activateWindow._refCount == 1)
3955 delete activateWindow;
3959 delete activateWindow;
3961 mods->isActivate = true;
3965 if(!modalWindow && window && !window.destroyed)
3967 if(!guiApp.windowCaptured || windowDragged)
3969 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown)
3971 bool moving = ((window.state != maximized &&
3972 window.IsMouseMoving(
3973 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
3974 || (guiApp.windowMoving && !guiApp.windowIsResizing);
3976 if(!moving && window.IsMouseResizing(
3977 x - window.absPosition.x,
3978 y - window.absPosition.y,
3979 window.size.w, window.size.h,
3980 &guiApp.resizeX, &guiApp.resizeY, &guiApp.resizeEndX, &guiApp.resizeEndY))
3982 guiApp.windowIsResizing = true;
3983 guiApp.windowResizingBefore.w = window.size.w;
3984 guiApp.windowResizingBefore.h = window.size.h;
3986 if(guiApp.windowIsResizing || windowDragged || moving)
3989 guiApp.windowMoving = window;
3990 guiApp.windowMovingStart.x = guiApp.movingLast.x = x;
3991 guiApp.windowMovingStart.y = guiApp.movingLast.y = y;
3992 guiApp.windowMovingBefore.x = window.position.x;//s;
3993 guiApp.windowMovingBefore.y = window.position.y;//s;
3994 if(guiApp.windowMoving == guiApp.windowMoving.rootWindow)
3995 guiApp.interfaceDriver.StartMoving(guiApp.windowMoving.rootWindow, 0,0,false);
3998 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
4000 if(window.style.fixed &&
4002 window.IsMouseMoving(
4003 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
4005 window.ShowSysMenu(x, y);
4009 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown)
4011 if(window.sbv || window.sbh)
4014 guiApp.windowScrolling = window;
4015 guiApp.windowScrollingStart.x = x;
4016 guiApp.windowScrollingStart.y = y;
4017 guiApp.windowScrollingBefore.x = window.scroll.x;
4018 guiApp.windowScrollingBefore.y = window.scroll.y;
4021 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
4023 if(window.style.hasMaximize &&
4024 window.IsMouseMoving(
4025 x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
4028 (window.state == maximized) ? normal : maximized, false, *mods);
4036 if(guiApp.windowMoving)
4038 if(guiApp.windowMoving.parent)
4040 if(guiApp.windowMoving.style.nonClient)
4041 guiApp.windowMoving.parent.SetMouseRangeToWindow();
4043 guiApp.windowMoving.parent.SetMouseRangeToClient();
4047 window.UpdateDecorations();
4050 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp)
4052 // Log("\n*** LEFT BUTTON UP ***\n");
4053 if(guiApp.windowMoving)
4054 guiApp.windowMoving.StopMoving();
4056 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp)
4058 if(guiApp.windowScrolling)
4060 Window windowScrolling = guiApp.windowScrolling;
4061 guiApp.windowScrolling = null;
4062 windowScrolling.ReleaseCapture();
4066 if(!result || (window && window.destroyed)) window = null;
4068 if(window && window.FindModal())
4071 if(trueWindow && trueWindow.FindModal())
4079 msgWindow = GetAtPosition(x,y, true, false);
4081 msgWindow.SelectMouseCursor();
4084 if(guiApp.windowCaptured || trueWindow)
4086 Window prevWindow = guiApp.prevWindow;
4087 if(guiApp.prevWindow && trueWindow != guiApp.prevWindow)
4089 guiApp.prevWindow.mouseInside = false;
4090 guiApp.prevWindow = null;
4092 // Eventually fix this not to include captured?
4093 if(!prevWindow.OnMouseLeave(*mods))
4096 if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
4098 Box box = trueWindow.box;
4099 box.left += trueWindow.absPosition.x;
4100 box.right += trueWindow.absPosition.x;
4101 box.top += trueWindow.absPosition.y;
4102 box.bottom += trueWindow.absPosition.y;
4104 if(box.IsPointInside({x, y}) && trueWindow != /*guiApp.*/prevWindow /*!trueWindow.mouseInside*/)
4106 int overX = x - (trueWindow.absPosition.x + trueWindow.clientStart.x);
4107 int overY = y - (trueWindow.absPosition.y + trueWindow.clientStart.y);
4109 overX = Max(Min(overX, 32767),-32768);
4110 overY = Max(Min(overY, 32767),-32768);
4112 trueWindow.mouseInside = true;
4113 if(!trueWindow.OnMouseOver(overX, overY, *mods))
4117 if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
4118 guiApp.prevWindow = trueWindow;
4120 guiApp.prevWindow = null;
4122 SelectMouseCursor();
4124 if(window && !guiApp.windowMoving && !wasMoving && !wasScrolling)
4126 int clientX = x - (window.absPosition.x + window.clientStart.x);
4127 int clientY = y - (window.absPosition.y + window.clientStart.y);
4129 bool (* MouseMethod)(Window instance, int x, int y, Modifiers mods);
4131 clientX = Max(Min(clientX, 32767),-32768);
4132 clientY = Max(Min(clientY, 32767),-32768);
4134 MouseMethod = (void *)window._vTbl[method];
4136 if(MouseMethod /*&& !consequential*/ && !window.disabled)
4139 if(!MouseMethod(window, clientX, clientY, *mods))
4146 if(result && w && w.clickThrough && w.parent)
4151 if(!result || !w || !w.clickThrough)
4158 // --- Mouse cursor management ---
4160 bool KeyMessage(uint method, Key key, unichar character)
4165 if(guiApp.interimWindow)
4166 this = guiApp.interimWindow;
4169 if((SmartKey)key != alt && (SmartKey)key != Key::control && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && parent && this != parent.menuBar)
4173 if(!style.inactive || rootWindow != this)
4175 bool (*KeyMethod)(Window window, Key key, unichar ch) = (void *)_vTbl[method];
4176 Window modalWindow = FindModal();
4177 Window interimMaster = master ? master.rootWindow : null;
4181 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4182 status = OnSysKeyDown(key, character);
4183 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4184 status = OnSysKeyHit(key, character);
4185 else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4186 status = OnSysKeyUp(key, character);
4193 // Process Key Message for Internal UI Keyboard actions
4194 if(status && !destroyed && menuBar && state != minimized)
4197 if((SmartKey)key != alt)
4198 menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
4201 SmartKey sk = (SmartKey) key;
4202 if((character && !key.alt && !key.ctrl) || sk == left || sk == right || sk == up || sk == down || sk == home || sk == end || sk == escape || sk == alt)
4204 status = menuBar.KeyMessage(method, key, character);
4209 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4210 menuBar.OnKeyHit(escape, 0);
4212 if(!menuBar.focus && guiApp.caretOwner)
4213 guiApp.caretOwner.UpdateCaret(true, false);
4216 if(!destroyed && status)
4218 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4222 case left: case up: case right: case down:
4223 if(guiApp.windowMoving == this)
4226 int w = guiApp.windowMoving.size.w;
4227 int h = guiApp.windowMoving.size.h;
4228 int x = guiApp.windowMoving.scrolledPos.x;
4229 int y = guiApp.windowMoving.scrolledPos.y;
4233 if(key == down || key == up)
4234 step = Max(step, textCellH);
4236 step = Max(step, textCellW);
4239 if(guiApp.windowIsResizing)
4243 case left: w-=step; break;
4244 case right: w+=step; break;
4245 case up: h-=step; break;
4246 case down: h+=step; break;
4253 case left: x-=step; break;
4254 case right: x+=step; break;
4255 case up: y-=step; break;
4256 case down: y+=step; break;
4260 if(guiApp.resizeX) x += w - guiApp.windowMoving.size.w;
4261 if(guiApp.resizeY) y += h - guiApp.windowMoving.size.h;
4263 if(!guiApp.windowIsResizing || guiApp.resizeX)
4264 x = (x - guiApp.windowMovingBefore.x) + guiApp.windowMovingStart.x;
4266 x = (w - guiApp.windowResizingBefore.w) + guiApp.windowMovingStart.x;
4268 if(!guiApp.windowIsResizing || guiApp.resizeY)
4269 y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
4271 y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
4273 guiApp.interfaceDriver.SetMousePosition(x, y);
4274 ConsequentialMouseMove(true);
4282 if(guiApp.windowMoving && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4284 guiApp.windowMoving.StopMoving();
4285 ConsequentialMouseMove(false);
4293 ShowSysMenu(absPosition.x, absPosition.y);
4301 if(!destroyed && status && state != minimized)
4303 // Process all the way down the children
4304 if(activeChild && !activeChild.disabled)
4306 status = activeChild.KeyMessage(method, key, character);
4308 if(status && activeClient && activeChild != activeClient && !activeClient.disabled && (key.alt || key.ctrl) &&
4309 key.code != left && key.code != right && key.code != up && key.code != down)
4311 status = activeClient.KeyMessage(method, key, character);
4315 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4317 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && !defaultControl.disabled && state != minimized)
4318 // && defaultControl != activeChild)
4320 delete previousActive;
4321 previousActive = activeChild;
4322 if(previousActive) incref previousActive;
4324 ConsequentialMouseMove(false);
4325 if((defaultControl.active ||
4326 defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
4327 defaultControl.KeyMessage(method, defaultKey, character);
4333 if(!destroyed && status && (!modalWindow || this == guiApp.desktop))
4335 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4342 ShowSysMenu(absPosition.x, absPosition.y);
4349 if(this != guiApp.desktop)
4351 if(!guiApp.windowMoving && !guiApp.windowCaptured)
4353 if(state != maximized && (key.shift ? style.sizeable : style.fixed))
4355 MenuMoveOrSize(key.shift, true);
4359 else if(guiApp.windowMoving)
4361 guiApp.windowMoving.StopMoving();
4362 ConsequentialMouseMove(false);
4370 if(!destroyed && status && state != minimized)
4372 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4376 case tab: case shiftTab:
4378 Window cycleParent = this;
4379 if(this == guiApp.interimWindow && !master.style.interim && !cycleParent.style.tabCycle)
4380 cycleParent = master.parent;
4382 if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
4384 if(cycleParent.CycleChildren(!key.shift, false, false, true))
4386 Window child = cycleParent.activeChild;
4388 // Scroll the window to include the active control
4390 if(cycleParent.sbh && !child.style.dontScrollHorz)
4392 if(child.scrolledPos.x < 0)
4393 cycleParent.sbh.Action(Position,
4394 cycleParent.scroll.x + child.scrolledPos.x, 0);
4395 else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
4396 cycleParent.sbh.Action(Position,
4397 cycleParent.scroll.x + child.scrolledPos.x + child.size.w - cycleParent.clientSize.w, 0);
4399 if(cycleParent.sbv && !child.style.dontScrollVert)
4401 if(child.scrolledPos.y < 0)
4402 cycleParent.sbv.Action(Position,
4403 cycleParent.scroll.y + child.scrolledPos.y, 0);
4404 else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
4405 cycleParent.sbv.Action(Position,
4406 cycleParent.scroll.y + child.scrolledPos.y+child.size.h - cycleParent.clientSize.h, 0);
4409 cycleParent.ConsequentialMouseMove(false);
4415 case f6: case shiftF6:
4416 if(!guiApp.windowMoving /*!guiApp.windowCaptured*/)
4418 // NOT NEEDED... guiApp.windowMoving.ReleaseCapture();
4419 if(parent == guiApp.desktop)
4420 if(guiApp.desktop.CycleChildren(key.shift, true, false, true))
4425 if(style.tabCycle ||
4426 CycleChildren(key.shift, true, false, true))
4434 // mIRC Style Window Shortcuts
4435 case alt1: case alt2: case alt3: case alt4: case alt5:
4436 case alt6: case alt7: case alt8: case alt9: case alt0:
4441 for(document = children.first; document; document = document.next)
4443 if(document.style.isDocument && document.documentID - 1 == key.code - k1)
4445 if(document == activeChild)
4447 if(document.state == minimized)
4448 document.SetState(normal, false, key);
4451 document.SetState(minimized, false, key);
4452 CycleChildren(false, true, false);
4457 if(activeChild.state == maximized && document.style.hasMaximize)
4458 document.SetState(maximized, false, key);
4459 else if(document.state == minimized)
4460 document.SetState(normal, false, key);
4461 document.Activate();
4476 if(!destroyed && status)
4478 if(state == minimized)
4483 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4485 if((SmartKey)key == enter && !key.alt && !key.ctrl && defaultControl && previousActive)
4487 if(defaultControl.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, key, character))
4488 previousActive.ActivateEx(true, false, false, true, null, null);
4489 delete previousActive;
4495 if(!destroyed && status)
4497 status = ProcessHotKeys(method, key, character);
4499 if(!destroyed && status && !modalWindow && state != minimized)
4502 status = KeyMethod(this, key, character);
4503 if(!destroyed && status && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown)
4504 status = OnKeyHit(key, character);
4505 if(!destroyed && status && (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown || method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit))
4507 bool result = false;
4510 case ctrlUp: case ctrlDown:
4511 if(sbv && !guiApp.windowScrolling)
4512 result = sbv.Action((key == ctrlUp) ? up : down, 0, key);
4514 case wheelUp: case wheelDown:
4515 if(sbv && !guiApp.windowScrolling)
4517 result = sbv.Action((key == wheelUp) ? wheelUp : wheelDown, 0, key);
4518 // Do we want to do a consequential move regardless of result in this case?
4519 ConsequentialMouseMove(false);
4522 case ctrlPageUp: case ctrlPageDown:
4523 if(sbh && !guiApp.windowScrolling)
4524 result = sbh.Action((key == ctrlPageUp) ? up : down, 0, key);
4529 ConsequentialMouseMove(false);
4534 if(status && !destroyed && menuBar && state != minimized)
4535 status = menuBar.KeyMessage(method, key, character);
4537 if(style.interim && /*destroyed && */status && interimMaster)
4539 // Testing this... for Ctrl-O to open dialog when autocompletion listbox is popped...
4540 status = interimMaster.KeyMessage(method, key, character);
4547 bool ProcessHotKeys(uint method, Key key, unichar character)
4552 for(hotKey = hotKeys.first; hotKey; hotKey = hotKey.next)
4553 if((hotKey.key == key || (method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp && hotKey.key.code == key.code)) &&
4554 !hotKey.window.disabled && (hotKey.window.style.nonClient || state != minimized))
4556 Window hotKeyWindow = hotKey.window;
4557 Window parent = hotKeyWindow.parent;
4558 Window prevActiveWindow = activeChild;
4560 // Don't process non-visible buttons, but make an exception for the Alt-F4 with Native Decorations turned on
4561 if(hotKeyWindow.style.hidden && (!hotKeyWindow.style.nonClient || !parent || !parent.nativeDecorations || hotKeyWindow != parent.sysButtons[2]))
4564 if(prevActiveWindow) incref prevActiveWindow;
4565 incref hotKeyWindow;
4566 if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
4567 if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
4570 delete hotKeyWindow;
4571 delete prevActiveWindow;
4575 if(hotKeyWindow.style.nonClient && method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit)
4576 method = __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown;
4577 if(!hotKeyWindow.KeyMessage(method, Key::hotKey, character))
4579 // ********* WORKING ON THIS ***********
4580 if(prevActiveWindow && !guiApp.interimWindow)
4581 prevActiveWindow.ActivateEx(true, false, false, false, null, null);
4584 else if(hotKeyWindow.style.inactive)
4585 status = hotKeyWindow.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp, Key::hotKey, character);
4587 delete prevActiveWindow;
4588 delete hotKeyWindow;
4589 // For Key Ups, don't set status to false... (e.g.: Releasing Enter vs AltEnter hot key)
4590 if(method != __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp)
4594 if(status && tabCycle)
4597 for(child = children.first; child; child = child.next)
4599 if(child.tabCycle && !child.ProcessHotKeys(method, key, character))
4610 // --- Windows and graphics initialization / termination ---
4611 bool SetupRoot(void)
4615 // Setup relationship with outside world (bb root || !bb)
4616 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
4617 (displayDriver && displayDriver != parent.displayDriver))
4621 tempExtents = new0 Extent[4];
4626 /*if(guiApp.fullScreenMode)
4627 rootWindow = guiApp.desktop;
4629 //rootWindow = parent.created ? parent.rootWindow : null;
4630 rootWindow = parent.rootWindow;
4633 against = &parent.box;
4635 against = &parent.clientArea;
4638 for(child = children.first; child; child = child.next)
4641 return (rootWindow && (rootWindow == this || rootWindow.created)) ? true : false;
4644 bool Setup(bool positionChildren)
4646 bool result = false;
4649 if((!guiApp.fullScreenMode && parent == guiApp.desktop) || (guiApp.fullScreenMode && (this == guiApp.desktop || (displayDriver && displayDriver != parent.displayDriver))))
4651 subclass(DisplayDriver) dDriver = dispDriver ? dispDriver : GetDisplayDriver(guiApp.defaultDisplayDriver);
4652 DisplaySystem displaySystem = dDriver ? dDriver.displaySystem : null;
4654 windowHandle = dDriver.printer ? null : guiApp.interfaceDriver.CreateRootWindow(this);
4656 // This was here, is it really needed?
4657 //guiApp.interfaceDriver.ActivateRootWindow(this);
4661 displaySystem = DisplaySystem {};
4662 if(!displaySystem.Create(dDriver.name, guiApp.fullScreenMode ? windowHandle : windowHandle /*null*/, guiApp.fullScreenMode))
4664 delete displaySystem;
4669 display = Display { alphaBlend = alphaBlend, useSharedMemory = useSharedMemory, windowDriverData = windowData };
4670 if(display.Create(displaySystem, windowHandle))
4677 guiApp.interfaceDriver.SetIcon(this, icon);
4679 else if(this != guiApp.desktop)
4681 display = rootWindow ? rootWindow.display : null;
4687 if(guiApp.acquiredWindow && rootWindow == guiApp.acquiredWindow.rootWindow)
4688 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, true);
4690 for(child = children.first; child; child = child.next)
4692 if(child.created && !child.Setup(false))
4698 bool SetupDisplay(void)
4700 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
4701 if(is3D) return Window3D_SetupDisplay(this); else
4708 class_data void ** pureVTbl;
4710 bool LoadGraphics(bool creation, bool resetAnchors)
4712 bool result = false;
4713 bool success = false;
4715 WindowState stateBackup = state;
4718 if(!rootWindow.created)
4722 if(((subclass(Window))_class).pureVTbl)
4724 if(_vTbl == _class._vTbl)
4726 _vTbl = ((subclass(Window))_class).pureVTbl;
4731 for(m = 0; m < _class.vTblSize; m++)
4733 if(_vTbl[m] == _class._vTbl[m])
4734 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
4738 if(guiApp.currentSkin && ((subclass(Window))_class).pureVTbl)
4740 if(_vTbl == ((subclass(Window))_class).pureVTbl)
4742 _vTbl = _class._vTbl;
4747 for(m = 0; m < _class.vTblSize; m++)
4749 if(_vTbl[m] == ((subclass(Window))_class).pureVTbl[m])
4750 _vTbl[m] = _class._vTbl[m];
4755 if(guiApp.fullScreenMode || this != guiApp.desktop)
4757 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
4763 display.Lock(false);
4764 if(rootWindow == this)
4766 // Set Color Palette
4767 display.SetPalette(palette, true);
4771 if(guiApp.fullScreenMode && this == guiApp.desktop)
4776 for(c=0; c<SystemCursor::enumSize; c++)
4777 if(!guiApp.systemCursors[c].bitmap)
4779 guiApp.systemCursors[c].bitmapName = guiApp.currentSkin.CursorsBitmaps(c,
4780 &guiApp.systemCursors[c].hotSpotX,&guiApp.systemCursors[c].hotSpotY, &guiApp.systemCursors[c].paletteShades);
4781 if(guiApp.systemCursors[c].bitmapName)
4783 guiApp.systemCursors[c].bitmap = eBitmap_LoadT(guiApp.systemCursors[c].bitmapName, null,
4784 guiApp.systemCursors[c].paletteShades ? null : guiApp.desktop.display.displaySystem);
4785 if(guiApp.systemCursors[c].bitmap)
4786 guiApp.systemCursors[c].bitmap.paletteShades = guiApp.systemCursors[c].paletteShades;
4791 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
4793 cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
4794 cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
4796 cursor.bitmap.paletteShades = cursor.paletteShades;
4800 guiApp.cursorUpdate = true;
4803 ConsequentialMouseMove(false);
4809 // Load Window Graphic Resources
4812 if(usedFont == setFont || usedFont == window.systemFont)
4813 RemoveResource(usedFont);
4816 RemoveResource(setFont); // TESTING setFont instead of usedFont);
4819 RemoveResource(systemFont);
4822 RemoveResource(captionFont);
4824 for(ptr = resources.first; ptr; ptr = ptr.next)
4826 ptr.loaded = display.displaySystem.LoadResource(ptr.resource);
4829 AddResource(setFont);
4831 AddResource(systemFont);
4833 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
4840 //if(master && master.font)
4841 if(parent && parent.font)
4845 faceName = parent.font.faceName,
4846 size = parent.font.size,
4847 bold = parent.font.bold,
4848 italic = parent.font.italic,
4849 underline = parent.font.underline
4851 //font = parent.font;
4852 watch(parent) { font { } };
4855 font = guiApp.currentSkin.SystemFont();
4862 captionFont = guiApp.currentSkin.CaptionFont();
4863 AddResource(captionFont);
4865 if(OnLoadGraphics())
4871 //SetScrollLineStep(sbStep.x, sbStep.y);
4873 if(this != guiApp.desktop)
4877 normalAnchor = anchor;
4878 normalSizeAnchor = sizeAnchor;
4881 // Break the anchors for moveable/resizable windows
4883 if(style.fixed && style.isDocument)
4885 ComputeAnchors(ax, ay, aw, ah, &x, &y, &w, &h);
4897 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
4898 stateSizeAnchor = SizeAnchor {};
4903 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
4908 left = (iconID % maxIcons) * MINIMIZED_WIDTH,
4909 bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
4912 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
4916 stateAnchor = normalAnchor;
4917 stateSizeAnchor = normalSizeAnchor;
4920 position = Point { };
4921 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
4932 if(Position(x, y, w, h, true, false, true, true, true, true))
4934 if((this != guiApp.desktop || guiApp.fullScreenMode) && rootWindow == this)
4937 guiApp.interfaceDriver.SetRootWindowState(this, normal, true);
4954 success = result = true;
4957 if(!creation && result)
4959 // Load menu bar first because sys buttons are on it...
4962 if(!menuBar.LoadGraphics(false, resetAnchors))
4968 for(child = children.first; child; child = child.next)
4970 if(child.created && child != menuBar && !child.LoadGraphics(false, resetAnchors))
4977 CreateSystemChildren();
4981 if(this == guiApp.desktop && !guiApp.fullScreenMode)
4984 guiApp.interfaceDriver.ActivateRootWindow(activeChild);
4989 //guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, caption);
4990 guiApp.LogErrorCode(IERR_GRAPHICS_LOADING_FAILED, class.name);
4993 // Do this here to avoid problems on Windows
4994 if(stateBackup == maximized)
4995 property::state = maximized;
4999 void UnloadGraphics(bool destroyWindows)
5003 // Free children's graphics
5004 for(child = children.first; child; child = child.next)
5005 child.UnloadGraphics(destroyWindows);
5008 display.Lock(false);
5011 if(guiApp.fullScreenMode && this == guiApp.desktop)
5016 for(c=0; c<SystemCursor::enumSize; c++)
5017 if(guiApp.systemCursors[c].bitmap)
5018 delete guiApp.systemCursors[c].bitmap;
5020 for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
5021 delete cursor.bitmap;
5023 guiApp.cursorBackground.Free();
5026 if(display && display.displaySystem)
5030 for(ptr = resources.first; ptr; ptr = ptr.next)
5034 display.displaySystem.UnloadResource(ptr.resource, ptr.loaded);
5039 // Free window graphics
5042 // Free skin graphics
5043 if(rootWindow == this)
5045 DisplaySystem displaySystem = display.displaySystem;
5048 display.driverData = null;
5049 display.displaySystem = null;
5053 if(displaySystem && !displaySystem.numDisplays && !is3D)
5054 delete displaySystem;
5063 if(guiApp.acquiredWindow && this == guiApp.acquiredWindow.rootWindow)
5064 guiApp.interfaceDriver.AcquireInput(guiApp.acquiredWindow.rootWindow, false);
5066 if(this == guiApp.desktop || parent == guiApp.desktop)
5068 if((guiApp.fullScreenMode || this != guiApp.desktop) && rootWindow == this && windowHandle && destroyWindows)
5069 guiApp.interfaceDriver.DestroyRootWindow(this);
5073 // --- Window Hiding ---
5075 void SetVisibility(bool state)
5077 bool visible = (style.hidden || !created) ? false : state;
5078 if(visible != this.visible)
5082 this.visible = visible;
5083 for(child = children.first; child; child = child.next)
5084 child.SetVisibility(visible);
5086 ConsequentialMouseMove(false);
5090 // --- Windows and graphics initialization / termination ---
5092 bool DisplayModeChanged(void)
5094 bool result = false;
5095 if(!guiApp.fullScreenMode && !guiApp.modeSwitching/* && guiApp.desktop.active*/)
5097 guiApp.modeSwitching = true;
5098 UnloadGraphics(false);
5100 if(LoadGraphics(false, false))
5102 guiApp.modeSwitching = false;
5107 // --- Window updates system ---
5109 void UpdateDirty(Box updateBox)
5111 if(!manageDisplay) { OnRedraw(null);return; }
5114 if(display && (!guiApp.fullScreenMode || guiApp.desktop.active) && !guiApp.modeSwitching)
5117 if(display.flags.flipping)
5120 rootWindow.UpdateDisplay();
5123 UpdateBackDisplay(updateBox);
5125 if(guiApp.fullScreenMode)
5127 guiApp.cursorUpdate = true;
5128 guiApp.PreserveAndDrawCursor();
5130 if(guiApp.fullScreenMode)
5131 guiApp.RestoreCursorBackground();
5137 // This function is strictly called as a result of system window activation
5138 bool ExternalActivate(bool active, bool activateRoot, Window window, Window swap)
5141 Window interimMaster = null;
5142 Window interimWindow = guiApp.interimWindow;
5143 if(interimWindow && interimWindow.master)
5144 interimMaster = interimWindow.master.rootWindow;
5146 if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
5147 // SetState(normal, false, 0);
5148 SetState(lastState, false, 0);
5150 if(interimMaster && swap == interimMaster && interimMaster.IsSlaveOf(window))
5154 /* WTH is this doing here?
5155 while(swap && swap.activeChild)
5157 swap = swap.activeChild;
5160 // TESTING THIS BEFORE...
5161 if(interimWindow && this == interimMaster)
5165 // Window interimSwap = this;
5166 Window menuBar = this.menuBar;
5167 if(menuBar && interimWindow.master == menuBar)
5170 while(interimSwap && interimSwap.activeChild)
5171 interimSwap = interimSwap.activeChild;
5173 result = interimWindow.ActivateEx(false, false, false, activateRoot, null,
5174 (menuBar && interimWindow.master == menuBar) ? menuBar : interimSwap);
5176 result = /*interimWindow.*/ActivateEx(false, false, false, activateRoot, null, menuBar);
5177 //result = ActivateEx(true, true, false, activateRoot, window, null);
5182 // Testing & FindModal() here: broke reactivating when a modal dialog is up (didn't root activate dialog)
5183 result = ActivateEx(active, active, false, activateRoot /*&& FindModal()*/, window, swap);
5185 if(interimWindow == this && interimMaster && !active)
5187 while(interimMaster && interimMaster.interim && interimMaster.master)
5189 // printf("Going up one master %s\n", interimMaster._class.name);
5190 interimMaster = interimMaster.master.rootWindow;
5192 // printf("Unactivating interim master %s (%x)\n", interimMaster._class.name, interimMaster);
5193 interimMaster.ActivateEx(active, active, false, activateRoot, window, swap);
5199 bool DestroyEx(int returnCode)
5202 Timer timer, nextTimer;
5204 OldLink prevOrder = null;
5205 Window client = null;
5207 if(parent) stopwatching(parent, font);
5209 // if(window.modalSlave) return false;
5210 if(destroyed || !created)
5217 OldLink slave = master.slaves.FindVoid(this);
5218 master.slaves.Delete(slave);
5221 // TOFIX IMMEDIATELY: COMMENTED THIS OUT... causes problem second time creating file dialog
5227 this.returnCode = (DialogResult)returnCode;
5229 AcquireInput(false);
5234 master.hotKeys.Delete(hotKey);
5238 if(guiApp.prevWindow == this)
5240 guiApp.prevWindow = null;
5243 if(guiApp.caretOwner == this)
5245 guiApp.interfaceDriver.SetCaret(0,0,0);
5246 UpdateCaret(false, true);
5247 guiApp.caretEnabled = false;
5252 parent.childrenCycle.Remove(cycle);
5256 OldLink tmpPrev = order.prev;
5257 if(tmpPrev && !(((Window)tmpPrev.data).style.hidden) && !(((Window)tmpPrev.data).destroyed) && (((Window)tmpPrev.data).created))
5258 prevOrder = tmpPrev;
5261 client = tmpPrev ? tmpPrev.data : null;
5262 if(client == this) { client = null; break; }
5263 if(client && (client.style.hidden || client.destroyed || !client.created))
5264 tmpPrev = client.order.prev;
5268 prevOrder = tmpPrev;
5273 // If this window can be an active client, make sure the next window we activate can also be one
5274 if(!style.nonClient && style.isActiveClient)
5276 tmpPrev = prevOrder;
5279 client = tmpPrev ? tmpPrev.data : null;
5280 if(client == this) { client = null; break; }
5281 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
5282 tmpPrev = client.order.prev;
5286 prevOrder = tmpPrev;
5290 if(client && client.style.hidden) client = null;
5292 // parent.childrenOrder.Remove(order);
5295 // TESTING THIS HERE!
5299 // If no display, don't bother deactivating stuff (causes unneeded problems when trying
5300 // to create a window inside a rootwindow that's being destroyed)
5301 // DISABLED THIS BECAUSE OF CREATING WINDOW IN DESKTOP IN WINDOWED MODE
5303 if(master && !master.destroyed /*&&
5304 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5306 if(master.defaultControl == this)
5307 master.defaultControl = null;
5309 if(parent && !parent.destroyed /*&&
5310 rootWindow && rootWindow.display && !rootWindow.destroyed*/)
5312 if((parent.activeChild == this /*|| parent.activeClient == this */|| guiApp.interimWindow == this))
5314 if(order && prevOrder && prevOrder.data != this && active)
5316 //((Window)prevOrder.data).ActivateEx(true, false, false, false /*true*/, null);
5318 ((Window)prevOrder.data).ActivateEx(true, false, false, (rootWindow == this) ? true : false, null, null);
5319 if(parent.activeClient == this)
5321 parent.activeClient = null;
5322 parent.UpdateActiveDocument(null);
5327 if(guiApp.interimWindow == this)
5330 PropagateActive(false, null, &goOn, true);
5334 //if(window.parent.activeChild == window)
5335 parent.activeChild = null;
5336 if(!style.nonClient /*&& style.isActiveClient*/)
5338 Window previous = parent.activeClient;
5339 if(style.isActiveClient)
5340 parent.activeClient = null;
5341 parent.UpdateActiveDocument(previous);
5346 else if(parent.activeClient == this)
5348 parent.activeClient = client;
5349 parent.UpdateActiveDocument(this);
5353 if(guiApp.interimWindow == this)
5355 guiApp.interimWindow = null;
5356 if(guiApp.caretOwner)
5358 Window desktop = guiApp.desktop;
5359 if(desktop.activeChild && desktop.activeChild.menuBar && !desktop.activeChild.menuBar.focus)
5360 guiApp.caretOwner.UpdateCaret(false, false);
5365 if(style.modal && master && master.modalSlave == this)
5366 master.modalSlave = null;
5370 if(!guiApp.caretOwner && parent.caretSize)
5372 guiApp.caretOwner = parent;
5373 parent.UpdateCaret(false, false);
5374 parent.Update(null);
5377 if(style.isActiveClient && visible)
5379 if(state == minimized) parent.numIcons--;
5380 parent.numPositions--;
5382 // Why was this commented out?
5383 GetRidOfVirtualArea();
5389 dirtyArea.Free(null);
5390 dirtyBack.Free(null);
5391 scrollExtent.Free(null);
5393 /* ATTEMPTING TO MOVE THAT ABOVE
5402 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5403 for(;(child = window.children.first);)
5405 for(; child && (child.destroyed || !child.created); child = child.next);
5414 UnloadGraphics(true);
5417 delete previousActive;
5420 // statusBar = null;
5423 if(master && !master.destroyed)
5425 //master.NotifyDestroyed(this, this.returnCode);
5426 NotifyDestroyed(master, this, this.returnCode);
5429 for(timer = guiApp.windowTimers.first; timer; timer = nextTimer)
5431 nextTimer = timer.next;
5432 if(timer.window == this)
5434 // WHY WERE WE SETTING THIS TO NULL? NO MORE WINDOW WHEN RECREATING...
5435 // timer.window = null;
5441 if(this == guiApp.windowMoving)
5444 if(guiApp.windowCaptured == this)
5446 //guiApp.windowCaptured = null;
5448 if(rootWindow != this && rootWindow)
5449 rootWindow.ConsequentialMouseMove(false);
5457 //for(child = children.first; next = child ? child.next : null, child; child = next)
5458 for(;(child = children.first); )
5460 for(; child && (child.destroyed || !child.created); child = child.next);
5470 /* // MOVED THIS UP...
5473 //for(child = window.children.first; next = child ? child.next : null, child; child = next)
5474 for(;(child = window.children.first); )
5476 for(; child && (child.destroyed || !child.created); child = child.next);
5485 while((slave = slaves.first))
5487 for(; slave && (((Window)slave.data).destroyed || !((Window)slave.data).created); slave = slave.next);
5489 ((Window)slave.data).DestroyEx(0);
5494 if(guiApp.caretOwner == this)
5495 guiApp.caretOwner = null;
5497 sysButtons[0] = null;
5498 sysButtons[1] = null;
5499 sysButtons[2] = null;
5502 if(rootWindow != this)
5504 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
5507 box.left -= parent.clientStart.x;
5508 box.top -= parent.clientStart.y;
5509 box.right -= parent.clientStart.x;
5510 box.bottom -= parent.clientStart.y;
5512 if(parent) parent.Update(box);
5517 OldLink slave = master.slaves.FindVoid(this);
5518 master.slaves.Delete(slave);
5524 parent.children.Remove(this);
5529 //autoCreate = false;
5532 // SHOULD THIS BE HERE? FIXED CRASH WITH GOTO DIALOG
5533 if(((subclass(Window))_class).pureVTbl)
5535 if(_vTbl == _class._vTbl)
5537 _vTbl = ((subclass(Window))_class).pureVTbl;
5542 for(m = 0; m < _class.vTblSize; m++)
5544 if(_vTbl[m] == _class._vTbl[m])
5545 _vTbl[m] = ((subclass(Window))_class).pureVTbl[m];
5554 void SetStateEx(WindowState newState, bool activate)
5557 WindowState prevState = state;
5561 if(prevState != newState)
5562 lastState = prevState;
5564 if(rootWindow == this && nativeDecorations)
5566 if(style.isActiveClient && !style.hidden && prevState == minimized)
5569 // This block used to be at the end of the function... moved it for flicker problem in X
5570 // ------------------------------------------------------
5574 stateAnchor = normalAnchor;
5575 stateSizeAnchor = normalSizeAnchor;
5578 stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
5579 stateSizeAnchor = SizeAnchor {};
5583 int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
5586 byte * idBuffer = new0 byte[size];
5588 for(child = parent.children.first; child; child = child.next)
5590 if(child != this && child.state == minimized)
5592 if(child.iconID > size - 2)
5594 idBuffer = renew0 idBuffer byte[size*2];
5595 memset(idBuffer + size, 0, size);
5598 idBuffer[child.iconID] = (byte)bool::true;
5601 for(c = 0; c<size; c++)
5606 if(style.isActiveClient && !style.hidden)
5609 stateAnchor = Anchor { left = (iconID % maxIcons) * MINIMIZED_WIDTH, bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24) };
5610 stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
5614 // TOCHECK: Why was this here?
5615 //position.x = (tx > 0) ? tx & 0xFFFFF : tx;
5616 //position.y = (ty > 0) ? ty & 0xFFFFF : ty;
5617 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5619 Position(x, y, w, h, true, true, true, true, false, true);
5621 if(!style.inactive && !style.interim && this == parent.activeClient)
5622 parent.UpdateActiveDocument(null);
5624 CreateSystemChildren();
5625 // ------------------------------------------------------
5628 int GetPositionID(Window forChild)
5632 byte * idBuffer = new0 byte[size];
5635 for(child = children.first; child; child = child.next)
5637 if(child.style.isActiveClient && !child.style.hidden && child != forChild)
5639 if(child.positionID > size - 2)
5641 idBuffer = renew0 idBuffer byte[size*2];
5642 memset(idBuffer + size, 0, size);
5645 idBuffer[child.positionID] = (byte)bool::true;
5648 for(c = 0; c<size; c++)
5655 // --- Window related graphics ---
5657 void SetPalette(ColorAlpha * newPalette, bool colorMatch)
5659 palette = newPalette;
5660 if(rootWindow.display)
5661 rootWindow.display.SetPalette(palette, colorMatch);
5664 public bool AcquireInput(bool acquired)
5667 if(acquiredInput != acquired)
5669 if(active || (!visible && creationActivation == activate))
5670 result = AcquireInputEx(acquired);
5675 acquiredInput = acquired ? result : !result;
5680 void ListChildren(ListBox listBox)
5684 for(child = children.first; child; child = child.next)
5686 if(child.cycle && !child.style.nonClient && child.style.isActiveClient && child.visible)
5688 DataRow row = listBox.AddRow();
5689 row.tag = (int)child;
5690 child.FigureCaption(caption);
5691 row.SetData(null, caption);
5696 void UpdateVisual(Box extent)
5698 if(guiApp.driver != null)
5700 if(guiApp.fullScreenMode && guiApp.desktop.display)
5702 guiApp.desktop.mutex.Wait();
5703 guiApp.desktop.display.Lock(true);
5706 if(guiApp.desktop.active)
5708 if(guiApp.desktop.dirty || guiApp.cursorUpdate)
5710 if(guiApp.desktop.display.flags.flipping)
5711 guiApp.desktop.Update(null);
5712 guiApp.desktop.UpdateDisplay();
5713 guiApp.cursorUpdate = true;
5715 if(guiApp.cursorUpdate || guiApp.desktop.dirty)
5717 guiApp.PreserveAndDrawCursor();
5718 // guiApp.desktop.display.ShowScreen();
5719 guiApp.cursorUpdate = false;
5720 guiApp.desktop.dirty = false;
5721 guiApp.RestoreCursorBackground();
5725 guiApp.desktop.display.Unlock();
5726 guiApp.desktop.mutex.Release();
5730 Window rootWindow = this.rootWindow;
5731 rootWindow.mutex.Wait();
5736 guiApp.SignalEvent();
5739 guiApp.waitMutex.Wait();
5740 guiApp.interfaceDriver.Lock(rootWindow);
5741 if(!rootWindow.style.hidden && rootWindow.dirty)
5743 if(rootWindow.display)
5745 rootWindow.UpdateDisplay();
5746 //rootWindow.display.ShowScreen(null);
5748 rootWindow.dirty = false;
5750 guiApp.interfaceDriver.Unlock(rootWindow);
5751 guiApp.waitMutex.Release();
5754 rootWindow.mutex.Release();
5759 void UnlockDisplay(void)
5761 guiApp.interfaceDriver.Unlock(rootWindow);
5764 void LockDisplay(void)
5766 guiApp.interfaceDriver.Lock(rootWindow);
5769 Surface GetSurface(Box box)
5771 return Redraw((box == null) ? this.box : box);
5774 void SetMousePosition(int x, int y)
5776 guiApp.interfaceDriver.SetMousePosition(x + absPosition.x + clientStart.x, y + absPosition.y + clientStart.y);
5780 void IntegrationActivate(bool active)
5782 if(!guiApp.modeSwitching && !guiApp.fullScreenMode)
5784 isForegroundWindow = true;
5785 ActivateEx(active, active, false, false, null, null);
5786 isForegroundWindow = false;
5791 Window QueryCapture(void)
5793 return guiApp.windowCaptured;
5796 int GetDocumentID(void)
5800 byte * idBuffer = new0 byte[size];
5803 for(child = children.first; child; child = child.next)
5805 if(child.style.isDocument)
5807 if(child.documentID-1 > size - 2)
5809 idBuffer = renew0 idBuffer byte[size*2];
5810 memset(idBuffer + size, 0, size);
5813 idBuffer[child.documentID-1] = 1;
5816 for(c = 0; c<size; c++)
5824 void SetInitSize(Size size)
5827 sizeAnchor.size = size;
5828 normalSizeAnchor = sizeAnchor;
5830 // Break the anchors for moveable/resizable windows
5831 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
5833 stateAnchor = normalAnchor;
5834 stateSizeAnchor = normalSizeAnchor;
5836 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
5837 Position(x,y, w, h, true, true, true, true, false, true);
5841 void MenuMoveOrSize(bool resize, bool setCursorPosition)
5843 if(this != guiApp.desktop && state != maximized && (resize ? (state != minimized && style.sizable) : (style.fixed || moveable)))
5845 guiApp.windowIsResizing = resize;
5846 guiApp.windowMoving = this;
5847 guiApp.windowMovingStart = guiApp.movingLast = absPosition;
5848 if(guiApp.windowIsResizing)
5850 guiApp.windowMovingStart.x += size.w - 1;
5851 guiApp.windowMovingStart.y += size.h - 1;
5853 guiApp.windowMovingBefore = scrolledPos;
5854 guiApp.windowResizingBefore = size;
5855 guiApp.windowMoving.UpdateDecorations();
5856 if(guiApp.windowIsResizing)
5857 guiApp.resizeEndX = guiApp.resizeEndY = true;
5859 if(setCursorPosition)
5860 guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
5864 guiApp.interfaceDriver.GetMousePosition(&x, &y);
5865 guiApp.windowMovingStart.x += x - absPosition.x;
5866 guiApp.windowMovingStart.y += y - absPosition.y;
5869 if(guiApp.windowMoving)
5871 if(guiApp.windowMoving.style.nonClient)
5872 guiApp.windowMoving.parent.SetMouseRangeToWindow();
5874 guiApp.windowMoving.parent.SetMouseRangeToClient();
5879 if(this == rootWindow)
5880 guiApp.interfaceDriver.StartMoving(rootWindow, guiApp.windowMovingStart.x, guiApp.windowMovingStart.y, true);
5888 bool result = false;
5892 else if(guiApp && guiApp.driver != null)
5894 void * systemParent = null;
5895 OldLink slaveHolder;
5897 bool visible = !style.hidden;
5901 systemParent = parent;
5902 parent = guiApp.desktop;
5904 last = parent ? parent.children.last : null;
5906 if((parent && parent != guiApp.desktop && !parent.created) ||
5907 (master && master != guiApp.desktop && !master.created))
5911 property::parent = guiApp.desktop;
5912 if(!master) master = parent;
5914 if(style.modal && master.modalSlave)
5918 parent.children.Remove(this);
5921 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
5922 if(slaveHolder.data == this)
5924 master.slaves.Delete(slaveHolder);
5929 if(parent == guiApp.desktop && !mutex)
5932 if(style.isDocument)
5935 parent.numDocuments--;
5936 documentID = parent.GetDocumentID();
5939 if(!style.stayOnTop)
5940 for(; last && last.style.stayOnTop; last = last.prev);
5942 parent.children.Insert((last == this) ? null : last, this);
5943 //parent.children.Add(this);
5946 dispDriver = parent.dispDriver;
5949 master.modalSlave = this;
5951 box = Box { MAXINT, MAXINT, MININT, MININT }; //-MAXINT, -MAXINT };
5956 master.slaves.Add(slaveHolder = OldLink { data = this });
5961 master.hotKeys.Add(hotKey = HotKeySlot { key = setHotKey, window = this });
5963 if(style.isDefault && !master.defaultControl)
5964 master.defaultControl = this;
5966 stateAnchor = normalAnchor = anchor;
5967 stateSizeAnchor = normalSizeAnchor = sizeAnchor;
5969 // TOCHECK: Why is this here?
5970 //position.x = (ax > 0) ? ax & 0xFFFFF : ax;
5971 //position.y = (ay > 0) ? ay & 0xFFFFF : ay;
5973 this.visible = false;
5974 style.hidden = true;
5977 // autoCreate = true;
5985 if(parent == guiApp.desktop)
5986 Log("LoadGraphics %s\n", caption);
5988 if(LoadGraphics(true, false))
5996 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
6003 if(style.hasMenuBar /*&& menu*/)
6009 menu = menu, isMenuBar = true, anchor = Anchor { top = 23, left = 1, right = 1 },
6010 interim = false, inactive = true, nonClient = true, size.h = 24
6018 // Create the system buttons
6019 CreateSystemChildren();
6021 UpdateActiveDocument(null);
6023 if(style.isDocument)
6027 MenuItem item = menu.FindItem(MenuFileSave, 0);
6028 if(item) item.disabled = !modifiedDocument && fileName;
6033 if(parent == guiApp.desktop)
6034 Log("Preemptive SetState %s\n", caption);
6037 // Preemptive Set State to ensure proper anchoring
6038 SetStateEx(state, false);
6040 style.hidden = true;
6046 for(child = children.first; child; child = next)
6049 if(!child.created && (child.autoCreate || child.wasCreated))
6056 for(link = slaves.first; link; link = next)
6058 Window slave = link.data;
6060 if(!slave.created && (slave.autoCreate || slave.wasCreated))
6069 if(parent == guiApp.desktop)
6070 Log("Real SetState %s\n", caption);
6073 if(isActiveClient && visible)
6075 parent.numPositions--;
6076 if(state == minimized) parent.numIcons--;
6079 // Real set state & activate for proper display & activation
6080 property::visible = visible;
6081 // SetState(state & 0x00000003, true, 0);
6086 /*if(rootWindow == this)
6087 guiApp.interfaceDriver.ActivateRootWindow(this);
6089 if(creationActivation == activate)
6090 ActivateEx(true, false, true, true, null, null);
6091 else if(creationActivation == flash)
6096 rootWindow.ConsequentialMouseMove(false);
6107 guiApp.LogErrorCode(IERR_WINDOW_CREATION_FAILED, caption);
6113 // Testing this here... Otherwise a failed LoadGraphics stalls the application
6115 //style.hidden = true; // !visible;
6116 style.hidden = !visible;
6117 if(master.modalSlave == this)
6118 master.modalSlave = null;
6125 void WriteCaption(Surface surface, int x, int y)
6128 Interface::WriteKeyedTextDisabled(surface, x,y, caption, hotKey ? hotKey.key : 0, !isEnabled);
6131 void Update(Box region)
6137 rootWindow = this.rootWindow;
6139 // rootWindow.mutex.Wait();
6140 if(!destroyed && visible && display)
6145 // Testing this to avoid repetitve full update to take time...
6146 if(dirtyArea.count == 1)
6148 BoxItem item = (BoxItem)ACCESS_ITEM(dirtyArea, dirtyArea.first);
6149 if(item.box.left <= box.left &&
6150 item.box.top <= box.top &&
6151 item.box.right >= box.right &&
6152 item.box.bottom >= box.bottom)
6154 rootWindow.dirty = true;
6159 if(display.flags.flipping && !rootWindow.dirty)
6161 if(this == rootWindow)
6165 rootWindow.Update(null);
6170 rootWindow.dirty = true;
6175 realBox.left += clientStart.x;
6176 realBox.top += clientStart.y;
6177 realBox.right += clientStart.x;
6178 realBox.bottom += clientStart.y;
6184 if(realBox.right >= realBox.left &&
6185 realBox.bottom >= realBox.top)
6187 // if(!rootWindow.fullRender)
6188 dirtyArea.UnionBox(realBox, rootWindow.tempExtents[0]);
6190 for(child = children.first; child; child = child.next)
6195 box.left -= child.absPosition.x - absPosition.x;
6196 box.top -= child.absPosition.y - absPosition.y;
6197 box.right -= child.absPosition.x - absPosition.x;
6198 box.bottom -= child.absPosition.y - absPosition.y;
6199 if(box.right >= child.box.left && box.left <= child.box.right &&
6200 box.bottom >= child.box.top && box.top <= child.box.bottom)
6202 box.left -= child.clientStart.x;
6203 box.top -= child.clientStart.y;
6204 box.right -= child.clientStart.x;
6205 box.bottom -= child.clientStart.y;
6211 realBox.left += absPosition.x - rootWindow.absPosition.x;
6212 realBox.top += absPosition.y - rootWindow.absPosition.y;
6213 realBox.right += absPosition.x - rootWindow.absPosition.x;
6214 realBox.bottom += absPosition.y - rootWindow.absPosition.y;
6215 rootWindow.dirtyBack.UnionBox(realBox, rootWindow.tempExtents[0]);
6218 else if(this == guiApp.desktop)
6221 for(window = children.first; window; window = window.next)
6227 Box childBox = region;
6229 childBox.left -= window.absPosition.x - guiApp.desktop.absPosition.x;
6230 childBox.top -= window.absPosition.y - guiApp.desktop.absPosition.y;
6231 childBox.right -= window.absPosition.x - guiApp.desktop.absPosition.x;
6232 childBox.bottom -= window.absPosition.y - guiApp.desktop.absPosition.y;
6234 window.Update(childBox);
6237 window.Update(null);
6242 // rootWindow.mutex.Release();
6249 if(guiApp.windowCaptured != this)
6251 if(guiApp.windowCaptured)
6255 //Logf("Captured %s (%s)\n", caption, class.name);
6256 guiApp.interfaceDriver.SetMouseCapture(rootWindow);
6257 guiApp.windowCaptured = this;
6263 bool Destroy(int code)
6268 if(!CloseConfirmation(false)) return false;
6272 // TOCHECK: Should autoCreate be set to false here?
6275 // Is this needed here? DestroyEx should decref already...
6284 void Move(int x, int y, int w, int h)
6286 normalAnchor = Anchor { left = x, top = y };
6287 normalSizeAnchor = SizeAnchor { size = { w, h } };
6289 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
6291 if(destroyed) return;
6293 stateAnchor = normalAnchor;
6294 stateSizeAnchor = normalSizeAnchor;
6296 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
6297 Position(x,y, w, h, true, true, true, true, false, true);
6301 DialogResult Modal(void)
6307 // FIXES MEMORY LEAK IF Create() FAILED
6313 void SetScrollArea(int width, int height, bool snapToStep)
6315 bool resize = false;
6318 int stepX = sbStep.x, stepY = sbStep.y;
6319 // Needed to make snapped down position match the skin's check of client area
6320 // against realvirtual
6323 SNAPDOWN(stepX, textCellW);
6324 SNAPDOWN(stepY, textCellH);
6325 stepX = Max(stepX, textCellW);
6326 stepY = Max(stepY, textCellH);
6328 if(scrollFlags.snapX)
6329 SNAPUP(width, stepX);
6330 if(scrollFlags.snapY)
6331 SNAPUP(height, stepY);
6334 reqScrollArea.w = width;
6335 reqScrollArea.h = height;
6336 noAutoScrollArea = (width > 0 || height > 0);
6338 UpdateScrollBars(true, true);
6341 void SetScrollPosition(int x, int y)
6344 sbh.Action(setPosition, x, 0);
6348 int seen = clientSize.w, total = reqScrollArea.w;
6350 if(scrollFlags.snapX)
6351 SNAPDOWN(seen, sbStep.x);
6353 if(!total) total = seen;
6354 range = total - seen + 1;
6355 range = Max(range, 1);
6357 if(x >= range) x = range - 1;
6359 if(scrollFlags.snapX)
6360 SNAPUP(x, sbStep.x);
6363 OnHScroll(setPosition, x, 0);
6367 SNAPDOWN(x, textCellW);
6373 sbv.Action(setPosition, y, 0);
6377 int seen = clientSize.h, total = reqScrollArea.h;
6380 if(scrollFlags.snapY)
6381 SNAPDOWN(seen, sbStep.y);
6383 if(!total) total = seen;
6384 range = total - seen + 1;
6385 range = Max(range, 1);
6387 if(y >= range) y = range - 1;
6389 if(scrollFlags.snapY)
6390 SNAPUP(y, sbStep.y);
6393 OnVScroll(setPosition, y, 0);
6396 SNAPDOWN(y, textCellH);
6401 UpdateCaret(false, false);
6404 void SetScrollLineStep(int stepX, int stepY)
6410 SNAPDOWN(stepX, textCellW);
6411 SNAPDOWN(stepY, textCellH);
6412 stepX = Max(stepX, textCellW);
6413 stepY = Max(stepY, textCellH);
6416 sbh.lineStep = stepX;
6418 sbv.lineStep = stepY;
6421 void SetState(WindowState newState, bool activate, Modifiers mods)
6425 if(state == newState || OnStateChange(newState, mods))
6427 WindowState prevState = state;
6431 // This used to be at the end of the brackets... moved for X, testing...
6432 // This has the effect of activating the window through the system...
6433 if(rootWindow == this)
6434 guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
6436 SetStateEx(newState, activate);
6438 if(rootWindow == this && !rootWindow.nativeDecorations)
6440 int x = position.x, y = position.y;
6443 x -= guiApp.desktop.absPosition.x;
6444 y -= guiApp.desktop.absPosition.y;
6446 guiApp.interfaceDriver.PositionRootWindow(this, x, y, size.w, size.h, true, true);
6450 //state = prevState;
6452 if(state != maximized && style.hasMaximize)
6455 for(child = parent.children.first; child; child = child.next)
6457 if(child != this && child.state == maximized)
6458 child.SetStateEx(normal, false);
6462 if(!style.nonClient && (sbv || sbh) && this != parent.sbv && this != parent.sbh)
6463 parent.UpdateScrollBars(true, true);
6466 // Do we really need this stuff here?
6467 // Shouldn't the Activate stuff take care of it?
6468 if(parent.rootWindow == parent && style)
6471 parent.FigureCaption(caption);
6472 guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
6473 parent.UpdateDecorations();
6477 rootWindow.ConsequentialMouseMove(false);
6484 BitmapResource GetIcon(SkinBitmap iconID)
6486 return guiApp.currentSkin.GetBitmap(iconID);
6489 void SetMouseRange(Box range)
6491 if(range || guiApp.fullScreenMode)
6496 clip.left = range.left + absPosition.x + clientStart.x;
6497 clip.top = range.top + absPosition.y + clientStart.y;
6498 clip.right = range.right + absPosition.x + clientStart.x;
6499 clip.bottom = range.bottom + absPosition.y + clientStart.y;
6503 clip.left = guiApp.desktop.box.left;
6504 clip.top = guiApp.desktop.box.top;
6505 clip.right = guiApp.desktop.box.right;
6506 clip.bottom = guiApp.desktop.box.bottom;
6508 guiApp.interfaceDriver.SetMouseRange(rootWindow, clip);
6511 guiApp.interfaceDriver.SetMouseRange(rootWindow, null);
6514 void SetMouseRangeToClient(void)
6516 if(guiApp.fullScreenMode || this != guiApp.desktop)
6518 Box box {0, 0, clientSize.w - 1, clientSize.h - 1 };
6519 box.Clip(clientArea);
6523 SetMouseRange(null);
6526 void SetMouseRangeToWindow(void)
6528 Box box { -clientStart.x, -clientStart.y, size.w-1, size.h-1 };
6529 if(this == guiApp.desktop)
6530 SetMouseRangeToClient();
6535 // x, y: Desktop Coordinates
6536 void ShowSysMenu(int x, int y)
6539 PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
6542 menu, "Restore", r, NotifySelect = MenuWindowRestore,
6543 disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
6547 menu, "Move", m, NotifySelect = MenuWindowMove,
6548 disabled = !style.fixed || state == maximized
6552 menu, "Size", s, NotifySelect = MenuWindowSize,
6553 disabled = !style.sizable || state != normal
6557 menu, "Minimize", n, NotifySelect = MenuWindowMinimize,
6558 disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
6562 menu, "Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
6563 disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
6567 menu, "Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
6568 disabled = !style.fixed, checkable = true, checked = style.stayOnTop
6570 MenuDivider { menu };
6573 menu, "Close", c, (parent == guiApp.desktop) ? altF4 : ( style.isActiveClient ? ctrlF4 : 0), NotifySelect = MenuWindowClose,
6574 bold = true, disabled = !style.hasClose, bitmap = guiApp.currentSkin.GetBitmap(close)
6576 windowMenu.Create();
6581 ActivateEx(true, true, true, true, null, null);
6584 void MakeActive(void)
6586 ActivateEx(true, false, true, false, null, null);
6589 void SoftActivate(void)
6591 if(guiApp.desktop.active)
6597 void Deactivate(void)
6599 ActivateEx(false, true, true, true, null, null);
6604 guiApp.interfaceDriver.FlashRootWindow(rootWindow);
6607 bool CycleChildren(bool backward, bool clientOnly, bool tabCycleOnly, bool cycleParents)
6609 bool result = false;
6610 if(activeChild && activeChild.cycle)
6612 Window modalWindow, child = activeChild;
6613 if(!clientOnly /*&& parent.tabCycle*/)
6615 Window next = child;
6618 if(next.cycle == (backward ? childrenCycle.first : childrenCycle.last))
6622 if(parent && parent.CycleChildren(backward, false, true, true))
6630 next = next.cycle.prev.data;
6632 next = next.cycle.next.data;
6633 if(!next.disabled && !next.inactive /*isRemote*/ && next.created && !next.nonClient && (!clientOnly || next.style.isActiveClient) && !next.style.hidden && next.FindModal() != activeChild)
6638 if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
6639 parent.tabCycle && parent.CycleChildren(backward, false, false))
6643 if(tabCycleOnly && !tabCycle) return false;
6650 child = child.cycle.prev.data;
6652 child = child.cycle.next.data;
6653 if(child == child.parent.activeChild)
6655 else if(!child.disabled && child.created && (!clientOnly || child.style.isActiveClient) && !child.style.hidden && child.FindModal() != activeChild)
6658 modalWindow = child.FindModal();
6661 // Scroll the window to include the active control
6662 if(sbh && !child.style.dontScrollHorz)
6664 if(child.scrolledPos.x < 0)
6665 sbh.Action(setPosition, scroll.x + child.scrolledPos.x, 0);
6666 else if(child.scrolledPos.x + child.size.w > clientSize.w)
6667 sbh.Action(setPosition, scroll.x + child.scrolledPos.x + child.size.w - clientSize.w, 0);
6669 if(sbv && !child.style.dontScrollVert)
6671 if(child.scrolledPos.y < 0)
6672 sbv.Action(setPosition, scroll.y + child.scrolledPos.y, 0);
6673 else if(child.scrolledPos.y + child.size.h > clientSize.h)
6674 sbv.Action(setPosition, scroll.y + child.scrolledPos.y + child.size.h - clientSize.h, 0);
6678 child = modalWindow ? modalWindow : child;
6679 child.ActivateEx(true, true, true, true, null, null);
6680 if(child.tabCycle && child.childrenCycle.first)
6681 child = ((OldLink)(backward ? child.childrenCycle.first : child.childrenCycle.last)).data;
6689 ConsequentialMouseMove(false);
6693 void AddResource(Resource resource)
6697 ResPtr ptr { resource = resource };
6701 // Load Graphics here if window is created already
6702 if(/*created && */display)
6704 display.Lock(false);
6705 ptr.loaded = display.displaySystem.LoadResource(resource);
6709 // Temporary hack to load font right away for listbox in dropbox ...
6710 else if(master && master.display)
6712 master.display.Lock(false);
6713 master.display.displaySystem.LoadResource(resource);
6714 master.display.Unlock();
6720 void RemoveResource(Resource resource)
6725 for(ptr = resources.first; ptr; ptr = ptr.next)
6727 if(ptr.resource == resource)
6733 // Unload Graphics here if window is created already
6734 if(/*created && */display)
6738 display.Lock(false);
6739 display.displaySystem.UnloadResource(resource, ptr.loaded);
6745 resources.Delete(ptr);
6750 void SetCaret(int x, int y, int size)
6757 if(active && !style.interim)
6759 if(visible || !guiApp.caretOwner)
6760 guiApp.caretOwner = size ? this : null;
6762 UpdateCaret(false, false);
6765 guiApp.interfaceDriver.SetCaret(0,0,0);
6766 UpdateCaret(false, true);
6767 guiApp.caretEnabled = false;
6770 else if(style.inactive && active)
6772 guiApp.interfaceDriver.SetCaret(0,0,0);
6773 UpdateCaret(false, true);
6774 guiApp.caretEnabled = false;
6779 void Scroll(int x, int y)
6781 bool opaque = !style.drawBehind || background.a;
6782 if(opaque && display && display.flags.scrolling)
6784 Box box = clientArea;
6785 box.left += clientStart.x;
6786 box.top += clientStart.y;
6787 box.right += clientStart.x;
6788 box.bottom += clientStart.y;
6790 //scrollExtent.Free(null);
6791 scrollExtent.AddBox(box);
6792 scrolledArea.x += x;
6793 scrolledArea.y += y;
6795 //scrollExtent.Free();
6796 //scrollExtent.AddBox(clientArea);
6797 //scrollExtent.Offset(clientStart.x, clientStart.y);
6798 //scrolledArea.x = x;
6799 //scrolledArea.y = y;
6805 rootWindow.dirty = true;
6808 void ReleaseCapture()
6810 if(guiApp && guiApp.windowCaptured && guiApp.windowCaptured == this)
6812 Window oldCaptured = guiApp.windowCaptured;
6813 guiApp.windowCaptured = null;
6814 guiApp.prevWindow = null;
6817 //guiApp.Log("Released Capture\n");
6819 guiApp.interfaceDriver.SetMouseCapture(null);
6821 //oldCaptured.OnMouseCaptureLost();
6824 oldCaptured.ConsequentialMouseMove(false);
6829 void SetText(char * format, ...)
6836 char caption[MAX_F_STRING];
6838 va_start(args, format);
6839 vsprintf(caption, format, args);
6842 this.caption = new char[strlen(caption)+1];
6844 strcpy(this.caption, caption);
6853 bool Grab(Bitmap bitmap, Box box, bool decorations)
6855 bool result = false;
6856 if(display || this == guiApp.desktop)
6858 Box clip = {MININT, MININT, MAXINT, MAXINT};
6864 clip.Clip(clientArea);
6866 clip.Clip(this.box);
6868 if(rootWindow != this)
6870 clip.left += absPosition.y;
6871 clip.top += absPosition.y;
6872 clip.right += absPosition.x;
6873 clip.bottom += absPosition.y;
6876 clip.left += decorations ? 0 : clientStart.x;
6877 clip.top += decorations ? 0 : clientStart.y;
6878 clip.right += decorations ? 0 : clientStart.x;
6879 clip.bottom += decorations ? 0 : clientStart.y;
6881 if(display && display.flags.flipping)
6883 rootWindow.Update(null);
6884 rootWindow.UpdateDisplay();
6891 result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
6892 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
6896 result = display.Grab(bitmap, clip.left, clip.top,
6897 clip.right - clip.left + 1, clip.bottom - clip.top + 1);
6899 if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
6901 if(!bitmap.Convert(null, pixelFormat888, null))
6908 void GetMousePosition(int * x, int * y)
6910 int mouseX = 0, mouseY = 0;
6911 if(!guiApp.acquiredWindow && (guiApp.desktop.active || !guiApp.fullScreenMode))
6914 guiApp.interfaceDriver.GetMousePosition(&mouseX, &mouseY);
6915 if(this != guiApp.desktop)
6917 mouseX -= absPosition.x + clientStart.x;
6918 mouseY -= absPosition.y + clientStart.y;
6925 DialogResult DoModal()
6927 DialogResult returnCode = 0;
6928 int terminated = terminateX;
6931 while(!destroyed && guiApp.driver != null)
6933 if(terminateX != terminated)
6935 terminated = terminateX;
6936 guiApp.desktop.Destroy(0);
6937 if(guiApp.desktop.created)
6940 //printf("Resetting terminate X to 0\n");
6946 guiApp.UpdateDisplay();
6947 if(!guiApp.ProcessInput(false))
6950 returnCode = this.returnCode;
6963 return !destroyed && guiApp.driver != null && terminateX < 2;
6966 DialogResult DoModalEnd()
6968 DialogResult returnCode = this.returnCode;
6973 // --- Window manipulation ---
6974 /*bool GetDisabled()
6976 bool disabled = this.disabled;
6978 for(window = this; (window = window.master); )
6989 // --- Mouse Manipulation ---
6990 void GetNCMousePosition(int * x, int * y)
6992 GetMousePosition(x, y);
6993 if(x) *x += clientStart.x;
6994 if(y) *y += clientStart.y;
6997 // --- Carets manipulation ---
6998 void GetCaretPosition(Point caretPos)
7000 caretPos = this.caretPos;
7003 int GetCaretSize(void)
7008 bool ButtonCloseDialog(Button button, int x, int y, Modifiers mods)
7014 bool CloseConfirmation(bool parentClosing)
7027 if(!OnClose(parentClosing))
7030 // If you want to skip this, simply set modifiedDocument to false in OnClose
7031 if(result && (/*fileName || */style.isDocument) && modifiedDocument)
7033 DialogResult dialogRes;
7036 sprintf(message, "Save changes to %s?", fileName);
7038 sprintf(message, "Save changes to Untitled %d?", documentID);
7040 dialogRes = MessageBox { master = master, type = yesNoCancel, text = parent.caption, contents = message }.Modal();
7042 if(dialogRes == yes)
7044 // TOFIX: Precomp error if brackets are taken out
7045 result = (DialogResult)MenuFileSave(null, 0) != cancel;
7047 else if(dialogRes == cancel)
7053 for(slave = slaves.first; slave; slave = slave.next)
7054 if(!((Window)slave.data).CloseConfirmation(true))
7056 // ((Window)slave.data).CloseConfirmation(true);
7064 for(child = children.first; child; child = child.next)
7065 if(child.master != this && !child.CloseConfirmation(true))
7075 // Static methods... move them somewhere else?
7076 void ::RestoreCaret()
7078 if(guiApp.caretOwner)
7079 guiApp.caretOwner.UpdateCaret(false, false);
7082 void ::FreeMouseRange()
7084 guiApp.interfaceDriver.SetMouseRange(null, null);
7088 bool MenuFileClose(MenuItem selection, Modifiers mods)
7090 Window document = activeChild;
7092 document.Destroy(0);
7096 bool MenuFileExit(MenuItem selection, Modifiers mods)
7102 bool MenuFileSave(MenuItem selection, Modifiers mods)
7106 fileMonitor.fileName = null;
7109 if(OnSaveFile(fileName))
7111 //if(OnFileModified != Window::OnFileModified)
7114 fileMonitor.fileName = fileName;
7120 MessageBox dialog { master = master, type = yesNoCancel, text = "Error writing file", contents = "Save as a different file?" };
7121 DialogResult answer = dialog.Modal();
7123 if(answer != yes) return (bool)answer;
7126 return MenuFileSaveAs(selection, mods);
7129 bool MenuFileSaveAs(MenuItem selection, Modifiers mods)
7131 DialogResult result = (DialogResult)bool::true;
7132 FileDialog fileDialog = saveDialog;
7135 fileDialog = FileDialog {};
7140 fileDialog.filePath = fileName;
7143 char filePath[MAX_FILENAME];
7144 sprintf(filePath, "Untitled %d", documentID);
7145 fileDialog.filePath = filePath;
7147 fileMonitor.fileName = null;
7149 fileDialog.type = save;
7150 fileDialog.text = "Save As";
7154 fileDialog.master = master.parent ? master : this;
7155 if(fileDialog.Modal() == ok)
7157 char * filePath = fileDialog.filePath;
7159 if(OnSaveFile(filePath))
7162 property::fileName = filePath;
7163 NotifySaved(master, this, filePath);
7168 MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = "Error writing file", contents = "Save as a different file?" };
7169 DialogResult answer = dialog.Modal();
7184 //if(OnFileModified != Window::OnFileModified && fileName)
7187 fileMonitor.fileName = fileName;
7191 return (bool)result; // Actually returning result from Yes/NoCancel message box
7194 bool MenuFileSaveAll(MenuItem selection, Modifiers mods)
7196 Window document = activeChild;
7198 for(document = children.first; document; document = next)
7200 next = document.next;
7201 if(document.style.isDocument || document.fileName)
7202 document.MenuFileSave(selection, mods);
7207 bool MenuWindowArrangeIcons(MenuItem selection, Modifiers mods)
7211 for(document = children.first; document; document = document.next)
7212 //if(document.style.isDocument && document.state == minimized)
7213 if(document.style.isActiveClient && document.state == minimized)
7214 document.SetState(minimized, false, mods);
7218 bool MenuWindowCascade(MenuItem selection, Modifiers mods)
7220 Window document = activeChild;
7223 Window firstDocument = null;
7225 OldLink cycle = document.cycle.prev;
7230 if(child.style.isActiveClient && !child.style.hidden)
7234 firstDocument = child;
7235 if(child.state == minimized)
7236 child.SetState(minimized, false, mods);
7239 child.positionID = id++;
7240 child.SetState(normal, false, mods);
7241 child.anchor.left.type = cascade;
7244 child.normalSizeAnchor = *&child.sizeAnchor;
7245 child.normalAnchor = child.anchor;
7247 // Break the anchors for moveable/resizable windows
7248 if(child.style.fixed)
7250 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7252 (*&child.normalAnchor).left = x;
7253 (*&child.normalAnchor).top = y;
7254 (*&child.normalAnchor).right.type = none;
7255 (*&child.normalAnchor).bottom.type = none;
7257 child.normalSizeAnchor.isClientW = false;
7258 child.normalSizeAnchor.isClientH = false;
7259 child.normalSizeAnchor.size.w = w;
7260 child.normalSizeAnchor.size.h = h;
7261 child.anchored = false;
7264 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7266 child.stateAnchor = child.normalAnchor;
7267 child.stateSizeAnchor = child.normalSizeAnchor;
7269 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7270 child.Position(x, y, w, h, true, true, true, true, false, false);
7275 last = children.last;
7276 if(!child.style.stayOnTop)
7277 for(; last && last.style.stayOnTop; last = last.prev);
7278 children.Move(child, last);
7279 childrenOrder.Move(child.order, childrenOrder.last);
7281 if(cycle == document.cycle) break;
7285 firstDocument.Activate();
7290 bool MenuWindowClose(MenuItem selection, Modifiers mods)
7297 // Close all closes all active clients, not all documents
7298 bool MenuWindowCloseAll(MenuItem selection, Modifiers mods)
7300 Window next, document;
7302 for(document = children.first; document; document = next)
7304 for(next = document.next; next && !(next.style.isActiveClient; next = next.next);
7305 if(document.style.isActiveClient)
7306 if(!document.Destroy(0) && !document.style.hidden)
7312 bool MenuWindowMaximize(MenuItem selection, Modifiers mods)
7314 if(style.hasMaximize && state != maximized)
7315 SetState(maximized, 0, 0);
7319 bool MenuWindowMinimize(MenuItem selection, Modifiers mods)
7321 if(style.hasMinimize && state != minimized)
7323 SetState(minimized, 0, 0);
7324 parent.CycleChildren(false, true, false, true);
7329 bool MenuWindowMove(MenuItem selection, Modifiers mods)
7331 MenuMoveOrSize(false, selection ? true : false);
7335 bool MenuWindowNext(MenuItem selection, Modifiers mods)
7337 CycleChildren(false, true, false, true);
7341 bool MenuWindowPrevious(MenuItem selection, Modifiers mods)
7343 CycleChildren(true, true, false, true);
7347 bool MenuWindowSize(MenuItem selection, Modifiers mods)
7349 MenuMoveOrSize(true, true);
7353 bool MenuWindowRestore(MenuItem selection, Modifiers mods)
7356 SetState(normal, 0, 0);
7360 bool MenuWindowSelectWindow(MenuItem selection, Modifiers mods)
7363 int id = selection.id;
7364 OldLink cycle = activeClient.cycle;
7366 //for(c = 0, cycle = activeChild.cycle; c<id; cycle = cycle.next, c++);
7369 Window sibling = cycle.data;
7370 if(sibling.style.isActiveClient)
7378 document = cycle.data;
7379 document.Activate();
7381 //if(activeChild.state == maximized)
7382 // document.SetState(maximized, false, mods);
7383 //else if(document.state == minimized)
7384 // document.SetState(normal, false, mods);
7388 bool MenuWindowStayOnTop(MenuItem selection, Modifiers mods)
7390 stayOnTop = !style.stayOnTop;
7394 bool MenuWindowTileHorz(MenuItem selection, Modifiers mods)
7396 Window document = activeChild;
7399 Window firstDocument = null;
7400 OldLink cycle = document.cycle;
7404 Window child = cycle.data;
7405 if(child.style.isActiveClient && !child.style.hidden)
7407 if(!firstDocument) firstDocument = child;
7408 if(child.state == minimized)
7409 child.SetState(minimized, false, mods);
7412 child.positionID = id++;
7413 child.SetState(normal, false, mods);
7414 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7416 child.anchor.left.type = hTiled;
7419 child.normalSizeAnchor = *&child.sizeAnchor;
7420 child.normalAnchor = child.anchor;
7422 // Break the anchors for moveable/resizable windows
7423 if(child.style.fixed)
7425 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7427 (*&child.normalAnchor).left = x;
7428 (*&child.normalAnchor).top = y;
7429 (*&child.normalAnchor).right.type = none;
7430 (*&child.normalAnchor).bottom.type = none;
7431 child.normalSizeAnchor.isClientW = false;
7432 child.normalSizeAnchor.isClientH = false;
7433 child.normalSizeAnchor.size.w = w;
7434 child.normalSizeAnchor.size.h = h;
7435 child.anchored = false;
7438 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7440 child.stateAnchor = child.normalAnchor;
7441 child.stateSizeAnchor = child.normalSizeAnchor;
7443 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7444 child.Position(x,y, w, h, true, true, true, true, false, true);
7449 if((cycle = cycle.next) == document.cycle) break;
7452 firstDocument.Activate();
7457 bool MenuWindowTileVert(MenuItem selection, Modifiers mods)
7459 Window document = activeChild;
7462 Window firstDocument = null;
7464 OldLink cycle = document.cycle;
7469 //if(child.style.isDocument)
7470 if(child.style.isActiveClient && !child.style.hidden)
7472 if(!firstDocument) firstDocument = child;
7473 if(child.state == minimized)
7474 child.SetState(minimized, false, mods);
7477 child.positionID = id++;
7478 child.SetState(normal, false, mods);
7479 child.ActivateEx(true, false, false, false, null, null); // To move active clients on top of other windows
7481 child.anchor.left.type = vTiled;
7484 child.normalSizeAnchor = *&child.sizeAnchor;
7485 child.normalAnchor = child.anchor;
7487 // Break the anchors for moveable/resizable windows
7488 if(child.style.fixed)
7490 child.ComputeAnchors(child.anchor, *&child.sizeAnchor, &x, &y, &w, &h);
7492 (*&child.normalAnchor).left = x;
7493 (*&child.normalAnchor).top = y;
7494 (*&child.normalAnchor).right.type = none;
7495 (*&child.normalAnchor).bottom.type = none;
7496 child.normalSizeAnchor.isClientW = false;
7497 child.normalSizeAnchor.isClientH = false;
7498 child.normalSizeAnchor.size.w = w;
7499 child.normalSizeAnchor.size.h = h;
7500 child.anchored = false;
7503 if(child.state == normal /*|| child.state == Hidden */) // Hidden is new here ...
7505 child.stateAnchor = child.normalAnchor;
7506 child.stateSizeAnchor = child.normalSizeAnchor;
7508 child.ComputeAnchors(child.stateAnchor, child.stateSizeAnchor, &x, &y, &w, &h);
7509 child.Position(x,y, w, h, true, true, true, true, false, true);
7514 if((cycle = cycle.next) == document.cycle) break;
7517 firstDocument.Activate();
7522 bool MenuWindowWindows(MenuItem selection, Modifiers mods)
7524 WindowList dialog { master = this };
7525 Window document = (Window)dialog.Modal();
7528 if(activeChild.state == maximized)
7529 document.SetState(maximized, false, mods);
7530 else if(document.state == minimized)
7531 document.SetState(normal, false, mods);
7532 document.Activate();
7538 virtual bool OnCreate(void);
7539 virtual void OnDestroy(void);
7540 virtual void OnDestroyed(void);
7541 virtual bool OnClose(bool parentClosing);
7542 virtual bool OnStateChange(WindowState state, Modifiers mods);
7543 virtual bool OnPostCreate(void);
7544 virtual bool OnMoving(int *x, int *y, int w, int h);
7545 virtual bool OnResizing(int *width, int *height);
7546 virtual void OnResize(int width, int height);
7547 virtual void OnPosition(int x, int y, int width, int height);
7548 virtual bool OnLoadGraphics(void);
7549 virtual void OnApplyGraphics(void);
7550 virtual void OnUnloadGraphics(void);
7551 virtual void OnRedraw(Surface surface);
7552 virtual bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct);
7553 virtual void OnActivateClient(Window client, Window previous);
7554 virtual bool OnKeyDown(Key key, unichar ch);
7555 virtual bool OnKeyUp(Key key, unichar ch);
7556 virtual bool OnKeyHit(Key key, unichar ch);
7557 virtual bool OnSysKeyDown(Key key, unichar ch);
7558 virtual bool OnSysKeyUp(Key key, unichar ch);
7559 virtual bool OnSysKeyHit(Key key, unichar ch);
7560 virtual bool OnMouseOver(int x, int y, Modifiers mods);
7561 virtual bool OnMouseLeave(Modifiers mods);
7562 virtual bool OnMouseMove(int x, int y, Modifiers mods);
7563 virtual bool OnLeftButtonDown(int x, int y, Modifiers mods);
7564 virtual bool OnLeftButtonUp(int x, int y, Modifiers mods);
7565 virtual bool OnLeftDoubleClick(int x, int y, Modifiers mods);
7566 virtual bool OnRightButtonDown(int x, int y, Modifiers mods);
7567 virtual bool OnRightButtonUp(int x, int y, Modifiers mods);
7568 virtual bool OnRightDoubleClick(int x, int y, Modifiers mods);
7569 virtual bool OnMiddleButtonDown(int x, int y, Modifiers mods);
7570 virtual bool OnMiddleButtonUp(int x, int y, Modifiers mods);
7571 virtual bool OnMiddleDoubleClick(int x, int y, Modifiers mods);
7572 virtual void OnMouseCaptureLost(void);
7573 virtual void OnHScroll(ScrollBarAction action, int position, Key key);
7574 virtual void OnVScroll(ScrollBarAction action, int position, Key key);
7575 virtual void OnDrawOverChildren(Surface surface);
7576 virtual bool OnFileModified(FileChange fileChange, char * param);
7577 virtual bool OnSaveFile(char * fileName);
7579 // Skins Virtual Functions
7580 virtual void GetDecorationsSize(MinMaxValue * w, MinMaxValue * h);
7581 virtual void SetWindowMinimum(MinMaxValue * mw, MinMaxValue * mh);
7582 virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
7587 virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7588 virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
7589 virtual bool IsMouseMoving(int x, int y, int w, int h);
7590 virtual bool IsMouseResizing(int x, int y, int w, int h, bool *resizeX, bool *resizeY, bool *resizeEndX, bool *resizeEndY);
7591 virtual void UpdateNonClient();
7592 virtual void SetBox(Box box);
7593 virtual bool IsInside(int x, int y)
7595 return box.IsPointInside({x, y});
7597 virtual bool IsOpaque()
7599 return (!style.drawBehind || background.a == 255);
7603 virtual bool Window::NotifyActivate(Window window, bool active, Window previous);
7604 virtual void Window::NotifyDestroyed(Window window, DialogResult result);
7605 virtual void Window::NotifySaved(Window window, char * filePath);
7610 property Window parent
7612 property_category "Layout"
7615 if(value || guiApp.desktop)
7618 Window oldParent = parent;
7619 Anchor anchor = this.anchor;
7621 if(value && value.IsDescendantOf(this)) return;
7622 if(value && value == this)
7624 if(!value) value = guiApp.desktop;
7626 if(value == oldParent) return;
7628 if(!master || (master == this.parent && master == guiApp.desktop))
7629 property::master = value;
7633 parent.children.Remove(this);
7637 box.left - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7638 box.top - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y,
7639 box.right - absPosition.x + parent.absPosition.x + style.nonClient * parent.clientStart.x,
7640 box.bottom - absPosition.y + parent.absPosition.y + style.nonClient * parent.clientStart.y
7644 last = value.children.last;
7646 if(style.isDocument)
7649 parent.numDocuments--;
7650 documentID = value.GetDocumentID();
7653 if(style.isActiveClient && !style.hidden)
7655 if(parent && parent != guiApp.desktop && !(style.hidden))
7657 if(state == minimized) parent.numIcons--;
7658 parent.numPositions--;
7662 if(!style.stayOnTop)
7663 for(; last && last.style.stayOnTop; last = last.prev);
7665 value.children.Insert(last, this);
7667 // *** NEW HERE: ***
7669 parent.childrenCycle.Delete(cycle);
7671 parent.childrenOrder.Delete(order);
7679 int x = position.x, y = position.y, w = size.w, h = size.h;
7683 x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
7684 y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
7686 vpw = value.clientSize.w;
7687 vph = value.clientSize.h;
7693 else if(style.fixed)
7695 if(!style.dontScrollHorz && value.scrollArea.w) vpw = value.scrollArea.w;
7696 if(!style.dontScrollVert && value.scrollArea.h) vph = value.scrollArea.h;
7699 anchor = this.anchor;
7701 if(anchor.left.type == offset) anchor.left.distance = x;
7702 else if(anchor.left.type == relative) anchor.left.percent = (float)x / vpw;
7703 if(anchor.top.type == offset) anchor.top.distance = y;
7704 else if(anchor.top.type == relative) anchor.top.percent = (float)y / vph;
7705 if(anchor.right.type == offset) anchor.right.distance = vpw - (x + w);
7706 //else if(anchor.right.type == relative) anchor.right.percent = 1.0-(float) (vpw - (x + w)) / vpw;
7707 else if(anchor.right.type == relative) anchor.right.percent = (float) (vpw - (x + w)) / vpw;
7708 if(anchor.bottom.type == offset) anchor.bottom.distance = vph - (y + h);
7709 //else if(anchor.bottom.type == relative) anchor.bottom.percent = 1.0-(float) (vph - (y + h)) / vph;
7710 else if(anchor.bottom.type == relative) anchor.bottom.percent = (float) (vph - (y + h)) / vph;
7712 if(!anchor.left.type && !anchor.right.type)
7714 anchor.horz.distance = (x + w / 2) - (vpw / 2);
7715 //anchor.horz.type = anchor.horz.distance ? AnchorValueOffset : 0;
7717 else if(anchor.horz.type == middleRelative) anchor.horz.percent = (float) ((x + w / 2) - (vpw / 2)) / vpw;
7718 if(!anchor.top.type && !anchor.bottom.type)
7720 anchor.vert.distance = (y + h / 2) - (vph / 2);
7721 //anchor.vert.type = anchor.vert.distance ? AnchorValueOffset : 0;
7723 else if(anchor.vert.type == middleRelative) anchor.vert.percent = (float)((y + h / 2) - (vph / 2)) / vph;
7731 parent.childrenCycle.Insert(
7732 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
7733 cycle = OldLink { data = this });
7734 parent.childrenOrder.Insert(
7735 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
7736 order = OldLink { data = this });
7739 if(!style.hidden && style.isActiveClient)
7741 positionID = parent.GetPositionID(this);
7742 parent.numPositions++;
7743 if(state == minimized) parent.numIcons--;
7746 // *** FONT INHERITANCE ***
7747 if(!setFont && oldParent)
7748 stopwatching(oldParent, font);
7752 RemoveResource(systemFont);
7755 // TESTING WITH WATCHERS:
7756 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7757 // usedFont = setFont ? setFont : (systemFont);
7761 if(guiApp.currentSkin)
7763 systemFont = guiApp.currentSkin.SystemFont();
7766 usedFont = systemFont;
7767 AddResource(systemFont);
7775 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
7784 if(value.rootWindow && value.rootWindow.display && rootWindow)
7786 bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
7787 (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
7790 UnloadGraphics(false);
7793 LoadGraphics(false, false);
7796 if(value.rootWindow != rootWindow)
7797 DisplayModeChanged();
7801 scrolledPos.x = MININT; // Prevent parent update
7802 property::anchor = anchor;
7806 if(guiApp.currentSkin)
7807 guiApp.currentSkin.SetWindowMinimum(this, &skinMinSize.w, &skinMinSize.h);
7809 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7810 Position(x, y, w, h, true, true, true, true, false, true);
7815 // else parent = value;
7818 get { return parent; }
7821 property Window master
7823 property_category "Behavior"
7826 //if(this == value) return;
7827 if(value && value.IsSlaveOf(this)) return;
7833 OldLink slaveHolder;
7834 for(slaveHolder = master.slaves.first; slaveHolder; slaveHolder = slaveHolder.next)
7835 if(slaveHolder.data == this)
7837 master.slaves.Delete(slaveHolder);
7844 value.slaves.Add(OldLink { data = this });
7849 master.hotKeys.Remove(hotKey);
7850 value.hotKeys.Add(hotKey);
7853 if(master && master.defaultControl == this)
7854 master.defaultControl = null;
7856 if(style.isDefault && !value.defaultControl)
7857 value.defaultControl = this;
7863 get { return master ? master : parent; }
7866 property char * text
7868 property_category "Appearance"
7875 caption = new char[strlen(value)+1];
7877 strcpy(caption, value);
7882 get { return caption; }
7887 property_category "Behavior"
7896 master.hotKeys.Add(hotKey = HotKeySlot { });
7900 hotKey.window = this;
7905 master.hotKeys.Delete(hotKey);
7910 get { return hotKey ? hotKey.key : 0; }
7913 property Color background
7915 property_category "Appearance"
7918 background.color = value;
7923 if(this == rootWindow)
7924 guiApp.interfaceDriver.SetRootWindowColor(this);
7927 get { return background.color; }
7930 property Percentage opacity
7932 property_category "Appearance"
7935 background.a = (byte)Min(Max((int)(value * 255), 0), 255);
7936 drawBehind = background.a ? false : true;
7938 get { return background.a / 255.0f; }
7941 property Color foreground
7943 property_category "Appearance"
7951 get { return foreground; }
7954 property BorderStyle borderStyle
7956 property_category "Appearance"
7959 if(!((BorderBits)value).fixed)
7961 style.hasClose = false;
7962 style.hasMaximize = false;
7963 style.hasMinimize = false;
7965 style.borderBits = value;
7969 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
7971 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
7972 Position(x, y, w, h, true, true, true, true, false, true);
7973 CreateSystemChildren();
7976 get { return (BorderStyle)style.borderBits; }
7979 property Size minClientSize
7981 property_category "Layout"
7982 set { minSize = value; }
7983 get { value = minSize; }
7986 property Size maxClientSize
7988 property_category "Layout"
7989 set { maxSize = value; }
7990 get { value = maxSize; }
7993 property bool hasMaximize
7995 property_category "Window Style"
7998 style.hasMaximize = 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.hasMaximize; }
8014 property bool hasMinimize
8016 property_category "Window Style"
8019 style.hasMinimize = value;
8020 if(value) { style.fixed = true; style.contour = true; }
8024 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8026 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8027 Position(x, y, w, h, true, true, true, true, false, true);
8029 CreateSystemChildren();
8032 get { return style.hasMinimize; }
8035 property bool hasClose
8037 property_category "Window Style"
8040 style.hasClose = value;
8041 if(value) { style.fixed = true; style.contour = true; }
8045 SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
8046 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8047 Position(x, y, w, h, true, true, true, true, false, true);
8048 CreateSystemChildren();
8051 get { return style.hasClose; }
8054 property bool nonClient
8056 property_category "Layout"
8059 style.nonClient = value;
8061 style.stayOnTop = true;
8063 get { return style.nonClient; }
8066 property bool inactive
8068 property_category "Behavior"
8073 // *** NEW HERE: ***
8077 parent.childrenCycle.Delete(cycle);
8079 parent.childrenOrder.Delete(order);
8086 active = false; // true;
8087 if(parent.activeChild == this)
8088 parent.activeChild = null;
8089 if(parent.activeClient == this)
8090 parent.activeClient = null;
8099 parent.childrenCycle.Insert(
8100 (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null,
8101 cycle = OldLink { data = this });
8103 parent.childrenOrder.Insert(
8104 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8105 order = OldLink { data = this });
8108 style.inactive = value;
8110 get { return style.inactive; }
8113 property bool clickThrough
8115 property_category "Behavior"
8116 set { style.clickThrough = value; }
8117 get { return style.clickThrough; }
8120 property bool isRemote
8122 property_category "Behavior"
8123 set { style.isRemote = value; }
8124 get { return style.isRemote; }
8127 property bool noCycle
8129 property_category "Behavior"
8130 set { style.noCycle = value; }
8131 get { return style.noCycle; }
8134 property bool isModal
8136 property_category "Behavior"
8137 set { style.modal = value; }
8138 get { return style.modal; }
8141 property bool interim
8143 property_category "Behavior"
8144 set { style.interim = value; }
8145 get { return style.interim; }
8148 property bool tabCycle
8150 property_category "Behavior"
8151 set { style.tabCycle = value; }
8152 get { return style.tabCycle; }
8155 property bool isDefault
8157 property_category "Behavior"
8165 /*for(sibling = parent.children.first; sibling; sibling = sibling.next)
8166 if(sibling != this && sibling.style.isDefault)
8167 sibling.style.isDefault = false;*/
8168 if(master.defaultControl)
8169 master.defaultControl.style.isDefault = false;
8170 master.defaultControl = this;
8172 else if(master.defaultControl == this)
8173 master.defaultControl = null;
8177 style.isDefault = value;
8179 Position(position.x, position.y, size.w, size.h, true, true, true,true,true, true);
8181 get { return style.isDefault; }
8184 property bool drawBehind
8186 property_category "Window Style"
8187 set { style.drawBehind = value; }
8188 get { return style.drawBehind; }
8191 property bool hasMenuBar
8193 property_category "Window Style"
8203 if(created && !menuBar)
8210 anchor = Anchor { top = 23, left = 1, right = 1 },
8212 inactive = true, nonClient = true
8217 else if(created && menuBar)
8222 style.hasMenuBar = value;
8224 get { return style.hasMenuBar; }
8227 property bool hasStatusBar
8229 property_category "Window Style"
8236 statusBar = StatusBar { this };
8244 style.hasStatusBar = value;
8246 get { return style.hasStatusBar; }
8248 property bool stayOnTop
8250 property_category "Window Style"
8255 if(created && !style.stayOnTop)
8257 if(rootWindow == this)
8258 guiApp.interfaceDriver.OrderRootWindow(this, true);
8259 else if(parent.children.last != this)
8261 parent.children.Move(this, parent.children.last);
8265 style.stayOnTop = true;
8269 if(created && style.stayOnTop)
8271 if(rootWindow == this)
8272 guiApp.interfaceDriver.OrderRootWindow(this, false);
8279 for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
8280 order && ((Window)order.data).style.stayOnTop;
8281 order = (order == parent.childrenOrder.first) ? null : order.prev);
8282 last = order ? order.data : null;
8286 for(last = parent.children.last;
8287 last && last.style.stayOnTop;
8291 parent.children.Move(this, last);
8295 style.stayOnTop = false;
8298 get { return style.stayOnTop; }
8303 property_category "Window Style"
8313 if(menuBar && !value)
8320 if(!menuBar && style.hasMenuBar && value)
8324 this, menu = value, isMenuBar = true,
8325 anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
8326 inactive = true, nonClient = true
8330 UpdateActiveDocument(null);
8333 get { return menu; }
8336 property FontResource font
8338 property_category "Appearance"
8340 isset { return setFont ? true : false; }
8345 if(value && !setFont) { stopwatching(parent, font); }
8346 else if(!value && setFont)
8352 usedFont = setFont ? setFont : (parent.parent ? parent.usedFont : systemFont);
8361 RemoveResource(setFont);
8366 RemoveResource(systemFont);
8373 AddResource(setFont);
8376 usedFont = setFont ? setFont : ((parent && parent.parent) ? parent.usedFont : systemFont);
8379 systemFont = guiApp.currentSkin.SystemFont();
8381 usedFont = systemFont;
8382 AddResource(systemFont);
8390 get { return usedFont; }
8393 property SizeAnchor sizeAnchor
8395 property_category "Layout"
8398 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8399 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8400 sizeAnchor.isClientW != sizeAnchor.isClientH;
8407 normalSizeAnchor = sizeAnchor;
8409 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8411 stateAnchor = normalAnchor;
8412 stateSizeAnchor = normalSizeAnchor;
8414 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8415 Position(x,y, w, h, true, true, true, true, false, true);
8422 { sizeAnchor.isClientW ? clientSize.w : size.w, sizeAnchor.isClientH ? clientSize.h : size.h },
8423 sizeAnchor.isClientW,
8424 sizeAnchor.isClientH
8431 property_category "Layout"
8434 Anchor thisAnchor = anchor;
8435 SizeAnchor thisSizeAnchor = sizeAnchor;
8436 bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
8437 bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
8438 bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
8439 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8440 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8441 !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8447 sizeAnchor.isClientW = false;
8448 sizeAnchor.isClientH = false;
8449 sizeAnchor.size = value;
8451 normalSizeAnchor = sizeAnchor;
8453 if(state == normal /*|| state == Hidden*/) // Hidden is new here ...
8455 stateAnchor = normalAnchor;
8456 stateSizeAnchor = normalSizeAnchor;
8458 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8459 Position(x, y, w, h, true, true, true, true, false, true);
8462 get { value = size; }
8465 property Size clientSize
8467 property_category "Layout"
8470 return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
8471 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
8472 sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
8477 sizeAnchor.isClientW = true;
8478 sizeAnchor.isClientH = true;
8479 sizeAnchor.size = value;
8481 normalSizeAnchor = sizeAnchor;
8483 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8485 stateAnchor = normalAnchor;
8486 stateSizeAnchor = normalSizeAnchor;
8488 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8489 Position(x,y, w, h, true, true, true, true, false, true);
8492 get { value = clientSize; }
8495 property Size initSize { get { value = sizeAnchor.size; } };
8497 property Anchor anchor
8499 property_category "Layout"
8500 isset { return (anchor.left.type != offset || anchor.top.type != offset || anchor.right.type || anchor.bottom.type); }
8506 if(anchor.left.type && anchor.right.type && (!value.left.type || !value.right.type))
8508 normalSizeAnchor.isClientW = sizeAnchor.isClientW = false;
8509 normalSizeAnchor.size.w = sizeAnchor.size.w = size.w;
8511 if(anchor.top.type && anchor.bottom.type && (!value.top.type || !value.bottom.type))
8513 normalSizeAnchor.isClientH = sizeAnchor.isClientH = false;
8514 normalSizeAnchor.size.h = sizeAnchor.size.h = size.h;
8518 if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
8520 anchor.left.distance = 0;
8521 anchor.horz.type = 0;
8523 if(anchor.bottom.type && (anchor.vert.type == middleRelative || !anchor.top.type))
8525 anchor.top.distance = 0;
8526 anchor.vert.type = 0;
8535 normalAnchor = anchor;
8537 // Break the anchors for moveable/resizable windows
8538 /*if(style.fixed ) //&& value.left.type == cascade)
8540 ComputeAnchors(anchor, sizeAnchor, &x, &y, &w, &h);
8542 this.anchor = normalAnchor = Anchor { left = x, top = y };
8543 normalSizeAnchor = SizeAnchor { { w, h } };
8546 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8548 stateAnchor = normalAnchor;
8549 stateSizeAnchor = normalSizeAnchor;
8551 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8552 Position(x, y, w, h, true, true, true, true, false, true);
8561 get { value = this ? anchor : Anchor { }; }
8564 property Point position
8566 property_category "Layout"
8569 if(value == null) return;
8571 anchor.left = value.x;
8572 anchor.top = value.y;
8573 anchor.right.type = none;
8574 anchor.bottom.type = none;
8579 normalAnchor = anchor;
8581 // Break the anchors for moveable/resizable windows
8585 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8587 normalAnchor.left = x;
8588 normalAnchor.top = y;
8589 normalAnchor.right.type = none;
8590 normalAnchor.bottom.type = none;
8591 normalSizeAnchor.size.width = w;
8592 normalSizeAnchor.size.height = h;
8596 if(state == normal /*|| state == Hidden */) // Hidden is new here ...
8598 stateAnchor = normalAnchor;
8599 stateSizeAnchor = normalSizeAnchor;
8601 ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
8602 Position(x,y, w, h, true, true, true, true, false, true);
8606 get { value = position; }
8609 property bool disabled
8611 property_category "Behavior"
8614 if(this && disabled != value)
8621 get { return (bool)disabled; }
8624 property bool isEnabled
8629 for(parent = this; parent; parent = parent.parent)
8636 property WindowState state
8638 property_category "Behavior"
8639 set { SetState(value, false, 0); }
8640 get { return this ? state : 0; }
8643 property bool visible
8645 property_category "Behavior"
8648 if(this && !value && !style.hidden && parent)
8650 Window client = null;
8652 style.hidden = true;
8653 if(style.isActiveClient)
8655 parent.numPositions--;
8656 if(state == minimized) parent.numIcons--;
8661 OldLink prevOrder = null;
8663 if(rootWindow == this)
8664 guiApp.interfaceDriver.SetRootWindowState(this, state, false);
8667 Box box { scrolledPos.x, scrolledPos.y, scrolledPos.x + size.w - 1, scrolledPos.y + size.h - 1 };
8670 box.left -= parent.clientStart.x;
8671 box.top -= parent.clientStart.y;
8672 box.right -= parent.clientStart.x;
8673 box.bottom -= parent.clientStart.y;
8677 if(style.modal && master && master.modalSlave == this)
8678 master.modalSlave = null;
8682 OldLink tmpPrev = order.prev;
8683 client = tmpPrev ? tmpPrev.data : null;
8684 if(client && !client.style.hidden && !client.destroyed && client.created)
8685 prevOrder = tmpPrev;
8688 client = tmpPrev ? tmpPrev.data : null;
8689 if(client == this) { client = null; break; }
8690 if(client && ((client.style.hidden) || client.destroyed || !client.created))
8692 tmpPrev = client.order.prev;
8697 prevOrder = tmpPrev;
8702 // If this window can be an active client, make sure the next window we activate can also be one
8703 if(!style.nonClient && style.isActiveClient)
8705 tmpPrev = prevOrder;
8708 client = tmpPrev ? tmpPrev.data : null;
8709 if(client == this) { client = null; break; }
8710 if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
8712 tmpPrev = client.order.prev;
8717 prevOrder = tmpPrev;
8721 if(client && client.style.hidden) client = null;
8725 if((parent.activeChild == this || guiApp.interimWindow == this) && true /*activate*/)
8727 if(order && prevOrder && prevOrder.data != this)
8728 ((Window)prevOrder.data).ActivateEx(true, false, false, true, null, null);
8730 ActivateEx(false, false, false, true, null, null);
8732 // TESTING THIS HERE FOR HIDING ACTIVE CLIENT
8733 if(parent.activeClient == this)
8735 parent.activeClient = null;
8736 parent.UpdateActiveDocument(null);
8739 else if(parent.activeClient == this)
8741 parent.activeClient = client;
8742 parent.UpdateActiveDocument(this);
8745 // *** Not doing this anymore ***
8748 parent.childrenCycle.Delete(cycle);
8750 parent.childrenOrder.Delete(order);
8755 if(style.isActiveClient && !value)
8757 if(state == minimized) parent.numIcons--;
8758 parent.numPositions--;
8760 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8765 else if(this && value && style.hidden)
8767 style.hidden = false;
8770 SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8771 if(rootWindow == this)
8772 guiApp.interfaceDriver.SetRootWindowState(this, state, true);
8774 if(style.modal && master)
8775 master.modalSlave = this;
8777 if(style.isActiveClient)
8779 positionID = parent.GetPositionID(this);
8780 parent.numPositions++;
8781 if(state == minimized) parent.numIcons++;
8784 // *** NOT DOING THIS ANYMORE ***
8786 if(!(style.inactive))
8788 if(!(style.noCycle))
8790 cycle = parent.childrenCycle.AddAfter(
8791 (parent.activeChild && parent.activeChild.cycle) ?
8792 parent.activeChild.cycle.prev : null, sizeof(OldLink));
8795 order = parent.childrenOrder.AddAfter(
8796 (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
8803 if(true || !parent.activeChild)
8804 ActivateEx(true, false, true, true, null, null);
8806 if(creationActivation == activate)
8807 ActivateEx(true, false, true, true, null, null);
8808 else if(creationActivation == flash && !object)
8811 //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
8815 ConsequentialMouseMove(false);
8822 get { return (style.hidden || !setVisible) ? false : true; }
8825 property bool isDocument
8827 property_category "Document"
8828 set { style.isDocument = value; }
8829 get { return style.isDocument; }
8832 property bool mergeMenus
8834 property_category "Window Style"
8835 set { mergeMenus = value; }
8836 get { return (bool)mergeMenus; }
8839 property bool hasHorzScroll
8841 property_category "Window Style"
8846 if(!style.hasHorzScroll && created)
8848 CreateSystemChildren();
8849 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8852 else if(style.hasHorzScroll)
8856 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8858 style.hasHorzScroll = value;
8861 get { return style.hasHorzScroll; }
8864 property bool hasVertScroll
8866 property_category "Window Style"
8871 if(!style.hasVertScroll && created)
8873 style.hasVertScroll = true;
8874 CreateSystemChildren();
8875 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8878 else if(style.hasVertScroll)
8882 Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
8884 style.hasVertScroll = value;
8886 get { return style.hasVertScroll; }
8889 property bool dontHideScroll
8891 property_category "Behavior"
8894 scrollFlags.dontHide = value;
8897 //UpdateScrollBars(true, true);
8898 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
8902 // UpdateScrollBars(true, true);
8903 Position(position.x, position.y, size.w, size.h, false, true, true, true, true, true);
8906 get { return scrollFlags.dontHide; }
8909 property bool dontScrollVert
8911 property_category "Behavior"
8912 set { style.dontScrollVert = value; }
8913 get { return style.dontScrollVert; }
8915 property bool dontScrollHorz
8917 property_category "Behavior"
8918 set { style.dontScrollHorz = value; }
8919 get { return style.dontScrollHorz; }
8922 property bool snapVertScroll
8924 property_category "Behavior"
8927 scrollFlags.snapY = value;
8928 if(sbv) sbv.snap = value;
8930 get { return scrollFlags.snapY; }
8932 property bool snapHorzScroll
8934 property_category "Behavior"
8937 scrollFlags.snapX = value;
8938 if(sbh) sbh.snap = value;
8940 get { return scrollFlags.snapX; }
8943 property Point scroll
8945 property_category "Behavior"
8949 // TESTING THIS IMPLEMENTATION:
8950 SetScrollPosition(value.x, value.y);
8952 get { value = scroll; }
8955 property bool modifyVirtualArea
8957 property_category "Behavior"
8958 set { modifyVirtArea = value; }
8959 get { return (bool)modifyVirtArea; }
8962 property char * fileName
8964 property_category "Document"
8967 if(menu && ((!fileName && value) || (fileName && !value)))
8969 MenuItem item = menu.FindItem(MenuFileSave, 0);
8970 if(item) item.disabled = !modifiedDocument && value;
8975 if(value && value[0])
8976 fileName = CopyString(value);
8978 if(parent && this == parent.activeClient)
8979 parent.UpdateActiveDocument(null);
8983 // if(style.isDocument)
8985 fileMonitor.fileName = value;
8987 get { return fileName; }
8992 property_category "Data"
8997 property bool modifiedDocument
8999 property_category "Document"
9002 if(style.isDocument || fileName)
9006 MenuItem item = menu.FindItem(MenuFileSave, 0);
9007 if(item) item.disabled = !value && fileName;
9011 if(modifiedDocument != value)
9013 modifiedDocument = value;
9014 if(style.isDocument || fileName)
9018 get { return (bool)modifiedDocument; }
9021 property bool showInTaskBar
9023 property_category "Window Style"
9024 set { style.showInTaskBar = value; }
9025 get { return (style.showInTaskBar; }
9027 property FileDialog saveDialog { set { saveDialog = value; } };
9028 property bool isActiveClient
9030 property_category "Behavior"
9031 set { style.isActiveClient = value; }
9032 get { return style.isActiveClient; }
9035 property Cursor cursor
9037 property_category "Appearance"
9041 SelectMouseCursor();
9043 get { return cursor; }
9046 //#if !defined(ECERE_VANILLA)
9047 property char * name
9049 property_category "Design"
9052 return (this && object) ? object.name : null;
9057 activeDesigner.RenameObject(object, value);
9061 property char * displayDriver
9063 property_category "Behavior"
9066 dispDriver = GetDisplayDriver(value);
9067 //DisplayModeChanged();
9071 return dispDriver ? dispDriver.name : null;
9075 // RUNTIME PROPERTIES
9076 property bool autoCreate { set { autoCreate = value; } get { return (bool)autoCreate; } };
9077 property Size scrollArea
9079 property_category "Behavior"
9083 SetScrollArea(value.w, value.h, false);
9085 SetScrollArea(0,0, true);
9087 get { value = scrollArea; }
9090 return scrollArea.w > clientSize.w || scrollArea.h > clientSize.h;
9095 property_category "Layout"
9096 set { if(this) is3D = value; }
9097 get { return (bool)is3D; }
9100 // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
9102 // Will be merged with font later
9103 property Font fontObject { get { return usedFont ? usedFont.font : null; } };
9104 property Point clientStart { get { value = clientStart; } };
9105 property Point absPosition { get { value = absPosition; } };
9106 property Anchor normalAnchor { get {value = normalAnchor; } };
9107 // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
9108 property bool active { get { return (bool)active; } };
9109 property bool created { get { return (bool)created; } };
9110 property bool destroyed { get { return (bool)destroyed; } };
9111 property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
9112 property Window firstChild { get { return children.first; } };
9113 property Window lastChild { get { return children.last; } };
9114 property Window activeClient { get { return activeClient; } };
9115 property Window activeChild { get { return activeChild; } };
9116 property Display display { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
9117 property DisplaySystem displaySystem { get { return display ? display.displaySystem : null; } };
9118 property ScrollBar horzScroll { get { return sbh; } };
9119 property ScrollBar vertScroll { get { return sbv; } };
9120 property StatusBar statusBar { get { return statusBar; } };
9121 property Window rootWindow { get { return rootWindow; } };
9122 property bool closing { get { return (bool)closing; } set { closing = value; } };
9123 property int documentID { get { return documentID; } };
9124 property Window previous { get { return prev; } }
9125 property Window next { get { return next; } }
9126 property Window nextSlave { get { OldLink link = master.slaves.FindLink(this); return (link && link.next) ? link.next.data : null; } }
9127 property PopupMenu menuBar { get { return menuBar; } }
9128 property ScrollBar sbv { get { return sbv; } }
9129 property ScrollBar sbh { get { return sbh; } }
9130 property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
9131 property void * systemHandle { get { return windowHandle; } }
9132 property Button minimizeButton { get { return sysButtons[0]; } };
9133 property Button maximizeButton { get { return sysButtons[1]; } };
9134 property Button closeButton { get { return sysButtons[2]; } };
9135 property BitmapResource icon
9137 get { return icon; }
9143 guiApp.interfaceDriver.SetIcon(this, value);
9146 property bool moveable { get { return (bool)moveable; } set { moveable = value; } };
9147 property bool alphaBlend { get { return (bool)alphaBlend; } set { alphaBlend = value; } };
9148 property bool useSharedMemory { get { return (bool)useSharedMemory; } set { useSharedMemory = value; } };
9149 property CreationActivationOption creationActivation { get { return creationActivation; } set { creationActivation = value; } };
9150 property bool nativeDecorations { get { return (bool)nativeDecorations && rootWindow == this; } set { nativeDecorations = value; } };
9151 property bool manageDisplay { get { return (bool)manageDisplay; } set { manageDisplay = value; } };
9157 WindowBits style; // Window Style
9158 char * caption; // Name / Caption
9159 Window parent; // Parent window
9160 OldList children; // List of children in Z order
9161 Window activeChild; // Child window having focus
9162 Window activeClient;
9163 Window previousActive; // Child active prior to activating the default child
9164 Window master; // Window owning and receiving notifications concerning this window
9165 OldList slaves; // List of windows belonging to this window
9166 Display display; // Display this window is drawn into
9168 Point position; // Position in parent window client area
9169 Point absPosition; // Absolute position
9170 Point clientStart; // Client area position from (0,0) in this window
9172 Size clientSize; // Client area size
9173 Size scrollArea; // Virtual Scroll area size
9174 Size reqScrollArea; // Requested virtual area size
9175 Point scroll; // Virtual area scrolling position
9176 public ScrollBar sbh, sbv; // Scrollbar window handles
9177 Cursor cursor; // Mouse cursor used for this window
9180 StatusBar statusBar;
9181 Button sysButtons[3];
9183 Box clientArea; // Client Area box clipped to parent
9185 HotKeySlot hotKey; // HotKey for this window
9189 ScrollFlags scrollFlags;// Window Scrollbar Flags
9190 int id; // Control ID
9192 ColorAlpha background; // Background color used to draw the window area
9194 subclass(DisplayDriver) dispDriver; // Display driver name for this window
9195 OldList childrenCycle; // Cycling order
9196 OldLink cycle; // Element of parent's cycling order
9197 OldList childrenOrder; // Circular Z-Order
9198 OldLink order; // Element of parent's circular Z-Order
9199 Window modalSlave; // Slave window blocking this window's interaction
9201 Window rootWindow; // Topmost system managed window
9202 void * windowHandle; // System window handle
9204 DialogResult returnCode;// Return code for modal windows
9206 Point sbStep; // Scrollbar line scrolling steps
9209 SizeAnchor stateSizeAnchor;
9211 Anchor normalAnchor;
9212 SizeAnchor normalSizeAnchor;
9214 Size skinMinSize; // Minimal window size based on style
9215 Point scrolledPos; // Scrolled position
9216 Box box; // Window box clipped to parent
9217 Box * against; // What to clip the box to
9219 Extent dirtyArea { /*first = -1, last = -1, free = -1*/ }; // Area marked for update by Update
9220 Extent renderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered
9221 Extent overRenderArea { /*first = -1, last = -1, free = -1*/ }; // Temporary extent: Area that is going to be rendered over children
9222 Extent clipExtent { /*first = -1, last = -1, free = -1*/ }; // Temporary extent against which to clip render area
9223 Extent scrollExtent { /*first = -1, last = -1, free = -1*/ }; // Area to scroll
9224 Point scrolledArea; // Distance to scroll area by
9225 Extent dirtyBack { /*first = -1, last = -1, free = -1*/ }; // Only used by root window
9227 OldList hotKeys; // List of the hotkeys of all children
9228 Window defaultControl; // Default child control
9232 ColorAlpha * palette; // Color palette used for this window
9234 int caretSize; // Size of caret, non zero if a caret is present
9235 Point caretPos; // Caret position
9237 void * systemParent; // Parent System Window for embedded windows
9244 WindowState lastState;
9246 FileMonitor fileMonitor
9248 this, FileChange { modified = true };
9250 bool OnFileNotify(FileChange action, char * param)
9253 fileMonitor.StopMonitoring();
9254 if(OnFileModified(action, param))
9255 fileMonitor.StartMonitoring();
9260 FontResource setFont, systemFont;
9261 FontResource usedFont;
9262 FontResource captionFont;
9264 FileDialog saveDialog;
9266 SizeAnchor sizeAnchor;
9268 // FormDesigner data
9271 Extent * tempExtents; //[4];
9272 BitmapResource icon;
9274 CreationActivationOption creationActivation;
9277 bool active:1; // true if window and ancestors are active
9278 bool acquiredInput:1; // true if the window is processing state based input
9279 bool modifiedDocument:1;
9280 bool disabled:1; // true if window cannot interact
9281 bool isForegroundWindow:1;// true while a root window is being activated
9282 bool visible:1; // Visibility flag
9283 bool destroyed:1; // true if window is being destroyed
9284 bool anchored:1; // true if this window is repositioned when the parent resizes
9285 bool dirty:1; // Flag set to true if any descendant must be redrawn
9291 bool modifyVirtArea:1;
9292 bool noAutoScrollArea:1;
9295 bool setVisible:1; // FOR FORM DESIGNER
9301 bool useSharedMemory:1;
9304 bool nativeDecorations:1;
9305 bool manageDisplay:1;
9308 WindowController controller;
9309 public property WindowController controller { get { return controller; } set { delete controller; controller = value; if(controller) incref controller; } }
9312 public class CommonControl : Window
9314 // creationActivation = doNothing;
9317 public class Percentage : float
9319 char * OnGetString(char * string, float * fieldData, bool * needClass)
9323 sprintf(string, "%.2f", this);
9324 c = strlen(string)-1;
9327 if(string[c] != '0')
9328 last = Max(last, c);
9329 if(string[c] == '.')
9342 public void ApplySkin(Class c, char * name, void ** vTbl)
9344 char className[1024];
9349 subclass(Window) wc = (subclass(Window))c;
9350 subclass(Window) base = (subclass(Window))c.base;
9352 sprintf(className, "%sSkin_%s", name, c.name);
9353 wc.pureVTbl = c._vTbl;
9354 c._vTbl = new void *[c.vTblSize];
9355 memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
9356 sc = eSystem_FindClass(c.module.application, className);
9360 for(m = 0; m < c.base.vTblSize; m++)
9362 if(c._vTbl[m] == base.pureVTbl[m])
9363 c._vTbl[m] = vTbl[m];
9368 for(m = 0; m < c.vTblSize; m++)
9370 if(sc._vTbl[m] != wc.pureVTbl[m])
9371 c._vTbl[m] = sc._vTbl[m];
9375 for(d = c.derivatives.first; d; d = d.next)
9377 ApplySkin(d.data, name, c._vTbl);
9381 public void UnapplySkin(Class c)
9383 char className[1024];
9385 subclass(Window) wc = (subclass(Window))c;
9386 subclass(Window) base = (subclass(Window))c.base;
9389 if(wc.pureVTbl && c._vTbl != wc.pureVTbl)
9392 c._vTbl = wc.pureVTbl;
9396 for(d = c.derivatives.first; d; d = d.next)
9398 UnapplySkin(d.data);
9402 void CheckFontIntegrity(Window window)
9407 if(window.usedFont && window.usedFont.font == 0xecececec)
9409 FontResource uf = window.usedFont;
9410 char * className = window._class.name;
9411 char * text = window.text;
9414 for(c = window.firstChild; c; c = c.next)
9415 CheckFontIntegrity(c);
9419 public class ControllableWindow : Window
9421 /*WindowController controller;
9422 public property WindowController controller { get { return controller; } set { delete controller; controller = value; incref controller; } }
9423 ~ControllableWindow() { delete controller; }*/
9426 class WindowControllerInterface : ControllableWindow
9428 bool OnKeyDown(Key key, unichar ch)
9430 bool result = ((int(*)())(void *)controller.OnKeyDown)((void *)controller.controlled, (void *)controller, key, ch);
9432 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown](controller.window, key, ch);
9436 bool OnKeyUp(Key key, unichar ch)
9438 bool result = ((int(*)())(void *)controller.OnKeyUp)((void *)controller.controlled, (void *)controller, key, ch);
9440 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyUp](controller.window, key, ch);
9444 bool OnKeyHit(Key key, unichar ch)
9446 bool result = ((int(*)())(void *)controller.OnKeyHit)((void *)controller.controlled, (void *)controller, key, ch);
9448 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyHit](controller.window, key, ch);
9452 bool OnMouseMove(int x, int y, Modifiers mods)
9454 bool result = ((int(*)())(void *)controller.OnMouseMove)((void *)controller.controlled, (void *)controller, x, y, mods);
9456 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove](controller.window, x, y, mods);
9460 bool OnLeftButtonDown(int x, int y, Modifiers mods)
9462 bool result = ((int(*)())(void *)controller.OnLeftButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9464 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown](controller.window, x, y, mods);
9468 bool OnLeftButtonUp(int x, int y, Modifiers mods)
9470 bool result = ((int(*)())(void *)controller.OnLeftButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9472 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp](controller.window, x, y, mods);
9476 bool OnLeftDoubleClick(int x, int y, Modifiers mods)
9478 bool result = ((int(*)())(void *)controller.OnLeftDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9480 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick](controller.window, x, y, mods);
9484 bool OnRightButtonDown(int x, int y, Modifiers mods)
9486 bool result = ((int(*)())(void *)controller.OnRightButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9488 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown](controller.window, x, y, mods);
9492 bool OnRightButtonUp(int x, int y, Modifiers mods)
9494 bool result = ((int(*)())(void *)controller.OnRightButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9496 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonUp](controller.window, x, y, mods);
9500 bool OnRightDoubleClick(int x, int y, Modifiers mods)
9502 bool result = ((int(*)())(void *)controller.OnRightDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9504 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightDoubleClick](controller.window, x, y, mods);
9508 bool OnMiddleButtonDown(int x, int y, Modifiers mods)
9510 bool result = ((int(*)())(void *)controller.OnMiddleButtonDown)((void *)controller.controlled, (void *)controller, x, y, mods);
9512 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonDown](controller.window, x, y, mods);
9516 bool OnMiddleButtonUp(int x, int y, Modifiers mods)
9518 bool result = ((int(*)())(void *)controller.OnMiddleButtonUp)((void *)controller.controlled, (void *)controller, x, y, mods);
9520 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleButtonUp](controller.window, x, y, mods);
9524 bool OnMiddleDoubleClick(int x, int y, Modifiers mods)
9526 bool result = ((int(*)())(void *)controller.OnMiddleDoubleClick)((void *)controller.controlled, (void *)controller, x, y, mods);
9528 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMiddleDoubleClick](controller.window, x, y, mods);
9532 void OnResize(int width, int height)
9534 ((int(*)())(void *)controller.OnResize)((void *)controller.controlled, (void *)controller, width, height);
9535 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnResize](controller.window, width, height);
9538 void OnRedraw(Surface surface)
9540 ((int(*)())(void *)controller.OnRedraw)((void *)controller.controlled, (void *)controller, surface);
9541 controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRedraw](controller.window, surface);
9546 bool result = ((int(*)())(void *)controller.OnCreate)((void *)controller.controlled, (void *)controller);
9548 result = controller.windowVTbl[__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnCreate](controller.window);
9553 public class WindowController<class V>
9556 property Window window
9560 uint size = class(Window).vTblSize;
9563 windowVTbl = new void *[size];
9564 memcpy(windowVTbl, value._vTbl, size * sizeof(void *));
9565 if(value._vTbl == value._class._vTbl)
9567 value._vTbl = new void *[value._class.vTblSize];
9568 memcpy(value._vTbl + size, value._class._vTbl + size, (value._class.vTblSize - size) * sizeof(void *));
9572 for(c = 0; c < size; c++)
9574 void * function = class(WindowControllerInterface)._vTbl[c];
9575 if(function != DefaultFunction)
9576 value._vTbl[c] = function;
9578 value._vTbl[c] = windowVTbl[c];
9583 memcpy(value._vTbl, windowVTbl, class(Window).vTblSize * sizeof(void *));
9586 get { return window; }
9588 property V controlled
9590 set { controlled = value; }
9591 get { return controlled; }
9593 virtual bool V::OnKeyDown(WindowController controller, Key key, unichar ch);
9594 virtual bool V::OnKeyUp(WindowController controller, Key key, unichar ch);
9595 virtual bool V::OnKeyHit(WindowController controller, Key key, unichar ch);
9596 virtual bool V::OnMouseMove(WindowController controller, int x, int y, Modifiers mods);
9597 virtual bool V::OnLeftButtonDown(WindowController controller, int x, int y, Modifiers mods);
9598 virtual bool V::OnLeftButtonUp(WindowController controller, int x, int y, Modifiers mods);
9599 virtual bool V::OnLeftDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9600 virtual bool V::OnRightButtonDown(WindowController controller, int x, int y, Modifiers mods);
9601 virtual bool V::OnRightButtonUp(WindowController controller, int x, int y, Modifiers mods);
9602 virtual bool V::OnRightDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9603 virtual bool V::OnMiddleButtonDown(WindowController controller, int x, int y, Modifiers mods);
9604 virtual bool V::OnMiddleButtonUp(WindowController controller, int x, int y, Modifiers mods);
9605 virtual bool V::OnMiddleDoubleClick(WindowController controller, int x, int y, Modifiers mods);
9606 virtual void V::OnResize(WindowController controller, int width, int height);
9607 virtual void V::OnRedraw(WindowController controller, Surface surface);
9608 virtual bool V::OnCreate(WindowController controller);
9611 int (** windowVTbl)();