]>
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; | |
98 | m_frameMenuBar = (wxMenuBar *) NULL; | |
99 | } | |
1e6feb95 | 100 | #endif // wxUSE_MENUS |
7c0ea335 VZ |
101 | |
102 | #if wxUSE_STATUSBAR | |
103 | if ( m_frameStatusBar ) | |
104 | { | |
105 | delete m_frameStatusBar; | |
106 | m_frameStatusBar = (wxStatusBar *) NULL; | |
107 | } | |
108 | #endif // wxUSE_STATUSBAR | |
109 | ||
110 | #if wxUSE_TOOLBAR | |
111 | if ( m_frameToolBar ) | |
112 | { | |
113 | delete m_frameToolBar; | |
114 | m_frameToolBar = (wxToolBar *) NULL; | |
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 | ||
2b022169 RD |
173 | |
174 | void wxFrameBase::SendSizeEvent() | |
175 | { | |
176 | wxSizeEvent event( GetSize(), GetId() ); | |
177 | event.SetEventObject( this ); | |
178 | GetEventHandler()->AddPendingEvent( event ); | |
179 | } | |
180 | ||
181 | ||
7c0ea335 VZ |
182 | // ---------------------------------------------------------------------------- |
183 | // misc | |
184 | // ---------------------------------------------------------------------------- | |
185 | ||
a6ac49b1 VZ |
186 | #if wxUSE_MENUS |
187 | ||
7c0ea335 VZ |
188 | bool wxFrameBase::ProcessCommand(int id) |
189 | { | |
190 | wxMenuBar *bar = GetMenuBar(); | |
191 | if ( !bar ) | |
d1b20379 | 192 | return false; |
7c0ea335 | 193 | |
a6ac49b1 VZ |
194 | wxMenuItem *item = bar->FindItem(id); |
195 | if ( !item ) | |
196 | return false; | |
197 | ||
198 | return ProcessCommand(item); | |
199 | } | |
200 | ||
201 | bool wxFrameBase::ProcessCommand(wxMenuItem *item) | |
202 | { | |
203 | wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId()); | |
3ca6a5f0 BP |
204 | commandEvent.SetEventObject(this); |
205 | ||
a6ac49b1 VZ |
206 | if (!item->IsEnabled()) |
207 | return true; | |
d4597e13 | 208 | |
a6ac49b1 VZ |
209 | if ((item->GetKind() == wxITEM_RADIO) && item->IsChecked() ) |
210 | return true; | |
26c36d75 | 211 | |
a6ac49b1 VZ |
212 | if (item->IsCheckable()) |
213 | { | |
214 | item->Toggle(); | |
0472ece7 | 215 | |
a6ac49b1 VZ |
216 | // use the new value |
217 | commandEvent.SetInt(item->IsChecked()); | |
3ca6a5f0 | 218 | } |
7c0ea335 | 219 | |
e047f594 | 220 | return HandleWindowEvent(commandEvent); |
7c0ea335 VZ |
221 | } |
222 | ||
a6ac49b1 VZ |
223 | #endif // wxUSE_MENUS |
224 | ||
e39af974 JS |
225 | // Do the UI update processing for this window. This is |
226 | // provided for the application to call if it wants to | |
227 | // force a UI update, particularly for the menus and toolbar. | |
228 | void wxFrameBase::UpdateWindowUI(long flags) | |
229 | { | |
230 | wxWindowBase::UpdateWindowUI(flags); | |
a62848fd | 231 | |
e39af974 JS |
232 | #if wxUSE_TOOLBAR |
233 | if (GetToolBar()) | |
234 | GetToolBar()->UpdateWindowUI(flags); | |
235 | #endif | |
236 | ||
237 | #if wxUSE_MENUS | |
238 | if (GetMenuBar()) | |
239 | { | |
240 | if ((flags & wxUPDATE_UI_FROMIDLE) && !wxUSE_IDLEMENUUPDATES) | |
241 | { | |
242 | // If coming from an idle event, we only | |
243 | // want to update the menus if we're | |
244 | // in the wxUSE_IDLEMENUUPDATES configuration: | |
245 | // so if we're not, do nothing | |
246 | } | |
247 | else | |
248 | DoMenuUpdates(); | |
249 | } | |
96ac065f | 250 | #endif // wxUSE_MENUS |
e39af974 JS |
251 | } |
252 | ||
7c0ea335 | 253 | // ---------------------------------------------------------------------------- |
96ac065f | 254 | // event handlers for status bar updates from menus |
7c0ea335 VZ |
255 | // ---------------------------------------------------------------------------- |
256 | ||
96ac065f VZ |
257 | #if wxUSE_MENUS && wxUSE_STATUSBAR |
258 | ||
7c0ea335 VZ |
259 | void wxFrameBase::OnMenuHighlight(wxMenuEvent& event) |
260 | { | |
261 | #if wxUSE_STATUSBAR | |
722ed5be | 262 | (void)ShowMenuHelp(event.GetMenuId()); |
7c0ea335 VZ |
263 | #endif // wxUSE_STATUSBAR |
264 | } | |
265 | ||
d1b20379 | 266 | #if !wxUSE_IDLEMENUUPDATES |
96ac065f | 267 | void wxFrameBase::OnMenuOpen(wxMenuEvent& event) |
d1b20379 DS |
268 | #else |
269 | void wxFrameBase::OnMenuOpen(wxMenuEvent& WXUNUSED(event)) | |
270 | #endif | |
96ac065f VZ |
271 | { |
272 | #if !wxUSE_IDLEMENUUPDATES | |
273 | DoMenuUpdates(event.GetMenu()); | |
274 | #endif // !wxUSE_IDLEMENUUPDATES | |
275 | } | |
276 | ||
277 | void wxFrameBase::OnMenuClose(wxMenuEvent& WXUNUSED(event)) | |
278 | { | |
6d99eb3e | 279 | DoGiveHelp(wxEmptyString, false); |
96ac065f VZ |
280 | } |
281 | ||
282 | #endif // wxUSE_MENUS && wxUSE_STATUSBAR | |
283 | ||
e39af974 JS |
284 | // Implement internal behaviour (menu updating on some platforms) |
285 | void wxFrameBase::OnInternalIdle() | |
6522713c | 286 | { |
e2b6d07d | 287 | wxTopLevelWindow::OnInternalIdle(); |
a62848fd | 288 | |
0b30bb0b | 289 | #if wxUSE_MENUS && wxUSE_IDLEMENUUPDATES |
e39af974 | 290 | if (wxUpdateUIEvent::CanUpdate(this)) |
0b30bb0b JS |
291 | DoMenuUpdates(); |
292 | #endif | |
293 | } | |
294 | ||
7c0ea335 VZ |
295 | // ---------------------------------------------------------------------------- |
296 | // status bar stuff | |
297 | // ---------------------------------------------------------------------------- | |
298 | ||
299 | #if wxUSE_STATUSBAR | |
300 | ||
301 | wxStatusBar* wxFrameBase::CreateStatusBar(int number, | |
302 | long style, | |
303 | wxWindowID id, | |
304 | const wxString& name) | |
305 | { | |
306 | // the main status bar can only be created once (or else it should be | |
307 | // deleted before calling CreateStatusBar() again) | |
308 | wxCHECK_MSG( !m_frameStatusBar, (wxStatusBar *)NULL, | |
309 | wxT("recreating status bar in wxFrame") ); | |
310 | ||
a4f01f05 | 311 | SetStatusBar(OnCreateStatusBar(number, style, id, name)); |
7c0ea335 VZ |
312 | |
313 | return m_frameStatusBar; | |
314 | } | |
315 | ||
316 | wxStatusBar *wxFrameBase::OnCreateStatusBar(int number, | |
317 | long style, | |
318 | wxWindowID id, | |
319 | const wxString& name) | |
320 | { | |
ed791986 | 321 | wxStatusBar *statusBar = new wxStatusBar(this, id, style, name); |
7c0ea335 | 322 | |
7c0ea335 VZ |
323 | statusBar->SetFieldsCount(number); |
324 | ||
325 | return statusBar; | |
326 | } | |
327 | ||
328 | void wxFrameBase::SetStatusText(const wxString& text, int number) | |
329 | { | |
7c0ea335 VZ |
330 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); |
331 | ||
332 | m_frameStatusBar->SetStatusText(text, number); | |
333 | } | |
334 | ||
335 | void wxFrameBase::SetStatusWidths(int n, const int widths_field[] ) | |
336 | { | |
7c0ea335 VZ |
337 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") ); |
338 | ||
339 | m_frameStatusBar->SetStatusWidths(n, widths_field); | |
340 | ||
341 | PositionStatusBar(); | |
342 | } | |
343 | ||
1f361cdd | 344 | void wxFrameBase::PushStatusText(const wxString& text, int number) |
f6bcfd97 | 345 | { |
1f361cdd MB |
346 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); |
347 | ||
348 | m_frameStatusBar->PushStatusText(text, number); | |
349 | } | |
f6bcfd97 | 350 | |
1f361cdd MB |
351 | void wxFrameBase::PopStatusText(int number) |
352 | { | |
353 | wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") ); | |
354 | ||
355 | m_frameStatusBar->PopStatusText(number); | |
356 | } | |
357 | ||
722ed5be | 358 | bool wxFrameBase::ShowMenuHelp(int menuId) |
1f361cdd MB |
359 | { |
360 | #if wxUSE_MENUS | |
f6bcfd97 BP |
361 | // if no help string found, we will clear the status bar text |
362 | wxString helpString; | |
fa36fe36 | 363 | if ( menuId != wxID_SEPARATOR && menuId != -3 /* wxID_TITLE */ ) |
f6bcfd97 | 364 | { |
10816efb | 365 | const wxMenuItem * const item = FindItemInMenuBar(menuId); |
fa7134b0 | 366 | if ( item && !item->IsSeparator() ) |
10816efb VZ |
367 | helpString = item->GetHelp(); |
368 | ||
369 | // notice that it's ok if we don't find the item because it might | |
370 | // belong to the popup menu, so don't assert here | |
f6bcfd97 BP |
371 | } |
372 | ||
6d99eb3e | 373 | DoGiveHelp(helpString, true); |
f6bcfd97 | 374 | |
1729813a | 375 | return !helpString.empty(); |
3379ed37 | 376 | #else // !wxUSE_MENUS |
d1b20379 | 377 | return false; |
3379ed37 | 378 | #endif // wxUSE_MENUS/!wxUSE_MENUS |
f6bcfd97 BP |
379 | } |
380 | ||
a4f01f05 VZ |
381 | void wxFrameBase::SetStatusBar(wxStatusBar *statBar) |
382 | { | |
383 | bool hadBar = m_frameStatusBar != NULL; | |
384 | m_frameStatusBar = statBar; | |
385 | ||
386 | if ( (m_frameStatusBar != NULL) != hadBar ) | |
387 | { | |
388 | PositionStatusBar(); | |
389 | ||
390 | DoLayout(); | |
391 | } | |
392 | } | |
393 | ||
7c0ea335 VZ |
394 | #endif // wxUSE_STATUSBAR |
395 | ||
f257ac87 | 396 | #if wxUSE_MENUS || wxUSE_TOOLBAR |
6d99eb3e | 397 | void wxFrameBase::DoGiveHelp(const wxString& help, bool show) |
c60a36d5 VZ |
398 | { |
399 | #if wxUSE_STATUSBAR | |
96ac065f VZ |
400 | if ( m_statusBarPane < 0 ) |
401 | { | |
402 | // status bar messages disabled | |
403 | return; | |
404 | } | |
405 | ||
406 | wxStatusBar *statbar = GetStatusBar(); | |
407 | if ( !statbar ) | |
408 | return; | |
409 | ||
6d99eb3e VZ |
410 | wxString text; |
411 | if ( show ) | |
4cbc928a | 412 | { |
6d99eb3e VZ |
413 | // remember the old status bar text if this is the first time we're |
414 | // called since the menu has been opened as we're going to overwrite it | |
415 | // in our DoGiveHelp() and we want to restore it when the menu is | |
416 | // closed | |
417 | // | |
418 | // note that it would be logical to do this in OnMenuOpen() but under | |
419 | // MSW we get an EVT_MENU_HIGHLIGHT before EVT_MENU_OPEN, strangely | |
420 | // enough, and so this doesn't work and instead we use the ugly trick | |
421 | // with using special m_oldStatusText value as "menu opened" (but it is | |
422 | // arguably better than adding yet another member variable to wxFrame | |
423 | // on all platforms) | |
96ac065f VZ |
424 | if ( m_oldStatusText.empty() ) |
425 | { | |
6d99eb3e VZ |
426 | m_oldStatusText = statbar->GetStatusText(m_statusBarPane); |
427 | if ( m_oldStatusText.empty() ) | |
428 | { | |
429 | // use special value to prevent us from doing this the next time | |
430 | m_oldStatusText += _T('\0'); | |
431 | } | |
96ac065f | 432 | } |
6d99eb3e VZ |
433 | |
434 | text = help; | |
435 | } | |
436 | else // hide help, restore the original text | |
437 | { | |
438 | text = m_oldStatusText; | |
439 | m_oldStatusText.clear(); | |
96ac065f | 440 | } |
c60a36d5 | 441 | |
6d99eb3e | 442 | statbar->SetStatusText(text, m_statusBarPane); |
f428e6c5 | 443 | #else |
3b257996 | 444 | wxUnusedVar(help); |
f428e6c5 | 445 | wxUnusedVar(show); |
c60a36d5 VZ |
446 | #endif // wxUSE_STATUSBAR |
447 | } | |
f257ac87 | 448 | #endif // wxUSE_MENUS || wxUSE_TOOLBAR |
c60a36d5 VZ |
449 | |
450 | ||
7c0ea335 VZ |
451 | // ---------------------------------------------------------------------------- |
452 | // toolbar stuff | |
453 | // ---------------------------------------------------------------------------- | |
454 | ||
455 | #if wxUSE_TOOLBAR | |
456 | ||
457 | wxToolBar* wxFrameBase::CreateToolBar(long style, | |
458 | wxWindowID id, | |
459 | const wxString& name) | |
460 | { | |
6a17b868 | 461 | // the main toolbar can't be recreated (unless it was explicitly deleted |
7c0ea335 VZ |
462 | // before) |
463 | wxCHECK_MSG( !m_frameToolBar, (wxToolBar *)NULL, | |
464 | wxT("recreating toolbar in wxFrame") ); | |
465 | ||
f9dae779 VZ |
466 | if ( style == -1 ) |
467 | { | |
468 | // use default style | |
469 | // | |
470 | // NB: we don't specify the default value in the method declaration | |
471 | // because | |
472 | // a) this allows us to have different defaults for different | |
473 | // platforms (even if we don't have them right now) | |
474 | // b) we don't need to include wx/toolbar.h in the header then | |
475 | style = wxBORDER_NONE | wxTB_HORIZONTAL | wxTB_FLAT; | |
476 | } | |
477 | ||
a4f01f05 | 478 | SetToolBar(OnCreateToolBar(style, id, name)); |
7c0ea335 VZ |
479 | |
480 | return m_frameToolBar; | |
481 | } | |
482 | ||
483 | wxToolBar* wxFrameBase::OnCreateToolBar(long style, | |
484 | wxWindowID id, | |
485 | const wxString& name) | |
486 | { | |
a9102b36 JS |
487 | #if defined(__WXWINCE__) && defined(__POCKETPC__) |
488 | return new wxToolMenuBar(this, id, | |
489 | wxDefaultPosition, wxDefaultSize, | |
490 | style, name); | |
491 | #else | |
7c0ea335 VZ |
492 | return new wxToolBar(this, id, |
493 | wxDefaultPosition, wxDefaultSize, | |
494 | style, name); | |
a9102b36 | 495 | #endif |
7c0ea335 VZ |
496 | } |
497 | ||
a4f01f05 VZ |
498 | void wxFrameBase::SetToolBar(wxToolBar *toolbar) |
499 | { | |
500 | bool hadBar = m_frameToolBar != NULL; | |
501 | m_frameToolBar = toolbar; | |
502 | ||
503 | if ( (m_frameToolBar != NULL) != hadBar ) | |
504 | { | |
505 | PositionToolBar(); | |
506 | ||
507 | DoLayout(); | |
508 | } | |
509 | } | |
510 | ||
7c0ea335 VZ |
511 | #endif // wxUSE_TOOLBAR |
512 | ||
513 | // ---------------------------------------------------------------------------- | |
6522713c | 514 | // menus |
7c0ea335 VZ |
515 | // ---------------------------------------------------------------------------- |
516 | ||
1e6feb95 VZ |
517 | #if wxUSE_MENUS |
518 | ||
63fec618 | 519 | // update all menus |
92f1a59c | 520 | void wxFrameBase::DoMenuUpdates(wxMenu* menu) |
63fec618 | 521 | { |
92f1a59c | 522 | if (menu) |
4d538595 DS |
523 | { |
524 | wxEvtHandler* source = GetEventHandler(); | |
92f1a59c | 525 | menu->UpdateUI(source); |
4d538595 DS |
526 | } |
527 | else | |
54517652 | 528 | { |
4d538595 DS |
529 | wxMenuBar* bar = GetMenuBar(); |
530 | if (bar != NULL) | |
531 | bar->UpdateMenus(); | |
63fec618 | 532 | } |
63fec618 | 533 | } |
1e6feb95 | 534 | |
6522713c VZ |
535 | void wxFrameBase::DetachMenuBar() |
536 | { | |
537 | if ( m_frameMenuBar ) | |
538 | { | |
539 | m_frameMenuBar->Detach(); | |
540 | m_frameMenuBar = NULL; | |
541 | } | |
542 | } | |
543 | ||
544 | void wxFrameBase::AttachMenuBar(wxMenuBar *menubar) | |
545 | { | |
546 | if ( menubar ) | |
547 | { | |
6522713c | 548 | menubar->Attach((wxFrame *)this); |
3dbe38c3 | 549 | m_frameMenuBar = menubar; |
6522713c VZ |
550 | } |
551 | } | |
552 | ||
553 | void wxFrameBase::SetMenuBar(wxMenuBar *menubar) | |
554 | { | |
555 | if ( menubar == GetMenuBar() ) | |
556 | { | |
557 | // nothing to do | |
558 | return; | |
559 | } | |
560 | ||
561 | DetachMenuBar(); | |
562 | ||
a96b4743 | 563 | this->AttachMenuBar(menubar); |
6522713c VZ |
564 | } |
565 | ||
10816efb VZ |
566 | const wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const |
567 | { | |
568 | const wxMenuBar * const menuBar = GetMenuBar(); | |
569 | ||
570 | return menuBar ? menuBar->FindItem(menuId) : NULL; | |
571 | } | |
572 | ||
1e6feb95 | 573 | #endif // wxUSE_MENUS |