///////////////////////////////////////////////////////////////////////////////
-// Name: common/ctrlsub.cpp
+// Name: src/common/ctrlsub.cpp
// Purpose: wxItemContainer implementation
// Author: Vadim Zeitlin
// Modified by:
// Created: 22.10.99
// RCS-ID: $Id$
-// Copyright: (c) wxWindows team
+// Copyright: (c) wxWidgets team
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "controlwithitems.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/arrstr.h"
#endif
+IMPLEMENT_ABSTRACT_CLASS(wxControlWithItems, wxControl)
+
// ============================================================================
-// implementation
+// wxItemContainerImmutable implementation
// ============================================================================
-wxItemContainer::~wxItemContainer()
+wxItemContainerImmutable::~wxItemContainerImmutable()
{
// this destructor is required for Darwin
}
// selection
// ----------------------------------------------------------------------------
-wxString wxItemContainer::GetStringSelection() const
+wxString wxItemContainerImmutable::GetStringSelection() const
{
wxString s;
+
int sel = GetSelection();
- if ( sel != -1 )
- s = GetString(sel);
+ if ( sel != wxNOT_FOUND )
+ s = GetString((unsigned int)sel);
return s;
}
+bool wxItemContainerImmutable::SetStringSelection(const wxString& s)
+{
+ const int sel = FindString(s);
+ if ( sel == wxNOT_FOUND )
+ return false;
+
+ SetSelection(sel);
+
+ return true;
+}
+
+wxArrayString wxItemContainerImmutable::GetStrings() const
+{
+ wxArrayString result;
+
+ const unsigned int count = GetCount();
+ result.Alloc(count);
+ for ( unsigned int n = 0; n < count; n++ )
+ result.Add(GetString(n));
+
+ return result;
+}
+
+// ============================================================================
+// wxItemContainer implementation
+// ============================================================================
+
+wxItemContainer::~wxItemContainer()
+{
+ // this destructor is required for Darwin
+}
+
// ----------------------------------------------------------------------------
// appending items
// ----------------------------------------------------------------------------
void wxItemContainer::Append(const wxArrayString& strings)
{
- size_t count = strings.GetCount();
+ const size_t count = strings.GetCount();
for ( size_t n = 0; n < count; n++ )
{
Append(strings[n]);
}
}
-int wxItemContainer::Insert(const wxString& item, int pos, void *clientData)
+int wxItemContainer::Insert(const wxString& item, unsigned int pos, void *clientData)
{
int n = DoInsert(item, pos);
if ( n != wxNOT_FOUND )
return n;
}
-int
-wxItemContainer::Insert(const wxString& item, int pos, wxClientData *clientData)
+int wxItemContainer::Insert(const wxString& item, unsigned int pos, wxClientData *clientData)
{
int n = DoInsert(item, pos);
if ( n != wxNOT_FOUND )
// client data
// ----------------------------------------------------------------------------
-void wxItemContainer::SetClientObject(int n, wxClientData *data)
+void wxItemContainer::SetClientObject(unsigned int n, wxClientData *data)
{
wxASSERT_MSG( m_clientDataItemsType != wxClientData_Void,
wxT("can't have both object and void client data") );
DoSetItemClientObject(n, data);
}
-wxClientData *wxItemContainer::GetClientObject(int n) const
+wxClientData *wxItemContainer::GetClientObject(unsigned int n) const
{
wxASSERT_MSG( m_clientDataItemsType == wxClientData_Object,
wxT("this window doesn't have object client data") );
return DoGetItemClientObject(n);
}
-void wxItemContainer::SetClientData(int n, void *data)
+void wxItemContainer::SetClientData(unsigned int n, void *data)
{
wxASSERT_MSG( m_clientDataItemsType != wxClientData_Object,
wxT("can't have both object and void client data") );
m_clientDataItemsType = wxClientData_Void;
}
-void *wxItemContainer::GetClientData(int n) const
+void *wxItemContainer::GetClientData(unsigned int n) const
{
wxASSERT_MSG( m_clientDataItemsType == wxClientData_Void,
wxT("this window doesn't have void client data") );