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 "ToolSymbols.h"
25
// For compilers that support precompilation, includes <wx/wx.h>.
26
#include <wx/wxprec.h>
35
#include <wx/xrc/xmlres.h>
36
#include <wx/bmpcbox.h>
37
#include <wx/statline.h>
38
#include <wx/clrpicker.h>
42
#include "ToolSymbols.h"
43
#include "ToolGroup.h"
44
#include "../ArtProvider.h" //to use ArtProvider for managing icons
45
#include "../TheApp.h" //to use GetMainFrame()
46
#include "../MainFrame.h" //to get active lmScoreCanvas
47
#include "../ScoreCanvas.h" //to send commands
48
#include "../../widgets/Button.h"
49
#include "../../score/defs.h"
50
#include "../../score/FiguredBass.h"
51
#include "../../graphic/GraphicManager.h" //to use GenerateBitmapForKeyCtrol()
57
#define lm_NUM_HARMONY_BUTTONS 2
58
#define lm_NUM_SYMBOL_BUTTONS 3
62
lmID_BT_Harmony = 2600,
63
lmID_BT_Symbols = lmID_BT_Harmony + lm_NUM_HARMONY_BUTTONS,
67
IMPLEMENT_DYNAMIC_CLASS(lmToolPageSymbols, lmToolPage)
70
lmToolPageSymbols::lmToolPageSymbols()
74
lmToolPageSymbols::lmToolPageSymbols(wxWindow* parent)
79
void lmToolPageSymbols::Create(wxWindow* parent)
82
lmToolPage::CreatePage(parent, lmPAGE_SYMBOLS);
85
m_sPageToolTip = _("Edit tools for text, graphics and symbols");
86
m_sPageBitmapName = _T("tool_symbols");
92
lmToolPageSymbols::~lmToolPageSymbols()
96
void lmToolPageSymbols::CreateGroups()
98
//Create the groups for this page
100
wxBoxSizer *pMainSizer = GetMainSizer();
102
m_pGrpHarmony = new lmGrpHarmony(this, pMainSizer, lmMM_DATA_ENTRY);
103
AddGroup(m_pGrpHarmony);
104
m_pGrpSymbols = new lmGrpSymbols(this, pMainSizer, lmMM_DATA_ENTRY);
105
AddGroup(m_pGrpSymbols);
109
//Select harmony group
110
SelectGroup(m_pGrpHarmony);
112
//initialize info about selected group/tool
113
m_nCurGroupID = lmGRP_Harmony;
114
m_nCurToolID = m_pGrpHarmony->GetCurrentToolID();
116
m_fGroupsCreated = true;
118
//for now disable symbols group
119
m_pGrpSymbols->SetAsAlwaysDisabled();
122
wxString lmToolPageSymbols::GetToolShortDescription()
124
//returns a short description of the selected tool. This description is used to
125
//be displayed in the status bar
128
switch( GetCurrentToolID() )
130
case lmTOOL_FIGURED_BASS:
131
sDescr = _("Add figured bass");
135
sDescr = _("Add 'hold chord' figured bass line");
139
sDescr = _("Add text");
143
sDescr = _("Add line or arrow");
147
sDescr = _("Add textbox");
158
//--------------------------------------------------------------------------------
159
// lmGrpSymbols implementation
160
//--------------------------------------------------------------------------------
162
lmGrpSymbols::lmGrpSymbols(lmToolPage* pParent, wxBoxSizer* pMainSizer,
163
int nValidMouseModes)
164
: lmToolButtonsGroup(pParent, lm_eGT_ToolSelector, lm_NUM_SYMBOL_BUTTONS,
165
lmTBG_ONE_SELECTED, pMainSizer,
166
lmID_BT_Symbols, lmTOOL_TEXT, pParent->GetColors(),
171
void lmGrpSymbols::CreateGroupControls(wxBoxSizer* pMainSizer)
173
//create the buttons for the group
175
lmToolButtonData cButtons[] =
177
{ lmTOOL_TEXT, _("Text"), _T("symbols_text") },
178
{ lmTOOL_LINES, _("Lines and arrows"), _T("symbols_line") },
179
{ lmTOOL_TEXTBOX, _("Text boxes"), _T("symbols_textbox") },
182
int nNumButtons = sizeof(cButtons) / sizeof(lmToolButtonData);
184
SetGroupTitle(_("Text and graphics"));
185
wxBoxSizer* pCtrolsSizer = CreateGroupSizer(pMainSizer);
187
SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
189
wxBoxSizer* pButtonsSizer;
190
wxSize btSize(24, 24);
191
for (int iB=0; iB < nNumButtons; iB++)
194
pButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
195
pCtrolsSizer->Add(pButtonsSizer);
198
wxString sBtName = cButtons[iB].sBitmapName;
199
m_pButton[iB] = new lmCheckButton(this, lmID_BT_Symbols+iB, wxBitmap(24, 24));
200
m_pButton[iB]->SetBitmapUp(sBtName, _T(""), btSize);
201
m_pButton[iB]->SetBitmapDown(sBtName, _T("button_selected_flat"), btSize);
202
m_pButton[iB]->SetBitmapOver(sBtName, _T("button_over_flat"), btSize);
203
m_pButton[iB]->SetBitmapDisabled(sBtName + _T("_dis"), _T(""), btSize);
204
m_pButton[iB]->SetToolTip(cButtons[iB].sToolTip);
205
pButtonsSizer->Add(m_pButton[iB], wxSizerFlags(0).Border(wxALL, 0) );
206
pButtonsSizer->Add( new wxStaticText(this, wxID_ANY, cButtons[iB].sToolTip),
207
wxSizerFlags(0).Border(wxLEFT|wxTOP|wxBOTTOM, 5) );
212
SelectButton(0); //select text button
217
//--------------------------------------------------------------------------------
218
// lmGrpHarmony implementation
219
//--------------------------------------------------------------------------------
221
lmGrpHarmony::lmGrpHarmony(lmToolPage* pParent, wxBoxSizer* pMainSizer,
222
int nValidMouseModes)
223
: lmToolButtonsGroup(pParent, lm_eGT_ToolSelector, lm_NUM_HARMONY_BUTTONS,
224
lmTBG_ONE_SELECTED, pMainSizer,
225
lmID_BT_Harmony, lmTOOL_FIGURED_BASS, pParent->GetColors(),
230
void lmGrpHarmony::CreateGroupControls(wxBoxSizer* pMainSizer)
232
//create the buttons for the group
234
lmToolButtonData cButtons[] =
236
{ lmTOOL_FIGURED_BASS, _("Figured bass"), _T("harmony_figured_bass") },
237
{ lmTOOL_FB_LINE, _("'Hold chord' line"), _T("harmony_fb_line") },
240
int nNumButtons = sizeof(cButtons) / sizeof(lmToolButtonData);
242
SetGroupTitle(_("Harmony"));
243
wxBoxSizer* pCtrolsSizer = CreateGroupSizer(pMainSizer);
245
SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
247
wxBoxSizer* pButtonsSizer;
248
wxSize btSize(24, 24);
249
for (int iB=0; iB < nNumButtons; iB++)
251
pButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
252
pCtrolsSizer->Add(pButtonsSizer);
254
wxString sBtName = cButtons[iB].sBitmapName;
255
m_pButton[iB] = new lmCheckButton(this, lmID_BT_Harmony+iB, wxBitmap(24, 24));
256
m_pButton[iB]->SetBitmapUp(sBtName, _T(""), btSize);
257
m_pButton[iB]->SetBitmapDown(sBtName, _T("button_selected_flat"), btSize);
258
m_pButton[iB]->SetBitmapOver(sBtName, _T("button_over_flat"), btSize);
259
m_pButton[iB]->SetBitmapDisabled(sBtName + _T("_dis"), _T(""), btSize);
260
m_pButton[iB]->SetToolTip(cButtons[iB].sToolTip);
261
pButtonsSizer->Add(m_pButton[iB], wxSizerFlags(0).Border(wxALL, 0) );
262
pButtonsSizer->Add( new wxStaticText(this, wxID_ANY, cButtons[iB].sToolTip),
263
wxSizerFlags(0).Border(wxLEFT|wxTOP|wxBOTTOM, 5) );
268
SelectButton(0); //select figured bass button