X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88d42654d76be0098f6a1fa12b83af97f5b6235a..a8522481f71a43df96d6322890e9f539c7737993:/contrib/utils/convertrc/wxr2xml.cpp?ds=sidebyside
diff --git a/contrib/utils/convertrc/wxr2xml.cpp b/contrib/utils/convertrc/wxr2xml.cpp
index a6e9d0d973..f2e331ec5c 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,805 @@
#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(), "w+t");
+ wxASSERT_MSG(result, "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, "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");
-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();
+ wxNode *node;
+
+ while ((node = m_table.Next()))
+ {
+ wxItemResource *res = (wxItemResource *) node->Data();
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 == "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);
}
-
-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\n\n");
}
-void wxWxr2Xml::ParseControls(wxItemResource *res)
+void wxr2xml::ParseControls(wxItemResource * res)
{
-wxNode *node = res->GetChildren().First();
-while (node)
+ wxNode *node = res->GetChildren().First();
+ 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->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();
}
}
-//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(">\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" << res->GetWidth() << "," << res->GetHeight() << "d\n";
+ else
+ msg << "\t\t\t\t" << res->GetWidth() << "," << res->GetHeight() << "\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" << res->GetX() << "," << res->GetY() << "d\n";
+ else
+ msg << "\t\t\t\t" << res->GetX() << "," << res->GetY() << "\n";
+ return msg;
}
-void wxWxr2Xml::ParseButton(wxItemResource *res)
+void wxr2xml::ParseButton(wxItemResource * res)
{
-m_xmlfile.Write("