Difference in reported size width

View: New views
3 Messages — Rating Filter:   Alert me  

Difference in reported size width

by Jim Hunter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am wondering how to accurately get the width of an object prior to it getting rendered?

I have an object that I am 'building' that is a composite of a few controls (TextArea, Button, Label) and a few containers. Part of the object is a qx.ui.basic.Label that I need to know how wide it is to calculate some things. When I use this line, prior to rendering I get 69 as the width:

this.theCaption.getSizeHint()['width']

But if I issue that same call after it gets rendered, the width is reported as 62. So all of my calculations are off by 7. I am not changing the font of the label after creating it so that can't be the issue. Is there a better way to get the width of the label?

Thanks,
Jim


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Difference in reported size width

by Fabian Jakobs :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jim,

the size hint computes the preferred size of the widgets. This is
computed for each widget in the first pass of the layout process. The
second pass starts from the root widget and renders the widget based on
their size hints and the available size. That's why the size hint can
differ from the computed size. On way to get the computed size is
listening to the "resize" event. This event is fired after the final
size has been computed by the layout system.

I hope this helps,
Fabian

Jim Hunter schrieb:

> I am wondering how to accurately get the width of an object prior to
> it getting rendered?
>
> I have an object that I am 'building' that is a composite of a few
> controls (TextArea, Button, Label) and a few containers. Part of the
> object is a qx.ui.basic.Label that I need to know how wide it is to
> calculate some things. When I use this line, prior to rendering I get
> 69 as the width:
>
> this.theCaption.getSizeHint()['width']
>
> But if I issue that same call after it gets rendered, the width is
> reported as 62. So all of my calculations are off by 7. I am not
> changing the font of the label after creating it so that can't be the
> issue. Is there a better way to get the width of the label?
>
> Thanks,
> Jim



--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG - Web Technologies
Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
Telefon: +49 721 91374-6784
fabian.jakobs@...

Amtsgericht Montabaur / HRB 6484
Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
Aufsichtsratsvorsitzender: Michael Scheeren


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Re: Difference in reported size width

by Jim Hunter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, I had found a work around by doing my positioning in the 'appear' event and it seems to work without any noticeable movement of the controls. But I think I will take your advice and move that to the resize event instead.

Thanks,
Jim


On Fri, Jul 10, 2009 at 7:56 AM, Fabian Jakobs <fabian.jakobs@...> wrote:
Hi Jim,

the size hint computes the preferred size of the widgets. This is
computed for each widget in the first pass of the layout process. The
second pass starts from the root widget and renders the widget based on
their size hints and the available size. That's why the size hint can
differ from the computed size. On way to get the computed size is
listening to the "resize" event. This event is fired after the final
size has been computed by the layout system.

I hope this helps,
Fabian

Jim Hunter schrieb:
> I am wondering how to accurately get the width of an object prior to
> it getting rendered?
>
> I have an object that I am 'building' that is a composite of a few
> controls (TextArea, Button, Label) and a few containers. Part of the
> object is a qx.ui.basic.Label that I need to know how wide it is to
> calculate some things. When I use this line, prior to rendering I get
> 69 as the width:
>
> this.theCaption.getSizeHint()['width']
>
> But if I issue that same call after it gets rendered, the width is
> reported as 62. So all of my calculations are off by 7. I am not
> changing the font of the label after creating it so that can't be the
> issue. Is there a better way to get the width of the label?
>
> Thanks,
> Jim



--
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG - Web Technologies
Ernst-Frey-Straße 9 · DE-76135 Karlsruhe
Telefon: +49 721 91374-6784
fabian.jakobs@...

Amtsgericht Montabaur / HRB 6484
Vorstände: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas Gottschlich, Robert Hoffmann, Markus Huhn, Hans-Henning Kettler, Dr. Oliver Mauss, Jan Oetjen
Aufsichtsratsvorsitzender: Michael Scheeren


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@...
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel