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