1 \section{\class{wxFrame
}}\label{wxframe
}
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.
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.
11 \wxheading{Derived from
}
13 \helpref{wxWindow
}{wxwindow
}\\
14 \helpref{wxEvtHandler
}{wxevthandler
}\\
15 \helpref{wxObject
}{wxobject
}
17 \wxheading{Window styles
}
20 \begin{twocollist
}\itemsep=
0pt
21 \twocolitem{\windowstyle{wxICONIZE
}}{Display the frame iconized (minimized) (Windows only).
}
22 \twocolitem{\windowstyle{wxCAPTION
}}{Puts a caption on the frame.
}
23 \twocolitem{\windowstyle{wxDEFAULT
\_FRAME\_STYLE}}{Defined as
{\bf wxMINIMIZE
\_BOX \pipe wxMAXIMIZE
\_BOX \pipe wxTHICK
\_FRAME \pipe wxSYSTEM
\_MENU \pipe wxCAPTION
}.
}
24 \twocolitem{\windowstyle{wxMINIMIZE
}}{Identical to
{\bf wxICONIZE
}.
}
25 \twocolitem{\windowstyle{wxMINIMIZE
\_BOX}}{Displays a minimize box on the frame (Windows and Motif only).
}
26 \twocolitem{\windowstyle{wxMAXIMIZE
}}{Displays the frame maximized (Windows only).
}
27 \twocolitem{\windowstyle{wxMAXIMIZE
\_BOX}}{Displays a maximize box on the frame (Windows and Motif only).
}
28 \twocolitem{\windowstyle{wxSTAY
\_ON\_TOP}}{Stay on top of other windows (Windows only).
}
29 \twocolitem{\windowstyle{wxSYSTEM
\_MENU}}{Displays a system menu (Windows and Motif only).
}
30 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Displays a thick frame around the window (Windows and Motif only).
}
31 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Displays a resizeable border around the window (Motif only).
}
34 See also
\helpref{window styles overview
}{windowstyles
}.
38 An application should normally define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
39 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
43 \helpref{wxMDIParentFrame
}{wxmdiparentframe
},
\helpref{wxMDIChildFrame
}{wxmdichildframe
},
\rtfsp
44 \helpref{wxMiniFrame
}{wxminiframe
},
\helpref{wxDialog
}{wxdialog
}
46 \latexignore{\rtfignore{\wxheading{Members
}}}
48 \membersection{wxFrame::wxFrame
}\label{wxframeconstr
}
50 \func{}{wxFrame
}{\void}
54 \func{}{wxFrame
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
55 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
56 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
57 \param{const wxString\&
}{name = ``frame"
}}
59 Constructor, creating the window.
61 \wxheading{Parameters
}
63 \docparam{parent
}{The window parent. This may be NULL. If it is non-NULL, the frame will
64 always be displayed on top of the parent window on Windows.
}
66 \docparam{id
}{The window identifier. It may take a value of -
1 to indicate a default value.
}
68 \docparam{title
}{The caption to be displayed on the frame's title bar.
}
70 \docparam{pos
}{The window position. A value of (-
1, -
1) indicates a default position, chosen by
71 either the windowing system or wxWindows, depending on platform.
}
73 \docparam{size
}{The window size. A value of (-
1, -
1) indicates a default size, chosen by
74 either the windowing system or wxWindows, depending on platform.
}
76 \docparam{style
}{The window style. See
\helpref{wxFrame
}{wxframe
}.
}
78 \docparam{name
}{The name of the window. This parameter is used to associate a name with the item,
79 allowing the application user to set Motif resource values for
84 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
85 (otherwise all styles take effect).
89 \helpref{wxFrame::Create
}{wxframecreate
}
91 \membersection{wxFrame::
\destruct{wxFrame
}}
93 \func{void
}{\destruct{wxFrame
}}{\void}
95 Destructor. Destroys all child windows and menu bar if present.
97 \membersection{wxFrame::Centre
}\label{wxframecentre
}
99 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
101 Centres the frame on the display.
103 \wxheading{Parameters
}
105 \docparam{direction
}{The parameter may be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
107 \membersection{wxFrame::Command
}\label{wxframecommand
}
109 \func{void
}{Command
}{\param{int
}{id
}}
111 Simulate a menu command.
113 \wxheading{Parameters
}
115 \docparam{id
}{The identifier for a menu item.
}
117 \membersection{wxFrame::Create
}\label{wxframecreate
}
119 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
120 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
121 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
122 \param{const wxString\&
}{name = ``frame"
}}
124 Used in two-step frame construction. See
\helpref{wxFrame::wxFrame
}{wxframeconstr
}\rtfsp
127 \membersection{wxFrame::CreateStatusBar
}\label{wxframecreatestatusbar
}
129 \func{virtual wxStatusBar*
}{CreateStatusBar
}{\param{int
}{ number =
1},
130 \param{long
}{ style =
0},
131 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "statusBar"
}}
133 Creates a status bar at the bottom of the frame.
135 \wxheading{Parameters
}
137 \docparam{number
}{The number of fields to create. Specify a
138 value greater than
1 to create a multi-field status bar.
}
140 \docparam{style
}{The status bar style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
143 \docparam{id
}{The status bar window identifier. If -
1, an identifier will be chosen by
146 \docparam{name
}{The status bar window name.
}
148 \wxheading{Return value
}
150 A pointer to the the status bar if it was created successfully, NULL otherwise.
154 The width of the status bar is the whole width of the frame (adjusted automatically when
155 resizing), and the height and text size are chosen by the host windowing system.
157 By default, the status bar is an instance of wxStatusBar. To use a different class,
158 override
\helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
}.
160 Note that you can put controls and other windows on the status bar if you wish.
164 \helpref{wxFrame::SetStatusText
}{wxframesetstatustext
},
\rtfsp
165 \helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
},
\rtfsp
166 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
168 \membersection{wxFrame::CreateToolBar
}\label{wxframecreatetoolbar
}
170 \func{virtual wxToolBar*
}{CreateToolBar
}{\param{long
}{ style = wxNO
\_BORDER \pipe wxTB
\_HORIZONTAL},
171 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "toolBar"
}}
173 Creates a toolbar at the top or left of the frame.
175 \wxheading{Parameters
}
177 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
180 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
183 \docparam{name
}{The toolbar window name.
}
185 \wxheading{Return value
}
187 A pointer to the the toolbar if it was created successfully, NULL otherwise.
191 By default, the toolbar is an instance of wxToolBar (which is defined to be
192 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
193 override
\helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
}.
195 When a toolbar has been created with this function, or made known to the frame
196 with
\helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}, the frame will manage the toolbar
197 position and adjust the return value from
\helpref{wxWindow::GetClientSize
}{wxwindowgetclientsize
} to
198 reflect the available space for application windows.
202 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\rtfsp
203 \helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
},
\rtfsp
204 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
},
\rtfsp
205 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
207 \membersection{wxFrame::GetMenuBar
}\label{wxframegetmenubar
}
209 \constfunc{wxMenuBar*
}{GetMenuBar
}{\void}
211 Returns a pointer to the menubar currently associated with the frame (if any).
215 \helpref{wxFrame::SetMenuBar
}{wxframesetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
217 \membersection{wxFrame::GetStatusBar
}\label{wxframegetstatusbar
}
219 \func{wxStatusBar*
}{GetStatusBar
}{\void}
221 Returns a pointer to the status bar currently associated with the frame (if any).
225 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
227 \membersection{wxFrame::GetTitle
}\label{wxframegettitle
}
229 \func{wxString\&
}{GetTitle
}{\void}
231 Gets a temporary pointer to the frame title. See
232 \helpref{wxFrame::SetTitle
}{wxframesettitle
}.
234 \membersection{wxFrame::GetToolBar
}\label{wxframegettoolbar
}
236 \func{wxToolBar*
}{GetToolBar
}{\void}
238 Returns a pointer to the toolbar currently associated with the frame (if any).
242 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
243 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}
245 \membersection{wxFrame::Iconize
}\label{wxframeiconize
}
247 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
249 Iconizes or restores the frame.
251 \wxheading{Parameters
}
253 \docparam{izonize
}{If TRUE, iconizes the frame; if FALSE, shows and restores it.
}
257 \helpref{wxFrame::IsIconized
}{wxframeisiconized
},
\helpref{wxFrame::Maximize
}{wxframemaximize
}.
259 \membersection{wxFrame::IsIconized
}\label{wxframeisiconized
}
261 \func{bool
}{IsIconized
}{\void}
263 Returns TRUE if the frame is iconized.
265 \membersection{wxFrame::LoadAccelerators
}\label{wxframeloadaccelerators
}
267 \func{void
}{LoadAccelerators
}{\param{const wxString\&
}{table
}}
269 Loads a keyboard accelerator table for this frame.
271 \wxheading{Parameters
}
273 \docparam{table
}{Accelerator table to load.
}
275 \wxheading{Return value
}
277 TRUE if the operation was successful, FALSE otherwise.
281 Accelerator tables map keystrokes onto control and menu identifiers, so the
282 programmer does not have to explicitly program this correspondence.
284 See the hello demo (
{\tt hello.cpp
} and
{\tt hello.rc
}) for
285 an example of accelerator usage. This is a fragment from
{\tt hello.rc
}:
288 #define HELLO_LOAD_FILE
111
290 menus_accel ACCELERATORS
293 "^L", HELLO_LOAD_FILE
298 This function only works under Windows.
300 % huh? If you call LoadAccelerators, you need to override wxFrame::OnActivate to do nothing.
302 \membersection{wxFrame::Maximize
}\label{wxframemaximize
}
304 \func{void
}{Maximize
}{\param{const bool
}{maximize
}}
306 Maximizes or restores the frame.
308 \wxheading{Parameters
}
310 \docparam{maximize
}{If TRUE, maximizes the frame, otherwise it restores it
}.
314 This function only works under Windows.
318 \helpref{wxFrame::Iconize
}{wxframeiconize
}
320 \membersection{wxFrame::OnActivate
}
322 \func{void
}{OnActivate
}{\param{bool
}{ active
}}
324 Called when a window is activated or deactivated (MS Windows
325 only). If the window is being activated,
{\it active
} is TRUE, else it
328 If you call wxFrame::LoadAccelerators, you need to override this function e.g.
331 void OnActivate(bool)
{};
334 \membersection{wxFrame::OnCreateStatusBar
}\label{wxframeoncreatestatusbar
}
336 \func{virtual wxStatusBar*
}{OnCreateStatusBar
}{\param{int
}{number
}
337 \param{long
}{ style
},
338 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
340 Virtual function called when a status bar is requested by
\helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
}.
342 \wxheading{Parameters
}
344 \docparam{number
}{The number of fields to create.
}
346 \docparam{style
}{The window style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
349 \docparam{id
}{The window identifier. If -
1, an identifier will be chosen by
352 \docparam{name
}{The window name.
}
354 \wxheading{Return value
}
360 An application can override this function to return a different kind of status bar. The default
361 implementation returns an instance of
\helpref{wxStatusBar
}{wxstatusbar
}.
365 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}.
367 \membersection{wxFrame::OnCreateToolBar
}\label{wxframeoncreatetoolbar
}
369 \func{virtual wxToolBar*
}{OnCreateToolBar
}{\param{long
}{ style
},
370 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
372 Virtual function called when a toolbar is requested by
\helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
}.
374 \wxheading{Parameters
}
376 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
379 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
382 \docparam{name
}{The toolbar window name.
}
384 \wxheading{Return value
}
390 An application can override this function to return a different kind of toolbar. The default
391 implementation returns an instance of
\helpref{wxToolBar
}{wxtoolbar
}.
395 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
}.
397 \membersection{wxFrame::OnMenuCommand
}\label{wxframeonmenucommand
}
399 \func{void
}{OnMenuCommand
}{\param{wxCommandEvent\&
}{ event
}}
401 See
\helpref{wxWindow::OnMenuCommand
}{wxwindowonmenucommand
}.
403 \membersection{wxFrame::OnMenuHighlight
}\label{wxframeonmenuhighlight
}
405 \func{void
}{OnMenuHighlight
}{\param{wxMenuEvent\&
}{ event
}}
407 See
\helpref{wxWindow::OnMenuHighlight
}{wxwindowonmenuhighlight
}.
409 \membersection{wxFrame::OnSize
}\label{wxframeonsize
}
411 \func{void
}{OnSize
}{\param{wxSizeEvent\&
}{event
}}
413 See
\helpref{wxWindow::OnSize
}{wxwindowonsize
}.
415 The default
{\bf wxFrame::OnSize
} implementation looks for a single subwindow,
416 and if one is found, resizes it to fit
417 inside the frame. Override this member if more complex behaviour
418 is required (for example, if there are several subwindows).
420 \membersection{wxFrame::SetIcon
}\label{wxframeseticon
}
422 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
424 Sets the icon for this frame.
426 \wxheading{Parameters
}
428 \docparam{icon
}{The icon to associate with this frame.
}
432 The frame takes a `copy' of
{\it icon
}, but since it uses reference
433 counting, the copy is very quick. It is safe to delete
{\it icon
} after
434 calling this function.
436 Under Windows, instead of using
{\bf SetIcon
}, you can add the
437 following lines to your MS Windows resource file:
440 wxSTD_MDIPARENTFRAME ICON icon1.ico
441 wxSTD_MDICHILDFRAME ICON icon2.ico
442 wxSTD_FRAME ICON icon3.ico
445 where icon1.ico will be used for the MDI parent frame, icon2.ico
446 will be used for MDI child frames, and icon3.ico will be used for
449 If these icons are not supplied, and
{\bf SetIcon
} is not called either,
450 then the following defaults apply if you have included wx.rc.
453 wxDEFAULT_FRAME ICON std.ico
454 wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
455 wxDEFAULT_MDICHILDFRAME ICON child.ico
458 You can replace std.ico, mdi.ico and child.ico with your own defaults
459 for all your wxWindows application. Currently they show the same icon.
461 {\it Note:
} a wxWindows application linked with subsystem equal to
4.0
462 (i.e. marked as a Windows
95 application) doesn't respond properly
463 to wxFrame::SetIcon. To work around this until a solution is found,
464 mark your program as a
3.5 application. This will also ensure
465 that Windows provides small icons for the application automatically.
467 See also
\helpref{wxIcon
}{wxicon
}.
469 \membersection{wxFrame::SetMenuBar
}\label{wxframesetmenubar
}
471 \func{void
}{SetMenuBar
}{\param{wxMenuBar*
}{menuBar
}}
473 Tells the frame to show the given menu bar.
475 \wxheading{Parameters
}
477 \docparam{menuBar
}{The menu bar to associate with the frame.
}
481 If the frame is destroyed, the
482 menu bar and its menus will be destroyed also, so do not delete the menu
483 bar explicitly (except by resetting the frame's menu bar to another
486 Under Windows, a call to
\helpref{wxFrame::OnSize
}{wxframeonsize
} is generated, so be sure to initialize
487 data members properly before calling
{\bf SetMenuBar
}.
489 Note that it is not possible to call this function twice for the same frame object.
493 \helpref{wxFrame::GetMenuBar
}{wxframegetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}.
495 \membersection{wxFrame::SetStatusBar
}\label{wxframesetstatusbar
}
497 \func{void
}{SetStatusBar
}{\param{wxStatusBar*
}{ statusBar
}}
499 Associates a status bar with the frame.
503 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
},
\rtfsp
504 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
506 \membersection{wxFrame::SetStatusText
}\label{wxframesetstatustext
}
508 \func{virtual void
}{SetStatusText
}{\param{const wxString\&
}{ text
},
\param{int
}{ number =
0}}
510 Sets the status bar text and redraws the status bar.
512 \wxheading{Parameters
}
514 \docparam{text
}{The text for the status field.
}
516 \docparam{number
}{The status field (starting from zero).
}
520 Use an empty string to clear the status bar.
524 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
526 \membersection{wxFrame::SetStatusWidths
}\label{wxframesetstatuswidths
}
528 \func{virtual void
}{SetStatusWidths
}{\param{int
}{ n
},
\param{int *
}{widths
}}
530 Sets the widths of the fields in the status bar.
532 \wxheading{Parameters
}
534 \wxheading{n
}{The number of fields in the status bar. It must be the
535 same used in
\helpref{CreateStatusBar
}{wxframecreatestatusbar
}.
}
537 \docparam{widths
}{Must contain an array of
{\it n
} integers, each of which is a status field width
538 in pixels. A value of -
1 indicates that the field is variable width; at least one
539 field must be -
1. You should delete this array after calling
{\bf SetStatusWidths
}.
}
543 The widths of the variable fields are calculated from the total width of all fields,
544 minus the sum of widths of the non-variable fields, divided by the number of
547 \membersection{wxFrame::SetToolBar
}\label{wxframesettoolbar
}
549 \func{void
}{SetToolBar
}{\param{wxToolBar*
}{ toolBar
}}
551 Associates a toolbar with the frame.
555 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
556 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
558 \membersection{wxFrame::SetTitle
}\label{wxframesettitle
}
560 \func{virtual void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
562 Sets the frame title.
564 \wxheading{Parameters
}
566 \docparam{title
}{The frame title.
}
570 \helpref{wxFrame::GetTitle
}{wxframegettitle
}