Re: [gtk-list] Is Gtk_DrawingArea in gtk-- usable?



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

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;
    }

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.

-- 
Rob Browning <rlb@cs.utexas.edu>
PGP fingerprint = E8 0E 0D 04 F5 21 A0 94  53 2B 97 F5 D6 4E 39 30



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