+
+void rc2xml::WriteBitmap(wxString bitmapname)
+{
+//Look up bitmap
+ wxNode *node=m_bitmaplist->Find(LookUpId(bitmapname));
+ if (node==NULL)
+ {
+ m_xmlfile.Write(_T("\t\t\t<bitmap>missingfile</bitmap>\n"));
+ wxLogError(_T("Unable to find bitmap:")+bitmapname);
+ return;
+ }
+
+ wxString *bitmappath;
+ bitmappath=(wxString *)node->GetData();
+
+ bitmapname=wxFileNameFromPath(*bitmappath);
+ wxBitmap bitmap;
+ if (!bitmap.LoadFile(*bitmappath,wxBITMAP_TYPE_BMP ))
+ wxLogError(_T("Unable to load bitmap:")+*bitmappath);
+
+ //Make a bitmap file name
+ bitmapname=CleanName(bitmapname);
+ bitmapname+=_T(".bmp");
+ m_xmlfile.Write(_T("\t\t\t<bitmap>")+bitmapname+_T("</bitmap>\n"));
+ bitmap.SaveFile(m_targetpath+bitmapname,wxBITMAP_TYPE_BMP);
+}
+
+void rc2xml::WriteIcon(wxString iconname)
+{
+wxNode *node=m_iconlist->Find(iconname);
+ if (node==NULL)
+ {
+ m_xmlfile.Write(_T("\t\t\t<bitmap>missing_file</bitmap>\n"));
+ wxLogError(_T("Unable to find icon:")+iconname);
+ }
+ wxString *iconpath;
+ iconpath=(wxString *)node->GetData();
+ wxIcon icon;
+ wxBitmap bitmap;
+ if (!icon.LoadFile(*iconpath,wxBITMAP_TYPE_ICO ))
+ wxLogError(_T("Unable to load icon:")+*iconpath);
+#ifdef __WXMSW__
+ bitmap.CopyFromIcon(icon);
+#else
+ bitmap = icon;
+#endif
+ iconname=wxFileNameFromPath(*iconpath);
+ //Make a bitmap file name
+ iconname=CleanName(iconname);
+ iconname+=_T(".bmp");
+ m_xmlfile.Write(_T("\t\t\t<bitmap>")+iconname+_T("</bitmap>\n"));
+ bitmap.SaveFile(m_targetpath+iconname,wxBITMAP_TYPE_BMP);
+
+
+}
+/*Unfortunately sometimes the great MSVC Resource editor decides
+to use numbers instead of the word id. I have no idea why they
+do this, but that is the way it is.
+*/
+/* this is a quick and dirty way to parse the resource.h file
+it will not recognize #ifdef so it can be easily fooled
+*/
+void rc2xml::ParseResourceHeader()
+{
+wxTextFile r;
+//Attempt to load resource.h in current path
+ if (!r.Open(_T("resource.h")))
+ {
+ wxLogError(_T("Warining Unable to load resource.h file"));
+ return;
+ }
+
+ wxString str;
+ wxString id,v;
+ wxStringTokenizer tok;
+ wxString *varname;
+
+
+ long n;
+
+//Read through entire file
+ for ( str = r.GetFirstLine(); !r.Eof(); str = r.GetNextLine() )
+ {
+ if (str.Find(_T("#define"))!=wxNOT_FOUND)
+ {
+ tok.SetString(str);
+ //Just ignore #define token
+ tok.GetNextToken();
+ v=tok.GetNextToken();
+ id=tok.GetNextToken();
+ if (id.IsNumber())
+ {
+ varname=new wxString;
+ id.ToLong(&n);
+ *varname=v;
+ m_resourcelist->Append(n,varname);
+ }
+ }
+ }
+
+
+
+}
+
+
+wxString rc2xml::LookUpId(wxString id)
+{
+wxString st;
+
+if (!id.IsNumber())
+ return id;
+long n;
+id.ToLong(&n);
+wxNode *node=m_resourcelist->Find(n);
+ wxString *s;
+ if (node==NULL)
+ return id;
+
+ s=(wxString *)node->GetData();
+ st=*s;
+return st;
+}