From 7bbf6255aa2b342586841c21efbb571b6b9d27de Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 12 Jul 2000 07:21:46 +0000 Subject: Added John's autocompletion changes and fiddled to make autocompletion list size better. --- win32/PlatWin.cxx | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index bea215566..87f90cfa1 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -698,7 +698,7 @@ HINSTANCE Window::GetInstance() { ::GetWindowLong(id,GWL_HINSTANCE)); } -ListBox::ListBox() { +ListBox::ListBox() : desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(8) { } ListBox::~ListBox() { @@ -712,12 +712,45 @@ void ListBox::Create(Window &parent, int ctrlID) { parent.GetInstance(), 0); } +void ListBox::SetFont(Font &font) { + Window::SetFont(font); +} + +void ListBox::SetAverageCharWidth(int width) { + aveCharWidth = width; +} + +void ListBox::SetVisibleRows(int rows) { + desiredVisibleRows = rows; +} + +PRectangle ListBox::GetDesiredRect() { + PRectangle rcDesired = GetPosition(); + int itemHeight = SendMessage(LB_GETITEMHEIGHT, 0); + int rows = Length(); + if ((rows == 0) || (rows > desiredVisibleRows)) + rows = desiredVisibleRows; + // The +6 allows for borders + rcDesired.bottom = rcDesired.top + 6 + itemHeight * rows; + int width = maxItemCharacters; + if (width < 12) + width = 12; + rcDesired.right = rcDesired.left + width * (aveCharWidth+aveCharWidth/3); + if (Length() > rows) + rcDesired.right = rcDesired.right + GetSystemMetrics(SM_CXVSCROLL); + return rcDesired; +} + void ListBox::Clear() { SendMessage(LB_RESETCONTENT); + maxItemCharacters = 0; } void ListBox::Append(char *s) { SendMessage(LB_ADDSTRING, 0, reinterpret_cast(s)); + size_t len = strlen(s); + if (maxItemCharacters < len) + maxItemCharacters = len; } int ListBox::Length() { @@ -733,7 +766,8 @@ int ListBox::GetSelection() { } int ListBox::Find(const char *prefix) { - return SendMessage(LB_FINDSTRING, 0, reinterpret_cast(prefix)); + return SendMessage(LB_FINDSTRING, static_cast(-1), + reinterpret_cast(prefix)); } void ListBox::GetValue(int n, char *value, int len) { -- cgit v1.2.3