Applied patch from Neil Robinson to allow manipulation of unattached menubars

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37270 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-02-03 16:29:05 +00:00
parent ab552aa4d7
commit 7e02be855d

View File

@@ -1054,7 +1054,11 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
m_titles[pos] = title; m_titles[pos] = title;
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (IsAttached()) if (IsAttached())
#else
if (GetHmenu())
#endif
{ {
int mswpos = MSWPositionForWxMenu(menuOld,pos); int mswpos = MSWPositionForWxMenu(menuOld,pos);
@@ -1079,6 +1083,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
} }
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
if (IsAttached())
Refresh(); Refresh();
} }
@@ -1090,7 +1095,14 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
// Find out which MSW item before which we'll be inserting before // Find out which MSW item before which we'll be inserting before
// wxMenuBarBase::Insert is called and GetMenu(pos) is the new menu. // wxMenuBarBase::Insert is called and GetMenu(pos) is the new menu.
// If IsAttached() is false this won't be used anyway // If IsAttached() is false this won't be used anyway
int mswpos = (!IsAttached() || (pos == m_menus.GetCount())) bool isAttached =
#if defined(WINCE_WITHOUT_COMMANDBAR)
IsAttached();
#else
(GetHmenu() != 0);
#endif
int mswpos = (!isAttached || (pos == m_menus.GetCount()))
? -1 // append the menu ? -1 // append the menu
: MSWPositionForWxMenu(GetMenu(pos),pos); : MSWPositionForWxMenu(GetMenu(pos),pos);
@@ -1099,9 +1111,9 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
m_titles.Insert(title, pos); m_titles.Insert(title, pos);
if ( IsAttached() ) if ( isAttached )
{ {
#if defined(WINCE_WITHOUT_COMMANDAR) #if defined(WINCE_WITHOUT_COMMANDBAR)
if (!GetToolBar()) if (!GetToolBar())
return false; return false;
TBBUTTON tbButton; TBBUTTON tbButton;
@@ -1137,6 +1149,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
} }
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
if (IsAttached())
Refresh(); Refresh();
} }
@@ -1153,9 +1166,13 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
m_titles.Add(title); m_titles.Add(title);
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (IsAttached()) if (IsAttached())
#else
if (GetHmenu())
#endif
{ {
#if defined(WINCE_WITHOUT_COMMANDAR) #if defined(WINCE_WITHOUT_COMMANDBAR)
if (!GetToolBar()) if (!GetToolBar())
return false; return false;
TBBUTTON tbButton; TBBUTTON tbButton;
@@ -1192,6 +1209,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
} }
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
if (IsAttached())
Refresh(); Refresh();
} }
@@ -1204,9 +1222,13 @@ wxMenu *wxMenuBar::Remove(size_t pos)
if ( !menu ) if ( !menu )
return NULL; return NULL;
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (IsAttached()) if (IsAttached())
#else
if (GetHmenu())
#endif
{ {
#if defined(WINCE_WITHOUT_COMMANDAR) #if defined(WINCE_WITHOUT_COMMANDBAR)
if (GetToolBar()) if (GetToolBar())
{ {
if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_DELETEBUTTON, (UINT) pos, (LPARAM) 0)) if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_DELETEBUTTON, (UINT) pos, (LPARAM) 0))
@@ -1229,10 +1251,10 @@ wxMenu *wxMenuBar::Remove(size_t pos)
} }
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
if (IsAttached())
Refresh(); Refresh();
} }
m_titles.RemoveAt(pos); m_titles.RemoveAt(pos);
return menu; return menu;