+void rc2xml::WriteBitmap(wxString bitmapname)
+{
+//Look up bitmap
+ wxNode *node=m_bitmaplist->Find(LookUpId(bitmapname));
+ if (node==NULL)
+ {
+ m_xmlfile.Write("\t\t\t<bitmap>missingfile</bitmap>\n");
+ wxLogError("Unable to find bitmap:"+bitmapname);
+ return;
+ }
+
+ wxString *bitmappath;
+ bitmappath=(wxString *)node->Data();
+
+ bitmapname=wxFileNameFromPath(*bitmappath);
+ wxBitmap bitmap;
+ if (!bitmap.LoadFile(*bitmappath,wxBITMAP_TYPE_BMP ))
+ wxLogError("Unable to load bitmap:"+*bitmappath);
+
+ //Make a bitmap file name
+ bitmapname=CleanName(bitmapname);
+ bitmapname+=".bmp";
+ m_xmlfile.Write("\t\t\t<bitmap>"+bitmapname+"</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<bitmap>missing_file</bitmap>\n");
+ wxLogError("Unable to find icon:"+iconname);
+ }
+ wxString *iconpath;
+ iconpath=(wxString *)node->Data();
+ wxIcon icon;
+ wxBitmap bitmap;
+ if (!icon.LoadFile(*iconpath,wxBITMAP_TYPE_ICO ))
+ wxLogError("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+=".bmp";
+ m_xmlfile.Write("\t\t\t<bitmap>"+iconname+"</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("resource.h"))
+ {
+ wxLogError("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("#define")!=-1)
+ {
+ 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->Data();
+ st=*s;
+return st;