diff options
author | nyamatongwe <unknown> | 2003-01-10 11:16:25 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2003-01-10 11:16:25 +0000 |
commit | 01b9516c3f69e6be8497f32c35aee17f74aba86b (patch) | |
tree | 7939b3d549d0aa57d21876b89e550724d1714e6b /src/AutoComplete.cxx | |
parent | a5ff7b278c50fc280e388ed609e960766a00bedd (diff) | |
download | scintilla-mirror-01b9516c3f69e6be8497f32c35aee17f74aba86b.tar.gz |
Changed listbox member to a pointer to allow use of platform-specific
subclass.
Diffstat (limited to 'src/AutoComplete.cxx')
-rw-r--r-- | src/AutoComplete.cxx | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index 8b788be06..adbd24d03 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -2,7 +2,7 @@ /** @file AutoComplete.cxx ** Defines the auto completion list box. **/ -// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org> +// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org> // The License.txt file describes the conditions under which this software may be distributed. #include <stdlib.h> @@ -20,28 +20,36 @@ AutoComplete::AutoComplete() : typesep('?'), ignoreCase(false), chooseSingle(false), + lb(0), posStart(0), startLen(0), cancelAtStartPos(true), autoHide(true), dropRestOfWord(false) { + lb = ListBox::Allocate(); stopChars[0] = '\0'; fillUpChars[0] = '\0'; } AutoComplete::~AutoComplete() { - lb.Destroy(); + if (lb) { + lb->Destroy(); + delete lb; + lb = 0; + } } bool AutoComplete::Active() { return active; } -void AutoComplete::Start(Window &parent, int ctrlID, int position, int startLen_) { - if (!lb.Created()) { - lb.Create(parent, ctrlID); +void AutoComplete::Start(Window &parent, int ctrlID, int position, + int startLen_, int lineHeight, bool unicodeMode) { + if (active) { + Cancel(); } - lb.Clear(); + lb->Create(parent, ctrlID, lineHeight, unicodeMode); + lb->Clear(); active = true; startLen = startLen_; posStart = position; @@ -82,7 +90,7 @@ char AutoComplete::GetTypesep() { } void AutoComplete::SetList(const char *list) { - lb.Clear(); + lb->Clear(); char *words = new char[strlen(list) + 1]; if (words) { strcpy(words, list); @@ -94,7 +102,7 @@ void AutoComplete::SetList(const char *list) { words[i] = '\0'; if (numword) *numword = '\0'; - lb.Append(startword, numword?atoi(numword + 1):0); + lb->Append(startword, numword?atoi(numword + 1):-1); startword = words + i + 1; numword = NULL; } else if (words[i] == typesep) { @@ -104,34 +112,34 @@ void AutoComplete::SetList(const char *list) { if (startword) { if (numword) *numword = '\0'; - lb.Append(startword, numword?atoi(numword + 1):0); + lb->Append(startword, numword?atoi(numword + 1):-1); } delete []words; } } void AutoComplete::Show() { - lb.Show(); - lb.Select(0); + lb->Show(); + lb->Select(0); } void AutoComplete::Cancel() { - if (lb.Created()) { - lb.Destroy(); + if (lb->Created()) { + lb->Destroy(); active = false; } } void AutoComplete::Move(int delta) { - int count = lb.Length(); - int current = lb.GetSelection(); + int count = lb->Length(); + int current = lb->GetSelection(); current += delta; if (current >= count) current = count - 1; if (current < 0) current = 0; - lb.Select(current); + lb->Select(current); } void AutoComplete::Select(const char *word) { @@ -140,10 +148,10 @@ void AutoComplete::Select(const char *word) { const int maxItemLen=1000; char item[maxItemLen]; int start = 0; // lower bound of the api array block to search - int end = lb.Length() - 1; // upper bound of the api array block to search + int end = lb->Length() - 1; // upper bound of the api array block to search while ((start <= end) && (location == -1)) { // Binary searching loop int pivot = (start + end) / 2; - lb.GetValue(pivot, item, maxItemLen); + lb->GetValue(pivot, item, maxItemLen); int cond; if (ignoreCase) cond = CompareNCaseInsensitive(word, item, lenWord); @@ -152,7 +160,7 @@ void AutoComplete::Select(const char *word) { if (!cond) { // Find first match while (pivot > start) { - lb.GetValue(pivot-1, item, maxItemLen); + lb->GetValue(pivot-1, item, maxItemLen); if (ignoreCase) cond = CompareNCaseInsensitive(word, item, lenWord); else @@ -171,6 +179,6 @@ void AutoComplete::Select(const char *word) { if (location == -1 && autoHide) Cancel(); else - lb.Select(location); + lb->Select(location); } |