summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Hamann <lars@gtk.org>1998-10-16 15:00:05 +0000
committerLars Hamann <lars@src.gnome.org>1998-10-16 15:00:05 +0000
commiteff33964d753abf04786ce1f03a8cffff5a76cd2 (patch)
treed029375876fc861c20d82276306d301d706936cb
parent0849664209839adf6fe85608e1303ab44de26d63 (diff)
downloadgtk+-eff33964d753abf04786ce1f03a8cffff5a76cd2.tar.gz
change a few cell styles of inserted row (change_style): change style of
Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org> * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell styles of inserted row (change_style): change style of focus_row * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style) (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions to set/get row/cell styles. (gtk_clist_realize): attach row and cell style, allocate row colors. (gtk_clist_unrealize): detach row and cell styles. (get_cell_style): new function. get correct cell style. (draw_cell_pixmap): new function. (draw_row): draw cells with row or cell styles. (row_new): set cell and row styles to NULL. (row_delete): detach & unref cell and row styles. * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles): new functions to attach/detach styles and allocate colors. (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row styles of invisible nodes. (draw_cell_pixmap): new function. (get_cell_style): new function. get correct cell style. (gtk_ctree_draw_expander): new function. draw tree expander. (gtk_ctree_draw_lines): new function.draw tree lines. (draw_row): draw cells with row or cell styles. (row_new): set cell and row styles to NULL. (row_delete): detach & unref cell and row styles. (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style) (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style): Analogons of GtkCList functions (gtk_ctree_set_spacing): new function. set spacing between tree expander and cell contents (gtk_ctree_set_expander_style): new function. set expander style of ctree. (ctree_is_hot_spot): few changes due to draw_row modifications.
-rw-r--r--ChangeLog39
-rw-r--r--ChangeLog.pre-2-039
-rw-r--r--ChangeLog.pre-2-1039
-rw-r--r--ChangeLog.pre-2-239
-rw-r--r--ChangeLog.pre-2-439
-rw-r--r--ChangeLog.pre-2-639
-rw-r--r--ChangeLog.pre-2-839
-rw-r--r--gtk/gtkclist.c730
-rw-r--r--gtk/gtkclist.h49
-rw-r--r--gtk/gtkctree.c2367
-rw-r--r--gtk/gtkctree.h66
-rw-r--r--gtk/testgtk.c504
-rw-r--r--tests/testgtk.c504
13 files changed, 2666 insertions, 1827 deletions
diff --git a/ChangeLog b/ChangeLog
index c11edc544e..552a072aad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index c11edc544e..552a072aad 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index c11edc544e..552a072aad 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index c11edc544e..552a072aad 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index c11edc544e..552a072aad 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index c11edc544e..552a072aad 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index c11edc544e..552a072aad 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,4 +1,41 @@
-Wed, 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
+Fri Oct 16 15:59:02 1998 Lars Hamann <lars@gtk.org>
+
+ * gtk/testgtk.c (insert_row_clist) (create_clist): change a few cell
+ styles of inserted row
+ (change_style): change style of focus_row
+
+ * gtk/gtkclist.c (gtk_clist_get_row_style) (gtk_clist_set_row_style)
+ (gtk_clist_get_cell_style) (gtk_clist_set_cell_style): new functions
+ to set/get row/cell styles.
+ (gtk_clist_realize): attach row and cell style, allocate row colors.
+ (gtk_clist_unrealize): detach row and cell styles.
+ (get_cell_style): new function. get correct cell style.
+ (draw_cell_pixmap): new function.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+
+ * gtk/gtkctree.c (ctree_detach_styles) (ctree_attach_styles):
+ new functions to attach/detach styles and allocate colors.
+ (gtk_ctree_realize) (gtk_ctree_unrealize): attach/detach cell and row
+ styles of invisible nodes.
+ (draw_cell_pixmap): new function.
+ (get_cell_style): new function. get correct cell style.
+ (gtk_ctree_draw_expander): new function. draw tree expander.
+ (gtk_ctree_draw_lines): new function.draw tree lines.
+ (draw_row): draw cells with row or cell styles.
+ (row_new): set cell and row styles to NULL.
+ (row_delete): detach & unref cell and row styles.
+ (gtk_ctree_node_get_row_style) (gtk_ctree_node_set_row_style)
+ (gtk_ctree_node_get_cell_style) (gtk_ctree_node_set_cell_style):
+ Analogons of GtkCList functions
+ (gtk_ctree_set_spacing): new function. set spacing between
+ tree expander and cell contents
+ (gtk_ctree_set_expander_style): new function. set expander style
+ of ctree.
+ (ctree_is_hot_spot): few changes due to draw_row modifications.
+
+Wed 14 Oct 1998 10:17:13 +0200 Paolo Molaro <lupus@debian.org>
* gtk/gtkcombo.c: try completion on MOD1-TAB.
Handle case when the combo->list is empty.
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index ea1dc32033..886174ed8a 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -213,6 +213,22 @@ static void gtk_clist_forall (GtkContainer *container,
gpointer callback_data);
/* Drawing */
+static void get_cell_style (GtkCList *clist,
+ GtkCListRow *clist_row,
+ gint state,
+ gint column,
+ GtkStyle **style,
+ GdkGC **fg_gc,
+ GdkGC **bg_gc);
+static gint draw_cell_pixmap (GdkWindow *window,
+ GdkRectangle *clip_rectangle,
+ GdkGC *fg_gc,
+ GdkPixmap *pixmap,
+ GdkBitmap *mask,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
static void draw_row (GtkCList * clist,
GdkRectangle * area,
gint row,
@@ -1418,7 +1434,8 @@ gtk_clist_set_row_height (GtkCList * clist,
{
text_height = height - (GTK_WIDGET (clist)->style->font->ascent +
GTK_WIDGET (clist) ->style->font->descent + 1);
- clist->row_center_offset = (text_height / 2) + GTK_WIDGET (clist)->style->font->ascent + 1.5;
+ clist->row_center_offset = ((text_height / 2) + 1.5 +
+ GTK_WIDGET (clist)->style->font->ascent);
}
if (!GTK_CLIST_FROZEN (clist))
@@ -1704,6 +1721,9 @@ gtk_clist_set_foreground (GtkCList * clist,
{
clist_row->foreground = *color;
clist_row->fg_set = TRUE;
+ if (GTK_WIDGET_REALIZED (clist))
+ gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (clist)),
+ &clist_row->foreground);
}
else
clist_row->fg_set = FALSE;
@@ -1732,6 +1752,9 @@ gtk_clist_set_background (GtkCList * clist,
{
clist_row->background = *color;
clist_row->bg_set = TRUE;
+ if (GTK_WIDGET_REALIZED (clist))
+ gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (clist)),
+ &clist_row->background);
}
else
clist_row->bg_set = FALSE;
@@ -2517,12 +2540,15 @@ gtk_clist_finalize (GtkObject * object)
static void
gtk_clist_realize (GtkWidget * widget)
{
- gint i;
GtkCList *clist;
GdkWindowAttr attributes;
- gint attributes_mask;
GdkGCValues values;
+ GtkCListRow *clist_row;
+ GList *list;
+ gint attributes_mask;
gint border_width;
+ gint i;
+ gint j;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CLIST (widget));
@@ -2552,7 +2578,8 @@ gtk_clist_realize (GtkWidget * widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
/* main window */
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
+ widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, clist);
widget->style = gtk_style_attach (widget->style, widget->window);
@@ -2566,28 +2593,35 @@ gtk_clist_realize (GtkWidget * widget)
attributes.width = clist->column_title_area.width;
attributes.height = clist->column_title_area.height;
- clist->title_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ clist->title_window = gdk_window_new (widget->window, &attributes,
+ attributes_mask);
gdk_window_set_user_data (clist->title_window, clist);
- gtk_style_set_background (widget->style, clist->title_window, GTK_STATE_SELECTED);
+ gtk_style_set_background (widget->style, clist->title_window,
+ GTK_STATE_SELECTED);
gdk_window_show (clist->title_window);
/* set things up so column buttons are drawn in title window */
for (i = 0; i < clist->columns; i++)
if (clist->column[i].button)
- gtk_widget_set_parent_window (clist->column[i].button, clist->title_window);
+ gtk_widget_set_parent_window (clist->column[i].button,
+ clist->title_window);
/* clist-window */
- attributes.x = clist->internal_allocation.x + widget->style->klass->xthickness;
- attributes.y = clist->internal_allocation.y + widget->style->klass->ythickness +
- clist->column_title_area.height;
+ attributes.x = (clist->internal_allocation.x +
+ widget->style->klass->xthickness);
+ attributes.y = (clist->internal_allocation.y +
+ widget->style->klass->ythickness +
+ clist->column_title_area.height);
attributes.width = clist->clist_window_width;
attributes.height = clist->clist_window_height;
- clist->clist_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ clist->clist_window = gdk_window_new (widget->window, &attributes,
+ attributes_mask);
gdk_window_set_user_data (clist->clist_window, clist);
- gdk_window_set_background (clist->clist_window, &widget->style->bg[GTK_STATE_PRELIGHT]);
+ gdk_window_set_background (clist->clist_window,
+ &widget->style->bg[GTK_STATE_PRELIGHT]);
gdk_window_show (clist->clist_window);
gdk_window_get_size (clist->clist_window, &clist->clist_window_width,
&clist->clist_window_height);
@@ -2599,9 +2633,10 @@ gtk_clist_realize (GtkWidget * widget)
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
GDK_KEY_PRESS_MASK);
- attributes.cursor = clist->cursor_drag = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
attributes_mask = GDK_WA_CURSOR;
-
+ attributes.cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
+ clist->cursor_drag = attributes.cursor;
+
attributes.x = LIST_WIDTH (clist) + 1;
attributes.y = 0;
attributes.width = 0;
@@ -2609,7 +2644,8 @@ gtk_clist_realize (GtkWidget * widget)
for (i = 0; i < clist->columns; i++)
{
- clist->column[i].window = gdk_window_new (clist->title_window, &attributes, attributes_mask);
+ clist->column[i].window = gdk_window_new (clist->title_window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (clist->column[i].window, clist);
}
@@ -2633,6 +2669,34 @@ gtk_clist_realize (GtkWidget * widget)
GDK_GC_FOREGROUND |
GDK_GC_FUNCTION |
GDK_GC_SUBWINDOW);
+
+ /* attach optional row/cell styles, allocate foreground/background colors */
+ list = clist->row_list;
+ for (i = 0; i < clist->rows; i++)
+ {
+ clist_row = list->data;
+ list = list->next;
+
+ if (clist_row->style)
+ clist_row->style = gtk_style_attach (clist_row->style,
+ clist->clist_window);
+
+ if (clist_row->fg_set || clist_row->bg_set)
+ {
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (widget);
+ if (clist_row->fg_set)
+ gdk_color_alloc (colormap, &clist_row->foreground);
+ if (clist_row->bg_set)
+ gdk_color_alloc (colormap, &clist_row->background);
+ }
+
+ for (j = 0; j < clist->columns; j++)
+ if (clist_row->cell[j].style)
+ clist_row->cell[j].style =
+ gtk_style_attach (clist_row->cell[j].style, clist->clist_window);
+ }
}
static void
@@ -2648,6 +2712,28 @@ gtk_clist_unrealize (GtkWidget * widget)
GTK_CLIST_SET_FLAG (clist, CLIST_FROZEN);
+ /* detach optional row/cell styles */
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ GtkCListRow *clist_row;
+ GList *list;
+ gint j;
+
+ list = clist->row_list;
+ for (i = 0; i < clist->rows; i++)
+ {
+ clist_row = list->data;
+ list = list->next;
+
+ if (clist_row->style)
+ gtk_style_detach (clist_row->style);
+ for (j = 0; j < clist->columns; j++)
+ if (clist_row->cell[j].style)
+ gtk_style_detach (clist_row->cell[j].style);
+ }
+ }
+
gdk_cursor_destroy (clist->cursor_drag);
gdk_gc_destroy (clist->xor_gc);
gdk_gc_destroy (clist->fg_gc);
@@ -3620,9 +3706,102 @@ gtk_clist_forall (GtkContainer *container,
/*
* DRAWING
+ * get_cell_style
+ * draw_cell_pixmap
* draw_row
* draw_rows
*/
+
+static void
+get_cell_style (GtkCList *clist,
+ GtkCListRow *clist_row,
+ gint state,
+ gint column,
+ GtkStyle **style,
+ GdkGC **fg_gc,
+ GdkGC **bg_gc)
+{
+ if (clist_row->cell[column].style)
+ {
+ if (style)
+ *style = clist_row->cell[column].style;
+ if (fg_gc)
+ *fg_gc = clist_row->cell[column].style->fg_gc[state];
+ if (bg_gc)
+ *bg_gc = clist_row->cell[column].style->bg_gc[state];
+ }
+ else if (clist_row->style)
+ {
+ if (style)
+ *style = clist_row->style;
+ if (fg_gc)
+ *fg_gc = clist_row->style->fg_gc[state];
+ if (bg_gc)
+ *bg_gc = clist_row->style->bg_gc[state];
+ }
+ else
+ {
+ if (style)
+ *style = GTK_WIDGET (clist)->style;
+ if (fg_gc)
+ *fg_gc = GTK_WIDGET (clist)->style->fg_gc[state];
+ if (bg_gc)
+ *bg_gc = GTK_WIDGET (clist)->style->bg_gc[state];
+
+ if (state != GTK_STATE_SELECTED)
+ {
+ if (fg_gc && clist_row->fg_set)
+ *fg_gc = clist->fg_gc;
+ if (bg_gc && clist_row->bg_set)
+ *bg_gc = clist->bg_gc;
+ }
+ }
+}
+
+static gint
+draw_cell_pixmap (GdkWindow *window,
+ GdkRectangle *clip_rectangle,
+ GdkGC *fg_gc,
+ GdkPixmap *pixmap,
+ GdkBitmap *mask,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
+{
+ gint xsrc = 0;
+ gint ysrc = 0;
+
+ if (mask)
+ {
+ gdk_gc_set_clip_mask (fg_gc, mask);
+ gdk_gc_set_clip_origin (fg_gc, x, y);
+ }
+
+ if (x < clip_rectangle->x)
+ {
+ xsrc = clip_rectangle->x - x;
+ width -= xsrc;
+ x = clip_rectangle->x;
+ }
+ if (x + width > clip_rectangle->x + clip_rectangle->width)
+ width = clip_rectangle->x + clip_rectangle->width - x;
+
+ if (y < clip_rectangle->y)
+ {
+ ysrc = clip_rectangle->y - y;
+ height -= ysrc;
+ y = clip_rectangle->y;
+ }
+ if (y + height > clip_rectangle->y + clip_rectangle->height)
+ height = clip_rectangle->y + clip_rectangle->height - y;
+
+ gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);
+ gdk_gc_set_clip_origin (fg_gc, 0, 0);
+
+ return x + MAX (width, 0);
+}
+
static void
draw_row (GtkCList * clist,
GdkRectangle * area,
@@ -3630,19 +3809,18 @@ draw_row (GtkCList * clist,
GtkCListRow * clist_row)
{
GtkWidget *widget;
- GdkGC *fg_gc, *bg_gc;
- GdkRectangle row_rectangle, cell_rectangle, clip_rectangle, intersect_rectangle,
- *rect;
- gint i, offset = 0, width, height, pixmap_width = 0;
- gint xsrc, ysrc, xdest, ydest;
+ GdkRectangle *rect;
+ GdkRectangle row_rectangle;
+ GdkRectangle cell_rectangle;
+ GdkRectangle clip_rectangle;
+ GdkRectangle intersect_rectangle;
+ gint state;
+ gint i;
g_return_if_fail (clist != NULL);
/* bail now if we arn't drawable yet */
- if (!GTK_WIDGET_DRAWABLE (clist))
- return;
-
- if (row < 0 || row >= clist->rows)
+ if (!GTK_WIDGET_DRAWABLE (clist) || row < 0 || row >= clist->rows)
return;
widget = GTK_WIDGET (clist);
@@ -3671,35 +3849,23 @@ draw_row (GtkCList * clist,
clip_rectangle.y = row_rectangle.y;
clip_rectangle.height = row_rectangle.height;
- /* select GC for background rectangle */
- if (clist_row->state == GTK_STATE_SELECTED)
- {
- fg_gc = widget->style->fg_gc[GTK_STATE_SELECTED];
- bg_gc = widget->style->bg_gc[GTK_STATE_SELECTED];
- }
- else
+ if (clist_row->state == GTK_STATE_NORMAL)
{
+ state = GTK_STATE_PRELIGHT;
if (clist_row->fg_set)
- {
- gdk_gc_set_foreground (clist->fg_gc, &clist_row->foreground);
- fg_gc = clist->fg_gc;
- }
- else
- fg_gc = widget->style->fg_gc[GTK_STATE_NORMAL];
-
+ gdk_gc_set_foreground (clist->fg_gc, &clist_row->foreground);
if (clist_row->bg_set)
- {
- gdk_gc_set_foreground (clist->bg_gc, &clist_row->background);
- bg_gc = clist->bg_gc;
- }
- else
- bg_gc = widget->style->bg_gc[GTK_STATE_PRELIGHT];
+ gdk_gc_set_foreground (clist->bg_gc, &clist_row->background);
}
+ else
+ state = clist_row->state;
/* draw the cell borders and background */
if (area)
{
- if (gdk_rectangle_intersect (area, &cell_rectangle, &intersect_rectangle))
+ rect = &intersect_rectangle;
+ if (gdk_rectangle_intersect (area, &cell_rectangle,
+ &intersect_rectangle))
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_NORMAL],
TRUE,
@@ -3713,7 +3879,8 @@ draw_row (GtkCList * clist,
{
cell_rectangle.y += clist->row_height + CELL_SPACING;
- if (gdk_rectangle_intersect (area, &cell_rectangle, &intersect_rectangle))
+ if (gdk_rectangle_intersect (area, &cell_rectangle,
+ &intersect_rectangle))
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_NORMAL],
TRUE,
@@ -3723,26 +3890,13 @@ draw_row (GtkCList * clist,
intersect_rectangle.height);
}
- if (!gdk_rectangle_intersect (area, &row_rectangle, &intersect_rectangle))
+ if (!gdk_rectangle_intersect (area, &row_rectangle,&intersect_rectangle))
return;
- if (clist_row->state == GTK_STATE_SELECTED || clist_row->bg_set)
- gdk_draw_rectangle (clist->clist_window,
- bg_gc,
- TRUE,
- intersect_rectangle.x,
- intersect_rectangle.y,
- intersect_rectangle.width,
- intersect_rectangle.height);
- else
- gdk_window_clear_area (clist->clist_window,
- intersect_rectangle.x,
- intersect_rectangle.y,
- intersect_rectangle.width,
- intersect_rectangle.height);
}
else
{
+ rect = &clip_rectangle;
gdk_draw_rectangle (clist->clist_window,
widget->style->base_gc[GTK_STATE_NORMAL],
TRUE,
@@ -3764,75 +3918,68 @@ draw_row (GtkCList * clist,
cell_rectangle.width,
cell_rectangle.height);
}
-
- if (clist_row->state == GTK_STATE_SELECTED || clist_row->bg_set)
- gdk_draw_rectangle (clist->clist_window,
- bg_gc,
- TRUE,
- row_rectangle.x,
- row_rectangle.y,
- row_rectangle.width,
- row_rectangle.height);
- else
- gdk_window_clear_area (clist->clist_window,
- row_rectangle.x,
- row_rectangle.y,
- row_rectangle.width,
- row_rectangle.height);
}
-
+
/* iterate and draw all the columns (row cells) and draw their contents */
for (i = 0; i < clist->columns; i++)
{
+ GtkStyle *style;
+ GdkGC *fg_gc;
+ GdkGC *bg_gc;
+
+ gint width;
+ gint height;
+ gint pixmap_width;
+ gint offset = 0;
+ gint row_center_offset;
+
if (!clist->column[i].visible)
continue;
+ get_cell_style (clist, clist_row, state, i, &style, &fg_gc, &bg_gc);
+
clip_rectangle.x = clist->column[i].area.x + clist->hoffset;
clip_rectangle.width = clist->column[i].area.width;
/* calculate clipping region clipping region */
- if (!area)
- {
- rect = &clip_rectangle;
- }
- else
- {
- if (!gdk_rectangle_intersect (area, &clip_rectangle,
- &intersect_rectangle))
- continue;
- rect = &intersect_rectangle;
- }
+ clip_rectangle.x -= COLUMN_INSET + CELL_SPACING;
+ clip_rectangle.width += (2 * COLUMN_INSET + CELL_SPACING +
+ (i + 1 == clist->columns) * CELL_SPACING);
+
+ if (area && !gdk_rectangle_intersect (area, &clip_rectangle,
+ &intersect_rectangle))
+ continue;
+
+ gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
+ rect->x, rect->y, rect->width, rect->height);
+
+ clip_rectangle.x += COLUMN_INSET + CELL_SPACING;
+ clip_rectangle.width -= (2 * COLUMN_INSET + CELL_SPACING +
+ (i + 1 == clist->columns) * CELL_SPACING);
/* calculate real width for column justification */
+ pixmap_width = 0;
+ offset = 0;
switch (clist_row->cell[i].type)
{
- case GTK_CELL_EMPTY:
- continue;
- break;
-
case GTK_CELL_TEXT:
- width = gdk_string_width (GTK_WIDGET (clist)->style->font,
+ width = gdk_string_width (style->font,
GTK_CELL_TEXT (clist_row->cell[i])->text);
break;
-
case GTK_CELL_PIXMAP:
- gdk_window_get_size (GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap, &width, &height);
- pixmap_width = width;
+ gdk_window_get_size (GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
+ &pixmap_width, &height);
+ width = pixmap_width;
break;
-
case GTK_CELL_PIXTEXT:
- gdk_window_get_size (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap, &width, &height);
- pixmap_width = width;
- width += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
- width += gdk_string_width (GTK_WIDGET (clist)->style->font,
- GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
+ gdk_window_get_size (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
+ &pixmap_width, &height);
+ width = (pixmap_width +
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
+ gdk_string_width (style->font,
+ GTK_CELL_PIXTEXT
+ (clist_row->cell[i])->text));
break;
-
- case GTK_CELL_WIDGET:
- /* unimplimented */
- continue;
- break;
-
default:
continue;
break;
@@ -3841,182 +3988,81 @@ draw_row (GtkCList * clist,
switch (clist->column[i].justification)
{
case GTK_JUSTIFY_LEFT:
- offset = clip_rectangle.x;
+ offset = clip_rectangle.x + clist_row->cell[i].horizontal;
break;
-
case GTK_JUSTIFY_RIGHT:
- offset = (clip_rectangle.x + clip_rectangle.width) - width;
+ offset = (clip_rectangle.x + clist_row->cell[i].horizontal +
+ clip_rectangle.width - width);
break;
-
case GTK_JUSTIFY_CENTER:
- offset = (clip_rectangle.x + (clip_rectangle.width / 2)) - (width / 2);
- break;
-
case GTK_JUSTIFY_FILL:
- offset = (clip_rectangle.x + (clip_rectangle.width / 2)) - (width / 2);
- break;
-
- default:
- offset = 0;
+ offset = (clip_rectangle.x + clist_row->cell[i].horizontal +
+ (clip_rectangle.width / 2) - (width / 2));
break;
};
- /* Draw Text or Pixmap */
+ /* Draw Text and/or Pixmap */
switch (clist_row->cell[i].type)
{
- case GTK_CELL_EMPTY:
- continue;
- break;
-
- case GTK_CELL_TEXT:
- gdk_gc_set_clip_rectangle (fg_gc, rect);
-
- gdk_draw_string (clist->clist_window,
- widget->style->font,
- fg_gc,
- offset + clist_row->cell[i].horizontal,
- row_rectangle.y + clist->row_center_offset +
- clist_row->cell[i].vertical,
- GTK_CELL_TEXT (clist_row->cell[i])->text);
-
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
- break;
-
case GTK_CELL_PIXMAP:
- xsrc = 0;
- ysrc = 0;
- xdest = offset + clist_row->cell[i].horizontal;
- ydest = (clip_rectangle.y + (clip_rectangle.height / 2)) - height / 2 +
- clist_row->cell[i].vertical;
-
- if (xdest < clip_rectangle.x)
- {
- xsrc = clip_rectangle.x - xdest;
- pixmap_width -= xsrc;
- xdest = clip_rectangle.x;
- }
-
- if (xdest + pixmap_width > clip_rectangle.x + clip_rectangle.width)
- pixmap_width = (clip_rectangle.x + clip_rectangle.width) - xdest;
-
- if (ydest < clip_rectangle.y)
- {
- ysrc = clip_rectangle.y - ydest;
- height -= ysrc;
- ydest = clip_rectangle.y;
- }
-
- if (ydest + height > clip_rectangle.y + clip_rectangle.height)
- height = (clip_rectangle.y + clip_rectangle.height) - ydest;
-
- if (GTK_CELL_PIXMAP (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXMAP (clist_row->cell[i])->mask);
- gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
- }
- gdk_draw_pixmap (clist->clist_window,
- fg_gc,
- GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
- xsrc, ysrc,
- xdest, ydest,
- pixmap_width, height);
-
- if (GTK_CELL_PIXMAP (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_origin (fg_gc, 0, 0);
- gdk_gc_set_clip_mask (fg_gc, NULL);
- }
+ draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,
+ GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
+ GTK_CELL_PIXMAP (clist_row->cell[i])->mask,
+ offset,
+ clip_rectangle.y + clist_row->cell[i].vertical +
+ (clip_rectangle.height - height) / 2,
+ pixmap_width, height);
break;
-
case GTK_CELL_PIXTEXT:
- /* draw the pixmap */
- xsrc = 0;
- ysrc = 0;
- xdest = offset + clist_row->cell[i].horizontal;
- ydest = (clip_rectangle.y + (clip_rectangle.height / 2)) - height / 2 +
- clist_row->cell[i].vertical;
-
- if (xdest < clip_rectangle.x)
- {
- xsrc = clip_rectangle.x - xdest;
- pixmap_width -= xsrc;
- xdest = clip_rectangle.x;
- }
-
- if (xdest + pixmap_width > clip_rectangle.x + clip_rectangle.width)
- pixmap_width = (clip_rectangle.x + clip_rectangle.width) - xdest;
-
- if (ydest < clip_rectangle.y)
- {
- ysrc = clip_rectangle.y - ydest;
- height -= ysrc;
- ydest = clip_rectangle.y;
- }
+ offset =
+ draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->mask,
+ offset,
+ clip_rectangle.y + clist_row->cell[i].vertical+
+ (clip_rectangle.height - height) / 2,
+ pixmap_width, height);
+ offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
+ case GTK_CELL_TEXT:
+ if (style != GTK_WIDGET (clist)->style)
+ row_center_offset = (((clist->row_height - style->font->ascent -
+ style->font->descent - 1) / 2) + 1.5 +
+ style->font->ascent);
+ else
+ row_center_offset = clist->row_center_offset;
- if (ydest + height > clip_rectangle.y + clip_rectangle.height)
- height = (clip_rectangle.y + clip_rectangle.height) - ydest;
-
- if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
- gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
- }
-
- gdk_draw_pixmap (clist->clist_window,
- fg_gc,
- GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
- xsrc, ysrc,
- xdest,
- ydest,
- pixmap_width, height);
-
- gdk_gc_set_clip_origin (fg_gc, 0, 0);
-
- offset += pixmap_width + GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
-
- /* draw the string */
- gdk_gc_set_clip_rectangle (fg_gc, rect);
-
- gdk_draw_string (clist->clist_window,
- widget->style->font,
- fg_gc,
- offset + clist_row->cell[i].horizontal,
- row_rectangle.y + clist->row_center_offset +
+ gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
+ gdk_draw_string (clist->clist_window, style->font, fg_gc,
+ offset,
+ row_rectangle.y + row_center_offset +
clist_row->cell[i].vertical,
- GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
-
+ (clist_row->cell[i].type == GTK_CELL_PIXTEXT) ?
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->text :
+ GTK_CELL_TEXT (clist_row->cell[i])->text);
gdk_gc_set_clip_rectangle (fg_gc, NULL);
break;
-
- case GTK_CELL_WIDGET:
- /* unimplimented */
- continue;
- break;
-
default:
- continue;
break;
}
}
+
+ /* draw focus rectangle */
if (clist->focus_row == row && GTK_WIDGET_HAS_FOCUS (widget))
{
- if (area)
- {
- if (gdk_rectangle_intersect (area, &row_rectangle,
- &intersect_rectangle))
- {
- gdk_gc_set_clip_rectangle (clist->xor_gc, &intersect_rectangle);
- gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
- row_rectangle.x, row_rectangle.y,
- row_rectangle.width - 1,
- row_rectangle.height - 1);
- gdk_gc_set_clip_rectangle (clist->xor_gc, NULL);
- }
- }
- else
+ if (!area)
gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
row_rectangle.x, row_rectangle.y,
row_rectangle.width - 1, row_rectangle.height - 1);
+ else if (gdk_rectangle_intersect (area, &row_rectangle,
+ &intersect_rectangle))
+ {
+ gdk_gc_set_clip_rectangle (clist->xor_gc, &intersect_rectangle);
+ gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
+ row_rectangle.x, row_rectangle.y,
+ row_rectangle.width - 1,
+ row_rectangle.height - 1);
+ gdk_gc_set_clip_rectangle (clist->xor_gc, NULL);
+ }
}
}
@@ -4993,10 +5039,12 @@ row_new (GtkCList * clist)
clist_row->cell[i].type = GTK_CELL_EMPTY;
clist_row->cell[i].vertical = 0;
clist_row->cell[i].horizontal = 0;
+ clist_row->cell[i].style = NULL;
}
clist_row->fg_set = FALSE;
clist_row->bg_set = FALSE;
+ clist_row->style = NULL;
clist_row->selectable = TRUE;
clist_row->state = GTK_STATE_NORMAL;
clist_row->data = NULL;
@@ -5012,8 +5060,23 @@ row_delete (GtkCList * clist,
gint i;
for (i = 0; i < clist->columns; i++)
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
- (clist, clist_row, i, GTK_CELL_EMPTY, NULL, 0, NULL, NULL);
+ {
+ GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ (clist, clist_row, i, GTK_CELL_EMPTY, NULL, 0, NULL, NULL);
+ if (clist_row->cell[i].style)
+ {
+ if (GTK_WIDGET_REALIZED (clist))
+ gtk_style_detach (clist_row->cell[i].style);
+ gtk_style_unref (clist_row->cell[i].style);
+ }
+ }
+
+ if (clist_row->style)
+ {
+ if (GTK_WIDGET_REALIZED (clist))
+ gtk_style_detach (clist_row->style);
+ gtk_style_unref (clist_row->style);
+ }
if (clist_row->destroy)
clist_row->destroy (clist_row->data);
@@ -5038,28 +5101,23 @@ set_cell_contents (GtkCList *clist,
{
case GTK_CELL_EMPTY:
break;
-
case GTK_CELL_TEXT:
g_free (GTK_CELL_TEXT (clist_row->cell[column])->text);
break;
-
case GTK_CELL_PIXMAP:
gdk_pixmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->pixmap);
if (GTK_CELL_PIXMAP (clist_row->cell[column])->mask)
gdk_bitmap_unref (GTK_CELL_PIXMAP (clist_row->cell[column])->mask);
break;
-
case GTK_CELL_PIXTEXT:
g_free (GTK_CELL_PIXTEXT (clist_row->cell[column])->text);
gdk_pixmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->pixmap);
if (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask)
gdk_bitmap_unref (GTK_CELL_PIXTEXT (clist_row->cell[column])->mask);
break;
-
case GTK_CELL_WIDGET:
/* unimplimented */
break;
-
default:
break;
}
@@ -5075,7 +5133,6 @@ set_cell_contents (GtkCList *clist,
GTK_CELL_TEXT (clist_row->cell[column])->text = g_strdup (text);
}
break;
-
case GTK_CELL_PIXMAP:
if (pixmap)
{
@@ -5085,7 +5142,6 @@ set_cell_contents (GtkCList *clist,
GTK_CELL_PIXMAP (clist_row->cell[column])->mask = mask;
}
break;
-
case GTK_CELL_PIXTEXT:
if (text && pixmap)
{
@@ -5096,7 +5152,6 @@ set_cell_contents (GtkCList *clist,
GTK_CELL_PIXTEXT (clist_row->cell[column])->mask = mask;
}
break;
-
default:
break;
}
@@ -5708,7 +5763,7 @@ update_extended_selection (GtkCList *clist,
}
else if (top >= clist->clist_window_height)
{
- area.y = ROW_TOP_YPIXEL (clist, s1);
+ area.y = ROW_TOP_YPIXEL (clist, s1) - 1;
area.height = clist->clist_window_height - area.y;
draw_rows (clist, &area);
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
@@ -5718,7 +5773,7 @@ update_extended_selection (GtkCList *clist,
else if (top + clist->row_height > clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
- y1 = ROW_TOP_YPIXEL (clist, s1);
+ y1 = ROW_TOP_YPIXEL (clist, s1) - 1;
h1 = (e1 - s1 + 1) * (clist->row_height + CELL_SPACING);
}
@@ -5742,7 +5797,7 @@ update_extended_selection (GtkCList *clist,
}
else if (top >= clist->clist_window_height)
{
- area.y = ROW_TOP_YPIXEL (clist, s2);
+ area.y = ROW_TOP_YPIXEL (clist, s2) - 1;
area.height = clist->clist_window_height - area.y;
draw_rows (clist, &area);
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
@@ -5752,7 +5807,7 @@ update_extended_selection (GtkCList *clist,
else if (top + clist->row_height > clist->clist_window_height)
gtk_clist_moveto (clist, clist->focus_row, -1, 1, 0);
- y2 = ROW_TOP_YPIXEL (clist, s2);
+ y2 = ROW_TOP_YPIXEL (clist, s2) - 1;
h2 = (e2 - s2 + 1) * (clist->row_height + CELL_SPACING);
}
@@ -6543,3 +6598,134 @@ real_sort_list (GtkCList *clist)
if (thaw)
gtk_clist_thaw (clist);
}
+
+/* gtk_clist_set_cell_style
+ * gtk_clist_get_cell_style
+ * gtk_clist_set_row_style
+ * gtk_clist_get_row_style
+ */
+
+void
+gtk_clist_set_cell_style (GtkCList *clist,
+ gint row,
+ gint column,
+ GtkStyle *style)
+{
+ GtkCListRow *clist_row;
+
+ g_return_if_fail (clist != NULL);
+ g_return_if_fail (GTK_IS_CLIST (clist));
+
+ if (row < 0 || row >= clist->rows || column < 0 || column >= clist->columns)
+ return;
+
+ clist_row = (g_list_nth (clist->row_list, row))->data;
+
+ if (clist_row->cell[column].style == style)
+ return;
+
+ if (clist_row->cell[column].style)
+ {
+ if (GTK_WIDGET_REALIZED (clist))
+ gtk_style_detach (clist_row->cell[column].style);
+ gtk_style_unref (clist_row->cell[column].style);
+ }
+
+ clist_row->cell[column].style = style;
+
+ if (clist_row->cell[column].style)
+ {
+ gtk_style_ref (clist_row->cell[column].style);
+
+ if (GTK_WIDGET_REALIZED (clist))
+ clist_row->cell[column].style =
+ gtk_style_attach (clist_row->cell[column].style,
+ clist->clist_window);
+ }
+
+ /* redraw the list if it's not frozen */
+ if (!GTK_CLIST_FROZEN (clist))
+ {
+ if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
+ GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ }
+}
+
+GtkStyle *
+gtk_clist_get_cell_style (GtkCList *clist,
+ gint row,
+ gint column)
+{
+ GtkCListRow *clist_row;
+
+ g_return_val_if_fail (clist != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
+
+ if (row < 0 || row >= clist->rows || column < 0 || column >= clist->columns)
+ return NULL;
+
+ clist_row = (g_list_nth (clist->row_list, row))->data;
+
+ return clist_row->cell[column].style;
+}
+
+void
+gtk_clist_set_row_style (GtkCList *clist,
+ gint row,
+ GtkStyle *style)
+{
+ GtkCListRow *clist_row;
+
+ g_return_if_fail (clist != NULL);
+ g_return_if_fail (GTK_IS_CLIST (clist));
+
+ if (row < 0 || row >= clist->rows)
+ return;
+
+ clist_row = (g_list_nth (clist->row_list, row))->data;
+
+ if (clist_row->style == style)
+ return;
+
+ if (clist_row->style)
+ {
+ if (GTK_WIDGET_REALIZED (clist))
+ gtk_style_detach (clist_row->style);
+ gtk_style_unref (clist_row->style);
+ }
+
+ clist_row->style = style;
+
+ if (clist_row->style)
+ {
+ gtk_style_ref (clist_row->style);
+
+ if (GTK_WIDGET_REALIZED (clist))
+ clist_row->style = gtk_style_attach (clist_row->style,
+ clist->clist_window);
+ }
+
+ /* redraw the list if it's not frozen */
+ if (!GTK_CLIST_FROZEN (clist))
+ {
+ if (gtk_clist_row_is_visible (clist, row) != GTK_VISIBILITY_NONE)
+ GTK_CLIST_CLASS_FW (clist)->draw_row (clist, NULL, row, clist_row);
+ }
+}
+
+GtkStyle *
+gtk_clist_get_row_style (GtkCList *clist,
+ gint row)
+{
+ GtkCListRow *clist_row;
+
+ g_return_val_if_fail (clist != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_CLIST (clist), NULL);
+
+ if (row < 0 || row >= clist->rows)
+ return NULL;
+
+ clist_row = (g_list_nth (clist->row_list, row))->data;
+
+ return clist_row->style;
+}
diff --git a/gtk/gtkclist.h b/gtk/gtkclist.h
index 84fd8e5f1a..0e56a78923 100644
--- a/gtk/gtkclist.h
+++ b/gtk/gtkclist.h
@@ -278,6 +278,8 @@ struct _GtkCListRow
GdkColor foreground;
GdkColor background;
+ GtkStyle *style;
+
gpointer data;
GtkDestroyNotify destroy;
@@ -291,9 +293,11 @@ struct _GtkCellText
{
GtkCellType type;
- gint vertical;
- gint horizontal;
+ gint16 vertical;
+ gint16 horizontal;
+ GtkStyle *style;
+
gchar *text;
};
@@ -301,9 +305,11 @@ struct _GtkCellPixmap
{
GtkCellType type;
- gint vertical;
- gint horizontal;
+ gint16 vertical;
+ gint16 horizontal;
+ GtkStyle *style;
+
GdkPixmap *pixmap;
GdkBitmap *mask;
};
@@ -312,9 +318,11 @@ struct _GtkCellPixText
{
GtkCellType type;
- gint vertical;
- gint horizontal;
+ gint16 vertical;
+ gint16 horizontal;
+ GtkStyle *style;
+
gchar *text;
guint8 spacing;
GdkPixmap *pixmap;
@@ -325,9 +333,11 @@ struct _GtkCellWidget
{
GtkCellType type;
- gint vertical;
- gint horizontal;
+ gint16 vertical;
+ gint16 horizontal;
+ GtkStyle *style;
+
GtkWidget *widget;
};
@@ -335,9 +345,11 @@ struct _GtkCell
{
GtkCellType type;
- gint vertical;
- gint horizontal;
+ gint16 vertical;
+ gint16 horizontal;
+ GtkStyle *style;
+
union {
gchar *text;
@@ -532,6 +544,23 @@ void gtk_clist_set_background (GtkCList *clist,
gint row,
GdkColor *color);
+/* set / get cell styles */
+void gtk_clist_set_cell_style (GtkCList *clist,
+ gint row,
+ gint column,
+ GtkStyle *style);
+
+GtkStyle *gtk_clist_get_cell_style (GtkCList *clist,
+ gint row,
+ gint column);
+
+void gtk_clist_set_row_style (GtkCList *clist,
+ gint row,
+ GtkStyle *style);
+
+GtkStyle *gtk_clist_get_row_style (GtkCList *clist,
+ gint row);
+
/* this sets a horizontal and vertical shift for drawing
* the contents of a cell; it can be positive or negitive;
* this is particulary useful for indenting items in a column
diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c
index 8c29f2cc64..5ad5744dad 100644
--- a/gtk/gtkctree.c
+++ b/gtk/gtkctree.c
@@ -50,7 +50,6 @@
static void gtk_ctree_class_init (GtkCTreeClass *klass);
static void gtk_ctree_init (GtkCTree *ctree);
static void gtk_ctree_destroy (GtkObject *object);
-
static void gtk_ctree_realize (GtkWidget *widget);
static void gtk_ctree_unrealize (GtkWidget *widget);
static gint gtk_ctree_button_press (GtkWidget *widget,
@@ -59,6 +58,43 @@ static gint gtk_ctree_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_ctree_button_motion (GtkWidget *widget,
GdkEventMotion *event);
+static void ctree_attach_styles (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gpointer data);
+static void ctree_detach_styles (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gpointer data);
+static gint draw_cell_pixmap (GdkWindow *window,
+ GdkRectangle *clip_rectangle,
+ GdkGC *fg_gc,
+ GdkPixmap *pixmap,
+ GdkBitmap *mask,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
+static void get_cell_style (GtkCList *clist,
+ GtkCListRow *clist_row,
+ gint state,
+ gint column,
+ GtkStyle **style,
+ GdkGC **fg_gc,
+ GdkGC **bg_gc);
+static gint gtk_ctree_draw_expander (GtkCTree *ctree,
+ GtkCTreeRow *ctree_row,
+ GtkStyle *style,
+ GdkRectangle *clip_rectangle,
+ gint x);
+static gint gtk_ctree_draw_lines (GtkCTree *ctree,
+ GtkCTreeRow *ctree_row,
+ gint row,
+ gint column,
+ gint state,
+ GdkRectangle *clip_rectangle,
+ GdkRectangle *cell_rectangle,
+ GdkRectangle *crect,
+ GdkRectangle *area,
+ GtkStyle *style);
static void draw_row (GtkCList *clist,
GdkRectangle *area,
gint row,
@@ -393,6 +429,7 @@ gtk_ctree_init (GtkCTree *ctree)
{
ctree->drag_icon = NULL;
ctree->tree_indent = 20;
+ ctree->tree_spacing = 5;
ctree->tree_column = 0;
ctree->drag_row = -1;
ctree->drag_source = NULL;
@@ -403,6 +440,7 @@ gtk_ctree_init (GtkCTree *ctree)
ctree->in_drag = FALSE;
ctree->drag_rect = FALSE;
ctree->line_style = GTK_CTREE_LINES_SOLID;
+ ctree->expander_style = GTK_CTREE_EXPANDER_SQUARE;
ctree->drag_compare = NULL;
ctree->show_stub = TRUE;
}
@@ -445,10 +483,63 @@ gtk_ctree_destroy (GtkObject *object)
}
static void
+ctree_attach_styles (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gpointer data)
+{
+ GtkCList *clist;
+ gint i;
+
+ clist = GTK_CLIST (ctree);
+
+ if (GTK_CTREE_ROW (node)->row.style)
+ GTK_CTREE_ROW (node)->row.style =
+ gtk_style_attach (GTK_CTREE_ROW (node)->row.style, clist->clist_window);
+
+ if (GTK_CTREE_ROW (node)->row.fg_set || GTK_CTREE_ROW (node)->row.bg_set)
+ {
+ GdkColormap *colormap;
+
+ colormap = gtk_widget_get_colormap (GTK_WIDGET (ctree));
+ if (GTK_CTREE_ROW (node)->row.fg_set)
+ gdk_color_alloc (colormap, &(GTK_CTREE_ROW (node)->row.foreground));
+ if (GTK_CTREE_ROW (node)->row.bg_set)
+ gdk_color_alloc (colormap, &(GTK_CTREE_ROW (node)->row.background));
+ }
+
+ for (i = 0; i < clist->columns; i++)
+ if (GTK_CTREE_ROW (node)->row.cell[i].style)
+ GTK_CTREE_ROW (node)->row.cell[i].style =
+ gtk_style_attach (GTK_CTREE_ROW (node)->row.cell[i].style,
+ clist->clist_window);
+}
+
+static void
+ctree_detach_styles (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gpointer data)
+{
+ GtkCList *clist;
+ gint i;
+
+ clist = GTK_CLIST (ctree);
+
+ if (GTK_CTREE_ROW (node)->row.style)
+ gtk_style_detach (GTK_CTREE_ROW (node)->row.style);
+ for (i = 0; i < clist->columns; i++)
+ if (GTK_CTREE_ROW (node)->row.cell[i].style)
+ gtk_style_detach (GTK_CTREE_ROW (node)->row.cell[i].style);
+}
+
+static void
gtk_ctree_realize (GtkWidget *widget)
{
GtkCTree *ctree;
+ GtkCList *clist;
GdkGCValues values;
+ GtkCTreeNode *node;
+ GtkCTreeNode *child;
+ gint i;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CTREE (widget));
@@ -456,6 +547,17 @@ gtk_ctree_realize (GtkWidget *widget)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
ctree = GTK_CTREE (widget);
+ clist = GTK_CLIST (widget);
+
+ node = GTK_CTREE_NODE (clist->row_list);
+ for (i = 0; i < clist->rows; i++)
+ {
+ if (GTK_CTREE_ROW (node)->children && !GTK_CTREE_ROW (node)->expanded)
+ for (child = GTK_CTREE_ROW (node)->children; child;
+ child = GTK_CTREE_ROW (child)->sibling)
+ gtk_ctree_pre_recursive (ctree, child, ctree_attach_styles, NULL);
+ node = GTK_CTREE_NODE_NEXT (node);
+ }
values.foreground = widget->style->fg[GTK_STATE_NORMAL];
values.background = widget->style->bg[GTK_STATE_NORMAL];
@@ -480,6 +582,7 @@ static void
gtk_ctree_unrealize (GtkWidget *widget)
{
GtkCTree *ctree;
+ GtkCList *clist;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CTREE (widget));
@@ -487,6 +590,25 @@ gtk_ctree_unrealize (GtkWidget *widget)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
ctree = GTK_CTREE (widget);
+ clist = GTK_CLIST (widget);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ {
+ GtkCTreeNode *node;
+ GtkCTreeNode *child;
+ gint i;
+
+ node = GTK_CTREE_NODE (clist->row_list);
+ for (i = 0; i < clist->rows; i++)
+ {
+ if (GTK_CTREE_ROW (node)->children &&
+ !GTK_CTREE_ROW (node)->expanded)
+ for (child = GTK_CTREE_ROW (node)->children; child;
+ child = GTK_CTREE_ROW (child)->sibling)
+ gtk_ctree_pre_recursive(ctree, child, ctree_detach_styles, NULL);
+ node = GTK_CTREE_NODE_NEXT (node);
+ }
+ }
gdk_gc_destroy (ctree->lines_gc);
}
@@ -1082,1328 +1204,999 @@ draw_xor_rect (GtkCTree *ctree)
clist->clist_window_width - 1, clist->row_height);
}
-static void
-draw_row (GtkCList *clist,
- GdkRectangle *area,
- gint row,
- GtkCListRow *clist_row)
+static gint
+draw_cell_pixmap (GdkWindow *window,
+ GdkRectangle *clip_rectangle,
+ GdkGC *fg_gc,
+ GdkPixmap *pixmap,
+ GdkBitmap *mask,
+ gint x,
+ gint y,
+ gint width,
+ gint height)
{
- GtkWidget *widget;
- GtkCTree *ctree;
- GdkGC *fg_gc;
- GdkGC *bg_gc;
- GdkRectangle row_rectangle;
- GdkRectangle cell_rectangle;
- GdkRectangle clip_rectangle;
- GdkRectangle intersect_rectangle;
- GdkRectangle *rect;
+ gint xsrc = 0;
+ gint ysrc = 0;
- gint i, offset = 0, width, height, pixmap_width = 0, string_width = 0;
- gint xsrc, ysrc, xdest = 0, ydest;
- gboolean need_redraw = TRUE;
- gboolean draw_pixmap = FALSE;
-
- g_return_if_fail (clist != NULL);
+ if (mask)
+ {
+ gdk_gc_set_clip_mask (fg_gc, mask);
+ gdk_gc_set_clip_origin (fg_gc, x, y);
+ }
+ if (x < clip_rectangle->x)
+ {
+ xsrc = clip_rectangle->x - x;
+ width -= xsrc;
+ x = clip_rectangle->x;
+ }
+ if (x + width > clip_rectangle->x + clip_rectangle->width)
+ width = clip_rectangle->x + clip_rectangle->width - x;
- /* bail now if we arn't drawable yet */
- if (!GTK_WIDGET_DRAWABLE (clist))
- return;
+ if (y < clip_rectangle->y)
+ {
+ ysrc = clip_rectangle->y - y;
+ height -= ysrc;
+ y = clip_rectangle->y;
+ }
+ if (y + height > clip_rectangle->y + clip_rectangle->height)
+ height = clip_rectangle->y + clip_rectangle->height - y;
- if (row < 0 || row >= clist->rows)
- return;
+ if (width > 0 && height > 0)
+ gdk_draw_pixmap (window, fg_gc, pixmap, xsrc, ysrc, x, y, width, height);
+
+ gdk_gc_set_clip_origin (fg_gc, 0, 0);
- widget = GTK_WIDGET (clist);
- ctree = GTK_CTREE (clist);
+ return x + MAX (width, 0);
+}
- /* if the function is passed the pointer to the row instead of null,
- * it avoids this expensive lookup */
- if (!clist_row)
- clist_row = (g_list_nth (clist->row_list, row))->data;
+static void
+get_cell_style (GtkCList *clist,
+ GtkCListRow *clist_row,
+ gint state,
+ gint column,
+ GtkStyle **style,
+ GdkGC **fg_gc,
+ GdkGC **bg_gc)
+{
+ if (clist_row->cell[column].style)
+ {
+ if (style)
+ *style = clist_row->cell[column].style;
+ if (fg_gc)
+ *fg_gc = clist_row->cell[column].style->fg_gc[state];
+ if (bg_gc)
+ *bg_gc = clist_row->cell[column].style->bg_gc[state];
+ }
+ else if (clist_row->style)
+ {
+ if (style)
+ *style = clist_row->style;
+ if (fg_gc)
+ *fg_gc = clist_row->style->fg_gc[state];
+ if (bg_gc)
+ *bg_gc = clist_row->style->bg_gc[state];
+ }
+ else
+ {
+ if (style)
+ *style = GTK_WIDGET (clist)->style;
+ if (fg_gc)
+ *fg_gc = GTK_WIDGET (clist)->style->fg_gc[state];
+ if (bg_gc)
+ *bg_gc = GTK_WIDGET (clist)->style->bg_gc[state];
+
+ if (state != GTK_STATE_SELECTED)
+ {
+ if (fg_gc && clist_row->fg_set)
+ *fg_gc = clist->fg_gc;
+ if (bg_gc && clist_row->bg_set)
+ *bg_gc = clist->bg_gc;
+ }
+ }
+}
- /* rectangle of the entire row */
- row_rectangle.x = 0;
- row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
- row_rectangle.width = clist->clist_window_width;
- row_rectangle.height = clist->row_height;
+static gint
+gtk_ctree_draw_expander (GtkCTree *ctree,
+ GtkCTreeRow *ctree_row,
+ GtkStyle *style,
+ GdkRectangle *clip_rectangle,
+ gint x)
+{
+ GtkCList *clist;
+ GdkPoint points[3];
+ gint justification_factor;
+ gint y;
- /* rectangle of the cell spacing above the row */
- cell_rectangle.x = 0;
- cell_rectangle.y = row_rectangle.y - CELL_SPACING;
- cell_rectangle.width = row_rectangle.width;
- cell_rectangle.height = CELL_SPACING;
+ if (ctree->expander_style == GTK_CTREE_EXPANDER_NONE)
+ return x;
- /* rectangle used to clip drawing operations, it's y and height
- * positions only need to be set once, so we set them once here.
- * the x and width are set withing the drawing loop below once per
- * column */
- clip_rectangle.y = row_rectangle.y;
- clip_rectangle.height = row_rectangle.height;
+ clist = GTK_CLIST (ctree);
+ if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)
+ justification_factor = -1;
+ else
+ justification_factor = 1;
+ y = (clip_rectangle->y + (clip_rectangle->height - PM_SIZE) / 2 -
+ (clip_rectangle->height + 1) % 2);
- /* select GC for background rectangle */
- if (clist_row->state == GTK_STATE_SELECTED)
+ if (!ctree_row->children)
{
- fg_gc = widget->style->fg_gc[GTK_STATE_SELECTED];
- bg_gc = widget->style->bg_gc[GTK_STATE_SELECTED];
+ switch (ctree->expander_style)
+ {
+ case GTK_CTREE_EXPANDER_NONE:
+ return x;
+ case GTK_CTREE_EXPANDER_TRIANGLE:
+ return x + justification_factor * (PM_SIZE + 3);
+ case GTK_CTREE_EXPANDER_SQUARE:
+ case GTK_CTREE_EXPANDER_CIRCULAR:
+ return x + justification_factor * (PM_SIZE + 1);
+ }
}
- else
+
+ gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], clip_rectangle);
+ gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], clip_rectangle);
+
+ switch (ctree->expander_style)
{
- if (clist_row->fg_set)
+ case GTK_CTREE_EXPANDER_NONE:
+ break;
+ case GTK_CTREE_EXPANDER_TRIANGLE:
+ if (ctree_row->expanded)
{
- gdk_gc_set_foreground (clist->fg_gc, &clist_row->foreground);
- fg_gc = clist->fg_gc;
+ points[0].x = x;
+ points[0].y = y + (PM_SIZE + 2) / 6;
+ points[1].x = points[0].x + justification_factor * (PM_SIZE + 2);
+ points[1].y = points[0].y;
+ points[2].x = (points[0].x +
+ justification_factor * (PM_SIZE + 2) / 2);
+ points[2].y = y + 2 * (PM_SIZE + 2) / 3;
}
else
- fg_gc = widget->style->fg_gc[GTK_STATE_NORMAL];
-
- if (clist_row->bg_set)
{
- gdk_gc_set_foreground (clist->bg_gc, &clist_row->background);
- bg_gc = clist->bg_gc;
+ points[0].x = x + justification_factor * ((PM_SIZE + 2) / 6 + 2);
+ points[0].y = y - 1;
+ points[1].x = points[0].x;
+ points[1].y = points[0].y + (PM_SIZE + 2);
+ points[2].x = (points[0].x +
+ justification_factor * (2 * (PM_SIZE + 2) / 3 - 1));
+ points[2].y = points[0].y + (PM_SIZE + 2) / 2;
}
- else
- bg_gc = widget->style->bg_gc[GTK_STATE_PRELIGHT];
- }
+ gdk_draw_polygon (clist->clist_window, style->base_gc[GTK_STATE_NORMAL],
+ TRUE, points, 3);
+ gdk_draw_polygon (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
+ FALSE, points, 3);
- /* draw the cell borders and background */
- if (area)
- {
- if (gdk_rectangle_intersect (area, &cell_rectangle,
- &intersect_rectangle))
- gdk_draw_rectangle (clist->clist_window,
- widget->style->base_gc[GTK_STATE_NORMAL],
- TRUE,
- intersect_rectangle.x,
- intersect_rectangle.y,
- intersect_rectangle.width,
- intersect_rectangle.height);
-
- /* the last row has to clear it's bottom cell spacing too */
- if (clist_row == clist->row_list_end->data)
- {
- cell_rectangle.y += clist->row_height + CELL_SPACING;
+ x += justification_factor * (PM_SIZE + 3);
+ break;
+ case GTK_CTREE_EXPANDER_SQUARE:
+ case GTK_CTREE_EXPANDER_CIRCULAR:
+ if (justification_factor == -1)
+ x += justification_factor * (PM_SIZE + 1);
- if (gdk_rectangle_intersect (area, &cell_rectangle,
- &intersect_rectangle))
- gdk_draw_rectangle (clist->clist_window,
- widget->style->base_gc[GTK_STATE_NORMAL],
- TRUE,
- intersect_rectangle.x,
- intersect_rectangle.y,
- intersect_rectangle.width,
- intersect_rectangle.height);
+ if (ctree->expander_style == GTK_CTREE_EXPANDER_CIRCULAR)
+ {
+ gdk_draw_arc (clist->clist_window, style->base_gc[GTK_STATE_NORMAL],
+ TRUE, x, y, PM_SIZE, PM_SIZE, 0, 360 * 64);
+ gdk_draw_arc (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
+ FALSE, x, y, PM_SIZE, PM_SIZE, 0, 360 * 64);
}
-
- if (gdk_rectangle_intersect
- (area, &row_rectangle, &intersect_rectangle))
+ else
{
- if (clist_row->state == GTK_STATE_SELECTED || clist_row->bg_set)
- gdk_draw_rectangle (clist->clist_window,
- bg_gc,
- TRUE,
- intersect_rectangle.x,
- intersect_rectangle.y,
- intersect_rectangle.width,
- intersect_rectangle.height);
- else
- gdk_window_clear_area (clist->clist_window,
- intersect_rectangle.x,
- intersect_rectangle.y,
- intersect_rectangle.width,
- intersect_rectangle.height);
+ gdk_draw_rectangle (clist->clist_window,
+ style->base_gc[GTK_STATE_NORMAL], TRUE,
+ x, y, PM_SIZE, PM_SIZE);
+ gdk_draw_rectangle (clist->clist_window,
+ style->fg_gc[GTK_STATE_NORMAL], FALSE,
+ x, y, PM_SIZE, PM_SIZE);
}
- else
- need_redraw = FALSE;
+
+ gdk_draw_line (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
+ x + 2, y + PM_SIZE / 2, x + PM_SIZE - 2, y + PM_SIZE / 2);
+
+ if (!ctree_row->expanded)
+ gdk_draw_line (clist->clist_window, style->fg_gc[GTK_STATE_NORMAL],
+ x + PM_SIZE / 2, y + 2,
+ x + PM_SIZE / 2, y + PM_SIZE - 2);
+
+ if (justification_factor == 1)
+ x += justification_factor * (PM_SIZE + 1);
+ break;
+ }
+
+ gdk_gc_set_clip_rectangle (style->fg_gc[GTK_STATE_NORMAL], NULL);
+ gdk_gc_set_clip_rectangle (style->base_gc[GTK_STATE_NORMAL], NULL);
+
+ return x;
+}
+
+
+static gint
+gtk_ctree_draw_lines (GtkCTree *ctree,
+ GtkCTreeRow *ctree_row,
+ gint row,
+ gint column,
+ gint state,
+ GdkRectangle *clip_rectangle,
+ GdkRectangle *cell_rectangle,
+ GdkRectangle *crect,
+ GdkRectangle *area,
+ GtkStyle *style)
+{
+ GtkCList *clist;
+ GtkCTreeNode *node;
+ GtkCTreeNode *parent;
+ GdkRectangle tree_rectangle;
+ GdkRectangle tc_rectangle;
+ GdkGC *bg_gc;
+ gint offset;
+ gint offset_x;
+ gint offset_y;
+ gint xcenter;
+ gint ycenter;
+ gint next_level;
+ gint column_right;
+ gint column_left;
+ gint justify_right;
+ gint justification_factor;
+
+ clist = GTK_CLIST (ctree);
+ ycenter = clip_rectangle->y + (clip_rectangle->height / 2);
+ justify_right = (clist->column[column].justification == GTK_JUSTIFY_RIGHT);
+
+ if (justify_right)
+ {
+ offset = (clip_rectangle->x + clip_rectangle->width - 1 -
+ ctree->tree_indent * (ctree_row->level - 1));
+ justification_factor = -1;
}
else
{
- gdk_draw_rectangle (clist->clist_window,
- widget->style->base_gc[GTK_STATE_NORMAL],
- TRUE,
- cell_rectangle.x,
- cell_rectangle.y,
- cell_rectangle.width,
- cell_rectangle.height);
-
- /* the last row has to clear it's bottom cell spacing too */
- if (clist_row == clist->row_list_end->data)
- {
- cell_rectangle.y += clist->row_height + CELL_SPACING;
-
- gdk_draw_rectangle (clist->clist_window,
- widget->style->base_gc[GTK_STATE_NORMAL],
- TRUE,
- cell_rectangle.x,
- cell_rectangle.y,
- cell_rectangle.width,
- cell_rectangle.height);
- }
-
- if (clist_row->state == GTK_STATE_SELECTED || clist_row->bg_set)
- gdk_draw_rectangle (clist->clist_window,
- bg_gc,
- TRUE,
- row_rectangle.x,
- row_rectangle.y,
- row_rectangle.width,
- row_rectangle.height);
- else
- gdk_window_clear_area (clist->clist_window,
- row_rectangle.x,
- row_rectangle.y,
- row_rectangle.width,
- row_rectangle.height);
+ offset = clip_rectangle->x + ctree->tree_indent * (ctree_row->level - 1);
+ justification_factor = 1;
}
- /* iterate and draw all the columns (row cells) and draw their contents */
- for (i = 0; i < clist->columns; i++)
+ switch (ctree->line_style)
{
- if (!clist->column[i].visible)
- continue;
-
- if (!need_redraw && ctree->tree_column != i)
- continue;
-
- clip_rectangle.x = clist->column[i].area.x + clist->hoffset;
- clip_rectangle.width = clist->column[i].area.width;
+ case GTK_CTREE_LINES_NONE:
+ break;
+ case GTK_CTREE_LINES_TABBED:
+ xcenter = offset + justification_factor * TAB_SIZE;
- /* calculate clipping region */
- if (i == ctree->tree_column)
- {
- clip_rectangle.y -= CELL_SPACING;
- clip_rectangle.height += CELL_SPACING;
- }
+ column_right = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) +
+ clist->column[ctree->tree_column].area.width +
+ COLUMN_INSET);
+ column_left = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) -
+ COLUMN_INSET - CELL_SPACING);
- if (i == ctree->tree_column)
+ if (area)
{
+ tree_rectangle.y = crect->y;
+ tree_rectangle.height = crect->height;
- if (clist_row->state == GTK_STATE_SELECTED)
+ if (justify_right)
{
- gdk_gc_set_foreground (ctree->lines_gc,
- &GTK_WIDGET (ctree)->style->
- fg[GTK_STATE_SELECTED]);
- gdk_gc_set_background (ctree->lines_gc,
- &GTK_WIDGET (ctree)->style->
- bg[GTK_STATE_SELECTED]);
+ tree_rectangle.x = xcenter;
+ tree_rectangle.width = column_right - xcenter;
}
else
{
- gdk_gc_set_foreground (ctree->lines_gc,
- &GTK_WIDGET (ctree)->style->
- fg[GTK_STATE_NORMAL]);
- if (clist_row->bg_set)
- gdk_gc_set_background (ctree->lines_gc,
- &clist_row->background);
+ tree_rectangle.x = column_left;
+ tree_rectangle.width = xcenter - column_left;
}
- if (ctree->line_style == GTK_CTREE_LINES_TABBED)
+ if (!gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle))
{
- if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
- {
- xdest = clip_rectangle.x + clip_rectangle.width - 1 -
- (((GtkCTreeRow *) clist_row)->level - 1) *
- ctree->tree_indent;
-
- gdk_draw_line (clist->clist_window,
- ctree->lines_gc,
- -1,
- row_rectangle.y - 1,
- MAX (xdest - TAB_SIZE, clip_rectangle.x - 1),
- row_rectangle.y - 1);
-
- if (clist_row == clist->row_list_end->data)
- gdk_draw_line
- (clist->clist_window,
- ctree->lines_gc,
- -1,
- row_rectangle.y + clist->row_height,
- MAX (clip_rectangle.x + clip_rectangle.width -
- TAB_SIZE - 1 -
- (((GtkCTreeRow *) clist_row)->level > 1) *
- MIN (ctree->tree_indent / 2, TAB_SIZE),
- clip_rectangle.x - 1),
- row_rectangle.y + clist->row_height);
-
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_rectangle
- (clist->clist_window,
- widget->style->bg_gc[GTK_STATE_PRELIGHT],
- TRUE,
- clip_rectangle.x + clip_rectangle.width,
- row_rectangle.y,
- CELL_SPACING + COLUMN_INSET,
- row_rectangle.height);
- }
- else
- {
- xdest = clip_rectangle.x +
- (((GtkCTreeRow *) clist_row)->level - 1) *
- ctree->tree_indent;
-
- gdk_draw_line (clist->clist_window,
- ctree->lines_gc,
- MIN (xdest + TAB_SIZE,
- clip_rectangle.x + clip_rectangle.width),
- row_rectangle.y - 1,
- clist->clist_window_width,
- row_rectangle.y - 1);
-
- if (clist_row == clist->row_list_end->data)
- gdk_draw_line
- (clist->clist_window, ctree->lines_gc,
- MIN (clip_rectangle.x + TAB_SIZE +
- (((GtkCTreeRow *) clist_row)->level > 1) *
- MIN (ctree->tree_indent / 2, TAB_SIZE),
- clip_rectangle.x + clip_rectangle.width),
- row_rectangle.y + clist->row_height,
- clist->clist_window_width,
- row_rectangle.y + clist->row_height);
-
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_rectangle
- (clist->clist_window,
- widget->style->bg_gc[GTK_STATE_PRELIGHT],
- TRUE,
- clip_rectangle.x - CELL_SPACING - COLUMN_INSET,
- row_rectangle.y,
- CELL_SPACING + COLUMN_INSET,
- row_rectangle.height);
- }
+ offset += justification_factor * 3;
+ break;
}
}
- if (!area)
+ gdk_gc_set_clip_rectangle (ctree->lines_gc, crect);
+
+ next_level = ctree_row->level;
+
+ if (!ctree_row->sibling || (ctree_row->children && ctree_row->expanded))
{
- rect = &clip_rectangle;
+ node = gtk_ctree_find_node_ptr (ctree, ctree_row);
+ if (GTK_CTREE_NODE_NEXT (node))
+ next_level = GTK_CTREE_ROW (GTK_CTREE_NODE_NEXT (node))->level;
+ else
+ next_level = 0;
}
- else
+
+ if (ctree->tree_indent > 0)
{
+ node = ctree_row->parent;
+ while (node)
+ {
+ xcenter -= (justification_factor * ctree->tree_indent);
- if (!gdk_rectangle_intersect (area, &clip_rectangle,
- &intersect_rectangle))
- continue;
- rect = &intersect_rectangle;
- }
+ if ((justify_right && xcenter < column_left) ||
+ (!justify_right && xcenter > column_right))
+ {
+ node = GTK_CTREE_ROW (node)->parent;
+ continue;
+ }
- /* calculate real width for column justification */
- switch (clist_row->cell[i].type)
- {
- case GTK_CELL_EMPTY:
- continue;
- break;
+ tree_rectangle.y = cell_rectangle->y;
+ tree_rectangle.height = cell_rectangle->height;
+ if (justify_right)
+ {
+ tree_rectangle.x = MAX (xcenter - ctree->tree_indent + 1,
+ column_left);
+ tree_rectangle.width = MIN (xcenter - column_left,
+ ctree->tree_indent);
+ }
+ else
+ {
+ tree_rectangle.x = xcenter;
+ tree_rectangle.width = MIN (column_right - xcenter,
+ ctree->tree_indent);
+ }
- case GTK_CELL_TEXT:
- width = gdk_string_width (GTK_WIDGET (clist)->style->font,
- GTK_CELL_TEXT (clist_row->cell[i])->text);
- break;
+ if (!area || gdk_rectangle_intersect (area, &tree_rectangle,
+ &tc_rectangle))
+ {
+ get_cell_style (clist, &GTK_CTREE_ROW (node)->row,
+ state, column, NULL, NULL, &bg_gc);
+
+ if (bg_gc == clist->bg_gc)
+ gdk_gc_set_foreground
+ (clist->bg_gc, &GTK_CTREE_ROW (node)->row.background);
+
+ if (!area)
+ gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
+ tree_rectangle.x,
+ tree_rectangle.y,
+ tree_rectangle.width,
+ tree_rectangle.height);
+ else
+ gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
+ tc_rectangle.x,
+ tc_rectangle.y,
+ tc_rectangle.width,
+ tc_rectangle.height);
+ }
+ if (next_level > GTK_CTREE_ROW (node)->level)
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ xcenter, crect->y,
+ xcenter, crect->y + crect->height);
+ else
+ {
+ gint width;
- case GTK_CELL_PIXMAP:
- gdk_window_get_size (GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
- &width, &height);
- pixmap_width = width;
- break;
+ offset_x = MIN (ctree->tree_indent, 2 * TAB_SIZE);
+ width = offset_x / 2 + offset_x % 2;
- case GTK_CELL_PIXTEXT:
- if (i == ctree->tree_column)
- {
- string_width = 0;
- width = 0;
+ parent = GTK_CTREE_ROW (node)->parent;
- if (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)
- gdk_window_get_size (GTK_CELL_PIXTEXT
- (clist_row->cell[i])->pixmap,
- &width, &height);
+ tree_rectangle.y = ycenter;
+ tree_rectangle.height = (cell_rectangle->y - ycenter +
+ cell_rectangle->height);
- pixmap_width = width;
- width += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
+ if (justify_right)
+ {
+ tree_rectangle.x = MAX(xcenter + 1 - width, column_left);
+ tree_rectangle.width = MIN (xcenter + 1 - column_left,
+ width);
+ }
+ else
+ {
+ tree_rectangle.x = xcenter;
+ tree_rectangle.width = MIN (column_right - xcenter,
+ width);
+ }
- if (GTK_CELL_PIXTEXT (clist_row->cell[i])->text)
- string_width += gdk_string_width
- (GTK_WIDGET (clist)->style->font,
- GTK_CELL_PIXTEXT(clist_row->cell[i])->text);
-
- width += string_width +
- ((GtkCTreeRow *)clist_row)->level * ctree->tree_indent;
- }
- else
- {
- gdk_window_get_size (GTK_CELL_PIXTEXT
- (clist_row->cell[i])->pixmap,
- &width, &height);
- pixmap_width = width;
- width += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
- width += gdk_string_width (GTK_WIDGET (clist)->style->font,
- GTK_CELL_PIXTEXT
- (clist_row->cell[i])->text);
+ if (!area ||
+ gdk_rectangle_intersect (area, &tree_rectangle,
+ &tc_rectangle))
+ {
+ if (parent)
+ {
+ get_cell_style (clist, &GTK_CTREE_ROW (parent)->row,
+ state, column, NULL, NULL, &bg_gc);
+ if (bg_gc == clist->bg_gc)
+ gdk_gc_set_foreground
+ (clist->bg_gc,
+ &GTK_CTREE_ROW (parent)->row.background);
+ }
+ else if (state == GTK_STATE_SELECTED)
+ bg_gc = style->bg_gc[state];
+ else
+ bg_gc = GTK_WIDGET (clist)->style->bg_gc[state];
+
+ if (!area)
+ gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
+ tree_rectangle.x,
+ tree_rectangle.y,
+ tree_rectangle.width,
+ tree_rectangle.height);
+ else
+ gdk_draw_rectangle (clist->clist_window,
+ bg_gc, TRUE,
+ tc_rectangle.x,
+ tc_rectangle.y,
+ tc_rectangle.width,
+ tc_rectangle.height);
+ }
+
+ get_cell_style (clist, &GTK_CTREE_ROW (node)->row,
+ state, column, NULL, NULL, &bg_gc);
+ if (bg_gc == clist->bg_gc)
+ gdk_gc_set_foreground
+ (clist->bg_gc, &GTK_CTREE_ROW (node)->row.background);
+
+ gdk_gc_set_clip_rectangle (bg_gc, crect);
+ gdk_draw_arc (clist->clist_window, bg_gc, TRUE,
+ xcenter - (justify_right * offset_x),
+ cell_rectangle->y,
+ offset_x, clist->row_height,
+ (180 + (justify_right * 90)) * 64, 90 * 64);
+ gdk_gc_set_clip_rectangle (bg_gc, NULL);
+
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ xcenter, cell_rectangle->y, xcenter, ycenter);
+
+ if (justify_right)
+ gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE,
+ xcenter - offset_x, cell_rectangle->y,
+ offset_x, clist->row_height,
+ 270 * 64, 90 * 64);
+ else
+ gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE,
+ xcenter, cell_rectangle->y,
+ offset_x, clist->row_height,
+ 180 * 64, 90 * 64);
+ }
+ node = GTK_CTREE_ROW (node)->parent;
}
- break;
+ }
- case GTK_CELL_WIDGET:
- /* unimplemented */
- continue;
- break;
+ if (state != GTK_STATE_SELECTED)
+ {
+ tree_rectangle.y = clip_rectangle->y;
+ tree_rectangle.height = clip_rectangle->height;
+ tree_rectangle.width = COLUMN_INSET + CELL_SPACING +
+ MIN (clist->column[ctree->tree_column].area.width + COLUMN_INSET,
+ TAB_SIZE);
+
+ if (justify_right)
+ tree_rectangle.x = MAX (xcenter + 1, column_left);
+ else
+ tree_rectangle.x = column_left;
- default:
- continue;
- break;
+ if (!area)
+ gdk_draw_rectangle (clist->clist_window,
+ GTK_WIDGET
+ (ctree)->style->bg_gc[GTK_STATE_PRELIGHT],
+ TRUE,
+ tree_rectangle.x,
+ tree_rectangle.y,
+ tree_rectangle.width,
+ tree_rectangle.height);
+ else if (gdk_rectangle_intersect (area, &tree_rectangle,
+ &tc_rectangle))
+ gdk_draw_rectangle (clist->clist_window,
+ GTK_WIDGET
+ (ctree)->style->bg_gc[GTK_STATE_PRELIGHT],
+ TRUE,
+ tc_rectangle.x,
+ tc_rectangle.y,
+ tc_rectangle.width,
+ tc_rectangle.height);
}
- switch (clist->column[i].justification)
+ xcenter = offset + (justification_factor * ctree->tree_indent / 2);
+
+ get_cell_style (clist, &ctree_row->row, state, column, NULL, NULL,
+ &bg_gc);
+ if (bg_gc == clist->bg_gc)
+ gdk_gc_set_foreground (clist->bg_gc, &ctree_row->row.background);
+
+ gdk_gc_set_clip_rectangle (bg_gc, crect);
+ if (ctree_row->is_leaf)
{
- case GTK_JUSTIFY_LEFT:
- offset = clip_rectangle.x;
- break;
+ GdkPoint points[6];
- case GTK_JUSTIFY_RIGHT:
- offset = (clip_rectangle.x + clip_rectangle.width) - width;
- break;
+ points[0].x = offset + justification_factor * TAB_SIZE;
+ points[0].y = cell_rectangle->y;
- case GTK_JUSTIFY_CENTER:
- offset = (clip_rectangle.x + (clip_rectangle.width / 2))
- - (width / 2);
- break;
+ points[1].x = points[0].x - justification_factor * 4;
+ points[1].y = points[0].y;
- case GTK_JUSTIFY_FILL:
- offset = (clip_rectangle.x + (clip_rectangle.width / 2))
- - (width / 2);
- break;
+ points[2].x = points[1].x - justification_factor * 2;
+ points[2].y = points[1].y + 3;
- default:
- offset = 0;
- break;
- };
+ points[3].x = points[2].x;
+ points[3].y = points[2].y + clist->row_height - 5;
- if (i == ctree->tree_column)
+ points[4].x = points[3].x + justification_factor * 2;
+ points[4].y = points[3].y + 3;
+
+ points[5].x = points[4].x + justification_factor * 4;
+ points[5].y = points[4].y;
+
+ gdk_draw_polygon (clist->clist_window, bg_gc, TRUE, points, 6);
+ gdk_draw_lines (clist->clist_window, ctree->lines_gc, points, 6);
+ }
+ else
{
- GdkGC *cgc;
- GdkGC *tgc;
- GdkGC *mbg_gc;
- GtkCTreeNode *work;
- GtkCTreeNode *work2;
- gint xoffset;
- gint yoffset;
- gint xcenter;
- gint ycenter;
- gint offset_x;
- gint offset_y = 0;
- gint next_level;
- gint in;
- GdkPoint points[6];
+ gdk_draw_arc (clist->clist_window, bg_gc, TRUE,
+ offset - (justify_right * 2 * TAB_SIZE),
+ cell_rectangle->y,
+ 2 * TAB_SIZE, clist->row_height,
+ (90 + (180 * justify_right)) * 64, 180 * 64);
+ gdk_draw_arc (clist->clist_window, ctree->lines_gc, FALSE,
+ offset - (justify_right * 2 * TAB_SIZE),
+ cell_rectangle->y,
+ 2 * TAB_SIZE, clist->row_height,
+ (90 + (180 * justify_right)) * 64, 180 * 64);
+ }
+ gdk_gc_set_clip_rectangle (bg_gc, NULL);
+ gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
- xsrc = 0;
- ysrc = 0;
+ offset += justification_factor * 3;
+ break;
+ default:
+ xcenter = offset + justification_factor * PM_SIZE / 2;
- yoffset = (clip_rectangle.height - PM_SIZE) / 2;
- xoffset = (ctree->tree_indent - PM_SIZE) / 2;
- ycenter = clip_rectangle.y + (clip_rectangle.height / 2);
- ydest = ycenter - height / 2 + clist_row->cell[i].vertical;
+ if (area)
+ {
+ tree_rectangle.y = crect->y;
+ tree_rectangle.height = crect->height;
- gdk_gc_set_clip_origin (fg_gc, 0, 0);
- gdk_gc_set_clip_rectangle (fg_gc, rect);
- if (ctree->line_style != GTK_CTREE_LINES_NONE)
+ if (justify_right)
{
- gdk_gc_set_clip_origin (ctree->lines_gc, 0, 0);
- gdk_gc_set_clip_rectangle (ctree->lines_gc, rect);
+ tree_rectangle.x = xcenter - PM_SIZE / 2 - 2;
+ tree_rectangle.width = (clip_rectangle->x +
+ clip_rectangle->width -tree_rectangle.x);
}
-
- switch (clist->column[i].justification)
+ else
{
- case GTK_JUSTIFY_CENTER:
- case GTK_JUSTIFY_FILL:
- offset = clip_rectangle.x;
- case GTK_JUSTIFY_LEFT:
- offset_x = 1;
- xdest = clip_rectangle.x - xoffset +
- (((GtkCTreeRow *) clist_row)->level - 1) * ctree->tree_indent;
- xcenter = xdest + (ctree->tree_indent / 2);
-
- switch (ctree->line_style)
- {
- case GTK_CTREE_LINES_NONE:
- break;
- case GTK_CTREE_LINES_TABBED:
- xdest = clip_rectangle.x +
- (((GtkCTreeRow *) clist_row)->level - 1) *
- ctree->tree_indent;
- xcenter = xdest + TAB_SIZE;
-
- gdk_gc_set_clip_origin (clist->bg_gc, 0, 0);
- gdk_gc_set_clip_rectangle (clist->bg_gc, rect);
-
- gdk_gc_set_clip_origin
- (widget->style->bg_gc[GTK_STATE_PRELIGHT], 0, 0);
- gdk_gc_set_clip_rectangle
- (widget->style->bg_gc[GTK_STATE_PRELIGHT], rect);
-
- work = ((GtkCTreeRow *)clist_row)->parent;
- next_level = ((GtkCTreeRow *)clist_row)->level;
-
- if (!(((GtkCTreeRow *)clist_row)->sibling ||
- (((GtkCTreeRow *)clist_row)->children &&
- ((GtkCTreeRow *)clist_row)->expanded)))
- {
- work2 = gtk_ctree_find_node_ptr
- (ctree, (GtkCTreeRow *) clist_row);
+ tree_rectangle.x = clip_rectangle->x + PM_SIZE / 2;
+ tree_rectangle.width = (xcenter + PM_SIZE / 2 + 2 -
+ clip_rectangle->x);
+ }
- if (GTK_CTREE_NODE_NEXT (work2))
- next_level =
- GTK_CTREE_ROW (GTK_CTREE_NODE_NEXT (work2))->level;
- else
- next_level = 0;
- }
+ if (!gdk_rectangle_intersect (area, &tree_rectangle, &tc_rectangle))
+ break;
+ }
- while (work)
- {
- xcenter -= ctree->tree_indent;
+ offset_x = 1;
+ offset_y = 0;
+ if (ctree->line_style == GTK_CTREE_LINES_DOTTED)
+ {
+ offset_x += abs((clip_rectangle->x + clist->hoffset) % 2);
+ offset_y = abs((cell_rectangle->y + clist->voffset) % 2);
+ }
- if (GTK_CTREE_ROW(work)->row.bg_set)
- {
- gdk_gc_set_foreground
- (clist->bg_gc,
- &(GTK_CTREE_ROW(work)->row.background));
- mbg_gc = clist->bg_gc;
- }
- else
- mbg_gc = widget->style->bg_gc[GTK_STATE_PRELIGHT];
-
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_rectangle (clist->clist_window, mbg_gc, TRUE,
- xcenter, rect->y,
- ctree->tree_indent, rect->height);
-
- if (next_level > GTK_CTREE_ROW (work)->level)
- gdk_draw_line
- (clist->clist_window, ctree->lines_gc,
- xcenter, rect->y,
- xcenter, rect->y + rect->height);
- else
- {
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter, clip_rectangle.y,
- xcenter, ycenter);
-
- in = MIN (ctree->tree_indent, 2 * TAB_SIZE);
-
- if (clist_row->state != GTK_STATE_SELECTED)
- {
- work2 = GTK_CTREE_ROW (work)->parent;
-
- if (work2 && GTK_CTREE_ROW (work2)->row.bg_set)
- {
- gdk_gc_set_foreground
- (clist->bg_gc,
- &(GTK_CTREE_ROW (work2)->row.background));
-
- gdk_draw_rectangle
- (clist->clist_window, clist->bg_gc, TRUE,
- xcenter,
- ycenter,
- in / 2 + in % 2,
- row_rectangle.height / 2 + 1);
-
- if (GTK_CTREE_ROW (work)->row.bg_set)
- gdk_gc_set_foreground
- (clist->bg_gc,
- &(GTK_CTREE_ROW (work)->row.background));
- }
- else
- gdk_draw_rectangle
- (clist->clist_window,
- widget->style->bg_gc[GTK_STATE_PRELIGHT],
- TRUE,
- xcenter,
- ycenter,
- in / 2 + in % 2,
- row_rectangle.height / 2 + 1);
-
- gdk_draw_arc (clist->clist_window, mbg_gc,
- TRUE,
- xcenter, clip_rectangle.y,
- in, clist->row_height,
- 180 * 64, 90 * 64);
- }
-
- gdk_draw_arc (clist->clist_window, ctree->lines_gc,
- FALSE,
- xcenter, clip_rectangle.y,
- in, clist->row_height,
- 180 * 64, 90 * 64);
- }
- work = GTK_CTREE_ROW (work)->parent;
- }
+ clip_rectangle->y--;
+ clip_rectangle->height++;
+ gdk_gc_set_clip_rectangle (ctree->lines_gc, clip_rectangle);
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ xcenter,
+ (ctree->show_stub || clist->row_list->data != ctree_row) ?
+ cell_rectangle->y + offset_y : ycenter,
+ xcenter,
+ (ctree_row->sibling) ? crect->y +crect->height : ycenter);
+
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ xcenter + (justification_factor * offset_x), ycenter,
+ xcenter + (justification_factor * (PM_SIZE / 2 + 2)),
+ ycenter);
+
+ node = ctree_row->parent;
+ while (node)
+ {
+ xcenter -= (justification_factor * ctree->tree_indent);
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_rectangle
- (clist->clist_window,
- widget->style->bg_gc[GTK_STATE_PRELIGHT], TRUE,
- clip_rectangle.x, row_rectangle.y,
- TAB_SIZE, row_rectangle.height);
+ if (GTK_CTREE_ROW (node)->sibling)
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ xcenter, cell_rectangle->y + offset_y,
+ xcenter, crect->y + crect->height);
+ node = GTK_CTREE_ROW (node)->parent;
+ }
+ gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
+ clip_rectangle->y++;
+ clip_rectangle->height--;
+ break;
+ }
+ return offset;
+}
- xcenter = xdest + (ctree->tree_indent / 2);
-
- if (clist_row->bg_set)
- gdk_gc_set_foreground
- (clist->bg_gc, &clist_row->background);
-
- if (((GtkCTreeRow *)clist_row)->is_leaf)
- {
- points[0].x = xdest + TAB_SIZE;
- points[0].y = row_rectangle.y - 1;
-
- points[1].x = points[0].x - 4;
- points[1].y = points[0].y;
-
- points[2].x = points[1].x - 2;
- points[2].y = points[1].y + 3;
-
- points[3].x = points[2].x;
- points[3].y = points[2].y + clist->row_height - 5;
-
- points[4].x = points[3].x + 2;
- points[4].y = points[3].y + 3;
-
- points[5].x = points[4].x + 4;
- points[5].y = points[4].y;
-
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_polygon (clist->clist_window, bg_gc, TRUE,
- points, 6);
-
- gdk_draw_lines (clist->clist_window, ctree->lines_gc,
- points, 6);
- }
- else
- {
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_arc (clist->clist_window, bg_gc, TRUE,
- xdest, row_rectangle.y - 1,
- 2 * TAB_SIZE, clist->row_height,
- 90 * 64, 180 * 64);
-
- gdk_draw_arc (clist->clist_window, ctree->lines_gc,
- FALSE,
- xdest, row_rectangle.y - 1,
- 2 * TAB_SIZE, clist->row_height,
- 90 * 64, 180 * 64);
+static void
+draw_row (GtkCList *clist,
+ GdkRectangle *area,
+ gint row,
+ GtkCListRow *clist_row)
+{
+ GtkWidget *widget;
+ GtkCTree *ctree;
+ GdkRectangle *rect;
+ GdkRectangle *crect;
+ GdkRectangle row_rectangle;
+ GdkRectangle cell_rectangle;
+ GdkRectangle clip_rectangle;
+ GdkRectangle intersect_rectangle;
+ gint column_left = 0;
+ gint column_right = 0;
+ gint offset = 0;
+ gint state;
+ gint i;
- }
+ g_return_if_fail (clist != NULL);
- gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
- gdk_gc_set_clip_rectangle (clist->bg_gc, NULL);
- gdk_gc_set_clip_rectangle
- (widget->style->bg_gc[GTK_STATE_PRELIGHT], NULL);
-
- break;
- default:
- xcenter = xdest + (ctree->tree_indent / 2);
- if (ctree->line_style == GTK_CTREE_LINES_DOTTED)
- {
- offset_x += abs ((clip_rectangle.x + clist->hoffset) %
- 2);
- offset_y = abs ((clip_rectangle.y + clist->voffset) % 2);
- }
-
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter,
- (ctree->show_stub ||
- clist->row_list->data != clist_row) ?
- clip_rectangle.y + offset_y : ycenter,
- xcenter,
- (((GtkCTreeRow *)clist_row)->sibling) ?
- rect->y + rect->height : ycenter);
-
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter + offset_x, ycenter,
- xcenter + PM_SIZE / 2 + 2, ycenter);
-
- work = ((GtkCTreeRow *)clist_row)->parent;
- while (work)
- {
- xcenter -= ctree->tree_indent;
- if (GTK_CTREE_ROW (work)->sibling)
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter, clip_rectangle.y + offset_y,
- xcenter, rect->y + rect->height);
- work = GTK_CTREE_ROW (work)->parent;
- }
- gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
- break;
- }
-
- if (((GtkCTreeRow *)clist_row)->children)
- {
- if (clist_row->state == GTK_STATE_SELECTED)
- {
- if (clist_row->fg_set)
- tgc = clist->fg_gc;
- else
- tgc = widget->style->fg_gc[GTK_STATE_NORMAL];
- cgc = tgc;
- }
- else
- {
- cgc = GTK_WIDGET
- (clist)->style->fg_gc[GTK_STATE_SELECTED];
- tgc = fg_gc;
- }
-
- gdk_gc_set_clip_rectangle (cgc, rect);
+ /* bail now if we arn't drawable yet */
+ if (!GTK_WIDGET_DRAWABLE (clist) || row < 0 || row >= clist->rows)
+ return;
- switch (ctree->line_style)
- {
- case GTK_CTREE_LINES_NONE:
- if (!((GtkCTreeRow *)clist_row)->expanded)
- {
- points[0].x = xdest + xoffset + (PM_SIZE+2) / 6 + 2;
- points[0].y = clip_rectangle.y + yoffset - 1;
- points[1].x = points[0].x;
- points[1].y = points[0].y + (PM_SIZE+2);
- points[2].x = points[0].x + 2 * (PM_SIZE+2) / 3 - 1;
- points[2].y = points[0].y + (PM_SIZE+2) / 2;
- }
- else
- {
- points[0].x = xdest + xoffset;
- points[0].y = clip_rectangle.y + yoffset
- + (PM_SIZE+2) / 6;
- points[1].x = points[0].x + (PM_SIZE+2);
- points[1].y = points[0].y;
- points[2].x = points[0].x + (PM_SIZE+2) / 2;
- points[2].y = clip_rectangle.y + yoffset +
- 2 * (PM_SIZE+2) / 3;
- }
+ widget = GTK_WIDGET (clist);
+ ctree = GTK_CTREE (clist);
- gdk_draw_polygon (clist->clist_window,
- GTK_WIDGET (clist)->style->
- fg_gc[GTK_STATE_SELECTED],
- TRUE, points, 3);
- gdk_draw_polygon (clist->clist_window, tgc, FALSE,
- points, 3);
- break;
- case GTK_CTREE_LINES_TABBED:
- xcenter = xdest + PM_SIZE + 2;
- gdk_draw_arc (clist->clist_window,
- GTK_WIDGET (clist)->style->
- fg_gc[GTK_STATE_SELECTED],
- TRUE,
- xcenter - PM_SIZE/2,
- ycenter - PM_SIZE/2,
- PM_SIZE, PM_SIZE, 0, 360 * 64);
-
- gdk_draw_line (clist->clist_window, tgc,
- xcenter - 2,
- ycenter,
- xcenter + 2,
- ycenter);
-
- if (!((GtkCTreeRow *)clist_row)->expanded)
- gdk_draw_line (clist->clist_window, tgc,
- xcenter, clip_rectangle.y + yoffset + 2,
- xcenter,
- clip_rectangle.y + yoffset + PM_SIZE-2);
- break;
- default:
- gdk_draw_rectangle
- (clist->clist_window,
- GTK_WIDGET (clist)->style->fg_gc[GTK_STATE_SELECTED],
- TRUE,
- xdest + xoffset,
- clip_rectangle.y + yoffset,
- PM_SIZE, PM_SIZE);
-
- gdk_draw_rectangle (clist->clist_window, tgc, FALSE,
- xdest + xoffset,
- clip_rectangle.y + yoffset,
- PM_SIZE, PM_SIZE);
-
- gdk_draw_line (clist->clist_window, tgc,
- xdest + xoffset + 2, ycenter,
- xdest + xoffset + PM_SIZE - 2, ycenter);
-
- if (!((GtkCTreeRow *)clist_row)->expanded)
- {
- xcenter = xdest + (ctree->tree_indent / 2);
- gdk_draw_line (clist->clist_window, tgc,
- xcenter,
- clip_rectangle.y + yoffset + 2,
- xcenter,
- clip_rectangle.y + yoffset +
- PM_SIZE - 2);
- }
- break;
- }
-
- gdk_gc_set_clip_rectangle (cgc, NULL);
- }
-
- xdest += offset - clip_rectangle.x + ctree->tree_indent +
- clist_row->cell[i].horizontal;
+ /* if the function is passed the pointer to the row instead of null,
+ * it avoids this expensive lookup */
+ if (!clist_row)
+ clist_row = (g_list_nth (clist->row_list, row))->data;
- if (pixmap_width && xdest + pixmap_width >= rect->x &&
- xdest <= rect->x + rect->width)
- draw_pixmap = TRUE;
+ /* rectangle of the entire row */
+ row_rectangle.x = 0;
+ row_rectangle.y = ROW_TOP_YPIXEL (clist, row);
+ row_rectangle.width = clist->clist_window_width;
+ row_rectangle.height = clist->row_height;
- break;
+ /* rectangle of the cell spacing above the row */
+ cell_rectangle.x = 0;
+ cell_rectangle.y = row_rectangle.y - CELL_SPACING;
+ cell_rectangle.width = row_rectangle.width;
+ cell_rectangle.height = CELL_SPACING;
- case GTK_JUSTIFY_RIGHT:
- offset_x = 0;
-
- xdest = clip_rectangle.x + clip_rectangle.width + xoffset - 1 -
- (((GtkCTreeRow *) clist_row)->level - 1) * ctree->tree_indent;
-
- switch (ctree->line_style)
- {
- case GTK_CTREE_LINES_NONE:
- break;
- case GTK_CTREE_LINES_TABBED:
- xdest = clip_rectangle.x + clip_rectangle.width - 1
- - (((GtkCTreeRow *) clist_row)->level - 1)
- * ctree->tree_indent;
- xcenter = xdest - TAB_SIZE;
-
- gdk_gc_set_clip_origin (clist->bg_gc, 0, 0);
- gdk_gc_set_clip_rectangle (clist->bg_gc, rect);
-
- gdk_gc_set_clip_origin
- (widget->style->bg_gc[GTK_STATE_PRELIGHT], 0, 0);
- gdk_gc_set_clip_rectangle
- (widget->style->bg_gc[GTK_STATE_PRELIGHT], rect);
-
- work = ((GtkCTreeRow *)clist_row)->parent;
- next_level = ((GtkCTreeRow *)clist_row)->level;
-
- if (!(((GtkCTreeRow *)clist_row)->sibling ||
- (((GtkCTreeRow *)clist_row)->children &&
- ((GtkCTreeRow *)clist_row)->expanded)))
- {
- work2 = gtk_ctree_find_node_ptr
- (ctree, (GtkCTreeRow *) clist_row);
+ /* rectangle used to clip drawing operations, it's y and height
+ * positions only need to be set once, so we set them once here.
+ * the x and width are set withing the drawing loop below once per
+ * column */
+ clip_rectangle.y = row_rectangle.y;
+ clip_rectangle.height = row_rectangle.height;
- if (GTK_CTREE_NODE_NEXT (work2))
- next_level =
- GTK_CTREE_ROW (GTK_CTREE_NODE_NEXT (work2))->level;
- else
- next_level = 0;
- }
+ if (clist_row->state == GTK_STATE_NORMAL)
+ {
+ state = GTK_STATE_PRELIGHT;
+ if (clist_row->fg_set)
+ gdk_gc_set_foreground (clist->fg_gc, &clist_row->foreground);
+ if (clist_row->bg_set)
+ gdk_gc_set_foreground (clist->bg_gc, &clist_row->background);
+ }
+ else
+ state = clist_row->state;
- while (work)
- {
- xcenter += ctree->tree_indent;
+ gdk_gc_set_foreground (ctree->lines_gc,
+ &widget->style->fg[clist_row->state]);
- if (GTK_CTREE_ROW(work)->row.bg_set)
- {
- gdk_gc_set_foreground
- (clist->bg_gc,
- &(GTK_CTREE_ROW (work)->row.background));
- mbg_gc = clist->bg_gc;
- }
- else
- mbg_gc = widget->style->bg_gc[GTK_STATE_PRELIGHT];
+ /* draw the cell borders */
+ if (area)
+ {
+ rect = &intersect_rectangle;
+ crect = &intersect_rectangle;
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_rectangle (clist->clist_window,
- mbg_gc, TRUE,
- xcenter - ctree->tree_indent + 1,
- rect->y,
- ctree->tree_indent,
- rect->height);
-
- if (next_level > GTK_CTREE_ROW (work)->level)
- gdk_draw_line
- (clist->clist_window, ctree->lines_gc,
- xcenter, rect->y,
- xcenter, rect->y + rect->height);
- else
- {
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter, clip_rectangle.y,
- xcenter, ycenter);
-
- in = MIN (ctree->tree_indent, 2 * TAB_SIZE);
-
- if (clist_row->state != GTK_STATE_SELECTED)
- {
- work2 = GTK_CTREE_ROW (work)->parent;
-
- if (work2 && GTK_CTREE_ROW (work2)->row.bg_set)
- {
- gdk_gc_set_foreground
- (clist->bg_gc,
- &(GTK_CTREE_ROW (work2)->row.background));
-
- gdk_draw_rectangle
- (clist->clist_window, clist->bg_gc, TRUE,
- xcenter + 1 - in / 2 - in % 2,
- ycenter,
- in / 2 + in % 2,
- row_rectangle.height / 2 + 1);
-
- if (GTK_CTREE_ROW (work)->row.bg_set)
- gdk_gc_set_foreground
- (clist->bg_gc,
- &(GTK_CTREE_ROW(work)->row.background));
- }
- else
- gdk_draw_rectangle
- (clist->clist_window,
- widget->style->bg_gc[GTK_STATE_PRELIGHT],
- TRUE,
- xcenter + 1 - in / 2 - in % 2,
- ycenter,
- in / 2 + in % 2,
- row_rectangle.height / 2 + 1);
-
- gdk_draw_arc (clist->clist_window, mbg_gc, TRUE,
- xcenter - in, clip_rectangle.y,
- in, clist->row_height,
- 270 * 64, 90 * 64);
- }
-
- gdk_draw_arc (clist->clist_window, ctree->lines_gc,
- FALSE,
- xcenter - in, clip_rectangle.y,
- in, clist->row_height,
- 270 * 64, 90 * 64);
- }
+ if (gdk_rectangle_intersect (area, &cell_rectangle, crect))
+ gdk_draw_rectangle (clist->clist_window,
+ widget->style->base_gc[GTK_STATE_NORMAL], TRUE,
+ crect->x, crect->y, crect->width, crect->height);
+ }
+ else
+ {
+ rect = &clip_rectangle;
+ crect = &cell_rectangle;
- work = GTK_CTREE_ROW (work)->parent;
- }
+ gdk_draw_rectangle (clist->clist_window,
+ widget->style->base_gc[GTK_STATE_NORMAL], TRUE,
+ crect->x, crect->y, crect->width, crect->height);
+ }
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_rectangle
- (clist->clist_window,
- widget->style->bg_gc[GTK_STATE_PRELIGHT], TRUE,
- xcenter + 1, row_rectangle.y,
- TAB_SIZE, row_rectangle.height);
+ /* horizontal black lines */
+ if (ctree->line_style == GTK_CTREE_LINES_TABBED)
+ {
- xcenter = xdest - (ctree->tree_indent / 2);
-
- if (clist_row->bg_set)
- gdk_gc_set_foreground
- (clist->bg_gc, &clist_row->background);
-
- if (((GtkCTreeRow *)clist_row)->is_leaf)
- {
- points[0].x = xdest - TAB_SIZE;
- points[0].y = row_rectangle.y - 1;
-
- points[1].x = points[0].x + 4;
- points[1].y = points[0].y;
-
- points[2].x = points[1].x + 2;
- points[2].y = points[1].y + 3;
-
- points[3].x = points[2].x;
- points[3].y = points[2].y + clist->row_height - 5;
-
- points[4].x = points[3].x - 2;
- points[4].y = points[3].y + 3;
-
- points[5].x = points[4].x - 4;
- points[5].y = points[4].y;
-
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_polygon (clist->clist_window, bg_gc, TRUE,
- points, 6);
-
- gdk_draw_lines (clist->clist_window, ctree->lines_gc,
- points, 6);
- }
- else
- {
- if (clist_row->state != GTK_STATE_SELECTED)
- gdk_draw_arc (clist->clist_window, bg_gc, TRUE,
- xdest - 2 * TAB_SIZE,
- row_rectangle.y - 1,
- 2 * TAB_SIZE, clist->row_height,
- 270 * 64, 180 * 64);
-
- gdk_draw_arc (clist->clist_window, ctree->lines_gc,
- FALSE,
- xdest - 2 * TAB_SIZE,
- row_rectangle.y - 1,
- 2 * TAB_SIZE, clist->row_height,
- 270 * 64, 180 * 64);
- }
+ column_right = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) +
+ clist->column[ctree->tree_column].area.width +
+ COLUMN_INSET);
+ column_left = (COLUMN_LEFT_XPIXEL (clist, ctree->tree_column) -
+ COLUMN_INSET - (ctree->tree_column != 0) * CELL_SPACING);
- gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
- gdk_gc_set_clip_rectangle (clist->bg_gc, NULL);
- gdk_gc_set_clip_rectangle
- (widget->style->bg_gc[GTK_STATE_PRELIGHT], NULL);
-
- break;
- default:
- xcenter = xdest - (ctree->tree_indent / 2);
- if (ctree->line_style == GTK_CTREE_LINES_DOTTED)
- {
- offset_x += abs ((clip_rectangle.x + clist->hoffset) %
- 2);
- offset_y = abs ((clip_rectangle.y + clist->voffset) % 2);
- }
-
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter, clip_rectangle.y + offset_y,
- xcenter,
- (((GtkCTreeRow *)clist_row)->sibling) ?
- rect->y + rect->height : ycenter);
-
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter - offset_x, ycenter,
- xcenter - PM_SIZE / 2 - 2, ycenter);
-
- work = ((GtkCTreeRow *)clist_row)->parent;
- while (work)
- {
- xcenter += ctree->tree_indent;
- if (GTK_CTREE_ROW (work)->sibling)
- gdk_draw_line (clist->clist_window, ctree->lines_gc,
- xcenter, clip_rectangle.y - offset_y,
- xcenter, rect->y + rect->height);
- work = GTK_CTREE_ROW (work)->parent;
- }
- gdk_gc_set_clip_rectangle (ctree->lines_gc, NULL);
- }
+ switch (clist->column[ctree->tree_column].justification)
+ {
+ case GTK_JUSTIFY_CENTER:
+ case GTK_JUSTIFY_FILL:
+ case GTK_JUSTIFY_LEFT:
+ offset = (column_left + ctree->tree_indent *
+ (((GtkCTreeRow *)clist_row)->level - 1));
-
- if (((GtkCTreeRow *)clist_row)->children)
- {
- if (clist_row->state == GTK_STATE_SELECTED)
- {
- if (clist_row->fg_set)
- tgc = clist->fg_gc;
- else
- tgc = widget->style->fg_gc[GTK_STATE_NORMAL];
- cgc = tgc;
- }
- else
- {
- cgc =
- GTK_WIDGET(clist)->style->fg_gc[GTK_STATE_SELECTED];
- tgc = fg_gc;
- }
-
- gdk_gc_set_clip_rectangle (cgc, rect);
-
- switch (ctree->line_style)
- {
- case GTK_CTREE_LINES_NONE:
- if (!((GtkCTreeRow *)clist_row)->expanded)
- {
- points[0].x = xdest - xoffset - (PM_SIZE+2) / 6 - 2;
- points[0].y = clip_rectangle.y + yoffset - 1;
- points[1].x = points[0].x;
- points[1].y = points[0].y + (PM_SIZE+2);
- points[2].x = points[0].x - 2 * (PM_SIZE+2) / 3 + 1;
- points[2].y = points[0].y + (PM_SIZE+2) / 2;
- }
- else
- {
- points[0].x = xdest - xoffset;
- points[0].y = clip_rectangle.y + yoffset +
- (PM_SIZE+2) / 6;
- points[1].x = points[0].x - (PM_SIZE+2);
- points[1].y = points[0].y;
- points[2].x = points[0].x - (PM_SIZE+2) / 2;
- points[2].y = clip_rectangle.y + yoffset +
- 2 * (PM_SIZE+2) / 3;
- }
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ MIN (offset + TAB_SIZE, column_right),
+ cell_rectangle.y,
+ clist->clist_window_width, cell_rectangle.y);
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ offset = (column_right - 1 - ctree->tree_indent *
+ (((GtkCTreeRow *)clist_row)->level - 1));
- gdk_draw_polygon (clist->clist_window,
- GTK_WIDGET (clist)->style->
- fg_gc[GTK_STATE_SELECTED],
- TRUE, points, 3);
- gdk_draw_polygon (clist->clist_window, tgc, FALSE,
- points, 3);
- break;
- case GTK_CTREE_LINES_TABBED:
- xcenter = xdest - PM_SIZE - 2;
-
- gdk_draw_arc (clist->clist_window,
- GTK_WIDGET (clist)->style->
- fg_gc[GTK_STATE_SELECTED],
- TRUE,
- xcenter - PM_SIZE/2,
- ycenter - PM_SIZE/2,
- PM_SIZE, PM_SIZE, 0, 360 * 64);
-
- gdk_draw_line (clist->clist_window, tgc,
- xcenter - 2,
- ycenter,
- xcenter + 2,
- ycenter);
-
- if (!((GtkCTreeRow *)clist_row)->expanded)
- {
- gdk_draw_line (clist->clist_window, tgc, xcenter,
- clip_rectangle.y + yoffset + 2,
- xcenter, clip_rectangle.y + yoffset
- + PM_SIZE - 2);
- }
- break;
- default:
- gdk_draw_rectangle (clist->clist_window,
- GTK_WIDGET(clist)->style->
- fg_gc[GTK_STATE_SELECTED], TRUE,
- xdest - xoffset - PM_SIZE,
- clip_rectangle.y + yoffset,
- PM_SIZE, PM_SIZE);
-
- gdk_draw_rectangle (clist->clist_window, tgc, FALSE,
- xdest - xoffset - PM_SIZE,
- clip_rectangle.y + yoffset,
- PM_SIZE, PM_SIZE);
-
- gdk_draw_line (clist->clist_window, tgc,
- xdest - xoffset - 2, ycenter,
- xdest - xoffset - PM_SIZE + 2, ycenter);
-
- if (!((GtkCTreeRow *)clist_row)->expanded)
- {
- xcenter = xdest - (ctree->tree_indent / 2);
- gdk_draw_line (clist->clist_window, tgc, xcenter,
- clip_rectangle.y + yoffset + 2,
- xcenter, clip_rectangle.y + yoffset
- + PM_SIZE - 2);
- }
- }
- gdk_gc_set_clip_rectangle (cgc, NULL);
- }
-
- xdest -= (ctree->tree_indent + pixmap_width
- + clist_row->cell[i].horizontal);
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ -1, cell_rectangle.y,
+ MAX (offset - TAB_SIZE, column_left),
+ cell_rectangle.y);
+ break;
+ }
+ }
- if (pixmap_width && xdest + pixmap_width >= rect->x &&
- xdest <= rect->x + rect->width)
- draw_pixmap = TRUE;
- break;
- default :
- break;
- }
+ /* the last row has to clear it's bottom cell spacing too */
+ if (clist_row == clist->row_list_end->data)
+ {
+ cell_rectangle.y += clist->row_height + CELL_SPACING;
- if (draw_pixmap)
- {
- if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_mask
- (fg_gc, GTK_CELL_PIXTEXT (clist_row->cell[i])->mask);
- gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
- }
-
- if (xdest < clip_rectangle.x)
- {
- xsrc = clip_rectangle.x - xdest;
- pixmap_width -= xsrc;
- xdest = clip_rectangle.x;
- }
-
- if (xdest + pixmap_width >
- clip_rectangle.x + clip_rectangle.width)
- pixmap_width =
- (clip_rectangle.x + clip_rectangle.width) - xdest;
-
- if (ydest < clip_rectangle.y)
- {
- ysrc = clip_rectangle.y - ydest;
- height -= ysrc;
- ydest = clip_rectangle.y;
- }
-
- if (ydest + height > clip_rectangle.y + clip_rectangle.height)
- height = (clip_rectangle.y + clip_rectangle.height) - ydest;
-
- gdk_draw_pixmap (clist->clist_window, fg_gc,
- GTK_CELL_PIXTEXT
- (clist_row->cell[i])->pixmap,
- xsrc, ysrc, xdest, ydest,
- pixmap_width, height);
- }
+ if (!area || gdk_rectangle_intersect (area, &cell_rectangle, crect))
+ {
+ gdk_draw_rectangle (clist->clist_window,
+ widget->style->base_gc[GTK_STATE_NORMAL], TRUE,
+ crect->x, crect->y, crect->width, crect->height);
- if (string_width)
+ /* horizontal black lines */
+ if (ctree->line_style == GTK_CTREE_LINES_TABBED)
{
- gint delta;
-
- if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
- xdest -= (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
- string_width);
- else
- xdest += (GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing +
- pixmap_width);
-
- delta = CELL_SPACING - (rect->y - clip_rectangle.y);
- if (delta > 0)
+ switch (clist->column[ctree->tree_column].justification)
{
- rect->y += delta;
- rect->height -= delta;
+ case GTK_JUSTIFY_CENTER:
+ case GTK_JUSTIFY_FILL:
+ case GTK_JUSTIFY_LEFT:
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ MIN (column_left + TAB_SIZE + COLUMN_INSET +
+ (((GtkCTreeRow *)clist_row)->level > 1) *
+ MIN (ctree->tree_indent / 2, TAB_SIZE),
+ column_right),
+ cell_rectangle.y,
+ clist->clist_window_width, cell_rectangle.y);
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ gdk_draw_line (clist->clist_window, ctree->lines_gc,
+ -1, cell_rectangle.y,
+ MAX (column_right - TAB_SIZE - 1 -
+ COLUMN_INSET -
+ (((GtkCTreeRow *)clist_row)->level > 1) *
+ MIN (ctree->tree_indent / 2, TAB_SIZE),
+ column_left - 1), cell_rectangle.y);
+ break;
}
-
- gdk_gc_set_clip_rectangle (fg_gc, rect);
-
- gdk_draw_string
- (clist->clist_window, widget->style->font, fg_gc, xdest,
- row_rectangle.y + clist->row_center_offset +
- clist_row->cell[i].vertical,
- GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
}
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
+ }
+ }
+
+ /* iterate and draw all the columns (row cells) and draw their contents */
+ for (i = 0; i < clist->columns; i++)
+ {
+ GtkStyle *style;
+ GdkGC *fg_gc;
+ GdkGC *bg_gc;
+
+ gint width;
+ gint height;
+ gint pixmap_width;
+ gint string_width;
+ gint old_offset;
+ gint row_center_offset;
+
+ if (!clist->column[i].visible)
+ continue;
+
+ get_cell_style (clist, clist_row, state, i, &style, &fg_gc, &bg_gc);
+
+ /* calculate clipping region */
+ clip_rectangle.x = clist->column[i].area.x + clist->hoffset;
+ clip_rectangle.width = clist->column[i].area.width;
+
+ cell_rectangle.x = clip_rectangle.x - COLUMN_INSET - CELL_SPACING;
+ cell_rectangle.width = (clip_rectangle.width + 2 * COLUMN_INSET +
+ (1 + (i + 1 == clist->columns)) * CELL_SPACING);
+ cell_rectangle.y = clip_rectangle.y;
+ cell_rectangle.height = clip_rectangle.height;
+
+ string_width = 0;
+ pixmap_width = 0;
+
+ if (area && !gdk_rectangle_intersect (area, &cell_rectangle,
+ &intersect_rectangle))
+ {
+ if (i != ctree->tree_column)
+ continue;
}
else
{
+ gdk_draw_rectangle (clist->clist_window, bg_gc, TRUE,
+ crect->x, crect->y, crect->width, crect->height);
+
+ /* calculate real width for column justification */
switch (clist_row->cell[i].type)
{
- case GTK_CELL_EMPTY:
- continue;
- break;
-
case GTK_CELL_TEXT:
- gdk_gc_set_clip_rectangle (fg_gc, rect);
-
- gdk_draw_string (clist->clist_window,
- widget->style->font,
- fg_gc,
- offset + clist_row->cell[i].horizontal,
- row_rectangle.y + clist->row_center_offset +
- clist_row->cell[i].vertical,
- GTK_CELL_TEXT (clist_row->cell[i])->text);
-
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
+ width = gdk_string_width
+ (style->font, GTK_CELL_TEXT (clist_row->cell[i])->text);
break;
-
case GTK_CELL_PIXMAP:
- xsrc = 0;
- ysrc = 0;
- xdest = offset + clist_row->cell[i].horizontal;
- ydest = (clip_rectangle.y + (clip_rectangle.height / 2))
- - height / 2 + clist_row->cell[i].vertical;
+ gdk_window_get_size
+ (GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap, &pixmap_width,
+ &height);
+ width = pixmap_width;
+ break;
+ case GTK_CELL_PIXTEXT:
+ if (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap)
+ gdk_window_get_size
+ (GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
+ &pixmap_width, &height);
- if (GTK_CELL_PIXMAP (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXMAP
- (clist_row->cell[i])->mask);
- gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
- }
+ width = (pixmap_width +
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing);
- if (xdest < clip_rectangle.x)
- {
- xsrc = clip_rectangle.x - xdest;
- pixmap_width -= xsrc;
- xdest = clip_rectangle.x;
- }
-
- if (xdest + pixmap_width >
- clip_rectangle.x + clip_rectangle.width)
- pixmap_width = (clip_rectangle.x + clip_rectangle.width) -
- xdest;
-
- if (ydest < clip_rectangle.y)
+ if (GTK_CELL_PIXTEXT (clist_row->cell[i])->text)
{
- ysrc = clip_rectangle.y - ydest;
- height -= ysrc;
- ydest = clip_rectangle.y;
+ string_width = gdk_string_width
+ (style->font, GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
+ width += string_width;
}
- if (ydest + height > clip_rectangle.y + clip_rectangle.height)
- height = (clip_rectangle.y + clip_rectangle.height) - ydest;
-
- gdk_draw_pixmap (clist->clist_window, fg_gc,
- GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
- xsrc, ysrc, xdest, ydest, pixmap_width, height);
+ if (i == ctree->tree_column)
+ width += (ctree->tree_indent *
+ ((GtkCTreeRow *)clist_row)->level);
+ break;
+ default:
+ continue;
+ break;
+ }
- if (GTK_CELL_PIXMAP (clist_row->cell[i])->mask)
- {
- gdk_gc_set_clip_origin (fg_gc, 0, 0);
- gdk_gc_set_clip_mask (fg_gc, NULL);
- }
+ switch (clist->column[i].justification)
+ {
+ case GTK_JUSTIFY_LEFT:
+ offset = clip_rectangle.x + clist_row->cell[i].horizontal;
break;
+ case GTK_JUSTIFY_RIGHT:
+ offset = (clip_rectangle.x + clist_row->cell[i].horizontal +
+ clip_rectangle.width - width);
+ break;
+ case GTK_JUSTIFY_CENTER:
+ case GTK_JUSTIFY_FILL:
+ offset = (clip_rectangle.x + clist_row->cell[i].horizontal +
+ (clip_rectangle.width / 2) - (width / 2));
+ break;
+ };
- case GTK_CELL_PIXTEXT:
- /* draw the pixmap */
- xsrc = 0;
- ysrc = 0;
- xdest = offset + clist_row->cell[i].horizontal;
- ydest = (clip_rectangle.y + (clip_rectangle.height / 2))
- - height / 2 + clist_row->cell[i].vertical;
-
- if (GTK_CELL_PIXTEXT (clist_row->cell[i])->mask)
+ if (i != ctree->tree_column)
+ {
+ offset += clist_row->cell[i].horizontal;
+ switch (clist_row->cell[i].type)
{
- gdk_gc_set_clip_mask (fg_gc, GTK_CELL_PIXTEXT
- (clist_row->cell[i])->mask);
- gdk_gc_set_clip_origin (fg_gc, xdest, ydest);
+ case GTK_CELL_PIXMAP:
+ draw_cell_pixmap
+ (clist->clist_window, &clip_rectangle, fg_gc,
+ GTK_CELL_PIXMAP (clist_row->cell[i])->pixmap,
+ GTK_CELL_PIXMAP (clist_row->cell[i])->mask,
+ offset,
+ clip_rectangle.y + clist_row->cell[i].vertical +
+ (clip_rectangle.height - height) / 2,
+ pixmap_width, height);
+ break;
+ case GTK_CELL_PIXTEXT:
+ offset = draw_cell_pixmap
+ (clist->clist_window, &clip_rectangle, fg_gc,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->mask,
+ offset,
+ clip_rectangle.y + clist_row->cell[i].vertical +
+ (clip_rectangle.height - height) / 2,
+ pixmap_width, height);
+ offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
+ case GTK_CELL_TEXT:
+ if (style != GTK_WIDGET (clist)->style)
+ row_center_offset = (((clist->row_height -
+ style->font->ascent -
+ style->font->descent - 1) / 2) +
+ 1.5 + style->font->ascent);
+ else
+ row_center_offset = clist->row_center_offset;
+
+ gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
+ gdk_draw_string
+ (clist->clist_window, style->font, fg_gc,
+ offset,
+ row_rectangle.y + row_center_offset +
+ clist_row->cell[i].vertical,
+ (clist_row->cell[i].type == GTK_CELL_PIXTEXT) ?
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->text :
+ GTK_CELL_TEXT (clist_row->cell[i])->text);
+ gdk_gc_set_clip_rectangle (fg_gc, NULL);
+ break;
+ default:
+ break;
}
+ continue;
+ }
+ }
- if (xdest < clip_rectangle.x)
- {
- xsrc = clip_rectangle.x - xdest;
- pixmap_width -= xsrc;
- xdest = clip_rectangle.x;
- }
+ if (bg_gc == clist->bg_gc)
+ gdk_gc_set_background (ctree->lines_gc, &clist_row->background);
- if (xdest + pixmap_width >
- clip_rectangle.x + clip_rectangle.width)
- pixmap_width = (clip_rectangle.x + clip_rectangle.width)
- - xdest;
+ /* draw ctree->tree_column */
+ cell_rectangle.y -= CELL_SPACING;
+ cell_rectangle.height += CELL_SPACING;
- if (ydest < clip_rectangle.y)
- {
- ysrc = clip_rectangle.y - ydest;
- height -= ysrc;
- ydest = clip_rectangle.y;
- }
+ if (area && !gdk_rectangle_intersect (area, &cell_rectangle,
+ &intersect_rectangle))
+ continue;
- if (ydest + height > clip_rectangle.y + clip_rectangle.height)
- height = (clip_rectangle.y + clip_rectangle.height) - ydest;
-
- gdk_draw_pixmap (clist->clist_window, fg_gc,
- GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
- xsrc, ysrc, xdest, ydest, pixmap_width, height);
-
- gdk_gc_set_clip_origin (fg_gc, 0, 0);
-
- xdest += pixmap_width + GTK_CELL_PIXTEXT
- (clist_row->cell[i])->spacing;
-
- /* draw the string */
- gdk_gc_set_clip_rectangle (fg_gc, rect);
-
- gdk_draw_string (clist->clist_window, widget->style->font, fg_gc,
- xdest,
- row_rectangle.y + clist->row_center_offset +
- clist_row->cell[i].vertical,
- GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
-
- gdk_gc_set_clip_rectangle (fg_gc, NULL);
-
- break;
+ /* draw lines */
+ offset = gtk_ctree_draw_lines (ctree, (GtkCTreeRow *)clist_row, row, i,
+ state, &clip_rectangle, &cell_rectangle,
+ crect, area, style);
- case GTK_CELL_WIDGET:
- /* unimplemented */
- continue;
- break;
+ /* draw expander */
+ offset = gtk_ctree_draw_expander (ctree, (GtkCTreeRow *)clist_row,
+ style, &clip_rectangle, offset);
- default:
- continue;
- break;
- }
+ if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
+ offset -= ctree->tree_spacing;
+ else
+ offset += ctree->tree_spacing;
+
+ if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
+ offset -= (pixmap_width + clist_row->cell[i].horizontal);
+ else
+ offset += clist_row->cell[i].horizontal;
+
+ old_offset = offset;
+ offset = draw_cell_pixmap (clist->clist_window, &clip_rectangle, fg_gc,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->pixmap,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->mask,
+ offset,
+ clip_rectangle.y + clist_row->cell[i].vertical
+ + (clip_rectangle.height - height) / 2,
+ pixmap_width, height);
+
+ if (string_width)
+ {
+ if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
+ offset = (old_offset - string_width -
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing);
+ else
+ offset += GTK_CELL_PIXTEXT (clist_row->cell[i])->spacing;
+
+ if (style != GTK_WIDGET (clist)->style)
+ row_center_offset = (((clist->row_height - style->font->ascent -
+ style->font->descent - 1) / 2) +
+ 1.5 + style->font->ascent);
+ else
+ row_center_offset = clist->row_center_offset;
+
+ gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
+ gdk_draw_string (clist->clist_window, style->font, fg_gc, offset,
+ row_rectangle.y + row_center_offset +
+ clist_row->cell[i].vertical,
+ GTK_CELL_PIXTEXT (clist_row->cell[i])->text);
}
+ gdk_gc_set_clip_rectangle (fg_gc, NULL);
}
+
+ /* draw focus rectangle */
if (clist->focus_row == row && GTK_WIDGET_HAS_FOCUS (widget))
{
- if (area)
- {
- if (gdk_rectangle_intersect (area, &row_rectangle,
- &intersect_rectangle))
- {
- gdk_gc_set_clip_rectangle (clist->xor_gc, &intersect_rectangle);
- gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
- row_rectangle.x, row_rectangle.y,
- row_rectangle.width - 1,
- row_rectangle.height - 1);
- gdk_gc_set_clip_rectangle (clist->xor_gc, NULL);
- }
- }
- else
+ if (!area)
gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
row_rectangle.x, row_rectangle.y,
row_rectangle.width - 1, row_rectangle.height - 1);
+ else if (gdk_rectangle_intersect (area, &row_rectangle,
+ &intersect_rectangle))
+ {
+ gdk_gc_set_clip_rectangle (clist->xor_gc, &intersect_rectangle);
+ gdk_draw_rectangle (clist->clist_window, clist->xor_gc, FALSE,
+ row_rectangle.x, row_rectangle.y,
+ row_rectangle.width - 1,
+ row_rectangle.height - 1);
+ gdk_gc_set_clip_rectangle (clist->xor_gc, NULL);
+ }
}
}
@@ -3328,12 +3121,14 @@ row_new (GtkCTree *ctree)
ctree_row->row.cell[i].type = GTK_CELL_EMPTY;
ctree_row->row.cell[i].vertical = 0;
ctree_row->row.cell[i].horizontal = 0;
+ ctree_row->row.cell[i].style = NULL;
}
GTK_CELL_PIXTEXT (ctree_row->row.cell[ctree->tree_column])->text = NULL;
ctree_row->row.fg_set = FALSE;
ctree_row->row.bg_set = FALSE;
+ ctree_row->row.style = NULL;
ctree_row->row.selectable = TRUE;
ctree_row->row.state = GTK_STATE_NORMAL;
ctree_row->row.data = NULL;
@@ -3362,8 +3157,23 @@ row_delete (GtkCTree *ctree,
clist = GTK_CLIST (ctree);
for (i = 0; i < clist->columns; i++)
- GTK_CLIST_CLASS_FW (clist)->set_cell_contents
- (clist, &(ctree_row->row), i, GTK_CELL_EMPTY, NULL, 0, NULL, NULL);
+ {
+ GTK_CLIST_CLASS_FW (clist)->set_cell_contents
+ (clist, &(ctree_row->row), i, GTK_CELL_EMPTY, NULL, 0, NULL, NULL);
+ if (ctree_row->row.cell[i].style)
+ {
+ if (GTK_WIDGET_REALIZED (ctree))
+ gtk_style_detach (ctree_row->row.cell[i].style);
+ gtk_style_unref (ctree_row->row.cell[i].style);
+ }
+ }
+
+ if (ctree_row->row.style)
+ {
+ if (GTK_WIDGET_REALIZED (ctree))
+ gtk_style_detach (ctree_row->row.style);
+ gtk_style_unref (ctree_row->row.style);
+ }
if (ctree_row->pixmap_closed)
{
@@ -3669,31 +3479,28 @@ ctree_is_hot_spot (GtkCTree *ctree,
g_return_val_if_fail (GTK_IS_CTREE (ctree), FALSE);
g_return_val_if_fail (node != NULL, FALSE);
- tree_row = GTK_CTREE_ROW (node);
clist = GTK_CLIST (ctree);
- if (!clist->column[ctree->tree_column].visible)
+ if (!clist->column[ctree->tree_column].visible ||
+ ctree->expander_style == GTK_CTREE_EXPANDER_NONE)
return FALSE;
+ tree_row = GTK_CTREE_ROW (node);
+
cell = GTK_CELL_PIXTEXT(tree_row->row.cell[ctree->tree_column]);
- yu = ROW_TOP_YPIXEL (clist, row) + (clist->row_height - PM_SIZE) / 2;
+ yu = (ROW_TOP_YPIXEL (clist, row) + (clist->row_height - PM_SIZE) / 2 -
+ (clist->row_height - 1) % 2);
if (clist->column[ctree->tree_column].justification == GTK_JUSTIFY_RIGHT)
- {
- xl = clist->column[ctree->tree_column].area.x
- + clist->column[ctree->tree_column].area.width + clist->hoffset
- /*+ cell->horizontal +*/
- - (tree_row->level - 1) * ctree->tree_indent
- - PM_SIZE - 1 -
- (ctree->line_style == GTK_CTREE_LINES_TABBED) * ((PM_SIZE / 2) + 1);
- }
+ xl = (clist->column[ctree->tree_column].area.x +
+ clist->column[ctree->tree_column].area.width - 1 + clist->hoffset -
+ (tree_row->level - 1) * ctree->tree_indent - PM_SIZE -
+ (ctree->line_style == GTK_CTREE_LINES_TABBED) * 3);
else
- {
- xl = clist->column[ctree->tree_column].area.x + clist->hoffset
- + cell->horizontal + (tree_row->level - 1) * ctree->tree_indent +
- (ctree->line_style == GTK_CTREE_LINES_TABBED) * ((PM_SIZE / 2) + 2);
- }
+ xl = (clist->column[ctree->tree_column].area.x + clist->hoffset +
+ (tree_row->level - 1) * ctree->tree_indent +
+ (ctree->line_style == GTK_CTREE_LINES_TABBED) * 3);
return (x >= xl && x <= xl + PM_SIZE && y >= yu && y <= yu + PM_SIZE);
}
@@ -5085,6 +4892,112 @@ gtk_ctree_get_node_info (GtkCTree *ctree,
}
void
+gtk_ctree_node_set_cell_style (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gint column,
+ GtkStyle *style)
+{
+ GtkCList *clist;
+
+ g_return_if_fail (ctree != NULL);
+ g_return_if_fail (GTK_IS_CTREE (ctree));
+ g_return_if_fail (node != NULL);
+
+ clist = GTK_CLIST (ctree);
+
+ if (column < 0 || column >= clist->columns)
+ return;
+
+ if (GTK_CTREE_ROW (node)->row.cell[column].style == style)
+ return;
+
+ if (GTK_CTREE_ROW (node)->row.cell[column].style)
+ {
+ if (GTK_WIDGET_REALIZED (ctree))
+ gtk_style_detach (GTK_CTREE_ROW (node)->row.cell[column].style);
+ gtk_style_unref (GTK_CTREE_ROW (node)->row.cell[column].style);
+ }
+
+ GTK_CTREE_ROW (node)->row.cell[column].style = style;
+
+ if (GTK_CTREE_ROW (node)->row.cell[column].style)
+ {
+ gtk_style_ref (GTK_CTREE_ROW (node)->row.cell[column].style);
+
+ if (GTK_WIDGET_REALIZED (ctree))
+ GTK_CTREE_ROW (node)->row.cell[column].style =
+ gtk_style_attach (GTK_CTREE_ROW (node)->row.cell[column].style,
+ clist->clist_window);
+ }
+
+ tree_draw_node (ctree, node);
+}
+
+GtkStyle *
+gtk_ctree_node_get_cell_style (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gint column)
+{
+ g_return_val_if_fail (ctree != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ if (column < 0 || column >= GTK_CLIST (ctree)->columns)
+ return NULL;
+
+ return GTK_CTREE_ROW (node)->row.cell[column].style;
+}
+
+void
+gtk_ctree_node_set_row_style (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ GtkStyle *style)
+{
+ GtkCList *clist;
+
+ g_return_if_fail (ctree != NULL);
+ g_return_if_fail (GTK_IS_CTREE (ctree));
+ g_return_if_fail (node != NULL);
+
+ clist = GTK_CLIST (ctree);
+
+ if (GTK_CTREE_ROW (node)->row.style == style)
+ return;
+
+ if (GTK_CTREE_ROW (node)->row.style)
+ {
+ if (GTK_WIDGET_REALIZED (ctree))
+ gtk_style_detach (GTK_CTREE_ROW (node)->row.style);
+ gtk_style_unref (GTK_CTREE_ROW (node)->row.style);
+ }
+
+ GTK_CTREE_ROW (node)->row.style = style;
+
+ if (GTK_CTREE_ROW (node)->row.style)
+ {
+ gtk_style_ref (GTK_CTREE_ROW (node)->row.style);
+
+ if (GTK_WIDGET_REALIZED (ctree))
+ GTK_CTREE_ROW (node)->row.style =
+ gtk_style_attach (GTK_CTREE_ROW (node)->row.style,
+ clist->clist_window);
+ }
+
+ tree_draw_node (ctree, node);
+}
+
+GtkStyle *
+gtk_ctree_node_get_row_style (GtkCTree *ctree,
+ GtkCTreeNode *node)
+{
+ g_return_val_if_fail (ctree != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
+ g_return_val_if_fail (node != NULL, NULL);
+
+ return GTK_CTREE_ROW (node)->row.style;
+}
+
+void
gtk_ctree_node_set_foreground (GtkCTree *ctree,
GtkCTreeNode *node,
GdkColor *color)
@@ -5097,6 +5010,9 @@ gtk_ctree_node_set_foreground (GtkCTree *ctree,
{
GTK_CTREE_ROW (node)->row.foreground = *color;
GTK_CTREE_ROW (node)->row.fg_set = TRUE;
+ if (GTK_WIDGET_REALIZED (ctree))
+ gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (ctree)),
+ &GTK_CTREE_ROW (node)->row.foreground);
}
else
GTK_CTREE_ROW (node)->row.fg_set = FALSE;
@@ -5117,6 +5033,9 @@ gtk_ctree_node_set_background (GtkCTree *ctree,
{
GTK_CTREE_ROW (node)->row.background = *color;
GTK_CTREE_ROW (node)->row.bg_set = TRUE;
+ if (GTK_WIDGET_REALIZED (ctree))
+ gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (ctree)),
+ &GTK_CTREE_ROW (node)->row.background);
}
else
GTK_CTREE_ROW (node)->row.bg_set = FALSE;
@@ -5214,6 +5133,22 @@ gtk_ctree_set_indent (GtkCTree *ctree,
}
void
+gtk_ctree_set_spacing (GtkCTree *ctree,
+ gint spacing)
+{
+ g_return_if_fail (ctree != NULL);
+ g_return_if_fail (GTK_IS_CTREE (ctree));
+ g_return_if_fail (spacing >= 0);
+
+ if (spacing != ctree->tree_spacing)
+ {
+ ctree->tree_spacing = spacing;
+ if (!GTK_CLIST_FROZEN (ctree))
+ gtk_clist_thaw (GTK_CLIST (ctree));
+ }
+}
+
+void
gtk_ctree_show_stub (GtkCTree *ctree,
gboolean show_stub)
{
@@ -5301,6 +5236,22 @@ gtk_ctree_set_line_style (GtkCTree *ctree,
}
}
+void
+gtk_ctree_set_expander_style (GtkCTree *ctree,
+ GtkCTreeExpanderStyle expander_style)
+{
+ g_return_if_fail (ctree != NULL);
+ g_return_if_fail (GTK_IS_CTREE (ctree));
+
+ if (expander_style != ctree->expander_style)
+ {
+ ctree->expander_style = expander_style;
+
+ if (!GTK_CLIST_FROZEN (ctree))
+ gtk_clist_thaw (GTK_CLIST (ctree));
+ }
+}
+
/***********************************************************
* Tree sorting functions *
diff --git a/gtk/gtkctree.h b/gtk/gtkctree.h
index f3cf56d64e..784b3400a1 100644
--- a/gtk/gtkctree.h
+++ b/gtk/gtkctree.h
@@ -51,14 +51,22 @@ typedef enum
typedef enum
{
+ GTK_CTREE_LINES_NONE,
GTK_CTREE_LINES_SOLID,
GTK_CTREE_LINES_DOTTED,
- GTK_CTREE_LINES_TABBED,
- GTK_CTREE_LINES_NONE
+ GTK_CTREE_LINES_TABBED
} GtkCTreeLineStyle;
typedef enum
{
+ GTK_CTREE_EXPANDER_NONE,
+ GTK_CTREE_EXPANDER_SQUARE,
+ GTK_CTREE_EXPANDER_TRIANGLE,
+ GTK_CTREE_EXPANDER_CIRCULAR
+} GtkCTreeExpanderStyle;
+
+typedef enum
+{
GTK_CTREE_EXPANSION_EXPAND,
GTK_CTREE_EXPANSION_EXPAND_RECURSIVE,
GTK_CTREE_EXPANSION_COLLAPSE,
@@ -97,18 +105,20 @@ struct _GtkCTree
gint icon_height;
gint tree_indent;
+ gint tree_spacing;
gint tree_column;
gint drag_row;
GtkCTreeNode *drag_source;
GtkCTreeNode *drag_target;
gint insert_pos;
- guint reorderable : 1;
- guint use_icons : 1;
- guint in_drag : 1;
- guint drag_rect : 1;
- guint line_style : 2;
- guint show_stub : 1;
+ guint reorderable : 1;
+ guint use_icons : 1;
+ guint in_drag : 1;
+ guint drag_rect : 1;
+ guint line_style : 2;
+ guint expander_style : 2;
+ guint show_stub : 1;
GtkCTreeCompareDragFunc drag_compare;
};
@@ -361,6 +371,18 @@ gint gtk_ctree_get_node_info (GtkCTree *ctree,
GdkBitmap **mask_opened,
gboolean *is_leaf,
gboolean *expanded);
+void gtk_ctree_node_set_row_style (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ GtkStyle *style);
+GtkStyle * gtk_ctree_node_get_row_style (GtkCTree *ctree,
+ GtkCTreeNode *node);
+void gtk_ctree_node_set_cell_style (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gint column,
+ GtkStyle *style);
+GtkStyle * gtk_ctree_node_get_cell_style (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gint column);
void gtk_ctree_node_set_foreground (GtkCTree *ctree,
GtkCTreeNode *node,
GdkColor *color);
@@ -388,18 +410,22 @@ GtkVisibility gtk_ctree_node_is_visible (GtkCTree *ctree,
* GtkCTree specific functions *
***********************************************************/
-void gtk_ctree_set_indent (GtkCTree *ctree,
- gint indent);
-void gtk_ctree_show_stub (GtkCTree *ctree,
- gboolean show_stub);
-void gtk_ctree_set_reorderable (GtkCTree *ctree,
- gboolean reorderable);
-void gtk_ctree_set_use_drag_icons (GtkCTree *ctree,
- gboolean use_icons);
-void gtk_ctree_set_line_style (GtkCTree *ctree,
- GtkCTreeLineStyle line_style);
-void gtk_ctree_set_drag_compare_func (GtkCTree *ctree,
- GtkCTreeCompareDragFunc cmp_func);
+void gtk_ctree_set_indent (GtkCTree *ctree,
+ gint indent);
+void gtk_ctree_set_spacing (GtkCTree *ctree,
+ gint spacing);
+void gtk_ctree_show_stub (GtkCTree *ctree,
+ gboolean show_stub);
+void gtk_ctree_set_reorderable (GtkCTree *ctree,
+ gboolean reorderable);
+void gtk_ctree_set_use_drag_icons (GtkCTree *ctree,
+ gboolean use_icons);
+void gtk_ctree_set_line_style (GtkCTree *ctree,
+ GtkCTreeLineStyle line_style);
+void gtk_ctree_set_expander_style (GtkCTree *ctree,
+ GtkCTreeExpanderStyle expander_style);
+void gtk_ctree_set_drag_compare_func (GtkCTree *ctree,
+ GtkCTreeCompareDragFunc cmp_func);
/***********************************************************
* Tree sorting functions *
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 49c592fa6d..914725b21f 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -3468,6 +3468,46 @@ static char * mini_page_xpm[] = {
" oooooooooo ",
" "};
+static char * gtk_mini_xpm[] = {
+"15 20 17 1",
+" c None",
+". c #14121F",
+"+ c #278828",
+"@ c #9B3334",
+"# c #284C72",
+"$ c #24692A",
+"% c #69282E",
+"& c #37C539",
+"* c #1D2F4D",
+"= c #6D7076",
+"- c #7D8482",
+"; c #E24A49",
+"> c #515357",
+", c #9B9C9B",
+"' c #2FA232",
+") c #3CE23D",
+"! c #3B6CCB",
+" ",
+" ***> ",
+" >.*!!!* ",
+" ***....#*= ",
+" *!*.!!!**!!# ",
+" .!!#*!#*!!!!# ",
+" @%#!.##.*!!$& ",
+" @;%*!*.#!#')) ",
+" @;;@%!!*$&)'' ",
+" @%.%@%$'&)$+' ",
+" @;...@$'*'*)+ ",
+" @;%..@$+*.')$ ",
+" @;%%;;$+..$)# ",
+" @;%%;@$$$'.$# ",
+" %;@@;;$$+))&* ",
+" %;;;@+$&)&* ",
+" %;;@'))+> ",
+" %;@'&# ",
+" >%$$ ",
+" >= "};
+
#define TESTGTK_CLIST_COLUMNS 20
static gint clist_rows = 0;
static GtkWidget *clist_omenu;
@@ -3480,11 +3520,14 @@ add1000_clist (GtkWidget *widget, gpointer data)
char *texts[TESTGTK_CLIST_COLUMNS];
GdkBitmap *mask;
GdkPixmap *pixmap;
-
- pixmap = gdk_pixmap_create_from_xpm_d (GTK_CLIST (data)->clist_window,
+ GtkCList *clist;
+
+ clist = GTK_CLIST (data);
+
+ pixmap = gdk_pixmap_create_from_xpm_d (clist->clist_window,
&mask,
&GTK_WIDGET (data)->style->white,
- mini_page_xpm);
+ gtk_mini_xpm);
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
{
@@ -3499,9 +3542,9 @@ add1000_clist (GtkWidget *widget, gpointer data)
gtk_clist_freeze (GTK_CLIST (data));
for (i = 0; i < 1000; i++)
{
- sprintf (text[0], "Row %d", rand() % 10000 /*clist_rows++*/);
- row = gtk_clist_append (GTK_CLIST (data), texts);
- gtk_clist_set_pixtext (GTK_CLIST (data), row, 3, "Hello World", 5, pixmap, mask);
+ sprintf (text[0], "Row %d", rand() % 10000);
+ row = gtk_clist_append (clist, texts);
+ gtk_clist_set_pixtext (clist, row, 3, "gtk+", 5, pixmap, mask);
}
gtk_clist_thaw (GTK_CLIST (data));
@@ -3692,10 +3735,48 @@ insert_row_clist (GtkWidget *widget, gpointer data)
"This", "is", "a", "inserted", "row."
};
+ static GtkStyle *style1 = NULL;
+ static GtkStyle *style2 = NULL;
+ static GtkStyle *style3 = NULL;
+ gint row;
+
if (GTK_CLIST (data)->focus_row >= 0)
- gtk_clist_insert (GTK_CLIST (data), GTK_CLIST (data)->focus_row, text);
+ row = gtk_clist_insert (GTK_CLIST (data), GTK_CLIST (data)->focus_row,
+ text);
else
- gtk_clist_insert (GTK_CLIST (data), 0, text);
+ row = gtk_clist_prepend (GTK_CLIST (data), text);
+
+ if (!style1)
+ {
+ GdkColor col1;
+ GdkColor col2;
+
+ col1.red = 0;
+ col1.green = 56000;
+ col1.blue = 0;
+ col2.red = 32000;
+ col2.green = 0;
+ col2.blue = 56000;
+
+ style1 = gtk_style_copy (GTK_WIDGET (data)->style);
+ style1->bg[GTK_STATE_PRELIGHT] = col1;
+ style1->bg[GTK_STATE_SELECTED] = col2;
+
+ style2 = gtk_style_copy (GTK_WIDGET (data)->style);
+ style2->fg[GTK_STATE_PRELIGHT] = col1;
+ style2->fg[GTK_STATE_SELECTED] = col2;
+
+ style3 = gtk_style_copy (GTK_WIDGET (data)->style);
+ style3->fg[GTK_STATE_PRELIGHT] = col1;
+ style3->bg[GTK_STATE_PRELIGHT] = col2;
+ gdk_font_unref (style3->font);
+ style3->font =
+ gdk_font_load ("-*-courier-medium-*-*-*-*-120-*-*-*-*-*-*");
+ }
+
+ gtk_clist_set_cell_style (GTK_CLIST (data), row, 3, style1);
+ gtk_clist_set_cell_style (GTK_CLIST (data), row, 4, style2);
+ gtk_clist_set_cell_style (GTK_CLIST (data), row, 0, style3);
clist_rows++;
}
@@ -3749,7 +3830,9 @@ clist_toggle_sel_mode (GtkWidget *widget, GtkCList *clist)
static void
clist_click_column (GtkCList *clist, gint column, gpointer data)
{
- if (column == clist->sort_column)
+ if (column == 5)
+ gtk_clist_set_column_visibility (clist, column, FALSE);
+ else if (column == clist->sort_column)
{
if (clist->sort_type == GTK_SORT_ASCENDING)
clist->sort_type = GTK_SORT_DESCENDING;
@@ -3770,10 +3853,11 @@ create_clist (void)
static char *titles[] =
{
- "Title 0", "Title 1", "Title 2", "Title 3", "Title 4",
- "Title 5", "Title 6", "Title 7", "Title 8", "Title 9",
- "Title 10", "Title 11", "Title 12", "Title 13", "Title 14",
- "Title 15", "Title 16", "Title 17", "Title 18", "Title 19"
+ "Title 0", "Title 1", "not resizeable", "max width 120",
+ "min width 40", "hide column", "Title 6", "Title 7",
+ "Title 8", "Title 9", "Title 10", "Title 11", "Title 12",
+ "Title 13", "Title 14", "Title 15", "Title 16", "Title 17",
+ "Title 18", "Title 19"
};
static OptionMenuItem items[] =
@@ -3796,14 +3880,17 @@ create_clist (void)
GtkWidget *undo_button;
GtkWidget *label;
+ GtkStyle *style;
+ GdkColor col1;
+ GdkColor col2;
+
if (!window)
{
clist_rows = 0;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed),
- &window);
+ GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
gtk_window_set_title (GTK_WINDOW (window), "clist");
gtk_container_border_width (GTK_CONTAINER (window), 0);
@@ -3821,41 +3908,32 @@ create_clist (void)
/*clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS);*/
gtk_signal_connect (GTK_OBJECT (clist), "click_column",
- (GtkSignalFunc) clist_click_column,
- NULL);
+ (GtkSignalFunc) clist_click_column, NULL);
/* control buttons */
button = gtk_button_new_with_label ("Add 1,000 Rows With Pixmaps");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) add1000_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) add1000_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Add 10,000 Rows");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) add10000_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) add10000_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Clear List");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) clear_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) clear_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Remove Row");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) remove_row_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) remove_row_clist, (gpointer) clist);
/* second layer of buttons */
box2 = gtk_hbox_new (FALSE, 10);
@@ -3865,34 +3943,26 @@ create_clist (void)
button = gtk_button_new_with_label ("Insert Row");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) insert_row_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) insert_row_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Show Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) show_titles_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) show_titles_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Hide Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) hide_titles_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) hide_titles_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Warning Test");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) clist_warning_test,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) clist_warning_test,(gpointer) clist);
box2 = gtk_hbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
@@ -3900,10 +3970,8 @@ create_clist (void)
undo_button = gtk_button_new_with_label ("Undo last selection");
gtk_box_pack_start (GTK_BOX (box2), undo_button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (undo_button),
- "clicked",
- (GtkSignalFunc) undo_selection,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (undo_button), "clicked",
+ (GtkSignalFunc) undo_selection, (gpointer) clist);
label = gtk_label_new ("Selection Mode :");
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0);
@@ -3940,6 +4008,10 @@ create_clist (void)
for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++)
gtk_clist_set_column_width (GTK_CLIST (clist), i, 80);
+ gtk_clist_set_column_resizeable (GTK_CLIST (clist), 2, FALSE);
+ gtk_clist_set_column_max_width (GTK_CLIST (clist), 3, 120);
+ gtk_clist_set_column_min_width (GTK_CLIST (clist), 4, 40);
+
gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_EXTENDED);
gtk_clist_set_policy (GTK_CLIST (clist), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -3958,10 +4030,35 @@ create_clist (void)
sprintf (text[1], "Right");
sprintf (text[2], "Center");
+ col1.red = 56000;
+ col1.green = 0;
+ col1.blue = 0;
+ col2.red = 0;
+ col2.green = 56000;
+ col2.blue = 32000;
+
+ style = gtk_style_new ();
+ style->fg[GTK_STATE_PRELIGHT] = col1;
+ style->bg[GTK_STATE_PRELIGHT] = col2;
+
+ gdk_font_unref (style->font);
+ style->font =
+ gdk_font_load ("-adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*");
+
for (i = 0; i < 10; i++)
{
sprintf (text[0], "Row %d", clist_rows++);
gtk_clist_append (GTK_CLIST (clist), texts);
+
+ switch (i % 4)
+ {
+ case 2:
+ gtk_clist_set_row_style (GTK_CLIST (clist), i, style);
+ break;
+ default:
+ gtk_clist_set_cell_style (GTK_CLIST (clist), i, i % 4, style);
+ break;
+ }
}
gtk_container_border_width (GTK_CONTAINER (clist), 5);
@@ -4014,10 +4111,11 @@ static GtkWidget *vis_label;
static GtkWidget *omenu1;
static GtkWidget *omenu2;
static GtkWidget *omenu3;
+static GtkWidget *omenu4;
static GtkWidget *spin1;
static GtkWidget *spin2;
static GtkWidget *spin3;
-static GdkColor *col_bg;
+static gint line_style;
void after_press (GtkCTree *ctree, gpointer data)
{
@@ -4150,6 +4248,55 @@ void select_all (GtkWidget *widget, GtkCTree *ctree)
after_press (ctree, NULL);
}
+void change_style (GtkWidget *widget, GtkCTree *ctree)
+{
+ static GtkStyle *style1 = NULL;
+ static GtkStyle *style2 = NULL;
+
+ GtkCTreeNode *node;
+ GdkColor col1;
+ GdkColor col2;
+
+ if (GTK_CLIST (ctree)->focus_row >= 0)
+ node = GTK_CTREE_NODE
+ (g_list_nth (GTK_CLIST (ctree)->row_list,GTK_CLIST (ctree)->focus_row));
+ else
+ node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
+
+ if (!node)
+ return;
+
+ if (!style1)
+ {
+ col1.red = 0;
+ col1.green = 56000;
+ col1.blue = 0;
+ col2.red = 32000;
+ col2.green = 0;
+ col2.blue = 56000;
+
+ style1 = gtk_style_new ();
+ style1->bg[GTK_STATE_PRELIGHT] = col1;
+ style1->fg[GTK_STATE_SELECTED] = col2;
+
+ style2 = gtk_style_new ();
+ style2->bg[GTK_STATE_SELECTED] = col2;
+ style2->fg[GTK_STATE_PRELIGHT] = col1;
+ style2->bg[GTK_STATE_PRELIGHT] = col2;
+ gdk_font_unref (style2->font);
+ style2->font =
+ gdk_font_load ("-*-courier-medium-*-*-*-*-300-*-*-*-*-*-*");
+ }
+
+ gtk_ctree_node_set_cell_style (ctree, node, 1, style1);
+ gtk_ctree_node_set_cell_style (ctree, node, 0, style2);
+
+ if (GTK_CTREE_ROW (node)->children)
+ gtk_ctree_node_set_row_style (ctree, GTK_CTREE_ROW (node)->children,
+ style2);
+
+}
+
void unselect_all (GtkWidget *widget, GtkCTree *ctree)
{
gtk_ctree_unselect_recursive (ctree, NULL);
@@ -4204,11 +4351,6 @@ void remove_selection (GtkWidget *widget, GtkCTree *ctree)
after_press (ctree, NULL);
}
-void sort_all (GtkWidget *widget, GtkCTree *ctree)
-{
- gtk_ctree_sort_recursive (ctree, NULL);
-}
-
struct _ExportStruct {
gchar *tree;
gchar *info;
@@ -4352,6 +4494,11 @@ void change_indent (GtkWidget *widget, GtkCTree *ctree)
gtk_ctree_set_indent (ctree, GTK_ADJUSTMENT (widget)->value);
}
+void change_spacing (GtkWidget *widget, GtkCTree *ctree)
+{
+ gtk_ctree_set_spacing (ctree, GTK_ADJUSTMENT (widget)->value);
+}
+
void change_row_height (GtkWidget *widget, GtkCList *clist)
{
gtk_clist_set_row_height (clist, GTK_ADJUSTMENT (widget)->value);
@@ -4364,24 +4511,20 @@ void toggle_reorderable (GtkWidget *widget, GtkCTree *ctree)
void set_background (GtkCTree *ctree, GtkCTreeNode *node, gpointer data)
{
+ GtkStyle *style = NULL;
+
if (!node)
return;
if (ctree->line_style != GTK_CTREE_LINES_TABBED)
{
- if (GTK_CTREE_ROW (node)->is_leaf)
- {
- if (GTK_CTREE_ROW (node)->parent)
- gtk_ctree_node_set_background
- (ctree, node,
- GTK_CTREE_ROW (GTK_CTREE_ROW (node)->parent)->row.data);
- }
- else
- gtk_ctree_node_set_background (ctree, node,
- GTK_CTREE_ROW (node)->row.data);
+ if (!GTK_CTREE_ROW (node)->is_leaf)
+ style = GTK_CTREE_ROW (node)->row.data;
+ else if (GTK_CTREE_ROW (node)->parent)
+ style = GTK_CTREE_ROW (GTK_CTREE_ROW (node)->parent)->row.data;
}
- else
- gtk_ctree_node_set_background (ctree, node, NULL);
+
+ gtk_ctree_node_set_row_style (ctree, node, style);
}
void ctree_toggle_line_style (GtkWidget *widget, GtkCTree *ctree)
@@ -4392,14 +4535,28 @@ void ctree_toggle_line_style (GtkWidget *widget, GtkCTree *ctree)
return;
RADIOMENUTOGGLED ((GtkRadioMenuItem *)
- (((GtkOptionMenu *)omenu1)->menu_item),i);
+ (((GtkOptionMenu *)omenu1)->menu_item), i);
if ((ctree->line_style == GTK_CTREE_LINES_TABBED &&
- ((GtkCTreeLineStyle) (3-i)) != GTK_CTREE_LINES_TABBED) ||
+ ((GtkCTreeLineStyle) (3 - i)) != GTK_CTREE_LINES_TABBED) ||
(ctree->line_style != GTK_CTREE_LINES_TABBED &&
- ((GtkCTreeLineStyle) (3-i)) == GTK_CTREE_LINES_TABBED))
+ ((GtkCTreeLineStyle) (3 - i)) == GTK_CTREE_LINES_TABBED))
gtk_ctree_pre_recursive (ctree, NULL, set_background, NULL);
- gtk_ctree_set_line_style (ctree, (GtkCTreeLineStyle) (3-i));
+ gtk_ctree_set_line_style (ctree, 3 - i);
+ line_style = 3 - i;
+}
+
+void ctree_toggle_expander_style (GtkWidget *widget, GtkCTree *ctree)
+{
+ gint i;
+
+ if (!GTK_WIDGET_MAPPED (widget))
+ return;
+
+ RADIOMENUTOGGLED ((GtkRadioMenuItem *)
+ (((GtkOptionMenu *)omenu2)->menu_item), i);
+
+ gtk_ctree_set_expander_style (ctree, (GtkCTreeExpanderStyle) (3 - i));
}
void ctree_toggle_justify (GtkWidget *widget, GtkCTree *ctree)
@@ -4410,10 +4567,10 @@ void ctree_toggle_justify (GtkWidget *widget, GtkCTree *ctree)
return;
RADIOMENUTOGGLED ((GtkRadioMenuItem *)
- (((GtkOptionMenu *)omenu2)->menu_item),i);
+ (((GtkOptionMenu *)omenu3)->menu_item), i);
gtk_clist_set_column_justification (GTK_CLIST (ctree), ctree->tree_column,
- (GtkJustification) (1-i));
+ (GtkJustification) (1 - i));
}
void ctree_toggle_sel_mode (GtkWidget *widget, GtkCTree *ctree)
@@ -4424,12 +4581,12 @@ void ctree_toggle_sel_mode (GtkWidget *widget, GtkCTree *ctree)
return;
RADIOMENUTOGGLED ((GtkRadioMenuItem *)
- (((GtkOptionMenu *)omenu3)->menu_item), i);
+ (((GtkOptionMenu *)omenu4)->menu_item), i);
- gtk_clist_set_selection_mode (GTK_CLIST (ctree), (GtkSelectionMode) (3-i));
+ gtk_clist_set_selection_mode (GTK_CLIST (ctree), (GtkSelectionMode) (3 - i));
after_press (ctree, NULL);
}
-
+
void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
gint num_books, gint num_pages, GtkCTreeNode *parent)
{
@@ -4452,8 +4609,9 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
pixmap3, mask3, NULL, NULL,
TRUE, FALSE);
- if (ctree->line_style == GTK_CTREE_LINES_TABBED)
- gtk_ctree_node_set_background (ctree, sibling, col_bg);
+ if (parent && ctree->line_style == GTK_CTREE_LINES_TABBED)
+ gtk_ctree_node_set_row_style (ctree, sibling,
+ GTK_CTREE_ROW (parent)->row.style);
}
if (cur_depth == depth)
@@ -4461,6 +4619,8 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
for (i = num_books; i > 0; i--)
{
+ GtkStyle *style;
+
books++;
sprintf (buf1, "Book %02d", (gint) rand() % 100);
sprintf (buf2, "Item %d-%d", cur_depth, i);
@@ -4468,32 +4628,30 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
pixmap1, mask1, pixmap2, mask2,
FALSE, FALSE);
- col_bg = g_new (GdkColor, 1);
-
- if (cur_depth % 3 == 0)
- {
- col_bg->red = 10000 * (cur_depth % 6);
- col_bg->green = 0;
- col_bg->blue = 65535 - ((i * 10000) % 65535);
- }
- else if (cur_depth % 3 == 1)
+ style = gtk_style_new();
+ switch (cur_depth % 3)
{
- col_bg->red = 10000 * (cur_depth % 6);
- col_bg->green = 65535 - ((i * 10000) % 65535);
- col_bg->blue = 0;
- }
- else
- {
- col_bg->red = 65535 - ((i * 10000) % 65535);
- col_bg->green = 0;
- col_bg->blue = 10000 * (cur_depth % 6);
+ case 0:
+ style->bg[GTK_STATE_PRELIGHT].red = 10000 * (cur_depth % 6);
+ style->bg[GTK_STATE_PRELIGHT].green = 0;
+ style->bg[GTK_STATE_PRELIGHT].blue = 65535 - ((i * 10000) % 65535);
+ break;
+ case 1:
+ style->bg[GTK_STATE_PRELIGHT].red = 10000 * (cur_depth % 6);
+ style->bg[GTK_STATE_PRELIGHT].green = 65535 - ((i * 10000) % 65535);
+ style->bg[GTK_STATE_PRELIGHT].blue = 0;
+ break;
+ default:
+ style->bg[GTK_STATE_PRELIGHT].red = 65535 - ((i * 10000) % 65535);
+ style->bg[GTK_STATE_PRELIGHT].green = 0;
+ style->bg[GTK_STATE_PRELIGHT].blue = 10000 * (cur_depth % 6);
+ break;
}
-
- gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (ctree)), col_bg);
- gtk_ctree_node_set_row_data_full (ctree, sibling, col_bg, g_free);
+ gtk_ctree_node_set_row_data_full (ctree, sibling, style,
+ (GtkDestroyNotify) gtk_style_unref);
if (ctree->line_style == GTK_CTREE_LINES_TABBED)
- gtk_ctree_node_set_background (ctree, sibling, col_bg);
+ gtk_ctree_node_set_row_style (ctree, sibling, style);
build_recursive (ctree, cur_depth + 1, depth, num_books, num_pages,
sibling);
@@ -4506,6 +4664,7 @@ void rebuild_tree (GtkWidget *widget, GtkCTree *ctree)
gchar label1[] = "Root";
gchar label2[] = "";
GtkCTreeNode *parent;
+ GtkStyle *style;
guint b, d, p, n;
text[0] = label1;
@@ -4532,14 +4691,15 @@ void rebuild_tree (GtkWidget *widget, GtkCTree *ctree)
parent = gtk_ctree_insert_node (ctree, NULL, NULL, text, 5, pixmap1,
mask1, pixmap2, mask2, FALSE, TRUE);
- col_bg = g_new (GdkColor, 1);
- col_bg->red = 0;
- col_bg->green = 45000;
- col_bg->blue = 55000;
- gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (ctree)), col_bg);
- gtk_ctree_node_set_row_data_full (ctree, parent, col_bg, g_free);
+ style = gtk_style_new ();
+ style->bg[GTK_STATE_PRELIGHT].red = 0;
+ style->bg[GTK_STATE_PRELIGHT].green = 45000;
+ style->bg[GTK_STATE_PRELIGHT].blue = 55000;
+ gtk_ctree_node_set_row_data_full (ctree, parent, style,
+ (GtkDestroyNotify) gtk_style_unref);
+
if (ctree->line_style == GTK_CTREE_LINES_TABBED)
- gtk_ctree_node_set_background (ctree, parent, col_bg);
+ gtk_ctree_node_set_row_style (ctree, parent, style);
build_recursive (ctree, 1, d, b, p, parent);
gtk_clist_thaw (GTK_CLIST (ctree));
@@ -4572,6 +4732,8 @@ void create_ctree (void)
GtkTooltips *tooltips;
GtkCTree *ctree;
GtkWidget *vbox;
+ GtkWidget *bbox;
+ GtkWidget *mbox;
GtkWidget *hbox;
GtkWidget *hbox2;
GtkWidget *frame;
@@ -4587,19 +4749,27 @@ void create_ctree (void)
static OptionMenuItem items1[] =
{
+ { "No lines", ctree_toggle_line_style },
{ "Solid", ctree_toggle_line_style },
{ "Dotted", ctree_toggle_line_style },
- { "Tabbed", ctree_toggle_line_style },
- { "No lines", ctree_toggle_line_style }
+ { "Tabbed", ctree_toggle_line_style }
};
static OptionMenuItem items2[] =
{
+ { "None", ctree_toggle_expander_style },
+ { "Square", ctree_toggle_expander_style },
+ { "Triangle", ctree_toggle_expander_style },
+ { "Circular", ctree_toggle_expander_style }
+ };
+
+ static OptionMenuItem items3[] =
+ {
{ "Left", ctree_toggle_justify },
{ "Right", ctree_toggle_justify }
};
- static OptionMenuItem items3[] =
+ static OptionMenuItem items4[] =
{
{ "Single", ctree_toggle_sel_mode },
{ "Browse", ctree_toggle_sel_mode },
@@ -4665,6 +4835,8 @@ void create_ctree (void)
ctree = GTK_CTREE (gtk_ctree_new_with_titles (2, 0, title));
gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
+ line_style = GTK_CTREE_LINES_DOTTED;
+
gtk_ctree_set_reorderable (ctree, TRUE);
gtk_signal_connect (GTK_OBJECT (ctree), "click_column",
(GtkSignalFunc) ctree_click_column,
@@ -4700,9 +4872,53 @@ void create_ctree (void)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (rebuild_tree), ctree);
+ bbox = gtk_hbox_new (FALSE, 5);
+ gtk_container_border_width (GTK_CONTAINER (bbox), 5);
+ gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, TRUE, 0);
+
+ mbox = gtk_vbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
+
+ label = gtk_label_new ("Row height :");
+ gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new ("Indent :");
+ gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new ("Spacing :");
+ gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
+
+ mbox = gtk_vbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (20, 12, 100, 1, 10, 0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_tooltips_set_tip (tooltips, spinner,
+ "Row height of list items", NULL);
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (change_row_height), ctree);
+ gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+ gtk_clist_set_row_height ( GTK_CLIST (ctree), adj->value);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (20, 0, 60, 1, 10, 0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_tooltips_set_tip (tooltips, spinner, "Tree indentation.", NULL);
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (change_indent), ctree);
+ gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (5, 0, 60, 1, 10, 0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_tooltips_set_tip (tooltips, spinner, "Tree spacing.", NULL);
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (change_spacing), ctree);
+ gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+
+ mbox = gtk_vbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
+
hbox = gtk_hbox_new (FALSE, 5);
- gtk_container_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Expand all");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
@@ -4714,9 +4930,9 @@ void create_ctree (void)
GTK_SIGNAL_FUNC (collapse_all), ctree);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- button = gtk_button_new_with_label ("Sort tree");
+ button = gtk_button_new_with_label ("Change Style");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (sort_all), ctree);
+ GTK_SIGNAL_FUNC (change_style), ctree);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
button = gtk_button_new_with_label ("Export tree");
@@ -4725,20 +4941,7 @@ void create_ctree (void)
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
hbox = gtk_hbox_new (FALSE, 5);
- gtk_container_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
- label = gtk_label_new ("Row height :");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-
- adj = (GtkAdjustment *) gtk_adjustment_new (20, 12, 100, 1, 10, 0);
- spinner = gtk_spin_button_new (adj, 0, 0);
- gtk_tooltips_set_tip (tooltips, spinner,
- "Row height of list items", NULL);
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- GTK_SIGNAL_FUNC (change_row_height), ctree);
- gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, TRUE, 5);
- gtk_clist_set_row_height ( GTK_CLIST (ctree), adj->value);
+ gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Select all");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
@@ -4755,23 +4958,6 @@ void create_ctree (void)
GTK_SIGNAL_FUNC (remove_selection), ctree);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- hbox = gtk_hbox_new (TRUE, 5);
- gtk_container_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
- hbox2 = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0);
-
- label = gtk_label_new ("Indent :");
- gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
-
- adj = (GtkAdjustment *) gtk_adjustment_new (20, 0, 60, 1, 10, 0);
- spinner = gtk_spin_button_new (adj, 0, 0);
- gtk_tooltips_set_tip (tooltips, spinner, "Tree indentation.", NULL);
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- GTK_SIGNAL_FUNC (change_indent), ctree);
- gtk_box_pack_start (GTK_BOX (hbox2), spinner, FALSE, TRUE, 5);
-
check = gtk_check_button_new_with_label ("Reorderable");
gtk_tooltips_set_tip (tooltips, check,
"Tree items can be reordered by dragging.", NULL);
@@ -4779,21 +4965,29 @@ void create_ctree (void)
GTK_SIGNAL_FUNC (toggle_reorderable), ctree);
gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (check), TRUE);
+
+ hbox = gtk_hbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
- omenu1 = build_option_menu (items1, 4, 1, ctree);
+ omenu1 = build_option_menu (items1, 4, 2, ctree);
gtk_tooltips_set_tip (tooltips, omenu1, "The tree's line style.", NULL);
gtk_box_pack_start (GTK_BOX (hbox), omenu1, FALSE, TRUE, 0);
- omenu2 = build_option_menu (items2, 2, 0, ctree);
- gtk_tooltips_set_tip (tooltips, omenu2, "The tree's justification.",
+ omenu2 = build_option_menu (items2, 4, 1, ctree);
+ gtk_tooltips_set_tip (tooltips, omenu2, "The tree's expander style.",
NULL);
gtk_box_pack_start (GTK_BOX (hbox), omenu2, FALSE, TRUE, 0);
-
- omenu3 = build_option_menu (items3, 4, 3, ctree);
- gtk_tooltips_set_tip (tooltips, omenu3, "The list's selection mode.",
+
+ omenu3 = build_option_menu (items3, 2, 0, ctree);
+ gtk_tooltips_set_tip (tooltips, omenu3, "The tree's justification.",
NULL);
gtk_box_pack_start (GTK_BOX (hbox), omenu3, FALSE, TRUE, 0);
+ omenu4 = build_option_menu (items4, 4, 3, ctree);
+ gtk_tooltips_set_tip (tooltips, omenu4, "The list's selection mode.",
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), omenu4, FALSE, TRUE, 0);
+
gtk_widget_realize (window);
pixmap1 = gdk_pixmap_create_from_xpm_d (window->window, &mask1,
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 49c592fa6d..914725b21f 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -3468,6 +3468,46 @@ static char * mini_page_xpm[] = {
" oooooooooo ",
" "};
+static char * gtk_mini_xpm[] = {
+"15 20 17 1",
+" c None",
+". c #14121F",
+"+ c #278828",
+"@ c #9B3334",
+"# c #284C72",
+"$ c #24692A",
+"% c #69282E",
+"& c #37C539",
+"* c #1D2F4D",
+"= c #6D7076",
+"- c #7D8482",
+"; c #E24A49",
+"> c #515357",
+", c #9B9C9B",
+"' c #2FA232",
+") c #3CE23D",
+"! c #3B6CCB",
+" ",
+" ***> ",
+" >.*!!!* ",
+" ***....#*= ",
+" *!*.!!!**!!# ",
+" .!!#*!#*!!!!# ",
+" @%#!.##.*!!$& ",
+" @;%*!*.#!#')) ",
+" @;;@%!!*$&)'' ",
+" @%.%@%$'&)$+' ",
+" @;...@$'*'*)+ ",
+" @;%..@$+*.')$ ",
+" @;%%;;$+..$)# ",
+" @;%%;@$$$'.$# ",
+" %;@@;;$$+))&* ",
+" %;;;@+$&)&* ",
+" %;;@'))+> ",
+" %;@'&# ",
+" >%$$ ",
+" >= "};
+
#define TESTGTK_CLIST_COLUMNS 20
static gint clist_rows = 0;
static GtkWidget *clist_omenu;
@@ -3480,11 +3520,14 @@ add1000_clist (GtkWidget *widget, gpointer data)
char *texts[TESTGTK_CLIST_COLUMNS];
GdkBitmap *mask;
GdkPixmap *pixmap;
-
- pixmap = gdk_pixmap_create_from_xpm_d (GTK_CLIST (data)->clist_window,
+ GtkCList *clist;
+
+ clist = GTK_CLIST (data);
+
+ pixmap = gdk_pixmap_create_from_xpm_d (clist->clist_window,
&mask,
&GTK_WIDGET (data)->style->white,
- mini_page_xpm);
+ gtk_mini_xpm);
for (i = 0; i < TESTGTK_CLIST_COLUMNS; i++)
{
@@ -3499,9 +3542,9 @@ add1000_clist (GtkWidget *widget, gpointer data)
gtk_clist_freeze (GTK_CLIST (data));
for (i = 0; i < 1000; i++)
{
- sprintf (text[0], "Row %d", rand() % 10000 /*clist_rows++*/);
- row = gtk_clist_append (GTK_CLIST (data), texts);
- gtk_clist_set_pixtext (GTK_CLIST (data), row, 3, "Hello World", 5, pixmap, mask);
+ sprintf (text[0], "Row %d", rand() % 10000);
+ row = gtk_clist_append (clist, texts);
+ gtk_clist_set_pixtext (clist, row, 3, "gtk+", 5, pixmap, mask);
}
gtk_clist_thaw (GTK_CLIST (data));
@@ -3692,10 +3735,48 @@ insert_row_clist (GtkWidget *widget, gpointer data)
"This", "is", "a", "inserted", "row."
};
+ static GtkStyle *style1 = NULL;
+ static GtkStyle *style2 = NULL;
+ static GtkStyle *style3 = NULL;
+ gint row;
+
if (GTK_CLIST (data)->focus_row >= 0)
- gtk_clist_insert (GTK_CLIST (data), GTK_CLIST (data)->focus_row, text);
+ row = gtk_clist_insert (GTK_CLIST (data), GTK_CLIST (data)->focus_row,
+ text);
else
- gtk_clist_insert (GTK_CLIST (data), 0, text);
+ row = gtk_clist_prepend (GTK_CLIST (data), text);
+
+ if (!style1)
+ {
+ GdkColor col1;
+ GdkColor col2;
+
+ col1.red = 0;
+ col1.green = 56000;
+ col1.blue = 0;
+ col2.red = 32000;
+ col2.green = 0;
+ col2.blue = 56000;
+
+ style1 = gtk_style_copy (GTK_WIDGET (data)->style);
+ style1->bg[GTK_STATE_PRELIGHT] = col1;
+ style1->bg[GTK_STATE_SELECTED] = col2;
+
+ style2 = gtk_style_copy (GTK_WIDGET (data)->style);
+ style2->fg[GTK_STATE_PRELIGHT] = col1;
+ style2->fg[GTK_STATE_SELECTED] = col2;
+
+ style3 = gtk_style_copy (GTK_WIDGET (data)->style);
+ style3->fg[GTK_STATE_PRELIGHT] = col1;
+ style3->bg[GTK_STATE_PRELIGHT] = col2;
+ gdk_font_unref (style3->font);
+ style3->font =
+ gdk_font_load ("-*-courier-medium-*-*-*-*-120-*-*-*-*-*-*");
+ }
+
+ gtk_clist_set_cell_style (GTK_CLIST (data), row, 3, style1);
+ gtk_clist_set_cell_style (GTK_CLIST (data), row, 4, style2);
+ gtk_clist_set_cell_style (GTK_CLIST (data), row, 0, style3);
clist_rows++;
}
@@ -3749,7 +3830,9 @@ clist_toggle_sel_mode (GtkWidget *widget, GtkCList *clist)
static void
clist_click_column (GtkCList *clist, gint column, gpointer data)
{
- if (column == clist->sort_column)
+ if (column == 5)
+ gtk_clist_set_column_visibility (clist, column, FALSE);
+ else if (column == clist->sort_column)
{
if (clist->sort_type == GTK_SORT_ASCENDING)
clist->sort_type = GTK_SORT_DESCENDING;
@@ -3770,10 +3853,11 @@ create_clist (void)
static char *titles[] =
{
- "Title 0", "Title 1", "Title 2", "Title 3", "Title 4",
- "Title 5", "Title 6", "Title 7", "Title 8", "Title 9",
- "Title 10", "Title 11", "Title 12", "Title 13", "Title 14",
- "Title 15", "Title 16", "Title 17", "Title 18", "Title 19"
+ "Title 0", "Title 1", "not resizeable", "max width 120",
+ "min width 40", "hide column", "Title 6", "Title 7",
+ "Title 8", "Title 9", "Title 10", "Title 11", "Title 12",
+ "Title 13", "Title 14", "Title 15", "Title 16", "Title 17",
+ "Title 18", "Title 19"
};
static OptionMenuItem items[] =
@@ -3796,14 +3880,17 @@ create_clist (void)
GtkWidget *undo_button;
GtkWidget *label;
+ GtkStyle *style;
+ GdkColor col1;
+ GdkColor col2;
+
if (!window)
{
clist_rows = 0;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
- GTK_SIGNAL_FUNC(gtk_widget_destroyed),
- &window);
+ GTK_SIGNAL_FUNC (gtk_widget_destroyed), &window);
gtk_window_set_title (GTK_WINDOW (window), "clist");
gtk_container_border_width (GTK_CONTAINER (window), 0);
@@ -3821,41 +3908,32 @@ create_clist (void)
/*clist = gtk_clist_new (TESTGTK_CLIST_COLUMNS);*/
gtk_signal_connect (GTK_OBJECT (clist), "click_column",
- (GtkSignalFunc) clist_click_column,
- NULL);
+ (GtkSignalFunc) clist_click_column, NULL);
/* control buttons */
button = gtk_button_new_with_label ("Add 1,000 Rows With Pixmaps");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) add1000_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) add1000_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Add 10,000 Rows");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) add10000_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) add10000_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Clear List");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) clear_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) clear_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Remove Row");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) remove_row_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) remove_row_clist, (gpointer) clist);
/* second layer of buttons */
box2 = gtk_hbox_new (FALSE, 10);
@@ -3865,34 +3943,26 @@ create_clist (void)
button = gtk_button_new_with_label ("Insert Row");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) insert_row_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) insert_row_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Show Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) show_titles_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) show_titles_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Hide Title Buttons");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) hide_titles_clist,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) hide_titles_clist, (gpointer) clist);
button = gtk_button_new_with_label ("Warning Test");
gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (button),
- "clicked",
- (GtkSignalFunc) clist_warning_test,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ (GtkSignalFunc) clist_warning_test,(gpointer) clist);
box2 = gtk_hbox_new (FALSE, 10);
gtk_container_border_width (GTK_CONTAINER (box2), 10);
@@ -3900,10 +3970,8 @@ create_clist (void)
undo_button = gtk_button_new_with_label ("Undo last selection");
gtk_box_pack_start (GTK_BOX (box2), undo_button, TRUE, TRUE, 0);
- gtk_signal_connect (GTK_OBJECT (undo_button),
- "clicked",
- (GtkSignalFunc) undo_selection,
- (gpointer) clist);
+ gtk_signal_connect (GTK_OBJECT (undo_button), "clicked",
+ (GtkSignalFunc) undo_selection, (gpointer) clist);
label = gtk_label_new ("Selection Mode :");
gtk_box_pack_start (GTK_BOX (box2), label, FALSE, TRUE, 0);
@@ -3940,6 +4008,10 @@ create_clist (void)
for (i = 1; i < TESTGTK_CLIST_COLUMNS; i++)
gtk_clist_set_column_width (GTK_CLIST (clist), i, 80);
+ gtk_clist_set_column_resizeable (GTK_CLIST (clist), 2, FALSE);
+ gtk_clist_set_column_max_width (GTK_CLIST (clist), 3, 120);
+ gtk_clist_set_column_min_width (GTK_CLIST (clist), 4, 40);
+
gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_EXTENDED);
gtk_clist_set_policy (GTK_CLIST (clist), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -3958,10 +4030,35 @@ create_clist (void)
sprintf (text[1], "Right");
sprintf (text[2], "Center");
+ col1.red = 56000;
+ col1.green = 0;
+ col1.blue = 0;
+ col2.red = 0;
+ col2.green = 56000;
+ col2.blue = 32000;
+
+ style = gtk_style_new ();
+ style->fg[GTK_STATE_PRELIGHT] = col1;
+ style->bg[GTK_STATE_PRELIGHT] = col2;
+
+ gdk_font_unref (style->font);
+ style->font =
+ gdk_font_load ("-adobe-helvetica-bold-r-*-*-*-140-*-*-*-*-*-*");
+
for (i = 0; i < 10; i++)
{
sprintf (text[0], "Row %d", clist_rows++);
gtk_clist_append (GTK_CLIST (clist), texts);
+
+ switch (i % 4)
+ {
+ case 2:
+ gtk_clist_set_row_style (GTK_CLIST (clist), i, style);
+ break;
+ default:
+ gtk_clist_set_cell_style (GTK_CLIST (clist), i, i % 4, style);
+ break;
+ }
}
gtk_container_border_width (GTK_CONTAINER (clist), 5);
@@ -4014,10 +4111,11 @@ static GtkWidget *vis_label;
static GtkWidget *omenu1;
static GtkWidget *omenu2;
static GtkWidget *omenu3;
+static GtkWidget *omenu4;
static GtkWidget *spin1;
static GtkWidget *spin2;
static GtkWidget *spin3;
-static GdkColor *col_bg;
+static gint line_style;
void after_press (GtkCTree *ctree, gpointer data)
{
@@ -4150,6 +4248,55 @@ void select_all (GtkWidget *widget, GtkCTree *ctree)
after_press (ctree, NULL);
}
+void change_style (GtkWidget *widget, GtkCTree *ctree)
+{
+ static GtkStyle *style1 = NULL;
+ static GtkStyle *style2 = NULL;
+
+ GtkCTreeNode *node;
+ GdkColor col1;
+ GdkColor col2;
+
+ if (GTK_CLIST (ctree)->focus_row >= 0)
+ node = GTK_CTREE_NODE
+ (g_list_nth (GTK_CLIST (ctree)->row_list,GTK_CLIST (ctree)->focus_row));
+ else
+ node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
+
+ if (!node)
+ return;
+
+ if (!style1)
+ {
+ col1.red = 0;
+ col1.green = 56000;
+ col1.blue = 0;
+ col2.red = 32000;
+ col2.green = 0;
+ col2.blue = 56000;
+
+ style1 = gtk_style_new ();
+ style1->bg[GTK_STATE_PRELIGHT] = col1;
+ style1->fg[GTK_STATE_SELECTED] = col2;
+
+ style2 = gtk_style_new ();
+ style2->bg[GTK_STATE_SELECTED] = col2;
+ style2->fg[GTK_STATE_PRELIGHT] = col1;
+ style2->bg[GTK_STATE_PRELIGHT] = col2;
+ gdk_font_unref (style2->font);
+ style2->font =
+ gdk_font_load ("-*-courier-medium-*-*-*-*-300-*-*-*-*-*-*");
+ }
+
+ gtk_ctree_node_set_cell_style (ctree, node, 1, style1);
+ gtk_ctree_node_set_cell_style (ctree, node, 0, style2);
+
+ if (GTK_CTREE_ROW (node)->children)
+ gtk_ctree_node_set_row_style (ctree, GTK_CTREE_ROW (node)->children,
+ style2);
+
+}
+
void unselect_all (GtkWidget *widget, GtkCTree *ctree)
{
gtk_ctree_unselect_recursive (ctree, NULL);
@@ -4204,11 +4351,6 @@ void remove_selection (GtkWidget *widget, GtkCTree *ctree)
after_press (ctree, NULL);
}
-void sort_all (GtkWidget *widget, GtkCTree *ctree)
-{
- gtk_ctree_sort_recursive (ctree, NULL);
-}
-
struct _ExportStruct {
gchar *tree;
gchar *info;
@@ -4352,6 +4494,11 @@ void change_indent (GtkWidget *widget, GtkCTree *ctree)
gtk_ctree_set_indent (ctree, GTK_ADJUSTMENT (widget)->value);
}
+void change_spacing (GtkWidget *widget, GtkCTree *ctree)
+{
+ gtk_ctree_set_spacing (ctree, GTK_ADJUSTMENT (widget)->value);
+}
+
void change_row_height (GtkWidget *widget, GtkCList *clist)
{
gtk_clist_set_row_height (clist, GTK_ADJUSTMENT (widget)->value);
@@ -4364,24 +4511,20 @@ void toggle_reorderable (GtkWidget *widget, GtkCTree *ctree)
void set_background (GtkCTree *ctree, GtkCTreeNode *node, gpointer data)
{
+ GtkStyle *style = NULL;
+
if (!node)
return;
if (ctree->line_style != GTK_CTREE_LINES_TABBED)
{
- if (GTK_CTREE_ROW (node)->is_leaf)
- {
- if (GTK_CTREE_ROW (node)->parent)
- gtk_ctree_node_set_background
- (ctree, node,
- GTK_CTREE_ROW (GTK_CTREE_ROW (node)->parent)->row.data);
- }
- else
- gtk_ctree_node_set_background (ctree, node,
- GTK_CTREE_ROW (node)->row.data);
+ if (!GTK_CTREE_ROW (node)->is_leaf)
+ style = GTK_CTREE_ROW (node)->row.data;
+ else if (GTK_CTREE_ROW (node)->parent)
+ style = GTK_CTREE_ROW (GTK_CTREE_ROW (node)->parent)->row.data;
}
- else
- gtk_ctree_node_set_background (ctree, node, NULL);
+
+ gtk_ctree_node_set_row_style (ctree, node, style);
}
void ctree_toggle_line_style (GtkWidget *widget, GtkCTree *ctree)
@@ -4392,14 +4535,28 @@ void ctree_toggle_line_style (GtkWidget *widget, GtkCTree *ctree)
return;
RADIOMENUTOGGLED ((GtkRadioMenuItem *)
- (((GtkOptionMenu *)omenu1)->menu_item),i);
+ (((GtkOptionMenu *)omenu1)->menu_item), i);
if ((ctree->line_style == GTK_CTREE_LINES_TABBED &&
- ((GtkCTreeLineStyle) (3-i)) != GTK_CTREE_LINES_TABBED) ||
+ ((GtkCTreeLineStyle) (3 - i)) != GTK_CTREE_LINES_TABBED) ||
(ctree->line_style != GTK_CTREE_LINES_TABBED &&
- ((GtkCTreeLineStyle) (3-i)) == GTK_CTREE_LINES_TABBED))
+ ((GtkCTreeLineStyle) (3 - i)) == GTK_CTREE_LINES_TABBED))
gtk_ctree_pre_recursive (ctree, NULL, set_background, NULL);
- gtk_ctree_set_line_style (ctree, (GtkCTreeLineStyle) (3-i));
+ gtk_ctree_set_line_style (ctree, 3 - i);
+ line_style = 3 - i;
+}
+
+void ctree_toggle_expander_style (GtkWidget *widget, GtkCTree *ctree)
+{
+ gint i;
+
+ if (!GTK_WIDGET_MAPPED (widget))
+ return;
+
+ RADIOMENUTOGGLED ((GtkRadioMenuItem *)
+ (((GtkOptionMenu *)omenu2)->menu_item), i);
+
+ gtk_ctree_set_expander_style (ctree, (GtkCTreeExpanderStyle) (3 - i));
}
void ctree_toggle_justify (GtkWidget *widget, GtkCTree *ctree)
@@ -4410,10 +4567,10 @@ void ctree_toggle_justify (GtkWidget *widget, GtkCTree *ctree)
return;
RADIOMENUTOGGLED ((GtkRadioMenuItem *)
- (((GtkOptionMenu *)omenu2)->menu_item),i);
+ (((GtkOptionMenu *)omenu3)->menu_item), i);
gtk_clist_set_column_justification (GTK_CLIST (ctree), ctree->tree_column,
- (GtkJustification) (1-i));
+ (GtkJustification) (1 - i));
}
void ctree_toggle_sel_mode (GtkWidget *widget, GtkCTree *ctree)
@@ -4424,12 +4581,12 @@ void ctree_toggle_sel_mode (GtkWidget *widget, GtkCTree *ctree)
return;
RADIOMENUTOGGLED ((GtkRadioMenuItem *)
- (((GtkOptionMenu *)omenu3)->menu_item), i);
+ (((GtkOptionMenu *)omenu4)->menu_item), i);
- gtk_clist_set_selection_mode (GTK_CLIST (ctree), (GtkSelectionMode) (3-i));
+ gtk_clist_set_selection_mode (GTK_CLIST (ctree), (GtkSelectionMode) (3 - i));
after_press (ctree, NULL);
}
-
+
void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
gint num_books, gint num_pages, GtkCTreeNode *parent)
{
@@ -4452,8 +4609,9 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
pixmap3, mask3, NULL, NULL,
TRUE, FALSE);
- if (ctree->line_style == GTK_CTREE_LINES_TABBED)
- gtk_ctree_node_set_background (ctree, sibling, col_bg);
+ if (parent && ctree->line_style == GTK_CTREE_LINES_TABBED)
+ gtk_ctree_node_set_row_style (ctree, sibling,
+ GTK_CTREE_ROW (parent)->row.style);
}
if (cur_depth == depth)
@@ -4461,6 +4619,8 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
for (i = num_books; i > 0; i--)
{
+ GtkStyle *style;
+
books++;
sprintf (buf1, "Book %02d", (gint) rand() % 100);
sprintf (buf2, "Item %d-%d", cur_depth, i);
@@ -4468,32 +4628,30 @@ void build_recursive (GtkCTree *ctree, gint cur_depth, gint depth,
pixmap1, mask1, pixmap2, mask2,
FALSE, FALSE);
- col_bg = g_new (GdkColor, 1);
-
- if (cur_depth % 3 == 0)
- {
- col_bg->red = 10000 * (cur_depth % 6);
- col_bg->green = 0;
- col_bg->blue = 65535 - ((i * 10000) % 65535);
- }
- else if (cur_depth % 3 == 1)
+ style = gtk_style_new();
+ switch (cur_depth % 3)
{
- col_bg->red = 10000 * (cur_depth % 6);
- col_bg->green = 65535 - ((i * 10000) % 65535);
- col_bg->blue = 0;
- }
- else
- {
- col_bg->red = 65535 - ((i * 10000) % 65535);
- col_bg->green = 0;
- col_bg->blue = 10000 * (cur_depth % 6);
+ case 0:
+ style->bg[GTK_STATE_PRELIGHT].red = 10000 * (cur_depth % 6);
+ style->bg[GTK_STATE_PRELIGHT].green = 0;
+ style->bg[GTK_STATE_PRELIGHT].blue = 65535 - ((i * 10000) % 65535);
+ break;
+ case 1:
+ style->bg[GTK_STATE_PRELIGHT].red = 10000 * (cur_depth % 6);
+ style->bg[GTK_STATE_PRELIGHT].green = 65535 - ((i * 10000) % 65535);
+ style->bg[GTK_STATE_PRELIGHT].blue = 0;
+ break;
+ default:
+ style->bg[GTK_STATE_PRELIGHT].red = 65535 - ((i * 10000) % 65535);
+ style->bg[GTK_STATE_PRELIGHT].green = 0;
+ style->bg[GTK_STATE_PRELIGHT].blue = 10000 * (cur_depth % 6);
+ break;
}
-
- gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (ctree)), col_bg);
- gtk_ctree_node_set_row_data_full (ctree, sibling, col_bg, g_free);
+ gtk_ctree_node_set_row_data_full (ctree, sibling, style,
+ (GtkDestroyNotify) gtk_style_unref);
if (ctree->line_style == GTK_CTREE_LINES_TABBED)
- gtk_ctree_node_set_background (ctree, sibling, col_bg);
+ gtk_ctree_node_set_row_style (ctree, sibling, style);
build_recursive (ctree, cur_depth + 1, depth, num_books, num_pages,
sibling);
@@ -4506,6 +4664,7 @@ void rebuild_tree (GtkWidget *widget, GtkCTree *ctree)
gchar label1[] = "Root";
gchar label2[] = "";
GtkCTreeNode *parent;
+ GtkStyle *style;
guint b, d, p, n;
text[0] = label1;
@@ -4532,14 +4691,15 @@ void rebuild_tree (GtkWidget *widget, GtkCTree *ctree)
parent = gtk_ctree_insert_node (ctree, NULL, NULL, text, 5, pixmap1,
mask1, pixmap2, mask2, FALSE, TRUE);
- col_bg = g_new (GdkColor, 1);
- col_bg->red = 0;
- col_bg->green = 45000;
- col_bg->blue = 55000;
- gdk_color_alloc (gtk_widget_get_colormap (GTK_WIDGET (ctree)), col_bg);
- gtk_ctree_node_set_row_data_full (ctree, parent, col_bg, g_free);
+ style = gtk_style_new ();
+ style->bg[GTK_STATE_PRELIGHT].red = 0;
+ style->bg[GTK_STATE_PRELIGHT].green = 45000;
+ style->bg[GTK_STATE_PRELIGHT].blue = 55000;
+ gtk_ctree_node_set_row_data_full (ctree, parent, style,
+ (GtkDestroyNotify) gtk_style_unref);
+
if (ctree->line_style == GTK_CTREE_LINES_TABBED)
- gtk_ctree_node_set_background (ctree, parent, col_bg);
+ gtk_ctree_node_set_row_style (ctree, parent, style);
build_recursive (ctree, 1, d, b, p, parent);
gtk_clist_thaw (GTK_CLIST (ctree));
@@ -4572,6 +4732,8 @@ void create_ctree (void)
GtkTooltips *tooltips;
GtkCTree *ctree;
GtkWidget *vbox;
+ GtkWidget *bbox;
+ GtkWidget *mbox;
GtkWidget *hbox;
GtkWidget *hbox2;
GtkWidget *frame;
@@ -4587,19 +4749,27 @@ void create_ctree (void)
static OptionMenuItem items1[] =
{
+ { "No lines", ctree_toggle_line_style },
{ "Solid", ctree_toggle_line_style },
{ "Dotted", ctree_toggle_line_style },
- { "Tabbed", ctree_toggle_line_style },
- { "No lines", ctree_toggle_line_style }
+ { "Tabbed", ctree_toggle_line_style }
};
static OptionMenuItem items2[] =
{
+ { "None", ctree_toggle_expander_style },
+ { "Square", ctree_toggle_expander_style },
+ { "Triangle", ctree_toggle_expander_style },
+ { "Circular", ctree_toggle_expander_style }
+ };
+
+ static OptionMenuItem items3[] =
+ {
{ "Left", ctree_toggle_justify },
{ "Right", ctree_toggle_justify }
};
- static OptionMenuItem items3[] =
+ static OptionMenuItem items4[] =
{
{ "Single", ctree_toggle_sel_mode },
{ "Browse", ctree_toggle_sel_mode },
@@ -4665,6 +4835,8 @@ void create_ctree (void)
ctree = GTK_CTREE (gtk_ctree_new_with_titles (2, 0, title));
gtk_ctree_set_line_style (ctree, GTK_CTREE_LINES_DOTTED);
+ line_style = GTK_CTREE_LINES_DOTTED;
+
gtk_ctree_set_reorderable (ctree, TRUE);
gtk_signal_connect (GTK_OBJECT (ctree), "click_column",
(GtkSignalFunc) ctree_click_column,
@@ -4700,9 +4872,53 @@ void create_ctree (void)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (rebuild_tree), ctree);
+ bbox = gtk_hbox_new (FALSE, 5);
+ gtk_container_border_width (GTK_CONTAINER (bbox), 5);
+ gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, TRUE, 0);
+
+ mbox = gtk_vbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
+
+ label = gtk_label_new ("Row height :");
+ gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new ("Indent :");
+ gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new ("Spacing :");
+ gtk_box_pack_start (GTK_BOX (mbox), label, FALSE, FALSE, 0);
+
+ mbox = gtk_vbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (20, 12, 100, 1, 10, 0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_tooltips_set_tip (tooltips, spinner,
+ "Row height of list items", NULL);
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (change_row_height), ctree);
+ gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+ gtk_clist_set_row_height ( GTK_CLIST (ctree), adj->value);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (20, 0, 60, 1, 10, 0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_tooltips_set_tip (tooltips, spinner, "Tree indentation.", NULL);
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (change_indent), ctree);
+ gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+
+ adj = (GtkAdjustment *) gtk_adjustment_new (5, 0, 60, 1, 10, 0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_tooltips_set_tip (tooltips, spinner, "Tree spacing.", NULL);
+ gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
+ GTK_SIGNAL_FUNC (change_spacing), ctree);
+ gtk_box_pack_start (GTK_BOX (mbox), spinner, FALSE, FALSE, 5);
+
+ mbox = gtk_vbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (bbox), mbox, FALSE, TRUE, 0);
+
hbox = gtk_hbox_new (FALSE, 5);
- gtk_container_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Expand all");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
@@ -4714,9 +4930,9 @@ void create_ctree (void)
GTK_SIGNAL_FUNC (collapse_all), ctree);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- button = gtk_button_new_with_label ("Sort tree");
+ button = gtk_button_new_with_label ("Change Style");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (sort_all), ctree);
+ GTK_SIGNAL_FUNC (change_style), ctree);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
button = gtk_button_new_with_label ("Export tree");
@@ -4725,20 +4941,7 @@ void create_ctree (void)
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
hbox = gtk_hbox_new (FALSE, 5);
- gtk_container_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
- label = gtk_label_new ("Row height :");
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-
- adj = (GtkAdjustment *) gtk_adjustment_new (20, 12, 100, 1, 10, 0);
- spinner = gtk_spin_button_new (adj, 0, 0);
- gtk_tooltips_set_tip (tooltips, spinner,
- "Row height of list items", NULL);
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- GTK_SIGNAL_FUNC (change_row_height), ctree);
- gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, TRUE, 5);
- gtk_clist_set_row_height ( GTK_CLIST (ctree), adj->value);
+ gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Select all");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
@@ -4755,23 +4958,6 @@ void create_ctree (void)
GTK_SIGNAL_FUNC (remove_selection), ctree);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- hbox = gtk_hbox_new (TRUE, 5);
- gtk_container_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
-
- hbox2 = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0);
-
- label = gtk_label_new ("Indent :");
- gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
-
- adj = (GtkAdjustment *) gtk_adjustment_new (20, 0, 60, 1, 10, 0);
- spinner = gtk_spin_button_new (adj, 0, 0);
- gtk_tooltips_set_tip (tooltips, spinner, "Tree indentation.", NULL);
- gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
- GTK_SIGNAL_FUNC (change_indent), ctree);
- gtk_box_pack_start (GTK_BOX (hbox2), spinner, FALSE, TRUE, 5);
-
check = gtk_check_button_new_with_label ("Reorderable");
gtk_tooltips_set_tip (tooltips, check,
"Tree items can be reordered by dragging.", NULL);
@@ -4779,21 +4965,29 @@ void create_ctree (void)
GTK_SIGNAL_FUNC (toggle_reorderable), ctree);
gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, TRUE, 0);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (check), TRUE);
+
+ hbox = gtk_hbox_new (TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (mbox), hbox, FALSE, FALSE, 0);
- omenu1 = build_option_menu (items1, 4, 1, ctree);
+ omenu1 = build_option_menu (items1, 4, 2, ctree);
gtk_tooltips_set_tip (tooltips, omenu1, "The tree's line style.", NULL);
gtk_box_pack_start (GTK_BOX (hbox), omenu1, FALSE, TRUE, 0);
- omenu2 = build_option_menu (items2, 2, 0, ctree);
- gtk_tooltips_set_tip (tooltips, omenu2, "The tree's justification.",
+ omenu2 = build_option_menu (items2, 4, 1, ctree);
+ gtk_tooltips_set_tip (tooltips, omenu2, "The tree's expander style.",
NULL);
gtk_box_pack_start (GTK_BOX (hbox), omenu2, FALSE, TRUE, 0);
-
- omenu3 = build_option_menu (items3, 4, 3, ctree);
- gtk_tooltips_set_tip (tooltips, omenu3, "The list's selection mode.",
+
+ omenu3 = build_option_menu (items3, 2, 0, ctree);
+ gtk_tooltips_set_tip (tooltips, omenu3, "The tree's justification.",
NULL);
gtk_box_pack_start (GTK_BOX (hbox), omenu3, FALSE, TRUE, 0);
+ omenu4 = build_option_menu (items4, 4, 3, ctree);
+ gtk_tooltips_set_tip (tooltips, omenu4, "The list's selection mode.",
+ NULL);
+ gtk_box_pack_start (GTK_BOX (hbox), omenu4, FALSE, TRUE, 0);
+
gtk_widget_realize (window);
pixmap1 = gdk_pixmap_create_from_xpm_d (window->window, &mask1,