/////////////////////////////////////////////////////////////////////////////
-// Name: odcombo.cpp
+// Name: src/generic/odcombo.cpp
// Purpose: wxOwnerDrawnComboBox, wxVListBoxComboPopup
// Author: Jaakko Salli
// Modified by:
#pragma hdrstop
#endif
-#if wxUSE_OWNERDRAWNCOMBOBOX
+#if wxUSE_ODCOMBOBOX
+
+#include "wx/odcombo.h"
#ifndef WX_PRECOMP
#include "wx/log.h"
#endif
#include "wx/combo.h"
-#include "wx/odcombo.h"
-
// ============================================================================
// implementation
void wxVListBoxComboPopup::Init()
-/* : wxVListBox(),
- wxComboPopup(combo)*/
{
m_widestWidth = 0;
m_avgCharWidth = 0;
wxCoord wxVListBoxComboPopup::OnMeasureItem(size_t WXUNUSED(n)) const
{
- /*
- int itemHeight = m_combo->OnMeasureListItem(n);
- if ( itemHeight < 0 )
- itemHeight = m_itemHeight;
- */
return m_itemHeight;
}
{
value-=10;
}
- /*
- else if ( keycode == WXK_END )
- {
- value = itemCount-1;
- }
- else if ( keycode == WXK_HOME )
- {
- value = 0;
- }
- */
else
return false;
ClearClientDatas();
+ m_value = wxNOT_FOUND;
+
if ( IsCreated() )
wxVListBox::SetItemCount(0);
}
wxVListBox::SetItemCount( wxVListBox::GetItemCount()-1 );
}
-int wxVListBoxComboPopup::FindString(const wxString& s) const
+int wxVListBoxComboPopup::FindString(const wxString& s, bool bCase) const
{
- return m_strings.Index(s);
+ return m_strings.Index(s, bCase);
}
unsigned int wxVListBoxComboPopup::GetCount() const
void wxVListBoxComboPopup::SetSelection( int item )
{
- // This seems to be necessary (2.5.3 w/ MingW atleast)
- if ( item < -1 || item >= (int)m_strings.GetCount() )
- item = -1;
+ wxCHECK_RET( item == wxNOT_FOUND || ((unsigned int)item < GetCount()),
+ wxT("invalid index in wxVListBoxComboPopup::SetSelection") );
m_value = item;
// ----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE(wxOwnerDrawnComboBox, wxComboControl)
+BEGIN_EVENT_TABLE(wxOwnerDrawnComboBox, wxComboCtrl)
END_EVENT_TABLE()
-IMPLEMENT_DYNAMIC_CLASS2(wxOwnerDrawnComboBox, wxComboControl, wxControlWithItems)
+IMPLEMENT_DYNAMIC_CLASS2(wxOwnerDrawnComboBox, wxComboCtrl, wxControlWithItems)
void wxOwnerDrawnComboBox::Init()
{
const wxValidator& validator,
const wxString& name)
{
- return wxComboControl::Create(parent,id,value,pos,size,style,validator,name);
+ return wxComboCtrl::Create(parent,id,value,pos,size,style,validator,name);
}
wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent,
long style,
const wxValidator& validator,
const wxString& name)
- : wxComboControl()
+ : wxComboCtrl()
{
Init();
popup = new wxVListBoxComboPopup();
}
- wxComboControl::SetPopupControl(popup);
+ wxComboCtrl::SetPopupControl(popup);
wxASSERT(popup);
m_popupInterface = (wxVListBoxComboPopup*) popup;
m_popupInterface->Clear();
- GetTextCtrl()->SetValue(wxEmptyString);
+ SetValue(wxEmptyString);
}
void wxOwnerDrawnComboBox::Delete(unsigned int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxOwnerDrawnComboBox::Delete") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxOwnerDrawnComboBox::Delete") );
if ( GetSelection() == (int) n )
SetValue(wxEmptyString);
wxString wxOwnerDrawnComboBox::GetString(unsigned int n) const
{
- wxCHECK_MSG( (n >= 0) && (n < GetCount()), wxEmptyString, _T("invalid index in wxOwnerDrawnComboBox::GetString") );
+ wxCHECK_MSG( IsValid(n), wxEmptyString, _T("invalid index in wxOwnerDrawnComboBox::GetString") );
return m_popupInterface->GetString(n);
}
void wxOwnerDrawnComboBox::SetString(unsigned int n, const wxString& s)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxOwnerDrawnComboBox::SetString") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxOwnerDrawnComboBox::SetString") );
m_popupInterface->SetString(n,s);
}
-int wxOwnerDrawnComboBox::FindString(const wxString& s) const
+int wxOwnerDrawnComboBox::FindString(const wxString& s, bool bCase) const
{
wxASSERT_MSG( m_popupInterface, wxT("no popup interface") );
- return m_popupInterface->FindString(s);
+ return m_popupInterface->FindString(s, bCase);
}
void wxOwnerDrawnComboBox::Select(int n)
{
- wxCHECK_RET( (n >= -1) && (n < (int)GetCount()), _T("invalid index in wxOwnerDrawnComboBox::Select") );
+ wxCHECK_RET( (n == wxNOT_FOUND) || IsValid(n), _T("invalid index in wxOwnerDrawnComboBox::Select") );
EnsurePopupControl();
m_popupInterface->SetSelection(n);
int wxOwnerDrawnComboBox::DoInsert(const wxString& item, unsigned 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"));
EnsurePopupControl();
m_popupInterface->Insert(item,pos);
return (wxClientData*) DoGetItemClientData(n);
}
-#endif // wxUSE_OWNERDRAWNCOMBOBOX
+#endif // wxUSE_ODCOMBOBOX