Author: manolo
Date: 2010-12-12 08:13:55 -0800 (Sun, 12 Dec 2010)
New Revision: 8017
Log:
Moved enums Page_Format and Page_Layout to class Fl_Paged_Device
where they are better located. Small reorganization of device-related include 
files.

Modified:
   branches/branch-1.3/FL/Fl_Device.H
   branches/branch-1.3/FL/Fl_Paged_Device.H
   branches/branch-1.3/FL/Fl_PostScript.H
   branches/branch-1.3/FL/Fl_Printer.H
   branches/branch-1.3/src/Fl_Paged_Device.cxx
   branches/branch-1.3/src/Fl_PostScript.cxx

Modified: branches/branch-1.3/FL/Fl_Device.H
===================================================================
--- branches/branch-1.3/FL/Fl_Device.H  2010-12-12 11:19:12 UTC (rev 8016)
+++ branches/branch-1.3/FL/Fl_Device.H  2010-12-12 16:13:55 UTC (rev 8017)
@@ -26,7 +26,8 @@
 //     http://www.fltk.org/str.php
 //
 /** \file Fl_Device.H 
- \brief declaration of classes Fl_Device, Fl_Graphics_Driver, 
Fl_Surface_Device, Fl_Display_Device.
+ \brief declaration of classes Fl_Device, Fl_Graphics_Driver, 
Fl_Surface_Device, 
+ Fl_Display_Device, Fl_Device_Plugin.
 */
 
 #ifndef Fl_Device_H
@@ -374,6 +375,28 @@
   static Fl_Display_Device *display_device() { return fl_display_device; };
 };
 
+/**
+ This plugin socket allows the integration of new device drivers for special
+ window or screen types. It is currently used to provide an automated printing
+ service for OpenGL windows, if linked with fltk_gl.
+ */
+class Fl_Device_Plugin : public Fl_Plugin {
+public:
+  /** \brief The constructor */
+  Fl_Device_Plugin(const char *name)
+  : Fl_Plugin(klass(), name) { }
+  /** \brief Returns the class name */
+  virtual const char *klass() { return "fltk:device"; }
+  /** \brief Returns the plugin name */
+  virtual const char *name() = 0;
+  /** \brief Prints a widget 
+   \param w the widget
+   \param x,y offsets where to print relatively to coordinates origin
+   \param height height of the current drawing area
+   */
+  virtual int print(Fl_Widget* w, int x, int y, int height) { return 0; }
+};
+
 #endif // Fl_Device_H
 
 //

Modified: branches/branch-1.3/FL/Fl_Paged_Device.H
===================================================================
--- branches/branch-1.3/FL/Fl_Paged_Device.H    2010-12-12 11:19:12 UTC (rev 
8016)
+++ branches/branch-1.3/FL/Fl_Paged_Device.H    2010-12-12 16:13:55 UTC (rev 
8017)
@@ -34,6 +34,8 @@
 
 #include <FL/Fl_Device.H>
 
+#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
+
 /**
  \brief Represents page-structured drawing surfaces.
  *
@@ -41,6 +43,69 @@
  or Fl_PostScript_File_Device instead.
  */
 class Fl_Paged_Device : public Fl_Surface_Device {
+public:
+  /**
+   \brief Possible page formats.
+   
+   All paper formats with pre-defined width and height.
+   */
+  enum Page_Format {
+    A0 = 0, /**<  A0 format */
+    A1,
+    A2,
+    A3,
+    A4, /**<  A4 format */
+    A5,
+    A6,
+    A7,
+    A8,
+    A9,
+    B0,
+    B1,
+    B2,
+    B3,
+    B4,
+    B5,
+    B6,
+    B7,
+    B8,
+    B9,
+    B10,
+    C5E,
+    DLE,
+    EXECUTIVE,
+    FOLIO,
+    LEDGER,
+    LEGAL,
+    LETTER, /**<  Letter format */
+    TABLOID,
+    ENVELOPE,
+    MEDIA = 0x1000
+  };
+  /**
+   \brief Possible page layouts.
+   */
+  enum Page_Layout {
+    PORTRAIT = 0,  /**< Portrait orientation */
+    LANDSCAPE = 0x100,   /**< Landscape orientation */
+    REVERSED = 0x200,  /**< Reversed orientation */
+    ORIENTATION = 0x300 /**<  orientation */
+  };
+
+  /** \brief width, height and name of a page format
+ */
+  typedef struct {
+    /** \brief width in points */
+    int width; 
+    /** \brief height in points */
+    int height; 
+    /** \brief format name */
+    const char *name; 
+  } page_format;
+  /** \brief width, height and name of all elements of the enum \ref 
Page_Format.
+   */
+  static const page_format page_formats[NO_PAGE_FORMATS];  
+  
 private:
 #ifdef __APPLE__
   struct chain_elt {

Modified: branches/branch-1.3/FL/Fl_PostScript.H
===================================================================
--- branches/branch-1.3/FL/Fl_PostScript.H      2010-12-12 11:19:12 UTC (rev 
8016)
+++ branches/branch-1.3/FL/Fl_PostScript.H      2010-12-12 16:13:55 UTC (rev 
8017)
@@ -35,8 +35,6 @@
 #include <FL/Fl_Paged_Device.H>
 #include <FL/fl_draw.H>
 
-#define NO_PAGE_FORMATS 30 /* MSVC6 compilation fix */
-
 /**
  \brief PostScript graphical backend.
  *
@@ -66,58 +64,10 @@
 class Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
 public: 
   static const char *device_type;
-  /**
-   \brief Possible page formats.
-   */
-  enum Page_Format {
-    A0 = 0,
-    A1,
-    A2,
-    A3,
-    A4,
-    A5,
-    A6,
-    A7,
-    A8,
-    A9,
-    B0,
-    B1,
-    B2,
-    B3,
-    B4,
-    B5,
-    B6,
-    B7,
-    B8,
-    B9,
-    B10,
-    C5E,
-    DLE,
-    EXECUTIVE,
-    FOLIO,
-    LEDGER,
-    LEGAL,
-    LETTER,
-    TABLOID,
-    ENVELOPE,
-    MEDIA = 0x1000
-  };
-  
-  /**
-   \brief Possible page layouts.
-   */
-  enum Page_Layout {PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, 
ORIENTATION = 0x300};
-    
 #ifndef FL_DOXYGEN
 public:
   enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
   
-typedef struct page_format {
-  int width;
-  int height;
-  const char *name;
-} page_format;
-  
 class Clip {
   public:
     int x, y, w, h;
@@ -162,10 +112,9 @@
  
   FILE *output;
   double pw_, ph_;
-  static const page_format page_formats[NO_PAGE_FORMATS];
   
   uchar bg_r, bg_g, bg_b;
-  int start_postscript (int pagecount, enum Page_Format format, enum 
Page_Layout layout);
+  int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format 
format, enum Fl_Paged_Device::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); };
@@ -178,7 +127,7 @@
   void draw_scaled_image(Fl_Draw_Image_Cb call, void *data, double x, double 
y, double w, double h, int iw, int ih, int D);
   void draw_scaled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, 
double y, double w, double h, int iw, int ih, int D);
   
-  enum Page_Format page_format_;
+  enum Fl_Paged_Device::Page_Format page_format_;
   char *ps_filename_;
   // implementation of drawing methods
   void color(Fl_Color c);
@@ -280,10 +229,10 @@
   static const char *device_type;
   Fl_PostScript_File_Device();
   ~Fl_PostScript_File_Device();
-  int start_job(int pagecount, enum Fl_PostScript_Graphics_Driver::Page_Format 
format = Fl_PostScript_Graphics_Driver::A4, 
-               enum Fl_PostScript_Graphics_Driver::Page_Layout layout = 
Fl_PostScript_Graphics_Driver::PORTRAIT);
-  int start_job(FILE *ps_output, int pagecount, enum 
Fl_PostScript_Graphics_Driver::Page_Format format = 
Fl_PostScript_Graphics_Driver::A4, 
-               enum Fl_PostScript_Graphics_Driver::Page_Layout layout = 
Fl_PostScript_Graphics_Driver::PORTRAIT);
+  int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = 
Fl_Paged_Device::A4, 
+               enum Fl_Paged_Device::Page_Layout layout = 
Fl_Paged_Device::PORTRAIT);
+  int start_job(FILE *ps_output, int pagecount, enum 
Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, 
+               enum Fl_Paged_Device::Page_Layout layout = 
Fl_Paged_Device::PORTRAIT);
   int start_page (void);
   int printable_rect(int *w, int *h);
   void margins(int *left, int *top, int *right, int *bottom);

Modified: branches/branch-1.3/FL/Fl_Printer.H
===================================================================
--- branches/branch-1.3/FL/Fl_Printer.H 2010-12-12 11:19:12 UTC (rev 8016)
+++ branches/branch-1.3/FL/Fl_Printer.H 2010-12-12 16:13:55 UTC (rev 8017)
@@ -239,28 +239,6 @@
 };
 #endif
 
-/**
- This plugin socket allows the integration of new device drivers for special
- window or screen types. It is currently used to provide an automated printing
- service for OpenGL windows, if linked with fltk_gl.
- */
-class Fl_Device_Plugin : public Fl_Plugin {
-public:
-  /** \brief The constructor */
-  Fl_Device_Plugin(const char *name)
-  : Fl_Plugin(klass(), name) { }
-  /** \brief Returns the class name */
-  virtual const char *klass() { return "fltk:device"; }
-  /** \brief Returns the plugin name */
-  virtual const char *name() = 0;
-  /** \brief Prints a widget 
-   \param w the widget
-   \param x,y offsets where to print relatively to coordinates origin
-   \param height height of the current drawing area
-   */
-  virtual int print(Fl_Widget* w, int x, int y, int height) { return 0; }
-};
-
 #endif // Fl_Printer_H
 
 //

Modified: branches/branch-1.3/src/Fl_Paged_Device.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Paged_Device.cxx 2010-12-12 11:19:12 UTC (rev 
8016)
+++ branches/branch-1.3/src/Fl_Paged_Device.cxx 2010-12-12 16:13:55 UTC (rev 
8017)
@@ -28,8 +28,9 @@
  \brief implementation of class Fl_Paged_Device.
  */
 
+#include <FL/Fl_Paged_Device.H>
 #include <FL/Fl.H>
-#include <FL/Fl_Printer.H>
+#include <FL/fl_draw.H>
 
 const char *Fl_Paged_Device::device_type = "Fl_Paged_Device";
 
@@ -286,6 +287,47 @@
  */
 void Fl_Paged_Device::untranslate(void) {}
 
+const Fl_Paged_Device::page_format 
Fl_Paged_Device::page_formats[NO_PAGE_FORMATS] = { 
+  // order of enum Page_Format
+  // comes from appendix B of 5003.PPD_Spec_v4.3.pdf
+  
+  // A* // index(Ai) = i
+  {2384, 3370, "A0"},
+  {1684, 2384, "A1"},
+  {1191, 1684, "A2"},
+  { 842, 1191, "A3"},
+  { 595,  842, "A4"},
+  { 420,  595, "A5"},
+  { 297,  420, "A6"},
+  { 210,  297, "A7"},
+  { 148,  210, "A8"},
+  { 105,  148, "A9"},
+  
+  // B* // index(Bi) = i+10
+  {2920, 4127, "B0"},
+  {2064, 2920, "B1"},
+  {1460, 2064, "B2"},
+  {1032, 1460, "B3"},
+  { 729, 1032, "B4"},
+  { 516,  729, "B5"},
+  { 363,  516, "B6"},
+  { 258,  363, "B7"},
+  { 181,  258, "B8"},
+  { 127,  181, "B9"},
+  {  91,  127, "B10"},
+  
+  // others
+  { 459,  649, "EnvC5"}, // envelope
+  { 312,  624, "EnvDL"}, // envelope
+  { 522,  756, "Executive"},
+  { 595,  935, "Folio"},
+  {1224,  792, "Ledger"}, // landscape
+  { 612, 1008, "Legal"},
+  { 612,  792, "Letter"},
+  { 792, 1224, "Tabloid"},
+  { 297,  684, "Env10"} // envelope
+};
+
 //
 // End of "$Id$".
 //

Modified: branches/branch-1.3/src/Fl_PostScript.cxx
===================================================================
--- branches/branch-1.3/src/Fl_PostScript.cxx   2010-12-12 11:19:12 UTC (rev 
8016)
+++ branches/branch-1.3/src/Fl_PostScript.cxx   2010-12-12 16:13:55 UTC (rev 
8017)
@@ -87,7 +87,8 @@
  @param layout Desired page layout.
  @return 0 iff OK, 1 if user cancelled the file dialog, 2 if fopen failed on 
user-selected output file.
  */
-int Fl_PostScript_File_Device::start_job (int pagecount, enum 
Fl_PostScript_Graphics_Driver::Page_Format format, enum 
Fl_PostScript_Graphics_Driver::Page_Layout layout)
+int Fl_PostScript_File_Device::start_job (int pagecount, enum 
Fl_Paged_Device::Page_Format format, 
+                                         enum Fl_Paged_Device::Page_Layout 
layout)
 {
   Fl_Native_File_Chooser fnfc;
   fnfc.title(Fl_PostScript_File_Device::file_chooser_title);
@@ -120,7 +121,8 @@
  @param layout Desired page layout.
  @return always 0.
  */
-int Fl_PostScript_File_Device::start_job (FILE *ps_output, int pagecount, enum 
Fl_PostScript_Graphics_Driver::Page_Format format, enum 
Fl_PostScript_Graphics_Driver::Page_Layout layout)
+int Fl_PostScript_File_Device::start_job (FILE *ps_output, int pagecount, 
+    enum Fl_Paged_Device::Page_Format format, enum 
Fl_Paged_Device::Page_Layout layout)
 {
   Fl_PostScript_Graphics_Driver *ps = driver();
   ps->output = ps_output;
@@ -145,46 +147,6 @@
   #include "print_panel.cxx"
 #endif
 
-const Fl_PostScript_Graphics_Driver::page_format 
Fl_PostScript_Graphics_Driver::page_formats[NO_PAGE_FORMATS] = { // order of 
enum Page_Format
-// comes from appendix B of 5003.PPD_Spec_v4.3.pdf
-
-  // A* // index(Ai) = i
-  {2384, 3370, "A0"},
-  {1684, 2384, "A1"},
-  {1191, 1684, "A2"},
-  { 842, 1191, "A3"},
-  { 595,  842, "A4"},
-  { 420,  595, "A5"},
-  { 297,  420, "A6"},
-  { 210,  297, "A7"},
-  { 148,  210, "A8"},
-  { 105,  148, "A9"},
-
-  // B* // index(Bi) = i+10
-  {2920, 4127, "B0"},
-  {2064, 2920, "B1"},
-  {1460, 2064, "B2"},
-  {1032, 1460, "B3"},
-  { 729, 1032, "B4"},
-  { 516,  729, "B5"},
-  { 363,  516, "B6"},
-  { 258,  363, "B7"},
-  { 181,  258, "B8"},
-  { 127,  181, "B9"},
-  {  91,  127, "B10"},
-
-  // others
-  { 459,  649, "EnvC5"}, // envelope
-  { 312,  624, "EnvDL"}, // envelope
-  { 522,  756, "Executive"},
-  { 595,  935, "Folio"},
-  {1224,  792, "Ledger"}, // landscape
-  { 612, 1008, "Legal"},
-  { 612,  792, "Letter"},
-  { 792, 1224, "Tabloid"},
-  { 297,  684, "Env10"} // envelope
-};
-
 //  Prolog string 
 
 static const char * prolog =
@@ -566,11 +528,12 @@
 
 // end prolog 
 
-int Fl_PostScript_Graphics_Driver::start_postscript (int pagecount, enum 
Fl_PostScript_Graphics_Driver::Page_Format format, enum 
Fl_PostScript_Graphics_Driver::Page_Layout layout)
+int Fl_PostScript_Graphics_Driver::start_postscript (int pagecount, 
+    enum Fl_Paged_Device::Page_Format format, enum 
Fl_Paged_Device::Page_Layout layout)
 //returns 0 iff OK
 {
   int w, h, x;
-  if (format == A4) {
+  if (format == Fl_Paged_Device::A4) {
     left_margin = 18;
     top_margin = 18;
   }
@@ -578,7 +541,7 @@
     left_margin = 12;
     top_margin = 12;
   }
-  page_format_ = (enum Page_Format)(format | layout);
+  page_format_ = (enum Fl_Paged_Device::Page_Format)(format | layout);
   
   fputs("%!PS-Adobe-3.0\n", output);
   fputs("%%Creator: FLTK\n", output);
@@ -588,10 +551,10 @@
     fprintf(output, "%%%%Pages: %i\n", pagecount);
   else
     fputs("%%Pages: (atend)\n", output);
-  fprintf(output, "%%%%BeginFeature: *PageSize %s\n", 
page_formats[format].name );
-  w = page_formats[format].width;
-  h = page_formats[format].height;
-  if (lang_level_ == 3 && (layout & LANDSCAPE) ) { x = w; w = h; h = x; }
+  fprintf(output, "%%%%BeginFeature: *PageSize %s\n", 
Fl_Paged_Device::page_formats[format].name );
+  w = Fl_Paged_Device::page_formats[format].width;
+  h = Fl_Paged_Device::page_formats[format].height;
+  if (lang_level_ == 3 && (layout & Fl_Paged_Device::LANDSCAPE) ) { x = w; w = 
h; h = x; }
   fprintf(output, "<</PageSize[%d %d]>>setpagedevice\n", w, h );
   fputs("%%EndFeature\n", output);
   fputs("%%EndComments\n", output);
@@ -672,8 +635,8 @@
   }
   
   fprintf(output, "%%%%BeginPageSetup\n");
-  if((media & MEDIA) &&(lang_level_>1)){
-    int r = media & REVERSED;
+  if((media & Fl_Paged_Device::MEDIA) &&(lang_level_>1)){
+    int r = media & Fl_Paged_Device::REVERSED;
     if(r) r = 2;
     fprintf(output, "<< /PageSize [%i %i] /Orientation %i>> setpagedevice\n", 
(int)(pw+.5), (int)(ph+.5), r);
   }
@@ -690,9 +653,9 @@
   line_style(0);
   fprintf(output, "GS\n");
   
-  if (!((media & MEDIA) &&(lang_level_>1))){
+  if (!((media & Fl_Paged_Device::MEDIA) &&(lang_level_>1))){
     if (pw > ph) {
-      if(media & REVERSED) {
+      if(media & Fl_Paged_Device::REVERSED) {
         fprintf(output, "-90 rotate %i 0 translate\n", int(-pw));
        }
       else {
@@ -700,7 +663,7 @@
        }
       }
       else {
-       if(media & REVERSED)
+       if(media & Fl_Paged_Device::REVERSED)
          fprintf(output, "180 rotate %i %i translate\n", int(-pw), int(-ph));
        }
   }
@@ -710,12 +673,12 @@
 void Fl_PostScript_Graphics_Driver::page(int format){
   
   
-  if(format &  LANDSCAPE){
-    ph_=Fl_PostScript_Graphics_Driver::page_formats[format & 0xFF].width;
-    pw_=Fl_PostScript_Graphics_Driver::page_formats[format & 0xFF].height;
+  if(format &  Fl_Paged_Device::LANDSCAPE){
+    ph_=Fl_Paged_Device::page_formats[format & 0xFF].width;
+    pw_=Fl_Paged_Device::page_formats[format & 0xFF].height;
   }else{
-    pw_=Fl_PostScript_Graphics_Driver::page_formats[format & 0xFF].width;
-    ph_=Fl_PostScript_Graphics_Driver::page_formats[format & 0xFF].height;
+    pw_=Fl_Paged_Device::page_formats[format & 0xFF].width;
+    ph_=Fl_Paged_Device::page_formats[format & 0xFF].height;
   }
   page(pw_,ph_,format & 0xFF00);//,orientation only;
 }
@@ -1488,8 +1451,8 @@
 
 #if ! (defined(__APPLE__) || defined(WIN32) )
 int Fl_Printer::start_job(int pages, int *firstpage, int *lastpage) {
-  enum Fl_PostScript_Graphics_Driver::Page_Format format;
-  enum Fl_PostScript_Graphics_Driver::Page_Layout layout;
+  enum Fl_Paged_Device::Page_Format format;
+  enum Fl_Paged_Device::Page_Layout layout;
 
   // first test version for print dialog
   if (!print_panel) make_print_panel();
@@ -1507,7 +1470,7 @@
 
   // get options
 
-  format = print_page_size->value() ? Fl_PostScript_Graphics_Driver::A4 : 
Fl_PostScript_Graphics_Driver::LETTER;
+  format = print_page_size->value() ? Fl_Paged_Device::A4 : 
Fl_Paged_Device::LETTER;
   { // page range choice
     int from = 1, to = pages;
     if (print_pages->value()) {
@@ -1522,10 +1485,10 @@
     pages = to - from + 1;
   }
   
-  if (print_output_mode[0]->value()) layout = 
Fl_PostScript_Graphics_Driver::PORTRAIT;
-  else if (print_output_mode[1]->value()) layout = 
Fl_PostScript_Graphics_Driver::LANDSCAPE;
-  else if (print_output_mode[2]->value()) layout = 
Fl_PostScript_Graphics_Driver::PORTRAIT;
-  else layout = Fl_PostScript_Graphics_Driver::LANDSCAPE;
+  if (print_output_mode[0]->value()) layout = Fl_Paged_Device::PORTRAIT;
+  else if (print_output_mode[1]->value()) layout = Fl_Paged_Device::LANDSCAPE;
+  else if (print_output_mode[2]->value()) layout = Fl_Paged_Device::PORTRAIT;
+  else layout = Fl_Paged_Device::LANDSCAPE;
 
   int print_pipe = print_choice->value();      // 0 = print to file, >0 = 
printer (pipe)
 

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

Reply via email to