Uh, there was a bug in the code. Here it is again, packaged as a mixin:

/* ************************************************************************

   qcl - the qooxdoo component library
  
   http://qooxdoo.org/contrib/project/qcl/
  
   Copyright:
     2007-2009 Christian Boulanger
  
   License:
     LGPL: http://www.gnu.org/licenses/lgpl.html
     EPL: http://www.eclipse.org/org/documents/epl-v10.php
     See the LICENSE file in the project's top-level directory for details.
  
   Authors:
   *  Christian Boulanger (cboulanger)
  
************************************************************************ */


/**
 * A mixin that provides a "Loading..." popup over a widget that is 
 * just requesting data from the server
 */
qx.Mixin.define("qcl.ui.MLoadingPopup",
{
  
  members:
  {
    __loadingPopup : null,
    
     /**
      * Creates the popup
      */
     createPopup : function()
     {
        this.__loadingPopup = new qx.ui.popup.Popup(new
qx.ui.layout.Canvas()).set({
          decorator: "group",
          width : 100,
          height : 50,
          padding : 10
        });
        this.__loadingPopup.add( new qx.ui.basic.Atom("Loading...",
"bibliograph/ajax-loader.gif") );
     },
     
     /**
      * Shows the popup centered over the widget
      * @param widget {qx.ui.core.Widget}
      */
     showPopup : function( widget )
     {
       var p = this.__loadingPopup;
       var c,l,t,w,h;
       if ( widget  ) 
       {
          c = widget.getContentLocation();
          if ( c )
          {
            var w = c.right - c.left;
            var h = c.bottom - c.top;
            l = Math.floor( c.left + ( w / 2) - ( p.getWidth() / 2 ) ); 
            t = Math.floor( c.top + ( h / 2) - ( p.getHeight() / 2) );
          }
       }
       if ( widget && l && t)
       {
         p.placeToPoint({left: l, top: t}); // we have valid paramters 
       }
       else
       {
         l =  Math.floor( ( qx.bom.Document.getWidth() / 2 ) - (
p.getWidth() / 2 ) );
         t =  Math.floor( ( qx.bom.Document.getHeight() / 2 ) - (
p.getHeight() / 2 ) );
         p.placeToPoint({left: l, top: t}); // place it in the middle of the
screen 
       }
       p.show();      
     },
     
     /**
      * Hides the widget
      */
     hidePopup : function()
     {
       this.__loadingPopup.hide();
     }
   },

   /**
    * Destructor
    */
  destruct : function() {
    this._disposeObjects("__loadingPopup");
  }   
});
-- 
View this message in context: 
http://n2.nabble.com/Center-a-popup-over-a-widget-tp4925313p4926206.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to