]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/frame.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFrame
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 #define wxFRAME_NO_TASKBAR 0x0002 // No taskbar button (MSW only)
13 #define wxFRAME_TOOL_WINDOW 0x0004 // No taskbar button, no system menu
14 #define wxFRAME_FLOAT_ON_PARENT 0x0008 // Always above its parent
20 A frame is a window whose size and position can (usually) be changed by the user.
22 It usually has thick borders and a title bar, and can optionally contain a
23 menu bar, toolbar and status bar. A frame can contain any window that is not
26 A frame that has a status bar and toolbar, created via the CreateStatusBar() and
27 CreateToolBar() functions, manages these windows and adjusts the value returned
28 by GetClientSize() to reflect the remaining size available to application windows.
30 @remarks An application should normally define an wxCloseEvent handler for the
31 frame to respond to system close events, for example so that related
32 data and subwindows can be cleaned up.
35 @section frame_defaultevent Default event processing
37 wxFrame processes the following events:
39 @li @c wxEVT_SIZE: if the frame has exactly one child window, not counting the
40 status and toolbar, this child is resized to take the entire frame client area.
41 If two or more windows are present, they should be laid out explicitly either
42 by manually handling @c wxEVT_SIZE or using sizers;
43 @li @c wxEVT_MENU_HIGHLIGHT: the default implementation displays the help string
44 associated with the selected item in the first pane of the status bar, if there is one.
48 @style{wxDEFAULT_FRAME_STYLE}
49 Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER |
50 wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN.
52 Display the frame iconized (minimized). Windows only.
54 Puts a caption on the frame. Notice that this flag is required by
55 wxMINIMIZE_BOX, wxMAXIMIZE_BOX and wxCLOSE_BOX on most systems as
56 the corresponding buttons cannot be shown if the window has no title
57 bar at all. I.e. if wxCAPTION is not specified those styles would be
60 Identical to wxICONIZE. Windows only.
61 @style{wxMINIMIZE_BOX}
62 Displays a minimize box on the frame.
64 Displays the frame maximized. Windows and GTK+ only.
65 @style{wxMAXIMIZE_BOX}
66 Displays a maximize box on the frame. Notice that under wxGTK
67 wxRESIZE_BORDER must be used as well or this style is ignored.
69 Displays a close box on the frame.
71 Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT.
73 Displays a system menu containing the list of various windows
74 commands in the window title bar. Unlike wxMINIMIZE_BOX,
75 wxMAXIMIZE_BOX and wxCLOSE_BOX styles this style can be used without
76 wxCAPTION, at least under Windows, and makes the system menu
77 available without showing it on screen in this case. However it is
78 recommended to only use it together with wxCAPTION for consistent
79 behaviour under all platforms.
80 @style{wxRESIZE_BORDER}
81 Displays a resizable border around the window.
82 @style{wxFRAME_TOOL_WINDOW}
83 Causes a frame with a small title bar to be created; the frame does
84 not appear in the taskbar under Windows or GTK+.
85 @style{wxFRAME_NO_TASKBAR}
86 Creates an otherwise normal frame but it does not appear in the
87 taskbar under Windows or GTK+ (note that it will minimize to the
88 desktop window under Windows which may seem strange to the users
89 and thus it might be better to use this style only without
90 wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if the
91 window manager supports _NET_WM_STATE_SKIP_TASKBAR hint.
92 @style{wxFRAME_FLOAT_ON_PARENT}
93 The frame will always be on top of its parent (unlike wxSTAY_ON_TOP).
94 A frame created with this style must have a non-@NULL parent.
95 @style{wxFRAME_SHAPED}
96 Windows with this style are allowed to have their shape changed
97 with the SetShape() method.
100 The default frame style is for normal, resizable frames.
101 To create a frame which cannot be resized by user, you may use the following
102 combination of styles:
105 wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX)
108 See also the @ref overview_windowstyles.
110 @beginExtraStyleTable
111 @style{wxFRAME_EX_CONTEXTHELP}
112 Under Windows, puts a query button on the caption. When pressed,
113 Windows will go into a context-sensitive help mode and wxWidgets
114 will send a @c wxEVT_HELP event if the user clicked on an application
115 window. Note that this is an extended style and must be set by
116 calling SetExtraStyle before Create is called (two-step
117 construction). You cannot use this style together with
118 wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use
119 wxDEFAULT_FRAME_STYLE ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the
120 frames having this style (the dialogs don't have a minimize or a
121 maximize box by default)
122 @style{wxFRAME_EX_METAL}
123 On Mac OS X, frames with this style will be shown with a metallic
124 look. This is an extra style.
127 @beginEventEmissionTable
128 @event{EVT_CLOSE(func)}
129 Process a @c wxEVT_CLOSE_WINDOW event when the frame is being
130 closed by the user or programmatically (see wxWindow::Close).
131 The user may generate this event clicking the close button
132 (typically the 'X' on the top-right of the title bar) if it's present
133 (see the @c wxCLOSE_BOX style). See wxCloseEvent.
134 @event{EVT_ICONIZE(func)}
135 Process a @c wxEVT_ICONIZE event. See wxIconizeEvent.
136 @event{EVT_MENU_OPEN(func)}
137 A menu is about to be opened. See wxMenuEvent.
138 @event{EVT_MENU_CLOSE(func)}
139 A menu has been just closed. See wxMenuEvent.
140 @event{EVT_MENU_HIGHLIGHT(id, func)}
141 The menu item with the specified id has been highlighted: used to show
142 help prompts in the status bar by wxFrame. See wxMenuEvent.
143 @event{EVT_MENU_HIGHLIGHT_ALL(func)}
144 A menu item has been highlighted, i.e. the currently selected menu item has changed.
149 @category{managedwnd}
151 @see wxMDIParentFrame, wxMDIChildFrame, wxMiniFrame, wxDialog
153 class wxFrame
: public wxTopLevelWindow
162 Constructor, creating the window.
165 The window parent. This may be @NULL. If it is non-@NULL, the frame will
166 always be displayed on top of the parent window on Windows.
168 The window identifier. It may take a value of -1 to indicate a default value.
170 The caption to be displayed on the frame's title bar.
172 The window position. The value wxDefaultPosition indicates a default position,
173 chosen by either the windowing system or wxWidgets, depending on platform.
175 The window size. The value wxDefaultSize indicates a default size, chosen by
176 either the windowing system or wxWidgets, depending on platform.
178 The window style. See wxFrame class description.
180 The name of the window. This parameter is used to associate a name with
181 the item, allowing the application user to set Motif resource values for
184 @remarks For Motif, MWM (the Motif Window Manager) should be running for
185 any window styles to work (otherwise all styles take effect).
189 wxFrame(wxWindow
* parent
, wxWindowID id
,
190 const wxString
& title
,
191 const wxPoint
& pos
= wxDefaultPosition
,
192 const wxSize
& size
= wxDefaultSize
,
193 long style
= wxDEFAULT_FRAME_STYLE
,
194 const wxString
& name
= wxFrameNameStr
);
197 Destructor. Destroys all child windows and menu bar if present.
199 See @ref overview_windowdeletion for more info.
204 Centres the frame on the display.
207 The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.
209 void Centre(int direction
= wxBOTH
);
212 Used in two-step frame construction.
213 See wxFrame() for further details.
215 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& title
,
216 const wxPoint
& pos
= wxDefaultPosition
,
217 const wxSize
& size
= wxDefaultSize
,
218 long style
= wxDEFAULT_FRAME_STYLE
,
219 const wxString
& name
= wxFrameNameStr
);
222 Creates a status bar at the bottom of the frame.
225 The number of fields to create. Specify a
226 value greater than 1 to create a multi-field status bar.
228 The status bar style. See wxStatusBar for a list of valid styles.
230 The status bar window identifier. If -1, an identifier will be chosen
233 The status bar window name.
235 @return A pointer to the status bar if it was created successfully, @NULL
238 @remarks The width of the status bar is the whole width of the frame
239 (adjusted automatically when resizing), and the height
240 and text size are chosen by the host windowing system.
242 @see SetStatusText(), OnCreateStatusBar(), GetStatusBar()
244 virtual wxStatusBar
* CreateStatusBar(int number
= 1, long style
= wxSTB_DEFAULT_STYLE
,
246 const wxString
& name
= wxStatusBarNameStr
);
249 Creates a toolbar at the top or left of the frame.
252 The toolbar style. See wxToolBar for a list of valid styles.
254 The toolbar window identifier. If -1, an identifier will be chosen
257 The toolbar window name.
259 @return A pointer to the toolbar if it was created successfully, @NULL
263 By default, the toolbar is an instance of wxToolBar.
264 To use a different class, override OnCreateToolBar().
265 When a toolbar has been created with this function, or made
266 known to the frame with wxFrame::SetToolBar(), the frame will
267 manage the toolbar position and adjust the return value from
268 wxWindow::GetClientSize() to reflect the available space for
270 Under Pocket PC, you should always use this function for creating
271 the toolbar to be managed by the frame, so that wxWidgets can
272 use a combined menubar and toolbar.
273 Where you manage your own toolbars, create a wxToolBar as usual.
275 @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(), GetToolBar()
277 virtual wxToolBar
* CreateToolBar(long style
= wxBORDER_NONE
| wxTB_HORIZONTAL
,
278 wxWindowID id
= wxID_ANY
,
279 const wxString
& name
= wxToolBarNameStr
);
282 Returns the origin of the frame client area (in client coordinates).
283 It may be different from (0, 0) if the frame has a toolbar.
285 virtual wxPoint
GetClientAreaOrigin() const;
288 Returns a pointer to the menubar currently associated with the frame (if any).
290 @see SetMenuBar(), wxMenuBar, wxMenu
292 virtual wxMenuBar
* GetMenuBar() const;
295 Returns a pointer to the status bar currently associated with the frame
298 @see CreateStatusBar(), wxStatusBar
300 virtual wxStatusBar
* GetStatusBar() const;
303 Returns the status bar pane used to display menu and toolbar help.
305 @see SetStatusBarPane()
307 int GetStatusBarPane() const;
310 Returns a pointer to the toolbar currently associated with the frame (if any).
312 @see CreateToolBar(), wxToolBar, SetToolBar()
314 virtual wxToolBar
* GetToolBar() const;
317 Virtual function called when a status bar is requested by CreateStatusBar().
320 The number of fields to create.
322 The window style. See wxStatusBar for a list
325 The window identifier. If -1, an identifier will be chosen by
330 @return A status bar object.
332 @remarks An application can override this function to return a different
333 kind of status bar. The default implementation returns
334 an instance of wxStatusBar.
336 @see CreateStatusBar(), wxStatusBar.
338 virtual wxStatusBar
* OnCreateStatusBar(int number
, long style
,
340 const wxString
& name
);
343 Virtual function called when a toolbar is requested by CreateToolBar().
346 The toolbar style. See wxToolBar for a list
349 The toolbar window identifier. If -1, an identifier will be chosen by
352 The toolbar window name.
354 @return A toolbar object.
356 @remarks An application can override this function to return a different
357 kind of toolbar. The default implementation returns an
358 instance of wxToolBar.
360 @see CreateToolBar(), wxToolBar.
362 virtual wxToolBar
* OnCreateToolBar(long style
, wxWindowID id
,
363 const wxString
& name
);
366 Simulate a menu command.
369 The identifier for a menu item.
371 bool ProcessCommand(int id
);
374 Tells the frame to show the given menu bar.
377 The menu bar to associate with the frame.
379 @remarks If the frame is destroyed, the menu bar and its menus will be
380 destroyed also, so do not delete the menu bar
381 explicitly (except by resetting the frame's menu bar to
382 another frame or @NULL).
383 Under Windows, a size event is generated, so be sure to
384 initialize data members properly before calling SetMenuBar().
385 Note that on some platforms, it is not possible to call this
386 function twice for the same frame object.
388 @see GetMenuBar(), wxMenuBar, wxMenu.
390 virtual void SetMenuBar(wxMenuBar
* menuBar
);
393 Associates a status bar with the frame.
395 If @a statusBar is @NULL, then the status bar, if present, is detached from
396 the frame, but @e not deleted.
398 @see CreateStatusBar(), wxStatusBar, GetStatusBar()
400 virtual void SetStatusBar(wxStatusBar
* statusBar
);
403 Set the status bar pane used to display menu and toolbar help.
404 Using -1 disables help display.
406 void SetStatusBarPane(int n
);
409 Sets the status bar text and redraws the status bar.
412 The text for the status field.
414 The status field (starting from zero).
416 @remarks Use an empty string to clear the status bar.
418 @see CreateStatusBar(), wxStatusBar
420 virtual void SetStatusText(const wxString
& text
, int number
= 0);
423 Sets the widths of the fields in the status bar.
426 The number of fields in the status bar. It must be the
427 same used in CreateStatusBar.
429 Must contain an array of n integers, each of which is a status field width
430 in pixels. A value of -1 indicates that the field is variable width; at
431 least one field must be -1. You should delete this array after calling
434 @remarks The widths of the variable fields are calculated from the total
435 width of all fields, minus the sum of widths of the
436 non-variable fields, divided by the number of variable fields.
439 In wxPerl this method takes the field widths as parameters.
442 virtual void SetStatusWidths(int n
, const int* widths_field
);
445 Associates a toolbar with the frame.
447 virtual void SetToolBar(wxToolBar
* toolBar
);
450 void PushStatusText(const wxString
&text
, int number
= 0);
451 void PopStatusText(int number
= 0);