mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-25 00:43:39 +08:00
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:
@@ -30,6 +30,8 @@ class WXDLLEXPORT wxSizerXmlHandler : public wxXmlResourceHandler
|
||||
private:
|
||||
bool m_IsInside;
|
||||
wxSizer *m_ParentSizer;
|
||||
|
||||
bool IsSizerNode(wxXmlNode *node);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ class WXDLLEXPORT wxXmlResource : public wxObject
|
||||
void UpdateResources();
|
||||
|
||||
// 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:
|
||||
wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL);
|
||||
@@ -212,11 +212,17 @@ class WXDLLEXPORT wxXmlResourceHandler : public wxObject
|
||||
|
||||
// Variables (filled by CreateResource)
|
||||
wxXmlNode *m_Node;
|
||||
wxString m_Class;
|
||||
wxObject *m_Parent, *m_Instance;
|
||||
wxWindow *m_ParentAsWindow, *m_InstanceAsWindow;
|
||||
|
||||
// --- 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
|
||||
// (the problem is, <tag>content<tag> is represented as
|
||||
// wxXML_ENTITY_NODE name="tag", content=""
|
||||
@@ -278,9 +284,8 @@ class WXDLLEXPORT wxXmlResourceHandler : public wxObject
|
||||
// Sets common window options:
|
||||
void SetupWindow(wxWindow *wnd);
|
||||
|
||||
void CreateChildren(wxObject *parent, bool only_this_handler = FALSE,
|
||||
wxXmlNode *children_node = NULL /*stands for
|
||||
GetParamNode("children")*/);
|
||||
void CreateChildren(wxObject *parent, bool this_hnd_only = FALSE);
|
||||
void CreateChildrenPrivately(wxObject *parent, wxXmlNode *rootnode = NULL);
|
||||
wxObject *CreateResFromNode(wxXmlNode *node, wxObject *parent, wxObject *instance = NULL)
|
||||
{ return m_Resource->CreateResFromNode(node, parent, instance); }
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ wxObject *wxBitmapXmlHandler::DoCreateResource()
|
||||
|
||||
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)
|
||||
{
|
||||
return node->GetName() == _T("icon");
|
||||
return IsOfClass(node, _T("wxIcon"));
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ wxObject *wxBitmapButtonXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("bitmapbutton");
|
||||
return IsOfClass(node, _T("wxBitmapButton"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ wxObject *wxButtonXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxButtonXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("button");
|
||||
return IsOfClass(node, _T("wxButton"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ wxObject *wxCalendarCtrlXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxCalendarCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("calendarctrl");
|
||||
return IsOfClass(node, _T("wxCalendarCtrl"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ wxObject *wxCheckBoxXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("checkbox");
|
||||
return IsOfClass(node, _T("wxCheckBox"));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,12 +31,11 @@ wxCheckListXmlHandler::wxCheckListXmlHandler()
|
||||
|
||||
wxObject *wxCheckListXmlHandler::DoCreateResource()
|
||||
{
|
||||
if( m_Node->GetName() == _T("checklist"))
|
||||
if (m_Class == _T("wxCheckList"))
|
||||
{
|
||||
// need to build the list of strings from children
|
||||
m_InsideBox = TRUE;
|
||||
CreateChildren( NULL, TRUE /* only this handler */,
|
||||
GetParamNode(_T("content")));
|
||||
CreateChildrenPrivately(NULL, GetParamNode(_T("content")));
|
||||
wxString *strings = (wxString *) NULL;
|
||||
if( strList.GetCount() > 0 )
|
||||
{
|
||||
@@ -64,7 +63,7 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
|
||||
while (n)
|
||||
{
|
||||
if (n->GetType() != wxXML_ELEMENT_NODE ||
|
||||
n->GetName() != _T("item" ))
|
||||
n->GetName() != _T("item"))
|
||||
{ n = n->GetNext(); continue; }
|
||||
|
||||
// checking boolean is a bit ugly here (see GetBool() )
|
||||
@@ -102,10 +101,9 @@ wxObject *wxCheckListXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxCheckListXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return( node->GetName() == _T("checklist") ||
|
||||
( m_InsideBox &&
|
||||
node->GetName() == _T("item" ))
|
||||
);
|
||||
return (IsOfClass(node, _T("wxCheckList")) ||
|
||||
(m_InsideBox && node->GetName() == _T("item"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,15 +31,14 @@ wxChoiceXmlHandler::wxChoiceXmlHandler()
|
||||
|
||||
wxObject *wxChoiceXmlHandler::DoCreateResource()
|
||||
{
|
||||
if( m_Node->GetName() == _T("choice"))
|
||||
if( m_Class == _T("wxChoice"))
|
||||
{
|
||||
// find the selection
|
||||
long selection = GetLong( _T("selection"), -1 );
|
||||
|
||||
// need to build the list of strings from children
|
||||
m_InsideBox = TRUE;
|
||||
CreateChildren( NULL, TRUE /* only this handler */,
|
||||
GetParamNode(_T("content")));
|
||||
CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
|
||||
wxString *strings = (wxString *) NULL;
|
||||
if( strList.GetCount() > 0 )
|
||||
{
|
||||
@@ -88,10 +87,9 @@ wxObject *wxChoiceXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxChoiceXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return( node->GetName() == _T("choice") ||
|
||||
( m_InsideBox &&
|
||||
node->GetName() == _T("item" ))
|
||||
);
|
||||
return (IsOfClass(node, _T("wxChoice")) ||
|
||||
(m_InsideBox && node->GetName() == _T("item"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,15 +36,14 @@ wxComboBoxXmlHandler::wxComboBoxXmlHandler()
|
||||
|
||||
wxObject *wxComboBoxXmlHandler::DoCreateResource()
|
||||
{
|
||||
if( m_Node->GetName() == _T("combobox"))
|
||||
if( m_Class == _T("wxComboBox"))
|
||||
{
|
||||
// find the selection
|
||||
long selection = GetLong( _T("selection"), -1 );
|
||||
|
||||
// need to build the list of strings from children
|
||||
m_InsideBox = TRUE;
|
||||
CreateChildren( NULL, TRUE /* only this handler */,
|
||||
GetParamNode(_T("content")));
|
||||
CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
|
||||
wxString *strings = (wxString *) NULL;
|
||||
if( strList.GetCount() > 0 )
|
||||
{
|
||||
@@ -94,10 +93,9 @@ wxObject *wxComboBoxXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxComboBoxXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return( node->GetName() == _T("combobox") ||
|
||||
( m_InsideBox &&
|
||||
node->GetName() == _T("item" ))
|
||||
);
|
||||
return (IsOfClass(node, _T("wxComboBox")) ||
|
||||
(m_InsideBox && node->GetName() == _T("item"))
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -74,7 +74,7 @@ wxObject *wxDialogXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxDialogXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("dialog");
|
||||
return IsOfClass(node, _T("wxDialog"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ wxObject *wxGaugeXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("gauge");
|
||||
return IsOfClass(node, _T("wxGauge"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ wxObject *wxHtmlWindowXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("htmlwindow");
|
||||
return IsOfClass(node, _T("wxHtmlWindow"));
|
||||
}
|
||||
|
||||
#endif // wxUSE_HTML
|
||||
|
||||
@@ -37,15 +37,14 @@ wxListBoxXmlHandler::wxListBoxXmlHandler()
|
||||
|
||||
wxObject *wxListBoxXmlHandler::DoCreateResource()
|
||||
{
|
||||
if( m_Node->GetName() == _T("listbox"))
|
||||
if( m_Class == _T("wxListBox"))
|
||||
{
|
||||
// find the selection
|
||||
long selection = GetLong( _T("selection"), -1 );
|
||||
|
||||
// need to build the list of strings from children
|
||||
m_InsideBox = TRUE;
|
||||
CreateChildren( NULL, TRUE /* only this handler */,
|
||||
GetParamNode(_T("content")));
|
||||
CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
|
||||
wxString *strings = (wxString *) NULL;
|
||||
if( strList.GetCount() > 0 )
|
||||
{
|
||||
@@ -94,10 +93,9 @@ wxObject *wxListBoxXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxListBoxXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return( node->GetName() == _T("listbox") ||
|
||||
( m_InsideBox &&
|
||||
node->GetName() == _T("item" ))
|
||||
);
|
||||
return (IsOfClass(node, _T("wxListBox")) ||
|
||||
(m_InsideBox && node->GetName() == _T("item"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,5 +63,5 @@ wxObject *wxListCtrlXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("listctrl");
|
||||
return IsOfClass(node, _T("wxListCtrl"));
|
||||
}
|
||||
|
||||
@@ -41,30 +41,30 @@ wxNotebookXmlHandler::wxNotebookXmlHandler()
|
||||
|
||||
wxObject *wxNotebookXmlHandler::DoCreateResource()
|
||||
{
|
||||
if (m_Node->GetName() == _T("notebookpage"))
|
||||
if (m_Class == _T("notebookpage"))
|
||||
{
|
||||
wxXmlNode *n = GetParamNode(_T("window"))->GetChildren();
|
||||
while (n)
|
||||
wxXmlNode *n = GetParamNode(_T("object"));
|
||||
|
||||
if (n)
|
||||
{
|
||||
if (n->GetType() == wxXML_ELEMENT_NODE)
|
||||
{
|
||||
bool old_ins = m_IsInside;
|
||||
m_IsInside = FALSE;
|
||||
m_IsInside = old_ins;
|
||||
wxObject *item = CreateResFromNode(n, m_Notebook, NULL);
|
||||
wxWindow *wnd = wxDynamicCast(item, wxWindow);
|
||||
|
||||
if (wnd)
|
||||
m_Notebook->AddPage(wnd, GetText(_T("label")),
|
||||
GetBool(_T("selected"), 0));
|
||||
else
|
||||
wxLogError(_T("Error in resource."));
|
||||
return wnd;
|
||||
}
|
||||
n = n->GetNext();
|
||||
bool old_ins = m_IsInside;
|
||||
m_IsInside = FALSE;
|
||||
m_IsInside = old_ins;
|
||||
wxObject *item = CreateResFromNode(n, m_Notebook, NULL);
|
||||
wxWindow *wnd = wxDynamicCast(item, wxWindow);
|
||||
|
||||
if (wnd)
|
||||
m_Notebook->AddPage(wnd, GetText(_T("label")),
|
||||
GetBool(_T("selected"), 0));
|
||||
else
|
||||
wxLogError(_T("Error in resource."));
|
||||
return wnd;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 {
|
||||
@@ -93,8 +93,8 @@ wxObject *wxNotebookXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxNotebookXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return ((!m_IsInside && node->GetName() == _T("notebook")) ||
|
||||
(m_IsInside && node->GetName() == _T("notebookpage")));
|
||||
return ((!m_IsInside && IsOfClass(node, _T("wxNotebook"))) ||
|
||||
(m_IsInside && IsOfClass(node, _T("notebookpage"))));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,5 +59,5 @@ wxObject *wxPanelXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxPanelXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("panel");
|
||||
return IsOfClass(node, _T("wxPanel"));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ wxObject *wxRadioButtonXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxRadioButtonXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("radiobutton");
|
||||
return IsOfClass(node, _T("wxRadioButton"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
|
||||
|
||||
wxObject *wxRadioBoxXmlHandler::DoCreateResource()
|
||||
{
|
||||
if( m_Node->GetName() == _T("radiobox"))
|
||||
if( m_Class == _T("wxRadioBox"))
|
||||
{
|
||||
// find the selection
|
||||
long selection = GetLong( _T("selection"), -1 );
|
||||
|
||||
// need to build the list of strings from children
|
||||
m_InsideBox = TRUE;
|
||||
CreateChildren( NULL, TRUE /* only this handler */, GetParamNode(_T("content")));
|
||||
CreateChildrenPrivately( NULL, GetParamNode(_T("content")));
|
||||
wxString *strings = (wxString *) NULL;
|
||||
if( strList.GetCount() > 0 )
|
||||
{
|
||||
@@ -94,10 +94,9 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return( node->GetName() == _T("radiobox") ||
|
||||
( m_InsideBox &&
|
||||
node->GetName() == _T("item" ))
|
||||
);
|
||||
return (IsOfClass(node, _T("wxRadioBox")) ||
|
||||
(m_InsideBox && node->GetName() == _T("item"))
|
||||
);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -56,7 +56,7 @@ wxObject *wxScrollBarXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxScrollBarXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("scrollbar");
|
||||
return IsOfClass(node, _T("wxScrollBar"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#include "wx/statbox.h"
|
||||
#include "wx/notebook.h"
|
||||
|
||||
static bool IsSizerNode(wxXmlNode *node)
|
||||
bool wxSizerXmlHandler::IsSizerNode(wxXmlNode *node)
|
||||
{
|
||||
return (node->GetName() == _T("boxsizer")) ||
|
||||
(node->GetName() == _T("staticboxsizer")) ||
|
||||
(node->GetName() == _T("gridsizer")) ||
|
||||
(node->GetName() == _T("flexgridsizer"));
|
||||
return (IsOfClass(node, _T("wxBoxSizer"))) ||
|
||||
(IsOfClass(node, _T("wxStaticBoxSizer"))) ||
|
||||
(IsOfClass(node, _T("wxGridSizer"))) ||
|
||||
(IsOfClass(node, _T("wxFlexGridSizer")));
|
||||
}
|
||||
|
||||
|
||||
@@ -73,51 +73,50 @@ wxSizerXmlHandler::wxSizerXmlHandler()
|
||||
|
||||
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;
|
||||
m_IsInside = FALSE;
|
||||
if (!IsSizerNode(n)) m_ParentSizer = NULL;
|
||||
wxObject *item = CreateResFromNode(n, m_Parent, NULL);
|
||||
m_IsInside = old_ins;
|
||||
m_ParentSizer = old_par;
|
||||
wxSizer *sizer = wxDynamicCast(item, wxSizer);
|
||||
wxWindow *wnd = wxDynamicCast(item, wxWindow);
|
||||
wxSize minsize = GetSize(_T("minsize"));
|
||||
|
||||
if (sizer)
|
||||
{
|
||||
m_ParentSizer->Add(sizer, GetLong(_T("option")),
|
||||
GetStyle(_T("flag")), GetDimension(_T("border")));
|
||||
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;
|
||||
bool old_ins = m_IsInside;
|
||||
wxSizer *old_par = m_ParentSizer;
|
||||
m_IsInside = FALSE;
|
||||
if (!IsSizerNode(n)) m_ParentSizer = NULL;
|
||||
wxObject *item = CreateResFromNode(n, m_Parent, NULL);
|
||||
m_IsInside = old_ins;
|
||||
m_ParentSizer = old_par;
|
||||
wxSizer *sizer = wxDynamicCast(item, wxSizer);
|
||||
wxWindow *wnd = wxDynamicCast(item, wxWindow);
|
||||
wxSize minsize = GetSize(_T("minsize"));
|
||||
|
||||
if (sizer)
|
||||
{
|
||||
m_ParentSizer->Add(sizer, GetLong(_T("option")),
|
||||
GetStyle(_T("flag")), GetDimension(_T("border")));
|
||||
if (!(minsize == wxDefaultSize))
|
||||
m_ParentSizer->SetItemMinSize(sizer, minsize.x, minsize.y);
|
||||
}
|
||||
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!"));
|
||||
wxSize sz = GetSize();
|
||||
@@ -130,29 +129,29 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
|
||||
else {
|
||||
wxSizer *sizer = NULL;
|
||||
|
||||
wxXmlNode *parentNode = m_Node->GetParent()->GetParent();
|
||||
wxXmlNode *parentNode = m_Node->GetParent();
|
||||
|
||||
wxCHECK_MSG(m_ParentSizer != NULL ||
|
||||
((parentNode->GetName() == _T("panel") ||
|
||||
parentNode->GetName() == _T("dialog")) &&
|
||||
((IsOfClass(parentNode, _T("wxPanel")) ||
|
||||
IsOfClass(parentNode, _T("wxDialog"))) &&
|
||||
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));
|
||||
|
||||
else if (m_Node->GetName() == _T("staticboxsizer"))
|
||||
else if (m_Class == _T("wxStaticBoxSizer"))
|
||||
{
|
||||
sizer = new wxStaticBoxSizer(
|
||||
new wxStaticBox(m_ParentAsWindow, -1, GetText(_T("label"))),
|
||||
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")),
|
||||
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")),
|
||||
GetDimension(_T("vgap")), GetDimension(_T("hgap")));
|
||||
|
||||
@@ -193,6 +192,6 @@ wxObject *wxSizerXmlHandler::DoCreateResource()
|
||||
bool wxSizerXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return ((!m_IsInside && IsSizerNode(node)) ||
|
||||
(m_IsInside && node->GetName() == _T("sizeritem")) ||
|
||||
(m_IsInside && node->GetName() == _T("spacer")));
|
||||
(m_IsInside && IsOfClass(node, _T("sizeritem"))) ||
|
||||
(m_IsInside && IsOfClass(node, _T("spacer"))));
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ wxObject *wxSliderXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxSliderXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("slider");
|
||||
return IsOfClass(node, _T("wxSlider"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ wxObject *wxSpinCtrlXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("spinctrl");
|
||||
return IsOfClass(node, _T("wxSpinCtrl"));
|
||||
}
|
||||
|
||||
#endif // wxUSE_SPINCTRL
|
||||
|
||||
@@ -46,7 +46,7 @@ wxObject *wxStaticBitmapXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxStaticBitmapXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("staticbitmap");
|
||||
return IsOfClass(node, _T("wxStaticBitmap"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ wxObject *wxStaticBoxXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxStaticBoxXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("staticbox");
|
||||
return IsOfClass(node, _T("wxStaticBox"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ wxObject *wxStaticLineXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxStaticLineXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("staticline");
|
||||
return IsOfClass(node, _T("wxStaticLine"));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,7 @@ wxObject *wxStaticTextXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxStaticTextXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("statictext");
|
||||
return IsOfClass(node, _T("wxStaticText"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ wxObject *wxTextCtrlXmlHandler::DoCreateResource()
|
||||
GetText(_T("value")),
|
||||
GetPosition(), GetSize(),
|
||||
GetStyle(),
|
||||
wxDefaultValidator,
|
||||
GetText(_T("name"))
|
||||
wxDefaultValidator,
|
||||
GetName()
|
||||
);
|
||||
SetupWindow(text);
|
||||
|
||||
@@ -52,7 +52,7 @@ wxObject *wxTextCtrlXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxTextCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("textctrl");
|
||||
return IsOfClass(node, _T("wxTextCtrl"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ wxToolBarXmlHandler::wxToolBarXmlHandler()
|
||||
|
||||
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!"));
|
||||
m_Toolbar->AddTool(GetID(),
|
||||
@@ -53,14 +53,14 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
|
||||
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!"));
|
||||
m_Toolbar->AddSeparator();
|
||||
return m_Toolbar; // must return non-NULL
|
||||
}
|
||||
|
||||
else /*<toolbar>*/
|
||||
else /*<object class="wxToolBar">*/
|
||||
{
|
||||
int style = GetStyle(_T("style"), wxNO_BORDER | wxTB_HORIZONTAL);
|
||||
#ifdef __WXMSW__
|
||||
@@ -86,22 +86,23 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
|
||||
if (separation != -1)
|
||||
toolbar->SetToolSeparation(separation);
|
||||
|
||||
wxXmlNode *children_node = GetParamNode(_T("children"));
|
||||
wxXmlNode *children_node = GetParamNode(_T("object"));
|
||||
if (children_node == NULL) return toolbar;
|
||||
|
||||
m_IsInside = TRUE;
|
||||
m_Toolbar = toolbar;
|
||||
|
||||
wxXmlNode *n = children_node->GetChildren();
|
||||
wxXmlNode *n = children_node;
|
||||
|
||||
while (n)
|
||||
{
|
||||
if (n->GetType() == wxXML_ELEMENT_NODE)
|
||||
if (n->GetType() == wxXML_ELEMENT_NODE &&
|
||||
n->GetName() == _T("object"))
|
||||
{
|
||||
wxObject *created = CreateResFromNode(n, toolbar, NULL);
|
||||
wxControl *control = wxDynamicCast(created, wxControl);
|
||||
if (n->GetName() != _T("tool") &&
|
||||
n->GetName() != _T("separator") &&
|
||||
if (IsOfClass(n, _T("tool")) &&
|
||||
IsOfClass(n, _T("separator")) &&
|
||||
control != NULL)
|
||||
toolbar->AddControl(control);
|
||||
}
|
||||
@@ -120,9 +121,9 @@ wxObject *wxToolBarXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxToolBarXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return ((!m_IsInside && node->GetName() == _T("toolbar")) ||
|
||||
(m_IsInside && node->GetName() == _T("tool")) ||
|
||||
(m_IsInside && node->GetName() == _T("separator")));
|
||||
return ((!m_IsInside && IsOfClass(node, _T("wxToolBar"))) ||
|
||||
(m_IsInside && IsOfClass(node, _T("tool"))) ||
|
||||
(m_IsInside && IsOfClass(node, _T("separator"))));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -51,7 +51,7 @@ wxObject *wxTreeCtrlXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxTreeCtrlXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("treectrl");
|
||||
return IsOfClass(node, _T("wxTreeCtrl"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
|
||||
wnd = m_ParentAsWindow->FindWindow(name);
|
||||
|
||||
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
|
||||
{
|
||||
if (wnd->GetParent() != m_ParentAsWindow)
|
||||
@@ -56,6 +56,6 @@ wxObject *wxUnknownWidgetXmlHandler::DoCreateResource()
|
||||
|
||||
bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
|
||||
{
|
||||
return node->GetName() == _T("unknown");
|
||||
return IsOfClass(node, _T("unknown"));
|
||||
}
|
||||
|
||||
|
||||
+47
-29
@@ -131,21 +131,21 @@ void wxXmlResource::ClearHandlers()
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 *bmp = (wxBitmap*)CreateResFromNode(
|
||||
FindResource(name, wxT("bitmap")), NULL, NULL);
|
||||
FindResource(name, wxT("wxBitmap")), NULL, NULL);
|
||||
wxBitmap rt;
|
||||
|
||||
if (bmp) { rt = *bmp; delete bmp; }
|
||||
@@ -190,7 +190,7 @@ wxBitmap wxXmlResource::LoadBitmap(const wxString& name)
|
||||
wxIcon wxXmlResource::LoadIcon(const wxString& name)
|
||||
{
|
||||
wxIcon *icon = (wxIcon*)CreateResFromNode(
|
||||
FindResource(name, wxT("icon")), NULL, NULL);
|
||||
FindResource(name, wxT("wxIcon")), NULL, NULL);
|
||||
wxIcon rt;
|
||||
|
||||
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
|
||||
|
||||
@@ -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;
|
||||
for (wxXmlNode *node = m_Data[f].Doc->GetRoot()->GetChildren();
|
||||
node; node = node->GetNext())
|
||||
if ( node->GetType() == wxXML_ELEMENT_NODE &&
|
||||
(!type || node->GetName() == type) &&
|
||||
node->GetPropVal(wxT("name"), &dummy) &&
|
||||
dummy == name)
|
||||
if (node->GetType() == wxXML_ELEMENT_NODE &&
|
||||
(!classname ||
|
||||
node->GetPropVal(wxT("class"), wxEmptyString) == classname) &&
|
||||
node->GetName() == wxT("object") &&
|
||||
node->GetPropVal(wxT("name"), &dummy) &&
|
||||
dummy == name)
|
||||
{
|
||||
#if wxUSE_FILESYSTEM
|
||||
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!"),
|
||||
name.c_str(), type.c_str());
|
||||
wxLogError(_("XML resource '%s' (class '%s') not found!"),
|
||||
name.c_str(), classname.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -353,7 +355,7 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wx
|
||||
while (ND)
|
||||
{
|
||||
handler = (wxXmlResourceHandler*)ND->GetData();
|
||||
if (handler->CanHandle(node))
|
||||
if (node->GetName() == _T("object") && handler->CanHandle(node))
|
||||
{
|
||||
ret = handler->CreateResource(node, parent, instance);
|
||||
if (ret) return ret;
|
||||
@@ -361,7 +363,9 @@ wxObject *wxXmlResource::CreateResFromNode(wxXmlNode *node, wxObject *parent, wx
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -383,10 +387,12 @@ wxXmlResourceHandler::wxXmlResourceHandler()
|
||||
wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent, wxObject *instance)
|
||||
{
|
||||
wxXmlNode *myNode = m_Node;
|
||||
wxString myClass = m_Class;
|
||||
wxObject *myParent = m_Parent, *myInstance = m_Instance;
|
||||
wxWindow *myParentAW = m_ParentAsWindow, *myInstanceAW = m_InstanceAsWindow;
|
||||
|
||||
m_Node = node;
|
||||
m_Class = node->GetPropVal(_T("class"), wxEmptyString);
|
||||
m_Parent = parent;
|
||||
m_Instance = instance;
|
||||
m_ParentAsWindow = wxDynamicCast(m_Parent, wxWindow);
|
||||
@@ -395,6 +401,7 @@ wxObject *wxXmlResourceHandler::CreateResource(wxXmlNode *node, wxObject *parent
|
||||
wxObject *returned = DoCreateResource();
|
||||
|
||||
m_Node = myNode;
|
||||
m_Class = myClass;
|
||||
m_Parent = myParent; m_ParentAsWindow = myParentAW;
|
||||
m_Instance = myInstance; m_InstanceAsWindow = myInstanceAW;
|
||||
|
||||
@@ -810,23 +817,17 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd)
|
||||
}
|
||||
|
||||
|
||||
void wxXmlResourceHandler::CreateChildren(wxObject *parent,
|
||||
bool only_this_handler, wxXmlNode *children_node)
|
||||
void wxXmlResourceHandler::CreateChildren(wxObject *parent, bool this_hnd_only)
|
||||
{
|
||||
if (children_node == NULL) children_node = GetParamNode(_T("children"));
|
||||
if (children_node == NULL) return;
|
||||
|
||||
wxXmlNode *n = children_node->GetChildren();
|
||||
wxXmlNode *n = m_Node->GetChildren();
|
||||
|
||||
while (n)
|
||||
{
|
||||
if (n->GetType() == wxXML_ELEMENT_NODE)
|
||||
if (n->GetType() == wxXML_ELEMENT_NODE &&
|
||||
n->GetName() == _T("object"))
|
||||
{
|
||||
if (only_this_handler)
|
||||
{
|
||||
if (CanHandle(n))
|
||||
CreateResource(n, parent, NULL);
|
||||
}
|
||||
if (this_hnd_only && CanHandle(n))
|
||||
CreateResource(n, parent, NULL);
|
||||
else
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ microsoft reuses the keyword DIALOG for other things
|
||||
wxString title;
|
||||
wxString ptsize,face;
|
||||
|
||||
m_xmlfile.Write("\t<dialog");
|
||||
m_xmlfile.Write("\t<object class=\"wxDialog\"");
|
||||
//Avoid duplicate names this way
|
||||
dlgname.Replace("IDD_","DLG_");
|
||||
WriteBasicInfo(x,y,width,height,dlgname);
|
||||
@@ -152,10 +152,8 @@ microsoft reuses the keyword DIALOG for other things
|
||||
token=GetToken();
|
||||
}
|
||||
|
||||
m_xmlfile.Write("\t<children>\n");
|
||||
ParseControls();
|
||||
m_xmlfile.Write("\t</children>\n");
|
||||
m_xmlfile.Write("\t</dialog>\n");
|
||||
m_xmlfile.Write("\t</object>\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -207,9 +205,9 @@ void rc2xml::ParseStaticText()
|
||||
int 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);
|
||||
m_xmlfile.Write("\t\t</statictext>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
|
||||
}
|
||||
//EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
|
||||
@@ -222,9 +220,9 @@ void rc2xml::ParseTextCtrl()
|
||||
ReadRect(x,y,width,height);
|
||||
//TODO
|
||||
//style=GetToken();
|
||||
m_xmlfile.Write("\t\t<textctrl");
|
||||
m_xmlfile.Write("\t\t<object class\"wxTextCtrl\"");
|
||||
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
|
||||
@@ -238,10 +236,10 @@ void rc2xml::ParsePushButton()
|
||||
int 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);
|
||||
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;
|
||||
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);
|
||||
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)
|
||||
@@ -375,9 +373,9 @@ void rc2xml::ParseComboBox()
|
||||
int 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);
|
||||
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="";
|
||||
|
||||
//Write menubar to xml file
|
||||
m_xmlfile.Write("\t<menubar");
|
||||
m_xmlfile.Write("\t<object class=\"wxMenuBar\"");
|
||||
//Avoid duplicate names this way
|
||||
varname.Replace("IDR_","MB_");
|
||||
WriteName(varname);
|
||||
m_xmlfile.Write(">\n");
|
||||
m_xmlfile.Write("\t\t<children>\n");
|
||||
|
||||
while ((token!="BEGIN")&(token!="{"))
|
||||
token=GetToken();
|
||||
@@ -404,8 +401,7 @@ void rc2xml::ParseMenu(wxString varname)
|
||||
ParsePopupMenu();
|
||||
}
|
||||
}
|
||||
m_xmlfile.Write("\t\t</children>\n");
|
||||
m_xmlfile.Write("\t</menubar>\n");
|
||||
m_xmlfile.Write("\t</object>\n");
|
||||
}
|
||||
|
||||
void rc2xml::ParsePopupMenu()
|
||||
@@ -423,11 +419,10 @@ void rc2xml::ParsePopupMenu()
|
||||
//Write Menu item
|
||||
//Generate a fake name since RC menus don't have one
|
||||
name<<"Menu_"<<menucount;
|
||||
m_xmlfile.Write("\t\t<menu");
|
||||
m_xmlfile.Write("\t\t<object class=\"wxMenu\"");
|
||||
WriteName(name);
|
||||
m_xmlfile.Write(">\n");
|
||||
WriteLabel(token);
|
||||
m_xmlfile.Write("\t\t\t<children>\n");
|
||||
|
||||
while ((token!="BEGIN")&(token!="{"))
|
||||
token=GetToken();
|
||||
@@ -441,8 +436,7 @@ void rc2xml::ParsePopupMenu()
|
||||
if (token=="MENUITEM")
|
||||
ParseMenuItem();
|
||||
}
|
||||
m_xmlfile.Write("\t\t\t</children>\n");
|
||||
m_xmlfile.Write("\t\t\t</menu>\n");
|
||||
m_xmlfile.Write("\t\t\t</object>\n");
|
||||
}
|
||||
|
||||
wxString rc2xml::PeekToken()
|
||||
@@ -484,10 +478,10 @@ void rc2xml::ParseSlider(wxString label, wxString varname)
|
||||
|
||||
int 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);
|
||||
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);
|
||||
|
||||
//Always horizontal in MFC
|
||||
m_xmlfile.Write("\t\t<gauge");
|
||||
m_xmlfile.Write("\t\t<object class=\"wxGauge\"");
|
||||
WriteBasicInfo(x,y,width,height,varname);
|
||||
WriteStyle(style);
|
||||
m_xmlfile.Write("\t\t</gauge>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
}
|
||||
|
||||
bool rc2xml::ReadOrs(wxString & orstring)
|
||||
@@ -538,19 +532,19 @@ void rc2xml::ParseCtrlButton(wxString label, wxString varname)
|
||||
if (token.Find("BS_AUTOCHECKBOX")!=-1)
|
||||
{
|
||||
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);
|
||||
WriteLabel(label);
|
||||
m_xmlfile.Write("\t\t</checkbox>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
}
|
||||
|
||||
if (token.Find("BS_AUTORADIOBUTTON")!=-1)
|
||||
{
|
||||
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);
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
//Make it a rich text control
|
||||
style+="wxTE_MULTILINE ";
|
||||
m_xmlfile.Write("\t\t<textctrl");
|
||||
m_xmlfile.Write("\t\t<object class=\"wxTextCtrl\"");
|
||||
WriteBasicInfo(x,y,width,height,varname);
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
|
||||
//Write toolbar to xml file
|
||||
m_xmlfile.Write(" <toolbar");
|
||||
m_xmlfile.Write(" <object class=\"wxToolBar\"");
|
||||
//Avoid duplicate names this way
|
||||
varname.Replace("IDR_","TB_");
|
||||
WriteName(varname);
|
||||
@@ -779,7 +773,6 @@ void rc2xml::ParseToolBar(wxString varname)
|
||||
style+="wxTB_FLAT";
|
||||
WriteStyle(style);
|
||||
|
||||
m_xmlfile.Write("\t\t<children>\n");
|
||||
|
||||
//Grab width and height
|
||||
int width,height;
|
||||
@@ -797,7 +790,7 @@ void rc2xml::ParseToolBar(wxString varname)
|
||||
if (token=="BUTTON")
|
||||
{
|
||||
buttonname=GetToken();
|
||||
m_xmlfile.Write("\t\t\t<tool");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"tool\"");
|
||||
WriteName(buttonname);
|
||||
m_xmlfile.Write(">\n");
|
||||
//Write tool tip if any
|
||||
@@ -812,17 +805,16 @@ void rc2xml::ParseToolBar(wxString varname)
|
||||
buttonname+=".bmp";
|
||||
m_xmlfile.Write("\t\t\t\t<bitmap>"+buttonname+"</bitmap>\n");
|
||||
WriteToolButton(buttonname,c,width,height,bitmap);
|
||||
m_xmlfile.Write("\t\t\t</tool>\n");
|
||||
m_xmlfile.Write("\t\t\t</object>\n");
|
||||
c++;
|
||||
}
|
||||
else if (token=="SEPARATOR")
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<separator/>\n");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
|
||||
}
|
||||
token=GetToken();
|
||||
}
|
||||
m_xmlfile.Write("\t</children>\n");
|
||||
m_xmlfile.Write("\t</toolbar>\n");
|
||||
m_xmlfile.Write("\t</object>\n");
|
||||
}
|
||||
|
||||
//Extract bitmaps from larger toolbar bitmap
|
||||
@@ -890,7 +882,7 @@ void rc2xml::ParseMenuItem()
|
||||
//int spot;
|
||||
if (PeekToken()=="SEPARATOR")
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<separator/>\n");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -899,7 +891,7 @@ void rc2xml::ParseMenuItem()
|
||||
//Remove \t because it causes problems
|
||||
//spot=token.First("\\t");
|
||||
//token=token.Left(spot);
|
||||
m_xmlfile.Write("\t\t\t<menuitem");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxMenuItem\"");
|
||||
WriteName(name);
|
||||
m_xmlfile.Write(">\n");
|
||||
WriteLabel(token);
|
||||
@@ -926,7 +918,7 @@ void rc2xml::ParseMenuItem()
|
||||
|
||||
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;
|
||||
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);
|
||||
//Save icon as a bitmap
|
||||
WriteIcon(iconname);
|
||||
m_xmlfile.Write("\t\t</staticbitmap>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
|
||||
}
|
||||
//IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico"
|
||||
@@ -984,10 +976,10 @@ void rc2xml::ParseStaticBitmap(wxString bitmapname, wxString varname)
|
||||
int 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);
|
||||
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
|
||||
style=_T("wxSB_HORIZONTAL");
|
||||
|
||||
m_xmlfile.Write("\t\t<scrollbar");
|
||||
m_xmlfile.Write("\t\t<object class=\"wxScrollBar\"");
|
||||
WriteBasicInfo(x,y,width,height,varname);
|
||||
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,
|
||||
@@ -1074,9 +1066,9 @@ void rc2xml::ParseTreeCtrl(wxString label, wxString varname)
|
||||
ReadOrs(token);
|
||||
int 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);
|
||||
m_xmlfile.Write("\t\t</treectrl>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
|
||||
}
|
||||
// CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32",
|
||||
@@ -1089,9 +1081,9 @@ void rc2xml::ParseCalendar(wxString label, wxString varname)
|
||||
ReadOrs(token);
|
||||
int 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);
|
||||
m_xmlfile.Write("\t\t</calendarctrl>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
}
|
||||
// CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP,
|
||||
// 7,89,68,71
|
||||
@@ -1103,9 +1095,9 @@ void rc2xml::ParseListCtrl(wxString label, wxString varname)
|
||||
ReadOrs(token);
|
||||
int 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);
|
||||
m_xmlfile.Write("\t\t</listctrl>\n");
|
||||
m_xmlfile.Write("\t\t</object>\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -92,28 +92,24 @@ bool wxr2xml::ParseResources()
|
||||
|
||||
void wxr2xml::ParsePanel(wxItemResource * res)
|
||||
{
|
||||
m_xmlfile.Write("\t<panel");
|
||||
m_xmlfile.Write("\t<object class=\"wxPanel\"");
|
||||
PanelStuff(res);
|
||||
WriteControlInfo(res);
|
||||
m_xmlfile.Write("\n");
|
||||
m_xmlfile.Write("\t\t<children>\n");
|
||||
ParseControls(res);
|
||||
m_xmlfile.Write(" \t\t</children>\n");
|
||||
m_xmlfile.Write("\t</panel>\n\n");
|
||||
m_xmlfile.Write("\t</object>\n\n");
|
||||
}
|
||||
|
||||
void wxr2xml::ParseDialog(wxItemResource * res)
|
||||
{
|
||||
PanelStuff(res);
|
||||
m_xmlfile.Write("\t<dialog");
|
||||
m_xmlfile.Write("\t<object class=\"wxDialog\"");
|
||||
WriteControlInfo(res);
|
||||
m_xmlfile.Write(GetTitle(res));
|
||||
|
||||
m_xmlfile.Write("\n");
|
||||
m_xmlfile.Write("\t\t<children>\n");
|
||||
ParseControls(res);
|
||||
m_xmlfile.Write("\t\t</children>\n");
|
||||
m_xmlfile.Write("\t</dialog>\n\n");
|
||||
m_xmlfile.Write("\t</object>\n\n");
|
||||
}
|
||||
|
||||
void wxr2xml::ParseControls(wxItemResource * res)
|
||||
@@ -194,18 +190,18 @@ wxString wxr2xml::GetPosition(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);
|
||||
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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<textctrl");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxTextCtrl\"");
|
||||
WriteControlInfo(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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<checkbox");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxCheckBox\"");
|
||||
WriteControlInfo(res);
|
||||
m_xmlfile.Write(GetLabel(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)
|
||||
@@ -239,38 +235,38 @@ wxString wxr2xml::GetLabel(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);
|
||||
m_xmlfile.Write(GetLabel(res));
|
||||
// Add radio box items
|
||||
WriteStringList(res);
|
||||
// Value1
|
||||
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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<listbox");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxListBox\"");
|
||||
WriteControlInfo(res);
|
||||
WriteStringList(res);
|
||||
m_xmlfile.Write("\t\t\t</listbox>\n");
|
||||
m_xmlfile.Write("\t\t\t</object>\n");
|
||||
}
|
||||
|
||||
void wxr2xml::ParseStaticText(wxItemResource * res)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<statictext");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxStaticText\"");
|
||||
WriteControlInfo(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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<staticbox");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxStaticBox\"");
|
||||
WriteControlInfo(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)
|
||||
@@ -286,20 +282,20 @@ void wxr2xml::WriteStringList(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);
|
||||
// Add choice items
|
||||
WriteStringList(res);
|
||||
m_xmlfile.Write("\t\t\t</choice>\n");
|
||||
m_xmlfile.Write("\t\t\t</object>\n");
|
||||
}
|
||||
|
||||
void wxr2xml::ParseGauge(wxItemResource * res)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<gauge");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxGauge\"");
|
||||
WriteControlInfo(res);
|
||||
m_xmlfile.Write(GetValue1(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)
|
||||
@@ -318,12 +314,12 @@ wxString wxr2xml::GetRange(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);
|
||||
m_xmlfile.Write(GetValue1(res));
|
||||
m_xmlfile.Write(GetMax(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)
|
||||
@@ -342,34 +338,34 @@ wxString wxr2xml::GetMin(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);
|
||||
// Add combo items
|
||||
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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<radiobutton");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxRadioButton\"");
|
||||
WriteControlInfo(res);
|
||||
m_xmlfile.Write(GetLabel(res));
|
||||
|
||||
wxString msg;
|
||||
m_xmlfile.Write(GetValue1(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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<scrollbar");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxScrollBar\"");
|
||||
WriteControlInfo(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<range>"+GetValue3(res)+"</range>\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)
|
||||
@@ -584,18 +580,16 @@ void wxr2xml::ParseMenuBar(wxItemResource * res)
|
||||
wxItemResource *child;
|
||||
wxNode *node = res->GetChildren().First();
|
||||
// Get Menu Bar Name
|
||||
m_xmlfile.Write("\t<menubar ");
|
||||
m_xmlfile.Write("\t<object class=\"wxMenuBar\" ");
|
||||
m_xmlfile.Write(GenerateName(res));
|
||||
m_xmlfile.Write(">\n");
|
||||
m_xmlfile.Write("\t\t<children>\n");
|
||||
while (node) {
|
||||
child = (wxItemResource *) node->Data();
|
||||
ParseMenu(child);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
m_xmlfile.Write("\t\t</children>\n");
|
||||
m_xmlfile.Write("\t</menubar> \n\n");
|
||||
m_xmlfile.Write("\t</object> \n\n");
|
||||
}
|
||||
|
||||
void wxr2xml::ParseMenu(wxItemResource * res)
|
||||
@@ -603,7 +597,7 @@ void wxr2xml::ParseMenu(wxItemResource * res)
|
||||
wxItemResource *child;
|
||||
wxNode *node = res->GetChildren().First();
|
||||
// Get Menu
|
||||
m_xmlfile.Write("\t\t\t<menu ");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxMenu\" ");
|
||||
wxString menuname;
|
||||
menuname << "name = \"menu_" << res->GetValue1() << "\"";
|
||||
m_xmlfile.Write(menuname);
|
||||
@@ -613,7 +607,6 @@ void wxr2xml::ParseMenu(wxItemResource * res)
|
||||
if (res->GetValue4() != "")
|
||||
m_xmlfile.Write("\t\t\t\t<help>" + res->GetValue4() +
|
||||
"</help>\n");
|
||||
m_xmlfile.Write("\t\t\t<children>\n");
|
||||
// Read in menu items and additional menus
|
||||
while (node) {
|
||||
child = (wxItemResource *) node->Data();
|
||||
@@ -623,17 +616,16 @@ void wxr2xml::ParseMenu(wxItemResource * res)
|
||||
ParseMenu(child);
|
||||
node = node->Next();
|
||||
}
|
||||
m_xmlfile.Write("\t\t\t</children>\n");
|
||||
m_xmlfile.Write("\t\t\t</menu> \n");
|
||||
m_xmlfile.Write("\t\t\t</object> \n");
|
||||
}
|
||||
|
||||
void wxr2xml::ParseMenuItem(wxItemResource * res)
|
||||
{
|
||||
// Get Menu Item or Separator
|
||||
if (res->GetTitle() == "") {
|
||||
m_xmlfile.Write("\t\t\t<separator/>\n");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
|
||||
} else {
|
||||
m_xmlfile.Write("\t\t\t\t<menuitem ");
|
||||
m_xmlfile.Write("\t\t\t\t<object class=\"wxMenuItem\" ");
|
||||
wxString menuname;
|
||||
menuname << "name = \"menuitem_" << res->GetValue1() << "\"";
|
||||
m_xmlfile.Write(menuname);
|
||||
@@ -645,7 +637,7 @@ void wxr2xml::ParseMenuItem(wxItemResource * res)
|
||||
res->GetValue4() + "</help>\n");
|
||||
if (res->GetValue2())
|
||||
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)
|
||||
{
|
||||
m_xmlfile.Write("\t\t\t<staticbitmap");
|
||||
m_xmlfile.Write("\t\t\t<object class=\"wxStaticBitmap\"");
|
||||
WriteControlInfo(res);
|
||||
// value4 holds bitmap name
|
||||
wxString bitmapname;
|
||||
@@ -667,13 +659,13 @@ void wxr2xml::ParseStaticBitmap(wxItemResource * res)
|
||||
bitmapname += _T(".bmp");
|
||||
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
|
||||
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
|
||||
}
|
||||
//Parse a bitmap resource
|
||||
void wxr2xml::ParseBitmap(wxItemResource * res)
|
||||
{
|
||||
m_xmlfile.Write("\t<bitmap ");
|
||||
m_xmlfile.Write("\t<object class=\"wxBitmap\" ");
|
||||
m_xmlfile.Write(GenerateName(res)+">");
|
||||
wxString bitmapname;
|
||||
bitmapname = res->GetName();
|
||||
@@ -682,7 +674,7 @@ void wxr2xml::ParseBitmap(wxItemResource * res)
|
||||
bitmapname += _T(".bmp");
|
||||
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
|
||||
m_xmlfile.Write(bitmapname);
|
||||
m_xmlfile.Write("</bitmap>\n\n");
|
||||
m_xmlfile.Write("</object>\n\n");
|
||||
}
|
||||
|
||||
void wxr2xml::PanelStuff(wxItemResource * res)
|
||||
@@ -727,7 +719,7 @@ wxString wxr2xml::GetValue5(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);
|
||||
// value4 holds bitmap name
|
||||
wxString bitmapname;
|
||||
@@ -738,7 +730,7 @@ void wxr2xml::ParseBitmapButton(wxItemResource *res)
|
||||
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
|
||||
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)
|
||||
@@ -779,19 +771,19 @@ void wxr2xml::GetFontFace(wxFont font)
|
||||
case wxDEFAULT:
|
||||
break;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
default:
|
||||
wxLogError("Unknown font face");
|
||||
|
||||
+15
-21
@@ -83,7 +83,7 @@ int XmlResApp::OnRun()
|
||||
{ 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_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_PARAM, NULL, NULL, "input file",
|
||||
@@ -133,7 +133,7 @@ void XmlResApp::ParseParams(const wxCmdLineParser& cmdline)
|
||||
flagCompress = flagCPP && !cmdline.Found("u");
|
||||
|
||||
if (!cmdline.Found("o", &parOutput))
|
||||
parOutput = flagCPP ? "resource.cpp" : "resource.rsc";
|
||||
parOutput = flagCPP ? "resource.cpp" : "resource.xrs";
|
||||
parOutputPath = wxPathOnly(parOutput);
|
||||
if (!parOutputPath) parOutputPath = ".";
|
||||
|
||||
@@ -189,8 +189,8 @@ wxArrayString XmlResApp::PrepareTempFiles()
|
||||
|
||||
FindFilesInXML(doc.GetRoot(), flist, path);
|
||||
|
||||
doc.Save(parOutputPath + "/" + name + ".xmb", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN);
|
||||
flist.Add(name + ".xmb");
|
||||
doc.Save(parOutputPath + "/" + name + ".xrc", flagCompress ? wxXML_IO_BINZ : wxXML_IO_BIN);
|
||||
flist.Add(name + ".xrc");
|
||||
}
|
||||
|
||||
return flist;
|
||||
@@ -285,38 +285,32 @@ static wxString FileToCppArray(wxString filename, int num)
|
||||
wxString snum;
|
||||
wxFFile file(filename, "rb");
|
||||
size_t lng = file.Length();
|
||||
int linelng;
|
||||
|
||||
snum.Printf("%i", num);
|
||||
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];
|
||||
file.Read(buffer, lng);
|
||||
|
||||
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;
|
||||
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 << "\n";
|
||||
}
|
||||
output << tmp;
|
||||
linelng += tmp.Length()+1;
|
||||
}
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
output += "\"\n;\n\n";
|
||||
output += "};\n\n";
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -378,7 +372,7 @@ void " + parFuncname + "()\n\
|
||||
wxString name, ext, path;
|
||||
wxSplitPath(parFiles[i], &path, &name, &ext);
|
||||
file.Write(" wxTheXmlResource->Load(\"memory:xml_resource/" +
|
||||
name + ".xmb" + "\");\n");
|
||||
name + ".xrc" + "\");\n");
|
||||
}
|
||||
|
||||
file.Write("\n}\n");
|
||||
|
||||
@@ -6,57 +6,24 @@ program_dir = contrib/utils/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
|
||||
DATAFILES = \
|
||||
df/boxsizer.df \
|
||||
df/break.df \
|
||||
df/button.df \
|
||||
df/checkbox.df \
|
||||
df/checklist.df \
|
||||
df/choice.df \
|
||||
df/combobox.df \
|
||||
df/control.df \
|
||||
df/dialog.df \
|
||||
df/flexgridsizer.df \
|
||||
df/gauge.df \
|
||||
df/gridsizer.df \
|
||||
df/htmlwindow.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
|
||||
|
||||
DATAFILES = df/break.df df/control.df df/menu_item.df df/notebookpage.df \
|
||||
df/panel_item.df df/panelbase.df df/separator.df df/sizer_item.df \
|
||||
df/sizeritem.df df/spacer.df df/tool.df df/toolbar_item.df \
|
||||
df/unknown.df df/window.df df/wxBitmapButton.df df/wxBoxSizer.df \
|
||||
df/wxButton.df df/wxCalendarCtrl.df df/wxCheckBox.df \
|
||||
df/wxCheckList.df df/wxChoice.df df/wxComboBox.df df/wxDialog.df \
|
||||
df/wxFlexGridSizer.df df/wxGauge.df df/wxGridSizer.df \
|
||||
df/wxHtmlWindow.df df/wxListBox.df df/wxListCtrl.df df/wxMenu.df \
|
||||
df/wxMenuBar.df df/wxMenuItem.df df/wxNotebook.df df/wxPanel.df \
|
||||
df/wxRadioBox.df df/wxRadioButton.df df/wxScrollBar.df \
|
||||
df/wxSlider.df df/wxSpinButton.df df/wxSpinCtrl.df \
|
||||
df/wxStaticBitmap.df df/wxStaticBox.df df/wxStaticBoxSizer.df \
|
||||
df/wxStaticLine.df df/wxStaticText.df df/wxTextCtrl.df \
|
||||
df/wxToolBar.df df/wxTreeCtrl.df
|
||||
|
||||
APPEXTRALIBS=$(top_builddir)/lib/libwxxml.@WX_TARGET_LIBRARY_TYPE@
|
||||
APPEXTRADEFS=-I$(top_srcdir)/contrib/include
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
node staticboxsizer
|
||||
derived from boxsizer
|
||||
var label of text
|
||||
var minsize of coord
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
node bitmapbutton
|
||||
node wxBitmapButton
|
||||
var style of flags wxBU_AUTODRAW,wxBU_LEFT,wxBU_RIGHT,wxBU_TOP,wxBU_BOTTOM
|
||||
var default of bool
|
||||
var bitmap of text
|
||||
@@ -1,4 +1,4 @@
|
||||
node boxsizer
|
||||
node wxBoxSizer
|
||||
type sizer
|
||||
icon 0
|
||||
childtype sizer_item
|
||||
@@ -1,4 +1,4 @@
|
||||
node button
|
||||
node wxButton
|
||||
var label of text
|
||||
var default of bool
|
||||
derived from control
|
||||
+1
-1
@@ -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
|
||||
derived from control
|
||||
@@ -1,4 +1,4 @@
|
||||
node checkbox
|
||||
node wxCheckBox
|
||||
var label of text
|
||||
var checked of bool
|
||||
derived from control
|
||||
@@ -1,3 +1,3 @@
|
||||
node checklist
|
||||
node wxCheckList
|
||||
var content of not_implemented
|
||||
derived from control
|
||||
@@ -1,4 +1,4 @@
|
||||
node choice
|
||||
node wxChoice
|
||||
var style of flags wxCB_SORT
|
||||
var selection of integer
|
||||
var content of not_implemented
|
||||
@@ -1,4 +1,4 @@
|
||||
node combobox
|
||||
node wxComboBox
|
||||
var style of flags wxCB_SIMPLE,wxCB_SORT,wxCB_READONLY,wxCB_DROPDOWN
|
||||
var value of string
|
||||
var selection of integer
|
||||
@@ -1,4 +1,4 @@
|
||||
node dialog
|
||||
node wxDialog
|
||||
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 centered of bool
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
node flexgridsizer
|
||||
node wxFlexGridSizer
|
||||
type sizer
|
||||
icon 4
|
||||
childtype sizer_item
|
||||
@@ -1,4 +1,4 @@
|
||||
node gauge
|
||||
node wxGauge
|
||||
var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH
|
||||
var range of integer
|
||||
var value of integer
|
||||
@@ -1,4 +1,4 @@
|
||||
node gridsizer
|
||||
node wxGridSizer
|
||||
type sizer
|
||||
icon 4
|
||||
childtype sizer_item
|
||||
@@ -1,4 +1,4 @@
|
||||
node htmlwindow
|
||||
node wxHtmlWindow
|
||||
var url of text
|
||||
var htmlcode of text
|
||||
var borders of dimension
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user