From: Steve Brokenshire Date: Sun, 16 Apr 2017 16:12:19 +0000 (+0100) Subject: frmMain: Close all windows on preferences, edit & delete calendar X-Git-Tag: release-0.03~1 X-Git-Url: http://Server1/repobrowser/?a=commitdiff_plain;h=cc5af07fed91fda6b067780c62d545ba48740c64;p=xestiacalendar%2F.git frmMain: Close all windows on preferences, edit & delete calendar --- diff --git a/source/forms/main/frmMain-Window.cpp b/source/forms/main/frmMain-Window.cpp index 401eead..ab1c7cb 100644 --- a/source/forms/main/frmMain-Window.cpp +++ b/source/forms/main/frmMain-Window.cpp @@ -98,4 +98,28 @@ void frmMain::ShowEventWindow( wxCommandEvent &event ){ frmEventEditorPtr->Raise(); } + +bool frmMain::CloseAllWindows() +{ + // Attempt to close all windows. + + if (WindowListPointersMenu.size() == 0) + { + return true; + } + + if (wxMessageBox(_("Before preforming the action, all windows that are open will need to close. Do you wish to continue?"), _("Close All Windowss"), wxYES_NO) == wxYES) + { + for(std::map::iterator windowIter = WindowListPointers.begin(); + windowIter != WindowListPointers.end(); windowIter++) + { + wxWindow *windowPointer = static_cast(windowIter->second); + windowPointer->Close(); + } + return true; + } + else + { + return false; + } } \ No newline at end of file diff --git a/source/forms/main/frmMain.cpp b/source/forms/main/frmMain.cpp index 835118b..8d6a4f8 100644 --- a/source/forms/main/frmMain.cpp +++ b/source/forms/main/frmMain.cpp @@ -258,6 +258,13 @@ void frmMain::LoadAccountData(){ void frmMain::ShowPreferencesWindow( wxCommandEvent& event ) { + // Close all windows first. + + if (CloseAllWindows() == false) + { + return; + } + // Open the preferences window. reloadAccounts = FALSE; @@ -378,6 +385,13 @@ void frmMain::CreateNewCalendar( wxCommandEvent& event ) void frmMain::EditCalendar( wxCommandEvent& event ) { + // Close all windows first. + + if (CloseAllWindows() == false) + { + return; + } + // Get the calendar data. CDSGetCalendarInfo calendarInfo = calendarData.GetCalendar(event.GetInt()); @@ -395,6 +409,13 @@ void frmMain::EditCalendar( wxCommandEvent& event ) void frmMain::DeleteCalendar( wxCommandEvent& event ) { + // Close all windows first. + + if (CloseAllWindows() == false) + { + return; + } + CalendarProperties *calendarEventInfo = (CalendarProperties*)event.GetClientData(); // Get the calendar data. diff --git a/source/forms/main/frmMain.h b/source/forms/main/frmMain.h index 23b9079..37930ae 100644 --- a/source/forms/main/frmMain.h +++ b/source/forms/main/frmMain.h @@ -90,6 +90,8 @@ class frmMain : public frmMainADT void WindowUpdate( wxCommandEvent& event ); void WindowDelete( wxCommandEvent& event ); void ShowEventWindow( wxCommandEvent &event ); + bool CloseAllWindows(); + public: /** Constructor */ frmMain( wxWindow* parent );