for (int i = 0; i < n; i++)
{
+ m_clientDataList.Append( (wxObject*) NULL );
+ m_clientObjectList.Append( (wxObject*) NULL );
+
GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( choices[i] );
ConnectWidget( list_item );
- m_clientDataList.Append( (wxObject*)NULL );
-
gtk_widget_show( list_item );
}
wxListBox::~wxListBox()
{
- wxNode *node = m_clientDataList.First();
- while (node)
- {
- wxClientData *cd = (wxClientData*)node->Data();
- if (cd) delete cd;
- node = node->Next();
- }
- m_clientDataList.Clear();
+ Clear();
}
void wxListBox::AppendCommon( const wxString &item )
void wxListBox::Append( const wxString &item )
{
- m_clientDataList.Append( (wxObject*)NULL );
+ m_clientDataList.Append( (wxObject*) NULL );
+ m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, void *clientData )
{
- if (clientData)
- m_clientDataList.Append( (wxObject*) new wxVoidClientData( clientData ) );
- else
- m_clientDataList.Append( (wxObject*)NULL );
+ m_clientDataList.Append( (wxObject*) clientData );
+ m_clientObjectList.Append( (wxObject*) NULL );
AppendCommon( item );
}
void wxListBox::Append( const wxString &item, wxClientData *clientData )
{
- m_clientDataList.Append( (wxObject*) clientData );
+ m_clientObjectList.Append( (wxObject*) clientData );
+ m_clientDataList.Append( (wxObject*) NULL );
AppendCommon( item );
}
wxNode *node = m_clientDataList.Nth( n );
if (!node) return;
- wxClientData *cd = (wxClientData*) node->Data();
- if (cd) delete cd;
-
- if (clientData)
- node->SetData( (wxObject*) new wxVoidClientData(clientData) );
- else
- node->SetData( (wxObject*) NULL );
+ node->SetData( (wxObject*) clientData );
}
void* wxListBox::GetClientData( int n )
wxNode *node = m_clientDataList.Nth( n );
if (!node) return NULL;
- wxVoidClientData *cd = (wxVoidClientData*) node->Data();
- if (cd)
- return cd->GetData();
- else
- return (void*) NULL;
+ return node->Data();
}
void wxListBox::SetClientObject( int n, wxClientData* clientData )
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
- wxNode *node = m_clientDataList.Nth( n );
+ wxNode *node = m_clientObjectList.Nth( n );
if (!node) return;
wxClientData *cd = (wxClientData*) node->Data();
{
wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
- wxNode *node = m_clientDataList.Nth( n );
+ wxNode *node = m_clientObjectList.Nth( n );
if (!node) return (wxClientData*) NULL;
return (wxClientData*) node->Data();
gtk_list_clear_items( m_list, 0, Number() );
- wxNode *node = m_clientDataList.First();
+ wxNode *node = m_clientObjectList.First();
while (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
node = node->Next();
}
+ m_clientObjectList.Clear();
+
m_clientDataList.Clear();
}
gtk_list_remove_items( m_list, list );
g_list_free( list );
- wxNode *node = m_clientDataList.Nth( n );
- if (!node)
- {
- wxFAIL_MSG( "wrong index" );
- }
- else
+ wxNode *node = m_clientObjectList.Nth( n );
+ if (node)
{
wxClientData *cd = (wxClientData*)node->Data();
if (cd) delete cd;
+ m_clientObjectList.DeleteNode( node );
+ }
+
+ node = m_clientDataList.Nth( n );
+ if (node)
+ {
m_clientDataList.DeleteNode( node );
}
}
{
SetWidgetStyle();
- GdkWindow *window = GTK_WIDGET(m_list)->window;
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
- gdk_window_set_background( window, m_backgroundColour.GetColor() );
- gdk_window_clear( window );
+ if (m_backgroundColour.Ok())
+ {
+ GdkWindow *window = GTK_WIDGET(m_list)->window;
+ m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
+ gdk_window_set_background( window, m_backgroundColour.GetColor() );
+ gdk_window_clear( window );
+ }
GList *child = m_list->children;
while (child)