Help! gdk_window_set_child_shapes() problem!
- From: Monte Lin <monte ipex com tw>
- To: gtk-app-devel-list gnome org
- Subject: Help! gdk_window_set_child_shapes() problem!
- Date: Fri, 22 Jun 2001 19:16:06 +0800
Hi:
I'm tring figuring out the way to have shaped widget with the
gtk/gdk support of X shape extention. I digged out the code (weelbarrow)
from the gtk tutorial sample codes and made some modifications. As
follow:
/*=============================================================
=============================================================*/
/* example-start wheelbarrow wheelbarrow.c */
#include <gtk/gtk.h>
/* the original code embeds the xpm data directly */
#include "image.xpm"
/* When invoked (via signal delete_event), terminates the
application */
void close_application( GtkWidget *widget, GdkEvent *event,
gpointer data ) {
gtk_main_quit();
}
int main (int argc, char *argv[])
{
/* GtkWidget is the storage type for widgets */
GtkWidget *window, *pixmap1, *pixmap2, *fixed, *btn1,
*btn2;
GdkPixmap *gdk_pixmap, *gdk_pixmap2;
GdkBitmap *mask, *mask2;
GtkStyle *style;
GdkGC *gc;
/* Create the main window, and attach delete_event signal
to terminate
* the application. Note that the main window will not
have a titlebar
* since we're making it a popup. */
gtk_init (&argc, &argv);
//window = gtk_window_new( GTK_WINDOW_POPUP );
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
// window = gtk_window_new( GTK_WINDOW_DIALOG);
gtk_window_set_default_size(GTK_WINDOW(window), 128, 48);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (close_application),
NULL);
gtk_widget_show (window);
/* Now for the pixmap and the pixmap widget */
style = gtk_widget_get_default_style();
gc = style->black_gc;
gdk_pixmap = gdk_pixmap_create_from_xpm_d( window->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
WheelbarrowFull_xpm );
pixmap1 = gtk_pixmap_new( gdk_pixmap, mask );
gtk_widget_show( pixmap1 );
gdk_pixmap2 = gdk_pixmap_create_from_xpm_d(
window->window, &mask2,
&style->bg[GTK_STATE_NORMAL],
WheelbarrowFull_xpm );
pixmap2 = gtk_pixmap_new( gdk_pixmap2, mask2 );
gtk_widget_show( pixmap2 );
//btn1= gtk_button_new();
btn1= gtk_event_box_new();
gtk_container_add (GTK_CONTAINER (btn1), pixmap1);
gtk_widget_show(btn1);
//btn2= gtk_button_new();
btn2= gtk_event_box_new();
gtk_container_add (GTK_CONTAINER (btn2), pixmap2);
gtk_widget_show(btn2);
/* To display the pixmap, we use a fixed widget to place
the pixmap */
//fixed = gtk_fixed_new();
fixed = gtk_hbox_new(FALSE,0);
//gtk_fixed_put( GTK_FIXED(fixed), btn1, 0, 0 );
gtk_box_pack_start( GTK_BOX(fixed), btn1, FALSE,0,0 );
//gtk_fixed_put( GTK_FIXED(fixed), btn2, 48, 0 );
gtk_box_pack_start( GTK_BOX(fixed), btn2, FALSE, 0, 0 );
gtk_container_add( GTK_CONTAINER(window), fixed );
gtk_widget_show( fixed );
//gtk_widget_set_usize( fixed, 128, 48 );
/* This masks out everything except for the image itself
*/
gtk_widget_shape_combine_mask( btn1, mask, 0, 0 );
gtk_widget_shape_combine_mask( btn2, mask2, 0, 0 );
//(1) gdk_window_set_child_shapes(fixed->window);
//(2) gdk_window_set_child_shapes(window->window);
/* show the window */
gtk_widget_set_uposition( window, 20, 400 );
gtk_widget_show( window );
gtk_main ();
return(0);
}
/* example-end */
/*============================================================
============================================================
*/
With above code, I'm able to show two shaped image in a window, fine.
But I want more. I like to have the top-level window bounding area to be
transparent, so you can see through the top-level window except those
two shaped image. I have gone half (exactly half) the way toward that.
If I uncomment the "//(1)" or "//(2)" line of code, I get a transparent
window but only one shape image.
According to the GDK sources, the call to the
gdk_window_set_child_shapes() call should play the trick I want. Now it
seems there ares somethings I have missed. Could anybody help me?
Thanks!
Monte Lin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]