]> git.saurik.com Git - wxWidgets.git/commitdiff
Support encodings in wxGTK_CONV_BACK() in the same way as we do it in
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 27 Feb 2007 15:41:56 +0000 (15:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 27 Feb 2007 15:41:56 +0000 (15:41 +0000)
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

include/wx/gtk/private.h
src/gtk/aboutdlg.cpp
src/gtk/font.cpp
src/gtk/menu.cpp
src/gtk/utilsgtk.cpp
src/gtk/window.cpp
src/unix/fontutil.cpp

index 7352f87369905e4896f4c2151e9d110d624591a7..d5afceb68ed5735616d1c5866dd161888411f8b0 100644 (file)
     #define wxGTK_CONV_ENC(s, enc) wxGTK_CONV((s))
     #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s))
     #define wxGTK_CONV_SYS(s) wxGTK_CONV((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
     #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
     wxConvertToGTK(const wxString& s,
                    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
     inline wxCharBuffer wxConvertToGTK(const wxString& s, const wxFont& font)
     {
                                            : 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_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_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
 
 // Some deprecated GTK+ prototypes we still use often
index b6d960990b6298c59d163986967ed7215a239de8..d8058f0336f5bbc8ae1fb6a9164188930aee0fa9 100644 (file)
@@ -93,7 +93,7 @@ wxGtkAboutDialogOnLink(GtkAboutDialog * WXUNUSED(about),
                        const gchar *link,
                        gpointer WXUNUSED(data))
 {
-    wxLaunchDefaultBrowser(wxGTK_CONV_BACK(link));
+    wxLaunchDefaultBrowser(wxGTK_CONV_BACK_SYS(link));
 }
 
 void wxAboutBox(const wxAboutDialogInfo& info)
index e355db0f1c7dbfe822772cb7d72fbefe8f0a5f30..11e7b20c644e18e6132feaad0097a991be110154 100644 (file)
@@ -201,7 +201,7 @@ void wxFontRefData::InitFromNative()
     PangoFontDescription *desc = m_nativeFontInfo.description;
 
     // 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
     int pango_size = pango_font_description_get_size( desc );
index 7f4d87855ddfec40c5d8444d1dc961f3638cffc9..78539a50de79a6e59a803f3b4afd2b7dae1e0007 100644 (file)
@@ -1547,8 +1547,9 @@ static wxString GetGtkHotKey( const wxMenuItem& item )
             default:
                 if ( code < 127 )
                 {
-                    wxString name = wxGTK_CONV_BACK( gdk_keyval_name((guint)code) );
-                    if ( name )
+                    const wxString
+                        name = wxGTK_CONV_BACK_SYS(gdk_keyval_name((guint)code));
+                    if ( !name.empty() )
                     {
                         hotkey << name;
                         break;
index 72757f441ba6560126389d28288dad429e9ed7af..698225a0beb75acad1a38317df6c00a6ce5dc1a3 100644 (file)
@@ -209,6 +209,17 @@ wxCharBuffer wxConvertToGTK(const wxString& s, wxFontEncoding enc)
     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
 
 // ----------------------------------------------------------------------------
index dd6be8cf368ad8fbe93b045e2e5c1b345df0f843..a9a67e6c68631b9443f1711583d603a51230490a 100644 (file)
@@ -1158,7 +1158,7 @@ gtk_wxwindow_commit_cb (GtkIMContext *context,
                                   window, window->m_imData->lastKeyEvent);
     }
 
-    const wxWxCharBuffer data(wxGTK_CONV_BACK(str));
+    const wxWxCharBuffer data(wxGTK_CONV_BACK_SYS(str));
     if( !data )
         return;
 
@@ -2137,16 +2137,11 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
     if ((client_width == win->m_oldClientWidth) && (client_height == win->m_oldClientHeight))
         return;
 
-#if 0
-        wxPrintf( wxT("size_allocate ") );
-        if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
-            wxPrintf( win->GetClassInfo()->GetClassName() );
-        wxPrintf( wxT(" %d %d %d %d\n"),
-                alloc->x,
-                alloc->y,
-                alloc->width,
-                alloc->height );
-#endif
+    if ( !client_width && !client_height )
+    {
+        // the window is currently unmapped, don't generate size events
+        return;
+    }
 
     win->m_oldClientWidth = client_width;
     win->m_oldClientHeight = client_height;
index d9eab1961d637261a56273c791307f12a778b2ab..1a19014406575fc04a86e42b3f419fda4deac777 100644 (file)
@@ -136,9 +136,7 @@ bool wxNativeFontInfo::GetUnderlined() const
 
 wxString wxNativeFontInfo::GetFaceName() const
 {
-    wxString tmp = wxGTK_CONV_BACK( pango_font_description_get_family( description ) );
-
-    return tmp;
+    return wxGTK_CONV_BACK_SYS(pango_font_description_get_family(description));
 }
 
 wxFontFamily wxNativeFontInfo::GetFamily() const
@@ -327,7 +325,7 @@ wxString wxNativeFontInfo::ToString() const
 {
     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)