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,
85 wxRICHTEXT_INSERT_NONE,
86 wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE,
90 // TODO: Rename these to be wxRICHTEXT_* ??
92 wxTEXT_ATTR_TEXT_COLOUR,
93 wxTEXT_ATTR_BACKGROUND_COLOUR,
94 wxTEXT_ATTR_FONT_FACE,
95 wxTEXT_ATTR_FONT_SIZE,
96 wxTEXT_ATTR_FONT_WEIGHT,
97 wxTEXT_ATTR_FONT_ITALIC,
98 wxTEXT_ATTR_FONT_UNDERLINE,
100 wxTEXT_ATTR_ALIGNMENT,
101 wxTEXT_ATTR_LEFT_INDENT,
102 wxTEXT_ATTR_RIGHT_INDENT,
105 wxTEXT_ATTR_PARA_SPACING_AFTER,
106 wxTEXT_ATTR_PARA_SPACING_BEFORE,
107 wxTEXT_ATTR_LINE_SPACING,
108 wxTEXT_ATTR_CHARACTER_STYLE_NAME,
109 wxTEXT_ATTR_PARAGRAPH_STYLE_NAME,
110 wxTEXT_ATTR_BULLET_STYLE,
111 wxTEXT_ATTR_BULLET_NUMBER,
112 wxTEXT_ATTR_BULLET_SYMBOL,
114 wxTEXT_ATTR_BULLET_STYLE_NONE,
115 wxTEXT_ATTR_BULLET_STYLE_ARABIC,
116 wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER,
117 wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER,
118 wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER,
119 wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER,
120 wxTEXT_ATTR_BULLET_STYLE_SYMBOL,
121 wxTEXT_ATTR_BULLET_STYLE_BITMAP,
122 wxTEXT_ATTR_BULLET_STYLE_PARENTHESES,
123 wxTEXT_ATTR_BULLET_STYLE_PERIOD,
125 wxTEXT_ATTR_LINE_SPACING_NORMAL,
126 wxTEXT_ATTR_LINE_SPACING_HALF,
127 wxTEXT_ATTR_LINE_SPACING_TWICE,
131 enum wxTextAttrAlignment
133 wxTEXT_ALIGNMENT_DEFAULT,
134 wxTEXT_ALIGNMENT_LEFT,
135 wxTEXT_ALIGNMENT_CENTRE,
136 wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE,
137 wxTEXT_ALIGNMENT_RIGHT,
138 wxTEXT_ALIGNMENT_JUSTIFIED
141 //----------------------------------------------------------------------
143 %typemap(in) wxRichTextRange& (wxRichTextRange temp) {
145 if ( ! wxRichTextRange_helper($input, &$1)) SWIG_fail;
147 %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxRichTextRange& {
148 $1 = wxPySimple_typecheck($input, wxT("wxRichTextRange"), 2);
154 bool wxRichTextRange_helper(PyObject* source, wxRichTextRange** obj)
156 if (source == Py_None) {
157 **obj = wxRICHTEXT_NONE;
160 return wxPyTwoIntItem_helper(source, obj, wxT("wxRichTextRange"));
166 DocStr(wxRichTextRange,
167 "RichTextRange is a data structure that represents a range of text
168 within a `RichTextCtrl`. It simply contains integer ``start`` and
169 ``end`` properties and a few operations useful for dealing with
170 ranges. In most places in wxPython where a RichTextRange is expected a
171 2-tuple containing (start, end) can be used instead.", "");
173 class wxRichTextRange
177 wxRichTextRange(long start=0, long end=0),
178 "Creates a new range object.", "");
184 DocStr(__eq__, "Test for equality of RichTextRange objects.", "");
185 bool __eq__(PyObject* other) {
186 wxRichTextRange temp, *obj = &temp;
187 if ( other == Py_None ) return false;
188 if ( ! wxRichTextRange_helper(other, &obj) ) {
192 return self->operator==(*obj);
198 wxRichTextRange , operator -(const wxRichTextRange& range) const,
202 wxRichTextRange , operator +(const wxRichTextRange& range) const,
207 void , SetRange(long start, long end),
212 void , SetStart(long start),
216 long , GetStart() const,
219 %pythoncode { start = property(GetStart, SetStart) }
222 void , SetEnd(long end),
226 long , GetEnd() const,
229 %pythoncode { end = property(GetEnd, SetEnd) }
233 bool , IsOutside(const wxRichTextRange& range) const,
234 "Returns true if this range is completely outside 'range'", "");
238 bool , IsWithin(const wxRichTextRange& range) const,
239 "Returns true if this range is completely within 'range'", "");
243 bool , Contains(long pos) const,
244 "Returns true if the given position is within this range. Allow for the
245 possibility of an empty range - assume the position is within this
250 bool , LimitTo(const wxRichTextRange& range) ,
251 "Limit this range to be within 'range'", "");
255 long , GetLength() const,
256 "Gets the length of the range", "");
261 "Swaps the start and end", "");
266 "Get() -> (start,end)",
267 "Returns the start and end properties as a tuple.", "");
269 wxPyBlock_t blocked = wxPyBeginBlockThreads();
270 PyObject* tup = PyTuple_New(2);
271 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetStart()));
272 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetEnd()));
273 wxPyEndBlockThreads(blocked);
278 def __str__(self): return str(self.Get())
279 def __repr__(self): return 'RichTextRange'+str(self.Get())
280 def __len__(self): return len(self.Get())
281 def __getitem__(self, index): return self.Get()[index]
282 def __setitem__(self, index, val):
283 if index == 0: self.start = val
284 elif index == 1: self.end = val
285 else: raise IndexError
286 def __nonzero__(self): return self.Get() != (0,0)
287 __safe_for_unpickling__ = True
288 def __reduce__(self): return (RichTextRange, self.Get())
291 %property(End, GetEnd, SetEnd, doc="See `GetEnd` and `SetEnd`");
292 %property(Length, GetLength, doc="See `GetLength`");
293 %property(Start, GetStart, SetStart, doc="See `GetStart` and `SetStart`");
299 wxRichTextRange wxPy_RTR_ALL(wxRICHTEXT_ALL);
300 wxRichTextRange wxPy_RTR_NONE(wxRICHTEXT_NONE);
303 %rename(RICHTEXT_ALL) wxPy_RTR_ALL;
304 %rename(RICHTEXT_NONE) wxPy_RTR_NONE;
307 wxRichTextRange wxPy_RTR_ALL;
308 wxRichTextRange wxPy_RTR_NONE;
311 //----------------------------------------------------------------------
313 DocStr(wxRichTextAttr,
314 "The RichTextAttr class stored information about the various attributes
315 for a block of text, including font, colour, indents, alignments, and
322 wxRichTextAttr(const wxColour& colText = wxNullColour,
323 const wxColour& colBack = wxNullColour,
324 wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
328 // // Making a wxTextAttrEx object.
329 // operator wxTextAttrEx () const ;
331 // // Copy to a wxTextAttr
332 // void CopyTo(wxTextAttrEx& attr) const;
336 // Create font from font attributes.
338 wxFont , CreateFont() const,
342 // Get attributes from font.
343 bool GetFontAttributes(const wxFont& font);
347 return self.CreateFont()
348 def SetFont(self, font):
349 return self.GetFontAttributes(font)
353 void SetTextColour(const wxColour& colText);
354 void SetBackgroundColour(const wxColour& colBack);
355 void SetAlignment(wxTextAttrAlignment alignment);
356 void SetTabs(const wxArrayInt& tabs);
357 void SetLeftIndent(int indent, int subIndent = 0);
358 void SetRightIndent(int indent);
360 void SetFontSize(int pointSize);
361 void SetFontStyle(int fontStyle);
362 void SetFontWeight(int fontWeight);
363 void SetFontFaceName(const wxString& faceName);
364 void SetFontUnderlined(bool underlined);
366 void SetFlags(long flags);
368 void SetCharacterStyleName(const wxString& name);
369 void SetParagraphStyleName(const wxString& name);
370 void SetParagraphSpacingAfter(int spacing);
371 void SetParagraphSpacingBefore(int spacing);
372 void SetLineSpacing(int spacing);
373 void SetBulletStyle(int style);
374 void SetBulletNumber(int n);
375 void SetBulletSymbol(wxChar symbol);
377 const wxColour& GetTextColour() const;
378 const wxColour& GetBackgroundColour() const;
379 wxTextAttrAlignment GetAlignment() const;
380 const wxArrayInt& GetTabs() const;
381 long GetLeftIndent() const;
382 long GetLeftSubIndent() const;
383 long GetRightIndent() const;
384 long GetFlags() const;
386 int GetFontSize() const;
387 int GetFontStyle() const;
388 int GetFontWeight() const;
389 bool GetFontUnderlined() const;
390 const wxString& GetFontFaceName() const;
392 const wxString& GetCharacterStyleName() const;
393 const wxString& GetParagraphStyleName() const;
394 int GetParagraphSpacingAfter() const;
395 int GetParagraphSpacingBefore() const;
396 int GetLineSpacing() const;
397 int GetBulletStyle() const;
398 int GetBulletNumber() const { return m_bulletNumber; }
399 wxChar GetBulletSymbol() const;
402 bool HasTextColour() const;
403 bool HasBackgroundColour() const;
404 bool HasAlignment() const;
405 bool HasTabs() const;
406 bool HasLeftIndent() const;
407 bool HasRightIndent() const;
408 bool HasWeight() const;
409 bool HasSize() const;
410 bool HasItalic() const;
411 bool HasUnderlined() const;
412 bool HasFaceName() const;
413 bool HasFont() const;
415 bool HasParagraphSpacingAfter() const;
416 bool HasParagraphSpacingBefore() const;
417 bool HasLineSpacing() const;
418 bool HasCharacterStyleName() const;
419 bool HasParagraphStyleName() const;
420 bool HasBulletStyle() const;
421 bool HasBulletNumber() const;
422 bool HasBulletSymbol() const;
424 bool HasFlag(long flag) const;
426 // Is this a character style?
427 bool IsCharacterStyle() const;
428 bool IsParagraphStyle() const;
430 // returns false if we have any attributes set, true otherwise
431 bool IsDefault() const;
434 // // return the attribute having the valid font and colours: it uses the
435 // // attributes set in attr and falls back first to attrDefault and then to
436 // // the text control font/colours for those attributes which are not set
437 // static wxRichTextAttr Combine(const wxRichTextAttr& attr,
438 // const wxRichTextAttr& attrDef,
439 // const wxTextCtrlBase *text);
442 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
443 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
444 %property(BulletNumber, GetBulletNumber, SetBulletNumber, doc="See `GetBulletNumber` and `SetBulletNumber`");
445 %property(BulletStyle, GetBulletStyle, SetBulletStyle, doc="See `GetBulletStyle` and `SetBulletStyle`");
446 %property(BulletSymbol, GetBulletSymbol, SetBulletSymbol, doc="See `GetBulletSymbol` and `SetBulletSymbol`");
447 %property(CharacterStyleName, GetCharacterStyleName, SetCharacterStyleName, doc="See `GetCharacterStyleName` and `SetCharacterStyleName`");
448 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
449 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
450 %property(FontAttributes, GetFontAttributes, doc="See `GetFontAttributes`");
451 %property(FontFaceName, GetFontFaceName, SetFontFaceName, doc="See `GetFontFaceName` and `SetFontFaceName`");
452 %property(FontSize, GetFontSize, SetFontSize, doc="See `GetFontSize` and `SetFontSize`");
453 %property(FontStyle, GetFontStyle, SetFontStyle, doc="See `GetFontStyle` and `SetFontStyle`");
454 %property(FontUnderlined, GetFontUnderlined, SetFontUnderlined, doc="See `GetFontUnderlined` and `SetFontUnderlined`");
455 %property(FontWeight, GetFontWeight, SetFontWeight, doc="See `GetFontWeight` and `SetFontWeight`");
456 %property(LeftIndent, GetLeftIndent, SetLeftIndent, doc="See `GetLeftIndent` and `SetLeftIndent`");
457 %property(LeftSubIndent, GetLeftSubIndent, doc="See `GetLeftSubIndent`");
458 %property(LineSpacing, GetLineSpacing, SetLineSpacing, doc="See `GetLineSpacing` and `SetLineSpacing`");
459 %property(ParagraphSpacingAfter, GetParagraphSpacingAfter, SetParagraphSpacingAfter, doc="See `GetParagraphSpacingAfter` and `SetParagraphSpacingAfter`");
460 %property(ParagraphSpacingBefore, GetParagraphSpacingBefore, SetParagraphSpacingBefore, doc="See `GetParagraphSpacingBefore` and `SetParagraphSpacingBefore`");
461 %property(ParagraphStyleName, GetParagraphStyleName, SetParagraphStyleName, doc="See `GetParagraphStyleName` and `SetParagraphStyleName`");
462 %property(RightIndent, GetRightIndent, SetRightIndent, doc="See `GetRightIndent` and `SetRightIndent`");
463 %property(Tabs, GetTabs, SetTabs, doc="See `GetTabs` and `SetTabs`");
464 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
469 wxTEXT_ATTR_CHARACTER,
470 wxTEXT_ATTR_PARAGRAPH,
475 //----------------------------------------------------------------------
476 //----------------------------------------------------------------------
478 MustHaveApp(wxRichTextCtrl);
479 DocStr(wxRichTextCtrl,
482 class wxRichTextCtrl : public wxScrolledWindow
485 %pythonAppend wxRichTextCtrl "self._setOORInfo(self)"
486 %pythonAppend wxRichTextCtrl() ""
488 wxRichTextCtrl( wxWindow* parent,
490 const wxString& value = wxPyEmptyString,
491 const wxPoint& pos = wxDefaultPosition,
492 const wxSize& size = wxDefaultSize,
493 long style = wxRE_MULTILINE );
494 %RenameCtor(PreRichTextCtrl, wxRichTextCtrl());
497 bool Create( wxWindow* parent,
499 const wxString& value = wxPyEmptyString,
500 const wxPoint& pos = wxDefaultPosition,
501 const wxSize& size = wxDefaultSize,
502 long style = wxRE_MULTILINE );
506 virtual wxString , GetValue() const,
510 virtual void , SetValue(const wxString& value),
515 virtual wxString , GetRange(long from, long to) const,
520 virtual int , GetLineLength(long lineNo) const ,
524 virtual wxString , GetLineText(long lineNo) const ,
528 virtual int , GetNumberOfLines() const ,
533 virtual bool , IsModified() const ,
537 virtual bool , IsEditable() const ,
541 // more readable flag testing methods
543 bool , IsSingleLine() const,
547 bool , IsMultiLine() const,
552 virtual void , GetSelection(long* OUTPUT, long* OUTPUT) const,
553 "GetSelection() --> (start, end)",
554 "Returns the start and end positions of the current selection. If the
555 values are the same then there is no selection.", "");
559 virtual wxString , GetStringSelection() const,
564 wxString , GetFilename() const,
569 void , SetFilename(const wxString& filename),
574 void , SetDelayedLayoutThreshold(long threshold),
575 "Set the threshold in character positions for doing layout optimization
576 during sizing.", "");
580 long , GetDelayedLayoutThreshold() const,
581 "Get the threshold in character positions for doing layout optimization
582 during sizing.", "");
587 virtual void , Clear(),
591 virtual void , Replace(long from, long to, const wxString& value),
595 virtual void , Remove(long from, long to),
600 virtual bool , LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY),
601 "Load the contents of the document from the given filename.", "");
604 virtual bool , SaveFile(const wxString& file = wxPyEmptyString,
605 int type = wxRICHTEXT_TYPE_ANY),
606 "Save the contents of the document to the given filename, or if the
607 empty string is passed then to the filename set with `SetFilename`.", "");
610 // sets/clears the dirty flag
612 virtual void , MarkDirty(),
613 "Sets the dirty flag, meaning that the contents of the control have
614 changed and need to be saved.", "");
617 virtual void , DiscardEdits(),
618 "Clears the dirty flag.
619 :see: `MarkDirty`", "");
623 virtual void , SetMaxLength(unsigned long len),
624 "Set the max number of characters which may be entered in a single line
629 virtual void , WriteText(const wxString& text),
630 "Insert text at the current position.", "");
633 virtual void , AppendText(const wxString& text),
634 "Append text to the end of the document.", "");
638 virtual bool , SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style),
639 "Set the style for the text in ``range`` to ``style``", "");
642 virtual bool , GetStyle(long position, wxRichTextAttr& style),
643 "Retrieve the style used at the given position. Copies the style
644 values at ``position`` into the ``style`` parameter and returns ``True``
645 if successful. Returns ``False`` otherwise.", "");
648 virtual bool , GetUncombinedStyle(long position, wxRichTextAttr& style),
649 "Get the content (uncombined) attributes for this position. Copies the
650 style values at ``position`` into the ``style`` parameter and returns
651 ``True`` if successful. Returns ``False`` otherwise.", "");
655 virtual bool , SetDefaultStyle(const wxRichTextAttr& style),
656 "Set the style used by default for the rich text document.", "");
660 virtual const wxRichTextAttr , GetDefaultStyleEx() const,
661 "Retrieves a copy of the default style object.", "",
666 virtual long , XYToPosition(long x, long y) const,
667 "Translate a col,row coordinants into a document position.", "");
670 virtual void , PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const,
671 "PositionToXY(self, long pos) --> (x, y)",
672 "Retrieves the col,row for the given position within the document", "");
676 virtual void , ShowPosition(long position),
677 "Ensure that the given position in the document is visible.", "");
681 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const,
682 "HitTest(self, Point pt) --> (result, pos)",
683 "Returns the character position at the given point in pixels. Note
684 that ``pt`` should be given in device coordinates, and not be adjusted
685 for the client area origin nor for scrolling. The return value is a
686 tuple of the hit test result and the position.", "
688 Possible result values are a bitmask of these flags:
690 ========================= ====================================
691 RICHTEXT_HITTEST_NONE The point was not on this object.
692 RICHTEXT_HITTEST_BEFORE The point was before the position
693 returned from HitTest.
694 RICHTEXT_HITTEST_AFTER The point was after the position
695 returned from HitTest.
696 RICHTEXT_HITTEST_ON The point was on the position
697 returned from HitTest
698 ========================= ====================================
702 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt,
704 wxTextCoord *OUTPUT) const,
705 "HitTestRC(self, Point pt) --> (result, col, row)",
706 "Returns the column and row of the given point in pixels. Note that
707 ``pt`` should be given in device coordinates, and not be adjusted for
708 the client area origin nor for scrolling. The return value is a tuple
709 of the hit test result and the column and row values.", "
714 // Clipboard operations
716 virtual void , Copy(),
717 "Copies the selected text to the clipboard.", "");
720 virtual void , Cut(),
721 "Copies the selected text to the clipboard and removes the selection.", "");
724 virtual void , Paste(),
725 "Pastes text from the clipboard into the document at the current
726 insertion point.", "");
729 virtual void , DeleteSelection(),
730 "Remove the current selection.", "");
734 virtual bool , CanCopy() const,
735 "Returns ``True`` if the selection can be copied to the clipboard.", "");
738 virtual bool , CanCut() const,
739 "Returns ``True`` if the selection can be cut to the clipboard.", "");
742 virtual bool , CanPaste() const,
743 "Returns ``True`` if the current contents of the clipboard can be
744 pasted into the document.", "");
747 virtual bool , CanDeleteSelection() const,
748 "Returns ``True`` if the selection can be removed from the document.", "");
753 virtual void , Undo(),
754 "If the last operation can be undone, undoes the last operation.", "");
757 virtual void , Redo(),
758 "If the last operation can be redone, redoes the last operation.", "");
762 virtual bool , CanUndo() const,
763 "Returns ``True`` if the last operation can be undone.", "");
766 virtual bool , CanRedo() const,
767 "Returns ``True`` if the last operation can be redone.", "");
772 virtual void , SetInsertionPoint(long pos),
773 "Sets the insertion point at the given position.", "");
776 virtual void , SetInsertionPointEnd(),
777 "Moves the insertion point to the end of the document.", "");
780 virtual long , GetInsertionPoint() const,
781 "Returns the insertion point. This is defined as the zero based index
782 of the character position to the right of the insertion point.", "");
785 virtual long , GetLastPosition() const,
786 "Returns the zero based index of the last position in the document.", "");
790 virtual void , SetSelection(long from, long to),
791 "Selects the text starting at the first position up to (but not
792 including) the character at the last position. If both parameters are
793 equal to -1 then all text in the control is selected.", "");
796 virtual void , SelectAll(),
797 "Select all text in the document.", "");
800 virtual void , SetEditable(bool editable),
801 "Makes the document editable or read-only, overriding the RE_READONLY
805 // /// Call Freeze to prevent refresh
806 // virtual void Freeze();
808 // /// Call Thaw to refresh
809 // virtual void Thaw();
811 // /// Call Thaw to refresh
813 // virtual bool , IsFrozen() const,
818 virtual bool , HasSelection() const,
822 ///// Functionality specific to wxRichTextCtrl
824 /// Write an image at the current insertion point. Supply optional type to use
825 /// for internal and file storage of the raw data.
827 virtual bool , WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG),
831 /// Write a bitmap at the current insertion point. Supply optional type to use
832 /// for internal and file storage of the raw data.
834 virtual bool , WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG),
839 /// Load an image from file and write at the current insertion point.
841 virtual bool , WriteImage(const wxString& filename, int bitmapType),
846 /// Write an image block at the current insertion point.
848 virtual bool , WriteImage(const wxRichTextImageBlock& imageBlock),
853 /// Insert a newline (actually paragraph) at the current insertion point.
855 virtual bool , Newline(),
860 /// Set basic (overall) style
862 virtual void , SetBasicStyle(const wxTextAttrEx& style),
867 virtual void , SetBasicStyle(const wxRichTextAttr& style),
872 /// Get basic (overall) style
874 virtual const wxTextAttrEx& , GetBasicStyle() const,
878 /// Begin using a style
880 virtual bool , BeginStyle(const wxTextAttrEx& style),
886 virtual bool , EndStyle(),
892 virtual bool , EndAllStyles(),
908 /// Begin using italic
910 bool , BeginItalic(),
920 /// Begin using underline
922 bool , BeginUnderline(),
926 /// End using underline
928 bool , EndUnderline(),
932 /// Begin using point size
934 bool , BeginFontSize(int pointSize),
938 /// End using point size
940 bool , EndFontSize(),
944 /// Begin using this font
946 bool , BeginFont(const wxFont& font),
956 /// Begin using this colour
958 bool , BeginTextColour(const wxColour& colour),
962 /// End using a colour
964 bool , EndTextColour(),
968 /// Begin using alignment
970 bool , BeginAlignment(wxTextAttrAlignment alignment),
976 bool , EndAlignment(),
980 /// Begin left indent
982 bool , BeginLeftIndent(int leftIndent, int leftSubIndent = 0),
988 bool , EndLeftIndent(),
992 /// Begin right indent
994 bool , BeginRightIndent(int rightIndent),
1000 bool , EndRightIndent(),
1004 /// Begin paragraph spacing
1006 bool , BeginParagraphSpacing(int before, int after),
1010 /// End paragraph spacing
1012 bool , EndParagraphSpacing(),
1016 /// Begin line spacing
1018 bool , BeginLineSpacing(int lineSpacing),
1022 /// End line spacing
1024 bool , EndLineSpacing(),
1028 /// Begin numbered bullet
1030 bool , BeginNumberedBullet(int bulletNumber,
1033 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD),
1037 /// End numbered bullet
1039 bool , EndNumberedBullet(),
1043 /// Begin symbol bullet
1045 bool , BeginSymbolBullet(char symbol,
1048 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL),
1052 /// End symbol bullet
1054 bool , EndSymbolBullet(),
1058 /// Begin named character style
1060 bool , BeginCharacterStyle(const wxString& characterStyle),
1064 /// End named character style
1066 bool , EndCharacterStyle(),
1070 /// Begin named paragraph style
1072 bool , BeginParagraphStyle(const wxString& paragraphStyle),
1076 /// End named character style
1078 bool , EndParagraphStyle(),
1082 /// Sets the default style to the style under the cursor
1084 bool , SetDefaultStyleToCursorStyle(),
1088 /// Clear the selection
1090 virtual void , SelectNone(),
1093 /// Select the word at the given character position
1095 virtual bool , SelectWord(long position),
1099 /// Get/set the selection range in character positions. -1, -1 means no selection.
1101 wxRichTextRange , GetSelectionRange() const,
1105 void , SetSelectionRange(const wxRichTextRange& range),
1108 /// Get/set the selection range in character positions. -1, -1 means no selection.
1109 /// The range is in internal format, i.e. a single character selection is denoted
1112 const wxRichTextRange& , GetInternalSelectionRange() const,
1116 void , SetInternalSelectionRange(const wxRichTextRange& range),
1121 /// Add a new paragraph of text to the end of the buffer
1123 virtual wxRichTextRange , AddParagraph(const wxString& text),
1129 virtual wxRichTextRange , AddImage(const wxImage& image),
1133 /// Layout the buffer: which we must do before certain operations, such as
1134 /// setting the caret position.
1136 virtual bool , LayoutContent(bool onlyVisibleRect = false),
1140 /// Move the caret to the given character position
1142 virtual bool , MoveCaret(long pos, bool showAtLineStart = false),
1148 virtual bool , MoveRight(int noPositions = 1, int flags = 0),
1154 virtual bool , MoveLeft(int noPositions = 1, int flags = 0),
1160 virtual bool , MoveUp(int noLines = 1, int flags = 0),
1166 virtual bool , MoveDown(int noLines = 1, int flags = 0),
1170 /// Move to the end of the line
1172 virtual bool , MoveToLineEnd(int flags = 0),
1176 /// Move to the start of the line
1178 virtual bool , MoveToLineStart(int flags = 0),
1182 /// Move to the end of the paragraph
1184 virtual bool , MoveToParagraphEnd(int flags = 0),
1188 /// Move to the start of the paragraph
1190 virtual bool , MoveToParagraphStart(int flags = 0),
1194 /// Move to the start of the buffer
1196 virtual bool , MoveHome(int flags = 0),
1200 /// Move to the end of the buffer
1202 virtual bool , MoveEnd(int flags = 0),
1208 virtual bool , PageUp(int noPages = 1, int flags = 0),
1212 /// Move n pages down
1214 virtual bool , PageDown(int noPages = 1, int flags = 0),
1218 /// Move n words left
1220 virtual bool , WordLeft(int noPages = 1, int flags = 0),
1224 /// Move n words right
1226 virtual bool , WordRight(int noPages = 1, int flags = 0),
1230 /// Returns the buffer associated with the control.
1231 // wxRichTextBuffer& GetBuffer();
1233 const wxRichTextBuffer& , GetBuffer() const,
1237 /// Start batching undo history for commands.
1239 virtual bool , BeginBatchUndo(const wxString& cmdName),
1243 /// End batching undo history for commands.
1245 virtual bool , EndBatchUndo(),
1249 /// Are we batching undo history for commands?
1251 virtual bool , BatchingUndo() const,
1255 /// Start suppressing undo history for commands.
1257 virtual bool , BeginSuppressUndo(),
1261 /// End suppressing undo history for commands.
1263 virtual bool , EndSuppressUndo(),
1267 /// Are we suppressing undo history for commands?
1269 virtual bool , SuppressingUndo() const,
1273 /// Test if this whole range has character attributes of the specified kind. If any
1274 /// of the attributes are different within the range, the test fails. You
1275 /// can use this to implement, for example, bold button updating. style must have
1276 /// flags indicating which attributes are of interest.
1279 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1280 const wxTextAttrEx& style) const,
1285 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1286 const wxRichTextAttr& style) const,
1291 /// Test if this whole range has paragraph attributes of the specified kind. If any
1292 /// of the attributes are different within the range, the test fails. You
1293 /// can use this to implement, for example, centering button updating. style must have
1294 /// flags indicating which attributes are of interest.
1297 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1298 const wxTextAttrEx& style) const,
1303 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1304 const wxRichTextAttr& style) const,
1309 /// Is all of the selection bold?
1311 virtual bool , IsSelectionBold(),
1315 /// Is all of the selection italics?
1317 virtual bool , IsSelectionItalics(),
1321 /// Is all of the selection underlined?
1323 virtual bool , IsSelectionUnderlined(),
1327 /// Is all of the selection aligned according to the specified flag?
1329 virtual bool , IsSelectionAligned(wxTextAttrAlignment alignment),
1333 /// Apply bold to the selection
1335 virtual bool , ApplyBoldToSelection(),
1339 /// Apply italic to the selection
1341 virtual bool , ApplyItalicToSelection(),
1345 /// Apply underline to the selection
1347 virtual bool , ApplyUnderlineToSelection(),
1351 /// Apply alignment to the selection
1353 virtual bool , ApplyAlignmentToSelection(wxTextAttrAlignment alignment),
1357 /// Set style sheet, if any.
1359 void , SetStyleSheet(wxRichTextStyleSheet* styleSheet),
1363 wxRichTextStyleSheet* , GetStyleSheet() const,
1366 /// Apply the style sheet to the buffer, for example if the styles have changed.
1368 bool , ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL),
1373 %property(Buffer, GetBuffer, doc="See `GetBuffer`");
1374 %property(DefaultStyle, GetDefaultStyle, SetDefaultStyle, doc="See `GetDefaultStyle` and `SetDefaultStyle`");
1375 %property(DelayedLayoutThreshold, GetDelayedLayoutThreshold, SetDelayedLayoutThreshold, doc="See `GetDelayedLayoutThreshold` and `SetDelayedLayoutThreshold`");
1376 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
1377 %property(InsertionPoint, GetInsertionPoint, SetInsertionPoint, doc="See `GetInsertionPoint` and `SetInsertionPoint`");
1378 %property(InternalSelectionRange, GetInternalSelectionRange, SetInternalSelectionRange, doc="See `GetInternalSelectionRange` and `SetInternalSelectionRange`");
1379 %property(LastPosition, GetLastPosition, doc="See `GetLastPosition`");
1380 %property(NumberOfLines, GetNumberOfLines, doc="See `GetNumberOfLines`");
1381 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
1382 %property(SelectionRange, GetSelectionRange, SetSelectionRange, doc="See `GetSelectionRange` and `SetSelectionRange`");
1383 %property(StringSelection, GetStringSelection, doc="See `GetStringSelection`");
1384 %property(StyleSheet, GetStyleSheet, SetStyleSheet, doc="See `GetStyleSheet` and `SetStyleSheet`");
1385 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
1388 // TODO: Which of these should be exposed to Python?
1390 // /// Set font, and also default attributes
1391 // virtual bool SetFont(const wxFont& font);
1393 // /// Set up scrollbars, e.g. after a resize
1394 // virtual void SetupScrollbars(bool atTop = false);
1396 // /// Keyboard navigation
1397 // virtual bool KeyboardNavigate(int keyCode, int flags);
1399 // /// Paint the background
1400 // virtual void PaintBackground(wxDC& dc);
1402 // /// Recreate buffer bitmap if necessary
1403 // virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1405 // /// Set the selection
1406 // virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
1409 // virtual void DoWriteText(const wxString& value, bool selectionOnly = true);
1411 // /// Send an update event
1412 // virtual bool SendUpdateEvent();
1414 // /// Init command event
1415 // void InitCommandEvent(wxCommandEvent& event) const;
1417 // /// do the window-specific processing after processing the update event
1418 // // (duplicated code from wxTextCtrlBase)
1419 // #if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
1420 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
1423 // /// Should we inherit colours?
1424 // virtual bool ShouldInheritColours() const;
1426 // /// Position the caret
1427 // virtual void PositionCaret();
1429 // /// Extend the selection, returning true if the selection was
1430 // /// changed. Selections are in caret positions.
1431 // virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1433 // /// Scroll into view. This takes a _caret_ position.
1434 // virtual bool ScrollIntoView(long position, int keyCode);
1436 // /// The caret position is the character position just before the caret.
1437 // /// A value of -1 means the caret is at the start of the buffer.
1438 // void SetCaretPosition(long position, bool showAtLineStart = false) ;
1439 // long GetCaretPosition() const;
1441 // /// Move caret one visual step forward: this may mean setting a flag
1442 // /// and keeping the same position if we're going from the end of one line
1443 // /// to the start of the next, which may be the exact same caret position.
1444 // void MoveCaretForward(long oldPosition) ;
1446 // /// Move caret one visual step forward: this may mean setting a flag
1447 // /// and keeping the same position if we're going from the end of one line
1448 // /// to the start of the next, which may be the exact same caret position.
1449 // void MoveCaretBack(long oldPosition) ;
1451 // /// Get the caret height and position for the given character position
1452 // bool GetCaretPositionForIndex(long position, wxRect& rect);
1454 // /// Gets the line for the visible caret position. If the caret is
1455 // /// shown at the very end of the line, it means the next character is actually
1456 // /// on the following line. So let's get the line we're expecting to find
1457 // /// if this is the case.
1458 // wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1460 // /// Gets the command processor
1461 // wxCommandProcessor* GetCommandProcessor() const;
1463 // /// Delete content if there is a selection, e.g. when pressing a key.
1464 // /// Returns the new caret position in newPos, or leaves it if there
1465 // /// was no action.
1466 // bool DeleteSelectedContent(long* newPos= NULL);
1468 // /// Transform logical to physical
1469 // wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
1471 // /// Transform physical to logical
1472 // wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
1474 // /// Finds the caret position for the next word. Direction
1475 // /// is 1 (forward) or -1 (backwards).
1476 // virtual long FindNextWordPosition(int direction = 1) const;
1478 // /// Is the given position visible on the screen?
1479 // bool IsPositionVisible(long pos) const;
1481 // /// Returns the first visible position in the current view
1482 // long GetFirstVisiblePosition() const;
1486 //----------------------------------------------------------------------
1489 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED;
1490 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED;
1491 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_CLICK;
1492 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK;
1493 %constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK;
1494 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK;
1495 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN;
1499 EVT_RICHTEXT_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 1)
1500 EVT_RICHTEXT_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 1)
1501 EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 1)
1502 EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 1)
1503 EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1)
1504 EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1)
1505 EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1)
1509 class wxRichTextEvent : public wxNotifyEvent
1512 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
1514 int GetIndex() const;
1515 void SetIndex(int n);
1517 int GetFlags() const;
1518 void SetFlags(int flags);
1520 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
1521 %property(Index, GetIndex, SetIndex, doc="See `GetIndex` and `SetIndex`");
1524 //----------------------------------------------------------------------
1529 //----------------------------------------------------------------------