source: Readingame/HyperTextView.h

main
Last change on this file was 3d333fd, checked in by PulkoMandy <pulkomandy@…>, 10 months ago

Continue adding things

  • Fix main window layout (text view sizing)
  • Implement conditional messages (partially)
  • Implements some more opcodes around flags
  • Property mode set to 100644
File size: 2.2 KB
Line 
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
15class HyperTextView;
16
17
18class HyperTextAction {
19public:
20 HyperTextAction(int32 event);
21 virtual ~HyperTextAction();
22
23 virtual void MouseOver(HyperTextView* view, BPoint where,
24 int32 startOffset, int32 endOffset,
25 BMessage* message);
26 virtual void MouseAway(HyperTextView* view, BPoint where,
27 int32 startOffset, int32 endOffset,
28 BMessage* message);
29 virtual void Clicked(HyperTextView* view, BPoint where,
30 BMessage* message);
31private:
32 int32 fMessage;
33};
34
35
36class HyperTextView : public BTextView {
37public:
38 HyperTextView(const char* name,
39 uint32 flags = B_WILL_DRAW
40 | B_PULSE_NEEDED);
41 HyperTextView(BRect frame, const char* name,
42 BRect textRect, uint32 resizeMask,
43 uint32 flags = B_WILL_DRAW
44 | B_PULSE_NEEDED);
45 virtual ~HyperTextView();
46
47 virtual void MouseDown(BPoint where);
48 virtual void MouseUp(BPoint where);
49 virtual void MouseMoved(BPoint where, uint32 transit,
50 const BMessage* dragMessage);
51
52 virtual bool HasHeightForWidth() override;
53 virtual void GetHeightForWidth(float width, float* min,
54 float* max, float* preferred) override;
55
56 void SetText(const char* text);
57
58 void AddHyperTextAction(int32 startOffset,
59 int32 endOffset, HyperTextAction* action);
60
61 void InsertHyperText(const char* inText,
62 HyperTextAction* action,
63 const text_run_array* inRuns = NULL);
64 void InsertHyperText(const char* inText,
65 int32 inLength, HyperTextAction* action,
66 const text_run_array* inRuns = NULL);
67private:
68 struct ActionInfo;
69 class ActionInfoList;
70
71 HyperTextAction* _ActionAt(const BPoint& where) const;
72 const ActionInfo* _ActionInfoAt(const BPoint& where) const;
73
74private:
75 ActionInfoList* fActionInfos;
76 const ActionInfo* fLastActionInfo;
77};
78
79
80#endif // HYPER_TEXT_VIEW_H
Note: See TracBrowser for help on using the repository browser.