]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/combocmn.cpp
Forward declare classes instead of including their declarations.
[wxWidgets.git] / src / common / combocmn.cpp
index 2f99796830cd1ab19dcbc167d88254a734b74219..0b3a518a1b22ec7331f01bca321b574773c0c7a0 100644 (file)
@@ -590,6 +590,12 @@ void wxComboPopup::SetStringValue( const wxString& WXUNUSED(value) )
 {
 }
 
+bool wxComboPopup::FindItem(const wxString& WXUNUSED(item),
+                            wxString* WXUNUSED(trueItem))
+{
+    return true;
+}
+
 bool wxComboPopup::LazyCreate()
 {
     return false;
@@ -2078,11 +2084,7 @@ void wxComboCtrlBase::OnButtonClick()
     {
         case Hidden:
         {
-            wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
-            event.SetEventObject(this);
-            HandleWindowEvent(event);
-
-            ShowPopup();
+            Popup();
             break;
         }
 
@@ -2095,6 +2097,15 @@ void wxComboCtrlBase::OnButtonClick()
     }
 }
 
+void wxComboCtrlBase::Popup()
+{
+    wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_DROPDOWN, GetId());
+    event.SetEventObject(this);
+    HandleWindowEvent(event);
+
+    ShowPopup();
+}
+
 void wxComboCtrlBase::ShowPopup()
 {
     EnsurePopupControl();
@@ -2570,12 +2581,26 @@ void wxComboCtrlBase::OnSetValue(const wxString& value)
     // to set the string value here (as well as sometimes in ShowPopup).
     if ( m_valueString != value )
     {
-        m_valueString = value;
+        bool found = true;
+        wxString trueValue = value;
+
+        // Conform to wxComboBox behavior: read-only control can only accept
+        // valid list items and empty string
+        if ( m_popupInterface && HasFlag(wxCB_READONLY) && value.length() )
+        {
+            found = m_popupInterface->FindItem(value,
+                                               &trueValue);
+        }
+
+        if ( found )
+        {
+            m_valueString = trueValue;
 
-        EnsurePopupControl();
+            EnsurePopupControl();
 
-        if (m_popupInterface)
-            m_popupInterface->SetStringValue(value);
+            if ( m_popupInterface )
+                m_popupInterface->SetStringValue(trueValue);
+        }
     }
 
     Refresh();