00001 /*************************************************************** 00002 * Name: SettingsDialogImpl.cpp 00003 * Purpose: Code for SettingsDialogImpl class 00004 * Author: NDA (nicola.dellamico@ndatech.it) 00005 * Created: 2008-07-29 00006 * Copyright: CAEN S.p.A (www.caen.it) 00007 * License: 00008 **************************************************************/ 00009 #ifdef WX_PRECOMP 00010 #include "wx_pch.h" 00011 #endif 00012 #include "SettingsDialogImpl.h" 00013 00014 SettingsDialogImpl::SettingsDialogImpl(wxWindow* parent) 00015 : SettingsDialog( parent) { 00016 // Read configuration settings and setup controls 00017 if ( !this->m_application_settings.ReadSettings()) { 00018 wxFAIL_MSG( _("SettingsDialogImpl::SettingsDialogImpl: Errors while reading application settings")); 00019 } 00020 this->m_device_name_textCtrl->SetValue( this->m_application_settings.m_communication_device_id); 00021 this->m_first_visible_channel_spinCtrl->SetValue( this->m_application_settings.m_first_visible_channel); 00022 this->m_last_visible_channel_spinCtrl->SetValue( this->m_application_settings.m_last_visible_channel); 00023 this->m_module_address_spinCtrl->SetValue( this->m_application_settings.m_default_module_address); 00024 this->m_mux_out_spinCtrl->SetValue( this->m_application_settings.m_default_mux_out); 00025 this->m_logger_enabled_checkBox->SetValue( this->m_application_settings.m_is_logger_enabled); 00026 this->m_logger_visible_checkBox->SetValue( this->m_application_settings.m_is_logger_visible); 00027 } 00028 00029 SettingsDialogImpl::~SettingsDialogImpl() { 00030 //dtor 00031 } 00032 00033 void SettingsDialogImpl::OnOkClicked( wxCommandEvent& event) { 00034 // Validity checks 00035 // Communication 00036 if ( this->m_device_name_textCtrl->GetValue( ).Trim().IsEmpty()) { 00037 wxMessageDialog dlg( this, _("Invalid device name"), ("Error"), wxOK| wxICON_ERROR); 00038 dlg.ShowModal(); 00039 return; 00040 } 00041 // Board 00042 if( this->m_application_settings.m_first_visible_channel> this->m_application_settings.m_last_visible_channel) { 00043 wxMessageDialog dlg( this, _("The first visible channel must be lesser or equal to last visible channel"), ("Error"), wxOK| wxICON_ERROR); 00044 dlg.ShowModal(); 00045 return; 00046 } 00047 00048 this->m_application_settings.m_communication_device_id= this->m_device_name_textCtrl->GetValue( ).Trim(); 00049 this->m_application_settings.m_first_visible_channel= this->m_first_visible_channel_spinCtrl->GetValue( ); 00050 this->m_application_settings.m_last_visible_channel= this->m_last_visible_channel_spinCtrl->GetValue( ); 00051 this->m_application_settings.m_default_module_address= this->m_module_address_spinCtrl->GetValue( ); 00052 this->m_application_settings.m_default_mux_out= this->m_mux_out_spinCtrl->GetValue( ); 00053 this->m_application_settings.m_is_logger_enabled= this->m_logger_enabled_checkBox->GetValue( ); 00054 this->m_application_settings.m_is_logger_visible= this->m_logger_visible_checkBox->GetValue( ); 00055 if ( !this->m_application_settings.WriteSettings()) { 00056 wxFAIL_MSG( _("SettingsDialogImpl::SettingsDialogImpl: Errors while writing application settings")); 00057 } 00058 event.Skip(); 00059 }
1.5.6