]>
git.saurik.com Git - wxWidgets.git/blob - samples/treectrl/treetest.h
e0299c00459a7d3105a82d81fa42c7ec39aebe47
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTreeCtrl sample
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // Define a new application type
13 class MyApp
: public wxApp
19 class MyTreeItemData
: public wxTreeItemData
22 MyTreeItemData(const wxString
& desc
) : m_desc(desc
) { }
24 void ShowInfo(wxTreeCtrl
*tree
);
30 class MyTreeCtrl
: public wxTreeCtrl
40 MyTreeCtrl(wxWindow
*parent
, const wxWindowID id
,
41 const wxPoint
& pos
, const wxSize
& size
,
43 virtual ~MyTreeCtrl();
45 void OnBeginDrag(wxTreeEvent
& event
);
46 void OnBeginRDrag(wxTreeEvent
& event
);
47 void OnBeginLabelEdit(wxTreeEvent
& event
);
48 void OnEndLabelEdit(wxTreeEvent
& event
);
49 void OnDeleteItem(wxTreeEvent
& event
);
50 void OnGetInfo(wxTreeEvent
& event
);
51 void OnSetInfo(wxTreeEvent
& event
);
52 void OnItemExpanded(wxTreeEvent
& event
);
53 void OnItemExpanding(wxTreeEvent
& event
);
54 void OnItemCollapsed(wxTreeEvent
& event
);
55 void OnItemCollapsing(wxTreeEvent
& event
);
56 void OnSelChanged(wxTreeEvent
& event
);
57 void OnSelChanging(wxTreeEvent
& event
);
58 void OnTreeKeyDown(wxTreeEvent
& event
);
59 void OnItemActivated(wxTreeEvent
& event
);
61 void GetItemsRecursively(const wxTreeItemId
& idParent
, long cookie
);
63 void AddTestItemsToTree(size_t numChildren
,
66 void DoSortChildren(const wxTreeItemId
& item
, bool reverse
= FALSE
)
67 { m_reverseSort
= reverse
; wxTreeCtrl::SortChildren(item
); }
70 virtual int OnCompareItems(const wxTreeItemId
& item1
,
71 const wxTreeItemId
& item2
);
74 void AddItemsRecursively(const wxTreeItemId
& idParent
,
79 wxImageList
*m_imageListNormal
;
80 bool m_reverseSort
; // flag for OnCompareItems
82 // NB: due to an ugly wxMSW hack you _must_ use DECLARE_DYNAMIC_CLASS()
83 // if you want your overloaded OnCompareItems() to be called.
84 // OTOH, if you don't want it you may omit the next line - this will
85 // make default (alphabetical) sorting much faster under wxMSW.
86 DECLARE_DYNAMIC_CLASS(MyTreeCtrl
)
90 // Define a new frame type
91 class MyFrame
: public wxFrame
95 MyFrame(const wxString
& title
, int x
, int y
, int w
, int h
);
99 void OnQuit(wxCommandEvent
& event
);
100 void OnAbout(wxCommandEvent
& event
);
101 void OnDump(wxCommandEvent
& event
);
102 void OnDelete(wxCommandEvent
& event
);
103 void OnDeleteChildren(wxCommandEvent
& event
);
104 void OnDeleteAll(wxCommandEvent
& event
);
105 void OnRecreate(wxCommandEvent
& event
);
107 void OnSetBold(wxCommandEvent
& WXUNUSED(event
)) { DoSetBold(TRUE
); }
108 void OnClearBold(wxCommandEvent
& WXUNUSED(event
)) { DoSetBold(FALSE
); }
110 void OnRename(wxCommandEvent
& event
);
111 void OnSort(wxCommandEvent
& event
) { DoSort(); }
112 void OnSortRev(wxCommandEvent
& event
) { DoSort(TRUE
); }
115 void DoSort(bool reverse
= FALSE
);
117 MyTreeCtrl
*m_treeCtrl
;
119 void DoSetBold(bool bold
= TRUE
);
121 DECLARE_EVENT_TABLE()
124 // menu and control ids
136 TreeTest_DeleteChildren
,