FLTK 1.3.3: Fl_PostScript.H Source File

FLTK 1.3.3

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_PostScript.H
Go to the documentation of this file.
1 //
2 // "$Id: Fl_PostScript.H 10308 2014-09-13 17:51:20Z manolo $"
3 //
4 // Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 2010-2011 by Bill Spitzak and others.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18
23 #ifndef Fl_PostScript_H
24 #define Fl_PostScript_H
25
26 #include <FL/Fl_Paged_Device.H>
27 #include <FL/fl_draw.H>
28 #include <stdarg.h>
29
58 extern "C" {
59 typedef int (Fl_PostScript_Close_Command)(FILE *);
60 }
61
62 class FL_EXPORT Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
63 public:
64 static const char *class_id;
65 const char *class_name() {return class_id;};
66 Fl_PostScript_Graphics_Driver();
67 #ifndef FL_DOXYGEN
68 enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
69
70 class Clip {
71 public:
72 int x, y, w, h;
73 Clip *prev;
74 };
75 Clip * clip_;
76
77 int lang_level_;
78 int gap_;
79 int pages_;
80
81 double width_;
82 double height_;
83
84 int shape_;
85 int linewidth_;// need for clipping, lang level 1-2
86 int linestyle_;//
87 int interpolate_; //interpolation of images
88 unsigned char cr_,cg_,cb_;
89 char linedash_[256];//should be enough
90 void concat(); // transform ror scalable dradings...
91 void reconcat(); //invert
92 void recover(); //recovers the state after grestore (such as line styles...)
93 void reset();
94
95 uchar * mask;
96 int mx; // width of mask;
97 int my; // mask lines
98 //Fl_Color bg_;
99 Fl_PostScript_Close_Command* close_cmd_;
100 int page_policy_;
101 int nPages;
102 int orientation_;
103
104 float scale_x;
105 float scale_y;
106 float angle;
107 int left_margin;
108 int top_margin;
109
110 FILE *output;
111 double pw_, ph_;
112
113 uchar bg_r, bg_g, bg_b;
114 int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout);
115 /* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
116 */
117 void transformed_draw(const char* s, int n, double x, double y); //precise text placing
118 void transformed_draw(const char* s, double x, double y);
119 int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
120
121 enum Fl_Paged_Device::Page_Format page_format_;
122 char *ps_filename_;
123
124 void page_policy(int p);
125 int page_policy(){return page_policy_;};
126 void close_command(Fl_PostScript_Close_Command* cmd){close_cmd_=cmd;};
127 FILE * file() {return output;};
128 //void orientation (int o);
129 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
130 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
131 void interpolate(int i){interpolate_=i;};
132 int interpolate(){return interpolate_;}
133
134 void page(double pw, double ph, int media = 0);
135 void page(int format);
136 #endif // FL_DOXYGEN
137
138 // implementation of drawing methods
139 void color(Fl_Color c);
140 void color(uchar r, uchar g, uchar b);
141
142 void push_clip(int x, int y, int w, int h);
143 int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
144 int not_clipped(int x, int y, int w, int h);
145 void push_no_clip();
146 void pop_clip();
147
148 void line_style(int style, int width=0, char* dashes=0);
149
150 void rect(int x, int y, int w, int h);
151 void rectf(int x, int y, int w, int h);
152
153 void xyline(int x, int y, int x1);
154 void xyline(int x, int y, int x1, int y2);
155 void xyline(int x, int y, int x1, int y2, int x3);
156
157 void yxline(int x, int y, int y1);
158 void yxline(int x, int y, int y1, int x2);
159 void yxline(int x, int y, int y1, int x2, int y3);
160
161 void line(int x1, int y1, int x2, int y2);
162 void line(int x1, int y1, int x2, int y2, int x3, int y3);
163
164 void loop(int x0, int y0, int x1, int y1, int x2, int y2);
165 void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
166 void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
167 void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
168 void point(int x, int y);
169
170 void begin_points();
171 void begin_line();
172 void begin_loop();
173 void begin_polygon();
174 void vertex(double x, double y);
175 void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
176 void circle(double x, double y, double r);
177 void arc(double x, double y, double r, double start, double a);
178 void arc(int x, int y, int w, int h, double a1, double a2);
179 void pie(int x, int y, int w, int h, double a1, double a2);
180 void end_points();
181 void end_line();
182 void end_loop();
183 void end_polygon();
184 void begin_complex_polygon(){begin_polygon();};
185 void gap(){gap_=1;};
186 void end_complex_polygon(){end_polygon();};
187 void transformed_vertex(double x, double y);
188
189 void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0);
190 void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0);
191 void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3);
192 void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1);
193
194 void draw(const char* s, int nBytes, int x, int y) {transformed_draw(s,nBytes,x,y); };
195 #ifdef __APPLE__
196 void draw(const char* s, int nBytes, float x, float y) {transformed_draw(s,nBytes,x,y); };
197 #endif
198 void draw(int angle, const char *str, int n, int x, int y);
199 void rtl_draw(const char* s, int n, int x, int y);
200 void font(int face, int size);
201 double width(const char *, int);
202 double width(unsigned int u);
203 void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h);
204 int height();
205 int descent();
206 void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
207 void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
208 void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
209 int clocale_printf(const char *format, ...);
210 ~Fl_PostScript_Graphics_Driver();
211 };
212
216 class FL_EXPORT Fl_PostScript_File_Device : public Fl_Paged_Device {
217 #ifdef __APPLE__
218 CGContextRef gc;
219 #endif
220 protected:
221 Fl_PostScript_Graphics_Driver *driver();
222 public:
223 static const char *class_id;
224 const char *class_name() {return class_id;};
225 Fl_PostScript_File_Device();
226 ~Fl_PostScript_File_Device();
227 int start_job(int pagecount, int* from, int* to);
228 int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
229 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT);
230 int start_job(FILE *ps_output, int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
231 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT);
232 int start_page (void);
233 int printable_rect(int *w, int *h);
234 void margins(int *left, int *top, int *right, int *bottom);
235 void origin(int *x, int *y);
236 void origin(int x, int y);
237 void scale (float scale_x, float scale_y = 0.);
238 void rotate(float angle);
239 void translate(int x, int y);
240 void untranslate(void);
241 int end_page (void);
242 void end_job(void);
243 #ifdef __APPLE__
244 void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); }
245 #endif
246
247 static const char *file_chooser_title;
248 };
249
250 #endif // Fl_PostScript_H
251
252 //
253 // End of "$Id: Fl_PostScript.H 10308 2014-09-13 17:51:20Z manolo $"
254 //
Fl_PostScript_File_Device::class_name
const char * class_name()
Returns the name of the class of this object.
Definition: Fl_PostScript.H:224
Fl_Graphics_Driver::begin_points
virtual void begin_points()
see fl_begin_points().
Definition: fl_vertex.cxx:75
Fl_Paged_Device::start_job
virtual int start_job(int pagecount, int *frompage=NULL, int *topage=NULL)
Starts a print job.
Definition: Fl_Paged_Device.cxx:156
Fl_Graphics_Driver::begin_loop
virtual void begin_loop()
see fl_begin_loop().
Definition: fl_vertex.cxx:79
Fl_Paged_Device
Represents page-structured drawing surfaces.
Definition: Fl_Paged_Device.H:38
Fl_Pixmap
The Fl_Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency...
Definition: Fl_Pixmap.H:41
Fl_Graphics_Driver::text_extents
virtual void text_extents(const char *, int n, int &dx, int &dy, int &w, int &h)
see fl_text_extents(const char*, int n, int& dx, int& dy, int& w, int& h).
Definition: Fl_Device.cxx:64
Fl_Paged_Device::margins
virtual void margins(int *left, int *top, int *right, int *bottom)
Computes the dimensions of margins that lie between the printable page area and the full page...
Definition: Fl_Paged_Device.cxx:188
Fl_PostScript_Close_Command
int( Fl_PostScript_Close_Command)(FILE *)
PostScript graphical backend.
Definition: Fl_PostScript.H:59
Fl_Graphics_Driver::pop_clip
virtual void pop_clip()
see fl_pop_clip().
Definition: fl_rect.cxx:597
Fl_Graphics_Driver::rect
virtual void rect(int x, int y, int w, int h)
see fl_rect(int x, int y, int w, int h).
Definition: fl_rect.cxx:158
Fl_PostScript_Graphics_Driver::draw
void draw(const char *s, int nBytes, int x, int y)
see fl_draw(const char *str, int n, int x, int y).
Definition: Fl_PostScript.H:194
Fl_Surface_Device::set_current
virtual void set_current(void)
Use this drawing surface for future graphics requests.
Definition: Fl_Device.cxx:40
Fl_Graphics_Driver::draw_image_mono
virtual void draw_image_mono(const uchar *buf, int X, int Y, int W, int H, int D=1, int L=0)
see fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L).
Definition: Fl_Device.H:346
Fl_Graphics_Driver::loop
virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2)
see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2).
Definition: fl_rect.cxx:380
Fl_Graphics_Driver::not_clipped
virtual int not_clipped(int x, int y, int w, int h)
see fl_not_clipped(int x, int y, int w, int h).
Definition: fl_rect.cxx:605
Fl_Graphics_Driver::xyline
virtual void xyline(int x, int y, int x1)
see fl_xyline(int x, int y, int x1).
Definition: fl_rect.cxx:198
Fl_Paged_Device::scale
virtual void scale(float scale_x, float scale_y=0.)
Changes the scaling of page coordinates.
Definition: Fl_Paged_Device.cxx:214
Fl_Paged_Device::Page_Layout
Page_Layout
Possible page layouts.
Definition: Fl_Paged_Device.H:81
Fl_Graphics_Driver::point
virtual void point(int x, int y)
see fl_point(int x, int y).
Definition: fl_rect.cxx:487
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:183
Fl_Graphics_Driver::end_loop
virtual void end_loop()
see fl_end_loop().
Definition: fl_vertex.cxx:159
Fl_Graphics_Driver::rtl_draw
virtual void rtl_draw(const char *str, int n, int x, int y)
see fl_rtl_draw(const char *str, int n, int x, int y).
Definition: Fl_Device.H:251
Fl_Graphics_Driver::transformed_vertex
virtual void transformed_vertex(double xf, double yf)
see fl_transformed_vertex(double xf, double yf).
Definition: fl_vertex.cxx:103
Fl_Graphics_Driver::height
virtual int height()
see fl_height().
Definition: Fl_Device.H:391
Fl_Paged_Device::end_job
virtual void end_job(void)
To be called at the end of a print job.
Definition: Fl_Paged_Device.cxx:235
Fl_Paged_Device::untranslate
virtual void untranslate(void)
Undoes the effect of a previous translate() call.
Definition: Fl_Paged_Device.cxx:249
Fl_Paged_Device::origin
virtual void origin(int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
Definition: Fl_Paged_Device.cxx:201
Fl_Graphics_Driver::begin_polygon
virtual void begin_polygon()
see fl_begin_polygon().
Definition: fl_vertex.cxx:81
Fl_Graphics_Driver::end_line
virtual void end_line()
see fl_end_line().
Definition: fl_vertex.cxx:133
Fl_PostScript_File_Device::file_chooser_title
static const char * file_chooser_title
Label of the PostScript file chooser window.
Definition: Fl_PostScript.H:247
Fl_Graphics_Driver::polygon
virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2)
see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2).
Definition: fl_rect.cxx:435
Fl_Graphics_Driver::descent
virtual int descent()
see fl_descent().
Definition: Fl_Device.H:393
Fl_Graphics_Driver::color
Fl_Color color()
see fl_color(void).
Definition: Fl_Device.H:395
Fl_Paged_Device::rotate
virtual void rotate(float angle)
Rotates the graphics operations relatively to paper.
Definition: Fl_Paged_Device.cxx:223
Fl_Graphics_Driver::line_style
virtual void line_style(int style, int width=0, char *dashes=0)
see fl_line_style(int style, int width, char* dashes).
Definition: fl_line_style.cxx:50
Fl_PostScript_Graphics_Driver::class_name
const char * class_name()
Returns the name of the class of this object.
Definition: Fl_PostScript.H:65
Fl_PostScript_Graphics_Driver::gap
void gap()
see fl_gap().
Definition: Fl_PostScript.H:185
Fl_PostScript_Graphics_Driver
Definition: Fl_PostScript.H:62
Fl_Graphics_Driver::begin_line
virtual void begin_line()
see fl_begin_line().
Definition: fl_vertex.cxx:77
Fl_Graphics_Driver::font
Fl_Font font()
see fl_font(void).
Definition: Fl_Device.H:381
Fl_Graphics_Driver::curve
virtual void curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)
see fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3...
Definition: fl_curve.cxx:32
Fl_Paged_Device.H
declaration of class Fl_Paged_Device.
Fl_PostScript_Graphics_Driver::begin_complex_polygon
void begin_complex_polygon()
see fl_begin_complex_polygon().
Definition: Fl_PostScript.H:184
Fl_Paged_Device::Page_Format
Page_Format
Possible page formats.
Definition: Fl_Paged_Device.H:45
Fl_Graphics_Driver::vertex
virtual void vertex(double x, double y)
see fl_vertex(double x, double y).
Definition: fl_vertex.cxx:111
fl_draw.H
utility header to pull drawing functions together
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
Fl_Graphics_Driver::yxline
virtual void yxline(int x, int y, int y1)
see fl_yxline(int x, int y, int y1).
Definition: fl_rect.cxx:265
Fl_Draw_Image_Cb
void(* Fl_Draw_Image_Cb)(void *data, int x, int y, int w, uchar *buf)
signature of image generation callback function.
Definition: Fl_Device.H:49
Fl_Graphics_Driver::draw_image
virtual void draw_image(const uchar *buf, int X, int Y, int W, int H, int D=3, int L=0)
see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L).
Definition: Fl_Device.H:344
Fl_Graphics_Driver
A virtual class subclassed for each graphics driver FLTK uses.
Definition: Fl_Device.H:103
Fl_Graphics_Driver::push_no_clip
virtual void push_no_clip()
see fl_push_no_clip().
Definition: fl_rect.cxx:590
Fl_Graphics_Driver::circle
virtual void circle(double x, double y, double r)
see fl_circle(double x, double y, double r).
Definition: fl_vertex.cxx:244
Fl_Graphics_Driver::arc
virtual void arc(double x, double y, double r, double start, double end)
see fl_arc(double x, double y, double r, double start, double end).
Definition: fl_arc.cxx:37
Fl_Graphics_Driver::pie
virtual void pie(int x, int y, int w, int h, double a1, double a2)
see fl_pie(int x, int y, int w, int h, double a1, double a2).
Definition: fl_arci.cxx:76
Fl_Bitmap
The Fl_Bitmap class supports caching and drawing of mono-color (bitmap) images.
Definition: Fl_Bitmap.H:33
Fl_Graphics_Driver::line
virtual void line(int x, int y, int x1, int y1)
see fl_line(int x, int y, int x1, int y1).
Definition: fl_rect.cxx:334
Fl_Paged_Device::translate
virtual void translate(int x, int y)
Translates the current graphics origin accounting for the current rotation.
Definition: Fl_Paged_Device.cxx:244
Fl_Paged_Device::A4
A4 format.
Definition: Fl_Paged_Device.H:50
Fl_PostScript_Graphics_Driver::end_complex_polygon
void end_complex_polygon()
see fl_end_complex_polygon().
Definition: Fl_PostScript.H:186
Fl_Graphics_Driver::rectf
virtual void rectf(int x, int y, int w, int h)
see fl_rectf(int x, int y, int w, int h).
Definition: fl_rect.cxx:180
Fl_PostScript_File_Device
To send graphical output to a PostScript file.
Definition: Fl_PostScript.H:216
Fl_Graphics_Driver::clip_box
virtual int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
see fl_clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
Definition: fl_rect.cxx:636
Fl_Graphics_Driver::end_polygon
virtual void end_polygon()
see fl_end_polygon().
Definition: fl_vertex.cxx:165
Fl_Graphics_Driver::push_clip
virtual void push_clip(int x, int y, int w, int h)
see fl_push_clip(int x, int y, int w, int h).
Definition: fl_rect.cxx:553
Fl_Paged_Device::start_page
virtual int start_page(void)
Starts a new printed page.
Definition: Fl_Paged_Device.cxx:165
Fl_Paged_Device::end_page
virtual int end_page(void)
To be called at the end of each page.
Definition: Fl_Paged_Device.cxx:230
Fl_Paged_Device::printable_rect
virtual int printable_rect(int *w, int *h)
Computes the width and height of the printable area of the page.
Definition: Fl_Paged_Device.cxx:175
Fl_Paged_Device::PORTRAIT
Portrait orientation.
Definition: Fl_Paged_Device.H:82
Fl_Graphics_Driver::width
virtual double width(const char *str, int n)
see fl_width(const char *str, int n).
Definition: Fl_Device.H:385
Fl_Graphics_Driver::end_points
virtual void end_points()
see fl_end_points().
Definition: fl_vertex.cxx:115
Fl_Graphics_Driver::draw
virtual void draw(const char *str, int n, int x, int y)
see fl_draw(const char *str, int n, int x, int y).
Definition: Fl_Device.H:244
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
Fl_Surface_Device::driver
Fl_Graphics_Driver * driver()
Returns the graphics driver of this drawing surface.
Definition: Fl_Device.H:537
- © 1998-2014 by Bill Spitzak and others.