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