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