]> git.saurik.com Git - wxWidgets.git/blame - contrib/utils/convertrc/convert.cpp
Changed version number
[wxWidgets.git] / contrib / utils / convertrc / convert.cpp
CommitLineData
2193517f
VS
1//wxConvertApp Programming Utility
2/*This program currently offers 3 useful conversions
31. Converts most of an .RC file into a wxXml file
42. Converts most of an .wxr file into a wxXml file
53. Converts portions of an .RC file into a wxr file
6*/
7
8#ifdef __GNUG__
694f70fa 9#pragma implementation "convert.h"
2193517f
VS
10#endif
11
12// For compilers that support precompilation, includes "wx/wx.h".
92a19c2e 13#include "wx/wxprec.h"
2193517f
VS
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19// for all others, include the necessary headers (this file is usually all you
be5a51fb 20// need because it includes almost all "standard" wxWidgets headers
2193517f
VS
21#ifndef WX_PRECOMP
22#include <wx/wx.h>
23#endif
24
25#include <wx/image.h>
7c9955d1
JS
26
27#include "wx/deprecated/setup.h"
28#include "wx/deprecated/resource.h"
2193517f
VS
29
30#include "convert.h"
31#include "rc2wxr.h"
32#include "wxr2xml.h"
33#include "rc2xml.h"
34
35IMPLEMENT_APP(wxConvertApp)
36//////////////////////////////////////////////////////////////////////
37// Construction/Destruction
38//////////////////////////////////////////////////////////////////////
39
40wxConvertApp::wxConvertApp()
41{
42 m_pFrame=NULL;
43 m_pMenuBar=NULL;
44
45}
46
47wxConvertApp::~wxConvertApp()
48{
49
50}
51
52
53bool wxConvertApp::OnInit()
54{
55//Initialize all image loaders(JPEG,BMP,PNG,and etc)
56 wxInitAllImageHandlers();
19d0f58d 57 SetAppName(_T("wxConvertApp"));
2193517f
VS
58
59 if (HandleCommandLine())
f80ea77b 60 return true;
2193517f
VS
61
62
63// Create the main frame window
f80ea77b 64 m_pFrame = new wxMainFrame(NULL, wxID_ANY, _T("wxConvertApp"), wxPoint(0, 0), wxSize(500, 400),
2193517f 65 wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);
7c9955d1 66
2193517f 67 InitMenu();
f80ea77b 68 m_pFrame->Show(true);
2193517f 69 SetTopWindow(m_pFrame);
f80ea77b 70 return true;
2193517f
VS
71}
72
73void wxConvertApp::InitMenu()
74{
75 m_pMenuBar=new wxMenuBar;
76 wxASSERT(m_pMenuBar);
77
78 wxMenu *filemenu=new wxMenu;
19d0f58d
JS
79 filemenu->Append(ID_RC2WXR,_T("Convert RC file to WXR file"));
80 filemenu->Append(ID_WXR2XML,_T("Convert WXR file to XML file"));
81 filemenu->Append(ID_RC2XML,_T("Convert RC file to XML file"));
2193517f 82
19d0f58d
JS
83 filemenu->Append(ID_QUIT, _T("E&xit"));
84 m_pMenuBar->Append(filemenu,_T("&File"));
2193517f
VS
85
86 m_pFrame->SetMenuBar(m_pMenuBar);
87}
88
89
90
91// MainFrame.cpp: implementation of the wxMainFrame class.
92//
93//////////////////////////////////////////////////////////////////////
94
95BEGIN_EVENT_TABLE(wxMainFrame, wxFrame)
96 EVT_MENU(ID_QUIT,wxMainFrame::OnQuit)
97 EVT_MENU(ID_RC2WXR,wxMainFrame::OnRc2Wxr)
98 EVT_MENU(ID_WXR2XML,wxMainFrame::OnWXR2XML)
99 EVT_MENU(ID_RC2XML,wxMainFrame::OnRC2XML)
100END_EVENT_TABLE()
101
102
103
104//////////////////////////////////////////////////////////////////////
105// Construction/Destruction
106//////////////////////////////////////////////////////////////////////
107
7c9955d1 108wxMainFrame::wxMainFrame(wxWindow* parent,wxWindowID id,
2193517f
VS
109const wxString& title, const wxPoint& pos, const wxSize& size,
110long style, const wxString& name)
111:wxFrame(parent,id,title,pos,size,style,name)
112{
7c9955d1 113
2193517f
VS
114}
115
116wxMainFrame::~wxMainFrame()
117{
118}
119
120
121
19d0f58d 122void wxMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
2193517f 123{
f80ea77b 124 Close(true);
2193517f
VS
125}
126
127
19d0f58d 128void wxMainFrame::OnRc2Wxr(wxCommandEvent& WXUNUSED(event))
2193517f
VS
129{
130 wxFileDialog filed(this);
19d0f58d 131 filed.SetWildcard(_T("*.rc"));
2193517f
VS
132 filed.SetStyle(wxOPEN);
133
134 if (filed.ShowModal()!=wxID_OK)
135 return;
136
19d0f58d
JS
137 wxFileDialog wxrfile(this,_T("Enter Desired WXR file name"));
138 wxrfile.SetWildcard(_T("*.wxr"));
2193517f 139 wxrfile.SetStyle(wxOPEN);
19d0f58d 140 wxrfile.SetFilename(_T("resource.wxr"));
2193517f
VS
141
142 if (wxrfile.ShowModal()!=wxID_OK)
143 return;
144
145 rc2wxr convert;
146 convert.Convert(wxrfile.GetPath(),filed.GetPath());
147}
148
19d0f58d 149void wxMainFrame::OnWXR2XML(wxCommandEvent& WXUNUSED(event))
2193517f
VS
150{
151 wxFileDialog f(this);
19d0f58d 152 f.SetWildcard(_T("*.wxr"));
2193517f
VS
153 if (f.ShowModal()!=wxID_OK)
154 return;
155
156
19d0f58d
JS
157 wxFileDialog xmlfile(this,_T("Enter Desired XML file name"));
158 xmlfile.SetWildcard(_T("*.xml"));
2193517f 159 xmlfile.SetStyle(wxOPEN);
19d0f58d 160 xmlfile.SetFilename(_T("resource.xml"));
2193517f
VS
161
162 if (xmlfile.ShowModal()!=wxID_OK)
163 return;
164
165 wxr2xml XMLCon;
166 XMLCon.Convert(f.GetPath(),xmlfile.GetPath());
7c9955d1 167
2193517f
VS
168}
169
19d0f58d 170void wxMainFrame::OnRC2XML(wxCommandEvent& WXUNUSED(event))
2193517f
VS
171{
172 wxFileDialog f(this);
19d0f58d 173 f.SetWildcard(_T("*.rc"));
2193517f
VS
174 if (f.ShowModal()!=wxID_OK)
175 return;
176
19d0f58d
JS
177 wxFileDialog xmlfile(this,_T("Enter Desired XML file name"));
178 xmlfile.SetWildcard(_T("*.xml"));
2193517f 179 xmlfile.SetStyle(wxOPEN);
19d0f58d 180 xmlfile.SetFilename(_T("resource.xml"));
2193517f
VS
181
182 if (xmlfile.ShowModal()!=wxID_OK)
183 return;
184
185 rc2xml XMLCon;
186 XMLCon.Convert(f.GetPath(),xmlfile.GetPath());
187
188}
189
190bool wxConvertApp::HandleCommandLine()
191{
192
7c9955d1 193 if (argc != 2)
f80ea77b 194 return false;
2193517f
VS
195
196//Figure out kind of conversion
197 wxString source,target;
7c9955d1 198
2193517f
VS
199 wxr2xml trans_wxr2xml;
200 rc2xml trans_rc2xml;
201 rc2wxr trans_rc2wxr;
202
203 source=argv[1];
204 target=argv[2];
7c9955d1 205
2193517f 206
19d0f58d 207 if ((source.Find(_T(".wxr"))>0)&&(target.Find(_T(".xml"))>0))
2193517f
VS
208 {
209 trans_wxr2xml.Convert(source,target);
f80ea77b 210 return true;
2193517f 211 }
f80ea77b 212 else if ((source.Find(_T(".rc"))!=wxNOT_FOUND)&(target.Find(_T(".wxr"))!=wxNOT_FOUND))
2193517f
VS
213 {
214 trans_rc2wxr.Convert(source,target);
f80ea77b 215 return true;
2193517f 216 }
f80ea77b 217 else if ((source.Find(_T(".rc"))!=wxNOT_FOUND)&(target.Find(_T(".xml"))!=wxNOT_FOUND))
2193517f
VS
218 {
219 trans_rc2xml.Convert(source,target);
f80ea77b 220 return true;
2193517f 221 }
7c9955d1 222
f80ea77b 223 return false;
2193517f 224}