From b549cfaaea11ce5e881e2151a838c91a031ad9ba Mon Sep 17 00:00:00 2001 From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> Date: Sun, 13 Mar 2022 08:56:23 +0100 Subject: Separate platform init functions from platform-specific driver files --- src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.H | 35 +++++++++++++++++++++++ src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx | 20 +------------ src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 2 ++ src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 23 +++------------ src/drivers/GDI/Fl_GDI_Image_Surface_Driver.H | 38 +++++++++++++++++++++++++ src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx | 22 +------------- 6 files changed, 81 insertions(+), 59 deletions(-) create mode 100644 src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.H create mode 100644 src/drivers/GDI/Fl_GDI_Image_Surface_Driver.H (limited to 'src/drivers/GDI') diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.H b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.H new file mode 100644 index 000000000..6d8923c99 --- /dev/null +++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.H @@ -0,0 +1,35 @@ +// +// Copy-to-clipboard code for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022 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: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_GDI_COPY_SURFACE_DRIVER_H +#define FL_GDI_COPY_SURFACE_DRIVER_H + +#include +#include + +class Fl_GDI_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { + friend class Fl_Copy_Surface_Driver; +protected: + HDC oldgc; + HDC gc; + Fl_GDI_Copy_Surface_Driver(int w, int h); + ~Fl_GDI_Copy_Surface_Driver(); + void set_current(); + void translate(int x, int y); + void untranslate(); +}; + +#endif // FL_GDI_COPY_SURFACE_DRIVER_H diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx index c1d845e6a..29478a9c4 100644 --- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx @@ -15,31 +15,13 @@ // #include -#include +#include "Fl_GDI_Copy_Surface_Driver.H" #include #include "Fl_GDI_Graphics_Driver.H" #include "../WinAPI/Fl_WinAPI_Screen_Driver.H" #include #include -class Fl_GDI_Copy_Surface_Driver : public Fl_Copy_Surface_Driver { - friend class Fl_Copy_Surface_Driver; -protected: - HDC oldgc; - HDC gc; - Fl_GDI_Copy_Surface_Driver(int w, int h); - ~Fl_GDI_Copy_Surface_Driver(); - void set_current(); - void translate(int x, int y); - void untranslate(); -}; - - -Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h) -{ - return new Fl_GDI_Copy_Surface_Driver(w, h); -} - Fl_GDI_Copy_Surface_Driver::Fl_GDI_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) { driver(Fl_Graphics_Driver::newMainGraphicsDriver()); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index 824ad2fa7..59c111a39 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -177,10 +177,12 @@ public: #if USE_GDIPLUS class Fl_GDIplus_Graphics_Driver : public Fl_GDI_Graphics_Driver { + friend class Fl_Graphics_Driver; private: Gdiplus::Color gdiplus_color_; Gdiplus::Pen *pen_; Gdiplus::SolidBrush *brush_; + static ULONG_PTR gdiplusToken; public: Fl_GDIplus_Graphics_Driver(); virtual ~Fl_GDIplus_Graphics_Driver(); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 484830e2a..caa8d6746 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -24,7 +24,6 @@ #include "Fl_Font.H" #if USE_GDIPLUS -static ULONG_PTR gdiplusToken = 0; Fl_GDIplus_Graphics_Driver::Fl_GDIplus_Graphics_Driver() : Fl_GDI_Graphics_Driver() { if (!fl_current_xmap) color(FL_BLACK); @@ -51,27 +50,13 @@ int Fl_GDIplus_Graphics_Driver::antialias() { #endif -/* - * By linking this module, the following static method will instantiate the - * Windows GDI Graphics driver as the main display driver. - */ -Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() -{ -#if USE_GDIPLUS - // Initialize GDI+. - static Gdiplus::GdiplusStartupInput gdiplusStartupInput; - if (gdiplusToken == 0) GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); - - Fl_Graphics_Driver *driver = new Fl_GDIplus_Graphics_Driver(); - return driver; -#else - return new Fl_GDI_Graphics_Driver(); -#endif -} #if USE_GDIPLUS + +ULONG_PTR Fl_GDIplus_Graphics_Driver::gdiplusToken = 0; + void Fl_GDIplus_Graphics_Driver::shutdown() { - Gdiplus::GdiplusShutdown(gdiplusToken); + Gdiplus::GdiplusShutdown(Fl_GDIplus_Graphics_Driver::gdiplusToken); } #endif diff --git a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.H b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.H new file mode 100644 index 000000000..979b7bd3a --- /dev/null +++ b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.H @@ -0,0 +1,38 @@ +// +// Draw-to-image code for the Fast Light Tool Kit (FLTK). +// +// Copyright 2022 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: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef FL_GDI_IMAGE_SURFACE_DRIVER_H +#define FL_GDI_IMAGE_SURFACE_DRIVER_H + +#include +#include +#include + +class Fl_GDI_Image_Surface_Driver : public Fl_Image_Surface_Driver { + virtual void end_current(); +public: + Window pre_window; + int _savedc; + Fl_GDI_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); + ~Fl_GDI_Image_Surface_Driver(); + void set_current(); + void translate(int x, int y); + void untranslate(); + Fl_RGB_Image *image(); + POINT origin; +}; + +#endif // FL_GDI_IMAGE_SURFACE_DRIVER_H diff --git a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx index 09a1a7e2a..7f655e291 100644 --- a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx @@ -17,30 +17,10 @@ #include "Fl_GDI_Graphics_Driver.H" #include "../WinAPI/Fl_WinAPI_Screen_Driver.H" -#include +#include "Fl_GDI_Image_Surface_Driver.H" #include #include -class Fl_GDI_Image_Surface_Driver : public Fl_Image_Surface_Driver { - virtual void end_current(); -public: - Window pre_window; - int _savedc; - Fl_GDI_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off); - ~Fl_GDI_Image_Surface_Driver(); - void set_current(); - void translate(int x, int y); - void untranslate(); - Fl_RGB_Image *image(); - POINT origin; -}; - - -Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, int h, int high_res, Fl_Offscreen off) -{ - return new Fl_GDI_Image_Surface_Driver(w, h, high_res, off); -} - Fl_GDI_Image_Surface_Driver::Fl_GDI_Image_Surface_Driver(int w, int h, int high_res, Fl_Offscreen off) : Fl_Image_Surface_Driver(w, h, high_res, off) { float d = fl_graphics_driver->scale(); -- cgit v1.2.3