Re: bogged down in drawingarea tutorial



rchilds vctlabs com wrote:

> Hello,
>
> I'm looking through the DrawingArea tutorial, the first section that
> describes how to use GC's:
>
> Gdk::GC some_gc;
> some_gc.create(get_window());
> Gdk::Color some_color;
> Gdk::Colormap some_colormap(Gdk::Colormap::get_system());
> some_color.set_red(65535);
> some_color.set_green(0);
> some_color.set_blue(0);
> some_colormap.alloc(some_color);
> some_gc.set_foreground(some_color);
>
> I'm writing a sample app to draw pixels in a drawing area.  There are
> 256 shades of red, which I have implemented as follows:
> Gdk::Color colorList[NSHADES];
> I have a for loop that calls the .set_(red)|(green)|(blue) member
> functions for each distinct shade.
>
> However, I can't even get past the GC!  This is how I've declared it:
> Gdk::GC drawGc;
>
> GCC complains thus:
> /usr/include/gdkmm-2.4/gdkmm/gc.h:389: error: `Gdk::GC::GC()' is protected

GC should be created by
Glib::RefPtr<GC> 
create (const Glib::RefPtr<Drawable>& drawable)

>
> I've looked in the gc.h file, which is not at all illuminating about why
> this is protected.
>
> The next line fails as well:
> Gdk::Colormap appColormap(Gdk::Colormap::get_system());

As the compiler tells you, get_system() returns a
Glib::RefPtr<Gdk::Colormap> ... Thus, you should try something like
....
Glib::RefPtr<Gdk::Colormap>
p_colormap(Gdk::Colormap::get_system());
...

>
> and here's the relevant GCC complaint:
> test.cc:61: error: no matching function for call to
> `Gdk::Colormap::Colormap(Glib::RefPtr<Gdk::Colormap>)'
> /usr/include/gdkmm-2.4/gdkmm/colormap.h:101: note: candidates are:
> Gdk::Colormap::Colormap(const Glib::RefPtr<Gdk::Visual>&, bool)
> /usr/include/gdkmm-2.4/gdkmm/colormap.h:76: note:
> Gdk::Colormap::Colormap(GdkColormap*)
> /usr/include/gdkmm-2.4/gdkmm/colormap.h:75: note:
> Gdk::Colormap::Colormap(const Glib::ConstructParams&)
> /usr/include/gdkmm-2.4/gdkmm/colormap.h:71: note:
> Gdk::Colormap::Colormap(const Gdk::Colormap&)
>
> 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..

You can use set_size_request(...) in your constructor ...

>
> Is there a better tutorial, or do I continue to rely on the kindness of
> strangers on the gtkmm-list (which, by the way, I don't actually receive
> email from despite joining the mailing list) ??

I would strongly suggest that you study the following example:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch14s03.html#id2524650

>
> please help ?
>
> --
> Ron Lockwood-Childs
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org <mailto:gtkmm-list gnome org>
> http://mail.gnome.org/mailman/listinfo/gtkmm-list





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