]> git.saurik.com Git - wxWidgets.git/blame - include/wx/ctrlsub.h
Commented out wxAutoNSAutoreleasePool in CallOnInit()
[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
371a5b4e 9// Licence: wxWindows licence
6c8a980f
VZ
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_CTRLSUB_H_BASE_
13#define _WX_CTRLSUB_H_BASE_
14
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
6c8a980f
VZ
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 46
0e0bc921
VZ
47 // append several items at once to the control
48 void Append(const wxArrayString& strings);
49
243dbf1a
VZ
50 int Insert(const wxString& item, int pos)
51 { return DoInsert(item, pos); }
52 int Insert(const wxString& item, int pos, void *clientData);
53 int Insert(const wxString& item, int pos, wxClientData *clientData);
54
6c8a980f
VZ
55 // deleting items
56 // --------------
57
58 virtual void Clear() = 0;
59 virtual void Delete(int n) = 0;
60
61 // accessing strings
62 // -----------------
63
64 virtual int GetCount() const = 0;
a8dade3e
VZ
65 bool IsEmpty() const { return GetCount() == 0; }
66
6c8a980f
VZ
67 virtual wxString GetString(int n) const = 0;
68 virtual void SetString(int n, const wxString& s) = 0;
69 virtual int FindString(const wxString& s) const = 0;
70
71 // selection
72 // ---------
73
74 virtual void Select(int n) = 0;
75 virtual int GetSelection() const = 0;
76
77 wxString GetStringSelection() const;
78
79 // misc
80 // ----
81
82 // client data stuff
83 void SetClientData(int n, void* clientData);
84 void* GetClientData(int n) const;
85
86 void SetClientObject(int n, wxClientData* clientData);
87 wxClientData* GetClientObject(int n) const;
88
89 bool HasClientObjectData() const
1e6feb95 90 { return m_clientDataItemsType == wxClientData_Object; }
6c8a980f 91 bool HasClientUntypedData() const
1e6feb95 92 { return m_clientDataItemsType == wxClientData_Void; }
6c8a980f 93
62e26542 94#if WXWIN_COMPATIBILITY_2_2
6c8a980f
VZ
95 // compatibility - these functions are deprecated, use the new ones
96 // instead
97 int Number() const { return GetCount(); }
62e26542 98#endif // WXWIN_COMPATIBILITY_2_2
1e6feb95 99
6c8a980f
VZ
100protected:
101 virtual int DoAppend(const wxString& item) = 0;
243dbf1a 102 virtual int DoInsert(const wxString& item, int pos) = 0;
6c8a980f
VZ
103
104 virtual void DoSetItemClientData(int n, void* clientData) = 0;
105 virtual void* DoGetItemClientData(int n) const = 0;
106 virtual void DoSetItemClientObject(int n, wxClientData* clientData) = 0;
107 virtual wxClientData* DoGetItemClientObject(int n) const = 0;
108
109 // the type of the client data for the items
110 wxClientDataType m_clientDataItemsType;
111};
112
1e6feb95
VZ
113class WXDLLEXPORT wxControlWithItems : public wxControl, public wxItemContainer
114{
115public:
7c720ce6
GD
116 wxControlWithItems() { }
117 virtual ~wxControlWithItems();
118
1e6feb95
VZ
119 // we have to redefine these functions here to avoid ambiguities in classes
120 // deriving from us which would arise otherwise because both base classses
121 // have the methods with the same names - hopefully, a smart compiler can
122 // optimize away these simple inline wrappers so we don't suffer much from
123 // this
124
125 void SetClientData(void *data)
126 {
127 wxControl::SetClientData(data);
128 }
129
130 void *GetClientData() const
131 {
132 return wxControl::GetClientData();
133 }
134
135 void SetClientObject(wxClientData *data)
136 {
137 wxControl::SetClientObject(data);
138 }
139
140 wxClientData *GetClientObject() const
141 {
142 return wxControl::GetClientObject();
143 }
144
145 void SetClientData(int n, void* clientData)
146 {
147 wxItemContainer::SetClientData(n, clientData);
148 }
149
150 void* GetClientData(int n) const
151 {
152 return wxItemContainer::GetClientData(n);
153 }
154
155 void SetClientObject(int n, wxClientData* clientData)
156 {
157 wxItemContainer::SetClientObject(n, clientData);
158 }
159
160 wxClientData* GetClientObject(int n) const
161 {
162 return wxItemContainer::GetClientObject(n);
163 }
164};
165
166#endif // wxUSE_CONTROLS
6c8a980f 167
1e6feb95 168#endif // _WX_CTRLSUB_H_BASE_
6c8a980f 169