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