]>
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
45 sel
= GetValue().substr(from
, to
- from
);
51 void wxTextEntryBase::AppendText(const wxString
& text
)
53 SetInsertionPointEnd();
57 void wxTextEntryBase::DoSetValue(const wxString
& value
, int flags
)
59 EventsSuppressor
noeventsIf(this, !(flags
& SetValue_SendEvent
));
65 void wxTextEntryBase::Replace(long from
, long to
, const wxString
& value
)
68 EventsSuppressor
noevents(this);
75 bool wxTextEntryBase::HasSelection() const
78 GetSelection(&from
, &to
);
83 void wxTextEntryBase::RemoveSelection()
86 GetSelection(& from
, & to
);
87 if (from
!= -1 && to
!= -1)
91 wxString
wxTextEntryBase::GetStringSelection() const
94 GetSelection(&from
, &to
);
96 return GetRange(from
, to
);
99 bool wxTextEntryBase::CanCopy() const
101 return HasSelection();
104 bool wxTextEntryBase::CanCut() const
106 return CanCopy() && IsEditable();
109 bool wxTextEntryBase::CanPaste() const
114 // check if there is any text on the clipboard
115 if ( wxTheClipboard
->IsSupported(wxDF_TEXT
)
117 || wxTheClipboard
->IsSupported(wxDF_UNICODETEXT
)
118 #endif // wxUSE_UNICODE
123 #endif // wxUSE_CLIPBOARD
129 #endif // wxUSE_TEXTCTRL || wxUSE_COMBOBOX