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.
}
45 The default frame style is for normal, resizeable frames. To create a frame
46 which can not be resized by user, you may use the following combination of
47 styles:
{\tt wxDEFAULT
\_FRAME\_STYLE \& \~ (wxRESIZE
\_BORDER \pipe wxRESIZE
\_BOX \pipe wxMAXIMIZE
\_BOX)
}.
48 % Note: the space after the tilde is necessary or Tex2RTF complains.
50 See also
\helpref{window styles overview
}{windowstyles
}.
54 An application should normally define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
55 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
59 \helpref{wxMDIParentFrame
}{wxmdiparentframe
},
\helpref{wxMDIChildFrame
}{wxmdichildframe
},
\rtfsp
60 \helpref{wxMiniFrame
}{wxminiframe
},
\helpref{wxDialog
}{wxdialog
}
62 \latexignore{\rtfignore{\wxheading{Members
}}}
64 \membersection{wxFrame::wxFrame
}\label{wxframeconstr
}
66 \func{}{wxFrame
}{\void}
70 \func{}{wxFrame
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
71 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
72 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
73 \param{const wxString\&
}{name = ``frame"
}}
75 Constructor, creating the window.
77 \wxheading{Parameters
}
79 \docparam{parent
}{The window parent. This may be NULL. If it is non-NULL, the frame will
80 always be displayed on top of the parent window on Windows.
}
82 \docparam{id
}{The window identifier. It may take a value of -
1 to indicate a default value.
}
84 \docparam{title
}{The caption to be displayed on the frame's title bar.
}
86 \docparam{pos
}{The window position. A value of (-
1, -
1) indicates a default position, chosen by
87 either the windowing system or wxWindows, depending on platform.
}
89 \docparam{size
}{The window size. A value of (-
1, -
1) indicates a default size, chosen by
90 either the windowing system or wxWindows, depending on platform.
}
92 \docparam{style
}{The window style. See
\helpref{wxFrame
}{wxframe
}.
}
94 \docparam{name
}{The name of the window. This parameter is used to associate a name with the item,
95 allowing the application user to set Motif resource values for
100 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
101 (otherwise all styles take effect).
105 \helpref{wxFrame::Create
}{wxframecreate
}
107 \membersection{wxFrame::
\destruct{wxFrame
}}
109 \func{void
}{\destruct{wxFrame
}}{\void}
111 Destructor. Destroys all child windows and menu bar if present.
113 \membersection{wxFrame::Centre
}\label{wxframecentre
}
115 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
117 Centres the frame on the display.
119 \wxheading{Parameters
}
121 \docparam{direction
}{The parameter may be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
123 \membersection{wxFrame::Command
}\label{wxframecommand
}
125 \func{void
}{Command
}{\param{int
}{id
}}
127 Simulate a menu command.
129 \wxheading{Parameters
}
131 \docparam{id
}{The identifier for a menu item.
}
133 \membersection{wxFrame::Create
}\label{wxframecreate
}
135 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
136 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
137 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
138 \param{const wxString\&
}{name = ``frame"
}}
140 Used in two-step frame construction. See
\helpref{wxFrame::wxFrame
}{wxframeconstr
}\rtfsp
143 \membersection{wxFrame::CreateStatusBar
}\label{wxframecreatestatusbar
}
145 \func{virtual wxStatusBar*
}{CreateStatusBar
}{\param{int
}{ number =
1},
146 \param{long
}{ style =
0},
147 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "statusBar"
}}
149 Creates a status bar at the bottom of the frame.
151 \wxheading{Parameters
}
153 \docparam{number
}{The number of fields to create. Specify a
154 value greater than
1 to create a multi-field status bar.
}
156 \docparam{style
}{The status bar style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
159 \docparam{id
}{The status bar window identifier. If -
1, an identifier will be chosen by
162 \docparam{name
}{The status bar window name.
}
164 \wxheading{Return value
}
166 A pointer to the the status bar if it was created successfully, NULL otherwise.
170 The width of the status bar is the whole width of the frame (adjusted automatically when
171 resizing), and the height and text size are chosen by the host windowing system.
173 By default, the status bar is an instance of wxStatusBar. To use a different class,
174 override
\helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
}.
176 Note that you can put controls and other windows on the status bar if you wish.
180 \helpref{wxFrame::SetStatusText
}{wxframesetstatustext
},
\rtfsp
181 \helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
},
\rtfsp
182 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
184 \membersection{wxFrame::CreateToolBar
}\label{wxframecreatetoolbar
}
186 \func{virtual wxToolBar*
}{CreateToolBar
}{\param{long
}{ style = wxNO
\_BORDER \pipe wxTB
\_HORIZONTAL},
187 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "toolBar"
}}
189 Creates a toolbar at the top or left of the frame.
191 \wxheading{Parameters
}
193 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
196 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
199 \docparam{name
}{The toolbar window name.
}
201 \wxheading{Return value
}
203 A pointer to the the toolbar if it was created successfully, NULL otherwise.
207 By default, the toolbar is an instance of wxToolBar (which is defined to be
208 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
209 override
\helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
}.
211 When a toolbar has been created with this function, or made known to the frame
212 with
\helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}, the frame will manage the toolbar
213 position and adjust the return value from
\helpref{wxWindow::GetClientSize
}{wxwindowgetclientsize
} to
214 reflect the available space for application windows.
218 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\rtfsp
219 \helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
},
\rtfsp
220 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
},
\rtfsp
221 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
223 \membersection{wxFrame::GetClientAreaOrigin
}\label{wxframegetclientareaorigin
}
225 \constfunc{wxPoint
}{GetClientAreaOrigin
}{\void}
227 Returns the origin of the frame client area (in client coordinates). It may be
228 different from (
0,
0) if the frame has a toolbar.
230 \membersection{wxFrame::GetMenuBar
}\label{wxframegetmenubar
}
232 \constfunc{wxMenuBar*
}{GetMenuBar
}{\void}
234 Returns a pointer to the menubar currently associated with the frame (if any).
238 \helpref{wxFrame::SetMenuBar
}{wxframesetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
240 \membersection{wxFrame::GetStatusBar
}\label{wxframegetstatusbar
}
242 \constfunc{wxStatusBar*
}{GetStatusBar
}{\void}
244 Returns a pointer to the status bar currently associated with the frame (if any).
248 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
250 \membersection{wxFrame::GetTitle
}\label{wxframegettitle
}
252 \constfunc{wxString
}{GetTitle
}{\void}
254 Gets a string containing the frame title. See
\helpref{wxFrame::SetTitle
}{wxframesettitle
}.
256 \membersection{wxFrame::GetToolBar
}\label{wxframegettoolbar
}
258 \constfunc{wxToolBar*
}{GetToolBar
}{\void}
260 Returns a pointer to the toolbar currently associated with the frame (if any).
264 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
265 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}
267 \membersection{wxFrame::Iconize
}\label{wxframeiconize
}
269 \func{void
}{Iconize
}{\param{bool
}{ iconize
}}
271 Iconizes or restores the frame. Windows only.
273 \wxheading{Parameters
}
275 \docparam{izonize
}{If TRUE, iconizes the frame; if FALSE, shows and restores it.
}
279 \helpref{wxFrame::IsIconized
}{wxframeisiconized
},
\helpref{wxFrame::Maximize
}{wxframemaximize
}.
281 \membersection{wxFrame::IsIconized
}\label{wxframeisiconized
}
283 \constfunc{bool
}{IsIconized
}{\void}
285 Returns TRUE if the frame is iconized. Windows only.
287 \membersection{wxFrame::IsMaximized
}\label{wxframeismaximized
}
289 \constfunc{bool
}{IsMaximized
}{\void}
291 Returns TRUE if the frame is maximized.
293 \membersection{wxFrame::Maximize
}\label{wxframemaximize
}
295 \func{void
}{Maximize
}{\param{bool
}{maximize
}}
297 Maximizes or restores the frame.
299 \wxheading{Parameters
}
301 \docparam{maximize
}{If TRUE, maximizes the frame, otherwise it restores it.
}
305 This function only works under Windows.
309 \helpref{wxFrame::Iconize
}{wxframeiconize
}
311 \membersection{wxFrame::OnActivate
}
313 \func{void
}{OnActivate
}{\param{wxActivateEvent\&
}{ event
}}
315 Called when a window is activated or deactivated (MS Windows
316 only). See also
\helpref{wxActivateEvent
}{wxactivateevent
}.
318 \membersection{wxFrame::OnCreateStatusBar
}\label{wxframeoncreatestatusbar
}
320 \func{virtual wxStatusBar*
}{OnCreateStatusBar
}{\param{int
}{number
},
321 \param{long
}{ style
},
322 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
324 Virtual function called when a status bar is requested by
\helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
}.
326 \wxheading{Parameters
}
328 \docparam{number
}{The number of fields to create.
}
330 \docparam{style
}{The window style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
333 \docparam{id
}{The window identifier. If -
1, an identifier will be chosen by
336 \docparam{name
}{The window name.
}
338 \wxheading{Return value
}
344 An application can override this function to return a different kind of status bar. The default
345 implementation returns an instance of
\helpref{wxStatusBar
}{wxstatusbar
}.
349 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}.
351 \membersection{wxFrame::OnCreateToolBar
}\label{wxframeoncreatetoolbar
}
353 \func{virtual wxToolBar*
}{OnCreateToolBar
}{\param{long
}{ style
},
354 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
356 Virtual function called when a toolbar is requested by
\helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
}.
358 \wxheading{Parameters
}
360 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
363 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
366 \docparam{name
}{The toolbar window name.
}
368 \wxheading{Return value
}
374 An application can override this function to return a different kind of toolbar. The default
375 implementation returns an instance of
\helpref{wxToolBar
}{wxtoolbar
}.
379 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
}.
381 \membersection{wxFrame::OnMenuCommand
}\label{wxframeonmenucommand
}
383 \func{void
}{OnMenuCommand
}{\param{wxCommandEvent\&
}{ event
}}
385 See
\helpref{wxWindow::OnMenuCommand
}{wxwindowonmenucommand
}.
387 \membersection{wxFrame::OnMenuHighlight
}\label{wxframeonmenuhighlight
}
389 \func{void
}{OnMenuHighlight
}{\param{wxMenuEvent\&
}{ event
}}
391 See
\helpref{wxWindow::OnMenuHighlight
}{wxwindowonmenuhighlight
}.
393 \membersection{wxFrame::OnSize
}\label{wxframeonsize
}
395 \func{void
}{OnSize
}{\param{wxSizeEvent\&
}{event
}}
397 See
\helpref{wxWindow::OnSize
}{wxwindowonsize
}.
399 The default
{\bf wxFrame::OnSize
} implementation looks for a single subwindow,
400 and if one is found, resizes it to fit
401 inside the frame. Override this member if more complex behaviour
402 is required (for example, if there are several subwindows).
404 \membersection{wxFrame::SetIcon
}\label{wxframeseticon
}
406 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
408 Sets the icon for this frame.
410 \wxheading{Parameters
}
412 \docparam{icon
}{The icon to associate with this frame.
}
416 The frame takes a `copy' of
{\it icon
}, but since it uses reference
417 counting, the copy is very quick. It is safe to delete
{\it icon
} after
418 calling this function.
420 % VZ: we don't have all this any more (18.08.00)
422 %Under Windows, instead of using {\bf SetIcon}, you can add the
423 %following lines to your MS Windows resource file:
426 %wxSTD_MDIPARENTFRAME ICON icon1.ico
427 %wxSTD_MDICHILDFRAME ICON icon2.ico
428 %wxSTD_FRAME ICON icon3.ico
431 %where icon1.ico will be used for the MDI parent frame, icon2.ico
432 %will be used for MDI child frames, and icon3.ico will be used for
435 %If these icons are not supplied, and {\bf SetIcon} is not called either,
436 %then the following defaults apply if you have included wx.rc.
439 %wxDEFAULT_FRAME ICON std.ico
440 %wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
441 %wxDEFAULT_MDICHILDFRAME ICON child.ico
444 %You can replace std.ico, mdi.ico and child.ico with your own defaults
445 %for all your wxWindows application. Currently they show the same icon.
447 See also
\helpref{wxIcon
}{wxicon
}.
449 \membersection{wxFrame::SetMenuBar
}\label{wxframesetmenubar
}
451 \func{void
}{SetMenuBar
}{\param{wxMenuBar*
}{menuBar
}}
453 Tells the frame to show the given menu bar.
455 \wxheading{Parameters
}
457 \docparam{menuBar
}{The menu bar to associate with the frame.
}
461 If the frame is destroyed, the
462 menu bar and its menus will be destroyed also, so do not delete the menu
463 bar explicitly (except by resetting the frame's menu bar to another
466 Under Windows, a call to
\helpref{wxFrame::OnSize
}{wxframeonsize
} is generated, so be sure to initialize
467 data members properly before calling
{\bf SetMenuBar
}.
469 Note that it is not possible to call this function twice for the same frame object.
473 \helpref{wxFrame::GetMenuBar
}{wxframegetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}.
475 \membersection{wxFrame::SetStatusBar
}\label{wxframesetstatusbar
}
477 \func{void
}{SetStatusBar
}{\param{wxStatusBar*
}{ statusBar
}}
479 Associates a status bar with the frame.
483 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
},
\rtfsp
484 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
486 \membersection{wxFrame::SetStatusText
}\label{wxframesetstatustext
}
488 \func{virtual void
}{SetStatusText
}{\param{const wxString\&
}{ text
},
\param{int
}{ number =
0}}
490 Sets the status bar text and redraws the status bar.
492 \wxheading{Parameters
}
494 \docparam{text
}{The text for the status field.
}
496 \docparam{number
}{The status field (starting from zero).
}
500 Use an empty string to clear the status bar.
504 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
506 \membersection{wxFrame::SetStatusWidths
}\label{wxframesetstatuswidths
}
508 \func{virtual void
}{SetStatusWidths
}{\param{int
}{ n
},
\param{int *
}{widths
}}
510 Sets the widths of the fields in the status bar.
512 \wxheading{Parameters
}
514 \wxheading{n
}{The number of fields in the status bar. It must be the
515 same used in
\helpref{CreateStatusBar
}{wxframecreatestatusbar
}.
}
517 \docparam{widths
}{Must contain an array of
{\it n
} integers, each of which is a status field width
518 in pixels. A value of -
1 indicates that the field is variable width; at least one
519 field must be -
1. You should delete this array after calling
{\bf SetStatusWidths
}.
}
523 The widths of the variable fields are calculated from the total width of all fields,
524 minus the sum of widths of the non-variable fields, divided by the number of
527 \pythonnote{Only a single parameter is required, a Python list of
530 \membersection{wxFrame::SetToolBar
}\label{wxframesettoolbar
}
532 \func{void
}{SetToolBar
}{\param{wxToolBar*
}{ toolBar
}}
534 Associates a toolbar with the frame.
538 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
539 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
541 \membersection{wxFrame::SetTitle
}\label{wxframesettitle
}
543 \func{virtual void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
545 Sets the frame title.
547 \wxheading{Parameters
}
549 \docparam{title
}{The frame title.
}
553 \helpref{wxFrame::GetTitle
}{wxframegettitle
}
555 \membersection{wxFrame::ShowFullScreen
}\label{wxframeshowfullscreen
}
557 \func{bool
}{ShowFullScreen
}{\param{bool
}{ show
},
\param{long
}{ style = wxFULLSCREEN
\_ALL}}
559 Passing TRUE to
{\it shows
} shows the frame full-screen, and passing FALSE restores the frame
560 again.
{\it style
} is a bit list containing some or all of the following values, which
561 indicate what elements of the frame to hide in full-screen mode:
563 \begin{itemize
}\itemsep=
0pt
564 \item wxFULLSCREEN
\_NOMENUBAR
565 \item wxFULLSCREEN
\_NOTOOLBAR
566 \item wxFULLSCREEN
\_NOSTATUSBAR
567 \item wxFULLSCREEN
\_NOBORDER
568 \item wxFULLSCREEN
\_NOCAPTION
569 \item wxFULLSCREEN
\_ALL (all of the above)
572 This function only works on Windows and has not been tested with MDI frames.