remove duplicated HitTest implementation from wxCheckListBox, it already inherits wxListBox::HitTest() (which was however lacking an overload taking 2 coordinates, added now)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-25 18:10:24 +00:00
parent 44e7bad0d4
commit 0a03dc7a13
4 changed files with 7 additions and 23 deletions

View File

@@ -91,8 +91,10 @@ public:
// event.GetExtraLong()) // event.GetExtraLong())
void Command(wxCommandEvent& event); void Command(wxCommandEvent& event);
// returns the item number at a point or wxNOT_FOUND // return the index of the item at this position or wxNOT_FOUND
int HitTest(const wxPoint& point) const { return DoListHitTest(point); } int HitTest(const wxPoint& point) const { return DoListHitTest(point); }
int HitTest(int x, int y) const { return DoListHitTest(wxPoint(x, y)); }
// For generating events in multiple and extended mode // For generating events in multiple and extended mode
wxArrayInt m_oldSelections; wxArrayInt m_oldSelections;

View File

@@ -64,10 +64,6 @@ public:
virtual bool IsChecked(unsigned int uiIndex) const; virtual bool IsChecked(unsigned int uiIndex) const;
virtual void Check(unsigned int uiIndex, bool bCheck = true); virtual void Check(unsigned int uiIndex, bool bCheck = true);
// return the index of the item at this position or wxNOT_FOUND
int HitTest(const wxPoint& pt) const { return DoHitTestItem(pt.x, pt.y); }
int HitTest(wxCoord x, wxCoord y) const { return DoHitTestItem(x, y); }
// accessors // accessors
size_t GetItemHeight() const { return m_nItemHeight; } size_t GetItemHeight() const { return m_nItemHeight; }
@@ -77,9 +73,6 @@ public:
virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item); virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *item);
protected: protected:
// this can't be called DoHitTest() because wxWindow already has this method
int DoHitTestItem(wxCoord x, wxCoord y) const;
// pressing space or clicking the check box toggles the item // pressing space or clicking the check box toggles the item
void OnKeyDown(wxKeyEvent& event); void OnKeyDown(wxKeyEvent& event);
void OnLeftClick(wxMouseEvent& event); void OnLeftClick(wxMouseEvent& event);

View File

@@ -171,6 +171,7 @@ public:
*/ */
virtual int GetSelections(wxArrayInt& selections) const; virtual int GetSelections(wxArrayInt& selections) const;
//@{
/** /**
Returns the item located at @a point, or @c wxNOT_FOUND if there Returns the item located at @a point, or @c wxNOT_FOUND if there
is no item located at @a point. is no item located at @a point.
@@ -186,6 +187,8 @@ public:
@since 2.7.0 @since 2.7.0
*/ */
int HitTest(const wxPoint& point) const; int HitTest(const wxPoint& point) const;
int HitTest(int x, int y) const;
//@}
/** /**
Insert the given number of strings before the specified position. Insert the given number of strings before the specified position.

View File

@@ -508,20 +508,6 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
} }
} }
int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const
{
int nItem = (int)::SendMessage
(
(HWND)GetHWND(),
LB_ITEMFROMPOINT,
0,
MAKELPARAM(x, y)
);
return nItem >= (int)m_noItems ? wxNOT_FOUND : nItem;
}
wxSize wxCheckListBox::DoGetBestSize() const wxSize wxCheckListBox::DoGetBestSize() const
{ {
wxSize best = wxListBox::DoGetBestSize(); wxSize best = wxListBox::DoGetBestSize();
@@ -530,4 +516,4 @@ wxSize wxCheckListBox::DoGetBestSize() const
return best; return best;
} }
#endif #endif // wxUSE_CHECKLISTBOX