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
; }
33 virtual ~wxControlWithItems() {} // Added min for Mac X
39 void Append(const wxString
& item
)
41 void Append(const wxString
& item
, void *clientData
)
42 { int n
= DoAppend(item
); SetClientData(n
, clientData
); }
43 void Append(const wxString
& item
, wxClientData
*clientData
)
44 { int n
= DoAppend(item
); SetClientObject(n
, clientData
); }
49 virtual void Clear() = 0;
50 virtual void Delete(int n
) = 0;
55 virtual int GetCount() const = 0;
56 virtual wxString
GetString(int n
) const = 0;
57 virtual void SetString(int n
, const wxString
& s
) = 0;
58 virtual int FindString(const wxString
& s
) const = 0;
63 virtual void Select(int n
) = 0;
64 virtual int GetSelection() const = 0;
66 wxString
GetStringSelection() const;
72 void SetClientData(int n
, void* clientData
);
73 void* GetClientData(int n
) const;
75 void SetClientObject(int n
, wxClientData
* clientData
);
76 wxClientData
* GetClientObject(int n
) const;
78 bool HasClientObjectData() const
79 { return m_clientDataItemsType
== ClientData_Object
; }
80 bool HasClientUntypedData() const
81 { return m_clientDataItemsType
== ClientData_Void
; }
83 // compatibility - these functions are deprecated, use the new ones
85 int Number() const { return GetCount(); }
88 virtual int DoAppend(const wxString
& item
) = 0;
90 virtual void DoSetItemClientData(int n
, void* clientData
) = 0;
91 virtual void* DoGetItemClientData(int n
) const = 0;
92 virtual void DoSetItemClientObject(int n
, wxClientData
* clientData
) = 0;
93 virtual wxClientData
* DoGetItemClientObject(int n
) const = 0;
95 // the type of the client data for the items
96 wxClientDataType m_clientDataItemsType
;
99 #endif // _WX_CTRLSUB_H_BASE_