]>
Commit | Line | Data |
---|---|---|
0ec1179b VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/common/textentrycmn.cpp | |
3 | // Purpose: wxTextEntryBase implementation | |
4 | // Author: Vadim Zeitlin | |
5 | // Created: 2007-09-26 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org> | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // ============================================================================ | |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | // for compilers that support precompilation, includes "wx.h". | |
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX | |
27 | ||
28 | #ifndef WX_PRECOMP | |
29 | #endif //WX_PRECOMP | |
30 | ||
31 | #include "wx/textentry.h" | |
32 | ||
33 | // ============================================================================ | |
34 | // wxTextEntryBase implementation | |
35 | // ============================================================================ | |
36 | ||
37 | wxString wxTextEntryBase::GetRange(long from, long to) const | |
38 | { | |
39 | wxString sel; | |
40 | if ( from < to ) | |
41 | { | |
42 | sel = GetValue().substr(from, to - from); | |
43 | } | |
44 | ||
45 | return sel; | |
46 | } | |
47 | ||
48 | void wxTextEntryBase::AppendText(const wxString& text) | |
49 | { | |
50 | SetInsertionPointEnd(); | |
51 | WriteText(text); | |
52 | } | |
53 | ||
54 | void wxTextEntryBase::DoSetValue(const wxString& value, int flags) | |
55 | { | |
56 | EventsSuppressor noeventsIf(this, !(flags & SetValue_SendEvent)); | |
57 | ||
58 | SelectAll(); | |
59 | WriteText(value); | |
60 | } | |
61 | ||
62 | void wxTextEntryBase::Replace(long from, long to, const wxString& value) | |
63 | { | |
64 | { | |
65 | EventsSuppressor noevents(this); | |
66 | Remove(from, to); | |
67 | } | |
68 | ||
69 | WriteText(value); | |
70 | } | |
71 | ||
72 | bool wxTextEntryBase::HasSelection() const | |
73 | { | |
74 | long from, to; | |
75 | GetSelection(&from, &to); | |
76 | ||
77 | return from < to; | |
78 | } | |
79 | ||
80 | wxString wxTextEntryBase::GetStringSelection() const | |
81 | { | |
82 | long from, to; | |
83 | GetSelection(&from, &to); | |
84 | ||
85 | return GetRange(from, to); | |
86 | } | |
87 | ||
88 | bool wxTextEntryBase::CanCopy() const | |
89 | { | |
90 | return HasSelection(); | |
91 | } | |
92 | ||
93 | bool wxTextEntryBase::CanCut() const | |
94 | { | |
95 | return CanCopy() && IsEditable(); | |
96 | } | |
97 | ||
98 | bool wxTextEntryBase::CanPaste() const | |
99 | { | |
100 | return IsEditable(); | |
101 | } | |
102 | ||
103 | #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX |