]>
git.saurik.com Git - wxWidgets.git/blob - interface/frame.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFrame
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A frame is a window whose size and position can (usually) be changed by the user.
15 It usually has thick borders and a title bar, and can optionally contain a
16 menu bar, toolbar and status bar. A frame can contain any window that is not
19 A frame that has a status bar and toolbar, created via the CreateStatusBar() and
20 CreateToolBar() functions, manages these windows and adjusts the value returned
21 by GetClientSize() to reflect the remaining size available to application windows.
23 @remarks An application should normally define an wxCloseEvent handler for the
24 frame to respond to system close events, for example so that related
25 data and subwindows can be cleaned up.
28 @section wxframe_defaultevent Default event processing
30 wxFrame processes the following events:
32 @li @c wxEVT_SIZE: if the frame has exactly one child window, not counting the
33 status and toolbar, this child is resized to take the entire frame client area.
34 If two or more windows are present, they should be laid out explicitly either
35 by manually handling wxEVT_SIZE or using sizers;
36 @li @c wxEVT_MENU_HIGHLIGHT: the default implementation displays the help string
37 associated with the selected item in the first pane of the status bar, if there is one.
41 @style{wxDEFAULT_FRAME_STYLE}
42 Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER |
43 wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN.
45 Display the frame iconized (minimized). Windows only.
47 Puts a caption on the frame.
49 Identical to wxICONIZE. Windows only.
50 @style{wxMINIMIZE_BOX}
51 Displays a minimize box on the frame.
53 Displays the frame maximized. Windows only.
54 @style{wxMAXIMIZE_BOX}
55 Displays a maximize box on the frame.
57 Displays a close box on the frame.
59 Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT.
61 Displays a system menu.
62 @style{wxRESIZE_BORDER}
63 Displays a resizeable border around the window.
64 @style{wxFRAME_TOOL_WINDOW}
65 Causes a frame with a small titlebar to be created; the frame does
66 not appear in the taskbar under Windows or GTK+.
67 @style{wxFRAME_NO_TASKBAR}
68 Creates an otherwise normal frame but it does not appear in the
69 taskbar under Windows or GTK+ (note that it will minimize to the
70 desktop window under Windows which may seem strange to the users
71 and thus it might be better to use this style only without
72 wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if GTK+
73 is at least version 2.2 and the window manager supports
74 _NET_WM_STATE_SKIP_TASKBAR hint. Has no effect under other platforms.
75 @style{wxFRAME_FLOAT_ON_PARENT}
76 The frame will always be on top of its parent (unlike wxSTAY_ON_TOP).
77 A frame created with this style must have a non-@NULL parent.
78 @style{wxFRAME_SHAPED}
79 Windows with this style are allowed to have their shape changed
80 with the SetShape() method.
83 The default frame style is for normal, resizeable frames.
84 To create a frame which can not be resized by user, you may use the following
85 combination of styles:
88 wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxRESIZE_BOX | wxMAXIMIZE_BOX)
91 See also the @ref overview_windowstyles.
94 @style{wxFRAME_EX_CONTEXTHELP}
95 Under Windows, puts a query button on the caption. When pressed,
96 Windows will go into a context-sensitive help mode and wxWidgets
97 will send a wxEVT_HELP event if the user clicked on an application
98 window. Note that this is an extended style and must be set by
99 calling SetExtraStyle before Create is called (two-step
100 construction). You cannot use this style together with
101 wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use
102 wxDEFAULT_FRAME_STYLE ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the
103 frames having this style (the dialogs don't have a minimize or a
104 maximize box by default)
105 @style{wxFRAME_EX_METAL}
106 On Mac OS X, frames with this style will be shown with a metallic
107 look. This is an extra style.
111 @category{managedwnd}
113 @see wxMDIParentFrame, wxMDIChildFrame, wxMiniFrame, wxDialog
115 class wxFrame
: public wxTopLevelWindow
120 Constructor, creating the window.
123 The window parent. This may be @NULL. If it is non-@NULL, the frame will
124 always be displayed on top of the parent window on Windows.
126 The window identifier. It may take a value of -1 to indicate a default
129 The caption to be displayed on the frame's title bar.
131 The window position. The value wxDefaultPosition indicates a default position,
133 either the windowing system or wxWidgets, depending on platform.
135 The window size. The value wxDefaultSize indicates a default size, chosen by
136 either the windowing system or wxWidgets, depending on platform.
138 The window style. See wxFrame.
140 The name of the window. This parameter is used to associate a name with the
142 allowing the application user to set Motif resource values for
145 @remarks For Motif, MWM (the Motif Window Manager) should be running for
146 any window styles to work (otherwise all styles take
152 wxFrame(wxWindow
* parent
, wxWindowID id
,
153 const wxString
& title
,
154 const wxPoint
& pos
= wxDefaultPosition
,
155 const wxSize
& size
= wxDefaultSize
,
156 long style
= wxDEFAULT_FRAME_STYLE
,
157 const wxString
& name
= "frame");
161 Destructor. Destroys all child windows and menu bar if present.
166 Centres the frame on the display.
169 The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.
171 void Centre(int direction
= wxBOTH
);
174 Used in two-step frame construction. See wxFrame()
177 bool Create(wxWindow
* parent
, wxWindowID id
,
178 const wxString
& title
,
179 const wxPoint
& pos
= wxDefaultPosition
,
180 const wxSize
& size
= wxDefaultSize
,
181 long style
= wxDEFAULT_FRAME_STYLE
,
182 const wxString
& name
= "frame");
185 Creates a status bar at the bottom of the frame.
188 The number of fields to create. Specify a
189 value greater than 1 to create a multi-field status bar.
191 The status bar style. See wxStatusBar for a list
194 The status bar window identifier. If -1, an identifier will be chosen by
197 The status bar window name.
199 @return A pointer to the status bar if it was created successfully, @NULL
202 @remarks The width of the status bar is the whole width of the frame
203 (adjusted automatically when resizing), and the height
204 and text size are chosen by the host windowing system.
206 @see SetStatusText(), OnCreateStatusBar(), GetStatusBar()
208 virtual wxStatusBar
* CreateStatusBar(int number
= 1,
211 const wxString
& name
= "statusBar");
214 Creates a toolbar at the top or left of the frame.
217 The toolbar style. See wxToolBar for a list
220 The toolbar window identifier. If -1, an identifier will be chosen by
223 The toolbar window name.
225 @return A pointer to the toolbar if it was created successfully, @NULL
228 @remarks By default, the toolbar is an instance of wxToolBar (which is
229 defined to be a suitable toolbar class on each
230 platform, such as wxToolBar95). To use a different
231 class, override OnCreateToolBar().
233 @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(),
236 virtual wxToolBar
* CreateToolBar(long style
= wxBORDER_NONE
| wxTB_HORIZONTAL
,
238 const wxString
& name
= "toolBar");
241 Returns the origin of the frame client area (in client coordinates). It may be
242 different from (0, 0) if the frame has a toolbar.
244 wxPoint
GetClientAreaOrigin() const;
247 Returns a pointer to the menubar currently associated with the frame (if any).
249 @see SetMenuBar(), wxMenuBar, wxMenu
251 wxMenuBar
* GetMenuBar() const;
254 Returns a pointer to the status bar currently associated with the frame (if
257 @see CreateStatusBar(), wxStatusBar
259 wxStatusBar
* GetStatusBar() const;
262 Returns the status bar pane used to display menu and toolbar help.
264 @see SetStatusBarPane()
266 int GetStatusBarPane();
269 Returns a pointer to the toolbar currently associated with the frame (if any).
271 @see CreateToolBar(), wxToolBar, SetToolBar()
273 wxToolBar
* GetToolBar() const;
276 Virtual function called when a status bar is requested by CreateStatusBar().
279 The number of fields to create.
281 The window style. See wxStatusBar for a list
284 The window identifier. If -1, an identifier will be chosen by
289 @return A status bar object.
291 @remarks An application can override this function to return a different
292 kind of status bar. The default implementation returns
293 an instance of wxStatusBar.
295 @see CreateStatusBar(), wxStatusBar.
297 virtual wxStatusBar
* OnCreateStatusBar(int number
, long style
,
299 const wxString
& name
);
302 Virtual function called when a toolbar is requested by CreateToolBar().
305 The toolbar style. See wxToolBar for a list
308 The toolbar window identifier. If -1, an identifier will be chosen by
311 The toolbar window name.
313 @return A toolbar object.
315 @remarks An application can override this function to return a different
316 kind of toolbar. The default implementation returns an
317 instance of wxToolBar.
319 @see CreateToolBar(), wxToolBar.
321 virtual wxToolBar
* OnCreateToolBar(long style
, wxWindowID id
,
322 const wxString
& name
);
325 Simulate a menu command.
328 The identifier for a menu item.
330 void ProcessCommand(int id
);
333 This function sends a dummy @ref overview_wxsizeevent "size event" to the frame
334 forcing it to reevaluate its children positions. It is sometimes useful to call
335 this function after adding or deleting a children after the frame creation or
336 if a child size changes.
337 Note that if the frame is using either sizers or constraints for the children
338 layout, it is enough to call wxWindow::Layout directly and
339 this function should not be used in this case.
341 void SendSizeEvent();
344 Tells the frame to show the given menu bar.
347 The menu bar to associate with the frame.
349 @remarks If the frame is destroyed, the menu bar and its menus will be
350 destroyed also, so do not delete the menu bar
351 explicitly (except by resetting the frame's menu bar to
352 another frame or @NULL).
354 @see GetMenuBar(), wxMenuBar, wxMenu.
356 void SetMenuBar(wxMenuBar
* menuBar
);
359 Associates a status bar with the frame.
361 @see CreateStatusBar(), wxStatusBar, GetStatusBar()
363 void SetStatusBar(wxStatusBar
* statusBar
);
366 Set the status bar pane used to display menu and toolbar help.
367 Using -1 disables help display.
369 void SetStatusBarPane(int n
);
372 Sets the status bar text and redraws the status bar.
375 The text for the status field.
377 The status field (starting from zero).
379 @remarks Use an empty string to clear the status bar.
381 @see CreateStatusBar(), wxStatusBar
383 virtual void SetStatusText(const wxString
& text
, int number
= 0);
386 Sets the widths of the fields in the status bar.
389 The number of fields in the status bar. It must be the
390 same used in CreateStatusBar.
392 Must contain an array of n integers, each of which is a status field width
393 in pixels. A value of -1 indicates that the field is variable width; at
395 field must be -1. You should delete this array after calling
398 @remarks The widths of the variable fields are calculated from the total
399 width of all fields, minus the sum of widths of the
400 non-variable fields, divided by the number of variable
403 virtual void SetStatusWidths(int n
, int* widths
);
406 Associates a toolbar with the frame.
408 void SetToolBar(wxToolBar
* toolBar
);