-//-----------------------------------------------------------------------------
-// data
-//-----------------------------------------------------------------------------
-
-extern bool g_blockEventsOnDrag;
-static int g_SelectionBeforePopup = wxID_NONE; // this means the popup is hidden
-
-//-----------------------------------------------------------------------------
-// "changed" - typing and list item matches get changed, select-child
-// if it doesn't match an item then just get a single changed
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void
-gtkcombo_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
-{
- if (combo->m_ignoreNextUpdate)
- {
- combo->m_ignoreNextUpdate = false;
- return;
- }
-
- if (!combo->m_hasVMT) return;
-
- wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
- event.SetString( combo->GetValue() );
- event.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event );
-}
-}
-
-extern "C" {
-static void
-gtkcombo_dummy_callback(GtkEntry *WXUNUSED(entry), GtkCombo *WXUNUSED(combo))
-{
-}
-}
-
-extern "C" {
-static void
-gtkcombo_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
-{
- // when the popup is hidden, throw a SELECTED event only if the combobox
- // selection changed.
- const int curSelection = combo->GetCurrentSelection();
-
- const bool hasChanged = curSelection != g_SelectionBeforePopup;
-
- // reset the selection flag to value meaning that it is hidden and do it
- // now, before generating the events, so that GetSelection() returns the
- // new value from the event handler
- g_SelectionBeforePopup = wxID_NONE;
-
- if ( hasChanged )
- {
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
- event.SetInt( curSelection );
- event.SetString( combo->GetStringSelection() );
- event.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event );
-
- // for consistency with the other ports, send TEXT event
- wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
- event2.SetString( combo->GetStringSelection() );
- event2.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event2 );
- }
-}
-}
-
-extern "C" {
-static void
-gtkcombo_popup_show_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
-{
- // store the combobox selection value before the popup is shown
- g_SelectionBeforePopup = combo->GetCurrentSelection();
-}
-}
-
-//-----------------------------------------------------------------------------
-// "select-child" - click/cursor get select-child, changed, select-child
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static void
-gtkcombo_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo )
-{
- if (!combo->m_hasVMT) return;
-
- if (g_blockEventsOnDrag) return;
-
- int curSelection = combo->GetCurrentSelection();
-
- if (combo->m_prevSelection == curSelection) return;
-
- GtkWidget *list = GTK_COMBO(combo->m_widget)->list;
- gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection );
-
- combo->m_prevSelection = curSelection;
-
- // Quickly set the value of the combo box
- // as GTK+ does that only AFTER the event
- // is sent.
- GtkWidget* entry = GTK_COMBO(combo->GetHandle())->entry;
- g_signal_handlers_block_by_func(
- entry, (gpointer)gtkcombo_text_changed_callback, combo);
- combo->SetValue( combo->GetStringSelection() );
- g_signal_handlers_unblock_by_func(
- entry, (gpointer)gtkcombo_text_changed_callback, combo);
-
- // throw a SELECTED event only if the combobox popup is hidden (wxID_NONE)
- // because when combobox popup is shown, gtkcombo_combo_select_child_callback is
- // called each times the mouse is over an item with a pressed button so a lot
- // of SELECTED event could be generated if the user keep the mouse button down
- // and select other items ...
- if (g_SelectionBeforePopup == wxID_NONE)
- {
- wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
- event.SetInt( curSelection );
- event.SetString( combo->GetStringSelection() );
- event.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event );
-
- // for consistency with the other ports, don't generate text update
- // events while the user is browsing the combobox neither
- wxCommandEvent event2( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
- event2.SetString( combo->GetValue() );
- event2.SetEventObject( combo );
- combo->GetEventHandler()->ProcessEvent( event2 );
- }
-}
-}