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
& wxDEFAULT_DIALOG_STYLE
)
408 s
+= _T("wxDEFAULT_DIALOG_STYLE|");
409 #if WXWIN_COMPATIBILITY_2_6
410 if (style
& wxDIALOG_MODAL
)
411 s
+= _T("wxDIALOG_MODAL|");
412 if (style
& wxDIALOG_MODELESS
)
413 s
+= _T("wxDIALOG_MODELESS|");
416 #endif // WXWIN_COMPATIBILITY_2_6
417 if (style
& wxTAB_TRAVERSAL
)
418 s
+= _T("wxTAB_TRAVERSAL|");
419 if (style
& wxWS_EX_VALIDATE_RECURSIVELY
)
420 s
+= _T("wxWS_EX_VALIDATE_RECURSIVELY|");
421 if (style
& wxSTAY_ON_TOP
)
422 s
+= _T("wxSTAY_ON_TOP|");
423 if (style
& wxCAPTION
)
424 s
+= _T("wxCAPTION|");
425 if (style
& wxRESIZE_BORDER
)
426 s
+= _T("wxRESIZE_BORDER|");
427 if (style
& wxRESIZE_BOX
)
428 s
+= _T("wxRESIZE_BOX|");
429 if (style
& wxRESIZE_BORDER
)
430 s
+= _T("wxRESIZE_BORDER|");
431 if (style
& wxSYSTEM_MENU
)
432 s
+= _T("wxSYSTEM_MENU|");
433 if (style
& wxCLIP_CHILDREN
)
434 s
+= _T("wxCLIP_CHILDREN|");
437 if (restype
== _T("wxPanel"))
439 if (style
& wxCLIP_CHILDREN
)
440 s
+= _T("wxCLIP_CHILDREN|");
441 #if WXWIN_COMPATIBILITY_2_6
444 #endif // WXWIN_COMPATIBILITY_2_6
445 if (style
& wxTAB_TRAVERSAL
)
446 s
+= _T("wxTAB_TRAVERSAL|");
447 if (style
& wxWS_EX_VALIDATE_RECURSIVELY
)
448 s
+= _T("wxWS_EX_VALIDATE_RECURSIVELY|");
451 if (restype
== _T("wxComboBox"))
453 if (style
& wxCB_SORT
)
454 s
+= _T("wxCB_SORT|");
455 if (style
& wxCB_SIMPLE
)
456 s
+= _T("wxCB_SIMPLE|");
457 if (style
& wxCB_READONLY
)
458 s
+= _T("wxCB_READONLY|");
459 if (style
& wxCB_DROPDOWN
)
460 s
+= _T("wxCB_DROPDOWN|");
463 if (restype
== _T("wxGauge"))
465 if (style
& wxGA_HORIZONTAL
)
466 s
+= _T("wxGA_HORIZONTAL|");
467 if (style
& wxGA_VERTICAL
)
468 s
+= _T("wxGA_VERTICAL|");
469 if (style
& wxGA_PROGRESSBAR
)
470 s
+= _T("wxGA_PROGRESSBAR|");
472 if (style
& wxGA_SMOOTH
)
473 s
+= _T("wxGA_SMOOTH|");
476 if (restype
== _T("wxRadioButton"))
478 if (style
& wxRB_GROUP
)
479 s
+= _T("wxRB_GROUP|");
482 if (restype
== _T("wxStaticText"))
484 if (style
& wxST_NO_AUTORESIZE
)
485 s
+= _T("wxST_NO_AUTORESIZEL|");
488 if (restype
== _T("wxRadioBox"))
490 if (style
& wxRA_HORIZONTAL
)
491 s
+= _T("wxRA_HORIZONTAL|");
492 if (style
& wxRA_SPECIFY_COLS
)
493 s
+= _T("wxRA_SPECIFY_COLS|");
494 if (style
& wxRA_SPECIFY_ROWS
)
495 s
+= _T("wxRA_SPECIFY_ROWS|");
496 if (style
& wxRA_VERTICAL
)
497 s
+= _T("wxRA_VERTICAL|");
500 if (restype
== _T("wxListBox"))
502 if (style
& wxLB_SINGLE
)
503 s
+= _T("wxLB_SINGLE|");
504 if (style
& wxLB_MULTIPLE
)
505 s
+= _T("wxLB_MULTIPLE|");
506 if (style
& wxLB_EXTENDED
)
507 s
+= _T("wxLB_EXTENDED|");
508 if (style
& wxLB_HSCROLL
)
509 s
+= _T("wxLB_HSCROLL|");
510 if (style
& wxLB_ALWAYS_SB
)
511 s
+= _T("wxLB_ALWAYS_SB|");
512 if (style
& wxLB_NEEDED_SB
)
513 s
+= _T("wxLB_NEEDED_SB|");
514 if (style
& wxLB_SORT
)
515 s
+= _T("wxLB_SORT|");
518 if (restype
== _T("wxTextCtrl"))
520 if (style
& wxTE_PROCESS_ENTER
)
521 s
+= _T("wxTE_PROCESS_ENTER|");
522 if (style
& wxTE_PROCESS_TAB
)
523 s
+= _T("wxTE_PROCESS_TAB|");
524 if (style
& wxTE_MULTILINE
)
525 s
+= _T("wxTE_MULTILINE|");
526 if (style
& wxTE_PASSWORD
)
527 s
+= _T("wxTE_PASSWORD|");
528 if (style
& wxTE_READONLY
)
529 s
+= _T("wxTE_READONLY|");
530 if (style
& wxHSCROLL
)
531 s
+= _T("wxHSCROLL|");
535 if (restype
== _T("wxScrollBar"))
537 if (style
& wxSB_HORIZONTAL
)
538 s
+= _T("wxSB_HORIZONTAL|");
539 if (style
& wxSB_VERTICAL
)
540 s
+= _T("wxSB_VERTICAL|");
546 return wxEmptyString
;
548 s
= s
.Truncate(l
- 1);
550 s
+= _T("</style>\n");
554 wxString
wxr2xml::GetDimension(wxItemResource
* res
)
557 msg
<< _T("\t\t\t\t<dimension>") << res
->GetValue1() << _T("</dimension>\n");
561 wxString
wxr2xml::GenerateName(wxItemResource
* res
)
564 name
= _T(" name=\"");
565 switch (res
->GetId()) {
567 name
+= _T("wxID_OK");
570 name
+= _T("wxID_CANCEL");
573 name
+= res
->GetName();
580 void wxr2xml::ParseMenuBar(wxItemResource
* res
)
582 wxItemResource
*child
;
583 wxNode
*node
= res
->GetChildren().GetFirst();
585 m_xmlfile
.Write(_T("\t<object class=\"wxMenuBar\" "));
586 m_xmlfile
.Write(GenerateName(res
));
587 m_xmlfile
.Write(_T(">\n"));
589 child
= (wxItemResource
*) node
->GetData();
591 node
= node
->GetNext();
594 m_xmlfile
.Write(_T("\t</object> \n\n"));
597 void wxr2xml::ParseMenu(wxItemResource
* res
)
599 wxItemResource
*child
;
600 wxNode
*node
= res
->GetChildren().GetFirst();
602 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxMenu\" "));
604 menuname
<< _T("name = \"menu_") << res
->GetValue1() << _T("\"");
605 m_xmlfile
.Write(menuname
);
606 m_xmlfile
.Write(_T(">\n"));
607 m_xmlfile
.Write(_T("\t\t\t\t<label>")
608 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
609 if (!res
->GetValue4().empty())
610 m_xmlfile
.Write(_T("\t\t\t\t<help>") + res
->GetValue4() +
612 // Read in menu items and additional menus
614 child
= (wxItemResource
*) node
->GetData();
615 if (!child
->GetChildren().GetFirst())
616 ParseMenuItem(child
);
619 node
= node
->GetNext();
621 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
624 void wxr2xml::ParseMenuItem(wxItemResource
* res
)
626 // Get Menu Item or Separator
627 if (res
->GetTitle().empty()) {
628 m_xmlfile
.Write(_T("\t\t\t<object class=\"separator\"/>\n"));
630 m_xmlfile
.Write(_T("\t\t\t\t<object class=\"wxMenuItem\" "));
632 menuname
<< _T("name = \"menuitem_") << res
->GetValue1() << _T("\"");
633 m_xmlfile
.Write(menuname
);
634 m_xmlfile
.Write(_T(">\n"));
635 m_xmlfile
.Write(_T("\t\t\t<label>")
636 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
637 if (!res
->GetValue4().empty())
638 m_xmlfile
.Write(_T("\t\t\t<help>") +
639 res
->GetValue4() + _T("</help>\n"));
640 if (res
->GetValue2())
641 m_xmlfile
.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
642 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
646 wxString
wxr2xml::FixMenuString(wxString phrase
)
648 phrase
.Replace(_T("&"), _T("$"));
652 void wxr2xml::ParseStaticBitmap(wxItemResource
* res
)
654 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticBitmap\""));
655 WriteControlInfo(res
);
656 // value4 holds bitmap name
658 bitmapname
= res
->GetValue4();
660 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
661 bitmapname
+= _T(".bmp");
662 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
663 m_xmlfile
.Write(_T("\n\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>"));
664 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
667 //Parse a bitmap resource
668 void wxr2xml::ParseBitmap(wxItemResource
* res
)
670 m_xmlfile
.Write(_T("\t<object class=\"wxBitmap\" "));
671 m_xmlfile
.Write(GenerateName(res
)+_T(">"));
673 bitmapname
= res
->GetName();
675 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
676 bitmapname
+= _T(".bmp");
677 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
678 m_xmlfile
.Write(bitmapname
);
679 m_xmlfile
.Write(_T("</object>\n\n"));
682 void wxr2xml::PanelStuff(wxItemResource
* res
)
684 if ((res
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
689 // If this is true ignore fonts, background color and use system
691 if ((res
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
692 m_systemdefaults
= true;
694 m_systemdefaults
= false;
698 wxString
wxr2xml::GetValue2(wxItemResource
*res
)
701 msg
<< res
->GetValue2();
705 wxString
wxr2xml::GetValue3(wxItemResource
*res
)
708 msg
<< res
->GetValue3();
713 wxString
wxr2xml::GetValue5(wxItemResource
*res
)
716 msg
<< res
->GetValue5();
721 void wxr2xml::ParseBitmapButton(wxItemResource
*res
)
724 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
725 WriteControlInfo(res
);
726 // value4 holds bitmap name
728 bitmapname
= res
->GetValue4();
730 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
731 bitmapname
+= _T(".bmp");
732 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
733 m_xmlfile
.Write(_T("\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>\n"));
735 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
738 void wxr2xml::WriteFontInfo(wxItemResource
*res
)
740 //if systems_defaults true just ignore the fonts
741 if (m_systemdefaults
)
745 if (!font
.GetRefData())
748 m_xmlfile
.Write(_T("\t\t\t<font>\n"));
749 //Get font point size,font family,weight,font style,underline
752 pt
=font
.GetPointSize();
753 msg
<<_T("\t\t\t\t<size>")<<pt
<<_T("</size>\n");
754 m_xmlfile
.Write(msg
);
759 if (font
.GetUnderlined())
760 m_xmlfile
.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
762 m_xmlfile
.Write(_T("\t\t\t</font>\n"));
765 //WARNING possible make here
766 //I wasn't really sure the right way to do this.
767 void wxr2xml::GetFontFace(wxFont font
)
769 int family
=font
.GetFamily();
776 m_xmlfile
.Write(_T("\t\t\t\t<face>decorative</face>\n"));
779 m_xmlfile
.Write(_T("\t\t\t\t<face>roman</face>\n"));
782 m_xmlfile
.Write(_T("\t\t\t\t<face>script</face>\n"));
785 m_xmlfile
.Write(_T("\t\t\t\t<face>swiss</face>\n"));
788 m_xmlfile
.Write(_T("\t\t\t\t<face>modern</face>\n"));
791 wxLogError(_T("Unknown font face"));
795 void wxr2xml::GetFontStyle(wxFont font
)
798 int style
=font
.GetStyle();
802 //since this is default no point in making file any larger
806 m_xmlfile
.Write(_T("<style>italic</style>\n"));
809 m_xmlfile
.Write(_T("<style>slant</style>\n"));
812 wxLogError(_T("Unknown font style"));
816 void wxr2xml::GetFontWeight(wxFont font
)
818 int weight
=font
.GetWeight();
822 //since this is default no point in making file any larger
826 m_xmlfile
.Write(_T("\t\t\t\t<weight>light</weight>\n"));
829 m_xmlfile
.Write(_T("\t\t\t\t<weight>bold</weight>\n"));
832 wxLogError(_T("Unknown font weight"));