]>
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
)
47 sel
= value
.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
));
69 void wxTextEntryBase::Replace(long from
, long to
, const wxString
& value
)
72 EventsSuppressor
noevents(this);
76 SetInsertionPoint(from
);
80 bool wxTextEntryBase::HasSelection() const
83 GetSelection(&from
, &to
);
88 void wxTextEntryBase::RemoveSelection()
91 GetSelection(& from
, & to
);
92 if (from
!= -1 && to
!= -1)
96 wxString
wxTextEntryBase::GetStringSelection() const
99 GetSelection(&from
, &to
);
101 return GetRange(from
, to
);
104 bool wxTextEntryBase::CanCopy() const
106 return HasSelection();
109 bool wxTextEntryBase::CanCut() const
111 return CanCopy() && IsEditable();
114 bool wxTextEntryBase::CanPaste() const
119 // check if there is any text on the clipboard
120 if ( wxTheClipboard
->IsSupported(wxDF_TEXT
)
122 || wxTheClipboard
->IsSupported(wxDF_UNICODETEXT
)
123 #endif // wxUSE_UNICODE
128 #endif // wxUSE_CLIPBOARD
134 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX