1999-07-14 22:55:57 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: common/textcmn.cpp
|
|
|
|
// Purpose: implementation of platform-independent functions of wxTextCtrl
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 13.07.99
|
|
|
|
// RCS-ID: $Id$
|
2004-05-23 14:56:36 +00:00
|
|
|
// Copyright: (c) wxWidgets team
|
|
|
|
// Licence: wxWidgets licence
|
1999-07-14 22:55:57 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
2001-06-26 20:59:19 +00:00
|
|
|
|
2003-08-09 12:46:53 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
1999-08-12 12:18:49 +00:00
|
|
|
#pragma implementation "textctrlbase.h"
|
|
|
|
#endif
|
2001-06-26 20:59:19 +00:00
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// for compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_TEXTCTRL
|
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
#ifndef WX_PRECOMP
|
1999-07-15 13:42:27 +00:00
|
|
|
#include "wx/intl.h"
|
|
|
|
#include "wx/log.h"
|
1999-07-14 22:55:57 +00:00
|
|
|
#include "wx/textctrl.h"
|
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
|
|
|
#include "wx/ffile.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// we don't have any objects of type wxTextCtrlBase in the program, only
|
|
|
|
// wxTextCtrl, so this cast is safe
|
|
|
|
#define TEXTCTRL(ptr) ((wxTextCtrl *)(ptr))
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
2001-07-29 22:40:21 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxTextUrlEvent, wxCommandEvent)
|
|
|
|
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED)
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_ENTER)
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_URL)
|
2001-08-15 12:45:53 +00:00
|
|
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN)
|
2001-07-29 22:40:21 +00:00
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ctor
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
wxTextCtrlBase::wxTextCtrlBase()
|
|
|
|
{
|
2000-02-17 18:23:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxTextCtrlBase::~wxTextCtrlBase()
|
|
|
|
{
|
1999-07-14 22:55:57 +00:00
|
|
|
}
|
|
|
|
|
2001-05-27 03:28:28 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// style functions - not implemented here
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
wxTextAttr::wxTextAttr(const wxColour& colText,
|
|
|
|
const wxColour& colBack,
|
|
|
|
const wxFont& font,
|
|
|
|
wxTextAttrAlignment alignment)
|
|
|
|
: m_colText(colText), m_colBack(colBack), m_font(font), m_textAlignment(alignment)
|
|
|
|
{
|
|
|
|
m_flags = 0;
|
|
|
|
m_leftIndent = 0;
|
2004-05-15 18:17:14 +00:00
|
|
|
m_leftSubIndent = 0;
|
2003-06-20 16:25:31 +00:00
|
|
|
m_rightIndent = 0;
|
|
|
|
if (m_colText.Ok()) m_flags |= wxTEXT_ATTR_TEXT_COLOUR;
|
|
|
|
if (m_colBack.Ok()) m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR;
|
|
|
|
if (m_font.Ok()) m_flags |= wxTEXT_ATTR_FONT;
|
|
|
|
if (alignment != wxTEXT_ALIGNMENT_DEFAULT)
|
|
|
|
m_flags |= wxTEXT_ATTR_ALIGNMENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxTextAttr::Init()
|
|
|
|
{
|
|
|
|
m_textAlignment = wxTEXT_ALIGNMENT_DEFAULT;
|
|
|
|
m_flags = 0;
|
|
|
|
m_leftIndent = 0;
|
2004-05-15 18:17:14 +00:00
|
|
|
m_leftSubIndent = 0;
|
2003-06-20 16:25:31 +00:00
|
|
|
m_rightIndent = 0;
|
|
|
|
}
|
|
|
|
|
2001-11-26 14:50:50 +00:00
|
|
|
/* static */
|
|
|
|
wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr,
|
|
|
|
const wxTextAttr& attrDef,
|
|
|
|
const wxTextCtrlBase *text)
|
|
|
|
{
|
|
|
|
wxFont font = attr.GetFont();
|
|
|
|
if ( !font.Ok() )
|
|
|
|
{
|
|
|
|
font = attrDef.GetFont();
|
|
|
|
|
|
|
|
if ( text && !font.Ok() )
|
|
|
|
font = text->GetFont();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxColour colFg = attr.GetTextColour();
|
|
|
|
if ( !colFg.Ok() )
|
|
|
|
{
|
|
|
|
colFg = attrDef.GetTextColour();
|
|
|
|
|
|
|
|
if ( text && !colFg.Ok() )
|
|
|
|
colFg = text->GetForegroundColour();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxColour colBg = attr.GetBackgroundColour();
|
|
|
|
if ( !colBg.Ok() )
|
|
|
|
{
|
|
|
|
colBg = attrDef.GetBackgroundColour();
|
|
|
|
|
|
|
|
if ( text && !colBg.Ok() )
|
|
|
|
colBg = text->GetBackgroundColour();
|
|
|
|
}
|
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
wxTextAttr newAttr(colFg, colBg, font);
|
|
|
|
|
|
|
|
if (attr.HasAlignment())
|
|
|
|
newAttr.SetAlignment(attr.GetAlignment());
|
|
|
|
else if (attrDef.HasAlignment())
|
|
|
|
newAttr.SetAlignment(attrDef.GetAlignment());
|
|
|
|
|
|
|
|
if (attr.HasTabs())
|
|
|
|
newAttr.SetTabs(attr.GetTabs());
|
|
|
|
else if (attrDef.HasTabs())
|
|
|
|
newAttr.SetTabs(attrDef.GetTabs());
|
|
|
|
|
|
|
|
if (attr.HasLeftIndent())
|
2004-05-15 18:17:14 +00:00
|
|
|
newAttr.SetLeftIndent(attr.GetLeftIndent(), attr.GetLeftSubIndent());
|
2003-06-20 16:25:31 +00:00
|
|
|
else if (attrDef.HasLeftIndent())
|
2004-05-15 18:17:14 +00:00
|
|
|
newAttr.SetLeftIndent(attrDef.GetLeftIndent(), attr.GetLeftSubIndent());
|
2003-06-20 16:25:31 +00:00
|
|
|
|
|
|
|
if (attr.HasRightIndent())
|
|
|
|
newAttr.SetRightIndent(attr.GetRightIndent());
|
|
|
|
else if (attrDef.HasRightIndent())
|
|
|
|
newAttr.SetRightIndent(attrDef.GetRightIndent());
|
|
|
|
|
|
|
|
return newAttr;
|
2001-11-26 14:50:50 +00:00
|
|
|
}
|
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
void wxTextAttr::operator= (const wxTextAttr& attr)
|
|
|
|
{
|
|
|
|
m_font = attr.m_font;
|
|
|
|
m_colText = attr.m_colText;
|
|
|
|
m_colBack = attr.m_colBack;
|
|
|
|
m_textAlignment = attr.m_textAlignment;
|
|
|
|
m_leftIndent = attr.m_leftIndent;
|
2004-05-15 18:17:14 +00:00
|
|
|
m_leftSubIndent = attr.m_leftSubIndent;
|
2003-06-20 16:25:31 +00:00
|
|
|
m_rightIndent = attr.m_rightIndent;
|
|
|
|
m_tabs = attr.m_tabs;
|
|
|
|
m_flags = attr.m_flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-27 03:28:28 +00:00
|
|
|
// apply styling to text range
|
|
|
|
bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end),
|
|
|
|
const wxTextAttr& WXUNUSED(style))
|
|
|
|
{
|
|
|
|
// to be implemented in derived TextCtrl classes
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
// get the styling at the given position
|
|
|
|
bool wxTextCtrlBase::GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style))
|
|
|
|
{
|
|
|
|
// to be implemented in derived TextCtrl classes
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-05-27 03:28:28 +00:00
|
|
|
// change default text attributes
|
2001-11-26 14:50:50 +00:00
|
|
|
bool wxTextCtrlBase::SetDefaultStyle(const wxTextAttr& style)
|
2001-05-27 03:28:28 +00:00
|
|
|
{
|
2001-12-02 13:29:21 +00:00
|
|
|
// keep the old attributes if the new style doesn't specify them unless the
|
|
|
|
// new style is empty - then reset m_defaultStyle (as there is no other way
|
|
|
|
// to do it)
|
|
|
|
if ( style.IsDefault() )
|
|
|
|
m_defaultStyle = style;
|
|
|
|
else
|
|
|
|
m_defaultStyle = wxTextAttr::Combine(style, m_defaultStyle, this);
|
2001-11-26 14:50:50 +00:00
|
|
|
|
2001-05-27 03:28:28 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get default text attributes
|
|
|
|
const wxTextAttr& wxTextCtrlBase::GetDefaultStyle() const
|
|
|
|
{
|
|
|
|
return m_defaultStyle;
|
|
|
|
}
|
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// file IO functions
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::LoadFile(const wxString& filename)
|
|
|
|
{
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_FFILE
|
1999-07-14 22:55:57 +00:00
|
|
|
wxFFile file(filename);
|
|
|
|
if ( file.IsOpened() )
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
if ( file.ReadAll(&text) )
|
|
|
|
{
|
|
|
|
SetValue(text);
|
|
|
|
|
|
|
|
DiscardEdits();
|
|
|
|
|
|
|
|
m_filename = filename;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxLogError(_("File couldn't be loaded."));
|
2001-06-26 20:59:19 +00:00
|
|
|
#endif // wxUSE_FFILE
|
1999-07-14 22:55:57 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::SaveFile(const wxString& filename)
|
|
|
|
{
|
|
|
|
wxString filenameToUse = filename.IsEmpty() ? m_filename : filename;
|
2003-10-16 09:05:54 +00:00
|
|
|
if ( filenameToUse.empty() )
|
1999-07-14 22:55:57 +00:00
|
|
|
{
|
|
|
|
// what kind of message to give? is it an error or a program bug?
|
1999-10-08 14:35:56 +00:00
|
|
|
wxLogDebug(wxT("Can't save textctrl to file without filename."));
|
1999-07-14 22:55:57 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_FFILE
|
2003-10-16 09:05:54 +00:00
|
|
|
wxFFile file(filenameToUse, _T("w"));
|
1999-07-14 22:55:57 +00:00
|
|
|
if ( file.IsOpened() && file.Write(GetValue()) )
|
|
|
|
{
|
|
|
|
// it's not modified any longer
|
|
|
|
DiscardEdits();
|
|
|
|
|
2003-10-16 09:05:54 +00:00
|
|
|
// if it worked, save for future calls
|
|
|
|
m_filename = filenameToUse;
|
1999-07-14 22:55:57 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-10-16 09:05:54 +00:00
|
|
|
#endif // wxUSE_FFILE
|
1999-07-14 22:55:57 +00:00
|
|
|
|
|
|
|
wxLogError(_("The text couldn't be saved."));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// stream-like insertion operator
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
wxTextCtrl& wxTextCtrlBase::operator<<(const wxString& s)
|
|
|
|
{
|
|
|
|
AppendText(s);
|
|
|
|
return *TEXTCTRL(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTextCtrl& wxTextCtrlBase::operator<<(float f)
|
|
|
|
{
|
|
|
|
wxString str;
|
1999-10-08 14:35:56 +00:00
|
|
|
str.Printf(wxT("%.2f"), f);
|
1999-07-14 22:55:57 +00:00
|
|
|
AppendText(str);
|
|
|
|
return *TEXTCTRL(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTextCtrl& wxTextCtrlBase::operator<<(double d)
|
|
|
|
{
|
|
|
|
wxString str;
|
1999-10-08 14:35:56 +00:00
|
|
|
str.Printf(wxT("%.2f"), d);
|
1999-07-14 22:55:57 +00:00
|
|
|
AppendText(str);
|
|
|
|
return *TEXTCTRL(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTextCtrl& wxTextCtrlBase::operator<<(int i)
|
|
|
|
{
|
|
|
|
wxString str;
|
1999-10-08 14:35:56 +00:00
|
|
|
str.Printf(wxT("%d"), i);
|
1999-07-14 22:55:57 +00:00
|
|
|
AppendText(str);
|
|
|
|
return *TEXTCTRL(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxTextCtrl& wxTextCtrlBase::operator<<(long i)
|
|
|
|
{
|
|
|
|
wxString str;
|
1999-10-08 14:35:56 +00:00
|
|
|
str.Printf(wxT("%ld"), i);
|
1999-07-14 22:55:57 +00:00
|
|
|
AppendText(str);
|
|
|
|
return *TEXTCTRL(this);
|
|
|
|
}
|
|
|
|
|
1999-07-22 17:51:54 +00:00
|
|
|
wxTextCtrl& wxTextCtrlBase::operator<<(const wxChar c)
|
1999-07-14 22:55:57 +00:00
|
|
|
{
|
|
|
|
return operator<<(wxString(c));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// streambuf methods implementation
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#ifndef NO_TEXT_WINDOW_STREAM
|
|
|
|
|
2001-10-19 16:27:15 +00:00
|
|
|
int wxTextCtrlBase::overflow(int c)
|
1999-07-14 22:55:57 +00:00
|
|
|
{
|
2001-10-19 16:27:15 +00:00
|
|
|
AppendText((wxChar)c);
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2001-10-19 16:27:15 +00:00
|
|
|
// return something different from EOF
|
1999-07-14 22:55:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // NO_TEXT_WINDOW_STREAM
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// clipboard stuff
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::CanCopy() const
|
|
|
|
{
|
|
|
|
// can copy if there's a selection
|
|
|
|
long from, to;
|
|
|
|
GetSelection(&from, &to);
|
|
|
|
return from != to;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::CanCut() const
|
|
|
|
{
|
|
|
|
// can cut if there's a selection and if we're not read only
|
|
|
|
return CanCopy() && IsEditable();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::CanPaste() const
|
|
|
|
{
|
|
|
|
// can paste if we are not read only
|
|
|
|
return IsEditable();
|
|
|
|
}
|
|
|
|
|
2002-04-07 22:29:04 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// emulating key presses
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-07-23 14:49:37 +00:00
|
|
|
#ifdef __WIN32__
|
|
|
|
// the generic version is unused in wxMSW
|
|
|
|
bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
#else // !__WIN32__
|
2002-04-07 22:29:04 +00:00
|
|
|
bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
|
|
|
|
{
|
2003-04-07 17:32:19 +00:00
|
|
|
wxChar ch = 0;
|
2002-04-07 22:29:04 +00:00
|
|
|
int keycode = event.GetKeyCode();
|
|
|
|
switch ( keycode )
|
|
|
|
{
|
|
|
|
case WXK_NUMPAD0:
|
|
|
|
case WXK_NUMPAD1:
|
|
|
|
case WXK_NUMPAD2:
|
|
|
|
case WXK_NUMPAD3:
|
|
|
|
case WXK_NUMPAD4:
|
|
|
|
case WXK_NUMPAD5:
|
|
|
|
case WXK_NUMPAD6:
|
|
|
|
case WXK_NUMPAD7:
|
|
|
|
case WXK_NUMPAD8:
|
|
|
|
case WXK_NUMPAD9:
|
|
|
|
ch = _T('0') + keycode - WXK_NUMPAD0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_MULTIPLY:
|
|
|
|
case WXK_NUMPAD_MULTIPLY:
|
|
|
|
ch = _T('*');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_ADD:
|
|
|
|
case WXK_NUMPAD_ADD:
|
|
|
|
ch = _T('+');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_SUBTRACT:
|
|
|
|
case WXK_NUMPAD_SUBTRACT:
|
|
|
|
ch = _T('-');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_DECIMAL:
|
|
|
|
case WXK_NUMPAD_DECIMAL:
|
|
|
|
ch = _T('.');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_DIVIDE:
|
|
|
|
case WXK_NUMPAD_DIVIDE:
|
|
|
|
ch = _T('/');
|
|
|
|
break;
|
|
|
|
|
2003-01-02 00:07:13 +00:00
|
|
|
case WXK_DELETE:
|
|
|
|
case WXK_NUMPAD_DELETE:
|
|
|
|
// delete the character at cursor
|
|
|
|
{
|
|
|
|
const long pos = GetInsertionPoint(),
|
|
|
|
last = GetLastPosition();
|
|
|
|
if ( pos < last )
|
|
|
|
Remove(pos, pos + 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WXK_BACK:
|
|
|
|
// delete the character before the cursor
|
|
|
|
{
|
|
|
|
const long pos = GetInsertionPoint();
|
|
|
|
if ( pos > 0 )
|
|
|
|
Remove(pos - 1, pos);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-04-07 22:29:04 +00:00
|
|
|
default:
|
2002-08-05 18:04:08 +00:00
|
|
|
if ( keycode < 256 && keycode >= 0 && wxIsprint(keycode) )
|
2002-04-07 22:29:04 +00:00
|
|
|
{
|
|
|
|
// FIXME this is not going to work for non letters...
|
|
|
|
if ( !event.ShiftDown() )
|
|
|
|
{
|
2002-08-05 18:04:08 +00:00
|
|
|
keycode = wxTolower(keycode);
|
2002-04-07 22:29:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ch = (wxChar)keycode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ch = _T('\0');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ch )
|
|
|
|
{
|
|
|
|
WriteText(ch);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-23 14:49:37 +00:00
|
|
|
#endif // !__WIN32__
|
2002-04-07 22:29:04 +00:00
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2002-01-09 01:32:02 +00:00
|
|
|
// selection and ranges
|
2001-06-26 20:59:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void wxTextCtrlBase::SelectAll()
|
|
|
|
{
|
|
|
|
SetSelection(0, GetLastPosition());
|
|
|
|
}
|
|
|
|
|
2001-11-14 03:50:11 +00:00
|
|
|
wxString wxTextCtrlBase::GetStringSelection() const
|
2001-11-14 01:27:16 +00:00
|
|
|
{
|
|
|
|
long from, to;
|
|
|
|
GetSelection(&from, &to);
|
|
|
|
|
2002-01-09 01:32:02 +00:00
|
|
|
return GetRange(from, to);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString wxTextCtrlBase::GetRange(long from, long to) const
|
|
|
|
{
|
2001-11-14 01:27:16 +00:00
|
|
|
wxString sel;
|
|
|
|
if ( from < to )
|
|
|
|
{
|
|
|
|
sel = GetValue().Mid(from, to - from);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sel;
|
|
|
|
}
|
|
|
|
|
2003-07-09 10:15:21 +00:00
|
|
|
// do the window-specific processing after processing the update event
|
|
|
|
void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
|
|
|
|
{
|
|
|
|
if ( event.GetSetEnabled() )
|
|
|
|
Enable(event.GetEnabled());
|
|
|
|
|
|
|
|
if ( event.GetSetText() )
|
|
|
|
{
|
|
|
|
if ( event.GetText() != GetValue() )
|
|
|
|
SetValue(event.GetText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-04 14:56:14 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// hit testing
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
wxTextCtrlHitTestResult
|
|
|
|
wxTextCtrlBase::HitTest(const wxPoint& WXUNUSED(pt),
|
|
|
|
wxTextCoord * WXUNUSED(col),
|
|
|
|
wxTextCoord * WXUNUSED(row)) const
|
|
|
|
{
|
|
|
|
// not implemented
|
|
|
|
return wxTE_HT_UNKNOWN;
|
|
|
|
}
|
2003-07-09 10:15:21 +00:00
|
|
|
|
2001-07-31 17:56:45 +00:00
|
|
|
#else // !wxUSE_TEXTCTRL
|
|
|
|
|
|
|
|
// define this one even if !wxUSE_TEXTCTRL because it is also used by other
|
|
|
|
// controls (wxComboBox and wxSpinCtrl)
|
|
|
|
#include "wx/event.h"
|
|
|
|
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED)
|
|
|
|
|
|
|
|
#endif // wxUSE_TEXTCTRL/!wxUSE_TEXTCTRL
|
2001-06-26 20:59:19 +00:00
|
|
|
|