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(BRect frame, const char* name, 33 BRect textRect, uint32 resizeMask, 34 uint32 flags = B_WILL_DRAW 35 | B_PULSE_NEEDED); 36 virtual ~HyperTextView(); 37 38 virtual void MouseDown(BPoint where); 39 virtual void MouseUp(BPoint where); 40 virtual void MouseMoved(BPoint where, uint32 transit, 41 const BMessage* dragMessage); 42 43 void AddHyperTextAction(int32 startOffset, 44 int32 endOffset, HyperTextAction* action); 45 46 void InsertHyperText(const char* inText, 47 HyperTextAction* action, 48 const text_run_array* inRuns = NULL); 49 void InsertHyperText(const char* inText, 50 int32 inLength, HyperTextAction* action, 51 const text_run_array* inRuns = NULL); 52 private: 53 HyperTextAction* _ActionAt(const BPoint& where) const; 54 55 struct ActionInfo; 56 class ActionInfoList; 57 58 ActionInfoList* fActionInfos; 59 }; 60 61 62 #endif // HYPER_TEXT_VIEW_H 63