FLTK 1.3.0
|
00001 // 00002 // "$Id: Fl_PostScript.H 8699 2011-05-20 16:39:06Z manolo $" 00003 // 00004 // Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK). 00005 // 00006 // Copyright 2010-2011 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 // 00032 #ifndef Fl_PostScript_H 00033 #define Fl_PostScript_H 00034 00035 #include <FL/Fl_Paged_Device.H> 00036 #include <FL/fl_draw.H> 00037 00064 class FL_EXPORT Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver { 00065 public: 00066 static const char *class_id; 00067 const char *class_name() {return class_id;}; 00068 Fl_PostScript_Graphics_Driver(); 00069 #ifndef FL_DOXYGEN 00070 enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS}; 00071 00072 class Clip { 00073 public: 00074 int x, y, w, h; 00075 Clip *prev; 00076 }; 00077 Clip * clip_; 00078 00079 int lang_level_; 00080 int gap_; 00081 int pages_; 00082 00083 double width_; 00084 double height_; 00085 00086 int shape_; 00087 int linewidth_;// need for clipping, lang level 1-2 00088 int linestyle_;// 00089 int interpolate_; //interpolation of images 00090 unsigned char cr_,cg_,cb_; 00091 char linedash_[256];//should be enough 00092 void concat(); // transform ror scalable dradings... 00093 void reconcat(); //invert 00094 void recover(); //recovers the state after grestore (such as line styles...) 00095 void reset(); 00096 00097 uchar * mask; 00098 int mx; // width of mask; 00099 int my; // mask lines 00100 //Fl_Color bg_; 00101 int (*close_cmd_)(FILE *); 00102 int page_policy_; 00103 int nPages; 00104 int orientation_; 00105 00106 float scale_x; 00107 float scale_y; 00108 float angle; 00109 int left_margin; 00110 int top_margin; 00111 00112 FILE *output; 00113 double pw_, ph_; 00114 00115 uchar bg_r, bg_g, bg_b; 00116 int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout); 00117 /* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0); 00118 */ 00119 void transformed_draw(const char* s, int n, double x, double y); //precise text placing 00120 void transformed_draw(const char* s, double x, double y); 00121 int alpha_mask(const uchar * data, int w, int h, int D, int LD=0); 00122 00123 enum Fl_Paged_Device::Page_Format page_format_; 00124 char *ps_filename_; 00125 00126 void page_policy(int p); 00127 int page_policy(){return page_policy_;}; 00128 void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;}; 00129 FILE * file() {return output;}; 00130 //void orientation (int o); 00131 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor 00132 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor 00133 void interpolate(int i){interpolate_=i;}; 00134 int interpolate(){return interpolate_;} 00135 00136 void page(double pw, double ph, int media = 0); 00137 void page(int format); 00138 #endif // FL_DOXYGEN 00139 00140 // implementation of drawing methods 00141 void color(Fl_Color c); 00142 void color(uchar r, uchar g, uchar b); 00143 00144 void push_clip(int x, int y, int w, int h); 00145 int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H); 00146 int not_clipped(int x, int y, int w, int h); 00147 void push_no_clip(); 00148 void pop_clip(); 00149 00150 void line_style(int style, int width=0, char* dashes=0); 00151 00152 void rect(int x, int y, int w, int h); 00153 void rectf(int x, int y, int w, int h); 00154 00155 void xyline(int x, int y, int x1); 00156 void xyline(int x, int y, int x1, int y2); 00157 void xyline(int x, int y, int x1, int y2, int x3); 00158 00159 void yxline(int x, int y, int y1); 00160 void yxline(int x, int y, int y1, int x2); 00161 void yxline(int x, int y, int y1, int x2, int y3); 00162 00163 void line(int x1, int y1, int x2, int y2); 00164 void line(int x1, int y1, int x2, int y2, int x3, int y3); 00165 00166 void loop(int x0, int y0, int x1, int y1, int x2, int y2); 00167 void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); 00168 void polygon(int x0, int y0, int x1, int y1, int x2, int y2); 00169 void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); 00170 void point(int x, int y); 00171 00172 void begin_points(); 00173 void begin_line(); 00174 void begin_loop(); 00175 void begin_polygon(); 00176 void vertex(double x, double y); 00177 void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3); 00178 void circle(double x, double y, double r); 00179 void arc(double x, double y, double r, double start, double a); 00180 void arc(int x, int y, int w, int h, double a1, double a2); 00181 void pie(int x, int y, int w, int h, double a1, double a2); 00182 void end_points(); 00183 void end_line(); 00184 void end_loop(); 00185 void end_polygon(); 00186 void begin_complex_polygon(){begin_polygon();}; 00187 void gap(){gap_=1;}; 00188 void end_complex_polygon(){end_polygon();}; 00189 void transformed_vertex(double x, double y); 00190 00191 void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0); 00192 void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0); 00193 void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3); 00194 void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1); 00195 00196 void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); }; 00197 #ifdef __APPLE__ 00198 void draw(const char* s, int n, float x, float y) {transformed_draw(s,n,x,y); }; 00199 #endif 00200 void draw(int angle, const char *str, int n, int x, int y); 00201 void rtl_draw(const char* s, int n, int x, int y); 00202 void font(int face, int size); 00203 double width(const char *, int); 00204 void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h); 00205 int height(); 00206 int descent(); 00207 void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy); 00208 void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy); 00209 void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy); 00210 ~Fl_PostScript_Graphics_Driver(); 00211 }; 00212 00216 class FL_EXPORT Fl_PostScript_File_Device : public Fl_Paged_Device { 00217 #ifdef __APPLE__ 00218 Fl_CGContextRef gc; 00219 #endif 00220 protected: 00221 Fl_PostScript_Graphics_Driver *driver(); 00222 public: 00223 static const char *class_id; 00224 const char *class_name() {return class_id;}; 00225 Fl_PostScript_File_Device(); 00226 ~Fl_PostScript_File_Device(); 00227 int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, 00228 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT); 00229 int start_job(FILE *ps_output, int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4, 00230 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT); 00231 int start_page (void); 00232 int printable_rect(int *w, int *h); 00233 void margins(int *left, int *top, int *right, int *bottom); 00234 void origin(int *x, int *y); 00235 void origin(int x, int y); 00236 void scale (float scale_x, float scale_y = 0.); 00237 void rotate(float angle); 00238 void translate(int x, int y); 00239 void untranslate(void); 00240 int end_page (void); 00241 void end_job(void); 00242 #ifdef __APPLE__ 00243 void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); } 00244 #endif 00245 00246 static const char *file_chooser_title; 00247 }; 00248 00249 #endif // Fl_PostScript_H 00250 00251 // 00252 // End of "$Id: Fl_PostScript.H 8699 2011-05-20 16:39:06Z manolo $" 00253 //