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
}. Currently the GTK port of wxWindows
35 ignores all the window styles listed above as there is no standard way (yet) to inform the
36 window manager about such options. Therefore, the only relevant window style flag which
37 the GTK port recognizes is
\windowstyle{wxSIMPLE
\_BORDER} which brings up a frame without
38 any window decorations. This can be used for a splash screen or specialized tooltip etc.
42 An application should normally define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
43 frame to respond to system close events, for example so that related data and subwindows can be cleaned up.
47 \helpref{wxMDIParentFrame
}{wxmdiparentframe
},
\helpref{wxMDIChildFrame
}{wxmdichildframe
},
\rtfsp
48 \helpref{wxMiniFrame
}{wxminiframe
},
\helpref{wxDialog
}{wxdialog
}
50 \latexignore{\rtfignore{\wxheading{Members
}}}
52 \membersection{wxFrame::wxFrame
}\label{wxframeconstr
}
54 \func{}{wxFrame
}{\void}
58 \func{}{wxFrame
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
59 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
60 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
61 \param{const wxString\&
}{name = ``frame"
}}
63 Constructor, creating the window.
65 \wxheading{Parameters
}
67 \docparam{parent
}{The window parent. This may be NULL. If it is non-NULL, the frame will
68 always be displayed on top of the parent window on Windows.
}
70 \docparam{id
}{The window identifier. It may take a value of -
1 to indicate a default value.
}
72 \docparam{title
}{The caption to be displayed on the frame's title bar.
}
74 \docparam{pos
}{The window position. A value of (-
1, -
1) indicates a default position, chosen by
75 either the windowing system or wxWindows, depending on platform.
}
77 \docparam{size
}{The window size. A value of (-
1, -
1) indicates a default size, chosen by
78 either the windowing system or wxWindows, depending on platform.
}
80 \docparam{style
}{The window style. See
\helpref{wxFrame
}{wxframe
}.
}
82 \docparam{name
}{The name of the window. This parameter is used to associate a name with the item,
83 allowing the application user to set Motif resource values for
88 For Motif, MWM (the Motif Window Manager) should be running for any window styles to work
89 (otherwise all styles take effect).
93 \helpref{wxFrame::Create
}{wxframecreate
}
95 \membersection{wxFrame::
\destruct{wxFrame
}}
97 \func{void
}{\destruct{wxFrame
}}{\void}
99 Destructor. Destroys all child windows and menu bar if present.
101 \membersection{wxFrame::Centre
}\label{wxframecentre
}
103 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
105 Centres the frame on the display.
107 \wxheading{Parameters
}
109 \docparam{direction
}{The parameter may be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
111 \membersection{wxFrame::Command
}\label{wxframecommand
}
113 \func{void
}{Command
}{\param{int
}{id
}}
115 Simulate a menu command.
117 \wxheading{Parameters
}
119 \docparam{id
}{The identifier for a menu item.
}
121 \membersection{wxFrame::Create
}\label{wxframecreate
}
123 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
124 \param{const wxString\&
}{title
},
\param{const wxPoint\&
}{ pos = wxDefaultPosition
},
\rtfsp
125 \param{const wxSize\&
}{ size = wxDefaultSize
},
\param{long
}{ style = wxDEFAULT
\_FRAME\_STYLE},
\rtfsp
126 \param{const wxString\&
}{name = ``frame"
}}
128 Used in two-step frame construction. See
\helpref{wxFrame::wxFrame
}{wxframeconstr
}\rtfsp
131 \membersection{wxFrame::CreateStatusBar
}\label{wxframecreatestatusbar
}
133 \func{virtual wxStatusBar*
}{CreateStatusBar
}{\param{int
}{ number =
1},
134 \param{long
}{ style =
0},
135 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "statusBar"
}}
137 Creates a status bar at the bottom of the frame.
139 \wxheading{Parameters
}
141 \docparam{number
}{The number of fields to create. Specify a
142 value greater than
1 to create a multi-field status bar.
}
144 \docparam{style
}{The status bar style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
147 \docparam{id
}{The status bar window identifier. If -
1, an identifier will be chosen by
150 \docparam{name
}{The status bar window name.
}
152 \wxheading{Return value
}
154 A pointer to the the status bar if it was created successfully, NULL otherwise.
158 The width of the status bar is the whole width of the frame (adjusted automatically when
159 resizing), and the height and text size are chosen by the host windowing system.
161 By default, the status bar is an instance of wxStatusBar. To use a different class,
162 override
\helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
}.
164 Note that you can put controls and other windows on the status bar if you wish.
168 \helpref{wxFrame::SetStatusText
}{wxframesetstatustext
},
\rtfsp
169 \helpref{wxFrame::OnCreateStatusBar
}{wxframeoncreatestatusbar
},
\rtfsp
170 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
172 \membersection{wxFrame::CreateToolBar
}\label{wxframecreatetoolbar
}
174 \func{virtual wxToolBar*
}{CreateToolBar
}{\param{long
}{ style = wxNO
\_BORDER \pipe wxTB
\_HORIZONTAL},
175 \param{wxWindowID
}{ id = -
1},
\param{const wxString\&
}{ name = "toolBar"
}}
177 Creates a toolbar at the top or left of the frame.
179 \wxheading{Parameters
}
181 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
184 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
187 \docparam{name
}{The toolbar window name.
}
189 \wxheading{Return value
}
191 A pointer to the the toolbar if it was created successfully, NULL otherwise.
195 By default, the toolbar is an instance of wxToolBar (which is defined to be
196 a suitable toolbar class on each platform, such as wxToolBar95). To use a different class,
197 override
\helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
}.
199 When a toolbar has been created with this function, or made known to the frame
200 with
\helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}, the frame will manage the toolbar
201 position and adjust the return value from
\helpref{wxWindow::GetClientSize
}{wxwindowgetclientsize
} to
202 reflect the available space for application windows.
206 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\rtfsp
207 \helpref{wxFrame::OnCreateToolBar
}{wxframeoncreatetoolbar
},
\rtfsp
208 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
},
\rtfsp
209 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
211 \membersection{wxFrame::GetMenuBar
}\label{wxframegetmenubar
}
213 \constfunc{wxMenuBar*
}{GetMenuBar
}{\void}
215 Returns a pointer to the menubar currently associated with the frame (if any).
219 \helpref{wxFrame::SetMenuBar
}{wxframesetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}
221 \membersection{wxFrame::GetStatusBar
}\label{wxframegetstatusbar
}
223 \func{wxStatusBar*
}{GetStatusBar
}{\void}
225 Returns a pointer to the status bar currently associated with the frame (if any).
229 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
231 \membersection{wxFrame::GetTitle
}\label{wxframegettitle
}
233 \func{wxString\&
}{GetTitle
}{\void}
235 Gets a temporary pointer to the frame title. See
236 \helpref{wxFrame::SetTitle
}{wxframesettitle
}.
238 \membersection{wxFrame::GetToolBar
}\label{wxframegettoolbar
}
240 \func{wxToolBar*
}{GetToolBar
}{\void}
242 Returns a pointer to the toolbar currently associated with the frame (if any).
246 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
247 \helpref{wxFrame::SetToolBar
}{wxframesettoolbar
}
249 \membersection{wxFrame::Iconize
}\label{wxframeiconize
}
251 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
253 Iconizes or restores the frame.
255 \wxheading{Parameters
}
257 \docparam{izonize
}{If TRUE, iconizes the frame; if FALSE, shows and restores it.
}
261 \helpref{wxFrame::IsIconized
}{wxframeisiconized
},
\helpref{wxFrame::Maximize
}{wxframemaximize
}.
263 \membersection{wxFrame::IsIconized
}\label{wxframeisiconized
}
265 \constfunc{bool
}{IsIconized
}{\void}
267 Returns TRUE if the frame is iconized.
269 \membersection{wxFrame::IsMaximized
}\label{wxframeismaximized
}
271 \constfunc{bool
}{IsMaximized
}{\void}
273 Returns TRUE if the frame is maximized.
275 \membersection{wxFrame::Maximize
}\label{wxframemaximize
}
277 \func{void
}{Maximize
}{\param{const bool
}{maximize
}}
279 Maximizes or restores the frame.
281 \wxheading{Parameters
}
283 \docparam{maximize
}{If TRUE, maximizes the frame, otherwise it restores it
}.
287 This function only works under Windows.
291 \helpref{wxFrame::Iconize
}{wxframeiconize
}
293 \membersection{wxFrame::OnActivate
}
295 \func{void
}{OnActivate
}{\param{wxActivateEvent\&
}{ event
}}
297 Called when a window is activated or deactivated (MS Windows
298 only). See also
\helpref{wxActivateEvent
}{wxactivateevent
}.
300 \membersection{wxFrame::OnCreateStatusBar
}\label{wxframeoncreatestatusbar
}
302 \func{virtual wxStatusBar*
}{OnCreateStatusBar
}{\param{int
}{number
}
303 \param{long
}{ style
},
304 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
306 Virtual function called when a status bar is requested by
\helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
}.
308 \wxheading{Parameters
}
310 \docparam{number
}{The number of fields to create.
}
312 \docparam{style
}{The window style. See
\helpref{wxStatusBar
}{wxstatusbar
} for a list
315 \docparam{id
}{The window identifier. If -
1, an identifier will be chosen by
318 \docparam{name
}{The window name.
}
320 \wxheading{Return value
}
326 An application can override this function to return a different kind of status bar. The default
327 implementation returns an instance of
\helpref{wxStatusBar
}{wxstatusbar
}.
331 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}.
333 \membersection{wxFrame::OnCreateToolBar
}\label{wxframeoncreatetoolbar
}
335 \func{virtual wxToolBar*
}{OnCreateToolBar
}{\param{long
}{ style
},
336 \param{wxWindowID
}{ id
},
\param{const wxString\&
}{ name
}}
338 Virtual function called when a toolbar is requested by
\helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
}.
340 \wxheading{Parameters
}
342 \docparam{style
}{The toolbar style. See
\helpref{wxToolBar
}{wxtoolbar
} for a list
345 \docparam{id
}{The toolbar window identifier. If -
1, an identifier will be chosen by
348 \docparam{name
}{The toolbar window name.
}
350 \wxheading{Return value
}
356 An application can override this function to return a different kind of toolbar. The default
357 implementation returns an instance of
\helpref{wxToolBar
}{wxtoolbar
}.
361 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
}.
363 \membersection{wxFrame::OnMenuCommand
}\label{wxframeonmenucommand
}
365 \func{void
}{OnMenuCommand
}{\param{wxCommandEvent\&
}{ event
}}
367 See
\helpref{wxWindow::OnMenuCommand
}{wxwindowonmenucommand
}.
369 \membersection{wxFrame::OnMenuHighlight
}\label{wxframeonmenuhighlight
}
371 \func{void
}{OnMenuHighlight
}{\param{wxMenuEvent\&
}{ event
}}
373 See
\helpref{wxWindow::OnMenuHighlight
}{wxwindowonmenuhighlight
}.
375 \membersection{wxFrame::OnSize
}\label{wxframeonsize
}
377 \func{void
}{OnSize
}{\param{wxSizeEvent\&
}{event
}}
379 See
\helpref{wxWindow::OnSize
}{wxwindowonsize
}.
381 The default
{\bf wxFrame::OnSize
} implementation looks for a single subwindow,
382 and if one is found, resizes it to fit
383 inside the frame. Override this member if more complex behaviour
384 is required (for example, if there are several subwindows).
386 \membersection{wxFrame::SetIcon
}\label{wxframeseticon
}
388 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
390 Sets the icon for this frame.
392 \wxheading{Parameters
}
394 \docparam{icon
}{The icon to associate with this frame.
}
398 The frame takes a `copy' of
{\it icon
}, but since it uses reference
399 counting, the copy is very quick. It is safe to delete
{\it icon
} after
400 calling this function.
402 Under Windows, instead of using
{\bf SetIcon
}, you can add the
403 following lines to your MS Windows resource file:
406 wxSTD_MDIPARENTFRAME ICON icon1.ico
407 wxSTD_MDICHILDFRAME ICON icon2.ico
408 wxSTD_FRAME ICON icon3.ico
411 where icon1.ico will be used for the MDI parent frame, icon2.ico
412 will be used for MDI child frames, and icon3.ico will be used for
415 If these icons are not supplied, and
{\bf SetIcon
} is not called either,
416 then the following defaults apply if you have included wx.rc.
419 wxDEFAULT_FRAME ICON std.ico
420 wxDEFAULT_MDIPARENTFRAME ICON mdi.ico
421 wxDEFAULT_MDICHILDFRAME ICON child.ico
424 You can replace std.ico, mdi.ico and child.ico with your own defaults
425 for all your wxWindows application. Currently they show the same icon.
427 {\it Note:
} a wxWindows application linked with subsystem equal to
4.0
428 (i.e. marked as a Windows
95 application) doesn't respond properly
429 to wxFrame::SetIcon. To work around this until a solution is found,
430 mark your program as a
3.5 application. This will also ensure
431 that Windows provides small icons for the application automatically.
433 See also
\helpref{wxIcon
}{wxicon
}.
435 \membersection{wxFrame::SetMenuBar
}\label{wxframesetmenubar
}
437 \func{void
}{SetMenuBar
}{\param{wxMenuBar*
}{menuBar
}}
439 Tells the frame to show the given menu bar.
441 \wxheading{Parameters
}
443 \docparam{menuBar
}{The menu bar to associate with the frame.
}
447 If the frame is destroyed, the
448 menu bar and its menus will be destroyed also, so do not delete the menu
449 bar explicitly (except by resetting the frame's menu bar to another
452 Under Windows, a call to
\helpref{wxFrame::OnSize
}{wxframeonsize
} is generated, so be sure to initialize
453 data members properly before calling
{\bf SetMenuBar
}.
455 Note that it is not possible to call this function twice for the same frame object.
459 \helpref{wxFrame::GetMenuBar
}{wxframegetmenubar
},
\helpref{wxMenuBar
}{wxmenubar
},
\helpref{wxMenu
}{wxmenu
}.
461 \membersection{wxFrame::SetStatusBar
}\label{wxframesetstatusbar
}
463 \func{void
}{SetStatusBar
}{\param{wxStatusBar*
}{ statusBar
}}
465 Associates a status bar with the frame.
469 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
},
\rtfsp
470 \helpref{wxFrame::GetStatusBar
}{wxframegetstatusbar
}
472 \membersection{wxFrame::SetStatusText
}\label{wxframesetstatustext
}
474 \func{virtual void
}{SetStatusText
}{\param{const wxString\&
}{ text
},
\param{int
}{ number =
0}}
476 Sets the status bar text and redraws the status bar.
478 \wxheading{Parameters
}
480 \docparam{text
}{The text for the status field.
}
482 \docparam{number
}{The status field (starting from zero).
}
486 Use an empty string to clear the status bar.
490 \helpref{wxFrame::CreateStatusBar
}{wxframecreatestatusbar
},
\helpref{wxStatusBar
}{wxstatusbar
}
492 \membersection{wxFrame::SetStatusWidths
}\label{wxframesetstatuswidths
}
494 \func{virtual void
}{SetStatusWidths
}{\param{int
}{ n
},
\param{int *
}{widths
}}
496 Sets the widths of the fields in the status bar.
498 \wxheading{Parameters
}
500 \wxheading{n
}{The number of fields in the status bar. It must be the
501 same used in
\helpref{CreateStatusBar
}{wxframecreatestatusbar
}.
}
503 \docparam{widths
}{Must contain an array of
{\it n
} integers, each of which is a status field width
504 in pixels. A value of -
1 indicates that the field is variable width; at least one
505 field must be -
1. You should delete this array after calling
{\bf SetStatusWidths
}.
}
509 The widths of the variable fields are calculated from the total width of all fields,
510 minus the sum of widths of the non-variable fields, divided by the number of
513 \membersection{wxFrame::SetToolBar
}\label{wxframesettoolbar
}
515 \func{void
}{SetToolBar
}{\param{wxToolBar*
}{ toolBar
}}
517 Associates a toolbar with the frame.
521 \helpref{wxFrame::CreateToolBar
}{wxframecreatetoolbar
},
\helpref{wxToolBar
}{wxtoolbar
},
\rtfsp
522 \helpref{wxFrame::GetToolBar
}{wxframegettoolbar
}
524 \membersection{wxFrame::SetTitle
}\label{wxframesettitle
}
526 \func{virtual void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
528 Sets the frame title.
530 \wxheading{Parameters
}
532 \docparam{title
}{The frame title.
}
536 \helpref{wxFrame::GetTitle
}{wxframegettitle
}