implemented wxChoice::Delete

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15108 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2002-04-12 09:31:12 +00:00
parent fc51b8c37e
commit 645420d872
4 changed files with 59 additions and 4 deletions

View File

@ -192,6 +192,7 @@ wxGTK:
- fixed wxDC::Blit() to honour source DC's logical coordinates
- implemented wxIdleEvent::RequestMore() for simple background tasks
(unlike thread work)
- implemented wxChoice::Delete()
wxHTML:

View File

@ -119,6 +119,16 @@ Clears the strings from the choice item.
Creates the choice for two-step construction. See \helpref{wxChoice::wxChoice}{wxchoiceconstr}.
\membersection{wxChoice::Delete}\label{wxchoicedelete}
\func{void}{Delete}{\param{int }{n}}
Deletes the item with the given index from the control.
\wxheading{Parameters}
\docparam{n}{The item to delete.}
\membersection{wxChoice::FindString}\label{wxchoicefindstring}
\constfunc{int}{FindString}{\param{const wxString\& }{string}}

View File

@ -209,9 +209,31 @@ void wxChoice::Clear()
m_strings->Clear();
}
void wxChoice::Delete( int WXUNUSED(n) )
void wxChoice::Delete( int n )
{
wxFAIL_MSG( wxT("wxChoice:Delete not implemented") );
wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
// VZ: apparently GTK+ doesn't have a built-in function to do it (not even
// in 2.0), hence this dump implementation - still better than nothing
int i,
count = GetCount();
wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") );
wxArrayString items;
items.Alloc(count);
for ( i = 0; i < count; i++ )
{
if ( i != n )
items.Add(GetString(i));
}
Clear();
for ( i = 0; i < count - 1; i++ )
{
Append(items[i]);
}
}
int wxChoice::FindString( const wxString &string ) const

View File

@ -209,9 +209,31 @@ void wxChoice::Clear()
m_strings->Clear();
}
void wxChoice::Delete( int WXUNUSED(n) )
void wxChoice::Delete( int n )
{
wxFAIL_MSG( wxT("wxChoice:Delete not implemented") );
wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
// VZ: apparently GTK+ doesn't have a built-in function to do it (not even
// in 2.0), hence this dump implementation - still better than nothing
int i,
count = GetCount();
wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") );
wxArrayString items;
items.Alloc(count);
for ( i = 0; i < count; i++ )
{
if ( i != n )
items.Add(GetString(i));
}
Clear();
for ( i = 0; i < count - 1; i++ )
{
Append(items[i]);
}
}
int wxChoice::FindString( const wxString &string ) const