FLTK 1.4.0
Loading...
Searching...
No Matches
Fl_Window_Driver.H
1//
2// A base class for platform specific window handling code
3// for the Fast Light Tool Kit (FLTK).
4//
5// Copyright 2010-2024 by Bill Spitzak and others.
6//
7// This library is free software. Distribution and use rights are outlined in
8// the file "COPYING" which should have been included with this file. If this
9// file is missing or damaged, see the license at:
10//
11// https://www.fltk.org/COPYING.php
12//
13// Please see the following page on how to report bugs and issues:
14//
15// https://www.fltk.org/bugs.php
16//
17
28#ifndef FL_WINDOW_DRIVER_H
29#define FL_WINDOW_DRIVER_H
30
31#include <FL/Fl_Export.H>
32#include <FL/Fl_Window.H>
33#include <FL/Fl_Overlay_Window.H>
34
35#include <stdlib.h>
36
37class Fl_X;
38class Fl_Image;
39class Fl_RGB_Image;
41
52class Fl_Window_Driver
53{
54 friend class Fl_Window;
55private:
56 static bool is_a_rescale_; // true when a top-level window is being rescaled
57
58protected:
59 Fl_Window *pWindow;
60 int screen_num_; // number of screen where window is mapped
61public:
62 Fl_Window_Driver(Fl_Window *);
63 virtual ~Fl_Window_Driver();
64 static Fl_Window_Driver *newWindowDriver(Fl_Window *);
65 static fl_uintptr_t xid(const Fl_Window *win);
66 static Fl_Window *find(fl_uintptr_t xid);
67 int wait_for_expose_value;
68 Fl_Image_Surface *other_xid; // offscreen bitmap (overlay and double-buffered windows)
69 int screen_num();
70 void screen_num(int n) { screen_num_ = n; }
71
72
73 // --- frequently used accessors to public window data
75 int x() const { return pWindow->x(); }
77 int y() const { return pWindow->y(); }
79 int w() const { return pWindow->w(); }
81 int h() const { return pWindow->h(); }
83 int border() const { return pWindow->border(); }
85 int visible() const { return pWindow->visible(); }
87 int visible_r() const { return pWindow->visible_r(); }
89 int shown() const { return pWindow->shown(); }
91 Fl_Group *parent() const { return pWindow->parent(); }
92
93 // --- accessors to private window data
94 int minw();
95 int minh();
96 int maxw();
97 int maxh();
98 int dw();
99 int dh();
100 int aspect();
101 unsigned char size_range_set();
102 int is_resizable() { return pWindow->is_resizable(); }
103 void is_a_rescale(bool b) { is_a_rescale_ = b;}
104 int fullscreen_screen_top();
105 int fullscreen_screen_bottom();
106 int fullscreen_screen_left();
107 int fullscreen_screen_right();
108 int* no_fullscreen_x() { return &pWindow->no_fullscreen_x; }
109 int* no_fullscreen_y() { return &pWindow->no_fullscreen_y; }
110 int* no_fullscreen_w() { return &pWindow->no_fullscreen_w; }
111 int* no_fullscreen_h() { return &pWindow->no_fullscreen_h; }
112 int force_position();
113 void force_position(int c);
114 void x(int X);
115 void y(int Y);
116 void current(Fl_Window *c);
117 char show_iconic() { return Fl_Window::show_next_window_iconic(); }
118 void show_iconic(char c) { Fl_Window::show_next_window_iconic(c); }
119 void flx(Fl_X *x) { pWindow->flx_ = x; }
120 Fl_Cursor cursor_default() { return pWindow->cursor_default; }
121 void destroy_double_buffer();
123 Fl_Window *overlay() {
124 return pWindow->as_overlay_window() ? pWindow->as_overlay_window()->overlay_ : NULL;
125 }
127 void overlay(Fl_Window *o) {
128 if (pWindow->as_overlay_window()) pWindow->as_overlay_window()->overlay_ = o;
129 }
130
131 void resize_after_scale_change(int ns, float old_f, float new_f);
132 void set_popup_window() { pWindow->set_flag(Fl_Window::POPUP); }
133 bool popup_window() const {return pWindow->flags() & Fl_Window::POPUP;}
134
135 // --- window data
136 virtual int decorated_w() { return w(); } // default, should be overidden by driver
137 virtual int decorated_h() { return h(); }
138 virtual const Fl_Image* shape() { return NULL; }
139
140 // --- window management
141 virtual void take_focus();
142 virtual void flush(); // the default implementation may be enough
143 virtual void flush_double();
144 virtual void flush_overlay();
146 virtual void draw_begin();
148 virtual void draw_end();
149 void draw();
150 virtual void make_current();
151 virtual void label(const char *name, const char *mininame);
152
153 virtual void makeWindow() {}
154 virtual void wait_for_expose();
155 virtual void show();
156 virtual void resize(int /*X*/, int /*Y*/, int /*W*/, int /*H*/) {}
157 virtual void hide() {}
158 int hide_common();
159 virtual void map() {}
160 virtual void unmap() {}
161 virtual void fullscreen_on() {}
162 virtual void fullscreen_off(int /*X*/, int /*Y*/, int /*W*/, int /*H*/) {}
163 virtual void maximize();
164 virtual void un_maximize();
165 virtual bool maximize_needs_hide() { return false; }
166 void is_maximized(bool b) { pWindow->is_maximized_(b); }
167 virtual void use_border();
168 virtual void size_range();
169 virtual void iconize() {}
170 virtual void decoration_sizes(int *top, int *left, int *right, int *bottom) {
171 *top = *left = *right = *bottom = 0;
172 }
173 virtual void show_with_args_begin() {}
174 virtual void show_with_args_end(int /*argc*/, char ** /*argv*/) {}
175 virtual int can_do_overlay();
176 virtual void redraw_overlay();
177
178 // --- window cursor stuff
179 virtual int set_cursor(Fl_Cursor);
180 virtual int set_cursor(const Fl_RGB_Image*, int, int);
181
182 // --- window shape stuff
183 void shape_pixmap_(Fl_Image* pixmap); // platform-independent, support function
184 virtual void shape(const Fl_Image*) {}
185 virtual void shape_alpha_(Fl_Image*, int /*offset*/) {}
186
187 // --- window icon stuff
188 virtual void icons(const Fl_RGB_Image* /*icons*/[], int /*count*/) {}
189 virtual const void *icon() const {return NULL;}
190 virtual void icon(const void *) {}
191 virtual void free_icons() {}
192
193 // --- window printing/drawing helper
194 virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left,
195 Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
196 virtual int scroll(int /*src_x*/, int /*src_y*/, int /*src_w*/, int /*src_h*/,
197 int /*dest_x*/, int /*dest_y*/,
198 void (*)(void*, int,int,int,int), void*) { return 0; }
199 static inline Fl_Window_Driver* driver(const Fl_Window *win) {return win->pWindowDriver;}
200
201 // --- support for menu windows
202 // The default implementation of next 2 virtual members is enough if the
203 // position of a window in a screen is known. Next static members may be useful
204 // when that's not the case, as with Wayland.
205 virtual void reposition_menu_window(int x, int y);
206 virtual void menu_window_area(int &X, int &Y, int &W, int &H, int nscreen = -1);
207 static Fl_Window *menu_parent(int *display_height = NULL);
208 static Fl_Window *menu_leftorigin(Fl_Window*);
209 static Fl_Window *menu_title(Fl_Window*);
210 static int menu_itemheight(Fl_Window*);
211 static int menu_bartitle(Fl_Window*);
212 static int menu_selected(Fl_Window*);
213 static int *menu_offset_y(Fl_Window*);
214 static bool is_floating_title(Fl_Window *);
215 static void scroll_to_selected_item(Fl_Window *);
216
217 virtual fl_uintptr_t os_id() { return 0; }
218};
219
220#endif // FL_WINDOW_DRIVER_H
221
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition Enumerations.H:1261
Fl_Window widget .
The Fl_Group class is the FLTK container widget.
Definition Fl_Group.H:56
int find(const Fl_Widget *) const
Searches the child array for the widget and returns the index.
Definition Fl_Group.cxx:50
Directs all graphics requests to an Fl_Image.
Definition Fl_Image_Surface.H:65
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
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
int y() const
Gets the widget position in its window.
Definition Fl_Widget.H:358
int h() const
Gets the widget height.
Definition Fl_Widget.H:368
unsigned int flags() const
Gets the widget flags mask.
Definition Fl_Widget.H:150
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition Fl_Widget.H:152
@ POPUP
popup window (i.e., positioned relatively to another mapped window)
Definition Fl_Widget.H:184
int w() const
Gets the widget width.
Definition Fl_Widget.H:363
int take_focus()
Gives the widget the keyboard focus.
Definition Fl_Widget.cxx:148
void x(int v)
Internal use only.
Definition Fl_Widget.H:142
unsigned int visible() const
Returns whether a widget is visible.
Definition Fl_Widget.H:833
int visible_r() const
Returns whether a widget and all its parents are visible.
Definition Fl_Widget.cxx:291
Fl_Group * parent() const
Returns a pointer to the parent widget.
Definition Fl_Widget.H:326
void w(int v)
Internal use only.
Definition Fl_Widget.H:146
void y(int v)
Internal use only.
Definition Fl_Widget.H:144
void h(int v)
Internal use only.
Definition Fl_Widget.H:148
int x() const
Gets the widget position in its window.
Definition Fl_Widget.H:353
This widget produces an actual window.
Definition Fl_Window.H:55
void free_icons()
Deletes all icons previously attached to the window.
Definition Fl_Window.cxx:400
int decorated_w() const
Returns the window width including any frame added by the window manager.
Definition Fl_Window.cxx:469
int force_position() const
Returns the internal state of the window's FORCE_POSITION flag.
Definition Fl_Window.H:124
void icons(const Fl_RGB_Image *[], int)
Sets the window icons.
Definition Fl_Window.cxx:377
int screen_num()
The number of the screen containing the mapped window.
Definition Fl_Window.cxx:846
static bool is_a_rescale()
Returns true when a window is being rescaled.
Definition Fl_Window.cxx:915
virtual void flush()
Forces the window to be drawn, this window is also made current and calls draw().
Definition Fl_Window.cxx:481
void iconize()
Iconifies the window.
Definition Fl_Window_iconize.cxx:20
const void * icon() const
Gets the current icon window target dependent data.
Definition Fl_Window.cxx:384
void make_current()
Sets things up so that the drawing functions in <FL/fl_draw.H> will go into this window.
Definition Fl_Window.cxx:533
void border(int b)
Sets whether or not the window manager border is around the window.
Definition Fl_Window_fullscreen.cxx:20
virtual class Fl_Overlay_Window * as_overlay_window()
Return non-null if this is an Fl_Overlay_Window object.
Definition Fl_Window.H:589
int is_resizable()
Protected method to determine whether a window is resizable.
Definition Fl_Window.cxx:837
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Window.cxx:491
static char show_next_window_iconic()
Returns the static flag whether the next window should be opened iconified.
Definition Fl_Window.H:623
void maximize()
Maximizes a top-level window to its current screen.
Definition Fl_Window.cxx:933
void hide() FL_OVERRIDE
Removes the window from the screen.
Definition Fl_Window.cxx:563
const Fl_Image * shape()
Returns the image controlling the window shape or NULL.
Definition Fl_Window.cxx:912
unsigned int border() const
Returns whether the window possesses a border.
Definition Fl_Window.H:221
int shown()
Returns non-zero if show() has been called (but not hide() ).
Definition Fl_Window.H:418
void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)
Sets the allowable range the user can resize this window to.
Definition Fl_Window.cxx:665
void show() FL_OVERRIDE
Puts the window on the screen.
Definition Fl_Window.cxx:545
void wait_for_expose()
Waits for the window to be displayed after calling show().
Definition Fl_Window.cxx:464
fl_uintptr_t os_id()
Returns a platform-specific identification of a shown window, or 0 if not shown.
Definition Fl_Window.cxx:924
void fullscreen_off()
Turns off any side effects of fullscreen()
Definition Fl_Window_fullscreen.cxx:59
void resize(int X, int Y, int W, int H) FL_OVERRIDE
Changes the size and position of the window.
Definition Fl_Window.cxx:559
int decorated_h() const
Returns the window height including any window title bar and any frame added by the window manager.
Definition Fl_Window.cxx:475
const char * label() const
See void Fl_Window::label(const char*)
Definition Fl_Window.H:351
static Fl_Window * current()
Returns the last window that was made current.
Definition Fl_Window.cxx:184
void un_maximize()
Returns a previously maximized top-level window to its previous size.
Definition Fl_Window.cxx:944
opaque fl_uintptr_t
An unsigned integral type large enough to store a pointer or an unsigned long value.
Definition platform_types.h:36