Re: Please explain 1st arg of configure & expose event functions...



On Wed, Feb 06, 2002 at 10:06:24AM -0500, Paul Davis wrote:
> >Examples of configure and expose event functions
> >have a mysterious GtkWidget for the first arg.
> >I cannot seem to discern what it is.
> 
> often, a signal is emitted because of an event occuring in/on the
> widget. the handler(s) for the signal receive a pointer to the widget
> as their first argument. this allows them to know which widget they
> are dealing with (since the same function might be used to handle
> similar signals for many different widgets).
> 
> >What is all this widget->allocation.height, widget->window stuff and where
> >did it come from and why is it useful?
> 
> if you are going to do "low level" drawing in a widget, you need to
> know how big the widget is, and you need access to the GdkWindow that
> is actually the object in which drawing occurs. these are members of
> all GtkWidgets (though the GdkWindow member is only valid after the
> widget has been realized - it corresponds (when using XWindow) to an
> actual X window).
> 
> --p

P.

Thanks again!
This widget that is the first argument seems to be the window
that _contains_ the pixmap drawing from what you are saying.
I'm confused because some elements of this window object
are used to give information about the _pixmap_?!?!?

Let me explain if you don't mind...

I know that following command ends up drawing a rectangle in the pixmap
which is NOT the same size as the window it is in.  Yet, notice
that all dimensions given are the dimensions of the window?!?!?
(This is inside a configure event signal handler so widget
is the first arg we are talking about.)

   gdk_draw_rectangle(Pixmaps::middleMassTimeSeriesPlot,
      widget->style->black_gc, TRUE, 0, 0,
      widget->allocation.width, widget->allocation.height);

And...

The following command redraws a pixmap after an expose event.  Notice the second
argument seems to be saying "Use the style of the widget (window)".
Shouldn't we be using the "style" of the pixmap??  (By the way, unrelated:
why do we need event->area.x * event->area.y args twice?)

   gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
      Pixmaps::powerSpectralDensityPlot, event->area.x, event->area.y,
      event->area.x, event->area.y, event->area.width, event->area.height);


Chris

-- 
=======================================================
| Dr. Christian Seberino  || (619) 553-7940  (office) |
| SPAWARSYSCEN 2363       || (619) 553-2836  (fax)    |
| 53560 HULL ST           ||                          |
| SAN DIEGO CA 92152-5001 || seberino spawar navy mil |
=======================================================



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