]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/listbox.h
Rework the GTK WebKit backend history to remove the need for the map between wxWebHis...
[wxWidgets.git] / include / wx / osx / listbox.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/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 virtual void HandleLineEvent( unsigned int n, bool doubleClick );
126 protected:
127 // callback for derived classes which may have to insert additional data
128 // at a certain line - which cannot be predetermined for sorted list data
129 virtual void OnItemInserted(unsigned int pos);
130
131 virtual void DoClear();
132 virtual void DoDeleteOneItem(unsigned int n);
133
134 // from wxItemContainer
135 virtual int DoInsertItems(const wxArrayStringsAdapter& items,
136 unsigned int pos,
137 void **clientData, wxClientDataType type);
138
139 virtual void DoSetItemClientData(unsigned int n, void* clientData);
140 virtual void* DoGetItemClientData(unsigned int n) const;
141
142 // from wxListBoxBase
143 virtual void DoSetSelection(int n, bool select);
144 virtual void DoSetFirstItem(int n);
145 virtual int DoListHitTest(const wxPoint& point) const;
146
147 // free memory (common part of Clear() and dtor)
148 // prevent collision with some BSD definitions of macro Free()
149 void FreeData();
150
151 virtual wxSize DoGetBestSize() const;
152
153 bool m_blockEvents;
154
155 wxListWidgetColumn* m_textColumn;
156
157 // data storage (copied from univ)
158
159 // the array containing all items (it is sorted if the listbox has
160 // wxLB_SORT style)
161 union
162 {
163 wxArrayString *unsorted;
164 wxSortedArrayString *sorted;
165 } m_strings;
166
167 // and this one the client data (either void or wxClientData)
168 wxArrayPtrVoid m_itemsClientData;
169
170 private:
171 #ifdef __WXOSX_CARBON__
172 // It needs to call our CalcAndSendEvent().
173 friend class wxMacDataBrowserListControl;
174 #endif // Carbon
175
176 DECLARE_DYNAMIC_CLASS(wxListBox)
177 DECLARE_EVENT_TABLE()
178 };
179
180 #endif // _WX_LISTBOX_H_