From: <pst...@us...> - 2013-03-17 10:18:23
|
Revision: 957 http://sourceforge.net/p/jazzplusplus/code/957 Author: pstieber Date: 2013-03-17 10:18:20 +0000 (Sun, 17 Mar 2013) Log Message: ----------- Added code to handle application close via the X while playing. Modified Paths: -------------- trunk/jazz/src/TrackFrame.cpp trunk/jazz/src/TrackFrame.h Modified: trunk/jazz/src/TrackFrame.cpp =================================================================== --- trunk/jazz/src/TrackFrame.cpp 2013-01-10 04:23:56 UTC (rev 956) +++ trunk/jazz/src/TrackFrame.cpp 2013-03-17 10:18:20 UTC (rev 957) @@ -77,6 +77,8 @@ //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(JZTrackFrame, JZEventFrame) + EVT_CLOSE(JZTrackFrame::OnClose) + EVT_MENU(wxID_NEW, JZTrackFrame::OnFileNew) EVT_MENU(wxID_OPEN, JZTrackFrame::OnFileOpenProject) @@ -472,6 +474,34 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZTrackFrame::OnClose(wxCloseEvent& CloseEvent) +{ + if (CloseEvent.CanVeto() && mpProject && mpProject->IsPlaying()) + { + if ( + wxMessageBox( + "Currently playing the MIDI file... continue closing?", + "Please confirm", + wxICON_QUESTION | wxYES_NO) != wxYES ) + { + CloseEvent.Veto(); + return; + } + } + + if (mpProject && mpProject->IsPlaying()) + { + // Since we cannont veto the close event, stop a playing project. + mpProject->Stop(); + } + + // At this point, we can either call Destroy(), or CloseEvent.Skip() + // since the default event handler also calls Destroy(). + CloseEvent.Skip(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZTrackFrame::OnFileNew(wxCommandEvent& Event) { if (wxMessageBox("Clear Song?", "Sure?", wxOK | wxCANCEL) == wxOK) Modified: trunk/jazz/src/TrackFrame.h =================================================================== --- trunk/jazz/src/TrackFrame.h 2013-01-10 04:23:56 UTC (rev 956) +++ trunk/jazz/src/TrackFrame.h 2013-03-17 10:18:20 UTC (rev 957) @@ -69,6 +69,8 @@ void CreateMenu(); + void OnClose(wxCloseEvent& CloseEvent); + void OnFileNew(wxCommandEvent& Event); void OnFileOpenProject(wxCommandEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |