]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/frame.tex
Made wxLayoutAlgorithm more general (copes with nested sash windows)
[wxWidgets.git] / docs / latex / wx / frame.tex
CommitLineData
a660d684
KB
1\section{\class{wxFrame}}\label{wxframe}
2
3A frame is a window whose size and position can (usually) be changed by the user. It usually has
4thick borders and a title bar, and can optionally contain a menu bar, toolbar and
5status bar. A frame can contain any window that is not a frame or dialog.
6
81d66cf3
JS
7A frame that has a status bar and toolbar created via the CreateStatusBar/CreateToolBar functions
8manages these windows, and adjusts the value returned by GetClientSize to reflect
9the remaining size available to application windows.
10
a660d684
KB
11\wxheading{Derived from}
12
13\helpref{wxWindow}{wxwindow}\\
14\helpref{wxEvtHandler}{wxevthandler}\\
15\helpref{wxObject}{wxobject}
16
17\wxheading{Window styles}
18
19\twocolwidtha{5cm}
20\begin{twocollist}\itemsep=0pt
21\twocolitem{\windowstyle{wxICONIZE}}{Display the frame iconized (minimized) (Windows only).}
22\twocolitem{\windowstyle{wxCAPTION}}{Puts a caption on the frame.}
23\twocolitem{\windowstyle{wxDEFAULT\_FRAME\_STYLE}}{Defined as {\bf wxMINIMIZE\_BOX \pipe wxMAXIMIZE\_BOX \pipe wxTHICK\_FRAME \pipe wxSYSTEM\_MENU \pipe wxCAPTION}.}
24\twocolitem{\windowstyle{wxMINIMIZE}}{Identical to {\bf wxICONIZE}.}
25\twocolitem{\windowstyle{wxMINIMIZE\_BOX}}{Displays a minimize box on the frame (Windows and Motif only).}
26\twocolitem{\windowstyle{wxMAXIMIZE}}{Displays the frame maximized (Windows only).}
27\twocolitem{\windowstyle{wxMAXIMIZE\_BOX}}{Displays a maximize box on the frame (Windows and Motif only).}
28\twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{Stay on top of other windows (Windows only).}
29\twocolitem{\windowstyle{wxSYSTEM\_MENU}}{Displays a system menu (Windows and Motif only).}
30\twocolitem{\windowstyle{wxTHICK\_FRAME}}{Displays a thick frame around the window (Windows and Motif only).}
31\twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Displays a resizeable border around the window (Motif only).}
32\end{twocollist}
33
5fc02438
RR
34See also \helpref{window styles overview}{windowstyles}. Currently the GTK port of wxWindows
35ignores all the window styles listed above as there is no standard way (yet) to inform the
36window manager about such options. Therefore, the only relevant window style flag which
37the GTK port recognizes is \windowstyle{wxSIMPLE\_BORDER} which brings up a frame without
38any window decorations. This can be used for a splash screen or specialized tooltip etc.
a660d684
KB
39
40\wxheading{Remarks}
41
42An application should normally define an \helpref{OnCloseWindow}{wxwindowonclosewindow} handler for the
43frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
44
45\wxheading{See also}
46
47\helpref{wxMDIParentFrame}{wxmdiparentframe}, \helpref{wxMDIChildFrame}{wxmdichildframe},\rtfsp
48\helpref{wxMiniFrame}{wxminiframe}, \helpref{wxDialog}{wxdialog}
49
50\latexignore{\rtfignore{\wxheading{Members}}}
51
52\membersection{wxFrame::wxFrame}\label{wxframeconstr}
53
54\func{}{wxFrame}{\void}
55
56Default constructor.
57
eaaa6a06 58\func{}{wxFrame}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
a660d684
KB
59\param{const wxString\& }{title}, \param{const wxPoint\&}{ pos = wxDefaultPosition},\rtfsp
60\param{const wxSize\&}{ size = wxDefaultSize}, \param{long}{ style = wxDEFAULT\_FRAME\_STYLE},\rtfsp
61\param{const wxString\& }{name = ``frame"}}
62
63Constructor, creating the window.
64
65\wxheading{Parameters}
66
67\docparam{parent}{The window parent. This may be NULL. If it is non-NULL, the frame will
68always be displayed on top of the parent window on Windows.}
69
70\docparam{id}{The window identifier. It may take a value of -1 to indicate a default value.}
71
72\docparam{title}{The caption to be displayed on the frame's title bar.}
73
74\docparam{pos}{The window position. A value of (-1, -1) indicates a default position, chosen by
75either the windowing system or wxWindows, depending on platform.}
76
77\docparam{size}{The window size. A value of (-1, -1) indicates a default size, chosen by
78either the windowing system or wxWindows, depending on platform.}
79
80\docparam{style}{The window style. See \helpref{wxFrame}{wxframe}.}
81
82\docparam{name}{The name of the window. This parameter is used to associate a name with the item,
83allowing the application user to set Motif resource values for
84individual windows.}
85
86\wxheading{Remarks}
87
88For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
89(otherwise all styles take effect).
90
91\wxheading{See also}
92
93\helpref{wxFrame::Create}{wxframecreate}
94
95\membersection{wxFrame::\destruct{wxFrame}}
96
97\func{void}{\destruct{wxFrame}}{\void}
98
99Destructor. Destroys all child windows and menu bar if present.
100
101\membersection{wxFrame::Centre}\label{wxframecentre}
102
eaaa6a06 103\func{void}{Centre}{\param{int}{ direction = wxBOTH}}
a660d684
KB
104
105Centres the frame on the display.
106
107\wxheading{Parameters}
108
109\docparam{direction}{The parameter may be {\tt wxHORIZONTAL}, {\tt wxVERTICAL} or {\tt wxBOTH}.}
110
111\membersection{wxFrame::Command}\label{wxframecommand}
112
113\func{void}{Command}{\param{int }{id}}
114
115Simulate a menu command.
116
117\wxheading{Parameters}
118
119\docparam{id}{The identifier for a menu item.}
120
121\membersection{wxFrame::Create}\label{wxframecreate}
122
eaaa6a06 123\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
a660d684
KB
124\param{const wxString\& }{title}, \param{const wxPoint\&}{ pos = wxDefaultPosition},\rtfsp
125\param{const wxSize\&}{ size = wxDefaultSize}, \param{long}{ style = wxDEFAULT\_FRAME\_STYLE},\rtfsp
126\param{const wxString\& }{name = ``frame"}}
127
128Used in two-step frame construction. See \helpref{wxFrame::wxFrame}{wxframeconstr}\rtfsp
129for further details.
130
131\membersection{wxFrame::CreateStatusBar}\label{wxframecreatestatusbar}
132
81d66cf3
JS
133\func{virtual wxStatusBar*}{CreateStatusBar}{\param{int}{ number = 1},
134 \param{long}{ style = 0},
135 \param{wxWindowID}{ id = -1}, \param{const wxString\&}{ name = "statusBar"}}
a660d684
KB
136
137Creates a status bar at the bottom of the frame.
138
139\wxheading{Parameters}
140
141\docparam{number}{The number of fields to create. Specify a
142value greater than 1 to create a multi-field status bar.}
143
81d66cf3
JS
144\docparam{style}{The status bar style. See \helpref{wxStatusBar}{wxstatusbar} for a list
145of valid styles.}
146
147\docparam{id}{The status bar window identifier. If -1, an identifier will be chosen by
148wxWindows.}
149
150\docparam{name}{The status bar window name.}
151
a660d684
KB
152\wxheading{Return value}
153
81d66cf3 154A pointer to the the status bar if it was created successfully, NULL otherwise.
a660d684
KB
155
156\wxheading{Remarks}
157
158The width of the status bar is the whole width of the frame (adjusted automatically when
159resizing), and the height and text size are chosen by the host windowing system.
160
161By default, the status bar is an instance of wxStatusBar. To use a different class,
162override \helpref{wxFrame::OnCreateStatusBar}{wxframeoncreatestatusbar}.
163
164Note that you can put controls and other windows on the status bar if you wish.
165
166\wxheading{See also}
167
168\helpref{wxFrame::SetStatusText}{wxframesetstatustext},\rtfsp
169\helpref{wxFrame::OnCreateStatusBar}{wxframeoncreatestatusbar},\rtfsp
170\helpref{wxFrame::GetStatusBar}{wxframegetstatusbar}
171
81d66cf3
JS
172\membersection{wxFrame::CreateToolBar}\label{wxframecreatetoolbar}
173
174\func{virtual wxToolBar*}{CreateToolBar}{\param{long}{ style = wxNO\_BORDER \pipe wxTB\_HORIZONTAL},
175 \param{wxWindowID}{ id = -1}, \param{const wxString\&}{ name = "toolBar"}}
176
177Creates a toolbar at the top or left of the frame.
178
179\wxheading{Parameters}
180
181\docparam{style}{The toolbar style. See \helpref{wxToolBar}{wxtoolbar} for a list
182of valid styles.}
183
184\docparam{id}{The toolbar window identifier. If -1, an identifier will be chosen by
185wxWindows.}
186
187\docparam{name}{The toolbar window name.}
188
189\wxheading{Return value}
190
191A pointer to the the toolbar if it was created successfully, NULL otherwise.
192
193\wxheading{Remarks}
194
195By default, the toolbar is an instance of wxToolBar (which is defined to be
196a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
197override \helpref{wxFrame::OnCreateToolBar}{wxframeoncreatetoolbar}.
198
199When a toolbar has been created with this function, or made known to the frame
200with \helpref{wxFrame::SetToolBar}{wxframesettoolbar}, the frame will manage the toolbar
201position and adjust the return value from \helpref{wxWindow::GetClientSize}{wxwindowgetclientsize} to
202reflect the available space for application windows.
203
204\wxheading{See also}
205
206\helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar},\rtfsp
207\helpref{wxFrame::OnCreateToolBar}{wxframeoncreatetoolbar},\rtfsp
208\helpref{wxFrame::SetToolBar}{wxframesettoolbar},\rtfsp
209\helpref{wxFrame::GetToolBar}{wxframegettoolbar}
210
a660d684
KB
211\membersection{wxFrame::GetMenuBar}\label{wxframegetmenubar}
212
213\constfunc{wxMenuBar*}{GetMenuBar}{\void}
214
215Returns a pointer to the menubar currently associated with the frame (if any).
216
217\wxheading{See also}
218
219\helpref{wxFrame::SetMenuBar}{wxframesetmenubar}, \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}
220
221\membersection{wxFrame::GetStatusBar}\label{wxframegetstatusbar}
222
223\func{wxStatusBar*}{GetStatusBar}{\void}
224
225Returns a pointer to the status bar currently associated with the frame (if any).
226
227\wxheading{See also}
228
229\helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar}
230
231\membersection{wxFrame::GetTitle}\label{wxframegettitle}
232
233\func{wxString\&}{GetTitle}{\void}
234
235Gets a temporary pointer to the frame title. See
236\helpref{wxFrame::SetTitle}{wxframesettitle}.
237
81d66cf3
JS
238\membersection{wxFrame::GetToolBar}\label{wxframegettoolbar}
239
240\func{wxToolBar*}{GetToolBar}{\void}
241
242Returns a pointer to the toolbar currently associated with the frame (if any).
243
244\wxheading{See also}
245
246\helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}, \helpref{wxToolBar}{wxtoolbar},\rtfsp
247\helpref{wxFrame::SetToolBar}{wxframesettoolbar}
248
a660d684
KB
249\membersection{wxFrame::Iconize}\label{wxframeiconize}
250
251\func{void}{Iconize}{\param{const bool}{ iconize}}
252
253Iconizes or restores the frame.
254
255\wxheading{Parameters}
256
257\docparam{izonize}{If TRUE, iconizes the frame; if FALSE, shows and restores it.}
258
259\wxheading{See also}
260
261\helpref{wxFrame::IsIconized}{wxframeisiconized}, \helpref{wxFrame::Maximize}{wxframemaximize}.
262
263\membersection{wxFrame::IsIconized}\label{wxframeisiconized}
264
94b49b93 265\constfunc{bool}{IsIconized}{\void}
a660d684
KB
266
267Returns TRUE if the frame is iconized.
268
94b49b93
JS
269\membersection{wxFrame::IsMaximized}\label{wxframeismaximized}
270
271\constfunc{bool}{IsMaximized}{\void}
272
273Returns TRUE if the frame is maximized.
274
a660d684
KB
275\membersection{wxFrame::Maximize}\label{wxframemaximize}
276
277\func{void}{Maximize}{\param{const bool }{maximize}}
278
279Maximizes or restores the frame.
280
281\wxheading{Parameters}
282
283\docparam{maximize}{If TRUE, maximizes the frame, otherwise it restores it}.
284
285\wxheading{Remarks}
286
287This function only works under Windows.
288
289\wxheading{See also}
290
291\helpref{wxFrame::Iconize}{wxframeiconize}
292
293\membersection{wxFrame::OnActivate}
294
8cbd2bde 295\func{void}{OnActivate}{\param{wxActivateEvent\&}{ event}}
a660d684
KB
296
297Called when a window is activated or deactivated (MS Windows
8cbd2bde 298only). See also \helpref{wxActivateEvent}{wxactivateevent}.
a660d684
KB
299
300\membersection{wxFrame::OnCreateStatusBar}\label{wxframeoncreatestatusbar}
301
81d66cf3
JS
302\func{virtual wxStatusBar*}{OnCreateStatusBar}{\param{int }{number}
303 \param{long}{ style},
304 \param{wxWindowID}{ id}, \param{const wxString\&}{ name}}
a660d684
KB
305
306Virtual function called when a status bar is requested by \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}.
307
308\wxheading{Parameters}
309
310\docparam{number}{The number of fields to create.}
311
81d66cf3
JS
312\docparam{style}{The window style. See \helpref{wxStatusBar}{wxstatusbar} for a list
313of valid styles.}
314
315\docparam{id}{The window identifier. If -1, an identifier will be chosen by
316wxWindows.}
317
318\docparam{name}{The window name.}
319
a660d684
KB
320\wxheading{Return value}
321
322A status bar object.
323
324\wxheading{Remarks}
325
326An application can override this function to return a different kind of status bar. The default
327implementation returns an instance of \helpref{wxStatusBar}{wxstatusbar}.
328
329\wxheading{See also}
330
331\helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar}.
332
81d66cf3
JS
333\membersection{wxFrame::OnCreateToolBar}\label{wxframeoncreatetoolbar}
334
335\func{virtual wxToolBar*}{OnCreateToolBar}{\param{long}{ style},
336 \param{wxWindowID}{ id}, \param{const wxString\&}{ name}}
337
338Virtual function called when a toolbar is requested by \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}.
339
340\wxheading{Parameters}
341
342\docparam{style}{The toolbar style. See \helpref{wxToolBar}{wxtoolbar} for a list
343of valid styles.}
344
345\docparam{id}{The toolbar window identifier. If -1, an identifier will be chosen by
346wxWindows.}
347
348\docparam{name}{The toolbar window name.}
349
350\wxheading{Return value}
351
352A toolbar object.
353
354\wxheading{Remarks}
355
356An application can override this function to return a different kind of toolbar. The default
357implementation returns an instance of \helpref{wxToolBar}{wxtoolbar}.
358
359\wxheading{See also}
360
361\helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}, \helpref{wxToolBar}{wxtoolbar}.
362
a660d684
KB
363\membersection{wxFrame::OnMenuCommand}\label{wxframeonmenucommand}
364
365\func{void}{OnMenuCommand}{\param{wxCommandEvent\&}{ event}}
366
367See \helpref{wxWindow::OnMenuCommand}{wxwindowonmenucommand}.
368
369\membersection{wxFrame::OnMenuHighlight}\label{wxframeonmenuhighlight}
370
371\func{void}{OnMenuHighlight}{\param{wxMenuEvent\&}{ event}}
372
373See \helpref{wxWindow::OnMenuHighlight}{wxwindowonmenuhighlight}.
374
375\membersection{wxFrame::OnSize}\label{wxframeonsize}
376
377\func{void}{OnSize}{\param{wxSizeEvent\& }{event}}
378
379See \helpref{wxWindow::OnSize}{wxwindowonsize}.
380
381The default {\bf wxFrame::OnSize} implementation looks for a single subwindow,
382and if one is found, resizes it to fit
383inside the frame. Override this member if more complex behaviour
384is required (for example, if there are several subwindows).
385
386\membersection{wxFrame::SetIcon}\label{wxframeseticon}
387
388\func{void}{SetIcon}{\param{const wxIcon\& }{icon}}
389
390Sets the icon for this frame.
391
392\wxheading{Parameters}
393
394\docparam{icon}{The icon to associate with this frame.}
395
396\wxheading{Remarks}
397
398The frame takes a `copy' of {\it icon}, but since it uses reference
399counting, the copy is very quick. It is safe to delete {\it icon} after
400calling this function.
401
402Under Windows, instead of using {\bf SetIcon}, you can add the
403following lines to your MS Windows resource file:
404
405\begin{verbatim}
406wxSTD_MDIPARENTFRAME ICON icon1.ico
407wxSTD_MDICHILDFRAME ICON icon2.ico
408wxSTD_FRAME ICON icon3.ico
409\end{verbatim}
410
411where icon1.ico will be used for the MDI parent frame, icon2.ico
412will be used for MDI child frames, and icon3.ico will be used for
413non-MDI frames.
414
415If these icons are not supplied, and {\bf SetIcon} is not called either,
416then the following defaults apply if you have included wx.rc.
417
418\begin{verbatim}
419wxDEFAULT_FRAME ICON std.ico
420wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
421wxDEFAULT_MDICHILDFRAME ICON child.ico
422\end{verbatim}
423
424You can replace std.ico, mdi.ico and child.ico with your own defaults
425for all your wxWindows application. Currently they show the same icon.
426
427{\it Note:} a wxWindows application linked with subsystem equal to 4.0
428(i.e. marked as a Windows 95 application) doesn't respond properly
429to wxFrame::SetIcon. To work around this until a solution is found,
430mark your program as a 3.5 application. This will also ensure
431that Windows provides small icons for the application automatically.
432
433See also \helpref{wxIcon}{wxicon}.
434
435\membersection{wxFrame::SetMenuBar}\label{wxframesetmenubar}
436
437\func{void}{SetMenuBar}{\param{wxMenuBar* }{menuBar}}
438
439Tells the frame to show the given menu bar.
440
441\wxheading{Parameters}
442
443\docparam{menuBar}{The menu bar to associate with the frame.}
444
445\wxheading{Remarks}
446
447If the frame is destroyed, the
448menu bar and its menus will be destroyed also, so do not delete the menu
449bar explicitly (except by resetting the frame's menu bar to another
450frame or NULL).
451
452Under Windows, a call to \helpref{wxFrame::OnSize}{wxframeonsize} is generated, so be sure to initialize
453data members properly before calling {\bf SetMenuBar}.
454
455Note that it is not possible to call this function twice for the same frame object.
456
457\wxheading{See also}
458
459\helpref{wxFrame::GetMenuBar}{wxframegetmenubar}, \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}.
460
81d66cf3
JS
461\membersection{wxFrame::SetStatusBar}\label{wxframesetstatusbar}
462
463\func{void}{SetStatusBar}{\param{wxStatusBar*}{ statusBar}}
464
465Associates a status bar with the frame.
466
467\wxheading{See also}
468
469\helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar},\rtfsp
470\helpref{wxFrame::GetStatusBar}{wxframegetstatusbar}
471
a660d684
KB
472\membersection{wxFrame::SetStatusText}\label{wxframesetstatustext}
473
eaaa6a06 474\func{virtual void}{SetStatusText}{\param{const wxString\& }{ text}, \param{int}{ number = 0}}
a660d684
KB
475
476Sets the status bar text and redraws the status bar.
477
478\wxheading{Parameters}
479
480\docparam{text}{The text for the status field.}
481
482\docparam{number}{The status field (starting from zero).}
483
484\wxheading{Remarks}
485
486Use an empty string to clear the status bar.
487
488\wxheading{See also}
489
490\helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar}
491
492\membersection{wxFrame::SetStatusWidths}\label{wxframesetstatuswidths}
493
eaaa6a06 494\func{virtual void}{SetStatusWidths}{\param{int}{ n}, \param{int *}{widths}}
a660d684
KB
495
496Sets the widths of the fields in the status bar.
497
498\wxheading{Parameters}
499
500\wxheading{n}{The number of fields in the status bar. It must be the
501same used in \helpref{CreateStatusBar}{wxframecreatestatusbar}.}
502
503\docparam{widths}{Must contain an array of {\it n} integers, each of which is a status field width
504in pixels. A value of -1 indicates that the field is variable width; at least one
505field must be -1. You should delete this array after calling {\bf SetStatusWidths}.}
506
507\wxheading{Remarks}
508
509The widths of the variable fields are calculated from the total width of all fields,
510minus the sum of widths of the non-variable fields, divided by the number of
511variable fields.
512
81d66cf3
JS
513\membersection{wxFrame::SetToolBar}\label{wxframesettoolbar}
514
515\func{void}{SetToolBar}{\param{wxToolBar*}{ toolBar}}
516
517Associates a toolbar with the frame.
518
519\wxheading{See also}
520
521\helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}, \helpref{wxToolBar}{wxtoolbar},\rtfsp
522\helpref{wxFrame::GetToolBar}{wxframegettoolbar}
523
a660d684
KB
524\membersection{wxFrame::SetTitle}\label{wxframesettitle}
525
526\func{virtual void}{SetTitle}{\param{const wxString\& }{ title}}
527
528Sets the frame title.
529
530\wxheading{Parameters}
531
532\docparam{title}{The frame title.}
533
534\wxheading{See also}
535
536\helpref{wxFrame::GetTitle}{wxframegettitle}
537