summaryrefslogtreecommitdiffstats
path: root/display.h
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2012-09-11 11:16:34 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-11 07:26:38 -0700
commit50eac41129b09f989bade45077beab32bb585eb0 (patch)
tree78cedc96af221262aa21f995ef45d7733a183813 /display.h
parent38d49bf0411acb67f3623a813d912c07025f474a (diff)
downloadsubsurface-50eac41129b09f989bade45077beab32bb585eb0.tar.gz
Use GTK_UNIT_INCH when printing to provide consistency across OS
Tests have shown that the most multi-platform way to do printing with GTK is to use GTK_UNIT_INCH (or GTK_UNIT_MM) with GtkPrintOperation. Tested on Linux, OSX, Windows. However this requires the appropriate scaling for Pango and Cairo to be done, with separate plotting logic for printing and drawing on the screen. To achieve that, profile.c:plot() now accepts a scaling parameter from type "scale_mode_t" defined in "display.h". Also due to new scale, small decimal numbers (such as 6.12345) cannot be well stored in "cairo_rectangle_int_t" therefore it is replaced with "cairo_rectangle_t", which uses doubles to provide Cairo with a drawing area. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Minor whitespace cleanup. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'display.h')
-rw-r--r--display.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/display.h b/display.h
index ef52e99f5..82d12682b 100644
--- a/display.h
+++ b/display.h
@@ -3,6 +3,10 @@
#include <cairo.h>
+#define DPI_SCREEN 72.0
+#define SCALE_SCREEN 1.0
+#define SCALE_PRINT (1.0 / DPI_SCREEN)
+
extern void repaint_dive(void);
extern void do_print(void);
@@ -22,7 +26,9 @@ struct graphics_context {
double topy, bottomy;
};
-extern void plot(struct graphics_context *gc, cairo_rectangle_int_t *drawing_area, struct dive *dive);
+typedef enum { SC_SCREEN, SC_PRINT } scale_mode_t;
+
+extern void plot(struct graphics_context *gc, cairo_rectangle_t *drawing_area, struct dive *dive, scale_mode_t scale);
extern void init_profile_background(struct graphics_context *gc);
extern void attach_tooltip(int x, int y, int w, int h, const char *text);