#endif
#include "wx/wx.h"
-#include "wx/xml/xml.h"
-#include "wx/xml/xmlres.h"
+#include "wx/xrc/xml.h"
+#include "wx/xrc/xmlres.h"
#include "wx/config.h"
#include "wx/log.h"
#include "wx/splitter.h"
#include "xmlhelpr.h"
#include "editor.h"
-#include "wx/xml/xh_menu.h"
+#include "wx/xrc/xh_menu.h"
class MyMenubarHandler : public wxMenuBarXmlHandler
{
-void PreviewFrame::Preview(wxXmlNode *node,const wxString &version)
+void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
{
+ wxString version = orig_doc->GetRoot()->GetPropVal(wxT("version"), wxT("0.0.0.0"));
+
while (node->GetParent()->GetParent() != NULL) node = node->GetParent();
{
root->AddProperty(new wxXmlProperty(wxT("version"),version,NULL));
doc.SetRoot(root);
doc.GetRoot()->AddChild(new wxXmlNode(*node));
+ doc.SetFileEncoding(orig_doc->GetFileEncoding());
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
- doc.Save(m_TmpFile, wxXML_IO_BIN);
+ if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame"))
+ XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
+
+ doc.Save(m_TmpFile);
// wxXmlResource will detect change automatically
}
}
m_Node = node;
- m_Version = version;
+ m_Doc = orig_doc;
m_LogCtrl->Clear();
wxLogTextCtrl mylog(m_LogCtrl);
PreviewToolbar();
else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
PreviewPanel();
-
+ else if (XmlGetClass(node) == _T("wxFrame"))
+ PreviewWXFrame();
+
wxSetWorkingDirectory(oldcwd);
wxLog::SetActiveTarget(oldlog);
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
}
}
+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)
void PreviewFrame::OnMouseEnter(wxMouseEvent& event)
{
- if (m_Dirty) Preview(m_Node,m_Version);
+ if (m_Dirty) Preview(m_Node,m_Doc);
}