change in XRC format

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8491 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2000-10-07 21:56:37 +00:00
parent 3efb0e4bbd
commit e066e2566a
79 changed files with 730 additions and 606 deletions

View File

@@ -30,6 +30,8 @@ class WXDLLEXPORT wxSizerXmlHandler : public wxXmlResourceHandler
private: private:
bool m_IsInside; bool m_IsInside;
wxSizer *m_ParentSizer; wxSizer *m_ParentSizer;
bool IsSizerNode(wxXmlNode *node);
}; };

View File

@@ -124,7 +124,7 @@ class WXDLLEXPORT wxXmlResource : public wxObject
void UpdateResources(); void UpdateResources();
// Finds resource (calls UpdateResources) and returns node containing it // Finds resource (calls UpdateResources) and returns node containing it
wxXmlNode *FindResource(const wxString& name, const wxString& type); wxXmlNode *FindResource(const wxString& name, const wxString& classname);
// Creates resource from info in given node: // Creates resource from info in given node:
wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL); wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL);
@@ -212,11 +212,17 @@ class WXDLLEXPORT wxXmlResourceHandler : public wxObject
// Variables (filled by CreateResource) // Variables (filled by CreateResource)
wxXmlNode *m_Node; wxXmlNode *m_Node;
wxString m_Class;
wxObject *m_Parent, *m_Instance; wxObject *m_Parent, *m_Instance;
wxWindow *m_ParentAsWindow, *m_InstanceAsWindow; wxWindow *m_ParentAsWindow, *m_InstanceAsWindow;
// --- Handy methods: // --- Handy methods:
// Returns true if the node has property class equal to classname,
// e.g. <object class="wxDialog">
bool IsOfClass(wxXmlNode *node, const wxString& classname)
{ return node->GetPropVal(_T("class"), wxEmptyString) == classname; }
// Gets node content from wxXML_ENTITY_NODE // Gets node content from wxXML_ENTITY_NODE
// (the problem is, <tag>content<tag> is represented as // (the problem is, <tag>content<tag> is represented as
// wxXML_ENTITY_NODE name="tag", content="" // wxXML_ENTITY_NODE name="tag", content=""
@@ -278,9 +284,8 @@ class WXDLLEXPORT wxXmlResourceHandler : public wxObject
// Sets common window options: // Sets common window options:
void SetupWindow(wxWindow *wnd); void SetupWindow(wxWindow *wnd);
void CreateChildren(wxObject *parent, bool only_this_handler = FALSE, void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE);
wxXmlNode *children_node = NULL /*stands for void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
GetParamNode("children")*/);
wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL) wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL)
{ return m_Resource->CreateResFromNode(node, parent, instance); } { return m_Resource->CreateResFromNode(node, parent, instance); }

View File

@@ -37,7 +37,7 @@ wxObject *wxBitmapXmlHandler::DoCreateResource()
bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node) bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("bitmap"); return IsOfClass(node, _T("wxBitmap"));
} }
@@ -55,6 +55,6 @@ wxObject *wxIconXmlHandler::DoCreateResource()
bool wxIconXmlHandler::CanHandle(wxXmlNode *node) bool wxIconXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("icon"); return IsOfClass(node, _T("wxIcon"));
} }

View File

@@ -60,7 +60,7 @@ wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node) bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("bitmapbutton"); return IsOfClass(node, _T("wxBitmapButton"));
} }

View File

@@ -49,7 +49,7 @@ wxObject *wxButtonXmlHandler::DoCreateResource()
bool wxButtonXmlHandler::CanHandle(wxXmlNode *node) bool wxButtonXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("button"); return IsOfClass(node, _T("wxButton"));
} }

View File

@@ -54,7 +54,7 @@ wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
bool wxCalendarCtrlXmlHandler::CanHandle(wxXmlNode *node) bool wxCalendarCtrlXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("calendarctrl"); return IsOfClass(node, _T("wxCalendarCtrl"));
} }

View File

@@ -51,7 +51,7 @@ wxObject *wxCheckBoxXmlHandler::DoCreateResource()
bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node) bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("checkbox"); return IsOfClass(node, _T("wxCheckBox"));
} }
#endif #endif

View File

@@ -31,12 +31,11 @@ wxCheckListXmlHandler::wxCheckListXmlHandler()
wxObject *wxCheckListXmlHandler::DoCreateResource() wxObject *wxCheckListXmlHandler::DoCreateResource()
{ {
if( m_Node->GetName() == _T("checklist")) if (m_Class == _T("wxCheckList"))
{ {
// need to build the list of strings from children // need to build the list of strings from children
m_InsideBox = TRUE; m_InsideBox = TRUE;
CreateChildren( NULL, TRUE /* only this handler */, CreateChildrenPrivately(NULL, GetParamNode(_T("content")));
GetParamNode(_T("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 ) if( strList.GetCount() > 0 )
{ {
@@ -64,7 +63,7 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
while (n) while (n)
{ {
if (n->GetType() != wxXML_ELEMENT_NODE || if (n->GetType() != wxXML_ELEMENT_NODE ||
n->GetName() != _T("item" )) n->GetName() != _T("item"))
{ n = n->GetNext(); continue; } { n = n->GetNext(); continue; }
// checking boolean is a bit ugly here (see GetBool() ) // checking boolean is a bit ugly here (see GetBool() )
@@ -102,10 +101,9 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
bool wxCheckListXmlHandler::CanHandle(wxXmlNode *node) bool wxCheckListXmlHandler::CanHandle(wxXmlNode *node)
{ {
return( node->GetName() == _T("checklist") || return (IsOfClass(node, _T("wxCheckList")) ||
( m_InsideBox && (m_InsideBox && node->GetName() == _T("item"))
node->GetName() == _T("item" )) );
);
} }

View File

@@ -31,15 +31,14 @@ wxChoiceXmlHandler::wxChoiceXmlHandler()
wxObject *wxChoiceXmlHandler::DoCreateResource() wxObject *wxChoiceXmlHandler::DoCreateResource()
{ {
if( m_Node->GetName() == _T("choice")) if( m_Class == _T("wxChoice"))
{ {
// find the selection // find the selection
long selection = GetLong( _T("selection"), -1 ); long selection = GetLong( _T("selection"), -1 );
// need to build the list of strings from children // need to build the list of strings from children
m_InsideBox = TRUE; m_InsideBox = TRUE;
CreateChildren( NULL, TRUE /* only this handler */, CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
GetParamNode(_T("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 ) if( strList.GetCount() > 0 )
{ {
@@ -88,10 +87,9 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node) bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node)
{ {
return( node->GetName() == _T("choice") || return (IsOfClass(node, _T("wxChoice")) ||
( m_InsideBox && (m_InsideBox && node->GetName() == _T("item"))
node->GetName() == _T("item" )) );
);
} }

View File

@@ -36,15 +36,14 @@ wxComboBoxXmlHandler::wxComboBoxXmlHandler()
wxObject *wxComboBoxXmlHandler::DoCreateResource() wxObject *wxComboBoxXmlHandler::DoCreateResource()
{ {
if( m_Node->GetName() == _T("combobox")) if( m_Class == _T("wxComboBox"))
{ {
// find the selection // find the selection
long selection = GetLong( _T("selection"), -1 ); long selection = GetLong( _T("selection"), -1 );
// need to build the list of strings from children // need to build the list of strings from children
m_InsideBox = TRUE; m_InsideBox = TRUE;
CreateChildren( NULL, TRUE /* only this handler */, CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
GetParamNode(_T("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 ) if( strList.GetCount() > 0 )
{ {
@@ -94,10 +93,9 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node) bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node)
{ {
return( node->GetName() == _T("combobox") || return (IsOfClass(node, _T("wxComboBox")) ||
( m_InsideBox && (m_InsideBox && node->GetName() == _T("item"))
node->GetName() == _T("item" )) );
);
} }
#endif #endif

View File

@@ -74,7 +74,7 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
bool wxDialogXmlHandler::CanHandle(wxXmlNode *node) bool wxDialogXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("dialog"); return IsOfClass(node, _T("wxDialog"));
} }

View File

@@ -67,7 +67,7 @@ wxObject *wxGaugeXmlHandler::DoCreateResource()
bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node) bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("gauge"); return IsOfClass(node, _T("wxGauge"));
} }

View File

@@ -66,7 +66,7 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node) bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("htmlwindow"); return IsOfClass(node, _T("wxHtmlWindow"));
} }
#endif // wxUSE_HTML #endif // wxUSE_HTML

View File

@@ -37,15 +37,14 @@ wxListBoxXmlHandler::wxListBoxXmlHandler()
wxObject *wxListBoxXmlHandler::DoCreateResource() wxObject *wxListBoxXmlHandler::DoCreateResource()
{ {
if( m_Node->GetName() == _T("listbox")) if( m_Class == _T("wxListBox"))
{ {
// find the selection // find the selection
long selection = GetLong( _T("selection"), -1 ); long selection = GetLong( _T("selection"), -1 );
// need to build the list of strings from children // need to build the list of strings from children
m_InsideBox = TRUE; m_InsideBox = TRUE;
CreateChildren( NULL, TRUE /* only this handler */, CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
GetParamNode(_T("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 ) if( strList.GetCount() > 0 )
{ {
@@ -94,10 +93,9 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node) bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node)
{ {
return( node->GetName() == _T("listbox") || return (IsOfClass(node, _T("wxListBox")) ||
( m_InsideBox && (m_InsideBox && node->GetName() == _T("item"))
node->GetName() == _T("item" )) );
);
} }

View File

@@ -63,5 +63,5 @@ wxObject *wxListCtrlXmlHandler::DoCreateResource()
bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node) bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("listctrl"); return IsOfClass(node, _T("wxListCtrl"));
} }

View File

@@ -41,30 +41,30 @@ wxNotebookXmlHandler::wxNotebookXmlHandler()
wxObject *wxNotebookXmlHandler::DoCreateResource() wxObject *wxNotebookXmlHandler::DoCreateResource()
{ {
if (m_Node->GetName() == _T("notebookpage")) if (m_Class == _T("notebookpage"))
{ {
wxXmlNode *n = GetParamNode(_T("window"))->GetChildren(); wxXmlNode *n = GetParamNode(_T("object"));
while (n)
if (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE) bool old_ins = m_IsInside;
{ m_IsInside = FALSE;
bool old_ins = m_IsInside; m_IsInside = old_ins;
m_IsInside = FALSE; wxObject *item = CreateResFromNode(n, m_Notebook, NULL);
m_IsInside = old_ins; wxWindow *wnd = wxDynamicCast(item, wxWindow);
wxObject *item = CreateResFromNode(n, m_Notebook, NULL);
wxWindow *wnd = wxDynamicCast(item, wxWindow); if (wnd)
m_Notebook->AddPage(wnd, GetText(_T("label")),
if (wnd) GetBool(_T("selected"), 0));
m_Notebook->AddPage(wnd, GetText(_T("label")), else
GetBool(_T("selected"), 0)); wxLogError(_T("Error in resource."));
else return wnd;
wxLogError(_T("Error in resource.")); }
return wnd; else
} {
n = n->GetNext(); wxLogError(_T("Error in resource: no control within notebook's <page> tag."));
return NULL;
} }
wxLogError(_T("Error in resource: no control within notebook's <page> tag."));
return NULL;
} }
else { else {
@@ -93,8 +93,8 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node) bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
{ {
return ((!m_IsInside && node->GetName() == _T("notebook")) || return ((!m_IsInside && IsOfClass(node, _T("wxNotebook"))) ||
(m_IsInside && node->GetName() == _T("notebookpage"))); (m_IsInside && IsOfClass(node, _T("notebookpage"))));
} }
#endif #endif

View File

@@ -59,5 +59,5 @@ wxObject *wxPanelXmlHandler::DoCreateResource()
bool wxPanelXmlHandler::CanHandle(wxXmlNode *node) bool wxPanelXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("panel"); return IsOfClass(node, _T("wxPanel"));
} }

View File

@@ -59,7 +59,7 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
bool wxRadioButtonXmlHandler::CanHandle(wxXmlNode *node) bool wxRadioButtonXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("radiobutton"); return IsOfClass(node, _T("wxRadioButton"));
} }

View File

@@ -36,14 +36,14 @@ wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
wxObject *wxRadioBoxXmlHandler::DoCreateResource() wxObject *wxRadioBoxXmlHandler::DoCreateResource()
{ {
if( m_Node->GetName() == _T("radiobox")) if( m_Class == _T("wxRadioBox"))
{ {
// find the selection // find the selection
long selection = GetLong( _T("selection"), -1 ); long selection = GetLong( _T("selection"), -1 );
// need to build the list of strings from children // need to build the list of strings from children
m_InsideBox = TRUE; m_InsideBox = TRUE;
CreateChildren( NULL, TRUE /* only this handler */, GetParamNode(_T("content"))); CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
wxString *strings = (wxString *) NULL; wxString *strings = (wxString *) NULL;
if( strList.GetCount() > 0 ) if( strList.GetCount() > 0 )
{ {
@@ -94,10 +94,9 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node) bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
{ {
return( node->GetName() == _T("radiobox") || return (IsOfClass(node, _T("wxRadioBox")) ||
( m_InsideBox && (m_InsideBox && node->GetName() == _T("item"))
node->GetName() == _T("item" )) );
);
} }
#endif #endif

View File

@@ -56,7 +56,7 @@ wxObject *wxScrollBarXmlHandler::DoCreateResource()
bool wxScrollBarXmlHandler::CanHandle(wxXmlNode *node) bool wxScrollBarXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("scrollbar"); return IsOfClass(node, _T("wxScrollBar"));
} }

View File

@@ -25,12 +25,12 @@
#include "wx/statbox.h" #include "wx/statbox.h"
#include "wx/notebook.h" #include "wx/notebook.h"
static bool IsSizerNode(wxXmlNode *node) bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node)
{ {
return (node->GetName() == _T("boxsizer")) || return (IsOfClass(node, _T("wxBoxSizer"))) ||
(node->GetName() == _T("staticboxsizer")) || (IsOfClass(node, _T("wxStaticBoxSizer"))) ||
(node->GetName() == _T("gridsizer")) || (IsOfClass(node, _T("wxGridSizer"))) ||
(node->GetName() == _T("flexgridsizer")); (IsOfClass(node, _T("wxFlexGridSizer")));
} }
@@ -73,51 +73,50 @@ wxSizerXmlHandler::wxSizerXmlHandler()
wxObject *wxSizerXmlHandler::DoCreateResource() wxObject *wxSizerXmlHandler::DoCreateResource()
{ {
if (m_Node->GetName() == _T("sizeritem")) if (m_Class == _T("sizeritem"))
{ {
wxXmlNode *n = GetParamNode(_T("window"))->GetChildren(); wxXmlNode *n = GetParamNode(_T("object"));
while (n) if (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE) bool old_ins = m_IsInside;
{ wxSizer *old_par = m_ParentSizer;
bool old_ins = m_IsInside; m_IsInside = FALSE;
wxSizer *old_par = m_ParentSizer; if (!IsSizerNode(n)) m_ParentSizer = NULL;
m_IsInside = FALSE; wxObject *item = CreateResFromNode(n, m_Parent, NULL);
if (!IsSizerNode(n)) m_ParentSizer = NULL; m_IsInside = old_ins;
wxObject *item = CreateResFromNode(n, m_Parent, NULL); m_ParentSizer = old_par;
m_IsInside = old_ins; wxSizer *sizer = wxDynamicCast(item, wxSizer);
m_ParentSizer = old_par; wxWindow *wnd = wxDynamicCast(item, wxWindow);
wxSizer *sizer = wxDynamicCast(item, wxSizer); wxSize minsize = GetSize(_T("minsize"));
wxWindow *wnd = wxDynamicCast(item, wxWindow);
wxSize minsize = GetSize(_T("minsize")); if (sizer)
{
if (sizer) m_ParentSizer->Add(sizer, GetLong(_T("option")),
{ GetStyle(_T("flag")), GetDimension(_T("border")));
m_ParentSizer->Add(sizer, GetLong(_T("option")), if (!(minsize == wxDefaultSize))
GetStyle(_T("flag")), GetDimension(_T("border"))); m_ParentSizer->SetItemMinSize(sizer, minsize.x, minsize.y);
if (!(minsize == wxDefaultSize))
m_ParentSizer->SetItemMinSize(sizer, minsize.x, minsize.y);
}
else if (wnd)
{
m_ParentSizer->Add(wnd, GetLong(_T("option")),
GetStyle(_T("flag")), GetDimension(_T("border")));
if (!(minsize == wxDefaultSize))
m_ParentSizer->SetItemMinSize(wnd, minsize.x, minsize.y);
}
else
wxLogError(_T("Error in resource."));
return item;
} }
n = n->GetNext(); else if (wnd)
{
m_ParentSizer->Add(wnd, GetLong(_T("option")),
GetStyle(_T("flag")), GetDimension(_T("border")));
if (!(minsize == wxDefaultSize))
m_ParentSizer->SetItemMinSize(wnd, minsize.x, minsize.y);
}
else
wxLogError(_T("Error in resource."));
return item;
}
else /*n == NULL*/
{
wxLogError(_T("Error in resource: no control/sizer within sizer's <item> tag."));
return NULL;
} }
wxLogError(_T("Error in resource: no control/sizer within sizer's <item> tag."));
return NULL;
} }
else if (m_Node->GetName() == _T("spacer")) else if (m_Class == _T("spacer"))
{ {
wxCHECK_MSG(m_ParentSizer, NULL, _T("Incorrect syntax of XML resource: spacer not within sizer!")); wxCHECK_MSG(m_ParentSizer, NULL, _T("Incorrect syntax of XML resource: spacer not within sizer!"));
wxSize sz = GetSize(); wxSize sz = GetSize();
@@ -130,29 +129,29 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
else { else {
wxSizer *sizer = NULL; wxSizer *sizer = NULL;
wxXmlNode *parentNode = m_Node->GetParent()->GetParent(); wxXmlNode *parentNode = m_Node->GetParent();
wxCHECK_MSG(m_ParentSizer != NULL || wxCHECK_MSG(m_ParentSizer != NULL ||
((parentNode->GetName() == _T("panel") || ((IsOfClass(parentNode, _T("wxPanel")) ||
parentNode->GetName() == _T("dialog")) && IsOfClass(parentNode, _T("wxDialog"))) &&
parentNode->GetType() == wxXML_ELEMENT_NODE), NULL, parentNode->GetType() == wxXML_ELEMENT_NODE), NULL,
_T("Incorrect use of sizer: parent is not 'dialog' or 'panel'.")); _T("Incorrect use of sizer: parent is not 'wxDialog' or 'wxPanel'."));
if (m_Node->GetName() == _T("boxsizer")) if (m_Class == _T("wxBoxSizer"))
sizer = new wxBoxSizer(GetStyle(_T("orient"), wxHORIZONTAL)); sizer = new wxBoxSizer(GetStyle(_T("orient"), wxHORIZONTAL));
else if (m_Node->GetName() == _T("staticboxsizer")) else if (m_Class == _T("wxStaticBoxSizer"))
{ {
sizer = new wxStaticBoxSizer( sizer = new wxStaticBoxSizer(
new wxStaticBox(m_ParentAsWindow, -1, GetText(_T("label"))), new wxStaticBox(m_ParentAsWindow, -1, GetText(_T("label"))),
GetStyle(_T("orient"), wxHORIZONTAL)); GetStyle(_T("orient"), wxHORIZONTAL));
} }
else if (m_Node->GetName() == _T("gridsizer")) else if (m_Class == _T("wxGridSizer"))
sizer = new wxGridSizer(GetLong(_T("rows")), GetLong(_T("cols")), sizer = new wxGridSizer(GetLong(_T("rows")), GetLong(_T("cols")),
GetDimension(_T("vgap")), GetDimension(_T("hgap"))); GetDimension(_T("vgap")), GetDimension(_T("hgap")));
else if (m_Node->GetName() == _T("flexgridsizer")) else if (m_Class == _T("wxFlexGridSizer"))
sizer = new wxFlexGridSizer(GetLong(_T("rows")), GetLong(_T("cols")), sizer = new wxFlexGridSizer(GetLong(_T("rows")), GetLong(_T("cols")),
GetDimension(_T("vgap")), GetDimension(_T("hgap"))); GetDimension(_T("vgap")), GetDimension(_T("hgap")));
@@ -193,6 +192,6 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
bool wxSizerXmlHandler::CanHandle(wxXmlNode *node) bool wxSizerXmlHandler::CanHandle(wxXmlNode *node)
{ {
return ((!m_IsInside && IsSizerNode(node)) || return ((!m_IsInside && IsSizerNode(node)) ||
(m_IsInside && node->GetName() == _T("sizeritem")) || (m_IsInside && IsOfClass(node, _T("sizeritem"))) ||
(m_IsInside && node->GetName() == _T("spacer"))); (m_IsInside && IsOfClass(node, _T("spacer"))));
} }

View File

@@ -87,7 +87,7 @@ wxObject *wxSliderXmlHandler::DoCreateResource()
bool wxSliderXmlHandler::CanHandle(wxXmlNode *node) bool wxSliderXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("slider"); return IsOfClass(node, _T("wxSlider"));
} }

View File

@@ -93,7 +93,7 @@ wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node) bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("spinctrl"); return IsOfClass(node, _T("wxSpinCtrl"));
} }
#endif // wxUSE_SPINCTRL #endif // wxUSE_SPINCTRL

View File

@@ -46,7 +46,7 @@ wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
bool wxStaticBitmapXmlHandler::CanHandle(wxXmlNode *node) bool wxStaticBitmapXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("staticbitmap"); return IsOfClass(node, _T("wxStaticBitmap"));
} }

View File

@@ -46,7 +46,7 @@ wxObject *wxStaticBoxXmlHandler::DoCreateResource()
bool wxStaticBoxXmlHandler::CanHandle(wxXmlNode *node) bool wxStaticBoxXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("staticbox"); return IsOfClass(node, _T("wxStaticBox"));
} }

View File

@@ -49,7 +49,7 @@ wxObject *wxStaticLineXmlHandler::DoCreateResource()
bool wxStaticLineXmlHandler::CanHandle(wxXmlNode *node) bool wxStaticLineXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("staticline"); return IsOfClass(node, _T("wxStaticLine"));
} }
#endif #endif

View File

@@ -47,7 +47,7 @@ wxObject *wxStaticTextXmlHandler::DoCreateResource()
bool wxStaticTextXmlHandler::CanHandle(wxXmlNode *node) bool wxStaticTextXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("statictext"); return IsOfClass(node, _T("wxStaticText"));
} }

View File

@@ -40,8 +40,8 @@ wxObject *wxTextCtrlXmlHandler::DoCreateResource()
GetText(_T("value")), GetText(_T("value")),
GetPosition(), GetSize(), GetPosition(), GetSize(),
GetStyle(), GetStyle(),
wxDefaultValidator, wxDefaultValidator,
GetText(_T("name")) GetName()
); );
SetupWindow(text); SetupWindow(text);
@@ -52,7 +52,7 @@ wxObject *wxTextCtrlXmlHandler::DoCreateResource()
bool wxTextCtrlXmlHandler::CanHandle(wxXmlNode *node) bool wxTextCtrlXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("textctrl"); return IsOfClass(node, _T("wxTextCtrl"));
} }

View File

@@ -38,7 +38,7 @@ wxToolBarXmlHandler::wxToolBarXmlHandler()
wxObject *wxToolBarXmlHandler::DoCreateResource() wxObject *wxToolBarXmlHandler::DoCreateResource()
{ {
if (m_Node->GetName() == _T("tool")) if (m_Class == _T("tool"))
{ {
wxCHECK_MSG(m_Toolbar, NULL, _T("Incorrect syntax of XML resource: tool not within a toolbar!")); wxCHECK_MSG(m_Toolbar, NULL, _T("Incorrect syntax of XML resource: tool not within a toolbar!"));
m_Toolbar->AddTool(GetID(), m_Toolbar->AddTool(GetID(),
@@ -53,14 +53,14 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
return m_Toolbar; // must return non-NULL return m_Toolbar; // must return non-NULL
} }
else if (m_Node->GetName() == _T("separator")) else if (m_Class == _T("separator"))
{ {
wxCHECK_MSG(m_Toolbar, NULL, _T("Incorrect syntax of XML resource: separator not within a toolbar!")); wxCHECK_MSG(m_Toolbar, NULL, _T("Incorrect syntax of XML resource: separator not within a toolbar!"));
m_Toolbar->AddSeparator(); m_Toolbar->AddSeparator();
return m_Toolbar; // must return non-NULL return m_Toolbar; // must return non-NULL
} }
else /*<toolbar>*/ else /*<object class="wxToolBar">*/
{ {
int style = GetStyle(_T("style"), wxNO_BORDER | wxTB_HORIZONTAL); int style = GetStyle(_T("style"), wxNO_BORDER | wxTB_HORIZONTAL);
#ifdef __WXMSW__ #ifdef __WXMSW__
@@ -86,22 +86,23 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
if (separation != -1) if (separation != -1)
toolbar->SetToolSeparation(separation); toolbar->SetToolSeparation(separation);
wxXmlNode *children_node = GetParamNode(_T("children")); wxXmlNode *children_node = GetParamNode(_T("object"));
if (children_node == NULL) return toolbar; if (children_node == NULL) return toolbar;
m_IsInside = TRUE; m_IsInside = TRUE;
m_Toolbar = toolbar; m_Toolbar = toolbar;
wxXmlNode *n = children_node->GetChildren(); wxXmlNode *n = children_node;
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE) if (n->GetType() == wxXML_ELEMENT_NODE &&
n->GetName() == _T("object"))
{ {
wxObject *created = CreateResFromNode(n, toolbar, NULL); wxObject *created = CreateResFromNode(n, toolbar, NULL);
wxControl *control = wxDynamicCast(created, wxControl); wxControl *control = wxDynamicCast(created, wxControl);
if (n->GetName() != _T("tool") && if (IsOfClass(n, _T("tool")) &&
n->GetName() != _T("separator") && IsOfClass(n, _T("separator")) &&
control != NULL) control != NULL)
toolbar->AddControl(control); toolbar->AddControl(control);
} }
@@ -120,9 +121,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node) bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
{ {
return ((!m_IsInside && node->GetName() == _T("toolbar")) || return ((!m_IsInside && IsOfClass(node, _T("wxToolBar"))) ||
(m_IsInside && node->GetName() == _T("tool")) || (m_IsInside && IsOfClass(node, _T("tool"))) ||
(m_IsInside && node->GetName() == _T("separator"))); (m_IsInside && IsOfClass(node, _T("separator"))));
} }
#endif #endif

View File

@@ -51,7 +51,7 @@ wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
bool wxTreeCtrlXmlHandler::CanHandle(wxXmlNode *node) bool wxTreeCtrlXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("treectrl"); return IsOfClass(node, _T("wxTreeCtrl"));
} }

View File

@@ -43,7 +43,7 @@ wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
wnd = m_ParentAsWindow->FindWindow(name); wnd = m_ParentAsWindow->FindWindow(name);
if (wnd == NULL) if (wnd == NULL)
wxLogError(_T("Cannot find specified window for <unknown> (id=%li, name='%s')."), id, name.mb_str()); wxLogError(_T("Cannot find specified window for class 'unknown' (id=%li, name='%s')."), id, name.mb_str());
else else
{ {
if (wnd->GetParent() != m_ParentAsWindow) if (wnd->GetParent() != m_ParentAsWindow)
@@ -56,6 +56,6 @@ wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node) bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
{ {
return node->GetName() == _T("unknown"); return IsOfClass(node, _T("unknown"));
} }

View File

@@ -131,21 +131,21 @@ void wxXmlResource::ClearHandlers()
wxMenu *wxXmlResource::LoadMenu(const wxString& name) wxMenu *wxXmlResource::LoadMenu(const wxString& name)
{ {
return (wxMenu*)CreateResFromNode(FindResource(name, wxT("menu")), NULL, NULL); return (wxMenu*)CreateResFromNode(FindResource(name, wxT("wxMenu")), NULL, NULL);
} }
wxMenuBar *wxXmlResource::LoadMenuBar(const wxString& name) wxMenuBar *wxXmlResource::LoadMenuBar(const wxString& name)
{ {
return (wxMenuBar*)CreateResFromNode(FindResource(name, wxT("menubar")), NULL, NULL); return (wxMenuBar*)CreateResFromNode(FindResource(name, wxT("wxMenuBar")), NULL, NULL);
} }
wxToolBar *wxXmlResource::LoadToolBar(wxWindow *parent, const wxString& name) wxToolBar *wxXmlResource::LoadToolBar(wxWindow *parent, const wxString& name)
{ {
return (wxToolBar*)CreateResFromNode(FindResource(name, wxT("toolbar")), parent, NULL); return (wxToolBar*)CreateResFromNode(FindResource(name, wxT("wxToolBar")), parent, NULL);
} }
@@ -160,19 +160,19 @@ wxDialog *wxXmlResource::LoadDialog(wxWindow *parent, const wxString& name)
bool wxXmlResource::LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name) bool wxXmlResource::LoadDialog(wxDialog *dlg, wxWindow *parent, const wxString& name)
{ {
return CreateResFromNode(FindResource(name, wxT("dialog")), parent, dlg) != NULL; return CreateResFromNode(FindResource(name, wxT("wxDialog")), parent, dlg) != NULL;
} }
wxPanel *wxXmlResource::LoadPanel(wxWindow *parent, const wxString& name) wxPanel *wxXmlResource::LoadPanel(wxWindow *parent, const wxString& name)
{ {
return (wxPanel*)CreateResFromNode(FindResource(name, wxT("panel")), parent, NULL); return (wxPanel*)CreateResFromNode(FindResource(name, wxT("wxPanel")), parent, NULL);
} }
bool wxXmlResource::LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name) bool wxXmlResource::LoadPanel(wxPanel *panel, wxWindow *parent, const wxString& name)
{ {
return CreateResFromNode(FindResource(name, wxT("panel")), parent, panel) != NULL; return CreateResFromNode(FindResource(name, wxT("wxPanel")), parent, panel) != NULL;
} }
@@ -180,7 +180,7 @@ bool wxXmlResource::LoadPanel(wxPanel *panel, wxWindow *parent, const wxString&
wxBitmap wxXmlResource::LoadBitmap(const wxString& name) wxBitmap wxXmlResource::LoadBitmap(const wxString& name)
{ {
wxBitmap *bmp = (wxBitmap*)CreateResFromNode( wxBitmap *bmp = (wxBitmap*)CreateResFromNode(
FindResource(name, wxT("bitmap")), NULL, NULL); FindResource(name, wxT("wxBitmap")), NULL, NULL);
wxBitmap rt; wxBitmap rt;
if (bmp) { rt = *bmp; delete bmp; } if (bmp) { rt = *bmp; delete bmp; }
@@ -190,7 +190,7 @@ wxBitmap wxXmlResource::LoadBitmap(const wxString& name)
wxIcon wxXmlResource::LoadIcon(const wxString& name) wxIcon wxXmlResource::LoadIcon(const wxString& name)
{ {
wxIcon *icon = (wxIcon*)CreateResFromNode( wxIcon *icon = (wxIcon*)CreateResFromNode(
FindResource(name, wxT("icon")), NULL, NULL); FindResource(name, wxT("wxIcon")), NULL, NULL);
wxIcon rt; wxIcon rt;
if (icon) { rt = *icon; delete icon; } if (icon) { rt = *icon; delete icon; }
@@ -314,7 +314,7 @@ void wxXmlResource::UpdateResources()
wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& type) wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& classname)
{ {
UpdateResources(); //ensure everything is up-to-date UpdateResources(); //ensure everything is up-to-date
@@ -324,10 +324,12 @@ wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& typ
if (m_Data[f].Doc == NULL || m_Data[f].Doc->GetRoot() == NULL) continue; if (m_Data[f].Doc == NULL || m_Data[f].Doc->GetRoot() == NULL) continue;
for (wxXmlNode *node = m_Data[f].Doc->GetRoot()->GetChildren(); for (wxXmlNode *node = m_Data[f].Doc->GetRoot()->GetChildren();
node; node = node->GetNext()) node; node = node->GetNext())
if ( node->GetType() == wxXML_ELEMENT_NODE && if (node->GetType() == wxXML_ELEMENT_NODE &&
(!type || node->GetName() == type) && (!classname ||
node->GetPropVal(wxT("name"), &dummy) && node->GetPropVal(wxT("class"), wxEmptyString) == classname) &&
dummy == name) node->GetName() == wxT("object") &&
node->GetPropVal(wxT("name"), &dummy) &&
dummy == name)
{ {
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
m_CurFileSystem.ChangePathTo(m_Data[f].File); m_CurFileSystem.ChangePathTo(m_Data[f].File);
@@ -336,8 +338,8 @@ wxXmlNode *wxXmlResource::FindResource(const wxString& name, const wxString& typ
} }
} }
wxLogError(_("XML resource '%s' (type '%s') not found!"), wxLogError(_("XML resource '%s' (class '%s') not found!"),
name.c_str(), type.c_str()); name.c_str(), classname.c_str());
return NULL; return NULL;
} }
@@ -353,7 +355,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wx
while (ND) while (ND)
{ {
handler = (wxXmlResourceHandler*)ND->GetData(); handler = (wxXmlResourceHandler*)ND->GetData();
if (handler->CanHandle(node)) if (node->GetName() == _T("object") && handler->CanHandle(node))
{ {
ret = handler->CreateResource(node, parent, instance); ret = handler->CreateResource(node, parent, instance);
if (ret) return ret; if (ret) return ret;
@@ -361,7 +363,9 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wx
ND = ND->GetNext(); ND = ND->GetNext();
} }
wxLogError(_("No handler found for XML node '%s'!"), node->GetName().c_str()); wxLogError(_("No handler found for XML node '%s', class '%s'!"),
node->GetName().c_str(),
node->GetPropVal(_T("class"), wxEmptyString).c_str());
return NULL; return NULL;
} }
@@ -383,10 +387,12 @@ wxXmlResourceHandler::wxXmlResourceHandler()
wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance) wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance)
{ {
wxXmlNode *myNode = m_Node; wxXmlNode *myNode = m_Node;
wxString myClass = m_Class;
wxObject *myParent = m_Parent, *myInstance = m_Instance; wxObject *myParent = m_Parent, *myInstance = m_Instance;
wxWindow *myParentAW = m_ParentAsWindow, *myInstanceAW = m_InstanceAsWindow; wxWindow *myParentAW = m_ParentAsWindow, *myInstanceAW = m_InstanceAsWindow;
m_Node = node; m_Node = node;
m_Class = node->GetPropVal(_T("class"), wxEmptyString);
m_Parent = parent; m_Parent = parent;
m_Instance = instance; m_Instance = instance;
m_ParentAsWindow = wxDynamicCast(m_Parent, wxWindow); m_ParentAsWindow = wxDynamicCast(m_Parent, wxWindow);
@@ -395,6 +401,7 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent
wxObject *returned = DoCreateResource(); wxObject *returned = DoCreateResource();
m_Node = myNode; m_Node = myNode;
m_Class = myClass;
m_Parent = myParent; m_ParentAsWindow = myParentAW; m_Parent = myParent; m_ParentAsWindow = myParentAW;
m_Instance = myInstance; m_InstanceAsWindow = myInstanceAW; m_Instance = myInstance; m_InstanceAsWindow = myInstanceAW;
@@ -810,23 +817,17 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd)
} }
void wxXmlResourceHandler::CreateChildren(wxObject *parent, void wxXmlResourceHandler::CreateChildren(wxObject *parent, bool this_hnd_only)
bool only_this_handler, wxXmlNode *children_node)
{ {
if (children_node == NULL) children_node = GetParamNode(_T("children")); wxXmlNode *n = m_Node->GetChildren();
if (children_node == NULL) return;
wxXmlNode *n = children_node->GetChildren();
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE) if (n->GetType() == wxXML_ELEMENT_NODE &&
n->GetName() == _T("object"))
{ {
if (only_this_handler) if (this_hnd_only && CanHandle(n))
{ CreateResource(n, parent, NULL);
if (CanHandle(n))
CreateResource(n, parent, NULL);
}
else else
m_Resource->CreateResFromNode(n, parent, NULL); m_Resource->CreateResFromNode(n, parent, NULL);
} }
@@ -835,6 +836,23 @@ void wxXmlResourceHandler::CreateChildren(wxObject *parent,
} }
void wxXmlResourceHandler::CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL)
{
wxXmlNode *root;
if (rootnode == NULL) root = m_Node; else root = rootnode;
wxXmlNode *n = root->GetChildren();
while (n)
{
if (n->GetType() == wxXML_ELEMENT_NODE && CanHandle(n))
{
CreateResource(n, parent, NULL);
}
n = n->GetNext();
}
}

View File

@@ -123,7 +123,7 @@ microsoft reuses the keyword DIALOG for other things
wxString title; wxString title;
wxString ptsize,face; wxString ptsize,face;
m_xmlfile.Write("\t<dialog"); m_xmlfile.Write("\t<object class=\"wxDialog\"");
//Avoid duplicate names this way //Avoid duplicate names this way
dlgname.Replace("IDD_","DLG_"); dlgname.Replace("IDD_","DLG_");
WriteBasicInfo(x,y,width,height,dlgname); WriteBasicInfo(x,y,width,height,dlgname);
@@ -152,10 +152,8 @@ microsoft reuses the keyword DIALOG for other things
token=GetToken(); token=GetToken();
} }
m_xmlfile.Write("\t<children>\n");
ParseControls(); ParseControls();
m_xmlfile.Write("\t</children>\n"); m_xmlfile.Write("\t</object>\n");
m_xmlfile.Write("\t</dialog>\n");
} }
/* /*
@@ -207,9 +205,9 @@ void rc2xml::ParseStaticText()
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<statictext"); m_xmlfile.Write("\t\t<object class=\"wxStaticText\"");
WriteBasicInfo(x,y,width,height,varname);WriteLabel(phrase); WriteBasicInfo(x,y,width,height,varname);WriteLabel(phrase);
m_xmlfile.Write("\t\t</statictext>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
//EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL //EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
@@ -222,9 +220,9 @@ void rc2xml::ParseTextCtrl()
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
//TODO //TODO
//style=GetToken(); //style=GetToken();
m_xmlfile.Write("\t\t<textctrl"); m_xmlfile.Write("\t\t<object class\"wxTextCtrl\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
m_xmlfile.Write("\t\t</textctrl>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
//PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP //PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP
@@ -238,10 +236,10 @@ void rc2xml::ParsePushButton()
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<button"); m_xmlfile.Write("\t\t<object class\"wxButton\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteLabel(phrase); WriteLabel(phrase);
m_xmlfile.Write("\t\t</button>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
@@ -271,10 +269,10 @@ void rc2xml::ParseGroupBox()
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<staticbox"); m_xmlfile.Write("\t\t<object class=\"wxStaticBox\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteLabel(phrase); WriteLabel(phrase);
m_xmlfile.Write("\t\t</staticbox>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
void rc2xml::ReadRect(int & x, int & y, int & width, int & height) void rc2xml::ReadRect(int & x, int & y, int & width, int & height)
@@ -375,9 +373,9 @@ void rc2xml::ParseComboBox()
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<combobox"); m_xmlfile.Write("\t\t<object class=\"wxComboBox\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
m_xmlfile.Write("\n\t\t</combobox>\n"); m_xmlfile.Write("\n\t\t</object>\n");
} }
@@ -386,12 +384,11 @@ void rc2xml::ParseMenu(wxString varname)
wxString token=""; wxString token="";
//Write menubar to xml file //Write menubar to xml file
m_xmlfile.Write("\t<menubar"); m_xmlfile.Write("\t<object class=\"wxMenuBar\"");
//Avoid duplicate names this way //Avoid duplicate names this way
varname.Replace("IDR_","MB_"); varname.Replace("IDR_","MB_");
WriteName(varname); WriteName(varname);
m_xmlfile.Write(">\n"); m_xmlfile.Write(">\n");
m_xmlfile.Write("\t\t<children>\n");
while ((token!="BEGIN")&(token!="{")) while ((token!="BEGIN")&(token!="{"))
token=GetToken(); token=GetToken();
@@ -404,8 +401,7 @@ void rc2xml::ParseMenu(wxString varname)
ParsePopupMenu(); ParsePopupMenu();
} }
} }
m_xmlfile.Write("\t\t</children>\n"); m_xmlfile.Write("\t</object>\n");
m_xmlfile.Write("\t</menubar>\n");
} }
void rc2xml::ParsePopupMenu() void rc2xml::ParsePopupMenu()
@@ -423,11 +419,10 @@ void rc2xml::ParsePopupMenu()
//Write Menu item //Write Menu item
//Generate a fake name since RC menus don't have one //Generate a fake name since RC menus don't have one
name<<"Menu_"<<menucount; name<<"Menu_"<<menucount;
m_xmlfile.Write("\t\t<menu"); m_xmlfile.Write("\t\t<object class=\"wxMenu\"");
WriteName(name); WriteName(name);
m_xmlfile.Write(">\n"); m_xmlfile.Write(">\n");
WriteLabel(token); WriteLabel(token);
m_xmlfile.Write("\t\t\t<children>\n");
while ((token!="BEGIN")&(token!="{")) while ((token!="BEGIN")&(token!="{"))
token=GetToken(); token=GetToken();
@@ -441,8 +436,7 @@ void rc2xml::ParsePopupMenu()
if (token=="MENUITEM") if (token=="MENUITEM")
ParseMenuItem(); ParseMenuItem();
} }
m_xmlfile.Write("\t\t\t</children>\n"); m_xmlfile.Write("\t\t\t</object>\n");
m_xmlfile.Write("\t\t\t</menu>\n");
} }
wxString rc2xml::PeekToken() wxString rc2xml::PeekToken()
@@ -484,10 +478,10 @@ void rc2xml::ParseSlider(wxString label, wxString varname)
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<slider"); m_xmlfile.Write("\t\t<object class=\"wxSlider\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style); WriteStyle(style);
m_xmlfile.Write("\n\t\t</slider>\n"); m_xmlfile.Write("\n\t\t</object>\n");
} }
/* /*
@@ -503,10 +497,10 @@ void rc2xml::ParseProgressBar(wxString label, wxString varname)
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
//Always horizontal in MFC //Always horizontal in MFC
m_xmlfile.Write("\t\t<gauge"); m_xmlfile.Write("\t\t<object class=\"wxGauge\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style); WriteStyle(style);
m_xmlfile.Write("\t\t</gauge>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
bool rc2xml::ReadOrs(wxString & orstring) bool rc2xml::ReadOrs(wxString & orstring)
@@ -538,19 +532,19 @@ void rc2xml::ParseCtrlButton(wxString label, wxString varname)
if (token.Find("BS_AUTOCHECKBOX")!=-1) if (token.Find("BS_AUTOCHECKBOX")!=-1)
{ {
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<checkbox"); m_xmlfile.Write("\t\t<object class=\"wxCheckBox\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteLabel(label); WriteLabel(label);
m_xmlfile.Write("\t\t</checkbox>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
if (token.Find("BS_AUTORADIOBUTTON")!=-1) if (token.Find("BS_AUTORADIOBUTTON")!=-1)
{ {
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<radiobutton"); m_xmlfile.Write("\t\t<object class=\"wxRadioButton\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteLabel(label); WriteLabel(label);
m_xmlfile.Write("\t\t</radiobutton>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
} }
@@ -654,9 +648,9 @@ void rc2xml::ParseListBox()
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<listbox"); m_xmlfile.Write("\t\t<object class=\"wxListBox\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
m_xmlfile.Write("\n\t\t</listbox>\n"); m_xmlfile.Write("\n\t\t</object>\n");
} }
/* /*
@@ -673,10 +667,10 @@ void rc2xml::ParseRichEdit(wxString label, wxString varname)
wxString style; wxString style;
//Make it a rich text control //Make it a rich text control
style+="wxTE_MULTILINE "; style+="wxTE_MULTILINE ";
m_xmlfile.Write("\t\t<textctrl"); m_xmlfile.Write("\t\t<object class=\"wxTextCtrl\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style); WriteStyle(style);
m_xmlfile.Write("\t\t</textctrl>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
/* /*
@@ -696,10 +690,10 @@ void rc2xml::ParseSpinCtrl(wxString label, wxString varname)
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<spinbutton"); m_xmlfile.Write("\t\t<object class=\"wxSpinButton\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style); WriteStyle(style);
m_xmlfile.Write("\n\t\t</spinbutton>\n"); m_xmlfile.Write("\n\t\t</object>\n");
} }
@@ -770,7 +764,7 @@ void rc2xml::ParseToolBar(wxString varname)
wxLogError("Unable to load bitmap:"+*bitmappath); wxLogError("Unable to load bitmap:"+*bitmappath);
//Write toolbar to xml file //Write toolbar to xml file
m_xmlfile.Write(" <toolbar"); m_xmlfile.Write(" <object class=\"wxToolBar\"");
//Avoid duplicate names this way //Avoid duplicate names this way
varname.Replace("IDR_","TB_"); varname.Replace("IDR_","TB_");
WriteName(varname); WriteName(varname);
@@ -779,7 +773,6 @@ void rc2xml::ParseToolBar(wxString varname)
style+="wxTB_FLAT"; style+="wxTB_FLAT";
WriteStyle(style); WriteStyle(style);
m_xmlfile.Write("\t\t<children>\n");
//Grab width and height //Grab width and height
int width,height; int width,height;
@@ -797,7 +790,7 @@ void rc2xml::ParseToolBar(wxString varname)
if (token=="BUTTON") if (token=="BUTTON")
{ {
buttonname=GetToken(); buttonname=GetToken();
m_xmlfile.Write("\t\t\t<tool"); m_xmlfile.Write("\t\t\t<object class=\"tool\"");
WriteName(buttonname); WriteName(buttonname);
m_xmlfile.Write(">\n"); m_xmlfile.Write(">\n");
//Write tool tip if any //Write tool tip if any
@@ -812,17 +805,16 @@ void rc2xml::ParseToolBar(wxString varname)
buttonname+=".bmp"; buttonname+=".bmp";
m_xmlfile.Write("\t\t\t\t<bitmap>"+buttonname+"</bitmap>\n"); m_xmlfile.Write("\t\t\t\t<bitmap>"+buttonname+"</bitmap>\n");
WriteToolButton(buttonname,c,width,height,bitmap); WriteToolButton(buttonname,c,width,height,bitmap);
m_xmlfile.Write("\t\t\t</tool>\n"); m_xmlfile.Write("\t\t\t</object>\n");
c++; c++;
} }
else if (token=="SEPARATOR") else if (token=="SEPARATOR")
{ {
m_xmlfile.Write("\t\t\t<separator/>\n"); m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
} }
token=GetToken(); token=GetToken();
} }
m_xmlfile.Write("\t</children>\n"); m_xmlfile.Write("\t</object>\n");
m_xmlfile.Write("\t</toolbar>\n");
} }
//Extract bitmaps from larger toolbar bitmap //Extract bitmaps from larger toolbar bitmap
@@ -890,7 +882,7 @@ void rc2xml::ParseMenuItem()
//int spot; //int spot;
if (PeekToken()=="SEPARATOR") if (PeekToken()=="SEPARATOR")
{ {
m_xmlfile.Write("\t\t\t<separator/>\n"); m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
return; return;
} }
@@ -899,7 +891,7 @@ void rc2xml::ParseMenuItem()
//Remove \t because it causes problems //Remove \t because it causes problems
//spot=token.First("\\t"); //spot=token.First("\\t");
//token=token.Left(spot); //token=token.Left(spot);
m_xmlfile.Write("\t\t\t<menuitem"); m_xmlfile.Write("\t\t\t<object class=\"wxMenuItem\"");
WriteName(name); WriteName(name);
m_xmlfile.Write(">\n"); m_xmlfile.Write(">\n");
WriteLabel(token); WriteLabel(token);
@@ -926,7 +918,7 @@ void rc2xml::ParseMenuItem()
ptoken=PeekToken(); ptoken=PeekToken();
} }
m_xmlfile.Write("\t\t\t</menuitem>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
@@ -942,11 +934,11 @@ void rc2xml::ParseIconStatic()
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<staticbitmap"); m_xmlfile.Write("\t\t<object class=\"wxStaticBitmap\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
//Save icon as a bitmap //Save icon as a bitmap
WriteIcon(iconname); WriteIcon(iconname);
m_xmlfile.Write("\t\t</staticbitmap>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
//IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico" //IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico"
@@ -984,10 +976,10 @@ void rc2xml::ParseStaticBitmap(wxString bitmapname, wxString varname)
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<staticbitmap"); m_xmlfile.Write("\t\t<object class=\"wxStaticBitmap\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteBitmap(bitmapname); WriteBitmap(bitmapname);
m_xmlfile.Write("\t\t</staticbitmap>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
@@ -1058,10 +1050,10 @@ if (token.Find("SBS_VERT")!=-1)
else else
style=_T("wxSB_HORIZONTAL"); style=_T("wxSB_HORIZONTAL");
m_xmlfile.Write("\t\t<scrollbar"); m_xmlfile.Write("\t\t<object class=\"wxScrollBar\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style); WriteStyle(style);
m_xmlfile.Write("\n\t\t</scrollbar>\n"); m_xmlfile.Write("\n\t\t</object>\n");
} }
// CONTROL "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP, // CONTROL "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP,
@@ -1074,9 +1066,9 @@ void rc2xml::ParseTreeCtrl(wxString label, wxString varname)
ReadOrs(token); ReadOrs(token);
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<treectrl"); m_xmlfile.Write("\t\t<object class=\"wxTreeCtrl\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
m_xmlfile.Write("\t\t</treectrl>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
// CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32", // CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32",
@@ -1089,9 +1081,9 @@ void rc2xml::ParseCalendar(wxString label, wxString varname)
ReadOrs(token); ReadOrs(token);
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<calendarctrl"); m_xmlfile.Write("\t\t<object class=\"wxCalendarCtrl\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
m_xmlfile.Write("\t\t</calendarctrl>\n"); m_xmlfile.Write("\t\t</object>\n");
} }
// CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP, // CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP,
// 7,89,68,71 // 7,89,68,71
@@ -1103,9 +1095,9 @@ void rc2xml::ParseListCtrl(wxString label, wxString varname)
ReadOrs(token); ReadOrs(token);
int x,y,width,height; int x,y,width,height;
ReadRect(x,y,width,height); ReadRect(x,y,width,height);
m_xmlfile.Write("\t\t<listctrl"); m_xmlfile.Write("\t\t<object class=\"wxListCtrl\"");
WriteBasicInfo(x,y,width,height,varname); WriteBasicInfo(x,y,width,height,varname);
m_xmlfile.Write("\t\t</listctrl>\n"); m_xmlfile.Write("\t\t</object>\n");
} }

View File

@@ -92,28 +92,24 @@ bool wxr2xml::ParseResources()
void wxr2xml::ParsePanel(wxItemResource * res) void wxr2xml::ParsePanel(wxItemResource * res)
{ {
m_xmlfile.Write("\t<panel"); m_xmlfile.Write("\t<object class=\"wxPanel\"");
PanelStuff(res); PanelStuff(res);
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write("\n"); m_xmlfile.Write("\n");
m_xmlfile.Write("\t\t<children>\n");
ParseControls(res); ParseControls(res);
m_xmlfile.Write(" \t\t</children>\n"); m_xmlfile.Write("\t</object>\n\n");
m_xmlfile.Write("\t</panel>\n\n");
} }
void wxr2xml::ParseDialog(wxItemResource * res) void wxr2xml::ParseDialog(wxItemResource * res)
{ {
PanelStuff(res); PanelStuff(res);
m_xmlfile.Write("\t<dialog"); m_xmlfile.Write("\t<object class=\"wxDialog\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetTitle(res)); m_xmlfile.Write(GetTitle(res));
m_xmlfile.Write("\n"); m_xmlfile.Write("\n");
m_xmlfile.Write("\t\t<children>\n");
ParseControls(res); ParseControls(res);
m_xmlfile.Write("\t\t</children>\n"); m_xmlfile.Write("\t</object>\n\n");
m_xmlfile.Write("\t</dialog>\n\n");
} }
void wxr2xml::ParseControls(wxItemResource * res) void wxr2xml::ParseControls(wxItemResource * res)
@@ -194,18 +190,18 @@ wxString wxr2xml::GetPosition(wxItemResource * res)
void wxr2xml::ParseButton(wxItemResource * res) void wxr2xml::ParseButton(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<button"); m_xmlfile.Write("\t\t\t<object class=\"wxButton\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetLabel(res)); m_xmlfile.Write(GetLabel(res));
m_xmlfile.Write("\t\t\t</button>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::ParseTextCtrl(wxItemResource * res) void wxr2xml::ParseTextCtrl(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<textctrl"); m_xmlfile.Write("\t\t\t<object class=\"wxTextCtrl\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetValue4(res)); m_xmlfile.Write(GetValue4(res));
m_xmlfile.Write("\t\t\t</textctrl>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
@@ -225,11 +221,11 @@ wxString wxr2xml::GetValue4(wxItemResource * res)
void wxr2xml::ParseCheckBox(wxItemResource * res) void wxr2xml::ParseCheckBox(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<checkbox"); m_xmlfile.Write("\t\t\t<object class=\"wxCheckBox\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetLabel(res)); m_xmlfile.Write(GetLabel(res));
m_xmlfile.Write(GetCheckStatus(res)); m_xmlfile.Write(GetCheckStatus(res));
m_xmlfile.Write("\t\t\t</checkbox>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
wxString wxr2xml::GetLabel(wxItemResource * res) wxString wxr2xml::GetLabel(wxItemResource * res)
@@ -239,38 +235,38 @@ wxString wxr2xml::GetLabel(wxItemResource * res)
void wxr2xml::ParseRadioBox(wxItemResource * res) void wxr2xml::ParseRadioBox(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<radiobox"); m_xmlfile.Write("\t\t\t<object class=\"wxRadioBox\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetLabel(res)); m_xmlfile.Write(GetLabel(res));
// Add radio box items // Add radio box items
WriteStringList(res); WriteStringList(res);
// Value1 // Value1
m_xmlfile.Write(GetDimension(res)); m_xmlfile.Write(GetDimension(res));
m_xmlfile.Write("\t\t\t</radiobox>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::ParseListBox(wxItemResource * res) void wxr2xml::ParseListBox(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<listbox"); m_xmlfile.Write("\t\t\t<object class=\"wxListBox\"");
WriteControlInfo(res); WriteControlInfo(res);
WriteStringList(res); WriteStringList(res);
m_xmlfile.Write("\t\t\t</listbox>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::ParseStaticText(wxItemResource * res) void wxr2xml::ParseStaticText(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<statictext"); m_xmlfile.Write("\t\t\t<object class=\"wxStaticText\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetLabel(res)); m_xmlfile.Write(GetLabel(res));
m_xmlfile.Write("\t\t\t</statictext>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::ParseStaticBox(wxItemResource * res) void wxr2xml::ParseStaticBox(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<staticbox"); m_xmlfile.Write("\t\t\t<object class=\"wxStaticBox\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetLabel(res)); m_xmlfile.Write(GetLabel(res));
m_xmlfile.Write("\t\t\t</staticbox>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::WriteStringList(wxItemResource * res) void wxr2xml::WriteStringList(wxItemResource * res)
@@ -286,20 +282,20 @@ void wxr2xml::WriteStringList(wxItemResource * res)
void wxr2xml::ParseChoice(wxItemResource * res) void wxr2xml::ParseChoice(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<choice"); m_xmlfile.Write("\t\t\t<object class=\"wxChoice\"");
WriteControlInfo(res); WriteControlInfo(res);
// Add choice items // Add choice items
WriteStringList(res); WriteStringList(res);
m_xmlfile.Write("\t\t\t</choice>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::ParseGauge(wxItemResource * res) void wxr2xml::ParseGauge(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<gauge"); m_xmlfile.Write("\t\t\t<object class=\"wxGauge\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetValue1(res)); m_xmlfile.Write(GetValue1(res));
m_xmlfile.Write(GetRange(res)); m_xmlfile.Write(GetRange(res));
m_xmlfile.Write("\n\t\t\t</gauge>\n"); m_xmlfile.Write("\n\t\t\t</object>\n");
} }
wxString wxr2xml::GetValue1(wxItemResource * res) wxString wxr2xml::GetValue1(wxItemResource * res)
@@ -318,12 +314,12 @@ wxString wxr2xml::GetRange(wxItemResource * res)
void wxr2xml::ParseSlider(wxItemResource * res) void wxr2xml::ParseSlider(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<slider"); m_xmlfile.Write("\t\t\t<object class=\"wxSlider\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetValue1(res)); m_xmlfile.Write(GetValue1(res));
m_xmlfile.Write(GetMax(res)); m_xmlfile.Write(GetMax(res));
m_xmlfile.Write(GetMin(res)); m_xmlfile.Write(GetMin(res));
m_xmlfile.Write("\n\t\t\t</slider>\n"); m_xmlfile.Write("\n\t\t\t</object>\n");
} }
wxString wxr2xml::GetMax(wxItemResource * res) wxString wxr2xml::GetMax(wxItemResource * res)
@@ -342,34 +338,34 @@ wxString wxr2xml::GetMin(wxItemResource * res)
void wxr2xml::ParseComboBox(wxItemResource * res) void wxr2xml::ParseComboBox(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<combobox"); m_xmlfile.Write("\t\t\t<object class=\"wxComboBox\"");
WriteControlInfo(res); WriteControlInfo(res);
// Add combo items // Add combo items
WriteStringList(res); WriteStringList(res);
m_xmlfile.Write("\n\t\t\t</combobox>\n"); m_xmlfile.Write("\n\t\t\t</object>\n");
} }
void wxr2xml::ParseRadioButton(wxItemResource * res) void wxr2xml::ParseRadioButton(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<radiobutton"); m_xmlfile.Write("\t\t\t<object class=\"wxRadioButton\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetLabel(res)); m_xmlfile.Write(GetLabel(res));
wxString msg; wxString msg;
m_xmlfile.Write(GetValue1(res)); m_xmlfile.Write(GetValue1(res));
m_xmlfile.Write(GetCheckStatus(res)); m_xmlfile.Write(GetCheckStatus(res));
m_xmlfile.Write("\t\t\t</radiobutton>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::ParseScrollBar(wxItemResource * res) void wxr2xml::ParseScrollBar(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<scrollbar"); m_xmlfile.Write("\t\t\t<object class=\"wxScrollBar\"");
WriteControlInfo(res); WriteControlInfo(res);
m_xmlfile.Write(GetValue1(res)); m_xmlfile.Write(GetValue1(res));
m_xmlfile.Write("\t\t\t\t<thumbsize>"+GetValue2(res)+"</thumbsize>\n"); m_xmlfile.Write("\t\t\t\t<thumbsize>"+GetValue2(res)+"</thumbsize>\n");
m_xmlfile.Write("\t\t\t\t<range>"+GetValue3(res)+"</range>\n"); m_xmlfile.Write("\t\t\t\t<range>"+GetValue3(res)+"</range>\n");
m_xmlfile.Write("\t\t\t\t<pagesize>"+GetValue5(res)+"</pagesize>\n"); m_xmlfile.Write("\t\t\t\t<pagesize>"+GetValue5(res)+"</pagesize>\n");
m_xmlfile.Write("\t\t\t</scrollbar>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
wxString wxr2xml::GetCheckStatus(wxItemResource * res) wxString wxr2xml::GetCheckStatus(wxItemResource * res)
@@ -584,18 +580,16 @@ void wxr2xml::ParseMenuBar(wxItemResource * res)
wxItemResource *child; wxItemResource *child;
wxNode *node = res->GetChildren().First(); wxNode *node = res->GetChildren().First();
// Get Menu Bar Name // Get Menu Bar Name
m_xmlfile.Write("\t<menubar "); m_xmlfile.Write("\t<object class=\"wxMenuBar\" ");
m_xmlfile.Write(GenerateName(res)); m_xmlfile.Write(GenerateName(res));
m_xmlfile.Write(">\n"); m_xmlfile.Write(">\n");
m_xmlfile.Write("\t\t<children>\n");
while (node) { while (node) {
child = (wxItemResource *) node->Data(); child = (wxItemResource *) node->Data();
ParseMenu(child); ParseMenu(child);
node = node->Next(); node = node->Next();
} }
m_xmlfile.Write("\t\t</children>\n"); m_xmlfile.Write("\t</object> \n\n");
m_xmlfile.Write("\t</menubar> \n\n");
} }
void wxr2xml::ParseMenu(wxItemResource * res) void wxr2xml::ParseMenu(wxItemResource * res)
@@ -603,7 +597,7 @@ void wxr2xml::ParseMenu(wxItemResource * res)
wxItemResource *child; wxItemResource *child;
wxNode *node = res->GetChildren().First(); wxNode *node = res->GetChildren().First();
// Get Menu // Get Menu
m_xmlfile.Write("\t\t\t<menu "); m_xmlfile.Write("\t\t\t<object class=\"wxMenu\" ");
wxString menuname; wxString menuname;
menuname << "name = \"menu_" << res->GetValue1() << "\""; menuname << "name = \"menu_" << res->GetValue1() << "\"";
m_xmlfile.Write(menuname); m_xmlfile.Write(menuname);
@@ -613,7 +607,6 @@ void wxr2xml::ParseMenu(wxItemResource * res)
if (res->GetValue4() != "") if (res->GetValue4() != "")
m_xmlfile.Write("\t\t\t\t<help>" + res->GetValue4() + m_xmlfile.Write("\t\t\t\t<help>" + res->GetValue4() +
"</help>\n"); "</help>\n");
m_xmlfile.Write("\t\t\t<children>\n");
// Read in menu items and additional menus // Read in menu items and additional menus
while (node) { while (node) {
child = (wxItemResource *) node->Data(); child = (wxItemResource *) node->Data();
@@ -623,17 +616,16 @@ void wxr2xml::ParseMenu(wxItemResource * res)
ParseMenu(child); ParseMenu(child);
node = node->Next(); node = node->Next();
} }
m_xmlfile.Write("\t\t\t</children>\n"); m_xmlfile.Write("\t\t\t</object> \n");
m_xmlfile.Write("\t\t\t</menu> \n");
} }
void wxr2xml::ParseMenuItem(wxItemResource * res) void wxr2xml::ParseMenuItem(wxItemResource * res)
{ {
// Get Menu Item or Separator // Get Menu Item or Separator
if (res->GetTitle() == "") { if (res->GetTitle() == "") {
m_xmlfile.Write("\t\t\t<separator/>\n"); m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
} else { } else {
m_xmlfile.Write("\t\t\t\t<menuitem "); m_xmlfile.Write("\t\t\t\t<object class=\"wxMenuItem\" ");
wxString menuname; wxString menuname;
menuname << "name = \"menuitem_" << res->GetValue1() << "\""; menuname << "name = \"menuitem_" << res->GetValue1() << "\"";
m_xmlfile.Write(menuname); m_xmlfile.Write(menuname);
@@ -645,7 +637,7 @@ void wxr2xml::ParseMenuItem(wxItemResource * res)
res->GetValue4() + "</help>\n"); res->GetValue4() + "</help>\n");
if (res->GetValue2()) if (res->GetValue2())
m_xmlfile.Write("\t\t\t\t<checkable>1</checkable>\n"); m_xmlfile.Write("\t\t\t\t<checkable>1</checkable>\n");
m_xmlfile.Write("\t\t\t</menuitem> \n"); m_xmlfile.Write("\t\t\t</object> \n");
} }
} }
@@ -657,7 +649,7 @@ wxString wxr2xml::FixMenuString(wxString phrase)
void wxr2xml::ParseStaticBitmap(wxItemResource * res) void wxr2xml::ParseStaticBitmap(wxItemResource * res)
{ {
m_xmlfile.Write("\t\t\t<staticbitmap"); m_xmlfile.Write("\t\t\t<object class=\"wxStaticBitmap\"");
WriteControlInfo(res); WriteControlInfo(res);
// value4 holds bitmap name // value4 holds bitmap name
wxString bitmapname; wxString bitmapname;
@@ -667,13 +659,13 @@ void wxr2xml::ParseStaticBitmap(wxItemResource * res)
bitmapname += _T(".bmp"); bitmapname += _T(".bmp");
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
m_xmlfile.Write("\n\t\t\t\t<bitmap>" + bitmapname + "</bitmap>"); m_xmlfile.Write("\n\t\t\t\t<bitmap>" + bitmapname + "</bitmap>");
m_xmlfile.Write("\t\t\t</staticbitmap>\n"); m_xmlfile.Write("\t\t\t</object>\n");
// bitmap5 // bitmap5
} }
//Parse a bitmap resource //Parse a bitmap resource
void wxr2xml::ParseBitmap(wxItemResource * res) void wxr2xml::ParseBitmap(wxItemResource * res)
{ {
m_xmlfile.Write("\t<bitmap "); m_xmlfile.Write("\t<object class=\"wxBitmap\" ");
m_xmlfile.Write(GenerateName(res)+">"); m_xmlfile.Write(GenerateName(res)+">");
wxString bitmapname; wxString bitmapname;
bitmapname = res->GetName(); bitmapname = res->GetName();
@@ -682,7 +674,7 @@ void wxr2xml::ParseBitmap(wxItemResource * res)
bitmapname += _T(".bmp"); bitmapname += _T(".bmp");
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
m_xmlfile.Write(bitmapname); m_xmlfile.Write(bitmapname);
m_xmlfile.Write("</bitmap>\n\n"); m_xmlfile.Write("</object>\n\n");
} }
void wxr2xml::PanelStuff(wxItemResource * res) void wxr2xml::PanelStuff(wxItemResource * res)
@@ -727,7 +719,7 @@ wxString wxr2xml::GetValue5(wxItemResource *res)
void wxr2xml::ParseBitmapButton(wxItemResource *res) void wxr2xml::ParseBitmapButton(wxItemResource *res)
{ {
m_xmlfile.Write("\t\t\t<bitmapbutton"); m_xmlfile.Write("\t\t\t<object class=\"wxBitmapButton\"");
WriteControlInfo(res); WriteControlInfo(res);
// value4 holds bitmap name // value4 holds bitmap name
wxString bitmapname; wxString bitmapname;
@@ -738,7 +730,7 @@ void wxr2xml::ParseBitmapButton(wxItemResource *res)
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
m_xmlfile.Write("\t\t\t\t<bitmap>" + bitmapname + "</bitmap>\n"); m_xmlfile.Write("\t\t\t\t<bitmap>" + bitmapname + "</bitmap>\n");
m_xmlfile.Write("\t\t\t</bitmapbutton>\n"); m_xmlfile.Write("\t\t\t</object>\n");
} }
void wxr2xml::WriteFontInfo(wxItemResource *res) void wxr2xml::WriteFontInfo(wxItemResource *res)
@@ -779,19 +771,19 @@ void wxr2xml::GetFontFace(wxFont font)
case wxDEFAULT: case wxDEFAULT:
break; break;
case wxDECORATIVE: case wxDECORATIVE:
m_xmlfile.Write("\t\t\t\t<face>Decorative</face>\n"); m_xmlfile.Write("\t\t\t\t<face>decorative</face>\n");
break; break;
case wxROMAN: case wxROMAN:
m_xmlfile.Write("\t\t\t\t<face>Roman</face>\n"); m_xmlfile.Write("\t\t\t\t<face>roman</face>\n");
break; break;
case wxSCRIPT: case wxSCRIPT:
m_xmlfile.Write("\t\t\t\t<face>Script</face>\n"); m_xmlfile.Write("\t\t\t\t<face>script</face>\n");
break; break;
case wxSWISS: case wxSWISS:
m_xmlfile.Write("\t\t\t\t<face>Swiss</face>\n"); m_xmlfile.Write("\t\t\t\t<face>swiss</face>\n");
break; break;
case wxMODERN: case wxMODERN:
m_xmlfile.Write("\t\t\t\t<face>Modern</face>\n"); m_xmlfile.Write("\t\t\t\t<face>modern</face>\n");
break; break;
default: default:
wxLogError("Unknown font face"); wxLogError("Unknown font face");

View File

@@ -83,7 +83,7 @@ int XmlResApp::OnRun()
{ wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" }, { wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" },
{ wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" }, { wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" },
{ wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" }, { wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" },
{ wxCMD_LINE_OPTION, "o", "output", "output file [resource.rsc/cpp]" }, { wxCMD_LINE_OPTION, "o", "output", "output file [resource.xrs/cpp]" },
{ wxCMD_LINE_OPTION, "l", "list-of-handlers", "output list of neccessary handlers to this file" }, { wxCMD_LINE_OPTION, "l", "list-of-handlers", "output list of neccessary handlers to this file" },
{ wxCMD_LINE_PARAM, NULL, NULL, "input file", { wxCMD_LINE_PARAM, NULL, NULL, "input file",
@@ -133,7 +133,7 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
flagCompress = flagCPP && !cmdline.Found("u"); flagCompress = flagCPP && !cmdline.Found("u");
if (!cmdline.Found("o", &parOutput)) if (!cmdline.Found("o", &parOutput))
parOutput = flagCPP ? "resource.cpp" : "resource.rsc"; parOutput = flagCPP ? "resource.cpp" : "resource.xrs";
parOutputPath = wxPathOnly(parOutput); parOutputPath = wxPathOnly(parOutput);
if (!parOutputPath) parOutputPath = "."; if (!parOutputPath) parOutputPath = ".";
@@ -189,8 +189,8 @@ wxArrayString XmlResApp::PrepareTempFiles()
FindFilesInXML(doc.GetRoot(), flist, path); FindFilesInXML(doc.GetRoot(), flist, path);
doc.Save(parOutputPath + "/" + name + ".xmb", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN); doc.Save(parOutputPath + "/" + name + ".xrc", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN);
flist.Add(name + ".xmb"); flist.Add(name + ".xrc");
} }
return flist; return flist;
@@ -285,38 +285,32 @@ static wxString FileToCppArray(wxString filename, int num)
wxString snum; wxString snum;
wxFFile file(filename, "rb"); wxFFile file(filename, "rb");
size_t lng = file.Length(); size_t lng = file.Length();
int linelng;
snum.Printf("%i", num); snum.Printf("%i", num);
output.Printf("static size_t xml_res_size_" + snum + " = %i;\n", lng); output.Printf("static size_t xml_res_size_" + snum + " = %i;\n", lng);
output += "static unsigned char xml_res_file_" + snum + "[] = \"\\\n"; output += "static unsigned char xml_res_file_" + snum + "[] = {\n";
// we cannot use string literals because MSVC is dumb wannabe compiler
// with arbitrary limitation to 2048 strings :(
unsigned char *buffer = new unsigned char[lng]; unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng); file.Read(buffer, lng);
for (size_t i = 0, linelng = 0; i < lng; i++) for (size_t i = 0, linelng = 0; i < lng; i++)
{ {
if (linelng > 70) tmp.Printf("%i", buffer[i]);
if (i != 0) output << ',';
if (linelng > 70)
{ {
linelng = 0; linelng = 0;
output += "\\\n"; output << "\n";
}
if (buffer[i] < 32 || buffer[i] == '"' || buffer[i] == '\\')
{
tmp.Printf("\\%03o", buffer[i]);
output += tmp;
linelng += 4;
}
else
{
output << (wxChar)buffer[i];
linelng++;
} }
output << tmp;
linelng += tmp.Length()+1;
} }
delete[] buffer; delete[] buffer;
output += "\"\n;\n\n"; output += "};\n\n";
return output; return output;
} }
@@ -378,7 +372,7 @@ void " + parFuncname + "()\n\
wxString name, ext, path; wxString name, ext, path;
wxSplitPath(parFiles[i], &path, &name, &ext); wxSplitPath(parFiles[i], &path, &name, &ext);
file.Write(" wxTheXmlResource->Load(\"memory:xml_resource/" + file.Write(" wxTheXmlResource->Load(\"memory:xml_resource/" +
name + ".xmb" + "\");\n"); name + ".xrc" + "\");\n");
} }
file.Write("\n}\n"); file.Write("\n}\n");

View File

@@ -6,57 +6,24 @@ program_dir = contrib/utils/wxrcedit
PROGRAM=wxrcedit PROGRAM=wxrcedit
OBJECTS=edapp.o editor.o nodehnd.o prophnd.o xmlhelpr.o OBJECTS=edapp.o editor.o nodehnd.o prophnd.o xmlhelpr.o preview.o
DATADIRS = df DATADIRS = df
DATAFILES = \ DATAFILES = df/break.df df/control.df df/menu_item.df df/notebookpage.df \
df/boxsizer.df \ df/panel_item.df df/panelbase.df df/separator.df df/sizer_item.df \
df/break.df \ df/sizeritem.df df/spacer.df df/tool.df df/toolbar_item.df \
df/button.df \ df/unknown.df df/window.df df/wxBitmapButton.df df/wxBoxSizer.df \
df/checkbox.df \ df/wxButton.df df/wxCalendarCtrl.df df/wxCheckBox.df \
df/checklist.df \ df/wxCheckList.df df/wxChoice.df df/wxComboBox.df df/wxDialog.df \
df/choice.df \ df/wxFlexGridSizer.df df/wxGauge.df df/wxGridSizer.df \
df/combobox.df \ df/wxHtmlWindow.df df/wxListBox.df df/wxListCtrl.df df/wxMenu.df \
df/control.df \ df/wxMenuBar.df df/wxMenuItem.df df/wxNotebook.df df/wxPanel.df \
df/dialog.df \ df/wxRadioBox.df df/wxRadioButton.df df/wxScrollBar.df \
df/flexgridsizer.df \ df/wxSlider.df df/wxSpinButton.df df/wxSpinCtrl.df \
df/gauge.df \ df/wxStaticBitmap.df df/wxStaticBox.df df/wxStaticBoxSizer.df \
df/gridsizer.df \ df/wxStaticLine.df df/wxStaticText.df df/wxTextCtrl.df \
df/htmlwindow.df \ df/wxToolBar.df df/wxTreeCtrl.df
df/menu.df \
df/menu_item.df \
df/menubar.df \
df/menuitem.df \
df/notebook.df \
df/notebookpage.df \
df/panel.df \
df/panel_item.df \
df/panelbase.df \
df/radiobox.df \
df/radiobutton.df \
df/separator.df \
df/sizer_item.df \
df/sizeritem.df \
df/slider.df \
df/spacer.df \
df/spinbutton.df \
df/spinctrl.df \
df/staticbitmap.df \
df/staticboxsizer.df \
df/statictext.df \
df/textctrl.df \
df/toolbar_item.df \
df/tool.df \
df/toolbar.df \
df/window.df \
df/listbox.df \
df/bitmapbutton.df \
df/calendarctrl.df \
df/listctrl.df \
df/scrollbar.df \
df/staticbox.df \
df/treectrl.df
APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@ APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@
APPEXTRADEFS=-I$(top_srcdir)/contrib/include APPEXTRADEFS=-I$(top_srcdir)/contrib/include

View File

@@ -1,4 +0,0 @@
node staticboxsizer
derived from boxsizer
var label of text
var minsize of coord

View File

@@ -1,4 +1,4 @@
node bitmapbutton node wxBitmapButton
var style of flags wxBU_AUTODRAW,wxBU_LEFT,wxBU_RIGHT,wxBU_TOP,wxBU_BOTTOM var style of flags wxBU_AUTODRAW,wxBU_LEFT,wxBU_RIGHT,wxBU_TOP,wxBU_BOTTOM
var default of bool var default of bool
var bitmap of text var bitmap of text

View File

@@ -1,4 +1,4 @@
node boxsizer node wxBoxSizer
type sizer type sizer
icon 0 icon 0
childtype sizer_item childtype sizer_item

View File

@@ -1,4 +1,4 @@
node button node wxButton
var label of text var label of text
var default of bool var default of bool
derived from control derived from control

View File

@@ -1,3 +1,3 @@
node calendarctrl node wxCalendarCtrl
var style of flags wxCAL_SUNDAY_FIRST,wxCAL_MONDAY_FIRST,wxCAL_SHOW_HOLIDAYS,wxCAL_NO_YEAR_CHANGE,wxCAL_NO_MONTH_CHANGE var style of flags wxCAL_SUNDAY_FIRST,wxCAL_MONDAY_FIRST,wxCAL_SHOW_HOLIDAYS,wxCAL_NO_YEAR_CHANGE,wxCAL_NO_MONTH_CHANGE
derived from control derived from control

View File

@@ -1,4 +1,4 @@
node checkbox node wxCheckBox
var label of text var label of text
var checked of bool var checked of bool
derived from control derived from control

View File

@@ -1,3 +1,3 @@
node checklist node wxCheckList
var content of not_implemented var content of not_implemented
derived from control derived from control

View File

@@ -1,4 +1,4 @@
node choice node wxChoice
var style of flags wxCB_SORT var style of flags wxCB_SORT
var selection of integer var selection of integer
var content of not_implemented var content of not_implemented

View File

@@ -1,4 +1,4 @@
node combobox node wxComboBox
var style of flags wxCB_SIMPLE,wxCB_SORT,wxCB_READONLY,wxCB_DROPDOWN var style of flags wxCB_SIMPLE,wxCB_SORT,wxCB_READONLY,wxCB_DROPDOWN
var value of string var value of string
var selection of integer var selection of integer

View File

@@ -1,4 +1,4 @@
node dialog node wxDialog
var title of text var title of text
var style of flags wxSTAY_ON_TOP,wxCAPTION,wxDEFAULT_DIALOG_STYLE,wxTHICK_FRAME,wxSYSTEM_MENU,wxRESIZE_BORDER,wxRESIZE_BOX,wxDIALOG_MODAL,wxDIALOG_MODELESS var style of flags wxSTAY_ON_TOP,wxCAPTION,wxDEFAULT_DIALOG_STYLE,wxTHICK_FRAME,wxSYSTEM_MENU,wxRESIZE_BORDER,wxRESIZE_BOX,wxDIALOG_MODAL,wxDIALOG_MODELESS
var centered of bool var centered of bool

View File

@@ -1,4 +1,4 @@
node flexgridsizer node wxFlexGridSizer
type sizer type sizer
icon 4 icon 4
childtype sizer_item childtype sizer_item

View File

@@ -1,4 +1,4 @@
node gauge node wxGauge
var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH
var range of integer var range of integer
var value of integer var value of integer

View File

@@ -1,4 +1,4 @@
node gridsizer node wxGridSizer
type sizer type sizer
icon 4 icon 4
childtype sizer_item childtype sizer_item

View File

@@ -1,4 +1,4 @@
node htmlwindow node wxHtmlWindow
var url of text var url of text
var htmlcode of text var htmlcode of text
var borders of dimension var borders of dimension

View File

@@ -1,4 +1,4 @@
node listbox node wxListBox
var style of flags wxLB_SINGLE,wxLB_MULTIPLE,wxLB_EXTENDED,wxLB_HSCROLL,wxLB_ALWAYS_SB,wxLB_NEEDED_SB,wxLB_SORT var style of flags wxLB_SINGLE,wxLB_MULTIPLE,wxLB_EXTENDED,wxLB_HSCROLL,wxLB_ALWAYS_SB,wxLB_NEEDED_SB,wxLB_SORT
var selection of integer var selection of integer
var content of not_implemented var content of not_implemented

View File

@@ -1,3 +1,3 @@
node listctrl node wxListCtrl
var style of flags wxLC_LIST,wxLC_REPORT,wxLC_REPORT,wxLC_ICON,wxLC_SMALL_ICON,wxLC_ALIGN_TOP,wxLC_ALIGN_LEFT,wxLC_AUTOARRANGE,wxLC_USER_TEXT,wxLC_EDIT_LABELS,wxLC_NO_HEADER,wxLC_SINGLE_SEL,wxLC_SORT_ASCENDING,wxLC_SORT_DESCENDING var style of flags wxLC_LIST,wxLC_REPORT,wxLC_REPORT,wxLC_ICON,wxLC_SMALL_ICON,wxLC_ALIGN_TOP,wxLC_ALIGN_LEFT,wxLC_AUTOARRANGE,wxLC_USER_TEXT,wxLC_EDIT_LABELS,wxLC_NO_HEADER,wxLC_SINGLE_SEL,wxLC_SORT_ASCENDING,wxLC_SORT_DESCENDING
derived from control derived from control

View File

@@ -1,4 +1,4 @@
node menu node wxMenu
type panel type panel
icon 0 icon 0
childtype menu_item childtype menu_item

View File

@@ -1,5 +1,5 @@
node menubar node wxMenuBar
type panel type panel
icon 0 icon 0
childtype menu childtype wxMenu
var style of flags wxMB_DOCKABLE var style of flags wxMB_DOCKABLE

View File

@@ -1,4 +1,4 @@
node menuitem node wxMenuItem
type normal type normal
icon 0 icon 0
var label of text var label of text

View File

@@ -1,6 +1,6 @@
node notebook node wxNotebook
type notebook type notebook
var style of flags wxNB_FIXEDWIDTH,wxNB_LEFT,wxNB_RIGHT,wxNB_BOTTOM var style of flags wxNB_FIXEDWIDTH,wxNB_LEFT,wxNB_RIGHT,wxNB_BOTTOM
var usenotebooksizer of bool var usenotebooksizer of bool
childtype panel childtype wxPanel
derived from control derived from control

View File

@@ -1,3 +1,3 @@
node panel node wxPanel
derived from panel_item derived from panel_item
derived from panelbase derived from panelbase

View File

@@ -1,4 +1,4 @@
node radiobox node wxRadioBox
var style of flags wxRA_SPECIFY_COLS,wxRA_HORIZONTAL,wxRA_SPECIFY_ROWS,wxRA_VERTICAL var style of flags wxRA_SPECIFY_COLS,wxRA_HORIZONTAL,wxRA_SPECIFY_ROWS,wxRA_VERTICAL
var label of text var label of text
var dimension of integer var dimension of integer

View File

@@ -1,4 +1,4 @@
node radiobutton node wxRadioButton
var label of text var label of text
var value of bool var value of bool
var style of flags wxRB_GROUP var style of flags wxRB_GROUP

View File

@@ -1,4 +1,4 @@
node scrollbar node wxScrollBar
var style of flags wxSB_HORIZONTAL,wxSB_VERTICAL var style of flags wxSB_HORIZONTAL,wxSB_VERTICAL
var value of integer var value of integer
var thumbsize of integer var thumbsize of integer

View File

@@ -1,4 +1,4 @@
node slider node wxSlider
var value of integer var value of integer
var min of integer var min of integer
var max of integer var max of integer

View File

@@ -1,4 +1,4 @@
node spinctrl node wxSpinButton
var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP
var value of integer var value of integer
var min of integer var min of integer

View File

@@ -1,4 +1,4 @@
node spinbutton node wxSpinCtrl
var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP
var value of integer var value of integer
var min of integer var min of integer

View File

@@ -1,3 +1,3 @@
node staticbitmap node wxStaticBitmap
var bitmap of text var bitmap of text
derived from control derived from control

View File

@@ -1,3 +1,3 @@
node staticbox node wxStaticBox
var label of text var label of text
derived from control derived from control

View File

@@ -0,0 +1,4 @@
node wxStaticBoxSizer
derived from wxBoxSizer
var label of text
var minsize of coord

View File

@@ -1,3 +1,3 @@
node staticline node wxStaticLine
var style of flags wxLI_HORIZONTAL,wxLI_VERTICAL var style of flags wxLI_HORIZONTAL,wxLI_VERTICAL
derived from control derived from control

View File

@@ -1,3 +1,3 @@
node statictext node wxStaticText
var label of text var label of text
derived from control derived from control

View File

@@ -1,4 +1,4 @@
node textctrl node wxTextCtrl
var value of text var value of text
var style of flags wxTE_PROCESS_ENTER,wxTE_PROCESS_TAB,wxTE_MULTILINE,wxTE_PASSWORD,wxTE_READONLY,wxHSCROLL var style of flags wxTE_PROCESS_ENTER,wxTE_PROCESS_TAB,wxTE_MULTILINE,wxTE_PASSWORD,wxTE_READONLY,wxHSCROLL
derived from control derived from control

View File

@@ -1,4 +1,4 @@
node toolbar node wxToolBar
type panel type panel
icon 0 icon 0
childtype toolbar_item childtype toolbar_item

View File

@@ -1,3 +1,3 @@
node treectrl node wxTreeCtrl
var style of flags wxTR_HAS_BUTTONS,wxTR_EDIT_LABELS,wxTR_MULTIPLE var style of flags wxTR_HAS_BUTTONS,wxTR_EDIT_LABELS,wxTR_MULTIPLE
derived from control derived from control

View File

@@ -31,6 +31,7 @@
#include "editor.h" #include "editor.h"
#include "nodehnd.h" #include "nodehnd.h"
#include "xmlhelpr.h" #include "xmlhelpr.h"
#include "preview.h"
@@ -146,7 +147,6 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
m_SelectedNode = NULL; m_SelectedNode = NULL;
m_Resource = NULL; m_Resource = NULL;
m_FileName = wxEmptyString; m_FileName = wxEmptyString;
m_Preview = NULL;
m_SelectedProp = -1; m_SelectedProp = -1;
wxMenu *menuFile = new wxMenu; wxMenu *menuFile = new wxMenu;
@@ -187,7 +187,6 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
#endif #endif
// must stay last: // must stay last:
m_Handlers.Append(new NodeHandlerUnknown(this)); m_Handlers.Append(new NodeHandlerUnknown(this));
// Create toolbar: // Create toolbar:
wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT); wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT);
@@ -295,6 +294,8 @@ EditorFrame::EditorFrame(wxFrame *parent, const wxString& filename)
EditorFrame::~EditorFrame() EditorFrame::~EditorFrame()
{ {
PreviewFrame::Get()->Close();
wxConfigBase *cfg = wxConfigBase::Get(); wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write("editor_x", (long)GetPosition().x); cfg->Write("editor_x", (long)GetPosition().x);
@@ -400,102 +401,6 @@ void EditorFrame::NewFile()
void EditorFrame::RefreshPreview(wxXmlNode *node)
{
wxConfigBase *cfg = wxConfigBase::Get();
wxBusyCursor bcur;
wxXmlResource *res = new wxXmlResource;
wxString tempfile;
wxPoint pos = wxPoint(cfg->Read("preview_x", -1), cfg->Read("preview_y", -1));
wxSize size = wxSize(cfg->Read("preview_w", 50), cfg->Read("preview_h", 300));
while (node->GetParent() != m_Resource->GetRoot())
node = node->GetParent();
m_Preview = wxFindWindowByName("preview_window");
if (m_Preview)
{
pos = m_Preview->GetPosition();
size = m_Preview->GetSize();
cfg->Write("preview_x", (long)pos.x);
cfg->Write("preview_y", (long)pos.y);
cfg->Write("preview_w", (long)size.x);
cfg->Write("preview_h", (long)size.y);
}
res->InitAllHandlers();
wxGetTempFileName("xmleditor", tempfile);
m_Resource->Save(tempfile, wxXML_IO_BIN);
res->Load(tempfile);
if (node->GetName() == "dialog")
{
wxDialog *dlg = new wxDialog;
if (res->LoadDialog(dlg, NULL, node->GetPropVal("name", "-1")))
{
if (pos.x != -1) dlg->Move(pos);
dlg->Show(TRUE);
if (m_Preview) m_Preview->Close(TRUE);
m_Preview = dlg;
m_Preview->SetName("preview_window");
m_Preview->SetFocus();
}
else
{
delete dlg;
wxLogError(_("Cannot preview the dialog -- XML resource corrupted."));
}
}
else if (node->GetName() == "menubar" || node->GetName() == "menu")
{
wxMenuBar *mbar;
if (node->GetName() == "menubar")
mbar = res->LoadMenuBar(node->GetPropVal("name", "-1"));
else
{
mbar = new wxMenuBar;
wxMenu *m = res->LoadMenu(node->GetPropVal("name", "-1"));
if (m != NULL) mbar->Append(m, node->GetPropVal("name", "-1"));
else { delete mbar; mbar = NULL; }
}
if (mbar == NULL)
wxLogError(_("Cannot preview the menu -- XML resource corrupted."));
else
{
wxFrame *frame = new wxFrame(NULL, -1, _("Menu preview"), pos, size);
frame->SetMenuBar(mbar);
frame->CreateStatusBar();
if (m_Preview) m_Preview->Close(TRUE);
m_Preview = frame;
m_Preview->SetName("preview_window");
m_Preview->Show(TRUE);
m_Preview->SetFocus();
}
}
else if (node->GetName() == "toolbar")
{
wxFrame *frame = new wxFrame(NULL, -1, _("Menu preview"), pos, size);
frame->SetToolBar(res->LoadToolBar(frame, node->GetPropVal("name", "-1")));
frame->CreateStatusBar();
if (m_Preview) m_Preview->Close(TRUE);
m_Preview = frame;
m_Preview->SetName("preview_window");
m_Preview->Show(TRUE);
m_Preview->SetFocus();
}
delete res;
wxRemoveFile(tempfile);
}
void EditorFrame::RefreshTree() void EditorFrame::RefreshTree()
{ {
wxXmlNode *sel = m_SelectedNode; wxXmlNode *sel = m_SelectedNode;
@@ -802,7 +707,7 @@ void EditorFrame::OnToolbar(wxCommandEvent& event)
{ {
XmlTreeData* dt = (XmlTreeData*)m_TreeCtrl->GetItemData(m_TreeCtrl->GetSelection());; XmlTreeData* dt = (XmlTreeData*)m_TreeCtrl->GetItemData(m_TreeCtrl->GetSelection());;
if (dt != NULL && dt->Node != NULL) if (dt != NULL && dt->Node != NULL)
RefreshPreview(dt->Node); PreviewFrame::Get()->Preview(dt->Node);
break; break;
} }
@@ -873,7 +778,9 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
NodeHandler *hnd = FindHandler(realnode); NodeHandler *hnd = FindHandler(realnode);
wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWSYBNODE]; wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWSYBNODE];
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, name); wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
node->AddProperty(_T("class"), name);
hnd->InsertNode(realnode, node, m_SelectedNode); hnd->InsertNode(realnode, node, m_SelectedNode);
wxTreeItemId root = m_TreeCtrl->GetSelection(); wxTreeItemId root = m_TreeCtrl->GetSelection();
SelectNode(node, &root); SelectNode(node, &root);
@@ -887,7 +794,9 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
NodeHandler *hnd = FindHandler(realnode); NodeHandler *hnd = FindHandler(realnode);
wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWNODE]; wxString name = hnd->GetChildTypes()[event.GetId()-ID_NEWNODE];
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, name); wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
node->AddProperty(_T("class"), name);
hnd->InsertNode(realnode, node); hnd->InsertNode(realnode, node);
wxTreeItemId root = m_TreeCtrl->GetSelection(); wxTreeItemId root = m_TreeCtrl->GetSelection();
SelectNode(node, &root); SelectNode(node, &root);
@@ -898,15 +807,16 @@ void EditorFrame::OnNewNode(wxCommandEvent& event)
wxString name; wxString name;
switch (event.GetId()) switch (event.GetId())
{ {
case ID_NEWDIALOG : name = "dialog"; break; case ID_NEWDIALOG : name = _T("wxDialog"); break;
case ID_NEWPANEL : name = "panel"; break; case ID_NEWPANEL : name = _T("wxPanel"); break;
case ID_NEWMENU : name = "menu"; break; case ID_NEWMENU : name = _T("wxMenu"); break;
case ID_NEWMENUBAR : name = "menubar"; break; case ID_NEWMENUBAR : name = _T("wxMenuBar"); break;
case ID_NEWTOOLBAR : name = "toolbar"; break; case ID_NEWTOOLBAR : name = _T("wxToolBar"); break;
default : return; // never occurs default : return; // never occurs
} }
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, name); wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
node->AddProperty(_T("class"), name);
m_Resource->GetRoot()->AddChild(node); m_Resource->GetRoot()->AddChild(node);
NotifyChanged(CHANGED_TREE); NotifyChanged(CHANGED_TREE);
SelectNode(node); SelectNode(node);
@@ -921,11 +831,11 @@ 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 dialog")); popup->Append(ID_NEWDIALOG, _("New wxDialog"));
popup->Append(ID_NEWPANEL, _("New panel")); popup->Append(ID_NEWPANEL, _("New wxPanel"));
popup->Append(ID_NEWMENU, _("New menu")); popup->Append(ID_NEWMENU, _("New wxMenu"));
popup->Append(ID_NEWMENUBAR, _("New menubar")); popup->Append(ID_NEWMENUBAR, _("New wxMenuBar"));
popup->Append(ID_NEWTOOLBAR, _("New toolbar")); popup->Append(ID_NEWTOOLBAR, _("New wxToolBar"));
} }
else else
@@ -940,10 +850,20 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
if (!arr.IsEmpty()) if (!arr.IsEmpty())
{ {
wxMenu *news = new wxMenu; wxMenu *news = new wxMenu;
wxMenu *news2 = news;
for (size_t i = 0; i < arr.GetCount(); i++) for (size_t i = 0; i < arr.GetCount(); i++)
{ {
news->Append(i + ID_NEWNODE, arr[i]); news2->Append(i + ID_NEWNODE, arr[i]);
if (i % 16 == 15) news->Break(); #ifdef __WXGTK__ // doesn't support Break
if (i % 20 == 19)
{
wxMenu *m = new wxMenu;
news2->Append(ID_NEWNODE+arr.GetCount(), _("More..."), m);
news2 = m;
}
#else
if (i % 16 == 15) news2->Break();
#endif
} }
popup->Append(ID_NEWNODE-1, _("New child"), news); popup->Append(ID_NEWNODE-1, _("New child"), news);
} }
@@ -963,10 +883,20 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
if (!arr.IsEmpty()) if (!arr.IsEmpty())
{ {
wxMenu *news = new wxMenu; wxMenu *news = new wxMenu;
wxMenu *news2 = news;
for (size_t i = 0; i < arr.GetCount(); i++) for (size_t i = 0; i < arr.GetCount(); i++)
{ {
news->Append(i + ID_NEWSYBNODE, arr[i]); news2->Append(i + ID_NEWSYBNODE, arr[i]);
if (i % 16 == 15) news->Break(); #ifdef __WXGTK__ // doesn't support Break
if (i % 20 == 19)
{
wxMenu *m = new wxMenu;
news2->Append(ID_NEWSYBNODE+arr.GetCount(), _("More..."), m);
news2 = m;
}
#else
if (i % 16 == 15) news2->Break();
#endif
} }
popup->Append(ID_NEWSYBNODE-1, _("New sybling"), news); popup->Append(ID_NEWSYBNODE-1, _("New sybling"), news);
} }
@@ -974,10 +904,10 @@ void EditorFrame::OnRightClickTree(wxPoint pos)
popup->AppendSeparator(); popup->AppendSeparator();
popup->Append(ID_CUT, "Cut"); popup->Append(ID_CUT, _("Cut"));
popup->Append(ID_COPY, "Copy"); popup->Append(ID_COPY, _("Copy"));
popup->Append(ID_PASTE_SYBLING, "Paste as sybling"); popup->Append(ID_PASTE_SYBLING, _("Paste as sybling"));
popup->Append(ID_PASTE_CHILD, "Paste as child"); popup->Append(ID_PASTE_CHILD, _("Paste as child"));
popup->AppendSeparator(); popup->AppendSeparator();
popup->Append(ID_DELETE_NODE, _("Delete")); popup->Append(ID_DELETE_NODE, _("Delete"));
popup->Enable(ID_PASTE_SYBLING, m_Clipboard != NULL); popup->Enable(ID_PASTE_SYBLING, m_Clipboard != NULL);

View File

@@ -58,9 +58,9 @@ class EditorFrame : public wxFrame
void LoadFile(const wxString& filename); void LoadFile(const wxString& filename);
void NewFile(); void NewFile();
void SaveFile(const wxString& filename); void SaveFile(const wxString& filename);
wxString GetFileName() { return m_FileName; }
void RefreshTree(); void RefreshTree();
void RefreshPreview(wxXmlNode *node);
void RefreshProps(wxXmlNode *node); void RefreshProps(wxXmlNode *node);
void RefreshPropsEdit(); void RefreshPropsEdit();
bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL); bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL);
@@ -96,7 +96,6 @@ class EditorFrame : public wxFrame
wxString m_FileName; wxString m_FileName;
wxXmlDocument *m_Resource; wxXmlDocument *m_Resource;
wxWindow *m_Preview;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
void OnTreeSel(wxTreeEvent& event); void OnTreeSel(wxTreeEvent& event);

View File

@@ -149,6 +149,11 @@ NodeHandler *NodeHandler::CreateFromFile(const wxString& filename, EditorFrame *
ni->Type = HANDLER_NONE; ni->Type = HANDLER_NONE;
ni->Icon = 0; ni->Icon = 0;
ni->Read(filename); ni->Read(filename);
// maybe we already parsed it?
for (size_t i = 0; i < s_AllNodes->GetCount(); i++)
if ((*s_AllNodes)[i].Node == ni->Node) return NULL;
s_AllNodes->Add(*ni); // add a copy s_AllNodes->Add(*ni); // add a copy
if (ni->Type == HANDLER_NONE || ni->Node.IsEmpty() || ni->Abstract) if (ni->Type == HANDLER_NONE || ni->Node.IsEmpty() || ni->Abstract)
@@ -226,7 +231,7 @@ NodeHandler::~NodeHandler()
bool NodeHandler::CanHandle(wxXmlNode *node) bool NodeHandler::CanHandle(wxXmlNode *node)
{ {
return (m_NodeInfo->Node == node->GetName()); return (m_NodeInfo->Node == XmlGetClass(node));
} }
@@ -248,11 +253,11 @@ wxTreeItemId NodeHandler::CreateTreeNode(wxTreeCtrl *treectrl,
wxString NodeHandler::GetTreeString(wxXmlNode *node) wxString NodeHandler::GetTreeString(wxXmlNode *node)
{ {
wxString xmlid = node->GetPropVal("name", ""); wxString xmlid = node->GetPropVal(_T("name"), wxEmptyString);
if (xmlid.IsEmpty()) if (xmlid.IsEmpty())
return node->GetName(); return XmlGetClass(node);
else else
return (node->GetName() + " '" + xmlid + "'"); return XmlGetClass(node) + _T(" '") + xmlid + _T("'");
} }
@@ -325,13 +330,12 @@ wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl,
{ {
wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node); wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node);
wxXmlNode *n = XmlFindNode(node, "children"); wxXmlNode *n = XmlFindNode(node, "object");
if (n) n = n->GetChildren();
while (n) while (n)
{ {
if (n->GetType() == wxXML_ELEMENT_NODE) if (n->GetType() == wxXML_ELEMENT_NODE &&
n->GetName() == _T("object"))
EditorFrame::Get()->CreateTreeNode(treectrl, root, n); EditorFrame::Get()->CreateTreeNode(treectrl, root, n);
n = n->GetNext(); n = n->GetNext();
} }
@@ -343,16 +347,10 @@ wxTreeItemId NodeHandlerPanel::CreateTreeNode(wxTreeCtrl *treectrl,
void NodeHandlerPanel::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) void NodeHandlerPanel::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
{ {
wxXmlNode *cnd = XmlFindNode(parent, "children");
if (cnd == NULL)
{
cnd = new wxXmlNode(wxXML_ELEMENT_NODE, "children");
parent->AddChild(cnd);
}
if (insert_before) if (insert_before)
cnd->InsertChild(node, insert_before); parent->InsertChild(node, insert_before);
else else
cnd->AddChild(node); parent->AddChild(node);
EditorFrame::Get()->NotifyChanged(CHANGED_TREE); EditorFrame::Get()->NotifyChanged(CHANGED_TREE);
} }
@@ -361,32 +359,24 @@ void NodeHandlerPanel::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode
void NodeHandlerSizer::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) void NodeHandlerSizer::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
{ {
wxXmlNode *cnd = XmlFindNode(parent, "children"); if (XmlGetClass(node) == _T("spacer") || XmlGetClass(node) == _T("sizeritem"))
if (cnd == NULL)
{
cnd = new wxXmlNode(wxXML_ELEMENT_NODE, "children");
parent->AddChild(cnd);
}
if (node->GetName() == "spacer" || node->GetName() == "sizeritem")
{ {
if (insert_before) if (insert_before)
cnd->InsertChild(node, insert_before); parent->InsertChild(node, insert_before);
else else
cnd->AddChild(node); parent->AddChild(node);
} }
else else
{ {
wxXmlNode *itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, "sizeritem"); wxXmlNode *itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
wxXmlNode *winnode = new wxXmlNode(wxXML_ELEMENT_NODE, "window"); itemnode->AddProperty(_T("class"), _T("sizeritem"));
itemnode->AddChild(winnode); itemnode->AddChild(node);
winnode->AddChild(node);
if (insert_before) if (insert_before)
cnd->InsertChild(itemnode, insert_before); parent->InsertChild(itemnode, insert_before);
else else
cnd->AddChild(itemnode); parent->AddChild(itemnode);
} }
EditorFrame::Get()->NotifyChanged(CHANGED_TREE); EditorFrame::Get()->NotifyChanged(CHANGED_TREE);
} }
@@ -398,7 +388,7 @@ int NodeHandlerSizer::GetTreeIcon(wxXmlNode *node)
int orig = NodeHandler::GetTreeIcon(node); int orig = NodeHandler::GetTreeIcon(node);
if (orig == 0) if (orig == 0)
{ {
if (XmlReadValue(node, "orient") == "wxVERTICAL") return 2; if (XmlReadValue(node, _T("orient")) == _T("wxVERTICAL")) return 2;
else return 3; else return 3;
} }
else return orig; else return orig;
@@ -450,17 +440,7 @@ int NodeHandlerSizerItem::GetTreeIcon(wxXmlNode *node)
wxXmlNode *NodeHandlerSizerItem::GetRealNode(wxXmlNode *node) wxXmlNode *NodeHandlerSizerItem::GetRealNode(wxXmlNode *node)
{ {
wxXmlNode *n = XmlFindNode(node, "window"); return XmlFindNode(node, _T("object"));
if (n) n = n->GetChildren();
while (n)
{
if (n->GetType() == wxXML_ELEMENT_NODE)
return n;
n = n->GetNext();
}
return NULL;
} }
@@ -469,31 +449,23 @@ wxXmlNode *NodeHandlerSizerItem::GetRealNode(wxXmlNode *node)
void NodeHandlerNotebook::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before) void NodeHandlerNotebook::InsertNode(wxXmlNode *parent, wxXmlNode *node, wxXmlNode *insert_before)
{ {
wxXmlNode *cnd = XmlFindNode(parent, "children");
if (cnd == NULL)
{
cnd = new wxXmlNode(wxXML_ELEMENT_NODE, "children");
parent->AddChild(cnd);
}
{ {
wxXmlNode *itemnode; wxXmlNode *itemnode;
if (node->GetName() == "notebookpage") if (XmlGetClass(node) == _T("notebookpage"))
itemnode = node; itemnode = node;
else else
{ {
itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, "notebookpage"); itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
wxXmlNode *winnode = new wxXmlNode(wxXML_ELEMENT_NODE, "window"); itemnode->AddProperty(_T("class"), _T("notebookpage"));
itemnode->AddChild(winnode); itemnode->AddChild(node);
winnode->AddChild(node);
} }
if (insert_before) if (insert_before)
cnd->InsertChild(itemnode, insert_before); parent->InsertChild(itemnode, insert_before);
else else
cnd->AddChild(itemnode); parent->AddChild(itemnode);
} }
EditorFrame::Get()->NotifyChanged(CHANGED_TREE); EditorFrame::Get()->NotifyChanged(CHANGED_TREE);
} }

View File

@@ -0,0 +1,195 @@
/////////////////////////////////////////////////////////////////////////////
// Author: Vaclav Slavik
// Created: 2000/05/05
// RCS-ID: $Id$
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "preview.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/wx.h"
#include "wx/xml/xml.h"
#include "wx/xml/xmlres.h"
#include "wx/config.h"
#include "wx/log.h"
#include "wx/splitter.h"
#include "preview.h"
#include "xmlhelpr.h"
#include "editor.h"
#include "wx/xml/xh_menu.h"
class MyMenubarHandler : public wxMenuBarXmlHandler
{
public:
MyMenubarHandler(wxMenuBar *mbar) : m_MenuBar(mbar) {}
wxObject *DoCreateResource()
{
//wxMenuBar *menubar = new wxMenuBar(GetStyle());
CreateChildren(m_MenuBar);
return m_MenuBar;
}
private:
wxMenuBar *m_MenuBar;
};
PreviewFrame* PreviewFrame::ms_Instance = NULL;
PreviewFrame *PreviewFrame::Get()
{
if (ms_Instance == NULL)
{
(void)new PreviewFrame;
ms_Instance->Show(TRUE);
}
return ms_Instance;
}
PreviewFrame::PreviewFrame()
: wxFrame(NULL, -1, _("Preview"))
{
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_TmpFile = wxGetTempFileName(_T("wxrcedit"));
m_RC->Load(m_TmpFile);
wxConfigBase *cfg = wxConfigBase::Get();
SetSize(wxRect(wxPoint(cfg->Read(_T("previewframe_x"), -1), cfg->Read(_T("previewframe_y"), -1)),
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,
wxDefaultSize, wxTE_MULTILINE);
m_ScrollWin = new wxScrolledWindow(m_Splitter, -1);
m_ScrollWin->SetBackgroundColour(_T("light steel blue"));
m_Splitter->SplitHorizontally(m_ScrollWin, m_LogCtrl, cfg->Read(_T("previewframe_sash"), 300));
CreateStatusBar();
}
PreviewFrame::~PreviewFrame()
{
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::Preview(wxXmlNode *node)
{
while (node->GetParent()->GetParent() != NULL) node = node->GetParent();
{
wxXmlDocument doc;
doc.SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, _T("resource")));
doc.GetRoot()->AddChild(new wxXmlNode(*node));
if (XmlGetClass(doc.GetRoot()->GetChildren()) == _T("wxDialog"))
XmlSetClass(doc.GetRoot()->GetChildren(), _T("wxPanel"));
doc.Save(m_TmpFile, wxXML_IO_BIN);
// wxXmlResource will detect change automatically
}
//if (m_Node != node)
{
SetToolBar(NULL);
for (int i = (int)(GetMenuBar()->GetMenuCount())-1; i >= 0; i--)
delete GetMenuBar()->Remove(i);
m_ScrollWin->DestroyChildren();
}
m_Node = node;
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"))
PreviewToolbar();
else if (XmlGetClass(node) == _T("wxPanel") || XmlGetClass(node) == _T("wxDialog"))
PreviewPanel();
wxSetWorkingDirectory(oldcwd);
wxLog::SetActiveTarget(oldlog);
}
void PreviewFrame::PreviewMenu()
{
wxMenuBar *mbar;
if (XmlGetClass(m_Node) == _T("wxMenuBar"))
mbar = m_RC->LoadMenuBar(m_Node->GetPropVal(_T("name"), _T("-1")));
else
{
wxMenu *m = m_RC->LoadMenu(m_Node->GetPropVal(_T("name"), _T("-1")));
if (m != NULL) GetMenuBar()->Append(m, _("(menu)"));
}
if (mbar == NULL)
wxLogError(_("Cannot preview the menu -- XML resource corrupted."));
}
void PreviewFrame::PreviewToolbar()
{
SetToolBar(m_RC->LoadToolBar(this, m_Node->GetPropVal(_T("name"), _T("-1"))));
}
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
{
m_ScrollWin->SetScrollbars(1, 1, panel->GetSize().x, panel->GetSize().y,
0, 0, TRUE);
}
}

View File

@@ -0,0 +1,55 @@
/////////////////////////////////////////////////////////////////////////////
// Purpose: XML resources editor
// Author: Vaclav Slavik
// Created: 2000/05/05
// RCS-ID: $Id$
// Copyright: (c) 2000 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma interface "preview.h"
#endif
#ifndef _PREVIEW_H_
#define _PREVIEW_H_
class WXDLLEXPORT wxXmlNode;
class WXDLLEXPORT wxScrolledWindow;
class WXDLLEXPORT wxTextCtrl;
class WXDLLEXPORT wxSplitterWindow;
class WXDLLEXPORT wxXmlResource;
class WXDLLEXPORT wxXmlDocument;
#include "wx/frame.h"
class PreviewFrame : public wxFrame
{
public:
PreviewFrame();
~PreviewFrame();
void Preview(wxXmlNode *node);
static PreviewFrame *Get();
private:
void PreviewMenu();
void PreviewToolbar();
void PreviewPanel();
private:
static PreviewFrame *ms_Instance;
wxXmlNode *m_Node;
wxScrolledWindow *m_ScrollWin;
wxTextCtrl *m_LogCtrl;
wxSplitterWindow *m_Splitter;
wxXmlResource *m_RC;
wxString m_TmpFile;
};
#endif

View File

@@ -81,4 +81,20 @@ wxString XmlReadValue(wxXmlNode *parent, const wxString& name)
wxString XmlGetClass(wxXmlNode *parent)
{
return parent->GetPropVal(_T("class"), wxEmptyString);
}
void XmlSetClass(wxXmlNode *parent, const wxString& classname)
{
parent->DeleteProperty(_T("class"));
parent->AddProperty(_T("class"), classname);
}

View File

@@ -19,5 +19,7 @@
void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value); void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value);
wxString XmlReadValue(wxXmlNode *parent, const wxString& name); wxString XmlReadValue(wxXmlNode *parent, const wxString& name);
wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& name); wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& name);
wxString XmlGetClass(wxXmlNode *parent);
void XmlSetClass(wxXmlNode *parent, const wxString& classname);
#endif #endif

View File

@@ -83,7 +83,7 @@ int XmlResApp::OnRun()
{ wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" }, { wxCMD_LINE_SWITCH, "c", "cpp-code", "output C++ source rather than .rsc file" },
{ wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" }, { wxCMD_LINE_SWITCH, "u", "uncompressed", "do not compress .xml files (C++ only)" },
{ wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" }, { wxCMD_LINE_OPTION, "n", "function", "C++ function name (with -c) [InitXmlResource]" },
{ wxCMD_LINE_OPTION, "o", "output", "output file [resource.rsc/cpp]" }, { wxCMD_LINE_OPTION, "o", "output", "output file [resource.xrs/cpp]" },
{ wxCMD_LINE_OPTION, "l", "list-of-handlers", "output list of neccessary handlers to this file" }, { wxCMD_LINE_OPTION, "l", "list-of-handlers", "output list of neccessary handlers to this file" },
{ wxCMD_LINE_PARAM, NULL, NULL, "input file", { wxCMD_LINE_PARAM, NULL, NULL, "input file",
@@ -133,7 +133,7 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
flagCompress = flagCPP && !cmdline.Found("u"); flagCompress = flagCPP && !cmdline.Found("u");
if (!cmdline.Found("o", &parOutput)) if (!cmdline.Found("o", &parOutput))
parOutput = flagCPP ? "resource.cpp" : "resource.rsc"; parOutput = flagCPP ? "resource.cpp" : "resource.xrs";
parOutputPath = wxPathOnly(parOutput); parOutputPath = wxPathOnly(parOutput);
if (!parOutputPath) parOutputPath = "."; if (!parOutputPath) parOutputPath = ".";
@@ -189,8 +189,8 @@ wxArrayString XmlResApp::PrepareTempFiles()
FindFilesInXML(doc.GetRoot(), flist, path); FindFilesInXML(doc.GetRoot(), flist, path);
doc.Save(parOutputPath + "/" + name + ".xmb", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN); doc.Save(parOutputPath + "/" + name + ".xrc", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN);
flist.Add(name + ".xmb"); flist.Add(name + ".xrc");
} }
return flist; return flist;
@@ -285,38 +285,32 @@ static wxString FileToCppArray(wxString filename, int num)
wxString snum; wxString snum;
wxFFile file(filename, "rb"); wxFFile file(filename, "rb");
size_t lng = file.Length(); size_t lng = file.Length();
int linelng;
snum.Printf("%i", num); snum.Printf("%i", num);
output.Printf("static size_t xml_res_size_" + snum + " = %i;\n", lng); output.Printf("static size_t xml_res_size_" + snum + " = %i;\n", lng);
output += "static unsigned char xml_res_file_" + snum + "[] = \"\\\n"; output += "static unsigned char xml_res_file_" + snum + "[] = {\n";
// we cannot use string literals because MSVC is dumb wannabe compiler
// with arbitrary limitation to 2048 strings :(
unsigned char *buffer = new unsigned char[lng]; unsigned char *buffer = new unsigned char[lng];
file.Read(buffer, lng); file.Read(buffer, lng);
for (size_t i = 0, linelng = 0; i < lng; i++) for (size_t i = 0, linelng = 0; i < lng; i++)
{ {
if (linelng > 70) tmp.Printf("%i", buffer[i]);
if (i != 0) output << ',';
if (linelng > 70)
{ {
linelng = 0; linelng = 0;
output += "\\\n"; output << "\n";
}
if (buffer[i] < 32 || buffer[i] == '"' || buffer[i] == '\\')
{
tmp.Printf("\\%03o", buffer[i]);
output += tmp;
linelng += 4;
}
else
{
output << (wxChar)buffer[i];
linelng++;
} }
output << tmp;
linelng += tmp.Length()+1;
} }
delete[] buffer; delete[] buffer;
output += "\"\n;\n\n"; output += "};\n\n";
return output; return output;
} }
@@ -378,7 +372,7 @@ void " + parFuncname + "()\n\
wxString name, ext, path; wxString name, ext, path;
wxSplitPath(parFiles[i], &path, &name, &ext); wxSplitPath(parFiles[i], &path, &name, &ext);
file.Write(" wxTheXmlResource->Load(\"memory:xml_resource/" + file.Write(" wxTheXmlResource->Load(\"memory:xml_resource/" +
name + ".xmb" + "\");\n"); name + ".xrc" + "\");\n");
} }
file.Write("\n}\n"); file.Write("\n}\n");