X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..3527f29c8769e09d796c547c0c309f8b86407012:/contrib/utils/wxrcedit/preview.cpp diff --git a/contrib/utils/wxrcedit/preview.cpp b/contrib/utils/wxrcedit/preview.cpp index a7ffa2eacd..29a11c77bd 100644 --- a/contrib/utils/wxrcedit/preview.cpp +++ b/contrib/utils/wxrcedit/preview.cpp @@ -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); @@ -197,7 +202,7 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc) void PreviewFrame::PreviewMenu() { - wxMenuBar *mbar; + wxMenuBar *mbar = NULL; if (XmlGetClass(m_Node) == _T("wxMenuBar")) mbar = m_RC->LoadMenuBar(m_Node->GetPropVal(_T("name"), _T("-1"))); @@ -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,12 +238,43 @@ 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) END_EVENT_TABLE() -void PreviewFrame::OnMouseEnter(wxMouseEvent& event) +void PreviewFrame::OnMouseEnter(wxMouseEvent& WXUNUSED(event)) { if (m_Dirty) Preview(m_Node,m_Doc); }