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 // TODO: convert mask
264 bool wxTreeCtrl::GetItem(wxTreeItem
& info
) const
267 tvItem
.hItem
= (HTREEITEM
)info
.m_itemId
;
268 tvItem
.pszText
= NULL
;
270 if ( info
.m_mask
& wxTREE_MASK_TEXT
)
272 tvItem
.mask
|= TVIF_TEXT
;
273 tvItem
.pszText
= new char[513];
274 tvItem
.cchTextMax
= 512;
276 if ( info
.m_mask
& wxTREE_MASK_DATA
)
277 tvItem
.mask
|= TVIF_PARAM
;
279 bool success
= TreeView_GetItem((HWND
)GetHWND(), &tvItem
) != 0;
283 wxLogSysError("TreeView_GetItem failed");
286 delete[] tvItem
.pszText
;
291 wxConvertFromMSWTreeItem(info
, tvItem
);
294 delete[] tvItem
.pszText
;
299 bool wxTreeCtrl::SetItem(wxTreeItem
& info
)
302 wxConvertToMSWTreeItem(info
, item
);
303 return (::SendMessage((HWND
) GetHWND(), TVM_SETITEM
, 0, (LPARAM
)&item
) != 0);
306 int wxTreeCtrl::GetItemState(long item
, long stateMask
) const
310 info
.m_mask
= wxTREE_MASK_STATE
;
311 info
.m_stateMask
= stateMask
;
312 info
.m_itemId
= item
;
320 bool wxTreeCtrl::SetItemState(long item
, long state
, long stateMask
)
324 info
.m_mask
= wxTREE_MASK_STATE
;
325 info
.m_state
= state
;
326 info
.m_stateMask
= stateMask
;
327 info
.m_itemId
= item
;
329 return SetItem(info
);
332 bool wxTreeCtrl::SetItemImage(long item
, int image
, int selImage
)
336 info
.m_mask
= wxTREE_MASK_IMAGE
;
337 info
.m_image
= image
;
340 info
.m_selectedImage
= selImage
;
341 info
.m_mask
|= wxTREE_MASK_SELECTED_IMAGE
;
343 info
.m_itemId
= item
;
345 return SetItem(info
);
348 wxString
wxTreeCtrl::GetItemText(long item
) const
352 info
.m_mask
= wxTREE_MASK_TEXT
;
353 info
.m_itemId
= item
;
360 void wxTreeCtrl::SetItemText(long item
, const wxString
& str
)
364 info
.m_mask
= wxTREE_MASK_TEXT
;
365 info
.m_itemId
= item
;
371 long wxTreeCtrl::GetItemData(long item
) const
375 info
.m_mask
= wxTREE_MASK_DATA
;
376 info
.m_itemId
= item
;
383 bool wxTreeCtrl::SetItemData(long item
, long data
)
387 info
.m_mask
= wxTREE_MASK_DATA
;
388 info
.m_itemId
= item
;
391 return SetItem(info
);
394 bool wxTreeCtrl::GetItemRect(long item
, wxRectangle
& rect
, bool textOnly
) const
398 *(HTREEITEM
*)& rect2
= (HTREEITEM
) item
;
399 bool success
= (::SendMessage((HWND
) GetHWND(), TVM_GETITEMRECT
, (WPARAM
)textOnly
,
400 (LPARAM
)&rect2
) != 0);
404 rect
.width
= rect2
.right
- rect2
.left
;
405 rect
.height
= rect2
.bottom
- rect2
.left
;
409 wxTextCtrl
& wxTreeCtrl::GetEditControl(void) const
411 HWND hWnd
= (HWND
) TreeView_GetEditControl((HWND
) GetHWND());
412 ((wxTreeCtrl
*)this)->m_textCtrl
.SetHWND((WXHWND
) hWnd
);
413 return (wxTextCtrl
&) m_textCtrl
;
417 bool wxTreeCtrl::DeleteItem(long item
)
419 return (TreeView_DeleteItem((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
422 bool wxTreeCtrl::ExpandItem(long item
, int action
)
424 UINT mswAction
= TVE_EXPAND
;
427 case wxTREE_EXPAND_EXPAND
:
428 mswAction
= TVE_EXPAND
;
430 case wxTREE_EXPAND_COLLAPSE
:
431 mswAction
= TVE_COLLAPSE
;
432 case wxTREE_EXPAND_COLLAPSE_RESET
:
433 mswAction
= TVE_COLLAPSERESET
;
434 case wxTREE_EXPAND_TOGGLE
:
435 mswAction
= TVE_TOGGLE
;
440 return (TreeView_Expand((HWND
) GetHWND(), (HTREEITEM
) item
, mswAction
) != 0);
443 long wxTreeCtrl::InsertItem(long parent
, wxTreeItem
& info
, long insertAfter
)
445 TV_INSERTSTRUCT tvInsertStruct
;
446 tvInsertStruct
.hParent
= (HTREEITEM
) parent
;
447 tvInsertStruct
.hInsertAfter
= (HTREEITEM
) insertAfter
;
449 wxConvertToMSWTreeItem(info
, tvInsertStruct
.item
);
451 return (long) TreeView_InsertItem((HWND
) GetHWND(), & tvInsertStruct
);
454 long wxTreeCtrl::InsertItem(long parent
, const wxString
& label
, int image
, int selImage
,
459 info
.m_mask
= wxTREE_MASK_TEXT
;
462 info
.m_mask
|= wxTREE_MASK_IMAGE
| wxTREE_MASK_SELECTED_IMAGE
;
463 info
.m_image
= image
;
464 if ( selImage
== -1 )
465 info
.m_selectedImage
= image
;
467 info
.m_selectedImage
= selImage
;
470 return InsertItem(parent
, info
, insertAfter
);
473 bool wxTreeCtrl::SelectItem(long item
)
475 return (TreeView_SelectItem((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
478 bool wxTreeCtrl::ScrollTo(long item
)
480 return (TreeView_SelectSetFirstVisible((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
483 bool wxTreeCtrl::DeleteAllItems(void)
485 return (TreeView_DeleteAllItems((HWND
) GetHWND()) != 0);
488 wxTextCtrl
& wxTreeCtrl::Edit(long item
)
490 HWND hWnd
= (HWND
) TreeView_EditLabel((HWND
) GetHWND(), item
);
491 m_textCtrl
.SetHWND((WXHWND
) hWnd
);
495 long wxTreeCtrl::HitTest(const wxPoint
& point
, int& flags
)
497 TV_HITTESTINFO hitTestInfo
;
498 hitTestInfo
.pt
.x
= (int) point
.x
;
499 hitTestInfo
.pt
.y
= (int) point
.y
;
501 TreeView_HitTest((HWND
) GetHWND(), & hitTestInfo
);
504 if ( hitTestInfo
.flags
& TVHT_ABOVE
)
505 flags
|= wxTREE_HITTEST_ABOVE
;
506 if ( hitTestInfo
.flags
& TVHT_BELOW
)
507 flags
|= wxTREE_HITTEST_BELOW
;
508 if ( hitTestInfo
.flags
& TVHT_NOWHERE
)
509 flags
|= wxTREE_HITTEST_NOWHERE
;
510 if ( hitTestInfo
.flags
& TVHT_ONITEMBUTTON
)
511 flags
|= wxTREE_HITTEST_ONITEMBUTTON
;
512 if ( hitTestInfo
.flags
& TVHT_ONITEMICON
)
513 flags
|= wxTREE_HITTEST_ONITEMICON
;
514 if ( hitTestInfo
.flags
& TVHT_ONITEMINDENT
)
515 flags
|= wxTREE_HITTEST_ONITEMINDENT
;
516 if ( hitTestInfo
.flags
& TVHT_ONITEMLABEL
)
517 flags
|= wxTREE_HITTEST_ONITEMLABEL
;
518 if ( hitTestInfo
.flags
& TVHT_ONITEMRIGHT
)
519 flags
|= wxTREE_HITTEST_ONITEMRIGHT
;
520 if ( hitTestInfo
.flags
& TVHT_ONITEMSTATEICON
)
521 flags
|= wxTREE_HITTEST_ONITEMSTATEICON
;
522 if ( hitTestInfo
.flags
& TVHT_TOLEFT
)
523 flags
|= wxTREE_HITTEST_TOLEFT
;
524 if ( hitTestInfo
.flags
& TVHT_TORIGHT
)
525 flags
|= wxTREE_HITTEST_TORIGHT
;
527 return (long) hitTestInfo
.hItem
;
531 wxImageList *wxTreeCtrl::CreateDragImage(long item)
536 bool wxTreeCtrl::SortChildren(long item
)
538 return (TreeView_SortChildren((HWND
) GetHWND(), (HTREEITEM
) item
, 0) != 0);
541 bool wxTreeCtrl::EnsureVisible(long item
)
543 return (TreeView_EnsureVisible((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
546 bool wxTreeCtrl::MSWCommand(WXUINT cmd
, WXWORD id
)
548 if (cmd
== EN_UPDATE
)
550 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, id
);
551 event
.SetEventObject( this );
552 ProcessCommand(event
);
555 else if (cmd
== EN_KILLFOCUS
)
557 wxCommandEvent
event(wxEVT_KILL_FOCUS
, id
);
558 event
.SetEventObject( this );
559 ProcessCommand(event
);
565 bool wxTreeCtrl::MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
)
567 wxTreeEvent
event(wxEVT_NULL
, m_windowId
);
568 wxEventType eventType
= wxEVT_NULL
;
569 NMHDR
* hdr1
= (NMHDR
*) lParam
;
570 switch ( hdr1
->code
)
574 eventType
= wxEVT_COMMAND_TREE_BEGIN_DRAG
;
575 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
576 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
577 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
578 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
581 case TVN_BEGINLABELEDIT
:
583 eventType
= wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
;
584 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
585 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
590 eventType
= wxEVT_COMMAND_TREE_BEGIN_RDRAG
;
591 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
592 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
593 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
594 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
599 eventType
= wxEVT_COMMAND_TREE_DELETE_ITEM
;
600 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
601 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemOld
, (HWND
) GetHWND());
602 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
603 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
606 case TVN_ENDLABELEDIT
:
608 eventType
= wxEVT_COMMAND_TREE_END_LABEL_EDIT
;
609 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
610 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
613 case TVN_GETDISPINFO
:
615 eventType
= wxEVT_COMMAND_TREE_GET_INFO
;
616 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
617 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
620 case TVN_ITEMEXPANDING
:
622 eventType
= wxEVT_COMMAND_TREE_ITEM_EXPANDING
;
623 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
624 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
626 switch ( hdr
->action
)
629 event
.m_code
= wxTREE_EXPAND_EXPAND
;
632 event
.m_code
= wxTREE_EXPAND_COLLAPSE
;
633 case TVE_COLLAPSERESET
:
634 event
.m_code
= wxTREE_EXPAND_COLLAPSE_RESET
;
636 event
.m_code
= wxTREE_EXPAND_TOGGLE
;
643 case TVN_ITEMEXPANDED
:
645 eventType
= wxEVT_COMMAND_TREE_ITEM_EXPANDED
;
646 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
647 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
648 switch ( hdr
->action
)
651 event
.m_code
= wxTREE_EXPAND_EXPAND
;
654 event
.m_code
= wxTREE_EXPAND_COLLAPSE
;
655 case TVE_COLLAPSERESET
:
656 event
.m_code
= wxTREE_EXPAND_COLLAPSE_RESET
;
658 event
.m_code
= wxTREE_EXPAND_TOGGLE
;
667 eventType
= wxEVT_COMMAND_TREE_KEY_DOWN
;
668 TV_KEYDOWN
*info
= (TV_KEYDOWN
*)lParam
;
669 event
.m_code
= wxCharCodeMSWToWX(info
->wVKey
);
674 eventType
= wxEVT_COMMAND_TREE_SEL_CHANGED
;
675 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
676 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
677 event
.m_oldItem
= (long) hdr
->itemNew
.hItem
;
681 case TVN_SELCHANGING
:
683 eventType
= wxEVT_COMMAND_TREE_SEL_CHANGING
;
684 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
685 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
686 event
.m_oldItem
= (long) hdr
->itemNew
.hItem
;
689 case TVN_SETDISPINFO
:
691 eventType
= wxEVT_COMMAND_TREE_SET_INFO
;
692 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
693 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
698 return wxControl::MSWNotify(wParam
, lParam
);
702 event
.SetEventObject( this );
703 event
.SetEventType(eventType
);
705 if ( !GetEventHandler()->ProcessEvent(event
) )
708 if (hdr1
->code
== TVN_GETDISPINFO
)
710 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
711 wxConvertToMSWTreeItem(event
.m_item
, info
->item
);
717 // Tree item structure
718 wxTreeItem::wxTreeItem(void)
725 m_selectedImage
= -1;
730 // If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
731 static void wxConvertFromMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
, HWND getFullInfo
)
733 info
.m_data
= tvItem
.lParam
;
736 info
.m_stateMask
= 0;
738 long oldMask
= tvItem
.mask
;
740 bool needText
= FALSE
;
741 if (getFullInfo
!= 0)
743 if ( tvItem
.mask
& TVIF_TEXT
)
750 tvItem
.pszText
= new char[513];
751 tvItem
.cchTextMax
= 512;
753 tvItem
.mask
|= TVIF_HANDLE
| TVIF_STATE
| TVIF_TEXT
| TVIF_IMAGE
| TVIF_SELECTEDIMAGE
| TVIF_CHILDREN
| TVIF_PARAM
;
754 ::SendMessage(getFullInfo
, TVM_GETITEM
, 0, (LPARAM
)& tvItem
) ;
757 if ( tvItem
.mask
& TVIF_HANDLE
)
759 info
.m_mask
|= wxTREE_MASK_HANDLE
;
760 info
.m_itemId
= (long) tvItem
.hItem
;
762 if ( tvItem
.mask
& TVIF_STATE
)
764 info
.m_mask
|= wxTREE_MASK_STATE
;
765 if ( tvItem
.stateMask
& TVIS_BOLD
)
767 info
.m_stateMask
|= wxTREE_STATE_BOLD
;
768 if ( tvItem
.state
& TVIS_BOLD
)
769 info
.m_state
|= wxTREE_STATE_BOLD
;
772 if ( tvItem
.stateMask
& TVIS_CUT
)
774 info
.m_stateMask
|= wxTREE_STATE_CUT
;
775 if ( tvItem
.state
& TVIS_CUT
)
776 info
.m_state
|= wxTREE_STATE_CUT
;
779 if ( tvItem
.stateMask
& TVIS_DROPHILITED
)
781 info
.m_stateMask
|= wxTREE_STATE_DROPHILITED
;
782 if ( tvItem
.state
& TVIS_DROPHILITED
)
783 info
.m_state
|= wxTREE_STATE_DROPHILITED
;
785 if ( tvItem
.stateMask
& TVIS_EXPANDED
)
787 info
.m_stateMask
|= wxTREE_STATE_EXPANDED
;
788 if ( tvItem
.state
& TVIS_EXPANDED
)
789 info
.m_state
|= wxTREE_STATE_EXPANDED
;
791 if ( tvItem
.stateMask
& TVIS_EXPANDEDONCE
)
793 info
.m_stateMask
|= wxTREE_STATE_EXPANDEDONCE
;
794 if ( tvItem
.state
& TVIS_EXPANDEDONCE
)
795 info
.m_state
|= wxTREE_STATE_EXPANDEDONCE
;
797 if ( tvItem
.stateMask
& TVIS_FOCUSED
)
799 info
.m_stateMask
|= wxTREE_STATE_FOCUSED
;
800 if ( tvItem
.state
& TVIS_FOCUSED
)
801 info
.m_state
|= wxTREE_STATE_FOCUSED
;
803 if ( tvItem
.stateMask
& TVIS_SELECTED
)
805 info
.m_stateMask
|= wxTREE_STATE_SELECTED
;
806 if ( tvItem
.state
& TVIS_SELECTED
)
807 info
.m_state
|= wxTREE_STATE_SELECTED
;
811 if ( tvItem
.mask
& TVIF_TEXT
)
813 info
.m_mask
|= wxTREE_MASK_TEXT
;
814 info
.m_text
= tvItem
.pszText
;
816 if ( tvItem
.mask
& TVIF_IMAGE
)
818 info
.m_mask
|= wxTREE_MASK_IMAGE
;
819 info
.m_image
= tvItem
.iImage
;
821 if ( tvItem
.mask
& TVIF_SELECTEDIMAGE
)
823 info
.m_mask
|= wxTREE_MASK_SELECTED_IMAGE
;
824 info
.m_selectedImage
= tvItem
.iSelectedImage
;
826 if ( tvItem
.mask
& TVIF_CHILDREN
)
828 info
.m_mask
|= wxTREE_MASK_CHILDREN
;
829 info
.m_children
= tvItem
.cChildren
;
831 if ( tvItem
.mask
& TVIF_PARAM
)
832 info
.m_mask
|= wxTREE_MASK_DATA
;
837 delete[] tvItem
.pszText
;
839 tvItem
.mask
= oldMask
;
842 static void wxConvertToMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
)
844 tvItem
.hItem
= (HTREEITEM
) info
.m_itemId
;
846 tvItem
.iImage
= info
.m_image
;
847 tvItem
.iSelectedImage
= info
.m_selectedImage
;
848 tvItem
.cChildren
= info
.m_children
;
849 tvItem
.lParam
= info
.m_data
;
851 tvItem
.stateMask
= 0;
854 if (info
.m_mask
& wxTREE_MASK_HANDLE
)
855 tvItem
.mask
|= TVIF_HANDLE
;
856 if (info
.m_mask
& wxTREE_MASK_STATE
)
857 tvItem
.mask
|= TVIF_STATE
;
858 if (info
.m_mask
& wxTREE_MASK_TEXT
)
860 tvItem
.mask
|= TVIF_TEXT
;
861 tvItem
.pszText
= (char *) (const char *)info
.m_text
;
862 if ( tvItem
.pszText
)
863 tvItem
.cchTextMax
= info
.m_text
.Length();
865 tvItem
.cchTextMax
= 0;
867 if (info
.m_mask
& wxTREE_MASK_IMAGE
)
868 tvItem
.mask
|= TVIF_IMAGE
;
869 if (info
.m_mask
& wxTREE_MASK_SELECTED_IMAGE
)
870 tvItem
.mask
|= TVIF_SELECTEDIMAGE
;
871 if (info
.m_mask
& wxTREE_MASK_CHILDREN
)
872 tvItem
.mask
|= TVIF_CHILDREN
;
873 if (info
.m_mask
& wxTREE_MASK_DATA
)
874 tvItem
.mask
|= TVIF_PARAM
;
876 if (info
.m_stateMask
& wxTREE_STATE_BOLD
)
878 tvItem
.stateMask
|= TVIS_BOLD
;
879 tvItem
.state
|= TVIS_BOLD
;
881 if (info
.m_stateMask
& wxTREE_STATE_CUT
)
883 tvItem
.stateMask
|= TVIS_CUT
;
884 if ( info
.m_state
& wxTREE_STATE_CUT
)
885 tvItem
.state
|= TVIS_CUT
;
887 if (info
.m_stateMask
& wxTREE_STATE_DROPHILITED
)
889 tvItem
.stateMask
|= TVIS_DROPHILITED
;
890 if ( info
.m_state
& wxTREE_STATE_DROPHILITED
)
891 tvItem
.state
|= TVIS_DROPHILITED
;
893 if (info
.m_stateMask
& wxTREE_STATE_EXPANDED
)
895 tvItem
.stateMask
|= TVIS_EXPANDED
;
896 if ( info
.m_state
& wxTREE_STATE_EXPANDED
)
897 tvItem
.state
|= TVIS_EXPANDED
;
899 if (info
.m_stateMask
& wxTREE_STATE_EXPANDEDONCE
)
901 tvItem
.stateMask
|= TVIS_EXPANDEDONCE
;
902 if ( info
.m_state
& wxTREE_STATE_EXPANDEDONCE
)
903 tvItem
.state
|= TVIS_EXPANDEDONCE
;
905 if (info
.m_stateMask
& wxTREE_STATE_FOCUSED
)
907 tvItem
.stateMask
|= TVIS_FOCUSED
;
908 if ( info
.m_state
& wxTREE_STATE_FOCUSED
)
909 tvItem
.state
|= TVIS_FOCUSED
;
911 if (info
.m_stateMask
& wxTREE_STATE_SELECTED
)
913 tvItem
.stateMask
|= TVIS_SELECTED
;
914 if ( info
.m_state
& wxTREE_STATE_SELECTED
)
915 tvItem
.state
|= TVIS_SELECTED
;
920 IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent
, wxCommandEvent
)
922 wxTreeEvent::wxTreeEvent(wxEventType commandType
, int id
):
923 wxCommandEvent(commandType
, id
)