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