X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e066e2566a4e5db3510fe6a204d66850eaeceade..6a54cc2a1156229f1db27ec816c9be84e8da2ee3:/contrib/utils/wxrcedit/preview.cpp diff --git a/contrib/utils/wxrcedit/preview.cpp b/contrib/utils/wxrcedit/preview.cpp index 82729ec307..9aeb615401 100644 --- a/contrib/utils/wxrcedit/preview.cpp +++ b/contrib/utils/wxrcedit/preview.cpp @@ -18,8 +18,8 @@ #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" @@ -27,7 +27,7 @@ #include "xmlhelpr.h" #include "editor.h" -#include "wx/xml/xh_menu.h" +#include "wx/xrc/xh_menu.h" class MyMenubarHandler : public wxMenuBarXmlHandler { @@ -61,20 +61,23 @@ PreviewFrame *PreviewFrame::Get() } PreviewFrame::PreviewFrame() - : wxFrame(NULL, -1, _("Preview")) + : wxFrame(EditorFrame::Get(), -1, _("Preview"), + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR +#ifdef __WXMSW__ + | wxFRAME_TOOL_WINDOW +#endif + ) { + m_Dirty = FALSE; ms_Instance = this; m_Node = NULL; SetMenuBar(new wxMenuBar()); - m_RC = new wxXmlResource; - // these handlers take precedence over std. ones: - m_RC->AddHandler(new MyMenubarHandler(GetMenuBar())); - // std handlers: - m_RC->InitAllHandlers(); + m_RC = NULL; m_TmpFile = wxGetTempFileName(_T("wxrcedit")); - m_RC->Load(m_TmpFile); + ResetResource(); wxConfigBase *cfg = wxConfigBase::Get(); SetSize(wxRect(wxPoint(cfg->Read(_T("previewframe_x"), -1), cfg->Read(_T("previewframe_y"), -1)), @@ -88,10 +91,26 @@ PreviewFrame::PreviewFrame() m_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300)); CreateStatusBar(); + +#ifdef __WXMSW__ + SendSizeEvent(); // force resize for WXMSW +#endif } +void PreviewFrame::ResetResource() +{ + delete m_RC; + m_RC = new wxXmlResource; + // these handlers take precedence over std. ones: + m_RC->AddHandler(new MyMenubarHandler(GetMenuBar())); + // std handlers: + m_RC->InitAllHandlers(); + wxRemoveFile(m_TmpFile); + m_RC->Load(m_TmpFile); +} + PreviewFrame::~PreviewFrame() { wxConfigBase *cfg = wxConfigBase::Get(); @@ -109,13 +128,27 @@ PreviewFrame::~PreviewFrame() -void PreviewFrame::Preview(wxXmlNode *node) +void PreviewFrame::MakeDirty() +{ + if (m_Node == NULL) return; + if (m_Dirty) return; + m_Dirty = TRUE; + m_LogCtrl->Clear(); + m_LogCtrl->SetValue(_("Resource modified.\n" + "Move mouse cursor over the preview window to refresh it.")); +} + + + +void PreviewFrame::Preview(wxXmlNode *node,const wxString &version) { while (node->GetParent()->GetParent() != NULL) node = node->GetParent(); { wxXmlDocument doc; - doc.SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _T("resource"))); + wxXmlNode *root = new wxXmlNode(wxXML_ELEMENT_NODE, _T("resource")); + root->AddProperty(new wxXmlProperty(wxT("version"),version,NULL)); + doc.SetRoot(root); doc.GetRoot()->AddChild(new wxXmlNode(*node)); if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog")) @@ -135,6 +168,7 @@ void PreviewFrame::Preview(wxXmlNode *node) } m_Node = node; + m_Version = version; m_LogCtrl->Clear(); wxLogTextCtrl mylog(m_LogCtrl); @@ -152,6 +186,8 @@ void PreviewFrame::Preview(wxXmlNode *node) wxSetWorkingDirectory(oldcwd); wxLog::SetActiveTarget(oldlog); + + m_Dirty = FALSE; } @@ -193,3 +229,13 @@ void PreviewFrame::PreviewPanel() 0, 0, TRUE); } } + + +BEGIN_EVENT_TABLE(PreviewFrame, wxFrame) + EVT_ENTER_WINDOW(PreviewFrame::OnMouseEnter) +END_EVENT_TABLE() + +void PreviewFrame::OnMouseEnter(wxMouseEvent& event) +{ + if (m_Dirty) Preview(m_Node,m_Version); +}