private:
bool m_IsInside;
wxSizer *m_ParentSizer;
+
+ bool IsSizerNode(wxXmlNode *node);
};
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);
// 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=""
// 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); }
bool wxBitmapXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("bitmap");
+ return IsOfClass(node, _T("wxBitmap"));
}
bool wxIconXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("icon");
+ return IsOfClass(node, _T("wxIcon"));
}
bool wxBitmapButtonXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("bitmapbutton");
+ return IsOfClass(node, _T("wxBitmapButton"));
}
bool wxButtonXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("button");
+ return IsOfClass(node, _T("wxButton"));
}
bool wxCalendarCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("calendarctrl");
+ return IsOfClass(node, _T("wxCalendarCtrl"));
}
bool wxCheckBoxXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("checkbox");
+ return IsOfClass(node, _T("wxCheckBox"));
}
#endif
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 )
{
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() )
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"))
+ );
}
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 )
{
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"))
+ );
}
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 )
{
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
bool wxDialogXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("dialog");
+ return IsOfClass(node, _T("wxDialog"));
}
bool wxGaugeXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("gauge");
+ return IsOfClass(node, _T("wxGauge"));
}
bool wxHtmlWindowXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("htmlwindow");
+ return IsOfClass(node, _T("wxHtmlWindow"));
}
#endif // wxUSE_HTML
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 )
{
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"))
+ );
}
bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("listctrl");
+ return IsOfClass(node, _T("wxListCtrl"));
}
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)
+ {
+ 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
{
- 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();
+ 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 {
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
bool wxPanelXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("panel");
+ return IsOfClass(node, _T("wxPanel"));
}
bool wxRadioButtonXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("radiobutton");
+ return IsOfClass(node, _T("wxRadioButton"));
}
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 )
{
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
bool wxScrollBarXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("scrollbar");
+ return IsOfClass(node, _T("wxScrollBar"));
}
#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")));
}
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();
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")));
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"))));
}
bool wxSliderXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("slider");
+ return IsOfClass(node, _T("wxSlider"));
}
bool wxSpinCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("spinctrl");
+ return IsOfClass(node, _T("wxSpinCtrl"));
}
#endif // wxUSE_SPINCTRL
bool wxStaticBitmapXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("staticbitmap");
+ return IsOfClass(node, _T("wxStaticBitmap"));
}
bool wxStaticBoxXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("staticbox");
+ return IsOfClass(node, _T("wxStaticBox"));
}
bool wxStaticLineXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("staticline");
+ return IsOfClass(node, _T("wxStaticLine"));
}
#endif
bool wxStaticTextXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("statictext");
+ return IsOfClass(node, _T("wxStaticText"));
}
GetText(_T("value")),
GetPosition(), GetSize(),
GetStyle(),
- wxDefaultValidator,
- GetText(_T("name"))
+ wxDefaultValidator,
+ GetName()
);
SetupWindow(text);
bool wxTextCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("textctrl");
+ return IsOfClass(node, _T("wxTextCtrl"));
}
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(),
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__
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);
}
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
bool wxTreeCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("treectrl");
+ return IsOfClass(node, _T("wxTreeCtrl"));
}
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)
bool wxUnknownWidgetXmlHandler::CanHandle(wxXmlNode *node)
{
- return node->GetName() == _T("unknown");
+ return IsOfClass(node, _T("unknown"));
}
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);
}
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;
}
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; }
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; }
-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
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);
}
}
- 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;
}
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;
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;
}
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);
wxObject *returned = DoCreateResource();
m_Node = myNode;
+ m_Class = myClass;
m_Parent = myParent; m_ParentAsWindow = myParentAW;
m_Instance = myInstance; m_InstanceAsWindow = myInstanceAW;
}
-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);
}
}
+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();
+ }
+}
+
+
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);
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");
}
/*
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
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
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");
}
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)
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");
}
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();
ParsePopupMenu();
}
}
- m_xmlfile.Write("\t\t</children>\n");
- m_xmlfile.Write("\t</menubar>\n");
+ m_xmlfile.Write("\t</object>\n");
}
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();
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()
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");
}
/*
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)
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");
}
}
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");
}
/*
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");
}
/*
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");
}
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);
style+="wxTB_FLAT";
WriteStyle(style);
- m_xmlfile.Write("\t\t<children>\n");
//Grab width and height
int width,height;
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
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
//int spot;
if (PeekToken()=="SEPARATOR")
{
- m_xmlfile.Write("\t\t\t<separator/>\n");
+ m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
return;
}
//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);
ptoken=PeekToken();
}
- m_xmlfile.Write("\t\t\t</menuitem>\n");
+ m_xmlfile.Write("\t\t\t</object>\n");
}
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"
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");
}
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,
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",
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
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");
}
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)
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");
}
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)
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)
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)
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)
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)
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)
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);
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();
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);
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");
}
}
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;
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();
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)
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;
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)
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");
{ 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",
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 = ".";
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;
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;
}
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");
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
+++ /dev/null
-node bitmapbutton
-var style of flags wxBU_AUTODRAW,wxBU_LEFT,wxBU_RIGHT,wxBU_TOP,wxBU_BOTTOM
-var default of bool
-var bitmap of text
-var selected of text
-var focus of text
-var disabled of text
-derived from control
+++ /dev/null
-node boxsizer
-type sizer
-icon 0
-childtype sizer_item
-derived from panel_item
-var orient of flags wxHORIZONTAL,wxVERTICAL
-var minsize of coord
+++ /dev/null
-node button
-var label of text
-var default of bool
-derived from control
\ No newline at end of file
+++ /dev/null
-node calendarctrl
-var style of flags wxCAL_SUNDAY_FIRST,wxCAL_MONDAY_FIRST,wxCAL_SHOW_HOLIDAYS,wxCAL_NO_YEAR_CHANGE,wxCAL_NO_MONTH_CHANGE
-derived from control
+++ /dev/null
-node checkbox
-var label of text
-var checked of bool
-derived from control
\ No newline at end of file
+++ /dev/null
-node checklist
-var content of not_implemented
-derived from control
+++ /dev/null
-node choice
-var style of flags wxCB_SORT
-var selection of integer
-var content of not_implemented
-derived from control
+++ /dev/null
-node combobox
-var style of flags wxCB_SIMPLE,wxCB_SORT,wxCB_READONLY,wxCB_DROPDOWN
-var value of string
-var selection of integer
-var content of not_implemented
-derived from control
+++ /dev/null
-node dialog
-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
-derived from panelbase
+++ /dev/null
-node flexgridsizer
-type sizer
-icon 4
-childtype sizer_item
-derived from panel_item
-var rows of integer
-var cols of integer
-var vgap of dimension
-var hgap of dimension
-var minsize of coord
+++ /dev/null
-node gauge
-var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH
-var range of integer
-var value of integer
-var shadow of dimension
-var bezel of dimension
-derived from control
+++ /dev/null
-node gridsizer
-type sizer
-icon 4
-childtype sizer_item
-derived from panel_item
-var rows of integer
-var cols of integer
-var vgap of dimension
-var hgap of dimension
-var minsize of coord
+++ /dev/null
-node htmlwindow
-var url of text
-var htmlcode of text
-var borders of dimension
-var style of flags wxHW_SCROLLBAR_NEVER,wxHW_SCROLLBAR_AUTO
-derived from control
+++ /dev/null
-node listbox
-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 content of not_implemented
-derived from control
+++ /dev/null
-node listctrl
-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
+++ /dev/null
-node menu
-type panel
-icon 0
-childtype menu_item
-var label of text
-var style of flags wxMENU_TEAROFF
-var help of text
-derived from menu_item
+++ /dev/null
-node menubar
-type panel
-icon 0
-childtype menu
-var style of flags wxMB_DOCKABLE
+++ /dev/null
-node menuitem
-type normal
-icon 0
-var label of text
-var help of text
-var checkable of bool
-var checked of bool
-var enabled of bool
-derived from menu_item
+++ /dev/null
-node notebook
-type notebook
-var style of flags wxNB_FIXEDWIDTH,wxNB_LEFT,wxNB_RIGHT,wxNB_BOTTOM
-var usenotebooksizer of bool
-childtype panel
-derived from control
+++ /dev/null
-node panel
-derived from panel_item
-derived from panelbase
+++ /dev/null
-node radiobox
-var style of flags wxRA_SPECIFY_COLS,wxRA_HORIZONTAL,wxRA_SPECIFY_ROWS,wxRA_VERTICAL
-var label of text
-var dimension of integer
-var selection of integer
-var content of not_implemented
-derived from control
+++ /dev/null
-node radiobutton
-var label of text
-var value of bool
-var style of flags wxRB_GROUP
-derived from control
+++ /dev/null
-node scrollbar
-var style of flags wxSB_HORIZONTAL,wxSB_VERTICAL
-var value of integer
-var thumbsize of integer
-var range of integer
-var pagesize of integer
-derived from control
\ No newline at end of file
+++ /dev/null
-node slider
-var value of integer
-var min of integer
-var max of integer
-var style of flags wxSL_HORIZONTAL,wxSL_VERTICAL,wxSL_AUTOTICKS,wxSL_LABELS,wxSL_LEFT,wxSL_TOP,wxSL_RIGHT,wxSL_BOTTOM,wxSL_BOTH,wxSL_SELRANGE
-var tickfreq of integer
-var pagesize of integer
-var linesize of integer
-var thumb of integer
-var tick of integer
-var selmin of integer
-var selmax of integer
-derived from control
+++ /dev/null
-node spinbutton
-var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP
-var value of integer
-var min of integer
-var max of integer
-derived from control
+++ /dev/null
-node spinctrl
-var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP
-var value of integer
-var min of integer
-var max of integer
-derived from control
+++ /dev/null
-node staticbitmap
-var bitmap of text
-derived from control
\ No newline at end of file
+++ /dev/null
-node staticbox
-var label of text
-derived from control
+++ /dev/null
-node staticboxsizer
-derived from boxsizer
-var label of text
-var minsize of coord
+++ /dev/null
-node staticline
-var style of flags wxLI_HORIZONTAL,wxLI_VERTICAL
-derived from control
+++ /dev/null
-node statictext
-var label of text
-derived from control
\ No newline at end of file
+++ /dev/null
-node textctrl
-var value of text
-var style of flags wxTE_PROCESS_ENTER,wxTE_PROCESS_TAB,wxTE_MULTILINE,wxTE_PASSWORD,wxTE_READONLY,wxHSCROLL
-derived from control
+++ /dev/null
-node toolbar
-type panel
-icon 0
-childtype toolbar_item
-var style of flags wxTB_FLAT,wxTB_DOCKABLE,wxTB_VERTICAL,wxTB_HORIZONTAL
-var bitmapsize of coord
-var pos of coord
-var size of coord
-var margins of coord
-var packing of integer
-var separation of integer
+++ /dev/null
-node treectrl
-var style of flags wxTR_HAS_BUTTONS,wxTR_EDIT_LABELS,wxTR_MULTIPLE
-derived from control
--- /dev/null
+node wxBitmapButton
+var style of flags wxBU_AUTODRAW,wxBU_LEFT,wxBU_RIGHT,wxBU_TOP,wxBU_BOTTOM
+var default of bool
+var bitmap of text
+var selected of text
+var focus of text
+var disabled of text
+derived from control
--- /dev/null
+node wxBoxSizer
+type sizer
+icon 0
+childtype sizer_item
+derived from panel_item
+var orient of flags wxHORIZONTAL,wxVERTICAL
+var minsize of coord
--- /dev/null
+node wxButton
+var label of text
+var default of bool
+derived from control
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+node wxCheckBox
+var label of text
+var checked of bool
+derived from control
\ No newline at end of file
--- /dev/null
+node wxCheckList
+var content of not_implemented
+derived from control
--- /dev/null
+node wxChoice
+var style of flags wxCB_SORT
+var selection of integer
+var content of not_implemented
+derived from control
--- /dev/null
+node wxComboBox
+var style of flags wxCB_SIMPLE,wxCB_SORT,wxCB_READONLY,wxCB_DROPDOWN
+var value of string
+var selection of integer
+var content of not_implemented
+derived from control
--- /dev/null
+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
+derived from panelbase
--- /dev/null
+node wxFlexGridSizer
+type sizer
+icon 4
+childtype sizer_item
+derived from panel_item
+var rows of integer
+var cols of integer
+var vgap of dimension
+var hgap of dimension
+var minsize of coord
--- /dev/null
+node wxGauge
+var style of flags wxGA_HORIZONTAL,wxGA_VERTICAL,wxGA_PROGRESSBAR,wxGA_SMOOTH
+var range of integer
+var value of integer
+var shadow of dimension
+var bezel of dimension
+derived from control
--- /dev/null
+node wxGridSizer
+type sizer
+icon 4
+childtype sizer_item
+derived from panel_item
+var rows of integer
+var cols of integer
+var vgap of dimension
+var hgap of dimension
+var minsize of coord
--- /dev/null
+node wxHtmlWindow
+var url of text
+var htmlcode of text
+var borders of dimension
+var style of flags wxHW_SCROLLBAR_NEVER,wxHW_SCROLLBAR_AUTO
+derived from control
--- /dev/null
+node wxListBox
+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 content of not_implemented
+derived from control
--- /dev/null
+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
+derived from control
--- /dev/null
+node wxMenu
+type panel
+icon 0
+childtype menu_item
+var label of text
+var style of flags wxMENU_TEAROFF
+var help of text
+derived from menu_item
--- /dev/null
+node wxMenuBar
+type panel
+icon 0
+childtype wxMenu
+var style of flags wxMB_DOCKABLE
--- /dev/null
+node wxMenuItem
+type normal
+icon 0
+var label of text
+var help of text
+var checkable of bool
+var checked of bool
+var enabled of bool
+derived from menu_item
--- /dev/null
+node wxNotebook
+type notebook
+var style of flags wxNB_FIXEDWIDTH,wxNB_LEFT,wxNB_RIGHT,wxNB_BOTTOM
+var usenotebooksizer of bool
+childtype wxPanel
+derived from control
--- /dev/null
+node wxPanel
+derived from panel_item
+derived from panelbase
--- /dev/null
+node wxRadioBox
+var style of flags wxRA_SPECIFY_COLS,wxRA_HORIZONTAL,wxRA_SPECIFY_ROWS,wxRA_VERTICAL
+var label of text
+var dimension of integer
+var selection of integer
+var content of not_implemented
+derived from control
--- /dev/null
+node wxRadioButton
+var label of text
+var value of bool
+var style of flags wxRB_GROUP
+derived from control
--- /dev/null
+node wxScrollBar
+var style of flags wxSB_HORIZONTAL,wxSB_VERTICAL
+var value of integer
+var thumbsize of integer
+var range of integer
+var pagesize of integer
+derived from control
\ No newline at end of file
--- /dev/null
+node wxSlider
+var value of integer
+var min of integer
+var max of integer
+var style of flags wxSL_HORIZONTAL,wxSL_VERTICAL,wxSL_AUTOTICKS,wxSL_LABELS,wxSL_LEFT,wxSL_TOP,wxSL_RIGHT,wxSL_BOTTOM,wxSL_BOTH,wxSL_SELRANGE
+var tickfreq of integer
+var pagesize of integer
+var linesize of integer
+var thumb of integer
+var tick of integer
+var selmin of integer
+var selmax of integer
+derived from control
--- /dev/null
+node wxSpinButton
+var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP
+var value of integer
+var min of integer
+var max of integer
+derived from control
--- /dev/null
+node wxSpinCtrl
+var style of flags wxSP_HORIZONTAL,wxSP_VERTICAL,wxSP_ARROW_KEYS,wxSP_WRAP
+var value of integer
+var min of integer
+var max of integer
+derived from control
--- /dev/null
+node wxStaticBitmap
+var bitmap of text
+derived from control
\ No newline at end of file
--- /dev/null
+node wxStaticBox
+var label of text
+derived from control
--- /dev/null
+node wxStaticBoxSizer
+derived from wxBoxSizer
+var label of text
+var minsize of coord
--- /dev/null
+node wxStaticLine
+var style of flags wxLI_HORIZONTAL,wxLI_VERTICAL
+derived from control
--- /dev/null
+node wxStaticText
+var label of text
+derived from control
\ No newline at end of file
--- /dev/null
+node wxTextCtrl
+var value of text
+var style of flags wxTE_PROCESS_ENTER,wxTE_PROCESS_TAB,wxTE_MULTILINE,wxTE_PASSWORD,wxTE_READONLY,wxHSCROLL
+derived from control
--- /dev/null
+node wxToolBar
+type panel
+icon 0
+childtype toolbar_item
+var style of flags wxTB_FLAT,wxTB_DOCKABLE,wxTB_VERTICAL,wxTB_HORIZONTAL
+var bitmapsize of coord
+var pos of coord
+var size of coord
+var margins of coord
+var packing of integer
+var separation of integer
--- /dev/null
+node wxTreeCtrl
+var style of flags wxTR_HAS_BUTTONS,wxTR_EDIT_LABELS,wxTR_MULTIPLE
+derived from control
#include "editor.h"
#include "nodehnd.h"
#include "xmlhelpr.h"
+#include "preview.h"
m_SelectedNode = NULL;
m_Resource = NULL;
m_FileName = wxEmptyString;
- m_Preview = NULL;
m_SelectedProp = -1;
wxMenu *menuFile = new wxMenu;
#endif
// must stay last:
m_Handlers.Append(new NodeHandlerUnknown(this));
-
// Create toolbar:
wxToolBar *toolBar = CreateToolBar(wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT);
EditorFrame::~EditorFrame()
{
+ PreviewFrame::Get()->Close();
+
wxConfigBase *cfg = wxConfigBase::Get();
cfg->Write("editor_x", (long)GetPosition().x);
-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()
{
wxXmlNode *sel = m_SelectedNode;
{
XmlTreeData* dt = (XmlTreeData*)m_TreeCtrl->GetItemData(m_TreeCtrl->GetSelection());;
if (dt != NULL && dt->Node != NULL)
- RefreshPreview(dt->Node);
+ PreviewFrame::Get()->Preview(dt->Node);
break;
}
NodeHandler *hnd = FindHandler(realnode);
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);
wxTreeItemId root = m_TreeCtrl->GetSelection();
SelectNode(node, &root);
NodeHandler *hnd = FindHandler(realnode);
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);
wxTreeItemId root = m_TreeCtrl->GetSelection();
SelectNode(node, &root);
wxString name;
switch (event.GetId())
{
- case ID_NEWDIALOG : name = "dialog"; break;
- case ID_NEWPANEL : name = "panel"; break;
- case ID_NEWMENU : name = "menu"; break;
- case ID_NEWMENUBAR : name = "menubar"; break;
- case ID_NEWTOOLBAR : name = "toolbar"; break;
+ case ID_NEWDIALOG : name = _T("wxDialog"); break;
+ case ID_NEWPANEL : name = _T("wxPanel"); break;
+ case ID_NEWMENU : name = _T("wxMenu"); break;
+ case ID_NEWMENUBAR : name = _T("wxMenuBar"); break;
+ case ID_NEWTOOLBAR : name = _T("wxToolBar"); break;
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);
NotifyChanged(CHANGED_TREE);
SelectNode(node);
if (m_SelectedNode == NULL || m_SelectedNode == m_Resource->GetRoot())
{
- popup->Append(ID_NEWDIALOG, _("New dialog"));
- popup->Append(ID_NEWPANEL, _("New panel"));
- popup->Append(ID_NEWMENU, _("New menu"));
- popup->Append(ID_NEWMENUBAR, _("New menubar"));
- popup->Append(ID_NEWTOOLBAR, _("New toolbar"));
+ popup->Append(ID_NEWDIALOG, _("New wxDialog"));
+ popup->Append(ID_NEWPANEL, _("New wxPanel"));
+ popup->Append(ID_NEWMENU, _("New wxMenu"));
+ popup->Append(ID_NEWMENUBAR, _("New wxMenuBar"));
+ popup->Append(ID_NEWTOOLBAR, _("New wxToolBar"));
}
else
if (!arr.IsEmpty())
{
wxMenu *news = new wxMenu;
+ wxMenu *news2 = news;
for (size_t i = 0; i < arr.GetCount(); i++)
{
- news->Append(i + ID_NEWNODE, arr[i]);
- if (i % 16 == 15) news->Break();
+ news2->Append(i + ID_NEWNODE, arr[i]);
+#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);
}
if (!arr.IsEmpty())
{
wxMenu *news = new wxMenu;
+ wxMenu *news2 = news;
for (size_t i = 0; i < arr.GetCount(); i++)
{
- news->Append(i + ID_NEWSYBNODE, arr[i]);
- if (i % 16 == 15) news->Break();
+ news2->Append(i + ID_NEWSYBNODE, arr[i]);
+#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->AppendSeparator();
- popup->Append(ID_CUT, "Cut");
- popup->Append(ID_COPY, "Copy");
- popup->Append(ID_PASTE_SYBLING, "Paste as sybling");
- popup->Append(ID_PASTE_CHILD, "Paste as child");
+ popup->Append(ID_CUT, _("Cut"));
+ popup->Append(ID_COPY, _("Copy"));
+ popup->Append(ID_PASTE_SYBLING, _("Paste as sybling"));
+ popup->Append(ID_PASTE_CHILD, _("Paste as child"));
popup->AppendSeparator();
popup->Append(ID_DELETE_NODE, _("Delete"));
popup->Enable(ID_PASTE_SYBLING, m_Clipboard != NULL);
void LoadFile(const wxString& filename);
void NewFile();
void SaveFile(const wxString& filename);
+ wxString GetFileName() { return m_FileName; }
void RefreshTree();
- void RefreshPreview(wxXmlNode *node);
void RefreshProps(wxXmlNode *node);
void RefreshPropsEdit();
bool SelectNode(wxXmlNode *node, wxTreeItemId *root = NULL);
wxString m_FileName;
wxXmlDocument *m_Resource;
- wxWindow *m_Preview;
DECLARE_EVENT_TABLE()
void OnTreeSel(wxTreeEvent& event);
ni->Type = HANDLER_NONE;
ni->Icon = 0;
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
if (ni->Type == HANDLER_NONE || ni->Node.IsEmpty() || ni->Abstract)
bool NodeHandler::CanHandle(wxXmlNode *node)
{
- return (m_NodeInfo->Node == node->GetName());
+ return (m_NodeInfo->Node == XmlGetClass(node));
}
wxString NodeHandler::GetTreeString(wxXmlNode *node)
{
- wxString xmlid = node->GetPropVal("name", "");
+ wxString xmlid = node->GetPropVal(_T("name"), wxEmptyString);
if (xmlid.IsEmpty())
- return node->GetName();
+ return XmlGetClass(node);
else
- return (node->GetName() + " '" + xmlid + "'");
+ return XmlGetClass(node) + _T(" '") + xmlid + _T("'");
}
{
wxTreeItemId root = NodeHandler::CreateTreeNode(treectrl, parent, node);
- wxXmlNode *n = XmlFindNode(node, "children");
+ wxXmlNode *n = XmlFindNode(node, "object");
- if (n) n = n->GetChildren();
-
while (n)
{
- if (n->GetType() == wxXML_ELEMENT_NODE)
+ if (n->GetType() == wxXML_ELEMENT_NODE &&
+ n->GetName() == _T("object"))
EditorFrame::Get()->CreateTreeNode(treectrl, root, n);
n = n->GetNext();
}
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)
- cnd->InsertChild(node, insert_before);
+ parent->InsertChild(node, insert_before);
else
- cnd->AddChild(node);
+ parent->AddChild(node);
EditorFrame::Get()->NotifyChanged(CHANGED_TREE);
}
void NodeHandlerSizer::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 (node->GetName() == "spacer" || node->GetName() == "sizeritem")
+{
+ if (XmlGetClass(node) == _T("spacer") || XmlGetClass(node) == _T("sizeritem"))
{
if (insert_before)
- cnd->InsertChild(node, insert_before);
+ parent->InsertChild(node, insert_before);
else
- cnd->AddChild(node);
+ parent->AddChild(node);
}
else
{
- wxXmlNode *itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, "sizeritem");
- wxXmlNode *winnode = new wxXmlNode(wxXML_ELEMENT_NODE, "window");
- itemnode->AddChild(winnode);
- winnode->AddChild(node);
+ wxXmlNode *itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
+ itemnode->AddProperty(_T("class"), _T("sizeritem"));
+ itemnode->AddChild(node);
if (insert_before)
- cnd->InsertChild(itemnode, insert_before);
+ parent->InsertChild(itemnode, insert_before);
else
- cnd->AddChild(itemnode);
+ parent->AddChild(itemnode);
}
EditorFrame::Get()->NotifyChanged(CHANGED_TREE);
}
int orig = NodeHandler::GetTreeIcon(node);
if (orig == 0)
{
- if (XmlReadValue(node, "orient") == "wxVERTICAL") return 2;
+ if (XmlReadValue(node, _T("orient")) == _T("wxVERTICAL")) return 2;
else return 3;
}
else return orig;
wxXmlNode *NodeHandlerSizerItem::GetRealNode(wxXmlNode *node)
{
- wxXmlNode *n = XmlFindNode(node, "window");
-
- if (n) n = n->GetChildren();
-
- while (n)
- {
- if (n->GetType() == wxXML_ELEMENT_NODE)
- return n;
- n = n->GetNext();
- }
- return NULL;
+ return XmlFindNode(node, _T("object"));
}
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;
- if (node->GetName() == "notebookpage")
+ if (XmlGetClass(node) == _T("notebookpage"))
itemnode = node;
else
{
- itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, "notebookpage");
- wxXmlNode *winnode = new wxXmlNode(wxXML_ELEMENT_NODE, "window");
- itemnode->AddChild(winnode);
- winnode->AddChild(node);
+ itemnode = new wxXmlNode(wxXML_ELEMENT_NODE, _T("object"));
+ itemnode->AddProperty(_T("class"), _T("notebookpage"));
+ itemnode->AddChild(node);
}
if (insert_before)
- cnd->InsertChild(itemnode, insert_before);
+ parent->InsertChild(itemnode, insert_before);
else
- cnd->AddChild(itemnode);
+ parent->AddChild(itemnode);
}
EditorFrame::Get()->NotifyChanged(CHANGED_TREE);
}
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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);
+ }
+}
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// 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
+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);
+}
+
+
+
+
void XmlWriteValue(wxXmlNode *parent, const wxString& name, const wxString& value);
wxString XmlReadValue(wxXmlNode *parent, const wxString& name);
wxXmlNode *XmlFindNode(wxXmlNode *parent, const wxString& name);
+wxString XmlGetClass(wxXmlNode *parent);
+void XmlSetClass(wxXmlNode *parent, const wxString& classname);
#endif
{ 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",
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 = ".";
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;
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;
}
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");