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())
287 %property(End, GetEnd, SetEnd, doc="See `GetEnd` and `SetEnd`");
288 %property(Length, GetLength, doc="See `GetLength`");
289 %property(Start, GetStart, SetStart, doc="See `GetStart` and `SetStart`");
295 wxRichTextRange wxPy_RTR_ALL(wxRICHTEXT_ALL);
296 wxRichTextRange wxPy_RTR_NONE(wxRICHTEXT_NONE);
299 %rename(RICHTEXT_ALL) wxPy_RTR_ALL;
300 %rename(RICHTEXT_NONE) wxPy_RTR_NONE;
303 wxRichTextRange wxPy_RTR_ALL;
304 wxRichTextRange wxPy_RTR_NONE;
307 //----------------------------------------------------------------------
309 DocStr(wxRichTextAttr,
310 "The RichTextAttr class stored information about the various attributes
311 for a block of text, including font, colour, indents, alignments, and
318 wxRichTextAttr(const wxColour& colText = wxNullColour,
319 const wxColour& colBack = wxNullColour,
320 wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
324 // // Making a wxTextAttrEx object.
325 // operator wxTextAttrEx () const ;
327 // // Copy to a wxTextAttr
328 // void CopyTo(wxTextAttrEx& attr) const;
332 // Create font from font attributes.
334 wxFont , CreateFont() const,
338 // Get attributes from font.
339 bool GetFontAttributes(const wxFont& font);
343 return self.CreateFont()
344 def SetFont(self, font):
345 return self.GetFontAttributes(font)
349 void SetTextColour(const wxColour& colText);
350 void SetBackgroundColour(const wxColour& colBack);
351 void SetAlignment(wxTextAttrAlignment alignment);
352 void SetTabs(const wxArrayInt& tabs);
353 void SetLeftIndent(int indent, int subIndent = 0);
354 void SetRightIndent(int indent);
356 void SetFontSize(int pointSize);
357 void SetFontStyle(int fontStyle);
358 void SetFontWeight(int fontWeight);
359 void SetFontFaceName(const wxString& faceName);
360 void SetFontUnderlined(bool underlined);
362 void SetFlags(long flags);
364 void SetCharacterStyleName(const wxString& name);
365 void SetParagraphStyleName(const wxString& name);
366 void SetParagraphSpacingAfter(int spacing);
367 void SetParagraphSpacingBefore(int spacing);
368 void SetLineSpacing(int spacing);
369 void SetBulletStyle(int style);
370 void SetBulletNumber(int n);
371 void SetBulletSymbol(wxChar symbol);
373 const wxColour& GetTextColour() const;
374 const wxColour& GetBackgroundColour() const;
375 wxTextAttrAlignment GetAlignment() const;
376 const wxArrayInt& GetTabs() const;
377 long GetLeftIndent() const;
378 long GetLeftSubIndent() const;
379 long GetRightIndent() const;
380 long GetFlags() const;
382 int GetFontSize() const;
383 int GetFontStyle() const;
384 int GetFontWeight() const;
385 bool GetFontUnderlined() const;
386 const wxString& GetFontFaceName() const;
388 const wxString& GetCharacterStyleName() const;
389 const wxString& GetParagraphStyleName() const;
390 int GetParagraphSpacingAfter() const;
391 int GetParagraphSpacingBefore() const;
392 int GetLineSpacing() const;
393 int GetBulletStyle() const;
394 int GetBulletNumber() const { return m_bulletNumber; }
395 wxChar GetBulletSymbol() const;
398 bool HasTextColour() const;
399 bool HasBackgroundColour() const;
400 bool HasAlignment() const;
401 bool HasTabs() const;
402 bool HasLeftIndent() const;
403 bool HasRightIndent() const;
404 bool HasWeight() const;
405 bool HasSize() const;
406 bool HasItalic() const;
407 bool HasUnderlined() const;
408 bool HasFaceName() const;
409 bool HasFont() const;
411 bool HasParagraphSpacingAfter() const;
412 bool HasParagraphSpacingBefore() const;
413 bool HasLineSpacing() const;
414 bool HasCharacterStyleName() const;
415 bool HasParagraphStyleName() const;
416 bool HasBulletStyle() const;
417 bool HasBulletNumber() const;
418 bool HasBulletSymbol() const;
420 bool HasFlag(long flag) const;
422 // Is this a character style?
423 bool IsCharacterStyle() const;
424 bool IsParagraphStyle() const;
426 // returns false if we have any attributes set, true otherwise
427 bool IsDefault() const;
430 // // return the attribute having the valid font and colours: it uses the
431 // // attributes set in attr and falls back first to attrDefault and then to
432 // // the text control font/colours for those attributes which are not set
433 // static wxRichTextAttr Combine(const wxRichTextAttr& attr,
434 // const wxRichTextAttr& attrDef,
435 // const wxTextCtrlBase *text);
438 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
439 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
440 %property(BulletNumber, GetBulletNumber, SetBulletNumber, doc="See `GetBulletNumber` and `SetBulletNumber`");
441 %property(BulletStyle, GetBulletStyle, SetBulletStyle, doc="See `GetBulletStyle` and `SetBulletStyle`");
442 %property(BulletSymbol, GetBulletSymbol, SetBulletSymbol, doc="See `GetBulletSymbol` and `SetBulletSymbol`");
443 %property(CharacterStyleName, GetCharacterStyleName, SetCharacterStyleName, doc="See `GetCharacterStyleName` and `SetCharacterStyleName`");
444 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
445 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
446 %property(FontAttributes, GetFontAttributes, doc="See `GetFontAttributes`");
447 %property(FontFaceName, GetFontFaceName, SetFontFaceName, doc="See `GetFontFaceName` and `SetFontFaceName`");
448 %property(FontSize, GetFontSize, SetFontSize, doc="See `GetFontSize` and `SetFontSize`");
449 %property(FontStyle, GetFontStyle, SetFontStyle, doc="See `GetFontStyle` and `SetFontStyle`");
450 %property(FontUnderlined, GetFontUnderlined, SetFontUnderlined, doc="See `GetFontUnderlined` and `SetFontUnderlined`");
451 %property(FontWeight, GetFontWeight, SetFontWeight, doc="See `GetFontWeight` and `SetFontWeight`");
452 %property(LeftIndent, GetLeftIndent, SetLeftIndent, doc="See `GetLeftIndent` and `SetLeftIndent`");
453 %property(LeftSubIndent, GetLeftSubIndent, doc="See `GetLeftSubIndent`");
454 %property(LineSpacing, GetLineSpacing, SetLineSpacing, doc="See `GetLineSpacing` and `SetLineSpacing`");
455 %property(ParagraphSpacingAfter, GetParagraphSpacingAfter, SetParagraphSpacingAfter, doc="See `GetParagraphSpacingAfter` and `SetParagraphSpacingAfter`");
456 %property(ParagraphSpacingBefore, GetParagraphSpacingBefore, SetParagraphSpacingBefore, doc="See `GetParagraphSpacingBefore` and `SetParagraphSpacingBefore`");
457 %property(ParagraphStyleName, GetParagraphStyleName, SetParagraphStyleName, doc="See `GetParagraphStyleName` and `SetParagraphStyleName`");
458 %property(RightIndent, GetRightIndent, SetRightIndent, doc="See `GetRightIndent` and `SetRightIndent`");
459 %property(Tabs, GetTabs, SetTabs, doc="See `GetTabs` and `SetTabs`");
460 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
465 wxTEXT_ATTR_CHARACTER,
466 wxTEXT_ATTR_PARAGRAPH,
471 //----------------------------------------------------------------------
472 //----------------------------------------------------------------------
474 MustHaveApp(wxRichTextCtrl);
475 DocStr(wxRichTextCtrl,
478 class wxRichTextCtrl : public wxScrolledWindow
481 %pythonAppend wxRichTextCtrl "self._setOORInfo(self)"
482 %pythonAppend wxRichTextCtrl() ""
484 wxRichTextCtrl( wxWindow* parent,
486 const wxString& value = wxPyEmptyString,
487 const wxPoint& pos = wxDefaultPosition,
488 const wxSize& size = wxDefaultSize,
489 long style = wxRE_MULTILINE );
490 %RenameCtor(PreRichTextCtrl, wxRichTextCtrl());
493 bool Create( wxWindow* parent,
495 const wxString& value = wxPyEmptyString,
496 const wxPoint& pos = wxDefaultPosition,
497 const wxSize& size = wxDefaultSize,
498 long style = wxRE_MULTILINE );
502 virtual wxString , GetValue() const,
506 virtual void , SetValue(const wxString& value),
511 virtual wxString , GetRange(long from, long to) const,
516 virtual int , GetLineLength(long lineNo) const ,
520 virtual wxString , GetLineText(long lineNo) const ,
524 virtual int , GetNumberOfLines() const ,
529 virtual bool , IsModified() const ,
533 virtual bool , IsEditable() const ,
537 // more readable flag testing methods
539 bool , IsSingleLine() const,
543 bool , IsMultiLine() const,
548 virtual void , GetSelection(long* OUTPUT, long* OUTPUT) const,
549 "GetSelection() --> (start, end)",
550 "Returns the start and end positions of the current selection. If the
551 values are the same then there is no selection.", "");
555 virtual wxString , GetStringSelection() const,
560 wxString , GetFilename() const,
565 void , SetFilename(const wxString& filename),
570 void , SetDelayedLayoutThreshold(long threshold),
571 "Set the threshold in character positions for doing layout optimization
572 during sizing.", "");
576 long , GetDelayedLayoutThreshold() const,
577 "Get the threshold in character positions for doing layout optimization
578 during sizing.", "");
583 virtual void , Clear(),
587 virtual void , Replace(long from, long to, const wxString& value),
591 virtual void , Remove(long from, long to),
596 virtual bool , LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY),
597 "Load the contents of the document from the given filename.", "");
600 virtual bool , SaveFile(const wxString& file = wxPyEmptyString,
601 int type = wxRICHTEXT_TYPE_ANY),
602 "Save the contents of the document to the given filename, or if the
603 empty string is passed then to the filename set with `SetFilename`.", "");
606 // sets/clears the dirty flag
608 virtual void , MarkDirty(),
609 "Sets the dirty flag, meaning that the contents of the control have
610 changed and need to be saved.", "");
613 virtual void , DiscardEdits(),
614 "Clears the dirty flag.
615 :see: `MarkDirty`", "");
619 virtual void , SetMaxLength(unsigned long len),
620 "Set the max number of characters which may be entered in a single line
625 virtual void , WriteText(const wxString& text),
626 "Insert text at the current position.", "");
629 virtual void , AppendText(const wxString& text),
630 "Append text to the end of the document.", "");
634 virtual bool , SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style),
635 "Set the style for the text in ``range`` to ``style``", "");
638 virtual bool , GetStyle(long position, wxRichTextAttr& style),
639 "Retrieve the style used at the given position. Copies the style
640 values at ``position`` into the ``style`` parameter returns ``True``
641 if successful. Returns ``False`` otherwise.", "");
645 virtual bool , SetDefaultStyle(const wxRichTextAttr& style),
646 "Set the style used by default for the rich text document.", "");
650 virtual const wxRichTextAttr , GetDefaultStyleEx() const,
651 "Retrieves a copy of the default style object.", "",
656 virtual long , XYToPosition(long x, long y) const,
657 "Translate a col,row coordinants into a document position.", "");
660 virtual void , PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const,
661 "PositionToXY(self, long pos) --> (x, y)",
662 "Retrieves the col,row for the given position within the document", "");
666 virtual void , ShowPosition(long position),
667 "Ensure that the given position in the document is visible.", "");
671 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const,
672 "HitTest(self, Point pt) --> (result, pos)",
673 "Returns the character position at the given point in pixels. Note
674 that ``pt`` should be given in device coordinates, and not be adjusted
675 for the client area origin nor for scrolling. The return value is a
676 tuple of the hit test result and the position.", "
678 Possible result values are a bitmask of these flags:
680 ========================= ====================================
681 RICHTEXT_HITTEST_NONE The point was not on this object.
682 RICHTEXT_HITTEST_BEFORE The point was before the position
683 returned from HitTest.
684 RICHTEXT_HITTEST_AFTER The point was after the position
685 returned from HitTest.
686 RICHTEXT_HITTEST_ON The point was on the position
687 returned from HitTest
688 ========================= ====================================
692 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt,
694 wxTextCoord *OUTPUT) const,
695 "HitTestRC(self, Point pt) --> (result, col, row)",
696 "Returns the column and row of the given point in pixels. Note that
697 ``pt`` should be given in device coordinates, and not be adjusted for
698 the client area origin nor for scrolling. The return value is a tuple
699 of the hit test result and the column and row values.", "
704 // Clipboard operations
706 virtual void , Copy(),
707 "Copies the selected text to the clipboard.", "");
710 virtual void , Cut(),
711 "Copies the selected text to the clipboard and removes the selection.", "");
714 virtual void , Paste(),
715 "Pastes text from the clipboard into the document at the current
716 insertion point.", "");
719 virtual void , DeleteSelection(),
720 "Remove the current selection.", "");
724 virtual bool , CanCopy() const,
725 "Returns ``True`` if the selection can be copied to the clipboard.", "");
728 virtual bool , CanCut() const,
729 "Returns ``True`` if the selection can be cut to the clipboard.", "");
732 virtual bool , CanPaste() const,
733 "Returns ``True`` if the current contents of the clipboard can be
734 pasted into the document.", "");
737 virtual bool , CanDeleteSelection() const,
738 "Returns ``True`` if the selection can be removed from the document.", "");
743 virtual void , Undo(),
744 "If the last operation can be undone, undoes the last operation.", "");
747 virtual void , Redo(),
748 "If the last operation can be redone, redoes the last operation.", "");
752 virtual bool , CanUndo() const,
753 "Returns ``True`` if the last operation can be undone.", "");
756 virtual bool , CanRedo() const,
757 "Returns ``True`` if the last operation can be redone.", "");
762 virtual void , SetInsertionPoint(long pos),
763 "Sets the insertion point at the given position.", "");
766 virtual void , SetInsertionPointEnd(),
767 "Moves the insertion point to the end of the document.", "");
770 virtual long , GetInsertionPoint() const,
771 "Returns the insertion point. This is defined as the zero based index
772 of the character position to the right of the insertion point.", "");
775 virtual long , GetLastPosition() const,
776 "Returns the zero based index of the last position in the document.", "");
780 virtual void , SetSelection(long from, long to),
781 "Selects the text starting at the first position up to (but not
782 including) the character at the last position. If both parameters are
783 equal to -1 then all text in the control is selected.", "");
786 virtual void , SelectAll(),
787 "Select all text in the document.", "");
790 virtual void , SetEditable(bool editable),
791 "Makes the document editable or read-only, overriding the RE_READONLY
795 // /// Call Freeze to prevent refresh
796 // virtual void Freeze();
798 // /// Call Thaw to refresh
799 // virtual void Thaw();
801 // /// Call Thaw to refresh
803 // virtual bool , IsFrozen() const,
808 virtual bool , HasSelection() const,
812 ///// Functionality specific to wxRichTextCtrl
814 /// Write an image at the current insertion point. Supply optional type to use
815 /// for internal and file storage of the raw data.
817 virtual bool , WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG),
821 /// Write a bitmap at the current insertion point. Supply optional type to use
822 /// for internal and file storage of the raw data.
824 virtual bool , WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG),
829 /// Load an image from file and write at the current insertion point.
831 virtual bool , WriteImage(const wxString& filename, int bitmapType),
836 /// Write an image block at the current insertion point.
838 virtual bool , WriteImage(const wxRichTextImageBlock& imageBlock),
843 /// Insert a newline (actually paragraph) at the current insertion point.
845 virtual bool , Newline(),
850 /// Set basic (overall) style
852 virtual void , SetBasicStyle(const wxTextAttrEx& style),
857 virtual void , SetBasicStyle(const wxRichTextAttr& style),
862 /// Get basic (overall) style
864 virtual const wxTextAttrEx& , GetBasicStyle() const,
868 /// Begin using a style
870 virtual bool , BeginStyle(const wxTextAttrEx& style),
876 virtual bool , EndStyle(),
882 virtual bool , EndAllStyles(),
898 /// Begin using italic
900 bool , BeginItalic(),
910 /// Begin using underline
912 bool , BeginUnderline(),
916 /// End using underline
918 bool , EndUnderline(),
922 /// Begin using point size
924 bool , BeginFontSize(int pointSize),
928 /// End using point size
930 bool , EndFontSize(),
934 /// Begin using this font
936 bool , BeginFont(const wxFont& font),
946 /// Begin using this colour
948 bool , BeginTextColour(const wxColour& colour),
952 /// End using a colour
954 bool , EndTextColour(),
958 /// Begin using alignment
960 bool , BeginAlignment(wxTextAttrAlignment alignment),
966 bool , EndAlignment(),
970 /// Begin left indent
972 bool , BeginLeftIndent(int leftIndent, int leftSubIndent = 0),
978 bool , EndLeftIndent(),
982 /// Begin right indent
984 bool , BeginRightIndent(int rightIndent),
990 bool , EndRightIndent(),
994 /// Begin paragraph spacing
996 bool , BeginParagraphSpacing(int before, int after),
1000 /// End paragraph spacing
1002 bool , EndParagraphSpacing(),
1006 /// Begin line spacing
1008 bool , BeginLineSpacing(int lineSpacing),
1012 /// End line spacing
1014 bool , EndLineSpacing(),
1018 /// Begin numbered bullet
1020 bool , BeginNumberedBullet(int bulletNumber,
1023 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD),
1027 /// End numbered bullet
1029 bool , EndNumberedBullet(),
1033 /// Begin symbol bullet
1035 bool , BeginSymbolBullet(char symbol,
1038 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL),
1042 /// End symbol bullet
1044 bool , EndSymbolBullet(),
1048 /// Begin named character style
1050 bool , BeginCharacterStyle(const wxString& characterStyle),
1054 /// End named character style
1056 bool , EndCharacterStyle(),
1060 /// Begin named paragraph style
1062 bool , BeginParagraphStyle(const wxString& paragraphStyle),
1066 /// End named character style
1068 bool , EndParagraphStyle(),
1072 /// Sets the default style to the style under the cursor
1074 bool , SetDefaultStyleToCursorStyle(),
1078 /// Clear the selection
1080 virtual void , SelectNone(),
1084 /// Get/set the selection range in character positions. -1, -1 means no selection.
1086 wxRichTextRange , GetSelectionRange() const,
1090 void , SetSelectionRange(const wxRichTextRange& range),
1093 /// Get/set the selection range in character positions. -1, -1 means no selection.
1094 /// The range is in internal format, i.e. a single character selection is denoted
1097 const wxRichTextRange& , GetInternalSelectionRange() const,
1101 void , SetInternalSelectionRange(const wxRichTextRange& range),
1106 /// Add a new paragraph of text to the end of the buffer
1108 virtual wxRichTextRange , AddParagraph(const wxString& text),
1114 virtual wxRichTextRange , AddImage(const wxImage& image),
1118 /// Layout the buffer: which we must do before certain operations, such as
1119 /// setting the caret position.
1121 virtual bool , LayoutContent(bool onlyVisibleRect = false),
1125 /// Move the caret to the given character position
1127 virtual bool , MoveCaret(long pos, bool showAtLineStart = false),
1133 virtual bool , MoveRight(int noPositions = 1, int flags = 0),
1139 virtual bool , MoveLeft(int noPositions = 1, int flags = 0),
1145 virtual bool , MoveUp(int noLines = 1, int flags = 0),
1151 virtual bool , MoveDown(int noLines = 1, int flags = 0),
1155 /// Move to the end of the line
1157 virtual bool , MoveToLineEnd(int flags = 0),
1161 /// Move to the start of the line
1163 virtual bool , MoveToLineStart(int flags = 0),
1167 /// Move to the end of the paragraph
1169 virtual bool , MoveToParagraphEnd(int flags = 0),
1173 /// Move to the start of the paragraph
1175 virtual bool , MoveToParagraphStart(int flags = 0),
1179 /// Move to the start of the buffer
1181 virtual bool , MoveHome(int flags = 0),
1185 /// Move to the end of the buffer
1187 virtual bool , MoveEnd(int flags = 0),
1193 virtual bool , PageUp(int noPages = 1, int flags = 0),
1197 /// Move n pages down
1199 virtual bool , PageDown(int noPages = 1, int flags = 0),
1203 /// Move n words left
1205 virtual bool , WordLeft(int noPages = 1, int flags = 0),
1209 /// Move n words right
1211 virtual bool , WordRight(int noPages = 1, int flags = 0),
1215 /// Returns the buffer associated with the control.
1216 // wxRichTextBuffer& GetBuffer();
1218 const wxRichTextBuffer& , GetBuffer() const,
1222 /// Start batching undo history for commands.
1224 virtual bool , BeginBatchUndo(const wxString& cmdName),
1228 /// End batching undo history for commands.
1230 virtual bool , EndBatchUndo(),
1234 /// Are we batching undo history for commands?
1236 virtual bool , BatchingUndo() const,
1240 /// Start suppressing undo history for commands.
1242 virtual bool , BeginSuppressUndo(),
1246 /// End suppressing undo history for commands.
1248 virtual bool , EndSuppressUndo(),
1252 /// Are we suppressing undo history for commands?
1254 virtual bool , SuppressingUndo() const,
1258 /// Test if this whole range has character attributes of the specified kind. If any
1259 /// of the attributes are different within the range, the test fails. You
1260 /// can use this to implement, for example, bold button updating. style must have
1261 /// flags indicating which attributes are of interest.
1264 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1265 const wxTextAttrEx& style) const,
1270 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1271 const wxRichTextAttr& style) const,
1276 /// Test if this whole range has paragraph attributes of the specified kind. If any
1277 /// of the attributes are different within the range, the test fails. You
1278 /// can use this to implement, for example, centering button updating. style must have
1279 /// flags indicating which attributes are of interest.
1282 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1283 const wxTextAttrEx& style) const,
1288 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1289 const wxRichTextAttr& style) const,
1294 /// Is all of the selection bold?
1296 virtual bool , IsSelectionBold(),
1300 /// Is all of the selection italics?
1302 virtual bool , IsSelectionItalics(),
1306 /// Is all of the selection underlined?
1308 virtual bool , IsSelectionUnderlined(),
1312 /// Is all of the selection aligned according to the specified flag?
1314 virtual bool , IsSelectionAligned(wxTextAttrAlignment alignment),
1318 /// Apply bold to the selection
1320 virtual bool , ApplyBoldToSelection(),
1324 /// Apply italic to the selection
1326 virtual bool , ApplyItalicToSelection(),
1330 /// Apply underline to the selection
1332 virtual bool , ApplyUnderlineToSelection(),
1336 /// Apply alignment to the selection
1338 virtual bool , ApplyAlignmentToSelection(wxTextAttrAlignment alignment),
1342 /// Set style sheet, if any.
1344 void , SetStyleSheet(wxRichTextStyleSheet* styleSheet),
1348 wxRichTextStyleSheet* , GetStyleSheet() const,
1352 %property(Buffer, GetBuffer, doc="See `GetBuffer`");
1353 %property(DefaultStyle, GetDefaultStyle, SetDefaultStyle, doc="See `GetDefaultStyle` and `SetDefaultStyle`");
1354 %property(DelayedLayoutThreshold, GetDelayedLayoutThreshold, SetDelayedLayoutThreshold, doc="See `GetDelayedLayoutThreshold` and `SetDelayedLayoutThreshold`");
1355 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
1356 %property(InsertionPoint, GetInsertionPoint, SetInsertionPoint, doc="See `GetInsertionPoint` and `SetInsertionPoint`");
1357 %property(InternalSelectionRange, GetInternalSelectionRange, SetInternalSelectionRange, doc="See `GetInternalSelectionRange` and `SetInternalSelectionRange`");
1358 %property(LastPosition, GetLastPosition, doc="See `GetLastPosition`");
1359 %property(NumberOfLines, GetNumberOfLines, doc="See `GetNumberOfLines`");
1360 %property(Selection, GetSelection, SetSelection, doc="See `GetSelection` and `SetSelection`");
1361 %property(SelectionRange, GetSelectionRange, SetSelectionRange, doc="See `GetSelectionRange` and `SetSelectionRange`");
1362 %property(StringSelection, GetStringSelection, doc="See `GetStringSelection`");
1363 %property(StyleSheet, GetStyleSheet, SetStyleSheet, doc="See `GetStyleSheet` and `SetStyleSheet`");
1364 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
1367 // TODO: Which of these should be exposed to Python?
1369 // /// Set font, and also default attributes
1370 // virtual bool SetFont(const wxFont& font);
1372 // /// Set up scrollbars, e.g. after a resize
1373 // virtual void SetupScrollbars(bool atTop = false);
1375 // /// Keyboard navigation
1376 // virtual bool KeyboardNavigate(int keyCode, int flags);
1378 // /// Paint the background
1379 // virtual void PaintBackground(wxDC& dc);
1381 // /// Recreate buffer bitmap if necessary
1382 // virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1384 // /// Set the selection
1385 // virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
1388 // virtual void DoWriteText(const wxString& value, bool selectionOnly = true);
1390 // /// Send an update event
1391 // virtual bool SendUpdateEvent();
1393 // /// Init command event
1394 // void InitCommandEvent(wxCommandEvent& event) const;
1396 // /// do the window-specific processing after processing the update event
1397 // // (duplicated code from wxTextCtrlBase)
1398 // #if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
1399 // virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
1402 // /// Should we inherit colours?
1403 // virtual bool ShouldInheritColours() const;
1405 // /// Position the caret
1406 // virtual void PositionCaret();
1408 // /// Extend the selection, returning true if the selection was
1409 // /// changed. Selections are in caret positions.
1410 // virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1412 // /// Scroll into view. This takes a _caret_ position.
1413 // virtual bool ScrollIntoView(long position, int keyCode);
1415 // /// The caret position is the character position just before the caret.
1416 // /// A value of -1 means the caret is at the start of the buffer.
1417 // void SetCaretPosition(long position, bool showAtLineStart = false) ;
1418 // long GetCaretPosition() const;
1420 // /// Move caret one visual step forward: this may mean setting a flag
1421 // /// and keeping the same position if we're going from the end of one line
1422 // /// to the start of the next, which may be the exact same caret position.
1423 // void MoveCaretForward(long oldPosition) ;
1425 // /// Move caret one visual step forward: this may mean setting a flag
1426 // /// and keeping the same position if we're going from the end of one line
1427 // /// to the start of the next, which may be the exact same caret position.
1428 // void MoveCaretBack(long oldPosition) ;
1430 // /// Get the caret height and position for the given character position
1431 // bool GetCaretPositionForIndex(long position, wxRect& rect);
1433 // /// Gets the line for the visible caret position. If the caret is
1434 // /// shown at the very end of the line, it means the next character is actually
1435 // /// on the following line. So let's get the line we're expecting to find
1436 // /// if this is the case.
1437 // wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1439 // /// Gets the command processor
1440 // wxCommandProcessor* GetCommandProcessor() const;
1442 // /// Delete content if there is a selection, e.g. when pressing a key.
1443 // /// Returns the new caret position in newPos, or leaves it if there
1444 // /// was no action.
1445 // bool DeleteSelectedContent(long* newPos= NULL);
1447 // /// Transform logical to physical
1448 // wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
1450 // /// Transform physical to logical
1451 // wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
1453 // /// Finds the caret position for the next word. Direction
1454 // /// is 1 (forward) or -1 (backwards).
1455 // virtual long FindNextWordPosition(int direction = 1) const;
1457 // /// Is the given position visible on the screen?
1458 // bool IsPositionVisible(long pos) const;
1460 // /// Returns the first visible position in the current view
1461 // long GetFirstVisiblePosition() const;
1465 //----------------------------------------------------------------------
1468 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED;
1469 %constant wxEventType wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED;
1470 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_CLICK;
1471 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK;
1472 %constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK;
1473 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK;
1474 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN;
1478 EVT_RICHTEXT_ITEM_SELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 1)
1479 EVT_RICHTEXT_ITEM_DESELECTED = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 1)
1480 EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 1)
1481 EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 1)
1482 EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1)
1483 EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1)
1484 EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1)
1488 class wxRichTextEvent : public wxNotifyEvent
1491 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
1493 int GetIndex() const;
1494 void SetIndex(int n);
1496 int GetFlags() const;
1497 void SetFlags(int flags);
1499 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
1500 %property(Index, GetIndex, SetIndex, doc="See `GetIndex` and `SetIndex`");
1503 //----------------------------------------------------------------------
1508 //----------------------------------------------------------------------