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
//-------------------------------------------------------------------------------------
21
/*! @file Constrains.h
22
@brief Header file for Constrain derived classes
29
#ifndef __CONSTRAINS_H__ //to avoid nested includes
30
#define __CONSTRAINS_H__
32
// For compilers that support precompilation, includes "wx/wx.h".
33
#include "wx/wxprec.h"
43
#include "../score/Score.h"
46
enum EIntervalName // name of the intervals considered in exercises
48
ein_1 = 0, // unison // must start with 0. Used as index for arrays
73
ein_Max_Item //Must be the last one. Just to know how many items
76
#define lmNUM_INTVALS ein_Max_Item //num intervals considered in constraints
78
//----------------------------------------------------------------------------------------
85
bool IsValid(EClefType nClef) { return m_fValidClefs[nClef-lmMIN_CLEF]; }
86
void SetValid(EClefType nClef, bool fValid) { m_fValidClefs[nClef-lmMIN_CLEF] = fValid; }
89
wxString GetLowerPitch(EClefType nClef) { return m_aLowerPitch[nClef-lmMIN_CLEF]; }
90
wxString GetUpperPitch(EClefType nClef) { return m_aUpperPitch[nClef-lmMIN_CLEF]; }
91
void SetLowerPitch(EClefType nClef, wxString sPitch) {
92
m_aLowerPitch[nClef-lmMIN_CLEF] = sPitch;
94
void SetUpperPitch(EClefType nClef, wxString sPitch) {
95
m_aUpperPitch[nClef-lmMIN_CLEF] = sPitch;
100
bool m_fValidClefs[lmMAX_CLEF - lmMIN_CLEF + 1];
101
wxString m_aLowerPitch[lmMAX_CLEF - lmMIN_CLEF + 1];
102
wxString m_aUpperPitch[lmMAX_CLEF - lmMIN_CLEF + 1];
105
//----------------------------------------------------------------------------------------
107
class lmKeyConstrains
111
~lmKeyConstrains() {}
112
bool IsValid(EKeySignatures nKey) { return m_fValidKeys[nKey-lmMIN_KEY]; }
113
void SetValid(EKeySignatures nKey, bool fValid) { m_fValidKeys[nKey-lmMIN_KEY] = fValid; }
116
bool m_fValidKeys[lmMAX_KEY - lmMIN_KEY + 1];
119
//----------------------------------------------------------------------------------------
121
class lmTimeSignConstrains
124
lmTimeSignConstrains();
125
~lmTimeSignConstrains() {}
126
bool IsValid(ETimeSignature nTime) { return m_fValidTimes[nTime-lmMIN_TIME_SIGN]; }
127
void SetValid(ETimeSignature nTime, bool fValid) {
128
m_fValidTimes[nTime-lmMIN_TIME_SIGN] = fValid;
130
bool SetConstrains(wxString sTimeSigns);
133
bool m_fValidTimes[lmMAX_TIME_SIGN - lmMIN_TIME_SIGN + 1];
136
// lmTheoIntervalsConstrains -------------------------------------------------------------
138
enum EProblemTheoIntervals
140
ePT_DeduceInterval = 0, //WARNING: the enum values are used as indexes
141
ePT_BuildInterval, // in DlgCfgTheoIntervals. Do not alter
142
ePT_Both // neither order nor values. Must start in 0
146
class lmTheoIntervalsConstrains //: public ProblemConstrains
149
lmTheoIntervalsConstrains();
150
~lmTheoIntervalsConstrains() {}
152
bool IsValidClef(EClefType nClef) { return m_oClefs.IsValid(nClef); }
153
void SetClef(EClefType nClef, bool fValid) { m_oClefs.SetValid(nClef, fValid); }
155
EProblemTheoIntervals GetProblemType() { return m_nProblemType; }
156
void SetProblemType(EProblemTheoIntervals nType) { m_nProblemType = nType; }
158
bool GetAccidentals() { return m_fAccidentals; }
159
void SetAccidentals(bool fValue) { m_fAccidentals = fValue; }
161
bool GetDoubleAccidentals() { return m_fDoubleAccidentals; }
162
void SetDoubleAccidentals(bool fValue) { m_fDoubleAccidentals = fValue; }
164
lmClefConstrain* GetClefConstrains() { return &m_oClefs; }
172
lmClefConstrain m_oClefs;
173
EProblemTheoIntervals m_nProblemType;
174
bool m_fAccidentals; //allow accidentals
175
bool m_fDoubleAccidentals; //allow double accidentals
180
/*! @class lmScoreCtrolOptions
181
@brief Options for lmScoreCtrol control
183
class lmScoreCtrolOptions
186
lmScoreCtrolOptions() {
190
fMeasuresCtrol = false;
192
fMusicBorder = false;
193
sPlayLabel = _("Play");
194
sStopPlayLabel = _("Stop");
195
sSolfaLabel = _("Read");
196
sStopSolfaLabel = _("Stop");
197
sMeasuresLabel = _("Measure %d");
198
sStopMeasureLabel = _("Stop %d");
203
~lmScoreCtrolOptions() {}
205
void SetControlPlay(bool fValue, wxString sLabels = _T(""))
208
if (sLabels != _T(""))
209
SetLabels(sLabels, &sPlayLabel, &sStopPlayLabel);
211
void SetControlSolfa(bool fValue, wxString sLabels = _T(""))
213
fSolfaCtrol = fValue;
214
if (sLabels != _T(""))
215
SetLabels(sLabels, &sSolfaLabel, &sStopSolfaLabel);
217
void SetControlMeasures(bool fValue, wxString sLabels = _T(""))
219
fMeasuresCtrol = fValue;
220
if (sLabels != _T(""))
221
SetLabels(sLabels, &sMeasuresLabel, &sStopMeasureLabel);
224
void SetMetronomeMM(long nValue) { m_nMM = nValue; }
225
long GetMetronomeMM() { return m_nMM; }
228
bool fPlayCtrol; //Instert "Play" link
229
wxString sPlayLabel; //label for "Play" link
230
wxString sStopPlayLabel; //label for "Stop playing" link
232
bool fSolfaCtrol; //insert a "Sol-fa" link
233
wxString sSolfaLabel; //label for "Sol-fa" link
234
wxString sStopSolfaLabel; //label for "Stop sol-fa" link
236
bool fMeasuresCtrol; //insert "play-measure" links
237
wxString sMeasuresLabel;
238
wxString sStopMeasureLabel;
240
bool fBorder; // border around control
241
bool fMusicBorder; // border around music
246
void SetLabels(wxString& sLabel, wxString* pStart, wxString* pStop);
248
long m_nMM; // metronome setting
253
/*! @class lmMusicReadingCtrolOptions
254
@brief Options for lmTheoMusicReadingCtrol control
256
class lmMusicReadingCtrolOptions
259
lmMusicReadingCtrolOptions() {
265
fSettingsLink = false;
266
sPlayLabel = _("Play");
267
sStopPlayLabel = _("Stop");
268
sSolfaLabel = _("Read");
269
sStopSolfaLabel = _("Stop");
272
~lmMusicReadingCtrolOptions() {}
273
void SetControlPlay(bool fValue, wxString sLabels = _T(""))
276
if (sLabels != _T(""))
277
SetLabels(sLabels, &sPlayLabel, &sStopPlayLabel);
279
void SetControlSolfa(bool fValue, wxString sLabels = _T(""))
281
fSolfaCtrol = fValue;
282
if (sLabels != _T(""))
283
SetLabels(sLabels, &sSolfaLabel, &sStopSolfaLabel);
285
void SetControlSettings(bool fValue, wxString sKey =_T(""))
287
fSettingsLink = fValue;
291
void SetGoBackURL(wxString sURL) { fGoBackLink = true; sGoBackURL = sURL; }
294
bool fPlayCtrol; //Instert "Play" link
295
wxString sPlayLabel; //label for "Play" link
296
wxString sStopPlayLabel; //label for "Stop playing" link
298
bool fSolfaCtrol; //insert a "Sol-fa" link
299
wxString sSolfaLabel; //label for "Sol-fa" link
300
wxString sStopSolfaLabel; //label for "Stop sol-fa" link
303
bool fGoBackLink; // insert a "Go back to theory" link
304
wxString sGoBackURL; //URL for "Go back" link
306
bool fSettingsLink; // insert the settings link
307
wxString sSettingsKey; // key for saving the user settings
310
void SetLabels(wxString& sLabel, wxString* pStart, wxString* pStop);
317
// lmTheoScalesConstrains -------------------------------------------------------------
319
enum EProblemTheoScales
321
ePTS_DeduceScale = 0,
327
class lmTheoScalesConstrains
330
lmTheoScalesConstrains() {
331
m_fCtrolKeySignature = false;
332
m_fDrawWithoutKeySignature = true;
335
m_nProblemType = ePTS_Both;
337
~lmTheoScalesConstrains() {}
339
bool IsValidClef(EClefType nClef) { return m_oClefs.IsValid(nClef); }
340
void SetClef(EClefType nClef, bool fValid) { m_oClefs.SetValid(nClef, fValid); }
341
lmClefConstrain* GetClefConstrains() { return &m_oClefs; }
343
EProblemTheoScales GetProblemType() { return m_nProblemType; }
344
void SetProblemType(EProblemTheoScales nType) { m_nProblemType = nType; }
346
void SetMajorType(bool fValue) { m_fMajor = fValue; }
347
bool MajorType() { return m_fMajor; }
348
void SetMinorType(bool fValue) { m_fMinor = fValue; }
349
bool MinorType() { return m_fMinor; }
350
void SetCtrolKeySignature(bool fValue) { m_fCtrolKeySignature = fValue; }
351
bool CtrolKeySignature() { return m_fCtrolKeySignature; }
352
bool DrawWithoutKeySignature() { return m_fDrawWithoutKeySignature; }
355
bool m_fCtrolKeySignature;
356
bool m_fDrawWithoutKeySignature;
359
lmClefConstrain m_oClefs;
360
EProblemTheoScales m_nProblemType;
364
#endif // __CONSTRAINS_H__