X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/598d8cacefaa185a962ebc39d31533410692c56b..cc6dd35581586950ebcf7ef4493166001ec5a645:/src/os2/menuitem.cpp diff --git a/src/os2/menuitem.cpp b/src/os2/menuitem.cpp index 574fea6166..91c6e9d975 100644 --- a/src/os2/menuitem.cpp +++ b/src/os2/menuitem.cpp @@ -58,35 +58,43 @@ // static function for translating menu labels // ---------------------------------------------------------------------------- -static wxString TextToLabel(const wxString& rTitle) +static wxString TextToLabel( + const wxString& rsTitle +) { - wxString Title; - const wxChar *pc; - for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ ) + wxString sTitle; + const wxChar* zPc; + + if (rsTitle.IsEmpty()) + return(sTitle); + + for (zPc = rsTitle.c_str(); *zPc != wxT('\0'); zPc++) { - if (*pc == wxT('&') ) + if (*zPc == wxT('&')) { - if (*(pc+1) == wxT('&')) + if (*(zPc + 1) == wxT('&')) { - pc++; - Title << wxT('&'); + zPc++; + sTitle << wxT('&'); } else - Title << wxT('~'); + sTitle << wxT('~'); } else { - if ( *pc == wxT('~') ) + if ( *zPc == wxT('~')) { - // tildes must be doubled to prevent them from being + // + // Tildes must be doubled to prevent them from being // interpreted as accelerator character prefix by PM ??? - Title << *pc; + // + sTitle << *zPc; } - Title << *pc; + sTitle << *zPc; } } - return Title; -} + return(sTitle); +} // end of TextToLabel // ============================================================================ // implementation @@ -127,6 +135,8 @@ wxMenuItem::wxMenuItem( #endif // owner drawn { wxASSERT_MSG(pParentMenu != NULL, wxT("a menu item should have a parent")); + memset(&m_vMenuData, '\0', sizeof(m_vMenuData)); + m_vMenuData.id = (USHORT)nId; Init(); } // end of wxMenuItem::wxMenuItem @@ -173,12 +183,11 @@ void wxMenuItem::Init() SetTextColour(SYS_COLOR(MENUTEXT)); SetBackgroundColour(SYS_COLOR(MENU)); - #undef SYS_COLOR - // // We don't want normal items be owner-drawn // ResetOwnerDrawn(); + #undef SYS_COLOR // // Tell the owner drawing code to to show the accel string as well @@ -218,23 +227,25 @@ bool wxMenuItem::IsChecked() const } // end of wxMenuItem::IsChecked wxString wxMenuItemBase::GetLabelFromText( - const wxString& rText + const wxString& rsText ) { - wxString label; - for ( const wxChar *pc = rText.c_str(); *pc; pc++ ) + wxString sLabel; + + for (const char* zPc = rsText.c_str(); *zPc; zPc++) { - if ( *pc == wxT('~') || *pc == wxT('&') ) + if (*zPc == wxT('~') || *zPc == wxT('&')) { - // '~' is the escape character for GTK+ and '&' is the one for + // + // '~' is the escape character for OS/2PM and '&' is the one for // wxWindows - skip both of them + // continue; } - - label += *pc; + sLabel += *zPc; } - return label; -} + return sLabel; +} // end of wxMenuItemBase::GetLabelFromText // // Radio group stuff @@ -412,6 +423,9 @@ void wxMenuItem::SetText( wxMenuItemBase::SetText(sText); OWNER_DRAWN_ONLY(wxOwnerDrawn::SetName(sText)); +#if wxUSE_OWNER_DRAWN + SetAccelString(rText.AfterFirst(_T('\t'))); +#endif // wxUSE_OWNER_DRAWN HWND hMenu = GetHmenuOf(m_parentMenu);