Further UNicode fixes.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16525 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -257,7 +257,11 @@ int wxChoice::FindString( const wxString &string ) const
|
|||||||
|
|
||||||
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
||||||
|
|
||||||
wxString tmp( wxGTK_CONV_BACK( label->label ) );
|
#ifdef __WXGTK20__
|
||||||
|
wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
|
||||||
|
#else
|
||||||
|
wxString tmp( label->label );
|
||||||
|
#endif
|
||||||
if (string == tmp)
|
if (string == tmp)
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
@@ -272,8 +276,14 @@ int wxChoice::GetSelection() const
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") );
|
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") );
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
|
||||||
|
return gtk_option_menu_get_history( GTK_OPTION_MENU(m_widget) );
|
||||||
|
|
||||||
|
#else
|
||||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
GList *child = menu_shell->children;
|
GList *child = menu_shell->children;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
@@ -284,6 +294,7 @@ int wxChoice::GetSelection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
|
void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
|
||||||
@@ -313,7 +324,11 @@ wxString wxChoice::GetString( int n ) const
|
|||||||
|
|
||||||
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
||||||
|
|
||||||
return wxString( wxGTK_CONV_BACK(label->label) );
|
#ifdef __WXGTK20__
|
||||||
|
return wxString( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
|
||||||
|
#else
|
||||||
|
return wxString( label->label );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
|
@@ -131,7 +131,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
|||||||
|
|
||||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||||
|
|
||||||
|
#ifndef __WXGTK20__
|
||||||
gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
|
gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@@ -405,7 +407,11 @@ wxString wxComboBox::GetString( int n ) const
|
|||||||
{
|
{
|
||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
str = wxString(label->label,*wxConvCurrent);
|
#ifdef __WXGTK20__
|
||||||
|
str = wxGTK_CONV_BACK( gtk_label_get_text( label) );
|
||||||
|
#else
|
||||||
|
str = wxString( label->label );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -471,8 +477,18 @@ void wxComboBox::SetStringSelection( const wxString &string )
|
|||||||
|
|
||||||
wxString wxComboBox::GetValue() const
|
wxString wxComboBox::GetValue() const
|
||||||
{
|
{
|
||||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
|
||||||
wxString tmp = wxString(gtk_entry_get_text( GTK_ENTRY(entry) ),*wxConvCurrent);
|
wxString tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry ) ) );
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (int i = 0; i < wxStrlen(tmp.c_str()) +1; i++)
|
||||||
|
{
|
||||||
|
wxChar c = tmp[i];
|
||||||
|
printf( "%d ", (int) (c) );
|
||||||
|
}
|
||||||
|
printf( "\n" );
|
||||||
|
#endif
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,14 +556,18 @@ long wxComboBox::GetLastPosition() const
|
|||||||
void wxComboBox::Replace( long from, long to, const wxString& value )
|
void wxComboBox::Replace( long from, long to, const wxString& value )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
||||||
// FIXME: not quite sure how to do this method right in multibyte mode
|
|
||||||
// FIXME GTK 2.0
|
|
||||||
|
|
||||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||||
if (value.IsNull()) return;
|
if (value.IsNull()) return;
|
||||||
gint pos = (gint)to;
|
gint pos = (gint)to;
|
||||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value.mbc_str(), value.Length(), &pos );
|
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
wxCharBuffer buffer = wxConvUTF8.cWX2MB( value );
|
||||||
|
gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos );
|
||||||
|
#else
|
||||||
|
gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.Length(), &pos );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboBox::Remove(long from, long to)
|
void wxComboBox::Remove(long from, long to)
|
||||||
|
@@ -95,7 +95,7 @@ wxDataFormatId wxDataFormat::GetType() const
|
|||||||
|
|
||||||
wxString wxDataFormat::GetId() const
|
wxString wxDataFormat::GetId() const
|
||||||
{
|
{
|
||||||
wxString ret( gdk_atom_name( m_format ) ); // this will convert from ascii to Unicode
|
wxString ret = wxString::FromAscii( gdk_atom_name( m_format ) );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ void wxDataFormat::SetId( const wxChar *id )
|
|||||||
PrepareFormats();
|
PrepareFormats();
|
||||||
m_type = wxDF_PRIVATE;
|
m_type = wxDF_PRIVATE;
|
||||||
wxString tmp( id );
|
wxString tmp( id );
|
||||||
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
|
m_format = gdk_atom_intern( (const char*) tmp.ToAscii(), FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataFormat::PrepareFormats()
|
void wxDataFormat::PrepareFormats()
|
||||||
@@ -134,7 +134,11 @@ void wxDataFormat::PrepareFormats()
|
|||||||
// text/uri-list for file dnd because compatibility is not important
|
// text/uri-list for file dnd because compatibility is not important
|
||||||
// here (with whom?)
|
// here (with whom?)
|
||||||
if (!g_textAtom)
|
if (!g_textAtom)
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
g_textAtom = gdk_atom_intern( "text/utf8", FALSE );
|
||||||
|
#else
|
||||||
g_textAtom = gdk_atom_intern( "STRING" /* "text/plain" */, FALSE );
|
g_textAtom = gdk_atom_intern( "STRING" /* "text/plain" */, FALSE );
|
||||||
|
#endif
|
||||||
if (!g_pngAtom)
|
if (!g_pngAtom)
|
||||||
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
|
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
|
||||||
if (!g_fileAtom)
|
if (!g_fileAtom)
|
||||||
|
@@ -756,7 +756,11 @@ wxString wxListBox::GetString( int n ) const
|
|||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
|
|
||||||
wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
|
#ifdef __WXGTK20__
|
||||||
|
wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
|
||||||
|
#else
|
||||||
|
wxString str = wxString( label->label );
|
||||||
|
#endif
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@@ -785,7 +789,11 @@ int wxListBox::FindString( const wxString &item ) const
|
|||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
|
|
||||||
wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
|
#ifdef __WXGTK20__
|
||||||
|
wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
|
||||||
|
#else
|
||||||
|
wxString str = wxString( label->label );
|
||||||
|
#endif
|
||||||
|
|
||||||
if (str == item)
|
if (str == item)
|
||||||
return count;
|
return count;
|
||||||
|
@@ -257,7 +257,11 @@ int wxChoice::FindString( const wxString &string ) const
|
|||||||
|
|
||||||
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
||||||
|
|
||||||
wxString tmp( wxGTK_CONV_BACK( label->label ) );
|
#ifdef __WXGTK20__
|
||||||
|
wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
|
||||||
|
#else
|
||||||
|
wxString tmp( label->label );
|
||||||
|
#endif
|
||||||
if (string == tmp)
|
if (string == tmp)
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
@@ -272,8 +276,14 @@ int wxChoice::GetSelection() const
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") );
|
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") );
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
|
||||||
|
return gtk_option_menu_get_history( GTK_OPTION_MENU(m_widget) );
|
||||||
|
|
||||||
|
#else
|
||||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
GList *child = menu_shell->children;
|
GList *child = menu_shell->children;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
@@ -284,6 +294,7 @@ int wxChoice::GetSelection() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
|
void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
|
||||||
@@ -313,7 +324,11 @@ wxString wxChoice::GetString( int n ) const
|
|||||||
|
|
||||||
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
|
||||||
|
|
||||||
return wxString( wxGTK_CONV_BACK(label->label) );
|
#ifdef __WXGTK20__
|
||||||
|
return wxString( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
|
||||||
|
#else
|
||||||
|
return wxString( label->label );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
|
@@ -131,7 +131,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
|||||||
|
|
||||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||||
|
|
||||||
|
#ifndef __WXGTK20__
|
||||||
gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
|
gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
|
||||||
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@@ -405,7 +407,11 @@ wxString wxComboBox::GetString( int n ) const
|
|||||||
{
|
{
|
||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
str = wxString(label->label,*wxConvCurrent);
|
#ifdef __WXGTK20__
|
||||||
|
str = wxGTK_CONV_BACK( gtk_label_get_text( label) );
|
||||||
|
#else
|
||||||
|
str = wxString( label->label );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -471,8 +477,18 @@ void wxComboBox::SetStringSelection( const wxString &string )
|
|||||||
|
|
||||||
wxString wxComboBox::GetValue() const
|
wxString wxComboBox::GetValue() const
|
||||||
{
|
{
|
||||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
|
||||||
wxString tmp = wxString(gtk_entry_get_text( GTK_ENTRY(entry) ),*wxConvCurrent);
|
wxString tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry ) ) );
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
for (int i = 0; i < wxStrlen(tmp.c_str()) +1; i++)
|
||||||
|
{
|
||||||
|
wxChar c = tmp[i];
|
||||||
|
printf( "%d ", (int) (c) );
|
||||||
|
}
|
||||||
|
printf( "\n" );
|
||||||
|
#endif
|
||||||
|
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,14 +556,18 @@ long wxComboBox::GetLastPosition() const
|
|||||||
void wxComboBox::Replace( long from, long to, const wxString& value )
|
void wxComboBox::Replace( long from, long to, const wxString& value )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
|
||||||
// FIXME: not quite sure how to do this method right in multibyte mode
|
|
||||||
// FIXME GTK 2.0
|
|
||||||
|
|
||||||
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
|
||||||
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
|
||||||
if (value.IsNull()) return;
|
if (value.IsNull()) return;
|
||||||
gint pos = (gint)to;
|
gint pos = (gint)to;
|
||||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value.mbc_str(), value.Length(), &pos );
|
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
wxCharBuffer buffer = wxConvUTF8.cWX2MB( value );
|
||||||
|
gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos );
|
||||||
|
#else
|
||||||
|
gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.Length(), &pos );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboBox::Remove(long from, long to)
|
void wxComboBox::Remove(long from, long to)
|
||||||
|
@@ -95,7 +95,7 @@ wxDataFormatId wxDataFormat::GetType() const
|
|||||||
|
|
||||||
wxString wxDataFormat::GetId() const
|
wxString wxDataFormat::GetId() const
|
||||||
{
|
{
|
||||||
wxString ret( gdk_atom_name( m_format ) ); // this will convert from ascii to Unicode
|
wxString ret = wxString::FromAscii( gdk_atom_name( m_format ) );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ void wxDataFormat::SetId( const wxChar *id )
|
|||||||
PrepareFormats();
|
PrepareFormats();
|
||||||
m_type = wxDF_PRIVATE;
|
m_type = wxDF_PRIVATE;
|
||||||
wxString tmp( id );
|
wxString tmp( id );
|
||||||
m_format = gdk_atom_intern( wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
|
m_format = gdk_atom_intern( (const char*) tmp.ToAscii(), FALSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataFormat::PrepareFormats()
|
void wxDataFormat::PrepareFormats()
|
||||||
@@ -134,7 +134,11 @@ void wxDataFormat::PrepareFormats()
|
|||||||
// text/uri-list for file dnd because compatibility is not important
|
// text/uri-list for file dnd because compatibility is not important
|
||||||
// here (with whom?)
|
// here (with whom?)
|
||||||
if (!g_textAtom)
|
if (!g_textAtom)
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
g_textAtom = gdk_atom_intern( "text/utf8", FALSE );
|
||||||
|
#else
|
||||||
g_textAtom = gdk_atom_intern( "STRING" /* "text/plain" */, FALSE );
|
g_textAtom = gdk_atom_intern( "STRING" /* "text/plain" */, FALSE );
|
||||||
|
#endif
|
||||||
if (!g_pngAtom)
|
if (!g_pngAtom)
|
||||||
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
|
g_pngAtom = gdk_atom_intern( "image/png", FALSE );
|
||||||
if (!g_fileAtom)
|
if (!g_fileAtom)
|
||||||
|
@@ -756,7 +756,11 @@ wxString wxListBox::GetString( int n ) const
|
|||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
|
|
||||||
wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
|
#ifdef __WXGTK20__
|
||||||
|
wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
|
||||||
|
#else
|
||||||
|
wxString str = wxString( label->label );
|
||||||
|
#endif
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@@ -785,7 +789,11 @@ int wxListBox::FindString( const wxString &item ) const
|
|||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
|
|
||||||
wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
|
#ifdef __WXGTK20__
|
||||||
|
wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) );
|
||||||
|
#else
|
||||||
|
wxString str = wxString( label->label );
|
||||||
|
#endif
|
||||||
|
|
||||||
if (str == item)
|
if (str == item)
|
||||||
return count;
|
return count;
|
||||||
|
Reference in New Issue
Block a user