X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/92a19c2e7757ba742846f83e56356de0a607bdc2..a70b2f8001a5522cf6f172f11ba36b4af65af121:/contrib/utils/convertrc/rc2wxr.cpp diff --git a/contrib/utils/convertrc/rc2wxr.cpp b/contrib/utils/convertrc/rc2wxr.cpp index 30a0262a6c..9eb0b430ff 100644 --- a/contrib/utils/convertrc/rc2wxr.cpp +++ b/contrib/utils/convertrc/rc2wxr.cpp @@ -46,7 +46,7 @@ This code was used as a starting point for my rc2xml converter // for all others, include the necessary headers (this file is usually all you -// need because it includes almost all "standard" wxWindows headers +// need because it includes almost all "standard" wxWidgets headers #ifndef WX_PRECOMP @@ -62,7 +62,8 @@ This code was used as a starting point for my rc2xml converter #include "wx/image.h" -#include "wx/resource.h" +#include "wx/deprecated/setup.h" +#include "wx/deprecated/resource.h" ////////////////////////////////////////////////////////////////////// @@ -102,7 +103,7 @@ m_rc.Open(rcfile); m_filesize=m_rc.Length(); -if( (m_wxr = fopen( wxrfile, "wt" )) == NULL ) +if( (m_wxr = wxFopen( wxrfile, _T("wt") )) == NULL ) { @@ -130,7 +131,7 @@ tok=GetToken(); -if (tok=="DIALOG") +if (tok==_T("DIALOG")) { @@ -138,17 +139,17 @@ ParseDialog(prevtok); } - -if (tok=="MENU") + +if (tok==_T("MENU")) { ParseMenu(prevtok); -} +} @@ -160,7 +161,7 @@ prevtok=tok; fclose(m_wxr); -//fclose(m_rc); +//fclose(m_rc); m_rc.Close(); @@ -174,7 +175,7 @@ m_rc.Close(); /* -Example .rc +Example .rc Microsoft style as of v5.0 @@ -222,7 +223,7 @@ 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 @@ -232,7 +233,7 @@ tok=PeekToken(); //Microsoft notation? -if (tok=="DISCARDABLE") +if (tok==_T("DISCARDABLE")) { @@ -250,15 +251,15 @@ if (!tok.IsNumber()) //Generate Dialog text -fprintf(m_wxr,"static char *dialog%i = \"dialog(name = '%s',\\\n",dlgid,dlgname); +wxFprintf(m_wxr,_T("static char *dialog%i = \"dialog(name = '%s',\\\n"),dlgid,dlgname.c_str()); //be lazy about style for now. add it later -fprintf(m_wxr,"style = 'wxRAISED_BORDER | wxCAPTION | wxTHICK_FRAME | wxSYSTEM_MENU',\\\n"); +wxFprintf(m_wxr,_T("style = 'wxRAISED_BORDER | wxCAPTION | wxTHICK_FRAME | wxSYSTEM_MENU',\\\n")); -fprintf(m_wxr,"id = %i,\\\n",dlgid); +wxFprintf(m_wxr,_T("id = %i,\\\n"),dlgid); @@ -268,7 +269,7 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr,"x = %i, y = %i, width = %i, height = %i,\\\n",x,y,width,height); +wxFprintf(m_wxr,_T("x = %i, y = %i, width = %i, height = %i,\\\n"),x,y,width,height); @@ -284,17 +285,17 @@ wxString title; -while ((tok!="BEGIN")&(tok!="{")) +while ((tok!=_T("BEGIN"))&(tok!=_T("{"))) { -if (tok=="CAPTION") +if (tok==_T("CAPTION")) { title=GetQuoteField(); -fprintf(m_wxr,"title = '%s',\\\n",title); +wxFprintf(m_wxr,_T("title = '%s',\\\n"),title.c_str()); } @@ -302,17 +303,17 @@ tok=GetToken(); } -fprintf(m_wxr,"use_dialog_units = 1,\\\n"); +wxFprintf(m_wxr,_T("use_dialog_units = 1,\\\n")); -fprintf(m_wxr,"use_system_defaults = 0,\\\n"); +wxFprintf(m_wxr,_T("use_system_defaults = 0,\\\n")); -fprintf(m_wxr,"font = [8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif'],\\\n"); +wxFprintf(m_wxr,_T("font = [8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif'],\\\n")); ParseControls(); -fprintf(m_wxr,").\";\n\n"); +wxFprintf(m_wxr,_T(").\";\n\n")); } @@ -328,7 +329,7 @@ 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 @@ -350,35 +351,35 @@ wxString tok; tok=GetToken(); -while ((tok!="END")&(tok!="}")) +while ((tok!=_T("END"))&(tok!=_T("}"))) { -if (tok=="LTEXT") +if (tok==_T("LTEXT")) ParseStaticText(); -if (tok=="EDITTEXT") +if (tok==_T("EDITTEXT")) ParseTextCtrl(); -if (tok=="PUSHBUTTON") +if (tok==_T("PUSHBUTTON")) ParsePushButton(); -if (tok=="DEFPUSHBUTTON") +if (tok==_T("DEFPUSHBUTTON")) ParsePushButton(); -if (tok=="GROUPBOX") +if (tok==_T("GROUPBOX")) ParseGroupBox(); -if (tok=="COMBOBOX") +if (tok==_T("COMBOBOX")) ParseComboBox(); -if (tok=="CONTROL") +if (tok==_T("CONTROL")) ParseControlMS(); @@ -412,11 +413,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxStaticText,'%s','0','%s',",m_controlid,phrase,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxStaticText,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str()); -fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); } @@ -438,11 +439,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxTextCtrl,'','0','%s',",m_controlid,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxTextCtrl,'','0','%s',"),m_controlid,varname.c_str()); -fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); @@ -468,19 +469,19 @@ m_controlid++; c=m_controlid; -if (varname=="IDOK") +if (varname==_T("IDOK")) c=wxID_OK; -if (varname=="IDCANCEL") +if (varname==_T("IDCANCEL")) c=wxID_CANCEL; -if (varname=="IDAPPLY") +if (varname==_T("IDAPPLY")) c=wxID_APPLY; @@ -490,11 +491,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxButton,'%s','0','%s',",c,phrase,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxButton,'%s','0','%s',"),c,phrase.c_str(),varname.c_str()); -fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); @@ -550,11 +551,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxStaticBox,'%s','0','%s',",m_controlid,phrase,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxStaticBox,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str()); -fprintf(m_wxr,"%i,%i,%i,%i,'',\\\n",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); @@ -568,13 +569,13 @@ void rc2wxr::ReadRect(int & x, int & y, int & width, int & height) { -x=atoi(GetToken()); +x=wxAtoi(GetToken()); -y=atoi(GetToken()); +y=wxAtoi(GetToken()); -width=atoi(GetToken()); +width=wxAtoi(GetToken()); -height=atoi(GetToken()); +height=wxAtoi(GetToken()); @@ -586,7 +587,7 @@ wxString rc2wxr::GetToken() { -wxString tok=""; +wxString tok=wxEmptyString; @@ -642,7 +643,7 @@ m_done=TRUE; } - + @@ -692,7 +693,7 @@ while (ch!=34) ReadChar(ch); - + ReadChar(ch); @@ -752,7 +753,7 @@ void rc2wxr::ParseComboBox() { -/* 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 */ @@ -770,11 +771,11 @@ ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxChoice,'','0','%s',",m_controlid,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxChoice,'','0','%s',"),m_controlid,varname.c_str()); -fprintf(m_wxr,"%i,%i,%i,%i,[],\\\n",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,[],\\\n"),x,y,width,height); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); @@ -788,39 +789,39 @@ void rc2wxr::ParseMenu(wxString name) { -wxString tok=""; +wxString tok=wxEmptyString; static int menuid=0; menuid++; -fprintf(m_wxr,"static char *MenuBar%i = \"menu(name = '%s',\\\n",menuid,name); +wxFprintf(m_wxr,_T("static char *MenuBar%i = \"menu(name = '%s',\\\n"),menuid,name.c_str()); -fprintf(m_wxr,"menu = \\\n"); +wxFprintf(m_wxr,_T("menu = \\\n")); -fprintf(m_wxr,"[\\\n"); +wxFprintf(m_wxr,_T("[\\\n")); -while ((tok!="BEGIN")&(tok!="{")) +while ((tok!=_T("BEGIN"))&(tok!=_T("{"))) tok=GetToken(); -while ((tok!="END")&(tok!="}")) +while ((tok!=_T("END"))&(tok!=_T("}"))) { tok=GetToken(); -if (tok=="POPUP") +if (tok==_T("POPUP")) { ParsePopupMenu(); - fprintf(m_wxr," ],\\\n"); + wxFprintf(m_wxr,_T(" ],\\\n")); } @@ -828,7 +829,7 @@ if (tok=="POPUP") -fprintf(m_wxr,"]).\";\n\n"); +wxFprintf(m_wxr,_T("]).\";\n\n")); } @@ -852,31 +853,31 @@ int spot; //Remove /t because it causes problems -spot=tok.First("\\t"); +spot=tok.First(_T("\\t")); tok=tok.Left(spot); -fprintf(m_wxr," ['%s',%i,'',\\\n",tok,menuitem); +wxFprintf(m_wxr,_T(" ['%s',%i,'',\\\n"),tok.c_str(),menuitem); -while ((tok!="BEGIN")&(tok!="{")) +while ((tok!=_T("BEGIN"))&(tok!=_T("{"))) tok=GetToken(); -while ((tok!="END")&(tok!="}")) +while ((tok!=_T("END"))&(tok!=_T("}"))) { tok=GetToken(); -if (tok=="MENUITEM") +if (tok==_T("MENUITEM")) { -if (PeekToken()=="SEPARATOR") +if (PeekToken()==_T("SEPARATOR")) -fprintf(m_wxr," [],\\\n"); +wxFprintf(m_wxr,_T(" [],\\\n")); else @@ -886,13 +887,13 @@ tok=GetQuoteField(); //Remove /t because it causes problems -spot=tok.First("\\t"); +spot=tok.First(_T("\\t")); tok=tok.Left(spot); menuitem++; -fprintf(m_wxr," ['%s',%i,''],\\\n",tok,menuitem); +wxFprintf(m_wxr,_T(" ['%s',%i,''],\\\n"),tok.c_str(),menuitem); } @@ -904,7 +905,7 @@ fprintf(m_wxr," ['%s',%i,''],\\\n",tok,menuitem); - + } @@ -950,21 +951,21 @@ kindctrl.MakeUpper(); -if (kindctrl=="MSCTLS_TRACKBAR32") +if (kindctrl==_T("MSCTLS_TRACKBAR32")) ParseSlider(label,varname); -if (kindctrl=="MSCTLS_PROGRESS32") +if (kindctrl==_T("MSCTLS_PROGRESS32")) ParseProgressBar(label,varname); -if (kindctrl=="BUTTON") +if (kindctrl==_T("BUTTON")) ParseCtrlButton(label,varname); } -/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | +/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,52,73,100,15 @@ -972,29 +973,30 @@ if (kindctrl=="BUTTON") -void rc2wxr::ParseSlider(wxString label, wxString varname) +void rc2wxr::ParseSlider(wxString WXUNUSED(label), wxString varname) { wxString tok; -while (ReadOrs(tok)); +while (ReadOrs(tok)) + ; -fprintf(m_wxr," control = [%i,wxSlider,'','wxSL_HORIZONTAL','%s',",m_controlid,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxSlider,'','wxSL_HORIZONTAL','%s',"),m_controlid,varname.c_str()); int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr,"%i,%i,%i,%i,",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height); -fprintf(m_wxr," 1, 1, 10,\\\n"); +wxFprintf(m_wxr,_T(" 1, 1, 10,\\\n")); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); } -/* +/* CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32", @@ -1002,25 +1004,26 @@ CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32", */ -void rc2wxr::ParseProgressBar(wxString label, wxString varname) +void rc2wxr::ParseProgressBar(wxString WXUNUSED(label), wxString varname) { wxString tok; -while (ReadOrs(tok)); +while (ReadOrs(tok)) + ; -fprintf(m_wxr," control = [%i,wxGauge,'','wxGA_HORIZONTAL','%s',",m_controlid,varname); +wxFprintf(m_wxr,_T(" control = [%i,wxGauge,'','wxGA_HORIZONTAL','%s',"),m_controlid,varname.c_str()); int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr,"%i,%i,%i,%i,",x,y,width,height); +wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height); -fprintf(m_wxr," 0, 10,\\\n"); +wxFprintf(m_wxr,_T(" 0, 10,\\\n")); -fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); +wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); } @@ -1064,37 +1067,39 @@ int x,y,width,height; -if (tok=="BS_AUTOCHECKBOX") +if (tok==_T("BS_AUTOCHECKBOX")) { - fprintf(m_wxr," control = [%i,wxCheckBox,'%s','0','%s',",m_controlid,label,varname); + wxFprintf(m_wxr,_T(" control = [%i,wxCheckBox,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str()); - while (ReadOrs(tok)); + while (ReadOrs(tok)) + ; ReadRect(x,y,width,height); - fprintf(m_wxr,"%i,%i,%i,%i,0,\\\n",x,y,width,height); + wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height); - fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); + wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); } -if (tok=="BS_AUTORADIOBUTTON") +if (tok==_T("BS_AUTORADIOBUTTON")) { - fprintf(m_wxr," control = [%i,wxRadioButton,'%s','0','%s',",m_controlid,label,varname); + wxFprintf(m_wxr,_T(" control = [%i,wxRadioButton,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str()); - while(ReadOrs(tok)); + while(ReadOrs(tok)) + ; ReadRect(x,y,width,height); - fprintf(m_wxr,"%i,%i,%i,%i,0,\\\n",x,y,width,height); + wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height); - fprintf(m_wxr,"[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"); + wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); }