summaryrefslogtreecommitdiff
path: root/gtk/gtkctree.c
diff options
context:
space:
mode:
authorLars Hamann <lars@gtk.org>1998-10-07 00:03:24 +0000
committerLars Hamann <lars@src.gnome.org>1998-10-07 00:03:24 +0000
commita2951281f36c08cd32df5bfa7e197c5b9f54fb40 (patch)
treee8add75cb72ce3dbd6e80061359e4efd59675808 /gtk/gtkctree.c
parentc3a163b021a672f92c182a6e20b246441d34bd92 (diff)
downloadgtk+-a2951281f36c08cd32df5bfa7e197c5b9f54fb40.tar.gz
new signal GtkCList::resize_column. don't draw invisible columns
Wed Oct 7 00:59:46 1998 Lars Hamann <lars@gtk.org> * gtk/gtkclist.h: new signal GtkCList::resize_column. * gtk/gtkclist.c (draw_row): don't draw invisible columns (size_allocate_title_buttons) (size_allocate_columns): skip invisible columns (new_column_width): take min/max_width into account (gtk_clist_button_release) (gtk_clist_motion): changes due to changed new_column_width function (LIST_WIDTH): changed define to inline function. (real_resize_column): class function for resize_column signal (gtk_clist_motion): fixed autoscrolling for column resizes (gtk_clist_set_column_visibility): don't hide last visible column, changed visible arg to gboolean (gtk_clist_set_column_min_width)(gtk_clist_set_column_max_width): new functions : set min/max width of a column (gtk_clist_set_column_resizeable): new function : enable/disable column resize operations by mouse * gtk/gtkctree.c (draw_row): don't draw invisible columns (ctree_is_hot_spot): return FALSE if tree_column is invisible (draw_xor_line) (draw_xor_rect): draw full rectangle/line if tree_column is invisible (gtk_ctree_find_all_by_row_data) (gtk_ctree_find_all_by_row_data_custom): new function from Ronan Bourlier <ronan@radioss.com>. Returns a GList of all GtkCTreeNodes with row->data == data.
Diffstat (limited to 'gtk/gtkctree.c')
-rw-r--r--gtk/gtkctree.c285
1 files changed, 186 insertions, 99 deletions
diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c
index 5e666b389c..b7448ecf55 100644
--- a/gtk/gtkctree.c
+++ b/gtk/gtkctree.c
@@ -969,37 +969,41 @@ draw_xor_line (GtkCTree *ctree)
else
y = ROW_TOP_YPIXEL (clist, ctree->drag_row) - 1;
- switch (clist->column[ctree->tree_column].justification)
- {
- case GTK_JUSTIFY_CENTER:
- case GTK_JUSTIFY_FILL:
- case GTK_JUSTIFY_LEFT:
- if (ctree->tree_column > 0)
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- COLUMN_LEFT_XPIXEL(clist, 0), y,
- COLUMN_LEFT_XPIXEL(clist, ctree->tree_column - 1) +
- clist->column[ctree->tree_column - 1].area.width, y);
+ if (clist->column[ctree->tree_column].visible)
+ switch (clist->column[ctree->tree_column].justification)
+ {
+ case GTK_JUSTIFY_CENTER:
+ case GTK_JUSTIFY_FILL:
+ case GTK_JUSTIFY_LEFT:
+ if (ctree->tree_column > 0)
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ COLUMN_LEFT_XPIXEL(clist, 0), y,
+ COLUMN_LEFT_XPIXEL(clist, ctree->tree_column - 1) +
+ clist->column[ctree->tree_column - 1].area.width, y);
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) +
- ctree->tree_indent * level -
- (ctree->tree_indent - PM_SIZE) / 2, y,
- GTK_WIDGET (ctree)->allocation.width, y);
- break;
- case GTK_JUSTIFY_RIGHT:
- if (ctree->tree_column < clist->columns - 1)
gdk_draw_line (clist->clist_window, ctree->xor_gc,
- COLUMN_LEFT_XPIXEL(clist, ctree->tree_column + 1), y,
- COLUMN_LEFT_XPIXEL(clist, clist->columns - 1) +
- clist->column[clist->columns - 1].area.width, y);
+ COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) +
+ ctree->tree_indent * level -
+ (ctree->tree_indent - PM_SIZE) / 2, y,
+ GTK_WIDGET (ctree)->allocation.width, y);
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ if (ctree->tree_column < clist->columns - 1)
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ COLUMN_LEFT_XPIXEL(clist, ctree->tree_column + 1), y,
+ COLUMN_LEFT_XPIXEL(clist, clist->columns - 1) +
+ clist->column[clist->columns - 1].area.width, y);
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- 0, y, COLUMN_LEFT_XPIXEL(clist, ctree->tree_column)
- + clist->column[ctree->tree_column].area.width
- - ctree->tree_indent * level +
- (ctree->tree_indent - PM_SIZE) / 2, y);
- break;
- }
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ 0, y, COLUMN_LEFT_XPIXEL(clist, ctree->tree_column)
+ + clist->column[ctree->tree_column].area.width -
+ ctree->tree_indent * level +
+ (ctree->tree_indent - PM_SIZE) / 2, y);
+ break;
+ }
+ else
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ 0, y, clist->clist_window_width, y);
}
static void
@@ -1017,77 +1021,84 @@ draw_xor_rect (GtkCTree *ctree)
y = ROW_TOP_YPIXEL (clist, ctree->drag_row) + clist->row_height;
- switch (clist->column[ctree->tree_column].justification)
- {
- case GTK_JUSTIFY_CENTER:
- case GTK_JUSTIFY_FILL:
- case GTK_JUSTIFY_LEFT:
- points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) +
- ctree->tree_indent * level - (ctree->tree_indent - PM_SIZE) / 2;
- points[0].y = y;
- points[3].x = points[0].x;
- points[3].y = y - clist->row_height - 1;
- points[1].x = clist->clist_window_width - 1;
- points[1].y = points[0].y;
- points[2].x = points[1].x;
- points[2].y = points[3].y;
-
- for (i = 0; i < 3; i++)
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- points[i].x, points[i].y, points[i+1].x, points[i+1].y);
-
- if (ctree->tree_column > 0)
- {
- points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column - 1) +
- clist->column[ctree->tree_column - 1].area.width ;
- points[0].y = y;
- points[3].x = points[0].x;
- points[3].y = y - clist->row_height - 1;
- points[1].x = 0;
- points[1].y = points[0].y;
- points[2].x = 0;
- points[2].y = points[3].y;
-
- for (i = 0; i < 3; i++)
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- points[i].x, points[i].y, points[i+1].x,
- points[i+1].y);
- }
- break;
- case GTK_JUSTIFY_RIGHT:
- points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) -
- ctree->tree_indent * level + (ctree->tree_indent - PM_SIZE) / 2 +
- clist->column[ctree->tree_column].area.width;
- points[0].y = y;
- points[3].x = points[0].x;
- points[3].y = y - clist->row_height - 1;
- points[1].x = 0;
- points[1].y = points[0].y;
- points[2].x = 0;
- points[2].y = points[3].y;
-
- for (i = 0; i < 3; i++)
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- points[i].x, points[i].y, points[i+1].x, points[i+1].y);
-
- if (ctree->tree_column < clist->columns - 1)
- {
- points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column + 1);
- points[0].y = y;
- points[3].x = points[0].x;
- points[3].y = y - clist->row_height - 1;
- points[1].x = clist->clist_window_width - 1;
- points[1].y = points[0].y;
- points[2].x = points[1].x;
- points[2].y = points[3].y;
-
- for (i = 0; i < 3; i++)
- gdk_draw_line (clist->clist_window, ctree->xor_gc,
- points[i].x, points[i].y, points[i+1].x,
- points[i+1].y);
- }
- break;
- }
+ if (clist->column[ctree->tree_column].visible)
+ switch (clist->column[ctree->tree_column].justification)
+ {
+ case GTK_JUSTIFY_CENTER:
+ case GTK_JUSTIFY_FILL:
+ case GTK_JUSTIFY_LEFT:
+ points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) +
+ ctree->tree_indent * level - (ctree->tree_indent - PM_SIZE) / 2;
+ points[0].y = y;
+ points[3].x = points[0].x;
+ points[3].y = y - clist->row_height - 1;
+ points[1].x = clist->clist_window_width - 1;
+ points[1].y = points[0].y;
+ points[2].x = points[1].x;
+ points[2].y = points[3].y;
+
+ for (i = 0; i < 3; i++)
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ points[i].x, points[i].y,
+ points[i+1].x, points[i+1].y);
+
+ if (ctree->tree_column > 0)
+ {
+ points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column - 1) +
+ clist->column[ctree->tree_column - 1].area.width ;
+ points[0].y = y;
+ points[3].x = points[0].x;
+ points[3].y = y - clist->row_height - 1;
+ points[1].x = 0;
+ points[1].y = points[0].y;
+ points[2].x = 0;
+ points[2].y = points[3].y;
+
+ for (i = 0; i < 3; i++)
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ points[i].x, points[i].y, points[i+1].x,
+ points[i+1].y);
+ }
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column) -
+ ctree->tree_indent * level + (ctree->tree_indent - PM_SIZE) / 2 +
+ clist->column[ctree->tree_column].area.width;
+ points[0].y = y;
+ points[3].x = points[0].x;
+ points[3].y = y - clist->row_height - 1;
+ points[1].x = 0;
+ points[1].y = points[0].y;
+ points[2].x = 0;
+ points[2].y = points[3].y;
+
+ for (i = 0; i < 3; i++)
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ points[i].x, points[i].y,
+ points[i+1].x, points[i+1].y);
+
+ if (ctree->tree_column < clist->columns - 1)
+ {
+ points[0].x = COLUMN_LEFT_XPIXEL(clist, ctree->tree_column + 1);
+ points[0].y = y;
+ points[3].x = points[0].x;
+ points[3].y = y - clist->row_height - 1;
+ points[1].x = clist->clist_window_width - 1;
+ points[1].y = points[0].y;
+ points[2].x = points[1].x;
+ points[2].y = points[3].y;
+
+ for (i = 0; i < 3; i++)
+ gdk_draw_line (clist->clist_window, ctree->xor_gc,
+ points[i].x, points[i].y,
+ points[i+1].x, points[i+1].y);
+ }
+ break;
+ }
+ else
+ gdk_draw_rectangle (clist->clist_window, ctree->xor_gc, FALSE,
+ 0, y - clist->row_height,
+ clist->clist_window_width - 1, clist->row_height);
}
static void
@@ -1266,6 +1277,8 @@ draw_row (GtkCList *clist,
/* iterate and draw all the columns (row cells) and draw their contents */
for (i = 0; i < clist->columns; i++)
{
+ if (!clist->column[i].visible)
+ continue;
if (!need_redraw && ctree->tree_column != i)
continue;
@@ -3678,6 +3691,9 @@ ctree_is_hot_spot (GtkCTree *ctree,
tree_row = GTK_CTREE_ROW (node);
clist = GTK_CLIST (ctree);
+ if (!clist->column[ctree->tree_column].visible)
+ return FALSE;
+
cell = GTK_CELL_PIXTEXT(tree_row->row.cell[ctree->tree_column]);
yu = ROW_TOP_YPIXEL (clist, row) + (clist->row_height - PM_SIZE) / 2;
@@ -4321,6 +4337,40 @@ gtk_ctree_find_by_row_data (GtkCTree *ctree,
return NULL;
}
+GList *
+gtk_ctree_find_all_by_row_data (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gpointer data)
+{
+ GList *list = NULL;
+
+ g_return_val_if_fail (ctree != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
+
+ /* if node == NULL then look in the whole tree */
+ if (!node)
+ node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
+
+ while (node)
+ {
+ if (GTK_CTREE_ROW (node)->row.data == data)
+ list = g_list_append (list, node);
+
+ if (GTK_CTREE_ROW (node)->children)
+ {
+ GList *sub_list;
+
+ sub_list = gtk_ctree_find_all_by_row_data (ctree,
+ GTK_CTREE_ROW
+ (node)->children,
+ data);
+ list = g_list_concat (list, sub_list);
+ }
+ node = GTK_CTREE_ROW (node)->sibling;
+ }
+ return list;
+}
+
GtkCTreeNode *
gtk_ctree_find_by_row_data_custom (GtkCTree *ctree,
GtkCTreeNode *node,
@@ -4347,6 +4397,43 @@ gtk_ctree_find_by_row_data_custom (GtkCTree *ctree,
return NULL;
}
+GList *
+gtk_ctree_find_all_by_row_data_custom (GtkCTree *ctree,
+ GtkCTreeNode *node,
+ gpointer data,
+ GCompareFunc func)
+{
+ GList *list = NULL;
+
+ g_return_val_if_fail (ctree != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_CTREE (ctree), NULL);
+ g_return_val_if_fail (func != NULL, NULL);
+
+ /* if node == NULL then look in the whole tree */
+ if (!node)
+ node = GTK_CTREE_NODE (GTK_CLIST (ctree)->row_list);
+
+ while (node)
+ {
+ if (!func (GTK_CTREE_ROW (node)->row.data, data))
+ list = g_list_append (list, node);
+
+ if (GTK_CTREE_ROW (node)->children)
+ {
+ GList *sub_list;
+
+ sub_list = gtk_ctree_find_all_by_row_data_custom (ctree,
+ GTK_CTREE_ROW
+ (node)->children,
+ data,
+ func);
+ list = g_list_concat (list, sub_list);
+ }
+ node = GTK_CTREE_ROW (node)->sibling;
+ }
+ return list;
+}
+
gboolean
gtk_ctree_is_hot_spot (GtkCTree *ctree,
gint x,