FLTK 1.5.0
Loading...
Searching...
No Matches
Fl_PDF_File_Surface.H
1//
2// Declaration of class Fl_PDF_File_Surface for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 2024 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
17#ifndef PDF_FILE_SURFACE_H
18#define PDF_FILE_SURFACE_H
19
20#include <FL/Fl_Paged_Device.H>
21
31class FL_EXPORT Fl_PDF_File_Surface : public Fl_Paged_Device {
32private:
33 const char **out_filename_;
34 Fl_Paged_Device *platform_surface_;
35 static Fl_Paged_Device *new_platform_pdf_surface_(const char ***);
36public:
40 static const char * format_dialog_title;
41 static const char * format_dialog_page_size;
42 static const char * format_dialog_orientation;
43 static const char * format_dialog_default;
55 int begin_job(const char* defaultfilename, char **perr = NULL);
57 int begin_job(int, int *, int *, char **) FL_OVERRIDE {return 1;}
66 int begin_document(const char* pathname,
69 char **perr = NULL);
70 int printable_rect(int *w, int *h) FL_OVERRIDE { return platform_surface_->printable_rect(w,h); }
71 void margins(int *left, int *top, int *right, int *bottom) FL_OVERRIDE {
72 platform_surface_->margins(left,top,right,bottom);
73 }
74 void origin(int x, int y) FL_OVERRIDE {platform_surface_->origin(x, y);}
75 void origin(int *x, int *y) FL_OVERRIDE {platform_surface_->origin(x, y);}
76 void scale(float s_x, float s_y = 0) FL_OVERRIDE {platform_surface_->scale(s_x, s_y);}
77 void rotate(float angle) FL_OVERRIDE {platform_surface_->rotate(angle);}
78 void translate(int x, int y) FL_OVERRIDE {platform_surface_->translate(x, y);}
79 void untranslate() FL_OVERRIDE {platform_surface_->untranslate();};
80 int begin_page(void) FL_OVERRIDE {return platform_surface_->begin_page();}
81 int end_page(void) FL_OVERRIDE {return platform_surface_->end_page();}
82 void end_job(void) FL_OVERRIDE {return platform_surface_->end_job();}
84 inline const char *pdf_filename() { return *out_filename_; }
85 void set_current() FL_OVERRIDE { if (platform_surface_) platform_surface_->set_current(); }
86 bool is_current() FL_OVERRIDE { return surface() == platform_surface_; }
87};
88
89#endif // PDF_FILE_SURFACE_H
declaration of class Fl_Paged_Device.
To send graphical output to a PDF file.
Definition Fl_PDF_File_Surface.H:31
void set_current() FL_OVERRIDE
Make this surface the current drawing surface.
Definition Fl_PDF_File_Surface.H:85
void origin(int x, int y) FL_OVERRIDE
Sets the position of the origin of graphics in the drawable part of the drawing surface.
Definition Fl_PDF_File_Surface.H:74
void end_job(void) FL_OVERRIDE
To be called at the end of a print job.
Definition Fl_PDF_File_Surface.H:82
static const char * format_dialog_orientation
Localizable text of the "PDF document settings" dialog.
Definition Fl_PDF_File_Surface.H:42
const char * pdf_filename()
Returns the name of the PDF document.
Definition Fl_PDF_File_Surface.H:84
void rotate(float angle) FL_OVERRIDE
Rotates the graphics operations relatively to paper.
Definition Fl_PDF_File_Surface.H:77
int begin_job(int, int *, int *, char **) FL_OVERRIDE
Don't use for this class.
Definition Fl_PDF_File_Surface.H:57
int printable_rect(int *w, int *h) FL_OVERRIDE
Computes the width and height of the drawable area of the drawing surface.
Definition Fl_PDF_File_Surface.H:70
static const char * format_dialog_default
Localizable text of the "PDF document settings" dialog.
Definition Fl_PDF_File_Surface.H:43
static const char * format_dialog_title
Localizable text of the "PDF document settings" dialog.
Definition Fl_PDF_File_Surface.H:40
int begin_page(void) FL_OVERRIDE
Begins a new printed page.
Definition Fl_PDF_File_Surface.H:80
bool is_current() FL_OVERRIDE
Is this surface the current drawing surface?
Definition Fl_PDF_File_Surface.H:86
void origin(int *x, int *y) FL_OVERRIDE
Computes the coordinates of the current origin of graphics functions.
Definition Fl_PDF_File_Surface.H:75
int end_page(void) FL_OVERRIDE
To be called at the end of each page.
Definition Fl_PDF_File_Surface.H:81
void translate(int x, int y) FL_OVERRIDE
Translates the current graphics origin accounting for the current rotation.
Definition Fl_PDF_File_Surface.H:78
int begin_document(const char *pathname, enum Fl_Paged_Device::Page_Format format=Fl_Paged_Device::A4, enum Fl_Paged_Device::Page_Layout layout=Fl_Paged_Device::PORTRAIT, char **perr=NULL)
Prepare to draw to a PDF document identified by its pathname.
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.
Definition Fl_PDF_File_Surface.H:71
void untranslate() FL_OVERRIDE
Undoes the effect of a previous translate() call.
Definition Fl_PDF_File_Surface.H:79
static const char * format_dialog_page_size
Localizable text of the "PDF document settings" dialog.
Definition Fl_PDF_File_Surface.H:41
int begin_job(const char *defaultfilename, char **perr=NULL)
Prepare to draw to a PDF document identified with a file chooser.
void scale(float s_x, float s_y=0) FL_OVERRIDE
Changes the scaling of page coordinates.
Definition Fl_PDF_File_Surface.H:76
Represents page-structured drawing surfaces.
Definition Fl_Paged_Device.H:36
virtual int begin_page(void)
Begins a new printed page.
Definition Fl_Paged_Device.cxx:54
virtual void scale(float scale_x, float scale_y=0.)
Changes the scaling of page coordinates.
Definition Fl_Paged_Device.cxx:81
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:67
virtual int end_page(void)
To be called at the end of each page.
Definition Fl_Paged_Device.cxx:104
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
virtual void end_job(void)
To be called at the end of a print job.
Definition Fl_Paged_Device.cxx:109
virtual void rotate(float angle)
Rotates the graphics operations relatively to paper.
Definition Fl_Paged_Device.cxx:90
virtual void set_current(void)
Make this surface the current drawing surface.
Definition Fl_Device.cxx:91
static Fl_Surface_Device * surface()
The current drawing surface.
Definition Fl_Device.H:81
virtual int printable_rect(int *w, int *h)
Computes the width and height of the drawable area of the drawing surface.
Definition Fl_Widget_Surface.cxx:190
virtual void origin(int x, int y)
Sets the position of the origin of graphics in the drawable part of the drawing surface.
Definition Fl_Widget_Surface.cxx:145
virtual void untranslate()
Undoes the effect of a previous translate() call.
Definition Fl_Widget_Surface.cxx:121
virtual void translate(int x, int y)
Translates the current graphics origin accounting for the current rotation.
Definition Fl_Widget_Surface.cxx:114
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:38