#include "rc2xml.h"
#include "wx/image.h"
-#include "wx/resource.h"
+#include "wx/deprecated/setup.h"
+#include "wx/deprecated/resource.h"
#include <wx/textfile.h>
#include <wx/tokenzr.h>
{
m_rc.Open(rcfile.c_str());
m_filesize=m_rc.Length();
-
+
m_workingpath=wxPathOnly(rcfile);
bool result;
result=m_xmlfile.Open(xmlfile.c_str(),"w+t");
- wxASSERT_MSG(result,"Couldn't create XML file");
+ wxASSERT_MSG(result,"Couldn't create XML file");
if (!result)
return FALSE;
-
+
/* Write Basic header for XML file */
m_xmlfile.Write("<?xml version=\"1.0\" ?>\n");
m_xmlfile.Write("<resource>\n");
-
+
//Read resource.h
ParseResourceHeader();
//Gather all the resource we need for toolbars,menus, and etc
m_xmlfile.Write("</resource>\n");
m_xmlfile.Close();
m_rc.Close();
- wxMessageBox(_("Conversion complete."), _("Done"),
+ wxMessageBox(_("Conversion complete."), _("Done"),
wxOK | wxICON_INFORMATION);
return TRUE;
wxString token;
static int dlgid=999;
dlgid++;
-/* Make sure that this really is a dialog
+/* Make sure that this really is a dialog
microsoft reuses the keyword DIALOG for other things
*/
token=PeekToken();
token=GetToken();
wxString title;
wxString ptsize,face;
-
+
m_xmlfile.Write("\t<object class=\"wxDialog\"");
//Avoid duplicate names this way
dlgname.Replace("IDD_","DLG_");
WriteBasicInfo(x,y,width,height,dlgname);
WriteTitle(title);
-
+
while ((token!="BEGIN")&(token!="{"))
{
/*
BEGIN
- EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT
+ EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT
WS_TABSTOP
LTEXT "Bands",IDC_STATIC,11,86,21,8
EDITTEXT IDC_NAME,10,3,75,14,ES_AUTOHSCROLL
m_done=TRUE;
return TRUE;
}
-
+
return FALSE;
}
{
m_done=TRUE;
}
-
+
while (!Seperator(ch))
{
while (ch!=34)
ReadChar(ch);
ReadChar(ch);
-
+
while (ch!=34)
{
phrase+=(char)ch;
p=m_rc.Tell();
ReadChar(ch);
// RC supports "", for embedded quote, as well as \"
- if (ch==34)
- phrase+='\\';
+ if (ch==34)
+ phrase+='\\';
else
{
m_rc.Seek(p);
void rc2xml::ParseComboBox(wxString varname)
{
-/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
+/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP */
wxString token,style;
int x,y,width,height;
if (token=="POPUP")
ParsePopupMenu();
-
+
if (token=="MENUITEM")
ParseMenuItem();
}
}
-/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
+/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
TBS_NOTICKS | WS_TABSTOP,52,73,100,15
*/
m_xmlfile.Write("\n\t\t</object>\n");
}
-/*
+/*
CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32",
WS_BORDER,15,52,154,13
*/
{
wxString token,style;
ReadOrs(token);
-
+
int x,y,width,height;
ReadRect(x,y,width,height);
while(PeekToken()==_T("|"))
{
- //Grab |
+ //Grab |
orstring+=GetToken();
//Grab next token
orstring+=GetToken();
(token.Find("BS_RADIOBUTTON")!=-1))
ParseRadioButton(label, varname);
else if (token.Find("BS_GROUPBOX")!=-1)
- ParseGroupBox(label, varname);
+ ParseGroupBox(label, varname);
else // if ((token.Find("BS_PUSHBUTTON")!=-1)||
// (token.Find("BS_DEFPUSHBUTTON")!=-1))
ParsePushButton(label, varname); // make default case
void rc2xml::WriteName(wxString name)
{
-
+
//Try to convert any number ids into names
name=LookUpId(name);
//Replace common MS ids with wxWindows ids
m_xmlfile.Write("\t\t\t<style>"+style+"</style>\n");
}
/*
- LISTBOX IDC_LIST1,16,89,48,40,LBS_SORT | LBS_MULTIPLESEL |
+ LISTBOX IDC_LIST1,16,89,48,40,LBS_SORT | LBS_MULTIPLESEL |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
*/
void rc2xml::ParseListBox(wxString varname)
}
/*
- CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER |
+ CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER |
WS_TABSTOP,103,110,40,14
*/
void rc2xml::ParseRichEdit(wxString label, wxString varname)
void rc2xml::ParseSpinCtrl(wxString label, wxString varname)
{
wxString token,style;
-
+
ReadOrs(token);
if (token.Find("UDS_HORZ")!=-1)
style="wxSP_HORIZONTAL";
ParseStringTable(prevtok);
else if (token=="ICON")
ParseIcon(prevtok);
-
+
prevtok=token;
}
}
void rc2xml::ParseBitmap(wxString varname)
{
wxString token,*bitmapfile;
-
+
token=PeekToken();
//Microsoft notation?
if (token=="DISCARDABLE")
ParseMenu(prevtok);
else if (token=="TOOLBAR")
ParseToolBar(prevtok);
-
+
prevtok=token;
}
void rc2xml::ParseToolBar(wxString varname)
{
- wxString token;
+ wxString token;
token=GetToken();
wxASSERT_MSG(token=="DISCARDABLE","Error in toolbar parsing");
//Look up bitmap for toolbar and load
width=atoi(GetToken());
height=atoi(GetToken());
- int c=0;
+ int c=0;
wxString buttonname,msg,tip,longhelp;
token=GetToken();
while ((token!="BEGIN")&(token!="{"))
WriteLabel(token);
//Look up help if any listed in stringtable
//can't assume numbers correlate, restrict to string identifiers
- if ((!name.IsNumber())&&(LookUpString(name,msg)))
+ if ((!name.IsNumber())&&(LookUpString(name,msg)))
{
SplitHelp(msg,tip,longhelp);
m_xmlfile.Write("\t\t\t<help>"
else if (token=="GRAYED");
else
wxLogError("Unknown Menu Item token:"+token);
-
+
ptoken=PeekToken();
ptoken.MakeUpper();
}
- m_xmlfile.Write("\t\t\t</object>\n");
+ m_xmlfile.Write("\t\t\t</object>\n");
}
*iconfile=GetQuoteField();
m_iconlist->Append(varname,iconfile);
-
+
}
wxString style;
ReadOrs(token);
-
+
if (token.Find("SBS_VERT")!=-1)
style=_T("wxSB_VERTICAL");
//Default MFC style is horizontal
wxLogError("Unable to find bitmap:"+bitmapname);
return;
}
-
+
wxString *bitmappath;
bitmappath=(wxString *)node->Data();
m_xmlfile.Write("\t\t\t<bitmap>"+iconname+"</bitmap>\n");
bitmap.SaveFile(m_targetpath+iconname,wxBITMAP_TYPE_BMP);
-
+
}
/*Unfortunately sometimes the great MSVC Resource editor decides
to use numbers instead of the word id. I have no idea why they
wxLogError("Warining Unable to load resource.h file");
return;
}
-
+
wxString str;
wxString id,v;
wxStringTokenizer tok;
wxString *varname;
-
-
+
+
long n;
//Read through entire file
}
}
-
-
+
+
}