Re: Transparent label



Havoc Pennington wrote:
> 
> Daniel Shane <daniel@insu.com> writes:
> > I would like to know if its possible to make the main window
> > transparent? My main window only has to things, a pixmap (which can
> > easily be made transparent) and a label. The question is, how can I
> > recompute the mask so as to show the text that is in the label? If I
> > gtk_window_shape_combine_mask() the pixmap with the main window then my
> > label will not show up because the mask will hide it.
> >
> 
> 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.

int main (int argc, char *argv[] )
{
    GtkWidget *window, *widget;
    GdkPixmap *pm;
    GdkBitmap *mask = NULL;
    GdkFont *font;
 
    gtk_init (&argc, &argv);
    
    window = gtk_window_new( GTK_WINDOW_POPUP );
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (close_application), NULL);
    gtk_widget_realize(window);

    widget = gtk_drawing_area_new ();
    gtk_drawing_area_size (GTK_DRAWING_AREA (widget), 400, 400);
 
    font = gdk_font_load
           ("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*");        
    pm = gdk_pixmap_create_from_xpm( window->window, &mask, NULL,
                                     "netscape.xpm" );
    gtk_widget_shape_combine_mask( widget, mask, 0, 0 ); 
    gtk_widget_shape_combine_mask( window, mask, 0, 0 );
    
    gtk_container_add( GTK_CONTAINER(window), widget);
    gtk_widget_show( widget );
    gtk_widget_show( window ); 

    gdk_draw_string (pm, font, pm->style->white_gc, 20,40 , 
                     "Hello world!");
    gdk_draw_pixmap (widget->window, widget->style->black_gc, 
                     pm, 0, 0, 0, 0, 400, 400);    

    gtk_main ();
          
    return(0);
}




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