]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ctrlsub.h
compilation/linking fixes for DoCaptureMouse() change
[wxWidgets.git] / include / wx / ctrlsub.h
CommitLineData
6c8a980f
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/ctrlsub.h (read: "wxConTRoL with SUBitems")
3// Purpose: wxControlWithItems interface
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 22.10.99
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CTRLSUB_H_BASE_
13#define _WX_CTRLSUB_H_BASE_
14
15#ifdef __GNUG__
16 #pragma interface "controlwithitems.h"
17#endif
18
1e6feb95
VZ
19#if wxUSE_CONTROLS
20
6c8a980f
VZ
21#include "wx/control.h" // base class
22
23// ----------------------------------------------------------------------------
1e6feb95 24// wxItemContainer defines an interface which is implemented by all controls
6c8a980f
VZ
25// which have string subitems each of which may be selected.
26//
1e6feb95
VZ
27// Examples: wxListBox, wxCheckListBox, wxChoice and wxComboBox (which
28// implements an extended interface deriving from this one)
6c8a980f
VZ
29// ----------------------------------------------------------------------------
30
1e6feb95 31class WXDLLEXPORT wxItemContainer
6c8a980f
VZ
32{
33public:
1e6feb95 34 wxItemContainer() { m_clientDataItemsType = wxClientData_None; }
799ea011 35 virtual ~wxItemContainer();
6c8a980f
VZ
36
37 // adding items
38 // ------------
39
1e6feb95
VZ
40 int Append(const wxString& item)
41 { return DoAppend(item); }
42 int Append(const wxString& item, void *clientData)
43 { int n = DoAppend(item); SetClientData(n, clientData); return n; }
44 int Append(const wxString& item, wxClientData *clientData)
45 { int n = DoAppend(item); SetClientObject(n, clientData); return n; }
6c8a980f
VZ
46
47 // deleting items
48 // --------------
49
50 virtual void Clear() = 0;
51 virtual void Delete(int n) = 0;
52
53 // accessing strings
54 // -----------------
55
56 virtual int GetCount() const = 0;
57 virtual wxString GetString(int n) const = 0;
58 virtual void SetString(int n, const wxString& s) = 0;
59 virtual int FindString(const wxString& s) const = 0;
60
61 // selection
62 // ---------
63
64 virtual void Select(int n) = 0;
65 virtual int GetSelection() const = 0;
66
67 wxString GetStringSelection() const;
68
69 // misc
70 // ----
71
72 // client data stuff
73 void SetClientData(int n, void* clientData);
74 void* GetClientData(int n) const;
75
76 void SetClientObject(int n, wxClientData* clientData);
77 wxClientData* GetClientObject(int n) const;
78
79 bool HasClientObjectData() const
1e6feb95 80 { return m_clientDataItemsType == wxClientData_Object; }
6c8a980f 81 bool HasClientUntypedData() const
1e6feb95 82 { return m_clientDataItemsType == wxClientData_Void; }
6c8a980f 83
62e26542 84#if WXWIN_COMPATIBILITY_2_2
6c8a980f
VZ
85 // compatibility - these functions are deprecated, use the new ones
86 // instead
87 int Number() const { return GetCount(); }
62e26542 88#endif // WXWIN_COMPATIBILITY_2_2
1e6feb95 89
6c8a980f
VZ
90protected:
91 virtual int DoAppend(const wxString& item) = 0;
92
93 virtual void DoSetItemClientData(int n, void* clientData) = 0;
94 virtual void* DoGetItemClientData(int n) const = 0;
95 virtual void DoSetItemClientObject(int n, wxClientData* clientData) = 0;
96 virtual wxClientData* DoGetItemClientObject(int n) const = 0;
97
98 // the type of the client data for the items
99 wxClientDataType m_clientDataItemsType;
100};
101
1e6feb95
VZ
102class WXDLLEXPORT wxControlWithItems : public wxControl, public wxItemContainer
103{
104public:
105 // we have to redefine these functions here to avoid ambiguities in classes
106 // deriving from us which would arise otherwise because both base classses
107 // have the methods with the same names - hopefully, a smart compiler can
108 // optimize away these simple inline wrappers so we don't suffer much from
109 // this
110
111 void SetClientData(void *data)
112 {
113 wxControl::SetClientData(data);
114 }
115
116 void *GetClientData() const
117 {
118 return wxControl::GetClientData();
119 }
120
121 void SetClientObject(wxClientData *data)
122 {
123 wxControl::SetClientObject(data);
124 }
125
126 wxClientData *GetClientObject() const
127 {
128 return wxControl::GetClientObject();
129 }
130
131 void SetClientData(int n, void* clientData)
132 {
133 wxItemContainer::SetClientData(n, clientData);
134 }
135
136 void* GetClientData(int n) const
137 {
138 return wxItemContainer::GetClientData(n);
139 }
140
141 void SetClientObject(int n, wxClientData* clientData)
142 {
143 wxItemContainer::SetClientObject(n, clientData);
144 }
145
146 wxClientData* GetClientObject(int n) const
147 {
148 return wxItemContainer::GetClientObject(n);
149 }
150};
151
152#endif // wxUSE_CONTROLS
6c8a980f 153
1e6feb95 154#endif // _WX_CTRLSUB_H_BASE_
6c8a980f 155