diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-11-03 18:05:10 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2020-11-03 18:05:18 +0100 |
| commit | 0d594319c1f423679c7e7cd712003921da103c70 (patch) | |
| tree | ecdc31a39baa10de21cef5c0fcb95b5e1a1a9142 /FL | |
| parent | 5132bb6a062b68be8f0e9e84fb5ae979ab613ea5 (diff) | |
Add extra argument to Fl_SVG_File_Surface constructor.
This makes processing of the underlying FILE object consistant by classes
Fl_SVG_File_Surface, Fl_EPS_File_Surface and Fl_PostScript_File_Surface.
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_SVG_File_Surface.H | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/FL/Fl_SVG_File_Surface.H b/FL/Fl_SVG_File_Surface.H index 74437326f..67d0aa4db 100644 --- a/FL/Fl_SVG_File_Surface.H +++ b/FL/Fl_SVG_File_Surface.H @@ -46,17 +46,21 @@ */ class FL_EXPORT Fl_SVG_File_Surface : public Fl_Widget_Surface { int width_, height_; + int (*closef_)(FILE*); public: /** Constructor of the SVG drawing surface. \param width,height Width and height of the graphics area in FLTK drawing units \param svg A writable FILE pointer where the SVG data are to be sent. The resulting SVG data are not complete until after destruction of the Fl_SVG_File_Surface object or after calling close(). - */ - Fl_SVG_File_Surface(int width, int height, FILE *svg); + \param closef If not NULL, the destructor and close() will call \p closef(svg) after all + SVG data has been sent. If NULL, \p fclose(svg) is called instead. This allows to close the FILE + pointer by, e.g., \p pclose, or, using a function such as \p "int keep_open(FILE*){return 0;}", to keep it open after + completion of all output to \p svg. Function \p closef should return non zero to indicate an error. + */ + Fl_SVG_File_Surface(int width, int height, FILE *svg, int (*closef)(FILE*) = NULL); /** Destructor. - The underlying FILE pointer remains open after destruction of the Fl_SVG_File_Surface object - unless close() was called. + The underlying FILE pointer is processed as by close(). */ ~Fl_SVG_File_Surface(); /** Returns the underlying FILE pointer */ @@ -65,9 +69,10 @@ public: virtual void translate(int x, int y); virtual void untranslate(); virtual int printable_rect(int *w, int *h); - /** Closes with function fclose() the FILE pointer where SVG data is output. + /** Closes the FILE pointer where SVG data is output. + The underlying FILE is closed by function fclose() unless another function was set at object's construction time. The only operation possible after this on the Fl_SVG_File_Surface object is its destruction. - \return The value returned by fclose(). */ + \return The value returned by the closing function call. */ int close(); }; |
