fix for scrolling in checklistboxes (Win32 only)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1972 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -226,10 +226,24 @@ void wxCheckListBoxItem::Check(bool check)
|
|||||||
m_nIndex = (size_t)index;
|
m_nIndex = (size_t)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nHeight = m_pParent->GetItemHeight();
|
HWND hwndListbox = (HWND)m_pParent->GetHWND();
|
||||||
size_t y = m_nIndex * nHeight;
|
|
||||||
RECT rcUpdate = { 0, y, GetDefaultMarginWidth(), y + nHeight};
|
#ifdef __WIN32__
|
||||||
InvalidateRect((HWND)m_pParent->GetHWND(), &rcUpdate, FALSE);
|
RECT rcUpdate;
|
||||||
|
|
||||||
|
if ( ::SendMessage(hwndListbox, LB_GETITEMRECT,
|
||||||
|
m_nIndex, (LPARAM)&rcUpdate) == LB_ERR )
|
||||||
|
{
|
||||||
|
wxLogDebug("LB_GETITEMRECT failed");
|
||||||
|
}
|
||||||
|
#else // Win16
|
||||||
|
// FIXME this doesn't work if the listbox is scrolled!
|
||||||
|
size_t nHeight = m_pParent->GetItemHeight();
|
||||||
|
size_t y = m_nIndex * nHeight;
|
||||||
|
RECT rcUpdate = { 0, y, GetDefaultMarginWidth(), y + nHeight};
|
||||||
|
#endif // Win32/16
|
||||||
|
|
||||||
|
InvalidateRect(hwndListbox, &rcUpdate, FALSE);
|
||||||
|
|
||||||
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId());
|
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, m_pParent->GetId());
|
||||||
event.SetInt(m_nIndex);
|
event.SetInt(m_nIndex);
|
||||||
@@ -357,8 +371,19 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& event)
|
|||||||
{
|
{
|
||||||
// clicking on the item selects it, clicking on the checkmark toggles
|
// clicking on the item selects it, clicking on the checkmark toggles
|
||||||
if ( event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) {
|
if ( event.GetX() <= wxOwnerDrawn::GetDefaultMarginWidth() ) {
|
||||||
// FIXME better use LB_ITEMFROMPOINT perhaps?
|
#ifdef __WIN32__
|
||||||
size_t nItem = ((size_t)event.GetY()) / m_nItemHeight;
|
size_t nItem = (size_t)::SendMessage
|
||||||
|
(
|
||||||
|
(HWND)GetHWND(),
|
||||||
|
LB_ITEMFROMPOINT,
|
||||||
|
0,
|
||||||
|
MAKELPARAM(event.GetX(), event.GetY())
|
||||||
|
);
|
||||||
|
#else // Win16
|
||||||
|
// FIXME this doesn't work when the listbox is scrolled!
|
||||||
|
size_t nItem = ((size_t)event.GetY()) / m_nItemHeight;
|
||||||
|
#endif // Win32/16
|
||||||
|
|
||||||
if ( nItem < (size_t)m_noItems )
|
if ( nItem < (size_t)m_noItems )
|
||||||
GetItem(nItem)->Toggle();
|
GetItem(nItem)->Toggle();
|
||||||
//else: it's not an error, just click outside of client zone
|
//else: it's not an error, just click outside of client zone
|
||||||
|
Reference in New Issue
Block a user