diff options
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_Bitmap.H | 7 | ||||
| -rw-r--r-- | FL/Fl_Gl_Window_Driver.H | 4 | ||||
| -rw-r--r-- | FL/Fl_Graphics_Driver.H | 171 | ||||
| -rw-r--r-- | FL/Fl_Image.H | 3 | ||||
| -rw-r--r-- | FL/Fl_Pixmap.H | 3 | ||||
| -rw-r--r-- | FL/Fl_Screen_Driver.H | 21 | ||||
| -rw-r--r-- | FL/Fl_Window_Driver.H | 4 | ||||
| -rw-r--r-- | FL/fl_draw.H | 10 |
8 files changed, 196 insertions, 27 deletions
diff --git a/FL/Fl_Bitmap.H b/FL/Fl_Bitmap.H index 4d4172e92..fe457999b 100644 --- a/FL/Fl_Bitmap.H +++ b/FL/Fl_Bitmap.H @@ -3,7 +3,7 @@ // // Bitmap header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 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 @@ -45,15 +45,16 @@ private: int &X, int &Y, int &W, int &H); /** for internal use */ fl_uintptr_t id_; + float cache_scale_; // graphics scaling value when id_ was computed public: /** The constructors create a new bitmap from the specified bitmap data */ Fl_Bitmap(const uchar *bits, int W, int H) : - Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0) {data((const char **)&array, 1);} + Fl_Image(W,H,0), array(bits), alloc_array(0), id_(0), cache_scale_(1) {data((const char **)&array, 1);} /** The constructors create a new bitmap from the specified bitmap data */ Fl_Bitmap(const char *bits, int W, int H) : - Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0) {data((const char **)&array, 1);} + Fl_Image(W,H,0), array((const uchar *)bits), alloc_array(0), id_(0), cache_scale_(1) {data((const char **)&array, 1);} virtual ~Fl_Bitmap(); virtual Fl_Image *copy(int W, int H); Fl_Image *copy() { return copy(w(), h()); } diff --git a/FL/Fl_Gl_Window_Driver.H b/FL/Fl_Gl_Window_Driver.H index db8702185..ec00d96c0 100644 --- a/FL/Fl_Gl_Window_Driver.H +++ b/FL/Fl_Gl_Window_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 2016 by Bill Spitzak and others. +// Copyright 2016-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 @@ -127,6 +127,7 @@ class Fl_Cocoa_Gl_Window_Driver : public Fl_Gl_Window_Driver { class Fl_WinAPI_Gl_Window_Driver : public Fl_Gl_Window_Driver { friend class Fl_Gl_Window_Driver; Fl_WinAPI_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {} + virtual float pixels_per_unit(); virtual int mode_(int m, const int *a); virtual void make_current_after(); virtual void swap_buffers(); @@ -156,6 +157,7 @@ class Fl_WinAPI_Gl_Window_Driver : public Fl_Gl_Window_Driver { class Fl_X11_Gl_Window_Driver : public Fl_Gl_Window_Driver { friend class Fl_Gl_Window_Driver; Fl_X11_Gl_Window_Driver(Fl_Gl_Window *win) : Fl_Gl_Window_Driver(win) {} + virtual float pixels_per_unit(); virtual void before_show(int& need_redraw); virtual int mode_(int m, const int *a); virtual void swap_buffers(); diff --git a/FL/Fl_Graphics_Driver.H b/FL/Fl_Graphics_Driver.H index bdcf1e9d5..8af285e8e 100644 --- a/FL/Fl_Graphics_Driver.H +++ b/FL/Fl_Graphics_Driver.H @@ -18,7 +18,7 @@ // /** \file Fl_Graphics_Driver.H - \brief declaration of classe Fl_Graphics_Driver. + \brief declaration of class Fl_Graphics_Driver. */ #ifndef FL_GRAPHICS_DRIVER_H @@ -33,12 +33,7 @@ class Fl_Graphics_Driver; class Fl_Shared_Image; -/** a platform-specific class implementing a system font */ -class Fl_Font_Descriptor -#ifdef FL_DOXYGEN -{} -#endif -; +class Fl_Font_Descriptor; /** \brief Points to the driver that currently receives all graphics requests */ FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver; @@ -57,19 +52,28 @@ struct Fl_Fontdesc; #define FL_REGION_STACK_SIZE 10 #define FL_MATRIX_STACK_SIZE 32 /** - \brief A virtual class subclassed for each graphics driver FLTK uses. + An abstract class subclassed for each graphics driver FLTK uses. Typically, FLTK applications do not use directly objects from this class. Rather, they perform drawing operations (e.g., fl_rectf()) that operate on the current drawing surface (see Fl_Surface_Device). Drawing operations are functionally presented in \ref drawing and as function lists - in the \ref fl_drawings and \ref fl_attributes modules. The \ref fl_graphics_driver global variable - gives at any time the graphics driver used by all drawing operations. Its value changes when - drawing operations are directed to another drawing surface by Fl_Surface_Device::set_current(). + in the \ref fl_drawings and \ref fl_attributes modules. + + \p <tt>Fl_Surface_Device::surface()->driver()</tt> + gives at any time the graphics driver used by all drawing operations. + For compatibility with older FLTK versions, the \ref fl_graphics_driver global variable gives the same result. + Its value changes when + drawing operations are directed to another drawing surface by Fl_Surface_Device::push_current() / + Fl_Surface_Device::pop_current() / Fl_Surface_Device::set_current(). \p The Fl_Graphics_Driver class is of interest if one wants to perform new kinds of drawing operations. An example would be to draw to a PDF file. This would involve creating a new Fl_Graphics_Driver derived class. This new class should implement all virtual methods of the Fl_Graphics_Driver class to support all FLTK drawing functions. - */ + + \p The Fl_Graphics_Driver class is essential for developers of the FLTK library. + Each platform supported by FLTK requires to create a derived class of Fl_Graphics_Driver that + implements all its virtual member functions according to the platform. + */ class FL_EXPORT Fl_Graphics_Driver { friend class Fl_Surface_Device; friend class Fl_Display_Device; @@ -167,22 +171,42 @@ protected: virtual Fl_Bitmask create_bitmask(int w, int h, const uchar *array) {return 0; } /** Support function for image drawing */ virtual void delete_bitmask(Fl_Bitmask bm) {} + /** For internal library use only */ + static void change_image_size(Fl_Image *img, int W, int H) { + img->w(W); + img->h(H); + } // Support function for image drawing virtual void uncache_pixmap(fl_uintptr_t p); // accessor functions to protected image members int start_image(Fl_Image *img, int XP, int YP, int WP, int HP, int &cx, int &cy, int &X, int &Y, int &W, int &H); + /** Accessor to a private member variable of Fl_RGB_Image */ static fl_uintptr_t* id(Fl_RGB_Image *rgb) {return &(rgb->id_);} + /** Accessor to a private member variable of Fl_Pixmap */ static fl_uintptr_t* id(Fl_Pixmap *pm) {return &(pm->id_);} + /** Accessor to a private member variable of Fl_Bitmap */ static fl_uintptr_t* id(Fl_Bitmap *bm) {return &(bm->id_);} + /** Accessor to a private member variable of Fl_RGB_Image */ static fl_uintptr_t* mask(Fl_RGB_Image *rgb) {return &(rgb->mask_);} + /** Accessor to a private member variable of Fl_Pixmap */ static fl_uintptr_t* mask(Fl_Pixmap *pm) {return &(pm->mask_);} + /** Accessor to a private member variable of Fl_Pixmap */ + static float* cache_scale(Fl_Pixmap *pm) {return &(pm->cache_scale_);} + /** Accessor to a private member variable of Fl_Bitmap */ + static float* cache_scale(Fl_Bitmap *bm) {return &(bm->cache_scale_);} + /** Accessor to a private member variable of Fl_RGB_Image */ + static float* cache_scale(Fl_RGB_Image *rgb) {return &(rgb->cache_scale_);} + /** Accessor to a private member variable of Fl_Pixmap */ static Fl_Color* pixmap_bg_color(Fl_Pixmap *pm) {return &(pm->pixmap_bg_color);} + /** For internal library use only */ static void draw_empty(Fl_Image* img, int X, int Y) {img->draw_empty(X, Y);} + /** Accessor to a private member function of Fl_Bitmap */ static int prepare(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int &cx, int &cy, int &X, int &Y, int &W, int &H) { return bm->prepare(XP,YP,WP,HP,cx,cy,X,Y,W,H); } + /** Accessor to a private member function of Fl_Pixmap */ static int prepare(Fl_Pixmap *pm, int XP, int YP, int WP, int HP, int &cx, int &cy, int &X, int &Y, int &W, int &H) { return pm->prepare(XP,YP,WP,HP,cx,cy,X,Y,W,H); @@ -245,8 +269,6 @@ public: virtual void pop_matrix(); virtual void mult_matrix(double a, double b, double c, double d, double x, double y); virtual void rotate(double d); - virtual void scale(double x, double y); - virtual void scale(double x); virtual void translate(double x,double y); virtual void begin_points(); virtual void begin_line(); @@ -346,17 +368,134 @@ public: virtual void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h); virtual Fl_Region XRectangleRegion(int x, int y, int w, int h); virtual void XDestroyRegion(Fl_Region r); - // font support + /** Returns the current value of the scaling factor (usually > 1 on HiDPI displays) */ + virtual float scale() {return 1;} + /** Sets the current value of the scaling factor */ + virtual void scale(float f) {} + /** Support for Fl::get_font_name() */ virtual const char* get_font_name(Fl_Font fnum, int* ap) {return NULL;} + /** Support for Fl::get_font_sizes() */ virtual int get_font_sizes(Fl_Font fnum, int*& sizep) {return 0;} + /** Support for Fl::set_fonts() */ virtual Fl_Font set_fonts(const char *name) {return 0;} - // an implementation which returns NULL may be enough + /** Some platforms may need to implement this to support fonts */ virtual Fl_Fontdesc* calc_fl_fonts(void) {return NULL;} + /** Support for Fl::set_font() */ virtual unsigned font_desc_size() {return 0;} + /** Support for Fl::get_font() */ virtual const char *font_name(int num) {return NULL;} + /** Support for Fl::set_font() */ virtual void font_name(int num, const char *name) {} }; +#ifndef FL_DOXYGEN +/* Abstract class Fl_Scalable_Graphics_Driver is platform-independent. + It supports the scaling of all graphics coordinates by a + float factor helpful to support HiDPI displays. + This class does : + - compute scaled coordinates + - scale the cached offscreen of image objects + - scale the pixel arrays used when performing direct image draws + - call the member functions of a platform-specific, + Fl_Scalable_Graphics_Driver-derived class that do the drawings with adequately + scaled coordinates. The member functions are named with the _unscaled suffix. + - scale and unscale the clipping region. + + This class is presently used on the X11 platform to support HiDPI displays. + In the future, it may also be used on the WIN32 platform. + */ +class Fl_Scalable_Graphics_Driver : public Fl_Graphics_Driver { +public: + Fl_Scalable_Graphics_Driver(); + float scale() { return scale_; } +protected: + float scale_; // scale between user and graphical coordinates: graphical = user * scale_ + void cache_size(Fl_Image *img, int &width, int &height); + virtual Fl_Region scale_clip(float f)=0; + void unscale_clip(Fl_Region r); + virtual void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_unscaled(Fl_Pixmap *pxm, float s, int XP, int YP, int WP, int HP, int cx, int cy)=0; + virtual void draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_unscaled(Fl_Bitmap *bm, float s, int XP, int YP, int WP, int HP, int cx, int cy)=0; + virtual void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy); + virtual void draw_unscaled(Fl_RGB_Image *img, float s, int XP, int YP, int WP, int HP, int cx, int cy)=0; + void draw(Fl_Shared_Image *shared, int X, int Y); + virtual void point(int x, int y); + virtual void point_unscaled(float x, float y) = 0; + virtual void rect(int x, int y, int w, int h); + virtual void rect_unscaled(float x, float y, float w, float h) = 0; + virtual void rectf(int x, int y, int w, int h); + virtual void rectf_unscaled(float x, float y, float w, float h) = 0; + virtual void line(int x, int y, int x1, int y1); + virtual void line_unscaled(float x, float y, float x1, float y1) = 0; + virtual void line(int x, int y, int x1, int y1, int x2, int y2); + virtual void line_unscaled(float x, float y, float x1, float y1, float x2, float y2) = 0; + virtual void xyline(int x, int y, int x1); + virtual void xyline(int x, int y, int x1, int y2); + virtual void xyline(int x, int y, int x1, int y2, int x3); + virtual void xyline_unscaled(float x, float y, float x1)=0; + virtual void xyline_unscaled(float x, float y, float x1, float y2)=0; + virtual void xyline_unscaled(float x, float y, float x1, float y2, float x3)=0; + virtual void yxline(int x, int y, int y1); + virtual void yxline(int x, int y, int y1, int x2); + virtual void yxline(int x, int y, int y1, int x2, int y3); + virtual void yxline_unscaled(float x, float y, float y1)=0; + virtual void yxline_unscaled(float x, float y, float y1, float x2)=0; + virtual void yxline_unscaled(float x, float y, float y1, float x2, float y3)=0; + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2); + virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2)=0; + virtual void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + virtual void loop_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)=0; + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2); + virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2)=0; + virtual void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3); + virtual void polygon_unscaled(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)=0; + virtual void circle(double x, double y, double r); + virtual void ellipse_unscaled(double xt, double yt, double rx, double ry)=0; + virtual void font(Fl_Font face, Fl_Fontsize size); + virtual void font_unscaled(Fl_Font face, Fl_Fontsize size)=0; + virtual double width(const char *str, int n); + virtual double width(unsigned int c); + virtual double width_unscaled(const char *str, int n)=0; + virtual double width_unscaled(unsigned int c)=0; + virtual Fl_Fontsize size(); + virtual Fl_Fontsize size_unscaled()=0; + virtual void text_extents(const char *str, int n, int &dx, int &dy, int &w, int &h); + virtual void text_extents_unscaled(const char *str, int n, int &dx, int &dy, int &w, int &h)=0; + virtual int height(); + virtual int descent(); + virtual int height_unscaled()=0; + virtual int descent_unscaled()=0; + virtual void draw(const char *str, int n, int x, int y); + virtual void draw_unscaled(const char *str, int n, int x, int y)=0; + virtual void draw(int angle, const char *str, int n, int x, int y); + virtual void draw_unscaled(int angle, const char *str, int n, int x, int y)=0; + virtual void rtl_draw(const char* str, int n, int x, int y); + virtual void rtl_draw_unscaled(const char* str, int n, int x, int y)=0; + virtual void arc(int x, int y, int w, int h, double a1, double a2); + virtual void arc_unscaled(float x, float y, float w, float h, double a1, double a2)=0; + virtual void pie(int x, int y, int w, int h, double a1, double a2); + virtual void pie_unscaled(float x, float y, float w, float h, double a1, double a2)=0; + virtual void line_style(int style, int width=0, char* dashes=0); + virtual void line_style_unscaled(int style, float width, char* dashes)=0; + virtual void copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); + virtual void copy_offscreen_unscaled(float x, float y, float w, float h, Fl_Offscreen pixmap, float srcx, float srcy)=0; + void draw_image_rescale(void *buf, Fl_Draw_Image_Cb cb, int X, int Y, int W, int H, int D, int L, bool mono, float s); + virtual void draw_image_unscaled(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0)=0; + virtual void draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3)=0; + void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0); + void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3); + virtual void draw_image_mono_unscaled(const uchar* buf, int x, int y, int w, int h, int d, int l)=0; + void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0); + virtual void draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1)=0; + void draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=1); + + void transformed_vertex(double xf, double yf); + virtual void transformed_vertex0(float x, float y)=0; + void vertex(double x, double y); +}; +#endif // FL_DOXYGEN + #endif // FL_GRAPHICS_DRIVER_H // diff --git a/FL/Fl_Image.H b/FL/Fl_Image.H index 4e0663bfd..83e76cbd0 100644 --- a/FL/Fl_Image.H +++ b/FL/Fl_Image.H @@ -3,7 +3,7 @@ // // Image header file 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 @@ -223,6 +223,7 @@ private: // These two variables are used to cache the image and mask for the main display graphics driver fl_uintptr_t id_; fl_uintptr_t mask_; + float cache_scale_; // graphics scaling value when id_ was computed public: diff --git a/FL/Fl_Pixmap.H b/FL/Fl_Pixmap.H index acfa7e62b..df6eddb4c 100644 --- a/FL/Fl_Pixmap.H +++ b/FL/Fl_Pixmap.H @@ -3,7 +3,7 @@ // // Pixmap header file for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2012 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 @@ -56,6 +56,7 @@ private: fl_uintptr_t id_; fl_uintptr_t mask_; Fl_Color pixmap_bg_color; + float cache_scale_; // graphics scaling value when id_ was computed public: diff --git a/FL/Fl_Screen_Driver.H b/FL/Fl_Screen_Driver.H index 762358412..84f25d9fa 100644 --- a/FL/Fl_Screen_Driver.H +++ b/FL/Fl_Screen_Driver.H @@ -3,7 +3,7 @@ // // All screen related calls in a driver style class. // -// 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 @@ -54,6 +54,8 @@ protected: static const int MAX_SCREENS = 16; int num_screens; + static float fl_intersection(int x1, int y1, int w1, int h1, + int x2, int y2, int w2, int h2); public: static char bg_set; @@ -61,6 +63,8 @@ public: static char fg_set; public: + virtual float scale(int n) {return 1;} + virtual void scale(int n, float f) { } static Fl_Screen_Driver *newScreenDriver(); // --- display management virtual void display(const char *disp); @@ -157,6 +161,21 @@ public: virtual void close_display() {} // compute dimensions of an Fl_Offscreen virtual void offscreen_size(Fl_Offscreen off, int &width, int &height) {} + + void rescale_all_windows_from_screen(int screen, float f); + static void transient_scale_display(float f, int nscreen); + static int scale_handler(int event); + virtual void init_workarea() {} + virtual float desktop_scale_factor() {return 1;} + float default_scale_factor(); + enum APP_SCALING_CAPABILITY { + NO_APP_SCALING = 0, ///< The platform does not support rescaling. + SYSTEMWIDE_APP_SCALING, ///< The platform supports rescaling with the same factor for all screens. + PER_SCREEN_APP_SCALING ///< The platform supports rescaling with one factor for each screen. + }; + /** Returns the platform's support for rescaling the application with ctrl-/+/-/0/ keys. + */ + virtual APP_SCALING_CAPABILITY rescalable() { return NO_APP_SCALING; } }; diff --git a/FL/Fl_Window_Driver.H b/FL/Fl_Window_Driver.H index 8d1775e84..4157edb6d 100644 --- a/FL/Fl_Window_Driver.H +++ b/FL/Fl_Window_Driver.H @@ -4,7 +4,7 @@ // A base class for platform specific window handling code // 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 @@ -56,6 +56,8 @@ public: static Fl_Window_Driver *newWindowDriver(Fl_Window *); int wait_for_expose_value; Fl_Offscreen other_xid; // offscreen bitmap (overlay and double-buffered windows) + virtual int screen_num(); + virtual void screen_num(int) {} // --- frequently used accessors to public window data /** returns the x coordinate of the window. */ diff --git a/FL/fl_draw.H b/FL/fl_draw.H index 65090fd22..d312ff191 100644 --- a/FL/fl_draw.H +++ b/FL/fl_draw.H @@ -3,7 +3,7 @@ // // Portable drawing function header file 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 @@ -335,12 +335,16 @@ inline void fl_pop_matrix() { fl_graphics_driver->pop_matrix(); } Concatenates scaling transformation onto the current one. \param[in] x,y scale factors in x-direction and y-direction */ -inline void fl_scale(double x, double y) { fl_graphics_driver->scale(x, y); } +inline void fl_scale(double x, double y) { + fl_graphics_driver->mult_matrix(x,0,0,y,0,0); +} /** Concatenates scaling transformation onto the current one. \param[in] x scale factor in both x-direction and y-direction */ -inline void fl_scale(double x) { fl_graphics_driver->scale(x, x); } +inline void fl_scale(double x) { + fl_graphics_driver->mult_matrix(x,0,0,x,0,0); +} /** Concatenates translation transformation onto the current one. \param[in] x,y translation factor in x-direction and y-direction |
