FLTK 1.3.0
Fl_Printer.H
Go to the documentation of this file.
00001 //
00002 // "$Id$"
00003 //
00004 // Printing support for the Fast Light Tool Kit (FLTK).
00005 //
00006 // Copyright 2010 by Bill Spitzak and others.
00007 //
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU Library General Public
00010 // License as published by the Free Software Foundation; either
00011 // version 2 of the License, or (at your option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 // Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public
00019 // License along with this library; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021 // USA.
00022 //
00023 // Please report all bugs and problems on the following page:
00024 //
00025 //     http://www.fltk.org/str.php
00026 //
00031 #ifndef Fl_Printer_H
00032 #define Fl_Printer_H
00033 
00034 #include <FL/x.H>
00035 #include <FL/Fl_Paged_Device.H>
00036 #include <FL/fl_draw.H>
00037 #include <FL/Fl_Pixmap.H>
00038 #include <FL/Fl_RGB_Image.H>
00039 #include <FL/Fl_Bitmap.H>
00040 #include <stdio.h>
00041 #if !(defined(__APPLE__) || defined(WIN32))
00042 #include <FL/Fl_PostScript.H>
00043 #elif defined(WIN32)
00044 #include <commdlg.h>
00045 #endif
00046 
00047 #if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN)
00048 
00055 class Fl_System_Printer : public Fl_Paged_Device {
00056   friend class Fl_Printer;
00057 private:
00059   void *gc; 
00060   void set_current(void);
00061 #ifdef __APPLE__
00062   float scale_x;
00063   float scale_y;
00064   float angle; // rotation angle in radians
00065   Fl_PMPrintSession  printSession;
00066   Fl_PMPageFormat    pageFormat;
00067   Fl_PMPrintSettings printSettings;
00068 #elif defined(WIN32)
00069   int   abortPrint;
00070   PRINTDLG      pd;
00071   HDC           hPr;
00072   int           prerr;
00073   int left_margin;
00074   int top_margin;
00075   void absolute_printable_rect(int *x, int *y, int *w, int *h);
00076 #endif
00077 protected:
00079   Fl_System_Printer(void);
00080 public:
00081   static const char *class_id;
00082   const char *class_name() {return class_id;};
00083   int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
00084   int start_page (void);
00085   int printable_rect(int *w, int *h);
00086   void margins(int *left, int *top, int *right, int *bottom);
00087   void origin(int *x, int *y);
00088   void origin(int x, int y);
00089   void scale (float scale_x, float scale_y = 0.);
00090   void rotate(float angle);
00091   void translate(int x, int y);
00092   void untranslate(void);
00093   int end_page (void);
00094   void end_job (void);
00096   ~Fl_System_Printer(void);
00097 }; // class Fl_System_Printer
00098 
00099 #endif
00100   
00101 #if !(defined(__APPLE__) || defined(WIN32) )
00102 
00109 class Fl_PostScript_Printer : public Fl_PostScript_File_Device {
00110   friend class Fl_Printer;
00111 protected:
00113   Fl_PostScript_Printer(void) {};
00114 public:
00115   static const char *class_id;
00116   const char *class_name() {return class_id;};
00117   int start_job(int pages, int *firstpage = NULL, int *lastpage = NULL);
00118 };
00119 
00120 #endif
00121 
00154 class Fl_Printer : public Fl_Paged_Device {
00155 public:
00156   static const char *class_id;
00157   const char *class_name() {return class_id;};
00159   Fl_Printer(void);
00160   int start_job(int pagecount, int *frompage = NULL, int *topage = NULL);
00161   int start_page(void);
00162   int printable_rect(int *w, int *h);
00163   void margins(int *left, int *top, int *right, int *bottom);
00164   void origin(int *x, int *y);
00165   void origin(int x, int y);
00166   void scale(float scale_x, float scale_y = 0.);
00167   void rotate(float angle);
00168   void translate(int x, int y);
00169   void untranslate(void);
00170   int end_page (void);
00171   void end_job (void);
00172   void print_widget(Fl_Widget* widget, int delta_x=0, int delta_y=0);
00173   void print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x=0, int delta_y=0);
00174   void set_current(void);
00175   Fl_Graphics_Driver* driver(void);
00177   ~Fl_Printer(void);
00178  
00182   static const char *dialog_title; 
00183   static const char *dialog_printer; 
00184   static const char *dialog_range; 
00185   static const char *dialog_copies; 
00186   static const char *dialog_all; 
00187   static const char *dialog_pages;
00188   static const char *dialog_from;
00189   static const char *dialog_to;
00190   static const char *dialog_properties;
00191   static const char *dialog_copyNo;
00192   static const char *dialog_print_button;
00193   static const char *dialog_cancel_button;
00194   static const char *dialog_print_to_file;
00195   static const char *property_title;
00196   static const char *property_pagesize;
00197   static const char *property_mode;
00198   static const char *property_use;
00199   static const char *property_save;
00200   static const char *property_cancel;
00202 private:
00203 #if defined(WIN32) || defined(__APPLE__)
00204   Fl_System_Printer *printer;
00205 #else
00206   Fl_PostScript_Printer *printer;
00207 #endif
00208 };
00209 
00210 #endif // Fl_Printer_H
00211 
00212 //
00213 // End of "$Id$"
00214 //