Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Win32: implement further UTF8 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 ){
23         // Add a window to the window list.
24         
25         WindowData *receivedWindowData = (WindowData*)event.GetClientData();
27         size_t pos;
29         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, receivedWindowData->WindowID, wxT("Event Window #") + wxString::Format(wxT("%i"), receivedWindowData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
30         mnuNewItem->SetId(receivedWindowData->WindowID);
31         mnuWindow->Append(mnuNewItem);
32         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowEventWindow));
33         
34         frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(receivedWindowData->WindowPointer);
35         wxString windowTitle = frmEventEditorPtr->GetTitle();   
36         mnuNewItem->SetItemLabel(windowTitle);
37         
38         WindowListPointersMenu.insert(std::make_pair(receivedWindowData->WindowID, mnuNewItem));
39         WindowListPointers.insert(std::make_pair(receivedWindowData->WindowID, receivedWindowData->WindowPointer));
40         WindowListType.insert(std::make_pair(receivedWindowData->WindowID, 0));
41         
42         delete receivedWindowData;
43         receivedWindowData = NULL;
44         
45 }
47 void frmMain::WindowUpdate( wxCommandEvent &event ){
49         // Add a window to the window list.
50         
51         WindowData *receivedWindowData = (WindowData*)event.GetClientData();
53         size_t pos;
54         
55         frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(receivedWindowData->WindowPointer);
56         
57         wxString windowTitle = frmEventEditorPtr->GetTitle();
58         
59         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(receivedWindowData->WindowID);
60         
61         MenuIter->second->SetItemLabel(windowTitle);
62         
63         delete receivedWindowData;
64         receivedWindowData = NULL;
66 }
68 void frmMain::WindowDelete( wxCommandEvent &event ){
70         // Delete the window from the window list.
72         WindowData *receivedWindowData = (WindowData*)event.GetClientData();
73         
74         size_t pos;
75         
76         std::map<int, wxMenuItem*>::iterator menuIter = WindowListPointersMenu.find(receivedWindowData->WindowID);
77     
78         mnuWindow->Destroy(menuIter->second);
79         
80         WindowListPointersMenu.erase(receivedWindowData->WindowID);
81         WindowListPointers.erase(receivedWindowData->WindowID);
82         WindowListType.erase(receivedWindowData->WindowID);
83         
84         delete receivedWindowData;
85         receivedWindowData = NULL;
87 }
89 void frmMain::ShowEventWindow( wxCommandEvent &event ){
90     
91         // Show a contact window from the window list.
92     
93         std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
94     
95         frmEventEditor *frmEventEditorPtr = static_cast<frmEventEditor*>(WindowIter->second);
96     
97         frmEventEditorPtr->Show();
98         frmEventEditorPtr->Raise();
99     
102 bool frmMain::CloseAllWindows()
104         // Attempt to close all windows.
105         
106         if (WindowListPointersMenu.size() == 0)
107         {
108                 return true;
109         }
110         
111         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)
112         {
113                 for(std::map<int, void*>::iterator windowIter = WindowListPointers.begin();
114                         windowIter != WindowListPointers.end(); windowIter++)
115                 {
116                         wxWindow *windowPointer = static_cast<wxWindow*>(windowIter->second);
117                         windowPointer->Close();
118                 }
119                 return true;
120         }
121         else
122         {
123                 return false;
124         }
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