]>
Commit | Line | Data |
---|---|---|
23324ae1 | 1 | ///////////////////////////////////////////////////////////////////////////// |
7afd2b58 JS |
2 | // Name: wx/richtext/richtextctrl.h |
3 | // Purpose: A rich edit control | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2005-09-30 | |
7afd2b58 | 7 | // Copyright: (c) Julian Smart |
526954c5 | 8 | // Licence: wxWindows licence |
23324ae1 FM |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
7afd2b58 JS |
11 | /* |
12 | * Styles and flags | |
13 | */ | |
14 | ||
23324ae1 | 15 | /** |
7afd2b58 JS |
16 | Styles |
17 | */ | |
7c913512 | 18 | |
7afd2b58 JS |
19 | #define wxRE_READONLY 0x0010 |
20 | #define wxRE_MULTILINE 0x0020 | |
21 | #define wxRE_CENTRE_CARET 0x8000 | |
22 | #define wxRE_CENTER_CARET wxRE_CENTRE_CARET | |
7c913512 | 23 | |
7afd2b58 JS |
24 | /** |
25 | Flags | |
26 | */ | |
9e7ad1ca | 27 | |
7afd2b58 JS |
28 | #define wxRICHTEXT_SHIFT_DOWN 0x01 |
29 | #define wxRICHTEXT_CTRL_DOWN 0x02 | |
30 | #define wxRICHTEXT_ALT_DOWN 0x04 | |
31 | ||
32 | /** | |
33 | Extra flags | |
34 | */ | |
35 | ||
36 | // Don't draw guide lines around boxes and tables | |
37 | #define wxRICHTEXT_EX_NO_GUIDELINES 0x00000100 | |
38 | ||
39 | ||
40 | /* | |
41 | Defaults | |
23324ae1 | 42 | */ |
7afd2b58 JS |
43 | |
44 | #define wxRICHTEXT_DEFAULT_OVERALL_SIZE wxSize(-1, -1) | |
45 | #define wxRICHTEXT_DEFAULT_IMAGE_SIZE wxSize(80, 80) | |
46 | #define wxRICHTEXT_DEFAULT_SPACING 3 | |
47 | #define wxRICHTEXT_DEFAULT_MARGIN 3 | |
48 | #define wxRICHTEXT_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175) | |
49 | #define wxRICHTEXT_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140) | |
50 | #define wxRICHTEXT_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE) | |
51 | #define wxRICHTEXT_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200) | |
52 | #define wxRICHTEXT_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80) | |
53 | #define wxRICHTEXT_DEFAULT_CARET_WIDTH 2 | |
54 | // Minimum buffer size before delayed layout kicks in | |
55 | #define wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD 20000 | |
56 | // Milliseconds before layout occurs after resize | |
57 | #define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50 | |
58 | ||
59 | /* Identifiers | |
60 | */ | |
61 | #define wxID_RICHTEXT_PROPERTIES1 (wxID_HIGHEST + 1) | |
62 | #define wxID_RICHTEXT_PROPERTIES2 (wxID_HIGHEST + 2) | |
63 | #define wxID_RICHTEXT_PROPERTIES3 (wxID_HIGHEST + 3) | |
64 | ||
65 | /* | |
66 | Normal selection occurs initially and as user drags within one container. | |
67 | Common ancestor selection occurs when the user starts dragging across containers | |
68 | that have a common ancestor, for example the cells in a table. | |
69 | */ | |
70 | ||
71 | enum wxRichTextCtrlSelectionState | |
23324ae1 | 72 | { |
7afd2b58 JS |
73 | wxRichTextCtrlSelectionState_Normal, |
74 | wxRichTextCtrlSelectionState_CommonAncestor | |
75 | }; | |
76 | ||
77 | /** | |
78 | @class wxRichTextContextMenuPropertiesInfo | |
79 | ||
80 | wxRichTextContextMenuPropertiesInfo keeps track of objects that appear in the context menu, | |
81 | whose properties are available to be edited. | |
82 | */ | |
738b7b98 | 83 | |
16caec26 | 84 | class wxRichTextContextMenuPropertiesInfo |
7afd2b58 JS |
85 | { |
86 | public: | |
738b7b98 BP |
87 | /** |
88 | Constructor. | |
738b7b98 | 89 | */ |
42f2b395 | 90 | wxRichTextContextMenuPropertiesInfo(); |
7afd2b58 JS |
91 | |
92 | // Operations | |
23324ae1 | 93 | |
23324ae1 | 94 | /** |
7afd2b58 | 95 | Initialisation. |
23324ae1 | 96 | */ |
42f2b395 | 97 | void Init(); |
23324ae1 FM |
98 | |
99 | /** | |
7afd2b58 | 100 | Adds an item. |
23324ae1 | 101 | */ |
7afd2b58 | 102 | bool AddItem(const wxString& label, wxRichTextObject* obj); |
23324ae1 FM |
103 | |
104 | /** | |
7afd2b58 | 105 | Returns the number of menu items that were added. |
23324ae1 | 106 | */ |
7afd2b58 | 107 | int AddMenuItems(wxMenu* menu, int startCmd = wxID_RICHTEXT_PROPERTIES1) const; |
23324ae1 FM |
108 | |
109 | /** | |
7afd2b58 JS |
110 | Adds appropriate menu items for the current container and clicked on object |
111 | (and container's parent, if appropriate). | |
23324ae1 | 112 | */ |
303f0be7 | 113 | int AddItems(wxRichTextCtrl* ctrl, wxRichTextObject* container, wxRichTextObject* obj); |
23324ae1 FM |
114 | |
115 | /** | |
7afd2b58 | 116 | Clears the items. |
23324ae1 | 117 | */ |
42f2b395 | 118 | void Clear(); |
7afd2b58 JS |
119 | |
120 | // Accessors | |
23324ae1 FM |
121 | |
122 | /** | |
7afd2b58 | 123 | Returns the nth label. |
23324ae1 | 124 | */ |
42f2b395 | 125 | wxString GetLabel(int n) const; |
23324ae1 FM |
126 | |
127 | /** | |
7afd2b58 | 128 | Returns the nth object. |
23324ae1 | 129 | */ |
42f2b395 | 130 | wxRichTextObject* GetObject(int n) const; |
23324ae1 FM |
131 | |
132 | /** | |
7afd2b58 | 133 | Returns the array of objects. |
23324ae1 | 134 | */ |
42f2b395 | 135 | wxRichTextObjectPtrArray& GetObjects(); |
23324ae1 FM |
136 | |
137 | /** | |
7afd2b58 | 138 | Returns the array of objects. |
23324ae1 | 139 | */ |
42f2b395 | 140 | const wxRichTextObjectPtrArray& GetObjects() const; |
23324ae1 FM |
141 | |
142 | /** | |
7afd2b58 | 143 | Returns the array of labels. |
23324ae1 | 144 | */ |
42f2b395 | 145 | wxArrayString& GetLabels(); |
23324ae1 FM |
146 | |
147 | /** | |
7afd2b58 | 148 | Returns the array of labels. |
23324ae1 | 149 | */ |
42f2b395 | 150 | const wxArrayString& GetLabels() const; |
23324ae1 FM |
151 | |
152 | /** | |
7afd2b58 | 153 | Returns the number of items. |
23324ae1 | 154 | */ |
42f2b395 | 155 | int GetCount() const; |
23324ae1 | 156 | |
7afd2b58 JS |
157 | wxRichTextObjectPtrArray m_objects; |
158 | wxArrayString m_labels; | |
159 | }; | |
e54c96f1 | 160 | |
23324ae1 FM |
161 | /** |
162 | @class wxRichTextCtrl | |
7c913512 | 163 | |
23324ae1 FM |
164 | wxRichTextCtrl provides a generic, ground-up implementation of a text control |
165 | capable of showing multiple styles and images. | |
7c913512 | 166 | |
23324ae1 | 167 | wxRichTextCtrl sends notification events: see wxRichTextEvent. |
9e7ad1ca | 168 | |
ce7fe42e VZ |
169 | It also sends the standard wxTextCtrl events @c wxEVT_TEXT_ENTER and |
170 | @c wxEVT_TEXT, and wxTextUrlEvent when URL content is clicked. | |
7c913512 | 171 | |
738b7b98 | 172 | For more information, see the @ref overview_richtextctrl. |
7c913512 | 173 | |
e9f10004 JS |
174 | @beginStyleTable |
175 | @style{wxRE_CENTRE_CARET} | |
176 | The control will try to keep the caret line centred vertically while editing. | |
177 | wxRE_CENTER_CARET is a synonym for this style. | |
178 | @style{wxRE_MULTILINE} | |
179 | The control will be multiline (mandatory). | |
180 | @style{wxRE_READONLY} | |
181 | The control will not be editable. | |
182 | @endStyleTable | |
183 | ||
23324ae1 | 184 | @library{wxrichtext} |
21b447dc | 185 | @category{richtext} |
ce154616 | 186 | @appearance{richtextctrl} |
7afd2b58 JS |
187 | |
188 | */ | |
189 | ||
16caec26 | 190 | class wxRichTextCtrl : public wxControl, |
42f2b395 RD |
191 | public wxTextCtrlIface, |
192 | public wxScrollHelper | |
23324ae1 FM |
193 | { |
194 | public: | |
7afd2b58 JS |
195 | // Constructors |
196 | ||
23324ae1 | 197 | /** |
7afd2b58 | 198 | Default constructor. |
23324ae1 | 199 | */ |
7afd2b58 | 200 | wxRichTextCtrl( ); |
738b7b98 BP |
201 | |
202 | /** | |
203 | Constructor, creating and showing a rich text control. | |
204 | ||
205 | @param parent | |
206 | Parent window. Must not be @NULL. | |
207 | @param id | |
208 | Window identifier. The value @c wxID_ANY indicates a default value. | |
209 | @param value | |
210 | Default string. | |
211 | @param pos | |
212 | Window position. | |
213 | @param size | |
214 | Window size. | |
215 | @param style | |
216 | Window style. | |
217 | @param validator | |
218 | Window validator. | |
219 | @param name | |
220 | Window name. | |
221 | ||
222 | @see Create(), wxValidator | |
223 | */ | |
7afd2b58 JS |
224 | wxRichTextCtrl( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, |
225 | long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr); | |
23324ae1 FM |
226 | |
227 | /** | |
228 | Destructor. | |
229 | */ | |
7afd2b58 JS |
230 | virtual ~wxRichTextCtrl( ); |
231 | ||
232 | // Operations | |
23324ae1 FM |
233 | |
234 | /** | |
7afd2b58 | 235 | Creates the underlying window. |
23324ae1 | 236 | */ |
7afd2b58 JS |
237 | bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, |
238 | long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr ); | |
23324ae1 FM |
239 | |
240 | /** | |
7afd2b58 | 241 | Initialises the members of the control. |
23324ae1 | 242 | */ |
7afd2b58 JS |
243 | void Init(); |
244 | ||
245 | // Accessors | |
23324ae1 FM |
246 | |
247 | /** | |
7afd2b58 JS |
248 | Gets the text for the given range. |
249 | The end point of range is specified as the last character position of | |
250 | the span of text, plus one. | |
23324ae1 | 251 | */ |
7afd2b58 | 252 | virtual wxString GetRange(long from, long to) const; |
23324ae1 FM |
253 | |
254 | /** | |
7afd2b58 | 255 | Returns the length of the specified line in characters. |
23324ae1 | 256 | */ |
7afd2b58 | 257 | virtual int GetLineLength(long lineNo) const ; |
23324ae1 FM |
258 | |
259 | /** | |
7afd2b58 | 260 | Returns the text for the given line. |
23324ae1 | 261 | */ |
7afd2b58 | 262 | virtual wxString GetLineText(long lineNo) const ; |
23324ae1 FM |
263 | |
264 | /** | |
7afd2b58 | 265 | Returns the number of lines in the buffer. |
23324ae1 | 266 | */ |
7afd2b58 | 267 | virtual int GetNumberOfLines() const ; |
23324ae1 FM |
268 | |
269 | /** | |
7afd2b58 | 270 | Returns @true if the buffer has been modified. |
23324ae1 | 271 | */ |
7afd2b58 | 272 | virtual bool IsModified() const ; |
23324ae1 FM |
273 | |
274 | /** | |
7afd2b58 | 275 | Returns @true if the control is editable. |
23324ae1 | 276 | */ |
7afd2b58 | 277 | virtual bool IsEditable() const ; |
23324ae1 FM |
278 | |
279 | /** | |
7afd2b58 JS |
280 | Returns @true if the control is single-line. |
281 | Currently wxRichTextCtrl does not support single-line editing. | |
23324ae1 | 282 | */ |
42f2b395 | 283 | bool IsSingleLine() const; |
23324ae1 FM |
284 | |
285 | /** | |
7afd2b58 | 286 | Returns @true if the control is multiline. |
23324ae1 | 287 | */ |
42f2b395 | 288 | bool IsMultiLine() const; |
23324ae1 | 289 | |
7afd2b58 | 290 | //@{ |
23324ae1 | 291 | /** |
7afd2b58 JS |
292 | Returns the range of the current selection. |
293 | The end point of range is specified as the last character position of the span | |
294 | of text, plus one. | |
295 | If the return values @a from and @a to are the same, there is no selection. | |
23324ae1 | 296 | */ |
7afd2b58 | 297 | virtual void GetSelection(long* from, long* to) const; |
42f2b395 RD |
298 | const wxRichTextSelection& GetSelection() const; |
299 | wxRichTextSelection& GetSelection(); | |
7afd2b58 | 300 | //@} |
23324ae1 FM |
301 | |
302 | /** | |
7afd2b58 | 303 | Returns the text within the current selection range, if any. |
23324ae1 | 304 | */ |
7afd2b58 | 305 | virtual wxString GetStringSelection() const; |
23324ae1 FM |
306 | |
307 | /** | |
7afd2b58 | 308 | Gets the current filename associated with the control. |
23324ae1 | 309 | */ |
42f2b395 | 310 | wxString GetFilename() const; |
23324ae1 FM |
311 | |
312 | /** | |
7afd2b58 | 313 | Sets the current filename. |
23324ae1 | 314 | */ |
42f2b395 | 315 | void SetFilename(const wxString& filename); |
23324ae1 FM |
316 | |
317 | /** | |
7afd2b58 JS |
318 | Sets the size of the buffer beyond which layout is delayed during resizing. |
319 | This optimizes sizing for large buffers. The default is 20000. | |
23324ae1 | 320 | */ |
42f2b395 | 321 | void SetDelayedLayoutThreshold(long threshold); |
23324ae1 FM |
322 | |
323 | /** | |
7afd2b58 JS |
324 | Gets the size of the buffer beyond which layout is delayed during resizing. |
325 | This optimizes sizing for large buffers. The default is 20000. | |
23324ae1 | 326 | */ |
42f2b395 | 327 | long GetDelayedLayoutThreshold() const; |
23324ae1 FM |
328 | |
329 | /** | |
23324ae1 | 330 | */ |
42f2b395 | 331 | bool GetFullLayoutRequired() const; |
23324ae1 FM |
332 | |
333 | /** | |
23324ae1 | 334 | */ |
42f2b395 | 335 | void SetFullLayoutRequired(bool b); |
23324ae1 FM |
336 | |
337 | /** | |
23324ae1 | 338 | */ |
42f2b395 | 339 | wxLongLong GetFullLayoutTime() const; |
23324ae1 FM |
340 | |
341 | /** | |
23324ae1 | 342 | */ |
42f2b395 | 343 | void SetFullLayoutTime(wxLongLong t); |
23324ae1 FM |
344 | |
345 | /** | |
23324ae1 | 346 | */ |
42f2b395 | 347 | long GetFullLayoutSavedPosition() const; |
23324ae1 FM |
348 | |
349 | /** | |
23324ae1 | 350 | */ |
42f2b395 | 351 | void SetFullLayoutSavedPosition(long p); |
23324ae1 | 352 | |
7afd2b58 | 353 | // Force any pending layout due to large buffer |
23324ae1 | 354 | /** |
23324ae1 | 355 | */ |
7afd2b58 | 356 | void ForceDelayedLayout(); |
23324ae1 FM |
357 | |
358 | /** | |
7afd2b58 | 359 | Sets the text (normal) cursor. |
23324ae1 | 360 | */ |
42f2b395 | 361 | void SetTextCursor(const wxCursor& cursor ); |
23324ae1 FM |
362 | |
363 | /** | |
7afd2b58 | 364 | Returns the text (normal) cursor. |
23324ae1 | 365 | */ |
42f2b395 | 366 | wxCursor GetTextCursor() const; |
23324ae1 FM |
367 | |
368 | /** | |
7afd2b58 | 369 | Sets the cursor to be used over URLs. |
23324ae1 | 370 | */ |
42f2b395 | 371 | void SetURLCursor(const wxCursor& cursor ); |
23324ae1 FM |
372 | |
373 | /** | |
7afd2b58 | 374 | Returns the cursor to be used over URLs. |
23324ae1 | 375 | */ |
42f2b395 | 376 | wxCursor GetURLCursor() const; |
23324ae1 FM |
377 | |
378 | /** | |
7afd2b58 JS |
379 | Returns @true if we are showing the caret position at the start of a line |
380 | instead of at the end of the previous one. | |
23324ae1 | 381 | */ |
42f2b395 | 382 | bool GetCaretAtLineStart() const; |
23324ae1 FM |
383 | |
384 | /** | |
7afd2b58 JS |
385 | Sets a flag to remember that we are showing the caret position at the start of a line |
386 | instead of at the end of the previous one. | |
23324ae1 | 387 | */ |
42f2b395 | 388 | void SetCaretAtLineStart(bool atStart); |
23324ae1 FM |
389 | |
390 | /** | |
0c0e063e | 391 | Returns @true if we are extending a selection. |
23324ae1 | 392 | */ |
42f2b395 | 393 | bool GetDragging() const; |
23324ae1 FM |
394 | |
395 | /** | |
0c0e063e | 396 | Sets a flag to remember if we are extending a selection. |
23324ae1 | 397 | */ |
42f2b395 | 398 | void SetDragging(bool dragging); |
23324ae1 FM |
399 | |
400 | /** | |
0c0e063e | 401 | Are we trying to start Drag'n'Drop? |
23324ae1 | 402 | */ |
42f2b395 | 403 | bool GetPreDrag() const; |
23324ae1 FM |
404 | |
405 | /** | |
0c0e063e | 406 | Set if we're trying to start Drag'n'Drop |
23324ae1 | 407 | */ |
42f2b395 | 408 | void SetPreDrag(bool pd); |
0c0e063e JS |
409 | |
410 | /** | |
411 | Get the possible Drag'n'Drop start point | |
412 | */ | |
42f2b395 | 413 | const wxPoint GetDragStartPoint() const; |
0c0e063e JS |
414 | |
415 | /** | |
416 | Set the possible Drag'n'Drop start point | |
417 | */ | |
42f2b395 | 418 | void SetDragStartPoint(wxPoint sp); |
0c0e063e JS |
419 | |
420 | /** | |
421 | Get the possible Drag'n'Drop start time | |
422 | */ | |
42f2b395 | 423 | const wxDateTime GetDragStartTime() const; |
0c0e063e JS |
424 | |
425 | /** | |
426 | Set the possible Drag'n'Drop start time | |
427 | */ | |
42f2b395 | 428 | void SetDragStartTime(wxDateTime st); |
23324ae1 | 429 | |
7afd2b58 JS |
430 | #if wxRICHTEXT_BUFFERED_PAINTING |
431 | //@{ | |
23324ae1 | 432 | /** |
7afd2b58 | 433 | Returns the buffer bitmap if using buffered painting. |
23324ae1 | 434 | */ |
42f2b395 RD |
435 | const wxBitmap& GetBufferBitmap() const; |
436 | wxBitmap& GetBufferBitmap(); | |
7afd2b58 JS |
437 | //@} |
438 | #endif | |
23324ae1 FM |
439 | |
440 | /** | |
7afd2b58 | 441 | Returns the current context menu. |
23324ae1 | 442 | */ |
42f2b395 | 443 | wxMenu* GetContextMenu() const; |
23324ae1 FM |
444 | |
445 | /** | |
7afd2b58 | 446 | Sets the current context menu. |
23324ae1 | 447 | */ |
7afd2b58 | 448 | void SetContextMenu(wxMenu* menu); |
23324ae1 FM |
449 | |
450 | /** | |
7afd2b58 JS |
451 | Returns an anchor so we know how to extend the selection. |
452 | It's a caret position since it's between two characters. | |
23324ae1 | 453 | */ |
42f2b395 | 454 | long GetSelectionAnchor() const; |
23324ae1 | 455 | |
23324ae1 | 456 | /** |
7afd2b58 JS |
457 | Sets an anchor so we know how to extend the selection. |
458 | It's a caret position since it's between two characters. | |
23324ae1 | 459 | */ |
42f2b395 | 460 | void SetSelectionAnchor(long anchor); |
23324ae1 FM |
461 | |
462 | /** | |
7afd2b58 | 463 | Returns the anchor object if selecting multiple containers. |
23324ae1 | 464 | */ |
42f2b395 | 465 | wxRichTextObject* GetSelectionAnchorObject() const; |
23324ae1 FM |
466 | |
467 | /** | |
7afd2b58 | 468 | Sets the anchor object if selecting multiple containers. |
23324ae1 | 469 | */ |
42f2b395 | 470 | void SetSelectionAnchorObject(wxRichTextObject* anchor); |
23324ae1 | 471 | |
7afd2b58 | 472 | //@{ |
23324ae1 | 473 | /** |
7afd2b58 JS |
474 | Returns an object that stores information about context menu property item(s), |
475 | in order to communicate between the context menu event handler and the code | |
476 | that responds to it. The wxRichTextContextMenuPropertiesInfo stores one | |
477 | item for each object that could respond to a property-editing event. If | |
478 | objects are nested, several might be editable. | |
23324ae1 | 479 | */ |
42f2b395 RD |
480 | wxRichTextContextMenuPropertiesInfo& GetContextMenuPropertiesInfo(); |
481 | const wxRichTextContextMenuPropertiesInfo& GetContextMenuPropertiesInfo() const; | |
7afd2b58 | 482 | //@} |
23324ae1 FM |
483 | |
484 | /** | |
7afd2b58 JS |
485 | Returns the wxRichTextObject object that currently has the editing focus. |
486 | If there are no composite objects, this will be the top-level buffer. | |
23324ae1 | 487 | */ |
42f2b395 | 488 | wxRichTextParagraphLayoutBox* GetFocusObject() const; |
23324ae1 | 489 | |
0c0e063e JS |
490 | /** |
491 | Setter for m_focusObject. | |
492 | */ | |
493 | void StoreFocusObject(wxRichTextParagraphLayoutBox* obj); | |
494 | ||
23324ae1 | 495 | /** |
7afd2b58 | 496 | Sets the wxRichTextObject object that currently has the editing focus. |
591805e0 SL |
497 | @param obj |
498 | The wxRichTextObject to set focus on. | |
0c0e063e JS |
499 | @param setCaretPosition |
500 | Optionally set the caret position. | |
23324ae1 | 501 | */ |
7afd2b58 | 502 | bool SetFocusObject(wxRichTextParagraphLayoutBox* obj, bool setCaretPosition = true); |
371ae8b5 | 503 | |
7afd2b58 | 504 | // Operations |
23324ae1 FM |
505 | |
506 | /** | |
7afd2b58 | 507 | Invalidates the whole buffer to trigger painting later. |
23324ae1 | 508 | */ |
42f2b395 | 509 | void Invalidate(); |
23324ae1 FM |
510 | |
511 | /** | |
7afd2b58 | 512 | Clears the buffer content, leaving a single empty paragraph. Cannot be undone. |
23324ae1 | 513 | */ |
7afd2b58 | 514 | virtual void Clear(); |
23324ae1 | 515 | |
23324ae1 | 516 | /** |
7afd2b58 JS |
517 | Replaces the content in the specified range with the string specified by |
518 | @a value. | |
23324ae1 | 519 | */ |
7afd2b58 | 520 | virtual void Replace(long from, long to, const wxString& value); |
23324ae1 FM |
521 | |
522 | /** | |
7afd2b58 | 523 | Removes the content in the specified range. |
23324ae1 | 524 | */ |
7afd2b58 | 525 | virtual void Remove(long from, long to); |
23324ae1 FM |
526 | |
527 | /** | |
7afd2b58 | 528 | Loads content into the control's buffer using the given type. |
23324ae1 | 529 | |
7afd2b58 JS |
530 | If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from |
531 | the filename extension. | |
23324ae1 | 532 | |
7afd2b58 | 533 | This function looks for a suitable wxRichTextFileHandler object. |
23324ae1 | 534 | */ |
7afd2b58 JS |
535 | bool LoadFile(const wxString& file, |
536 | int type = wxRICHTEXT_TYPE_ANY); | |
23324ae1 FM |
537 | |
538 | /** | |
7afd2b58 | 539 | Helper function for LoadFile(). Loads content into the control's buffer using the given type. |
23324ae1 | 540 | |
7afd2b58 JS |
541 | If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from |
542 | the filename extension. | |
23324ae1 | 543 | |
7afd2b58 | 544 | This function looks for a suitable wxRichTextFileHandler object. |
23324ae1 | 545 | */ |
7afd2b58 | 546 | virtual bool DoLoadFile(const wxString& file, int fileType); |
23324ae1 FM |
547 | |
548 | /** | |
7afd2b58 | 549 | Saves the buffer content using the given type. |
23324ae1 | 550 | |
7afd2b58 JS |
551 | If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from |
552 | the filename extension. | |
23324ae1 | 553 | |
7afd2b58 | 554 | This function looks for a suitable wxRichTextFileHandler object. |
23324ae1 | 555 | */ |
7afd2b58 JS |
556 | bool SaveFile(const wxString& file = wxEmptyString, |
557 | int type = wxRICHTEXT_TYPE_ANY); | |
23324ae1 FM |
558 | |
559 | /** | |
7afd2b58 | 560 | Helper function for SaveFile(). Saves the buffer content using the given type. |
23324ae1 | 561 | |
7afd2b58 JS |
562 | If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from |
563 | the filename extension. | |
23324ae1 | 564 | |
7afd2b58 | 565 | This function looks for a suitable wxRichTextFileHandler object. |
23324ae1 | 566 | */ |
7afd2b58 JS |
567 | virtual bool DoSaveFile(const wxString& file = wxEmptyString, |
568 | int fileType = wxRICHTEXT_TYPE_ANY); | |
23324ae1 FM |
569 | |
570 | /** | |
7afd2b58 | 571 | Sets flags that change the behaviour of loading or saving. |
23324ae1 | 572 | |
7afd2b58 JS |
573 | See the documentation for each handler class to see what flags are |
574 | relevant for each handler. | |
23324ae1 | 575 | */ |
42f2b395 | 576 | void SetHandlerFlags(int flags); |
23324ae1 FM |
577 | |
578 | /** | |
7afd2b58 JS |
579 | Returns flags that change the behaviour of loading or saving. |
580 | See the documentation for each handler class to see what flags are | |
581 | relevant for each handler. | |
23324ae1 | 582 | */ |
42f2b395 | 583 | int GetHandlerFlags() const; |
23324ae1 FM |
584 | |
585 | /** | |
7afd2b58 | 586 | Marks the buffer as modified. |
23324ae1 | 587 | */ |
7afd2b58 | 588 | virtual void MarkDirty(); |
23324ae1 FM |
589 | |
590 | /** | |
7afd2b58 JS |
591 | Sets the buffer's modified status to @false, and clears the buffer's command |
592 | history. | |
23324ae1 | 593 | */ |
7afd2b58 | 594 | virtual void DiscardEdits(); |
23324ae1 | 595 | |
42f2b395 RD |
596 | |
597 | void SetModified(bool modified); | |
598 | ||
23324ae1 | 599 | /** |
7afd2b58 JS |
600 | Sets the maximum number of characters that may be entered in a single line |
601 | text control. For compatibility only; currently does nothing. | |
23324ae1 | 602 | */ |
42f2b395 | 603 | virtual void SetMaxLength(unsigned long len); |
23324ae1 FM |
604 | |
605 | /** | |
7afd2b58 | 606 | Writes text at the current position. |
23324ae1 | 607 | */ |
7afd2b58 | 608 | virtual void WriteText(const wxString& text); |
23324ae1 FM |
609 | |
610 | /** | |
7afd2b58 | 611 | Sets the insertion point to the end of the buffer and writes the text. |
23324ae1 | 612 | */ |
7afd2b58 | 613 | virtual void AppendText(const wxString& text); |
23324ae1 | 614 | |
7afd2b58 | 615 | //@{ |
23324ae1 | 616 | /** |
7afd2b58 JS |
617 | Gets the attributes at the given position. |
618 | This function gets the combined style - that is, the style you see on the | |
619 | screen as a result of combining base style, paragraph style and character | |
620 | style attributes. | |
621 | ||
622 | To get the character or paragraph style alone, use GetUncombinedStyle(). | |
623 | ||
624 | @beginWxPerlOnly | |
625 | In wxPerl this method is implemented as GetStyle(@a position) | |
626 | returning a 2-element list (ok, attr). | |
627 | @endWxPerlOnly | |
23324ae1 | 628 | */ |
7afd2b58 JS |
629 | virtual bool GetStyle(long position, wxTextAttr& style); |
630 | virtual bool GetStyle(long position, wxRichTextAttr& style); | |
631 | virtual bool GetStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container); | |
632 | //@} | |
23324ae1 | 633 | |
7afd2b58 | 634 | //@{ |
23324ae1 | 635 | /** |
7afd2b58 JS |
636 | Sets the attributes for the given range. |
637 | The end point of range is specified as the last character position of the span | |
638 | of text, plus one. | |
639 | ||
640 | So, for example, to set the style for a character at position 5, use the range | |
641 | (5,6). | |
23324ae1 | 642 | */ |
7afd2b58 JS |
643 | virtual bool SetStyle(long start, long end, const wxTextAttr& style); |
644 | virtual bool SetStyle(long start, long end, const wxRichTextAttr& style); | |
645 | virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style); | |
646 | virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style); | |
647 | //@} | |
23324ae1 FM |
648 | |
649 | /** | |
7afd2b58 | 650 | Sets the attributes for a single object |
23324ae1 | 651 | */ |
e059e1bb | 652 | virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); |
23324ae1 FM |
653 | |
654 | //@{ | |
655 | /** | |
7afd2b58 JS |
656 | Gets the attributes common to the specified range. |
657 | Attributes that differ in value within the range will not be included | |
658 | in @a style flags. | |
659 | ||
660 | @beginWxPerlOnly | |
661 | In wxPerl this method is implemented as GetStyleForRange(@a position) | |
662 | returning a 2-element list (ok, attr). | |
663 | @endWxPerlOnly | |
23324ae1 | 664 | */ |
7afd2b58 JS |
665 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style); |
666 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style); | |
667 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container); | |
23324ae1 FM |
668 | //@} |
669 | ||
670 | /** | |
7afd2b58 JS |
671 | Sets the attributes for the given range, passing flags to determine how the |
672 | attributes are set. | |
673 | ||
674 | The end point of range is specified as the last character position of the span | |
675 | of text, plus one. So, for example, to set the style for a character at | |
676 | position 5, use the range (5,6). | |
677 | ||
678 | @a flags may contain a bit list of the following values: | |
679 | - wxRICHTEXT_SETSTYLE_NONE: no style flag. | |
680 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be | |
681 | undoable. | |
682 | - wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied | |
683 | if the combined style at this point is already the style in question. | |
684 | - wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be | |
685 | applied to paragraphs, and not the content. | |
686 | This allows content styling to be preserved independently from that | |
687 | of e.g. a named paragraph style. | |
688 | - wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be | |
689 | applied to characters, and not the paragraph. | |
690 | This allows content styling to be preserved independently from that | |
691 | of e.g. a named paragraph style. | |
692 | - wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying | |
693 | the new style. | |
694 | - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags | |
695 | are used in this operation. | |
23324ae1 | 696 | */ |
7afd2b58 | 697 | virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); |
23324ae1 | 698 | |
7afd2b58 | 699 | //@{ |
23324ae1 | 700 | /** |
7afd2b58 JS |
701 | Gets the attributes at the given position. |
702 | This function gets the @e uncombined style - that is, the attributes associated | |
703 | with the paragraph or character content, and not necessarily the combined | |
704 | attributes you see on the screen. | |
705 | To get the combined attributes, use GetStyle(). | |
706 | ||
707 | If you specify (any) paragraph attribute in @e style's flags, this function | |
708 | will fetch the paragraph attributes. | |
709 | Otherwise, it will return the character attributes. | |
371ae8b5 MB |
710 | |
711 | @beginWxPerlOnly | |
7afd2b58 JS |
712 | In wxPerl this method is implemented as GetUncombinedStyle(@a position) |
713 | returning a 2-element list (ok, attr). | |
371ae8b5 | 714 | @endWxPerlOnly |
23324ae1 | 715 | */ |
7afd2b58 JS |
716 | virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style); |
717 | virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container); | |
718 | //@} | |
23324ae1 | 719 | |
7afd2b58 | 720 | //@{ |
23324ae1 | 721 | /** |
7afd2b58 JS |
722 | Sets the current default style, which can be used to change how subsequently |
723 | inserted text is displayed. | |
23324ae1 | 724 | */ |
7afd2b58 JS |
725 | virtual bool SetDefaultStyle(const wxTextAttr& style); |
726 | virtual bool SetDefaultStyle(const wxRichTextAttr& style); | |
727 | //@} | |
23324ae1 FM |
728 | |
729 | /** | |
730 | Returns the current default style, which can be used to change how subsequently | |
9e7ad1ca | 731 | inserted text is displayed. |
23324ae1 | 732 | */ |
7afd2b58 | 733 | virtual const wxRichTextAttr& GetDefaultStyleEx() const; |
23324ae1 | 734 | |
7afd2b58 | 735 | //virtual const wxTextAttr& GetDefaultStyle() const; |
23324ae1 | 736 | |
7afd2b58 | 737 | //@{ |
23324ae1 | 738 | /** |
7afd2b58 JS |
739 | Sets the list attributes for the given range, passing flags to determine how |
740 | the attributes are set. | |
23324ae1 | 741 | |
7afd2b58 JS |
742 | Either the style definition or the name of the style definition (in the current |
743 | sheet) can be passed. | |
744 | @a flags is a bit list of the following: | |
745 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
746 | - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from | |
747 | @a startFrom, otherwise existing attributes are used. | |
748 | - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used | |
749 | as the level for all paragraphs, otherwise the current indentation will be used. | |
23324ae1 | 750 | |
7afd2b58 | 751 | @see NumberList(), PromoteList(), ClearListStyle(). |
23324ae1 | 752 | */ |
7afd2b58 JS |
753 | virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); |
754 | virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
755 | //@} | |
23324ae1 FM |
756 | |
757 | /** | |
7afd2b58 JS |
758 | Clears the list style from the given range, clearing list-related attributes |
759 | and applying any named paragraph style associated with each paragraph. | |
23324ae1 | 760 | |
7afd2b58 JS |
761 | @a flags is a bit list of the following: |
762 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
23324ae1 | 763 | |
7afd2b58 | 764 | @see SetListStyle(), PromoteList(), NumberList(). |
23324ae1 | 765 | */ |
7afd2b58 | 766 | virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); |
23324ae1 | 767 | |
7afd2b58 | 768 | //@{ |
23324ae1 | 769 | /** |
7afd2b58 JS |
770 | Numbers the paragraphs in the given range. |
771 | Pass flags to determine how the attributes are set. | |
23324ae1 | 772 | |
7afd2b58 JS |
773 | Either the style definition or the name of the style definition (in the current |
774 | sheet) can be passed. | |
23324ae1 | 775 | |
7afd2b58 JS |
776 | @a flags is a bit list of the following: |
777 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
778 | - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from | |
779 | @a startFrom, otherwise existing attributes are used. | |
780 | - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used | |
781 | as the level for all paragraphs, otherwise the current indentation will be used. | |
782 | ||
783 | @see SetListStyle(), PromoteList(), ClearListStyle(). | |
23324ae1 | 784 | */ |
7afd2b58 JS |
785 | virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); |
786 | virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
787 | //@} | |
23324ae1 | 788 | |
7afd2b58 | 789 | //@{ |
23324ae1 | 790 | /** |
7afd2b58 JS |
791 | Promotes or demotes the paragraphs in the given range. |
792 | A positive @a promoteBy produces a smaller indent, and a negative number | |
793 | produces a larger indent. Pass flags to determine how the attributes are set. | |
794 | Either the style definition or the name of the style definition (in the current | |
795 | sheet) can be passed. | |
796 | ||
797 | @a flags is a bit list of the following: | |
798 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
799 | - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from | |
800 | @a startFrom, otherwise existing attributes are used. | |
801 | - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used | |
802 | as the level for all paragraphs, otherwise the current indentation will be used. | |
803 | ||
804 | @see SetListStyle(), @see SetListStyle(), ClearListStyle(). | |
23324ae1 | 805 | */ |
7afd2b58 JS |
806 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); |
807 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); | |
808 | //@} | |
23324ae1 | 809 | |
590a0f8b JS |
810 | /** |
811 | Sets the properties for the given range, passing flags to determine how the | |
812 | attributes are set. You can merge properties or replace them. | |
813 | ||
814 | The end point of range is specified as the last character position of the span | |
815 | of text, plus one. So, for example, to set the properties for a character at | |
816 | position 5, use the range (5,6). | |
817 | ||
818 | @a flags may contain a bit list of the following values: | |
819 | - wxRICHTEXT_SETSPROPERTIES_NONE: no flag. | |
820 | - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be | |
821 | undoable. | |
822 | - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be | |
823 | applied to paragraphs, and not the content. | |
824 | - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be | |
825 | applied to characters, and not the paragraph. | |
826 | - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying | |
827 | the new properties. | |
828 | - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties. | |
829 | */ | |
830 | virtual bool SetProperties(const wxRichTextRange& range, const wxRichTextProperties& properties, int flags = wxRICHTEXT_SETPROPERTIES_WITH_UNDO); | |
831 | ||
23324ae1 | 832 | /** |
7afd2b58 | 833 | Deletes the content within the given range. |
23324ae1 | 834 | */ |
7afd2b58 | 835 | virtual bool Delete(const wxRichTextRange& range); |
23324ae1 FM |
836 | |
837 | /** | |
7afd2b58 | 838 | Translates from column and line number to position. |
23324ae1 | 839 | */ |
7afd2b58 | 840 | virtual long XYToPosition(long x, long y) const; |
23324ae1 FM |
841 | |
842 | /** | |
7afd2b58 | 843 | Converts a text position to zero-based column and line numbers. |
23324ae1 | 844 | */ |
7afd2b58 | 845 | virtual bool PositionToXY(long pos, long *x, long *y) const; |
23324ae1 FM |
846 | |
847 | /** | |
7afd2b58 | 848 | Scrolls the buffer so that the given position is in view. |
23324ae1 | 849 | */ |
7afd2b58 | 850 | virtual void ShowPosition(long pos); |
23324ae1 | 851 | |
7afd2b58 | 852 | //@{ |
23324ae1 | 853 | /** |
7afd2b58 JS |
854 | Finds the character at the given position in pixels. |
855 | @a pt is in device coords (not adjusted for the client area origin nor for | |
856 | scrolling). | |
857 | */ | |
858 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; | |
859 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, | |
860 | wxTextCoord *col, | |
861 | wxTextCoord *row) const; | |
0c0e063e JS |
862 | |
863 | /** | |
864 | Finds the container at the given point, which is assumed to be in client coordinates. | |
865 | */ | |
866 | wxRichTextParagraphLayoutBox* FindContainerAtPoint(const wxPoint pt, long& position, int& hit, wxRichTextObject* hitObj, int flags = 0); | |
7afd2b58 | 867 | //@} |
9e7ad1ca | 868 | |
7afd2b58 | 869 | // Clipboard operations |
371ae8b5 | 870 | |
7afd2b58 JS |
871 | /** |
872 | Copies the selected content (if any) to the clipboard. | |
23324ae1 | 873 | */ |
7afd2b58 | 874 | virtual void Copy(); |
23324ae1 FM |
875 | |
876 | /** | |
7afd2b58 JS |
877 | Copies the selected content (if any) to the clipboard and deletes the selection. |
878 | This is undoable. | |
23324ae1 | 879 | */ |
7afd2b58 | 880 | virtual void Cut(); |
23324ae1 FM |
881 | |
882 | /** | |
7afd2b58 | 883 | Pastes content from the clipboard to the buffer. |
23324ae1 | 884 | */ |
7afd2b58 | 885 | virtual void Paste(); |
23324ae1 FM |
886 | |
887 | /** | |
7afd2b58 | 888 | Deletes the content in the selection, if any. This is undoable. |
23324ae1 | 889 | */ |
7afd2b58 | 890 | virtual void DeleteSelection(); |
23324ae1 FM |
891 | |
892 | /** | |
7afd2b58 | 893 | Returns @true if selected content can be copied to the clipboard. |
23324ae1 | 894 | */ |
7afd2b58 | 895 | virtual bool CanCopy() const; |
23324ae1 FM |
896 | |
897 | /** | |
7afd2b58 | 898 | Returns @true if selected content can be copied to the clipboard and deleted. |
23324ae1 | 899 | */ |
7afd2b58 | 900 | virtual bool CanCut() const; |
23324ae1 FM |
901 | |
902 | /** | |
7afd2b58 JS |
903 | Returns @true if the clipboard content can be pasted to the buffer. |
904 | */ | |
905 | virtual bool CanPaste() const; | |
9e7ad1ca | 906 | |
7afd2b58 JS |
907 | /** |
908 | Returns @true if selected content can be deleted. | |
23324ae1 | 909 | */ |
7afd2b58 | 910 | virtual bool CanDeleteSelection() const; |
23324ae1 FM |
911 | |
912 | /** | |
7afd2b58 | 913 | Undoes the command at the top of the command history, if there is one. |
23324ae1 | 914 | */ |
7afd2b58 | 915 | virtual void Undo(); |
23324ae1 FM |
916 | |
917 | /** | |
7afd2b58 | 918 | Redoes the current command. |
23324ae1 | 919 | */ |
7afd2b58 | 920 | virtual void Redo(); |
23324ae1 | 921 | |
23324ae1 | 922 | /** |
7afd2b58 | 923 | Returns @true if there is a command in the command history that can be undone. |
23324ae1 | 924 | */ |
7afd2b58 | 925 | virtual bool CanUndo() const; |
23324ae1 FM |
926 | |
927 | /** | |
7afd2b58 | 928 | Returns @true if there is a command in the command history that can be redone. |
23324ae1 | 929 | */ |
7afd2b58 | 930 | virtual bool CanRedo() const; |
23324ae1 | 931 | |
23324ae1 | 932 | /** |
7afd2b58 JS |
933 | Sets the insertion point and causes the current editing style to be taken from |
934 | the new position (unlike wxRichTextCtrl::SetCaretPosition). | |
935 | */ | |
936 | virtual void SetInsertionPoint(long pos); | |
9e7ad1ca | 937 | |
7afd2b58 JS |
938 | /** |
939 | Sets the insertion point to the end of the text control. | |
940 | */ | |
941 | virtual void SetInsertionPointEnd(); | |
9e7ad1ca | 942 | |
7afd2b58 JS |
943 | /** |
944 | Returns the current insertion point. | |
23324ae1 | 945 | */ |
7afd2b58 | 946 | virtual long GetInsertionPoint() const; |
23324ae1 FM |
947 | |
948 | /** | |
7afd2b58 | 949 | Returns the last position in the buffer. |
23324ae1 | 950 | */ |
7afd2b58 | 951 | virtual wxTextPos GetLastPosition() const; |
23324ae1 | 952 | |
7afd2b58 | 953 | //@{ |
23324ae1 | 954 | /** |
7afd2b58 JS |
955 | Sets the selection to the given range. |
956 | The end point of range is specified as the last character position of the span | |
957 | of text, plus one. | |
958 | ||
959 | So, for example, to set the selection for a character at position 5, use the | |
960 | range (5,6). | |
23324ae1 | 961 | */ |
7afd2b58 | 962 | virtual void SetSelection(long from, long to); |
42f2b395 | 963 | void SetSelection(const wxRichTextSelection& sel); |
7afd2b58 JS |
964 | //@} |
965 | ||
23324ae1 FM |
966 | |
967 | /** | |
7afd2b58 | 968 | Selects all the text in the buffer. |
23324ae1 | 969 | */ |
7afd2b58 | 970 | virtual void SelectAll(); |
23324ae1 FM |
971 | |
972 | /** | |
7afd2b58 | 973 | Makes the control editable, or not. |
23324ae1 | 974 | */ |
7afd2b58 | 975 | virtual void SetEditable(bool editable); |
23324ae1 FM |
976 | |
977 | /** | |
7afd2b58 JS |
978 | Returns @true if there is a selection and the object containing the selection |
979 | was the same as the current focus object. | |
23324ae1 | 980 | */ |
7afd2b58 | 981 | virtual bool HasSelection() const; |
23324ae1 FM |
982 | |
983 | /** | |
7afd2b58 JS |
984 | Returns @true if there was a selection, whether or not the current focus object |
985 | is the same as the selection's container object. | |
23324ae1 | 986 | */ |
7afd2b58 | 987 | virtual bool HasUnfocusedSelection() const; |
23324ae1 | 988 | |
7afd2b58 | 989 | //@{ |
23324ae1 | 990 | /** |
7afd2b58 JS |
991 | Write a bitmap or image at the current insertion point. |
992 | Supply an optional type to use for internal and file storage of the raw data. | |
23324ae1 | 993 | */ |
7afd2b58 JS |
994 | virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, |
995 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
996 | ||
997 | virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, | |
998 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
999 | //@} | |
23324ae1 FM |
1000 | |
1001 | /** | |
7afd2b58 | 1002 | Loads an image from a file and writes it at the current insertion point. |
23324ae1 | 1003 | */ |
7afd2b58 JS |
1004 | virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType, |
1005 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
23324ae1 FM |
1006 | |
1007 | /** | |
7afd2b58 | 1008 | Writes an image block at the current insertion point. |
23324ae1 | 1009 | */ |
7afd2b58 JS |
1010 | virtual bool WriteImage(const wxRichTextImageBlock& imageBlock, |
1011 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
23324ae1 FM |
1012 | |
1013 | /** | |
7afd2b58 JS |
1014 | Write a text box at the current insertion point, returning the text box. |
1015 | You can then call SetFocusObject() to set the focus to the new object. | |
23324ae1 | 1016 | */ |
7afd2b58 | 1017 | virtual wxRichTextBox* WriteTextBox(const wxRichTextAttr& textAttr = wxRichTextAttr()); |
23324ae1 | 1018 | |
7c9fdebe JS |
1019 | /** |
1020 | Writes a field at the current insertion point. | |
1021 | ||
1022 | @param fieldType | |
1023 | The field type, matching an existing field type definition. | |
1024 | @param properties | |
1025 | Extra data for the field. | |
1026 | @param textAttr | |
1027 | Optional attributes. | |
1028 | ||
1029 | @see wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard | |
1030 | */ | |
1031 | virtual wxRichTextField* WriteField(const wxString& fieldType, const wxRichTextProperties& properties, | |
1032 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
1033 | ||
23324ae1 | 1034 | /** |
7afd2b58 JS |
1035 | Write a table at the current insertion point, returning the table. |
1036 | You can then call SetFocusObject() to set the focus to the new object. | |
23324ae1 | 1037 | */ |
7afd2b58 | 1038 | virtual wxRichTextTable* WriteTable(int rows, int cols, const wxRichTextAttr& tableAttr = wxRichTextAttr(), const wxRichTextAttr& cellAttr = wxRichTextAttr()); |
23324ae1 FM |
1039 | |
1040 | /** | |
7afd2b58 | 1041 | Inserts a new paragraph at the current insertion point. @see LineBreak(). |
23324ae1 | 1042 | */ |
7afd2b58 | 1043 | virtual bool Newline(); |
23324ae1 FM |
1044 | |
1045 | /** | |
9e7ad1ca FM |
1046 | Inserts a line break at the current insertion point. |
1047 | ||
1048 | A line break forces wrapping within a paragraph, and can be introduced by | |
1049 | using this function, by appending the wxChar value @b wxRichTextLineBreakChar | |
1050 | to text content, or by typing Shift-Return. | |
23324ae1 | 1051 | */ |
adaaa686 | 1052 | virtual bool LineBreak(); |
23324ae1 FM |
1053 | |
1054 | /** | |
7afd2b58 | 1055 | Sets the basic (overall) style. |
9e7ad1ca | 1056 | |
7afd2b58 JS |
1057 | This is the style of the whole buffer before further styles are applied, |
1058 | unlike the default style, which only affects the style currently being | |
1059 | applied (for example, setting the default style to bold will cause | |
1060 | subsequently inserted text to be bold). | |
23324ae1 | 1061 | */ |
42f2b395 | 1062 | virtual void SetBasicStyle(const wxRichTextAttr& style); |
23324ae1 FM |
1063 | |
1064 | /** | |
7afd2b58 JS |
1065 | Gets the basic (overall) style. |
1066 | ||
1067 | This is the style of the whole buffer before further styles are applied, | |
1068 | unlike the default style, which only affects the style currently being | |
1069 | applied (for example, setting the default style to bold will cause | |
1070 | subsequently inserted text to be bold). | |
23324ae1 | 1071 | */ |
42f2b395 | 1072 | virtual const wxRichTextAttr& GetBasicStyle() const; |
23324ae1 FM |
1073 | |
1074 | /** | |
7afd2b58 | 1075 | Begins applying a style. |
23324ae1 | 1076 | */ |
42f2b395 | 1077 | virtual bool BeginStyle(const wxRichTextAttr& style); |
23324ae1 FM |
1078 | |
1079 | /** | |
7afd2b58 | 1080 | Ends the current style. |
23324ae1 | 1081 | */ |
42f2b395 | 1082 | virtual bool EndStyle(); |
23324ae1 FM |
1083 | |
1084 | /** | |
7afd2b58 | 1085 | Ends application of all styles in the current style stack. |
23324ae1 | 1086 | */ |
42f2b395 | 1087 | virtual bool EndAllStyles(); |
23324ae1 FM |
1088 | |
1089 | /** | |
7afd2b58 | 1090 | Begins using bold. |
23324ae1 | 1091 | */ |
42f2b395 | 1092 | bool BeginBold(); |
23324ae1 FM |
1093 | |
1094 | /** | |
7afd2b58 | 1095 | Ends using bold. |
23324ae1 | 1096 | */ |
42f2b395 | 1097 | bool EndBold(); |
23324ae1 FM |
1098 | |
1099 | /** | |
7afd2b58 | 1100 | Begins using italic. |
23324ae1 | 1101 | */ |
42f2b395 | 1102 | bool BeginItalic(); |
23324ae1 FM |
1103 | |
1104 | /** | |
7afd2b58 | 1105 | Ends using italic. |
23324ae1 | 1106 | */ |
42f2b395 | 1107 | bool EndItalic(); |
23324ae1 FM |
1108 | |
1109 | /** | |
7afd2b58 | 1110 | Begins using underlining. |
23324ae1 | 1111 | */ |
42f2b395 | 1112 | bool BeginUnderline(); |
23324ae1 FM |
1113 | |
1114 | /** | |
7afd2b58 | 1115 | End applying underlining. |
23324ae1 | 1116 | */ |
42f2b395 | 1117 | bool EndUnderline(); |
23324ae1 FM |
1118 | |
1119 | /** | |
7afd2b58 | 1120 | Begins using the given point size. |
23324ae1 | 1121 | */ |
42f2b395 | 1122 | bool BeginFontSize(int pointSize); |
23324ae1 FM |
1123 | |
1124 | /** | |
7afd2b58 | 1125 | Ends using a point size. |
23324ae1 | 1126 | */ |
42f2b395 | 1127 | bool EndFontSize(); |
23324ae1 FM |
1128 | |
1129 | /** | |
7afd2b58 | 1130 | Begins using this font. |
23324ae1 | 1131 | */ |
42f2b395 | 1132 | bool BeginFont(const wxFont& font); |
23324ae1 FM |
1133 | |
1134 | /** | |
7afd2b58 | 1135 | Ends using a font. |
23324ae1 | 1136 | */ |
42f2b395 | 1137 | bool EndFont(); |
23324ae1 FM |
1138 | |
1139 | /** | |
7afd2b58 | 1140 | Begins using this colour. |
23324ae1 | 1141 | */ |
42f2b395 | 1142 | bool BeginTextColour(const wxColour& colour); |
23324ae1 | 1143 | |
23324ae1 | 1144 | /** |
7afd2b58 JS |
1145 | Ends applying a text colour. |
1146 | */ | |
42f2b395 | 1147 | bool EndTextColour(); |
9e7ad1ca | 1148 | |
7afd2b58 JS |
1149 | /** |
1150 | Begins using alignment. | |
1151 | For alignment values, see wxTextAttr. | |
1152 | */ | |
42f2b395 | 1153 | bool BeginAlignment(wxTextAttrAlignment alignment); |
9e7ad1ca | 1154 | |
7afd2b58 JS |
1155 | /** |
1156 | Ends alignment. | |
1157 | */ | |
42f2b395 | 1158 | bool EndAlignment(); |
9e7ad1ca | 1159 | |
7afd2b58 JS |
1160 | /** |
1161 | Begins applying a left indent and subindent in tenths of a millimetre. | |
1162 | The subindent is an offset from the left edge of the paragraph, and is | |
1163 | used for all but the first line in a paragraph. A positive value will | |
1164 | cause the first line to appear to the left of the subsequent lines, and | |
1165 | a negative value will cause the first line to be indented to the right | |
1166 | of the subsequent lines. | |
1167 | ||
1168 | wxRichTextBuffer uses indentation to render a bulleted item. The | |
1169 | content of the paragraph, including the first line, starts at the | |
1170 | @a leftIndent plus the @a leftSubIndent. | |
1171 | ||
1172 | @param leftIndent | |
1173 | The distance between the margin and the bullet. | |
1174 | @param leftSubIndent | |
1175 | The distance between the left edge of the bullet and the left edge | |
1176 | of the actual paragraph. | |
23324ae1 | 1177 | */ |
42f2b395 | 1178 | bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0); |
23324ae1 FM |
1179 | |
1180 | /** | |
7afd2b58 | 1181 | Ends left indent. |
23324ae1 | 1182 | */ |
42f2b395 | 1183 | bool EndLeftIndent(); |
23324ae1 FM |
1184 | |
1185 | /** | |
7afd2b58 | 1186 | Begins a right indent, specified in tenths of a millimetre. |
23324ae1 | 1187 | */ |
42f2b395 | 1188 | bool BeginRightIndent(int rightIndent); |
23324ae1 FM |
1189 | |
1190 | /** | |
7afd2b58 | 1191 | Ends right indent. |
23324ae1 | 1192 | */ |
42f2b395 | 1193 | bool EndRightIndent(); |
23324ae1 FM |
1194 | |
1195 | /** | |
7afd2b58 JS |
1196 | Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing |
1197 | in tenths of a millimetre. | |
23324ae1 | 1198 | */ |
42f2b395 | 1199 | bool BeginParagraphSpacing(int before, int after); |
23324ae1 FM |
1200 | |
1201 | /** | |
7afd2b58 | 1202 | Ends paragraph spacing. |
23324ae1 | 1203 | */ |
42f2b395 | 1204 | bool EndParagraphSpacing(); |
23324ae1 FM |
1205 | |
1206 | /** | |
7afd2b58 JS |
1207 | Begins appling line spacing. @e spacing is a multiple, where 10 means |
1208 | single-spacing, 15 means 1.5 spacing, and 20 means double spacing. | |
1209 | ||
1210 | The ::wxTextAttrLineSpacing constants are defined for convenience. | |
23324ae1 | 1211 | */ |
42f2b395 | 1212 | bool BeginLineSpacing(int lineSpacing); |
23324ae1 FM |
1213 | |
1214 | /** | |
7afd2b58 | 1215 | Ends line spacing. |
23324ae1 | 1216 | */ |
42f2b395 | 1217 | bool EndLineSpacing(); |
23324ae1 FM |
1218 | |
1219 | /** | |
7afd2b58 JS |
1220 | Begins a numbered bullet. |
1221 | ||
1222 | This call will be needed for each item in the list, and the | |
1223 | application should take care of incrementing the numbering. | |
1224 | ||
1225 | @a bulletNumber is a number, usually starting with 1. | |
1226 | @a leftIndent and @a leftSubIndent are values in tenths of a millimetre. | |
1227 | @a bulletStyle is a bitlist of the ::wxTextAttrBulletStyle values. | |
1228 | ||
1229 | wxRichTextBuffer uses indentation to render a bulleted item. | |
1230 | The left indent is the distance between the margin and the bullet. | |
1231 | The content of the paragraph, including the first line, starts | |
1232 | at leftMargin + leftSubIndent. | |
1233 | So the distance between the left edge of the bullet and the | |
1234 | left of the actual paragraph is leftSubIndent. | |
23324ae1 | 1235 | */ |
42f2b395 RD |
1236 | bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD); |
1237 | ||
23324ae1 | 1238 | /** |
7afd2b58 | 1239 | Ends application of a numbered bullet. |
23324ae1 | 1240 | */ |
42f2b395 | 1241 | bool EndNumberedBullet(); |
23324ae1 FM |
1242 | |
1243 | /** | |
7afd2b58 JS |
1244 | Begins applying a symbol bullet, using a character from the current font. |
1245 | See BeginNumberedBullet() for an explanation of how indentation is used | |
1246 | to render the bulleted paragraph. | |
23324ae1 | 1247 | */ |
42f2b395 RD |
1248 | bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL); |
1249 | ||
23324ae1 | 1250 | /** |
7afd2b58 | 1251 | Ends applying a symbol bullet. |
23324ae1 | 1252 | */ |
42f2b395 | 1253 | bool EndSymbolBullet(); |
23324ae1 FM |
1254 | |
1255 | /** | |
7afd2b58 | 1256 | Begins applying a symbol bullet. |
23324ae1 | 1257 | */ |
42f2b395 | 1258 | bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD); |
23324ae1 FM |
1259 | |
1260 | /** | |
7afd2b58 | 1261 | Begins applying a standard bullet. |
23324ae1 | 1262 | */ |
42f2b395 | 1263 | bool EndStandardBullet(); |
23324ae1 FM |
1264 | |
1265 | /** | |
7afd2b58 | 1266 | Begins using the named character style. |
23324ae1 | 1267 | */ |
42f2b395 | 1268 | bool BeginCharacterStyle(const wxString& characterStyle); |
23324ae1 FM |
1269 | |
1270 | /** | |
7afd2b58 | 1271 | Ends application of a named character style. |
23324ae1 | 1272 | */ |
42f2b395 | 1273 | bool EndCharacterStyle(); |
23324ae1 FM |
1274 | |
1275 | /** | |
7afd2b58 | 1276 | Begins applying the named paragraph style. |
23324ae1 | 1277 | */ |
42f2b395 | 1278 | bool BeginParagraphStyle(const wxString& paragraphStyle); |
23324ae1 FM |
1279 | |
1280 | /** | |
7afd2b58 | 1281 | Ends application of a named paragraph style. |
23324ae1 | 1282 | */ |
42f2b395 | 1283 | bool EndParagraphStyle(); |
23324ae1 FM |
1284 | |
1285 | /** | |
7afd2b58 JS |
1286 | Begins using a specified list style. |
1287 | Optionally, you can also pass a level and a number. | |
23324ae1 | 1288 | */ |
42f2b395 | 1289 | bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1); |
23324ae1 FM |
1290 | |
1291 | /** | |
7afd2b58 | 1292 | Ends using a specified list style. |
23324ae1 | 1293 | */ |
42f2b395 | 1294 | bool EndListStyle(); |
23324ae1 | 1295 | |
826c4761 | 1296 | /** |
7afd2b58 | 1297 | Begins applying wxTEXT_ATTR_URL to the content. |
826c4761 | 1298 | |
7afd2b58 JS |
1299 | Pass a URL and optionally, a character style to apply, since it is common |
1300 | to mark a URL with a familiar style such as blue text with underlining. | |
826c4761 | 1301 | */ |
42f2b395 | 1302 | bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString); |
826c4761 | 1303 | |
23324ae1 | 1304 | /** |
7afd2b58 | 1305 | Ends applying a URL. |
23324ae1 | 1306 | */ |
42f2b395 | 1307 | bool EndURL(); |
23324ae1 FM |
1308 | |
1309 | /** | |
7afd2b58 | 1310 | Sets the default style to the style under the cursor. |
23324ae1 | 1311 | */ |
7afd2b58 | 1312 | bool SetDefaultStyleToCursorStyle(); |
23324ae1 FM |
1313 | |
1314 | /** | |
7afd2b58 | 1315 | Cancels any selection. |
23324ae1 | 1316 | */ |
7afd2b58 | 1317 | virtual void SelectNone(); |
23324ae1 | 1318 | |
23324ae1 | 1319 | /** |
7afd2b58 | 1320 | Selects the word at the given character position. |
23324ae1 | 1321 | */ |
7afd2b58 | 1322 | virtual bool SelectWord(long position); |
23324ae1 FM |
1323 | |
1324 | /** | |
7afd2b58 JS |
1325 | Returns the selection range in character positions. -1, -1 means no selection. |
1326 | ||
1327 | The range is in API convention, i.e. a single character selection is denoted | |
1328 | by (n, n+1) | |
23324ae1 | 1329 | */ |
7afd2b58 | 1330 | wxRichTextRange GetSelectionRange() const; |
23324ae1 FM |
1331 | |
1332 | /** | |
7afd2b58 JS |
1333 | Sets the selection to the given range. |
1334 | The end point of range is specified as the last character position of the span | |
1335 | of text, plus one. | |
1336 | ||
1337 | So, for example, to set the selection for a character at position 5, use the | |
1338 | range (5,6). | |
23324ae1 | 1339 | */ |
7afd2b58 | 1340 | void SetSelectionRange(const wxRichTextRange& range); |
23324ae1 FM |
1341 | |
1342 | /** | |
7afd2b58 JS |
1343 | Returns the selection range in character positions. -2, -2 means no selection |
1344 | -1, -1 means select everything. | |
1345 | The range is in internal format, i.e. a single character selection is denoted | |
1346 | by (n, n) | |
23324ae1 | 1347 | */ |
42f2b395 | 1348 | wxRichTextRange GetInternalSelectionRange() const; |
23324ae1 FM |
1349 | |
1350 | /** | |
7afd2b58 JS |
1351 | Sets the selection range in character positions. -2, -2 means no selection |
1352 | -1, -1 means select everything. | |
1353 | The range is in internal format, i.e. a single character selection is denoted | |
1354 | by (n, n) | |
23324ae1 | 1355 | */ |
42f2b395 | 1356 | void SetInternalSelectionRange(const wxRichTextRange& range); |
23324ae1 FM |
1357 | |
1358 | /** | |
7afd2b58 | 1359 | Adds a new paragraph of text to the end of the buffer. |
23324ae1 | 1360 | */ |
7afd2b58 | 1361 | virtual wxRichTextRange AddParagraph(const wxString& text); |
23324ae1 FM |
1362 | |
1363 | /** | |
7afd2b58 | 1364 | Adds an image to the control's buffer. |
23324ae1 | 1365 | */ |
7afd2b58 | 1366 | virtual wxRichTextRange AddImage(const wxImage& image); |
23324ae1 FM |
1367 | |
1368 | /** | |
7afd2b58 JS |
1369 | Lays out the buffer, which must be done before certain operations, such as |
1370 | setting the caret position. | |
1371 | This function should not normally be required by the application. | |
23324ae1 | 1372 | */ |
7afd2b58 | 1373 | virtual bool LayoutContent(bool onlyVisibleRect = false); |
23324ae1 FM |
1374 | |
1375 | /** | |
7afd2b58 | 1376 | Move the caret to the given character position. |
9e7ad1ca | 1377 | |
7afd2b58 JS |
1378 | Please note that this does not update the current editing style |
1379 | from the new position; to do that, call wxRichTextCtrl::SetInsertionPoint instead. | |
23324ae1 | 1380 | */ |
7afd2b58 | 1381 | virtual bool MoveCaret(long pos, bool showAtLineStart = false, wxRichTextParagraphLayoutBox* container = NULL); |
23324ae1 FM |
1382 | |
1383 | /** | |
7afd2b58 | 1384 | Moves right. |
23324ae1 | 1385 | */ |
7afd2b58 | 1386 | virtual bool MoveRight(int noPositions = 1, int flags = 0); |
23324ae1 FM |
1387 | |
1388 | /** | |
7afd2b58 JS |
1389 | Moves left. |
1390 | */ | |
1391 | virtual bool MoveLeft(int noPositions = 1, int flags = 0); | |
346c54a4 | 1392 | |
7afd2b58 JS |
1393 | /** |
1394 | Moves to the start of the paragraph. | |
23324ae1 | 1395 | */ |
7afd2b58 | 1396 | virtual bool MoveUp(int noLines = 1, int flags = 0); |
23324ae1 FM |
1397 | |
1398 | /** | |
7afd2b58 | 1399 | Moves the caret down. |
23324ae1 | 1400 | */ |
7afd2b58 | 1401 | virtual bool MoveDown(int noLines = 1, int flags = 0); |
23324ae1 FM |
1402 | |
1403 | /** | |
7afd2b58 | 1404 | Moves to the end of the line. |
23324ae1 | 1405 | */ |
7afd2b58 | 1406 | virtual bool MoveToLineEnd(int flags = 0); |
23324ae1 FM |
1407 | |
1408 | /** | |
7afd2b58 | 1409 | Moves to the start of the line. |
23324ae1 | 1410 | */ |
7afd2b58 | 1411 | virtual bool MoveToLineStart(int flags = 0); |
23324ae1 FM |
1412 | |
1413 | /** | |
7afd2b58 | 1414 | Moves to the end of the paragraph. |
23324ae1 | 1415 | */ |
7afd2b58 | 1416 | virtual bool MoveToParagraphEnd(int flags = 0); |
23324ae1 FM |
1417 | |
1418 | /** | |
7afd2b58 | 1419 | Moves to the start of the paragraph. |
23324ae1 | 1420 | */ |
7afd2b58 | 1421 | virtual bool MoveToParagraphStart(int flags = 0); |
23324ae1 FM |
1422 | |
1423 | /** | |
7afd2b58 | 1424 | Moves to the start of the buffer. |
23324ae1 | 1425 | */ |
7afd2b58 | 1426 | virtual bool MoveHome(int flags = 0); |
23324ae1 FM |
1427 | |
1428 | /** | |
7afd2b58 JS |
1429 | Moves to the end of the buffer. |
1430 | */ | |
1431 | virtual bool MoveEnd(int flags = 0); | |
9e7ad1ca | 1432 | |
7afd2b58 JS |
1433 | /** |
1434 | Moves one or more pages up. | |
23324ae1 | 1435 | */ |
7afd2b58 | 1436 | virtual bool PageUp(int noPages = 1, int flags = 0); |
23324ae1 FM |
1437 | |
1438 | /** | |
7afd2b58 | 1439 | Moves one or more pages down. |
23324ae1 | 1440 | */ |
7afd2b58 | 1441 | virtual bool PageDown(int noPages = 1, int flags = 0); |
23324ae1 FM |
1442 | |
1443 | /** | |
7afd2b58 | 1444 | Moves a number of words to the left. |
23324ae1 | 1445 | */ |
7afd2b58 | 1446 | virtual bool WordLeft(int noPages = 1, int flags = 0); |
23324ae1 | 1447 | |
23324ae1 | 1448 | /** |
7afd2b58 JS |
1449 | Move a nuber of words to the right. |
1450 | */ | |
1451 | virtual bool WordRight(int noPages = 1, int flags = 0); | |
9e7ad1ca | 1452 | |
7afd2b58 JS |
1453 | //@{ |
1454 | /** | |
1455 | Returns the buffer associated with the control. | |
23324ae1 | 1456 | */ |
42f2b395 RD |
1457 | wxRichTextBuffer& GetBuffer(); |
1458 | const wxRichTextBuffer& GetBuffer() const; | |
23324ae1 FM |
1459 | //@} |
1460 | ||
1461 | /** | |
7afd2b58 JS |
1462 | Starts batching undo history for commands. |
1463 | */ | |
42f2b395 | 1464 | virtual bool BeginBatchUndo(const wxString& cmdName); |
9e7ad1ca | 1465 | |
7afd2b58 JS |
1466 | /** |
1467 | Ends batching undo command history. | |
23324ae1 | 1468 | */ |
42f2b395 | 1469 | virtual bool EndBatchUndo(); |
23324ae1 FM |
1470 | |
1471 | /** | |
7afd2b58 JS |
1472 | Returns @true if undo commands are being batched. |
1473 | */ | |
42f2b395 | 1474 | virtual bool BatchingUndo() const; |
9e7ad1ca | 1475 | |
7afd2b58 JS |
1476 | /** |
1477 | Starts suppressing undo history for commands. | |
23324ae1 | 1478 | */ |
42f2b395 | 1479 | virtual bool BeginSuppressUndo(); |
23324ae1 | 1480 | |
23324ae1 | 1481 | /** |
7afd2b58 JS |
1482 | Ends suppressing undo command history. |
1483 | */ | |
42f2b395 | 1484 | virtual bool EndSuppressUndo(); |
9e7ad1ca | 1485 | |
7afd2b58 JS |
1486 | /** |
1487 | Returns @true if undo history suppression is on. | |
23324ae1 | 1488 | */ |
42f2b395 | 1489 | virtual bool SuppressingUndo() const; |
23324ae1 | 1490 | |
23324ae1 | 1491 | /** |
7afd2b58 JS |
1492 | Test if this whole range has character attributes of the specified kind. |
1493 | If any of the attributes are different within the range, the test fails. | |
9e7ad1ca | 1494 | |
7afd2b58 JS |
1495 | You can use this to implement, for example, bold button updating. |
1496 | @a style must have flags indicating which attributes are of interest. | |
1497 | */ | |
42f2b395 RD |
1498 | virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const; |
1499 | ||
9e7ad1ca | 1500 | |
7afd2b58 JS |
1501 | /** |
1502 | Test if this whole range has paragraph attributes of the specified kind. | |
1503 | If any of the attributes are different within the range, the test fails. | |
1504 | You can use this to implement, for example, centering button updating. | |
1505 | @a style must have flags indicating which attributes are of interest. | |
1506 | */ | |
42f2b395 RD |
1507 | virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const; |
1508 | ||
7afd2b58 JS |
1509 | |
1510 | /** | |
4f51b983 | 1511 | Returns @true if all of the selection, or the content at the caret position, is bold. |
7afd2b58 JS |
1512 | */ |
1513 | virtual bool IsSelectionBold(); | |
1514 | ||
1515 | /** | |
4f51b983 | 1516 | Returns @true if all of the selection, or the content at the caret position, is italic. |
7afd2b58 JS |
1517 | */ |
1518 | virtual bool IsSelectionItalics(); | |
1519 | ||
1520 | /** | |
4f51b983 | 1521 | Returns @true if all of the selection, or the content at the caret position, is underlined. |
7afd2b58 JS |
1522 | */ |
1523 | virtual bool IsSelectionUnderlined(); | |
1524 | ||
75936ec6 | 1525 | /** |
4f51b983 | 1526 | Returns @true if all of the selection, or the content at the current caret position, has the supplied wxTextAttrEffects flag(s). |
75936ec6 JS |
1527 | */ |
1528 | virtual bool DoesSelectionHaveTextEffectFlag(int flag); | |
1529 | ||
7afd2b58 JS |
1530 | /** |
1531 | Returns @true if all of the selection is aligned according to the specified flag. | |
1532 | */ | |
1533 | virtual bool IsSelectionAligned(wxTextAttrAlignment alignment); | |
1534 | ||
1535 | /** | |
4f51b983 | 1536 | Apples bold to the selection or the default style (undoable). |
7afd2b58 JS |
1537 | */ |
1538 | virtual bool ApplyBoldToSelection(); | |
1539 | ||
1540 | /** | |
4f51b983 | 1541 | Applies italic to the selection or the default style (undoable). |
7afd2b58 JS |
1542 | */ |
1543 | virtual bool ApplyItalicToSelection(); | |
1544 | ||
1545 | /** | |
4f51b983 | 1546 | Applies underline to the selection or the default style (undoable). |
7afd2b58 JS |
1547 | */ |
1548 | virtual bool ApplyUnderlineToSelection(); | |
1549 | ||
75936ec6 JS |
1550 | /** |
1551 | Applies one or more wxTextAttrEffects flags to the selection (undoable). | |
4f51b983 | 1552 | If there is no selection, it is applied to the default style. |
75936ec6 JS |
1553 | */ |
1554 | virtual bool ApplyTextEffectToSelection(int flags); | |
1555 | ||
7afd2b58 | 1556 | /** |
4f51b983 | 1557 | Applies the given alignment to the selection or the default style (undoable). |
7afd2b58 JS |
1558 | For alignment values, see wxTextAttr. |
1559 | */ | |
1560 | virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment); | |
1561 | ||
1562 | /** | |
1563 | Applies the style sheet to the buffer, matching paragraph styles in the sheet | |
1564 | against named styles in the buffer. | |
1565 | ||
1566 | This might be useful if the styles have changed. | |
1567 | If @a sheet is @NULL, the sheet set with SetStyleSheet() is used. | |
1568 | Currently this applies paragraph styles only. | |
23324ae1 | 1569 | */ |
7afd2b58 | 1570 | virtual bool ApplyStyle(wxRichTextStyleDefinition* def); |
23324ae1 FM |
1571 | |
1572 | /** | |
9e7ad1ca FM |
1573 | Sets the style sheet associated with the control. |
1574 | A style sheet allows named character and paragraph styles to be applied. | |
23324ae1 | 1575 | */ |
42f2b395 | 1576 | void SetStyleSheet(wxRichTextStyleSheet* styleSheet); |
23324ae1 FM |
1577 | |
1578 | /** | |
7afd2b58 JS |
1579 | Returns the style sheet associated with the control, if any. |
1580 | A style sheet allows named character and paragraph styles to be applied. | |
23324ae1 | 1581 | */ |
42f2b395 | 1582 | wxRichTextStyleSheet* GetStyleSheet() const; |
23324ae1 FM |
1583 | |
1584 | /** | |
7afd2b58 | 1585 | Push the style sheet to top of stack. |
23324ae1 | 1586 | */ |
42f2b395 | 1587 | bool PushStyleSheet(wxRichTextStyleSheet* styleSheet); |
23324ae1 FM |
1588 | |
1589 | /** | |
7afd2b58 | 1590 | Pops the style sheet from top of stack. |
23324ae1 | 1591 | */ |
42f2b395 | 1592 | wxRichTextStyleSheet* PopStyleSheet(); |
23324ae1 FM |
1593 | |
1594 | /** | |
7afd2b58 | 1595 | Applies the style sheet to the buffer, for example if the styles have changed. |
23324ae1 | 1596 | */ |
7afd2b58 JS |
1597 | bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL); |
1598 | ||
9b794421 JS |
1599 | /** |
1600 | Shows the given context menu, optionally adding appropriate property-editing commands for the current position in the object hierarchy. | |
1601 | */ | |
1602 | virtual bool ShowContextMenu(wxMenu* menu, const wxPoint& pt, bool addPropertyCommands); | |
1603 | ||
1604 | /** | |
1605 | Prepares the context menu, optionally adding appropriate property-editing commands. | |
1606 | Returns the number of property commands added. | |
1607 | */ | |
1608 | virtual int PrepareContextMenu(wxMenu* menu, const wxPoint& pt, bool addPropertyCommands); | |
1609 | ||
303f0be7 JS |
1610 | /** |
1611 | Returns @true if we can edit the object's properties via a GUI. | |
1612 | */ | |
590a0f8b | 1613 | virtual bool CanEditProperties(wxRichTextObject* obj) const; |
303f0be7 JS |
1614 | |
1615 | /** | |
1616 | Edits the object's properties via a GUI. | |
1617 | */ | |
590a0f8b JS |
1618 | virtual bool EditProperties(wxRichTextObject* obj, wxWindow* parent); |
1619 | ||
1620 | /** | |
1621 | Gets the object's properties menu label. | |
1622 | */ | |
1623 | virtual wxString GetPropertiesMenuLabel(wxRichTextObject* obj); | |
303f0be7 | 1624 | |
cc2aecde JS |
1625 | /** |
1626 | Prepares the content just before insertion (or after buffer reset). Called by the same function in wxRichTextBuffer. | |
1627 | Currently is only called if undo mode is on. | |
1628 | */ | |
42f2b395 | 1629 | virtual void PrepareContent(wxRichTextParagraphLayoutBox& container); |
cc2aecde JS |
1630 | |
1631 | /** | |
1632 | Can we delete this range? | |
1633 | Sends an event to the control. | |
1634 | */ | |
1635 | virtual bool CanDeleteRange(wxRichTextParagraphLayoutBox& container, const wxRichTextRange& range) const; | |
1636 | ||
1637 | /** | |
1638 | Can we insert content at this position? | |
1639 | Sends an event to the control. | |
1640 | */ | |
1641 | virtual bool CanInsertContent(wxRichTextParagraphLayoutBox& container, long pos) const; | |
1642 | ||
12f5219f JS |
1643 | /** |
1644 | Enable or disable the vertical scrollbar. | |
1645 | */ | |
1646 | virtual void EnableVerticalScrollbar(bool enable); | |
1647 | ||
1648 | /** | |
1649 | Returns @true if the vertical scrollbar is enabled. | |
1650 | */ | |
1651 | virtual bool GetVerticalScrollbarEnabled() const; | |
1652 | ||
32423dd8 JS |
1653 | /** |
1654 | Sets the scale factor for displaying fonts, for example for more comfortable | |
1655 | editing. | |
1656 | */ | |
1657 | void SetFontScale(double fontScale, bool refresh = false); | |
1658 | ||
1659 | /** | |
1660 | Returns the scale factor for displaying fonts, for example for more comfortable | |
1661 | editing. | |
1662 | */ | |
1663 | double GetFontScale() const { return GetBuffer().GetFontScale(); } | |
1664 | ||
1665 | /** | |
1666 | Sets the scale factor for displaying certain dimensions such as indentation and | |
1667 | inter-paragraph spacing. This can be useful when editing in a small control | |
1668 | where you still want legible text, but a minimum of wasted white space. | |
1669 | */ | |
1670 | void SetDimensionScale(double dimScale, bool refresh = false); | |
1671 | ||
1672 | /** | |
1673 | Returns the scale factor for displaying certain dimensions such as indentation | |
1674 | and inter-paragraph spacing. | |
1675 | */ | |
1676 | double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); } | |
1677 | ||
4ba36292 JS |
1678 | /** |
1679 | Sets an overall scale factor for displaying and editing the content. | |
1680 | */ | |
1681 | void SetScale(double scale, bool refresh = false); | |
1682 | ||
1683 | /** | |
1684 | Returns an overall scale factor for displaying and editing the content. | |
1685 | */ | |
42f2b395 | 1686 | double GetScale() const; |
4ba36292 JS |
1687 | |
1688 | /** | |
1689 | Returns an unscaled point. | |
1690 | */ | |
1691 | wxPoint GetUnscaledPoint(const wxPoint& pt) const; | |
1692 | ||
1693 | /** | |
1694 | Returns a scaled point. | |
1695 | */ | |
1696 | wxPoint GetScaledPoint(const wxPoint& pt) const; | |
1697 | ||
1698 | /** | |
1699 | Returns an unscaled size. | |
1700 | */ | |
1701 | wxSize GetUnscaledSize(const wxSize& sz) const; | |
1702 | ||
1703 | /** | |
1704 | Returns a scaled size. | |
1705 | */ | |
1706 | wxSize GetScaledSize(const wxSize& sz) const; | |
1707 | ||
1708 | /** | |
1709 | Returns an unscaled rectangle. | |
1710 | */ | |
1711 | wxRect GetUnscaledRect(const wxRect& rect) const; | |
1712 | ||
1713 | /** | |
1714 | Returns a scaled rectangle. | |
1715 | */ | |
1716 | wxRect GetScaledRect(const wxRect& rect) const; | |
1717 | ||
f7667b84 JS |
1718 | /** |
1719 | Returns @true if this control can use virtual attributes and virtual text. | |
1720 | The default is @false. | |
1721 | */ | |
1722 | bool GetVirtualAttributesEnabled() const; | |
1723 | ||
1724 | /** | |
1725 | Pass @true to let the control use virtual attributes. | |
1726 | The default is @false. | |
1727 | */ | |
1728 | void EnableVirtualAttributes(bool b); | |
1729 | ||
7afd2b58 | 1730 | // Command handlers |
23324ae1 FM |
1731 | |
1732 | /** | |
7afd2b58 | 1733 | Sends the event to the control. |
23324ae1 | 1734 | */ |
7afd2b58 | 1735 | void Command(wxCommandEvent& event); |
23324ae1 FM |
1736 | |
1737 | /** | |
7afd2b58 | 1738 | Loads the first dropped file. |
23324ae1 | 1739 | */ |
7afd2b58 JS |
1740 | void OnDropFiles(wxDropFilesEvent& event); |
1741 | ||
1742 | void OnCaptureLost(wxMouseCaptureLostEvent& event); | |
1743 | void OnSysColourChanged(wxSysColourChangedEvent& event); | |
23324ae1 FM |
1744 | |
1745 | /** | |
7afd2b58 | 1746 | Standard handler for the wxID_CUT command. |
23324ae1 | 1747 | */ |
7afd2b58 | 1748 | void OnCut(wxCommandEvent& event); |
23324ae1 FM |
1749 | |
1750 | /** | |
7afd2b58 | 1751 | Standard handler for the wxID_COPY command. |
23324ae1 | 1752 | */ |
7afd2b58 | 1753 | void OnCopy(wxCommandEvent& event); |
23324ae1 | 1754 | |
23324ae1 | 1755 | /** |
7afd2b58 | 1756 | Standard handler for the wxID_PASTE command. |
23324ae1 | 1757 | */ |
7afd2b58 | 1758 | void OnPaste(wxCommandEvent& event); |
9e7ad1ca FM |
1759 | |
1760 | /** | |
7afd2b58 | 1761 | Standard handler for the wxID_UNDO command. |
9e7ad1ca | 1762 | */ |
7afd2b58 | 1763 | void OnUndo(wxCommandEvent& event); |
9e7ad1ca | 1764 | |
9e7ad1ca | 1765 | /** |
7afd2b58 | 1766 | Standard handler for the wxID_REDO command. |
9e7ad1ca | 1767 | */ |
7afd2b58 | 1768 | void OnRedo(wxCommandEvent& event); |
23324ae1 FM |
1769 | |
1770 | /** | |
7afd2b58 | 1771 | Standard handler for the wxID_SELECTALL command. |
23324ae1 | 1772 | */ |
7afd2b58 | 1773 | void OnSelectAll(wxCommandEvent& event); |
23324ae1 FM |
1774 | |
1775 | /** | |
7afd2b58 | 1776 | Standard handler for property commands. |
23324ae1 | 1777 | */ |
7afd2b58 | 1778 | void OnProperties(wxCommandEvent& event); |
5e6e278d | 1779 | |
7afd2b58 JS |
1780 | /** |
1781 | Standard handler for the wxID_CLEAR command. | |
1782 | */ | |
1783 | void OnClear(wxCommandEvent& event); | |
5e6e278d FM |
1784 | |
1785 | /** | |
7afd2b58 JS |
1786 | Standard update handler for the wxID_CUT command. |
1787 | */ | |
1788 | void OnUpdateCut(wxUpdateUIEvent& event); | |
1789 | ||
1790 | /** | |
1791 | Standard update handler for the wxID_COPY command. | |
1792 | */ | |
1793 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
1794 | ||
1795 | /** | |
1796 | Standard update handler for the wxID_PASTE command. | |
1797 | */ | |
1798 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
1799 | ||
1800 | /** | |
1801 | Standard update handler for the wxID_UNDO command. | |
1802 | */ | |
1803 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
1804 | ||
1805 | /** | |
1806 | Standard update handler for the wxID_REDO command. | |
1807 | */ | |
1808 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
1809 | ||
1810 | /** | |
1811 | Standard update handler for the wxID_SELECTALL command. | |
1812 | */ | |
1813 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
1814 | ||
1815 | /** | |
1816 | Standard update handler for property commands. | |
1817 | */ | |
1818 | ||
1819 | void OnUpdateProperties(wxUpdateUIEvent& event); | |
1820 | ||
1821 | /** | |
1822 | Standard update handler for the wxID_CLEAR command. | |
1823 | */ | |
1824 | void OnUpdateClear(wxUpdateUIEvent& event); | |
1825 | ||
1826 | /** | |
1827 | Shows a standard context menu with undo, redo, cut, copy, paste, clear, and | |
1828 | select all commands. | |
1829 | */ | |
1830 | void OnContextMenu(wxContextMenuEvent& event); | |
1831 | ||
1832 | // Event handlers | |
1833 | ||
1834 | // Painting | |
1835 | void OnPaint(wxPaintEvent& event); | |
1836 | void OnEraseBackground(wxEraseEvent& event); | |
1837 | ||
1838 | // Left-click | |
1839 | void OnLeftClick(wxMouseEvent& event); | |
1840 | ||
1841 | // Left-up | |
1842 | void OnLeftUp(wxMouseEvent& event); | |
1843 | ||
1844 | // Motion | |
1845 | void OnMoveMouse(wxMouseEvent& event); | |
1846 | ||
1847 | // Left-double-click | |
1848 | void OnLeftDClick(wxMouseEvent& event); | |
1849 | ||
1850 | // Middle-click | |
1851 | void OnMiddleClick(wxMouseEvent& event); | |
1852 | ||
1853 | // Right-click | |
1854 | void OnRightClick(wxMouseEvent& event); | |
1855 | ||
1856 | // Key press | |
1857 | void OnChar(wxKeyEvent& event); | |
1858 | ||
1859 | // Sizing | |
1860 | void OnSize(wxSizeEvent& event); | |
1861 | ||
1862 | // Setting/losing focus | |
1863 | void OnSetFocus(wxFocusEvent& event); | |
1864 | void OnKillFocus(wxFocusEvent& event); | |
1865 | ||
1866 | // Idle-time processing | |
1867 | void OnIdle(wxIdleEvent& event); | |
1868 | ||
1869 | // Scrolling | |
1870 | void OnScroll(wxScrollWinEvent& event); | |
1871 | ||
1872 | /** | |
1873 | Sets the font, and also the basic and default attributes | |
1874 | (see wxRichTextCtrl::SetDefaultStyle). | |
5e6e278d | 1875 | */ |
7afd2b58 JS |
1876 | virtual bool SetFont(const wxFont& font); |
1877 | ||
1878 | /** | |
1879 | A helper function setting up scrollbars, for example after a resize. | |
1880 | */ | |
1881 | virtual void SetupScrollbars(bool atTop = false); | |
1882 | ||
1883 | /** | |
1884 | Helper function implementing keyboard navigation. | |
1885 | */ | |
1886 | virtual bool KeyboardNavigate(int keyCode, int flags); | |
5e6e278d FM |
1887 | |
1888 | /** | |
7afd2b58 | 1889 | Paints the background. |
5e6e278d | 1890 | */ |
7afd2b58 JS |
1891 | virtual void PaintBackground(wxDC& dc); |
1892 | ||
1893 | /** | |
37467663 | 1894 | Other user defined painting after everything else (i.e.\ all text) is painted. |
7afd2b58 JS |
1895 | |
1896 | @since 2.9.1 | |
1897 | */ | |
1898 | virtual void PaintAboveContent(wxDC& WXUNUSED(dc)) {} | |
1899 | ||
1900 | #if wxRICHTEXT_BUFFERED_PAINTING | |
1901 | /** | |
1902 | Recreates the buffer bitmap if necessary. | |
1903 | */ | |
1904 | virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize); | |
1905 | #endif | |
1906 | ||
1907 | // Write text | |
1908 | virtual void DoWriteText(const wxString& value, int flags = 0); | |
1909 | ||
1910 | // Should we inherit colours? | |
42f2b395 | 1911 | virtual bool ShouldInheritColours() const; |
7afd2b58 JS |
1912 | |
1913 | /** | |
1914 | Internal function to position the visible caret according to the current caret | |
1915 | position. | |
1916 | */ | |
1917 | virtual void PositionCaret(wxRichTextParagraphLayoutBox* container = NULL); | |
1918 | ||
1919 | /** | |
1920 | Helper function for extending the selection, returning @true if the selection | |
1921 | was changed. Selections are in caret positions. | |
1922 | */ | |
1923 | virtual bool ExtendSelection(long oldPosition, long newPosition, int flags); | |
1924 | ||
1925 | /** | |
1926 | Scrolls @a position into view. This function takes a caret position. | |
1927 | */ | |
1928 | virtual bool ScrollIntoView(long position, int keyCode); | |
1929 | ||
1930 | /** | |
1931 | Refreshes the area affected by a selection change. | |
1932 | */ | |
1933 | bool RefreshForSelectionChange(const wxRichTextSelection& oldSelection, const wxRichTextSelection& newSelection); | |
1934 | ||
1935 | /** | |
1936 | Sets the caret position. | |
1937 | ||
1938 | The caret position is the character position just before the caret. | |
1939 | A value of -1 means the caret is at the start of the buffer. | |
1940 | Please note that this does not update the current editing style | |
1941 | from the new position or cause the actual caret to be refreshed; to do that, | |
1942 | call wxRichTextCtrl::SetInsertionPoint instead. | |
1943 | */ | |
1944 | void SetCaretPosition(long position, bool showAtLineStart = false) ; | |
1945 | ||
1946 | /** | |
1947 | Returns the current caret position. | |
1948 | */ | |
42f2b395 | 1949 | long GetCaretPosition() const; |
7afd2b58 JS |
1950 | |
1951 | /** | |
1952 | The adjusted caret position is the character position adjusted to take | |
1953 | into account whether we're at the start of a paragraph, in which case | |
1954 | style information should be taken from the next position, not current one. | |
1955 | */ | |
1956 | long GetAdjustedCaretPosition(long caretPos) const; | |
1957 | ||
1958 | /** | |
1959 | Move the caret one visual step forward: this may mean setting a flag | |
1960 | and keeping the same position if we're going from the end of one line | |
1961 | to the start of the next, which may be the exact same caret position. | |
1962 | */ | |
1963 | void MoveCaretForward(long oldPosition) ; | |
1964 | ||
1965 | /** | |
1966 | Move the caret one visual step forward: this may mean setting a flag | |
1967 | and keeping the same position if we're going from the end of one line | |
1968 | to the start of the next, which may be the exact same caret position. | |
1969 | */ | |
1970 | void MoveCaretBack(long oldPosition) ; | |
1971 | ||
1972 | /** | |
1973 | Returns the caret height and position for the given character position. | |
1974 | If container is null, the current focus object will be used. | |
1975 | ||
1976 | @beginWxPerlOnly | |
1977 | In wxPerl this method is implemented as | |
1978 | GetCaretPositionForIndex(@a position) returning a | |
1979 | 2-element list (ok, rect). | |
1980 | @endWxPerlOnly | |
1981 | */ | |
1982 | bool GetCaretPositionForIndex(long position, wxRect& rect, wxRichTextParagraphLayoutBox* container = NULL); | |
1983 | ||
1984 | /** | |
1985 | Internal helper function returning the line for the visible caret position. | |
1986 | If the caret is shown at the very end of the line, it means the next character | |
1987 | is actually on the following line. | |
1988 | So this function gets the line we're expecting to find if this is the case. | |
1989 | */ | |
1990 | wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const; | |
1991 | ||
1992 | /** | |
1993 | Gets the command processor associated with the control's buffer. | |
1994 | */ | |
42f2b395 | 1995 | wxCommandProcessor* GetCommandProcessor() const; |
7afd2b58 JS |
1996 | |
1997 | /** | |
1998 | Deletes content if there is a selection, e.g. when pressing a key. | |
1999 | Returns the new caret position in @e newPos, or leaves it if there | |
2000 | was no action. This is undoable. | |
2001 | ||
2002 | @beginWxPerlOnly | |
2003 | In wxPerl this method takes no arguments and returns a 2-element | |
2004 | list (ok, newPos). | |
2005 | @endWxPerlOnly | |
2006 | */ | |
2007 | bool DeleteSelectedContent(long* newPos= NULL); | |
2008 | ||
2009 | /** | |
2010 | Transforms logical (unscrolled) position to physical window position. | |
2011 | */ | |
2012 | wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const; | |
2013 | ||
2014 | /** | |
2015 | Transforms physical window position to logical (unscrolled) position. | |
2016 | */ | |
2017 | wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const; | |
2018 | ||
2019 | /** | |
2020 | Helper function for finding the caret position for the next word. | |
2021 | Direction is 1 (forward) or -1 (backwards). | |
2022 | */ | |
2023 | virtual long FindNextWordPosition(int direction = 1) const; | |
2024 | ||
2025 | /** | |
2026 | Returns @true if the given position is visible on the screen. | |
2027 | */ | |
2028 | bool IsPositionVisible(long pos) const; | |
2029 | ||
2030 | /** | |
2031 | Returns the first visible position in the current view. | |
2032 | */ | |
2033 | long GetFirstVisiblePosition() const; | |
2034 | ||
2035 | /** | |
2036 | Returns the caret position since the default formatting was changed. As | |
2037 | soon as this position changes, we no longer reflect the default style | |
2038 | in the UI. A value of -2 means that we should only reflect the style of the | |
2039 | content under the caret. | |
2040 | */ | |
42f2b395 | 2041 | long GetCaretPositionForDefaultStyle() const; |
7afd2b58 JS |
2042 | |
2043 | /** | |
2044 | Set the caret position for the default style that the user is selecting. | |
2045 | */ | |
42f2b395 | 2046 | void SetCaretPositionForDefaultStyle(long pos); |
7afd2b58 JS |
2047 | |
2048 | /** | |
2049 | Returns @true if the user has recently set the default style without moving | |
2050 | the caret, and therefore the UI needs to reflect the default style and not | |
2051 | the style at the caret. | |
2052 | ||
2053 | Below is an example of code that uses this function to determine whether the UI | |
2054 | should show that the current style is bold. | |
2055 | ||
2056 | @see SetAndShowDefaultStyle(). | |
2057 | */ | |
42f2b395 | 2058 | bool IsDefaultStyleShowing() const; |
7afd2b58 JS |
2059 | |
2060 | /** | |
2061 | Sets @a attr as the default style and tells the control that the UI should | |
2062 | reflect this attribute until the user moves the caret. | |
2063 | ||
2064 | @see IsDefaultStyleShowing(). | |
2065 | */ | |
42f2b395 | 2066 | void SetAndShowDefaultStyle(const wxRichTextAttr& attr); |
7afd2b58 JS |
2067 | |
2068 | /** | |
2069 | Returns the first visible point in the window. | |
2070 | */ | |
2071 | wxPoint GetFirstVisiblePoint() const; | |
2072 | ||
7afd2b58 JS |
2073 | /** |
2074 | Returns the content of the entire control as a string. | |
2075 | */ | |
2076 | virtual wxString GetValue() const; | |
2077 | ||
2078 | /** | |
2079 | Replaces existing content with the given text. | |
2080 | */ | |
2081 | virtual void SetValue(const wxString& value); | |
2082 | ||
7afd2b58 JS |
2083 | |
2084 | // Implementation | |
2085 | ||
4ce3ebd3 JS |
2086 | /** |
2087 | Processes the back key. | |
2088 | */ | |
2089 | virtual bool ProcessBackKey(wxKeyEvent& event, int flags); | |
2090 | ||
2091 | /** | |
2092 | Given a character position at which there is a list style, find the range | |
2093 | encompassing the same list style by looking backwards and forwards. | |
2094 | */ | |
2095 | virtual wxRichTextRange FindRangeForList(long pos, bool& isNumberedList); | |
2096 | ||
7afd2b58 JS |
2097 | /** |
2098 | Sets up the caret for the given position and container, after a mouse click. | |
2099 | */ | |
2100 | bool SetCaretPositionAfterClick(wxRichTextParagraphLayoutBox* container, long position, int hitTestFlags, bool extendSelection = false); | |
2101 | ||
2102 | /** | |
2103 | Find the caret position for the combination of hit-test flags and character position. | |
2104 | Returns the caret position and also an indication of where to place the caret (caretLineStart) | |
2105 | since this is ambiguous (same position used for end of line and start of next). | |
2106 | */ | |
2107 | long FindCaretPositionForCharacterPosition(long position, int hitTestFlags, wxRichTextParagraphLayoutBox* container, | |
42f2b395 | 2108 | bool& caretLineStart); |
7afd2b58 | 2109 | |
590a0f8b JS |
2110 | /** |
2111 | Processes mouse movement in order to change the cursor | |
2112 | */ | |
2113 | virtual bool ProcessMouseMovement(wxRichTextParagraphLayoutBox* container, wxRichTextObject* obj, long position, const wxPoint& pos); | |
2114 | ||
7afd2b58 JS |
2115 | /** |
2116 | Font names take a long time to retrieve, so cache them (on demand). | |
2117 | */ | |
2118 | static const wxArrayString& GetAvailableFontNames(); | |
2119 | ||
2120 | /** | |
2121 | Clears the cache of available font names. | |
2122 | */ | |
2123 | static void ClearAvailableFontNames(); | |
2124 | ||
7afd2b58 JS |
2125 | // implement wxTextEntry methods |
2126 | virtual wxString DoGetValue() const; | |
2127 | ||
2128 | protected: | |
2129 | // implement the wxTextEntry pure virtual method | |
42f2b395 | 2130 | virtual wxWindow *GetEditableWindow(); |
7afd2b58 JS |
2131 | |
2132 | // margins functions | |
2133 | virtual bool DoSetMargins(const wxPoint& pt); | |
2134 | virtual wxPoint DoGetMargins() const; | |
2135 | ||
7afd2b58 JS |
2136 | |
2137 | // Overrides | |
2138 | protected: | |
2139 | ||
2140 | /** | |
2141 | Currently this simply returns @c wxSize(10, 10). | |
2142 | */ | |
2143 | virtual wxSize DoGetBestSize() const ; | |
2144 | ||
2145 | virtual void DoSetValue(const wxString& value, int flags = 0); | |
2146 | ||
2147 | virtual void DoThaw(); | |
2148 | ||
2149 | ||
2150 | // Data members | |
0c0e063e | 2151 | protected: |
7afd2b58 JS |
2152 | #if wxRICHTEXT_BUFFERED_PAINTING |
2153 | /// Buffer bitmap | |
2154 | wxBitmap m_bufferBitmap; | |
2155 | #endif | |
2156 | ||
2157 | /// Text buffer | |
2158 | wxRichTextBuffer m_buffer; | |
2159 | ||
2160 | wxMenu* m_contextMenu; | |
2161 | ||
2162 | /// Caret position (1 less than the character position, so -1 is the | |
2163 | /// first caret position). | |
2164 | long m_caretPosition; | |
2165 | ||
2166 | /// Caret position when the default formatting has been changed. As | |
2167 | /// soon as this position changes, we no longer reflect the default style | |
2168 | /// in the UI. | |
2169 | long m_caretPositionForDefaultStyle; | |
2170 | ||
2171 | /// Selection range in character positions. -2, -2 means no selection. | |
2172 | wxRichTextSelection m_selection; | |
2173 | ||
2174 | wxRichTextCtrlSelectionState m_selectionState; | |
2175 | ||
2176 | /// Anchor so we know how to extend the selection | |
2177 | /// It's a caret position since it's between two characters. | |
2178 | long m_selectionAnchor; | |
2179 | ||
2180 | /// Anchor object if selecting multiple container objects, such as grid cells. | |
2181 | wxRichTextObject* m_selectionAnchorObject; | |
2182 | ||
2183 | /// Are we editable? | |
2184 | bool m_editable; | |
2185 | ||
2186 | /// Are we showing the caret position at the start of a line | |
2187 | /// instead of at the end of the previous one? | |
2188 | bool m_caretAtLineStart; | |
2189 | ||
2190 | /// Are we dragging a selection? | |
2191 | bool m_dragging; | |
2192 | ||
7afd2b58 JS |
2193 | /// Do we need full layout in idle? |
2194 | bool m_fullLayoutRequired; | |
2195 | wxLongLong m_fullLayoutTime; | |
2196 | long m_fullLayoutSavedPosition; | |
2197 | ||
2198 | /// Threshold for doing delayed layout | |
2199 | long m_delayedLayoutThreshold; | |
2200 | ||
2201 | /// Cursors | |
2202 | wxCursor m_textCursor; | |
2203 | wxCursor m_urlCursor; | |
2204 | ||
2205 | static wxArrayString sm_availableFontNames; | |
2206 | ||
2207 | wxRichTextContextMenuPropertiesInfo m_contextMenuPropertiesInfo; | |
2208 | ||
2209 | /// The object that currently has the editing focus | |
2210 | wxRichTextParagraphLayoutBox* m_focusObject; | |
2211 | }; | |
2212 | ||
2213 | /** | |
2214 | @class wxRichTextEvent | |
2215 | ||
2216 | This is the event class for wxRichTextCtrl notifications. | |
2217 | ||
2218 | @beginEventTable{wxRichTextEvent} | |
2219 | @event{EVT_RICHTEXT_LEFT_CLICK(id, func)} | |
ce7fe42e | 2220 | Process a @c wxEVT_RICHTEXT_LEFT_CLICK event, generated when the user |
7afd2b58 JS |
2221 | releases the left mouse button over an object. |
2222 | @event{EVT_RICHTEXT_RIGHT_CLICK(id, func)} | |
ce7fe42e | 2223 | Process a @c wxEVT_RICHTEXT_RIGHT_CLICK event, generated when the user |
7afd2b58 JS |
2224 | releases the right mouse button over an object. |
2225 | @event{EVT_RICHTEXT_MIDDLE_CLICK(id, func)} | |
ce7fe42e | 2226 | Process a @c wxEVT_RICHTEXT_MIDDLE_CLICK event, generated when the user |
7afd2b58 JS |
2227 | releases the middle mouse button over an object. |
2228 | @event{EVT_RICHTEXT_LEFT_DCLICK(id, func)} | |
ce7fe42e | 2229 | Process a @c wxEVT_RICHTEXT_LEFT_DCLICK event, generated when the user |
7afd2b58 JS |
2230 | double-clicks an object. |
2231 | @event{EVT_RICHTEXT_RETURN(id, func)} | |
ce7fe42e | 2232 | Process a @c wxEVT_RICHTEXT_RETURN event, generated when the user |
7afd2b58 JS |
2233 | presses the return key. Valid event functions: GetFlags, GetPosition. |
2234 | @event{EVT_RICHTEXT_CHARACTER(id, func)} | |
ce7fe42e | 2235 | Process a @c wxEVT_RICHTEXT_CHARACTER event, generated when the user |
7afd2b58 JS |
2236 | presses a character key. Valid event functions: GetFlags, GetPosition, GetCharacter. |
2237 | @event{EVT_RICHTEXT_DELETE(id, func)} | |
ce7fe42e | 2238 | Process a @c wxEVT_RICHTEXT_DELETE event, generated when the user |
7afd2b58 JS |
2239 | presses the backspace or delete key. Valid event functions: GetFlags, GetPosition. |
2240 | @event{EVT_RICHTEXT_RETURN(id, func)} | |
ce7fe42e | 2241 | Process a @c wxEVT_RICHTEXT_RETURN event, generated when the user |
7afd2b58 JS |
2242 | presses the return key. Valid event functions: GetFlags, GetPosition. |
2243 | @event{EVT_RICHTEXT_STYLE_CHANGED(id, func)} | |
ce7fe42e | 2244 | Process a @c wxEVT_RICHTEXT_STYLE_CHANGED event, generated when |
7afd2b58 JS |
2245 | styling has been applied to the control. Valid event functions: GetPosition, GetRange. |
2246 | @event{EVT_RICHTEXT_STYLESHEET_CHANGED(id, func)} | |
ce7fe42e | 2247 | Process a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING event, generated |
7afd2b58 JS |
2248 | when the control's stylesheet has changed, for example the user added, |
2249 | edited or deleted a style. Valid event functions: GetRange, GetPosition. | |
2250 | @event{EVT_RICHTEXT_STYLESHEET_REPLACING(id, func)} | |
ce7fe42e | 2251 | Process a @c wxEVT_RICHTEXT_STYLESHEET_REPLACING event, generated |
7afd2b58 JS |
2252 | when the control's stylesheet is about to be replaced, for example when |
2253 | a file is loaded into the control. | |
2254 | Valid event functions: Veto, GetOldStyleSheet, GetNewStyleSheet. | |
2255 | @event{EVT_RICHTEXT_STYLESHEET_REPLACED(id, func)} | |
ce7fe42e | 2256 | Process a @c wxEVT_RICHTEXT_STYLESHEET_REPLACED event, generated |
7afd2b58 JS |
2257 | when the control's stylesheet has been replaced, for example when a file |
2258 | is loaded into the control. | |
2259 | Valid event functions: GetOldStyleSheet, GetNewStyleSheet. | |
590a0f8b | 2260 | @event{EVT_RICHTEXT_PROPERTIES_CHANGED(id, func)} |
ce7fe42e | 2261 | Process a @c wxEVT_RICHTEXT_PROPERTIES_CHANGED event, generated when |
590a0f8b | 2262 | properties have been applied to the control. Valid event functions: GetPosition, GetRange. |
7afd2b58 | 2263 | @event{EVT_RICHTEXT_CONTENT_INSERTED(id, func)} |
ce7fe42e | 2264 | Process a @c wxEVT_RICHTEXT_CONTENT_INSERTED event, generated when |
7afd2b58 JS |
2265 | content has been inserted into the control. |
2266 | Valid event functions: GetPosition, GetRange. | |
2267 | @event{EVT_RICHTEXT_CONTENT_DELETED(id, func)} | |
ce7fe42e | 2268 | Process a @c wxEVT_RICHTEXT_CONTENT_DELETED event, generated when |
7afd2b58 JS |
2269 | content has been deleted from the control. |
2270 | Valid event functions: GetPosition, GetRange. | |
2271 | @event{EVT_RICHTEXT_BUFFER_RESET(id, func)} | |
ce7fe42e | 2272 | Process a @c wxEVT_RICHTEXT_BUFFER_RESET event, generated when the |
7afd2b58 JS |
2273 | buffer has been reset by deleting all content. |
2274 | You can use this to set a default style for the first new paragraph. | |
2275 | @event{EVT_RICHTEXT_SELECTION_CHANGED(id, func)} | |
ce7fe42e | 2276 | Process a @c wxEVT_RICHTEXT_SELECTION_CHANGED event, generated when the |
7afd2b58 JS |
2277 | selection range has changed. |
2278 | @event{EVT_RICHTEXT_FOCUS_OBJECT_CHANGED(id, func)} | |
ce7fe42e | 2279 | Process a @c wxEVT_RICHTEXT_FOCUS_OBJECT_CHANGED event, generated when the |
7afd2b58 JS |
2280 | current focus object has changed. |
2281 | @endEventTable | |
2282 | ||
2283 | @library{wxrichtext} | |
2284 | @category{events,richtext} | |
2285 | */ | |
2286 | ||
16caec26 | 2287 | class wxRichTextEvent : public wxNotifyEvent |
7afd2b58 JS |
2288 | { |
2289 | public: | |
2290 | /** | |
2291 | Constructor. | |
2292 | ||
2293 | @param commandType | |
2294 | The type of the event. | |
591805e0 | 2295 | @param winid |
7afd2b58 JS |
2296 | Window identifier. The value @c wxID_ANY indicates a default value. |
2297 | */ | |
42f2b395 | 2298 | wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); |
7afd2b58 JS |
2299 | |
2300 | /** | |
2301 | Copy constructor. | |
2302 | */ | |
42f2b395 RD |
2303 | wxRichTextEvent(const wxRichTextEvent& event); |
2304 | ||
7afd2b58 | 2305 | /** |
f090e4ef | 2306 | Returns the buffer position at which the event occurred. |
7afd2b58 | 2307 | */ |
42f2b395 | 2308 | long GetPosition() const; |
7afd2b58 JS |
2309 | |
2310 | /** | |
2311 | Sets the buffer position variable. | |
2312 | */ | |
42f2b395 | 2313 | void SetPosition(long pos); |
7afd2b58 JS |
2314 | |
2315 | /** | |
2316 | Returns flags indicating modifier keys pressed. | |
2317 | ||
2318 | Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN. | |
2319 | */ | |
42f2b395 | 2320 | int GetFlags() const; |
7afd2b58 JS |
2321 | |
2322 | /** | |
2323 | Sets flags indicating modifier keys pressed. | |
2324 | ||
2325 | Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN. | |
2326 | */ | |
42f2b395 | 2327 | void SetFlags(int flags); |
7afd2b58 JS |
2328 | |
2329 | /** | |
2330 | Returns the old style sheet. | |
2331 | ||
ce7fe42e VZ |
2332 | Can be used in a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING or |
2333 | @c wxEVT_RICHTEXT_STYLESHEET_CHANGED event handler. | |
7afd2b58 | 2334 | */ |
42f2b395 | 2335 | wxRichTextStyleSheet* GetOldStyleSheet() const; |
7afd2b58 JS |
2336 | |
2337 | /** | |
2338 | Sets the old style sheet variable. | |
2339 | */ | |
42f2b395 | 2340 | void SetOldStyleSheet(wxRichTextStyleSheet* sheet); |
7afd2b58 JS |
2341 | |
2342 | /** | |
2343 | Returns the new style sheet. | |
2344 | ||
ce7fe42e VZ |
2345 | Can be used in a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING or |
2346 | @c wxEVT_RICHTEXT_STYLESHEET_CHANGED event handler. | |
7afd2b58 | 2347 | */ |
42f2b395 | 2348 | wxRichTextStyleSheet* GetNewStyleSheet() const; |
7afd2b58 JS |
2349 | |
2350 | /** | |
2351 | Sets the new style sheet variable. | |
2352 | */ | |
42f2b395 | 2353 | void SetNewStyleSheet(wxRichTextStyleSheet* sheet); |
7afd2b58 JS |
2354 | |
2355 | /** | |
2356 | Gets the range for the current operation. | |
2357 | */ | |
42f2b395 | 2358 | const wxRichTextRange& GetRange() const; |
7afd2b58 JS |
2359 | |
2360 | /** | |
2361 | Sets the range variable. | |
2362 | */ | |
42f2b395 | 2363 | void SetRange(const wxRichTextRange& range); |
7afd2b58 JS |
2364 | |
2365 | /** | |
ce7fe42e | 2366 | Returns the character pressed, within a @c wxEVT_RICHTEXT_CHARACTER event. |
7afd2b58 | 2367 | */ |
42f2b395 | 2368 | wxChar GetCharacter() const; |
7afd2b58 JS |
2369 | |
2370 | /** | |
2371 | Sets the character variable. | |
2372 | */ | |
42f2b395 | 2373 | void SetCharacter(wxChar ch); |
7afd2b58 JS |
2374 | |
2375 | /** | |
2376 | Returns the container for which the event is relevant. | |
2377 | */ | |
42f2b395 | 2378 | wxRichTextParagraphLayoutBox* GetContainer() const; |
7afd2b58 JS |
2379 | |
2380 | /** | |
2381 | Sets the container for which the event is relevant. | |
2382 | */ | |
42f2b395 | 2383 | void SetContainer(wxRichTextParagraphLayoutBox* container); |
7afd2b58 JS |
2384 | |
2385 | /** | |
2386 | Returns the old container, for a focus change event. | |
2387 | */ | |
42f2b395 | 2388 | wxRichTextParagraphLayoutBox* GetOldContainer() const; |
7afd2b58 JS |
2389 | |
2390 | /** | |
2391 | Sets the old container, for a focus change event. | |
2392 | */ | |
42f2b395 | 2393 | void SetOldContainer(wxRichTextParagraphLayoutBox* container); |
7afd2b58 | 2394 | |
42f2b395 | 2395 | virtual wxEvent *Clone() const; |
7afd2b58 JS |
2396 | |
2397 | protected: | |
2398 | int m_flags; | |
2399 | long m_position; | |
2400 | wxRichTextStyleSheet* m_oldStyleSheet; | |
2401 | wxRichTextStyleSheet* m_newStyleSheet; | |
2402 | wxRichTextRange m_range; | |
2403 | wxChar m_char; | |
2404 | wxRichTextParagraphLayoutBox* m_container; | |
2405 | wxRichTextParagraphLayoutBox* m_oldContainer; | |
2406 | ||
23324ae1 | 2407 | }; |
12346143 RD |
2408 | |
2409 | ||
2410 | wxEventType wxEVT_RICHTEXT_LEFT_CLICK; | |
2411 | wxEventType wxEVT_RICHTEXT_RIGHT_CLICK; | |
2412 | wxEventType wxEVT_RICHTEXT_MIDDLE_CLICK; | |
2413 | wxEventType wxEVT_RICHTEXT_LEFT_DCLICK; | |
2414 | wxEventType wxEVT_RICHTEXT_RETURN; | |
2415 | wxEventType wxEVT_RICHTEXT_CHARACTER; | |
2416 | wxEventType wxEVT_RICHTEXT_DELETE; | |
2417 | ||
2418 | wxEventType wxEVT_RICHTEXT_STYLESHEET_CHANGING; | |
2419 | wxEventType wxEVT_RICHTEXT_STYLESHEET_CHANGED; | |
2420 | wxEventType wxEVT_RICHTEXT_STYLESHEET_REPLACING; | |
2421 | wxEventType wxEVT_RICHTEXT_STYLESHEET_REPLACED; | |
2422 | ||
2423 | wxEventType wxEVT_RICHTEXT_CONTENT_INSERTED; | |
2424 | wxEventType wxEVT_RICHTEXT_CONTENT_DELETED; | |
2425 | wxEventType wxEVT_RICHTEXT_STYLE_CHANGED; | |
2426 | wxEventType wxEVT_RICHTEXT_PROPERTIES_CHANGED; | |
2427 | wxEventType wxEVT_RICHTEXT_SELECTION_CHANGED; | |
2428 | wxEventType wxEVT_RICHTEXT_BUFFER_RESET; | |
2429 | wxEventType wxEVT_RICHTEXT_FOCUS_OBJECT_CHANGED; |