Anybody of GTk's Team ? or More about Shapes
- From: "José Miguel R. Barrientos" <jmiguel ceselsa es>
- To: "gtk-list redhat com" <gtk-list redhat com>
- Subject: Anybody of GTk's Team ? or More about Shapes
- Date: Mon, 17 May 1999 09:31:32 +0000
At risk to get people bored,
I think that with minimal modifications it's possible to combine more than one
mask in the shape of a container.
This code do it. Specially the function my_shape_combine_mask() it's easy to
include in Gdk (I think).
See the code please (better execute it :), because I'm not be able to express
myself in english ...
Thanx a lot,
- José Miguel
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
/* */
int main(int argc, char *argv[]) {
GtkWidget *toplevel = NULL,
*area = NULL,
*pixm1 = NULL,
*pixm2 = NULL;
GtkStyle *style;
GdkPixmap *pdata = NULL;
GdkBitmap *mask;
GdkWindow *rootw;
GdkWindowPrivate *privw;
gtk_init(&argc, &argv);
rootw = gdk_window_foreign_new(GDK_ROOT_WINDOW());
gtk_widget_show(toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_widget_set_name(toplevel, "- P R U E B A S -");
gtk_signal_connect(GTK_OBJECT(toplevel), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
gtk_signal_connect(GTK_OBJECT(toplevel), "delete_event",
GTK_SIGNAL_FUNC(gtk_false), NULL);
gtk_widget_show(area = gtk_fixed_new());
gtk_container_add(GTK_CONTAINER(toplevel), area);
style = gtk_widget_get_default_style();
pdata = gdk_pixmap_create_from_xpm(rootw, &mask, &style->bg[GTK_STATE_NORMAL],
"../../gtk/kiss/Modeller.xpm");
gtk_widget_show(pixm1 = gtk_pixmap_new(pdata, mask));
gtk_fixed_put(GTK_FIXED(area), pixm1, 10, 10);
/* Shape of first child, Normal Method */
gdk_window_shape_combine_mask(area->window, mask, 10, 10);
/* I want more pixmaps in same container */
pdata = gdk_pixmap_create_from_xpm(rootw, &mask, &style->bg[GTK_STATE_NORMAL],
"../../gtk/kiss/3DRings.xpm");
gtk_widget_show(pixm2 = gtk_pixmap_new(pdata, mask));
gtk_fixed_put(GTK_FIXED(area), pixm2, 40, 40);
gtk_widget_realize(area);
gdk_window_set_cursor(area->window, gdk_cursor_new(GDK_HAND2));
/* Merge Shape of second pixmap */
my_shape_combine_mask(area->window, mask, 40, 40);
gtk_main();
return(0);
}
/*
* It's not safe to use Gdk internals
* */
int my_shape_combine_mask(GdkWindow *window, GdkBitmap *mask, gint x, gint y) {
GdkWindowPrivate *window_private;
Pixmap pixmap;
g_return_if_fail(window != NULL);
window_private = (GdkWindowPrivate*)window;
if(window_private->destroyed)
return;
/* if(gdk_window_have_shape_ext()) { */
if(mask) {
GdkWindowPrivate *pixmap_private;
pixmap_private =(GdkWindowPrivate*) mask;
pixmap =(Pixmap) pixmap_private->xwindow;
} else {
x = 0;
y = 0;
pixmap = None;
}
XShapeCombineMask(window_private->xdisplay, window_private->xwindow,
ShapeBounding, x, y, pixmap, ShapeUnion);
/* } */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]