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