Re: [gtk-list] Gtk--: setting visible len of Gtk_Entry fields



>I like to hav a Gtk_Entry field with visibility only 5 chars width,

   GdkFont *font;
   Gtk_Entry entry;

   .
   .
   .
   .

   font = entry->get_style().gtkobj()->font;

   entry.set_usize (gdk_string_width (font "WWWWW") + 15,
                    gdk_string_height (font,"W") + 15);

the " + 15" is my own preference for the padding around the 5-char string.
Note that the choice of "W" is significant - you would get different
results with, say, "l".

I await a nicer way of doing this, since I use this hack a lot for
spinbuttons. Its really gross, and there *ought* be to be a nicer
way.

>and if more of input it should autoscroll.

this happens automatically already. you can use Gtk_Entry::set_max_length() to
limit the total number of characters allowed in the Gtk_Entry.

>and how can I set the vertical spacing in a GTK_VBox ?

     vbox.set_homogenous (false);
     vbox.set_spacing (n_pixels_between_widgets_in_box);

--p



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