xref: /haiku/src/apps/webpositive/autocompletion/TextViewCompleter.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
1 /*
2  * Copyright 2002-2006, project beam (http://sourceforge.net/projects/beam).
3  * All rights reserved. Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Oliver Tappe <beam@hirschkaefer.de>
7  */
8 #ifndef TEXT_CONTROL_COMPLETER_H
9 #define TEXT_CONTROL_COMPLETER_H
10 
11 #include <MessageFilter.h>
12 
13 #include "AutoCompleter.h"
14 
15 
16 class BTextView;
17 
18 class TextViewCompleter : protected BAutoCompleter, public BMessageFilter {
19 public:
20 								TextViewCompleter(BTextView* textView,
21 									ChoiceModel* choiceModel = NULL,
22 									PatternSelector* patternSelector = NULL);
23 	virtual						~TextViewCompleter();
24 
25 			void				SetModificationsReported(bool reported);
26 			void				TextModified(bool updateChoices);
27 
28 private:
29 	virtual	filter_result		Filter(BMessage* message, BHandler** target);
30 
31 	class TextViewWrapper : public EditView {
32 	public:
33 								TextViewWrapper(BTextView* textView);
34 		virtual	BRect			GetAdjustmentFrame();
35 		virtual	void			GetEditViewState(BString& text,
36 									int32* caretPos);
37 		virtual	void			SetEditViewState(const BString& text,
38 									int32 caretPos, int32 selectionLength = 0);
39 	private:
40 				BTextView*		fTextView;
41 	};
42 
43 private:
44 			BTextView*			fTextView;
45 			bool				fModificationsReported;
46 };
47 
48 #endif // TEXT_CONTROL_COMPLETER_H
49