]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/edtree.cpp
fixed bug with using wxCommandEvent::GetInt() instead of GetId()
[wxWidgets.git] / utils / dialoged / src / edtree.cpp
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)
41 EVT_LEFT_DCLICK(wxResourceEditorProjectTree::LeftDClick)
42 //EVT_LEFT_DOWN(wxResourceEditorProjectTree::LeftClick)
43 EVT_TREE_SEL_CHANGED(IDC_TREECTRL, wxResourceEditorProjectTree::OnSelChanged)
44 END_EVENT_TABLE()
45
46 wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
47 long style):
48 wxTreeCtrl(parent, id, pos, size, style)
49 {
50 }
51
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
102 void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event))
103 {
104 long sel = GetSelection();
105 if (sel == -1)
106 return;
107
108 if (GetItemData(sel) == 0)
109 return;
110
111 wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
112
113 wxString resType(res->GetType());
114
115 wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
116 wxResourceManager *manager = frame->manager;
117
118 long selParent = wxTreeCtrl::GetParent(sel);
119
120 wxWindow *win = NULL;
121 if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
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 }
140 else
141 {
142 // manager->EditSelectedResource();
143 win = manager->FindWindowForResource(res);
144 wxResourceManager::GetCurrentResourceManager()->EditWindow(win);
145 }
146
147
148 } // wxResourceEditorProjectTree::LeftDClick()
149
150
151 void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event))
152 {
153 long sel = GetSelection();
154 if (sel == -1)
155 return;
156
157 if (GetItemData(sel) == 0)
158 return;
159
160 if (m_invalid)
161 return;
162
163 wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
164 wxString resType(res->GetType());
165
166 wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
167 wxResourceManager *manager = frame->manager;
168
169 long selParent = wxTreeCtrl::GetParent(sel);
170
171 if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
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()
194