summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: aa42d0d)
raw | patch | inline | side by side (parent: aa42d0d)
author | JazzyNico <JazzyNico@users.sourceforge.net> | |
Wed, 12 Aug 2009 06:45:56 +0000 (06:45 +0000) | ||
committer | JazzyNico <JazzyNico@users.sourceforge.net> | |
Wed, 12 Aug 2009 06:45:56 +0000 (06:45 +0000) |
src/ui/dialog/print.cpp | patch | blob | history |
index d15773ecb9fa31aab81f794d2591bb720a57091b..214b1a6db9ebaa9ec3d3f22f74ad36fce2251e3f 100644 (file)
--- a/src/ui/dialog/print.cpp
+++ b/src/ui/dialog/print.cpp
#endif
#ifdef WIN32
#include <io.h>
+#include <windows.h>
#endif
#include <gtkmm/stock.h>
static void
-draw_page (GtkPrintOperation */*operation*/,
+draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
gint /*page_nr*/,
gpointer user_data)
cairo_surface_t *surface = cairo_get_target(cr);
cairo_matrix_t ctm;
cairo_get_matrix(cr, &ctm);
+#ifdef WIN32
+ //Gtk+ does not take the non printable area into account
+ //http://bugzilla.gnome.org/show_bug.cgi?id=381371
+ //
+ // This workaround translates the origin from the top left of the
+ // printable area to the top left of the page.
+ GtkPrintSettings *settings = gtk_print_operation_get_print_settings(operation);
+ const gchar *printerName = gtk_print_settings_get_printer(settings);
+ HDC hdc = CreateDC("WINSPOOL", printerName, NULL, NULL);
+ if (hdc) {
+ cairo_matrix_t mat;
+ int x_off = GetDeviceCaps (hdc, PHYSICALOFFSETX);
+ int y_off = GetDeviceCaps (hdc, PHYSICALOFFSETY);
+ cairo_matrix_init_translate(&mat, -x_off, -y_off);
+ cairo_matrix_multiply (&ctm, &ctm, &mat);
+ DeleteDC(hdc);
+ }
+#endif
bool ret = ctx->setSurfaceTarget (surface, true, &ctm);
if (ret) {
ret = renderer.setupDocument (ctx, junk->_doc, TRUE, NULL);