]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/richtext.i
No animate contrib anymore
[wxWidgets.git] / wxPython / src / richtext.i
CommitLineData
30fc5e8f
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: richtext.i
3// Purpose: Classes for wxRichTExtCtrl and support 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%define DOCSTRING
14""
15%enddef
16
17%module(package="wx", docstring=DOCSTRING) richtext
18
19%{
20#include "wx/wxPython/wxPython.h"
21#include "wx/wxPython/pyclasses.h"
22#include "wx/wxPython/printfw.h"
23#include "wx/wxPython/twoitem.h"
24
25#include <wx/richtext/richtextctrl.h>
26
27
28class wxEffects;
29class wxBufferedDC;
30class wxBufferedPaintDC;
31class wxMetaFile;
32class wxMetaFileDC;
33class wxPrinterDC;
34
35%}
36
37#define USE_TEXTATTREX 0
38
39//----------------------------------------------------------------------
40
41%import windows.i
475edb11 42// ?? %import gdi.i
30fc5e8f
RD
43
44%pythoncode { wx = _core }
45%pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
46
47MAKE_CONST_WXSTRING_NOSWIG(EmptyString);
48
49//----------------------------------------------------------------------
50
51enum {
52 wxRE_READONLY,
53 wxRE_MULTILINE,
54
55 wxRICHTEXT_SHIFT_DOWN,
56 wxRICHTEXT_CTRL_DOWN,
57 wxRICHTEXT_ALT_DOWN,
58
59 wxRICHTEXT_SELECTED,
60 wxRICHTEXT_TAGGED,
61 wxRICHTEXT_FOCUSSED,
62 wxRICHTEXT_IS_FOCUS,
63
64 wxRICHTEXT_TYPE_ANY,
65 wxRICHTEXT_TYPE_TEXT,
66 wxRICHTEXT_TYPE_XML,
67 wxRICHTEXT_TYPE_HTML,
68 wxRICHTEXT_TYPE_RTF,
69 wxRICHTEXT_TYPE_PDF,
70
71 wxRICHTEXT_FIXED_WIDTH,
72 wxRICHTEXT_FIXED_HEIGHT,
73 wxRICHTEXT_VARIABLE_WIDTH,
74 wxRICHTEXT_VARIABLE_HEIGHT,
75
76
77 wxRICHTEXT_HITTEST_NONE,
78 wxRICHTEXT_HITTEST_BEFORE,
79 wxRICHTEXT_HITTEST_AFTER,
80 wxRICHTEXT_HITTEST_ON,
81
82 wxRICHTEXT_FORMATTED,
83 wxRICHTEXT_UNFORMATTED,
1aefbabe
RD
84
85 wxRICHTEXT_SETSTYLE_NONE,
86 wxRICHTEXT_SETSTYLE_WITH_UNDO,
87 wxRICHTEXT_SETSTYLE_OPTIMIZE,
88 wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY,
89 wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY,
90
bdec7d7a
RD
91 wxRICHTEXT_INSERT_NONE,
92 wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE,
1aefbabe 93
30fc5e8f
RD
94
95
96 // TODO: Rename these to be wxRICHTEXT_* ??
97
98 wxTEXT_ATTR_TEXT_COLOUR,
99 wxTEXT_ATTR_BACKGROUND_COLOUR,
100 wxTEXT_ATTR_FONT_FACE,
101 wxTEXT_ATTR_FONT_SIZE,
102 wxTEXT_ATTR_FONT_WEIGHT,
103 wxTEXT_ATTR_FONT_ITALIC,
104 wxTEXT_ATTR_FONT_UNDERLINE,
105 wxTEXT_ATTR_FONT,
106 wxTEXT_ATTR_ALIGNMENT,
107 wxTEXT_ATTR_LEFT_INDENT,
108 wxTEXT_ATTR_RIGHT_INDENT,
109 wxTEXT_ATTR_TABS,
110
111 wxTEXT_ATTR_PARA_SPACING_AFTER,
112 wxTEXT_ATTR_PARA_SPACING_BEFORE,
113 wxTEXT_ATTR_LINE_SPACING,
114 wxTEXT_ATTR_CHARACTER_STYLE_NAME,
115 wxTEXT_ATTR_PARAGRAPH_STYLE_NAME,
116 wxTEXT_ATTR_BULLET_STYLE,
117 wxTEXT_ATTR_BULLET_NUMBER,
30fc5e8f
RD
118
119 wxTEXT_ATTR_BULLET_STYLE_NONE,
120 wxTEXT_ATTR_BULLET_STYLE_ARABIC,
121 wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER,
122 wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER,
123 wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER,
124 wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER,
125 wxTEXT_ATTR_BULLET_STYLE_SYMBOL,
126 wxTEXT_ATTR_BULLET_STYLE_BITMAP,
127 wxTEXT_ATTR_BULLET_STYLE_PARENTHESES,
128 wxTEXT_ATTR_BULLET_STYLE_PERIOD,
129
130 wxTEXT_ATTR_LINE_SPACING_NORMAL,
131 wxTEXT_ATTR_LINE_SPACING_HALF,
132 wxTEXT_ATTR_LINE_SPACING_TWICE,
133
134};
135
136enum wxTextAttrAlignment
137{
138 wxTEXT_ALIGNMENT_DEFAULT,
139 wxTEXT_ALIGNMENT_LEFT,
140 wxTEXT_ALIGNMENT_CENTRE,
141 wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE,
142 wxTEXT_ALIGNMENT_RIGHT,
143 wxTEXT_ALIGNMENT_JUSTIFIED
144};
145
146//----------------------------------------------------------------------
147
148%typemap(in) wxRichTextRange& (wxRichTextRange temp) {
149 $1 = &temp;
150 if ( ! wxRichTextRange_helper($input, &$1)) SWIG_fail;
151}
152%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) wxRichTextRange& {
153 $1 = wxPySimple_typecheck($input, wxT("wxRichTextRange"), 2);
154}
155
156
157%{
158
159bool wxRichTextRange_helper(PyObject* source, wxRichTextRange** obj)
160{
161 if (source == Py_None) {
162 **obj = wxRICHTEXT_NONE;
163 return true;
164 }
165 return wxPyTwoIntItem_helper(source, obj, wxT("wxRichTextRange"));
166}
167%}
168
169
170
171DocStr(wxRichTextRange,
172"RichTextRange is a data structure that represents a range of text
173within a `RichTextCtrl`. It simply contains integer ``start`` and
174``end`` properties and a few operations useful for dealing with
175ranges. In most places in wxPython where a RichTextRange is expected a
1762-tuple containing (start, end) can be used instead.", "");
177
178class wxRichTextRange
179{
180public:
181 DocCtorStr(
182 wxRichTextRange(long start=0, long end=0),
183 "Creates a new range object.", "");
184
185 ~wxRichTextRange();
186
187 %extend {
188 KeepGIL(__eq__);
189 DocStr(__eq__, "Test for equality of RichTextRange objects.", "");
190 bool __eq__(PyObject* other) {
191 wxRichTextRange temp, *obj = &temp;
192 if ( other == Py_None ) return false;
193 if ( ! wxRichTextRange_helper(other, &obj) ) {
194 PyErr_Clear();
195 return false;
196 }
197 return self->operator==(*obj);
198 }
199 }
200
201
202 DocDeclStr(
203 wxRichTextRange , operator -(const wxRichTextRange& range) const,
204 "", "");
205
206 DocDeclStr(
207 wxRichTextRange , operator +(const wxRichTextRange& range) const,
208 "", "");
209
210
211 DocDeclStr(
212 void , SetRange(long start, long end),
213 "", "");
214
215
216 DocDeclStr(
217 void , SetStart(long start),
218 "", "");
219
220 DocDeclStr(
221 long , GetStart() const,
222 "", "");
223
224 %pythoncode { start = property(GetStart, SetStart) }
225
226 DocDeclStr(
227 void , SetEnd(long end),
228 "", "");
229
230 DocDeclStr(
231 long , GetEnd() const,
232 "", "");
233
234 %pythoncode { end = property(GetEnd, SetEnd) }
235
236
237 DocDeclStr(
238 bool , IsOutside(const wxRichTextRange& range) const,
239 "Returns true if this range is completely outside 'range'", "");
240
241
242 DocDeclStr(
243 bool , IsWithin(const wxRichTextRange& range) const,
244 "Returns true if this range is completely within 'range'", "");
245
246
247 DocDeclStr(
248 bool , Contains(long pos) const,
249 "Returns true if the given position is within this range. Allow for the
250possibility of an empty range - assume the position is within this
251empty range.", "");
252
253
254 DocDeclStr(
255 bool , LimitTo(const wxRichTextRange& range) ,
256 "Limit this range to be within 'range'", "");
257
258
259 DocDeclStr(
260 long , GetLength() const,
261 "Gets the length of the range", "");
262
263
264 DocDeclStr(
265 void , Swap(),
266 "Swaps the start and end", "");
267
268
269 %extend {
270 DocAStr(Get,
271 "Get() -> (start,end)",
272 "Returns the start and end properties as a tuple.", "");
273 PyObject* Get() {
274 wxPyBlock_t blocked = wxPyBeginBlockThreads();
275 PyObject* tup = PyTuple_New(2);
276 PyTuple_SET_ITEM(tup, 0, PyInt_FromLong(self->GetStart()));
277 PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->GetEnd()));
278 wxPyEndBlockThreads(blocked);
279 return tup;
280 }
281 }
282 %pythoncode {
283 def __str__(self): return str(self.Get())
284 def __repr__(self): return 'RichTextRange'+str(self.Get())
285 def __len__(self): return len(self.Get())
286 def __getitem__(self, index): return self.Get()[index]
287 def __setitem__(self, index, val):
288 if index == 0: self.start = val
289 elif index == 1: self.end = val
290 else: raise IndexError
291 def __nonzero__(self): return self.Get() != (0,0)
292 __safe_for_unpickling__ = True
293 def __reduce__(self): return (RichTextRange, self.Get())
294 }
e70b4d2d
RD
295
296 %property(End, GetEnd, SetEnd, doc="See `GetEnd` and `SetEnd`");
297 %property(Length, GetLength, doc="See `GetLength`");
298 %property(Start, GetStart, SetStart, doc="See `GetStart` and `SetStart`");
30fc5e8f
RD
299};
300
301
302
303%{
304 wxRichTextRange wxPy_RTR_ALL(wxRICHTEXT_ALL);
305 wxRichTextRange wxPy_RTR_NONE(wxRICHTEXT_NONE);
306%}
307
308%rename(RICHTEXT_ALL) wxPy_RTR_ALL;
309%rename(RICHTEXT_NONE) wxPy_RTR_NONE;
310
311%immutable;
312wxRichTextRange wxPy_RTR_ALL;
313wxRichTextRange wxPy_RTR_NONE;
314%mutable;
315
316//----------------------------------------------------------------------
317
318DocStr(wxRichTextAttr,
319"The RichTextAttr class stored information about the various attributes
320for a block of text, including font, colour, indents, alignments, and
321etc.", "");
322
323class wxRichTextAttr
324{
325public:
326
327 wxRichTextAttr(const wxColour& colText = wxNullColour,
328 const wxColour& colBack = wxNullColour,
329 wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
330
331 ~wxRichTextAttr();
332
333// // Making a wxTextAttrEx object.
334// operator wxTextAttrEx () const ;
335
336// // Copy to a wxTextAttr
337// void CopyTo(wxTextAttrEx& attr) const;
338
339
340
341 // Create font from font attributes.
342 DocDeclStr(
343 wxFont , CreateFont() const,
344 "", "");
345
346
347 // Get attributes from font.
348 bool GetFontAttributes(const wxFont& font);
349
350 %pythoncode {
351 def GetFont(self):
352 return self.CreateFont()
353 def SetFont(self, font):
354 return self.GetFontAttributes(font)
355 }
1aefbabe 356
30fc5e8f
RD
357 // setters
358 void SetTextColour(const wxColour& colText);
359 void SetBackgroundColour(const wxColour& colBack);
360 void SetAlignment(wxTextAttrAlignment alignment);
361 void SetTabs(const wxArrayInt& tabs);
362 void SetLeftIndent(int indent, int subIndent = 0);
363 void SetRightIndent(int indent);
364
365 void SetFontSize(int pointSize);
366 void SetFontStyle(int fontStyle);
367 void SetFontWeight(int fontWeight);
368 void SetFontFaceName(const wxString& faceName);
369 void SetFontUnderlined(bool underlined);
370
371 void SetFlags(long flags);
372
373 void SetCharacterStyleName(const wxString& name);
374 void SetParagraphStyleName(const wxString& name);
375 void SetParagraphSpacingAfter(int spacing);
376 void SetParagraphSpacingBefore(int spacing);
377 void SetLineSpacing(int spacing);
378 void SetBulletStyle(int style);
379 void SetBulletNumber(int n);
cbc3893c 380 void SetBulletText(wxChar symbol);
1aefbabe
RD
381 void SetBulletFont(const wxString& bulletFont);
382
30fc5e8f
RD
383 const wxColour& GetTextColour() const;
384 const wxColour& GetBackgroundColour() const;
385 wxTextAttrAlignment GetAlignment() const;
386 const wxArrayInt& GetTabs() const;
387 long GetLeftIndent() const;
388 long GetLeftSubIndent() const;
389 long GetRightIndent() const;
390 long GetFlags() const;
391
392 int GetFontSize() const;
393 int GetFontStyle() const;
394 int GetFontWeight() const;
395 bool GetFontUnderlined() const;
396 const wxString& GetFontFaceName() const;
397
398 const wxString& GetCharacterStyleName() const;
399 const wxString& GetParagraphStyleName() const;
400 int GetParagraphSpacingAfter() const;
401 int GetParagraphSpacingBefore() const;
402 int GetLineSpacing() const;
403 int GetBulletStyle() const;
1aefbabe 404 int GetBulletNumber() const;
cbc3893c 405 const wxString& GetBulletText() const;
1aefbabe 406 const wxString& GetBulletFont() const;
30fc5e8f
RD
407
408 // accessors
409 bool HasTextColour() const;
410 bool HasBackgroundColour() const;
411 bool HasAlignment() const;
412 bool HasTabs() const;
413 bool HasLeftIndent() const;
414 bool HasRightIndent() const;
4de4adce
RD
415// bool HasWeight() const;
416// bool HasSize() const;
417// bool HasItalic() const;
418// bool HasUnderlined() const;
419// bool HasFaceName() const;
30fc5e8f
RD
420 bool HasFont() const;
421
422 bool HasParagraphSpacingAfter() const;
423 bool HasParagraphSpacingBefore() const;
424 bool HasLineSpacing() const;
425 bool HasCharacterStyleName() const;
426 bool HasParagraphStyleName() const;
427 bool HasBulletStyle() const;
428 bool HasBulletNumber() const;
cbc3893c 429 bool HasBulletText() const;
30fc5e8f
RD
430
431 bool HasFlag(long flag) const;
432
433 // Is this a character style?
434 bool IsCharacterStyle() const;
435 bool IsParagraphStyle() const;
436
437 // returns false if we have any attributes set, true otherwise
438 bool IsDefault() const;
439
1aefbabe 440
475edb11
RD
441// // return the attribute having the valid font and colours: it uses the
442// // attributes set in attr and falls back first to attrDefault and then to
443// // the text control font/colours for those attributes which are not set
444// static wxRichTextAttr Combine(const wxRichTextAttr& attr,
445// const wxRichTextAttr& attrDef,
446// const wxTextCtrlBase *text);
e70b4d2d 447
1aefbabe 448
e70b4d2d
RD
449 %property(Alignment, GetAlignment, SetAlignment, doc="See `GetAlignment` and `SetAlignment`");
450 %property(BackgroundColour, GetBackgroundColour, SetBackgroundColour, doc="See `GetBackgroundColour` and `SetBackgroundColour`");
1aefbabe 451 %property(BulletFont, GetBulletFont, SetBulletFont, doc="See `GetBulletFont` and `SetBulletFont`");
e70b4d2d
RD
452 %property(BulletNumber, GetBulletNumber, SetBulletNumber, doc="See `GetBulletNumber` and `SetBulletNumber`");
453 %property(BulletStyle, GetBulletStyle, SetBulletStyle, doc="See `GetBulletStyle` and `SetBulletStyle`");
cbc3893c 454 %property(BulletText, GetBulletText, SetBulletText, doc="See `GetBulletText` and `SetBulletText`");
e70b4d2d
RD
455 %property(CharacterStyleName, GetCharacterStyleName, SetCharacterStyleName, doc="See `GetCharacterStyleName` and `SetCharacterStyleName`");
456 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
457 %property(Font, GetFont, SetFont, doc="See `GetFont` and `SetFont`");
458 %property(FontAttributes, GetFontAttributes, doc="See `GetFontAttributes`");
459 %property(FontFaceName, GetFontFaceName, SetFontFaceName, doc="See `GetFontFaceName` and `SetFontFaceName`");
460 %property(FontSize, GetFontSize, SetFontSize, doc="See `GetFontSize` and `SetFontSize`");
461 %property(FontStyle, GetFontStyle, SetFontStyle, doc="See `GetFontStyle` and `SetFontStyle`");
462 %property(FontUnderlined, GetFontUnderlined, SetFontUnderlined, doc="See `GetFontUnderlined` and `SetFontUnderlined`");
463 %property(FontWeight, GetFontWeight, SetFontWeight, doc="See `GetFontWeight` and `SetFontWeight`");
464 %property(LeftIndent, GetLeftIndent, SetLeftIndent, doc="See `GetLeftIndent` and `SetLeftIndent`");
465 %property(LeftSubIndent, GetLeftSubIndent, doc="See `GetLeftSubIndent`");
466 %property(LineSpacing, GetLineSpacing, SetLineSpacing, doc="See `GetLineSpacing` and `SetLineSpacing`");
467 %property(ParagraphSpacingAfter, GetParagraphSpacingAfter, SetParagraphSpacingAfter, doc="See `GetParagraphSpacingAfter` and `SetParagraphSpacingAfter`");
468 %property(ParagraphSpacingBefore, GetParagraphSpacingBefore, SetParagraphSpacingBefore, doc="See `GetParagraphSpacingBefore` and `SetParagraphSpacingBefore`");
469 %property(ParagraphStyleName, GetParagraphStyleName, SetParagraphStyleName, doc="See `GetParagraphStyleName` and `SetParagraphStyleName`");
470 %property(RightIndent, GetRightIndent, SetRightIndent, doc="See `GetRightIndent` and `SetRightIndent`");
471 %property(Tabs, GetTabs, SetTabs, doc="See `GetTabs` and `SetTabs`");
472 %property(TextColour, GetTextColour, SetTextColour, doc="See `GetTextColour` and `SetTextColour`");
30fc5e8f
RD
473};
474
475
476enum {
477 wxTEXT_ATTR_CHARACTER,
478 wxTEXT_ATTR_PARAGRAPH,
479 wxTEXT_ATTR_ALL
480};
481
482
483//----------------------------------------------------------------------
484//----------------------------------------------------------------------
485
486MustHaveApp(wxRichTextCtrl);
487DocStr(wxRichTextCtrl,
488"", "");
489
490class wxRichTextCtrl : public wxScrolledWindow
491{
492public:
493 %pythonAppend wxRichTextCtrl "self._setOORInfo(self)"
494 %pythonAppend wxRichTextCtrl() ""
495
496 wxRichTextCtrl( wxWindow* parent,
497 wxWindowID id = -1,
80b08b7f 498 const wxString& value = wxPyEmptyString,
30fc5e8f
RD
499 const wxPoint& pos = wxDefaultPosition,
500 const wxSize& size = wxDefaultSize,
501 long style = wxRE_MULTILINE );
502 %RenameCtor(PreRichTextCtrl, wxRichTextCtrl());
503
504
505 bool Create( wxWindow* parent,
506 wxWindowID id = -1,
80b08b7f 507 const wxString& value = wxPyEmptyString,
30fc5e8f
RD
508 const wxPoint& pos = wxDefaultPosition,
509 const wxSize& size = wxDefaultSize,
510 long style = wxRE_MULTILINE );
511
512
513 DocDeclStr(
514 virtual wxString , GetValue() const,
515 "", "");
516
517 DocDeclStr(
518 virtual void , SetValue(const wxString& value),
519 "", "");
520
521
522 DocDeclStr(
523 virtual wxString , GetRange(long from, long to) const,
524 "", "");
525
526
527 DocDeclStr(
528 virtual int , GetLineLength(long lineNo) const ,
529 "", "");
530
531 DocDeclStr(
532 virtual wxString , GetLineText(long lineNo) const ,
533 "", "");
534
535 DocDeclStr(
536 virtual int , GetNumberOfLines() const ,
537 "", "");
538
539
540 DocDeclStr(
541 virtual bool , IsModified() const ,
542 "", "");
543
544 DocDeclStr(
545 virtual bool , IsEditable() const ,
546 "", "");
547
548
549 // more readable flag testing methods
550 DocDeclStr(
551 bool , IsSingleLine() const,
552 "", "");
553
554 DocDeclStr(
555 bool , IsMultiLine() const,
556 "", "");
557
558
559 DocDeclAStr(
560 virtual void , GetSelection(long* OUTPUT, long* OUTPUT) const,
561 "GetSelection() --> (start, end)",
562 "Returns the start and end positions of the current selection. If the
563values are the same then there is no selection.", "");
564
565
566 DocDeclStr(
567 virtual wxString , GetStringSelection() const,
568 "", "");
569
570
571 DocDeclStr(
572 wxString , GetFilename() const,
573 "", "");
574
575
576 DocDeclStr(
577 void , SetFilename(const wxString& filename),
578 "", "");
579
580
581 DocDeclStr(
582 void , SetDelayedLayoutThreshold(long threshold),
583 "Set the threshold in character positions for doing layout optimization
584during sizing.", "");
585
586
587 DocDeclStr(
588 long , GetDelayedLayoutThreshold() const,
589 "Get the threshold in character positions for doing layout optimization
590during sizing.", "");
591
592
593
594 DocDeclStr(
595 virtual void , Clear(),
596 "", "");
597
598 DocDeclStr(
599 virtual void , Replace(long from, long to, const wxString& value),
600 "", "");
601
602 DocDeclStr(
603 virtual void , Remove(long from, long to),
604 "", "");
605
606
607 DocDeclStr(
608 virtual bool , LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY),
609 "Load the contents of the document from the given filename.", "");
610
611 DocDeclStr(
612 virtual bool , SaveFile(const wxString& file = wxPyEmptyString,
613 int type = wxRICHTEXT_TYPE_ANY),
614 "Save the contents of the document to the given filename, or if the
a2cccbc3 615empty string is passed then to the filename set with `SetFilename`.", "");
30fc5e8f
RD
616
617
cbc3893c
KO
618 DocDeclStr(
619 void , SetHandlerFlags(int flags),
620 "Set the handler flags, controlling loading and saving.", "");
621
622 DocDeclStr(
623 int , GetHandlerFlags() const,
624 "Get the handler flags, controlling loading and saving.", "");
625
30fc5e8f
RD
626 // sets/clears the dirty flag
627 DocDeclStr(
628 virtual void , MarkDirty(),
629 "Sets the dirty flag, meaning that the contents of the control have
630changed and need to be saved.", "");
631
632 DocDeclStr(
633 virtual void , DiscardEdits(),
634 "Clears the dirty flag.
635:see: `MarkDirty`", "");
636
637
638 DocDeclStr(
639 virtual void , SetMaxLength(unsigned long len),
640 "Set the max number of characters which may be entered in a single line
641text control.", "");
642
643
644 DocDeclStr(
645 virtual void , WriteText(const wxString& text),
646 "Insert text at the current position.", "");
647
648 DocDeclStr(
649 virtual void , AppendText(const wxString& text),
650 "Append text to the end of the document.", "");
651
652
653 DocDeclStr(
654 virtual bool , SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style),
655 "Set the style for the text in ``range`` to ``style``", "");
656
1aefbabe
RD
657 DocDeclStr(
658 virtual bool , SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style,
659 int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO),
660 "Extended style setting operation with flags including:
661RICHTEXT_SETSTYLE_WITH_UNDO, RICHTEXT_SETSTYLE_OPTIMIZE,
662RICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, RICHTEXT_SETSTYLE_CHARACTERS_ONLY", "");
663
664
665
30fc5e8f 666 DocDeclStr(
74c8720e 667 virtual bool , GetStyle(long position, wxRichTextAttr& style),
30fc5e8f 668 "Retrieve the style used at the given position. Copies the style
bdec7d7a 669values at ``position`` into the ``style`` parameter and returns ``True``
30fc5e8f
RD
670if successful. Returns ``False`` otherwise.", "");
671
bdec7d7a
RD
672 DocDeclStr(
673 virtual bool , GetUncombinedStyle(long position, wxRichTextAttr& style),
674 "Get the content (uncombined) attributes for this position. Copies the
675style values at ``position`` into the ``style`` parameter and returns
676``True`` if successful. Returns ``False`` otherwise.", "");
1aefbabe
RD
677
678
30fc5e8f
RD
679 DocDeclStr(
680 virtual bool , SetDefaultStyle(const wxRichTextAttr& style),
681 "Set the style used by default for the rich text document.", "");
682
683
684 DocDeclStrName(
685 virtual const wxRichTextAttr , GetDefaultStyleEx() const,
686 "Retrieves a copy of the default style object.", "",
687 GetDefaultStyle);
688
689
690 DocDeclStr(
691 virtual long , XYToPosition(long x, long y) const,
692 "Translate a col,row coordinants into a document position.", "");
693
694 DocDeclAStr(
695 virtual void , PositionToXY(long pos, long *OUTPUT, long *OUTPUT) const,
696 "PositionToXY(self, long pos) --> (x, y)",
697 "Retrieves the col,row for the given position within the document", "");
698
699
700 DocDeclStr(
701 virtual void , ShowPosition(long position),
702 "Ensure that the given position in the document is visible.", "");
703
704
705 DocDeclAStr(
706 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt, long *OUTPUT) const,
707 "HitTest(self, Point pt) --> (result, pos)",
708 "Returns the character position at the given point in pixels. Note
709that ``pt`` should be given in device coordinates, and not be adjusted
710for the client area origin nor for scrolling. The return value is a
711tuple of the hit test result and the position.", "
712
713Possible result values are a bitmask of these flags:
714
715 ========================= ====================================
716 RICHTEXT_HITTEST_NONE The point was not on this object.
717 RICHTEXT_HITTEST_BEFORE The point was before the position
718 returned from HitTest.
719 RICHTEXT_HITTEST_AFTER The point was after the position
720 returned from HitTest.
721 RICHTEXT_HITTEST_ON The point was on the position
722 returned from HitTest
723 ========================= ====================================
724");
725
726 DocDeclAStrName(
727 virtual wxTextCtrlHitTestResult , HitTest(const wxPoint& pt,
728 wxTextCoord *OUTPUT,
729 wxTextCoord *OUTPUT) const,
730 "HitTestRC(self, Point pt) --> (result, col, row)",
731 "Returns the column and row of the given point in pixels. Note that
732``pt`` should be given in device coordinates, and not be adjusted for
733the client area origin nor for scrolling. The return value is a tuple
734of the hit test result and the column and row values.", "
735:see: `HitTest`",
736 HitTestXY);
737
738
739 // Clipboard operations
740 DocDeclStr(
741 virtual void , Copy(),
742 "Copies the selected text to the clipboard.", "");
743
744 DocDeclStr(
745 virtual void , Cut(),
746 "Copies the selected text to the clipboard and removes the selection.", "");
747
748 DocDeclStr(
749 virtual void , Paste(),
750 "Pastes text from the clipboard into the document at the current
751insertion point.", "");
752
753 DocDeclStr(
754 virtual void , DeleteSelection(),
755 "Remove the current selection.", "");
756
757
758 DocDeclStr(
759 virtual bool , CanCopy() const,
760 "Returns ``True`` if the selection can be copied to the clipboard.", "");
761
762 DocDeclStr(
763 virtual bool , CanCut() const,
764 "Returns ``True`` if the selection can be cut to the clipboard.", "");
765
766 DocDeclStr(
767 virtual bool , CanPaste() const,
768 "Returns ``True`` if the current contents of the clipboard can be
769pasted into the document.", "");
770
771 DocDeclStr(
772 virtual bool , CanDeleteSelection() const,
773 "Returns ``True`` if the selection can be removed from the document.", "");
774
775
776 // Undo/redo
777 DocDeclStr(
778 virtual void , Undo(),
779 "If the last operation can be undone, undoes the last operation.", "");
780
781 DocDeclStr(
782 virtual void , Redo(),
783 "If the last operation can be redone, redoes the last operation.", "");
784
785
786 DocDeclStr(
787 virtual bool , CanUndo() const,
788 "Returns ``True`` if the last operation can be undone.", "");
789
790 DocDeclStr(
791 virtual bool , CanRedo() const,
792 "Returns ``True`` if the last operation can be redone.", "");
793
794
795 // Insertion point
796 DocDeclStr(
797 virtual void , SetInsertionPoint(long pos),
798 "Sets the insertion point at the given position.", "");
799
800 DocDeclStr(
801 virtual void , SetInsertionPointEnd(),
802 "Moves the insertion point to the end of the document.", "");
803
804 DocDeclStr(
805 virtual long , GetInsertionPoint() const,
806 "Returns the insertion point. This is defined as the zero based index
807of the character position to the right of the insertion point.", "");
808
809 DocDeclStr(
810 virtual long , GetLastPosition() const,
811 "Returns the zero based index of the last position in the document.", "");
812
813
814 DocDeclStr(
815 virtual void , SetSelection(long from, long to),
816 "Selects the text starting at the first position up to (but not
817including) the character at the last position. If both parameters are
818equal to -1 then all text in the control is selected.", "");
819
820 DocDeclStr(
821 virtual void , SelectAll(),
822 "Select all text in the document.", "");
823
824 DocDeclStr(
825 virtual void , SetEditable(bool editable),
826 "Makes the document editable or read-only, overriding the RE_READONLY
827flag.", "");
828
829
830// /// Call Freeze to prevent refresh
831// virtual void Freeze();
832
833// /// Call Thaw to refresh
834// virtual void Thaw();
835
836// /// Call Thaw to refresh
837// DocDeclStr(
838// virtual bool , IsFrozen() const,
839// "", "");
840
841
842 DocDeclStr(
843 virtual bool , HasSelection() const,
844 "", "");
845
846
847///// Functionality specific to wxRichTextCtrl
848
849 /// Write an image at the current insertion point. Supply optional type to use
850 /// for internal and file storage of the raw data.
851 DocDeclStr(
852 virtual bool , WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG),
853 "", "");
854
855
856 /// Write a bitmap at the current insertion point. Supply optional type to use
857 /// for internal and file storage of the raw data.
858 DocDeclStrName(
859 virtual bool , WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG),
860 "", "",
861 WriteBitmap);
862
863
864 /// Load an image from file and write at the current insertion point.
865 DocDeclStrName(
866 virtual bool , WriteImage(const wxString& filename, int bitmapType),
867 "", "",
868 WriteImageFile);
869
870
871 /// Write an image block at the current insertion point.
872 DocDeclStrName(
873 virtual bool , WriteImage(const wxRichTextImageBlock& imageBlock),
874 "", "",
875 WriteImageBlock);
876
877
878 /// Insert a newline (actually paragraph) at the current insertion point.
879 DocDeclStr(
880 virtual bool , Newline(),
881 "", "");
882
883
884#if USE_TEXTATTREX
885/// Set basic (overall) style
886 DocDeclStr(
887 virtual void , SetBasicStyle(const wxTextAttrEx& style),
888 "", "");
889#endif
890
891 DocDeclStr(
892 virtual void , SetBasicStyle(const wxRichTextAttr& style),
893 "", "");
894
895
896#if USE_TEXTATTREX
897 /// Get basic (overall) style
898 DocDeclStr(
899 virtual const wxTextAttrEx& , GetBasicStyle() const,
900 "", "");
901
902
903 /// Begin using a style
904 DocDeclStr(
905 virtual bool , BeginStyle(const wxTextAttrEx& style),
906 "", "");
907#endif
908
909 /// End the style
910 DocDeclStr(
911 virtual bool , EndStyle(),
912 "", "");
913
914
915 /// End all styles
916 DocDeclStr(
917 virtual bool , EndAllStyles(),
918 "", "");
919
920
921 /// Begin using bold
922 DocDeclStr(
923 bool , BeginBold(),
924 "", "");
925
926
927 /// End using bold
928 DocDeclStr(
929 bool , EndBold(),
930 "", "");
931
932
933 /// Begin using italic
934 DocDeclStr(
935 bool , BeginItalic(),
936 "", "");
937
938
939 /// End using italic
940 DocDeclStr(
941 bool , EndItalic(),
942 "", "");
943
944
945 /// Begin using underline
946 DocDeclStr(
947 bool , BeginUnderline(),
948 "", "");
949
950
951 /// End using underline
952 DocDeclStr(
953 bool , EndUnderline(),
954 "", "");
955
956
957 /// Begin using point size
958 DocDeclStr(
959 bool , BeginFontSize(int pointSize),
960 "", "");
961
962
963 /// End using point size
964 DocDeclStr(
965 bool , EndFontSize(),
966 "", "");
967
968
969 /// Begin using this font
970 DocDeclStr(
971 bool , BeginFont(const wxFont& font),
972 "", "");
973
974
975 /// End using a font
976 DocDeclStr(
977 bool , EndFont(),
978 "", "");
979
980
981 /// Begin using this colour
982 DocDeclStr(
983 bool , BeginTextColour(const wxColour& colour),
984 "", "");
985
986
987 /// End using a colour
988 DocDeclStr(
989 bool , EndTextColour(),
990 "", "");
991
992
993 /// Begin using alignment
994 DocDeclStr(
995 bool , BeginAlignment(wxTextAttrAlignment alignment),
996 "", "");
997
998
999 /// End alignment
1000 DocDeclStr(
1001 bool , EndAlignment(),
1002 "", "");
1003
1004
1005 /// Begin left indent
1006 DocDeclStr(
1007 bool , BeginLeftIndent(int leftIndent, int leftSubIndent = 0),
1008 "", "");
1009
1010
1011 /// End left indent
1012 DocDeclStr(
1013 bool , EndLeftIndent(),
1014 "", "");
1015
1016
1017 /// Begin right indent
1018 DocDeclStr(
1019 bool , BeginRightIndent(int rightIndent),
1020 "", "");
1021
1022
1023 /// End right indent
1024 DocDeclStr(
1025 bool , EndRightIndent(),
1026 "", "");
1027
1028
1029 /// Begin paragraph spacing
1030 DocDeclStr(
1031 bool , BeginParagraphSpacing(int before, int after),
1032 "", "");
1033
1034
1035 /// End paragraph spacing
1036 DocDeclStr(
1037 bool , EndParagraphSpacing(),
1038 "", "");
1039
1040
1041 /// Begin line spacing
1042 DocDeclStr(
1043 bool , BeginLineSpacing(int lineSpacing),
1044 "", "");
1045
1046
1047 /// End line spacing
1048 DocDeclStr(
1049 bool , EndLineSpacing(),
1050 "", "");
1051
1052
1053 /// Begin numbered bullet
1054 DocDeclStr(
1055 bool , BeginNumberedBullet(int bulletNumber,
1056 int leftIndent,
1057 int leftSubIndent,
1058 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD),
1059 "", "");
1060
1061
1062 /// End numbered bullet
1063 DocDeclStr(
1064 bool , EndNumberedBullet(),
1065 "", "");
1066
1067
1068 /// Begin symbol bullet
1069 DocDeclStr(
cbc3893c 1070 bool , BeginSymbolBullet(const wxString& symbol,
30fc5e8f
RD
1071 int leftIndent,
1072 int leftSubIndent,
1073 int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL),
1074 "", "");
1075
1076
1077 /// End symbol bullet
1078 DocDeclStr(
1079 bool , EndSymbolBullet(),
1080 "", "");
1081
1082
1083 /// Begin named character style
1084 DocDeclStr(
1085 bool , BeginCharacterStyle(const wxString& characterStyle),
1086 "", "");
1087
1088
1089 /// End named character style
1090 DocDeclStr(
1091 bool , EndCharacterStyle(),
1092 "", "");
1093
1094
1095 /// Begin named paragraph style
1096 DocDeclStr(
1097 bool , BeginParagraphStyle(const wxString& paragraphStyle),
1098 "", "");
1099
1100
1101 /// End named character style
1102 DocDeclStr(
1103 bool , EndParagraphStyle(),
1104 "", "");
1105
1106
cbc3893c
KO
1107 DocDeclStr(
1108 bool , BeginListStyle(const wxString& listStyle, int level = 1, int number = 1),
1109 "Begin named list style.", "");
1110
1111 DocDeclStr(
1112 bool , EndListStyle(), "End named list style.", "");
1113
1114 DocDeclStr(
1115 bool , BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString),
1116 "Begin URL.", "");
1117
1118 DocDeclStr(
1119 bool , EndURL(), "End URL.", "");
1120
30fc5e8f
RD
1121 /// Sets the default style to the style under the cursor
1122 DocDeclStr(
1123 bool , SetDefaultStyleToCursorStyle(),
1124 "", "");
1125
1126
1127 /// Clear the selection
1128 DocDeclStr(
1129 virtual void , SelectNone(),
1130 "", "");
1131
bdec7d7a
RD
1132 /// Select the word at the given character position
1133 DocDeclStr(
1134 virtual bool , SelectWord(long position),
1135 "", "");
1aefbabe 1136
30fc5e8f
RD
1137
1138 /// Get/set the selection range in character positions. -1, -1 means no selection.
1139 DocDeclStr(
74c8720e 1140 wxRichTextRange , GetSelectionRange() const,
30fc5e8f
RD
1141 "", "");
1142
1143 DocDeclStr(
1144 void , SetSelectionRange(const wxRichTextRange& range),
1145 "", "");
1146
74c8720e
RD
1147 /// Get/set the selection range in character positions. -1, -1 means no selection.
1148 /// The range is in internal format, i.e. a single character selection is denoted
1149 /// by (n, n)
1150 DocDeclStr(
1151 const wxRichTextRange& , GetInternalSelectionRange() const,
1152 "", "");
1aefbabe 1153
74c8720e
RD
1154 DocDeclStr(
1155 void , SetInternalSelectionRange(const wxRichTextRange& range),
1156 "", "");
1aefbabe 1157
74c8720e 1158
30fc5e8f
RD
1159
1160 /// Add a new paragraph of text to the end of the buffer
1161 DocDeclStr(
1162 virtual wxRichTextRange , AddParagraph(const wxString& text),
1163 "", "");
1164
1165
1166 /// Add an image
1167 DocDeclStr(
1168 virtual wxRichTextRange , AddImage(const wxImage& image),
1169 "", "");
1170
1171
1172 /// Layout the buffer: which we must do before certain operations, such as
1173 /// setting the caret position.
1174 DocDeclStr(
1175 virtual bool , LayoutContent(bool onlyVisibleRect = false),
1176 "", "");
1177
1178
1179 /// Move the caret to the given character position
1180 DocDeclStr(
1181 virtual bool , MoveCaret(long pos, bool showAtLineStart = false),
1182 "", "");
1183
1184
1185 /// Move right
1186 DocDeclStr(
1187 virtual bool , MoveRight(int noPositions = 1, int flags = 0),
1188 "", "");
1189
1190
1191 /// Move left
1192 DocDeclStr(
1193 virtual bool , MoveLeft(int noPositions = 1, int flags = 0),
1194 "", "");
1195
1196
1197 /// Move up
1198 DocDeclStr(
1199 virtual bool , MoveUp(int noLines = 1, int flags = 0),
1200 "", "");
1201
1202
1203 /// Move up
1204 DocDeclStr(
1205 virtual bool , MoveDown(int noLines = 1, int flags = 0),
1206 "", "");
1207
1208
1209 /// Move to the end of the line
1210 DocDeclStr(
1211 virtual bool , MoveToLineEnd(int flags = 0),
1212 "", "");
1213
1214
1215 /// Move to the start of the line
1216 DocDeclStr(
1217 virtual bool , MoveToLineStart(int flags = 0),
1218 "", "");
1219
1220
1221 /// Move to the end of the paragraph
1222 DocDeclStr(
1223 virtual bool , MoveToParagraphEnd(int flags = 0),
1224 "", "");
1225
1226
1227 /// Move to the start of the paragraph
1228 DocDeclStr(
1229 virtual bool , MoveToParagraphStart(int flags = 0),
1230 "", "");
1231
1232
1233 /// Move to the start of the buffer
1234 DocDeclStr(
1235 virtual bool , MoveHome(int flags = 0),
1236 "", "");
1237
1238
1239 /// Move to the end of the buffer
1240 DocDeclStr(
1241 virtual bool , MoveEnd(int flags = 0),
1242 "", "");
1243
1244
1245 /// Move n pages up
1246 DocDeclStr(
1247 virtual bool , PageUp(int noPages = 1, int flags = 0),
1248 "", "");
1249
1250
1251 /// Move n pages down
1252 DocDeclStr(
1253 virtual bool , PageDown(int noPages = 1, int flags = 0),
1254 "", "");
1255
1256
1257 /// Move n words left
1258 DocDeclStr(
1259 virtual bool , WordLeft(int noPages = 1, int flags = 0),
1260 "", "");
1261
1262
1263 /// Move n words right
1264 DocDeclStr(
1265 virtual bool , WordRight(int noPages = 1, int flags = 0),
1266 "", "");
1267
1268
1269 /// Returns the buffer associated with the control.
1270// wxRichTextBuffer& GetBuffer();
1271 DocDeclStr(
1272 const wxRichTextBuffer& , GetBuffer() const,
1273 "", "");
1274
1275
1276 /// Start batching undo history for commands.
1277 DocDeclStr(
1278 virtual bool , BeginBatchUndo(const wxString& cmdName),
1279 "", "");
1280
1281
1282 /// End batching undo history for commands.
1283 DocDeclStr(
1284 virtual bool , EndBatchUndo(),
1285 "", "");
1286
1287
1288 /// Are we batching undo history for commands?
1289 DocDeclStr(
1290 virtual bool , BatchingUndo() const,
1291 "", "");
1292
1293
1294 /// Start suppressing undo history for commands.
1295 DocDeclStr(
1296 virtual bool , BeginSuppressUndo(),
1297 "", "");
1298
1299
1300 /// End suppressing undo history for commands.
1301 DocDeclStr(
1302 virtual bool , EndSuppressUndo(),
1303 "", "");
1304
1305
1306 /// Are we suppressing undo history for commands?
1307 DocDeclStr(
1308 virtual bool , SuppressingUndo() const,
1309 "", "");
1310
1311
1312 /// Test if this whole range has character attributes of the specified kind. If any
1313 /// of the attributes are different within the range, the test fails. You
1314 /// can use this to implement, for example, bold button updating. style must have
1315 /// flags indicating which attributes are of interest.
1316#if USE_TEXTATTREX
1317 DocDeclStr(
1318 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1319 const wxTextAttrEx& style) const,
1320 "", "");
1321#endif
1322
1323 DocDeclStr(
1324 virtual bool , HasCharacterAttributes(const wxRichTextRange& range,
1325 const wxRichTextAttr& style) const,
1326 "", "");
1327
1328
1329
1330 /// Test if this whole range has paragraph attributes of the specified kind. If any
1331 /// of the attributes are different within the range, the test fails. You
1332 /// can use this to implement, for example, centering button updating. style must have
1333 /// flags indicating which attributes are of interest.
1334#if USE_TEXTATTREX
1335 DocDeclStr(
1336 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1337 const wxTextAttrEx& style) const,
1338 "", "");
1339#endif
1340
1341 DocDeclStr(
1342 virtual bool , HasParagraphAttributes(const wxRichTextRange& range,
1343 const wxRichTextAttr& style) const,
1344 "", "");
1345
1346
1347
1348 /// Is all of the selection bold?
1349 DocDeclStr(
74c8720e 1350 virtual bool , IsSelectionBold(),
30fc5e8f
RD
1351 "", "");
1352
1353
1354 /// Is all of the selection italics?
1355 DocDeclStr(
74c8720e 1356 virtual bool , IsSelectionItalics(),
30fc5e8f
RD
1357 "", "");
1358
1359
1360 /// Is all of the selection underlined?
1361 DocDeclStr(
74c8720e 1362 virtual bool , IsSelectionUnderlined(),
30fc5e8f
RD
1363 "", "");
1364
1365
1366 /// Is all of the selection aligned according to the specified flag?
1367 DocDeclStr(
74c8720e 1368 virtual bool , IsSelectionAligned(wxTextAttrAlignment alignment),
30fc5e8f
RD
1369 "", "");
1370
1371
1372 /// Apply bold to the selection
1373 DocDeclStr(
1374 virtual bool , ApplyBoldToSelection(),
1375 "", "");
1376
1377
1378 /// Apply italic to the selection
1379 DocDeclStr(
1380 virtual bool , ApplyItalicToSelection(),
1381 "", "");
1382
1383
1384 /// Apply underline to the selection
1385 DocDeclStr(
1386 virtual bool , ApplyUnderlineToSelection(),
1387 "", "");
1388
1389
1390 /// Apply alignment to the selection
1391 DocDeclStr(
1392 virtual bool , ApplyAlignmentToSelection(wxTextAttrAlignment alignment),
1393 "", "");
1394
1395
1396 /// Set style sheet, if any.
1397 DocDeclStr(
1398 void , SetStyleSheet(wxRichTextStyleSheet* styleSheet),
1399 "", "");
1400
1401 DocDeclStr(
1402 wxRichTextStyleSheet* , GetStyleSheet() const,
1403 "", "");
1404
bdec7d7a
RD
1405 /// Apply the style sheet to the buffer, for example if the styles have changed.
1406 DocDeclStr(
1407 bool , ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL),
1408 "", "");
1aefbabe
RD
1409
1410
30fc5e8f 1411
e70b4d2d
RD
1412 %property(Buffer, GetBuffer, doc="See `GetBuffer`");
1413 %property(DefaultStyle, GetDefaultStyle, SetDefaultStyle, doc="See `GetDefaultStyle` and `SetDefaultStyle`");
1414 %property(DelayedLayoutThreshold, GetDelayedLayoutThreshold, SetDelayedLayoutThreshold, doc="See `GetDelayedLayoutThreshold` and `SetDelayedLayoutThreshold`");
1415 %property(Filename, GetFilename, SetFilename, doc="See `GetFilename` and `SetFilename`");
1416 %property(InsertionPoint, GetInsertionPoint, SetInsertionPoint, doc="See `GetInsertionPoint` and `SetInsertionPoint`");
1417 %property(InternalSelectionRange, GetInternalSelectionRange, SetInternalSelectionRange, doc="See `GetInternalSelectionRange` and `SetInternalSelectionRange`");
1418 %property(LastPosition, GetLastPosition, doc="See `GetLastPosition`");
1419 %property(NumberOfLines, GetNumberOfLines, doc="See `GetNumberOfLines`");
71975d80 1420 %property(Selection, GetSelection, SetSelectionRange, doc="See `GetSelection` and `SetSelection`");
e70b4d2d
RD
1421 %property(SelectionRange, GetSelectionRange, SetSelectionRange, doc="See `GetSelectionRange` and `SetSelectionRange`");
1422 %property(StringSelection, GetStringSelection, doc="See `GetStringSelection`");
1423 %property(StyleSheet, GetStyleSheet, SetStyleSheet, doc="See `GetStyleSheet` and `SetStyleSheet`");
1424 %property(Value, GetValue, SetValue, doc="See `GetValue` and `SetValue`");
30fc5e8f
RD
1425
1426// Implementation
1427// TODO: Which of these should be exposed to Python?
1428
1429// /// Set font, and also default attributes
1430// virtual bool SetFont(const wxFont& font);
1431
1432// /// Set up scrollbars, e.g. after a resize
1433// virtual void SetupScrollbars(bool atTop = false);
1434
1435// /// Keyboard navigation
1436// virtual bool KeyboardNavigate(int keyCode, int flags);
1437
1438// /// Paint the background
1439// virtual void PaintBackground(wxDC& dc);
1440
1441// /// Recreate buffer bitmap if necessary
1442// virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1443
1444// /// Set the selection
1445// virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
1446
1447// /// Write text
1448// virtual void DoWriteText(const wxString& value, bool selectionOnly = true);
1449
1450// /// Send an update event
1451// virtual bool SendUpdateEvent();
1452
1453// /// Init command event
1454// void InitCommandEvent(wxCommandEvent& event) const;
1455
1456// /// do the window-specific processing after processing the update event
1457// // (duplicated code from wxTextCtrlBase)
1458// #if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
1459// virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
1460// #endif
1461
1462// /// Should we inherit colours?
1463// virtual bool ShouldInheritColours() const;
1464
1465// /// Position the caret
1466// virtual void PositionCaret();
1467
1468// /// Extend the selection, returning true if the selection was
1469// /// changed. Selections are in caret positions.
1470// virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1471
1472// /// Scroll into view. This takes a _caret_ position.
1473// virtual bool ScrollIntoView(long position, int keyCode);
1474
1475// /// The caret position is the character position just before the caret.
1476// /// A value of -1 means the caret is at the start of the buffer.
1477// void SetCaretPosition(long position, bool showAtLineStart = false) ;
1478// long GetCaretPosition() const;
1479
1480// /// Move caret one visual step forward: this may mean setting a flag
1481// /// and keeping the same position if we're going from the end of one line
1482// /// to the start of the next, which may be the exact same caret position.
1483// void MoveCaretForward(long oldPosition) ;
1484
1485// /// Move caret one visual step forward: this may mean setting a flag
1486// /// and keeping the same position if we're going from the end of one line
1487// /// to the start of the next, which may be the exact same caret position.
1488// void MoveCaretBack(long oldPosition) ;
1489
1490// /// Get the caret height and position for the given character position
1491// bool GetCaretPositionForIndex(long position, wxRect& rect);
1492
1493// /// Gets the line for the visible caret position. If the caret is
1494// /// shown at the very end of the line, it means the next character is actually
1495// /// on the following line. So let's get the line we're expecting to find
1496// /// if this is the case.
1497// wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1498
1499// /// Gets the command processor
1500// wxCommandProcessor* GetCommandProcessor() const;
1501
1502// /// Delete content if there is a selection, e.g. when pressing a key.
1503// /// Returns the new caret position in newPos, or leaves it if there
1504// /// was no action.
1505// bool DeleteSelectedContent(long* newPos= NULL);
1506
1507// /// Transform logical to physical
1508// wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
1509
1510// /// Transform physical to logical
1511// wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
1512
1513// /// Finds the caret position for the next word. Direction
1514// /// is 1 (forward) or -1 (backwards).
1515// virtual long FindNextWordPosition(int direction = 1) const;
1516
1517// /// Is the given position visible on the screen?
1518// bool IsPositionVisible(long pos) const;
1519
1520// /// Returns the first visible position in the current view
1521// long GetFirstVisiblePosition() const;
1522};
1523
1524
1525//----------------------------------------------------------------------
1526
1527
30fc5e8f
RD
1528%constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_CLICK;
1529%constant wxEventType wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK;
1530%constant wxEventType wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK;
1531%constant wxEventType wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK;
1532%constant wxEventType wxEVT_COMMAND_RICHTEXT_RETURN;
cbc3893c
KO
1533%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING;
1534%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED;
1535%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING;
1536%constant wxEventType wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED;
c8408242
KO
1537%constant wxEventType wxEVT_COMMAND_RICHTEXT_CHARACTER;
1538%constant wxEventType wxEVT_COMMAND_RICHTEXT_DELETE;
30fc5e8f
RD
1539
1540%pythoncode {
30fc5e8f
RD
1541EVT_RICHTEXT_LEFT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 1)
1542EVT_RICHTEXT_RIGHT_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 1)
1543EVT_RICHTEXT_MIDDLE_CLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 1)
1544EVT_RICHTEXT_LEFT_DCLICK = wx.PyEventBinder(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 1)
1545EVT_RICHTEXT_RETURN = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_RETURN, 1)
cbc3893c
KO
1546EVT_RICHTEXT_STYLESHEET_CHANGING = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, 1)
1547EVT_RICHTEXT_STYLESHEET_CHANGED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, 1)
1548EVT_RICHTEXT_STYLESHEET_REPLACING = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, 1)
1549EVT_RICHTEXT_STYLESHEET_REPLACED = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, 1)
c8408242
KO
1550EVT_RICHTEXT_CHARACTER = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_CHARACTER, 1)
1551EVT_RICHTEXT_DELETE = wx.PyEventBinder( wxEVT_COMMAND_RICHTEXT_DELETE, 1)
30fc5e8f
RD
1552}
1553
1554
1555class wxRichTextEvent : public wxNotifyEvent
1556{
1557public:
1558 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
1559
c8408242
KO
1560 int GetPosition() const;
1561 void SetPosition(int n);
30fc5e8f
RD
1562
1563 int GetFlags() const;
1564 void SetFlags(int flags);
e70b4d2d
RD
1565
1566 %property(Flags, GetFlags, SetFlags, doc="See `GetFlags` and `SetFlags`");
c8408242 1567 %property(Index, GetPosition, SetPosition, doc="See `GetPosition` and `SetPosition`");
30fc5e8f
RD
1568};
1569
1570//----------------------------------------------------------------------
1571
1572%init %{
cd46ad2b 1573 wxRichTextModuleInit();
30fc5e8f
RD
1574%}
1575
1576//----------------------------------------------------------------------