FLTK 1.4.4

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-2025 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
23
27
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
37 class Fl_X;
38 class Fl_Image;
39 class Fl_RGB_Image;
40 class Fl_Image_Surface;
41
52 class Fl_Window_Driver
53{
54 friend class Fl_Window;
55 private:
56 static bool is_a_rescale_; // true when a top-level window is being rescaled
57
58 protected:
59 Fl_Window *pWindow;
60 int screen_num_; // number of screen where window is mapped
61 public:
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 is_resizable() { return pWindow->is_resizable(); }
95 void is_a_rescale(bool b) { is_a_rescale_ = b;}
96 int fullscreen_screen_top();
97 int fullscreen_screen_bottom();
98 int fullscreen_screen_left();
99 int fullscreen_screen_right();
100 int* no_fullscreen_x() { return &pWindow->no_fullscreen_x; }
101 int* no_fullscreen_y() { return &pWindow->no_fullscreen_y; }
102 int* no_fullscreen_w() { return &pWindow->no_fullscreen_w; }
103 int* no_fullscreen_h() { return &pWindow->no_fullscreen_h; }
104 int force_position();
105 void force_position(int c);
106 void x(int X);
107 void y(int Y);
108 void current(Fl_Window *c);
109 char show_iconic() { return Fl_Window::show_next_window_iconic(); }
110 void show_iconic(char c) { Fl_Window::show_next_window_iconic(c); }
111 void flx(Fl_X *x) { pWindow->flx_ = x; }
112 Fl_Cursor cursor_default() { return pWindow->cursor_default; }
113 void destroy_double_buffer();
115 Fl_Window *overlay() {
116 return pWindow->as_overlay_window() ? pWindow->as_overlay_window()->overlay_ : NULL;
117 }
119 void overlay(Fl_Window *o) {
120 if (pWindow->as_overlay_window()) pWindow->as_overlay_window()->overlay_ = o;
121 }
122
123 void resize_after_scale_change(int ns, float old_f, float new_f);
124 void set_popup_window() { pWindow->set_flag(Fl_Window::POPUP); }
125 bool popup_window() const {return pWindow->flags() & Fl_Window::POPUP;}
126
127 // --- window data
128 virtual int decorated_w() { return w(); } // default, should be overidden by driver
129 virtual int decorated_h() { return h(); }
130 virtual const Fl_Image* shape() { return NULL; }
131
132 // --- window management
133 virtual void take_focus();
134 virtual void flush(); // the default implementation may be enough
135 virtual void flush_double();
136 virtual void flush_overlay();
138 virtual void draw_begin();
140 virtual void draw_end();
141 void draw();
142 virtual void make_current();
143 virtual void label(const char *name, const char *mininame);
144
145 virtual void makeWindow() {}
146 virtual void wait_for_expose();
147 virtual void show();
148 virtual void resize(int /*X*/, int /*Y*/, int /*W*/, int /*H*/) {}
149 virtual void hide() {}
150 int hide_common();
151 virtual void map() {}
152 virtual void unmap() {}
153 virtual void fullscreen_on() {}
154 virtual void fullscreen_off(int /*X*/, int /*Y*/, int /*W*/, int /*H*/) {}
155 virtual void fullscreen_screens(bool /*on_off*/) {}
156 virtual void maximize();
157 virtual void un_maximize();
158 virtual bool maximize_needs_hide() { return false; }
159 void is_maximized(bool b) { pWindow->is_maximized_(b); }
160 virtual void use_border();
161 virtual void size_range();
162 virtual void iconize() {}
163 virtual void decoration_sizes(int *top, int *left, int *right, int *bottom) {
164 *top = *left = *right = *bottom = 0;
165 }
166 virtual void show_with_args_begin() {}
167 virtual void show_with_args_end(int /*argc*/, char ** /*argv*/) {}
168 virtual int can_do_overlay();
169 virtual void redraw_overlay();
170
171 // --- window cursor stuff
172 virtual int set_cursor(Fl_Cursor);
173 virtual int set_cursor(const Fl_RGB_Image*, int, int);
174
175 // --- window shape stuff
176 void shape_pixmap_(Fl_Image* pixmap); // platform-independent, support function
177 virtual void shape(const Fl_Image*) {}
178 virtual void shape_alpha_(Fl_Image*, int /*offset*/) {}
179
180 // --- window icon stuff
181 virtual void icons(const Fl_RGB_Image* /*icons*/[], int /*count*/) {}
182 virtual const void *icon() const {return NULL;}
183 virtual void icon(const void *) {}
184 virtual void free_icons() {}
185
186 // --- window printing/drawing helper
187 virtual void capture_titlebar_and_borders(Fl_RGB_Image*& top, Fl_RGB_Image*& left,
188 Fl_RGB_Image*& bottom, Fl_RGB_Image*& right);
189 virtual int scroll(int /*src_x*/, int /*src_y*/, int /*src_w*/, int /*src_h*/,
190 int /*dest_x*/, int /*dest_y*/,
191 void (*)(void*, int,int,int,int), void*) { return 0; }
192 static inline Fl_Window_Driver* driver(const Fl_Window *win) {return win->pWindowDriver;}
193
194 // --- support for menu windows
195 // The default implementation of next 2 virtual members is enough if the
196 // position of a window in a screen is known. Next static members may be useful
197 // when that's not the case, as with Wayland.
198 virtual void reposition_menu_window(int x, int y);
199 virtual void menu_window_area(int &X, int &Y, int &W, int &H, int nscreen = -1);
200 static Fl_Window *menu_parent(int *display_height = NULL);
201 static Fl_Window *menu_leftorigin(Fl_Window*);
202 static Fl_Window *menu_title(Fl_Window*);
203 static int menu_itemheight(Fl_Window*);
204 static int menu_bartitle(Fl_Window*);
205 static int menu_selected(Fl_Window*);
206 static int *menu_offset_y(Fl_Window*);
207 static bool is_floating_title(Fl_Window *);
208 static void scroll_to_selected_item(Fl_Window *);
209 // non-NULL when an Fl_Menu_Button is being pulled down
210 static class Fl_Menu_Button *current_menu_button;
211
212 virtual fl_uintptr_t os_id() { return 0; }
213 virtual void allow_expand_outside_parent() {}
214};
215
216#endif // FL_WINDOW_DRIVER_H
217
Fl_Cursor
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition Enumerations.H:1283
Fl_Window.H
Fl_Window widget .
Fl_Group::find
int find(const Fl_Widget *) const
Searches the child array for the widget and returns the index.
Definition Fl_Group.cxx:50
Fl_Image_Surface
Directs all graphics requests to an Fl_Image.
Definition Fl_Image_Surface.H:65
Fl_Image
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
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_Widget::y
int y() const
Gets the widget position in its window.
Definition Fl_Widget.H:366
Fl_Widget::h
int h() const
Gets the widget height.
Definition Fl_Widget.H:376
Fl_Widget::flags
unsigned int flags() const
Gets the widget flags mask.
Definition Fl_Widget.H:158
Fl_Widget::POPUP
@ POPUP
popup window (i.e., positioned relatively to another mapped window)
Definition Fl_Widget.H:192
Fl_Widget::set_flag
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition Fl_Widget.H:160
Fl_Widget::w
int w() const
Gets the widget width.
Definition Fl_Widget.H:371
Fl_Widget::take_focus
int take_focus()
Gives the widget the keyboard focus.
Definition Fl_Widget.cxx:150
Fl_Widget::x
void x(int v)
Internal use only.
Definition Fl_Widget.H:150
Fl_Widget::visible
unsigned int visible() const
Returns whether a widget is visible.
Definition Fl_Widget.H:872
Fl_Widget::visible_r
int visible_r() const
Returns whether a widget and all its parents are visible.
Definition Fl_Widget.cxx:275
Fl_Widget::parent
Fl_Group * parent() const
Returns a pointer to the parent widget.
Definition Fl_Widget.H:334
Fl_Widget::w
void w(int v)
Internal use only.
Definition Fl_Widget.H:154
Fl_Widget::y
void y(int v)
Internal use only.
Definition Fl_Widget.H:152
Fl_Widget::h
void h(int v)
Internal use only.
Definition Fl_Widget.H:156
Fl_Widget::x
int x() const
Gets the widget position in its window.
Definition Fl_Widget.H:361
Fl_Window::free_icons
void free_icons()
Deletes all icons previously attached to the window.
Definition Fl_Window.cxx:400
Fl_Window::decorated_w
int decorated_w() const
Returns the window width including any frame added by the window manager.
Definition Fl_Window.cxx:469
Fl_Window::force_position
int force_position() const
Returns the internal state of the window's FORCE_POSITION flag.
Definition Fl_Window.H:130
Fl_Window::icons
void icons(const Fl_RGB_Image *[], int)
Sets the window icons.
Definition Fl_Window.cxx:377
Fl_Window::screen_num
int screen_num()
The number of the screen containing the mapped window.
Definition Fl_Window.cxx:895
Fl_Window::is_a_rescale
static bool is_a_rescale()
Returns true when a window is being rescaled.
Definition Fl_Window.cxx:986
Fl_Window::flush
virtual void flush()
Forces the window to be drawn, this window is also made current and calls draw().
Definition Fl_Window.cxx:481
Fl_Window::iconize
void iconize()
Iconifies the window.
Definition Fl_Window_iconize.cxx:20
Fl_Window::icon
const void * icon() const
Gets the current icon window target dependent data.
Definition Fl_Window.cxx:384
Fl_Window::fullscreen_screens
void fullscreen_screens(int top, int bottom, int left, int right)
Sets which screens should be used when this window is in fullscreen mode.
Definition Fl_Window_fullscreen.cxx:72
Fl_Window::make_current
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:534
Fl_Window::border
void border(int b)
Sets whether or not the window manager border is around the window.
Definition Fl_Window_fullscreen.cxx:20
Fl_Window::as_overlay_window
virtual class Fl_Overlay_Window * as_overlay_window()
Return non-null if this is an Fl_Overlay_Window object.
Definition Fl_Window.H:605
Fl_Window::is_resizable
int is_resizable()
Protected method to determine whether a window is resizable.
Definition Fl_Window.cxx:870
Fl_Window::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Window.cxx:491
Fl_Window::show_next_window_iconic
static char show_next_window_iconic()
Returns the static flag whether the next window should be opened iconified.
Definition Fl_Window.H:639
Fl_Window::maximize
void maximize()
Maximizes a top-level window to its current screen.
Definition Fl_Window.cxx:1013
Fl_Window::hide
void hide() FL_OVERRIDE
Removes the window from the screen.
Definition Fl_Window.cxx:564
Fl_Window::shape
const Fl_Image * shape()
Returns the image controlling the window shape or NULL.
Definition Fl_Window.cxx:980
Fl_Window::border
unsigned int border() const
Returns whether the window possesses a border.
Definition Fl_Window.H:233
Fl_Window::shown
int shown()
Returns non-zero if show() has been called (but not hide() ).
Definition Fl_Window.H:434
Fl_Window::size_range
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 to which the user can resize this window.
Definition Fl_Window.cxx:667
Fl_Window::show
void show() FL_OVERRIDE
Puts the window on the screen.
Definition Fl_Window.cxx:546
Fl_Window::wait_for_expose
void wait_for_expose()
Waits for the window to be displayed after calling show().
Definition Fl_Window.cxx:464
Fl_Window::fullscreen_off
void fullscreen_off()
Turns off any side effects of fullscreen().
Definition Fl_Window_fullscreen.cxx:63
Fl_Window::resize
void resize(int X, int Y, int W, int H) FL_OVERRIDE
Changes the size and position of the window.
Definition Fl_Window.cxx:560
Fl_Window::decorated_h
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
Fl_Window::label
const char * label() const
See void Fl_Window::label(const char*).
Definition Fl_Window.H:367
Fl_Window::current
static Fl_Window * current()
Returns the last window that was made current.
Definition Fl_Window.cxx:184
Fl_Window::un_maximize
void un_maximize()
Returns a previously maximized top-level window to its previous size.
Definition Fl_Window.cxx:1026
fl_uintptr_t
opaque fl_uintptr_t
An unsigned integral type large enough to store a pointer or an unsigned long value.
Definition platform_types.h:36