Add Fl::screen_scale(int) function to get the scaling factor value of a screen.

This allows to keep class Fl_Screen_Driver away from the public API.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12926 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2018-05-22 17:00:27 +00:00
parent 4c65d976e4
commit ce71c4b679
6 changed files with 11 additions and 4 deletions

View File

@ -1008,6 +1008,7 @@ int main() {
static void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my); // via screen driver
static void screen_work_area(int &X, int &Y, int &W, int &H, int n); // via screen driver
static void screen_work_area(int &X, int &Y, int &W, int &H); // via screen driver
static float screen_scale(int n); // via screen driver
/** @} */

View File

@ -543,7 +543,7 @@ public:
void shape(const Fl_Image* img);
void shape(const Fl_Image& b) ;
int is_shaped();
inline int screen_num();
int screen_num();
};
#endif

View File

@ -62,7 +62,7 @@ for the screen in use and obtains quantities in <b>drawing units</b>.
The current scale factor value, for an Fl_Window named \e window, is given by
\code
int nscreen = window->screen_num(); // the screen where window is mapped
float s = Fl::screen_driver()->scale(nscreen); // this screen's scale factor
float s = Fl::screen_scale(nscreen); // this screen's scale factor
\endcode
One drawing unit generally corresponds to one screen pixel...
<li>...but not on Mac OS X and for retina displays, where one drawing unit corresponds

View File

@ -2110,6 +2110,12 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
return Fl_Graphics_Driver::default_driver().get_font_sizes(fnum, sizep);
}
/** Current value of the GUI scaling factor for screen number \p n */
float Fl::screen_scale(int n) {
return Fl::screen_driver()->scale(n);
}
// Pointers you can use to change FLTK to another language.
// Note: Similar pointers are defined in FL/fl_ask.H and src/fl_ask.cxx
FL_EXPORT const char* fl_local_shift = Fl::system_driver()->shift_name();

View File

@ -632,7 +632,7 @@ void Fl_Window::size_range(int minw, int minh, int maxw, int maxh, int dw, int d
}
/** The number of the screen containing the mapped window */
inline int Fl_Window::screen_num() {
int Fl_Window::screen_num() {
return pWindowDriver->screen_num();
}

View File

@ -383,7 +383,7 @@ void Fl_Cocoa_Printer_Driver::draw_decorated_window(Fl_Window *win, int x_offset
CGContextRef gc = (CGContextRef)driver()->gc();
CGContextSaveGState(gc);
CGContextTranslateCTM(gc, x_offset - 0.5, y_offset + bt - 0.5);
float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(win)->screen_num());
float s = Fl::screen_scale(win->screen_num());
CGContextScaleCTM(gc, 1/s, -1/s);
Fl_Cocoa_Window_Driver::draw_layer_to_context(layer, gc, win->w() * s, bt);
CGContextRestoreGState(gc);