FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Screen_Driver.H
1//
2// All screen related calls in a driver style class.
3//
4// Copyright 1998-2024 by Bill Spitzak and others.
5//
6// This library is free software. Distribution and use rights are outlined in
7// the file "COPYING" which should have been included with this file. If this
8// file is missing or damaged, see the license at:
9//
10// https://www.fltk.org/COPYING.php
11//
12// Please see the following page on how to report bugs and issues:
13//
14// https://www.fltk.org/bugs.php
15//
16
22
23#ifndef FL_SCREEN_DRIVER_H
24#define FL_SCREEN_DRIVER_H
25
26#include <FL/fl_types.h>
27#include <FL/Fl.H> // for Fl_Timeout_Handler
28#include <FL/Fl_Text_Editor.H>
29
30
31// TODO: add text composition?
32// TODO: add Fl::display
33// TODO: add copy/paste, drag/drop?
34// TODO: get key/get mouse?
35// TODO: system colors/colormaps
36// TODO: system menu?
37// TODO: native filechooser
38// TODO: native message boxes
39// TODO: read screen to image
40// TODO: application shortcuts
41
42 class Fl_Window;
43 class Fl_RGB_Image;
44 class Fl_Group;
45 class Fl_Input;
46 class Fl_System_Driver;
47
55 class Fl_Screen_Driver {
56
57 protected:
58 Fl_Screen_Driver();
59 virtual ~Fl_Screen_Driver();
60
61 static const int MAX_SCREENS = 16;
62
63 int num_screens;
64 static float fl_intersection(int x1, int y1, int w1, int h1,
65 int x2, int y2, int w2, int h2);
66
67 public:
68 static int keyboard_screen_scaling; // true means ctrl/+/-/0/ resize windows
69 static char bg_set;
70 static char bg2_set;
71 static char fg_set;
72 static Fl_System_Driver *system_driver;
73 // These flags are useful after calling XParseGeometry(). They indicate which of its
74 // arguments contain meaningful data upon return.
75 static const int fl_NoValue;
76 static const int fl_WidthValue;
77 static const int fl_HeightValue;
78 static const int fl_XValue;
79 static const int fl_YValue;
80 static const int fl_XNegative;
81 static const int fl_YNegative;
82 // Next 2 are used when transient scale windows are implemented as popups
83 static Fl_Window *transient_scale_parent;
84 static void del_transient_window(void *);
85 // key_table and key_table_size are used in fl_shortcut to translate key names
86 struct Keyname {
87 unsigned int key;
88 const char* name;
89 } *key_table;
90 int key_table_size;
91
92 virtual float scale(int) { return 1; }
93 virtual void scale(int /*n*/, float /*f*/) {}
94 static Fl_Screen_Driver *newScreenDriver();
95 // implement to process the -display argument and support the DISPLAY env var
96 virtual void display(const char *) { }
97 // default implementation should be enough
98 virtual int XParseGeometry(const char* string, int* x, int* y, unsigned int* width, unsigned int* height);
99 // the default implementation is most probably enough
100 virtual void own_colormap() {}
101 // the default implementation of shortcut_add_key_name() is in src/fl_shortcut.cxx
102 virtual const char *shortcut_add_key_name(unsigned key, char *p, char *buf, const char **);
103 // whether a platform uses additional code in Fl_Menu::handle_part1(int e)
104 virtual int need_menu_handle_part1_extra() {return 0;}
105 // whether a platform uses additional code in Fl_Menu::handle(int e)
106 virtual int need_menu_handle_part2() {return 0;}
107 // implement functions telling whether a key is pressed
108 virtual int event_key(int) {return 0;}
109 virtual int get_key(int) {return 0;}
110 virtual int visual(int flags);
111 // --- screen configuration
112 virtual void init() {}
113 virtual int x() { return 0; }
114 virtual int y() { return 0; }
115 virtual int w() { return 800; } // default, FL_OVERRIDE in driver!
116 virtual int h() { return 600; } // default, FL_OVERRIDE in driver!
117 virtual int screen_count();
118 void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my);
119 virtual void screen_xywh(int &X, int &Y, int &W, int &H, int /*n*/) {
120 X = 0;
121 Y = 0;
122 W = 800;
123 H = 600;
124 }
125 void screen_xywh(int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh);
126 virtual bool screen_boundaries_known() { return true; }
127 virtual int screen_num(int x, int y);
128 virtual int screen_num(int x, int y, int w, int h);
129 virtual void screen_dpi(float &h, float &v, int n = 0) { // FL_OVERRIDE in driver!
130 h = 72;
131 v = 72;
132 (void)n;
133 }
134 void screen_work_area(int &X, int &Y, int &W, int &H, int mx, int my);
135 virtual void screen_work_area(int &X, int &Y, int &W, int &H, int n) {
136 screen_xywh(X, Y, W, H, n);
137 }
138 // --- audible output
139 virtual void beep(int) {}
140 // --- global events
141 virtual void flush() {} // must FL_OVERRIDE
142 virtual void grab(Fl_Window *) {}
143 // --- global colors
144 /* the default implementation of parse_color() may be enough */
145 virtual int parse_color(const char *p, uchar &r, uchar &g, uchar &b);
146 virtual void get_system_colors();
147 /* the default implementation of get_system_scheme() may be enough */
148 virtual const char *get_system_scheme();
149
150 static int secret_input_character;
151 /* Implement to indicate whether complex text input may involve marked text.
152 When it does, has_marked_text returns non zero.
153 */
154 virtual int has_marked_text() const { return 0; }
155 // implement so text-editing widgets support dead keys
156 virtual int compose(int &del) {
157 del = 0;
158 return 0;
159 }
160 // default implementation may be enough
161 virtual void compose_reset();
162 // implement to support drag-n-drop. use_selection = 1 means the GUI is welcome to display
163 // the selected text during the D&D operation
164 virtual int dnd(int use_selection = 0) { (void)use_selection; return 0; }
165 // null means no platform-specific key bindings for Fl_Text_Editor
166 Fl_Text_Editor::Key_Binding *text_editor_extra_key_bindings;
167 // default implementation may be enough
168 virtual int text_display_can_leak() const { return 0; }
169
170 // if no keyboard is connected on a touch or pen device, the system on-screen keyboard is
171 // requested
172 virtual void request_keyboard() {}
173 // we no longer need the on-screen keyboard; it's up to the system to hide it
174 virtual void release_keyboard() {}
175
176 /* Member function read_win_rectangle() supports public functions
177 fl_read_image() and fl_capture_window() which capture pixel data from
178 a window (or also from an offscreen buffer with fl_read_image).
179
180 If 'may_capture_subwins' is true, an implementation may or may not capture
181 also the content of subwindows embedded in 'win'. If subwindows were captured,
182 *'did_capture_subwins' is returned set to true. If read_win_rectangle()
183 is called with 'may_capture_subwins' set to true, 'did_capture_subwins' should
184 be set before the call to the address of a boolean set to false.
185 The implementation of this virtual function for the macOS platform has the
186 capability of capturing subwindows when asked for.
187
188 A platform may also use its read_win_rectangle() implementation to capture
189 window decorations (e.g., title bar). In that case, it is called by
190 Fl_XXX_Window_Driver::capture_titlebar_and_borders().
191
192 win is the window to capture from, or NULL to capture from the current offscreen
193 */
194 virtual Fl_RGB_Image *read_win_rectangle(int /*X*/, int /*Y*/, int /*w*/, int /*h*/, Fl_Window *,
195 bool may_capture_subwins = false,
196 bool *did_capture_subwins = NULL) {
197 (void)may_capture_subwins;
198 (void)did_capture_subwins;
199 return NULL;
200 }
201 static void write_image_inside(Fl_RGB_Image *to, Fl_RGB_Image *from, int to_x, int to_y);
202 static Fl_RGB_Image *traverse_to_gl_subwindows(Fl_Group *g, int x, int y, int w, int h,
203 Fl_RGB_Image *full_img);
204 static size_t convert_crlf(char *s, size_t len);
205 // optional platform-specific key handling for Fl_Input widget
206 // the default implementation may be enough
207 virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
208 // implement to support Fl::get_mouse()
209 virtual int get_mouse(int &/*x*/, int &/*y*/) { return 0; }
210 // optional methods to enable/disable input methods for complex scripts
211 virtual void enable_im() {}
212 virtual void disable_im() {}
213 // calls open_display_platform() and then does platform-independent work
214 void open_display();
215 // implement to open access to the display
216 virtual void open_display_platform() {}
217 // optional method to close display access
218 virtual void close_display() {}
219 // compute dimensions of an Fl_Offscreen
220 virtual void offscreen_size(Fl_Offscreen, int &/*width*/, int &/*height*/) {}
221
222 void rescale_all_windows_from_screen(int screen, float f, float old_f);
223 static void transient_scale_display(float f, int nscreen);
224 // need export to fltk_gl.so because used in glut_compatibility.cxx
225 static FL_EXPORT int scale_handler(int event);
226 virtual void desktop_scale_factor() {}
227 void use_startup_scale_factor();
228 enum APP_SCALING_CAPABILITY {
229 NO_APP_SCALING = 0,
230 SYSTEMWIDE_APP_SCALING,
231 PER_SCREEN_APP_SCALING
232 };
235 virtual APP_SCALING_CAPABILITY rescalable() { return NO_APP_SCALING; }
236 // supports Fl_Window::default_icons()
237 virtual void default_icons(const Fl_RGB_Image *icons[], int count);
238 // implement to support copy-to-clipboard
239 virtual void copy(const char * /*stuff*/, int /*len*/, int /*clipboard*/, const char * /*type*/) {}
240 // implement to support paste-from-clipboard
241 virtual void paste(Fl_Widget &, int /*clipboard*/, const char * /*type*/) {}
242 // implement to support paste-from-clipboard
243 virtual int clipboard_contains(const char * /*type*/) {return 0;}
244 // implement to support paste-from-clipboard
245 virtual void clipboard_notify_change() {}
246 // next 3 are related to Input Methods
247 virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
248 virtual void reset_spot();
249 virtual void set_status(int X, int Y, int W, int H);
250 virtual float base_scale(int numscreen);
251};
252
253#endif // !FL_SCREEN_DRIVER_H
254
Fl.H
Fl static class.
Fl_Group
The Fl_Group class is the main FLTK container widget.
Definition Fl_Group.H:56
Fl_Input
This is the FLTK text input widget.
Definition Fl_Input.H:220
Fl_RGB_Image
The Fl_RGB_Image class supports caching and drawing of full-color images with 1 to 4 channels of colo...
Definition Fl_Image.H:339
Fl_Window
This widget produces an actual window.
Definition Fl_Window.H:55
fl_types.h
This file contains simple "C"-style type definitions.
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30
Fl_Offscreen
opaque Fl_Offscreen
Platform-specific value representing an offscreen drawing buffer.
Definition platform_types.h:46