1999-07-14 22:55:57 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-04-27 12:47:14 +00:00
|
|
|
// Name: src/common/textcmn.cpp
|
1999-07-14 22:55:57 +00:00
|
|
|
// 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
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-07-14 22:55:57 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
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
|
|
|
|
|
2006-04-27 12:47:14 +00:00
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/event.h"
|
|
|
|
#endif // WX_PRECOMP
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_TEXTCTRL
|
|
|
|
|
2006-04-27 12:47:14 +00:00
|
|
|
#include "wx/textctrl.h"
|
|
|
|
|
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
|
|
|
#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
|
|
|
|
2006-07-02 07:41:02 +00:00
|
|
|
IMPLEMENT_ABSTRACT_CLASS(wxTextCtrlBase, wxControl)
|
|
|
|
|
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);
|
2004-09-23 18:20:56 +00:00
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
if (attr.HasAlignment())
|
|
|
|
newAttr.SetAlignment(attr.GetAlignment());
|
|
|
|
else if (attrDef.HasAlignment())
|
|
|
|
newAttr.SetAlignment(attrDef.GetAlignment());
|
2004-09-23 18:20:56 +00:00
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
if (attr.HasTabs())
|
|
|
|
newAttr.SetTabs(attr.GetTabs());
|
|
|
|
else if (attrDef.HasTabs())
|
|
|
|
newAttr.SetTabs(attrDef.GetTabs());
|
2004-09-23 18:20:56 +00:00
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
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());
|
2004-09-23 18:20:56 +00:00
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
if (attr.HasRightIndent())
|
|
|
|
newAttr.SetRightIndent(attr.GetRightIndent());
|
|
|
|
else if (attrDef.HasRightIndent())
|
2004-09-23 18:20:56 +00:00
|
|
|
newAttr.SetRightIndent(attrDef.GetRightIndent());
|
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
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))
|
|
|
|
{
|
2007-09-26 00:30:22 +00:00
|
|
|
// to be implemented in derived classes
|
2004-09-23 18:20:56 +00:00
|
|
|
return false;
|
2001-05-27 03:28:28 +00:00
|
|
|
}
|
|
|
|
|
2003-06-20 16:25:31 +00:00
|
|
|
// get the styling at the given position
|
|
|
|
bool wxTextCtrlBase::GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style))
|
|
|
|
{
|
2007-09-26 00:30:22 +00:00
|
|
|
// to be implemented in derived classes
|
2004-09-23 18:20:56 +00:00
|
|
|
return false;
|
2003-06-20 16:25:31 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return true;
|
2001-05-27 03:28:28 +00:00
|
|
|
}
|
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// file IO functions
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2006-09-24 11:40:33 +00:00
|
|
|
bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
|
1999-07-14 22:55:57 +00:00
|
|
|
{
|
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;
|
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return true;
|
1999-07-14 22:55:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return false;
|
1999-07-14 22:55:57 +00:00
|
|
|
}
|
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
bool wxTextAreaBase::SaveFile(const wxString& filename, int fileType)
|
1999-07-14 22:55:57 +00:00
|
|
|
{
|
2005-01-19 16:25:34 +00:00
|
|
|
wxString filenameToUse = filename.empty() ? 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
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return false;
|
1999-07-14 22:55:57 +00:00
|
|
|
}
|
|
|
|
|
2006-09-24 11:40:33 +00:00
|
|
|
return DoSaveFile(filenameToUse, fileType);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
|
|
|
|
{
|
2001-06-26 20:59:19 +00:00
|
|
|
#if wxUSE_FFILE
|
2006-09-24 11:40:33 +00:00
|
|
|
wxFFile file(filename, _T("w"));
|
1999-07-14 22:55:57 +00:00
|
|
|
if ( file.IsOpened() && file.Write(GetValue()) )
|
|
|
|
{
|
2006-09-24 11:40:33 +00:00
|
|
|
// if it worked, save for future calls
|
|
|
|
m_filename = filename;
|
2006-10-08 22:40:14 +00:00
|
|
|
|
1999-07-14 22:55:57 +00:00
|
|
|
// it's not modified any longer
|
|
|
|
DiscardEdits();
|
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return true;
|
1999-07-14 22:55:57 +00:00
|
|
|
}
|
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."));
|
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return false;
|
1999-07-14 22:55:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2005-04-13 17:51:16 +00:00
|
|
|
#if wxHAS_TEXT_WINDOW_STREAM
|
1999-07-14 22:55:57 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-04-13 17:51:16 +00:00
|
|
|
#endif // wxHAS_TEXT_WINDOW_STREAM
|
1999-07-14 22:55:57 +00:00
|
|
|
|
2002-04-07 22:29:04 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// emulating key presses
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool wxTextCtrlBase::EmulateKeyPress(const wxKeyEvent& event)
|
|
|
|
{
|
2007-09-26 00:30:22 +00:00
|
|
|
// we have a native implementation for Win32 and so don't need this one
|
|
|
|
#ifndef __WIN32__
|
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:
|
2005-07-21 16:22:28 +00:00
|
|
|
ch = (wxChar)(_T('0') + keycode - WXK_NUMPAD0);
|
2002-04-07 22:29:04 +00:00
|
|
|
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
|
|
|
|
{
|
2005-01-19 16:25:34 +00:00
|
|
|
const long pos = GetInsertionPoint();
|
|
|
|
if ( pos < GetLastPosition() )
|
2003-01-02 00:07:13 +00:00
|
|
|
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:
|
2004-10-28 11:19:39 +00:00
|
|
|
#if wxUSE_UNICODE
|
|
|
|
if ( event.GetUnicodeKey() )
|
|
|
|
{
|
|
|
|
ch = event.GetUnicodeKey();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
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);
|
|
|
|
|
2004-09-23 18:20:56 +00:00
|
|
|
return true;
|
2002-04-07 22:29:04 +00:00
|
|
|
}
|
2007-09-26 00:39:04 +00:00
|
|
|
#else // __WIN32__
|
|
|
|
wxUnusedVar(event);
|
|
|
|
#endif // !__WIN32__/__WIN32__
|
2002-04-07 22:29:04 +00:00
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
return false;
|
2001-11-14 01:27:16 +00:00
|
|
|
}
|
|
|
|
|
2003-07-09 10:15:21 +00:00
|
|
|
// do the window-specific processing after processing the update event
|
|
|
|
void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
|
|
|
|
{
|
2006-02-12 16:32:50 +00:00
|
|
|
// call inherited, but skip the wxControl's version, and call directly the
|
|
|
|
// wxWindow's one instead, because the only reason why we are overriding this
|
|
|
|
// function is that we want to use SetValue() instead of wxControl::SetLabel()
|
|
|
|
wxWindowBase::DoUpdateWindowUI(event);
|
2004-09-23 18:20:56 +00:00
|
|
|
|
2006-02-12 16:32:50 +00:00
|
|
|
// update text
|
2003-07-09 10:15:21 +00:00
|
|
|
if ( event.GetSetText() )
|
|
|
|
{
|
|
|
|
if ( event.GetText() != GetValue() )
|
|
|
|
SetValue(event.GetText());
|
2004-09-23 18:20:56 +00:00
|
|
|
}
|
2003-07-09 10:15:21 +00:00
|
|
|
}
|
|
|
|
|
2004-02-04 14:56:14 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// hit testing
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2004-07-23 18:07:40 +00:00
|
|
|
wxTextCtrlHitTestResult
|
2007-09-26 00:30:22 +00:00
|
|
|
wxTextAreaBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const
|
2004-07-23 18:07:40 +00:00
|
|
|
{
|
|
|
|
// implement in terms of the other overload as the native ports typically
|
|
|
|
// can get the position and not (x, y) pair directly (although wxUniv
|
|
|
|
// directly gets x and y -- and so overrides this method as well)
|
|
|
|
long pos;
|
|
|
|
wxTextCtrlHitTestResult rc = HitTest(pt, &pos);
|
|
|
|
|
|
|
|
if ( rc != wxTE_HT_UNKNOWN )
|
|
|
|
{
|
|
|
|
PositionToXY(pos, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2004-02-04 14:56:14 +00:00
|
|
|
wxTextCtrlHitTestResult
|
2007-09-26 00:30:22 +00:00
|
|
|
wxTextAreaBase::HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(pos)) const
|
2004-02-04 14:56:14 +00:00
|
|
|
{
|
|
|
|
// not implemented
|
|
|
|
return wxTE_HT_UNKNOWN;
|
|
|
|
}
|
2003-07-09 10:15:21 +00:00
|
|
|
|
2006-10-08 22:40:14 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// events
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
/* static */
|
2007-09-26 16:48:46 +00:00
|
|
|
bool wxTextCtrlBase::SendTextUpdatedEvent(wxWindow *win)
|
2006-10-08 22:40:14 +00:00
|
|
|
{
|
2007-09-26 00:30:22 +00:00
|
|
|
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, win->GetId());
|
2006-10-08 22:40:14 +00:00
|
|
|
|
|
|
|
// do not do this as it could be very inefficient if the text control
|
|
|
|
// contains a lot of text and we're not using ref-counted wxString
|
|
|
|
// implementation -- instead, event.GetString() will query the control for
|
|
|
|
// its current text if needed
|
2007-09-26 00:30:22 +00:00
|
|
|
//event.SetString(win->GetValue());
|
2006-10-08 22:40:14 +00:00
|
|
|
|
2007-09-26 00:30:22 +00:00
|
|
|
event.SetEventObject(win);
|
2007-09-26 16:48:46 +00:00
|
|
|
return win->GetEventHandler()->ProcessEvent(event);
|
2006-10-08 22:40:14 +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)
|
|
|
|
|
|
|
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_UPDATED)
|
|
|
|
|
|
|
|
#endif // wxUSE_TEXTCTRL/!wxUSE_TEXTCTRL
|