]> git.saurik.com Git - wxWidgets.git/blame - src/common/framecmn.cpp
Added support for reading image resolutions from PNG images.
[wxWidgets.git] / src / common / framecmn.cpp
CommitLineData
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 35
f313deaa
PC
36extern WXDLLEXPORT_DATA(const char) wxFrameNameStr[] = "frame";
37extern WXDLLEXPORT_DATA(const char) wxStatusLineNameStr[] = "status_line";
38
7c0ea335
VZ
39// ----------------------------------------------------------------------------
40// event table
41// ----------------------------------------------------------------------------
42
96ac065f
VZ
43#if wxUSE_MENUS && wxUSE_STATUSBAR
44
7d9f12f3 45BEGIN_EVENT_TABLE(wxFrameBase, wxTopLevelWindow)
0b30bb0b 46 EVT_MENU_OPEN(wxFrameBase::OnMenuOpen)
96ac065f
VZ
47 EVT_MENU_CLOSE(wxFrameBase::OnMenuClose)
48
7c0ea335 49 EVT_MENU_HIGHLIGHT_ALL(wxFrameBase::OnMenuHighlight)
7c0ea335
VZ
50END_EVENT_TABLE()
51
96ac065f
VZ
52#endif // wxUSE_MENUS && wxUSE_STATUSBAR
53
7c0ea335
VZ
54// ============================================================================
55// implementation
56// ============================================================================
57
28953245
SC
58// ----------------------------------------------------------------------------
59// XTI
60// ----------------------------------------------------------------------------
61
62wxDEFINE_FLAGS( wxFrameStyle )
63wxBEGIN_FLAGS( wxFrameStyle )
64// new style border flags, we put them first to
65// use them for streaming out
66wxFLAGS_MEMBER(wxBORDER_SIMPLE)
67wxFLAGS_MEMBER(wxBORDER_SUNKEN)
68wxFLAGS_MEMBER(wxBORDER_DOUBLE)
69wxFLAGS_MEMBER(wxBORDER_RAISED)
70wxFLAGS_MEMBER(wxBORDER_STATIC)
71wxFLAGS_MEMBER(wxBORDER_NONE)
72
73// old style border flags
74wxFLAGS_MEMBER(wxSIMPLE_BORDER)
75wxFLAGS_MEMBER(wxSUNKEN_BORDER)
76wxFLAGS_MEMBER(wxDOUBLE_BORDER)
77wxFLAGS_MEMBER(wxRAISED_BORDER)
78wxFLAGS_MEMBER(wxSTATIC_BORDER)
79wxFLAGS_MEMBER(wxBORDER)
80
81// standard window styles
82wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
83wxFLAGS_MEMBER(wxCLIP_CHILDREN)
84wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
85wxFLAGS_MEMBER(wxWANTS_CHARS)
86wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
87wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
88wxFLAGS_MEMBER(wxVSCROLL)
89wxFLAGS_MEMBER(wxHSCROLL)
90
91// frame styles
92wxFLAGS_MEMBER(wxSTAY_ON_TOP)
93wxFLAGS_MEMBER(wxCAPTION)
94#if WXWIN_COMPATIBILITY_2_6
95wxFLAGS_MEMBER(wxTHICK_FRAME)
96#endif // WXWIN_COMPATIBILITY_2_6
97wxFLAGS_MEMBER(wxSYSTEM_MENU)
98wxFLAGS_MEMBER(wxRESIZE_BORDER)
99#if WXWIN_COMPATIBILITY_2_6
100wxFLAGS_MEMBER(wxRESIZE_BOX)
101#endif // WXWIN_COMPATIBILITY_2_6
102wxFLAGS_MEMBER(wxCLOSE_BOX)
103wxFLAGS_MEMBER(wxMAXIMIZE_BOX)
104wxFLAGS_MEMBER(wxMINIMIZE_BOX)
105
106wxFLAGS_MEMBER(wxFRAME_TOOL_WINDOW)
107wxFLAGS_MEMBER(wxFRAME_FLOAT_ON_PARENT)
108
109wxFLAGS_MEMBER(wxFRAME_SHAPED)
110wxEND_FLAGS( wxFrameStyle )
111
112wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow, "wx/frame.h")
113
114wxBEGIN_PROPERTIES_TABLE(wxFrame)
115wxEVENT_PROPERTY( Menu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEvent)
116
117wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString(), 0 /*flags*/, \
118 wxT("Helpstring"), wxT("group"))
119wxPROPERTY_FLAGS( WindowStyle, wxFrameStyle, long, SetWindowStyleFlag, \
120 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
121 wxT("Helpstring"), wxT("group")) // style
122wxPROPERTY( MenuBar, wxMenuBar *, SetMenuBar, GetMenuBar, wxEMPTY_PARAMETER_VALUE, \
123 0 /*flags*/, wxT("Helpstring"), wxT("group"))
124wxEND_PROPERTIES_TABLE()
125
126wxEMPTY_HANDLERS_TABLE(wxFrame)
127
128wxCONSTRUCTOR_6( wxFrame, wxWindow*, Parent, wxWindowID, Id, wxString, Title, \
129 wxPoint, Position, wxSize, Size, long, WindowStyle)
130
7c0ea335
VZ
131// ----------------------------------------------------------------------------
132// construction/destruction
133// ----------------------------------------------------------------------------
134
135wxFrameBase::wxFrameBase()
136{
1e6feb95 137#if wxUSE_MENUS
7c0ea335 138 m_frameMenuBar = NULL;
1e6feb95 139#endif // wxUSE_MENUS
7c0ea335
VZ
140
141#if wxUSE_TOOLBAR
142 m_frameToolBar = NULL;
143#endif // wxUSE_TOOLBAR
144
145#if wxUSE_STATUSBAR
146 m_frameStatusBar = NULL;
147#endif // wxUSE_STATUSBAR
1f361cdd
MB
148
149 m_statusBarPane = 0;
7c0ea335
VZ
150}
151
799ea011
GD
152wxFrameBase::~wxFrameBase()
153{
154 // this destructor is required for Darwin
155}
156
7c0ea335
VZ
157wxFrame *wxFrameBase::New(wxWindow *parent,
158 wxWindowID id,
159 const wxString& title,
160 const wxPoint& pos,
161 const wxSize& size,
162 long style,
163 const wxString& name)
164{
165 return new wxFrame(parent, id, title, pos, size, style, name);
166}
167
168void wxFrameBase::DeleteAllBars()
169{
1e6feb95 170#if wxUSE_MENUS
5276b0a5 171 wxDELETE(m_frameMenuBar);
1e6feb95 172#endif // wxUSE_MENUS
7c0ea335
VZ
173
174#if wxUSE_STATUSBAR
5276b0a5 175 wxDELETE(m_frameStatusBar);
7c0ea335
VZ
176#endif // wxUSE_STATUSBAR
177
178#if wxUSE_TOOLBAR
5276b0a5 179 wxDELETE(m_frameToolBar);
7c0ea335
VZ
180#endif // wxUSE_TOOLBAR
181}
182
1e6feb95
VZ
183bool wxFrameBase::IsOneOfBars(const wxWindow *win) const
184{
185#if wxUSE_MENUS
186 if ( win == GetMenuBar() )
d1b20379 187 return true;
1e6feb95
VZ
188#endif // wxUSE_MENUS
189
190#if wxUSE_STATUSBAR
191 if ( win == GetStatusBar() )
d1b20379 192 return true;
1e6feb95
VZ
193#endif // wxUSE_STATUSBAR
194
195#if wxUSE_TOOLBAR
196 if ( win == GetToolBar() )
d1b20379 197 return true;
1e6feb95
VZ
198#endif // wxUSE_TOOLBAR
199
8d22935d
VZ
200 wxUnusedVar(win);
201
d1b20379 202 return false;
1e6feb95
VZ
203}
204
1c4f8f8d
VZ
205// ----------------------------------------------------------------------------
206// wxFrame size management: we exclude the areas taken by menu/status/toolbars
207// from the client area, so the client area is what's really available for the
208// frame contents
209// ----------------------------------------------------------------------------
210
211// get the origin of the client area in the client coordinates
212wxPoint wxFrameBase::GetClientAreaOrigin() const
213{
7d9f12f3 214 wxPoint pt = wxTopLevelWindow::GetClientAreaOrigin();
1c4f8f8d 215
a9928e9d 216#if wxUSE_TOOLBAR && !defined(__WXUNIVERSAL__)
d4597e13
VZ
217 wxToolBar *toolbar = GetToolBar();
218 if ( toolbar && toolbar->IsShown() )
1c4f8f8d
VZ
219 {
220 int w, h;
d4597e13 221 toolbar->GetSize(&w, &h);
1c4f8f8d 222
d4597e13 223 if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL )
1c4f8f8d
VZ
224 {
225 pt.x += w;
226 }
227 else
228 {
229 pt.y += h;
230 }
231 }
232#endif // wxUSE_TOOLBAR
233
234 return pt;
235}
236
7c0ea335
VZ
237// ----------------------------------------------------------------------------
238// misc
239// ----------------------------------------------------------------------------
240
a6ac49b1
VZ
241#if wxUSE_MENUS
242
7c0ea335
VZ
243bool wxFrameBase::ProcessCommand(int id)
244{
245 wxMenuBar *bar = GetMenuBar();
246 if ( !bar )
d1b20379 247 return false;
7c0ea335 248
a6ac49b1
VZ
249 wxMenuItem *item = bar->FindItem(id);
250 if ( !item )
251 return false;
252
253 return ProcessCommand(item);
254}
255
256bool wxFrameBase::ProcessCommand(wxMenuItem *item)
257{
258 wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
3ca6a5f0
BP
259 commandEvent.SetEventObject(this);
260
a6ac49b1
VZ
261 if (!item->IsEnabled())
262 return true;
d4597e13 263
a6ac49b1
VZ
264 if ((item->GetKind() == wxITEM_RADIO) && item->IsChecked() )
265 return true;
26c36d75 266
a6ac49b1
VZ
267 if (item->IsCheckable())
268 {
269 item->Toggle();
0472ece7 270
a6ac49b1
VZ
271 // use the new value
272 commandEvent.SetInt(item->IsChecked());
3ca6a5f0 273 }
7c0ea335 274
e047f594 275 return HandleWindowEvent(commandEvent);
7c0ea335
VZ
276}
277
a6ac49b1
VZ
278#endif // wxUSE_MENUS
279
e39af974
JS
280// Do the UI update processing for this window. This is
281// provided for the application to call if it wants to
282// force a UI update, particularly for the menus and toolbar.
283void wxFrameBase::UpdateWindowUI(long flags)
284{
285 wxWindowBase::UpdateWindowUI(flags);
a62848fd 286
e39af974
JS
287#if wxUSE_TOOLBAR
288 if (GetToolBar())
289 GetToolBar()->UpdateWindowUI(flags);
290#endif
291
292#if wxUSE_MENUS
293 if (GetMenuBar())
294 {
a2289551
VZ
295 // If coming from an idle event, we only want to update the menus if
296 // we're in the wxUSE_IDLEMENUUPDATES configuration, otherwise they
297 // will be update when the menu is opened later
298#if !wxUSE_IDLEMENUUPDATES
299 if ( !(flags & wxUPDATE_UI_FROMIDLE) )
300#endif // wxUSE_IDLEMENUUPDATES
e39af974
JS
301 DoMenuUpdates();
302 }
96ac065f 303#endif // wxUSE_MENUS
e39af974
JS
304}
305
7c0ea335 306// ----------------------------------------------------------------------------
96ac065f 307// event handlers for status bar updates from menus
7c0ea335
VZ
308// ----------------------------------------------------------------------------
309
96ac065f
VZ
310#if wxUSE_MENUS && wxUSE_STATUSBAR
311
7c0ea335
VZ
312void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
313{
314#if wxUSE_STATUSBAR
722ed5be 315 (void)ShowMenuHelp(event.GetMenuId());
7c0ea335
VZ
316#endif // wxUSE_STATUSBAR
317}
318
96ac065f
VZ
319void wxFrameBase::OnMenuOpen(wxMenuEvent& event)
320{
a2289551
VZ
321#if wxUSE_IDLEMENUUPDATES
322 wxUnusedVar(event);
323#else // !wxUSE_IDLEMENUUPDATES
324 // as we didn't update the menus from idle time, do it now
96ac065f 325 DoMenuUpdates(event.GetMenu());
a2289551 326#endif // wxUSE_IDLEMENUUPDATES/!wxUSE_IDLEMENUUPDATES
96ac065f
VZ
327}
328
329void wxFrameBase::OnMenuClose(wxMenuEvent& WXUNUSED(event))
330{
6d99eb3e 331 DoGiveHelp(wxEmptyString, false);
96ac065f
VZ
332}
333
334#endif // wxUSE_MENUS && wxUSE_STATUSBAR
335
e39af974
JS
336// Implement internal behaviour (menu updating on some platforms)
337void wxFrameBase::OnInternalIdle()
6522713c 338{
e2b6d07d 339 wxTopLevelWindow::OnInternalIdle();
a62848fd 340
0b30bb0b 341#if wxUSE_MENUS && wxUSE_IDLEMENUUPDATES
e39af974 342 if (wxUpdateUIEvent::CanUpdate(this))
0b30bb0b
JS
343 DoMenuUpdates();
344#endif
345}
346
7c0ea335
VZ
347// ----------------------------------------------------------------------------
348// status bar stuff
349// ----------------------------------------------------------------------------
350
351#if wxUSE_STATUSBAR
352
353wxStatusBar* wxFrameBase::CreateStatusBar(int number,
354 long style,
355 wxWindowID id,
356 const wxString& name)
357{
358 // the main status bar can only be created once (or else it should be
359 // deleted before calling CreateStatusBar() again)
d3b9f782 360 wxCHECK_MSG( !m_frameStatusBar, NULL,
7c0ea335
VZ
361 wxT("recreating status bar in wxFrame") );
362
a4f01f05 363 SetStatusBar(OnCreateStatusBar(number, style, id, name));
7c0ea335
VZ
364
365 return m_frameStatusBar;
366}
367
368wxStatusBar *wxFrameBase::OnCreateStatusBar(int number,
369 long style,
370 wxWindowID id,
371 const wxString& name)
372{
ed791986 373 wxStatusBar *statusBar = new wxStatusBar(this, id, style, name);
7c0ea335 374
7c0ea335
VZ
375 statusBar->SetFieldsCount(number);
376
377 return statusBar;
378}
379
380void wxFrameBase::SetStatusText(const wxString& text, int number)
381{
7c0ea335
VZ
382 wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") );
383
384 m_frameStatusBar->SetStatusText(text, number);
385}
386
387void wxFrameBase::SetStatusWidths(int n, const int widths_field[] )
388{
7c0ea335
VZ
389 wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set widths for") );
390
391 m_frameStatusBar->SetStatusWidths(n, widths_field);
392
393 PositionStatusBar();
394}
395
1f361cdd 396void wxFrameBase::PushStatusText(const wxString& text, int number)
f6bcfd97 397{
1f361cdd
MB
398 wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") );
399
400 m_frameStatusBar->PushStatusText(text, number);
401}
f6bcfd97 402
1f361cdd
MB
403void wxFrameBase::PopStatusText(int number)
404{
405 wxCHECK_RET( m_frameStatusBar != NULL, wxT("no statusbar to set text for") );
406
407 m_frameStatusBar->PopStatusText(number);
408}
409
722ed5be 410bool wxFrameBase::ShowMenuHelp(int menuId)
1f361cdd
MB
411{
412#if wxUSE_MENUS
f6bcfd97 413 // if no help string found, we will clear the status bar text
29c7962a
VZ
414 //
415 // NB: wxID_NONE is used for (sub)menus themselves by wxMSW
f6bcfd97 416 wxString helpString;
29c7962a 417 if ( menuId != wxID_SEPARATOR && menuId != wxID_NONE )
f6bcfd97 418 {
10816efb 419 const wxMenuItem * const item = FindItemInMenuBar(menuId);
fa7134b0 420 if ( item && !item->IsSeparator() )
10816efb
VZ
421 helpString = item->GetHelp();
422
423 // notice that it's ok if we don't find the item because it might
424 // belong to the popup menu, so don't assert here
f6bcfd97
BP
425 }
426
6d99eb3e 427 DoGiveHelp(helpString, true);
f6bcfd97 428
1729813a 429 return !helpString.empty();
3379ed37 430#else // !wxUSE_MENUS
d1b20379 431 return false;
3379ed37 432#endif // wxUSE_MENUS/!wxUSE_MENUS
f6bcfd97
BP
433}
434
a4f01f05
VZ
435void wxFrameBase::SetStatusBar(wxStatusBar *statBar)
436{
437 bool hadBar = m_frameStatusBar != NULL;
438 m_frameStatusBar = statBar;
439
440 if ( (m_frameStatusBar != NULL) != hadBar )
441 {
442 PositionStatusBar();
443
444 DoLayout();
445 }
446}
447
7c0ea335
VZ
448#endif // wxUSE_STATUSBAR
449
f257ac87 450#if wxUSE_MENUS || wxUSE_TOOLBAR
6d99eb3e 451void wxFrameBase::DoGiveHelp(const wxString& help, bool show)
c60a36d5
VZ
452{
453#if wxUSE_STATUSBAR
96ac065f
VZ
454 if ( m_statusBarPane < 0 )
455 {
456 // status bar messages disabled
457 return;
458 }
459
460 wxStatusBar *statbar = GetStatusBar();
461 if ( !statbar )
462 return;
463
6d99eb3e
VZ
464 wxString text;
465 if ( show )
4cbc928a 466 {
6d99eb3e
VZ
467 // remember the old status bar text if this is the first time we're
468 // called since the menu has been opened as we're going to overwrite it
469 // in our DoGiveHelp() and we want to restore it when the menu is
470 // closed
471 //
472 // note that it would be logical to do this in OnMenuOpen() but under
473 // MSW we get an EVT_MENU_HIGHLIGHT before EVT_MENU_OPEN, strangely
474 // enough, and so this doesn't work and instead we use the ugly trick
475 // with using special m_oldStatusText value as "menu opened" (but it is
476 // arguably better than adding yet another member variable to wxFrame
477 // on all platforms)
96ac065f
VZ
478 if ( m_oldStatusText.empty() )
479 {
6d99eb3e
VZ
480 m_oldStatusText = statbar->GetStatusText(m_statusBarPane);
481 if ( m_oldStatusText.empty() )
482 {
483 // use special value to prevent us from doing this the next time
9a83f860 484 m_oldStatusText += wxT('\0');
6d99eb3e 485 }
96ac065f 486 }
6d99eb3e 487
f0f03f32 488 m_lastHelpShown =
6d99eb3e
VZ
489 text = help;
490 }
491 else // hide help, restore the original text
492 {
f0f03f32
VZ
493 // clear the last shown help string but remember its value
494 wxString lastHelpShown;
495 lastHelpShown.swap(m_lastHelpShown);
496
497 // also clear the old status text but remember it too to restore it
498 // below
499 text.swap(m_oldStatusText);
500
501 if ( statbar->GetStatusText(m_statusBarPane) != lastHelpShown )
502 {
503 // if the text was changed with an explicit SetStatusText() call
504 // from the user code in the meanwhile, do not overwrite it with
505 // the old status bar contents -- this is almost certainly not what
506 // the user expects and would be very hard to avoid from user code
507 return;
508 }
96ac065f 509 }
c60a36d5 510
6d99eb3e 511 statbar->SetStatusText(text, m_statusBarPane);
f428e6c5 512#else
3b257996 513 wxUnusedVar(help);
f428e6c5 514 wxUnusedVar(show);
c60a36d5
VZ
515#endif // wxUSE_STATUSBAR
516}
f257ac87 517#endif // wxUSE_MENUS || wxUSE_TOOLBAR
c60a36d5
VZ
518
519
7c0ea335
VZ
520// ----------------------------------------------------------------------------
521// toolbar stuff
522// ----------------------------------------------------------------------------
523
524#if wxUSE_TOOLBAR
525
526wxToolBar* wxFrameBase::CreateToolBar(long style,
527 wxWindowID id,
528 const wxString& name)
529{
6a17b868 530 // the main toolbar can't be recreated (unless it was explicitly deleted
7c0ea335 531 // before)
d3b9f782 532 wxCHECK_MSG( !m_frameToolBar, NULL,
7c0ea335
VZ
533 wxT("recreating toolbar in wxFrame") );
534
f9dae779
VZ
535 if ( style == -1 )
536 {
537 // use default style
538 //
539 // NB: we don't specify the default value in the method declaration
540 // because
541 // a) this allows us to have different defaults for different
542 // platforms (even if we don't have them right now)
543 // b) we don't need to include wx/toolbar.h in the header then
544 style = wxBORDER_NONE | wxTB_HORIZONTAL | wxTB_FLAT;
545 }
546
a4f01f05 547 SetToolBar(OnCreateToolBar(style, id, name));
7c0ea335
VZ
548
549 return m_frameToolBar;
550}
551
552wxToolBar* wxFrameBase::OnCreateToolBar(long style,
553 wxWindowID id,
554 const wxString& name)
555{
a9102b36
JS
556#if defined(__WXWINCE__) && defined(__POCKETPC__)
557 return new wxToolMenuBar(this, id,
558 wxDefaultPosition, wxDefaultSize,
559 style, name);
560#else
7c0ea335
VZ
561 return new wxToolBar(this, id,
562 wxDefaultPosition, wxDefaultSize,
563 style, name);
a9102b36 564#endif
7c0ea335
VZ
565}
566
a4f01f05
VZ
567void wxFrameBase::SetToolBar(wxToolBar *toolbar)
568{
62f6be44 569 if ( (toolbar != NULL) != (m_frameToolBar != NULL) )
a4f01f05 570 {
62f6be44
VZ
571 // the toolbar visibility must have changed so we need to both position
572 // the toolbar itself (if it appeared) and to relayout the frame
573 // contents in any case
574
575 if ( toolbar )
576 {
577 // we need to assign it to m_frameToolBar for PositionToolBar() to
578 // do anything
579 m_frameToolBar = toolbar;
580 PositionToolBar();
581 }
582 //else: tricky: do not reset m_frameToolBar yet as otherwise DoLayout()
583 // wouldn't recognize the (still existing) toolbar as one of our
584 // bars and wouldn't layout the single child of the frame correctly
585
586
587 // and this is even more tricky: we want DoLayout() to recognize the
588 // old toolbar for the purpose of not counting it among our non-bar
589 // children but we don't want to reserve any more space for it so we
590 // temporarily hide it
591 if ( m_frameToolBar )
592 m_frameToolBar->Hide();
a4f01f05
VZ
593
594 DoLayout();
62f6be44
VZ
595
596 if ( m_frameToolBar )
597 m_frameToolBar->Show();
a4f01f05 598 }
62f6be44
VZ
599
600 // this might have been already done above but it's simpler to just always
601 // do it unconditionally instead of testing for whether we already did it
602 m_frameToolBar = toolbar;
a4f01f05
VZ
603}
604
7c0ea335
VZ
605#endif // wxUSE_TOOLBAR
606
607// ----------------------------------------------------------------------------
6522713c 608// menus
7c0ea335
VZ
609// ----------------------------------------------------------------------------
610
1e6feb95
VZ
611#if wxUSE_MENUS
612
63fec618 613// update all menus
92f1a59c 614void wxFrameBase::DoMenuUpdates(wxMenu* menu)
63fec618 615{
92f1a59c 616 if (menu)
4d538595
DS
617 {
618 wxEvtHandler* source = GetEventHandler();
92f1a59c 619 menu->UpdateUI(source);
4d538595
DS
620 }
621 else
54517652 622 {
4d538595
DS
623 wxMenuBar* bar = GetMenuBar();
624 if (bar != NULL)
625 bar->UpdateMenus();
63fec618 626 }
63fec618 627}
1e6feb95 628
6522713c
VZ
629void wxFrameBase::DetachMenuBar()
630{
631 if ( m_frameMenuBar )
632 {
633 m_frameMenuBar->Detach();
634 m_frameMenuBar = NULL;
635 }
636}
637
638void wxFrameBase::AttachMenuBar(wxMenuBar *menubar)
639{
640 if ( menubar )
641 {
6522713c 642 menubar->Attach((wxFrame *)this);
3dbe38c3 643 m_frameMenuBar = menubar;
6522713c
VZ
644 }
645}
646
647void wxFrameBase::SetMenuBar(wxMenuBar *menubar)
648{
649 if ( menubar == GetMenuBar() )
650 {
651 // nothing to do
652 return;
653 }
654
655 DetachMenuBar();
656
a96b4743 657 this->AttachMenuBar(menubar);
6522713c
VZ
658}
659
79f9ea05 660wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const
10816efb
VZ
661{
662 const wxMenuBar * const menuBar = GetMenuBar();
663
664 return menuBar ? menuBar->FindItem(menuId) : NULL;
665}
666
1e6feb95 667#endif // wxUSE_MENUS