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
|
|
|
//
|
2016-02-09 21:25:02 +03:00
|
|
|
// Copyright 2010-2016 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;
|
2011-02-07 16:49:34 +03:00
|
|
|
class Fl_Font_Descriptor;
|
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).
|
|
|
|
<li> Memorize what is the current drawing surface with <tt> Fl_Surface_Device *old_current = Fl_Surface_Device::surface();</tt>
|
|
|
|
<li> Call \c surface->set_current(); 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()).
|
2015-03-24 17:20:38 +03:00
|
|
|
<li> At this point any 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()) operates 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
|
2015-02-26 18:38:54 +03:00
|
|
|
with \c old_current->set_current();.
|
2015-03-24 17:20:38 +03:00
|
|
|
<li> Delete \c surface.
|
|
|
|
</ol>
|
2010-05-27 21:20:18 +04:00
|
|
|
*/
|
2016-02-25 20:56:48 +03:00
|
|
|
class FL_EXPORT Fl_Surface_Device {
|
2010-05-27 21:20:18 +04:00
|
|
|
/** \brief The graphics driver in use by this surface. */
|
2016-03-07 23:50:18 +03:00
|
|
|
Fl_Graphics_Driver *pGraphicsDriver;
|
2011-02-02 15:42:47 +03:00
|
|
|
static Fl_Surface_Device *_surface; // the surface that currently receives graphics output
|
2016-03-07 23:50:18 +03:00
|
|
|
static Fl_Surface_Device *default_surface(); // create surface if none exists yet
|
2010-05-27 21:20:18 +04:00
|
|
|
protected:
|
|
|
|
/** \brief Constructor that sets the graphics driver to use for the created surface. */
|
2016-03-07 23:50:18 +03:00
|
|
|
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.
|
|
|
|
In other words, the Fl_Surface_Device object that currently receives all graphics output */
|
2015-12-16 10:18:34 +03:00
|
|
|
static inline Fl_Surface_Device *surface() {
|
|
|
|
return _surface ? _surface : default_surface();
|
|
|
|
};
|
2010-05-27 21:20:18 +04:00
|
|
|
/** \brief The destructor. */
|
2016-03-03 03:07:17 +03:00
|
|
|
virtual ~Fl_Surface_Device();
|
2010-05-27 21:20:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-02-26 18:38:54 +03:00
|
|
|
A display to which the computer can draw.
|
|
|
|
When the program begins running, an Fl_Display_Device instance has been created and made the current drawing surface.
|
|
|
|
There is no need to create any other object of this class.
|
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 {
|
2014-11-19 19:23:36 +03:00
|
|
|
friend class Fl_X;
|
2015-06-10 13:32:09 +03:00
|
|
|
friend class Fl_Graphics_Driver;
|
2016-02-09 15:33:49 +03:00
|
|
|
static Fl_Display_Device *_display; // the platform display device
|
2014-11-25 17:15:36 +03:00
|
|
|
static bool high_res_window_; //< true when drawing to a window of a retina display (Mac OS X only)
|
2010-05-27 21:20:18 +04:00
|
|
|
public:
|
2011-03-01 14:58:36 +03:00
|
|
|
Fl_Display_Device(Fl_Graphics_Driver *graphics_driver);
|
2015-04-29 01:02:48 +03:00
|
|
|
static Fl_Display_Device *display_device();
|
2016-02-09 15:33:49 +03:00
|
|
|
static bool high_resolution() {return high_res_window_;}
|
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
|
|
|
|
window or screen types. 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$".
|
|
|
|
//
|