]> git.saurik.com Git - wxWidgets.git/blob - src/mac/listbox.cpp
Did somework on the generic dialogs,
[wxWidgets.git] / src / mac / listbox.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: listbox.cpp
3 // Purpose: wxListBox
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "listbox.h"
14 #endif
15
16 #include "wx/listbox.h"
17 #include "wx/settings.h"
18 #include "wx/dynarray.h"
19 #include "wx/log.h"
20
21 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
23 #endif
24
25 // ============================================================================
26 // list box control implementation
27 // ============================================================================
28
29 // Listbox item
30 wxListBox::wxListBox()
31 {
32 m_noItems = 0;
33 m_selected = 0;
34 }
35
36 bool wxListBox::Create(wxWindow *parent, wxWindowID id,
37 const wxPoint& pos,
38 const wxSize& size,
39 int n, const wxString choices[],
40 long style,
41 const wxValidator& validator,
42 const wxString& name)
43 {
44 m_noItems = n;
45 m_selected = 0;
46
47 SetName(name);
48 SetValidator(validator);
49
50 if (parent) parent->AddChild(this);
51
52 wxSystemSettings settings;
53 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
54
55 m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
56
57 // TODO create listbox
58
59 return FALSE;
60 }
61
62 wxListBox::~wxListBox()
63 {
64 }
65
66 void wxListBox::SetFirstItem(int N)
67 {
68 // TODO
69 }
70
71 void wxListBox::SetFirstItem(const wxString& s)
72 {
73 // TODO
74 }
75
76 void wxListBox::Delete(int N)
77 {
78 m_noItems --;
79 // TODO
80 }
81
82 void wxListBox::Append(const wxString& item)
83 {
84 m_noItems ++;
85
86 // TODO
87 }
88
89 void wxListBox::Append(const wxString& item, char *Client_data)
90 {
91 m_noItems ++;
92
93 // TODO
94 }
95
96 void wxListBox::Set(int n, const wxString *choices, char** clientData)
97 {
98 m_noItems = n;
99
100 // TODO
101 }
102
103 int wxListBox::FindString(const wxString& s) const
104 {
105 // TODO
106 return -1;
107 }
108
109 void wxListBox::Clear()
110 {
111 m_noItems = 0;
112 // TODO
113 }
114
115 void wxListBox::SetSelection(int N, bool select)
116 {
117 // TODO
118 }
119
120 bool wxListBox::Selected(int N) const
121 {
122 // TODO
123 return FALSE;
124 }
125
126 void wxListBox::Deselect(int N)
127 {
128 // TODO
129 }
130
131 char *wxListBox::GetClientData(int N) const
132 {
133 // TODO
134 return (char *)NULL;
135 }
136
137 void wxListBox::SetClientData(int N, char *Client_data)
138 {
139 // TODO
140 }
141
142 // Return number of selections and an array of selected integers
143 int wxListBox::GetSelections(wxArrayInt& aSelections) const
144 {
145 aSelections.Empty();
146
147 /* TODO
148 if ((m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED))
149 {
150 int no_sel = ??
151 for ( int n = 0; n < no_sel; n++ )
152 aSelections.Add(??);
153
154 return no_sel;
155 }
156 else // single-selection listbox
157 {
158 aSelections.Add(??);
159
160 return 1;
161 }
162 */
163 return 0;
164 }
165
166 // Get single selection, for single choice list items
167 int wxListBox::GetSelection() const
168 {
169 // TODO
170 return -1;
171 }
172
173 // Find string for position
174 wxString wxListBox::GetString(int N) const
175 {
176 // TODO
177 return wxString("");
178 }
179
180 void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags)
181 {
182 // TODO
183 }
184
185 void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
186 {
187 m_noItems += nItems;
188
189 // TODO
190 }
191
192 void wxListBox::SetString(int N, const wxString& s)
193 {
194 // TODO
195 }
196
197 int wxListBox::Number () const
198 {
199 return m_noItems;
200 }
201
202 // For single selection items only
203 wxString wxListBox::GetStringSelection () const
204 {
205 int sel = GetSelection ();
206 if (sel > -1)
207 return this->GetString (sel);
208 else
209 return wxString("");
210 }
211
212 bool wxListBox::SetStringSelection (const wxString& s, bool flag)
213 {
214 int sel = FindString (s);
215 if (sel > -1)
216 {
217 SetSelection (sel, flag);
218 return TRUE;
219 }
220 else
221 return FALSE;
222 }
223
224 void wxListBox::Command (wxCommandEvent & event)
225 {
226 if (event.m_extraLong)
227 SetSelection (event.m_commandInt);
228 else
229 {
230 Deselect (event.m_commandInt);
231 return;
232 }
233 ProcessCommand (event);
234 }
235