- Settings implemented. Help enabled, text editor, terminal, file explorer names are saved.
#include <creaWx.h>
#include <wx/tooltip.h>
+#include <wx/config.h>
#include <stdlib.h>
#include <iostream> // for std::cout
#include "creaDevManager.h"
bool wxCreaDevManagerApp::OnInit()
{
wxApp::OnInit();
+ this->SetVendorName(wxT("Creatis"));
+ this->SetAppName(wxT("creaDevManager"));
+
+ wxConfigBase *pConfig = wxConfigBase::Get();
+
mainWindow = new wxCDMMainFrame(NULL);
SetTopWindow(mainWindow);
mainWindow->SetSize(750, 700);
int wxCreaDevManagerApp::OnExit()
{
+ delete wxConfigBase::Set((wxConfigBase *) NULL);
wxApp::OnExit();
std::cout << "Crea DevManager closed." << std::endl;
return 0;
#include<algorithm>
#include<cstdlib>
+#include<creaWx.h>
+#include<wx/config.h>
+
namespace CDMUtilities
{
template <typename Container>
int openTextEditor(const std::string& file)
{
- std::string command = TEXT_EDITOR;
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string command = crea::wx2std(pConfig->Read(wxT("TEXT_EDITOR"), crea::std2wx(CDMUtilities::TEXT_EDITOR)));
if(file != "")
command += " \"" + file + "\"";
int openFileExplorer(const std::string& file)
{
- std::string command = FILE_EXPLORER;
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string command = crea::wx2std(pConfig->Read(wxT("FILE_EXPLORER"), crea::std2wx(CDMUtilities::FILE_EXPLORER)));
if(file != "")
command += " \"" + file + "\"";
int openTerminal(const std::string& command)
{
- std::string comm = TERMINAL;
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ std::string comm = crea::wx2std(pConfig->Read(wxT("TERMINAl"), crea::std2wx(CDMUtilities::TERMINAL)));
if (command != "")
comm += + " " + command;
comm += " &";
/**
* Path slash
*/
- #ifdef _WIN32
- // ------ Windows
- static std::string SLASH = "\\";
- #elif __APPLE__
- // ------ Apple
- static std::string SLASH = "/";
- #else
- static std::string SLASH = "/";
- #endif
+#ifdef _WIN32
+ // ------ Windows
+ static std::string SLASH = "\\";
+#elif __APPLE__
+ // ------ Apple
+ static std::string SLASH = "/";
+#else
+ static std::string SLASH = "/";
+#endif
/**
* Text editor program
/**
* Terminal program
*/
- #ifdef _WIN32
- // ------ Windows
- static std::string TERMINAL = "start cmd.exe";
- #elif __APPLE__
- // ------ Apple
- //TODO: implementation for apple
- #else
- static std::string TERMINAL = "gnome-terminal";
- #endif
-
+#ifdef _WIN32
+ // ------ Windows
+ static std::string TERMINAL = "start cmd.exe";
+#elif __APPLE__
+ // ------ Apple
+ //TODO: implementation for apple
+#else
+ static std::string TERMINAL = "gnome-terminal";
+#endif
/**
* Structure that handles the split method for c++
#define ID_MENU_EXIT 10207
#define ID_MENU_REFRESH_PROJECT 10208
-#define ID_MENU_CUT 10209
+#define ID_MENU_SETTINGS 10209
#define ID_MENU_COPY 10210
#define ID_MENU_PASTE 10211
#define ID_MENU_DELETE 10212
#include "wx/tooltip.h"
#include "wx/wxhtml.h"
#include "wx/statline.h"
+#include "wx/config.h"
#include "CDMUtilities.h"
#include "creaDevManagerIds.h"
#include "wxCDMFileDescriptionPanel.h"
#include "wxCDMPackageManagerPanel.h"
+#include "wxCDMSettingsDialog.h"
+
#include "wxCDMProjectActionsPanel.h"
#include "wxCDMNewProjectDialog.h"
EVT_MENU(ID_MENU_EXPORT_HIERARCHY, wxCDMMainFrame::OnMenuExportHierarchy)
EVT_MENU(ID_MENU_EXIT, wxCDMMainFrame::OnMenuExit)
EVT_MENU(ID_MENU_REFRESH_PROJECT, wxCDMMainFrame::OnMenuRefreshProject)
+EVT_MENU(ID_MENU_SETTINGS, wxCDMMainFrame::OnMenuSettings)
EVT_MENU(ID_MENU_BBTK_GRAPHICAL_EDITOR, wxCDMMainFrame::OnMenuBBTKGraphicalEditor)
EVT_MENU(ID_MENU_MINITOOLS, wxCDMMainFrame::OnMenuMiniTools)
EVT_MENU(ID_MENU_CODE_EDITOR, wxCDMMainFrame::OnMenuCodeEditor)
)
{
wxFrame::Create(parent, id, caption, pos, size, style);
- this->model = new modelCDMMain();
this->help = true;
+
+ wxConfigBase* pConfig = wxConfigBase::Get();
+ this->help = pConfig->Read(wxT("HELP"), this->help);
+
+ this->model = new modelCDMMain();
+
CreateMenus();
CreateControls();
return TRUE;
//EditMenu
menu_Edit = new wxMenu();
menu_Edit->Append(ID_MENU_REFRESH_PROJECT, wxT("&Refresh Project"));
+ menu_Edit->Append(ID_MENU_SETTINGS, wxT("&Settings"));
menuBar->Append(menu_Edit, wxT("&Edit"));
event.Skip();
}
+void wxCDMMainFrame::OnMenuSettings(wxCommandEvent& event)
+{
+ wxCDMSettingsDialog* settingsDialog = new wxCDMSettingsDialog(this, -1);
+ settingsDialog->SetHelpEnabled(this->help);
+
+ int res = settingsDialog->ShowModal();
+ if(res == wxID_OK)
+ {
+ this->help = settingsDialog->IsHelpEnabled();
+ this->menu_Help->Check(ID_MENU_TOGGLE_HELP, this->help);
+ }
+}
+
void wxCDMMainFrame::OnMenuBBTKGraphicalEditor(wxCommandEvent& event)
{
std::cerr << "Event OnMenuBBTKGraphicalEditor not implemented" << std::endl;
auiManager.Update();
break;
default:
- event.Skip();
+ event.Skip();
+ break;
}
}
* @param event The event object that triggers the handler.
*/
void OnMenuRefreshProject(wxCommandEvent& event);
+ /**
+ * Open the settings dialog.
+ * @param event The event object that triggers the handler.
+ */
+ void OnMenuSettings(wxCommandEvent& event);
//Tools
/**
#endif
break;
default:
- res = wxT("std");
+ res = wxT("std");
+ break;
}
return res;
}
res = wxT("XML");
break;
default:
- res = wxT("C++");
+ res = wxT("C++");
+ break;
}
return res;
}
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+# pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+# This software is governed by the CeCILL-B license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL-B
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+# or in the file LICENSE.txt.
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+
+/*
+ * wxCDMMainHelpDialog.cpp
+ *
+ * Created on: 14/2/2013
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#include "wxCDMSettingsDialog.h"
+
+#include "creaDevManagerIds.h"
+#include "CDMUtilities.h"
+
+#include <wx/config.h>
+
+BEGIN_EVENT_TABLE(wxCDMSettingsDialog, wxDialog)
+EVT_BUTTON(ID_BUTTON_NEXT, wxCDMSettingsDialog::OnFinish)
+EVT_BUTTON(ID_BUTTON_PREV, wxCDMSettingsDialog::OnDefaults)
+EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMSettingsDialog::OnCancel)
+END_EVENT_TABLE()
+
+wxCDMSettingsDialog::wxCDMSettingsDialog(
+ wxWindow* parent,
+ wxWindowID id,
+ const wxString& caption,
+ const wxPoint& position,
+ const wxSize& size,
+ long style
+)
+{
+ wxCDMSettingsDialog::Create(parent, id, caption, position, size, style);
+}
+
+wxCDMSettingsDialog::~wxCDMSettingsDialog()
+{
+}
+
+bool wxCDMSettingsDialog::Create(
+ wxWindow* parent,
+ wxWindowID id,
+ const wxString& caption,
+ const wxPoint& position,
+ const wxSize& size,
+ long int style
+)
+{
+ wxDialog::Create(parent, id, caption, position, size, style);
+
+ this->CreateControls();
+
+ return TRUE;
+}
+
+bool wxCDMSettingsDialog::IsHelpEnabled()
+{
+ return this->helpEnabled->GetValue();
+}
+
+void wxCDMSettingsDialog::SetHelpEnabled(bool isHelp)
+{
+ this->helpEnabled->SetValue(isHelp);
+}
+
+void wxCDMSettingsDialog::CreateControls()
+{
+
+ wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
+
+
+ wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Crea Development Manager Settings"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+ v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+ wxStaticText* instruction = new wxStaticText(this, wxID_ANY, wxT("Change the values to modify the default behavior of the program."), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
+ v_sizer1->Add(instruction, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 5);
+
+ wxFlexGridSizer* formItems = new wxFlexGridSizer(4,2,9,15);
+
+ wxStaticText *stxtTextEditor = new wxStaticText(this, -1, wxT("Text Editor Command"));
+ wxStaticText *stxtFileExplorer = new wxStaticText(this, -1, wxT("File Explorer Command"));
+ wxStaticText *stxtTerminal = new wxStaticText(this, -1, wxT("Terminal Command"));
+ wxStaticText *stxtHelpEnabled = new wxStaticText(this, -1, wxT("Help Enabled"));
+
+ wxConfigBase* pConfig = wxConfigBase::Get();
+
+ this->textEditor = new wxTextCtrl(this, -1, pConfig->Read(wxT("TEXT_EDITOR"), crea::std2wx(CDMUtilities::TEXT_EDITOR)));
+ this->fileExplorer = new wxTextCtrl(this, -1, pConfig->Read(wxT("FILE_EXPLORER"), crea::std2wx(CDMUtilities::FILE_EXPLORER)));
+ this->terminal = new wxTextCtrl(this, -1, pConfig->Read(wxT("TERMINAL"), crea::std2wx(CDMUtilities::TERMINAL)));
+ this->helpEnabled = new wxCheckBox(this, -1, wxT(""));
+ this->helpEnabled->SetValue(pConfig->Read(wxT("HELP"), true));
+
+
+ formItems->Add(stxtTextEditor, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->textEditor, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtFileExplorer, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->fileExplorer, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtTerminal, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->terminal, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL);
+ formItems->Add(stxtHelpEnabled, 0, wxALIGN_CENTER_VERTICAL);
+ formItems->Add(this->helpEnabled, 1, wxEXPAND);
+
+
+ formItems->AddGrowableCol(1,1);
+
+ v_sizer1->Add(formItems, 1, wxEXPAND | wxALL, 15);
+
+ wxBoxSizer* h_sizer2 = new wxBoxSizer(wxHORIZONTAL);
+ h_sizer2->Add(new wxButton(this, ID_BUTTON_PREV, wxT("Restore Defaults")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+ h_sizer2->Add(new wxButton(this, ID_BUTTON_NEXT, wxT("OK")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+ h_sizer2->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Cancel")), 0, wxALL | wxALIGN_CENTER_VERTICAL, 5);
+
+
+ v_sizer1->Add(h_sizer2, 0, wxALIGN_CENTER | wxALL | wxEXPAND, 10);
+
+ SetSizer(v_sizer1);
+}
+
+void wxCDMSettingsDialog::OnFinish(wxCommandEvent& event)
+{
+ wxConfigBase* pConfig = wxConfigBase::Get();
+
+ pConfig->Write(wxT("TEXT_EDITOR"), this->textEditor->GetValue());
+ pConfig->Write(wxT("TERMINAL"), this->terminal->GetValue());
+ pConfig->Write(wxT("FILE_EXPLORER"), this->fileExplorer->GetValue());
+ pConfig->Write(wxT("HELP"), this->helpEnabled->GetValue());
+
+ this->EndModal(wxID_OK);
+}
+
+void wxCDMSettingsDialog::OnCancel(wxCommandEvent& event)
+{
+ this->EndModal(wxID_CANCEL);
+}
+
+void wxCDMSettingsDialog::OnDefaults(wxCommandEvent& event)
+{
+ this->textEditor->SetValue(crea::std2wx(CDMUtilities::TEXT_EDITOR));
+ this->terminal->SetValue(crea::std2wx(CDMUtilities::TERMINAL));
+ this->fileExplorer->SetValue(crea::std2wx(CDMUtilities::FILE_EXPLORER));
+ this->helpEnabled->SetValue(true);
+}
--- /dev/null
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+# pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+# This software is governed by the CeCILL-B license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL-B
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+# or in the file LICENSE.txt.
+#
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+#
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+
+/*
+ * wxCDMSettingsDialog.h
+ *
+ * Created on: 14/2/2013
+ * Author: Daniel Felipe Gonzalez Obando
+ */
+
+#ifndef WXCDMSETTINGSDIALOG_H_
+#define WXCDMSETTINGSDIALOG_H_
+
+#include <creaWx.h>
+#include <wx/dialog.h>
+#include <wx/dialog.h>
+
+/**
+ * Settings Dialog
+ */
+class wxCDMSettingsDialog : public wxDialog
+{
+ DECLARE_EVENT_TABLE()
+public:
+ /**
+ * Settings Dialog Constructor.
+ * @param parent Parent window.
+ * @param id Dialog ID. By default wxID_ANY.
+ * @param caption Dialog label. By default "Settings - CreaDevManager CREATIS".
+ * @param position Dialog position. By default wxDefaultPosition.
+ * @param size Dialog size. By default 350, 370.
+ * @param style Dialog style. By default wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER.
+ */
+ wxCDMSettingsDialog(
+ wxWindow* parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& caption = wxT("Settings - CreaDevManager CREATIS"),
+ const wxPoint& position = wxDefaultPosition,
+ const wxSize& size = wxSize(350,320),
+ long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
+ );
+ /**
+ * Destructor.
+ */
+ ~wxCDMSettingsDialog();
+ /**
+ * Settings Dialog Creator.
+ * @param parent Parent window.
+ * @param id Dialog ID. By default wxID_ANY.
+ * @param caption Dialog label. By default "Settings - CreaDevManager CREATIS".
+ * @param position Dialog position. By default wxDefaultPosition.
+ * @param size Dialog size. By default 350, 370.
+ * @param style Dialog style. By default wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER.
+ * @return if the creation was successful.
+ */
+ bool Create(
+ wxWindow* parent,
+ wxWindowID id = wxID_ANY,
+ const wxString& caption = wxT("Settings - CreaDevManager CREATIS"),
+ const wxPoint& position = wxDefaultPosition,
+ const wxSize& size = wxSize(350,320),
+ long style = wxDEFAULT_DIALOG_STYLE
+ );
+
+ /**
+ * Retrieves if the user has help enabled.
+ * @return True if the user has the help enabled.
+ */
+ bool IsHelpEnabled();
+
+ /**
+ * Sets the help enabled checkbox value.
+ * @param isHelp value of the help enabled checkbox.
+ */
+ void SetHelpEnabled(bool isHelp);
+
+protected:
+ /**
+ * Creates the help controls (text and buttons).
+ */
+ void CreateControls();
+
+ //attributes
+private:
+ /**
+ * Text Editor Command.
+ */
+ wxTextCtrl* textEditor;
+ /**
+ * Terminal Command.
+ */
+ wxTextCtrl* terminal;
+ /**
+ * File Explorer Command.
+ */
+ wxTextCtrl* fileExplorer;
+ /**
+ * Help Enabled.
+ */
+ wxCheckBox* helpEnabled;
+
+
+ //handlers
+protected:
+ /**
+ * Handler to close help dialog saving changes.
+ * @param event Unused.
+ */
+ void OnFinish(wxCommandEvent& event);
+
+ /**
+ * Handler to close help dialog discarding changes.
+ * @param event Unused.
+ */
+ void OnCancel(wxCommandEvent& event);
+
+ /**
+ * Handler to return to default settings.
+ * @param event Unused.
+ */
+ void OnDefaults(wxCommandEvent& event);
+};
+
+#endif /* WXCDMSETTINGSDIALOG_H_ */