2000-09-26 17:59:37 -04:00
|
|
|
// wxr2xml.cpp: implementation of the wxr2xml class.
|
|
|
|
// 8/30/00 Brian Gavin
|
2000-09-17 15:17:13 -04:00
|
|
|
// only tested on wxMSW so far
|
2000-09-26 17:59:37 -04:00
|
|
|
//License: wxWindows Liscense
|
|
|
|
// ////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/*
|
|
|
|
How to use class:
|
|
|
|
#include "wxr2xml.h"
|
|
|
|
...
|
|
|
|
wxr2xml trans;
|
|
|
|
trans->Convert("Myfile.wxr","Myfile.xml");
|
2000-09-17 15:17:13 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wxr2xml.h"
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
2000-09-17 15:17:13 -04:00
|
|
|
// Construction/Destruction
|
2000-09-26 17:59:37 -04:00
|
|
|
// ////////////////////////////////////////////////////////////////////
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxr2xml::wxr2xml()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxr2xml::~wxr2xml()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
bool wxr2xml::Convert(wxString wxrfile, wxString xmlfile)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
bool result;
|
2003-12-11 06:27:56 -05:00
|
|
|
result = m_xmlfile.Open(xmlfile.c_str(), _T("w+t"));
|
|
|
|
wxASSERT_MSG(result, _T("Couldn't create XML file"));
|
2000-09-26 17:59:37 -04:00
|
|
|
if (!result)
|
2004-06-11 09:14:23 -04:00
|
|
|
return false;
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
result = m_table.ParseResourceFile(wxrfile);
|
2003-12-11 06:27:56 -05:00
|
|
|
wxASSERT_MSG(result, _T("Couldn't Load WXR file"));
|
2000-09-26 17:59:37 -04:00
|
|
|
if (!result)
|
2004-06-11 09:14:23 -04:00
|
|
|
return false;
|
2000-09-26 17:59:37 -04:00
|
|
|
// Write basic xml header
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("<?xml version=\"1.0\" ?>\n"));
|
|
|
|
m_xmlfile.Write(_T("<resource>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
result = ParseResources();
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("</resource>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Close();
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
return result;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
bool wxr2xml::ParseResources()
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
m_table.BeginFind();
|
2004-05-15 13:38:29 -04:00
|
|
|
wxHashTable::Node *node;
|
2000-09-26 17:59:37 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
node = m_table.Next();
|
2004-06-11 09:14:23 -04:00
|
|
|
while (node)
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
wxItemResource *res = (wxItemResource *) node->GetData();
|
2000-09-17 15:17:13 -04:00
|
|
|
wxString resType(res->GetType());
|
2003-12-11 06:27:56 -05:00
|
|
|
if (resType == _T("wxDialog"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseDialog(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxPanel"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParsePanel(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxPanel"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParsePanel(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxMenu"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseMenuBar(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxBitmap"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseBitmap(res);
|
|
|
|
else
|
2003-12-11 06:27:56 -05:00
|
|
|
wxLogError(_T("Found unsupported resource ") + resType);
|
|
|
|
node = m_table.Next();
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
2004-06-11 09:14:23 -04:00
|
|
|
return true;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParsePanel(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t<object class=\"wxPanel\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
PanelStuff(res);
|
|
|
|
WriteControlInfo(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseControls(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t</object>\n\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseDialog(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
PanelStuff(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t<object class=\"wxDialog\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetTitle(res));
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseControls(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t</object>\n\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseControls(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
wxNode *node = res->GetChildren().GetFirst();
|
2004-06-11 09:14:23 -04:00
|
|
|
while (node)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
wxItemResource *res = (wxItemResource *) node->GetData();
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString resType(res->GetType());
|
2003-12-11 06:27:56 -05:00
|
|
|
if (resType == _T("wxButton"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseButton(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if ((resType == _T("wxTextCtrl")) | (resType == _T("wxText"))
|
|
|
|
| (resType == _T("wxMultiText")))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseTextCtrl(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxCheckBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseCheckBox(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxRadioBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseRadioBox(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxListBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseListBox(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if ((resType == _T("wxStaticText")) | (resType == _T("wxMessage")))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseStaticText(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxChoice"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseChoice(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxGauge"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseGauge(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxSlider"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseSlider(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxComboBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseComboBox(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxRadioButton"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseRadioButton(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxStaticBitmap"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseStaticBitmap(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxScrollBar"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseScrollBar(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if ((resType == _T("wxStaticBox")) | (resType == _T("wxGroupBox")))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseStaticBox(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
else if (resType == _T("wxBitmapButton"))
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseBitmapButton(res);
|
|
|
|
else
|
2003-12-11 06:27:56 -05:00
|
|
|
wxLogError(_T("Found unsupported resource ") + resType);
|
|
|
|
node = node->GetNext();
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
// Write out basic stuff every control has
|
2000-09-17 15:17:13 -04:00
|
|
|
// name,position,size,bg,fg
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::WriteControlInfo(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Write(GenerateName(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T(">\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Write(GetPosition(res));
|
|
|
|
m_xmlfile.Write(GetSize(res));
|
|
|
|
m_xmlfile.Write(GetStyles(res));
|
|
|
|
WriteFontInfo(res);
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetSize(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
|
|
|
if (m_dlgunits)
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<size>") << res->GetWidth() << _T(",") << res->GetHeight() << _T("d</size>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
else
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<size>") << res->GetWidth() << _T(",") << res->GetHeight() << _T("</size>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetPosition(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
|
|
|
if (m_dlgunits)
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<pos>") << res->GetX() << _T(",") << res->GetY() << _T("d</pos>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
else
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<pos>") << res->GetX() << _T(",") << res->GetY() << _T("</pos>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseButton(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxButton\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetLabel(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseTextCtrl(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxTextCtrl\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetValue4(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetTitle(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg = _T("\t\t\t\t<title>") + res->GetTitle() + _T("</title>");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetValue4(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg = _T("\t\t\t\t<value>") + res->GetValue4() + _T("</value>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseCheckBox(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxCheckBox\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetLabel(res));
|
|
|
|
m_xmlfile.Write(GetCheckStatus(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetLabel(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
return _T("\t\t\t\t<label>") + res->GetTitle() + _T("</label>\n");
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseRadioBox(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxRadioBox\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetLabel(res));
|
|
|
|
// Add radio box items
|
|
|
|
WriteStringList(res);
|
|
|
|
// Value1
|
|
|
|
m_xmlfile.Write(GetDimension(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseListBox(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxListBox\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
WriteStringList(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseStaticText(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxStaticText\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetLabel(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseStaticBox(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxStaticBox\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetLabel(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::WriteStringList(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<content>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
for (wxStringListNode * node = res->GetStringValues().GetFirst();
|
|
|
|
node;node = node->GetNext()) {
|
2000-09-17 15:17:13 -04:00
|
|
|
const wxString s1 = node->GetData();
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t\t<item>") + s1 + _T("</item>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t</content>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseChoice(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxChoice\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
// Add choice items
|
|
|
|
WriteStringList(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseGauge(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxGauge\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetValue1(res));
|
|
|
|
m_xmlfile.Write(GetRange(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\n\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetValue1(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<value>") << res->GetValue1() << _T("</value>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetRange(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<range>") << res->GetValue2() << _T("</range>");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseSlider(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxSlider\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetValue1(res));
|
|
|
|
m_xmlfile.Write(GetMax(res));
|
|
|
|
m_xmlfile.Write(GetMin(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\n\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetMax(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<max>") << res->GetValue3() << _T("</max>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetMin(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<min>") << res->GetValue2() << _T("</min>");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseComboBox(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxComboBox\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
// Add combo items
|
|
|
|
WriteStringList(res);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\n\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseRadioButton(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxRadioButton\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetLabel(res));
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
m_xmlfile.Write(GetValue1(res));
|
|
|
|
m_xmlfile.Write(GetCheckStatus(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseScrollBar(wxItemResource * res)
|
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxScrollBar\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
m_xmlfile.Write(GetValue1(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<thumbsize>")+GetValue2(res)+_T("</thumbsize>\n"));
|
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<range>")+GetValue3(res)+_T("</range>\n"));
|
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<pagesize>")+GetValue5(res)+_T("</pagesize>\n"));
|
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetCheckStatus(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<checked>") << res->GetValue1() << _T("</checked>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetStyles(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
// Very crude way to get styles
|
|
|
|
long style;
|
|
|
|
wxString s, restype;
|
|
|
|
restype = res->GetType();
|
|
|
|
style = res->GetStyle();
|
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
s = _T("\t\t\t\t<style>");
|
2000-09-26 17:59:37 -04:00
|
|
|
|
|
|
|
// Common styles for all controls
|
|
|
|
if (style & wxSIMPLE_BORDER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSIMPLE_BORDER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxSUNKEN_BORDER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSUNKEN_BORDER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxSIMPLE_BORDER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSIMPLE_BORDER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxDOUBLE_BORDER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxDOUBLE_BORDER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxRAISED_BORDER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRAISED_BORDER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTRANSPARENT_WINDOW)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTRANSPARENT_WINDOW|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxWANTS_CHARS)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxWANTS_CHARS|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxNO_FULL_REPAINT_ON_RESIZE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxNO_FULL_REPAINT_ON_RESIZE|");
|
2000-09-26 17:59:37 -04:00
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxDialog"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxDIALOG_MODAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxDIALOG_MODAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxDEFAULT_DIALOG_STYLE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxDEFAULT_DIALOG_STYLE|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxDIALOG_MODELESS)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxDIALOG_MODELESS|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxNO_3D)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxNO_3D|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTAB_TRAVERSAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTAB_TRAVERSAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxWS_EX_VALIDATE_RECURSIVELY)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxWS_EX_VALIDATE_RECURSIVELY|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxSTAY_ON_TOP)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSTAY_ON_TOP|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxCAPTION)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCAPTION|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTHICK_FRAME)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTHICK_FRAME|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxRESIZE_BOX)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRESIZE_BOX|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxRESIZE_BORDER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRESIZE_BORDER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxSYSTEM_MENU)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSYSTEM_MENU|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxCLIP_CHILDREN)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCLIP_CHILDREN|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxPanel"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxCLIP_CHILDREN)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCLIP_CHILDREN|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxNO_3D)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxNO_3D|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTAB_TRAVERSAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTAB_TRAVERSAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxWS_EX_VALIDATE_RECURSIVELY)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxWS_EX_VALIDATE_RECURSIVELY|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxComboBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxCB_SORT)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCB_SORT|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxCB_SIMPLE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCB_SIMPLE|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxCB_READONLY)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCB_READONLY|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxCB_DROPDOWN)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxCB_DROPDOWN|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxGauge"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxGA_HORIZONTAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxGA_HORIZONTAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxGA_VERTICAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxGA_VERTICAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxGA_PROGRESSBAR)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxGA_PROGRESSBAR|");
|
2000-09-26 17:59:37 -04:00
|
|
|
// windows only
|
|
|
|
if (style & wxGA_SMOOTH)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxGA_SMOOTH|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxRadioButton"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxRB_GROUP)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRB_GROUP|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxStaticText"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxST_NO_AUTORESIZE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxST_NO_AUTORESIZEL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxRadioBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxRA_HORIZONTAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRA_HORIZONTAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxRA_SPECIFY_COLS)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRA_SPECIFY_COLS|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxRA_SPECIFY_ROWS)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRA_SPECIFY_ROWS|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxRA_VERTICAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxRA_VERTICAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxListBox"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxLB_SINGLE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_SINGLE|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxLB_MULTIPLE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_MULTIPLE|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxLB_EXTENDED)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_EXTENDED|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxLB_HSCROLL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_HSCROLL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxLB_ALWAYS_SB)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_ALWAYS_SB|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxLB_NEEDED_SB)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_NEEDED_SB|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxLB_SORT)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxLB_SORT|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
if (restype == _T("wxTextCtrl"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxTE_PROCESS_ENTER)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTE_PROCESS_ENTER|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTE_PROCESS_TAB)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTE_PROCESS_TAB|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTE_MULTILINE)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTE_MULTILINE|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTE_PASSWORD)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTE_PASSWORD|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxTE_READONLY)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxTE_READONLY|");
|
2000-09-26 17:59:37 -04:00
|
|
|
if (style & wxHSCROLL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxHSCROLL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
if (restype == _T("wxScrollBar"))
|
2000-09-26 17:59:37 -04:00
|
|
|
{
|
|
|
|
if (style & wxSB_HORIZONTAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSB_HORIZONTAL|");
|
2004-06-11 09:14:23 -04:00
|
|
|
if (style & wxSB_VERTICAL)
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("wxSB_VERTICAL|");
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int l;
|
|
|
|
l = s.Length();
|
|
|
|
// No styles defined
|
|
|
|
if (l == 11)
|
|
|
|
return _T("");
|
|
|
|
// Trim off last |
|
|
|
|
s = s.Truncate(l - 1);
|
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
s += _T("</style>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return s;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetDimension(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
2003-12-11 06:27:56 -05:00
|
|
|
msg << _T("\t\t\t\t<dimension>") << res->GetValue1() << _T("</dimension>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
return msg;
|
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GenerateName(wxItemResource * res)
|
|
|
|
{
|
|
|
|
wxString name;
|
|
|
|
name = _T(" name=\"");
|
|
|
|
switch (res->GetId()) {
|
|
|
|
case wxID_OK:
|
|
|
|
name += _T("wxID_OK");
|
|
|
|
break;
|
|
|
|
case wxID_CANCEL:
|
|
|
|
name += _T("wxID_CANCEL");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
name += res->GetName();
|
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
name += _T("\"");
|
2000-09-26 17:59:37 -04:00
|
|
|
return name;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseMenuBar(wxItemResource * res)
|
|
|
|
{
|
|
|
|
wxItemResource *child;
|
2003-12-11 06:27:56 -05:00
|
|
|
wxNode *node = res->GetChildren().GetFirst();
|
2000-09-26 17:59:37 -04:00
|
|
|
// Get Menu Bar Name
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t<object class=\"wxMenuBar\" "));
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Write(GenerateName(res));
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T(">\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
while (node) {
|
2003-12-11 06:27:56 -05:00
|
|
|
child = (wxItemResource *) node->GetData();
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseMenu(child);
|
2003-12-11 06:27:56 -05:00
|
|
|
node = node->GetNext();
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t</object> \n\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxr2xml::ParseMenu(wxItemResource * res)
|
|
|
|
{
|
|
|
|
wxItemResource *child;
|
2003-12-11 06:27:56 -05:00
|
|
|
wxNode *node = res->GetChildren().GetFirst();
|
2004-06-11 09:14:23 -04:00
|
|
|
// Get Menu
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxMenu\" "));
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString menuname;
|
2003-12-11 06:27:56 -05:00
|
|
|
menuname << _T("name = \"menu_") << res->GetValue1() << _T("\"");
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Write(menuname);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T(">\n"));
|
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<label>")
|
|
|
|
+ FixMenuString(res->GetTitle()) + _T("</label>\n"));
|
|
|
|
if (res->GetValue4() != _T(""))
|
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<help>") + res->GetValue4() +
|
|
|
|
_T("</help>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
// Read in menu items and additional menus
|
|
|
|
while (node) {
|
2003-12-11 06:27:56 -05:00
|
|
|
child = (wxItemResource *) node->GetData();
|
|
|
|
if (!child->GetChildren().GetFirst())
|
2000-09-26 17:59:37 -04:00
|
|
|
ParseMenuItem(child);
|
|
|
|
else
|
|
|
|
ParseMenu(child);
|
2003-12-11 06:27:56 -05:00
|
|
|
node = node->GetNext();
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object> \n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxr2xml::ParseMenuItem(wxItemResource * res)
|
|
|
|
{
|
|
|
|
// Get Menu Item or Separator
|
2003-12-11 06:27:56 -05:00
|
|
|
if (res->GetTitle() == _T("")) {
|
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"separator\"/>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
} else {
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<object class=\"wxMenuItem\" "));
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString menuname;
|
2003-12-11 06:27:56 -05:00
|
|
|
menuname << _T("name = \"menuitem_") << res->GetValue1() << _T("\"");
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Write(menuname);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T(">\n"));
|
2004-06-11 09:14:23 -04:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<label>")
|
2003-12-11 06:27:56 -05:00
|
|
|
+ FixMenuString(res->GetTitle()) + _T("</label>\n"));
|
|
|
|
if (res->GetValue4() != _T(""))
|
2004-06-11 09:14:23 -04:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<help>") +
|
2003-12-11 06:27:56 -05:00
|
|
|
res->GetValue4() + _T("</help>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
if (res->GetValue2())
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
|
|
|
|
m_xmlfile.Write(_T("\t\t\t</object> \n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString wxr2xml::FixMenuString(wxString phrase)
|
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
phrase.Replace(_T("&"), _T("$"));
|
2000-09-26 17:59:37 -04:00
|
|
|
return phrase;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxr2xml::ParseStaticBitmap(wxItemResource * res)
|
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxStaticBitmap\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
// value4 holds bitmap name
|
|
|
|
wxString bitmapname;
|
|
|
|
bitmapname = res->GetValue4();
|
|
|
|
wxBitmap bitmap;
|
|
|
|
bitmap = wxResourceCreateBitmap(bitmapname, &m_table);
|
|
|
|
bitmapname += _T(".bmp");
|
|
|
|
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\n\t\t\t\t<bitmap>") + bitmapname + _T("</bitmap>"));
|
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
// bitmap5
|
|
|
|
}
|
|
|
|
//Parse a bitmap resource
|
|
|
|
void wxr2xml::ParseBitmap(wxItemResource * res)
|
|
|
|
{
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t<object class=\"wxBitmap\" "));
|
|
|
|
m_xmlfile.Write(GenerateName(res)+_T(">"));
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString bitmapname;
|
|
|
|
bitmapname = res->GetName();
|
|
|
|
wxBitmap bitmap;
|
|
|
|
bitmap = wxResourceCreateBitmap(bitmapname, &m_table);
|
|
|
|
bitmapname += _T(".bmp");
|
|
|
|
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
|
|
|
|
m_xmlfile.Write(bitmapname);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("</object>\n\n"));
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::PanelStuff(wxItemResource * res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
if ((res->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0)
|
2004-06-11 09:14:23 -04:00
|
|
|
m_dlgunits = true;
|
2000-09-26 17:59:37 -04:00
|
|
|
else
|
2004-06-11 09:14:23 -04:00
|
|
|
m_dlgunits = false;
|
2000-09-26 17:59:37 -04:00
|
|
|
|
|
|
|
// If this is true ignore fonts, background color and use system
|
|
|
|
// defaults instead
|
|
|
|
if ((res->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS) != 0)
|
2004-06-11 09:14:23 -04:00
|
|
|
m_systemdefaults = true;
|
2000-09-26 17:59:37 -04:00
|
|
|
else
|
2004-06-11 09:14:23 -04:00
|
|
|
m_systemdefaults = false;
|
2000-09-26 17:59:37 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString wxr2xml::GetValue2(wxItemResource *res)
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg << res->GetValue2();
|
|
|
|
return msg;
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetValue3(wxItemResource *res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
|
|
|
msg << res->GetValue3();
|
|
|
|
return msg;
|
|
|
|
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString wxr2xml::GetValue5(wxItemResource *res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2000-09-26 17:59:37 -04:00
|
|
|
wxString msg;
|
|
|
|
msg << res->GetValue5();
|
|
|
|
return msg;
|
|
|
|
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::ParseBitmapButton(wxItemResource *res)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
|
2000-09-26 17:59:37 -04:00
|
|
|
WriteControlInfo(res);
|
|
|
|
// value4 holds bitmap name
|
|
|
|
wxString bitmapname;
|
|
|
|
bitmapname = res->GetValue4();
|
|
|
|
wxBitmap bitmap;
|
|
|
|
bitmap = wxResourceCreateBitmap(bitmapname, &m_table);
|
|
|
|
bitmapname += _T(".bmp");
|
|
|
|
bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP);
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<bitmap>") + bitmapname + _T("</bitmap>\n"));
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</object>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxr2xml::WriteFontInfo(wxItemResource *res)
|
|
|
|
{
|
|
|
|
//if systems_defaults true just ignore the fonts
|
|
|
|
if (m_systemdefaults)
|
|
|
|
return;
|
|
|
|
wxFont font;
|
|
|
|
font=res->GetFont();
|
|
|
|
if (!font.GetRefData())
|
|
|
|
return;
|
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t<font>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
//Get font point size,font family,weight,font style,underline
|
|
|
|
int pt;
|
|
|
|
wxString msg;
|
|
|
|
pt=font.GetPointSize();
|
2003-12-11 06:27:56 -05:00
|
|
|
msg<<_T("\t\t\t\t<size>")<<pt<<_T("</size>\n");
|
2000-09-26 17:59:37 -04:00
|
|
|
m_xmlfile.Write(msg);
|
|
|
|
GetFontFace(font);
|
|
|
|
GetFontStyle(font);
|
|
|
|
GetFontWeight(font);
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
if (font.GetUnderlined())
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t</font>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
//WARNING possible make here
|
|
|
|
//I wasn't really sure the right way to do this.
|
|
|
|
void wxr2xml::GetFontFace(wxFont font)
|
|
|
|
{
|
|
|
|
int family=font.GetFamily();
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
switch (family)
|
|
|
|
{
|
|
|
|
case wxDEFAULT:
|
|
|
|
break;
|
|
|
|
case wxDECORATIVE:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<face>decorative</face>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
case wxROMAN:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<face>roman</face>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
case wxSCRIPT:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<face>script</face>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
case wxSWISS:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<face>swiss</face>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
case wxMODERN:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<face>modern</face>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
default:
|
2003-12-11 06:27:56 -05:00
|
|
|
wxLogError(_T("Unknown font face"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
void wxr2xml::GetFontStyle(wxFont font)
|
2000-09-17 15:17:13 -04:00
|
|
|
{
|
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
int style=font.GetStyle();
|
|
|
|
|
|
|
|
switch (style)
|
|
|
|
{
|
|
|
|
//since this is default no point in making file any larger
|
|
|
|
case wxNORMAL:
|
|
|
|
break;
|
|
|
|
case wxITALIC:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("<style>italic</style>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
case wxSLANT:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("<style>slant</style>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
default:
|
2003-12-11 06:27:56 -05:00
|
|
|
wxLogError(_T("Unknown font style"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxr2xml::GetFontWeight(wxFont font)
|
|
|
|
{
|
|
|
|
int weight=font.GetWeight();
|
2000-09-17 15:17:13 -04:00
|
|
|
|
2000-09-26 17:59:37 -04:00
|
|
|
switch (weight)
|
|
|
|
{
|
|
|
|
//since this is default no point in making file any larger
|
|
|
|
case wxNORMAL:
|
|
|
|
break;
|
|
|
|
case wxLIGHT:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<weight>light</weight>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
case wxBOLD:
|
2003-12-11 06:27:56 -05:00
|
|
|
m_xmlfile.Write(_T("\t\t\t\t<weight>bold</weight>\n"));
|
2000-09-26 17:59:37 -04:00
|
|
|
break;
|
|
|
|
default:
|
2003-12-11 06:27:56 -05:00
|
|
|
wxLogError(_T("Unknown font weight"));
|
2000-09-26 17:59:37 -04:00
|
|
|
}
|
2000-09-17 15:17:13 -04:00
|
|
|
}
|