1
//--------------------------------------------------------------------------------------
2
// LenMus Phonascus: The teacher of music
3
// Copyright (c) 2002-2010 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
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
22
#pragma implementation "WelcomeWnd.h"
25
// For compilers that support precompilation, includes <wx/wx.h>.
26
#include <wx/wxprec.h>
36
#include <wx/hyperlink.h>
38
#include "WelcomeWnd.h"
39
#include "TheApp.h" //to get access to locale info.
40
#include "ArtProvider.h" // to use ArtProvider for managing icons
42
#include "../app/MainFrame.h"
43
extern lmMainFrame* g_pMainFrame;
46
#include "../globals/Paths.h"
47
extern lmPaths* g_pPaths;
50
const int lmLINK_NewInLenmus = wxNewId();
51
const int lmLINK_NewScore = wxNewId();
52
const int lmLINK_QuickGuide = wxNewId();
53
const int lmLINK_OpenEBooks = wxNewId();
54
const int lmLINK_Recent1 = wxNewId();
55
const int lmLINK_Recent2 = wxNewId();
56
const int lmLINK_Recent3 = wxNewId();
57
const int lmLINK_Recent4 = wxNewId();
58
const int lmLINK_Recent5 = wxNewId();
59
const int lmLINK_Recent6 = wxNewId();
60
const int lmLINK_Recent7 = wxNewId();
61
const int lmLINK_Recent8 = wxNewId();
62
const int lmLINK_Recent9 = wxNewId();
65
BEGIN_EVENT_TABLE(lmWelcomeWnd, lmTDIChildFrame)
66
EVT_HYPERLINK (lmLINK_NewInLenmus, lmWelcomeWnd::OnNewInLenmus)
67
EVT_HYPERLINK (lmLINK_NewScore, lmWelcomeWnd::OnNewScore)
68
EVT_HYPERLINK (lmLINK_QuickGuide, lmWelcomeWnd::OnQuickGuide)
69
EVT_HYPERLINK (lmLINK_OpenEBooks, lmWelcomeWnd::OnOpenEBooks)
70
EVT_HYPERLINK (lmLINK_Recent1, lmWelcomeWnd::OnOpenRecent)
71
EVT_HYPERLINK (lmLINK_Recent2, lmWelcomeWnd::OnOpenRecent)
72
EVT_HYPERLINK (lmLINK_Recent3, lmWelcomeWnd::OnOpenRecent)
73
EVT_HYPERLINK (lmLINK_Recent4, lmWelcomeWnd::OnOpenRecent)
74
EVT_HYPERLINK (lmLINK_Recent5, lmWelcomeWnd::OnOpenRecent)
75
EVT_HYPERLINK (lmLINK_Recent6, lmWelcomeWnd::OnOpenRecent)
76
EVT_HYPERLINK (lmLINK_Recent7, lmWelcomeWnd::OnOpenRecent)
77
EVT_HYPERLINK (lmLINK_Recent8, lmWelcomeWnd::OnOpenRecent)
78
EVT_HYPERLINK (lmLINK_Recent9, lmWelcomeWnd::OnOpenRecent)
79
EVT_CLOSE (lmWelcomeWnd::OnCloseWindow)
82
IMPLEMENT_CLASS(lmWelcomeWnd, lmTDIChildFrame)
85
lmWelcomeWnd::lmWelcomeWnd(wxWindow* parent, wxWindowID id)
86
: lmTDIChildFrame((lmTDIParentFrame*)parent, id, _("Welcome"))
88
//get recent open files history and get number of files saved
89
wxFileHistory* pHistory = g_pMainFrame->GetFileHistory();
90
int nRecentFiles = pHistory->GetCount();
91
CreateControls(nRecentFiles, pHistory);
93
this->SetBackgroundColour(*wxWHITE);
95
//in linux, links background must also be changed
96
m_pLinkNewInLenmus->SetBackgroundColour(*wxWHITE);
97
m_pLinkVisitWebsite->SetBackgroundColour(*wxWHITE);
98
m_pLinkOpenEBooks->SetBackgroundColour(*wxWHITE);
99
m_pLinkQuickGuide->SetBackgroundColour(*wxWHITE);
100
m_pLinkNewScore->SetBackgroundColour(*wxWHITE);
101
for (int i=0; i < nRecentFiles; i++)
102
m_pLinkRecent[i]->SetBackgroundColour(*wxWHITE);
105
m_pLearnIcon->SetBitmap( wxArtProvider::GetIcon(_T("welcome_news"), wxART_OTHER) );
106
m_pScoreIcon->SetBitmap( wxArtProvider::GetIcon(_T("welcome_editor"), wxART_OTHER) );
107
m_pPhonascusIcon->SetBitmap( wxArtProvider::GetIcon(_T("welcome_theory"), wxART_OTHER) );
108
m_pBmpLeftBanner->SetBitmap( wxArtProvider::GetIcon(_T("welcome_left"), wxART_OTHER) );
113
void lmWelcomeWnd::CreateControls(int nRecentFiles, wxFileHistory* pHistory)
115
//Controls creation for WelcomeWnd
117
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
119
wxBoxSizer* pMainSizer;
120
pMainSizer = new wxBoxSizer( wxHORIZONTAL );
122
wxBoxSizer* pLeftBannerSizer;
123
pLeftBannerSizer = new wxBoxSizer( wxHORIZONTAL );
125
m_pBmpLeftBanner = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 165,773 ), 0 );
126
pLeftBannerSizer->Add( m_pBmpLeftBanner, 0, 0, 5 );
128
pMainSizer->Add( pLeftBannerSizer, 0, wxEXPAND, 20 );
130
wxBoxSizer* pContentSizer;
131
pContentSizer = new wxBoxSizer( wxHORIZONTAL );
134
pContentSizer->Add( 0, 0, 1, wxEXPAND, 5 );
136
wxBoxSizer* pItemsSizer;
137
pItemsSizer = new wxBoxSizer( wxVERTICAL );
139
wxBoxSizer* pHeadersSizer;
140
pHeadersSizer = new wxBoxSizer( wxHORIZONTAL );
143
pHeadersSizer->Add( 40, 0, 1, 0, 5 );
145
m_pTxtTitle = new wxStaticText( this, wxID_ANY, _("Welcome to LenMus"), wxDefaultPosition, wxDefaultSize, 0 );
146
m_pTxtTitle->Wrap( -1 );
147
m_pTxtTitle->SetFont( wxFont( 16, 74, 90, 92, false, wxT("Tahoma") ) );
149
pHeadersSizer->Add( m_pTxtTitle, 0, wxALL, 5 );
152
pHeadersSizer->Add( 40, 0, 1, 0, 5 );
154
pItemsSizer->Add( pHeadersSizer, 1, wxEXPAND, 5 );
156
wxBoxSizer* pLearnSizer;
157
pLearnSizer = new wxBoxSizer( wxVERTICAL );
159
m_pLearnTitle = new wxStaticText( this, wxID_ANY, _("Learn about LenMus"), wxDefaultPosition, wxDefaultSize, 0 );
160
m_pLearnTitle->Wrap( -1 );
161
m_pLearnTitle->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) );
163
pLearnSizer->Add( m_pLearnTitle, 0, wxALL, 5 );
165
wxBoxSizer* pLearnSubsizer;
166
pLearnSubsizer = new wxBoxSizer( wxHORIZONTAL );
168
m_pLearnIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(45, 45), 0 );
169
pLearnSubsizer->Add( m_pLearnIcon, 0, wxALL, 5 );
171
wxBoxSizer* pLearnLinksSizer;
172
pLearnLinksSizer = new wxBoxSizer( wxVERTICAL );
174
m_pLinkNewInLenmus = new wxHyperlinkCtrl( this, lmLINK_NewInLenmus, _("What's is new in LenMus"), wxT("http://www.lenmus.org"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
175
pLearnLinksSizer->Add( m_pLinkNewInLenmus, 0, wxRIGHT|wxLEFT, 5 );
177
m_pLinkVisitWebsite = new wxHyperlinkCtrl( this, wxID_ANY, _("Visit LenMus website"), wxT("http://www.lenmus.org"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
178
pLearnLinksSizer->Add( m_pLinkVisitWebsite, 0, wxRIGHT|wxLEFT, 5 );
180
pLearnSubsizer->Add( pLearnLinksSizer, 1, wxEXPAND|wxLEFT, 10 );
182
pLearnSizer->Add( pLearnSubsizer, 1, wxEXPAND, 5 );
184
pItemsSizer->Add( pLearnSizer, 0, wxTOP|wxRIGHT|wxLEFT, 20 );
186
wxBoxSizer* pPhonascusSizer;
187
pPhonascusSizer = new wxBoxSizer( wxVERTICAL );
189
m_pPhonascusTitle = new wxStaticText( this, wxID_ANY, _("Learn and practise music theory"), wxDefaultPosition, wxDefaultSize, 0 );
190
m_pPhonascusTitle->Wrap( -1 );
191
m_pPhonascusTitle->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) );
193
pPhonascusSizer->Add( m_pPhonascusTitle, 0, wxALL, 5 );
195
wxBoxSizer* pPhonascusSubsizer;
196
pPhonascusSubsizer = new wxBoxSizer( wxHORIZONTAL );
198
m_pPhonascusIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(45, 45), 0 );
199
pPhonascusSubsizer->Add( m_pPhonascusIcon, 0, wxALL, 5 );
201
wxBoxSizer* pPhonascusLinksSizer;
202
pPhonascusLinksSizer = new wxBoxSizer( wxVERTICAL );
204
m_pLinkOpenEBooks = new wxHyperlinkCtrl( this, lmLINK_OpenEBooks, _("Open eMusicBooks "), wxT("http://www.lenmus.org"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
205
pPhonascusLinksSizer->Add( m_pLinkOpenEBooks, 0, wxRIGHT|wxLEFT, 5 );
207
pPhonascusSubsizer->Add( pPhonascusLinksSizer, 1, wxEXPAND|wxLEFT, 10 );
209
pPhonascusSizer->Add( pPhonascusSubsizer, 1, wxEXPAND, 5 );
211
pItemsSizer->Add( pPhonascusSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 20 );
213
wxBoxSizer* pScoreSizer;
214
pScoreSizer = new wxBoxSizer( wxVERTICAL );
216
m_pScoreTitle = new wxStaticText( this, wxID_ANY, _("Create and edit music scores (beta 0 version)"), wxDefaultPosition, wxDefaultSize, 0 );
217
m_pScoreTitle->Wrap( -1 );
218
m_pScoreTitle->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) );
220
pScoreSizer->Add( m_pScoreTitle, 0, wxALL, 5 );
222
wxBoxSizer* pScoreSubsizer;
223
pScoreSubsizer = new wxBoxSizer( wxHORIZONTAL );
225
m_pScoreIcon = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize(45, 45), 0 );
226
pScoreSubsizer->Add( m_pScoreIcon, 0, wxALL, 5 );
228
wxBoxSizer* pScoreLinksSizer;
229
pScoreLinksSizer = new wxBoxSizer( wxVERTICAL );
231
m_pLinkNewScore = new wxHyperlinkCtrl( this, lmLINK_NewScore, _("New score ..."), wxT("http://www.lenmus.org"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
232
pScoreLinksSizer->Add( m_pLinkNewScore, 0, wxRIGHT|wxLEFT, 5 );
234
m_pLinkQuickGuide = new wxHyperlinkCtrl( this, lmLINK_QuickGuide, _("Editor quick guide"), wxT("http://www.lenmus.org"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
235
pScoreLinksSizer->Add( m_pLinkQuickGuide, 0, wxRIGHT|wxLEFT, 5 );
237
wxBoxSizer* pRecentScoresSizer;
238
pRecentScoresSizer = new wxBoxSizer( wxVERTICAL );
240
m_pRecentScoresTitle = new wxStaticText( this, wxID_ANY, _("Recent scores"), wxDefaultPosition, wxDefaultSize, 0 );
241
m_pRecentScoresTitle->Wrap( -1 );
242
m_pRecentScoresTitle->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) );
244
pRecentScoresSizer->Add( m_pRecentScoresTitle, 0, wxRIGHT|wxLEFT, 5 );
246
wxBoxSizer* pRecentScoresLinksSizer;
247
pRecentScoresLinksSizer = new wxBoxSizer( wxHORIZONTAL );
250
pRecentScoresLinksSizer->Add( 40, 0, 0, 0, 5 );
252
wxBoxSizer* pRecentScoresLinksSizer1;
253
pRecentScoresLinksSizer1 = new wxBoxSizer( wxVERTICAL );
255
for (int i=0; i < nRecentFiles; i++)
258
new wxHyperlinkCtrl(this, lmLINK_Recent1+i, pHistory->GetHistoryFile(i),
259
pHistory->GetHistoryFile(i), wxDefaultPosition, wxDefaultSize,
261
pRecentScoresLinksSizer1->Add( m_pLinkRecent[i], 0, wxRIGHT|wxLEFT, 5 );
264
pRecentScoresLinksSizer->Add( pRecentScoresLinksSizer1, 1, wxEXPAND, 5 );
266
pRecentScoresSizer->Add( pRecentScoresLinksSizer, 0, wxEXPAND, 5 );
268
pScoreLinksSizer->Add( pRecentScoresSizer, 1, wxEXPAND|wxTOP, 5 );
270
pScoreSubsizer->Add( pScoreLinksSizer, 1, wxEXPAND|wxLEFT, 10 );
272
pScoreSizer->Add( pScoreSubsizer, 1, wxEXPAND, 5 );
274
pItemsSizer->Add( pScoreSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 20 );
276
pContentSizer->Add( pItemsSizer, 6, 0, 5 );
279
pContentSizer->Add( 0, 0, 1, wxEXPAND, 5 );
281
pMainSizer->Add( pContentSizer, 1, wxEXPAND|wxTOP, 20 );
283
this->SetSizer( pMainSizer );
287
lmWelcomeWnd::~lmWelcomeWnd()
291
void lmWelcomeWnd::OnNewInLenmus(wxHyperlinkEvent& event)
293
#if 1 //1 = as html page, 0= as eBook
294
wxString sDoc = _T("release_notes.htm");
297
g_pMainFrame->OpenBook(_T("release_notes_1.htm"));
301
void lmWelcomeWnd::OnQuickGuide(wxHyperlinkEvent& event)
303
wxString sDoc = _T("editor_quick_guide.htm");
307
void lmWelcomeWnd::ShowDocument(wxString& sDocName)
309
wxString sPath = g_pPaths->GetLocalePath();
310
wxFileName oFile(sPath, sDocName, wxPATH_NATIVE);
311
if (!oFile.FileExists())
313
//use english version
314
sPath = g_pPaths->GetLocaleRootPath();
315
oFile.AssignDir(sPath);
316
oFile.AppendDir(_T("en"));
317
oFile.SetFullName(sDocName);
319
::wxLaunchDefaultBrowser( oFile.GetFullPath() );
322
void lmWelcomeWnd::OnNewScore(wxHyperlinkEvent& event)
324
wxCommandEvent myEvent; //It is not used. So I do not initialize it
325
g_pMainFrame->OnScoreWizard(myEvent);
328
void lmWelcomeWnd::OnOpenEBooks(wxHyperlinkEvent& event)
330
wxCommandEvent myEvent; //It is not used. So I do not initialize it
331
g_pMainFrame->OnOpenBook(myEvent);
334
void lmWelcomeWnd::OnOpenRecent(wxHyperlinkEvent& event)
336
wxString sFile = m_pLinkRecent[event.GetId() - lmLINK_Recent1]->GetURL();
337
g_pMainFrame->OpenScore(sFile, false); //false: it is not a new file
340
void lmWelcomeWnd::OnCloseWindow(wxCloseEvent& event)
343
g_pMainFrame->OnCloseWelcomeWnd();
345
event.Skip(); //allow to continue