#include "wx/dynarray.h"
#include "wx/log.h"
#include "wx/app.h"
+ #include "wx/settings.h"
#endif
#include "wx/msw/private.h"
#define wxUSE_COMCTL32_SAFELY 0
#include "wx/imaglist.h"
-#include "wx/settings.h"
#include "wx/msw/dragimag.h"
// macros to hide the cast ugliness
{
public:
wxTreeItemParam()
- : m_item(NULL),
+ : m_item((long int)0),
m_data(NULL)
{
for ( size_t n = 0; n < WXSIZEOF(m_images); n++ )
return;
data->SetImage(image, which);
+
+ RefreshItem(item);
}
wxTreeItemParam *wxTreeCtrl::GetItemParam(const wxTreeItemId& item) const
if ( TreeView_Expand(GetHwnd(), HITEM(item), flag) != 0 )
{
- wxTreeEvent event(wxEVT_NULL, m_windowId);
- event.m_item = item;
- event.SetEventObject(this);
-
// note that the {EXPAND|COLLAPS}ING event is sent by TreeView_Expand()
// itself
- event.SetEventType(gs_expandEvents[IsExpanded(item) ? IDX_EXPAND
- : IDX_COLLAPSE]
- [IDX_DONE]);
-
+ wxTreeEvent event(gs_expandEvents[IsExpanded(item) ? IDX_EXPAND
+ : IDX_COLLAPSE]
+ [IDX_DONE],
+ this, item);
(void)GetEventHandler()->ProcessEvent(event);
}
//else: change didn't took place, so do nothing at all
// the notification from the control (i.e. TVN_SELCHANG{ED|ING}), so
// send them ourselves
- wxTreeEvent event(wxEVT_NULL, m_windowId);
- event.m_item = item;
- event.SetEventObject(this);
-
- event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGING);
+ wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
{
if ( !TreeView_SelectItem(GetHwnd(), HITEM(item)) )
DeleteTextCtrl();
}
-wxTreeItemId wxTreeCtrl::DoTreeHitTest(const wxPoint& point, int& flags)
+wxTreeItemId wxTreeCtrl::DoTreeHitTest(const wxPoint& point, int& flags) const
{
TV_HITTESTINFO hitTestInfo;
hitTestInfo.pt.x = (int)point.x;
// implementation
// ----------------------------------------------------------------------------
+bool wxTreeCtrl::MSWShouldPreProcessMessage(WXMSG* msg)
+{
+ if ( msg->message == WM_KEYDOWN )
+ {
+ if ( msg->wParam == VK_RETURN )
+ {
+ // we need VK_RETURN to generate wxEVT_COMMAND_TREE_ITEM_ACTIVATED
+ return false;
+ }
+ }
+
+ return wxTreeCtrlBase::MSWShouldPreProcessMessage(msg);
+}
+
bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id)
{
if ( cmd == EN_UPDATE )
// Convert the screen point to a client point
wxPoint MenuPoint = ScreenToClient(wxPoint(x, y));
- wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_MENU, GetId() );
-
// can't use GetSelection() here as it would assert in multiselect mode
- event.m_item = wxTreeItemId(TreeView_GetSelection(GetHwnd()));
- event.SetEventObject( this );
+ wxTreeEvent event(wxEVT_COMMAND_TREE_ITEM_MENU, this,
+ wxTreeItemId(TreeView_GetSelection(GetHwnd())));
// Get the bounding rectangle for the item, including the non-text areas
wxRect ItemRect;
m_dragImage = NULL;
// generate the drag end event
- wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, m_windowId);
-
- event.m_item = htItem;
- event.m_pointDrag = wxPoint(x, y);
- event.SetEventObject(this);
-
+ wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, this, htItem);
(void)GetEventHandler()->ProcessEvent(event);
// if we don't do it, the tree seems to think that 2 items
// process WM_NOTIFY Windows message
bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{
- wxTreeEvent event(wxEVT_NULL, m_windowId);
+ wxTreeEvent event(wxEVT_NULL, this);
wxEventType eventType = wxEVT_NULL;
NMHDR *hdr = (NMHDR *)lParam;
if ( !wxIsCtrlDown() && !wxIsShiftDown() && !isAltDown &&
((info->wVKey == VK_SPACE) || (info->wVKey == VK_RETURN)) )
{
- wxTreeEvent event2(wxEVT_COMMAND_TREE_ITEM_ACTIVATED,
- m_windowId);
- event2.SetEventObject(this);
- if ( !(GetWindowStyle() & wxTR_MULTIPLE) )
- {
- event2.m_item = GetSelection();
- }
- //else: don't know how to get it
+ wxTreeItemId item;
+ if ( !HasFlag(wxTR_MULTIPLE) )
+ item = GetSelection();
- (void)GetEventHandler()->ProcessEvent(event2);
+ wxTreeEvent event2(wxEVT_COMMAND_TREE_ITEM_ACTIVATED,
+ this, item);
+ (void)GetEventHandler()->ProcessEvent(event2);
}
}
break;
wxTreeItemAttr * const attr = it->second;
+ wxTreeViewItem tvItem((void *)nmcd.dwItemSpec,
+ TVIF_STATE, TVIS_DROPHILITED);
+ DoGetItem(&tvItem);
+ const UINT tvItemState = tvItem.state;
+
// selection colours should override ours,
- // otherwise it is too confusing ot the user
- if ( !(nmcd.uItemState & CDIS_SELECTED) )
+ // otherwise it is too confusing to the user
+ if ( !(nmcd.uItemState & CDIS_SELECTED) &&
+ !(tvItemState & TVIS_DROPHILITED) )
{
wxColour colBack;
if ( attr->HasBackgroundColour() )
// colour when we don't have focus (we can't keep
// it when we do, it would usually be unreadable on
// the almost inverted bg colour...)
- if ( !(nmcd.uItemState & CDIS_SELECTED) ||
- FindFocus() != this )
+ if ( ( !(nmcd.uItemState & CDIS_SELECTED) ||
+ FindFocus() != this ) &&
+ !(tvItemState & TVIS_DROPHILITED) )
{
wxColour colText;
if ( attr->HasTextColour() )
return wxControl::MSWOnNotify(idCtrl, lParam, result);
}
- event.SetEventObject(this);
event.SetEventType(eventType);
+ if ( event.m_item.IsOk() )
+ event.SetClientObject(GetItemData(event.m_item));
+
bool processed = GetEventHandler()->ProcessEvent(event);
// post processing