]>
Commit | Line | Data |
---|---|---|
a1b82138 | 1 | /////////////////////////////////////////////////////////////////////////////// |
40ff126a | 2 | // Name: wx/textctrl.h |
a1b82138 VZ |
3 | // Purpose: wxTextCtrlBase class - the interface of wxTextCtrl |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 13.07.99 | |
7 | // RCS-ID: $Id$ | |
99d80019 | 8 | // Copyright: (c) Vadim Zeitlin |
65571936 | 9 | // Licence: wxWindows licence |
a1b82138 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_TEXTCTRL_H_BASE_ |
13 | #define _WX_TEXTCTRL_H_BASE_ | |
c801d85f | 14 | |
a1b82138 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
4bc1afd5 | 18 | |
a1b82138 | 19 | #include "wx/defs.h" |
1e6feb95 VZ |
20 | |
21 | #if wxUSE_TEXTCTRL | |
22 | ||
a1b82138 | 23 | #include "wx/control.h" // the base class |
0ec1179b | 24 | #include "wx/textentry.h" // single-line text entry interface |
efe66bbc VZ |
25 | #include "wx/dynarray.h" // wxArrayInt |
26 | #include "wx/gdicmn.h" // wxPoint | |
a1b82138 | 27 | |
15cdc341 WS |
28 | // Open Watcom 1.3 does allow only ios::rdbuf() while |
29 | // we want something with streambuf parameter | |
30 | // Also, can't use streambuf if making or using a DLL :-( | |
a1b82138 | 31 | |
15cdc341 WS |
32 | #if defined(__WATCOMC__) || \ |
33 | defined(__MWERKS__) || \ | |
2a92d7e5 | 34 | (defined(__WINDOWS__) && (defined(WXUSINGDLL) || defined(WXMAKINGDLL))) |
15cdc341 WS |
35 | #define wxHAS_TEXT_WINDOW_STREAM 0 |
36 | #elif wxUSE_STD_IOSTREAM | |
37 | #include "wx/ioswrap.h" | |
38 | #define wxHAS_TEXT_WINDOW_STREAM 1 | |
39 | #else | |
40 | #define wxHAS_TEXT_WINDOW_STREAM 0 | |
a1b82138 VZ |
41 | #endif |
42 | ||
b5dbe15d VS |
43 | class WXDLLIMPEXP_FWD_CORE wxTextCtrl; |
44 | class WXDLLIMPEXP_FWD_CORE wxTextCtrlBase; | |
0efe5ba7 | 45 | |
efe66bbc VZ |
46 | // ---------------------------------------------------------------------------- |
47 | // wxTextCtrl types | |
48 | // ---------------------------------------------------------------------------- | |
49 | ||
efe66bbc VZ |
50 | // wxTextCoord is the line or row number (which should have been unsigned but |
51 | // is long for backwards compatibility) | |
52 | typedef long wxTextCoord; | |
53 | ||
a1b82138 VZ |
54 | // ---------------------------------------------------------------------------- |
55 | // constants | |
56 | // ---------------------------------------------------------------------------- | |
57 | ||
f36e602b | 58 | extern WXDLLEXPORT_DATA(const char) wxTextCtrlNameStr[]; |
a1b82138 | 59 | |
7d8268a1 WS |
60 | // this is intentionally not enum to avoid warning fixes with |
61 | // typecasting from enum type to wxTextCoord | |
62 | const wxTextCoord wxOutOfRangeTextCoord = -1; | |
63 | const wxTextCoord wxInvalidTextCoord = -2; | |
64 | ||
c57e3339 VZ |
65 | // ---------------------------------------------------------------------------- |
66 | // wxTextCtrl style flags | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
e015d1f7 JS |
69 | #define wxTE_NO_VSCROLL 0x0002 |
70 | #define wxTE_AUTO_SCROLL 0x0008 | |
71 | ||
c57e3339 VZ |
72 | #define wxTE_READONLY 0x0010 |
73 | #define wxTE_MULTILINE 0x0020 | |
74 | #define wxTE_PROCESS_TAB 0x0040 | |
75 | ||
e015d1f7 JS |
76 | // alignment flags |
77 | #define wxTE_LEFT 0x0000 // 0x0000 | |
78 | #define wxTE_CENTER wxALIGN_CENTER_HORIZONTAL // 0x0100 | |
79 | #define wxTE_RIGHT wxALIGN_RIGHT // 0x0200 | |
80 | #define wxTE_CENTRE wxTE_CENTER | |
81 | ||
c57e3339 VZ |
82 | // this style means to use RICHEDIT control and does something only under wxMSW |
83 | // and Win32 and is silently ignored under all other platforms | |
84 | #define wxTE_RICH 0x0080 | |
e015d1f7 | 85 | |
c57e3339 VZ |
86 | #define wxTE_PROCESS_ENTER 0x0400 |
87 | #define wxTE_PASSWORD 0x0800 | |
88 | ||
89 | // automatically detect the URLs and generate the events when mouse is | |
90 | // moved/clicked over an URL | |
91 | // | |
9440c3d0 | 92 | // this is for Win32 richedit and wxGTK2 multiline controls only so far |
c57e3339 VZ |
93 | #define wxTE_AUTO_URL 0x1000 |
94 | ||
5a8f04e3 VZ |
95 | // by default, the Windows text control doesn't show the selection when it |
96 | // doesn't have focus - use this style to force it to always show it | |
97 | #define wxTE_NOHIDESEL 0x2000 | |
98 | ||
fb4888a6 | 99 | // use wxHSCROLL to not wrap text at all, wxTE_CHARWRAP to wrap it at any |
65c12361 | 100 | // position and wxTE_WORDWRAP to wrap at words boundary |
fb4888a6 VZ |
101 | // |
102 | // if no wrapping style is given at all, the control wraps at word boundary | |
65c12361 | 103 | #define wxTE_DONTWRAP wxHSCROLL |
fb4888a6 VZ |
104 | #define wxTE_CHARWRAP 0x4000 // wrap at any position |
105 | #define wxTE_WORDWRAP 0x0001 // wrap only at words boundaries | |
106 | #define wxTE_BESTWRAP 0x0000 // this is the default | |
107 | ||
40ff126a WS |
108 | #if WXWIN_COMPATIBILITY_2_6 |
109 | // obsolete synonym | |
110 | #define wxTE_LINEWRAP wxTE_CHARWRAP | |
111 | #endif // WXWIN_COMPATIBILITY_2_6 | |
65c12361 | 112 | |
a5aa8086 VZ |
113 | // force using RichEdit version 2.0 or 3.0 instead of 1.0 (default) for |
114 | // wxTE_RICH controls - can be used together with or instead of wxTE_RICH | |
115 | #define wxTE_RICH2 0x8000 | |
116 | ||
afafd942 JS |
117 | // reuse wxTE_RICH2's value for CAPEDIT control on Windows CE |
118 | #if defined(__SMARTPHONE__) || defined(__POCKETPC__) | |
119 | #define wxTE_CAPITALIZE wxTE_RICH2 | |
120 | #else | |
121 | #define wxTE_CAPITALIZE 0 | |
122 | #endif | |
123 | ||
3306aec1 JS |
124 | // ---------------------------------------------------------------------------- |
125 | // wxTextCtrl file types | |
126 | // ---------------------------------------------------------------------------- | |
127 | ||
128 | #define wxTEXT_TYPE_ANY 0 | |
129 | ||
efe66bbc VZ |
130 | // ---------------------------------------------------------------------------- |
131 | // wxTextCtrl::HitTest return values | |
132 | // ---------------------------------------------------------------------------- | |
133 | ||
134 | // the point asked is ... | |
135 | enum wxTextCtrlHitTestResult | |
136 | { | |
137 | wxTE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented | |
138 | wxTE_HT_BEFORE, // either to the left or upper | |
139 | wxTE_HT_ON_TEXT, // directly on | |
140 | wxTE_HT_BELOW, // below [the last line] | |
141 | wxTE_HT_BEYOND // after [the end of line] | |
142 | }; | |
143 | // ... the character returned | |
144 | ||
e00a5d3c JS |
145 | // ---------------------------------------------------------------------------- |
146 | // Types for wxTextAttr | |
147 | // ---------------------------------------------------------------------------- | |
148 | ||
149 | // Alignment | |
150 | ||
151 | enum wxTextAttrAlignment | |
152 | { | |
153 | wxTEXT_ALIGNMENT_DEFAULT, | |
154 | wxTEXT_ALIGNMENT_LEFT, | |
155 | wxTEXT_ALIGNMENT_CENTRE, | |
156 | wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE, | |
157 | wxTEXT_ALIGNMENT_RIGHT, | |
158 | wxTEXT_ALIGNMENT_JUSTIFIED | |
159 | }; | |
160 | ||
161 | // Flags to indicate which attributes are being applied | |
162 | ||
44cc96a8 JS |
163 | #define wxTEXT_ATTR_TEXT_COLOUR 0x00000001 |
164 | #define wxTEXT_ATTR_BACKGROUND_COLOUR 0x00000002 | |
165 | #define wxTEXT_ATTR_FONT_FACE 0x00000004 | |
166 | #define wxTEXT_ATTR_FONT_SIZE 0x00000008 | |
167 | #define wxTEXT_ATTR_FONT_WEIGHT 0x00000010 | |
168 | #define wxTEXT_ATTR_FONT_ITALIC 0x00000020 | |
169 | #define wxTEXT_ATTR_FONT_UNDERLINE 0x00000040 | |
170 | #define wxTEXT_ATTR_FONT_ENCODING 0x02000000 | |
e00a5d3c | 171 | #define wxTEXT_ATTR_FONT \ |
d0ee33f5 | 172 | ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ |
44cc96a8 JS |
173 | wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING ) |
174 | #define wxTEXT_ATTR_ALIGNMENT 0x00000080 | |
175 | #define wxTEXT_ATTR_LEFT_INDENT 0x00000100 | |
176 | #define wxTEXT_ATTR_RIGHT_INDENT 0x00000200 | |
177 | #define wxTEXT_ATTR_TABS 0x00000400 | |
178 | ||
179 | #define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800 | |
180 | #define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000 | |
181 | #define wxTEXT_ATTR_LINE_SPACING 0x00002000 | |
182 | #define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000 | |
183 | #define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000 | |
184 | #define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000 | |
185 | #define wxTEXT_ATTR_BULLET_STYLE 0x00020000 | |
186 | #define wxTEXT_ATTR_BULLET_NUMBER 0x00040000 | |
187 | #define wxTEXT_ATTR_BULLET_TEXT 0x00080000 | |
188 | #define wxTEXT_ATTR_BULLET_NAME 0x00100000 | |
189 | #define wxTEXT_ATTR_URL 0x00200000 | |
190 | #define wxTEXT_ATTR_PAGE_BREAK 0x00400000 | |
191 | #define wxTEXT_ATTR_EFFECTS 0x00800000 | |
192 | #define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000 | |
193 | ||
194 | /*! | |
195 | * Character and paragraph combined styles | |
196 | */ | |
197 | ||
198 | #define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_FONT_ENCODING|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL) | |
199 | ||
200 | #define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\ | |
201 | wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\ | |
202 | wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|\ | |
203 | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL) | |
204 | ||
205 | #define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) | |
206 | ||
207 | /*! | |
208 | * Styles for wxTextAttr::SetBulletStyle | |
209 | */ | |
210 | ||
211 | #define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000 | |
212 | #define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001 | |
213 | #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002 | |
214 | #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004 | |
215 | #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008 | |
216 | #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010 | |
217 | #define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020 | |
218 | #define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040 | |
219 | #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080 | |
220 | #define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100 | |
221 | #define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200 | |
222 | #define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400 | |
223 | #define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800 | |
224 | ||
225 | #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000 | |
226 | #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000 | |
227 | #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000 | |
228 | ||
229 | /*! | |
230 | * Styles for wxTextAttr::SetTextEffects | |
231 | */ | |
232 | ||
233 | #define wxTEXT_ATTR_EFFECT_NONE 0x00000000 | |
234 | #define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001 | |
235 | #define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002 | |
236 | #define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004 | |
237 | #define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008 | |
238 | #define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010 | |
239 | #define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020 | |
240 | #define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040 | |
241 | #define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080 | |
242 | #define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100 | |
243 | #define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200 | |
244 | ||
245 | /*! | |
246 | * Line spacing values | |
247 | */ | |
248 | ||
249 | #define wxTEXT_ATTR_LINE_SPACING_NORMAL 10 | |
250 | #define wxTEXT_ATTR_LINE_SPACING_HALF 15 | |
251 | #define wxTEXT_ATTR_LINE_SPACING_TWICE 20 | |
e00a5d3c | 252 | |
4bc1afd5 VZ |
253 | // ---------------------------------------------------------------------------- |
254 | // wxTextAttr: a structure containing the visual attributes of a text | |
255 | // ---------------------------------------------------------------------------- | |
256 | ||
257 | class WXDLLEXPORT wxTextAttr | |
258 | { | |
259 | public: | |
260 | // ctors | |
e00a5d3c | 261 | wxTextAttr() { Init(); } |
44cc96a8 | 262 | wxTextAttr(const wxTextAttr& attr) { Init(); Copy(attr); } |
4bc1afd5 VZ |
263 | wxTextAttr(const wxColour& colText, |
264 | const wxColour& colBack = wxNullColour, | |
e00a5d3c JS |
265 | const wxFont& font = wxNullFont, |
266 | wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); | |
267 | ||
44cc96a8 | 268 | // Initialise this object. |
e00a5d3c JS |
269 | void Init(); |
270 | ||
44cc96a8 JS |
271 | // Copy |
272 | void Copy(const wxTextAttr& attr); | |
53ee6090 | 273 | |
44cc96a8 JS |
274 | // Assignment |
275 | void operator= (const wxTextAttr& attr); | |
53ee6090 | 276 | |
44cc96a8 JS |
277 | // Equality test |
278 | bool operator== (const wxTextAttr& attr) const; | |
53ee6090 | 279 | |
44cc96a8 JS |
280 | // Partial equality test taking flags into account |
281 | bool EqPartial(const wxTextAttr& attr, int flags) const; | |
282 | ||
283 | // Create font from font attributes. | |
284 | wxFont CreateFont() const; | |
285 | ||
286 | // Get attributes from font. | |
287 | bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT); | |
4bc1afd5 VZ |
288 | |
289 | // setters | |
e00a5d3c JS |
290 | void SetTextColour(const wxColour& colText) { m_colText = colText; m_flags |= wxTEXT_ATTR_TEXT_COLOUR; } |
291 | void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; } | |
e00a5d3c JS |
292 | void SetAlignment(wxTextAttrAlignment alignment) { m_textAlignment = alignment; m_flags |= wxTEXT_ATTR_ALIGNMENT; } |
293 | void SetTabs(const wxArrayInt& tabs) { m_tabs = tabs; m_flags |= wxTEXT_ATTR_TABS; } | |
89b67477 | 294 | void SetLeftIndent(int indent, int subIndent = 0) { m_leftIndent = indent; m_leftSubIndent = subIndent; m_flags |= wxTEXT_ATTR_LEFT_INDENT; } |
e00a5d3c | 295 | void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; } |
44cc96a8 JS |
296 | |
297 | void SetFontSize(int pointSize) { m_fontSize = pointSize; m_flags |= wxTEXT_ATTR_FONT_SIZE; } | |
298 | void SetFontStyle(int fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; } | |
299 | void SetFontWeight(int fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; } | |
300 | void SetFontFaceName(const wxString& faceName) { m_fontFaceName = faceName; m_flags |= wxTEXT_ATTR_FONT_FACE; } | |
301 | void SetFontUnderlined(bool underlined) { m_fontUnderlined = underlined; m_flags |= wxTEXT_ATTR_FONT_UNDERLINE; } | |
302 | void SetFontEncoding(wxFontEncoding encoding) { m_fontEncoding = encoding; m_flags |= wxTEXT_ATTR_FONT_ENCODING; } | |
303 | ||
304 | // Set font | |
305 | void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT) { GetFontAttributes(font, flags); } | |
306 | ||
e00a5d3c | 307 | void SetFlags(long flags) { m_flags = flags; } |
4bc1afd5 | 308 | |
44cc96a8 JS |
309 | void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; m_flags |= wxTEXT_ATTR_CHARACTER_STYLE_NAME; } |
310 | void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; m_flags |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME; } | |
311 | void SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME); } | |
312 | void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_AFTER; } | |
313 | void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_BEFORE; } | |
314 | void SetLineSpacing(int spacing) { m_lineSpacing = spacing; m_flags |= wxTEXT_ATTR_LINE_SPACING; } | |
315 | void SetBulletStyle(int style) { m_bulletStyle = style; m_flags |= wxTEXT_ATTR_BULLET_STYLE; } | |
316 | void SetBulletNumber(int n) { m_bulletNumber = n; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; } | |
317 | void SetBulletText(const wxString& text) { m_bulletText = text; m_flags |= wxTEXT_ATTR_BULLET_TEXT; } | |
318 | void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; } | |
319 | void SetBulletName(const wxString& name) { m_bulletName = name; m_flags |= wxTEXT_ATTR_BULLET_NAME; } | |
320 | void SetURL(const wxString& url) { m_urlTarget = url; m_flags |= wxTEXT_ATTR_URL; } | |
321 | void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); } | |
322 | void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); } | |
323 | void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; } | |
324 | void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); } | |
4bc1afd5 VZ |
325 | |
326 | const wxColour& GetTextColour() const { return m_colText; } | |
327 | const wxColour& GetBackgroundColour() const { return m_colBack; } | |
e00a5d3c JS |
328 | wxTextAttrAlignment GetAlignment() const { return m_textAlignment; } |
329 | const wxArrayInt& GetTabs() const { return m_tabs; } | |
330 | long GetLeftIndent() const { return m_leftIndent; } | |
89b67477 | 331 | long GetLeftSubIndent() const { return m_leftSubIndent; } |
e00a5d3c JS |
332 | long GetRightIndent() const { return m_rightIndent; } |
333 | long GetFlags() const { return m_flags; } | |
4bc1afd5 | 334 | |
44cc96a8 JS |
335 | int GetFontSize() const { return m_fontSize; } |
336 | int GetFontStyle() const { return m_fontStyle; } | |
337 | int GetFontWeight() const { return m_fontWeight; } | |
338 | bool GetFontUnderlined() const { return m_fontUnderlined; } | |
339 | const wxString& GetFontFaceName() const { return m_fontFaceName; } | |
340 | wxFontEncoding GetFontEncoding() const { return m_fontEncoding; } | |
341 | ||
342 | wxFont GetFont() const { return CreateFont(); } | |
343 | ||
344 | const wxString& GetCharacterStyleName() const { return m_characterStyleName; } | |
345 | const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; } | |
346 | const wxString& GetListStyleName() const { return m_listStyleName; } | |
347 | int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; } | |
348 | int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; } | |
349 | int GetLineSpacing() const { return m_lineSpacing; } | |
350 | int GetBulletStyle() const { return m_bulletStyle; } | |
351 | int GetBulletNumber() const { return m_bulletNumber; } | |
352 | const wxString& GetBulletText() const { return m_bulletText; } | |
353 | const wxString& GetBulletFont() const { return m_bulletFont; } | |
354 | const wxString& GetBulletName() const { return m_bulletName; } | |
355 | const wxString& GetURL() const { return m_urlTarget; } | |
356 | int GetTextEffects() const { return m_textEffects; } | |
357 | int GetTextEffectFlags() const { return m_textEffectFlags; } | |
358 | int GetOutlineLevel() const { return m_outlineLevel; } | |
359 | ||
360 | // accessors | |
361 | bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; } | |
362 | bool HasBackgroundColour() const { return m_colBack.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; } | |
363 | bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) || HasFlag(wxTEXT_ATTR_ALIGNMENT) ; } | |
364 | bool HasTabs() const { return HasFlag(wxTEXT_ATTR_TABS) ; } | |
365 | bool HasLeftIndent() const { return HasFlag(wxTEXT_ATTR_LEFT_INDENT); } | |
366 | bool HasRightIndent() const { return HasFlag(wxTEXT_ATTR_RIGHT_INDENT); } | |
367 | bool HasFontWeight() const { return HasFlag(wxTEXT_ATTR_FONT_WEIGHT); } | |
368 | bool HasFontSize() const { return HasFlag(wxTEXT_ATTR_FONT_SIZE); } | |
369 | bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); } | |
370 | bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); } | |
371 | bool HasFontFaceName() const { return HasFlag(wxTEXT_ATTR_FONT_FACE); } | |
372 | bool HasFontEncoding() const { return HasFlag(wxTEXT_ATTR_FONT_ENCODING); } | |
373 | bool HasFont() const { return HasFlag(wxTEXT_ATTR_FONT); } | |
374 | ||
375 | bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); } | |
376 | bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE); } | |
377 | bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING); } | |
378 | bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME) && !m_characterStyleName.IsEmpty(); } | |
379 | bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && !m_paragraphStyleName.IsEmpty(); } | |
380 | bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); } | |
381 | bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); } | |
382 | bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); } | |
383 | bool HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT); } | |
384 | bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME); } | |
385 | bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); } | |
386 | bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); } | |
387 | bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); } | |
388 | bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); } | |
389 | bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); } | |
390 | ||
391 | bool HasFlag(long flag) const { return (m_flags & flag) != 0; } | |
392 | ||
393 | // Is this a character style? | |
394 | bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); } | |
395 | bool IsParagraphStyle() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH); } | |
396 | ||
17665a2b VZ |
397 | // returns false if we have any attributes set, true otherwise |
398 | bool IsDefault() const | |
399 | { | |
44cc96a8 JS |
400 | return GetFlags() == 0; |
401 | } | |
402 | ||
403 | // Merges the given attributes. Does not affect 'this'. If compareWith | |
404 | // is non-NULL, then it will be used to mask out those attributes that are the same in style | |
405 | // and compareWith, for situations where we don't want to explicitly set inherited attributes. | |
406 | bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL); | |
407 | ||
408 | // merges the attributes of the base and the overlay objects and returns | |
409 | // the result; the parameter attributes take precedence | |
410 | // | |
411 | // WARNING: the order of arguments is the opposite of Combine() | |
412 | static wxTextAttr Merge(const wxTextAttr& base, const wxTextAttr& overlay) | |
413 | { | |
414 | return Combine(overlay, base, NULL); | |
415 | } | |
416 | ||
417 | // merges the attributes of this object and overlay | |
418 | void Merge(const wxTextAttr& overlay) | |
419 | { | |
420 | *this = Merge(*this, overlay); | |
17665a2b VZ |
421 | } |
422 | ||
eda40bfc VZ |
423 | // return the attribute having the valid font and colours: it uses the |
424 | // attributes set in attr and falls back first to attrDefault and then to | |
425 | // the text control font/colours for those attributes which are not set | |
426 | static wxTextAttr Combine(const wxTextAttr& attr, | |
427 | const wxTextAttr& attrDef, | |
428 | const wxTextCtrlBase *text); | |
429 | ||
44cc96a8 JS |
430 | // Compare tabs |
431 | static bool TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2); | |
432 | ||
433 | // Remove attributes | |
434 | static bool RemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style); | |
435 | ||
436 | // Combine two bitlists, specifying the bits of interest with separate flags. | |
437 | static bool CombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB); | |
438 | ||
439 | // Compare two bitlists | |
440 | static bool BitlistsEqPartial(int valueA, int valueB, int flags); | |
441 | ||
442 | // Split into paragraph and character styles | |
443 | static bool SplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle); | |
444 | ||
4bc1afd5 | 445 | private: |
e00a5d3c | 446 | long m_flags; |
44cc96a8 JS |
447 | |
448 | // Paragraph styles | |
e00a5d3c JS |
449 | wxArrayInt m_tabs; // array of int: tab stops in 1/10 mm |
450 | int m_leftIndent; // left indent in 1/10 mm | |
cb719f2e | 451 | int m_leftSubIndent; // left indent for all but the first |
89b67477 VZ |
452 | // line in a paragraph relative to the |
453 | // first line, in 1/10 mm | |
e00a5d3c | 454 | int m_rightIndent; // right indent in 1/10 mm |
44cc96a8 JS |
455 | wxTextAttrAlignment m_textAlignment; |
456 | ||
457 | int m_paragraphSpacingAfter; | |
458 | int m_paragraphSpacingBefore; | |
459 | int m_lineSpacing; | |
460 | int m_bulletStyle; | |
461 | int m_bulletNumber; | |
462 | int m_textEffects; | |
463 | int m_textEffectFlags; | |
464 | int m_outlineLevel; | |
465 | wxString m_bulletText; | |
466 | wxString m_bulletFont; | |
467 | wxString m_bulletName; | |
468 | wxString m_urlTarget; | |
469 | wxFontEncoding m_fontEncoding; | |
470 | ||
471 | // Character styles | |
472 | wxColour m_colText, | |
473 | m_colBack; | |
474 | int m_fontSize; | |
475 | int m_fontStyle; | |
476 | int m_fontWeight; | |
477 | bool m_fontUnderlined; | |
478 | wxString m_fontFaceName; | |
479 | ||
480 | // Character style | |
481 | wxString m_characterStyleName; | |
482 | ||
483 | // Paragraph style | |
484 | wxString m_paragraphStyleName; | |
485 | ||
486 | // List style | |
487 | wxString m_listStyleName; | |
4bc1afd5 VZ |
488 | }; |
489 | ||
a1b82138 | 490 | // ---------------------------------------------------------------------------- |
0ec1179b | 491 | // wxTextAreaBase: multiline text control specific methods |
a1b82138 VZ |
492 | // ---------------------------------------------------------------------------- |
493 | ||
0ec1179b | 494 | class WXDLLIMPEXP_CORE wxTextAreaBase |
a1b82138 VZ |
495 | { |
496 | public: | |
0ec1179b VZ |
497 | wxTextAreaBase() { } |
498 | virtual ~wxTextAreaBase() { } | |
a1b82138 | 499 | |
0ec1179b VZ |
500 | // lines access |
501 | // ------------ | |
a5aa8086 | 502 | |
a1b82138 VZ |
503 | virtual int GetLineLength(long lineNo) const = 0; |
504 | virtual wxString GetLineText(long lineNo) const = 0; | |
505 | virtual int GetNumberOfLines() const = 0; | |
506 | ||
a1b82138 | 507 | |
0ec1179b VZ |
508 | // file IO |
509 | // ------- | |
aa8e9a36 | 510 | |
0ec1179b VZ |
511 | bool LoadFile(const wxString& file, int fileType = wxTEXT_TYPE_ANY) |
512 | { return DoLoadFile(file, fileType); } | |
513 | bool SaveFile(const wxString& file = wxEmptyString, | |
514 | int fileType = wxTEXT_TYPE_ANY); | |
a1b82138 | 515 | |
0ec1179b VZ |
516 | // dirty flag handling |
517 | // ------------------- | |
a1b82138 | 518 | |
0ec1179b | 519 | virtual bool IsModified() const = 0; |
3a9fa0d6 | 520 | virtual void MarkDirty() = 0; |
a1b82138 | 521 | virtual void DiscardEdits() = 0; |
be0ac181 VZ |
522 | void SetModified(bool modified) |
523 | { | |
524 | if ( modified ) | |
525 | MarkDirty(); | |
526 | else | |
527 | DiscardEdits(); | |
528 | } | |
a1b82138 | 529 | |
d7eee191 | 530 | |
0ec1179b VZ |
531 | // styles handling |
532 | // --------------- | |
94af7d45 | 533 | |
4bc1afd5 VZ |
534 | // text control under some platforms supports the text styles: these |
535 | // methods allow to apply the given text style to the given selection or to | |
536 | // set/get the style which will be used for all appended text | |
0ec1179b VZ |
537 | virtual bool SetStyle(long start, long end, const wxTextAttr& style) = 0; |
538 | virtual bool GetStyle(long position, wxTextAttr& style) = 0; | |
539 | virtual bool SetDefaultStyle(const wxTextAttr& style) = 0; | |
540 | virtual const wxTextAttr& GetDefaultStyle() const { return m_defaultStyle; } | |
541 | ||
542 | ||
543 | // coordinates translation | |
544 | // ----------------------- | |
4bc1afd5 | 545 | |
a1b82138 VZ |
546 | // translate between the position (which is just an index in the text ctrl |
547 | // considering all its contents as a single strings) and (x, y) coordinates | |
548 | // which represent column and line. | |
549 | virtual long XYToPosition(long x, long y) const = 0; | |
0efe5ba7 | 550 | virtual bool PositionToXY(long pos, long *x, long *y) const = 0; |
a1b82138 VZ |
551 | |
552 | virtual void ShowPosition(long pos) = 0; | |
553 | ||
efe66bbc VZ |
554 | // find the character at position given in pixels |
555 | // | |
556 | // NB: pt is in device coords (not adjusted for the client area origin nor | |
557 | // scrolling) | |
692c9b86 | 558 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; |
efe66bbc VZ |
559 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, |
560 | wxTextCoord *col, | |
561 | wxTextCoord *row) const; | |
562 | ||
0ec1179b VZ |
563 | protected: |
564 | // implementation of loading/saving | |
565 | virtual bool DoLoadFile(const wxString& file, int fileType) = 0; | |
566 | virtual bool DoSaveFile(const wxString& file, int fileType) = 0; | |
567 | ||
a1b82138 | 568 | |
0ec1179b VZ |
569 | // the name of the last file loaded with LoadFile() which will be used by |
570 | // SaveFile() by default | |
571 | wxString m_filename; | |
a1b82138 | 572 | |
0ec1179b VZ |
573 | // the text style which will be used for any new text added to the control |
574 | wxTextAttr m_defaultStyle; | |
a1b82138 | 575 | |
a1b82138 | 576 | |
0ec1179b VZ |
577 | DECLARE_NO_COPY_CLASS(wxTextAreaBase) |
578 | }; | |
a1b82138 | 579 | |
0ec1179b VZ |
580 | // this class defines wxTextCtrl interface, wxTextCtrlBase actually implements |
581 | // too much things because it derives from wxTextEntry and not wxTextEntryBase | |
582 | // and so any classes which "look like" wxTextCtrl (such as wxRichTextCtrl) | |
583 | // but don't need the (native) implementation bits from wxTextEntry should | |
584 | // actually derive from this one and not wxTextCtrlBase | |
585 | class WXDLLIMPEXP_CORE wxTextCtrlIface : public wxTextAreaBase, | |
586 | public wxTextEntryBase | |
587 | { | |
588 | public: | |
589 | wxTextCtrlIface() { } | |
590 | ||
591 | private: | |
592 | DECLARE_NO_COPY_CLASS(wxTextCtrlIface) | |
593 | }; | |
594 | ||
595 | // ---------------------------------------------------------------------------- | |
596 | // wxTextCtrl: a single or multiple line text zone where user can edit text | |
597 | // ---------------------------------------------------------------------------- | |
598 | ||
599 | class WXDLLEXPORT wxTextCtrlBase : public wxControl, | |
600 | #if wxHAS_TEXT_WINDOW_STREAM | |
601 | public wxSTD streambuf, | |
602 | #endif | |
603 | public wxTextAreaBase, | |
604 | public wxTextEntry | |
605 | { | |
606 | public: | |
607 | // creation | |
608 | // -------- | |
609 | ||
610 | wxTextCtrlBase() { } | |
611 | virtual ~wxTextCtrlBase() { } | |
612 | ||
613 | ||
614 | // more readable flag testing methods | |
615 | bool IsSingleLine() const { return !HasFlag(wxTE_MULTILINE); } | |
616 | bool IsMultiLine() const { return !IsSingleLine(); } | |
a1b82138 | 617 | |
a1b82138 VZ |
618 | // stream-like insertion operators: these are always available, whether we |
619 | // were, or not, compiled with streambuf support | |
620 | wxTextCtrl& operator<<(const wxString& s); | |
621 | wxTextCtrl& operator<<(int i); | |
622 | wxTextCtrl& operator<<(long i); | |
623 | wxTextCtrl& operator<<(float f); | |
624 | wxTextCtrl& operator<<(double d); | |
a324a7bc | 625 | wxTextCtrl& operator<<(const wxChar c); |
a1b82138 | 626 | |
0ec1179b VZ |
627 | // insert the character which would have resulted from this key event, |
628 | // return true if anything has been inserted | |
629 | virtual bool EmulateKeyPress(const wxKeyEvent& event); | |
630 | ||
631 | ||
fa2f57be VZ |
632 | // generate the wxEVT_COMMAND_TEXT_UPDATED event, like SetValue() does and |
633 | // return true if the event was processed | |
634 | static bool SendTextUpdatedEvent(wxWindow *win); | |
635 | bool SendTextUpdatedEvent() { return SendTextUpdatedEvent(this); } | |
ee2ec18e | 636 | |
e39af974 | 637 | // do the window-specific processing after processing the update event |
d4864e97 VZ |
638 | virtual void DoUpdateWindowUI(wxUpdateUIEvent& event); |
639 | ||
640 | virtual bool ShouldInheritColours() const { return false; } | |
e39af974 | 641 | |
0ec1179b VZ |
642 | // work around the problem with having HitTest() both in wxControl and |
643 | // wxTextAreaBase base classes | |
644 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const | |
645 | { | |
646 | return wxTextAreaBase::HitTest(pt, pos); | |
647 | } | |
648 | ||
649 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, | |
650 | wxTextCoord *col, | |
651 | wxTextCoord *row) const | |
652 | { | |
653 | return wxTextAreaBase::HitTest(pt, col, row); | |
654 | } | |
655 | ||
656 | // we provide stubs for these functions as not all platforms have styles | |
657 | // support, but we really should leave them pure virtual here | |
658 | virtual bool SetStyle(long start, long end, const wxTextAttr& style); | |
659 | virtual bool GetStyle(long position, wxTextAttr& style); | |
660 | virtual bool SetDefaultStyle(const wxTextAttr& style); | |
661 | ||
5bd3a2da | 662 | protected: |
6f02a879 VZ |
663 | // override streambuf method |
664 | #if wxHAS_TEXT_WINDOW_STREAM | |
665 | int overflow(int i); | |
666 | #endif // wxHAS_TEXT_WINDOW_STREAM | |
667 | ||
0ec1179b VZ |
668 | virtual bool DoLoadFile(const wxString& file, int fileType); |
669 | virtual bool DoSaveFile(const wxString& file, int fileType); | |
fa40e7a1 | 670 | |
fc7a2a60 VZ |
671 | |
672 | DECLARE_NO_COPY_CLASS(wxTextCtrlBase) | |
9d112688 | 673 | DECLARE_ABSTRACT_CLASS(wxTextCtrlBase) |
a1b82138 VZ |
674 | }; |
675 | ||
676 | // ---------------------------------------------------------------------------- | |
677 | // include the platform-dependent class definition | |
678 | // ---------------------------------------------------------------------------- | |
679 | ||
4175e952 RR |
680 | #if defined(__WXX11__) |
681 | #include "wx/x11/textctrl.h" | |
682 | #elif defined(__WXUNIVERSAL__) | |
1e6feb95 | 683 | #include "wx/univ/textctrl.h" |
9b141468 | 684 | #elif defined(__SMARTPHONE__) && defined(__WXWINCE__) |
302e251b | 685 | #include "wx/msw/wince/textctrlce.h" |
1e6feb95 | 686 | #elif defined(__WXMSW__) |
a1b82138 | 687 | #include "wx/msw/textctrl.h" |
2049ba38 | 688 | #elif defined(__WXMOTIF__) |
a1b82138 | 689 | #include "wx/motif/textctrl.h" |
1be7a35c | 690 | #elif defined(__WXGTK20__) |
a1b82138 | 691 | #include "wx/gtk/textctrl.h" |
1be7a35c MR |
692 | #elif defined(__WXGTK__) |
693 | #include "wx/gtk1/textctrl.h" | |
34138703 | 694 | #elif defined(__WXMAC__) |
a1b82138 | 695 | #include "wx/mac/textctrl.h" |
e64df9bc DE |
696 | #elif defined(__WXCOCOA__) |
697 | #include "wx/cocoa/textctrl.h" | |
1777b9bb DW |
698 | #elif defined(__WXPM__) |
699 | #include "wx/os2/textctrl.h" | |
c801d85f KB |
700 | #endif |
701 | ||
c57e3339 VZ |
702 | // ---------------------------------------------------------------------------- |
703 | // wxTextCtrl events | |
704 | // ---------------------------------------------------------------------------- | |
705 | ||
ad0bae85 VZ |
706 | #if !WXWIN_COMPATIBILITY_EVENT_TYPES |
707 | ||
c57e3339 VZ |
708 | BEGIN_DECLARE_EVENT_TYPES() |
709 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED, 7) | |
710 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER, 8) | |
711 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL, 13) | |
d7eee191 | 712 | DECLARE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN, 14) |
c57e3339 VZ |
713 | END_DECLARE_EVENT_TYPES() |
714 | ||
ad0bae85 VZ |
715 | #endif // !WXWIN_COMPATIBILITY_EVENT_TYPES |
716 | ||
c57e3339 VZ |
717 | class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent |
718 | { | |
719 | public: | |
d9e2e4c2 | 720 | wxTextUrlEvent(int winid, const wxMouseEvent& evtMouse, |
c57e3339 | 721 | long start, long end) |
d9e2e4c2 | 722 | : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, winid) |
7ee31b00 GD |
723 | , m_evtMouse(evtMouse), m_start(start), m_end(end) |
724 | { } | |
c57e3339 VZ |
725 | |
726 | // get the mouse event which happend over the URL | |
727 | const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; } | |
728 | ||
729 | // get the start of the URL | |
730 | long GetURLStart() const { return m_start; } | |
731 | ||
732 | // get the end of the URL | |
733 | long GetURLEnd() const { return m_end; } | |
734 | ||
735 | protected: | |
736 | // the corresponding mouse event | |
737 | wxMouseEvent m_evtMouse; | |
738 | ||
739 | // the start and end indices of the URL in the text control | |
740 | long m_start, | |
741 | m_end; | |
742 | ||
743 | private: | |
fc7a2a60 | 744 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextUrlEvent) |
c57e3339 VZ |
745 | |
746 | public: | |
747 | // for wxWin RTTI only, don't use | |
7ee31b00 | 748 | wxTextUrlEvent() : m_evtMouse(), m_start(0), m_end(0) { } |
c57e3339 VZ |
749 | }; |
750 | ||
751 | typedef void (wxEvtHandler::*wxTextUrlEventFunction)(wxTextUrlEvent&); | |
752 | ||
7fa03f04 | 753 | #define wxTextEventHandler(func) wxCommandEventHandler(func) |
b629d6d9 | 754 | #define wxTextUrlEventHandler(func) \ |
d94c09cd | 755 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTextUrlEventFunction, &func) |
7fa03f04 VZ |
756 | |
757 | #define wx__DECLARE_TEXTEVT(evt, id, fn) \ | |
758 | wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextEventHandler(fn)) | |
759 | ||
b629d6d9 VZ |
760 | #define wx__DECLARE_TEXTURLEVT(evt, id, fn) \ |
761 | wx__DECLARE_EVT1(wxEVT_COMMAND_TEXT_ ## evt, id, wxTextUrlEventHandler(fn)) | |
762 | ||
7fa03f04 VZ |
763 | #define EVT_TEXT(id, fn) wx__DECLARE_TEXTEVT(UPDATED, id, fn) |
764 | #define EVT_TEXT_ENTER(id, fn) wx__DECLARE_TEXTEVT(ENTER, id, fn) | |
b629d6d9 | 765 | #define EVT_TEXT_URL(id, fn) wx__DECLARE_TEXTURLEVT(URL, id, fn) |
7fa03f04 | 766 | #define EVT_TEXT_MAXLEN(id, fn) wx__DECLARE_TEXTEVT(MAXLEN, id, fn) |
c57e3339 | 767 | |
15cdc341 | 768 | #if wxHAS_TEXT_WINDOW_STREAM |
d73e6791 VZ |
769 | |
770 | // ---------------------------------------------------------------------------- | |
771 | // wxStreamToTextRedirector: this class redirects all data sent to the given | |
772 | // C++ stream to the wxTextCtrl given to its ctor during its lifetime. | |
773 | // ---------------------------------------------------------------------------- | |
774 | ||
775 | class WXDLLEXPORT wxStreamToTextRedirector | |
776 | { | |
9806a823 | 777 | private: |
6eaebb29 | 778 | void Init(wxTextCtrl *text) |
d73e6791 VZ |
779 | { |
780 | m_sbufOld = m_ostr.rdbuf(); | |
781 | m_ostr.rdbuf(text); | |
782 | } | |
783 | ||
9806a823 VZ |
784 | public: |
785 | wxStreamToTextRedirector(wxTextCtrl *text) | |
786 | : m_ostr(wxSTD cout) | |
787 | { | |
6eaebb29 | 788 | Init(text); |
9806a823 VZ |
789 | } |
790 | ||
791 | wxStreamToTextRedirector(wxTextCtrl *text, wxSTD ostream *ostr) | |
792 | : m_ostr(*ostr) | |
793 | { | |
6eaebb29 | 794 | Init(text); |
9806a823 VZ |
795 | } |
796 | ||
d73e6791 VZ |
797 | ~wxStreamToTextRedirector() |
798 | { | |
799 | m_ostr.rdbuf(m_sbufOld); | |
800 | } | |
801 | ||
802 | private: | |
803 | // the stream we're redirecting | |
804 | wxSTD ostream& m_ostr; | |
805 | ||
806 | // the old streambuf (before we changed it) | |
807 | wxSTD streambuf *m_sbufOld; | |
808 | }; | |
809 | ||
15cdc341 | 810 | #endif // wxHAS_TEXT_WINDOW_STREAM |
d73e6791 | 811 | |
1e6feb95 VZ |
812 | #endif // wxUSE_TEXTCTRL |
813 | ||
c801d85f | 814 | #endif |
34138703 | 815 | // _WX_TEXTCTRL_H_BASE_ |