for( size_t i = 0 ; i < GetMenuCount() ; ++i )
{
wxMenuInfo* info = new wxMenuInfo() ;
- info->Create( const_cast<wxMenuBar*>(this)->GetMenu(i) , GetLabelTop(i) ) ;
+ info->Create( const_cast<wxMenuBar*>(this)->GetMenu(i) , GetMenuLabel(i) ) ;
list->Append( info ) ;
}
return m_menuInfos ;
}
// find the (new) accel for this item
- wxAcceleratorEntry *accel = wxAcceleratorEntry::Create(item->GetText());
+ wxAcceleratorEntry *accel = wxAcceleratorEntry::Create(item->GetItemLabel());
if ( accel )
accel->m_command = item->GetId();
// prepare to insert the item in the menu
- wxString itemText = pItem->GetText();
+ wxString itemText = pItem->GetItemLabel();
LPCTSTR pData = NULL;
if ( pos == (size_t)-1 )
{
flags |= MF_STRING;
#ifdef __WXWINCE__
- itemText = wxMenuItem::GetLabelFromText(itemText);
+ itemText = wxMenuItem::GetLabelText(itemText);
#endif
pData = (wxChar*)itemText.wx_str();
// event processing
// ---------------------------------------------------------------------------
-bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)
+bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
{
+ const int id = (signed short)id_;
+
// ignore commands from the menu title
- if ( id != (WXWORD)idMenuTitle )
+ if ( id != idMenuTitle )
{
// update the check item when it's clicked
wxMenuItem * const item = FindItem(id);
if ( m_hMenu != 0 )
return m_hMenu;
- if (!GetToolBar())
- return 0;
+ wxToolMenuBar * const bar = wx_static_cast(wxToolMenuBar *, GetToolBar());
+ if ( !bar )
+ return NULL;
- HWND hCommandBar = (HWND) GetToolBar()->GetHWND();
- HMENU hMenu = (HMENU)::SendMessage(hCommandBar, SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0);
+ HWND hCommandBar = GetHwndOf(bar);
- // hMenu may be zero on Windows Mobile 5. So add the menus anyway.
- if (1) // (hMenu)
- {
- TBBUTTON tbButton;
- memset(&tbButton, 0, sizeof(TBBUTTON));
- tbButton.iBitmap = I_IMAGENONE;
- tbButton.fsState = TBSTATE_ENABLED;
- tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
+ // notify comctl32.dll about the version of the headers we use before using
+ // any other TB_XXX messages
+ SendMessage(hCommandBar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
- size_t i;
- for (i = 0; i < GetMenuCount(); i++)
- {
- HMENU hPopupMenu = (HMENU) GetMenu(i)->GetHMenu() ;
- tbButton.dwData = (DWORD)hPopupMenu;
- wxString label = wxStripMenuCodes(GetLabelTop(i));
- tbButton.iString = (int) label.wx_str();
+ TBBUTTON tbButton;
+ wxZeroMemory(tbButton);
+ tbButton.iBitmap = I_IMAGENONE;
+ tbButton.fsState = TBSTATE_ENABLED;
+ tbButton.fsStyle = TBSTYLE_DROPDOWN |
+ TBSTYLE_NO_DROPDOWN_ARROW |
+ TBSTYLE_AUTOSIZE;
- int position = i;
+ for ( unsigned i = 0; i < GetMenuCount(); i++ )
+ {
+ HMENU hPopupMenu = (HMENU) GetMenu(i)->GetHMenu();
+ tbButton.dwData = (DWORD)hPopupMenu;
+ wxString label = wxStripMenuCodes(GetMenuLabel(i));
+ tbButton.iString = (int) label.wx_str();
- tbButton.idCommand = NewControlId();
- if (!::SendMessage(hCommandBar, TB_INSERTBUTTON, position, (LPARAM)&tbButton))
- {
- wxLogLastError(wxT("TB_INSERTBUTTON"));
- }
+ tbButton.idCommand = NewControlId();
+ if ( !::SendMessage(hCommandBar, TB_INSERTBUTTON, i, (LPARAM)&tbButton) )
+ {
+ wxLogLastError(wxT("TB_INSERTBUTTON"));
}
}
- m_hMenu = (WXHMENU) hMenu;
+
+ m_hMenu = bar->GetHMenu();
return m_hMenu;
-#else
+#else // !__WXWINCE__
if ( m_hMenu != 0 )
return m_hMenu;
}
return m_hMenu;
-#endif
+#endif // __WXWINCE__/!__WXWINCE__
}
int wxMenuBar::MSWPositionForWxMenu(wxMenu *menu, int wxpos)
Refresh();
}
-void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
+void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label)
{
wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") );
Refresh();
}
-wxString wxMenuBar::GetLabelTop(size_t pos) const
+wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
- wxT("invalid menu index in wxMenuBar::GetLabelTop") );
+ wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
- return wxMenuItem::GetLabelFromText(m_titles[pos]);
+ return m_titles[pos];
}
// ---------------------------------------------------------------------------