Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
CalDAV: WIP CalDAV support
[xestiacalendar/.git] / source / forms / main / frmMain-Window.cpp
1 // frmMain-Window.h - frmMain form window functions.
2 //
3 // (c) 2017 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
7 // Xestia Calendar is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Calendar is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "frmMain.h"
21 void frmMain::WindowAdd( wxCommandEvent &event )
22 {
24         // Add a window to the window list.
25         
26         WindowData *receivedWindowData = (WindowData*)event.GetClientData();
28         size_t pos;
30         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, receivedWindowData->WindowID, wxT("Event Window #") + wxString::Format(wxT("%i"), receivedWindowData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
31         mnuNewItem->SetId(receivedWindowData->WindowID);
32         mnuWindow->Append(mnuNewItem);
33         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowEventWindow));
34         
35         frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(receivedWindowData->WindowPointer);
36         wxString windowTitle = frmEventEditorPtr->GetTitle();   
37         mnuNewItem->SetItemLabel(windowTitle);
38         
39         windowListPointersMenu.insert(std::make_pair(receivedWindowData->WindowID, mnuNewItem));
40         windowListPointers.insert(std::make_pair(receivedWindowData->WindowID, receivedWindowData->WindowPointer));
41         windowListType.insert(std::make_pair(receivedWindowData->WindowID, 0));
42         
43         delete receivedWindowData;
44         receivedWindowData = NULL;
45         
46 }
48 void frmMain::WindowUpdate( wxCommandEvent &event )
49 {
51         // Add a window to the window list.
52         
53         WindowData *receivedWindowData = (WindowData*)event.GetClientData();
55         size_t pos;
56         
57         frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(receivedWindowData->WindowPointer);
58         
59         wxString windowTitle = frmEventEditorPtr->GetTitle();
60         
61         std::map<int, wxMenuItem*>::iterator MenuIter = windowListPointersMenu.find(receivedWindowData->WindowID);
62         
63         MenuIter->second->SetItemLabel(windowTitle);
64         
65         delete receivedWindowData;
66         receivedWindowData = NULL;
68 }
70 void frmMain::WindowDelete( wxCommandEvent &event )
71 {
73         // Delete the window from the window list.
75         WindowData *receivedWindowData = (WindowData*)event.GetClientData();
76         
77         size_t pos;
78         
79         std::map<int, wxMenuItem*>::iterator menuIter = windowListPointersMenu.find(receivedWindowData->WindowID);
80     
81         mnuWindow->Destroy(menuIter->second);
82         
83         windowListPointersMenu.erase(receivedWindowData->WindowID);
84         windowListPointers.erase(receivedWindowData->WindowID);
85         windowListType.erase(receivedWindowData->WindowID);
86         
87         delete receivedWindowData;
88         receivedWindowData = NULL;
90 }
92 void frmMain::ShowEventWindow( wxCommandEvent &event )
93 {
94     
95         // Show a contact window from the window list.
96     
97         std::map<int, void*>::iterator WindowIter = windowListPointers.find(event.GetId());
98     
99         frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(WindowIter->second);
100     
101         frmEventEditorPtr->Show();
102         frmEventEditorPtr->Raise();
103     
106 bool frmMain::CloseAllWindows()
108         // Attempt to close all windows.
109         
110         if (windowListPointersMenu.size() == 0)
111         {
112                 return true;
113         }
114         
115         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)
116         {
117                 for(std::map<int, void*>::iterator windowIter = windowListPointers.begin();
118                         windowIter != windowListPointers.end(); windowIter++)
119                 {
120                         wxWindow *windowPointer = static_cast<wxWindow*>(windowIter->second);
121                         windowPointer->Close();
122                 }
123                 return true;
124         }
125         else
126         {
127                 return false;
128         }
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