summaryrefslogtreecommitdiff
path: root/src/drivers/GDI
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2016-03-19 18:14:58 +0000
committerManolo Gouy <Manolo>2016-03-19 18:14:58 +0000
commitf936eb1a962d9578befff4d4cdeac64339644594 (patch)
tree3f91ce050b1ee050dbaaf8cc04f99c73bb43cd34 /src/drivers/GDI
parent3dcc91d1f09b78a43f6fa8e8f13fd09076da0476 (diff)
Driver-based rewrite of the Fl_Copy_Surface class.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11374 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers/GDI')
-rw-r--r--src/drivers/GDI/Fl_GDI_Copy_Surface.cxx41
1 files changed, 34 insertions, 7 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface.cxx
index aa8e93682..1f6149052 100644
--- a/src/drivers/GDI/Fl_GDI_Copy_Surface.cxx
+++ b/src/drivers/GDI/Fl_GDI_Copy_Surface.cxx
@@ -18,11 +18,34 @@
#include "../../config_lib.h"
-
#ifdef FL_CFG_GFX_GDI
-#include "Fl_GDI_Copy_Surface.H"
+#include <FL/Fl_Copy_Surface.H>
+#include "Fl_GDI_Graphics_Driver.H"
+#include <windows.h>
+
+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();
+ int w() {return width;}
+ int h() {return height;}
+ int printable_rect(int *w, int *h) {*w = width; *h = height; return 0;}
+};
+
+
+Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h)
+{
+ return new Fl_GDI_Copy_Surface_Driver(w, h);
+}
-Fl_Copy_Surface::Helper::Helper(int w, int h) : Fl_Widget_Surface(NULL), width(w), height(h) {
+
+Fl_GDI_Copy_Surface_Driver::Fl_GDI_Copy_Surface_Driver(int w, int h) : Fl_Copy_Surface_Driver(w, h) {
driver(new Fl_Translated_GDI_Graphics_Driver);
oldgc = (HDC)Fl_Surface_Device::surface()->driver()->gc();
// exact computation of factor from screen units to EnhMetaFile units (0.01 mm)
@@ -43,7 +66,8 @@ Fl_Copy_Surface::Helper::Helper(int w, int h) : Fl_Widget_Surface(NULL), width(w
}
}
-Fl_Copy_Surface::Helper::~Helper() {
+
+Fl_GDI_Copy_Surface_Driver::~Fl_GDI_Copy_Surface_Driver() {
if (oldgc == (HDC)Fl_Surface_Device::surface()->driver()->gc()) oldgc = NULL;
HENHMETAFILE hmf = CloseEnhMetaFile (gc);
if ( hmf != NULL ) {
@@ -58,17 +82,20 @@ Fl_Copy_Surface::Helper::~Helper() {
Fl_Surface_Device::surface()->driver()->gc(oldgc);
}
-void Fl_Copy_Surface::Helper::set_current() {
+
+void Fl_GDI_Copy_Surface_Driver::set_current() {
driver()->gc(gc);
fl_window = (Window)1;
Fl_Surface_Device::set_current();
}
-void Fl_Copy_Surface::Helper::translate(int x, int y) {
+
+void Fl_GDI_Copy_Surface_Driver::translate(int x, int y) {
((Fl_Translated_GDI_Graphics_Driver*)driver())->translate_all(x, y);
}
-void Fl_Copy_Surface::Helper::untranslate() {
+
+void Fl_GDI_Copy_Surface_Driver::untranslate() {
((Fl_Translated_GDI_Graphics_Driver*)driver())->untranslate_all();
}
#endif // FL_CFG_GFX_GDI