corrected wxMenuBar::Insert , ::Append for a correct title even when the menubar is already attached, also removed a menu->attach which is not necessary anymore.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2002-01-11 19:14:30 +00:00
parent 4d23a4bf41
commit 40325b2630
2 changed files with 24 additions and 12 deletions

View File

@ -836,11 +836,13 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
m_titles.Insert(title, pos); m_titles.Insert(title, pos);
menu->Attach(this); Str255 label ;
wxMenuItem::MacBuildMenuString( label, NULL , NULL , title , false );
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , label ) ;
if ( IsAttached() ) if ( IsAttached() )
{ {
if ( pos == (size_t) -1 ) if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
{ {
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
} }
@ -947,12 +949,16 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
m_titles.Add(title); m_titles.Add(title);
Str255 label ;
wxMenuItem::MacBuildMenuString( label, NULL , NULL , title , false );
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , label ) ;
if ( IsAttached() ) if ( IsAttached() )
{ {
if (s_macInstalledMenuBar == this) if (s_macInstalledMenuBar == this)
{ {
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
} }
#if wxUSE_ACCEL #if wxUSE_ACCEL
if ( menu->HasAccels() ) if ( menu->HasAccels() )

View File

@ -836,11 +836,13 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
m_titles.Insert(title, pos); m_titles.Insert(title, pos);
menu->Attach(this); Str255 label ;
wxMenuItem::MacBuildMenuString( label, NULL , NULL , title , false );
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , label ) ;
if ( IsAttached() ) if ( IsAttached() )
{ {
if ( pos == (size_t) -1 ) if ( pos == (size_t) -1 || pos + 1 == m_menus.GetCount() )
{ {
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
} }
@ -947,12 +949,16 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
m_titles.Add(title); m_titles.Add(title);
Str255 label ;
wxMenuItem::MacBuildMenuString( label, NULL , NULL , title , false );
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , label ) ;
if ( IsAttached() ) if ( IsAttached() )
{ {
if (s_macInstalledMenuBar == this) if (s_macInstalledMenuBar == this)
{ {
::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ; ::InsertMenu( MAC_WXHMENU(menu->GetHMenu()) , 0 ) ;
} }
#if wxUSE_ACCEL #if wxUSE_ACCEL
if ( menu->HasAccels() ) if ( menu->HasAccels() )