]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/listbox.h
Make storing non-trivial data in wxThreadSpecificInfo possible.
[wxWidgets.git] / include / wx / osx / listbox.h
CommitLineData
6762286d 1/////////////////////////////////////////////////////////////////////////////
233f5738 2// Name: wx/osx/listbox.h
6762286d
SC
3// Purpose: wxListBox class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
6762286d
SC
7// Copyright: (c) Stefan Csomor
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_LISTBOX_H_
12#define _WX_LISTBOX_H_
13
14// ----------------------------------------------------------------------------
15// simple types
16// ----------------------------------------------------------------------------
17#include "wx/dynarray.h"
18#include "wx/arrstr.h"
19
20// forward decl for GetSelections()
21class wxArrayInt;
22
23// forward decl for wxListWidgetImpl implementation type.
24class wxListWidgetImpl;
25
26// List box item
27
28WX_DEFINE_ARRAY( char* , wxListDataArray );
29
30// ----------------------------------------------------------------------------
31// List box control
32// ----------------------------------------------------------------------------
33
34class WXDLLIMPEXP_FWD_CORE wxListWidgetColumn;
35
36class WXDLLIMPEXP_FWD_CORE wxListWidgetCellValue;
37
38class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase
39{
40public:
41 // ctors and such
42 wxListBox();
43
44 wxListBox(
45 wxWindow *parent,
46 wxWindowID winid,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 int n = 0, const wxString choices[] = NULL,
50 long style = 0,
51 const wxValidator& validator = wxDefaultValidator,
52 const wxString& name = wxListBoxNameStr)
53 {
54 Create(parent, winid, pos, size, n, choices, style, validator, name);
55 }
56
57 wxListBox(
58 wxWindow *parent,
59 wxWindowID winid,
60 const wxPoint& pos,
61 const wxSize& size,
62 const wxArrayString& choices,
63 long style = 0,
64 const wxValidator& validator = wxDefaultValidator,
65 const wxString& name = wxListBoxNameStr)
66 {
67 Create(parent, winid, pos, size, choices, style, validator, name);
68 }
69
70 bool Create(
71 wxWindow *parent,
72 wxWindowID winid,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& size = wxDefaultSize,
75 int n = 0,
76 const wxString choices[] = NULL,
77 long style = 0,
78 const wxValidator& validator = wxDefaultValidator,
79 const wxString& name = wxListBoxNameStr);
80
81 bool Create(
82 wxWindow *parent,
83 wxWindowID winid,
84 const wxPoint& pos,
85 const wxSize& size,
86 const wxArrayString& choices,
87 long style = 0,
88 const wxValidator& validator = wxDefaultValidator,
89 const wxString& name = wxListBoxNameStr);
90
91 virtual ~wxListBox();
03647350 92
6762286d
SC
93 // implement base class pure virtuals
94 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
95
96 virtual unsigned int GetCount() const;
97 virtual wxString GetString(unsigned int n) const;
98 virtual void SetString(unsigned int n, const wxString& s);
99 virtual int FindString(const wxString& s, bool bCase = false) const;
100
101 // data callbacks
102 virtual void GetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value );
103 virtual void SetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value );
03647350 104
6762286d
SC
105 virtual bool IsSelected(int n) const;
106 virtual int GetSelection() const;
107 virtual int GetSelections(wxArrayInt& aSelections) const;
108
109 virtual void EnsureVisible(int n);
110
111 virtual wxVisualAttributes GetDefaultAttributes() const
112 {
113 return GetClassDefaultAttributes(GetWindowVariant());
114 }
115
116 // wxCheckListBox support
117 static wxVisualAttributes
118 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
119
120 wxListWidgetImpl* GetListPeer() const;
03647350 121
6762286d
SC
122 bool MacGetBlockEvents() const { return m_blockEvents; }
123
124 virtual void HandleLineEvent( unsigned int n, bool doubleClick );
125protected:
126 // callback for derived classes which may have to insert additional data
127 // at a certain line - which cannot be predetermined for sorted list data
128 virtual void OnItemInserted(unsigned int pos);
129
130 virtual void DoClear();
131 virtual void DoDeleteOneItem(unsigned int n);
132
133 // from wxItemContainer
134 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
135 unsigned int pos,
136 void **clientData, wxClientDataType type);
137
138 virtual void DoSetItemClientData(unsigned int n, void* clientData);
139 virtual void* DoGetItemClientData(unsigned int n) const;
140
141 // from wxListBoxBase
142 virtual void DoSetSelection(int n, bool select);
143 virtual void DoSetFirstItem(int n);
144 virtual int DoListHitTest(const wxPoint& point) const;
145
146 // free memory (common part of Clear() and dtor)
147 // prevent collision with some BSD definitions of macro Free()
148 void FreeData();
149
150 virtual wxSize DoGetBestSize() const;
151
152 bool m_blockEvents;
03647350 153
6762286d 154 wxListWidgetColumn* m_textColumn;
03647350 155
6762286d 156 // data storage (copied from univ)
03647350 157
6762286d
SC
158 // the array containing all items (it is sorted if the listbox has
159 // wxLB_SORT style)
160 union
161 {
162 wxArrayString *unsorted;
163 wxSortedArrayString *sorted;
164 } m_strings;
165
166 // and this one the client data (either void or wxClientData)
167 wxArrayPtrVoid m_itemsClientData;
03647350 168
6762286d 169private:
4ea1bb9d
VZ
170#ifdef __WXOSX_CARBON__
171 // It needs to call our CalcAndSendEvent().
172 friend class wxMacDataBrowserListControl;
173#endif // Carbon
174
6762286d
SC
175 DECLARE_DYNAMIC_CLASS(wxListBox)
176 DECLARE_EVENT_TABLE()
177};
178
179#endif // _WX_LISTBOX_H_