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