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:
@@ -226,16 +226,17 @@ Unix:
|
|||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
- wxGTK uses GTK+ 2.x by default now, you have to pass --disable-gtk2 to
|
||||||
|
configure if you want to use GTK+ 1.2
|
||||||
- fixed many rendering artifacts and wrong colours with lots of GTK+ themes
|
- fixed many rendering artifacts and wrong colours with lots of GTK+ themes
|
||||||
- implemented wxColourDialog as native dialog
|
- implemented wxColourDialog as native dialog
|
||||||
|
- implemented wxTextCtrl::HitTest() (GTK+ >= 2)
|
||||||
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
|
- wxTreeCtrl::GetCount() counts root as well now (compatible with MSW)
|
||||||
- added support for wxCHK_3STATE style (GTK2 only)
|
- added support for wxCHK_3STATE style (GTK2 only)
|
||||||
- implemented text underlining under GTK2
|
- implemented text underlining under GTK2
|
||||||
- implemented wxFRAME_NO_TASKBAR style (GTK >= 2.2)
|
- implemented wxFRAME_NO_TASKBAR style (GTK >= 2.2)
|
||||||
- implemented support for wxSYS_DCLICK_?, wxSYS_DRAG_? and wxSYS_CURSOR_?
|
- implemented support for wxSYS_DCLICK_?, wxSYS_DRAG_? and wxSYS_CURSOR_?
|
||||||
in wxSystemSettings::GetMetric (Mart Raudsepp)
|
in wxSystemSettings::GetMetric (Mart Raudsepp)
|
||||||
- wxGTK uses GTK+ 2.x by default now, you have to pass --disable-gtk2 to
|
|
||||||
configure if you want to use GTK+ 1.2
|
|
||||||
- implemented wxTopLevel::IsMaximized() for GTK+2 and WMs that implement
|
- implemented wxTopLevel::IsMaximized() for GTK+2 and WMs that implement
|
||||||
freedesktop.org's wm-spec (Mart Raudsepp)
|
freedesktop.org's wm-spec (Mart Raudsepp)
|
||||||
|
|
||||||
|
@@ -825,8 +825,8 @@ pixels. If the return code is not \texttt{wxTE\_HT\_UNKNOWN} the row and column
|
|||||||
of the character closest to this position are returned in the \arg{col} and
|
of the character closest to this position are returned in the \arg{col} and
|
||||||
\arg{row} parameters (unless the pointers are {\tt NULL} which is allowed).
|
\arg{row} parameters (unless the pointers are {\tt NULL} which is allowed).
|
||||||
|
|
||||||
Please note that this function is currently only implemented in wxUniv and
|
Please note that this function is currently only implemented in wxUniv,
|
||||||
wxMSW ports.
|
wxMSW and wxGTK2 ports.
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
|
@@ -330,6 +330,7 @@ public:
|
|||||||
//
|
//
|
||||||
// NB: pt is in device coords (not adjusted for the client area origin nor
|
// NB: pt is in device coords (not adjusted for the client area origin nor
|
||||||
// scrolling)
|
// scrolling)
|
||||||
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
|
||||||
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
||||||
wxTextCoord *col,
|
wxTextCoord *col,
|
||||||
wxTextCoord *row) const;
|
wxTextCoord *row) const;
|
||||||
|
@@ -191,6 +191,7 @@ public:
|
|||||||
void RemoveSelection();
|
void RemoveSelection();
|
||||||
wxString GetSelectionText() const;
|
wxString GetSelectionText() const;
|
||||||
|
|
||||||
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
|
||||||
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
||||||
wxTextCoord *col,
|
wxTextCoord *col,
|
||||||
wxTextCoord *row) const;
|
wxTextCoord *row) const;
|
||||||
|
@@ -662,15 +662,24 @@ void MyTextCtrl::OnMouseEvent(wxMouseEvent& ev)
|
|||||||
msg = GetMouseEventDesc(ev);
|
msg = GetMouseEventDesc(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg << _T(" at (") << ev.GetX() << _T(", ") << ev.GetY() << _T(") ")
|
msg << _T(" at (") << ev.GetX() << _T(", ") << ev.GetY() << _T(") ");
|
||||||
<< _T("Flags: ")
|
|
||||||
|
long pos;
|
||||||
|
wxTextCtrlHitTestResult rc = HitTest(ev.GetPosition(), &pos);
|
||||||
|
if ( rc != wxTE_HT_UNKNOWN )
|
||||||
|
{
|
||||||
|
msg << _T("at position ") << pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg << _T("[Flags: ")
|
||||||
<< GetChar( ev.LeftIsDown(), _T('1') )
|
<< GetChar( ev.LeftIsDown(), _T('1') )
|
||||||
<< GetChar( ev.MiddleIsDown(), _T('2') )
|
<< GetChar( ev.MiddleIsDown(), _T('2') )
|
||||||
<< GetChar( ev.RightIsDown(), _T('3') )
|
<< GetChar( ev.RightIsDown(), _T('3') )
|
||||||
<< GetChar( ev.ControlDown(), _T('C') )
|
<< GetChar( ev.ControlDown(), _T('C') )
|
||||||
<< GetChar( ev.AltDown(), _T('A') )
|
<< GetChar( ev.AltDown(), _T('A') )
|
||||||
<< GetChar( ev.ShiftDown(), _T('S') )
|
<< GetChar( ev.ShiftDown(), _T('S') )
|
||||||
<< GetChar( ev.MetaDown(), _T('M') );
|
<< GetChar( ev.MetaDown(), _T('M') )
|
||||||
|
<< _T(']');
|
||||||
|
|
||||||
wxLogMessage(msg);
|
wxLogMessage(msg);
|
||||||
}
|
}
|
||||||
|
@@ -495,10 +495,26 @@ void wxTextCtrlBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
|
|||||||
// hit testing
|
// hit testing
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxTextCtrlHitTestResult
|
||||||
|
wxTextCtrlBase::HitTest(const wxPoint& pt, wxTextCoord *x, wxTextCoord *y) const
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
wxTextCtrlHitTestResult
|
wxTextCtrlHitTestResult
|
||||||
wxTextCtrlBase::HitTest(const wxPoint& WXUNUSED(pt),
|
wxTextCtrlBase::HitTest(const wxPoint& WXUNUSED(pt),
|
||||||
wxTextCoord * WXUNUSED(col),
|
long * WXUNUSED(pos)) const
|
||||||
wxTextCoord * WXUNUSED(row)) const
|
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return wxTE_HT_UNKNOWN;
|
return wxTE_HT_UNKNOWN;
|
||||||
|
@@ -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
|
long wxTextCtrl::GetInsertionPoint() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
|
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
|
||||||
|
@@ -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
|
long wxTextCtrl::GetInsertionPoint() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
|
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
|
||||||
|
@@ -2952,6 +2952,18 @@ wxTextCtrlHitTestResult wxTextCtrl::HitTestLine(const wxString& line,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxTextCtrlHitTestResult wxTextCtrl::HitTest(const wxPoint& pt, long *pos) const
|
||||||
|
{
|
||||||
|
wxTextCoord x, y;
|
||||||
|
wxTextCtrlHitTestResult rc = HitTest(pt, &x, &y);
|
||||||
|
if ( rc != wxTE_HT_UNKNOWN && pos )
|
||||||
|
{
|
||||||
|
*pos = XYToPosition(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
wxTextCtrlHitTestResult wxTextCtrl::HitTest(const wxPoint& pos,
|
wxTextCtrlHitTestResult wxTextCtrl::HitTest(const wxPoint& pos,
|
||||||
wxTextCoord *colOut,
|
wxTextCoord *colOut,
|
||||||
wxTextCoord *rowOut) const
|
wxTextCoord *rowOut) const
|
||||||
|
Reference in New Issue
Block a user