Re: bogged down in drawingarea tutorial



Hi Ron,

> GCC complains thus:
> /usr/include/gdkmm-2.4/gdkmm/gc.h:389: error: `Gdk::GC::GC()' is protected

That is because Gdk::GC does not have a public constructor. You must
either use Gdk::GC::create() or some other function that returns a
Glib::RefPtr<Gdk::GC>:

Glib::RefPtr<Gdk::Window> window = get_window();
Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(window);

This means Gdk::GC may only be accessed through a Glib::RefPtr.

> The next line fails as well:
> Gdk::Colormap appColormap(Gdk::Colormap::get_system());

Again, there is no public constructor for Gdk::Colormap. You have to use
the Gdk::Colormap::create() or Gdk::Colormap::get_system() functions and
assign the return value to a Glib::RefPtr<Gdk::Colormap>:

Glib::RefPtr<Gdk::Colormap> appColormap = Gdk::Colormap::get_system();

> I'm completely confused.  I'm no newbie to GTK+ either, I've used the
> library in a number of applications via the ruby-gnome2 wrappers, and
> thought I understood what I was doing..  I can't even figure out from
> the gtkmm tutorial how to allocate a specific size to the DrawingArea
> (!), and there's not even an overloaded constructor for DrawingArea with
> a pair of ints to specify width/height, I tried that..

Take a look at the reference documentation to see what you can do with
the gtkmm objects. Gtk::DrawingArea is derived from Gtk::Window, so you
can set the size with

Gtk::Window::set_default_size(int width, int height)

Cheers,

J�


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