added wxTextCtrl::HitTest(); implemented it for MSW

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25496 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-02-04 14:56:14 +00:00
parent 3e27ea5908
commit efe66bbc0e
7 changed files with 346 additions and 20 deletions

View File

@@ -208,6 +208,63 @@ private:
DECLARE_WIDGETS_PAGE(TextWidgetsPage)
};
// ----------------------------------------------------------------------------
// WidgetsTextCtrl
// ----------------------------------------------------------------------------
class WidgetsTextCtrl : public wxTextCtrl
{
public:
WidgetsTextCtrl(wxWindow *parent,
wxWindowID id,
const wxString& value,
int flags)
: wxTextCtrl(parent, id, value, wxDefaultPosition, wxDefaultSize, flags)
{
}
protected:
void OnRightClick(wxMouseEvent& event)
{
wxString where;
wxTextCoord x, y;
switch ( HitTest(event.GetPosition(), &x, &y) )
{
default:
wxFAIL_MSG( _T("unexpected HitTest() result") );
// fall through
case wxTE_HT_UNKNOWN:
x = y = -1;
where = _T("nowhere near");
break;
case wxTE_HT_BEFORE:
where = _T("before");
break;
case wxTE_HT_BELOW:
where = _T("below");
break;
case wxTE_HT_BEYOND:
where = _T("beyond");
break;
case wxTE_HT_ON_TEXT:
where = _T("at");
break;
}
wxLogMessage(_T("Mouse is %s (%ld, %ld)"), where.c_str(), x, y);
event.Skip();
}
private:
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// event tables
// ----------------------------------------------------------------------------
@@ -237,6 +294,10 @@ BEGIN_EVENT_TABLE(TextWidgetsPage, WidgetsPage)
EVT_RADIOBOX(wxID_ANY, TextWidgetsPage::OnCheckOrRadioBox)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(WidgetsTextCtrl, wxTextCtrl)
EVT_RIGHT_UP(WidgetsTextCtrl::OnRightClick)
END_EVENT_TABLE()
// ============================================================================
// implementation
// ============================================================================
@@ -552,10 +613,7 @@ void TextWidgetsPage::CreateText()
valueOld = _T("Hello, Universe!");
}
m_text = new wxTextCtrl(this, TextPage_Textctrl,
valueOld,
wxDefaultPosition, wxDefaultSize,
flags);
m_text = new WidgetsTextCtrl(this, TextPage_Textctrl, valueOld, flags);
// cast to int needed to silence gcc warning about different enums
m_sizerText->Add(m_text, 1, wxALL |