38 #include <wx/textctrl.h>
62 wxArrayString choices;
64 parent,
id,
wxT(
""), wxDefaultPosition, wxDefaultSize,
65 choices, wxCB_DROPDOWN
72 const wxString&
value,
75 const wxArrayString& choices,
77 const wxValidator& validator,
85 Create( parent,
id,
value, pos,
size, choices, style | wxCB_DROPDOWN, validator, name );
109 const wxString&
value,
112 const wxArrayString& choices,
114 const wxValidator& validator,
120 wxComboBox::Create( parent,
id,
value, pos,
size, choices, style, validator, name );
141 wxString
value = GetValue();
147 if (GetCount()) Delete(0);
165 (event.GetString().length() <=
m_PrevValue.length()) ){
174 wxString cur_value =
event.GetString();
175 long cur_pt = GetInsertionPoint();
178 cur_value = cur_value.Mid( 0, cur_value.Len() -1 );
190 wxArrayString new_base_choices =
ProvideItems( cur_value );
193 wxString cur_low =
m_IgnoreCase ? cur_value.Lower() : cur_value;
194 unsigned int matched_ix = 0;
195 while( matched_ix < compare_to->GetCount() ){
196 wxString cmp_str =
m_IgnoreCase ? (*compare_to)[matched_ix].Lower() : (*compare_to)[matched_ix];
198 if( cmp_str.StartsWith( cur_low ) ){
203 if( matched_ix == compare_to->GetCount() ){
220 SetValue( cur_value );
221 SetInsertionPoint( cur_pt );
235 wxString cur_value =
event.GetString();
236 long cur_pt = GetInsertionPoint();
242 bool to_be_completed = cur_pt == GetLastPosition();
269 _TRACE(
"CAutoCompleteCombo::OnItemSelected index " << event.GetSelection() );
271 wxString cur_value =
m_IgnoreCase ? GetValue().Lower() : GetValue();
274 if( cur_value.StartsWith( prev_value ) ){
275 SetInsertionPoint( (
long)prev_value.Length() );
276 SetSelection( (
int)prev_value.Length(), -1 );
279 if( cur_value.StartsWith( prev_value ) ){
280 SetInsertionPoint( (
long)prev_value.Length() );
281 SetSelection( (
int)prev_value.Length(), -1 );
296 _TRACE(
"CAutoCompleteCombo::OnKeyDown " << event.GetKeyCode() );
298 int kc =
event.GetKeyCode();
301 if( (kc == WXK_BACK || kc == WXK_CLEAR) ){
302 #if defined(__WXMAC__)
303 if( GetSelection() == GetLastPosition() ){
308 GetSelection( &from, &to );
309 if( from != to && to == GetLastPosition() ){
321 _TRACE(
"CAutoCompleteCombo::OnIdle" );
338 wxString orig_value = GetValue();
341 for(
unsigned int i = 0;
i < GetCount();
i++ ){
342 wxString
value = GetString(
i );
344 if( str_value.StartsWith(
prefix ) ){
346 if (
value != orig_value) {
348 SetSelection( (
int)
prefix.Len(), -1 );
357 wxArrayString wx_items;
360 vector<string> items;
364 for(
int i = 0;
i < (
int)items.size();
i++ ){
374 wxArrayString new_choices;
375 wxString pat_low =
m_IgnoreCase ? pattern.Lower() : pattern;
379 if( base_choice.StartsWith( pat_low ) ){
#define DICTIONARY_MAX_SIZE
CAutoCompleteCombo(wxWindow *parent, wxWindowID id=wxID_ANY)
wxArrayString m_PrevArray
void SetBaseItems(const wxArrayString &choices)
wxArrayString GetFilteredItems(const wxString &pattern)
void x_OnTimer(wxTimerEvent &event)
wxArrayString m_BaseChoices
void GetBaseItems(wxArrayString &choices)
virtual wxArrayString ProvideItems(const wxString &pattern)
void OnIdle(wxIdleEvent &event)
bool m_BlockTextChangedEvents
void OnKeyDown(wxKeyEvent &event)
bool m_IgnoreNextTextChangedEvent
void x_AutoComplete()
Completes value from available choices.
virtual ~CAutoCompleteCombo()
void OnItemSelected(wxCommandEvent &event)
CIRef< IFilterItems > m_Provider
void Create(wxWindow *parent, wxWindowID id, const wxString &value, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=wxCB_DROPDOWN, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxT("auto complete combo"))
void OnTextChanged(wxCommandEvent &event)
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
static const char * prefix[]
wxString ToWxString(const string &s)
string ToStdString(const wxString &s)