diff options
author | nyamatongwe <unknown> | 2005-03-25 05:08:19 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2005-03-25 05:08:19 +0000 |
commit | 221524e05b3e8566c0523b960ff9fdd55e1f2dc6 (patch) | |
tree | 3aa540e36a7ccf7eb74c51ecfb7b78e91531648b /gtk | |
parent | 937ba26991eff9ec535e40288b132ce1e03954c2 (diff) | |
download | scintilla-mirror-221524e05b3e8566c0523b960ff9fdd55e1f2dc6.tar.gz |
Patch from Blair McGlashan for autocompletion on Windows to
* Set maximum width of list
* set maximum height of list
* better calculate width
* use ellipsis when text is truncated to fit window
* use popup window so it can extend past parent window
* disallow resizing too small
* draw to bottom edge when resized so last item not full line high
* improve time to display by by 90%
Minor tweaks by me to fix warnings, layout etc.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/PlatGTK.cxx | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 00dc3d2a8..9ba18a8ce 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -1794,9 +1794,10 @@ public: } } virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, int lineHeight_, bool unicodeMode_); + virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_); virtual void SetAverageCharWidth(int width); virtual void SetVisibleRows(int rows); + virtual int GetVisibleRows() const; virtual PRectangle GetDesiredRect(); virtual int CaretFromEdge(); virtual void Clear(); @@ -1812,6 +1813,7 @@ public: doubleClickAction = action; doubleClickActionData = data; } + virtual void SetList(const char* list, char separator, char typesep); }; ListBox *ListBox::Allocate() { @@ -1842,7 +1844,7 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { return FALSE; } -void ListBoxX::Create(Window &, int, int, bool) { +void ListBoxX::Create(Window &, int, Point, int, bool) { id = gtk_window_new(GTK_WINDOW_POPUP); GtkWidget *frame = gtk_frame_new(NULL); @@ -1936,6 +1938,10 @@ void ListBoxX::SetVisibleRows(int rows) { desiredVisibleRows = rows; } +int ListBoxX::GetVisibleRows() const { + return desiredVisibleRows; +} + PRectangle ListBoxX::GetDesiredRect() { // Before any size allocated pretend its 100 wide so not scrolled PRectangle rc(0, 0, 100, 100); @@ -2280,6 +2286,36 @@ void ListBoxX::ClearRegisteredImages() { xset.Clear(); } +void ListBoxX::SetList(const char* list, char separator, char typesep) { + Clear(); + int count = strlen(list) + 1; + char *words = new char[count]; + if (words) { + memcpy(words, list, count); + char *startword = words; + char *numword = NULL; + int i = 0; + for (; words[i]; i++) { + if (words[i] == separator) { + words[i] = '\0'; + if (numword) + *numword = '\0'; + Append(startword, numword?atoi(numword + 1):-1); + startword = words + i + 1; + numword = NULL; + } else if (words[i] == typesep) { + numword = words + i; + } + } + if (startword) { + if (numword) + *numword = '\0'; + Append(startword, numword?atoi(numword + 1):-1); + } + delete []words; + } +} + Menu::Menu() : id(0) {} void Menu::CreatePopUp() { |