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