ported characters escaping in menus to GTK+ 2.0
(it is now possible to have / in menu entries, unlike in case of GTK+ 1.2; and \ was fixed to work in 2.0) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -117,14 +117,25 @@ static wxString wxReplaceUnderscore( const wxString& title )
|
|||||||
{
|
{
|
||||||
if (*pc == wxT('&'))
|
if (*pc == wxT('&'))
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(1, 2, 1)
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
str << wxT('_');
|
str << wxT('_');
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if GTK_CHECK_VERSION(2, 0, 0)
|
||||||
|
else if (*pc == wxT('/'))
|
||||||
|
{
|
||||||
|
str << wxT("\\/");
|
||||||
|
}
|
||||||
|
else if (*pc == wxT('\\'))
|
||||||
|
{
|
||||||
|
str << wxT("\\\\");
|
||||||
|
}
|
||||||
|
#elif GTK_CHECK_VERSION(1, 2, 0)
|
||||||
else if (*pc == wxT('/'))
|
else if (*pc == wxT('/'))
|
||||||
{
|
{
|
||||||
str << wxT('\\');
|
str << wxT('\\');
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if __WXGTK12__
|
#if __WXGTK12__
|
||||||
@@ -810,20 +821,35 @@ void wxMenuItem::DoSetText( const wxString& str )
|
|||||||
const wxChar *pc = str;
|
const wxChar *pc = str;
|
||||||
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
|
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
|
||||||
{
|
{
|
||||||
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
if (*pc == wxT('&'))
|
if (*pc == wxT('&'))
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(1, 2, 0)
|
|
||||||
m_text << wxT('_');
|
m_text << wxT('_');
|
||||||
}
|
}
|
||||||
else if ( *pc == wxT('_') ) // escape underscores
|
else if ( *pc == wxT('_') ) // escape underscores
|
||||||
{
|
{
|
||||||
m_text << wxT("__");
|
m_text << wxT("__");
|
||||||
}
|
}
|
||||||
|
#else // GTK+ < 1.2.0
|
||||||
|
if (*pc == wxT('&'))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if GTK_CHECK_VERSION(2, 0, 0)
|
||||||
|
else if (*pc == wxT('/')) // we have to escape slashes
|
||||||
|
{
|
||||||
|
m_text << wxT("\\/");
|
||||||
|
}
|
||||||
|
else if (*pc == wxT('\\')) // we have to double backslashes
|
||||||
|
{
|
||||||
|
m_text << wxT("\\\\");
|
||||||
|
}
|
||||||
|
#elif GTK_CHECK_VERSION(1, 2, 0)
|
||||||
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
|
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
|
||||||
{
|
{
|
||||||
m_text << wxT('\\'); /* ... and replace them with back slashes */
|
m_text << wxT('\\'); /* ... and replace them with back slashes */
|
||||||
#endif // GTK+ 1.2.0+
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
m_text << *pc;
|
m_text << *pc;
|
||||||
}
|
}
|
||||||
|
@@ -117,14 +117,25 @@ static wxString wxReplaceUnderscore( const wxString& title )
|
|||||||
{
|
{
|
||||||
if (*pc == wxT('&'))
|
if (*pc == wxT('&'))
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(1, 2, 1)
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
str << wxT('_');
|
str << wxT('_');
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if GTK_CHECK_VERSION(2, 0, 0)
|
||||||
|
else if (*pc == wxT('/'))
|
||||||
|
{
|
||||||
|
str << wxT("\\/");
|
||||||
|
}
|
||||||
|
else if (*pc == wxT('\\'))
|
||||||
|
{
|
||||||
|
str << wxT("\\\\");
|
||||||
|
}
|
||||||
|
#elif GTK_CHECK_VERSION(1, 2, 0)
|
||||||
else if (*pc == wxT('/'))
|
else if (*pc == wxT('/'))
|
||||||
{
|
{
|
||||||
str << wxT('\\');
|
str << wxT('\\');
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if __WXGTK12__
|
#if __WXGTK12__
|
||||||
@@ -810,20 +821,35 @@ void wxMenuItem::DoSetText( const wxString& str )
|
|||||||
const wxChar *pc = str;
|
const wxChar *pc = str;
|
||||||
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
|
for (; (*pc != wxT('\0')) && (*pc != wxT('\t')); pc++ )
|
||||||
{
|
{
|
||||||
|
#if GTK_CHECK_VERSION(1, 2, 0)
|
||||||
if (*pc == wxT('&'))
|
if (*pc == wxT('&'))
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(1, 2, 0)
|
|
||||||
m_text << wxT('_');
|
m_text << wxT('_');
|
||||||
}
|
}
|
||||||
else if ( *pc == wxT('_') ) // escape underscores
|
else if ( *pc == wxT('_') ) // escape underscores
|
||||||
{
|
{
|
||||||
m_text << wxT("__");
|
m_text << wxT("__");
|
||||||
}
|
}
|
||||||
|
#else // GTK+ < 1.2.0
|
||||||
|
if (*pc == wxT('&'))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if GTK_CHECK_VERSION(2, 0, 0)
|
||||||
|
else if (*pc == wxT('/')) // we have to escape slashes
|
||||||
|
{
|
||||||
|
m_text << wxT("\\/");
|
||||||
|
}
|
||||||
|
else if (*pc == wxT('\\')) // we have to double backslashes
|
||||||
|
{
|
||||||
|
m_text << wxT("\\\\");
|
||||||
|
}
|
||||||
|
#elif GTK_CHECK_VERSION(1, 2, 0)
|
||||||
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
|
else if (*pc == wxT('/')) /* we have to filter out slashes ... */
|
||||||
{
|
{
|
||||||
m_text << wxT('\\'); /* ... and replace them with back slashes */
|
m_text << wxT('\\'); /* ... and replace them with back slashes */
|
||||||
#endif // GTK+ 1.2.0+
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
m_text << *pc;
|
m_text << *pc;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user