2010-03-18 18:15:41 +03:00
|
|
|
//
|
|
|
|
// "$Id$"
|
|
|
|
//
|
2016-02-25 20:56:48 +03:00
|
|
|
// Definition of classes Fl_Surface_Device, Fl_Display_Device
|
2010-05-27 21:20:18 +04:00
|
|
|
// for the Fast Light Tool Kit (FLTK).
|
2010-03-18 18:15:41 +03:00
|
|
|
//
|
2017-04-25 15:42:22 +03:00
|
|
|
// Copyright 2010-2017 by Bill Spitzak and others.
|
2010-03-18 18:15:41 +03:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// 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:
|
2010-03-18 18:15:41 +03:00
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// http://www.fltk.org/COPYING.php
|
2010-03-18 18:15:41 +03:00
|
|
|
//
|
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
|
2010-03-25 16:59:00 +03:00
|
|
|
/** \file Fl_Device.H
|
2016-02-25 20:56:48 +03:00
|
|
|
\brief declaration of classes Fl_Surface_Device, Fl_Display_Device, Fl_Device_Plugin.
|
2010-03-25 16:59:00 +03:00
|
|
|
*/
|
2010-03-14 21:07:24 +03:00
|
|
|
|
|
|
|
#ifndef Fl_Device_H
|
|
|
|
#define Fl_Device_H
|
|
|
|
|
2010-03-17 01:51:31 +03:00
|
|
|
#include <FL/Fl_Plugin.H>
|
2012-02-17 13:19:15 +04:00
|
|
|
#include <stdlib.h>
|
2010-03-14 21:07:24 +03:00
|
|
|
|
2010-05-27 21:20:18 +04:00
|
|
|
class Fl_Graphics_Driver;
|
2016-02-10 22:49:35 +03:00
|
|
|
class Fl_RGB_Image;
|
2016-02-20 00:41:02 +03:00
|
|
|
class Fl_Widget;
|
2011-02-05 02:32:53 +03:00
|
|
|
|
2010-05-27 21:20:18 +04:00
|
|
|
/**
|
2015-12-22 13:15:28 +03:00
|
|
|
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:
|
2015-03-24 17:20:38 +03:00
|
|
|
<ol><li> Create \c surface, an object from a particular Fl_Surface_Device derived class (e.g., Fl_Copy_Surface, Fl_Printer).
|
2016-12-07 18:09:52 +03:00
|
|
|
<li> Call \c Fl_Surface_Device::push_current(surface); to redirect all graphics requests to \c surface which becomes the new
|
2015-02-26 18:38:54 +03:00
|
|
|
current drawing surface (not necessary with class Fl_Printer because it is done by Fl_Printer::start_job()).
|
2016-12-07 18:09:52 +03:00
|
|
|
<li> At this point all of the \ref fl_drawings (e.g., fl_rect()) or the \ref fl_attributes or \ref drawing_images functions
|
|
|
|
(e.g., fl_draw_image(), Fl_Image::draw()) operate on the new current drawing surface.
|
2015-02-26 18:38:54 +03:00
|
|
|
Certain drawing surfaces allow additional ways to draw to them (e.g., Fl_Printer::print_widget(), Fl_Image_Surface::draw()).
|
2015-03-24 17:20:38 +03:00
|
|
|
<li> After all drawing requests have been performed, redirect graphics requests back to their previous destination
|
2016-12-07 18:09:52 +03:00
|
|
|
with \c Fl_Surface_Device::pop_current();.
|
2015-03-24 17:20:38 +03:00
|
|
|
<li> Delete \c surface.
|
|
|
|
</ol>
|
2016-12-07 18:09:52 +03:00
|
|
|
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.
|
2010-05-27 21:20:18 +04:00
|
|
|
*/
|
2016-02-25 20:56:48 +03:00
|
|
|
class FL_EXPORT Fl_Surface_Device {
|
2016-11-30 10:09:48 +03:00
|
|
|
/** The graphics driver in use by this surface. */
|
2016-03-07 23:50:18 +03:00
|
|
|
Fl_Graphics_Driver *pGraphicsDriver;
|
2016-12-07 18:09:52 +03:00
|
|
|
static Fl_Surface_Device *surface_; // the surface that currently receives graphics requests
|
2016-03-07 23:50:18 +03:00
|
|
|
static Fl_Surface_Device *default_surface(); // create surface if none exists yet
|
2017-04-25 15:42:22 +03:00
|
|
|
/* Some drawing surfaces (e.g., Fl_XXX_Image_Surface_Driver) re-implement this.
|
|
|
|
Gets called each time a surface ceases to be the current drawing surface.
|
|
|
|
The next_current argument gives the drawing surface that will become current next */
|
|
|
|
virtual void end_current_(Fl_Surface_Device *next_current) {}
|
2010-05-27 21:20:18 +04:00
|
|
|
protected:
|
2016-11-30 10:09:48 +03:00
|
|
|
/** Constructor that sets the graphics driver to use for the created surface. */
|
|
|
|
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; }
|
2010-05-27 21:20:18 +04:00
|
|
|
public:
|
|
|
|
virtual void set_current(void);
|
|
|
|
/** \brief Sets the graphics driver of this drawing surface. */
|
2016-03-07 23:50:18 +03:00
|
|
|
inline void driver(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver;};
|
2010-05-27 21:20:18 +04:00
|
|
|
/** \brief Returns the graphics driver of this drawing surface. */
|
2016-03-07 23:50:18 +03:00
|
|
|
inline Fl_Graphics_Driver *driver() {return pGraphicsDriver; };
|
2015-03-24 17:20:38 +03:00
|
|
|
/** The current drawing surface.
|
2016-12-07 18:09:52 +03:00
|
|
|
In other words, the Fl_Surface_Device object that currently receives all graphics requests */
|
2015-12-16 10:18:34 +03:00
|
|
|
static inline Fl_Surface_Device *surface() {
|
2016-12-01 09:40:17 +03:00
|
|
|
return surface_ ? surface_ : default_surface();
|
2015-12-16 10:18:34 +03:00
|
|
|
};
|
2010-05-27 21:20:18 +04:00
|
|
|
/** \brief The destructor. */
|
2016-03-03 03:07:17 +03:00
|
|
|
virtual ~Fl_Surface_Device();
|
2016-12-07 18:09:52 +03:00
|
|
|
static void push_current(Fl_Surface_Device *new_current);
|
|
|
|
static Fl_Surface_Device *pop_current();
|
2010-05-27 21:20:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-02-26 18:38:54 +03:00
|
|
|
A display to which the computer can draw.
|
2016-04-26 08:44:54 +03:00
|
|
|
When the program begins running, an object of class Fl_Display_Device has been created and made the current drawing surface.
|
2010-05-27 21:20:18 +04:00
|
|
|
*/
|
2010-12-13 02:21:03 +03:00
|
|
|
class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device {
|
2011-03-01 14:58:36 +03:00
|
|
|
Fl_Display_Device(Fl_Graphics_Driver *graphics_driver);
|
2016-04-26 08:44:54 +03:00
|
|
|
public:
|
2015-04-29 01:02:48 +03:00
|
|
|
static Fl_Display_Device *display_device();
|
2010-05-27 21:20:18 +04:00
|
|
|
};
|
|
|
|
|
2010-12-12 19:13:55 +03:00
|
|
|
/**
|
|
|
|
This plugin socket allows the integration of new device drivers for special
|
2016-10-16 18:12:46 +03:00
|
|
|
window or screen types.
|
|
|
|
This class is not intended for use outside the FLTK library.
|
|
|
|
It is currently used to provide an automated printing
|
2014-11-06 19:48:57 +03:00
|
|
|
service and screen capture for OpenGL windows, if linked with fltk_gl.
|
2010-12-12 19:13:55 +03:00
|
|
|
*/
|
2010-12-13 02:21:03 +03:00
|
|
|
class FL_EXPORT Fl_Device_Plugin : public Fl_Plugin {
|
2010-12-12 19:13:55 +03:00
|
|
|
public:
|
|
|
|
/** \brief The constructor */
|
2011-10-02 10:25:13 +04:00
|
|
|
Fl_Device_Plugin(const char *pluginName)
|
|
|
|
: Fl_Plugin(klass(), pluginName) { }
|
2010-12-12 19:13:55 +03:00
|
|
|
/** \brief Returns the class name */
|
|
|
|
virtual const char *klass() { return "fltk:device"; }
|
|
|
|
/** \brief Returns the plugin name */
|
|
|
|
virtual const char *name() = 0;
|
|
|
|
/** \brief Prints a widget
|
|
|
|
\param w the widget
|
|
|
|
\param x,y offsets where to print relatively to coordinates origin
|
|
|
|
\param height height of the current drawing area
|
|
|
|
*/
|
2011-01-10 15:02:48 +03:00
|
|
|
virtual int print(Fl_Widget* w, int x, int y, int height) = 0;
|
2014-11-06 19:48:57 +03:00
|
|
|
/** captures a rectangle of a widget as an image
|
|
|
|
\return The captured pixels as an RGB image
|
|
|
|
*/
|
|
|
|
virtual Fl_RGB_Image* rectangle_capture(Fl_Widget *widget, int x, int y, int w, int h) = 0;
|
2010-12-12 19:13:55 +03:00
|
|
|
};
|
|
|
|
|
2010-03-14 21:07:24 +03:00
|
|
|
#endif // Fl_Device_H
|
2010-03-18 18:15:41 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// End of "$Id$".
|
|
|
|
//
|