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