MBCS and IM fixes (patch 1016292)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29019 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1337,24 +1337,13 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
event.m_uniChar = g_utf8_get_char( str );
|
const wxWCharBuffer data = wxConvUTF8.cMB2WC( (char*)str );
|
||||||
|
|
||||||
// Backward compatible for ISO-8859
|
|
||||||
if (event.m_uniChar < 256)
|
|
||||||
event.m_keyCode = event.m_uniChar;
|
|
||||||
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar);
|
|
||||||
#else
|
#else
|
||||||
wchar_t unistr[2];
|
const wxWCharBuffer wdata = wxConvUTF8.cMB2WC( (char*)str );
|
||||||
unistr[0] = g_utf8_get_char(str);
|
const wxCharBuffer data = wxConvLocal.cWC2MB( wdata );
|
||||||
unistr[1] = 0;
|
|
||||||
wxCharBuffer ansistr(wxConvLocal.cWC2MB(unistr));
|
|
||||||
// We cannot handle characters that cannot be represented in
|
|
||||||
// current locale's charset in non-Unicode mode:
|
|
||||||
if (ansistr.data() == NULL)
|
|
||||||
return;
|
|
||||||
event.m_keyCode = ansistr[0u];
|
|
||||||
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), (wxChar)event.m_keyCode);
|
|
||||||
#endif // wxUSE_UNICODE
|
#endif // wxUSE_UNICODE
|
||||||
|
if( !(const wxChar*)data )
|
||||||
|
return;
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
@@ -1362,6 +1351,17 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
wxWindow *parent = window;
|
wxWindow *parent = window;
|
||||||
while (parent && !parent->IsTopLevel())
|
while (parent && !parent->IsTopLevel())
|
||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
|
|
||||||
|
for( const wxChar* pstr = data; *pstr; pstr++ )
|
||||||
|
{
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
event.m_uniChar = *pstr;
|
||||||
|
// Backward compatible for ISO-8859
|
||||||
|
event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0;
|
||||||
|
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar);
|
||||||
|
#else
|
||||||
|
event.m_keyCode = *pstr;
|
||||||
|
#endif // wxUSE_UNICODE
|
||||||
if (parent)
|
if (parent)
|
||||||
{
|
{
|
||||||
event.SetEventType( wxEVT_CHAR_HOOK );
|
event.SetEventType( wxEVT_CHAR_HOOK );
|
||||||
@@ -1373,6 +1373,7 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
event.SetEventType(wxEVT_CHAR);
|
event.SetEventType(wxEVT_CHAR);
|
||||||
ret = window->GetEventHandler()->ProcessEvent( event );
|
ret = window->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -1337,24 +1337,13 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
event.m_uniChar = g_utf8_get_char( str );
|
const wxWCharBuffer data = wxConvUTF8.cMB2WC( (char*)str );
|
||||||
|
|
||||||
// Backward compatible for ISO-8859
|
|
||||||
if (event.m_uniChar < 256)
|
|
||||||
event.m_keyCode = event.m_uniChar;
|
|
||||||
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar);
|
|
||||||
#else
|
#else
|
||||||
wchar_t unistr[2];
|
const wxWCharBuffer wdata = wxConvUTF8.cMB2WC( (char*)str );
|
||||||
unistr[0] = g_utf8_get_char(str);
|
const wxCharBuffer data = wxConvLocal.cWC2MB( wdata );
|
||||||
unistr[1] = 0;
|
|
||||||
wxCharBuffer ansistr(wxConvLocal.cWC2MB(unistr));
|
|
||||||
// We cannot handle characters that cannot be represented in
|
|
||||||
// current locale's charset in non-Unicode mode:
|
|
||||||
if (ansistr.data() == NULL)
|
|
||||||
return;
|
|
||||||
event.m_keyCode = ansistr[0u];
|
|
||||||
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), (wxChar)event.m_keyCode);
|
|
||||||
#endif // wxUSE_UNICODE
|
#endif // wxUSE_UNICODE
|
||||||
|
if( !(const wxChar*)data )
|
||||||
|
return;
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
@@ -1362,6 +1351,17 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
wxWindow *parent = window;
|
wxWindow *parent = window;
|
||||||
while (parent && !parent->IsTopLevel())
|
while (parent && !parent->IsTopLevel())
|
||||||
parent = parent->GetParent();
|
parent = parent->GetParent();
|
||||||
|
|
||||||
|
for( const wxChar* pstr = data; *pstr; pstr++ )
|
||||||
|
{
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
event.m_uniChar = *pstr;
|
||||||
|
// Backward compatible for ISO-8859
|
||||||
|
event.m_keyCode = *pstr < 256 ? event.m_uniChar : 0;
|
||||||
|
wxLogTrace(TRACE_KEYS, _T("IM sent character '%c'"), event.m_uniChar);
|
||||||
|
#else
|
||||||
|
event.m_keyCode = *pstr;
|
||||||
|
#endif // wxUSE_UNICODE
|
||||||
if (parent)
|
if (parent)
|
||||||
{
|
{
|
||||||
event.SetEventType( wxEVT_CHAR_HOOK );
|
event.SetEventType( wxEVT_CHAR_HOOK );
|
||||||
@@ -1373,6 +1373,7 @@ static void gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
event.SetEventType(wxEVT_CHAR);
|
event.SetEventType(wxEVT_CHAR);
|
||||||
ret = window->GetEventHandler()->ProcessEvent( event );
|
ret = window->GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user