From 36badc2d94f226f8c72178e62b8de8fef33ceba2 Mon Sep 17 00:00:00 2001 From: leavengood Date: Wed, 29 Dec 2010 21:00:13 +0000 Subject: [PATCH] Add a scrollview (with associated resizing trickery to cut-off the sides of the scrollbar) to the auto-complete list. This now also makes the scrollwheel work but selection by mouse still needs implementing. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@561 94f232f2-1747-11df-bad5-a5bfde151594 --- .../autocompletion/AutoCompleterDefaultImpl.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/apps/webpositive/autocompletion/AutoCompleterDefaultImpl.cpp b/src/apps/webpositive/autocompletion/AutoCompleterDefaultImpl.cpp index 5c4d742aaf..4bfd556175 100644 --- a/src/apps/webpositive/autocompletion/AutoCompleterDefaultImpl.cpp +++ b/src/apps/webpositive/autocompletion/AutoCompleterDefaultImpl.cpp @@ -10,6 +10,7 @@ #include #include +#include #include @@ -324,7 +325,7 @@ BDefaultChoiceView::BDefaultChoiceView() : fWindow(NULL), fListView(NULL), - fMaxVisibleChoices(5) + fMaxVisibleChoices(8) { } @@ -373,10 +374,12 @@ BDefaultChoiceView::ShowChoices(BAutoCompleter::CompletionStyle* completer) ); } + BScrollView *scrollView = new BScrollView("", fListView, B_FOLLOW_NONE, 0, false, true, B_NO_BORDER); + fWindow = new BWindow(BRect(0, 0, 100, 100), "", B_BORDERED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_MOVABLE | B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FOCUS | B_ASYNCHRONOUS_CONTROLS); - fWindow->AddChild(fListView); + fWindow->AddChild(scrollView); int32 visibleCount = min_c(count, fMaxVisibleChoices); float listHeight = fListView->ItemFrame(visibleCount - 1).bottom + 1; @@ -390,8 +393,13 @@ BDefaultChoiceView::ShowChoices(BAutoCompleter::CompletionStyle* completer) else listRect.OffsetTo(pvRect.left, pvRect.top - listHeight); - fListView->MoveTo(0, 0); - fListView->ResizeTo(listRect.Width(), listRect.Height()); + // Moving here to cut off the scrollbar top + scrollView->MoveTo(0, -1); + // Adding the 1 and 2 to cut-off the scroll-bar top, right and bottom + scrollView->ResizeTo(listRect.Width() + 1, listRect.Height() + 2); + // Move here to compensate for the above + fListView->MoveTo(0, 1); + fListView->ResizeTo(listRect.Width() - B_V_SCROLL_BAR_WIDTH, listRect.Height()); fWindow->MoveTo(listRect.left, listRect.top); fWindow->ResizeTo(listRect.Width(), listRect.Height()); fWindow->Show();