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 (Unix only).
}
38 \twocolitem{\windowstyle{wxFRAME
\_FLOAT\_ON\_PARENT}}{Causes the frame to be above the parent window in the
39 z-order and not shown in the taskbar. Without this style, frames are created as top-level windows that may be obscured by
40 the parent window, and frame titles are shown in the taskbar. Windows and GTK.
}
41 \twocolitem{\windowstyle{wxFRAME
\_TOOL\_WINDOW}}{Causes a frame with a small titlebar to be created;
42 the frame title does not appear in the taskbar. Windows only.
}
43 \twocolitem{\windowstyle{wxFRAME
\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
44 caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send
45 a wxEVT
\_HELP event if the user clicked on an application window.
{\it Note
} that this is an extended
46 style and must be set by calling
\helpref{SetExtraStyle
}{wxwindowsetextrastyle
} before Create is called (two-step construction).
47 You cannot use this style together with wxMAXIMIZE
\_BOX or wxMINIMIZE
\_BOX.
}
50 The default frame style is for normal, resizeable frames. To create a frame
51 which can not be resized by user, you may use the following combination of
52 styles:
{\tt wxDEFAULT
\_FRAME\_STYLE \& \~ (wxRESIZE
\_BORDER \pipe wxRESIZE
\_BOX \pipe wxMAXIMIZE
\_BOX)
}.
53 % Note: the space after the tilde is necessary or Tex2RTF complains.
55 See also
\helpref{window styles overview
}{windowstyles
}.
59 An application should normally define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
60 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
64 \helpref{wxMDIParentFrame
}{wxmdiparentframe
},
\helpref{wxMDIChildFrame
}{wxmdichildframe
},
\rtfsp
65 \helpref{wxMiniFrame
}{wxminiframe
},
\helpref{wxDialog
}{wxdialog
}
67 \latexignore{\rtfignore{\wxheading{Members
}}}
69 \membersection{wxFrame::wxFrame
}\label{wxframeconstr
}
71 \func{}{wxFrame
}{\void}
75 \func{}{wxFrame
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
76 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
77 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
78 \param{const wxString\&
}{name = ``frame"
}}
80 Constructor, creating the window.
82 \wxheading{Parameters
}
84 \docparam{parent
}{The window parent. This may be NULL. If it is non-NULL, the frame will
85 always be displayed on top of the parent window on Windows.
}
87 \docparam{id
}{The window identifier. It may take a value of -
1 to indicate a default value.
}
89 \docparam{title
}{The caption to be displayed on the frame's title bar.
}
91 \docparam{pos
}{The window position. A value of (-
1, -
1) indicates a default position, chosen by
92 either the windowing system or wxWindows, depending on platform.
}
94 \docparam{size
}{The window size. A value of (-
1, -
1) indicates a default size, chosen by
95 either the windowing system or wxWindows, depending on platform.
}
97 \docparam{style
}{The window style. See
\helpref{wxFrame
}{wxframe
}.
}
99 \docparam{name
}{The name of the window. This parameter is used to associate a name with the item,
100 allowing the application user to set Motif resource values for
105 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
106 (otherwise all styles take effect).
110 \helpref{wxFrame::Create
}{wxframecreate
}
112 \membersection{wxFrame::
\destruct{wxFrame
}}
114 \func{void
}{\destruct{wxFrame
}}{\void}
116 Destructor. Destroys all child windows and menu bar if present.
118 \membersection{wxFrame::Centre
}\label{wxframecentre
}
120 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
122 Centres the frame on the display.
124 \wxheading{Parameters
}
126 \docparam{direction
}{The parameter may be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
128 \membersection{wxFrame::Command
}\label{wxframecommand
}
130 \func{void
}{Command
}{\param{int
}{id
}}
132 Simulate a menu command.
134 \wxheading{Parameters
}
136 \docparam{id
}{The identifier for a menu item.
}
138 \membersection{wxFrame::Create
}\label{wxframecreate
}
140 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
141 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
142 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
143 \param{const wxString\&
}{name = ``frame"
}}
145 Used in two-step frame construction. See
\helpref{wxFrame::wxFrame
}{wxframeconstr
}\rtfsp
148 \membersection{wxFrame::CreateStatusBar
}\label{wxframecreatestatusbar
}
150 \func{virtual wxStatusBar*
}{CreateStatusBar
}{\param{int
}{ number =
1},
151 \param{long
}{ style =
0},
152 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "statusBar"
}}
154 Creates a status bar at the bottom of the frame.
156 \wxheading{Parameters
}
158 \docparam{number
}{The number of fields to create. Specify a
159 value greater than
1 to create a multi-field status bar.
}
161 \docparam{style
}{The status bar style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
164 \docparam{id
}{The status bar window identifier. If -
1, an identifier will be chosen by
167 \docparam{name
}{The status bar window name.
}
169 \wxheading{Return value
}
171 A pointer to the the status bar if it was created successfully, NULL otherwise.
175 The width of the status bar is the whole width of the frame (adjusted automatically when
176 resizing), and the height and text size are chosen by the host windowing system.
178 By default, the status bar is an instance of wxStatusBar. To use a different class,
179 override
\helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
}.
181 Note that you can put controls and other windows on the status bar if you wish.
185 \helpref{wxFrame::SetStatusText
}{wxframesetstatustext
},
\rtfsp
186 \helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
},
\rtfsp
187 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
189 \membersection{wxFrame::CreateToolBar
}\label{wxframecreatetoolbar
}
191 \func{virtual wxToolBar*
}{CreateToolBar
}{\param{long
}{ style = wxNO
\_BORDER \pipe wxTB
\_HORIZONTAL},
192 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "toolBar"
}}
194 Creates a toolbar at the top or left of the frame.
196 \wxheading{Parameters
}
198 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
201 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
204 \docparam{name
}{The toolbar window name.
}
206 \wxheading{Return value
}
208 A pointer to the the toolbar if it was created successfully, NULL otherwise.
212 By default, the toolbar is an instance of wxToolBar (which is defined to be
213 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
214 override
\helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
}.
216 When a toolbar has been created with this function, or made known to the frame
217 with
\helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}, the frame will manage the toolbar
218 position and adjust the return value from
\helpref{wxWindow::GetClientSize
}{wxwindowgetclientsize
} to
219 reflect the available space for application windows.
223 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\rtfsp
224 \helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
},
\rtfsp
225 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
},
\rtfsp
226 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
228 \membersection{wxFrame::GetClientAreaOrigin
}\label{wxframegetclientareaorigin
}
230 \constfunc{wxPoint
}{GetClientAreaOrigin
}{\void}
232 Returns the origin of the frame client area (in client coordinates). It may be
233 different from (
0,
0) if the frame has a toolbar.
235 \membersection{wxFrame::GetMenuBar
}\label{wxframegetmenubar
}
237 \constfunc{wxMenuBar*
}{GetMenuBar
}{\void}
239 Returns a pointer to the menubar currently associated with the frame (if any).
243 \helpref{wxFrame::SetMenuBar
}{wxframesetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
245 \membersection{wxFrame::GetStatusBar
}\label{wxframegetstatusbar
}
247 \constfunc{wxStatusBar*
}{GetStatusBar
}{\void}
249 Returns a pointer to the status bar currently associated with the frame (if any).
253 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
255 \membersection{wxFrame::GetTitle
}\label{wxframegettitle
}
257 \constfunc{wxString
}{GetTitle
}{\void}
259 Gets a string containing the frame title. See
\helpref{wxFrame::SetTitle
}{wxframesettitle
}.
261 \membersection{wxFrame::GetToolBar
}\label{wxframegettoolbar
}
263 \constfunc{wxToolBar*
}{GetToolBar
}{\void}
265 Returns a pointer to the toolbar currently associated with the frame (if any).
269 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
270 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}
272 \membersection{wxFrame::Iconize
}\label{wxframeiconize
}
274 \func{void
}{Iconize
}{\param{bool
}{ iconize
}}
276 Iconizes or restores the frame. Windows only.
278 \wxheading{Parameters
}
280 \docparam{izonize
}{If TRUE, iconizes the frame; if FALSE, shows and restores it.
}
284 \helpref{wxFrame::IsIconized
}{wxframeisiconized
},
\helpref{wxFrame::Maximize
}{wxframemaximize
}.
286 \membersection{wxFrame::IsIconized
}\label{wxframeisiconized
}
288 \constfunc{bool
}{IsIconized
}{\void}
290 Returns TRUE if the frame is iconized. Windows only.
292 \membersection{wxFrame::IsMaximized
}\label{wxframeismaximized
}
294 \constfunc{bool
}{IsMaximized
}{\void}
296 Returns TRUE if the frame is maximized.
298 \membersection{wxFrame::Maximize
}\label{wxframemaximize
}
300 \func{void
}{Maximize
}{\param{bool
}{maximize
}}
302 Maximizes or restores the frame.
304 \wxheading{Parameters
}
306 \docparam{maximize
}{If TRUE, maximizes the frame, otherwise it restores it.
}
310 This function only works under Windows.
314 \helpref{wxFrame::Iconize
}{wxframeiconize
}
316 \membersection{wxFrame::OnActivate
}
318 \func{void
}{OnActivate
}{\param{wxActivateEvent\&
}{ event
}}
320 Called when a window is activated or deactivated (MS Windows
321 only). See also
\helpref{wxActivateEvent
}{wxactivateevent
}.
323 \membersection{wxFrame::OnCreateStatusBar
}\label{wxframeoncreatestatusbar
}
325 \func{virtual wxStatusBar*
}{OnCreateStatusBar
}{\param{int
}{number
},
326 \param{long
}{ style
},
327 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
329 Virtual function called when a status bar is requested by
\helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
}.
331 \wxheading{Parameters
}
333 \docparam{number
}{The number of fields to create.
}
335 \docparam{style
}{The window style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
338 \docparam{id
}{The window identifier. If -
1, an identifier will be chosen by
341 \docparam{name
}{The window name.
}
343 \wxheading{Return value
}
349 An application can override this function to return a different kind of status bar. The default
350 implementation returns an instance of
\helpref{wxStatusBar
}{wxstatusbar
}.
354 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}.
356 \membersection{wxFrame::OnCreateToolBar
}\label{wxframeoncreatetoolbar
}
358 \func{virtual wxToolBar*
}{OnCreateToolBar
}{\param{long
}{ style
},
359 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
361 Virtual function called when a toolbar is requested by
\helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
}.
363 \wxheading{Parameters
}
365 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
368 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
371 \docparam{name
}{The toolbar window name.
}
373 \wxheading{Return value
}
379 An application can override this function to return a different kind of toolbar. The default
380 implementation returns an instance of
\helpref{wxToolBar
}{wxtoolbar
}.
384 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
}.
386 \membersection{wxFrame::OnMenuCommand
}\label{wxframeonmenucommand
}
388 \func{void
}{OnMenuCommand
}{\param{wxCommandEvent\&
}{ event
}}
390 See
\helpref{wxWindow::OnMenuCommand
}{wxwindowonmenucommand
}.
392 \membersection{wxFrame::OnMenuHighlight
}\label{wxframeonmenuhighlight
}
394 \func{void
}{OnMenuHighlight
}{\param{wxMenuEvent\&
}{ event
}}
396 See
\helpref{wxWindow::OnMenuHighlight
}{wxwindowonmenuhighlight
}.
398 \membersection{wxFrame::OnSize
}\label{wxframeonsize
}
400 \func{void
}{OnSize
}{\param{wxSizeEvent\&
}{event
}}
402 See
\helpref{wxWindow::OnSize
}{wxwindowonsize
}.
404 The default
{\bf wxFrame::OnSize
} implementation looks for a single subwindow,
405 and if one is found, resizes it to fit
406 inside the frame. Override this member if more complex behaviour
407 is required (for example, if there are several subwindows).
409 \membersection{wxFrame::SetIcon
}\label{wxframeseticon
}
411 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
413 Sets the icon for this frame.
415 \wxheading{Parameters
}
417 \docparam{icon
}{The icon to associate with this frame.
}
421 The frame takes a `copy' of
{\it icon
}, but since it uses reference
422 counting, the copy is very quick. It is safe to delete
{\it icon
} after
423 calling this function.
425 % VZ: we don't have all this any more (18.08.00)
427 %Under Windows, instead of using {\bf SetIcon}, you can add the
428 %following lines to your MS Windows resource file:
431 %wxSTD_MDIPARENTFRAME ICON icon1.ico
432 %wxSTD_MDICHILDFRAME ICON icon2.ico
433 %wxSTD_FRAME ICON icon3.ico
436 %where icon1.ico will be used for the MDI parent frame, icon2.ico
437 %will be used for MDI child frames, and icon3.ico will be used for
440 %If these icons are not supplied, and {\bf SetIcon} is not called either,
441 %then the following defaults apply if you have included wx.rc.
444 %wxDEFAULT_FRAME ICON std.ico
445 %wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
446 %wxDEFAULT_MDICHILDFRAME ICON child.ico
449 %You can replace std.ico, mdi.ico and child.ico with your own defaults
450 %for all your wxWindows application. Currently they show the same icon.
452 See also
\helpref{wxIcon
}{wxicon
}.
454 \membersection{wxFrame::SetMenuBar
}\label{wxframesetmenubar
}
456 \func{void
}{SetMenuBar
}{\param{wxMenuBar*
}{menuBar
}}
458 Tells the frame to show the given menu bar.
460 \wxheading{Parameters
}
462 \docparam{menuBar
}{The menu bar to associate with the frame.
}
466 If the frame is destroyed, the
467 menu bar and its menus will be destroyed also, so do not delete the menu
468 bar explicitly (except by resetting the frame's menu bar to another
471 Under Windows, a call to
\helpref{wxFrame::OnSize
}{wxframeonsize
} is generated, so be sure to initialize
472 data members properly before calling
{\bf SetMenuBar
}.
474 Note that it is not possible to call this function twice for the same frame object.
478 \helpref{wxFrame::GetMenuBar
}{wxframegetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}.
480 \membersection{wxFrame::SetStatusBar
}\label{wxframesetstatusbar
}
482 \func{void
}{SetStatusBar
}{\param{wxStatusBar*
}{ statusBar
}}
484 Associates a status bar with the frame.
488 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
},
\rtfsp
489 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
491 \membersection{wxFrame::SetStatusText
}\label{wxframesetstatustext
}
493 \func{virtual void
}{SetStatusText
}{\param{const wxString\&
}{ text
},
\param{int
}{ number =
0}}
495 Sets the status bar text and redraws the status bar.
497 \wxheading{Parameters
}
499 \docparam{text
}{The text for the status field.
}
501 \docparam{number
}{The status field (starting from zero).
}
505 Use an empty string to clear the status bar.
509 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
511 \membersection{wxFrame::SetStatusWidths
}\label{wxframesetstatuswidths
}
513 \func{virtual void
}{SetStatusWidths
}{\param{int
}{ n
},
\param{int *
}{widths
}}
515 Sets the widths of the fields in the status bar.
517 \wxheading{Parameters
}
519 \wxheading{n
}{The number of fields in the status bar. It must be the
520 same used in
\helpref{CreateStatusBar
}{wxframecreatestatusbar
}.
}
522 \docparam{widths
}{Must contain an array of
{\it n
} integers, each of which is a status field width
523 in pixels. A value of -
1 indicates that the field is variable width; at least one
524 field must be -
1. You should delete this array after calling
{\bf SetStatusWidths
}.
}
528 The widths of the variable fields are calculated from the total width of all fields,
529 minus the sum of widths of the non-variable fields, divided by the number of
532 \pythonnote{Only a single parameter is required, a Python list of
535 \membersection{wxFrame::SetToolBar
}\label{wxframesettoolbar
}
537 \func{void
}{SetToolBar
}{\param{wxToolBar*
}{ toolBar
}}
539 Associates a toolbar with the frame.
543 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
544 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
546 \membersection{wxFrame::SetTitle
}\label{wxframesettitle
}
548 \func{virtual void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
550 Sets the frame title.
552 \wxheading{Parameters
}
554 \docparam{title
}{The frame title.
}
558 \helpref{wxFrame::GetTitle
}{wxframegettitle
}
560 \membersection{wxFrame::ShowFullScreen
}\label{wxframeshowfullscreen
}
562 \func{bool
}{ShowFullScreen
}{\param{bool
}{ show
},
\param{long
}{ style = wxFULLSCREEN
\_ALL}}
564 Passing TRUE to
{\it shows
} shows the frame full-screen, and passing FALSE restores the frame
565 again.
{\it style
} is a bit list containing some or all of the following values, which
566 indicate what elements of the frame to hide in full-screen mode:
568 \begin{itemize
}\itemsep=
0pt
569 \item wxFULLSCREEN
\_NOMENUBAR
570 \item wxFULLSCREEN
\_NOTOOLBAR
571 \item wxFULLSCREEN
\_NOSTATUSBAR
572 \item wxFULLSCREEN
\_NOBORDER
573 \item wxFULLSCREEN
\_NOCAPTION
574 \item wxFULLSCREEN
\_ALL (all of the above)
577 This function only works on Windows and has not been tested with MDI frames.