summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCST 1998 Shawn T. Amundson <amundson@gtk.org>1998-11-17 01:34:07 +0000
committerShawn Amundson <amundson@src.gnome.org>1998-11-17 01:34:07 +0000
commitbb0ec69706f29e67082f8617aedba7785039a2fd (patch)
tree78886d94d83399ec261b364a907a4c088b914e74
parente94a7b1a7afe102d74f075e76f2674287f2d2153 (diff)
downloadgdk-pixbuf-bb0ec69706f29e67082f8617aedba7785039a2fd.tar.gz
Pixmaps now grey out when insensitive, code thanks to GNOME stock by
Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org> * gtk/gtkpixmap.h gtk/gtkpixmap.c: Pixmaps now grey out when insensitive, code thanks to GNOME stock by Eckehard Berns. New function gtk_pixmap_set_build_insensitive to provide ability to turn this off.
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.pre-2-08
-rw-r--r--ChangeLog.pre-2-108
-rw-r--r--ChangeLog.pre-2-28
-rw-r--r--ChangeLog.pre-2-48
-rw-r--r--ChangeLog.pre-2-68
-rw-r--r--ChangeLog.pre-2-88
-rw-r--r--gtk/gtkpixmap.c121
-rw-r--r--gtk/gtkpixmap.h6
9 files changed, 178 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 45054c9c6..35e9a4b80 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,11 @@
+Mon Nov 16 19:19:00 CST 1998 Shawn T. Amundson <amundson@gtk.org>
+
+ * gtk/gtkpixmap.h
+ gtk/gtkpixmap.c: Pixmaps now grey out when insensitive,
+ code thanks to GNOME stock by Eckehard Berns. New function
+ gtk_pixmap_set_build_insensitive to provide ability to turn
+ this off.
+
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
diff --git a/gtk/gtkpixmap.c b/gtk/gtkpixmap.c
index 9cc6ec007..e38bd8d80 100644
--- a/gtk/gtkpixmap.c
+++ b/gtk/gtkpixmap.c
@@ -1,6 +1,9 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
+ * Insensitive pixmap building code by Eckehard Berns from GNOME Stock
+ * Copyright (C) 1997, 1998 Free Software Foundation
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
@@ -25,6 +28,7 @@ static void gtk_pixmap_init (GtkPixmap *pixmap);
static gint gtk_pixmap_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_pixmap_finalize (GtkObject *object);
+static void build_insensitive_pixmap (GtkPixmap *gtkpixmap);
static GtkWidgetClass *parent_class;
@@ -86,6 +90,7 @@ gtk_pixmap_new (GdkPixmap *val,
pixmap = gtk_type_new (gtk_pixmap_get_type ());
+ pixmap->build_insensitive = TRUE;
gtk_pixmap_set (pixmap, val, mask);
return GTK_WIDGET (pixmap);
@@ -117,7 +122,10 @@ gtk_pixmap_set (GtkPixmap *pixmap,
oldheight = GTK_WIDGET (pixmap)->requisition.height;
if (pixmap->pixmap)
gdk_pixmap_unref (pixmap->pixmap);
+ if (pixmap->pixmap_insensitive)
+ gdk_pixmap_unref (pixmap->pixmap_insensitive);
pixmap->pixmap = val;
+ pixmap->pixmap_insensitive = NULL;
if (pixmap->pixmap)
{
gdk_pixmap_ref (pixmap->pixmap);
@@ -166,7 +174,6 @@ gtk_pixmap_get (GtkPixmap *pixmap,
*mask = pixmap->mask;
}
-
static gint
gtk_pixmap_expose (GtkWidget *widget,
GdkEventExpose *event)
@@ -199,10 +206,23 @@ gtk_pixmap_expose (GtkWidget *widget,
gdk_gc_set_clip_origin (widget->style->black_gc, x, y);
}
- gdk_draw_pixmap (widget->window,
- widget->style->black_gc,
- pixmap->pixmap,
- 0, 0, x, y, -1, -1);
+ if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE
+ && pixmap->build_insensitive)
+ {
+ if (!pixmap->pixmap_insensitive)
+ build_insensitive_pixmap (pixmap);
+ gdk_draw_pixmap (widget->window,
+ widget->style->black_gc,
+ pixmap->pixmap_insensitive,
+ 0, 0, x, y, -1, -1);
+ }
+ else
+ {
+ gdk_draw_pixmap (widget->window,
+ widget->style->black_gc,
+ pixmap->pixmap,
+ 0, 0, x, y, -1, -1);
+ }
if (pixmap->mask)
{
@@ -212,3 +232,94 @@ gtk_pixmap_expose (GtkWidget *widget,
}
return FALSE;
}
+
+void
+gtk_pixmap_set_build_insensitive (GtkPixmap *pixmap, guint build)
+{
+ g_return_if_fail (pixmap != NULL);
+ g_return_if_fail (GTK_IS_PIXMAP (pixmap));
+
+ pixmap->build_insensitive = build;
+
+ if (GTK_WIDGET_VISIBLE (pixmap))
+ {
+ gtk_widget_queue_clear (GTK_WIDGET (pixmap));
+ }
+}
+
+static void
+build_insensitive_pixmap(GtkPixmap *gtkpixmap)
+{
+ GdkGC *gc;
+ GdkPixmap *pixmap = gtkpixmap->pixmap;
+ GdkPixmap *insensitive;
+ gint w, h, x, y;
+ GdkGCValues vals;
+ GdkVisual *visual;
+ GdkImage *image;
+ GdkColorContext *cc;
+ GdkColor color;
+ GdkColormap *cmap;
+ gint32 red, green, blue;
+ GtkStyle *style;
+ GtkWidget *window;
+
+ window = GTK_WIDGET (gtkpixmap);
+
+ g_return_if_fail(window != NULL);
+
+ gdk_window_get_size(pixmap, &w, &h);
+ visual = gtk_widget_get_visual(GTK_WIDGET(gtkpixmap));
+ cmap = gtk_widget_get_colormap(GTK_WIDGET(gtkpixmap));
+ gc = gdk_gc_new (pixmap);
+
+ cc = gdk_color_context_new(visual, cmap);
+ if ((cc->mode != GDK_CC_MODE_TRUE) && (cc->mode != GDK_CC_MODE_MY_GRAY))
+ {
+ gdk_color_context_free(cc);
+ style = gtk_widget_get_style(window);
+ color = style->bg[0];
+ gdk_gc_set_foreground (gc, &color);
+ for (y = 0; y < h; y ++)
+ {
+ for (x = y % 2; x < w; x += 2)
+ {
+ gdk_draw_point(pixmap, gc, x, y);
+ }
+ }
+ gdk_gc_destroy(gc);
+ return;
+ }
+
+ image = gdk_image_get(pixmap, 0, 0, w, h);
+ gdk_gc_get_values(gc, &vals);
+ style = gtk_widget_get_style(window);
+ color = style->bg[0];
+ red = color.red;
+ green = color.green;
+ blue = color.blue;
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ GdkColor c;
+ int failed;
+ c.pixel = gdk_image_get_pixel(image, x, y);
+ gdk_color_context_query_color(cc, &c);
+ c.red = (((gint32)c.red - red) >> 1) + red;
+ c.green = (((gint32)c.green - green) >> 1) + green;
+ c.blue = (((gint32)c.blue - blue) >> 1) + blue;
+ c.pixel = gdk_color_context_get_pixel(cc, c.red, c.green, c.blue,
+ &failed);
+ gdk_image_put_pixel(image, x, y, c.pixel);
+ }
+ }
+ insensitive = gdk_pixmap_new(GTK_WIDGET (gtkpixmap)->window, w, h, -1);
+ gdk_draw_image(insensitive, gc, image, 0, 0, 0, 0, w, h);
+ gtkpixmap->pixmap_insensitive = insensitive;
+ gdk_image_destroy(image);
+ gdk_gc_destroy(gc);
+ gdk_color_context_free(cc);
+}
+
+
diff --git a/gtk/gtkpixmap.h b/gtk/gtkpixmap.h
index 1694579ab..9f97f5a2e 100644
--- a/gtk/gtkpixmap.h
+++ b/gtk/gtkpixmap.h
@@ -45,6 +45,9 @@ struct _GtkPixmap
GdkPixmap *pixmap;
GdkBitmap *mask;
+
+ GdkPixmap *pixmap_insensitive;
+ guint build_insensitive : 1;
};
struct _GtkPixmapClass
@@ -63,6 +66,9 @@ void gtk_pixmap_get (GtkPixmap *pixmap,
GdkPixmap **val,
GdkBitmap **mask);
+void gtk_pixmap_set_build_insensitive (GtkPixmap *pixmap,
+ guint build);
+
#ifdef __cplusplus
}