Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmMain: Close all windows on preferences, edit & delete calendar
[xestiacalendar/.git] / source / forms / main / frmMain.cpp
index d04574f..8d6a4f8 100644 (file)
@@ -1,4 +1,4 @@
-// frmMain.h - frmMain form functions header.
+// frmMain.h - frmMain form functions
 //
 // (c) 2016-2017 Xestia Software Development.
 //
@@ -85,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 )
@@ -254,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;
@@ -374,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());
@@ -391,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.
@@ -469,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();
        
 }
@@ -478,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();
        
 }
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy