2010-03-18 18:29:18 +03:00
|
|
|
//
|
|
|
|
// "$Id$"
|
|
|
|
//
|
2010-03-25 16:59:00 +03:00
|
|
|
// implementation of Fl_Device class for the Fast Light Tool Kit (FLTK).
|
2010-03-18 18:29:18 +03:00
|
|
|
//
|
2012-03-18 22:48:29 +04:00
|
|
|
// Copyright 2010-2012 by Bill Spitzak and others.
|
2010-03-18 18:29:18 +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:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
2010-03-18 18:29:18 +03:00
|
|
|
//
|
|
|
|
// Please report all bugs and problems to:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
|
|
|
//
|
2010-03-14 21:07:24 +03:00
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Device.H>
|
|
|
|
#include <FL/Fl_Image.H>
|
|
|
|
|
2011-01-05 13:21:45 +03:00
|
|
|
const char *Fl_Device::class_id = "Fl_Device";
|
|
|
|
const char *Fl_Surface_Device::class_id = "Fl_Surface_Device";
|
|
|
|
const char *Fl_Display_Device::class_id = "Fl_Display_Device";
|
|
|
|
const char *Fl_Graphics_Driver::class_id = "Fl_Graphics_Driver";
|
2010-05-27 21:20:18 +04:00
|
|
|
#if defined(__APPLE__) || defined(FL_DOXYGEN)
|
2011-01-05 13:21:45 +03:00
|
|
|
const char *Fl_Quartz_Graphics_Driver::class_id = "Fl_Quartz_Graphics_Driver";
|
2015-06-11 14:51:33 +03:00
|
|
|
# ifndef FL_DOXYGEN
|
|
|
|
bool Fl_Display_Device::high_res_window_ = false;
|
|
|
|
# endif
|
2010-05-27 21:20:18 +04:00
|
|
|
#endif
|
|
|
|
#if defined(WIN32) || defined(FL_DOXYGEN)
|
2011-01-05 13:21:45 +03:00
|
|
|
const char *Fl_GDI_Graphics_Driver::class_id = "Fl_GDI_Graphics_Driver";
|
2012-03-18 22:48:29 +04:00
|
|
|
const char *Fl_GDI_Printer_Graphics_Driver::class_id = "Fl_GDI_Printer_Graphics_Driver";
|
2010-05-27 21:20:18 +04:00
|
|
|
#endif
|
|
|
|
#if !(defined(__APPLE__) || defined(WIN32))
|
2011-01-05 13:21:45 +03:00
|
|
|
const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver";
|
2010-05-27 21:20:18 +04:00
|
|
|
#endif
|
2010-03-14 21:07:24 +03:00
|
|
|
|
|
|
|
|
2015-03-24 17:20:38 +03:00
|
|
|
/** \brief Make this surface the current drawing surface.
|
|
|
|
This surface will receive all future graphics requests. */
|
2010-05-27 21:20:18 +04:00
|
|
|
void Fl_Surface_Device::set_current(void)
|
2010-03-14 21:07:24 +03:00
|
|
|
{
|
2010-07-01 17:21:32 +04:00
|
|
|
fl_graphics_driver = _driver;
|
2011-02-02 15:42:47 +03:00
|
|
|
_surface = this;
|
2010-03-14 21:07:24 +03:00
|
|
|
}
|
2010-03-18 18:29:18 +03:00
|
|
|
|
2012-03-18 22:48:29 +04:00
|
|
|
FL_EXPORT Fl_Graphics_Driver *fl_graphics_driver; // the current target device of graphics operations
|
|
|
|
Fl_Surface_Device* Fl_Surface_Device::_surface; // the current target surface of graphics operations
|
|
|
|
|
2011-02-24 21:02:11 +03:00
|
|
|
const Fl_Graphics_Driver::matrix Fl_Graphics_Driver::m0 = {1, 0, 0, 1, 0, 0};
|
2011-02-05 02:32:53 +03:00
|
|
|
|
|
|
|
Fl_Graphics_Driver::Fl_Graphics_Driver() {
|
2011-02-05 16:54:56 +03:00
|
|
|
font_ = 0;
|
|
|
|
size_ = 0;
|
|
|
|
sptr=0; rstackptr=0;
|
2012-03-11 22:58:55 +04:00
|
|
|
rstack[0] = NULL;
|
2011-02-05 16:54:56 +03:00
|
|
|
fl_clip_state_number=0;
|
|
|
|
m = m0;
|
|
|
|
fl_matrix = &m;
|
|
|
|
p = (XPOINT *)0;
|
2011-02-07 16:49:34 +03:00
|
|
|
font_descriptor_ = NULL;
|
2012-02-16 17:09:34 +04:00
|
|
|
p_size = 0;
|
2011-02-05 02:32:53 +03:00
|
|
|
};
|
|
|
|
|
2011-02-18 16:39:48 +03:00
|
|
|
void Fl_Graphics_Driver::text_extents(const char*t, int n, int& dx, int& dy, int& w, int& h)
|
|
|
|
{
|
|
|
|
w = (int)width(t, n);
|
|
|
|
h = - height();
|
2011-02-19 10:36:29 +03:00
|
|
|
dx = 0;
|
|
|
|
dy = descent();
|
2011-02-18 16:39:48 +03:00
|
|
|
}
|
|
|
|
|
2015-04-29 01:02:48 +03:00
|
|
|
/** A constructor that sets the graphics driver used by the display */
|
|
|
|
Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device(graphics_driver) {
|
2015-12-15 11:31:20 +03:00
|
|
|
this->set_current();
|
2011-03-01 14:58:36 +03:00
|
|
|
};
|
|
|
|
|
2011-02-18 16:39:48 +03:00
|
|
|
|
2015-04-29 01:02:48 +03:00
|
|
|
/** Returns the platform display device. */
|
|
|
|
Fl_Display_Device *Fl_Display_Device::display_device() {
|
|
|
|
static Fl_Display_Device *display = new Fl_Display_Device(new
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
Fl_Quartz_Graphics_Driver
|
|
|
|
#elif defined(WIN32)
|
|
|
|
Fl_GDI_Graphics_Driver
|
|
|
|
#else
|
|
|
|
Fl_Xlib_Graphics_Driver
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
return display;
|
|
|
|
};
|
|
|
|
|
2015-12-16 10:18:34 +03:00
|
|
|
|
|
|
|
Fl_Surface_Device *Fl_Surface_Device::default_surface()
|
|
|
|
{
|
|
|
|
return Fl_Display_Device::display_device();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-29 01:02:48 +03:00
|
|
|
Fl_Display_Device *Fl_Display_Device::_display = Fl_Display_Device::display_device();
|
|
|
|
|
2010-03-18 18:29:18 +03:00
|
|
|
//
|
|
|
|
// End of "$Id$".
|
|
|
|
//
|