#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");
wxString title;
wxString ptsize,face;
- m_xmlfile.Write("\t<dialog");
+ m_xmlfile.Write("\t<object class=\"wxDialog\"");
//Avoid duplicate names this way
dlgname.Replace("IDD_","DLG_");
WriteBasicInfo(x,y,width,height,dlgname);
token=GetToken();
}
- m_xmlfile.Write("\t<children>\n");
ParseControls();
- m_xmlfile.Write("\t</children>\n");
- m_xmlfile.Write("\t</dialog>\n");
+ m_xmlfile.Write("\t</object>\n");
}
/*
token=GetToken();
while ((token!="END")&(token!="}"))
{
+ if (token=="AUTOCHECKBOX")
+ ParseCheckBox();
+ else
+ if (token=="AUTORADIOBUTTON")
+ ParseRadioButton();
+ else
if (token=="LTEXT")
ParseStaticText();
else if (token=="EDITTEXT")
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<statictext");
+ m_xmlfile.Write("\t\t<object class=\"wxStaticText\"");
WriteBasicInfo(x,y,width,height,varname);WriteLabel(phrase);
- m_xmlfile.Write("\t\t</statictext>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
//EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
ReadRect(x,y,width,height);
//TODO
//style=GetToken();
- m_xmlfile.Write("\t\t<textctrl");
+ m_xmlfile.Write("\t\t<object class=\"wxTextCtrl\"");
+ WriteBasicInfo(x,y,width,height,varname);
+ m_xmlfile.Write("\t\t</object>\n");
+
+}
+//AUTOCHECKBOX "&log.", ID_XLOG, 25, 24, 21, 12
+void rc2xml::ParseCheckBox()
+{
+ wxString token;
+ wxString phrase,varname;
+ phrase=GetQuoteField();
+ varname=GetToken();
+
+ int x,y,width,height;
+ ReadRect(x,y,width,height);
+
+ m_xmlfile.Write("\t\t<object class=\"wxCheckBox\"");
+ WriteBasicInfo(x,y,width,height,varname);
+ WriteLabel(phrase);
+ m_xmlfile.Write("\t\t</object>\n");
+
+}
+//AUTORADIOBUTTON "&text", ID_SW10, 13, 12, 68, 10, BS_AUTORADIOBUTTON | WS_GROUP
+void rc2xml::ParseRadioButton()
+{
+ wxString token,style;
+ wxString phrase,varname;
+ phrase=GetQuoteField();
+ varname=GetToken();
+
+ int x,y,width,height;
+ if (ReadRect(x,y,width,height))
+ ReadOrs(token);
+ if (token.Find("WS_GROUP") != -1)
+ style += "wxRB_GROUP";
+
+ m_xmlfile.Write("\t\t<object class=\"wxRadioButton\"");
WriteBasicInfo(x,y,width,height,varname);
- m_xmlfile.Write("\t\t</textctrl>\n");
+ WriteLabel(phrase);
+ WriteStyle(style);
+ m_xmlfile.Write("\t\t</object>\n");
}
+
//PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP
void rc2xml::ParsePushButton()
{
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<button");
+ m_xmlfile.Write("\t\t<object class=\"wxButton\"");
WriteBasicInfo(x,y,width,height,varname);
WriteLabel(phrase);
- m_xmlfile.Write("\t\t</button>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<staticbox");
+ m_xmlfile.Write("\t\t<object class=\"wxStaticBox\"");
WriteBasicInfo(x,y,width,height,varname);
WriteLabel(phrase);
- m_xmlfile.Write("\t\t</staticbox>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
-void rc2xml::ReadRect(int & x, int & y, int & width, int & height)
+bool rc2xml::ReadRect(int & x, int & y, int & width, int & height)
{
x=atoi(GetToken());
y=atoi(GetToken());
width=atoi(GetToken());
- height=atoi(GetToken());
+ bool ret;
+ wxString tmp = GetToken(&ret);
+ height=atoi(tmp);
+ return ret; // check for more parameters
}
-wxString rc2xml::GetToken()
+wxString rc2xml::GetToken(bool *listseperator)
{
wxString token="";
while (!Seperator(ch))
{
- token+=(char)ch;
+ token += (char)ch;
ReadChar(ch);
}
- if (ch==EOF)
- m_done=TRUE;
+ if (ch == EOF)
+ m_done = TRUE;
+ if (listseperator)
+ *listseperator = (ch == ',');
return token;
}
{
/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
WS_VSCROLL | WS_TABSTOP */
- wxString token;
+ wxString token,style;
wxString varname;
varname=GetToken();
int x,y,width,height;
- ReadRect(x,y,width,height);
+ if (ReadRect(x,y,width,height))
+ ReadOrs(token);
- m_xmlfile.Write("\t\t<combobox");
+ m_xmlfile.Write("\t\t<object class=\"wxComboBox\"");
WriteBasicInfo(x,y,width,height,varname);
- m_xmlfile.Write("\n\t\t</combobox>\n");
+ if (token.Find("CBS_SIMPLE") != -1)
+ WriteStyle("wxCB_SIMPLE");
+ if (token.Find("CBS_SORT") != -1)
+ WriteStyle("wxCB_SORT");
+ if (token.Find("CBS_DISABLENOSCROLL") != -1)
+ WriteStyle("wxLB_ALWAYS_SB");
+ m_xmlfile.Write("\n\t\t</object>\n");
}
wxString token="";
//Write menubar to xml file
- m_xmlfile.Write("\t<menubar");
+ m_xmlfile.Write("\t<object class=\"wxMenuBar\"");
//Avoid duplicate names this way
varname.Replace("IDR_","MB_");
WriteName(varname);
m_xmlfile.Write(">\n");
- m_xmlfile.Write("\t\t<children>\n");
while ((token!="BEGIN")&(token!="{"))
token=GetToken();
ParsePopupMenu();
}
}
- m_xmlfile.Write("\t\t</children>\n");
- m_xmlfile.Write("\t</menubar>\n");
+ m_xmlfile.Write("\t</object>\n");
}
void rc2xml::ParsePopupMenu()
//Write Menu item
//Generate a fake name since RC menus don't have one
name<<"Menu_"<<menucount;
- m_xmlfile.Write("\t\t<menu");
+ m_xmlfile.Write("\t\t<object class=\"wxMenu\"");
WriteName(name);
m_xmlfile.Write(">\n");
WriteLabel(token);
- m_xmlfile.Write("\t\t\t<children>\n");
while ((token!="BEGIN")&(token!="{"))
token=GetToken();
if (token=="MENUITEM")
ParseMenuItem();
}
- m_xmlfile.Write("\t\t\t</children>\n");
- m_xmlfile.Write("\t\t\t</menu>\n");
+ m_xmlfile.Write("\t\t\t</object>\n");
}
wxString rc2xml::PeekToken()
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<slider");
+ m_xmlfile.Write("\t\t<object class=\"wxSlider\"");
WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style);
- m_xmlfile.Write("\n\t\t</slider>\n");
+ m_xmlfile.Write("\n\t\t</object>\n");
}
/*
ReadRect(x,y,width,height);
//Always horizontal in MFC
- m_xmlfile.Write("\t\t<gauge");
+ m_xmlfile.Write("\t\t<object class=\"wxGauge\"");
WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style);
- m_xmlfile.Write("\t\t</gauge>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
bool rc2xml::ReadOrs(wxString & orstring)
if (token.Find("BS_AUTOCHECKBOX")!=-1)
{
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<checkbox");
+ m_xmlfile.Write("\t\t<object class=\"wxCheckBox\"");
WriteBasicInfo(x,y,width,height,varname);
WriteLabel(label);
- m_xmlfile.Write("\t\t</checkbox>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
if (token.Find("BS_AUTORADIOBUTTON")!=-1)
{
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<radiobutton");
+ m_xmlfile.Write("\t\t<object class=\"wxRadioButton\"");
WriteBasicInfo(x,y,width,height,varname);
WriteLabel(label);
- m_xmlfile.Write("\t\t</radiobutton>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
}
name="wxID_COPY";
else if (name=="ID_EDIT_PASTE")
name="wxID_PASTE";
+ else if (name=="IDYES")
+ name="wxID_YES";
+ else if (name=="IDNO")
+ name="wxID_NO";
+ else if (name=="IDHELP")
+ name="wxID_HELP";
m_xmlfile.Write(" name= \""+name+"\"");
}
{
if (style.Length()==0)
return;
- m_xmlfile.Write("\n\t\t<style>"+style+"</style>\n");
+ m_xmlfile.Write("\t\t\t<style>"+style+"</style>\n");
}
/*
LISTBOX IDC_LIST1,16,89,48,40,LBS_SORT | LBS_MULTIPLESEL |
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<listbox");
+ m_xmlfile.Write("\t\t<object class=\"wxListBox\"");
WriteBasicInfo(x,y,width,height,varname);
- m_xmlfile.Write("\n\t\t</listbox>\n");
+ m_xmlfile.Write("\n\t\t</object>\n");
}
/*
wxString style;
//Make it a rich text control
style+="wxTE_MULTILINE ";
- m_xmlfile.Write("\t\t<textctrl");
+ m_xmlfile.Write("\t\t<object class=\"wxTextCtrl\"");
WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style);
- m_xmlfile.Write("\t\t</textctrl>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
/*
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<spinbutton");
+ m_xmlfile.Write("\t\t<object class=\"wxSpinButton\"");
WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style);
- m_xmlfile.Write("\n\t\t</spinbutton>\n");
+ m_xmlfile.Write("\n\t\t</object>\n");
}
wxLogError("Unable to load bitmap:"+*bitmappath);
//Write toolbar to xml file
- m_xmlfile.Write(" <toolbar");
+ m_xmlfile.Write(" <object class=\"wxToolBar\"");
//Avoid duplicate names this way
varname.Replace("IDR_","TB_");
WriteName(varname);
style+="wxTB_FLAT";
WriteStyle(style);
- m_xmlfile.Write("\t\t<children>\n");
//Grab width and height
int width,height;
if (token=="BUTTON")
{
buttonname=GetToken();
- m_xmlfile.Write("\t\t\t<tool");
+ m_xmlfile.Write("\t\t\t<object class=\"tool\"");
WriteName(buttonname);
m_xmlfile.Write(">\n");
//Write tool tip if any
buttonname+=".bmp";
m_xmlfile.Write("\t\t\t\t<bitmap>"+buttonname+"</bitmap>\n");
WriteToolButton(buttonname,c,width,height,bitmap);
- m_xmlfile.Write("\t\t\t</tool>\n");
+ m_xmlfile.Write("\t\t\t</object>\n");
c++;
}
else if (token=="SEPARATOR")
{
- m_xmlfile.Write("\t\t\t<separator/>\n");
+ m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
}
token=GetToken();
}
- m_xmlfile.Write("\t</children>\n");
- m_xmlfile.Write("\t</toolbar>\n");
+ m_xmlfile.Write("\t</object>\n");
}
//Extract bitmaps from larger toolbar bitmap
wxRect r(x,0,width,height);
wxBitmap little;
little=bitmap.GetSubBitmap(r);
- little.SaveFile(name,wxBITMAP_TYPE_BMP);
+ little.SaveFile(m_targetpath+name,wxBITMAP_TYPE_BMP);
}
void rc2xml::ParseStringTable(wxString varname)
//int spot;
if (PeekToken()=="SEPARATOR")
{
- m_xmlfile.Write("\t\t\t<separator/>\n");
+ m_xmlfile.Write("\t\t\t<object class=\"separator\"/>\n");
return;
}
//Remove \t because it causes problems
//spot=token.First("\\t");
//token=token.Left(spot);
- m_xmlfile.Write("\t\t\t<menuitem");
+ m_xmlfile.Write("\t\t\t<object class=\"wxMenuItem\"");
WriteName(name);
m_xmlfile.Write(">\n");
WriteLabel(token);
ptoken=PeekToken();
}
- m_xmlfile.Write("\t\t\t</menuitem>\n");
+ m_xmlfile.Write("\t\t\t</object>\n");
}
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<staticbitmap");
+ m_xmlfile.Write("\t\t<object class=\"wxStaticBitmap\"");
WriteBasicInfo(x,y,width,height,varname);
//Save icon as a bitmap
WriteIcon(iconname);
- m_xmlfile.Write("\t\t</staticbitmap>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
//IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico"
name.Replace("idr_","");
name.Replace("idb_","");
name.Replace("idc_","");
+
+ name.Replace(".ico","");
+
+ name.Replace(".bmp","");
return name;
}
// And the award for most messed up control goes to...
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<staticbitmap");
+ m_xmlfile.Write("\t\t<object class=\"wxStaticBitmap\"");
WriteBasicInfo(x,y,width,height,varname);
WriteBitmap(bitmapname);
- m_xmlfile.Write("\t\t</staticbitmap>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
else
style=_T("wxSB_HORIZONTAL");
- m_xmlfile.Write("\t\t<scrollbar");
+ m_xmlfile.Write("\t\t<object class=\"wxScrollBar\"");
WriteBasicInfo(x,y,width,height,varname);
WriteStyle(style);
- m_xmlfile.Write("\n\t\t</scrollbar>\n");
+ m_xmlfile.Write("\n\t\t</object>\n");
}
// CONTROL "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP,
ReadOrs(token);
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<treectrl");
+ m_xmlfile.Write("\t\t<object class=\"wxTreeCtrl\"");
WriteBasicInfo(x,y,width,height,varname);
- m_xmlfile.Write("\t\t</treectrl>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
// CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32",
ReadOrs(token);
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<calendarctrl");
+ m_xmlfile.Write("\t\t<object class=\"wxCalendarCtrl\"");
WriteBasicInfo(x,y,width,height,varname);
- m_xmlfile.Write("\t\t</calendarctrl>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
// CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP,
// 7,89,68,71
ReadOrs(token);
int x,y,width,height;
ReadRect(x,y,width,height);
- m_xmlfile.Write("\t\t<listctrl");
+ m_xmlfile.Write("\t\t<object class=\"wxListCtrl\"");
WriteBasicInfo(x,y,width,height,varname);
- m_xmlfile.Write("\t\t</listctrl>\n");
+ m_xmlfile.Write("\t\t</object>\n");
}
wxString *bitmappath;
bitmappath=(wxString *)node->Data();
+
+ bitmapname=wxFileNameFromPath(*bitmappath);
wxBitmap bitmap;
if (!bitmap.LoadFile(*bitmappath,wxBITMAP_TYPE_BMP ))
wxLogError("Unable to load bitmap:"+*bitmappath);
bitmapname=CleanName(bitmapname);
bitmapname+=".bmp";
m_xmlfile.Write("\t\t\t<bitmap>"+bitmapname+"</bitmap>\n");
- bitmap.SaveFile(bitmapname,wxBITMAP_TYPE_BMP);
+ bitmap.SaveFile(m_targetpath+bitmapname,wxBITMAP_TYPE_BMP);
}
void rc2xml::WriteIcon(wxString iconname)
#else
bitmap = icon;
#endif
-
+ iconname=wxFileNameFromPath(*iconpath);
//Make a bitmap file name
iconname=CleanName(iconname);
iconname+=".bmp";
m_xmlfile.Write("\t\t\t<bitmap>"+iconname+"</bitmap>\n");
- bitmap.SaveFile(iconname,wxBITMAP_TYPE_BMP);
+ bitmap.SaveFile(m_targetpath+iconname,wxBITMAP_TYPE_BMP);
}