1
//---------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2012 LenMus project
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.
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, see <http://www.gnu.org/licenses/>.
16
// For any comment, suggestion or feature request, please contact the manager of
17
// the project at cecilios@users.sourceforge.net
19
//---------------------------------------------------------------------------------------
21
#ifndef __LENMUS_COUNTERS_CTROL_H__
22
#define __LENMUS_COUNTERS_CTROL_H__
25
#include "lenmus_standard_header.h"
26
#include "lenmus_injectors.h"
29
#include <wx/wxprec.h>
32
#include <wx/bitmap.h>
35
#include <wx/statbmp.h>
36
#include <wx/string.h>
37
#include <wx/stattext.h>
38
#include <wx/gdicmn.h>
40
#include <wx/colour.h>
41
#include <wx/settings.h>
47
#include <lomse_internal_model.h>
48
#include <lomse_document.h>
49
#include <lomse_events.h>
50
#include <lomse_shape_text.h>
51
#include <lomse_control.h>
52
#include <lomse_static_text_ctrl.h>
53
using namespace lomse;
57
#include <lomse_hyperlink_ctrl.h>
58
using namespace lomse;
68
class ExerciseOptions;
71
//---------------------------------------------------------------------------------------
72
// CountersCtrol: an abstract control to embed in exercises for displaying
73
// statistics about user performance in doing the exercise
74
class CountersCtrol : public Control
77
ApplicationScope& m_appScope;
78
ExerciseCtrol* m_pOwner;
79
ExerciseOptions* m_pConstrains;
82
CountersCtrol(ApplicationScope& appScope, Document* pDoc,
83
ExerciseCtrol* pOwner, ExerciseOptions* pConstrains);
84
virtual ~CountersCtrol();
86
virtual void UpdateDisplay()=0;
87
virtual void OnNewQuestion() {}
89
//EventHandler mandatory overrides
90
virtual void handle_event(SpEventInfo pEvent) = 0;
93
void RightWrongSound(bool fSuccess);
96
void add_mode_controls(ImoContent* pWrapper);
97
void on_mode_changed(wxCommandEvent& WXUNUSED(event));
98
void change_generation_mode(int mode);
99
void change_generation_mode_label(int mode);
103
//---------------------------------------------------------------------------------------
104
// QuizCounters: a control to embed in exercises to display number of right and
105
// wrong student answers, in a session, and the total score (percentage)
106
class QuizCounters : public CountersCtrol
110
QuizManager* m_pProblemMngr;
111
bool m_fTwoTeamsMode;
114
GmoBoxControl* m_pMainBox;
115
StaticTextCtrl* m_pRightCounter[2];
116
StaticTextCtrl* m_pWrongCounter[2];
117
StaticTextCtrl* m_pTotalCounter[2];
127
wxImage* m_pImgTeam[2];
130
QuizCounters(ApplicationScope& appScope, Document* pDoc, ExerciseCtrol* pOwner,
131
ExerciseOptions* pConstrains, QuizManager* pProblemMngr, int nNumTeams);
134
//Control pure virtual methods implementation
136
LUnits width() { return m_size.width; }
137
LUnits height() { return m_size.height; }
138
LUnits top() { return m_pMainBox->get_top(); }
139
LUnits bottom() { return m_pMainBox->get_bottom(); }
140
LUnits left() { return m_pMainBox->get_left(); }
141
LUnits right() { return m_pMainBox->get_right(); }
142
GmoBoxControl* layout(LibraryScope& libraryScope, UPoint pos);
143
void on_draw(Drawer* pDrawer, RenderOptions& opt);
145
//CounterCtrol pure virtual methods implementation
146
void UpdateDisplay();
149
void OnNewQuestion();
150
void handle_event(SpEventInfo pEvent);
153
void ResetCounters();
157
static void on_reset_counters(void* pThis, SpEventInfo pEvent);
160
void UpdateDisplays(int nTeam);
161
void CreateCountersGroup(int nTeam, GmoBox* pMainBox, UPoint pos);
162
void reset_counters();
166
////---------------------------------------------------------------------------------------
167
//// LeitnerCounters: a control to embed in html exercises to display statistics
168
//// on user performance in learning the subject. It uses the Leitner system of
169
//// spaced repetitions
170
//class LeitnerCounters : public CountersCtrol
173
// LeitnerCounters(wxWindow* parent, wxWindowID id,
174
// ExerciseCtrol* pOwner, ExerciseOptions* pConstrains,
175
// LeitnerManager* pProblemMngr,
176
// const wxPoint& pos = wxDefaultPosition);
177
// ~LeitnerCounters();
180
// void OnExplainProgress(wxCommandEvent& WXUNUSED(event));
182
// //base class virtual methods implementation
183
// void UpdateDisplay();
187
// void CreateControls();
189
// LeitnerManager* m_pProblemMngr;
191
// ImoTextItem* m_pTxtNumQuestions;
192
// ImoTextItem* m_pLblEST;
193
// ImoTextItem* m_pTxtTime;
194
// ImoTextItem* m_pLblSession;
195
// ImoTextItem* m_pTxtSession;
196
// wxGauge* m_pGaugeSession;
197
// ImoTextItem* m_pLblGlobal;
198
// ImoTextItem* m_pTxtGlobal;
199
// wxGauge* m_pGaugeGlobal;
204
////---------------------------------------------------------------------------------------
205
//// PractiseCounters: a control to embed in html exercises to display statistics
206
//// on user performance in learning the subject. It uses the Leitner system in
208
//class PractiseCounters : public CountersCtrol
211
// PractiseCounters(wxWindow* parent, wxWindowID id,
212
// ExerciseCtrol* pOwner, ExerciseOptions* pConstrains,
213
// LeitnerManager* pProblemMngr,
214
// const wxPoint& pos = wxDefaultPosition);
215
// ~PractiseCounters();
218
// void OnResetCounters(wxCommandEvent& WXUNUSED(event));
220
// //base class virtual methods implementation
221
// void UpdateDisplay();
225
// void CreateControls();
227
// LeitnerManager* m_pProblemMngr;
229
// wxStaticBitmap* m_pImgWrong;
230
// ImoTextItem* m_pTxtWrong;
231
// wxStaticBitmap* m_pImgRight;
232
// ImoTextItem* m_pTxtRight;
233
// wxStaticBitmap* m_pImgTotal;
234
// ImoTextItem* m_pTxtTotal;
238
} // namespace lenmus
240
#endif // __LENMUS_COUNTERS_CTROL_H__