[gnumeric] Scale tiny buttons when printing. [Part of #705689]



commit 1e8219241e8d9e8b5eafa3791be8bf369c3070c7
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sat Aug 10 22:16:06 2013 -0600

    Scale tiny buttons when printing. [Part of #705689]
    
    2013-08-10  Andreas J. Guelzow <aguelzow pyrshep ca>
    
        * src/sheet-object-widget.c (draw_cairo_text): add 'scale'
        argument and change all callers

 ChangeLog                 |    7 ++++++-
 NEWS                      |    1 +
 src/sheet-object-widget.c |   29 +++++++++++++++++++++--------
 3 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d64b65a..38a1435 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
+2013-08-10  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+       * src/sheet-object-widget.c (draw_cairo_text): add 'scale'
+       argument and change all callers
+
 2013-08-09  Andreas J. Guelzow <aguelzow pyrshep ca>
 
-       * src/sheet-object-widget.c (get_font): add a fall-backs
+       * src/sheet-object-widget.c (get_font): add fall-backs
 
 2013-08-09  Andreas J. Guelzow <aguelzow pyrshep ca>
 
diff --git a/NEWS b/NEWS
index fda2b32..3ad2ca8 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Andreas:
        * Avoid crashing when printing sheet object widgets from ssconvert. [#705638]
        * Fix printing of sheet object widgets. [#705650] [#705653]
        * Use current GTK style when printing sheet object widgets from Gnumeric. [#705684]
+       * Scale tiny buttons when printing. [Part of #705689]
 
 Jean:
        * Fix text wrap inside sheet objects. [#704417]
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 6d72bc8..07b31cb 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -649,7 +649,7 @@ get_font (void)
 
 static void
 draw_cairo_text (cairo_t *cr, char const *text, int *pwidth, int *pheight,
-                gboolean centered_v, gboolean centered_h, gboolean single, gint highlight_n)
+                gboolean centered_v, gboolean centered_h, gboolean single, gint highlight_n, gboolean scale)
 {
        PangoLayout *layout = pango_cairo_create_layout (cr);
        double const scale_h = 72. / gnm_app_display_dpi_get (TRUE);
@@ -665,6 +665,16 @@ draw_cairo_text (cairo_t *cr, char const *text, int *pwidth, int *pheight,
        pango_layout_get_pixel_size (layout, &width, &height);
 
        cairo_scale (cr, scale_h, scale_v);
+
+       if (scale && pwidth != NULL && pheight != NULL) {
+               double sc_x = ((double) *pwidth)/(width * scale_h);
+               double sc_y = ((double) *pheight)/(height * scale_v);
+               double sc = MIN(sc_x, sc_y);
+
+               if (sc < 1.)
+                       cairo_scale (cr, sc, sc);
+       }
+
        if (centered_v)
                cairo_rel_move_to (cr, 0., 0.5 - ((double)height)/2.);
        if (centered_h)
@@ -717,7 +727,7 @@ sheet_widget_frame_draw_cairo (SheetObject const *so, cairo_t *cr,
        cairo_move_to (cr, 10, 0);
 
        cairo_save (cr);
-       draw_cairo_text (cr, swf->label, &twidth, &theight, FALSE, FALSE, TRUE, 0);
+       draw_cairo_text (cr, swf->label, &twidth, &theight, FALSE, FALSE, TRUE, 0, FALSE);
        cairo_restore (cr);
 
        cairo_set_line_width (cr, 1);
@@ -1254,7 +1264,9 @@ sheet_widget_button_draw_cairo (SheetObject const *so, cairo_t *cr,
 
        cairo_move_to (cr, width/2., height/2.);
 
-       draw_cairo_text (cr, swb->label, &twidth, &theight, TRUE, TRUE, TRUE, 0);
+       twidth = 0.8 * width;
+       theight = 0.8 * height;
+       draw_cairo_text (cr, swb->label, &twidth, &theight, TRUE, TRUE, TRUE, 0, TRUE);
 
        cairo_new_path (cr);
        cairo_restore (cr);
@@ -2074,7 +2086,7 @@ sheet_widget_spinbutton_draw_cairo (SheetObject const *so, cairo_t *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, FALSE, TRUE, 0);
+       draw_cairo_text (cr, str, NULL, NULL, TRUE, FALSE, TRUE, 0, FALSE);
        g_free (str);
 
        cairo_new_path (cr);
@@ -2698,7 +2710,7 @@ sheet_widget_checkbox_draw_cairo (SheetObject const *so, cairo_t *cr,
 
        cairo_move_to (cr, 4. + 8. + 4, halfheight);
 
-       draw_cairo_text (cr, swc->label, NULL, NULL, TRUE, FALSE, TRUE, 0);
+       draw_cairo_text (cr, swc->label, NULL, NULL, TRUE, FALSE, TRUE, 0, FALSE);
 
        cairo_new_path (cr);
        cairo_restore (cr);
@@ -3333,7 +3345,7 @@ sheet_widget_radio_button_draw_cairo (SheetObject const *so, cairo_t *cr,
 
        cairo_move_to (cr, 4. + 8. + 4, halfheight);
 
-       draw_cairo_text (cr, swr->label, NULL, NULL, TRUE, FALSE, TRUE, 0);
+       draw_cairo_text (cr, swr->label, NULL, NULL, TRUE, FALSE, TRUE, 0, FALSE);
 
        cairo_new_path (cr);
        cairo_restore (cr);
@@ -3903,7 +3915,8 @@ sheet_widget_list_draw_cairo (SheetObject const *so, cairo_t *cr,
 
                cairo_translate (cr, 4., 2.);
 
-               draw_cairo_text (cr, str->str, &twidth, &theight, FALSE, FALSE, FALSE, swl->selection);
+               draw_cairo_text (cr, str->str, &twidth, &theight, FALSE, FALSE, FALSE,
+                                swl->selection, FALSE);
 
                g_string_free (str, TRUE);
        }
@@ -4036,7 +4049,7 @@ sheet_widget_combo_draw_cairo (SheetObject const *so, cairo_t *cr,
                                                   swl->selection - 1)) {
                        char *str = NULL;
                        gtk_tree_model_get (swl->model, &iter, 0, &str, -1);
-                       draw_cairo_text (cr, str, NULL, NULL, TRUE, FALSE, TRUE, 0);
+                       draw_cairo_text (cr, str, NULL, NULL, TRUE, FALSE, TRUE, 0, FALSE);
                        g_free (str);
                }
        }


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