[gtkmm] Gdk::Colormap and Gdk::Color



Hey guys, I've been asking on IRC for a while, but as I'm ~12hrs from everyone else I should probably use the list.

The application I'm writing needs to do a fair amount of drawing onto pixmaps etc. so I've been tinkering with Gdk::Drawables lately and I'm wondering whether I've understood the Gdk::Color situation wrt Gdk::Colormaps. Please point out any errors in the following:

In order to draw a line in a specified color, say red, I need to.

{
Glib::RefPtr<Gdk::Pixmap> pm = Gdk::Pixmap::create(x,y,d);
Glib::RefPrt<Gdk::GC> gc = Gdk::GC::create(gc);
Glib::RefPtr<Gdk::Colormap> cm = gc->get_colorap()
Gdk::Color red("red");

cm->alloc_color(red);
pm->draw_line(gc, 0, 0, 100, 100);
}

Do I need to manually allocate colors everytime? or is there some funky Helper that'll hide all that stuff?

After I've alloced that color, can I pass it by value? or is there some hidden magic happening? i.e say I wanted to store allocated colors in a std::map<LColor::color, Gdk::Color> to simplify the process of translating draw instructions from the core code's own Colors to Gdk::Colors, no problems?

gtkmm-2.0 is feeling better with every widget I use.



Ta

Koz




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