1 /* ************************************************************************
3 qooxdoo - the new era of web development
8 2004-2007 1&1 Internet AG, Germany, http://www.1and1.org
11 LGPL: http://www.gnu.org/licenses/lgpl.html
12 EPL: http://www.eclipse.org/org/documents/epl-v10.php
13 See the LICENSE file in the project's top-level directory for details.
16 * Sebastian Werner (wpbasti)
17 * Andreas Ecker (ecker)
19 ************************************************************************ */
21 /* ************************************************************************
24 #embed(qx.widgettheme/window/*)
26 ************************************************************************ */
28 qx.OO.defineClass("qx.ui.window.Window", qx.ui.popup.Popup,
29 function(vCaption, vIcon, vWindowManager)
31 qx.ui.popup.Popup.call(this);
33 // ************************************************************************
35 // ************************************************************************
37 this.setMinWidth("auto");
38 this.setMinHeight("auto");
39 this.setAutoHide(false);
43 // ************************************************************************
45 // ************************************************************************
47 // Init Window Manager
48 this.setWindowManager(vWindowManager || qx.ui.window.Window.getDefaultWindowManager());
52 // ************************************************************************
53 // RESIZE AND MOVE FRAME
54 // ************************************************************************
56 var f = this._frame = new qx.ui.basic.Terminator;
57 f.setAppearance("window-resize-frame");
60 // ************************************************************************
62 // ************************************************************************
64 var l = this._layout = new qx.ui.layout.VerticalBoxLayout;
69 // ************************************************************************
71 // ************************************************************************
73 var cb = this._captionBar = new qx.ui.layout.HorizontalBoxLayout;
74 cb.setAppearance("window-captionbar");
78 // ************************************************************************
80 // ************************************************************************
84 var ci = this._captionIcon = new qx.ui.basic.Image(vIcon);
85 ci.setAppearance("window-captionbar-icon");
90 // ************************************************************************
92 // ************************************************************************
94 var ct = this._captionTitle = new qx.ui.basic.Label(vCaption);
95 ct.setAppearance("window-captionbar-title");
96 ct.setSelectable(false);
100 // ************************************************************************
102 // ************************************************************************
104 var cf = this._captionFlex = new qx.ui.basic.HorizontalSpacer;
108 // ************************************************************************
109 // CAPTIONBUTTONS: MINIMIZE
110 // ************************************************************************
112 var bm = this._minimizeButton = new qx.ui.form.Button(null, "widget/window/minimize.gif");
114 bm.setAppearance("window-captionbar-minimize-button");
117 bm.addEventListener("execute", this._onminimizebuttonclick, this);
118 bm.addEventListener("mousedown", this._onbuttonmousedown, this);
123 // ************************************************************************
124 // CAPTIONBUTTONS: RESTORE
125 // ************************************************************************
127 var br = this._restoreButton = new qx.ui.form.Button(null, "widget/window/restore.gif");
129 br.setAppearance("window-captionbar-restore-button");
132 br.addEventListener("execute", this._onrestorebuttonclick, this);
133 br.addEventListener("mousedown", this._onbuttonmousedown, this);
135 // don't add initially
139 // ************************************************************************
140 // CAPTIONBUTTONS: MAXIMIZE
141 // ************************************************************************
143 var bx = this._maximizeButton = new qx.ui.form.Button(null, "widget/window/maximize.gif");
145 bx.setAppearance("window-captionbar-maximize-button");
148 bx.addEventListener("execute", this._onmaximizebuttonclick, this);
149 bx.addEventListener("mousedown", this._onbuttonmousedown, this);
154 // ************************************************************************
155 // CAPTIONBUTTONS: CLOSE
156 // ************************************************************************
158 var bc = this._closeButton = new qx.ui.form.Button(null, "widget/window/close.gif");
160 bc.setAppearance("window-captionbar-close-button");
163 bc.addEventListener("execute", this._onclosebuttonclick, this);
164 bc.addEventListener("mousedown", this._onbuttonmousedown, this);
169 // ************************************************************************
171 // ************************************************************************
173 var p = this._pane = new qx.ui.layout.CanvasLayout;
175 p.setOverflow("hidden");
179 // ************************************************************************
181 // ************************************************************************
183 var sb = this._statusBar = new qx.ui.layout.HorizontalBoxLayout;
184 sb.setAppearance("window-statusbar");
187 // ************************************************************************
189 // ************************************************************************
191 var st = this._statusText = new qx.ui.basic.Label("Ready");
192 st.setAppearance("window-statusbar-text");
193 st.setSelectable(false);
197 // ************************************************************************
199 // ************************************************************************
201 this.setCaption(vCaption);
205 // ************************************************************************
207 // ************************************************************************
209 this.addEventListener("mousedown", this._onwindowmousedown, this);
210 this.addEventListener("mouseup", this._onwindowmouseup, this);
211 this.addEventListener("mousemove", this._onwindowmousemove, this);
212 this.addEventListener("click", this._onwindowclick, this);
215 // ************************************************************************
216 // EVENTS: CAPTIONBAR
217 // ************************************************************************
219 cb.addEventListener("mousedown", this._oncaptionmousedown, this);
220 cb.addEventListener("mouseup", this._oncaptionmouseup, this);
221 cb.addEventListener("mousemove", this._oncaptionmousemove, this);
222 cb.addEventListener("dblclick", this._oncaptiondblblick, this);
225 // ************************************************************************
227 // ************************************************************************
228 this.remapChildrenHandlingTo(this._pane);
236 ---------------------------------------------------------------------------
238 ---------------------------------------------------------------------------
242 Appearance of the widget
244 qx.OO.changeProperty({ name : "appearance", type : "string", defaultValue : "window" });
247 The windowManager to use for.
249 qx.OO.addProperty({ name : "windowManager", type : "object" });
252 If the window is active, only one window in a single qx.manager.object.WindowManager could
253 have set this to true at the same time.
255 qx.OO.addProperty({ name : "active", type : "boolean", defaultValue : false });
258 Should be window be modal (this disable minimize and maximize buttons)
260 qx.OO.addProperty({ name : "modal", type : "boolean", defaultValue : false });
263 Should be window be modal (this disable minimize and maximize buttons)
265 qx.OO.addProperty({ name : "mode", type : "string", defaultValue : null, possibleValues : [ "minimized", "maximized" ], allowNull : true });
268 The opener (button) of the window
270 qx.OO.addProperty({ name : "opener", type : "object" });
273 The text of the caption
275 qx.OO.addProperty({ name : "caption" });
278 The icon of the caption
280 qx.OO.addProperty({ name : "icon", type : "string" });
283 The text of the statusbar
285 qx.OO.addProperty({ name : "status", type : "string", defaultValue : "Ready" });
288 Should the close button be shown
290 qx.OO.addProperty({ name : "showClose", type : "boolean", defaultValue : true });
293 Should the maximize button be shown
295 qx.OO.addProperty({ name : "showMaximize", type : "boolean", defaultValue : true });
298 Should the minimize button be shown
300 qx.OO.addProperty({ name : "showMinimize", type : "boolean", defaultValue : true });
303 Should the statusbar be shown
305 qx.OO.addProperty({ name : "showStatusbar", type : "boolean", defaultValue : false });
308 Should the user have the ability to close the window
310 qx.OO.addProperty({ name : "allowClose", type : "boolean", defaultValue : true });
313 Should the user have the ability to maximize the window
315 qx.OO.addProperty({ name : "allowMaximize", type : "boolean", defaultValue : true });
318 Should the user have the ability to minimize the window
320 qx.OO.addProperty({ name : "allowMinimize", type : "boolean", defaultValue : true });
323 If the text (in the captionbar) should be visible
325 qx.OO.addProperty({ name : "showCaption", type : "boolean", defaultValue : true });
328 If the icon (in the captionbar) should be visible
330 qx.OO.addProperty({ name : "showIcon", type : "boolean", defaultValue : true });
333 If the window is resizeable
335 qx.OO.addProperty({ name : "resizeable", type : "boolean", defaultValue : true });
338 If the window is moveable
340 qx.OO.addProperty({ name : "moveable", type : "boolean", defaultValue : true });
343 The resize method to use
345 qx.OO.addProperty({ name : "resizeMethod", type : "string", defaultValue : "frame", possibleValues : [ "opaque", "lazyopaque", "frame", "translucent" ] });
348 The move method to use
350 qx.OO.addProperty({ name : "moveMethod", type : "string", defaultValue : "opaque", possibleValues : [ "opaque", "frame", "translucent" ] });
356 ---------------------------------------------------------------------------
358 ---------------------------------------------------------------------------
361 qx.ui.window.Window.getDefaultWindowManager = function()
363 if (!qx.ui.window.Window._defaultWindowManager) {
364 qx.ui.window.Window._defaultWindowManager = new qx.manager.object.WindowManager;
367 return qx.ui.window.Window._defaultWindowManager;
375 ---------------------------------------------------------------------------
377 ---------------------------------------------------------------------------
380 qx.Proto.getPane = function() {
384 qx.Proto.getCaptionBar = function() {
385 return this._captionBar;
388 qx.Proto.getStatusBar = function() {
389 return this._statusBar;
392 qx.Proto.close = function() {
396 qx.Proto.open = function(vOpener)
398 if (vOpener != null) {
399 this.setOpener(vOpener);
402 if (this.getCentered()) {
403 this.centerToBrowser();
409 qx.Proto.focus = function() {
410 this.setActive(true);
413 qx.Proto.blur = function() {
414 this.setActive(false);
417 qx.Proto.maximize = function() {
418 this.setMode("maximized");
421 qx.Proto.minimize = function() {
422 this.setMode("minimized");
425 qx.Proto.restore = function() {
437 ---------------------------------------------------------------------------
439 ---------------------------------------------------------------------------
442 qx.Proto._beforeAppear = function()
444 // Intentionally bypass superclass and call super.super._beforeAppear
445 qx.ui.layout.CanvasLayout.prototype._beforeAppear.call(this);
448 qx.manager.object.PopupManager.getInstance().update();
450 // Configure the focus root to be the current opened window
451 qx.event.handler.EventHandler.getInstance().setFocusRoot(this);
453 this.getWindowManager().add(this);
457 qx.Proto._beforeDisappear = function()
459 // Intentionally bypass superclass and call super.super._beforeDisappear
460 qx.ui.layout.CanvasLayout.prototype._beforeDisappear.call(this);
463 var vFocusRoot = qx.event.handler.EventHandler.getInstance().getFocusRoot();
464 if (vFocusRoot == this || this.contains(vFocusRoot)) {
465 qx.event.handler.EventHandler.getInstance().setFocusRoot(null);
468 // Be sure to disable any capturing inside invisible parts
469 // Is this to much overhead?
470 // Are there any other working solutions?
471 var vWidget = qx.event.handler.EventHandler.getInstance().getCaptureWidget();
472 if (vWidget && this.contains(vWidget)) {
473 vWidget.setCapture(false);
476 this.getWindowManager().remove(this);
477 this._makeInactive();
485 ---------------------------------------------------------------------------
487 ---------------------------------------------------------------------------
490 qx.Proto._minZIndex = 1e5;
492 qx.Proto._sendTo = function()
494 var vAll = qx.lang.Object.getValues(this.getWindowManager().getAll()).sort(qx.util.Compare.byZIndex);
495 var vLength = vAll.length;
496 var vIndex = this._minZIndex;
498 for (var i=0; i<vLength; i++) {
499 vAll[i].setZIndex(vIndex++);
509 ---------------------------------------------------------------------------
511 ---------------------------------------------------------------------------
514 qx.Proto._modifyActive = function(propValue, propOldValue, propData)
518 if (this.getFocused()) {
519 this.setFocused(false);
522 if (this.getWindowManager().getActiveWindow() == this) {
523 this.getWindowManager().setActiveWindow(null);
526 this.removeState("active");
527 this._captionBar.removeState("active");
532 // Also do this if gets inactive as this moved the focus outline
533 // away from any focused child.
534 if (!this.getFocusedChild()) {
535 this.setFocused(true);
538 this.getWindowManager().setActiveWindow(this);
541 this.addState("active");
542 this._captionBar.addState("active");
548 qx.Proto._modifyModal = function(propValue, propOldValue, propData)
551 if (this._initialLayoutDone && this.getVisibility() && this.getDisplay())
553 var vTop = this.getTopLevelWidget();
554 propValue ? vTop.block(this) : vTop.release(this);
560 qx.Proto._modifyAllowClose = function(propValue, propOldValue, propData) {
561 return this._closeButtonManager();
564 qx.Proto._modifyAllowMaximize = function(propValue, propOldValue, propData) {
565 return this._maximizeButtonManager();
568 qx.Proto._modifyAllowMinimize = function(propValue, propOldValue, propData) {
569 return this._minimizeButtonManager();
572 qx.Proto._modifyMode = function(propValue, propOldValue, propData)
588 this._restoreFromMaximized();
592 this._restoreFromMinimized();
600 qx.Proto._modifyShowCaption = function(propValue, propOldValue, propData)
604 this._captionBar.addAt(this._captionTitle, this.getShowIcon() ? 1 : 0);
608 this._captionBar.remove(this._captionTitle);
614 qx.Proto._modifyShowIcon = function(propValue, propOldValue, propData)
618 this._captionBar.addAtBegin(this._captionIcon);
622 this._captionBar.remove(this._captionIcon);
628 qx.Proto._modifyShowStatusbar = function(propValue, propOldValue, propData)
632 this._layout.addAtEnd(this._statusBar);
636 this._layout.remove(this._statusBar);
642 qx.Proto._modifyShowClose = function(propValue, propOldValue, propData)
646 this._captionBar.addAtEnd(this._closeButton);
650 this._captionBar.remove(this._closeButton);
656 qx.Proto._modifyShowMaximize = function(propValue, propOldValue, propData)
660 var t = this.getMode() == "maximized" ? this._restoreButton : this._maximizeButton;
662 if (this.getShowMinimize())
664 this._captionBar.addAfter(t, this._minimizeButton);
668 this._captionBar.addAfter(t, this._captionFlex);
673 this._captionBar.remove(this._maximizeButton);
674 this._captionBar.remove(this._restoreButton);
680 qx.Proto._modifyShowMinimize = function(propValue, propOldValue, propData)
684 this._captionBar.addAfter(this._minimizeButton, this._captionFlex);
688 this._captionBar.remove(this._minimizeButton);
694 qx.Proto._minimizeButtonManager = function()
696 this._minimizeButton.setEnabled(this.getAllowMinimize());
701 qx.Proto._closeButtonManager = function()
703 this._closeButton.setEnabled(this.getAllowClose());
708 qx.Proto._maximizeButtonManager = function()
710 var b = this.getAllowMaximize() && this.getResizeable() && this._computedMaxWidthTypeNull && this._computedMaxHeightTypeNull;
712 this._maximizeButton.setEnabled(b);
713 this._restoreButton.setEnabled(b);
718 qx.Proto._modifyStatus = function(propValue, propOldValue, propData)
720 this._statusText.setHtml(propValue);
725 qx.Proto._modifyMaxWidth = function(propValue, propOldValue, propData) {
726 return this._maximizeButtonManager();
729 qx.Proto._modifyMaxHeight = function(propValue, propOldValue, propData) {
730 return this._maximizeButtonManager();
733 qx.Proto._modifyResizeable = function(propValue, propOldValue, propData) {
734 return this._maximizeButtonManager();
737 qx.Proto._modifyCaption = function(propValue, propOldValue, propData)
739 this._captionTitle.setHtml(propValue);
748 ---------------------------------------------------------------------------
749 STATE LAYOUT IMPLEMENTATION
750 ---------------------------------------------------------------------------
753 qx.Proto._minimize = function()
759 qx.Proto._restoreFromMaximized = function()
761 // restore previous dimension and location
762 this.setLeft(this._previousLeft ? this._previousLeft : null);
763 this.setWidth(this._previousWidth ? this._previousWidth : null);
764 this.setRight(this._previousRight ? this._previousRight : null);
766 this.setTop(this._previousTop ? this._previousTop : null);
767 this.setHeight(this._previousHeight ? this._previousHeight : null);
768 this.setBottom(this._previousBottom ? this._previousBottom : null);
771 this.removeState("maximized");
774 if (this.getShowMaximize())
776 var cb = this._captionBar;
777 var v = cb.indexOf(this._restoreButton);
779 cb.remove(this._restoreButton);
780 cb.addAt(this._maximizeButton, v);
783 // finally focus the window
787 qx.Proto._restoreFromMinimized = function()
789 if (this.hasState("maximized"))
791 this.setMode("maximized");
798 qx.Proto._maximize = function()
800 if (this.hasState("maximized"))
805 // store current dimension and location
806 this._previousLeft = this.getLeft();
807 this._previousWidth = this.getWidth();
808 this._previousRight = this.getRight();
809 this._previousTop = this.getTop();
810 this._previousHeight = this.getHeight();
811 this._previousBottom = this.getBottom();
813 // setup new dimension and location
817 this.setHeight(null);
822 this.addState("maximized");
825 if (this.getShowMaximize())
827 var cb = this._captionBar;
828 var v = cb.indexOf(this._maximizeButton);
830 cb.remove(this._maximizeButton);
831 cb.addAt(this._restoreButton, v);
834 // finally focus the window
845 ---------------------------------------------------------------------------
847 ---------------------------------------------------------------------------
850 qx.Proto._onwindowmousedown = function(e)
854 if (this._resizeNorth || this._resizeSouth || this._resizeWest || this._resizeEast)
857 this.setCapture(true);
859 // activate global cursor
860 this.getTopLevelWidget().setGlobalCursor(this.getCursor());
863 var el = this.getElement();
865 // measuring and caching of values for resize session
866 var pa = this.getParent();
867 var pl = pa.getElement();
869 var l = qx.html.Location.getPageAreaLeft(pl);
870 var t = qx.html.Location.getPageAreaTop(pl);
871 var r = qx.html.Location.getPageAreaRight(pl);
872 var b = qx.html.Location.getPageAreaBottom(pl);
874 // handle frame and translucently
875 switch(this.getResizeMethod())
878 this.setOpacity(0.5);
884 if (f.getParent() != this.getParent())
886 f.setParent(this.getParent());
887 qx.ui.core.Widget.flushGlobalQueues();
890 f._applyRuntimeLeft(qx.html.Location.getPageBoxLeft(el) - l);
891 f._applyRuntimeTop(qx.html.Location.getPageBoxTop(el) - t);
893 f._applyRuntimeWidth(qx.html.Dimension.getBoxWidth(el));
894 f._applyRuntimeHeight(qx.html.Dimension.getBoxHeight(el));
896 f.setZIndex(this.getZIndex() + 1);
901 // create resize session
902 var s = this._resizeSession = {};
904 if (this._resizeWest)
906 s.boxWidth = qx.html.Dimension.getBoxWidth(el);
907 s.boxRight = qx.html.Location.getPageBoxRight(el);
910 if (this._resizeWest || this._resizeEast)
912 s.boxLeft = qx.html.Location.getPageBoxLeft(el);
914 s.parentAreaOffsetLeft = l;
915 s.parentAreaOffsetRight = r;
917 s.minWidth = this.getMinWidthValue();
918 s.maxWidth = this.getMaxWidthValue();
921 if (this._resizeNorth)
923 s.boxHeight = qx.html.Dimension.getBoxHeight(el);
924 s.boxBottom = qx.html.Location.getPageBoxBottom(el);
927 if (this._resizeNorth || this._resizeSouth)
929 s.boxTop = qx.html.Location.getPageBoxTop(el);
931 s.parentAreaOffsetTop = t;
932 s.parentAreaOffsetBottom = b;
934 s.minHeight = this.getMinHeightValue();
935 s.maxHeight = this.getMaxHeightValue();
940 // cleanup resize session
941 delete this._resizeSession;
948 qx.Proto._onwindowmouseup = function(e)
950 var s = this._resizeSession;
955 this.setCapture(false);
957 // deactivate global cursor
958 this.getTopLevelWidget().setGlobalCursor(null);
960 // sync sizes to frame
961 switch(this.getResizeMethod())
965 if (!(o && o.getParent())) {
971 if (s.lastLeft != null) {
972 this.setLeft(s.lastLeft);
975 if (s.lastTop != null) {
976 this.setTop(s.lastTop);
979 if (s.lastWidth != null) {
980 this.setWidth(s.lastWidth);
983 if (s.lastHeight != null) {
984 this.setHeight(s.lastHeight);
987 if (this.getResizeMethod() == "frame") {
988 this._frame.setParent(null);
993 this.setOpacity(null);
998 delete this._resizeNorth;
999 delete this._resizeEast;
1000 delete this._resizeSouth;
1001 delete this._resizeWest;
1003 delete this._resizeSession;
1007 e.stopPropagation();
1010 qx.Proto._near = function(p, e) {
1011 return e > (p - 5) && e < (p + 5);
1014 qx.Proto._onwindowmousemove = function(e)
1016 if (!this.getResizeable() || this.getMode() != null) {
1020 var s = this._resizeSession;
1024 if (this._resizeWest)
1026 s.lastWidth = qx.lang.Number.limit(s.boxWidth + s.boxLeft - Math.max(e.getPageX(), s.parentAreaOffsetLeft), s.minWidth, s.maxWidth);
1027 s.lastLeft = s.boxRight - s.lastWidth - s.parentAreaOffsetLeft;
1029 else if (this._resizeEast)
1031 s.lastWidth = qx.lang.Number.limit(Math.min(e.getPageX(), s.parentAreaOffsetRight) - s.boxLeft, s.minWidth, s.maxWidth);
1034 if (this._resizeNorth)
1036 s.lastHeight = qx.lang.Number.limit(s.boxHeight + s.boxTop - Math.max(e.getPageY(), s.parentAreaOffsetTop), s.minHeight, s.maxHeight);
1037 s.lastTop = s.boxBottom - s.lastHeight - s.parentAreaOffsetTop;
1039 else if (this._resizeSouth)
1041 s.lastHeight = qx.lang.Number.limit(Math.min(e.getPageY(), s.parentAreaOffsetBottom) - s.boxTop, s.minHeight, s.maxHeight);
1044 switch(this.getResizeMethod())
1048 if (this._resizeWest || this._resizeEast)
1050 this.setWidth(s.lastWidth);
1052 if (this._resizeWest) {
1053 this.setLeft(s.lastLeft);
1057 if (this._resizeNorth || this._resizeSouth)
1059 this.setHeight(s.lastHeight);
1061 if (this._resizeNorth) {
1062 this.setTop(s.lastTop);
1069 var o = this.getResizeMethod() == "frame" ? this._frame : this;
1071 if (this._resizeWest || this._resizeEast)
1073 o._applyRuntimeWidth(s.lastWidth);
1075 if (this._resizeWest) {
1076 o._applyRuntimeLeft(s.lastLeft);
1080 if (this._resizeNorth || this._resizeSouth)
1082 o._applyRuntimeHeight(s.lastHeight);
1084 if (this._resizeNorth) {
1085 o._applyRuntimeTop(s.lastTop);
1092 var resizeMode = "";
1093 var el = this.getElement();
1095 this._resizeNorth = this._resizeSouth = this._resizeWest = this._resizeEast = false;
1097 if (this._near(qx.html.Location.getPageBoxTop(el), e.getPageY()))
1100 this._resizeNorth = true;
1102 else if (this._near(qx.html.Location.getPageBoxBottom(el), e.getPageY()))
1105 this._resizeSouth = true;
1108 if (this._near(qx.html.Location.getPageBoxLeft(el), e.getPageX()))
1111 this._resizeWest = true;
1113 else if (this._near(qx.html.Location.getPageBoxRight(el), e.getPageX()))
1116 this._resizeEast = true;
1119 if (this._resizeNorth || this._resizeSouth || this._resizeWest || this._resizeEast)
1121 this.setCursor(resizeMode + "-resize");
1125 this.setCursor(null);
1130 e.stopPropagation();
1133 qx.Proto._onwindowclick = function(e)
1136 e.stopPropagation();
1144 ---------------------------------------------------------------------------
1146 ---------------------------------------------------------------------------
1149 qx.Proto._onbuttonmousedown = function(e) {
1150 e.stopPropagation();
1153 qx.Proto._onminimizebuttonclick = function(e)
1157 // we need to be sure that the button gets the right states after clicking
1158 // because the button will move and does not get the mouseup event anymore
1159 this._minimizeButton.removeState("pressed");
1160 this._minimizeButton.removeState("abandoned");
1161 this._minimizeButton.removeState("over");
1163 e.stopPropagation();
1166 qx.Proto._onrestorebuttonclick = function(e)
1170 // we need to be sure that the button gets the right states after clicking
1171 // because the button will move and does not get the mouseup event anymore
1172 this._restoreButton.removeState("pressed");
1173 this._restoreButton.removeState("abandoned");
1174 this._restoreButton.removeState("over");
1176 e.stopPropagation();
1179 qx.Proto._onmaximizebuttonclick = function(e)
1183 // we need to be sure that the button gets the right states after clicking
1184 // because the button will move and does not get the mouseup event anymore
1185 this._maximizeButton.removeState("pressed");
1186 this._maximizeButton.removeState("abandoned");
1187 this._maximizeButton.removeState("over");
1189 e.stopPropagation();
1192 qx.Proto._onclosebuttonclick = function(e)
1196 // we need to be sure that the button gets the right states after clicking
1197 // because the button will move and does not get the mouseup event anymore
1198 this._closeButton.removeState("pressed");
1199 this._closeButton.removeState("abandoned");
1200 this._closeButton.removeState("over");
1202 e.stopPropagation();
1212 ---------------------------------------------------------------------------
1214 ---------------------------------------------------------------------------
1217 qx.Proto._oncaptionmousedown = function(e)
1219 if (!e.isLeftButtonPressed() || !this.getMoveable() || this.getMode() != null) {
1224 this._captionBar.setCapture(true);
1227 var el = this.getElement();
1229 // measuring and caching of values for drag session
1230 var pa = this.getParent();
1231 var pl = pa.getElement();
1233 var l = qx.html.Location.getPageAreaLeft(pl);
1234 var t = qx.html.Location.getPageAreaTop(pl);
1235 var r = qx.html.Location.getPageAreaRight(pl);
1236 var b = qx.html.Location.getPageAreaBottom(pl);
1240 offsetX : e.getPageX() - qx.html.Location.getPageBoxLeft(el) + l,
1241 offsetY : e.getPageY() - qx.html.Location.getPageBoxTop(el) + t,
1243 parentAvailableAreaLeft : l + 5,
1244 parentAvailableAreaTop : t + 5,
1245 parentAvailableAreaRight : r - 5,
1246 parentAvailableAreaBottom : b - 5
1249 // handle frame and translucently
1250 switch(this.getMoveMethod())
1253 this.setOpacity(0.5);
1257 var f = this._frame;
1259 if (f.getParent() != this.getParent())
1261 f.setParent(this.getParent());
1262 qx.ui.core.Widget.flushGlobalQueues();
1265 f._applyRuntimeLeft(qx.html.Location.getPageBoxLeft(el) - l);
1266 f._applyRuntimeTop(qx.html.Location.getPageBoxTop(el) - t);
1268 f._applyRuntimeWidth(qx.html.Dimension.getBoxWidth(el));
1269 f._applyRuntimeHeight(qx.html.Dimension.getBoxHeight(el));
1271 f.setZIndex(this.getZIndex() + 1);
1277 qx.Proto._oncaptionmouseup = function(e)
1279 var s = this._dragSession;
1285 // disable capturing
1286 this._captionBar.setCapture(false);
1288 // move window to last position
1289 if (s.lastX != null) {
1290 this.setLeft(s.lastX);
1293 if (s.lastY != null) {
1294 this.setTop(s.lastY);
1297 // handle frame and translucently
1298 switch(this.getMoveMethod())
1301 this.setOpacity(null);
1305 this._frame.setParent(null);
1310 delete this._dragSession;
1313 qx.Proto._oncaptionmousemove = function(e)
1315 var s = this._dragSession;
1317 // pre check for active session and capturing
1318 if (!s || !this._captionBar.getCapture()) {
1322 // pre check if we go out of the available area
1323 if (!qx.lang.Number.isBetweenRange(e.getPageX(), s.parentAvailableAreaLeft, s.parentAvailableAreaRight) || !qx.lang.Number.isBetweenRange(e.getPageY(), s.parentAvailableAreaTop, s.parentAvailableAreaBottom)) {
1327 // use the fast and direct dom methods
1328 var o = this.getMoveMethod() == "frame" ? this._frame : this;
1330 o._applyRuntimeLeft(s.lastX = e.getPageX() - s.offsetX);
1331 o._applyRuntimeTop(s.lastY = e.getPageY() - s.offsetY);
1334 qx.Proto._oncaptiondblblick = function()
1336 if (!this._maximizeButton.getEnabled()) {
1340 return this.getMode() == "maximized" ? this.restore() : this.maximize();
1351 ---------------------------------------------------------------------------
1353 ---------------------------------------------------------------------------
1356 qx.Proto.dispose = function()
1358 if (this.getDisposed()) {
1364 this._layout.dispose();
1365 this._layout = null;
1370 this._frame.dispose();
1374 if (this._captionBar)
1376 this._captionBar.dispose();
1377 this._captionBar = null;
1380 if (this._captionIcon)
1382 this._captionIcon.dispose();
1383 this._captionIcon = null;
1386 if (this._captionTitle)
1388 this._captionTitle.dispose();
1389 this._captionTitle = null;
1392 if (this._captionFlex)
1394 this._captionFlex.dispose();
1395 this._captionFlex = null;
1398 if (this._closeButton)
1400 this._closeButton.dispose();
1401 this._closeButton = null;
1404 if (this._minimizeButton)
1406 this._minimizeButton.dispose();
1407 this._minimizeButton = null;
1410 if (this._maximizeButton)
1412 this._maximizeButton.dispose();
1413 this._maximizeButton = null;
1416 if (this._restoreButton)
1418 this._restoreButton.dispose();
1419 this._restoreButton = null;
1424 this._pane.dispose();
1428 if (this._statusBar)
1430 this._statusBar.dispose();
1431 this._statusBar = null;
1434 if (this._statusText)
1436 this._statusText.dispose();
1437 this._statusText = null;
1440 return qx.ui.popup.Popup.prototype.dispose.call(this);