Re: How do I get the color....



Klas Bengtsson wrote:
> 
> I am using images on buttons instead of text...  My problem i that my picture (.xpm file)
> has a white background ang  gtk buttons are gray...  I tried to set style-> whith in the
> *gtk_colour field of pixmap...  Pleaze .....Help ...
> 

(This should probably go into the FAQ soon)

You need to set the background color of your .xpm file to transparent. You can do this by
loading the .xpm file into a text editor and make sure it looks something like this:
(Red rectangle on transparent color)

/* XPM */
static char *test[] = {
/* width height num_colors chars_per_pixel */
"    8    8       2            1",
/* colors */
". c None",
"# c #ff0000",
/* pixels */
"........",
"........",
"..####..",
"..####..",
"..####..",
"..####..",
"........",
"........"
};

So, find your background color string and set its corresponding color to "None".

Now, in the code (look at testgtk.c for example) you do:

..

GtkWidget *button;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
GtkStyle *style;
gchar *xpm_filename;

..

style = gtk_widget_style (button);
pixmap = gdk_pixmap_create_from_xpm (
  button->window,
  &pixmap_mask,
  style->bg[GTK_STATE_NORMAL]
  xpm_filename);

..


Hope this helps.

Tom

--

tomb@gimp.org



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