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