]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/combobox.cpp
Fix compilation error
[wxWidgets.git] / src / gtk1 / combobox.cpp
index 3480b849047306342f16d50c08b2a0effd9ee911..5244048804770fb0be8fe7219dc99d242e941714 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        src/gtk/combobox.cpp
+// Name:        src/gtk1/combobox.cpp
 // Purpose:
 // Author:      Robert Roebling
 // Id:          $Id$
@@ -20,7 +20,7 @@
 
 #include "wx/textctrl.h"    // for wxEVT_COMMAND_TEXT_UPDATED
 
-#include "wx/gtk/private.h"
+#include "wx/gtk1/private.h"
 
 //-----------------------------------------------------------------------------
 // idle system
@@ -75,18 +75,29 @@ gtk_popup_hide_callback(GtkCombo *WXUNUSED(gtk_combo), wxComboBox *combo)
 {
     // when the popup is hidden, throw a SELECTED event only if the combobox
     // selection changed.
-    int curSelection = combo->GetCurrentSelection();
-    if (g_SelectionBeforePopup != curSelection)
+    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 );
-    }
 
-    // reset the selection flag to value meaning that it is hidden
-    g_SelectionBeforePopup = wxID_NONE;
+        // 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 );
+    }
 }
 }
 
@@ -144,7 +155,7 @@ gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(wi
         event.SetEventObject( combo );
         combo->GetEventHandler()->ProcessEvent( event );
 
-        // for consistencu with the other ports, don't generate text update
+        // 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() );
@@ -217,7 +228,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 
     // Disable GTK's broken events ...
     gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id );
-    // ... and add surogate handler.
+    // ... and add surrogate handler.
     combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed",
                   (GtkSignalFunc) gtk_dummy_callback, combo);
 
@@ -227,16 +238,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     // and case-sensitive
     gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE );
 
-#ifdef __WXGTK20__
-    if (style & wxNO_BORDER)
-        g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL );
-#endif
-
     GtkWidget *list = GTK_COMBO(m_widget)->list;
 
-#ifndef __WXGTK20__
     // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
-#endif
 
     for (int i = 0; i < n; i++)
     {
@@ -539,11 +543,7 @@ int wxComboBox::FindString( const wxString &item, bool bCase ) const
     {
         GtkBin *bin = GTK_BIN( child->data );
         GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
-        wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-#else
         wxString str( label->label );
-#endif
         if (item.IsSameAs( str , bCase ) )
             return count;
 
@@ -596,11 +596,7 @@ wxString wxComboBox::GetString( int n ) const
     {
         GtkBin *bin = GTK_BIN( child->data );
         GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
-        str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
-#else
         str = wxString( label->label );
-#endif
     }
     else
     {
@@ -621,11 +617,7 @@ wxString wxComboBox::GetStringSelection() const
     {
         GtkBin *bin = GTK_BIN( selection->data );
         GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
-        wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-#else
         wxString tmp( label->label );
-#endif
         return tmp;
     }
 
@@ -821,15 +813,8 @@ void wxComboBox::GetSelection( long* from, long* to ) const
     if (IsEditable())
     {
         GtkEditable *editable = GTK_EDITABLE(GTK_COMBO(m_widget)->entry);
-#ifdef __WXGTK20__
-        gint start, end;
-        gtk_editable_get_selection_bounds(editable, & start, & end);
-        *from = start;
-        *to = end;
-#else
         *from = (long) editable->selection_start_pos;
         *to = (long) editable->selection_end_pos;
-#endif
     }
 }