1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Classes for wxRichTExtCtrl and support classes
7 // Created: 11-April-2006
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
17 %module(package="wx", docstring=DOCSTRING) richtext
20 #include "wx/wxPython/wxPython.h"
21 #include "wx/wxPython/pyclasses.h"
22 #include "wx/wxPython/printfw.h"
23 #include "wx/wxPython/twoitem.h"
25 #include <wx/richtext/richtextctrl.h>
30 class wxBufferedPaintDC;
37 #define USE_TEXTATTREX 0
39 //----------------------------------------------------------------------
44 %pythoncode { wx = _core }
45 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
47 MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
49 //----------------------------------------------------------------------
55 wxRICHTEXT_SHIFT_DOWN,
71 wxRICHTEXT_FIXED_WIDTH,
72 wxRICHTEXT_FIXED_HEIGHT,
73 wxRICHTEXT_VARIABLE_WIDTH,
74 wxRICHTEXT_VARIABLE_HEIGHT,
77 wxRICHTEXT_HITTEST_NONE,
78 wxRICHTEXT_HITTEST_BEFORE,
79 wxRICHTEXT_HITTEST_AFTER,
80 wxRICHTEXT_HITTEST_ON,
83 wxRICHTEXT_UNFORMATTED,
86 // TODO: Rename these to be wxRICHTEXT_* ??
88 wxTEXT_ATTR_TEXT_COLOUR,
89 wxTEXT_ATTR_BACKGROUND_COLOUR,
90 wxTEXT_ATTR_FONT_FACE,
91 wxTEXT_ATTR_FONT_SIZE,
92 wxTEXT_ATTR_FONT_WEIGHT,
93 wxTEXT_ATTR_FONT_ITALIC,
94 wxTEXT_ATTR_FONT_UNDERLINE,
96 wxTEXT_ATTR_ALIGNMENT,
97 wxTEXT_ATTR_LEFT_INDENT,
98 wxTEXT_ATTR_RIGHT_INDENT,
101 wxTEXT_ATTR_PARA_SPACING_AFTER,
102 wxTEXT_ATTR_PARA_SPACING_BEFORE,
103 wxTEXT_ATTR_LINE_SPACING,
104 wxTEXT_ATTR_CHARACTER_STYLE_NAME,
105 wxTEXT_ATTR_PARAGRAPH_STYLE_NAME,
106 wxTEXT_ATTR_BULLET_STYLE,
107 wxTEXT_ATTR_BULLET_NUMBER,
108 wxTEXT_ATTR_BULLET_SYMBOL,
110 wxTEXT_ATTR_BULLET_STYLE_NONE,
111 wxTEXT_ATTR_BULLET_STYLE_ARABIC,
112 wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER,
113 wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER,
114 wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER,
115 wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER,
116 wxTEXT_ATTR_BULLET_STYLE_SYMBOL,
117 wxTEXT_ATTR_BULLET_STYLE_BITMAP,
118 wxTEXT_ATTR_BULLET_STYLE_PARENTHESES,
119 wxTEXT_ATTR_BULLET_STYLE_PERIOD,
121 wxTEXT_ATTR_LINE_SPACING_NORMAL,
122 wxTEXT_ATTR_LINE_SPACING_HALF,
123 wxTEXT_ATTR_LINE_SPACING_TWICE,
127 enum wxTextAttrAlignment
129 wxTEXT_ALIGNMENT_DEFAULT,
130 wxTEXT_ALIGNMENT_LEFT,
131 wxTEXT_ALIGNMENT_CENTRE,
132 wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE,
133 wxTEXT_ALIGNMENT_RIGHT,
134 wxTEXT_ALIGNMENT_JUSTIFIED
137 //----------------------------------------------------------------------
139 %typemap(in) wxRichTextRange& (wxRichTextRange temp) {
141 if ( ! wxRichTextRange_helper($input, &$1)) SWIG_fail;
143 %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxRichTextRange& {
144 $1 = wxPySimple_typecheck($input, wxT("wxRichTextRange"), 2);
150 bool wxRichTextRange_helper(PyObject* source, wxRichTextRange** obj)
152 if (source == Py_None) {
153 **obj = wxRICHTEXT_NONE;
156 return wxPyTwoIntItem_helper(source, obj, wxT("wxRichTextRange"));
162 DocStr(wxRichTextRange,
163 "RichTextRange is a data structure that represents a range of text
164 within a `RichTextCtrl`. It simply contains integer ``start`` and
165 ``end`` properties and a few operations useful for dealing with
166 ranges. In most places in wxPython where a RichTextRange is expected a
167 2-tuple containing (start, end) can be used instead.", "");
169 class wxRichTextRange
173 wxRichTextRange(long start=0, long end=0),
174 "Creates a new range object.", "");
180 DocStr(__eq__, "Test for equality of RichTextRange objects.", "");
181 bool __eq__(PyObject* other) {
182 wxRichTextRange temp, *obj = &temp;
183 if ( other == Py_None ) return false;
184 if ( ! wxRichTextRange_helper(other, &obj) ) {
188 return self->operator==(*obj);
194 wxRichTextRange , operator -(const wxRichTextRange& range) const,
198 wxRichTextRange , operator +(const wxRichTextRange& range) const,
203 void , SetRange(long start, long end),
208 void , SetStart(long start),
212 long , GetStart() const,
215 %pythoncode { start = property(GetStart, SetStart) }
218 void , SetEnd(long end),
222 long , GetEnd() const,
225 %pythoncode { end = property(GetEnd, SetEnd) }
229 bool , IsOutside(const wxRichTextRange& range) const,
230 "Returns true if this range is completely outside 'range'", "");
234 bool , IsWithin(const wxRichTextRange& range) const,
235 "Returns true if this range is completely within 'range'", "");
239 bool , Contains(long pos) const,
240 "Returns true if the given position is within this range. Allow for the
241 possibility of an empty range - assume the position is within this
246 bool , LimitTo(const wxRichTextRange& range) ,
247 "Limit this range to be within 'range'", "");
251 long , GetLength() const,
252 "Gets the length of the range", "");
257 "Swaps the start and end", "");
262 "Get() -> (start,end)",
263 "Returns the start and end properties as a tuple.", "");
265 wxPyBlock_t blocked = wxPyBeginBlockThreads();
266 PyObject* tup = PyTuple_New(2);
267 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetStart()));
268 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetEnd()));
269 wxPyEndBlockThreads(blocked);
274 def __str__(self): return str(self.Get())
275 def __repr__(self): return 'RichTextRange'+str(self.Get())
276 def __len__(self): return len(self.Get())
277 def __getitem__(self, index): return self.Get()[index]
278 def __setitem__(self, index, val):
279 if index == 0: self.start = val
280 elif index == 1: self.end = val
281 else: raise IndexError
282 def __nonzero__(self): return self.Get() != (0,0)
283 __safe_for_unpickling__ = True
284 def __reduce__(self): return (RichTextRange, self.Get())
291 wxRichTextRange wxPy_RTR_ALL(wxRICHTEXT_ALL);
292 wxRichTextRange wxPy_RTR_NONE(wxRICHTEXT_NONE);
295 %rename(RICHTEXT_ALL) wxPy_RTR_ALL;
296 %rename(RICHTEXT_NONE) wxPy_RTR_NONE;
299 wxRichTextRange wxPy_RTR_ALL;
300 wxRichTextRange wxPy_RTR_NONE;
303 //----------------------------------------------------------------------
305 DocStr(wxRichTextAttr,
306 "The RichTextAttr class stored information about the various attributes
307 for a block of text, including font, colour, indents, alignments, and
314 wxRichTextAttr(const wxColour& colText = wxNullColour,
315 const wxColour& colBack = wxNullColour,
316 wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
320 // // Making a wxTextAttrEx object.
321 // operator wxTextAttrEx () const ;
323 // // Copy to a wxTextAttr
324 // void CopyTo(wxTextAttrEx& attr) const;
328 // Create font from font attributes.
330 wxFont , CreateFont() const,
334 // Get attributes from font.
335 bool GetFontAttributes(const wxFont& font);
339 return self.CreateFont()
340 def SetFont(self, font):
341 return self.GetFontAttributes(font)
345 void SetTextColour(const wxColour& colText);
346 void SetBackgroundColour(const wxColour& colBack);
347 void SetAlignment(wxTextAttrAlignment alignment);
348 void SetTabs(const wxArrayInt& tabs);
349 void SetLeftIndent(int indent, int subIndent = 0);
350 void SetRightIndent(int indent);
352 void SetFontSize(int pointSize);
353 void SetFontStyle(int fontStyle);
354 void SetFontWeight(int fontWeight);
355 void SetFontFaceName(const wxString& faceName);
356 void SetFontUnderlined(bool underlined);
358 void SetFlags(long flags);
360 void SetCharacterStyleName(const wxString& name);
361 void SetParagraphStyleName(const wxString& name);
362 void SetParagraphSpacingAfter(int spacing);
363 void SetParagraphSpacingBefore(int spacing);
364 void SetLineSpacing(int spacing);
365 void SetBulletStyle(int style);
366 void SetBulletNumber(int n);
367 void SetBulletSymbol(wxChar symbol);
369 const wxColour& GetTextColour() const;
370 const wxColour& GetBackgroundColour() const;
371 wxTextAttrAlignment GetAlignment() const;
372 const wxArrayInt& GetTabs() const;
373 long GetLeftIndent() const;
374 long GetLeftSubIndent() const;
375 long GetRightIndent() const;
376 long GetFlags() const;
378 int GetFontSize() const;
379 int GetFontStyle() const;
380 int GetFontWeight() const;
381 bool GetFontUnderlined() const;
382 const wxString& GetFontFaceName() const;
384 const wxString& GetCharacterStyleName() const;
385 const wxString& GetParagraphStyleName() const;
386 int GetParagraphSpacingAfter() const;
387 int GetParagraphSpacingBefore() const;
388 int GetLineSpacing() const;
389 int GetBulletStyle() const;
390 int GetBulletNumber() const { return m_bulletNumber; }
391 wxChar GetBulletSymbol() const;
394 bool HasTextColour() const;
395 bool HasBackgroundColour() const;
396 bool HasAlignment() const;
397 bool HasTabs() const;
398 bool HasLeftIndent() const;
399 bool HasRightIndent() const;
400 bool HasWeight() const;
401 bool HasSize() const;
402 bool HasItalic() const;
403 bool HasUnderlined() const;
404 bool HasFaceName() const;
405 bool HasFont() const;
407 bool HasParagraphSpacingAfter() const;
408 bool HasParagraphSpacingBefore() const;
409 bool HasLineSpacing() const;
410 bool HasCharacterStyleName() const;
411 bool HasParagraphStyleName() const;
412 bool HasBulletStyle() const;
413 bool HasBulletNumber() const;
414 bool HasBulletSymbol() const;
416 bool HasFlag(long flag) const;
418 // Is this a character style?
419 bool IsCharacterStyle() const;
420 bool IsParagraphStyle() const;
422 // returns false if we have any attributes set, true otherwise
423 bool IsDefault() const;
426 // // return the attribute having the valid font and colours: it uses the
427 // // attributes set in attr and falls back first to attrDefault and then to
428 // // the text control font/colours for those attributes which are not set
429 // static wxRichTextAttr Combine(const wxRichTextAttr& attr,
430 // const wxRichTextAttr& attrDef,
431 // const wxTextCtrlBase *text);
436 wxTEXT_ATTR_CHARACTER,
437 wxTEXT_ATTR_PARAGRAPH,
442 //----------------------------------------------------------------------
443 //----------------------------------------------------------------------
445 MustHaveApp(wxRichTextCtrl);
446 DocStr(wxRichTextCtrl,
449 class wxRichTextCtrl : public wxScrolledWindow
452 %pythonAppend wxRichTextCtrl "self._setOORInfo(self)"
453 %pythonAppend wxRichTextCtrl() ""
455 wxRichTextCtrl( wxWindow* parent,
457 const wxPoint& pos = wxDefaultPosition,
458 const wxSize& size = wxDefaultSize,
459 long style = wxRE_MULTILINE );
460 %RenameCtor(PreRichTextCtrl, wxRichTextCtrl());
463 bool Create( wxWindow* parent,
465 const wxPoint& pos = wxDefaultPosition,
466 const wxSize& size = wxDefaultSize,
467 long style = wxRE_MULTILINE );
471 virtual wxString , GetValue() const,
475 virtual void , SetValue(const wxString& value),
480 virtual wxString , GetRange(long from, long to) const,
485 virtual int , GetLineLength(long lineNo) const ,
489 virtual wxString , GetLineText(long lineNo) const ,
493 virtual int , GetNumberOfLines() const ,
498 virtual bool , IsModified() const ,
502 virtual bool , IsEditable() const ,
506 // more readable flag testing methods
508 bool , IsSingleLine() const,
512 bool , IsMultiLine() const,
517 virtual void , GetSelection(long* OUTPUT, long* OUTPUT) const,
518 "GetSelection() --> (start, end)",
519 "Returns the start and end positions of the current selection. If the
520 values are the same then there is no selection.", "");
524 virtual wxString , GetStringSelection() const,
529 wxString , GetFilename() const,
534 void , SetFilename(const wxString& filename),
539 void , SetDelayedLayoutThreshold(long threshold),
540 "Set the threshold in character positions for doing layout optimization
541 during sizing.", "");
545 long , GetDelayedLayoutThreshold() const,
546 "Get the threshold in character positions for doing layout optimization
547 during sizing.", "");
552 virtual void , Clear(),
556 virtual void , Replace(long from, long to, const wxString& value),
560 virtual void , Remove(long from, long to),
565 virtual bool , LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY),
566 "Load the contents of the document from the given filename.", "");
569 virtual bool , SaveFile(const wxString& file = wxPyEmptyString,
570 int type = wxRICHTEXT_TYPE_ANY),
571 "Save the contents of the document to the given filename, or if the
572 empty string is passed then to the filename set with `SetFileName`.", "");
575 // sets/clears the dirty flag
577 virtual void , MarkDirty(),
578 "Sets the dirty flag, meaning that the contents of the control have
579 changed and need to be saved.", "");
582 virtual void , DiscardEdits(),
583 "Clears the dirty flag.
584 :see: `MarkDirty`", "");
588 virtual void , SetMaxLength(unsigned long len),
589 "Set the max number of characters which may be entered in a single line
594 virtual void , WriteText(const wxString& text),
595 "Insert text at the current position.", "");
598 virtual void , AppendText(const wxString& text),
599 "Append text to the end of the document.", "");
603 virtual bool , SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style),
604 "Set the style for the text in ``range`` to ``style``", "");
607 virtual bool , GetStyle(long position, wxRichTextAttr& style) const,
608 "Retrieve the style used at the given position. Copies the style
609 values at ``position`` into the ``style`` parameter returns ``True``
610 if successful. Returns ``False`` otherwise.", "");
614 virtual bool , SetDefaultStyle(const wxRichTextAttr& style),
615 "Set the style used by default for the rich text document.", "");
619 virtual const wxRichTextAttr , GetDefaultStyleEx() const,
620 "Retrieves a copy of the default style object.", "",
625 virtual long , XYToPosition(long x, long y) const,
626 "Translate a col,row coordinants into a document position.", "");
629 virtual void , PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const,
630 "PositionToXY(self, long pos) --> (x, y)",
631 "Retrieves the col,row for the given position within the document", "");
635 virtual void , ShowPosition(long position),
636 "Ensure that the given position in the document is visible.", "");
640 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const,
641 "HitTest(self, Point pt) --> (result, pos)",
642 "Returns the character position at the given point in pixels. Note
643 that ``pt`` should be given in device coordinates, and not be adjusted
644 for the client area origin nor for scrolling. The return value is a
645 tuple of the hit test result and the position.", "
647 Possible result values are a bitmask of these flags:
649 ========================= ====================================
650 RICHTEXT_HITTEST_NONE The point was not on this object.
651 RICHTEXT_HITTEST_BEFORE The point was before the position
652 returned from HitTest.
653 RICHTEXT_HITTEST_AFTER The point was after the position
654 returned from HitTest.
655 RICHTEXT_HITTEST_ON The point was on the position
656 returned from HitTest
657 ========================= ====================================
661 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt,
663 wxTextCoord *OUTPUT) const,
664 "HitTestRC(self, Point pt) --> (result, col, row)",
665 "Returns the column and row of the given point in pixels. Note that
666 ``pt`` should be given in device coordinates, and not be adjusted for
667 the client area origin nor for scrolling. The return value is a tuple
668 of the hit test result and the column and row values.", "
673 // Clipboard operations
675 virtual void , Copy(),
676 "Copies the selected text to the clipboard.", "");
679 virtual void , Cut(),
680 "Copies the selected text to the clipboard and removes the selection.", "");
683 virtual void , Paste(),
684 "Pastes text from the clipboard into the document at the current
685 insertion point.", "");
688 virtual void , DeleteSelection(),
689 "Remove the current selection.", "");
693 virtual bool , CanCopy() const,
694 "Returns ``True`` if the selection can be copied to the clipboard.", "");
697 virtual bool , CanCut() const,
698 "Returns ``True`` if the selection can be cut to the clipboard.", "");
701 virtual bool , CanPaste() const,
702 "Returns ``True`` if the current contents of the clipboard can be
703 pasted into the document.", "");
706 virtual bool , CanDeleteSelection() const,
707 "Returns ``True`` if the selection can be removed from the document.", "");
712 virtual void , Undo(),
713 "If the last operation can be undone, undoes the last operation.", "");
716 virtual void , Redo(),
717 "If the last operation can be redone, redoes the last operation.", "");
721 virtual bool , CanUndo() const,
722 "Returns ``True`` if the last operation can be undone.", "");
725 virtual bool , CanRedo() const,
726 "Returns ``True`` if the last operation can be redone.", "");
731 virtual void , SetInsertionPoint(long pos),
732 "Sets the insertion point at the given position.", "");
735 virtual void , SetInsertionPointEnd(),
736 "Moves the insertion point to the end of the document.", "");
739 virtual long , GetInsertionPoint() const,
740 "Returns the insertion point. This is defined as the zero based index
741 of the character position to the right of the insertion point.", "");
744 virtual long , GetLastPosition() const,
745 "Returns the zero based index of the last position in the document.", "");
749 virtual void , SetSelection(long from, long to),
750 "Selects the text starting at the first position up to (but not
751 including) the character at the last position. If both parameters are
752 equal to -1 then all text in the control is selected.", "");
755 virtual void , SelectAll(),
756 "Select all text in the document.", "");
759 virtual void , SetEditable(bool editable),
760 "Makes the document editable or read-only, overriding the RE_READONLY
764 // /// Call Freeze to prevent refresh
765 // virtual void Freeze();
767 // /// Call Thaw to refresh
768 // virtual void Thaw();
770 // /// Call Thaw to refresh
772 // virtual bool , IsFrozen() const,
777 virtual bool , HasSelection() const,
781 ///// Functionality specific to wxRichTextCtrl
783 /// Write an image at the current insertion point. Supply optional type to use
784 /// for internal and file storage of the raw data.
786 virtual bool , WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG),
790 /// Write a bitmap at the current insertion point. Supply optional type to use
791 /// for internal and file storage of the raw data.
793 virtual bool , WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG),
798 /// Load an image from file and write at the current insertion point.
800 virtual bool , WriteImage(const wxString& filename, int bitmapType),
805 /// Write an image block at the current insertion point.
807 virtual bool , WriteImage(const wxRichTextImageBlock& imageBlock),
812 /// Insert a newline (actually paragraph) at the current insertion point.
814 virtual bool , Newline(),
819 /// Set basic (overall) style
821 virtual void , SetBasicStyle(const wxTextAttrEx& style),
826 virtual void , SetBasicStyle(const wxRichTextAttr& style),
831 /// Get basic (overall) style
833 virtual const wxTextAttrEx& , GetBasicStyle() const,
837 /// Begin using a style
839 virtual bool , BeginStyle(const wxTextAttrEx& style),
845 virtual bool , EndStyle(),
851 virtual bool , EndAllStyles(),
867 /// Begin using italic
869 bool , BeginItalic(),
879 /// Begin using underline
881 bool , BeginUnderline(),
885 /// End using underline
887 bool , EndUnderline(),
891 /// Begin using point size
893 bool , BeginFontSize(int pointSize),
897 /// End using point size
899 bool , EndFontSize(),
903 /// Begin using this font
905 bool , BeginFont(const wxFont& font),
915 /// Begin using this colour
917 bool , BeginTextColour(const wxColour& colour),
921 /// End using a colour
923 bool , EndTextColour(),
927 /// Begin using alignment
929 bool , BeginAlignment(wxTextAttrAlignment alignment),
935 bool , EndAlignment(),
939 /// Begin left indent
941 bool , BeginLeftIndent(int leftIndent, int leftSubIndent = 0),
947 bool , EndLeftIndent(),
951 /// Begin right indent
953 bool , BeginRightIndent(int rightIndent),
959 bool , EndRightIndent(),
963 /// Begin paragraph spacing
965 bool , BeginParagraphSpacing(int before, int after),
969 /// End paragraph spacing
971 bool , EndParagraphSpacing(),
975 /// Begin line spacing
977 bool , BeginLineSpacing(int lineSpacing),
983 bool , EndLineSpacing(),
987 /// Begin numbered bullet
989 bool , BeginNumberedBullet(int bulletNumber,
992 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD),
996 /// End numbered bullet
998 bool , EndNumberedBullet(),
1002 /// Begin symbol bullet
1004 bool , BeginSymbolBullet(char symbol,
1007 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL),
1011 /// End symbol bullet
1013 bool , EndSymbolBullet(),
1017 /// Begin named character style
1019 bool , BeginCharacterStyle(const wxString& characterStyle),
1023 /// End named character style
1025 bool , EndCharacterStyle(),
1029 /// Begin named paragraph style
1031 bool , BeginParagraphStyle(const wxString& paragraphStyle),
1035 /// End named character style
1037 bool , EndParagraphStyle(),
1041 /// Sets the default style to the style under the cursor
1043 bool , SetDefaultStyleToCursorStyle(),
1047 /// Clear the selection
1049 virtual void , SelectNone(),
1053 /// Get/set the selection range in character positions. -1, -1 means no selection.
1055 const wxRichTextRange& , GetSelectionRange() const,
1059 void , SetSelectionRange(const wxRichTextRange& range),
1063 /// Add a new paragraph of text to the end of the buffer
1065 virtual wxRichTextRange , AddParagraph(const wxString& text),
1071 virtual wxRichTextRange , AddImage(const wxImage& image),
1075 /// Layout the buffer: which we must do before certain operations, such as
1076 /// setting the caret position.
1078 virtual bool , LayoutContent(bool onlyVisibleRect = false),
1082 /// Move the caret to the given character position
1084 virtual bool , MoveCaret(long pos, bool showAtLineStart = false),
1090 virtual bool , MoveRight(int noPositions = 1, int flags = 0),
1096 virtual bool , MoveLeft(int noPositions = 1, int flags = 0),
1102 virtual bool , MoveUp(int noLines = 1, int flags = 0),
1108 virtual bool , MoveDown(int noLines = 1, int flags = 0),
1112 /// Move to the end of the line
1114 virtual bool , MoveToLineEnd(int flags = 0),
1118 /// Move to the start of the line
1120 virtual bool , MoveToLineStart(int flags = 0),
1124 /// Move to the end of the paragraph
1126 virtual bool , MoveToParagraphEnd(int flags = 0),
1130 /// Move to the start of the paragraph
1132 virtual bool , MoveToParagraphStart(int flags = 0),
1136 /// Move to the start of the buffer
1138 virtual bool , MoveHome(int flags = 0),
1142 /// Move to the end of the buffer
1144 virtual bool , MoveEnd(int flags = 0),
1150 virtual bool , PageUp(int noPages = 1, int flags = 0),
1154 /// Move n pages down
1156 virtual bool , PageDown(int noPages = 1, int flags = 0),
1160 /// Move n words left
1162 virtual bool , WordLeft(int noPages = 1, int flags = 0),
1166 /// Move n words right
1168 virtual bool , WordRight(int noPages = 1, int flags = 0),
1172 /// Returns the buffer associated with the control.
1173 // wxRichTextBuffer& GetBuffer();
1175 const wxRichTextBuffer& , GetBuffer() const,
1179 /// Start batching undo history for commands.
1181 virtual bool , BeginBatchUndo(const wxString& cmdName),
1185 /// End batching undo history for commands.
1187 virtual bool , EndBatchUndo(),
1191 /// Are we batching undo history for commands?
1193 virtual bool , BatchingUndo() const,
1197 /// Start suppressing undo history for commands.
1199 virtual bool , BeginSuppressUndo(),
1203 /// End suppressing undo history for commands.
1205 virtual bool , EndSuppressUndo(),
1209 /// Are we suppressing undo history for commands?
1211 virtual bool , SuppressingUndo() const,
1215 /// Test if this whole range has character attributes of the specified kind. If any
1216 /// of the attributes are different within the range, the test fails. You
1217 /// can use this to implement, for example, bold button updating. style must have
1218 /// flags indicating which attributes are of interest.
1221 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1222 const wxTextAttrEx& style) const,
1227 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1228 const wxRichTextAttr& style) const,
1233 /// Test if this whole range has paragraph attributes of the specified kind. If any
1234 /// of the attributes are different within the range, the test fails. You
1235 /// can use this to implement, for example, centering button updating. style must have
1236 /// flags indicating which attributes are of interest.
1239 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1240 const wxTextAttrEx& style) const,
1245 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1246 const wxRichTextAttr& style) const,
1251 /// Is all of the selection bold?
1253 virtual bool , IsSelectionBold() const,
1257 /// Is all of the selection italics?
1259 virtual bool , IsSelectionItalics() const,
1263 /// Is all of the selection underlined?
1265 virtual bool , IsSelectionUnderlined() const,
1269 /// Is all of the selection aligned according to the specified flag?
1271 virtual bool , IsSelectionAligned(wxTextAttrAlignment alignment) const,
1275 /// Apply bold to the selection
1277 virtual bool , ApplyBoldToSelection(),
1281 /// Apply italic to the selection
1283 virtual bool , ApplyItalicToSelection(),
1287 /// Apply underline to the selection
1289 virtual bool , ApplyUnderlineToSelection(),
1293 /// Apply alignment to the selection
1295 virtual bool , ApplyAlignmentToSelection(wxTextAttrAlignment alignment),
1299 /// Set style sheet, if any.
1301 void , SetStyleSheet(wxRichTextStyleSheet* styleSheet),
1305 wxRichTextStyleSheet* , GetStyleSheet() const,
1311 // TODO: Which of these should be exposed to Python?
1313 // /// Set font, and also default attributes
1314 // virtual bool SetFont(const wxFont& font);
1316 // /// Set up scrollbars, e.g. after a resize
1317 // virtual void SetupScrollbars(bool atTop = false);
1319 // /// Keyboard navigation
1320 // virtual bool KeyboardNavigate(int keyCode, int flags);
1322 // /// Paint the background
1323 // virtual void PaintBackground(wxDC& dc);
1325 // /// Recreate buffer bitmap if necessary
1326 // virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1328 // /// Set the selection
1329 // virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
1332 // virtual void DoWriteText(const wxString& value, bool selectionOnly = true);
1334 // /// Send an update event
1335 // virtual bool SendUpdateEvent();
1337 // /// Init command event
1338 // void InitCommandEvent(wxCommandEvent& event) const;
1340 // /// do the window-specific processing after processing the update event
1341 // // (duplicated code from wxTextCtrlBase)
1342 // #if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
1343 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
1346 // /// Should we inherit colours?
1347 // virtual bool ShouldInheritColours() const;
1349 // /// Position the caret
1350 // virtual void PositionCaret();
1352 // /// Extend the selection, returning true if the selection was
1353 // /// changed. Selections are in caret positions.
1354 // virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1356 // /// Scroll into view. This takes a _caret_ position.
1357 // virtual bool ScrollIntoView(long position, int keyCode);
1359 // /// The caret position is the character position just before the caret.
1360 // /// A value of -1 means the caret is at the start of the buffer.
1361 // void SetCaretPosition(long position, bool showAtLineStart = false) ;
1362 // long GetCaretPosition() const;
1364 // /// Move caret one visual step forward: this may mean setting a flag
1365 // /// and keeping the same position if we're going from the end of one line
1366 // /// to the start of the next, which may be the exact same caret position.
1367 // void MoveCaretForward(long oldPosition) ;
1369 // /// Move caret one visual step forward: this may mean setting a flag
1370 // /// and keeping the same position if we're going from the end of one line
1371 // /// to the start of the next, which may be the exact same caret position.
1372 // void MoveCaretBack(long oldPosition) ;
1374 // /// Get the caret height and position for the given character position
1375 // bool GetCaretPositionForIndex(long position, wxRect& rect);
1377 // /// Gets the line for the visible caret position. If the caret is
1378 // /// shown at the very end of the line, it means the next character is actually
1379 // /// on the following line. So let's get the line we're expecting to find
1380 // /// if this is the case.
1381 // wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1383 // /// Gets the command processor
1384 // wxCommandProcessor* GetCommandProcessor() const;
1386 // /// Delete content if there is a selection, e.g. when pressing a key.
1387 // /// Returns the new caret position in newPos, or leaves it if there
1388 // /// was no action.
1389 // bool DeleteSelectedContent(long* newPos= NULL);
1391 // /// Transform logical to physical
1392 // wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
1394 // /// Transform physical to logical
1395 // wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
1397 // /// Finds the caret position for the next word. Direction
1398 // /// is 1 (forward) or -1 (backwards).
1399 // virtual long FindNextWordPosition(int direction = 1) const;
1401 // /// Is the given position visible on the screen?
1402 // bool IsPositionVisible(long pos) const;
1404 // /// Returns the first visible position in the current view
1405 // long GetFirstVisiblePosition() const;
1409 //----------------------------------------------------------------------
1412 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED;
1413 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED;
1414 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_CLICK;
1415 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK;
1416 %constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK;
1417 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK;
1418 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN;
1422 EVT_RICHTEXT_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 1)
1423 EVT_RICHTEXT_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 1)
1424 EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 1)
1425 EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 1)
1426 EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1)
1427 EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1)
1428 EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1)
1432 class wxRichTextEvent : public wxNotifyEvent
1435 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
1437 int GetIndex() const;
1438 void SetIndex(int n);
1440 int GetFlags() const;
1441 void SetFlags(int flags);
1444 //----------------------------------------------------------------------
1449 //----------------------------------------------------------------------