FLTK 1.4.2
Loading...
Searching...
No Matches
Fl_PostScript.H
Go to the documentation of this file.
1//
2// Support for graphics output to PostScript file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 2010-2020 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
20
21#ifndef Fl_PostScript_H
22#define Fl_PostScript_H
23
24#include <FL/Fl_Paged_Device.H>
25#include <FL/fl_draw.H>
26#include <stdarg.h>
27
32extern "C" {
33 typedef int (*Fl_PostScript_Close_Command)(FILE *);
34}
35
36class Fl_PostScript_Graphics_Driver;
37
79private:
80 // memorize the display's current font to restore it when the object ceases being current
81 Fl_Font display_font_;
82 Fl_Fontsize display_size_;
83protected:
87 inline Fl_PostScript_Graphics_Driver *driver() { return (Fl_PostScript_Graphics_Driver*)Fl_Surface_Device::driver(); }
88public:
94 int begin_job(int pagecount, int* from, int* to, char **perr_message) FL_OVERRIDE;
104 int begin_job(int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
108 int start_job(int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
110 return begin_job(pagecount, format, layout);
111 }
112
122 int begin_job(FILE *ps_output, int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
126 int start_job(FILE *ps_output, int pagecount = 0, enum Fl_Paged_Device::Page_Format format = Fl_Paged_Device::A4,
128 return begin_job(ps_output, pagecount, format, layout);
129 }
130
132 int printable_rect(int *w, int *h) FL_OVERRIDE;
133 void margins(int *left, int *top, int *right, int *bottom) FL_OVERRIDE;
134 void origin(int *x, int *y) FL_OVERRIDE;
135 void origin(int x, int y) FL_OVERRIDE;
136 void scale (float scale_x, float scale_y = 0.) FL_OVERRIDE;
137 void rotate(float angle) FL_OVERRIDE;
138 void translate(int x, int y) FL_OVERRIDE;
146 static const char *file_chooser_title;
148 FILE *file();
153};
154
172class FL_EXPORT Fl_EPS_File_Surface : public Fl_Widget_Surface {
173protected:
175 inline Fl_PostScript_Graphics_Driver *driver() { return (Fl_PostScript_Graphics_Driver*)Fl_Surface_Device::driver(); }
176public:
191 Fl_EPS_File_Surface(int width, int height, FILE *eps_output,
192 Fl_Color background = FL_WHITE, Fl_PostScript_Close_Command closef = NULL);
201 int printable_rect(int *w, int *h) FL_OVERRIDE;
203 FILE *file();
204 void origin(int x, int y) FL_OVERRIDE;
205 void origin(int *px, int *py) FL_OVERRIDE;
206 void translate(int x, int y) FL_OVERRIDE;
211 int close();
212};
213
214#endif // Fl_PostScript_H
int Fl_Font
A font number is an index into the internal font table.
Definition Enumerations.H:1056
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1113
int Fl_Fontsize
Size of a font in pixels.
Definition Enumerations.H:1085
declaration of class Fl_Paged_Device.
int(* Fl_PostScript_Close_Command)(FILE *)
Signature of functions FLTK may use to close FILE variables after PostScript/EPS output.
Definition Fl_PostScript.H:33
void translate(int x, int y) FL_OVERRIDE
Translates the current graphics origin accounting for the current rotation.
void untranslate() FL_OVERRIDE
Undoes the effect of a previous translate() call.
int close()
Completes all EPS output.
Fl_PostScript_Graphics_Driver * driver()
Returns the PostScript driver of this drawing surface.
Definition Fl_PostScript.H:175
Fl_EPS_File_Surface(int width, int height, FILE *eps_output, Fl_Color background=FL_WHITE, Fl_PostScript_Close_Command closef=NULL)
Constructor.
FILE * file()
Returns the underlying FILE pointer.
void origin(int x, int y) FL_OVERRIDE
Sets the position of the origin of graphics in the drawable part of the drawing surface.
~Fl_EPS_File_Surface()
Destructor.
void origin(int *px, int *py) FL_OVERRIDE
Computes the coordinates of the current origin of graphics functions.
int printable_rect(int *w, int *h) FL_OVERRIDE
Computes the width and height of the drawable area of the drawing surface.
Fl_Paged_Device()
The constructor.
Definition Fl_Paged_Device.H:39
virtual int begin_job(int pagecount=0, int *frompage=NULL, int *topage=NULL, char **perr_message=NULL)
Begins a print job.
Definition Fl_Paged_Device.cxx:36
Page_Layout
Possible page layouts.
Definition Fl_Paged_Device.H:81
@ PORTRAIT
Portrait orientation.
Definition Fl_Paged_Device.H:82
Page_Format
Possible page formats.
Definition Fl_Paged_Device.H:45
@ A4
A4 format.
Definition Fl_Paged_Device.H:50
Fl_PostScript_File_Device()
The constructor.
int start_job(FILE *ps_output, int pagecount=0, enum Fl_Paged_Device::Page_Format format=Fl_Paged_Device::A4, enum Fl_Paged_Device::Page_Layout layout=Fl_Paged_Device::PORTRAIT)
Synonym of begin_job().
Definition Fl_PostScript.H:126
~Fl_PostScript_File_Device()
The destructor.
void origin(int x, int y) FL_OVERRIDE
Sets the position of the origin of graphics in the drawable part of the drawing surface.
int begin_job(int pagecount=0, enum Fl_Paged_Device::Page_Format format=Fl_Paged_Device::A4, enum Fl_Paged_Device::Page_Layout layout=Fl_Paged_Device::PORTRAIT)
Begins the session where all graphics requests will go to a local PostScript file.
static const char * file_chooser_title
Label of the PostScript file chooser window.
Definition Fl_PostScript.H:146
void margins(int *left, int *top, int *right, int *bottom) FL_OVERRIDE
Computes the dimensions of margins that lie between the printable page area and the full page.
int begin_job(int pagecount, int *from, int *to, char **perr_message) FL_OVERRIDE
Don't use with this class.
FILE * file()
Returns the underlying FILE* receiving all PostScript data.
Fl_PostScript_Graphics_Driver * driver()
Returns the PostScript driver of this drawing surface.
Definition Fl_PostScript.H:87
void translate(int x, int y) FL_OVERRIDE
Translates the current graphics origin accounting for the current rotation.
void scale(float scale_x, float scale_y=0.) FL_OVERRIDE
Changes the scaling of page coordinates.
int begin_page(void) FL_OVERRIDE
Begins a new printed page.
void rotate(float angle) FL_OVERRIDE
Rotates the graphics operations relatively to paper.
void untranslate(void) FL_OVERRIDE
Undoes the effect of a previous translate() call.
int start_job(int pagecount=0, enum Fl_Paged_Device::Page_Format format=Fl_Paged_Device::A4, enum Fl_Paged_Device::Page_Layout layout=Fl_Paged_Device::PORTRAIT)
Synonym of begin_job().
Definition Fl_PostScript.H:108
void end_job(void) FL_OVERRIDE
Completes all PostScript output.
int end_page(void) FL_OVERRIDE
To be called at the end of each page.
int begin_job(FILE *ps_output, int pagecount=0, enum Fl_Paged_Device::Page_Format format=Fl_Paged_Device::A4, enum Fl_Paged_Device::Page_Layout layout=Fl_Paged_Device::PORTRAIT)
Begins the session where all graphics requests will go to FILE pointer.
void origin(int *x, int *y) FL_OVERRIDE
Computes the coordinates of the current origin of graphics functions.
int printable_rect(int *w, int *h) FL_OVERRIDE
Computes the width and height of the drawable area of the drawing surface.
void end_current() FL_OVERRIDE
FLTK calls this each time a surface ceases to be the current drawing surface.
void close_command(Fl_PostScript_Close_Command cmd)
Sets the function end_job() calls to close the file()
void set_current() FL_OVERRIDE
Make this surface the current drawing surface.
Fl_Graphics_Driver * driver()
Returns the graphics driver of this drawing surface.
Definition Fl_Device.H:76
Fl_Widget_Surface(Fl_Graphics_Driver *d)
The constructor.
Definition Fl_Widget_Surface.cxx:28
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
utility header to pull drawing functions together