1
//--------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2007 Cecilio Salmeron
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU General Public License as published by the Free Software Foundation;
7
// either version 2 of the License, or (at your option) any later version.
9
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
10
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11
// PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
// You should have received a copy of the GNU General Public License along with this
14
// program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street,
15
// Fifth Floor, Boston, MA 02110-1301, USA.
17
// for (any comment, suggestion or feature request, please contact the manager of
18
// the project at cecilios@users.sourceforge.net
20
//-------------------------------------------------------------------------------------
24
#pragma implementation "DlgCfgTheoIntervals.h"
27
// for (compilers that support precompilation, includes "wx/wx.h".
28
#include "wx/wxprec.h"
38
#include <wx/dialog.h>
39
#include <wx/button.h>
41
#include "wx/xrc/xmlres.h"
44
#include "../globals/Paths.h"
45
extern lmPaths* g_pPaths;
49
#include "DlgCfgTheoIntervals.h"
50
#include "../ldp_parser/AuxString.h"
51
#include "../auxmusic/Conversion.h"
55
//-----------------------------------------------------------------------------
56
// Event table: connect the events to the handler functions to process them
57
//-----------------------------------------------------------------------------
60
BEGIN_EVENT_TABLE(lmDlgCfgTheoIntervals, wxDialog)
61
EVT_BUTTON( XRCID( "buttonAccept" ), lmDlgCfgTheoIntervals::OnAcceptClicked )
62
EVT_BUTTON( XRCID( "buttonCancel" ), lmDlgCfgTheoIntervals::OnCancelClicked )
65
EVT_CHECKBOX( XRCID( "chkGClef" ), lmDlgCfgTheoIntervals::OnControlClicked )
66
EVT_CHECKBOX( XRCID( "chkF4Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
67
EVT_CHECKBOX( XRCID( "chkF3Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
68
EVT_CHECKBOX( XRCID( "chkC1Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
69
EVT_CHECKBOX( XRCID( "chkC2Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
70
EVT_CHECKBOX( XRCID( "chkC3Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
71
EVT_CHECKBOX( XRCID( "chkC4Clef" ), lmDlgCfgTheoIntervals::OnControlClicked )
74
EVT_CHECKBOX( XRCID( "chkAccidentals" ), lmDlgCfgTheoIntervals::OnControlClicked )
80
lmDlgCfgTheoIntervals::lmDlgCfgTheoIntervals(wxWindow * parent,
81
lmTheoIntervalsConstrains* pConstrains)
84
m_pConstrains = pConstrains;
86
// create the dialog controls
87
wxXmlResource::Get()->LoadDialog(this, parent, _T("DlgCfgTheoIntervals"));
90
//get pointers to all controls
93
// error messages and bitmaps
94
m_pLblClefError = XRCCTRL(*this, "lblClefError", wxStaticText);
95
m_pBmpClefError = XRCCTRL(*this, "bmpClefError", wxStaticBitmap);
98
m_pChkClef[0] = XRCCTRL(*this, "chkGClef", wxCheckBox);
99
m_pChkClef[1] = XRCCTRL(*this, "chkF4Clef", wxCheckBox);
100
m_pChkClef[2] = XRCCTRL(*this, "chkF3Clef", wxCheckBox);
101
m_pChkClef[3] = XRCCTRL(*this, "chkC1Clef", wxCheckBox);
102
m_pChkClef[4] = XRCCTRL(*this, "chkC2Clef", wxCheckBox);
103
m_pChkClef[5] = XRCCTRL(*this, "chkC3Clef", wxCheckBox);
104
m_pChkClef[6] = XRCCTRL(*this, "chkC4Clef", wxCheckBox);
106
// allowed accidentals
107
m_pChkDoubleAccidentals = XRCCTRL(*this, "chkDoubleAccidentals", wxCheckBox);
108
m_pChkAccidentals = XRCCTRL(*this, "chkAccidentals", wxCheckBox);
111
m_radProblemType = XRCCTRL(*this, "radProblemType", wxRadioBox);
115
wxArtProvider::GetBitmap(_T("msg_error"), wxART_TOOLBAR, wxSize(16,16));
116
m_pBmpClefError->SetBitmap(bmpError);
118
//hide all error messages and their associated icons
119
m_pLblClefError->Show(false);
120
m_pBmpClefError->Show(false);
123
// initialize all controls with current constraints data
126
// check boxes for allowed clefs
128
for (i=0; i < 7; i++) {
129
m_pChkClef[i]->SetValue( m_pConstrains->IsValidClef((EClefType)((int)lmMIN_CLEF+i) ));
132
// allowed accidentals.
133
m_pChkAccidentals->SetValue( m_pConstrains->GetAccidentals() );
134
if ( m_pChkAccidentals->GetValue() ) {
135
m_pChkDoubleAccidentals->SetValue( m_pConstrains->GetDoubleAccidentals() );
136
m_pChkDoubleAccidentals->Enable(true);
139
m_pChkDoubleAccidentals->SetValue(false);
142
m_radProblemType->SetSelection( (int)m_pConstrains->GetProblemType() );
144
//center dialog on screen
149
lmDlgCfgTheoIntervals::~lmDlgCfgTheoIntervals()
153
/*! Accept button will be enabled only if all data habe been validated and is Ok. So
154
when accept button is clicked we can proceed to save data.
156
void lmDlgCfgTheoIntervals::OnAcceptClicked(wxCommandEvent& WXUNUSED(event))
158
// save allowed clefs
160
for (i=0; i < 7; i++) {
161
m_pConstrains->SetClef((EClefType)((int)lmMIN_CLEF+i), m_pChkClef[i]->GetValue());
164
// save allowed accidentals
165
m_pConstrains->SetAccidentals( m_pChkAccidentals->GetValue() );
166
m_pConstrains->SetDoubleAccidentals( m_pChkDoubleAccidentals->GetValue() );
169
m_pConstrains->SetProblemType((EProblemTheoIntervals)m_radProblemType->GetSelection() );
171
//terminate the dialog
175
/*! Returns true if there are errors. If there are no
176
errors the Accept button is enabled. Otherwise it is disabled.
178
bool lmDlgCfgTheoIntervals::VerifyData()
184
bool fGlobalError = false;
185
m_pLblClefError->Show(false);
186
m_pBmpClefError->Show(false);
188
// check that at least one clef is allowed
189
bool fAtLeastOne = false;
190
for (i=0; i < 7; i++) {
191
if (m_pChkClef[i]->GetValue()) {
196
fError = !fAtLeastOne;
198
m_pLblClefError->Show(true);
199
m_pBmpClefError->Show(true);
201
fGlobalError |= fError;
203
// enable double accidentals only if accidentals checked
204
if (m_pChkAccidentals->GetValue()) {
205
m_pChkDoubleAccidentals->Enable(true);
208
m_pChkDoubleAccidentals->SetValue(false);
209
m_pChkDoubleAccidentals->Enable(false);
212
//enable / disable accept button
213
wxButton* pButtonAccept = XRCCTRL(*this, "buttonAccept", wxButton);
214
pButtonAccept->Enable(!fGlobalError);
220
void lmDlgCfgTheoIntervals::OnControlClicked(wxCommandEvent& WXUNUSED(event))
b'\\ No newline at end of file'