]>
Commit | Line | Data |
---|---|---|
2193517f VS |
1 | // rc2xml.cpp: implementation of the rc2xml class. |
2 | //Author: Brian Gavin 9/24/00 | |
3 | //License: wxWindows License | |
4 | /* | |
5 | How to use: | |
6 | #include "rc2xml.h" | |
7 | ... | |
8 | rc2xml trans; | |
9 | trans->Convert("Myfile.rc","Myfile.xml"); | |
10 | */ | |
11 | /* TODO | |
12 | 1. Figure how to fix memory leaks in all wxLists in this class | |
13 | 2. Find a way to rename MS Windows fonts so that they work | |
14 | cross platform (wxGTK,etc) | |
15 | 3. Be able to abort incorrectly formated files without crashing | |
16 | */ | |
17 | ||
18 | #ifdef __GNUG__ | |
19 | #pragma implementation "rc2xml.cpp" | |
20 | #pragma interface "rc2xml.cpp" | |
21 | #endif | |
22 | ||
88d42654 | 23 | // For compilers that support precompilation, includes "wx/wx.h". |
92a19c2e | 24 | #include "wx/wxprec.h" |
2193517f VS |
25 | |
26 | #ifdef __BORLANDC__ | |
27 | #pragma hdrstop | |
28 | #endif | |
29 | ||
30 | // for all others, include the necessary headers (this file is usually all you | |
be5a51fb | 31 | // need because it includes almost all "standard" wxWidgets headers |
2193517f VS |
32 | #ifndef WX_PRECOMP |
33 | #include <wx/wx.h> | |
34 | #endif | |
35 | ||
88d42654 VS |
36 | |
37 | #include "rc2xml.h" | |
38 | #include "wx/image.h" | |
7c9955d1 JS |
39 | #include "wx/deprecated/setup.h" |
40 | #include "wx/deprecated/resource.h" | |
2193517f VS |
41 | #include <wx/textfile.h> |
42 | #include <wx/tokenzr.h> | |
43 | ||
44 | ||
45 | ||
88d42654 VS |
46 | ////////////////////////////////////////////////////////////////////// |
47 | // Construction/Destruction | |
48 | ////////////////////////////////////////////////////////////////////// | |
49 | ||
2193517f | 50 | rc2xml::rc2xml() |
88d42654 | 51 | { |
f80ea77b | 52 | m_done=false; |
2193517f VS |
53 | m_bitmaplist=new wxList(wxKEY_STRING); |
54 | m_stringtable=new wxList(wxKEY_STRING); | |
55 | m_iconlist = new wxList(wxKEY_STRING); | |
56 | m_resourcelist =new wxList(wxKEY_INTEGER); | |
88d42654 VS |
57 | } |
58 | ||
2193517f | 59 | rc2xml::~rc2xml() |
88d42654 | 60 | { |
2193517f VS |
61 | delete m_bitmaplist; |
62 | delete m_stringtable; | |
63 | delete m_iconlist; | |
64 | delete m_resourcelist; | |
88d42654 VS |
65 | } |
66 | ||
2193517f | 67 | bool rc2xml::Convert(wxString rcfile, wxString xmlfile) |
88d42654 | 68 | { |
2193517f VS |
69 | m_rc.Open(rcfile.c_str()); |
70 | m_filesize=m_rc.Length(); | |
7c9955d1 | 71 | |
92a19c2e | 72 | |
2c99715a | 73 | m_workingpath=wxPathOnly(rcfile); |
92a19c2e | 74 | |
19d0f58d | 75 | m_targetpath=wxPathOnly(xmlfile) + _T("\\"); |
2c99715a | 76 | |
92a19c2e GT |
77 | |
78 | ||
2c99715a VS |
79 | wxSetWorkingDirectory(m_workingpath); |
80 | ||
92a19c2e | 81 | |
2193517f | 82 | bool result; |
19d0f58d JS |
83 | result=m_xmlfile.Open(xmlfile.c_str(),_T("w+t")); |
84 | wxASSERT_MSG(result,_T("Couldn't create XML file")); | |
2193517f | 85 | if (!result) |
f80ea77b | 86 | return false; |
88d42654 | 87 | |
7c9955d1 | 88 | |
88d42654 | 89 | /* Write Basic header for XML file */ |
19d0f58d JS |
90 | m_xmlfile.Write(_T("<?xml version=\"1.0\" ?>\n")); |
91 | m_xmlfile.Write(_T("<resource>\n")); | |
7c9955d1 | 92 | |
2193517f VS |
93 | //Read resource.h |
94 | ParseResourceHeader(); | |
88d42654 | 95 | //Gather all the resource we need for toolbars,menus, and etc |
2193517f | 96 | FirstPass(); |
f80ea77b | 97 | m_done=false; |
2193517f | 98 | m_rc.Seek(0); |
88d42654 | 99 | //Read in dialogs, toolbars,menus |
2193517f | 100 | SecondPass(); |
88d42654 | 101 | |
19d0f58d | 102 | m_xmlfile.Write(_T("</resource>\n")); |
2193517f VS |
103 | m_xmlfile.Close(); |
104 | m_rc.Close(); | |
7c9955d1 | 105 | wxMessageBox(_("Conversion complete."), _("Done"), |
5c8756b0 | 106 | wxOK | wxICON_INFORMATION); |
88d42654 | 107 | |
f80ea77b | 108 | return true; |
88d42654 VS |
109 | } |
110 | ||
111 | ||
2193517f | 112 | void rc2xml::ParseDialog(wxString dlgname) |
88d42654 | 113 | { |
2193517f VS |
114 | wxString token; |
115 | static int dlgid=999; | |
116 | dlgid++; | |
7c9955d1 | 117 | /* Make sure that this really is a dialog |
2193517f VS |
118 | microsoft reuses the keyword DIALOG for other things |
119 | */ | |
120 | token=PeekToken(); | |
121 | //Microsoft notation? | |
19d0f58d JS |
122 | while ((token==_T("DISCARDABLE")) |
123 | ||(token==_T("LOADONCALL"))||(token==_T("MOVEABLE"))) | |
2193517f VS |
124 | { |
125 | token=GetToken(); | |
126 | token=PeekToken(); | |
127 | } | |
128 | //Error isn't a Dialog resource eject eject | |
129 | if (!token.IsNumber()) | |
130 | return; | |
88d42654 VS |
131 | |
132 | //Record x,y,width,height | |
2193517f VS |
133 | int x,y,width,height; |
134 | ReadRect(x,y,width,height); | |
88d42654 | 135 | //Get Title |
2193517f VS |
136 | token=GetToken(); |
137 | wxString title; | |
138 | wxString ptsize,face; | |
7c9955d1 | 139 | |
19d0f58d | 140 | m_xmlfile.Write(_T("\t<object class=\"wxDialog\"")); |
2193517f | 141 | //Avoid duplicate names this way |
19d0f58d | 142 | dlgname.Replace(_T("IDD_"),_T("DLG_")); |
2193517f VS |
143 | WriteBasicInfo(x,y,width,height,dlgname); |
144 | WriteTitle(title); | |
7c9955d1 | 145 | |
2193517f | 146 | |
19d0f58d | 147 | while ((token!=_T("BEGIN"))&(token!=_T("{"))) |
2193517f | 148 | { |
d7e3abf7 | 149 | if (token==_T("CAPTION")) |
2193517f | 150 | { |
d7e3abf7 | 151 | title=GetQuoteField(); |
2193517f VS |
152 | } |
153 | ||
154 | //TODO fix face name so that it is cross platform name | |
155 | // FONT 8, "MS Sans Serif" | |
19d0f58d | 156 | if (token==_T("FONT")) |
d7e3abf7 | 157 | { |
2193517f VS |
158 | ptsize=GetToken(); |
159 | face=GetQuoteField(); | |
19d0f58d JS |
160 | m_xmlfile.Write(_T("\t\t<font>\n")); |
161 | m_xmlfile.Write(_T("\t\t\t<size>")+ptsize+_T("</size>\n")); | |
162 | m_xmlfile.Write(_T("\t\t\t<face>")+face+_T("</face>\n")); | |
163 | m_xmlfile.Write(_T("\t\t</font>\n")); | |
d7e3abf7 | 164 | } |
2193517f VS |
165 | |
166 | token=GetToken(); | |
167 | } | |
88d42654 | 168 | |
2193517f | 169 | ParseControls(); |
19d0f58d | 170 | m_xmlfile.Write(_T("\t</object>\n")); |
88d42654 VS |
171 | } |
172 | ||
173 | /* | |
174 | BEGIN | |
7c9955d1 | 175 | EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT |
88d42654 VS |
176 | WS_TABSTOP |
177 | LTEXT "Bands",IDC_STATIC,11,86,21,8 | |
178 | EDITTEXT IDC_NAME,10,3,75,14,ES_AUTOHSCROLL | |
179 | END | |
180 | */ | |
2193517f | 181 | void rc2xml::ParseControls() |
88d42654 | 182 | { |
2193517f | 183 | wxString token; |
5c8756b0 | 184 | wxString label,varname; |
2193517f VS |
185 | |
186 | token=GetToken(); | |
19d0f58d | 187 | while ((token!=_T("END"))&(token!=_T("}"))) |
2193517f | 188 | { |
19d0f58d | 189 | if (token==_T("AUTOCHECKBOX")) |
5c8756b0 JS |
190 | { |
191 | label=GetQuoteField(); | |
192 | varname=GetToken(); | |
193 | ParseCheckBox(label,varname); | |
194 | } | |
11ad1132 | 195 | else |
19d0f58d | 196 | if (token==_T("AUTORADIOBUTTON")) |
5c8756b0 JS |
197 | { |
198 | label=GetQuoteField(); | |
199 | varname=GetToken(); | |
200 | ParseRadioButton(label,varname); | |
201 | } | |
11ad1132 | 202 | else |
19d0f58d | 203 | if (token==_T("LTEXT")) |
5c8756b0 JS |
204 | { |
205 | label=GetQuoteField(); | |
206 | varname=GetToken(); | |
207 | ParseStaticText(label,varname); | |
208 | } | |
19d0f58d | 209 | else if (token==_T("EDITTEXT")) |
5c8756b0 JS |
210 | { |
211 | varname=GetToken(); | |
212 | ParseTextCtrl(varname); | |
213 | } | |
19d0f58d | 214 | else if ((token==_T("PUSHBUTTON"))||(token==_T("DEFPUSHBUTTON"))) |
5c8756b0 JS |
215 | { |
216 | label=GetQuoteField(); | |
217 | varname=GetToken(); | |
218 | ParsePushButton(label,varname); | |
219 | } | |
19d0f58d | 220 | else if (token==_T("GROUPBOX")) |
5c8756b0 JS |
221 | { |
222 | label=GetQuoteField(); | |
223 | varname=GetToken(); | |
224 | ParseGroupBox(label,varname); | |
225 | } | |
19d0f58d | 226 | else if (token==_T("COMBOBOX")) |
5c8756b0 JS |
227 | { |
228 | varname=GetToken(); | |
229 | ParseComboBox(varname); | |
230 | } | |
19d0f58d | 231 | else if (token==_T("CONTROL")) |
2193517f | 232 | ParseControlMS(); |
19d0f58d | 233 | else if (token==_T("LISTBOX")) |
5c8756b0 JS |
234 | { |
235 | varname=GetToken(); | |
236 | ParseListBox(varname); | |
237 | } | |
19d0f58d | 238 | else if (token==_T("ICON")) |
2193517f | 239 | ParseIconStatic(); |
19d0f58d | 240 | else if (token==_T("SCROLLBAR")) |
2193517f VS |
241 | ParseScrollBar(); |
242 | token=GetToken(); | |
243 | } | |
88d42654 VS |
244 | |
245 | } | |
246 | //LTEXT "Radius",IDC_STATIC,9,67,23,8 | |
5c8756b0 | 247 | void rc2xml::ParseStaticText(wxString phrase, wxString varname) |
88d42654 | 248 | { |
2193517f | 249 | wxString token; |
5c8756b0 JS |
250 | token=PeekToken(); |
251 | while (!token.IsNumber()) | |
252 | { | |
253 | token=GetToken(); | |
254 | token=PeekToken(); | |
255 | } | |
2193517f VS |
256 | int x,y,width,height; |
257 | ReadRect(x,y,width,height); | |
88d42654 | 258 | |
19d0f58d | 259 | m_xmlfile.Write(_T("\t\t<object class=\"wxStaticText\"")); |
2193517f | 260 | WriteBasicInfo(x,y,width,height,varname);WriteLabel(phrase); |
19d0f58d | 261 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
262 | |
263 | } | |
264 | //EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL | |
5c8756b0 | 265 | void rc2xml::ParseTextCtrl(wxString varname) |
88d42654 | 266 | { |
2193517f | 267 | wxString token; |
5c8756b0 JS |
268 | wxString style; |
269 | token=PeekToken(); | |
270 | while (!token.IsNumber()) | |
271 | { | |
272 | token=GetToken(); | |
273 | token=PeekToken(); | |
274 | } | |
2193517f VS |
275 | int x,y,width,height; |
276 | ReadRect(x,y,width,height); | |
88d42654 VS |
277 | //TODO |
278 | //style=GetToken(); | |
19d0f58d | 279 | m_xmlfile.Write(_T("\t\t<object class=\"wxTextCtrl\"")); |
2193517f | 280 | WriteBasicInfo(x,y,width,height,varname); |
19d0f58d | 281 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
282 | |
283 | } | |
11ad1132 | 284 | //AUTOCHECKBOX "&log.", ID_XLOG, 25, 24, 21, 12 |
5c8756b0 | 285 | void rc2xml::ParseCheckBox(wxString phrase, wxString varname) |
11ad1132 VS |
286 | { |
287 | wxString token; | |
5c8756b0 JS |
288 | token=PeekToken(); |
289 | while (!token.IsNumber()) | |
290 | { | |
291 | token=GetToken(); | |
292 | token=PeekToken(); | |
293 | } | |
11ad1132 VS |
294 | int x,y,width,height; |
295 | ReadRect(x,y,width,height); | |
296 | ||
19d0f58d | 297 | m_xmlfile.Write(_T("\t\t<object class=\"wxCheckBox\"")); |
11ad1132 VS |
298 | WriteBasicInfo(x,y,width,height,varname); |
299 | WriteLabel(phrase); | |
19d0f58d | 300 | m_xmlfile.Write(_T("\t\t</object>\n")); |
11ad1132 VS |
301 | |
302 | } | |
303 | //AUTORADIOBUTTON "&text", ID_SW10, 13, 12, 68, 10, BS_AUTORADIOBUTTON | WS_GROUP | |
5c8756b0 | 304 | void rc2xml::ParseRadioButton(wxString phrase, wxString varname) |
11ad1132 VS |
305 | { |
306 | wxString token,style; | |
11ad1132 | 307 | int x,y,width,height; |
5c8756b0 JS |
308 | bool GotOrs; |
309 | GotOrs = ReadOrs(token); | |
11ad1132 | 310 | if (ReadRect(x,y,width,height)) |
f80ea77b | 311 | if (GotOrs==false) |
11ad1132 | 312 | ReadOrs(token); |
f80ea77b | 313 | if (token.Find(_T("WS_GROUP")) != wxNOT_FOUND) |
19d0f58d | 314 | style += _T("wxRB_GROUP"); |
11ad1132 | 315 | |
19d0f58d | 316 | m_xmlfile.Write(_T("\t\t<object class=\"wxRadioButton\"")); |
11ad1132 VS |
317 | WriteBasicInfo(x,y,width,height,varname); |
318 | WriteLabel(phrase); | |
319 | WriteStyle(style); | |
19d0f58d | 320 | m_xmlfile.Write(_T("\t\t</object>\n")); |
11ad1132 VS |
321 | |
322 | } | |
323 | ||
88d42654 | 324 | //PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP |
5c8756b0 | 325 | void rc2xml::ParsePushButton(wxString phrase, wxString varname) |
88d42654 | 326 | { |
2193517f | 327 | wxString token; |
88d42654 | 328 | |
5c8756b0 JS |
329 | token=PeekToken(); |
330 | while (!token.IsNumber()) | |
331 | { | |
332 | token=GetToken(); | |
333 | token=PeekToken(); | |
334 | } | |
2193517f VS |
335 | int x,y,width,height; |
336 | ReadRect(x,y,width,height); | |
88d42654 | 337 | |
19d0f58d | 338 | m_xmlfile.Write(_T("\t\t<object class=\"wxButton\"")); |
2193517f VS |
339 | WriteBasicInfo(x,y,width,height,varname); |
340 | WriteLabel(phrase); | |
19d0f58d | 341 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
342 | |
343 | } | |
344 | ||
345 | ||
2193517f | 346 | bool rc2xml::Seperator(int ch) |
88d42654 VS |
347 | { |
348 | //if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')|(ch=='\t')) | |
2193517f | 349 | if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='\t')) |
f80ea77b | 350 | return true; |
2193517f VS |
351 | |
352 | if (ch==EOF) | |
d7e3abf7 | 353 | { |
f80ea77b WS |
354 | m_done=true; |
355 | return true; | |
d7e3abf7 | 356 | } |
7c9955d1 | 357 | |
f80ea77b | 358 | return false; |
88d42654 VS |
359 | } |
360 | ||
5c8756b0 | 361 | void rc2xml::ParseGroupBox(wxString phrase, wxString varname) |
88d42654 VS |
362 | { |
363 | // GROUPBOX "Rotate",IDC_STATIC,1,1,71,79 | |
2193517f | 364 | wxString token; |
5c8756b0 JS |
365 | token=PeekToken(); |
366 | while (!token.IsNumber()) | |
367 | { | |
368 | token=GetToken(); | |
369 | token=PeekToken(); | |
370 | } | |
2193517f VS |
371 | int x,y,width,height; |
372 | ReadRect(x,y,width,height); | |
373 | ||
19d0f58d | 374 | m_xmlfile.Write(_T("\t\t<object class=\"wxStaticBox\"")); |
2193517f VS |
375 | WriteBasicInfo(x,y,width,height,varname); |
376 | WriteLabel(phrase); | |
19d0f58d | 377 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
378 | } |
379 | ||
11ad1132 | 380 | bool rc2xml::ReadRect(int & x, int & y, int & width, int & height) |
88d42654 | 381 | { |
19d0f58d JS |
382 | x=wxAtoi(GetToken()); |
383 | y=wxAtoi(GetToken()); | |
384 | width=wxAtoi(GetToken()); | |
11ad1132 VS |
385 | bool ret; |
386 | wxString tmp = GetToken(&ret); | |
19d0f58d | 387 | height=wxAtoi(tmp); |
11ad1132 | 388 | return ret; // check for more parameters |
88d42654 VS |
389 | } |
390 | ||
11ad1132 | 391 | wxString rc2xml::GetToken(bool *listseperator) |
88d42654 | 392 | { |
19d0f58d | 393 | wxString token=wxEmptyString; |
88d42654 | 394 | |
2193517f VS |
395 | if (m_rc.Eof()) |
396 | { | |
f80ea77b | 397 | m_done=true; |
2193517f | 398 | return token; |
88d42654 VS |
399 | } |
400 | ||
2193517f VS |
401 | int ch=0; |
402 | ReadChar(ch); | |
403 | if (ch==EOF) | |
404 | { | |
f80ea77b | 405 | m_done=true; |
2193517f VS |
406 | return token; |
407 | } | |
88d42654 | 408 | |
2193517f VS |
409 | while (Seperator(ch)) |
410 | { | |
411 | ReadChar(ch); | |
412 | if (m_done) | |
413 | return token; | |
414 | } | |
88d42654 | 415 | |
2193517f VS |
416 | if (ch==EOF) |
417 | { | |
f80ea77b | 418 | m_done=true; |
2193517f | 419 | } |
7c9955d1 | 420 | |
88d42654 | 421 | |
2193517f VS |
422 | while (!Seperator(ch)) |
423 | { | |
11ad1132 | 424 | token += (char)ch; |
2193517f VS |
425 | ReadChar(ch); |
426 | } | |
88d42654 | 427 | |
11ad1132 | 428 | if (ch == EOF) |
f80ea77b | 429 | m_done = true; |
88d42654 | 430 | |
11ad1132 VS |
431 | if (listseperator) |
432 | *listseperator = (ch == ','); | |
2193517f | 433 | return token; |
88d42654 VS |
434 | } |
435 | ||
2193517f | 436 | wxString rc2xml::GetQuoteField() |
88d42654 | 437 | { |
2193517f VS |
438 | wxString phrase; |
439 | //ASCII code 34 " | |
440 | int ch=0; | |
c988c5b2 JS |
441 | int ch1=0; |
442 | ||
2193517f | 443 | ReadChar(ch); |
88d42654 | 444 | |
c988c5b2 JS |
445 | // !! Changed by MS, 15th/11/04. Can now read strings such as |
446 | // """Catapult"" - blah blah", ... | |
447 | ||
2193517f VS |
448 | while (ch!=34) |
449 | ReadChar(ch); | |
7c9955d1 | 450 | |
c988c5b2 JS |
451 | // found first '"' |
452 | while (true) | |
5c8756b0 | 453 | { |
c988c5b2 JS |
454 | ReadChar(ch); |
455 | if (ch == 34) | |
456 | { | |
457 | // another quote? | |
458 | ReadChar(ch1); | |
459 | if (ch1 != 34) | |
460 | { | |
461 | // real end of string.. | |
462 | break; | |
463 | } | |
464 | ||
465 | // add a single quote - fall through | |
466 | } | |
467 | phrase+=(char)ch; | |
5c8756b0 | 468 | } |
c988c5b2 | 469 | |
5c8756b0 JS |
470 | return phrase; |
471 | } | |
472 | ||
473 | // string in stringtable may contain embedded quotes | |
474 | // escape characters retained to allow strings to be rewritten | |
475 | wxString rc2xml::GetStringQuote() | |
476 | { | |
477 | wxString phrase; | |
478 | //ASCII code 34 " | |
f80ea77b | 479 | bool done=false; |
d7e3abf7 | 480 | int ch=0,lastch=0; |
2193517f | 481 | ReadChar(ch); |
88d42654 | 482 | |
2193517f | 483 | while (ch!=34) |
5c8756b0 | 484 | ReadChar(ch); |
d7e3abf7 | 485 | |
5c8756b0 | 486 | ReadChar(ch); |
f80ea77b | 487 | while (done==false) |
d7e3abf7 | 488 | { |
5c8756b0 | 489 | if ((ch==34)&&(lastch!='\\')) |
d7e3abf7 WS |
490 | { |
491 | wxFileOffset p = m_rc.Tell(); | |
5c8756b0 | 492 | ReadChar(ch); |
d7e3abf7 | 493 | // RC supports "", for embedded quote, as well as \" |
7c9955d1 JS |
494 | if (ch==34) |
495 | phrase+='\\'; | |
5c8756b0 | 496 | else |
d7e3abf7 | 497 | { |
5c8756b0 | 498 | m_rc.Seek(p); |
f80ea77b | 499 | done = true; |
5c8756b0 JS |
500 | } |
501 | } | |
f80ea77b | 502 | if (done==true) |
5c8756b0 JS |
503 | break; |
504 | if (ch=='\r') | |
505 | ReadChar(ch); // skip | |
506 | if ((ch=='\n')&&(lastch=='\\')) // lastch <should> be this | |
507 | phrase+='n'; // escape | |
508 | else | |
d7e3abf7 WS |
509 | phrase+=(char)ch; |
510 | ||
5c8756b0 | 511 | lastch=ch; |
d7e3abf7 | 512 | ReadChar(ch); |
2193517f | 513 | } |
5c8756b0 | 514 | |
2193517f | 515 | return phrase; |
88d42654 VS |
516 | } |
517 | ||
2193517f | 518 | void rc2xml::ReadChar(int &ch) |
88d42654 | 519 | { |
d7e3abf7 | 520 | wxFileOffset result = m_rc.Tell(); |
88d42654 | 521 | |
2193517f | 522 | if((result>=m_filesize)) |
f80ea77b | 523 | m_done=true; |
88d42654 | 524 | |
d7e3abf7 | 525 | result = m_rc.Read(&ch,1); |
88d42654 | 526 | |
d7e3abf7 | 527 | if( result == wxInvalidOffset ) |
f80ea77b | 528 | m_done=true; |
88d42654 | 529 | |
2193517f | 530 | if(ch==EOF) |
f80ea77b | 531 | m_done=true; |
88d42654 VS |
532 | } |
533 | ||
5c8756b0 | 534 | void rc2xml::ParseComboBox(wxString varname) |
88d42654 | 535 | { |
7c9955d1 | 536 | /* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT | |
88d42654 | 537 | WS_VSCROLL | WS_TABSTOP */ |
11ad1132 | 538 | wxString token,style; |
2193517f | 539 | int x,y,width,height; |
5c8756b0 JS |
540 | bool GotOrs; |
541 | GotOrs = ReadOrs(token); | |
11ad1132 | 542 | if (ReadRect(x,y,width,height)) |
f80ea77b | 543 | if (GotOrs==false) |
11ad1132 | 544 | ReadOrs(token); |
88d42654 | 545 | |
19d0f58d | 546 | m_xmlfile.Write(_T("\t\t<object class=\"wxComboBox\"")); |
2193517f | 547 | WriteBasicInfo(x,y,width,height,varname); |
f80ea77b | 548 | if (token.Find(_T("CBS_SIMPLE")) != wxNOT_FOUND) |
19d0f58d | 549 | WriteStyle(_T("wxCB_SIMPLE")); |
f80ea77b | 550 | if (token.Find(_T("CBS_SORT")) != wxNOT_FOUND) |
19d0f58d | 551 | WriteStyle(_T("wxCB_SORT")); |
f80ea77b | 552 | if (token.Find(_T("CBS_DISABLENOSCROLL")) != wxNOT_FOUND) |
19d0f58d JS |
553 | WriteStyle(_T("wxLB_ALWAYS_SB")); |
554 | m_xmlfile.Write(_T("\n\t\t</object>\n")); | |
88d42654 VS |
555 | |
556 | } | |
557 | ||
2193517f | 558 | void rc2xml::ParseMenu(wxString varname) |
88d42654 | 559 | { |
19d0f58d | 560 | wxString token=wxEmptyString; |
2193517f VS |
561 | |
562 | //Write menubar to xml file | |
19d0f58d | 563 | m_xmlfile.Write(_T("\t<object class=\"wxMenuBar\"")); |
2193517f | 564 | //Avoid duplicate names this way |
19d0f58d | 565 | varname.Replace(_T("IDR_"),_T("MB_")); |
2193517f | 566 | WriteName(varname); |
19d0f58d | 567 | m_xmlfile.Write(_T(">\n")); |
2193517f | 568 | |
19d0f58d | 569 | while ((token!=_T("BEGIN"))&(token!=_T("{"))) |
2193517f VS |
570 | token=GetToken(); |
571 | ||
19d0f58d | 572 | while ((token!=_T("END"))&(token!=_T("}"))) |
2193517f VS |
573 | { |
574 | token=GetToken(); | |
5c8756b0 JS |
575 | token.MakeUpper(); |
576 | ||
19d0f58d | 577 | if (token==_T("POPUP")) |
2193517f VS |
578 | { |
579 | ParsePopupMenu(); | |
580 | } | |
581 | } | |
19d0f58d | 582 | m_xmlfile.Write(_T("\t</object>\n")); |
88d42654 VS |
583 | } |
584 | ||
2193517f | 585 | void rc2xml::ParsePopupMenu() |
88d42654 | 586 | { |
2193517f VS |
587 | static int menucount=0; |
588 | menucount++; | |
589 | wxString token,name,msg,longhelp,tip; | |
590 | token=GetQuoteField(); | |
591 | ||
592 | //Remove \t because it causes problems | |
88d42654 | 593 | |
2193517f VS |
594 | //spot=token.First("\\t"); |
595 | //token=token.Left(spot); | |
88d42654 VS |
596 | |
597 | //Write Menu item | |
598 | //Generate a fake name since RC menus don't have one | |
19d0f58d JS |
599 | name << _T("Menu_") << menucount; |
600 | m_xmlfile.Write(_T("\t\t<object class=\"wxMenu\"")); | |
2193517f | 601 | WriteName(name); |
19d0f58d | 602 | m_xmlfile.Write(_T(">\n")); |
2193517f | 603 | WriteLabel(token); |
2193517f | 604 | |
19d0f58d | 605 | while ((token!=_T("BEGIN"))&(token!=_T("{"))) |
2193517f VS |
606 | token=GetToken(); |
607 | ||
19d0f58d | 608 | while ((token!=_T("END"))&(token!=_T("}"))) |
2193517f VS |
609 | { |
610 | token=GetToken(); | |
5c8756b0 JS |
611 | token.MakeUpper(); |
612 | ||
19d0f58d | 613 | if (token==_T("POPUP")) |
2193517f | 614 | ParsePopupMenu(); |
7c9955d1 | 615 | |
19d0f58d | 616 | if (token==_T("MENUITEM")) |
2193517f VS |
617 | ParseMenuItem(); |
618 | } | |
19d0f58d | 619 | m_xmlfile.Write(_T("\t\t\t</object>\n")); |
88d42654 VS |
620 | } |
621 | ||
2193517f | 622 | wxString rc2xml::PeekToken() |
88d42654 | 623 | { |
2193517f VS |
624 | wxString token; |
625 | int p; | |
626 | p=m_rc.Tell(); | |
627 | token=GetToken(); | |
88d42654 | 628 | |
2193517f VS |
629 | m_rc.Seek(p); |
630 | return token; | |
88d42654 VS |
631 | } |
632 | //MS Windows pain in the butt CONTROL | |
2193517f | 633 | void rc2xml::ParseControlMS() |
88d42654 | 634 | { |
2193517f VS |
635 | wxString label,varname,kindctrl,token; |
636 | token=PeekToken(); | |
88d42654 | 637 | |
19d0f58d | 638 | if (token.Contains(_T("\""))) |
2193517f VS |
639 | ParseNormalMSControl(); |
640 | else | |
641 | ParseWeirdMSControl(); | |
88d42654 VS |
642 | |
643 | } | |
644 | ||
7c9955d1 | 645 | /* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | |
88d42654 VS |
646 | TBS_NOTICKS | WS_TABSTOP,52,73,100,15 |
647 | */ | |
648 | ||
19d0f58d | 649 | void rc2xml::ParseSlider(wxString WXUNUSED(label), wxString varname) |
88d42654 | 650 | { |
2193517f VS |
651 | wxString token,style; |
652 | ReadOrs(token); | |
f80ea77b | 653 | if (token.Find(_T("TBS_VERT"))!=wxNOT_FOUND) |
19d0f58d | 654 | style+=_T("wxSL_VERTICAL"); |
2193517f VS |
655 | //MFC RC Default is horizontal |
656 | else | |
19d0f58d | 657 | style+=_T("wxSL_HORIZONTAL"); |
2193517f VS |
658 | |
659 | int x,y,width,height; | |
660 | ReadRect(x,y,width,height); | |
19d0f58d | 661 | m_xmlfile.Write(_T("\t\t<object class=\"wxSlider\"")); |
2193517f VS |
662 | WriteBasicInfo(x,y,width,height,varname); |
663 | WriteStyle(style); | |
19d0f58d | 664 | m_xmlfile.Write(_T("\n\t\t</object>\n")); |
88d42654 VS |
665 | |
666 | } | |
7c9955d1 | 667 | /* |
88d42654 VS |
668 | CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32", |
669 | WS_BORDER,15,52,154,13 | |
670 | */ | |
19d0f58d | 671 | void rc2xml::ParseProgressBar(wxString WXUNUSED(label), wxString varname) |
88d42654 | 672 | { |
2193517f VS |
673 | wxString token,style; |
674 | ReadOrs(token); | |
7c9955d1 | 675 | |
2193517f VS |
676 | int x,y,width,height; |
677 | ReadRect(x,y,width,height); | |
678 | ||
88d42654 | 679 | //Always horizontal in MFC |
19d0f58d | 680 | m_xmlfile.Write(_T("\t\t<object class=\"wxGauge\"")); |
2193517f VS |
681 | WriteBasicInfo(x,y,width,height,varname); |
682 | WriteStyle(style); | |
19d0f58d | 683 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
684 | } |
685 | ||
2193517f | 686 | bool rc2xml::ReadOrs(wxString & orstring) |
88d42654 | 687 | { |
2193517f VS |
688 | wxString token; |
689 | ||
690 | token=PeekToken(); | |
691 | if (token.IsNumber()) | |
f80ea77b | 692 | return false; |
2193517f VS |
693 | orstring=GetToken(); |
694 | ||
695 | while(PeekToken()==_T("|")) | |
696 | { | |
7c9955d1 | 697 | //Grab | |
2193517f VS |
698 | orstring+=GetToken(); |
699 | //Grab next token | |
700 | orstring+=GetToken(); | |
701 | } | |
f80ea77b | 702 | return true; |
88d42654 VS |
703 | } |
704 | ||
5c8756b0 | 705 | //Is it a checkbutton or a radiobutton or a pushbutton or a groupbox |
2193517f | 706 | void rc2xml::ParseCtrlButton(wxString label, wxString varname) |
88d42654 | 707 | { |
2193517f | 708 | wxString token; |
5c8756b0 JS |
709 | int p; |
710 | p=m_rc.Tell(); | |
2193517f | 711 | ReadOrs(token); |
5c8756b0 | 712 | m_rc.Seek(p); |
2193517f | 713 | |
f80ea77b | 714 | if (token.Find(_T("BS_AUTOCHECKBOX"))!=wxNOT_FOUND) |
5c8756b0 | 715 | ParseCheckBox(label, varname); |
f80ea77b WS |
716 | else if ((token.Find(_T("BS_AUTORADIOBUTTON"))!=wxNOT_FOUND)|| |
717 | (token.Find(_T("BS_RADIOBUTTON"))!=wxNOT_FOUND)) | |
5c8756b0 | 718 | ParseRadioButton(label, varname); |
f80ea77b | 719 | else if (token.Find(_T("BS_GROUPBOX"))!=wxNOT_FOUND) |
7c9955d1 | 720 | ParseGroupBox(label, varname); |
f80ea77b WS |
721 | else // if ((token.Find("BS_PUSHBUTTON")!=wxNOT_FOUND)|| |
722 | // (token.Find("BS_DEFPUSHBUTTON")!=wxNOT_FOUND)) | |
5c8756b0 | 723 | ParsePushButton(label, varname); // make default case |
88d42654 VS |
724 | } |
725 | ||
2193517f | 726 | void rc2xml::WriteSize(int width, int height) |
88d42654 | 727 | { |
2193517f | 728 | wxString msg; |
19d0f58d | 729 | msg << _T(" <size>") << width << _T(",") << height << _T("d</size>"); |
2193517f | 730 | m_xmlfile.Write(msg); |
88d42654 VS |
731 | } |
732 | ||
2193517f | 733 | void rc2xml::WritePosition(int x, int y) |
88d42654 | 734 | { |
2193517f | 735 | wxString msg; |
19d0f58d | 736 | msg << _T(" <pos>") << x << _T(",") << y << _T("d</pos>"); |
2193517f | 737 | m_xmlfile.Write(msg); |
88d42654 VS |
738 | } |
739 | ||
2193517f | 740 | void rc2xml::WriteTitle(wxString title) |
88d42654 | 741 | { |
2193517f | 742 | wxString msg; |
19d0f58d | 743 | msg=_T("\t\t<title>")+title+_T("</title>\n"); |
2193517f | 744 | m_xmlfile.Write(msg); |
88d42654 VS |
745 | } |
746 | ||
2193517f | 747 | void rc2xml::WriteName(wxString name) |
88d42654 | 748 | { |
7c9955d1 | 749 | |
2193517f VS |
750 | //Try to convert any number ids into names |
751 | name=LookUpId(name); | |
be5a51fb | 752 | //Replace common MS ids with wxWidgets ids |
88d42654 | 753 | //I didn't do everyone of them |
19d0f58d JS |
754 | if (name==_T("IDOK")) |
755 | name=_T("wxID_OK"); | |
756 | else if (name==_T("IDCANCEL")) | |
757 | name=_T("wxID_CANCEL"); | |
758 | else if (name==_T("IDAPPLY")) | |
759 | name=_T("wxID_APPLY"); | |
760 | else if (name==_T("ID_FILE_OPEN")) | |
761 | name=_T("wxID_OPEN"); | |
762 | else if (name==_T("ID_FILE_CLOSE")) | |
763 | name=_T("wxID_CLOSE"); | |
764 | else if (name==_T("ID_FILE_SAVE")) | |
765 | name=_T("wxID_SAVE"); | |
766 | else if (name==_T("ID_FILE_SAVE_AS")) | |
767 | name=_T("wxID_SAVEAS"); | |
768 | else if (name==_T("ID_APP_EXIT")) | |
769 | name=_T("wxID_EXIT"); | |
770 | else if (name==_T("ID_FILE_PRINT")) | |
771 | name=_T("wxID_PRINT"); | |
772 | else if (name==_T("ID_FILE_PRINT_PREVIEW")) | |
773 | name=_T("wxID_PREVIEW"); | |
774 | else if (name==_T("ID_FILE_PRINT_SETUP")) | |
775 | name=_T("wxID_PRINT_SETUP"); | |
776 | else if (name==_T("ID_APP_ABOUT")) | |
777 | name=_T("wxID_ABOUT"); | |
778 | else if (name==_T("ID_EDIT_UNDO")) | |
779 | name=_T("wxID_UNDO"); | |
780 | else if (name==_T("ID_EDIT_CUT")) | |
781 | name=_T("wxID_CUT"); | |
782 | else if (name==_T("ID_EDIT_COPY")) | |
783 | name=_T("wxID_COPY"); | |
784 | else if (name==_T("ID_EDIT_PASTE")) | |
785 | name=_T("wxID_PASTE"); | |
786 | else if (name==_T("IDYES")) | |
787 | name=_T("wxID_YES"); | |
788 | else if (name==_T("IDNO")) | |
789 | name=_T("wxID_NO"); | |
790 | else if (name==_T("IDHELP")) | |
791 | name=_T("wxID_HELP"); | |
792 | ||
793 | m_xmlfile.Write(_T(" name= \"")+name+_T("\"")); | |
88d42654 VS |
794 | } |
795 | ||
2193517f | 796 | void rc2xml::WriteLabel(wxString label) |
88d42654 | 797 | { |
19d0f58d | 798 | label.Replace(_T("&"),_T("$")); |
c988c5b2 | 799 | // changes by MS, handle '<' '>' characters within a label. |
b0e43baf WS |
800 | label.Replace(_T("<"),_T("<")); |
801 | label.Replace(_T(">"),_T(">")); | |
19d0f58d | 802 | m_xmlfile.Write(_T("\t\t\t<label>")+label+_T("</label>\n")); |
88d42654 VS |
803 | } |
804 | ||
2193517f | 805 | void rc2xml::WriteBasicInfo(int x, int y, int width, int height, wxString name) |
88d42654 | 806 | { |
2193517f | 807 | WriteName(name); |
19d0f58d JS |
808 | m_xmlfile.Write(_T(">\n")); |
809 | m_xmlfile.Write(_T("\t\t\t")); | |
2193517f VS |
810 | WritePosition(x,y); |
811 | WriteSize(width,height); | |
19d0f58d | 812 | m_xmlfile.Write(_T("\n")); |
88d42654 VS |
813 | } |
814 | ||
2193517f | 815 | void rc2xml::WriteStyle(wxString style) |
88d42654 | 816 | { |
2193517f VS |
817 | if (style.Length()==0) |
818 | return; | |
19d0f58d | 819 | m_xmlfile.Write(_T("\t\t\t<style>")+style+_T("</style>\n")); |
88d42654 VS |
820 | } |
821 | /* | |
7c9955d1 | 822 | LISTBOX IDC_LIST1,16,89,48,40,LBS_SORT | LBS_MULTIPLESEL | |
88d42654 VS |
823 | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP |
824 | */ | |
5c8756b0 | 825 | void rc2xml::ParseListBox(wxString varname) |
88d42654 | 826 | { |
2193517f | 827 | wxString token; |
5c8756b0 JS |
828 | token=PeekToken(); |
829 | while (!token.IsNumber()) | |
830 | { | |
831 | token=GetToken(); | |
832 | token=PeekToken(); | |
833 | } | |
2193517f VS |
834 | int x,y,width,height; |
835 | ReadRect(x,y,width,height); | |
88d42654 | 836 | |
19d0f58d | 837 | m_xmlfile.Write(_T("\t\t<object class=\"wxListBox\"")); |
2193517f | 838 | WriteBasicInfo(x,y,width,height,varname); |
19d0f58d | 839 | m_xmlfile.Write(_T("\n\t\t</object>\n")); |
88d42654 VS |
840 | |
841 | } | |
842 | /* | |
7c9955d1 | 843 | CONTROL "",IDC_RICHEDIT1,"RICHEDIT",ES_AUTOHSCROLL | WS_BORDER | |
88d42654 VS |
844 | WS_TABSTOP,103,110,40,14 |
845 | */ | |
8b523dc5 | 846 | void rc2xml::ParseRichEdit(wxString WXUNUSED(label), wxString varname) |
88d42654 | 847 | { |
2193517f VS |
848 | wxString token; |
849 | //while (ReadOrs(token)); | |
850 | ReadOrs(token); | |
851 | int x,y,width,height; | |
852 | ReadRect(x,y,width,height); | |
853 | wxString style; | |
88d42654 | 854 | //Make it a rich text control |
19d0f58d JS |
855 | style+=_T("wxTE_MULTILINE "); |
856 | m_xmlfile.Write(_T("\t\t<object class=\"wxTextCtrl\"")); | |
2193517f VS |
857 | WriteBasicInfo(x,y,width,height,varname); |
858 | WriteStyle(style); | |
19d0f58d | 859 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
860 | |
861 | } | |
862 | /* | |
863 | CONTROL "Spin1",IDC_SPIN1,"msctls_updown32",UDS_ARROWKEYS,209,72, | |
864 | 19,26 | |
865 | */ | |
19d0f58d | 866 | void rc2xml::ParseSpinCtrl(wxString WXUNUSED(label), wxString varname) |
88d42654 | 867 | { |
2193517f | 868 | wxString token,style; |
7c9955d1 | 869 | |
2193517f | 870 | ReadOrs(token); |
f80ea77b | 871 | if (token.Find(_T("UDS_HORZ"))!=wxNOT_FOUND) |
19d0f58d | 872 | style=_T("wxSP_HORIZONTAL"); |
2193517f VS |
873 | //MFC default |
874 | else | |
19d0f58d | 875 | style=_T("wxSP_VERTICAL"); |
2193517f VS |
876 | |
877 | int x,y,width,height; | |
878 | ReadRect(x,y,width,height); | |
19d0f58d | 879 | m_xmlfile.Write(_T("\t\t<object class=\"wxSpinButton\"")); |
2193517f VS |
880 | WriteBasicInfo(x,y,width,height,varname); |
881 | WriteStyle(style); | |
19d0f58d | 882 | m_xmlfile.Write(_T("\n\t\t</object>\n")); |
88d42654 VS |
883 | |
884 | } | |
885 | ||
2193517f | 886 | void rc2xml::FirstPass() |
88d42654 | 887 | { |
2193517f VS |
888 | wxString token,prevtok; |
889 | while (!m_done) | |
890 | { | |
891 | token=GetToken(); | |
19d0f58d | 892 | if (token==_T("BITMAP")) |
2193517f | 893 | ParseBitmap(prevtok); |
19d0f58d | 894 | else if (token==_T("STRINGTABLE")) |
2193517f | 895 | ParseStringTable(prevtok); |
19d0f58d | 896 | else if (token==_T("ICON")) |
2193517f | 897 | ParseIcon(prevtok); |
7c9955d1 | 898 | |
2193517f VS |
899 | prevtok=token; |
900 | } | |
88d42654 VS |
901 | } |
902 | ||
2193517f | 903 | void rc2xml::ParseBitmap(wxString varname) |
88d42654 | 904 | { |
19311d4e WS |
905 | wxString token; |
906 | wxString *bitmapfile; | |
7c9955d1 | 907 | |
2193517f VS |
908 | token=PeekToken(); |
909 | //Microsoft notation? | |
19d0f58d | 910 | if (token==_T("DISCARDABLE")) |
2193517f VS |
911 | { |
912 | token=GetToken(); | |
913 | token=PeekToken(); | |
914 | } | |
915 | bitmapfile=new wxString; | |
916 | *bitmapfile=GetQuoteField(); | |
917 | m_bitmaplist->Append(varname,bitmapfile); | |
88d42654 VS |
918 | |
919 | } | |
920 | ||
921 | ||
2193517f | 922 | void rc2xml::SecondPass() |
88d42654 | 923 | { |
2193517f VS |
924 | wxString token,prevtok; |
925 | while (!m_done) | |
926 | { | |
927 | token=GetToken(); | |
19d0f58d | 928 | if ((token==_T("DIALOG"))||(token==_T("DIALOGEX"))) |
2193517f | 929 | ParseDialog(prevtok); |
19d0f58d | 930 | else if (token==_T("MENU")) |
2193517f | 931 | ParseMenu(prevtok); |
19d0f58d | 932 | else if (token==_T("TOOLBAR")) |
2193517f | 933 | ParseToolBar(prevtok); |
7c9955d1 | 934 | |
2193517f VS |
935 | prevtok=token; |
936 | } | |
88d42654 VS |
937 | |
938 | } | |
939 | ||
2193517f | 940 | void rc2xml::ParseToolBar(wxString varname) |
88d42654 | 941 | { |
7c9955d1 | 942 | wxString token; |
2193517f | 943 | token=GetToken(); |
19d0f58d | 944 | wxASSERT_MSG(token==_T("DISCARDABLE"),_T("Error in toolbar parsing")); |
88d42654 | 945 | //Look up bitmap for toolbar and load |
2193517f VS |
946 | wxNode *node=m_bitmaplist->Find(LookUpId(varname)); |
947 | wxString *bitmappath; | |
19d0f58d | 948 | bitmappath=(wxString *)node->GetData(); |
2193517f VS |
949 | wxBitmap bitmap; |
950 | if (!bitmap.LoadFile(*bitmappath,wxBITMAP_TYPE_BMP )) | |
19d0f58d | 951 | wxLogError(_T("Unable to load bitmap:")+*bitmappath); |
88d42654 VS |
952 | |
953 | //Write toolbar to xml file | |
f80ea77b | 954 | m_xmlfile.Write(_T("\t<object class=\"wxToolBar\"")); |
88d42654 | 955 | //Avoid duplicate names this way |
19d0f58d | 956 | varname.Replace(_T("IDR_"),_T("TB_")); |
2193517f | 957 | WriteName(varname); |
19d0f58d | 958 | m_xmlfile.Write(_T(">\n")); |
2193517f | 959 | wxString style; |
19d0f58d | 960 | style+=_T("wxTB_FLAT"); |
2193517f | 961 | WriteStyle(style); |
88d42654 | 962 | |
88d42654 VS |
963 | |
964 | //Grab width and height | |
2193517f | 965 | int width,height; |
19d0f58d JS |
966 | width=wxAtoi(GetToken()); |
967 | height=wxAtoi(GetToken()); | |
2193517f | 968 | |
7c9955d1 | 969 | int c=0; |
2193517f VS |
970 | wxString buttonname,msg,tip,longhelp; |
971 | token=GetToken(); | |
19d0f58d | 972 | while ((token!=_T("BEGIN"))&(token!=_T("{"))) |
2193517f VS |
973 | token=GetToken(); |
974 | ||
19d0f58d | 975 | while ((token!=_T("END"))&(token!=_T("}"))) |
2193517f | 976 | { |
19d0f58d | 977 | if (token==_T("BUTTON")) |
2193517f VS |
978 | { |
979 | buttonname=GetToken(); | |
19d0f58d | 980 | m_xmlfile.Write(_T("\t\t\t<object class=\"tool\"")); |
2193517f | 981 | WriteName(buttonname); |
19d0f58d | 982 | m_xmlfile.Write(_T(">\n")); |
2193517f VS |
983 | //Write tool tip if any |
984 | if (LookUpString(buttonname,msg)) | |
985 | { | |
986 | SplitHelp(msg,tip,longhelp); | |
19d0f58d | 987 | m_xmlfile.Write(_T("\t\t\t\t<tooltip>")+tip+_T("</tooltip>\n")); |
f80ea77b | 988 | m_xmlfile.Write(_T("\t\t<longhelp>")+longhelp+_T("</longhelp>\n")); |
2193517f VS |
989 | } |
990 | //Make a bitmap file name | |
991 | buttonname=CleanName(buttonname); | |
19d0f58d JS |
992 | buttonname+=_T(".bmp"); |
993 | m_xmlfile.Write(_T("\t\t\t\t<bitmap>")+buttonname+_T("</bitmap>\n")); | |
2193517f | 994 | WriteToolButton(buttonname,c,width,height,bitmap); |
19d0f58d | 995 | m_xmlfile.Write(_T("\t\t\t</object>\n")); |
2193517f VS |
996 | c++; |
997 | } | |
19d0f58d | 998 | else if (token==_T("SEPARATOR")) |
2193517f | 999 | { |
19d0f58d | 1000 | m_xmlfile.Write(_T("\t\t\t<object class=\"separator\"/>\n")); |
2193517f VS |
1001 | } |
1002 | token=GetToken(); | |
1003 | } | |
19d0f58d | 1004 | m_xmlfile.Write(_T("\t</object>\n")); |
88d42654 VS |
1005 | } |
1006 | ||
1007 | //Extract bitmaps from larger toolbar bitmap | |
2193517f | 1008 | void rc2xml::WriteToolButton(wxString name,int index, int width, int height, wxBitmap bitmap) |
88d42654 | 1009 | { |
2193517f VS |
1010 | int x; |
1011 | x=index*width; | |
1012 | wxRect r(x,0,width,height); | |
1013 | wxBitmap little; | |
1014 | little=bitmap.GetSubBitmap(r); | |
2c99715a | 1015 | little.SaveFile(m_targetpath+name,wxBITMAP_TYPE_BMP); |
88d42654 VS |
1016 | } |
1017 | ||
8b523dc5 | 1018 | void rc2xml::ParseStringTable(wxString WXUNUSED(varname)) |
88d42654 | 1019 | { |
2193517f VS |
1020 | wxString token; |
1021 | token=GetToken(); | |
19d0f58d | 1022 | while ((token!=_T("BEGIN"))&(token!=_T("{"))) |
2193517f VS |
1023 | token=GetToken(); |
1024 | token=GetToken(); | |
1025 | wxString *msg; | |
1026 | ||
19d0f58d | 1027 | while ((token!=_T("END"))&(token!=_T("}"))) |
8b523dc5 | 1028 | { |
2193517f | 1029 | msg=new wxString; |
5c8756b0 | 1030 | *msg=GetStringQuote(); |
2193517f VS |
1031 | m_stringtable->Append(token,msg); |
1032 | token=GetToken(); | |
8b523dc5 | 1033 | } |
88d42654 VS |
1034 | } |
1035 | ||
2193517f | 1036 | bool rc2xml::LookUpString(wxString strid,wxString & st) |
88d42654 | 1037 | { |
2193517f VS |
1038 | wxNode *node=m_stringtable->Find(strid); |
1039 | wxString *s; | |
1040 | if (node==NULL) | |
f80ea77b | 1041 | return false; |
88d42654 | 1042 | |
19d0f58d | 1043 | s=(wxString *)node->GetData(); |
2193517f | 1044 | st=*s; |
88d42654 | 1045 | |
f80ea77b | 1046 | return true; |
88d42654 VS |
1047 | } |
1048 | ||
2193517f | 1049 | bool rc2xml::SplitHelp(wxString msg, wxString &shorthelp, wxString &longhelp) |
88d42654 | 1050 | { |
2193517f | 1051 | int spot; |
19d0f58d | 1052 | spot=msg.Find(_T("\\n")); |
f80ea77b | 1053 | if (spot==wxNOT_FOUND) |
2193517f VS |
1054 | { |
1055 | shorthelp=msg; | |
1056 | longhelp=msg; | |
1057 | } | |
1058 | ||
1059 | longhelp=msg.Left(spot); | |
1060 | spot=msg.Length()-spot-2; | |
1061 | shorthelp=msg.Right(spot); | |
f80ea77b | 1062 | return true; |
88d42654 VS |
1063 | } |
1064 | ||
2193517f | 1065 | void rc2xml::ParseMenuItem() |
88d42654 | 1066 | { |
2193517f VS |
1067 | wxString token,name,msg,tip,longhelp; |
1068 | //int spot; | |
19d0f58d | 1069 | if (PeekToken()==_T("SEPARATOR")) |
2193517f | 1070 | { |
19d0f58d | 1071 | m_xmlfile.Write(_T("\t\t\t<object class=\"separator\"/>\n")); |
2193517f VS |
1072 | return; |
1073 | } | |
1074 | ||
1075 | token=GetQuoteField(); | |
1076 | name=GetToken(); | |
1077 | //Remove \t because it causes problems | |
1078 | //spot=token.First("\\t"); | |
1079 | //token=token.Left(spot); | |
19d0f58d | 1080 | m_xmlfile.Write(_T("\t\t\t<object class=\"wxMenuItem\"")); |
2193517f | 1081 | WriteName(name); |
19d0f58d | 1082 | m_xmlfile.Write(_T(">\n")); |
2193517f | 1083 | WriteLabel(token); |
88d42654 | 1084 | //Look up help if any listed in stringtable |
5c8756b0 | 1085 | //can't assume numbers correlate, restrict to string identifiers |
7c9955d1 | 1086 | if ((!name.IsNumber())&&(LookUpString(name,msg))) |
2193517f VS |
1087 | { |
1088 | SplitHelp(msg,tip,longhelp); | |
19d0f58d JS |
1089 | m_xmlfile.Write(_T("\t\t\t<help>") |
1090 | +longhelp+_T("</help>\n")); | |
2193517f | 1091 | } |
88d42654 | 1092 | //look for extra attributes like checked and break |
2193517f VS |
1093 | wxString ptoken; |
1094 | ptoken=PeekToken(); | |
5c8756b0 | 1095 | ptoken.MakeUpper(); |
19d0f58d | 1096 | while ((ptoken!=_T("MENUITEM"))&(ptoken!=_T("POPUP"))&(ptoken!=_T("END"))) |
2193517f VS |
1097 | { |
1098 | token=GetToken(); | |
5c8756b0 | 1099 | ptoken.MakeUpper(); |
19d0f58d JS |
1100 | if (token==_T("CHECKED")) |
1101 | m_xmlfile.Write(_T("\t\t\t<checkable>1</checkable>\n")); | |
b2247ee9 CE |
1102 | else if (token==_T("MENUBREAK")) |
1103 | ; | |
2193517f | 1104 | //m_xmlfile.Write("\t\t\t</break>\n"); |
b2247ee9 CE |
1105 | else if (token==_T("GRAYED")) |
1106 | ; | |
2193517f | 1107 | else |
19d0f58d | 1108 | wxLogError(_T("Unknown Menu Item token:")+token); |
7c9955d1 | 1109 | |
2193517f | 1110 | ptoken=PeekToken(); |
5c8756b0 | 1111 | ptoken.MakeUpper(); |
2193517f | 1112 | } |
19d0f58d | 1113 | m_xmlfile.Write(_T("\t\t\t</object>\n")); |
88d42654 VS |
1114 | |
1115 | } | |
1116 | ||
1117 | //ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 | |
2193517f | 1118 | void rc2xml::ParseIconStatic() |
88d42654 | 1119 | { |
2193517f VS |
1120 | wxString token; |
1121 | wxString varname,iconname; | |
5c8756b0 | 1122 | token = PeekToken(); |
19d0f58d | 1123 | if (token.Contains(_T("\""))) |
5c8756b0 JS |
1124 | iconname = GetQuoteField(); |
1125 | else | |
2193517f | 1126 | iconname=GetToken(); |
88d42654 | 1127 | //Look up icon |
2193517f | 1128 | varname=GetToken(); |
88d42654 | 1129 | |
2193517f VS |
1130 | int x,y,width,height; |
1131 | ReadRect(x,y,width,height); | |
88d42654 | 1132 | |
19d0f58d | 1133 | m_xmlfile.Write(_T("\t\t<object class=\"wxStaticBitmap\"")); |
2193517f | 1134 | WriteBasicInfo(x,y,width,height,varname); |
88d42654 | 1135 | //Save icon as a bitmap |
2193517f | 1136 | WriteIcon(iconname); |
19d0f58d | 1137 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
1138 | |
1139 | } | |
1140 | //IDR_MAINFRAME ICON DISCARDABLE "res\\mfcexample.ico" | |
2193517f | 1141 | void rc2xml::ParseIcon(wxString varname) |
88d42654 | 1142 | { |
19311d4e WS |
1143 | wxString token; |
1144 | wxString *iconfile; | |
2193517f VS |
1145 | iconfile=new wxString; |
1146 | token=PeekToken(); | |
88d42654 | 1147 | |
2193517f VS |
1148 | *iconfile=GetQuoteField(); |
1149 | m_iconlist->Append(varname,iconfile); | |
7c9955d1 | 1150 | |
88d42654 VS |
1151 | |
1152 | } | |
1153 | ||
2193517f | 1154 | wxString rc2xml::CleanName(wxString name) |
88d42654 | 1155 | { |
2193517f | 1156 | name.MakeLower(); |
19d0f58d JS |
1157 | name.Replace(_T("id_"),wxEmptyString); |
1158 | name.Replace(_T("idr_"),wxEmptyString); | |
1159 | name.Replace(_T("idb_"),wxEmptyString); | |
1160 | name.Replace(_T("idc_"),wxEmptyString); | |
92a19c2e | 1161 | |
19d0f58d | 1162 | name.Replace(_T(".ico"),wxEmptyString); |
92a19c2e | 1163 | |
19d0f58d | 1164 | name.Replace(_T(".bmp"),wxEmptyString); |
2193517f | 1165 | return name; |
88d42654 VS |
1166 | } |
1167 | // And the award for most messed up control goes to... | |
1168 | // CONTROL IDB_FACE,IDC_STATIC,"Static",SS_BITMAP,26,62,32,30 | |
2193517f | 1169 | void rc2xml::ParseStaticBitmap(wxString bitmapname, wxString varname) |
88d42654 | 1170 | { |
2193517f VS |
1171 | wxString token; |
1172 | //Grab SS_BITMAP | |
5c8756b0 | 1173 | ReadOrs(token); |
88d42654 | 1174 | |
88d42654 | 1175 | |
2193517f VS |
1176 | int x,y,width,height; |
1177 | ReadRect(x,y,width,height); | |
1178 | ||
19d0f58d | 1179 | m_xmlfile.Write(_T("\t\t<object class=\"wxStaticBitmap\"")); |
2193517f VS |
1180 | WriteBasicInfo(x,y,width,height,varname); |
1181 | WriteBitmap(bitmapname); | |
19d0f58d | 1182 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
1183 | |
1184 | } | |
1185 | ||
2193517f | 1186 | void rc2xml::ParseNormalMSControl() |
88d42654 VS |
1187 | { |
1188 | wxString label,varname,kindctrl; | |
1189 | ||
1190 | label=GetQuoteField(); | |
1191 | varname=GetToken(); | |
1192 | kindctrl=GetQuoteField(); | |
1193 | kindctrl.MakeUpper(); | |
1194 | ||
19d0f58d | 1195 | if (kindctrl==_T("MSCTLS_UPDOWN32")) |
2193517f | 1196 | ParseSpinCtrl(label,varname); |
19d0f58d | 1197 | if (kindctrl==_T("MSCTLS_TRACKBAR32")) |
2193517f | 1198 | ParseSlider(label,varname); |
19d0f58d | 1199 | if (kindctrl==_T("MSCTLS_PROGRESS32")) |
2193517f | 1200 | ParseProgressBar(label,varname); |
19d0f58d | 1201 | if (kindctrl==_T("SYSTREEVIEW32")) |
2193517f | 1202 | ParseTreeCtrl(label,varname); |
19d0f58d | 1203 | if (kindctrl==_T("SYSMONTHCAL32")) |
2193517f | 1204 | ParseCalendar(label,varname); |
19d0f58d | 1205 | if (kindctrl==_T("SYSLISTVIEW32")) |
2193517f | 1206 | ParseListCtrl(label,varname); |
19d0f58d | 1207 | if (kindctrl==_T("BUTTON")) |
2193517f | 1208 | ParseCtrlButton(label,varname); |
19d0f58d | 1209 | if (kindctrl==_T("RICHEDIT")) |
2193517f | 1210 | ParseRichEdit(label,varname); |
19d0f58d | 1211 | if (kindctrl==_T("STATIC")) |
5c8756b0 JS |
1212 | { |
1213 | wxString token; | |
1214 | int p=m_rc.Tell(); | |
1215 | ReadOrs(token); | |
1216 | m_rc.Seek(p); | |
f80ea77b | 1217 | if (token.Find(_T("SS_BITMAP"))!=wxNOT_FOUND) |
5c8756b0 JS |
1218 | ParseStaticBitmap(label,varname); |
1219 | else | |
1220 | ParseStaticText(label,varname); | |
1221 | } | |
19d0f58d | 1222 | if (kindctrl==_T("EDIT")) |
5c8756b0 | 1223 | ParseTextCtrl(varname); |
19d0f58d | 1224 | if (kindctrl==_T("LISTBOX")) |
5c8756b0 | 1225 | ParseListBox(varname); |
19d0f58d | 1226 | if (kindctrl==_T("COMBOBOX")) |
5c8756b0 | 1227 | ParseComboBox(varname); |
88d42654 VS |
1228 | |
1229 | } | |
1230 | ||
2193517f | 1231 | void rc2xml::ParseWeirdMSControl() |
88d42654 | 1232 | { |
2193517f VS |
1233 | wxString kindctrl; |
1234 | wxString varname; | |
1235 | wxString id; | |
1236 | id=GetToken(); | |
1237 | varname=GetToken(); | |
1238 | kindctrl=GetQuoteField(); | |
1239 | kindctrl.MakeUpper(); | |
88d42654 | 1240 | // CONTROL IDB_FACE,IDC_STATIC,"Static",SS_BITMAP,26,62,32,30 |
19d0f58d | 1241 | if (kindctrl==_T("STATIC")) |
2193517f | 1242 | { |
19d0f58d | 1243 | if (PeekToken()==_T("SS_BITMAP")) |
2193517f VS |
1244 | ParseStaticBitmap(id,varname); |
1245 | else | |
19d0f58d | 1246 | wxLogError(_T("Unknown MS Control Static token")); |
2193517f | 1247 | } |
88d42654 VS |
1248 | |
1249 | } | |
1250 | //SCROLLBAR IDC_SCROLLBAR1,219,56,10,40,SBS_VERT | |
1251 | ||
2193517f | 1252 | void rc2xml::ParseScrollBar() |
88d42654 | 1253 | { |
2193517f VS |
1254 | wxString token; |
1255 | wxString varname; | |
1256 | ||
1257 | varname=GetToken(); | |
1258 | int x,y,width,height; | |
1259 | ReadRect(x,y,width,height); | |
1260 | wxString style; | |
1261 | ||
1262 | ReadOrs(token); | |
7c9955d1 | 1263 | |
f80ea77b | 1264 | if (token.Find(_T("SBS_VERT"))!=wxNOT_FOUND) |
2193517f | 1265 | style=_T("wxSB_VERTICAL"); |
88d42654 | 1266 | //Default MFC style is horizontal |
2193517f VS |
1267 | else |
1268 | style=_T("wxSB_HORIZONTAL"); | |
88d42654 | 1269 | |
19d0f58d | 1270 | m_xmlfile.Write(_T("\t\t<object class=\"wxScrollBar\"")); |
2193517f VS |
1271 | WriteBasicInfo(x,y,width,height,varname); |
1272 | WriteStyle(style); | |
19d0f58d | 1273 | m_xmlfile.Write(_T("\n\t\t</object>\n")); |
88d42654 VS |
1274 | |
1275 | } | |
1276 | // CONTROL "Tree1",IDC_TREE1,"SysTreeView32",WS_BORDER | WS_TABSTOP, | |
1277 | // 7,7,66,61 | |
1278 | ||
19d0f58d | 1279 | void rc2xml::ParseTreeCtrl(wxString WXUNUSED(label), wxString varname) |
88d42654 | 1280 | { |
2193517f VS |
1281 | wxString token; |
1282 | //while (ReadOrs(token)); | |
1283 | ReadOrs(token); | |
1284 | int x,y,width,height; | |
1285 | ReadRect(x,y,width,height); | |
19d0f58d | 1286 | m_xmlfile.Write(_T("\t\t<object class=\"wxTreeCtrl\"")); |
2193517f | 1287 | WriteBasicInfo(x,y,width,height,varname); |
19d0f58d | 1288 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
1289 | |
1290 | } | |
1291 | // CONTROL "MonthCalendar1",IDC_MONTHCALENDAR1,"SysMonthCal32", | |
1292 | //MCS_NOTODAY | WS_TABSTOP,105,71,129,89 | |
1293 | ||
19d0f58d | 1294 | void rc2xml::ParseCalendar(wxString WXUNUSED(label), wxString varname) |
88d42654 | 1295 | { |
2193517f VS |
1296 | wxString token; |
1297 | //while (ReadOrs(token)); | |
1298 | ReadOrs(token); | |
1299 | int x,y,width,height; | |
1300 | ReadRect(x,y,width,height); | |
19d0f58d | 1301 | m_xmlfile.Write(_T("\t\t<object class=\"wxCalendarCtrl\"")); |
2193517f | 1302 | WriteBasicInfo(x,y,width,height,varname); |
19d0f58d | 1303 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
1304 | } |
1305 | // CONTROL "List1",IDC_LIST1,"SysListView32",WS_BORDER | WS_TABSTOP, | |
1306 | // 7,89,68,71 | |
1307 | ||
19d0f58d | 1308 | void rc2xml::ParseListCtrl(wxString WXUNUSED(label), wxString varname) |
88d42654 | 1309 | { |
2193517f VS |
1310 | wxString token; |
1311 | //while (ReadOrs(token)); | |
1312 | ReadOrs(token); | |
1313 | int x,y,width,height; | |
1314 | ReadRect(x,y,width,height); | |
19d0f58d | 1315 | m_xmlfile.Write(_T("\t\t<object class=\"wxListCtrl\"")); |
2193517f | 1316 | WriteBasicInfo(x,y,width,height,varname); |
19d0f58d | 1317 | m_xmlfile.Write(_T("\t\t</object>\n")); |
88d42654 VS |
1318 | |
1319 | } | |
2193517f VS |
1320 | |
1321 | void rc2xml::WriteBitmap(wxString bitmapname) | |
1322 | { | |
1323 | //Look up bitmap | |
1324 | wxNode *node=m_bitmaplist->Find(LookUpId(bitmapname)); | |
1325 | if (node==NULL) | |
1326 | { | |
19d0f58d JS |
1327 | m_xmlfile.Write(_T("\t\t\t<bitmap>missingfile</bitmap>\n")); |
1328 | wxLogError(_T("Unable to find bitmap:")+bitmapname); | |
2193517f VS |
1329 | return; |
1330 | } | |
7c9955d1 | 1331 | |
2193517f | 1332 | wxString *bitmappath; |
19d0f58d | 1333 | bitmappath=(wxString *)node->GetData(); |
92a19c2e | 1334 | |
2c99715a | 1335 | bitmapname=wxFileNameFromPath(*bitmappath); |
2193517f VS |
1336 | wxBitmap bitmap; |
1337 | if (!bitmap.LoadFile(*bitmappath,wxBITMAP_TYPE_BMP )) | |
19d0f58d | 1338 | wxLogError(_T("Unable to load bitmap:")+*bitmappath); |
2193517f VS |
1339 | |
1340 | //Make a bitmap file name | |
1341 | bitmapname=CleanName(bitmapname); | |
19d0f58d JS |
1342 | bitmapname+=_T(".bmp"); |
1343 | m_xmlfile.Write(_T("\t\t\t<bitmap>")+bitmapname+_T("</bitmap>\n")); | |
2c99715a | 1344 | bitmap.SaveFile(m_targetpath+bitmapname,wxBITMAP_TYPE_BMP); |
2193517f VS |
1345 | } |
1346 | ||
1347 | void rc2xml::WriteIcon(wxString iconname) | |
1348 | { | |
1349 | wxNode *node=m_iconlist->Find(iconname); | |
1350 | if (node==NULL) | |
1351 | { | |
19d0f58d JS |
1352 | m_xmlfile.Write(_T("\t\t\t<bitmap>missing_file</bitmap>\n")); |
1353 | wxLogError(_T("Unable to find icon:")+iconname); | |
2193517f VS |
1354 | } |
1355 | wxString *iconpath; | |
19d0f58d | 1356 | iconpath=(wxString *)node->GetData(); |
2193517f VS |
1357 | wxIcon icon; |
1358 | wxBitmap bitmap; | |
1359 | if (!icon.LoadFile(*iconpath,wxBITMAP_TYPE_ICO )) | |
19d0f58d | 1360 | wxLogError(_T("Unable to load icon:")+*iconpath); |
2193517f VS |
1361 | #ifdef __WXMSW__ |
1362 | bitmap.CopyFromIcon(icon); | |
1363 | #else | |
1364 | bitmap = icon; | |
1365 | #endif | |
2c99715a | 1366 | iconname=wxFileNameFromPath(*iconpath); |
2193517f VS |
1367 | //Make a bitmap file name |
1368 | iconname=CleanName(iconname); | |
19d0f58d JS |
1369 | iconname+=_T(".bmp"); |
1370 | m_xmlfile.Write(_T("\t\t\t<bitmap>")+iconname+_T("</bitmap>\n")); | |
2c99715a | 1371 | bitmap.SaveFile(m_targetpath+iconname,wxBITMAP_TYPE_BMP); |
2193517f | 1372 | |
7c9955d1 | 1373 | |
2193517f VS |
1374 | } |
1375 | /*Unfortunately sometimes the great MSVC Resource editor decides | |
1376 | to use numbers instead of the word id. I have no idea why they | |
1377 | do this, but that is the way it is. | |
1378 | */ | |
1379 | /* this is a quick and dirty way to parse the resource.h file | |
1380 | it will not recognize #ifdef so it can be easily fooled | |
1381 | */ | |
1382 | void rc2xml::ParseResourceHeader() | |
1383 | { | |
1384 | wxTextFile r; | |
1385 | //Attempt to load resource.h in current path | |
19d0f58d | 1386 | if (!r.Open(_T("resource.h"))) |
2193517f | 1387 | { |
19d0f58d | 1388 | wxLogError(_T("Warining Unable to load resource.h file")); |
2193517f VS |
1389 | return; |
1390 | } | |
7c9955d1 | 1391 | |
2193517f VS |
1392 | wxString str; |
1393 | wxString id,v; | |
1394 | wxStringTokenizer tok; | |
1395 | wxString *varname; | |
7c9955d1 JS |
1396 | |
1397 | ||
2193517f VS |
1398 | long n; |
1399 | ||
1400 | //Read through entire file | |
1401 | for ( str = r.GetFirstLine(); !r.Eof(); str = r.GetNextLine() ) | |
1402 | { | |
f80ea77b | 1403 | if (str.Find(_T("#define"))!=wxNOT_FOUND) |
2193517f VS |
1404 | { |
1405 | tok.SetString(str); | |
1406 | //Just ignore #define token | |
1407 | tok.GetNextToken(); | |
1408 | v=tok.GetNextToken(); | |
1409 | id=tok.GetNextToken(); | |
1410 | if (id.IsNumber()) | |
1411 | { | |
1412 | varname=new wxString; | |
1413 | id.ToLong(&n); | |
1414 | *varname=v; | |
1415 | m_resourcelist->Append(n,varname); | |
1416 | } | |
1417 | } | |
1418 | } | |
1419 | ||
7c9955d1 JS |
1420 | |
1421 | ||
2193517f VS |
1422 | } |
1423 | ||
1424 | ||
1425 | wxString rc2xml::LookUpId(wxString id) | |
1426 | { | |
1427 | wxString st; | |
1428 | ||
1429 | if (!id.IsNumber()) | |
1430 | return id; | |
1431 | long n; | |
1432 | id.ToLong(&n); | |
1433 | wxNode *node=m_resourcelist->Find(n); | |
1434 | wxString *s; | |
1435 | if (node==NULL) | |
1436 | return id; | |
1437 | ||
19d0f58d | 1438 | s=(wxString *)node->GetData(); |
2193517f VS |
1439 | st=*s; |
1440 | return st; | |
1441 | } |