+///////////////////////////////////////////////////////////////////////////////\r
+// Name: src/msw/textentry.cpp\r
+// Purpose: wxTextEntry implementation for wxMSW\r
+// Author: Vadim Zeitlin\r
+// Created: 2007-09-26\r
+// RCS-ID: $Id: wxhead.cpp,v 1.7 2007/01/09 16:22:45 zeitlin Exp $\r
+// Copyright: (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>\r
+// Licence: wxWindows licence\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
+// ============================================================================\r
+// declarations\r
+// ============================================================================\r
+\r
+// ----------------------------------------------------------------------------\r
+// headers\r
+// ----------------------------------------------------------------------------\r
+\r
+// for compilers that support precompilation, includes "wx.h".\r
+#include "wx/wxprec.h"\r
+\r
+#ifdef __BORLANDC__\r
+ #pragma hdrstop\r
+#endif\r
+\r
+#ifndef WX_PRECOMP\r
+#endif // WX_PRECOMP\r
+\r
+#include "wx/textentry.h"\r
+\r
+#include "wx/msw/private.h"\r
+\r
+#define GetEditHwnd() ((HWND)(GetEditHWND()))\r
+\r
+// ============================================================================\r
+// wxTextEntry implementation\r
+// ============================================================================\r
+\r
+void wxTextEntry::WriteText(const wxString& text)\r
+{\r
+ ::SendMessage(GetEditHwnd(), EM_REPLACESEL, 0, (LPARAM)text.wx_str());\r
+}\r
+\r
+wxString wxTextEntry::GetValue() const\r
+{\r
+ return wxGetWindowText(GetEditHWND());\r
+}\r
+\r
+void wxTextEntry::Remove(long from, long to)\r
+{\r
+ DoSetSelection(from, to, SetSel_NoScroll);\r
+ WriteText(wxString());\r
+}\r
+\r
+void wxTextEntry::Copy()\r
+{\r
+ ::SendMessage(GetEditHwnd(), WM_COPY, 0, 0);\r
+}\r
+\r
+void wxTextEntry::Cut()\r
+{\r
+ ::SendMessage(GetEditHwnd(), WM_CUT, 0, 0);\r
+}\r
+\r
+void wxTextEntry::Paste()\r
+{\r
+ ::SendMessage(GetEditHwnd(), WM_PASTE, 0, 0);\r
+}\r
+\r
+void wxTextEntry::Undo()\r
+{\r
+ ::SendMessage(GetEditHwnd(), EM_UNDO, 0, 0);\r
+}\r
+\r
+void wxTextEntry::Redo()\r
+{\r
+ // same as Undo, since Undo undoes the undo\r
+ return Undo();\r
+}\r
+\r
+bool wxTextEntry::CanUndo() const\r
+{\r
+ return ::SendMessage(GetEditHwnd(), EM_CANUNDO, 0, 0) != 0;\r
+}\r
+\r
+bool wxTextEntry::CanRedo() const\r
+{\r
+ // see comment in Redo()\r
+ return CanUndo();\r
+}\r
+\r
+void wxTextEntry::SetInsertionPoint(long pos)\r
+{\r
+ // be careful to call DoSetSelection() which is overridden in wxTextCtrl\r
+ // and not just SetSelection() here\r
+ DoSetSelection(pos, pos);\r
+}\r
+\r
+long wxTextEntry::GetInsertionPoint() const\r
+{\r
+ long from;\r
+ GetSelection(&from, NULL);\r
+ return from;\r
+}\r
+\r
+long wxTextEntry::GetLastPosition() const\r
+{\r
+ return ::SendMessage(GetEditHwnd(), EM_LINELENGTH, 0, 0);\r
+}\r
+\r
+void wxTextEntry::DoSetSelection(long from, long to, int WXUNUSED(flags))\r
+{\r
+ // if from and to are both -1, it means (in wxWidgets) that all text should\r
+ // be selected, translate this into Windows convention\r
+ if ( (from == -1) && (to == -1) )\r
+ {\r
+ from = 0;\r
+ }\r
+\r
+ ::SendMessage(GetEditHwnd(), EM_SETSEL, from, to);\r
+}\r
+\r
+void wxTextEntry::GetSelection(long *from, long *to) const\r
+{\r
+ DWORD dwStart, dwEnd;\r
+ ::SendMessage(GetEditHwnd(), EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);\r
+\r
+ if ( from )\r
+ *from = dwStart;\r
+ if ( to )\r
+ *to = dwEnd;\r
+}\r
+\r
+bool wxTextEntry::IsEditable() const\r
+{\r
+ return (::GetWindowLong(GetEditHwnd(), GWL_STYLE) & ES_READONLY) != 0;\r
+}\r
+\r
+void wxTextEntry::SetEditable(bool editable)\r
+{\r
+ ::SendMessage(GetEditHwnd(), EM_SETREADONLY, !editable, 0);\r
+}\r
+\r
+void wxTextEntry::SetMaxLength(unsigned long len)\r
+{\r
+ if ( len >= 0xffff )\r
+ {\r
+ // this will set it to a platform-dependent maximum (much more\r
+ // than 64Kb under NT)\r
+ len = 0;\r
+ }\r
+\r
+ ::SendMessage(GetEditHwnd(), EM_LIMITTEXT, len, 0);\r
+}\r