1998-10-20 01:39:29 +04:00
|
|
|
//
|
|
|
|
// Window header file for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2023-11-17 18:55:37 +03:00
|
|
|
// Copyright 1998-2023 by Bill Spitzak and others.
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2011-07-19 08:49:30 +04: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-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/COPYING.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// Please see the following page on how to report bugs and issues:
|
2005-04-16 04:13:17 +04:00
|
|
|
//
|
2020-07-01 19:03:10 +03:00
|
|
|
// https://www.fltk.org/bugs.php
|
1998-10-20 01:39:29 +04:00
|
|
|
//
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2014-08-27 15:55:57 +04:00
|
|
|
/** \file
|
2008-09-16 11:26:22 +04:00
|
|
|
Fl_Window widget . */
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
#ifndef Fl_Window_H
|
|
|
|
#define Fl_Window_H
|
|
|
|
|
2016-03-23 21:00:37 +03:00
|
|
|
#include <FL/Fl.H>
|
2016-03-23 20:13:09 +03:00
|
|
|
#include <FL/Fl_Group.H>
|
|
|
|
#include <FL/Fl_Bitmap.H>
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2020-07-12 19:06:03 +03:00
|
|
|
#define FL_WINDOW 0xF0 ///< window type id: all subclasses have type() >= this
|
2008-09-18 23:09:34 +04:00
|
|
|
#define FL_DOUBLE_WINDOW 0xF1 ///< double window type id
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2001-05-11 22:37:08 +04:00
|
|
|
class Fl_X;
|
2016-02-20 01:21:02 +03:00
|
|
|
class Fl_Window_Driver;
|
2014-06-16 15:17:57 +04:00
|
|
|
class Fl_RGB_Image;
|
2016-03-07 01:22:22 +03:00
|
|
|
class Fl_Double_Window;
|
2014-09-21 18:10:36 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
This widget produces an actual window. This can either be a main
|
|
|
|
window, with a border and title and all the window management controls,
|
2008-09-17 19:44:43 +04:00
|
|
|
or a "subwindow" inside a window. This is controlled by whether or not
|
2008-09-14 02:33:03 +04:00
|
|
|
the window has a parent().
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2020-07-12 19:06:03 +03:00
|
|
|
Once you create a window, you usually add children Fl_Widget's to it
|
|
|
|
by using window->add(child) for each new widget.
|
2009-12-24 14:40:26 +03:00
|
|
|
See Fl_Group for more information on how to add and remove children.
|
|
|
|
|
|
|
|
There are several subclasses of Fl_Window that provide
|
|
|
|
double-buffering, overlay, menu, and OpenGL support.
|
|
|
|
|
|
|
|
The window's callback is done if the user tries to close a window
|
|
|
|
using the window manager and Fl::modal() is zero or equal to the
|
|
|
|
window. Fl_Window has a default callback that calls Fl_Window::hide().
|
2023-01-05 15:51:30 +03:00
|
|
|
Callback reasons can be \p FL_REASON_CANCELLED if the Escape key was pressed,
|
|
|
|
or \p FL_REASON_CLOSED when the close button is clicked. \p FL_WHEN_...
|
|
|
|
flags are ignored.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-15 01:25:39 +04:00
|
|
|
class FL_EXPORT Fl_Window : public Fl_Group {
|
2017-12-29 10:45:27 +03:00
|
|
|
friend class Fl_X;
|
|
|
|
friend class Fl_Window_Driver;
|
2017-12-29 10:25:50 +03:00
|
|
|
private:
|
2010-11-17 01:17:40 +03:00
|
|
|
static char *default_xclass_;
|
2023-11-17 18:55:37 +03:00
|
|
|
static char show_next_window_iconic_; // 1 means create next window in iconic form
|
2016-02-09 04:48:08 +03:00
|
|
|
|
2012-04-05 19:04:43 +04:00
|
|
|
int no_fullscreen_x;
|
|
|
|
int no_fullscreen_y;
|
|
|
|
int no_fullscreen_w;
|
|
|
|
int no_fullscreen_h;
|
2014-06-11 13:10:53 +04:00
|
|
|
int fullscreen_screen_top;
|
|
|
|
int fullscreen_screen_bottom;
|
|
|
|
int fullscreen_screen_left;
|
|
|
|
int fullscreen_screen_right;
|
2010-11-17 01:17:40 +03:00
|
|
|
|
2018-03-10 03:46:12 +03:00
|
|
|
// TODO: it would make sense to merge the use of Fl_X and Fl_Window_Driver, maybe simply by
|
2020-07-12 19:06:03 +03:00
|
|
|
// TODO: deriving Fl_Window_Driver from Fl_X. However, there are a lot of historic kludges
|
|
|
|
// TODO: for some platforms around Fl_X.
|
2023-01-13 23:16:17 +03:00
|
|
|
Fl_X *flx_; // points at the system-specific stuff, but exists only after the window is mapped
|
2016-04-09 13:42:17 +03:00
|
|
|
Fl_Window_Driver *pWindowDriver; // points at the system-specific stuff at window creation time
|
1998-10-06 23:14:55 +04:00
|
|
|
|
|
|
|
const char* iconlabel_;
|
2010-11-17 01:17:40 +03:00
|
|
|
char* xclass_;
|
2022-02-23 01:28:04 +03:00
|
|
|
|
|
|
|
// private size_range stuff:
|
|
|
|
int minw_, minh_, maxw_, maxh_;
|
|
|
|
int dw_, dh_, aspect_;
|
|
|
|
uchar size_range_set_; // true (1) if size_range() has been set or calculated
|
|
|
|
|
2002-08-01 06:15:43 +04:00
|
|
|
// cursor stuff
|
|
|
|
Fl_Cursor cursor_default;
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2002-08-14 20:19:48 +04:00
|
|
|
void _Fl_Window(); // constructor innards
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2005-07-15 13:34:53 +04:00
|
|
|
// unimplemented copy ctor and assignment operator
|
|
|
|
Fl_Window(const Fl_Window&);
|
|
|
|
Fl_Window& operator=(const Fl_Window&);
|
|
|
|
|
2023-11-04 13:30:45 +03:00
|
|
|
void is_maximized_(bool b);
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
protected:
|
|
|
|
|
2009-12-24 14:40:26 +03:00
|
|
|
/** Stores the last window that was made current. See current() const */
|
2002-08-14 20:19:48 +04:00
|
|
|
static Fl_Window *current_;
|
2022-12-30 21:14:36 +03:00
|
|
|
void draw() FL_OVERRIDE;
|
2024-10-30 16:27:40 +03:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/** Forces the window to be drawn, this window is also made current and calls draw(). */
|
2002-08-14 20:19:48 +04:00
|
|
|
virtual void flush();
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2024-10-30 16:27:40 +03:00
|
|
|
protected:
|
|
|
|
|
2009-12-24 14:40:26 +03:00
|
|
|
/**
|
|
|
|
Sets an internal flag that tells FLTK and the window manager to
|
|
|
|
honor position requests.
|
|
|
|
|
|
|
|
This is used internally and should not be needed by user code.
|
|
|
|
|
|
|
|
\param[in] force 1 to set the FORCE_POSITION flag, 0 to clear it
|
|
|
|
*/
|
|
|
|
void force_position(int force) {
|
|
|
|
if (force) set_flag(FORCE_POSITION);
|
|
|
|
else clear_flag(FORCE_POSITION);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
Returns the internal state of the window's FORCE_POSITION flag.
|
|
|
|
|
|
|
|
\retval 1 if flag is set
|
|
|
|
\retval 0 otherwise
|
|
|
|
|
|
|
|
\see force_position(int)
|
|
|
|
*/
|
|
|
|
int force_position() const { return ((flags() & FORCE_POSITION)?1:0); }
|
|
|
|
|
2014-06-16 15:39:32 +04:00
|
|
|
void free_icons();
|
|
|
|
|
2022-02-23 01:28:04 +03:00
|
|
|
void default_size_range(); // calculate size_range() if not set explicitly
|
|
|
|
int is_resizable(); // calculate size_range() and return whether this is resizable
|
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
public:
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2020-07-12 19:06:03 +03:00
|
|
|
Creates a window from the given width \p w, height \p h, and \p title.
|
2020-07-01 19:03:10 +03:00
|
|
|
If Fl_Group::current() is not NULL, the window is created as a
|
2009-12-24 14:40:26 +03:00
|
|
|
subwindow of the parent window.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2020-07-12 19:06:03 +03:00
|
|
|
The (w, h) form of the constructor creates a top-level window
|
|
|
|
and asks the window manager to position the window. The (x, y, w, h)
|
2008-09-14 02:33:03 +04:00
|
|
|
form of the constructor either creates a subwindow or a
|
2020-07-12 19:06:03 +03:00
|
|
|
top-level window at the specified location (x, y), subject to window
|
2008-09-14 02:33:03 +04:00
|
|
|
manager configuration. If you do not specify the position of the
|
|
|
|
window, the window manager will pick a place to show the window
|
2020-07-12 19:06:03 +03:00
|
|
|
or allow the user to pick a location. Use position(x, y)
|
2008-09-14 02:33:03 +04:00
|
|
|
or hotspot() before calling show() to request a
|
2020-07-01 19:03:10 +03:00
|
|
|
position on the screen. See Fl_Window::resize()
|
2009-12-24 14:40:26 +03:00
|
|
|
for some more details on positioning windows.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2009-12-24 14:40:26 +03:00
|
|
|
Top-level windows initially have visible() set to 0
|
2008-09-14 02:33:03 +04:00
|
|
|
and parent() set to NULL. Subwindows initially
|
|
|
|
have visible() set to 1 and parent() set to
|
2009-12-24 14:40:26 +03:00
|
|
|
the parent window pointer.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2009-12-24 14:40:26 +03:00
|
|
|
Fl_Widget::box() defaults to FL_FLAT_BOX. If you plan to
|
|
|
|
completely fill the window with children widgets you should
|
2008-09-14 02:33:03 +04:00
|
|
|
change this to FL_NO_BOX. If you turn the window border off
|
|
|
|
you may want to change this to FL_UP_BOX.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2020-07-12 19:06:03 +03:00
|
|
|
\see Fl_Window(int x, int y, int w, int h, const char *title)
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2020-07-12 19:06:03 +03:00
|
|
|
Fl_Window(int w, int h, const char *title = 0);
|
|
|
|
/** Creates a window from the given position (x, y), size (w, h) and title.
|
2023-10-13 20:08:30 +03:00
|
|
|
|
2023-07-13 19:22:59 +03:00
|
|
|
On a multi-screen system, the values computed by
|
|
|
|
Fl::screen_xywh(int &X, int &Y, int &W, int &H, int n) can be used to
|
2023-07-14 19:10:09 +03:00
|
|
|
discover the coordinates of the area of screen \#n.
|
2023-07-13 19:22:59 +03:00
|
|
|
When these screens have various scale factor
|
2023-07-14 19:00:34 +03:00
|
|
|
values, an \p (x, y) pair may not be enough to specify the targeted screen
|
2023-07-13 19:22:59 +03:00
|
|
|
for the window, because the same \p (x,y) pair can belong to several screens.
|
|
|
|
In that situation, a call to Fl_Window::screen_num(int) is to be used to identify
|
2023-07-14 19:00:34 +03:00
|
|
|
unambiguously the targeted screen.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2011-01-30 11:55:46 +03:00
|
|
|
\see Fl_Window(int w, int h, const char *title)
|
2023-07-13 19:22:59 +03:00
|
|
|
\see Fl::screen_xywh(int &X, int &Y, int &W, int &H, int n)
|
2023-10-13 20:08:30 +03:00
|
|
|
|
2023-07-13 19:22:59 +03:00
|
|
|
\note Under Wayland, it's generally not possible for the client app to control
|
2024-06-03 16:05:04 +03:00
|
|
|
the position of a window in the system. It's possible to specify on what screen
|
|
|
|
should the compositor place a fullscreen window. It's also possible to make an
|
|
|
|
Fl_Window the child of another window or group and control with \p x and \p y
|
|
|
|
its screen position relatively to the enclosing window. Apply member function
|
|
|
|
Fl_Window::allow_expand_outside_parent() to the child window to allow it
|
|
|
|
to expand partially or totally outside its parent.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2020-07-12 19:06:03 +03:00
|
|
|
Fl_Window(int x, int y, int w, int h, const char *title = 0);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
The destructor <I>also deletes all the children</I>. This allows a
|
|
|
|
whole tree to be deleted at once, without having to keep a pointer to
|
2020-07-01 19:03:10 +03:00
|
|
|
all the children in the user code. A kludge has been done so the
|
2009-12-24 14:40:26 +03:00
|
|
|
Fl_Window and all of its children can be automatic (local)
|
2008-09-14 02:33:03 +04:00
|
|
|
variables, but you must declare the Fl_Window <I>first</I> so
|
|
|
|
that it is destroyed last.
|
|
|
|
*/
|
|
|
|
virtual ~Fl_Window();
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2022-12-30 21:14:36 +03:00
|
|
|
int handle(int) FL_OVERRIDE;
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-12-24 14:40:26 +03:00
|
|
|
Changes the size and position of the window. If shown() is true,
|
|
|
|
these changes are communicated to the window server (which may
|
2008-09-14 02:33:03 +04:00
|
|
|
refuse that size and cause a further resize). If shown() is
|
|
|
|
false, the size and position are used when show() is called.
|
2009-12-24 14:40:26 +03:00
|
|
|
See Fl_Group for the effect of resizing on the child widgets.
|
|
|
|
|
|
|
|
You can also call the Fl_Widget methods size(x,y) and position(w,h),
|
|
|
|
which are inline wrappers for this virtual function.
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
A top-level window can not force, but merely suggest a position and
|
|
|
|
size to the operating system. The window manager may not be willing or
|
|
|
|
able to display a window at the desired position or with the given
|
|
|
|
dimensions. It is up to the application developer to verify window
|
2008-09-14 02:33:03 +04:00
|
|
|
parameters after the resize request.
|
|
|
|
*/
|
2022-12-30 21:14:36 +03:00
|
|
|
void resize(int X,int Y,int W,int H) FL_OVERRIDE;
|
2019-05-09 11:49:03 +03:00
|
|
|
/** Sets whether or not the window manager border is around the window.
|
|
|
|
The default value is true. <I>With some X window
|
|
|
|
managers, this does not work after show() has been called.</I>
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-15 01:25:39 +04:00
|
|
|
void border(int b);
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-12-24 14:40:26 +03:00
|
|
|
Fast inline function to turn the window manager border
|
2008-09-14 02:33:03 +04:00
|
|
|
off. It only works before show() is called.
|
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void clear_border() {set_flag(NOBORDER);}
|
2019-05-09 11:49:03 +03:00
|
|
|
/** Returns whether the window possesses a border */
|
2020-07-01 19:03:10 +03:00
|
|
|
unsigned int border() const {return !(flags() & NOBORDER);}
|
2022-12-30 21:14:36 +03:00
|
|
|
/** Activates the flags NOBORDER|OVERRIDE */
|
2020-07-01 19:03:10 +03:00
|
|
|
void set_override() {set_flag(NOBORDER|OVERRIDE);}
|
2022-12-30 21:14:36 +03:00
|
|
|
/** Returns non zero if OVERRIDE flag is set, 0 otherwise. */
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int override() const { return flags()&OVERRIDE; }
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-09-17 19:44:43 +04:00
|
|
|
A "modal" window, when shown(), will prevent any events from
|
2008-09-14 02:33:03 +04:00
|
|
|
being delivered to other windows in the same program, and will also
|
|
|
|
remain on top of the other windows (if the X window manager supports
|
2008-09-17 19:44:43 +04:00
|
|
|
the "transient for" property). Several modal windows may be shown at
|
2009-08-03 10:26:32 +04:00
|
|
|
once, in which case only the last one shown gets events. You can see
|
2009-12-24 14:40:26 +03:00
|
|
|
which window (if any) is modal by calling Fl::modal().
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void set_modal() {set_flag(MODAL);}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Returns true if this window is modal. */
|
2020-07-01 19:03:10 +03:00
|
|
|
unsigned int modal() const {return flags() & MODAL;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2008-09-17 19:44:43 +04:00
|
|
|
A "non-modal" window (terminology borrowed from Microsoft Windows)
|
2008-09-14 02:33:03 +04:00
|
|
|
acts like a modal() one in that it remains on top, but it has
|
|
|
|
no effect on event delivery. There are <I>three</I> states for a
|
|
|
|
window: modal, non-modal, and normal.
|
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void set_non_modal() {set_flag(NON_MODAL);}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Returns true if this window is modal or non-modal. */
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int non_modal() const {return flags() & (NON_MODAL|MODAL);}
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2014-10-29 17:21:08 +03:00
|
|
|
/**
|
|
|
|
Clears the "modal" flags and converts a "modal" or "non-modal"
|
|
|
|
window back into a "normal" window.
|
|
|
|
|
|
|
|
Note that there are <I>three</I> states for a window: modal,
|
|
|
|
non-modal, and normal.
|
|
|
|
|
|
|
|
You can not change the "modality" of a window whilst
|
|
|
|
it is shown, so it is necessary to first hide() the window,
|
|
|
|
change its "modality" as required, then re-show the window
|
|
|
|
for the new state to take effect.
|
|
|
|
|
|
|
|
This method can also be used to change a "modal" window into a
|
|
|
|
"non-modal" one. On several supported platforms, the "modal" state
|
|
|
|
over-rides the "non-modal" state, so the "modal" state must be
|
|
|
|
cleared before the window can be set into the "non-modal"
|
|
|
|
state.
|
|
|
|
In general, the following sequence should work:
|
|
|
|
|
|
|
|
\code
|
|
|
|
win->hide();
|
|
|
|
win->clear_modal_states();
|
2020-07-12 19:06:03 +03:00
|
|
|
// Set win to new state as desired, or leave "normal", e.g...
|
2014-10-29 17:21:08 +03:00
|
|
|
win->set_non_modal();
|
|
|
|
win->show();
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
\note Under some window managers, the sequence of hiding the
|
|
|
|
window and changing its modality will often cause it to be
|
|
|
|
re-displayed at a different position when it is subsequently
|
|
|
|
shown. This is an irritating feature but appears to be
|
|
|
|
unavoidable at present.
|
|
|
|
As a result we would advise to use this method only when
|
|
|
|
absolutely necessary.
|
|
|
|
|
|
|
|
\see void set_modal(), void set_non_modal()
|
|
|
|
*/
|
|
|
|
void clear_modal_states() {clear_flag(NON_MODAL | MODAL);}
|
|
|
|
|
2009-08-03 10:26:32 +04:00
|
|
|
/**
|
|
|
|
Marks the window as a menu window.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2009-08-03 10:26:32 +04:00
|
|
|
This is intended for internal use, but it can also be used if you
|
|
|
|
write your own menu handling. However, this is not recommended.
|
|
|
|
|
|
|
|
This flag is used for correct "parenting" of windows in communication
|
|
|
|
with the windowing system. Modern X window managers can use different
|
|
|
|
flags to distinguish menu and tooltip windows from normal windows.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2009-08-03 10:26:32 +04:00
|
|
|
This must be called before the window is shown and cannot be changed
|
|
|
|
later.
|
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void set_menu_window() {set_flag(MENU_WINDOW);}
|
2009-08-03 10:26:32 +04:00
|
|
|
|
|
|
|
/** Returns true if this window is a menu window. */
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int menu_window() const {return flags() & MENU_WINDOW;}
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2009-08-03 10:26:32 +04:00
|
|
|
/**
|
|
|
|
Marks the window as a tooltip window.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2009-08-03 10:26:32 +04:00
|
|
|
This is intended for internal use, but it can also be used if you
|
|
|
|
write your own tooltip handling. However, this is not recommended.
|
|
|
|
|
|
|
|
This flag is used for correct "parenting" of windows in communication
|
|
|
|
with the windowing system. Modern X window managers can use different
|
|
|
|
flags to distinguish menu and tooltip windows from normal windows.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2009-08-03 10:26:32 +04:00
|
|
|
This must be called before the window is shown and cannot be changed
|
|
|
|
later.
|
|
|
|
|
|
|
|
\note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this
|
|
|
|
also \b clears the menu_window() state.
|
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void set_tooltip_window() { set_flag(TOOLTIP_WINDOW);
|
|
|
|
clear_flag(MENU_WINDOW); }
|
2009-08-03 10:26:32 +04:00
|
|
|
/** Returns true if this window is a tooltip window. */
|
2009-09-28 18:34:52 +04:00
|
|
|
unsigned int tooltip_window() const {return flags() & TOOLTIP_WINDOW;}
|
2009-08-03 10:26:32 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-12-24 14:40:26 +03:00
|
|
|
Positions the window so that the mouse is pointing at the given
|
|
|
|
position, or at the center of the given widget, which may be the
|
2008-09-14 02:33:03 +04:00
|
|
|
window itself. If the optional offscreen parameter is
|
|
|
|
non-zero, then the window is allowed to extend off the screen (this
|
|
|
|
does not work with some X window managers). \see position()
|
|
|
|
*/
|
2002-07-15 01:25:39 +04:00
|
|
|
void hotspot(int x, int y, int offscreen = 0);
|
2008-09-18 23:09:34 +04:00
|
|
|
/** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */
|
2002-07-15 01:25:39 +04:00
|
|
|
void hotspot(const Fl_Widget*, int offscreen = 0);
|
2008-09-18 23:09:34 +04:00
|
|
|
/** See void Fl_Window::hotspot(int x, int y, int offscreen = 0) */
|
1998-10-06 23:14:55 +04:00
|
|
|
void hotspot(const Fl_Widget& p, int offscreen = 0) {hotspot(&p,offscreen);}
|
2009-12-24 14:40:26 +03:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-12-24 14:40:26 +03:00
|
|
|
Undoes the effect of a previous resize() or show() so that the next time
|
|
|
|
show() is called the window manager is free to position the window.
|
|
|
|
|
|
|
|
This is for Forms compatibility only.
|
|
|
|
|
|
|
|
\deprecated please use force_position(0) instead
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2020-07-01 19:03:10 +03:00
|
|
|
void free_position() {clear_flag(FORCE_POSITION);}
|
2022-02-23 01:28:04 +03:00
|
|
|
|
2016-03-23 20:13:09 +03:00
|
|
|
void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0);
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2024-05-26 18:50:40 +03:00
|
|
|
uchar get_size_range(int *minw, int *minh, int *maxw=NULL, int *maxh=NULL, int *dw=NULL, int *dh=NULL, int *aspect=NULL);
|
|
|
|
|
2008-09-18 23:09:34 +04:00
|
|
|
/** See void Fl_Window::label(const char*) */
|
2020-07-01 19:03:10 +03:00
|
|
|
const char* label() const {return Fl_Widget::label();}
|
2008-09-18 23:09:34 +04:00
|
|
|
/** See void Fl_Window::iconlabel(const char*) */
|
2020-07-01 19:03:10 +03:00
|
|
|
const char* iconlabel() const {return iconlabel_;}
|
2009-12-24 14:40:26 +03:00
|
|
|
/** Sets the window title bar label. */
|
2002-07-15 01:25:39 +04:00
|
|
|
void label(const char*);
|
2008-09-18 23:09:34 +04:00
|
|
|
/** Sets the icon label. */
|
2002-07-15 01:25:39 +04:00
|
|
|
void iconlabel(const char*);
|
2009-12-24 14:40:26 +03:00
|
|
|
/** Sets the icon label. */
|
2011-02-25 11:44:47 +03:00
|
|
|
void label(const char* label, const char* iconlabel); // platform dependent
|
2005-04-09 17:51:32 +04:00
|
|
|
void copy_label(const char* a);
|
2010-11-17 01:17:40 +03:00
|
|
|
|
|
|
|
static void default_xclass(const char*);
|
|
|
|
static const char *default_xclass();
|
|
|
|
const char* xclass() const;
|
|
|
|
void xclass(const char* c);
|
2014-06-16 15:39:32 +04:00
|
|
|
|
|
|
|
static void default_icon(const Fl_RGB_Image*);
|
|
|
|
static void default_icons(const Fl_RGB_Image*[], int);
|
|
|
|
void icon(const Fl_RGB_Image*);
|
|
|
|
void icons(const Fl_RGB_Image*[], int);
|
|
|
|
|
2022-10-06 14:15:16 +03:00
|
|
|
#if defined(_WIN32) || defined(FL_DOXYGEN)
|
2016-03-22 16:27:22 +03:00
|
|
|
typedef struct HICON__* HICON;
|
|
|
|
// These 2 member functions break the driver model but are kept for back compatibility.
|
2016-04-16 15:28:50 +03:00
|
|
|
// They are implemented in Fl_win32.cxx
|
2022-11-01 22:06:22 +03:00
|
|
|
|
2022-10-06 14:15:16 +03:00
|
|
|
/** Sets the default window icons (Windows platform only).
|
|
|
|
|
|
|
|
Convenience function to set the default icons using Windows'
|
|
|
|
native HICON icon handles.
|
|
|
|
|
|
|
|
The given icons are copied. You can free the icons immediately after
|
|
|
|
this call.
|
|
|
|
|
|
|
|
\param[in] big_icon default large icon for all windows
|
|
|
|
subsequently created
|
|
|
|
\param[in] small_icon default small icon for all windows
|
|
|
|
subsequently created
|
|
|
|
|
|
|
|
\see Fl_Window::default_icon(const Fl_RGB_Image *)
|
|
|
|
\see Fl_Window::default_icons(const Fl_RGB_Image *[], int)
|
|
|
|
\see Fl_Window::icon(const Fl_RGB_Image *)
|
|
|
|
\see Fl_Window::icons(const Fl_RGB_Image *[], int)
|
|
|
|
\see Fl_Window::icons(HICON, HICON)
|
|
|
|
*/
|
2014-06-16 15:39:32 +04:00
|
|
|
static void default_icons(HICON big_icon, HICON small_icon);
|
2022-11-01 22:06:22 +03:00
|
|
|
|
2022-10-06 14:15:16 +03:00
|
|
|
/** Sets the window icons using HICON handles (Windows platform only).
|
|
|
|
|
|
|
|
The given icons are copied. You can free the icons immediately after
|
|
|
|
this call.
|
|
|
|
|
|
|
|
\param[in] big_icon large window icon
|
|
|
|
\param[in] small_icon small window icon
|
|
|
|
*/
|
2014-06-16 15:39:32 +04:00
|
|
|
void icons(HICON big_icon, HICON small_icon);
|
2022-10-06 14:15:16 +03:00
|
|
|
#endif // defined(_WIN32) || defined(FL_DOXYGEN)
|
2014-06-16 15:39:32 +04:00
|
|
|
|
|
|
|
/* for legacy compatibility */
|
2011-02-25 11:44:47 +03:00
|
|
|
const void* icon() const;
|
|
|
|
void icon(const void * ic);
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Returns non-zero if show() has been called (but not hide()
|
2009-12-24 14:40:26 +03:00
|
|
|
). You can tell if a window is iconified with (w->shown()
|
|
|
|
&& !w->visible()).
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2023-01-13 23:16:17 +03:00
|
|
|
int shown() {return flx_ != 0;}
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2023-02-05 11:37:48 +03:00
|
|
|
Puts the window on the screen. This has the side
|
|
|
|
effect of opening the display, if not done before.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
|
|
|
If the window is already shown then it is restored and raised to the
|
2008-09-14 02:33:03 +04:00
|
|
|
top. This is really convenient because your program can call show()
|
2011-02-25 11:44:47 +03:00
|
|
|
at any time, even if the window is already up. It also means that
|
2008-09-14 02:33:03 +04:00
|
|
|
show() serves the purpose of raise() in other toolkits.
|
2015-07-27 21:13:46 +03:00
|
|
|
|
2010-11-17 14:03:51 +03:00
|
|
|
Fl_Window::show(int argc, char **argv) is used for top-level
|
|
|
|
windows and allows standard arguments to be parsed from the
|
|
|
|
command-line.
|
2015-07-27 21:13:46 +03:00
|
|
|
|
|
|
|
\note For some obscure reasons Fl_Window::show() resets the current
|
|
|
|
group by calling Fl_Group::current(0). The comments in the code
|
|
|
|
say "get rid of very common user bug: forgot end()". Although
|
|
|
|
this is true it may have unwanted side effects if you show() an
|
|
|
|
unrelated window (maybe for an error message or warning) while
|
|
|
|
building a window or any other group widget.
|
|
|
|
|
|
|
|
\todo Check if we can remove resetting the current group in a later
|
|
|
|
FLTK version (after 1.3.x). This may break "already broken" programs
|
|
|
|
though if they rely on this "feature".
|
|
|
|
|
2010-11-17 14:03:51 +03:00
|
|
|
\see Fl_Window::show(int argc, char **argv)
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2022-12-30 21:14:36 +03:00
|
|
|
void show() FL_OVERRIDE;
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-12-24 14:40:26 +03:00
|
|
|
Removes the window from the screen. If the window is already hidden or
|
2008-09-14 02:33:03 +04:00
|
|
|
has not been shown then this does nothing and is harmless.
|
|
|
|
*/
|
2022-12-30 21:14:36 +03:00
|
|
|
void hide() FL_OVERRIDE;
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2023-02-05 11:37:48 +03:00
|
|
|
Puts the window on the screen with show() and parses command-line arguments.
|
2010-11-17 14:03:51 +03:00
|
|
|
|
2023-02-05 11:37:48 +03:00
|
|
|
This call should be used for top-level windows, at least for the
|
|
|
|
first (main) window. It allows standard arguments to be parsed, as done by Fl::args(int, char **),
|
2010-11-17 14:03:51 +03:00
|
|
|
from the command-line. You can use \p argc and \p argv from
|
|
|
|
main(int argc, char **argv) for this call.
|
|
|
|
|
2023-02-05 11:37:48 +03:00
|
|
|
This call also sets up some system-specific internal variables, that is,
|
|
|
|
it sets FL_SELECTION_COLOR and calls Fl::background(), Fl::background2(), Fl::foreground()
|
|
|
|
with default or X resources-given values, and calls Fl::scheme(const char *) for the current scheme.
|
|
|
|
On X11, it also calls Fl::dnd_text_ops(int), Fl_Tooltip::enable(int),
|
|
|
|
Fl::visible_focus(int) with X resources-given values.
|
2010-11-17 14:03:51 +03:00
|
|
|
|
|
|
|
\param argc command-line argument count, usually from main()
|
|
|
|
\param argv command-line argument vector, usually from main()
|
|
|
|
|
|
|
|
\see virtual void Fl_Window::show()
|
2023-02-05 11:37:48 +03:00
|
|
|
\see Fl::args(int, char **)
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2010-11-17 14:03:51 +03:00
|
|
|
void show(int argc, char **argv);
|
2014-09-27 03:58:05 +04:00
|
|
|
|
|
|
|
// Enables synchronous show(), docs in Fl_Window.cxx
|
|
|
|
void wait_for_expose();
|
|
|
|
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2014-06-11 13:10:53 +04:00
|
|
|
Makes the window completely fill one or more screens, without any
|
|
|
|
window manager border visible. You must use fullscreen_off() to
|
2020-07-01 19:03:10 +03:00
|
|
|
undo this.
|
2012-03-23 20:47:53 +04:00
|
|
|
|
|
|
|
\note On some platforms, this can result in the keyboard being
|
|
|
|
grabbed. The window may also be recreated, meaning hide() and
|
|
|
|
show() will be called.
|
2014-06-11 13:10:53 +04:00
|
|
|
|
|
|
|
\see void Fl_Window::fullscreen_screens()
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-15 01:25:39 +04:00
|
|
|
void fullscreen();
|
2012-03-23 20:47:53 +04:00
|
|
|
/**
|
|
|
|
Turns off any side effects of fullscreen()
|
|
|
|
*/
|
|
|
|
void fullscreen_off();
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2020-07-01 19:03:10 +03:00
|
|
|
Turns off any side effects of fullscreen() and does
|
2008-09-14 02:33:03 +04:00
|
|
|
resize(x,y,w,h).
|
|
|
|
*/
|
2012-07-26 04:40:37 +04:00
|
|
|
void fullscreen_off(int X,int Y,int W,int H);
|
2012-03-23 20:47:53 +04:00
|
|
|
/**
|
2020-07-01 19:03:10 +03:00
|
|
|
Returns non zero if FULLSCREEN flag is set, 0 otherwise.
|
2012-03-23 20:47:53 +04:00
|
|
|
*/
|
|
|
|
unsigned int fullscreen_active() const { return flags() & FULLSCREEN; }
|
2014-06-11 13:10:53 +04:00
|
|
|
/**
|
|
|
|
Sets which screens should be used when this window is in fullscreen
|
|
|
|
mode. The window will be resized to the top of the screen with index
|
2020-07-01 19:03:10 +03:00
|
|
|
\p top, the bottom of the screen with index \p bottom, etc.
|
2014-06-11 13:10:53 +04:00
|
|
|
|
|
|
|
If this method is never called, or if any argument is < 0, then the
|
|
|
|
window will be resized to fill the screen it is currently on.
|
|
|
|
|
|
|
|
\see void Fl_Window::fullscreen()
|
|
|
|
*/
|
|
|
|
void fullscreen_screens(int top, int bottom, int left, int right);
|
2023-11-14 20:14:48 +03:00
|
|
|
|
2023-11-04 13:30:45 +03:00
|
|
|
void maximize();
|
|
|
|
void un_maximize();
|
|
|
|
/** Returns whether the window is currently maximized */
|
|
|
|
unsigned int maximize_active() const { return flags() & MAXIMIZED; }
|
|
|
|
public:
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
|
|
|
Iconifies the window. If you call this when shown() is false
|
|
|
|
it will show() it as an icon. If the window is already
|
|
|
|
iconified this does nothing.
|
2009-12-24 14:40:26 +03:00
|
|
|
|
|
|
|
Call show() to restore the window.
|
|
|
|
|
|
|
|
When a window is iconified/restored (either by these calls or by the
|
2020-07-01 19:03:10 +03:00
|
|
|
user) the handle() method is called with FL_HIDE and
|
2009-12-24 14:40:26 +03:00
|
|
|
FL_SHOW events and visible() is turned on and off.
|
|
|
|
|
|
|
|
There is no way to control what is drawn in the icon except with the
|
2008-09-14 02:33:03 +04:00
|
|
|
string passed to Fl_Window::xclass(). You should not rely on
|
|
|
|
window managers displaying the icons.
|
|
|
|
*/
|
2002-07-15 01:25:39 +04:00
|
|
|
void iconize();
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2002-07-15 01:25:39 +04:00
|
|
|
int x_root() const ;
|
|
|
|
int y_root() const ;
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2008-09-18 23:09:34 +04:00
|
|
|
static Fl_Window *current();
|
2008-09-14 02:33:03 +04:00
|
|
|
/**
|
2009-12-24 14:40:26 +03:00
|
|
|
Sets things up so that the drawing functions in <FL/fl_draw.H> will go
|
|
|
|
into this window. This is useful for incremental update of windows, such
|
|
|
|
as in an idle callback, which will make your program behave much better
|
|
|
|
if it draws a slow graphic. <B>Danger: incremental update is very hard to
|
2008-09-14 02:33:03 +04:00
|
|
|
debug and maintain!</B>
|
2009-12-24 14:40:26 +03:00
|
|
|
|
|
|
|
This method only works for the Fl_Window and Fl_Gl_Window derived classes.
|
2008-09-14 02:33:03 +04:00
|
|
|
*/
|
2002-07-15 01:25:39 +04:00
|
|
|
void make_current();
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2014-06-16 15:17:57 +04:00
|
|
|
void cursor(Fl_Cursor);
|
|
|
|
void cursor(const Fl_RGB_Image*, int, int);
|
|
|
|
void default_cursor(Fl_Cursor);
|
|
|
|
|
|
|
|
/* for legacy compatibility */
|
|
|
|
void cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
|
|
|
|
void default_cursor(Fl_Cursor c, Fl_Color, Fl_Color=FL_WHITE);
|
|
|
|
|
2002-07-15 01:25:39 +04:00
|
|
|
static void default_callback(Fl_Window*, void* v);
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2011-04-16 01:38:05 +04:00
|
|
|
/** Returns the window width including any frame added by the window manager.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2020-09-09 19:00:24 +03:00
|
|
|
Same as w() if applied to a subwindow, or if window is not yet mapped.
|
2022-02-08 10:03:35 +03:00
|
|
|
\see decorated_h().
|
2011-04-16 01:38:05 +04:00
|
|
|
*/
|
2017-06-16 12:29:54 +03:00
|
|
|
int decorated_w() const;
|
|
|
|
|
2020-07-01 19:03:10 +03:00
|
|
|
/** Returns the window height including any window title bar and any frame
|
2011-04-16 01:38:05 +04:00
|
|
|
added by the window manager.
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2020-09-09 19:00:24 +03:00
|
|
|
Same as h() if applied to a subwindow, or if window is not yet mapped.
|
2022-02-08 10:03:35 +03:00
|
|
|
\note Under X11, FLTK is able to compute the size of window titlebars and borders
|
|
|
|
only if these decoration elements are strictly X11-based. When that's not the case,
|
|
|
|
decorated_h() returns the same value as h() and decorated_w() as w(), and FLTK
|
|
|
|
cannot access window decorations.
|
2022-03-03 19:20:24 +03:00
|
|
|
|
2022-02-08 10:03:35 +03:00
|
|
|
\note Under X11 again, the values returned by decorated_h() and decorated_w()
|
|
|
|
may not be reliable <b> during a resize operation</b>. The size of decoration elements
|
|
|
|
of a window is best computed when the window is first mapped.
|
2011-04-16 01:38:05 +04:00
|
|
|
*/
|
2017-06-16 12:29:54 +03:00
|
|
|
int decorated_h() const;
|
1998-10-06 23:14:55 +04:00
|
|
|
|
2016-03-13 18:31:26 +03:00
|
|
|
// Note: Doxygen docs in Fl_Widget.H to avoid redundancy.
|
2022-12-30 21:14:36 +03:00
|
|
|
Fl_Window* as_window() FL_OVERRIDE { return this; }
|
2023-03-18 19:33:27 +03:00
|
|
|
Fl_Window const* as_window() const FL_OVERRIDE { return this; }
|
2016-03-13 18:31:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Return non-null if this is an Fl_Overlay_Window object.
|
|
|
|
*/
|
|
|
|
virtual class Fl_Overlay_Window *as_overlay_window() {return 0L; }
|
|
|
|
|
2016-03-07 01:22:22 +03:00
|
|
|
/**
|
2016-03-10 20:19:34 +03:00
|
|
|
Return non-null if this is an Fl_Double_Window object.
|
2016-03-07 01:22:22 +03:00
|
|
|
*/
|
2016-03-13 18:31:26 +03:00
|
|
|
virtual class Fl_Double_Window *as_double_window() {return 0L;}
|
2020-07-01 19:03:10 +03:00
|
|
|
|
2016-03-10 20:19:34 +03:00
|
|
|
void shape(const Fl_Image* img);
|
2023-09-28 17:21:31 +03:00
|
|
|
void shape(const Fl_Image& b);
|
2019-02-23 12:21:27 +03:00
|
|
|
const Fl_Image *shape();
|
2023-09-28 17:21:31 +03:00
|
|
|
void draw_backdrop();
|
2018-05-22 20:00:27 +03:00
|
|
|
int screen_num();
|
2020-08-14 17:44:05 +03:00
|
|
|
void screen_num(int screen_num);
|
2020-05-08 18:08:20 +03:00
|
|
|
static bool is_a_rescale();
|
2022-03-21 13:41:40 +03:00
|
|
|
fl_uintptr_t os_id();
|
2023-11-17 18:55:37 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets a static flag whether the next window should be opened iconified.
|
|
|
|
|
|
|
|
\note This is an <b>internal function</b>, you should not use this in user code.
|
|
|
|
|
|
|
|
Please use Fl_Window::iconize() instead.
|
|
|
|
*/
|
|
|
|
static void show_next_window_iconic(char stat) {
|
|
|
|
show_next_window_iconic_ = stat ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the static flag whether the next window should be opened iconified.
|
|
|
|
|
|
|
|
\note This is an <b>internal function</b>, you should not use this in user code.
|
|
|
|
|
|
|
|
Please use Fl_Window::iconize() to iconify a window.
|
|
|
|
*/
|
|
|
|
static char show_next_window_iconic() {
|
|
|
|
return show_next_window_iconic_;
|
|
|
|
}
|
2024-06-21 19:10:33 +03:00
|
|
|
|
2024-06-02 09:28:40 +03:00
|
|
|
void allow_expand_outside_parent();
|
2024-06-21 19:10:33 +03:00
|
|
|
|
1998-10-06 23:14:55 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|