#endif
// For compilers that support precompilation, includes "wx/wx.h".
-#include <wx/wxprec.h>
+#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
m_rc.Open(rcfile.c_str());
m_filesize=m_rc.Length();
+
m_workingpath=wxPathOnly(rcfile);
+
m_targetpath=wxPathOnly(xmlfile)+"\\";
+
+
wxSetWorkingDirectory(m_workingpath);
+
bool result;
result=m_xmlfile.Open(xmlfile.c_str(),"w+t");
wxASSERT_MSG(result,"Couldn't create XML file");
m_xmlfile.Write("</resource>\n");
m_xmlfile.Close();
m_rc.Close();
+ wxMessageBox(_("Conversion complete."), _("Done"),
+ wxOK | wxICON_INFORMATION);
return TRUE;
}
*/
token=PeekToken();
//Microsoft notation?
- if (token=="DISCARDABLE")
+ while ((token=="DISCARDABLE")
+ ||(token=="LOADONCALL")||(token=="MOVEABLE"))
{
token=GetToken();
token=PeekToken();
void rc2xml::ParseControls()
{
wxString token;
+ wxString label,varname;
token=GetToken();
while ((token!="END")&(token!="}"))
{
if (token=="AUTOCHECKBOX")
- ParseCheckBox();
+ {
+ label=GetQuoteField();
+ varname=GetToken();
+ ParseCheckBox(label,varname);
+ }
else
if (token=="AUTORADIOBUTTON")
- ParseRadioButton();
+ {
+ label=GetQuoteField();
+ varname=GetToken();
+ ParseRadioButton(label,varname);
+ }
else
if (token=="LTEXT")
- ParseStaticText();
+ {
+ label=GetQuoteField();
+ varname=GetToken();
+ ParseStaticText(label,varname);
+ }
else if (token=="EDITTEXT")
- ParseTextCtrl();
- else if (token=="PUSHBUTTON")
- ParsePushButton();
- else if (token=="DEFPUSHBUTTON")
- ParsePushButton();
+ {
+ varname=GetToken();
+ ParseTextCtrl(varname);
+ }
+ else if ((token=="PUSHBUTTON")||(token=="DEFPUSHBUTTON"))
+ {
+ label=GetQuoteField();
+ varname=GetToken();
+ ParsePushButton(label,varname);
+ }
else if (token=="GROUPBOX")
- ParseGroupBox();
+ {
+ label=GetQuoteField();
+ varname=GetToken();
+ ParseGroupBox(label,varname);
+ }
else if (token=="COMBOBOX")
- ParseComboBox();
+ {
+ varname=GetToken();
+ ParseComboBox(varname);
+ }
else if (token=="CONTROL")
ParseControlMS();
else if (token=="LISTBOX")
- ParseListBox();
+ {
+ varname=GetToken();
+ ParseListBox(varname);
+ }
else if (token=="ICON")
ParseIconStatic();
else if (token=="SCROLLBAR")
}
//LTEXT "Radius",IDC_STATIC,9,67,23,8
-void rc2xml::ParseStaticText()
+void rc2xml::ParseStaticText(wxString phrase, wxString varname)
{
wxString token;
- wxString phrase,varname;
- phrase=GetQuoteField();
- varname=GetToken();
+ token=PeekToken();
+ while (!token.IsNumber())
+ {
+ token=GetToken();
+ token=PeekToken();
+ }
int x,y,width,height;
ReadRect(x,y,width,height);
}
//EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
-void rc2xml::ParseTextCtrl()
+void rc2xml::ParseTextCtrl(wxString varname)
{
wxString token;
- wxString varname,style;
- varname=GetToken();
+ wxString style;
+ token=PeekToken();
+ while (!token.IsNumber())
+ {
+ token=GetToken();
+ token=PeekToken();
+ }
int x,y,width,height;
ReadRect(x,y,width,height);
//TODO
}
//AUTOCHECKBOX "&log.", ID_XLOG, 25, 24, 21, 12
-void rc2xml::ParseCheckBox()
+void rc2xml::ParseCheckBox(wxString phrase, wxString varname)
{
wxString token;
- wxString phrase,varname;
- phrase=GetQuoteField();
- varname=GetToken();
-
+ token=PeekToken();
+ while (!token.IsNumber())
+ {
+ token=GetToken();
+ token=PeekToken();
+ }
int x,y,width,height;
ReadRect(x,y,width,height);
}
//AUTORADIOBUTTON "&text", ID_SW10, 13, 12, 68, 10, BS_AUTORADIOBUTTON | WS_GROUP
-void rc2xml::ParseRadioButton()
+void rc2xml::ParseRadioButton(wxString phrase, wxString varname)
{
wxString token,style;
- wxString phrase,varname;
- phrase=GetQuoteField();
- varname=GetToken();
-
int x,y,width,height;
+ bool GotOrs;
+ GotOrs = ReadOrs(token);
if (ReadRect(x,y,width,height))
+ if (GotOrs==FALSE)
ReadOrs(token);
if (token.Find("WS_GROUP") != -1)
style += "wxRB_GROUP";
}
//PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP
-void rc2xml::ParsePushButton()
+void rc2xml::ParsePushButton(wxString phrase, wxString varname)
{
wxString token;
- wxString phrase,varname;
- phrase=GetQuoteField();
- varname=GetToken();
+ token=PeekToken();
+ while (!token.IsNumber())
+ {
+ token=GetToken();
+ token=PeekToken();
+ }
int x,y,width,height;
ReadRect(x,y,width,height);
return FALSE;
}
-void rc2xml::ParseGroupBox()
+void rc2xml::ParseGroupBox(wxString phrase, wxString varname)
{
// GROUPBOX "Rotate",IDC_STATIC,1,1,71,79
wxString token;
- wxString phrase,varname;
- phrase=GetQuoteField();
- varname=GetToken();
+ token=PeekToken();
+ while (!token.IsNumber())
+ {
+ token=GetToken();
+ token=PeekToken();
+ }
int x,y,width,height;
ReadRect(x,y,width,height);
while (ch!=34)
ReadChar(ch);
+ ReadChar(ch);
+ while (ch!=34)
+ {
+ phrase+=(char)ch;
+ ReadChar(ch);
+ }
+ return phrase;
+}
+
+// string in stringtable may contain embedded quotes
+// escape characters retained to allow strings to be rewritten
+wxString rc2xml::GetStringQuote()
+{
+ wxString phrase;
+ //ASCII code 34 "
+ bool done=FALSE;
+ int p,ch=0,lastch=0;
ReadChar(ch);
while (ch!=34)
+ ReadChar(ch);
+ ReadChar(ch);
+ while (done==FALSE)
+ {
+ if ((ch==34)&&(lastch!='\\'))
+ {
+ p=m_rc.Tell();
+ ReadChar(ch);
+// RC supports "", for embedded quote, as well as \"
+ if (ch==34)
+ phrase+='\\';
+ else
{
+ m_rc.Seek(p);
+ done = TRUE;
+ }
+ }
+ if (done==TRUE)
+ break;
+ if (ch=='\r')
+ ReadChar(ch); // skip
+ if ((ch=='\n')&&(lastch=='\\')) // lastch <should> be this
+ phrase+='n'; // escape
+ else
phrase+=(char)ch;
+ lastch=ch;
ReadChar(ch);
}
+
return phrase;
}
m_done=TRUE;
}
-void rc2xml::ParseComboBox()
+void rc2xml::ParseComboBox(wxString varname)
{
/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP */
wxString token,style;
- wxString varname;
- varname=GetToken();
int x,y,width,height;
+ bool GotOrs;
+ GotOrs = ReadOrs(token);
if (ReadRect(x,y,width,height))
+ if (GotOrs==FALSE)
ReadOrs(token);
m_xmlfile.Write("\t\t<object class=\"wxComboBox\"");
while ((token!="END")&(token!="}"))
{
token=GetToken();
+ token.MakeUpper();
+
if (token=="POPUP")
{
ParsePopupMenu();
while ((token!="END")&(token!="}"))
{
token=GetToken();
+ token.MakeUpper();
+
if (token=="POPUP")
ParsePopupMenu();
return TRUE;
}
-//Is it a check button or a radio button
+//Is it a checkbutton or a radiobutton or a pushbutton or a groupbox
void rc2xml::ParseCtrlButton(wxString label, wxString varname)
{
wxString token;
+ int p;
+ p=m_rc.Tell();
ReadOrs(token);
- int x,y,width,height;
+ m_rc.Seek(p);
if (token.Find("BS_AUTOCHECKBOX")!=-1)
- {
- ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<object class=\"wxCheckBox\"");
- WriteBasicInfo(x,y,width,height,varname);
- WriteLabel(label);
- m_xmlfile.Write("\t\t</object>\n");
- }
-
- if (token.Find("BS_AUTORADIOBUTTON")!=-1)
- {
- ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<object class=\"wxRadioButton\"");
- WriteBasicInfo(x,y,width,height,varname);
- WriteLabel(label);
- m_xmlfile.Write("\t\t</object>\n");
- }
-
+ ParseCheckBox(label, varname);
+ else if ((token.Find("BS_AUTORADIOBUTTON")!=-1)||
+ (token.Find("BS_RADIOBUTTON")!=-1))
+ ParseRadioButton(label, varname);
+ else if (token.Find("BS_GROUPBOX")!=-1)
+ ParseGroupBox(label, varname);
+ else // if ((token.Find("BS_PUSHBUTTON")!=-1)||
+// (token.Find("BS_DEFPUSHBUTTON")!=-1))
+ ParsePushButton(label, varname); // make default case
}
-
void rc2xml::WriteSize(int width, int height)
{
wxString msg;
LISTBOX IDC_LIST1,16,89,48,40,LBS_SORT | LBS_MULTIPLESEL |
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
*/
-void rc2xml::ParseListBox()
+void rc2xml::ParseListBox(wxString varname)
{
wxString token;
- wxString varname;
- varname=GetToken();
+ token=PeekToken();
+ while (!token.IsNumber())
+ {
+ token=GetToken();
+ token=PeekToken();
+ }
int x,y,width,height;
ReadRect(x,y,width,height);
while (!m_done)
{
token=GetToken();
- if (token=="DIALOG")
+ if ((token=="DIALOG")||(token=="DIALOGEX"))
ParseDialog(prevtok);
else if (token=="MENU")
ParseMenu(prevtok);
int c=0;
wxString buttonname,msg,tip,longhelp;
token=GetToken();
- while ((token!="BEGIN"))
+ while ((token!="BEGIN")&(token!="{"))
token=GetToken();
while ((token!="END")&(token!="}"))
{
wxString token;
token=GetToken();
- while ((token!="BEGIN"))
+ while ((token!="BEGIN")&(token!="{"))
token=GetToken();
token=GetToken();
wxString *msg;
while ((token!="END")&(token!="}"))
{
msg=new wxString;
- *msg=GetQuoteField();
+ *msg=GetStringQuote();
m_stringtable->Append(token,msg);
token=GetToken();
}
m_xmlfile.Write(">\n");
WriteLabel(token);
//Look up help if any listed in stringtable
- if (LookUpString(name,msg))
+//can't assume numbers correlate, restrict to string identifiers
+ if ((!name.IsNumber())&&(LookUpString(name,msg)))
{
SplitHelp(msg,tip,longhelp);
m_xmlfile.Write("\t\t\t<help>"
//look for extra attributes like checked and break
wxString ptoken;
ptoken=PeekToken();
+ ptoken.MakeUpper();
while ((ptoken!="MENUITEM")&(ptoken!="POPUP")&(ptoken!="END"))
{
token=GetToken();
+ ptoken.MakeUpper();
if (token=="CHECKED")
m_xmlfile.Write("\t\t\t<checkable>1</checkable>\n");
else if (token=="MENUBREAK");
wxLogError("Unknown Menu Item token:"+token);
ptoken=PeekToken();
+ ptoken.MakeUpper();
}
m_xmlfile.Write("\t\t\t</object>\n");
{
wxString token;
wxString varname,iconname;
+ token = PeekToken();
+ if (token.Contains("\""))
+ iconname = GetQuoteField();
+ else
iconname=GetToken();
//Look up icon
varname=GetToken();
name.Replace("idr_","");
name.Replace("idb_","");
name.Replace("idc_","");
+
name.Replace(".ico","");
+
name.Replace(".bmp","");
return name;
}
{
wxString token;
//Grab SS_BITMAP
- token=GetToken();
-
+ ReadOrs(token);
int x,y,width,height;
ParseCtrlButton(label,varname);
if (kindctrl=="RICHEDIT")
ParseRichEdit(label,varname);
+ if (kindctrl=="STATIC")
+ {
+ wxString token;
+ int p=m_rc.Tell();
+ ReadOrs(token);
+ m_rc.Seek(p);
+ if (token.Find("SS_BITMAP")!=-1)
+ ParseStaticBitmap(label,varname);
+ else
+ ParseStaticText(label,varname);
+ }
+ if (kindctrl=="EDIT")
+ ParseTextCtrl(varname);
+ if (kindctrl=="LISTBOX")
+ ParseListBox(varname);
+ if (kindctrl=="COMBOBOX")
+ ParseComboBox(varname);
}
wxString *bitmappath;
bitmappath=(wxString *)node->Data();
+
bitmapname=wxFileNameFromPath(*bitmappath);
wxBitmap bitmap;
if (!bitmap.LoadFile(*bitmappath,wxBITMAP_TYPE_BMP ))