3
<H2><A name=Fl_Window>class Fl_Window</A></H2>
5
<H3>Class Hierarchy</H3>
8
<A href=Fl_Group.html#Fl_Group>Fl_Group</A>
12
+----<A href=Fl_Double_Window.html#Fl_Double_Window>Fl_Double_Window</A>, <A href=Fl_Gl_Window.html#Fl_Gl_Window>Fl_Gl_Window</A>,
13
<A href=Fl_Overlay_Window.html#Fl_Overlay_Window>Fl_Overlay_Window</A>, <A href=Fl_Single_Window.html#Fl_Single_Window>Fl_Single_Window</A>
16
<H3>Include Files</H3>
19
#include <FL/Fl_Window.H>
23
This widget produces an actual window. This can either be a main
24
window, with a border and title and all the window management controls,
25
or a "subwindow" inside a window. This is controlled by whether or not
26
the window has a <TT>parent()</TT>.
27
<P>Once you create a window, you usually add children <TT>Fl_Widget</TT>
28
's to it by using <TT>window->add(child)</TT> for each new widget. See <A
29
href=Fl_Group.html#Fl_Group><TT>Fl_Group</TT></A> for more information
30
on how to add and remove children. </P>
31
<P>There are several subclasses of <TT>Fl_Window</TT> that provide
32
double-buffering, overlay, menu, and OpenGL support. </P>
33
<P>The window's callback is done if the user tries to close a window
34
using the window manager and <A href="Fl.html#Fl.modal"><TT>
35
Fl::modal()</TT></A> is zero or equal to the window. <TT>Fl_Window</TT>
36
has a default callback that calls <TT>Fl_Window::hide()</TT>. </P>
39
<TABLE width=90% summary="Fl_Window methods.">
40
<TR><TD align=left valign=top>
42
<LI><A href=#Fl_Window.Fl_Window>Fl_Window</A></LI>
43
<LI><A href=#Fl_Window.~Fl_Window>~Fl_Window</A></LI>
44
<LI><A href=#Fl_Window.border>border</A></LI>
45
<LI><A href=#Fl_Window.clear_border>clear_border</A></LI>
46
<LI><A href=#Fl_Window.current>current</A></LI>
47
<LI><A href=#Fl_Window.cursor>cursor</A></LI>
49
</TD><TD align=left valign=top>
51
<LI><A href=#Fl_Window.free_position>free_position</A></LI>
52
<LI><A href=#Fl_Window.fullscreen>fullscreen</A></LI>
53
<LI><A href=#Fl_Window.fullscreen_off>fullscreen_off</A></LI>
54
<LI><A href=#Fl_Window.hide>hide</A></LI>
55
<LI><A href=#Fl_Window.hotspot>hotspot</A></LI>
57
</TD><TD align=left valign=top>
59
<LI><A href=#Fl_Window.iconize>iconize</A></LI>
60
<LI><A href=#Fl_Window.iconlabel>iconlabel</A></LI>
61
<LI><A href=#Fl_Window.label>label</A></LI>
62
<LI><A href=#Fl_Window.make_current>make_current</A></LI>
63
<LI><A href=#Fl_Window.modal>modal</A></LI>
65
</TD><TD align=left valign=top>
67
<LI><A href=#Fl_Window.non_modal>non_modal</A></LI>
68
<LI><A href=#Fl_Window.resize>resize</A></LI>
69
<LI><A href=#Fl_Window.set_modal>set_modal</A></LI>
70
<LI><A href=#Fl_Window.set_non_modal>set_non_modal</A></LI>
71
<LI><A href=#Fl_Window.show>show</A></LI>
73
</TD><TD align=left valign=top>
75
<LI><A href=#Fl_Window.shown>shown</A></LI>
76
<LI><A href=#Fl_Window.size_range>size_range</A></LI>
77
<LI><A href=#Fl_Window.xclass>xclass</A></LI>
82
<H4><A name=Fl_Window.Fl_Window>Fl_Window::Fl_Window(int w, int h, const char *title = 0)</A></H4>
84
The first form of the constructor should be used for a "top-level" window
85
(that is, one that is not inside another window). It correctly sets
86
<tt>visible()</tt> to false and <tt>parent()</tt> to <tt>NULL</tt>.
87
By not specifying the position of the window, the window system will pick a
88
place to show the window or allow the user to pick a location. If you want to
89
force a position you should call <tt>position(x,y)</tt> or <tt>hotspot()</tt>
90
before calling <tt>show()</tt>.
92
<P><TT>Fl_Widget::box()</TT> is set to <TT>FL_FLAT_BOX</TT>. If you
93
plan to completely fill the window with children widgets you should
94
change this to <TT>FL_NO_BOX</TT>. If you turn the window border off
95
you may want to change this to <TT>FL_UP_BOX</TT>. </P>
97
<h4>Fl_Window::Fl_Window(int x, int y, int w, int h, const char *title = 0)</H4>
99
<P>The second form of the constructor is for creating child windows. It
100
leaves <tt>visible()</tt> set to true.
102
<H4><A name=Fl_Window.~Fl_Window>virtual Fl_Window::~Fl_Window()</A></H4>
103
The destructor <I>also deletes all the children</I>. This allows a
104
whole tree to be deleted at once, without having to keep a pointer to
105
all the children in the user code. A kludge has been done so the <TT>
106
Fl_Window</TT> and all of it's children can be automatic (local)
107
variables, but you must declare the <TT>Fl_Window</TT> <I>first</I> so
108
that it is destroyed last.
109
<H4><A name=Fl_Window.size_range>void Fl_Window::size_range(int minw,
110
int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)</A></H4>
111
Set the allowable range the user can resize this window to. This only
112
works for top-level windows.
114
<LI><TT>minw</TT> and <TT>minh</TT> are the smallest the window can
116
<LI><TT>maxw</TT> and <TT>maxh</TT> are the largest the window can be.
117
If either is <I>equal</I> to the minimum then you cannot resize in
118
that direction. If either is zero then FLTK picks a maximum size in
119
that direction such that the window will fill the screen. </LI>
120
<LI><TT>dw</TT> and <TT>dh</TT> are size increments. The window will
121
be constrained to widths of <TT>minw + N * dw</TT>, where <TT>N</TT>
122
is any non-negative integer. If these are less or equal to 1 they
123
are ignored. (this is ignored on WIN32)</LI>
124
<LI><TT>aspect</TT> is a flag that indicates that the window should
125
preserve it's aspect ratio. This only works if both the maximum and
126
minimum have the same aspect ratio. (ignored on WIN32 and by many X
127
window managers)</LI>
129
If this function is not called, FLTK tries to figure out the range
130
from the setting of <A href="Fl_Group.html#Fl_Group.resizable"><TT>resizable()</TT></A>:
132
<LI>If <TT>resizable()</TT> is <TT>NULL</TT> (this is the default)
133
then the window cannot be resized and the resize border and max-size
134
control will not be displayed for the window. </LI>
135
<LI>If either dimension of <TT>resizable()</TT> is less than 100,
136
then that is considered the minimum size. Otherwise the <TT>
137
resizable()</TT> has a minimum size of 100. </LI>
138
<LI>If either dimension of <TT>resizable()</TT> is zero, then that is
139
also the maximum size (so the window cannot resize in that direction). </LI>
141
It is undefined what happens if the current size does not fit in the
142
constraints passed to <TT>size_range()</TT>.
143
<H4><A name=Fl_Window.show>virtual void Fl_Window::show()
144
<BR> void Fl_Window::show(int argc, char **argv)</A></H4>
145
Put the window on the screen. Usually this has the side effect of
146
opening the display. The second form is used for top-level
147
windows and allow standard arguments to be parsed from the
149
<P>If the window is already shown then it is restored and raised to the
150
top. This is really convenient because your program can call <TT>show()</TT>
151
at any time, even if the window is already up. It also means that <TT>
152
show()</TT> serves the purpose of <TT>raise()</TT> in other toolkits. </P>
153
<H4><A name=Fl_Window.hide>virtual void Fl_Window::hide()</A></H4>
154
Remove the window from the screen. If the window is already hidden or
155
has not been shown then this does nothing and is harmless.
156
<H4><A name=Fl_Window.shown>int Fl_Window::shown() const</A></H4>
157
Returns non-zero if <TT>show()</TT> has been called (but not <TT>hide()</TT>
158
). You can tell if a window is iconified with <TT>(w->shown()
159
&!w->visible())</TT>.
160
<H4><A name=Fl_Window.iconize>void Fl_Window::iconize()</A></H4>
161
Iconifies the window. If you call this when <TT>shown()</TT> is false
162
it will <TT>show()</TT> it as an icon. If the window is already
163
iconified this does nothing.
164
<P>Call <TT>show()</TT> to restore the window. </P>
165
<P>When a window is iconified/restored (either by these calls or by the
166
user) the <TT>handle()</TT> method is called with <TT>FL_HIDE</TT> and <TT>
167
FL_SHOW</TT> events and <TT>visible()</TT> is turned on and off. </P>
168
<P>There is no way to control what is drawn in the icon except with the
169
string passed to <TT>Fl_Window::xclass()</TT>. You should not rely on
170
window managers displaying the icons. </P>
172
<H4><A name=Fl_Window.resize>void Fl_Window::resize(int,int,int,int)</A></H4>
173
Change the size and position of the window. If <TT>shown()</TT> is
174
true, these changes are communicated to the window server (which may
175
refuse that size and cause a further resize). If <TT>shown()</TT> is
176
false, the size and position are used when <TT>show()</TT> is called.
177
See <A href=Fl_Group.html#Fl_Group><TT>Fl_Group</TT></A> for the effect
178
of resizing on the child widgets.
179
<P>You can also call the <TT>Fl_Widget</TT> methods <TT>size(x,y)</TT>
180
and <TT>position(w,h)</TT>, which are inline wrappers for this virtual
182
<H4><A name=Fl_Window.free_position>void Fl_Window::free_position()</A></H4>
183
Undoes the effect of a previous <TT>resize()</TT> or <TT>show()</TT>
184
so that the next time <TT>show()</TT> is called the window manager is
185
free to position the window.
186
<H4><A name=Fl_Window.hotspot>void Fl_Window::hotspot(int x, int y, int
188
<BR> void Fl_Window::hotspot(const Fl_Widget*, int offscreen = 0)
189
<BR> void Fl_Window::hotspot(const Fl_Widgetp, int offscreen = 0)</A></H4>
190
<TT>position()</TT> the window so that the mouse is pointing at the
191
given position, or at the center of the given widget, which may be the
192
window itself. If the optional <TT>offscreen</TT> parameter is
193
non-zero, then the window is allowed to extend off the screen (this
194
does not work with some X window managers).
195
<H4><A name=Fl_Window.fullscreen>void Fl_Window::fullscreen()</A></H4>
196
Makes the window completely fill the screen, without any window
197
manager border visible. You must use <TT>fullscreen_off()</TT> to undo
198
this. This may not work with all window managers.
199
<H4><A name=Fl_Window.fullscreen_off>int Fl_Window::fullscreen_off(int
200
x, int y, int w, int h)</A></H4>
201
Turns off any side effects of <TT>fullscreen()</TT> and does <TT>
202
resize(x,y,w,h)</TT>.
203
<H4><A name=Fl_Window.border>int Fl_Window::border(int)
204
<BR> uchar Fl_Window::border() const</A></H4>
205
Gets or sets whether or not the window manager border is around the
206
window. The default value is true. <TT>border(n)</TT> can be used to
207
turn the border on and off, and returns non-zero if the value has been
208
changed. <I>Under most X window managers this does not work after <TT>
209
show()</TT> has been called, although SGI's 4DWM does work.</I>
210
<H4><A name=Fl_Window.clear_border>void Fl_Window::clear_border()</A></H4>
211
<TT>clear_border()</TT> is a fast inline function to turn the border
212
off. It only works before <TT>show()</TT> is called.
213
<H4><A name=Fl_Window.set_modal>void Fl_Window::set_modal()</A></H4>
214
A "modal" window, when <TT>shown()</TT>, will prevent any events from
215
being delivered to other windows in the same program, and will also
216
remain on top of the other windows (if the X window manager supports
217
the "transient for" property). Several modal windows may be shown at
218
once, in which case only the last one shown gets events. You can see
219
which window (if any) is modal by calling <A href="Fl.html#Fl.modal"><TT>
220
Fl::modal()</TT></A>.
221
<H4><A name=Fl_Window.modal>uchar Fl_Window::modal() const</A></H4>
222
Returns true if this window is modal.
223
<H4><A name=Fl_Window.set_non_modal>void Fl_Window::set_non_modal()</A></H4>
224
A "non-modal" window (terminology borrowed from Microsoft Windows)
225
acts like a <TT>modal()</TT> one in that it remains on top, but it has
226
no effect on event delivery. There are <I>three</I> states for a
227
window: modal, non-modal, and normal.
228
<H4><A name=Fl_Window.non_modal>uchar Fl_Window::non_modal() const</A></H4>
229
Returns true if this window is modal or non-modal.
230
<H4><A name=Fl_Window.label>void Fl_Window::label(const char*)
231
<BR> const char* Fl_Window::label() const</A></H4>
232
Gets or sets the window title bar label.
233
<H4><A name=Fl_Window.iconlabel>void Fl_Window::iconlabel(const char*)
234
<BR> const char* Fl_Window::iconlabel() const</A></H4>
235
Gets or sets the icon label.
236
<H4><A name=Fl_Window.xclass>void Fl_Window::xclass(const char*)
237
<BR> const char* Fl_Window::xclass() const</A></H4>
238
A string used to tell the system what type of window this is. Mostly
239
this identifies the picture to draw in the icon. <I>Under X, this is
240
turned into a <TT>XA_WM_CLASS</TT> pair by truncating at the first
241
non-alphanumeric character and capitalizing the first character, and
242
the second one if the first is 'x'. Thus "foo" turns into "foo, Foo",
243
and "xprog.1" turns into "xprog, XProg".</I> This only works if called <I>
244
before</I> calling <TT>show()</TT>.
245
<P>Under Microsoft Windows this string is used as the name of the
246
WNDCLASS structure, though it is not clear if this can have any
248
<H4><A name=Fl_Window.make_current>void Fl_Window::make_current()</A></H4>
249
<TT>make_current()</TT> sets things up so that the drawing functions in <A
250
href=drawing.html#drawing><TT><FL/fl_draw.H></TT></A> will go into this
251
window. This is useful for incremental update of windows, such as in an
252
idle callback, which will make your program behave much better if it
253
draws a slow graphic. <B>Danger: incremental update is very hard to
254
debug and maintain!</B>
255
<P>This method only works for the <TT>Fl_Window</TT> and <TT>
256
Fl_Gl_Window</TT> classes. </P>
257
<H4><A name=Fl_Window.current>static Fl_Window* Fl_Window::current()</A></H4>
258
Returns the last window that was made current.
259
<H4><A name=Fl_Window.cursor>void Fl_Window::cursor(Fl_Cursor, Fl_Color = FL_WHITE, Fl_Color = FL_BLACK)</A></H4>
260
Change the cursor for this window. This always calls the system, if
261
you are changing the cursor a lot you may want to keep track of how
262
you set it in a static varaible and call this only if the new cursor
265
<P>The type <TT>Fl_Cursor</TT> is an enumeration defined in <A
266
href=enumerations.html#cursor> <TT><Enumerations.H></TT></A>.
267
(Under X you can get any XC_cursor value by passing <TT>
268
Fl_Cursor((XC_foo/2)+1)</TT>). The colors only work on X, they are
269
not implemented on WIN32.