]>
Commit | Line | Data |
---|---|---|
2193517f | 1 | // rc2wxr.cpp: implementation of the rc2wxr class. |
92a19c2e | 2 | |
88d42654 | 3 | // |
92a19c2e | 4 | |
88d42654 | 5 | ////////////////////////////////////////////////////////////////////// |
92a19c2e | 6 | |
2193517f | 7 | //Author: Brian Gavin 9/24/00 |
92a19c2e | 8 | |
2193517f | 9 | //License: wxWindows License |
92a19c2e | 10 | |
2193517f | 11 | /* |
92a19c2e | 12 | |
2193517f | 13 | WARNING- I know this code has some bugs to work out but |
92a19c2e | 14 | |
2193517f | 15 | I don't plan to fix them since I feel that wxr files will |
92a19c2e | 16 | |
2193517f | 17 | not be used much longer. |
92a19c2e | 18 | |
2193517f | 19 | This code was used as a starting point for my rc2xml converter |
92a19c2e | 20 | |
2193517f | 21 | */ |
92a19c2e | 22 | |
2193517f | 23 | #ifdef __GNUG__ |
92a19c2e | 24 | |
2193517f | 25 | #pragma implementation "rc2wxr.cpp" |
92a19c2e | 26 | |
2193517f | 27 | #pragma interface "rc2wxr.cpp" |
92a19c2e | 28 | |
2193517f VS |
29 | #endif |
30 | ||
92a19c2e GT |
31 | |
32 | ||
88d42654 | 33 | // For compilers that support precompilation, includes "wx/wx.h". |
92a19c2e GT |
34 | |
35 | #include "wx/wxprec.h" | |
36 | ||
37 | ||
2193517f VS |
38 | |
39 | #ifdef __BORLANDC__ | |
92a19c2e | 40 | |
2193517f | 41 | #pragma hdrstop |
92a19c2e | 42 | |
2193517f VS |
43 | #endif |
44 | ||
92a19c2e GT |
45 | |
46 | ||
2193517f | 47 | // for all others, include the necessary headers (this file is usually all you |
92a19c2e | 48 | |
be5a51fb | 49 | // need because it includes almost all "standard" wxWidgets headers |
92a19c2e | 50 | |
2193517f | 51 | #ifndef WX_PRECOMP |
92a19c2e | 52 | |
2193517f | 53 | #include <wx/wx.h> |
92a19c2e | 54 | |
2193517f VS |
55 | #endif |
56 | ||
88d42654 | 57 | |
92a19c2e GT |
58 | |
59 | ||
60 | ||
88d42654 | 61 | #include "rc2wxr.h" |
92a19c2e | 62 | |
88d42654 | 63 | #include "wx/image.h" |
92a19c2e | 64 | |
7c9955d1 JS |
65 | #include "wx/deprecated/setup.h" |
66 | #include "wx/deprecated/resource.h" | |
92a19c2e | 67 | |
88d42654 | 68 | ////////////////////////////////////////////////////////////////////// |
92a19c2e | 69 | |
88d42654 | 70 | // Construction/Destruction |
92a19c2e | 71 | |
88d42654 VS |
72 | ////////////////////////////////////////////////////////////////////// |
73 | ||
92a19c2e GT |
74 | |
75 | ||
2193517f | 76 | rc2wxr::rc2wxr() |
92a19c2e | 77 | |
88d42654 | 78 | { |
92a19c2e | 79 | |
f80ea77b | 80 | m_done=false; |
92a19c2e | 81 | |
88d42654 | 82 | m_controlid=6000; |
92a19c2e | 83 | |
88d42654 VS |
84 | } |
85 | ||
92a19c2e GT |
86 | |
87 | ||
2193517f | 88 | rc2wxr::~rc2wxr() |
92a19c2e | 89 | |
88d42654 VS |
90 | { |
91 | ||
92a19c2e GT |
92 | |
93 | ||
88d42654 VS |
94 | } |
95 | ||
92a19c2e GT |
96 | |
97 | ||
2193517f | 98 | void rc2wxr::Convert(wxString wxrfile, wxString rcfile) |
88d42654 | 99 | { |
4430ec36 WS |
100 | m_rc.Open(rcfile); |
101 | m_filesize=m_rc.Length(); | |
102 | if( (m_wxr = wxFopen( wxrfile.fn_str(), _T("wt") )) == NULL ) | |
103 | { | |
104 | return; | |
105 | } | |
92a19c2e | 106 | |
4430ec36 | 107 | wxString tok,prevtok; |
92a19c2e | 108 | |
4430ec36 WS |
109 | while (!m_done) |
110 | { | |
111 | tok=GetToken(); | |
92a19c2e | 112 | |
4430ec36 WS |
113 | if (tok==_T("DIALOG")) |
114 | { | |
115 | ParseDialog(prevtok); | |
116 | } | |
92a19c2e | 117 | |
4430ec36 WS |
118 | if (tok==_T("MENU")) |
119 | { | |
120 | ParseMenu(prevtok); | |
121 | } | |
88d42654 | 122 | |
4430ec36 WS |
123 | prevtok=tok; |
124 | } | |
92a19c2e | 125 | |
4430ec36 | 126 | fclose(m_wxr); |
92a19c2e | 127 | |
4430ec36 | 128 | m_rc.Close(); |
88d42654 VS |
129 | } |
130 | ||
131 | ||
92a19c2e GT |
132 | |
133 | ||
134 | ||
88d42654 | 135 | /* |
92a19c2e | 136 | |
7c9955d1 | 137 | Example .rc |
92a19c2e | 138 | |
88d42654 | 139 | Microsoft style as of v5.0 |
92a19c2e | 140 | |
88d42654 | 141 | IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55 |
92a19c2e | 142 | |
88d42654 | 143 | STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU |
92a19c2e | 144 | |
88d42654 | 145 | CAPTION "About Funimator" |
92a19c2e | 146 | |
88d42654 VS |
147 | FONT 8, "MS Sans Serif" |
148 | ||
92a19c2e GT |
149 | |
150 | ||
88d42654 | 151 | Borland 4.5 style rc |
92a19c2e | 152 | |
88d42654 | 153 | IDD_DIBATTR DIALOG 7, 16, 172, 119 |
92a19c2e | 154 | |
88d42654 | 155 | STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU |
92a19c2e | 156 | |
88d42654 | 157 | CAPTION "DIB Attributes" |
92a19c2e | 158 | |
88d42654 | 159 | FONT 8, "MS Sans Serif" |
92a19c2e | 160 | |
88d42654 | 161 | { |
92a19c2e | 162 | |
88d42654 | 163 | DEFPUSHBUTTON "Ok", IDOK, 114, 8, 50, 14 |
92a19c2e | 164 | |
88d42654 VS |
165 | PUSHBUTTON "Cancel", IDCANCEL, 114, 28, 50, 14 |
166 | ||
167 | ||
168 | ||
92a19c2e GT |
169 | |
170 | ||
171 | ||
172 | ||
88d42654 | 173 | */ |
92a19c2e | 174 | |
2193517f | 175 | void rc2wxr::ParseDialog(wxString dlgname) |
92a19c2e | 176 | |
2193517f | 177 | { |
92a19c2e | 178 | |
2193517f | 179 | wxString tok; |
92a19c2e | 180 | |
2193517f | 181 | static int dlgid=999; |
92a19c2e | 182 | |
2193517f | 183 | dlgid++; |
92a19c2e | 184 | |
7c9955d1 | 185 | /* Make sure that this really is a dialog |
92a19c2e | 186 | |
2193517f | 187 | microsoft reuses the keyword DIALOG for other things |
92a19c2e | 188 | |
2193517f | 189 | */ |
92a19c2e | 190 | |
2193517f | 191 | tok=PeekToken(); |
92a19c2e | 192 | |
2193517f | 193 | //Microsoft notation? |
92a19c2e | 194 | |
19d0f58d | 195 | if (tok==_T("DISCARDABLE")) |
92a19c2e | 196 | |
2193517f | 197 | { |
92a19c2e | 198 | |
2193517f | 199 | tok=GetToken(); |
92a19c2e | 200 | |
2193517f | 201 | tok=PeekToken(); |
92a19c2e | 202 | |
2193517f | 203 | } |
92a19c2e | 204 | |
2193517f | 205 | //This isn't a Dialog resource eject eject |
92a19c2e | 206 | |
2193517f | 207 | if (!tok.IsNumber()) |
92a19c2e | 208 | |
2193517f | 209 | return; |
92a19c2e | 210 | |
88d42654 | 211 | //Generate Dialog text |
92a19c2e | 212 | |
19d0f58d | 213 | wxFprintf(m_wxr,_T("static char *dialog%i = \"dialog(name = '%s',\\\n"),dlgid,dlgname.c_str()); |
92a19c2e | 214 | |
88d42654 | 215 | //be lazy about style for now. add it later |
92a19c2e | 216 | |
19d0f58d | 217 | wxFprintf(m_wxr,_T("style = 'wxRAISED_BORDER | wxCAPTION | wxTHICK_FRAME | wxSYSTEM_MENU',\\\n")); |
88d42654 | 218 | |
92a19c2e GT |
219 | |
220 | ||
19d0f58d | 221 | wxFprintf(m_wxr,_T("id = %i,\\\n"),dlgid); |
88d42654 | 222 | |
92a19c2e GT |
223 | |
224 | ||
88d42654 | 225 | //Record x,y,width,height |
92a19c2e | 226 | |
88d42654 | 227 | int x,y,width,height; |
92a19c2e | 228 | |
88d42654 | 229 | ReadRect(x,y,width,height); |
92a19c2e | 230 | |
19d0f58d | 231 | wxFprintf(m_wxr,_T("x = %i, y = %i, width = %i, height = %i,\\\n"),x,y,width,height); |
88d42654 VS |
232 | |
233 | ||
92a19c2e GT |
234 | |
235 | ||
236 | ||
88d42654 | 237 | //CAPTION "About Funimator" |
92a19c2e | 238 | |
88d42654 | 239 | //Get Title |
92a19c2e | 240 | |
88d42654 | 241 | tok=GetToken(); |
92a19c2e | 242 | |
88d42654 VS |
243 | wxString title; |
244 | ||
92a19c2e GT |
245 | |
246 | ||
19d0f58d | 247 | while ((tok!=_T("BEGIN"))&(tok!=_T("{"))) |
92a19c2e | 248 | |
88d42654 | 249 | { |
92a19c2e | 250 | |
19d0f58d | 251 | if (tok==_T("CAPTION")) |
92a19c2e | 252 | |
2193517f | 253 | { |
92a19c2e | 254 | |
2193517f | 255 | title=GetQuoteField(); |
92a19c2e | 256 | |
19d0f58d | 257 | wxFprintf(m_wxr,_T("title = '%s',\\\n"),title.c_str()); |
92a19c2e | 258 | |
2193517f | 259 | } |
92a19c2e | 260 | |
88d42654 | 261 | tok=GetToken(); |
92a19c2e | 262 | |
88d42654 | 263 | } |
92a19c2e | 264 | |
19d0f58d | 265 | wxFprintf(m_wxr,_T("use_dialog_units = 1,\\\n")); |
92a19c2e | 266 | |
19d0f58d | 267 | wxFprintf(m_wxr,_T("use_system_defaults = 0,\\\n")); |
88d42654 | 268 | |
92a19c2e GT |
269 | |
270 | ||
19d0f58d | 271 | wxFprintf(m_wxr,_T("font = [8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif'],\\\n")); |
92a19c2e | 272 | |
88d42654 | 273 | ParseControls(); |
92a19c2e | 274 | |
19d0f58d | 275 | wxFprintf(m_wxr,_T(").\";\n\n")); |
92a19c2e | 276 | |
88d42654 VS |
277 | } |
278 | ||
92a19c2e GT |
279 | |
280 | ||
88d42654 | 281 | /* |
92a19c2e | 282 | |
88d42654 VS |
283 | BEGIN |
284 | ||
285 | ||
286 | ||
92a19c2e GT |
287 | |
288 | ||
289 | ||
290 | ||
7c9955d1 | 291 | EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT |
92a19c2e | 292 | |
88d42654 | 293 | WS_TABSTOP |
92a19c2e | 294 | |
88d42654 | 295 | LTEXT "Bands",IDC_STATIC,11,86,21,8 |
92a19c2e | 296 | |
88d42654 | 297 | EDITTEXT IDC_NAME,10,3,75,14,ES_AUTOHSCROLL |
92a19c2e | 298 | |
88d42654 | 299 | END |
92a19c2e | 300 | |
88d42654 | 301 | */ |
92a19c2e | 302 | |
2193517f | 303 | void rc2wxr::ParseControls() |
92a19c2e | 304 | |
88d42654 | 305 | { |
92a19c2e | 306 | |
88d42654 VS |
307 | wxString tok; |
308 | ||
92a19c2e GT |
309 | |
310 | ||
88d42654 | 311 | tok=GetToken(); |
92a19c2e | 312 | |
19d0f58d | 313 | while ((tok!=_T("END"))&(tok!=_T("}"))) |
92a19c2e | 314 | |
88d42654 | 315 | { |
92a19c2e | 316 | |
19d0f58d | 317 | if (tok==_T("LTEXT")) |
92a19c2e | 318 | |
88d42654 | 319 | ParseStaticText(); |
92a19c2e | 320 | |
19d0f58d | 321 | if (tok==_T("EDITTEXT")) |
92a19c2e | 322 | |
88d42654 | 323 | ParseTextCtrl(); |
92a19c2e | 324 | |
19d0f58d | 325 | if (tok==_T("PUSHBUTTON")) |
92a19c2e | 326 | |
88d42654 | 327 | ParsePushButton(); |
92a19c2e | 328 | |
19d0f58d | 329 | if (tok==_T("DEFPUSHBUTTON")) |
92a19c2e | 330 | |
88d42654 | 331 | ParsePushButton(); |
92a19c2e | 332 | |
19d0f58d | 333 | if (tok==_T("GROUPBOX")) |
92a19c2e | 334 | |
88d42654 | 335 | ParseGroupBox(); |
92a19c2e | 336 | |
19d0f58d | 337 | if (tok==_T("COMBOBOX")) |
92a19c2e | 338 | |
88d42654 | 339 | ParseComboBox(); |
92a19c2e | 340 | |
19d0f58d | 341 | if (tok==_T("CONTROL")) |
92a19c2e | 342 | |
88d42654 VS |
343 | ParseControlMS(); |
344 | ||
92a19c2e GT |
345 | |
346 | ||
88d42654 | 347 | tok=GetToken(); |
92a19c2e | 348 | |
88d42654 VS |
349 | } |
350 | ||
92a19c2e GT |
351 | |
352 | ||
88d42654 | 353 | } |
92a19c2e | 354 | |
88d42654 | 355 | //LTEXT "Radius",IDC_STATIC,9,67,23,8 |
92a19c2e | 356 | |
2193517f | 357 | void rc2wxr::ParseStaticText() |
92a19c2e | 358 | |
88d42654 | 359 | { |
92a19c2e | 360 | |
88d42654 | 361 | wxString tok; |
92a19c2e | 362 | |
88d42654 | 363 | wxString phrase,varname; |
92a19c2e | 364 | |
88d42654 | 365 | phrase=GetQuoteField(); |
92a19c2e | 366 | |
88d42654 | 367 | varname=GetToken(); |
92a19c2e | 368 | |
88d42654 | 369 | m_controlid++; |
92a19c2e | 370 | |
88d42654 | 371 | int x,y,width,height; |
92a19c2e | 372 | |
88d42654 | 373 | ReadRect(x,y,width,height); |
92a19c2e | 374 | |
19d0f58d | 375 | wxFprintf(m_wxr,_T(" control = [%i,wxStaticText,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str()); |
92a19c2e | 376 | |
19d0f58d | 377 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); |
92a19c2e | 378 | |
19d0f58d | 379 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
92a19c2e | 380 | |
88d42654 | 381 | } |
92a19c2e | 382 | |
88d42654 | 383 | //EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL |
92a19c2e | 384 | |
2193517f | 385 | void rc2wxr::ParseTextCtrl() |
92a19c2e | 386 | |
88d42654 | 387 | { |
92a19c2e | 388 | |
88d42654 | 389 | wxString tok; |
92a19c2e | 390 | |
88d42654 | 391 | wxString varname; |
92a19c2e | 392 | |
88d42654 | 393 | varname=GetToken(); |
92a19c2e | 394 | |
88d42654 | 395 | m_controlid++; |
92a19c2e | 396 | |
88d42654 | 397 | int x,y,width,height; |
92a19c2e | 398 | |
88d42654 | 399 | ReadRect(x,y,width,height); |
92a19c2e | 400 | |
19d0f58d | 401 | wxFprintf(m_wxr,_T(" control = [%i,wxTextCtrl,'','0','%s',"),m_controlid,varname.c_str()); |
92a19c2e | 402 | |
19d0f58d | 403 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); |
92a19c2e | 404 | |
19d0f58d | 405 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
88d42654 | 406 | |
92a19c2e GT |
407 | |
408 | ||
88d42654 | 409 | } |
92a19c2e | 410 | |
88d42654 | 411 | //PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP |
92a19c2e | 412 | |
2193517f | 413 | void rc2wxr::ParsePushButton() |
92a19c2e | 414 | |
88d42654 | 415 | { |
92a19c2e | 416 | |
88d42654 | 417 | wxString tok; |
92a19c2e | 418 | |
88d42654 | 419 | wxString phrase,varname; |
92a19c2e | 420 | |
88d42654 | 421 | phrase=GetQuoteField(); |
92a19c2e | 422 | |
88d42654 | 423 | varname=GetToken(); |
92a19c2e | 424 | |
88d42654 | 425 | int c; |
92a19c2e | 426 | |
88d42654 | 427 | m_controlid++; |
92a19c2e | 428 | |
88d42654 | 429 | c=m_controlid; |
92a19c2e | 430 | |
19d0f58d | 431 | if (varname==_T("IDOK")) |
92a19c2e | 432 | |
88d42654 VS |
433 | c=wxID_OK; |
434 | ||
92a19c2e GT |
435 | |
436 | ||
19d0f58d | 437 | if (varname==_T("IDCANCEL")) |
92a19c2e | 438 | |
88d42654 VS |
439 | c=wxID_CANCEL; |
440 | ||
92a19c2e GT |
441 | |
442 | ||
19d0f58d | 443 | if (varname==_T("IDAPPLY")) |
92a19c2e | 444 | |
88d42654 VS |
445 | c=wxID_APPLY; |
446 | ||
92a19c2e GT |
447 | |
448 | ||
88d42654 | 449 | int x,y,width,height; |
92a19c2e | 450 | |
88d42654 | 451 | ReadRect(x,y,width,height); |
92a19c2e | 452 | |
19d0f58d | 453 | wxFprintf(m_wxr,_T(" control = [%i,wxButton,'%s','0','%s',"),c,phrase.c_str(),varname.c_str()); |
92a19c2e | 454 | |
19d0f58d | 455 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); |
92a19c2e | 456 | |
19d0f58d | 457 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
88d42654 | 458 | |
92a19c2e GT |
459 | |
460 | ||
88d42654 VS |
461 | } |
462 | ||
463 | ||
92a19c2e GT |
464 | |
465 | ||
466 | ||
2193517f | 467 | bool rc2wxr::Seperator(int ch) |
92a19c2e | 468 | |
88d42654 | 469 | { |
92a19c2e | 470 | |
88d42654 | 471 | if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|')) |
92a19c2e | 472 | |
f80ea77b | 473 | return true; |
88d42654 | 474 | |
92a19c2e GT |
475 | |
476 | ||
88d42654 | 477 | if (ch==EOF) |
92a19c2e | 478 | |
88d42654 | 479 | { |
92a19c2e | 480 | |
f80ea77b | 481 | m_done=true; |
92a19c2e | 482 | |
f80ea77b | 483 | return true; |
92a19c2e | 484 | |
88d42654 | 485 | } |
92a19c2e | 486 | |
f80ea77b | 487 | return false; |
92a19c2e | 488 | |
88d42654 VS |
489 | } |
490 | ||
92a19c2e GT |
491 | |
492 | ||
2193517f | 493 | void rc2wxr::ParseGroupBox() |
92a19c2e | 494 | |
88d42654 | 495 | { |
92a19c2e | 496 | |
88d42654 | 497 | // GROUPBOX "Rotate",IDC_STATIC,1,1,71,79 |
92a19c2e | 498 | |
88d42654 | 499 | wxString tok; |
92a19c2e | 500 | |
88d42654 | 501 | wxString phrase,varname; |
92a19c2e | 502 | |
88d42654 | 503 | phrase=GetQuoteField(); |
92a19c2e | 504 | |
88d42654 | 505 | varname=GetToken(); |
92a19c2e | 506 | |
88d42654 | 507 | m_controlid++; |
92a19c2e | 508 | |
88d42654 | 509 | int x,y,width,height; |
92a19c2e | 510 | |
88d42654 | 511 | ReadRect(x,y,width,height); |
92a19c2e | 512 | |
19d0f58d | 513 | wxFprintf(m_wxr,_T(" control = [%i,wxStaticBox,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str()); |
92a19c2e | 514 | |
19d0f58d | 515 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height); |
92a19c2e | 516 | |
19d0f58d | 517 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
88d42654 VS |
518 | |
519 | ||
92a19c2e GT |
520 | |
521 | ||
522 | ||
88d42654 VS |
523 | } |
524 | ||
92a19c2e GT |
525 | |
526 | ||
2193517f | 527 | void rc2wxr::ReadRect(int & x, int & y, int & width, int & height) |
92a19c2e | 528 | |
88d42654 | 529 | { |
92a19c2e | 530 | |
19d0f58d | 531 | x=wxAtoi(GetToken()); |
92a19c2e | 532 | |
19d0f58d | 533 | y=wxAtoi(GetToken()); |
92a19c2e | 534 | |
19d0f58d | 535 | width=wxAtoi(GetToken()); |
92a19c2e | 536 | |
19d0f58d | 537 | height=wxAtoi(GetToken()); |
88d42654 | 538 | |
92a19c2e GT |
539 | |
540 | ||
88d42654 VS |
541 | } |
542 | ||
92a19c2e GT |
543 | |
544 | ||
2193517f | 545 | wxString rc2wxr::GetToken() |
92a19c2e | 546 | |
88d42654 | 547 | { |
92a19c2e | 548 | |
19d0f58d | 549 | wxString tok=wxEmptyString; |
88d42654 | 550 | |
92a19c2e GT |
551 | |
552 | ||
88d42654 | 553 | if (m_rc.Eof()) |
92a19c2e | 554 | |
88d42654 | 555 | { |
92a19c2e | 556 | |
f80ea77b | 557 | m_done=true; |
92a19c2e | 558 | |
88d42654 | 559 | return tok; |
92a19c2e | 560 | |
88d42654 VS |
561 | } |
562 | ||
92a19c2e GT |
563 | |
564 | ||
88d42654 | 565 | int ch=0; |
92a19c2e | 566 | |
88d42654 | 567 | ReadChar(ch); |
92a19c2e | 568 | |
88d42654 | 569 | if (ch==EOF) |
92a19c2e | 570 | |
88d42654 | 571 | { |
92a19c2e | 572 | |
f80ea77b | 573 | m_done=true; |
92a19c2e | 574 | |
88d42654 | 575 | return tok; |
92a19c2e | 576 | |
88d42654 VS |
577 | } |
578 | ||
92a19c2e GT |
579 | |
580 | ||
88d42654 | 581 | while (Seperator(ch)) |
92a19c2e | 582 | |
88d42654 | 583 | { |
92a19c2e | 584 | |
88d42654 | 585 | ReadChar(ch); |
92a19c2e | 586 | |
88d42654 | 587 | if (m_done) |
92a19c2e | 588 | |
2193517f | 589 | return tok; |
92a19c2e | 590 | |
88d42654 VS |
591 | } |
592 | ||
92a19c2e GT |
593 | |
594 | ||
88d42654 | 595 | if (ch==EOF) |
92a19c2e | 596 | |
88d42654 | 597 | { |
92a19c2e | 598 | |
f80ea77b | 599 | m_done=true; |
88d42654 | 600 | |
92a19c2e GT |
601 | |
602 | ||
88d42654 | 603 | } |
92a19c2e | 604 | |
7c9955d1 | 605 | |
88d42654 | 606 | |
92a19c2e GT |
607 | |
608 | ||
88d42654 | 609 | while (!Seperator(ch)) |
92a19c2e | 610 | |
88d42654 | 611 | { |
92a19c2e | 612 | |
2193517f | 613 | tok+=(char)ch; |
92a19c2e | 614 | |
2193517f | 615 | ReadChar(ch); |
88d42654 | 616 | |
92a19c2e GT |
617 | |
618 | ||
88d42654 VS |
619 | } |
620 | ||
92a19c2e GT |
621 | |
622 | ||
88d42654 | 623 | if (ch==EOF) |
92a19c2e | 624 | |
f80ea77b | 625 | m_done=true; |
88d42654 VS |
626 | |
627 | ||
92a19c2e GT |
628 | |
629 | ||
630 | ||
88d42654 | 631 | return tok; |
92a19c2e | 632 | |
88d42654 VS |
633 | } |
634 | ||
92a19c2e GT |
635 | |
636 | ||
2193517f | 637 | wxString rc2wxr::GetQuoteField() |
92a19c2e | 638 | |
88d42654 | 639 | { |
92a19c2e | 640 | |
88d42654 | 641 | wxString phrase; |
92a19c2e | 642 | |
88d42654 | 643 | //ASCII code 34 " |
92a19c2e | 644 | |
88d42654 | 645 | int ch=0; |
92a19c2e | 646 | |
88d42654 VS |
647 | ReadChar(ch); |
648 | ||
92a19c2e GT |
649 | |
650 | ||
88d42654 | 651 | while (ch!=34) |
92a19c2e | 652 | |
88d42654 | 653 | ReadChar(ch); |
92a19c2e | 654 | |
7c9955d1 | 655 | |
92a19c2e | 656 | |
88d42654 VS |
657 | ReadChar(ch); |
658 | ||
92a19c2e GT |
659 | |
660 | ||
88d42654 | 661 | while (ch!=34) |
92a19c2e | 662 | |
88d42654 | 663 | { |
92a19c2e | 664 | |
88d42654 | 665 | phrase+=(char)ch; |
92a19c2e | 666 | |
88d42654 | 667 | ReadChar(ch); |
92a19c2e | 668 | |
88d42654 | 669 | } |
92a19c2e | 670 | |
88d42654 | 671 | return phrase; |
92a19c2e | 672 | |
88d42654 VS |
673 | } |
674 | ||
92a19c2e GT |
675 | |
676 | ||
2193517f | 677 | void rc2wxr::ReadChar(int &ch) |
92a19c2e | 678 | |
88d42654 | 679 | { |
92a19c2e | 680 | |
f80ea77b | 681 | int result; |
92a19c2e | 682 | |
88d42654 VS |
683 | result=m_rc.Tell(); |
684 | ||
92a19c2e GT |
685 | |
686 | ||
88d42654 | 687 | if((result>=m_filesize)) |
92a19c2e | 688 | |
f80ea77b | 689 | m_done=true; |
88d42654 | 690 | |
92a19c2e GT |
691 | |
692 | ||
88d42654 VS |
693 | result=m_rc.Read(&ch,1); |
694 | ||
92a19c2e GT |
695 | |
696 | ||
88d42654 | 697 | if((result==-1)) |
92a19c2e | 698 | |
f80ea77b | 699 | m_done=true; |
88d42654 | 700 | |
92a19c2e GT |
701 | |
702 | ||
88d42654 | 703 | if(ch==EOF) |
92a19c2e | 704 | |
f80ea77b | 705 | m_done=true; |
92a19c2e | 706 | |
88d42654 VS |
707 | } |
708 | ||
92a19c2e GT |
709 | |
710 | ||
2193517f | 711 | void rc2wxr::ParseComboBox() |
92a19c2e | 712 | |
88d42654 | 713 | { |
92a19c2e | 714 | |
7c9955d1 | 715 | /* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT | |
92a19c2e | 716 | |
88d42654 | 717 | WS_VSCROLL | WS_TABSTOP */ |
92a19c2e | 718 | |
88d42654 | 719 | wxString tok; |
92a19c2e | 720 | |
88d42654 | 721 | wxString varname; |
92a19c2e | 722 | |
88d42654 | 723 | varname=GetToken(); |
92a19c2e | 724 | |
88d42654 | 725 | m_controlid++; |
92a19c2e | 726 | |
88d42654 | 727 | int x,y,width,height; |
92a19c2e | 728 | |
88d42654 VS |
729 | ReadRect(x,y,width,height); |
730 | ||
92a19c2e GT |
731 | |
732 | ||
19d0f58d | 733 | wxFprintf(m_wxr,_T(" control = [%i,wxChoice,'','0','%s',"),m_controlid,varname.c_str()); |
92a19c2e | 734 | |
19d0f58d | 735 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,[],\\\n"),x,y,width,height); |
92a19c2e | 736 | |
19d0f58d | 737 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
88d42654 VS |
738 | |
739 | ||
92a19c2e GT |
740 | |
741 | ||
742 | ||
88d42654 VS |
743 | } |
744 | ||
92a19c2e GT |
745 | |
746 | ||
2193517f | 747 | void rc2wxr::ParseMenu(wxString name) |
92a19c2e | 748 | |
88d42654 | 749 | { |
92a19c2e | 750 | |
19d0f58d | 751 | wxString tok=wxEmptyString; |
92a19c2e | 752 | |
88d42654 | 753 | static int menuid=0; |
92a19c2e | 754 | |
88d42654 | 755 | menuid++; |
92a19c2e | 756 | |
19d0f58d | 757 | wxFprintf(m_wxr,_T("static char *MenuBar%i = \"menu(name = '%s',\\\n"),menuid,name.c_str()); |
92a19c2e | 758 | |
19d0f58d | 759 | wxFprintf(m_wxr,_T("menu = \\\n")); |
92a19c2e | 760 | |
19d0f58d | 761 | wxFprintf(m_wxr,_T("[\\\n")); |
88d42654 | 762 | |
92a19c2e GT |
763 | |
764 | ||
19d0f58d | 765 | while ((tok!=_T("BEGIN"))&(tok!=_T("{"))) |
92a19c2e | 766 | |
88d42654 VS |
767 | tok=GetToken(); |
768 | ||
92a19c2e GT |
769 | |
770 | ||
19d0f58d | 771 | while ((tok!=_T("END"))&(tok!=_T("}"))) |
92a19c2e | 772 | |
88d42654 | 773 | { |
92a19c2e | 774 | |
88d42654 | 775 | tok=GetToken(); |
92a19c2e | 776 | |
19d0f58d | 777 | if (tok==_T("POPUP")) |
92a19c2e | 778 | |
f80ea77b | 779 | { |
92a19c2e | 780 | |
88d42654 | 781 | ParsePopupMenu(); |
92a19c2e | 782 | |
f80ea77b | 783 | wxFprintf(m_wxr,_T(" ],\\\n")); |
92a19c2e | 784 | |
f80ea77b | 785 | } |
92a19c2e | 786 | |
88d42654 VS |
787 | } |
788 | ||
92a19c2e GT |
789 | |
790 | ||
19d0f58d | 791 | wxFprintf(m_wxr,_T("]).\";\n\n")); |
92a19c2e | 792 | |
88d42654 VS |
793 | } |
794 | ||
92a19c2e GT |
795 | |
796 | ||
2193517f | 797 | void rc2wxr::ParsePopupMenu() |
92a19c2e | 798 | |
88d42654 | 799 | { |
92a19c2e | 800 | |
88d42654 | 801 | static int menuitem=99; |
92a19c2e | 802 | |
88d42654 VS |
803 | menuitem++; |
804 | ||
92a19c2e GT |
805 | |
806 | ||
88d42654 | 807 | wxString tok; |
92a19c2e | 808 | |
88d42654 | 809 | tok=GetQuoteField(); |
92a19c2e | 810 | |
88d42654 | 811 | int spot; |
92a19c2e | 812 | |
88d42654 | 813 | //Remove /t because it causes problems |
92a19c2e | 814 | |
19d0f58d | 815 | spot=tok.First(_T("\\t")); |
92a19c2e | 816 | |
88d42654 | 817 | tok=tok.Left(spot); |
92a19c2e | 818 | |
19d0f58d | 819 | wxFprintf(m_wxr,_T(" ['%s',%i,'',\\\n"),tok.c_str(),menuitem); |
92a19c2e | 820 | |
19d0f58d | 821 | while ((tok!=_T("BEGIN"))&(tok!=_T("{"))) |
92a19c2e | 822 | |
88d42654 VS |
823 | tok=GetToken(); |
824 | ||
92a19c2e GT |
825 | |
826 | ||
19d0f58d | 827 | while ((tok!=_T("END"))&(tok!=_T("}"))) |
92a19c2e | 828 | |
88d42654 | 829 | { |
92a19c2e | 830 | |
88d42654 | 831 | tok=GetToken(); |
92a19c2e | 832 | |
19d0f58d | 833 | if (tok==_T("MENUITEM")) |
92a19c2e | 834 | |
2193517f | 835 | { |
92a19c2e | 836 | |
19d0f58d | 837 | if (PeekToken()==_T("SEPARATOR")) |
92a19c2e | 838 | |
19d0f58d | 839 | wxFprintf(m_wxr,_T(" [],\\\n")); |
92a19c2e | 840 | |
2193517f | 841 | else |
92a19c2e | 842 | |
2193517f | 843 | { |
92a19c2e | 844 | |
2193517f | 845 | tok=GetQuoteField(); |
92a19c2e | 846 | |
2193517f | 847 | //Remove /t because it causes problems |
92a19c2e | 848 | |
19d0f58d | 849 | spot=tok.First(_T("\\t")); |
92a19c2e | 850 | |
2193517f | 851 | tok=tok.Left(spot); |
92a19c2e | 852 | |
2193517f | 853 | menuitem++; |
92a19c2e | 854 | |
19d0f58d | 855 | wxFprintf(m_wxr,_T(" ['%s',%i,''],\\\n"),tok.c_str(),menuitem); |
92a19c2e | 856 | |
2193517f | 857 | } |
92a19c2e | 858 | |
2193517f | 859 | } |
88d42654 | 860 | |
92a19c2e GT |
861 | |
862 | ||
88d42654 VS |
863 | } |
864 | ||
92a19c2e GT |
865 | |
866 | ||
7c9955d1 | 867 | |
92a19c2e | 868 | |
88d42654 VS |
869 | } |
870 | ||
92a19c2e GT |
871 | |
872 | ||
2193517f | 873 | wxString rc2wxr::PeekToken() |
92a19c2e | 874 | |
88d42654 | 875 | { |
92a19c2e | 876 | |
88d42654 | 877 | wxString tok; |
92a19c2e | 878 | |
88d42654 | 879 | int p; |
92a19c2e | 880 | |
88d42654 | 881 | p=m_rc.Tell(); |
92a19c2e | 882 | |
88d42654 VS |
883 | tok=GetToken(); |
884 | ||
92a19c2e GT |
885 | |
886 | ||
88d42654 | 887 | m_rc.Seek(p); |
92a19c2e | 888 | |
88d42654 | 889 | return tok; |
92a19c2e | 890 | |
88d42654 | 891 | } |
92a19c2e | 892 | |
88d42654 | 893 | //Windows pain in the butt CONTROL |
92a19c2e | 894 | |
2193517f | 895 | void rc2wxr::ParseControlMS() |
92a19c2e | 896 | |
88d42654 | 897 | { |
92a19c2e | 898 | |
88d42654 | 899 | wxString label,varname,kindctrl,tok; |
92a19c2e | 900 | |
88d42654 | 901 | label=GetQuoteField(); |
92a19c2e | 902 | |
88d42654 | 903 | varname=GetToken(); |
92a19c2e | 904 | |
88d42654 | 905 | kindctrl=GetQuoteField(); |
92a19c2e | 906 | |
88d42654 VS |
907 | kindctrl.MakeUpper(); |
908 | ||
909 | ||
92a19c2e GT |
910 | |
911 | ||
912 | ||
19d0f58d | 913 | if (kindctrl==_T("MSCTLS_TRACKBAR32")) |
92a19c2e | 914 | |
88d42654 | 915 | ParseSlider(label,varname); |
92a19c2e | 916 | |
19d0f58d | 917 | if (kindctrl==_T("MSCTLS_PROGRESS32")) |
92a19c2e | 918 | |
88d42654 | 919 | ParseProgressBar(label,varname); |
92a19c2e | 920 | |
19d0f58d | 921 | if (kindctrl==_T("BUTTON")) |
92a19c2e | 922 | |
88d42654 | 923 | ParseCtrlButton(label,varname); |
92a19c2e | 924 | |
88d42654 | 925 | } |
92a19c2e | 926 | |
7c9955d1 | 927 | /* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | |
92a19c2e | 928 | |
88d42654 | 929 | TBS_NOTICKS | WS_TABSTOP,52,73,100,15 |
92a19c2e | 930 | |
88d42654 VS |
931 | */ |
932 | ||
92a19c2e GT |
933 | |
934 | ||
19d0f58d | 935 | void rc2wxr::ParseSlider(wxString WXUNUSED(label), wxString varname) |
92a19c2e | 936 | |
88d42654 | 937 | { |
92a19c2e | 938 | |
2193517f | 939 | wxString tok; |
92a19c2e | 940 | |
b2247ee9 CE |
941 | while (ReadOrs(tok)) |
942 | ; | |
92a19c2e | 943 | |
19d0f58d | 944 | wxFprintf(m_wxr,_T(" control = [%i,wxSlider,'','wxSL_HORIZONTAL','%s',"),m_controlid,varname.c_str()); |
92a19c2e | 945 | |
88d42654 | 946 | int x,y,width,height; |
92a19c2e | 947 | |
88d42654 | 948 | ReadRect(x,y,width,height); |
92a19c2e | 949 | |
19d0f58d | 950 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height); |
92a19c2e | 951 | |
19d0f58d | 952 | wxFprintf(m_wxr,_T(" 1, 1, 10,\\\n")); |
92a19c2e | 953 | |
19d0f58d | 954 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
92a19c2e | 955 | |
88d42654 | 956 | } |
92a19c2e | 957 | |
7c9955d1 | 958 | /* |
92a19c2e | 959 | |
88d42654 | 960 | CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32", |
92a19c2e | 961 | |
88d42654 | 962 | WS_BORDER,15,52,154,13 |
92a19c2e | 963 | |
88d42654 | 964 | */ |
92a19c2e | 965 | |
19d0f58d | 966 | void rc2wxr::ParseProgressBar(wxString WXUNUSED(label), wxString varname) |
92a19c2e | 967 | |
88d42654 | 968 | { |
92a19c2e | 969 | |
88d42654 | 970 | wxString tok; |
92a19c2e | 971 | |
b2247ee9 CE |
972 | while (ReadOrs(tok)) |
973 | ; | |
92a19c2e | 974 | |
19d0f58d | 975 | wxFprintf(m_wxr,_T(" control = [%i,wxGauge,'','wxGA_HORIZONTAL','%s',"),m_controlid,varname.c_str()); |
92a19c2e | 976 | |
88d42654 | 977 | int x,y,width,height; |
92a19c2e | 978 | |
88d42654 | 979 | ReadRect(x,y,width,height); |
92a19c2e | 980 | |
19d0f58d | 981 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height); |
92a19c2e | 982 | |
19d0f58d | 983 | wxFprintf(m_wxr,_T(" 0, 10,\\\n")); |
92a19c2e | 984 | |
19d0f58d | 985 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
92a19c2e | 986 | |
88d42654 VS |
987 | } |
988 | ||
92a19c2e GT |
989 | |
990 | ||
2193517f | 991 | bool rc2wxr::ReadOrs(wxString & w) |
92a19c2e | 992 | |
88d42654 | 993 | { |
92a19c2e | 994 | |
88d42654 | 995 | wxString tok; |
92a19c2e | 996 | |
88d42654 | 997 | tok=PeekToken(); |
92a19c2e | 998 | |
88d42654 | 999 | if (tok.IsNumber()) |
92a19c2e | 1000 | |
88d42654 | 1001 | return false; |
92a19c2e | 1002 | |
88d42654 | 1003 | w=GetToken(); |
92a19c2e | 1004 | |
f80ea77b | 1005 | return true; |
92a19c2e | 1006 | |
88d42654 VS |
1007 | } |
1008 | ||
92a19c2e GT |
1009 | |
1010 | ||
88d42654 | 1011 | //Is it a check button or a radio button |
92a19c2e | 1012 | |
2193517f | 1013 | void rc2wxr::ParseCtrlButton(wxString label, wxString varname) |
92a19c2e | 1014 | |
88d42654 | 1015 | { |
92a19c2e | 1016 | |
88d42654 | 1017 | wxString tok; |
92a19c2e | 1018 | |
2193517f | 1019 | tok=GetToken(); |
88d42654 | 1020 | |
92a19c2e GT |
1021 | |
1022 | ||
88d42654 | 1023 | m_controlid++; |
92a19c2e | 1024 | |
2193517f | 1025 | int x,y,width,height; |
88d42654 | 1026 | |
92a19c2e GT |
1027 | |
1028 | ||
19d0f58d | 1029 | if (tok==_T("BS_AUTOCHECKBOX")) |
92a19c2e | 1030 | |
88d42654 | 1031 | { |
92a19c2e | 1032 | |
19d0f58d | 1033 | wxFprintf(m_wxr,_T(" control = [%i,wxCheckBox,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str()); |
92a19c2e | 1034 | |
b2247ee9 CE |
1035 | while (ReadOrs(tok)) |
1036 | ; | |
92a19c2e | 1037 | |
2193517f | 1038 | ReadRect(x,y,width,height); |
92a19c2e | 1039 | |
19d0f58d | 1040 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height); |
92a19c2e | 1041 | |
19d0f58d | 1042 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
92a19c2e | 1043 | |
88d42654 VS |
1044 | } |
1045 | ||
92a19c2e GT |
1046 | |
1047 | ||
19d0f58d | 1048 | if (tok==_T("BS_AUTORADIOBUTTON")) |
92a19c2e | 1049 | |
88d42654 | 1050 | { |
92a19c2e | 1051 | |
19d0f58d | 1052 | wxFprintf(m_wxr,_T(" control = [%i,wxRadioButton,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str()); |
92a19c2e | 1053 | |
b2247ee9 CE |
1054 | while(ReadOrs(tok)) |
1055 | ; | |
92a19c2e | 1056 | |
2193517f | 1057 | ReadRect(x,y,width,height); |
92a19c2e | 1058 | |
19d0f58d | 1059 | wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height); |
92a19c2e | 1060 | |
19d0f58d | 1061 | wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n")); |
92a19c2e | 1062 | |
88d42654 VS |
1063 | } |
1064 | ||
1065 | ||
1066 | ||
92a19c2e GT |
1067 | |
1068 | ||
1069 | ||
1070 | ||
88d42654 VS |
1071 | } |
1072 | ||
92a19c2e GT |
1073 | |
1074 |