#include "wx/choice.h"
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
+#include "wx/gtk/private.h"
//-----------------------------------------------------------------------------
// idle system
m_strings->Clear();
}
-void wxChoice::Delete( int WXUNUSED(n) )
+void wxChoice::Delete( int n )
{
- wxFAIL_MSG( wxT("wxChoice:Delete not implemented") );
+ wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
+
+ // VZ: apparently GTK+ doesn't have a built-in function to do it (not even
+ // in 2.0), hence this dump implementation - still better than nothing
+ int i,
+ count = GetCount();
+
+ wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") );
+
+ wxArrayString items;
+ items.Alloc(count);
+ for ( i = 0; i < count; i++ )
+ {
+ if ( i != n )
+ items.Add(GetString(i));
+ }
+
+ Clear();
+
+ for ( i = 0; i < count - 1; i++ )
+ {
+ Append(items[i]);
+ }
}
int wxChoice::FindString( const wxString &string ) const
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = (GtkLabel *) NULL;
- if (bin->child) label = GTK_LABEL(bin->child);
- if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
+ if (bin->child)
+ label = GTK_LABEL(bin->child);
+ if (!label)
+ label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
+
+ wxString tmp( wxGTK_CONV_BACK( label->label ) );
+ if (string == tmp)
+ return count;
- if (string == wxString(label->label,*wxConvCurrent))
- return count;
-
- child = child->next;
- count++;
+ child = child->next;
+ count++;
}
return -1;
if (count == n)
{
GtkLabel *label = (GtkLabel *) NULL;
- if (bin->child) label = GTK_LABEL(bin->child);
- if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
+ if (bin->child)
+ label = GTK_LABEL(bin->child);
+ if (!label)
+ label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
- return wxString(label->label,*wxConvCurrent);
+ return wxString( wxGTK_CONV_BACK(label->label) );
}
child = child->next;
count++;
GtkBin *bin = GTK_BIN( child->data );
GtkWidget *label = (GtkWidget *) NULL;
- if (bin->child) label = bin->child;
- if (!label) label = GTK_BUTTON(m_widget)->child;
+ if (bin->child)
+ label = bin->child;
+ if (!label)
+ label = BUTTON_CHILD(m_widget);
gtk_widget_set_style( label, m_widgetStyle );
size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item)
{
- GtkWidget *menu_item = gtk_menu_item_new_with_label( item.mbc_str() );
+ GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
size_t index;
if ( m_strings )
size_t count = GetCount();
for ( size_t n = 0; n < count; n++ )
{
- width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str());
+ // FIXME GTK 2.0
+ width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
if ( width > ret.x )
ret.x = width;
}
if ( ret.x < 80 )
ret.x = 80;
- ret.y = 16 + gdk_char_height( m_widget->style->font, 'H' );
+ ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H' );
+
return ret;
}