[gnumeric] Improve printing of spin buttons



commit 05b8199d16fc2d583bc99614c427fc94727e7eb5
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Sep 29 11:33:06 2010 -0600

    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

 ChangeLog                 |    5 ++++
 src/sheet-object-widget.c |   56 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2c115cf..4da52f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 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
 	  all callers
 	(sheet_widget_frame_draw_cairo): new
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 1a6008f..1b7cedc 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -1828,10 +1828,66 @@ sheet_widget_spinbutton_user_config (SheetObject *so, SheetControl *sc)
 }
 
 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;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]