forked from AuroraMiddleware/gtk
This commit adds a cell_background property for cell renderers. With this
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org> This commit adds a cell_background property for cell renderers. With this property you can make your TreeView look incredibly ugly. * gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and cell_background_set properties, (set_cell_bg_color): new function, (gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property): support for new properties, (gtk_cell_renderer_render): render a background when set. * gtk/gtkcellrenderer.h: add cell_background_set and cell_background fields. * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action): when rendering, pass in just the background_area of the cell and not the background_area of the entire column.
This commit is contained in:
parent
1b771c4428
commit
cb3c5cc14d
20
ChangeLog
20
ChangeLog
@ -1,3 +1,22 @@
|
||||
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
This commit adds a cell_background property for cell renderers. With
|
||||
this property you can make your TreeView look incredibly ugly.
|
||||
|
||||
* gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and
|
||||
cell_background_set properties,
|
||||
(set_cell_bg_color): new function,
|
||||
(gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property):
|
||||
support for new properties,
|
||||
(gtk_cell_renderer_render): render a background when set.
|
||||
|
||||
* gtk/gtkcellrenderer.h: add cell_background_set and cell_background
|
||||
fields.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action):
|
||||
when rendering, pass in just the background_area of the cell and not
|
||||
the background_area of the entire column.
|
||||
|
||||
2002-04-22 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_drag_data_get): Use
|
||||
@ -18,7 +37,6 @@ Mon Apr 22 19:24:29 2002 Kristian Rietveld <kris@gtk.org>
|
||||
icon stuff in the cellrendererpixbuf instead of its own stock icon
|
||||
rendering code.
|
||||
|
||||
|
||||
2002-04-21 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
|
||||
|
@ -1,3 +1,22 @@
|
||||
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
This commit adds a cell_background property for cell renderers. With
|
||||
this property you can make your TreeView look incredibly ugly.
|
||||
|
||||
* gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and
|
||||
cell_background_set properties,
|
||||
(set_cell_bg_color): new function,
|
||||
(gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property):
|
||||
support for new properties,
|
||||
(gtk_cell_renderer_render): render a background when set.
|
||||
|
||||
* gtk/gtkcellrenderer.h: add cell_background_set and cell_background
|
||||
fields.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action):
|
||||
when rendering, pass in just the background_area of the cell and not
|
||||
the background_area of the entire column.
|
||||
|
||||
2002-04-22 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_drag_data_get): Use
|
||||
@ -18,7 +37,6 @@ Mon Apr 22 19:24:29 2002 Kristian Rietveld <kris@gtk.org>
|
||||
icon stuff in the cellrendererpixbuf instead of its own stock icon
|
||||
rendering code.
|
||||
|
||||
|
||||
2002-04-21 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
|
||||
|
@ -1,3 +1,22 @@
|
||||
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
This commit adds a cell_background property for cell renderers. With
|
||||
this property you can make your TreeView look incredibly ugly.
|
||||
|
||||
* gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and
|
||||
cell_background_set properties,
|
||||
(set_cell_bg_color): new function,
|
||||
(gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property):
|
||||
support for new properties,
|
||||
(gtk_cell_renderer_render): render a background when set.
|
||||
|
||||
* gtk/gtkcellrenderer.h: add cell_background_set and cell_background
|
||||
fields.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action):
|
||||
when rendering, pass in just the background_area of the cell and not
|
||||
the background_area of the entire column.
|
||||
|
||||
2002-04-22 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_drag_data_get): Use
|
||||
@ -18,7 +37,6 @@ Mon Apr 22 19:24:29 2002 Kristian Rietveld <kris@gtk.org>
|
||||
icon stuff in the cellrendererpixbuf instead of its own stock icon
|
||||
rendering code.
|
||||
|
||||
|
||||
2002-04-21 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
|
||||
|
@ -1,3 +1,22 @@
|
||||
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
This commit adds a cell_background property for cell renderers. With
|
||||
this property you can make your TreeView look incredibly ugly.
|
||||
|
||||
* gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and
|
||||
cell_background_set properties,
|
||||
(set_cell_bg_color): new function,
|
||||
(gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property):
|
||||
support for new properties,
|
||||
(gtk_cell_renderer_render): render a background when set.
|
||||
|
||||
* gtk/gtkcellrenderer.h: add cell_background_set and cell_background
|
||||
fields.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action):
|
||||
when rendering, pass in just the background_area of the cell and not
|
||||
the background_area of the entire column.
|
||||
|
||||
2002-04-22 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_drag_data_get): Use
|
||||
@ -18,7 +37,6 @@ Mon Apr 22 19:24:29 2002 Kristian Rietveld <kris@gtk.org>
|
||||
icon stuff in the cellrendererpixbuf instead of its own stock icon
|
||||
rendering code.
|
||||
|
||||
|
||||
2002-04-21 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
|
||||
|
@ -1,3 +1,22 @@
|
||||
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
This commit adds a cell_background property for cell renderers. With
|
||||
this property you can make your TreeView look incredibly ugly.
|
||||
|
||||
* gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and
|
||||
cell_background_set properties,
|
||||
(set_cell_bg_color): new function,
|
||||
(gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property):
|
||||
support for new properties,
|
||||
(gtk_cell_renderer_render): render a background when set.
|
||||
|
||||
* gtk/gtkcellrenderer.h: add cell_background_set and cell_background
|
||||
fields.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action):
|
||||
when rendering, pass in just the background_area of the cell and not
|
||||
the background_area of the entire column.
|
||||
|
||||
2002-04-22 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_drag_data_get): Use
|
||||
@ -18,7 +37,6 @@ Mon Apr 22 19:24:29 2002 Kristian Rietveld <kris@gtk.org>
|
||||
icon stuff in the cellrendererpixbuf instead of its own stock icon
|
||||
rendering code.
|
||||
|
||||
|
||||
2002-04-21 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
|
||||
|
@ -1,3 +1,22 @@
|
||||
Tue Apr 23 18:35:34 2002 Kristian Rietveld <kris@gtk.org>
|
||||
|
||||
This commit adds a cell_background property for cell renderers. With
|
||||
this property you can make your TreeView look incredibly ugly.
|
||||
|
||||
* gtk/gtkcellrenderer.c: add cell_background, cell_background_gdk and
|
||||
cell_background_set properties,
|
||||
(set_cell_bg_color): new function,
|
||||
(gtk_cell_renderer_get_property), (gtk_cell_renderer_set_property):
|
||||
support for new properties,
|
||||
(gtk_cell_renderer_render): render a background when set.
|
||||
|
||||
* gtk/gtkcellrenderer.h: add cell_background_set and cell_background
|
||||
fields.
|
||||
|
||||
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_cell_process_action):
|
||||
when rendering, pass in just the background_area of the cell and not
|
||||
the background_area of the entire column.
|
||||
|
||||
2002-04-22 Anders Carlsson <andersca@gnu.org>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_drag_data_get): Use
|
||||
@ -18,7 +37,6 @@ Mon Apr 22 19:24:29 2002 Kristian Rietveld <kris@gtk.org>
|
||||
icon stuff in the cellrendererpixbuf instead of its own stock icon
|
||||
rendering code.
|
||||
|
||||
|
||||
2002-04-21 Alexander Larsson <alla@lysator.liu.se>
|
||||
|
||||
* gdk/x11/gdkwindow-x11.c (gdk_window_reparent):
|
||||
|
@ -30,6 +30,8 @@ static void gtk_cell_renderer_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void set_cell_bg_color (GtkCellRenderer *cell,
|
||||
GdkColor *color);
|
||||
|
||||
|
||||
enum {
|
||||
@ -43,7 +45,10 @@ enum {
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT,
|
||||
PROP_IS_EXPANDER,
|
||||
PROP_IS_EXPANDED
|
||||
PROP_IS_EXPANDED,
|
||||
PROP_CELL_BACKGROUND,
|
||||
PROP_CELL_BACKGROUND_GDK,
|
||||
PROP_CELL_BACKGROUND_SET
|
||||
};
|
||||
|
||||
|
||||
@ -200,6 +205,29 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
|
||||
FALSE,
|
||||
G_PARAM_READABLE |
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_CELL_BACKGROUND,
|
||||
g_param_spec_string ("cell_background",
|
||||
_("Cell background color name"),
|
||||
_("Cell background color as a string"),
|
||||
NULL,
|
||||
G_PARAM_WRITABLE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_CELL_BACKGROUND_GDK,
|
||||
g_param_spec_boxed ("cell_background_gdk",
|
||||
_("Cell background color"),
|
||||
_("Cell background color as a GdkColor"),
|
||||
GDK_TYPE_COLOR,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
|
||||
|
||||
#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE))
|
||||
|
||||
ADD_SET_PROP ("cell_background_set", PROP_CELL_BACKGROUND_SET,
|
||||
_("Cell background set"),
|
||||
_("Whether this tag affects the cell background color"));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -242,6 +270,21 @@ gtk_cell_renderer_get_property (GObject *object,
|
||||
case PROP_IS_EXPANDED:
|
||||
g_value_set_int (value, cell->is_expanded);
|
||||
break;
|
||||
case PROP_CELL_BACKGROUND_GDK:
|
||||
{
|
||||
GdkColor color;
|
||||
|
||||
color.red = cell->cell_background.red;
|
||||
color.green = cell->cell_background.green;
|
||||
color.blue = cell->cell_background.blue;
|
||||
|
||||
g_value_set_boxed (value, &color);
|
||||
}
|
||||
break;
|
||||
case PROP_CELL_BACKGROUND_SET:
|
||||
g_value_set_boolean (value, cell->cell_background_set);
|
||||
break;
|
||||
case PROP_CELL_BACKGROUND:
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
@ -289,12 +332,58 @@ gtk_cell_renderer_set_property (GObject *object,
|
||||
case PROP_IS_EXPANDED:
|
||||
cell->is_expanded = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CELL_BACKGROUND:
|
||||
{
|
||||
GdkColor color;
|
||||
|
||||
if (!g_value_get_string (value))
|
||||
set_cell_bg_color (cell, NULL);
|
||||
else if (gdk_color_parse (g_value_get_string (value), &color))
|
||||
set_cell_bg_color (cell, &color);
|
||||
else
|
||||
g_warning ("Don't know color `%s'", g_value_get_string (value));
|
||||
|
||||
g_object_notify (object, "cell_background_gdk");
|
||||
}
|
||||
break;
|
||||
case PROP_CELL_BACKGROUND_GDK:
|
||||
set_cell_bg_color (cell, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_CELL_BACKGROUND_SET:
|
||||
cell->cell_background_set = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_cell_bg_color (GtkCellRenderer *cell,
|
||||
GdkColor *color)
|
||||
{
|
||||
if (color)
|
||||
{
|
||||
if (!cell->cell_background_set)
|
||||
{
|
||||
cell->cell_background_set = TRUE;
|
||||
g_object_notify (G_OBJECT (cell), "cell_background_set");
|
||||
}
|
||||
|
||||
cell->cell_background.red = color->red;
|
||||
cell->cell_background.green = color->green;
|
||||
cell->cell_background.blue = color->blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cell->cell_background_set)
|
||||
{
|
||||
cell->cell_background_set = FALSE;
|
||||
g_object_notify (G_OBJECT (cell), "cell_background_set");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_get_size:
|
||||
* @cell: a #GtkCellRenderer
|
||||
@ -369,9 +458,30 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
gboolean selected = FALSE;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
|
||||
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
|
||||
|
||||
selected = (flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED;
|
||||
|
||||
if (cell->cell_background_set && !selected)
|
||||
{
|
||||
GdkColor color;
|
||||
GdkGC *gc;
|
||||
|
||||
color.red = cell->cell_background.red;
|
||||
color.green = cell->cell_background.green;
|
||||
color.blue = cell->cell_background.blue;
|
||||
|
||||
gc = gdk_gc_new (window);
|
||||
gdk_gc_set_rgb_fg_color (gc, &color);
|
||||
gdk_draw_rectangle (window, gc, TRUE,
|
||||
background_area->x, background_area->y,
|
||||
background_area->width, background_area->height);
|
||||
g_object_unref (G_OBJECT (gc));
|
||||
}
|
||||
|
||||
GTK_CELL_RENDERER_GET_CLASS (cell)->render (cell,
|
||||
window,
|
||||
widget,
|
||||
|
@ -69,6 +69,10 @@ struct _GtkCellRenderer
|
||||
guint visible : 1;
|
||||
guint is_expander : 1;
|
||||
guint is_expanded : 1;
|
||||
|
||||
guint cell_background_set : 1;
|
||||
|
||||
GdkColor cell_background;
|
||||
};
|
||||
|
||||
struct _GtkCellRendererClass
|
||||
|
@ -2326,11 +2326,13 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
{
|
||||
GList *list;
|
||||
GdkRectangle real_cell_area;
|
||||
GdkRectangle real_background_area;
|
||||
gint expand_cell_count = 0;
|
||||
gint full_requested_width = 0;
|
||||
gint extra_space;
|
||||
gint min_x, min_y, max_x, max_y;
|
||||
gint focus_line_width;
|
||||
gint dx;
|
||||
|
||||
min_x = G_MAXINT;
|
||||
min_y = G_MAXINT;
|
||||
@ -2338,6 +2340,8 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
max_y = 0;
|
||||
|
||||
real_cell_area = *cell_area;
|
||||
real_background_area = *background_area;
|
||||
dx = real_cell_area.x - real_background_area.x;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (tree_column->tree_view),
|
||||
"focus-line-width", &focus_line_width,
|
||||
@ -2373,12 +2377,18 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
(info->expand?extra_space:0);
|
||||
info->real_width = real_cell_area.width;
|
||||
real_cell_area.x += focus_line_width;
|
||||
|
||||
real_background_area.width = real_cell_area.width;
|
||||
real_background_area.x += focus_line_width;
|
||||
if (!list->prev)
|
||||
real_background_area.width += dx;
|
||||
|
||||
if (action == CELL_ACTION_RENDER)
|
||||
{
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
background_area,
|
||||
&real_background_area,
|
||||
&real_cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
@ -2457,6 +2467,7 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
}
|
||||
}
|
||||
real_cell_area.x += (info->requested_width + tree_column->spacing);
|
||||
real_background_area.x += (info->requested_width + tree_column->spacing);
|
||||
}
|
||||
for (list = g_list_last (tree_column->cell_list); list; list = list->prev)
|
||||
{
|
||||
@ -2471,12 +2482,13 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
real_cell_area.width = info->requested_width +
|
||||
(info->expand?extra_space:0);
|
||||
info->real_width = real_cell_area.width;
|
||||
real_background_area.width = real_background_area.width;
|
||||
if (action == CELL_ACTION_RENDER)
|
||||
{
|
||||
gtk_cell_renderer_render (info->cell,
|
||||
window,
|
||||
tree_column->tree_view,
|
||||
background_area,
|
||||
&real_background_area,
|
||||
&real_cell_area,
|
||||
expose_area,
|
||||
flags);
|
||||
@ -2501,6 +2513,7 @@ gtk_tree_view_column_cell_process_action (GtkTreeViewColumn *tree_column,
|
||||
max_y = real_cell_area.y + y_offset + height;
|
||||
}
|
||||
real_cell_area.x += (info->requested_width + tree_column->spacing);
|
||||
real_background_area.x += (info->requested_width + tree_column->spacing);
|
||||
}
|
||||
|
||||
if (action == CELL_ACTION_FOCUS)
|
||||
|
Loading…
Reference in New Issue
Block a user