// Modified by:
// Created: 15.09.00
// RCS-ID: $Id$
-// Copyright: (c) 2000 Vadim Zeitlin
+// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#endif
#include "wx/clipbrd.h"
+
#include "wx/textfile.h"
#include "wx/caret.h"
#include "wx/cmdproc.h"
+#if wxUSE_CLIPBOARD
+#include "wx/dataobj.h"
+#endif
+
// turn extra wxTextCtrl-specific debugging on/off
#define WXDEBUG_TEXT
style |= wxALWAYS_SHOW_SB;
}
+ // wxTE_WORDWRAP is 0 for now so we don't need the code below
+#if 0
if ( style & wxTE_WORDWRAP )
{
// wrapping words means wrapping, hence no horz scrollbar
style &= ~wxHSCROLL;
}
+#endif // 0
// TODO: support wxTE_NO_VSCROLL (?)
// create data object for single line controls
m_data.sdata = new wxTextSingleLineData;
}
+
+#if wxUSE_TWO_WINDOWS
+ if ((style & wxBORDER_MASK) == 0)
+ style |= wxBORDER_SUNKEN;
+#endif
if ( !wxControl::Create(parent, id, pos, size, style,
validator, name) )
}
else // valid sel range
{
+ // remember the 'to' position as the current position, used to move the
+ // caret there later
+ wxTextPos toOrig = to;
+
OrderPositions(from, to);
wxCHECK_RET( to <= GetLastPosition(),
}
//else: nothing to do
- // the insertion point is put at the end of selection
- DoSetInsertionPoint(to);
+ // the insertion point is put at the location where the caret was moved
+ DoSetInsertionPoint(toOrig);
}
}
wxTextCoord wxTextCtrl::GetRowCount() const
{
wxTextCoord count = GetLineCount();
+ if (count == 0)
+ return 0;
if ( WrapLines() )
{
count = GetFirstRowOfLine(count - 1) +
// the update region is in window coords and text area is in the client
// ones, so it must be shifted before computing intersection
wxRegion rgnUpdate = GetUpdateRegion();
+
wxRect rectTextArea = GetRealTextArea();
wxPoint pt = GetClientAreaOrigin();
wxRect rectTextAreaAdjusted = rectTextArea;
return pos;
}
-bool wxStdTextCtrlInputHandler::HandleKey(wxControl *control,
+bool wxStdTextCtrlInputHandler::HandleKey(wxInputConsumer *consumer,
const wxKeyEvent& event,
bool pressed)
{
if ( (action != wxACTION_NONE) && (action != wxACTION_TEXT_PREFIX_SEL) )
{
- control->PerformAction(action, -1, str);
+ consumer->PerformAction(action, -1, str);
return TRUE;
}
- return wxStdInputHandler::HandleKey(control, event, pressed);
+ return wxStdInputHandler::HandleKey(consumer, event, pressed);
}
-bool wxStdTextCtrlInputHandler::HandleMouse(wxControl *control,
+bool wxStdTextCtrlInputHandler::HandleMouse(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
if ( event.LeftDown() )
{
wxASSERT_MSG( !m_winCapture, _T("left button going down twice?") );
- wxTextCtrl *text = wxStaticCast(control, wxTextCtrl);
+ wxTextCtrl *text = wxStaticCast(consumer->GetInputWindow(), wxTextCtrl);
m_winCapture = text;
m_winCapture->CaptureMouse();
else if ( event.LeftDClick() )
{
// select the word the cursor is on
- control->PerformAction(wxACTION_TEXT_SEL_WORD);
+ consumer->PerformAction(wxACTION_TEXT_SEL_WORD);
}
else if ( event.LeftUp() )
{
}
}
- return wxStdInputHandler::HandleMouse(control, event);
+ return wxStdInputHandler::HandleMouse(consumer, event);
}
-bool wxStdTextCtrlInputHandler::HandleMouseMove(wxControl *control,
+bool wxStdTextCtrlInputHandler::HandleMouseMove(wxInputConsumer *consumer,
const wxMouseEvent& event)
{
if ( m_winCapture )
}
}
- return wxStdInputHandler::HandleMouseMove(control, event);
+ return wxStdInputHandler::HandleMouseMove(consumer, event);
}
-bool wxStdTextCtrlInputHandler::HandleFocus(wxControl *control,
+bool wxStdTextCtrlInputHandler::HandleFocus(wxInputConsumer *consumer,
const wxFocusEvent& event)
{
- wxTextCtrl *text = wxStaticCast(control, wxTextCtrl);
+ wxTextCtrl *text = wxStaticCast(consumer->GetInputWindow(), wxTextCtrl);
// the selection appearance changes depending on whether we have the focus
text->RefreshSelection();