79 wxSizerFlags::DisableConsistencyChecks();
83 wxFileName fn(Paths::GetDocumentsPath() +
"/PSP-UFU/config.ini");
84 if (!fn.DirExists()) {
88 wxTextFile file(fn.GetFullPath());
89 auto data = propertiesData->GetGeneralPropertiesData();
92 if (!file.Open())
return false;
95 for (line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine()) {
97 wxString tagValue =
"";
98 bool parseValue =
false;
99 for (
unsigned int i = 0; i < line.Len(); ++i) {
100 if (line[i] ==
'=') {
112 if (tagValue ==
"pt-br" || tagValue ==
"pt") {
113 data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
115 else if (tagValue ==
"en" || tagValue ==
"en-us" || tagValue ==
"en-uk") {
116 data.language = wxLANGUAGE_ENGLISH;
119 if (tag ==
"theme") {
120 if (tagValue ==
"light") {
121 data.theme = THEME_LIGHT;
123 else if (tagValue ==
"dark") {
124 data.theme = THEME_DARK;
127 if (tag ==
"plotlib") {
128 if (tagValue ==
"chartdir") {
129 data.plotLib = PlotLib::wxCHART_DIR;
131 else if (tagValue ==
"mathplot") {
132 data.plotLib = PlotLib::wxMATH_PLOT;
143 if (tag ==
"labelfont") {
144 data.labelFont = tagValue;
146 if (tag ==
"labelfontsize") {
148 tagValue.ToLong(&size);
149 data.labelFontSize =
static_cast<int>(size);
151 if (tag ==
"atpfile") {
152 data.atpPath = wxFileName(tagValue);
158 if (!file.Open())
return false;
161 file.AddLine(
"lang=en");
162 file.AddLine(
"plotlib=chartdir");
163 file.AddLine(
"theme=light");
164 file.AddLine(
"labelfont=Arial");
165 file.AddLine(
"labelfontsize=10");
166 file.AddLine(
"atpfile=");
172 data.language = wxLANGUAGE_ENGLISH;
173 data.theme = THEME_LIGHT;
174 data.plotLib = PlotLib::wxCHART_DIR;
176 propertiesData->SetGeneralPropertiesData(data);
180 wxString atpFolder = Paths::GetDocumentsPath() +
"/PSP-UFU/atp";
181 if (!wxDir::Exists(atpFolder)) wxDir::Make(atpFolder);
182 data.atpWorkFolder = atpFolder;
184 propertiesData->SetGeneralPropertiesData(data);
188 void LoadCatalogs(wxLocale* locale,
PropertiesData* propertiesData)
191 if (!locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT)) {
192 wxMessageDialog msgDialog(
nullptr, _(
"This language is not supported by the system."), _(
"Error"),
193 wxOK | wxCENTRE | wxICON_ERROR);
194 msgDialog.ShowModal();
198 wxString langPath = Paths::GetDataPath() +
"/lang";
199 locale->AddCatalogLookupPathPrefix(langPath);
201 if (propertiesData->GetGeneralPropertiesData().language == wxLANGUAGE_PORTUGUESE_BRAZILIAN) {
202 if (!locale->AddCatalog(wxT(
"pt_BR"))) {
203 wxMessageDialog msgDialog(
nullptr, _(
"Fail to load brazilian portuguese language catalog."), _(
"Error"),
204 wxOK | wxCENTRE | wxICON_ERROR);
205 msgDialog.ShowModal();
210 virtual bool OnInit()
213 wxImage::AddHandler(
new wxPNGHandler);
214 wxImage::AddHandler(
new wxJPEGHandler);
219 wxString fontsPath = Paths::GetDataPath() +
"/fonts";
220 bool loadFont = wxFont::AddPrivateFont(fontsPath +
"/cmunrm.ttf");
221 if (loadFont) loadFont = wxFont::AddPrivateFont(fontsPath +
"/cmunbx.ttf");
223 wxMessageDialog msgDialog(
nullptr, _(
"Failed to load local font."), _(
"Error"),
224 wxOK | wxCENTRE | wxICON_ERROR);
225 msgDialog.ShowModal();
230 LoadInitFile(propertiesData);
232 wxLocale* locale =
new wxLocale();
233 LoadCatalogs(locale, propertiesData);
235 wxString openFilePath =
"";
238 wxCmdLineParser cmdLineParser(wxApp::argc, wxApp::argv);
240 cmdLineParser.AddParam(
"", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
241 cmdLineParser.AddSwitch(
"t",
"test",
"Run PSP-UFU tests");
244 if (cmdLineParser.Parse() == 0) {
245 wxCmdLineArgs args = cmdLineParser.GetArguments();
246 for (
auto it = args.begin(), itEnd = args.end(); it != itEnd; ++it) {
247 if (it->GetKind() == wxCMD_LINE_PARAM) { openFilePath = it->GetStrVal(); }
248 else if (it->GetShortName() ==
"t") {
256 mainFrame->SetIcon(wxICON(aaaaprogicon));
258 SetTopWindow(mainFrame);
260 GetTopWindow()->Show();
261 exit(mainFrame->RunPSPTest());
263 return GetTopWindow()->Show();
Main frame of the program. This class manage the ribbon menu and the notebook behavior.