1 // wxr2xml.cpp: implementation of the wxr2xml class.
3 // only tested on wxMSW so far
4 // License: wxWindows Liscense
5 // ////////////////////////////////////////////////////////////////////
12 trans->Convert("Myfile.wxr","Myfile.xml");
15 // For compilers that support precompilation, includes "wx/wx.h".
16 #include "wx/wxprec.h"
28 // ////////////////////////////////////////////////////////////////////
29 // Construction/Destruction
30 // ////////////////////////////////////////////////////////////////////
40 bool wxr2xml::Convert(wxString wxrfile
, wxString xmlfile
)
43 result
= m_xmlfile
.Open(xmlfile
.c_str(), _T("w+t"));
44 wxASSERT_MSG(result
, _T("Couldn't create XML file"));
48 result
= m_table
.ParseResourceFile(wxrfile
);
49 wxASSERT_MSG(result
, _T("Couldn't Load WXR file"));
52 // Write basic xml header
53 m_xmlfile
.Write(_T("<?xml version=\"1.0\" ?>\n"));
54 m_xmlfile
.Write(_T("<resource>\n"));
55 result
= ParseResources();
56 m_xmlfile
.Write(_T("</resource>\n"));
63 bool wxr2xml::ParseResources()
66 wxHashTable::Node
*node
;
68 node
= m_table
.Next();
71 wxItemResource
*res
= (wxItemResource
*) node
->GetData();
72 wxString
resType(res
->GetType());
73 if (resType
== _T("wxDialog"))
75 else if (resType
== _T("wxPanel"))
77 else if (resType
== _T("wxPanel"))
79 else if (resType
== _T("wxMenu"))
81 else if (resType
== _T("wxBitmap"))
84 wxLogError(_T("Found unsupported resource ") + resType
);
85 node
= m_table
.Next();
90 void wxr2xml::ParsePanel(wxItemResource
* res
)
92 m_xmlfile
.Write(_T("\t<object class=\"wxPanel\""));
94 WriteControlInfo(res
);
95 m_xmlfile
.Write(_T("\n"));
97 m_xmlfile
.Write(_T("\t</object>\n\n"));
100 void wxr2xml::ParseDialog(wxItemResource
* res
)
103 m_xmlfile
.Write(_T("\t<object class=\"wxDialog\""));
104 WriteControlInfo(res
);
105 m_xmlfile
.Write(GetTitle(res
));
107 m_xmlfile
.Write(_T("\n"));
109 m_xmlfile
.Write(_T("\t</object>\n\n"));
112 void wxr2xml::ParseControls(wxItemResource
* res
)
114 wxNode
*node
= res
->GetChildren().GetFirst();
117 wxItemResource
*res
= (wxItemResource
*) node
->GetData();
118 wxString
resType(res
->GetType());
119 if (resType
== _T("wxButton"))
121 else if ((resType
== _T("wxTextCtrl")) | (resType
== _T("wxText"))
122 | (resType
== _T("wxMultiText")))
124 else if (resType
== _T("wxCheckBox"))
126 else if (resType
== _T("wxRadioBox"))
128 else if (resType
== _T("wxListBox"))
130 else if ((resType
== _T("wxStaticText")) | (resType
== _T("wxMessage")))
131 ParseStaticText(res
);
132 else if (resType
== _T("wxChoice"))
134 else if (resType
== _T("wxGauge"))
136 else if (resType
== _T("wxSlider"))
138 else if (resType
== _T("wxComboBox"))
140 else if (resType
== _T("wxRadioButton"))
141 ParseRadioButton(res
);
142 else if (resType
== _T("wxStaticBitmap"))
143 ParseStaticBitmap(res
);
144 else if (resType
== _T("wxScrollBar"))
146 else if ((resType
== _T("wxStaticBox")) | (resType
== _T("wxGroupBox")))
148 else if (resType
== _T("wxBitmapButton"))
149 ParseBitmapButton(res
);
151 wxLogError(_T("Found unsupported resource ") + resType
);
152 node
= node
->GetNext();
156 // Write out basic stuff every control has
157 // name,position,size,bg,fg
158 void wxr2xml::WriteControlInfo(wxItemResource
* res
)
160 m_xmlfile
.Write(GenerateName(res
));
161 m_xmlfile
.Write(_T(">\n"));
162 m_xmlfile
.Write(GetPosition(res
));
163 m_xmlfile
.Write(GetSize(res
));
164 m_xmlfile
.Write(GetStyles(res
));
168 wxString
wxr2xml::GetSize(wxItemResource
* res
)
172 msg
<< _T("\t\t\t\t<size>") << res
->GetWidth() << _T(",") << res
->GetHeight() << _T("d</size>\n");
174 msg
<< _T("\t\t\t\t<size>") << res
->GetWidth() << _T(",") << res
->GetHeight() << _T("</size>\n");
178 wxString
wxr2xml::GetPosition(wxItemResource
* res
)
182 msg
<< _T("\t\t\t\t<pos>") << res
->GetX() << _T(",") << res
->GetY() << _T("d</pos>\n");
184 msg
<< _T("\t\t\t\t<pos>") << res
->GetX() << _T(",") << res
->GetY() << _T("</pos>\n");
188 void wxr2xml::ParseButton(wxItemResource
* res
)
190 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxButton\""));
191 WriteControlInfo(res
);
192 m_xmlfile
.Write(GetLabel(res
));
193 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
196 void wxr2xml::ParseTextCtrl(wxItemResource
* res
)
198 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxTextCtrl\""));
199 WriteControlInfo(res
);
200 m_xmlfile
.Write(GetValue4(res
));
201 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
205 wxString
wxr2xml::GetTitle(wxItemResource
* res
)
208 msg
= _T("\t\t\t\t<title>") + res
->GetTitle() + _T("</title>");
212 wxString
wxr2xml::GetValue4(wxItemResource
* res
)
215 msg
= _T("\t\t\t\t<value>") + res
->GetValue4() + _T("</value>\n");
219 void wxr2xml::ParseCheckBox(wxItemResource
* res
)
221 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxCheckBox\""));
222 WriteControlInfo(res
);
223 m_xmlfile
.Write(GetLabel(res
));
224 m_xmlfile
.Write(GetCheckStatus(res
));
225 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
228 wxString
wxr2xml::GetLabel(wxItemResource
* res
)
230 return _T("\t\t\t\t<label>") + res
->GetTitle() + _T("</label>\n");
233 void wxr2xml::ParseRadioBox(wxItemResource
* res
)
235 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxRadioBox\""));
236 WriteControlInfo(res
);
237 m_xmlfile
.Write(GetLabel(res
));
238 // Add radio box items
239 WriteStringList(res
);
241 m_xmlfile
.Write(GetDimension(res
));
242 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
245 void wxr2xml::ParseListBox(wxItemResource
* res
)
247 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxListBox\""));
248 WriteControlInfo(res
);
249 WriteStringList(res
);
250 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
253 void wxr2xml::ParseStaticText(wxItemResource
* res
)
255 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticText\""));
256 WriteControlInfo(res
);
257 m_xmlfile
.Write(GetLabel(res
));
258 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
261 void wxr2xml::ParseStaticBox(wxItemResource
* res
)
263 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticBox\""));
264 WriteControlInfo(res
);
265 m_xmlfile
.Write(GetLabel(res
));
266 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
269 void wxr2xml::WriteStringList(wxItemResource
* res
)
271 m_xmlfile
.Write(_T("\t\t\t\t<content>\n"));
272 for (wxStringListNode
* node
= res
->GetStringValues().GetFirst();
273 node
;node
= node
->GetNext()) {
274 const wxString s1
= node
->GetData();
275 m_xmlfile
.Write(_T("\t\t\t\t\t<item>") + s1
+ _T("</item>\n"));
277 m_xmlfile
.Write(_T("\t\t\t\t</content>\n"));
280 void wxr2xml::ParseChoice(wxItemResource
* res
)
282 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxChoice\""));
283 WriteControlInfo(res
);
285 WriteStringList(res
);
286 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
289 void wxr2xml::ParseGauge(wxItemResource
* res
)
291 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxGauge\""));
292 WriteControlInfo(res
);
293 m_xmlfile
.Write(GetValue1(res
));
294 m_xmlfile
.Write(GetRange(res
));
295 m_xmlfile
.Write(_T("\n\t\t\t</object>\n"));
298 wxString
wxr2xml::GetValue1(wxItemResource
* res
)
301 msg
<< _T("\t\t\t\t<value>") << res
->GetValue1() << _T("</value>\n");
305 wxString
wxr2xml::GetRange(wxItemResource
* res
)
308 msg
<< _T("\t\t\t\t<range>") << res
->GetValue2() << _T("</range>");
312 void wxr2xml::ParseSlider(wxItemResource
* res
)
314 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxSlider\""));
315 WriteControlInfo(res
);
316 m_xmlfile
.Write(GetValue1(res
));
317 m_xmlfile
.Write(GetMax(res
));
318 m_xmlfile
.Write(GetMin(res
));
319 m_xmlfile
.Write(_T("\n\t\t\t</object>\n"));
322 wxString
wxr2xml::GetMax(wxItemResource
* res
)
325 msg
<< _T("\t\t\t\t<max>") << res
->GetValue3() << _T("</max>\n");
329 wxString
wxr2xml::GetMin(wxItemResource
* res
)
332 msg
<< _T("\t\t\t\t<min>") << res
->GetValue2() << _T("</min>");
336 void wxr2xml::ParseComboBox(wxItemResource
* res
)
338 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxComboBox\""));
339 WriteControlInfo(res
);
341 WriteStringList(res
);
342 m_xmlfile
.Write(_T("\n\t\t\t</object>\n"));
345 void wxr2xml::ParseRadioButton(wxItemResource
* res
)
347 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxRadioButton\""));
348 WriteControlInfo(res
);
349 m_xmlfile
.Write(GetLabel(res
));
352 m_xmlfile
.Write(GetValue1(res
));
353 m_xmlfile
.Write(GetCheckStatus(res
));
354 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
357 void wxr2xml::ParseScrollBar(wxItemResource
* res
)
359 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxScrollBar\""));
360 WriteControlInfo(res
);
361 m_xmlfile
.Write(GetValue1(res
));
362 m_xmlfile
.Write(_T("\t\t\t\t<thumbsize>")+GetValue2(res
)+_T("</thumbsize>\n"));
363 m_xmlfile
.Write(_T("\t\t\t\t<range>")+GetValue3(res
)+_T("</range>\n"));
364 m_xmlfile
.Write(_T("\t\t\t\t<pagesize>")+GetValue5(res
)+_T("</pagesize>\n"));
365 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
368 wxString
wxr2xml::GetCheckStatus(wxItemResource
* res
)
371 msg
<< _T("\t\t\t\t<checked>") << res
->GetValue1() << _T("</checked>\n");
375 wxString
wxr2xml::GetStyles(wxItemResource
* res
)
377 // Very crude way to get styles
380 restype
= res
->GetType();
381 style
= res
->GetStyle();
383 s
= _T("\t\t\t\t<style>");
385 // Common styles for all controls
386 if (style
& wxSIMPLE_BORDER
)
387 s
+= _T("wxSIMPLE_BORDER|");
388 if (style
& wxSUNKEN_BORDER
)
389 s
+= _T("wxSUNKEN_BORDER|");
390 if (style
& wxSIMPLE_BORDER
)
391 s
+= _T("wxSIMPLE_BORDER|");
392 if (style
& wxDOUBLE_BORDER
)
393 s
+= _T("wxDOUBLE_BORDER|");
394 if (style
& wxRAISED_BORDER
)
395 s
+= _T("wxRAISED_BORDER|");
396 if (style
& wxTRANSPARENT_WINDOW
)
397 s
+= _T("wxTRANSPARENT_WINDOW|");
398 if (style
& wxWANTS_CHARS
)
399 s
+= _T("wxWANTS_CHARS|");
400 if (style
& wxNO_FULL_REPAINT_ON_RESIZE
)
401 s
+= _T("wxNO_FULL_REPAINT_ON_RESIZE|");
403 if (restype
== _T("wxDialog"))
405 if (style
& wxDEFAULT_DIALOG_STYLE
)
406 s
+= _T("wxDEFAULT_DIALOG_STYLE|");
407 #if WXWIN_COMPATIBILITY_2_6
408 if (style
& wxDIALOG_MODAL
)
409 s
+= _T("wxDIALOG_MODAL|");
410 if (style
& wxDIALOG_MODELESS
)
411 s
+= _T("wxDIALOG_MODELESS|");
414 #endif // WXWIN_COMPATIBILITY_2_6
415 if (style
& wxTAB_TRAVERSAL
)
416 s
+= _T("wxTAB_TRAVERSAL|");
417 if (style
& wxWS_EX_VALIDATE_RECURSIVELY
)
418 s
+= _T("wxWS_EX_VALIDATE_RECURSIVELY|");
419 if (style
& wxSTAY_ON_TOP
)
420 s
+= _T("wxSTAY_ON_TOP|");
421 if (style
& wxCAPTION
)
422 s
+= _T("wxCAPTION|");
423 if (style
& wxRESIZE_BORDER
)
424 s
+= _T("wxRESIZE_BORDER|");
425 if (style
& wxRESIZE_BOX
)
426 s
+= _T("wxRESIZE_BOX|");
427 if (style
& wxRESIZE_BORDER
)
428 s
+= _T("wxRESIZE_BORDER|");
429 if (style
& wxSYSTEM_MENU
)
430 s
+= _T("wxSYSTEM_MENU|");
431 if (style
& wxCLIP_CHILDREN
)
432 s
+= _T("wxCLIP_CHILDREN|");
435 if (restype
== _T("wxPanel"))
437 if (style
& wxCLIP_CHILDREN
)
438 s
+= _T("wxCLIP_CHILDREN|");
439 #if WXWIN_COMPATIBILITY_2_6
442 #endif // WXWIN_COMPATIBILITY_2_6
443 if (style
& wxTAB_TRAVERSAL
)
444 s
+= _T("wxTAB_TRAVERSAL|");
445 if (style
& wxWS_EX_VALIDATE_RECURSIVELY
)
446 s
+= _T("wxWS_EX_VALIDATE_RECURSIVELY|");
449 if (restype
== _T("wxComboBox"))
451 if (style
& wxCB_SORT
)
452 s
+= _T("wxCB_SORT|");
453 if (style
& wxCB_SIMPLE
)
454 s
+= _T("wxCB_SIMPLE|");
455 if (style
& wxCB_READONLY
)
456 s
+= _T("wxCB_READONLY|");
457 if (style
& wxCB_DROPDOWN
)
458 s
+= _T("wxCB_DROPDOWN|");
461 if (restype
== _T("wxGauge"))
463 if (style
& wxGA_HORIZONTAL
)
464 s
+= _T("wxGA_HORIZONTAL|");
465 if (style
& wxGA_VERTICAL
)
466 s
+= _T("wxGA_VERTICAL|");
468 if (style
& wxGA_SMOOTH
)
469 s
+= _T("wxGA_SMOOTH|");
472 if (restype
== _T("wxRadioButton"))
474 if (style
& wxRB_GROUP
)
475 s
+= _T("wxRB_GROUP|");
478 if (restype
== _T("wxStaticText"))
480 if (style
& wxST_NO_AUTORESIZE
)
481 s
+= _T("wxST_NO_AUTORESIZEL|");
484 if (restype
== _T("wxRadioBox"))
486 if (style
& wxRA_HORIZONTAL
)
487 s
+= _T("wxRA_HORIZONTAL|");
488 if (style
& wxRA_SPECIFY_COLS
)
489 s
+= _T("wxRA_SPECIFY_COLS|");
490 if (style
& wxRA_SPECIFY_ROWS
)
491 s
+= _T("wxRA_SPECIFY_ROWS|");
492 if (style
& wxRA_VERTICAL
)
493 s
+= _T("wxRA_VERTICAL|");
496 if (restype
== _T("wxListBox"))
498 if (style
& wxLB_SINGLE
)
499 s
+= _T("wxLB_SINGLE|");
500 if (style
& wxLB_MULTIPLE
)
501 s
+= _T("wxLB_MULTIPLE|");
502 if (style
& wxLB_EXTENDED
)
503 s
+= _T("wxLB_EXTENDED|");
504 if (style
& wxLB_HSCROLL
)
505 s
+= _T("wxLB_HSCROLL|");
506 if (style
& wxLB_ALWAYS_SB
)
507 s
+= _T("wxLB_ALWAYS_SB|");
508 if (style
& wxLB_NEEDED_SB
)
509 s
+= _T("wxLB_NEEDED_SB|");
510 if (style
& wxLB_SORT
)
511 s
+= _T("wxLB_SORT|");
514 if (restype
== _T("wxTextCtrl"))
516 if (style
& wxTE_PROCESS_ENTER
)
517 s
+= _T("wxTE_PROCESS_ENTER|");
518 if (style
& wxTE_PROCESS_TAB
)
519 s
+= _T("wxTE_PROCESS_TAB|");
520 if (style
& wxTE_MULTILINE
)
521 s
+= _T("wxTE_MULTILINE|");
522 if (style
& wxTE_PASSWORD
)
523 s
+= _T("wxTE_PASSWORD|");
524 if (style
& wxTE_READONLY
)
525 s
+= _T("wxTE_READONLY|");
526 if (style
& wxHSCROLL
)
527 s
+= _T("wxHSCROLL|");
531 if (restype
== _T("wxScrollBar"))
533 if (style
& wxSB_HORIZONTAL
)
534 s
+= _T("wxSB_HORIZONTAL|");
535 if (style
& wxSB_VERTICAL
)
536 s
+= _T("wxSB_VERTICAL|");
542 return wxEmptyString
;
544 s
= s
.Truncate(l
- 1);
546 s
+= _T("</style>\n");
550 wxString
wxr2xml::GetDimension(wxItemResource
* res
)
553 msg
<< _T("\t\t\t\t<dimension>") << res
->GetValue1() << _T("</dimension>\n");
557 wxString
wxr2xml::GenerateName(wxItemResource
* res
)
560 name
= _T(" name=\"");
561 switch (res
->GetId()) {
563 name
+= _T("wxID_OK");
566 name
+= _T("wxID_CANCEL");
569 name
+= res
->GetName();
576 void wxr2xml::ParseMenuBar(wxItemResource
* res
)
578 wxItemResource
*child
;
579 wxNode
*node
= res
->GetChildren().GetFirst();
581 m_xmlfile
.Write(_T("\t<object class=\"wxMenuBar\" "));
582 m_xmlfile
.Write(GenerateName(res
));
583 m_xmlfile
.Write(_T(">\n"));
585 child
= (wxItemResource
*) node
->GetData();
587 node
= node
->GetNext();
590 m_xmlfile
.Write(_T("\t</object> \n\n"));
593 void wxr2xml::ParseMenu(wxItemResource
* res
)
595 wxItemResource
*child
;
596 wxNode
*node
= res
->GetChildren().GetFirst();
598 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxMenu\" "));
600 menuname
<< _T("name = \"menu_") << res
->GetValue1() << _T("\"");
601 m_xmlfile
.Write(menuname
);
602 m_xmlfile
.Write(_T(">\n"));
603 m_xmlfile
.Write(_T("\t\t\t\t<label>")
604 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
605 if (!res
->GetValue4().empty())
606 m_xmlfile
.Write(_T("\t\t\t\t<help>") + res
->GetValue4() +
608 // Read in menu items and additional menus
610 child
= (wxItemResource
*) node
->GetData();
611 if (!child
->GetChildren().GetFirst())
612 ParseMenuItem(child
);
615 node
= node
->GetNext();
617 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
620 void wxr2xml::ParseMenuItem(wxItemResource
* res
)
622 // Get Menu Item or Separator
623 if (res
->GetTitle().empty()) {
624 m_xmlfile
.Write(_T("\t\t\t<object class=\"separator\"/>\n"));
626 m_xmlfile
.Write(_T("\t\t\t\t<object class=\"wxMenuItem\" "));
628 menuname
<< _T("name = \"menuitem_") << res
->GetValue1() << _T("\"");
629 m_xmlfile
.Write(menuname
);
630 m_xmlfile
.Write(_T(">\n"));
631 m_xmlfile
.Write(_T("\t\t\t<label>")
632 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
633 if (!res
->GetValue4().empty())
634 m_xmlfile
.Write(_T("\t\t\t<help>") +
635 res
->GetValue4() + _T("</help>\n"));
636 if (res
->GetValue2())
637 m_xmlfile
.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
638 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
642 wxString
wxr2xml::FixMenuString(wxString phrase
)
644 phrase
.Replace(_T("&"), _T("$"));
648 void wxr2xml::ParseStaticBitmap(wxItemResource
* res
)
650 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticBitmap\""));
651 WriteControlInfo(res
);
652 // value4 holds bitmap name
654 bitmapname
= res
->GetValue4();
656 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
657 bitmapname
+= _T(".bmp");
658 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
659 m_xmlfile
.Write(_T("\n\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>"));
660 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
663 //Parse a bitmap resource
664 void wxr2xml::ParseBitmap(wxItemResource
* res
)
666 m_xmlfile
.Write(_T("\t<object class=\"wxBitmap\" "));
667 m_xmlfile
.Write(GenerateName(res
)+_T(">"));
669 bitmapname
= res
->GetName();
671 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
672 bitmapname
+= _T(".bmp");
673 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
674 m_xmlfile
.Write(bitmapname
);
675 m_xmlfile
.Write(_T("</object>\n\n"));
678 void wxr2xml::PanelStuff(wxItemResource
* res
)
680 if ((res
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
685 // If this is true ignore fonts, background color and use system
687 if ((res
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
688 m_systemdefaults
= true;
690 m_systemdefaults
= false;
694 wxString
wxr2xml::GetValue2(wxItemResource
*res
)
697 msg
<< res
->GetValue2();
701 wxString
wxr2xml::GetValue3(wxItemResource
*res
)
704 msg
<< res
->GetValue3();
709 wxString
wxr2xml::GetValue5(wxItemResource
*res
)
712 msg
<< res
->GetValue5();
717 void wxr2xml::ParseBitmapButton(wxItemResource
*res
)
720 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
721 WriteControlInfo(res
);
722 // value4 holds bitmap name
724 bitmapname
= res
->GetValue4();
726 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
727 bitmapname
+= _T(".bmp");
728 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
729 m_xmlfile
.Write(_T("\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>\n"));
731 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
734 void wxr2xml::WriteFontInfo(wxItemResource
*res
)
736 //if systems_defaults true just ignore the fonts
737 if (m_systemdefaults
)
741 if (!font
.GetRefData())
744 m_xmlfile
.Write(_T("\t\t\t<font>\n"));
745 //Get font point size,font family,weight,font style,underline
748 pt
=font
.GetPointSize();
749 msg
<<_T("\t\t\t\t<size>")<<pt
<<_T("</size>\n");
750 m_xmlfile
.Write(msg
);
755 if (font
.GetUnderlined())
756 m_xmlfile
.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
758 m_xmlfile
.Write(_T("\t\t\t</font>\n"));
761 //WARNING possible make here
762 //I wasn't really sure the right way to do this.
763 void wxr2xml::GetFontFace(wxFont font
)
765 int family
=font
.GetFamily();
772 m_xmlfile
.Write(_T("\t\t\t\t<face>decorative</face>\n"));
775 m_xmlfile
.Write(_T("\t\t\t\t<face>roman</face>\n"));
778 m_xmlfile
.Write(_T("\t\t\t\t<face>script</face>\n"));
781 m_xmlfile
.Write(_T("\t\t\t\t<face>swiss</face>\n"));
784 m_xmlfile
.Write(_T("\t\t\t\t<face>modern</face>\n"));
787 wxLogError(_T("Unknown font face"));
791 void wxr2xml::GetFontStyle(wxFont font
)
794 int style
=font
.GetStyle();
798 //since this is default no point in making file any larger
802 m_xmlfile
.Write(_T("<style>italic</style>\n"));
805 m_xmlfile
.Write(_T("<style>slant</style>\n"));
808 wxLogError(_T("Unknown font style"));
812 void wxr2xml::GetFontWeight(wxFont font
)
814 int weight
=font
.GetWeight();
818 //since this is default no point in making file any larger
822 m_xmlfile
.Write(_T("\t\t\t\t<weight>light</weight>\n"));
825 m_xmlfile
.Write(_T("\t\t\t\t<weight>bold</weight>\n"));
828 wxLogError(_T("Unknown font weight"));