Re: [gtk-list] Drawing ???




> 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
accompanying text.

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:

<tscreen><verb>
gdk_draw_line ()
gdk_draw_rectangle ()
gdk_draw_arc ()
gdk_draw_polygon ()
gdk_draw_string ()
gdk_draw_text ()
gdk_draw_pixmap ()
gdk_draw_bitmap ()
gdk_draw_image ()
gdk_draw_points ()
gdk_draw_segments ()
</verb></tscreen>

See the reference documentation or the header file
<tt>&lt;gdk/gdk.h&gt;</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:

<tscreen><verb>
void       gtk_widget_draw                (GtkWidget           *widget,
					   GdkRectangle        *area);
</verb></tscreen>

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", ...)

Regards,
                                        Owen



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