From: <pst...@us...> - 2008-04-07 04:54:18
|
Revision: 437 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=437&view=rev Author: pstieber Date: 2008-04-06 21:54:17 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Added a Save As... capability. Modified Paths: -------------- trunk/jazz/src/Harmony.cpp trunk/jazz/src/Harmony.h Modified: trunk/jazz/src/Harmony.cpp =================================================================== --- trunk/jazz/src/Harmony.cpp 2008-04-07 04:49:52 UTC (rev 436) +++ trunk/jazz/src/Harmony.cpp 2008-04-07 04:54:17 UTC (rev 437) @@ -44,7 +44,6 @@ using namespace std; -#define MEN_CLOSE 1 #define MEN_MIDI 2 #define MEN_TRANSPOSE 4 #define MEN_CLEARSEQ 6 @@ -71,7 +70,6 @@ #define MEN_IONSCALE 25 #define MEN_SETTINGS 26 #define MEN_LOAD 27 -#define MEN_SAVE 28 #include "Bitmaps/open.xpm" @@ -99,7 +97,7 @@ static JZToolDef tdefs[] = { { MEN_LOAD, false, open_xpm, "open harmony file" }, - { MEN_SAVE, false, save_xpm, "save harmony file" }, + { wxID_SAVEAS, false, save_xpm, "save harmony file" }, { JZToolBar::eToolBarSeparator }, { MEN_MAJSCALE, true, majscale_xpm, "major scale" }, { MEN_HARSCALE, true, harscale_xpm, "harmonic scale" }, @@ -479,6 +477,8 @@ void FileLoad(); + void FileSaveAs(); + void OnMenuCommand(int id, wxToolBar *mpToolBar); void TransposeSelection(); @@ -522,17 +522,15 @@ float mChordX, mChordY, mChordWidth, mChordHeight; - float ofs; + int mMargin; -// wxFrame* parent; - HBContext* seq[SEQMAX]; int mSequenceCount; std::string mDefaultFileName; - bool has_changed; + bool mHasChanged; HBContext mouse_context; @@ -614,10 +612,15 @@ mChordHeight = 2.5 * TextHeight; mChordX = 50; mChordY = 4 * mChordHeight; - ofs = TextHeight / 4; + mMargin = TextHeight / 4; + if (mMargin <= 0) + { + mMargin = 1; + } + mDefaultFileName = "noname.har"; - has_changed = false; + mHasChanged = false; SetScrollbars(0, (int)(mChordHeight + 0.5), 0, 12 + SEQMAX / 8 + 2, 0, 0); } @@ -777,10 +780,10 @@ Rectangle.y = (int)(mChordY + (5 * ct.ScaleNr() % 12) * mChordHeight); } - Rectangle.x += (int)ofs; - Rectangle.y -= (int)ofs; - Rectangle.width = (int)(mChordWidth - 2 * ofs); - Rectangle.height = (int)(mChordHeight - 2 * ofs); + Rectangle.x += mMargin; + Rectangle.y -= mMargin; + Rectangle.width = (int)(mChordWidth - 2 * mMargin); + Rectangle.height = (int)(mChordHeight - 2 * mMargin); } //----------------------------------------------------------------------------- @@ -1274,33 +1277,36 @@ mDefaultFileName.c_str(), "Load Harmonies", false, - has_changed, + mHasChanged, "*.har"); - ifstream Is(FileName.c_str()); - Is >> *this; + if (!FileName.empty()) + { + ifstream Is(FileName.c_str()); + Is >> *this; + } } +void HBCanvas::FileSaveAs() +{ + wxString FileName = file_selector( + mDefaultFileName.c_str(), + "Save Harmonies", + true, + mHasChanged, + "*.har"); + + if (!FileName.empty()) + { + ofstream os(FileName.c_str()); + os << *this; + } +} + void HBCanvas::OnMenuCommand(int id, wxToolBar *mpToolBar) { switch (id) { - case MEN_SAVE: - { - wxString fname = file_selector( - mDefaultFileName.c_str(), - "Save Harmonies", - true, - has_changed, - "*.har"); - if (fname) - { - ofstream os(fname); - os << *this; - } - } - break; - case MEN_MAJSCALE: SetScaleType(id, Major, mpToolBar); break; @@ -1770,6 +1776,8 @@ EVT_MENU(MEN_LOAD, HBFrame::OnFileLoad) + EVT_MENU(wxID_SAVEAS, HBFrame::OnFileSaveAs) + EVT_MENU(MEN_MIDI, HBFrame::OnSettingsMidi) EVT_MENU(MEN_HAUNSCH, HBFrame::OnSettingsHaunschild) @@ -1801,8 +1809,8 @@ wxMenu* pFileMenu = new wxMenu; pFileMenu->Append(MEN_LOAD, "&Load..."); - pFileMenu->Append(MEN_SAVE, "&Save"); - pFileMenu->Append(MEN_CLOSE, "&Close"); + pFileMenu->Append(wxID_SAVEAS, "Save &As..."); + pFileMenu->Append(wxID_CLOSE, "&Close"); wxMenu* pSettingsMenu = new wxMenu; pSettingsMenu->Append(MEN_EDIT, "&Chord"); @@ -1943,8 +1951,7 @@ mpHbWindow->seq[mpHbWindow->mouse_context.SeqNr() - 1]); break; - case MEN_CLOSE: -// DELETE_THIS(); + case wxID_CLOSE: Destroy(); break; @@ -1977,6 +1984,13 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void HBFrame::OnFileSaveAs(wxCommandEvent& Event) +{ + mpHbWindow->FileSaveAs(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void HBFrame::OnActionClearSequence(wxCommandEvent& Event) { mpHbWindow->ClearSeq(); Modified: trunk/jazz/src/Harmony.h =================================================================== --- trunk/jazz/src/Harmony.h 2008-04-07 04:49:52 UTC (rev 436) +++ trunk/jazz/src/Harmony.h 2008-04-07 04:54:17 UTC (rev 437) @@ -69,13 +69,13 @@ int SeqDefined(); - int GetChordKeys(int *out, int step, int n_steps); + int GetChordKeys(int* out, int step, int n_steps); - int GetSelectedChord(int *out); + int GetSelectedChord(int* out); - int GetSelectedScale(int *out); + int GetSelectedScale(int* out); - int GetBassKeys(int *out, int step, int n_steps); + int GetBassKeys(int* out, int step, int n_steps); HBAnalyzer* GetAnalyzer(); @@ -89,6 +89,8 @@ void OnFileLoad(wxCommandEvent& Event); + void OnFileSaveAs(wxCommandEvent& Event); + void OnSettingsMidi(wxCommandEvent& Event); void OnSettingsHaunschild(wxCommandEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |