FLTK 1.4.4: Fl_Window.H Source File

FLTK 1.4.4

Loading...
Searching...
No Matches
Fl_Window.H
Go to the documentation of this file.
1//
2// Window header file for the Fast Light Tool Kit (FLTK).
3//
4// Copyright 1998-2025 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
19
20#ifndef Fl_Window_H
21#define Fl_Window_H
22
23#include <FL/Fl.H>
24#include <FL/Fl_Group.H>
25#include <FL/Fl_Bitmap.H>
26
27#define FL_WINDOW 0xF0
28#define FL_DOUBLE_WINDOW 0xF1
29
30class Fl_X;
31class Fl_Window_Driver;
32class Fl_RGB_Image;
33class Fl_Double_Window;
34
55 class FL_EXPORT Fl_Window : public Fl_Group {
56 friend class Fl_X;
57 friend class Fl_Window_Driver;
58private:
59 static char *default_xclass_;
60 static char show_next_window_iconic_; // 1 means create next window in iconic form
61
62 int no_fullscreen_x;
63 int no_fullscreen_y;
64 int no_fullscreen_w;
65 int no_fullscreen_h;
66 int fullscreen_screen_top;
67 int fullscreen_screen_bottom;
68 int fullscreen_screen_left;
69 int fullscreen_screen_right;
70
71 // TODO: it would make sense to merge the use of Fl_X and Fl_Window_Driver, maybe simply by
72 // TODO: deriving Fl_Window_Driver from Fl_X. However, there are a lot of historic kludges
73 // TODO: for some platforms around Fl_X.
74 Fl_X *flx_; // points at the system-specific stuff, but exists only after the window is mapped
75 Fl_Window_Driver *pWindowDriver; // points at the system-specific stuff at window creation time
76
77 const char* iconlabel_;
78 char* xclass_;
79
80 // private size_range stuff:
81 int minw_, minh_, maxw_, maxh_;
82 int dw_, dh_, aspect_;
83 uchar size_range_set_; // true (1) if size_range() has been set or calculated
84
85 // cursor stuff
86 Fl_Cursor cursor_default;
87
88 void _Fl_Window(); // constructor innards
89
90 // unimplemented copy ctor and assignment operator
91 Fl_Window(const Fl_Window&);
92 Fl_Window& operator=(const Fl_Window&);
93
94 void is_maximized_(bool b);
95
96protected:
97
99 static Fl_Window *current_;
100 void draw() FL_OVERRIDE;
101
102public:
103
105 virtual void flush();
106
107protected:
108
117 void force_position(int force) {
118 if (force) set_flag(FORCE_POSITION);
119 else clear_flag(FORCE_POSITION);
120 }
121
130 int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
131
132 void free_icons();
133
134 void default_size_range(); // calculate size_range() if not set explicitly
135 int is_resizable(); // calculate size_range() and return whether this is resizable
136
137public:
138
167 Fl_Window(int w, int h, const char *title = 0);
190 Fl_Window(int x, int y, int w, int h, const char *title = 0);
199 virtual ~Fl_Window();
200
201 int handle(int) FL_OVERRIDE;
202
219 void resize(int X,int Y,int W,int H) FL_OVERRIDE;
226 void border(int b);
231 void clear_border() {set_flag(NOBORDER);}
233 unsigned int border() const {return !(flags() & NOBORDER);}
235 void set_override() {set_flag(NOBORDER|OVERRIDE);}
237 unsigned int override() const { return flags()&OVERRIDE; }
246 void set_modal() {set_flag(MODAL);}
248 unsigned int modal() const {return flags() & MODAL;}
255 void set_non_modal() {set_flag(NON_MODAL);}
257 unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);}
258
296 void clear_modal_states() {clear_flag(NON_MODAL | MODAL);}
297
311 void set_menu_window() {set_flag(MENU_WINDOW);}
312
314 unsigned int menu_window() const {return flags() & MENU_WINDOW;}
315
332 void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
333 clear_flag(MENU_WINDOW); }
334
335 unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
336
344 void hotspot(int x, int y, int offscreen = 0);
346 void hotspot(const Fl_Widget*, int offscreen = 0);
348 void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
349
360 void free_position() { clear_flag(FORCE_POSITION); }
361
362 void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0);
363
364 uchar get_size_range(int *minw, int *minh, int *maxw=NULL, int *maxh=NULL, int *dw=NULL, int *dh=NULL, int *aspect=NULL);
365
367 const char* label() const {return Fl_Widget::label();}
369 const char* iconlabel() const {return iconlabel_;}
371 void label(const char*);
373 void iconlabel(const char*);
375 void label(const char* label, const char* iconlabel); // platform dependent
376 void copy_label(const char* a);
377
378 static void default_xclass(const char*);
379 static const char *default_xclass();
380 const char* xclass() const;
381 void xclass(const char* c);
382
383 static void default_icon(const Fl_RGB_Image*);
384 static void default_icons(const Fl_RGB_Image*[], int);
385 void icon(const Fl_RGB_Image*);
386 void icons(const Fl_RGB_Image*[], int);
387
388#if defined(_WIN32) || defined(FL_DOXYGEN)
389 typedef struct HICON__* HICON;
390 // These 2 member functions break the driver model but are kept for back compatibility.
391 // They are implemented in Fl_win32.cxx
392
412 static void default_icons(HICON big_icon, HICON small_icon);
413
422 void icons(HICON big_icon, HICON small_icon);
423#endif // defined(_WIN32) || defined(FL_DOXYGEN)
424
425 /* for legacy compatibility */
426 const void* icon() const;
427 void icon(const void * ic);
428
434 int shown() {return flx_ != 0;}
461 void show() FL_OVERRIDE;
466 void hide() FL_OVERRIDE;
487 void show(int argc, char **argv);
488
489 // Enables synchronous show(), docs in Fl_Window.cxx
490 void wait_for_expose();
491
503 void fullscreen();
507 void fullscreen_off();
512 void fullscreen_off(int X,int Y,int W,int H);
516 unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
527 void fullscreen_screens(int top, int bottom, int left, int right);
528
529 void maximize();
530 void un_maximize();
532 unsigned int maximize_active() const { return flags() & MAXIMIZED; }
533public:
549 void iconize();
550
551 int x_root() const ;
552 int y_root() const ;
553
554 static Fl_Window *current();
564 void make_current();
565
566 void cursor(Fl_Cursor);
567 void cursor(const Fl_RGB_Image*, int, int);
568 void default_cursor(Fl_Cursor);
569
570 /* for legacy compatibility */
571 void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
572 void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
573
574 static void default_callback(Fl_Window*, void* v);
575
581 int decorated_w() const;
582
596 int decorated_h() const;
597
598 // Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
599 Fl_Window* as_window() FL_OVERRIDE { return this; }
600 Fl_Window const* as_window() const FL_OVERRIDE { return this; }
601
605 virtual class Fl_Overlay_Window *as_overlay_window() {return 0L; }
606
610 virtual class Fl_Double_Window *as_double_window() {return 0L;}
611
612 void shape(const Fl_Image* img);
613 void shape(const Fl_Image& b);
614 const Fl_Image *shape();
615 void draw_backdrop();
616 int screen_num();
617 void screen_num(int screen_num);
618 static bool is_a_rescale();
619 fl_uintptr_t os_id();
620
628 static void show_next_window_iconic(char stat) {
629 show_next_window_iconic_ = stat ? 1 : 0;
630 }
631
639 static char show_next_window_iconic() {
640 return show_next_window_iconic_;
641 }
642
643 void allow_expand_outside_parent();
644
645};
646
647#endif
Fl_Cursor
Fl_Cursor
The following constants define the mouse cursors that are available in FLTK.
Definition Enumerations.H:1283
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition Enumerations.H:1120
Fl.H
Fl static class.
Fl_Group.H
Fl_Group and Fl_End classes.
Fl_Double_Window
The Fl_Double_Window provides a double-buffered window.
Definition Fl_Double_Window.H:31
Fl_Group::handle
int handle(int) FL_OVERRIDE
Handles the specified event.
Definition Fl_Group.cxx:145
Fl_Group::resize
void resize(int, int, int, int) FL_OVERRIDE
Resizes the Fl_Group widget and all of its children.
Definition Fl_Group.cxx:825
Fl_Group::draw
void draw() FL_OVERRIDE
Draws the widget.
Definition Fl_Group.cxx:943
Fl_Group::current
static Fl_Group * current()
Returns the currently active group.
Definition Fl_Group.cxx:82
Fl_Image
Base class for image caching, scaling and drawing.
Definition Fl_Image.H:60
Fl_Overlay_Window
This window provides double buffering and also the ability to draw the "overlay" which is another pic...
Definition Fl_Overlay_Window.H:36
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
Fl_Widget is the base class for all widgets in FLTK.
Definition Fl_Widget.H:112
Fl_Widget::default_callback
static void default_callback(Fl_Widget *widget, void *data)
The default callback for all widgets that don't set a callback.
Definition Fl_Widget.cxx:38
Fl_Widget::label
const char * label() const
Gets the current label text.
Definition Fl_Widget.H:498
Fl_Widget::flags
unsigned int flags() const
Gets the widget flags mask.
Definition Fl_Widget.H:158
Fl_Widget::OVERRIDE
@ OVERRIDE
position window on top (Fl_Window)
Definition Fl_Widget.H:175
Fl_Widget::FORCE_POSITION
@ FORCE_POSITION
don't let the window manager position the window (Fl_Window)
Definition Fl_Widget.H:171
Fl_Widget::NOBORDER
@ NOBORDER
don't draw a decoration (Fl_Window)
Definition Fl_Widget.H:170
Fl_Widget::MAXIMIZED
@ MAXIMIZED
a maximized Fl_Window
Definition Fl_Widget.H:191
Fl_Widget::TOOLTIP_WINDOW
@ TOOLTIP_WINDOW
a temporary popup, transparent to events, and dismissed easily (Fl_Window)
Definition Fl_Widget.H:180
Fl_Widget::MODAL
@ MODAL
a window blocking input to all other windows (Fl_Window)
Definition Fl_Widget.H:181
Fl_Widget::MENU_WINDOW
@ MENU_WINDOW
a temporary popup window, dismissed by clicking outside (Fl_Window)
Definition Fl_Widget.H:179
Fl_Widget::NON_MODAL
@ NON_MODAL
this is a hovering toolbar window (Fl_Window)
Definition Fl_Widget.H:172
Fl_Widget::FULLSCREEN
@ FULLSCREEN
a fullscreen window (Fl_Window)
Definition Fl_Widget.H:185
Fl_Widget::set_flag
void set_flag(unsigned int c)
Sets a flag in the flags mask.
Definition Fl_Widget.H:160
Fl_Widget::as_window
virtual Fl_Window * as_window()
Returns an Fl_Window pointer if this widget is an Fl_Window.
Definition Fl_Widget.H:1230
Fl_Widget::copy_label
void copy_label(const char *new_label)
Sets the current label.
Definition Fl_Widget.cxx:302
Fl_Widget::show
virtual void show()
Makes a widget visible.
Definition Fl_Widget.cxx:251
Fl_Widget::clear_flag
void clear_flag(unsigned int c)
Clears a flag in the flags mask.
Definition Fl_Widget.H:162
Fl_Widget::draw_backdrop
void draw_backdrop() const
If FL_ALIGN_IMAGE_BACKDROP is set, the image or deimage will be drawn.
Definition fl_boxtype.cxx:516
Fl_Window
This widget produces an actual window.
Definition Fl_Window.H:55
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::default_icons
static void default_icons(HICON big_icon, HICON small_icon)
Sets the default window icons (Windows platform only).
Fl_Window::maximize_active
unsigned int maximize_active() const
Returns whether the window is currently maximized.
Definition Fl_Window.H:532
Fl_Window::free_position
void free_position()
Undoes the effect of a previous resize() or show() so that the next time show() is called the window ...
Definition Fl_Window.H:360
Fl_Window::fullscreen_active
unsigned int fullscreen_active() const
Returns non zero if FULLSCREEN flag is set, 0 otherwise.
Definition Fl_Window.H:516
Fl_Window::force_position
void force_position(int force)
Sets an internal flag that tells FLTK and the window manager to honor position requests.
Definition Fl_Window.H:117
Fl_Window::set_menu_window
void set_menu_window()
Marks the window as a menu window.
Definition Fl_Window.H:311
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::iconlabel
const char * iconlabel() const
See void Fl_Window::iconlabel(const char*).
Definition Fl_Window.H:369
Fl_Window::icon
void icon(const Fl_RGB_Image *)
Sets or resets a single window icon.
Definition Fl_Window.cxx:348
Fl_Window::clear_modal_states
void clear_modal_states()
Clears the "modal" flags and converts a "modal" or "non-modal" window back into a "normal" window.
Definition Fl_Window.H:296
Fl_Window::non_modal
unsigned int non_modal() const
Returns true if this window is modal or non-modal.
Definition Fl_Window.H:257
Fl_Window::menu_window
unsigned int menu_window() const
Returns true if this window is a menu window.
Definition Fl_Window.H:314
Fl_Window::hotspot
void hotspot(const Fl_Widget &p, int offscreen=0)
See void Fl_Window::hotspot(int x, int y, int offscreen = 0).
Definition Fl_Window.H:348
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::icons
void icons(HICON big_icon, HICON small_icon)
Sets the window icons using HICON handles (Windows platform only).
Fl_Window::set_override
void set_override()
Activates the flags NOBORDER|OVERRIDE.
Definition Fl_Window.H:235
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::as_double_window
virtual class Fl_Double_Window * as_double_window()
Return non-null if this is an Fl_Double_Window object.
Definition Fl_Window.H:610
Fl_Window::modal
unsigned int modal() const
Returns true if this window is modal.
Definition Fl_Window.H:248
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::as_window
Fl_Window * as_window() FL_OVERRIDE
Returns an Fl_Window pointer if this widget is an Fl_Window.
Definition Fl_Window.H:599
Fl_Window::set_non_modal
void set_non_modal()
A "non-modal" window (terminology borrowed from Microsoft Windows) acts like a modal() one in that it...
Definition Fl_Window.H:255
Fl_Window::clear_border
void clear_border()
Fast inline function to turn the window manager border off.
Definition Fl_Window.H:231
Fl_Window::current_
static Fl_Window * current_
Stores the last window that was made current.
Definition Fl_Window.H:99
Fl_Window::set_modal
void set_modal()
A "modal" window, when shown(), will prevent any events from being delivered to other windows in the ...
Definition Fl_Window.H:246
Fl_Window::show_next_window_iconic
static void show_next_window_iconic(char stat)
Sets a static flag whether the next window should be opened iconified.
Definition Fl_Window.H:628
Fl_Window::set_tooltip_window
void set_tooltip_window()
Marks the window as a tooltip window.
Definition Fl_Window.H:332
Fl_Window::label
const char * label() const
See void Fl_Window::label(const char*).
Definition Fl_Window.H:367
Fl_Window::tooltip_window
unsigned int tooltip_window() const
Returns true if this window is a tooltip window.
Definition Fl_Window.H:335
FL_OVERRIDE
#define FL_OVERRIDE
This macro makes it safe to use the C++11 keyword override with older compilers.
Definition fl_attr.h:46
uchar
unsigned char uchar
unsigned char
Definition fl_types.h:30
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