]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/frame.h
Fix wrong return value in the changes of r73365.
[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$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
7d40f0a5
RD
9/**
10 Frame specific styles
11*/
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
15
16
23324ae1
FM
17/**
18 @class wxFrame
7c913512 19
ea6a2ccb
FM
20 A frame is a window whose size and position can (usually) be changed by the user.
21
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
23324ae1 24 a frame or dialog.
7c913512 25
ea6a2ccb
FM
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.
29
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.
33
34
674d80a7 35 @section frame_defaultevent Default event processing
ea6a2ccb
FM
36
37 wxFrame processes the following events:
38
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
9d157d59 42 by manually handling @c wxEVT_SIZE or using sizers;
ea6a2ccb
FM
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.
45
7c913512 46
23324ae1 47 @beginStyleTable
8c6791e4 48 @style{wxDEFAULT_FRAME_STYLE}
7c913512 49 Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER |
23324ae1 50 wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN.
8c6791e4 51 @style{wxICONIZE}
23324ae1 52 Display the frame iconized (minimized). Windows only.
8c6791e4 53 @style{wxCAPTION}
7832ada0
VZ
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
58 simply ignored.
8c6791e4 59 @style{wxMINIMIZE}
23324ae1 60 Identical to wxICONIZE. Windows only.
8c6791e4 61 @style{wxMINIMIZE_BOX}
23324ae1 62 Displays a minimize box on the frame.
8c6791e4 63 @style{wxMAXIMIZE}
62fc18ef 64 Displays the frame maximized. Windows and GTK+ only.
8c6791e4 65 @style{wxMAXIMIZE_BOX}
7832ada0
VZ
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.
8c6791e4 68 @style{wxCLOSE_BOX}
23324ae1 69 Displays a close box on the frame.
8c6791e4 70 @style{wxSTAY_ON_TOP}
23324ae1 71 Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT.
8c6791e4 72 @style{wxSYSTEM_MENU}
7832ada0
VZ
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.
8c6791e4 80 @style{wxRESIZE_BORDER}
d13b34d3 81 Displays a resizable border around the window.
8c6791e4 82 @style{wxFRAME_TOOL_WINDOW}
7832ada0 83 Causes a frame with a small title bar to be created; the frame does
23324ae1 84 not appear in the taskbar under Windows or GTK+.
8c6791e4 85 @style{wxFRAME_NO_TASKBAR}
23324ae1
FM
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
7832ada0
VZ
90 wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if the
91 window manager supports _NET_WM_STATE_SKIP_TASKBAR hint.
8c6791e4 92 @style{wxFRAME_FLOAT_ON_PARENT}
ea6a2ccb
FM
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}
7832ada0 96 Windows with this style are allowed to have their shape changed
ea6a2ccb
FM
97 with the SetShape() method.
98 @endStyleTable
99
d13b34d3 100 The default frame style is for normal, resizable frames.
4c51a665 101 To create a frame which cannot be resized by user, you may use the following
ea6a2ccb
FM
102 combination of styles:
103
104 @code
15840e67 105 wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX)
ea6a2ccb
FM
106 @endcode
107
108 See also the @ref overview_windowstyles.
109
110 @beginExtraStyleTable
8c6791e4 111 @style{wxFRAME_EX_CONTEXTHELP}
23324ae1
FM
112 Under Windows, puts a query button on the caption. When pressed,
113 Windows will go into a context-sensitive help mode and wxWidgets
3a194bda 114 will send a @c wxEVT_HELP event if the user clicked on an application
23324ae1
FM
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)
8c6791e4 122 @style{wxFRAME_EX_METAL}
23324ae1
FM
123 On Mac OS X, frames with this style will be shown with a metallic
124 look. This is an extra style.
ea6a2ccb 125 @endExtraStyleTable
7c913512 126
3051a44a 127 @beginEventEmissionTable
9d157d59 128 @event{EVT_CLOSE(func)}
96b57f0d
VZ
129 Process a @c wxEVT_CLOSE_WINDOW event when the frame is being
130 closed by the user or programmatically (see wxWindow::Close).
9d157d59
FM
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
3051a44a
FM
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.
145 See wxMenuEvent.
9d157d59
FM
146 @endEventTable
147
23324ae1
FM
148 @library{wxcore}
149 @category{managedwnd}
7c913512 150
e54c96f1 151 @see wxMDIParentFrame, wxMDIChildFrame, wxMiniFrame, wxDialog
23324ae1
FM
152*/
153class wxFrame : public wxTopLevelWindow
154{
155public:
674d80a7
FM
156 /**
157 Default constructor.
158 */
159 wxFrame();
160
23324ae1
FM
161 /**
162 Constructor, creating the window.
3c4f71cc 163
7c913512 164 @param parent
4cc4bfaf
FM
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.
7c913512 167 @param id
674d80a7 168 The window identifier. It may take a value of -1 to indicate a default value.
7c913512 169 @param title
4cc4bfaf 170 The caption to be displayed on the frame's title bar.
7c913512 171 @param pos
4cc4bfaf 172 The window position. The value wxDefaultPosition indicates a default position,
674d80a7 173 chosen by either the windowing system or wxWidgets, depending on platform.
7c913512 174 @param size
4cc4bfaf
FM
175 The window size. The value wxDefaultSize indicates a default size, chosen by
176 either the windowing system or wxWidgets, depending on platform.
7c913512 177 @param style
674d80a7 178 The window style. See wxFrame class description.
7c913512 179 @param name
674d80a7
FM
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
4cc4bfaf 182 individual windows.
3c4f71cc 183
23324ae1 184 @remarks For Motif, MWM (the Motif Window Manager) should be running for
674d80a7 185 any window styles to work (otherwise all styles take effect).
3c4f71cc 186
4cc4bfaf 187 @see Create()
23324ae1 188 */
7c913512
FM
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,
408776d0 194 const wxString& name = wxFrameNameStr);
23324ae1
FM
195
196 /**
197 Destructor. Destroys all child windows and menu bar if present.
2e4f32d7
FM
198
199 See @ref overview_windowdeletion for more info.
23324ae1 200 */
adaaa686 201 virtual ~wxFrame();
23324ae1
FM
202
203 /**
204 Centres the frame on the display.
3c4f71cc 205
7c913512 206 @param direction
4cc4bfaf 207 The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.
23324ae1
FM
208 */
209 void Centre(int direction = wxBOTH);
210
211 /**
674d80a7
FM
212 Used in two-step frame construction.
213 See wxFrame() for further details.
23324ae1 214 */
43c48e1e 215 bool Create(wxWindow* parent, wxWindowID id, const wxString& title,
23324ae1
FM
216 const wxPoint& pos = wxDefaultPosition,
217 const wxSize& size = wxDefaultSize,
218 long style = wxDEFAULT_FRAME_STYLE,
43c48e1e 219 const wxString& name = wxFrameNameStr);
23324ae1
FM
220
221 /**
222 Creates a status bar at the bottom of the frame.
3c4f71cc 223
7c913512 224 @param number
4cc4bfaf
FM
225 The number of fields to create. Specify a
226 value greater than 1 to create a multi-field status bar.
7c913512 227 @param style
674d80a7 228 The status bar style. See wxStatusBar for a list of valid styles.
7c913512 229 @param id
674d80a7
FM
230 The status bar window identifier. If -1, an identifier will be chosen
231 by wxWidgets.
7c913512 232 @param name
4cc4bfaf 233 The status bar window name.
3c4f71cc 234
d29a9a8a 235 @return A pointer to the status bar if it was created successfully, @NULL
674d80a7 236 otherwise.
3c4f71cc 237
23324ae1 238 @remarks The width of the status bar is the whole width of the frame
4cc4bfaf
FM
239 (adjusted automatically when resizing), and the height
240 and text size are chosen by the host windowing system.
3c4f71cc 241
4cc4bfaf 242 @see SetStatusText(), OnCreateStatusBar(), GetStatusBar()
23324ae1 243 */
c4c178c1 244 virtual wxStatusBar* CreateStatusBar(int number = 1, long style = wxSTB_DEFAULT_STYLE,
43c48e1e 245 wxWindowID id = 0,
6fc53251 246 const wxString& name = wxStatusBarNameStr);
23324ae1
FM
247
248 /**
249 Creates a toolbar at the top or left of the frame.
3c4f71cc 250
7c913512 251 @param style
674d80a7 252 The toolbar style. See wxToolBar for a list of valid styles.
7c913512 253 @param id
674d80a7
FM
254 The toolbar window identifier. If -1, an identifier will be chosen
255 by wxWidgets.
7c913512 256 @param name
4cc4bfaf 257 The toolbar window name.
3c4f71cc 258
d29a9a8a 259 @return A pointer to the toolbar if it was created successfully, @NULL
674d80a7 260 otherwise.
3c4f71cc 261
bb69632a
FM
262 @remarks
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
269 application windows.
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.
674d80a7
FM
274
275 @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(), GetToolBar()
23324ae1 276 */
4cc4bfaf 277 virtual wxToolBar* CreateToolBar(long style = wxBORDER_NONE | wxTB_HORIZONTAL,
43c48e1e
FM
278 wxWindowID id = wxID_ANY,
279 const wxString& name = wxToolBarNameStr);
23324ae1
FM
280
281 /**
674d80a7
FM
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.
23324ae1 284 */
adaaa686 285 virtual wxPoint GetClientAreaOrigin() const;
23324ae1
FM
286
287 /**
288 Returns a pointer to the menubar currently associated with the frame (if any).
3c4f71cc 289
4cc4bfaf 290 @see SetMenuBar(), wxMenuBar, wxMenu
23324ae1 291 */
adaaa686 292 virtual wxMenuBar* GetMenuBar() const;
23324ae1
FM
293
294 /**
674d80a7
FM
295 Returns a pointer to the status bar currently associated with the frame
296 (if any).
3c4f71cc 297
4cc4bfaf 298 @see CreateStatusBar(), wxStatusBar
23324ae1 299 */
adaaa686 300 virtual wxStatusBar* GetStatusBar() const;
23324ae1
FM
301
302 /**
303 Returns the status bar pane used to display menu and toolbar help.
3c4f71cc 304
4cc4bfaf 305 @see SetStatusBarPane()
23324ae1 306 */
adaaa686 307 int GetStatusBarPane() const;
23324ae1
FM
308
309 /**
310 Returns a pointer to the toolbar currently associated with the frame (if any).
3c4f71cc 311
4cc4bfaf 312 @see CreateToolBar(), wxToolBar, SetToolBar()
23324ae1 313 */
adaaa686 314 virtual wxToolBar* GetToolBar() const;
23324ae1
FM
315
316 /**
317 Virtual function called when a status bar is requested by CreateStatusBar().
3c4f71cc 318
7c913512 319 @param number
4cc4bfaf 320 The number of fields to create.
7c913512 321 @param style
4cc4bfaf
FM
322 The window style. See wxStatusBar for a list
323 of valid styles.
7c913512 324 @param id
4cc4bfaf
FM
325 The window identifier. If -1, an identifier will be chosen by
326 wxWidgets.
7c913512 327 @param name
4cc4bfaf 328 The window name.
3c4f71cc 329
d29a9a8a 330 @return A status bar object.
3c4f71cc 331
23324ae1 332 @remarks An application can override this function to return a different
4cc4bfaf
FM
333 kind of status bar. The default implementation returns
334 an instance of wxStatusBar.
3c4f71cc 335
4cc4bfaf 336 @see CreateStatusBar(), wxStatusBar.
23324ae1
FM
337 */
338 virtual wxStatusBar* OnCreateStatusBar(int number, long style,
339 wxWindowID id,
340 const wxString& name);
341
342 /**
343 Virtual function called when a toolbar is requested by CreateToolBar().
3c4f71cc 344
7c913512 345 @param style
4cc4bfaf
FM
346 The toolbar style. See wxToolBar for a list
347 of valid styles.
7c913512 348 @param id
4cc4bfaf
FM
349 The toolbar window identifier. If -1, an identifier will be chosen by
350 wxWidgets.
7c913512 351 @param name
4cc4bfaf 352 The toolbar window name.
3c4f71cc 353
d29a9a8a 354 @return A toolbar object.
3c4f71cc 355
23324ae1 356 @remarks An application can override this function to return a different
4cc4bfaf
FM
357 kind of toolbar. The default implementation returns an
358 instance of wxToolBar.
3c4f71cc 359
4cc4bfaf 360 @see CreateToolBar(), wxToolBar.
23324ae1
FM
361 */
362 virtual wxToolBar* OnCreateToolBar(long style, wxWindowID id,
363 const wxString& name);
364
365 /**
366 Simulate a menu command.
3c4f71cc 367
7c913512 368 @param id
4cc4bfaf 369 The identifier for a menu item.
23324ae1 370 */
a44f3b5a 371 bool ProcessCommand(int id);
23324ae1 372
23324ae1
FM
373 /**
374 Tells the frame to show the given menu bar.
3c4f71cc 375
7c913512 376 @param menuBar
4cc4bfaf 377 The menu bar to associate with the frame.
3c4f71cc 378
23324ae1 379 @remarks If the frame is destroyed, the menu bar and its menus will be
4cc4bfaf
FM
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).
674d80a7
FM
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.
3c4f71cc 387
4cc4bfaf 388 @see GetMenuBar(), wxMenuBar, wxMenu.
23324ae1 389 */
adaaa686 390 virtual void SetMenuBar(wxMenuBar* menuBar);
23324ae1
FM
391
392 /**
393 Associates a status bar with the frame.
3c4f71cc 394
c4c178c1
FM
395 If @a statusBar is @NULL, then the status bar, if present, is detached from
396 the frame, but @e not deleted.
397
4cc4bfaf 398 @see CreateStatusBar(), wxStatusBar, GetStatusBar()
23324ae1 399 */
adaaa686 400 virtual void SetStatusBar(wxStatusBar* statusBar);
23324ae1
FM
401
402 /**
403 Set the status bar pane used to display menu and toolbar help.
404 Using -1 disables help display.
405 */
406 void SetStatusBarPane(int n);
407
408 /**
409 Sets the status bar text and redraws the status bar.
3c4f71cc 410
7c913512 411 @param text
4cc4bfaf 412 The text for the status field.
7c913512 413 @param number
4cc4bfaf 414 The status field (starting from zero).
3c4f71cc 415
23324ae1 416 @remarks Use an empty string to clear the status bar.
3c4f71cc 417
4cc4bfaf 418 @see CreateStatusBar(), wxStatusBar
23324ae1
FM
419 */
420 virtual void SetStatusText(const wxString& text, int number = 0);
421
422 /**
423 Sets the widths of the fields in the status bar.
3c4f71cc 424
7c913512 425 @param n
4cc4bfaf
FM
426 The number of fields in the status bar. It must be the
427 same used in CreateStatusBar.
f21dd16b 428 @param widths_field
4cc4bfaf
FM
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
674d80a7
FM
431 least one field must be -1. You should delete this array after calling
432 SetStatusWidths().
3c4f71cc 433
23324ae1 434 @remarks The widths of the variable fields are calculated from the total
4cc4bfaf 435 width of all fields, minus the sum of widths of the
674d80a7 436 non-variable fields, divided by the number of variable fields.
1058f652
MB
437
438 @beginWxPerlOnly
439 In wxPerl this method takes the field widths as parameters.
440 @endWxPerlOnly
23324ae1 441 */
43c48e1e 442 virtual void SetStatusWidths(int n, const int* widths_field);
23324ae1
FM
443
444 /**
445 Associates a toolbar with the frame.
446 */
adaaa686 447 virtual void SetToolBar(wxToolBar* toolBar);
05b0355a
RD
448
449
450 void PushStatusText(const wxString &text, int number = 0);
451 void PopStatusText(int number = 0);
452
23324ae1 453};
e54c96f1 454