]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/_richtextctrl.i
fixes to wint_t and wchar_t handling in unichar.h (fixes FreeBSD compilation and...
[wxWidgets.git] / wxPython / src / _richtextctrl.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: _richtextctrl.i
3 // Purpose: wxRichTextCtrl and related classes
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 11-April-2006
8 // RCS-ID: $Id$
9 // Copyright: (c) 2006 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13 // Not a %module
14
15
16 //---------------------------------------------------------------------------
17
18 %{
19 %}
20
21 //---------------------------------------------------------------------------
22 %newgroup
23
24 enum {
25 wxRE_READONLY,
26 wxRE_MULTILINE,
27
28 wxRICHTEXT_SHIFT_DOWN,
29 wxRICHTEXT_CTRL_DOWN,
30 wxRICHTEXT_ALT_DOWN,
31
32 wxRICHTEXT_SELECTED,
33 wxRICHTEXT_TAGGED,
34 wxRICHTEXT_FOCUSSED,
35 wxRICHTEXT_IS_FOCUS,
36
37 };
38
39
40 //---------------------------------------------------------------------------
41
42 MAKE_CONST_WXSTRING2(RichTextCtrlNameStr, wxT("richText"));
43
44 MustHaveApp(wxRichTextCtrl);
45
46
47 DocStr(wxRichTextCtrl,
48 "", "");
49
50
51 class wxRichTextCtrl : public wxScrolledWindow
52 {
53 public:
54 %pythonAppend wxRichTextCtrl "self._setOORInfo(self)"
55 %pythonAppend wxRichTextCtrl() ""
56
57 wxRichTextCtrl( wxWindow* parent,
58 wxWindowID id = -1,
59 const wxString& value = wxPyEmptyString,
60 const wxPoint& pos = wxDefaultPosition,
61 const wxSize& size = wxDefaultSize,
62 long style = wxRE_MULTILINE,
63 const wxValidator& validator = wxDefaultValidator,
64 const wxString& name = wxPyRichTextCtrlNameStr );
65 %RenameCtor(PreRichTextCtrl, wxRichTextCtrl());
66
67
68 bool Create( wxWindow* parent,
69 wxWindowID id = -1,
70 const wxString& value = wxPyEmptyString,
71 const wxPoint& pos = wxDefaultPosition,
72 const wxSize& size = wxDefaultSize,
73 long style = wxRE_MULTILINE,
74 const wxValidator& validator = wxDefaultValidator,
75 const wxString& name = wxPyRichTextCtrlNameStr );
76
77
78 DocDeclStr(
79 virtual wxString , GetValue() const,
80 "", "");
81
82 DocDeclStr(
83 virtual void , SetValue(const wxString& value),
84 "", "");
85
86
87 DocDeclStr(
88 virtual wxString , GetRange(long from, long to) const,
89 "", "");
90
91
92 DocDeclStr(
93 virtual int , GetLineLength(long lineNo) const ,
94 "", "");
95
96 DocDeclStr(
97 virtual wxString , GetLineText(long lineNo) const ,
98 "", "");
99
100 DocDeclStr(
101 virtual int , GetNumberOfLines() const ,
102 "", "");
103
104
105 DocDeclStr(
106 virtual bool , IsModified() const ,
107 "", "");
108
109 DocDeclStr(
110 virtual bool , IsEditable() const ,
111 "", "");
112
113
114 // more readable flag testing methods
115 DocDeclStr(
116 bool , IsSingleLine() const,
117 "", "");
118
119 DocDeclStr(
120 bool , IsMultiLine() const,
121 "", "");
122
123
124 DocDeclAStr(
125 virtual void , GetSelection(long* OUTPUT, long* OUTPUT) const,
126 "GetSelection() --> (start, end)",
127 "Returns the start and end positions of the current selection. If the
128 values are the same then there is no selection.", "");
129
130
131 DocDeclStr(
132 virtual wxString , GetStringSelection() const,
133 "", "");
134
135
136 DocDeclStr(
137 wxString , GetFilename() const,
138 "", "");
139
140
141 DocDeclStr(
142 void , SetFilename(const wxString& filename),
143 "", "");
144
145
146 DocDeclStr(
147 void , SetDelayedLayoutThreshold(long threshold),
148 "Set the threshold in character positions for doing layout optimization
149 during sizing.", "");
150
151
152 DocDeclStr(
153 long , GetDelayedLayoutThreshold() const,
154 "Get the threshold in character positions for doing layout optimization
155 during sizing.", "");
156
157
158
159 DocDeclStr(
160 virtual void , Clear(),
161 "", "");
162
163 DocDeclStr(
164 virtual void , Replace(long from, long to, const wxString& value),
165 "", "");
166
167 DocDeclStr(
168 virtual void , Remove(long from, long to),
169 "", "");
170
171
172 DocDeclStr(
173 virtual bool , LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY),
174 "Load the contents of the document from the given filename.", "");
175
176 DocDeclStr(
177 virtual bool , SaveFile(const wxString& file = wxPyEmptyString,
178 int type = wxRICHTEXT_TYPE_ANY),
179 "Save the contents of the document to the given filename, or if the
180 empty string is passed then to the filename set with `SetFilename`.", "");
181
182
183 DocDeclStr(
184 void , SetHandlerFlags(int flags),
185 "Set the handler flags, controlling loading and saving.", "");
186
187 DocDeclStr(
188 int , GetHandlerFlags() const,
189 "Get the handler flags, controlling loading and saving.", "");
190
191 // sets/clears the dirty flag
192 DocDeclStr(
193 virtual void , MarkDirty(),
194 "Sets the dirty flag, meaning that the contents of the control have
195 changed and need to be saved.", "");
196
197 DocDeclStr(
198 virtual void , DiscardEdits(),
199 "Clears the dirty flag.
200 :see: `MarkDirty`", "");
201
202
203 DocDeclStr(
204 virtual void , SetMaxLength(unsigned long len),
205 "Set the max number of characters which may be entered in a single line
206 text control.", "");
207
208
209 DocDeclStr(
210 virtual void , WriteText(const wxString& text),
211 "Insert text at the current position.", "");
212
213 DocDeclStr(
214 virtual void , AppendText(const wxString& text),
215 "Append text to the end of the document.", "");
216
217
218 DocDeclStr(
219 virtual bool , SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style),
220 "Set the style for the text in ``range`` to ``style``", "");
221
222 DocDeclStr(
223 virtual bool , GetStyle(long position, wxRichTextAttr& style),
224 "Retrieve the style used at the given position. Copies the style
225 values at ``position`` into the ``style`` parameter and returns ``True``
226 if successful. Returns ``False`` otherwise.", "");
227
228
229 DocDeclStr(
230 virtual bool , GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style),
231 "Get the common set of styles for the range", "");
232
233
234 DocDeclStr(
235 virtual bool , SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style,
236 int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO),
237 "Extended style setting operation with flags including:
238 RICHTEXT_SETSTYLE_WITH_UNDO, RICHTEXT_SETSTYLE_OPTIMIZE,
239 RICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, RICHTEXT_SETSTYLE_CHARACTERS_ONLY", "");
240
241
242
243 DocDeclStr(
244 virtual bool , GetUncombinedStyle(long position, wxRichTextAttr& style),
245 "Get the content (uncombined) attributes for this position. Copies the
246 style values at ``position`` into the ``style`` parameter and returns
247 ``True`` if successful. Returns ``False`` otherwise.", "");
248
249
250 DocDeclStr(
251 virtual bool , SetDefaultStyle(const wxRichTextAttr& style),
252 "Set the style used by default for the rich text document.", "");
253
254
255 DocDeclStrName(
256 virtual const wxRichTextAttr , GetDefaultStyleEx() const,
257 "Retrieves a copy of the default style object.", "",
258 GetDefaultStyle);
259
260
261 // TODO: Select which of these to keep or rename
262
263 /// Set list style
264 // virtual bool SetListStyle(const wxRichTextRange& range,
265 // wxRichTextListStyleDefinition* def,
266 // int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO,
267 // int startFrom = 1, int specifiedLevel = -1);
268 virtual bool SetListStyle(const wxRichTextRange& range,
269 const wxString& defName,
270 int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO,
271 int startFrom = 1, int specifiedLevel = -1);
272
273 /// Clear list for given range
274 virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
275
276 /// Number/renumber any list elements in the given range
277 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
278 // virtual bool NumberList(const wxRichTextRange& range,
279 // wxRichTextListStyleDefinition* def = NULL,
280 // int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO,
281 // int startFrom = 1, int specifiedLevel = -1);
282 virtual bool NumberList(const wxRichTextRange& range,
283 const wxString& defName,
284 int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO,
285 int startFrom = 1, int specifiedLevel = -1);
286
287 /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
288 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
289 // virtual bool PromoteList(int promoteBy, const wxRichTextRange& range,
290 // wxRichTextListStyleDefinition* def = NULL,
291 // int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO,
292 // int specifiedLevel = -1);
293 virtual bool PromoteList(int promoteBy, const wxRichTextRange& range,
294 const wxString& defName,
295 int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO,
296 int specifiedLevel = -1);
297
298 /// Deletes the content in the given range
299 virtual bool Delete(const wxRichTextRange& range);
300
301
302
303
304 DocDeclStr(
305 virtual long , XYToPosition(long x, long y) const,
306 "Translate a col,row coordinants into a document position.", "");
307
308 DocDeclAStr(
309 virtual void , PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const,
310 "PositionToXY(self, long pos) --> (x, y)",
311 "Retrieves the col,row for the given position within the document", "");
312
313
314 DocDeclStr(
315 virtual void , ShowPosition(long position),
316 "Ensure that the given position in the document is visible.", "");
317
318
319 DocDeclAStr(
320 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const,
321 "HitTest(self, Point pt) --> (result, pos)",
322 "Returns the character position at the given point in pixels. Note
323 that ``pt`` should be given in device coordinates, and not be adjusted
324 for the client area origin nor for scrolling. The return value is a
325 tuple of the hit test result and the position.", "
326
327 Possible result values are a bitmask of these flags:
328
329 ========================= ====================================
330 RICHTEXT_HITTEST_NONE The point was not on this object.
331 RICHTEXT_HITTEST_BEFORE The point was before the position
332 returned from HitTest.
333 RICHTEXT_HITTEST_AFTER The point was after the position
334 returned from HitTest.
335 RICHTEXT_HITTEST_ON The point was on the position
336 returned from HitTest
337 ========================= ====================================
338 ");
339
340 DocDeclAStrName(
341 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt,
342 wxTextCoord *OUTPUT,
343 wxTextCoord *OUTPUT) const,
344 "HitTestRC(self, Point pt) --> (result, col, row)",
345 "Returns the column and row of the given point in pixels. Note that
346 ``pt`` should be given in device coordinates, and not be adjusted for
347 the client area origin nor for scrolling. The return value is a tuple
348 of the hit test result and the column and row values.", "
349 :see: `HitTest`",
350 HitTestXY);
351
352
353 // Clipboard operations
354 DocDeclStr(
355 virtual void , Copy(),
356 "Copies the selected text to the clipboard.", "");
357
358 DocDeclStr(
359 virtual void , Cut(),
360 "Copies the selected text to the clipboard and removes the selection.", "");
361
362 DocDeclStr(
363 virtual void , Paste(),
364 "Pastes text from the clipboard into the document at the current
365 insertion point.", "");
366
367 DocDeclStr(
368 virtual void , DeleteSelection(),
369 "Remove the current selection.", "");
370
371
372 DocDeclStr(
373 virtual bool , CanCopy() const,
374 "Returns ``True`` if the selection can be copied to the clipboard.", "");
375
376 DocDeclStr(
377 virtual bool , CanCut() const,
378 "Returns ``True`` if the selection can be cut to the clipboard.", "");
379
380 DocDeclStr(
381 virtual bool , CanPaste() const,
382 "Returns ``True`` if the current contents of the clipboard can be
383 pasted into the document.", "");
384
385 DocDeclStr(
386 virtual bool , CanDeleteSelection() const,
387 "Returns ``True`` if the selection can be removed from the document.", "");
388
389
390 // Undo/redo
391 DocDeclStr(
392 virtual void , Undo(),
393 "If the last operation can be undone, undoes the last operation.", "");
394
395 DocDeclStr(
396 virtual void , Redo(),
397 "If the last operation can be redone, redoes the last operation.", "");
398
399
400 DocDeclStr(
401 virtual bool , CanUndo() const,
402 "Returns ``True`` if the last operation can be undone.", "");
403
404 DocDeclStr(
405 virtual bool , CanRedo() const,
406 "Returns ``True`` if the last operation can be redone.", "");
407
408
409 // Insertion point
410 DocDeclStr(
411 virtual void , SetInsertionPoint(long pos),
412 "Sets the insertion point at the given position.", "");
413
414 DocDeclStr(
415 virtual void , SetInsertionPointEnd(),
416 "Moves the insertion point to the end of the document.", "");
417
418 DocDeclStr(
419 virtual long , GetInsertionPoint() const,
420 "Returns the insertion point. This is defined as the zero based index
421 of the character position to the right of the insertion point.", "");
422
423 DocDeclStr(
424 virtual long , GetLastPosition() const,
425 "Returns the zero based index of the last position in the document.", "");
426
427
428 DocDeclStr(
429 virtual void , SetSelection(long from, long to),
430 "Selects the text starting at the first position up to (but not
431 including) the character at the last position. If both parameters are
432 equal to -1 then all text in the control is selected.", "");
433
434 DocDeclStr(
435 virtual void , SelectAll(),
436 "Select all text in the document.", "");
437
438 DocDeclStr(
439 virtual void , SetEditable(bool editable),
440 "Makes the document editable or read-only, overriding the RE_READONLY
441 flag.", "");
442
443
444 DocDeclStr(
445 virtual bool , HasSelection() const,
446 "", "");
447
448
449 ///// Functionality specific to wxRichTextCtrl
450
451 /// Write an image at the current insertion point. Supply optional type to use
452 /// for internal and file storage of the raw data.
453 DocDeclStr(
454 virtual bool , WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG),
455 "", "");
456
457
458 /// Write a bitmap at the current insertion point. Supply optional type to use
459 /// for internal and file storage of the raw data.
460 DocDeclStrName(
461 virtual bool , WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG),
462 "", "",
463 WriteBitmap);
464
465
466 /// Load an image from file and write at the current insertion point.
467 DocDeclStrName(
468 virtual bool , WriteImage(const wxString& filename, int bitmapType),
469 "", "",
470 WriteImageFile);
471
472
473 /// Write an image block at the current insertion point.
474 DocDeclStrName(
475 virtual bool , WriteImage(const wxRichTextImageBlock& imageBlock),
476 "", "",
477 WriteImageBlock);
478
479
480 /// Insert a newline (actually paragraph) at the current insertion point.
481 DocDeclStr(
482 virtual bool , Newline(),
483 "", "");
484
485
486 /// Insert a line break at the current insertion point.
487 virtual bool LineBreak();
488
489
490 DocDeclStr(
491 virtual void , SetBasicStyle(const wxRichTextAttr& style),
492 "", "");
493
494
495 /// Get basic (overall) style
496 DocDeclStr(
497 virtual const wxRichTextAttr , GetBasicStyle() const,
498 "", "");
499
500
501 /// Begin using a style
502 DocDeclStr(
503 virtual bool , BeginStyle(const wxRichTextAttr& style),
504 "", "");
505
506
507 /// End the style
508 DocDeclStr(
509 virtual bool , EndStyle(),
510 "", "");
511
512
513 /// End all styles
514 DocDeclStr(
515 virtual bool , EndAllStyles(),
516 "", "");
517
518
519 /// Begin using bold
520 DocDeclStr(
521 bool , BeginBold(),
522 "", "");
523
524
525 /// End using bold
526 DocDeclStr(
527 bool , EndBold(),
528 "", "");
529
530
531 /// Begin using italic
532 DocDeclStr(
533 bool , BeginItalic(),
534 "", "");
535
536
537 /// End using italic
538 DocDeclStr(
539 bool , EndItalic(),
540 "", "");
541
542
543 /// Begin using underline
544 DocDeclStr(
545 bool , BeginUnderline(),
546 "", "");
547
548
549 /// End using underline
550 DocDeclStr(
551 bool , EndUnderline(),
552 "", "");
553
554
555 /// Begin using point size
556 DocDeclStr(
557 bool , BeginFontSize(int pointSize),
558 "", "");
559
560
561 /// End using point size
562 DocDeclStr(
563 bool , EndFontSize(),
564 "", "");
565
566
567 /// Begin using this font
568 DocDeclStr(
569 bool , BeginFont(const wxFont& font),
570 "", "");
571
572
573 /// End using a font
574 DocDeclStr(
575 bool , EndFont(),
576 "", "");
577
578
579 /// Begin using this colour
580 DocDeclStr(
581 bool , BeginTextColour(const wxColour& colour),
582 "", "");
583
584
585 /// End using a colour
586 DocDeclStr(
587 bool , EndTextColour(),
588 "", "");
589
590
591 /// Begin using alignment
592 DocDeclStr(
593 bool , BeginAlignment(wxTextAttrAlignment alignment),
594 "", "");
595
596
597 /// End alignment
598 DocDeclStr(
599 bool , EndAlignment(),
600 "", "");
601
602
603 /// Begin left indent
604 DocDeclStr(
605 bool , BeginLeftIndent(int leftIndent, int leftSubIndent = 0),
606 "", "");
607
608
609 /// End left indent
610 DocDeclStr(
611 bool , EndLeftIndent(),
612 "", "");
613
614
615 /// Begin right indent
616 DocDeclStr(
617 bool , BeginRightIndent(int rightIndent),
618 "", "");
619
620
621 /// End right indent
622 DocDeclStr(
623 bool , EndRightIndent(),
624 "", "");
625
626
627 /// Begin paragraph spacing
628 DocDeclStr(
629 bool , BeginParagraphSpacing(int before, int after),
630 "", "");
631
632
633 /// End paragraph spacing
634 DocDeclStr(
635 bool , EndParagraphSpacing(),
636 "", "");
637
638
639 /// Begin line spacing
640 DocDeclStr(
641 bool , BeginLineSpacing(int lineSpacing),
642 "", "");
643
644
645 /// End line spacing
646 DocDeclStr(
647 bool , EndLineSpacing(),
648 "", "");
649
650
651 /// Begin numbered bullet
652 DocDeclStr(
653 bool , BeginNumberedBullet(int bulletNumber,
654 int leftIndent,
655 int leftSubIndent,
656 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD),
657 "", "");
658
659
660 /// End numbered bullet
661 DocDeclStr(
662 bool , EndNumberedBullet(),
663 "", "");
664
665
666 /// Begin symbol bullet
667 DocDeclStr(
668 bool , BeginSymbolBullet(const wxString& symbol,
669 int leftIndent,
670 int leftSubIndent,
671 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL),
672 "", "");
673
674
675 /// End symbol bullet
676 DocDeclStr(
677 bool , EndSymbolBullet(),
678 "", "");
679
680
681 /// Begin standard bullet
682 DocDeclStr(
683 bool , BeginStandardBullet(const wxString& bulletName,
684 int leftIndent,
685 int leftSubIndent,
686 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD),
687 "", "");
688
689
690
691 /// End standard bullet
692 DocDeclStr(
693 bool , EndStandardBullet(),
694 "", "");
695
696
697 /// Begin named character style
698 DocDeclStr(
699 bool , BeginCharacterStyle(const wxString& characterStyle),
700 "", "");
701
702
703 /// End named character style
704 DocDeclStr(
705 bool , EndCharacterStyle(),
706 "", "");
707
708
709 /// Begin named paragraph style
710 DocDeclStr(
711 bool , BeginParagraphStyle(const wxString& paragraphStyle),
712 "", "");
713
714
715 /// End named character style
716 DocDeclStr(
717 bool , EndParagraphStyle(),
718 "", "");
719
720
721 DocDeclStr(
722 bool , BeginListStyle(const wxString& listStyle, int level = 1, int number = 1),
723 "Begin named list style.", "");
724
725 DocDeclStr(
726 bool , EndListStyle(), "End named list style.", "");
727
728 DocDeclStr(
729 bool , BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString),
730 "Begin URL.", "");
731
732 DocDeclStr(
733 bool , EndURL(), "End URL.", "");
734
735 /// Sets the default style to the style under the cursor
736 DocDeclStr(
737 bool , SetDefaultStyleToCursorStyle(),
738 "", "");
739
740
741 /// Clear the selection
742 DocDeclStr(
743 virtual void , SelectNone(),
744 "", "");
745
746 /// Select the word at the given character position
747 DocDeclStr(
748 virtual bool , SelectWord(long position),
749 "", "");
750
751
752 /// Get/set the selection range in character positions. -1, -1 means no selection.
753 DocDeclStr(
754 wxRichTextRange , GetSelectionRange() const,
755 "", "");
756
757 DocDeclStr(
758 void , SetSelectionRange(const wxRichTextRange& range),
759 "", "");
760
761 /// Get/set the selection range in character positions. -1, -1 means no selection.
762 /// The range is in internal format, i.e. a single character selection is denoted
763 /// by (n, n)
764 DocDeclStr(
765 const wxRichTextRange& , GetInternalSelectionRange() const,
766 "", "");
767
768 DocDeclStr(
769 void , SetInternalSelectionRange(const wxRichTextRange& range),
770 "", "");
771
772
773
774 /// Add a new paragraph of text to the end of the buffer
775 DocDeclStr(
776 virtual wxRichTextRange , AddParagraph(const wxString& text),
777 "", "");
778
779
780 /// Add an image
781 DocDeclStr(
782 virtual wxRichTextRange , AddImage(const wxImage& image),
783 "", "");
784
785
786 /// Layout the buffer: which we must do before certain operations, such as
787 /// setting the caret position.
788 DocDeclStr(
789 virtual bool , LayoutContent(bool onlyVisibleRect = false),
790 "", "");
791
792
793 /// Move the caret to the given character position
794 DocDeclStr(
795 virtual bool , MoveCaret(long pos, bool showAtLineStart = false),
796 "", "");
797
798
799 /// Move right
800 DocDeclStr(
801 virtual bool , MoveRight(int noPositions = 1, int flags = 0),
802 "", "");
803
804
805 /// Move left
806 DocDeclStr(
807 virtual bool , MoveLeft(int noPositions = 1, int flags = 0),
808 "", "");
809
810
811 /// Move up
812 DocDeclStr(
813 virtual bool , MoveUp(int noLines = 1, int flags = 0),
814 "", "");
815
816
817 /// Move up
818 DocDeclStr(
819 virtual bool , MoveDown(int noLines = 1, int flags = 0),
820 "", "");
821
822
823 /// Move to the end of the line
824 DocDeclStr(
825 virtual bool , MoveToLineEnd(int flags = 0),
826 "", "");
827
828
829 /// Move to the start of the line
830 DocDeclStr(
831 virtual bool , MoveToLineStart(int flags = 0),
832 "", "");
833
834
835 /// Move to the end of the paragraph
836 DocDeclStr(
837 virtual bool , MoveToParagraphEnd(int flags = 0),
838 "", "");
839
840
841 /// Move to the start of the paragraph
842 DocDeclStr(
843 virtual bool , MoveToParagraphStart(int flags = 0),
844 "", "");
845
846
847 /// Move to the start of the buffer
848 DocDeclStr(
849 virtual bool , MoveHome(int flags = 0),
850 "", "");
851
852
853 /// Move to the end of the buffer
854 DocDeclStr(
855 virtual bool , MoveEnd(int flags = 0),
856 "", "");
857
858
859 /// Move n pages up
860 DocDeclStr(
861 virtual bool , PageUp(int noPages = 1, int flags = 0),
862 "", "");
863
864
865 /// Move n pages down
866 DocDeclStr(
867 virtual bool , PageDown(int noPages = 1, int flags = 0),
868 "", "");
869
870
871 /// Move n words left
872 DocDeclStr(
873 virtual bool , WordLeft(int noPages = 1, int flags = 0),
874 "", "");
875
876
877 /// Move n words right
878 DocDeclStr(
879 virtual bool , WordRight(int noPages = 1, int flags = 0),
880 "", "");
881
882
883 /// Returns the buffer associated with the control.
884 DocDeclStr(
885 wxRichTextBuffer& , GetBuffer(),
886 "", "");
887
888
889 /// Start batching undo history for commands.
890 DocDeclStr(
891 virtual bool , BeginBatchUndo(const wxString& cmdName),
892 "", "");
893
894
895 /// End batching undo history for commands.
896 DocDeclStr(
897 virtual bool , EndBatchUndo(),
898 "", "");
899
900
901 /// Are we batching undo history for commands?
902 DocDeclStr(
903 virtual bool , BatchingUndo() const,
904 "", "");
905
906
907 /// Start suppressing undo history for commands.
908 DocDeclStr(
909 virtual bool , BeginSuppressUndo(),
910 "", "");
911
912
913 /// End suppressing undo history for commands.
914 DocDeclStr(
915 virtual bool , EndSuppressUndo(),
916 "", "");
917
918
919 /// Are we suppressing undo history for commands?
920 DocDeclStr(
921 virtual bool , SuppressingUndo() const,
922 "", "");
923
924
925 /// Test if this whole range has character attributes of the specified kind. If any
926 /// of the attributes are different within the range, the test fails. You
927 /// can use this to implement, for example, bold button updating. style must have
928 /// flags indicating which attributes are of interest.
929 DocDeclStr(
930 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
931 const wxRichTextAttr& style) const,
932 "", "");
933
934
935
936 /// Test if this whole range has paragraph attributes of the specified kind. If any
937 /// of the attributes are different within the range, the test fails. You
938 /// can use this to implement, for example, centering button updating. style must have
939 /// flags indicating which attributes are of interest.
940 DocDeclStr(
941 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
942 const wxRichTextAttr& style) const,
943 "", "");
944
945
946
947 /// Is all of the selection bold?
948 DocDeclStr(
949 virtual bool , IsSelectionBold(),
950 "", "");
951
952
953 /// Is all of the selection italics?
954 DocDeclStr(
955 virtual bool , IsSelectionItalics(),
956 "", "");
957
958
959 /// Is all of the selection underlined?
960 DocDeclStr(
961 virtual bool , IsSelectionUnderlined(),
962 "", "");
963
964
965 /// Is all of the selection aligned according to the specified flag?
966 DocDeclStr(
967 virtual bool , IsSelectionAligned(wxTextAttrAlignment alignment),
968 "", "");
969
970
971 /// Apply bold to the selection
972 DocDeclStr(
973 virtual bool , ApplyBoldToSelection(),
974 "", "");
975
976
977 /// Apply italic to the selection
978 DocDeclStr(
979 virtual bool , ApplyItalicToSelection(),
980 "", "");
981
982
983 /// Apply underline to the selection
984 DocDeclStr(
985 virtual bool , ApplyUnderlineToSelection(),
986 "", "");
987
988
989 /// Apply alignment to the selection
990 DocDeclStr(
991 virtual bool , ApplyAlignmentToSelection(wxTextAttrAlignment alignment),
992 "", "");
993
994
995 /// Apply a named style to the selection
996 virtual bool ApplyStyle(wxRichTextStyleDefinition* def);
997
998 /// Set style sheet, if any.
999 DocDeclStr(
1000 void , SetStyleSheet(wxRichTextStyleSheet* styleSheet),
1001 "", "");
1002
1003 DocDeclStr(
1004 wxRichTextStyleSheet* , GetStyleSheet() const,
1005 "", "");
1006
1007
1008 /// Push style sheet to top of stack
1009 bool PushStyleSheet(wxRichTextStyleSheet* styleSheet);
1010
1011
1012 /// Pop style sheet from top of stack
1013 wxRichTextStyleSheet* PopStyleSheet();
1014
1015
1016 /// Apply the style sheet to the buffer, for example if the styles have changed.
1017 DocDeclStr(
1018 bool , ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL),
1019 "", "");
1020
1021
1022
1023 %property(Buffer, GetBuffer, doc="See `GetBuffer`");
1024 %property(DefaultStyle, GetDefaultStyle, SetDefaultStyle, doc="See `GetDefaultStyle` and `SetDefaultStyle`");
1025 %property(DelayedLayoutThreshold, GetDelayedLayoutThreshold, SetDelayedLayoutThreshold, doc="See `GetDelayedLayoutThreshold` and `SetDelayedLayoutThreshold`");
1026 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
1027 %property(InsertionPoint, GetInsertionPoint, SetInsertionPoint, doc="See `GetInsertionPoint` and `SetInsertionPoint`");
1028 %property(InternalSelectionRange, GetInternalSelectionRange, SetInternalSelectionRange, doc="See `GetInternalSelectionRange` and `SetInternalSelectionRange`");
1029 %property(LastPosition, GetLastPosition, doc="See `GetLastPosition`");
1030 %property(NumberOfLines, GetNumberOfLines, doc="See `GetNumberOfLines`");
1031 %property(Selection, GetSelection, SetSelectionRange, doc="See `GetSelection` and `SetSelection`");
1032 %property(SelectionRange, GetSelectionRange, SetSelectionRange, doc="See `GetSelectionRange` and `SetSelectionRange`");
1033 %property(StringSelection, GetStringSelection, doc="See `GetStringSelection`");
1034 %property(StyleSheet, GetStyleSheet, SetStyleSheet, doc="See `GetStyleSheet` and `SetStyleSheet`");
1035 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
1036
1037
1038
1039 // TODO: Some of these methods may be useful too...
1040
1041
1042 // /// Set up scrollbars, e.g. after a resize
1043 // virtual void SetupScrollbars(bool atTop = false);
1044
1045 // /// Keyboard navigation
1046 // virtual bool KeyboardNavigate(int keyCode, int flags);
1047
1048 // /// Paint the background
1049 // virtual void PaintBackground(wxDC& dc);
1050
1051 // #if wxRICHTEXT_BUFFERED_PAINTING
1052 // /// Recreate buffer bitmap if necessary
1053 // virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1054 // #endif
1055
1056 // /// Set the selection
1057 // virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
1058
1059 // /// Write text
1060 // virtual void DoWriteText(const wxString& value, int flags = 0);
1061
1062 // /// Should we inherit colours?
1063 // virtual bool ShouldInheritColours() const { return false; }
1064
1065 // /// Position the caret
1066 // virtual void PositionCaret();
1067
1068 // /// Extend the selection, returning true if the selection was
1069 // /// changed. Selections are in caret positions.
1070 // virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1071
1072 // /// Scroll into view. This takes a _caret_ position.
1073 // virtual bool ScrollIntoView(long position, int keyCode);
1074
1075 // /// The caret position is the character position just before the caret.
1076 // /// A value of -1 means the caret is at the start of the buffer.
1077 // void SetCaretPosition(long position, bool showAtLineStart = false) ;
1078 // long GetCaretPosition() const { return m_caretPosition; }
1079
1080 // /// The adjusted caret position is the character position adjusted to take
1081 // /// into account whether we're at the start of a paragraph, in which case
1082 // /// style information should be taken from the next position, not current one.
1083 // long GetAdjustedCaretPosition(long caretPos) const;
1084
1085 // /// Move caret one visual step forward: this may mean setting a flag
1086 // /// and keeping the same position if we're going from the end of one line
1087 // /// to the start of the next, which may be the exact same caret position.
1088 // void MoveCaretForward(long oldPosition) ;
1089
1090 // /// Move caret one visual step forward: this may mean setting a flag
1091 // /// and keeping the same position if we're going from the end of one line
1092 // /// to the start of the next, which may be the exact same caret position.
1093 // void MoveCaretBack(long oldPosition) ;
1094
1095 // /// Get the caret height and position for the given character position
1096 // bool GetCaretPositionForIndex(long position, wxRect& rect);
1097
1098 // /// Gets the line for the visible caret position. If the caret is
1099 // /// shown at the very end of the line, it means the next character is actually
1100 // /// on the following line. So let's get the line we're expecting to find
1101 // /// if this is the case.
1102 // wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1103
1104 // /// Gets the command processor
1105 // wxCommandProcessor* GetCommandProcessor() const { return GetBuffer().GetCommandProcessor(); }
1106
1107 // /// Delete content if there is a selection, e.g. when pressing a key.
1108 // /// Returns the new caret position in newPos, or leaves it if there
1109 // /// was no action.
1110 // bool DeleteSelectedContent(long* newPos= NULL);
1111
1112 // /// Transform logical to physical
1113 // wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
1114
1115 // /// Transform physical to logical
1116 // wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
1117
1118 // /// Finds the caret position for the next word. Direction
1119 // /// is 1 (forward) or -1 (backwards).
1120 // virtual long FindNextWordPosition(int direction = 1) const;
1121
1122 // /// Is the given position visible on the screen?
1123 // bool IsPositionVisible(long pos) const;
1124
1125 // /// Returns the first visible position in the current view
1126 // long GetFirstVisiblePosition() const;
1127
1128 // /// Returns the caret position since the default formatting was changed. As
1129 // /// soon as this position changes, we no longer reflect the default style
1130 // /// in the UI. A value of -2 means that we should only reflect the style of the
1131 // /// content under the caret.
1132 // long GetCaretPositionForDefaultStyle() const { return m_caretPositionForDefaultStyle; }
1133
1134 // /// Set the caret position for the default style that the user is selecting.
1135 // void SetCaretPositionForDefaultStyle(long pos) { m_caretPositionForDefaultStyle = pos; }
1136
1137 // /// Should the UI reflect the default style chosen by the user, rather than the style under
1138 // /// the caret?
1139 // bool IsDefaultStyleShowing() const { return m_caretPositionForDefaultStyle != -2; }
1140
1141 // /// Convenience function that tells the control to start reflecting the default
1142 // /// style, since the user is changing it.
1143 // void SetAndShowDefaultStyle(const wxRichTextAttr& attr)
1144 // {
1145 // SetDefaultStyle(attr);
1146 // SetCaretPositionForDefaultStyle(GetCaretPosition());
1147 // }
1148
1149 // /// Get the first visible point in the window
1150 // wxPoint GetFirstVisiblePoint() const;
1151
1152 // // Implementation
1153
1154 // /// Font names take a long time to retrieve, so cache them (on demand)
1155 // static const wxArrayString& GetAvailableFontNames();
1156 // static void ClearAvailableFontNames();
1157
1158 };
1159
1160
1161 //---------------------------------------------------------------------------
1162 %newgroup
1163
1164
1165 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_CLICK;
1166 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK;
1167 %constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK;
1168 %constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK;
1169 %constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN;
1170 %constant wxEventType wxEVT_COMMAND_RICHTEXT_CHARACTER;
1171 %constant wxEventType wxEVT_COMMAND_RICHTEXT_DELETE;
1172
1173 %constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING;
1174 %constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED;
1175 %constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING;
1176 %constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED;
1177
1178 %constant wxEventType wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED;
1179 %constant wxEventType wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED;
1180 %constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED;
1181 %constant wxEventType wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED;
1182
1183 %pythoncode {
1184 EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 1)
1185 EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 1)
1186 EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1)
1187 EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1)
1188 EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1)
1189 EVT_RICHTEXT_CHARACTER = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_CHARACTER, 1)
1190 EVT_RICHTEXT_DELETE = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_DELETE, 1)
1191
1192 EVT_RICHTEXT_STYLESHEET_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, 1)
1193 EVT_RICHTEXT_STYLESHEET_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, 1)
1194 EVT_RICHTEXT_STYLESHEET_REPLACING = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, 1)
1195 EVT_RICHTEXT_STYLESHEET_REPLACED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, 1)
1196
1197 EVT_RICHTEXT_CONTENT_INSERTED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, 1)
1198 EVT_RICHTEXT_CONTENT_DELETED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, 1)
1199 EVT_RICHTEXT_STYLE_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, 1)
1200 EVT_RICHTEXT_SELECTION_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, 1)
1201 }
1202
1203
1204 class wxRichTextEvent : public wxNotifyEvent
1205 {
1206 public:
1207 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
1208
1209 int GetPosition() const;
1210 void SetPosition(int n);
1211
1212 int GetFlags() const;
1213 void SetFlags(int flags);
1214
1215 wxRichTextStyleSheet* GetOldStyleSheet() const;
1216 void SetOldStyleSheet(wxRichTextStyleSheet* sheet);
1217
1218 wxRichTextStyleSheet* GetNewStyleSheet() const;
1219 void SetNewStyleSheet(wxRichTextStyleSheet* sheet);
1220
1221 const wxRichTextRange& GetRange() const;
1222 void SetRange(const wxRichTextRange& range);
1223
1224 wxChar GetCharacter() const;
1225 void SetCharacter(wxChar ch);
1226
1227
1228 %property(Flags, GetFlags, SetFlags);
1229 %property(Index, GetPosition, SetPosition);
1230 %property(OldStyleSheet, GetOldStyleSheet, SetOldStyleSheet);
1231 %property(NewStyleSheet, GetNewStyleSheet, SetNewStyleSheet);
1232 %property(Range, GetRange, SetRange);
1233 %property(Character, GetCharacter, SetCharacter);
1234 };
1235
1236
1237 //---------------------------------------------------------------------------