X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/be5a51fb592f3fa2ba38ac6cd1e488d6d806058c..3285ee538be44537a0d4e43252db18f5e7362782:/contrib/utils/convertrc/rc2xml.cpp diff --git a/contrib/utils/convertrc/rc2xml.cpp b/contrib/utils/convertrc/rc2xml.cpp index fdc82ee0f3..ddc225b77b 100644 --- a/contrib/utils/convertrc/rc2xml.cpp +++ b/contrib/utils/convertrc/rc2xml.cpp @@ -16,8 +16,7 @@ cross platform (wxGTK,etc) */ #ifdef __GNUG__ -#pragma implementation "rc2xml.cpp" -#pragma interface "rc2xml.cpp" +#pragma implementation "rc2xml.h" #endif // For compilers that support precompilation, includes "wx/wx.h". @@ -49,7 +48,7 @@ cross platform (wxGTK,etc) rc2xml::rc2xml() { - m_done=FALSE; + m_done=false; m_bitmaplist=new wxList(wxKEY_STRING); m_stringtable=new wxList(wxKEY_STRING); m_iconlist = new wxList(wxKEY_STRING); @@ -83,7 +82,7 @@ bool rc2xml::Convert(wxString rcfile, wxString xmlfile) result=m_xmlfile.Open(xmlfile.c_str(),_T("w+t")); wxASSERT_MSG(result,_T("Couldn't create XML file")); if (!result) - return FALSE; + return false; /* Write Basic header for XML file */ @@ -94,7 +93,7 @@ bool rc2xml::Convert(wxString rcfile, wxString xmlfile) ParseResourceHeader(); //Gather all the resource we need for toolbars,menus, and etc FirstPass(); - m_done=FALSE; + m_done=false; m_rc.Seek(0); //Read in dialogs, toolbars,menus SecondPass(); @@ -105,7 +104,7 @@ bool rc2xml::Convert(wxString rcfile, wxString xmlfile) wxMessageBox(_("Conversion complete."), _("Done"), wxOK | wxICON_INFORMATION); -return TRUE; +return true; } @@ -146,22 +145,22 @@ microsoft reuses the keyword DIALOG for other things while ((token!=_T("BEGIN"))&(token!=_T("{"))) { - if (token==_T("CAPTION")) + if (token==_T("CAPTION")) { - title=GetQuoteField(); + title=GetQuoteField(); } //TODO fix face name so that it is cross platform name // FONT 8, "MS Sans Serif" if (token==_T("FONT")) - { + { ptsize=GetToken(); face=GetQuoteField(); m_xmlfile.Write(_T("\t\t\n")); m_xmlfile.Write(_T("\t\t\t")+ptsize+_T("\n")); m_xmlfile.Write(_T("\t\t\t")+face+_T("\n")); m_xmlfile.Write(_T("\t\t\n")); - } + } token=GetToken(); } @@ -308,9 +307,9 @@ void rc2xml::ParseRadioButton(wxString phrase, wxString varname) bool GotOrs; GotOrs = ReadOrs(token); if (ReadRect(x,y,width,height)) - if (GotOrs==FALSE) + if (GotOrs==false) ReadOrs(token); - if (token.Find(_T("WS_GROUP")) != -1) + if (token.Find(_T("WS_GROUP")) != wxNOT_FOUND) style += _T("wxRB_GROUP"); m_xmlfile.Write(_T("\t\t be this phrase+='n'; // escape else - phrase+=(char)ch; + phrase+=(char)ch; + lastch=ch; - ReadChar(ch); + ReadChar(ch); } return phrase; @@ -497,19 +516,18 @@ wxString rc2xml::GetStringQuote() void rc2xml::ReadChar(int &ch) { - int result; - result=m_rc.Tell(); + wxFileOffset result = m_rc.Tell(); if((result>=m_filesize)) - m_done=TRUE; + m_done=true; - result=m_rc.Read(&ch,1); + result = m_rc.Read(&ch,1); - if((result==-1)) - m_done=TRUE; + if( result == wxInvalidOffset ) + m_done=true; if(ch==EOF) - m_done=TRUE; + m_done=true; } void rc2xml::ParseComboBox(wxString varname) @@ -521,16 +539,16 @@ void rc2xml::ParseComboBox(wxString varname) bool GotOrs; GotOrs = ReadOrs(token); if (ReadRect(x,y,width,height)) - if (GotOrs==FALSE) + if (GotOrs==false) ReadOrs(token); m_xmlfile.Write(_T("\t\t\n")); @@ -602,25 +620,22 @@ void rc2xml::ParsePopupMenu() wxString rc2xml::PeekToken() { - wxString token; - int p; - p=m_rc.Tell(); - token=GetToken(); + wxFileOffset p = m_rc.Tell(); + wxString token=GetToken(); m_rc.Seek(p); return token; } + //MS Windows pain in the butt CONTROL void rc2xml::ParseControlMS() { - wxString label,varname,kindctrl,token; - token=PeekToken(); + wxString token = PeekToken(); if (token.Contains(_T("\""))) ParseNormalMSControl(); else ParseWeirdMSControl(); - } /* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | @@ -631,7 +646,7 @@ void rc2xml::ParseSlider(wxString WXUNUSED(label), wxString varname) { wxString token,style; ReadOrs(token); - if (token.Find(_T("TBS_VERT"))!=-1) + if (token.Find(_T("TBS_VERT"))!=wxNOT_FOUND) style+=_T("wxSL_VERTICAL"); //MFC RC Default is horizontal else @@ -670,7 +685,7 @@ bool rc2xml::ReadOrs(wxString & orstring) token=PeekToken(); if (token.IsNumber()) - return FALSE; + return false; orstring=GetToken(); while(PeekToken()==_T("|")) @@ -680,27 +695,26 @@ bool rc2xml::ReadOrs(wxString & orstring) //Grab next token orstring+=GetToken(); } - return TRUE; + return true; } //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(); + wxFileOffset p = m_rc.Tell(); ReadOrs(token); m_rc.Seek(p); - if (token.Find(_T("BS_AUTOCHECKBOX"))!=-1) + if (token.Find(_T("BS_AUTOCHECKBOX"))!=wxNOT_FOUND) ParseCheckBox(label, varname); - else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=-1)|| - (token.Find(_T("BS_RADIOBUTTON"))!=-1)) + else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=wxNOT_FOUND)|| + (token.Find(_T("BS_RADIOBUTTON"))!=wxNOT_FOUND)) ParseRadioButton(label, varname); - else if (token.Find(_T("BS_GROUPBOX"))!=-1) + else if (token.Find(_T("BS_GROUPBOX"))!=wxNOT_FOUND) ParseGroupBox(label, varname); - else // if ((token.Find("BS_PUSHBUTTON")!=-1)|| -// (token.Find("BS_DEFPUSHBUTTON")!=-1)) + else // if ((token.Find("BS_PUSHBUTTON")!=wxNOT_FOUND)|| +// (token.Find("BS_DEFPUSHBUTTON")!=wxNOT_FOUND)) ParsePushButton(label, varname); // make default case } @@ -777,6 +791,9 @@ name=LookUpId(name); void rc2xml::WriteLabel(wxString label) { label.Replace(_T("&"),_T("$")); + // changes by MS, handle '<' '>' characters within a label. + label.Replace(_T("<"),_T("<")); + label.Replace(_T(">"),_T(">")); m_xmlfile.Write(_T("\t\t\t\n")); } @@ -821,7 +838,7 @@ void rc2xml::ParseListBox(wxString varname) CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER | WS_TABSTOP,103,110,40,14 */ -void rc2xml::ParseRichEdit(wxString label, wxString varname) +void rc2xml::ParseRichEdit(wxString WXUNUSED(label), wxString varname) { wxString token; //while (ReadOrs(token)); @@ -846,7 +863,7 @@ void rc2xml::ParseSpinCtrl(wxString WXUNUSED(label), wxString varname) wxString token,style; ReadOrs(token); - if (token.Find(_T("UDS_HORZ"))!=-1) + if (token.Find(_T("UDS_HORZ"))!=wxNOT_FOUND) style=_T("wxSP_HORIZONTAL"); //MFC default else @@ -880,7 +897,8 @@ void rc2xml::FirstPass() void rc2xml::ParseBitmap(wxString varname) { - wxString token,*bitmapfile; + wxString token; + wxString *bitmapfile; token=PeekToken(); //Microsoft notation? @@ -928,7 +946,7 @@ void rc2xml::ParseToolBar(wxString varname) wxLogError(_T("Unable to load bitmap:")+*bitmappath); //Write toolbar to xml file - m_xmlfile.Write(_T(" ")+tip+_T("\n")); - m_xmlfile.Write(_T(" ")+longhelp+_T("\n")); + m_xmlfile.Write(_T("\t\t")+longhelp+_T("\n")); } //Make a bitmap file name buttonname=CleanName(buttonname); @@ -992,7 +1010,7 @@ void rc2xml::WriteToolButton(wxString name,int index, int width, int height, wxB little.SaveFile(m_targetpath+name,wxBITMAP_TYPE_BMP); } -void rc2xml::ParseStringTable(wxString varname) +void rc2xml::ParseStringTable(wxString WXUNUSED(varname)) { wxString token; token=GetToken(); @@ -1002,13 +1020,12 @@ void rc2xml::ParseStringTable(wxString varname) wxString *msg; while ((token!=_T("END"))&(token!=_T("}"))) - { + { msg=new wxString; *msg=GetStringQuote(); m_stringtable->Append(token,msg); token=GetToken(); - } - + } } bool rc2xml::LookUpString(wxString strid,wxString & st) @@ -1016,19 +1033,19 @@ bool rc2xml::LookUpString(wxString strid,wxString & st) wxNode *node=m_stringtable->Find(strid); wxString *s; if (node==NULL) - return FALSE; + return false; s=(wxString *)node->GetData(); st=*s; - return TRUE; + return true; } bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp) { int spot; spot=msg.Find(_T("\\n")); - if (spot==-1) + if (spot==wxNOT_FOUND) { shorthelp=msg; longhelp=msg; @@ -1037,7 +1054,7 @@ bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp) longhelp=msg.Left(spot); spot=msg.Length()-spot-2; shorthelp=msg.Right(spot); - return TRUE; + return true; } void rc2xml::ParseMenuItem() @@ -1118,7 +1135,8 @@ void rc2xml::ParseIconStatic() //IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico" void rc2xml::ParseIcon(wxString varname) { - wxString token,*iconfile; + wxString token; + wxString *iconfile; iconfile=new wxString; token=PeekToken(); @@ -1162,70 +1180,63 @@ void rc2xml::ParseStaticBitmap(wxString bitmapname, wxString varname) void rc2xml::ParseNormalMSControl() { -wxString label,varname,kindctrl; - -label=GetQuoteField(); -varname=GetToken(); -kindctrl=GetQuoteField(); -kindctrl.MakeUpper(); + wxString label=GetQuoteField(); + wxString varname=GetToken(); + wxString kindctrl=GetQuoteField(); + kindctrl.MakeUpper(); if (kindctrl==_T("MSCTLS_UPDOWN32")) ParseSpinCtrl(label,varname); - if (kindctrl==_T("MSCTLS_TRACKBAR32")) + else if (kindctrl==_T("MSCTLS_TRACKBAR32")) ParseSlider(label,varname); - if (kindctrl==_T("MSCTLS_PROGRESS32")) + else if (kindctrl==_T("MSCTLS_PROGRESS32")) ParseProgressBar(label,varname); - if (kindctrl==_T("SYSTREEVIEW32")) + else if (kindctrl==_T("SYSTREEVIEW32")) ParseTreeCtrl(label,varname); - if (kindctrl==_T("SYSMONTHCAL32")) + else if (kindctrl==_T("SYSMONTHCAL32")) ParseCalendar(label,varname); - if (kindctrl==_T("SYSLISTVIEW32")) + else if (kindctrl==_T("SYSLISTVIEW32")) ParseListCtrl(label,varname); - if (kindctrl==_T("BUTTON")) + else if (kindctrl==_T("BUTTON")) ParseCtrlButton(label,varname); - if (kindctrl==_T("RICHEDIT")) + else if (kindctrl==_T("RICHEDIT")) ParseRichEdit(label,varname); - if (kindctrl==_T("STATIC")) - { + else if (kindctrl==_T("STATIC")) + { wxString token; - int p=m_rc.Tell(); + wxFileOffset p = m_rc.Tell(); ReadOrs(token); m_rc.Seek(p); - if (token.Find(_T("SS_BITMAP"))!=-1) + if (token.Find(_T("SS_BITMAP"))!=wxNOT_FOUND) ParseStaticBitmap(label,varname); else ParseStaticText(label,varname); - } - if (kindctrl==_T("EDIT")) + } + else if (kindctrl==_T("EDIT")) ParseTextCtrl(varname); - if (kindctrl==_T("LISTBOX")) + else if (kindctrl==_T("LISTBOX")) ParseListBox(varname); - if (kindctrl==_T("COMBOBOX")) + else if (kindctrl==_T("COMBOBOX")) ParseComboBox(varname); - } void rc2xml::ParseWeirdMSControl() { - wxString kindctrl; - wxString varname; - wxString id; - id=GetToken(); - varname=GetToken(); - kindctrl=GetQuoteField(); + wxString id = GetToken(); + wxString varname = GetToken(); + wxString kindctrl = GetQuoteField(); kindctrl.MakeUpper(); // CONTROL IDB_FACE,IDC_STATIC,"Static",SS_BITMAP,26,62,32,30 if (kindctrl==_T("STATIC")) - { + { if (PeekToken()==_T("SS_BITMAP")) ParseStaticBitmap(id,varname); else wxLogError(_T("Unknown MS Control Static token")); - } - + } } -//SCROLLBAR IDC_SCROLLBAR1,219,56,10,40,SBS_VERT +//SCROLLBAR IDC_SCROLLBAR1,219,56,10,40,SBS_VERT void rc2xml::ParseScrollBar() { wxString token; @@ -1238,7 +1249,7 @@ void rc2xml::ParseScrollBar() ReadOrs(token); -if (token.Find(_T("SBS_VERT"))!=-1) +if (token.Find(_T("SBS_VERT"))!=wxNOT_FOUND) style=_T("wxSB_VERTICAL"); //Default MFC style is horizontal else @@ -1377,7 +1388,7 @@ wxTextFile r; //Read through entire file for ( str = r.GetFirstLine(); !r.Eof(); str = r.GetNextLine() ) { - if (str.Find(_T("#define"))!=-1) + if (str.Find(_T("#define"))!=wxNOT_FOUND) { tok.SetString(str); //Just ignore #define token