summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-08-10 18:07:02 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2017-08-10 18:07:02 -0300
commite5f19af9a5829a307951785e850e53fc4fcfac90 (patch)
tree5292932b350eac34b400c81cd4a68d2356fd835c
parent8a1ffbc01135a1466ad7400518e4c56a4bdc3af5 (diff)
downloadPSP.git-e5f19af9a5829a307951785e850e53fc4fcfac90.tar.gz
PSP.git-e5f19af9a5829a307951785e850e53fc4fcfac90.tar.xz
PSP.git-e5f19af9a5829a307951785e850e53fc4fcfac90.zip
Model 1 machine fixed, init file under implementation
-rw-r--r--Project/Electromechanical.cpp2
-rw-r--r--Project/MainFrame.cpp9
-rw-r--r--Project/MainFrame.h6
-rw-r--r--Project/Project.mk2
-rw-r--r--Project/PropertiesForm.cpp38
-rw-r--r--Project/PropertiesForm.h14
-rw-r--r--Project/PropertiesForm.wxcp471
-rw-r--r--Project/main.cpp69
8 files changed, 598 insertions, 13 deletions
diff --git a/Project/Electromechanical.cpp b/Project/Electromechanical.cpp
index e26a21d..446ade2 100644
--- a/Project/Electromechanical.cpp
+++ b/Project/Electromechanical.cpp
@@ -470,7 +470,7 @@ bool Electromechanical::InitializeDynamicElements()
xq = data.transXd * k;
xd = xq;
}
- if(data.syncXq == 0.0) xq = data.syncXd * k;
+ else if(data.syncXq == 0.0) xq = data.syncXd * k;
// Initialize state variables
std::complex<double> eq0 = data.terminalVoltage + std::complex<double>(ra, xq) * ia;
diff --git a/Project/MainFrame.cpp b/Project/MainFrame.cpp
index 90447ab..89d550a 100644
--- a/Project/MainFrame.cpp
+++ b/Project/MainFrame.cpp
@@ -13,14 +13,18 @@
#include "FileHanding.h"
#include "GeneralPropertiesForm.h"
#include "SimulationsSettingsForm.h"
+#include "PropertiesData.h"
MainFrame::MainFrame() : MainFrameBase(NULL) {}
-MainFrame::MainFrame(wxWindow* parent, wxLocale* locale) : MainFrameBase(parent)
+
+MainFrame::MainFrame(wxWindow* parent, wxLocale* locale, PropertiesData* initProperties) : MainFrameBase(parent)
{
m_locale = locale;
+ m_generalProperties = initProperties;
Init();
}
+
MainFrame::~MainFrame()
{
// if(m_artMetro) delete m_artMetro;
@@ -29,7 +33,10 @@ MainFrame::~MainFrame()
NULL, this);
delete m_addElementsMenu;
}
+ if(m_locale) delete m_locale;
+ if(m_generalProperties) delete m_generalProperties;
}
+
void MainFrame::Init()
{
this->SetSize(800, 600);
diff --git a/Project/MainFrame.h b/Project/MainFrame.h
index af1ee3e..d7ff171 100644
--- a/Project/MainFrame.h
+++ b/Project/MainFrame.h
@@ -13,6 +13,7 @@ class Workspace;
class FileHanding;
class GeneralPropertiesForm;
class SimulationsSettingsForm;
+class PropertiesData;
enum {
ID_ADDMENU_BUS = 20000,
@@ -30,7 +31,7 @@ class MainFrame : public MainFrameBase
{
public:
MainFrame();
- MainFrame(wxWindow* parent, wxLocale* locale);
+ MainFrame(wxWindow* parent, wxLocale* locale, PropertiesData* initProperties);
~MainFrame();
protected:
@@ -69,13 +70,14 @@ class MainFrame : public MainFrameBase
virtual void OnUndoClick(wxRibbonButtonBarEvent& event);
virtual void OnNewClick(wxRibbonButtonBarEvent& event);
- private:
+ protected:
std::vector<Workspace*> m_workspaceList;
int m_projectNumber = 1;
wxRibbonMetroArtProvider* m_artMetro = NULL;
wxMenu* m_addElementsMenu = NULL;
wxLocale* m_locale = NULL;
+ PropertiesData* m_generalProperties = NULL;
void Init();
void EnableCurrentProjectRibbon(bool enable = true);
diff --git a/Project/Project.mk b/Project/Project.mk
index 7d06d84..1d3d670 100644
--- a/Project/Project.mk
+++ b/Project/Project.mk
@@ -13,7 +13,7 @@ CurrentFileName :=
CurrentFilePath :=
CurrentFileFullPath :=
User :=NDSE-69
-Date :=09/08/2017
+Date :=10/08/2017
CodeLitePath :="C:/Program Files/CodeLite"
LinkerName :=C:/TDM-GCC-64/bin/g++.exe
SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC
diff --git a/Project/PropertiesForm.cpp b/Project/PropertiesForm.cpp
index 5841f09..8c3fac0 100644
--- a/Project/PropertiesForm.cpp
+++ b/Project/PropertiesForm.cpp
@@ -31,6 +31,44 @@ GeneralPropertiesFormBase::GeneralPropertiesFormBase(wxWindow* parent, wxWindowI
boxSizer_lvl1_1->Add(m_notebook, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5));
+ m_panelGeneral = new wxPanel(m_notebook, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(m_notebook, wxSize(-1,-1)), wxTAB_TRAVERSAL);
+ m_notebook->AddPage(m_panelGeneral, _("General"), false);
+
+ wxBoxSizer* boxSizerLvl2_1 = new wxBoxSizer(wxVERTICAL);
+ m_panelGeneral->SetSizer(boxSizerLvl2_1);
+
+ wxBoxSizer* boxSizerLvl3_1 = new wxBoxSizer(wxVERTICAL);
+
+ boxSizerLvl2_1->Add(boxSizerLvl3_1, 0, wxEXPAND, WXC_FROM_DIP(5));
+
+ m_staticTextLanguage = new wxStaticText(m_panelGeneral, wxID_ANY, _("Language"), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0);
+
+ boxSizerLvl3_1->Add(m_staticTextLanguage, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));
+
+ wxArrayString m_choiceLanguageArr;
+ m_choiceLanguageArr.Add(wxT("English"));
+ m_choiceLanguageArr.Add(wxT("Portuguese"));
+ m_choiceLanguage = new wxChoice(m_panelGeneral, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), m_choiceLanguageArr, 0);
+ m_choiceLanguage->SetSelection(0);
+
+ boxSizerLvl3_1->Add(m_choiceLanguage, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, WXC_FROM_DIP(5));
+
+ wxBoxSizer* boxSizerLvl3_2 = new wxBoxSizer(wxVERTICAL);
+
+ boxSizerLvl2_1->Add(boxSizerLvl3_2, 0, wxEXPAND, WXC_FROM_DIP(5));
+
+ m_staticTextTheme = new wxStaticText(m_panelGeneral, wxID_ANY, _("Theme"), wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), 0);
+
+ boxSizerLvl3_2->Add(m_staticTextTheme, 0, wxLEFT|wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));
+
+ wxArrayString m_choiceThemeArr;
+ m_choiceThemeArr.Add(wxT("Light"));
+ m_choiceThemeArr.Add(wxT("Dark"));
+ m_choiceTheme = new wxChoice(m_panelGeneral, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(m_panelGeneral, wxSize(-1,-1)), m_choiceThemeArr, 0);
+ m_choiceTheme->SetSelection(0);
+
+ boxSizerLvl3_2->Add(m_choiceTheme, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, WXC_FROM_DIP(5));
+
wxBoxSizer* boxSizer_bottonButtons = new wxBoxSizer(wxHORIZONTAL);
boxSizer_lvl1_1->Add(boxSizer_bottonButtons, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5));
diff --git a/Project/PropertiesForm.h b/Project/PropertiesForm.h
index 0998602..cc4b7e6 100644
--- a/Project/PropertiesForm.h
+++ b/Project/PropertiesForm.h
@@ -15,13 +15,13 @@
#include <wx/artprov.h>
#include <wx/sizer.h>
#include <wx/notebook.h>
-#include <wx/button.h>
#include <wx/panel.h>
#include <wx/imaglist.h>
#include <wx/stattext.h>
-#include <wx/textctrl.h>
#include <wx/choice.h>
#include <wx/arrstr.h>
+#include <wx/button.h>
+#include <wx/textctrl.h>
#include <wx/statbox.h>
#include <wx/checkbox.h>
#if wxVERSION_NUMBER >= 2900
@@ -45,6 +45,11 @@ class GeneralPropertiesFormBase : public wxDialog
{
protected:
wxNotebook* m_notebook;
+ wxPanel* m_panelGeneral;
+ wxStaticText* m_staticTextLanguage;
+ wxChoice* m_choiceLanguage;
+ wxStaticText* m_staticTextTheme;
+ wxChoice* m_choiceTheme;
wxButton* m_buttonOK;
wxButton* m_buttonCancel;
@@ -53,6 +58,11 @@ protected:
virtual void OnButtonCancelClick(wxCommandEvent& event) { event.Skip(); }
public:
+ wxStaticText* GetStaticTextLanguage() { return m_staticTextLanguage; }
+ wxChoice* GetChoiceLanguage() { return m_choiceLanguage; }
+ wxStaticText* GetStaticTextTheme() { return m_staticTextTheme; }
+ wxChoice* GetChoiceTheme() { return m_choiceTheme; }
+ wxPanel* GetPanelGeneral() { return m_panelGeneral; }
wxNotebook* GetNotebook() { return m_notebook; }
wxButton* GetButtonOK() { return m_buttonOK; }
wxButton* GetButtonCancel() { return m_buttonCancel; }
diff --git a/Project/PropertiesForm.wxcp b/Project/PropertiesForm.wxcp
index 8905eb2..a63c219 100644
--- a/Project/PropertiesForm.wxcp
+++ b/Project/PropertiesForm.wxcp
@@ -1,7 +1,7 @@
{
"metadata": {
"m_generatedFilesDir": ".",
- "m_objCounter": 182,
+ "m_objCounter": 200,
"m_includeFiles": [],
"m_bitmapFunction": "wxCDAD0InitBitmapResources",
"m_bitmapsFile": "PropertiesFormBitmaps.cpp",
@@ -217,7 +217,474 @@
"m_value": ""
}],
"m_events": [],
- "m_children": []
+ "m_children": [{
+ "m_type": 4441,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": ["wxTAB_TRAVERSAL"],
+ "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM"],
+ "m_properties": [{
+ "type": "winid",
+ "m_label": "ID:",
+ "m_winid": "wxID_ANY"
+ }, {
+ "type": "string",
+ "m_label": "Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_panelGeneral"
+ }, {
+ "type": "multi-string",
+ "m_label": "Tooltip:",
+ "m_value": ""
+ }, {
+ "type": "colour",
+ "m_label": "Bg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "colour",
+ "m_label": "Fg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "font",
+ "m_label": "Font:",
+ "m_value": ""
+ }, {
+ "type": "bool",
+ "m_label": "Hidden",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Disabled",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Focused",
+ "m_value": false
+ }, {
+ "type": "string",
+ "m_label": "Class Name:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Include File:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Label:",
+ "m_value": "General"
+ }, {
+ "type": "bitmapPicker",
+ "m_label": "Bitmap File:",
+ "m_path": ""
+ }, {
+ "type": "bool",
+ "m_label": "Selected",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Null Page",
+ "m_value": false
+ }],
+ "m_events": [],
+ "m_children": [{
+ "m_type": 4401,
+ "proportion": 1,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"],
+ "m_properties": [{
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "boxSizerLvl2_1"
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "choice",
+ "m_label": "Orientation:",
+ "m_selection": 0,
+ "m_options": ["wxVERTICAL", "wxHORIZONTAL"]
+ }],
+ "m_events": [],
+ "m_children": [{
+ "m_type": 4401,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxEXPAND"],
+ "m_properties": [{
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "boxSizerLvl3_1"
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "choice",
+ "m_label": "Orientation:",
+ "m_selection": 0,
+ "m_options": ["wxVERTICAL", "wxHORIZONTAL"]
+ }],
+ "m_events": [],
+ "m_children": [{
+ "m_type": 4405,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxALIGN_CENTER_VERTICAL"],
+ "m_properties": [{
+ "type": "winid",
+ "m_label": "ID:",
+ "m_winid": "wxID_ANY"
+ }, {
+ "type": "string",
+ "m_label": "Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_staticTextLanguage"
+ }, {
+ "type": "multi-string",
+ "m_label": "Tooltip:",
+ "m_value": ""
+ }, {
+ "type": "colour",
+ "m_label": "Bg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "colour",
+ "m_label": "Fg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "font",
+ "m_label": "Font:",
+ "m_value": ""
+ }, {
+ "type": "bool",
+ "m_label": "Hidden",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Disabled",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Focused",
+ "m_value": false
+ }, {
+ "type": "string",
+ "m_label": "Class Name:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Include File:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "multi-string",
+ "m_label": "Label:",
+ "m_value": "Language"
+ }, {
+ "type": "string",
+ "m_label": "Wrap:",
+ "m_value": "-1"
+ }],
+ "m_events": [],
+ "m_children": []
+ }, {
+ "m_type": 4411,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxBOTTOM", "wxEXPAND"],
+ "m_properties": [{
+ "type": "winid",
+ "m_label": "ID:",
+ "m_winid": "wxID_ANY"
+ }, {
+ "type": "string",
+ "m_label": "Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_choiceLanguage"
+ }, {
+ "type": "multi-string",
+ "m_label": "Tooltip:",
+ "m_value": ""
+ }, {
+ "type": "colour",
+ "m_label": "Bg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "colour",
+ "m_label": "Fg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "font",
+ "m_label": "Font:",
+ "m_value": ""
+ }, {
+ "type": "bool",
+ "m_label": "Hidden",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Disabled",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Focused",
+ "m_value": false
+ }, {
+ "type": "string",
+ "m_label": "Class Name:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Include File:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "multi-string",
+ "m_label": "Choices:",
+ "m_value": "English;Portuguese"
+ }, {
+ "type": "string",
+ "m_label": "Selection:",
+ "m_value": "0"
+ }],
+ "m_events": [],
+ "m_children": []
+ }]
+ }, {
+ "m_type": 4401,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxEXPAND"],
+ "m_properties": [{
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "boxSizerLvl3_2"
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "choice",
+ "m_label": "Orientation:",
+ "m_selection": 0,
+ "m_options": ["wxVERTICAL", "wxHORIZONTAL"]
+ }],
+ "m_events": [],
+ "m_children": [{
+ "m_type": 4405,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxTOP", "wxALIGN_CENTER_VERTICAL"],
+ "m_properties": [{
+ "type": "winid",
+ "m_label": "ID:",
+ "m_winid": "wxID_ANY"
+ }, {
+ "type": "string",
+ "m_label": "Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_staticTextTheme"
+ }, {
+ "type": "multi-string",
+ "m_label": "Tooltip:",
+ "m_value": ""
+ }, {
+ "type": "colour",
+ "m_label": "Bg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "colour",
+ "m_label": "Fg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "font",
+ "m_label": "Font:",
+ "m_value": ""
+ }, {
+ "type": "bool",
+ "m_label": "Hidden",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Disabled",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Focused",
+ "m_value": false
+ }, {
+ "type": "string",
+ "m_label": "Class Name:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Include File:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "multi-string",
+ "m_label": "Label:",
+ "m_value": "Theme"
+ }, {
+ "type": "string",
+ "m_label": "Wrap:",
+ "m_value": "-1"
+ }],
+ "m_events": [],
+ "m_children": []
+ }, {
+ "m_type": 4411,
+ "proportion": 0,
+ "border": 5,
+ "gbSpan": "1,1",
+ "gbPosition": "0,0",
+ "m_styles": [],
+ "m_sizerFlags": ["wxLEFT", "wxRIGHT", "wxBOTTOM", "wxEXPAND"],
+ "m_properties": [{
+ "type": "winid",
+ "m_label": "ID:",
+ "m_winid": "wxID_ANY"
+ }, {
+ "type": "string",
+ "m_label": "Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Minimum Size:",
+ "m_value": "-1,-1"
+ }, {
+ "type": "string",
+ "m_label": "Name:",
+ "m_value": "m_choiceTheme"
+ }, {
+ "type": "multi-string",
+ "m_label": "Tooltip:",
+ "m_value": ""
+ }, {
+ "type": "colour",
+ "m_label": "Bg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "colour",
+ "m_label": "Fg Colour:",
+ "colour": "<Default>"
+ }, {
+ "type": "font",
+ "m_label": "Font:",
+ "m_value": ""
+ }, {
+ "type": "bool",
+ "m_label": "Hidden",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Disabled",
+ "m_value": false
+ }, {
+ "type": "bool",
+ "m_label": "Focused",
+ "m_value": false
+ }, {
+ "type": "string",
+ "m_label": "Class Name:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Include File:",
+ "m_value": ""
+ }, {
+ "type": "string",
+ "m_label": "Style:",
+ "m_value": ""
+ }, {
+ "type": "multi-string",
+ "m_label": "Choices:",
+ "m_value": "Light;Dark"
+ }, {
+ "type": "string",
+ "m_label": "Selection:",
+ "m_value": "0"
+ }],
+ "m_events": [],
+ "m_children": []
+ }]
+ }]
+ }]
+ }]
}, {
"m_type": 4401,
"proportion": 0,
diff --git a/Project/main.cpp b/Project/main.cpp
index e24860d..c4c6e40 100644
--- a/Project/main.cpp
+++ b/Project/main.cpp
@@ -2,17 +2,76 @@
#include <wx/event.h>
#include <wx/image.h>
#include <wx/stdpaths.h>
+#include <wx/textfile.h>
#include "MainFrame.h"
+#include "PropertiesData.h"
// Define the MainApp
class MainApp : public wxApp
{
-public:
+ public:
MainApp() {}
virtual ~MainApp() {}
- void LoadCatalogs(wxLocale* locale)
+ void LoadInitFile(PropertiesData* propertiesData)
{
+ wxTextFile file("config.ini");
+ auto data = propertiesData->GetGeneralPropertiesData();
+
+ if(!file.Open()) {
+ // Create default init file.
+ wxString defaultInitFile = "lang=en\ntheme=light\n";
+
+ file.Create();
+ file.AddLine(defaultInitFile);
+ file.Write();
+ file.Close();
+
+ data.language = wxLANGUAGE_ENGLISH;
+ data.theme = THEME_LIGHT;
+ propertiesData->SetGeneralPropertiesData(data);
+ }
+
+ wxString line;
+ for(line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine()) {
+ wxString tag = "";
+ wxString tagValue = "";
+ bool parseValue = false;
+ for(unsigned int i = 0; i < line.Len(); ++i) {
+ if(line[i] == '=') {
+ parseValue = true;
+ } else {
+ if(parseValue)
+ tagValue += line[i];
+ else
+ tag += line[i];
+ }
+ }
+ // Language
+ if(tag == "lang") {
+ if(tagValue == "pt-br" || tagValue == "pt") {
+ data.language = wxLANGUAGE_PORTUGUESE_BRAZILIAN;
+ } else if(tagValue == "en" || tagValue == "en-us" || tagValue == "en-uk") {
+ data.language = wxLANGUAGE_ENGLISH;
+ }
+ }
+ if(tag == "theme") {
+ if(tagValue == "light") {
+ data.theme = THEME_LIGHT;
+ } else if(tagValue == "dark") {
+ data.theme = THEME_DARK;
+ }
+ }
+ }
+ file.Close();
+
+ propertiesData->SetGeneralPropertiesData(data);
+ }
+
+ void LoadCatalogs(wxLocale* locale, PropertiesData* propertiesData)
+ {
+ LoadInitFile(propertiesData);
+
// Load computer settings.
locale->Init(locale->GetSystemLanguage(), wxLOCALE_DONT_LOAD_DEFAULT);
@@ -29,10 +88,12 @@ public:
wxImage::AddHandler(new wxPNGHandler);
wxImage::AddHandler(new wxJPEGHandler);
+ PropertiesData* propertiesData = new PropertiesData();
+
wxLocale* locale = new wxLocale();
- LoadCatalogs(locale);
+ LoadCatalogs(locale, propertiesData);
- MainFrame* mainFrame = new MainFrame(NULL, locale);
+ MainFrame* mainFrame = new MainFrame(NULL, locale, propertiesData);
SetTopWindow(mainFrame);
return GetTopWindow()->Show();
}