1 \section{\class{wxFrame
}}\label{wxframe
}
3 A frame is a window whose size and position can (usually) be changed by the
4 user. It usually has thick borders and a title bar, and can optionally contain
5 a menu bar, toolbar and status bar. A frame can contain any window that is not
8 A frame that has a status bar and toolbar created via the
9 CreateStatusBar/CreateToolBar functions manages these windows, and adjusts the
10 value returned by GetClientSize to reflect the remaining size available to
13 \wxheading{Derived from
}
15 \helpref{wxWindow
}{wxwindow
}\\
16 \helpref{wxEvtHandler
}{wxevthandler
}\\
17 \helpref{wxObject
}{wxobject
}
19 \wxheading{Include files
}
23 \wxheading{Window styles
}
26 \begin{twocollist
}\itemsep=
0pt
27 \twocolitem{\windowstyle{wxICONIZE
}}{Display the frame iconized (minimized). Windows only.
}
28 \twocolitem{\windowstyle{wxCAPTION
}}{Puts a caption on the frame.
}
29 \twocolitem{\windowstyle{wxDEFAULT
\_FRAME\_STYLE}}{Defined as
{\bf wxMINIMIZE
\_BOX \pipe wxMAXIMIZE
\_BOX \pipe wxTHICK
\_FRAME \pipe wxSYSTEM
\_MENU \pipe wxCAPTION
}.
}
30 \twocolitem{\windowstyle{wxMINIMIZE
}}{Identical to
{\bf wxICONIZE
}. Windows only.
}
31 \twocolitem{\windowstyle{wxMINIMIZE
\_BOX}}{Displays a minimize box on the frame.
}
32 \twocolitem{\windowstyle{wxMAXIMIZE
}}{Displays the frame maximized. Windows only.
}
33 \twocolitem{\windowstyle{wxMAXIMIZE
\_BOX}}{Displays a maximize box on the frame.
}
34 \twocolitem{\windowstyle{wxSTAY
\_ON\_TOP}}{Stay on top of other windows. Windows only.
}
35 \twocolitem{\windowstyle{wxSYSTEM
\_MENU}}{Displays a system menu.
}
36 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Displays a thick frame around the window. Windows and Motif only.
}
37 \twocolitem{\windowstyle{wxSIMPLE
\_BORDER}}{Displays no border or decorations. GTK and Windows only (?).
}
38 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Displays a resizeable border around the window (Unix only).
}
39 \twocolitem{\windowstyle{wxFRAME
\_FLOAT\_ON\_PARENT}}{Causes the frame to be above the parent window in the
40 z-order and not shown in the taskbar. Without this style, frames are created as top-level windows that may be obscured by
41 the parent window, and frame titles are shown in the taskbar. Windows only.
}
42 \twocolitem{\windowstyle{wxFRAME
\_TOOL\_WINDOW}}{Causes a frame with a small titlebar to be created;
43 the frame title does not appear in the taskbar. Windows only.
}
46 See also
\helpref{window styles overview
}{windowstyles
}.
50 An application should normally define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
51 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
55 \helpref{wxMDIParentFrame
}{wxmdiparentframe
},
\helpref{wxMDIChildFrame
}{wxmdichildframe
},
\rtfsp
56 \helpref{wxMiniFrame
}{wxminiframe
},
\helpref{wxDialog
}{wxdialog
}
58 \latexignore{\rtfignore{\wxheading{Members
}}}
60 \membersection{wxFrame::wxFrame
}\label{wxframeconstr
}
62 \func{}{wxFrame
}{\void}
66 \func{}{wxFrame
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
67 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
68 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
69 \param{const wxString\&
}{name = ``frame"
}}
71 Constructor, creating the window.
73 \wxheading{Parameters
}
75 \docparam{parent
}{The window parent. This may be NULL. If it is non-NULL, the frame will
76 always be displayed on top of the parent window on Windows.
}
78 \docparam{id
}{The window identifier. It may take a value of -
1 to indicate a default value.
}
80 \docparam{title
}{The caption to be displayed on the frame's title bar.
}
82 \docparam{pos
}{The window position. A value of (-
1, -
1) indicates a default position, chosen by
83 either the windowing system or wxWindows, depending on platform.
}
85 \docparam{size
}{The window size. A value of (-
1, -
1) indicates a default size, chosen by
86 either the windowing system or wxWindows, depending on platform.
}
88 \docparam{style
}{The window style. See
\helpref{wxFrame
}{wxframe
}.
}
90 \docparam{name
}{The name of the window. This parameter is used to associate a name with the item,
91 allowing the application user to set Motif resource values for
96 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
97 (otherwise all styles take effect).
101 \helpref{wxFrame::Create
}{wxframecreate
}
103 \membersection{wxFrame::
\destruct{wxFrame
}}
105 \func{void
}{\destruct{wxFrame
}}{\void}
107 Destructor. Destroys all child windows and menu bar if present.
109 \membersection{wxFrame::Centre
}\label{wxframecentre
}
111 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
113 Centres the frame on the display.
115 \wxheading{Parameters
}
117 \docparam{direction
}{The parameter may be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
119 \membersection{wxFrame::Command
}\label{wxframecommand
}
121 \func{void
}{Command
}{\param{int
}{id
}}
123 Simulate a menu command.
125 \wxheading{Parameters
}
127 \docparam{id
}{The identifier for a menu item.
}
129 \membersection{wxFrame::Create
}\label{wxframecreate
}
131 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
132 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
133 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
134 \param{const wxString\&
}{name = ``frame"
}}
136 Used in two-step frame construction. See
\helpref{wxFrame::wxFrame
}{wxframeconstr
}\rtfsp
139 \membersection{wxFrame::CreateStatusBar
}\label{wxframecreatestatusbar
}
141 \func{virtual wxStatusBar*
}{CreateStatusBar
}{\param{int
}{ number =
1},
142 \param{long
}{ style =
0},
143 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "statusBar"
}}
145 Creates a status bar at the bottom of the frame.
147 \wxheading{Parameters
}
149 \docparam{number
}{The number of fields to create. Specify a
150 value greater than
1 to create a multi-field status bar.
}
152 \docparam{style
}{The status bar style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
155 \docparam{id
}{The status bar window identifier. If -
1, an identifier will be chosen by
158 \docparam{name
}{The status bar window name.
}
160 \wxheading{Return value
}
162 A pointer to the the status bar if it was created successfully, NULL otherwise.
166 The width of the status bar is the whole width of the frame (adjusted automatically when
167 resizing), and the height and text size are chosen by the host windowing system.
169 By default, the status bar is an instance of wxStatusBar. To use a different class,
170 override
\helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
}.
172 Note that you can put controls and other windows on the status bar if you wish.
176 \helpref{wxFrame::SetStatusText
}{wxframesetstatustext
},
\rtfsp
177 \helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
},
\rtfsp
178 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
180 \membersection{wxFrame::CreateToolBar
}\label{wxframecreatetoolbar
}
182 \func{virtual wxToolBar*
}{CreateToolBar
}{\param{long
}{ style = wxNO
\_BORDER \pipe wxTB
\_HORIZONTAL},
183 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "toolBar"
}}
185 Creates a toolbar at the top or left of the frame.
187 \wxheading{Parameters
}
189 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
192 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
195 \docparam{name
}{The toolbar window name.
}
197 \wxheading{Return value
}
199 A pointer to the the toolbar if it was created successfully, NULL otherwise.
203 By default, the toolbar is an instance of wxToolBar (which is defined to be
204 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
205 override
\helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
}.
207 When a toolbar has been created with this function, or made known to the frame
208 with
\helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}, the frame will manage the toolbar
209 position and adjust the return value from
\helpref{wxWindow::GetClientSize
}{wxwindowgetclientsize
} to
210 reflect the available space for application windows.
214 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\rtfsp
215 \helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
},
\rtfsp
216 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
},
\rtfsp
217 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
219 \membersection{wxFrame::GetClientAreaOrigin
}\label{wxframegetclientareaorigin
}
221 \constfunc{wxPoint
}{GetClientAreaOrigin
}{\void}
223 Returns the origin of the frame client area (in client coordinates). It may be
224 different from (
0,
0) if the frame has a toolbar.
226 \membersection{wxFrame::GetMenuBar
}\label{wxframegetmenubar
}
228 \constfunc{wxMenuBar*
}{GetMenuBar
}{\void}
230 Returns a pointer to the menubar currently associated with the frame (if any).
234 \helpref{wxFrame::SetMenuBar
}{wxframesetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
236 \membersection{wxFrame::GetStatusBar
}\label{wxframegetstatusbar
}
238 \func{wxStatusBar*
}{GetStatusBar
}{\void}
240 Returns a pointer to the status bar currently associated with the frame (if any).
244 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
246 \membersection{wxFrame::GetTitle
}\label{wxframegettitle
}
248 \func{wxString\&
}{GetTitle
}{\void}
250 Gets a temporary pointer to the frame title. See
251 \helpref{wxFrame::SetTitle
}{wxframesettitle
}.
253 \membersection{wxFrame::GetToolBar
}\label{wxframegettoolbar
}
255 \func{wxToolBar*
}{GetToolBar
}{\void}
257 Returns a pointer to the toolbar currently associated with the frame (if any).
261 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
262 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}
264 \membersection{wxFrame::Iconize
}\label{wxframeiconize
}
266 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
268 Iconizes or restores the frame. Windows only.
270 \wxheading{Parameters
}
272 \docparam{izonize
}{If TRUE, iconizes the frame; if FALSE, shows and restores it.
}
276 \helpref{wxFrame::IsIconized
}{wxframeisiconized
},
\helpref{wxFrame::Maximize
}{wxframemaximize
}.
278 \membersection{wxFrame::IsIconized
}\label{wxframeisiconized
}
280 \constfunc{bool
}{IsIconized
}{\void}
282 Returns TRUE if the frame is iconized. Windows only.
284 \membersection{wxFrame::IsMaximized
}\label{wxframeismaximized
}
286 \constfunc{bool
}{IsMaximized
}{\void}
288 Returns TRUE if the frame is maximized.
290 \membersection{wxFrame::Maximize
}\label{wxframemaximize
}
292 \func{void
}{Maximize
}{\param{const bool
}{maximize
}}
294 Maximizes or restores the frame.
296 \wxheading{Parameters
}
298 \docparam{maximize
}{If TRUE, maximizes the frame, otherwise it restores it
}.
302 This function only works under Windows.
306 \helpref{wxFrame::Iconize
}{wxframeiconize
}
308 \membersection{wxFrame::OnActivate
}
310 \func{void
}{OnActivate
}{\param{wxActivateEvent\&
}{ event
}}
312 Called when a window is activated or deactivated (MS Windows
313 only). See also
\helpref{wxActivateEvent
}{wxactivateevent
}.
315 \membersection{wxFrame::OnCreateStatusBar
}\label{wxframeoncreatestatusbar
}
317 \func{virtual wxStatusBar*
}{OnCreateStatusBar
}{\param{int
}{number
},
318 \param{long
}{ style
},
319 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
321 Virtual function called when a status bar is requested by
\helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
}.
323 \wxheading{Parameters
}
325 \docparam{number
}{The number of fields to create.
}
327 \docparam{style
}{The window style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
330 \docparam{id
}{The window identifier. If -
1, an identifier will be chosen by
333 \docparam{name
}{The window name.
}
335 \wxheading{Return value
}
341 An application can override this function to return a different kind of status bar. The default
342 implementation returns an instance of
\helpref{wxStatusBar
}{wxstatusbar
}.
346 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}.
348 \membersection{wxFrame::OnCreateToolBar
}\label{wxframeoncreatetoolbar
}
350 \func{virtual wxToolBar*
}{OnCreateToolBar
}{\param{long
}{ style
},
351 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
353 Virtual function called when a toolbar is requested by
\helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
}.
355 \wxheading{Parameters
}
357 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
360 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
363 \docparam{name
}{The toolbar window name.
}
365 \wxheading{Return value
}
371 An application can override this function to return a different kind of toolbar. The default
372 implementation returns an instance of
\helpref{wxToolBar
}{wxtoolbar
}.
376 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
}.
378 \membersection{wxFrame::OnMenuCommand
}\label{wxframeonmenucommand
}
380 \func{void
}{OnMenuCommand
}{\param{wxCommandEvent\&
}{ event
}}
382 See
\helpref{wxWindow::OnMenuCommand
}{wxwindowonmenucommand
}.
384 \membersection{wxFrame::OnMenuHighlight
}\label{wxframeonmenuhighlight
}
386 \func{void
}{OnMenuHighlight
}{\param{wxMenuEvent\&
}{ event
}}
388 See
\helpref{wxWindow::OnMenuHighlight
}{wxwindowonmenuhighlight
}.
390 \membersection{wxFrame::OnSize
}\label{wxframeonsize
}
392 \func{void
}{OnSize
}{\param{wxSizeEvent\&
}{event
}}
394 See
\helpref{wxWindow::OnSize
}{wxwindowonsize
}.
396 The default
{\bf wxFrame::OnSize
} implementation looks for a single subwindow,
397 and if one is found, resizes it to fit
398 inside the frame. Override this member if more complex behaviour
399 is required (for example, if there are several subwindows).
401 \membersection{wxFrame::SetIcon
}\label{wxframeseticon
}
403 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
405 Sets the icon for this frame.
407 \wxheading{Parameters
}
409 \docparam{icon
}{The icon to associate with this frame.
}
413 The frame takes a `copy' of
{\it icon
}, but since it uses reference
414 counting, the copy is very quick. It is safe to delete
{\it icon
} after
415 calling this function.
417 Under Windows, instead of using
{\bf SetIcon
}, you can add the
418 following lines to your MS Windows resource file:
421 wxSTD_MDIPARENTFRAME ICON icon1.ico
422 wxSTD_MDICHILDFRAME ICON icon2.ico
423 wxSTD_FRAME ICON icon3.ico
426 where icon1.ico will be used for the MDI parent frame, icon2.ico
427 will be used for MDI child frames, and icon3.ico will be used for
430 If these icons are not supplied, and
{\bf SetIcon
} is not called either,
431 then the following defaults apply if you have included wx.rc.
434 wxDEFAULT_FRAME ICON std.ico
435 wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
436 wxDEFAULT_MDICHILDFRAME ICON child.ico
439 You can replace std.ico, mdi.ico and child.ico with your own defaults
440 for all your wxWindows application. Currently they show the same icon.
442 {\it Note:
} a wxWindows application linked with subsystem equal to
4.0
443 (i.e. marked as a Windows
95 application) doesn't respond properly
444 to wxFrame::SetIcon. To work around this until a solution is found,
445 mark your program as a
3.5 application. This will also ensure
446 that Windows provides small icons for the application automatically.
448 See also
\helpref{wxIcon
}{wxicon
}.
450 \membersection{wxFrame::SetMenuBar
}\label{wxframesetmenubar
}
452 \func{void
}{SetMenuBar
}{\param{wxMenuBar*
}{menuBar
}}
454 Tells the frame to show the given menu bar.
456 \wxheading{Parameters
}
458 \docparam{menuBar
}{The menu bar to associate with the frame.
}
462 If the frame is destroyed, the
463 menu bar and its menus will be destroyed also, so do not delete the menu
464 bar explicitly (except by resetting the frame's menu bar to another
467 Under Windows, a call to
\helpref{wxFrame::OnSize
}{wxframeonsize
} is generated, so be sure to initialize
468 data members properly before calling
{\bf SetMenuBar
}.
470 Note that it is not possible to call this function twice for the same frame object.
474 \helpref{wxFrame::GetMenuBar
}{wxframegetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}.
476 \membersection{wxFrame::SetStatusBar
}\label{wxframesetstatusbar
}
478 \func{void
}{SetStatusBar
}{\param{wxStatusBar*
}{ statusBar
}}
480 Associates a status bar with the frame.
484 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
},
\rtfsp
485 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
487 \membersection{wxFrame::SetStatusText
}\label{wxframesetstatustext
}
489 \func{virtual void
}{SetStatusText
}{\param{const wxString\&
}{ text
},
\param{int
}{ number =
0}}
491 Sets the status bar text and redraws the status bar.
493 \wxheading{Parameters
}
495 \docparam{text
}{The text for the status field.
}
497 \docparam{number
}{The status field (starting from zero).
}
501 Use an empty string to clear the status bar.
505 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
507 \membersection{wxFrame::SetStatusWidths
}\label{wxframesetstatuswidths
}
509 \func{virtual void
}{SetStatusWidths
}{\param{int
}{ n
},
\param{int *
}{widths
}}
511 Sets the widths of the fields in the status bar.
513 \wxheading{Parameters
}
515 \wxheading{n
}{The number of fields in the status bar. It must be the
516 same used in
\helpref{CreateStatusBar
}{wxframecreatestatusbar
}.
}
518 \docparam{widths
}{Must contain an array of
{\it n
} integers, each of which is a status field width
519 in pixels. A value of -
1 indicates that the field is variable width; at least one
520 field must be -
1. You should delete this array after calling
{\bf SetStatusWidths
}.
}
524 The widths of the variable fields are calculated from the total width of all fields,
525 minus the sum of widths of the non-variable fields, divided by the number of
528 \pythonnote{Only a single parameter is required, a Python list of
532 \membersection{wxFrame::SetToolBar
}\label{wxframesettoolbar
}
534 \func{void
}{SetToolBar
}{\param{wxToolBar*
}{ toolBar
}}
536 Associates a toolbar with the frame.
540 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
541 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
543 \membersection{wxFrame::SetTitle
}\label{wxframesettitle
}
545 \func{virtual void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
547 Sets the frame title.
549 \wxheading{Parameters
}
551 \docparam{title
}{The frame title.
}
555 \helpref{wxFrame::GetTitle
}{wxframegettitle
}