NTK 1.3.0
Fl_PostScript.H
Go to the documentation of this file.
1//
2// "$Id: Fl_PostScript.H 8699 2011-05-20 16:39:06Z 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; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems on the following page:
24//
25// http://www.fltk.org/str.php
26//
30
31
32#ifndef Fl_PostScript_H
33#define Fl_PostScript_H
34
35#include <FL/Fl_Paged_Device.H>
36#include <FL/fl_draw.H>
37
65public:
66 static const char *class_id;
67 const char *class_name() {return class_id;};
69#ifndef FL_DOXYGEN
70 enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
71
72class Clip {
73 public:
74 int x, y, w, h;
75 Clip *prev;
76 };
77 Clip * clip_;
78
79 int lang_level_;
80 int gap_;
81 int pages_;
82
83 double width_;
84 double height_;
85
86 int shape_;
87 int linewidth_;// need for clipping, lang level 1-2
88 int linestyle_;//
89 int interpolate_; //interpolation of images
90 unsigned char cr_,cg_,cb_;
91 char linedash_[256];//should be enough
92 void concat(); // transform ror scalable dradings...
93 void reconcat(); //invert
94 void recover(); //recovers the state after grestore (such as line styles...)
95 void reset();
96
97 uchar * mask;
98 int mx; // width of mask;
99 int my; // mask lines
100 //Fl_Color bg_;
101 int (*close_cmd_)(FILE *);
102 int page_policy_;
103 int nPages;
104 int orientation_;
105
106 float scale_x;
107 float scale_y;
108 float angle;
109 int left_margin;
110 int top_margin;
111
112 FILE *output;
113 double pw_, ph_;
114
115 uchar bg_r, bg_g, bg_b;
116 int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout);
117 /* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
118 */
119 void transformed_draw(const char* s, int n, double x, double y); //precise text placing
120 void transformed_draw(const char* s, double x, double y);
121 int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
122
123 enum Fl_Paged_Device::Page_Format page_format_;
124 char *ps_filename_;
125
126 void page_policy(int p);
127 int page_policy(){return page_policy_;};
128 void close_command( int (*cmd)(FILE *)){close_cmd_=cmd;};
129 FILE * file() {return output;};
130 //void orientation (int o);
131 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
132 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
133 void interpolate(int i){interpolate_=i;};
134 int interpolate(){return interpolate_;}
135
136 void page(double pw, double ph, int media = 0);
137 void page(int format);
138#endif // FL_DOXYGEN
139
140 // implementation of drawing methods
142 void color(uchar r, uchar g, uchar b);
143
144 void push_clip(int x, int y, int w, int h);
145 int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
146 int not_clipped(int x, int y, int w, int h);
148 void pop_clip();
149
150 void line_style(int style, int width=0, char* dashes=0);
151
152 void rect(int x, int y, int w, int h);
153 void rectf(int x, int y, int w, int h);
154
155 void xyline(int x, int y, int x1);
156 void xyline(int x, int y, int x1, int y2);
157 void xyline(int x, int y, int x1, int y2, int x3);
158
159 void yxline(int x, int y, int y1);
160 void yxline(int x, int y, int y1, int x2);
161 void yxline(int x, int y, int y1, int x2, int y3);
162
163 void line(int x1, int y1, int x2, int y2);
164 void line(int x1, int y1, int x2, int y2, int x3, int y3);
165
166 void loop(int x0, int y0, int x1, int y1, int x2, int y2);
167 void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
168 void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
169 void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
170 void point(int x, int y);
171
176 void vertex(double x, double y);
177 void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
178 void circle(double x, double y, double r);
179 void arc(double x, double y, double r, double start, double a);
180 void arc(int x, int y, int w, int h, double a1, double a2);
181 void pie(int x, int y, int w, int h, double a1, double a2);
183 void end_line();
184 void end_loop();
187 void gap(){gap_=1;};
189 void transformed_vertex(double x, double y);
190
191 void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0);
192 void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0);
193 void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3);
194 void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1);
195
196 void draw(const char* s, int n, int x, int y) {transformed_draw(s,n,x,y); };
197#ifdef __APPLE__
198 void draw(const char* s, int n, float x, float y) {transformed_draw(s,n,x,y); };
199#endif
200 void draw(int angle, const char *str, int n, int x, int y);
201 void rtl_draw(const char* s, int n, int x, int y);
202 void font(int face, int size);
203 double width(const char *, int);
204 void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h);
205 int height();
206 int descent();
207 void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
208 void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
209 void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
211};
212
217#ifdef __APPLE__
218 Fl_CGContextRef gc;
219#endif
220protected:
222public:
223 static const char *class_id;
224 const char *class_name() {return class_id;};
227 int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
229 int start_job(FILE *ps_output, int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
231 int start_page (void);
232 int printable_rect(int *w, int *h);
233 void margins(int *left, int *top, int *right, int *bottom);
234 void origin(int *x, int *y);
235 void origin(int x, int y);
236 void scale (float scale_x, float scale_y = 0.);
237 void rotate(float angle);
238 void translate(int x, int y);
239 void untranslate(void);
240 int end_page (void);
241 void end_job(void);
242#ifdef __APPLE__
243 void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); }
244#endif
245
246 static const char *file_chooser_title;
247};
248
249#endif // Fl_PostScript_H
250
251//
252// End of "$Id: Fl_PostScript.H 8699 2011-05-20 16:39:06Z manolo $"
253//
unsigned int Fl_Color
an FLTK color value
Definition Enumerations.H:764
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:58
declaration of class Fl_Paged_Device.
Fl_Graphics_Driver()
The constructor.
Definition Fl_Device.cxx:77
virtual void draw(const char *str, int n, int x, int y)=0
see fl_draw(const char *str, int n, int x, int y).
virtual void begin_polygon()
see fl_begin_polygon().
Definition fl_vertex.cxx:90
Fl_Fontsize size()
see fl_size().
Definition Fl_Device.H:388
virtual void end_polygon()
see fl_end_polygon().
Definition fl_vertex.cxx:174
Fl_Paged_Device()
The constructor.
Definition Fl_Paged_Device.H:118
Page_Layout
Possible page layouts.
Definition Fl_Paged_Device.H:90
@ PORTRAIT
Portrait orientation.
Definition Fl_Paged_Device.H:91
Page_Format
Possible page formats.
Definition Fl_Paged_Device.H:54
@ A4
A4 format.
Definition Fl_Paged_Device.H:59
To send graphical output to a PostScript file.
Definition Fl_PostScript.H:216
void translate(int x, int y)
Translates the current graphics origin accounting for the current rotation.
Fl_PostScript_File_Device()
The constructor.
Definition Fl_PostScript.cxx:70
void untranslate(void)
Undoes the effect of a previous translate() call.
static const char * file_chooser_title
Label of the PostScript file chooser window.
Definition Fl_PostScript.H:246
int end_page(void)
To be called at the end of each page.
void origin(int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
void rotate(float angle)
Rotates the graphics operations relatively to paper.
Fl_PostScript_Graphics_Driver * driver()
Returns the PostScript driver of this drawing surface.
Definition Fl_PostScript.cxx:81
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.
void scale(float scale_x, float scale_y=0.)
Changes the scaling of page coordinates.
void end_job(void)
To be called at the end of a print job.
int start_page(void)
Starts a new printed page.
void origin(int *x, int *y)
Computes the page coordinates of the current origin of graphics functions.
const char * class_name()
Returns the name of the class of this object.
Definition Fl_PostScript.H:224
int printable_rect(int *w, int *h)
Computes the width and height of the printable area of the page.
PostScript graphical backend.
Definition Fl_PostScript.H:64
void draw(Fl_RGB_Image *rgb, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl_RGB_Image object to the device.
void draw(Fl_Bitmap *bitmap, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl_Bitmap object to the device.
void begin_polygon()
see fl_begin_polygon().
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).
void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl_polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
void begin_complex_polygon()
see fl_begin_complex_polygon().
Definition Fl_PostScript.H:186
void rect(int x, int y, int w, int h)
see fl_rect(int x, int y, int w, int h).
void color(uchar r, uchar g, uchar b)
see fl_color(uchar r, uchar g, uchar b).
void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl_loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
void arc(double x, double y, double r, double start, double a)
see fl_arc(double x, double y, double r, double start, double end).
void line_style(int style, int width=0, char *dashes=0)
see fl_line_style(int style, int width, char* dashes).
Fl_PostScript_Graphics_Driver()
The constructor.
Definition Fl_PostScript.cxx:51
void begin_line()
see fl_begin_line().
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).
void begin_loop()
see fl_begin_loop().
void xyline(int x, int y, int x1, int y2, int x3)
see fl_xyline(int x, int y, int x1, int y2, int x3).
void pop_clip()
see fl_pop_clip().
void begin_points()
see fl_begin_points().
void gap()
see fl_gap().
Definition Fl_PostScript.H:187
void end_points()
see fl_end_points().
void draw_image(Fl_Draw_Image_Cb call, void *data, int x, int y, int w, int h, int delta=3)
see fl_draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D).
void rtl_draw(const char *s, int n, int x, int y)
see fl_rtl_draw(const char *str, int n, int x, int y).
void transformed_vertex(double x, double y)
see fl_transformed_vertex(double xf, double yf).
void end_polygon()
see fl_end_polygon().
void xyline(int x, int y, int x1, int y2)
see fl_xyline(int x, int y, int x1, int y2).
void draw_image_mono(const uchar *d, int x, int y, int w, int h, int delta=1, int ld=0)
see fl_draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L).
void xyline(int x, int y, int x1)
see fl_xyline(int x, int y, int x1).
double width(const char *, int)
see fl_width(const char *str, int n).
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).
void color(Fl_Color c)
see fl_color(Fl_Color c).
void draw(const char *s, int n, int x, int y)
see fl_draw(const char *str, int n, int x, int y).
Definition Fl_PostScript.H:196
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).
void circle(double x, double y, double r)
see fl_circle(double x, double y, double r).
void font(int face, int size)
see fl_font(Fl_Font face, Fl_Fontsize size).
void line(int x1, int y1, int x2, int y2)
see fl_line(int x, int y, int x1, int y1).
void curve(double x, double y, 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,...
const char * class_name()
Returns the name of the class of this object.
Definition Fl_PostScript.H:67
void rectf(int x, int y, int w, int h)
see fl_rectf(int x, int y, int w, int h).
void end_loop()
see fl_end_loop().
void push_no_clip()
see fl_push_no_clip().
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl_Pixmap object to the device.
void end_complex_polygon()
see fl_end_complex_polygon().
Definition Fl_PostScript.H:188
void yxline(int x, int y, int y1, int x2, int y3)
see fl_yxline(int x, int y, int y1, int x2, int y3).
void arc(int x, int y, int w, int h, double a1, double a2)
see fl_arc(int x, int y, int w, int h, double a1, double a2).
void point(int x, int y)
see fl_point(int x, int y).
void yxline(int x, int y, int y1, int x2)
see fl_yxline(int x, int y, int y1, int x2).
void vertex(double x, double y)
see fl_vertex(double x, double y).
void yxline(int x, int y, int y1)
see fl_yxline(int x, int y, int y1).
void push_clip(int x, int y, int w, int h)
see fl_push_clip(int x, int y, int w, int h).
void line(int x1, int y1, int x2, int y2, int x3, int y3)
see fl_line(int x, int y, int x1, int y1, int x2, int y2).
void draw_image_mono(Fl_Draw_Image_Cb call, void *data, int x, int y, int w, int h, int delta=1)
see fl_draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D).
void text_extents(const char *c, 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).
int not_clipped(int x, int y, int w, int h)
see fl_not_clipped(int x, int y, int w, int h).
int height()
see fl_height().
int descent()
see fl_descent().
void draw_image(const uchar *d, int x, int y, int w, int h, int delta=3, int ldelta=0)
see fl_draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L).
void draw(int angle, const char *str, int n, int x, int y)
see fl_draw(int angle, const char *str, int n, int x, int y).
void end_line()
see fl_end_line().
virtual void set_current(void)
Use this drawing surface for future graphics requests.
Definition Fl_Device.cxx:69
utility header to pull drawing functions together
unsigned char uchar
unsigned char
Definition fl_types.h:39