1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextctrl.h
3 // Purpose: A rich edit control
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RICHTEXTCTRL_H_
13 #define _WX_RICHTEXTCTRL_H_
15 #include "wx/textctrl.h"
19 #include "wx/scrolwin.h"
22 #include "wx/richtext/richtextbuffer.h"
24 #if wxCHECK_VERSION(2,7,0)
25 #define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0
27 #define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0
37 #define wxRE_READONLY 0x0010
38 #define wxRE_MULTILINE 0x0020
43 #define wxRICHTEXT_SHIFT_DOWN 0x01
44 #define wxRICHTEXT_CTRL_DOWN 0x02
45 #define wxRICHTEXT_ALT_DOWN 0x04
50 #define wxRICHTEXT_DEFAULT_OVERALL_SIZE wxSize(-1, -1)
51 #define wxRICHTEXT_DEFAULT_IMAGE_SIZE wxSize(80, 80)
52 #define wxRICHTEXT_DEFAULT_SPACING 3
53 #define wxRICHTEXT_DEFAULT_MARGIN 3
54 #define wxRICHTEXT_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175)
55 #define wxRICHTEXT_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140)
56 #define wxRICHTEXT_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)
57 #define wxRICHTEXT_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200)
58 #define wxRICHTEXT_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80)
59 #define wxRICHTEXT_DEFAULT_CARET_WIDTH 2
62 * Forward declarations
66 * wxRichTextItem class declaration
69 // Drawing styles/states
70 #define wxRICHTEXT_SELECTED 0x01
71 #define wxRICHTEXT_TAGGED 0x02
72 // The control is focussed
73 #define wxRICHTEXT_FOCUSSED 0x04
74 // The item itself has the focus
75 #define wxRICHTEXT_IS_FOCUS 0x08
78 * wxRichTextCtrl class declaration
81 class WXDLLIMPEXP_ADV wxRichTextCtrl
:
82 #if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
83 public wxTextCtrlBase
, wxScrollHelper
85 public wxScrolledWindow
88 DECLARE_CLASS( wxRichTextCtrl
)
95 wxRichTextCtrl( wxWindow
* parent
, wxWindowID id
= -1, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
96 long style
= wxRE_MULTILINE
);
102 bool Create( wxWindow
* parent
, wxWindowID id
= -1, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
103 long style
= wxRE_MULTILINE
);
105 /// Member initialisation
108 ///// wxTextCtrl compatibility
112 virtual wxString
GetValue() const;
113 virtual void SetValue(const wxString
& value
);
115 virtual wxString
GetRange(long from
, long to
) const;
117 virtual int GetLineLength(long lineNo
) const ;
118 virtual wxString
GetLineText(long lineNo
) const ;
119 virtual int GetNumberOfLines() const ;
121 virtual bool IsModified() const ;
122 virtual bool IsEditable() const ;
124 // more readable flag testing methods
125 bool IsSingleLine() const { return !HasFlag(wxRE_MULTILINE
); }
126 bool IsMultiLine() const { return !IsSingleLine(); }
128 // If the return values from and to are the same, there is no selection.
129 virtual void GetSelection(long* from
, long* to
) const;
131 virtual wxString
GetStringSelection() const;
134 wxString
GetFilename() const { return m_filename
; }
137 void SetFilename(const wxString
& filename
) { m_filename
= filename
; }
142 virtual void Clear();
143 virtual void Replace(long from
, long to
, const wxString
& value
);
144 virtual void Remove(long from
, long to
);
146 // load/save the controls contents from/to the file
147 virtual bool LoadFile(const wxString
& file
, int type
= wxRICHTEXT_TYPE_ANY
);
148 virtual bool SaveFile(const wxString
& file
= wxEmptyString
, int type
= wxRICHTEXT_TYPE_ANY
);
150 // sets/clears the dirty flag
151 virtual void MarkDirty();
152 virtual void DiscardEdits();
154 // set the max number of characters which may be entered in a single line
156 virtual void SetMaxLength(unsigned long WXUNUSED(len
)) { }
158 // writing text inserts it at the current position, appending always
159 // inserts it at the end
160 virtual void WriteText(const wxString
& text
);
161 virtual void AppendText(const wxString
& text
);
163 // text control under some platforms supports the text styles: these
164 // methods allow to apply the given text style to the given selection or to
165 // set/get the style which will be used for all appended text
166 virtual bool SetStyle(long start
, long end
, const wxTextAttrEx
& style
);
167 virtual bool SetStyle(const wxRichTextRange
& range
, const wxRichTextAttr
& style
);
168 virtual bool GetStyle(long position
, wxTextAttrEx
& style
) const;
169 virtual bool GetStyle(long position
, wxRichTextAttr
& style
) const;
170 virtual bool SetDefaultStyle(const wxTextAttrEx
& style
);
172 // TODO: change to GetDefaultStyle if we merge wxTextAttr and wxTextAttrEx
173 virtual const wxTextAttrEx
& GetDefaultStyleEx() const;
175 // translate between the position (which is just an index in the text ctrl
176 // considering all its contents as a single strings) and (x, y) coordinates
177 // which represent column and line.
178 virtual long XYToPosition(long x
, long y
) const;
179 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
181 virtual void ShowPosition(long pos
);
183 // find the character at position given in pixels
185 // NB: pt is in device coords (not adjusted for the client area origin nor
187 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long *pos
) const;
188 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
190 wxTextCoord
*row
) const;
192 // Clipboard operations
195 virtual void Paste();
196 virtual void DeleteSelection();
198 virtual bool CanCopy() const;
199 virtual bool CanCut() const;
200 virtual bool CanPaste() const;
201 virtual bool CanDeleteSelection() const;
207 virtual bool CanUndo() const;
208 virtual bool CanRedo() const;
211 virtual void SetInsertionPoint(long pos
);
212 virtual void SetInsertionPointEnd();
213 virtual long GetInsertionPoint() const;
214 virtual wxTextPos
GetLastPosition() const;
216 virtual void SetSelection(long from
, long to
);
217 virtual void SelectAll();
218 virtual void SetEditable(bool editable
);
220 /// Call Freeze to prevent refresh
221 virtual void Freeze();
223 /// Call Thaw to refresh
224 virtual void Thaw(bool refresh
= true);
226 /// Call Thaw to refresh
227 virtual bool IsFrozen() const { return m_freezeCount
> 0; }
229 virtual bool HasSelection() const;
231 ///// Functionality specific to wxRichTextCtrl
233 /// Write an image at the current insertion point. Supply optional type to use
234 /// for internal and file storage of the raw data.
235 virtual bool WriteImage(const wxImage
& image
, int bitmapType
= wxBITMAP_TYPE_PNG
);
237 /// Write a bitmap at the current insertion point. Supply optional type to use
238 /// for internal and file storage of the raw data.
239 virtual bool WriteImage(const wxBitmap
& bitmap
, int bitmapType
= wxBITMAP_TYPE_PNG
);
241 /// Load an image from file and write at the current insertion point.
242 virtual bool WriteImage(const wxString
& filename
, int bitmapType
);
244 /// Write an image block at the current insertion point.
245 virtual bool WriteImage(const wxRichTextImageBlock
& imageBlock
);
247 /// Insert a newline (actually paragraph) at the current insertion point.
248 virtual bool Newline();
250 /// Set basic (overall) style
251 virtual void SetBasicStyle(const wxTextAttrEx
& style
) { GetBuffer().SetBasicStyle(style
); }
252 virtual void SetBasicStyle(const wxRichTextAttr
& style
) { GetBuffer().SetBasicStyle(style
); }
254 /// Get basic (overall) style
255 virtual const wxTextAttrEx
& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
257 /// Begin using a style
258 virtual bool BeginStyle(const wxTextAttrEx
& style
) { return GetBuffer().BeginStyle(style
); }
261 virtual bool EndStyle() { return GetBuffer().EndStyle(); }
264 virtual bool EndAllStyles() { return GetBuffer().EndAllStyles(); }
267 bool BeginBold() { return GetBuffer().BeginBold(); }
270 bool EndBold() { return GetBuffer().EndBold(); }
272 /// Begin using italic
273 bool BeginItalic() { return GetBuffer().BeginItalic(); }
276 bool EndItalic() { return GetBuffer().EndItalic(); }
278 /// Begin using underline
279 bool BeginUnderline() { return GetBuffer().BeginUnderline(); }
281 /// End using underline
282 bool EndUnderline() { return GetBuffer().EndUnderline(); }
284 /// Begin using point size
285 bool BeginFontSize(int pointSize
) { return GetBuffer().BeginFontSize(pointSize
); }
287 /// End using point size
288 bool EndFontSize() { return GetBuffer().EndFontSize(); }
290 /// Begin using this font
291 bool BeginFont(const wxFont
& font
) { return GetBuffer().BeginFont(font
); }
294 bool EndFont() { return GetBuffer().EndFont(); }
296 /// Begin using this colour
297 bool BeginTextColour(const wxColour
& colour
) { return GetBuffer().BeginTextColour(colour
); }
299 /// End using a colour
300 bool EndTextColour() { return GetBuffer().EndTextColour(); }
302 /// Begin using alignment
303 bool BeginAlignment(wxTextAttrAlignment alignment
) { return GetBuffer().BeginAlignment(alignment
); }
306 bool EndAlignment() { return GetBuffer().EndAlignment(); }
308 /// Begin left indent
309 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0) { return GetBuffer().BeginLeftIndent(leftIndent
, leftSubIndent
); }
312 bool EndLeftIndent() { return GetBuffer().EndLeftIndent(); }
314 /// Begin right indent
315 bool BeginRightIndent(int rightIndent
) { return GetBuffer().BeginRightIndent(rightIndent
); }
318 bool EndRightIndent() { return GetBuffer().EndRightIndent(); }
320 /// Begin paragraph spacing
321 bool BeginParagraphSpacing(int before
, int after
) { return GetBuffer().BeginParagraphSpacing(before
, after
); }
323 /// End paragraph spacing
324 bool EndParagraphSpacing() { return GetBuffer().EndParagraphSpacing(); }
326 /// Begin line spacing
327 bool BeginLineSpacing(int lineSpacing
) { return GetBuffer().BeginLineSpacing(lineSpacing
); }
330 bool EndLineSpacing() { return GetBuffer().EndLineSpacing(); }
332 /// Begin numbered bullet
333 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
334 { return GetBuffer().BeginNumberedBullet(bulletNumber
, leftIndent
, leftSubIndent
, bulletStyle
); }
336 /// End numbered bullet
337 bool EndNumberedBullet() { return GetBuffer().EndNumberedBullet(); }
339 /// Begin symbol bullet
340 bool BeginSymbolBullet(wxChar symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
341 { return GetBuffer().BeginSymbolBullet(symbol
, leftIndent
, leftSubIndent
, bulletStyle
); }
343 /// End symbol bullet
344 bool EndSymbolBullet() { return GetBuffer().EndSymbolBullet(); }
346 /// Begin named character style
347 bool BeginCharacterStyle(const wxString
& characterStyle
) { return GetBuffer().BeginCharacterStyle(characterStyle
); }
349 /// End named character style
350 bool EndCharacterStyle() { return GetBuffer().EndCharacterStyle(); }
352 /// Begin named paragraph style
353 bool BeginParagraphStyle(const wxString
& paragraphStyle
) { return GetBuffer().BeginParagraphStyle(paragraphStyle
); }
355 /// End named character style
356 bool EndParagraphStyle() { return GetBuffer().EndParagraphStyle(); }
358 /// Sets the default style to the style under the cursor
359 bool SetDefaultStyleToCursorStyle();
361 /// Clear the selection
362 virtual void SelectNone();
364 /// Get/set the selection range in character positions. -1, -1 means no selection.
365 const wxRichTextRange
& GetSelectionRange() const { return m_selectionRange
; }
366 void SetSelectionRange(const wxRichTextRange
& range
) { m_selectionRange
= range
; }
368 /// Add a new paragraph of text to the end of the buffer
369 virtual wxRichTextRange
AddParagraph(const wxString
& text
);
372 virtual wxRichTextRange
AddImage(const wxImage
& image
);
374 /// Layout the buffer: which we must do before certain operations, such as
375 /// setting the caret position.
376 virtual bool Layout();
378 /// Move the caret to the given character position
379 virtual bool MoveCaret(long pos
, bool showAtLineStart
= false);
382 virtual bool MoveRight(int noPositions
= 1, int flags
= 0);
385 virtual bool MoveLeft(int noPositions
= 1, int flags
= 0);
388 virtual bool MoveUp(int noLines
= 1, int flags
= 0);
391 virtual bool MoveDown(int noLines
= 1, int flags
= 0);
393 /// Move to the end of the line
394 virtual bool MoveToLineEnd(int flags
= 0);
396 /// Move to the start of the line
397 virtual bool MoveToLineStart(int flags
= 0);
399 /// Move to the end of the paragraph
400 virtual bool MoveToParagraphEnd(int flags
= 0);
402 /// Move to the start of the paragraph
403 virtual bool MoveToParagraphStart(int flags
= 0);
405 /// Move to the start of the buffer
406 virtual bool MoveHome(int flags
= 0);
408 /// Move to the end of the buffer
409 virtual bool MoveEnd(int flags
= 0);
412 virtual bool PageUp(int noPages
= 1, int flags
= 0);
414 /// Move n pages down
415 virtual bool PageDown(int noPages
= 1, int flags
= 0);
417 /// Move n words left
418 virtual bool WordLeft(int noPages
= 1, int flags
= 0);
420 /// Move n words right
421 virtual bool WordRight(int noPages
= 1, int flags
= 0);
423 /// Returns the buffer associated with the control.
424 wxRichTextBuffer
& GetBuffer() { return m_buffer
; }
425 const wxRichTextBuffer
& GetBuffer() const { return m_buffer
; }
427 /// Start batching undo history for commands.
428 virtual bool BeginBatchUndo(const wxString
& cmdName
) { return m_buffer
.BeginBatchUndo(cmdName
); }
430 /// End batching undo history for commands.
431 virtual bool EndBatchUndo() { return m_buffer
.EndBatchUndo(); }
433 /// Are we batching undo history for commands?
434 virtual bool BatchingUndo() const { return m_buffer
.BatchingUndo(); }
436 /// Start suppressing undo history for commands.
437 virtual bool BeginSuppressUndo() { return m_buffer
.BeginSuppressUndo(); }
439 /// End suppressing undo history for commands.
440 virtual bool EndSuppressUndo() { return m_buffer
.EndSuppressUndo(); }
442 /// Are we suppressing undo history for commands?
443 virtual bool SuppressingUndo() const { return m_buffer
.SuppressingUndo(); }
445 /// Test if this whole range has character attributes of the specified kind. If any
446 /// of the attributes are different within the range, the test fails. You
447 /// can use this to implement, for example, bold button updating. style must have
448 /// flags indicating which attributes are of interest.
449 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const
451 return GetBuffer().HasCharacterAttributes(range
, style
);
453 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const
455 return GetBuffer().HasCharacterAttributes(range
, style
);
458 /// Test if this whole range has paragraph attributes of the specified kind. If any
459 /// of the attributes are different within the range, the test fails. You
460 /// can use this to implement, for example, centering button updating. style must have
461 /// flags indicating which attributes are of interest.
462 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const
464 return GetBuffer().HasParagraphAttributes(range
, style
);
466 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const
468 return GetBuffer().HasParagraphAttributes(range
, style
);
471 /// Is all of the selection bold?
472 virtual bool IsSelectionBold() const;
474 /// Is all of the selection italics?
475 virtual bool IsSelectionItalics() const;
477 /// Is all of the selection underlined?
478 virtual bool IsSelectionUnderlined() const;
480 /// Is all of the selection aligned according to the specified flag?
481 virtual bool IsSelectionAligned(wxTextAttrAlignment alignment
) const;
483 /// Apply bold to the selection
484 virtual bool ApplyBoldToSelection();
486 /// Apply italic to the selection
487 virtual bool ApplyItalicToSelection();
489 /// Apply underline to the selection
490 virtual bool ApplyUnderlineToSelection();
492 /// Apply alignment to the selection
493 virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment
);
495 /// Set style sheet, if any.
496 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { GetBuffer().SetStyleSheet(styleSheet
); }
497 wxRichTextStyleSheet
* GetStyleSheet() const { return GetBuffer().GetStyleSheet(); }
501 void Command(wxCommandEvent
& event
);
502 void OnDropFiles(wxDropFilesEvent
& event
);
504 void OnCut(wxCommandEvent
& event
);
505 void OnCopy(wxCommandEvent
& event
);
506 void OnPaste(wxCommandEvent
& event
);
507 void OnUndo(wxCommandEvent
& event
);
508 void OnRedo(wxCommandEvent
& event
);
509 void OnSelectAll(wxCommandEvent
& event
);
510 void OnClear(wxCommandEvent
& event
);
512 void OnUpdateCut(wxUpdateUIEvent
& event
);
513 void OnUpdateCopy(wxUpdateUIEvent
& event
);
514 void OnUpdatePaste(wxUpdateUIEvent
& event
);
515 void OnUpdateUndo(wxUpdateUIEvent
& event
);
516 void OnUpdateRedo(wxUpdateUIEvent
& event
);
517 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
518 void OnUpdateClear(wxUpdateUIEvent
& event
);
520 // Show a context menu for Rich Edit controls (the standard
521 // EDIT control has one already)
522 void OnContextMenu(wxContextMenuEvent
& event
);
527 void OnPaint(wxPaintEvent
& event
);
528 void OnEraseBackground(wxEraseEvent
& event
);
531 void OnLeftClick(wxMouseEvent
& event
);
534 void OnLeftUp(wxMouseEvent
& event
);
537 void OnMoveMouse(wxMouseEvent
& event
);
539 /// Left-double-click
540 void OnLeftDClick(wxMouseEvent
& event
);
543 void OnMiddleClick(wxMouseEvent
& event
);
546 void OnRightClick(wxMouseEvent
& event
);
549 void OnChar(wxKeyEvent
& event
);
552 void OnSize(wxSizeEvent
& event
);
554 /// Setting/losing focus
555 void OnSetFocus(wxFocusEvent
& event
);
556 void OnKillFocus(wxFocusEvent
& event
);
560 /// Set font, and also default attributes
561 virtual bool SetFont(const wxFont
& font
);
563 /// Set up scrollbars, e.g. after a resize
564 virtual void SetupScrollbars(bool atTop
= false);
566 /// Keyboard navigation
567 virtual bool Navigate(int keyCode
, int flags
);
569 /// Paint the background
570 virtual void PaintBackground(wxDC
& dc
);
572 /// Recreate buffer bitmap if necessary
573 virtual bool RecreateBuffer(const wxSize
& size
= wxDefaultSize
);
575 /// Set the selection
576 virtual void DoSetSelection(long from
, long to
, bool scrollCaret
= true);
579 virtual void DoWriteText(const wxString
& value
, bool selectionOnly
= true);
581 /// Send an update event
582 virtual bool SendUpdateEvent();
584 /// Init command event
585 void InitCommandEvent(wxCommandEvent
& event
) const;
587 /// do the window-specific processing after processing the update event
588 virtual void DoUpdateWindowUI(wxUpdateUIEvent
& event
);
590 /// Should we inherit colours?
591 virtual bool ShouldInheritColours() const { return false; }
593 /// Position the caret
594 virtual void PositionCaret();
596 /// Extend the selection, returning true if the selection was
597 /// changed. Selections are in caret positions.
598 virtual bool ExtendSelection(long oldPosition
, long newPosition
, int flags
);
600 /// Scroll into view. This takes a _caret_ position.
601 virtual bool ScrollIntoView(long position
, int keyCode
);
603 /// The caret position is the character position just before the caret.
604 /// A value of -1 means the caret is at the start of the buffer.
605 void SetCaretPosition(long position
, bool showAtLineStart
= false) ;
606 long GetCaretPosition() const { return m_caretPosition
; }
608 /// Move caret one visual step forward: this may mean setting a flag
609 /// and keeping the same position if we're going from the end of one line
610 /// to the start of the next, which may be the exact same caret position.
611 void MoveCaretForward(long oldPosition
) ;
613 /// Move caret one visual step forward: this may mean setting a flag
614 /// and keeping the same position if we're going from the end of one line
615 /// to the start of the next, which may be the exact same caret position.
616 void MoveCaretBack(long oldPosition
) ;
618 /// Get the caret height and position for the given character position
619 bool GetCaretPositionForIndex(long position
, wxRect
& rect
);
621 /// Gets the line for the visible caret position. If the caret is
622 /// shown at the very end of the line, it means the next character is actually
623 /// on the following line. So let's get the line we're expecting to find
624 /// if this is the case.
625 wxRichTextLine
* GetVisibleLineForCaretPosition(long caretPosition
) const;
627 /// Gets the command processor
628 wxCommandProcessor
* GetCommandProcessor() const { return GetBuffer().GetCommandProcessor(); }
630 /// Delete content if there is a selection, e.g. when pressing a key.
631 /// Returns the new caret position in newPos, or leaves it if there
633 bool DeleteSelectedContent(long* newPos
= NULL
);
635 /// Transform logical to physical
636 wxPoint
GetPhysicalPoint(const wxPoint
& ptLogical
);
638 /// Transform physical to logical
639 wxPoint
GetLogicalPoint(const wxPoint
& ptPhysical
);
641 /// Finds the caret position for the next word. Direction
642 /// is 1 (forward) or -1 (backwards).
643 virtual long FindNextWordPosition(int direction
= 1) const;
645 /// Is the given position visible on the screen?
646 bool IsPositionVisible(long pos
) const;
650 virtual wxSize
DoGetBestSize() const ;
655 /// Allows nested Freeze/Thaw
659 wxBitmap m_bufferBitmap
;
662 wxRichTextBuffer m_buffer
;
667 wxMenu
* m_contextMenu
;
669 /// Caret position (1 less than the character position, so -1 is the
670 /// first caret position).
671 long m_caretPosition
;
673 /// Selection range in character positions. -2, -2 means no selection.
674 wxRichTextRange m_selectionRange
;
676 /// Anchor so we know how to extend the selection
677 /// It's a caret position since it's between two characters.
678 long m_selectionAnchor
;
683 /// Are we showing the caret position at the start of a line
684 /// instead of at the end of the previous one?
685 bool m_caretAtLineStart
;
687 /// Are we dragging a selection?
690 /// Start position for drag
695 * wxRichTextEvent - the event class for wxRichTextCtrl notifications
698 class WXDLLIMPEXP_ADV wxRichTextEvent
: public wxNotifyEvent
701 wxRichTextEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
702 : wxNotifyEvent(commandType
, winid
),
703 m_itemIndex(-1), m_flags(0)
706 wxRichTextEvent(const wxRichTextEvent
& event
)
707 : wxNotifyEvent(event
),
708 m_itemIndex(event
.m_itemIndex
), m_flags(event
.m_flags
)
711 int GetIndex() const { return m_itemIndex
; }
712 void SetIndex(int n
) { m_itemIndex
= n
; }
714 int GetFlags() const { return m_flags
; }
715 void SetFlags(int flags
) { m_flags
= flags
; }
717 virtual wxEvent
*Clone() const { return new wxRichTextEvent(*this); }
724 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRichTextEvent
)
728 * wxRichTextCtrl event macros
731 BEGIN_DECLARE_EVENT_TYPES()
732 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED
, 2600)
733 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED
, 2601)
734 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK
, 2602)
735 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK
, 2603)
736 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK
, 2604)
737 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK
, 2605)
738 DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RETURN
, 2606)
739 END_DECLARE_EVENT_TYPES()
741 typedef void (wxEvtHandler::*wxRichTextEventFunction
)(wxRichTextEvent
&);
743 #define EVT_RICHTEXT_ITEM_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
744 #define EVT_RICHTEXT_ITEM_DESELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
745 #define EVT_RICHTEXT_LEFT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
746 #define EVT_RICHTEXT_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
747 #define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
748 #define EVT_RICHTEXT_LEFT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
749 #define EVT_RICHTEXT_RETURN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
755 // _WX_RICHTEXTCTRL_H_