Re: getting the size of a drawing area
- From: Owen Taylor <otaylor redhat com>
- To: John C Atkeson <jcatkeson juno com>
- Cc: gtk-list redhat com
- Subject: Re: getting the size of a drawing area
- Date: 02 Dec 1999 13:20:33 -0500
John C Atkeson <jcatkeson@juno.com> writes:
>
> I'm using widget->allocation.width and .height to determine the shape
> of my drawing area at runtime, but am getting funny results.
>
> I set allocation.width and .height to 700x500 at startup - and they
> stick there for the entire life of the program, even after the user has
> resized the window/widget many times and the drawing_area is obviously no
> longer those proportions.
>
> How can one not be equal to the other?
Hrmmm, without sample code, I can't say.
First it is not allowed to touch allocation.width/height yourself.
That is the size that GTK+ gives the widget. Setting it yourself
doesn't make sense, and it will be overwritten.
Second, when your drawing area gets the new size, the following
code will be called:
=================
static void
gtk_drawing_area_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_DRAWING_AREA (widget));
g_return_if_fail (allocation != NULL);
widget->allocation = *allocation;
widget->allocation.width = MAX (1, widget->allocation.width);
widget->allocation.height = MAX (1, widget->allocation.height);
[...]
}
=================
This looks pretty much guaranteed to change the allocation to
me. My best guesses are that your drawing area is packed in
such a way that the drawing area isn't changing size when
the toplevel changes size or that there is some confusion
between allocation and requisition in your program.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]