1 //
2 // "$Id: Fl_Device.cxx 8504 2011-03-04 16:48:10Z manolo $"
3 //
4 // implementation of Fl_Device class for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright 2010-2011 by Bill Spitzak and others.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
22 //
23 // Please report all bugs and problems to:
24 //
25 //     http://www.fltk.org/str.php
26 //
27 
28 #include <FL/Fl.H>
29 #include <FL/Fl_Device.H>
30 #include <FL/Fl_Image.H>
31 
32 const char *Fl_Device::class_id = "Fl_Device";
33 const char *Fl_Surface_Device::class_id = "Fl_Surface_Device";
34 const char *Fl_Display_Device::class_id = "Fl_Display_Device";
35 const char *Fl_Graphics_Driver::class_id = "Fl_Graphics_Driver";
36 #if defined(__APPLE__) || defined(FL_DOXYGEN)
37 const char *Fl_Quartz_Graphics_Driver::class_id = "Fl_Quartz_Graphics_Driver";
38 #endif
39 #if defined(WIN32) || defined(FL_DOXYGEN)
40 const char *Fl_GDI_Graphics_Driver::class_id = "Fl_GDI_Graphics_Driver";
41 #endif
42 #if !(defined(__APPLE__) || defined(WIN32))
43 const char *Fl_Xlib_Graphics_Driver::class_id = "Fl_Xlib_Graphics_Driver";
44 #endif
45 
46 
47 /** \brief Use this drawing surface for future graphics requests. */
set_current(void)48 void Fl_Surface_Device::set_current(void)
49 {
50   fl_graphics_driver = _driver;
51   _surface = this;
52 }
53 
54 const Fl_Graphics_Driver::matrix Fl_Graphics_Driver::m0 = {1, 0, 0, 1, 0, 0};
55 
Fl_Graphics_Driver()56 Fl_Graphics_Driver::Fl_Graphics_Driver() {
57   font_ = 0;
58   size_ = 0;
59   sptr=0; rstackptr=0;
60   fl_clip_state_number=0;
61   m = m0;
62   fl_matrix = &m;
63   p = (XPOINT *)0;
64   font_descriptor_ = NULL;
65 };
66 
text_extents(const char * t,int n,int & dx,int & dy,int & w,int & h)67 void Fl_Graphics_Driver::text_extents(const char*t, int n, int& dx, int& dy, int& w, int& h)
68 {
69   w = (int)width(t, n);
70   h = - height();
71   dx = 0;
72   dy = descent();
73 }
74 
Fl_Display_Device(Fl_Graphics_Driver * graphics_driver)75 Fl_Display_Device::Fl_Display_Device(Fl_Graphics_Driver *graphics_driver) : Fl_Surface_Device( graphics_driver) {
76 #ifdef __APPLE__
77   SInt32 versionMajor = 0;
78   SInt32 versionMinor = 0;
79   SInt32 versionBugFix = 0;
80   Gestalt( gestaltSystemVersionMajor, &versionMajor );
81   Gestalt( gestaltSystemVersionMinor, &versionMinor );
82   Gestalt( gestaltSystemVersionBugFix, &versionBugFix );
83   fl_mac_os_version = versionMajor * 10000 + versionMinor * 100 + versionBugFix;
84 #endif
85 };
86 
87 
88 //
89 // End of "$Id: Fl_Device.cxx 8504 2011-03-04 16:48:10Z manolo $".
90 //
91