Re: automatically resizing widgets properly



On Mon, 2003-06-23 at 07:49, Paul Davis wrote:
> >I'm in the middle of porting my gtk app to gtk2, and have been replacing 
> >set_usize calls to set_size_request, but I'm left thinking that there has 
> >to be a better way to do this...? the docs talk about the inherent 
> >duffness of forcing a widget size (i'm using lots of small gtk_entry's and 
> >want them between 20 and 50px wide as part of a table). Is there any way 
> >to make them automatically use any available space? if i don't set the 
> >size of the widget, they naturally come out at full default size, completely 
> >distorting the main UI.
> >
> >for example, I have a table like this:
> >
> >+-------------+--------+
> >| <--entry--> | toggle |
> >+-------------+--------+
> >| <-------entry------> |
> >+----------------------+
> >
> >the lower entry is full size, and the toggle will naturally shrink, but i 
> >then want the top entry to use all the remaining space in that table row.
> 
> the trick i generally use, and yes, i do consider it a trick, is to
> put elements that you don't want to expand beyond their normal size
> into a box of the correct orientation. in the above case:
> 
>      <--- entry -------><-hbox[toggle]->
>      <---------  entry ---------------->
> 
> for vertical layouts, use a vbox. if you'd grown up with TeX as your
> typesetting system of choice, this would all make sense :)

The normal widget to use for this is GtkAlignment. (Though I don't
think it answers the above question, which was about letting entries
get smaller than their normal minimum width, as I undestand it.)

> even so, i still have to use set_usize/set_size_request quite often,
> particularly to size any kind of textual display widget so that its
> wide enough to show the largest string i will ever put there without
> resizing dynamically, which looks really, really stupid in my
> programs. this also applies to compound widgets like spinbuttons. 

If you are doing this, you really, really need to check your program
with a wide range of font sizes to make sure that it still works.

Using set_set_request() occasionally is normal; you shouldn't have
to do it *frequently*. And GtkSpinbutton does pick a width based on
the range of values you set.

Regards,
 					Owen





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