X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db9504c5049e9e89588b3947ac9ecce524b820b8..f5d29b396f837cab85b8d63992cc1b640007db67:/include/wx/list.h diff --git a/include/wx/list.h b/include/wx/list.h index 696162ab44..75c3c01cbb 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// /* @@ -144,6 +144,10 @@ public: const char *GetKeyString() const { return m_key.string; } long GetKeyInteger() const { return m_key.integer; } + // Necessary for some existing code + void SetKeyString(char* s) { m_key.string = s; } + void SetKeyInteger(long i) { m_key.integer = i; } + #ifdef wxLIST_COMPATIBILITY // compatibility methods wxNode *Next() const { return (wxNode *)GetNext(); } @@ -159,6 +163,9 @@ protected: void *GetData() const { return m_data; } void SetData(void *data) { m_data = data; } + // get 0-based index of this node within the list or NOT_FOUND + int IndexOf() const; + virtual void DeleteData() { } private: @@ -188,11 +195,25 @@ public: size_t GetCount() const { return m_count; } // operations + // delete all nodes void Clear(); + // instruct it to destroy user data when deleting nodes void DeleteContents(bool destroy) { m_destroy = destroy; } + // query if to delete + bool GetDeleteContents() const + { return m_destroy; } + + // get the keytype + wxKeyType GetKeyType() const + { return m_keyType; } + + // set the keytype (required by the serial code) + void SetKeyType(wxKeyType keyType) + { wxASSERT( m_count==0 ); m_keyType = keyType; } + protected: // all methods here are "overloaded" in derived classes to provide compile // time type checking @@ -244,7 +265,7 @@ protected: bool DeleteNode(wxNodeBase *node); // finds object pointer and deletes node (and object if DeleteContents // is on), returns FALSE if object not found - bool DeleteObject(void *object); + bool DeleteObject(void *object); // search (all return NULL if item not found) // by data @@ -253,6 +274,9 @@ protected: // by key wxNodeBase *Find(const wxListKey& key) const; + // get 0-based index of object or NOT_FOUND + int IndexOf( void *object ) const; + // this function allows the sorting of arbitrary lists by giving // a function to compare two list elements. The list is sorted in place. void Sort(const wxSortCompareFunction compfunc); @@ -261,7 +285,7 @@ protected: void *FirstThat(wxListIterateFunction func); void ForEach(wxListIterateFunction func); void *LastThat(wxListIterateFunction func); - + private: // helpers // common part of all ctors @@ -373,6 +397,9 @@ private: virtual nodetype *Find(const wxListKey& key) const \ { return (nodetype *)wxListBase::Find(key); } \ \ + int IndexOf( T *object ) const \ + { return wxListBase::IndexOf(object); } \ + \ void Sort(wxSortFuncFor_##name func) \ { wxListBase::Sort((wxSortCompareFunction)func); } \ \ @@ -426,7 +453,7 @@ public: // ----------------------------------------------------------------------------- // wxStringList class for compatibility with the old code // ----------------------------------------------------------------------------- - + WX_DECLARE_LIST_2(char, wxStringListBase, wxStringListNode); class WXDLLEXPORT wxStringList : public wxStringListBase @@ -448,8 +475,7 @@ public: wxNode *Add(const char *s) { return (wxNode *)wxStringListBase::Append(copystring(s)); } - void Delete(const char *s) - { wxStringListBase::DeleteObject((char *)s); } + bool Delete(const char *s); char **ListToArray(bool new_copies = FALSE) const; bool Member(const char *s) const;