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