2016-02-10 22:49:35 +03:00
|
|
|
//
|
|
|
|
// All screen related calls in a driver style class.
|
|
|
|
//
|
2021-06-16 15:24:05 +03:00
|
|
|
// Copyright 1998-2021 by Bill Spitzak and others.
|
2016-02-10 22:49:35 +03:00
|
|
|
//
|
|
|
|
// 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:
|
|
|
|
//
|
2020-01-31 17:48:21 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
2016-02-10 22:49:35 +03:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2016-02-10 22:49:35 +03:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
2016-02-10 22:49:35 +03:00
|
|
|
//
|
|
|
|
|
2018-06-23 19:47:40 +03:00
|
|
|
/**
|
2018-06-23 23:50:22 +03:00
|
|
|
\cond DriverDev
|
|
|
|
\addtogroup DriverDeveloper
|
|
|
|
\{
|
2018-06-23 19:47:40 +03:00
|
|
|
*/
|
|
|
|
|
2016-02-10 22:49:35 +03:00
|
|
|
#ifndef FL_SCREEN_DRIVER_H
|
|
|
|
#define FL_SCREEN_DRIVER_H
|
|
|
|
|
2016-04-01 13:28:03 +03:00
|
|
|
#include <FL/fl_types.h>
|
|
|
|
#include <FL/Fl.H> // for Fl_Timeout_Handler
|
2016-04-01 17:49:29 +03:00
|
|
|
#include <FL/Fl_Text_Editor.H>
|
2016-04-01 13:28:03 +03:00
|
|
|
|
2016-02-10 22:49:35 +03:00
|
|
|
|
2016-02-11 01:43:45 +03:00
|
|
|
// TODO: add text composition?
|
|
|
|
// TODO: add Fl::display
|
|
|
|
// TODO: add copy/paste, drag/drop?
|
|
|
|
// TODO: get key/get mouse?
|
|
|
|
// TODO: system colors/colormaps
|
|
|
|
// TODO: system menu?
|
|
|
|
// TODO: native filechooser
|
|
|
|
// TODO: native message boxes
|
|
|
|
// TODO: read screen to image
|
|
|
|
// TODO: application shortcuts
|
|
|
|
|
2016-02-13 19:12:57 +03:00
|
|
|
class Fl_Window;
|
2016-04-03 09:51:09 +03:00
|
|
|
class Fl_RGB_Image;
|
|
|
|
class Fl_Group;
|
2016-04-06 22:39:15 +03:00
|
|
|
class Fl_Input;
|
2016-02-13 19:12:57 +03:00
|
|
|
|
2018-06-23 19:47:40 +03:00
|
|
|
/**
|
2021-06-16 15:24:05 +03:00
|
|
|
A base class describing the interface between FLTK and screen-related operations.
|
2018-06-23 23:50:22 +03:00
|
|
|
|
2021-06-16 15:24:05 +03:00
|
|
|
This class is only for internal use by the FLTK library.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2021-06-16 15:24:05 +03:00
|
|
|
Each supported platform implements several of the virtual methods of this class.
|
|
|
|
*/
|
2016-02-26 14:13:43 +03:00
|
|
|
class FL_EXPORT Fl_Screen_Driver {
|
2016-02-10 22:49:35 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Fl_Screen_Driver();
|
2016-02-26 16:41:48 +03:00
|
|
|
virtual ~Fl_Screen_Driver();
|
2016-02-10 22:49:35 +03:00
|
|
|
|
|
|
|
static const int MAX_SCREENS = 16;
|
|
|
|
|
2016-02-10 23:26:51 +03:00
|
|
|
int num_screens;
|
2021-06-16 15:24:05 +03:00
|
|
|
static float fl_intersection(int x1, int y1, int w1, int h1,
|
|
|
|
int x2, int y2, int w2, int h2);
|
2016-02-10 22:49:35 +03:00
|
|
|
|
2016-02-13 16:17:29 +03:00
|
|
|
public:
|
2020-01-31 17:48:21 +03:00
|
|
|
static int keyboard_screen_scaling; // true means ctrl/+/-/0/ resize windows
|
2016-02-13 16:17:29 +03:00
|
|
|
static char bg_set;
|
|
|
|
static char bg2_set;
|
|
|
|
static char fg_set;
|
|
|
|
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual float scale(int) { return 1; }
|
|
|
|
virtual void scale(int /*n*/, float /*f*/) {}
|
2016-02-10 22:49:35 +03:00
|
|
|
static Fl_Screen_Driver *newScreenDriver();
|
2016-02-13 15:57:00 +03:00
|
|
|
// --- display management
|
|
|
|
virtual void display(const char *disp);
|
2016-02-13 19:12:57 +03:00
|
|
|
virtual int visual(int flags);
|
2016-02-11 01:43:45 +03:00
|
|
|
// --- screen configuration
|
2018-03-02 23:03:04 +03:00
|
|
|
virtual void init() {}
|
2021-06-18 19:46:17 +03:00
|
|
|
virtual int x() { return 0; }
|
|
|
|
virtual int y() { return 0; }
|
|
|
|
virtual int w() { return 800; } // default, override in driver!
|
|
|
|
virtual int h() { return 600; } // default, override in driver!
|
2016-02-10 22:49:35 +03:00
|
|
|
virtual int screen_count();
|
2017-06-17 09:53:44 +03:00
|
|
|
void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual void screen_xywh(int &X, int &Y, int &W, int &H, int /*n*/) {
|
2021-06-16 15:24:05 +03:00
|
|
|
X = 0;
|
|
|
|
Y = 0;
|
|
|
|
W = 800;
|
|
|
|
H = 600;
|
|
|
|
}
|
2017-06-17 09:53:44 +03:00
|
|
|
void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
|
2016-02-10 22:49:35 +03:00
|
|
|
virtual int screen_num(int x, int y);
|
|
|
|
virtual int screen_num(int x, int y, int w, int h);
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual void screen_dpi(float &h, float &v, int n = 0) { // override in driver!
|
|
|
|
h = 72;
|
|
|
|
v = 72;
|
2021-12-09 13:40:43 +03:00
|
|
|
(void)n;
|
2021-06-16 15:24:05 +03:00
|
|
|
}
|
2017-06-17 09:53:44 +03:00
|
|
|
void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual void screen_work_area(int &X, int &Y, int &W, int &H, int n) {
|
|
|
|
screen_xywh(X, Y, W, H, n);
|
|
|
|
}
|
2016-02-11 01:43:45 +03:00
|
|
|
// --- audible output
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual void beep(int) {}
|
2016-02-11 03:10:49 +03:00
|
|
|
// --- global events
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual void flush() {} // must override
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual double wait(double) { return 0.0; } // must override
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual int ready() { return 0; } // must override
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual void grab(Fl_Window *) {}
|
2016-02-13 15:57:00 +03:00
|
|
|
// --- global colors
|
2018-01-09 10:26:49 +03:00
|
|
|
/* the default implementation of parse_color() may be enough */
|
2021-06-18 19:46:17 +03:00
|
|
|
virtual int parse_color(const char *p, uchar &r, uchar &g, uchar &b);
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual void get_system_colors() {}
|
2018-11-28 21:01:02 +03:00
|
|
|
/* the default implementation of get_system_scheme() may be enough */
|
2016-02-13 19:12:57 +03:00
|
|
|
virtual const char *get_system_scheme();
|
2016-03-01 03:54:21 +03:00
|
|
|
// --- global timers
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual void add_timeout(double, Fl_Timeout_Handler, void *) {}
|
|
|
|
virtual void repeat_timeout(double, Fl_Timeout_Handler, void *) {}
|
|
|
|
virtual int has_timeout(Fl_Timeout_Handler, void *) { return 0; }
|
|
|
|
virtual void remove_timeout(Fl_Timeout_Handler, void *) {}
|
2016-03-31 18:57:35 +03:00
|
|
|
|
|
|
|
static int secret_input_character;
|
2016-03-31 20:25:18 +03:00
|
|
|
/* Implement to indicate whether complex text input may involve marked text.
|
2022-01-07 18:34:44 +03:00
|
|
|
When it does, has_marked_text returns non zero.
|
2021-06-16 15:24:05 +03:00
|
|
|
*/
|
|
|
|
virtual int has_marked_text() const { return 0; }
|
2016-03-31 22:55:03 +03:00
|
|
|
// implement so text-editing widgets support dead keys
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual int compose(int &del) {
|
|
|
|
del = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
2016-03-31 22:55:03 +03:00
|
|
|
// default implementation may be enough
|
|
|
|
virtual void compose_reset();
|
|
|
|
// implement to support drag-n-drop. use_selection = 1 means the GUI is welcome to display
|
|
|
|
// the selected text during the D&D operation
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual int dnd(int use_selection = 0) { (void)use_selection; return 0; }
|
2016-04-01 17:49:29 +03:00
|
|
|
// null means no platform-specific key bindings for Fl_Text_Editor
|
|
|
|
Fl_Text_Editor::Key_Binding *text_editor_extra_key_bindings;
|
2016-04-01 18:37:19 +03:00
|
|
|
// default implementation may be enough
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual int text_display_can_leak() const { return 0; }
|
2016-09-22 10:44:34 +03:00
|
|
|
|
2021-06-16 15:24:05 +03:00
|
|
|
// if no keyboard is connected on a touch or pen device, the system on-screen keyboard is
|
|
|
|
// requested
|
|
|
|
virtual void request_keyboard() {}
|
2018-03-24 20:08:25 +03:00
|
|
|
// we no longer need the on-screen keyboard; it's up to the system to hide it
|
2021-06-16 15:24:05 +03:00
|
|
|
virtual void release_keyboard() {}
|
2018-03-24 20:08:25 +03:00
|
|
|
|
2019-08-21 13:01:01 +03:00
|
|
|
/* Member function read_win_rectangle() supports public functions
|
2021-11-16 17:03:36 +03:00
|
|
|
fl_read_image() and fl_capture_window() which capture pixel data from
|
2021-06-16 15:24:05 +03:00
|
|
|
a window (or also from an offscreen buffer with fl_read_image).
|
|
|
|
|
|
|
|
If 'may_capture_subwins' is true, an implementation may or may not capture
|
|
|
|
also the content of subwindows embedded in 'win'. If subwindows were captured,
|
|
|
|
*'did_capture_subwins' is returned set to true. If read_win_rectangle()
|
|
|
|
is called with 'may_capture_subwins' set to true, 'did_capture_subwins' should
|
|
|
|
be set before the call to the address of a boolean set to false.
|
|
|
|
The implementation of this virtual function for the macOS platform has the
|
|
|
|
capability of capturing subwindows when asked for.
|
|
|
|
|
|
|
|
A platform may also use its read_win_rectangle() implementation to capture
|
|
|
|
window decorations (e.g., title bar). In that case, it is called by
|
|
|
|
Fl_XXX_Window_Driver::capture_titlebar_and_borders().
|
|
|
|
|
|
|
|
win is the window to capture from, or NULL to capture from the current offscreen
|
|
|
|
*/
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual Fl_RGB_Image *read_win_rectangle(int /*X*/, int /*Y*/, int /*w*/, int /*h*/, Fl_Window *,
|
2021-06-16 15:24:05 +03:00
|
|
|
bool may_capture_subwins = false,
|
|
|
|
bool *did_capture_subwins = NULL) {
|
2021-12-09 13:40:43 +03:00
|
|
|
(void)may_capture_subwins;
|
|
|
|
(void)did_capture_subwins;
|
2021-06-16 15:24:05 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2016-04-03 09:51:09 +03:00
|
|
|
static void write_image_inside(Fl_RGB_Image *to, Fl_RGB_Image *from, int to_x, int to_y);
|
2018-02-09 16:48:22 +03:00
|
|
|
static Fl_RGB_Image *traverse_to_gl_subwindows(Fl_Group *g, int x, int y, int w, int h,
|
2016-04-03 09:51:09 +03:00
|
|
|
Fl_RGB_Image *full_img);
|
2016-04-06 22:39:15 +03:00
|
|
|
// optional platform-specific key handling for Fl_Input widget
|
|
|
|
// the default implementation may be enough
|
|
|
|
virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
|
2016-04-15 17:18:37 +03:00
|
|
|
// implement to support Fl::get_mouse()
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual int get_mouse(int &/*x*/, int &/*y*/) { return 0; }
|
2016-04-15 18:12:22 +03:00
|
|
|
// optional methods to enable/disable input methods for complex scripts
|
|
|
|
virtual void enable_im() {}
|
|
|
|
virtual void disable_im() {}
|
2017-06-01 17:05:47 +03:00
|
|
|
// calls open_display_platform() and then does platform-independent work
|
|
|
|
void open_display();
|
2016-04-15 18:36:10 +03:00
|
|
|
// implement to open access to the display
|
2017-06-01 17:05:47 +03:00
|
|
|
virtual void open_display_platform() {}
|
2016-04-15 18:36:10 +03:00
|
|
|
// optional method to close display access
|
|
|
|
virtual void close_display() {}
|
2016-12-14 21:54:12 +03:00
|
|
|
// compute dimensions of an Fl_Offscreen
|
2021-12-09 13:40:43 +03:00
|
|
|
virtual void offscreen_size(Fl_Offscreen, int &/*width*/, int &/*height*/) {}
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2017-05-17 14:54:18 +03:00
|
|
|
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);
|
2019-03-06 13:10:37 +03:00
|
|
|
virtual void desktop_scale_factor() {}
|
|
|
|
void use_startup_scale_factor();
|
2017-05-17 14:54:18 +03:00
|
|
|
enum APP_SCALING_CAPABILITY {
|
2021-06-16 15:24:05 +03:00
|
|
|
NO_APP_SCALING = 0, ///< The platform does not support rescaling.
|
2017-05-17 14:54:18 +03:00
|
|
|
SYSTEMWIDE_APP_SCALING, ///< The platform supports rescaling with the same factor for all screens.
|
2021-06-16 15:24:05 +03:00
|
|
|
PER_SCREEN_APP_SCALING ///< The platform supports rescaling with one factor for each screen.
|
2017-05-17 14:54:18 +03:00
|
|
|
};
|
2021-06-16 15:24:05 +03:00
|
|
|
/** Returns the platform's support for rescaling the application with ctrl/+/-/0 keys.
|
2017-05-17 14:54:18 +03:00
|
|
|
*/
|
|
|
|
virtual APP_SCALING_CAPABILITY rescalable() { return NO_APP_SCALING; }
|
2019-03-25 20:47:29 +03:00
|
|
|
// supports Fl_Window::default_icons()
|
|
|
|
virtual void default_icons(const Fl_RGB_Image *icons[], int count);
|
2016-02-10 22:49:35 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // !FL_SCREEN_DRIVER_H
|
|
|
|
|
2018-06-23 19:47:40 +03:00
|
|
|
/**
|
2018-06-23 23:50:22 +03:00
|
|
|
\}
|
|
|
|
\endcond
|
2018-06-23 19:47:40 +03:00
|
|
|
*/
|