FLTK 1.4.0
Fl_Surface_Device Class Reference

A drawing surface that's susceptible to receive graphical output. More...

#include <Fl_Device.H>

Inheritance diagram for Fl_Surface_Device:
Fl_Display_Device Fl_Widget_Surface Fl_Copy_Surface Fl_EPS_File_Surface Fl_Image_Surface Fl_Paged_Device Fl_SVG_File_Surface Fl_PostScript_File_Device Fl_Printer

Public Member Functions

Fl_Graphics_Driver * driver ()
 Returns the graphics driver of this drawing surface. More...
 
virtual bool is_current ()
 Is this surface the current drawing surface?
 
virtual void set_current (void)
 Make this surface the current drawing surface. More...
 
virtual ~Fl_Surface_Device ()
 The destructor. More...
 

Static Public Member Functions

static Fl_Surface_Devicepop_current ()
 Removes the top element from the current drawing surface stack, and makes the new top element current. More...
 
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. More...
 
static Fl_Surface_Devicesurface ()
 The current drawing surface. More...
 

Protected Member Functions

void driver (Fl_Graphics_Driver *graphics_driver)
 Sets the graphics driver of this drawing surface. More...
 
virtual void end_current ()
 
 Fl_Surface_Device (Fl_Graphics_Driver *graphics_driver)
 Constructor that sets the graphics driver to use for the created surface. More...
 

Detailed Description

A drawing surface that's susceptible to receive graphical output.

Any FLTK application has at any time a current drawing surface to which all drawing requests are directed. The current surface is given by Fl_Surface_Device::surface(). When main() begins running, the current drawing surface has been set to the computer's display, an instance of the Fl_Display_Device class.

A drawing surface other than the computer's display, is typically used as follows:

  1. Create surface, an object from a particular Fl_Surface_Device derived class (e.g., Fl_Copy_Surface, Fl_Printer).
  2. Call Fl_Surface_Device::push_current(surface); to redirect all graphics requests to surface which becomes the new current drawing surface (not necessary with class Fl_Printer because it is done by Fl_Printer::begin_job()).
  3. At this point all of the Drawing functions (e.g., fl_rect()) or the Color & Font functions or Drawing Images functions (e.g., fl_draw_image(), Fl_Image::draw()) operate on the new current drawing surface. Drawing surfaces from Fl_Widget_Surface derived classes allow additional ways to draw to them (e.g., Fl_Printer::print_widget(), Fl_Image_Surface::draw()).
  4. After all drawing requests have been performed, redirect graphics requests back to their previous destination with Fl_Surface_Device::pop_current();.
  5. Delete surface.

For back-compatibility, it is also possible to use the Fl_Surface_Device::set_current() member function to change the current drawing surface, once to the new surface, once to the previous one.

Class Fl_Surface_Device can also be derived to define new kinds of graphical output usable with FLTK drawing functions. An example would be to draw to a PDF file. This would require to create a new class, say PDF_File_Surface, derived from class Fl_Surface_Device, and another new class, say PDF_Graphics_Driver, derived from class Fl_Graphics_Driver. Class PDF_Graphics_Driver should implement all virtual methods of the Fl_Graphics_Driver class to support all FLTK drawing functions and have them draw into PDF files. Alternatively, class PDF_Graphics_Driver could implement only some virtual methods, and only part of the FLTK drawing API would be usable when drawing to PDF files.

Constructor & Destructor Documentation

◆ Fl_Surface_Device()

Fl_Surface_Device::Fl_Surface_Device ( Fl_Graphics_Driver *  graphics_driver)
inlineprotected

Constructor that sets the graphics driver to use for the created surface.

◆ ~Fl_Surface_Device()

Fl_Surface_Device::~Fl_Surface_Device ( )
virtual

The destructor.

Member Function Documentation

◆ driver() [1/2]

void Fl_Surface_Device::driver ( Fl_Graphics_Driver *  graphics_driver)
inlineprotected

Sets the graphics driver of this drawing surface.

◆ driver() [2/2]

Fl_Graphics_Driver* Fl_Surface_Device::driver ( )
inline

Returns the graphics driver of this drawing surface.

◆ pop_current()

Fl_Surface_Device * Fl_Surface_Device::pop_current ( )
static

Removes the top element from the current drawing surface stack, and makes the new top element current.

Returns
A pointer to the new current drawing surface.
Version
1.4.0

◆ push_current()

void Fl_Surface_Device::push_current ( Fl_Surface_Device new_current)
static

Pushes new_current on top of the stack of current drawing surfaces, and makes it current.

new_current will receive all future graphics requests.

Version
1.4.0

◆ set_current()

void Fl_Surface_Device::set_current ( void  )
virtual

Make this surface the current drawing surface.

This surface will receive all future graphics requests. Starting from FLTK 1.4.0, another convenient API to set/unset the current drawing surface is Fl_Surface_Device::push_current( ) / Fl_Surface_Device::pop_current().

Reimplemented in Fl_Printer, Fl_Image_Surface, and Fl_Copy_Surface.

◆ surface()

static Fl_Surface_Device* Fl_Surface_Device::surface ( )
inlinestatic

The current drawing surface.

In other words, the Fl_Surface_Device object that currently receives all graphics requests


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