FLTK
Fl_Device.H
Go to the documentation of this file.
1 //
2 // Definition of classes Fl_Surface_Device, Fl_Display_Device
3 // for the Fast Light Tool Kit (FLTK).
4 //
5 // Copyright 2010-2017 by Bill Spitzak and others.
6 //
7 // This library is free software. Distribution and use rights are outlined in
8 // the file "COPYING" which should have been included with this file. If this
9 // file is missing or damaged, see the license at:
10 //
11 // https://www.fltk.org/COPYING.php
12 //
13 // Please see the following page on how to report bugs and issues:
14 //
15 // https://www.fltk.org/bugs.php
16 //
17 
22 #ifndef Fl_Device_H
23 #define Fl_Device_H
24 
25 #include <FL/Fl_Plugin.H>
26 #include <FL/platform_types.h>
27 #include <stdlib.h>
28 
29 class Fl_Graphics_Driver;
30 class Fl_RGB_Image;
31 class Fl_Widget;
32 
65 class FL_EXPORT Fl_Surface_Device {
67  Fl_Graphics_Driver *pGraphicsDriver;
68  static Fl_Surface_Device *surface_; // the surface that currently receives graphics requests
69  static Fl_Surface_Device *default_surface(); // create surface if none exists yet
70 protected:
71  /* Some drawing surfaces (e.g., Fl_XXX_Image_Surface_Driver) re-implement this.
72  Gets called each time a surface ceases to be the current drawing surface. */
73  virtual void end_current() { surface_ = 0;}
75  Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver; }
77  inline void driver(Fl_Graphics_Driver *graphics_driver) {pGraphicsDriver = graphics_driver;};
78 public:
79  virtual void set_current(void);
80  virtual bool is_current();
82  inline Fl_Graphics_Driver *driver() {return pGraphicsDriver; };
85  static inline Fl_Surface_Device *surface() {
86  return surface_ ? surface_ : default_surface();
87  };
89  virtual ~Fl_Surface_Device();
90  static void push_current(Fl_Surface_Device *new_current);
91  static Fl_Surface_Device *pop_current();
92 };
93 
98 class FL_EXPORT Fl_Display_Device : public Fl_Surface_Device {
99  Fl_Display_Device(Fl_Graphics_Driver *graphics_driver);
100 public:
101  static Fl_Display_Device *display_device();
102 };
103 
111 class FL_EXPORT Fl_Device_Plugin : public Fl_Plugin {
112 public:
114  Fl_Device_Plugin(const char *pluginName)
115  : Fl_Plugin(klass(), pluginName) { }
117  virtual const char *klass() { return "fltk:device"; }
119  virtual const char *name() = 0;
121  virtual int print(Fl_Widget* w) = 0;
125  virtual Fl_RGB_Image* rectangle_capture(Fl_Widget *widget, int x, int y, int w, int h) = 0;
127  static Fl_Device_Plugin *opengl_plugin();
128 };
129 
130 #endif // Fl_Device_H
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:85
virtual const char * klass()
Returns the class name.
Definition: Fl_Device.H:117
A drawing surface that&#39;s susceptible to receive graphical output.
Definition: Fl_Device.H:65
Definitions of platform-dependent types.
void driver(Fl_Graphics_Driver *graphics_driver)
Sets the graphics driver of this drawing surface.
Definition: Fl_Device.H:77
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition: Fl_Image.H:287
This plugin socket allows the integration of new device drivers for special window or screen types...
Definition: Fl_Device.H:111
Fl_Surface_Device(Fl_Graphics_Driver *graphics_driver)
Constructor that sets the graphics driver to use for the created surface.
Definition: Fl_Device.H:75
static Fl_Surface_Device * surface()
The current drawing surface.
Definition: Fl_Device.H:85
Fl_Plugin allows link-time and run-time integration of binary modules.
Definition: Fl_Plugin.H:59
Fl_Device_Plugin(const char *pluginName)
The constructor.
Definition: Fl_Device.H:114
A display to which the computer can draw.
Definition: Fl_Device.H:98
Fl_Graphics_Driver * driver()
Returns the graphics driver of this drawing surface.
Definition: Fl_Device.H:82