On Wed, Sep 03, 2008 at 06:30:25PM +0800, Lazy Fox wrote:
> /* How to get the widget's size before it has been shown?
> *
> * There are two "printf" statements below. I want to get the widget's
> size at the first printf.
> * How to do this?
> */
> #include <gtk/gtk.h>
>
> int main( int argc, char *argv[] )
> {
> GtkWidget *window;
> gtk_init (&argc, &argv);
>
> window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
> printf("width=%d \n", window->allocation.width); // return 1
> gtk_widget_show (window);
> printf("width=%d \n", window->allocation.width); // return 200
> gtk_main ();
> return 0;
> }
You can't do that. Depending on how widgets are packed together
the size must be calculated. That is just what gtk_widget_show
does. You can eaven change packeting in runtime. Then you must
make a new expose, where the size should be recalculated.
> _______________________________________________
> gtk-app-devel-list mailing list
> [EMAIL PROTECTED]
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
--
Göran Hasse
----------------------------------------------------------------
Göran Hasse email: [EMAIL PROTECTED] Tel: 019-450105
Raditex AB http://www.raditex.se
Planiavägen 15, 1tr Mob: 070-5530148
131 34 NACKA, SWEDEN OrgNr: 556240-0589
VAT: SE556240058901
------------------------------------------------------------------
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list