Support encodings in wxGTK_CONV_BACK() in the same way as we do it in
wxGTK_CONV(), i.e. return the string containing text in ISO-8859-1 encoding and not UTF-8 if the controls font was set to have ISO-8859-1 encoding git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44577 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -28,15 +28,23 @@
|
|||||||
#define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
|
#define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
|
||||||
#define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
|
#define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
|
||||||
#define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
|
#define wxGTK_CONV_SYS(s) wxGTK_CONV((s))
|
||||||
|
|
||||||
#define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX((s))
|
#define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX((s))
|
||||||
|
#define wxGTK_CONV_BACK_ENC(s, enc) wxGTK_CONV_BACK(s)
|
||||||
|
#define wxGTK_CONV_BACK_FONT(s, font) wxGTK_CONV_BACK(s)
|
||||||
|
#define wxGTK_CONV_BACK_SYS(s) wxGTK_CONV_BACK(s)
|
||||||
#else
|
#else
|
||||||
#include "wx/font.h"
|
#include "wx/font.h"
|
||||||
|
|
||||||
// convert the text in given encoding to UTF-8 used by wxGTK
|
// convert the text between the given encoding and UTF-8 used by wxGTK
|
||||||
extern wxCharBuffer
|
extern wxCharBuffer
|
||||||
wxConvertToGTK(const wxString& s,
|
wxConvertToGTK(const wxString& s,
|
||||||
wxFontEncoding enc = wxFONTENCODING_SYSTEM);
|
wxFontEncoding enc = wxFONTENCODING_SYSTEM);
|
||||||
|
|
||||||
|
extern wxCharBuffer
|
||||||
|
wxConvertFromGTK(const wxString& s,
|
||||||
|
wxFontEncoding enc = wxFONTENCODING_SYSTEM);
|
||||||
|
|
||||||
// helper: use the encoding of the given font if it's valid
|
// helper: use the encoding of the given font if it's valid
|
||||||
inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
|
inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
|
||||||
{
|
{
|
||||||
@@ -44,11 +52,35 @@
|
|||||||
: wxFONTENCODING_SYSTEM);
|
: wxFONTENCODING_SYSTEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline wxCharBuffer wxConvertFromGTK(const wxString& s, const wxFont& font)
|
||||||
|
{
|
||||||
|
return wxConvertFromGTK(s, font.Ok() ? font.GetEncoding()
|
||||||
|
: wxFONTENCODING_SYSTEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
// more helpers: allow passing GTK+ strings directly
|
||||||
|
inline wxCharBuffer
|
||||||
|
wxConvertFromGTK(const wxGtkString& gs,
|
||||||
|
wxFontEncoding enc = wxFONTENCODING_SYSTEM)
|
||||||
|
{
|
||||||
|
return wxConvertFromGTK(gs.c_str(), enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wxCharBuffer
|
||||||
|
wxConvertFromGTK(const wxGtkString& gs, const wxFont& font)
|
||||||
|
{
|
||||||
|
return wxConvertFromGTK(gs.c_str(), font);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
|
||||||
#define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
|
#define wxGTK_CONV_ENC(s, enc) wxConvertToGTK((s), (enc))
|
||||||
#define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
|
#define wxGTK_CONV_FONT(s, font) wxConvertToGTK((s), (font))
|
||||||
#define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font)
|
|
||||||
#define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
|
#define wxGTK_CONV_SYS(s) wxConvertToGTK((s))
|
||||||
#define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX(wxConvUTF8.cMB2WC((s)))
|
|
||||||
|
#define wxGTK_CONV_BACK(s) wxConvertFromGTK((s), m_font)
|
||||||
|
#define wxGTK_CONV_BACK_ENC(s, enc) wxConvertFromGTK((s), (enc))
|
||||||
|
#define wxGTK_CONV_BACK_FONT(s, font) wxConvertFromGTK((s), (font))
|
||||||
|
#define wxGTK_CONV_BACK_SYS(s) wxConvertFromGTK((s))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Some deprecated GTK+ prototypes we still use often
|
// Some deprecated GTK+ prototypes we still use often
|
||||||
|
@@ -93,7 +93,7 @@ wxGtkAboutDialogOnLink(GtkAboutDialog * WXUNUSED(about),
|
|||||||
const gchar *link,
|
const gchar *link,
|
||||||
gpointer WXUNUSED(data))
|
gpointer WXUNUSED(data))
|
||||||
{
|
{
|
||||||
wxLaunchDefaultBrowser(wxGTK_CONV_BACK(link));
|
wxLaunchDefaultBrowser(wxGTK_CONV_BACK_SYS(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAboutBox(const wxAboutDialogInfo& info)
|
void wxAboutBox(const wxAboutDialogInfo& info)
|
||||||
|
@@ -201,7 +201,7 @@ void wxFontRefData::InitFromNative()
|
|||||||
PangoFontDescription *desc = m_nativeFontInfo.description;
|
PangoFontDescription *desc = m_nativeFontInfo.description;
|
||||||
|
|
||||||
// init fields
|
// init fields
|
||||||
m_faceName = wxGTK_CONV_BACK( pango_font_description_get_family( desc ) );
|
m_faceName = wxGTK_CONV_BACK_SYS(pango_font_description_get_family(desc));
|
||||||
|
|
||||||
// Pango sometimes needs to have a size
|
// Pango sometimes needs to have a size
|
||||||
int pango_size = pango_font_description_get_size( desc );
|
int pango_size = pango_font_description_get_size( desc );
|
||||||
|
@@ -1547,8 +1547,9 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
|
|||||||
default:
|
default:
|
||||||
if ( code < 127 )
|
if ( code < 127 )
|
||||||
{
|
{
|
||||||
wxString name = wxGTK_CONV_BACK( gdk_keyval_name((guint)code) );
|
const wxString
|
||||||
if ( name )
|
name = wxGTK_CONV_BACK_SYS(gdk_keyval_name((guint)code));
|
||||||
|
if ( !name.empty() )
|
||||||
{
|
{
|
||||||
hotkey << name;
|
hotkey << name;
|
||||||
break;
|
break;
|
||||||
|
@@ -209,6 +209,17 @@ wxCharBuffer wxConvertToGTK(const wxString& s, wxFontEncoding enc)
|
|||||||
return wxConvUTF8.cWC2MB(wbuf);
|
return wxConvUTF8.cWC2MB(wbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxCharBuffer wxConvertFromGTK(const wxString& s, wxFontEncoding enc)
|
||||||
|
{
|
||||||
|
// this conversion should never fail as GTK+ always uses UTF-8 internally
|
||||||
|
// so there are no complications here
|
||||||
|
const wxWCharBuffer wbuf(wxConvUTF8.cMB2WC(s));
|
||||||
|
if ( enc == wxFONTENCODING_SYSTEM )
|
||||||
|
return wxConvUI->cWC2MB(wbuf);
|
||||||
|
|
||||||
|
return wxCSConv(enc).cWC2MB(wbuf);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // !wxUSE_UNICODE
|
#endif // !wxUSE_UNICODE
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -1158,7 +1158,7 @@ gtk_wxwindow_commit_cb (GtkIMContext *context,
|
|||||||
window, window->m_imData->lastKeyEvent);
|
window, window->m_imData->lastKeyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxWxCharBuffer data(wxGTK_CONV_BACK(str));
|
const wxWxCharBuffer data(wxGTK_CONV_BACK_SYS(str));
|
||||||
if( !data )
|
if( !data )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2137,16 +2137,11 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
if ((client_width == win->m_oldClientWidth) && (client_height == win->m_oldClientHeight))
|
if ((client_width == win->m_oldClientWidth) && (client_height == win->m_oldClientHeight))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if 0
|
if ( !client_width && !client_height )
|
||||||
wxPrintf( wxT("size_allocate ") );
|
{
|
||||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
// the window is currently unmapped, don't generate size events
|
||||||
wxPrintf( win->GetClassInfo()->GetClassName() );
|
return;
|
||||||
wxPrintf( wxT(" %d %d %d %d\n"),
|
}
|
||||||
alloc->x,
|
|
||||||
alloc->y,
|
|
||||||
alloc->width,
|
|
||||||
alloc->height );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
win->m_oldClientWidth = client_width;
|
win->m_oldClientWidth = client_width;
|
||||||
win->m_oldClientHeight = client_height;
|
win->m_oldClientHeight = client_height;
|
||||||
|
@@ -136,9 +136,7 @@ bool wxNativeFontInfo::GetUnderlined() const
|
|||||||
|
|
||||||
wxString wxNativeFontInfo::GetFaceName() const
|
wxString wxNativeFontInfo::GetFaceName() const
|
||||||
{
|
{
|
||||||
wxString tmp = wxGTK_CONV_BACK( pango_font_description_get_family( description ) );
|
return wxGTK_CONV_BACK_SYS(pango_font_description_get_family(description));
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontFamily wxNativeFontInfo::GetFamily() const
|
wxFontFamily wxNativeFontInfo::GetFamily() const
|
||||||
@@ -327,7 +325,7 @@ wxString wxNativeFontInfo::ToString() const
|
|||||||
{
|
{
|
||||||
wxGtkString str(pango_font_description_to_string( description ));
|
wxGtkString str(pango_font_description_to_string( description ));
|
||||||
|
|
||||||
return wxGTK_CONV_BACK(str);
|
return wxGTK_CONV_BACK_SYS(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxNativeFontInfo::FromUserString(const wxString& s)
|
bool wxNativeFontInfo::FromUserString(const wxString& s)
|
||||||
|
Reference in New Issue
Block a user