Re: Widget's Fixed Size??
- From: Paul Davis <paul linuxaudiosystems com>
- To: jalqadir netscape net
- Cc: gtkmm-list gnome org
- Subject: Re: Widget's Fixed Size??
- Date: Sat, 07 Jan 2006 21:43:44 -0500
On Sat, 2006-01-07 at 21:34 -0500, jalqadir netscape net wrote:
> Is there a way to make a Gtk::Entry widget to have a fixed size? How
> do I do this?
any_widget.set_size_request (width_pixels, height_pixels);
width_pixels or height_pixels can be -1 to leave that dimension "unset".
but its generally a bad idea to do this without some knowledge of font
dimensions, hence you really want something more like:
void
Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const
gchar *text,
gint hpadding, gint vpadding)
{
int height = 0;
int width = 0;
w.ensure_style ();
w.create_pango_layout(text)->get_pixel_size (width, height);
height += vpadding;
width += hpadding;
w.set_size_request(width, height);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]