diff options
| author | Manolo Gouy <Manolo> | 2017-04-25 17:05:17 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2017-04-25 17:05:17 +0000 |
| commit | 18a84d073dd67f81685611739c588441e3b881ea (patch) | |
| tree | c1f2112addba6298d13e6b8e6d2b5db1466164d1 | |
| parent | 2ddc89fb6167b9c28795a20318576a98783e6c46 (diff) | |
Remove Fl_Translated_GDI_Graphics_Driver and have its functions performed by Fl_GDI_Graphics_Driver.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12227 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx | 8 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 21 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 20 | ||||
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx | 6 |
4 files changed, 28 insertions, 27 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx index 2d0ab4760..1e7584fa8 100644 --- a/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Copy_Surface_Driver.cxx @@ -3,7 +3,7 @@ // // Copy-to-clipboard code for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 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 @@ -48,7 +48,7 @@ Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int 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); + driver(new Fl_GDI_Graphics_Driver); oldgc = (HDC)Fl_Surface_Device::surface()->driver()->gc(); // exact computation of factor from screen units to EnhMetaFile units (0.01 mm) HDC hdc = GetDC(NULL); @@ -96,12 +96,12 @@ void Fl_GDI_Copy_Surface_Driver::set_current() { void Fl_GDI_Copy_Surface_Driver::translate(int x, int y) { - ((Fl_Translated_GDI_Graphics_Driver*)driver())->translate_all(x, y); + ((Fl_GDI_Graphics_Driver*)driver())->translate_all(x, y); } void Fl_GDI_Copy_Surface_Driver::untranslate() { - ((Fl_Translated_GDI_Graphics_Driver*)driver())->untranslate_all(); + ((Fl_GDI_Graphics_Driver*)driver())->untranslate_all(); } #endif // FL_CFG_GFX_GDI diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index 62c624bc9..73ed71735 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -4,7 +4,7 @@ // Definition of classes Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device // for the Fast Light Tool Kit (FLTK). // -// Copyright 2010-2016 by Bill Spitzak and others. +// Copyright 2010-2017 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 @@ -37,6 +37,8 @@ class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver { private: BOOL alpha_blend_(int x, int y, int w, int h, HDC src_gc, int srcx, int srcy, int srcw, int srch); + int depth; // to support translation + POINT *origins; // to support translation protected: HDC gc_; int numcount; @@ -47,8 +49,8 @@ protected: int p_size; POINT *p; public: - Fl_GDI_Graphics_Driver() {mask_bitmap_ = NULL; gc_ = NULL; p_size = 0; p = NULL;} - virtual ~Fl_GDI_Graphics_Driver() { if (p) free(p); } + Fl_GDI_Graphics_Driver() {mask_bitmap_ = NULL; gc_ = NULL; p_size = 0; p = NULL; depth = -1; origins = NULL;} + virtual ~Fl_GDI_Graphics_Driver() { if (p) free(p); delete[] origins;} virtual int has_feature(driver_feature mask) { return mask & NATIVE; } char can_do_alpha_blending(); virtual void gc(void *ctxt) { gc_ = (HDC)ctxt; global_gc(); } @@ -84,6 +86,8 @@ public: void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h); Fl_Region XRectangleRegion(int x, int y, int w, int h); void XDestroyRegion(Fl_Region r); + void translate_all(int x, int y); + void untranslate_all(void); protected: void transformed_vertex0(int x, int y); void fixloop(); @@ -143,7 +147,6 @@ protected: virtual const char *font_name(int num); virtual void font_name(int num, const char *name); virtual unsigned font_desc_size(); -protected: void global_gc(); }; @@ -162,16 +165,6 @@ public: }; -class Fl_Translated_GDI_Graphics_Driver : public Fl_GDI_Graphics_Driver { - unsigned depth; - POINT origins[10]; -public: - Fl_Translated_GDI_Graphics_Driver() {depth = 0;} - virtual void translate_all(int x, int y); - virtual void untranslate_all(void); -}; - - #endif // FL_GDI_GRAPHICS_DRIVER_H // diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index 1ba2a198a..6649e3f3d 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -3,7 +3,7 @@ // // Rectangle drawing routines for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 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 @@ -134,19 +134,27 @@ void Fl_GDI_Graphics_Driver::copy_offscreen_with_alpha(int x,int y,int w,int h,H RestoreDC(new_gc, save); DeleteDC(new_gc); } -#endif -void Fl_Translated_GDI_Graphics_Driver::translate_all(int x, int y) { +void Fl_GDI_Graphics_Driver::translate_all(int x, int y) { + const int stack_height = 10; + if (depth == -1) { + origins = new POINT[stack_height]; + depth = 0; + } + if (depth >= stack_height) { + Fl::warning("Fl_Copy/Image_Surface: translate stack overflow!"); + depth = stack_height - 1; + } GetWindowOrgEx((HDC)gc(), origins+depth); SetWindowOrgEx((HDC)gc(), origins[depth].x - x, origins[depth].y - y, NULL); - if (depth < sizeof(origins)/sizeof(POINT)) depth++; - else Fl::warning("Fl_Copy_Surface: translate stack overflow!"); + depth++; } -void Fl_Translated_GDI_Graphics_Driver::untranslate_all() { +void Fl_GDI_Graphics_Driver::untranslate_all() { if (depth > 0) depth--; SetWindowOrgEx((HDC)gc(), origins[depth].x, origins[depth].y, NULL); } +#endif void Fl_GDI_Graphics_Driver::add_rectangle_to_region(Fl_Region r, int X, int Y, int W, int H) { Fl_Region R = XRectangleRegion(X, Y, W, H); diff --git a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx index c94d9e37e..5e0b636f5 100644 --- a/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Image_Surface_Driver.cxx @@ -52,7 +52,7 @@ Fl_Image_Surface_Driver *Fl_Image_Surface_Driver::newImageSurfaceDriver(int w, i 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, 0) { previous = 0; offscreen = off ? off : CreateCompatibleBitmap( (fl_graphics_driver->gc() ? (HDC)fl_graphics_driver->gc() : fl_GetDC(0) ) , w, h); - driver(new Fl_Translated_GDI_Graphics_Driver); + driver(new Fl_GDI_Graphics_Driver); _sgc = NULL; } @@ -77,12 +77,12 @@ void Fl_GDI_Image_Surface_Driver::set_current() { void Fl_GDI_Image_Surface_Driver::translate(int x, int y) { - ((Fl_Translated_GDI_Graphics_Driver*)driver())->translate_all(x, y); + ((Fl_GDI_Graphics_Driver*)driver())->translate_all(x, y); } void Fl_GDI_Image_Surface_Driver::untranslate() { - ((Fl_Translated_GDI_Graphics_Driver*)driver())->untranslate_all(); + ((Fl_GDI_Graphics_Driver*)driver())->untranslate_all(); } |
