Getting the width and height of a widget in gtk+-1.2



Hi!

Please CC your reply to my email address, as I am not subscribed. 
Thanks !

The task is simple enough:  Given any widget, determine its width and
height.  No, gdk_window_get_size doesn't help, because if the widget
does not have its own window, I get the size of one of its containers,
which is useless.

Here's the code I wrote:

void gtk_widget_get_size (GtkWidget *widget, int *pcx, int *pcy)
  {
  GtkArg arg ;
  arg.name = "width" ;
  gtk_widget_get (widget, &arg) ;
  *pcx = GTK_VALUE_INT (arg) ;
  arg.name = "height" ;
  gtk_widget_get (widget, &arg) ;
  *pcy = GTK_VALUE_INT (arg) ;
  }

I call this function during the configure_event of the main window.  The
widget I inquire about is a checkbox embedded in a VBox, embedded in a
viewport, embedded in a scrollwindow, embedded in a table, embedded in a
dialog box's vbox.

It returns -1 for both the width and the height, no matter how many
times the function is called (if I drag the window around, it gets
called a whole bunch of times).

I tried both GTK_VALUE_INT and GTK_VALUE_UINT.  Interestingly, even with
GTK_VALUE_UINT, the function still fills in *pcx and *pcy with -1.

My goal is this:
I have a dynamic list(VBox, really) of checkboxes which gets filled in
before the dialog box pops up.  I want to measure the width and height
of the checkboxes, then cause the width of the dialog box to become such
that the scrollwindow and the viewport can accomodate the widest
checkbox without a horizontal scrollbar.  I would like to do this
(preferably) before the dialog box becomes visible, so the user doesn't
experience a jerk when it pops up.



Thanks for all your help !




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