]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/dialoged/src/edtree.cpp
Added wxMouseCaptureChangedEvent. Added some missing Capture related methods.
[wxWidgets.git] / utils / dialoged / src / edtree.cpp
index 00086583d88661e7994650c5eb4b26d53b3705ca..26babac2e52b1ebcde1c3efd80eef4848acd2d21 100644 (file)
 #include "reseditr.h"
 
 BEGIN_EVENT_TABLE(wxResourceEditorProjectTree, wxTreeCtrl)
 #include "reseditr.h"
 
 BEGIN_EVENT_TABLE(wxResourceEditorProjectTree, wxTreeCtrl)
-    EVT_LEFT_DCLICK(wxResourceEditorProjectTree::LeftDClick)
-    EVT_TREE_SEL_CHANGED(IDC_TREECTRL, wxResourceEditorProjectTree::OnSelChanged)
+EVT_LEFT_DCLICK(wxResourceEditorProjectTree::LeftDClick)
+//EVT_LEFT_DOWN(wxResourceEditorProjectTree::LeftClick)
+EVT_TREE_SEL_CHANGED(IDC_TREECTRL, wxResourceEditorProjectTree::OnSelChanged)
 END_EVENT_TABLE()
 
 wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
 END_EVENT_TABLE()
 
 wxResourceEditorProjectTree::wxResourceEditorProjectTree(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
-        long style):
-     wxTreeCtrl(parent, id, pos, size, style)
+                                                         long style):
+wxTreeCtrl(parent, id, pos, size, style)
 {
 }
 
 {
 }
 
-void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event))
+/*
+void wxResourceEditorProjectTree::LeftClick(wxMouseEvent &event)
 {
 {
-#if 0
     long sel = GetSelection();
     if (sel == -1)
         return;
     long sel = GetSelection();
     if (sel == -1)
         return;
-
+    
     if (GetItemData(sel) == 0)
     if (GetItemData(sel) == 0)
+    {
+        event.Skip();
         return;
         return;
+    }
+    
+    wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
 
 
-    wxItemResource* res = (wxResourceTreeData *)GetItemData(sel)->GetResource();
     wxString resType(res->GetType());
     wxString resType(res->GetType());
+
+    wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
+    wxResourceManager *manager = frame->manager;
+
+    long selParent = wxTreeCtrl::GetParent(sel);
+
     if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
     if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
+    {
+        wxWindow *win = manager->FindWindowForResource(res);
+
+        // Check to see if the item selected in on the current dialog being
+        // displayed.  If not, then we will have to find the items parent dialog
+        if (!win)
+        {
+            // The item is on a dialog other than the one currently being
+            // shown/worked on, so find the parent dialog, switch to use
+            // its resource manager, and then find the window in the dialog
+            wxItemResource* resParent = ((wxResourceTreeData *)GetItemData(selParent))->GetResource();
+            wxResourceManager::GetCurrentResourceManager()->Edit(resParent);
+            win = manager->FindWindowForResource(res);
+        }
+/ *
+        if (win)
+            manager->GetCurrentResourceManager()->EditWindow(win);
+* /
+    }
+//    else
+//        manager->EditSelectedResource();
+  
+    event.Skip();
+
+}  // wxResourceEditorProjectTree::LeftClick()
+*/
+
+void wxResourceEditorProjectTree::LeftDClick(wxMouseEvent& WXUNUSED(event))
+{
+    long sel = GetSelection();
+    if (sel == -1)
         return;
         return;
+    
+    if (GetItemData(sel) == 0)
+        return;
+    
+    wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
+
+    wxString resType(res->GetType());
 
     wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
     wxResourceManager *manager = frame->manager;
 
 
     wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
     wxResourceManager *manager = frame->manager;
 
-    manager->EditSelectedResource();
-#endif
-}
+    long selParent = wxTreeCtrl::GetParent(sel);
+
+    wxWindow *win = NULL;
+    if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
+    {
+        win = manager->FindWindowForResource(res);
+
+        // Check to see if the item selected in on the current dialog being
+        // displayed.  If not, then we will have to find the items parent dialog
+        if (!win)
+        {
+            // The item is on a dialog other than the one currently being
+            // shown/worked on, so find the parent dialog, switch to use
+            // its resource manager, and then find the window in the dialog
+            wxItemResource* resParent = ((wxResourceTreeData *)GetItemData(selParent))->GetResource();
+            wxResourceManager::GetCurrentResourceManager()->Edit(resParent);
+            win = manager->FindWindowForResource(res);
+        }
+
+        if (win)
+            manager->GetCurrentResourceManager()->EditWindow(win);
+    }
+    else
+    {
+//        manager->EditSelectedResource();
+        win = manager->FindWindowForResource(res);
+        wxResourceManager::GetCurrentResourceManager()->EditWindow(win);
+    }
+
+
+}  // wxResourceEditorProjectTree::LeftDClick()
+
 
 void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event))
 {
     long sel = GetSelection();
     if (sel == -1)
         return;
 
 void wxResourceEditorProjectTree::OnSelChanged(wxTreeEvent& WXUNUSED(event))
 {
     long sel = GetSelection();
     if (sel == -1)
         return;
-
+    
     if (GetItemData(sel) == 0)
         return;
     if (GetItemData(sel) == 0)
         return;
-
+    
     if (m_invalid)
         return;
     if (m_invalid)
         return;
-
+    
     wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
     wxString resType(res->GetType());
     wxItemResource* res = ((wxResourceTreeData *)GetItemData(sel))->GetResource();
     wxString resType(res->GetType());
-    if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
-        return;
 
 
-    wxResourceManager::GetCurrentResourceManager()->Edit(res);
-}
+    wxResourceEditorFrame *frame = (wxResourceEditorFrame *)wxWindow::GetParent();
+    wxResourceManager *manager = frame->manager;
+
+    long selParent = wxTreeCtrl::GetParent(sel);
+
+    if (resType != "wxDialog" && resType != "wxDialogBox" && resType != "wxPanel")
+    {
+        wxWindow *win = manager->FindWindowForResource(res);
+
+        // Check to see if the item selected in on the current dialog being
+        // displayed.  If not, then we will have to find the items parent dialog
+        if (!win)
+        {
+            // The item is on a dialog other than the one currently being
+            // shown/worked on, so find the parent dialog, switch to use
+            // its resource manager, and then find the window in the dialog
+            wxItemResource* resParent = ((wxResourceTreeData *)GetItemData(selParent))->GetResource();
+            wxResourceManager::GetCurrentResourceManager()->Edit(resParent);
+            win = manager->FindWindowForResource(res);
+        }
+
+//        if (win)
+//            manager->GetCurrentResourceManager()->EditWindow(win);
+    }
+    else
+        wxResourceManager::GetCurrentResourceManager()->Edit(res);
+
+}  // wxResourceEditorProjectTree::OnSelChanged()