]> git.saurik.com Git - wxWidgets.git/blame - interface/frame.h
compilation fix for PCH-less build
[wxWidgets.git] / interface / 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
11 @wxheader{frame.h}
7c913512 12
ea6a2ccb
FM
13 A frame is a window whose size and position can (usually) be changed by the user.
14
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
23324ae1 17 a frame or dialog.
7c913512 18
ea6a2ccb
FM
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.
22
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.
26
27
28 @section wxframe_defaultevent Default event processing
29
30 wxFrame processes the following events:
31
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.
38
7c913512 39
23324ae1 40 @beginStyleTable
8c6791e4 41 @style{wxDEFAULT_FRAME_STYLE}
7c913512 42 Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER |
23324ae1 43 wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN.
8c6791e4 44 @style{wxICONIZE}
23324ae1 45 Display the frame iconized (minimized). Windows only.
8c6791e4 46 @style{wxCAPTION}
23324ae1 47 Puts a caption on the frame.
8c6791e4 48 @style{wxMINIMIZE}
23324ae1 49 Identical to wxICONIZE. Windows only.
8c6791e4 50 @style{wxMINIMIZE_BOX}
23324ae1 51 Displays a minimize box on the frame.
8c6791e4 52 @style{wxMAXIMIZE}
23324ae1 53 Displays the frame maximized. Windows only.
8c6791e4 54 @style{wxMAXIMIZE_BOX}
23324ae1 55 Displays a maximize box on the frame.
8c6791e4 56 @style{wxCLOSE_BOX}
23324ae1 57 Displays a close box on the frame.
8c6791e4 58 @style{wxSTAY_ON_TOP}
23324ae1 59 Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT.
8c6791e4 60 @style{wxSYSTEM_MENU}
23324ae1 61 Displays a system menu.
8c6791e4 62 @style{wxRESIZE_BORDER}
23324ae1 63 Displays a resizeable border around the window.
8c6791e4 64 @style{wxFRAME_TOOL_WINDOW}
23324ae1
FM
65 Causes a frame with a small titlebar to be created; the frame does
66 not appear in the taskbar under Windows or GTK+.
8c6791e4 67 @style{wxFRAME_NO_TASKBAR}
23324ae1
FM
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+
7c913512 73 is at least version 2.2 and the window manager supports
ea6a2ccb 74 _NET_WM_STATE_SKIP_TASKBAR hint. Has no effect under other platforms.
8c6791e4 75 @style{wxFRAME_FLOAT_ON_PARENT}
ea6a2ccb
FM
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.
81 @endStyleTable
82
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:
86
87 @code
88 wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxRESIZE_BOX | wxMAXIMIZE_BOX)
89 @endcode
90
91 See also the @ref overview_windowstyles.
92
93 @beginExtraStyleTable
8c6791e4 94 @style{wxFRAME_EX_CONTEXTHELP}
23324ae1
FM
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)
8c6791e4 105 @style{wxFRAME_EX_METAL}
23324ae1
FM
106 On Mac OS X, frames with this style will be shown with a metallic
107 look. This is an extra style.
ea6a2ccb 108 @endExtraStyleTable
7c913512 109
23324ae1
FM
110 @library{wxcore}
111 @category{managedwnd}
7c913512 112
e54c96f1 113 @see wxMDIParentFrame, wxMDIChildFrame, wxMiniFrame, wxDialog
23324ae1
FM
114*/
115class wxFrame : public wxTopLevelWindow
116{
117public:
118 //@{
119 /**
120 Constructor, creating the window.
3c4f71cc 121
7c913512 122 @param parent
4cc4bfaf
FM
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.
7c913512 125 @param id
4cc4bfaf
FM
126 The window identifier. It may take a value of -1 to indicate a default
127 value.
7c913512 128 @param title
4cc4bfaf 129 The caption to be displayed on the frame's title bar.
7c913512 130 @param pos
4cc4bfaf
FM
131 The window position. The value wxDefaultPosition indicates a default position,
132 chosen by
133 either the windowing system or wxWidgets, depending on platform.
7c913512 134 @param size
4cc4bfaf
FM
135 The window size. The value wxDefaultSize indicates a default size, chosen by
136 either the windowing system or wxWidgets, depending on platform.
7c913512 137 @param style
4cc4bfaf 138 The window style. See wxFrame.
7c913512 139 @param name
4cc4bfaf 140 The name of the window. This parameter is used to associate a name with the
23324ae1 141 item,
4cc4bfaf
FM
142 allowing the application user to set Motif resource values for
143 individual windows.
3c4f71cc 144
23324ae1 145 @remarks For Motif, MWM (the Motif Window Manager) should be running for
4cc4bfaf
FM
146 any window styles to work (otherwise all styles take
147 effect).
3c4f71cc 148
4cc4bfaf 149 @see Create()
23324ae1
FM
150 */
151 wxFrame();
7c913512
FM
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");
23324ae1
FM
158 //@}
159
160 /**
161 Destructor. Destroys all child windows and menu bar if present.
162 */
163 ~wxFrame();
164
165 /**
166 Centres the frame on the display.
3c4f71cc 167
7c913512 168 @param direction
4cc4bfaf 169 The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH.
23324ae1
FM
170 */
171 void Centre(int direction = wxBOTH);
172
173 /**
174 Used in two-step frame construction. See wxFrame()
175 for further details.
176 */
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");
183
184 /**
185 Creates a status bar at the bottom of the frame.
3c4f71cc 186
7c913512 187 @param number
4cc4bfaf
FM
188 The number of fields to create. Specify a
189 value greater than 1 to create a multi-field status bar.
7c913512 190 @param style
4cc4bfaf
FM
191 The status bar style. See wxStatusBar for a list
192 of valid styles.
7c913512 193 @param id
4cc4bfaf
FM
194 The status bar window identifier. If -1, an identifier will be chosen by
195 wxWidgets.
7c913512 196 @param name
4cc4bfaf 197 The status bar window name.
3c4f71cc 198
d29a9a8a 199 @return A pointer to the status bar if it was created successfully, @NULL
4cc4bfaf 200 otherwise.
3c4f71cc 201
23324ae1 202 @remarks The width of the status bar is the whole width of the frame
4cc4bfaf
FM
203 (adjusted automatically when resizing), and the height
204 and text size are chosen by the host windowing system.
3c4f71cc 205
4cc4bfaf 206 @see SetStatusText(), OnCreateStatusBar(), GetStatusBar()
23324ae1
FM
207 */
208 virtual wxStatusBar* CreateStatusBar(int number = 1,
209 long style = 0,
210 wxWindowID id = -1,
211 const wxString& name = "statusBar");
212
213 /**
214 Creates a toolbar at the top or left of the frame.
3c4f71cc 215
7c913512 216 @param style
4cc4bfaf
FM
217 The toolbar style. See wxToolBar for a list
218 of valid styles.
7c913512 219 @param id
4cc4bfaf
FM
220 The toolbar window identifier. If -1, an identifier will be chosen by
221 wxWidgets.
7c913512 222 @param name
4cc4bfaf 223 The toolbar window name.
3c4f71cc 224
d29a9a8a 225 @return A pointer to the toolbar if it was created successfully, @NULL
4cc4bfaf 226 otherwise.
3c4f71cc 227
23324ae1 228 @remarks By default, the toolbar is an instance of wxToolBar (which is
4cc4bfaf
FM
229 defined to be a suitable toolbar class on each
230 platform, such as wxToolBar95). To use a different
231 class, override OnCreateToolBar().
3c4f71cc 232
4cc4bfaf
FM
233 @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(),
234 GetToolBar()
23324ae1 235 */
4cc4bfaf 236 virtual wxToolBar* CreateToolBar(long style = wxBORDER_NONE | wxTB_HORIZONTAL,
23324ae1
FM
237 wxWindowID id = -1,
238 const wxString& name = "toolBar");
239
240 /**
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.
243 */
328f5751 244 wxPoint GetClientAreaOrigin() const;
23324ae1
FM
245
246 /**
247 Returns a pointer to the menubar currently associated with the frame (if any).
3c4f71cc 248
4cc4bfaf 249 @see SetMenuBar(), wxMenuBar, wxMenu
23324ae1 250 */
328f5751 251 wxMenuBar* GetMenuBar() const;
23324ae1
FM
252
253 /**
254 Returns a pointer to the status bar currently associated with the frame (if
255 any).
3c4f71cc 256
4cc4bfaf 257 @see CreateStatusBar(), wxStatusBar
23324ae1 258 */
328f5751 259 wxStatusBar* GetStatusBar() const;
23324ae1
FM
260
261 /**
262 Returns the status bar pane used to display menu and toolbar help.
3c4f71cc 263
4cc4bfaf 264 @see SetStatusBarPane()
23324ae1
FM
265 */
266 int GetStatusBarPane();
267
268 /**
269 Returns a pointer to the toolbar currently associated with the frame (if any).
3c4f71cc 270
4cc4bfaf 271 @see CreateToolBar(), wxToolBar, SetToolBar()
23324ae1 272 */
328f5751 273 wxToolBar* GetToolBar() const;
23324ae1
FM
274
275 /**
276 Virtual function called when a status bar is requested by CreateStatusBar().
3c4f71cc 277
7c913512 278 @param number
4cc4bfaf 279 The number of fields to create.
7c913512 280 @param style
4cc4bfaf
FM
281 The window style. See wxStatusBar for a list
282 of valid styles.
7c913512 283 @param id
4cc4bfaf
FM
284 The window identifier. If -1, an identifier will be chosen by
285 wxWidgets.
7c913512 286 @param name
4cc4bfaf 287 The window name.
3c4f71cc 288
d29a9a8a 289 @return A status bar object.
3c4f71cc 290
23324ae1 291 @remarks An application can override this function to return a different
4cc4bfaf
FM
292 kind of status bar. The default implementation returns
293 an instance of wxStatusBar.
3c4f71cc 294
4cc4bfaf 295 @see CreateStatusBar(), wxStatusBar.
23324ae1
FM
296 */
297 virtual wxStatusBar* OnCreateStatusBar(int number, long style,
298 wxWindowID id,
299 const wxString& name);
300
301 /**
302 Virtual function called when a toolbar is requested by CreateToolBar().
3c4f71cc 303
7c913512 304 @param style
4cc4bfaf
FM
305 The toolbar style. See wxToolBar for a list
306 of valid styles.
7c913512 307 @param id
4cc4bfaf
FM
308 The toolbar window identifier. If -1, an identifier will be chosen by
309 wxWidgets.
7c913512 310 @param name
4cc4bfaf 311 The toolbar window name.
3c4f71cc 312
d29a9a8a 313 @return A toolbar object.
3c4f71cc 314
23324ae1 315 @remarks An application can override this function to return a different
4cc4bfaf
FM
316 kind of toolbar. The default implementation returns an
317 instance of wxToolBar.
3c4f71cc 318
4cc4bfaf 319 @see CreateToolBar(), wxToolBar.
23324ae1
FM
320 */
321 virtual wxToolBar* OnCreateToolBar(long style, wxWindowID id,
322 const wxString& name);
323
324 /**
325 Simulate a menu command.
3c4f71cc 326
7c913512 327 @param id
4cc4bfaf 328 The identifier for a menu item.
23324ae1
FM
329 */
330 void ProcessCommand(int id);
331
332 /**
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.
23324ae1
FM
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.
340 */
341 void SendSizeEvent();
342
343 /**
344 Tells the frame to show the given menu bar.
3c4f71cc 345
7c913512 346 @param menuBar
4cc4bfaf 347 The menu bar to associate with the frame.
3c4f71cc 348
23324ae1 349 @remarks If the frame is destroyed, the menu bar and its menus will be
4cc4bfaf
FM
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).
3c4f71cc 353
4cc4bfaf 354 @see GetMenuBar(), wxMenuBar, wxMenu.
23324ae1
FM
355 */
356 void SetMenuBar(wxMenuBar* menuBar);
357
358 /**
359 Associates a status bar with the frame.
3c4f71cc 360
4cc4bfaf 361 @see CreateStatusBar(), wxStatusBar, GetStatusBar()
23324ae1
FM
362 */
363 void SetStatusBar(wxStatusBar* statusBar);
364
365 /**
366 Set the status bar pane used to display menu and toolbar help.
367 Using -1 disables help display.
368 */
369 void SetStatusBarPane(int n);
370
371 /**
372 Sets the status bar text and redraws the status bar.
3c4f71cc 373
7c913512 374 @param text
4cc4bfaf 375 The text for the status field.
7c913512 376 @param number
4cc4bfaf 377 The status field (starting from zero).
3c4f71cc 378
23324ae1 379 @remarks Use an empty string to clear the status bar.
3c4f71cc 380
4cc4bfaf 381 @see CreateStatusBar(), wxStatusBar
23324ae1
FM
382 */
383 virtual void SetStatusText(const wxString& text, int number = 0);
384
385 /**
386 Sets the widths of the fields in the status bar.
3c4f71cc 387
7c913512 388 @param n
4cc4bfaf
FM
389 The number of fields in the status bar. It must be the
390 same used in CreateStatusBar.
7c913512 391 @param widths
4cc4bfaf
FM
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
394 least one
395 field must be -1. You should delete this array after calling
396 SetStatusWidths.
3c4f71cc 397
23324ae1 398 @remarks The widths of the variable fields are calculated from the total
4cc4bfaf
FM
399 width of all fields, minus the sum of widths of the
400 non-variable fields, divided by the number of variable
401 fields.
23324ae1 402 */
4cc4bfaf 403 virtual void SetStatusWidths(int n, int* widths);
23324ae1
FM
404
405 /**
406 Associates a toolbar with the frame.
407 */
408 void SetToolBar(wxToolBar* toolBar);
409};
e54c96f1 410