]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
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 | \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 | ||
30 | See also \helpref{window styles overview}{windowstyles}. | |
31 | ||
32 | \wxheading{Remarks} | |
33 | ||
34 | An application should normally define an \helpref{OnCloseWindow}{wxwindowonclosewindow} handler for the | |
35 | frame 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 | ||
48 | Default 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 | ||
55 | Constructor, 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 | |
60 | always 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 | |
67 | either 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 | |
70 | either 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, | |
75 | allowing the application user to set Motif resource values for | |
76 | individual windows.} | |
77 | ||
78 | \wxheading{Remarks} | |
79 | ||
80 | For 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 | ||
91 | Destructor. 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 | ||
97 | Centres 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 | ||
107 | Simulate 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 | ||
120 | Used in two-step frame construction. See \helpref{wxFrame::wxFrame}{wxframeconstr}\rtfsp | |
121 | for further details. | |
122 | ||
123 | \membersection{wxFrame::CreateStatusBar}\label{wxframecreatestatusbar} | |
124 | ||
125 | \func{virtual bool}{CreateStatusBar}{\param{const int}{ number = 1}} | |
126 | ||
127 | Creates 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 | |
132 | value greater than 1 to create a multi-field status bar.} | |
133 | ||
134 | \wxheading{Return value} | |
135 | ||
136 | TRUE if the status bar was created successfully. | |
137 | ||
138 | \wxheading{Remarks} | |
139 | ||
140 | The width of the status bar is the whole width of the frame (adjusted automatically when | |
141 | resizing), and the height and text size are chosen by the host windowing system. | |
142 | ||
143 | By default, the status bar is an instance of wxStatusBar. To use a different class, | |
144 | override \helpref{wxFrame::OnCreateStatusBar}{wxframeoncreatestatusbar}. | |
145 | ||
146 | Note 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 | ||
158 | Returns 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 | ||
168 | Returns 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 | ||
178 | Gets 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 | ||
185 | Iconizes 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 | ||
199 | Returns TRUE if the frame is iconized. | |
200 | ||
201 | \membersection{wxFrame::LoadAccelerators}\label{wxframeloadaccelerators} | |
202 | ||
203 | \func{void}{LoadAccelerators}{\param{const wxString\& }{table}} | |
204 | ||
205 | Loads 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 | ||
213 | TRUE if the operation was successful, FALSE otherwise. | |
214 | ||
215 | \wxheading{Remarks} | |
216 | ||
217 | Accelerator tables map keystrokes onto control and menu identifiers, so the | |
218 | programmer does not have to explicitly program this correspondence. | |
219 | ||
220 | See the hello demo ({\tt hello.cpp} and {\tt hello.rc}) for | |
221 | an example of accelerator usage. This is a fragment from {\tt hello.rc}: | |
222 | ||
223 | \begin{verbatim} | |
224 | #define HELLO_LOAD_FILE 111 | |
225 | ||
226 | menus_accel ACCELERATORS | |
227 | { | |
228 | ||
229 | "^L", HELLO_LOAD_FILE | |
230 | ||
231 | } | |
232 | \end{verbatim} | |
233 | ||
234 | This 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 | ||
242 | Maximizes 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 | ||
250 | This 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 | ||
260 | Called when a window is activated or deactivated (MS Windows | |
261 | only). If the window is being activated, {\it active} is TRUE, else it | |
262 | is FALSE. | |
263 | ||
264 | If 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 | ||
274 | Virtual 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 | ||
282 | A status bar object. | |
283 | ||
284 | \wxheading{Remarks} | |
285 | ||
286 | An application can override this function to return a different kind of status bar. The default | |
287 | implementation 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 | ||
297 | See \helpref{wxWindow::OnMenuCommand}{wxwindowonmenucommand}. | |
298 | ||
299 | \membersection{wxFrame::OnMenuHighlight}\label{wxframeonmenuhighlight} | |
300 | ||
301 | \func{void}{OnMenuHighlight}{\param{wxMenuEvent\&}{ event}} | |
302 | ||
303 | See \helpref{wxWindow::OnMenuHighlight}{wxwindowonmenuhighlight}. | |
304 | ||
305 | \membersection{wxFrame::OnSize}\label{wxframeonsize} | |
306 | ||
307 | \func{void}{OnSize}{\param{wxSizeEvent\& }{event}} | |
308 | ||
309 | See \helpref{wxWindow::OnSize}{wxwindowonsize}. | |
310 | ||
311 | The default {\bf wxFrame::OnSize} implementation looks for a single subwindow, | |
312 | and if one is found, resizes it to fit | |
313 | inside the frame. Override this member if more complex behaviour | |
314 | is 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 | ||
320 | Sets 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 | ||
328 | The frame takes a `copy' of {\it icon}, but since it uses reference | |
329 | counting, the copy is very quick. It is safe to delete {\it icon} after | |
330 | calling this function. | |
331 | ||
332 | Under Windows, instead of using {\bf SetIcon}, you can add the | |
333 | following lines to your MS Windows resource file: | |
334 | ||
335 | \begin{verbatim} | |
336 | wxSTD_MDIPARENTFRAME ICON icon1.ico | |
337 | wxSTD_MDICHILDFRAME ICON icon2.ico | |
338 | wxSTD_FRAME ICON icon3.ico | |
339 | \end{verbatim} | |
340 | ||
341 | where icon1.ico will be used for the MDI parent frame, icon2.ico | |
342 | will be used for MDI child frames, and icon3.ico will be used for | |
343 | non-MDI frames. | |
344 | ||
345 | If these icons are not supplied, and {\bf SetIcon} is not called either, | |
346 | then the following defaults apply if you have included wx.rc. | |
347 | ||
348 | \begin{verbatim} | |
349 | wxDEFAULT_FRAME ICON std.ico | |
350 | wxDEFAULT_MDIPARENTFRAME ICON mdi.ico | |
351 | wxDEFAULT_MDICHILDFRAME ICON child.ico | |
352 | \end{verbatim} | |
353 | ||
354 | You can replace std.ico, mdi.ico and child.ico with your own defaults | |
355 | for 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 | |
359 | to wxFrame::SetIcon. To work around this until a solution is found, | |
360 | mark your program as a 3.5 application. This will also ensure | |
361 | that Windows provides small icons for the application automatically. | |
362 | ||
363 | See also \helpref{wxIcon}{wxicon}. | |
364 | ||
365 | \membersection{wxFrame::SetMenuBar}\label{wxframesetmenubar} | |
366 | ||
367 | \func{void}{SetMenuBar}{\param{wxMenuBar* }{menuBar}} | |
368 | ||
369 | Tells 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 | ||
377 | If the frame is destroyed, the | |
378 | menu bar and its menus will be destroyed also, so do not delete the menu | |
379 | bar explicitly (except by resetting the frame's menu bar to another | |
380 | frame or NULL). | |
381 | ||
382 | Under Windows, a call to \helpref{wxFrame::OnSize}{wxframeonsize} is generated, so be sure to initialize | |
383 | data members properly before calling {\bf SetMenuBar}. | |
384 | ||
385 | Note 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 | ||
395 | Sets 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 | ||
405 | Use 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 | ||
415 | Sets 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 | |
420 | same 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 | |
423 | in pixels. A value of -1 indicates that the field is variable width; at least one | |
424 | field must be -1. You should delete this array after calling {\bf SetStatusWidths}.} | |
425 | ||
426 | \wxheading{Remarks} | |
427 | ||
428 | The widths of the variable fields are calculated from the total width of all fields, | |
429 | minus the sum of widths of the non-variable fields, divided by the number of | |
430 | variable fields. | |
431 | ||
432 | \membersection{wxFrame::SetTitle}\label{wxframesettitle} | |
433 | ||
434 | \func{virtual void}{SetTitle}{\param{const wxString\& }{ title}} | |
435 | ||
436 | Sets 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 |