]> git.saurik.com Git - wxWidgets.git/blobdiff - contrib/utils/wxrcedit/preview.cpp
fixed 'patch' #422993 (Error in wxConfigBase::Write for doubles)
[wxWidgets.git] / contrib / utils / wxrcedit / preview.cpp
index 82729ec3074190cfb2f00a672b37f74988fcd8ad..015a883b3f4f817688dabd7d5a762026e5d53c05 100644 (file)
@@ -61,8 +61,15 @@ 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;
     
@@ -88,6 +95,10 @@ PreviewFrame::PreviewFrame()
     m_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300));
 
     CreateStatusBar();
+
+#ifdef __WXMSW__
+    SendSizeEvent(); // force resize for WXMSW
+#endif
 }
 
 
@@ -109,6 +120,18 @@ PreviewFrame::~PreviewFrame()
 
 
         
+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)
 {
    while (node->GetParent()->GetParent() != NULL) node = node->GetParent();
@@ -152,6 +175,8 @@ void PreviewFrame::Preview(wxXmlNode *node)
    
    wxSetWorkingDirectory(oldcwd);
    wxLog::SetActiveTarget(oldlog);
+   
+   m_Dirty = FALSE;
 }
 
 
@@ -193,3 +218,23 @@ void PreviewFrame::PreviewPanel()
                                    0, 0, TRUE);
     }
 }
+
+
+#ifdef __WXMSW__
+// avoid Problems with setting the focus to a no longer existing child
+void PreviewFrame::OnActivate(wxActivateEvent &event)
+{
+}
+#endif
+
+BEGIN_EVENT_TABLE(PreviewFrame, wxFrame)
+    EVT_ENTER_WINDOW(PreviewFrame::OnMouseEnter)
+#ifdef __WXMSW__
+    EVT_ACTIVATE(PreviewFrame::OnActivate)
+#endif
+END_EVENT_TABLE()
+
+void PreviewFrame::OnMouseEnter(wxMouseEvent& event)
+{
+    if (m_Dirty) Preview(m_Node);
+}