[gtkmm] drawing pixels -- Gtk::DrawingArea



I'm trying to draw some pixels, but the DrawingArea chapter of
The Book seems to be a little out-of-date (I'm new to gtkmm and
not familiar with gtkmm 1.2). I suggest this because, in the
section with the example (Drawing Lines), the declaration for
on_expose_event() is public and returns an int, where the
header (gtkmm/widget.h) lists it as protected and returning a
bool. Also, the example uses Gtk::Main::run() without a
Gtk::Window arg like many other examples, and a couple other
subtle clues.

In the examples that came with the docs, scribble-simple.cc
doesn't compile. However, drawingarea.cc does build and work,
and I see that protected bool on_expose_event() is the correct
way to go.

drawingarea.cc brings up new questions though -- here they
are:

-- Glib::RefPtr<Gdk::GC> gc_;
It looks like the only graphics-related objects that need to
be referred to through a Glib::RefPtr are: Gdk::GC,
Gdk::Colormap, and Gdk::Drawable. Wait, why the
Glib::RefPtr<Gdk::Window> window_? Is that necessary? So far,
I've only dealt with Gtk::Window's.

-- virtual void on_realize()
I see that this is a protected member function of Gtk::Widget.
What does it do? I see it listed in the docs here:
file:///home/john/docs/gtkmm/docs/reference/html/classGtk_1_1Widget.html#b8
but there's no description. Am I looking in the wrong place?

-- Still in on_realize(), What's the Glib::RefPtr<Gdk::Drawable> for? The docs
file:///home/john/docs/gtkmm/docs/reference/html/classGdk_1_1Drawable.html#_details
say that you need a concrete Drawable, but we've got it pointing to our
Gtk::Window, right?

This seems overly complicated... does examples/drawingarea.cc
reflect the current state of gtkmm-2?

Thanks,
---j




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