]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/utils/wxrcedit/preview.cpp
Updated makefiles etc. for 2.5.1
[wxWidgets.git] / contrib / utils / wxrcedit / preview.cpp
index a7ffa2eacdc3c5f16e47fe3a2ea429edf98768a3..22d9ceeaab0cb237c1c06ab50e4d4580400de54a 100644 (file)
@@ -18,7 +18,7 @@
 #endif
 
 #include "wx/wx.h"
-#include "wx/xrc/xml.h"
+#include "wx/xml/xml.h"
 #include "wx/xrc/xmlres.h"
 #include "wx/config.h"
 #include "wx/log.h"
@@ -157,6 +157,9 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
        if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog")) 
            XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));   
 
+       if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame")) 
+           XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));  
+
        doc.Save(m_TmpFile);
        // wxXmlResource will detect change automatically
    }
@@ -186,7 +189,9 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
        PreviewToolbar();
    else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
        PreviewPanel();
-   
+   else if (XmlGetClass(node) == _T("wxFrame"))
+          PreviewWXFrame();    
+
    wxSetWorkingDirectory(oldcwd);
    wxLog::SetActiveTarget(oldlog);
    
@@ -223,7 +228,7 @@ void PreviewFrame::PreviewToolbar()
 void PreviewFrame::PreviewPanel()
 {
     wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, m_Node->GetPropVal(_T("name"), _T("-1")));
-    
+
     if (panel == NULL)
         wxLogError(_("Cannot preview the panel -- XML resource corrupted."));
     else
@@ -233,6 +238,37 @@ void PreviewFrame::PreviewPanel()
     }
 }
 
+void PreviewFrame::PreviewWXFrame()
+{
+       //for this to work the frame MUST have a child panel!
+
+       wxXmlNode*      child = m_Node;
+       wxString name;
+
+       while( child != NULL)
+       {
+               name = child->GetPropVal(_T("name"), _T("-1"));
+               
+               if(name != _T("-1"))
+               {
+                       wxXmlNode* parent = child->GetParent();
+                       if(parent->GetPropVal(_T("class"),_T("-1")) == _T("wxPanel"))
+                               break;
+               }
+               child = child->GetNext();
+       }
+
+    wxPanel *panel = m_RC->LoadPanel(m_ScrollWin, name);
+    
+    if (panel == NULL)
+        wxLogError(_("Cannot preview the panel -- XML resource corrupted."));
+    else
+    {
+        m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
+                                   0, 0, TRUE);
+    }
+
+}
 
 BEGIN_EVENT_TABLE(PreviewFrame, wxFrame)
     EVT_ENTER_WINDOW(PreviewFrame::OnMouseEnter)