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



Hi Michael!

Ah, the problem is now getting clearer for me. I missed the point because
I missed a line in my code that does the allocation for me (using rgb values):
col.rgb_find_color(gc->get_colormap());

I see that your code will work as long as you can use the same colormap,
that being the case when:
"the depth of the colormap's visual (...) match(es) the depth of the
drawable for which the GC was created" (gdk doc for gdk_gc_set_colormap).

However I don't see where your code makes life any easier or more convinient.
If it's a performance issue then you should find out whether gdk colormaps
already buffer the colors for you or eat time every time you call alloc.
(You will have to look in the gdk sources - I don't find anything in the docs.)

Regards,

  Martin


Am 08.08.2002 12:15 schrieb(en) Michael Koziarski:
> > {
> > 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);
> > }
>
> I've never used colormaps but from what I see I think that the
following
> solution should do the same:

Thanks for the reply,  It seems we were both halfway there.  you set
the foreground, but in order for it to actually be used (i.e. line be
red rather than black), it's gotta be alloc'd too.

So my question about Color's being Copy friendly still stands,  as
does my question about 'automagic-color' widgets.

Basically what I'm thinking is pretty much this (allowing for typos &
missing #includes)

http://www.koziarski.org/GColorManager.C
http://www.koziarski.org/GColorManager.h

Any problems with that code?  or am I needlessly duplicating work
available elsewhere?



--
========================================================================
| Michael Koziarski                   |"Conventional wisdom is often   |
| Data Engineer, Linux user           | long on convention and short   |
| & Objectivist.                      | on wisdom" --                  |
| http://www.koziarski.com            | Warren E. Buffett, BRK.A       |
========================================================================
_______________________________________________
gtkmm-list mailing list
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]