1
|
class RichTextView : public Ctrl {
|
2
|
public:
|
3
|
virtual void Paint(Draw& w);
|
4
|
virtual bool Key(dword key, int count);
|
5
|
virtual void Layout();
|
6
|
virtual Value GetData() const;
|
7
|
virtual void SetData(const Value& v);
|
8
|
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
|
9
|
virtual Image CursorImage(Point p, dword keyflags);
|
10
|
virtual void LeftDown(Point p, dword keyflags);
|
11
|
virtual void MouseMove(Point p, dword keyflags);
|
12
|
virtual void LeftRepeat(Point p, dword keyflags);
|
13
|
virtual void LeftDouble(Point p, dword keyflags);
|
14
|
virtual void LeftTriple(Point p, dword keyflags);
|
15
|
virtual void RightDown(Point p, dword keyflags);
|
16
|
|
17
|
private:
|
18
|
Rect margin;
|
19
|
Color background;
|
20
|
Zoom zoom;
|
21
|
int cx;
|
22
|
ScrollBar sb;
|
23
|
Scroller scroller;
|
24
|
RichText text;
|
25
|
bool sizetracking;
|
26
|
bool vcenter;
|
27
|
bool hldec;
|
28
|
int highlight;
|
29
|
int sell, selh;
|
30
|
int cursor, anchor;
|
31
|
bool lazy;
|
32
|
bool shrink_oversized_objects;
|
33
|
|
34
|
void EndSizeTracking();
|
35
|
void SetSb();
|
36
|
void Scroll();
|
37
|
int GetPageCx(bool reduced = false) const;
|
38
|
int GetPointPos(Point p) const;
|
39
|
String GetLink(int pos, Point p) const;
|
40
|
void RefreshSel();
|
41
|
void RefreshRange(int a, int b);
|
42
|
|
43
|
protected:
|
44
|
enum {
|
45
|
TIMEID_ENDSIZETRACKING = Ctrl::TIMEID_COUNT,
|
46
|
TIMEID_COUNT
|
47
|
};
|
48
|
|
49
|
public:
|
50
|
Callback1<const String&> WhenLink;
|
51
|
Callback1<int> WhenMouseMove;
|
52
|
|
53
|
void Clear();
|
54
|
void Pick(pick_ RichText& t);
|
55
|
void Pick(pick_ RichText& txt, Zoom z);
|
56
|
void SetQTF(const char *qtf, Zoom z = Zoom(1, 1));
|
57
|
const RichText& Get() const { return text; }
|
58
|
String GetQTF(byte cs = CHARSET_UTF8) const { return AsQTF(text, cs); }
|
59
|
|
60
|
int GetWidth() const { return text.GetWidth(); }
|
61
|
int GetHeight(int cx) const { return text.GetHeight(Zoom(1, 1), cx); }
|
62
|
|
63
|
int GetSb() const { return sb; }
|
64
|
void SetSb(int i) { sb = i; }
|
65
|
int GetSbTotal() const { return sb.GetTotal(); }
|
66
|
Zoom GetZoom() const;
|
67
|
Rect GetPage() const;
|
68
|
|
69
|
void GotoLabel(const String& lbl, bool highlight = false);
|
70
|
void ClearHighlight() { highlight = Null; Refresh(); }
|
71
|
|
72
|
int GetLength() const { return text.GetLength(); }
|
73
|
|
74
|
bool IsSelection() const { return anchor != cursor; }
|
75
|
void Copy();
|
76
|
|
77
|
void ScrollUp() { sb.PrevLine(); }
|
78
|
void ScrollDown() { sb.NextLine(); }
|
79
|
void ScrollPageUp() { sb.PrevPage(); }
|
80
|
void ScrollPageDown() { sb.NextPage(); }
|
81
|
void ScrollEnd() { sb.End(); }
|
82
|
void ScrollBegin() { sb.Begin(); }
|
83
|
|
84
|
RichTextView& PageWidth(int cx);
|
85
|
RichTextView& SetZoom(Zoom z);
|
86
|
RichTextView& Background(Color _color);
|
87
|
RichTextView& VCenter(bool b = true);
|
88
|
RichTextView& NoVCenter() { return VCenter(false); }
|
89
|
RichTextView& Margins(const Rect& m);
|
90
|
RichTextView& HMargins(int a);
|
91
|
RichTextView& VMargins(int a);
|
92
|
RichTextView& Margins(int a);
|
93
|
RichTextView& NoSb(bool b = true) { sb.AutoHide(!b); sb.Show(!b); return *this; }
|
94
|
RichTextView& AutoHideSb(bool b = true) { sb.AutoHide(b); return *this; }
|
95
|
RichTextView& HyperlinkDecoration(bool b = true) { hldec = b; Refresh(); return *this; }
|
96
|
RichTextView& NoHyperlinkDecoration() { return HyperlinkDecoration(false); }
|
97
|
RichTextView& Lazy(bool b = true) { lazy = b; return *this; }
|
98
|
RichTextView& NoLazy() { return Lazy(false); }
|
99
|
RichTextView& ShrinkOversizedObjects(bool b = true) { shrink_oversized_objects = b; Refresh(); return *this; }
|
100
|
RichTextView& NoShrinkOversizedObjects() { return ShrinkOversizedObjects(false); }
|
101
|
|
102
|
void operator=(const char *qtf) { SetQTF(qtf); }
|
103
|
|
104
|
RichTextView& SetScrollBarStyle(const ScrollBar::Style& s) { sb.SetStyle(s); return *this; }
|
105
|
|
106
|
typedef RichTextView CLASSNAME;
|
107
|
|
108
|
RichTextView();
|
109
|
virtual ~RichTextView();
|
110
|
};
|
111
|
|
112
|
class RichTextCtrl : public RichTextView {
|
113
|
public:
|
114
|
virtual void SetData(const Value& v);
|
115
|
|
116
|
public:
|
117
|
void SetQTF(const char *qtf, Zoom z = GetRichTextStdScreenZoom()) { RichTextView::SetQTF(qtf, z); }
|
118
|
void operator=(const char *qtf) { SetQTF(qtf); }
|
119
|
RichTextCtrl();
|
120
|
};
|
121
|
|
122
|
int Prompt(Callback1<const String&> WhenLink,
|
123
|
const char *title, const Image& icon, const char *qtf, bool okcancel,
|
124
|
const char *button1, const char *button2 = NULL, const char *button3 = NULL,
|
125
|
int cx = 0);
|
126
|
int Prompt(const char *title, const Image& icon, const char *qtf, bool okcancel,
|
127
|
const char *button1, const char *button2 = NULL, const char *button3 = NULL,
|
128
|
int cx = 0);
|
129
|
int Prompt(const char *title, const Image& icon, const char *qtf,
|
130
|
const char *button1, const char *button2 = NULL, const char *button3 = NULL,
|
131
|
int cx = 0);
|
132
|
|
133
|
void PromptOK(const char *qtf);
|
134
|
int PromptOKCancel(const char *qtf);
|
135
|
int PromptYesNo(const char *qtf);
|
136
|
int PromptYesNoCancel(const char *qtf);
|
137
|
int PromptRetryCancel(const char *qtf);
|
138
|
int PromptAbortRetry(const char *qtf);
|
139
|
int PromptAbortRetryIgnore(const char *qtf);
|
140
|
|
141
|
void Exclamation(const char *qtf);
|
142
|
|
143
|
void ErrorOK(const char *qtf);
|
144
|
int ErrorOKCancel(const char *qtf);
|
145
|
int ErrorYesNo(const char *qtf);
|
146
|
int ErrorYesNoCancel(const char *qtf);
|
147
|
int ErrorRetryCancel(const char *qtf);
|
148
|
int ErrorAbortRetry(const char *qtf);
|
149
|
int ErrorAbortRetryIgnore(const char *qtf);
|
150
|
|
151
|
Image YesButtonImage();
|
152
|
Image NoButtonImage();
|
153
|
Image AbortButtonImage();
|
154
|
Image RetryButtonImage();
|
155
|
|
156
|
void YesButtonImage_Write(Image m);
|
157
|
void NoButtonImage_Write(Image m);
|
158
|
void AbortButtonImage_Write(Image m);
|
159
|
void RetryButtonImage_Write(Image m);
|
160
|
|
161
|
void ShowExc(const Exc& exc);
|
162
|
|
163
|
class HelpWindow : public TopWindow {
|
164
|
public:
|
165
|
virtual bool Key(dword key, int);
|
166
|
|
167
|
private:
|
168
|
RichTextView view;
|
169
|
TreeCtrl tree;
|
170
|
Splitter tree_view;
|
171
|
ToolBar toolbar;
|
172
|
Zoom zoom;
|
173
|
|
174
|
struct Pos : Moveable<Pos> {
|
175
|
String link;
|
176
|
int scy;
|
177
|
};
|
178
|
|
179
|
Vector<Pos> back;
|
180
|
Vector<Pos> forward;
|
181
|
Index<String> tree_ndx;
|
182
|
String topic;
|
183
|
String label;
|
184
|
String current_link;
|
185
|
|
186
|
bool GoTo0(const String& link);
|
187
|
void Back();
|
188
|
void Forward();
|
189
|
void FontSize();
|
190
|
void Tools(Bar& bar);
|
191
|
void TreeCursor();
|
192
|
void SetZoom();
|
193
|
void Print();
|
194
|
Pos GetPos();
|
195
|
Vector<int> ScPositions(const Vector<int>& p);
|
196
|
void Ids(int pid, Vector<int>& r);
|
197
|
Vector<int> Ids();
|
198
|
bool PrevNext(int d, bool allowempty);
|
199
|
|
200
|
public:
|
201
|
virtual Topic AcquireTopic(const String& topic);
|
202
|
virtual void FinishText(RichText& text);
|
203
|
virtual void BarEx(Bar& bar);
|
204
|
|
205
|
void GoTo(const String& link);
|
206
|
|
207
|
void SetBar();
|
208
|
void Serialize(Stream& s);
|
209
|
|
210
|
void ClearTree();
|
211
|
int AddTree(int parent, const Image& img, const String& topic, const String& title);
|
212
|
void SortTree(int id, int (*cmp)(const Value& k1, const Value& v1,
|
213
|
const Value& k2, const Value& v2));
|
214
|
void SortTree(int id, int (*cmp)(const Value& v1, const Value& v2));
|
215
|
void SortTree(int id);
|
216
|
void FinishTree();
|
217
|
void OpenDeep(int id = 0);
|
218
|
void CurrentOrHome();
|
219
|
void ClearCurrentLink() { current_link.Clear(); }
|
220
|
bool Up(const Vector<int>& poslist);
|
221
|
bool Down(const Vector<int>& poslist);
|
222
|
bool Next(bool allowempty = false);
|
223
|
bool Prev(bool allowempty = false);
|
224
|
|
225
|
String GetCurrent() const { return topic; }
|
226
|
String GetCurrentLabel() const { return label; }
|
227
|
String GetCurrentLink() const { return current_link; }
|
228
|
|
229
|
typedef HelpWindow CLASSNAME;
|
230
|
|
231
|
HelpWindow();
|
232
|
};
|
233
|
|
234
|
#ifndef PLATFORM_PDA
|
235
|
|
236
|
void Print(Draw& w, const RichText& text, const Rect& page, const Vector<int>& pagelist);
|
237
|
void Print(Draw& w, const RichText& text, const Rect& page);
|
238
|
bool Print(const RichText& text, const Rect& page, int currentpage, const char *name = NULL);
|
239
|
|
240
|
#endif
|