Re: [gtk-list] Re: getting the widget size



On Wed, 3 Jun 1998, Michael J. Hammel wrote:

> In a previous message, Tim Janik says:
> > 
> > On Wed, 3 Jun 1998, Kevin Pearson wrote:
> > 
> > > Hello,
> > > 
> > > Is there a function or way to get the widget size?
> > > 
> > > opposite of gtk_widget_set_usize()?
> > 
> > printf ("widget <%s> size: width=%d, height=%d\n",
> >         gtk_type_name (GTK_OBJECT_TYPE (widget)),
> >         widget->allocation.width,
> >         widget->allocation.height);
> 
> What the difference between this and 
> 
>      GtkRequisition attributes;
>      gtk_widget_size_request(w, &attributes);
>      width = attributes.width;
>      height = attributes.height;
> 
> I've been using the latter instead of the allocation.width/height settings.
> It seems to work ok, but maybe its not what I really want.

widget->requisition holds width and height that a widget would like
to have.
widget->allocation holds the width/height that the widget actually got
allocated.
e.g. imagine a homogenous hbox with two children that request different
widths:

+---------------------------------------------------------+
| +-------------------------+ +-------------------------+ |
| |<--requested width-->|   | |<--- requested width --->| |
| |                         | |          equals         | |
| |<--- allocated width --->| |<--- allocated width --->| |
| +-------------------------+ +-------------------------+ |
+---------------------------------------------------------+

in this case the first child's allocation is bigger (in width) than its
requisition, because the per-child width of a homogenous hbox is the
maximum width of all its visible children.

> -- 
> Michael J. Hammel           |Webster's definition of Win95: 32bit extensions and
> The Graphics Muse           |graphical shell for a 16bit patch to an 8bit OS 
> mjhammel@graphics-muse.org  |originally coded for a 4bit cpu, written by a 2 bit
> http://www.graphics-muse.org  company, that can't stand 1 bit of competition.
> 
> 

---
ciaoTJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]