Re: TEXT over transparent background



Hi Julio
The code you sent me is realy I was looking for. Thanks for that.
But I'd like to understand a little bit about pixmap, GC and mask.
I need to change the text color from black to green or red, and I also need
to get the same efect with
progress bar and menues. That´s why I'd like to know concepts about pixmap
and GC.
The questions are:
Could you explain to me something about pixmap and GC (over the code you
sent me)? I realy didn't find any good tutorial about them.
or could you recomend me any tutorial about them?
Are you Spanish speaker? If yes, I'm Spanish speaker too, If you want you
can explain to me in spanish. English is good too.
How can I change color texts?

Thanks for help

Ariel Fritz
----- Original Message -----
From: "Julio Pastrana" <pastrana informatik uni-freiburg de>
To: "Ariel Fritz" <duin tutopia com>
Cc: <gtk-app-devel-list gnome org>
Sent: Saturday, October 25, 2003 7:00 AM
Subject: Re: TEXT over transparent background



Hello again Ariel
well I changed  some things from
the example and I add a line that does
magic .. just to mask the whole window

 gtk_widget_shape_combine_mask( window, xpm, 0, 0 );

it is explained in theWheelbarrow (i think)

OK other thing
try this 2 types of windows

window = gtk_window_new( GTK_WINDOW_TOPLEVEL);

window = gtk_window_new( GTK_WINDOW_POPUP );

just replace  GTK_WINDOW_TOPLEVEL for GTK_WINDOW_POPUP
or viseversa ... and check the efect

i hope you ca understand this one  =)
heve fun


-------------------------------------------------------
#include <gtk/gtk.h>
#include <stdlib.h>

void close_application( GtkWidget *widget, GdkEvent
*event, gpointer data ) {
    gtk_main_quit();
}

int main (int argc, char *argv[])
{
   //widgets we will show
       GtkWidget *window, *pixmap;

   // just to define colors
        GdkGC *gccc;
        GdkGC *gc;
        GdkColor white;
        GdkColor black;

   GdkPixmap   *p; // this is the color pixmap
        GdkPixmap *xpm; //this is the mask
        GdkFont *label_font=NULL; // to store the text you want to draw

        GtkWidget *vbox1;


    int sizeX = 300;
    int sizeY = 100;


    gtk_init (&argc, &argv);



    window = gtk_window_new( GTK_WINDOW_TOPLEVEL);  // window =
gtk_window_new( GTK_WINDOW_POPUP );
    gtk_widget_set_usize (window,  sizeX ,  sizeY);
    gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (close_application), NULL);
    gtk_widget_show (window);


    vbox1 = gtk_vbox_new (FALSE, 0);
    gtk_widget_set_name (vbox1, "vbox1");
    gtk_widget_ref (vbox1);
    gtk_object_set_data_full (GTK_OBJECT (window), "vbox1", vbox1,
                             (GtkDestroyNotify) gtk_widget_unref);
    gtk_container_add (GTK_CONTAINER (window), vbox1);
    gtk_widget_show (vbox1);


         gdk_color_parse("white", &white);
         gdk_color_alloc(gtk_widget_get_colormap(window),&white);

         gdk_color_parse("black", &black);
         gdk_color_alloc(gtk_widget_get_colormap(window),&black);




           p =  gdk_pixmap_new ( window->window, sizeX,sizeY, -1);
//creating color pixmap
           xpm = gdk_pixmap_new ( NULL, sizeX, sizeY,1);   //creating  one
color pixmap (It is actually a BITMAP)

          // getting the gc for the bitmap 1 bit color
           gc = gdk_gc_new(xpm);
           gdk_gc_set_foreground(gc, &black);
           gdk_draw_rectangle(xpm, gc, TRUE, 0,0, sizeX,sizeY);
           gdk_gc_set_foreground(gc, &white);



                  /* everything you draw you have to draw it on the mask
also */
  /* just with the white color */

                   // getting the gc for the pixmap
                   gccc = gdk_gc_new(p);
                  gdk_gc_set_background(gccc, &white);
                  gdk_draw_rectangle(p, gccc, TRUE, 0,0,  sizeX,sizeY);

                  label_font =
gdk_font_load("-*-helvetica-*-r-normal-*-14-*-*-*-*-*-*-*");
    char * text = "Ventana Transparente";
  gdk_draw_string(p , label_font , gccc , 30, 30, text);
                  gdk_draw_string(xpm , label_font , gc , 30, 30, text);


        //as in the Wheelbarrow example
        //we need to send the pixmap "p" to a pixmap Widget
        //and we mask it with the bitmap xpm
         pixmap = gtk_pixmap_new( p, xpm);

//now we do not need the pixmap
//because the widget has the data
//and we free the memory of the pixmap and the bitmap
  gdk_pixmap_unref(p);
                  gdk_pixmap_unref(xpm);

         //attaching the widget to a vbox
         gtk_container_add( GTK_CONTAINER(vbox1),  pixmap);
         gtk_widget_show( pixmap );

        /* This masks out everything except for the image itself */
         gtk_widget_shape_combine_mask( window, xpm, 0, 0 );
         gtk_widget_show( pixmap );

    gtk_main ();

    return 0;
}




-------------------------------------------------------


On Thu, 23 Oct 2003, Ariel Fritz wrote:

Thanks for information

I really tryed to understand your code but I couldn´t at all.
I´m very beginer in GTK, and I don´t know some of functions that you use
in
code.
I´ll explain my doubts and my needs.

I realy need to show a text on over any window. This text should be holded
in another window with tranparent background. Image TV menu labels.

I was taking a look in wheelbarrow.c example that came with GTK and your
example. But I couldn´t get any good results.

If you can help me I´ll thank you.

Ariel Antonio Fritz
--- Original Message -----
From: "Julio Pastrana" <pastrana informatik uni-freiburg de>
To: "Ariel Fritz" <duin tutopia com>
Cc: <gtk-app-devel-list gnome org>
Sent: Thursday, October 23, 2003 5:31 AM
Subject: Re: TEXT over transparent background

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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