]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/frame.tex
Remove event handlers wxApp::OnQueryEndSession and wxDialog::OnCharHook from docs...
[wxWidgets.git] / docs / latex / wx / frame.tex
1 \section{\class{wxFrame}}\label{wxframe}
2
3 A frame is a window whose size and position can (usually) be changed by the
4 user. It usually has thick borders and a title bar, and can optionally contain
5 a menu bar, toolbar and status bar. A frame can contain any window that is not
6 a frame or dialog.
7
8 A frame that has a status bar and toolbar created via the
9 CreateStatusBar/CreateToolBar functions manages these windows, and adjusts the
10 value returned by GetClientSize to reflect the remaining size available to
11 application windows.
12
13 \wxheading{Derived from}
14
15 \helpref{wxTopLevelWindow}{wxtoplevelwindow}\\
16 \helpref{wxWindow}{wxwindow}\\
17 \helpref{wxEvtHandler}{wxevthandler}\\
18 \helpref{wxObject}{wxobject}
19
20 \wxheading{Include files}
21
22 <wx/frame.h>
23
24 \wxheading{Window styles}
25
26 \twocolwidtha{5cm}
27 \begin{twocollist}\itemsep=0pt
28 \twocolitem{\windowstyle{wxDEFAULT\_FRAME\_STYLE}}{Defined as {\bf wxMINIMIZE\_BOX \pipe wxMAXIMIZE\_BOX \pipe wxRESIZE\_BORDER \pipe wxSYSTEM\_MENU \pipe wxCAPTION \pipe wxCLOSE\_BOX \pipe wxCLIP\_CHILDREN}.}
29 \twocolitem{\windowstyle{wxICONIZE}}{Display the frame iconized (minimized). Windows only. }
30 \twocolitem{\windowstyle{wxCAPTION}}{Puts a caption on the frame.}
31 \twocolitem{\windowstyle{wxMINIMIZE}}{Identical to {\bf wxICONIZE}. Windows only.}
32 \twocolitem{\windowstyle{wxMINIMIZE\_BOX}}{Displays a minimize box on the frame.}
33 \twocolitem{\windowstyle{wxMAXIMIZE}}{Displays the frame maximized. Windows only.}
34 \twocolitem{\windowstyle{wxMAXIMIZE\_BOX}}{Displays a maximize box on the frame.}
35 \twocolitem{\windowstyle{wxCLOSE\_BOX}}{Displays a close box on the frame.}
36 \twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{Stay on top of all other windows,
37 see also wxFRAME\_FLOAT\_ON\_PARENT. Windows only.}
38 \twocolitem{\windowstyle{wxSYSTEM\_MENU}}{Displays a system menu.}
39 \twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Displays a resizeable border around the window.}
40 \twocolitem{\windowstyle{wxFRAME\_TOOL\_WINDOW}}{Causes a frame with a small
41 titlebar to be created; the frame does not appear in the taskbar under Windows or GTK+.}
42 \twocolitem{\windowstyle{wxFRAME\_NO\_TASKBAR}}{Creates an otherwise normal
43 frame but it does not appear in the taskbar under Windows or GTK+ (note that it
44 will minimize to the desktop window under Windows which may seem strange to the
45 users and thus it might be better to use this style only without
46 wxMINIMIZE\_BOX style). In wxGTK, the flag is respected only if GTK+ is at
47 least version 2.2 and the window manager supports
48 \urlref{\_NET\_WM\_STATE\_SKIP\_TASKBAR}{http://freedesktop.org/Standards/wm-spec/1.3/ar01s05.html} hint.
49 Has no effect under other platforms.}
50 \twocolitem{\windowstyle{wxFRAME\_FLOAT\_ON\_PARENT}}{The frame will always be
51 on top of its parent (unlike wxSTAY\_ON\_TOP). A frame created with this style
52 must have a non-NULL parent.}
53 \twocolitem{\windowstyle{wxFRAME\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
54 caption. When pressed, Windows will go into a context-sensitive help mode and wxWidgets will send
55 a wxEVT\_HELP event if the user clicked on an application window. {\it Note} that this is an extended
56 style and must be set by calling \helpref{SetExtraStyle}{wxwindowsetextrastyle} before Create is called (two-step construction).
57 You cannot use this style together with wxMAXIMIZE\_BOX or wxMINIMIZE\_BOX, so
58 you should use\rtfsp
59 {\tt wxDEFAULT\_FRAME\_STYLE \& ~ (wxMINIMIZE\_BOX | wxMAXIMIZE\_BOX)} for the
60 frames having this style (the dialogs don't have a minimize or a maximize box by
61 default)}
62 \twocolitem{\windowstyle{wxFRAME\_SHAPED}}{Windows with this style are
63 allowed to have their shape changed with the \helpref{SetShape}{wxtoplevelwindowsetshape} method.}
64 \end{twocollist}
65
66 The default frame style is for normal, resizeable frames. To create a frame
67 which can not be resized by user, you may use the following combination of
68 styles: {\tt wxDEFAULT\_FRAME\_STYLE \& ~ (wxRESIZE\_BORDER \pipe wxRESIZE\_BOX \pipe wxMAXIMIZE\_BOX)}.
69 % Note: the space after the tilde is necessary or Tex2RTF complains.
70
71 See also \helpref{window styles overview}{windowstyles}.
72
73 \wxheading{Default event processing}
74
75 wxFrame processes the following events:
76
77 \begin{twocollist}\itemsep=0pt
78 \twocolitem{\helpref{wxEVT\_SIZE}{wxsizeevent}}{If the frame has exactly one
79 child window, not counting the status and toolbar, this child is resized to
80 take the entire frame client area. If two or more windows are present, they
81 should be laid out explicitly either by manually handling wxEVT\_SIZE or using
82 \helpref{sizers}{sizeroverview}}
83
84 \twocolitem{\helpref{wxEVT\_MENU\_HIGHLIGHT}{wxmenuevent}}{The default
85 implementation displays the \helpref{help string}{wxmenuitemgethelp} associated
86 with the selected item in the first pane of the status bar, if there is one.}
87 \end{twocollist}
88
89 \wxheading{Remarks}
90
91 An application should normally define an \helpref{wxCloseEvent}{wxcloseevent} handler for the
92 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
93
94 \wxheading{See also}
95
96 \helpref{wxMDIParentFrame}{wxmdiparentframe}, \helpref{wxMDIChildFrame}{wxmdichildframe},\rtfsp
97 \helpref{wxMiniFrame}{wxminiframe}, \helpref{wxDialog}{wxdialog}
98
99 \latexignore{\rtfignore{\wxheading{Members}}}
100
101 \membersection{wxFrame::wxFrame}\label{wxframector}
102
103 \func{}{wxFrame}{\void}
104
105 Default constructor.
106
107 \func{}{wxFrame}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
108 \param{const wxString\& }{title}, \param{const wxPoint\&}{ pos = wxDefaultPosition},\rtfsp
109 \param{const wxSize\&}{ size = wxDefaultSize}, \param{long}{ style = wxDEFAULT\_FRAME\_STYLE},\rtfsp
110 \param{const wxString\& }{name = ``frame"}}
111
112 Constructor, creating the window.
113
114 \wxheading{Parameters}
115
116 \docparam{parent}{The window parent. This may be NULL. If it is non-NULL, the frame will
117 always be displayed on top of the parent window on Windows.}
118
119 \docparam{id}{The window identifier. It may take a value of -1 to indicate a default value.}
120
121 \docparam{title}{The caption to be displayed on the frame's title bar.}
122
123 \docparam{pos}{The window position. A value of (-1, -1) indicates a default position, chosen by
124 either the windowing system or wxWidgets, depending on platform.}
125
126 \docparam{size}{The window size. A value of (-1, -1) indicates a default size, chosen by
127 either the windowing system or wxWidgets, depending on platform.}
128
129 \docparam{style}{The window style. See \helpref{wxFrame}{wxframe}.}
130
131 \docparam{name}{The name of the window. This parameter is used to associate a name with the item,
132 allowing the application user to set Motif resource values for
133 individual windows.}
134
135 \wxheading{Remarks}
136
137 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
138 (otherwise all styles take effect).
139
140 \wxheading{See also}
141
142 \helpref{wxFrame::Create}{wxframecreate}
143
144 \membersection{wxFrame::\destruct{wxFrame}}\label{wxframedtor}
145
146 \func{void}{\destruct{wxFrame}}{\void}
147
148 Destructor. Destroys all child windows and menu bar if present.
149
150 \membersection{wxFrame::Centre}\label{wxframecentre}
151
152 \func{void}{Centre}{\param{int}{ direction = wxBOTH}}
153
154 Centres the frame on the display.
155
156 \wxheading{Parameters}
157
158 \docparam{direction}{The parameter may be {\tt wxHORIZONTAL}, {\tt wxVERTICAL} or {\tt wxBOTH}.}
159
160 \membersection{wxFrame::Create}\label{wxframecreate}
161
162 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
163 \param{const wxString\& }{title}, \param{const wxPoint\&}{ pos = wxDefaultPosition},\rtfsp
164 \param{const wxSize\&}{ size = wxDefaultSize}, \param{long}{ style = wxDEFAULT\_FRAME\_STYLE},\rtfsp
165 \param{const wxString\& }{name = ``frame"}}
166
167 Used in two-step frame construction. See \helpref{wxFrame::wxFrame}{wxframector}\rtfsp
168 for further details.
169
170 \membersection{wxFrame::CreateStatusBar}\label{wxframecreatestatusbar}
171
172 \func{virtual wxStatusBar*}{CreateStatusBar}{\param{int}{ number = 1},
173 \param{long}{ style = 0},
174 \param{wxWindowID}{ id = -1}, \param{const wxString\&}{ name = "statusBar"}}
175
176 Creates a status bar at the bottom of the frame.
177
178 \wxheading{Parameters}
179
180 \docparam{number}{The number of fields to create. Specify a
181 value greater than 1 to create a multi-field status bar.}
182
183 \docparam{style}{The status bar style. See \helpref{wxStatusBar}{wxstatusbar} for a list
184 of valid styles.}
185
186 \docparam{id}{The status bar window identifier. If -1, an identifier will be chosen by
187 wxWidgets.}
188
189 \docparam{name}{The status bar window name.}
190
191 \wxheading{Return value}
192
193 A pointer to the the status bar if it was created successfully, NULL otherwise.
194
195 \wxheading{Remarks}
196
197 The width of the status bar is the whole width of the frame (adjusted automatically when
198 resizing), and the height and text size are chosen by the host windowing system.
199
200 By default, the status bar is an instance of wxStatusBar. To use a different class,
201 override \helpref{wxFrame::OnCreateStatusBar}{wxframeoncreatestatusbar}.
202
203 Note that you can put controls and other windows on the status bar if you wish.
204
205 \wxheading{See also}
206
207 \helpref{wxFrame::SetStatusText}{wxframesetstatustext},\rtfsp
208 \helpref{wxFrame::OnCreateStatusBar}{wxframeoncreatestatusbar},\rtfsp
209 \helpref{wxFrame::GetStatusBar}{wxframegetstatusbar}
210
211 \membersection{wxFrame::CreateToolBar}\label{wxframecreatetoolbar}
212
213 \func{virtual wxToolBar*}{CreateToolBar}{\param{long}{ style = wxNO\_BORDER \pipe wxTB\_HORIZONTAL},
214 \param{wxWindowID}{ id = -1}, \param{const wxString\&}{ name = "toolBar"}}
215
216 Creates a toolbar at the top or left of the frame.
217
218 \wxheading{Parameters}
219
220 \docparam{style}{The toolbar style. See \helpref{wxToolBar}{wxtoolbar} for a list
221 of valid styles.}
222
223 \docparam{id}{The toolbar window identifier. If -1, an identifier will be chosen by
224 wxWidgets.}
225
226 \docparam{name}{The toolbar window name.}
227
228 \wxheading{Return value}
229
230 A pointer to the the toolbar if it was created successfully, NULL otherwise.
231
232 \wxheading{Remarks}
233
234 By default, the toolbar is an instance of wxToolBar (which is defined to be
235 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
236 override \helpref{wxFrame::OnCreateToolBar}{wxframeoncreatetoolbar}.
237
238 When a toolbar has been created with this function, or made known to the frame
239 with \helpref{wxFrame::SetToolBar}{wxframesettoolbar}, the frame will manage the toolbar
240 position and adjust the return value from \helpref{wxWindow::GetClientSize}{wxwindowgetclientsize} to
241 reflect the available space for application windows.
242
243 \wxheading{See also}
244
245 \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar},\rtfsp
246 \helpref{wxFrame::OnCreateToolBar}{wxframeoncreatetoolbar},\rtfsp
247 \helpref{wxFrame::SetToolBar}{wxframesettoolbar},\rtfsp
248 \helpref{wxFrame::GetToolBar}{wxframegettoolbar}
249
250 \membersection{wxFrame::GetClientAreaOrigin}\label{wxframegetclientareaorigin}
251
252 \constfunc{wxPoint}{GetClientAreaOrigin}{\void}
253
254 Returns the origin of the frame client area (in client coordinates). It may be
255 different from (0, 0) if the frame has a toolbar.
256
257 \membersection{wxFrame::GetMenuBar}\label{wxframegetmenubar}
258
259 \constfunc{wxMenuBar*}{GetMenuBar}{\void}
260
261 Returns a pointer to the menubar currently associated with the frame (if any).
262
263 \wxheading{See also}
264
265 \helpref{wxFrame::SetMenuBar}{wxframesetmenubar}, \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}
266
267 \membersection{wxFrame::GetStatusBar}\label{wxframegetstatusbar}
268
269 \constfunc{wxStatusBar*}{GetStatusBar}{\void}
270
271 Returns a pointer to the status bar currently associated with the frame (if any).
272
273 \wxheading{See also}
274
275 \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar}
276
277 \membersection{wxFrame::GetStatusBarPane}\label{wxframegetstatusbarpane}
278
279 \func{int}{GetStatusBarPane}{\void}
280
281 Returns the status bar pane used to display menu and toolbar help.
282
283 \wxheading{See also}
284
285 \helpref{wxFrame::SetStatusBarPane}{wxframesetstatusbarpane}
286
287 \membersection{wxFrame::GetToolBar}\label{wxframegettoolbar}
288
289 \constfunc{wxToolBar*}{GetToolBar}{\void}
290
291 Returns a pointer to the toolbar currently associated with the frame (if any).
292
293 \wxheading{See also}
294
295 \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}, \helpref{wxToolBar}{wxtoolbar},\rtfsp
296 \helpref{wxFrame::SetToolBar}{wxframesettoolbar}
297
298 \membersection{wxFrame::OnCreateStatusBar}\label{wxframeoncreatestatusbar}
299
300 \func{virtual wxStatusBar*}{OnCreateStatusBar}{\param{int }{number},
301 \param{long}{ style},
302 \param{wxWindowID}{ id}, \param{const wxString\&}{ name}}
303
304 Virtual function called when a status bar is requested by \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}.
305
306 \wxheading{Parameters}
307
308 \docparam{number}{The number of fields to create.}
309
310 \docparam{style}{The window style. See \helpref{wxStatusBar}{wxstatusbar} for a list
311 of valid styles.}
312
313 \docparam{id}{The window identifier. If -1, an identifier will be chosen by
314 wxWidgets.}
315
316 \docparam{name}{The window name.}
317
318 \wxheading{Return value}
319
320 A status bar object.
321
322 \wxheading{Remarks}
323
324 An application can override this function to return a different kind of status bar. The default
325 implementation returns an instance of \helpref{wxStatusBar}{wxstatusbar}.
326
327 \wxheading{See also}
328
329 \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar}.
330
331 \membersection{wxFrame::OnCreateToolBar}\label{wxframeoncreatetoolbar}
332
333 \func{virtual wxToolBar*}{OnCreateToolBar}{\param{long}{ style},
334 \param{wxWindowID}{ id}, \param{const wxString\&}{ name}}
335
336 Virtual function called when a toolbar is requested by \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}.
337
338 \wxheading{Parameters}
339
340 \docparam{style}{The toolbar style. See \helpref{wxToolBar}{wxtoolbar} for a list
341 of valid styles.}
342
343 \docparam{id}{The toolbar window identifier. If -1, an identifier will be chosen by
344 wxWidgets.}
345
346 \docparam{name}{The toolbar window name.}
347
348 \wxheading{Return value}
349
350 A toolbar object.
351
352 \wxheading{Remarks}
353
354 An application can override this function to return a different kind of toolbar. The default
355 implementation returns an instance of \helpref{wxToolBar}{wxtoolbar}.
356
357 \wxheading{See also}
358
359 \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}, \helpref{wxToolBar}{wxtoolbar}.
360
361
362 \membersection{wxFrame::ProcessCommand}\label{wxframeprocesscommand}
363
364 \func{void}{ProcessCommand}{\param{int }{id}}
365
366 Simulate a menu command.
367
368 \wxheading{Parameters}
369
370 \docparam{id}{The identifier for a menu item.}
371
372
373 \membersection{wxFrame::SendSizeEvent}\label{wxframesendsizeevent}
374
375 \func{void}{SendSizeEvent}{\void}
376
377 This function sends a dummy \helpref{size event}{wxsizeevent} to the frame
378 forcing it to reevaluate its children positions. It is sometimes useful to call
379 this function after adding or deleting a children after the frame creation or
380 if a child size changes.
381
382 Note that if the frame is using either sizers or constraints for the children
383 layout, it is enough to call \helpref{Layout()}{wxwindowlayout} directly and
384 this function should not be used in this case.
385
386 % VZ: we don't have all this any more (18.08.00)
387 %
388 %Under Windows, instead of using {\bf SetIcon}, you can add the
389 %following lines to your MS Windows resource file:
390 %
391 %\begin{verbatim}
392 %wxSTD_MDIPARENTFRAME ICON icon1.ico
393 %wxSTD_MDICHILDFRAME ICON icon2.ico
394 %wxSTD_FRAME ICON icon3.ico
395 %\end{verbatim}
396 %
397 %where icon1.ico will be used for the MDI parent frame, icon2.ico
398 %will be used for MDI child frames, and icon3.ico will be used for
399 %non-MDI frames.
400 %
401 %If these icons are not supplied, and {\bf SetIcon} is not called either,
402 %then the following defaults apply if you have included wx.rc.
403 %
404 %\begin{verbatim}
405 %wxDEFAULT_FRAME ICON std.ico
406 %wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
407 %wxDEFAULT_MDICHILDFRAME ICON child.ico
408 %\end{verbatim}
409 %
410 %You can replace std.ico, mdi.ico and child.ico with your own defaults
411 %for all your wxWidgets application. Currently they show the same icon.
412
413 \membersection{wxFrame::SetMenuBar}\label{wxframesetmenubar}
414
415 \func{void}{SetMenuBar}{\param{wxMenuBar* }{menuBar}}
416
417 Tells the frame to show the given menu bar.
418
419 \wxheading{Parameters}
420
421 \docparam{menuBar}{The menu bar to associate with the frame.}
422
423 \wxheading{Remarks}
424
425 If the frame is destroyed, the
426 menu bar and its menus will be destroyed also, so do not delete the menu
427 bar explicitly (except by resetting the frame's menu bar to another
428 frame or NULL).
429
430 Under Windows, a size event is generated, so be sure to initialize
431 data members properly before calling {\bf SetMenuBar}.
432
433 Note that on some platforms, it is not possible to call this function twice for the same frame object.
434
435 \wxheading{See also}
436
437 \helpref{wxFrame::GetMenuBar}{wxframegetmenubar}, \helpref{wxMenuBar}{wxmenubar}, \helpref{wxMenu}{wxmenu}.
438
439 \membersection{wxFrame::SetStatusBar}\label{wxframesetstatusbar}
440
441 \func{void}{SetStatusBar}{\param{wxStatusBar*}{ statusBar}}
442
443 Associates a status bar with the frame.
444
445 \wxheading{See also}
446
447 \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar},\rtfsp
448 \helpref{wxFrame::GetStatusBar}{wxframegetstatusbar}
449
450 \membersection{wxFrame::SetStatusBarPane}\label{wxframesetstatusbarpane}
451
452 \func{void}{SetStatusBarPane}{\param{int}{ n}}
453
454 Set the status bar pane used to display menu and toolbar help.
455 Using -1 disables help display.
456
457 \membersection{wxFrame::SetStatusText}\label{wxframesetstatustext}
458
459 \func{virtual void}{SetStatusText}{\param{const wxString\& }{ text}, \param{int}{ number = 0}}
460
461 Sets the status bar text and redraws the status bar.
462
463 \wxheading{Parameters}
464
465 \docparam{text}{The text for the status field.}
466
467 \docparam{number}{The status field (starting from zero).}
468
469 \wxheading{Remarks}
470
471 Use an empty string to clear the status bar.
472
473 \wxheading{See also}
474
475 \helpref{wxFrame::CreateStatusBar}{wxframecreatestatusbar}, \helpref{wxStatusBar}{wxstatusbar}
476
477 \membersection{wxFrame::SetStatusWidths}\label{wxframesetstatuswidths}
478
479 \func{virtual void}{SetStatusWidths}{\param{int}{ n}, \param{int *}{widths}}
480
481 Sets the widths of the fields in the status bar.
482
483 \wxheading{Parameters}
484
485 \wxheading{n}{The number of fields in the status bar. It must be the
486 same used in \helpref{CreateStatusBar}{wxframecreatestatusbar}.}
487
488 \docparam{widths}{Must contain an array of {\it n} integers, each of which is a status field width
489 in pixels. A value of -1 indicates that the field is variable width; at least one
490 field must be -1. You should delete this array after calling {\bf SetStatusWidths}.}
491
492 \wxheading{Remarks}
493
494 The widths of the variable fields are calculated from the total width of all fields,
495 minus the sum of widths of the non-variable fields, divided by the number of
496 variable fields.
497
498 \pythonnote{Only a single parameter is required, a Python list of
499 integers.}
500
501 \perlnote{In wxPerl this method takes the field widths as parameters.}
502
503 \membersection{wxFrame::SetToolBar}\label{wxframesettoolbar}
504
505 \func{void}{SetToolBar}{\param{wxToolBar*}{ toolBar}}
506
507 Associates a toolbar with the frame.
508
509 \wxheading{See also}
510
511 \helpref{wxFrame::CreateToolBar}{wxframecreatetoolbar}, \helpref{wxToolBar}{wxtoolbar},\rtfsp
512 \helpref{wxFrame::GetToolBar}{wxframegettoolbar}
513