3 * Purpose: Tree control
10 /* static const char sccsid[] = "%W% %G%"; */
13 #pragma implementation "treectrl.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
29 #if defined(__WIN95__)
31 #include "wx/treectrl.h"
32 #include "wx/msw/private.h"
38 // Bug in headers, sometimes
40 #define TVIS_FOCUSED 0x0001
43 static void wxConvertToMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
);
44 static void wxConvertFromMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
, HWND getFullInfo
= 0);
46 #if !USE_SHARED_LIBRARY
47 IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl
, wxControl
)
48 IMPLEMENT_DYNAMIC_CLASS(wxTreeItem
, wxObject
)
52 wxTreeCtrl::wxTreeCtrl(void)
54 m_imageListNormal
= NULL
;
55 m_imageListState
= NULL
;
58 bool wxTreeCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
59 long style
, const wxValidator
& validator
, const wxString
& name
)
61 wxSystemSettings settings
;
62 SetBackgroundColour(settings
.GetSystemColour(wxSYS_COLOUR_WINDOW
));
63 SetForegroundColour(parent
->GetDefaultForegroundColour());
66 SetValidator(validator
);
68 m_imageListNormal
= NULL
;
69 m_imageListState
= NULL
;
76 m_windowStyle
= style
;
78 // SetFont(wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL));
91 m_windowId
= (id
== -1) ? NewControlId() : id
;
93 DWORD wstyle
= WS_VISIBLE
| WS_CHILD
| WS_TABSTOP
| TVS_HASLINES
;
96 WXDWORD exStyle
= Determine3DEffects(WS_EX_CLIENTEDGE
, &want3D
) ;
98 // Even with extended styles, need to combine with WS_BORDER
99 // for them to look right.
100 if (want3D
|| (m_windowStyle
& wxSIMPLE_BORDER
) || (m_windowStyle
& wxRAISED_BORDER
) ||
101 (m_windowStyle
& wxSUNKEN_BORDER
) || (m_windowStyle
& wxDOUBLE_BORDER
))
104 if ( m_windowStyle
& wxTR_HAS_BUTTONS
)
105 wstyle
|= TVS_HASBUTTONS
;
107 if ( m_windowStyle
& wxTR_EDIT_LABELS
)
108 wstyle
|= TVS_EDITLABELS
;
110 if ( m_windowStyle
& wxTR_LINES_AT_ROOT
)
111 wstyle
|= TVS_LINESATROOT
;
113 // Create the toolbar control.
114 HWND hWndTreeControl
= CreateWindowEx(exStyle
,
119 (HWND
) parent
->GetHWND(),
124 m_hWnd
= (WXHWND
) hWndTreeControl
;
125 if (parent
) parent
->AddChild(this);
127 SubclassWin((WXHWND
) m_hWnd
);
132 wxTreeCtrl::~wxTreeCtrl(void)
134 m_textCtrl
.SetHWND((WXHWND
) NULL
);
138 int wxTreeCtrl::GetCount(void) const
140 return (int) TreeView_GetCount((HWND
) GetHWND());
143 int wxTreeCtrl::GetIndent(void) const
145 return (int) TreeView_GetIndent((HWND
) GetHWND());
148 void wxTreeCtrl::SetIndent(int indent
)
150 TreeView_SetIndent((HWND
) GetHWND(), indent
);
153 wxImageList
*wxTreeCtrl::GetImageList(int which
) const
155 if ( which
== wxIMAGE_LIST_NORMAL
)
157 return m_imageListNormal
;
159 else if ( which
== wxIMAGE_LIST_STATE
)
161 return m_imageListState
;
166 void wxTreeCtrl::SetImageList(wxImageList
*imageList
, int which
)
169 if ( which
== wxIMAGE_LIST_NORMAL
)
171 flags
= TVSIL_NORMAL
;
172 m_imageListNormal
= imageList
;
174 else if ( which
== wxIMAGE_LIST_STATE
)
177 m_imageListState
= imageList
;
179 TreeView_SetImageList((HWND
) GetHWND(), (HIMAGELIST
) imageList
? imageList
->GetHIMAGELIST() : 0, flags
);
182 long wxTreeCtrl::GetNextItem(long item
, int code
) const
187 case wxTREE_NEXT_CARET
:
190 case wxTREE_NEXT_CHILD
:
193 case wxTREE_NEXT_DROPHILITE
:
194 flag
= TVGN_DROPHILITE
;
196 case wxTREE_NEXT_FIRSTVISIBLE
:
197 flag
= TVGN_FIRSTVISIBLE
;
199 case wxTREE_NEXT_NEXT
:
202 case wxTREE_NEXT_NEXTVISIBLE
:
203 flag
= TVGN_NEXTVISIBLE
;
205 case wxTREE_NEXT_PARENT
:
208 case wxTREE_NEXT_PREVIOUS
:
209 flag
= TVGN_PREVIOUS
;
211 case wxTREE_NEXT_PREVIOUSVISIBLE
:
212 flag
= TVGN_PREVIOUSVISIBLE
;
214 case wxTREE_NEXT_ROOT
:
221 return (long) TreeView_GetNextItem( (HWND
) GetHWND(), (HTREEITEM
) item
, flag
);
224 bool wxTreeCtrl::ItemHasChildren(long item
) const
227 item2
.hItem
= (HTREEITEM
) item
;
228 item2
.mask
= TVIF_CHILDREN
;
229 TreeView_GetItem((HWND
) GetHWND(), &item2
);
230 return (item2
.cChildren
!= 0);
233 long wxTreeCtrl::GetChild(long item
) const
235 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_CHILD
, (LPARAM
)item
);
238 long wxTreeCtrl::GetParent(long item
) const
240 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_PARENT
, (LPARAM
)item
);
243 long wxTreeCtrl::GetFirstVisibleItem(void) const
245 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_FIRSTVISIBLE
, 0);
248 long wxTreeCtrl::GetNextVisibleItem(long item
) const
250 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_NEXTVISIBLE
, (LPARAM
)item
);
253 long wxTreeCtrl::GetSelection(void) const
255 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_CARET
, 0);
258 long wxTreeCtrl::GetRootItem(void) const
260 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_ROOT
, 0);
263 bool wxTreeCtrl::GetItem(wxTreeItem
& info
) const
266 tvItem
.hItem
= (HTREEITEM
)info
.m_itemId
;
267 tvItem
.pszText
= NULL
;
269 tvItem
.stateMask
= 0;
271 // TODO: convert other bits in the mask
272 if ( info
.m_mask
& wxTREE_MASK_TEXT
)
274 tvItem
.mask
|= TVIF_TEXT
;
275 tvItem
.pszText
= new char[513];
276 tvItem
.cchTextMax
= 512;
278 if ( info
.m_mask
& wxTREE_MASK_DATA
)
279 tvItem
.mask
|= TVIF_PARAM
;
280 if ( info
.m_stateMask
& wxTREE_STATE_EXPANDED
) {
281 tvItem
.mask
|= TVIF_STATE
;
282 tvItem
.stateMask
|= TVIS_EXPANDED
;
285 bool success
= TreeView_GetItem((HWND
)GetHWND(), &tvItem
) != 0;
289 wxLogSysError("TreeView_GetItem failed");
292 delete[] tvItem
.pszText
;
297 wxConvertFromMSWTreeItem(info
, tvItem
);
300 delete[] tvItem
.pszText
;
305 bool wxTreeCtrl::SetItem(wxTreeItem
& info
)
308 wxConvertToMSWTreeItem(info
, item
);
309 return (::SendMessage((HWND
) GetHWND(), TVM_SETITEM
, 0, (LPARAM
)&item
) != 0);
312 int wxTreeCtrl::GetItemState(long item
, long stateMask
) const
316 info
.m_mask
= wxTREE_MASK_STATE
;
317 info
.m_stateMask
= stateMask
;
318 info
.m_itemId
= item
;
326 bool wxTreeCtrl::SetItemState(long item
, long state
, long stateMask
)
330 info
.m_mask
= wxTREE_MASK_STATE
;
331 info
.m_state
= state
;
332 info
.m_stateMask
= stateMask
;
333 info
.m_itemId
= item
;
335 return SetItem(info
);
338 bool wxTreeCtrl::SetItemImage(long item
, int image
, int selImage
)
342 info
.m_mask
= wxTREE_MASK_IMAGE
;
343 info
.m_image
= image
;
346 info
.m_selectedImage
= selImage
;
347 info
.m_mask
|= wxTREE_MASK_SELECTED_IMAGE
;
349 info
.m_itemId
= item
;
351 return SetItem(info
);
354 wxString
wxTreeCtrl::GetItemText(long item
) const
358 info
.m_mask
= wxTREE_MASK_TEXT
;
359 info
.m_itemId
= item
;
366 void wxTreeCtrl::SetItemText(long item
, const wxString
& str
)
370 info
.m_mask
= wxTREE_MASK_TEXT
;
371 info
.m_itemId
= item
;
377 long wxTreeCtrl::GetItemData(long item
) const
381 info
.m_mask
= wxTREE_MASK_DATA
;
382 info
.m_itemId
= item
;
389 bool wxTreeCtrl::SetItemData(long item
, long data
)
393 info
.m_mask
= wxTREE_MASK_DATA
;
394 info
.m_itemId
= item
;
397 return SetItem(info
);
400 bool wxTreeCtrl::GetItemRect(long item
, wxRectangle
& rect
, bool textOnly
) const
404 *(HTREEITEM
*)& rect2
= (HTREEITEM
) item
;
405 bool success
= (::SendMessage((HWND
) GetHWND(), TVM_GETITEMRECT
, (WPARAM
)textOnly
,
406 (LPARAM
)&rect2
) != 0);
410 rect
.width
= rect2
.right
- rect2
.left
;
411 rect
.height
= rect2
.bottom
- rect2
.left
;
415 wxTextCtrl
& wxTreeCtrl::GetEditControl(void) const
417 HWND hWnd
= (HWND
) TreeView_GetEditControl((HWND
) GetHWND());
418 ((wxTreeCtrl
*)this)->m_textCtrl
.SetHWND((WXHWND
) hWnd
);
419 return (wxTextCtrl
&) m_textCtrl
;
423 bool wxTreeCtrl::DeleteItem(long item
)
425 return (TreeView_DeleteItem((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
428 bool wxTreeCtrl::ExpandItem(long item
, int action
)
430 UINT mswAction
= TVE_EXPAND
;
433 case wxTREE_EXPAND_EXPAND
:
434 mswAction
= TVE_EXPAND
;
437 case wxTREE_EXPAND_COLLAPSE
:
438 mswAction
= TVE_COLLAPSE
;
441 case wxTREE_EXPAND_COLLAPSE_RESET
:
442 // @@@ it should also delete all the items! currently, if you do use this
443 // code your program will probaly crash. Feel free to remove this if
445 wxFAIL_MSG("wxTREE_EXPAND_COLLAPSE_RESET probably doesn't work.");
446 mswAction
= TVE_COLLAPSERESET
;
449 case wxTREE_EXPAND_TOGGLE
:
450 mswAction
= TVE_TOGGLE
;
454 wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem");
457 bool bOk
= TreeView_Expand((HWND
)GetHWND(), (HTREEITEM
)item
, mswAction
) != 0;
459 // TreeView_Expand doesn't send TVN_EXPAND(ING) messages, so emulate them
461 wxTreeEvent
event(wxEVT_NULL
, m_windowId
);
462 event
.m_item
.m_itemId
= item
;
463 event
.m_item
.m_mask
=
464 event
.m_item
.m_stateMask
= 0xffff; // get all
465 GetItem(event
.m_item
);
467 bool bIsExpanded
= (event
.m_item
.m_state
& wxTREE_STATE_EXPANDED
) != 0;
469 event
.m_code
= action
;
470 event
.SetEventObject(this);
472 // @@@ return values of {EXPAND|COLLAPS}ING event handler is discarded
473 event
.SetEventType(bIsExpanded
? wxEVT_COMMAND_TREE_ITEM_EXPANDING
474 : wxEVT_COMMAND_TREE_ITEM_COLLAPSING
);
475 GetEventHandler()->ProcessEvent(event
);
477 event
.SetEventType(bIsExpanded
? wxEVT_COMMAND_TREE_ITEM_EXPANDED
478 : wxEVT_COMMAND_TREE_ITEM_COLLAPSED
);
479 GetEventHandler()->ProcessEvent(event
);
485 long wxTreeCtrl::InsertItem(long parent
, wxTreeItem
& info
, long insertAfter
)
487 TV_INSERTSTRUCT tvInsertStruct
;
488 tvInsertStruct
.hParent
= (HTREEITEM
) parent
;
489 tvInsertStruct
.hInsertAfter
= (HTREEITEM
) insertAfter
;
491 wxConvertToMSWTreeItem(info
, tvInsertStruct
.item
);
493 return (long) TreeView_InsertItem((HWND
) GetHWND(), & tvInsertStruct
);
496 long wxTreeCtrl::InsertItem(long parent
, const wxString
& label
, int image
, int selImage
,
501 info
.m_mask
= wxTREE_MASK_TEXT
;
504 info
.m_mask
|= wxTREE_MASK_IMAGE
| wxTREE_MASK_SELECTED_IMAGE
;
505 info
.m_image
= image
;
506 if ( selImage
== -1 )
507 info
.m_selectedImage
= image
;
509 info
.m_selectedImage
= selImage
;
512 return InsertItem(parent
, info
, insertAfter
);
515 bool wxTreeCtrl::SelectItem(long item
)
517 return (TreeView_SelectItem((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
520 bool wxTreeCtrl::ScrollTo(long item
)
522 return (TreeView_SelectSetFirstVisible((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
525 bool wxTreeCtrl::DeleteAllItems(void)
527 return (TreeView_DeleteAllItems((HWND
) GetHWND()) != 0);
530 wxTextCtrl
& wxTreeCtrl::Edit(long item
)
532 HWND hWnd
= (HWND
) TreeView_EditLabel((HWND
) GetHWND(), item
);
533 m_textCtrl
.SetHWND((WXHWND
) hWnd
);
537 long wxTreeCtrl::HitTest(const wxPoint
& point
, int& flags
)
539 TV_HITTESTINFO hitTestInfo
;
540 hitTestInfo
.pt
.x
= (int) point
.x
;
541 hitTestInfo
.pt
.y
= (int) point
.y
;
543 TreeView_HitTest((HWND
) GetHWND(), & hitTestInfo
);
546 if ( hitTestInfo
.flags
& TVHT_ABOVE
)
547 flags
|= wxTREE_HITTEST_ABOVE
;
548 if ( hitTestInfo
.flags
& TVHT_BELOW
)
549 flags
|= wxTREE_HITTEST_BELOW
;
550 if ( hitTestInfo
.flags
& TVHT_NOWHERE
)
551 flags
|= wxTREE_HITTEST_NOWHERE
;
552 if ( hitTestInfo
.flags
& TVHT_ONITEMBUTTON
)
553 flags
|= wxTREE_HITTEST_ONITEMBUTTON
;
554 if ( hitTestInfo
.flags
& TVHT_ONITEMICON
)
555 flags
|= wxTREE_HITTEST_ONITEMICON
;
556 if ( hitTestInfo
.flags
& TVHT_ONITEMINDENT
)
557 flags
|= wxTREE_HITTEST_ONITEMINDENT
;
558 if ( hitTestInfo
.flags
& TVHT_ONITEMLABEL
)
559 flags
|= wxTREE_HITTEST_ONITEMLABEL
;
560 if ( hitTestInfo
.flags
& TVHT_ONITEMRIGHT
)
561 flags
|= wxTREE_HITTEST_ONITEMRIGHT
;
562 if ( hitTestInfo
.flags
& TVHT_ONITEMSTATEICON
)
563 flags
|= wxTREE_HITTEST_ONITEMSTATEICON
;
564 if ( hitTestInfo
.flags
& TVHT_TOLEFT
)
565 flags
|= wxTREE_HITTEST_TOLEFT
;
566 if ( hitTestInfo
.flags
& TVHT_TORIGHT
)
567 flags
|= wxTREE_HITTEST_TORIGHT
;
569 return (long) hitTestInfo
.hItem
;
573 wxImageList *wxTreeCtrl::CreateDragImage(long item)
578 bool wxTreeCtrl::SortChildren(long item
)
580 return (TreeView_SortChildren((HWND
) GetHWND(), (HTREEITEM
) item
, 0) != 0);
583 bool wxTreeCtrl::EnsureVisible(long item
)
585 return (TreeView_EnsureVisible((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
588 bool wxTreeCtrl::MSWCommand(WXUINT cmd
, WXWORD id
)
590 if (cmd
== EN_UPDATE
)
592 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, id
);
593 event
.SetEventObject( this );
594 ProcessCommand(event
);
597 else if (cmd
== EN_KILLFOCUS
)
599 wxCommandEvent
event(wxEVT_KILL_FOCUS
, id
);
600 event
.SetEventObject( this );
601 ProcessCommand(event
);
607 bool wxTreeCtrl::MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
)
609 wxTreeEvent
event(wxEVT_NULL
, m_windowId
);
610 wxEventType eventType
= wxEVT_NULL
;
611 NMHDR
* hdr1
= (NMHDR
*) lParam
;
612 switch ( hdr1
->code
)
616 eventType
= wxEVT_COMMAND_TREE_BEGIN_DRAG
;
617 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
618 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
619 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
620 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
623 case TVN_BEGINLABELEDIT
:
625 eventType
= wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
;
626 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
627 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
632 eventType
= wxEVT_COMMAND_TREE_BEGIN_RDRAG
;
633 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
634 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
635 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
636 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
641 eventType
= wxEVT_COMMAND_TREE_DELETE_ITEM
;
642 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
643 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemOld
, (HWND
) GetHWND());
644 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
645 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
648 case TVN_ENDLABELEDIT
:
650 eventType
= wxEVT_COMMAND_TREE_END_LABEL_EDIT
;
651 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
652 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
655 case TVN_GETDISPINFO
:
657 eventType
= wxEVT_COMMAND_TREE_GET_INFO
;
658 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
659 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
662 case TVN_ITEMEXPANDING
:
664 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
665 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
667 switch ( hdr
->action
)
670 eventType
= wxEVT_COMMAND_TREE_ITEM_EXPANDING
;
674 eventType
= wxEVT_COMMAND_TREE_ITEM_COLLAPSING
;
677 case TVE_COLLAPSERESET
:
679 wxLogDebug("unexpected code in TVN_ITEMEXPANDING message");
685 case TVN_ITEMEXPANDED
:
687 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
688 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
689 switch ( hdr
->action
)
692 eventType
= wxEVT_COMMAND_TREE_ITEM_EXPANDED
;
696 eventType
= wxEVT_COMMAND_TREE_ITEM_COLLAPSED
;
699 case TVE_COLLAPSERESET
:
701 wxLogDebug("unexpected code in TVN_ITEMEXPANDED message");
708 eventType
= wxEVT_COMMAND_TREE_KEY_DOWN
;
709 TV_KEYDOWN
*info
= (TV_KEYDOWN
*)lParam
;
710 event
.m_code
= wxCharCodeMSWToWX(info
->wVKey
);
715 eventType
= wxEVT_COMMAND_TREE_SEL_CHANGED
;
716 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
717 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
718 event
.m_oldItem
= (long) hdr
->itemNew
.hItem
;
722 case TVN_SELCHANGING
:
724 eventType
= wxEVT_COMMAND_TREE_SEL_CHANGING
;
725 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
726 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
727 event
.m_oldItem
= (long) hdr
->itemNew
.hItem
;
730 case TVN_SETDISPINFO
:
732 eventType
= wxEVT_COMMAND_TREE_SET_INFO
;
733 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
734 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
739 return wxControl::MSWNotify(wParam
, lParam
);
743 event
.SetEventObject(this);
744 event
.SetEventType(eventType
);
746 if ( !GetEventHandler()->ProcessEvent(event
) )
749 if (hdr1
->code
== TVN_GETDISPINFO
)
751 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
752 wxConvertToMSWTreeItem(event
.m_item
, info
->item
);
758 // Tree item structure
759 wxTreeItem::wxTreeItem(void)
766 m_selectedImage
= -1;
771 // If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
772 static void wxConvertFromMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
, HWND getFullInfo
)
774 info
.m_data
= tvItem
.lParam
;
777 info
.m_stateMask
= 0;
779 long oldMask
= tvItem
.mask
;
781 bool needText
= FALSE
;
782 if (getFullInfo
!= 0)
784 if ( tvItem
.mask
& TVIF_TEXT
)
791 tvItem
.pszText
= new char[513];
792 tvItem
.cchTextMax
= 512;
794 tvItem
.mask
|= TVIF_HANDLE
| TVIF_STATE
| TVIF_TEXT
| TVIF_IMAGE
| TVIF_SELECTEDIMAGE
| TVIF_CHILDREN
| TVIF_PARAM
;
795 ::SendMessage(getFullInfo
, TVM_GETITEM
, 0, (LPARAM
)& tvItem
) ;
798 if ( tvItem
.mask
& TVIF_HANDLE
)
800 info
.m_mask
|= wxTREE_MASK_HANDLE
;
801 info
.m_itemId
= (long) tvItem
.hItem
;
803 if ( tvItem
.mask
& TVIF_STATE
)
805 info
.m_mask
|= wxTREE_MASK_STATE
;
806 if ( tvItem
.stateMask
& TVIS_BOLD
)
808 info
.m_stateMask
|= wxTREE_STATE_BOLD
;
809 if ( tvItem
.state
& TVIS_BOLD
)
810 info
.m_state
|= wxTREE_STATE_BOLD
;
813 if ( tvItem
.stateMask
& TVIS_CUT
)
815 info
.m_stateMask
|= wxTREE_STATE_CUT
;
816 if ( tvItem
.state
& TVIS_CUT
)
817 info
.m_state
|= wxTREE_STATE_CUT
;
820 if ( tvItem
.stateMask
& TVIS_DROPHILITED
)
822 info
.m_stateMask
|= wxTREE_STATE_DROPHILITED
;
823 if ( tvItem
.state
& TVIS_DROPHILITED
)
824 info
.m_state
|= wxTREE_STATE_DROPHILITED
;
826 if ( tvItem
.stateMask
& TVIS_EXPANDED
)
828 info
.m_stateMask
|= wxTREE_STATE_EXPANDED
;
829 if ( tvItem
.state
& TVIS_EXPANDED
)
830 info
.m_state
|= wxTREE_STATE_EXPANDED
;
832 if ( tvItem
.stateMask
& TVIS_EXPANDEDONCE
)
834 info
.m_stateMask
|= wxTREE_STATE_EXPANDEDONCE
;
835 if ( tvItem
.state
& TVIS_EXPANDEDONCE
)
836 info
.m_state
|= wxTREE_STATE_EXPANDEDONCE
;
838 if ( tvItem
.stateMask
& TVIS_FOCUSED
)
840 info
.m_stateMask
|= wxTREE_STATE_FOCUSED
;
841 if ( tvItem
.state
& TVIS_FOCUSED
)
842 info
.m_state
|= wxTREE_STATE_FOCUSED
;
844 if ( tvItem
.stateMask
& TVIS_SELECTED
)
846 info
.m_stateMask
|= wxTREE_STATE_SELECTED
;
847 if ( tvItem
.state
& TVIS_SELECTED
)
848 info
.m_state
|= wxTREE_STATE_SELECTED
;
852 if ( tvItem
.mask
& TVIF_TEXT
)
854 info
.m_mask
|= wxTREE_MASK_TEXT
;
855 info
.m_text
= tvItem
.pszText
;
857 if ( tvItem
.mask
& TVIF_IMAGE
)
859 info
.m_mask
|= wxTREE_MASK_IMAGE
;
860 info
.m_image
= tvItem
.iImage
;
862 if ( tvItem
.mask
& TVIF_SELECTEDIMAGE
)
864 info
.m_mask
|= wxTREE_MASK_SELECTED_IMAGE
;
865 info
.m_selectedImage
= tvItem
.iSelectedImage
;
867 if ( tvItem
.mask
& TVIF_CHILDREN
)
869 info
.m_mask
|= wxTREE_MASK_CHILDREN
;
870 info
.m_children
= tvItem
.cChildren
;
872 if ( tvItem
.mask
& TVIF_PARAM
)
873 info
.m_mask
|= wxTREE_MASK_DATA
;
878 delete[] tvItem
.pszText
;
880 tvItem
.mask
= oldMask
;
883 static void wxConvertToMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
)
885 tvItem
.hItem
= (HTREEITEM
) info
.m_itemId
;
887 tvItem
.iImage
= info
.m_image
;
888 tvItem
.iSelectedImage
= info
.m_selectedImage
;
889 tvItem
.cChildren
= info
.m_children
;
890 tvItem
.lParam
= info
.m_data
;
892 tvItem
.stateMask
= 0;
895 if (info
.m_mask
& wxTREE_MASK_HANDLE
)
896 tvItem
.mask
|= TVIF_HANDLE
;
897 if (info
.m_mask
& wxTREE_MASK_STATE
)
898 tvItem
.mask
|= TVIF_STATE
;
899 if (info
.m_mask
& wxTREE_MASK_TEXT
)
901 tvItem
.mask
|= TVIF_TEXT
;
902 tvItem
.pszText
= (char *) (const char *)info
.m_text
;
903 if ( tvItem
.pszText
)
904 tvItem
.cchTextMax
= info
.m_text
.Length();
906 tvItem
.cchTextMax
= 0;
908 if (info
.m_mask
& wxTREE_MASK_IMAGE
)
909 tvItem
.mask
|= TVIF_IMAGE
;
910 if (info
.m_mask
& wxTREE_MASK_SELECTED_IMAGE
)
911 tvItem
.mask
|= TVIF_SELECTEDIMAGE
;
912 if (info
.m_mask
& wxTREE_MASK_CHILDREN
)
913 tvItem
.mask
|= TVIF_CHILDREN
;
914 if (info
.m_mask
& wxTREE_MASK_DATA
)
915 tvItem
.mask
|= TVIF_PARAM
;
917 if (info
.m_stateMask
& wxTREE_STATE_BOLD
)
919 tvItem
.stateMask
|= TVIS_BOLD
;
920 tvItem
.state
|= TVIS_BOLD
;
922 if (info
.m_stateMask
& wxTREE_STATE_CUT
)
924 tvItem
.stateMask
|= TVIS_CUT
;
925 if ( info
.m_state
& wxTREE_STATE_CUT
)
926 tvItem
.state
|= TVIS_CUT
;
928 if (info
.m_stateMask
& wxTREE_STATE_DROPHILITED
)
930 tvItem
.stateMask
|= TVIS_DROPHILITED
;
931 if ( info
.m_state
& wxTREE_STATE_DROPHILITED
)
932 tvItem
.state
|= TVIS_DROPHILITED
;
934 if (info
.m_stateMask
& wxTREE_STATE_EXPANDED
)
936 tvItem
.stateMask
|= TVIS_EXPANDED
;
937 if ( info
.m_state
& wxTREE_STATE_EXPANDED
)
938 tvItem
.state
|= TVIS_EXPANDED
;
940 if (info
.m_stateMask
& wxTREE_STATE_EXPANDEDONCE
)
942 tvItem
.stateMask
|= TVIS_EXPANDEDONCE
;
943 if ( info
.m_state
& wxTREE_STATE_EXPANDEDONCE
)
944 tvItem
.state
|= TVIS_EXPANDEDONCE
;
946 if (info
.m_stateMask
& wxTREE_STATE_FOCUSED
)
948 tvItem
.stateMask
|= TVIS_FOCUSED
;
949 if ( info
.m_state
& wxTREE_STATE_FOCUSED
)
950 tvItem
.state
|= TVIS_FOCUSED
;
952 if (info
.m_stateMask
& wxTREE_STATE_SELECTED
)
954 tvItem
.stateMask
|= TVIS_SELECTED
;
955 if ( info
.m_state
& wxTREE_STATE_SELECTED
)
956 tvItem
.state
|= TVIS_SELECTED
;
961 IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent
, wxCommandEvent
)
963 wxTreeEvent::wxTreeEvent(wxEventType commandType
, int id
):
964 wxCommandEvent(commandType
, id
)