int wxOwnerDrawnComboBox::DoInsertItems(const wxArrayStringsAdapter& items, unsigned int pos, void **clientData, wxClientDataType type) { EnsurePopupControl(); const unsigned int count = items.GetCount(); if ( HasFlag(wxCB_SORT) ) { int n = pos; for ( unsigned int i = 0; i < count; ++i ) { n = GetVListBoxComboPopup()->Append(items[i]); AssignNewItemClientData(n, clientData, i, type); } return n; } else { for ( unsigned int i = 0; i < count; ++i, ++pos ) { GetVListBoxComboPopup()->Insert(items[i], pos); AssignNewItemClientData(pos, clientData, i, type); } return pos - 1; } }
void* wxOwnerDrawnComboBox::DoGetItemClientData(unsigned int n) const { if ( !m_popupInterface ) return NULL; return GetVListBoxComboPopup()->GetItemClientData(n); }
int wxOwnerDrawnComboBox::GetSelection() const { if ( !m_popupInterface ) return m_initChs.Index(m_valueString); return GetVListBoxComboPopup()->GetSelection(); }
unsigned int wxOwnerDrawnComboBox::GetCount() const { if ( !m_popupInterface ) return m_initChs.GetCount(); return GetVListBoxComboPopup()->GetCount(); }
int wxOwnerDrawnComboBox::DoAppend(const wxString& item) { EnsurePopupControl(); wxASSERT(m_popupInterface); return GetVListBoxComboPopup()->Append(item); }
void ODIconCombo::OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const { int offset_x = bmpArray.Item(item).GetWidth(); int bmpHeight = bmpArray.Item(item).GetHeight(); dc.DrawBitmap(bmpArray.Item(item), rect.x, rect.y + (rect.height - bmpHeight)/2, true); if ( flags & wxODCB_PAINTING_CONTROL ) { wxString text = GetValue(); int margin_x = 2; #if wxCHECK_VERSION(2, 9, 0) if ( ShouldUseHintText() ) { text = GetHint(); wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); dc.SetTextForeground(col); } margin_x = GetMargins().x; #endif dc.DrawText( text, rect.x + margin_x + offset_x, (rect.height-dc.GetCharHeight())/2 + rect.y ); } else { dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2 + offset_x, (rect.height-dc.GetCharHeight())/2 + rect.y ); } }
void wxOwnerDrawnComboBox::OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const { if ( flags & wxODCB_PAINTING_CONTROL ) { wxString text; if ( !ShouldUseHintText() ) { text = GetValue(); } else { text = GetHint(); wxColour col = wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT); dc.SetTextForeground(col); } dc.DrawText( text, rect.x + GetMargins().x, (rect.height-dc.GetCharHeight())/2 + rect.y ); } else { dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2, rect.y ); } }
void wxOwnerDrawnComboBox::DoSetItemClientData(unsigned int n, void* clientData) { EnsurePopupControl(); GetVListBoxComboPopup()->SetItemClientData(n, clientData, GetClientDataType()); }
int wxOwnerDrawnComboBox::FindString(const wxString& s, bool bCase) const { if ( !m_popupInterface ) return m_initChs.Index(s, bCase); return GetVListBoxComboPopup()->FindString(s, bCase); }
void wxOwnerDrawnComboBox::SetString(unsigned int n, const wxString& s) { EnsurePopupControl(); wxCHECK_RET( IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::SetString") ); GetVListBoxComboPopup()->SetString(n,s); }
void wxOwnerDrawnComboBox::Clear() { EnsurePopupControl(); GetVListBoxComboPopup()->Clear(); SetValue(wxEmptyString); }
wxString wxOwnerDrawnComboBox::GetString(unsigned int n) const { wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("invalid index in wxOwnerDrawnComboBox::GetString") ); if ( !m_popupInterface ) return m_initChs.Item(n); return GetVListBoxComboPopup()->GetString(n); }
void wxOwnerDrawnComboBox::DoDeleteOneItem(unsigned int n) { wxCHECK_RET( IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::Delete") ); if ( GetSelection() == (int) n ) ChangeValue(wxEmptyString); GetVListBoxComboPopup()->Delete(n); }
void wxOwnerDrawnComboBox::DoSetPopupControl(wxComboPopup* popup) { if ( !popup ) { popup = new wxVListBoxComboPopup(); } wxComboCtrl::DoSetPopupControl(popup); wxASSERT(popup); // Add initial choices to the wxVListBox if ( !GetVListBoxComboPopup()->GetCount() ) { GetVListBoxComboPopup()->Populate(m_initChs); m_initChs.Clear(); } }
void wxOwnerDrawnComboBox::DoClear() { EnsurePopupControl(); GetVListBoxComboPopup()->Clear(); // NB: This really needs to be SetValue() instead of ChangeValue(), // as wxTextEntry API expects an event to be sent. SetValue(wxEmptyString); }
void wxOwnerDrawnComboBox::DoClear() { EnsurePopupControl(); GetVListBoxComboPopup()->Clear(); // There is no text entry when using wxCB_READONLY style, so test for it. if ( GetTextCtrl() ) wxTextEntry::Clear(); }
int wxOwnerDrawnComboBox::DoInsert(const wxString& item, unsigned int pos) { EnsurePopupControl(); wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list")); wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index")); GetVListBoxComboPopup()->Insert(item,pos); return pos; }
void wxOwnerDrawnComboBox::Select(int n) { EnsurePopupControl(); wxCHECK_RET( (n == wxNOT_FOUND) || IsValid(n), wxT("invalid index in wxOwnerDrawnComboBox::Select") ); GetVListBoxComboPopup()->SetSelection(n); wxString str; if ( n >= 0 ) str = GetVListBoxComboPopup()->GetString(n); // Refresh text portion in control if ( m_text ) m_text->ChangeValue( str ); else m_valueString = str; Refresh(); }
void wxOwnerDrawnComboBox::OnDrawItem( wxDC& dc, const wxRect& rect, int item, int flags ) const { if ( flags & wxODCB_PAINTING_CONTROL ) { dc.DrawText( GetValue(), rect.x + GetTextIndent(), (rect.height-dc.GetCharHeight())/2 + rect.y ); } else { dc.DrawText( GetVListBoxComboPopup()->GetString(item), rect.x + 2, rect.y ); } }
wxOwnerDrawnComboBox::~wxOwnerDrawnComboBox() { if ( m_popupInterface ) GetVListBoxComboPopup()->ClearClientDatas(); }