|
From: <pst...@us...> - 2013-04-07 19:30:51
|
Revision: 1011
http://sourceforge.net/p/jazzplusplus/code/1011
Author: pstieber
Date: 2013-04-07 19:30:44 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
Added the ability to save a rhythm generator file.
Modified Paths:
--------------
trunk/jazz/src/Rhythm.cpp
trunk/jazz/src/Rhythm.h
Modified: trunk/jazz/src/Rhythm.cpp
===================================================================
--- trunk/jazz/src/Rhythm.cpp 2013-04-07 16:29:20 UTC (rev 1010)
+++ trunk/jazz/src/Rhythm.cpp 2013-04-07 19:30:44 UTC (rev 1011)
@@ -1693,6 +1693,24 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZRhythmGeneratorWindow::Write(ostream& Os)
+{
+ Win2Instrument();
+
+ Os << 2 << endl;
+ Os << mInstruments.size() << endl;
+ for (
+ vector<JZRhythm*>::const_iterator iInstrument = mInstruments.begin();
+ iInstrument != mInstruments.end();
+ ++iInstrument)
+ {
+ const JZRhythm& Instrument = **iInstrument;
+ Instrument.Write(Os);
+ }
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZRhythmGeneratorWindow::ClearInstruments()
{
for (
@@ -1847,6 +1865,8 @@
EVT_MENU(wxID_OPEN, JZRhythmGeneratorFrame::OnOpen)
+ EVT_MENU(wxID_SAVE, JZRhythmGeneratorFrame::OnSave)
+
EVT_MENU(ID_INSTRUMENT_ADD, JZRhythmGeneratorFrame::OnAddInstrument)
EVT_MENU(ID_INSTRUMENT_DELETE, JZRhythmGeneratorFrame::OnDeleteInstrument)
@@ -1965,6 +1985,27 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+void JZRhythmGeneratorFrame::OnSave(wxCommandEvent&)
+{
+ bool HasChanged = false;
+ wxString FileName = file_selector(
+ mDefaultFileName,
+ "Save Rhythm",
+ true,
+ HasChanged,
+ "*.rhy");
+ if (!FileName.empty())
+ {
+ ofstream Os(FileName.mb_str());
+ if (Os)
+ {
+ mpRhythmGeneratorWindow->Write(Os);
+ }
+ }
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
void JZRhythmGeneratorFrame::OnAddInstrument(wxCommandEvent&)
{
mpRhythmGeneratorWindow->AddInstrument();
Modified: trunk/jazz/src/Rhythm.h
===================================================================
--- trunk/jazz/src/Rhythm.h 2013-04-07 16:29:20 UTC (rev 1010)
+++ trunk/jazz/src/Rhythm.h 2013-04-07 19:30:44 UTC (rev 1011)
@@ -267,6 +267,8 @@
void Read(std::istream& Is);
+ void Write(std::ostream& Os);
+
void AddInstrument();
void DeleteInstrument();
@@ -328,6 +330,8 @@
void OnOpen(wxCommandEvent& Event);
+ void OnSave(wxCommandEvent& Event);
+
void OnAddInstrument(wxCommandEvent& Event);
void OnDeleteInstrument(wxCommandEvent& Event);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|