~s-cecilio/lenmus/trunk

627 by cecilios
cleaning and commit recent work
1
//---------------------------------------------------------------------------------------
2
//    LenMus Phonascus: The teacher of music
716 by Cecilio Salmeron
Changes to prepare a new release:
3
//    Copyright (c) 2010-2015 LenMus project
627 by cecilios
cleaning and commit recent work
4
//
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 3 of the License, or (at your option) any later version.
8
//
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.
12
//
13
//    You should have received a copy of the GNU General Public License along with this
14
//    program. If not, see <http://www.gnu.org/licenses/>.
15
//
16
//    For any comment, suggestion or feature request, please contact the manager of
17
//    the project at cecilios@users.sourceforge.net
18
//
19
//---------------------------------------------------------------------------------------
20
21
#ifndef __LENMUS_EXERCISE_CTROL_H__        //to avoid nested includes
22
#define __LENMUS_EXERCISE_CTROL_H__
23
24
//lenmus
634 by cecilios
starting eBooks conversion
25
#include "lenmus_standard_header.h"
627 by cecilios
cleaning and commit recent work
26
#include "lenmus_dyncontrol.h"
27
#include "lenmus_constrains.h"
634 by cecilios
starting eBooks conversion
28
#include "lenmus_counters_ctrol.h"
29
#include "lenmus_events.h"
627 by cecilios
cleaning and commit recent work
30
31
//wxWidgets
32
#include <wx/wxprec.h>
33
#include <wx/wx.h>
634 by cecilios
starting eBooks conversion
34
#include <wx/event.h>
627 by cecilios
cleaning and commit recent work
35
36
//lomse
37
#include <lomse_events.h>
634 by cecilios
starting eBooks conversion
38
#include <lomse_hyperlink_ctrl.h>
640 by cecilios
Fixed bug with tied notes in composer. Fixed memory leaks in FragmentsTable. Updates checker implemented.Language files reviewed.
39
#include <lomse_player_gui.h>
689 by Cecilio Salmeron
adding ButtonCtrl: checkpoint 1
40
#include <lomse_button_ctrl.h>
627 by cecilios
cleaning and commit recent work
41
using namespace lomse;
42
43
44
namespace lenmus
45
{
46
47
// forward declarations
48
class DocumentCanvas;
633 by cecilios
last work before vacation
49
class ProblemManager;
634 by cecilios
starting eBooks conversion
50
class CountersCtrol;
51
class ProblemDisplayer;
627 by cecilios
cleaning and commit recent work
52
53
54
//--------------------------------------------------------------------------------
55
// An abstract class for any kind of Ctrol included in an eBook.
656 by cecilios
initial commit with all changes for 5.1. See changelog
56
class EBookCtrol : public DynControl, public EventHandler, public PlayerNoGui
627 by cecilios
cleaning and commit recent work
57
{
58
protected:
634 by cecilios
starting eBooks conversion
59
    DocumentWindow*     m_pCanvas;
633 by cecilios
last work before vacation
60
    EBookCtrolOptions*  m_pBaseConstrains;
61
    ImoDynamic*         m_pDyn;
62
    Document*           m_pDoc;
63
    bool                m_fControlsCreated;
705 by Cecilio Salmeron
Continue development for suporting edition:
64
    int                 m_state;        //interal state (FSM)
706 by Cecilio Salmeron
Integrate Lomsein Lenmus tree, to simplify build process
65
    ImoId               m_dynId;
627 by cecilios
cleaning and commit recent work
66
634 by cecilios
starting eBooks conversion
67
    EBookCtrol(long dynId, ApplicationScope& appScope, DocumentWindow* pCanvas);
627 by cecilios
cleaning and commit recent work
68
69
public:
70
    virtual ~EBookCtrol();
71
72
    //implementation of virtual pure in parent DynControl
73
    void generate_content(ImoDynamic* pDyn, Document* pDoc);
634 by cecilios
starting eBooks conversion
74
    virtual void handle_event(SpEventInfo pEvent);
627 by cecilios
cleaning and commit recent work
75
76
    virtual void get_ctrol_options_from_params() = 0;
77
    virtual void initialize_ctrol() = 0;
78
705 by Cecilio Salmeron
Continue development for suporting edition:
79
    //virtual pure event handlers to be implemented by derived classes
633 by cecilios
last work before vacation
80
    virtual void on_debug_show_source_score()=0;
81
    virtual void on_debug_show_midi_events()=0;
627 by cecilios
cleaning and commit recent work
82
705 by Cecilio Salmeron
Continue development for suporting edition:
83
    //event handlers. No need to implement in derived classes
627 by cecilios
cleaning and commit recent work
84
    virtual void on_settings_button();
633 by cecilios
last work before vacation
85
    virtual void on_go_back();
627 by cecilios
cleaning and commit recent work
86
656 by cecilios
initial commit with all changes for 5.1. See changelog
87
    //overrides of PlayerNoGui for using general metronome for speed settings
88
    int get_metronome_mm();
664 by cecilios
BooksDlg: fixed link to study guide. EBookCtrol fix: override get_metronome() method so that ScorePlayer has access to global metronome. Fix error in CMakeList (reported by mta'chrono)
89
    Metronome* get_metronome();
656 by cecilios
initial commit with all changes for 5.1. See changelog
90
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
91
    //access to parent window
92
    wxWindow* get_parent_window();
93
627 by cecilios
cleaning and commit recent work
94
protected:
95
    //virtual methods to be implemented by derived classes
96
    virtual void initialize_strings()=0;
97
    virtual wxDialog* get_settings_dialog()=0;
633 by cecilios
last work before vacation
98
    virtual void on_settings_changed()=0;
627 by cecilios
cleaning and commit recent work
99
100
private:
634 by cecilios
starting eBooks conversion
101
//    void do_stop_sounds();
627 by cecilios
cleaning and commit recent work
102
};
103
104
105
106
//---------------------------------------------------------------------------------------
107
// An abstract class for any kind of exercise included in an eBook.
108
class ExerciseCtrol : public EBookCtrol
109
{
110
protected:
634 by cecilios
starting eBooks conversion
111
    ExerciseCtrol(long dynId, ApplicationScope& appScope, DocumentWindow* pCanvas);
627 by cecilios
cleaning and commit recent work
112
113
public:
114
    virtual ~ExerciseCtrol();
115
116
    //mandatory override for EventHandler
634 by cecilios
starting eBooks conversion
117
    virtual void handle_event(SpEventInfo pEvent);
627 by cecilios
cleaning and commit recent work
118
705 by Cecilio Salmeron
Continue development for suporting edition:
119
    //event handlers. No need to implement in derived classes
627 by cecilios
cleaning and commit recent work
120
    virtual void on_resp_button(int iButton);
121
    virtual void on_new_problem();
122
    virtual void on_display_solution();
638 by cecilios
Support for playing scores added to DocumentCanvas
123
    virtual void on_button_mouse_in(SpEventMouse pEvent);
124
    virtual void on_button_mouse_out(SpEventMouse pEvent);
634 by cecilios
starting eBooks conversion
125
126
    //other
127
    virtual void OnQuestionAnswered(int iQ, bool fSuccess);
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
128
    inline int get_generation_mode() { return m_nGenerationMode; }
129
    void change_generation_mode(int nMode);
634 by cecilios
starting eBooks conversion
130
    static void on_exercise_activated(void* pThis, SpEventInfo pEvent);
627 by cecilios
cleaning and commit recent work
131
132
133
protected:
134
    //virtual methods to be implemented by derived classes
135
    virtual void create_answer_buttons(LUnits height, LUnits spacing) = 0;
136
    virtual wxString set_new_problem()=0;
705 by Cecilio Salmeron
Continue development for suporting edition:
137
    virtual void play(bool fVisualTracking=true)=0;
138
    virtual void stop_sounds()=0;
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
139
    virtual void play_specific_sound(int nButton)=0;
627 by cecilios
cleaning and commit recent work
140
    virtual void display_solution()=0;
634 by cecilios
starting eBooks conversion
141
    virtual void display_problem_score()=0;
627 by cecilios
cleaning and commit recent work
142
    virtual void delete_scores()=0;
633 by cecilios
last work before vacation
143
    virtual void set_problem_space()=0;
627 by cecilios
cleaning and commit recent work
144
705 by Cecilio Salmeron
Continue development for suporting edition:
145
    //methods that, normally, it is not necessary to override in derived classes
627 by cecilios
cleaning and commit recent work
146
    virtual void set_button_color(int i, Color color);
147
    virtual void enable_buttons(bool fEnable);
148
    virtual void new_problem();
149
    virtual void reset_exercise();
633 by cecilios
last work before vacation
150
    virtual void set_event_handlers();
640 by cecilios
Fixed bug with tied notes in composer. Fixed memory leaks in FragmentsTable. Updates checker implemented.Language files reviewed.
151
    virtual void create_problem_display_box(ImoContent* pWrapper, ImoStyle* pStyle=NULL);
694 by Cecilio Salmeron
Chinese translation and bug fixes.
152
    virtual bool is_play_button_initially_enabled();
705 by Cecilio Salmeron
Continue development for suporting edition:
153
    virtual bool check_success(int nButton);
154
    virtual void display_first_time_content();
155
    virtual string get_initial_msge();
627 by cecilios
cleaning and commit recent work
156
157
    //methods invoked from derived classes
158
    virtual void create_controls();
690 by cecilios, ilizaran
159
    void set_buttons(ButtonCtrl* pButton[], int nNumButtons);
627 by cecilios
cleaning and commit recent work
160
633 by cecilios
last work before vacation
161
    //internal methods
634 by cecilios
starting eBooks conversion
162
    CountersCtrol* create_counters_ctrol(ImoContent* pWrapper);
633 by cecilios
last work before vacation
163
    void create_problem_manager();
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
164
    void change_from_learning_to_practising();
694 by Cecilio Salmeron
Chinese translation and bug fixes.
165
    void display_initial_msge();
705 by Cecilio Salmeron
Continue development for suporting edition:
166
    void create_display_and_counters();
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
167
168
    //helper
169
    inline bool is_learning_mode() { return m_nGenerationMode == k_learning_mode; }
694 by Cecilio Salmeron
Chinese translation and bug fixes.
170
    inline bool is_solution_displayed() { return m_fSolutionDisplayed; }
171
    inline bool is_theory_mode() {
172
        return (static_cast<ExerciseOptions*>( m_pBaseConstrains ))->is_theory_mode();
173
    }
627 by cecilios
cleaning and commit recent work
174
634 by cecilios
starting eBooks conversion
175
    //wrappers for event handlers
176
    static void on_new_problem(void* pThis, SpEventInfo pEvent);
177
    static void on_play_event(void* pThis, SpEventInfo pEvent);
639 by cecilios
Fixed error msg in dlg_ear_intervals. Other changes needed for compatibility with lomse changes. Added debug option for drawing spacers.
178
    //static void on_end_of_play_event(void* pThis, SpEventInfo pEvent);
634 by cecilios
starting eBooks conversion
179
    static void on_display_solution(void* pThis, SpEventInfo pEvent);
180
    static void on_settings(void* pThis, SpEventInfo pEvent);
181
    static void on_see_source_score(void* pThis, SpEventInfo pEvent);
182
    static void on_see_midi_events(void* pThis, SpEventInfo pEvent);
183
    static void on_go_back_event(void* pThis, SpEventInfo pEvent);
184
185
    void change_counters_ctrol();
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
186
    void remove_counters_ctrol();
634 by cecilios
starting eBooks conversion
187
627 by cecilios
cleaning and commit recent work
188
189
        // member variables
190
191
    //display control variables
634 by cecilios
starting eBooks conversion
192
    ImoScore*       m_pScoreToPlay;
193
    ProblemDisplayer* m_pDisplay;
627 by cecilios
cleaning and commit recent work
194
634 by cecilios
starting eBooks conversion
195
    CountersCtrol*  m_pCounters;
196
    bool            m_fCountersValid;   //when changing mode counters might not be valid
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
197
    ImoContent*     m_pCountersWrapper;
198
    ImoParagraph*   m_pCountersPara;
199
627 by cecilios
cleaning and commit recent work
200
    bool                m_fQuestionAsked;   //question asked but not yet answered
201
    int                 m_nRespIndex;       //index to the button with the right answer
202
    int                 m_nRespAltIndex;    //alternative right answer (i.e. enarmonic answer)
203
204
    wxString            m_sAnswer;          //string with the right answer
694 by Cecilio Salmeron
Chinese translation and bug fixes.
205
    bool                m_fSolutionDisplayed;
627 by cecilios
cleaning and commit recent work
206
705 by Cecilio Salmeron
Continue development for suporting edition:
207
    HyperlinkCtrl*     m_pPlayButton;      // "play" button
634 by cecilios
starting eBooks conversion
208
    HyperlinkCtrl*     m_pNewProblem;      //"New problem" link
209
    HyperlinkCtrl*     m_pShowSolution;    //"Show solution" link
633 by cecilios
last work before vacation
210
627 by cecilios
cleaning and commit recent work
211
    int                 m_nNumButtons;      //num answer buttons
690 by cecilios, ilizaran
212
    ButtonCtrl**        m_pAnswerButtons;   //buttons for the answers
627 by cecilios
cleaning and commit recent work
213
    long                m_nIdFirstButton;   //ID of first button; the others in sequence
214
633 by cecilios
last work before vacation
215
    //to generate problems
216
    int                     m_nGenerationMode;
634 by cecilios
starting eBooks conversion
217
    int                     m_nProblemLevel;
218
    ProblemManager*         m_pProblemManager;
219
    int                     m_iQ;               //index of asked question
633 by cecilios
last work before vacation
220
    wxString                m_sKeyPrefix;
634 by cecilios
starting eBooks conversion
221
222
    //to measure times
223
    wxDateTime              m_tmAsked;      //when was asked last question
627 by cecilios
cleaning and commit recent work
224
225
private:
634 by cecilios
starting eBooks conversion
226
//    void do_stop_sounds();
627 by cecilios
cleaning and commit recent work
227
    void do_display_solution();
228
229
};
230
231
634 by cecilios
starting eBooks conversion
232
//---------------------------------------------------------------------------------------
233
// Abstract class to create exercise to compare scores/sounds
234
class CompareCtrol : public ExerciseCtrol
235
{
236
public:
237
238
    // constructor and destructor
239
    CompareCtrol(long dynId, ApplicationScope& appScope, DocumentWindow* pCanvas);
240
    virtual ~CompareCtrol();
241
242
    enum {
243
        k_num_rows = 1,
244
        k_num_cols = 3,
245
        k_num_buttons = 3,
246
        m_ID_BUTTON = 3010,
247
    };
248
249
250
protected:
251
    //virtual methods implemented in this class
252
    void create_answer_buttons(LUnits height, LUnits spacing);
253
    virtual void initialize_strings();
254
255
protected:
256
    // member variables
690 by cecilios, ilizaran
257
    ButtonCtrl*     m_pAnswerButton[k_num_buttons];   //buttons for the answers
634 by cecilios
starting eBooks conversion
258
259
};
260
261
262
//---------------------------------------------------------------------------------------
263
// Abstract class to create exercise to compare two scores
639 by cecilios
Fixed error msg in dlg_ear_intervals. Other changes needed for compatibility with lomse changes. Added debug option for drawing spacers.
264
class CompareScoresCtrol : public wxEvtHandler, public CompareCtrol
634 by cecilios
starting eBooks conversion
265
{
266
public:
267
268
    // constructor and destructor
269
    CompareScoresCtrol(long dynId, ApplicationScope& appScope, DocumentWindow* pCanvas);
270
    virtual ~CompareScoresCtrol();
271
272
    //implementation of virtual event handlers
273
    virtual void on_debug_show_source_score();
274
    virtual void on_debug_show_midi_events();
639 by cecilios
Fixed error msg in dlg_ear_intervals. Other changes needed for compatibility with lomse changes. Added debug option for drawing spacers.
275
    virtual void on_end_of_playback();
634 by cecilios
starting eBooks conversion
276
277
protected:
278
    //implementation of some virtual methods
656 by cecilios
initial commit with all changes for 5.1. See changelog
279
    void play(bool fVisualTracking=true);
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
280
    void play_specific_sound(int nButton) {}
634 by cecilios
starting eBooks conversion
281
    void display_solution();
282
    void display_problem_score();
283
    void delete_scores();
284
    void stop_sounds();
285
286
287
protected:
288
    // wxWidgets event handlers
289
    void on_timer_event(wxTimerEvent& WXUNUSED(event));
290
291
    ScorePlayer*    m_pPlayer;
292
    ImoScore*       m_pScore[2];        //the two problem scores
293
    int             m_nNowPlaying;      //score being played (0, 1)
294
    wxTimer         m_oPauseTimer;      //timer to do a pause between the two scores
295
    ImoScore*       m_pSolutionScore;   //solution score
296
    int             m_nPlayMM;          //metronome setting to play the scores
297
    bool            m_fPlayingProblem;  //currently playing the score (might be waiting for timer event)
298
299
private:
656 by cecilios
initial commit with all changes for 5.1. See changelog
300
    void PlayScore(int nIntv, bool fVisualTracking);
634 by cecilios
starting eBooks conversion
301
716 by Cecilio Salmeron
Changes to prepare a new release:
302
    wxDECLARE_CLASS(CompareScoresCtrol);
634 by cecilios
starting eBooks conversion
303
};
627 by cecilios
cleaning and commit recent work
304
305
//---------------------------------------------------------------------------------------
306
// Abstract class to create exercises with one problem score
307
class OneScoreCtrol : public ExerciseCtrol
308
{
309
protected:
634 by cecilios
starting eBooks conversion
310
    OneScoreCtrol(long dynId, ApplicationScope& appScope, DocumentWindow* pCanvas);
627 by cecilios
cleaning and commit recent work
311
312
public:
313
    virtual ~OneScoreCtrol();
314
633 by cecilios
last work before vacation
315
    //implementation of virtual event handlers
316
    virtual void on_debug_show_source_score();
317
    virtual void on_debug_show_midi_events();
639 by cecilios
Fixed error msg in dlg_ear_intervals. Other changes needed for compatibility with lomse changes. Added debug option for drawing spacers.
318
    virtual void on_end_of_playback();
627 by cecilios
cleaning and commit recent work
319
320
protected:
321
322
    //virtual pure methods defined in this class
694 by Cecilio Salmeron
Chinese translation and bug fixes.
323
    virtual ImoScore* prepare_aux_score(int nButton)=0;
324
    virtual bool are_answer_buttons_allowed_for_playing();
325
    virtual bool is_play_again_message_allowed();
326
    virtual bool remove_problem_text_when_displaying_solution();
627 by cecilios
cleaning and commit recent work
327
328
    //implementation of some virtual methods
656 by cecilios
initial commit with all changes for 5.1. See changelog
329
    virtual void play(bool fVisualTracking=true);
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
330
    void play_specific_sound(int nButton);
627 by cecilios
cleaning and commit recent work
331
    void display_solution();
634 by cecilios
starting eBooks conversion
332
    void display_problem_score();
627 by cecilios
cleaning and commit recent work
333
    void delete_scores();
334
    void stop_sounds();
335
336
        // member variables
337
338
    ScorePlayer* m_pPlayer;
339
    ImoScore*   m_pProblemScore;    //score with the problem
340
	ImoScore*   m_pSolutionScore;	//if not NULL, score with the solution. If NULL
341
                                    //   problem score will be used as solution score
342
    ImoScore*   m_pAuxScore;        //score to play user selected buttons
343
    int         m_nPlayMM;          //metronome setting to play scores
344
};
345
346
////---------------------------------------------------------------------------------------
347
//// Abstract class to create exercises to compare two Midi pitches
348
//class CompareMidiCtrol : public CompareCtrol
349
//{
350
//public:
634 by cecilios
starting eBooks conversion
351
//    CompareMidiCtrol(long dynId, ApplicationScope& appScope, DocumentCanvas* pCanvas);
627 by cecilios
cleaning and commit recent work
352
//    virtual ~CompareMidiCtrol();
353
//
354
//    // event handlers
355
//    void OnTimerEvent(wxTimerEvent& WXUNUSED(event));
356
//
357
//    //implementation of virtual event handlers
633 by cecilios
last work before vacation
358
//    virtual void on_debug_show_source_score() {}
359
//    virtual void on_debug_show_midi_events() {}
627 by cecilios
cleaning and commit recent work
360
//
361
//protected:
362
//    //implementation of some virtual methods
363
//    virtual void play();
683 by Cecilio Salmeron
Added script po-statistics.pl to maintain website translations page. * Restored exercise modes (learning, practise, exam and quiz). * Added DlgExerciseMode. * Restored right/wrong sounds when answering an exercise. * Fixed bug #1074909. * Fixed bug #1082637.
364
//    void play_specific_sound(int nButton) {}
627 by cecilios
cleaning and commit recent work
365
//    void display_solution();
634 by cecilios
starting eBooks conversion
366
//    void display_problem_score();
627 by cecilios
cleaning and commit recent work
367
//    void delete_scores() {}
368
//    void stop_sounds();
369
//
370
//protected:
371
//    void PlaySound(int iSound);
372
//
373
//
374
//        // member variables
375
//
633 by cecilios
last work before vacation
376
//    MidiPitch            m_mpPitch[2];
627 by cecilios
cleaning and commit recent work
377
//    int                 m_nChannel[2];
378
//    int                 m_nInstr[2];
379
//    long                m_nTimeIntval[2];   //interval between first and second pitch
380
//    bool                m_fStopPrev;        //stop previous pitch when sounding the next pitch
381
//
382
//    wxTimer             m_oTimer;           //timer to control sounds' duration
383
//    int                 m_nNowPlaying;      //pitch number being played or -1
384
//};
705 by Cecilio Salmeron
Continue development for suporting edition:
385
386
387
//---------------------------------------------------------------------------------------
388
// Abstract class for any kind of exercise using the score editor
389
class FullEditorCtrol : public EBookCtrol
390
{
391
protected:
392
    ExerciseOptions* m_pConstrains;
393
394
    //the scores
395
    ImoScore* m_pProblemScore;  //(opt) the problem (aural training)
396
    ImoScore* m_pContextScore;  //(opt) to play before problem, to create pitch/tonality context
397
    ImoScore* m_pUserScore;     //the one to be displayed and edited by student
398
399
    //score player and its settings
400
    ScorePlayer* m_pPlayer;
401
    int m_nPlayMM;              //metronome setting to play scores
402
    int m_midiVoice;            //instrument to use for playing scores
403
404
    //display control variables
706 by Cecilio Salmeron
Integrate Lomsein Lenmus tree, to simplify build process
405
    ImoScore*           m_pUserScoreToPlay;
406
    ImoScore*           m_pProblemScoreToPlay;
407
    ProblemDisplayer*   m_pDisplay;
705 by Cecilio Salmeron
Continue development for suporting edition:
408
409
    //action buttons
706 by Cecilio Salmeron
Integrate Lomsein Lenmus tree, to simplify build process
410
    HyperlinkCtrl*  m_pPlayProblem;     //"Play problem again" button
411
    HyperlinkCtrl*  m_pPlayUserScore;   //"Play my solution" button
412
    HyperlinkCtrl*  m_pNewProblem;      //"New problem" link
413
    HyperlinkCtrl*  m_pDoneButton;      //"Done" link
705 by Cecilio Salmeron
Continue development for suporting edition:
414
415
    //other
416
    int m_numTimesProblemPlayed;
417
418
    //pre-translated strings for button labels
419
    string m_label_new_problem;
420
    string m_label_play_problem;
421
    string m_label_done;
422
    string m_label_play_user_score;
423
    string m_label_stop_playing;
424
425
    FullEditorCtrol(long dynId, ApplicationScope& appScope, DocumentWindow* pCanvas);
426
427
public:
428
    virtual ~FullEditorCtrol();
429
430
    //implementation of virtual pure in parent EBookCtrol
431
    virtual void on_debug_show_source_score();
432
    virtual void on_debug_show_midi_events();
433
434
    //specific
435
436
    //event handlers. No need to implement in derived classes
437
    virtual void on_end_of_playback();
438
439
protected:
440
    //virtual methods to be implemented by derived classes
441
    virtual wxString generate_new_problem()=0;
442
    virtual void do_correct_exercise()=0;
443
    virtual void delete_specific_scores()=0;
444
445
    //overridable, for changing default exercise layout
446
    ImoStyle* m_pLinksSpacerStyle;
447
    virtual void layout_exercise();
448
    virtual void add_settings_goback_and_debug_links(ImoParagraph* pContainer,
449
                                                     ImoStyle* pSpacerStyle=NULL);
450
    virtual void add_new_problem_link(ImoParagraph* pContainer, ImoStyle* pSpacerStyle=NULL);
451
    virtual void add_play_problem_link(ImoParagraph* pContainer, ImoStyle* pSpacerStyle=NULL);
452
    virtual void add_done_link(ImoParagraph* pContainer, ImoStyle* pSpacerStyle=NULL);
453
    virtual void add_play_solution_link(ImoParagraph* pContainer, ImoStyle* pSpacerStyle=NULL);
454
    virtual void add_optional_content_block_1() {}
455
    virtual void add_optional_content_block_2() {}
456
457
    //methods that, normally, it is not necessary to override in derived classes
458
    virtual void process_event(int event);
459
    virtual void new_problem();
460
    virtual void initial_play_of_problem();
461
    virtual void reset_exercise();
462
    virtual void correct_exercise();
463
    virtual void create_problem_display_box(ImoContent* pWrapper, ImoStyle* pStyle=NULL);
464
    virtual void enable_links_for_current_state();
465
466
    void create_controls();
467
    void display_user_score();
468
    void enable_edition();
469
    void disable_edition();
470
    void play_or_stop_user_score();
471
    void play_or_stop_problem(bool fDoCountOff=false);
472
    void do_play_problem(bool fDoCountOff);
473
    void stop_sounds();
474
    void delete_scores();
475
    void mover_cursor_to_end();
476
    void change_state(int newState);
477
478
    //events
479
    enum {
480
        k_click_new_problem=0,
481
        k_click_play_or_stop_problem,
482
        k_click_done,
483
        k_click_play_or_stop_user_score,
484
        k_end_of_playback,
485
        //
486
        k_first_unused_event,
487
    };
488
489
    //exercise states
490
    enum {
491
        k_state_start=0,            //user has entered in exercise page
492
        k_state_playing_problem,    //program is playing the problem score
493
        k_state_ready,              //user can start solving the problem
494
        k_state_solution,           //solution is displayed
495
        k_state_playing_user,       //program is playing user solution
496
        k_state_replaying_problem,  //program is playing again problem score
497
498
        k_state_first_unused
499
    };
500
501
502
    //helper
503
//    inline bool is_solution_displayed() { return m_fSolutionDisplayed; }
504
    inline bool is_theory_mode() {
505
        return (static_cast<ExerciseOptions*>( m_pBaseConstrains ))->is_theory_mode();
506
    }
507
508
    //wrappers for event handlers
509
    static void on_new_problem(void* pThis, SpEventInfo pEvent);
510
    static void on_play_problem(void* pThis, SpEventInfo pEvent);
511
    static void on_play_user_score(void* pThis, SpEventInfo pEvent);
512
    static void on_correct_exercise(void* pThis, SpEventInfo pEvent);
513
    static void on_settings(void* pThis, SpEventInfo pEvent);
514
    static void on_see_source_score(void* pThis, SpEventInfo pEvent);
515
    static void on_see_midi_events(void* pThis, SpEventInfo pEvent);
516
    static void on_go_back_event(void* pThis, SpEventInfo pEvent);
517
};
627 by cecilios
cleaning and commit recent work
518
519
520
}   //namespace lenmus
521
522
#endif  // __LENMUS_EXERCISE_CTROL_H__