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_MAIN_FRAME_H__ //to avoid nested includes
22
#define __LENMUS_MAIN_FRAME_H__
25
#include "lenmus_standard_header.h"
26
#include "lenmus_injectors.h"
27
#include "lenmus_canvas.h"
28
#include "lenmus_test_runner.h"
29
#include "lenmus_dlg_debug.h"
30
#include "lenmus_events.h"
31
#include "lenmus_metronome.h"
34
#include "wx/wxprec.h"
38
#include <wx/msgdlg.h>
39
#include <wx/filedlg.h>
42
#include <wx/dcmemory.h>
44
//#include <wx/stopwatch.h>
45
#include <wx/aui/aui.h>
46
//#include <wx/timer.h> //to use wxTimer
47
#include <wx/spinctrl.h> //to use spin control
48
#include <wx/combobox.h> //to use comboBox control
49
#include <wx/docview.h> //to use wxFileHistory
52
class wxPageSetupDialogData;
56
#include <lomse_doorway.h>
57
#include <lomse_document.h>
58
#include <lomse_graphic_view.h>
59
#include <lomse_interactor.h>
60
#include <lomse_presenter.h>
61
#include <lomse_events.h>
62
#include <lomse_internal_model.h>
63
#include <lomse_analyser.h>
64
#include "lomse_player_gui.h"
65
using namespace lomse;
69
#include <UnitTest++.h>
82
class GlobalMetronome;
85
DECLARE_EVENT_TYPE(LM_EVT_CHECK_FOR_UPDATES, -1)
86
DECLARE_EVENT_TYPE(LM_EVT_OPEN_BOOK, -1)
88
//public identifiers for commands/events sent to MainFrame
90
k_id_check_for_updates = 10000,
93
k_menu_last_public_id,
96
//---------------------------------------------------------------------------------------
97
// Define the main frame for the GUI
98
class MainFrame : public ContentFrame, public PlayerGui
101
ApplicationScope& m_appScope;
102
wxAuiManager m_layoutManager;
103
string m_lastOpenFile; //path for currently open file
110
// //controllers, special windows, and other controls
111
// lmToolBox* m_pToolBox; //tool box window
112
Canvas* m_pWelcomeWnd; //welcome window
113
// lmHtmlWindow* m_pHtmlWin;
114
wxSpinCtrl* m_pSpinMetronome;
115
wxComboBox* m_pComboZoom;
117
GlobalMetronome* m_pMainMtr; //independent metronome
118
GlobalMetronome* m_pMtr; //metronome currently associated to frame metronome controls
120
// //flags for toggle buttons/menus
121
// bool m_fHelpOpened;
124
wxToolBar* m_pToolbar; // main toolbar
125
wxToolBar* m_pTbFile; // file toolbar
126
wxToolBar* m_pTbEdit; // edit toolbar
127
wxToolBar* m_pTbZoom; // zoom toolbar
128
wxToolBar* m_pTbPlay; // play toolbar
129
wxToolBar* m_pTbMtr; // metronome toolbar
130
wxToolBar* m_pTbTextBooks; // text books navigation toolbar
133
StatusBar* m_pStatusBar;
135
// bool m_fClosingAll;
137
//to remember print settings during the session
138
wxPrintData* m_pPrintData;
139
wxPageSetupDialogData* m_pPageSetupData;
142
wxFileHistory m_fileHistory;
145
MainFrame(ApplicationScope& appScope, const wxPoint& pos = wxDefaultPosition,
146
const wxSize& size = wxDefaultSize);
147
virtual ~MainFrame();
149
void create_controls();
150
void run_midi_wizard();
151
void show_welcome_window();
154
static void wrapper_lomse_event(void* pThis, SpEventInfo pEvent);
155
static void wrapper_lomse_request(void* pThis, Request* pRequest);
157
//commands from other places
158
void update_toolbars_layout();
163
void add_new_panel(wxWindow* window, const wxString& caption,
164
const wxPoint& pos = wxDefaultPosition);
166
//mandatory overrides from PlayerGui
167
void on_end_of_playback();
169
int get_metronome_mm();
170
Metronome* get_metronome();
171
bool countoff_status();
172
bool metronome_status();
175
void disable_tool(wxUpdateUIEvent &event);
176
void save_preferences();
177
void create_metronome();
180
void set_lomse_callbacks();
181
void load_file(const string& filename);
182
Interactor* get_active_canvas_interactor();
183
ImoScore* get_active_score();
184
DocumentWindow* get_active_document_window();
185
DocumentFrame* get_active_document_frame();
187
//for serving lomse requests
188
void generate_dynamic_content(RequestDynamic* pRequest);
189
void get_font_filename(RequestFont* pRequest);
192
void zoom_to(double scale);
195
void on_lomse_event(SpEventInfo pEvent);
196
void on_lomse_request(Request* pRequest);
198
// wxLocale* m_pLocale; // locale for internationalization
201
bool is_welcome_page_displayed();
204
void show_toolbars_if_user_preferences();
205
void create_toolbars();
206
void delete_toolbars();
207
// void CreateTextBooksToolBar(long style, wxSize nIconSize, int nRow);
210
void create_menu_item(wxMenu* pMenu, int nId, const wxString& sItemName,
211
const wxString& sToolTip = _T(""),
212
wxItemKind nKind = wxITEM_NORMAL,
213
const wxString& sIconName = _T("empty") );
216
void show_status_bar_if_user_preferences();
217
void create_status_bar(int nType=0);
218
void delete_status_bar();
219
// void SetStatusBarMsg(const wxString& sText);
220
// void SetStatusBarMouseData(int nPage, float rTime, int nMeasure, lmUPoint uPos);
221
// void SetStatusBarCaretData(int nPage, float rTime, int nMeasure);
224
// inline lmToolBox* GetActiveToolBox() { return m_pToolBox; }
225
// bool IsToolBoxVisible();
226
// void ShowToolBox(bool fShow);
229
// void SetMetronome(GlobalMetronome* pMtr);
230
// GlobalMetronome* GetMetronome() { return m_pMtr; }
233
void on_file_quit(wxCommandEvent& event);
234
void on_file_open(wxCommandEvent& WXUNUSED(event));
235
void on_file_reload(wxCommandEvent& WXUNUSED(event));
236
// void OnFileClose(wxCommandEvent& event);
237
// void OnFileSave(wxCommandEvent& event);
238
// void OnFileSaveAs(wxCommandEvent& event);
239
// void OnScoreWizard(wxCommandEvent& WXUNUSED(event));
240
// void OnFileImport(wxCommandEvent& WXUNUSED(event));
241
// void OnExportMusicXML(wxCommandEvent& WXUNUSED(event));
242
// void OnExportBMP(wxCommandEvent& WXUNUSED(event));
243
// void OnExportJPG(wxCommandEvent& WXUNUSED(event));
244
void on_print_setup(wxCommandEvent& WXUNUSED(event));
245
void on_print(wxCommandEvent& WXUNUSED(event));
246
void on_update_UI_file(wxUpdateUIEvent& event);
247
void on_open_recent_file(wxCommandEvent& event);
248
void on_open_book(wxCommandEvent& event);
249
// void ExportAsImage(int nImgType);
252
// // Edit menu events
253
// void OnEditCut(wxCommandEvent& event);
254
// void OnEditCopy(wxCommandEvent& event);
255
// void OnEditPaste(wxCommandEvent& event);
256
// void OnEditUpdateUI(wxUpdateUIEvent& event);
258
// // Score Menu events
259
// void OnScoreTitles(wxCommandEvent& WXUNUSED(event));
261
// // Instrument menu events
262
// void OnInstrumentProperties(wxCommandEvent& WXUNUSED(event));
265
#if (LENMUS_DEBUG_MENU == 1)
266
void on_do_tests(wxCommandEvent& WXUNUSED(event));
267
void on_see_paths(wxCommandEvent& WXUNUSED(event));
268
void on_debug_draw_box(wxCommandEvent& event);
269
void on_debug_justify_systems(wxCommandEvent& event);
270
void on_debug_dump_column_tables(wxCommandEvent& event);
271
void on_debug_force_release_behaviour(wxCommandEvent& event);
272
void on_debug_show_debug_links(wxCommandEvent& event);
273
// void OnDebugShowBorderOnScores(wxCommandEvent& event);
274
// void OnDebugRecSelec(wxCommandEvent& event);
275
// void OnDebugDrawBounds(wxCommandEvent& event);
276
void on_debug_draw_anchors(wxCommandEvent& event);
277
// void OnDebugTestMidi(wxCommandEvent& event);
278
// void OnDebugSetTraceLevel(wxCommandEvent& WXUNUSED(event));
279
// void OnDebugPatternEditor(wxCommandEvent& WXUNUSED(event));
280
// void OnDebugUnitTests(wxCommandEvent& event);
281
// void OnDebugShowDirtyObjects(wxCommandEvent& event);
282
// // methods requiring a score
283
// void OnDebugCheckHarmony(wxCommandEvent& WXUNUSED(event));
284
// void OnDebugDumpBitmaps(wxCommandEvent& event);
285
void on_debug_dump_gmodel(wxCommandEvent& WXUNUSED(event));
286
void on_debug_see_midi_events(wxCommandEvent& WXUNUSED(event));
287
void on_debug_see_ldp_source(wxCommandEvent& WXUNUSED(event));
288
void on_debug_see_lmd_source(wxCommandEvent& WXUNUSED(event));
289
void on_debug_see_staffobjs(wxCommandEvent& WXUNUSED(event));
290
// void on_debug_see_sourceForUndo(wxCommandEvent& event);
291
// void OnDebugSeeXML(wxCommandEvent& event);
292
// void OnDebugTestProcessor(wxCommandEvent& WXUNUSED(event));
293
// void OnDebugScoreUI(wxUpdateUIEvent& event);
294
void on_debug_print_preview(wxCommandEvent& WXUNUSED(event));
297
void on_update_UI_score(wxUpdateUIEvent &event);
298
void on_update_UI_document(wxUpdateUIEvent &event);
301
void on_combo_zoom(wxCommandEvent& event);
302
void on_zoom_100(wxCommandEvent& WXUNUSED(event)) { zoom_to(1.0); }
303
void on_zoom_fit_width(wxCommandEvent& event);
304
void on_zoom_fit_full(wxCommandEvent& event);
305
void on_zoom_other(wxCommandEvent& event);
306
void on_zoom_in(wxCommandEvent& WXUNUSED(event));
307
void on_zoom_out(wxCommandEvent& WXUNUSED(event));
308
void on_update_UI_zoom(wxUpdateUIEvent& event);
311
// void OnViewTools(wxCommandEvent& event);
312
// void OnViewRulers(wxCommandEvent& event);
313
// void OnViewRulersUI(wxUpdateUIEvent& event);
314
void on_view_tool_bar(wxCommandEvent& WXUNUSED(event));
315
void on_view_status_bar(wxCommandEvent& WXUNUSED(event));
316
void on_update_UI_tool_bar(wxUpdateUIEvent& event);
317
void on_update_UI_status_bar(wxUpdateUIEvent& event);
318
// void OnViewPageMargins(wxCommandEvent& event);
319
void on_view_welcome_page(wxCommandEvent& WXUNUSED(event));
320
void on_update_UI_welcome_page(wxUpdateUIEvent& event);
323
void on_update_UI_sound(wxUpdateUIEvent& event);
324
void on_sound_test(wxCommandEvent& WXUNUSED(event));
325
void on_all_sounds_off(wxCommandEvent& WXUNUSED(event));
326
void on_run_midi_wizard(wxCommandEvent& WXUNUSED(event));
327
void on_play_start(wxCommandEvent& WXUNUSED(event));
328
// void OnPlayCursorStart(wxCommandEvent& WXUNUSED(event));
329
void on_play_stop(wxCommandEvent& WXUNUSED(event));
330
void on_play_pause(wxCommandEvent& WXUNUSED(event));
333
void on_window_close_all(wxCommandEvent& WXUNUSED(event));
336
// void OnComboVoice(wxCommandEvent& event);
339
void on_about(wxCommandEvent& event);
340
// void OnHelpQuickGuide(wxCommandEvent& WXUNUSED(event));
341
// void OnHelpOpen(wxCommandEvent& event);
342
void on_check_for_updates(wxCommandEvent& WXUNUSED(event));
343
void on_silently_check_for_updates(wxCommandEvent& WXUNUSED(event));
344
void on_visit_website(wxCommandEvent& WXUNUSED(event));
346
// Other menu items events
347
void on_options(wxCommandEvent& WXUNUSED(event));
348
void on_open_books(wxCommandEvent& event);
349
// void OnOpenBookUI(wxUpdateUIEvent& event);
351
//other even managers
352
void on_metronome_timer(wxTimerEvent& event);
353
void on_metronome_on_off(wxCommandEvent& WXUNUSED(event));
354
void on_metronome_update(wxSpinEvent& WXUNUSED(event));
355
void on_metronome_update_text(wxCommandEvent& WXUNUSED(event));
356
// void OnPaneClose(wxAuiManagerEvent& event);
357
// void OnKeyPress(wxKeyEvent& event);
358
// void OnKeyF1(wxCommandEvent& event);
361
// //textbook events and methods
362
// void OnDocumentFrame(wxCommandEvent& event);
363
// void OnDocumentFrameUpdateUI(wxUpdateUIEvent& event);
364
// void OnCloseDocumentFrame();
367
void on_close_frame(wxCloseEvent& WXUNUSED(event));
368
void on_size(wxSizeEvent& WXUNUSED(event));
369
//void on_create_counters_panel(wxCommandEvent& WXUNUSED(event));
370
//void on_counters_event(CountersEvent& event);
371
void OnPaneClose(wxAuiManagerEvent& evt);
374
//DlgCounters* create_counters_dlg(int mode, ProblemManager* pManager);
375
//wxPoint get_counters_position();
376
// void SetOpenHelpButton(bool fButtonPressed);
377
// void SilentlyCheckForUpdates(bool fSilent);
378
// inline wxMenu* GetEditMenu() {return m_editMenu; }
379
// void NewScoreWindow(lmEditorMode* pMode, ImoScore* pScore);
380
// void OpenScore(wxString& sFilename, bool fAsNew);
381
// void OpenBook(const wxString& sPageName);
382
// void RunUnitTests();
385
// bool ShowRulers();
386
// bool IsCountOffChecked();
389
// void OnCloseWelcomeWnd();
391
// //eBooks controller
392
// void SetHtmlWindow(lmHtmlWindow* pHtmlWin) { m_pHtmlWin = pHtmlWin; }
393
// lmHtmlWindow* GetHtmlWindow() { return m_pHtmlWin; }
396
// void DumpScore(ImoScore* pScore);
398
// //access to information
399
// inline TextBookController* GetBookController() { return m_pBookController; }
400
// lmController* GetActiveController();
401
// inline wxFileHistory* GetFileHistory() { return GetDocumentManager()->GetFileHistory(); }
402
// lmDocument* GetActiveDoc();
405
// void OnActiveChildChanged(lmTDIChildFrame* pFrame);
408
// void RedirectKeyPressEvent(wxKeyEvent& event);
409
// void SetFocusOnActiveView();
411
// //access to current active MDI Child
412
// lmScoreView* GetActiveScoreView();
414
//#if lmUSE_LIBRARY_MVC
416
// //call back to access the MvcCollection
417
// MvcCollection* GetMvcCollection();
418
// void OnCloseDocument(Document* pDoc);
423
// void InitializeHelp();
424
// void InitializeBooks();
425
// void ScanForBooks(wxString sPath, wxString sPattern);
426
// void CloseAllWindows();
429
DECLARE_EVENT_TABLE()
434
} // namespace lenmus
436
#endif // __LENMUS_MAIN_FRAME_H__