correct properties were not set during initial add somehow

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48986 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-09-28 23:14:08 +00:00
parent 32b171bc0e
commit 69a05ef6d6

View File

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