FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Copy_Surface Class Reference

Supports copying of graphical data to the clipboard. More...

#include <Fl_Copy_Surface.H>

Inheritance diagram for Fl_Copy_Surface:
Fl_Widget_Surface Fl_Surface_Device

Public Member Functions

 Fl_Copy_Surface (int w, int h)
 the constructor
 
int h ()
 Returns the pixel height of the copy surface.
 
bool is_current () FL_OVERRIDE
 Is this surface the current 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 set_current () FL_OVERRIDE
 Make this surface the current drawing surface.
 
int w ()
 Returns the pixel width of the copy surface.
 
 ~Fl_Copy_Surface ()
 the 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 ~Fl_Surface_Device ()
 The destructor.
 

Protected Member Functions

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

Additional Inherited Members

- Static Public Member Functions inherited from Fl_Surface_Device
static Fl_Surface_Devicepop_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_Devicesurface ()
 The current drawing 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

Supports copying of graphical data to the clipboard.


After creation of an Fl_Copy_Surface object, make it the current drawing surface calling Fl_Surface_Device::push_current(), and all subsequent graphics requests will be recorded in the clipboard. It's possible to draw widgets (using Fl_Copy_Surface::draw() ) or to use any of the Drawing functions or the Color & Font functions. Finally, delete the Fl_Copy_Surface object to load the clipboard with the graphical data.
Fl_Gl_Window 's can be copied to the clipboard as well.
Usage example:

Fl_Widget *g = ...; // a widget you want to copy to the clipboard
Fl_Copy_Surface *copy_surf = new Fl_Copy_Surface(g->w(), g->h()); // create an Fl_Copy_Surface object
Fl_Surface_Device::push_current(copy_surf); // direct graphics requests to the clipboard
fl_color(FL_WHITE); fl_rectf(0, 0, g->w(), g->h()); // draw a white background
copy_surf->draw(g); // draw the g widget in the clipboard
Fl_Surface_Device::pop_current(); // direct graphics requests back to their previous destination
delete copy_surf; // after this, the clipboard is loaded
Supports copying of graphical data to the clipboard.
Definition Fl_Copy_Surface.H:49
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:143
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:129
void draw(Fl_Widget *widget, int delta_x=0, int delta_y=0)
Draws the widget on the drawing surface.
Definition Fl_Widget_Surface.cxx:43
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:104
void w(int v)
Internal use only.
Definition Fl_Widget.H:146
void h(int v)
Internal use only.
Definition Fl_Widget.H:148
Fl_Color fl_color()
Return the last fl_color() that was set.
Definition fl_draw.H:74
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:330

Platform details:

  • Windows: Transparent RGB images copy without transparency. The graphical data are copied to the clipboard in two formats: 1) as an 'enhanced metafile'; 2) as a color bitmap. Applications to which the clipboard content is pasted can use the format that suits them best.
  • Mac OS: The graphical data are copied to the clipboard (a.k.a. pasteboard) in two 'flavors': 1) in vectorial form as PDF data; 2) in bitmap form as a TIFF image. Applications to which the clipboard content is pasted can use the flavor that suits them best.
  • X11 and Wayland: the graphical data are copied to the clipboard as an image in BMP format.

Constructor & Destructor Documentation

◆ Fl_Copy_Surface()

Fl_Copy_Surface::Fl_Copy_Surface ( int  w,
int  h 
)

the constructor

Parameters
w,hWidth and height of the drawing surface in FLTK units

Member Function Documentation

◆ is_current()

bool Fl_Copy_Surface::is_current ( )
virtual

Is this surface the current drawing surface?

Reimplemented from Fl_Surface_Device.

◆ origin() [1/2]

void Fl_Copy_Surface::origin ( int *  x,
int *  y 
)
virtual

Computes the coordinates of the current origin of graphics functions.

Parameters
[out]x,yIf 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_Copy_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,yHorizontal and vertical positions in the drawing surface of the desired origin of graphics.

Reimplemented from Fl_Widget_Surface.

◆ printable_rect()

int Fl_Copy_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.

◆ set_current()

void Fl_Copy_Surface::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, the preferred API to change the current drawing surface is Fl_Surface_Device::push_current( ) / Fl_Surface_Device::pop_current().

Note
It's recommended to use this function only as follows : Other scenarios of drawing surface changes should be performed via Fl_Surface_Device::push_current( ) / Fl_Surface_Device::pop_current().

Reimplemented from Fl_Surface_Device.

◆ translate()

void Fl_Copy_Surface::translate ( int  x,
int  y 
)
protectedvirtual

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_Copy_Surface::untranslate ( void  )
protectedvirtual

Undoes the effect of a previous translate() call.

Reimplemented from Fl_Widget_Surface.


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