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;
160 wxString plotLibProp =
"plotlib=chartdir";
162 plotLibProp =
"plotlib=mathplot";
166 file.AddLine(
"lang=en");
167 file.AddLine(plotLibProp);
168 file.AddLine(
"theme=light");
169 file.AddLine(
"labelfont=Arial");
170 file.AddLine(
"labelfontsize=10");
171 file.AddLine(
"atpfile=");
177 data.language = wxLANGUAGE_ENGLISH;
178 data.theme = THEME_LIGHT;
179 data.plotLib = PlotLib::wxCHART_DIR;
181 data.plotLib = PlotLib::wxMATH_PLOT;
184 propertiesData->SetGeneralPropertiesData(data);
188 wxString atpFolder = Paths::GetDocumentsPath() +
"/PSP-UFU/atp";
189 if (!wxDir::Exists(atpFolder)) wxDir::Make(atpFolder);
190 data.atpWorkFolder = atpFolder;
192 propertiesData->SetGeneralPropertiesData(data);
196 void LoadCatalogs(wxLocale* locale,
PropertiesData* propertiesData)
199 if (!locale->Init(propertiesData->GetGeneralPropertiesData().language, wxLOCALE_DONT_LOAD_DEFAULT)) {
200 wxMessageDialog msgDialog(
nullptr, _(
"This language is not supported by the system."), _(
"Error"),
201 wxOK | wxCENTRE | wxICON_ERROR);
202 msgDialog.ShowModal();
206 wxString langPath = Paths::GetDataPath() +
"/lang";
207 locale->AddCatalogLookupPathPrefix(langPath);
209 if (propertiesData->GetGeneralPropertiesData().language == wxLANGUAGE_PORTUGUESE_BRAZILIAN) {
210 if (!locale->AddCatalog(wxT(
"pt_BR"))) {
211 wxMessageDialog msgDialog(
nullptr, _(
"Fail to load brazilian portuguese language catalog."), _(
"Error"),
212 wxOK | wxCENTRE | wxICON_ERROR);
213 msgDialog.ShowModal();
218 virtual bool OnInit()
221 wxImage::AddHandler(
new wxPNGHandler);
222 wxImage::AddHandler(
new wxJPEGHandler);
227 wxString fontsPath = Paths::GetDataPath() +
"/fonts";
228 bool loadFont = wxFont::AddPrivateFont(fontsPath +
"/cmunrm.ttf");
229 if (loadFont) loadFont = wxFont::AddPrivateFont(fontsPath +
"/cmunbx.ttf");
231 wxMessageDialog msgDialog(
nullptr, _(
"Failed to load local font."), _(
"Error"),
232 wxOK | wxCENTRE | wxICON_ERROR);
233 msgDialog.ShowModal();
239 LoadInitFile(propertiesData);
241 if (propertiesData->GetGeneralPropertiesData().theme == THEME_LIGHT)
242 SetAppearance(Appearance::Light);
243 else if (propertiesData->GetGeneralPropertiesData().theme == THEME_DARK)
244 SetAppearance(Appearance::Dark);
246 SetAppearance(Appearance::System);
248 wxLocale* locale =
new wxLocale();
249 LoadCatalogs(locale, propertiesData);
251 wxString openFilePath =
"";
254 wxCmdLineParser cmdLineParser(wxApp::argc, wxApp::argv);
256 cmdLineParser.AddParam(
"", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
257 cmdLineParser.AddSwitch(
"t",
"test",
"Run PSP-UFU tests");
260 if (cmdLineParser.Parse() == 0) {
261 wxCmdLineArgs args = cmdLineParser.GetArguments();
262 for (
auto it = args.begin(), itEnd = args.end(); it != itEnd; ++it) {
263 if (it->GetKind() == wxCMD_LINE_PARAM) { openFilePath = it->GetStrVal(); }
264 else if (it->GetShortName() ==
"t") {
272 mainFrame->SetIcon(wxICON(aaaaprogicon));
274 SetTopWindow(mainFrame);
276 GetTopWindow()->Show();
277 exit(mainFrame->RunPSPTest());
279 return GetTopWindow()->Show();
Main frame of the program. This class manage the ribbon menu and the notebook behavior.