]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/frame.h
run tests on the wxMSW port again
[wxWidgets.git] / interface / wx / frame.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: frame.h
e54c96f1 3// Purpose: interface of wxFrame
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxFrame
7c913512 11
ea6a2ccb
FM
12 A frame is a window whose size and position can (usually) be changed by the user.
13
14 It usually has thick borders and a title bar, and can optionally contain a
15 menu bar, toolbar and status bar. A frame can contain any window that is not
23324ae1 16 a frame or dialog.
7c913512 17
ea6a2ccb
FM
18 A frame that has a status bar and toolbar, created via the CreateStatusBar() and
19 CreateToolBar() functions, manages these windows and adjusts the value returned
20 by GetClientSize() to reflect the remaining size available to application windows.
21
22 @remarks An application should normally define an wxCloseEvent handler for the
23 frame to respond to system close events, for example so that related
24 data and subwindows can be cleaned up.
25
26
674d80a7 27 @section frame_defaultevent Default event processing
ea6a2ccb
FM
28
29 wxFrame processes the following events:
30
31 @li @c wxEVT_SIZE: if the frame has exactly one child window, not counting the
32 status and toolbar, this child is resized to take the entire frame client area.
33 If two or more windows are present, they should be laid out explicitly either
9d157d59 34 by manually handling @c wxEVT_SIZE or using sizers;
ea6a2ccb
FM
35 @li @c wxEVT_MENU_HIGHLIGHT: the default implementation displays the help string
36 associated with the selected item in the first pane of the status bar, if there is one.
37
7c913512 38
23324ae1 39 @beginStyleTable
8c6791e4 40 @style{wxDEFAULT_FRAME_STYLE}
7c913512 41 Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER |
23324ae1 42 wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN.
8c6791e4 43 @style{wxICONIZE}
23324ae1 44 Display the frame iconized (minimized). Windows only.
8c6791e4 45 @style{wxCAPTION}
23324ae1 46 Puts a caption on the frame.
8c6791e4 47 @style{wxMINIMIZE}
23324ae1 48 Identical to wxICONIZE. Windows only.
8c6791e4 49 @style{wxMINIMIZE_BOX}
23324ae1 50 Displays a minimize box on the frame.
8c6791e4 51 @style{wxMAXIMIZE}
23324ae1 52 Displays the frame maximized. Windows only.
8c6791e4 53 @style{wxMAXIMIZE_BOX}
23324ae1 54 Displays a maximize box on the frame.
8c6791e4 55 @style{wxCLOSE_BOX}
23324ae1 56 Displays a close box on the frame.
8c6791e4 57 @style{wxSTAY_ON_TOP}
23324ae1 58 Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT.
8c6791e4 59 @style{wxSYSTEM_MENU}
23324ae1 60 Displays a system menu.
8c6791e4 61 @style{wxRESIZE_BORDER}
23324ae1 62 Displays a resizeable border around the window.
8c6791e4 63 @style{wxFRAME_TOOL_WINDOW}
23324ae1
FM
64 Causes a frame with a small titlebar to be created; the frame does
65 not appear in the taskbar under Windows or GTK+.
8c6791e4 66 @style{wxFRAME_NO_TASKBAR}
23324ae1
FM
67 Creates an otherwise normal frame but it does not appear in the
68 taskbar under Windows or GTK+ (note that it will minimize to the
69 desktop window under Windows which may seem strange to the users
70 and thus it might be better to use this style only without
71 wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if GTK+
7c913512 72 is at least version 2.2 and the window manager supports
ea6a2ccb 73 _NET_WM_STATE_SKIP_TASKBAR hint. Has no effect under other platforms.
8c6791e4 74 @style{wxFRAME_FLOAT_ON_PARENT}
ea6a2ccb
FM
75 The frame will always be on top of its parent (unlike wxSTAY_ON_TOP).
76 A frame created with this style must have a non-@NULL parent.
77 @style{wxFRAME_SHAPED}
78 Windows with this style are allowed to have their shape changed
79 with the SetShape() method.
80 @endStyleTable
81
82 The default frame style is for normal, resizeable frames.
83 To create a frame which can not be resized by user, you may use the following
84 combination of styles:
85
86 @code
15840e67 87 wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX)
ea6a2ccb
FM
88 @endcode
89
90 See also the @ref overview_windowstyles.
91
92 @beginExtraStyleTable
8c6791e4 93 @style{wxFRAME_EX_CONTEXTHELP}
23324ae1
FM
94 Under Windows, puts a query button on the caption. When pressed,
95 Windows will go into a context-sensitive help mode and wxWidgets
96 will send a wxEVT_HELP event if the user clicked on an application
97 window. Note that this is an extended style and must be set by
98 calling SetExtraStyle before Create is called (two-step
99 construction). You cannot use this style together with
100 wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use
101 wxDEFAULT_FRAME_STYLE ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the
102 frames having this style (the dialogs don't have a minimize or a
103 maximize box by default)
8c6791e4 104 @style{wxFRAME_EX_METAL}
23324ae1
FM
105 On Mac OS X, frames with this style will be shown with a metallic
106 look. This is an extra style.
ea6a2ccb 107 @endExtraStyleTable
7c913512 108
3051a44a 109 @beginEventEmissionTable
9d157d59
FM
110 @event{EVT_CLOSE(func)}
111 The frame is being closed by the user or programmatically (see wxWindow::Close).
112 The user may generate this event clicking the close button
113 (typically the 'X' on the top-right of the title bar) if it's present
3051a44a
FM
114 (see the @c wxCLOSE_BOX style). See wxCloseEvent.
115 @event{EVT_ICONIZE(func)}
116 Process a @c wxEVT_ICONIZE event. See wxIconizeEvent.
117 @event{EVT_MENU_OPEN(func)}
118 A menu is about to be opened. See wxMenuEvent.
119 @event{EVT_MENU_CLOSE(func)}
120 A menu has been just closed. See wxMenuEvent.
121 @event{EVT_MENU_HIGHLIGHT(id, func)}
122 The menu item with the specified id has been highlighted: used to show
123 help prompts in the status bar by wxFrame. See wxMenuEvent.
124 @event{EVT_MENU_HIGHLIGHT_ALL(func)}
125 A menu item has been highlighted, i.e. the currently selected menu item has changed.
126 See wxMenuEvent.
9d157d59
FM
127 @endEventTable
128
23324ae1
FM
129 @library{wxcore}
130 @category{managedwnd}
7c913512 131
e54c96f1 132 @see wxMDIParentFrame, wxMDIChildFrame, wxMiniFrame, wxDialog
23324ae1
FM
133*/
134class wxFrame : public wxTopLevelWindow
135{
136public:
674d80a7
FM
137 /**
138 Default constructor.
139 */
140 wxFrame();
141
23324ae1
FM
142 /**
143 Constructor, creating the window.
3c4f71cc 144
7c913512 145 @param parent
4cc4bfaf
FM
146 The window parent. This may be @NULL. If it is non-@NULL, the frame will
147 always be displayed on top of the parent window on Windows.
7c913512 148 @param id
674d80a7 149 The window identifier. It may take a value of -1 to indicate a default value.
7c913512 150 @param title
4cc4bfaf 151 The caption to be displayed on the frame's title bar.
7c913512 152 @param pos
4cc4bfaf 153 The window position. The value wxDefaultPosition indicates a default position,
674d80a7 154 chosen by either the windowing system or wxWidgets, depending on platform.
7c913512 155 @param size
4cc4bfaf
FM
156 The window size. The value wxDefaultSize indicates a default size, chosen by
157 either the windowing system or wxWidgets, depending on platform.
7c913512 158 @param style
674d80a7 159 The window style. See wxFrame class description.
7c913512 160 @param name
674d80a7
FM
161 The name of the window. This parameter is used to associate a name with
162 the item, allowing the application user to set Motif resource values for
4cc4bfaf 163 individual windows.
3c4f71cc 164
23324ae1 165 @remarks For Motif, MWM (the Motif Window Manager) should be running for
674d80a7 166 any window styles to work (otherwise all styles take effect).
3c4f71cc 167
4cc4bfaf 168 @see Create()
23324ae1 169 */
7c913512
FM
170 wxFrame(wxWindow* parent, wxWindowID id,
171 const wxString& title,
172 const wxPoint& pos = wxDefaultPosition,
173 const wxSize& size = wxDefaultSize,
174 long style = wxDEFAULT_FRAME_STYLE,
408776d0 175 const wxString& name = wxFrameNameStr);
23324ae1
FM
176
177 /**
178 Destructor. Destroys all child windows and menu bar if present.
2e4f32d7
FM
179
180 See @ref overview_windowdeletion for more info.
23324ae1 181 */
adaaa686 182 virtual ~wxFrame();
23324ae1
FM
183
184 /**
185 Centres the frame on the display.
3c4f71cc 186
7c913512 187 @param direction
4cc4bfaf 188 The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.
23324ae1
FM
189 */
190 void Centre(int direction = wxBOTH);
191
192 /**
674d80a7
FM
193 Used in two-step frame construction.
194 See wxFrame() for further details.
23324ae1 195 */
43c48e1e 196 bool Create(wxWindow* parent, wxWindowID id, const wxString& title,
23324ae1
FM
197 const wxPoint& pos = wxDefaultPosition,
198 const wxSize& size = wxDefaultSize,
199 long style = wxDEFAULT_FRAME_STYLE,
43c48e1e 200 const wxString& name = wxFrameNameStr);
23324ae1
FM
201
202 /**
203 Creates a status bar at the bottom of the frame.
3c4f71cc 204
7c913512 205 @param number
4cc4bfaf
FM
206 The number of fields to create. Specify a
207 value greater than 1 to create a multi-field status bar.
7c913512 208 @param style
674d80a7 209 The status bar style. See wxStatusBar for a list of valid styles.
7c913512 210 @param id
674d80a7
FM
211 The status bar window identifier. If -1, an identifier will be chosen
212 by wxWidgets.
7c913512 213 @param name
4cc4bfaf 214 The status bar window name.
3c4f71cc 215
d29a9a8a 216 @return A pointer to the status bar if it was created successfully, @NULL
674d80a7 217 otherwise.
3c4f71cc 218
23324ae1 219 @remarks The width of the status bar is the whole width of the frame
4cc4bfaf
FM
220 (adjusted automatically when resizing), and the height
221 and text size are chosen by the host windowing system.
3c4f71cc 222
4cc4bfaf 223 @see SetStatusText(), OnCreateStatusBar(), GetStatusBar()
23324ae1 224 */
43c48e1e
FM
225 virtual wxStatusBar* CreateStatusBar(int number = 1, long style = wxST_SIZEGRIP|wxFULL_REPAINT_ON_RESIZE,
226 wxWindowID id = 0,
227 const wxString& name = wxStatusLineNameStr);
23324ae1
FM
228
229 /**
230 Creates a toolbar at the top or left of the frame.
3c4f71cc 231
7c913512 232 @param style
674d80a7 233 The toolbar style. See wxToolBar for a list of valid styles.
7c913512 234 @param id
674d80a7
FM
235 The toolbar window identifier. If -1, an identifier will be chosen
236 by wxWidgets.
7c913512 237 @param name
4cc4bfaf 238 The toolbar window name.
3c4f71cc 239
d29a9a8a 240 @return A pointer to the toolbar if it was created successfully, @NULL
674d80a7 241 otherwise.
3c4f71cc 242
bb69632a
FM
243 @remarks
244 By default, the toolbar is an instance of wxToolBar.
245 To use a different class, override OnCreateToolBar().
246 When a toolbar has been created with this function, or made
247 known to the frame with wxFrame::SetToolBar(), the frame will
248 manage the toolbar position and adjust the return value from
249 wxWindow::GetClientSize() to reflect the available space for
250 application windows.
251 Under Pocket PC, you should always use this function for creating
252 the toolbar to be managed by the frame, so that wxWidgets can
253 use a combined menubar and toolbar.
254 Where you manage your own toolbars, create a wxToolBar as usual.
674d80a7
FM
255
256 @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(), GetToolBar()
23324ae1 257 */
4cc4bfaf 258 virtual wxToolBar* CreateToolBar(long style = wxBORDER_NONE | wxTB_HORIZONTAL,
43c48e1e
FM
259 wxWindowID id = wxID_ANY,
260 const wxString& name = wxToolBarNameStr);
23324ae1
FM
261
262 /**
674d80a7
FM
263 Returns the origin of the frame client area (in client coordinates).
264 It may be different from (0, 0) if the frame has a toolbar.
23324ae1 265 */
adaaa686 266 virtual wxPoint GetClientAreaOrigin() const;
23324ae1
FM
267
268 /**
269 Returns a pointer to the menubar currently associated with the frame (if any).
3c4f71cc 270
4cc4bfaf 271 @see SetMenuBar(), wxMenuBar, wxMenu
23324ae1 272 */
adaaa686 273 virtual wxMenuBar* GetMenuBar() const;
23324ae1
FM
274
275 /**
674d80a7
FM
276 Returns a pointer to the status bar currently associated with the frame
277 (if any).
3c4f71cc 278
4cc4bfaf 279 @see CreateStatusBar(), wxStatusBar
23324ae1 280 */
adaaa686 281 virtual wxStatusBar* GetStatusBar() const;
23324ae1
FM
282
283 /**
284 Returns the status bar pane used to display menu and toolbar help.
3c4f71cc 285
4cc4bfaf 286 @see SetStatusBarPane()
23324ae1 287 */
adaaa686 288 int GetStatusBarPane() const;
23324ae1
FM
289
290 /**
291 Returns a pointer to the toolbar currently associated with the frame (if any).
3c4f71cc 292
4cc4bfaf 293 @see CreateToolBar(), wxToolBar, SetToolBar()
23324ae1 294 */
adaaa686 295 virtual wxToolBar* GetToolBar() const;
23324ae1
FM
296
297 /**
298 Virtual function called when a status bar is requested by CreateStatusBar().
3c4f71cc 299
7c913512 300 @param number
4cc4bfaf 301 The number of fields to create.
7c913512 302 @param style
4cc4bfaf
FM
303 The window style. See wxStatusBar for a list
304 of valid styles.
7c913512 305 @param id
4cc4bfaf
FM
306 The window identifier. If -1, an identifier will be chosen by
307 wxWidgets.
7c913512 308 @param name
4cc4bfaf 309 The window name.
3c4f71cc 310
d29a9a8a 311 @return A status bar object.
3c4f71cc 312
23324ae1 313 @remarks An application can override this function to return a different
4cc4bfaf
FM
314 kind of status bar. The default implementation returns
315 an instance of wxStatusBar.
3c4f71cc 316
4cc4bfaf 317 @see CreateStatusBar(), wxStatusBar.
23324ae1
FM
318 */
319 virtual wxStatusBar* OnCreateStatusBar(int number, long style,
320 wxWindowID id,
321 const wxString& name);
322
323 /**
324 Virtual function called when a toolbar is requested by CreateToolBar().
3c4f71cc 325
7c913512 326 @param style
4cc4bfaf
FM
327 The toolbar style. See wxToolBar for a list
328 of valid styles.
7c913512 329 @param id
4cc4bfaf
FM
330 The toolbar window identifier. If -1, an identifier will be chosen by
331 wxWidgets.
7c913512 332 @param name
4cc4bfaf 333 The toolbar window name.
3c4f71cc 334
d29a9a8a 335 @return A toolbar object.
3c4f71cc 336
23324ae1 337 @remarks An application can override this function to return a different
4cc4bfaf
FM
338 kind of toolbar. The default implementation returns an
339 instance of wxToolBar.
3c4f71cc 340
4cc4bfaf 341 @see CreateToolBar(), wxToolBar.
23324ae1
FM
342 */
343 virtual wxToolBar* OnCreateToolBar(long style, wxWindowID id,
344 const wxString& name);
345
346 /**
347 Simulate a menu command.
3c4f71cc 348
7c913512 349 @param id
4cc4bfaf 350 The identifier for a menu item.
23324ae1 351 */
a44f3b5a 352 bool ProcessCommand(int id);
23324ae1 353
23324ae1
FM
354 /**
355 Tells the frame to show the given menu bar.
3c4f71cc 356
7c913512 357 @param menuBar
4cc4bfaf 358 The menu bar to associate with the frame.
3c4f71cc 359
23324ae1 360 @remarks If the frame is destroyed, the menu bar and its menus will be
4cc4bfaf
FM
361 destroyed also, so do not delete the menu bar
362 explicitly (except by resetting the frame's menu bar to
363 another frame or @NULL).
674d80a7
FM
364 Under Windows, a size event is generated, so be sure to
365 initialize data members properly before calling SetMenuBar().
366 Note that on some platforms, it is not possible to call this
367 function twice for the same frame object.
3c4f71cc 368
4cc4bfaf 369 @see GetMenuBar(), wxMenuBar, wxMenu.
23324ae1 370 */
adaaa686 371 virtual void SetMenuBar(wxMenuBar* menuBar);
23324ae1
FM
372
373 /**
374 Associates a status bar with the frame.
3c4f71cc 375
4cc4bfaf 376 @see CreateStatusBar(), wxStatusBar, GetStatusBar()
23324ae1 377 */
adaaa686 378 virtual void SetStatusBar(wxStatusBar* statusBar);
23324ae1
FM
379
380 /**
381 Set the status bar pane used to display menu and toolbar help.
382 Using -1 disables help display.
383 */
384 void SetStatusBarPane(int n);
385
386 /**
387 Sets the status bar text and redraws the status bar.
3c4f71cc 388
7c913512 389 @param text
4cc4bfaf 390 The text for the status field.
7c913512 391 @param number
4cc4bfaf 392 The status field (starting from zero).
3c4f71cc 393
23324ae1 394 @remarks Use an empty string to clear the status bar.
3c4f71cc 395
4cc4bfaf 396 @see CreateStatusBar(), wxStatusBar
23324ae1
FM
397 */
398 virtual void SetStatusText(const wxString& text, int number = 0);
399
400 /**
401 Sets the widths of the fields in the status bar.
3c4f71cc 402
7c913512 403 @param n
4cc4bfaf
FM
404 The number of fields in the status bar. It must be the
405 same used in CreateStatusBar.
f21dd16b 406 @param widths_field
4cc4bfaf
FM
407 Must contain an array of n integers, each of which is a status field width
408 in pixels. A value of -1 indicates that the field is variable width; at
674d80a7
FM
409 least one field must be -1. You should delete this array after calling
410 SetStatusWidths().
3c4f71cc 411
23324ae1 412 @remarks The widths of the variable fields are calculated from the total
4cc4bfaf 413 width of all fields, minus the sum of widths of the
674d80a7 414 non-variable fields, divided by the number of variable fields.
23324ae1 415 */
43c48e1e 416 virtual void SetStatusWidths(int n, const int* widths_field);
23324ae1
FM
417
418 /**
419 Associates a toolbar with the frame.
420 */
adaaa686 421 virtual void SetToolBar(wxToolBar* toolBar);
23324ae1 422};
e54c96f1 423