]>
Commit | Line | Data |
---|---|---|
53010e52 | 1 | ///////////////////////////////////////////////////////////////////////////// |
11e62fe6 | 2 | // Name: src/gtk/combobox.cpp |
53010e52 RR |
3 | // Purpose: |
4 | // Author: Robert Roebling | |
dbf858b5 | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 7 | // Licence: wxWindows licence |
53010e52 RR |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
14f355c2 VS |
10 | // For compilers that support precompilation, includes "wx.h". |
11 | #include "wx/wxprec.h" | |
12 | ||
dcf924a3 RR |
13 | #if wxUSE_COMBOBOX |
14 | ||
8228b893 WS |
15 | #include "wx/combobox.h" |
16 | ||
88a7a4e1 WS |
17 | #ifndef WX_PRECOMP |
18 | #include "wx/intl.h" | |
9eddec69 | 19 | #include "wx/settings.h" |
fec9cc08 | 20 | #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED |
aaa6d89a | 21 | #include "wx/arrstr.h" |
88a7a4e1 WS |
22 | #endif |
23 | ||
1efb5db8 MR |
24 | // We use GtkCombo which has been deprecated since GTK+ 2.3.0 |
25 | // in favour of GtkComboBox for <GTK2.4 runtime | |
5b008dd7 MR |
26 | // We also use GtkList |
27 | #ifdef GTK_DISABLE_DEPRECATED | |
1efb5db8 MR |
28 | #undef GTK_DISABLE_DEPRECATED |
29 | #endif | |
9e691f46 | 30 | #include "wx/gtk/private.h" |
83624f79 | 31 | |
47908e25 RR |
32 | //----------------------------------------------------------------------------- |
33 | // data | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | extern bool g_blockEventsOnDrag; | |
40eb3606 VZ |
37 | static int g_SelectionBeforePopup = wxID_NONE; // this means the popup is hidden |
38 | ||
78b3b018 RR |
39 | //----------------------------------------------------------------------------- |
40 | // "changed" - typing and list item matches get changed, select-child | |
41 | // if it doesn't match an item then just get a single changed | |
42 | //----------------------------------------------------------------------------- | |
43 | ||
865bb325 | 44 | extern "C" { |
78b3b018 | 45 | static void |
1fb33bdb | 46 | gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) |
78b3b018 RR |
47 | { |
48 | if (g_isIdle) wxapp_install_idle_handler(); | |
49 | ||
50 | if (combo->m_ignoreNextUpdate) | |
150e31d2 | 51 | { |
7d8268a1 | 52 | combo->m_ignoreNextUpdate = false; |
78b3b018 RR |
53 | return; |
54 | } | |
55 | ||
56 | if (!combo->m_hasVMT) return; | |
57 | ||
58 | wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); | |
59 | event.SetString( combo->GetValue() ); | |
60 | event.SetEventObject( combo ); | |
61 | combo->GetEventHandler()->ProcessEvent( event ); | |
62 | } | |
865bb325 | 63 | } |
78b3b018 | 64 | |
865bb325 | 65 | extern "C" { |
78b3b018 | 66 | static void |
1fb33bdb | 67 | gtkcombo_dummy_callback(GtkEntry *WXUNUSED(entry), GtkCombo *WXUNUSED(combo)) |
78b3b018 RR |
68 | { |
69 | } | |
865bb325 | 70 | } |
78b3b018 | 71 | |
865bb325 | 72 | extern "C" { |
9d6a9fdd | 73 | static void |
1fb33bdb | 74 | gtkcombo_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) |
7d8268a1 | 75 | { |
9d6a9fdd RR |
76 | // when the popup is hidden, throw a SELECTED event only if the combobox |
77 | // selection changed. | |
3dbfe8f4 VZ |
78 | const int curSelection = combo->GetCurrentSelection(); |
79 | ||
80 | const bool hasChanged = curSelection != g_SelectionBeforePopup; | |
81 | ||
82 | // reset the selection flag to value meaning that it is hidden and do it | |
83 | // now, before generating the events, so that GetSelection() returns the | |
84 | // new value from the event handler | |
85 | g_SelectionBeforePopup = wxID_NONE; | |
86 | ||
87 | if ( hasChanged ) | |
9d6a9fdd RR |
88 | { |
89 | wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); | |
90 | event.SetInt( curSelection ); | |
91 | event.SetString( combo->GetStringSelection() ); | |
92 | event.SetEventObject( combo ); | |
93 | combo->GetEventHandler()->ProcessEvent( event ); | |
345bdf13 KH |
94 | |
95 | // for consistency with the other ports, send TEXT event | |
96 | wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); | |
97 | event2.SetString( combo->GetStringSelection() ); | |
98 | event2.SetEventObject( combo ); | |
99 | combo->GetEventHandler()->ProcessEvent( event2 ); | |
9d6a9fdd | 100 | } |
9d6a9fdd | 101 | } |
865bb325 | 102 | } |
9d6a9fdd | 103 | |
865bb325 | 104 | extern "C" { |
9d6a9fdd | 105 | static void |
1fb33bdb | 106 | gtkcombo_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo) |
9d6a9fdd RR |
107 | { |
108 | // store the combobox selection value before the popup is shown | |
40eb3606 | 109 | g_SelectionBeforePopup = combo->GetCurrentSelection(); |
9d6a9fdd | 110 | } |
865bb325 | 111 | } |
9d6a9fdd | 112 | |
53010e52 | 113 | //----------------------------------------------------------------------------- |
461573cc | 114 | // "select-child" - click/cursor get select-child, changed, select-child |
47908e25 | 115 | //----------------------------------------------------------------------------- |
47908e25 | 116 | |
865bb325 | 117 | extern "C" { |
8a85884a | 118 | static void |
1fb33bdb | 119 | gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo ) |
53010e52 | 120 | { |
acfd422a | 121 | if (g_isIdle) wxapp_install_idle_handler(); |
8a85884a | 122 | |
a2053b27 | 123 | if (!combo->m_hasVMT) return; |
30ed6e5c | 124 | |
acfd422a | 125 | if (g_blockEventsOnDrag) return; |
805dd538 | 126 | |
40eb3606 | 127 | int curSelection = combo->GetCurrentSelection(); |
30ed6e5c | 128 | |
3c4e4af6 RR |
129 | if (combo->m_prevSelection == curSelection) return; |
130 | ||
131 | GtkWidget *list = GTK_COMBO(combo->m_widget)->list; | |
132 | gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection ); | |
150e31d2 | 133 | |
159b66c0 RR |
134 | combo->m_prevSelection = curSelection; |
135 | ||
78b3b018 RR |
136 | // Quickly set the value of the combo box |
137 | // as GTK+ does that only AFTER the event | |
138 | // is sent. | |
9fa72bd2 | 139 | g_signal_handlers_disconnect_by_func (GTK_COMBO (combo->GetHandle())->entry, |
1fb33bdb | 140 | (gpointer) gtkcombo_text_changed_callback, |
9fa72bd2 | 141 | combo); |
78b3b018 | 142 | combo->SetValue( combo->GetStringSelection() ); |
9fa72bd2 | 143 | g_signal_connect_after (GTK_COMBO (combo->GetHandle())->entry, "changed", |
1fb33bdb | 144 | G_CALLBACK (gtkcombo_text_changed_callback), combo); |
78b3b018 | 145 | |
40eb3606 | 146 | // throw a SELECTED event only if the combobox popup is hidden (wxID_NONE) |
1fb33bdb | 147 | // because when combobox popup is shown, gtkcombo_combo_select_child_callback is |
9d6a9fdd RR |
148 | // called each times the mouse is over an item with a pressed button so a lot |
149 | // of SELECTED event could be generated if the user keep the mouse button down | |
150 | // and select other items ... | |
40eb3606 | 151 | if (g_SelectionBeforePopup == wxID_NONE) |
9d6a9fdd RR |
152 | { |
153 | wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); | |
154 | event.SetInt( curSelection ); | |
155 | event.SetString( combo->GetStringSelection() ); | |
156 | event.SetEventObject( combo ); | |
157 | combo->GetEventHandler()->ProcessEvent( event ); | |
0c77152e | 158 | |
345bdf13 | 159 | // for consistency with the other ports, don't generate text update |
40eb3606 VZ |
160 | // events while the user is browsing the combobox neither |
161 | wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); | |
162 | event2.SetString( combo->GetValue() ); | |
163 | event2.SetEventObject( combo ); | |
164 | combo->GetEventHandler()->ProcessEvent( event2 ); | |
165 | } | |
461573cc | 166 | } |
865bb325 | 167 | } |
461573cc | 168 | |
590f50d6 RR |
169 | #ifdef __WXGTK24__ |
170 | extern "C" { | |
171 | static void | |
172 | gtkcombobox_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) | |
173 | { | |
174 | if (g_isIdle) wxapp_install_idle_handler(); | |
175 | ||
176 | if (!combo->m_hasVMT) return; | |
177 | ||
178 | wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); | |
179 | event.SetString( combo->GetValue() ); | |
180 | event.SetEventObject( combo ); | |
181 | combo->GetEventHandler()->ProcessEvent( event ); | |
182 | } | |
183 | } | |
184 | ||
185 | extern "C" { | |
186 | static void | |
187 | gtkcombobox_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) | |
188 | { | |
189 | if (g_isIdle) wxapp_install_idle_handler(); | |
190 | ||
191 | if (!combo->m_hasVMT) return; | |
ddd53873 RR |
192 | |
193 | if (combo->GetSelection() == -1) | |
194 | return; | |
590f50d6 RR |
195 | |
196 | wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); | |
197 | event.SetInt( combo->GetSelection() ); | |
198 | event.SetString( combo->GetStringSelection() ); | |
199 | event.SetEventObject( combo ); | |
200 | combo->GetEventHandler()->ProcessEvent( event ); | |
201 | } | |
202 | } | |
a73ae836 | 203 | |
590f50d6 RR |
204 | #endif |
205 | ||
e1e955e1 RR |
206 | //----------------------------------------------------------------------------- |
207 | // wxComboBox | |
53010e52 RR |
208 | //----------------------------------------------------------------------------- |
209 | ||
210 | IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) | |
211 | ||
b4071e91 | 212 | BEGIN_EVENT_TABLE(wxComboBox, wxControl) |
fd0eed64 | 213 | EVT_SIZE(wxComboBox::OnSize) |
8a85884a | 214 | EVT_CHAR(wxComboBox::OnChar) |
150e31d2 JS |
215 | |
216 | EVT_MENU(wxID_CUT, wxComboBox::OnCut) | |
217 | EVT_MENU(wxID_COPY, wxComboBox::OnCopy) | |
218 | EVT_MENU(wxID_PASTE, wxComboBox::OnPaste) | |
219 | EVT_MENU(wxID_UNDO, wxComboBox::OnUndo) | |
220 | EVT_MENU(wxID_REDO, wxComboBox::OnRedo) | |
221 | EVT_MENU(wxID_CLEAR, wxComboBox::OnDelete) | |
222 | EVT_MENU(wxID_SELECTALL, wxComboBox::OnSelectAll) | |
223 | ||
224 | EVT_UPDATE_UI(wxID_CUT, wxComboBox::OnUpdateCut) | |
225 | EVT_UPDATE_UI(wxID_COPY, wxComboBox::OnUpdateCopy) | |
226 | EVT_UPDATE_UI(wxID_PASTE, wxComboBox::OnUpdatePaste) | |
227 | EVT_UPDATE_UI(wxID_UNDO, wxComboBox::OnUpdateUndo) | |
228 | EVT_UPDATE_UI(wxID_REDO, wxComboBox::OnUpdateRedo) | |
229 | EVT_UPDATE_UI(wxID_CLEAR, wxComboBox::OnUpdateDelete) | |
230 | EVT_UPDATE_UI(wxID_SELECTALL, wxComboBox::OnUpdateSelectAll) | |
b4071e91 RR |
231 | END_EVENT_TABLE() |
232 | ||
584ad2a3 MB |
233 | bool wxComboBox::Create( wxWindow *parent, wxWindowID id, |
234 | const wxString& value, | |
235 | const wxPoint& pos, const wxSize& size, | |
236 | const wxArrayString& choices, | |
237 | long style, const wxValidator& validator, | |
238 | const wxString& name ) | |
239 | { | |
240 | wxCArrayString chs(choices); | |
241 | ||
242 | return Create( parent, id, value, pos, size, chs.GetCount(), | |
243 | chs.GetStrings(), style, validator, name ); | |
244 | } | |
245 | ||
fd0eed64 RR |
246 | bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, |
247 | const wxPoint& pos, const wxSize& size, | |
248 | int n, const wxString choices[], | |
805dd538 VZ |
249 | long style, const wxValidator& validator, |
250 | const wxString& name ) | |
53010e52 | 251 | { |
7d8268a1 WS |
252 | m_ignoreNextUpdate = false; |
253 | m_needParent = true; | |
254 | m_acceptsFocus = true; | |
159b66c0 | 255 | m_prevSelection = 0; |
805dd538 | 256 | |
db434467 | 257 | if (!PreCreation( parent, pos, size ) || |
4dcaf11a RR |
258 | !CreateBase( parent, id, pos, size, style, validator, name )) |
259 | { | |
223d09f6 | 260 | wxFAIL_MSG( wxT("wxComboBox creation failed") ); |
7d8268a1 | 261 | return false; |
4dcaf11a | 262 | } |
6de97a3b | 263 | |
590f50d6 RR |
264 | #ifdef __WXGTK24__ |
265 | if (!gtk_check_version(2,4,0)) | |
266 | { | |
267 | m_widget = gtk_combo_box_entry_new_text(); | |
268 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
8228b893 | 269 | |
590f50d6 | 270 | gtk_entry_set_editable( GTK_ENTRY( GTK_BIN(m_widget)->child ), TRUE ); |
8228b893 | 271 | |
590f50d6 RR |
272 | for (int i = 0; i < n; i++) |
273 | { | |
274 | gtk_combo_box_append_text( combobox, wxGTK_CONV( choices[i] ) ); | |
30ed6e5c | 275 | |
590f50d6 RR |
276 | m_clientDataList.Append( (wxObject*)NULL ); |
277 | m_clientObjectList.Append( (wxObject*)NULL ); | |
278 | } | |
279 | } | |
280 | else | |
281 | #endif | |
282 | { | |
283 | m_widget = gtk_combo_new(); | |
284 | GtkCombo* combo = GTK_COMBO(m_widget); | |
8228b893 | 285 | |
590f50d6 RR |
286 | // Disable GTK's broken events ... |
287 | g_signal_handler_disconnect (combo->entry, combo->entry_change_id); | |
288 | // ... and add surrogate handler. | |
289 | combo->entry_change_id = g_signal_connect (combo->entry, "changed", | |
1fb33bdb | 290 | G_CALLBACK (gtkcombo_dummy_callback), |
9fa72bd2 | 291 | combo); |
805dd538 | 292 | |
590f50d6 RR |
293 | // make it more useable |
294 | gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget), TRUE ); | |
30ed6e5c | 295 | |
590f50d6 RR |
296 | // and case-sensitive |
297 | gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE ); | |
3ca6a5f0 | 298 | |
590f50d6 | 299 | if (style & wxNO_BORDER) |
7d1fea10 | 300 | g_object_set (combo->entry, "has-frame", FALSE, NULL ); |
8228b893 | 301 | |
590f50d6 | 302 | GtkWidget *list = combo->list; |
7d8268a1 | 303 | |
590f50d6 RR |
304 | for (int i = 0; i < n; i++) |
305 | { | |
306 | GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( choices[i] ) ); | |
805dd538 | 307 | |
590f50d6 RR |
308 | m_clientDataList.Append( (wxObject*)NULL ); |
309 | m_clientObjectList.Append( (wxObject*)NULL ); | |
805dd538 | 310 | |
590f50d6 | 311 | gtk_container_add( GTK_CONTAINER(list), list_item ); |
805dd538 | 312 | |
590f50d6 RR |
313 | gtk_widget_show( list_item ); |
314 | } | |
fd0eed64 | 315 | } |
805dd538 | 316 | |
590f50d6 | 317 | |
f03fc89f | 318 | m_parent->DoAddChild( this ); |
30ed6e5c | 319 | |
590f50d6 RR |
320 | GtkEntry *entry = NULL; |
321 | #ifdef __WXGTK24__ | |
322 | if (!gtk_check_version(2,4,0)) | |
323 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
324 | else | |
8228b893 | 325 | #endif |
590f50d6 | 326 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 327 | |
590f50d6 | 328 | m_focusWidget = GTK_WIDGET( entry ); |
805dd538 | 329 | |
abdeb9e7 | 330 | PostCreation(size); |
53010e52 | 331 | |
590f50d6 RR |
332 | #ifdef __WXGTK24__ |
333 | if (!gtk_check_version(2,4,0)) | |
334 | ConnectWidget( m_widget ); | |
335 | else | |
336 | #endif | |
337 | ConnectWidget( GTK_COMBO(m_widget)->button ); | |
805dd538 | 338 | |
590f50d6 RR |
339 | #ifdef __WXGTK24__ |
340 | if (!gtk_check_version(2,4,0)) | |
341 | { | |
342 | gtk_entry_set_text( entry, wxGTK_CONV(value) ); | |
8228b893 | 343 | |
590f50d6 RR |
344 | if (style & wxCB_READONLY) |
345 | gtk_entry_set_editable( entry, FALSE ); | |
8228b893 | 346 | |
590f50d6 RR |
347 | g_signal_connect_after (entry, "changed", |
348 | G_CALLBACK (gtkcombobox_text_changed_callback), this); | |
8228b893 | 349 | |
590f50d6 RR |
350 | g_signal_connect_after (m_widget, "changed", |
351 | G_CALLBACK (gtkcombobox_changed_callback), this); | |
f4322df6 | 352 | |
590f50d6 RR |
353 | } |
354 | else | |
355 | #endif | |
356 | { | |
357 | GtkCombo *combo = GTK_COMBO(m_widget); | |
358 | // MSW's combo box shows the value and the selection is -1 | |
359 | gtk_entry_set_text( entry, wxGTK_CONV(value) ); | |
360 | gtk_list_unselect_all( GTK_LIST(combo->list) ); | |
805dd538 | 361 | |
590f50d6 RR |
362 | if (style & wxCB_READONLY) |
363 | gtk_entry_set_editable( entry, FALSE ); | |
a260fe6a | 364 | |
590f50d6 RR |
365 | // "show" and "hide" events are generated when user click on the combobox button which popups a list |
366 | // this list is the "popwin" gtk widget | |
367 | g_signal_connect (GTK_COMBO(combo)->popwin, "hide", | |
1fb33bdb | 368 | G_CALLBACK (gtkcombo_popup_hide_callback), this); |
590f50d6 | 369 | g_signal_connect (GTK_COMBO(combo)->popwin, "show", |
1fb33bdb | 370 | G_CALLBACK (gtkcombo_popup_show_callback), this); |
590f50d6 | 371 | g_signal_connect_after (combo->list, "select-child", |
1fb33bdb | 372 | G_CALLBACK (gtkcombo_combo_select_child_callback), |
9fa72bd2 | 373 | this); |
590f50d6 RR |
374 | g_signal_connect_after (entry, "changed", |
375 | G_CALLBACK (gtkcombo_text_changed_callback), this); | |
590f50d6 | 376 | } |
805dd538 | 377 | |
170acdc9 | 378 | SetInitialSize(size); // need this too because this is a wxControlWithItems |
805dd538 | 379 | |
7d8268a1 | 380 | return true; |
fd0eed64 RR |
381 | } |
382 | ||
383 | wxComboBox::~wxComboBox() | |
384 | { | |
222ed1d6 | 385 | wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); |
fd0eed64 RR |
386 | while (node) |
387 | { | |
b1d4dd7a | 388 | wxClientData *cd = (wxClientData*)node->GetData(); |
fd0eed64 | 389 | if (cd) delete cd; |
b1d4dd7a | 390 | node = node->GetNext(); |
fd0eed64 | 391 | } |
7d6d2cd4 RR |
392 | m_clientObjectList.Clear(); |
393 | ||
fd0eed64 | 394 | m_clientDataList.Clear(); |
6de97a3b | 395 | } |
53010e52 | 396 | |
2b5f62a0 VZ |
397 | void wxComboBox::SetFocus() |
398 | { | |
399 | if ( m_hasFocus ) | |
400 | { | |
401 | // don't do anything if we already have focus | |
402 | return; | |
403 | } | |
404 | ||
405 | gtk_widget_grab_focus( m_focusWidget ); | |
406 | } | |
407 | ||
6f6f938f | 408 | int wxComboBox::DoAppend( const wxString &item ) |
53010e52 | 409 | { |
2a68b7a0 | 410 | wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); |
805dd538 | 411 | |
590f50d6 RR |
412 | #ifdef __WXGTK24__ |
413 | if (!gtk_check_version(2,4,0)) | |
414 | { | |
415 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
416 | gtk_combo_box_append_text( combobox, wxGTK_CONV( item ) ); | |
417 | } | |
418 | else | |
419 | #endif | |
420 | { | |
421 | DisableEvents(); | |
805dd538 | 422 | |
590f50d6 RR |
423 | GtkWidget *list = GTK_COMBO(m_widget)->list; |
424 | GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) ); | |
805dd538 | 425 | |
590f50d6 | 426 | gtk_container_add( GTK_CONTAINER(list), list_item ); |
ec5d85fb | 427 | |
590f50d6 RR |
428 | if (GTK_WIDGET_REALIZED(m_widget)) |
429 | { | |
430 | gtk_widget_realize( list_item ); | |
431 | gtk_widget_realize( GTK_BIN(list_item)->child ); | |
432 | } | |
2b07d713 | 433 | |
590f50d6 RR |
434 | // Apply current widget style to the new list_item |
435 | GtkRcStyle *style = CreateWidgetStyle(); | |
436 | if (style) | |
437 | { | |
438 | gtk_widget_modify_style( GTK_WIDGET( list_item ), style ); | |
439 | GtkBin *bin = GTK_BIN( list_item ); | |
440 | GtkWidget *label = GTK_WIDGET( bin->child ); | |
441 | gtk_widget_modify_style( label, style ); | |
442 | gtk_rc_style_unref( style ); | |
443 | } | |
805dd538 | 444 | |
590f50d6 | 445 | gtk_widget_show( list_item ); |
30ed6e5c | 446 | |
590f50d6 RR |
447 | EnableEvents(); |
448 | } | |
53010e52 | 449 | |
aa61d352 | 450 | const unsigned int count = GetCount(); |
8228b893 WS |
451 | |
452 | if ( m_clientDataList.GetCount() < count ) | |
0a164d4c | 453 | m_clientDataList.Append( (wxObject*) NULL ); |
8228b893 | 454 | if ( m_clientObjectList.GetCount() < count ) |
0a164d4c | 455 | m_clientObjectList.Append( (wxObject*) NULL ); |
805dd538 | 456 | |
b0021947 VS |
457 | InvalidateBestSize(); |
458 | ||
6f6f938f | 459 | return count - 1; |
fd0eed64 RR |
460 | } |
461 | ||
aa61d352 | 462 | int wxComboBox::DoInsert(const wxString &item, unsigned int pos) |
243dbf1a | 463 | { |
708c45a6 VZ |
464 | wxCHECK_MSG( !(GetWindowStyle() & wxCB_SORT), -1, |
465 | wxT("can't insert into sorted list")); | |
466 | ||
467 | wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); | |
8228b893 | 468 | wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") ); |
243dbf1a | 469 | |
aa61d352 | 470 | unsigned int count = GetCount(); |
6f6f938f | 471 | |
aa61d352 | 472 | if (pos == count) |
6f6f938f | 473 | return Append(item); |
243dbf1a | 474 | |
590f50d6 RR |
475 | #ifdef __WXGTK24__ |
476 | if (!gtk_check_version(2,4,0)) | |
477 | { | |
478 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
479 | gtk_combo_box_insert_text( combobox, pos, wxGTK_CONV( item ) ); | |
480 | } | |
481 | else | |
482 | #endif | |
483 | { | |
484 | DisableEvents(); | |
243dbf1a | 485 | |
590f50d6 RR |
486 | GtkWidget *list = GTK_COMBO(m_widget)->list; |
487 | GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) ); | |
243dbf1a | 488 | |
590f50d6 RR |
489 | GList *gitem_list = g_list_alloc (); |
490 | gitem_list->data = list_item; | |
491 | gtk_list_insert_items( GTK_LIST (list), gitem_list, pos ); | |
243dbf1a | 492 | |
590f50d6 RR |
493 | if (GTK_WIDGET_REALIZED(m_widget)) |
494 | { | |
495 | gtk_widget_realize( list_item ); | |
496 | gtk_widget_realize( GTK_BIN(list_item)->child ); | |
243dbf1a | 497 | |
590f50d6 RR |
498 | ApplyWidgetStyle(); |
499 | } | |
243dbf1a | 500 | |
590f50d6 | 501 | gtk_widget_show( list_item ); |
243dbf1a | 502 | |
590f50d6 RR |
503 | EnableEvents(); |
504 | } | |
8228b893 | 505 | |
6f6f938f | 506 | count = GetCount(); |
243dbf1a | 507 | |
8228b893 | 508 | if ( m_clientDataList.GetCount() < count ) |
0a164d4c | 509 | m_clientDataList.Insert( pos, (wxObject*) NULL ); |
8228b893 | 510 | if ( m_clientObjectList.GetCount() < count ) |
0a164d4c | 511 | m_clientObjectList.Insert( pos, (wxObject*) NULL ); |
243dbf1a | 512 | |
b0021947 | 513 | InvalidateBestSize(); |
243dbf1a | 514 | |
6f6f938f | 515 | return pos; |
243dbf1a VZ |
516 | } |
517 | ||
aa61d352 | 518 | void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData) |
fd0eed64 | 519 | { |
223d09f6 | 520 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 521 | |
222ed1d6 | 522 | wxList::compatibility_iterator node = m_clientDataList.Item( n ); |
fd0eed64 | 523 | if (!node) return; |
805dd538 | 524 | |
f5e27805 | 525 | node->SetData( (wxObject*) clientData ); |
6de97a3b | 526 | } |
53010e52 | 527 | |
aa61d352 | 528 | void* wxComboBox::DoGetItemClientData(unsigned int n) const |
53010e52 | 529 | { |
223d09f6 | 530 | wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); |
805dd538 | 531 | |
222ed1d6 | 532 | wxList::compatibility_iterator node = m_clientDataList.Item( n ); |
805dd538 | 533 | |
30ed6e5c | 534 | return node ? node->GetData() : NULL; |
fd0eed64 RR |
535 | } |
536 | ||
aa61d352 | 537 | void wxComboBox::DoSetItemClientObject(unsigned int n, wxClientData* clientData) |
fd0eed64 | 538 | { |
223d09f6 | 539 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 540 | |
222ed1d6 | 541 | wxList::compatibility_iterator node = m_clientObjectList.Item( n ); |
fd0eed64 | 542 | if (!node) return; |
805dd538 | 543 | |
e94e2e95 | 544 | // wxItemContainer already deletes data for us |
805dd538 | 545 | |
fd0eed64 | 546 | node->SetData( (wxObject*) clientData ); |
6de97a3b | 547 | } |
53010e52 | 548 | |
aa61d352 | 549 | wxClientData* wxComboBox::DoGetItemClientObject(unsigned int n) const |
53010e52 | 550 | { |
223d09f6 | 551 | wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, wxT("invalid combobox") ); |
805dd538 | 552 | |
222ed1d6 | 553 | wxList::compatibility_iterator node = m_clientObjectList.Item( n ); |
805dd538 | 554 | |
30ed6e5c | 555 | return node ? (wxClientData*) node->GetData() : NULL; |
fd0eed64 RR |
556 | } |
557 | ||
558 | void wxComboBox::Clear() | |
559 | { | |
223d09f6 | 560 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 561 | |
461573cc | 562 | DisableEvents(); |
30ed6e5c | 563 | |
590f50d6 RR |
564 | #ifdef __WXGTK24__ |
565 | if (!gtk_check_version(2,4,0)) | |
566 | { | |
567 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
aa61d352 VZ |
568 | const unsigned int count = GetCount(); |
569 | for (unsigned int i = 0; i < count; i++) | |
590f50d6 RR |
570 | gtk_combo_box_remove_text( combobox, 0 ); |
571 | } | |
c1a3ff25 VZ |
572 | else // GTK+ < 2.4.0 |
573 | #endif // __WXGTK24__ | |
590f50d6 RR |
574 | { |
575 | GtkWidget *list = GTK_COMBO(m_widget)->list; | |
576 | gtk_list_clear_items( GTK_LIST(list), 0, GetCount() ); | |
577 | } | |
8228b893 | 578 | |
222ed1d6 | 579 | wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); |
fd0eed64 RR |
580 | while (node) |
581 | { | |
b1d4dd7a | 582 | wxClientData *cd = (wxClientData*)node->GetData(); |
c1a3ff25 | 583 | delete cd; |
b1d4dd7a | 584 | node = node->GetNext(); |
fd0eed64 | 585 | } |
f5e27805 | 586 | m_clientObjectList.Clear(); |
805dd538 | 587 | |
fd0eed64 | 588 | m_clientDataList.Clear(); |
30ed6e5c | 589 | |
461573cc | 590 | EnableEvents(); |
b0021947 VS |
591 | |
592 | InvalidateBestSize(); | |
6de97a3b | 593 | } |
53010e52 | 594 | |
aa61d352 | 595 | void wxComboBox::Delete(unsigned int n) |
53010e52 | 596 | { |
223d09f6 | 597 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 598 | |
590f50d6 RR |
599 | #ifdef __WXGTK24__ |
600 | if (!gtk_check_version(2,4,0)) | |
fd0eed64 | 601 | { |
8228b893 WS |
602 | wxCHECK_RET( IsValid(n), wxT("invalid index") ); |
603 | ||
590f50d6 RR |
604 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); |
605 | gtk_combo_box_remove_text( combobox, n ); | |
fd0eed64 | 606 | } |
590f50d6 RR |
607 | else |
608 | #endif | |
609 | { | |
610 | GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list ); | |
805dd538 | 611 | |
590f50d6 RR |
612 | GList *child = g_list_nth( listbox->children, n ); |
613 | ||
614 | if (!child) | |
615 | { | |
616 | wxFAIL_MSG(wxT("wrong index")); | |
617 | return; | |
618 | } | |
30ed6e5c | 619 | |
590f50d6 | 620 | DisableEvents(); |
805dd538 | 621 | |
590f50d6 RR |
622 | GList *list = g_list_append( (GList*) NULL, child->data ); |
623 | gtk_list_remove_items( listbox, list ); | |
624 | g_list_free( list ); | |
625 | ||
626 | EnableEvents(); | |
627 | } | |
8228b893 | 628 | |
222ed1d6 | 629 | wxList::compatibility_iterator node = m_clientObjectList.Item( n ); |
f5e27805 | 630 | if (node) |
fd0eed64 | 631 | { |
b1d4dd7a | 632 | wxClientData *cd = (wxClientData*)node->GetData(); |
fd0eed64 | 633 | if (cd) delete cd; |
222ed1d6 | 634 | m_clientObjectList.Erase( node ); |
f5e27805 | 635 | } |
805dd538 | 636 | |
b1d4dd7a | 637 | node = m_clientDataList.Item( n ); |
f5e27805 | 638 | if (node) |
222ed1d6 | 639 | m_clientDataList.Erase( node ); |
150e31d2 | 640 | |
b0021947 | 641 | InvalidateBestSize(); |
461573cc RR |
642 | } |
643 | ||
aa61d352 | 644 | void wxComboBox::SetString(unsigned int n, const wxString &text) |
461573cc RR |
645 | { |
646 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); | |
647 | ||
590f50d6 RR |
648 | #ifdef __WXGTK24__ |
649 | if (!gtk_check_version(2,4,0)) | |
461573cc | 650 | { |
590f50d6 | 651 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); |
8228b893 WS |
652 | wxCHECK_RET( IsValid(n), wxT("invalid index") ); |
653 | ||
590f50d6 RR |
654 | GtkTreeModel *model = gtk_combo_box_get_model( combobox ); |
655 | GtkTreeIter iter; | |
656 | if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n)) | |
657 | { | |
658 | GValue value = { 0, }; | |
659 | g_value_init( &value, G_TYPE_STRING ); | |
660 | g_value_set_string( &value, wxGTK_CONV( text ) ); | |
661 | gtk_list_store_set_value( GTK_LIST_STORE(model), &iter, 0, &value ); | |
662 | g_value_unset( &value ); | |
663 | } | |
461573cc RR |
664 | } |
665 | else | |
590f50d6 | 666 | #endif |
461573cc | 667 | { |
590f50d6 | 668 | GtkWidget *list = GTK_COMBO(m_widget)->list; |
150e31d2 | 669 | |
590f50d6 RR |
670 | GList *child = g_list_nth( GTK_LIST(list)->children, n ); |
671 | if (child) | |
672 | { | |
673 | GtkBin *bin = GTK_BIN( child->data ); | |
674 | GtkLabel *label = GTK_LABEL( bin->child ); | |
675 | gtk_label_set_text(label, wxGTK_CONV(text)); | |
676 | } | |
677 | else | |
678 | { | |
679 | wxFAIL_MSG( wxT("wxComboBox: wrong index") ); | |
680 | } | |
681 | } | |
8228b893 | 682 | |
b0021947 | 683 | InvalidateBestSize(); |
6de97a3b | 684 | } |
53010e52 | 685 | |
11e62fe6 | 686 | int wxComboBox::FindString( const wxString &item, bool bCase ) const |
53010e52 | 687 | { |
0a164d4c | 688 | wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid combobox") ); |
805dd538 | 689 | |
590f50d6 RR |
690 | #ifdef __WXGTK24__ |
691 | if (!gtk_check_version(2,4,0)) | |
53010e52 | 692 | { |
590f50d6 RR |
693 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); |
694 | GtkTreeModel* model = gtk_combo_box_get_model( combobox ); | |
695 | GtkTreeIter iter; | |
696 | gtk_tree_model_get_iter_first( model, &iter ); | |
697 | if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter )) | |
698 | return -1; | |
699 | int count = 0; | |
8228b893 | 700 | do |
590f50d6 RR |
701 | { |
702 | GValue value = { 0, }; | |
703 | gtk_tree_model_get_value( model, &iter, 0, &value ); | |
704 | wxString str = wxGTK_CONV_BACK( g_value_get_string( &value ) ); | |
705 | g_value_unset( &value ); | |
8228b893 | 706 | |
590f50d6 RR |
707 | if (item.IsSameAs( str, bCase ) ) |
708 | return count; | |
8228b893 | 709 | |
590f50d6 | 710 | count++; |
8228b893 | 711 | |
590f50d6 RR |
712 | } while (gtk_tree_model_iter_next( model, &iter )); |
713 | } | |
714 | else | |
715 | #endif | |
716 | { | |
717 | GtkWidget *list = GTK_COMBO(m_widget)->list; | |
68567a96 | 718 | |
590f50d6 RR |
719 | GList *child = GTK_LIST(list)->children; |
720 | int count = 0; | |
721 | while (child) | |
722 | { | |
723 | GtkBin *bin = GTK_BIN( child->data ); | |
724 | GtkLabel *label = GTK_LABEL( bin->child ); | |
725 | wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); | |
726 | ||
727 | if (item.IsSameAs( str , bCase ) ) | |
728 | return count; | |
30ed6e5c | 729 | |
590f50d6 RR |
730 | count++; |
731 | child = child->next; | |
732 | } | |
fd0eed64 | 733 | } |
805dd538 | 734 | |
7cf8cb48 | 735 | return wxNOT_FOUND; |
fd0eed64 RR |
736 | } |
737 | ||
738 | int wxComboBox::GetSelection() const | |
40eb3606 | 739 | { |
590f50d6 RR |
740 | #ifdef __WXGTK24__ |
741 | if (!gtk_check_version(2,4,0)) | |
742 | { | |
743 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
744 | return gtk_combo_box_get_active( combobox ); | |
745 | } | |
746 | else | |
747 | #endif | |
748 | // if the popup is currently opened, use the selection as it had been | |
749 | // before it dropped down | |
750 | return g_SelectionBeforePopup == wxID_NONE ? GetCurrentSelection() | |
40eb3606 VZ |
751 | : g_SelectionBeforePopup; |
752 | } | |
753 | ||
754 | int wxComboBox::GetCurrentSelection() const | |
fd0eed64 | 755 | { |
223d09f6 | 756 | wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); |
805dd538 | 757 | |
590f50d6 RR |
758 | #ifdef __WXGTK24__ |
759 | if (!gtk_check_version(2,4,0)) | |
fd0eed64 | 760 | { |
590f50d6 RR |
761 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); |
762 | return gtk_combo_box_get_active( combobox ); | |
763 | } | |
764 | else | |
765 | #endif | |
766 | { | |
767 | GtkWidget *list = GTK_COMBO(m_widget)->list; | |
768 | ||
769 | GList *selection = GTK_LIST(list)->selection; | |
770 | if (selection) | |
fd0eed64 | 771 | { |
590f50d6 RR |
772 | GList *child = GTK_LIST(list)->children; |
773 | int count = 0; | |
774 | while (child) | |
775 | { | |
776 | if (child->data == selection->data) return count; | |
777 | count++; | |
778 | child = child->next; | |
779 | } | |
fd0eed64 | 780 | } |
6de97a3b | 781 | } |
805dd538 | 782 | |
fd0eed64 | 783 | return -1; |
6de97a3b | 784 | } |
53010e52 | 785 | |
aa61d352 | 786 | wxString wxComboBox::GetString(unsigned int n) const |
53010e52 | 787 | { |
0a164d4c | 788 | wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid combobox") ); |
805dd538 | 789 | |
7cf8cb48 | 790 | wxString str; |
8228b893 | 791 | |
590f50d6 RR |
792 | #ifdef __WXGTK24__ |
793 | if (!gtk_check_version(2,4,0)) | |
fd0eed64 | 794 | { |
590f50d6 RR |
795 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); |
796 | GtkTreeModel *model = gtk_combo_box_get_model( combobox ); | |
797 | GtkTreeIter iter; | |
798 | if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n)) | |
799 | { | |
800 | GValue value = { 0, }; | |
801 | gtk_tree_model_get_value( model, &iter, 0, &value ); | |
802 | wxString tmp = wxGTK_CONV_BACK( g_value_get_string( &value ) ); | |
803 | g_value_unset( &value ); | |
804 | return tmp; | |
805 | } | |
7cf8cb48 VZ |
806 | } |
807 | else | |
590f50d6 | 808 | #endif |
8228b893 | 809 | { |
590f50d6 RR |
810 | GtkWidget *list = GTK_COMBO(m_widget)->list; |
811 | ||
812 | GList *child = g_list_nth( GTK_LIST(list)->children, n ); | |
813 | if (child) | |
814 | { | |
815 | GtkBin *bin = GTK_BIN( child->data ); | |
816 | GtkLabel *label = GTK_LABEL( bin->child ); | |
817 | str = wxGTK_CONV_BACK( gtk_label_get_text(label) ); | |
818 | } | |
819 | else | |
820 | { | |
821 | wxFAIL_MSG( wxT("wxComboBox: wrong index") ); | |
822 | } | |
fd0eed64 | 823 | } |
805dd538 | 824 | |
7cf8cb48 | 825 | return str; |
6de97a3b | 826 | } |
53010e52 | 827 | |
fd0eed64 | 828 | wxString wxComboBox::GetStringSelection() const |
53010e52 | 829 | { |
0a164d4c | 830 | wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid combobox") ); |
805dd538 | 831 | |
590f50d6 RR |
832 | #ifdef __WXGTK24__ |
833 | if (!gtk_check_version(2,4,0)) | |
fd0eed64 | 834 | { |
590f50d6 RR |
835 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); |
836 | int sel = gtk_combo_box_get_active( combobox ); | |
837 | if (sel == -1) | |
838 | return wxEmptyString; | |
aa61d352 | 839 | return GetString(sel); |
fd0eed64 | 840 | } |
590f50d6 RR |
841 | else |
842 | #endif | |
8228b893 | 843 | { |
590f50d6 RR |
844 | GtkWidget *list = GTK_COMBO(m_widget)->list; |
845 | ||
846 | GList *selection = GTK_LIST(list)->selection; | |
847 | if (selection) | |
848 | { | |
849 | GtkBin *bin = GTK_BIN( selection->data ); | |
850 | GtkLabel *label = GTK_LABEL( bin->child ); | |
851 | wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); | |
852 | return tmp; | |
853 | } | |
805dd538 | 854 | |
590f50d6 RR |
855 | wxFAIL_MSG( wxT("wxComboBox: no selection") ); |
856 | } | |
805dd538 | 857 | |
0a164d4c | 858 | return wxEmptyString; |
6de97a3b | 859 | } |
53010e52 | 860 | |
aa61d352 | 861 | unsigned int wxComboBox::GetCount() const |
53010e52 | 862 | { |
223d09f6 | 863 | wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") ); |
805dd538 | 864 | |
590f50d6 RR |
865 | #ifdef __WXGTK24__ |
866 | if (!gtk_check_version(2,4,0)) | |
867 | { | |
868 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
869 | GtkTreeModel* model = gtk_combo_box_get_model( combobox ); | |
870 | GtkTreeIter iter; | |
871 | gtk_tree_model_get_iter_first( model, &iter ); | |
872 | if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter )) | |
873 | return 0; | |
aa61d352 | 874 | unsigned int ret = 1; |
590f50d6 RR |
875 | while (gtk_tree_model_iter_next( model, &iter )) |
876 | ret++; | |
877 | return ret; | |
878 | } | |
879 | else | |
880 | #endif | |
8228b893 | 881 | { |
590f50d6 | 882 | GtkWidget *list = GTK_COMBO(m_widget)->list; |
805dd538 | 883 | |
590f50d6 | 884 | GList *child = GTK_LIST(list)->children; |
aa61d352 VZ |
885 | unsigned int count = 0; |
886 | while (child) | |
887 | { | |
888 | count++; | |
889 | child = child->next; | |
890 | } | |
590f50d6 RR |
891 | return count; |
892 | } | |
8228b893 | 893 | |
590f50d6 | 894 | return 0; |
6de97a3b | 895 | } |
53010e52 | 896 | |
debe6624 | 897 | void wxComboBox::SetSelection( int n ) |
53010e52 | 898 | { |
223d09f6 | 899 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 900 | |
953704c1 RR |
901 | DisableEvents(); |
902 | ||
590f50d6 RR |
903 | #ifdef __WXGTK24__ |
904 | if (!gtk_check_version(2,4,0)) | |
905 | { | |
906 | GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); | |
907 | gtk_combo_box_set_active( combobox, n ); | |
908 | } | |
909 | else | |
910 | #endif | |
911 | { | |
912 | GtkWidget *list = GTK_COMBO(m_widget)->list; | |
913 | gtk_list_unselect_item( GTK_LIST(list), m_prevSelection ); | |
914 | gtk_list_select_item( GTK_LIST(list), n ); | |
915 | m_prevSelection = n; | |
916 | } | |
8228b893 | 917 | |
953704c1 | 918 | EnableEvents(); |
6de97a3b | 919 | } |
53010e52 | 920 | |
fd0eed64 | 921 | wxString wxComboBox::GetValue() const |
53010e52 | 922 | { |
590f50d6 RR |
923 | GtkEntry *entry = NULL; |
924 | #ifdef __WXGTK24__ | |
925 | if (!gtk_check_version(2,4,0)) | |
926 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
927 | else | |
8228b893 | 928 | #endif |
590f50d6 | 929 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 930 | |
2e1d7104 RR |
931 | wxString tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry ) ) ); |
932 | ||
30ed6e5c | 933 | #if 0 |
2e1d7104 RR |
934 | for (int i = 0; i < wxStrlen(tmp.c_str()) +1; i++) |
935 | { | |
936 | wxChar c = tmp[i]; | |
937 | printf( "%d ", (int) (c) ); | |
938 | } | |
939 | printf( "\n" ); | |
940 | #endif | |
30ed6e5c | 941 | |
fd0eed64 | 942 | return tmp; |
6de97a3b | 943 | } |
53010e52 RR |
944 | |
945 | void wxComboBox::SetValue( const wxString& value ) | |
946 | { | |
223d09f6 | 947 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 948 | |
590f50d6 RR |
949 | GtkEntry *entry = NULL; |
950 | #ifdef __WXGTK24__ | |
951 | if (!gtk_check_version(2,4,0)) | |
952 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
953 | else | |
8228b893 | 954 | #endif |
590f50d6 | 955 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 956 | |
0a164d4c | 957 | wxString tmp; |
fd0eed64 | 958 | if (!value.IsNull()) tmp = value; |
590f50d6 | 959 | gtk_entry_set_text( entry, wxGTK_CONV( tmp ) ); |
150e31d2 | 960 | |
b0021947 | 961 | InvalidateBestSize(); |
6de97a3b | 962 | } |
53010e52 | 963 | |
fd0eed64 | 964 | void wxComboBox::Copy() |
53010e52 | 965 | { |
223d09f6 | 966 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 967 | |
590f50d6 RR |
968 | GtkEntry *entry = NULL; |
969 | #ifdef __WXGTK24__ | |
970 | if (!gtk_check_version(2,4,0)) | |
971 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
972 | else | |
8228b893 | 973 | #endif |
590f50d6 | 974 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 975 | |
afa7bd1e | 976 | gtk_editable_copy_clipboard(GTK_EDITABLE(entry)); |
6de97a3b | 977 | } |
53010e52 | 978 | |
fd0eed64 | 979 | void wxComboBox::Cut() |
53010e52 | 980 | { |
223d09f6 | 981 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 982 | |
590f50d6 RR |
983 | GtkEntry *entry = NULL; |
984 | #ifdef __WXGTK24__ | |
985 | if (!gtk_check_version(2,4,0)) | |
986 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
987 | else | |
8228b893 | 988 | #endif |
590f50d6 | 989 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 990 | |
afa7bd1e | 991 | gtk_editable_cut_clipboard(GTK_EDITABLE(entry)); |
6de97a3b | 992 | } |
53010e52 | 993 | |
fd0eed64 | 994 | void wxComboBox::Paste() |
53010e52 | 995 | { |
223d09f6 | 996 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 997 | |
590f50d6 RR |
998 | GtkEntry *entry = NULL; |
999 | #ifdef __WXGTK24__ | |
1000 | if (!gtk_check_version(2,4,0)) | |
1001 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1002 | else | |
8228b893 | 1003 | #endif |
590f50d6 | 1004 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1005 | |
afa7bd1e | 1006 | gtk_editable_paste_clipboard(GTK_EDITABLE(entry)); |
6de97a3b | 1007 | } |
53010e52 | 1008 | |
150e31d2 JS |
1009 | void wxComboBox::Undo() |
1010 | { | |
1011 | // TODO | |
1012 | } | |
1013 | ||
1014 | void wxComboBox::Redo() | |
1015 | { | |
1016 | // TODO | |
1017 | } | |
1018 | ||
1019 | void wxComboBox::SelectAll() | |
1020 | { | |
4e324a3f | 1021 | SetSelection(0, GetLastPosition()); |
150e31d2 JS |
1022 | } |
1023 | ||
1024 | bool wxComboBox::CanUndo() const | |
1025 | { | |
1026 | // TODO | |
1027 | return false; | |
1028 | } | |
1029 | ||
1030 | bool wxComboBox::CanRedo() const | |
1031 | { | |
1032 | // TODO | |
1033 | return false; | |
1034 | } | |
1035 | ||
1036 | bool wxComboBox::HasSelection() const | |
1037 | { | |
1038 | long from, to; | |
1039 | GetSelection(&from, &to); | |
1040 | return from != to; | |
1041 | } | |
1042 | ||
1043 | bool wxComboBox::CanCopy() const | |
1044 | { | |
1045 | // Can copy if there's a selection | |
1046 | return HasSelection(); | |
1047 | } | |
1048 | ||
1049 | bool wxComboBox::CanCut() const | |
1050 | { | |
1051 | return CanCopy() && IsEditable(); | |
1052 | } | |
1053 | ||
1054 | bool wxComboBox::CanPaste() const | |
1055 | { | |
1056 | // TODO: check for text on the clipboard | |
1057 | return IsEditable() ; | |
1058 | } | |
1059 | ||
1060 | bool wxComboBox::IsEditable() const | |
1061 | { | |
1062 | return !HasFlag(wxCB_READONLY); | |
1063 | } | |
1064 | ||
1065 | ||
debe6624 | 1066 | void wxComboBox::SetInsertionPoint( long pos ) |
53010e52 | 1067 | { |
223d09f6 | 1068 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 1069 | |
6f6f938f VZ |
1070 | if ( pos == GetLastPosition() ) |
1071 | pos = -1; | |
1072 | ||
590f50d6 RR |
1073 | GtkEntry *entry = NULL; |
1074 | #ifdef __WXGTK24__ | |
1075 | if (!gtk_check_version(2,4,0)) | |
1076 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1077 | else | |
8228b893 | 1078 | #endif |
590f50d6 | 1079 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1080 | |
590f50d6 | 1081 | gtk_entry_set_position( entry, (int)pos ); |
6de97a3b | 1082 | } |
53010e52 | 1083 | |
fd0eed64 | 1084 | long wxComboBox::GetInsertionPoint() const |
53010e52 | 1085 | { |
590f50d6 RR |
1086 | GtkEntry *entry = NULL; |
1087 | #ifdef __WXGTK24__ | |
1088 | if (!gtk_check_version(2,4,0)) | |
1089 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1090 | else | |
8228b893 | 1091 | #endif |
590f50d6 | 1092 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1093 | |
590f50d6 | 1094 | return (long) gtk_editable_get_position(GTK_EDITABLE(entry)); |
6de97a3b | 1095 | } |
53010e52 | 1096 | |
7d8268a1 | 1097 | wxTextPos wxComboBox::GetLastPosition() const |
53010e52 | 1098 | { |
590f50d6 RR |
1099 | GtkEntry *entry = NULL; |
1100 | #ifdef __WXGTK24__ | |
1101 | if (!gtk_check_version(2,4,0)) | |
1102 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1103 | else | |
8228b893 | 1104 | #endif |
590f50d6 | 1105 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1106 | |
590f50d6 | 1107 | int pos = entry->text_length; |
fd0eed64 | 1108 | return (long) pos-1; |
6de97a3b | 1109 | } |
53010e52 | 1110 | |
debe6624 | 1111 | void wxComboBox::Replace( long from, long to, const wxString& value ) |
53010e52 | 1112 | { |
223d09f6 | 1113 | wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); |
805dd538 | 1114 | |
590f50d6 RR |
1115 | GtkEntry *entry = NULL; |
1116 | #ifdef __WXGTK24__ | |
1117 | if (!gtk_check_version(2,4,0)) | |
1118 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1119 | else | |
8228b893 | 1120 | #endif |
590f50d6 | 1121 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1122 | |
fd0eed64 RR |
1123 | gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to ); |
1124 | if (value.IsNull()) return; | |
1125 | gint pos = (gint)to; | |
30ed6e5c | 1126 | |
2e1d7104 RR |
1127 | #if wxUSE_UNICODE |
1128 | wxCharBuffer buffer = wxConvUTF8.cWX2MB( value ); | |
1129 | gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos ); | |
1130 | #else | |
8228b893 | 1131 | gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos ); |
2e1d7104 | 1132 | #endif |
6de97a3b | 1133 | } |
53010e52 | 1134 | |
20d10ee1 | 1135 | void wxComboBox::SetSelection( long from, long to ) |
53010e52 | 1136 | { |
590f50d6 RR |
1137 | GtkEntry *entry = NULL; |
1138 | #ifdef __WXGTK24__ | |
1139 | if (!gtk_check_version(2,4,0)) | |
1140 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1141 | else | |
8228b893 | 1142 | #endif |
590f50d6 | 1143 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1144 | |
20d10ee1 | 1145 | gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to ); |
6de97a3b | 1146 | } |
53010e52 | 1147 | |
150e31d2 JS |
1148 | void wxComboBox::GetSelection( long* from, long* to ) const |
1149 | { | |
590f50d6 RR |
1150 | GtkEntry *entry = NULL; |
1151 | #ifdef __WXGTK24__ | |
1152 | if (!gtk_check_version(2,4,0)) | |
1153 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1154 | else | |
8228b893 | 1155 | #endif |
590f50d6 | 1156 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1157 | |
150e31d2 JS |
1158 | if (IsEditable()) |
1159 | { | |
590f50d6 | 1160 | GtkEditable *editable = GTK_EDITABLE(entry); |
4e324a3f JS |
1161 | gint start, end; |
1162 | gtk_editable_get_selection_bounds(editable, & start, & end); | |
1163 | *from = start; | |
1164 | *to = end; | |
150e31d2 JS |
1165 | } |
1166 | } | |
1167 | ||
20d10ee1 | 1168 | void wxComboBox::SetEditable( bool editable ) |
53010e52 | 1169 | { |
590f50d6 RR |
1170 | GtkEntry *entry = NULL; |
1171 | #ifdef __WXGTK24__ | |
1172 | if (!gtk_check_version(2,4,0)) | |
1173 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1174 | else | |
8228b893 | 1175 | #endif |
590f50d6 | 1176 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1177 | |
20d10ee1 | 1178 | gtk_entry_set_editable( GTK_ENTRY(entry), editable ); |
b4071e91 RR |
1179 | } |
1180 | ||
8a85884a VZ |
1181 | void wxComboBox::OnChar( wxKeyEvent &event ) |
1182 | { | |
12a3f227 | 1183 | if ( event.GetKeyCode() == WXK_RETURN ) |
8a85884a | 1184 | { |
461573cc | 1185 | // GTK automatically selects an item if its in the list |
17a1ebd1 VZ |
1186 | wxCommandEvent eventEnter(wxEVT_COMMAND_TEXT_ENTER, GetId()); |
1187 | eventEnter.SetString( GetValue() ); | |
1188 | eventEnter.SetInt( GetSelection() ); | |
1189 | eventEnter.SetEventObject( this ); | |
3352cfff | 1190 | |
17a1ebd1 | 1191 | if (!GetEventHandler()->ProcessEvent( eventEnter )) |
3352cfff RR |
1192 | { |
1193 | // This will invoke the dialog default action, such | |
1194 | // as the clicking the default button. | |
1195 | ||
1196 | wxWindow *top_frame = m_parent; | |
1197 | while (top_frame->GetParent() && !(top_frame->IsTopLevel())) | |
1198 | top_frame = top_frame->GetParent(); | |
1199 | ||
1200 | if (top_frame && GTK_IS_WINDOW(top_frame->m_widget)) | |
1201 | { | |
1202 | GtkWindow *window = GTK_WINDOW(top_frame->m_widget); | |
1203 | ||
1204 | if (window->default_widget) | |
150e31d2 | 1205 | gtk_widget_activate (window->default_widget); |
3352cfff RR |
1206 | } |
1207 | } | |
30ed6e5c | 1208 | |
461573cc RR |
1209 | // Catch GTK event so that GTK doesn't open the drop |
1210 | // down list upon RETURN. | |
0878fb4c | 1211 | return; |
8a85884a | 1212 | } |
30ed6e5c | 1213 | |
7cf8cb48 | 1214 | event.Skip(); |
8a85884a VZ |
1215 | } |
1216 | ||
953704c1 RR |
1217 | void wxComboBox::DisableEvents() |
1218 | { | |
590f50d6 RR |
1219 | #ifdef __WXGTK24__ |
1220 | if (!gtk_check_version(2,4,0)) | |
1221 | { | |
8228b893 | 1222 | g_signal_handlers_disconnect_by_func (GTK_BIN(m_widget)->child, |
590f50d6 | 1223 | (gpointer)gtkcombobox_text_changed_callback, this); |
8228b893 | 1224 | |
590f50d6 RR |
1225 | g_signal_handlers_disconnect_by_func (m_widget, |
1226 | (gpointer)gtkcombobox_changed_callback, this); | |
1227 | } | |
1228 | else | |
8228b893 | 1229 | #endif |
590f50d6 RR |
1230 | { |
1231 | g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->list, | |
1232 | (gpointer) gtkcombo_combo_select_child_callback, this); | |
8228b893 | 1233 | |
590f50d6 RR |
1234 | g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->entry, |
1235 | (gpointer) gtkcombo_text_changed_callback, this); | |
1236 | } | |
953704c1 RR |
1237 | } |
1238 | ||
1239 | void wxComboBox::EnableEvents() | |
1240 | { | |
590f50d6 RR |
1241 | #ifdef __WXGTK24__ |
1242 | if (!gtk_check_version(2,4,0)) | |
1243 | { | |
1244 | g_signal_connect_after (GTK_BIN(m_widget)->child, "changed", | |
1245 | G_CALLBACK (gtkcombobox_text_changed_callback), this); | |
8228b893 | 1246 | |
590f50d6 RR |
1247 | g_signal_connect_after (m_widget, "changed", |
1248 | G_CALLBACK (gtkcombobox_changed_callback), this); | |
1249 | } | |
1250 | else | |
8228b893 | 1251 | #endif |
590f50d6 RR |
1252 | { |
1253 | g_signal_connect_after (GTK_COMBO(m_widget)->list, "select-child", | |
1fb33bdb | 1254 | G_CALLBACK (gtkcombo_combo_select_child_callback), |
9fa72bd2 | 1255 | this); |
590f50d6 | 1256 | g_signal_connect_after (GTK_COMBO(m_widget)->entry, "changed", |
1fb33bdb | 1257 | G_CALLBACK (gtkcombo_text_changed_callback), |
9fa72bd2 | 1258 | this ); |
590f50d6 | 1259 | } |
953704c1 RR |
1260 | } |
1261 | ||
b4071e91 RR |
1262 | void wxComboBox::OnSize( wxSizeEvent &event ) |
1263 | { | |
590f50d6 RR |
1264 | #ifdef __WXGTK24__ |
1265 | if (!gtk_check_version(2,4,0)) | |
1266 | { | |
1267 | // Do nothing | |
1268 | } | |
1269 | else | |
1270 | #endif | |
1271 | { | |
1272 | // NB: In some situations (e.g. on non-first page of a wizard, if the | |
1273 | // size used is default size), GtkCombo widget is resized correctly, | |
1274 | // but it's look is not updated, it's rendered as if it was much wider. | |
1275 | // No other widgets are affected, so it looks like a bug in GTK+. | |
1276 | // Manually requesting resize calculation (as gtk_pizza_set_size does) | |
1277 | // fixes it. | |
1278 | if (GTK_WIDGET_VISIBLE(m_widget)) | |
1279 | gtk_widget_queue_resize(m_widget); | |
1280 | } | |
260a67b7 | 1281 | |
f03fc89f | 1282 | event.Skip(); |
6de97a3b | 1283 | } |
53010e52 | 1284 | |
f40fdaa3 | 1285 | void wxComboBox::DoApplyWidgetStyle(GtkRcStyle *style) |
868a2826 | 1286 | { |
590f50d6 RR |
1287 | #ifdef __WXGTK24__ |
1288 | if (!gtk_check_version(2,4,0)) | |
1289 | { | |
1290 | // Do nothing | |
1291 | } | |
1292 | else | |
1293 | #endif | |
1294 | { | |
f40fdaa3 | 1295 | // gtk_widget_modify_style( GTK_COMBO(m_widget)->button, syle ); |
ea2d542c | 1296 | |
590f50d6 RR |
1297 | gtk_widget_modify_style( GTK_COMBO(m_widget)->entry, style ); |
1298 | gtk_widget_modify_style( GTK_COMBO(m_widget)->list, style ); | |
805dd538 | 1299 | |
590f50d6 RR |
1300 | GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list ); |
1301 | GList *child = list->children; | |
1302 | while (child) | |
1303 | { | |
1304 | gtk_widget_modify_style( GTK_WIDGET(child->data), style ); | |
805dd538 | 1305 | |
590f50d6 RR |
1306 | GtkBin *bin = GTK_BIN(child->data); |
1307 | gtk_widget_modify_style( bin->child, style ); | |
805dd538 | 1308 | |
590f50d6 RR |
1309 | child = child->next; |
1310 | } | |
fd0eed64 | 1311 | } |
868a2826 | 1312 | } |
b4071e91 | 1313 | |
fd0eed64 | 1314 | GtkWidget* wxComboBox::GetConnectWidget() |
97b3455a | 1315 | { |
590f50d6 RR |
1316 | GtkEntry *entry = NULL; |
1317 | #ifdef __WXGTK24__ | |
1318 | if (!gtk_check_version(2,4,0)) | |
1319 | entry = GTK_ENTRY( GTK_BIN(m_widget)->child ); | |
1320 | else | |
8228b893 | 1321 | #endif |
590f50d6 | 1322 | entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); |
8228b893 | 1323 | |
590f50d6 | 1324 | return GTK_WIDGET( entry ); |
97b3455a RR |
1325 | } |
1326 | ||
ef5c70f9 | 1327 | GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const |
b4071e91 | 1328 | { |
590f50d6 RR |
1329 | #ifdef __WXGTK24__ |
1330 | if (!gtk_check_version(2,4,0)) | |
1331 | { | |
ef5c70f9 VZ |
1332 | wxUnusedVar(windows); |
1333 | ||
1334 | return GTK_ENTRY(GTK_BIN(m_widget)->child)->text_area; | |
590f50d6 RR |
1335 | } |
1336 | else | |
ef5c70f9 | 1337 | #endif // GTK+ 2.4 |
590f50d6 | 1338 | { |
ef5c70f9 VZ |
1339 | windows.push_back(GTK_ENTRY(GTK_COMBO(m_widget)->entry)->text_area); |
1340 | windows.push_back(GTK_COMBO(m_widget)->button->window); | |
1341 | ||
1342 | // indicate that we return multiple windows in the windows array | |
1343 | return NULL; | |
590f50d6 | 1344 | } |
b4071e91 | 1345 | } |
ac57418f | 1346 | |
f68586e5 VZ |
1347 | wxSize wxComboBox::DoGetBestSize() const |
1348 | { | |
db434467 | 1349 | wxSize ret( wxControl::DoGetBestSize() ); |
a6fc8ae3 VZ |
1350 | |
1351 | // we know better our horizontal extent: it depends on the longest string | |
1352 | // in the combobox | |
a6fc8ae3 VZ |
1353 | if ( m_widget ) |
1354 | { | |
60d85ccb | 1355 | int width; |
aa61d352 VZ |
1356 | unsigned int count = GetCount(); |
1357 | for ( unsigned int n = 0; n < count; n++ ) | |
a6fc8ae3 | 1358 | { |
aa61d352 | 1359 | GetTextExtent(GetString(n), &width, NULL, NULL, NULL ); |
a6fc8ae3 VZ |
1360 | if ( width > ret.x ) |
1361 | ret.x = width; | |
1362 | } | |
1363 | } | |
1364 | ||
1365 | // empty combobox should have some reasonable default size too | |
1366 | if ( ret.x < 100 ) | |
1367 | ret.x = 100; | |
9f884528 RD |
1368 | |
1369 | CacheBestSize(ret); | |
db434467 | 1370 | return ret; |
f68586e5 VZ |
1371 | } |
1372 | ||
9d522606 RD |
1373 | // static |
1374 | wxVisualAttributes | |
1375 | wxComboBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant)) | |
1376 | { | |
590f50d6 RR |
1377 | #ifdef __WXGTK24__ |
1378 | if (!gtk_check_version(2,4,0)) | |
1379 | return GetDefaultAttributesFromGTKWidget(gtk_combo_box_entry_new, true); | |
1380 | else | |
1381 | #endif | |
1382 | return GetDefaultAttributesFromGTKWidget(gtk_combo_new, true); | |
9d522606 RD |
1383 | } |
1384 | ||
150e31d2 JS |
1385 | // ---------------------------------------------------------------------------- |
1386 | // standard event handling | |
1387 | // ---------------------------------------------------------------------------- | |
1388 | ||
1389 | void wxComboBox::OnCut(wxCommandEvent& WXUNUSED(event)) | |
1390 | { | |
1391 | Cut(); | |
1392 | } | |
1393 | ||
1394 | void wxComboBox::OnCopy(wxCommandEvent& WXUNUSED(event)) | |
1395 | { | |
1396 | Copy(); | |
1397 | } | |
1398 | ||
1399 | void wxComboBox::OnPaste(wxCommandEvent& WXUNUSED(event)) | |
1400 | { | |
1401 | Paste(); | |
1402 | } | |
1403 | ||
1404 | void wxComboBox::OnUndo(wxCommandEvent& WXUNUSED(event)) | |
1405 | { | |
1406 | Undo(); | |
1407 | } | |
1408 | ||
1409 | void wxComboBox::OnRedo(wxCommandEvent& WXUNUSED(event)) | |
1410 | { | |
1411 | Redo(); | |
1412 | } | |
1413 | ||
1414 | void wxComboBox::OnDelete(wxCommandEvent& WXUNUSED(event)) | |
1415 | { | |
1416 | long from, to; | |
1417 | GetSelection(& from, & to); | |
1418 | if (from != -1 && to != -1) | |
1419 | Remove(from, to); | |
1420 | } | |
1421 | ||
1422 | void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event)) | |
1423 | { | |
1424 | SetSelection(-1, -1); | |
1425 | } | |
1426 | ||
1427 | void wxComboBox::OnUpdateCut(wxUpdateUIEvent& event) | |
1428 | { | |
1429 | event.Enable( CanCut() ); | |
1430 | } | |
1431 | ||
1432 | void wxComboBox::OnUpdateCopy(wxUpdateUIEvent& event) | |
1433 | { | |
1434 | event.Enable( CanCopy() ); | |
1435 | } | |
1436 | ||
1437 | void wxComboBox::OnUpdatePaste(wxUpdateUIEvent& event) | |
1438 | { | |
1439 | event.Enable( CanPaste() ); | |
1440 | } | |
1441 | ||
1442 | void wxComboBox::OnUpdateUndo(wxUpdateUIEvent& event) | |
1443 | { | |
1444 | event.Enable( CanUndo() ); | |
1445 | } | |
1446 | ||
1447 | void wxComboBox::OnUpdateRedo(wxUpdateUIEvent& event) | |
1448 | { | |
1449 | event.Enable( CanRedo() ); | |
1450 | } | |
1451 | ||
1452 | void wxComboBox::OnUpdateDelete(wxUpdateUIEvent& event) | |
1453 | { | |
1454 | event.Enable(HasSelection() && IsEditable()) ; | |
1455 | } | |
1456 | ||
1457 | void wxComboBox::OnUpdateSelectAll(wxUpdateUIEvent& event) | |
1458 | { | |
1459 | event.Enable(GetLastPosition() > 0); | |
1460 | } | |
1461 | ||
dcf924a3 | 1462 | #endif |