aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table/e-cell-tree.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-06-11 12:20:56 +0800
committerChris Toshok <toshok@src.gnome.org>2000-06-11 12:20:56 +0800
commitaac3f2c8b69f579e04314b21a13d752afe4bd317 (patch)
treedec49e04bac8721e060f07003aa90bcb76d30479 /widgets/e-table/e-cell-tree.c
parent835ec00d01e23256143229d8e2c99f68afae1e6c (diff)
downloadgsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.tar
gsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.tar.gz
gsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.tar.bz2
gsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.tar.lz
gsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.tar.xz
gsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.tar.zst
gsoc2013-evolution-aac3f2c8b69f579e04314b21a13d752afe4bd317.zip
change things so we focus the cell and select the row, and also dispatch
2000-06-10 Chris Toshok <toshok@helixcode.com> * e-table-item.c (eti_event): change things so we focus the cell and select the row, and also dispatch the event to that row/cell. This fixes the problem with the tree where you had to click twice to activate the tree controls. * Makefile.am (libetable_a_SOURCES): remove e-tree-gnode.* and add e-tree-simple.* (icons): add tree-expanded.xpm and tree-unexpanded.xpm * e-cell-tree.c (ect_enter_edit): defer to subcell's view. (ect_leave_edit): defer to subcell's view. (visible_depth_of_node): visual depth, taking into account that the root node of the model might not be displayed. (offset_of_node): return the offset used to shift the subcell over. (ect_draw): don't draw vertical lines if we're the leftmode node (a visual root node). also, don't shift x2 by the subcell offset, so we get ellipses like we're supposed to. (ect_event): remove GDK_BUTTON_RELEASE from the list of events that we care about. * e-tree-example-1.c: lots of changes, a more dynamic UI so we can test tree model api stuff. * e-tree-gnode.c, e-tree-gnode.c: removed files, since their guts have been rolled into e-tree-model.c * e-tree-model.c, e-tree-model.h: substantially changed. too much to really describe here. this should really be considered the first revision of these files :) * e-tree-simple.c, e-tree-simple.h: analogous to e-table-simple, a subclass that allows the use of function pointers. svn path=/trunk/; revision=3519
Diffstat (limited to 'widgets/e-table/e-cell-tree.c')
-rw-r--r--widgets/e-table/e-cell-tree.c57
1 files changed, 41 insertions, 16 deletions
diff --git a/widgets/e-table/e-cell-tree.c b/widgets/e-table/e-cell-tree.c
index 9f40bd0eae..c3459ce4f8 100644
--- a/widgets/e-table/e-cell-tree.c
+++ b/widgets/e-table/e-cell-tree.c
@@ -49,6 +49,21 @@ static ECellClass *parent_class;
static GdkPixbuf *tree_expanded_pixbuf, *tree_unexpanded_pixbuf;
+#define INDENT_AMOUNT 16
+
+static int
+visible_depth_of_node (ETreeModel *tree_model, ETreePath *path)
+{
+ return (e_tree_model_node_depth (tree_model, path)
+ - (e_tree_model_root_node_is_visible (tree_model) ? 0 : 1));
+}
+
+static gint
+offset_of_node (ETreeModel *tree_model, ETreePath *path)
+{
+ return (visible_depth_of_node(tree_model, path) + 1) * INDENT_AMOUNT;
+}
+
static ETreePath*
e_cell_tree_get_node (ETreeModel *tree_model, int row)
{
@@ -136,7 +151,6 @@ ect_unrealize (ECellView *ecv)
(* parent_class->unrealize) (ecv);
}
-#define INDENT_AMOUNT 16
/*
* ECell::draw method
*/
@@ -167,7 +181,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
*/
node = e_cell_tree_get_node (tree_model, row);
- offset = (e_tree_model_node_depth (tree_model, node) + 1) * INDENT_AMOUNT;
+ offset = offset_of_node (tree_model, node);
expandable = e_tree_model_node_is_expandable (tree_model, node);
expanded = e_tree_model_node_is_expanded (tree_model, node);
subcell_offset = offset;
@@ -196,15 +210,8 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
rect.x, rect.y, rect.width, rect.height);
gdk_gc_set_foreground (tree_view->gc, foreground);
+ /* draw our lines */
if (E_CELL_TREE(tree_view->cell_view.ecell)->draw_lines) {
- /* draw our lines */
- gdk_draw_line (drawable, tree_view->gc,
- rect.x + offset - INDENT_AMOUNT / 2,
- rect.y,
- rect.x + offset - INDENT_AMOUNT / 2,
- (e_tree_model_node_get_next (tree_model, node)
- ? rect.y + rect.height
- : rect.y + rect.height / 2));
gdk_draw_line (drawable, tree_view->gc,
rect.x + offset - INDENT_AMOUNT / 2 + 1,
@@ -212,12 +219,22 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
rect.x + offset,
rect.y + rect.height / 2);
+ if (visible_depth_of_node (tree_model, node) != 0) {
+ gdk_draw_line (drawable, tree_view->gc,
+ rect.x + offset - INDENT_AMOUNT / 2,
+ rect.y,
+ rect.x + offset - INDENT_AMOUNT / 2,
+ (e_tree_model_node_get_next (tree_model, node)
+ ? rect.y + rect.height
+ : rect.y + rect.height / 2));
+ }
+
/* now traverse back up to the root of the tree, checking at
each level if the node has siblings, and drawing the
correct vertical pipe for it's configuration. */
node = e_tree_model_node_get_parent (tree_model, node);
offset -= INDENT_AMOUNT;
- while (node && ! e_tree_model_node_is_root (tree_model, node)) {
+ while (node && visible_depth_of_node (tree_model, node) != 0) {
if (e_tree_model_node_get_next(tree_model, node)) {
gdk_draw_line (drawable, tree_view->gc,
rect.x + offset - INDENT_AMOUNT / 2,
@@ -255,7 +272,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
subcell_offset pixels */
e_cell_draw (tree_view->subcell_view, drawable,
model_col, view_col, row, selected,
- x1 + subcell_offset, y1, x2 + subcell_offset, y2);
+ x1 + subcell_offset, y1, x2, y2);
}
/*
@@ -267,13 +284,12 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
switch (event->type) {
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE: {
+ case GDK_BUTTON_PRESS: {
/* if the event happened in our area of control (and
we care about it), handle it. */
ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row);
ETreePath *node = e_cell_tree_get_node (tree_model, row);
- int offset = (e_tree_model_node_depth (tree_model, node) + 1) * INDENT_AMOUNT;
+ int offset = offset_of_node (tree_model, node);
/* only activate the tree control if the click/release happens in the icon's area. */
if (event->button.x > (offset - INDENT_AMOUNT) && event->button.x < offset) {
@@ -284,6 +300,8 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
}
return TRUE;
}
+ else if (event->button.x < (offset - INDENT_AMOUNT))
+ return TRUE;
}
default:
/* otherwise, pass it off to our subcell_view */
@@ -309,7 +327,10 @@ ect_height (ECellView *ecell_view, int model_col, int view_col, int row)
static void *
ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
{
- return NULL;
+ /* just defer to our subcell's view */
+ ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
+
+ return e_cell_enter_edit (tree_view->subcell_view, model_col, view_col, row);
}
/*
@@ -318,6 +339,10 @@ ect_enter_edit (ECellView *ecell_view, int model_col, int view_col, int row)
static void
ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, void *edit_context)
{
+ /* just defer to our subcell's view */
+ ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
+
+ e_cell_leave_edit (tree_view->subcell_view, model_col, view_col, row, edit_context);
}
/*