00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
00065 public:
00066 static const char *device_type;
00067 #ifndef FL_DOXYGEN
00068 public:
00069 enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
00070
00071 class Clip {
00072 public:
00073 int x, y, w, h;
00074 Clip *prev;
00075 };
00076 Clip * clip_;
00077
00078 int lang_level_;
00079 int font_;
00080 int size_;
00081 int gap_;
00082 int pages_;
00083
00084 double width_;
00085 double height_;
00086
00087 int shape_;
00088 int linewidth_;
00089 int linestyle_;
00090 int interpolate_;
00091 unsigned char cr_,cg_,cb_;
00092 char linedash_[256];
00093 void concat();
00094 void reconcat();
00095 void recover();
00096 void reset();
00097
00098 uchar * mask;
00099 int mx;
00100 int my;
00101
00102 int (*close_cmd_)(FILE *);
00103 int page_policy_;
00104 int nPages;
00105 int orientation_;
00106
00107 float scale_x;
00108 float scale_y;
00109 float angle;
00110 int left_margin;
00111 int top_margin;
00112
00113 FILE *output;
00114 double pw_, ph_;
00115
00116 uchar bg_r, bg_g, bg_b;
00117 int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout);
00118
00119
00120 void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
00121 void draw(int angle, const char *str, int n, int x, int y);
00122 void transformed_draw(const char* s, int n, double x, double y);
00123 void transformed_draw(const char* s, double x, double y);
00124 int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
00125 void draw_scaled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
00126 void draw_scaled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
00127 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);
00128 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);
00129
00130 enum Fl_Paged_Device::Page_Format page_format_;
00131 char *ps_filename_;
00132
00133 void color(Fl_Color c);
00134 void color(uchar r, uchar g, uchar b);
00135
00136 void push_clip(int x, int y, int w, int h);
00137 int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
00138 int not_clipped(int x, int y, int w, int h);
00139 void push_no_clip();
00140 void pop_clip();
00141
00142 void line_style(int style, int width=0, char* dashes=0);
00143
00144 void rect(int x, int y, int w, int h);
00145 void rectf(int x, int y, int w, int h);
00146
00147 void xyline(int x, int y, int x1);
00148 void xyline(int x, int y, int x1, int y2);
00149 void xyline(int x, int y, int x1, int y2, int x3);
00150
00151 void yxline(int x, int y, int y1);
00152 void yxline(int x, int y, int y1, int x2);
00153 void yxline(int x, int y, int y1, int x2, int y3);
00154
00155 void line(int x1, int y1, int x2, int y2);
00156 void line(int x1, int y1, int x2, int y2, int x3, int y3);
00157
00158 void loop(int x0, int y0, int x1, int y1, int x2, int y2);
00159 void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
00160 void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
00161 void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
00162 void point(int x, int y);
00163
00164 void begin_points();
00165 void begin_line();
00166 void begin_loop();
00167 void begin_polygon();
00168 void vertex(double x, double y);
00169 void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
00170 void circle(double x, double y, double r);
00171 void arc(double x, double y, double r, double start, double a);
00172 void arc(int x, int y, int w, int h, double a1, double a2);
00173 void pie(int x, int y, int w, int h, double a1, double a2);
00174 void end_points();
00175 void end_line();
00176 void end_loop();
00177 void end_polygon();
00178 void begin_complex_polygon(){begin_polygon();};
00179 void gap(){gap_=1;};
00180 void end_complex_polygon(){end_polygon();};
00181 void transformed_vertex(double x, double y);
00182
00183 void font(int face, int size);
00184 int font(){return font_;};
00185 int size(){return size_;};
00186 double width(unsigned c);
00187 double width(const char* s, int n);
00188 int descent();
00189 int height();
00190
00191 void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0){draw_scaled_image(d,x,y,w,h,w,h,delta,ldelta);};
00192 void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0){draw_scaled_image_mono(d,x,y,w,h,w,h,delta,ld);};
00193 void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3){draw_scaled_image(call,data, x, y, w, h, w, h, delta);};
00194 void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1){draw_scaled_image_mono(call, data, x, y, w, h, w, h, delta);};
00195
00196 public:
00197 void page_policy(int p);
00198 int page_policy(){return page_policy_;};
00199 void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
00200 FILE * file() {return output;};
00201
00202
00203
00204 void interpolate(int i){interpolate_=i;};
00205 int interpolate(){return interpolate_;}
00206
00207 void page(double pw, double ph, int media = 0);
00208 void page(int format);
00209
00210 void place(double x, double y, double tx, double ty, double scale = 1);
00211 #endif // FL_DOXYGEN
00212 Fl_PostScript_Graphics_Driver();
00213 void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
00214 void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
00215 void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
00216 ~Fl_PostScript_Graphics_Driver();
00217 };
00218
00222 class Fl_PostScript_File_Device : public Fl_Paged_Device {
00223 #ifdef __APPLE__
00224 Fl_CGContextRef gc;
00225 #endif
00226 protected:
00227 Fl_PostScript_Graphics_Driver *driver();
00228 public:
00229 static const char *device_type;
00230 Fl_PostScript_File_Device();
00231 ~Fl_PostScript_File_Device();
00232 int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
00233 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT);
00234 int start_job(FILE *ps_output, int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
00235 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT);
00236 int start_page (void);
00237 int printable_rect(int *w, int *h);
00238 void margins(int *left, int *top, int *right, int *bottom);
00239 void origin(int x, int y);
00240 void scale (float scale_x, float scale_y);
00241 void rotate(float angle);
00242 void translate(int x, int y);
00243 void untranslate(void);
00244 int end_page (void);
00245 void end_job(void);
00246 #ifdef __APPLE__
00247 void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); }
00248 #endif
00249
00250 static const char *file_chooser_title;
00251 };
00252
00253 #endif // Fl_PostScript_H
00254
00255
00256
00257