Get the OS X Cocoa native combobox building by having the native code compile if...
[wxWidgets.git] / src / osx / combobox_osx.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/combobox_osx.cpp
3 // Purpose: wxComboBox class using HIView ComboBox
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id: combobox_osx.cpp 58318 2009-01-23 08:36:16Z RR $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_COMBOBOX && defined(wxOSX_USE_NATIVE_COMBOBOX)
15
16 #include "wx/combobox.h"
17 #include "wx/osx/private.h"
18
19 #ifndef WX_PRECOMP
20 #endif
21
22 // work in progress
23
24 IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
25
26 wxComboBox::~wxComboBox()
27 {
28 }
29
30 void wxComboBox::Init()
31 {
32 }
33
34 bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
35 const wxString& value,
36 const wxPoint& pos,
37 const wxSize& size,
38 const wxArrayString& choices,
39 long style,
40 const wxValidator& validator,
41 const wxString& name)
42 {
43 wxCArrayString chs( choices );
44
45 return Create( parent, id, value, pos, size, chs.GetCount(),
46 chs.GetStrings(), style, validator, name );
47 }
48
49 bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
50 const wxString& value,
51 const wxPoint& pos,
52 const wxSize& size,
53 int n, const wxString choices[],
54 long style,
55 const wxValidator& validator,
56 const wxString& name)
57 {
58 m_text = NULL;
59 m_choice = NULL;
60
61 m_macIsUserPane = false;
62
63 if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
64 return false;
65
66 m_peer = wxWidgetImpl::CreateComboBox( this, parent, id, NULL, pos, size, style, GetExtraStyle() );
67
68 MacPostControlCreate( pos, size );
69
70 Append(n, choices);
71
72 // Set the first item as being selected
73 if (n > 0)
74 SetSelection( 0 );
75
76 // Needed because it is a wxControlWithItems
77 SetInitialSize( size );
78
79 return true;
80 }
81
82 void wxComboBox::DelegateTextChanged( const wxString& value )
83 {
84 SetStringSelection( value );
85 }
86
87 void wxComboBox::DelegateChoice( const wxString& value )
88 {
89 SetStringSelection( value );
90 }
91
92 wxString wxComboBox::GetValue() const
93 {
94 wxFAIL_MSG("Method Not Implemented.");
95 return wxEmptyString;
96 }
97
98 void wxComboBox::SetValue(const wxString& value)
99 {
100 wxFAIL_MSG("Method Not Implemented.");
101 }
102
103 // Clipboard operations
104 void wxComboBox::Copy()
105 {
106 wxFAIL_MSG("Method Not Implemented.");
107 }
108
109 void wxComboBox::Cut()
110 {
111 wxFAIL_MSG("Method Not Implemented.");
112 }
113
114 void wxComboBox::Paste()
115 {
116 wxFAIL_MSG("Method Not Implemented.");
117 }
118
119 void wxComboBox::SetEditable(bool editable)
120 {
121 wxFAIL_MSG("Method Not Implemented.");
122 }
123
124 void wxComboBox::SetInsertionPoint(long pos)
125 {
126 wxFAIL_MSG("Method Not Implemented.");
127 }
128
129 void wxComboBox::SetInsertionPointEnd()
130 {
131 wxFAIL_MSG("Method Not Implemented.");
132 }
133
134 long wxComboBox::GetInsertionPoint() const
135 {
136 wxFAIL_MSG("Method Not Implemented.");
137 return 0;
138 }
139
140 wxTextPos wxComboBox::GetLastPosition() const
141 {
142 wxFAIL_MSG("Method Not Implemented.");
143 return 0;
144 }
145
146 void wxComboBox::Replace(long from, long to, const wxString& value)
147 {
148 wxFAIL_MSG("Method Not Implemented.");
149 }
150
151 void wxComboBox::Remove(long from, long to)
152 {
153 wxFAIL_MSG("Method Not Implemented.");
154 }
155
156 void wxComboBox::SetSelection(long from, long to)
157 {
158 wxFAIL_MSG("Method Not Implemented.");
159 }
160
161 int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
162 unsigned int pos,
163 void **clientData, wxClientDataType type)
164 {
165 wxFAIL_MSG("Method Not Implemented.");
166 return 0;
167 }
168
169 void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
170 {
171 wxFAIL_MSG("Method Not Implemented.");
172 }
173
174 void* wxComboBox::DoGetItemClientData(unsigned int n) const
175 {
176 wxFAIL_MSG("Method Not Implemented.");
177 return NULL;
178 }
179
180 unsigned int wxComboBox::GetCount() const
181 {
182 wxFAIL_MSG("Method Not Implemented.");
183 return 0;
184 }
185
186 void wxComboBox::DoDeleteOneItem(unsigned int n)
187 {
188 wxFAIL_MSG("Method Not Implemented.");
189 }
190
191 void wxComboBox::DoClear()
192 {
193 wxFAIL_MSG("Method Not Implemented.");
194 }
195
196 int wxComboBox::GetSelection() const
197 {
198 wxFAIL_MSG("Method Not Implemented.");
199 return 0;
200 }
201
202 void wxComboBox::GetSelection(long *from, long *to) const
203 {
204 wxFAIL_MSG("Method Not Implemented.");
205 }
206
207 void wxComboBox::SetSelection(int n)
208 {
209 wxFAIL_MSG("Method Not Implemented.");
210 }
211
212 int wxComboBox::FindString(const wxString& s, bool bCase) const
213 {
214 wxFAIL_MSG("Method Not Implemented.");
215 return 0;
216 }
217
218 wxString wxComboBox::GetString(unsigned int n) const
219 {
220 wxFAIL_MSG("Method Not Implemented.");
221 return wxEmptyString;
222 }
223
224 wxString wxComboBox::GetStringSelection() const
225 {
226 wxFAIL_MSG("Method Not Implemented.");
227 return wxEmptyString;
228 }
229
230 void wxComboBox::SetString(unsigned int n, const wxString& s)
231 {
232 wxFAIL_MSG("Method Not Implemented.");
233 }
234
235 bool wxComboBox::IsEditable() const
236 {
237 return !HasFlag(wxCB_READONLY);
238 }
239
240 void wxComboBox::Undo()
241 {
242 wxFAIL_MSG("Method Not Implemented.");
243 }
244
245 void wxComboBox::Redo()
246 {
247 wxFAIL_MSG("Method Not Implemented.");
248 }
249
250 void wxComboBox::SelectAll()
251 {
252 wxFAIL_MSG("Method Not Implemented.");
253 }
254
255 bool wxComboBox::CanCopy() const
256 {
257 wxFAIL_MSG("Method Not Implemented.");
258 return false;
259 }
260
261 bool wxComboBox::CanCut() const
262 {
263 wxFAIL_MSG("Method Not Implemented.");
264 return false;
265 }
266
267 bool wxComboBox::CanPaste() const
268 {
269 wxFAIL_MSG("Method Not Implemented.");
270 return false;
271 }
272
273 bool wxComboBox::CanUndo() const
274 {
275 wxFAIL_MSG("Method Not Implemented.");
276 return false;
277 }
278
279 bool wxComboBox::CanRedo() const
280 {
281 wxFAIL_MSG("Method Not Implemented.");
282 return false;
283 }
284
285 void wxComboBox::EnableTextChangedEvents(bool enable)
286 {
287 wxFAIL_MSG("Method Not Implemented.");
288 }
289
290 void wxComboBox::WriteText(const wxString& text)
291 {
292 wxFAIL_MSG("Method Not Implemented.");
293 }
294
295 wxString wxComboBox::DoGetValue() const
296 {
297 wxFAIL_MSG("Method Not Implemented.");
298 return wxEmptyString;
299 }
300
301 wxClientDataType wxComboBox::GetClientDataType() const
302 {
303 wxFAIL_MSG("Method Not Implemented.");
304 return wxClientData_None;
305 }
306
307 void wxComboBox::SetClientDataType(wxClientDataType clientDataItemsType)
308 {
309 wxFAIL_MSG("Method Not Implemented.");
310 }
311
312 bool wxComboBox::OSXHandleClicked( double timestampsec )
313 {
314 wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
315 event.SetInt(GetSelection());
316 event.SetEventObject(this);
317 event.SetString(GetStringSelection());
318 ProcessCommand(event);
319 return true;
320 }
321
322 #endif // wxUSE_COMBOBOX && defined(wxOSX_USE_NATIVE_COMBOBOX)