2014-05-23 20:47:21 +04:00
|
|
|
//
|
|
|
|
// Copy-to-clipboard code for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
|
|
|
// Copyright 1998-2014 by Bill Spitzak and others.
|
|
|
|
//
|
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
2014-05-23 20:47:21 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2014-05-23 20:47:21 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
2014-05-23 20:47:21 +04:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Fl_Copy_Surface_H
|
|
|
|
#define Fl_Copy_Surface_H
|
|
|
|
|
2016-03-01 21:07:12 +03:00
|
|
|
#include <FL/Fl_Widget_Surface.H>
|
2014-05-23 20:47:21 +04:00
|
|
|
|
|
|
|
/** Supports copying of graphical data to the clipboard.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2018-02-25 09:53:34 +03:00
|
|
|
<br> 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
|
2014-05-23 20:47:21 +04:00
|
|
|
will be recorded in the clipboard. It's possible to draw widgets (using Fl_Copy_Surface::draw()
|
|
|
|
) or to use any of the \ref fl_drawings or the \ref fl_attributes.
|
|
|
|
Finally, delete the Fl_Copy_Surface object to load the clipboard with the graphical data.
|
2020-07-01 19:03:10 +03:00
|
|
|
<br> Fl_Gl_Window 's can be copied to the clipboard as well.
|
2014-05-23 20:47:21 +04:00
|
|
|
<br> Usage example:
|
|
|
|
\code
|
|
|
|
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
|
2018-02-25 09:53:34 +03:00
|
|
|
Fl_Surface_Device::push_current(copy_surf); // direct graphics requests to the clipboard
|
2014-05-23 20:47:21 +04:00
|
|
|
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
|
2018-02-25 09:53:34 +03:00
|
|
|
Fl_Surface_Device::pop_current(); // direct graphics requests back to their previous destination
|
2014-05-23 20:47:21 +04:00
|
|
|
delete copy_surf; // after this, the clipboard is loaded
|
|
|
|
\endcode
|
|
|
|
Platform details:
|
2018-02-09 17:39:42 +03:00
|
|
|
\li Windows: Transparent RGB images copy without transparency.
|
2019-07-20 09:59:15 +03:00
|
|
|
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.
|
2015-10-21 09:12:32 +03:00
|
|
|
\li Mac OS: The graphical data are copied to the clipboard (a.k.a. pasteboard) in two 'flavors':
|
2020-07-01 19:03:10 +03:00
|
|
|
1) in vectorial form as PDF data; 2) in bitmap form as a TIFF image.
|
2014-05-23 20:47:21 +04:00
|
|
|
Applications to which the clipboard content is pasted can use the flavor that suits them best.
|
2015-10-21 09:12:32 +03:00
|
|
|
\li X11: the graphical data are copied to the clipboard as an image in BMP format.
|
2014-05-23 20:47:21 +04:00
|
|
|
*/
|
2016-02-26 15:51:47 +03:00
|
|
|
class FL_EXPORT Fl_Copy_Surface : public Fl_Widget_Surface {
|
2014-05-23 20:47:21 +04:00
|
|
|
private:
|
2016-03-19 21:14:58 +03:00
|
|
|
class Fl_Copy_Surface_Driver *platform_surface;
|
2016-02-26 15:51:47 +03:00
|
|
|
protected:
|
|
|
|
void translate(int x, int y);
|
|
|
|
void untranslate();
|
2014-05-23 20:47:21 +04:00
|
|
|
public:
|
|
|
|
Fl_Copy_Surface(int w, int h);
|
|
|
|
~Fl_Copy_Surface();
|
|
|
|
void set_current();
|
2019-04-10 14:14:04 +03:00
|
|
|
virtual bool is_current();
|
2014-11-08 21:10:35 +03:00
|
|
|
/** Returns the pixel width of the copy surface */
|
2016-03-01 20:20:25 +03:00
|
|
|
int w();
|
2014-11-08 21:10:35 +03:00
|
|
|
/** Returns the pixel height of the copy surface */
|
2016-03-01 20:20:25 +03:00
|
|
|
int h();
|
|
|
|
void origin(int *x, int *y);
|
2016-03-02 15:36:37 +03:00
|
|
|
void origin(int x, int y);
|
|
|
|
int printable_rect(int *w, int *h);
|
2014-05-23 20:47:21 +04:00
|
|
|
};
|
|
|
|
|
2016-03-19 21:14:58 +03:00
|
|
|
|
2018-06-23 19:47:40 +03:00
|
|
|
/**
|
2018-06-23 23:50:22 +03:00
|
|
|
\cond DriverDev
|
|
|
|
\addtogroup DriverDeveloper
|
|
|
|
\{
|
2018-06-23 19:47:40 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-23 23:50:22 +03:00
|
|
|
A base class describing the interface between FLTK and draw-to-clipboard operations.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2018-06-23 23:50:22 +03:00
|
|
|
This class is only for internal use by the FLTK library.
|
|
|
|
|
|
|
|
A supported platform should implement the virtual methods of this class
|
|
|
|
in order to support drawing to the clipboard through class Fl_Copy_Surface.
|
2016-04-23 09:27:31 +03:00
|
|
|
*/
|
2016-03-19 21:14:58 +03:00
|
|
|
class Fl_Copy_Surface_Driver : public Fl_Widget_Surface {
|
|
|
|
friend class Fl_Copy_Surface;
|
|
|
|
protected:
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
Fl_Copy_Surface_Driver(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) {}
|
|
|
|
virtual ~Fl_Copy_Surface_Driver() {}
|
2019-04-10 14:14:04 +03:00
|
|
|
virtual void set_current() = 0;
|
|
|
|
virtual void translate(int x, int y) = 0;
|
|
|
|
virtual void untranslate() = 0;
|
|
|
|
int printable_rect(int *w, int *h);
|
2016-04-24 22:30:17 +03:00
|
|
|
/** Each platform implements this function its own way.
|
|
|
|
It returns an object implementing all virtual functions
|
|
|
|
of class Fl_Copy_Surface_Driver for the plaform.
|
|
|
|
*/
|
2016-03-19 21:14:58 +03:00
|
|
|
static Fl_Copy_Surface_Driver *newCopySurfaceDriver(int w, int h);
|
|
|
|
};
|
|
|
|
|
2018-06-23 19:47:40 +03:00
|
|
|
/**
|
2018-06-23 23:50:22 +03:00
|
|
|
\}
|
|
|
|
\endcond
|
2018-06-23 19:47:40 +03:00
|
|
|
*/
|
2016-03-19 21:14:58 +03:00
|
|
|
|
2014-05-23 20:47:21 +04:00
|
|
|
#endif // Fl_Copy_Surface_H
|