]> git.saurik.com Git - wxWidgets.git/blame - contrib/utils/convertrc/rc2wxr.cpp
fix evaluation order bug (patch 1158099)
[wxWidgets.git] / contrib / utils / convertrc / rc2wxr.cpp
CommitLineData
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 13WARNING- I know this code has some bugs to work out but
92a19c2e 14
2193517f 15I don't plan to fix them since I feel that wxr files will
92a19c2e 16
2193517f 17not be used much longer.
92a19c2e 18
2193517f 19This 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 76rc2wxr::rc2wxr()
92a19c2e 77
88d42654 78{
92a19c2e 79
f80ea77b 80m_done=false;
92a19c2e 81
88d42654 82m_controlid=6000;
92a19c2e 83
88d42654
VS
84}
85
92a19c2e
GT
86
87
2193517f 88rc2wxr::~rc2wxr()
92a19c2e 89
88d42654
VS
90{
91
92a19c2e
GT
92
93
88d42654
VS
94}
95
92a19c2e
GT
96
97
2193517f 98void rc2wxr::Convert(wxString wxrfile, wxString rcfile)
88d42654 99{
4430ec36
WS
100 m_rc.Open(rcfile);
101 m_filesize=m_rc.Length();
994e41cb 102 if( (m_wxr = wxFopen( wxrfile, _T("wt") )) == NULL )
4430ec36
WS
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 137Example .rc
92a19c2e 138
88d42654 139Microsoft style as of v5.0
92a19c2e 140
88d42654 141IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
92a19c2e 142
88d42654 143STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
92a19c2e 144
88d42654 145CAPTION "About Funimator"
92a19c2e 146
88d42654
VS
147FONT 8, "MS Sans Serif"
148
92a19c2e
GT
149
150
88d42654 151 Borland 4.5 style rc
92a19c2e 152
88d42654 153IDD_DIBATTR DIALOG 7, 16, 172, 119
92a19c2e 154
88d42654 155STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
92a19c2e 156
88d42654 157CAPTION "DIB Attributes"
92a19c2e 158
88d42654 159FONT 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 175void rc2wxr::ParseDialog(wxString dlgname)
92a19c2e 176
2193517f 177{
92a19c2e 178
2193517f 179wxString tok;
92a19c2e 180
2193517f 181static int dlgid=999;
92a19c2e 182
2193517f 183dlgid++;
92a19c2e 184
7c9955d1 185/* Make sure that this really is a dialog
92a19c2e 186
2193517f 187microsoft reuses the keyword DIALOG for other things
92a19c2e 188
2193517f 189*/
92a19c2e 190
2193517f 191tok=PeekToken();
92a19c2e 192
2193517f 193//Microsoft notation?
92a19c2e 194
19d0f58d 195if (tok==_T("DISCARDABLE"))
92a19c2e 196
2193517f 197{
92a19c2e 198
2193517f 199tok=GetToken();
92a19c2e 200
2193517f 201tok=PeekToken();
92a19c2e 202
2193517f 203}
92a19c2e 204
2193517f 205//This isn't a Dialog resource eject eject
92a19c2e 206
2193517f 207if (!tok.IsNumber())
92a19c2e 208
2193517f 209 return;
92a19c2e 210
88d42654 211//Generate Dialog text
92a19c2e 212
19d0f58d 213wxFprintf(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 217wxFprintf(m_wxr,_T("style = 'wxRAISED_BORDER | wxCAPTION | wxTHICK_FRAME | wxSYSTEM_MENU',\\\n"));
88d42654 218
92a19c2e
GT
219
220
19d0f58d 221wxFprintf(m_wxr,_T("id = %i,\\\n"),dlgid);
88d42654 222
92a19c2e
GT
223
224
88d42654 225//Record x,y,width,height
92a19c2e 226
88d42654 227int x,y,width,height;
92a19c2e 228
88d42654 229ReadRect(x,y,width,height);
92a19c2e 230
19d0f58d 231wxFprintf(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 241tok=GetToken();
92a19c2e 242
88d42654
VS
243wxString title;
244
92a19c2e
GT
245
246
19d0f58d 247while ((tok!=_T("BEGIN"))&(tok!=_T("{")))
92a19c2e 248
88d42654 249{
92a19c2e 250
19d0f58d 251if (tok==_T("CAPTION"))
92a19c2e 252
2193517f 253{
92a19c2e 254
2193517f 255title=GetQuoteField();
92a19c2e 256
19d0f58d 257wxFprintf(m_wxr,_T("title = '%s',\\\n"),title.c_str());
92a19c2e 258
2193517f 259}
92a19c2e 260
88d42654 261tok=GetToken();
92a19c2e 262
88d42654 263}
92a19c2e 264
19d0f58d 265wxFprintf(m_wxr,_T("use_dialog_units = 1,\\\n"));
92a19c2e 266
19d0f58d 267wxFprintf(m_wxr,_T("use_system_defaults = 0,\\\n"));
88d42654 268
92a19c2e
GT
269
270
19d0f58d 271wxFprintf(m_wxr,_T("font = [8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif'],\\\n"));
92a19c2e 272
88d42654 273ParseControls();
92a19c2e 274
19d0f58d 275wxFprintf(m_wxr,_T(").\";\n\n"));
92a19c2e 276
88d42654
VS
277}
278
92a19c2e
GT
279
280
88d42654 281/*
92a19c2e 282
88d42654
VS
283BEGIN
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 299END
92a19c2e 300
88d42654 301*/
92a19c2e 302
2193517f 303void rc2wxr::ParseControls()
92a19c2e 304
88d42654 305{
92a19c2e 306
88d42654
VS
307wxString tok;
308
92a19c2e
GT
309
310
88d42654 311tok=GetToken();
92a19c2e 312
19d0f58d 313while ((tok!=_T("END"))&(tok!=_T("}")))
92a19c2e 314
88d42654 315{
92a19c2e 316
19d0f58d 317if (tok==_T("LTEXT"))
92a19c2e 318
88d42654 319 ParseStaticText();
92a19c2e 320
19d0f58d 321if (tok==_T("EDITTEXT"))
92a19c2e 322
88d42654 323 ParseTextCtrl();
92a19c2e 324
19d0f58d 325if (tok==_T("PUSHBUTTON"))
92a19c2e 326
88d42654 327 ParsePushButton();
92a19c2e 328
19d0f58d 329if (tok==_T("DEFPUSHBUTTON"))
92a19c2e 330
88d42654 331 ParsePushButton();
92a19c2e 332
19d0f58d 333if (tok==_T("GROUPBOX"))
92a19c2e 334
88d42654 335 ParseGroupBox();
92a19c2e 336
19d0f58d 337if (tok==_T("COMBOBOX"))
92a19c2e 338
88d42654 339 ParseComboBox();
92a19c2e 340
19d0f58d 341if (tok==_T("CONTROL"))
92a19c2e 342
88d42654
VS
343 ParseControlMS();
344
92a19c2e
GT
345
346
88d42654 347tok=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 357void rc2wxr::ParseStaticText()
92a19c2e 358
88d42654 359{
92a19c2e 360
88d42654 361wxString tok;
92a19c2e 362
88d42654 363wxString phrase,varname;
92a19c2e 364
88d42654 365phrase=GetQuoteField();
92a19c2e 366
88d42654 367varname=GetToken();
92a19c2e 368
88d42654 369m_controlid++;
92a19c2e 370
88d42654 371int x,y,width,height;
92a19c2e 372
88d42654 373ReadRect(x,y,width,height);
92a19c2e 374
19d0f58d 375wxFprintf(m_wxr,_T(" control = [%i,wxStaticText,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str());
92a19c2e 376
19d0f58d 377wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 378
19d0f58d 379wxFprintf(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 385void rc2wxr::ParseTextCtrl()
92a19c2e 386
88d42654 387{
92a19c2e 388
88d42654 389wxString tok;
92a19c2e 390
88d42654 391wxString varname;
92a19c2e 392
88d42654 393varname=GetToken();
92a19c2e 394
88d42654 395m_controlid++;
92a19c2e 396
88d42654 397int x,y,width,height;
92a19c2e 398
88d42654 399ReadRect(x,y,width,height);
92a19c2e 400
19d0f58d 401wxFprintf(m_wxr,_T(" control = [%i,wxTextCtrl,'','0','%s',"),m_controlid,varname.c_str());
92a19c2e 402
19d0f58d 403wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 404
19d0f58d 405wxFprintf(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 413void rc2wxr::ParsePushButton()
92a19c2e 414
88d42654 415{
92a19c2e 416
88d42654 417wxString tok;
92a19c2e 418
88d42654 419wxString phrase,varname;
92a19c2e 420
88d42654 421phrase=GetQuoteField();
92a19c2e 422
88d42654 423varname=GetToken();
92a19c2e 424
88d42654 425int c;
92a19c2e 426
88d42654 427m_controlid++;
92a19c2e 428
88d42654 429c=m_controlid;
92a19c2e 430
19d0f58d 431if (varname==_T("IDOK"))
92a19c2e 432
88d42654
VS
433c=wxID_OK;
434
92a19c2e
GT
435
436
19d0f58d 437if (varname==_T("IDCANCEL"))
92a19c2e 438
88d42654
VS
439c=wxID_CANCEL;
440
92a19c2e
GT
441
442
19d0f58d 443if (varname==_T("IDAPPLY"))
92a19c2e 444
88d42654
VS
445c=wxID_APPLY;
446
92a19c2e
GT
447
448
88d42654 449int x,y,width,height;
92a19c2e 450
88d42654 451ReadRect(x,y,width,height);
92a19c2e 452
19d0f58d 453wxFprintf(m_wxr,_T(" control = [%i,wxButton,'%s','0','%s',"),c,phrase.c_str(),varname.c_str());
92a19c2e 454
19d0f58d 455wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 456
19d0f58d 457wxFprintf(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 467bool rc2wxr::Seperator(int ch)
92a19c2e 468
88d42654 469{
92a19c2e 470
88d42654 471if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|'))
92a19c2e 472
f80ea77b 473 return true;
88d42654 474
92a19c2e
GT
475
476
88d42654 477if (ch==EOF)
92a19c2e 478
88d42654 479{
92a19c2e 480
f80ea77b 481m_done=true;
92a19c2e 482
f80ea77b 483return true;
92a19c2e 484
88d42654 485}
92a19c2e 486
f80ea77b 487return false;
92a19c2e 488
88d42654
VS
489}
490
92a19c2e
GT
491
492
2193517f 493void rc2wxr::ParseGroupBox()
92a19c2e 494
88d42654 495{
92a19c2e 496
88d42654 497// GROUPBOX "Rotate",IDC_STATIC,1,1,71,79
92a19c2e 498
88d42654 499wxString tok;
92a19c2e 500
88d42654 501wxString phrase,varname;
92a19c2e 502
88d42654 503phrase=GetQuoteField();
92a19c2e 504
88d42654 505varname=GetToken();
92a19c2e 506
88d42654 507m_controlid++;
92a19c2e 508
88d42654 509int x,y,width,height;
92a19c2e 510
88d42654 511ReadRect(x,y,width,height);
92a19c2e 512
19d0f58d 513wxFprintf(m_wxr,_T(" control = [%i,wxStaticBox,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str());
92a19c2e 514
19d0f58d 515wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 516
19d0f58d 517wxFprintf(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 527void rc2wxr::ReadRect(int & x, int & y, int & width, int & height)
92a19c2e 528
88d42654 529{
92a19c2e 530
19d0f58d 531x=wxAtoi(GetToken());
92a19c2e 532
19d0f58d 533y=wxAtoi(GetToken());
92a19c2e 534
19d0f58d 535width=wxAtoi(GetToken());
92a19c2e 536
19d0f58d 537height=wxAtoi(GetToken());
88d42654 538
92a19c2e
GT
539
540
88d42654
VS
541}
542
92a19c2e
GT
543
544
2193517f 545wxString rc2wxr::GetToken()
92a19c2e 546
88d42654 547{
92a19c2e 548
19d0f58d 549wxString tok=wxEmptyString;
88d42654 550
92a19c2e
GT
551
552
88d42654 553if (m_rc.Eof())
92a19c2e 554
88d42654 555{
92a19c2e 556
f80ea77b 557m_done=true;
92a19c2e 558
88d42654 559return tok;
92a19c2e 560
88d42654
VS
561}
562
92a19c2e
GT
563
564
88d42654 565int ch=0;
92a19c2e 566
88d42654 567ReadChar(ch);
92a19c2e 568
88d42654 569if (ch==EOF)
92a19c2e 570
88d42654 571{
92a19c2e 572
f80ea77b 573m_done=true;
92a19c2e 574
88d42654 575return tok;
92a19c2e 576
88d42654
VS
577}
578
92a19c2e
GT
579
580
88d42654 581while (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 595if (ch==EOF)
92a19c2e 596
88d42654 597{
92a19c2e 598
f80ea77b 599m_done=true;
88d42654 600
92a19c2e
GT
601
602
88d42654 603}
92a19c2e 604
7c9955d1 605
88d42654 606
92a19c2e
GT
607
608
88d42654 609while (!Seperator(ch))
92a19c2e 610
88d42654 611{
92a19c2e 612
2193517f 613tok+=(char)ch;
92a19c2e 614
2193517f 615ReadChar(ch);
88d42654 616
92a19c2e
GT
617
618
88d42654
VS
619}
620
92a19c2e
GT
621
622
88d42654 623if (ch==EOF)
92a19c2e 624
f80ea77b 625 m_done=true;
88d42654
VS
626
627
92a19c2e
GT
628
629
630
88d42654 631return tok;
92a19c2e 632
88d42654
VS
633}
634
92a19c2e
GT
635
636
2193517f 637wxString rc2wxr::GetQuoteField()
92a19c2e 638
88d42654 639{
92a19c2e 640
88d42654 641wxString phrase;
92a19c2e 642
88d42654 643//ASCII code 34 "
92a19c2e 644
88d42654 645int ch=0;
92a19c2e 646
88d42654
VS
647ReadChar(ch);
648
92a19c2e
GT
649
650
88d42654 651while (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 661while (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 671return phrase;
92a19c2e 672
88d42654
VS
673}
674
92a19c2e
GT
675
676
2193517f 677void rc2wxr::ReadChar(int &ch)
88d42654 678{
19311d4e 679 wxFileOffset result = m_rc.Tell();
92a19c2e 680
19311d4e
WS
681 if ( result >= m_filesize )
682 m_done=true;
88d42654 683
19311d4e 684 result = m_rc.Read(&ch,1);
92a19c2e 685
19311d4e
WS
686 if ( result==wxInvalidOffset )
687 m_done=true;
92a19c2e 688
19311d4e
WS
689 if(ch==EOF)
690 m_done=true;
88d42654
VS
691}
692
92a19c2e
GT
693
694
2193517f 695void rc2wxr::ParseComboBox()
88d42654 696{
92a19c2e 697
7c9955d1 698/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
92a19c2e 699
88d42654 700 WS_VSCROLL | WS_TABSTOP */
92a19c2e 701
88d42654 702wxString tok;
92a19c2e 703
88d42654 704wxString varname;
92a19c2e 705
88d42654 706varname=GetToken();
92a19c2e 707
88d42654 708m_controlid++;
92a19c2e 709
88d42654 710int x,y,width,height;
92a19c2e 711
88d42654
VS
712ReadRect(x,y,width,height);
713
92a19c2e
GT
714
715
19d0f58d 716wxFprintf(m_wxr,_T(" control = [%i,wxChoice,'','0','%s',"),m_controlid,varname.c_str());
92a19c2e 717
19d0f58d 718wxFprintf(m_wxr,_T("%i,%i,%i,%i,[],\\\n"),x,y,width,height);
92a19c2e 719
19d0f58d 720wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654
VS
721
722
92a19c2e
GT
723
724
725
88d42654
VS
726}
727
92a19c2e
GT
728
729
2193517f 730void rc2wxr::ParseMenu(wxString name)
92a19c2e 731
88d42654 732{
92a19c2e 733
19d0f58d 734wxString tok=wxEmptyString;
92a19c2e 735
88d42654 736static int menuid=0;
92a19c2e 737
88d42654 738menuid++;
92a19c2e 739
19d0f58d 740wxFprintf(m_wxr,_T("static char *MenuBar%i = \"menu(name = '%s',\\\n"),menuid,name.c_str());
92a19c2e 741
19d0f58d 742wxFprintf(m_wxr,_T("menu = \\\n"));
92a19c2e 743
19d0f58d 744wxFprintf(m_wxr,_T("[\\\n"));
88d42654 745
92a19c2e
GT
746
747
19d0f58d 748while ((tok!=_T("BEGIN"))&(tok!=_T("{")))
92a19c2e 749
88d42654
VS
750 tok=GetToken();
751
92a19c2e
GT
752
753
19d0f58d 754while ((tok!=_T("END"))&(tok!=_T("}")))
92a19c2e 755
88d42654 756{
92a19c2e 757
88d42654 758 tok=GetToken();
92a19c2e 759
19d0f58d 760if (tok==_T("POPUP"))
92a19c2e 761
f80ea77b 762 {
92a19c2e 763
88d42654 764 ParsePopupMenu();
92a19c2e 765
f80ea77b 766 wxFprintf(m_wxr,_T(" ],\\\n"));
92a19c2e 767
f80ea77b 768 }
92a19c2e 769
88d42654
VS
770}
771
92a19c2e
GT
772
773
19d0f58d 774wxFprintf(m_wxr,_T("]).\";\n\n"));
92a19c2e 775
88d42654
VS
776}
777
92a19c2e
GT
778
779
2193517f 780void rc2wxr::ParsePopupMenu()
92a19c2e 781
88d42654 782{
92a19c2e 783
88d42654 784static int menuitem=99;
92a19c2e 785
88d42654
VS
786menuitem++;
787
92a19c2e
GT
788
789
88d42654 790wxString tok;
92a19c2e 791
88d42654 792tok=GetQuoteField();
92a19c2e 793
88d42654 794int spot;
92a19c2e 795
88d42654 796//Remove /t because it causes problems
92a19c2e 797
19d0f58d 798spot=tok.First(_T("\\t"));
92a19c2e 799
88d42654 800tok=tok.Left(spot);
92a19c2e 801
19d0f58d 802wxFprintf(m_wxr,_T(" ['%s',%i,'',\\\n"),tok.c_str(),menuitem);
92a19c2e 803
19d0f58d 804while ((tok!=_T("BEGIN"))&(tok!=_T("{")))
92a19c2e 805
88d42654
VS
806 tok=GetToken();
807
92a19c2e
GT
808
809
19d0f58d 810while ((tok!=_T("END"))&(tok!=_T("}")))
92a19c2e 811
88d42654 812{
92a19c2e 813
88d42654 814 tok=GetToken();
92a19c2e 815
19d0f58d 816if (tok==_T("MENUITEM"))
92a19c2e 817
2193517f 818{
92a19c2e 819
19d0f58d 820if (PeekToken()==_T("SEPARATOR"))
92a19c2e 821
19d0f58d 822wxFprintf(m_wxr,_T(" [],\\\n"));
92a19c2e 823
2193517f 824else
92a19c2e 825
2193517f 826{
92a19c2e 827
2193517f 828tok=GetQuoteField();
92a19c2e 829
2193517f 830//Remove /t because it causes problems
92a19c2e 831
19d0f58d 832spot=tok.First(_T("\\t"));
92a19c2e 833
2193517f 834tok=tok.Left(spot);
92a19c2e 835
2193517f 836menuitem++;
92a19c2e 837
19d0f58d 838wxFprintf(m_wxr,_T(" ['%s',%i,''],\\\n"),tok.c_str(),menuitem);
92a19c2e 839
2193517f 840}
92a19c2e 841
2193517f 842}
88d42654 843
92a19c2e
GT
844
845
88d42654
VS
846}
847
92a19c2e
GT
848
849
7c9955d1 850
92a19c2e 851
88d42654
VS
852}
853
92a19c2e
GT
854
855
2193517f 856wxString rc2wxr::PeekToken()
92a19c2e 857
88d42654 858{
92a19c2e 859
88d42654 860wxString tok;
92a19c2e 861
88d42654 862int p;
92a19c2e 863
88d42654 864p=m_rc.Tell();
92a19c2e 865
88d42654
VS
866tok=GetToken();
867
92a19c2e
GT
868
869
88d42654 870m_rc.Seek(p);
92a19c2e 871
88d42654 872return tok;
92a19c2e 873
88d42654 874}
92a19c2e 875
88d42654 876//Windows pain in the butt CONTROL
92a19c2e 877
2193517f 878void rc2wxr::ParseControlMS()
92a19c2e 879
88d42654 880{
92a19c2e 881
88d42654 882wxString label,varname,kindctrl,tok;
92a19c2e 883
88d42654 884label=GetQuoteField();
92a19c2e 885
88d42654 886varname=GetToken();
92a19c2e 887
88d42654 888kindctrl=GetQuoteField();
92a19c2e 889
88d42654
VS
890kindctrl.MakeUpper();
891
892
92a19c2e
GT
893
894
895
19d0f58d 896if (kindctrl==_T("MSCTLS_TRACKBAR32"))
92a19c2e 897
88d42654 898 ParseSlider(label,varname);
92a19c2e 899
19d0f58d 900if (kindctrl==_T("MSCTLS_PROGRESS32"))
92a19c2e 901
88d42654 902 ParseProgressBar(label,varname);
92a19c2e 903
19d0f58d 904if (kindctrl==_T("BUTTON"))
92a19c2e 905
88d42654 906 ParseCtrlButton(label,varname);
92a19c2e 907
88d42654 908}
92a19c2e 909
7c9955d1 910/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
92a19c2e 911
88d42654 912 TBS_NOTICKS | WS_TABSTOP,52,73,100,15
92a19c2e 913
88d42654
VS
914*/
915
92a19c2e
GT
916
917
19d0f58d 918void rc2wxr::ParseSlider(wxString WXUNUSED(label), wxString varname)
92a19c2e 919
88d42654 920{
92a19c2e 921
2193517f 922wxString tok;
92a19c2e 923
b2247ee9
CE
924while (ReadOrs(tok))
925 ;
92a19c2e 926
19d0f58d 927wxFprintf(m_wxr,_T(" control = [%i,wxSlider,'','wxSL_HORIZONTAL','%s',"),m_controlid,varname.c_str());
92a19c2e 928
88d42654 929int x,y,width,height;
92a19c2e 930
88d42654 931ReadRect(x,y,width,height);
92a19c2e 932
19d0f58d 933wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height);
92a19c2e 934
19d0f58d 935wxFprintf(m_wxr,_T(" 1, 1, 10,\\\n"));
92a19c2e 936
19d0f58d 937wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
92a19c2e 938
88d42654 939}
92a19c2e 940
7c9955d1 941/*
92a19c2e 942
88d42654 943CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32",
92a19c2e 944
88d42654 945 WS_BORDER,15,52,154,13
92a19c2e 946
88d42654 947*/
92a19c2e 948
19d0f58d 949void rc2wxr::ParseProgressBar(wxString WXUNUSED(label), wxString varname)
92a19c2e 950
88d42654 951{
92a19c2e 952
88d42654 953wxString tok;
92a19c2e 954
b2247ee9
CE
955while (ReadOrs(tok))
956 ;
92a19c2e 957
19d0f58d 958wxFprintf(m_wxr,_T(" control = [%i,wxGauge,'','wxGA_HORIZONTAL','%s',"),m_controlid,varname.c_str());
92a19c2e 959
88d42654 960int x,y,width,height;
92a19c2e 961
88d42654 962ReadRect(x,y,width,height);
92a19c2e 963
19d0f58d 964wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height);
92a19c2e 965
19d0f58d 966wxFprintf(m_wxr,_T(" 0, 10,\\\n"));
92a19c2e 967
19d0f58d 968wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
92a19c2e 969
88d42654
VS
970}
971
92a19c2e
GT
972
973
2193517f 974bool rc2wxr::ReadOrs(wxString & w)
92a19c2e 975
88d42654 976{
92a19c2e 977
88d42654 978wxString tok;
92a19c2e 979
88d42654 980tok=PeekToken();
92a19c2e 981
88d42654 982if (tok.IsNumber())
92a19c2e 983
88d42654 984 return false;
92a19c2e 985
88d42654 986w=GetToken();
92a19c2e 987
f80ea77b 988return true;
92a19c2e 989
88d42654
VS
990}
991
92a19c2e
GT
992
993
88d42654 994//Is it a check button or a radio button
92a19c2e 995
2193517f 996void rc2wxr::ParseCtrlButton(wxString label, wxString varname)
92a19c2e 997
88d42654 998{
92a19c2e 999
88d42654 1000wxString tok;
92a19c2e 1001
2193517f 1002tok=GetToken();
88d42654 1003
92a19c2e
GT
1004
1005
88d42654 1006m_controlid++;
92a19c2e 1007
2193517f 1008int x,y,width,height;
88d42654 1009
92a19c2e
GT
1010
1011
19d0f58d 1012if (tok==_T("BS_AUTOCHECKBOX"))
92a19c2e 1013
88d42654 1014{
92a19c2e 1015
19d0f58d 1016 wxFprintf(m_wxr,_T(" control = [%i,wxCheckBox,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str());
92a19c2e 1017
b2247ee9
CE
1018 while (ReadOrs(tok))
1019 ;
92a19c2e 1020
2193517f 1021 ReadRect(x,y,width,height);
92a19c2e 1022
19d0f58d 1023 wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height);
92a19c2e 1024
19d0f58d 1025 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
92a19c2e 1026
88d42654
VS
1027}
1028
92a19c2e
GT
1029
1030
19d0f58d 1031if (tok==_T("BS_AUTORADIOBUTTON"))
92a19c2e 1032
88d42654 1033{
92a19c2e 1034
19d0f58d 1035 wxFprintf(m_wxr,_T(" control = [%i,wxRadioButton,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str());
92a19c2e 1036
b2247ee9
CE
1037 while(ReadOrs(tok))
1038 ;
92a19c2e 1039
2193517f 1040 ReadRect(x,y,width,height);
92a19c2e 1041
19d0f58d 1042 wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height);
92a19c2e 1043
19d0f58d 1044 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
92a19c2e 1045
88d42654
VS
1046}
1047
1048
1049
92a19c2e
GT
1050
1051
1052
1053
88d42654
VS
1054}
1055
92a19c2e
GT
1056
1057