Re: Gtk-- create Pixmaps at startup?




Thanks to Norbert Bladt for another suggestion.
Here is another attempt at Pixmap handling in Gtk--.
Code fragments follow.  The attached tarball has
a complete example.

Norbert Bladt <abladtn@autelca.ascom.ch> posted
> There is another call in GTK which allows to create pixmaps without
> "realizing". What is missing (see your gdk messages) is a "window".
> Why is it missing: It's sole use in the call to create a pixmap
> is to get the colormap of this (or any other window, see the patch
> to your code) window. However, as long as a window is not realized,
> there is no window and therefore no colormap !
> But, if you just get the default system colormap and use the call
> to create a pixmap together with this colormap you simply
> avoid executing code twice and have the same result. I am doing
> this and it works !
> 
> In detail:
> 	GdkPixmap* gdk_pixmap_colormap_create_from_xpm_d
> is your friend as is:
> 	GdkColormap *default_colormap;
> 	default_colormap = gdk_colormap_get_system ();
> That's it.
> Now, how do you do this in GTK-- ?
> This task is left to the reader :-) I am not using it.

Here is code fragments for creating and switching pixmaps in Gtk--:

class gtk_test_008
  class top_window : public Gtk_Window

    Gtk_Pixmap pm;

    Gdk_Colormap system_colormap;
    Gdk_Bitmap my_bitmap;
    Gdk_Pixmap red_1;
    Gdk_Pixmap blue_2;

#include "blue_2.xpm"
#include "red_1.xpm"

gtk_test_008::top_window::init()
  system_colormap = Gdk_Colormap::get_system();
  Gdk_Color tmp_color;

  red_1.create_colormap_from_xpm_d (0,
				    system_colormap,
				    my_bitmap,
				    tmp_color,
				    red_1_xpm
				    );
  blue_2.create_colormap_from_xpm_d (0,
				    system_colormap,
				    my_bitmap,
				    tmp_color,
				    blue_2_xpm
				    );

  pm_num = 1;
  pm.set (red_1,my_bitmap);
  status_text.set_text("1 Red");

  add(pm);

gtk_test_008::top_window::key_press_handler(GdkEventKey *gek)
  if (pm_num == 1)
    {
      pm_num = 2;
      pm.set (blue_2,my_bitmap);
    }
  else
    {
      pm_num = 1;
      pm.set (red_1,my_bitmap);
    }

begin 644 gtk--_pm_example.tar.gz
M'XL(`#H4JS<``^V:;6_:2!"`\[7^%7-.=3(H@`V$))!$NIS2ZG2J5-V'N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