From b4a11fe85cb632368ba8426204598806460b7679 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Sep 2007 00:12:13 +0000 Subject: [PATCH] don't access m_clientDataItemsType directly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/ctrlsub.h | 2 +- src/gtk/listbox.cpp | 3 --- src/mac/carbon/checklst.cpp | 1 - src/mac/carbon/combobox.cpp | 37 +++++++++++++++---------------------- src/mac/carbon/listbox.cpp | 1 - src/msw/choice.cpp | 27 ++++++++++++--------------- src/msw/listbox.cpp | 4 ++-- 7 files changed, 30 insertions(+), 45 deletions(-) diff --git a/include/wx/generic/ctrlsub.h b/include/wx/generic/ctrlsub.h index 425380d..c20c7e6 100644 --- a/include/wx/generic/ctrlsub.h +++ b/include/wx/generic/ctrlsub.h @@ -109,7 +109,7 @@ private: // this is the first time client data is used with this control DoInitItemClientData(); - m_clientDataItemsType = type; + SetClientDataType(type); } //else: we already have client data diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index b3f4a76..b4fa72e 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -483,9 +483,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, g_object_unref (entry); } - if ( !HasClientData() ) - m_clientDataItemsType = type; - return pos + numItems - 1; } diff --git a/src/mac/carbon/checklst.cpp b/src/mac/carbon/checklst.cpp index d58ae07..1374f26 100644 --- a/src/mac/carbon/checklst.cpp +++ b/src/mac/carbon/checklst.cpp @@ -89,7 +89,6 @@ bool wxCheckListBox::Create( // this will be increased by our Append command wxMacDataBrowserCheckListControl* control = new wxMacDataBrowserCheckListControl( this, pos, size, style ); - control->SetClientDataType( m_clientDataItemsType ); m_peer = control; MacPostControlCreate(pos,size); diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 1241f98..5c72811 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -507,44 +507,37 @@ int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items, void **clientData, wxClientDataType type) { - // wxItemContainer should probably be doing it itself but usually this is - // not necessary as the derived class DoInsertItems() calls - // AssignNewItemClientData() which initializes m_clientDataItemsType - // correctly; however as we just forward everything to wxChoice, we need to - // do it ourselves - // - // also notice that we never use wxClientData_Object with wxChoice as we - // don't want it to delete the data -- we will - int rc = m_choice->DoInsertItems(items, pos, clientData, - clientData ? wxClientData_Void - : wxClientData_None) ; - if ( rc != wxNOT_FOUND ) - { - if ( !HasClientData() && type != wxClientData_None ) - m_clientDataItemsType = type; - } - - return rc; + return m_choice->DoInsertItems(items, pos, clientData, type); } void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData) { - return m_choice->SetClientData( n , clientData ) ; + return m_choice->DoSetItemClientData( n , clientData ) ; } void* wxComboBox::DoGetItemClientData(unsigned int n) const { - return m_choice->GetClientData( n ) ; + return m_choice->DoGetItemClientData( n ) ; +} + +wxClientDataType wxComboBox::GetClientDataType() const +{ + return m_choice->GetClientDataType(); +} + +void wxComboBox::SetClientDataType(wxClientDataType clientDataItemsType) +{ + m_choice->SetClientDataType(clientDataItemsType); } void wxComboBox::DoDeleteOneItem(unsigned int n) { - m_choice->Delete( n ); + m_choice->DoDeleteOneItem( n ); } void wxComboBox::DoClear() { - m_choice->Clear(); + m_choice->DoClear(); } int wxComboBox::GetSelection() const diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 7bd1442..fb80168 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -82,7 +82,6 @@ bool wxListBox::Create( return false; wxMacDataBrowserListControl* control = new wxMacDataBrowserListControl( this, pos, size, style ); - control->SetClientDataType( m_clientDataItemsType ); m_peer = control; MacPostControlCreate( pos, size ); diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index 4d83426..9eec9c2 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -363,25 +363,22 @@ void wxChoice::SetString(unsigned int n, const wxString& s) // we have to delete and add back the string as there is no way to change a // string in place - // we need to preserve the client data - void *data; - if ( m_clientDataItemsType != wxClientData_None ) - { - data = DoGetItemClientData(n); - } - else // no client data - { - data = NULL; - } + // we need to preserve the client data manually + void *oldData = NULL; + wxClientData *oldObjData = NULL; + if ( HasClientUntypedData() ) + oldData = GetClientData(n); + else if ( HasClientObjectData() ) + oldObjData = GetClientObject(n); ::SendMessage(GetHwnd(), CB_DELETESTRING, n, 0); ::SendMessage(GetHwnd(), CB_INSERTSTRING, n, (LPARAM)s.wx_str() ); - if ( data ) - { - DoSetItemClientData(n, data); - } - //else: it's already NULL by default + // restore the client data + if ( oldData ) + SetClientData(n, oldData); + else if ( oldObjData ) + SetClientObject(n, oldObjData); InvalidateBestSize(); } diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 3f85f6b..b68359e 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -486,9 +486,9 @@ void wxListBox::SetString(unsigned int n, const wxString& s) void *oldData = NULL; wxClientData *oldObjData = NULL; - if ( m_clientDataItemsType == wxClientData_Void ) + if ( HasClientUntypedData() ) oldData = GetClientData(n); - else if ( m_clientDataItemsType == wxClientData_Object ) + else if ( HasClientObjectData() ) oldObjData = GetClientObject(n); // delete and recreate it -- 2.7.4