Re: [gtk-list] Drawing ???
- From: Owen Taylor <owt1 cornell edu>
- To: serge astro unc edu
- cc: gtk-list redhat com
- Subject: Re: [gtk-list] Drawing ???
- Date: Sun, 16 Nov 1997 18:13:28 -0500
> I am trying to draw in the drawing area but from what is written in the
> example scribble, it is not clear to me what one should do if he wants to
> draw a line or a circle or whatever. The code has gdk_draw_rectangle() and
> gtk_widget_draw(). What does the second do?
Hmmm, I assume that if you have scribble, you also have the
To quote a few relevant passages:
We've now seen how to keep the screen up to date with our pixmap, but
how do we actually draw interesting stuff on our pixmap? There are a
large number of calls in GTK's GDK library for drawing on
<em>drawables</em>. A drawable is simply something that can be drawn
upon. It can be a window, a pixmap, or a bitmap (a black and white
image). We've already seen two such calls above,
<tt>gdk_draw_rectangle()</tt> and <tt>gdk_draw_pixmap()</tt>. The
complete list is:
See the reference documentation or the header file
<tt><gdk/gdk.h></tt> for further details on these functions.
These functions all share the same first two arguments. The first
argument is the drawable to draw upon, the second argument is a
<em>graphics context</em> (GC).
After we draw the rectangle representing the brush onto the pixmap,
we call the function:
void gtk_widget_draw (GtkWidget *widget,
which notifies X that the area given by the <tt>area</tt> parameter
needs to be updated. X will eventually generate an expose event
(possibly combining the areas passed in several calls to
<tt>gtk_widget_draw()</tt>) which will cause our expose event handler
to copy the relevant portions to the screen.
(The expose handler could also draw things directly if you weren't
using a backing pixmap). If this doesn't explain things, maybe you
could be a bit more specific about what is confusing?
> One more thing. What event should I catch when a slider changes the value?
> I am writing an application which has to redraw the screen when a user changes
> values controlled by sliders.
gtk_signal_connect(GTK_RANGE(scale)->adjustment, "value_changed", ...)
] [Thread Prev