#define OWNER_DRAWN_ONLY( code )
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
+// ----------------------------------------------------------------------------
+// static function for translating menu labels
+// ----------------------------------------------------------------------------
+
+static wxString TextToLabel(const wxString& rTitle)
+{
+ wxString Title;
+ const wxChar *pc;
+ for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
+ {
+ if (*pc == wxT('&') )
+ {
+ if (*(pc+1) == wxT('&'))
+ {
+ pc++;
+ Title << wxT('&');
+ }
+ else
+ Title << wxT('~');
+ }
+ else
+ {
+ if ( *pc == wxT('~') )
+ {
+ // tildes must be doubled to prevent them from being
+ // interpreted as accelerator character prefix by PM ???
+ Title << *pc;
+ }
+ Title << *pc;
+ }
+ }
+ return Title;
+}
+
// ============================================================================
// implementation
// ============================================================================
// dynamic classes implementation
// ----------------------------------------------------------------------------
- #if wxUSE_OWNER_DRAWN
- IMPLEMENT_DYNAMIC_CLASS2(wxMenuItem, wxMenuItemBase, wxOwnerDrawn)
- #else //!USE_OWNER_DRAWN
- IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxMenuItemBase)
- #endif //USE_OWNER_DRAWN
+IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
// ----------------------------------------------------------------------------
// wxMenuItem
, int nId
, const wxString& rText
, const wxString& rStrHelp
-, bool bCheckable
+, wxItemKind kind
, wxMenu* pSubMenu
)
+: wxMenuItemBase(pParentMenu, nId, rText, rStrHelp, kind, pSubMenu)
#if wxUSE_OWNER_DRAWN
-: wxOwnerDrawn( rText
+, wxOwnerDrawn( TextToLabel(rText)
,bCheckable
)
#endif // owner drawn
//
// Set default menu colors
//
- #define SYS_COLOR(c) (wxSystemSettings::GetSystemColour(wxSYS_COLOUR_##c))
+ #define SYS_COLOR(c) (wxSystemSettings::GetColour(wxSYS_COLOUR_##c))
SetTextColour(SYS_COLOR(MENUTEXT));
SetBackgroundColour(SYS_COLOR(MENU));
#undef SYS_COLOR
#endif // wxUSE_OWNER_DRAWN
- m_parentMenu = pParentMenu;
- m_subMenu = pSubMenu;
- m_isEnabled = TRUE;
- m_isChecked = FALSE;
- m_id = nId;
- m_text = rText;
- m_isCheckable = bCheckable;
- m_help = rStrHelp;
+ m_text = TextToLabel(rText);
+
+ memset(&m_vMenuData, '\0', sizeof(m_vMenuData));
+ m_vMenuData.id= nId;
} // end of wxMenuItem::wxMenuItem
wxMenuItem::~wxMenuItem()
const wxString& rText
)
{
- return wxStripMenuCodes(rText);
-}
-
-// accelerators
-// ------------
-
-#if wxUSE_ACCEL
+ wxString label;
+ for ( const wxChar *pc = rText.c_str(); *pc; pc++ )
+ {
+ if ( *pc == wxT('~') || *pc == wxT('&') )
+ {
+ // '~' is the escape character for GTK+ and '&' is the one for
+ // wxWindows - skip both of them
+ continue;
+ }
-wxAcceleratorEntry *wxMenuItem::GetAccel() const
-{
- return wxGetAccelFromString(GetText());
+ label += *pc;
+ }
+ return label;
}
-#endif // wxUSE_ACCEL
-
// change item state
// -----------------
bOk = (bool)::WinSendMsg( GetHMenuOf(m_parentMenu)
,MM_SETITEMATTR
,MPFROM2SHORT(GetRealId(), TRUE)
- ,MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED)
+ ,MPFROM2SHORT(MIA_DISABLED, FALSE)
);
else
bOk = (bool)::WinSendMsg( GetHMenuOf(m_parentMenu)
,MM_SETITEMATTR
,MPFROM2SHORT(GetRealId(), TRUE)
- ,MPFROM2SHORT(MIA_DISABLED, FALSE)
+ ,MPFROM2SHORT(MIA_DISABLED, MIA_DISABLED)
);
if (!bOk)
{
{
bool bOk;
- wxCHECK_RET( m_isCheckable, wxT("only checkable items may be checked") );
+ wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") );
if (m_isChecked == bCheck)
return;
if (bCheck)
);
if (!bOk)
{
- wxLogLastError("EnableMenuItem");
+ wxLogLastError("CheckMenuItem");
}
wxMenuItemBase::Check(bCheck);
} // end of wxMenuItem::Check
//
// Don't do anything if label didn't change
//
- if (m_text == rText)
+
+ wxString Text = TextToLabel(rText);
+ if (m_text == Text)
return;
- wxMenuItemBase::SetText(rText);
- OWNER_DRAWN_ONLY(wxOwnerDrawn::SetName(rText));
+ wxMenuItemBase::SetText(Text);
+ OWNER_DRAWN_ONLY(wxOwnerDrawn::SetName(Text));
HWND hMenu = GetHMenuOf(m_parentMenu);
#endif //owner drawn
{
uFlagsOld |= MIS_TEXT;
- pData = (BYTE*)rText.c_str();
+ pData = (BYTE*)Text.c_str();
}
//
, int nId
, const wxString& rName
, const wxString& rHelp
-, bool bIsCheckable
+, wxItemKind kind
, wxMenu* pSubMenu
)
{
,nId
,rName
,rHelp
- ,bIsCheckable
+ ,kind
,pSubMenu
);
} // end of wxMenuItemBase::New