Commit 05b8199d authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Improve printing of spin buttons

2010-09-29  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* src/sheet-object-widget.c (sheet_widget_spinbutton_draw_cairo): new
	(sheet_widget_spinbutton_class_init): connect the above
parent 0a5d4ab8
2010-09-29 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object-widget.c (sheet_widget_spinbutton_draw_cairo): new
(sheet_widget_spinbutton_class_init): connect the above
2010-09-29 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object-widget.c (draw_cairo_text): add aguments and change
......
......@@ -1827,11 +1827,67 @@ sheet_widget_spinbutton_user_config (SheetObject *so, SheetControl *sc)
N_("Spinbutton Properties"));
}
static void
sheet_widget_spinbutton_draw_cairo (SheetObject const *so, cairo_t *cr,
double width, double height)
{
SheetWidgetAdjustment *swa = SHEET_WIDGET_ADJUSTMENT (so);
GtkAdjustment *adjustment = swa->adjustment;
double value = gtk_adjustment_get_value (adjustment);
int ivalue = (int) value;
double halfheight = height/2;
char *str;
cairo_save (cr);
cairo_set_line_width (cr, 0.5);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_new_path (cr);
cairo_move_to (cr, 0, 0);
cairo_line_to (cr, width, 0);
cairo_line_to (cr, width, height);
cairo_line_to (cr, 0, height);
cairo_close_path (cr);
cairo_stroke (cr);
cairo_new_path (cr);
cairo_move_to (cr, width - 10, 0);
cairo_rel_line_to (cr, 0, height);
cairo_stroke (cr);
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
cairo_new_path (cr);
cairo_move_to (cr, width - 5, 3);
cairo_rel_line_to (cr, 3, 3);
cairo_rel_line_to (cr, -6, 0);
cairo_close_path (cr);
cairo_fill (cr);
cairo_new_path (cr);
cairo_move_to (cr, width - 5, height - 3);
cairo_rel_line_to (cr, 3, -3);
cairo_rel_line_to (cr, -6, 0);
cairo_close_path (cr);
cairo_fill (cr);
str = g_strdup_printf ("%i", ivalue);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_move_to (cr, 4., halfheight);
draw_cairo_text (cr, str, NULL, NULL, TRUE);
g_free (str);
cairo_new_path (cr);
cairo_restore (cr);
}
static void
sheet_widget_spinbutton_class_init (SheetObjectWidgetClass *sow_class)
{
SheetWidgetAdjustmentClass *swa_class = (SheetWidgetAdjustmentClass *)sow_class;
SheetObjectClass *so_class = SHEET_OBJECT_CLASS (sow_class);
so_class->draw_cairo = &sheet_widget_spinbutton_draw_cairo;
sow_class->create_widget = &sheet_widget_spinbutton_create_widget;
SHEET_OBJECT_CLASS (sow_class)->user_config = &sheet_widget_spinbutton_user_config;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment