xref: /haiku/src/apps/aboutsystem/HyperTextView.h (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2  * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT license.
4  */
5 #ifndef HYPER_TEXT_VIEW_H
6 #define HYPER_TEXT_VIEW_H
7 
8 #include <TextView.h>
9 
10 
11 // TODO: The current implementation works correctly only for insertions at the
12 // end of the text. It doesn't keep track of any other insertions or deletions.
13 
14 
15 class HyperTextView;
16 
17 
18 class HyperTextAction {
19 public:
20 								HyperTextAction();
21 	virtual						~HyperTextAction();
22 
23 	virtual	void				MouseOver(HyperTextView* view, BPoint where,
24 									BMessage* message);
25 	virtual	void				Clicked(HyperTextView* view, BPoint where,
26 									BMessage* message);
27 };
28 
29 
30 class HyperTextView : public BTextView {
31 public:
32 								HyperTextView(const char* name,
33 									uint32 flags = B_WILL_DRAW
34 										| B_PULSE_NEEDED);
35 								HyperTextView(BRect frame, const char* name,
36 									BRect textRect, uint32 resizeMask,
37 									uint32 flags = B_WILL_DRAW
38 										| B_PULSE_NEEDED);
39 	virtual						~HyperTextView();
40 
41 	virtual	void				MouseDown(BPoint where);
42 	virtual	void				MouseUp(BPoint where);
43 	virtual	void				MouseMoved(BPoint where, uint32 transit,
44 									const BMessage* dragMessage);
45 
46 			void				AddHyperTextAction(int32 startOffset,
47 									int32 endOffset, HyperTextAction* action);
48 
49 			void				InsertHyperText(const char* inText,
50 									HyperTextAction* action,
51 									const text_run_array* inRuns = NULL);
52 			void				InsertHyperText(const char* inText,
53 									int32 inLength, HyperTextAction* action,
54 									const text_run_array* inRuns = NULL);
55 private:
56 			HyperTextAction*	_ActionAt(const BPoint& where) const;
57 
58 			struct ActionInfo;
59 			class ActionInfoList;
60 
61 			ActionInfoList*		fActionInfos;
62 };
63 
64 
65 #endif	// HYPER_TEXT_VIEW_H
66