// this is the first time client data is used with this control
DoInitItemClientData();
- m_clientDataItemsType = type;
+ SetClientDataType(type);
}
//else: we already have client data
g_object_unref (entry);
}
- if ( !HasClientData() )
- m_clientDataItemsType = type;
-
return pos + numItems - 1;
}
// 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);
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
return false;
wxMacDataBrowserListControl* control = new wxMacDataBrowserListControl( this, pos, size, style );
- control->SetClientDataType( m_clientDataItemsType );
m_peer = control;
MacPostControlCreate( pos, size );
// 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();
}
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