]>
Commit | Line | Data |
---|---|---|
a1b82138 | 1 | /////////////////////////////////////////////////////////////////////////////// |
d5da0ce7 | 2 | // Name: src/common/textcmn.cpp |
a1b82138 VZ |
3 | // Purpose: implementation of platform-independent functions of wxTextCtrl |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 13.07.99 | |
7 | // RCS-ID: $Id$ | |
77ffb593 | 8 | // Copyright: (c) wxWidgets team |
65571936 | 9 | // Licence: wxWindows licence |
a1b82138 VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | // ============================================================================ | |
13 | // declarations | |
14 | // ============================================================================ | |
1e6feb95 | 15 | |
a1b82138 VZ |
16 | // for compilers that support precompilation, includes "wx.h". |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
d5da0ce7 WS |
23 | #ifndef WX_PRECOMP |
24 | #include "wx/event.h" | |
25 | #endif // WX_PRECOMP | |
26 | ||
1e6feb95 VZ |
27 | #if wxUSE_TEXTCTRL |
28 | ||
d5da0ce7 WS |
29 | #include "wx/textctrl.h" |
30 | ||
a1b82138 | 31 | #ifndef WX_PRECOMP |
0efe5ba7 VZ |
32 | #include "wx/intl.h" |
33 | #include "wx/log.h" | |
a1b82138 VZ |
34 | #endif // WX_PRECOMP |
35 | ||
36 | #include "wx/ffile.h" | |
37 | ||
38 | // ---------------------------------------------------------------------------- | |
39 | // macros | |
40 | // ---------------------------------------------------------------------------- | |
41 | ||
42 | // we don't have any objects of type wxTextCtrlBase in the program, only | |
43 | // wxTextCtrl, so this cast is safe | |
44 | #define TEXTCTRL(ptr) ((wxTextCtrl *)(ptr)) | |
45 | ||
46 | // ============================================================================ | |
47 | // implementation | |
48 | // ============================================================================ | |
49 | ||
c57e3339 VZ |
50 | IMPLEMENT_DYNAMIC_CLASS(wxTextUrlEvent, wxCommandEvent) |
51 | ||
9b11752c VZ |
52 | wxDEFINE_EVENT( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent ); |
53 | wxDEFINE_EVENT( wxEVT_COMMAND_TEXT_ENTER, wxCommandEvent ); | |
54 | wxDEFINE_EVENT( wxEVT_COMMAND_TEXT_URL, wxTextUrlEvent ); | |
55 | wxDEFINE_EVENT( wxEVT_COMMAND_TEXT_MAXLEN, wxCommandEvent ); | |
c57e3339 | 56 | |
9d112688 JS |
57 | IMPLEMENT_ABSTRACT_CLASS(wxTextCtrlBase, wxControl) |
58 | ||
44cc96a8 JS |
59 | // ============================================================================ |
60 | // wxTextAttr implementation | |
61 | // ============================================================================ | |
4bc1afd5 | 62 | |
e00a5d3c JS |
63 | wxTextAttr::wxTextAttr(const wxColour& colText, |
64 | const wxColour& colBack, | |
65 | const wxFont& font, | |
44cc96a8 | 66 | wxTextAttrAlignment alignment): m_textAlignment(alignment), m_colText(colText), m_colBack(colBack) |
e00a5d3c | 67 | { |
44cc96a8 JS |
68 | Init(); |
69 | ||
e00a5d3c JS |
70 | if (m_colText.Ok()) m_flags |= wxTEXT_ATTR_TEXT_COLOUR; |
71 | if (m_colBack.Ok()) m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; | |
e00a5d3c JS |
72 | if (alignment != wxTEXT_ALIGNMENT_DEFAULT) |
73 | m_flags |= wxTEXT_ATTR_ALIGNMENT; | |
44cc96a8 JS |
74 | |
75 | GetFontAttributes(font); | |
e00a5d3c JS |
76 | } |
77 | ||
44cc96a8 | 78 | // Initialisation |
e00a5d3c JS |
79 | void wxTextAttr::Init() |
80 | { | |
81 | m_textAlignment = wxTEXT_ALIGNMENT_DEFAULT; | |
82 | m_flags = 0; | |
83 | m_leftIndent = 0; | |
89b67477 | 84 | m_leftSubIndent = 0; |
e00a5d3c | 85 | m_rightIndent = 0; |
44cc96a8 JS |
86 | |
87 | m_fontSize = 12; | |
7d76fbd5 FM |
88 | m_fontStyle = wxFONTSTYLE_NORMAL; |
89 | m_fontWeight = wxFONTWEIGHT_NORMAL; | |
44cc96a8 JS |
90 | m_fontUnderlined = false; |
91 | m_fontEncoding = wxFONTENCODING_DEFAULT; | |
9c4cb611 | 92 | m_fontFamily = wxFONTFAMILY_DEFAULT; |
44cc96a8 JS |
93 | |
94 | m_paragraphSpacingAfter = 0; | |
95 | m_paragraphSpacingBefore = 0; | |
96 | m_lineSpacing = 0; | |
97 | m_bulletStyle = wxTEXT_ATTR_BULLET_STYLE_NONE; | |
98 | m_textEffects = wxTEXT_ATTR_EFFECT_NONE; | |
99 | m_textEffectFlags = wxTEXT_ATTR_EFFECT_NONE; | |
100 | m_outlineLevel = 0; | |
101 | m_bulletNumber = 0; | |
102 | } | |
103 | ||
104 | // Copy | |
105 | void wxTextAttr::Copy(const wxTextAttr& attr) | |
106 | { | |
107 | m_colText = attr.m_colText; | |
108 | m_colBack = attr.m_colBack; | |
109 | m_textAlignment = attr.m_textAlignment; | |
110 | m_leftIndent = attr.m_leftIndent; | |
111 | m_leftSubIndent = attr.m_leftSubIndent; | |
112 | m_rightIndent = attr.m_rightIndent; | |
113 | m_tabs = attr.m_tabs; | |
114 | m_flags = attr.m_flags; | |
115 | ||
116 | m_fontSize = attr.m_fontSize; | |
117 | m_fontStyle = attr.m_fontStyle; | |
118 | m_fontWeight = attr.m_fontWeight; | |
119 | m_fontUnderlined = attr.m_fontUnderlined; | |
120 | m_fontFaceName = attr.m_fontFaceName; | |
121 | m_fontEncoding = attr.m_fontEncoding; | |
9c4cb611 | 122 | m_fontFamily = attr.m_fontFamily; |
44cc96a8 JS |
123 | m_textEffects = attr.m_textEffects; |
124 | m_textEffectFlags = attr.m_textEffectFlags; | |
125 | ||
126 | m_paragraphSpacingAfter = attr.m_paragraphSpacingAfter; | |
127 | m_paragraphSpacingBefore = attr.m_paragraphSpacingBefore; | |
128 | m_lineSpacing = attr.m_lineSpacing; | |
129 | m_characterStyleName = attr.m_characterStyleName; | |
130 | m_paragraphStyleName = attr.m_paragraphStyleName; | |
131 | m_listStyleName = attr.m_listStyleName; | |
132 | m_bulletStyle = attr.m_bulletStyle; | |
133 | m_bulletNumber = attr.m_bulletNumber; | |
134 | m_bulletText = attr.m_bulletText; | |
135 | m_bulletFont = attr.m_bulletFont; | |
136 | m_bulletName = attr.m_bulletName; | |
137 | m_outlineLevel = attr.m_outlineLevel; | |
138 | ||
139 | m_urlTarget = attr.m_urlTarget; | |
140 | } | |
141 | ||
142 | // operators | |
143 | void wxTextAttr::operator= (const wxTextAttr& attr) | |
144 | { | |
145 | Copy(attr); | |
146 | } | |
147 | ||
148 | // Equality test | |
149 | bool wxTextAttr::operator== (const wxTextAttr& attr) const | |
150 | { | |
151 | return GetFlags() == attr.GetFlags() && | |
152 | ||
153 | GetTextColour() == attr.GetTextColour() && | |
154 | GetBackgroundColour() == attr.GetBackgroundColour() && | |
155 | ||
156 | GetAlignment() == attr.GetAlignment() && | |
157 | GetLeftIndent() == attr.GetLeftIndent() && | |
158 | GetLeftSubIndent() == attr.GetLeftSubIndent() && | |
159 | GetRightIndent() == attr.GetRightIndent() && | |
160 | TabsEq(GetTabs(), attr.GetTabs()) && | |
161 | ||
162 | GetParagraphSpacingAfter() == attr.GetParagraphSpacingAfter() && | |
163 | GetParagraphSpacingBefore() == attr.GetParagraphSpacingBefore() && | |
164 | GetLineSpacing() == attr.GetLineSpacing() && | |
165 | GetCharacterStyleName() == attr.GetCharacterStyleName() && | |
166 | GetParagraphStyleName() == attr.GetParagraphStyleName() && | |
167 | GetListStyleName() == attr.GetListStyleName() && | |
168 | ||
169 | GetBulletStyle() == attr.GetBulletStyle() && | |
170 | GetBulletText() == attr.GetBulletText() && | |
171 | GetBulletNumber() == attr.GetBulletNumber() && | |
172 | GetBulletFont() == attr.GetBulletFont() && | |
173 | GetBulletName() == attr.GetBulletName() && | |
174 | ||
175 | GetTextEffects() == attr.GetTextEffects() && | |
176 | GetTextEffectFlags() == attr.GetTextEffectFlags() && | |
177 | ||
178 | GetOutlineLevel() == attr.GetOutlineLevel() && | |
179 | ||
180 | GetFontSize() == attr.GetFontSize() && | |
181 | GetFontStyle() == attr.GetFontStyle() && | |
182 | GetFontWeight() == attr.GetFontWeight() && | |
183 | GetFontUnderlined() == attr.GetFontUnderlined() && | |
184 | GetFontFaceName() == attr.GetFontFaceName() && | |
185 | GetFontEncoding() == attr.GetFontEncoding() && | |
9c4cb611 | 186 | GetFontFamily() == attr.GetFontFamily() && |
44cc96a8 JS |
187 | |
188 | GetURL() == attr.GetURL(); | |
189 | } | |
190 | ||
24777478 JS |
191 | // Partial equality test. Only returns false if an attribute doesn't match. |
192 | bool wxTextAttr::EqPartial(const wxTextAttr& attr) const | |
44cc96a8 | 193 | { |
24777478 JS |
194 | int flags = attr.GetFlags(); |
195 | ||
44cc96a8 JS |
196 | if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && GetTextColour() != attr.GetTextColour()) |
197 | return false; | |
198 | ||
199 | if ((flags & wxTEXT_ATTR_BACKGROUND_COLOUR) && GetBackgroundColour() != attr.GetBackgroundColour()) | |
200 | return false; | |
201 | ||
202 | if ((flags & wxTEXT_ATTR_FONT_FACE) && | |
203 | GetFontFaceName() != attr.GetFontFaceName()) | |
204 | return false; | |
205 | ||
206 | if ((flags & wxTEXT_ATTR_FONT_SIZE) && | |
207 | GetFontSize() != attr.GetFontSize()) | |
208 | return false; | |
209 | ||
210 | if ((flags & wxTEXT_ATTR_FONT_WEIGHT) && | |
211 | GetFontWeight() != attr.GetFontWeight()) | |
212 | return false; | |
213 | ||
214 | if ((flags & wxTEXT_ATTR_FONT_ITALIC) && | |
215 | GetFontStyle() != attr.GetFontStyle()) | |
216 | return false; | |
217 | ||
218 | if ((flags & wxTEXT_ATTR_FONT_UNDERLINE) && | |
219 | GetFontUnderlined() != attr.GetFontUnderlined()) | |
220 | return false; | |
221 | ||
222 | if ((flags & wxTEXT_ATTR_FONT_ENCODING) && | |
223 | GetFontEncoding() != attr.GetFontEncoding()) | |
224 | return false; | |
225 | ||
9c4cb611 JS |
226 | if ((flags & wxTEXT_ATTR_FONT_FAMILY) && |
227 | GetFontFamily() != attr.GetFontFamily()) | |
228 | return false; | |
229 | ||
44cc96a8 JS |
230 | if ((flags & wxTEXT_ATTR_URL) && GetURL() != attr.GetURL()) |
231 | return false; | |
232 | ||
233 | if ((flags & wxTEXT_ATTR_ALIGNMENT) && GetAlignment() != attr.GetAlignment()) | |
234 | return false; | |
235 | ||
236 | if ((flags & wxTEXT_ATTR_LEFT_INDENT) && | |
237 | ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent()))) | |
238 | return false; | |
239 | ||
240 | if ((flags & wxTEXT_ATTR_RIGHT_INDENT) && | |
241 | (GetRightIndent() != attr.GetRightIndent())) | |
242 | return false; | |
243 | ||
244 | if ((flags & wxTEXT_ATTR_PARA_SPACING_AFTER) && | |
245 | (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())) | |
246 | return false; | |
247 | ||
248 | if ((flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) && | |
249 | (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())) | |
250 | return false; | |
251 | ||
252 | if ((flags & wxTEXT_ATTR_LINE_SPACING) && | |
253 | (GetLineSpacing() != attr.GetLineSpacing())) | |
254 | return false; | |
255 | ||
256 | if ((flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) && | |
257 | (GetCharacterStyleName() != attr.GetCharacterStyleName())) | |
258 | return false; | |
259 | ||
260 | if ((flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && | |
261 | (GetParagraphStyleName() != attr.GetParagraphStyleName())) | |
262 | return false; | |
263 | ||
264 | if ((flags & wxTEXT_ATTR_LIST_STYLE_NAME) && | |
265 | (GetListStyleName() != attr.GetListStyleName())) | |
266 | return false; | |
267 | ||
268 | if ((flags & wxTEXT_ATTR_BULLET_STYLE) && | |
269 | (GetBulletStyle() != attr.GetBulletStyle())) | |
270 | return false; | |
271 | ||
272 | if ((flags & wxTEXT_ATTR_BULLET_NUMBER) && | |
273 | (GetBulletNumber() != attr.GetBulletNumber())) | |
274 | return false; | |
275 | ||
276 | if ((flags & wxTEXT_ATTR_BULLET_TEXT) && | |
277 | (GetBulletText() != attr.GetBulletText()) && | |
278 | (GetBulletFont() != attr.GetBulletFont())) | |
279 | return false; | |
280 | ||
281 | if ((flags & wxTEXT_ATTR_BULLET_NAME) && | |
282 | (GetBulletName() != attr.GetBulletName())) | |
283 | return false; | |
284 | ||
285 | if ((flags & wxTEXT_ATTR_TABS) && | |
286 | !TabsEq(GetTabs(), attr.GetTabs())) | |
287 | return false; | |
288 | ||
289 | if ((flags & wxTEXT_ATTR_PAGE_BREAK) && | |
290 | (HasPageBreak() != attr.HasPageBreak())) | |
291 | return false; | |
292 | ||
293 | if (flags & wxTEXT_ATTR_EFFECTS) | |
294 | { | |
295 | if (HasTextEffects() != attr.HasTextEffects()) | |
296 | return false; | |
297 | if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), attr.GetTextEffectFlags())) | |
298 | return false; | |
299 | } | |
300 | ||
301 | if ((flags & wxTEXT_ATTR_OUTLINE_LEVEL) && | |
302 | (GetOutlineLevel() != attr.GetOutlineLevel())) | |
303 | return false; | |
304 | ||
305 | return true; | |
306 | } | |
307 | ||
308 | // Create font from font attributes. | |
1fee6e25 | 309 | wxFont wxTextAttr::GetFont() const |
44cc96a8 | 310 | { |
1fee6e25 VZ |
311 | if ( !HasFont() ) |
312 | return wxNullFont; | |
313 | ||
44cc96a8 JS |
314 | int fontSize = 10; |
315 | if (HasFontSize()) | |
316 | fontSize = GetFontSize(); | |
317 | ||
318 | int fontStyle = wxNORMAL; | |
319 | if (HasFontItalic()) | |
320 | fontStyle = GetFontStyle(); | |
321 | ||
322 | int fontWeight = wxNORMAL; | |
323 | if (HasFontWeight()) | |
324 | fontWeight = GetFontWeight(); | |
325 | ||
326 | bool underlined = false; | |
327 | if (HasFontUnderlined()) | |
328 | underlined = GetFontUnderlined(); | |
329 | ||
330 | wxString fontFaceName; | |
331 | if (HasFontFaceName()) | |
332 | fontFaceName = GetFontFaceName(); | |
333 | ||
334 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT; | |
335 | if (HasFontEncoding()) | |
336 | encoding = GetFontEncoding(); | |
337 | ||
aa926768 | 338 | wxFontFamily fontFamily = wxFONTFAMILY_DEFAULT; |
9c4cb611 JS |
339 | if (HasFontFamily()) |
340 | fontFamily = GetFontFamily(); | |
341 | ||
342 | wxFont font(fontSize, fontFamily, fontStyle, fontWeight, underlined, fontFaceName, encoding); | |
44cc96a8 JS |
343 | return font; |
344 | } | |
345 | ||
346 | // Get attributes from font. | |
347 | bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags) | |
348 | { | |
349 | if (!font.Ok()) | |
350 | return false; | |
351 | ||
352 | if (flags & wxTEXT_ATTR_FONT_SIZE) | |
353 | m_fontSize = font.GetPointSize(); | |
354 | ||
355 | if (flags & wxTEXT_ATTR_FONT_ITALIC) | |
356 | m_fontStyle = font.GetStyle(); | |
357 | ||
358 | if (flags & wxTEXT_ATTR_FONT_WEIGHT) | |
359 | m_fontWeight = font.GetWeight(); | |
360 | ||
361 | if (flags & wxTEXT_ATTR_FONT_UNDERLINE) | |
362 | m_fontUnderlined = font.GetUnderlined(); | |
363 | ||
364 | if (flags & wxTEXT_ATTR_FONT_FACE) | |
365 | m_fontFaceName = font.GetFaceName(); | |
366 | ||
367 | if (flags & wxTEXT_ATTR_FONT_ENCODING) | |
368 | m_fontEncoding = font.GetEncoding(); | |
369 | ||
9c4cb611 | 370 | if (flags & wxTEXT_ATTR_FONT_FAMILY) |
aa926768 VZ |
371 | { |
372 | // wxFont might not know its family, avoid setting m_fontFamily to an | |
373 | // invalid value and rather pretend that we don't have any font family | |
374 | // information at all in this case | |
375 | const wxFontFamily fontFamily = font.GetFamily(); | |
376 | if ( fontFamily == wxFONTFAMILY_UNKNOWN ) | |
377 | flags &= ~wxTEXT_ATTR_FONT_FAMILY; | |
378 | else | |
379 | m_fontFamily = fontFamily; | |
380 | } | |
9c4cb611 | 381 | |
c4076626 JS |
382 | m_flags |= flags; |
383 | ||
44cc96a8 JS |
384 | return true; |
385 | } | |
386 | ||
d1e5be0e JS |
387 | // Resets bits in destination so new attributes aren't merged with mutually exclusive ones |
388 | static bool wxResetIncompatibleBits(const int mask, const int srcFlags, int& destFlags, int& destBits) | |
389 | { | |
390 | if ((srcFlags & mask) && (destFlags & mask)) | |
391 | { | |
392 | destBits &= ~mask; | |
393 | destFlags &= ~mask; | |
394 | } | |
395 | ||
396 | return true; | |
397 | } | |
398 | ||
44cc96a8 JS |
399 | bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith) |
400 | { | |
401 | wxTextAttr& destStyle = (*this); | |
402 | ||
403 | if (style.HasFontWeight()) | |
404 | { | |
405 | if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight())) | |
406 | destStyle.SetFontWeight(style.GetFontWeight()); | |
407 | } | |
408 | ||
409 | if (style.HasFontSize()) | |
410 | { | |
411 | if (!(compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize())) | |
412 | destStyle.SetFontSize(style.GetFontSize()); | |
413 | } | |
414 | ||
415 | if (style.HasFontItalic()) | |
416 | { | |
417 | if (!(compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle())) | |
418 | destStyle.SetFontStyle(style.GetFontStyle()); | |
419 | } | |
420 | ||
421 | if (style.HasFontUnderlined()) | |
422 | { | |
423 | if (!(compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined())) | |
424 | destStyle.SetFontUnderlined(style.GetFontUnderlined()); | |
425 | } | |
426 | ||
427 | if (style.HasFontFaceName()) | |
428 | { | |
429 | if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName())) | |
430 | destStyle.SetFontFaceName(style.GetFontFaceName()); | |
431 | } | |
432 | ||
433 | if (style.HasFontEncoding()) | |
434 | { | |
435 | if (!(compareWith && compareWith->HasFontEncoding() && compareWith->GetFontEncoding() == style.GetFontEncoding())) | |
436 | destStyle.SetFontEncoding(style.GetFontEncoding()); | |
437 | } | |
438 | ||
9c4cb611 JS |
439 | if (style.HasFontFamily()) |
440 | { | |
441 | if (!(compareWith && compareWith->HasFontFamily() && compareWith->GetFontFamily() == style.GetFontFamily())) | |
442 | destStyle.SetFontFamily(style.GetFontFamily()); | |
443 | } | |
444 | ||
44cc96a8 JS |
445 | if (style.GetTextColour().Ok() && style.HasTextColour()) |
446 | { | |
447 | if (!(compareWith && compareWith->HasTextColour() && compareWith->GetTextColour() == style.GetTextColour())) | |
448 | destStyle.SetTextColour(style.GetTextColour()); | |
449 | } | |
450 | ||
451 | if (style.GetBackgroundColour().Ok() && style.HasBackgroundColour()) | |
452 | { | |
453 | if (!(compareWith && compareWith->HasBackgroundColour() && compareWith->GetBackgroundColour() == style.GetBackgroundColour())) | |
454 | destStyle.SetBackgroundColour(style.GetBackgroundColour()); | |
455 | } | |
456 | ||
457 | if (style.HasAlignment()) | |
458 | { | |
459 | if (!(compareWith && compareWith->HasAlignment() && compareWith->GetAlignment() == style.GetAlignment())) | |
460 | destStyle.SetAlignment(style.GetAlignment()); | |
461 | } | |
462 | ||
463 | if (style.HasTabs()) | |
464 | { | |
465 | if (!(compareWith && compareWith->HasTabs() && TabsEq(compareWith->GetTabs(), style.GetTabs()))) | |
466 | destStyle.SetTabs(style.GetTabs()); | |
467 | } | |
468 | ||
469 | if (style.HasLeftIndent()) | |
470 | { | |
471 | if (!(compareWith && compareWith->HasLeftIndent() && compareWith->GetLeftIndent() == style.GetLeftIndent() | |
472 | && compareWith->GetLeftSubIndent() == style.GetLeftSubIndent())) | |
473 | destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); | |
474 | } | |
475 | ||
476 | if (style.HasRightIndent()) | |
477 | { | |
478 | if (!(compareWith && compareWith->HasRightIndent() && compareWith->GetRightIndent() == style.GetRightIndent())) | |
479 | destStyle.SetRightIndent(style.GetRightIndent()); | |
480 | } | |
481 | ||
482 | if (style.HasParagraphSpacingAfter()) | |
483 | { | |
484 | if (!(compareWith && compareWith->HasParagraphSpacingAfter() && compareWith->GetParagraphSpacingAfter() == style.GetParagraphSpacingAfter())) | |
485 | destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); | |
486 | } | |
487 | ||
488 | if (style.HasParagraphSpacingBefore()) | |
489 | { | |
490 | if (!(compareWith && compareWith->HasParagraphSpacingBefore() && compareWith->GetParagraphSpacingBefore() == style.GetParagraphSpacingBefore())) | |
491 | destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); | |
492 | } | |
493 | ||
494 | if (style.HasLineSpacing()) | |
495 | { | |
496 | if (!(compareWith && compareWith->HasLineSpacing() && compareWith->GetLineSpacing() == style.GetLineSpacing())) | |
497 | destStyle.SetLineSpacing(style.GetLineSpacing()); | |
498 | } | |
499 | ||
500 | if (style.HasCharacterStyleName()) | |
501 | { | |
502 | if (!(compareWith && compareWith->HasCharacterStyleName() && compareWith->GetCharacterStyleName() == style.GetCharacterStyleName())) | |
503 | destStyle.SetCharacterStyleName(style.GetCharacterStyleName()); | |
504 | } | |
505 | ||
506 | if (style.HasParagraphStyleName()) | |
507 | { | |
508 | if (!(compareWith && compareWith->HasParagraphStyleName() && compareWith->GetParagraphStyleName() == style.GetParagraphStyleName())) | |
509 | destStyle.SetParagraphStyleName(style.GetParagraphStyleName()); | |
510 | } | |
511 | ||
512 | if (style.HasListStyleName()) | |
513 | { | |
514 | if (!(compareWith && compareWith->HasListStyleName() && compareWith->GetListStyleName() == style.GetListStyleName())) | |
515 | destStyle.SetListStyleName(style.GetListStyleName()); | |
516 | } | |
517 | ||
518 | if (style.HasBulletStyle()) | |
519 | { | |
520 | if (!(compareWith && compareWith->HasBulletStyle() && compareWith->GetBulletStyle() == style.GetBulletStyle())) | |
521 | destStyle.SetBulletStyle(style.GetBulletStyle()); | |
522 | } | |
523 | ||
524 | if (style.HasBulletText()) | |
525 | { | |
526 | if (!(compareWith && compareWith->HasBulletText() && compareWith->GetBulletText() == style.GetBulletText())) | |
527 | { | |
528 | destStyle.SetBulletText(style.GetBulletText()); | |
529 | destStyle.SetBulletFont(style.GetBulletFont()); | |
530 | } | |
531 | } | |
532 | ||
533 | if (style.HasBulletNumber()) | |
534 | { | |
535 | if (!(compareWith && compareWith->HasBulletNumber() && compareWith->GetBulletNumber() == style.GetBulletNumber())) | |
536 | destStyle.SetBulletNumber(style.GetBulletNumber()); | |
537 | } | |
538 | ||
539 | if (style.HasBulletName()) | |
540 | { | |
541 | if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName())) | |
542 | destStyle.SetBulletName(style.GetBulletName()); | |
543 | } | |
544 | ||
545 | if (style.HasURL()) | |
546 | { | |
547 | if (!(compareWith && compareWith->HasURL() && compareWith->GetURL() == style.GetURL())) | |
548 | destStyle.SetURL(style.GetURL()); | |
549 | } | |
550 | ||
551 | if (style.HasPageBreak()) | |
552 | { | |
553 | if (!(compareWith && compareWith->HasPageBreak())) | |
554 | destStyle.SetPageBreak(); | |
555 | } | |
556 | ||
557 | if (style.HasTextEffects()) | |
558 | { | |
559 | if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects())) | |
560 | { | |
561 | int destBits = destStyle.GetTextEffects(); | |
562 | int destFlags = destStyle.GetTextEffectFlags(); | |
563 | ||
564 | int srcBits = style.GetTextEffects(); | |
565 | int srcFlags = style.GetTextEffectFlags(); | |
566 | ||
d1e5be0e JS |
567 | // Reset incompatible bits in the destination |
568 | wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_SUPERSCRIPT|wxTEXT_ATTR_EFFECT_SUBSCRIPT), srcFlags, destFlags, destBits); | |
569 | wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_CAPITALS|wxTEXT_ATTR_EFFECT_SMALL_CAPITALS), srcFlags, destFlags, destBits); | |
570 | wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_STRIKETHROUGH|wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH), srcFlags, destFlags, destBits); | |
571 | ||
44cc96a8 JS |
572 | CombineBitlists(destBits, srcBits, destFlags, srcFlags); |
573 | ||
574 | destStyle.SetTextEffects(destBits); | |
575 | destStyle.SetTextEffectFlags(destFlags); | |
576 | } | |
577 | } | |
578 | ||
579 | if (style.HasOutlineLevel()) | |
580 | { | |
581 | if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel())) | |
582 | destStyle.SetOutlineLevel(style.GetOutlineLevel()); | |
583 | } | |
584 | ||
585 | return true; | |
e00a5d3c JS |
586 | } |
587 | ||
eda40bfc VZ |
588 | /* static */ |
589 | wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr, | |
590 | const wxTextAttr& attrDef, | |
591 | const wxTextCtrlBase *text) | |
592 | { | |
7c3c990e JS |
593 | wxFont font; |
594 | if (attr.HasFont()) | |
595 | font = attr.GetFont(); | |
596 | ||
eda40bfc VZ |
597 | if ( !font.Ok() ) |
598 | { | |
7c3c990e JS |
599 | if (attrDef.HasFont()) |
600 | font = attrDef.GetFont(); | |
eda40bfc VZ |
601 | |
602 | if ( text && !font.Ok() ) | |
603 | font = text->GetFont(); | |
604 | } | |
605 | ||
606 | wxColour colFg = attr.GetTextColour(); | |
607 | if ( !colFg.Ok() ) | |
608 | { | |
609 | colFg = attrDef.GetTextColour(); | |
610 | ||
611 | if ( text && !colFg.Ok() ) | |
612 | colFg = text->GetForegroundColour(); | |
613 | } | |
614 | ||
615 | wxColour colBg = attr.GetBackgroundColour(); | |
616 | if ( !colBg.Ok() ) | |
617 | { | |
618 | colBg = attrDef.GetBackgroundColour(); | |
619 | ||
620 | if ( text && !colBg.Ok() ) | |
621 | colBg = text->GetBackgroundColour(); | |
622 | } | |
623 | ||
e00a5d3c | 624 | wxTextAttr newAttr(colFg, colBg, font); |
cb719f2e | 625 | |
e00a5d3c JS |
626 | if (attr.HasAlignment()) |
627 | newAttr.SetAlignment(attr.GetAlignment()); | |
628 | else if (attrDef.HasAlignment()) | |
629 | newAttr.SetAlignment(attrDef.GetAlignment()); | |
cb719f2e | 630 | |
e00a5d3c JS |
631 | if (attr.HasTabs()) |
632 | newAttr.SetTabs(attr.GetTabs()); | |
633 | else if (attrDef.HasTabs()) | |
634 | newAttr.SetTabs(attrDef.GetTabs()); | |
cb719f2e | 635 | |
e00a5d3c | 636 | if (attr.HasLeftIndent()) |
89b67477 | 637 | newAttr.SetLeftIndent(attr.GetLeftIndent(), attr.GetLeftSubIndent()); |
e00a5d3c | 638 | else if (attrDef.HasLeftIndent()) |
89b67477 | 639 | newAttr.SetLeftIndent(attrDef.GetLeftIndent(), attr.GetLeftSubIndent()); |
cb719f2e | 640 | |
e00a5d3c JS |
641 | if (attr.HasRightIndent()) |
642 | newAttr.SetRightIndent(attr.GetRightIndent()); | |
643 | else if (attrDef.HasRightIndent()) | |
cb719f2e WS |
644 | newAttr.SetRightIndent(attrDef.GetRightIndent()); |
645 | ||
e00a5d3c | 646 | return newAttr; |
eda40bfc VZ |
647 | } |
648 | ||
44cc96a8 JS |
649 | /// Compare tabs |
650 | bool wxTextAttr::TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2) | |
e00a5d3c | 651 | { |
44cc96a8 JS |
652 | if (tabs1.GetCount() != tabs2.GetCount()) |
653 | return false; | |
654 | ||
655 | size_t i; | |
656 | for (i = 0; i < tabs1.GetCount(); i++) | |
657 | { | |
658 | if (tabs1[i] != tabs2[i]) | |
659 | return false; | |
660 | } | |
661 | return true; | |
662 | } | |
663 | ||
664 | // Remove attributes | |
665 | bool wxTextAttr::RemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style) | |
666 | { | |
667 | int flags = style.GetFlags(); | |
668 | int destFlags = destStyle.GetFlags(); | |
669 | ||
670 | destStyle.SetFlags(destFlags & ~flags); | |
671 | ||
672 | return true; | |
673 | } | |
674 | ||
675 | /// Combine two bitlists, specifying the bits of interest with separate flags. | |
676 | bool wxTextAttr::CombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB) | |
677 | { | |
678 | // We want to apply B's bits to A, taking into account each's flags which indicate which bits | |
679 | // are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags | |
680 | // indicate it. | |
681 | ||
682 | // First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero | |
683 | // bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant. | |
684 | int valueA2 = ~(~valueB & flagsB) & valueA; | |
685 | ||
686 | // Now combine the 1 bits. | |
687 | int valueA3 = (valueB & flagsB) | valueA2; | |
688 | ||
689 | valueA = valueA3; | |
690 | flagsA = (flagsA | flagsB); | |
691 | ||
692 | return true; | |
693 | } | |
694 | ||
695 | /// Compare two bitlists | |
696 | bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags) | |
697 | { | |
698 | int relevantBitsA = valueA & flags; | |
699 | int relevantBitsB = valueB & flags; | |
700 | return (relevantBitsA != relevantBitsB); | |
e00a5d3c JS |
701 | } |
702 | ||
44cc96a8 JS |
703 | /// Split into paragraph and character styles |
704 | bool wxTextAttr::SplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle) | |
705 | { | |
706 | wxTextAttr defaultCharStyle1(style); | |
707 | wxTextAttr defaultParaStyle1(style); | |
708 | defaultCharStyle1.SetFlags(defaultCharStyle1.GetFlags()&wxTEXT_ATTR_CHARACTER); | |
709 | defaultParaStyle1.SetFlags(defaultParaStyle1.GetFlags()&wxTEXT_ATTR_PARAGRAPH); | |
710 | ||
711 | charStyle.Apply(defaultCharStyle1); | |
712 | parStyle.Apply(defaultParaStyle1); | |
713 | ||
714 | return true; | |
715 | } | |
e00a5d3c | 716 | |
4bc1afd5 VZ |
717 | // apply styling to text range |
718 | bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end), | |
719 | const wxTextAttr& WXUNUSED(style)) | |
720 | { | |
0ec1179b | 721 | // to be implemented in derived classes |
cb719f2e | 722 | return false; |
4bc1afd5 VZ |
723 | } |
724 | ||
e00a5d3c JS |
725 | // get the styling at the given position |
726 | bool wxTextCtrlBase::GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style)) | |
727 | { | |
0ec1179b | 728 | // to be implemented in derived classes |
cb719f2e | 729 | return false; |
e00a5d3c JS |
730 | } |
731 | ||
4bc1afd5 | 732 | // change default text attributes |
eda40bfc | 733 | bool wxTextCtrlBase::SetDefaultStyle(const wxTextAttr& style) |
4bc1afd5 | 734 | { |
c598f225 VZ |
735 | // keep the old attributes if the new style doesn't specify them unless the |
736 | // new style is empty - then reset m_defaultStyle (as there is no other way | |
737 | // to do it) | |
738 | if ( style.IsDefault() ) | |
739 | m_defaultStyle = style; | |
740 | else | |
741 | m_defaultStyle = wxTextAttr::Combine(style, m_defaultStyle, this); | |
eda40bfc | 742 | |
cb719f2e | 743 | return true; |
4bc1afd5 VZ |
744 | } |
745 | ||
a1b82138 VZ |
746 | // ---------------------------------------------------------------------------- |
747 | // file IO functions | |
748 | // ---------------------------------------------------------------------------- | |
749 | ||
3396739d | 750 | bool wxTextAreaBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType)) |
a1b82138 | 751 | { |
1e6feb95 | 752 | #if wxUSE_FFILE |
a1b82138 VZ |
753 | wxFFile file(filename); |
754 | if ( file.IsOpened() ) | |
755 | { | |
756 | wxString text; | |
757 | if ( file.ReadAll(&text) ) | |
758 | { | |
3396739d | 759 | SetValue(text); |
a1b82138 | 760 | |
cb719f2e | 761 | return true; |
a1b82138 VZ |
762 | } |
763 | } | |
3396739d VZ |
764 | #endif // wxUSE_FFILE |
765 | ||
766 | return false; | |
767 | } | |
a1b82138 | 768 | |
3396739d VZ |
769 | bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int fileType) |
770 | { | |
771 | if ( wxTextAreaBase::DoLoadFile(filename, fileType) ) | |
772 | { | |
773 | DiscardEdits(); | |
774 | m_filename = filename; | |
775 | return true; | |
776 | } | |
a1b82138 | 777 | wxLogError(_("File couldn't be loaded.")); |
3396739d VZ |
778 | return false; |
779 | } | |
a1b82138 | 780 | |
3396739d VZ |
781 | bool wxTextAreaBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType)) |
782 | { | |
783 | #if wxUSE_FFILE | |
784 | wxFFile file(filename, wxT("w")); | |
785 | return file.IsOpened() && file.Write(GetValue(), *wxConvCurrent); | |
786 | #else | |
cb719f2e | 787 | return false; |
3396739d | 788 | #endif // wxUSE_FFILE |
a1b82138 VZ |
789 | } |
790 | ||
0ec1179b | 791 | bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType) |
a1b82138 | 792 | { |
7d8268a1 | 793 | wxString filenameToUse = filename.empty() ? m_filename : filename; |
64dcc269 | 794 | if ( filenameToUse.empty() ) |
a1b82138 VZ |
795 | { |
796 | // what kind of message to give? is it an error or a program bug? | |
223d09f6 | 797 | wxLogDebug(wxT("Can't save textctrl to file without filename.")); |
a1b82138 | 798 | |
cb719f2e | 799 | return false; |
a1b82138 VZ |
800 | } |
801 | ||
3306aec1 JS |
802 | return DoSaveFile(filenameToUse, fileType); |
803 | } | |
804 | ||
3396739d | 805 | bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int fileType) |
3306aec1 | 806 | { |
3396739d | 807 | if ( wxTextAreaBase::DoSaveFile(filename, fileType) ) |
a1b82138 | 808 | { |
3306aec1 JS |
809 | // if it worked, save for future calls |
810 | m_filename = filename; | |
ee2ec18e | 811 | |
a1b82138 VZ |
812 | // it's not modified any longer |
813 | DiscardEdits(); | |
814 | ||
cb719f2e | 815 | return true; |
a1b82138 | 816 | } |
cb719f2e | 817 | return false; |
a1b82138 VZ |
818 | } |
819 | ||
820 | // ---------------------------------------------------------------------------- | |
821 | // stream-like insertion operator | |
822 | // ---------------------------------------------------------------------------- | |
823 | ||
824 | wxTextCtrl& wxTextCtrlBase::operator<<(const wxString& s) | |
825 | { | |
826 | AppendText(s); | |
827 | return *TEXTCTRL(this); | |
828 | } | |
829 | ||
a1b82138 VZ |
830 | wxTextCtrl& wxTextCtrlBase::operator<<(double d) |
831 | { | |
9e50ed28 | 832 | return *this << wxString::Format("%.2f", d); |
a1b82138 VZ |
833 | } |
834 | ||
835 | wxTextCtrl& wxTextCtrlBase::operator<<(int i) | |
836 | { | |
9e50ed28 | 837 | return *this << wxString::Format("%d", i); |
a1b82138 VZ |
838 | } |
839 | ||
9e50ed28 | 840 | wxTextCtrl& wxTextCtrlBase::operator<<(long l) |
a1b82138 | 841 | { |
9e50ed28 | 842 | return *this << wxString::Format("%ld", l); |
a1b82138 VZ |
843 | } |
844 | ||
845 | // ---------------------------------------------------------------------------- | |
846 | // streambuf methods implementation | |
847 | // ---------------------------------------------------------------------------- | |
848 | ||
15cdc341 | 849 | #if wxHAS_TEXT_WINDOW_STREAM |
a1b82138 | 850 | |
d73e6791 | 851 | int wxTextCtrlBase::overflow(int c) |
a1b82138 | 852 | { |
d73e6791 | 853 | AppendText((wxChar)c); |
a1b82138 | 854 | |
d73e6791 | 855 | // return something different from EOF |
a1b82138 VZ |
856 | return 0; |
857 | } | |
858 | ||
15cdc341 | 859 | #endif // wxHAS_TEXT_WINDOW_STREAM |
a1b82138 | 860 | |
94af7d45 VZ |
861 | // ---------------------------------------------------------------------------- |
862 | // emulating key presses | |
863 | // ---------------------------------------------------------------------------- | |
864 | ||
865 | bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event) | |
866 | { | |
0ec1179b VZ |
867 | // we have a native implementation for Win32 and so don't need this one |
868 | #ifndef __WIN32__ | |
02a48e3b | 869 | wxChar ch = 0; |
94af7d45 VZ |
870 | int keycode = event.GetKeyCode(); |
871 | switch ( keycode ) | |
872 | { | |
873 | case WXK_NUMPAD0: | |
874 | case WXK_NUMPAD1: | |
875 | case WXK_NUMPAD2: | |
876 | case WXK_NUMPAD3: | |
877 | case WXK_NUMPAD4: | |
878 | case WXK_NUMPAD5: | |
879 | case WXK_NUMPAD6: | |
880 | case WXK_NUMPAD7: | |
881 | case WXK_NUMPAD8: | |
882 | case WXK_NUMPAD9: | |
9a83f860 | 883 | ch = (wxChar)(wxT('0') + keycode - WXK_NUMPAD0); |
94af7d45 VZ |
884 | break; |
885 | ||
886 | case WXK_MULTIPLY: | |
887 | case WXK_NUMPAD_MULTIPLY: | |
9a83f860 | 888 | ch = wxT('*'); |
94af7d45 VZ |
889 | break; |
890 | ||
891 | case WXK_ADD: | |
892 | case WXK_NUMPAD_ADD: | |
9a83f860 | 893 | ch = wxT('+'); |
94af7d45 VZ |
894 | break; |
895 | ||
896 | case WXK_SUBTRACT: | |
897 | case WXK_NUMPAD_SUBTRACT: | |
9a83f860 | 898 | ch = wxT('-'); |
94af7d45 VZ |
899 | break; |
900 | ||
901 | case WXK_DECIMAL: | |
902 | case WXK_NUMPAD_DECIMAL: | |
9a83f860 | 903 | ch = wxT('.'); |
94af7d45 VZ |
904 | break; |
905 | ||
906 | case WXK_DIVIDE: | |
907 | case WXK_NUMPAD_DIVIDE: | |
9a83f860 | 908 | ch = wxT('/'); |
94af7d45 VZ |
909 | break; |
910 | ||
cd916794 VZ |
911 | case WXK_DELETE: |
912 | case WXK_NUMPAD_DELETE: | |
913 | // delete the character at cursor | |
914 | { | |
7d8268a1 WS |
915 | const long pos = GetInsertionPoint(); |
916 | if ( pos < GetLastPosition() ) | |
cd916794 VZ |
917 | Remove(pos, pos + 1); |
918 | } | |
919 | break; | |
920 | ||
921 | case WXK_BACK: | |
922 | // delete the character before the cursor | |
923 | { | |
924 | const long pos = GetInsertionPoint(); | |
925 | if ( pos > 0 ) | |
926 | Remove(pos - 1, pos); | |
927 | } | |
928 | break; | |
929 | ||
94af7d45 | 930 | default: |
c4d25c01 VS |
931 | #if wxUSE_UNICODE |
932 | if ( event.GetUnicodeKey() ) | |
933 | { | |
934 | ch = event.GetUnicodeKey(); | |
935 | } | |
936 | else | |
937 | #endif | |
401eb3de | 938 | if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) ) |
94af7d45 VZ |
939 | { |
940 | // FIXME this is not going to work for non letters... | |
941 | if ( !event.ShiftDown() ) | |
942 | { | |
401eb3de | 943 | keycode = wxTolower(keycode); |
94af7d45 VZ |
944 | } |
945 | ||
946 | ch = (wxChar)keycode; | |
947 | } | |
948 | else | |
949 | { | |
9a83f860 | 950 | ch = wxT('\0'); |
94af7d45 VZ |
951 | } |
952 | } | |
953 | ||
954 | if ( ch ) | |
955 | { | |
956 | WriteText(ch); | |
957 | ||
cb719f2e | 958 | return true; |
94af7d45 | 959 | } |
c8fe7fda VZ |
960 | #else // __WIN32__ |
961 | wxUnusedVar(event); | |
962 | #endif // !__WIN32__/__WIN32__ | |
94af7d45 | 963 | |
0ec1179b | 964 | return false; |
18414479 VZ |
965 | } |
966 | ||
e39af974 JS |
967 | // do the window-specific processing after processing the update event |
968 | void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event) | |
969 | { | |
a3a4105d VZ |
970 | // call inherited, but skip the wxControl's version, and call directly the |
971 | // wxWindow's one instead, because the only reason why we are overriding this | |
972 | // function is that we want to use SetValue() instead of wxControl::SetLabel() | |
973 | wxWindowBase::DoUpdateWindowUI(event); | |
cb719f2e | 974 | |
a3a4105d | 975 | // update text |
e39af974 JS |
976 | if ( event.GetSetText() ) |
977 | { | |
978 | if ( event.GetText() != GetValue() ) | |
979 | SetValue(event.GetText()); | |
cb719f2e | 980 | } |
e39af974 JS |
981 | } |
982 | ||
efe66bbc VZ |
983 | // ---------------------------------------------------------------------------- |
984 | // hit testing | |
985 | // ---------------------------------------------------------------------------- | |
986 | ||
692c9b86 | 987 | wxTextCtrlHitTestResult |
0ec1179b | 988 | wxTextAreaBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const |
692c9b86 VZ |
989 | { |
990 | // implement in terms of the other overload as the native ports typically | |
991 | // can get the position and not (x, y) pair directly (although wxUniv | |
992 | // directly gets x and y -- and so overrides this method as well) | |
993 | long pos; | |
994 | wxTextCtrlHitTestResult rc = HitTest(pt, &pos); | |
995 | ||
996 | if ( rc != wxTE_HT_UNKNOWN ) | |
997 | { | |
998 | PositionToXY(pos, x, y); | |
999 | } | |
1000 | ||
1001 | return rc; | |
1002 | } | |
1003 | ||
efe66bbc | 1004 | wxTextCtrlHitTestResult |
0ec1179b | 1005 | wxTextAreaBase::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(pos)) const |
efe66bbc VZ |
1006 | { |
1007 | // not implemented | |
1008 | return wxTE_HT_UNKNOWN; | |
1009 | } | |
e39af974 | 1010 | |
ad0bae85 VZ |
1011 | #else // !wxUSE_TEXTCTRL |
1012 | ||
1013 | // define this one even if !wxUSE_TEXTCTRL because it is also used by other | |
1014 | // controls (wxComboBox and wxSpinCtrl) | |
ad0bae85 | 1015 | |
9b11752c | 1016 | wxDEFINE_EVENT( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEvent ); |
ad0bae85 VZ |
1017 | |
1018 | #endif // wxUSE_TEXTCTRL/!wxUSE_TEXTCTRL |