]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/textentry.cpp
05bca2ac1c138c95467e74afa53c35204fb04842
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/textentry.cpp
3 // Purpose: wxTextEntry implementation for wxMSW
4 // Author: Vadim Zeitlin
6 // RCS-ID: $Id: wxhead.cpp,v 1.7 2007/01/09 16:22:45 zeitlin Exp $
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"
29 #include "wx/textentry.h"
31 #include "wx/msw/private.h"
33 #define GetEditHwnd() ((HWND)(GetEditHWND()))
35 // ============================================================================
36 // wxTextEntry implementation
37 // ============================================================================
39 void wxTextEntry::WriteText(const wxString
& text
)
41 ::SendMessage(GetEditHwnd(), EM_REPLACESEL
, 0, (LPARAM
)text
.wx_str());
44 wxString
wxTextEntry::GetValue() const
46 return wxGetWindowText(GetEditHWND());
49 void wxTextEntry::Remove(long from
, long to
)
51 DoSetSelection(from
, to
, SetSel_NoScroll
);
52 WriteText(wxString());
55 void wxTextEntry::Copy()
57 ::SendMessage(GetEditHwnd(), WM_COPY
, 0, 0);
60 void wxTextEntry::Cut()
62 ::SendMessage(GetEditHwnd(), WM_CUT
, 0, 0);
65 void wxTextEntry::Paste()
67 ::SendMessage(GetEditHwnd(), WM_PASTE
, 0, 0);
70 void wxTextEntry::Undo()
72 ::SendMessage(GetEditHwnd(), EM_UNDO
, 0, 0);
75 void wxTextEntry::Redo()
77 // same as Undo, since Undo undoes the undo
82 bool wxTextEntry::CanUndo() const
84 return ::SendMessage(GetEditHwnd(), EM_CANUNDO
, 0, 0) != 0;
87 bool wxTextEntry::CanRedo() const
89 // see comment in Redo()
93 void wxTextEntry::SetInsertionPoint(long pos
)
95 // be careful to call DoSetSelection() which is overridden in wxTextCtrl
96 // and not just SetSelection() here
97 DoSetSelection(pos
, pos
);
100 long wxTextEntry::GetInsertionPoint() const
103 GetSelection(&from
, NULL
);
107 long wxTextEntry::GetLastPosition() const
109 return ::SendMessage(GetEditHwnd(), EM_LINELENGTH
, 0, 0);
112 void wxTextEntry::DoSetSelection(long from
, long to
, int WXUNUSED(flags
))
114 // if from and to are both -1, it means (in wxWidgets) that all text should
115 // be selected, translate this into Windows convention
116 if ( (from
== -1) && (to
== -1) )
121 ::SendMessage(GetEditHwnd(), EM_SETSEL
, from
, to
);
124 void wxTextEntry::GetSelection(long *from
, long *to
) const
126 DWORD dwStart
, dwEnd
;
127 ::SendMessage(GetEditHwnd(), EM_GETSEL
, (WPARAM
)&dwStart
, (LPARAM
)&dwEnd
);
135 bool wxTextEntry::IsEditable() const
137 return (::GetWindowLong(GetEditHwnd(), GWL_STYLE
) & ES_READONLY
) != 0;
140 void wxTextEntry::SetEditable(bool editable
)
142 ::SendMessage(GetEditHwnd(), EM_SETREADONLY
, !editable
, 0);
145 void wxTextEntry::SetMaxLength(unsigned long len
)
149 // this will set it to a platform-dependent maximum (much more
150 // than 64Kb under NT)
154 ::SendMessage(GetEditHwnd(), EM_LIMITTEXT
, len
, 0);