00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_POSTSCRIPT_H_
00023 #define _FL_POSTSCRIPT_H_
00024
00025 #include "Fl_String.h"
00026 #include "fl_draw.h"
00027 #include "Fl_Printer.h"
00028 #include "Enumerations.h"
00029 #include <stdio.h>
00030
00032 class FL_API Fl_PostScript : public Fl_Printer
00033 {
00034 enum SHAPE { NONE=0, LINE, LOOP, POLYGON, POINTS };
00035
00036 class Clip{
00037 public:
00038 int x, y, w, h;
00039 Clip *prev;
00040 };
00041 Clip *clip_;
00042
00043 int lang_level_;
00044 Fl_Font font_;
00045 float size_;
00046 Fl_Color color_;
00047 FILE *output;
00048
00049 double width_;
00050 double height_;
00051
00052 int shape_;
00053 int linewidth_;
00054 int linestyle_;
00055 int interpolate_;
00056 unsigned char cr_,cg_,cb_;
00057 char linedash_[256];
00058
00059 void recover();
00060 void reset();
00061
00062
00063 int colored_, line_styled_, fonted_;
00064
00065
00066
00067 uchar *mask;
00068 int mx;
00069 int my;
00070 Fl_Color bg_;
00071
00072 protected:
00073 int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
00074
00075 void transformed_draw(const char* s, int n, float x, float y);
00076 void transformed_draw(const char* s, float x, float y) { transformed_draw(s,strlen(s),x,y); }
00077
00078 void draw_scalled_image(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
00079 void draw_scalled_image_mono(const uchar *data, double x, double y, double w, double h, int iw, int ih, int D=3, int LD=0);
00080 void draw_scalled_image(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
00081 void draw_scalled_image_mono(Fl_Draw_Image_Cb call, void *data, double x, double y, double w, double h, int iw, int ih, int D);
00082
00083 public:
00084 void draw(Fl_Widget * w);
00085
00086 Fl_PostScript(FILE *o, int lang_level, int format = A4, int orientation = PORTRAIT);
00087 Fl_PostScript(FILE *o, int lang_level, double x, double y, double w, double h);
00088 virtual ~Fl_PostScript();
00089
00090 int capabilities() { return 0; }
00091
00092 void interpolate(int i) { interpolate_=i; }
00093 int interpolate() const { return interpolate_; }
00094
00095 void page(double pw, double ph, int orientation);
00096 void page(int format, int orientation);
00097 void page() { page(pw_,ph_,orientation_); }
00098 void margins(double left, double top, double right, double bottom);
00099
00100 void fit(double x, double y, double w, double h, int align=FL_ALIGN_CENTER);
00101 void fit(double x, double y, double w, double h, double dpi, int align=FL_ALIGN_CENTER);
00102
00103 void place(double x, double y, double w, double h, double tx, double ty, double tw, double th, int align);
00104 void place(double x, double y, double w, double h, double tx, double ty, double tw, double th, double dpi, int align);
00105
00107
00108 void color(Fl_Color c);
00109 void bg_color(Fl_Color bg);
00110 void color(uchar r, uchar g, uchar b);
00111 Fl_Color color() const { return color_; }
00112
00113 void push_clip(int x, int y, int w, int h);
00114 void clip_out(int x, int y, int w, int h);
00115 void push_no_clip();
00116 void pop_clip();
00117 int not_clipped(int x, int y, int w, int h);
00118 int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
00119
00120 void line_style(int style, int width, char* dashes);
00121
00122
00123 void push_matrix();
00124 void pop_matrix();
00125 void scale(float x, float y);
00126 void scale(float x);
00127 void translate(float x, float y);
00128 void translate(int x, int y);
00129 void rotate(float d);
00130 void mult_matrix(float a, float b, float c, float d, float e, float f);
00131 void load_identity();
00132
00133
00134 void transform(float& x, float& y);
00135 void transform(int& x, int& y);
00136 void transform_distance(float& x, float& y);
00137
00138 void curve(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3);
00139
00140 void arc(float x, float y, float w, float h, float start, float end);
00141 void pie(int x, int y, int w, int h, float a1, float a2, int what);
00142 void circle(float x, float y, float r);
00143 void ellipse(float x, float y, float w, float h);
00144
00145 void rect(int x, int y, int w, int h);
00146 void rectf(int x, int y, int w, int h);
00147 void point(int x, int y);
00148 void line(int x1, int y1, int x2, int y2);
00149
00150 void points();
00151 void stroke();
00152 void fill();
00153 void fill_stroke(Fl_Color);
00154
00155 void newpath();
00156 void vertex(float x, float y);
00157 void vertex(int x, int y);
00158 void vertices(int n, const float v[][2]);
00159 void vertices(int n, const int v[][2]);
00160 void transformed_vertices(int n, const float v[][2]);
00161 void closepath();
00162
00163 void font(Fl_Font face, float size);
00164 void font(const char* s, float size);
00165 void font(const char* s, int attributes, float size);
00166
00167 Fl_Font font() const { return font_; }
00168 float size() const { return size_; }
00169
00170 void encoding(const char*);
00171 const char* encoding() const;
00172
00173 const char* fontname(Fl_Font, int * = 0);
00174
00175 float width(unsigned int ucs) const;
00176 float width(const char* s) const;
00177 float width(const Fl_String& s) const;
00178 float width(const char* s, int n) const;
00179
00180 float height() const;
00181 float descent() const;
00182
00183 void rtl_draw(const char *s, int n, float x, float y);
00184 void draw(const char* s, int n, float x, float y) { transformed_draw(s,n,x,y); }
00185 void draw(const Fl_String &s, float x, float y) { draw(s.c_str(), s.length(), x, y); }
00186 void draw(const char* s, float x, float y) { draw(s,strlen(s),x,y); }
00187
00188 void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0){draw_scalled_image(d,x,y,w,h,w,h,delta,ldelta);}
00189 void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0){draw_scalled_image_mono(d,x,y,w,h,w,h,delta,ld);}
00190
00191 void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3){draw_scalled_image(call,data, x, y, w, h, w, h, delta);}
00192
00193 void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1){draw_scalled_image_mono(call, data, x, y, w, h, w, h, delta);}
00194
00195 void rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b);
00196 void rectf(int x, int y, int w, int h, Fl_Color c) { uchar r, g, b; fl_get_color(c, r, g, b); rectf(x, y, w, h, r, g, b); }
00197
00199
00200 Fl_PostScript(FILE *o, int lang_level, double pw, double ph, int orientation);
00201 };
00202
00203
00204
00205 #endif