Re: Shrinking entry boxes?



A combo box with an input
list whose longest value is perhaps 6-7 characters will end up
large enough to hold over 20 characters.  Combo boxes that contain
only integer values ranging up to 200 or so will *still* be about
20 characters wide, even though only 3-4 are needed.  Is there
some way to manually force these things to only be N characters or
perhaps N pixels wide?

You can set the width of an entry to the width of 
a given string, as for example "01234567890123456789" 
(this is even better than specifying a number of characters),
with this code:

gtk_widget_set_usize (entry, gdk_string_width (entry->style->font,
"01234567890123456789") + entry->style->klass->xthickness, 0);

You can also set the width of a combo box to, 
say, 60 pixels, with this code:

combo = gtk_combo_new ();
gtk_widget_set_usize (GTK_WIDGET (combo), 60, 0);

As part of a combo box is an entry, you should be able to
use both methods. With the second method you must be carefull
about the width you use, think about themes, different fonts,
of course you need to guarantee that the width is always big enough.
You can use the second method with buttons, option_menus, etc...
In windows, because they can increase, gtk_widget_set_usize
actually sets the minimum window size, not necessarily the 
current window size.

Carlos




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