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 // ////////////////////////////////////////////////////////////////////
42 bool wxr2xml::Convert(wxString wxrfile
, wxString xmlfile
)
45 result
= m_xmlfile
.Open(xmlfile
.c_str(), _T("w+t"));
46 wxASSERT_MSG(result
, _T("Couldn't create XML file"));
50 result
= m_table
.ParseResourceFile(wxrfile
);
51 wxASSERT_MSG(result
, _T("Couldn't Load WXR file"));
54 // Write basic xml header
55 m_xmlfile
.Write(_T("<?xml version=\"1.0\" ?>\n"));
56 m_xmlfile
.Write(_T("<resource>\n"));
57 result
= ParseResources();
58 m_xmlfile
.Write(_T("</resource>\n"));
65 bool wxr2xml::ParseResources()
68 wxHashTable::Node
*node
;
70 node
= m_table
.Next();
73 wxItemResource
*res
= (wxItemResource
*) node
->GetData();
74 wxString
resType(res
->GetType());
75 if (resType
== _T("wxDialog"))
77 else if (resType
== _T("wxPanel"))
79 else if (resType
== _T("wxPanel"))
81 else if (resType
== _T("wxMenu"))
83 else if (resType
== _T("wxBitmap"))
86 wxLogError(_T("Found unsupported resource ") + resType
);
87 node
= m_table
.Next();
92 void wxr2xml::ParsePanel(wxItemResource
* res
)
94 m_xmlfile
.Write(_T("\t<object class=\"wxPanel\""));
96 WriteControlInfo(res
);
97 m_xmlfile
.Write(_T("\n"));
99 m_xmlfile
.Write(_T("\t</object>\n\n"));
102 void wxr2xml::ParseDialog(wxItemResource
* res
)
105 m_xmlfile
.Write(_T("\t<object class=\"wxDialog\""));
106 WriteControlInfo(res
);
107 m_xmlfile
.Write(GetTitle(res
));
109 m_xmlfile
.Write(_T("\n"));
111 m_xmlfile
.Write(_T("\t</object>\n\n"));
114 void wxr2xml::ParseControls(wxItemResource
* res
)
116 wxNode
*node
= res
->GetChildren().GetFirst();
119 wxItemResource
*res
= (wxItemResource
*) node
->GetData();
120 wxString
resType(res
->GetType());
121 if (resType
== _T("wxButton"))
123 else if ((resType
== _T("wxTextCtrl")) | (resType
== _T("wxText"))
124 | (resType
== _T("wxMultiText")))
126 else if (resType
== _T("wxCheckBox"))
128 else if (resType
== _T("wxRadioBox"))
130 else if (resType
== _T("wxListBox"))
132 else if ((resType
== _T("wxStaticText")) | (resType
== _T("wxMessage")))
133 ParseStaticText(res
);
134 else if (resType
== _T("wxChoice"))
136 else if (resType
== _T("wxGauge"))
138 else if (resType
== _T("wxSlider"))
140 else if (resType
== _T("wxComboBox"))
142 else if (resType
== _T("wxRadioButton"))
143 ParseRadioButton(res
);
144 else if (resType
== _T("wxStaticBitmap"))
145 ParseStaticBitmap(res
);
146 else if (resType
== _T("wxScrollBar"))
148 else if ((resType
== _T("wxStaticBox")) | (resType
== _T("wxGroupBox")))
150 else if (resType
== _T("wxBitmapButton"))
151 ParseBitmapButton(res
);
153 wxLogError(_T("Found unsupported resource ") + resType
);
154 node
= node
->GetNext();
158 // Write out basic stuff every control has
159 // name,position,size,bg,fg
160 void wxr2xml::WriteControlInfo(wxItemResource
* res
)
162 m_xmlfile
.Write(GenerateName(res
));
163 m_xmlfile
.Write(_T(">\n"));
164 m_xmlfile
.Write(GetPosition(res
));
165 m_xmlfile
.Write(GetSize(res
));
166 m_xmlfile
.Write(GetStyles(res
));
170 wxString
wxr2xml::GetSize(wxItemResource
* res
)
174 msg
<< _T("\t\t\t\t<size>") << res
->GetWidth() << _T(",") << res
->GetHeight() << _T("d</size>\n");
176 msg
<< _T("\t\t\t\t<size>") << res
->GetWidth() << _T(",") << res
->GetHeight() << _T("</size>\n");
180 wxString
wxr2xml::GetPosition(wxItemResource
* res
)
184 msg
<< _T("\t\t\t\t<pos>") << res
->GetX() << _T(",") << res
->GetY() << _T("d</pos>\n");
186 msg
<< _T("\t\t\t\t<pos>") << res
->GetX() << _T(",") << res
->GetY() << _T("</pos>\n");
190 void wxr2xml::ParseButton(wxItemResource
* res
)
192 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxButton\""));
193 WriteControlInfo(res
);
194 m_xmlfile
.Write(GetLabel(res
));
195 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
198 void wxr2xml::ParseTextCtrl(wxItemResource
* res
)
200 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxTextCtrl\""));
201 WriteControlInfo(res
);
202 m_xmlfile
.Write(GetValue4(res
));
203 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
207 wxString
wxr2xml::GetTitle(wxItemResource
* res
)
210 msg
= _T("\t\t\t\t<title>") + res
->GetTitle() + _T("</title>");
214 wxString
wxr2xml::GetValue4(wxItemResource
* res
)
217 msg
= _T("\t\t\t\t<value>") + res
->GetValue4() + _T("</value>\n");
221 void wxr2xml::ParseCheckBox(wxItemResource
* res
)
223 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxCheckBox\""));
224 WriteControlInfo(res
);
225 m_xmlfile
.Write(GetLabel(res
));
226 m_xmlfile
.Write(GetCheckStatus(res
));
227 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
230 wxString
wxr2xml::GetLabel(wxItemResource
* res
)
232 return _T("\t\t\t\t<label>") + res
->GetTitle() + _T("</label>\n");
235 void wxr2xml::ParseRadioBox(wxItemResource
* res
)
237 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxRadioBox\""));
238 WriteControlInfo(res
);
239 m_xmlfile
.Write(GetLabel(res
));
240 // Add radio box items
241 WriteStringList(res
);
243 m_xmlfile
.Write(GetDimension(res
));
244 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
247 void wxr2xml::ParseListBox(wxItemResource
* res
)
249 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxListBox\""));
250 WriteControlInfo(res
);
251 WriteStringList(res
);
252 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
255 void wxr2xml::ParseStaticText(wxItemResource
* res
)
257 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticText\""));
258 WriteControlInfo(res
);
259 m_xmlfile
.Write(GetLabel(res
));
260 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
263 void wxr2xml::ParseStaticBox(wxItemResource
* res
)
265 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticBox\""));
266 WriteControlInfo(res
);
267 m_xmlfile
.Write(GetLabel(res
));
268 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
271 void wxr2xml::WriteStringList(wxItemResource
* res
)
273 m_xmlfile
.Write(_T("\t\t\t\t<content>\n"));
274 for (wxStringListNode
* node
= res
->GetStringValues().GetFirst();
275 node
;node
= node
->GetNext()) {
276 const wxString s1
= node
->GetData();
277 m_xmlfile
.Write(_T("\t\t\t\t\t<item>") + s1
+ _T("</item>\n"));
279 m_xmlfile
.Write(_T("\t\t\t\t</content>\n"));
282 void wxr2xml::ParseChoice(wxItemResource
* res
)
284 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxChoice\""));
285 WriteControlInfo(res
);
287 WriteStringList(res
);
288 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
291 void wxr2xml::ParseGauge(wxItemResource
* res
)
293 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxGauge\""));
294 WriteControlInfo(res
);
295 m_xmlfile
.Write(GetValue1(res
));
296 m_xmlfile
.Write(GetRange(res
));
297 m_xmlfile
.Write(_T("\n\t\t\t</object>\n"));
300 wxString
wxr2xml::GetValue1(wxItemResource
* res
)
303 msg
<< _T("\t\t\t\t<value>") << res
->GetValue1() << _T("</value>\n");
307 wxString
wxr2xml::GetRange(wxItemResource
* res
)
310 msg
<< _T("\t\t\t\t<range>") << res
->GetValue2() << _T("</range>");
314 void wxr2xml::ParseSlider(wxItemResource
* res
)
316 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxSlider\""));
317 WriteControlInfo(res
);
318 m_xmlfile
.Write(GetValue1(res
));
319 m_xmlfile
.Write(GetMax(res
));
320 m_xmlfile
.Write(GetMin(res
));
321 m_xmlfile
.Write(_T("\n\t\t\t</object>\n"));
324 wxString
wxr2xml::GetMax(wxItemResource
* res
)
327 msg
<< _T("\t\t\t\t<max>") << res
->GetValue3() << _T("</max>\n");
331 wxString
wxr2xml::GetMin(wxItemResource
* res
)
334 msg
<< _T("\t\t\t\t<min>") << res
->GetValue2() << _T("</min>");
338 void wxr2xml::ParseComboBox(wxItemResource
* res
)
340 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxComboBox\""));
341 WriteControlInfo(res
);
343 WriteStringList(res
);
344 m_xmlfile
.Write(_T("\n\t\t\t</object>\n"));
347 void wxr2xml::ParseRadioButton(wxItemResource
* res
)
349 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxRadioButton\""));
350 WriteControlInfo(res
);
351 m_xmlfile
.Write(GetLabel(res
));
354 m_xmlfile
.Write(GetValue1(res
));
355 m_xmlfile
.Write(GetCheckStatus(res
));
356 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
359 void wxr2xml::ParseScrollBar(wxItemResource
* res
)
361 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxScrollBar\""));
362 WriteControlInfo(res
);
363 m_xmlfile
.Write(GetValue1(res
));
364 m_xmlfile
.Write(_T("\t\t\t\t<thumbsize>")+GetValue2(res
)+_T("</thumbsize>\n"));
365 m_xmlfile
.Write(_T("\t\t\t\t<range>")+GetValue3(res
)+_T("</range>\n"));
366 m_xmlfile
.Write(_T("\t\t\t\t<pagesize>")+GetValue5(res
)+_T("</pagesize>\n"));
367 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
370 wxString
wxr2xml::GetCheckStatus(wxItemResource
* res
)
373 msg
<< _T("\t\t\t\t<checked>") << res
->GetValue1() << _T("</checked>\n");
377 wxString
wxr2xml::GetStyles(wxItemResource
* res
)
379 // Very crude way to get styles
382 restype
= res
->GetType();
383 style
= res
->GetStyle();
385 s
= _T("\t\t\t\t<style>");
387 // Common styles for all controls
388 if (style
& wxSIMPLE_BORDER
)
389 s
+= _T("wxSIMPLE_BORDER|");
390 if (style
& wxSUNKEN_BORDER
)
391 s
+= _T("wxSUNKEN_BORDER|");
392 if (style
& wxSIMPLE_BORDER
)
393 s
+= _T("wxSIMPLE_BORDER|");
394 if (style
& wxDOUBLE_BORDER
)
395 s
+= _T("wxDOUBLE_BORDER|");
396 if (style
& wxRAISED_BORDER
)
397 s
+= _T("wxRAISED_BORDER|");
398 if (style
& wxTRANSPARENT_WINDOW
)
399 s
+= _T("wxTRANSPARENT_WINDOW|");
400 if (style
& wxWANTS_CHARS
)
401 s
+= _T("wxWANTS_CHARS|");
402 if (style
& wxNO_FULL_REPAINT_ON_RESIZE
)
403 s
+= _T("wxNO_FULL_REPAINT_ON_RESIZE|");
405 if (restype
== _T("wxDialog"))
407 if (style
& wxDIALOG_MODAL
)
408 s
+= _T("wxDIALOG_MODAL|");
409 if (style
& wxDEFAULT_DIALOG_STYLE
)
410 s
+= _T("wxDEFAULT_DIALOG_STYLE|");
411 if (style
& wxDIALOG_MODELESS
)
412 s
+= _T("wxDIALOG_MODELESS|");
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
& wxTHICK_FRAME
)
424 s
+= _T("wxTHICK_FRAME|");
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|");
441 if (style
& wxTAB_TRAVERSAL
)
442 s
+= _T("wxTAB_TRAVERSAL|");
443 if (style
& wxWS_EX_VALIDATE_RECURSIVELY
)
444 s
+= _T("wxWS_EX_VALIDATE_RECURSIVELY|");
447 if (restype
== _T("wxComboBox"))
449 if (style
& wxCB_SORT
)
450 s
+= _T("wxCB_SORT|");
451 if (style
& wxCB_SIMPLE
)
452 s
+= _T("wxCB_SIMPLE|");
453 if (style
& wxCB_READONLY
)
454 s
+= _T("wxCB_READONLY|");
455 if (style
& wxCB_DROPDOWN
)
456 s
+= _T("wxCB_DROPDOWN|");
459 if (restype
== _T("wxGauge"))
461 if (style
& wxGA_HORIZONTAL
)
462 s
+= _T("wxGA_HORIZONTAL|");
463 if (style
& wxGA_VERTICAL
)
464 s
+= _T("wxGA_VERTICAL|");
465 if (style
& wxGA_PROGRESSBAR
)
466 s
+= _T("wxGA_PROGRESSBAR|");
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|");
545 s
= s
.Truncate(l
- 1);
547 s
+= _T("</style>\n");
551 wxString
wxr2xml::GetDimension(wxItemResource
* res
)
554 msg
<< _T("\t\t\t\t<dimension>") << res
->GetValue1() << _T("</dimension>\n");
558 wxString
wxr2xml::GenerateName(wxItemResource
* res
)
561 name
= _T(" name=\"");
562 switch (res
->GetId()) {
564 name
+= _T("wxID_OK");
567 name
+= _T("wxID_CANCEL");
570 name
+= res
->GetName();
577 void wxr2xml::ParseMenuBar(wxItemResource
* res
)
579 wxItemResource
*child
;
580 wxNode
*node
= res
->GetChildren().GetFirst();
582 m_xmlfile
.Write(_T("\t<object class=\"wxMenuBar\" "));
583 m_xmlfile
.Write(GenerateName(res
));
584 m_xmlfile
.Write(_T(">\n"));
586 child
= (wxItemResource
*) node
->GetData();
588 node
= node
->GetNext();
591 m_xmlfile
.Write(_T("\t</object> \n\n"));
594 void wxr2xml::ParseMenu(wxItemResource
* res
)
596 wxItemResource
*child
;
597 wxNode
*node
= res
->GetChildren().GetFirst();
599 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxMenu\" "));
601 menuname
<< _T("name = \"menu_") << res
->GetValue1() << _T("\"");
602 m_xmlfile
.Write(menuname
);
603 m_xmlfile
.Write(_T(">\n"));
604 m_xmlfile
.Write(_T("\t\t\t\t<label>")
605 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
606 if (res
->GetValue4() != _T(""))
607 m_xmlfile
.Write(_T("\t\t\t\t<help>") + res
->GetValue4() +
609 // Read in menu items and additional menus
611 child
= (wxItemResource
*) node
->GetData();
612 if (!child
->GetChildren().GetFirst())
613 ParseMenuItem(child
);
616 node
= node
->GetNext();
618 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
621 void wxr2xml::ParseMenuItem(wxItemResource
* res
)
623 // Get Menu Item or Separator
624 if (res
->GetTitle() == _T("")) {
625 m_xmlfile
.Write(_T("\t\t\t<object class=\"separator\"/>\n"));
627 m_xmlfile
.Write(_T("\t\t\t\t<object class=\"wxMenuItem\" "));
629 menuname
<< _T("name = \"menuitem_") << res
->GetValue1() << _T("\"");
630 m_xmlfile
.Write(menuname
);
631 m_xmlfile
.Write(_T(">\n"));
632 m_xmlfile
.Write(_T("\t\t\t<label>")
633 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
634 if (res
->GetValue4() != _T(""))
635 m_xmlfile
.Write(_T("\t\t\t<help>") +
636 res
->GetValue4() + _T("</help>\n"));
637 if (res
->GetValue2())
638 m_xmlfile
.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
639 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
643 wxString
wxr2xml::FixMenuString(wxString phrase
)
645 phrase
.Replace(_T("&"), _T("$"));
649 void wxr2xml::ParseStaticBitmap(wxItemResource
* res
)
651 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticBitmap\""));
652 WriteControlInfo(res
);
653 // value4 holds bitmap name
655 bitmapname
= res
->GetValue4();
657 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
658 bitmapname
+= _T(".bmp");
659 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
660 m_xmlfile
.Write(_T("\n\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>"));
661 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
664 //Parse a bitmap resource
665 void wxr2xml::ParseBitmap(wxItemResource
* res
)
667 m_xmlfile
.Write(_T("\t<object class=\"wxBitmap\" "));
668 m_xmlfile
.Write(GenerateName(res
)+_T(">"));
670 bitmapname
= res
->GetName();
672 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
673 bitmapname
+= _T(".bmp");
674 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
675 m_xmlfile
.Write(bitmapname
);
676 m_xmlfile
.Write(_T("</object>\n\n"));
679 void wxr2xml::PanelStuff(wxItemResource
* res
)
681 if ((res
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
686 // If this is true ignore fonts, background color and use system
688 if ((res
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
689 m_systemdefaults
= true;
691 m_systemdefaults
= false;
695 wxString
wxr2xml::GetValue2(wxItemResource
*res
)
698 msg
<< res
->GetValue2();
702 wxString
wxr2xml::GetValue3(wxItemResource
*res
)
705 msg
<< res
->GetValue3();
710 wxString
wxr2xml::GetValue5(wxItemResource
*res
)
713 msg
<< res
->GetValue5();
718 void wxr2xml::ParseBitmapButton(wxItemResource
*res
)
721 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
722 WriteControlInfo(res
);
723 // value4 holds bitmap name
725 bitmapname
= res
->GetValue4();
727 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
728 bitmapname
+= _T(".bmp");
729 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
730 m_xmlfile
.Write(_T("\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>\n"));
732 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
735 void wxr2xml::WriteFontInfo(wxItemResource
*res
)
737 //if systems_defaults true just ignore the fonts
738 if (m_systemdefaults
)
742 if (!font
.GetRefData())
745 m_xmlfile
.Write(_T("\t\t\t<font>\n"));
746 //Get font point size,font family,weight,font style,underline
749 pt
=font
.GetPointSize();
750 msg
<<_T("\t\t\t\t<size>")<<pt
<<_T("</size>\n");
751 m_xmlfile
.Write(msg
);
756 if (font
.GetUnderlined())
757 m_xmlfile
.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
759 m_xmlfile
.Write(_T("\t\t\t</font>\n"));
762 //WARNING possible make here
763 //I wasn't really sure the right way to do this.
764 void wxr2xml::GetFontFace(wxFont font
)
766 int family
=font
.GetFamily();
773 m_xmlfile
.Write(_T("\t\t\t\t<face>decorative</face>\n"));
776 m_xmlfile
.Write(_T("\t\t\t\t<face>roman</face>\n"));
779 m_xmlfile
.Write(_T("\t\t\t\t<face>script</face>\n"));
782 m_xmlfile
.Write(_T("\t\t\t\t<face>swiss</face>\n"));
785 m_xmlfile
.Write(_T("\t\t\t\t<face>modern</face>\n"));
788 wxLogError(_T("Unknown font face"));
792 void wxr2xml::GetFontStyle(wxFont font
)
795 int style
=font
.GetStyle();
799 //since this is default no point in making file any larger
803 m_xmlfile
.Write(_T("<style>italic</style>\n"));
806 m_xmlfile
.Write(_T("<style>slant</style>\n"));
809 wxLogError(_T("Unknown font style"));
813 void wxr2xml::GetFontWeight(wxFont font
)
815 int weight
=font
.GetWeight();
819 //since this is default no point in making file any larger
823 m_xmlfile
.Write(_T("\t\t\t\t<weight>light</weight>\n"));
826 m_xmlfile
.Write(_T("\t\t\t\t<weight>bold</weight>\n"));
829 wxLogError(_T("Unknown font weight"));