X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a236aa2058ccf3d36e9cafc20fa7375080c4be50..3039ade95dbad1ee5a5ed03c25e3ed9241907850:/include/wx/ctrlsub.h diff --git a/include/wx/ctrlsub.h b/include/wx/ctrlsub.h index 901f52c45d..109369b489 100644 --- a/include/wx/ctrlsub.h +++ b/include/wx/ctrlsub.h @@ -30,7 +30,7 @@ // implements an extended interface deriving from this one) // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxItemContainerImmutable +class WXDLLIMPEXP_CORE wxItemContainerImmutable { public: wxItemContainerImmutable() { } @@ -73,7 +73,7 @@ public: bool SetStringSelection(const wxString& s); // return the selected string or empty string if none - wxString GetStringSelection() const; + virtual wxString GetStringSelection() const; // this is the same as SetSelection( for single-selection controls but // reads better for multi-selection ones @@ -97,7 +97,7 @@ protected: // in this case DoInsertItem() needs to be overridden. // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable +class WXDLLIMPEXP_CORE wxItemContainer : public wxItemContainerImmutable { private: // AppendItems() and InsertItems() helpers just call DoAppend/InsertItems() @@ -121,7 +121,7 @@ private: int AppendItems(const wxArrayStringsAdapter& items, void **clientData) { - wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object, + wxASSERT_MSG( GetClientDataType() != wxClientData_Object, _T("can't mix different types of client data") ); return AppendItems(items, clientData, wxClientData_Void); @@ -130,10 +130,10 @@ private: int AppendItems(const wxArrayStringsAdapter& items, wxClientData **clientData) { - wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void, + wxASSERT_MSG( GetClientDataType() != wxClientData_Void, _T("can't mix different types of client data") ); - return AppendItems(items, wx_reinterpret_cast(void **, clientData), + return AppendItems(items, reinterpret_cast(clientData), wxClientData_Object); } @@ -166,7 +166,7 @@ private: unsigned int pos, void **clientData) { - wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object, + wxASSERT_MSG( GetClientDataType() != wxClientData_Object, _T("can't mix different types of client data") ); return InsertItems(items, pos, clientData, wxClientData_Void); @@ -176,11 +176,11 @@ private: unsigned int pos, wxClientData **clientData) { - wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void, + wxASSERT_MSG( GetClientDataType() != wxClientData_Void, _T("can't mix different types of client data") ); return InsertItems(items, pos, - wx_reinterpret_cast(void **, clientData), + reinterpret_cast(clientData), wxClientData_Object); } @@ -280,6 +280,16 @@ public: void Delete(unsigned int pos); + // various accessors + // ----------------- + + // The control may maintain its items in a sorted order in which case + // items are automatically inserted at the right position when they are + // inserted or appended. Derived classes have to override this method if + // they implement sorting, typically by returning HasFlag(wxXX_SORT) + virtual bool IsSorted() const { return false; } + + // client data stuff // ----------------- @@ -289,19 +299,23 @@ public: void SetClientObject(unsigned int n, wxClientData* clientData); wxClientData* GetClientObject(unsigned int n) const; + // return the type of client data stored in this control: usually it just + // returns m_clientDataItemsType but must be overridden in the controls + // which delegate their client data storage to another one (e.g. wxChoice + // in wxUniv which stores data in wxListBox which it uses anyhow); don't + // forget to override SetClientDataType() if you override this one + // + // NB: for this to work no code should ever access m_clientDataItemsType + // directly but only via this function! + virtual wxClientDataType GetClientDataType() const + { return m_clientDataItemsType; } + bool HasClientData() const - { return m_clientDataItemsType != wxClientData_None; } + { return GetClientDataType() != wxClientData_None; } bool HasClientObjectData() const - { return m_clientDataItemsType == wxClientData_Object; } + { return GetClientDataType() == wxClientData_Object; } bool HasClientUntypedData() const - { return m_clientDataItemsType == wxClientData_Void; } - - - // The control may maintain its items in a sorted order in which case - // items are automatically inserted at the right position when they are - // inserted or appended. Derived classes have to override this method if - // they implement sorting, typically by returning HasFlag(wxXX_SORT) - virtual bool IsSorted() const { return false; } + { return GetClientDataType() == wxClientData_Void; } protected: // there is usually no need to override this method but you can do it if it @@ -364,7 +378,14 @@ protected: // set it to NULL (must only be called if HasClientObjectData()) void ResetItemClientObject(unsigned int n); + // set the type of the client data stored in this control: override this if + // you override GetClientDataType() + virtual void SetClientDataType(wxClientDataType clientDataItemsType) + { + m_clientDataItemsType = clientDataItemsType; + } +private: // the type of the client data for the items wxClientDataType m_clientDataItemsType; }; @@ -391,7 +412,7 @@ protected: wxClientData* GetClientObject(unsigned int n) const \ { return wxItemContainer::GetClientObject(n); } -class WXDLLEXPORT wxControlWithItemsBase : public wxControl, +class WXDLLIMPEXP_CORE wxControlWithItemsBase : public wxControl, public wxItemContainer { public: @@ -425,7 +446,7 @@ private: #elif defined(__WXMOTIF__) #include "wx/motif/ctrlsub.h" #else - class wxControlWithItems : public wxControlWithItemsBase + class WXDLLIMPEXP_CORE wxControlWithItems : public wxControlWithItemsBase { public: wxControlWithItems() { }