X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88d42654d76be0098f6a1fa12b83af97f5b6235a..f538710f0b798b21365fd614ba531055b225b115:/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::ParseDialog(wxItemResource *res) +void wxr2xml::ParseDialog(wxItemResource * res) { -PanelStuff(res); -m_xmlfile.Write(" \n"); -ParseControls(res); -m_xmlfile.Write(" \n"); -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\n"); + ParseControls(res); + 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(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::ParseTextCtrl(wxItemResource *res) +void wxr2xml::ParseTextCtrl(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -wxString wxWxr2Xml::GetTitle(wxItemResource *res) +wxString wxr2xml::GetTitle(wxItemResource * res) { -wxString msg; -msg=_T(" "+res->GetTitle()+""); -return msg; + wxString msg; + msg = _T("\t\t\t\t" + res->GetTitle() + ""); + return msg; } -wxString wxWxr2Xml::GetValue4(wxItemResource *res) +wxString wxr2xml::GetValue4(wxItemResource * res) { -wxString msg; -msg=_T(" "+res->GetValue4()+""); -return msg; + wxString msg; + msg = _T("\t\t\t\t" + res->GetValue4() + "\n"); + return msg; } -void wxWxr2Xml::ParseCheckBox(wxItemResource *res) +void wxr2xml::ParseCheckBox(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -wxString wxWxr2Xml::GetLabel(wxItemResource *res) +wxString wxr2xml::GetLabel(wxItemResource * res) { -return _T(" "); + return _T("\t\t\t\t\n"); } -void wxWxr2Xml::ParseRadioBox(wxItemResource *res) +void wxr2xml::ParseRadioBox(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::ParseListBox(wxItemResource *res) +void wxr2xml::ParseListBox(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::ParseStaticText(wxItemResource *res) +void wxr2xml::ParseStaticText(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::ParseStaticBox(wxItemResource *res) +void wxr2xml::ParseStaticBox(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::WriteStringList(wxItemResource *res) +void wxr2xml::WriteStringList(wxItemResource * res) { -m_xmlfile.Write("\n "); -for ( wxStringListNode *node = res->GetStringValues().GetFirst(); node; - node = node->GetNext() ) - { + m_xmlfile.Write("\t\t\t\t\n"); + for (wxStringListNode * node = res->GetStringValues().GetFirst(); + node;node = node->GetNext()) { const wxString s1 = node->GetData(); - m_xmlfile.Write("\n "+s1+""); + m_xmlfile.Write("\t\t\t\t\t" + s1 + "\n"); } - m_xmlfile.Write("\n "); + m_xmlfile.Write("\t\t\t\t\n"); } -void wxWxr2Xml::ParseChoice(wxItemResource *res) +void wxr2xml::ParseChoice(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::ParseGauge(wxItemResource *res) +void wxr2xml::ParseGauge(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } - -wxString wxWxr2Xml::GetValue1(wxItemResource *res) +wxString wxr2xml::GetValue1(wxItemResource * res) { -wxString msg; -msg<<" "<GetValue1()<<""; -return msg; + wxString msg; + msg << "\t\t\t\t" << res->GetValue1() << "\n"; + return msg; } -wxString wxWxr2Xml::GetRange(wxItemResource *res) +wxString wxr2xml::GetRange(wxItemResource * res) { -wxString msg; -msg<<" "<GetValue2()<<""; -return msg; + wxString msg; + msg << "\t\t\t\t" << res->GetValue2() << ""; + return msg; } -void wxWxr2Xml::ParseSlider(wxItemResource *res) +void wxr2xml::ParseSlider(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -wxString wxWxr2Xml::GetMax(wxItemResource *res) +wxString wxr2xml::GetMax(wxItemResource * res) { -wxString msg; -msg<<" "<GetValue3()<<""; -return msg; + wxString msg; + msg << "\t\t\t\t" << res->GetValue3() << "\n"; + return msg; } -wxString wxWxr2Xml::GetMin(wxItemResource *res) +wxString wxr2xml::GetMin(wxItemResource * res) { -wxString msg; -msg<<" "<GetValue2()<<""; -return msg; + wxString msg; + msg << "\t\t\t\t" << res->GetValue2() << ""; + return msg; } -void wxWxr2Xml::ParseComboBox(wxItemResource *res) +void wxr2xml::ParseComboBox(wxItemResource * res) { -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t\t\t\n"); } -void wxWxr2Xml::ParseRadioButton(wxItemResource *res) +void wxr2xml::ParseRadioButton(wxItemResource * res) { -m_xmlfile.Write(" \n"); +} -wxString msg; -m_xmlfile.Write(GetValue1(res)); -m_xmlfile.Write(GetCheckStatus(res)); -m_xmlfile.Write("\n \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"); } -void wxWxr2Xml::ParseScrollBar(wxItemResource *res) +wxString wxr2xml::GetCheckStatus(wxItemResource * res) { -m_xmlfile.Write(" \n"); -} + wxString msg; + msg << "\t\t\t\t" << res->GetValue1() << "\n"; + return msg; +} -wxString wxWxr2Xml::GetCheckStatus(wxItemResource *res) +wxString wxr2xml::GetStyles(wxItemResource * res) { -wxString msg; -msg<<" "<GetValue1()<<""; -return msg; + // Very crude way to get styles + long style; + wxString s, restype; + restype = res->GetType(); + style = res->GetStyle(); + + s = "\t\t\t\t\n"; + return s; } -wxString wxWxr2Xml::GetStyles(wxItemResource *res) +wxString wxr2xml::GetDimension(wxItemResource * res) { -//Very crude way to get styles -long style; -wxString s,restype; -restype=res->GetType(); -style=res->GetStyle(); + wxString msg; + msg << "\t\t\t\t" << res->GetValue1() << "\n"; + return msg; +} -s=""; -return s; -} - -wxString wxWxr2Xml::GetDimension(wxItemResource *res) -{ -wxString msg; -msg<<" "<GetValue1()<<""; -return msg; -} - -wxString wxWxr2Xml::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(); - } - -name+="\""; -return name; -} - -void wxWxr2Xml::ParseMenuBar(wxItemResource *res) -{ - wxItemResource *child; - wxNode *node = res->GetChildren().First(); - //Get Menu Bar Name - m_xmlfile.Write("\n"); - m_xmlfile.Write(" \n"); - while (node) - { - child= (wxItemResource *)node->Data(); - ParseMenu(child); +void wxr2xml::ParseMenuBar(wxItemResource * res) +{ + wxItemResource *child; + wxNode *node = res->GetChildren().First(); + // Get Menu Bar Name + m_xmlfile.Write("\t\n"); + while (node) { + child = (wxItemResource *) node->Data(); + ParseMenu(child); node = node->Next(); - } - - m_xmlfile.Write(" \n"); - m_xmlfile.Write(" \n"); -} - - -void wxWxr2Xml::ParseMenu(wxItemResource *res) -{ - wxItemResource *child; - wxNode *node = res->GetChildren().First(); - //Get Menu - m_xmlfile.Write(" GetValue1()<<"\""; - m_xmlfile.Write(menuname); - m_xmlfile.Write(">\n"); - m_xmlfile.Write(" \n"); - if (res->GetValue4()!="") - m_xmlfile.Write(" "+res->GetValue4()+"\n"); - m_xmlfile.Write(" \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(); - } -m_xmlfile.Write(" \n"); -m_xmlfile.Write(" \n"); + m_xmlfile.Write("\t \n\n"); +} + +void wxr2xml::ParseMenu(wxItemResource * res) +{ + wxItemResource *child; + wxNode *node = res->GetChildren().First(); + // Get Menu + m_xmlfile.Write("\t\t\tGetValue1() << "\""; + 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"); + // 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(); + } + m_xmlfile.Write("\t\t\t \n"); +} + +void wxr2xml::ParseMenuItem(wxItemResource * res) +{ + // Get Menu Item or Separator + if (res->GetTitle() == "") { + m_xmlfile.Write("\t\t\t\n"); + } else { + m_xmlfile.Write("\t\t\t\tGetValue1() << "\""; + m_xmlfile.Write(menuname); + m_xmlfile.Write(">\n"); + m_xmlfile.Write(" \n"); + if (res->GetValue4() != "") + m_xmlfile.Write(" " + + res->GetValue4() + "\n"); + if (res->GetValue2()) + m_xmlfile.Write("\t\t\t\t1\n"); + m_xmlfile.Write("\t\t\t \n"); + } +} + +wxString wxr2xml::FixMenuString(wxString phrase) +{ + phrase.Replace("&", "$"); + return phrase; +} + +void wxr2xml::ParseStaticBitmap(wxItemResource * res) +{ + m_xmlfile.Write("\t\t\tGetValue4(); + wxBitmap bitmap; + bitmap = wxResourceCreateBitmap(bitmapname, &m_table); + bitmapname += _T(".bmp"); + bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); + m_xmlfile.Write("\n\t\t\t\t" + bitmapname + ""); + m_xmlfile.Write("\t\t\t\n"); + // bitmap5 +} +//Parse a bitmap resource +void wxr2xml::ParseBitmap(wxItemResource * res) +{ + m_xmlfile.Write("\t"); + 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); + m_xmlfile.Write("\n\n"); } -void wxWxr2Xml::ParseMenuItem(wxItemResource *res) +void wxr2xml::PanelStuff(wxItemResource * res) { - //Get Menu Item or Separator -if (res->GetTitle()=="") - { - m_xmlfile.Write(" \n"); - } -else - { - m_xmlfile.Write(" GetValue1()<<"\""; - m_xmlfile.Write(menuname); - m_xmlfile.Write(">\n"); - m_xmlfile.Write(" \n"); - if (res->GetValue4()!="") - m_xmlfile.Write(" "+res->GetValue4()+"\n"); - if (res->GetValue2()) - m_xmlfile.Write(" 1\n"); - m_xmlfile.Write(" \n"); - } + 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; } -wxString wxWxr2Xml::FixMenuString(wxString phrase) +wxString wxr2xml::GetValue3(wxItemResource *res) { -phrase.Replace("&","$"); -return phrase; + wxString msg; + msg << res->GetValue3(); + return msg; + } -void wxWxr2Xml::ParseStaticBitmap(wxItemResource *res) +wxString wxr2xml::GetValue5(wxItemResource *res) { -m_xmlfile.Write(" GetValue4(); -wxBitmap bitmap; -bitmap= wxResourceCreateBitmap(bitmapname,&m_table); -bitmapname+=_T(".bmp"); -bitmap.SaveFile(bitmapname,wxBITMAP_TYPE_BMP); -m_xmlfile.Write("\n "+bitmapname+""); -m_xmlfile.Write("\n"); -//bitmap5 + wxString msg; + msg << res->GetValue5(); + return msg; + } -void wxWxr2Xml::ParseBitmap(wxItemResource *res) +void wxr2xml::ParseBitmapButton(wxItemResource *res) { + + m_xmlfile.Write("\t\t\tGetValue4(); + wxBitmap bitmap; + bitmap = wxResourceCreateBitmap(bitmapname, &m_table); + bitmapname += _T(".bmp"); + bitmap.SaveFile(bitmapname, wxBITMAP_TYPE_BMP); + m_xmlfile.Write("\t\t\t\t" + bitmapname + "\n"); + + m_xmlfile.Write("\t\t\t\n"); +} + +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\n"); + //Get font point size,font family,weight,font style,underline + int pt; + wxString msg; + pt=font.GetPointSize(); + msg<<"\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"); +} +//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: + m_xmlfile.Write("\t\t\t\tdecorative\n"); + break; + case wxROMAN: + m_xmlfile.Write("\t\t\t\troman\n"); + break; + case wxSCRIPT: + m_xmlfile.Write("\t\t\t\tscript\n"); + break; + case wxSWISS: + m_xmlfile.Write("\t\t\t\tswiss\n"); + break; + case wxMODERN: + m_xmlfile.Write("\t\t\t\tmodern\n"); + break; + default: + wxLogError("Unknown font face"); + } } -void wxWxr2Xml::PanelStuff(wxItemResource *res) +void wxr2xml::GetFontStyle(wxFont font) { -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; + 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("\n"); + break; + case wxSLANT: + m_xmlfile.Write("\n"); + break; + default: + wxLogError("Unknown font style"); + } +} + +void wxr2xml::GetFontWeight(wxFont font) +{ + int weight=font.GetWeight(); + switch (weight) + { +//since this is default no point in making file any larger + case wxNORMAL: + break; + case wxLIGHT: + m_xmlfile.Write("\t\t\t\tlight\n"); + break; + case wxBOLD: + m_xmlfile.Write("\t\t\t\tbold\n"); + break; + default: + wxLogError("Unknown font weight"); + } }