wxGTK:
+- Fixed handling of font encoding in non-Unicode build
- wxEVT_MENU_CLOSE and wxEVT_MENU_OPENED for popup menus are now generated.
- Implemented wxCURSOR_BLANK support.
- wxSlider generates all scroll events now and not only wxEVT_SCROLL_THUMBTRACK.
#if wxUSE_UNICODE
#define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s)
+ #define wxGTK_CONV_SYS(s, enc) wxGTK_CONV(s)
#define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s)
#else
- #define wxGTK_CONV(s) wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC(s) )
- #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX( (wxConvUTF8.cMB2WC( s ) ) )
+ // convert the text in given encoding to UTF-8 used by wxGTK
+ extern wxCharBuffer
+ wxConvertToGTK(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)
+ {
+ return wxConvertToGTK(s, font.Ok() ? font.GetEncoding()
+ : wxFONTENCODING_SYSTEM);
+ }
+
+ #define wxGTK_CONV(s) wxConvertToGTK((s), m_font)
+ #define wxGTK_CONV_SYS(s) wxConvertToGTK(s)
+ #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC((s)) )
#endif
// Some deprecated GTK+ prototypes we still use often
wxColour col;
GdkColor colGDK;
- if ( gdk_color_parse( wxGTK_CONV( name ), &colGDK ) )
+ if ( gdk_color_parse( wxGTK_CONV_SYS( name ), &colGDK ) )
{
wxColourRefData *refData = new wxColourRefData;
refData->m_color = colGDK;
m_weight;
bool m_underlined;
wxString m_faceName;
- wxFontEncoding m_encoding; // Unused under GTK 2.0
+ wxFontEncoding m_encoding;
bool m_noAA; // No anti-aliasing
// The native font info, basicly an XFLD under GTK 1.2 and
// And set its values
if (!m_faceName.empty())
{
- pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV(m_faceName) );
+ pango_font_description_set_family( m_nativeFontInfo.description,
+ wxGTK_CONV_SYS(m_faceName) );
}
else
{
// Pango description are never underlined (?)
m_underlined = FALSE;
- // Cannot we choose that
- m_encoding = wxFONTENCODING_SYSTEM;
+ // always with GTK+ 2
+ m_encoding = wxFONTENCODING_UTF8;
}
wxFontRefData::wxFontRefData( const wxFontRefData& data )
wxFontEncoding wxFont::GetEncoding() const
{
- wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
+ wxCHECK_MSG( Ok(), wxFONTENCODING_SYSTEM, wxT("invalid font") );
- // m_encoding is unused in wxGTK2, return encoding that the user set.
return M_FONTDATA->m_encoding;
}
bool wxFont::GetNoAntiAliasing() const
{
- wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->m_noAA;
}
oldLabel.Replace(wxT("_"), wxT(""));
wxString label1 = wxStripMenuCodes(str);
wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format
- wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo
+ wxCharBuffer oldbuf = wxGTK_CONV_SYS( GetGtkHotKey(*this) ); // and as <control>foo
DoSetText(str);
else
label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
- gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(m_text) );
+ gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV_SYS(m_text) );
}
guint accel_key;
accel_mods );
}
- wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*this) );
+ wxCharBuffer buf = wxGTK_CONV_SYS( GetGtkHotKey(*this) );
gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
if (accel_key != 0)
{
text = mitem->GetText();
const wxBitmap *bitmap = &mitem->GetBitmap();
- menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+ menuItem = gtk_image_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
GtkWidget *image;
if (bitmap->HasPixbuf())
{
case wxITEM_CHECK:
{
- menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+ menuItem = gtk_check_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
m_prevRadio = NULL;
break;
}
if ( m_prevRadio == NULL )
{
// start of a new radio group
- m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
+ m_prevRadio = menuItem =
+ gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV_SYS( text ) );
}
else // continue the radio group
{
group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (m_prevRadio));
- m_prevRadio = menuItem = gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV( text ) );
+ m_prevRadio = menuItem =
+ gtk_radio_menu_item_new_with_mnemonic( group, wxGTK_CONV_SYS( text ) );
}
break;
}
case wxITEM_NORMAL:
{
- menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV( text ) );
+ menuItem = gtk_menu_item_new_with_mnemonic( wxGTK_CONV_SYS( text ) );
m_prevRadio = NULL;
break;
}
guint accel_key;
GdkModifierType accel_mods;
- wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*mitem) );
+ wxCharBuffer buf = wxGTK_CONV_SYS( GetGtkHotKey(*mitem) );
// wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetText().c_str(), GetGtkHotKey(*mitem).c_str() );
gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods);
return wxGenericFindWindowAtPoint(pt);
}
+#if !wxUSE_UNICODE
+
+wxCharBuffer wxConvertToGTK(const wxString& s, wxFontEncoding enc)
+{
+ if ( enc == wxFONTENCODING_UTF8 )
+ {
+ // no need for conversion at all
+ return wxCharBuffer(s);
+ }
+
+ const wxWCharBuffer wbuf = wxCSConv(enc).cMB2WC(s);
+ wxCharBuffer buf;
+ if ( wbuf )
+ buf = wxConvUTF8.cWC2MB(wbuf);
+
+ return buf;
+}
+
+#endif // !wxUSE_UNICODE
// ----------------------------------------------------------------------------
// subprocess routines
void wxNativeFontInfo::SetFaceName(const wxString& facename)
{
- pango_font_description_set_family( description, wxGTK_CONV(facename) );
+ pango_font_description_set_family(description, wxGTK_CONV_SYS(facename));
}
void wxNativeFontInfo::SetFamily(wxFontFamily WXUNUSED(family))
if (description)
pango_font_description_free( description );
- description = pango_font_description_from_string( wxGTK_CONV( s ) );
+ description = pango_font_description_from_string( wxGTK_CONV_SYS( s ) );
return true;
}