1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
3 // Purpose: wxControlWithItems interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_CTRLSUB_H_BASE_
13 #define _WX_CTRLSUB_H_BASE_
16 #pragma interface "controlwithitems.h"
19 #include "wx/control.h" // base class
21 // ----------------------------------------------------------------------------
22 // wxControlWithItems defines an interface which is implemented by all controls
23 // which have string subitems each of which may be selected.
25 // Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox
26 // ----------------------------------------------------------------------------
28 class WXDLLEXPORT wxControlWithItems
: public wxControl
31 wxControlWithItems() { m_clientDataItemsType
= ClientData_None
; }
36 void Append(const wxString
& item
)
38 void Append(const wxString
& item
, void *clientData
)
39 { int n
= DoAppend(item
); SetClientData(n
, clientData
); }
40 void Append(const wxString
& item
, wxClientData
*clientData
)
41 { int n
= DoAppend(item
); SetClientObject(n
, clientData
); }
46 virtual void Clear() = 0;
47 virtual void Delete(int n
) = 0;
52 virtual int GetCount() const = 0;
53 virtual wxString
GetString(int n
) const = 0;
54 virtual void SetString(int n
, const wxString
& s
) = 0;
55 virtual int FindString(const wxString
& s
) const = 0;
60 virtual void Select(int n
) = 0;
61 virtual int GetSelection() const = 0;
63 wxString
GetStringSelection() const;
69 void SetClientData(int n
, void* clientData
);
70 void* GetClientData(int n
) const;
72 void SetClientObject(int n
, wxClientData
* clientData
);
73 wxClientData
* GetClientObject(int n
) const;
75 bool HasClientObjectData() const
76 { return m_clientDataItemsType
== ClientData_Object
; }
77 bool HasClientUntypedData() const
78 { return m_clientDataItemsType
== ClientData_Void
; }
80 // compatibility - these functions are deprecated, use the new ones
82 int Number() const { return GetCount(); }
85 virtual int DoAppend(const wxString
& item
) = 0;
87 virtual void DoSetItemClientData(int n
, void* clientData
) = 0;
88 virtual void* DoGetItemClientData(int n
) const = 0;
89 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
) = 0;
90 virtual wxClientData
* DoGetItemClientObject(int n
) const = 0;
92 // the type of the client data for the items
93 wxClientDataType m_clientDataItemsType
;
96 #endif // _WX_CTRLSUB_H_BASE_