Re: [gtk-list] Re: Is Gtk_DrawingArea in gtk-- usable?
- From: Tero Pulkkinen <terop students cc tut fi>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Is Gtk_DrawingArea in gtk-- usable?
- Date: 02 Feb 1998 11:20:55 +0200
> Jon Trowbridge <trow@emccta.com> writes:
> > It is possible to construct a drawing area widget in gtk--, but
> > how do I go about actually drawing into it? I'm an X/gtk/gtk--
> > programming newbie, so going to the source just confused me further...
You'll need to use the C interface for this. I hope eventually we get the
C++ interface for gdk ready to help make this easier, but currently
the C interface is fine and works.
Rob Browning <rlb@cs.utexas.edu> writes:
> I'm completely unfamiliar with gtk--, but assuming plain gtk, and
> assuming that you can get a drawing area widget created (see the
> tutorial and the testgtk program for general widget info), you just
> need to put the drawing calls you want in the expose function. Here's
> some trivial (and untested) bits:
>
> static gint
> my_expose (GtkWidget *widget, GdkEventExpose *event, gpointer my_data)
> {
> gdk_draw_arc(GTK_WIDGET(widget)->window, my_gc, TRUE,
> my_x, my_y, my_width, my_height,
> my_start_angle, my_sweep_angle);
> return TRUE;
> }
In gtk-- you can just override the expose_event_impl virtual function - just
like the gtk's builtin widgets does:
class foo : public Gtk_Drawing_Area {
public:
...
gint expose_event_impl(GdkEventExpose *e) {
Gtk_Drawing_Area::expose_event_impl(e); // call base class expose
GdkWindow *win=GTK_WIDGET(gtkobject)->window;
/* use drawing functions here from the C interface */
gdk_draw_arc(win,my_gc,TRUE,my_x,my_y,my_width,my_height,my_start_angle,my_sweep_angle);
}
...
};
> then assuming you have a drawing area widget assigned to drawing_area:
> gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
> GTK_SIGNAL_FUNC (my_expose), my_data);
> Note that this leaves off a bunch of smarts like only drawing the area
> that needs it by checking the expose event in my_expose, but it shows
> you the general idea.
Can use the connect() too, but IMHO its inconvinient. :)
--
-- Tero Pulkkinen -- terop@modeemi.cs.tut.fi --
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]