]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkprintoperation-win32.c
filechooserbutton: Add tests for unselect_all()
[~andy/gtk] / gtk / gtkprintoperation-win32.c
index 12c1e5ebc8143c0b1655e059b38afa6d16f4c277..04de8ebbeb178f44d8bd7d2db460199f96162a74 100644 (file)
@@ -13,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifndef _MSC_VER
@@ -43,7 +41,6 @@
 #include "gtkstock.h"
 #include "gtk.h"
 #include "gtkwin32embedwidget.h"
-#include "gtkalias.h"
 
 #define MAX_PAGE_RANGES 20
 #define STATUS_POLLING_TIME 2000
@@ -72,7 +69,7 @@ static void win32_poll_status (GtkPrintOperation *op);
 
 static const GUID myIID_IPrintDialogCallback  = {0x5852a2c3,0x6530,0x11d1,{0xb6,0xa3,0x0,0x0,0xf8,0x75,0x7b,0xf9}};
 
-#ifndef _MSC_VER
+#if !defined (_MSC_VER) && !defined (HAVE_IPRINTDIALOGCALLBACK)
 #undef INTERFACE
 #define INTERFACE IPrintDialogCallback
 DECLARE_INTERFACE_ (IPrintDialogCallback, IUnknown)
@@ -436,6 +433,22 @@ get_default_printer (void)
   return printer_name;
 }
 
+static void
+set_hard_margins (GtkPrintOperation *op)
+{
+  double top, bottom, left, right;
+  GtkPrintOperationWin32 *op_win32 = op->priv->platform_data;
+
+  top = GetDeviceCaps (op_win32->hdc, PHYSICALOFFSETY);
+  bottom = GetDeviceCaps (op_win32->hdc, PHYSICALHEIGHT)
+      - GetDeviceCaps (op_win32->hdc, VERTRES) - top;
+  left = GetDeviceCaps (op_win32->hdc, PHYSICALOFFSETX);
+  right = GetDeviceCaps (op_win32->hdc, PHYSICALWIDTH)
+      - GetDeviceCaps (op_win32->hdc, HORZRES) - left;
+
+  _gtk_print_context_set_hard_margins (op->priv->print_context, top, bottom, left, right);
+}
+
 void
 win32_start_page (GtkPrintOperation *op,
                  GtkPrintContext *print_context,
@@ -444,6 +457,7 @@ win32_start_page (GtkPrintOperation *op,
   GtkPrintOperationWin32 *op_win32 = op->priv->platform_data;
   LPDEVMODEW devmode;
   GtkPaperSize *paper_size;
+  double x_off, y_off;
 
   devmode = GlobalLock (op_win32->devmode);
   
@@ -468,6 +482,11 @@ win32_start_page (GtkPrintOperation *op,
   ResetDCW (op_win32->hdc, devmode);
   
   GlobalUnlock (op_win32->devmode);
+
+  set_hard_margins (op);
+  x_off = GetDeviceCaps (op_win32->hdc, PHYSICALOFFSETX);
+  y_off = GetDeviceCaps (op_win32->hdc, PHYSICALOFFSETY);
+  cairo_surface_set_device_offset (op_win32->surface, -x_off, -y_off);
   
   StartPage (op_win32->hdc);
 }
@@ -634,7 +653,7 @@ static HWND
 get_parent_hwnd (GtkWidget *widget)
 {
   gtk_widget_realize (widget);
-  return gdk_win32_drawable_get_handle (widget->window);
+  return gdk_win32_window_get_handle (gtk_widget_get_window (widget));
 }
 
 static void
@@ -940,8 +959,8 @@ devmode_from_settings (GtkPrintSettings *settings,
     {
       devmode->dmDriverExtra = extras_len;
       memcpy (((char *)devmode) + sizeof (DEVMODEW), extras, extras_len);
-      g_free (extras);
     }
+  g_free (extras);
   if (gtk_print_settings_has_key (settings, GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION))
     devmode->dmDriverVersion = gtk_print_settings_get_int (settings, GTK_PRINT_SETTINGS_WIN32_DRIVER_VERSION);
   
@@ -1318,7 +1337,7 @@ plug_grab_notify (GtkWidget        *widget,
                  gboolean          was_grabbed,
                  GtkPrintOperation *op)
 {
-  EnableWindow (GetAncestor (GDK_WINDOW_HWND (widget->window), GA_ROOT),
+  EnableWindow (GetAncestor (GDK_WINDOW_HWND (gtk_widget_get_window (widget)), GA_ROOT),
                was_grabbed);
 }
 
@@ -1339,13 +1358,13 @@ pageDlgProc (HWND wnd, UINT message, WPARAM wparam, LPARAM lparam)
 
       SetWindowLongPtrW (wnd, GWLP_USERDATA, (LONG_PTR)op);
       
-      plug = _gtk_win32_embed_widget_new ((GdkNativeWindow) wnd);
+      plug = _gtk_win32_embed_widget_new (wnd);
       gtk_window_set_modal (GTK_WINDOW (plug), TRUE);
       op_win32->embed_widget = plug;
       gtk_container_add (GTK_CONTAINER (plug), op->priv->custom_widget);
       gtk_widget_show (op->priv->custom_widget);
       gtk_widget_show (plug);
-      gdk_window_focus (plug->window, GDK_CURRENT_TIME);
+      gdk_window_focus (gtk_widget_get_window (plug), GDK_CURRENT_TIME);
 
       /* This dialog is modal, so we grab the embed widget */
       gtk_grab_add (plug);
@@ -1390,8 +1409,9 @@ create_application_page (GtkPrintOperation *op)
   const char *tab_label;
 
   /* Make the template the size of the custom widget size request */
-  gtk_widget_size_request (op->priv->custom_widget, &requisition);
-      
+  gtk_widget_get_preferred_size (op->priv->custom_widget,
+                                 &requisition, NULL);
+
   base_units = GetDialogBaseUnits ();
   baseunitX = LOWORD (base_units);
   baseunitY = HIWORD (base_units);
@@ -1560,6 +1580,8 @@ gtk_print_operation_run_without_dialog (GtkPrintOperation *op,
   gtk_print_context_set_cairo_context (priv->print_context, cr, dpi_x, dpi_y);
   cairo_destroy (cr);
 
+  set_hard_margins (op);
+
   memset (&docinfo, 0, sizeof (DOCINFOW));
   docinfo.cbSize = sizeof (DOCINFOW); 
   docinfo.lpszDocName = g_utf8_to_utf16 (op->priv->job_name, -1, NULL, NULL, NULL); 
@@ -1598,6 +1620,8 @@ gtk_print_operation_run_without_dialog (GtkPrintOperation *op,
   op->priv->manual_orientation = FALSE;
   op->priv->manual_scale = 1.0;
   op->priv->manual_page_set = GTK_PAGE_SET_ALL;
+  op->priv->manual_number_up = 1;
+  op->priv->manual_number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
 
   op->priv->start_page = win32_start_page;
   op->priv->end_page = win32_end_page;
@@ -1782,7 +1806,9 @@ gtk_print_operation_run_with_dialog (GtkPrintOperation *op,
       cr = cairo_create (op_win32->surface);
       gtk_print_context_set_cairo_context (priv->print_context, cr, dpi_x, dpi_y);
       cairo_destroy (cr);
-      
+
+      set_hard_margins (op);
+
       memset ( &docinfo, 0, sizeof (DOCINFOW));
       docinfo.cbSize = sizeof (DOCINFOW); 
       docinfo.lpszDocName = g_utf8_to_utf16 (op->priv->job_name, -1, NULL, NULL, NULL); 
@@ -1821,6 +1847,8 @@ gtk_print_operation_run_with_dialog (GtkPrintOperation *op,
       op->priv->manual_orientation = FALSE;
       op->priv->manual_scale = 1.0;
       op->priv->manual_page_set = GTK_PAGE_SET_ALL;
+      op->priv->manual_number_up = 1;
+      op->priv->manual_number_up_layout = GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM;
     }
 
   op->priv->start_page = win32_start_page;
@@ -2104,6 +2132,3 @@ gtk_print_run_page_setup_dialog_async (GtkWindow            *parent,
   done_cb (new_page_setup, data);
   g_object_unref (new_page_setup);
 }
-
-#define __GTK_PRINT_OPERATION_WIN32_C__
-#include "gtkaliasdef.c"