From c1f065e586d586c25c669e67d6b57b50804e243a Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Fri, 19 Apr 2002 20:22:24 +0000 Subject: print the cell in the allotted area (etog_print_height): return the print 2002-04-19 JP Rosevear * e-cell-toggle.c (etog_print): print the cell in the allotted area (etog_print_height): return the print height svn path=/trunk/; revision=16536 --- widgets/table/e-cell-toggle.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/widgets/table/e-cell-toggle.c b/widgets/table/e-cell-toggle.c index 0961b077ba..af451c6b73 100644 --- a/widgets/table/e-cell-toggle.c +++ b/widgets/table/e-cell-toggle.c @@ -300,6 +300,61 @@ etog_height (ECellView *ecell_view, int model_col, int view_col, int row) return toggle->height; } +/* + * ECell::print method + */ +static void +etog_print (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width, double height) +{ + ECellToggle *toggle = E_CELL_TOGGLE(ecell_view->ecell); + GdkPixbuf *image; + int scale; + const int value = GPOINTER_TO_INT ( + e_table_model_value_at (ecell_view->e_table_model, model_col, row)); + + if (value >= toggle->n_states){ + g_warning ("Value from the table model is %d, the states we support are [0..%d)\n", + value, toggle->n_states); + return; + } + + gnome_print_gsave(context); + + if (gnome_print_moveto(context, 2, 2) == -1) + /* FIXME */; + if (gnome_print_lineto(context, width - 2, 2) == -1) + /* FIXME */; + if (gnome_print_lineto(context, width - 2, height - 2) == -1) + /* FIXME */; + if (gnome_print_lineto(context, 2, height - 2) == -1) + /* FIXME */; + if (gnome_print_lineto(context, 2, 2) == -1) + /* FIXME */; + if (gnome_print_clip(context) == -1) + /* FIXME */; + + image = toggle->images[value]; + scale = MIN (width - 4, height - 4); + + gnome_print_translate (context, 2, (height - scale) / 2); + gnome_print_scale (context, scale, scale); + gnome_print_pixbuf (context, image); + + gnome_print_grestore(context); +} + +static gdouble +etog_print_height (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width) +{ + ECellToggle *toggle = E_CELL_TOGGLE (ecell_view->ecell); + + return toggle->height; +} + /* * ECell::max_width method */ @@ -367,6 +422,8 @@ e_cell_toggle_class_init (GtkObjectClass *object_class) ecc->draw = etog_draw; ecc->event = etog_event; ecc->height = etog_height; + ecc->print = etog_print; + ecc->print_height = etog_print_height; ecc->max_width = etog_max_width; ecc->style_set = etog_style_set; -- cgit v1.2.3