virtual void SetSelection(int n) { DoSetSelection(n, true); }
void SetSelection(int n, bool select) { DoSetSelection(n, select); }
+ // used to process wxUniv actions
+ bool PerformAction(const wxControlAction& action,
+ long numArg,
+ const wxString& strArg);
+
protected:
// we shouldn't return height too big from here
virtual wxSize DoGetBestClientSize() const;
// called whenever the user selects or activates a listbox item
void OnSelect(wxCommandEvent& event);
- // used to process wxUniv actions
- bool PerformAction(const wxControlAction& action,
- long numArg,
- const wxString& strArg);
-
private:
// has the mouse been released on this control?
bool m_clicked;
// always matches), but we want to show the first one in such case
if ( value.empty() )
{
- if ( GetCount() )
+ if ( GetCount() > 0 )
{
wxListBox::SetSelection(0);
}
void wxComboBox::Delete(int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Delete") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::Delete") );
if (GetSelection() == n)
GetText()->SetValue(wxEmptyString);
GetLBox()->Delete(n);
}
-int wxComboBox::GetCount() const
+size_t wxComboBox::GetCount() const
{
return GetLBox()->GetCount();
}
wxString wxComboBox::GetString(int n) const
{
- wxCHECK_MSG( (n >= 0) && (n < GetCount()), wxEmptyString, _T("invalid index in wxComboBox::GetString") );
+ wxCHECK_MSG( IsValid(n), wxEmptyString, _T("invalid index in wxComboBox::GetString") );
return GetLBox()->GetString(n);
}
void wxComboBox::SetString(int n, const wxString& s)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::SetString") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::SetString") );
GetLBox()->SetString(n, s);
}
void wxComboBox::SetSelection(int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Select") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::Select") );
GetLBox()->SetSelection(n);
GetText()->SetValue(GetLBox()->GetString(n));
int wxComboBox::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+ wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
- if (pos == GetCount())
+ if ((size_t)pos == GetCount())
return DoAppend(item);
GetLBox()->Insert(item, pos);