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.
This commit is contained in:
parent
e94a7b1a7a
commit
bb0ec69706
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
@ -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>
|
Tue Nov 17 00:06:29 1998 Lars Hamann <lars@gtk.org>
|
||||||
|
|
||||||
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
* gtk/gtknotebook.h (struct _GtkNotebook): new flags : homogeneous;
|
||||||
|
121
gtk/gtkpixmap.c
121
gtk/gtkpixmap.c
@ -1,6 +1,9 @@
|
|||||||
/* GTK - The GIMP Toolkit
|
/* GTK - The GIMP Toolkit
|
||||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Library General Public
|
* modify it under the terms of the GNU Library General Public
|
||||||
* License as published by the Free Software Foundation; either
|
* 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,
|
static gint gtk_pixmap_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
GdkEventExpose *event);
|
||||||
static void gtk_pixmap_finalize (GtkObject *object);
|
static void gtk_pixmap_finalize (GtkObject *object);
|
||||||
|
static void build_insensitive_pixmap (GtkPixmap *gtkpixmap);
|
||||||
|
|
||||||
static GtkWidgetClass *parent_class;
|
static GtkWidgetClass *parent_class;
|
||||||
|
|
||||||
@ -86,6 +90,7 @@ gtk_pixmap_new (GdkPixmap *val,
|
|||||||
|
|
||||||
pixmap = gtk_type_new (gtk_pixmap_get_type ());
|
pixmap = gtk_type_new (gtk_pixmap_get_type ());
|
||||||
|
|
||||||
|
pixmap->build_insensitive = TRUE;
|
||||||
gtk_pixmap_set (pixmap, val, mask);
|
gtk_pixmap_set (pixmap, val, mask);
|
||||||
|
|
||||||
return GTK_WIDGET (pixmap);
|
return GTK_WIDGET (pixmap);
|
||||||
@ -117,7 +122,10 @@ gtk_pixmap_set (GtkPixmap *pixmap,
|
|||||||
oldheight = GTK_WIDGET (pixmap)->requisition.height;
|
oldheight = GTK_WIDGET (pixmap)->requisition.height;
|
||||||
if (pixmap->pixmap)
|
if (pixmap->pixmap)
|
||||||
gdk_pixmap_unref (pixmap->pixmap);
|
gdk_pixmap_unref (pixmap->pixmap);
|
||||||
|
if (pixmap->pixmap_insensitive)
|
||||||
|
gdk_pixmap_unref (pixmap->pixmap_insensitive);
|
||||||
pixmap->pixmap = val;
|
pixmap->pixmap = val;
|
||||||
|
pixmap->pixmap_insensitive = NULL;
|
||||||
if (pixmap->pixmap)
|
if (pixmap->pixmap)
|
||||||
{
|
{
|
||||||
gdk_pixmap_ref (pixmap->pixmap);
|
gdk_pixmap_ref (pixmap->pixmap);
|
||||||
@ -166,7 +174,6 @@ gtk_pixmap_get (GtkPixmap *pixmap,
|
|||||||
*mask = pixmap->mask;
|
*mask = pixmap->mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gtk_pixmap_expose (GtkWidget *widget,
|
gtk_pixmap_expose (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
GdkEventExpose *event)
|
||||||
@ -199,10 +206,23 @@ gtk_pixmap_expose (GtkWidget *widget,
|
|||||||
gdk_gc_set_clip_origin (widget->style->black_gc, x, y);
|
gdk_gc_set_clip_origin (widget->style->black_gc, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_draw_pixmap (widget->window,
|
if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE
|
||||||
widget->style->black_gc,
|
&& pixmap->build_insensitive)
|
||||||
pixmap->pixmap,
|
{
|
||||||
0, 0, x, y, -1, -1);
|
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)
|
if (pixmap->mask)
|
||||||
{
|
{
|
||||||
@ -212,3 +232,94 @@ gtk_pixmap_expose (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
return FALSE;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,6 +45,9 @@ struct _GtkPixmap
|
|||||||
|
|
||||||
GdkPixmap *pixmap;
|
GdkPixmap *pixmap;
|
||||||
GdkBitmap *mask;
|
GdkBitmap *mask;
|
||||||
|
|
||||||
|
GdkPixmap *pixmap_insensitive;
|
||||||
|
guint build_insensitive : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkPixmapClass
|
struct _GtkPixmapClass
|
||||||
@ -63,6 +66,9 @@ void gtk_pixmap_get (GtkPixmap *pixmap,
|
|||||||
GdkPixmap **val,
|
GdkPixmap **val,
|
||||||
GdkBitmap **mask);
|
GdkBitmap **mask);
|
||||||
|
|
||||||
|
void gtk_pixmap_set_build_insensitive (GtkPixmap *pixmap,
|
||||||
|
guint build);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user