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