]>
git.saurik.com Git - wxWidgets.git/blob - src/common/textentrycmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/textentrycmn.cpp
3 // Purpose: wxTextEntryBase implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #if wxUSE_TEXTCTRL || wxUSE_COMBOBOX
29 #include "wx/window.h"
30 #include "wx/dataobj.h"
33 #include "wx/textentry.h"
34 #include "wx/clipbrd.h"
36 // ============================================================================
37 // wxTextEntryBase implementation
38 // ============================================================================
40 wxString
wxTextEntryBase::GetRange(long from
, long to
) const
43 wxString value
= GetValue();
45 if ((from
< to
) && ((long)value
.length() >= to
+ from
))
47 sel
= GetValue().substr(from
, to
- from
);
53 void wxTextEntryBase::AppendText(const wxString
& text
)
55 SetInsertionPointEnd();
59 void wxTextEntryBase::DoSetValue(const wxString
& value
, int flags
)
61 EventsSuppressor
noeventsIf(this, !(flags
& SetValue_SendEvent
));
67 void wxTextEntryBase::Replace(long from
, long to
, const wxString
& value
)
70 EventsSuppressor
noevents(this);
77 bool wxTextEntryBase::HasSelection() const
80 GetSelection(&from
, &to
);
85 void wxTextEntryBase::RemoveSelection()
88 GetSelection(& from
, & to
);
89 if (from
!= -1 && to
!= -1)
93 wxString
wxTextEntryBase::GetStringSelection() const
96 GetSelection(&from
, &to
);
98 return GetRange(from
, to
);
101 bool wxTextEntryBase::CanCopy() const
103 return HasSelection();
106 bool wxTextEntryBase::CanCut() const
108 return CanCopy() && IsEditable();
111 bool wxTextEntryBase::CanPaste() const
116 // check if there is any text on the clipboard
117 if ( wxTheClipboard
->IsSupported(wxDF_TEXT
)
119 || wxTheClipboard
->IsSupported(wxDF_UNICODETEXT
)
120 #endif // wxUSE_UNICODE
125 #endif // wxUSE_CLIPBOARD
131 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX