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