]> git.saurik.com Git - wxWidgets.git/commitdiff
don't access m_clientDataItemsType directly
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 17 Sep 2007 00:12:13 +0000 (00:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 17 Sep 2007 00:12:13 +0000 (00:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48732 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/ctrlsub.h
src/gtk/listbox.cpp
src/mac/carbon/checklst.cpp
src/mac/carbon/combobox.cpp
src/mac/carbon/listbox.cpp
src/msw/choice.cpp
src/msw/listbox.cpp

index 425380d6024d93973e0fe75d2896dc6e3e80a812..c20c7e62535f733e0d8ed2de88b8bbffece79df0 100644 (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
 
index b3f4a76682c27c727145c74817bae8a2afc8a8e5..b4fa72e3712b6d78edecac4512983de7e5fee18c 100644 (file)
@@ -483,9 +483,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items,
         g_object_unref (entry);
     }
 
-    if ( !HasClientData() )
-        m_clientDataItemsType = type;
-
     return pos + numItems - 1;
 }
 
index d58ae073923800642f85529a48391e9f20d1519d..1374f2646c802ce92e49d75cba64be6d91a58c09 100644 (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);
index 1241f98b12cbd7e31e274a4b87e70a365a2b815e..5c728117c5239aceebecdbea3466af9697e522dd 100644 (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
index 7bd1442a2346fc3306a923702b3443e22d79d239..fb80168fcc6ce850ffcc84b80ceb79ee8868ba47 100644 (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 );
index 4d834267cd5e920479f113999676099e1067e71e..9eec9c2332422433a5166bbbd315c221a5af77cb 100644 (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();
 }
index 3f85f6bbb7598bfab4231adec36e932c5f6feb1d..b68359e3e2b78ee44ed8723530e75f993772ef10 100644 (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