Re: Re: dinamically sized messagebox

From: Date: Sat, 19 Oct 2002 12:57:04 +0000
Subject: Re: Re: dinamically sized messagebox
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2550@lists.php.net to get a copy of this message
> > I would like to put out a dinamically sized message box, with > > a GtkLabel displaying the message. The solutions I have received: | 1. Try attaching to configure_event for that GtkLabel. That way | you can capture the dimensions of the widget when it resizes | itself. [Andrei Zmievski] I have tried this and it seems it only resizes after it is displayed, and I was unable to set_usize() with effect after this. | 2. Compute the size by using a specified font. [Brad Montgomery] | | $message = "Multiline\nmessage"; | | $font = gdk::font_load( | '-*-helvetica-bold-r-normal--*-130-*-*-p-0-iso8859-1' | ); | $label_height = $font->height($message) + 6; | | $message_parts = explode("\n",$message); | $label_width = 100; | | foreach ($message_parts as $line) { | $width = $font->width($line); | if ($width > $label_width) { | $label_width = $width; | } | } | | $box_width = $label_width + 100; | $box_height = count($message_parts) * $label_height + 100; This will actually work, and may be used in some situations when you have more complex sizing requirements, but I only had a need to make a message box in the size of the label, so this seemed a bit overkill to me for that. | 3. My finding ;) GtkWindow resizes to show it's widgets, if | I don't set_usize() of the window, but leave it's size | dynamic for the applicaton. The only thing I needed | is to set is the window's border and container's padding | values to get what I wanted. :) Simple enough. I hope this summary will help people who will search the archives for solution to a similar question. Goba

« previous php.gtk.general (#2550) next »