]>
Commit | Line | Data |
---|---|---|
5d7836c4 | 1 | ///////////////////////////////////////////////////////////////////////////// |
7fe8059f | 2 | // Name: wx/richtext/richtextctrl.h |
5d7836c4 JS |
3 | // Purpose: A rich edit control |
4 | // Author: Julian Smart | |
7fe8059f | 5 | // Modified by: |
5d7836c4 | 6 | // Created: 2005-09-30 |
7fe8059f | 7 | // RCS-ID: $Id$ |
5d7836c4 JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_RICHTEXTCTRL_H_ | |
13 | #define _WX_RICHTEXTCTRL_H_ | |
14 | ||
b01ca8b6 | 15 | #include "wx/richtext/richtextbuffer.h" |
5d7836c4 JS |
16 | |
17 | #if wxUSE_RICHTEXT | |
18 | ||
19 | #include "wx/scrolwin.h" | |
20 | #include "wx/caret.h" | |
21 | ||
b01ca8b6 | 22 | #include "wx/textctrl.h" |
b01ca8b6 | 23 | |
3e3a754f JS |
24 | #if !defined(__WXGTK__) && !defined(__WXMAC__) |
25 | #define wxRICHTEXT_BUFFERED_PAINTING 1 | |
26 | #else | |
27 | #define wxRICHTEXT_BUFFERED_PAINTING 0 | |
28 | #endif | |
29 | ||
b5dbe15d | 30 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition; |
ab14c7aa | 31 | |
5d7836c4 JS |
32 | /*! |
33 | * Styles and flags | |
34 | */ | |
35 | ||
36 | /* Styles | |
37 | */ | |
38 | ||
39 | #define wxRE_READONLY 0x0010 | |
40 | #define wxRE_MULTILINE 0x0020 | |
e9f10004 JS |
41 | #define wxRE_CENTRE_CARET 0x8000 |
42 | #define wxRE_CENTER_CARET wxRE_CENTRE_CARET | |
5d7836c4 JS |
43 | |
44 | /* Flags | |
45 | */ | |
46 | ||
47 | #define wxRICHTEXT_SHIFT_DOWN 0x01 | |
48 | #define wxRICHTEXT_CTRL_DOWN 0x02 | |
49 | #define wxRICHTEXT_ALT_DOWN 0x04 | |
50 | ||
51 | /* Defaults | |
52 | */ | |
53 | ||
54 | #define wxRICHTEXT_DEFAULT_OVERALL_SIZE wxSize(-1, -1) | |
55 | #define wxRICHTEXT_DEFAULT_IMAGE_SIZE wxSize(80, 80) | |
56 | #define wxRICHTEXT_DEFAULT_SPACING 3 | |
57 | #define wxRICHTEXT_DEFAULT_MARGIN 3 | |
58 | #define wxRICHTEXT_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175) | |
59 | #define wxRICHTEXT_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140) | |
60 | #define wxRICHTEXT_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) | |
61 | #define wxRICHTEXT_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200) | |
62 | #define wxRICHTEXT_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80) | |
63 | #define wxRICHTEXT_DEFAULT_CARET_WIDTH 2 | |
4d551ad5 JS |
64 | // Minimum buffer size before delayed layout kicks in |
65 | #define wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD 20000 | |
66 | // Milliseconds before layout occurs after resize | |
67 | #define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50 | |
5d7836c4 JS |
68 | |
69 | /*! | |
70 | * Forward declarations | |
71 | */ | |
72 | ||
73 | /*! | |
74 | * wxRichTextItem class declaration | |
75 | */ | |
76 | ||
77 | // Drawing styles/states | |
78 | #define wxRICHTEXT_SELECTED 0x01 | |
79 | #define wxRICHTEXT_TAGGED 0x02 | |
80 | // The control is focussed | |
81 | #define wxRICHTEXT_FOCUSSED 0x04 | |
82 | // The item itself has the focus | |
83 | #define wxRICHTEXT_IS_FOCUS 0x08 | |
84 | ||
85 | /*! | |
86 | * wxRichTextCtrl class declaration | |
87 | */ | |
88 | ||
24777478 JS |
89 | class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxControl, |
90 | public wxTextCtrlIface, | |
343ae70d | 91 | public wxScrollHelper |
7fe8059f | 92 | { |
5d7836c4 JS |
93 | DECLARE_CLASS( wxRichTextCtrl ) |
94 | DECLARE_EVENT_TABLE() | |
95 | ||
96 | public: | |
97 | // Constructors | |
98 | ||
99 | wxRichTextCtrl( ); | |
27e20452 | 100 | wxRichTextCtrl( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, |
4e8d9558 JS |
101 | long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); |
102 | ||
d3c7fc99 | 103 | virtual ~wxRichTextCtrl( ); |
5d7836c4 JS |
104 | |
105 | // Operations | |
106 | ||
107 | /// Creation | |
27e20452 | 108 | bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, |
4e8d9558 | 109 | long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr ); |
5d7836c4 JS |
110 | |
111 | /// Member initialisation | |
112 | void Init(); | |
113 | ||
114 | ///// wxTextCtrl compatibility | |
115 | ||
116 | // Accessors | |
117 | ||
5d7836c4 JS |
118 | virtual wxString GetRange(long from, long to) const; |
119 | ||
120 | virtual int GetLineLength(long lineNo) const ; | |
121 | virtual wxString GetLineText(long lineNo) const ; | |
122 | virtual int GetNumberOfLines() const ; | |
123 | ||
124 | virtual bool IsModified() const ; | |
125 | virtual bool IsEditable() const ; | |
126 | ||
127 | // more readable flag testing methods | |
128 | bool IsSingleLine() const { return !HasFlag(wxRE_MULTILINE); } | |
129 | bool IsMultiLine() const { return !IsSingleLine(); } | |
130 | ||
131 | // If the return values from and to are the same, there is no selection. | |
132 | virtual void GetSelection(long* from, long* to) const; | |
133 | ||
134 | virtual wxString GetStringSelection() const; | |
135 | ||
136 | /// Get filename | |
137 | wxString GetFilename() const { return m_filename; } | |
138 | ||
139 | /// Set filename | |
140 | void SetFilename(const wxString& filename) { m_filename = filename; } | |
141 | ||
4d551ad5 JS |
142 | /// Set the threshold in character positions for doing layout optimization during sizing |
143 | void SetDelayedLayoutThreshold(long threshold) { m_delayedLayoutThreshold = threshold; } | |
144 | ||
145 | /// Get the threshold in character positions for doing layout optimization during sizing | |
146 | long GetDelayedLayoutThreshold() const { return m_delayedLayoutThreshold; } | |
147 | ||
c2a4fabb JS |
148 | /// Set text cursor |
149 | void SetTextCursor(const wxCursor& cursor ) { m_textCursor = cursor; } | |
150 | ||
151 | /// Get text cursor | |
152 | wxCursor GetTextCursor() const { return m_textCursor; } | |
153 | ||
154 | /// Set URL cursor | |
155 | void SetURLCursor(const wxCursor& cursor ) { m_urlCursor = cursor; } | |
156 | ||
157 | /// Get URL cursor | |
158 | wxCursor GetURLCursor() const { return m_urlCursor; } | |
159 | ||
2f0baf97 JS |
160 | /// Are we showing the caret position at the start of a line |
161 | /// instead of at the end of the previous one? | |
162 | bool GetCaretAtLineStart() const { return m_caretAtLineStart; } | |
163 | void SetCaretAtLineStart(bool atStart) { m_caretAtLineStart = atStart; } | |
164 | ||
165 | /// Are we dragging a selection? | |
166 | bool GetDragging() const { return m_dragging; } | |
167 | void SetDragging(bool dragging) { m_dragging = dragging; } | |
168 | ||
169 | /// Get/set drag start position | |
170 | const wxPoint& GetDragStart() const { return m_dragStart; } | |
171 | void SetDragStart(const wxPoint& pt) { m_dragStart = pt; } | |
172 | ||
c631741b | 173 | #if wxRICHTEXT_BUFFERED_PAINTING |
2f0baf97 JS |
174 | /// Get the buffer bitmap |
175 | const wxBitmap& GetBufferBitmap() const { return m_bufferBitmap; } | |
176 | wxBitmap& GetBufferBitmap() { return m_bufferBitmap; } | |
c631741b | 177 | #endif |
2f0baf97 JS |
178 | |
179 | /// Get/set context menu | |
180 | wxMenu* GetContextMenu() const { return m_contextMenu; } | |
8e43fc77 | 181 | void SetContextMenu(wxMenu* menu); |
2f0baf97 JS |
182 | |
183 | /// Anchor so we know how to extend the selection | |
184 | /// It's a caret position since it's between two characters. | |
185 | long GetSelectionAnchor() const { return m_selectionAnchor; } | |
186 | void SetSelectionAnchor(long anchor) { m_selectionAnchor = anchor; } | |
187 | ||
cdaed652 VZ |
188 | /// The wxRichTextObject object under mouse if any |
189 | wxRichTextObject* GetCurrentObject() const { return m_currentObject; } | |
190 | void SetCurrentObject(wxRichTextObject* obj) { m_currentObject = obj; } | |
191 | ||
5d7836c4 JS |
192 | // Operations |
193 | ||
194 | // editing | |
195 | virtual void Clear(); | |
196 | virtual void Replace(long from, long to, const wxString& value); | |
197 | virtual void Remove(long from, long to); | |
198 | ||
199 | // load/save the controls contents from/to the file | |
3306aec1 | 200 | virtual bool DoLoadFile(const wxString& file, int fileType); |
d75a69e8 FM |
201 | virtual bool DoSaveFile(const wxString& file = wxEmptyString, |
202 | int fileType = wxRICHTEXT_TYPE_ANY); | |
5d7836c4 | 203 | |
d2d0adc7 JS |
204 | /// Set the handler flags, controlling loading and saving |
205 | void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); } | |
206 | ||
207 | /// Get the handler flags, controlling loading and saving | |
208 | int GetHandlerFlags() const { return GetBuffer().GetHandlerFlags(); } | |
209 | ||
5d7836c4 JS |
210 | // sets/clears the dirty flag |
211 | virtual void MarkDirty(); | |
212 | virtual void DiscardEdits(); | |
213 | ||
214 | // set the max number of characters which may be entered in a single line | |
215 | // text control | |
216 | virtual void SetMaxLength(unsigned long WXUNUSED(len)) { } | |
217 | ||
218 | // writing text inserts it at the current position, appending always | |
219 | // inserts it at the end | |
220 | virtual void WriteText(const wxString& text); | |
221 | virtual void AppendText(const wxString& text); | |
222 | ||
223 | // text control under some platforms supports the text styles: these | |
224 | // methods allow to apply the given text style to the given selection or to | |
225 | // set/get the style which will be used for all appended text | |
27e20452 | 226 | virtual bool SetStyle(long start, long end, const wxTextAttr& style); |
24777478 | 227 | virtual bool SetStyle(long start, long end, const wxRichTextAttr& style); |
44cc96a8 | 228 | virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style); |
24777478 | 229 | virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style); |
3966a9f4 | 230 | virtual bool GetStyle(long position, wxTextAttr& style); |
24777478 | 231 | virtual bool GetStyle(long position, wxRichTextAttr& style); |
fe5aa22c | 232 | |
cdaed652 | 233 | // Set an image style |
24777478 | 234 | void SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr); |
cdaed652 | 235 | |
a7ed48a5 | 236 | // get the common set of styles for the range |
44cc96a8 | 237 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style); |
24777478 | 238 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style); |
3e3a754f JS |
239 | // extended style setting operation with flags including: |
240 | // wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY | |
241 | // see richtextbuffer.h for more details. | |
24777478 | 242 | virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); |
3e3a754f | 243 | |
fe5aa22c | 244 | /// Get the content (uncombined) attributes for this position. |
24777478 | 245 | virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style); |
fe5aa22c | 246 | |
27e20452 | 247 | virtual bool SetDefaultStyle(const wxTextAttr& style); |
24777478 | 248 | virtual bool SetDefaultStyle(const wxRichTextAttr& style); |
5d7836c4 | 249 | |
24777478 | 250 | virtual const wxRichTextAttr& GetDefaultStyleEx() const; |
44cc96a8 | 251 | |
24777478 | 252 | //virtual const wxTextAttr& GetDefaultStyle() const; |
5d7836c4 | 253 | |
38f833b1 JS |
254 | /// Set list style |
255 | virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
256 | virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
257 | ||
258 | /// Clear list for given range | |
259 | virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
260 | ||
261 | /// Number/renumber any list elements in the given range | |
262 | /// def/defName can be NULL/empty to indicate that the existing list style should be used. | |
dadd4f55 | 263 | virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); |
38f833b1 JS |
264 | virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); |
265 | ||
266 | /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1 | |
267 | /// def/defName can be NULL/empty to indicate that the existing list style should be used. | |
dadd4f55 | 268 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); |
38f833b1 JS |
269 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); |
270 | ||
12cc29c5 JS |
271 | /// Deletes the content in the given range |
272 | virtual bool Delete(const wxRichTextRange& range); | |
273 | ||
5d7836c4 JS |
274 | // translate between the position (which is just an index in the text ctrl |
275 | // considering all its contents as a single strings) and (x, y) coordinates | |
276 | // which represent column and line. | |
277 | virtual long XYToPosition(long x, long y) const; | |
278 | virtual bool PositionToXY(long pos, long *x, long *y) const; | |
279 | ||
280 | virtual void ShowPosition(long pos); | |
281 | ||
282 | // find the character at position given in pixels | |
283 | // | |
284 | // NB: pt is in device coords (not adjusted for the client area origin nor | |
285 | // scrolling) | |
286 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; | |
287 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, | |
288 | wxTextCoord *col, | |
289 | wxTextCoord *row) const; | |
290 | ||
291 | // Clipboard operations | |
292 | virtual void Copy(); | |
293 | virtual void Cut(); | |
294 | virtual void Paste(); | |
295 | virtual void DeleteSelection(); | |
296 | ||
297 | virtual bool CanCopy() const; | |
298 | virtual bool CanCut() const; | |
299 | virtual bool CanPaste() const; | |
300 | virtual bool CanDeleteSelection() const; | |
301 | ||
302 | // Undo/redo | |
303 | virtual void Undo(); | |
304 | virtual void Redo(); | |
305 | ||
306 | virtual bool CanUndo() const; | |
307 | virtual bool CanRedo() const; | |
308 | ||
309 | // Insertion point | |
310 | virtual void SetInsertionPoint(long pos); | |
311 | virtual void SetInsertionPointEnd(); | |
312 | virtual long GetInsertionPoint() const; | |
313 | virtual wxTextPos GetLastPosition() const; | |
314 | ||
315 | virtual void SetSelection(long from, long to); | |
316 | virtual void SelectAll(); | |
317 | virtual void SetEditable(bool editable); | |
318 | ||
5d7836c4 JS |
319 | virtual bool HasSelection() const; |
320 | ||
321 | ///// Functionality specific to wxRichTextCtrl | |
322 | ||
323 | /// Write an image at the current insertion point. Supply optional type to use | |
324 | /// for internal and file storage of the raw data. | |
24777478 JS |
325 | virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, |
326 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
5d7836c4 JS |
327 | |
328 | /// Write a bitmap at the current insertion point. Supply optional type to use | |
329 | /// for internal and file storage of the raw data. | |
24777478 JS |
330 | virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, |
331 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
5d7836c4 JS |
332 | |
333 | /// Load an image from file and write at the current insertion point. | |
24777478 JS |
334 | virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType, |
335 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
5d7836c4 JS |
336 | |
337 | /// Write an image block at the current insertion point. | |
24777478 JS |
338 | virtual bool WriteImage(const wxRichTextImageBlock& imageBlock, |
339 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
5d7836c4 JS |
340 | |
341 | /// Insert a newline (actually paragraph) at the current insertion point. | |
342 | virtual bool Newline(); | |
343 | ||
ff76711f JS |
344 | /// Insert a line break at the current insertion point. |
345 | virtual bool LineBreak(); | |
346 | ||
5d7836c4 | 347 | /// Set basic (overall) style |
24777478 | 348 | virtual void SetBasicStyle(const wxRichTextAttr& style) { GetBuffer().SetBasicStyle(style); } |
5d7836c4 JS |
349 | |
350 | /// Get basic (overall) style | |
24777478 | 351 | virtual const wxRichTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); } |
5d7836c4 | 352 | |
24777478 | 353 | virtual bool BeginStyle(const wxRichTextAttr& style) { return GetBuffer().BeginStyle(style); } |
5d7836c4 JS |
354 | |
355 | /// End the style | |
356 | virtual bool EndStyle() { return GetBuffer().EndStyle(); } | |
357 | ||
358 | /// End all styles | |
359 | virtual bool EndAllStyles() { return GetBuffer().EndAllStyles(); } | |
360 | ||
361 | /// Begin using bold | |
362 | bool BeginBold() { return GetBuffer().BeginBold(); } | |
363 | ||
364 | /// End using bold | |
365 | bool EndBold() { return GetBuffer().EndBold(); } | |
366 | ||
367 | /// Begin using italic | |
368 | bool BeginItalic() { return GetBuffer().BeginItalic(); } | |
369 | ||
370 | /// End using italic | |
371 | bool EndItalic() { return GetBuffer().EndItalic(); } | |
372 | ||
373 | /// Begin using underline | |
374 | bool BeginUnderline() { return GetBuffer().BeginUnderline(); } | |
375 | ||
376 | /// End using underline | |
377 | bool EndUnderline() { return GetBuffer().EndUnderline(); } | |
378 | ||
379 | /// Begin using point size | |
380 | bool BeginFontSize(int pointSize) { return GetBuffer().BeginFontSize(pointSize); } | |
381 | ||
382 | /// End using point size | |
383 | bool EndFontSize() { return GetBuffer().EndFontSize(); } | |
384 | ||
385 | /// Begin using this font | |
386 | bool BeginFont(const wxFont& font) { return GetBuffer().BeginFont(font); } | |
387 | ||
388 | /// End using a font | |
389 | bool EndFont() { return GetBuffer().EndFont(); } | |
390 | ||
391 | /// Begin using this colour | |
392 | bool BeginTextColour(const wxColour& colour) { return GetBuffer().BeginTextColour(colour); } | |
393 | ||
394 | /// End using a colour | |
395 | bool EndTextColour() { return GetBuffer().EndTextColour(); } | |
396 | ||
397 | /// Begin using alignment | |
398 | bool BeginAlignment(wxTextAttrAlignment alignment) { return GetBuffer().BeginAlignment(alignment); } | |
399 | ||
400 | /// End alignment | |
401 | bool EndAlignment() { return GetBuffer().EndAlignment(); } | |
402 | ||
403 | /// Begin left indent | |
404 | bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0) { return GetBuffer().BeginLeftIndent(leftIndent, leftSubIndent); } | |
405 | ||
406 | /// End left indent | |
407 | bool EndLeftIndent() { return GetBuffer().EndLeftIndent(); } | |
408 | ||
409 | /// Begin right indent | |
410 | bool BeginRightIndent(int rightIndent) { return GetBuffer().BeginRightIndent(rightIndent); } | |
411 | ||
412 | /// End right indent | |
413 | bool EndRightIndent() { return GetBuffer().EndRightIndent(); } | |
414 | ||
415 | /// Begin paragraph spacing | |
416 | bool BeginParagraphSpacing(int before, int after) { return GetBuffer().BeginParagraphSpacing(before, after); } | |
417 | ||
418 | /// End paragraph spacing | |
419 | bool EndParagraphSpacing() { return GetBuffer().EndParagraphSpacing(); } | |
420 | ||
421 | /// Begin line spacing | |
422 | bool BeginLineSpacing(int lineSpacing) { return GetBuffer().BeginLineSpacing(lineSpacing); } | |
423 | ||
424 | /// End line spacing | |
425 | bool EndLineSpacing() { return GetBuffer().EndLineSpacing(); } | |
426 | ||
427 | /// Begin numbered bullet | |
428 | bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD) | |
429 | { return GetBuffer().BeginNumberedBullet(bulletNumber, leftIndent, leftSubIndent, bulletStyle); } | |
430 | ||
431 | /// End numbered bullet | |
432 | bool EndNumberedBullet() { return GetBuffer().EndNumberedBullet(); } | |
433 | ||
434 | /// Begin symbol bullet | |
d2d0adc7 | 435 | bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL) |
5d7836c4 JS |
436 | { return GetBuffer().BeginSymbolBullet(symbol, leftIndent, leftSubIndent, bulletStyle); } |
437 | ||
438 | /// End symbol bullet | |
439 | bool EndSymbolBullet() { return GetBuffer().EndSymbolBullet(); } | |
440 | ||
f089713f JS |
441 | /// Begin standard bullet |
442 | bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD) | |
443 | { return GetBuffer().BeginStandardBullet(bulletName, leftIndent, leftSubIndent, bulletStyle); } | |
444 | ||
445 | /// End standard bullet | |
446 | bool EndStandardBullet() { return GetBuffer().EndStandardBullet(); } | |
447 | ||
5d7836c4 JS |
448 | /// Begin named character style |
449 | bool BeginCharacterStyle(const wxString& characterStyle) { return GetBuffer().BeginCharacterStyle(characterStyle); } | |
450 | ||
451 | /// End named character style | |
452 | bool EndCharacterStyle() { return GetBuffer().EndCharacterStyle(); } | |
453 | ||
454 | /// Begin named paragraph style | |
455 | bool BeginParagraphStyle(const wxString& paragraphStyle) { return GetBuffer().BeginParagraphStyle(paragraphStyle); } | |
456 | ||
457 | /// End named character style | |
458 | bool EndParagraphStyle() { return GetBuffer().EndParagraphStyle(); } | |
459 | ||
f089713f JS |
460 | /// Begin named list style |
461 | bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1) { return GetBuffer().BeginListStyle(listStyle, level, number); } | |
462 | ||
463 | /// End named character style | |
464 | bool EndListStyle() { return GetBuffer().EndListStyle(); } | |
465 | ||
d2d0adc7 JS |
466 | /// Begin URL |
467 | bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString) { return GetBuffer().BeginURL(url, characterStyle); } | |
468 | ||
469 | /// End URL | |
470 | bool EndURL() { return GetBuffer().EndURL(); } | |
471 | ||
5d7836c4 JS |
472 | /// Sets the default style to the style under the cursor |
473 | bool SetDefaultStyleToCursorStyle(); | |
474 | ||
475 | /// Clear the selection | |
476 | virtual void SelectNone(); | |
477 | ||
0ca07313 JS |
478 | /// Select the word at the given character position |
479 | virtual bool SelectWord(long position); | |
480 | ||
5d7836c4 | 481 | /// Get/set the selection range in character positions. -1, -1 means no selection. |
96c9f0f6 JS |
482 | /// The range is in API convention, i.e. a single character selection is denoted |
483 | /// by (n, n+1) | |
484 | wxRichTextRange GetSelectionRange() const; | |
485 | void SetSelectionRange(const wxRichTextRange& range); | |
486 | ||
487 | /// Get/set the selection range in character positions. -1, -1 means no selection. | |
488 | /// The range is in internal format, i.e. a single character selection is denoted | |
489 | /// by (n, n) | |
490 | const wxRichTextRange& GetInternalSelectionRange() const { return m_selectionRange; } | |
491 | void SetInternalSelectionRange(const wxRichTextRange& range) { m_selectionRange = range; } | |
5d7836c4 JS |
492 | |
493 | /// Add a new paragraph of text to the end of the buffer | |
494 | virtual wxRichTextRange AddParagraph(const wxString& text); | |
495 | ||
496 | /// Add an image | |
497 | virtual wxRichTextRange AddImage(const wxImage& image); | |
498 | ||
499 | /// Layout the buffer: which we must do before certain operations, such as | |
500 | /// setting the caret position. | |
2f36e8dc | 501 | virtual bool LayoutContent(bool onlyVisibleRect = false); |
5d7836c4 JS |
502 | |
503 | /// Move the caret to the given character position | |
504 | virtual bool MoveCaret(long pos, bool showAtLineStart = false); | |
505 | ||
506 | /// Move right | |
507 | virtual bool MoveRight(int noPositions = 1, int flags = 0); | |
508 | ||
509 | /// Move left | |
510 | virtual bool MoveLeft(int noPositions = 1, int flags = 0); | |
511 | ||
512 | /// Move up | |
513 | virtual bool MoveUp(int noLines = 1, int flags = 0); | |
514 | ||
515 | /// Move up | |
516 | virtual bool MoveDown(int noLines = 1, int flags = 0); | |
517 | ||
518 | /// Move to the end of the line | |
519 | virtual bool MoveToLineEnd(int flags = 0); | |
520 | ||
521 | /// Move to the start of the line | |
522 | virtual bool MoveToLineStart(int flags = 0); | |
523 | ||
524 | /// Move to the end of the paragraph | |
525 | virtual bool MoveToParagraphEnd(int flags = 0); | |
526 | ||
527 | /// Move to the start of the paragraph | |
528 | virtual bool MoveToParagraphStart(int flags = 0); | |
529 | ||
530 | /// Move to the start of the buffer | |
531 | virtual bool MoveHome(int flags = 0); | |
532 | ||
533 | /// Move to the end of the buffer | |
534 | virtual bool MoveEnd(int flags = 0); | |
535 | ||
536 | /// Move n pages up | |
537 | virtual bool PageUp(int noPages = 1, int flags = 0); | |
538 | ||
539 | /// Move n pages down | |
540 | virtual bool PageDown(int noPages = 1, int flags = 0); | |
541 | ||
542 | /// Move n words left | |
543 | virtual bool WordLeft(int noPages = 1, int flags = 0); | |
544 | ||
545 | /// Move n words right | |
546 | virtual bool WordRight(int noPages = 1, int flags = 0); | |
547 | ||
548 | /// Returns the buffer associated with the control. | |
549 | wxRichTextBuffer& GetBuffer() { return m_buffer; } | |
550 | const wxRichTextBuffer& GetBuffer() const { return m_buffer; } | |
551 | ||
552 | /// Start batching undo history for commands. | |
553 | virtual bool BeginBatchUndo(const wxString& cmdName) { return m_buffer.BeginBatchUndo(cmdName); } | |
554 | ||
555 | /// End batching undo history for commands. | |
556 | virtual bool EndBatchUndo() { return m_buffer.EndBatchUndo(); } | |
557 | ||
558 | /// Are we batching undo history for commands? | |
559 | virtual bool BatchingUndo() const { return m_buffer.BatchingUndo(); } | |
560 | ||
561 | /// Start suppressing undo history for commands. | |
562 | virtual bool BeginSuppressUndo() { return m_buffer.BeginSuppressUndo(); } | |
563 | ||
564 | /// End suppressing undo history for commands. | |
565 | virtual bool EndSuppressUndo() { return m_buffer.EndSuppressUndo(); } | |
566 | ||
567 | /// Are we suppressing undo history for commands? | |
568 | virtual bool SuppressingUndo() const { return m_buffer.SuppressingUndo(); } | |
569 | ||
570 | /// Test if this whole range has character attributes of the specified kind. If any | |
571 | /// of the attributes are different within the range, the test fails. You | |
572 | /// can use this to implement, for example, bold button updating. style must have | |
573 | /// flags indicating which attributes are of interest. | |
24777478 | 574 | virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const |
5d7836c4 | 575 | { |
a7ed48a5 | 576 | return GetBuffer().HasCharacterAttributes(range.ToInternal(), style); |
5d7836c4 JS |
577 | } |
578 | ||
579 | /// Test if this whole range has paragraph attributes of the specified kind. If any | |
580 | /// of the attributes are different within the range, the test fails. You | |
581 | /// can use this to implement, for example, centering button updating. style must have | |
582 | /// flags indicating which attributes are of interest. | |
24777478 | 583 | virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const |
5d7836c4 | 584 | { |
a7ed48a5 | 585 | return GetBuffer().HasParagraphAttributes(range.ToInternal(), style); |
5d7836c4 JS |
586 | } |
587 | ||
588 | /// Is all of the selection bold? | |
3966a9f4 | 589 | virtual bool IsSelectionBold(); |
5d7836c4 JS |
590 | |
591 | /// Is all of the selection italics? | |
3966a9f4 | 592 | virtual bool IsSelectionItalics(); |
5d7836c4 JS |
593 | |
594 | /// Is all of the selection underlined? | |
3966a9f4 | 595 | virtual bool IsSelectionUnderlined(); |
5d7836c4 JS |
596 | |
597 | /// Is all of the selection aligned according to the specified flag? | |
3966a9f4 | 598 | virtual bool IsSelectionAligned(wxTextAttrAlignment alignment); |
5d7836c4 JS |
599 | |
600 | /// Apply bold to the selection | |
601 | virtual bool ApplyBoldToSelection(); | |
602 | ||
603 | /// Apply italic to the selection | |
604 | virtual bool ApplyItalicToSelection(); | |
605 | ||
606 | /// Apply underline to the selection | |
607 | virtual bool ApplyUnderlineToSelection(); | |
608 | ||
609 | /// Apply alignment to the selection | |
610 | virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment); | |
611 | ||
ab14c7aa | 612 | /// Apply a named style to the selection |
1807a1f3 | 613 | virtual bool ApplyStyle(wxRichTextStyleDefinition* def); |
ab14c7aa | 614 | |
38f833b1 | 615 | /// Set style sheet, if any |
5d7836c4 JS |
616 | void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); } |
617 | wxRichTextStyleSheet* GetStyleSheet() const { return GetBuffer().GetStyleSheet(); } | |
618 | ||
38f833b1 JS |
619 | /// Push style sheet to top of stack |
620 | bool PushStyleSheet(wxRichTextStyleSheet* styleSheet) { return GetBuffer().PushStyleSheet(styleSheet); } | |
621 | ||
622 | /// Pop style sheet from top of stack | |
623 | wxRichTextStyleSheet* PopStyleSheet() { return GetBuffer().PopStyleSheet(); } | |
624 | ||
fe5aa22c JS |
625 | /// Apply the style sheet to the buffer, for example if the styles have changed. |
626 | bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL); | |
627 | ||
5d7836c4 JS |
628 | // Command handlers |
629 | ||
c9f3a6a8 | 630 | void Command(wxCommandEvent& event); |
5d7836c4 | 631 | void OnDropFiles(wxDropFilesEvent& event); |
61f84e24 | 632 | void OnCaptureLost(wxMouseCaptureLostEvent& event); |
52170c5b | 633 | void OnSysColourChanged(wxSysColourChangedEvent& event); |
5d7836c4 JS |
634 | |
635 | void OnCut(wxCommandEvent& event); | |
636 | void OnCopy(wxCommandEvent& event); | |
637 | void OnPaste(wxCommandEvent& event); | |
638 | void OnUndo(wxCommandEvent& event); | |
639 | void OnRedo(wxCommandEvent& event); | |
640 | void OnSelectAll(wxCommandEvent& event); | |
cdaed652 | 641 | void OnImage(wxCommandEvent& event); |
5d7836c4 JS |
642 | void OnClear(wxCommandEvent& event); |
643 | ||
644 | void OnUpdateCut(wxUpdateUIEvent& event); | |
645 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
646 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
647 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
648 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
649 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
cdaed652 | 650 | void OnUpdateImage(wxUpdateUIEvent& event); |
5d7836c4 JS |
651 | void OnUpdateClear(wxUpdateUIEvent& event); |
652 | ||
653 | // Show a context menu for Rich Edit controls (the standard | |
654 | // EDIT control has one already) | |
655 | void OnContextMenu(wxContextMenuEvent& event); | |
7fe8059f | 656 | |
5d7836c4 JS |
657 | // Event handlers |
658 | ||
659 | /// Painting | |
660 | void OnPaint(wxPaintEvent& event); | |
661 | void OnEraseBackground(wxEraseEvent& event); | |
662 | ||
663 | /// Left-click | |
664 | void OnLeftClick(wxMouseEvent& event); | |
665 | ||
666 | /// Left-up | |
667 | void OnLeftUp(wxMouseEvent& event); | |
668 | ||
669 | /// Motion | |
670 | void OnMoveMouse(wxMouseEvent& event); | |
671 | ||
672 | /// Left-double-click | |
673 | void OnLeftDClick(wxMouseEvent& event); | |
674 | ||
675 | /// Middle-click | |
676 | void OnMiddleClick(wxMouseEvent& event); | |
677 | ||
678 | /// Right-click | |
679 | void OnRightClick(wxMouseEvent& event); | |
680 | ||
681 | /// Key press | |
682 | void OnChar(wxKeyEvent& event); | |
683 | ||
684 | /// Sizing | |
685 | void OnSize(wxSizeEvent& event); | |
686 | ||
687 | /// Setting/losing focus | |
688 | void OnSetFocus(wxFocusEvent& event); | |
689 | void OnKillFocus(wxFocusEvent& event); | |
690 | ||
4d551ad5 JS |
691 | /// Idle-time processing |
692 | void OnIdle(wxIdleEvent& event); | |
693 | ||
c59f6793 JS |
694 | /// Scrolling |
695 | void OnScroll(wxScrollWinEvent& event); | |
696 | ||
5d7836c4 JS |
697 | /// Set font, and also default attributes |
698 | virtual bool SetFont(const wxFont& font); | |
699 | ||
700 | /// Set up scrollbars, e.g. after a resize | |
169adfa9 | 701 | virtual void SetupScrollbars(bool atTop = false); |
5d7836c4 JS |
702 | |
703 | /// Keyboard navigation | |
0bab774b | 704 | virtual bool KeyboardNavigate(int keyCode, int flags); |
5d7836c4 JS |
705 | |
706 | /// Paint the background | |
707 | virtual void PaintBackground(wxDC& dc); | |
7fe8059f | 708 | |
35bdbae5 | 709 | /// Other user defined painting after everything else (i.e. all text) is painted |
6dc6bcd8 | 710 | virtual void PaintAboveContent(wxDC& WXUNUSED(dc)) {} |
35bdbae5 | 711 | |
3e3a754f | 712 | #if wxRICHTEXT_BUFFERED_PAINTING |
5d7836c4 JS |
713 | /// Recreate buffer bitmap if necessary |
714 | virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize); | |
3e3a754f | 715 | #endif |
5d7836c4 | 716 | |
5d7836c4 | 717 | /// Write text |
343ae70d | 718 | virtual void DoWriteText(const wxString& value, int flags = 0); |
5d7836c4 JS |
719 | |
720 | /// Should we inherit colours? | |
721 | virtual bool ShouldInheritColours() const { return false; } | |
722 | ||
723 | /// Position the caret | |
724 | virtual void PositionCaret(); | |
725 | ||
726 | /// Extend the selection, returning true if the selection was | |
727 | /// changed. Selections are in caret positions. | |
728 | virtual bool ExtendSelection(long oldPosition, long newPosition, int flags); | |
729 | ||
730 | /// Scroll into view. This takes a _caret_ position. | |
731 | virtual bool ScrollIntoView(long position, int keyCode); | |
732 | ||
7051fa41 JS |
733 | /// Refresh the area affected by a selection change |
734 | bool RefreshForSelectionChange(const wxRichTextRange& oldSelection, const wxRichTextRange& newSelection); | |
735 | ||
5d7836c4 JS |
736 | /// The caret position is the character position just before the caret. |
737 | /// A value of -1 means the caret is at the start of the buffer. | |
738 | void SetCaretPosition(long position, bool showAtLineStart = false) ; | |
739 | long GetCaretPosition() const { return m_caretPosition; } | |
740 | ||
ab14c7aa JS |
741 | /// The adjusted caret position is the character position adjusted to take |
742 | /// into account whether we're at the start of a paragraph, in which case | |
743 | /// style information should be taken from the next position, not current one. | |
744 | long GetAdjustedCaretPosition(long caretPos) const; | |
745 | ||
5d7836c4 JS |
746 | /// Move caret one visual step forward: this may mean setting a flag |
747 | /// and keeping the same position if we're going from the end of one line | |
748 | /// to the start of the next, which may be the exact same caret position. | |
749 | void MoveCaretForward(long oldPosition) ; | |
750 | ||
751 | /// Move caret one visual step forward: this may mean setting a flag | |
752 | /// and keeping the same position if we're going from the end of one line | |
753 | /// to the start of the next, which may be the exact same caret position. | |
754 | void MoveCaretBack(long oldPosition) ; | |
755 | ||
756 | /// Get the caret height and position for the given character position | |
757 | bool GetCaretPositionForIndex(long position, wxRect& rect); | |
758 | ||
759 | /// Gets the line for the visible caret position. If the caret is | |
760 | /// shown at the very end of the line, it means the next character is actually | |
761 | /// on the following line. So let's get the line we're expecting to find | |
762 | /// if this is the case. | |
763 | wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const; | |
764 | ||
765 | /// Gets the command processor | |
766 | wxCommandProcessor* GetCommandProcessor() const { return GetBuffer().GetCommandProcessor(); } | |
767 | ||
768 | /// Delete content if there is a selection, e.g. when pressing a key. | |
769 | /// Returns the new caret position in newPos, or leaves it if there | |
770 | /// was no action. | |
771 | bool DeleteSelectedContent(long* newPos= NULL); | |
772 | ||
773 | /// Transform logical to physical | |
4d551ad5 | 774 | wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const; |
5d7836c4 JS |
775 | |
776 | /// Transform physical to logical | |
4d551ad5 | 777 | wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const; |
5d7836c4 JS |
778 | |
779 | /// Finds the caret position for the next word. Direction | |
780 | /// is 1 (forward) or -1 (backwards). | |
781 | virtual long FindNextWordPosition(int direction = 1) const; | |
782 | ||
783 | /// Is the given position visible on the screen? | |
784 | bool IsPositionVisible(long pos) const; | |
785 | ||
4d551ad5 JS |
786 | /// Returns the first visible position in the current view |
787 | long GetFirstVisiblePosition() const; | |
788 | ||
ab14c7aa JS |
789 | /// Returns the caret position since the default formatting was changed. As |
790 | /// soon as this position changes, we no longer reflect the default style | |
791 | /// in the UI. A value of -2 means that we should only reflect the style of the | |
792 | /// content under the caret. | |
793 | long GetCaretPositionForDefaultStyle() const { return m_caretPositionForDefaultStyle; } | |
794 | ||
795 | /// Set the caret position for the default style that the user is selecting. | |
796 | void SetCaretPositionForDefaultStyle(long pos) { m_caretPositionForDefaultStyle = pos; } | |
797 | ||
798 | /// Should the UI reflect the default style chosen by the user, rather than the style under | |
799 | /// the caret? | |
800 | bool IsDefaultStyleShowing() const { return m_caretPositionForDefaultStyle != -2; } | |
801 | ||
802 | /// Convenience function that tells the control to start reflecting the default | |
803 | /// style, since the user is changing it. | |
24777478 | 804 | void SetAndShowDefaultStyle(const wxRichTextAttr& attr) |
ab14c7aa JS |
805 | { |
806 | SetDefaultStyle(attr); | |
807 | SetCaretPositionForDefaultStyle(GetCaretPosition()); | |
808 | } | |
809 | ||
ea160b2e JS |
810 | /// Get the first visible point in the window |
811 | wxPoint GetFirstVisiblePoint() const; | |
812 | ||
fe5aa22c JS |
813 | // Implementation |
814 | ||
dadd4f55 JS |
815 | /// Font names take a long time to retrieve, so cache them (on demand) |
816 | static const wxArrayString& GetAvailableFontNames(); | |
817 | static void ClearAvailableFontNames(); | |
818 | ||
805c8d92 VZ |
819 | WX_FORWARD_TO_SCROLL_HELPER() |
820 | ||
821 | // implement wxTextEntry methods | |
822 | virtual wxString DoGetValue() const; | |
823 | ||
824 | protected: | |
f5b7586b JS |
825 | // implement the wxTextEntry pure virtual method |
826 | virtual wxWindow *GetEditableWindow() { return this; } | |
827 | ||
63f7d502 VZ |
828 | // FIXME: this does not work, it allows this code to compile but will fail |
829 | // during run-time | |
2cd36ea0 | 830 | #ifndef __WXUNIVERSAL__ |
f5172305 JS |
831 | #ifdef __WXMSW__ |
832 | virtual WXHWND GetEditHWND() const { return GetHWND(); } | |
128fae46 | 833 | #endif |
5eb34e9e VZ |
834 | #ifdef __WXMOTIF__ |
835 | virtual WXWidget GetTextWidget() const { return NULL; } | |
836 | #endif | |
837 | #ifdef __WXGTK20__ | |
128fae46 | 838 | virtual GtkEditable *GetEditable() const { return NULL; } |
0847e36e | 839 | virtual GtkEntry *GetEntry() const { return NULL; } |
f5172305 | 840 | #endif |
2cd36ea0 | 841 | #endif // !__WXUNIVERSAL__ |
f5172305 | 842 | |
5d7836c4 | 843 | // Overrides |
6f02a879 | 844 | protected: |
5d7836c4 JS |
845 | |
846 | virtual wxSize DoGetBestSize() const ; | |
847 | ||
343ae70d VZ |
848 | virtual void DoSetValue(const wxString& value, int flags = 0); |
849 | ||
17808a75 VZ |
850 | virtual void DoThaw(); |
851 | ||
343ae70d | 852 | |
5d7836c4 JS |
853 | // Data members |
854 | private: | |
3e3a754f | 855 | #if wxRICHTEXT_BUFFERED_PAINTING |
5d7836c4 JS |
856 | /// Buffer bitmap |
857 | wxBitmap m_bufferBitmap; | |
3e3a754f | 858 | #endif |
5d7836c4 JS |
859 | |
860 | /// Text buffer | |
861 | wxRichTextBuffer m_buffer; | |
862 | ||
5d7836c4 JS |
863 | wxMenu* m_contextMenu; |
864 | ||
865 | /// Caret position (1 less than the character position, so -1 is the | |
866 | /// first caret position). | |
867 | long m_caretPosition; | |
868 | ||
ab14c7aa JS |
869 | /// Caret position when the default formatting has been changed. As |
870 | /// soon as this position changes, we no longer reflect the default style | |
871 | /// in the UI. | |
872 | long m_caretPositionForDefaultStyle; | |
873 | ||
5d7836c4 JS |
874 | /// Selection range in character positions. -2, -2 means no selection. |
875 | wxRichTextRange m_selectionRange; | |
876 | ||
877 | /// Anchor so we know how to extend the selection | |
878 | /// It's a caret position since it's between two characters. | |
879 | long m_selectionAnchor; | |
880 | ||
881 | /// Are we editable? | |
882 | bool m_editable; | |
883 | ||
884 | /// Are we showing the caret position at the start of a line | |
885 | /// instead of at the end of the previous one? | |
886 | bool m_caretAtLineStart; | |
887 | ||
888 | /// Are we dragging a selection? | |
889 | bool m_dragging; | |
890 | ||
891 | /// Start position for drag | |
892 | wxPoint m_dragStart; | |
4d551ad5 JS |
893 | |
894 | /// Do we need full layout in idle? | |
895 | bool m_fullLayoutRequired; | |
896 | wxLongLong m_fullLayoutTime; | |
897 | long m_fullLayoutSavedPosition; | |
898 | ||
899 | /// Threshold for doing delayed layout | |
900 | long m_delayedLayoutThreshold; | |
dadd4f55 | 901 | |
d2d0adc7 JS |
902 | /// Cursors |
903 | wxCursor m_textCursor; | |
904 | wxCursor m_urlCursor; | |
905 | ||
dadd4f55 | 906 | static wxArrayString sm_availableFontNames; |
cdaed652 VZ |
907 | /// The wxRichTextObject object under mouse if any |
908 | wxRichTextObject* m_currentObject; | |
909 | long m_imagePropertyId; | |
5d7836c4 JS |
910 | }; |
911 | ||
912 | /*! | |
913 | * wxRichTextEvent - the event class for wxRichTextCtrl notifications | |
914 | */ | |
915 | ||
3b2cb431 | 916 | class WXDLLIMPEXP_RICHTEXT wxRichTextEvent : public wxNotifyEvent |
5d7836c4 JS |
917 | { |
918 | public: | |
919 | wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) | |
920 | : wxNotifyEvent(commandType, winid), | |
5912d19e JS |
921 | m_flags(0), m_position(-1), m_oldStyleSheet(NULL), m_newStyleSheet(NULL), |
922 | m_char((wxChar) 0) | |
5d7836c4 JS |
923 | { } |
924 | ||
925 | wxRichTextEvent(const wxRichTextEvent& event) | |
926 | : wxNotifyEvent(event), | |
5912d19e JS |
927 | m_flags(event.m_flags), m_position(-1), |
928 | m_oldStyleSheet(event.m_oldStyleSheet), m_newStyleSheet(event.m_newStyleSheet), | |
929 | m_char((wxChar) 0) | |
5d7836c4 JS |
930 | { } |
931 | ||
5912d19e JS |
932 | long GetPosition() const { return m_position; } |
933 | void SetPosition(long pos) { m_position = pos; } | |
5d7836c4 JS |
934 | |
935 | int GetFlags() const { return m_flags; } | |
936 | void SetFlags(int flags) { m_flags = flags; } | |
937 | ||
d2d0adc7 JS |
938 | wxRichTextStyleSheet* GetOldStyleSheet() const { return m_oldStyleSheet; } |
939 | void SetOldStyleSheet(wxRichTextStyleSheet* sheet) { m_oldStyleSheet = sheet; } | |
940 | ||
941 | wxRichTextStyleSheet* GetNewStyleSheet() const { return m_newStyleSheet; } | |
942 | void SetNewStyleSheet(wxRichTextStyleSheet* sheet) { m_newStyleSheet = sheet; } | |
943 | ||
5912d19e JS |
944 | const wxRichTextRange& GetRange() const { return m_range; } |
945 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
946 | ||
947 | wxChar GetCharacter() const { return m_char; } | |
948 | void SetCharacter(wxChar ch) { m_char = ch; } | |
949 | ||
5d7836c4 JS |
950 | virtual wxEvent *Clone() const { return new wxRichTextEvent(*this); } |
951 | ||
952 | protected: | |
d2d0adc7 | 953 | int m_flags; |
5912d19e | 954 | long m_position; |
d2d0adc7 JS |
955 | wxRichTextStyleSheet* m_oldStyleSheet; |
956 | wxRichTextStyleSheet* m_newStyleSheet; | |
5912d19e JS |
957 | wxRichTextRange m_range; |
958 | wxChar m_char; | |
5d7836c4 JS |
959 | |
960 | private: | |
961 | DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRichTextEvent) | |
962 | }; | |
963 | ||
964 | /*! | |
c058cafa | 965 | * wxRichTextCtrl events |
5d7836c4 | 966 | */ |
9b11752c VZ |
967 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, wxRichTextEvent ); |
968 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, wxRichTextEvent ); | |
969 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, wxRichTextEvent ); | |
970 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, wxRichTextEvent ); | |
971 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RETURN, wxRichTextEvent ); | |
972 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CHARACTER, wxRichTextEvent ); | |
973 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_DELETE, wxRichTextEvent ); | |
974 | ||
975 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, wxRichTextEvent ); | |
976 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, wxRichTextEvent ); | |
977 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, wxRichTextEvent ); | |
978 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, wxRichTextEvent ); | |
979 | ||
980 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, wxRichTextEvent ); | |
981 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, wxRichTextEvent ); | |
982 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, wxRichTextEvent ); | |
983 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, wxRichTextEvent ); | |
984 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_BUFFER_RESET, wxRichTextEvent ); | |
5d7836c4 JS |
985 | |
986 | typedef void (wxEvtHandler::*wxRichTextEventFunction)(wxRichTextEvent&); | |
987 | ||
97f3b1e9 | 988 | #define wxRichTextEventHandler(func) \ |
3c778901 VZ |
989 | wxEVENT_HANDLER_CAST(wxRichTextEventFunction, func) |
990 | ||
a0e9a5df FM |
991 | #define EVT_RICHTEXT_LEFT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), |
992 | #define EVT_RICHTEXT_RIGHT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
993 | #define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
994 | #define EVT_RICHTEXT_LEFT_DCLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
995 | #define EVT_RICHTEXT_RETURN(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
996 | #define EVT_RICHTEXT_CHARACTER(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CHARACTER, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
997 | #define EVT_RICHTEXT_DELETE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_DELETE, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
998 | ||
999 | #define EVT_RICHTEXT_STYLESHEET_CHANGING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1000 | #define EVT_RICHTEXT_STYLESHEET_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1001 | #define EVT_RICHTEXT_STYLESHEET_REPLACING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1002 | #define EVT_RICHTEXT_STYLESHEET_REPLACED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1003 | ||
1004 | #define EVT_RICHTEXT_CONTENT_INSERTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1005 | #define EVT_RICHTEXT_CONTENT_DELETED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1006 | #define EVT_RICHTEXT_STYLE_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1007 | #define EVT_RICHTEXT_SELECTION_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
1008 | #define EVT_RICHTEXT_BUFFER_RESET(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_BUFFER_RESET, id, -1, wxRichTextEventHandler( fn ), NULL ), | |
5912d19e | 1009 | |
5d7836c4 JS |
1010 | #endif |
1011 | // wxUSE_RICHTEXT | |
1012 | ||
1013 | #endif | |
1014 | // _WX_RICHTEXTCTRL_H_ |