GC sometimes without a colormap



I use gtk-perl and this is a problem that occurs in it, but probably it is a GTK issue. At least nobody answered to this in the gtk-perl list.

I have this piece of code:

$pm = Gtk2::Gdk::Pixmap->new(undef,10,10,24);
$gc = new Gtk2::Gdk::GC $pm;
$gc->set_rgb_fg_color(Gtk2::Gdk::Color->new(0,0,0));
$pm->draw_rectangle($gc,1,0,0,10,10);
$pb = Gtk2::Gdk::Pixbuf->get_from_drawable($pm,undef,0,0,0,0,10,10);

The idea is to create small (10x10) pixbufs with varying colors for inserting them into the model of a treeview. The code works in Linux and Windows - usually, but in a specific Windows environment the following error occurs:

Gdk-WARNING **: gdk_gc_set_rgb_fg_color() and gdk_gc_set_rgb_bg_color() can
only be used on GC's with a colormap. A GC will have a colormap
if it is created for a drawable with a colormap, or if a
colormap has been set explicitly with gdk_gc_set_colormap.
Gdk-WARNING **: ../../../gtk+/gdk/gdkpixbuf-drawable.c:1249: Source drawable has no colormap; either pass in a colormap, or set the colormap on the drawable wit
h gdk_drawable_set_colormap()

It looks like I need to call $gc->set_colormap($color_map), and $color_map = Gtk2::Gdk::Colormap->new ($visual, $allocate) before that, but where do I get $visual and $allocate?

How do I test those cases where I need to do that?

Best regards,

Ari

--
Prof. Ari Jolma
Geoinformaatio- ja paikannustekniikka
Geoinformation and positioning technology
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




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