]>
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);
79 bool wxTextEntryBase::HasSelection() const
82 GetSelection(&from
, &to
);
87 void wxTextEntryBase::RemoveSelection()
90 GetSelection(& from
, & to
);
91 if (from
!= -1 && to
!= -1)
95 wxString
wxTextEntryBase::GetStringSelection() const
98 GetSelection(&from
, &to
);
100 return GetRange(from
, to
);
103 bool wxTextEntryBase::CanCopy() const
105 return HasSelection();
108 bool wxTextEntryBase::CanCut() const
110 return CanCopy() && IsEditable();
113 bool wxTextEntryBase::CanPaste() const
118 // check if there is any text on the clipboard
119 if ( wxTheClipboard
->IsSupported(wxDF_TEXT
)
121 || wxTheClipboard
->IsSupported(wxDF_UNICODETEXT
)
122 #endif // wxUSE_UNICODE
127 #endif // wxUSE_CLIPBOARD
133 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX