2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
30 * wxCDMMainHelpDialog.cpp
32 * Created on: 14/2/2013
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMSettingsDialog.h"
38 #include "creaDevManagerIds.h"
39 #include "CDMUtilities.h"
41 #include <wx/config.h>
43 BEGIN_EVENT_TABLE(wxCDMSettingsDialog, wxDialog)
44 EVT_BUTTON(ID_BUTTON_NEXT, wxCDMSettingsDialog::OnFinish)
45 EVT_BUTTON(ID_BUTTON_PREV, wxCDMSettingsDialog::OnDefaults)
46 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMSettingsDialog::OnCancel)
49 wxCDMSettingsDialog::wxCDMSettingsDialog(
52 const wxString& caption,
53 const wxPoint& position,
58 wxCDMSettingsDialog::Create(parent, id, caption, position, size, style);
61 wxCDMSettingsDialog::~wxCDMSettingsDialog()
65 bool wxCDMSettingsDialog::Create(
68 const wxString& caption,
69 const wxPoint& position,
74 wxDialog::Create(parent, id, caption, position, size, style);
76 this->CreateControls();
81 bool wxCDMSettingsDialog::IsHelpEnabled()
83 return this->helpEnabled->GetValue();
86 void wxCDMSettingsDialog::SetHelpEnabled(bool isHelp)
88 this->helpEnabled->SetValue(isHelp);
91 void wxCDMSettingsDialog::CreateControls()
94 wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
97 wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Crea Development Manager Settings"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
98 v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
100 wxStaticText* instruction = new wxStaticText(this, wxID_ANY, wxT("Change the values to modify the default behavior of the program."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
101 v_sizer1->Add(instruction, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 5);
103 wxFlexGridSizer* formItems = new wxFlexGridSizer(5,2,9,15);
105 wxStaticText *stxtTextEditor = new wxStaticText(this, -1, wxT("Text Editor Command"));
106 wxStaticText *stxtFileExplorer = new wxStaticText(this, -1, wxT("File Explorer Command"));
107 wxStaticText *stxtTerminal = new wxStaticText(this, -1, wxT("Terminal Command"));
108 wxStaticText *stxtHelpEnabled = new wxStaticText(this, -1, wxT("Help Enabled"));
110 wxStaticText* stxtBuildCommand = new wxStaticText(this, -1, wxT("Build Command"));
112 wxConfigBase* pConfig = wxConfigBase::Get();
114 this->textEditor = new wxTextCtrl(this, -1, pConfig->Read(wxT("TEXT_EDITOR"), crea::std2wx(CDMUtilities::TEXT_EDITOR)));
115 this->fileExplorer = new wxTextCtrl(this, -1, pConfig->Read(wxT("FILE_EXPLORER"), crea::std2wx(CDMUtilities::FILE_EXPLORER)));
116 this->terminal = new wxTextCtrl(this, -1, pConfig->Read(wxT("TERMINAL"), crea::std2wx(CDMUtilities::TERMINAL)));
117 this->helpEnabled = new wxCheckBox(this, -1, wxT(""));
118 this->helpEnabled->SetValue(pConfig->Read(wxT("HELP"), true) != 0);
120 this->buildCommand = new wxTextCtrl(this, -1, pConfig->Read(wxT("BUILD_COMMAND"), crea::std2wx(CDMUtilities::BUILD_COMMAND)));
123 formItems->Add(stxtTextEditor, 0, wxALIGN_CENTER_VERTICAL);
124 formItems->Add(this->textEditor, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
125 formItems->Add(stxtFileExplorer, 0, wxALIGN_CENTER_VERTICAL);
126 formItems->Add(this->fileExplorer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
127 formItems->Add(stxtTerminal, 0, wxALIGN_CENTER_VERTICAL);
128 formItems->Add(this->terminal, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
130 formItems->Add(stxtBuildCommand, 0, wxALIGN_CENTER_VERTICAL);
131 formItems->Add(this->buildCommand, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
133 formItems->Add(stxtHelpEnabled, 0, wxALIGN_CENTER_VERTICAL);
134 formItems->Add(this->helpEnabled, 1, wxEXPAND);
136 formItems->AddGrowableCol(1,1);
138 v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
140 wxBoxSizer* h_sizer2 = new wxBoxSizer(wxHORIZONTAL);
141 h_sizer2->Add(new wxButton(this, ID_BUTTON_PREV, wxT("Restore Defaults")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
142 h_sizer2->Add(new wxButton(this, ID_BUTTON_NEXT, wxT("OK")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
143 h_sizer2->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Cancel")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
146 v_sizer1->Add(h_sizer2, 0, wxALIGN_CENTER | wxALL | wxEXPAND, 10);
151 void wxCDMSettingsDialog::OnFinish(wxCommandEvent& event)
153 wxConfigBase* pConfig = wxConfigBase::Get();
155 pConfig->Write(wxT("TEXT_EDITOR"), this->textEditor->GetValue());
156 pConfig->Write(wxT("TERMINAL"), this->terminal->GetValue());
157 pConfig->Write(wxT("FILE_EXPLORER"), this->fileExplorer->GetValue());
158 pConfig->Write(wxT("HELP"), this->helpEnabled->GetValue());
160 pConfig->Write(wxT("BUILD_COMMAND"), this->buildCommand->GetValue());
165 this->EndModal(wxID_OK);
168 void wxCDMSettingsDialog::OnCancel(wxCommandEvent& event)
170 this->EndModal(wxID_CANCEL);
173 void wxCDMSettingsDialog::OnDefaults(wxCommandEvent& event)
175 this->textEditor->SetValue(crea::std2wx(CDMUtilities::TEXT_EDITOR));
176 this->terminal->SetValue(crea::std2wx(CDMUtilities::TERMINAL));
177 this->fileExplorer->SetValue(crea::std2wx(CDMUtilities::FILE_EXPLORER));
179 this->buildCommand->SetValue(crea::std2wx(CDMUtilities::BUILD_COMMAND));
181 this->helpEnabled->SetValue(true);