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/richtext/richtextbuffer.h"
19 #include "wx/scrolwin.h"
22 #if wxCHECK_VERSION(2,7,0)
23 #define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0
25 #define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0
28 #if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
29 #include "wx/textctrl.h"
39 #define wxRE_READONLY 0x0010
40 #define wxRE_MULTILINE 0x0020
45 #define wxRICHTEXT_SHIFT_DOWN 0x01
46 #define wxRICHTEXT_CTRL_DOWN 0x02
47 #define wxRICHTEXT_ALT_DOWN 0x04
52 #define wxRICHTEXT_DEFAULT_OVERALL_SIZE wxSize(-1, -1)
53 #define wxRICHTEXT_DEFAULT_IMAGE_SIZE wxSize(80, 80)
54 #define wxRICHTEXT_DEFAULT_SPACING 3
55 #define wxRICHTEXT_DEFAULT_MARGIN 3
56 #define wxRICHTEXT_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175)
57 #define wxRICHTEXT_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140)
58 #define wxRICHTEXT_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)
59 #define wxRICHTEXT_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200)
60 #define wxRICHTEXT_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80)
61 #define wxRICHTEXT_DEFAULT_CARET_WIDTH 2
62 // Minimum buffer size before delayed layout kicks in
63 #define wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD 20000
64 // Milliseconds before layout occurs after resize
65 #define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50
68 * Forward declarations
72 * wxRichTextItem class declaration
75 // Drawing styles/states
76 #define wxRICHTEXT_SELECTED 0x01
77 #define wxRICHTEXT_TAGGED 0x02
78 // The control is focussed
79 #define wxRICHTEXT_FOCUSSED 0x04
80 // The item itself has the focus
81 #define wxRICHTEXT_IS_FOCUS 0x08
84 * wxRichTextCtrl class declaration
87 class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl
:
88 #if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
89 public wxTextCtrlBase
, wxScrollHelper
91 public wxScrolledWindow
94 DECLARE_CLASS( wxRichTextCtrl
)
101 wxRichTextCtrl( wxWindow
* parent
, wxWindowID id
= -1, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
102 long style
= wxRE_MULTILINE
);
108 bool Create( wxWindow
* parent
, wxWindowID id
= -1, const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
,
109 long style
= wxRE_MULTILINE
);
111 /// Member initialisation
114 ///// wxTextCtrl compatibility
118 virtual wxString
GetValue() const;
119 virtual void SetValue(const wxString
& value
);
121 virtual wxString
GetRange(long from
, long to
) const;
123 virtual int GetLineLength(long lineNo
) const ;
124 virtual wxString
GetLineText(long lineNo
) const ;
125 virtual int GetNumberOfLines() const ;
127 virtual bool IsModified() const ;
128 virtual bool IsEditable() const ;
130 // more readable flag testing methods
131 bool IsSingleLine() const { return !HasFlag(wxRE_MULTILINE
); }
132 bool IsMultiLine() const { return !IsSingleLine(); }
134 // If the return values from and to are the same, there is no selection.
135 virtual void GetSelection(long* from
, long* to
) const;
137 virtual wxString
GetStringSelection() const;
140 wxString
GetFilename() const { return m_filename
; }
143 void SetFilename(const wxString
& filename
) { m_filename
= filename
; }
145 /// Set the threshold in character positions for doing layout optimization during sizing
146 void SetDelayedLayoutThreshold(long threshold
) { m_delayedLayoutThreshold
= threshold
; }
148 /// Get the threshold in character positions for doing layout optimization during sizing
149 long GetDelayedLayoutThreshold() const { return m_delayedLayoutThreshold
; }
154 virtual void Clear();
155 virtual void Replace(long from
, long to
, const wxString
& value
);
156 virtual void Remove(long from
, long to
);
158 // load/save the controls contents from/to the file
159 virtual bool LoadFile(const wxString
& file
, int type
= wxRICHTEXT_TYPE_ANY
);
160 virtual bool SaveFile(const wxString
& file
= wxEmptyString
, int type
= wxRICHTEXT_TYPE_ANY
);
162 // sets/clears the dirty flag
163 virtual void MarkDirty();
164 virtual void DiscardEdits();
166 // set the max number of characters which may be entered in a single line
168 virtual void SetMaxLength(unsigned long WXUNUSED(len
)) { }
170 // writing text inserts it at the current position, appending always
171 // inserts it at the end
172 virtual void WriteText(const wxString
& text
);
173 virtual void AppendText(const wxString
& text
);
175 // text control under some platforms supports the text styles: these
176 // methods allow to apply the given text style to the given selection or to
177 // set/get the style which will be used for all appended text
178 virtual bool SetStyle(long start
, long end
, const wxTextAttrEx
& style
);
179 virtual bool SetStyle(const wxRichTextRange
& range
, const wxRichTextAttr
& style
);
180 virtual bool GetStyle(long position
, wxTextAttrEx
& style
) const;
181 virtual bool GetStyle(long position
, wxRichTextAttr
& style
) const;
182 virtual bool SetDefaultStyle(const wxTextAttrEx
& style
);
184 // TODO: change to GetDefaultStyle if we merge wxTextAttr and wxTextAttrEx
185 virtual const wxTextAttrEx
& GetDefaultStyleEx() const;
187 // translate between the position (which is just an index in the text ctrl
188 // considering all its contents as a single strings) and (x, y) coordinates
189 // which represent column and line.
190 virtual long XYToPosition(long x
, long y
) const;
191 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
193 virtual void ShowPosition(long pos
);
195 // find the character at position given in pixels
197 // NB: pt is in device coords (not adjusted for the client area origin nor
199 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long *pos
) const;
200 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
202 wxTextCoord
*row
) const;
204 // Clipboard operations
207 virtual void Paste();
208 virtual void DeleteSelection();
210 virtual bool CanCopy() const;
211 virtual bool CanCut() const;
212 virtual bool CanPaste() const;
213 virtual bool CanDeleteSelection() const;
219 virtual bool CanUndo() const;
220 virtual bool CanRedo() const;
223 virtual void SetInsertionPoint(long pos
);
224 virtual void SetInsertionPointEnd();
225 virtual long GetInsertionPoint() const;
226 virtual wxTextPos
GetLastPosition() const;
228 virtual void SetSelection(long from
, long to
);
229 virtual void SelectAll();
230 virtual void SetEditable(bool editable
);
232 /// Call Freeze to prevent refresh
233 virtual void Freeze();
235 /// Call Thaw to refresh
238 /// Call Thaw to refresh
239 virtual bool IsFrozen() const { return m_freezeCount
> 0; }
241 virtual bool HasSelection() const;
243 ///// Functionality specific to wxRichTextCtrl
245 /// Write an image at the current insertion point. Supply optional type to use
246 /// for internal and file storage of the raw data.
247 virtual bool WriteImage(const wxImage
& image
, int bitmapType
= wxBITMAP_TYPE_PNG
);
249 /// Write a bitmap at the current insertion point. Supply optional type to use
250 /// for internal and file storage of the raw data.
251 virtual bool WriteImage(const wxBitmap
& bitmap
, int bitmapType
= wxBITMAP_TYPE_PNG
);
253 /// Load an image from file and write at the current insertion point.
254 virtual bool WriteImage(const wxString
& filename
, int bitmapType
);
256 /// Write an image block at the current insertion point.
257 virtual bool WriteImage(const wxRichTextImageBlock
& imageBlock
);
259 /// Insert a newline (actually paragraph) at the current insertion point.
260 virtual bool Newline();
262 /// Set basic (overall) style
263 virtual void SetBasicStyle(const wxTextAttrEx
& style
) { GetBuffer().SetBasicStyle(style
); }
264 virtual void SetBasicStyle(const wxRichTextAttr
& style
) { GetBuffer().SetBasicStyle(style
); }
266 /// Get basic (overall) style
267 virtual const wxTextAttrEx
& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
269 /// Begin using a style
270 virtual bool BeginStyle(const wxTextAttrEx
& style
) { return GetBuffer().BeginStyle(style
); }
273 virtual bool EndStyle() { return GetBuffer().EndStyle(); }
276 virtual bool EndAllStyles() { return GetBuffer().EndAllStyles(); }
279 bool BeginBold() { return GetBuffer().BeginBold(); }
282 bool EndBold() { return GetBuffer().EndBold(); }
284 /// Begin using italic
285 bool BeginItalic() { return GetBuffer().BeginItalic(); }
288 bool EndItalic() { return GetBuffer().EndItalic(); }
290 /// Begin using underline
291 bool BeginUnderline() { return GetBuffer().BeginUnderline(); }
293 /// End using underline
294 bool EndUnderline() { return GetBuffer().EndUnderline(); }
296 /// Begin using point size
297 bool BeginFontSize(int pointSize
) { return GetBuffer().BeginFontSize(pointSize
); }
299 /// End using point size
300 bool EndFontSize() { return GetBuffer().EndFontSize(); }
302 /// Begin using this font
303 bool BeginFont(const wxFont
& font
) { return GetBuffer().BeginFont(font
); }
306 bool EndFont() { return GetBuffer().EndFont(); }
308 /// Begin using this colour
309 bool BeginTextColour(const wxColour
& colour
) { return GetBuffer().BeginTextColour(colour
); }
311 /// End using a colour
312 bool EndTextColour() { return GetBuffer().EndTextColour(); }
314 /// Begin using alignment
315 bool BeginAlignment(wxTextAttrAlignment alignment
) { return GetBuffer().BeginAlignment(alignment
); }
318 bool EndAlignment() { return GetBuffer().EndAlignment(); }
320 /// Begin left indent
321 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0) { return GetBuffer().BeginLeftIndent(leftIndent
, leftSubIndent
); }
324 bool EndLeftIndent() { return GetBuffer().EndLeftIndent(); }
326 /// Begin right indent
327 bool BeginRightIndent(int rightIndent
) { return GetBuffer().BeginRightIndent(rightIndent
); }
330 bool EndRightIndent() { return GetBuffer().EndRightIndent(); }
332 /// Begin paragraph spacing
333 bool BeginParagraphSpacing(int before
, int after
) { return GetBuffer().BeginParagraphSpacing(before
, after
); }
335 /// End paragraph spacing
336 bool EndParagraphSpacing() { return GetBuffer().EndParagraphSpacing(); }
338 /// Begin line spacing
339 bool BeginLineSpacing(int lineSpacing
) { return GetBuffer().BeginLineSpacing(lineSpacing
); }
342 bool EndLineSpacing() { return GetBuffer().EndLineSpacing(); }
344 /// Begin numbered bullet
345 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
)
346 { return GetBuffer().BeginNumberedBullet(bulletNumber
, leftIndent
, leftSubIndent
, bulletStyle
); }
348 /// End numbered bullet
349 bool EndNumberedBullet() { return GetBuffer().EndNumberedBullet(); }
351 /// Begin symbol bullet
352 bool BeginSymbolBullet(wxChar symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
)
353 { return GetBuffer().BeginSymbolBullet(symbol
, leftIndent
, leftSubIndent
, bulletStyle
); }
355 /// End symbol bullet
356 bool EndSymbolBullet() { return GetBuffer().EndSymbolBullet(); }
358 /// Begin named character style
359 bool BeginCharacterStyle(const wxString
& characterStyle
) { return GetBuffer().BeginCharacterStyle(characterStyle
); }
361 /// End named character style
362 bool EndCharacterStyle() { return GetBuffer().EndCharacterStyle(); }
364 /// Begin named paragraph style
365 bool BeginParagraphStyle(const wxString
& paragraphStyle
) { return GetBuffer().BeginParagraphStyle(paragraphStyle
); }
367 /// End named character style
368 bool EndParagraphStyle() { return GetBuffer().EndParagraphStyle(); }
370 /// Sets the default style to the style under the cursor
371 bool SetDefaultStyleToCursorStyle();
373 /// Clear the selection
374 virtual void SelectNone();
376 /// Get/set the selection range in character positions. -1, -1 means no selection.
377 const wxRichTextRange
& GetSelectionRange() const { return m_selectionRange
; }
378 void SetSelectionRange(const wxRichTextRange
& range
) { m_selectionRange
= range
; }
380 /// Add a new paragraph of text to the end of the buffer
381 virtual wxRichTextRange
AddParagraph(const wxString
& text
);
384 virtual wxRichTextRange
AddImage(const wxImage
& image
);
386 /// Layout the buffer: which we must do before certain operations, such as
387 /// setting the caret position.
388 virtual bool LayoutContent(bool onlyVisibleRect
= false);
390 /// Move the caret to the given character position
391 virtual bool MoveCaret(long pos
, bool showAtLineStart
= false);
394 virtual bool MoveRight(int noPositions
= 1, int flags
= 0);
397 virtual bool MoveLeft(int noPositions
= 1, int flags
= 0);
400 virtual bool MoveUp(int noLines
= 1, int flags
= 0);
403 virtual bool MoveDown(int noLines
= 1, int flags
= 0);
405 /// Move to the end of the line
406 virtual bool MoveToLineEnd(int flags
= 0);
408 /// Move to the start of the line
409 virtual bool MoveToLineStart(int flags
= 0);
411 /// Move to the end of the paragraph
412 virtual bool MoveToParagraphEnd(int flags
= 0);
414 /// Move to the start of the paragraph
415 virtual bool MoveToParagraphStart(int flags
= 0);
417 /// Move to the start of the buffer
418 virtual bool MoveHome(int flags
= 0);
420 /// Move to the end of the buffer
421 virtual bool MoveEnd(int flags
= 0);
424 virtual bool PageUp(int noPages
= 1, int flags
= 0);
426 /// Move n pages down
427 virtual bool PageDown(int noPages
= 1, int flags
= 0);
429 /// Move n words left
430 virtual bool WordLeft(int noPages
= 1, int flags
= 0);
432 /// Move n words right
433 virtual bool WordRight(int noPages
= 1, int flags
= 0);
435 /// Returns the buffer associated with the control.
436 wxRichTextBuffer
& GetBuffer() { return m_buffer
; }
437 const wxRichTextBuffer
& GetBuffer() const { return m_buffer
; }
439 /// Start batching undo history for commands.
440 virtual bool BeginBatchUndo(const wxString
& cmdName
) { return m_buffer
.BeginBatchUndo(cmdName
); }
442 /// End batching undo history for commands.
443 virtual bool EndBatchUndo() { return m_buffer
.EndBatchUndo(); }
445 /// Are we batching undo history for commands?
446 virtual bool BatchingUndo() const { return m_buffer
.BatchingUndo(); }
448 /// Start suppressing undo history for commands.
449 virtual bool BeginSuppressUndo() { return m_buffer
.BeginSuppressUndo(); }
451 /// End suppressing undo history for commands.
452 virtual bool EndSuppressUndo() { return m_buffer
.EndSuppressUndo(); }
454 /// Are we suppressing undo history for commands?
455 virtual bool SuppressingUndo() const { return m_buffer
.SuppressingUndo(); }
457 /// Test if this whole range has character attributes of the specified kind. If any
458 /// of the attributes are different within the range, the test fails. You
459 /// can use this to implement, for example, bold button updating. style must have
460 /// flags indicating which attributes are of interest.
461 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const
463 return GetBuffer().HasCharacterAttributes(range
, style
);
465 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const
467 return GetBuffer().HasCharacterAttributes(range
, style
);
470 /// Test if this whole range has paragraph attributes of the specified kind. If any
471 /// of the attributes are different within the range, the test fails. You
472 /// can use this to implement, for example, centering button updating. style must have
473 /// flags indicating which attributes are of interest.
474 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const
476 return GetBuffer().HasParagraphAttributes(range
, style
);
478 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const
480 return GetBuffer().HasParagraphAttributes(range
, style
);
483 /// Is all of the selection bold?
484 virtual bool IsSelectionBold() const;
486 /// Is all of the selection italics?
487 virtual bool IsSelectionItalics() const;
489 /// Is all of the selection underlined?
490 virtual bool IsSelectionUnderlined() const;
492 /// Is all of the selection aligned according to the specified flag?
493 virtual bool IsSelectionAligned(wxTextAttrAlignment alignment
) const;
495 /// Apply bold to the selection
496 virtual bool ApplyBoldToSelection();
498 /// Apply italic to the selection
499 virtual bool ApplyItalicToSelection();
501 /// Apply underline to the selection
502 virtual bool ApplyUnderlineToSelection();
504 /// Apply alignment to the selection
505 virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment
);
507 /// Set style sheet, if any.
508 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { GetBuffer().SetStyleSheet(styleSheet
); }
509 wxRichTextStyleSheet
* GetStyleSheet() const { return GetBuffer().GetStyleSheet(); }
513 void Command(wxCommandEvent
& event
);
514 void OnDropFiles(wxDropFilesEvent
& event
);
516 void OnCut(wxCommandEvent
& event
);
517 void OnCopy(wxCommandEvent
& event
);
518 void OnPaste(wxCommandEvent
& event
);
519 void OnUndo(wxCommandEvent
& event
);
520 void OnRedo(wxCommandEvent
& event
);
521 void OnSelectAll(wxCommandEvent
& event
);
522 void OnClear(wxCommandEvent
& event
);
524 void OnUpdateCut(wxUpdateUIEvent
& event
);
525 void OnUpdateCopy(wxUpdateUIEvent
& event
);
526 void OnUpdatePaste(wxUpdateUIEvent
& event
);
527 void OnUpdateUndo(wxUpdateUIEvent
& event
);
528 void OnUpdateRedo(wxUpdateUIEvent
& event
);
529 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
530 void OnUpdateClear(wxUpdateUIEvent
& event
);
532 // Show a context menu for Rich Edit controls (the standard
533 // EDIT control has one already)
534 void OnContextMenu(wxContextMenuEvent
& event
);
539 void OnPaint(wxPaintEvent
& event
);
540 void OnEraseBackground(wxEraseEvent
& event
);
543 void OnLeftClick(wxMouseEvent
& event
);
546 void OnLeftUp(wxMouseEvent
& event
);
549 void OnMoveMouse(wxMouseEvent
& event
);
551 /// Left-double-click
552 void OnLeftDClick(wxMouseEvent
& event
);
555 void OnMiddleClick(wxMouseEvent
& event
);
558 void OnRightClick(wxMouseEvent
& event
);
561 void OnChar(wxKeyEvent
& event
);
564 void OnSize(wxSizeEvent
& event
);
566 /// Setting/losing focus
567 void OnSetFocus(wxFocusEvent
& event
);
568 void OnKillFocus(wxFocusEvent
& event
);
570 /// Idle-time processing
571 void OnIdle(wxIdleEvent
& event
);
574 void OnScroll(wxScrollWinEvent
& event
);
578 /// Set font, and also default attributes
579 virtual bool SetFont(const wxFont
& font
);
581 /// Set up scrollbars, e.g. after a resize
582 virtual void SetupScrollbars(bool atTop
= false);
584 /// Keyboard navigation
585 virtual bool KeyboardNavigate(int keyCode
, int flags
);
587 /// Paint the background
588 virtual void PaintBackground(wxDC
& dc
);
590 /// Recreate buffer bitmap if necessary
591 virtual bool RecreateBuffer(const wxSize
& size
= wxDefaultSize
);
593 /// Set the selection
594 virtual void DoSetSelection(long from
, long to
, bool scrollCaret
= true);
597 virtual void DoWriteText(const wxString
& value
, bool selectionOnly
= true);
599 /// Send an update event
600 virtual bool SendUpdateEvent();
602 /// Init command event
603 void InitCommandEvent(wxCommandEvent
& event
) const;
605 /// do the window-specific processing after processing the update event
606 // (duplicated code from wxTextCtrlBase)
607 #if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
608 virtual void DoUpdateWindowUI(wxUpdateUIEvent
& event
);
611 /// Should we inherit colours?
612 virtual bool ShouldInheritColours() const { return false; }
614 /// Position the caret
615 virtual void PositionCaret();
617 /// Extend the selection, returning true if the selection was
618 /// changed. Selections are in caret positions.
619 virtual bool ExtendSelection(long oldPosition
, long newPosition
, int flags
);
621 /// Scroll into view. This takes a _caret_ position.
622 virtual bool ScrollIntoView(long position
, int keyCode
);
624 /// The caret position is the character position just before the caret.
625 /// A value of -1 means the caret is at the start of the buffer.
626 void SetCaretPosition(long position
, bool showAtLineStart
= false) ;
627 long GetCaretPosition() const { return m_caretPosition
; }
629 /// Move caret one visual step forward: this may mean setting a flag
630 /// and keeping the same position if we're going from the end of one line
631 /// to the start of the next, which may be the exact same caret position.
632 void MoveCaretForward(long oldPosition
) ;
634 /// Move caret one visual step forward: this may mean setting a flag
635 /// and keeping the same position if we're going from the end of one line
636 /// to the start of the next, which may be the exact same caret position.
637 void MoveCaretBack(long oldPosition
) ;
639 /// Get the caret height and position for the given character position
640 bool GetCaretPositionForIndex(long position
, wxRect
& rect
);
642 /// Gets the line for the visible caret position. If the caret is
643 /// shown at the very end of the line, it means the next character is actually
644 /// on the following line. So let's get the line we're expecting to find
645 /// if this is the case.
646 wxRichTextLine
* GetVisibleLineForCaretPosition(long caretPosition
) const;
648 /// Gets the command processor
649 wxCommandProcessor
* GetCommandProcessor() const { return GetBuffer().GetCommandProcessor(); }
651 /// Delete content if there is a selection, e.g. when pressing a key.
652 /// Returns the new caret position in newPos, or leaves it if there
654 bool DeleteSelectedContent(long* newPos
= NULL
);
656 /// Transform logical to physical
657 wxPoint
GetPhysicalPoint(const wxPoint
& ptLogical
) const;
659 /// Transform physical to logical
660 wxPoint
GetLogicalPoint(const wxPoint
& ptPhysical
) const;
662 /// Finds the caret position for the next word. Direction
663 /// is 1 (forward) or -1 (backwards).
664 virtual long FindNextWordPosition(int direction
= 1) const;
666 /// Is the given position visible on the screen?
667 bool IsPositionVisible(long pos
) const;
669 /// Returns the first visible position in the current view
670 long GetFirstVisiblePosition() const;
672 #if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
673 WX_FORWARD_TO_SCROLL_HELPER()
679 virtual wxSize
DoGetBestSize() const ;
684 /// Allows nested Freeze/Thaw
688 wxBitmap m_bufferBitmap
;
691 wxRichTextBuffer m_buffer
;
696 wxMenu
* m_contextMenu
;
698 /// Caret position (1 less than the character position, so -1 is the
699 /// first caret position).
700 long m_caretPosition
;
702 /// Selection range in character positions. -2, -2 means no selection.
703 wxRichTextRange m_selectionRange
;
705 /// Anchor so we know how to extend the selection
706 /// It's a caret position since it's between two characters.
707 long m_selectionAnchor
;
712 /// Are we showing the caret position at the start of a line
713 /// instead of at the end of the previous one?
714 bool m_caretAtLineStart
;
716 /// Are we dragging a selection?
719 /// Start position for drag
722 /// Do we need full layout in idle?
723 bool m_fullLayoutRequired
;
724 wxLongLong m_fullLayoutTime
;
725 long m_fullLayoutSavedPosition
;
727 /// Threshold for doing delayed layout
728 long m_delayedLayoutThreshold
;
732 * wxRichTextEvent - the event class for wxRichTextCtrl notifications
735 class WXDLLIMPEXP_RICHTEXT wxRichTextEvent
: public wxNotifyEvent
738 wxRichTextEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
739 : wxNotifyEvent(commandType
, winid
),
740 m_itemIndex(-1), m_flags(0)
743 wxRichTextEvent(const wxRichTextEvent
& event
)
744 : wxNotifyEvent(event
),
745 m_itemIndex(event
.m_itemIndex
), m_flags(event
.m_flags
)
748 int GetIndex() const { return m_itemIndex
; }
749 void SetIndex(int n
) { m_itemIndex
= n
; }
751 int GetFlags() const { return m_flags
; }
752 void SetFlags(int flags
) { m_flags
= flags
; }
754 virtual wxEvent
*Clone() const { return new wxRichTextEvent(*this); }
761 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRichTextEvent
)
765 * wxRichTextCtrl event macros
768 BEGIN_DECLARE_EVENT_TYPES()
769 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED
, 2600)
770 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED
, 2601)
771 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_LEFT_CLICK
, 2602)
772 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK
, 2603)
773 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK
, 2604)
774 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK
, 2605)
775 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT
, wxEVT_COMMAND_RICHTEXT_RETURN
, 2606)
776 END_DECLARE_EVENT_TYPES()
778 typedef void (wxEvtHandler::*wxRichTextEventFunction
)(wxRichTextEvent
&);
780 #define EVT_RICHTEXT_ITEM_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
781 #define EVT_RICHTEXT_ITEM_DESELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
782 #define EVT_RICHTEXT_LEFT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
783 #define EVT_RICHTEXT_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
784 #define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
785 #define EVT_RICHTEXT_LEFT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
786 #define EVT_RICHTEXT_RETURN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ),
792 // _WX_RICHTEXTCTRL_H_