X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c74caa095c12410bd6a555df248699cb35821a8d..289cd4e2dca6beefe137a73c32f43ec3bb8517c4:/contrib/utils/convertrc/rc2wxr.cpp diff --git a/contrib/utils/convertrc/rc2wxr.cpp b/contrib/utils/convertrc/rc2wxr.cpp index 8adf43bec5..11eb941376 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 @@ -77,7 +77,7 @@ rc2wxr::rc2wxr() { -m_done=FALSE; +m_done=false; m_controlid=6000; @@ -96,77 +96,36 @@ rc2wxr::~rc2wxr() void rc2wxr::Convert(wxString wxrfile, wxString rcfile) - { + m_rc.Open(rcfile); + m_filesize=m_rc.Length(); + if( (m_wxr = wxFopen( wxrfile, _T("wt") )) == NULL ) + { + return; + } -m_rc.Open(rcfile); - -m_filesize=m_rc.Length(); - -if( (m_wxr = fopen( wxrfile, "wt" )) == NULL ) - -{ - - return; - -} - - - - - -wxString tok,prevtok; - - - - - -while (!m_done) - -{ - - - -tok=GetToken(); - - - -if (tok=="DIALOG") - -{ - -ParseDialog(prevtok); - -} - - - - - -if (tok=="MENU") - -{ - -ParseMenu(prevtok); - -} - - - -prevtok=tok; - -} - - + wxString tok,prevtok; -fclose(m_wxr); + while (!m_done) + { + tok=GetToken(); -//fclose(m_rc); + if (tok==_T("DIALOG")) + { + ParseDialog(prevtok); + } -m_rc.Close(); + if (tok==_T("MENU")) + { + ParseMenu(prevtok); + } + prevtok=tok; + } + fclose(m_wxr); + m_rc.Close(); } @@ -233,7 +192,7 @@ tok=PeekToken(); //Microsoft notation? -if (tok=="DISCARDABLE") +if (tok==_T("DISCARDABLE")) { @@ -251,15 +210,15 @@ if (!tok.IsNumber()) //Generate Dialog text -fprintf(m_wxr,"static char *dialog%i = \"dialog(name = '%s',\\\n",dlgid,dlgname.c_str()); +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); @@ -269,7 +228,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); @@ -285,17 +244,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.c_str()); +wxFprintf(m_wxr,_T("title = '%s',\\\n"),title.c_str()); } @@ -303,17 +262,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")); } @@ -351,35 +310,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(); @@ -413,11 +372,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxStaticText,'%s','0','%s',",m_controlid,phrase.c_str(),varname.c_str()); +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")); } @@ -439,11 +398,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxTextCtrl,'','0','%s',",m_controlid,varname.c_str()); +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")); @@ -469,19 +428,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; @@ -491,11 +450,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxButton,'%s','0','%s',",c,phrase.c_str(),varname.c_str()); +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")); @@ -511,7 +470,7 @@ bool rc2wxr::Seperator(int ch) if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')) - return TRUE; + return true; @@ -519,13 +478,13 @@ if (ch==EOF) { -m_done=TRUE; +m_done=true; -return TRUE; +return true; } -return FALSE; +return false; } @@ -551,11 +510,11 @@ int x,y,width,height; ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxStaticBox,'%s','0','%s',",m_controlid,phrase.c_str(),varname.c_str()); +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")); @@ -569,13 +528,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()); @@ -587,7 +546,7 @@ wxString rc2wxr::GetToken() { -wxString tok=""; +wxString tok=wxEmptyString; @@ -595,7 +554,7 @@ if (m_rc.Eof()) { -m_done=TRUE; +m_done=true; return tok; @@ -611,7 +570,7 @@ if (ch==EOF) { -m_done=TRUE; +m_done=true; return tok; @@ -637,7 +596,7 @@ if (ch==EOF) { -m_done=TRUE; +m_done=true; @@ -663,7 +622,7 @@ ReadChar(ch); if (ch==EOF) - m_done=TRUE; + m_done=true; @@ -719,7 +678,7 @@ void rc2wxr::ReadChar(int &ch) { - int result; + int result; result=m_rc.Tell(); @@ -727,7 +686,7 @@ result=m_rc.Tell(); if((result>=m_filesize)) - m_done=TRUE; + m_done=true; @@ -737,13 +696,13 @@ result=m_rc.Read(&ch,1); if((result==-1)) - m_done=TRUE; + m_done=true; if(ch==EOF) - m_done=TRUE; + m_done=true; } @@ -771,11 +730,11 @@ ReadRect(x,y,width,height); -fprintf(m_wxr," control = [%i,wxChoice,'','0','%s',",m_controlid,varname.c_str()); +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")); @@ -789,47 +748,47 @@ 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.c_str()); +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")); - } + } } -fprintf(m_wxr,"]).\";\n\n"); +wxFprintf(m_wxr,_T("]).\";\n\n")); } @@ -853,31 +812,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.c_str(),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 @@ -887,13 +846,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.c_str(),menuitem); +wxFprintf(m_wxr,_T(" ['%s',%i,''],\\\n"),tok.c_str(),menuitem); } @@ -951,15 +910,15 @@ 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); @@ -973,25 +932,26 @@ 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.c_str()); +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")); } @@ -1003,25 +963,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.c_str()); +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")); } @@ -1041,7 +1002,7 @@ if (tok.IsNumber()) w=GetToken(); -return TRUE; +return true; } @@ -1065,37 +1026,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.c_str(),varname.c_str()); + 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.c_str(),varname.c_str()); + 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")); }