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 WXWIN_COMPATIBILITY_2_6
426 if (style
& wxRESIZE_BOX
)
427 s
+= _T("wxRESIZE_BOX|");
428 #endif // WXWIN_COMPATIBILITY_2_6
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|");
470 if (style
& wxGA_SMOOTH
)
471 s
+= _T("wxGA_SMOOTH|");
474 if (restype
== _T("wxRadioButton"))
476 if (style
& wxRB_GROUP
)
477 s
+= _T("wxRB_GROUP|");
480 if (restype
== _T("wxStaticText"))
482 if (style
& wxST_NO_AUTORESIZE
)
483 s
+= _T("wxST_NO_AUTORESIZEL|");
486 if (restype
== _T("wxRadioBox"))
488 if (style
& wxRA_HORIZONTAL
)
489 s
+= _T("wxRA_HORIZONTAL|");
490 if (style
& wxRA_SPECIFY_COLS
)
491 s
+= _T("wxRA_SPECIFY_COLS|");
492 if (style
& wxRA_SPECIFY_ROWS
)
493 s
+= _T("wxRA_SPECIFY_ROWS|");
494 if (style
& wxRA_VERTICAL
)
495 s
+= _T("wxRA_VERTICAL|");
498 if (restype
== _T("wxListBox"))
500 if (style
& wxLB_SINGLE
)
501 s
+= _T("wxLB_SINGLE|");
502 if (style
& wxLB_MULTIPLE
)
503 s
+= _T("wxLB_MULTIPLE|");
504 if (style
& wxLB_EXTENDED
)
505 s
+= _T("wxLB_EXTENDED|");
506 if (style
& wxLB_HSCROLL
)
507 s
+= _T("wxLB_HSCROLL|");
508 if (style
& wxLB_ALWAYS_SB
)
509 s
+= _T("wxLB_ALWAYS_SB|");
510 if (style
& wxLB_NEEDED_SB
)
511 s
+= _T("wxLB_NEEDED_SB|");
512 if (style
& wxLB_SORT
)
513 s
+= _T("wxLB_SORT|");
516 if (restype
== _T("wxTextCtrl"))
518 if (style
& wxTE_PROCESS_ENTER
)
519 s
+= _T("wxTE_PROCESS_ENTER|");
520 if (style
& wxTE_PROCESS_TAB
)
521 s
+= _T("wxTE_PROCESS_TAB|");
522 if (style
& wxTE_MULTILINE
)
523 s
+= _T("wxTE_MULTILINE|");
524 if (style
& wxTE_PASSWORD
)
525 s
+= _T("wxTE_PASSWORD|");
526 if (style
& wxTE_READONLY
)
527 s
+= _T("wxTE_READONLY|");
528 if (style
& wxHSCROLL
)
529 s
+= _T("wxHSCROLL|");
533 if (restype
== _T("wxScrollBar"))
535 if (style
& wxSB_HORIZONTAL
)
536 s
+= _T("wxSB_HORIZONTAL|");
537 if (style
& wxSB_VERTICAL
)
538 s
+= _T("wxSB_VERTICAL|");
544 return wxEmptyString
;
546 s
= s
.Truncate(l
- 1);
548 s
+= _T("</style>\n");
552 wxString
wxr2xml::GetDimension(wxItemResource
* res
)
555 msg
<< _T("\t\t\t\t<dimension>") << res
->GetValue1() << _T("</dimension>\n");
559 wxString
wxr2xml::GenerateName(wxItemResource
* res
)
562 name
= _T(" name=\"");
563 switch (res
->GetId()) {
565 name
+= _T("wxID_OK");
568 name
+= _T("wxID_CANCEL");
571 name
+= res
->GetName();
578 void wxr2xml::ParseMenuBar(wxItemResource
* res
)
580 wxItemResource
*child
;
581 wxNode
*node
= res
->GetChildren().GetFirst();
583 m_xmlfile
.Write(_T("\t<object class=\"wxMenuBar\" "));
584 m_xmlfile
.Write(GenerateName(res
));
585 m_xmlfile
.Write(_T(">\n"));
587 child
= (wxItemResource
*) node
->GetData();
589 node
= node
->GetNext();
592 m_xmlfile
.Write(_T("\t</object> \n\n"));
595 void wxr2xml::ParseMenu(wxItemResource
* res
)
597 wxItemResource
*child
;
598 wxNode
*node
= res
->GetChildren().GetFirst();
600 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxMenu\" "));
602 menuname
<< _T("name = \"menu_") << res
->GetValue1() << _T("\"");
603 m_xmlfile
.Write(menuname
);
604 m_xmlfile
.Write(_T(">\n"));
605 m_xmlfile
.Write(_T("\t\t\t\t<label>")
606 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
607 if (!res
->GetValue4().empty())
608 m_xmlfile
.Write(_T("\t\t\t\t<help>") + res
->GetValue4() +
610 // Read in menu items and additional menus
612 child
= (wxItemResource
*) node
->GetData();
613 if (!child
->GetChildren().GetFirst())
614 ParseMenuItem(child
);
617 node
= node
->GetNext();
619 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
622 void wxr2xml::ParseMenuItem(wxItemResource
* res
)
624 // Get Menu Item or Separator
625 if (res
->GetTitle().empty()) {
626 m_xmlfile
.Write(_T("\t\t\t<object class=\"separator\"/>\n"));
628 m_xmlfile
.Write(_T("\t\t\t\t<object class=\"wxMenuItem\" "));
630 menuname
<< _T("name = \"menuitem_") << res
->GetValue1() << _T("\"");
631 m_xmlfile
.Write(menuname
);
632 m_xmlfile
.Write(_T(">\n"));
633 m_xmlfile
.Write(_T("\t\t\t<label>")
634 + FixMenuString(res
->GetTitle()) + _T("</label>\n"));
635 if (!res
->GetValue4().empty())
636 m_xmlfile
.Write(_T("\t\t\t<help>") +
637 res
->GetValue4() + _T("</help>\n"));
638 if (res
->GetValue2())
639 m_xmlfile
.Write(_T("\t\t\t\t<checkable>1</checkable>\n"));
640 m_xmlfile
.Write(_T("\t\t\t</object> \n"));
644 wxString
wxr2xml::FixMenuString(wxString phrase
)
646 phrase
.Replace(_T("&"), _T("$"));
650 void wxr2xml::ParseStaticBitmap(wxItemResource
* res
)
652 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxStaticBitmap\""));
653 WriteControlInfo(res
);
654 // value4 holds bitmap name
656 bitmapname
= res
->GetValue4();
658 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
659 bitmapname
+= _T(".bmp");
660 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
661 m_xmlfile
.Write(_T("\n\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>"));
662 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
665 //Parse a bitmap resource
666 void wxr2xml::ParseBitmap(wxItemResource
* res
)
668 m_xmlfile
.Write(_T("\t<object class=\"wxBitmap\" "));
669 m_xmlfile
.Write(GenerateName(res
)+_T(">"));
671 bitmapname
= res
->GetName();
673 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
674 bitmapname
+= _T(".bmp");
675 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
676 m_xmlfile
.Write(bitmapname
);
677 m_xmlfile
.Write(_T("</object>\n\n"));
680 void wxr2xml::PanelStuff(wxItemResource
* res
)
682 if ((res
->GetResourceStyle() & wxRESOURCE_DIALOG_UNITS
) != 0)
687 // If this is true ignore fonts, background color and use system
689 if ((res
->GetResourceStyle() & wxRESOURCE_USE_DEFAULTS
) != 0)
690 m_systemdefaults
= true;
692 m_systemdefaults
= false;
696 wxString
wxr2xml::GetValue2(wxItemResource
*res
)
699 msg
<< res
->GetValue2();
703 wxString
wxr2xml::GetValue3(wxItemResource
*res
)
706 msg
<< res
->GetValue3();
711 wxString
wxr2xml::GetValue5(wxItemResource
*res
)
714 msg
<< res
->GetValue5();
719 void wxr2xml::ParseBitmapButton(wxItemResource
*res
)
722 m_xmlfile
.Write(_T("\t\t\t<object class=\"wxBitmapButton\""));
723 WriteControlInfo(res
);
724 // value4 holds bitmap name
726 bitmapname
= res
->GetValue4();
728 bitmap
= wxResourceCreateBitmap(bitmapname
, &m_table
);
729 bitmapname
+= _T(".bmp");
730 bitmap
.SaveFile(bitmapname
, wxBITMAP_TYPE_BMP
);
731 m_xmlfile
.Write(_T("\t\t\t\t<bitmap>") + bitmapname
+ _T("</bitmap>\n"));
733 m_xmlfile
.Write(_T("\t\t\t</object>\n"));
736 void wxr2xml::WriteFontInfo(wxItemResource
*res
)
738 //if systems_defaults true just ignore the fonts
739 if (m_systemdefaults
)
743 if (!font
.GetRefData())
746 m_xmlfile
.Write(_T("\t\t\t<font>\n"));
747 //Get font point size,font family,weight,font style,underline
750 pt
=font
.GetPointSize();
751 msg
<<_T("\t\t\t\t<size>")<<pt
<<_T("</size>\n");
752 m_xmlfile
.Write(msg
);
757 if (font
.GetUnderlined())
758 m_xmlfile
.Write(_T("\t\t\t\t<underlined>1</underlined>\n"));
760 m_xmlfile
.Write(_T("\t\t\t</font>\n"));
763 //WARNING possible make here
764 //I wasn't really sure the right way to do this.
765 void wxr2xml::GetFontFace(wxFont font
)
767 int family
=font
.GetFamily();
774 m_xmlfile
.Write(_T("\t\t\t\t<face>decorative</face>\n"));
777 m_xmlfile
.Write(_T("\t\t\t\t<face>roman</face>\n"));
780 m_xmlfile
.Write(_T("\t\t\t\t<face>script</face>\n"));
783 m_xmlfile
.Write(_T("\t\t\t\t<face>swiss</face>\n"));
786 m_xmlfile
.Write(_T("\t\t\t\t<face>modern</face>\n"));
789 wxLogError(_T("Unknown font face"));
793 void wxr2xml::GetFontStyle(wxFont font
)
796 int style
=font
.GetStyle();
800 //since this is default no point in making file any larger
804 m_xmlfile
.Write(_T("<style>italic</style>\n"));
807 m_xmlfile
.Write(_T("<style>slant</style>\n"));
810 wxLogError(_T("Unknown font style"));
814 void wxr2xml::GetFontWeight(wxFont font
)
816 int weight
=font
.GetWeight();
820 //since this is default no point in making file any larger
824 m_xmlfile
.Write(_T("\t\t\t\t<weight>light</weight>\n"));
827 m_xmlfile
.Write(_T("\t\t\t\t<weight>bold</weight>\n"));
830 wxLogError(_T("Unknown font weight"));