1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxListBox class interface
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_LISTBOX_H_BASE_
13 #define _WX_LISTBOX_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
20 #pragma interface "listboxbase.h"
27 #include "wx/control.h" // base class
29 // forward declarations are enough here
30 class WXDLLEXPORT wxArrayInt
;
31 class WXDLLEXPORT wxArrayString
;
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
37 WXDLLEXPORT_DATA(extern const wxChar
*) wxListBoxNameStr
;
39 // ----------------------------------------------------------------------------
40 // wxListBox interface is defined by the class wxListBoxBase
41 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxListBoxBase
: public wxControl
47 wxListBoxBase() { m_clientDataItemsType
= ClientData_None
; }
52 void Append(const wxString
& item
)
54 void Append(const wxString
& item
, void *clientData
)
55 { int n
= DoAppend(item
); SetClientData(n
, clientData
); }
56 void Append(const wxString
& item
, wxClientData
*clientData
)
57 { int n
= DoAppend(item
); SetClientObject(n
, clientData
); }
59 void Insert(const wxString
& item
, int pos
)
60 { DoInsert(item
, pos
); }
61 void Insert(const wxString
& item
, int pos
, void *clientData
)
62 { DoInsert(item
, pos
); SetClientData(pos
, clientData
); }
63 void Insert(const wxString
& item
, int pos
, wxClientData
*clientData
)
64 { DoInsert(item
, pos
); SetClientObject(pos
, clientData
); }
66 void InsertItems(int nItems
, const wxString
*items
, int pos
);
67 void InsertItems(const wxArrayString
& items
, int pos
)
68 { DoInsertItems(items
, pos
); }
70 void Set(int n
, const wxString
* items
, void **clientData
= NULL
);
71 void Set(const wxArrayString
& items
, void **clientData
= NULL
)
72 { DoSetItems(items
, clientData
); }
77 virtual void Clear() = 0;
78 virtual void Delete(int n
) = 0;
83 virtual int GetCount() const = 0;
84 virtual wxString
GetString(int n
) const = 0;
85 virtual void SetString(int n
, const wxString
& s
) = 0;
86 virtual int FindString(const wxString
& s
) const = 0;
91 virtual bool IsSelected(int n
) const = 0;
92 virtual void SetSelection(int n
, bool select
= TRUE
) = 0;
93 void Select(int n
) { SetSelection(n
, TRUE
); }
94 void Deselect(int n
) { SetSelection(n
, FALSE
); }
96 virtual int GetSelection() const = 0;
97 virtual int GetSelections(wxArrayInt
& aSelections
) const = 0;
99 bool SetStringSelection(const wxString
& s
, bool select
= TRUE
);
100 wxString
GetStringSelection() const;
106 void SetClientData( int n
, void* clientData
);
107 void* GetClientData( int n
) const;
109 void SetClientObject( int n
, wxClientData
* clientData
);
110 wxClientData
* GetClientObject( int n
) const;
112 // Set the specified item at the first visible item or scroll to max
114 void SetFirstItem(int n
) { DoSetFirstItem(n
); }
115 void SetFirstItem(const wxString
& s
);
117 // emulate selecting or deselecting (depending on event.GetExtraLong())
118 // the item event.GetInt() from the control
119 virtual void Command(wxCommandEvent
&event
);
121 // compatibility - these functions are deprecated, use the new ones
123 bool Selected(int n
) const { return IsSelected(n
); }
124 int Number() const { return GetCount(); }
127 // NB: due to wxGTK implementation details, DoInsert() is implemented
128 // using DoInsertItems() and not the other way round
129 void DoInsert(const wxString
& item
, int pos
)
130 { InsertItems(1, &item
, pos
); }
132 // to be implemented in derived classes
133 virtual int DoAppend(const wxString
& item
) = 0;
134 virtual void DoInsertItems(const wxArrayString
& items
, int pos
) = 0;
135 virtual void DoSetItems(const wxArrayString
& items
, void **clientData
) = 0;
137 virtual void DoSetFirstItem(int n
) = 0;
139 virtual void DoSetClientData(int n
, void* clientData
) = 0;
140 virtual void* DoGetClientData(int n
) const = 0;
141 virtual void DoSetClientObject(int n
, wxClientData
* clientData
) = 0;
142 virtual wxClientData
* DoGetClientObject(int n
) const = 0;
144 // the above pure virtuals hide these virtuals in wxWindowBase
145 virtual void DoSetClientData(void* clientData
)
146 { wxWindowBase::DoSetClientData(clientData
); };
147 virtual void* DoGetClientData() const
148 { return(wxWindowBase::DoGetClientData()); };
149 virtual void DoSetClientObject( wxClientData
* clientData
)
150 { wxWindowBase::DoSetClientObject(clientData
); };
151 virtual wxClientData
* DoGetClientObject() const
152 { return(wxWindowBase::DoGetClientObject()); };
154 // the type of the client data for the items
155 wxClientDataType m_clientDataItemsType
;
158 // ----------------------------------------------------------------------------
159 // include the platform-specific class declaration
160 // ----------------------------------------------------------------------------
162 #if defined(__WXMSW__)
163 #include "wx/msw/listbox.h"
164 #elif defined(__WXMOTIF__)
165 #include "wx/motif/listbox.h"
166 #elif defined(__WXGTK__)
167 #include "wx/gtk/listbox.h"
168 #elif defined(__WXQT__)
169 #include "wx/qt/listbox.h"
170 #elif defined(__WXMAC__)
171 #include "wx/mac/listbox.h"
172 #elif defined(__WXPM__)
173 #include "wx/os2/listbox.h"
174 #elif defined(__WXSTUBS__)
175 #include "wx/stubs/listbox.h"
178 #endif // wxUSE_LISTBOX
181 // _WX_LISTBOX_H_BASE_