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