|
From: <pst...@us...> - 2008-04-06 18:26:28
|
Revision: 420
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=420&view=rev
Author: pstieber
Date: 2008-04-06 11:26:26 -0700 (Sun, 06 Apr 2008)
Log Message:
-----------
1. Changed tHelp to JZHelp.
2. Removed the global help instance from Help.cpp/.h and placed it in the global modules.
2. Changed the metronome class and dialog so that it records changes.
Modified Paths:
--------------
trunk/jazz/src/Dialogs/MetronomeSettingsDialog.cpp
trunk/jazz/src/Dialogs/MetronomeSettingsDialog.h
trunk/jazz/src/Globals.cpp
trunk/jazz/src/Globals.h
trunk/jazz/src/GuitarFrame.cpp
trunk/jazz/src/Help.cpp
trunk/jazz/src/Help.h
trunk/jazz/src/Metronome.cpp
trunk/jazz/src/Metronome.h
Modified: trunk/jazz/src/Dialogs/MetronomeSettingsDialog.cpp
===================================================================
--- trunk/jazz/src/Dialogs/MetronomeSettingsDialog.cpp 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Dialogs/MetronomeSettingsDialog.cpp 2008-04-06 18:26:26 UTC (rev 420)
@@ -28,7 +28,7 @@
#include "../Knob.h"
#include "../Resources.h"
-#include <vector>
+#include <iostream>
#include <sstream>
using namespace std;
@@ -41,6 +41,8 @@
EVT_KNOB_CHANGED(IDC_KB_VOLUME, JZMetronomeSettingsDialog::OnVolumeChange)
+ EVT_BUTTON(wxID_HELP, JZMetronomeSettingsDialog::OnHelp)
+
END_EVENT_TABLE()
//-----------------------------------------------------------------------------
@@ -50,12 +52,42 @@
JZMetronomeInfo& MetronomeInfo)
: wxDialog(pParent, wxID_ANY, wxString("Metronome Settings")),
mMetronomeInfo(MetronomeInfo),
+ mIndexToName(),
+ mIndexToPitch(),
+ mPitchToIndex(),
+ mKeyNormalName(),
+ mKeyAccentedName(),
mpVelocityKnob(0),
mpVelocityValue(0),
mpAccentedCheckBox(0),
mpNormalListbox(0),
mpAccentedListbox(0)
{
+ int Index = 0;
+ const vector<pair<string, int> >& DrumNames = gpConfig->GetDrumNames();
+ for (
+ vector<pair<string, int> >::const_iterator iDrumName = DrumNames.begin();
+ iDrumName != DrumNames.end();
+ ++iDrumName)
+ {
+ const string& DrumName = iDrumName->first;
+ const int& Value = iDrumName->second;
+
+ if (!DrumName.empty())
+ {
+ mIndexToName.push_back(DrumName);
+ mIndexToPitch.push_back(Value - 1);
+ mPitchToIndex.insert(make_pair(Value - 1, Index++));
+ }
+ }
+
+ mKeyNormalName =
+ mIndexToName[mPitchToIndex[mMetronomeInfo.GetKeyNormal()]];
+
+
+ mKeyAccentedName =
+ mIndexToName[mPitchToIndex[mMetronomeInfo.GetKeyAccented()]];
+
mpVelocityKnob = new JZKnob(this, IDC_KB_VOLUME, 100, 0, 127);
mpVelocityValue = new wxStaticText(this, wxID_ANY, "127");
@@ -64,29 +96,18 @@
mpNormalListbox = new wxListBox(this, wxID_ANY);
- int Selection = 0;
- int Index = 0;
+ mpAccentedListbox = new wxListBox(this, wxID_ANY);
+
for (
- vector<pair<string, int> >::const_iterator iPair = gSynthesizerTypes.begin();
- iPair != gSynthesizerTypes.end();
- ++iPair, ++Index)
+ vector<string>::const_iterator iName = mIndexToName.begin();
+ iName != mIndexToName.end();
+ ++iName)
{
- mpNormalListbox->Append(iPair->first.c_str());
- if (strcmp(iPair->first.c_str(), gpConfig->StrValue(C_SynthType)) == 0)
- {
- Selection = Index;
- }
+ const string& DrumName = *iName;
+ mpNormalListbox->Append(DrumName.c_str());
+ mpAccentedListbox->Append(DrumName.c_str());
}
- mpNormalListbox->SetSelection(Selection);
- mpAccentedListbox = new wxListBox(this, wxID_ANY);
-
- mpAccentedListbox->Append("Never");
- mpAccentedListbox->Append("Song Start");
- mpAccentedListbox->Append("Start Play");
-
- mpAccentedListbox->SetSelection(gpConfig->GetValue(C_SendSynthReset));
-
wxButton* pOkButton = new wxButton(this, wxID_OK, "&OK");
wxButton* pCancelButton = new wxButton(this, wxID_CANCEL, "Cancel");
wxButton* pHelpButton = new wxButton(this, wxID_HELP, "Help");
@@ -149,6 +170,41 @@
{
mpVelocityKnob->SetValueWithEvent(mMetronomeInfo.GetVelocity());
mpAccentedCheckBox->SetValue(mMetronomeInfo.IsAccented());
+
+ int Selection, Index;
+
+ Selection = 0;
+ Index = 0;
+ for (
+ vector<string>::const_iterator iName = mIndexToName.begin();
+ iName != mIndexToName.end();
+ ++iName, ++Index)
+ {
+ const string& DrumName = *iName;
+ if (DrumName == mKeyNormalName)
+ {
+ Selection = Index;
+ break;
+ }
+ }
+ mpNormalListbox->SetSelection(Selection);
+
+ Selection = 0;
+ Index = 0;
+ for (
+ vector<string>::const_iterator iName = mIndexToName.begin();
+ iName != mIndexToName.end();
+ ++iName, ++Index)
+ {
+ const string& DrumName = *iName;
+ if (DrumName == mKeyAccentedName)
+ {
+ Selection = Index;
+ break;
+ }
+ }
+ mpAccentedListbox->SetSelection(Selection);
+
return true;
}
@@ -159,6 +215,21 @@
mMetronomeInfo.SetVelocity(static_cast<unsigned char>(
mpVelocityKnob->GetValue()));
mMetronomeInfo.SetIsAccented(mpAccentedCheckBox->GetValue());
+
+ int Selection;
+
+ Selection = mpNormalListbox->GetSelection();
+ if (Selection != wxNOT_FOUND)
+ {
+ mMetronomeInfo.SetKeyNormal(mIndexToPitch[Selection]);
+ }
+
+ Selection = mpAccentedListbox->GetSelection();
+ if (Selection != wxNOT_FOUND)
+ {
+ mMetronomeInfo.SetKeyAccented(mIndexToPitch[Selection]);
+ }
+
return true;
}
@@ -171,3 +242,10 @@
Oss << Value;
mpVelocityValue->SetLabel(Oss.str().c_str());
}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZMetronomeSettingsDialog::OnHelp(wxCommandEvent& Event)
+{
+// gpHelpInstance->ShowTopic("Metronome Settings");
+}
Modified: trunk/jazz/src/Dialogs/MetronomeSettingsDialog.h
===================================================================
--- trunk/jazz/src/Dialogs/MetronomeSettingsDialog.h 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Dialogs/MetronomeSettingsDialog.h 2008-04-06 18:26:26 UTC (rev 420)
@@ -25,6 +25,10 @@
class JZKnob;
class JZKnobEvent;
+#include <vector>
+#include <string>
+#include <map>
+
//*****************************************************************************
//*****************************************************************************
class JZMetronomeSettingsDialog : public wxDialog
@@ -43,10 +47,22 @@
void OnVolumeChange(JZKnobEvent& Event);
+ void OnHelp(wxCommandEvent& Event);
+
private:
JZMetronomeInfo& mMetronomeInfo;
+ std::vector<std::string> mIndexToName;
+
+ std::vector<int> mIndexToPitch;
+
+ std::map<int, int> mPitchToIndex;
+
+ std::string mKeyNormalName;
+
+ std::string mKeyAccentedName;
+
JZKnob* mpVelocityKnob;
wxStaticText* mpVelocityValue;
Modified: trunk/jazz/src/Globals.cpp
===================================================================
--- trunk/jazz/src/Globals.cpp 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Globals.cpp 2008-04-06 18:26:26 UTC (rev 420)
@@ -39,7 +39,7 @@
JZPlayer* gpMidiPlayer = 0;
-tHelp* HelpInstance = 0;
+JZHelp* gpHelpInstance = 0;
vector<pair<string, int> > gLimitSteps;
Modified: trunk/jazz/src/Globals.h
===================================================================
--- trunk/jazz/src/Globals.h 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Globals.h 2008-04-06 18:26:26 UTC (rev 420)
@@ -33,7 +33,7 @@
class JZSong;
class JZSynth;
class JZPlayer;
-class tHelp;
+class JZHelp;
class JZProject;
class JZTrackFrame;
class JZTrackWindow;
@@ -49,7 +49,7 @@
extern JZSong* gpSong;
extern JZSynth* gpSynth;
extern JZPlayer* gpMidiPlayer;
-extern tHelp* HelpInstance;
+extern JZHelp* gpHelpInstance;
extern std::vector<std::pair<std::string, int> > gLimitSteps;
extern std::vector<std::pair<std::string, int> > gModes;
extern const int gScaleChromatic;
Modified: trunk/jazz/src/GuitarFrame.cpp
===================================================================
--- trunk/jazz/src/GuitarFrame.cpp 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/GuitarFrame.cpp 2008-04-06 18:26:26 UTC (rev 420)
@@ -113,7 +113,7 @@
//-----------------------------------------------------------------------------
void JZGuitarFrame::OnHelp(wxCommandEvent& event)
{
-// HelpInstance->ShowTopic("Guitar board");
+// gpHelpInstance->ShowTopic("Guitar board");
}
//-----------------------------------------------------------------------------
Modified: trunk/jazz/src/Help.cpp
===================================================================
--- trunk/jazz/src/Help.cpp 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Help.cpp 2008-04-06 18:26:26 UTC (rev 420)
@@ -25,36 +25,46 @@
#include "wx/html/helpctrl.h"
#include "Help.h"
+#include "Globals.h"
#include <iostream>
using namespace std;
-tHelp* gpHelpInstance = 0;
-
-tHelp::tHelp(const char* pHelpFleName)
+//*****************************************************************************
+// Description:
+// This is the help class definition.
+//*****************************************************************************
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZHelp::JZHelp(const char* pHelpFleName)
: mpHelp(0),
mHelpFile(pHelpFleName)
{
mpHelp = new wxHtmlHelpController();
mpHelp->Initialize(mHelpFile);
- cout << "tHelp::tHelp " << mHelpFile << endl;
+ cout << "JZHelp::JZHelp " << mHelpFile << endl;
}
-tHelp::~tHelp()
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+JZHelp::~JZHelp()
{
delete mpHelp;
}
-void tHelp::ShowTopic(const char* pTopic)
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZHelp::ShowTopic(const char* pTopic)
{
mpHelp->LoadFile(mHelpFile.c_str());
mpHelp->KeywordSearch(pTopic);
}
-void tHelp::DisplayContents()
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZHelp::DisplayContents()
{
mpHelp->LoadFile(mHelpFile.c_str());
mpHelp->DisplayContents();
}
-
Modified: trunk/jazz/src/Help.h
===================================================================
--- trunk/jazz/src/Help.h 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Help.h 2008-04-06 18:26:26 UTC (rev 420)
@@ -25,14 +25,18 @@
class wxHtmlHelpController;
-// a wrapper around the wx help classes.
-class tHelp
+//*****************************************************************************
+// Description:
+// This is the help class definition. This class implements a wrapper
+// around the wxWidgets help classes.
+//*****************************************************************************
+class JZHelp
{
public:
- tHelp(const char* pHelpFleName);
+ JZHelp(const char* pHelpFleName);
- ~tHelp();
+ ~JZHelp();
void ShowTopic(const char* pTopic);
@@ -45,6 +49,4 @@
wxString mHelpFile;
};
-extern tHelp* gpHelpInstance;
-
#endif // !defined(JZ_HELP_H)
Modified: trunk/jazz/src/Metronome.cpp
===================================================================
--- trunk/jazz/src/Metronome.cpp 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Metronome.cpp 2008-04-06 18:26:26 UTC (rev 420)
@@ -115,6 +115,20 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZMetronomeInfo::SetKeyNormal(unsigned char KeyNormal)
+{
+ mKeyNormal = KeyNormal;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void JZMetronomeInfo::SetKeyAccented(unsigned char KeyAccented)
+{
+ mKeyAccented = KeyAccented;
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZMetronomeInfo::SetVelocity(unsigned char Velocity)
{
mVelocity = Velocity;
Modified: trunk/jazz/src/Metronome.h
===================================================================
--- trunk/jazz/src/Metronome.h 2008-04-06 05:44:50 UTC (rev 419)
+++ trunk/jazz/src/Metronome.h 2008-04-06 18:26:26 UTC (rev 420)
@@ -41,6 +41,14 @@
void ReadFromConfiguration();
+ unsigned char GetKeyNormal() const;
+
+ void SetKeyNormal(unsigned char KeyNormal);
+
+ unsigned char GetKeyAccented() const;
+
+ void SetKeyAccented(unsigned char KeyAccented);
+
unsigned char GetVelocity() const;
void SetVelocity(unsigned char Velocity);
@@ -71,6 +79,18 @@
};
inline
+unsigned char JZMetronomeInfo::GetKeyNormal() const
+{
+ return mKeyNormal;
+}
+
+inline
+unsigned char JZMetronomeInfo::GetKeyAccented() const
+{
+ return mKeyAccented;
+}
+
+inline
unsigned char JZMetronomeInfo::GetVelocity() const
{
return mVelocity;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|