don't duplicate wxItemContainer methods in wxRadioBoxBase, instead extract the common intersection to a new wxItemContainerImmutable class and derive wxRadioBoxBase from it

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32008 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-02-13 19:01:17 +00:00
parent e9923becbe
commit 8ba7c77150
4 changed files with 78 additions and 83 deletions

View File

@@ -36,10 +36,10 @@
#endif
// ============================================================================
// implementation
// wxItemContainerImmutable implementation
// ============================================================================
wxItemContainer::~wxItemContainer()
wxItemContainerImmutable::~wxItemContainerImmutable()
{
// this destructor is required for Darwin
}
@@ -48,7 +48,7 @@ wxItemContainer::~wxItemContainer()
// selection
// ----------------------------------------------------------------------------
wxString wxItemContainer::GetStringSelection() const
wxString wxItemContainerImmutable::GetStringSelection() const
{
wxString s;
int sel = GetSelection();
@@ -58,7 +58,7 @@ wxString wxItemContainer::GetStringSelection() const
return s;
}
bool wxItemContainer::SetStringSelection(const wxString& s)
bool wxItemContainerImmutable::SetStringSelection(const wxString& s)
{
const int sel = FindString(s);
if ( sel == wxNOT_FOUND )
@@ -69,13 +69,25 @@ bool wxItemContainer::SetStringSelection(const wxString& s)
return true;
}
wxArrayString wxItemContainer::GetStrings() const
wxArrayString wxItemContainerImmutable::GetStrings() const
{
wxArrayString result ;
size_t count = GetCount() ;
for ( size_t n = 0 ; n < count ; n++ )
wxArrayString result;
const size_t count = GetCount();
result.Alloc(count);
for ( size_t n = 0; n < count; n++ )
result.Add(GetString(n));
return result ;
return result;
}
// ============================================================================
// wxItemContainer implementation
// ============================================================================
wxItemContainer::~wxItemContainer()
{
// this destructor is required for Darwin
}
// ----------------------------------------------------------------------------

View File

@@ -38,6 +38,18 @@
// implementation
// ============================================================================
int wxRadioBoxBase::FindString(const wxString& s) const
{
int count = GetCount();
for ( int n = 0; n < count; n++ )
{
if ( GetString(n) == s )
return n;
}
return wxNOT_FOUND;
}
int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const
{
int count = GetCount(),