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