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