126
128
m_pGrpKeyType = new lmGrpKeyType(this, pMainSizer);
133
m_pGrpClefType->SetSelected(true);
134
m_pGrpTimeType->SetSelected(false);
135
m_pGrpKeyType->SetSelected(false);
137
m_nCurGroupID = lmGRP_ClefType;
138
m_nCurToolID = lmTOOL_NONE;
140
m_fGroupsCreated = true;
143
bool lmToolPageClefs::DeselectRelatedGroups(lmEToolGroupID nGroupID)
145
//When there are several groups in the same tool page (i.e, clefs, keys and
146
//time signatures) the groups will behave as if they where a single 'logical
147
//group', that is, selecting a tool in a group will deselect any tool on the
148
//other related groups. To achieve this behaviour the group will call this
149
//method to inform the owner page.
150
//This method must deselect tools in any related groups to the one received
151
//as parameter, and must return 'true' if that group is a tool group of
152
//'false' if it is an options group.
157
m_pGrpClefType->SetSelected(true);
158
m_pGrpTimeType->SetSelected(false);
159
m_pGrpKeyType->SetSelected(false);
161
return true; //clef is a tool group
164
m_pGrpClefType->SetSelected(false);
165
m_pGrpTimeType->SetSelected(true);
166
m_pGrpKeyType->SetSelected(false);
168
return true; //time is a tool group
171
m_pGrpClefType->SetSelected(false);
172
m_pGrpTimeType->SetSelected(false);
173
m_pGrpKeyType->SetSelected(true);
175
return true; //key is a tool group
180
return false; //compiler happy
183
wxString lmToolPageClefs::GetToolShortDescription()
185
//returns a short description of the selected tool. This description is used to
186
//be displayed in the status bar
189
switch( GetCurrentGroupID() )
192
sDescr = _("Add clef");
196
sDescr = _("Add time signature");
200
sDescr = _("Add key signature");
134
212
// lmGrpClefType implementation
135
213
//--------------------------------------------------------------------------------
137
BEGIN_EVENT_TABLE(lmGrpClefType, lmToolGroup)
138
EVT_BUTTON (lmID_CLEF_ADD, lmGrpClefType::OnAddClef)
215
//aux. class to contain clefs data
220
lmClefData(lmEClefType type, wxString name, wxString sBmp)
221
: sClefName(name), nClefType(type), sButtonBmp(sBmp) {}
223
lmEClefType nClefType;
142
229
lm_eNUM_CLEFS = 8,
145
232
static lmClefData m_tClefs[lm_eNUM_CLEFS];
146
233
static bool m_fStringsInitialized = false;
237
//--------------------------------------------------------------------------------
239
BEGIN_EVENT_TABLE(lmGrpClefType, lmToolGroup)
240
EVT_COMBOBOX (lmID_CLEF_LIST, lmGrpClefType::OnClefList)
148
243
lmGrpClefType::lmGrpClefType(lmToolPage* pParent, wxBoxSizer* pMainSizer)
149
244
: lmToolGroup(pParent, pParent->GetColors())
153
248
if (!m_fStringsInitialized)
155
250
//AWARE: When addign more clefs, update lm_eNUM_CLEFS;
156
m_tClefs[0] = lmClefData( _("G clef on 2nd line"), lmE_Sol );
157
m_tClefs[1] = lmClefData( _("F clef on 4th line"), lmE_Fa4 );
158
m_tClefs[2] = lmClefData( _("F clef on 3rd line"), lmE_Fa3 );
159
m_tClefs[3] = lmClefData( _("C clef on 1st line"), lmE_Do1 );
160
m_tClefs[4] = lmClefData( _("C clef on 2nd line"), lmE_Do2 );
161
m_tClefs[5] = lmClefData( _("C clef on 3rd line"), lmE_Do3 );
162
m_tClefs[6] = lmClefData( _("C clef on 4th line"), lmE_Do4 );
163
m_tClefs[7] = lmClefData( _("Percussion clef"), lmE_Percussion );
251
m_tClefs[0] = lmClefData(lmE_Sol, _("G clef on 2nd line"), _T("clef_g") );
252
m_tClefs[1] = lmClefData(lmE_Fa4, _("F clef on 4th line"), _T("clef_g") );
253
m_tClefs[2] = lmClefData(lmE_Fa3, _("F clef on 3rd line"), _T("clef_g") );
254
m_tClefs[3] = lmClefData(lmE_Do1, _("C clef on 1st line"), _T("clef_g") );
255
m_tClefs[4] = lmClefData(lmE_Do2, _("C clef on 2nd line"), _T("clef_g") );
256
m_tClefs[5] = lmClefData(lmE_Do3, _("C clef on 3rd line"), _T("clef_g") );
257
m_tClefs[6] = lmClefData(lmE_Do4, _("C clef on 4th line"), _T("clef_g") );
258
m_tClefs[7] = lmClefData(lmE_Percussion, _("Percussion clef"), _T("clef_g") );
259
//// other clefs not yet available
263
//lmE_8Sol, //8 above
264
//lmE_Sol8, //8 below
267
//lmE_15Sol, //15 above
268
//lmE_Sol15, //15 below
269
//lmE_15Fa, //15 above
270
//lmE_Fa15, //15 below
165
271
m_fStringsInitialized = true;
181
287
pCtrolsSizer->Add( m_pClefList, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
183
//button to add the clef
184
m_pBtnAddClef = new wxButton(this, lmID_CLEF_ADD, _("Add clef"), wxDefaultPosition, wxDefaultSize, 0 );
185
pCtrolsSizer->Add( m_pBtnAddClef, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
191
void lmGrpClefType::OnAddClef(wxCommandEvent& event)
293
void lmGrpClefType::OnClefList(wxCommandEvent& event)
193
//insert selected key
195
int iC = m_pClefList->GetSelection();
196
lmController* pSC = GetMainFrame()->GetActiveController();
199
pSC->InsertClef(m_tClefs[iC].nClefType);
295
//Notify owner page about the tool change
201
//return focus to active view
202
GetMainFrame()->SetFocusOnActiveView();
298
((lmToolPage*)m_pParent)->OnToolChanged(this->GetToolGroupID(),
299
(lmEToolID)m_pClefList->GetSelection() );
206
302
void lmGrpClefType::LoadClefList()
215
311
m_pClefList->SetSelection(0);
314
lmEClefType lmGrpClefType::GetSelectedClef()
316
return (lmEClefType)m_pClefList->GetSelection();
321
#else //USE BUTTONS FOR CLEFS
322
//--------------------------------------------------------------------------------
324
lmGrpClefType::lmGrpClefType(lmToolPage* pParent, wxBoxSizer* pMainSizer)
325
: lmToolButtonsGroup(pParent, lm_NUM_CLEF_BUTTONS, lmTBG_ONE_SELECTED, pMainSizer,
326
lmID_BT_ClefType, lmTOOL_NONE, pParent->GetColors())
328
//load language dependent strings. Can not be statically initiallized because
329
//then they do not get translated
330
if (!m_fStringsInitialized)
332
//AWARE: When addign more clefs, update lm_eNUM_CLEFS;
333
m_tClefs[0] = lmClefData(lmE_Sol, _("G clef on 2nd line"), _T("clef_g") );
334
m_tClefs[1] = lmClefData(lmE_Fa4, _("F clef on 4th line"), _T("clef_g") );
335
m_tClefs[2] = lmClefData(lmE_Fa3, _("F clef on 3rd line"), _T("clef_g") );
336
m_tClefs[3] = lmClefData(lmE_Do1, _("C clef on 1st line"), _T("clef_g") );
337
m_tClefs[4] = lmClefData(lmE_Do2, _("C clef on 2nd line"), _T("clef_g") );
338
m_tClefs[5] = lmClefData(lmE_Do3, _("C clef on 3rd line"), _T("clef_g") );
339
m_tClefs[6] = lmClefData(lmE_Do4, _("C clef on 4th line"), _T("clef_g") );
340
m_tClefs[7] = lmClefData(lmE_Percussion, _("Percussion clef"), _T("clef_g") );
341
//// other clefs not yet available
345
//lmE_8Sol, //8 above
346
//lmE_Sol8, //8 below
349
//lmE_15Sol, //15 above
350
//lmE_Sol15, //15 below
351
//lmE_15Fa, //15 above
352
//lmE_Fa15, //15 below
353
m_fStringsInitialized = true;
356
CreateControls(pMainSizer);
359
void lmGrpClefType::CreateControls(wxBoxSizer* pMainSizer)
361
//create the common controls for a group
362
wxBoxSizer* pCtrolsSizer = CreateGroup(pMainSizer, _("Clef"));
364
wxBoxSizer* pButtonsSizer;
365
wxSize btSize(32, 48);
366
for (int iB=0; iB < lm_NUM_CLEF_BUTTONS; iB++)
369
pButtonsSizer = new wxBoxSizer(wxHORIZONTAL);
370
pCtrolsSizer->Add(pButtonsSizer);
373
m_pButton[iB] = new lmCheckButton(this, lmID_BT_ClefType+iB, wxBitmap(32, 48));
374
m_pButton[iB]->SetBitmapUp(m_tClefs[iB].sButtonBmp, _T(""), btSize);
375
m_pButton[iB]->SetBitmapDown(m_tClefs[iB].sButtonBmp, _T("button_selected_flat"), btSize);
376
m_pButton[iB]->SetBitmapOver(m_tClefs[iB].sButtonBmp, _T("button_over_flat"), btSize);
377
m_pButton[iB]->SetToolTip(m_tClefs[iB].sClefName);
378
pButtonsSizer->Add(m_pButton[iB], wxSizerFlags(0).Border(wxALL, 2) );
382
SelectButton(0); //select G clef
385
lmEClefType lmGrpClefType::GetSelectedClef()
387
return (lmEClefType)m_nSelButton;
390
#endif //lmUSE_CLEF_COMBO
273
447
void lmGrpTimeType::OnButton(wxCommandEvent& event)
275
int iB = event.GetId() - lmID_BT_TimeType;
276
lmController* pSC = GetMainFrame()->GetActiveController();
278
pSC->InsertTimeSignature(m_tButtons[iB].nBeats, m_tButtons[iB].nBeatType);
449
//Notify owner page about the tool change
451
m_nSelButton = event.GetId() - lmID_BT_TimeType;
452
((lmToolPage*)m_pParent)->OnToolChanged(this->GetToolGroupID(), (lmEToolID)m_nSelButton );
455
int lmGrpTimeType::GetTimeBeats()
457
//Returns 0 if no button selected
459
if (m_nSelButton != -1)
460
return m_tButtons[m_nSelButton].nBeats;
465
int lmGrpTimeType::GetTimeBeatType()
467
//Returns 0 if no button selected
469
if (m_nSelButton != -1)
470
return m_tButtons[m_nSelButton].nBeatType;
345
536
pCtrolsSizer->Add( m_pKeyList, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
347
//button to add the key
348
m_pBtnAddKey = new wxButton(this, lmID_KEY_ADD, _("Add key"), wxDefaultPosition, wxDefaultSize, 0 );
349
pCtrolsSizer->Add( m_pBtnAddKey, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
351
538
//load initial data
352
539
m_pKeyRad[0]->SetValue(true);
353
540
m_pKeyRad[1]->SetValue(false);
369
556
void lmGrpKeyType::OnKeyList(wxCommandEvent& event)
558
//An item has been selected in keys combo. Notify owner page about the tool change
374
void lmGrpKeyType::OnAddKey(wxCommandEvent& event)
376
//insert selected key
378
int iK = m_pKeyList->GetSelection();
379
bool fMajor = m_pKeyRad[0]->GetValue();
382
nFifths = m_tMajorKeys[iK].nFifths;
564
void lmGrpKeyType::NotifyToolChange()
566
//Notify owner page about the tool change
568
((lmToolPage*)m_pParent)->OnToolChanged(this->GetToolGroupID(),
569
(lmEToolID)m_pKeyList->GetSelection() );
572
bool lmGrpKeyType::IsMajorKeySignature()
574
return m_pKeyRad[0]->GetValue();
577
int lmGrpKeyType::GetFifths()
579
int iK = m_pKeyList->GetSelection();
580
if (m_pKeyRad[0]->GetValue()) //if is major key signature
581
return m_tMajorKeys[iK].nFifths;
384
nFifths = m_tMinorKeys[iK].nFifths;
386
lmController* pSC = GetMainFrame()->GetActiveController();
389
pSC->InsertKeySignature(nFifths, fMajor);
391
//return focus to active view
392
GetMainFrame()->SetFocusOnActiveView();
583
return m_tMinorKeys[iK].nFifths;
396
586
void lmGrpKeyType::LoadKeyList(int nType)