Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
GeneralPropertiesForm Class Reference

Form to edit the software's general data. More...

#include <GeneralPropertiesForm.h>

Inheritance diagram for GeneralPropertiesForm:
Collaboration diagram for GeneralPropertiesForm:

Public Member Functions

 GeneralPropertiesForm (wxWindow *parent, PropertiesData *properties)
 

Protected Member Functions

virtual void OnButtonCancelClick (wxCommandEvent &event)
 
virtual void OnButtonOKClick (wxCommandEvent &event)
 
virtual bool ValidateData ()
 

Protected Attributes

PropertiesDatam_properties = nullptr
 

Detailed Description

Form to edit the software's general data.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
05/10/2017

Definition at line 37 of file GeneralPropertiesForm.h.

Constructor & Destructor Documentation

◆ GeneralPropertiesForm()

GeneralPropertiesForm::GeneralPropertiesForm ( wxWindow *  parent,
PropertiesData properties 
)

Definition at line 24 of file GeneralPropertiesForm.cpp.

25 : GeneralPropertiesFormBase(parent)
26{
27 m_properties = properties;
28 auto data = m_properties->GetGeneralPropertiesData();
29
30 // Clear the choices and rebuild to set the correct translations.
31 m_choiceLanguage->Clear();
32 m_choiceLanguage->Insert(_("English"), 0);
33 m_choiceLanguage->Insert(_("Portuguese"), 1);
34 m_choiceTheme->Clear();
35 m_choiceTheme->Insert(_("Light"), 0);
36 m_choiceTheme->Insert(_("Dark"), 1);
37 //m_choiceRender->Clear();
38 //m_choiceRender->Insert(_("OpenGL"), 0);
39 //m_choiceRender->Insert(_("Device Context"), 0);
40 m_choicePlotLib->Clear();
41 m_choicePlotLib->Insert(_("Chart Director"), 0);
42 m_choicePlotLib->Insert(_("wxMathPlot"), 1);
43
44 switch (data.language) {
45 case wxLANGUAGE_ENGLISH: {
46 m_choiceLanguage->SetSelection(0);
47 } break;
48 case wxLANGUAGE_PORTUGUESE_BRAZILIAN: {
49 m_choiceLanguage->SetSelection(1);
50 } break;
51 default: {
52 m_choiceLanguage->SetSelection(wxNOT_FOUND);
53 } break;
54 }
55 switch (data.plotLib) {
56 case PlotLib::wxCHART_DIR: {
57 m_choicePlotLib->SetSelection(0);
58 } break;
59 case PlotLib::wxMATH_PLOT: {
60 m_choicePlotLib->SetSelection(1);
61 } break;
62 }
63 switch (data.theme) {
64 case THEME_LIGHT: {
65 m_choiceTheme->SetSelection(0);
66 } break;
67 case THEME_DARK: {
68 m_choiceTheme->SetSelection(1);
69 } break;
70 }
71 //if (data.useOpenGL) m_choiceRender->SetSelection(0);
72 //else m_choiceRender->SetSelection(1);
73 m_filePickerATPFolder->SetPath(data.atpPath.GetFullPath());
74
75
76 wxFont currentFont(data.labelFontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, data.labelFont);
77 m_fontPickerText->SetSelectedFont(currentFont);
78}

◆ ~GeneralPropertiesForm()

GeneralPropertiesForm::~GeneralPropertiesForm ( )
virtual

Definition at line 80 of file GeneralPropertiesForm.cpp.

80{}

Member Function Documentation

◆ OnButtonCancelClick()

virtual void GeneralPropertiesForm::OnButtonCancelClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 44 of file GeneralPropertiesForm.h.

44{ EndModal(wxID_CANCEL); }

◆ OnButtonOKClick()

void GeneralPropertiesForm::OnButtonOKClick ( wxCommandEvent &  event)
protectedvirtual

Definition at line 81 of file GeneralPropertiesForm.cpp.

82{
83 if (ValidateData()) EndModal(wxID_OK);
84}

◆ ValidateData()

bool GeneralPropertiesForm::ValidateData ( )
protectedvirtual

Definition at line 86 of file GeneralPropertiesForm.cpp.

87{
88 auto data = m_properties->GetGeneralPropertiesData();
89 auto checkData = m_properties->GetGeneralPropertiesData();
90 bool needRestart = false;
91 data.atpPath = wxFileName(m_filePickerATPFolder->GetPath());
92 wxFont slectedFont = m_fontPickerText->GetSelectedFont();
93 data.labelFont = slectedFont.GetFaceName();
94 data.labelFontSize = slectedFont.GetPointSize();
95
96 //wxTextFile file("config.ini");
97 wxFileName fn(wxStandardPaths::Get().GetDocumentsDir() + wxFileName::GetPathSeparator() + "PSP-UFU" + wxFileName::GetPathSeparator() + "config.ini");
98 wxTextFile file(fn.GetFullPath());
99 if (!file.Create()) {
100 if (!file.Open()) {
101 // Fail to access the file.
102 wxMessageDialog msgDialog(this,
103 _("It was not possible to access the init file.\nThe settings won't be applied."),
104 _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
105 msgDialog.ShowModal();
106 }
107 file.Clear();
108 }
109
110 wxString line = "lang=";
111 switch (m_choiceLanguage->GetSelection()) {
112 case 0: {
113 line += "en";
114 data.language = wxLANGUAGE_ENGLISH;
115 } break;
116 case 1: {
117 line += "pt-br";
118 data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
119 } break;
120 }
121 file.AddLine(line);
122 if (data.language != checkData.language) needRestart = true;
123
124 line = "plotlib=";
125 switch (m_choicePlotLib->GetSelection()) {
126 case 0: {
127 line += "chartdir";
128 data.plotLib = PlotLib::wxCHART_DIR;
129 } break;
130 case 1: {
131 line += "mathplot";
132 data.plotLib = PlotLib::wxMATH_PLOT;
133 } break;
134 }
135 file.AddLine(line);
136 //if (data.plotLib != checkData.plotLib) hasChanges = true;
137
138 line = "theme=";
139 switch (m_choiceTheme->GetSelection()) {
140 case 0: {
141 line += "light";
142 data.theme = THEME_LIGHT;
143 } break;
144 case 1: {
145 line += "dark";
146 data.theme = THEME_DARK;
147 } break;
148 }
149 file.AddLine(line);
150 if (data.theme != checkData.theme) needRestart = true;
151
152 //line = "useOpenGL=";
153 //switch (m_choiceRender->GetSelection()) {
154 //case 0: {
155 // line += "yes";
156 // data.useOpenGL = true;
157 //} break;
158 //case 1: {
159 // line += "no";
160 // data.useOpenGL = false;
161 //} break;
162 //}
163 //file.AddLine(line);
164 //if (data.useOpenGL != checkData.useOpenGL) hasChanges = true;
165
166 line = "labelfont=";
167 line += data.labelFont;
168 file.AddLine(line);
169
170 line = "labelfontsize=";
171 line += wxString::Format("%d", data.labelFontSize);
172 file.AddLine(line);
173
174
175 line = "atpfile=";
176 line += data.atpPath.GetFullPath();
177 file.AddLine(line);
178
179 file.Write();
180 file.Close();
181
182 if (needRestart) {
183 wxMessageDialog msgDialog(this, _("The application must be restarted to settings changes be applied."),
184 _("Info"), wxOK | wxCENTRE | wxICON_INFORMATION);
185 msgDialog.ShowModal();
186 }
187 m_properties->SetGeneralPropertiesData(data);
188 return true;
189}

Member Data Documentation

◆ m_properties

PropertiesData* GeneralPropertiesForm::m_properties = nullptr
protected

Definition at line 48 of file GeneralPropertiesForm.h.


The documentation for this class was generated from the following files: