don't access m_clientDataItemsType directly

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-09-17 00:12:13 +00:00
parent efb35bebfa
commit b4a11fe85c
7 changed files with 30 additions and 45 deletions

View File

@@ -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

View File

@@ -483,9 +483,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
g_object_unref (entry);
}
if ( !HasClientData() )
m_clientDataItemsType = type;
return pos + numItems - 1;
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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 );

View File

@@ -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();
}

View File

@@ -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