1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Resource editor project management tree
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "edtree.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
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"
33 #include "wx/slider.h"
34 #include "wx/textctrl.h"
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
)
46 wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
48 wxTreeCtrl(parent
, id
, pos
, size
, style
)
53 void wxResourceEditorProjectTree::LeftClick(wxMouseEvent &event)
55 long sel = GetSelection();
59 if (GetItemData(sel) == 0)
65 wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
67 wxString resType(res->GetType());
69 wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
70 wxResourceManager *manager = frame->manager;
72 long selParent = wxTreeCtrl::GetParent(sel);
74 if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
76 wxWindow *win = manager->FindWindowForResource(res);
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
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);
91 manager->GetCurrentResourceManager()->EditWindow(win);
95 // manager->EditSelectedResource();
99 } // wxResourceEditorProjectTree::LeftClick()
102 void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent
& WXUNUSED(event
))
104 long sel
= GetSelection();
108 if (GetItemData(sel
) == 0)
111 wxItemResource
* res
= ((wxResourceTreeData
*)GetItemData(sel
))->GetResource();
113 wxString
resType(res
->GetType());
115 wxResourceEditorFrame
*frame
= (wxResourceEditorFrame
*)wxWindow::GetParent();
116 wxResourceManager
*manager
= frame
->manager
;
118 long selParent
= wxTreeCtrl::GetParent(sel
);
120 wxWindow
*win
= NULL
;
121 if (resType
!= "wxDialog" && resType
!= "wxDialogBox" && resType
!= "wxPanel")
123 win
= manager
->FindWindowForResource(res
);
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
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
);
138 manager
->GetCurrentResourceManager()->EditWindow(win
);
142 // manager->EditSelectedResource();
143 win
= manager
->FindWindowForResource(res
);
144 wxResourceManager::GetCurrentResourceManager()->EditWindow(win
);
148 } // wxResourceEditorProjectTree::LeftDClick()
151 void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent
& WXUNUSED(event
))
153 long sel
= GetSelection();
157 if (GetItemData(sel
) == 0)
163 wxItemResource
* res
= ((wxResourceTreeData
*)GetItemData(sel
))->GetResource();
164 wxString
resType(res
->GetType());
166 wxResourceEditorFrame
*frame
= (wxResourceEditorFrame
*)wxWindow::GetParent();
167 wxResourceManager
*manager
= frame
->manager
;
169 long selParent
= wxTreeCtrl::GetParent(sel
);
171 if (resType
!= "wxDialog" && resType
!= "wxDialogBox" && resType
!= "wxPanel")
173 wxWindow
*win
= manager
->FindWindowForResource(res
);
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
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
);
188 // manager->GetCurrentResourceManager()->EditWindow(win);
191 wxResourceManager::GetCurrentResourceManager()->Edit(res
);
193 } // wxResourceEditorProjectTree::OnSelChanged()