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 IdfyScalesCtrolParms.h
22
@brief Header file for class lmIdfyScalesCtrolParms
23
@ingroup html_controls
29
#ifndef __EARSCALESCTROLPARMS_H__ //to avoid nested includes
30
#define __EARSCALESCTROLPARMS_H__
32
// For compilers that support precompilation, includes "wx/wx.h".
33
#include "wx/wxprec.h"
43
#include "ObjectParams.h"
44
#include "../ldp_parser/AuxString.h"
45
#include "ParamsParser.h"
46
#include "../exercises/ScalesConstrains.h"
49
//! This class pack all parameters to set up a Scale Identification exercise,
50
//! The settings must be read/setup by the IdfyScalesCtrol object.
52
class lmIdfyScalesCtrolParms : public lmObjectParams
55
lmIdfyScalesCtrolParms(const wxHtmlTag& tag, int nWidth, int nHeight,
56
int nPercent, long nStyle);
57
~lmIdfyScalesCtrolParms();
59
void AddParam(const wxHtmlTag& tag);
60
void CreateHtmlCell(wxHtmlWinParser *pHtmlParser);
66
// html object window attributes
68
wxString m_sParamErrors;
69
lmScalesConstrains* m_pConstrains;
71
DECLARE_NO_COPY_CLASS(lmIdfyScalesCtrolParms)
76
lmIdfyScalesCtrolParms::lmIdfyScalesCtrolParms(const wxHtmlTag& tag, int nWidth, int nHeight,
77
int nPercent, long nStyle)
78
: lmObjectParams(tag, nWidth, nHeight, nPercent)
81
// html object window attributes
82
m_nWindowStyle = nStyle;
84
// construct constraints object
85
m_pConstrains = new lmScalesConstrains(_T("IdfyScale"));
88
m_sParamErrors = _T(""); //no errors
93
lmIdfyScalesCtrolParms::~lmIdfyScalesCtrolParms()
95
//Constrains and options will be deleted by the Ctrol. DO NOT DELETE THEM HERE
96
//IF THE CONTROL HAS BEEN CREATED
97
if (m_sParamErrors != _T("")) {
98
if (m_pConstrains) delete m_pConstrains;
103
void lmIdfyScalesCtrolParms::AddParam(const wxHtmlTag& tag)
105
/*! @page IdfyChordCtrolParams
108
Params for lmIdfyChordCtrol - html object type="Application/LenMusIdfyChord"
110
keys Keyword "all" or a list of allowed key signatures, i.e.: "Do,Fas"
113
scales Keyword "all" or a list of allowed scales:
114
m-minor, M-major, a-augmented, d-diminished, s-suspended
115
T-triad, dom-dominant, hd-half diminished
117
triads: mT, MT, aT, dT, s4, s2
118
sevenths: m7, M7, a7, d7, mM7, aM7 dom7, hd7
121
Default: "mT,MT,aT,dT,m7,M7"
123
mode 'theory' | 'earTraining' Keyword indicating type of exercise
125
play_mode* 'ascending | descending | both' allowed play modes. Default: ascending
127
show_key '0 | 1' Default: 0 (do not display key signature)
129
control_settings Value="[key for storing the settings]"
130
By coding this param it is forced the inclusion of
131
the 'settings' link. Its value will be used
132
as the key for saving the user settings.
135
------------------------------------
136
<object type="Application/LenMus" class="IdfyScale" width="100%" height="300" border="0">
137
<param name="mode" value="earTraining">
138
<param name="scales" value="mT,MT,aT,dT,m7,M7,dom7">
139
<param name="keys" value="all">
146
wxString sName = wxEmptyString;
147
wxString sValue = wxEmptyString;
149
// scan name and value
150
if (!tag.HasParam(wxT("NAME"))) return; // ignore param tag if no name attribute
151
sName = tag.GetParam(_T("NAME"));
152
sName.UpperCase(); //convert to upper case
154
if (!tag.HasParam(_T("VALUE"))) return; // ignore param tag if no value attribute
156
// show Key signature
157
else if ( sName == _T("SHOW_KEY") ) {
159
bool fOK = tag.GetParamAsInt(_T("VALUE"), &nValue);
161
m_sParamErrors += wxString::Format(
162
_("Invalid param value in:\n<param %s >\nAcceptable values: 1 | 0 \n"),
163
tag.GetAllParams() );
165
m_pConstrains->SetDisplayKey( nValue != 0 );
169
else if ( sName == _T("PLAY_MODE") ) {
170
wxString sMode = tag.GetParam(_T("VALUE"));
171
if (sMode == _T("ascending"))
172
m_pConstrains->SetPlayMode(0);
173
else if (sMode == _T("descending"))
174
m_pConstrains->SetPlayMode(1);
175
else if (sMode == _T("both"))
176
m_pConstrains->SetPlayMode(2);
178
m_sParamErrors += wxString::Format( wxGetTranslation(
179
_T("Invalid param value in:\n<param %s >\n")
180
_T("Invalid value = %s \n")
181
_T("Acceptable values: 'ascending | descending | both'\n")),
182
tag.GetAllParams(), sMode );
186
// chords Keyword "all" or a list of allowed chords:
187
else if ( sName == _T("SCALES") ) {
188
wxString sClef = tag.GetParam(_T("VALUE"));
189
m_sParamErrors += ParseChords(tag.GetParam(_T("VALUE")), tag.GetAllParams(),
190
m_pConstrains->GetValidScales());
193
// mode 'theory | earTraining' Keyword indicating type of exercise
194
else if ( sName == _T("MODE") ) {
195
wxString sMode = tag.GetParam(_T("VALUE"));
196
if (sMode == _T("theory"))
197
m_pConstrains->SetTheoryMode(true);
198
else if (sMode == _T("earTraining"))
199
m_pConstrains->SetTheoryMode(false);
201
m_sParamErrors += wxString::Format( wxGetTranslation(
202
_T("Invalid param value in:\n<param %s >\n")
203
_T("Invalid value = %s \n")
204
_T("Acceptable values: 'theory | earTraining'\n")),
205
tag.GetAllParams(), sMode );
209
//keys keyword "all" or a list of allowed key signatures, i.e.: "Do,Fas"
210
else if ( sName == _T("KEYS") ) {
211
m_sParamErrors += ParseKeys(tag.GetParam(_T("VALUE")), tag.GetAllParams(),
212
m_pConstrains->GetKeyConstrains());
216
else if ( sName == _T("CONTROL_SETTINGS") ) {
217
m_pConstrains->SetSettingsLink(true);
218
m_pConstrains->SetSection( tag.GetParam(_T("VALUE") ));
223
m_sParamErrors += wxString::Format(
224
_("lmIdfyScalesCtrol. Unknown param: <param %s >\n"),
225
tag.GetAllParams() );
229
void lmIdfyScalesCtrolParms::CreateHtmlCell(wxHtmlWinParser *pHtmlParser)
231
//inform about param errors or create the control
233
if (m_sParamErrors != _T("")) {
234
// there are errors: display a text box with the error message
235
pWnd = new wxTextCtrl((wxWindow*)pHtmlParser->GetWindowInterface()->GetHTMLWindow(), -1, m_sParamErrors,
236
wxPoint(0,0), wxSize(300, 100), wxTE_MULTILINE);
239
// create the IdfyScalesCtrol
240
pWnd = new lmIdfyScalesCtrol((wxWindow*)pHtmlParser->GetWindowInterface()->GetHTMLWindow(), -1,
241
m_pConstrains, wxPoint(0,0), wxSize(m_nWidth, m_nHeight), m_nWindowStyle );
244
pHtmlParser->GetContainer()->InsertCell(new wxHtmlWidgetCell(pWnd, m_nPercent));
248
#endif // __EARSCALESCTROLPARMS_H__