]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/carbon/listbox.h
PCH-less build fixes
[wxWidgets.git] / include / wx / osx / carbon / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/listbox.h
3 // Purpose: wxListBox class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_LISTBOX_H_
13 #define _WX_LISTBOX_H_
14
15 // ----------------------------------------------------------------------------
16 // simple types
17 // ----------------------------------------------------------------------------
18 #include "wx/dynarray.h"
19 #include "wx/arrstr.h"
20
21 // forward decl for GetSelections()
22 class wxArrayInt;
23
24 // forward decl for wxListWidgetImpl implementation type.
25 class wxListWidgetImpl;
26
27 // List box item
28
29 WX_DEFINE_ARRAY( char* , wxListDataArray );
30
31 // ----------------------------------------------------------------------------
32 // List box control
33 // ----------------------------------------------------------------------------
34
35 class WXDLLIMPEXP_FWD_CORE wxListWidgetColumn;
36
37 class WXDLLIMPEXP_FWD_CORE wxListWidgetCellValue;
38
39 class WXDLLIMPEXP_CORE wxListBox : public wxListBoxBase
40 {
41 public:
42 // ctors and such
43 wxListBox();
44
45 wxListBox(
46 wxWindow *parent,
47 wxWindowID winid,
48 const wxPoint& pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 int n = 0, const wxString choices[] = NULL,
51 long style = 0,
52 const wxValidator& validator = wxDefaultValidator,
53 const wxString& name = wxListBoxNameStr)
54 {
55 Create(parent, winid, pos, size, n, choices, style, validator, name);
56 }
57
58 wxListBox(
59 wxWindow *parent,
60 wxWindowID winid,
61 const wxPoint& pos,
62 const wxSize& size,
63 const wxArrayString& choices,
64 long style = 0,
65 const wxValidator& validator = wxDefaultValidator,
66 const wxString& name = wxListBoxNameStr)
67 {
68 Create(parent, winid, pos, size, choices, style, validator, name);
69 }
70
71 bool Create(
72 wxWindow *parent,
73 wxWindowID winid,
74 const wxPoint& pos = wxDefaultPosition,
75 const wxSize& size = wxDefaultSize,
76 int n = 0,
77 const wxString choices[] = NULL,
78 long style = 0,
79 const wxValidator& validator = wxDefaultValidator,
80 const wxString& name = wxListBoxNameStr);
81
82 bool Create(
83 wxWindow *parent,
84 wxWindowID winid,
85 const wxPoint& pos,
86 const wxSize& size,
87 const wxArrayString& choices,
88 long style = 0,
89 const wxValidator& validator = wxDefaultValidator,
90 const wxString& name = wxListBoxNameStr);
91
92 virtual ~wxListBox();
93
94 // implement base class pure virtuals
95 virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
96
97 virtual unsigned int GetCount() const;
98 virtual wxString GetString(unsigned int n) const;
99 virtual void SetString(unsigned int n, const wxString& s);
100 virtual int FindString(const wxString& s, bool bCase = false) const;
101
102 // data callbacks
103 virtual void GetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value );
104 virtual void SetValueCallback( unsigned int n, wxListWidgetColumn* col , wxListWidgetCellValue& value );
105
106 virtual bool IsSelected(int n) const;
107 virtual int GetSelection() const;
108 virtual int GetSelections(wxArrayInt& aSelections) const;
109
110 virtual void EnsureVisible(int n);
111
112 virtual wxVisualAttributes GetDefaultAttributes() const
113 {
114 return GetClassDefaultAttributes(GetWindowVariant());
115 }
116
117 // wxCheckListBox support
118 static wxVisualAttributes
119 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
120
121 wxListWidgetImpl* GetListPeer() const;
122
123 bool MacGetBlockEvents() const { return m_blockEvents; }
124
125 protected:
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;
153
154 wxListWidgetColumn* m_textColumn;
155
156 // data storage (copied from univ)
157
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;
168
169 private:
170 DECLARE_DYNAMIC_CLASS(wxListBox)
171 DECLARE_EVENT_TABLE()
172 };
173
174 #endif // _WX_LISTBOX_H_