implemented HitTest() for GTK2; test it in the sample

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28430 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-07-23 18:07:40 +00:00
parent e38c6b5fc7
commit 692c9b8696
9 changed files with 109 additions and 9 deletions

View File

@@ -1057,6 +1057,36 @@ void wxTextCtrl::ShowPosition( long pos )
}
}
#ifdef __WXGTK20__
wxTextCtrlHitTestResult
wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const
{
if ( !IsMultiLine() )
{
// not supported
return wxTE_HT_UNKNOWN;
}
int x, y;
gtk_text_view_window_to_buffer_coords
(
GTK_TEXT_VIEW(m_text),
GTK_TEXT_WINDOW_TEXT,
pt.x, pt.y,
&x, &y
);
GtkTextIter iter;
gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(m_text), &iter, x, y);
if ( pos )
*pos = gtk_text_iter_get_offset(&iter);
return wxTE_HT_ON_TEXT;
}
#endif // __WXGTK20__
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );