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{wxDEFAULT
\_FRAME\_STYLE}}{Defined as
{\bf wxMINIMIZE
\_BOX \pipe wxMAXIMIZE
\_BOX \pipe wxRESIZE
\_BOX \pipe wxSYSTEM
\_MENU \pipe wxCAPTION
}.
}
28 \twocolitem{\windowstyle{wxICONIZE
}}{Display the frame iconized (minimized). Windows only.
}
29 \twocolitem{\windowstyle{wxCAPTION
}}{Puts a caption on the frame.
}
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{wxSIMPLE
\_BORDER}}{Displays no border or decorations. GTK and Windows only.
}
37 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Displays a resizeable border around the window.
}
38 \twocolitem{\windowstyle{wxFRAME
\_TOOL\_WINDOW}}{Causes a frame with a small
39 titlebar to be created; the frame does not appear in the taskbar under Windows.
}
40 \twocolitem{\windowstyle{wxFRAME
\_NO\_TASKBAR}}{Creates a normal frame but if
41 this frame has a parent it does not appear in the taskbar under Windows. Note
42 that a frame without parent will still appear in the taskbar even with this
43 style. Has no effect under other platforms.
}
44 \twocolitem{\windowstyle{wxFRAME
\_FLOAT\_ON\_PARENT}}{Unused any longer, use
45 wxFRAME
\_TOOL\_WINDOW or wxFRAME
\_NO\_TASKBAR instead
}
46 \twocolitem{\windowstyle{wxFRAME
\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
47 caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send
48 a wxEVT
\_HELP event if the user clicked on an application window.
{\it Note
} that this is an extended
49 style and must be set by calling
\helpref{SetExtraStyle
}{wxwindowsetextrastyle
} before Create is called (two-step construction).
50 You cannot use this style together with wxMAXIMIZE
\_BOX or wxMINIMIZE
\_BOX, so
52 {\tt wxDEFAULT
\_FRAME\_STYLE & ~(wxMINIMIZE
\_BOX | wxMAXIMIZE
\_BOX)
} for the
53 frames having this style (the dialogs don't have minimize nor maximize box by
57 The default frame style is for normal, resizeable frames. To create a frame
58 which can not be resized by user, you may use the following combination of
59 styles:
{\tt wxDEFAULT
\_FRAME\_STYLE \& \~ (wxRESIZE
\_BORDER \pipe wxRESIZE
\_BOX \pipe wxMAXIMIZE
\_BOX)
}.
60 % Note: the space after the tilde is necessary or Tex2RTF complains.
62 See also
\helpref{window styles overview
}{windowstyles
}.
66 An application should normally define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
67 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
71 \helpref{wxMDIParentFrame
}{wxmdiparentframe
},
\helpref{wxMDIChildFrame
}{wxmdichildframe
},
\rtfsp
72 \helpref{wxMiniFrame
}{wxminiframe
},
\helpref{wxDialog
}{wxdialog
}
74 \latexignore{\rtfignore{\wxheading{Members
}}}
76 \membersection{wxFrame::wxFrame
}\label{wxframeconstr
}
78 \func{}{wxFrame
}{\void}
82 \func{}{wxFrame
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
83 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
84 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
85 \param{const wxString\&
}{name = ``frame"
}}
87 Constructor, creating the window.
89 \wxheading{Parameters
}
91 \docparam{parent
}{The window parent. This may be NULL. If it is non-NULL, the frame will
92 always be displayed on top of the parent window on Windows.
}
94 \docparam{id
}{The window identifier. It may take a value of -
1 to indicate a default value.
}
96 \docparam{title
}{The caption to be displayed on the frame's title bar.
}
98 \docparam{pos
}{The window position. A value of (-
1, -
1) indicates a default position, chosen by
99 either the windowing system or wxWindows, depending on platform.
}
101 \docparam{size
}{The window size. A value of (-
1, -
1) indicates a default size, chosen by
102 either the windowing system or wxWindows, depending on platform.
}
104 \docparam{style
}{The window style. See
\helpref{wxFrame
}{wxframe
}.
}
106 \docparam{name
}{The name of the window. This parameter is used to associate a name with the item,
107 allowing the application user to set Motif resource values for
112 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
113 (otherwise all styles take effect).
117 \helpref{wxFrame::Create
}{wxframecreate
}
119 \membersection{wxFrame::
\destruct{wxFrame
}}
121 \func{void
}{\destruct{wxFrame
}}{\void}
123 Destructor. Destroys all child windows and menu bar if present.
125 \membersection{wxFrame::Centre
}\label{wxframecentre
}
127 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
129 Centres the frame on the display.
131 \wxheading{Parameters
}
133 \docparam{direction
}{The parameter may be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
135 \membersection{wxFrame::Command
}\label{wxframecommand
}
137 \func{void
}{Command
}{\param{int
}{id
}}
139 Simulate a menu command.
141 \wxheading{Parameters
}
143 \docparam{id
}{The identifier for a menu item.
}
145 \membersection{wxFrame::Create
}\label{wxframecreate
}
147 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
148 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
149 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
150 \param{const wxString\&
}{name = ``frame"
}}
152 Used in two-step frame construction. See
\helpref{wxFrame::wxFrame
}{wxframeconstr
}\rtfsp
155 \membersection{wxFrame::CreateStatusBar
}\label{wxframecreatestatusbar
}
157 \func{virtual wxStatusBar*
}{CreateStatusBar
}{\param{int
}{ number =
1},
158 \param{long
}{ style =
0},
159 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "statusBar"
}}
161 Creates a status bar at the bottom of the frame.
163 \wxheading{Parameters
}
165 \docparam{number
}{The number of fields to create. Specify a
166 value greater than
1 to create a multi-field status bar.
}
168 \docparam{style
}{The status bar style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
171 \docparam{id
}{The status bar window identifier. If -
1, an identifier will be chosen by
174 \docparam{name
}{The status bar window name.
}
176 \wxheading{Return value
}
178 A pointer to the the status bar if it was created successfully, NULL otherwise.
182 The width of the status bar is the whole width of the frame (adjusted automatically when
183 resizing), and the height and text size are chosen by the host windowing system.
185 By default, the status bar is an instance of wxStatusBar. To use a different class,
186 override
\helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
}.
188 Note that you can put controls and other windows on the status bar if you wish.
192 \helpref{wxFrame::SetStatusText
}{wxframesetstatustext
},
\rtfsp
193 \helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
},
\rtfsp
194 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
196 \membersection{wxFrame::CreateToolBar
}\label{wxframecreatetoolbar
}
198 \func{virtual wxToolBar*
}{CreateToolBar
}{\param{long
}{ style = wxNO
\_BORDER \pipe wxTB
\_HORIZONTAL},
199 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "toolBar"
}}
201 Creates a toolbar at the top or left of the frame.
203 \wxheading{Parameters
}
205 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
208 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
211 \docparam{name
}{The toolbar window name.
}
213 \wxheading{Return value
}
215 A pointer to the the toolbar if it was created successfully, NULL otherwise.
219 By default, the toolbar is an instance of wxToolBar (which is defined to be
220 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
221 override
\helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
}.
223 When a toolbar has been created with this function, or made known to the frame
224 with
\helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}, the frame will manage the toolbar
225 position and adjust the return value from
\helpref{wxWindow::GetClientSize
}{wxwindowgetclientsize
} to
226 reflect the available space for application windows.
230 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\rtfsp
231 \helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
},
\rtfsp
232 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
},
\rtfsp
233 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
235 \membersection{wxFrame::GetClientAreaOrigin
}\label{wxframegetclientareaorigin
}
237 \constfunc{wxPoint
}{GetClientAreaOrigin
}{\void}
239 Returns the origin of the frame client area (in client coordinates). It may be
240 different from (
0,
0) if the frame has a toolbar.
242 \membersection{wxFrame::GetMenuBar
}\label{wxframegetmenubar
}
244 \constfunc{wxMenuBar*
}{GetMenuBar
}{\void}
246 Returns a pointer to the menubar currently associated with the frame (if any).
250 \helpref{wxFrame::SetMenuBar
}{wxframesetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
252 \membersection{wxFrame::GetStatusBar
}\label{wxframegetstatusbar
}
254 \constfunc{wxStatusBar*
}{GetStatusBar
}{\void}
256 Returns a pointer to the status bar currently associated with the frame (if any).
260 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
262 \membersection{wxFrame::GetTitle
}\label{wxframegettitle
}
264 \constfunc{wxString
}{GetTitle
}{\void}
266 Gets a string containing the frame title. See
\helpref{wxFrame::SetTitle
}{wxframesettitle
}.
268 \membersection{wxFrame::GetToolBar
}\label{wxframegettoolbar
}
270 \constfunc{wxToolBar*
}{GetToolBar
}{\void}
272 Returns a pointer to the toolbar currently associated with the frame (if any).
276 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
277 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}
279 \membersection{wxFrame::Iconize
}\label{wxframeiconize
}
281 \func{void
}{Iconize
}{\param{bool
}{ iconize
}}
283 Iconizes or restores the frame.
285 \wxheading{Parameters
}
287 \docparam{izonize
}{If TRUE, iconizes the frame; if FALSE, shows and restores it.
}
291 \helpref{wxFrame::IsIconized
}{wxframeisiconized
},
\helpref{wxFrame::Maximize
}{wxframemaximize
}.
293 \membersection{wxFrame::IsFullScreen
}\label{wxframeisfullscreen
}
295 \func{bool
}{IsFullScreen
}{\void}
297 Returns TRUE if the frame is in fullscreen mode.
301 \helpref{wxFrame::ShowFullScreen
}{wxframeshowfullscreen
}
303 \membersection{wxFrame::IsIconized
}\label{wxframeisiconized
}
305 \constfunc{bool
}{IsIconized
}{\void}
307 Returns TRUE if the frame is iconized.
309 \membersection{wxFrame::IsMaximized
}\label{wxframeismaximized
}
311 \constfunc{bool
}{IsMaximized
}{\void}
313 Returns TRUE if the frame is maximized.
315 \membersection{wxFrame::Maximize
}\label{wxframemaximize
}
317 \func{void
}{Maximize
}{\param{bool
}{maximize
}}
319 Maximizes or restores the frame.
321 \wxheading{Parameters
}
323 \docparam{maximize
}{If TRUE, maximizes the frame, otherwise it restores it.
}
327 This function only works under Windows.
331 \helpref{wxFrame::Iconize
}{wxframeiconize
}
333 \membersection{wxFrame::OnActivate
}
335 \func{void
}{OnActivate
}{\param{wxActivateEvent\&
}{ event
}}
337 Called when a window is activated or deactivated (MS Windows
338 only). See also
\helpref{wxActivateEvent
}{wxactivateevent
}.
340 \membersection{wxFrame::OnCreateStatusBar
}\label{wxframeoncreatestatusbar
}
342 \func{virtual wxStatusBar*
}{OnCreateStatusBar
}{\param{int
}{number
},
343 \param{long
}{ style
},
344 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
346 Virtual function called when a status bar is requested by
\helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
}.
348 \wxheading{Parameters
}
350 \docparam{number
}{The number of fields to create.
}
352 \docparam{style
}{The window style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
355 \docparam{id
}{The window identifier. If -
1, an identifier will be chosen by
358 \docparam{name
}{The window name.
}
360 \wxheading{Return value
}
366 An application can override this function to return a different kind of status bar. The default
367 implementation returns an instance of
\helpref{wxStatusBar
}{wxstatusbar
}.
371 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}.
373 \membersection{wxFrame::OnCreateToolBar
}\label{wxframeoncreatetoolbar
}
375 \func{virtual wxToolBar*
}{OnCreateToolBar
}{\param{long
}{ style
},
376 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
378 Virtual function called when a toolbar is requested by
\helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
}.
380 \wxheading{Parameters
}
382 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
385 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
388 \docparam{name
}{The toolbar window name.
}
390 \wxheading{Return value
}
396 An application can override this function to return a different kind of toolbar. The default
397 implementation returns an instance of
\helpref{wxToolBar
}{wxtoolbar
}.
401 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
}.
403 \membersection{wxFrame::OnMenuCommand
}\label{wxframeonmenucommand
}
405 \func{void
}{OnMenuCommand
}{\param{wxCommandEvent\&
}{ event
}}
407 See
\helpref{wxWindow::OnMenuCommand
}{wxwindowonmenucommand
}.
409 \membersection{wxFrame::OnMenuHighlight
}\label{wxframeonmenuhighlight
}
411 \func{void
}{OnMenuHighlight
}{\param{wxMenuEvent\&
}{ event
}}
413 See
\helpref{wxWindow::OnMenuHighlight
}{wxwindowonmenuhighlight
}.
415 \membersection{wxFrame::OnSize
}\label{wxframeonsize
}
417 \func{void
}{OnSize
}{\param{wxSizeEvent\&
}{event
}}
419 See
\helpref{wxWindow::OnSize
}{wxwindowonsize
}.
421 The default
{\bf wxFrame::OnSize
} implementation looks for a single subwindow,
422 and if one is found, resizes it to fit
423 inside the frame. Override this member if more complex behaviour
424 is required (for example, if there are several subwindows).
426 \membersection{wxFrame::SetIcon
}\label{wxframeseticon
}
428 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
430 Sets the icon for this frame.
432 \wxheading{Parameters
}
434 \docparam{icon
}{The icon to associate with this frame.
}
438 The frame takes a `copy' of
{\it icon
}, but since it uses reference
439 counting, the copy is very quick. It is safe to delete
{\it icon
} after
440 calling this function.
442 % VZ: we don't have all this any more (18.08.00)
444 %Under Windows, instead of using {\bf SetIcon}, you can add the
445 %following lines to your MS Windows resource file:
448 %wxSTD_MDIPARENTFRAME ICON icon1.ico
449 %wxSTD_MDICHILDFRAME ICON icon2.ico
450 %wxSTD_FRAME ICON icon3.ico
453 %where icon1.ico will be used for the MDI parent frame, icon2.ico
454 %will be used for MDI child frames, and icon3.ico will be used for
457 %If these icons are not supplied, and {\bf SetIcon} is not called either,
458 %then the following defaults apply if you have included wx.rc.
461 %wxDEFAULT_FRAME ICON std.ico
462 %wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
463 %wxDEFAULT_MDICHILDFRAME ICON child.ico
466 %You can replace std.ico, mdi.ico and child.ico with your own defaults
467 %for all your wxWindows application. Currently they show the same icon.
469 See also
\helpref{wxIcon
}{wxicon
}.
471 \membersection{wxFrame::SetMenuBar
}\label{wxframesetmenubar
}
473 \func{void
}{SetMenuBar
}{\param{wxMenuBar*
}{menuBar
}}
475 Tells the frame to show the given menu bar.
477 \wxheading{Parameters
}
479 \docparam{menuBar
}{The menu bar to associate with the frame.
}
483 If the frame is destroyed, the
484 menu bar and its menus will be destroyed also, so do not delete the menu
485 bar explicitly (except by resetting the frame's menu bar to another
488 Under Windows, a call to
\helpref{wxFrame::OnSize
}{wxframeonsize
} is generated, so be sure to initialize
489 data members properly before calling
{\bf SetMenuBar
}.
491 Note that it is not possible to call this function twice for the same frame object.
495 \helpref{wxFrame::GetMenuBar
}{wxframegetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}.
497 \membersection{wxFrame::SetStatusBar
}\label{wxframesetstatusbar
}
499 \func{void
}{SetStatusBar
}{\param{wxStatusBar*
}{ statusBar
}}
501 Associates a status bar with the frame.
505 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
},
\rtfsp
506 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
508 \membersection{wxFrame::SetStatusText
}\label{wxframesetstatustext
}
510 \func{virtual void
}{SetStatusText
}{\param{const wxString\&
}{ text
},
\param{int
}{ number =
0}}
512 Sets the status bar text and redraws the status bar.
514 \wxheading{Parameters
}
516 \docparam{text
}{The text for the status field.
}
518 \docparam{number
}{The status field (starting from zero).
}
522 Use an empty string to clear the status bar.
526 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
528 \membersection{wxFrame::SetStatusWidths
}\label{wxframesetstatuswidths
}
530 \func{virtual void
}{SetStatusWidths
}{\param{int
}{ n
},
\param{int *
}{widths
}}
532 Sets the widths of the fields in the status bar.
534 \wxheading{Parameters
}
536 \wxheading{n
}{The number of fields in the status bar. It must be the
537 same used in
\helpref{CreateStatusBar
}{wxframecreatestatusbar
}.
}
539 \docparam{widths
}{Must contain an array of
{\it n
} integers, each of which is a status field width
540 in pixels. A value of -
1 indicates that the field is variable width; at least one
541 field must be -
1. You should delete this array after calling
{\bf SetStatusWidths
}.
}
545 The widths of the variable fields are calculated from the total width of all fields,
546 minus the sum of widths of the non-variable fields, divided by the number of
549 \pythonnote{Only a single parameter is required, a Python list of
552 \perlnote{In wxPerl this method takes the field widths as parameters.
}
554 \membersection{wxFrame::SetToolBar
}\label{wxframesettoolbar
}
556 \func{void
}{SetToolBar
}{\param{wxToolBar*
}{ toolBar
}}
558 Associates a toolbar with the frame.
562 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
563 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
565 \membersection{wxFrame::SetTitle
}\label{wxframesettitle
}
567 \func{virtual void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
569 Sets the frame title.
571 \wxheading{Parameters
}
573 \docparam{title
}{The frame title.
}
577 \helpref{wxFrame::GetTitle
}{wxframegettitle
}
579 \membersection{wxFrame::ShowFullScreen
}\label{wxframeshowfullscreen
}
581 \func{bool
}{ShowFullScreen
}{\param{bool
}{ show
},
\param{long
}{ style = wxFULLSCREEN
\_ALL}}
583 Passing TRUE to
{\it shows
} shows the frame full-screen, and passing FALSE restores the frame
584 again.
{\it style
} is a bit list containing some or all of the following values, which
585 indicate what elements of the frame to hide in full-screen mode:
587 \begin{itemize
}\itemsep=
0pt
588 \item wxFULLSCREEN
\_NOMENUBAR
589 \item wxFULLSCREEN
\_NOTOOLBAR
590 \item wxFULLSCREEN
\_NOSTATUSBAR
591 \item wxFULLSCREEN
\_NOBORDER
592 \item wxFULLSCREEN
\_NOCAPTION
593 \item wxFULLSCREEN
\_ALL (all of the above)
596 This function has not been tested with MDI frames.
600 \helpref{wxFrame::IsFullScreen
}{wxframeisfullscreen
}