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
, const wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
59 const 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
| TVS_LINESATROOT
;
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 // Create the toolbar control.
111 HWND hWndTreeControl
= CreateWindowEx(exStyle
,
116 (HWND
) parent
->GetHWND(),
121 m_hWnd
= (WXHWND
) hWndTreeControl
;
122 if (parent
) parent
->AddChild(this);
124 SubclassWin((WXHWND
) m_hWnd
);
129 wxTreeCtrl::~wxTreeCtrl(void)
131 m_textCtrl
.SetHWND((WXHWND
) NULL
);
135 int wxTreeCtrl::GetCount(void) const
137 return (int) TreeView_GetCount((HWND
) GetHWND());
140 int wxTreeCtrl::GetIndent(void) const
142 return (int) TreeView_GetIndent((HWND
) GetHWND());
145 void wxTreeCtrl::SetIndent(int indent
)
147 TreeView_SetIndent((HWND
) GetHWND(), indent
);
150 wxImageList
*wxTreeCtrl::GetImageList(const int which
) const
152 if ( which
== wxIMAGE_LIST_NORMAL
)
154 return m_imageListNormal
;
156 else if ( which
== wxIMAGE_LIST_STATE
)
158 return m_imageListState
;
163 void wxTreeCtrl::SetImageList(wxImageList
*imageList
, const int which
)
166 if ( which
== wxIMAGE_LIST_NORMAL
)
168 flags
= TVSIL_NORMAL
;
169 m_imageListNormal
= imageList
;
171 else if ( which
== wxIMAGE_LIST_STATE
)
174 m_imageListState
= imageList
;
176 TreeView_SetImageList((HWND
) GetHWND(), (HIMAGELIST
) imageList
? imageList
->GetHIMAGELIST() : 0, flags
);
179 long wxTreeCtrl::GetNextItem(const long item
, int code
) const
184 case wxTREE_NEXT_CARET
:
187 case wxTREE_NEXT_CHILD
:
190 case wxTREE_NEXT_DROPHILITE
:
191 flag
= TVGN_DROPHILITE
;
193 case wxTREE_NEXT_FIRSTVISIBLE
:
194 flag
= TVGN_FIRSTVISIBLE
;
196 case wxTREE_NEXT_NEXT
:
199 case wxTREE_NEXT_NEXTVISIBLE
:
200 flag
= TVGN_NEXTVISIBLE
;
202 case wxTREE_NEXT_PARENT
:
205 case wxTREE_NEXT_PREVIOUS
:
206 flag
= TVGN_PREVIOUS
;
208 case wxTREE_NEXT_PREVIOUSVISIBLE
:
209 flag
= TVGN_PREVIOUSVISIBLE
;
211 case wxTREE_NEXT_ROOT
:
218 return (long) TreeView_GetNextItem( (HWND
) GetHWND(), (HTREEITEM
) item
, flag
);
221 bool wxTreeCtrl::ItemHasChildren(const long item
) const
224 item2
.hItem
= (HTREEITEM
) item
;
225 item2
.mask
= TVIF_CHILDREN
;
226 TreeView_GetItem((HWND
) GetHWND(), &item2
);
227 return (item2
.cChildren
!= 0);
230 long wxTreeCtrl::GetChild(const long item
) const
232 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_CHILD
, (LPARAM
)item
);
235 long wxTreeCtrl::GetParent(const long item
) const
237 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_PARENT
, (LPARAM
)item
);
240 long wxTreeCtrl::GetFirstVisibleItem(void) const
242 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_FIRSTVISIBLE
, 0);
245 long wxTreeCtrl::GetNextVisibleItem(const long item
) const
247 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_NEXTVISIBLE
, (LPARAM
)item
);
250 long wxTreeCtrl::GetSelection(void) const
252 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_CARET
, 0);
255 long wxTreeCtrl::GetRootItem(void) const
257 return (long) ::SendMessage((HWND
) GetHWND(), TVM_GETNEXTITEM
, TVGN_ROOT
, 0);
260 // TODO: convert mask
261 bool wxTreeCtrl::GetItem(wxTreeItem
& info
) const
264 tvItem
.hItem
= (HTREEITEM
)info
.m_itemId
;
265 tvItem
.pszText
= NULL
;
267 if ( info
.m_mask
& wxTREE_MASK_TEXT
)
269 tvItem
.mask
|= TVIF_TEXT
;
270 tvItem
.pszText
= new char[513];
271 tvItem
.cchTextMax
= 512;
273 if ( info
.m_mask
& wxTREE_MASK_DATA
)
274 tvItem
.mask
|= TVIF_PARAM
;
276 bool success
= TreeView_GetItem((HWND
)GetHWND(), &tvItem
) != 0;
280 wxLogSysError("TreeView_GetItem failed");
283 delete[] tvItem
.pszText
;
288 wxConvertFromMSWTreeItem(info
, tvItem
);
291 delete[] tvItem
.pszText
;
296 bool wxTreeCtrl::SetItem(wxTreeItem
& info
)
299 wxConvertToMSWTreeItem(info
, item
);
300 return (::SendMessage((HWND
) GetHWND(), TVM_SETITEM
, 0, (LPARAM
)&item
) != 0);
303 int wxTreeCtrl::GetItemState(const long item
, const long stateMask
) const
307 info
.m_mask
= wxTREE_MASK_STATE
;
308 info
.m_stateMask
= stateMask
;
309 info
.m_itemId
= item
;
317 bool wxTreeCtrl::SetItemState(const long item
, const long state
, const long stateMask
)
321 info
.m_mask
= wxTREE_MASK_STATE
;
322 info
.m_state
= state
;
323 info
.m_stateMask
= stateMask
;
324 info
.m_itemId
= item
;
326 return SetItem(info
);
329 bool wxTreeCtrl::SetItemImage(const long item
, const int image
, const int selImage
)
333 info
.m_mask
= wxTREE_MASK_IMAGE
;
334 info
.m_image
= image
;
337 info
.m_selectedImage
= selImage
;
338 info
.m_mask
|= wxTREE_MASK_SELECTED_IMAGE
;
340 info
.m_itemId
= item
;
342 return SetItem(info
);
345 wxString
wxTreeCtrl::GetItemText(const long item
) const
349 info
.m_mask
= wxTREE_MASK_TEXT
;
350 info
.m_itemId
= item
;
357 void wxTreeCtrl::SetItemText(const long item
, const wxString
& str
)
361 info
.m_mask
= wxTREE_MASK_TEXT
;
362 info
.m_itemId
= item
;
368 long wxTreeCtrl::GetItemData(const long item
) const
372 info
.m_mask
= wxTREE_MASK_DATA
;
373 info
.m_itemId
= item
;
380 bool wxTreeCtrl::SetItemData(const long item
, long data
)
384 info
.m_mask
= wxTREE_MASK_DATA
;
385 info
.m_itemId
= item
;
388 return SetItem(info
);
391 bool wxTreeCtrl::GetItemRect(const long item
, wxRectangle
& rect
, bool textOnly
) const
395 *(HTREEITEM
*)& rect2
= (HTREEITEM
) item
;
396 bool success
= (::SendMessage((HWND
) GetHWND(), TVM_GETITEMRECT
, (WPARAM
)textOnly
,
397 (LPARAM
)&rect2
) != 0);
401 rect
.width
= rect2
.right
- rect2
.left
;
402 rect
.height
= rect2
.bottom
- rect2
.left
;
406 wxTextCtrl
& wxTreeCtrl::GetEditControl(void) const
408 HWND hWnd
= (HWND
) TreeView_GetEditControl((HWND
) GetHWND());
409 ((wxTreeCtrl
*)this)->m_textCtrl
.SetHWND((WXHWND
) hWnd
);
410 return (wxTextCtrl
&) m_textCtrl
;
414 bool wxTreeCtrl::DeleteItem(const long item
)
416 return (TreeView_DeleteItem((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
419 bool wxTreeCtrl::ExpandItem(const long item
, const int action
)
421 UINT mswAction
= TVE_EXPAND
;
424 case wxTREE_EXPAND_EXPAND
:
425 mswAction
= TVE_EXPAND
;
427 case wxTREE_EXPAND_COLLAPSE
:
428 mswAction
= TVE_COLLAPSE
;
429 case wxTREE_EXPAND_COLLAPSE_RESET
:
430 mswAction
= TVE_COLLAPSERESET
;
431 case wxTREE_EXPAND_TOGGLE
:
432 mswAction
= TVE_TOGGLE
;
437 return (TreeView_Expand((HWND
) GetHWND(), (HTREEITEM
) item
, mswAction
) != 0);
440 long wxTreeCtrl::InsertItem(const long parent
, wxTreeItem
& info
, const long insertAfter
)
442 TV_INSERTSTRUCT tvInsertStruct
;
443 tvInsertStruct
.hParent
= (HTREEITEM
) parent
;
444 tvInsertStruct
.hInsertAfter
= (HTREEITEM
) insertAfter
;
446 wxConvertToMSWTreeItem(info
, tvInsertStruct
.item
);
448 return (long) TreeView_InsertItem((HWND
) GetHWND(), & tvInsertStruct
);
451 long wxTreeCtrl::InsertItem(const long parent
, const wxString
& label
, const int image
, const int selImage
,
452 const long insertAfter
)
456 info
.m_mask
= wxTREE_MASK_TEXT
;
459 info
.m_mask
|= wxTREE_MASK_IMAGE
| wxTREE_MASK_SELECTED_IMAGE
;
460 info
.m_image
= image
;
461 if ( selImage
== -1 )
462 info
.m_selectedImage
= image
;
464 info
.m_selectedImage
= selImage
;
467 return InsertItem(parent
, info
, insertAfter
);
470 bool wxTreeCtrl::SelectItem(const long item
)
472 return (TreeView_SelectItem((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
475 bool wxTreeCtrl::ScrollTo(const long item
)
477 return (TreeView_SelectSetFirstVisible((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
480 bool wxTreeCtrl::DeleteAllItems(void)
482 return (TreeView_DeleteAllItems((HWND
) GetHWND()) != 0);
485 wxTextCtrl
& wxTreeCtrl::Edit(const long item
)
487 HWND hWnd
= (HWND
) TreeView_EditLabel((HWND
) GetHWND(), item
);
488 m_textCtrl
.SetHWND((WXHWND
) hWnd
);
492 long wxTreeCtrl::HitTest(const wxPoint
& point
, int& flags
)
494 TV_HITTESTINFO hitTestInfo
;
495 hitTestInfo
.pt
.x
= (int) point
.x
;
496 hitTestInfo
.pt
.y
= (int) point
.y
;
498 TreeView_HitTest((HWND
) GetHWND(), & hitTestInfo
);
501 if ( hitTestInfo
.flags
& TVHT_ABOVE
)
502 flags
|= wxTREE_HITTEST_ABOVE
;
503 if ( hitTestInfo
.flags
& TVHT_BELOW
)
504 flags
|= wxTREE_HITTEST_BELOW
;
505 if ( hitTestInfo
.flags
& TVHT_NOWHERE
)
506 flags
|= wxTREE_HITTEST_NOWHERE
;
507 if ( hitTestInfo
.flags
& TVHT_ONITEMBUTTON
)
508 flags
|= wxTREE_HITTEST_ONITEMBUTTON
;
509 if ( hitTestInfo
.flags
& TVHT_ONITEMICON
)
510 flags
|= wxTREE_HITTEST_ONITEMICON
;
511 if ( hitTestInfo
.flags
& TVHT_ONITEMINDENT
)
512 flags
|= wxTREE_HITTEST_ONITEMINDENT
;
513 if ( hitTestInfo
.flags
& TVHT_ONITEMLABEL
)
514 flags
|= wxTREE_HITTEST_ONITEMLABEL
;
515 if ( hitTestInfo
.flags
& TVHT_ONITEMRIGHT
)
516 flags
|= wxTREE_HITTEST_ONITEMRIGHT
;
517 if ( hitTestInfo
.flags
& TVHT_ONITEMSTATEICON
)
518 flags
|= wxTREE_HITTEST_ONITEMSTATEICON
;
519 if ( hitTestInfo
.flags
& TVHT_TOLEFT
)
520 flags
|= wxTREE_HITTEST_TOLEFT
;
521 if ( hitTestInfo
.flags
& TVHT_TORIGHT
)
522 flags
|= wxTREE_HITTEST_TORIGHT
;
524 return (long) hitTestInfo
.hItem
;
528 wxImageList *wxTreeCtrl::CreateDragImage(const long item)
533 bool wxTreeCtrl::SortChildren(const long item
)
535 return (TreeView_SortChildren((HWND
) GetHWND(), (HTREEITEM
) item
, 0) != 0);
538 bool wxTreeCtrl::EnsureVisible(const long item
)
540 return (TreeView_EnsureVisible((HWND
) GetHWND(), (HTREEITEM
) item
) != 0);
543 bool wxTreeCtrl::MSWCommand(const WXUINT cmd
, const WXWORD id
)
545 if (cmd
== EN_UPDATE
)
547 wxCommandEvent
event(wxEVT_COMMAND_TEXT_UPDATED
, id
);
548 event
.SetEventObject( this );
549 ProcessCommand(event
);
552 else if (cmd
== EN_KILLFOCUS
)
554 wxCommandEvent
event(wxEVT_KILL_FOCUS
, id
);
555 event
.SetEventObject( this );
556 ProcessCommand(event
);
562 bool wxTreeCtrl::MSWNotify(const WXWPARAM wParam
, const WXLPARAM lParam
)
564 wxTreeEvent
event(0, m_windowId
);
566 NMHDR
* hdr1
= (NMHDR
*) lParam
;
567 switch ( hdr1
->code
)
571 eventType
= wxEVT_COMMAND_TREE_BEGIN_DRAG
;
572 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
573 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
574 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
575 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
578 case TVN_BEGINLABELEDIT
:
580 eventType
= wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT
;
581 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
582 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
587 eventType
= wxEVT_COMMAND_TREE_BEGIN_RDRAG
;
588 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
589 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
590 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
591 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
596 eventType
= wxEVT_COMMAND_TREE_DELETE_ITEM
;
597 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
598 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemOld
, (HWND
) GetHWND());
599 event
.m_pointDrag
.x
= hdr
->ptDrag
.x
;
600 event
.m_pointDrag
.y
= hdr
->ptDrag
.y
;
603 case TVN_ENDLABELEDIT
:
605 eventType
= wxEVT_COMMAND_TREE_END_LABEL_EDIT
;
606 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
607 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
610 case TVN_GETDISPINFO
:
612 eventType
= wxEVT_COMMAND_TREE_GET_INFO
;
613 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
614 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
617 case TVN_ITEMEXPANDING
:
619 eventType
= wxEVT_COMMAND_TREE_ITEM_EXPANDING
;
620 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
621 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
623 switch ( hdr
->action
)
626 event
.m_code
= wxTREE_EXPAND_EXPAND
;
629 event
.m_code
= wxTREE_EXPAND_COLLAPSE
;
630 case TVE_COLLAPSERESET
:
631 event
.m_code
= wxTREE_EXPAND_COLLAPSE_RESET
;
633 event
.m_code
= wxTREE_EXPAND_TOGGLE
;
640 case TVN_ITEMEXPANDED
:
642 eventType
= wxEVT_COMMAND_TREE_ITEM_EXPANDED
;
643 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
644 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
645 switch ( hdr
->action
)
648 event
.m_code
= wxTREE_EXPAND_EXPAND
;
651 event
.m_code
= wxTREE_EXPAND_COLLAPSE
;
652 case TVE_COLLAPSERESET
:
653 event
.m_code
= wxTREE_EXPAND_COLLAPSE_RESET
;
655 event
.m_code
= wxTREE_EXPAND_TOGGLE
;
664 eventType
= wxEVT_COMMAND_TREE_KEY_DOWN
;
665 TV_KEYDOWN
*info
= (TV_KEYDOWN
*)lParam
;
666 event
.m_code
= wxCharCodeMSWToWX(info
->wVKey
);
671 eventType
= wxEVT_COMMAND_TREE_SEL_CHANGED
;
672 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
673 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
674 event
.m_oldItem
= (long) hdr
->itemNew
.hItem
;
678 case TVN_SELCHANGING
:
680 eventType
= wxEVT_COMMAND_TREE_SEL_CHANGING
;
681 NM_TREEVIEW
* hdr
= (NM_TREEVIEW
*)lParam
;
682 wxConvertFromMSWTreeItem(event
.m_item
, hdr
->itemNew
, (HWND
) GetHWND());
683 event
.m_oldItem
= (long) hdr
->itemNew
.hItem
;
686 case TVN_SETDISPINFO
:
688 eventType
= wxEVT_COMMAND_TREE_SET_INFO
;
689 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
690 wxConvertFromMSWTreeItem(event
.m_item
, info
->item
, (HWND
) GetHWND());
695 return wxControl::MSWNotify(wParam
, lParam
);
699 event
.SetEventObject( this );
700 event
.SetEventType(eventType
);
702 if ( !GetEventHandler()->ProcessEvent(event
) )
705 if (hdr1
->code
== TVN_GETDISPINFO
)
707 TV_DISPINFO
*info
= (TV_DISPINFO
*)lParam
;
708 wxConvertToMSWTreeItem(event
.m_item
, info
->item
);
714 // Tree item structure
715 wxTreeItem::wxTreeItem(void)
722 m_selectedImage
= -1;
727 // If getFullInfo is TRUE, we explicitly query for more info if we haven't got it all.
728 static void wxConvertFromMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
, HWND getFullInfo
)
730 info
.m_data
= tvItem
.lParam
;
733 info
.m_stateMask
= 0;
735 long oldMask
= tvItem
.mask
;
737 bool needText
= FALSE
;
738 if (getFullInfo
!= 0)
740 if ( tvItem
.mask
& TVIF_TEXT
)
747 tvItem
.pszText
= new char[513];
748 tvItem
.cchTextMax
= 512;
750 tvItem
.mask
|= TVIF_HANDLE
| TVIF_STATE
| TVIF_TEXT
| TVIF_IMAGE
| TVIF_SELECTEDIMAGE
| TVIF_CHILDREN
| TVIF_PARAM
;
751 ::SendMessage(getFullInfo
, TVM_GETITEM
, 0, (LPARAM
)& tvItem
) ;
754 if ( tvItem
.mask
& TVIF_HANDLE
)
756 info
.m_mask
|= wxTREE_MASK_HANDLE
;
757 info
.m_itemId
= (long) tvItem
.hItem
;
759 if ( tvItem
.mask
& TVIF_STATE
)
761 info
.m_mask
|= wxTREE_MASK_STATE
;
762 if ( tvItem
.stateMask
& TVIS_BOLD
)
764 info
.m_stateMask
|= wxTREE_STATE_BOLD
;
765 if ( tvItem
.state
& TVIS_BOLD
)
766 info
.m_state
|= wxTREE_STATE_BOLD
;
769 if ( tvItem
.stateMask
& TVIS_CUT
)
771 info
.m_stateMask
|= wxTREE_STATE_CUT
;
772 if ( tvItem
.state
& TVIS_CUT
)
773 info
.m_state
|= wxTREE_STATE_CUT
;
776 if ( tvItem
.stateMask
& TVIS_DROPHILITED
)
778 info
.m_stateMask
|= wxTREE_STATE_DROPHILITED
;
779 if ( tvItem
.state
& TVIS_DROPHILITED
)
780 info
.m_state
|= wxTREE_STATE_DROPHILITED
;
782 if ( tvItem
.stateMask
& TVIS_EXPANDED
)
784 info
.m_stateMask
|= wxTREE_STATE_EXPANDED
;
785 if ( tvItem
.state
& TVIS_EXPANDED
)
786 info
.m_state
|= wxTREE_STATE_EXPANDED
;
788 if ( tvItem
.stateMask
& TVIS_EXPANDEDONCE
)
790 info
.m_stateMask
|= wxTREE_STATE_EXPANDEDONCE
;
791 if ( tvItem
.state
& TVIS_EXPANDEDONCE
)
792 info
.m_state
|= wxTREE_STATE_EXPANDEDONCE
;
794 if ( tvItem
.stateMask
& TVIS_FOCUSED
)
796 info
.m_stateMask
|= wxTREE_STATE_FOCUSED
;
797 if ( tvItem
.state
& TVIS_FOCUSED
)
798 info
.m_state
|= wxTREE_STATE_FOCUSED
;
800 if ( tvItem
.stateMask
& TVIS_SELECTED
)
802 info
.m_stateMask
|= wxTREE_STATE_SELECTED
;
803 if ( tvItem
.state
& TVIS_SELECTED
)
804 info
.m_state
|= wxTREE_STATE_SELECTED
;
808 if ( tvItem
.mask
& TVIF_TEXT
)
810 info
.m_mask
|= wxTREE_MASK_TEXT
;
811 info
.m_text
= tvItem
.pszText
;
813 if ( tvItem
.mask
& TVIF_IMAGE
)
815 info
.m_mask
|= wxTREE_MASK_IMAGE
;
816 info
.m_image
= tvItem
.iImage
;
818 if ( tvItem
.mask
& TVIF_SELECTEDIMAGE
)
820 info
.m_mask
|= wxTREE_MASK_SELECTED_IMAGE
;
821 info
.m_selectedImage
= tvItem
.iSelectedImage
;
823 if ( tvItem
.mask
& TVIF_CHILDREN
)
825 info
.m_mask
|= wxTREE_MASK_CHILDREN
;
826 info
.m_children
= tvItem
.cChildren
;
828 if ( tvItem
.mask
& TVIF_PARAM
)
829 info
.m_mask
|= wxTREE_MASK_DATA
;
834 delete[] tvItem
.pszText
;
836 tvItem
.mask
= oldMask
;
839 static void wxConvertToMSWTreeItem(wxTreeItem
& info
, TV_ITEM
& tvItem
)
841 tvItem
.hItem
= (HTREEITEM
) info
.m_itemId
;
843 tvItem
.iImage
= info
.m_image
;
844 tvItem
.iSelectedImage
= info
.m_selectedImage
;
845 tvItem
.cChildren
= info
.m_children
;
846 tvItem
.lParam
= info
.m_data
;
848 tvItem
.stateMask
= 0;
851 if (info
.m_mask
& wxTREE_MASK_HANDLE
)
852 tvItem
.mask
|= TVIF_HANDLE
;
853 if (info
.m_mask
& wxTREE_MASK_STATE
)
854 tvItem
.mask
|= TVIF_STATE
;
855 if (info
.m_mask
& wxTREE_MASK_TEXT
)
857 tvItem
.mask
|= TVIF_TEXT
;
858 tvItem
.pszText
= (char *) (const char *)info
.m_text
;
859 if ( tvItem
.pszText
)
860 tvItem
.cchTextMax
= info
.m_text
.Length();
862 tvItem
.cchTextMax
= 0;
864 if (info
.m_mask
& wxTREE_MASK_IMAGE
)
865 tvItem
.mask
|= TVIF_IMAGE
;
866 if (info
.m_mask
& wxTREE_MASK_SELECTED_IMAGE
)
867 tvItem
.mask
|= TVIF_SELECTEDIMAGE
;
868 if (info
.m_mask
& wxTREE_MASK_CHILDREN
)
869 tvItem
.mask
|= TVIF_CHILDREN
;
870 if (info
.m_mask
& wxTREE_MASK_DATA
)
871 tvItem
.mask
|= TVIF_PARAM
;
873 if (info
.m_stateMask
& wxTREE_STATE_BOLD
)
875 tvItem
.stateMask
|= TVIS_BOLD
;
876 tvItem
.state
|= TVIS_BOLD
;
878 if (info
.m_stateMask
& wxTREE_STATE_CUT
)
880 tvItem
.stateMask
|= TVIS_CUT
;
881 if ( info
.m_state
& wxTREE_STATE_CUT
)
882 tvItem
.state
|= TVIS_CUT
;
884 if (info
.m_stateMask
& wxTREE_STATE_DROPHILITED
)
886 tvItem
.stateMask
|= TVIS_DROPHILITED
;
887 if ( info
.m_state
& wxTREE_STATE_DROPHILITED
)
888 tvItem
.state
|= TVIS_DROPHILITED
;
890 if (info
.m_stateMask
& wxTREE_STATE_EXPANDED
)
892 tvItem
.stateMask
|= TVIS_EXPANDED
;
893 if ( info
.m_state
& wxTREE_STATE_EXPANDED
)
894 tvItem
.state
|= TVIS_EXPANDED
;
896 if (info
.m_stateMask
& wxTREE_STATE_EXPANDEDONCE
)
898 tvItem
.stateMask
|= TVIS_EXPANDEDONCE
;
899 if ( info
.m_state
& wxTREE_STATE_EXPANDEDONCE
)
900 tvItem
.state
|= TVIS_EXPANDEDONCE
;
902 if (info
.m_stateMask
& wxTREE_STATE_FOCUSED
)
904 tvItem
.stateMask
|= TVIS_FOCUSED
;
905 if ( info
.m_state
& wxTREE_STATE_FOCUSED
)
906 tvItem
.state
|= TVIS_FOCUSED
;
908 if (info
.m_stateMask
& wxTREE_STATE_SELECTED
)
910 tvItem
.stateMask
|= TVIS_SELECTED
;
911 if ( info
.m_state
& wxTREE_STATE_SELECTED
)
912 tvItem
.state
|= TVIS_SELECTED
;
917 IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent
, wxCommandEvent
)
919 wxTreeEvent::wxTreeEvent(WXTYPE commandType
, int id
):
920 wxCommandEvent(commandType
, id
)