00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #ifndef _FL_PRINTER_H_
00023 #define _FL_PRINTER_H_
00024 
00025 #include "fl_draw.h"
00026 #include "Enumerations.h"
00027 
00028 const double FL_POINT = 1;
00029 const double FL_INCH = 72;
00030 const double FL_MM = 2.835;
00031 const double FL_CM = 28.35;
00032 const double FL_PICA = 12;
00033 
00034 const int NO_PAGE_FORMATS=30;
00035 
00037 class FL_API Fl_Printer : public Fl_Device {
00038 public:
00039     enum PAGE_FORMAT{
00040         USER, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
00041         B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10,
00042         C5E, DLE, EXECUTIVE, FOLIO, LEDGER, LEGAL,
00043         LETTER, TABLOID, ENVELOPE, NON_DEFINED = -1
00044     };
00045     enum PAGE_LAYOUT { PORTRAIT=0, LANDSCAPE=1 };
00046 
00047     static const int page_formats[NO_PAGE_FORMATS+1][2];
00048     virtual void page(double pw, double ph, int orientation) = 0;
00049     virtual void page(int format, int orientation) = 0;
00050     double page_width() const { return pw_; }
00051     double page_height() const { return ph_; }
00052     virtual void page() = 0;
00053     virtual void margins(double left, double top, double right, double bottom) = 0;
00054 
00055     virtual void fit(double x, double y, double w, double h, int align) = 0;
00056     virtual void fit(double x, double y, double w, double h, double dpi, int align) = 0;
00057     void fit(Fl_Widget * w, int align);
00058     void fit(Fl_Widget * w, double dpi, int align);
00059 
00060     virtual void place(double x, double y, double w, double h, double tx, double ty, double tw, double th, int align) = 0;
00061     virtual void place(double x, double y, double w, double h, double tx, double ty, double tw, double th, double dpi, int align) = 0;
00062     void place(Fl_Widget * w, double tx, double ty, double tw, double th, int align) { place(w->x(),w->y(),w->w(),w->h(), tx, ty, tw, th, align); }
00063     void place(Fl_Widget * w, double tx, double ty, double tw, double th, double dpi, int align) { place(w->x(),w->y(),w->w(),w->h(), tx, ty, tw, th, dpi, align); }
00064 
00065     Fl_Printer() : lm_(72),tm_(72),rm_(72),bm_(72),orientation_(0) { }
00066     virtual ~Fl_Printer() { }
00067 
00068     virtual void draw(Fl_Widget * w) = 0;
00069 
00070     virtual void draw(const char* s, float x, float y) { Fl_Device::draw(s, x, y); }
00071     virtual void draw(const Fl_String & s, float x, float y) { Fl_Device::draw(s, x, y); }
00072     virtual void draw(const char* s, int n, float x, float y) { Fl_Device::draw(s, n, x, y); }
00073 
00074 protected:
00075 
00076     int nPages;
00077     double lm_,tm_,rm_,bm_;
00078     double pw_, ph_;
00079     int orientation_;
00080 };
00081 
00082 #ifdef _WIN32
00083 
00084 #include "Fl_Gdi.h"
00085 #ifndef FL_PRINTER
00086 #define FL_GDI_PRINTER
00087 #define FL_PRINTER FL_GDI_PRINTER
00088 typedef Fl_Gdi_Settings Fl_Printer_Settings;
00089 inline Fl_Printer * fl_printer_chooser(Fl_Printer_Settings * s=0) {
00090     return fl_gdi_printer_chooser(s);
00091 }
00092 #endif
00093 
00094 #endif //_WIN32
00095 
00096 #endif // _FL_DEVICE_H_