From: <pst...@us...> - 2008-04-19 23:21:38
|
Revision: 465 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=465&view=rev Author: pstieber Date: 2008-04-19 16:21:32 -0700 (Sat, 19 Apr 2008) Log Message: ----------- Added a new version of the key on dialog. Added Paths: ----------- trunk/jazz/src/Dialogs/KeyOnDialog.cpp trunk/jazz/src/Dialogs/KeyOnDialog.h Added: trunk/jazz/src/Dialogs/KeyOnDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/KeyOnDialog.cpp (rev 0) +++ trunk/jazz/src/Dialogs/KeyOnDialog.cpp 2008-04-19 23:21:32 UTC (rev 465) @@ -0,0 +1,273 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2008 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#include "WxWidgets.h" + +#include "KeyOnDialog.h" + +#include "../Globals.h" +#include "../Project.h" +#include "../Events.h" +#include "../Knob.h" +#include "../KeyStringConverters.h" +#include "../Resources.h" + +#include <sstream> + +using namespace std; + +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(JZKeyOnDialog, wxDialog) + + EVT_KNOB_CHANGED(IDC_KB_VELOCITY, JZKeyOnDialog::OnVelocityChange) + + EVT_KNOB_CHANGED(IDC_KB_OFF_VELOCITY, JZKeyOnDialog::OnOffVelocityChange) + + EVT_KNOB_CHANGED(IDC_KB_CHANNEL, JZKeyOnDialog::OnChannelChange) + + EVT_BUTTON(wxID_HELP, JZKeyOnDialog::OnHelp) + +END_EVENT_TABLE() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZKeyOnDialog::JZKeyOnDialog(tKeyOn* pEvent, wxWindow* pParent) + : wxDialog(pParent, wxID_ANY, wxString("Key On")), + mpEvent(pEvent), + mpPitchEdit(0), + mpVelocityValue(0), + mpVelocityKnob(0), + mpOffVelocityValue(0), + mpOffVelocityKnob(0), + mpLengthEdit(0), + mpChannelValue(0), + mpChannelKnob(0), + mpClockEdit(0) +{ + mpPitchEdit = new wxTextCtrl(this, wxID_ANY); + + mpVelocityValue = new wxStaticText(this, wxID_ANY, "000"); + + mpVelocityKnob = new JZKnob(this, IDC_KB_VELOCITY, 0, 0, 127); + + mpOffVelocityValue = new wxStaticText(this, wxID_ANY, "000"); + + mpOffVelocityKnob = new JZKnob(this, IDC_KB_OFF_VELOCITY, 0, 0, 127); + + mpLengthEdit = new wxTextCtrl(this, wxID_ANY); + + mpChannelValue = new wxStaticText(this, wxID_ANY, "00"); + + mpChannelKnob = new JZKnob(this, IDC_KB_CHANNEL, 0, 1, 16); + + mpClockEdit = new wxTextCtrl(this, wxID_ANY); + + wxButton* pOkButton = new wxButton(this, wxID_OK, "&OK"); + wxButton* pCancelButton = new wxButton(this, wxID_CANCEL, "Cancel"); + wxButton* pHelpButton = new wxButton(this, wxID_HELP, "Help"); + pOkButton->SetDefault(); + + wxBoxSizer* pTopSizer = new wxBoxSizer(wxVERTICAL); + + wxFlexGridSizer* pFlexGridSizer; + + pFlexGridSizer = new wxFlexGridSizer(1, 2, 4, 2); + + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Pitch:"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add(mpPitchEdit, 0, wxALIGN_CENTER_VERTICAL); + + pTopSizer->Add(pFlexGridSizer, 0, wxCENTER | wxALL, 2); + + pFlexGridSizer = new wxFlexGridSizer(2, 3, 4, 2); + + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Velocity:"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add( + mpVelocityValue, + 0, + wxALIGN_CENTER_VERTICAL | wxFIXED_MINSIZE); + pFlexGridSizer->Add(mpVelocityKnob, 0, wxALIGN_CENTER_VERTICAL); + + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Off Velocity:"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add( + mpOffVelocityValue, + 0, + wxALIGN_CENTER_VERTICAL | wxFIXED_MINSIZE); + pFlexGridSizer->Add(mpOffVelocityKnob, 0, wxALIGN_CENTER_VERTICAL); + + pTopSizer->Add(pFlexGridSizer, 0, wxALIGN_CENTER); + + pFlexGridSizer = new wxFlexGridSizer(1, 2, 4, 2); + + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Length:"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add(mpLengthEdit, 0, wxALIGN_CENTER_VERTICAL); + + pTopSizer->Add(pFlexGridSizer, 0, wxCENTER | wxALL, 2); + + pFlexGridSizer = new wxFlexGridSizer(1, 3, 4, 2); + + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Channel:"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add( + mpChannelValue, + 0, + wxALIGN_CENTER_VERTICAL | wxFIXED_MINSIZE); + pFlexGridSizer->Add(mpChannelKnob, 0, wxALIGN_CENTER_VERTICAL); + + pTopSizer->Add(pFlexGridSizer, 0, wxCENTER | wxALL, 2); + + pFlexGridSizer = new wxFlexGridSizer(1, 2, 4, 2); + + pFlexGridSizer->Add( + new wxStaticText(this, wxID_ANY, "Clock:"), + 0, + wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); + pFlexGridSizer->Add(mpClockEdit, 0, wxALIGN_CENTER_VERTICAL); + + pTopSizer->Add(pFlexGridSizer, 0, wxCENTER | wxALL, 2); + + wxBoxSizer* pButtonSizer = new wxBoxSizer(wxHORIZONTAL); + pButtonSizer->Add(pOkButton, 0, wxALL, 5); + pButtonSizer->Add(pCancelButton, 0, wxALL, 5); + pButtonSizer->Add(pHelpButton, 0, wxALL, 5); + + pTopSizer->Add(pButtonSizer, 0, wxALIGN_CENTER | wxBOTTOM, 6); + + SetAutoLayout(true); + SetSizer(pTopSizer); + + pTopSizer->SetSizeHints(this); + pTopSizer->Fit(this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZKeyOnDialog::TransferDataToWindow() +{ + string KeyString; + KeyToString(mpEvent->mKey, KeyString); + mpPitchEdit->ChangeValue(KeyString.c_str()); + + ostringstream Oss; + + Oss << (int)mpEvent->mVelocity; + mpVelocityValue->SetLabel(Oss.str().c_str()); + + mpVelocityKnob->SetValue(mpEvent->mVelocity); + + Oss.str(""); + Oss << (int)mpEvent->GetOffVelocity(); + mpOffVelocityValue->SetLabel(Oss.str().c_str()); + + mpOffVelocityKnob->SetValue(mpEvent->GetOffVelocity()); + + wxString LengthString; + LengthString << mpEvent->Length; + mpLengthEdit->ChangeValue(LengthString); + + Oss.str(""); + Oss << (int)mpEvent->Channel + 1; + mpChannelValue->SetLabel(Oss.str().c_str()); + + mpChannelKnob->SetValue(mpEvent->Channel + 1); + + string ClockString; + gpProject->ClockToString(mpEvent->GetClock(), ClockString); + mpClockEdit->ChangeValue(ClockString.c_str()); + + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZKeyOnDialog::TransferDataFromWindow() +{ + wxString KeyString = mpPitchEdit->GetValue(); + mpEvent->mKey = StringToKey(KeyString.c_str()); + + mpEvent->mVelocity = mpVelocityKnob->GetValue(); + + mpEvent->SetOffVelocity(mpOffVelocityKnob->GetValue()); + + wxString LengthString = mpLengthEdit->GetValue(); + istringstream Iss(LengthString.c_str()); + Iss >> mpEvent->Length; + + mpEvent->Channel = mpChannelKnob->GetValue() - 1; + + wxString ClockString = mpClockEdit->GetValue(); + int Clock = gpProject->StringToClock(ClockString.c_str()); + mpEvent->SetClock(Clock); + + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKeyOnDialog::OnVelocityChange(JZKnobEvent& Event) +{ + int Value = Event.GetValue(); + ostringstream Oss; + Oss << Value; + mpVelocityValue->SetLabel(Oss.str().c_str()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKeyOnDialog::OnOffVelocityChange(JZKnobEvent& Event) +{ + int Value = Event.GetValue(); + ostringstream Oss; + Oss << Value; + mpOffVelocityValue->SetLabel(Oss.str().c_str()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKeyOnDialog::OnChannelChange(JZKnobEvent& Event) +{ + int Value = Event.GetValue(); + ostringstream Oss; + Oss << Value; + mpChannelValue->SetLabel(Oss.str().c_str()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZKeyOnDialog::OnHelp(wxCommandEvent& Event) +{ +// gpHelpInstance->ShowTopic("Key On Dialog"); +} Property changes on: trunk/jazz/src/Dialogs/KeyOnDialog.cpp ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/jazz/src/Dialogs/KeyOnDialog.h =================================================================== --- trunk/jazz/src/Dialogs/KeyOnDialog.h (rev 0) +++ trunk/jazz/src/Dialogs/KeyOnDialog.h 2008-04-19 23:21:32 UTC (rev 465) @@ -0,0 +1,71 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2008 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#ifndef JZ_KEYONDIALOG_H +#define JZ_KEYONDIALOG_H + +class tKeyOn; +class JZKnobEvent; +class JZKnob; + +//***************************************************************************** +//***************************************************************************** +class JZKeyOnDialog : public wxDialog +{ + public: + + JZKeyOnDialog(tKeyOn* pEvent, wxWindow* pParent); + + private: + + virtual bool TransferDataToWindow(); + + virtual bool TransferDataFromWindow(); + + void OnVelocityChange(JZKnobEvent& Event); + + void OnOffVelocityChange(JZKnobEvent& Event); + + void OnChannelChange(JZKnobEvent& Event); + + void OnHelp(wxCommandEvent& Event); + + private: + + tKeyOn* mpEvent; +// int mPitch; +// int mVelocity; +// int mLength; +// int mOffVelocity; + + wxTextCtrl* mpPitchEdit; + wxStaticText* mpVelocityValue; + JZKnob* mpVelocityKnob; + wxStaticText* mpOffVelocityValue; + JZKnob* mpOffVelocityKnob; + wxTextCtrl* mpLengthEdit; + wxStaticText* mpChannelValue; + JZKnob* mpChannelKnob; + wxTextCtrl* mpClockEdit; + + DECLARE_EVENT_TABLE(); +}; + +#endif // !defined(JZ_KEYONDIALOG_H) Property changes on: trunk/jazz/src/Dialogs/KeyOnDialog.h ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |