FLTK 1.4.5: Fl_SVG_File_Surface Class Reference

FLTK 1.4.5

Loading...
Searching...
No Matches
Fl_SVG_File_Surface Class Reference

A drawing surface producing a Scalable Vector Graphics (SVG) file. More...

`#include <Fl_SVG_File_Surface.H>`

Inheritance diagram for Fl_SVG_File_Surface:

## Public Member Functions
int | close ()
| Closes the FILE pointer where SVG data is output.
FILE * | file ()
| Returns the underlying FILE pointer.
| Fl_SVG_File_Surface (int width, int height, FILE *svg, int(*closef)(FILE *)=NULL)
| Constructor of the SVG drawing surface.
void | origin (int *x, int *y) FL_OVERRIDE
| Computes the coordinates of the current origin of graphics functions.
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 | printable_rect (int *w, int *h) FL_OVERRIDE
| Computes the width and height of the drawable area of the drawing surface.
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.
| ~Fl_SVG_File_Surface ()
| Destructor.
Public Member Functions inherited from Fl_Widget_Surface
void | draw (Fl_Widget *widget, int delta_x=0, int delta_y=0)
| Draws the widget on the drawing surface.
void | draw_decorated_window (Fl_Window *win, int x_offset=0, int y_offset=0)
| Draws a window with its title bar and frame if any.
void | print_window_part (Fl_Window *win, int x, int y, int w, int h, int delta_x=0, int delta_y=0)
| Draws a rectangular part of an on-screen window.
Public Member Functions inherited from Fl_Surface_Device
Fl_Graphics_Driver * | driver ()
| Returns the graphics driver of this drawing surface.
virtual bool | is_current ()
| Is this surface the current drawing surface?
virtual void | set_current (void)
| Make this surface the current drawing surface.
virtual | ~Fl_Surface_Device ()
| The destructor.

## Additional Inherited Members
Static Public Member Functions inherited from Fl_Surface_Device
static Fl_Surface_Device * | pop_current ()
| Removes the top element from the current drawing surface stack, and makes the new top element current.
static void | push_current (Fl_Surface_Device *new_current)
| Pushes `new_current` on top of the stack of current drawing surfaces, and makes it current.
static Fl_Surface_Device * | surface ()
| The current drawing surface.
Protected Member Functions inherited from Fl_Widget_Surface
| Fl_Widget_Surface (Fl_Graphics_Driver *d)
| The constructor.
Protected Member Functions inherited from Fl_Surface_Device
void | driver (Fl_Graphics_Driver *graphics_driver)
| Sets the graphics driver of this drawing surface.
virtual void | end_current ()
| FLTK calls this each time a surface ceases to be the current drawing surface.
| Fl_Surface_Device (Fl_Graphics_Driver *graphics_driver)
| Constructor that sets the graphics driver to use for the created surface.
Protected Attributes inherited from Fl_Widget_Surface
int | x_offset
| horizontal offset to the origin of graphics coordinates
int | y_offset
| vertical offset to the origin of graphics coordinates

## Detailed Description

A drawing surface producing a Scalable Vector Graphics (SVG) file.

This drawing surface allows to store any FLTK graphics in vectorial form in a "Scalable Vector Graphics" file.
Usage example:

Fl_Window *win = ...// Window to draw to a .svg file
int ww = win->decorated_w();
int wh = win->decorated_h();
FILE *svg = fl_fopen("/path/to/mywindow.svg", "w");
if (svg) {
Fl_SVG_File_Surface *surface = new Fl_SVG_File_Surface(ww, wh, svg);
Fl_Surface_Device::push_current(surface);
fl_color(FL_WHITE);
fl_rectf(0, 0, ww, wh);
surface->draw_decorated_window(win);
Fl_Surface_Device::pop_current();
delete surface; // the .svg file is not complete until the destructor was run
fclose(svg);
}
Fl_SVG_File_Surface::Fl_SVG_File_Surface
Fl_SVG_File_Surface(int width, int height, FILE *svg, int(*closef)(FILE *)=NULL)
Constructor of the SVG drawing surface.
Fl_Surface_Device::pop_current
static Fl_Surface_Device * pop_current()
Removes the top element from the current drawing surface stack, and makes the new top element current...
Definition Fl_Device.cxx:154
Fl_Surface_Device::push_current
static void push_current(Fl_Surface_Device *new_current)
Pushes new_current on top of the stack of current drawing surfaces, and makes it current.
Definition Fl_Device.cxx:140
Fl_Surface_Device::surface
static Fl_Surface_Device * surface()
The current drawing surface.
Definition Fl_Device.H:81
Fl_Window
This widget produces an actual window.
Definition Fl_Window.H:55
Fl_Window::decorated_w
int decorated_w() const
Returns the window width including any frame added by the window manager.
Definition Fl_Window.cxx:472
Fl_Window::decorated_h
int decorated_h() const
Returns the window height including any window title bar and any frame added by the window manager.
Definition Fl_Window.cxx:478
fl_color
Fl_Color fl_color()
Return the last fl_color() that was set.
Definition fl_draw.H:74
fl_rectf
void fl_rectf(int x, int y, int w, int h)
Color with current color a rectangle that exactly fills the given bounding box.
Definition fl_draw.H:339
fl_fopen
FILE * fl_fopen(const char *f, const char *mode)
Cross-platform function to open files with a UTF-8 encoded name.
Definition fl_utf8.cxx:432

Note
  FLTK uses the PNG and JPEG libraries to encode images to the SVG format. For this reason, class Fl_SVG_File_Surface is placed in the fltk_images library. If JPEG is not available at application build time, PNG is enough (but produces a quite larger output). If PNG isn't available either, images don't appear in the SVG output.

## Constructor & Destructor Documentation

## ◆ Fl_SVG_File_Surface()

Fl_SVG_File_Surface::Fl_SVG_File_Surface | ( | int | width,
|  | int | height,
|  | FILE * | svg,
|  | int(* | closef )(FILE *) = NULL )

Constructor of the SVG drawing surface.

Parameters

  width,height | Width and height of the graphics area in FLTK drawing units
  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().
  closef | If not NULL, the destructor and close() will call `closef(svg)` after all SVG data has been sent. If NULL, `fclose(svg)` is called instead. This allows to close the FILE pointer by, e.g., `pclose`, or, using a function such as `"int keep_open(FILE*){return 0;}"`, to keep it open after completion of all output to `svg`. Function `closef` should return non zero to indicate an error.

## ◆ ~Fl_SVG_File_Surface()

Fl_SVG_File_Surface::~Fl_SVG_File_Surface | ( |  | ) |

Destructor.

The underlying FILE pointer is processed as by close().

## Member Function Documentation

## ◆ close()

int Fl_SVG_File_Surface::close | ( |  | ) |

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.

Returns
  The value returned by the closing function call.

## ◆ origin() [1/2]

void Fl_SVG_File_Surface::origin | ( | int * | x,
|  | int * | y )
| virtual

Computes the coordinates of the current origin of graphics functions.

Parameters

  [out] | x,y | If non-null, *x and *y are set to the horizontal and vertical coordinates of the graphics origin.

Reimplemented from Fl_Widget_Surface.

## ◆ origin() [2/2]

void Fl_SVG_File_Surface::origin | ( | int | x,
|  | int | y )
| virtual

Sets the position of the origin of graphics in the drawable part of the drawing surface.

Arguments should be expressed relatively to the result of a previous printable_rect() call. That is, printable_rect(&w, &h); origin(w/2, 0); sets the graphics origin at the top center of the drawable area. Successive origin() calls don't combine their effects. Origin() calls are not affected by rotate() calls (for classes derived from Fl_Paged_Device).

Parameters

  [in] | x,y | Horizontal and vertical positions in the drawing surface of the desired origin of graphics.

Reimplemented from Fl_Widget_Surface.

## ◆ printable_rect()

int Fl_SVG_File_Surface::printable_rect | ( | int * | w,
|  | int * | h )
| virtual

Computes the width and height of the drawable area of the drawing surface.

Values are in the same unit as that used by FLTK drawing functions and are unchanged by calls to origin(). If the object is derived from class Fl_Paged_Device, values account for the user-selected paper type and print orientation and are changed by scale() calls.

Returns
  0 if OK, non-zero if any error

Reimplemented from Fl_Widget_Surface.

## ◆ translate()

void Fl_SVG_File_Surface::translate | ( | int | x,
|  | int | y )
| virtual

Translates the current graphics origin accounting for the current rotation.

Each translate() call must be matched by an untranslate() call. Successive translate() calls add up their effects.

Reimplemented from Fl_Widget_Surface.

## ◆ untranslate()

void Fl_SVG_File_Surface::untranslate | ( | void |  | ) |
| virtual

Undoes the effect of a previous translate() call.

Reimplemented from Fl_Widget_Surface.

The documentation for this class was generated from the following file:

- Fl_SVG_File_Surface.H