Fl_Group | +----Fl_Window | +----Fl_Double_Window, Fl_Gl_Window, Fl_Overlay_Window, Fl_Single_Window
#include <FL/Fl_Window.H>
Once you create a window, you usually add children Fl_Widget's to it by using window->add(child) for each new widget. 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() and calls exit(0) if this is the last top-level window.
Fl_Widget::box() is set to FL_FLAT_BOX. If you plan to completely fill the window with children widgets you should change this to FL_NO_BOX. If you turn the window border off you may want to change this to FL_UP_BOX.
The second form of the constructor is for creating child windows. It
leaves visible() set to true.
If this function is not called, FLTK tries to figure out the range
from the setting of resizeable():
It is harmless to call show() multiple times. If the window is
already shown then it is deiconized and raised to the top.
virtual Fl_Window::~Fl_Window()
Calls destroy(). The destructor also deletes all the
children. This allows a whole tree to be deleted at once, without
having to keep a pointer to all the children in the user code. A
kludge has been done so the Fl_Window and all of it's
children can be automatic (local) variables, but you must declare the
Fl_Window first so that it is destroyed last.
void Fl_Window::size_range(int minw,
int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)
Set the allowable range the user can resize this window to. This only
works for top-level windows.
It is undefined what happens if the current size does not fit in the
constraints passed to size_range().
void Fl_Window::show()
Put the window on the screen. Usually this has the side effect of
opening the display.
int Fl_Window::show(int argc, char **argv, int i);
This must be called after Fl::args(argc,argv) to show the "main"
window, this indicates which window should be affected by any
-geometry switch. In addition if Fl::args() has not been
called yet this does so, this is a useful shortcut for the main window
in a small program.
On both X and win32 changing this value causes the window to be removed from the screen.
On X this requires the window manager to support "TransisentForHint", not all do, in which case the window will appear normally.
Win32 and some X window managers have an annoying bug where calling show() on this window will also raise the parent window to right below this. This makes this ability far less useful than it could be...
You probably want to use exec(), unless you wish to put up a modal window but retain control of the program loop.
Notice that there is no way to turn off the modal() setting.
The return value is true only if some callback does window->set().
To use this, make an OK button with a callback that does this.
If parent is null the window that last received an event is used as
the parent. This is convenient for popups that appear in response to
a mouse or key click.
Notice that parent() of the window must be zero and it will remain
zero after this is called. Fltk uses a zero parent to indicate that
the system is managing the window.
On systems that don't support nested desktops (i.e. X) this does
show(frame), which produces a normal overlapping window that
is tied to remain atop and iconize with the frame window (IMHO this is
a great improvement over MDI!).
Subclasses can override this, if you do this you must also override
the destructor and make it call destroy().
Call show() to restore the window.
Currently there are only system-specific
ways to control what is drawn in the icon. You should not rely on
window managers displaying the icons.
You can also call the Fl_Widget methods size(x,y)
and position(w,h), which are inline wrappers for this virtual
function.
The special value FL_USEDEFAULT may be used for x and y
indicate that the system should choose the window's position.
On X this causes "override redirect". This is only good for
short-lived windows as it can confuse X window managers, however this
is the only reliable and fast way to do it. This also turns on "save
under" which on many X servers (like XFree86) can make the window
pop-down much faster.
The type Fl_Cursor is an enumeration defined in <Enumerations.H>.
(Under X you can get any XC_cursor value by passing
Fl_Cursor((XC_foo/2)+1)). The colors only work on X, they are
not implemented on WIN32.
bool Fl_Window::exec(const Fl_Window* parent = 0);
Does set_modal(); show(parent); then enters a loop of
handling events until the window is hidden again by the program
(usually by the user closing it, or from a callback from some widget
inside the window, such as an OK button). During this time events to
other windows in this application are either thrown away or redirected
to this window.
bool Fl_Window::show_inside(const Fl_Window* frame);
Make the window with a normal system border and behavior, but place it
inside the frame as though that was the desktop. This is what
Windows calls "MDI". Typically the other window (which must already
be shown) is a child window so that space can remain around it for a
menu/tool bar.
virtual void Fl_Window::hide()
Remove the window from the screen. If the window is already hidden or
has not been shown then this does nothing and is harmless.
virtual void Fl_Window::destroy();
Hides the window and also deletes all window system information about
the window, and thus returns if back to the state it was in before the
first show(). It is harmless to call this if the window is already
destroyed.
int Fl_Window::shown() const
Returns non-zero if show() has been called, but
destroy() has not been called.
int Fl_Window::iconic() const
Returns true if the window is currently displayed as an icon. Returns
false if the window is not shown() or hide() has been called. On X
this will return true for a short time after show() is called the
first time.
void Fl_Window::iconize()
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.
Fl_Window *Fl::first_window()
Returns the first shown() window in the widget hierarchy. If
no windows are displayed first_window returns NULL.
void *Fl::first_window(Fl_Window*)
Change which window is returned by Fl::first_window(). This
window must have shown() true. This is useful for making an exec(0) inside some inner code make the window a child
of the correct window.
Fl_Window *Fl::next_window(const Fl_Window*)
Returns the next shown() window in the hierarchy. You can
use this call to iterate through all the windows that are shown().
void Fl_Window::resize(int,int,int,int)
Change the size and position of the window. If shown() is
true, these changes are communicated to the window server (which may
refuse that size and cause a further resize). If shown() is
false, the size and position are used when show() is called.
See Fl_Group for the effect
of resizing on the child widgets.
void Fl_Window::hotspot(int x, int y, int
offscreen = 0)
position() the window so that the mouse is pointing at the
given position, or at the center of the given widget, which may be the
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).
void Fl_Window::hotspot(const Fl_Widget*, int offscreen = 0)
void Fl_Window::hotspot(const Fl_Widgetp, int offscreen = 0)void Fl_Window::fullscreen()
Makes the window completely fill the screen, without any window
manager border visible. You must use fullscreen_off() to undo
this. This may not work with all X window managers (and currently it
is not successful at hiding the Windows taskbar).
int Fl_Window::fullscreen_off(int x, int y, int w, int h)
Turns off any side effects of fullscreen() and does
resize(x,y,w,h).
void Fl_Window::clear_border()
You may turn off the window manager border before calling show() on
the window the first time. This will also mean the user cannot move,
iconize, or resize the window (unless your program does it). This is
used by the fltk menus and tooltips.
bool Fl_Window::border() const
Returns false if clear_border() has been called.
void Fl_Window::label(const char*)
Gets or sets the window title bar label.
const char* Fl_Window::label() constvoid Fl_Window::iconlabel(const char*)
Gets or sets the icon label.
const char* Fl_Window::iconlabel() constvoid Fl_Window::make_current()
make_current() 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. This call does not work for Fl_Double_Window!.
static Fl_Window* Fl_Window::current()
Returns the last window that was made current.
void Fl_Window::cursor(Fl_Cursor, Fl_Color = FL_WHITE, Fl_Color = FL_BLACK)
Change the cursor for this window. This always calls the system, if
you are changing the cursor a lot you may want to keep track of how
you set it in a static varaible and call this only if the new cursor
is different.