X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fforms%2Fmain%2FfrmMain.cpp;h=8d6a4f8a86d49ec0e8fcd195110bda6d0caa312c;hb=14524fdeb52ef649847928adbaef361e7498f32c;hp=e1f2bd9d229be4c9c90c9dea15cae180ff6ad1e3;hpb=457d38a9a7b94871b8df70e3a595fd316ca9c4c0;p=xestiacalendar%2F.git diff --git a/source/forms/main/frmMain.cpp b/source/forms/main/frmMain.cpp index e1f2bd9..8d6a4f8 100644 --- a/source/forms/main/frmMain.cpp +++ b/source/forms/main/frmMain.cpp @@ -1,3 +1,21 @@ +// frmMain.h - frmMain form functions +// +// (c) 2016-2017 Xestia Software Development. +// +// This file is part of Xestia Calendar. +// +// Xestia Calendar 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, version 3 of the license. +// +// Xestia Calendar 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 Xestia Calendar. If not, see + #include "frmMain.h" frmMain::frmMain( wxWindow* parent ) @@ -67,6 +85,10 @@ frmMainADT( parent ) Connect(ID_UPDATEENTRY, XCMAIN_UPDATEEVENT, wxCommandEventHandler(frmMain::UpdateEvent)); Connect(ID_EDITEVENT, XCMAIN_EDITEVENT, wxCommandEventHandler(frmMain::EditEvent)); + Connect(ID_ADDWINDOW, XCMAIN_ADDWINDOWINFO, wxCommandEventHandler(frmMain::WindowAdd)); + Connect(ID_UPDATEWINDOW, XCMAIN_UPDATEWINDOWINFO, wxCommandEventHandler(frmMain::WindowUpdate)); + Connect(ID_DELETEWINDOW, XCMAIN_DELETEWINDOWINFO, wxCommandEventHandler(frmMain::WindowDelete)); + } void frmMain::QuitApp( wxCloseEvent& event ) @@ -236,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; @@ -356,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()); @@ -373,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. @@ -451,6 +494,21 @@ void frmMain::CreateNewEvent( wxCommandEvent& event ){ frmEventEditor *frameNewEvent = new frmEventEditor ( this ); frameNewEvent->SetupForm(&calendarData, preferences); + frameNewEvent->SetWindowMenuItemID(++WindowMenuItemID); + + // Add the window to the window list. + + WindowData *newWindowData = new WindowData; + + newWindowData->DataType = 1; + newWindowData->WindowPointer = (void*)frameNewEvent; + newWindowData->WindowID = WindowMenuItemID; + + wxCommandEvent addevent(XCMAIN_ADDWINDOWINFO); + addevent.SetId(ID_ADDWINDOW); + addevent.SetClientData(newWindowData); + wxPostEvent(this, addevent); + frameNewEvent->Show(); } @@ -460,7 +518,24 @@ void frmMain::EditEvent( wxCommandEvent& event ){ frmEventEditor *frameEditEvent = new frmEventEditor ( this ); frameEditEvent->SetEventID(event.GetInt()); frameEditEvent->SetEditMode(true); + frameEditEvent->SetWindowMenuItemID(++WindowMenuItemID); frameEditEvent->SetupForm(&calendarData, preferences); + + // Add the window to the window list. + + WindowData *newWindowData = new WindowData; + + newWindowData->DataType = 1; + newWindowData->WindowPointer = (void*)frameEditEvent; + newWindowData->WindowID = WindowMenuItemID; + + wxCommandEvent addevent(XCMAIN_ADDWINDOWINFO); + addevent.SetId(ID_ADDWINDOW); + addevent.SetClientData(newWindowData); + wxPostEvent(this, addevent); + + // Setup the form and display it. + frameEditEvent->Show(); }