Yup again ;-)

Here is the patch:

now you can simply setCenter(true) for automatic centering on open or just call centerToBrowser()

Regards.

Sebastian Werner schrieb:

Dietrich Streifert schrieb:

Yep back ;-) Here it is:

proto.centerToBrowser = function() {
 var d = window.application.getClientWindow().getClientDocument();
 this.setLeft(d.getClientWidth()/2-this.getBoxWidth() /2);
 this.setTop(d.getClientHeight()/2-this.getBoxHeight() /2);
}

How about creating a property "center" (boolean) which (if set to true) centers the window on open:

proto.open = function(vOpener)
{
 if (QxUtil.isValid(vOpener)) {
   this.setOpener(vOpener);
 };

 if ( this.getCenter()) {
   this.centerToBrowser();
 }

 this.show();
};


If you create a patch and test it a bit that would be great.

Sebastian



Regards.


Sebastian Werner schrieb:

Dietrich Streifert schrieb:

So I have no idea where to start from.

The call to this.getWidth() and this.getHeight() should be replaced by a QxDom call.



yep.

QxDom.getComputedBoxWidth(this.getElement());

But this only works on widgets which are already created.

Also you can try, which should also work on non-created widgets to do a (this should also be faster):

this.getBoxWidth()

Sebastian


Give me a hint.

Thank you.

Sebastian Werner schrieb:

Dietrich Streifert schrieb:

Well I have such a method for QxWindow. But it works only if the width and height of the QxWindow is not set to auto:

QxWindow.prototype.centerToBrowser = function() {
 var d = window.application.getClientWindow().getClientDocument();
 this.setLeft(d.getClientWidth()/2-this.getWidth()/2);
 this.setTop(d.getClientHeight()/2-this.getHeight()/2);
}




You could also use the QxDom methods to get the correct sizes even on auto or percent sized windows.

Sebastian



My original Idea was to have a value 'center' or 'middle' for the left and top attribute so the queue can calculate the correct values at rendering time. More accurate we would have a centerTop and centerLeft attribute which are settable to 'center'.

But this would of course require additional implementation efforts in the rendering queue.

For now I'm using the above.


Oliver Vogel schrieb:

@sebastian
i am often using a Qxwindow "inside" a "normal" - Browser window.
the best way to position such a window is in the middle of the "document" of the "normal" window (i hope you can understand, what i mean)

so my question:
what about a centerToParent() or better centerToBrowserWIndow() function which centers the QxWindow in the middle of the Browser-Deocument?

Olli



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel








-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel







-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel






-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


--
Mit freundlichen Grüßen
Dietrich Streifert
Visionet GmbH

--- source/script/widgets/QxWindow.js.orig      Thu Dec  1 13:17:02 2005
+++ source/script/widgets/QxWindow.js   Thu Dec  1 13:47:47 2005
@@ -375,11 +375,14 @@
 */
 QxWindow.addProperty({ name : "moveMethod", type : QxConst.TYPEOF_STRING, 
defaultValue : "opaque", possibleValues : [ "opaque", "frame", "translucent" ] 
});
 
+/*!
+  Center the window on open
+*/
+QxWindow.addProperty({ name : "center", type : QxConst.TYPEOF_BOOLEAN, 
defaultValue : false });
 
 
 
 
-
 /*
 
------------------------------------------------------------------------------------
   STRINGS
@@ -421,6 +424,12 @@
   this.hide();
 };
 
+proto.centerToBrowser = function() {
+ var d = window.application.getClientWindow().getClientDocument();
+ this.setLeft(d.getClientWidth()/2-this.getBoxWidth()/2);
+ this.setTop(d.getClientHeight()/2-this.getBoxHeight()/2);
+};
+
 proto.open = function(vOpener)
 {
   if (QxUtil.isValid(vOpener)) {
@@ -427,6 +436,10 @@
     this.setOpener(vOpener);
   };
 
+  if (this.getCenter()) {
+    this.centerToBrowser();
+  };
+
   this.show();
 };
 
@@ -451,10 +464,6 @@
 };
 
 
-
-
-
-
 
 /*
 
------------------------------------------------------------------------------------
@@ -1406,4 +1415,4 @@
   };
 
   return QxPopup.prototype.dispose.call(this);
-};
+};

Reply via email to