Author: manolo
Date: 2010-03-07 05:31:56 -0800 (Sun, 07 Mar 2010)
New Revision: 7228
Log:
Added support for landscape orientation to PostScript printers and files.

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

Modified: branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H
===================================================================
--- branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H      2010-03-07 13:30:40 UTC 
(rev 7227)
+++ branches/branch-1.3-Fl_Printer/FL/Fl_Printer.H      2010-03-07 13:31:56 UTC 
(rev 7228)
@@ -274,7 +274,11 @@
 #endif
   { // defined for all 3 platforms
 public:
-  enum Page_Format{
+    
+    /**
+     @brief Possible page formats.
+     */
+    enum Page_Format{
     A0 = 0, 
     A1,
     A2,
@@ -307,7 +311,11 @@
     ENVELOPE,
     MEDIA = 0x1000
   };
-  enum Page_Layout {PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, 
ORIENTATION = 0x300};
+    
+    /**
+     @brief Possible page layouts.
+     */
+    enum Page_Layout {PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, 
ORIENTATION = 0x300};
 
     /**
      @brief The constructor.
@@ -323,11 +331,12 @@
      @brief Begins the session where all graphics will go to a local 
PostScript file.
      *
      Opens a file dialog to select an output PostScript file.
-     @param pagecount the total number of pages to be created
-     @param format desired page format
+     @param pagecount The total number of pages to be created.
+     @param format Desired page format.
+     @param layout Desired page layout.
      @return 0 iff OK
      */
-    int start_job(int pagecount, enum Page_Format format = A4);
+    int start_job(int pagecount, enum Page_Format format = A4, enum 
Page_Layout layout = PORTRAIT);
 
 #ifndef FL_DOXYGEN
 private:
@@ -392,7 +401,7 @@
   static const struct page_format page_formats[NO_PAGE_FORMATS];
   
   uchar bg_r, bg_g, bg_b;
-  int start_postscript (int pagecount, enum Page_Format format);
+  int start_postscript (int pagecount, enum Page_Format format, enum 
Page_Layout layout);
   /*  int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
    */
   void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };

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-07 
13:30:40 UTC (rev 7227)
+++ branches/branch-1.3-Fl_Printer/src/Fl_PS_Printer.cxx        2010-03-07 
13:31:56 UTC (rev 7228)
@@ -314,17 +314,18 @@
 Fl_PSfile_Device::Fl_PSfile_Device(void)
 {
   close_cmd_ = 0;
-  lang_level_ = 3;
+  //lang_level_ = 3;
+  lang_level_ = 2;
   mask = 0;
   ps_filename_ = NULL;
   type_ = postscript_device;
 }
 
-int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format format)
+int Fl_PSfile_Device::start_postscript (int pagecount, enum Page_Format 
format, enum Page_Layout layout)
 //returns 0 iff OK
 {
   this->set_current();
-  page_format_ = format;
+  page_format_ = (enum Page_Format)(format | layout);
   
   fputs("%!PS-Adobe-3.0\n", output);
   fputs("%%Creator: FLTK\n", output);
@@ -1117,7 +1118,7 @@
   return 0;
 }
 
-int Fl_PSfile_Device::start_job (int pagecount, enum Page_Format format)
+int Fl_PSfile_Device::start_job (int pagecount, enum Page_Format format, enum 
Page_Layout layout)
 {
   Fl_Native_File_Chooser fnfc;
   fnfc.title("Create a .ps file");
@@ -1128,7 +1129,7 @@
   output = fopen(fnfc.filename(), "w");
   if(output == NULL) return 1;
   ps_filename_ = strdup(fnfc.filename());
-  return start_postscript(pagecount, format);
+  return start_postscript(pagecount, format, layout);
 }
 
 void Fl_PSfile_Device::end_job (void)
@@ -1176,6 +1177,7 @@
   // return Fl_PSfile_Device::start_postscript(pages, format); *DONE*
 
   enum Page_Format format = A4; // default
+  enum Page_Layout layout = PORTRAIT; // default
   if(firstpage) *firstpage = 1; // temporary
   if(lastpage) *lastpage = pages; // temporary
 
@@ -1195,6 +1197,11 @@
   // get options
 
   format = print_page_size->value() ? A4 : LETTER;
+  
+  if (print_output_mode[0]->value()) layout = PORTRAIT;
+  else if (print_output_mode[1]->value()) layout = LANDSCAPE;
+  else if (print_output_mode[2]->value()) layout = PORTRAIT;
+  else layout = LANDSCAPE;
 
   print_pipe = print_choice->value();  // 0 = print to file, >0 = printer 
(pipe)
 
@@ -1203,7 +1210,7 @@
   if (!print_pipe) printer = "<File>";
 
   if (!print_pipe) // fall back to file printing
-    return Fl_PSfile_Device::start_job (pages, format);
+    return Fl_PSfile_Device::start_job (pages, format, layout);
 
   // Print: pipe the output into the lp command...
 
@@ -1218,9 +1225,7 @@
     return 1;
   }
 
-  ps_filename_ = strdup("FLTK.ps");    // dummy filename (needed?)
-
-  return Fl_PSfile_Device::start_postscript(pages, format); // start printing
+  return Fl_PSfile_Device::start_postscript(pages, format, layout); // start 
printing
 }
 
 /*

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

Reply via email to