changeset 1137:e24e5a13ff2c

Added code to test the new print functions in dwtest. GTK3 code mostly works except the for the text. Added stub print functions to all platforms besides GTK3. Need to decide what to do about GTK2; the GTK3 code will work in GTK 2.10 and later, but will require switching to cairo. Mac/Win/OS2 code coming soon. :)
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 09 Sep 2011 09:17:09 +0000
parents 1a5b0908659b
children caeae1ff0289
files dw.def dwtest.c dww.def gtk/dw.c gtk3/dw.c mac/dw.m os2/dw.c template/dw.c win/dw.c
diffstat 9 files changed, 222 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/dw.def	Fri Sep 09 00:28:25 2011 +0000
+++ b/dw.def	Fri Sep 09 09:17:09 2011 +0000
@@ -290,3 +290,8 @@
   dw_scrollbox_new                       @500
   dw_scrollbox_get_pos                   @501
   dw_scrollbox_get_range                 @502
+  
+  dw_print_new                           @510
+  dw_print_run                           @511
+  dw_print_cancel                        @512
+
--- a/dwtest.c	Fri Sep 09 00:28:25 2011 +0000
+++ b/dwtest.c	Fri Sep 09 09:17:09 2011 +0000
@@ -333,10 +333,11 @@
     }
 }
 
-void draw_shapes(int direct)
+void draw_shapes(int direct, HPIXMAP hpma)
 {
-    int width = (int)DW_PIXMAP_WIDTH(text2pm), height = (int)DW_PIXMAP_HEIGHT(text2pm);
-    HPIXMAP pixmap = direct ? NULL : text2pm;
+    HPIXMAP hpm = hpma ? hpma : text2pm;
+    int width = (int)DW_PIXMAP_WIDTH(hpm), height = (int)DW_PIXMAP_HEIGHT(hpm);
+    HPIXMAP pixmap = direct ? NULL : hpm;
     HWND window = direct ? textbox2 : 0;
 
     image_x = (int)dw_spinbutton_get_pos(imagexspin);
@@ -355,7 +356,7 @@
     }
 
     /* If we aren't drawing direct do a bitblt */
-    if(!direct)
+    if(!direct && !hpma)
     {
         text_expose( textbox2, NULL, NULL);
     }
@@ -366,10 +367,10 @@
     switch(render_type)
     {
         case 0:
-            draw_shapes(FALSE);
+            draw_shapes(FALSE, NULL);
             break;
         case 1:
-            draw_shapes(TRUE);
+            draw_shapes(TRUE, NULL);
             break;
         case 2:
             draw_file(current_row, current_col);
@@ -377,6 +378,19 @@
     }
 }
 
+int DWSIGNAL draw_page(HPRINT print, HPIXMAP pixmap, int page_num, void *data)
+{
+   draw_shapes(FALSE, pixmap);
+   return TRUE;
+}
+
+int DWSIGNAL print_callback(HWND window, void *data)
+{
+   HPRINT print = dw_print_new(0, 1, DW_SIGNAL_FUNC(draw_page), NULL);
+   dw_print_run(print, 0);
+   return FALSE;
+}
+
 int DWSIGNAL refresh_callback(HWND window, void *data)
 {
     update_render();
@@ -843,7 +857,7 @@
 void text_add(void)
 {
     unsigned long depth = dw_color_depth_get();
-    HWND vscrollbox, hbox, button1, label;
+    HWND vscrollbox, hbox, button1, button2, label;
 
     /* create a box to pack into the notebook page */
     pagebox = dw_box_new(BOXHORZ, 2);
@@ -880,6 +894,8 @@
 
     button1 = dw_button_new( "Refresh", 1223L );
     dw_box_pack_start( hbox, button1, 50, 25, TRUE, FALSE, 0);
+    button2 = dw_button_new( "Print", 1224L );
+    dw_box_pack_start( hbox, button2, 50, 25, TRUE, FALSE, 0);
 
     /* create render box for number pixmap */
     textbox1 = dw_render_new( 100 );
@@ -933,6 +949,7 @@
     dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status1);
     dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged_callback), (void *)status1);
     dw_signal_connect(button1, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(refresh_callback), NULL);
+    dw_signal_connect(button2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(print_callback), NULL);
     dw_signal_connect(rendcombo, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(render_select_event_callback), NULL );
     dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL);
 }
--- a/dww.def	Fri Sep 09 00:28:25 2011 +0000
+++ b/dww.def	Fri Sep 09 09:17:09 2011 +0000
@@ -287,3 +287,8 @@
   dw_scrollbox_new                       @500
   dw_scrollbox_get_pos                   @501
   dw_scrollbox_get_range                 @502
+
+  dw_print_new                           @510
+  dw_print_run                           @511
+  dw_print_cancel                        @512
+  
--- a/gtk/dw.c	Fri Sep 09 00:28:25 2011 +0000
+++ b/gtk/dw.c	Fri Sep 09 09:17:09 2011 +0000
@@ -11673,6 +11673,43 @@
 }
 
 /*
+ * Creates a new print object.
+ * Parameters:
+ *       flags: Flags to initially configure the print object.
+ *       pages: Number of pages to print.
+ *       drawfunc: The pointer to the function to be used as the callback.
+ *       drawdata: User data to be passed to the handler function.
+ * Returns:
+ *       A handle to the print object or NULL on failure.
+ */
+HPRINT API dw_print_new(unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
+{
+   return NULL;
+}
+
+/*
+ * Runs the print job, causing the draw page callbacks to fire.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ *       flags: Flags to run the print job.
+ * Returns:
+ *       DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
+ */
+int API dw_print_run(HPRINT print, unsigned long flags)
+{
+   return DW_ERROR_UNKNOWN;
+}
+
+/*
+ * Cancels the print job, typically called from a draw page callback.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ */
+void API dw_print_cancel(HPRINT print)
+{
+}
+
+/*
  * Returns a pointer to a static buffer which containes the
  * current user directory.  Or the root directory (C:\ on
  * OS/2 and Windows).
--- a/gtk3/dw.c	Fri Sep 09 00:28:25 2011 +0000
+++ b/gtk3/dw.c	Fri Sep 09 09:17:09 2011 +0000
@@ -10223,7 +10223,7 @@
  *       drawfunc: The pointer to the function to be used as the callback.
  *       drawdata: User data to be passed to the handler function.
  * Returns:
- *       A handle to the print object.
+ *       A handle to the print object or NULL on failure.
  */
 HPRINT API dw_print_new(unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
 {
--- a/mac/dw.m	Fri Sep 09 00:28:25 2011 +0000
+++ b/mac/dw.m	Fri Sep 09 09:17:09 2011 +0000
@@ -9262,3 +9262,41 @@
     [[NSWorkspace sharedWorkspace] openURL:myurl];
     return DW_ERROR_NONE;
 }
+
+/*
+ * Creates a new print object.
+ * Parameters:
+ *       flags: Flags to initially configure the print object.
+ *       pages: Number of pages to print.
+ *       drawfunc: The pointer to the function to be used as the callback.
+ *       drawdata: User data to be passed to the handler function.
+ * Returns:
+ *       A handle to the print object or NULL on failure.
+ */
+HPRINT API dw_print_new(unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
+{
+   return NULL;
+}
+
+/*
+ * Runs the print job, causing the draw page callbacks to fire.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ *       flags: Flags to run the print job.
+ * Returns:
+ *       DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
+ */
+int API dw_print_run(HPRINT print, unsigned long flags)
+{
+   return DW_ERROR_UNKNOWN;
+}
+
+/*
+ * Cancels the print job, typically called from a draw page callback.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ */
+void API dw_print_cancel(HPRINT print)
+{
+}
+
--- a/os2/dw.c	Fri Sep 09 00:28:25 2011 +0000
+++ b/os2/dw.c	Fri Sep 09 09:17:09 2011 +0000
@@ -10029,6 +10029,43 @@
 }
 
 /*
+ * Creates a new print object.
+ * Parameters:
+ *       flags: Flags to initially configure the print object.
+ *       pages: Number of pages to print.
+ *       drawfunc: The pointer to the function to be used as the callback.
+ *       drawdata: User data to be passed to the handler function.
+ * Returns:
+ *       A handle to the print object or NULL on failure.
+ */
+HPRINT API dw_print_new(unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
+{
+   return NULL;
+}
+
+/*
+ * Runs the print job, causing the draw page callbacks to fire.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ *       flags: Flags to run the print job.
+ * Returns:
+ *       DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
+ */
+int API dw_print_run(HPRINT print, unsigned long flags)
+{
+   return DW_ERROR_UNKNOWN;
+}
+
+/*
+ * Cancels the print job, typically called from a draw page callback.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ */
+void API dw_print_cancel(HPRINT print)
+{
+}
+
+/*
  * Returns a pointer to a static buffer which containes the
  * current user directory.  Or the root directory (C:\ on
  * OS/2 and Windows).
--- a/template/dw.c	Fri Sep 09 00:28:25 2011 +0000
+++ b/template/dw.c	Fri Sep 09 09:17:09 2011 +0000
@@ -3379,3 +3379,41 @@
 {
     return DW_ERROR_UNKNOWN;
 }
+
+/*
+ * Creates a new print object.
+ * Parameters:
+ *       flags: Flags to initially configure the print object.
+ *       pages: Number of pages to print.
+ *       drawfunc: The pointer to the function to be used as the callback.
+ *       drawdata: User data to be passed to the handler function.
+ * Returns:
+ *       A handle to the print object or NULL on failure.
+ */
+HPRINT API dw_print_new(unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
+{
+   return NULL;
+}
+
+/*
+ * Runs the print job, causing the draw page callbacks to fire.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ *       flags: Flags to run the print job.
+ * Returns:
+ *       DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
+ */
+int API dw_print_run(HPRINT print, unsigned long flags)
+{
+   return DW_ERROR_UNKNOWN;
+}
+
+/*
+ * Cancels the print job, typically called from a draw page callback.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ */
+void API dw_print_cancel(HPRINT print)
+{
+}
+
--- a/win/dw.c	Fri Sep 09 00:28:25 2011 +0000
+++ b/win/dw.c	Fri Sep 09 09:17:09 2011 +0000
@@ -9991,6 +9991,43 @@
 }
 
 /*
+ * Creates a new print object.
+ * Parameters:
+ *       flags: Flags to initially configure the print object.
+ *       pages: Number of pages to print.
+ *       drawfunc: The pointer to the function to be used as the callback.
+ *       drawdata: User data to be passed to the handler function.
+ * Returns:
+ *       A handle to the print object or NULL on failure.
+ */
+HPRINT API dw_print_new(unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
+{
+   return NULL;
+}
+
+/*
+ * Runs the print job, causing the draw page callbacks to fire.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ *       flags: Flags to run the print job.
+ * Returns:
+ *       DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
+ */
+int API dw_print_run(HPRINT print, unsigned long flags)
+{
+   return DW_ERROR_UNKNOWN;
+}
+
+/*
+ * Cancels the print job, typically called from a draw page callback.
+ * Parameters:
+ *       print: Handle to the print object returned by dw_print_new().
+ */
+void API dw_print_cancel(HPRINT print)
+{
+}
+
+/*
  * Returns a pointer to a static buffer which containes the
  * current user directory.  Or the root directory (C:\ on
  * OS/2 and Windows).