Re: [gtk-list] Re: (Hideki Fujimoto) wrote:

> From: "David M. Cook" <>
> Subject: [gtk-list] 
> Date: Sat, 21 Mar 1998 05:08:36 PST
> davecook> How do I add a pixmap to a window (a dialog in this case) 
> davecook> before I've shown the window.  
>  GdkColormap *cmap;
>  cmap = gdk_colormap_get_system();
>  <snip>
>  xpm = gdk_pixmap_colormap_create_from_xpm_d (NULL, cmap, &mask, 
>                                               &style->bg[GTK_STATE_NORMAL],
>                                               XPM_DATA);

Just hope *that* is in fact the gdk colormap that this window is going to be shown with ;-)

Another approach (swiped from testgtk.c :-) is to:

  GdkPixmap *pixmap;
  GdkBitmap *mask;
  GdkColor  *background;
  char      *filename;
  GtkWindow *window;

 ...(initialize window and all that stuff)
  gtk_widget_realize (window);

This now means your window is actually onscreen (though not drawn), and you can continue with:

  pixmap = gdk_pixmap_create_from_xpm (window->window, &mask, background, filename)

Note you now have a *gdk* pixmap, you may want to get a gdk pixmap from that thusly:

  mypixmap = gtk_pixmap_new (pixmap, mask);

Also, you could use gdk_pixmap_create_from_xpm_d instead of gdk_pixmap_create_from_xpm
if you prefer to have the data in your program instead of in a file outside of it. Have a look at testgtk.c
to see how to do this.
Now just add your gtkpixmap to your widget, that to the window, and finally gtk_widget_show it all.
   Deon Ramsey


Deon Ramsey (general Librarygopher) may be reached as:
Work:                       Private:

<A HREF="">Deon Ramsey</A>

Or via Snail-Mail:          Deon Ramsey
                            Koenigstr. 11
                            67655 Kaiserslautern

Program (Pro'-gram) n. A magic spell cast over a computer, causing it to
turn one's input into error messages.

There are many intelligent species in the Universe.
                                             They are all owned by cats.

Be discreet, be polite, but be yourself. -- Per Aspera

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