repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / webpositive / autocompletion / AutoCompleterDefaultImpl.h
blob6c3e50e8f509e355b3e4ff60d359cdc29aa76c55
1 /*
2 * Copyright 2002-2006, project beam (http://sourceforge.net/projects/beam).
3 * All rights reserved. Distributed under the terms of the MIT License.
5 * Authors:
6 * Oliver Tappe <beam@hirschkaefer.de>
7 */
8 #ifndef _AUTO_COMPLETER_DEFAULT_IMPL_H
9 #define _AUTO_COMPLETER_DEFAULT_IMPL_H
11 #include <ListView.h>
12 #include <String.h>
14 #include "AutoCompleter.h"
16 class BDefaultPatternSelector : public BAutoCompleter::PatternSelector {
17 public:
18 virtual void SelectPatternBounds(const BString& text,
19 int32 caretPos, int32* start,
20 int32* length);
24 class BDefaultCompletionStyle : public BAutoCompleter::CompletionStyle {
25 public:
26 BDefaultCompletionStyle(
27 BAutoCompleter::EditView* editView,
28 BAutoCompleter::ChoiceModel* choiceModel,
29 BAutoCompleter::ChoiceView* choiceView,
30 BAutoCompleter::PatternSelector*
31 patternSelector);
32 virtual ~BDefaultCompletionStyle();
34 virtual bool Select(int32 index);
35 virtual bool SelectNext(bool wrap = false);
36 virtual bool SelectPrevious(bool wrap = false);
37 virtual bool IsChoiceSelected() const;
38 virtual int32 SelectedChoiceIndex() const;
40 virtual void ApplyChoice(bool hideChoices = true);
41 virtual void CancelChoice();
43 virtual void EditViewStateChanged(bool updateChoices);
45 private:
46 BString fFullEnteredText;
47 int32 fSelectedIndex;
48 int32 fPatternStartPos;
49 int32 fPatternLength;
50 bool fIgnoreEditViewStateChanges;
54 class BDefaultChoiceView : public BAutoCompleter::ChoiceView {
55 protected:
56 class ListView : public BListView {
57 public:
58 ListView(
59 BAutoCompleter::CompletionStyle* completer);
60 virtual void SelectionChanged();
61 virtual void MessageReceived(BMessage* msg);
62 virtual void MouseDown(BPoint point);
63 virtual void AttachedToWindow();
65 private:
66 BAutoCompleter::CompletionStyle* fCompleter;
69 class ListItem : public BListItem {
70 public:
71 ListItem(const BAutoCompleter::Choice* choice);
72 virtual void DrawItem(BView* owner, BRect frame,
73 bool complete = false);
74 private:
75 BString fPreText;
76 BString fMatchText;
77 BString fPostText;
80 public:
81 BDefaultChoiceView();
82 virtual ~BDefaultChoiceView();
84 virtual void SelectChoiceAt(int32 index);
85 virtual void ShowChoices(
86 BAutoCompleter::CompletionStyle* completer);
87 virtual void HideChoices();
88 virtual bool ChoicesAreShown();
89 virtual int32 CountVisibleChoices() const;
91 void SetMaxVisibleChoices(int32 choices);
92 int32 MaxVisibleChoices() const;
94 private:
95 BWindow* fWindow;
96 ListView* fListView;
97 int32 fMaxVisibleChoices;
100 #endif // _AUTO_COMPLETER_DEFAULT_IMPL_H