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