]> git.saurik.com Git - wxWidgets.git/blame - samples/treectrl/treetest.h
internal browser creates temp file in current dir, safer if /tmp doesn't
[wxWidgets.git] / samples / treectrl / treetest.h
CommitLineData
457814b5
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: treetest.h
3// Purpose: wxTreeCtrl sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart and Markus Holzem
5a43154b 9// Licence: wxWindows license
457814b5
JS
10/////////////////////////////////////////////////////////////////////////////
11
12// Define a new application type
5a43154b
VZ
13class MyApp : public wxApp
14{
15public:
16 bool OnInit();
17};
457814b5 18
5a43154b
VZ
19class MyTreeItemData : public wxTreeItemData
20{
21public:
22 MyTreeItemData(const wxString& desc) : m_desc(desc) { }
23
24 void ShowInfo(wxTreeCtrl *tree);
25
26private:
27 wxString m_desc;
457814b5
JS
28};
29
5a43154b 30class MyTreeCtrl : public wxTreeCtrl
457814b5
JS
31{
32public:
5a43154b
VZ
33 enum
34 {
add28c55
VZ
35 TreeCtrlIcon_File,
36 TreeCtrlIcon_Folder
5a43154b
VZ
37 };
38
23fd5130 39 MyTreeCtrl() { }
5a43154b
VZ
40 MyTreeCtrl(wxWindow *parent, const wxWindowID id,
41 const wxPoint& pos, const wxSize& size,
42 long style);
43 virtual ~MyTreeCtrl();
44
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);
b46e8696 58 void OnTreeKeyDown(wxTreeEvent& event);
435fe83e 59 void OnItemActivated(wxTreeEvent& event);
5a43154b 60
ff5bf259
VZ
61 void GetItemsRecursively(const wxTreeItemId& idParent, long cookie);
62
63 void AddTestItemsToTree(size_t numChildren,
64 size_t depth);
4832f7c0 65
e1ee62bd
VZ
66 void DoSortChildren(const wxTreeItemId& item, bool reverse = FALSE)
67 { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }
68
69protected:
70 virtual int OnCompareItems(const wxTreeItemId& item1,
71 const wxTreeItemId& item2);
72
5a43154b
VZ
73private:
74 void AddItemsRecursively(const wxTreeItemId& idParent,
75 size_t nChildren,
4832f7c0 76 size_t depth,
ff5bf259 77 size_t folder);
5a43154b
VZ
78
79 wxImageList *m_imageListNormal;
e1ee62bd 80 bool m_reverseSort; // flag for OnCompareItems
5a43154b 81
23fd5130
VZ
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)
5a43154b 87 DECLARE_EVENT_TABLE()
457814b5
JS
88};
89
90// Define a new frame type
91class MyFrame: public wxFrame
019bf128
UU
92{
93public:
5a43154b
VZ
94 // ctor and dtor
95 MyFrame(const wxString& title, int x, int y, int w, int h);
96 virtual ~MyFrame();
f135ff73 97
5a43154b
VZ
98 // menu callbacks
99 void OnQuit(wxCommandEvent& event);
100 void OnAbout(wxCommandEvent& event);
4832f7c0 101 void OnDump(wxCommandEvent& event);
ff5bf259 102 void OnDelete(wxCommandEvent& event);
372edb9d 103 void OnDeleteChildren(wxCommandEvent& event);
ff5bf259
VZ
104 void OnDeleteAll(wxCommandEvent& event);
105 void OnRecreate(wxCommandEvent& event);
f135ff73 106
6daa0637
RR
107 void OnSetBold(wxCommandEvent& WXUNUSED(event)) { DoSetBold(TRUE); }
108 void OnClearBold(wxCommandEvent& WXUNUSED(event)) { DoSetBold(FALSE); }
add28c55 109
e1ee62bd
VZ
110 void OnRename(wxCommandEvent& event);
111 void OnSort(wxCommandEvent& event) { DoSort(); }
112 void OnSortRev(wxCommandEvent& event) { DoSort(TRUE); }
113
f135ff73 114private:
e1ee62bd
VZ
115 void DoSort(bool reverse = FALSE);
116
5a43154b 117 MyTreeCtrl *m_treeCtrl;
457814b5 118
add28c55
VZ
119 void DoSetBold(bool bold = TRUE);
120
5a43154b
VZ
121 DECLARE_EVENT_TABLE()
122};
457814b5 123
5a43154b
VZ
124// menu and control ids
125enum
126{
127 TreeTest_Quit,
128 TreeTest_About,
4832f7c0 129 TreeTest_Dump,
e1ee62bd
VZ
130 TreeTest_Sort,
131 TreeTest_SortRev,
add28c55
VZ
132 TreeTest_Bold,
133 TreeTest_UnBold,
e1ee62bd 134 TreeTest_Rename,
ff5bf259 135 TreeTest_Delete,
372edb9d 136 TreeTest_DeleteChildren,
ff5bf259
VZ
137 TreeTest_DeleteAll,
138 TreeTest_Recreate,
5a43154b 139 TreeTest_Ctrl = 100
23fd5130 140};