Re: How to shape a button



Hi!
Im sending you code from the project gtk-book,
http://gtkbook.sourceforge.net/

The function make_shapedwidget() should help.
To choose the shape of the widget change the
mask in the file "circle.xpm".


<CODE>

#include<gtk/gtk.h>
#include<gtk/gtkitemfactory.h>
#include<glib/gprintf.h>

 
gboolean  configure_event(GtkWidget *w,gpointer data)
{  
  //make a shaped mask
  GdkPixmap *pix;
  GdkBitmap *bit;
  GdkColor c={0};

 
pix=gdk_pixmap_create_from_xpm(w->window,&bit,&c,"circle.xpm");
 
gdk_window_shape_combine_mask(GDK_WINDOW(w->window),bit,100,100);
 
  gtk_window_set_decorated(GTK_WINDOW(w),FALSE);
  return TRUE;
}

GtkWidget * make_shapedwidget(void)
{
  GtkWidget *w;

  w=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
 
g_signal_connect(G_OBJECT(w),"configure_event",G_CALLBACK(configure_event),NULL);
 
g_signal_connect(G_OBJECT(w),"destroy",G_CALLBACK(gtk_main_quit),NULL);

  
gtk_container_add(GTK_CONTAINER(w),gtk_color_selection_new());
  return w;
}
</CODE>

Cheers
-Muthu.


--- Chris Wu <Chris Wu Sanmina-SCI Com> wrote:
Hi all,
       I would like to make a shaped button, but
when I use the
gtk_widget_shape_combine_mask(button, mask, 0, 0).
      I got "assertion `!GTK_WIDGET_NO_WINDOW
(widget)' failed".
      Would you mind to send me some demo code to
told me how to shape a
button!

Chris.Wu
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

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



                
__________________________________ 
Yahoo! Mail Mobile 
Take Yahoo! Mail with you! Check email on your mobile phone. 
http://mobile.yahoo.com/learn/mail 



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