FLTK 1.3.7: Fl_Surface_Device Class Reference

FLTK 1.3.7

Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
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:

## Public Member Functions
const char * | class_name ()
| Returns the name of the class of this object. More...
Fl_Graphics_Driver * | driver ()
| Returns the graphics driver of this drawing surface.
void | driver (Fl_Graphics_Driver *graphics_driver)
| Sets the graphics driver of this drawing surface.
virtual void | set_current (void)
| Make this surface the current drawing surface. More...
virtual | ~Fl_Surface_Device ()
| The destructor.
Public Member Functions inherited from Fl_Device
virtual | ~Fl_Device ()
| Virtual destructor. More...

## Static Public Member Functions
static Fl_Surface_Device * | surface ()
| The current drawing surface. More...

## Static Public Attributes
static const char * | class_id = "Fl_Surface_Device"
Static Public Attributes inherited from Fl_Device
static const char * | class_id = "Fl_Device"
| A string that identifies each subclass of Fl_Device. More...

## Protected Member Functions
| Fl_Surface_Device (Fl_Graphics_Driver *graphics_driver)
| Constructor that sets the graphics driver to use for the created surface.

## 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. Memorize what is the current drawing surface with `Fl_Surface_Device *old_current = Fl_Surface_Device::surface();`
3. Call `surface->set_current()`; 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::start_job()).
4. At this point any 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()) operates on the new current drawing surface. Certain drawing surfaces allow additional ways to draw to them (e.g., Fl_Printer::print_widget(), Fl_Image_Surface::draw()).
5. After all drawing requests have been performed, redirect graphics requests back to their previous destination with `old_current->set_current()`;.
6. Delete `surface`.

## Member Function Documentation

## ◆ class_name()

const char* Fl_Surface_Device::class_name | ( |  | ) |
| inlinevirtual

Returns the name of the class of this object.

Use of the class_name() function is discouraged because it will be removed from future FLTK versions.

The class of an instance of an Fl_Device subclass can be checked with code such as:

if ( instance->class_name() == Fl_Printer::class_id ) { ... }

Reimplemented from Fl_Device.

Reimplemented in Fl_Printer, Fl_PostScript_Printer, Fl_System_Printer, Fl_PostScript_File_Device, Fl_Paged_Device, Fl_Image_Surface, and Fl_Display_Device.

## ◆ 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.

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 output

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

- Fl_Device.H
- Fl_Device.cxx

- Copyright © 1998-2021 by Bill Spitzak and others.