Re: Transparent label



> > Why not just draw your label text on the pixmap, and ditch the GtkLabel?
> > 
> > Havoc
> 
> Humm.. maybe I'm not doing the right thing but with the following snipet
> I cant get the drawing on the pixmap to show. I guess the mask doesnt
> get updated when I draw on the pixmap using gdk_draw_pixmap() call. Of
> course, if I dont use the mask combine then i'm ok, the text will
> appear.
> 

When you call gdk_pixmap_create_from_xpm, the mask is created with all
non-0 values set to 1, the rest is set to 0 (obviously). From that
point, the mask won't be updated automatically because it is a
separate Gdk Object (which didn't exist before that function call).
Your pixmap is a GdkPixmap while your mask is a GdkBitmap, which are
two graphical object.

What happens is that your mask is adapted to the pixmap, but anything
you would write on the pixmap, which corresponding position on the
mask is 0 won't get displayed.
So in your case you need to draw your string on the bitmap as well as
on the pixmap.

You will also need to create a new GdkGC with a reference to the
bitmap. Set the foreground colour of that GdkGC to a GdkColor whose
pixel value is 1 (don't bother with the RGB values).
Afterwards, you will have to add this line:

gdk_draw_string (pm, font, name_of_the_new_gc, 20,40 , 
                     "Hello world!");

I hope to lenghty explanation will serve its purpose...


Wolfgang




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