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;
429 wxTEXT_ATTR_CHARACTER,
430 wxTEXT_ATTR_PARAGRAPH,
435 //----------------------------------------------------------------------
436 //----------------------------------------------------------------------
438 MustHaveApp(wxRichTextCtrl);
439 DocStr(wxRichTextCtrl,
442 class wxRichTextCtrl : public wxScrolledWindow
445 %pythonAppend wxRichTextCtrl "self._setOORInfo(self)"
446 %pythonAppend wxRichTextCtrl() ""
448 wxRichTextCtrl( wxWindow* parent,
450 const wxPoint& pos = wxDefaultPosition,
451 const wxSize& size = wxDefaultSize,
452 long style = wxRE_MULTILINE );
453 %RenameCtor(PreRichTextCtrl, wxRichTextCtrl());
456 bool Create( wxWindow* parent,
458 const wxPoint& pos = wxDefaultPosition,
459 const wxSize& size = wxDefaultSize,
460 long style = wxRE_MULTILINE );
464 virtual wxString , GetValue() const,
468 virtual void , SetValue(const wxString& value),
473 virtual wxString , GetRange(long from, long to) const,
478 virtual int , GetLineLength(long lineNo) const ,
482 virtual wxString , GetLineText(long lineNo) const ,
486 virtual int , GetNumberOfLines() const ,
491 virtual bool , IsModified() const ,
495 virtual bool , IsEditable() const ,
499 // more readable flag testing methods
501 bool , IsSingleLine() const,
505 bool , IsMultiLine() const,
510 virtual void , GetSelection(long* OUTPUT, long* OUTPUT) const,
511 "GetSelection() --> (start, end)",
512 "Returns the start and end positions of the current selection. If the
513 values are the same then there is no selection.", "");
517 virtual wxString , GetStringSelection() const,
522 wxString , GetFilename() const,
527 void , SetFilename(const wxString& filename),
532 void , SetDelayedLayoutThreshold(long threshold),
533 "Set the threshold in character positions for doing layout optimization
534 during sizing.", "");
538 long , GetDelayedLayoutThreshold() const,
539 "Get the threshold in character positions for doing layout optimization
540 during sizing.", "");
545 virtual void , Clear(),
549 virtual void , Replace(long from, long to, const wxString& value),
553 virtual void , Remove(long from, long to),
558 virtual bool , LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY),
559 "Load the contents of the document from the given filename.", "");
562 virtual bool , SaveFile(const wxString& file = wxPyEmptyString,
563 int type = wxRICHTEXT_TYPE_ANY),
564 "Save the contents of the document to the given filename, or if the
565 empty string is passed then to the filename set with `SetFileName`.", "");
568 // sets/clears the dirty flag
570 virtual void , MarkDirty(),
571 "Sets the dirty flag, meaning that the contents of the control have
572 changed and need to be saved.", "");
575 virtual void , DiscardEdits(),
576 "Clears the dirty flag.
577 :see: `MarkDirty`", "");
581 virtual void , SetMaxLength(unsigned long len),
582 "Set the max number of characters which may be entered in a single line
587 virtual void , WriteText(const wxString& text),
588 "Insert text at the current position.", "");
591 virtual void , AppendText(const wxString& text),
592 "Append text to the end of the document.", "");
596 virtual bool , SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style),
597 "Set the style for the text in ``range`` to ``style``", "");
600 virtual bool , GetStyle(long position, wxRichTextAttr& style) const,
601 "Retrieve the style used at the given position. Copies the style
602 values at ``position`` into the ``style`` parameter returns ``True``
603 if successful. Returns ``False`` otherwise.", "");
607 virtual bool , SetDefaultStyle(const wxRichTextAttr& style),
608 "Set the style used by default for the rich text document.", "");
612 virtual const wxRichTextAttr , GetDefaultStyleEx() const,
613 "Retrieves a copy of the default style object.", "",
618 virtual long , XYToPosition(long x, long y) const,
619 "Translate a col,row coordinants into a document position.", "");
622 virtual void , PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const,
623 "PositionToXY(self, long pos) --> (x, y)",
624 "Retrieves the col,row for the given position within the document", "");
628 virtual void , ShowPosition(long position),
629 "Ensure that the given position in the document is visible.", "");
633 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const,
634 "HitTest(self, Point pt) --> (result, pos)",
635 "Returns the character position at the given point in pixels. Note
636 that ``pt`` should be given in device coordinates, and not be adjusted
637 for the client area origin nor for scrolling. The return value is a
638 tuple of the hit test result and the position.", "
640 Possible result values are a bitmask of these flags:
642 ========================= ====================================
643 RICHTEXT_HITTEST_NONE The point was not on this object.
644 RICHTEXT_HITTEST_BEFORE The point was before the position
645 returned from HitTest.
646 RICHTEXT_HITTEST_AFTER The point was after the position
647 returned from HitTest.
648 RICHTEXT_HITTEST_ON The point was on the position
649 returned from HitTest
650 ========================= ====================================
654 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt,
656 wxTextCoord *OUTPUT) const,
657 "HitTestRC(self, Point pt) --> (result, col, row)",
658 "Returns the column and row of the given point in pixels. Note that
659 ``pt`` should be given in device coordinates, and not be adjusted for
660 the client area origin nor for scrolling. The return value is a tuple
661 of the hit test result and the column and row values.", "
666 // Clipboard operations
668 virtual void , Copy(),
669 "Copies the selected text to the clipboard.", "");
672 virtual void , Cut(),
673 "Copies the selected text to the clipboard and removes the selection.", "");
676 virtual void , Paste(),
677 "Pastes text from the clipboard into the document at the current
678 insertion point.", "");
681 virtual void , DeleteSelection(),
682 "Remove the current selection.", "");
686 virtual bool , CanCopy() const,
687 "Returns ``True`` if the selection can be copied to the clipboard.", "");
690 virtual bool , CanCut() const,
691 "Returns ``True`` if the selection can be cut to the clipboard.", "");
694 virtual bool , CanPaste() const,
695 "Returns ``True`` if the current contents of the clipboard can be
696 pasted into the document.", "");
699 virtual bool , CanDeleteSelection() const,
700 "Returns ``True`` if the selection can be removed from the document.", "");
705 virtual void , Undo(),
706 "If the last operation can be undone, undoes the last operation.", "");
709 virtual void , Redo(),
710 "If the last operation can be redone, redoes the last operation.", "");
714 virtual bool , CanUndo() const,
715 "Returns ``True`` if the last operation can be undone.", "");
718 virtual bool , CanRedo() const,
719 "Returns ``True`` if the last operation can be redone.", "");
724 virtual void , SetInsertionPoint(long pos),
725 "Sets the insertion point at the given position.", "");
728 virtual void , SetInsertionPointEnd(),
729 "Moves the insertion point to the end of the document.", "");
732 virtual long , GetInsertionPoint() const,
733 "Returns the insertion point. This is defined as the zero based index
734 of the character position to the right of the insertion point.", "");
737 virtual long , GetLastPosition() const,
738 "Returns the zero based index of the last position in the document.", "");
742 virtual void , SetSelection(long from, long to),
743 "Selects the text starting at the first position up to (but not
744 including) the character at the last position. If both parameters are
745 equal to -1 then all text in the control is selected.", "");
748 virtual void , SelectAll(),
749 "Select all text in the document.", "");
752 virtual void , SetEditable(bool editable),
753 "Makes the document editable or read-only, overriding the RE_READONLY
757 // /// Call Freeze to prevent refresh
758 // virtual void Freeze();
760 // /// Call Thaw to refresh
761 // virtual void Thaw();
763 // /// Call Thaw to refresh
765 // virtual bool , IsFrozen() const,
770 virtual bool , HasSelection() const,
774 ///// Functionality specific to wxRichTextCtrl
776 /// Write an image at the current insertion point. Supply optional type to use
777 /// for internal and file storage of the raw data.
779 virtual bool , WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG),
783 /// Write a bitmap 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 wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG),
791 /// Load an image from file and write at the current insertion point.
793 virtual bool , WriteImage(const wxString& filename, int bitmapType),
798 /// Write an image block at the current insertion point.
800 virtual bool , WriteImage(const wxRichTextImageBlock& imageBlock),
805 /// Insert a newline (actually paragraph) at the current insertion point.
807 virtual bool , Newline(),
812 /// Set basic (overall) style
814 virtual void , SetBasicStyle(const wxTextAttrEx& style),
819 virtual void , SetBasicStyle(const wxRichTextAttr& style),
824 /// Get basic (overall) style
826 virtual const wxTextAttrEx& , GetBasicStyle() const,
830 /// Begin using a style
832 virtual bool , BeginStyle(const wxTextAttrEx& style),
838 virtual bool , EndStyle(),
844 virtual bool , EndAllStyles(),
860 /// Begin using italic
862 bool , BeginItalic(),
872 /// Begin using underline
874 bool , BeginUnderline(),
878 /// End using underline
880 bool , EndUnderline(),
884 /// Begin using point size
886 bool , BeginFontSize(int pointSize),
890 /// End using point size
892 bool , EndFontSize(),
896 /// Begin using this font
898 bool , BeginFont(const wxFont& font),
908 /// Begin using this colour
910 bool , BeginTextColour(const wxColour& colour),
914 /// End using a colour
916 bool , EndTextColour(),
920 /// Begin using alignment
922 bool , BeginAlignment(wxTextAttrAlignment alignment),
928 bool , EndAlignment(),
932 /// Begin left indent
934 bool , BeginLeftIndent(int leftIndent, int leftSubIndent = 0),
940 bool , EndLeftIndent(),
944 /// Begin right indent
946 bool , BeginRightIndent(int rightIndent),
952 bool , EndRightIndent(),
956 /// Begin paragraph spacing
958 bool , BeginParagraphSpacing(int before, int after),
962 /// End paragraph spacing
964 bool , EndParagraphSpacing(),
968 /// Begin line spacing
970 bool , BeginLineSpacing(int lineSpacing),
976 bool , EndLineSpacing(),
980 /// Begin numbered bullet
982 bool , BeginNumberedBullet(int bulletNumber,
985 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD),
989 /// End numbered bullet
991 bool , EndNumberedBullet(),
995 /// Begin symbol bullet
997 bool , BeginSymbolBullet(char symbol,
1000 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL),
1004 /// End symbol bullet
1006 bool , EndSymbolBullet(),
1010 /// Begin named character style
1012 bool , BeginCharacterStyle(const wxString& characterStyle),
1016 /// End named character style
1018 bool , EndCharacterStyle(),
1022 /// Begin named paragraph style
1024 bool , BeginParagraphStyle(const wxString& paragraphStyle),
1028 /// End named character style
1030 bool , EndParagraphStyle(),
1034 /// Sets the default style to the style under the cursor
1036 bool , SetDefaultStyleToCursorStyle(),
1040 /// Clear the selection
1042 virtual void , SelectNone(),
1046 /// Get/set the selection range in character positions. -1, -1 means no selection.
1048 const wxRichTextRange& , GetSelectionRange() const,
1052 void , SetSelectionRange(const wxRichTextRange& range),
1056 /// Add a new paragraph of text to the end of the buffer
1058 virtual wxRichTextRange , AddParagraph(const wxString& text),
1064 virtual wxRichTextRange , AddImage(const wxImage& image),
1068 /// Layout the buffer: which we must do before certain operations, such as
1069 /// setting the caret position.
1071 virtual bool , LayoutContent(bool onlyVisibleRect = false),
1075 /// Move the caret to the given character position
1077 virtual bool , MoveCaret(long pos, bool showAtLineStart = false),
1083 virtual bool , MoveRight(int noPositions = 1, int flags = 0),
1089 virtual bool , MoveLeft(int noPositions = 1, int flags = 0),
1095 virtual bool , MoveUp(int noLines = 1, int flags = 0),
1101 virtual bool , MoveDown(int noLines = 1, int flags = 0),
1105 /// Move to the end of the line
1107 virtual bool , MoveToLineEnd(int flags = 0),
1111 /// Move to the start of the line
1113 virtual bool , MoveToLineStart(int flags = 0),
1117 /// Move to the end of the paragraph
1119 virtual bool , MoveToParagraphEnd(int flags = 0),
1123 /// Move to the start of the paragraph
1125 virtual bool , MoveToParagraphStart(int flags = 0),
1129 /// Move to the start of the buffer
1131 virtual bool , MoveHome(int flags = 0),
1135 /// Move to the end of the buffer
1137 virtual bool , MoveEnd(int flags = 0),
1143 virtual bool , PageUp(int noPages = 1, int flags = 0),
1147 /// Move n pages down
1149 virtual bool , PageDown(int noPages = 1, int flags = 0),
1153 /// Move n words left
1155 virtual bool , WordLeft(int noPages = 1, int flags = 0),
1159 /// Move n words right
1161 virtual bool , WordRight(int noPages = 1, int flags = 0),
1165 /// Returns the buffer associated with the control.
1166 // wxRichTextBuffer& GetBuffer();
1168 const wxRichTextBuffer& , GetBuffer() const,
1172 /// Start batching undo history for commands.
1174 virtual bool , BeginBatchUndo(const wxString& cmdName),
1178 /// End batching undo history for commands.
1180 virtual bool , EndBatchUndo(),
1184 /// Are we batching undo history for commands?
1186 virtual bool , BatchingUndo() const,
1190 /// Start suppressing undo history for commands.
1192 virtual bool , BeginSuppressUndo(),
1196 /// End suppressing undo history for commands.
1198 virtual bool , EndSuppressUndo(),
1202 /// Are we suppressing undo history for commands?
1204 virtual bool , SuppressingUndo() const,
1208 /// Test if this whole range has character attributes of the specified kind. If any
1209 /// of the attributes are different within the range, the test fails. You
1210 /// can use this to implement, for example, bold button updating. style must have
1211 /// flags indicating which attributes are of interest.
1214 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1215 const wxTextAttrEx& style) const,
1220 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1221 const wxRichTextAttr& style) const,
1226 /// Test if this whole range has paragraph attributes of the specified kind. If any
1227 /// of the attributes are different within the range, the test fails. You
1228 /// can use this to implement, for example, centering button updating. style must have
1229 /// flags indicating which attributes are of interest.
1232 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1233 const wxTextAttrEx& style) const,
1238 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1239 const wxRichTextAttr& style) const,
1244 /// Is all of the selection bold?
1246 virtual bool , IsSelectionBold() const,
1250 /// Is all of the selection italics?
1252 virtual bool , IsSelectionItalics() const,
1256 /// Is all of the selection underlined?
1258 virtual bool , IsSelectionUnderlined() const,
1262 /// Is all of the selection aligned according to the specified flag?
1264 virtual bool , IsSelectionAligned(wxTextAttrAlignment alignment) const,
1268 /// Apply bold to the selection
1270 virtual bool , ApplyBoldToSelection(),
1274 /// Apply italic to the selection
1276 virtual bool , ApplyItalicToSelection(),
1280 /// Apply underline to the selection
1282 virtual bool , ApplyUnderlineToSelection(),
1286 /// Apply alignment to the selection
1288 virtual bool , ApplyAlignmentToSelection(wxTextAttrAlignment alignment),
1292 /// Set style sheet, if any.
1294 void , SetStyleSheet(wxRichTextStyleSheet* styleSheet),
1298 wxRichTextStyleSheet* , GetStyleSheet() const,
1304 // TODO: Which of these should be exposed to Python?
1306 // /// Set font, and also default attributes
1307 // virtual bool SetFont(const wxFont& font);
1309 // /// Set up scrollbars, e.g. after a resize
1310 // virtual void SetupScrollbars(bool atTop = false);
1312 // /// Keyboard navigation
1313 // virtual bool KeyboardNavigate(int keyCode, int flags);
1315 // /// Paint the background
1316 // virtual void PaintBackground(wxDC& dc);
1318 // /// Recreate buffer bitmap if necessary
1319 // virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1321 // /// Set the selection
1322 // virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
1325 // virtual void DoWriteText(const wxString& value, bool selectionOnly = true);
1327 // /// Send an update event
1328 // virtual bool SendUpdateEvent();
1330 // /// Init command event
1331 // void InitCommandEvent(wxCommandEvent& event) const;
1333 // /// do the window-specific processing after processing the update event
1334 // // (duplicated code from wxTextCtrlBase)
1335 // #if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
1336 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
1339 // /// Should we inherit colours?
1340 // virtual bool ShouldInheritColours() const;
1342 // /// Position the caret
1343 // virtual void PositionCaret();
1345 // /// Extend the selection, returning true if the selection was
1346 // /// changed. Selections are in caret positions.
1347 // virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1349 // /// Scroll into view. This takes a _caret_ position.
1350 // virtual bool ScrollIntoView(long position, int keyCode);
1352 // /// The caret position is the character position just before the caret.
1353 // /// A value of -1 means the caret is at the start of the buffer.
1354 // void SetCaretPosition(long position, bool showAtLineStart = false) ;
1355 // long GetCaretPosition() const;
1357 // /// Move caret one visual step forward: this may mean setting a flag
1358 // /// and keeping the same position if we're going from the end of one line
1359 // /// to the start of the next, which may be the exact same caret position.
1360 // void MoveCaretForward(long oldPosition) ;
1362 // /// Move caret one visual step forward: this may mean setting a flag
1363 // /// and keeping the same position if we're going from the end of one line
1364 // /// to the start of the next, which may be the exact same caret position.
1365 // void MoveCaretBack(long oldPosition) ;
1367 // /// Get the caret height and position for the given character position
1368 // bool GetCaretPositionForIndex(long position, wxRect& rect);
1370 // /// Gets the line for the visible caret position. If the caret is
1371 // /// shown at the very end of the line, it means the next character is actually
1372 // /// on the following line. So let's get the line we're expecting to find
1373 // /// if this is the case.
1374 // wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1376 // /// Gets the command processor
1377 // wxCommandProcessor* GetCommandProcessor() const;
1379 // /// Delete content if there is a selection, e.g. when pressing a key.
1380 // /// Returns the new caret position in newPos, or leaves it if there
1381 // /// was no action.
1382 // bool DeleteSelectedContent(long* newPos= NULL);
1384 // /// Transform logical to physical
1385 // wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
1387 // /// Transform physical to logical
1388 // wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
1390 // /// Finds the caret position for the next word. Direction
1391 // /// is 1 (forward) or -1 (backwards).
1392 // virtual long FindNextWordPosition(int direction = 1) const;
1394 // /// Is the given position visible on the screen?
1395 // bool IsPositionVisible(long pos) const;
1397 // /// Returns the first visible position in the current view
1398 // long GetFirstVisiblePosition() const;
1402 //----------------------------------------------------------------------
1405 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED;
1406 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED;
1407 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_CLICK;
1408 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK;
1409 %constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK;
1410 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK;
1411 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN;
1415 EVT_RICHTEXT_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 1)
1416 EVT_RICHTEXT_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 1)
1417 EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 1)
1418 EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 1)
1419 EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1)
1420 EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1)
1421 EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1)
1425 class wxRichTextEvent : public wxNotifyEvent
1428 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
1430 int GetIndex() const;
1431 void SetIndex(int n);
1433 int GetFlags() const;
1434 void SetFlags(int flags);
1437 //----------------------------------------------------------------------
1442 //----------------------------------------------------------------------