]>
Commit | Line | Data |
---|---|---|
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 | |
34 | by manually handling wxEVT_SIZE or using sizers; | |
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 | |
674d80a7 FM |
39 | @section frame_styles |
40 | ||
41 | wxFrame supports the following styles: | |
42 | ||
23324ae1 | 43 | @beginStyleTable |
8c6791e4 | 44 | @style{wxDEFAULT_FRAME_STYLE} |
7c913512 | 45 | Defined as wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxRESIZE_BORDER | |
23324ae1 | 46 | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN. |
8c6791e4 | 47 | @style{wxICONIZE} |
23324ae1 | 48 | Display the frame iconized (minimized). Windows only. |
8c6791e4 | 49 | @style{wxCAPTION} |
23324ae1 | 50 | Puts a caption on the frame. |
8c6791e4 | 51 | @style{wxMINIMIZE} |
23324ae1 | 52 | Identical to wxICONIZE. Windows only. |
8c6791e4 | 53 | @style{wxMINIMIZE_BOX} |
23324ae1 | 54 | Displays a minimize box on the frame. |
8c6791e4 | 55 | @style{wxMAXIMIZE} |
23324ae1 | 56 | Displays the frame maximized. Windows only. |
8c6791e4 | 57 | @style{wxMAXIMIZE_BOX} |
23324ae1 | 58 | Displays a maximize box on the frame. |
8c6791e4 | 59 | @style{wxCLOSE_BOX} |
23324ae1 | 60 | Displays a close box on the frame. |
8c6791e4 | 61 | @style{wxSTAY_ON_TOP} |
23324ae1 | 62 | Stay on top of all other windows, see also wxFRAME_FLOAT_ON_PARENT. |
8c6791e4 | 63 | @style{wxSYSTEM_MENU} |
23324ae1 | 64 | Displays a system menu. |
8c6791e4 | 65 | @style{wxRESIZE_BORDER} |
23324ae1 | 66 | Displays a resizeable border around the window. |
8c6791e4 | 67 | @style{wxFRAME_TOOL_WINDOW} |
23324ae1 FM |
68 | Causes a frame with a small titlebar to be created; the frame does |
69 | not appear in the taskbar under Windows or GTK+. | |
8c6791e4 | 70 | @style{wxFRAME_NO_TASKBAR} |
23324ae1 FM |
71 | Creates an otherwise normal frame but it does not appear in the |
72 | taskbar under Windows or GTK+ (note that it will minimize to the | |
73 | desktop window under Windows which may seem strange to the users | |
74 | and thus it might be better to use this style only without | |
75 | wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if GTK+ | |
7c913512 | 76 | is at least version 2.2 and the window manager supports |
ea6a2ccb | 77 | _NET_WM_STATE_SKIP_TASKBAR hint. Has no effect under other platforms. |
8c6791e4 | 78 | @style{wxFRAME_FLOAT_ON_PARENT} |
ea6a2ccb FM |
79 | The frame will always be on top of its parent (unlike wxSTAY_ON_TOP). |
80 | A frame created with this style must have a non-@NULL parent. | |
81 | @style{wxFRAME_SHAPED} | |
82 | Windows with this style are allowed to have their shape changed | |
83 | with the SetShape() method. | |
84 | @endStyleTable | |
85 | ||
86 | The default frame style is for normal, resizeable frames. | |
87 | To create a frame which can not be resized by user, you may use the following | |
88 | combination of styles: | |
89 | ||
90 | @code | |
15840e67 | 91 | wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxMAXIMIZE_BOX) |
ea6a2ccb FM |
92 | @endcode |
93 | ||
94 | See also the @ref overview_windowstyles. | |
95 | ||
96 | @beginExtraStyleTable | |
8c6791e4 | 97 | @style{wxFRAME_EX_CONTEXTHELP} |
23324ae1 FM |
98 | Under Windows, puts a query button on the caption. When pressed, |
99 | Windows will go into a context-sensitive help mode and wxWidgets | |
100 | will send a wxEVT_HELP event if the user clicked on an application | |
101 | window. Note that this is an extended style and must be set by | |
102 | calling SetExtraStyle before Create is called (two-step | |
103 | construction). You cannot use this style together with | |
104 | wxMAXIMIZE_BOX or wxMINIMIZE_BOX, so you should use | |
105 | wxDEFAULT_FRAME_STYLE ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the | |
106 | frames having this style (the dialogs don't have a minimize or a | |
107 | maximize box by default) | |
8c6791e4 | 108 | @style{wxFRAME_EX_METAL} |
23324ae1 FM |
109 | On Mac OS X, frames with this style will be shown with a metallic |
110 | look. This is an extra style. | |
ea6a2ccb | 111 | @endExtraStyleTable |
7c913512 | 112 | |
23324ae1 FM |
113 | @library{wxcore} |
114 | @category{managedwnd} | |
7c913512 | 115 | |
e54c96f1 | 116 | @see wxMDIParentFrame, wxMDIChildFrame, wxMiniFrame, wxDialog |
23324ae1 FM |
117 | */ |
118 | class wxFrame : public wxTopLevelWindow | |
119 | { | |
120 | public: | |
674d80a7 FM |
121 | /** |
122 | Default constructor. | |
123 | */ | |
124 | wxFrame(); | |
125 | ||
23324ae1 FM |
126 | /** |
127 | Constructor, creating the window. | |
3c4f71cc | 128 | |
7c913512 | 129 | @param parent |
4cc4bfaf FM |
130 | The window parent. This may be @NULL. If it is non-@NULL, the frame will |
131 | always be displayed on top of the parent window on Windows. | |
7c913512 | 132 | @param id |
674d80a7 | 133 | The window identifier. It may take a value of -1 to indicate a default value. |
7c913512 | 134 | @param title |
4cc4bfaf | 135 | The caption to be displayed on the frame's title bar. |
7c913512 | 136 | @param pos |
4cc4bfaf | 137 | The window position. The value wxDefaultPosition indicates a default position, |
674d80a7 | 138 | chosen by either the windowing system or wxWidgets, depending on platform. |
7c913512 | 139 | @param size |
4cc4bfaf FM |
140 | The window size. The value wxDefaultSize indicates a default size, chosen by |
141 | either the windowing system or wxWidgets, depending on platform. | |
7c913512 | 142 | @param style |
674d80a7 | 143 | The window style. See wxFrame class description. |
7c913512 | 144 | @param name |
674d80a7 FM |
145 | The name of the window. This parameter is used to associate a name with |
146 | the item, allowing the application user to set Motif resource values for | |
4cc4bfaf | 147 | individual windows. |
3c4f71cc | 148 | |
23324ae1 | 149 | @remarks For Motif, MWM (the Motif Window Manager) should be running for |
674d80a7 | 150 | any window styles to work (otherwise all styles take effect). |
3c4f71cc | 151 | |
4cc4bfaf | 152 | @see Create() |
23324ae1 | 153 | */ |
7c913512 FM |
154 | wxFrame(wxWindow* parent, wxWindowID id, |
155 | const wxString& title, | |
156 | const wxPoint& pos = wxDefaultPosition, | |
157 | const wxSize& size = wxDefaultSize, | |
158 | long style = wxDEFAULT_FRAME_STYLE, | |
159 | const wxString& name = "frame"); | |
23324ae1 FM |
160 | |
161 | /** | |
162 | Destructor. Destroys all child windows and menu bar if present. | |
163 | */ | |
adaaa686 | 164 | virtual ~wxFrame(); |
23324ae1 FM |
165 | |
166 | /** | |
167 | Centres the frame on the display. | |
3c4f71cc | 168 | |
7c913512 | 169 | @param direction |
4cc4bfaf | 170 | The parameter may be wxHORIZONTAL, wxVERTICAL or wxBOTH. |
23324ae1 FM |
171 | */ |
172 | void Centre(int direction = wxBOTH); | |
173 | ||
174 | /** | |
674d80a7 FM |
175 | Used in two-step frame construction. |
176 | See wxFrame() for further details. | |
23324ae1 FM |
177 | */ |
178 | bool Create(wxWindow* parent, wxWindowID id, | |
179 | const wxString& title, | |
180 | const wxPoint& pos = wxDefaultPosition, | |
181 | const wxSize& size = wxDefaultSize, | |
182 | long style = wxDEFAULT_FRAME_STYLE, | |
183 | const wxString& name = "frame"); | |
184 | ||
185 | /** | |
186 | Creates a status bar at the bottom of the frame. | |
3c4f71cc | 187 | |
7c913512 | 188 | @param number |
4cc4bfaf FM |
189 | The number of fields to create. Specify a |
190 | value greater than 1 to create a multi-field status bar. | |
7c913512 | 191 | @param style |
674d80a7 | 192 | The status bar style. See wxStatusBar for a list of valid styles. |
7c913512 | 193 | @param id |
674d80a7 FM |
194 | The status bar window identifier. If -1, an identifier will be chosen |
195 | by 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 |
674d80a7 | 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 |
674d80a7 | 217 | The toolbar style. See wxToolBar for a list of valid styles. |
7c913512 | 218 | @param id |
674d80a7 FM |
219 | The toolbar window identifier. If -1, an identifier will be chosen |
220 | by wxWidgets. | |
7c913512 | 221 | @param name |
4cc4bfaf | 222 | The toolbar window name. |
3c4f71cc | 223 | |
d29a9a8a | 224 | @return A pointer to the toolbar if it was created successfully, @NULL |
674d80a7 | 225 | otherwise. |
3c4f71cc | 226 | |
23324ae1 | 227 | @remarks By default, the toolbar is an instance of wxToolBar (which is |
4cc4bfaf FM |
228 | defined to be a suitable toolbar class on each |
229 | platform, such as wxToolBar95). To use a different | |
230 | class, override OnCreateToolBar(). | |
674d80a7 FM |
231 | When a toolbar has been created with this function, or made |
232 | known to the frame with wxFrame::SetToolBar, the frame will | |
233 | manage the toolbar position and adjust the return value from | |
234 | wxWindow::GetClientSize to reflect the available space for | |
235 | application windows. | |
236 | Under Pocket PC, you should always use this function for creating | |
237 | the toolbar to be managed by the frame, so that wxWidgets can | |
238 | use a combined menubar and toolbar. | |
239 | Where you manage your own toolbars, create a wxToolBar as usual. | |
240 | ||
241 | @see CreateStatusBar(), OnCreateToolBar(), SetToolBar(), GetToolBar() | |
23324ae1 | 242 | */ |
4cc4bfaf | 243 | virtual wxToolBar* CreateToolBar(long style = wxBORDER_NONE | wxTB_HORIZONTAL, |
23324ae1 FM |
244 | wxWindowID id = -1, |
245 | const wxString& name = "toolBar"); | |
246 | ||
247 | /** | |
674d80a7 FM |
248 | Returns the origin of the frame client area (in client coordinates). |
249 | It may be different from (0, 0) if the frame has a toolbar. | |
23324ae1 | 250 | */ |
adaaa686 | 251 | virtual wxPoint GetClientAreaOrigin() const; |
23324ae1 FM |
252 | |
253 | /** | |
254 | Returns a pointer to the menubar currently associated with the frame (if any). | |
3c4f71cc | 255 | |
4cc4bfaf | 256 | @see SetMenuBar(), wxMenuBar, wxMenu |
23324ae1 | 257 | */ |
adaaa686 | 258 | virtual wxMenuBar* GetMenuBar() const; |
23324ae1 FM |
259 | |
260 | /** | |
674d80a7 FM |
261 | Returns a pointer to the status bar currently associated with the frame |
262 | (if any). | |
3c4f71cc | 263 | |
4cc4bfaf | 264 | @see CreateStatusBar(), wxStatusBar |
23324ae1 | 265 | */ |
adaaa686 | 266 | virtual wxStatusBar* GetStatusBar() const; |
23324ae1 FM |
267 | |
268 | /** | |
269 | Returns the status bar pane used to display menu and toolbar help. | |
3c4f71cc | 270 | |
4cc4bfaf | 271 | @see SetStatusBarPane() |
23324ae1 | 272 | */ |
adaaa686 | 273 | int GetStatusBarPane() const; |
23324ae1 FM |
274 | |
275 | /** | |
276 | Returns a pointer to the toolbar currently associated with the frame (if any). | |
3c4f71cc | 277 | |
4cc4bfaf | 278 | @see CreateToolBar(), wxToolBar, SetToolBar() |
23324ae1 | 279 | */ |
adaaa686 | 280 | virtual wxToolBar* GetToolBar() const; |
23324ae1 FM |
281 | |
282 | /** | |
283 | Virtual function called when a status bar is requested by CreateStatusBar(). | |
3c4f71cc | 284 | |
7c913512 | 285 | @param number |
4cc4bfaf | 286 | The number of fields to create. |
7c913512 | 287 | @param style |
4cc4bfaf FM |
288 | The window style. See wxStatusBar for a list |
289 | of valid styles. | |
7c913512 | 290 | @param id |
4cc4bfaf FM |
291 | The window identifier. If -1, an identifier will be chosen by |
292 | wxWidgets. | |
7c913512 | 293 | @param name |
4cc4bfaf | 294 | The window name. |
3c4f71cc | 295 | |
d29a9a8a | 296 | @return A status bar object. |
3c4f71cc | 297 | |
23324ae1 | 298 | @remarks An application can override this function to return a different |
4cc4bfaf FM |
299 | kind of status bar. The default implementation returns |
300 | an instance of wxStatusBar. | |
3c4f71cc | 301 | |
4cc4bfaf | 302 | @see CreateStatusBar(), wxStatusBar. |
23324ae1 FM |
303 | */ |
304 | virtual wxStatusBar* OnCreateStatusBar(int number, long style, | |
305 | wxWindowID id, | |
306 | const wxString& name); | |
307 | ||
308 | /** | |
309 | Virtual function called when a toolbar is requested by CreateToolBar(). | |
3c4f71cc | 310 | |
7c913512 | 311 | @param style |
4cc4bfaf FM |
312 | The toolbar style. See wxToolBar for a list |
313 | of valid styles. | |
7c913512 | 314 | @param id |
4cc4bfaf FM |
315 | The toolbar window identifier. If -1, an identifier will be chosen by |
316 | wxWidgets. | |
7c913512 | 317 | @param name |
4cc4bfaf | 318 | The toolbar window name. |
3c4f71cc | 319 | |
d29a9a8a | 320 | @return A toolbar object. |
3c4f71cc | 321 | |
23324ae1 | 322 | @remarks An application can override this function to return a different |
4cc4bfaf FM |
323 | kind of toolbar. The default implementation returns an |
324 | instance of wxToolBar. | |
3c4f71cc | 325 | |
4cc4bfaf | 326 | @see CreateToolBar(), wxToolBar. |
23324ae1 FM |
327 | */ |
328 | virtual wxToolBar* OnCreateToolBar(long style, wxWindowID id, | |
329 | const wxString& name); | |
330 | ||
331 | /** | |
332 | Simulate a menu command. | |
3c4f71cc | 333 | |
7c913512 | 334 | @param id |
4cc4bfaf | 335 | The identifier for a menu item. |
23324ae1 FM |
336 | */ |
337 | void ProcessCommand(int id); | |
338 | ||
23324ae1 FM |
339 | /** |
340 | Tells the frame to show the given menu bar. | |
3c4f71cc | 341 | |
7c913512 | 342 | @param menuBar |
4cc4bfaf | 343 | The menu bar to associate with the frame. |
3c4f71cc | 344 | |
23324ae1 | 345 | @remarks If the frame is destroyed, the menu bar and its menus will be |
4cc4bfaf FM |
346 | destroyed also, so do not delete the menu bar |
347 | explicitly (except by resetting the frame's menu bar to | |
348 | another frame or @NULL). | |
674d80a7 FM |
349 | Under Windows, a size event is generated, so be sure to |
350 | initialize data members properly before calling SetMenuBar(). | |
351 | Note that on some platforms, it is not possible to call this | |
352 | function twice for the same frame object. | |
3c4f71cc | 353 | |
4cc4bfaf | 354 | @see GetMenuBar(), wxMenuBar, wxMenu. |
23324ae1 | 355 | */ |
adaaa686 | 356 | virtual void SetMenuBar(wxMenuBar* menuBar); |
23324ae1 FM |
357 | |
358 | /** | |
359 | Associates a status bar with the frame. | |
3c4f71cc | 360 | |
4cc4bfaf | 361 | @see CreateStatusBar(), wxStatusBar, GetStatusBar() |
23324ae1 | 362 | */ |
adaaa686 | 363 | virtual void SetStatusBar(wxStatusBar* statusBar); |
23324ae1 FM |
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 | |
674d80a7 FM |
394 | least one field must be -1. You should delete this array after calling |
395 | SetStatusWidths(). | |
3c4f71cc | 396 | |
23324ae1 | 397 | @remarks The widths of the variable fields are calculated from the total |
4cc4bfaf | 398 | width of all fields, minus the sum of widths of the |
674d80a7 | 399 | non-variable fields, divided by the number of variable fields. |
23324ae1 | 400 | */ |
4cc4bfaf | 401 | virtual void SetStatusWidths(int n, int* widths); |
23324ae1 FM |
402 | |
403 | /** | |
404 | Associates a toolbar with the frame. | |
405 | */ | |
adaaa686 | 406 | virtual void SetToolBar(wxToolBar* toolBar); |
23324ae1 | 407 | }; |
e54c96f1 | 408 |