]> git.saurik.com Git - wxWidgets.git/blame - contrib/utils/convertrc/rc2wxr.cpp
Defaults in wxWinCE documented.
[wxWidgets.git] / contrib / utils / convertrc / rc2wxr.cpp
CommitLineData
2193517f 1// rc2wxr.cpp: implementation of the rc2wxr class.
88d42654
VS
2//
3//////////////////////////////////////////////////////////////////////
2193517f
VS
4//Author: Brian Gavin 9/24/00
5//License: wxWindows License
6/*
7WARNING- I know this code has some bugs to work out but
8I don't plan to fix them since I feel that wxr files will
9not be used much longer.
10This code was used as a starting point for my rc2xml converter
11*/
92a19c2e 12
2193517f 13#ifdef __GNUG__
694f70fa 14#pragma implementation "rc2wxr.h"
2193517f
VS
15#endif
16
88d42654 17// For compilers that support precompilation, includes "wx/wx.h".
92a19c2e
GT
18#include "wx/wxprec.h"
19
2193517f 20#ifdef __BORLANDC__
d7e3abf7 21 #pragma hdrstop
2193517f
VS
22#endif
23
24// for all others, include the necessary headers (this file is usually all you
92a19c2e 25
be5a51fb 26// need because it includes almost all "standard" wxWidgets headers
92a19c2e 27
2193517f 28#ifndef WX_PRECOMP
d7e3abf7 29 #include "wx/wx.h"
2193517f
VS
30#endif
31
88d42654 32#include "wx/image.h"
7c9955d1
JS
33#include "wx/deprecated/setup.h"
34#include "wx/deprecated/resource.h"
92a19c2e 35
d7e3abf7 36#include "rc2wxr.h"
92a19c2e 37
d7e3abf7 38//////////////////////////////////////////////////////////////////////
88d42654
VS
39// Construction/Destruction
40//////////////////////////////////////////////////////////////////////
41
2193517f 42rc2wxr::rc2wxr()
88d42654 43{
d7e3abf7
WS
44 m_done=false;
45 m_controlid=6000;
88d42654
VS
46}
47
2193517f 48rc2wxr::~rc2wxr()
88d42654 49{
88d42654
VS
50}
51
2193517f 52void rc2wxr::Convert(wxString wxrfile, wxString rcfile)
88d42654 53{
4430ec36
WS
54 m_rc.Open(rcfile);
55 m_filesize=m_rc.Length();
994e41cb 56 if( (m_wxr = wxFopen( wxrfile, _T("wt") )) == NULL )
4430ec36
WS
57 {
58 return;
59 }
92a19c2e 60
4430ec36 61 wxString tok,prevtok;
92a19c2e 62
4430ec36
WS
63 while (!m_done)
64 {
65 tok=GetToken();
92a19c2e 66
4430ec36
WS
67 if (tok==_T("DIALOG"))
68 {
69 ParseDialog(prevtok);
70 }
92a19c2e 71
4430ec36
WS
72 if (tok==_T("MENU"))
73 {
74 ParseMenu(prevtok);
75 }
88d42654 76
4430ec36
WS
77 prevtok=tok;
78 }
92a19c2e 79
4430ec36 80 fclose(m_wxr);
92a19c2e 81
4430ec36 82 m_rc.Close();
88d42654
VS
83}
84
85
86/*
92a19c2e 87
7c9955d1 88Example .rc
92a19c2e 89
88d42654 90Microsoft style as of v5.0
92a19c2e 91
88d42654 92IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
92a19c2e 93
88d42654 94STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
92a19c2e 95
88d42654 96CAPTION "About Funimator"
92a19c2e 97
88d42654
VS
98FONT 8, "MS Sans Serif"
99
100 Borland 4.5 style rc
92a19c2e 101
88d42654 102IDD_DIBATTR DIALOG 7, 16, 172, 119
92a19c2e 103
88d42654 104STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
92a19c2e 105
88d42654 106CAPTION "DIB Attributes"
92a19c2e 107
88d42654 108FONT 8, "MS Sans Serif"
92a19c2e 109
88d42654 110{
92a19c2e 111
88d42654 112 DEFPUSHBUTTON "Ok", IDOK, 114, 8, 50, 14
92a19c2e 113
88d42654
VS
114 PUSHBUTTON "Cancel", IDCANCEL, 114, 28, 50, 14
115
88d42654 116*/
92a19c2e 117
2193517f 118void rc2wxr::ParseDialog(wxString dlgname)
92a19c2e 119
2193517f 120{
92a19c2e 121
2193517f 122wxString tok;
92a19c2e 123
2193517f 124static int dlgid=999;
92a19c2e 125
2193517f 126dlgid++;
92a19c2e 127
7c9955d1 128/* Make sure that this really is a dialog
92a19c2e 129
2193517f 130microsoft reuses the keyword DIALOG for other things
92a19c2e 131
2193517f 132*/
92a19c2e 133
2193517f 134tok=PeekToken();
92a19c2e 135
2193517f 136//Microsoft notation?
92a19c2e 137
19d0f58d 138if (tok==_T("DISCARDABLE"))
92a19c2e 139
2193517f 140{
92a19c2e 141
2193517f 142tok=GetToken();
92a19c2e 143
2193517f 144tok=PeekToken();
92a19c2e 145
2193517f 146}
92a19c2e 147
2193517f 148//This isn't a Dialog resource eject eject
92a19c2e 149
2193517f 150if (!tok.IsNumber())
92a19c2e 151
2193517f 152 return;
92a19c2e 153
88d42654 154//Generate Dialog text
92a19c2e 155
19d0f58d 156wxFprintf(m_wxr,_T("static char *dialog%i = \"dialog(name = '%s',\\\n"),dlgid,dlgname.c_str());
92a19c2e 157
88d42654 158//be lazy about style for now. add it later
92a19c2e 159
19d0f58d 160wxFprintf(m_wxr,_T("style = 'wxRAISED_BORDER | wxCAPTION | wxTHICK_FRAME | wxSYSTEM_MENU',\\\n"));
19d0f58d 161wxFprintf(m_wxr,_T("id = %i,\\\n"),dlgid);
88d42654
VS
162
163//Record x,y,width,height
92a19c2e 164
88d42654 165int x,y,width,height;
92a19c2e 166
88d42654 167ReadRect(x,y,width,height);
92a19c2e 168
19d0f58d 169wxFprintf(m_wxr,_T("x = %i, y = %i, width = %i, height = %i,\\\n"),x,y,width,height);
88d42654
VS
170
171
172//CAPTION "About Funimator"
92a19c2e 173
88d42654 174//Get Title
92a19c2e 175
88d42654 176tok=GetToken();
92a19c2e 177
88d42654
VS
178wxString title;
179
92a19c2e
GT
180
181
19d0f58d 182while ((tok!=_T("BEGIN"))&(tok!=_T("{")))
92a19c2e 183
88d42654 184{
92a19c2e 185
19d0f58d 186if (tok==_T("CAPTION"))
92a19c2e 187
2193517f 188{
92a19c2e 189
2193517f 190title=GetQuoteField();
92a19c2e 191
19d0f58d 192wxFprintf(m_wxr,_T("title = '%s',\\\n"),title.c_str());
92a19c2e 193
2193517f 194}
92a19c2e 195
88d42654 196tok=GetToken();
92a19c2e 197
88d42654 198}
92a19c2e 199
19d0f58d 200wxFprintf(m_wxr,_T("use_dialog_units = 1,\\\n"));
92a19c2e 201
19d0f58d 202wxFprintf(m_wxr,_T("use_system_defaults = 0,\\\n"));
88d42654 203
92a19c2e
GT
204
205
19d0f58d 206wxFprintf(m_wxr,_T("font = [8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif'],\\\n"));
92a19c2e 207
88d42654 208ParseControls();
92a19c2e 209
19d0f58d 210wxFprintf(m_wxr,_T(").\";\n\n"));
92a19c2e 211
88d42654
VS
212}
213
92a19c2e
GT
214
215
88d42654 216/*
92a19c2e 217
88d42654
VS
218BEGIN
219
220
221
92a19c2e
GT
222
223
224
225
7c9955d1 226 EDITTEXT IDC_BANDS,36,83,22,14,ES_AUTOHSCROLL | ES_NUMBER | NOT
92a19c2e 227
88d42654 228 WS_TABSTOP
92a19c2e 229
88d42654 230 LTEXT "Bands",IDC_STATIC,11,86,21,8
92a19c2e 231
88d42654 232 EDITTEXT IDC_NAME,10,3,75,14,ES_AUTOHSCROLL
92a19c2e 233
88d42654 234END
92a19c2e 235
88d42654 236*/
92a19c2e 237
2193517f 238void rc2wxr::ParseControls()
92a19c2e 239
88d42654 240{
92a19c2e 241
88d42654
VS
242wxString tok;
243
92a19c2e
GT
244
245
88d42654 246tok=GetToken();
92a19c2e 247
19d0f58d 248while ((tok!=_T("END"))&(tok!=_T("}")))
92a19c2e 249
88d42654 250{
92a19c2e 251
19d0f58d 252if (tok==_T("LTEXT"))
92a19c2e 253
88d42654 254 ParseStaticText();
92a19c2e 255
19d0f58d 256if (tok==_T("EDITTEXT"))
92a19c2e 257
88d42654 258 ParseTextCtrl();
92a19c2e 259
19d0f58d 260if (tok==_T("PUSHBUTTON"))
92a19c2e 261
88d42654 262 ParsePushButton();
92a19c2e 263
19d0f58d 264if (tok==_T("DEFPUSHBUTTON"))
92a19c2e 265
88d42654 266 ParsePushButton();
92a19c2e 267
19d0f58d 268if (tok==_T("GROUPBOX"))
92a19c2e 269
88d42654 270 ParseGroupBox();
92a19c2e 271
19d0f58d 272if (tok==_T("COMBOBOX"))
92a19c2e 273
88d42654 274 ParseComboBox();
92a19c2e 275
19d0f58d 276if (tok==_T("CONTROL"))
92a19c2e 277
88d42654
VS
278 ParseControlMS();
279
92a19c2e
GT
280
281
88d42654 282tok=GetToken();
92a19c2e 283
88d42654
VS
284}
285
92a19c2e
GT
286
287
88d42654 288}
92a19c2e 289
88d42654 290//LTEXT "Radius",IDC_STATIC,9,67,23,8
92a19c2e 291
2193517f 292void rc2wxr::ParseStaticText()
92a19c2e 293
88d42654 294{
92a19c2e 295
88d42654 296wxString tok;
92a19c2e 297
88d42654 298wxString phrase,varname;
92a19c2e 299
88d42654 300phrase=GetQuoteField();
92a19c2e 301
88d42654 302varname=GetToken();
92a19c2e 303
88d42654 304m_controlid++;
92a19c2e 305
88d42654 306int x,y,width,height;
92a19c2e 307
88d42654 308ReadRect(x,y,width,height);
92a19c2e 309
19d0f58d 310wxFprintf(m_wxr,_T(" control = [%i,wxStaticText,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str());
92a19c2e 311
19d0f58d 312wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 313
19d0f58d 314wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
92a19c2e 315
88d42654 316}
92a19c2e 317
88d42654 318//EDITTEXT IDC_RADIUS,36,65,40,14,ES_AUTOHSCROLL
92a19c2e 319
2193517f 320void rc2wxr::ParseTextCtrl()
92a19c2e 321
88d42654 322{
92a19c2e 323
88d42654 324wxString tok;
92a19c2e 325
88d42654 326wxString varname;
92a19c2e 327
88d42654 328varname=GetToken();
92a19c2e 329
88d42654 330m_controlid++;
92a19c2e 331
88d42654 332int x,y,width,height;
92a19c2e 333
88d42654 334ReadRect(x,y,width,height);
92a19c2e 335
19d0f58d 336wxFprintf(m_wxr,_T(" control = [%i,wxTextCtrl,'','0','%s',"),m_controlid,varname.c_str());
92a19c2e 337
19d0f58d 338wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 339
19d0f58d 340wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654 341
92a19c2e
GT
342
343
88d42654 344}
92a19c2e 345
88d42654 346//PUSHBUTTON "Create/Update",IDC_CREATE,15,25,53,13,NOT WS_TABSTOP
92a19c2e 347
2193517f 348void rc2wxr::ParsePushButton()
92a19c2e 349
88d42654 350{
92a19c2e 351
88d42654 352wxString tok;
92a19c2e 353
88d42654 354wxString phrase,varname;
92a19c2e 355
88d42654 356phrase=GetQuoteField();
92a19c2e 357
88d42654 358varname=GetToken();
92a19c2e 359
88d42654 360int c;
92a19c2e 361
88d42654 362m_controlid++;
92a19c2e 363
88d42654 364c=m_controlid;
92a19c2e 365
19d0f58d 366if (varname==_T("IDOK"))
92a19c2e 367
88d42654
VS
368c=wxID_OK;
369
92a19c2e
GT
370
371
19d0f58d 372if (varname==_T("IDCANCEL"))
92a19c2e 373
88d42654
VS
374c=wxID_CANCEL;
375
92a19c2e
GT
376
377
19d0f58d 378if (varname==_T("IDAPPLY"))
92a19c2e 379
88d42654
VS
380c=wxID_APPLY;
381
92a19c2e
GT
382
383
88d42654 384int x,y,width,height;
92a19c2e 385
88d42654 386ReadRect(x,y,width,height);
92a19c2e 387
19d0f58d 388wxFprintf(m_wxr,_T(" control = [%i,wxButton,'%s','0','%s',"),c,phrase.c_str(),varname.c_str());
92a19c2e 389
19d0f58d 390wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 391
19d0f58d 392wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654 393
92a19c2e
GT
394
395
88d42654
VS
396}
397
398
92a19c2e
GT
399
400
401
3103e8a9 402bool rc2wxr::Separator(int ch)
92a19c2e 403
88d42654 404{
92a19c2e 405
88d42654 406if ((ch==' ')|(ch==',')|(ch==13)|(ch==10)|(ch=='|'))
92a19c2e 407
f80ea77b 408 return true;
88d42654 409
92a19c2e
GT
410
411
88d42654 412if (ch==EOF)
92a19c2e 413
88d42654 414{
92a19c2e 415
f80ea77b 416m_done=true;
92a19c2e 417
f80ea77b 418return true;
92a19c2e 419
88d42654 420}
92a19c2e 421
f80ea77b 422return false;
92a19c2e 423
88d42654
VS
424}
425
92a19c2e
GT
426
427
2193517f 428void rc2wxr::ParseGroupBox()
92a19c2e 429
88d42654 430{
92a19c2e 431
88d42654 432// GROUPBOX "Rotate",IDC_STATIC,1,1,71,79
92a19c2e 433
88d42654 434wxString tok;
92a19c2e 435
88d42654 436wxString phrase,varname;
92a19c2e 437
88d42654 438phrase=GetQuoteField();
92a19c2e 439
88d42654 440varname=GetToken();
92a19c2e 441
88d42654 442m_controlid++;
92a19c2e 443
88d42654 444int x,y,width,height;
92a19c2e 445
88d42654 446ReadRect(x,y,width,height);
92a19c2e 447
19d0f58d 448wxFprintf(m_wxr,_T(" control = [%i,wxStaticBox,'%s','0','%s',"),m_controlid,phrase.c_str(),varname.c_str());
92a19c2e 449
19d0f58d 450wxFprintf(m_wxr,_T("%i,%i,%i,%i,'',\\\n"),x,y,width,height);
92a19c2e 451
19d0f58d 452wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654
VS
453
454
92a19c2e
GT
455
456
457
88d42654
VS
458}
459
92a19c2e
GT
460
461
2193517f 462void rc2wxr::ReadRect(int & x, int & y, int & width, int & height)
92a19c2e 463
88d42654 464{
92a19c2e 465
19d0f58d 466x=wxAtoi(GetToken());
92a19c2e 467
19d0f58d 468y=wxAtoi(GetToken());
92a19c2e 469
19d0f58d 470width=wxAtoi(GetToken());
92a19c2e 471
19d0f58d 472height=wxAtoi(GetToken());
88d42654 473
92a19c2e
GT
474
475
88d42654
VS
476}
477
92a19c2e
GT
478
479
2193517f 480wxString rc2wxr::GetToken()
92a19c2e 481
88d42654 482{
92a19c2e 483
19d0f58d 484wxString tok=wxEmptyString;
88d42654 485
92a19c2e
GT
486
487
88d42654 488if (m_rc.Eof())
92a19c2e 489
88d42654 490{
92a19c2e 491
f80ea77b 492m_done=true;
92a19c2e 493
88d42654 494return tok;
92a19c2e 495
88d42654
VS
496}
497
92a19c2e
GT
498
499
88d42654 500int ch=0;
92a19c2e 501
88d42654 502ReadChar(ch);
92a19c2e 503
88d42654 504if (ch==EOF)
92a19c2e 505
88d42654 506{
92a19c2e 507
f80ea77b 508m_done=true;
92a19c2e 509
88d42654 510return tok;
92a19c2e 511
88d42654
VS
512}
513
92a19c2e
GT
514
515
3103e8a9 516while (Separator(ch))
92a19c2e 517
88d42654 518{
92a19c2e 519
88d42654 520 ReadChar(ch);
92a19c2e 521
88d42654 522 if (m_done)
92a19c2e 523
2193517f 524 return tok;
92a19c2e 525
88d42654
VS
526}
527
92a19c2e
GT
528
529
88d42654 530if (ch==EOF)
92a19c2e 531
88d42654 532{
92a19c2e 533
f80ea77b 534m_done=true;
88d42654 535
92a19c2e
GT
536
537
88d42654 538}
92a19c2e 539
7c9955d1 540
88d42654 541
92a19c2e
GT
542
543
3103e8a9 544while (!Separator(ch))
92a19c2e 545
88d42654 546{
92a19c2e 547
2193517f 548tok+=(char)ch;
92a19c2e 549
2193517f 550ReadChar(ch);
88d42654 551
92a19c2e
GT
552
553
88d42654
VS
554}
555
92a19c2e
GT
556
557
88d42654 558if (ch==EOF)
92a19c2e 559
f80ea77b 560 m_done=true;
88d42654
VS
561
562
92a19c2e
GT
563
564
565
88d42654 566return tok;
92a19c2e 567
88d42654
VS
568}
569
92a19c2e
GT
570
571
2193517f 572wxString rc2wxr::GetQuoteField()
88d42654 573{
d7e3abf7 574 wxString phrase;
92a19c2e 575
d7e3abf7
WS
576 //ASCII code 34 "
577 int ch=0;
578 ReadChar(ch);
92a19c2e 579
d7e3abf7
WS
580 while (ch!=34)
581 ReadChar(ch);
92a19c2e 582
d7e3abf7 583 ReadChar(ch);
92a19c2e 584
d7e3abf7
WS
585 while (ch!=34)
586 {
587 phrase+=(char)ch;
588 ReadChar(ch);
589 }
92a19c2e 590
d7e3abf7 591 return phrase;
88d42654
VS
592}
593
92a19c2e
GT
594
595
2193517f 596void rc2wxr::ReadChar(int &ch)
88d42654 597{
19311d4e 598 wxFileOffset result = m_rc.Tell();
92a19c2e 599
19311d4e
WS
600 if ( result >= m_filesize )
601 m_done=true;
88d42654 602
19311d4e 603 result = m_rc.Read(&ch,1);
92a19c2e 604
19311d4e
WS
605 if ( result==wxInvalidOffset )
606 m_done=true;
92a19c2e 607
19311d4e
WS
608 if(ch==EOF)
609 m_done=true;
88d42654
VS
610}
611
92a19c2e 612
7c9955d1 613/* COMBOBOX IDC_SCALECOMBO,10,110,48,52,CBS_DROPDOWNLIST | CBS_SORT |
88d42654 614 WS_VSCROLL | WS_TABSTOP */
d7e3abf7
WS
615void rc2wxr::ParseComboBox()
616{
617 int x,y,width,height;
618 wxString tok;
619 wxString varname = GetToken();
92a19c2e 620
d7e3abf7 621 m_controlid++;
92a19c2e 622
d7e3abf7
WS
623 ReadRect(x,y,width,height);
624 wxFprintf(m_wxr,_T(" control = [%i,wxChoice,'','0','%s',"),m_controlid,varname.c_str());
625 wxFprintf(m_wxr,_T("%i,%i,%i,%i,[],\\\n"),x,y,width,height);
626 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654
VS
627}
628
92a19c2e 629
2193517f 630void rc2wxr::ParseMenu(wxString name)
88d42654 631{
d7e3abf7
WS
632 wxString tok;
633 static int menuid=0;
634 menuid++;
635 wxFprintf(m_wxr,_T("static char *MenuBar%i = \"menu(name = '%s',\\\n"),menuid,name.c_str());
636 wxFprintf(m_wxr,_T("menu = \\\n"));
637 wxFprintf(m_wxr,_T("[\\\n"));
92a19c2e 638
d7e3abf7
WS
639 while ((tok!=_T("BEGIN"))&(tok!=_T("{")))
640 tok=GetToken();
92a19c2e 641
d7e3abf7 642 while ((tok!=_T("END"))&(tok!=_T("}")))
f80ea77b 643 {
d7e3abf7 644 tok=GetToken();
92a19c2e 645
d7e3abf7
WS
646 if (tok==_T("POPUP"))
647 {
648 ParsePopupMenu();
649 wxFprintf(m_wxr,_T(" ],\\\n"));
650 }
f80ea77b 651 }
92a19c2e 652
d7e3abf7 653 wxFprintf(m_wxr,_T("]).\";\n\n"));
88d42654
VS
654}
655
92a19c2e 656
2193517f 657void rc2wxr::ParsePopupMenu()
2193517f 658{
d7e3abf7 659 static int menuitem=99;
92a19c2e 660
d7e3abf7 661 menuitem++;
92a19c2e 662
d7e3abf7
WS
663 wxString tok = GetQuoteField();
664 int spot;
88d42654 665
d7e3abf7
WS
666 //Remove /t because it causes problems
667 spot=tok.First(_T("\\t"));
668 tok=tok.Left(spot);
92a19c2e 669
d7e3abf7 670 wxFprintf(m_wxr,_T(" ['%s',%i,'',\\\n"),tok.c_str(),menuitem);
92a19c2e 671
d7e3abf7
WS
672 while ((tok!=_T("BEGIN"))&(tok!=_T("{")))
673 tok=GetToken();
7c9955d1 674
d7e3abf7
WS
675 while ((tok!=_T("END"))&(tok!=_T("}")))
676 {
677 tok=GetToken();
92a19c2e 678
d7e3abf7
WS
679 if (tok==_T("MENUITEM"))
680 {
681 if (PeekToken()==_T("SEPARATOR"))
682 {
683 wxFprintf(m_wxr,_T(" [],\\\n"));
684 }
685 else
686 {
687 tok=GetQuoteField();
688 //Remove /t because it causes problems
689 spot=tok.First(_T("\\t"));
690 tok=tok.Left(spot);
691 menuitem++;
692 wxFprintf(m_wxr,_T(" ['%s',%i,''],\\\n"),tok.c_str(),menuitem);
693 }
694 }
695 }
88d42654
VS
696}
697
92a19c2e
GT
698
699
2193517f 700wxString rc2wxr::PeekToken()
88d42654 701{
d7e3abf7
WS
702 wxFileOffset p = m_rc.Tell();
703 wxString tok = GetToken();
704 m_rc.Seek(p);
705 return tok;
88d42654 706}
92a19c2e 707
88d42654 708//Windows pain in the butt CONTROL
2193517f 709void rc2wxr::ParseControlMS()
88d42654 710{
d7e3abf7
WS
711 wxString tok;
712 wxString label=GetQuoteField();
713 wxString varname=GetToken();
714 wxString kindctrl=GetQuoteField();
92a19c2e 715
d7e3abf7
WS
716 kindctrl.MakeUpper();
717 if (kindctrl==_T("MSCTLS_TRACKBAR32"))
718 ParseSlider(label,varname);
719 if (kindctrl==_T("MSCTLS_PROGRESS32"))
720 ParseProgressBar(label,varname);
721 if (kindctrl==_T("BUTTON"))
722 ParseCtrlButton(label,varname);
88d42654 723}
92a19c2e 724
7c9955d1 725/* CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH |
88d42654
VS
726 TBS_NOTICKS | WS_TABSTOP,52,73,100,15
727*/
19d0f58d 728void rc2wxr::ParseSlider(wxString WXUNUSED(label), wxString varname)
88d42654 729{
d7e3abf7
WS
730 int x,y,width,height;
731 wxString tok;
92a19c2e 732
d7e3abf7
WS
733 while (ReadOrs(tok))
734 ;
735 wxFprintf(m_wxr,_T(" control = [%i,wxSlider,'','wxSL_HORIZONTAL','%s',"),m_controlid,varname.c_str());
736 ReadRect(x,y,width,height);
737 wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height);
738 wxFprintf(m_wxr,_T(" 1, 1, 10,\\\n"));
739 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654 740}
92a19c2e 741
7c9955d1 742/*
88d42654
VS
743CONTROL "Progress1",CG_IDC_PROGDLG_PROGRESS,"msctls_progress32",
744 WS_BORDER,15,52,154,13
745*/
19d0f58d 746void rc2wxr::ParseProgressBar(wxString WXUNUSED(label), wxString varname)
88d42654 747{
d7e3abf7
WS
748 int x,y,width,height;
749 wxString tok;
92a19c2e 750
b2247ee9
CE
751 while (ReadOrs(tok))
752 ;
92a19c2e 753
d7e3abf7 754 wxFprintf(m_wxr,_T(" control = [%i,wxGauge,'','wxGA_HORIZONTAL','%s',"),m_controlid,varname.c_str());
2193517f 755 ReadRect(x,y,width,height);
d7e3abf7
WS
756 wxFprintf(m_wxr,_T("%i,%i,%i,%i,"),x,y,width,height);
757 wxFprintf(m_wxr,_T(" 0, 10,\\\n"));
19d0f58d 758 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
88d42654
VS
759}
760
92a19c2e 761
d7e3abf7 762bool rc2wxr::ReadOrs(wxString & w)
88d42654 763{
d7e3abf7
WS
764 wxString tok = PeekToken();
765 if (tok.IsNumber())
766 return false;
767 w=GetToken();
768 return true;
88d42654
VS
769}
770
771
d7e3abf7
WS
772//Is it a check button or a radio button
773void rc2wxr::ParseCtrlButton(wxString label, wxString varname)
774{
775 int x,y,width,height;
776 wxString tok = GetToken();
88d42654 777
d7e3abf7 778 m_controlid++;
92a19c2e 779
d7e3abf7
WS
780 if (tok==_T("BS_AUTOCHECKBOX"))
781 {
782 wxFprintf(m_wxr,_T(" control = [%i,wxCheckBox,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str());
783 while (ReadOrs(tok))
784 ;
92a19c2e 785
d7e3abf7
WS
786 ReadRect(x,y,width,height);
787 wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height);
788 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
789 }
92a19c2e 790
d7e3abf7
WS
791 if (tok==_T("BS_AUTORADIOBUTTON"))
792 {
793 wxFprintf(m_wxr,_T(" control = [%i,wxRadioButton,'%s','0','%s',"),m_controlid,label.c_str(),varname.c_str());
794 while(ReadOrs(tok))
795 ;
92a19c2e 796
d7e3abf7
WS
797 ReadRect(x,y,width,height);
798 wxFprintf(m_wxr,_T("%i,%i,%i,%i,0,\\\n"),x,y,width,height);
799 wxFprintf(m_wxr,_T("[8, 'wxSWISS', 'wxNORMAL', 'wxNORMAL', 0, 'MS Sans Serif']],\\\n"));
800 }
88d42654
VS
801}
802