diff options
author | Chris Toshok <toshok@helixcode.com> | 2000-06-14 15:07:38 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-06-14 15:07:38 +0800 |
commit | 5ae693645f49b1beb1b21adfc1e50c06aa130278 (patch) | |
tree | 5df64ae7148c1bdc2dce0f5ef5c1ff09e1044750 /widgets/e-table/e-cell-tree.c | |
parent | fabd9d91ab1aee4a091ddcdd6e189bacfcd4a920 (diff) | |
download | gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.tar gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.tar.gz gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.tar.bz2 gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.tar.lz gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.tar.xz gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.tar.zst gsoc2013-evolution-5ae693645f49b1beb1b21adfc1e50c06aa130278.zip |
new function, to generate postscript so i can test tree printing.
2000-06-14 Chris Toshok <toshok@helixcode.com>
* e-tree-example-1.c (print_tree): new function, to generate
postscript so i can test tree printing.
(create_tree): add print button.
* e-cell-tree.c (ect_print_height): implement function (in a
broken way for the time being, heh).
(ect_print): implement function to draw tree controls and offset
the subcell's printing. icons aren't printed yet, just lines.
(ect_draw): remove old unnecessary comments. only draw the
horizontal line in specific instances (well, add a test so a lone
root node doesn't get the horizontal line.)
(e_cell_tree_class_init): add print/print_height methods.
svn path=/trunk/; revision=3565
Diffstat (limited to 'widgets/e-table/e-cell-tree.c')
-rw-r--r-- | widgets/e-table/e-cell-tree.c | 117 |
1 files changed, 105 insertions, 12 deletions
diff --git a/widgets/e-table/e-cell-tree.c b/widgets/e-table/e-cell-tree.c index 28de6ff5bb..508d39e60f 100644 --- a/widgets/e-table/e-cell-tree.c +++ b/widgets/e-table/e-cell-tree.c @@ -167,13 +167,6 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, /* only draw the tree effects if we're the active sort */ if (/* XXX */ TRUE) { - /* - * need to get the following things from the model - * 1. depth of item. - * 2. whether or not it has any children. - * 3. whether the item is a toplevel item. - * 3. ... anything else? - */ node = e_cell_tree_get_node (tree_model, row); offset = offset_of_node (tree_model, node); @@ -208,11 +201,13 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, /* draw our lines */ if (E_CELL_TREE(tree_view->cell_view.ecell)->draw_lines) { - gdk_draw_line (drawable, tree_view->gc, - rect.x + offset - INDENT_AMOUNT / 2 + 1, - rect.y + rect.height / 2, - rect.x + offset, - rect.y + rect.height / 2); + if (!e_tree_model_node_is_root (tree_model, node) + || e_tree_model_node_get_children (tree_model, node, NULL) > 0) + gdk_draw_line (drawable, tree_view->gc, + rect.x + offset - INDENT_AMOUNT / 2 + 1, + rect.y + rect.height / 2, + rect.x + offset, + rect.y + rect.height / 2); if (visible_depth_of_node (tree_model, node) != 0) { gdk_draw_line (drawable, tree_view->gc, @@ -355,6 +350,102 @@ ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, voi e_cell_leave_edit (tree_view->subcell_view, model_col, view_col, row, edit_context); } +static void +ect_print (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width, double height) +{ + ECellTreeView *tree_view = (ECellTreeView *) ecell_view; + + if (/* XXX only if we're the active sort */ TRUE) { + 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 = offset_of_node (tree_model, node); + int subcell_offset = offset; + + /* draw our lines */ + if (E_CELL_TREE(tree_view->cell_view.ecell)->draw_lines) { + gnome_print_moveto (context, + offset - INDENT_AMOUNT / 2, + height / 2); + + gnome_print_lineto (context, + offset, + height / 2); + + if (visible_depth_of_node (tree_model, node) != 0) { + gnome_print_moveto (context, + offset - INDENT_AMOUNT / 2, + height); + gnome_print_lineto (context, + offset - INDENT_AMOUNT / 2, + (e_tree_model_node_get_next (tree_model, node) + ? 0 + : 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 && visible_depth_of_node (tree_model, node) != 0) { + if (e_tree_model_node_get_next(tree_model, node)) { + gnome_print_moveto (context, + offset - INDENT_AMOUNT / 2, + height); + gnome_print_lineto (context, + offset - INDENT_AMOUNT / 2, + 0); + } + node = e_tree_model_node_get_parent (tree_model, node); + offset -= INDENT_AMOUNT; + } + } + +#if 0 + /* now draw our icon if we're expandable */ + if (expandable) { + GdkPixbuf *image = (expanded + ? E_CELL_TREE(tree_view->cell_view.ecell)->open_pixbuf + : E_CELL_TREE(tree_view->cell_view.ecell)->closed_pixbuf); + int width, height; + + width = gdk_pixbuf_get_width(image); + height = gdk_pixbuf_get_height(image); + + gdk_pixbuf_render_to_drawable_alpha (image, + drawable, + 0, 0, + x1 + subcell_offset - INDENT_AMOUNT / 2 - width / 2, + y1 + (y2 - y1) / 2 - height / 2, + width, height, + GDK_PIXBUF_ALPHA_BILEVEL, + 128, + GDK_RGB_DITHER_NORMAL, + width, 0); + } +#endif + + gnome_print_stroke (context); + + if (gnome_print_translate(context, subcell_offset, 0) == -1) + /* FIXME */; + width -= subcell_offset; + } + + + e_cell_print (tree_view->subcell_view, context, model_col, view_col, row, width, height); +} + +static gdouble +ect_print_height (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width) +{ + return 12; /* XXX */ +} + /* * GtkObject::destroy method */ @@ -385,6 +476,8 @@ e_cell_tree_class_init (GtkObjectClass *object_class) ecc->height = ect_height; ecc->enter_edit = ect_enter_edit; ecc->leave_edit = ect_leave_edit; + ecc->print = ect_print; + ecc->print_height = ect_print_height; parent_class = gtk_type_class (PARENT_TYPE); } |