]>
git.saurik.com Git - wxWidgets.git/blob - contrib/utils/convertrc/rc2xml.cpp
1 // rc2xml.cpp: implementation of the rc2xml class.
2 //Author: Brian Gavin 9/24/00
3 //License: wxWindows License
9 trans->Convert("Myfile.rc","Myfile.xml");
12 1. Figure how to fix memory leaks in all wxLists in this class
13 2. Find a way to rename MS Windows fonts so that they work
14 cross platform (wxGTK,etc)
15 3. Be able to abort incorrectly formated files without crashing
19 #pragma implementation "rc2xml.cpp"
20 #pragma interface "rc2xml.cpp"
23 // For compilers that support precompilation, includes "wx/wx.h".
24 #include <wx/wxprec.h>
30 // for all others, include the necessary headers (this file is usually all you
31 // need because it includes almost all "standard" wxWindows headers
39 #include "wx/resource.h"
40 #include <wx/textfile.h>
41 #include <wx/tokenzr.h>
45 //////////////////////////////////////////////////////////////////////
46 // Construction/Destruction
47 //////////////////////////////////////////////////////////////////////
52 m_bitmaplist
=new wxList(wxKEY_STRING
);
53 m_stringtable
=new wxList(wxKEY_STRING
);
54 m_iconlist
= new wxList(wxKEY_STRING
);
55 m_resourcelist
=new wxList(wxKEY_INTEGER
);
63 delete m_resourcelist
;
66 bool rc2xml::Convert(wxString rcfile
, wxString xmlfile
)
68 m_rc
.Open(rcfile
.c_str());
69 m_filesize
=m_rc
.Length();
72 result
=m_xmlfile
.Open(xmlfile
.c_str(),"w+t");
73 wxASSERT_MSG(result
,"Couldn't create XML file");
78 /* Write Basic header for XML file */
79 m_xmlfile
.Write("<?xml version=\"1.0\" ?>\n");
80 m_xmlfile
.Write("<resource>\n");
83 ParseResourceHeader();
84 //Gather all the resource we need for toolbars,menus, and etc
88 //Read in dialogs, toolbars,menus
91 m_xmlfile
.Write("</resource>\n");
99 void rc2xml::ParseDialog(wxString dlgname
)
102 static int dlgid
=999;
104 /* Make sure that this really is a dialog
105 microsoft reuses the keyword DIALOG for other things
108 //Microsoft notation?
109 if (token
=="DISCARDABLE")
114 //Error isn't a Dialog resource eject eject
115 if (!token
.IsNumber())
118 //Record x,y,width,height
119 int x
,y
,width
,height
;
120 ReadRect(x
,y
,width
,height
);
124 wxString ptsize
,face
;
126 m_xmlfile
.Write("\t<dialog");
127 //Avoid duplicate names this way
128 dlgname
.Replace("IDD_","DLG_");
129 WriteBasicInfo(x
,y
,width
,height
,dlgname
);
133 while ((token
!="BEGIN")&(token
!="{"))
135 if (token
=="CAPTION")
137 title
=GetQuoteField();
140 //TODO fix face name so that it is cross platform name
141 // FONT 8, "MS Sans Serif"
145 face
=GetQuoteField();
146 m_xmlfile
.Write("\t\t<font>\n");
147 m_xmlfile
.Write("\t\t\t<size>"+ptsize
+"</size>\n");
148 m_xmlfile
.Write("\t\t\t<face>"+face
+"</face>\n");
149 m_xmlfile
.Write("\t\t</font>\n");
155 m_xmlfile
.Write("\t<children>\n");
157 m_xmlfile
.Write("\t</children>\n");
158 m_xmlfile
.Write("\t</dialog>\n");
163 EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT
165 LTEXT "Bands",IDC_STATIC,11,86,21,8
166 EDITTEXT IDC_NAME,10,3,75,14,ES_AUTOHSCROLL
169 void rc2xml::ParseControls()
174 while ((token
!="END")&(token
!="}"))
178 else if (token
=="EDITTEXT")
180 else if (token
=="PUSHBUTTON")
182 else if (token
=="DEFPUSHBUTTON")
184 else if (token
=="GROUPBOX")
186 else if (token
=="COMBOBOX")
188 else if (token
=="CONTROL")
190 else if (token
=="LISTBOX")
192 else if (token
=="ICON")
194 else if (token
=="SCROLLBAR")
200 //LTEXT "Radius",IDC_STATIC,9,67,23,8
201 void rc2xml::ParseStaticText()
204 wxString phrase
,varname
;
205 phrase
=GetQuoteField();
207 int x
,y
,width
,height
;
208 ReadRect(x
,y
,width
,height
);
210 m_xmlfile
.Write("\t\t<statictext");
211 WriteBasicInfo(x
,y
,width
,height
,varname
);WriteLabel(phrase
);
212 m_xmlfile
.Write("\t\t</statictext>\n");
215 //EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
216 void rc2xml::ParseTextCtrl()
219 wxString varname
,style
;
221 int x
,y
,width
,height
;
222 ReadRect(x
,y
,width
,height
);
225 m_xmlfile
.Write("\t\t<textctrl");
226 WriteBasicInfo(x
,y
,width
,height
,varname
);
227 m_xmlfile
.Write("\t\t</textctrl>\n");
230 //PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP
231 void rc2xml::ParsePushButton()
234 wxString phrase
,varname
;
235 phrase
=GetQuoteField();
238 int x
,y
,width
,height
;
239 ReadRect(x
,y
,width
,height
);
241 m_xmlfile
.Write("\t\t<button");
242 WriteBasicInfo(x
,y
,width
,height
,varname
);
244 m_xmlfile
.Write("\t\t</button>\n");
249 bool rc2xml::Seperator(int ch
)
251 //if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')|(ch=='\t'))
252 if ((ch
==' ')|(ch
==',')|(ch
==13)|(ch
==10)|(ch
=='\t'))
264 void rc2xml::ParseGroupBox()
266 // GROUPBOX "Rotate",IDC_STATIC,1,1,71,79
268 wxString phrase
,varname
;
269 phrase
=GetQuoteField();
271 int x
,y
,width
,height
;
272 ReadRect(x
,y
,width
,height
);
274 m_xmlfile
.Write("\t\t<staticbox");
275 WriteBasicInfo(x
,y
,width
,height
,varname
);
277 m_xmlfile
.Write("\t\t</staticbox>\n");
280 void rc2xml::ReadRect(int & x
, int & y
, int & width
, int & height
)
284 width
=atoi(GetToken());
285 height
=atoi(GetToken());
288 wxString
rc2xml::GetToken()
306 while (Seperator(ch
))
319 while (!Seperator(ch
))
331 wxString
rc2xml::GetQuoteField()
351 void rc2xml::ReadChar(int &ch
)
356 if((result
>=m_filesize
))
359 result
=m_rc
.Read(&ch
,1);
368 void rc2xml::ParseComboBox()
370 /* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
371 WS_VSCROLL | WS_TABSTOP */
375 int x
,y
,width
,height
;
376 ReadRect(x
,y
,width
,height
);
378 m_xmlfile
.Write("\t\t<combobox");
379 WriteBasicInfo(x
,y
,width
,height
,varname
);
380 m_xmlfile
.Write("\n\t\t</combobox>\n");
384 void rc2xml::ParseMenu(wxString varname
)
388 //Write menubar to xml file
389 m_xmlfile
.Write("\t<menubar");
390 //Avoid duplicate names this way
391 varname
.Replace("IDR_","MB_");
393 m_xmlfile
.Write(">\n");
394 m_xmlfile
.Write("\t\t<children>\n");
396 while ((token
!="BEGIN")&(token
!="{"))
399 while ((token
!="END")&(token
!="}"))
407 m_xmlfile
.Write("\t\t</children>\n");
408 m_xmlfile
.Write("\t</menubar>\n");
411 void rc2xml::ParsePopupMenu()
413 static int menucount
=0;
415 wxString token
,name
,msg
,longhelp
,tip
;
416 token
=GetQuoteField();
418 //Remove \t because it causes problems
420 //spot=token.First("\\t");
421 //token=token.Left(spot);
424 //Generate a fake name since RC menus don't have one
425 name
<<"Menu_"<<menucount
;
426 m_xmlfile
.Write("\t\t<menu");
428 m_xmlfile
.Write(">\n");
430 m_xmlfile
.Write("\t\t\t<children>\n");
432 while ((token
!="BEGIN")&(token
!="{"))
435 while ((token
!="END")&(token
!="}"))
441 if (token
=="MENUITEM")
444 m_xmlfile
.Write("\t\t\t</children>\n");
445 m_xmlfile
.Write("\t\t\t</menu>\n");
448 wxString
rc2xml::PeekToken()
458 //MS Windows pain in the butt CONTROL
459 void rc2xml::ParseControlMS()
461 wxString label
,varname
,kindctrl
,token
;
464 if (token
.Contains("\""))
465 ParseNormalMSControl();
467 ParseWeirdMSControl();
471 /* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
472 TBS_NOTICKS | WS_TABSTOP,52,73,100,15
475 void rc2xml::ParseSlider(wxString label
, wxString varname
)
477 wxString token
,style
;
479 if (token
.Find("TBS_VERT")!=-1)
480 style
+="wxSL_VERTICAL";
481 //MFC RC Default is horizontal
483 style
+="wxSL_HORIZONTAL";
485 int x
,y
,width
,height
;
486 ReadRect(x
,y
,width
,height
);
487 m_xmlfile
.Write("\t\t<slider");
488 WriteBasicInfo(x
,y
,width
,height
,varname
);
490 m_xmlfile
.Write("\n\t\t</slider>\n");
494 CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32",
495 WS_BORDER,15,52,154,13
497 void rc2xml::ParseProgressBar(wxString label
, wxString varname
)
499 wxString token
,style
;
502 int x
,y
,width
,height
;
503 ReadRect(x
,y
,width
,height
);
505 //Always horizontal in MFC
506 m_xmlfile
.Write("\t\t<gauge");
507 WriteBasicInfo(x
,y
,width
,height
,varname
);
509 m_xmlfile
.Write("\t\t</gauge>\n");
512 bool rc2xml::ReadOrs(wxString
& orstring
)
517 if (token
.IsNumber())
521 while(PeekToken()==_T("|"))
524 orstring
+=GetToken();
526 orstring
+=GetToken();
531 //Is it a check button or a radio button
532 void rc2xml::ParseCtrlButton(wxString label
, wxString varname
)
536 int x
,y
,width
,height
;
538 if (token
.Find("BS_AUTOCHECKBOX")!=-1)
540 ReadRect(x
,y
,width
,height
);
541 m_xmlfile
.Write("\t\t<checkbox");
542 WriteBasicInfo(x
,y
,width
,height
,varname
);
544 m_xmlfile
.Write("\t\t</checkbox>\n");
547 if (token
.Find("BS_AUTORADIOBUTTON")!=-1)
549 ReadRect(x
,y
,width
,height
);
550 m_xmlfile
.Write("\t\t<radiobutton");
551 WriteBasicInfo(x
,y
,width
,height
,varname
);
553 m_xmlfile
.Write("\t\t</radiobutton>\n");
559 void rc2xml::WriteSize(int width
, int height
)
562 msg
<<" <size>"<<width
<<","<<height
<<"d</size>";
563 m_xmlfile
.Write(msg
);
566 void rc2xml::WritePosition(int x
, int y
)
569 msg
<<" <pos>"<<x
<<","<<y
<<"d</pos>";
570 m_xmlfile
.Write(msg
);
573 void rc2xml::WriteTitle(wxString title
)
576 msg
=_T("\t\t<title>"+title
+"</title>\n");
577 m_xmlfile
.Write(msg
);
580 void rc2xml::WriteName(wxString name
)
583 //Try to convert any number ids into names
585 //Replace common MS ids with wxWindows ids
586 //I didn't do everyone of them
589 else if (name
=="IDCANCEL")
591 else if (name
=="IDAPPLY")
593 else if (name
=="ID_FILE_OPEN")
595 else if (name
=="ID_FILE_CLOSE")
597 else if (name
=="ID_FILE_SAVE")
599 else if (name
=="ID_FILE_SAVE_AS")
601 else if (name
=="ID_APP_EXIT")
603 else if (name
=="ID_FILE_PRINT")
605 else if (name
=="ID_FILE_PRINT_PREVIEW")
607 else if (name
=="ID_FILE_PRINT_SETUP")
608 name
="wxID_PRINT_SETUP";
609 else if (name
=="ID_APP_ABOUT")
611 else if (name
=="ID_EDIT_UNDO")
613 else if (name
=="ID_EDIT_CUT")
615 else if (name
=="ID_EDIT_COPY")
617 else if (name
=="ID_EDIT_PASTE")
620 m_xmlfile
.Write(" name= \""+name
+"\"");
623 void rc2xml::WriteLabel(wxString label
)
625 label
.Replace("&","$");
626 m_xmlfile
.Write("\t\t\t<label>"+label
+"</label>\n");
629 void rc2xml::WriteBasicInfo(int x
, int y
, int width
, int height
, wxString name
)
632 m_xmlfile
.Write(">\n");
633 m_xmlfile
.Write("\t\t\t");
635 WriteSize(width
,height
);
636 m_xmlfile
.Write("\n");
639 void rc2xml::WriteStyle(wxString style
)
641 if (style
.Length()==0)
643 m_xmlfile
.Write("\n\t\t<style>"+style
+"</style>\n");
646 LISTBOX IDC_LIST1,16,89,48,40,LBS_SORT | LBS_MULTIPLESEL |
647 LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
649 void rc2xml::ParseListBox()
654 int x
,y
,width
,height
;
655 ReadRect(x
,y
,width
,height
);
657 m_xmlfile
.Write("\t\t<listbox");
658 WriteBasicInfo(x
,y
,width
,height
,varname
);
659 m_xmlfile
.Write("\n\t\t</listbox>\n");
663 CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER |
664 WS_TABSTOP,103,110,40,14
666 void rc2xml::ParseRichEdit(wxString label
, wxString varname
)
669 //while (ReadOrs(token));
671 int x
,y
,width
,height
;
672 ReadRect(x
,y
,width
,height
);
674 //Make it a rich text control
675 style
+="wxTE_MULTILINE ";
676 m_xmlfile
.Write("\t\t<textctrl");
677 WriteBasicInfo(x
,y
,width
,height
,varname
);
679 m_xmlfile
.Write("\t\t</textctrl>\n");
683 CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,209,72,
686 void rc2xml::ParseSpinCtrl(wxString label
, wxString varname
)
688 wxString token
,style
;
691 if (token
.Find("UDS_HORZ")!=-1)
692 style
="wxSP_HORIZONTAL";
695 style
="wxSP_VERTICAL";
697 int x
,y
,width
,height
;
698 ReadRect(x
,y
,width
,height
);
699 m_xmlfile
.Write("\t\t<spinbutton");
700 WriteBasicInfo(x
,y
,width
,height
,varname
);
702 m_xmlfile
.Write("\n\t\t</spinbutton>\n");
706 void rc2xml::FirstPass()
708 wxString token
,prevtok
;
713 ParseBitmap(prevtok
);
714 else if (token
=="STRINGTABLE")
715 ParseStringTable(prevtok
);
716 else if (token
=="ICON")
723 void rc2xml::ParseBitmap(wxString varname
)
725 wxString token
,*bitmapfile
;
728 //Microsoft notation?
729 if (token
=="DISCARDABLE")
734 bitmapfile
=new wxString
;
735 *bitmapfile
=GetQuoteField();
736 m_bitmaplist
->Append(varname
,bitmapfile
);
741 void rc2xml::SecondPass()
743 wxString token
,prevtok
;
748 ParseDialog(prevtok
);
749 else if (token
=="MENU")
751 else if (token
=="TOOLBAR")
752 ParseToolBar(prevtok
);
759 void rc2xml::ParseToolBar(wxString varname
)
763 wxASSERT_MSG(token
=="DISCARDABLE","Error in toolbar parsing");
764 //Look up bitmap for toolbar and load
765 wxNode
*node
=m_bitmaplist
->Find(LookUpId(varname
));
766 wxString
*bitmappath
;
767 bitmappath
=(wxString
*)node
->Data();
769 if (!bitmap
.LoadFile(*bitmappath
,wxBITMAP_TYPE_BMP
))
770 wxLogError("Unable to load bitmap:"+*bitmappath
);
772 //Write toolbar to xml file
773 m_xmlfile
.Write(" <toolbar");
774 //Avoid duplicate names this way
775 varname
.Replace("IDR_","TB_");
777 m_xmlfile
.Write(">\n");
782 m_xmlfile
.Write("\t\t<children>\n");
784 //Grab width and height
786 width
=atoi(GetToken());
787 height
=atoi(GetToken());
790 wxString buttonname
,msg
,tip
,longhelp
;
792 while ((token
!="BEGIN"))
795 while ((token
!="END")&(token
!="}"))
799 buttonname
=GetToken();
800 m_xmlfile
.Write("\t\t\t<tool");
801 WriteName(buttonname
);
802 m_xmlfile
.Write(">\n");
803 //Write tool tip if any
804 if (LookUpString(buttonname
,msg
))
806 SplitHelp(msg
,tip
,longhelp
);
807 m_xmlfile
.Write("\t\t\t\t<tooltip>"+tip
+"</tooltip>\n");
808 m_xmlfile
.Write(" <longhelp>"+longhelp
+"</longhelp>\n");
810 //Make a bitmap file name
811 buttonname
=CleanName(buttonname
);
813 m_xmlfile
.Write("\t\t\t\t<bitmap>"+buttonname
+"</bitmap>\n");
814 WriteToolButton(buttonname
,c
,width
,height
,bitmap
);
815 m_xmlfile
.Write("\t\t\t</tool>\n");
818 else if (token
=="SEPARATOR")
820 m_xmlfile
.Write("\t\t\t<separator/>\n");
824 m_xmlfile
.Write("\t</children>\n");
825 m_xmlfile
.Write("\t</toolbar>\n");
828 //Extract bitmaps from larger toolbar bitmap
829 void rc2xml::WriteToolButton(wxString name
,int index
, int width
, int height
, wxBitmap bitmap
)
833 wxRect
r(x
,0,width
,height
);
835 little
=bitmap
.GetSubBitmap(r
);
836 little
.SaveFile(name
,wxBITMAP_TYPE_BMP
);
839 void rc2xml::ParseStringTable(wxString varname
)
843 while ((token
!="BEGIN"))
848 while ((token
!="END")&(token
!="}"))
851 *msg
=GetQuoteField();
852 m_stringtable
->Append(token
,msg
);
858 bool rc2xml::LookUpString(wxString strid
,wxString
& st
)
860 wxNode
*node
=m_stringtable
->Find(strid
);
865 s
=(wxString
*)node
->Data();
871 bool rc2xml::SplitHelp(wxString msg
, wxString
&shorthelp
, wxString
&longhelp
)
874 spot
=msg
.Find("\\n");
881 longhelp
=msg
.Left(spot
);
882 spot
=msg
.Length()-spot
-2;
883 shorthelp
=msg
.Right(spot
);
887 void rc2xml::ParseMenuItem()
889 wxString token
,name
,msg
,tip
,longhelp
;
891 if (PeekToken()=="SEPARATOR")
893 m_xmlfile
.Write("\t\t\t<separator/>\n");
897 token
=GetQuoteField();
899 //Remove \t because it causes problems
900 //spot=token.First("\\t");
901 //token=token.Left(spot);
902 m_xmlfile
.Write("\t\t\t<menuitem");
904 m_xmlfile
.Write(">\n");
906 //Look up help if any listed in stringtable
907 if (LookUpString(name
,msg
))
909 SplitHelp(msg
,tip
,longhelp
);
910 m_xmlfile
.Write("\t\t\t<help>"
911 +longhelp
+"</help>\n");
913 //look for extra attributes like checked and break
916 while ((ptoken
!="MENUITEM")&(ptoken
!="POPUP")&(ptoken
!="END"))
919 if (token
=="CHECKED")
920 m_xmlfile
.Write("\t\t\t<checkable>1</checkable>\n");
921 else if (token
=="MENUBREAK");
922 //m_xmlfile.Write("\t\t\t</break>\n");
923 else if (token
=="GRAYED");
925 wxLogError("Unknown Menu Item token:"+token
);
929 m_xmlfile
.Write("\t\t\t</menuitem>\n");
933 //ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
934 void rc2xml::ParseIconStatic()
937 wxString varname
,iconname
;
942 int x
,y
,width
,height
;
943 ReadRect(x
,y
,width
,height
);
945 m_xmlfile
.Write("\t\t<staticbitmap");
946 WriteBasicInfo(x
,y
,width
,height
,varname
);
947 //Save icon as a bitmap
949 m_xmlfile
.Write("\t\t</staticbitmap>\n");
952 //IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico"
953 void rc2xml::ParseIcon(wxString varname
)
955 wxString token
,*iconfile
;
956 iconfile
=new wxString
;
959 *iconfile
=GetQuoteField();
960 m_iconlist
->Append(varname
,iconfile
);
965 wxString
rc2xml::CleanName(wxString name
)
968 name
.Replace("id_","");
969 name
.Replace("idr_","");
970 name
.Replace("idb_","");
971 name
.Replace("idc_","");
974 // And the award for most messed up control goes to...
975 // CONTROL IDB_FACE,IDC_STATIC,"Static",SS_BITMAP,26,62,32,30
976 void rc2xml::ParseStaticBitmap(wxString bitmapname
, wxString varname
)
984 int x
,y
,width
,height
;
985 ReadRect(x
,y
,width
,height
);
987 m_xmlfile
.Write("\t\t<staticbitmap");
988 WriteBasicInfo(x
,y
,width
,height
,varname
);
989 WriteBitmap(bitmapname
);
990 m_xmlfile
.Write("\t\t</staticbitmap>\n");
994 void rc2xml::ParseNormalMSControl()
996 wxString label
,varname
,kindctrl
;
998 label
=GetQuoteField();
1000 kindctrl
=GetQuoteField();
1001 kindctrl
.MakeUpper();
1003 if (kindctrl
=="MSCTLS_UPDOWN32")
1004 ParseSpinCtrl(label
,varname
);
1005 if (kindctrl
=="MSCTLS_TRACKBAR32")
1006 ParseSlider(label
,varname
);
1007 if (kindctrl
=="MSCTLS_PROGRESS32")
1008 ParseProgressBar(label
,varname
);
1009 if (kindctrl
=="SYSTREEVIEW32")
1010 ParseTreeCtrl(label
,varname
);
1011 if (kindctrl
=="SYSMONTHCAL32")
1012 ParseCalendar(label
,varname
);
1013 if (kindctrl
=="SYSLISTVIEW32")
1014 ParseListCtrl(label
,varname
);
1015 if (kindctrl
=="BUTTON")
1016 ParseCtrlButton(label
,varname
);
1017 if (kindctrl
=="RICHEDIT")
1018 ParseRichEdit(label
,varname
);
1022 void rc2xml::ParseWeirdMSControl()
1029 kindctrl
=GetQuoteField();
1030 kindctrl
.MakeUpper();
1031 // CONTROL IDB_FACE,IDC_STATIC,"Static",SS_BITMAP,26,62,32,30
1032 if (kindctrl
=="STATIC")
1034 if (PeekToken()=="SS_BITMAP")
1035 ParseStaticBitmap(id
,varname
);
1037 wxLogError("Unknown MS Control Static token");
1041 //SCROLLBAR IDC_SCROLLBAR1,219,56,10,40,SBS_VERT
1043 void rc2xml::ParseScrollBar()
1049 int x
,y
,width
,height
;
1050 ReadRect(x
,y
,width
,height
);
1055 if (token
.Find("SBS_VERT")!=-1)
1056 style
=_T("wxSB_VERTICAL");
1057 //Default MFC style is horizontal
1059 style
=_T("wxSB_HORIZONTAL");
1061 m_xmlfile
.Write("\t\t<scrollbar");
1062 WriteBasicInfo(x
,y
,width
,height
,varname
);
1064 m_xmlfile
.Write("\n\t\t</scrollbar>\n");
1067 // CONTROL "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP,
1070 void rc2xml::ParseTreeCtrl(wxString label
, wxString varname
)
1073 //while (ReadOrs(token));
1075 int x
,y
,width
,height
;
1076 ReadRect(x
,y
,width
,height
);
1077 m_xmlfile
.Write("\t\t<treectrl");
1078 WriteBasicInfo(x
,y
,width
,height
,varname
);
1079 m_xmlfile
.Write("\t\t</treectrl>\n");
1082 // CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32",
1083 //MCS_NOTODAY | WS_TABSTOP,105,71,129,89
1085 void rc2xml::ParseCalendar(wxString label
, wxString varname
)
1088 //while (ReadOrs(token));
1090 int x
,y
,width
,height
;
1091 ReadRect(x
,y
,width
,height
);
1092 m_xmlfile
.Write("\t\t<calendarctrl");
1093 WriteBasicInfo(x
,y
,width
,height
,varname
);
1094 m_xmlfile
.Write("\t\t</calendarctrl>\n");
1096 // CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP,
1099 void rc2xml::ParseListCtrl(wxString label
, wxString varname
)
1102 //while (ReadOrs(token));
1104 int x
,y
,width
,height
;
1105 ReadRect(x
,y
,width
,height
);
1106 m_xmlfile
.Write("\t\t<listctrl");
1107 WriteBasicInfo(x
,y
,width
,height
,varname
);
1108 m_xmlfile
.Write("\t\t</listctrl>\n");
1112 void rc2xml::WriteBitmap(wxString bitmapname
)
1115 wxNode
*node
=m_bitmaplist
->Find(LookUpId(bitmapname
));
1118 m_xmlfile
.Write("\t\t\t<bitmap>missingfile</bitmap>\n");
1119 wxLogError("Unable to find bitmap:"+bitmapname
);
1123 wxString
*bitmappath
;
1124 bitmappath
=(wxString
*)node
->Data();
1126 if (!bitmap
.LoadFile(*bitmappath
,wxBITMAP_TYPE_BMP
))
1127 wxLogError("Unable to load bitmap:"+*bitmappath
);
1129 //Make a bitmap file name
1130 bitmapname
=CleanName(bitmapname
);
1132 m_xmlfile
.Write("\t\t\t<bitmap>"+bitmapname
+"</bitmap>\n");
1133 bitmap
.SaveFile(bitmapname
,wxBITMAP_TYPE_BMP
);
1136 void rc2xml::WriteIcon(wxString iconname
)
1138 wxNode
*node
=m_iconlist
->Find(iconname
);
1141 m_xmlfile
.Write("\t\t\t<bitmap>missing_file</bitmap>\n");
1142 wxLogError("Unable to find icon:"+iconname
);
1145 iconpath
=(wxString
*)node
->Data();
1148 if (!icon
.LoadFile(*iconpath
,wxBITMAP_TYPE_ICO
))
1149 wxLogError("Unable to load icon:"+*iconpath
);
1151 bitmap
.CopyFromIcon(icon
);
1156 //Make a bitmap file name
1157 iconname
=CleanName(iconname
);
1159 m_xmlfile
.Write("\t\t\t<bitmap>"+iconname
+"</bitmap>\n");
1160 bitmap
.SaveFile(iconname
,wxBITMAP_TYPE_BMP
);
1164 /*Unfortunately sometimes the great MSVC Resource editor decides
1165 to use numbers instead of the word id. I have no idea why they
1166 do this, but that is the way it is.
1168 /* this is a quick and dirty way to parse the resource.h file
1169 it will not recognize #ifdef so it can be easily fooled
1171 void rc2xml::ParseResourceHeader()
1174 //Attempt to load resource.h in current path
1175 if (!r
.Open("resource.h"))
1177 wxLogError("Warining Unable to load resource.h file");
1183 wxStringTokenizer tok
;
1189 //Read through entire file
1190 for ( str
= r
.GetFirstLine(); !r
.Eof(); str
= r
.GetNextLine() )
1192 if (str
.Find("#define")!=-1)
1195 //Just ignore #define token
1197 v
=tok
.GetNextToken();
1198 id
=tok
.GetNextToken();
1201 varname
=new wxString
;
1204 m_resourcelist
->Append(n
,varname
);
1214 wxString
rc2xml::LookUpId(wxString id
)
1222 wxNode
*node
=m_resourcelist
->Find(n
);
1227 s
=(wxString
*)node
->Data();