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