78 wxSizerFlags::DisableConsistencyChecks();
82 wxFileName fn(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() +
"PSP-UFU" + wxFileName::GetPathSeparator() +
"config.ini");
83 if (!fn.DirExists()) {
87 wxTextFile file(fn.GetFullPath());
88 auto data = propertiesData->GetGeneralPropertiesData();
91 if (!file.Open())
return false;
94 for (line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine()) {
96 wxString tagValue =
"";
97 bool parseValue =
false;
98 for (
unsigned int i = 0; i < line.Len(); ++i) {
111 if (tagValue ==
"pt-br" || tagValue ==
"pt") {
112 data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
114 else if (tagValue ==
"en" || tagValue ==
"en-us" || tagValue ==
"en-uk") {
115 data.language = wxLANGUAGE_ENGLISH;
118 if (tag ==
"theme") {
119 if (tagValue ==
"light") {
120 data.theme = THEME_LIGHT;
122 else if (tagValue ==
"dark") {
123 data.theme = THEME_DARK;
126 if (tag ==
"plotlib") {
127 if (tagValue ==
"chartdir") {
128 data.plotLib = PlotLib::wxCHART_DIR;
130 else if (tagValue ==
"mathplot") {
131 data.plotLib = PlotLib::wxMATH_PLOT;
142 if (tag ==
"labelfont") {
143 data.labelFont = tagValue;
145 if (tag ==
"labelfontsize") {
147 tagValue.ToLong(&size);
148 data.labelFontSize =
static_cast<int>(size);
150 if (tag ==
"atpfile") {
151 data.atpPath = wxFileName(tagValue);
157 if (!file.Open())
return false;
160 file.AddLine(
"lang=en");
161 file.AddLine(
"plotlib=chartdir");
162 file.AddLine(
"theme=light");
163 file.AddLine(
"labelfont=Arial");
164 file.AddLine(
"labelfontsize=10");
165 file.AddLine(
"atpfile=");
171 data.language = wxLANGUAGE_ENGLISH;
172 data.theme = THEME_LIGHT;
173 data.plotLib = PlotLib::wxCHART_DIR;
175 propertiesData->SetGeneralPropertiesData(data);
179 wxString atpFolder = wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() +
"PSP-UFU" + wxFileName::GetPathSeparator() +
"atp";
180 if (!wxDir::Exists(atpFolder)) wxDir::Make(atpFolder);
181 data.atpWorkFolder = atpFolder;
183 propertiesData->SetGeneralPropertiesData(data);
187 void LoadCatalogs(wxLocale* locale,
PropertiesData* propertiesData)
190 if (!locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT)) {
191 wxMessageDialog msgDialog(
nullptr, _(
"This language is not supported by the system."), _(
"Error"),
192 wxOK | wxCENTRE | wxICON_ERROR);
193 msgDialog.ShowModal();
196 wxFileName fn(wxStandardPaths::Get().GetExecutablePath());
197 wxString langPath = fn.GetPath() + wxFileName::DirName(
"\\..\\data\\lang", wxPATH_WIN).GetPath();
198 locale->AddCatalogLookupPathPrefix(langPath);
200 if (propertiesData->GetGeneralPropertiesData().language == wxLANGUAGE_PORTUGUESE_BRAZILIAN) {
201 if (!locale->AddCatalog(wxT(
"pt_BR"))) {
202 wxMessageDialog msgDialog(
nullptr, _(
"Fail to load brazilian portuguese language catalog."), _(
"Error"),
203 wxOK | wxCENTRE | wxICON_ERROR);
204 msgDialog.ShowModal();
209 virtual bool OnInit()
212 wxImage::AddHandler(
new wxPNGHandler);
213 wxImage::AddHandler(
new wxJPEGHandler);
217 wxFileName fn(wxStandardPaths::Get().GetExecutablePath());
218 wxString fontsPath = fn.GetPath() + wxFileName::DirName(
"\\..\\data\\fonts", wxPATH_WIN).GetPath();
219 bool loadFont = wxFont::AddPrivateFont(fontsPath + wxFileName::GetPathSeparator() +
"cmunrm.ttf");
220 if (loadFont) loadFont = wxFont::AddPrivateFont(fontsPath + wxFileName::GetPathSeparator() +
"cmunbx.ttf");
222 wxMessageDialog msgDialog(
nullptr, _(
"Fail to load local font."), _(
"Error"),
223 wxOK | wxCENTRE | wxICON_ERROR);
224 msgDialog.ShowModal();
229 LoadInitFile(propertiesData);
231 wxLocale* locale =
new wxLocale();
232 LoadCatalogs(locale, propertiesData);
234 wxString openFilePath =
"";
237 wxCmdLineParser cmdLineParser(wxApp::argc, wxApp::argv);
239 cmdLineParser.AddParam(
"", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
240 cmdLineParser.AddSwitch(
"t",
"test",
"Run PSP-UFU tests");
243 if (cmdLineParser.Parse() == 0) {
244 wxCmdLineArgs args = cmdLineParser.GetArguments();
245 for (
auto it = args.begin(), itEnd = args.end(); it != itEnd; ++it) {
246 if (it->GetKind() == wxCMD_LINE_PARAM) { openFilePath = it->GetStrVal(); }
247 else if (it->GetShortName() ==
"t") {
255 mainFrame->SetIcon(wxICON(aaaaprogicon));
257 SetTopWindow(mainFrame);
259 GetTopWindow()->Show();
260 exit(mainFrame->RunPSPTest());
262 return GetTopWindow()->Show();
Main frame of the program. This class manage the ribbon menu and the notebook behavior.