From 64fa6f167ebb404e5441eddcee5bbd0808466d7a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 13 Feb 2005 16:29:31 +0000
Subject: [PATCH] removed multiple duplicate copies (with subtly different
 behaviour) of SetStringSelection(); left only one of them in wxItemContainer
 (and another one in wxRadioBoxBase, to be removed)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32000 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/ctrlsub.tex         |  7 ++++++-
 include/wx/choice.h               |  1 -
 include/wx/cocoa/combobox.h       |  2 --
 include/wx/ctrlsub.h              |  6 +++++-
 include/wx/gtk/combobox.h         |  1 -
 include/wx/gtk1/combobox.h        |  1 -
 include/wx/mac/carbon/combobox.h  |  1 -
 include/wx/mac/classic/combobox.h |  1 -
 include/wx/univ/combobox.h        |  2 --
 src/cocoa/combobox.mm             |  6 +-----
 src/common/choiccmn.cpp           | 15 ---------------
 src/common/ctrlsub.cpp            | 11 +++++++++++
 src/gtk/combobox.cpp              | 10 ----------
 src/gtk1/combobox.cpp             | 10 ----------
 src/mac/carbon/combobox.cpp       | 12 ------------
 src/mac/carbon/combobxc.cpp       | 12 ------------
 src/mac/classic/combobox.cpp      | 12 ------------
 17 files changed, 23 insertions(+), 87 deletions(-)

diff --git a/docs/latex/wx/ctrlsub.tex b/docs/latex/wx/ctrlsub.tex
index fe7dbbf5fe..0848843058 100644
--- a/docs/latex/wx/ctrlsub.tex
+++ b/docs/latex/wx/ctrlsub.tex
@@ -337,7 +337,7 @@ Sets the label for the given item.
 
 \membersection{wxControlWithItems::SetStringSelection}\label{wxcontrolwithitemssetstringselection}
 
-\func{void}{SetStringSelection}{\param{const wxString\& }{ string}}
+\func{bool}{SetStringSelection}{\param{const wxString\& }{ string}}
 
 Selects the item with the specified string in the control. This doesn't cause
 any command events being emitted.
@@ -346,6 +346,11 @@ any command events being emitted.
 
 \docparam{string}{The string to select.}
 
+\wxheading{Return value}
+
+\true if the specified string has been selected, \false if it wasn't found in
+the control.
+
 \wxheading{See also}
 
 \helpref{SetSelection}{wxcontrolwithitemssetselection}
diff --git a/include/wx/choice.h b/include/wx/choice.h
index 47f7426051..12bf96c6e0 100644
--- a/include/wx/choice.h
+++ b/include/wx/choice.h
@@ -44,7 +44,6 @@ public:
 
     // single selection logic
     virtual void SetSelection(int n) = 0;
-    virtual bool SetStringSelection(const wxString& s);
 
     // don't override this
     virtual void Select(int n) { SetSelection(n); }
diff --git a/include/wx/cocoa/combobox.h b/include/wx/cocoa/combobox.h
index 4db5e44998..b9679a6f0b 100644
--- a/include/wx/cocoa/combobox.h
+++ b/include/wx/cocoa/combobox.h
@@ -81,8 +81,6 @@ public:
     virtual void SetSelection(int);
     // Overlapping methods
     virtual wxString GetStringSelection();
-    // other methods
-    virtual void SetStringSelection(const wxString& selection);
     // wxItemContainer
     virtual void Clear();
     virtual void Delete(int);
diff --git a/include/wx/ctrlsub.h b/include/wx/ctrlsub.h
index dbf7e9884b..56fd1750cc 100644
--- a/include/wx/ctrlsub.h
+++ b/include/wx/ctrlsub.h
@@ -46,7 +46,7 @@ public:
 
     // only for rtti needs (separate name)
     void AppendString( const wxString& item)
-    { Append( item ) ; }
+        { Append( item ); }
 
     // append several items at once to the control
     void Append(const wxArrayString& strings);
@@ -79,6 +79,10 @@ public:
     virtual void Select(int n) = 0;
     virtual int GetSelection() const = 0;
 
+    // set selection to the specified string, return false if not found
+    bool SetStringSelection(const wxString& s);
+
+    // return the selected string or empty string if none
     wxString GetStringSelection() const;
 
     // misc
diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h
index 6bfc5cf1a3..6c73810879 100644
--- a/include/wx/gtk/combobox.h
+++ b/include/wx/gtk/combobox.h
@@ -96,7 +96,6 @@ public:
     int Number() const { return GetCount(); }
     void SetSelection( int n );
     void Select( int n ) { return SetSelection( n ); }
-    bool SetStringSelection( const wxString &string );
     void SetString(int n, const wxString &text);
 
     wxString GetValue() const;
diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h
index 6bfc5cf1a3..6c73810879 100644
--- a/include/wx/gtk1/combobox.h
+++ b/include/wx/gtk1/combobox.h
@@ -96,7 +96,6 @@ public:
     int Number() const { return GetCount(); }
     void SetSelection( int n );
     void Select( int n ) { return SetSelection( n ); }
-    bool SetStringSelection( const wxString &string );
     void SetString(int n, const wxString &text);
 
     wxString GetValue() const;
diff --git a/include/wx/mac/carbon/combobox.h b/include/wx/mac/carbon/combobox.h
index b72509253d..34e982c20b 100644
--- a/include/wx/mac/carbon/combobox.h
+++ b/include/wx/mac/carbon/combobox.h
@@ -97,7 +97,6 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase
     virtual wxString GetString(int n) const ;
     virtual wxString GetStringSelection() const ;
     virtual void SetString(int n, const wxString& s) ;
-    virtual bool SetStringSelection(const wxString& sel);
 
     // Text field functions
     virtual wxString GetValue() const ;
diff --git a/include/wx/mac/classic/combobox.h b/include/wx/mac/classic/combobox.h
index b59bce7a64..f97c8a627f 100644
--- a/include/wx/mac/classic/combobox.h
+++ b/include/wx/mac/classic/combobox.h
@@ -92,7 +92,6 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase
     virtual wxString GetString(int n) const ;
     virtual wxString GetStringSelection() const ;
     virtual void SetString(int n, const wxString& s) ;
-    virtual bool SetStringSelection(const wxString& sel);
 
     // Text field functions
     virtual wxString GetValue() const ;
diff --git a/include/wx/univ/combobox.h b/include/wx/univ/combobox.h
index 32f2881cad..51012743f1 100644
--- a/include/wx/univ/combobox.h
+++ b/include/wx/univ/combobox.h
@@ -305,8 +305,6 @@ public:
     virtual int GetSelection() const;
     void SetSelection(int n) { Select(n); }
 
-    void SetStringSelection(const wxString& WXUNUSED(s)) {  }
-
     wxCONTROL_ITEMCONTAINER_CLIENTDATAOBJECT_RECAST
 
 protected:
diff --git a/src/cocoa/combobox.mm b/src/cocoa/combobox.mm
index e016e89205..86ce625c2e 100644
--- a/src/cocoa/combobox.mm
+++ b/src/cocoa/combobox.mm
@@ -80,10 +80,6 @@ wxString wxComboBox::GetStringSelection()
     return wxEmptyString;
 }
 
-void wxComboBox::SetStringSelection(const wxString& selection)
-{
-}
-
 void wxComboBox::Clear()
 {
 }
@@ -108,7 +104,7 @@ void wxComboBox::SetString(int, const wxString&)
 
 int wxComboBox::FindString(const wxString&) const
 {
-    return 0;
+    return wxNOT_FOUND;
 }
 
 int wxComboBox::GetSelection() const
diff --git a/src/common/choiccmn.cpp b/src/common/choiccmn.cpp
index d090aafd74..50c633894e 100644
--- a/src/common/choiccmn.cpp
+++ b/src/common/choiccmn.cpp
@@ -43,21 +43,6 @@ wxChoiceBase::~wxChoiceBase()
     // this destructor is required for Darwin
 }
 
-// ----------------------------------------------------------------------------
-// selection
-// ----------------------------------------------------------------------------
-
-bool wxChoiceBase::SetStringSelection(const wxString& s)
-{
-    int sel = FindString(s);
-    wxCHECK_MSG( sel != -1, false,
-                 wxT("invalid string in wxChoice::SetStringSelection") );
-
-    Select(sel);
-
-    return true;
-}
-
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
diff --git a/src/common/ctrlsub.cpp b/src/common/ctrlsub.cpp
index cf913548e0..59a9c9832b 100644
--- a/src/common/ctrlsub.cpp
+++ b/src/common/ctrlsub.cpp
@@ -58,6 +58,17 @@ wxString wxItemContainer::GetStringSelection() const
     return s;
 }
 
+bool wxItemContainer::SetStringSelection(const wxString& s)
+{
+    const int sel = FindString(s);
+    if ( sel == wxNOT_FOUND )
+        return false;
+
+    Select(sel);
+
+    return true;
+}
+
 wxArrayString wxItemContainer::GetStrings() const
 {
     wxArrayString result ;
diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp
index e5dd27f1ea..0e16d9ae26 100644
--- a/src/gtk/combobox.cpp
+++ b/src/gtk/combobox.cpp
@@ -644,16 +644,6 @@ void wxComboBox::SetSelection( int n )
     EnableEvents();
 }
 
-bool wxComboBox::SetStringSelection( const wxString &string )
-{
-    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid combobox") );
-
-    int res = FindString( string );
-    if (res == -1) return false;
-    SetSelection( res );
-    return true;
-}
-
 wxString wxComboBox::GetValue() const
 {
     GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp
index e5dd27f1ea..0e16d9ae26 100644
--- a/src/gtk1/combobox.cpp
+++ b/src/gtk1/combobox.cpp
@@ -644,16 +644,6 @@ void wxComboBox::SetSelection( int n )
     EnableEvents();
 }
 
-bool wxComboBox::SetStringSelection( const wxString &string )
-{
-    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid combobox") );
-
-    int res = FindString( string );
-    if (res == -1) return false;
-    SetSelection( res );
-    return true;
-}
-
 wxString wxComboBox::GetValue() const
 {
     GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp
index 7e6da680cf..7e83e671aa 100644
--- a/src/mac/carbon/combobox.cpp
+++ b/src/mac/carbon/combobox.cpp
@@ -565,18 +565,6 @@ wxString wxComboBox::GetStringSelection() const
         return wxEmptyString;
 }
 
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
-    int s = FindString (sel);
-    if (s > -1)
-        {
-            SetSelection (s);
-            return true;
-        }
-    else
-        return false;
-}
-
 void wxComboBox::SetString(int n, const wxString& s)
 {
     m_choice->SetString( n , s ) ;
diff --git a/src/mac/carbon/combobxc.cpp b/src/mac/carbon/combobxc.cpp
index fcbdd47b6b..59c2d1db3b 100644
--- a/src/mac/carbon/combobxc.cpp
+++ b/src/mac/carbon/combobxc.cpp
@@ -721,18 +721,6 @@ wxString wxComboBox::GetStringSelection() const
 #endif
 }
 
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
-    int s = FindString (sel);
-    if (s > -1)
-        {
-            SetSelection (s);
-            return true;
-        }
-    else
-        return false;
-}
-
 void wxComboBox::SetString(int n, const wxString& s)
 {
 #if USE_HICOMBOBOX
diff --git a/src/mac/classic/combobox.cpp b/src/mac/classic/combobox.cpp
index 4991d4587c..8562e17e72 100644
--- a/src/mac/classic/combobox.cpp
+++ b/src/mac/classic/combobox.cpp
@@ -511,18 +511,6 @@ wxString wxComboBox::GetStringSelection() const
         return wxEmptyString;
 }
 
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
-    int s = FindString (sel);
-    if (s > -1)
-        {
-            SetSelection (s);
-            return true;
-        }
-    else
-        return false;
-}
-
 void wxComboBox::SetString(int n, const wxString& s)
 {
     m_choice->SetString( n , s ) ;
-- 
2.50.0

