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(4,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 wxConfigBase* pConfig = wxConfigBase::Get();
112 this->textEditor = new wxTextCtrl(this, -1, pConfig->Read(wxT("TEXT_EDITOR"), crea::std2wx(CDMUtilities::TEXT_EDITOR)));
113 this->fileExplorer = new wxTextCtrl(this, -1, pConfig->Read(wxT("FILE_EXPLORER"), crea::std2wx(CDMUtilities::FILE_EXPLORER)));
114 this->terminal = new wxTextCtrl(this, -1, pConfig->Read(wxT("TERMINAL"), crea::std2wx(CDMUtilities::TERMINAL)));
115 this->helpEnabled = new wxCheckBox(this, -1, wxT(""));
116 this->helpEnabled->SetValue(pConfig->Read(wxT("HELP"), true) != 0);
119 formItems->Add(stxtTextEditor, 0, wxALIGN_CENTER_VERTICAL);
120 formItems->Add(this->textEditor, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
121 formItems->Add(stxtFileExplorer, 0, wxALIGN_CENTER_VERTICAL);
122 formItems->Add(this->fileExplorer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
123 formItems->Add(stxtTerminal, 0, wxALIGN_CENTER_VERTICAL);
124 formItems->Add(this->terminal, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
125 formItems->Add(stxtHelpEnabled, 0, wxALIGN_CENTER_VERTICAL);
126 formItems->Add(this->helpEnabled, 1, wxEXPAND);
129 formItems->AddGrowableCol(1,1);
131 v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
133 wxBoxSizer* h_sizer2 = new wxBoxSizer(wxHORIZONTAL);
134 h_sizer2->Add(new wxButton(this, ID_BUTTON_PREV, wxT("Restore Defaults")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
135 h_sizer2->Add(new wxButton(this, ID_BUTTON_NEXT, wxT("OK")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
136 h_sizer2->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Cancel")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
139 v_sizer1->Add(h_sizer2, 0, wxALIGN_CENTER | wxALL | wxEXPAND, 10);
144 void wxCDMSettingsDialog::OnFinish(wxCommandEvent& event)
146 wxConfigBase* pConfig = wxConfigBase::Get();
148 pConfig->Write(wxT("TEXT_EDITOR"), this->textEditor->GetValue());
149 pConfig->Write(wxT("TERMINAL"), this->terminal->GetValue());
150 pConfig->Write(wxT("FILE_EXPLORER"), this->fileExplorer->GetValue());
151 pConfig->Write(wxT("HELP"), this->helpEnabled->GetValue());
153 this->EndModal(wxID_OK);
156 void wxCDMSettingsDialog::OnCancel(wxCommandEvent& event)
158 this->EndModal(wxID_CANCEL);
161 void wxCDMSettingsDialog::OnDefaults(wxCommandEvent& event)
163 this->textEditor->SetValue(crea::std2wx(CDMUtilities::TEXT_EDITOR));
164 this->terminal->SetValue(crea::std2wx(CDMUtilities::TERMINAL));
165 this->fileExplorer->SetValue(crea::std2wx(CDMUtilities::FILE_EXPLORER));
166 this->helpEnabled->SetValue(true);