Adjust rectangle coordinates returned by wxDataViewCtrl::GetItemRect()
Because query for item rectangle is executed in the context of wxDataViewCtrl so coordinates of retrieved rectangle should be specified in wxDataViewCtrl client coordinates (not in wxDataViewMainWindow coordinates). To return correct coordinates it is necessary to convert rectangle coordinates retrieved by wxDataViewMainWindow::GetItemRect() from wxDataViewMainWindow client coordinates to wxDataViewCtrl client coordinates (they can different due to the presence of the header in wxDataViewCtrl client area).
This commit is contained in:
@@ -108,6 +108,7 @@ All (GUI):
|
|||||||
- Fix retrieving bounding box for wxDC with transformed coordinates.
|
- Fix retrieving bounding box for wxDC with transformed coordinates.
|
||||||
- Fix wxGraphicsMatrixData::Concat() for Direct2D and Cairo renderers.
|
- Fix wxGraphicsMatrixData::Concat() for Direct2D and Cairo renderers.
|
||||||
- Fix calculating point position in wxDataViewCtrl::HitTest().
|
- Fix calculating point position in wxDataViewCtrl::HitTest().
|
||||||
|
- Fix position of the rectangle returned by wxDataViewCtrl::GetItemRect().
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -1395,11 +1395,8 @@ public:
|
|||||||
int GetIndent() const;
|
int GetIndent() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns item rectangle.
|
Returns item rectangle. Coordinates of the rectangle are specified in
|
||||||
|
wxDataViewCtrl client area coordinates.
|
||||||
This method is currently not implemented at all in wxGTK and only
|
|
||||||
implemented for non-@NULL @a col argument in wxOSX. It is fully
|
|
||||||
implemented in the generic version of the control.
|
|
||||||
|
|
||||||
@param item
|
@param item
|
||||||
A valid item.
|
A valid item.
|
||||||
@@ -1407,6 +1404,10 @@ public:
|
|||||||
If non-@NULL, the rectangle returned corresponds to the
|
If non-@NULL, the rectangle returned corresponds to the
|
||||||
intersection of the item with the specified column. If @NULL, the
|
intersection of the item with the specified column. If @NULL, the
|
||||||
rectangle spans all the columns.
|
rectangle spans all the columns.
|
||||||
|
|
||||||
|
@note This method is currently not implemented at all in wxGTK and only
|
||||||
|
implemented for non-@NULL @a col argument in wxOSX. It is fully
|
||||||
|
implemented in the generic version of the control.
|
||||||
*/
|
*/
|
||||||
virtual wxRect GetItemRect(const wxDataViewItem& item,
|
virtual wxRect GetItemRect(const wxDataViewItem& item,
|
||||||
const wxDataViewColumn* col = NULL) const;
|
const wxDataViewColumn* col = NULL) const;
|
||||||
|
@@ -5349,7 +5349,12 @@ void wxDataViewCtrl::HitTest( const wxPoint & point, wxDataViewItem & item,
|
|||||||
wxRect wxDataViewCtrl::GetItemRect( const wxDataViewItem & item,
|
wxRect wxDataViewCtrl::GetItemRect( const wxDataViewItem & item,
|
||||||
const wxDataViewColumn* column ) const
|
const wxDataViewColumn* column ) const
|
||||||
{
|
{
|
||||||
return m_clientArea->GetItemRect(item, column);
|
// Convert position from the main window coordinates to the control coordinates.
|
||||||
|
// (They can be different due to the presence of the header.).
|
||||||
|
wxRect r = m_clientArea->GetItemRect(item, column);
|
||||||
|
const wxPoint ctrlPos = ScreenToClient(m_clientArea->ClientToScreen(r.GetPosition()));
|
||||||
|
r.SetPosition(ctrlPos);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewItem wxDataViewCtrl::GetItemByRow( unsigned int row ) const
|
wxDataViewItem wxDataViewCtrl::GetItemByRow( unsigned int row ) const
|
||||||
|
Reference in New Issue
Block a user