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