Implement subitem for wxGenericListCtrl::HitTest()

This commit is contained in:
Lauri Nurmi
2025-02-10 13:17:46 +02:00
parent 1ada0f511a
commit 580df3d670
2 changed files with 22 additions and 4 deletions
+4 -3
View File
@@ -905,9 +905,10 @@ public:
If @a ptrSubItem is not @NULL and the wxListCtrl is in the report
mode the subitem (or column) number will also be provided.
This feature is only available in version 2.7.0 or higher and is currently only
implemented under wxMSW and requires at least comctl32.dll of version 4.70 on
the host system or the value stored in @a ptrSubItem will be always -1.
This feature is available since version 3.2.7 in the generic control;
in earlier versions the value stored in @a ptrSubItem will be always -1.
Under wxMSW, the feature is available since version 2.7.0, and requires
at least comctl32.dll of version 4.70 on the host system.
To compile this feature into wxWidgets library you need to have access to
commctrl.h of version 4.70 that is provided by Microsoft.
+18 -1
View File
@@ -5482,9 +5482,26 @@ long wxGenericListCtrl::FindItem( long WXUNUSED(start), const wxPoint& pt,
long wxGenericListCtrl::HitTest(const wxPoint& point, int& flags, long *col) const
{
// TODO: sub item hit testing
if ( col )
{
*col = -1;
if ( InReportView() )
{
const wxPoint unscrolled = CalcUnscrolledPosition( point );
for ( int c = 0, wsum = 0, cols = GetColumnCount();
c < cols;
++c )
{
wsum += GetColumnWidth(c);
if ( wsum > unscrolled.x )
{
*col = c;
break;
}
}
}
}
return m_mainWin->HitTest( (int)point.x, (int)point.y, flags );
}