1
// RCS-ID: $Id: DlgCfgTheoIntervals.cpp,v 1.3 2006/02/23 19:15:54 cecilios Exp $
2
//--------------------------------------------------------------------------------------
3
// LenMus Phonascus: The teacher of music
4
// Copyright (c) 2002-2006 Cecilio Salmeron
6
// This program is free software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the Free Software Foundation;
8
// either version 2 of the License, or (at your option) any later version.
10
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
11
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
// PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
// You should have received a copy of the GNU General Public License along with this
15
// program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
16
// Fifth Floor, Boston, MA 02110-1301, USA.
18
// for (any comment, suggestion or feature request, please contact the manager of
19
// the project at cecilios@users.sourceforge.net
21
//-------------------------------------------------------------------------------------
22
/*! @file DlgCfgTheoIntervals.cpp
23
@brief Implementation file for class lmDlgCfgTheoIntervals
29
#pragma implementation "DlgCfgTheoIntervals.h"
32
// for (compilers that support precompilation, includes "wx/wx.h".
33
#include "wx/wxprec.h"
43
#include <wx/dialog.h>
44
#include <wx/button.h>
46
#include "wx/xrc/xmlres.h"
49
#include "../globals/Paths.h"
50
extern lmPaths* g_pPaths;
54
#include "DlgCfgTheoIntervals.h"
55
#include "../ldp_parser/AuxString.h"
56
#include "../auxmusic/Conversion.h"
60
//-----------------------------------------------------------------------------
61
// Event table: connect the events to the handler functions to process them
62
//-----------------------------------------------------------------------------
65
BEGIN_EVENT_TABLE(lmDlgCfgTheoIntervals, wxDialog)
66
EVT_BUTTON( XRCID( "buttonAccept" ), lmDlgCfgTheoIntervals::OnAcceptClicked )
67
EVT_BUTTON( XRCID( "buttonCancel" ), lmDlgCfgTheoIntervals::OnCancelClicked )
70
EVT_CHECKBOX( XRCID( "chkGClef" ), lmDlgCfgTheoIntervals::OnControlClicked )
71
EVT_CHECKBOX( XRCID( "chkF4Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
72
EVT_CHECKBOX( XRCID( "chkF3Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
73
EVT_CHECKBOX( XRCID( "chkC1Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
74
EVT_CHECKBOX( XRCID( "chkC2Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
75
EVT_CHECKBOX( XRCID( "chkC3Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
76
EVT_CHECKBOX( XRCID( "chkC4Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
79
EVT_CHECKBOX( XRCID( "chkAccidentals" ), lmDlgCfgTheoIntervals::OnControlClicked )
85
lmDlgCfgTheoIntervals::lmDlgCfgTheoIntervals(wxWindow * parent,
86
lmTheoIntervalsConstrains* pConstrains)
89
m_pConstrains = pConstrains;
91
// create the dialog controls
92
wxXmlResource::Get()->LoadDialog(this, parent, _T("DlgCfgTheoIntervals"));
95
//get pointers to all controls
98
// error messages and bitmaps
99
m_pLblClefError = XRCCTRL(*this, _T("lblClefError"), wxStaticText);
100
m_pBmpClefError = XRCCTRL(*this, _T("bmpClefError"), wxStaticBitmap);
103
m_pChkClef[0] = XRCCTRL(*this, _T("chkGClef"), wxCheckBox);
104
m_pChkClef[1] = XRCCTRL(*this, _T("chkF4Clef"), wxCheckBox);
105
m_pChkClef[2] = XRCCTRL(*this, _T("chkF3Clef"), wxCheckBox);
106
m_pChkClef[3] = XRCCTRL(*this, _T("chkC1Clef"), wxCheckBox);
107
m_pChkClef[4] = XRCCTRL(*this, _T("chkC2Clef"), wxCheckBox);
108
m_pChkClef[5] = XRCCTRL(*this, _T("chkC3Clef"), wxCheckBox);
109
m_pChkClef[6] = XRCCTRL(*this, _T("chkC4Clef"), wxCheckBox);
111
// allowed accidentals
112
m_pChkDoubleAccidentals = XRCCTRL(*this, _T("chkDoubleAccidentals"), wxCheckBox);
113
m_pChkAccidentals = XRCCTRL(*this, _T("chkAccidentals"), wxCheckBox);
116
m_radProblemType = XRCCTRL(*this, _T("radProblemType"), wxRadioBox);
120
wxArtProvider::GetBitmap(_T("msg_error"), wxART_TOOLBAR, wxSize(16,16));
121
m_pBmpClefError->SetBitmap(bmpError);
123
//hide all error messages and their associated icons
124
m_pLblClefError->Show(false);
125
m_pBmpClefError->Show(false);
128
// initialize all controls with current constrains data
131
// check boxes for allowed clefs
133
for (i=0; i < 7; i++) {
134
m_pChkClef[i]->SetValue( m_pConstrains->IsValidClef((EClefType)((int)lmMIN_CLEF+i) ));
137
// allowed accidentals.
138
m_pChkAccidentals->SetValue( m_pConstrains->GetAccidentals() );
139
if ( m_pChkAccidentals->GetValue() ) {
140
m_pChkDoubleAccidentals->SetValue( m_pConstrains->GetDoubleAccidentals() );
141
m_pChkDoubleAccidentals->Enable(true);
144
m_pChkDoubleAccidentals->SetValue(false);
147
m_radProblemType->SetSelection( (int)m_pConstrains->GetProblemType() );
149
//center dialog on screen
154
lmDlgCfgTheoIntervals::~lmDlgCfgTheoIntervals()
158
/*! Accept button will be enabled only if all data habe been validated and is Ok. So
159
when accept button is clicked we can proceed to save data.
161
void lmDlgCfgTheoIntervals::OnAcceptClicked(wxCommandEvent& WXUNUSED(event))
163
// save allowed clefs
165
for (i=0; i < 7; i++) {
166
m_pConstrains->SetClef((EClefType)((int)lmMIN_CLEF+i), m_pChkClef[i]->GetValue());
169
// save allowed accidentals
170
m_pConstrains->SetAccidentals( m_pChkAccidentals->GetValue() );
171
m_pConstrains->SetDoubleAccidentals( m_pChkDoubleAccidentals->GetValue() );
174
m_pConstrains->SetProblemType((EProblemTheoIntervals)m_radProblemType->GetSelection() );
176
//terminate the dialog
180
/*! Returns true if there are errors. If there are no
181
errors the Accept button is enabled. Otherwise it is disabled.
183
bool lmDlgCfgTheoIntervals::VerifyData()
189
bool fGlobalError = false;
190
m_pLblClefError->Show(false);
191
m_pBmpClefError->Show(false);
193
// check that at least one clef is allowed
194
bool fAtLeastOne = false;
195
for (i=0; i < 7; i++) {
196
if (m_pChkClef[i]->GetValue()) {
201
fError = !fAtLeastOne;
203
m_pLblClefError->Show(true);
204
m_pBmpClefError->Show(true);
206
fGlobalError |= fError;
208
// enable double accidentals only if accidentals checked
209
if (m_pChkAccidentals->GetValue()) {
210
m_pChkDoubleAccidentals->Enable(true);
213
m_pChkDoubleAccidentals->SetValue(false);
214
m_pChkDoubleAccidentals->Enable(false);
217
//enable / disable accept button
218
wxButton* pButtonAccept = XRCCTRL(*this, _T("buttonAccept"), wxButton);
219
pButtonAccept->Enable(!fGlobalError);
225
void lmDlgCfgTheoIntervals::OnControlClicked(wxCommandEvent& WXUNUSED(event))
b'\\ No newline at end of file'