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