m_imageListState = NULL;
}
-bool wxTreeCtrl::Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size,
- const long style, const wxValidator& validator, const wxString& name)
+bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style, const wxValidator& validator, const wxString& name)
{
wxSystemSettings settings;
SetBackgroundColour(settings.GetSystemColour(wxSYS_COLOUR_WINDOW));
TreeView_SetIndent((HWND) GetHWND(), indent);
}
-wxImageList *wxTreeCtrl::GetImageList(const int which) const
+wxImageList *wxTreeCtrl::GetImageList(int which) const
{
if ( which == wxIMAGE_LIST_NORMAL )
{
return NULL;
}
-void wxTreeCtrl::SetImageList(wxImageList *imageList, const int which)
+void wxTreeCtrl::SetImageList(wxImageList *imageList, int which)
{
int flags = 0;
if ( which == wxIMAGE_LIST_NORMAL )
TreeView_SetImageList((HWND) GetHWND(), (HIMAGELIST) imageList ? imageList->GetHIMAGELIST() : 0, flags);
}
-long wxTreeCtrl::GetNextItem(const long item, int code) const
+long wxTreeCtrl::GetNextItem(long item, int code) const
{
UINT flag = 0;
switch ( code )
return (long) TreeView_GetNextItem( (HWND) GetHWND(), (HTREEITEM) item, flag);
}
-bool wxTreeCtrl::ItemHasChildren(const long item) const
+bool wxTreeCtrl::ItemHasChildren(long item) const
{
TV_ITEM item2;
item2.hItem = (HTREEITEM) item;
return (item2.cChildren != 0);
}
-long wxTreeCtrl::GetChild(const long item) const
+long wxTreeCtrl::GetChild(long item) const
{
return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)item);
}
-long wxTreeCtrl::GetParent(const long item) const
+long wxTreeCtrl::GetParent(long item) const
{
return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)item);
}
return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_FIRSTVISIBLE, 0);
}
-long wxTreeCtrl::GetNextVisibleItem(const long item) const
+long wxTreeCtrl::GetNextVisibleItem(long item) const
{
return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_NEXTVISIBLE, (LPARAM)item);
}
return (long) ::SendMessage((HWND) GetHWND(), TVM_GETNEXTITEM, TVGN_ROOT, 0);
}
-// TODO: convert mask
bool wxTreeCtrl::GetItem(wxTreeItem& info) const
{
TV_ITEM tvItem;
tvItem.hItem = (HTREEITEM)info.m_itemId;
tvItem.pszText = NULL;
- tvItem.mask = 0;
+ tvItem.mask =
+ tvItem.stateMask = 0;
+
+ // TODO: convert other bits in the mask
if ( info.m_mask & wxTREE_MASK_TEXT )
{
tvItem.mask |= TVIF_TEXT;
}
if ( info.m_mask & wxTREE_MASK_DATA )
tvItem.mask |= TVIF_PARAM;
+ if ( info.m_stateMask & wxTREE_STATE_EXPANDED ) {
+ tvItem.mask |= TVIF_STATE;
+ tvItem.stateMask |= TVIS_EXPANDED;
+ }
bool success = TreeView_GetItem((HWND)GetHWND(), &tvItem) != 0;
return (::SendMessage((HWND) GetHWND(), TVM_SETITEM, 0, (LPARAM)&item) != 0);
}
-int wxTreeCtrl::GetItemState(const long item, const long stateMask) const
+int wxTreeCtrl::GetItemState(long item, long stateMask) const
{
wxTreeItem info;
return info.m_state;
}
-bool wxTreeCtrl::SetItemState(const long item, const long state, const long stateMask)
+bool wxTreeCtrl::SetItemState(long item, long state, long stateMask)
{
wxTreeItem info;
return SetItem(info);
}
-bool wxTreeCtrl::SetItemImage(const long item, const int image, const int selImage)
+bool wxTreeCtrl::SetItemImage(long item, int image, int selImage)
{
wxTreeItem info;
return SetItem(info);
}
-wxString wxTreeCtrl::GetItemText(const long item) const
+wxString wxTreeCtrl::GetItemText(long item) const
{
wxTreeItem info;
return info.m_text;
}
-void wxTreeCtrl::SetItemText(const long item, const wxString& str)
+void wxTreeCtrl::SetItemText(long item, const wxString& str)
{
wxTreeItem info;
SetItem(info);
}
-long wxTreeCtrl::GetItemData(const long item) const
+long wxTreeCtrl::GetItemData(long item) const
{
wxTreeItem info;
return info.m_data;
}
-bool wxTreeCtrl::SetItemData(const long item, long data)
+bool wxTreeCtrl::SetItemData(long item, long data)
{
wxTreeItem info;
return SetItem(info);
}
-bool wxTreeCtrl::GetItemRect(const long item, wxRectangle& rect, bool textOnly) const
+bool wxTreeCtrl::GetItemRect(long item, wxRectangle& rect, bool textOnly) const
{
RECT rect2;
}
// Operations
-bool wxTreeCtrl::DeleteItem(const long item)
+bool wxTreeCtrl::DeleteItem(long item)
{
return (TreeView_DeleteItem((HWND) GetHWND(), (HTREEITEM) item) != 0);
}
-bool wxTreeCtrl::ExpandItem(const long item, const int action)
+bool wxTreeCtrl::ExpandItem(long item, int action)
{
UINT mswAction = TVE_EXPAND;
switch ( action )
case wxTREE_EXPAND_EXPAND:
mswAction = TVE_EXPAND;
break;
+
case wxTREE_EXPAND_COLLAPSE:
mswAction = TVE_COLLAPSE;
+ break;
+
case wxTREE_EXPAND_COLLAPSE_RESET:
+ // @@@ it should also delete all the items! currently, if you do use this
+ // code your program will probaly crash. Feel free to remove this if
+ // it does work
+ wxFAIL_MSG("wxTREE_EXPAND_COLLAPSE_RESET probably doesn't work.");
mswAction = TVE_COLLAPSERESET;
+ break;
+
case wxTREE_EXPAND_TOGGLE:
mswAction = TVE_TOGGLE;
break;
- default :
- break;
+
+ default:
+ wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem");
+ }
+
+ bool bOk = TreeView_Expand((HWND)GetHWND(), (HTREEITEM)item, mswAction) != 0;
+
+ // TreeView_Expand doesn't send TVN_EXPAND(ING) messages, so emulate them
+ if ( bOk ) {
+ wxTreeEvent event(wxEVT_NULL, m_windowId);
+ event.m_item.m_itemId = item;
+ event.m_item.m_mask =
+ event.m_item.m_stateMask = 0xffff; // get all
+ GetItem(event.m_item);
+
+ bool bIsExpanded = (event.m_item.m_state & wxTREE_STATE_EXPANDED) != 0;
+
+ event.m_code = action;
+ event.SetEventObject(this);
+
+ // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded
+ event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDING
+ : wxEVT_COMMAND_TREE_ITEM_COLLAPSING);
+ GetEventHandler()->ProcessEvent(event);
+
+ event.SetEventType(bIsExpanded ? wxEVT_COMMAND_TREE_ITEM_EXPANDED
+ : wxEVT_COMMAND_TREE_ITEM_COLLAPSED);
+ GetEventHandler()->ProcessEvent(event);
}
- return (TreeView_Expand((HWND) GetHWND(), (HTREEITEM) item, mswAction) != 0);
+
+ return bOk;
}
-long wxTreeCtrl::InsertItem(const long parent, wxTreeItem& info, const long insertAfter)
+long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter)
{
TV_INSERTSTRUCT tvInsertStruct;
tvInsertStruct.hParent = (HTREEITEM) parent ;
return (long) TreeView_InsertItem((HWND) GetHWND(), & tvInsertStruct);
}
-long wxTreeCtrl::InsertItem(const long parent, const wxString& label, const int image, const int selImage,
- const long insertAfter)
+long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, int selImage,
+ long insertAfter)
{
wxTreeItem info;
info.m_text = label;
return InsertItem(parent, info, insertAfter);
}
-bool wxTreeCtrl::SelectItem(const long item)
+bool wxTreeCtrl::SelectItem(long item)
{
return (TreeView_SelectItem((HWND) GetHWND(), (HTREEITEM) item) != 0);
}
-bool wxTreeCtrl::ScrollTo(const long item)
+bool wxTreeCtrl::ScrollTo(long item)
{
return (TreeView_SelectSetFirstVisible((HWND) GetHWND(), (HTREEITEM) item) != 0);
}
return (TreeView_DeleteAllItems((HWND) GetHWND()) != 0);
}
-wxTextCtrl& wxTreeCtrl::Edit(const long item)
+wxTextCtrl& wxTreeCtrl::Edit(long item)
{
HWND hWnd = (HWND) TreeView_EditLabel((HWND) GetHWND(), item);
m_textCtrl.SetHWND((WXHWND) hWnd);
}
/*
-wxImageList *wxTreeCtrl::CreateDragImage(const long item)
+wxImageList *wxTreeCtrl::CreateDragImage(long item)
{
}
*/
-bool wxTreeCtrl::SortChildren(const long item)
+bool wxTreeCtrl::SortChildren(long item)
{
return (TreeView_SortChildren((HWND) GetHWND(), (HTREEITEM) item, 0) != 0);
}
-bool wxTreeCtrl::EnsureVisible(const long item)
+bool wxTreeCtrl::EnsureVisible(long item)
{
return (TreeView_EnsureVisible((HWND) GetHWND(), (HTREEITEM) item) != 0);
}
-bool wxTreeCtrl::MSWCommand(const WXUINT cmd, const WXWORD id)
+bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id)
{
if (cmd == EN_UPDATE)
{
else return FALSE;
}
-bool wxTreeCtrl::MSWNotify(const WXWPARAM wParam, const WXLPARAM lParam)
+bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
{
wxTreeEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
}
case TVN_ITEMEXPANDING:
{
- eventType = wxEVT_COMMAND_TREE_ITEM_EXPANDING;
NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
switch ( hdr->action )
{
case TVE_EXPAND:
- event.m_code = wxTREE_EXPAND_EXPAND;
+ eventType = wxEVT_COMMAND_TREE_ITEM_EXPANDING;
break;
+
case TVE_COLLAPSE:
- event.m_code = wxTREE_EXPAND_COLLAPSE;
+ eventType = wxEVT_COMMAND_TREE_ITEM_COLLAPSING;
+ break;
+
case TVE_COLLAPSERESET:
- event.m_code = wxTREE_EXPAND_COLLAPSE_RESET;
case TVE_TOGGLE:
- event.m_code = wxTREE_EXPAND_TOGGLE;
- break;
- default :
+ wxLogDebug("unexpected code in TVN_ITEMEXPANDING message");
break;
}
break;
}
+
case TVN_ITEMEXPANDED:
{
- eventType = wxEVT_COMMAND_TREE_ITEM_EXPANDED;
NM_TREEVIEW* hdr = (NM_TREEVIEW*)lParam;
wxConvertFromMSWTreeItem(event.m_item, hdr->itemNew, (HWND) GetHWND());
switch ( hdr->action )
{
case TVE_EXPAND:
- event.m_code = wxTREE_EXPAND_EXPAND;
+ eventType = wxEVT_COMMAND_TREE_ITEM_EXPANDED;
break;
+
case TVE_COLLAPSE:
- event.m_code = wxTREE_EXPAND_COLLAPSE;
+ eventType = wxEVT_COMMAND_TREE_ITEM_COLLAPSED;
+ break;
+
case TVE_COLLAPSERESET:
- event.m_code = wxTREE_EXPAND_COLLAPSE_RESET;
case TVE_TOGGLE:
- event.m_code = wxTREE_EXPAND_TOGGLE;
- break;
- default :
+ wxLogDebug("unexpected code in TVN_ITEMEXPANDED message");
break;
}
break;
break;
}
- event.SetEventObject( this );
+ event.SetEventObject(this);
event.SetEventType(eventType);
if ( !GetEventHandler()->ProcessEvent(event) )
wxConvertToMSWTreeItem(event.m_item, info->item);
}
- return TRUE;
+ return TRUE;
}
// Tree item structure