summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx72
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h16
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx98
-rw-r--r--src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h58
-rw-r--r--src/drivers/X11/Fl_X11_Screen_Driver.cxx98
-rw-r--r--src/drivers/X11/Fl_X11_Screen_Driver.h48
6 files changed, 390 insertions, 0 deletions
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
index f44beade4..94dedb813 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx
@@ -22,6 +22,78 @@
+/**
+ Creates a driver that manages all screen and display related calls.
+
+ This function must be implemented once for every platform. It is called
+ when the static members of the class "Fl" are created.
+ */
+Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
+{
+ return new Fl_Cocoa_Screen_Driver();
+}
+
+
+void Fl_Cocoa_Screen_Driver::init()
+{
+ CGDirectDisplayID displays[MAX_SCREENS];
+ CGDisplayCount count, i;
+ CGRect r;
+ CGGetActiveDisplayList(MAX_SCREENS, displays, &count);
+ for( i = 0; i < count; i++) {
+ r = CGDisplayBounds(displays[i]);
+ screens[i].x = int(r.origin.x);
+ screens[i].y = int(r.origin.y);
+ screens[i].width = int(r.size.width);
+ screens[i].height = int(r.size.height);
+ //fprintf(stderr,"screen %d %dx%dx%dx%d\n",i,screens[i].x,screens[i].y,screens[i].width,screens[i].height);
+ if (&CGDisplayScreenSize != NULL) {
+ CGSize s = CGDisplayScreenSize(displays[i]); // from 10.3
+ dpi_h[i] = screens[i].width / (s.width/25.4);
+ dpi_v[i] = screens[i].height / (s.height/25.4);
+ } else {
+ dpi_h[i] = dpi_v[i] = 75.;
+ }
+ }
+ num_screens = count;
+}
+
+
+void Fl_Cocoa_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, int n)
+{
+ if (num_screens < 0) init();
+ if (n < 0 || n >= num_screens) n = 0;
+ Fl_X::screen_work_area(X, Y, W, H, n);
+}
+
+
+void Fl_Cocoa_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n)
+{
+ if (num_screens < 0) init();
+
+ if ((n < 0) || (n >= num_screens))
+ n = 0;
+
+ X = screens[n].x;
+ Y = screens[n].y;
+ W = screens[n].width;
+ H = screens[n].height;
+}
+
+
+void Fl_Cocoa_Screen_Driver::screen_dpi(float &h, float &v, int n)
+{
+ if (num_screens < 0) init();
+ h = v = 0.0f;
+
+ if (n >= 0 && n < num_screens) {
+ h = dpi_h[n];
+ v = dpi_v[n];
+ }
+}
+
+
+
//
// End of "$Id$".
//
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h
index cc5b7150f..b0a64743c 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.h
@@ -25,6 +25,8 @@
#ifndef FL_COCOA_SCREEN_DRIVER_H
#define FL_COCOA_SCREEN_DRIVER_H
+#include <FL/Fl_Screen_Driver.H>
+
/*
Move everything here that manages the native screen interface.
@@ -35,6 +37,20 @@
- native dialog boxes
*/
+
+class FL_EXPORT Fl_Cocoa_Screen_Driver : public Fl_Screen_Driver {
+public:
+ virtual void init();
+ virtual int x();
+ virtual int y();
+ virtual int w();
+ virtual int h();
+ virtual void screen_xywh(int &X, int &Y, int &W, int &H, int n);
+ virtual void screen_dpi(float &h, float &v, int n=0);
+ virtual void screen_work_area(int &X, int &Y, int &W, int &H, int n);
+};
+
+
#endif // FL_COCOA_SCREEN_DRIVER_H
//
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
new file mode 100644
index 000000000..4f2da2e33
--- /dev/null
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.cxx
@@ -0,0 +1,98 @@
+//
+// "$Id$"
+//
+// Definition of MSWindows Win32/64 Screen interface
+//
+// Copyright 1998-2016 by Bill Spitzak and others.
+//
+// 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
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+
+#include "../../config_lib.h"
+#include "Fl_WinAPI_Screen_Driver.h"
+
+
+/**
+ Creates a driver that manages all screen and display related calls.
+
+ This function must be implemented once for every platform. It is called
+ when the static members of the class "Fl" are created.
+ */
+Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
+{
+ return new Fl_WinAPI_Screen_Driver();
+}
+
+
+void Fl_WinAPI_Screen_Driver::init()
+{
+ CGDirectDisplayID displays[MAX_SCREENS];
+ CGDisplayCount count, i;
+ CGRect r;
+ CGGetActiveDisplayList(MAX_SCREENS, displays, &count);
+ for( i = 0; i < count; i++) {
+ r = CGDisplayBounds(displays[i]);
+ screens[i].x = int(r.origin.x);
+ screens[i].y = int(r.origin.y);
+ screens[i].width = int(r.size.width);
+ screens[i].height = int(r.size.height);
+ //fprintf(stderr,"screen %d %dx%dx%dx%d\n",i,screens[i].x,screens[i].y,screens[i].width,screens[i].height);
+ if (&CGDisplayScreenSize != NULL) {
+ CGSize s = CGDisplayScreenSize(displays[i]); // from 10.3
+ dpi_h[i] = screens[i].width / (s.width/25.4);
+ dpi_v[i] = screens[i].height / (s.height/25.4);
+ } else {
+ dpi_h[i] = dpi_v[i] = 75.;
+ }
+ }
+ num_screens = count;
+}
+
+
+void Fl_WinAPI_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, int n)
+{
+ if (num_screens < 0) init();
+ if (n < 0 || n >= num_screens) n = 0;
+ Fl_X::screen_work_area(X, Y, W, H, n);
+}
+
+
+void Fl_WinAPI_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n)
+{
+ if (num_screens < 0) init();
+
+ if ((n < 0) || (n >= num_screens))
+ n = 0;
+
+ X = screens[n].x;
+ Y = screens[n].y;
+ W = screens[n].width;
+ H = screens[n].height;
+}
+
+
+void Fl_WinAPI_Screen_Driver::screen_dpi(float &h, float &v, int n)
+{
+ if (num_screens < 0) init();
+ h = v = 0.0f;
+
+ if (n >= 0 && n < num_screens) {
+ h = dpi_h[n];
+ v = dpi_v[n];
+ }
+}
+
+
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
new file mode 100644
index 000000000..2f7e104f0
--- /dev/null
+++ b/src/drivers/WinAPI/Fl_WinAPI_Screen_Driver.h
@@ -0,0 +1,58 @@
+//
+// "$Id: quartz.H 11017 2016-01-20 21:40:12Z matt $"
+//
+// Definition of MSWindows Win32/64 Screen interface
+// for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2010-2016 by Bill Spitzak and others.
+//
+// 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
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+/**
+ \file Fl_WinAPI_Screen_Driver.h
+ \brief Definition of MSWindows Win32/64 Screen interface.
+ */
+
+#ifndef FL_WINAPI_SCREEN_DRIVER_H
+#define FL_WINAPI_SCREEN_DRIVER_H
+
+#include <FL/Fl_Screen_Driver.H>
+
+/*
+ Move everything here that manages the native screen interface.
+
+ There is exactly one screen driver in the system.
+
+ - screen configuration and sizes
+ - multiple screens
+ - native dialog boxes
+*/
+
+
+class FL_EXPORT Fl_WinAPI_Screen_Driver : public Fl_Screen_Driver {
+public:
+ virtual void init();
+ virtual int x();
+ virtual int y();
+ virtual int w();
+ virtual int h();
+ virtual void screen_xywh(int &X, int &Y, int &W, int &H, int n);
+ virtual void screen_dpi(float &h, float &v, int n=0);
+ virtual void screen_work_area(int &X, int &Y, int &W, int &H, int n);
+};
+
+
+#endif // FL_WINAPI_SCREEN_DRIVER_H
+
+//
+// End of "$Id: quartz.H 11017 2016-01-20 21:40:12Z matt $".
+//
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx
new file mode 100644
index 000000000..2891ac1f9
--- /dev/null
+++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx
@@ -0,0 +1,98 @@
+//
+// "$Id$"
+//
+// Definition of X11 Screen interface
+//
+// Copyright 1998-2016 by Bill Spitzak and others.
+//
+// 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
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+
+#include "../../config_lib.h"
+#include "Fl_X11_Screen_Driver.h"
+
+
+/**
+ Creates a driver that manages all screen and display related calls.
+
+ This function must be implemented once for every platform. It is called
+ when the static members of the class "Fl" are created.
+ */
+Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver()
+{
+ return new Fl_X11_Screen_Driver();
+}
+
+
+void Fl_X11_Screen_Driver::init()
+{
+ CGDirectDisplayID displays[MAX_SCREENS];
+ CGDisplayCount count, i;
+ CGRect r;
+ CGGetActiveDisplayList(MAX_SCREENS, displays, &count);
+ for( i = 0; i < count; i++) {
+ r = CGDisplayBounds(displays[i]);
+ screens[i].x = int(r.origin.x);
+ screens[i].y = int(r.origin.y);
+ screens[i].width = int(r.size.width);
+ screens[i].height = int(r.size.height);
+ //fprintf(stderr,"screen %d %dx%dx%dx%d\n",i,screens[i].x,screens[i].y,screens[i].width,screens[i].height);
+ if (&CGDisplayScreenSize != NULL) {
+ CGSize s = CGDisplayScreenSize(displays[i]); // from 10.3
+ dpi_h[i] = screens[i].width / (s.width/25.4);
+ dpi_v[i] = screens[i].height / (s.height/25.4);
+ } else {
+ dpi_h[i] = dpi_v[i] = 75.;
+ }
+ }
+ num_screens = count;
+}
+
+
+void Fl_X11_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, int n)
+{
+ if (num_screens < 0) init();
+ if (n < 0 || n >= num_screens) n = 0;
+ Fl_X::screen_work_area(X, Y, W, H, n);
+}
+
+
+void Fl_X11_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n)
+{
+ if (num_screens < 0) init();
+
+ if ((n < 0) || (n >= num_screens))
+ n = 0;
+
+ X = screens[n].x;
+ Y = screens[n].y;
+ W = screens[n].width;
+ H = screens[n].height;
+}
+
+
+void Fl_X11_Screen_Driver::screen_dpi(float &h, float &v, int n)
+{
+ if (num_screens < 0) init();
+ h = v = 0.0f;
+
+ if (n >= 0 && n < num_screens) {
+ h = dpi_h[n];
+ v = dpi_v[n];
+ }
+}
+
+
+
+//
+// End of "$Id$".
+//
diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.h b/src/drivers/X11/Fl_X11_Screen_Driver.h
new file mode 100644
index 000000000..8c7bc8da2
--- /dev/null
+++ b/src/drivers/X11/Fl_X11_Screen_Driver.h
@@ -0,0 +1,48 @@
+//
+// "$Id: quartz.H 11017 2016-01-20 21:40:12Z matt $"
+//
+// Definition of X11 Screen interface
+// for the Fast Light Tool Kit (FLTK).
+//
+// Copyright 2010-2016 by Bill Spitzak and others.
+//
+// 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
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+
+/**
+ \file Fl_X11_Screen_Driver.h
+ \brief Definition of X11 Screen interface
+ */
+
+#ifndef FL_X11_SCREEN_DRIVER_H
+#define FL_X11_SCREEN_DRIVER_H
+
+#include <FL/Fl_Screen_Driver.H>
+
+
+class FL_EXPORT Fl_X11_Screen_Driver : public Fl_Screen_Driver {
+public:
+ virtual void init();
+ virtual int x();
+ virtual int y();
+ virtual int w();
+ virtual int h();
+ virtual void screen_xywh(int &X, int &Y, int &W, int &H, int n);
+ virtual void screen_dpi(float &h, float &v, int n=0);
+ virtual void screen_work_area(int &X, int &Y, int &W, int &H, int n);
+};
+
+
+#endif // FL_X11_SCREEN_DRIVER_H
+
+//
+// End of "$Id: quartz.H 11017 2016-01-20 21:40:12Z matt $".
+//