1
//--------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2010 LenMus project
5
// This file is derived from file src/docmdi.cpp from wxWidgets 2.7.1 project.
6
// Author: Julian Smart
7
// Copyright (c) Julian Smart
12
// This program is free software; you can redistribute it and/or modify it under the
13
// terms of the GNU General Public License as published by the Free Software Foundation,
14
// either version 3 of the License, or (at your option) any later version.
16
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
17
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
18
// PARTICULAR PURPOSE. See the GNU General Public License for more details.
20
// You should have received a copy of the GNU General Public License along with this
21
// program. If not, see <http://www.gnu.org/licenses/>.
23
// For any comment, suggestion or feature request, please contact the manager of
24
// the project at cecilios@users.sourceforge.net
26
//-------------------------------------------------------------------------------------
27
#ifndef __LM_DOCVIEWMDI_H__
28
#define __LM_DOCVIEWMDI_H__
31
#include <wx/docview.h>
33
#include "ChildFrame.h"
34
#include "ParentFrame.h"
35
#include "ClientWindow.h"
39
#include "../score/defs.h" //access to lmUSE_LIBRARY_MVC
41
#include "lomse_mvc_builder.h"
42
using namespace lomse;
46
//------------------------------------------------------------------------------------------------
48
//------------------------------------------------------------------------------------------------
53
class lmDocManager : public wxDocManager
56
lmDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true);
60
wxDocument* CreateDocument(const wxString& path, long flags);
65
void ImportFile(wxString& sPath);
66
void OpenFile(wxString& sPath, bool fAsNew);
67
void OpenDocument(lmEditorMode* pMode, lmScore* pScore);
70
void LoadRecentFiles(wxConfigBase* pConfig, const wxString& sKeyRoot);
71
void SaveRecentFiles();
72
void FileHistoryUsesMenu(wxMenu* pMenu);
73
void AddToHistory(const wxString& sFileWithPath);
74
wxString GetFromHistory(int iEntry);
75
inline wxFileHistory* GetFileHistory() { return &m_RecentFiles; }
76
inline int NumFilesInHistory() { return m_RecentFiles.GetCount(); }
81
void close_document(Document* pDoc);
82
inline MvcCollection* get_mvc_collection() { return &m_docviews; }
87
lmDocument* DoOpenDocument(const wxString& path, long flags, lmScore* pScore=NULL);
89
wxFileHistory m_RecentFiles; //list of rencently open files
90
wxString m_sConfigKey; //key to load/save history
91
wxConfigBase* m_pConfig; //config object to load/save config
94
MvcCollection m_docviews;
95
MvcBuilder* m_pBuilder;
101
//------------------------------------------------------------------------------------------------
102
// lmDocTDIParentFrame: top window for a Tabbed Document Interface
103
//------------------------------------------------------------------------------------------------
104
class lmDocTDIParentFrame: public lmTDIParentFrame
107
lmDocTDIParentFrame();
108
lmDocTDIParentFrame(lmDocManager* pDocManager, wxFrame* pParent, wxWindowID id,
109
const wxString& title, const wxPoint& pos = wxDefaultPosition,
110
const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame"));
112
bool Create(lmDocManager* pDocManager, wxFrame* pParent, wxWindowID id,
113
const wxString& title, const wxPoint& pos = wxDefaultPosition,
114
const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame"));
116
// Extend event processing to search the document manager's event table
117
virtual bool ProcessEvent(wxEvent& event);
119
lmDocManager* GetDocumentManager(void) const { return m_pDocManager; }
121
void OnExit(wxCommandEvent& event);
122
void OnMRUFile(wxCommandEvent& event);
123
void OnCloseWindow(wxCloseEvent& event);
130
lmDocManager* m_pDocManager;
133
DECLARE_CLASS(lmDocTDIParentFrame)
134
DECLARE_EVENT_TABLE()
135
DECLARE_NO_COPY_CLASS(lmDocTDIParentFrame)
140
//------------------------------------------------------------------------------------------------
141
// lmDocTDIChildFrame
142
//------------------------------------------------------------------------------------------------
143
class lmDocTDIChildFrame: public lmTDIChildFrame
146
lmDocTDIChildFrame();
147
lmDocTDIChildFrame(wxDocument *doc, wxView *view, lmTDIParentFrame *frame, wxWindowID id,
148
const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
149
long type = wxDEFAULT_FRAME_STYLE, const wxString& name = wxT("frame"));
150
virtual ~lmDocTDIChildFrame();
152
bool Create(wxDocument *doc,
154
lmTDIParentFrame *frame,
156
const wxString& title,
157
const wxPoint& pos = wxDefaultPosition,
158
const wxSize& size = wxDefaultSize,
159
long type = wxDEFAULT_FRAME_STYLE,
160
const wxString& name = wxFrameNameStr);
162
// Extend event processing to search the view's event table
163
virtual bool ProcessEvent(wxEvent& event);
165
void OnActivate(wxActivateEvent& event);
166
void OnCloseWindow(wxCloseEvent& event);
168
inline wxDocument *GetDocument() const { return m_childDocument; }
169
inline wxView *GetView(void) const { return m_childView; }
170
inline void SetDocument(wxDocument *doc) { m_childDocument = doc; }
171
inline void SetView(wxView *view) { m_childView = view; }
172
bool Destroy() { m_childView = (wxView *)NULL; return lmTDIChildFrame::Destroy(); }
176
wxDocument* m_childDocument;
180
DECLARE_EVENT_TABLE()
181
DECLARE_CLASS(lmDocTDIChildFrame)
182
DECLARE_NO_COPY_CLASS(lmDocTDIChildFrame)
185
#endif // __LM_DOCVIEWMDI_H__