implemented EVT_LIST_ITEM_FOCUSED() for Win32 wxListCtrl
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12454 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: listctrl.cpp
|
// Name: src/msw/listctrl.cpp
|
||||||
// Purpose: wxListCtrl
|
// Purpose: wxListCtrl
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -1486,6 +1486,8 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
wxListEvent event(wxEVT_NULL, m_windowId);
|
wxListEvent event(wxEVT_NULL, m_windowId);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
|
||||||
wxEventType eventType = wxEVT_NULL;
|
wxEventType eventType = wxEVT_NULL;
|
||||||
|
|
||||||
NMHDR *nmhdr = (NMHDR *)lParam;
|
NMHDR *nmhdr = (NMHDR *)lParam;
|
||||||
@@ -1655,22 +1657,52 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LVN_ITEMCHANGED:
|
case LVN_ITEMCHANGED:
|
||||||
// This needs to be sent to wxListCtrl as a rather more concrete
|
// we translate this catch all message into more interesting
|
||||||
// event. For now, just detect a selection or deselection.
|
// (and more easy to process) wxWindows events
|
||||||
if ( (nmLV->uNewState & LVIS_SELECTED) && !(nmLV->uOldState & LVIS_SELECTED) )
|
|
||||||
|
// first of all, we deal with the state change events only
|
||||||
|
if ( nmLV->uChanged & LVIF_STATE )
|
||||||
{
|
{
|
||||||
eventType = wxEVT_COMMAND_LIST_ITEM_SELECTED;
|
// temp vars for readability
|
||||||
event.m_itemIndex = nmLV->iItem;
|
const UINT stOld = nmLV->uOldState;
|
||||||
|
const UINT stNew = nmLV->uNewState;
|
||||||
|
|
||||||
|
// has the focus changed?
|
||||||
|
if ( !(stOld & LVIS_FOCUSED) && (stNew & LVIS_FOCUSED) )
|
||||||
|
{
|
||||||
|
eventType = wxEVT_COMMAND_LIST_ITEM_FOCUSED;
|
||||||
|
event.m_itemIndex = nmLV->iItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (stNew & LVIS_SELECTED) != (stOld & LVIS_SELECTED) )
|
||||||
|
{
|
||||||
|
if ( eventType != wxEVT_NULL )
|
||||||
|
{
|
||||||
|
// focus and selection have both changed: send the
|
||||||
|
// focus event from here and the selection one
|
||||||
|
// below
|
||||||
|
event.SetEventType(eventType);
|
||||||
|
(void)GetEventHandler()->ProcessEvent(event);
|
||||||
|
}
|
||||||
|
else // no focus event to send
|
||||||
|
{
|
||||||
|
// then need to set m_itemIndex as it wasn't done
|
||||||
|
// above
|
||||||
|
event.m_itemIndex = nmLV->iItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
eventType = stNew & LVIS_SELECTED
|
||||||
|
? wxEVT_COMMAND_LIST_ITEM_SELECTED
|
||||||
|
: wxEVT_COMMAND_LIST_ITEM_DESELECTED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( !(nmLV->uNewState & LVIS_SELECTED) && (nmLV->uOldState & LVIS_SELECTED) )
|
|
||||||
{
|
if ( eventType == wxEVT_NULL )
|
||||||
eventType = wxEVT_COMMAND_LIST_ITEM_DESELECTED;
|
|
||||||
event.m_itemIndex = nmLV->iItem;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
// not an interesting event for us
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LVN_KEYDOWN:
|
case LVN_KEYDOWN:
|
||||||
@@ -1838,7 +1870,6 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
// process the event
|
// process the event
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
event.SetEventObject( this );
|
|
||||||
event.SetEventType(eventType);
|
event.SetEventType(eventType);
|
||||||
|
|
||||||
if ( !GetEventHandler()->ProcessEvent(event) )
|
if ( !GetEventHandler()->ProcessEvent(event) )
|
||||||
|
Reference in New Issue
Block a user