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