#include "wx/fontutil.h"
#include "wx/gtk/win_gtk.h"
+#include "wx/gtk/private.h"
#include "wx/math.h" // for floating-point functions
bool underlined = m_font.Ok() && m_font.GetUnderlined();
-#if wxUSE_UNICODE
- const wxCharBuffer data = wxConvUTF8.cWC2MB( text );
-#else
- const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text );
- if ( !wdata )
+ const wxCharBuffer data = wxGTK_CONV( text );
+ if ( !data )
return;
- const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
-#endif
- size_t datalen = strlen((const char*)data);
- pango_layout_set_text( m_layout, (const char*) data, datalen);
+ const size_t datalen = strlen(data);
+ pango_layout_set_text( m_layout, data, datalen);
if (underlined)
{
pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description );
// Set layout's text
-#if wxUSE_UNICODE
- const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
- const char *dataUTF8 = (const char *)data;
-#else
- const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string );
- if ( !wdata )
- return;
-
- const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
- const char *dataUTF8 = (const char *)data;
-#endif
-
+ const wxCharBuffer dataUTF8 = wxGTK_CONV(string);
if ( !dataUTF8 )
{
// hardly ideal, but what else can we do if conversion failed?
gtk_text_buffer_get_end_iter( m_buffer, &end );
gchar *text = gtk_text_buffer_get_text( m_buffer, &start, &end, TRUE );
-#if wxUSE_UNICODE
- wxWCharBuffer buffer( wxConvUTF8.cMB2WX( text ) );
-#else
- wxCharBuffer buffer( wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC( text ) ) );
-#endif
- if ( buffer )
- tmp = buffer;
+ const wxWxCharBuffer buf = wxGTK_CONV_BACK(text);
+ if ( buf )
+ tmp = buf;
g_free( text );
}
else
{
- tmp = wxGTK_CONV_BACK( gtk_entry_get_text( GTK_ENTRY(m_text) ) );
+ const gchar *text = gtk_entry_get_text( GTK_ENTRY(m_text) );
+ const wxWxCharBuffer buf = wxGTK_CONV_BACK( text );
+ if ( buf )
+ tmp = buf;
}
return tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
-#if wxUSE_UNICODE
- wxCharBuffer buffer( wxConvUTF8.cWX2MB( value) );
-#else
- wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( value ) ) );
-#endif
- if (gtk_text_buffer_get_char_count(m_buffer) != 0)
- IgnoreNextTextUpdate();
-
+ const wxCharBuffer buffer(wxGTK_CONV(value));
if ( !buffer )
{
// what else can we do? at least don't crash...
return;
}
+ if (gtk_text_buffer_get_char_count(m_buffer) != 0)
+ IgnoreNextTextUpdate();
+
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
}
else
if ( text.empty() )
return;
+ const wxCharBuffer buffer(wxGTK_CONV(text));
+ if ( !buffer )
+ {
+ // what else can we do? at least don't crash...
+ return;
+ }
+
// gtk_text_changed_callback() will set m_modified to true but m_modified
// shouldn't be changed by the program writing to the text control itself,
// so save the old value and restore when we're done
if ( m_windowStyle & wxTE_MULTILINE )
{
-#if wxUSE_UNICODE
- wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
-#else
- wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
-#endif
- if ( !buffer )
- {
- // what else can we do? at least don't crash...
- return;
- }
-
// TODO: Call whatever is needed to delete the selection.
wxGtkTextInsert( m_text, m_buffer, m_defaultStyle, buffer );
// This moves the cursor pos to behind the inserted text.
gint len = gtk_editable_get_position(GTK_EDITABLE(m_text));
-#if wxUSE_UNICODE
- wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
-#else
- wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
-#endif
- if ( !buffer )
- {
- // what else can we do? at least don't crash...
- return;
- }
-
gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len );
// Bring entry's cursor uptodate.
window, window->m_imData->lastKeyEvent);
}
-#if wxUSE_UNICODE
- const wxWCharBuffer data = wxConvUTF8.cMB2WC( (char*)str );
-#else
- const wxWCharBuffer wdata = wxConvUTF8.cMB2WC( (char*)str );
- const wxCharBuffer data = wxConvLocal.cWC2MB( wdata );
-#endif // wxUSE_UNICODE
- if( !(const wxChar*)data )
+ const wxWxCharBuffer data(wxGTK_CONV_BACK(str));
+ if( !data )
return;
bool ret = false;
PangoLayout *layout = pango_layout_new(context);
pango_layout_set_font_description(layout, desc);
{
-#if wxUSE_UNICODE
- const wxCharBuffer data = wxConvUTF8.cWC2MB( string );
- pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
-#else
- const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string );
- const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata );
- pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data ));
-#endif
+ const wxCharBuffer data = wxGTK_CONV( string );
+ if ( data )
+ pango_layout_set_text(layout, data, strlen(data));
}
PangoRectangle rect;