// frmMain-Window.h - frmMain form window functions. // // (c) 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" void frmMain::WindowAdd( wxCommandEvent &event ){ // Add a window to the window list. WindowData *receivedWindowData = (WindowData*)event.GetClientData(); size_t pos; wxMenuItem *mnuNewItem = new wxMenuItem(NULL, receivedWindowData->WindowID, wxT("Event Window #") + wxString::Format(wxT("%i"), receivedWindowData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL); mnuNewItem->SetId(receivedWindowData->WindowID); mnuWindow->Append(mnuNewItem); this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowEventWindow)); frmEventEditor *frmEventEditorPtr = static_cast(receivedWindowData->WindowPointer); wxString windowTitle = frmEventEditorPtr->GetTitle(); mnuNewItem->SetItemLabel(windowTitle); WindowListPointersMenu.insert(std::make_pair(receivedWindowData->WindowID, mnuNewItem)); WindowListPointers.insert(std::make_pair(receivedWindowData->WindowID, receivedWindowData->WindowPointer)); WindowListType.insert(std::make_pair(receivedWindowData->WindowID, 0)); delete receivedWindowData; receivedWindowData = NULL; } void frmMain::WindowUpdate( wxCommandEvent &event ){ // Add a window to the window list. WindowData *receivedWindowData = (WindowData*)event.GetClientData(); size_t pos; frmEventEditor *frmEventEditorPtr = static_cast(receivedWindowData->WindowPointer); wxString windowTitle = frmEventEditorPtr->GetTitle(); std::map::iterator MenuIter = WindowListPointersMenu.find(receivedWindowData->WindowID); MenuIter->second->SetItemLabel(windowTitle); delete receivedWindowData; receivedWindowData = NULL; } void frmMain::WindowDelete( wxCommandEvent &event ){ // Delete the window from the window list. WindowData *receivedWindowData = (WindowData*)event.GetClientData(); size_t pos; std::map::iterator menuIter = WindowListPointersMenu.find(receivedWindowData->WindowID); mnuWindow->Destroy(menuIter->second); WindowListPointersMenu.erase(receivedWindowData->WindowID); WindowListPointers.erase(receivedWindowData->WindowID); WindowListType.erase(receivedWindowData->WindowID); delete receivedWindowData; receivedWindowData = NULL; } void frmMain::ShowEventWindow( wxCommandEvent &event ){ // Show a contact window from the window list. std::map::iterator WindowIter = WindowListPointers.find(event.GetId()); frmEventEditor *frmEventEditorPtr = static_cast(WindowIter->second); frmEventEditorPtr->Show(); 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; } }