Author: manolo
Date: 2010-03-10 23:31:35 -0800 (Wed, 10 Mar 2010)
New Revision: 7243
Log:
Added support for page range choice by user.

Modified:
   branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx
   branches/branch-1.3-Fl_Printer/src/print_panel.cxx

Modified: branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx        2010-03-10 
23:05:43 UTC (rev 7242)
+++ branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx        2010-03-11 
07:31:35 UTC (rev 7243)
@@ -316,6 +316,7 @@
   close_cmd_ = 0;
   //lang_level_ = 3;
   lang_level_ = 2;
+  //lang_level_ = 1;
   mask = 0;
   ps_filename_ = NULL;
   type_ = postscript_device;
@@ -1179,14 +1180,8 @@
 
 #if ! (defined(__APPLE__) || defined(WIN32) )
 int Fl_PS_Printer::start_job(int pages, int *firstpage, int *lastpage) {
-  // TODO:
-  // return the user's desired page range to the caller
-  // and transmit the range total to start_postscript()        *TODO*
-
   enum Page_Format format;
   enum Page_Layout layout;
-  if(firstpage) *firstpage = 1; // temporary
-  if(lastpage) *lastpage = pages; // temporary
 
   // first test version for print dialog
 
@@ -1195,6 +1190,9 @@
   print_selection->deactivate();
   print_all->setonly();
   print_all->do_callback();
+  print_from->value("1");
+  { char tmp[10]; snprintf(tmp, sizeof(tmp), "%d", pages); 
print_to->value(tmp); }
+  print_copies->parent()->deactivate(); // TODO: manage copy # and collate 
options
   print_panel->show(); // this is modal
   while (print_panel->shown()) Fl::wait();
   
@@ -1204,6 +1202,19 @@
   // get options
 
   format = print_page_size->value() ? A4 : LETTER;
+  { // page range choice
+    int from = 1, to = pages;
+    if (print_pages->value()) {
+      sscanf(print_from->value(), "%d", &from);
+      sscanf(print_to->value(), "%d", &to);
+    }
+    if (from < 1) from = 1;
+    if (to > pages) to = pages;
+    if (to < from) to = from;
+    if (firstpage) *firstpage = from;
+    if (lastpage) *lastpage = to;
+    pages = to - from + 1;
+  }
   
   if (print_output_mode[0]->value()) layout = PORTRAIT;
   else if (print_output_mode[1]->value()) layout = LANDSCAPE;

Modified: branches/branch-1.3-Fl_Printer/src/print_panel.cxx
===================================================================
--- branches/branch-1.3-Fl_Printer/src/print_panel.cxx  2010-03-10 23:05:43 UTC 
(rev 7242)
+++ branches/branch-1.3-Fl_Printer/src/print_panel.cxx  2010-03-11 07:31:35 UTC 
(rev 7243)
@@ -46,6 +46,7 @@
 #include <stdlib.h>
 #include "../src/flstring.h"
 #include <FL/Fl_Preferences.H>
+#include <FL/Fl_Int_Input.H>
 
 // extern Fl_Preferences fluid_prefs;
 
@@ -62,8 +63,8 @@
 static Fl_Progress *print_progress=(Fl_Progress *)0;
 static Fl_Double_Window *print_properties_panel=(Fl_Double_Window *)0;
 static Fl_Choice *print_page_size=(Fl_Choice *)0;
-static Fl_Input *print_from=(Fl_Input *)0;
-static Fl_Input *print_to=(Fl_Input *)0;
+static Fl_Int_Input *print_from=(Fl_Int_Input *)0;
+static Fl_Int_Input *print_to=(Fl_Int_Input *)0;
 static Fl_Spinner *print_copies=(Fl_Spinner *)0;
 
 static int print_start = 0;    // 1 if print_okay has been clicked
@@ -282,16 +283,16 @@
           print_selection->down_box(FL_ROUND_DOWN_BOX);
           print_selection->callback((Fl_Callback*)cb_print_selection);
         } // Fl_Round_Button* print_selection
-        { print_from = new Fl_Input(136, 126, 28, 25, "From:");
+        { print_from = new Fl_Int_Input(136, 126, 28, 25, "From:");
           print_from->type(2);
           print_from->textfont(4);
           print_from->deactivate();
-        } // Fl_Input* print_from
-        { print_to = new Fl_Input(199, 126, 28, 25, "To:");
+        } // Fl_Int_Input* print_from
+        { print_to = new Fl_Int_Input(199, 126, 28, 25, "To:");
           print_to->type(2);
           print_to->textfont(4);
           print_to->deactivate();
-        } // Fl_Input* print_to
+        } // Fl_Int_Input* print_to
         o->end();
       } // Fl_Group* o
       { Fl_Group* o = new Fl_Group(247, 86, 210, 105, "Copies");
@@ -587,7 +588,7 @@
 
   snprintf(name, sizeof(name), "%s/page_size", printer);
   // fluid_prefs.get(name, val, 0);
-  print_page_size->value(val);
+  print_page_size->value(1); // FIXME
 
   snprintf(name, sizeof(name), "%s/output_mode", printer);
   // fluid_prefs.get(name, val, 0);

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to