Re: Pixmap oddity
- From: Owen Taylor <otaylor redhat com>
- To: gtk-list redhat com
- Subject: Re: Pixmap oddity
- Date: 04 Jun 1999 12:57:34 -0400
"Scott A. Barron" <sbarron@abalonesoft.com> writes:
> Hello all,
>
> I am having trouble with some pixmaps. Here are my scenarios:
>
> Scenario 1:
> I have a button into which I put a pixmap created with
> gdk_pixmap_create_from_xpm_d. I then insert this button into a table and show
> everything. This scenario works as expected, no problems here.
>
> But, Scenario 2:
> I have the same button with the same pixmap, but this time I insert the button
> into an hbox, then put the hbox in the table. When I do this I get:
> Gdk-WARNING **: Creating pixmap from xpm with NULL window and colormap
>
> Can anyone help me understand why I'm getting this error? Is there a way
> around it? Everything displays fine, and the pixmaps are all seemingly
> correct, so I'm not sure why I get this error.
I'll see if I can quickly summarize the situation with
pixmaps and colormaps/visuals.
gdk_pixmap_create_from_xpm_d()
requires a non-NULL window parameter, to get a colormap
for the pixmap. (At one point, GTK+ would silently use
the default colormap if the window was NULL, but using
that colormap is not correct.)
Typically, people do this by doing:
gdk_pixmap_create_from_xpm_d (widget->window, ...)
Which works only if 'widget' is realized. To be realized
a widget must first be added into a widget heirarchy
that includes a toplevel window at the top; you
may also need to explicitely call gtk_widget_realize()
on the widget.
However, this is not the best way to handle the
problem. Instead, you should use:
GdkPixmap* gdk_pixmap_colormap_create_from_xpm
(GdkWindow *window,
GdkColormap *colormap,
GdkBitmap **mask,
GdkColor *transparent_color,
const gchar *filename);
Which takes, in addition to the window parameter,
a colormap parameter. If you pass in a non-null
colormap, then you can pass in a null window parameter.
Where do you get the colormap from? You can
get the colormap for any widget using
gtk_widget_get_colormap(); this does not
require the widget to be realized.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]