1) added wxFrame support to wxrcedit

2) fixes to wxrcedit so that generated files are compatible with new XRC
(both in patch #648659)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2002-12-21 00:20:35 +00:00
parent fc9a9b2ab2
commit 6267a331cb
7 changed files with 76 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ DATAFILES = df/break.df df/control.df df/menu_item.df df/notebookpage.df \
df/wxSlider.df df/wxSpinButton.df df/wxSpinCtrl.df \ df/wxSlider.df df/wxSpinButton.df df/wxSpinCtrl.df \
df/wxStaticBitmap.df df/wxStaticBox.df df/wxStaticBoxSizer.df \ df/wxStaticBitmap.df df/wxStaticBox.df df/wxStaticBoxSizer.df \
df/wxStaticLine.df df/wxStaticText.df df/wxTextCtrl.df \ df/wxStaticLine.df df/wxStaticText.df df/wxTextCtrl.df \
df/wxToolBar.df df/wxTreeCtrl.df df/wxToolBar.df df/wxTreeCtrl.df df/wxFrame.df
APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_xrc-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@ APPEXTRALIBS=$(top_builddir)/lib/lib@WX_LIBRARY_BASENAME@_xrc-@WX_RELEASE@.@WX_TARGET_LIBRARY_TYPE@
APPEXTRADEFS=-I$(top_srcdir)/contrib/include APPEXTRADEFS=-I$(top_srcdir)/contrib/include

View File

@@ -0,0 +1,8 @@
node wxFrame
type panel
icon 1
var title of text
var style of flags wxSTAY_ON_TOP,wxCAPTION,wxDEFAULT_FRAME_STYLE,wxSYSTEM_MENU,wxRESIZE_BORDER,wxICONIZE,wxMINIMIZE,wxMINIMIZE_BOX,wxMAXIMIZE,wxMAXIMIZE_BOX,wxSIMPLE_BORDER,wxFRAME_TOOL_WINDOW,wxFRAME_NO_TASKBAR,wxFRAME_FLOAT_ON_PARENT
var exstyle of flags wxFRAME_EX_CONTEXTHELP
var centered of bool
derived from panelbase

View File

@@ -92,7 +92,7 @@ void wxXmlRcEditDocument::Upgrade()
UpgradeNode(node); UpgradeNode(node);
} }
node->DeleteProperty(wxT("version")); node->DeleteProperty(wxT("version"));
node->AddProperty(wxT("version"), wxT(WX_XMLRES_CURRENT_VERSION_STRING)); node->AddProperty(wxT("version"), WX_XMLRES_CURRENT_VERSION_STRING);
} }
@@ -141,6 +141,7 @@ enum
ID_COPY, ID_COPY,
ID_NEWDIALOG, ID_NEWDIALOG,
ID_NEWFRAME,
ID_NEWPANEL, ID_NEWPANEL,
ID_NEWMENU, ID_NEWMENU,
ID_NEWMENUBAR, ID_NEWMENUBAR,
@@ -342,6 +343,11 @@ void EditorFrame::NewFile()
m_Resource = new wxXmlRcEditDocument; m_Resource = new wxXmlRcEditDocument;
m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource"))); m_Resource->SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _("resource")));
m_Resource->SetFileEncoding("utf-8");
m_Resource->GetRoot()->AddProperty(_T("version"),
WX_XMLRES_CURRENT_VERSION_STRING);
m_Modified = FALSE; m_Modified = FALSE;
RefreshTree(); RefreshTree();
RefreshTitle(); RefreshTitle();
@@ -366,6 +372,7 @@ void EditorFrame::RefreshTree()
wxXmlNode *sel = m_SelectedNode; wxXmlNode *sel = m_SelectedNode;
m_TreeCtrl->DeleteAllItems(); m_TreeCtrl->DeleteAllItems();
wxTreeItemId root = m_TreeCtrl->AddRoot("Resource: " + wxFileNameFromPath(m_FileName), 5, 5); wxTreeItemId root = m_TreeCtrl->AddRoot("Resource: " + wxFileNameFromPath(m_FileName), 5, 5);
wxXmlNode *n = m_Resource->GetRoot()->GetChildren(); wxXmlNode *n = m_Resource->GetRoot()->GetChildren();
@@ -613,6 +620,7 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
switch (event.GetId()) switch (event.GetId())
{ {
case ID_NEWDIALOG : name = _T("wxDialog"); break; case ID_NEWDIALOG : name = _T("wxDialog"); break;
case ID_NEWFRAME : name = _T("wxFrame"); break;
case ID_NEWPANEL : name = _T("wxPanel"); break; case ID_NEWPANEL : name = _T("wxPanel"); break;
case ID_NEWMENU : name = _T("wxMenu"); break; case ID_NEWMENU : name = _T("wxMenu"); break;
case ID_NEWMENUBAR : name = _T("wxMenuBar"); break; case ID_NEWMENUBAR : name = _T("wxMenuBar"); break;
@@ -637,6 +645,7 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot()) if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot())
{ {
popup->Append(ID_NEWDIALOG, _("New wxDialog")); popup->Append(ID_NEWDIALOG, _("New wxDialog"));
popup->Append(ID_NEWFRAME, _("New wxFrame"));
popup->Append(ID_NEWPANEL, _("New wxPanel")); popup->Append(ID_NEWPANEL, _("New wxPanel"));
popup->Append(ID_NEWMENU, _("New wxMenu")); popup->Append(ID_NEWMENU, _("New wxMenu"));
popup->Append(ID_NEWMENUBAR, _("New wxMenuBar")); popup->Append(ID_NEWMENUBAR, _("New wxMenuBar"));

View File

@@ -118,6 +118,7 @@ void PropEditCtrlColor::OnDetails()
clr = wxColour((tmp & 0xFF0000) >> 16, clr = wxColour((tmp & 0xFF0000) >> 16,
(tmp & 0x00FF00) >> 8, (tmp & 0x00FF00) >> 8,
(tmp & 0x0000FF)); (tmp & 0x0000FF));
clr = wxGetColourFromUser(NULL, clr); clr = wxGetColourFromUser(NULL, clr);
if (clr.Ok()) if (clr.Ok())
{ {

View File

@@ -157,6 +157,9 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog")) if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel")); XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxFrame"))
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
doc.Save(m_TmpFile); doc.Save(m_TmpFile);
// wxXmlResource will detect change automatically // wxXmlResource will detect change automatically
} }
@@ -186,6 +189,8 @@ void PreviewFrame::Preview(wxXmlNode *node, wxXmlDocument *orig_doc)
PreviewToolbar(); PreviewToolbar();
else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog")) else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
PreviewPanel(); PreviewPanel();
else if (XmlGetClass(node) == _T("wxFrame"))
PreviewWXFrame();
wxSetWorkingDirectory(oldcwd); wxSetWorkingDirectory(oldcwd);
wxLog::SetActiveTarget(oldlog); wxLog::SetActiveTarget(oldlog);
@@ -233,6 +238,37 @@ 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) BEGIN_EVENT_TABLE(PreviewFrame, wxFrame)
EVT_ENTER_WINDOW(PreviewFrame::OnMouseEnter) EVT_ENTER_WINDOW(PreviewFrame::OnMouseEnter)

View File

@@ -43,6 +43,7 @@ class PreviewFrame : public wxFrame
void PreviewMenu(); void PreviewMenu();
void PreviewToolbar(); void PreviewToolbar();
void PreviewPanel(); void PreviewPanel();
void PreviewWXFrame();
private: private:
static PreviewFrame *ms_Instance; static PreviewFrame *ms_Instance;

View File

@@ -38,7 +38,18 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS) const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS)
: wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style), : wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style),
m_EditCtrl(NULL) {} m_EditCtrl(NULL)
{
#if 0
// VS: Don't do it, it is *extremely* ugly.
// FIXME: find a better solution.
//make text larger so controls will fit properly
wxFont font = GetFont();
font.SetPointSize(font.GetPointSize()*1.5);
SetFont(font);
#endif
}
void OnPaint(wxPaintEvent& event) void OnPaint(wxPaintEvent& event)
{ {
@@ -63,6 +74,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
if (h.IsOk() && GetBoundingRect(h, itemRect)) if (h.IsOk() && GetBoundingRect(h, itemRect))
{ {
cy = itemRect.GetTop(); cy = itemRect.GetTop();
dc.DrawLine(0, cy, clientSize.x, cy); dc.DrawLine(0, cy, clientSize.x, cy);
lastH = h; lastH = h;
} }
@@ -88,6 +100,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl
{ {
wxRect bounding; wxRect bounding;
GetBoundingRect(item, bounding); GetBoundingRect(item, bounding);
bounding.SetX(0); bounding.SetX(0);
bounding.SetWidth(GetCompanionWindow()->GetSize().x); bounding.SetWidth(GetCompanionWindow()->GetSize().x);
dt->EditCtrl->BeginEdit(bounding, item); dt->EditCtrl->BeginEdit(bounding, item);
@@ -168,7 +181,6 @@ class PropsValueWindow: public wxTreeCompanionWindow
wxTreeItemId item = GetTreeCtrl()->HitTest(wxPoint(1, event.GetY()), flags); wxTreeItemId item = GetTreeCtrl()->HitTest(wxPoint(1, event.GetY()), flags);
if (item.IsOk()) if (item.IsOk())
{ {
GetTreeCtrl()->ScrollTo(item);
GetTreeCtrl()->SelectItem(item); GetTreeCtrl()->SelectItem(item);
} }
} }