X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e066e2566a4e5db3510fe6a204d66850eaeceade..dcb39c53303d1ec6884f7bcd7bc9dc101e560e62:/contrib/utils/convertrc/wxr2xml.cpp diff --git a/contrib/utils/convertrc/wxr2xml.cpp b/contrib/utils/convertrc/wxr2xml.cpp index f2e331ec5c..1141d30248 100644 --- a/contrib/utils/convertrc/wxr2xml.cpp +++ b/contrib/utils/convertrc/wxr2xml.cpp @@ -45,20 +45,20 @@ wxr2xml::~wxr2xml() 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"); + result = m_xmlfile.Open(xmlfile.c_str(), _T("w+t")); + wxASSERT_MSG(result, _T("Couldn't create XML file")); if (!result) - return FALSE; + return false; result = m_table.ParseResourceFile(wxrfile); - wxASSERT_MSG(result, "Couldn't Load WXR file"); + wxASSERT_MSG(result, _T("Couldn't Load WXR file")); if (!result) - return FALSE; + return false; // Write basic xml header - m_xmlfile.Write("\n"); - m_xmlfile.Write("\n"); + m_xmlfile.Write(_T("\n")); + m_xmlfile.Write(_T("\n")); result = ParseResources(); - m_xmlfile.Write("\n"); + m_xmlfile.Write(_T("\n")); m_xmlfile.Close(); @@ -68,91 +68,93 @@ bool wxr2xml::Convert(wxString wxrfile, wxString xmlfile) bool wxr2xml::ParseResources() { m_table.BeginFind(); - wxNode *node; + wxHashTable::Node *node; - while ((node = m_table.Next())) + node = m_table.Next(); + while (node) { - wxItemResource *res = (wxItemResource *) node->Data(); + wxItemResource *res = (wxItemResource *) node->GetData(); wxString resType(res->GetType()); - if (resType == "wxDialog") + if (resType == _T("wxDialog")) ParseDialog(res); - else if (resType == "wxPanel") + else if (resType == _T("wxPanel")) ParsePanel(res); - else if (resType == "wxPanel") + else if (resType == _T("wxPanel")) ParsePanel(res); - else if (resType == "wxMenu") + else if (resType == _T("wxMenu")) ParseMenuBar(res); - else if (resType == "wxBitmap") + else if (resType == _T("wxBitmap")) ParseBitmap(res); else - wxLogError("Found unsupported resource " + resType); + wxLogError(_T("Found unsupported resource ") + resType); + node = m_table.Next(); } - return TRUE; + return true; } void wxr2xml::ParsePanel(wxItemResource * res) { - m_xmlfile.Write("\t\n\n"); + m_xmlfile.Write(_T("\t\n\n")); } void wxr2xml::ParseDialog(wxItemResource * res) { PanelStuff(res); - m_xmlfile.Write("\t\n\n"); + m_xmlfile.Write(_T("\t\n\n")); } void wxr2xml::ParseControls(wxItemResource * res) { - wxNode *node = res->GetChildren().First(); - while (node) + wxNode *node = res->GetChildren().GetFirst(); + while (node) { - wxItemResource *res = (wxItemResource *) node->Data(); + wxItemResource *res = (wxItemResource *) node->GetData(); wxString resType(res->GetType()); - if (resType == "wxButton") + if (resType == _T("wxButton")) ParseButton(res); - else if ((resType == "wxTextCtrl") | (resType == "wxText") - | (resType == "wxMultiText")) + else if ((resType == _T("wxTextCtrl")) | (resType == _T("wxText")) + | (resType == _T("wxMultiText"))) ParseTextCtrl(res); - else if (resType == "wxCheckBox") + else if (resType == _T("wxCheckBox")) ParseCheckBox(res); - else if (resType == "wxRadioBox") + else if (resType == _T("wxRadioBox")) ParseRadioBox(res); - else if (resType == "wxListBox") + else if (resType == _T("wxListBox")) ParseListBox(res); - else if ((resType == "wxStaticText") | (resType == "wxMessage")) + else if ((resType == _T("wxStaticText")) | (resType == _T("wxMessage"))) ParseStaticText(res); - else if (resType == "wxChoice") + else if (resType == _T("wxChoice")) ParseChoice(res); - else if (resType == "wxGauge") + else if (resType == _T("wxGauge")) ParseGauge(res); - else if (resType == "wxSlider") + else if (resType == _T("wxSlider")) ParseSlider(res); - else if (resType == "wxComboBox") + else if (resType == _T("wxComboBox")) ParseComboBox(res); - else if (resType == "wxRadioButton") + else if (resType == _T("wxRadioButton")) ParseRadioButton(res); - else if (resType == "wxStaticBitmap") + else if (resType == _T("wxStaticBitmap")) ParseStaticBitmap(res); - else if (resType == "wxScrollBar") + else if (resType == _T("wxScrollBar")) ParseScrollBar(res); - else if ((resType == "wxStaticBox") | (resType == "wxGroupBox")) + else if ((resType == _T("wxStaticBox")) | (resType == _T("wxGroupBox"))) ParseStaticBox(res); - else if (resType == "wxBitmapButton") + else if (resType == _T("wxBitmapButton")) ParseBitmapButton(res); else - wxLogError("Found unsupported resource " + resType); - node = node->Next(); + wxLogError(_T("Found unsupported resource ") + resType); + node = node->GetNext(); } } @@ -161,7 +163,7 @@ void wxr2xml::ParseControls(wxItemResource * res) void wxr2xml::WriteControlInfo(wxItemResource * res) { m_xmlfile.Write(GenerateName(res)); - m_xmlfile.Write(">\n"); + m_xmlfile.Write(_T(">\n")); m_xmlfile.Write(GetPosition(res)); m_xmlfile.Write(GetSize(res)); m_xmlfile.Write(GetStyles(res)); @@ -172,9 +174,9 @@ wxString wxr2xml::GetSize(wxItemResource * res) { wxString msg; if (m_dlgunits) - msg << "\t\t\t\t" << res->GetWidth() << "," << res->GetHeight() << "d\n"; + msg << _T("\t\t\t\t") << res->GetWidth() << _T(",") << res->GetHeight() << _T("d\n"); else - msg << "\t\t\t\t" << res->GetWidth() << "," << res->GetHeight() << "\n"; + msg << _T("\t\t\t\t") << res->GetWidth() << _T(",") << res->GetHeight() << _T("\n"); return msg; } @@ -182,196 +184,196 @@ wxString wxr2xml::GetPosition(wxItemResource * res) { wxString msg; if (m_dlgunits) - msg << "\t\t\t\t" << res->GetX() << "," << res->GetY() << "d\n"; + msg << _T("\t\t\t\t") << res->GetX() << _T(",") << res->GetY() << _T("d\n"); else - msg << "\t\t\t\t" << res->GetX() << "," << res->GetY() << "\n"; + msg << _T("\t\t\t\t") << res->GetX() << _T(",") << res->GetY() << _T("\n"); return msg; } void wxr2xml::ParseButton(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::ParseTextCtrl(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } wxString wxr2xml::GetTitle(wxItemResource * res) { wxString msg; - msg = _T("\t\t\t\t" + res->GetTitle() + ""); + msg = _T("\t\t\t\t") + res->GetTitle() + _T(""); return msg; } wxString wxr2xml::GetValue4(wxItemResource * res) { wxString msg; - msg = _T("\t\t\t\t" + res->GetValue4() + "\n"); + msg = _T("\t\t\t\t") + res->GetValue4() + _T("\n"); return msg; } void wxr2xml::ParseCheckBox(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } wxString wxr2xml::GetLabel(wxItemResource * res) { - return _T("\t\t\t\t\n"); + return _T("\t\t\t\t\n"); } void wxr2xml::ParseRadioBox(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::ParseListBox(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::ParseStaticText(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::ParseStaticBox(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::WriteStringList(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\t\n")); for (wxStringListNode * node = res->GetStringValues().GetFirst(); node;node = node->GetNext()) { const wxString s1 = node->GetData(); - m_xmlfile.Write("\t\t\t\t\t" + s1 + "\n"); + m_xmlfile.Write(_T("\t\t\t\t\t") + s1 + _T("\n")); } - m_xmlfile.Write("\t\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\t\n")); } void wxr2xml::ParseChoice(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::ParseGauge(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\n\t\t\t\n")); } wxString wxr2xml::GetValue1(wxItemResource * res) { wxString msg; - msg << "\t\t\t\t" << res->GetValue1() << "\n"; + msg << _T("\t\t\t\t") << res->GetValue1() << _T("\n"); return msg; } wxString wxr2xml::GetRange(wxItemResource * res) { wxString msg; - msg << "\t\t\t\t" << res->GetValue2() << ""; + msg << _T("\t\t\t\t") << res->GetValue2() << _T(""); return msg; } void wxr2xml::ParseSlider(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\n\t\t\t\n")); } wxString wxr2xml::GetMax(wxItemResource * res) { wxString msg; - msg << "\t\t\t\t" << res->GetValue3() << "\n"; + msg << _T("\t\t\t\t") << res->GetValue3() << _T("\n"); return msg; } wxString wxr2xml::GetMin(wxItemResource * res) { wxString msg; - msg << "\t\t\t\t" << res->GetValue2() << ""; + msg << _T("\t\t\t\t") << res->GetValue2() << _T(""); return msg; } void wxr2xml::ParseComboBox(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\n\t\t\t\n")); } void wxr2xml::ParseRadioButton(wxItemResource * res) { - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::ParseScrollBar(wxItemResource * res) { - m_xmlfile.Write("\t\t\t"+GetValue2(res)+"\n"); - m_xmlfile.Write("\t\t\t\t"+GetValue3(res)+"\n"); - m_xmlfile.Write("\t\t\t\t"+GetValue5(res)+"\n"); - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\t")+GetValue2(res)+_T("\n")); + m_xmlfile.Write(_T("\t\t\t\t")+GetValue3(res)+_T("\n")); + m_xmlfile.Write(_T("\t\t\t\t")+GetValue5(res)+_T("\n")); + m_xmlfile.Write(_T("\t\t\t\n")); } wxString wxr2xml::GetCheckStatus(wxItemResource * res) { wxString msg; - msg << "\t\t\t\t" << res->GetValue1() << "\n"; + msg << _T("\t\t\t\t") << res->GetValue1() << _T("\n"); return msg; } @@ -383,158 +385,158 @@ wxString wxr2xml::GetStyles(wxItemResource * res) restype = res->GetType(); style = res->GetStyle(); - s = "\t\t\t\t\n"; + s += _T("\n"); return s; } wxString wxr2xml::GetDimension(wxItemResource * res) { wxString msg; - msg << "\t\t\t\t" << res->GetValue1() << "\n"; + msg << _T("\t\t\t\t") << res->GetValue1() << _T("\n"); return msg; } @@ -571,85 +573,85 @@ wxString wxr2xml::GenerateName(wxItemResource * res) name += res->GetName(); } - name += "\""; + name += _T("\""); return name; } void wxr2xml::ParseMenuBar(wxItemResource * res) { wxItemResource *child; - wxNode *node = res->GetChildren().First(); + wxNode *node = res->GetChildren().GetFirst(); // Get Menu Bar Name - m_xmlfile.Write("\t\n"); + m_xmlfile.Write(_T(">\n")); while (node) { - child = (wxItemResource *) node->Data(); + child = (wxItemResource *) node->GetData(); ParseMenu(child); - node = node->Next(); + node = node->GetNext(); } - m_xmlfile.Write("\t \n\n"); + m_xmlfile.Write(_T("\t \n\n")); } void wxr2xml::ParseMenu(wxItemResource * res) { wxItemResource *child; - wxNode *node = res->GetChildren().First(); - // Get Menu - m_xmlfile.Write("\t\t\tGetChildren().GetFirst(); + // Get Menu + m_xmlfile.Write(_T("\t\t\tGetValue1() << "\""; + menuname << _T("name = \"menu_") << res->GetValue1() << _T("\""); m_xmlfile.Write(menuname); - m_xmlfile.Write(">\n"); - m_xmlfile.Write("\t\t\t\t\n"); - if (res->GetValue4() != "") - m_xmlfile.Write("\t\t\t\t" + res->GetValue4() + - "\n"); + m_xmlfile.Write(_T(">\n")); + m_xmlfile.Write(_T("\t\t\t\t\n")); + if (res->GetValue4() != _T("")) + m_xmlfile.Write(_T("\t\t\t\t") + res->GetValue4() + + _T("\n")); // Read in menu items and additional menus while (node) { - child = (wxItemResource *) node->Data(); - if (!child->GetChildren().First()) + child = (wxItemResource *) node->GetData(); + if (!child->GetChildren().GetFirst()) ParseMenuItem(child); else ParseMenu(child); - node = node->Next(); + node = node->GetNext(); } - m_xmlfile.Write("\t\t\t \n"); + m_xmlfile.Write(_T("\t\t\t \n")); } void wxr2xml::ParseMenuItem(wxItemResource * res) { // Get Menu Item or Separator - if (res->GetTitle() == "") { - m_xmlfile.Write("\t\t\t\n"); + if (res->GetTitle() == _T("")) { + m_xmlfile.Write(_T("\t\t\t\n")); } else { - m_xmlfile.Write("\t\t\t\tGetValue1() << "\""; + menuname << _T("name = \"menuitem_") << res->GetValue1() << _T("\""); m_xmlfile.Write(menuname); - m_xmlfile.Write(">\n"); - m_xmlfile.Write(" \n"); - if (res->GetValue4() != "") - m_xmlfile.Write(" " + - res->GetValue4() + "\n"); + m_xmlfile.Write(_T(">\n")); + m_xmlfile.Write(_T("\t\t\t\n")); + if (res->GetValue4() != _T("")) + m_xmlfile.Write(_T("\t\t\t") + + res->GetValue4() + _T("\n")); if (res->GetValue2()) - m_xmlfile.Write("\t\t\t\t1\n"); - m_xmlfile.Write("\t\t\t \n"); + m_xmlfile.Write(_T("\t\t\t\t1\n")); + m_xmlfile.Write(_T("\t\t\t \n")); } } wxString wxr2xml::FixMenuString(wxString phrase) { - phrase.Replace("&", "$"); + phrase.Replace(_T("&"), _T("$")); return phrase; } void wxr2xml::ParseStaticBitmap(wxItemResource * res) { - m_xmlfile.Write("\t\t\t" + bitmapname + ""); - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\n\t\t\t\t") + bitmapname + _T("")); + m_xmlfile.Write(_T("\t\t\t\n")); // bitmap5 } //Parse a bitmap resource void wxr2xml::ParseBitmap(wxItemResource * res) { - m_xmlfile.Write("\t"); + m_xmlfile.Write(_T("\t")); wxString bitmapname; bitmapname = res->GetName(); wxBitmap bitmap; @@ -674,22 +676,22 @@ void wxr2xml::ParseBitmap(wxItemResource * res) bitmapname += _T(".bmp"); bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); m_xmlfile.Write(bitmapname); - m_xmlfile.Write("\n\n"); + m_xmlfile.Write(_T("\n\n")); } void wxr2xml::PanelStuff(wxItemResource * res) { if ((res->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS) != 0) - m_dlgunits = TRUE; + m_dlgunits = true; else - m_dlgunits = FALSE; + 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; + m_systemdefaults = true; else - m_systemdefaults = FALSE; + m_systemdefaults = false; } @@ -718,8 +720,8 @@ wxString wxr2xml::GetValue5(wxItemResource *res) void wxr2xml::ParseBitmapButton(wxItemResource *res) { - - m_xmlfile.Write("\t\t\t" + bitmapname + "\n"); - - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\t") + bitmapname + _T("\n")); + + m_xmlfile.Write(_T("\t\t\t\n")); } void wxr2xml::WriteFontInfo(wxItemResource *res) @@ -743,21 +745,21 @@ void wxr2xml::WriteFontInfo(wxItemResource *res) if (!font.GetRefData()) return; - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\n")); //Get font point size,font family,weight,font style,underline int pt; wxString msg; pt=font.GetPointSize(); - msg<<"\t\t\t\t"<\n"; + msg<<_T("\t\t\t\t")<\n"); m_xmlfile.Write(msg); GetFontFace(font); GetFontStyle(font); GetFontWeight(font); - + if (font.GetUnderlined()) - m_xmlfile.Write("\t\t\t\t1\n"); - - m_xmlfile.Write("\t\t\t\n"); + m_xmlfile.Write(_T("\t\t\t\t1\n")); + + m_xmlfile.Write(_T("\t\t\t\n")); } //WARNING possible make here @@ -765,28 +767,28 @@ void wxr2xml::WriteFontInfo(wxItemResource *res) void wxr2xml::GetFontFace(wxFont font) { int family=font.GetFamily(); - + switch (family) { case wxDEFAULT: break; case wxDECORATIVE: - m_xmlfile.Write("\t\t\t\tdecorative\n"); + m_xmlfile.Write(_T("\t\t\t\tdecorative\n")); break; case wxROMAN: - m_xmlfile.Write("\t\t\t\troman\n"); + m_xmlfile.Write(_T("\t\t\t\troman\n")); break; case wxSCRIPT: - m_xmlfile.Write("\t\t\t\tscript\n"); + m_xmlfile.Write(_T("\t\t\t\tscript\n")); break; case wxSWISS: - m_xmlfile.Write("\t\t\t\tswiss\n"); + m_xmlfile.Write(_T("\t\t\t\tswiss\n")); break; case wxMODERN: - m_xmlfile.Write("\t\t\t\tmodern\n"); + m_xmlfile.Write(_T("\t\t\t\tmodern\n")); break; default: - wxLogError("Unknown font face"); + wxLogError(_T("Unknown font face")); } } @@ -801,13 +803,13 @@ void wxr2xml::GetFontStyle(wxFont font) case wxNORMAL: break; case wxITALIC: - m_xmlfile.Write("\n"); + m_xmlfile.Write(_T("\n")); break; case wxSLANT: - m_xmlfile.Write("\n"); + m_xmlfile.Write(_T("\n")); break; default: - wxLogError("Unknown font style"); + wxLogError(_T("Unknown font style")); } } @@ -821,12 +823,12 @@ void wxr2xml::GetFontWeight(wxFont font) case wxNORMAL: break; case wxLIGHT: - m_xmlfile.Write("\t\t\t\tlight\n"); + m_xmlfile.Write(_T("\t\t\t\tlight\n")); break; case wxBOLD: - m_xmlfile.Write("\t\t\t\tbold\n"); + m_xmlfile.Write(_T("\t\t\t\tbold\n")); break; default: - wxLogError("Unknown font weight"); + wxLogError(_T("Unknown font weight")); } }