summaryrefslogtreecommitdiff
path: root/gtk/gtkprintoperation-win32.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2008-07-30 09:52:42 +0000
committerTor Lillqvist <tml@src.gnome.org>2008-07-30 09:52:42 +0000
commit29b6e6587aee192bdac9ac75b30ef62e74a05fbf (patch)
tree68529fac4914b874e6d5480abad8709cfa21b475 /gtk/gtkprintoperation-win32.c
parentfb7ce7db2740b25b71bd3a834007b864e07a87b9 (diff)
downloadgtk+-29b6e6587aee192bdac9ac75b30ef62e74a05fbf.tar.gz
Fix problems in handling custom paper sizes. The DEVMODE::dmPaperWidth and
2008-07-30 Tor Lillqvist <tml@novell.com> * gtk/gtkprintoperation-win32.c: Fix problems in handling custom paper sizes. The DEVMODE::dmPaperWidth and dmPaperLength are in tenths of a millimeter, and the RECT passed to CreateEnhMetaFile() is in hundredths of a millimeter. Patch by Sven Neumann. svn path=/trunk/; revision=20916
Diffstat (limited to 'gtk/gtkprintoperation-win32.c')
-rw-r--r--gtk/gtkprintoperation-win32.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gtk/gtkprintoperation-win32.c b/gtk/gtkprintoperation-win32.c
index f368e42839..ec6f9cc02c 100644
--- a/gtk/gtkprintoperation-win32.c
+++ b/gtk/gtkprintoperation-win32.c
@@ -439,6 +439,8 @@ win32_start_page (GtkPrintOperation *op,
{
devmode->dmPaperSize = DMPAPER_USER;
devmode->dmFields |= DM_PAPERWIDTH | DM_PAPERLENGTH;
+
+ /* Lengths in DEVMODE are in tenths of a millimeter */
devmode->dmPaperWidth = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM) * 10.0;
devmode->dmPaperLength = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM) * 10.0;
}
@@ -672,10 +674,12 @@ devmode_to_settings (GtkPrintSettings *settings,
-1, NULL, NULL, NULL);
if (form_name == NULL || form_name[0] == 0)
form_name = g_strdup (_("Custom size"));
+
+ /* Lengths in DEVMODE are in tenths of a millimeter */
paper_size = gtk_paper_size_new_custom (form_name,
form_name,
- devmode->dmPaperWidth * 10.0,
- devmode->dmPaperLength * 10.0,
+ devmode->dmPaperWidth / 10.0,
+ devmode->dmPaperLength / 10.0,
GTK_UNIT_MM);
gtk_print_settings_set_paper_size (settings, paper_size);
gtk_paper_size_free (paper_size);
@@ -954,8 +958,10 @@ devmode_from_settings (GtkPrintSettings *settings,
{
devmode->dmPaperSize = DMPAPER_USER;
devmode->dmFields |= DM_PAPERWIDTH | DM_PAPERLENGTH;
- devmode->dmPaperWidth = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM) / 10.0;
- devmode->dmPaperLength = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM) / 10.0;
+
+ /* Lengths in DEVMODE are in tenths of a millimeter */
+ devmode->dmPaperWidth = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM) * 10.0;
+ devmode->dmPaperLength = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM) * 10.0;
}
gtk_paper_size_free (paper_size);
}
@@ -1726,7 +1732,6 @@ _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation
gchar **target)
{
GtkPaperSize *paper_size;
- double w, h;
HDC metafile_dc;
RECT rect;
char *template;
@@ -1745,13 +1750,12 @@ _gtk_print_operation_platform_backend_create_preview_surface (GtkPrintOperation
g_free (filename);
paper_size = gtk_page_setup_get_paper_size (page_setup);
- w = gtk_paper_size_get_width (paper_size, GTK_UNIT_MM);
- h = gtk_paper_size_get_height (paper_size, GTK_UNIT_MM);
-
+
+ /* The rectangle dimensions are given in hundredths of a millimeter */
rect.left = 0;
- rect.right = w*100;
+ rect.right = 100.0 * gtk_paper_size_get_width (paper_size, GTK_UNIT_MM);
rect.top = 0;
- rect.bottom = h*100;
+ rect.bottom = 100.0 * gtk_paper_size_get_height (paper_size, GTK_UNIT_MM);
metafile_dc = CreateEnhMetaFileW (NULL, filename_utf16,
&rect, L"Gtk+\0Print Preview\0\0");