FLTK 1.3.8: Fl_PostScript.H Source File

FLTK 1.3.8

Fl_PostScript.H
Go to the documentation of this file.
1//
2// "$Id$"
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
30/* Signature of Fl_PostScript::close_command() functions passed as parameters. */
31extern "C" {
32 typedef int (Fl_PostScript_Close_Command)(FILE *);
33}
34
61 class FL_EXPORT Fl_PostScript_Graphics_Driver : public Fl_Graphics_Driver {
62private:
63 void transformed_draw_extra(const char* str, int n, double x, double y, int w, bool rtl);
64 void *prepare_rle85();
65 void write_rle85(uchar b, void *data);
66 void close_rle85(void *data);
67 void *prepare85();
68 void write85(void *data, const uchar *p, int len);
69 void close85(void *data);
70public:
71 static const char *class_id;
72 const char *class_name() {return class_id;};
73 Fl_PostScript_Graphics_Driver();
74#ifndef FL_DOXYGEN
75 enum SHAPE{NONE=0, LINE, LOOP, POLYGON, POINTS};
76
77class Clip {
78 public:
79 int x, y, w, h;
80 Clip *prev;
81 };
82 Clip * clip_;
83
84 int lang_level_;
85 int gap_;
86 int pages_;
87
88 double width_;
89 double height_;
90
91 int shape_;
92 int linewidth_;// need for clipping, lang level 1-2
93 int linestyle_;//
94 int interpolate_; //interpolation of images
95 unsigned char cr_,cg_,cb_;
96 char linedash_[256];//should be enough
97 void concat(); // transform ror scalable dradings...
98 void reconcat(); //invert
99 void recover(); //recovers the state after grestore (such as line styles...)
100 void reset();
101
102 uchar * mask;
103 int mx; // width of mask;
104 int my; // mask lines
105 //Fl_Color bg_;
106 Fl_PostScript_Close_Command* close_cmd_;
107 int page_policy_;
108 int nPages;
109 int orientation_;
110
111 float scale_x;
112 float scale_y;
113 float angle;
114 int left_margin;
115 int top_margin;
116
117 FILE *output;
118 double pw_, ph_;
119
120 uchar bg_r, bg_g, bg_b;
121 int start_postscript (int pagecount, enum Fl_Paged_Device::Page_Format format, enum Fl_Paged_Device::Page_Layout layout);
122 /* int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
123 */
124 void transformed_draw(const char* s, int n, double x, double y); //precise text placing
125 void transformed_draw(const char* s, double x, double y);
126 int alpha_mask(const uchar * data, int w, int h, int D, int LD=0);
127
128 enum Fl_Paged_Device::Page_Format page_format_;
129 char *ps_filename_;
130
131 void page_policy(int p);
132 int page_policy(){return page_policy_;};
133 void close_command(Fl_PostScript_Close_Command* cmd){close_cmd_=cmd;};
134 FILE * file() {return output;};
135 //void orientation (int o);
136 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int pages = 0); // ps (also multi-page) constructor
137 //Fl_PostScript_Graphics_Driver(FILE *o, int lang_level, int x, int y, int w, int h); //eps constructor
138 void interpolate(int i){interpolate_=i;};
139 int interpolate(){return interpolate_;}
140
141 void page(double pw, double ph, int media = 0);
142 void page(int format);
143#endif // FL_DOXYGEN
144
145 // implementation of drawing methods
146 void color(Fl_Color c);
147 void color(uchar r, uchar g, uchar b);
148
149 void push_clip(int x, int y, int w, int h);
150 int clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H);
151 int not_clipped(int x, int y, int w, int h);
152 void push_no_clip();
153 void pop_clip();
154
155 void line_style(int style, int width=0, char* dashes=0);
156
157 void rect(int x, int y, int w, int h);
158 void rectf(int x, int y, int w, int h);
159
160 void xyline(int x, int y, int x1);
161 void xyline(int x, int y, int x1, int y2);
162 void xyline(int x, int y, int x1, int y2, int x3);
163
164 void yxline(int x, int y, int y1);
165 void yxline(int x, int y, int y1, int x2);
166 void yxline(int x, int y, int y1, int x2, int y3);
167
168 void line(int x1, int y1, int x2, int y2);
169 void line(int x1, int y1, int x2, int y2, int x3, int y3);
170
171 void loop(int x0, int y0, int x1, int y1, int x2, int y2);
172 void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
173 void polygon(int x0, int y0, int x1, int y1, int x2, int y2);
174 void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3);
175 void point(int x, int y);
176
177 void begin_points();
178 void begin_line();
179 void begin_loop();
180 void begin_polygon();
181 void vertex(double x, double y);
182 void curve(double x, double y, double x1, double y1, double x2, double y2, double x3, double y3);
183 void circle(double x, double y, double r);
184 void arc(double x, double y, double r, double start, double a);
185 void arc(int x, int y, int w, int h, double a1, double a2);
186 void pie(int x, int y, int w, int h, double a1, double a2);
187 void end_points();
188 void end_line();
189 void end_loop();
190 void end_polygon();
191 void begin_complex_polygon(){begin_polygon();};
192 void gap(){gap_=1;};
193 void end_complex_polygon(){end_polygon();};
194 void transformed_vertex(double x, double y);
195
196 void draw_image(const uchar* d, int x,int y,int w,int h, int delta=3, int ldelta=0);
197 void draw_image_mono(const uchar* d, int x,int y,int w,int h, int delta=1, int ld=0);
198 void draw_image(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=3);
199 void draw_image_mono(Fl_Draw_Image_Cb call, void* data, int x,int y, int w, int h, int delta=1);
200
201 void draw(const char* s, int nBytes, int x, int y) {transformed_draw(s,nBytes,x,y); };
202#ifdef __APPLE__
203 void draw(const char* s, int nBytes, float x, float y) {transformed_draw(s,nBytes,x,y); };
204#endif
205 void draw(int angle, const char *str, int n, int x, int y);
206 void rtl_draw(const char* s, int n, int x, int y);
207 void font(int face, int size);
208 double width(const char *, int);
209 double width(unsigned int u);
210 void text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h);
211 int height();
212 int descent();
213 void draw(Fl_Pixmap * pxm,int XP, int YP, int WP, int HP, int cx, int cy);
214 void draw(Fl_Bitmap * bitmap,int XP, int YP, int WP, int HP, int cx, int cy);
215 void draw(Fl_RGB_Image * rgb,int XP, int YP, int WP, int HP, int cx, int cy);
216 int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
217 int clocale_printf(const char *format, ...);
218 ~Fl_PostScript_Graphics_Driver();
219};
220
226 class FL_EXPORT Fl_PostScript_File_Device : public Fl_Paged_Device {
227#ifdef __APPLE__
228 CGContextRef gc;
229#endif
230protected:
231 Fl_PostScript_Graphics_Driver *driver();
232public:
233 static const char *class_id;
234 const char *class_name() {return class_id;};
235 Fl_PostScript_File_Device();
236 ~Fl_PostScript_File_Device();
237 int start_job(int pagecount, int* from, int* to);
238 int start_job(int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
239 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT);
240 int start_job(FILE *ps_output, int pagecount, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
241 enum Fl_Paged_Device::Page_Layout layout = Fl_Paged_Device::PORTRAIT);
242 int start_page (void);
243 int printable_rect(int *w, int *h);
244 void margins(int *left, int *top, int *right, int *bottom);
245 void origin(int *x, int *y);
246 void origin(int x, int y);
247 void scale (float scale_x, float scale_y = 0.);
248 void rotate(float angle);
249 void translate(int x, int y);
250 void untranslate(void);
251 int end_page (void);
252 void end_job(void);
253#ifdef __APPLE__
254 void set_current() { fl_gc = gc; Fl_Paged_Device::set_current(); }
255#endif
256
257 static const char *file_chooser_title;
258};
259
260#endif // Fl_PostScript_H
261
262//
263// End of "$Id$"
264//
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors
Definition: Enumerations.H:932
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_Paged_Device.H
declaration of class Fl_Paged_Device.
Fl_Bitmap
The Fl_Bitmap class supports caching and drawing of mono-color (bitmap) images.
Definition: Fl_Bitmap.H:33
Fl_Graphics_Driver
A virtual class subclassed for each graphics driver FLTK uses.
Definition: Fl_Device.H:110
Fl_Graphics_Driver::begin_polygon
virtual void begin_polygon()
see fl_begin_polygon().
Definition: fl_vertex.cxx:81
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:251
Fl_Graphics_Driver::end_polygon
virtual void end_polygon()
see fl_end_polygon().
Definition: fl_vertex.cxx:163
Fl_Image
Base class for image caching and drawing.
Definition: Fl_Image.H:55
Fl_Paged_Device
Represents page-structured drawing surfaces.
Definition: Fl_Paged_Device.H:38
Fl_Paged_Device::Page_Layout
Page_Layout
Possible page layouts.
Definition: Fl_Paged_Device.H:86
Fl_Paged_Device::PORTRAIT
@ PORTRAIT
Portrait orientation.
Definition: Fl_Paged_Device.H:87
Fl_Paged_Device::Page_Format
Page_Format
Possible page formats.
Definition: Fl_Paged_Device.H:50
Fl_Paged_Device::A4
@ A4
A4 format.
Definition: Fl_Paged_Device.H:55
Fl_Pixmap
The Fl_Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency.
Definition: Fl_Pixmap.H:41
Fl_PostScript_File_Device
To send graphical output to a PostScript file.
Definition: Fl_PostScript.H:226
Fl_PostScript_File_Device::translate
void translate(int x, int y)
Translates the current graphics origin accounting for the current rotation.
Fl_PostScript_File_Device::untranslate
void untranslate(void)
Undoes the effect of a previous translate() call.
Fl_PostScript_File_Device::file_chooser_title
static const char * file_chooser_title
Label of the PostScript file chooser window.
Definition: Fl_PostScript.H:257
Fl_PostScript_File_Device::end_page
int end_page(void)
To be called at the end of each page.
Fl_PostScript_File_Device::origin
void origin(int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
Fl_PostScript_File_Device::rotate
void rotate(float angle)
Rotates the graphics operations relatively to paper.
Fl_PostScript_File_Device::margins
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.
Fl_PostScript_File_Device::scale
void scale(float scale_x, float scale_y=0.)
Changes the scaling of page coordinates.
Fl_PostScript_File_Device::end_job
void end_job(void)
To be called at the end of a print job.
Fl_PostScript_File_Device::start_page
int start_page(void)
Starts a new printed page.
Fl_PostScript_File_Device::origin
void origin(int *x, int *y)
Computes the page coordinates of the current origin of graphics functions.
Fl_PostScript_File_Device::class_name
const char * class_name()
Returns the name of the class of this object.
Definition: Fl_PostScript.H:234
Fl_PostScript_File_Device::printable_rect
int printable_rect(int *w, int *h)
Computes the width and height of the printable area of the page.
Fl_PostScript_Graphics_Driver
PostScript graphical backend.
Definition: Fl_PostScript.H:61
Fl_PostScript_Graphics_Driver::draw
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.
Fl_PostScript_Graphics_Driver::draw
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.
Fl_PostScript_Graphics_Driver::begin_polygon
void begin_polygon()
see fl_begin_polygon().
Fl_PostScript_Graphics_Driver::clip_box
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).
Fl_PostScript_Graphics_Driver::polygon
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).
Fl_PostScript_Graphics_Driver::begin_complex_polygon
void begin_complex_polygon()
see fl_begin_complex_polygon().
Definition: Fl_PostScript.H:191
Fl_PostScript_Graphics_Driver::rect
void rect(int x, int y, int w, int h)
see fl_rect(int x, int y, int w, int h).
Fl_PostScript_Graphics_Driver::color
void color(uchar r, uchar g, uchar b)
see fl_color(uchar r, uchar g, uchar b).
Fl_PostScript_Graphics_Driver::loop
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).
Fl_PostScript_Graphics_Driver::arc
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).
Fl_PostScript_Graphics_Driver::line_style
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::begin_line
void begin_line()
see fl_begin_line().
Fl_PostScript_Graphics_Driver::pie
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).
Fl_PostScript_Graphics_Driver::begin_loop
void begin_loop()
see fl_begin_loop().
Fl_PostScript_Graphics_Driver::xyline
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).
Fl_PostScript_Graphics_Driver::pop_clip
void pop_clip()
see fl_pop_clip().
Fl_PostScript_Graphics_Driver::begin_points
void begin_points()
see fl_begin_points().
Fl_PostScript_Graphics_Driver::gap
void gap()
see fl_gap().
Definition: Fl_PostScript.H:192
Fl_PostScript_Graphics_Driver::end_points
void end_points()
see fl_end_points().
Fl_PostScript_Graphics_Driver::draw_image
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).
Fl_PostScript_Graphics_Driver::rtl_draw
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).
Fl_PostScript_Graphics_Driver::transformed_vertex
void transformed_vertex(double x, double y)
see fl_transformed_vertex(double xf, double yf).
Fl_PostScript_Graphics_Driver::end_polygon
void end_polygon()
see fl_end_polygon().
Fl_PostScript_Graphics_Driver::xyline
void xyline(int x, int y, int x1, int y2)
see fl_xyline(int x, int y, int x1, int y2).
Fl_PostScript_Graphics_Driver::draw_image_mono
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).
Fl_PostScript_Graphics_Driver::xyline
void xyline(int x, int y, int x1)
see fl_xyline(int x, int y, int x1).
Fl_PostScript_Graphics_Driver::width
double width(const char *, int)
see fl_width(const char *str, int n).
Fl_PostScript_Graphics_Driver::polygon
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).
Fl_PostScript_Graphics_Driver::color
void color(Fl_Color c)
see fl_color(Fl_Color c).
Fl_PostScript_Graphics_Driver::loop
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).
Fl_PostScript_Graphics_Driver::circle
void circle(double x, double y, double r)
see fl_circle(double x, double y, double r).
Fl_PostScript_Graphics_Driver::font
void font(int face, int size)
see fl_font(Fl_Font face, Fl_Fontsize size).
Fl_PostScript_Graphics_Driver::line
void line(int x1, int y1, int x2, int y2)
see fl_line(int x, int y, int x1, int y1).
Fl_PostScript_Graphics_Driver::curve
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,...
Fl_PostScript_Graphics_Driver::class_name
const char * class_name()
Returns the name of the class of this object.
Definition: Fl_PostScript.H:72
Fl_PostScript_Graphics_Driver::rectf
void rectf(int x, int y, int w, int h)
see fl_rectf(int x, int y, int w, int h).
Fl_PostScript_Graphics_Driver::end_loop
void end_loop()
see fl_end_loop().
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:201
Fl_PostScript_Graphics_Driver::push_no_clip
void push_no_clip()
see fl_push_no_clip().
Fl_PostScript_Graphics_Driver::width
double width(unsigned int u)
see fl_width(unsigned int n).
Fl_PostScript_Graphics_Driver::draw
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.
Fl_PostScript_Graphics_Driver::end_complex_polygon
void end_complex_polygon()
see fl_end_complex_polygon().
Definition: Fl_PostScript.H:193
Fl_PostScript_Graphics_Driver::yxline
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).
Fl_PostScript_Graphics_Driver::arc
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).
Fl_PostScript_Graphics_Driver::point
void point(int x, int y)
see fl_point(int x, int y).
Fl_PostScript_Graphics_Driver::yxline
void yxline(int x, int y, int y1, int x2)
see fl_yxline(int x, int y, int y1, int x2).
Fl_PostScript_Graphics_Driver::vertex
void vertex(double x, double y)
see fl_vertex(double x, double y).
Fl_PostScript_Graphics_Driver::yxline
void yxline(int x, int y, int y1)
see fl_yxline(int x, int y, int y1).
Fl_PostScript_Graphics_Driver::push_clip
void push_clip(int x, int y, int w, int h)
see fl_push_clip(int x, int y, int w, int h).
Fl_PostScript_Graphics_Driver::line
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).
Fl_PostScript_Graphics_Driver::draw_image_mono
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).
Fl_PostScript_Graphics_Driver::text_extents
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).
Fl_PostScript_Graphics_Driver::not_clipped
int not_clipped(int x, int y, int w, int h)
see fl_not_clipped(int x, int y, int w, int h).
Fl_PostScript_Graphics_Driver::height
int height()
see fl_height().
Fl_PostScript_Graphics_Driver::descent
int descent()
see fl_descent().
Fl_PostScript_Graphics_Driver::draw_image
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).
Fl_PostScript_Graphics_Driver::draw_scaled
int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP)
Draws an Fl_Image scaled to width W & height H with top-left corner at X,Y.
Fl_PostScript_Graphics_Driver::draw
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).
Fl_PostScript_Graphics_Driver::end_line
void end_line()
see fl_end_line().
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:202
Fl_Surface_Device::set_current
virtual void set_current(void)
Make this surface the current drawing surface.
Definition: Fl_Device.cxx:44
fl_draw.H
utility header to pull drawing functions together
uchar
unsigned char uchar
unsigned char
Definition: fl_types.h:30
- Copyright © 1998-2021 by Bill Spitzak and others.