YATiSh
Yet Another TIme SHeet
yatishSettings.cpp
Go to the documentation of this file.
1 #include "wx_pch.h"
2 #include "yatishSettings.h"
3 
8  wxConfigBase * config = wxConfigBase::Get (false);
9  config->SetPath ("/yatish");
10  config->Read ("log2text", &log2text, false);
11  config->Read ("limitRow", &limitRow, false);
12  long tmp;
13  config->Read ("rowLimit", &tmp, 100l);
14  rowLimit = (int) tmp;
15  config->Read ("lib", &tmp, 0l);
16  lib = (ChartLib) tmp;
17  config->Read ("logo4pdf", &logo4pdf, false);
18  config->Read ("companyName_or_logoPath", &companyName_or_logoPath, wxEmptyString);
19  config->Read ("motto4pdf", &motto4pdf, true);
20  config->Read ("companyMotto", &companyMotto, wxEmptyString);
21  config->Read ("pdfCharts", &pdfCharts, true);
22 }
23 
28  wxConfigBase * config = wxConfigBase::Get (false);
29  config->SetPath ("/yatish");
30  config->Write ("log2text", log2text);
31  config->Write ("limitRow", limitRow);
32  config->Write ("rowLimit", (long) rowLimit);
33  config->Write ("lib", (long) lib);
34  config->Write ("logo4pdf", logo4pdf);
35  config->Write ("companyName_or_logoPath", companyName_or_logoPath);
36  config->Write ("motto4pdf", motto4pdf);
37  config->Write ("companyMotto", companyMotto);
38  config->Write ("pdfCharts", pdfCharts);
39 }
40 
41 #ifndef WX_PRECOMP
42  //(*InternalHeadersPCH(yatishSettings)
43  #include <wx/string.h>
44  #include <wx/intl.h>
45  //*)
46 #endif
47 //(*InternalHeaders(yatishSettings)
48 //*)
49 
50 //(*IdInit(yatishSettings)
51 const long yatishSettings::ID_STATICTEXT1 = wxNewId();
52 const long yatishSettings::idCheckBoxLog = wxNewId();
53 const long yatishSettings::ID_STATICTEXT2 = wxNewId();
54 const long yatishSettings::idCheckBoxLimit = wxNewId();
55 const long yatishSettings::ID_STATICTEXT3 = wxNewId();
56 const long yatishSettings::idSpinCtrlLimit = wxNewId();
57 const long yatishSettings::ID_STATICTEXT4 = wxNewId();
58 const long yatishSettings::idChoiceLib = wxNewId();
59 const long yatishSettings::idPanelGUI = wxNewId();
60 const long yatishSettings::idRadioButtonName = wxNewId();
61 const long yatishSettings::idTextCtrlName = wxNewId();
62 const long yatishSettings::idRadioButtonLogo = wxNewId();
63 const long yatishSettings::idButtonLogo = wxNewId();
64 const long yatishSettings::idCheckBoxMotto = wxNewId();
65 const long yatishSettings::idTextCtrlMotto = wxNewId();
66 const long yatishSettings::idCheckBoxPDFcharts = wxNewId();
67 const long yatishSettings::idPanelPDF = wxNewId();
68 const long yatishSettings::idNotebook = wxNewId();
69 //*)
70 
71 BEGIN_EVENT_TABLE (yatishSettings, wxDialog)
72  //(*EventTable(yatishSettings)
73  //*)
74  EVT_UPDATE_UI(idSpinCtrlLimit, yatishSettings::OnSpinCtrlLimitUpdate)
75  EVT_UPDATE_UI(idButtonLogo, yatishSettings::OnButtonLogoUpdate)
76  EVT_UPDATE_UI(idTextCtrlName, yatishSettings::OnTextCtrlNameUpdate)
77  EVT_UPDATE_UI(idTextCtrlMotto, yatishSettings::OnTextCtrlMottoUpdate)
78 END_EVENT_TABLE()
79 
81  //(*Initialize(yatishSettings)
82  wxBoxSizer* BoxSizer1;
83  wxBoxSizer* BoxSizer2;
84  wxBoxSizer* BoxSizer3;
85  wxBoxSizer* BoxSizer4;
86  wxBoxSizer* BoxSizer5;
87  wxBoxSizer* BoxSizer6;
88  wxButton* buttonCancel;
89  wxButton* buttonOK;
90  wxFlexGridSizer* FlexGridSizer1;
91  wxNotebook* notebook;
92  wxPanel* panelGUI;
93  wxPanel* panelPDF;
94  wxStaticBoxSizer* StaticBoxSizer1;
95 
96  Create(0, wxID_ANY, _("Yatish settings"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
97  SetExtraStyle( GetExtraStyle() | wxWS_EX_VALIDATE_RECURSIVELY );
98  BoxSizer1 = new wxBoxSizer(wxVERTICAL);
99  notebook = new wxNotebook(this, idNotebook, wxDefaultPosition, wxDefaultSize, 0, _T("idNotebook"));
100  panelGUI = new wxPanel(notebook, idPanelGUI, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("idPanelGUI"));
101  FlexGridSizer1 = new wxFlexGridSizer(4, 2, 0, 0);
102  StaticText1 = new wxStaticText(panelGUI, ID_STATICTEXT1, _("Logging:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
103  FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
104  checkBoxLog = new wxCheckBox(panelGUI, idCheckBoxLog, _("main frame"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idCheckBoxLog"));
105  checkBoxLog->SetValue(false);
106  FlexGridSizer1->Add(checkBoxLog, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
107  StaticText2 = new wxStaticText(panelGUI, ID_STATICTEXT2, _("Timeslot:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
108  FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
109  checkBoxLimit = new wxCheckBox(panelGUI, idCheckBoxLimit, _("limit list"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idCheckBoxLimit"));
110  checkBoxLimit->SetValue(false);
111  FlexGridSizer1->Add(checkBoxLimit, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
112  StaticText3 = new wxStaticText(panelGUI, ID_STATICTEXT3, _("Row limit:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
113  FlexGridSizer1->Add(StaticText3, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
114  spinCtrlLimit = new wxSpinCtrl(panelGUI, idSpinCtrlLimit, _T("100"), wxDefaultPosition, wxSize(125,-1), 0, 10, 1000, 100, _T("idSpinCtrlLimit"));
115  spinCtrlLimit->SetValue(_T("100"));
116  FlexGridSizer1->Add(spinCtrlLimit, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
117  StaticText4 = new wxStaticText(panelGUI, ID_STATICTEXT4, _("Charts:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
118  FlexGridSizer1->Add(StaticText4, 1, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
119  choiceLib = new wxChoice(panelGUI, idChoiceLib, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("idChoiceLib"));
120  choiceLib->SetSelection( choiceLib->Append(_("wxMathPlot")) );
121  choiceLib->Append(_("wxFreeChart"));
122  choiceLib->Append(_("wxCharts"));
123  FlexGridSizer1->Add(choiceLib, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
124  panelGUI->SetSizer(FlexGridSizer1);
125  FlexGridSizer1->Fit(panelGUI);
126  FlexGridSizer1->SetSizeHints(panelGUI);
127  panelPDF = new wxPanel(notebook, idPanelPDF, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("idPanelPDF"));
128  BoxSizer3 = new wxBoxSizer(wxVERTICAL);
129  StaticBoxSizer1 = new wxStaticBoxSizer(wxVERTICAL, panelPDF, _("Company"));
130  BoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
131  radioButtonName = new wxRadioButton(panelPDF, idRadioButtonName, _("Name"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP, wxDefaultValidator, _T("idRadioButtonName"));
132  BoxSizer4->Add(radioButtonName, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
133  textCtrlName = new wxTextCtrl(panelPDF, idTextCtrlName, wxEmptyString, wxDefaultPosition, wxSize(120,-1), 0, wxDefaultValidator, _T("idTextCtrlName"));
134  BoxSizer4->Add(textCtrlName, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5);
135  StaticBoxSizer1->Add(BoxSizer4, 1, wxALL|wxEXPAND, 0);
136  BoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
137  radioButtonLogo = new wxRadioButton(panelPDF, idRadioButtonLogo, _("Logo"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idRadioButtonLogo"));
138  BoxSizer5->Add(radioButtonLogo, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
139  BoxSizer5->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
140  buttonLogo = new wxButton(panelPDF, idButtonLogo, _("File..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idButtonLogo"));
141  BoxSizer5->Add(buttonLogo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
142  StaticBoxSizer1->Add(BoxSizer5, 1, wxALL|wxEXPAND, 0);
143  BoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
144  checkBoxMotto = new wxCheckBox(panelPDF, idCheckBoxMotto, _("Motto"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idCheckBoxMotto"));
145  checkBoxMotto->SetValue(false);
146  BoxSizer6->Add(checkBoxMotto, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
147  textCtrlMotto = new wxTextCtrl(panelPDF, idTextCtrlMotto, wxEmptyString, wxDefaultPosition, wxSize(120,-1), 0, wxDefaultValidator, _T("idTextCtrlMotto"));
148  BoxSizer6->Add(textCtrlMotto, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
149  StaticBoxSizer1->Add(BoxSizer6, 1, wxALL|wxEXPAND, 0);
150  BoxSizer3->Add(StaticBoxSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
151  checkBoxPDFcharts = new wxCheckBox(panelPDF, idCheckBoxPDFcharts, _("with charts"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idCheckBoxPDFcharts"));
152  checkBoxPDFcharts->SetValue(false);
153  BoxSizer3->Add(checkBoxPDFcharts, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
154  panelPDF->SetSizer(BoxSizer3);
155  BoxSizer3->Fit(panelPDF);
156  BoxSizer3->SetSizeHints(panelPDF);
157  notebook->AddPage(panelGUI, _("GUI"), false);
158  notebook->AddPage(panelPDF, _("PDF"), false);
159  BoxSizer1->Add(notebook, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
160  BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
161  buttonCancel = new wxButton(this, wxID_CANCEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_CANCEL"));
162  BoxSizer2->Add(buttonCancel, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
163  BoxSizer2->Add(-1,-1,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
164  buttonOK = new wxButton(this, wxID_OK, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_OK"));
165  BoxSizer2->Add(buttonOK, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
166  BoxSizer1->Add(BoxSizer2, 0, wxALL|wxEXPAND, 5);
167  SetSizer(BoxSizer1);
168  BoxSizer1->Fit(this);
169  BoxSizer1->SetSizeHints(this);
170 
171  Connect(idButtonLogo,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&yatishSettings::OnButtonLogoClick);
172  //*)
173  checkBoxLog->SetValidator ( wxGenericValidator (&log2text) );
174  checkBoxLimit->SetValidator ( wxGenericValidator (&limitRow) );
175  spinCtrlLimit->SetValidator ( wxGenericValidator (&rowLimit) );
176  choiceLib->SetValidator ( wxGenericValidator (&lib) );
177  radioButtonLogo->SetValidator ( wxGenericValidator (&logo4pdf) );
178  textCtrlName->SetValidator ( wxTextValidator (wxFILTER_NONE, &companyName_or_logoPath) );
179  checkBoxMotto->SetValidator ( wxGenericValidator (&motto4pdf) );
180  textCtrlMotto->SetValidator ( wxTextValidator (wxFILTER_NONE, &companyMotto) );
181  checkBoxPDFcharts->SetValidator ( wxGenericValidator (&pdfCharts) );
182  Fit(); SetMaxSize ( GetSize() );
183 }
184 
186  //(*Destroy(yatishSettings)
187  //*)
188 }
189 
191  log2text = s.log2text;
192  limitRow = s.limitRow;
193  rowLimit = s.rowLimit;
194  lib = (int) s.lib;
195  logo4pdf = s.logo4pdf;
197  motto4pdf = s.motto4pdf;
199  pdfCharts = s.pdfCharts;
200 }
201 
203  s.log2text = log2text;
204  s.limitRow = limitRow;
205  s.rowLimit = rowLimit;
206  s.lib = (ChartLib) lib;
207  s.logo4pdf = logo4pdf;
209  s.motto4pdf = motto4pdf;
211  s.pdfCharts = pdfCharts;
212 }
213 
214 void yatishSettings::OnSpinCtrlLimitUpdate (wxUpdateUIEvent& event) {
215  event.Enable ( checkBoxLimit->IsChecked() );
216 }
217 void yatishSettings::OnButtonLogoUpdate (wxUpdateUIEvent& event) {
218  event.Enable ( radioButtonLogo->GetValue() );
219 }
220 void yatishSettings::OnTextCtrlNameUpdate (wxUpdateUIEvent& event) {
221  event.Enable ( radioButtonName->GetValue() );
222 }
223 void yatishSettings::OnTextCtrlMottoUpdate (wxUpdateUIEvent& event) {
224  event.Enable ( checkBoxMotto->IsChecked() );
225 }
226 
227 void yatishSettings::OnButtonLogoClick(wxCommandEvent& event) {
228  wxFileDialog logoDlg (this, _("Select the logo file"),
229  wxStandardPaths::Get().GetDocumentsDir(), wxEmptyString,
230  "PNG|*.png|GIF|*.gif|JPEG|*.jpg", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
231  if (logoDlg.ShowModal() == wxID_CANCEL) return;
232  textCtrlName->SetValue ( logoDlg.GetPath() );
233 }
A dialog to modify YATiSh settings.
wxString companyMotto
wxCheckBox * checkBoxMotto
static const long idCheckBoxPDFcharts
wxRadioButton * radioButtonName
static const long ID_STATICTEXT2
static const long idButtonLogo
static const long idChoiceLib
static const long idPanelGUI
static const long idCheckBoxMotto
wxString companyName_or_logoPath
static const long idRadioButtonName
static const long ID_STATICTEXT1
void OnSpinCtrlLimitUpdate(wxUpdateUIEvent &)
void Get(Settings &)
void OnButtonLogoUpdate(wxUpdateUIEvent &)
static const long idCheckBoxLimit
static const long idRadioButtonLogo
static const long idNotebook
static const long ID_STATICTEXT3
static const long idSpinCtrlLimit
static const long idTextCtrlMotto
wxTextCtrl * textCtrlName
wxCheckBox * checkBoxLimit
static const long idPanelPDF
static const long idTextCtrlName
static const long ID_STATICTEXT4
void Set(Settings &)
void OnTextCtrlMottoUpdate(wxUpdateUIEvent &)
static const long idCheckBoxLog
void OnButtonLogoClick(wxCommandEvent &event)
wxRadioButton * radioButtonLogo
void OnTextCtrlNameUpdate(wxUpdateUIEvent &)
As its names implies: the class holding YATiSh settings.
int rowLimit
...to rowLimit lines.
bool pdfCharts
PDF charts?
wxString companyName_or_logoPath
Either the company name or its logo.
bool motto4pdf
Print the company motto in the PDF header?
ChartLib lib
A ChartLib enumerates the graphic libraries available for panel #3.
bool log2text
If True, error/warning messages will be forwarded to the bottom of the main frame.
~Settings()
The Settings destructor saves itself to the configuration file.
bool limitRow
If True, the listing in panel #2 will be limited...
wxString companyMotto
Slogan or short description of the purpose.
bool logo4pdf
If True the company name is replaced by its logo in the PDF header.
Settings()
The Settings constructor retrieves itself from the configuration file.
ChartLib
Same order as yatishSettings::choiceLib.