]>
Commit | Line | Data |
---|---|---|
ae8351fc JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: edtree.cpp | |
3 | // Purpose: Resource editor project management tree | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "edtree.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx/wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/wx.h" | |
25 | ||
26 | #include "wx/checkbox.h" | |
27 | #include "wx/button.h" | |
28 | #include "wx/choice.h" | |
29 | #include "wx/listbox.h" | |
30 | #include "wx/radiobox.h" | |
31 | #include "wx/statbox.h" | |
32 | #include "wx/gauge.h" | |
33 | #include "wx/slider.h" | |
34 | #include "wx/textctrl.h" | |
35 | #endif | |
36 | ||
37 | #include "edtree.h" | |
38 | #include "reseditr.h" | |
39 | ||
40 | BEGIN_EVENT_TABLE(wxResourceEditorProjectTree, wxTreeCtrl) | |
f6bcfd97 | 41 | EVT_LEFT_DCLICK(wxResourceEditorProjectTree::LeftDClick) |
e89ba6b3 | 42 | //EVT_LEFT_DOWN(wxResourceEditorProjectTree::LeftClick) |
f6bcfd97 | 43 | EVT_TREE_SEL_CHANGED(IDC_TREECTRL, wxResourceEditorProjectTree::OnSelChanged) |
ae8351fc JS |
44 | END_EVENT_TABLE() |
45 | ||
46 | wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, | |
f6bcfd97 BP |
47 | long style): |
48 | wxTreeCtrl(parent, id, pos, size, style) | |
ae8351fc JS |
49 | { |
50 | } | |
51 | ||
e89ba6b3 GT |
52 | /* |
53 | void wxResourceEditorProjectTree::LeftClick(wxMouseEvent &event) | |
54 | { | |
55 | long sel = GetSelection(); | |
56 | if (sel == -1) | |
57 | return; | |
58 | ||
59 | if (GetItemData(sel) == 0) | |
60 | { | |
61 | event.Skip(); | |
62 | return; | |
63 | } | |
64 | ||
65 | wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource(); | |
66 | ||
67 | wxString resType(res->GetType()); | |
68 | ||
69 | wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent(); | |
70 | wxResourceManager *manager = frame->manager; | |
71 | ||
72 | long selParent = wxTreeCtrl::GetParent(sel); | |
73 | ||
74 | if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel") | |
75 | { | |
76 | wxWindow *win = manager->FindWindowForResource(res); | |
77 | ||
78 | // Check to see if the item selected in on the current dialog being | |
79 | // displayed. If not, then we will have to find the items parent dialog | |
80 | if (!win) | |
81 | { | |
82 | // The item is on a dialog other than the one currently being | |
83 | // shown/worked on, so find the parent dialog, switch to use | |
84 | // its resource manager, and then find the window in the dialog | |
85 | wxItemResource* resParent = ((wxResourceTreeData *)GetItemData(selParent))->GetResource(); | |
86 | wxResourceManager::GetCurrentResourceManager()->Edit(resParent); | |
87 | win = manager->FindWindowForResource(res); | |
88 | } | |
89 | / * | |
90 | if (win) | |
91 | manager->GetCurrentResourceManager()->EditWindow(win); | |
92 | * / | |
93 | } | |
94 | // else | |
95 | // manager->EditSelectedResource(); | |
96 | ||
97 | event.Skip(); | |
98 | ||
99 | } // wxResourceEditorProjectTree::LeftClick() | |
100 | */ | |
101 | ||
fd71308f | 102 | void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event)) |
ae8351fc | 103 | { |
ae8351fc JS |
104 | long sel = GetSelection(); |
105 | if (sel == -1) | |
106 | return; | |
f6bcfd97 | 107 | |
ae8351fc JS |
108 | if (GetItemData(sel) == 0) |
109 | return; | |
f6bcfd97 | 110 | |
4158c64a GT |
111 | wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource(); |
112 | ||
ae8351fc | 113 | wxString resType(res->GetType()); |
4158c64a | 114 | |
ae8351fc JS |
115 | wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent(); |
116 | wxResourceManager *manager = frame->manager; | |
4158c64a | 117 | |
e89ba6b3 GT |
118 | long selParent = wxTreeCtrl::GetParent(sel); |
119 | ||
120 | wxWindow *win = NULL; | |
4158c64a | 121 | if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel") |
e89ba6b3 GT |
122 | { |
123 | win = manager->FindWindowForResource(res); | |
124 | ||
125 | // Check to see if the item selected in on the current dialog being | |
126 | // displayed. If not, then we will have to find the items parent dialog | |
127 | if (!win) | |
128 | { | |
129 | // The item is on a dialog other than the one currently being | |
130 | // shown/worked on, so find the parent dialog, switch to use | |
131 | // its resource manager, and then find the window in the dialog | |
132 | wxItemResource* resParent = ((wxResourceTreeData *)GetItemData(selParent))->GetResource(); | |
133 | wxResourceManager::GetCurrentResourceManager()->Edit(resParent); | |
134 | win = manager->FindWindowForResource(res); | |
135 | } | |
136 | ||
137 | if (win) | |
138 | manager->GetCurrentResourceManager()->EditWindow(win); | |
139 | } | |
4158c64a | 140 | else |
e89ba6b3 GT |
141 | { |
142 | // manager->EditSelectedResource(); | |
143 | win = manager->FindWindowForResource(res); | |
144 | wxResourceManager::GetCurrentResourceManager()->EditWindow(win); | |
145 | } | |
146 | ||
147 | ||
148 | } // wxResourceEditorProjectTree::LeftDClick() | |
149 | ||
ae8351fc | 150 | |
fd71308f | 151 | void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event)) |
ae8351fc JS |
152 | { |
153 | long sel = GetSelection(); | |
154 | if (sel == -1) | |
155 | return; | |
f6bcfd97 | 156 | |
ae8351fc JS |
157 | if (GetItemData(sel) == 0) |
158 | return; | |
f6bcfd97 | 159 | |
ae8351fc JS |
160 | if (m_invalid) |
161 | return; | |
f6bcfd97 | 162 | |
1195ec42 | 163 | wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource(); |
ae8351fc | 164 | wxString resType(res->GetType()); |
e89ba6b3 GT |
165 | |
166 | wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent(); | |
167 | wxResourceManager *manager = frame->manager; | |
168 | ||
169 | long selParent = wxTreeCtrl::GetParent(sel); | |
170 | ||
ae8351fc | 171 | if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel") |
e89ba6b3 GT |
172 | { |
173 | wxWindow *win = manager->FindWindowForResource(res); | |
174 | ||
175 | // Check to see if the item selected in on the current dialog being | |
176 | // displayed. If not, then we will have to find the items parent dialog | |
177 | if (!win) | |
178 | { | |
179 | // The item is on a dialog other than the one currently being | |
180 | // shown/worked on, so find the parent dialog, switch to use | |
181 | // its resource manager, and then find the window in the dialog | |
182 | wxItemResource* resParent = ((wxResourceTreeData *)GetItemData(selParent))->GetResource(); | |
183 | wxResourceManager::GetCurrentResourceManager()->Edit(resParent); | |
184 | win = manager->FindWindowForResource(res); | |
185 | } | |
186 | ||
187 | // if (win) | |
188 | // manager->GetCurrentResourceManager()->EditWindow(win); | |
189 | } | |
190 | else | |
191 | wxResourceManager::GetCurrentResourceManager()->Edit(res); | |
192 | ||
193 | } // wxResourceEditorProjectTree::OnSelChanged() | |
ae8351fc | 194 |