wxID_ANY, wxDefaultSize, wxDefaultPosition, wxNOT_FOUND, true, false, tabs replacements.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27745 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -36,11 +36,11 @@ class MyMenubarHandler : public wxMenuBarXmlHandler
|
||||
|
||||
wxObject *DoCreateResource()
|
||||
{
|
||||
//wxMenuBar *menubar = new wxMenuBar(GetStyle());
|
||||
//wxMenuBar *menubar = new wxMenuBar(GetStyle());
|
||||
CreateChildren(m_MenuBar);
|
||||
return m_MenuBar;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
wxMenuBar *m_MenuBar;
|
||||
};
|
||||
@@ -52,41 +52,41 @@ PreviewFrame* PreviewFrame::ms_Instance = NULL;
|
||||
|
||||
PreviewFrame *PreviewFrame::Get()
|
||||
{
|
||||
if (ms_Instance == NULL)
|
||||
if (ms_Instance == NULL)
|
||||
{
|
||||
(void)new PreviewFrame;
|
||||
ms_Instance->Show(TRUE);
|
||||
ms_Instance->Show(true);
|
||||
}
|
||||
return ms_Instance;
|
||||
}
|
||||
|
||||
PreviewFrame::PreviewFrame()
|
||||
: wxFrame(EditorFrame::Get(), -1, _("Preview"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
: wxFrame(EditorFrame::Get(), wxID_ANY, _("Preview"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR
|
||||
#ifdef __WXMSW__
|
||||
| wxFRAME_TOOL_WINDOW
|
||||
#endif
|
||||
)
|
||||
{
|
||||
m_Dirty = FALSE;
|
||||
m_Dirty = false;
|
||||
ms_Instance = this;
|
||||
m_Node = NULL;
|
||||
|
||||
|
||||
SetMenuBar(new wxMenuBar());
|
||||
|
||||
|
||||
m_RC = NULL;
|
||||
m_TmpFile = wxGetTempFileName(_T("wxrcedit"));
|
||||
ResetResource();
|
||||
|
||||
wxConfigBase *cfg = wxConfigBase::Get();
|
||||
SetSize(wxRect(wxPoint(cfg->Read(_T("previewframe_x"), -1), cfg->Read(_T("previewframe_y"), -1)),
|
||||
SetSize(wxRect(wxPoint(cfg->Read(_T("previewframe_x"), wxDefaultPosition.x), cfg->Read(_T("previewframe_y"), wxDefaultPosition.y)),
|
||||
wxSize(cfg->Read(_T("previewframe_w"), 400), cfg->Read(_T("previewframe_h"), 400))));
|
||||
|
||||
m_Splitter = new wxSplitterWindow(this, -1);
|
||||
m_LogCtrl = new wxTextCtrl(m_Splitter, -1, wxEmptyString, wxDefaultPosition,
|
||||
m_Splitter = new wxSplitterWindow(this, wxID_ANY);
|
||||
m_LogCtrl = new wxTextCtrl(m_Splitter, wxID_ANY, wxEmptyString, wxDefaultPosition,
|
||||
wxDefaultSize, wxTE_MULTILINE);
|
||||
m_ScrollWin = new wxScrolledWindow(m_Splitter, -1);
|
||||
m_ScrollWin = new wxScrolledWindow(m_Splitter, wxID_ANY);
|
||||
m_ScrollWin->SetBackgroundColour(_T("light steel blue"));
|
||||
m_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300));
|
||||
|
||||
@@ -113,26 +113,26 @@ void PreviewFrame::ResetResource()
|
||||
|
||||
PreviewFrame::~PreviewFrame()
|
||||
{
|
||||
wxConfigBase *cfg = wxConfigBase::Get();
|
||||
wxConfigBase *cfg = wxConfigBase::Get();
|
||||
cfg->Write(_T("previewframe_x"), (long)GetPosition().x);
|
||||
cfg->Write(_T("previewframe_y"), (long)GetPosition().y);
|
||||
cfg->Write(_T("previewframe_w"), (long)GetSize().x);
|
||||
cfg->Write(_T("previewframe_h"), (long)GetSize().y);
|
||||
cfg->Write(_T("previewframe_sash"), (long)m_Splitter->GetSashPosition());
|
||||
|
||||
|
||||
ms_Instance = NULL;
|
||||
|
||||
|
||||
delete m_RC;
|
||||
wxRemoveFile(m_TmpFile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void PreviewFrame::MakeDirty()
|
||||
{
|
||||
if (m_Node == NULL) return;
|
||||
if (m_Dirty) return;
|
||||
m_Dirty = TRUE;
|
||||
m_Dirty = true;
|
||||
m_LogCtrl->Clear();
|
||||
m_LogCtrl->SetValue(_("Resource modified.\nMove mouse cursor over the preview window to refresh it."));
|
||||
}
|
||||
@@ -153,11 +153,11 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
|
||||
doc.GetRoot()->AddChild(new wxXmlNode(*node));
|
||||
doc.SetFileEncoding(orig_doc->GetFileEncoding());
|
||||
|
||||
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
|
||||
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
|
||||
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"));
|
||||
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame"))
|
||||
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
|
||||
|
||||
doc.Save(m_TmpFile);
|
||||
// wxXmlResource will detect change automatically
|
||||
@@ -178,10 +178,10 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
|
||||
m_LogCtrl->Clear();
|
||||
wxLogTextCtrl mylog(m_LogCtrl);
|
||||
wxLog *oldlog = wxLog::SetActiveTarget(&mylog);
|
||||
|
||||
|
||||
wxString oldcwd = wxGetCwd();
|
||||
wxSetWorkingDirectory(wxPathOnly(EditorFrame::Get()->GetFileName()));
|
||||
|
||||
|
||||
if (XmlGetClass(node) == _T("wxMenuBar") || XmlGetClass(node) == _T("wxMenu"))
|
||||
PreviewMenu();
|
||||
else if (XmlGetClass(node) == _T("wxToolBar"))
|
||||
@@ -189,12 +189,12 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
|
||||
else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
|
||||
PreviewPanel();
|
||||
else if (XmlGetClass(node) == _T("wxFrame"))
|
||||
PreviewWXFrame();
|
||||
PreviewWXFrame();
|
||||
|
||||
wxSetWorkingDirectory(oldcwd);
|
||||
wxLog::SetActiveTarget(oldlog);
|
||||
|
||||
m_Dirty = FALSE;
|
||||
|
||||
m_Dirty = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,38 +233,38 @@ void PreviewFrame::PreviewPanel()
|
||||
else
|
||||
{
|
||||
m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
|
||||
0, 0, TRUE);
|
||||
0, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
void PreviewFrame::PreviewWXFrame()
|
||||
{
|
||||
//for this to work the frame MUST have a child panel!
|
||||
//for this to work the frame MUST have a child panel!
|
||||
|
||||
wxXmlNode* child = m_Node;
|
||||
wxString name;
|
||||
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();
|
||||
}
|
||||
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);
|
||||
0, 0, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user