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