X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88d42654d76be0098f6a1fa12b83af97f5b6235a..dcb39c53303d1ec6884f7bcd7bc9dc101e560e62:/contrib/utils/convertrc/wxr2xml.cpp
diff --git a/contrib/utils/convertrc/wxr2xml.cpp b/contrib/utils/convertrc/wxr2xml.cpp
index a6e9d0d973..1141d30248 100644
--- a/contrib/utils/convertrc/wxr2xml.cpp
+++ b/contrib/utils/convertrc/wxr2xml.cpp
@@ -1,11 +1,15 @@
-// wxr2xml.cpp: implementation of the wxWxr2Xml class.
-// 8/30/00 Brian Gavin
+// wxr2xml.cpp: implementation of the wxr2xml class.
+// 8/30/00 Brian Gavin
// only tested on wxMSW so far
-//////////////////////////////////////////////////////////////////////
-/* TODO
- port to wxGTK should be very easy
- support fonts
- add unsupported controls when XML format adds them
+//License: wxWindows Liscense
+// ////////////////////////////////////////////////////////////////////
+
+/*
+How to use class:
+#include "wxr2xml.h"
+...
+wxr2xml trans;
+trans->Convert("Myfile.wxr","Myfile.xml");
*/
#ifdef __GNUG__
#pragma implementation "wxr2xml.h"
@@ -24,671 +28,807 @@
#include "wxr2xml.h"
-
-//////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////
// Construction/Destruction
-//////////////////////////////////////////////////////////////////////
+// ////////////////////////////////////////////////////////////////////
-wxWxr2Xml::wxWxr2Xml()
+wxr2xml::wxr2xml()
{
}
-wxWxr2Xml::~wxWxr2Xml()
+wxr2xml::~wxr2xml()
{
}
-bool wxWxr2Xml::Convert(wxString wxrfile, wxString xmlfile)
+bool wxr2xml::Convert(wxString wxrfile, wxString xmlfile)
{
-bool result;
-result=m_xmlfile.Open(xmlfile.c_str(),"w+t");
-wxASSERT_MSG(result,"Couldn't create XML file");
-if (!result)
- return FALSE;
+ bool result;
+ result = m_xmlfile.Open(xmlfile.c_str(), _T("w+t"));
+ wxASSERT_MSG(result, _T("Couldn't create XML file"));
+ if (!result)
+ return false;
-result=m_table.ParseResourceFile(wxrfile);
-wxASSERT_MSG(result,"Couldn't Load WXR file");
-if (!result)
- return FALSE;
-//Write basic xml header
-m_xmlfile.Write("\n");
-m_xmlfile.Write("\n");
-result=ParseResources();
-m_xmlfile.Write("\n");
+ result = m_table.ParseResourceFile(wxrfile);
+ wxASSERT_MSG(result, _T("Couldn't Load WXR file"));
+ if (!result)
+ return false;
+ // Write basic xml header
+ m_xmlfile.Write(_T("\n"));
+ m_xmlfile.Write(_T("\n"));
+ result = ParseResources();
+ m_xmlfile.Write(_T("\n"));
-m_xmlfile.Close();
+ m_xmlfile.Close();
-return result;
+ return result;
}
-bool wxWxr2Xml::ParseResources()
+bool wxr2xml::ParseResources()
{
-m_table.BeginFind();
-wxNode *node;
-
-while ((node = m_table.Next()))
- {
- wxItemResource *res = (wxItemResource *)node->Data();
+ m_table.BeginFind();
+ wxHashTable::Node *node;
+
+ node = m_table.Next();
+ while (node)
+ {
+ wxItemResource *res = (wxItemResource *) node->GetData();
wxString resType(res->GetType());
- 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);
+ if (resType == _T("wxDialog"))
+ ParseDialog(res);
+ else if (resType == _T("wxPanel"))
+ ParsePanel(res);
+ else if (resType == _T("wxPanel"))
+ ParsePanel(res);
+ else if (resType == _T("wxMenu"))
+ ParseMenuBar(res);
+ else if (resType == _T("wxBitmap"))
+ ParseBitmap(res);
+ else
+ wxLogError(_T("Found unsupported resource ") + resType);
+ node = m_table.Next();
}
-
-return TRUE;
+ return true;
}
-void wxWxr2Xml::ParsePanel(wxItemResource *res)
+void wxr2xml::ParsePanel(wxItemResource * res)
{
-
-m_xmlfile.Write(" \n");
-ParseControls(res);
-m_xmlfile.Write(" \n");
-
-m_xmlfile.Write(" \n");
+ m_xmlfile.Write(_T("\t\n\n"));
}
-void wxWxr2Xml::ParseControls(wxItemResource *res)
+void wxr2xml::ParseControls(wxItemResource * res)
{
-wxNode *node = res->GetChildren().First();
-while (node)
+ wxNode *node = res->GetChildren().GetFirst();
+ while (node)
{
- 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")
- wxLogError("wxScrollBar unsupported");
- else if ((resType=="wxStaticBox")|(resType=="wxGroupBox"))
- wxLogError("wxStaticBox unsupported");
- else if (resType=="wxBitmapButton")
- wxLogError("wxBitmapButton unsupported");
- else
- wxLogError("Found unsupported resource "+resType);
- node = node->Next();
+ wxItemResource *res = (wxItemResource *) node->GetData();
+ wxString resType(res->GetType());
+ if (resType == _T("wxButton"))
+ ParseButton(res);
+ else if ((resType == _T("wxTextCtrl")) | (resType == _T("wxText"))
+ | (resType == _T("wxMultiText")))
+ ParseTextCtrl(res);
+ else if (resType == _T("wxCheckBox"))
+ ParseCheckBox(res);
+ else if (resType == _T("wxRadioBox"))
+ ParseRadioBox(res);
+ else if (resType == _T("wxListBox"))
+ ParseListBox(res);
+ else if ((resType == _T("wxStaticText")) | (resType == _T("wxMessage")))
+ ParseStaticText(res);
+ else if (resType == _T("wxChoice"))
+ ParseChoice(res);
+ else if (resType == _T("wxGauge"))
+ ParseGauge(res);
+ else if (resType == _T("wxSlider"))
+ ParseSlider(res);
+ else if (resType == _T("wxComboBox"))
+ ParseComboBox(res);
+ else if (resType == _T("wxRadioButton"))
+ ParseRadioButton(res);
+ else if (resType == _T("wxStaticBitmap"))
+ ParseStaticBitmap(res);
+ else if (resType == _T("wxScrollBar"))
+ ParseScrollBar(res);
+ else if ((resType == _T("wxStaticBox")) | (resType == _T("wxGroupBox")))
+ ParseStaticBox(res);
+ else if (resType == _T("wxBitmapButton"))
+ ParseBitmapButton(res);
+ else
+ wxLogError(_T("Found unsupported resource ") + resType);
+ node = node->GetNext();
}
}
-//Write out basic stuff every control has
+// Write out basic stuff every control has
// name,position,size,bg,fg
-void wxWxr2Xml::WriteControlInfo(wxItemResource *res)
+void wxr2xml::WriteControlInfo(wxItemResource * res)
{
-m_xmlfile.Write(GenerateName(res));
-m_xmlfile.Write(">\n");
-m_xmlfile.Write(GetPosition(res));
-m_xmlfile.Write(GetSize(res));
-m_xmlfile.Write(GetStyles(res));
+ m_xmlfile.Write(GenerateName(res));
+ m_xmlfile.Write(_T(">\n"));
+ m_xmlfile.Write(GetPosition(res));
+ m_xmlfile.Write(GetSize(res));
+ m_xmlfile.Write(GetStyles(res));
+ WriteFontInfo(res);
}
-wxString wxWxr2Xml::GetSize(wxItemResource *res)
+wxString wxr2xml::GetSize(wxItemResource * res)
{
-wxString msg;
-if (m_dlgunits)
- msg<<" "<GetWidth()<<","<GetHeight()<<"d";
-else
- msg<<" "<GetWidth()<<","<GetHeight()<<"";
-return msg;
+ wxString msg;
+ if (m_dlgunits)
+ msg << _T("\t\t\t\t") << res->GetWidth() << _T(",") << res->GetHeight() << _T("d\n");
+ else
+ msg << _T("\t\t\t\t") << res->GetWidth() << _T(",") << res->GetHeight() << _T("\n");
+ return msg;
}
-wxString wxWxr2Xml::GetPosition(wxItemResource *res)
+wxString wxr2xml::GetPosition(wxItemResource * res)
{
-wxString msg;
-if (m_dlgunits)
- msg<<" "<GetX()<<","<GetY()<<"d";
-else
- msg<<" "<GetX()<<","<GetY()<<"";
-return msg;
+ wxString msg;
+ if (m_dlgunits)
+ msg << _T("\t\t\t\t") << res->GetX() << _T(",") << res->GetY() << _T("d\n");
+ else
+ msg << _T("\t\t\t\t") << res->GetX() << _T(",") << res->GetY() << _T("\n");
+ return msg;
}
-void wxWxr2Xml::ParseButton(wxItemResource *res)
+void wxr2xml::ParseButton(wxItemResource * res)
{
-m_xmlfile.Write("