X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd0eed647daeb257f28699de879d2f4f5aeb7fb6..7c39369e5a9b2298eed8adc64a229482d5d90dd1:/src/gtk1/choice.cpp diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index e0f1da1d40..9bf71e04f5 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -14,6 +14,9 @@ #include "wx/choice.h" +#include "gdk/gdk.h" +#include "gtk/gtk.h" + //----------------------------------------------------------------------------- // data //----------------------------------------------------------------------------- @@ -55,7 +58,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, m_needParent = TRUE; PreCreation( parent, id, pos, size, style, name ); - + SetValidator( validator ); m_widget = gtk_option_menu_new(); @@ -70,7 +73,8 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, for (int i = 0; i < n; i++) { m_clientDataList.Append( (wxObject*) NULL ); - + m_clientObjectList.Append( (wxObject*) NULL ); + GtkWidget *item = gtk_menu_item_new_with_label( choices[i] ); gtk_menu_append( GTK_MENU(menu), item ); @@ -92,6 +96,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, SetBackgroundColour( parent->GetBackgroundColour() ); SetForegroundColour( parent->GetForegroundColour() ); + SetFont( parent->GetFont() ); Show( TRUE ); @@ -100,14 +105,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, wxChoice::~wxChoice() { - wxNode *node = m_clientDataList.First(); - while (node) - { - wxClientData *cd = (wxClientData*)node->Data(); - if (cd) delete cd; - node = node->Next(); - } - m_clientDataList.Clear(); + Clear(); } void wxChoice::AppendCommon( const wxString &item ) @@ -132,24 +130,24 @@ void wxChoice::AppendCommon( const wxString &item ) void wxChoice::Append( const wxString &item ) { - m_clientDataList.Append( (wxObject*)NULL ); + m_clientDataList.Append( (wxObject*) NULL ); + m_clientObjectList.Append( (wxObject*) NULL ); AppendCommon( item ); } void wxChoice::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 wxChoice::Append( const wxString &item, wxClientData *clientData ) { - m_clientDataList.Append( (wxObject*) clientData ); + m_clientObjectList.Append( (wxObject*) clientData ); + m_clientDataList.Append( (wxObject*) NULL ); AppendCommon( item ); } @@ -161,13 +159,7 @@ void wxChoice::SetClientData( int n, void* clientData ) 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* wxChoice::GetClientData( int n ) @@ -177,36 +169,31 @@ void* wxChoice::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 wxChoice::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(); if (cd) delete cd; - + node->SetData( (wxObject*) clientData ); } wxClientData* wxChoice::GetClientObject( int n ) { - wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" ); + 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(); } - void wxChoice::Clear() { @@ -216,13 +203,15 @@ void wxChoice::Clear() GtkWidget *menu = gtk_menu_new(); gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); - 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(); }