]>
Commit | Line | Data |
---|---|---|
63fec618 | 1 | ///////////////////////////////////////////////////////////////////////////// |
76b49cf4 | 2 | // Name: src/common/framecmn.cpp |
63fec618 VZ |
3 | // Purpose: common (for all platforms) wxFrame functions |
4 | // Author: Julian Smart, Vadim Zeitlin | |
5 | // Created: 01/02/97 | |
439b3bf1 | 6 | // Id: $Id$ |
55d99c7a | 7 | // Copyright: (c) 1998 Robert Roebling and Julian Smart |
65571936 | 8 | // Licence: wxWindows licence |
63fec618 VZ |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
7c0ea335 VZ |
11 | // ============================================================================ |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
f701d7ab JS |
19 | // For compilers that support precompilation, includes "wx.h". |
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
7c0ea335 | 23 | #pragma hdrstop |
f701d7ab JS |
24 | #endif |
25 | ||
76b49cf4 WS |
26 | #include "wx/frame.h" |
27 | ||
1e6feb95 | 28 | #ifndef WX_PRECOMP |
1e6feb95 VZ |
29 | #include "wx/menu.h" |
30 | #include "wx/menuitem.h" | |
31 | #include "wx/dcclient.h" | |
4e3e485b | 32 | #include "wx/toolbar.h" |
7c0ea335 | 33 | #include "wx/statusbr.h" |
3304646d | 34 | #endif // WX_PRECOMP |
7c0ea335 VZ |
35 | |
36 | // ---------------------------------------------------------------------------- | |
37 | // event table | |
38 | // ---------------------------------------------------------------------------- | |
39 | ||
96ac065f VZ |
40 | #if wxUSE_MENUS && wxUSE_STATUSBAR |
41 | ||
7d9f12f3 | 42 | BEGIN_EVENT_TABLE(wxFrameBase, wxTopLevelWindow) |
0b30bb0b | 43 | EVT_MENU_OPEN(wxFrameBase::OnMenuOpen) |
96ac065f VZ |
44 | EVT_MENU_CLOSE(wxFrameBase::OnMenuClose) |
45 | ||
7c0ea335 | 46 | EVT_MENU_HIGHLIGHT_ALL(wxFrameBase::OnMenuHighlight) |
7c0ea335 VZ |
47 | END_EVENT_TABLE() |
48 | ||
96ac065f VZ |
49 | #endif // wxUSE_MENUS && wxUSE_STATUSBAR |
50 | ||
7c0ea335 VZ |
51 | // ============================================================================ |
52 | // implementation | |
53 | // ============================================================================ | |
54 | ||
55 | // ---------------------------------------------------------------------------- | |
56 | // construction/destruction | |
57 | // ---------------------------------------------------------------------------- | |
58 | ||
59 | wxFrameBase::wxFrameBase() | |
60 | { | |
1e6feb95 | 61 | #if wxUSE_MENUS |
7c0ea335 | 62 | m_frameMenuBar = NULL; |
1e6feb95 | 63 | #endif // wxUSE_MENUS |
7c0ea335 VZ |
64 | |
65 | #if wxUSE_TOOLBAR | |
66 | m_frameToolBar = NULL; | |
67 | #endif // wxUSE_TOOLBAR | |
68 | ||
69 | #if wxUSE_STATUSBAR | |
70 | m_frameStatusBar = NULL; | |
71 | #endif // wxUSE_STATUSBAR | |
1f361cdd MB |
72 | |
73 | m_statusBarPane = 0; | |
7c0ea335 VZ |
74 | } |
75 | ||
799ea011 GD |
76 | wxFrameBase::~wxFrameBase() |
77 | { | |
78 | // this destructor is required for Darwin | |
79 | } | |
80 | ||
7c0ea335 VZ |
81 | wxFrame *wxFrameBase::New(wxWindow *parent, |
82 | wxWindowID id, | |
83 | const wxString& title, | |
84 | const wxPoint& pos, | |
85 | const wxSize& size, | |
86 | long style, | |
87 | const wxString& name) | |
88 | { | |
89 | return new wxFrame(parent, id, title, pos, size, style, name); | |
90 | } | |
91 | ||
92 | void wxFrameBase::DeleteAllBars() | |
93 | { | |
1e6feb95 | 94 | #if wxUSE_MENUS |
7c0ea335 VZ |
95 | if ( m_frameMenuBar ) |
96 | { | |
97 | delete m_frameMenuBar; | |
d3b9f782 | 98 | m_frameMenuBar = NULL; |
7c0ea335 | 99 | } |
1e6feb95 | 100 | #endif // wxUSE_MENUS |
7c0ea335 VZ |
101 | |
102 | #if wxUSE_STATUSBAR | |
103 | if ( m_frameStatusBar ) | |
104 | { | |
105 | delete m_frameStatusBar; | |
d3b9f782 | 106 | m_frameStatusBar = NULL; |
7c0ea335 VZ |
107 | } |
108 | #endif // wxUSE_STATUSBAR | |
109 | ||
110 | #if wxUSE_TOOLBAR | |
111 | if ( m_frameToolBar ) | |
112 | { | |
113 | delete m_frameToolBar; | |
d3b9f782 | 114 | m_frameToolBar = NULL; |
7c0ea335 VZ |
115 | } |
116 | #endif // wxUSE_TOOLBAR | |
117 | } | |
118 | ||
1e6feb95 VZ |
119 | bool wxFrameBase::IsOneOfBars(const wxWindow *win) const |
120 | { | |
121 | #if wxUSE_MENUS | |
122 | if ( win == GetMenuBar() ) | |
d1b20379 | 123 | return true; |
1e6feb95 VZ |
124 | #endif // wxUSE_MENUS |
125 | ||
126 | #if wxUSE_STATUSBAR | |
127 | if ( win == GetStatusBar() ) | |
d1b20379 | 128 | return true; |
1e6feb95 VZ |
129 | #endif // wxUSE_STATUSBAR |
130 | ||
131 | #if wxUSE_TOOLBAR | |
132 | if ( win == GetToolBar() ) | |
d1b20379 | 133 | return true; |
1e6feb95 VZ |
134 | #endif // wxUSE_TOOLBAR |
135 | ||
8d22935d VZ |
136 | wxUnusedVar(win); |
137 | ||
d1b20379 | 138 | return false; |
1e6feb95 VZ |
139 | } |
140 | ||
1c4f8f8d VZ |
141 | // ---------------------------------------------------------------------------- |
142 | // wxFrame size management: we exclude the areas taken by menu/status/toolbars | |
143 | // from the client area, so the client area is what's really available for the | |
144 | // frame contents | |
145 | // ---------------------------------------------------------------------------- | |
146 | ||
147 | // get the origin of the client area in the client coordinates | |
148 | wxPoint wxFrameBase::GetClientAreaOrigin() const | |
149 | { | |
7d9f12f3 | 150 | wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin(); |
1c4f8f8d | 151 | |
a9928e9d | 152 | #if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__) |
d4597e13 VZ |
153 | wxToolBar *toolbar = GetToolBar(); |
154 | if ( toolbar && toolbar->IsShown() ) | |
1c4f8f8d VZ |
155 | { |
156 | int w, h; | |
d4597e13 | 157 | toolbar->GetSize(&w, &h); |
1c4f8f8d | 158 | |
d4597e13 | 159 | if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) |
1c4f8f8d VZ |
160 | { |
161 | pt.x += w; | |
162 | } | |
163 | else | |
164 | { | |
165 | pt.y += h; | |
166 | } | |
167 | } | |
168 | #endif // wxUSE_TOOLBAR | |
169 | ||
170 | return pt; | |
171 | } | |
172 | ||
7c0ea335 VZ |
173 | // ---------------------------------------------------------------------------- |
174 | // misc | |
175 | // ---------------------------------------------------------------------------- | |
176 | ||
a6ac49b1 VZ |
177 | #if wxUSE_MENUS |
178 | ||
7c0ea335 VZ |
179 | bool wxFrameBase::ProcessCommand(int id) |
180 | { | |
181 | wxMenuBar *bar = GetMenuBar(); | |
182 | if ( !bar ) | |
d1b20379 | 183 | return false; |
7c0ea335 | 184 | |
a6ac49b1 VZ |
185 | wxMenuItem *item = bar->FindItem(id); |
186 | if ( !item ) | |
187 | return false; | |
188 | ||
189 | return ProcessCommand(item); | |
190 | } | |
191 | ||
192 | bool wxFrameBase::ProcessCommand(wxMenuItem *item) | |
193 | { | |
194 | wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId()); | |
3ca6a5f0 BP |
195 | commandEvent.SetEventObject(this); |
196 | ||
a6ac49b1 VZ |
197 | if (!item->IsEnabled()) |
198 | return true; | |
d4597e13 | 199 | |
a6ac49b1 VZ |
200 | if ((item->GetKind() == wxITEM_RADIO) && item->IsChecked() ) |
201 | return true; | |
26c36d75 | 202 | |
a6ac49b1 VZ |
203 | if (item->IsCheckable()) |
204 | { | |
205 | item->Toggle(); | |
0472ece7 | 206 | |
a6ac49b1 VZ |
207 | // use the new value |
208 | commandEvent.SetInt(item->IsChecked()); | |
3ca6a5f0 | 209 | } |
7c0ea335 | 210 | |
e047f594 | 211 | return HandleWindowEvent(commandEvent); |
7c0ea335 VZ |
212 | } |
213 | ||
a6ac49b1 VZ |
214 | #endif // wxUSE_MENUS |
215 | ||
e39af974 JS |
216 | // Do the UI update processing for this window. This is |
217 | // provided for the application to call if it wants to | |
218 | // force a UI update, particularly for the menus and toolbar. | |
219 | void wxFrameBase::UpdateWindowUI(long flags) | |
220 | { | |
221 | wxWindowBase::UpdateWindowUI(flags); | |
a62848fd | 222 | |
e39af974 JS |
223 | #if wxUSE_TOOLBAR |
224 | if (GetToolBar()) | |
225 | GetToolBar()->UpdateWindowUI(flags); | |
226 | #endif | |
227 | ||
228 | #if wxUSE_MENUS | |
229 | if (GetMenuBar()) | |
230 | { | |
a2289551 VZ |
231 | // If coming from an idle event, we only want to update the menus if |
232 | // we're in the wxUSE_IDLEMENUUPDATES configuration, otherwise they | |
233 | // will be update when the menu is opened later | |
234 | #if !wxUSE_IDLEMENUUPDATES | |
235 | if ( !(flags & wxUPDATE_UI_FROMIDLE) ) | |
236 | #endif // wxUSE_IDLEMENUUPDATES | |
e39af974 JS |
237 | DoMenuUpdates(); |
238 | } | |
96ac065f | 239 | #endif // wxUSE_MENUS |
e39af974 JS |
240 | } |
241 | ||
7c0ea335 | 242 | // ---------------------------------------------------------------------------- |
96ac065f | 243 | // event handlers for status bar updates from menus |
7c0ea335 VZ |
244 | // ---------------------------------------------------------------------------- |
245 | ||
96ac065f VZ |
246 | #if wxUSE_MENUS && wxUSE_STATUSBAR |
247 | ||
7c0ea335 VZ |
248 | void wxFrameBase::OnMenuHighlight(wxMenuEvent& event) |
249 | { | |
250 | #if wxUSE_STATUSBAR | |
722ed5be | 251 | (void)ShowMenuHelp(event.GetMenuId()); |
7c0ea335 VZ |
252 | #endif // wxUSE_STATUSBAR |
253 | } | |
254 | ||
96ac065f VZ |
255 | void wxFrameBase::OnMenuOpen(wxMenuEvent& event) |
256 | { | |
a2289551 VZ |
257 | #if wxUSE_IDLEMENUUPDATES |
258 | wxUnusedVar(event); | |
259 | #else // !wxUSE_IDLEMENUUPDATES | |
260 | // as we didn't update the menus from idle time, do it now | |
96ac065f | 261 | DoMenuUpdates(event.GetMenu()); |
a2289551 | 262 | #endif // wxUSE_IDLEMENUUPDATES/!wxUSE_IDLEMENUUPDATES |
96ac065f VZ |
263 | } |
264 | ||
265 | void wxFrameBase::OnMenuClose(wxMenuEvent& WXUNUSED(event)) | |
266 | { | |
6d99eb3e | 267 | DoGiveHelp(wxEmptyString, false); |
96ac065f VZ |
268 | } |
269 | ||
270 | #endif // wxUSE_MENUS && wxUSE_STATUSBAR | |
271 | ||
e39af974 JS |
272 | // Implement internal behaviour (menu updating on some platforms) |
273 | void wxFrameBase::OnInternalIdle() | |
6522713c | 274 | { |
e2b6d07d | 275 | wxTopLevelWindow::OnInternalIdle(); |
a62848fd | 276 | |
0b30bb0b | 277 | #if wxUSE_MENUS && wxUSE_IDLEMENUUPDATES |
e39af974 | 278 | if (wxUpdateUIEvent::CanUpdate(this)) |
0b30bb0b JS |
279 | DoMenuUpdates(); |
280 | #endif | |
281 | } | |
282 | ||
7c0ea335 VZ |
283 | // ---------------------------------------------------------------------------- |
284 | // status bar stuff | |
285 | // ---------------------------------------------------------------------------- | |
286 | ||
287 | #if wxUSE_STATUSBAR | |
288 | ||
289 | wxStatusBar* wxFrameBase::CreateStatusBar(int number, | |
290 | long style, | |
291 | wxWindowID id, | |
292 | const wxString& name) | |
293 | { | |
294 | // the main status bar can only be created once (or else it should be | |
295 | // deleted before calling CreateStatusBar() again) | |
d3b9f782 | 296 | wxCHECK_MSG( !m_frameStatusBar, NULL, |
7c0ea335 VZ |
297 | wxT("recreating status bar in wxFrame") ); |
298 | ||
a4f01f05 | 299 | SetStatusBar(OnCreateStatusBar(number, style, id, name)); |
7c0ea335 VZ |
300 | |
301 | return m_frameStatusBar; | |
302 | } | |
303 | ||
304 | wxStatusBar *wxFrameBase::OnCreateStatusBar(int number, | |
305 | long style, | |
306 | wxWindowID id, | |
307 | const wxString& name) | |
308 | { | |
ed791986 | 309 | wxStatusBar *statusBar = new wxStatusBar(this, id, style, name); |
7c0ea335 | 310 | |
7c0ea335 VZ |
311 | statusBar->SetFieldsCount(number); |
312 | ||
313 | return statusBar; | |
314 | } | |
315 | ||
316 | void wxFrameBase::SetStatusText(const wxString& text, int number) | |
317 | { | |
7c0ea335 VZ |
318 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); |
319 | ||
320 | m_frameStatusBar->SetStatusText(text, number); | |
321 | } | |
322 | ||
323 | void wxFrameBase::SetStatusWidths(int n, const int widths_field[] ) | |
324 | { | |
7c0ea335 VZ |
325 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); |
326 | ||
327 | m_frameStatusBar->SetStatusWidths(n, widths_field); | |
328 | ||
329 | PositionStatusBar(); | |
330 | } | |
331 | ||
1f361cdd | 332 | void wxFrameBase::PushStatusText(const wxString& text, int number) |
f6bcfd97 | 333 | { |
1f361cdd MB |
334 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); |
335 | ||
336 | m_frameStatusBar->PushStatusText(text, number); | |
337 | } | |
f6bcfd97 | 338 | |
1f361cdd MB |
339 | void wxFrameBase::PopStatusText(int number) |
340 | { | |
341 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); | |
342 | ||
343 | m_frameStatusBar->PopStatusText(number); | |
344 | } | |
345 | ||
722ed5be | 346 | bool wxFrameBase::ShowMenuHelp(int menuId) |
1f361cdd MB |
347 | { |
348 | #if wxUSE_MENUS | |
f6bcfd97 BP |
349 | // if no help string found, we will clear the status bar text |
350 | wxString helpString; | |
fa36fe36 | 351 | if ( menuId != wxID_SEPARATOR && menuId != -3 /* wxID_TITLE */ ) |
f6bcfd97 | 352 | { |
10816efb | 353 | const wxMenuItem * const item = FindItemInMenuBar(menuId); |
fa7134b0 | 354 | if ( item && !item->IsSeparator() ) |
10816efb VZ |
355 | helpString = item->GetHelp(); |
356 | ||
357 | // notice that it's ok if we don't find the item because it might | |
358 | // belong to the popup menu, so don't assert here | |
f6bcfd97 BP |
359 | } |
360 | ||
6d99eb3e | 361 | DoGiveHelp(helpString, true); |
f6bcfd97 | 362 | |
1729813a | 363 | return !helpString.empty(); |
3379ed37 | 364 | #else // !wxUSE_MENUS |
d1b20379 | 365 | return false; |
3379ed37 | 366 | #endif // wxUSE_MENUS/!wxUSE_MENUS |
f6bcfd97 BP |
367 | } |
368 | ||
a4f01f05 VZ |
369 | void wxFrameBase::SetStatusBar(wxStatusBar *statBar) |
370 | { | |
371 | bool hadBar = m_frameStatusBar != NULL; | |
372 | m_frameStatusBar = statBar; | |
373 | ||
374 | if ( (m_frameStatusBar != NULL) != hadBar ) | |
375 | { | |
376 | PositionStatusBar(); | |
377 | ||
378 | DoLayout(); | |
379 | } | |
380 | } | |
381 | ||
7c0ea335 VZ |
382 | #endif // wxUSE_STATUSBAR |
383 | ||
f257ac87 | 384 | #if wxUSE_MENUS || wxUSE_TOOLBAR |
6d99eb3e | 385 | void wxFrameBase::DoGiveHelp(const wxString& help, bool show) |
c60a36d5 VZ |
386 | { |
387 | #if wxUSE_STATUSBAR | |
96ac065f VZ |
388 | if ( m_statusBarPane < 0 ) |
389 | { | |
390 | // status bar messages disabled | |
391 | return; | |
392 | } | |
393 | ||
394 | wxStatusBar *statbar = GetStatusBar(); | |
395 | if ( !statbar ) | |
396 | return; | |
397 | ||
6d99eb3e VZ |
398 | wxString text; |
399 | if ( show ) | |
4cbc928a | 400 | { |
6d99eb3e VZ |
401 | // remember the old status bar text if this is the first time we're |
402 | // called since the menu has been opened as we're going to overwrite it | |
403 | // in our DoGiveHelp() and we want to restore it when the menu is | |
404 | // closed | |
405 | // | |
406 | // note that it would be logical to do this in OnMenuOpen() but under | |
407 | // MSW we get an EVT_MENU_HIGHLIGHT before EVT_MENU_OPEN, strangely | |
408 | // enough, and so this doesn't work and instead we use the ugly trick | |
409 | // with using special m_oldStatusText value as "menu opened" (but it is | |
410 | // arguably better than adding yet another member variable to wxFrame | |
411 | // on all platforms) | |
96ac065f VZ |
412 | if ( m_oldStatusText.empty() ) |
413 | { | |
6d99eb3e VZ |
414 | m_oldStatusText = statbar->GetStatusText(m_statusBarPane); |
415 | if ( m_oldStatusText.empty() ) | |
416 | { | |
417 | // use special value to prevent us from doing this the next time | |
9a83f860 | 418 | m_oldStatusText += wxT('\0'); |
6d99eb3e | 419 | } |
96ac065f | 420 | } |
6d99eb3e VZ |
421 | |
422 | text = help; | |
423 | } | |
424 | else // hide help, restore the original text | |
425 | { | |
426 | text = m_oldStatusText; | |
427 | m_oldStatusText.clear(); | |
96ac065f | 428 | } |
c60a36d5 | 429 | |
6d99eb3e | 430 | statbar->SetStatusText(text, m_statusBarPane); |
f428e6c5 | 431 | #else |
3b257996 | 432 | wxUnusedVar(help); |
f428e6c5 | 433 | wxUnusedVar(show); |
c60a36d5 VZ |
434 | #endif // wxUSE_STATUSBAR |
435 | } | |
f257ac87 | 436 | #endif // wxUSE_MENUS || wxUSE_TOOLBAR |
c60a36d5 VZ |
437 | |
438 | ||
7c0ea335 VZ |
439 | // ---------------------------------------------------------------------------- |
440 | // toolbar stuff | |
441 | // ---------------------------------------------------------------------------- | |
442 | ||
443 | #if wxUSE_TOOLBAR | |
444 | ||
445 | wxToolBar* wxFrameBase::CreateToolBar(long style, | |
446 | wxWindowID id, | |
447 | const wxString& name) | |
448 | { | |
6a17b868 | 449 | // the main toolbar can't be recreated (unless it was explicitly deleted |
7c0ea335 | 450 | // before) |
d3b9f782 | 451 | wxCHECK_MSG( !m_frameToolBar, NULL, |
7c0ea335 VZ |
452 | wxT("recreating toolbar in wxFrame") ); |
453 | ||
f9dae779 VZ |
454 | if ( style == -1 ) |
455 | { | |
456 | // use default style | |
457 | // | |
458 | // NB: we don't specify the default value in the method declaration | |
459 | // because | |
460 | // a) this allows us to have different defaults for different | |
461 | // platforms (even if we don't have them right now) | |
462 | // b) we don't need to include wx/toolbar.h in the header then | |
463 | style = wxBORDER_NONE | wxTB_HORIZONTAL | wxTB_FLAT; | |
464 | } | |
465 | ||
a4f01f05 | 466 | SetToolBar(OnCreateToolBar(style, id, name)); |
7c0ea335 VZ |
467 | |
468 | return m_frameToolBar; | |
469 | } | |
470 | ||
471 | wxToolBar* wxFrameBase::OnCreateToolBar(long style, | |
472 | wxWindowID id, | |
473 | const wxString& name) | |
474 | { | |
a9102b36 JS |
475 | #if defined(__WXWINCE__) && defined(__POCKETPC__) |
476 | return new wxToolMenuBar(this, id, | |
477 | wxDefaultPosition, wxDefaultSize, | |
478 | style, name); | |
479 | #else | |
7c0ea335 VZ |
480 | return new wxToolBar(this, id, |
481 | wxDefaultPosition, wxDefaultSize, | |
482 | style, name); | |
a9102b36 | 483 | #endif |
7c0ea335 VZ |
484 | } |
485 | ||
a4f01f05 VZ |
486 | void wxFrameBase::SetToolBar(wxToolBar *toolbar) |
487 | { | |
488 | bool hadBar = m_frameToolBar != NULL; | |
489 | m_frameToolBar = toolbar; | |
490 | ||
491 | if ( (m_frameToolBar != NULL) != hadBar ) | |
492 | { | |
493 | PositionToolBar(); | |
494 | ||
495 | DoLayout(); | |
496 | } | |
497 | } | |
498 | ||
7c0ea335 VZ |
499 | #endif // wxUSE_TOOLBAR |
500 | ||
501 | // ---------------------------------------------------------------------------- | |
6522713c | 502 | // menus |
7c0ea335 VZ |
503 | // ---------------------------------------------------------------------------- |
504 | ||
1e6feb95 VZ |
505 | #if wxUSE_MENUS |
506 | ||
63fec618 | 507 | // update all menus |
92f1a59c | 508 | void wxFrameBase::DoMenuUpdates(wxMenu* menu) |
63fec618 | 509 | { |
92f1a59c | 510 | if (menu) |
4d538595 DS |
511 | { |
512 | wxEvtHandler* source = GetEventHandler(); | |
92f1a59c | 513 | menu->UpdateUI(source); |
4d538595 DS |
514 | } |
515 | else | |
54517652 | 516 | { |
4d538595 DS |
517 | wxMenuBar* bar = GetMenuBar(); |
518 | if (bar != NULL) | |
519 | bar->UpdateMenus(); | |
63fec618 | 520 | } |
63fec618 | 521 | } |
1e6feb95 | 522 | |
6522713c VZ |
523 | void wxFrameBase::DetachMenuBar() |
524 | { | |
525 | if ( m_frameMenuBar ) | |
526 | { | |
527 | m_frameMenuBar->Detach(); | |
528 | m_frameMenuBar = NULL; | |
529 | } | |
530 | } | |
531 | ||
532 | void wxFrameBase::AttachMenuBar(wxMenuBar *menubar) | |
533 | { | |
534 | if ( menubar ) | |
535 | { | |
6522713c | 536 | menubar->Attach((wxFrame *)this); |
3dbe38c3 | 537 | m_frameMenuBar = menubar; |
6522713c VZ |
538 | } |
539 | } | |
540 | ||
541 | void wxFrameBase::SetMenuBar(wxMenuBar *menubar) | |
542 | { | |
543 | if ( menubar == GetMenuBar() ) | |
544 | { | |
545 | // nothing to do | |
546 | return; | |
547 | } | |
548 | ||
549 | DetachMenuBar(); | |
550 | ||
a96b4743 | 551 | this->AttachMenuBar(menubar); |
6522713c VZ |
552 | } |
553 | ||
79f9ea05 | 554 | wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const |
10816efb VZ |
555 | { |
556 | const wxMenuBar * const menuBar = GetMenuBar(); | |
557 | ||
558 | return menuBar ? menuBar->FindItem(menuId) : NULL; | |
559 | } | |
560 | ||
1e6feb95 | 561 | #endif // wxUSE_MENUS |