#undef GetNextSibling
#endif
-#include "wx/treectrl.h"
+#include "wx/msw/treectrl.h"
// Bug in headers, sometimes
#ifndef TVIS_FOCUSED
DoSetItem(&tvItem);
}
+void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold)
+{
+ wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_BOLD);
+ tvItem.state = bold ? TVIS_BOLD : 0;
+ DoSetItem(&tvItem);
+}
+
// ----------------------------------------------------------------------------
// Item status
// ----------------------------------------------------------------------------
bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const
{
+ // Bug in Gnu-Win32 headers, so don't use the macro TreeView_GetItemRect
RECT rect;
-// return (TreeView_GetItemRect(wxhWnd, (HTREEITEM) (WXHTREEITEM)item, &rect, FALSE) != 0);
- // Bug in Gnu-Win32 headers, so don't use the macro.
- return (SendMessage((wxhWnd), TVM_GETITEMRECT, (WPARAM) FALSE, (LPARAM) & rect) != 0);
+ return SendMessage(wxhWnd, TVM_GETITEMRECT, FALSE, (LPARAM)&rect) != 0;
}
return (tvItem.state & TVIS_SELECTED) != 0;
}
+bool wxTreeCtrl::IsBold(const wxTreeItemId& item) const
+{
+ wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_BOLD);
+ DoGetItem(&tvItem);
+
+ return (tvItem.state & TVIS_BOLD) != 0;
+}
+
// ----------------------------------------------------------------------------
// navigation
// ----------------------------------------------------------------------------
wxLogLastError("TreeView_InsertItem");
}
+ if ( data != NULL )
+ {
+ // associate the application tree item with Win32 tree item handle
+ data->SetId((WXHTREEITEM)id);
+ }
+
return wxTreeItemId((WXHTREEITEM)id);
}
void wxTreeCtrl::Delete(const wxTreeItemId& item)
{
- wxTreeItemData *data = GetItemData(item);
- if(data!=NULL)
- delete data; // may be NULL, ok
-
if ( !TreeView_DeleteItem(wxhWnd, (HTREEITEM)(WXHTREEITEM)item) )
{
wxLogLastError("TreeView_DeleteItem");
}
}
+// TODO
+size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, bool recursively)
+{
+ return 0;
+}
+
// ----------------------------------------------------------------------------
// implementation
// ----------------------------------------------------------------------------
}
// process WM_NOTIFY Windows message
-bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
+bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result)
{
wxTreeEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
}
default:
- return wxControl::MSWNotify(wParam, lParam);
+ return wxControl::MSWNotify(wParam, lParam, result);
}
event.SetEventObject(this);
event.SetEventType(eventType);
- bool rc = GetEventHandler()->ProcessEvent(event);
+ bool processed = GetEventHandler()->ProcessEvent(event);
// post processing
- switch ( hdr->code )
+ if ( hdr->code == TVN_DELETEITEM )
{
// NB: we might process this message using wxWindows event tables, but
// due to overhead of wxWin event system we prefer to do it here
// (otherwise deleting a tree with many items is just too slow)
- case TVN_DELETEITEM:
- {
- NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam;
- wxTreeItemData *data = (wxTreeItemData *)tv->itemOld.lParam;
- delete data; // may be NULL, ok
- }
- break;
-
- case TVN_ITEMEXPANDING:
- // if user called Veto(), don't allow expansion/collapse by
- // returning TRUE from here
- rc = event.m_code != 0;
- break;
+ NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam;
+ wxTreeItemData *data = (wxTreeItemData *)tv->itemOld.lParam;
+ delete data; // may be NULL, ok
}
- return rc;
+ *result = !event.IsAllowed();
+
+ return processed;
}
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent)
wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
- : wxCommandEvent(commandType, id)
+ : wxNotifyEvent(commandType, id)
{
m_code = 0;
m_itemOld = 0;