Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
getcontactinfo.cpp: Fix issue with using wxTransparentColour
[xestiaab/.git] / source / frmContact.cpp
1 // frmContact.cpp - Contact information form.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book 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 Address Book 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 Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContact.h"
20 #include "common/getcontactinfo.h"
21 #include "frmMain.h"
22 #include <wx/fs_mem.h>
23 #include <wx/filesys.h>
24 #include <wx/app.h>
26 BEGIN_EVENT_TABLE(frmContact, wxFrame)
27 END_EVENT_TABLE()
29 frmContact::frmContact( wxWindow* parent )
30 :
31 frmContactADT( parent )
32 {
34 }
36 void frmContact::CloseWindowProcessing(){
38 }
40 void frmContact::CloseWindow( wxCommandEvent& event ){
41                 
42         // Close this window.
43         
44         this->Close();
46 }
48 void frmContact::CloseWindow( wxCloseEvent& event ){
50         // Off for peppermint tea. Better clean up first or
51         // we'll be in for it later.
53         wxFileSystem::AddHandler(new wxMemoryFSHandler);
55         // Check if frmContact is the main window, if not
56         // then do some clear up.
57         
58         if (StartupMode == false){
59         
60                 if (MemoryFSListPtr->find(SessionID) == MemoryFSListPtr->end()){
62                 } else {
64                         std::map<wxString, wxString>::iterator striter;
66                         for (striter = MemoryFSListPtr->begin(); striter != MemoryFSListPtr->end(); striter++){
68                                 if (SessionID == striter->second){
70                                         // Delete the references from the wxMemoryFSHandler
71                                         // and the entry from the map.
73                                         wxMemoryFSHandler::RemoveFile(striter->first);
75                                         break;
77                                 }
79                         }
81                         MemoryFSListPtr->erase(striter);
83                 }
84         
85                 WindowData *WData = new WindowData;
87                 WData->DataType = 0;
88                 WData->WindowPointer = this;
89                 WData->WindowID = ContactUID;
91                 wxCommandEvent delevent(WINDOW_CLOSE);
92                 delevent.SetClientData(WData);
93                 wxPostEvent(GetParent(), delevent);
94         
95         }
96                 
97         Destroy();
99 }
101 bool frmContact::SetupContactData(vCard *vCardObj){
103         // Setup the contact information.
104         
105         wxFileSystem::AddHandler(new wxMemoryFSHandler);
106         
107         for (std::map<wxString, wxString>::iterator striter = MemoryFSListPtr->begin();
108         striter != MemoryFSListPtr->end(); striter++){
110                 if (SessionID == striter->second){
112                         // Delete the references from the wxMemoryFSHandler
113                         // and the entry from the map.
115                         wxMemoryFSHandler::RemoveFile(striter->first);
116                         MemoryFSListPtr->erase(striter);
118                 }
120         }
122         OldSessionID = SessionID;
123         SessionID = wxString::Format(wxT("%i"), rand() % 32768);
124         wxColour formattedBackgroundColour;
125         if (backgroundColour.IsEmpty())
126         {
127         
128                 formattedBackgroundColour = wxTransparentColour;
129         
130         }
131         else
132         {
133         
134                 formattedBackgroundColour.Set(backgroundColour);
135         
136         }
137         
138         
139         LoadContactData(vCardObj, htmContactData, SessionID, OldSessionID, MemoryFSListPtr, formattedBackgroundColour);
140         ArrayvCardOutData FNList;
141         FNList = vCardObj->GetByPartial(wxT("FN"));
142         
143         if (FNList.PropCount > 0){
144                 FNList.PropValues[0].Trim();
145                 SetTitle(FNList.PropValues[0]);
146         }
147         
148         if (StartupMode == false){
149         
150                 WindowData *WData = new WindowData;
152                 vCardFilename = vCardObj->GetFilename();
154                 WData->DataType = 0;
155                 WData->WindowPointer = this;
156                 WData->WindowID = ContactUID;
157         
158                 wxCommandEvent editevent(WINDOW_EDIT);
159                 editevent.SetClientData(WData);
160                 wxPostEvent(GetParent(), editevent);
161                 
162         }
164         return TRUE;
167 void frmContact::SetMode(bool StartupModeIn){
169         // Set the mode which frmContact will be operating.
170         
171         StartupMode = StartupModeIn;
172         
175 void frmContact::SetupPointers(std::map<wxString,wxString> *MemoryFSListIncPtr){
177         // Set the pointer for the Memory Filesystem map.
178         
179         MemoryFSListPtr = MemoryFSListIncPtr;
183 void frmContact::SetUID(int UID){
185         // Set the UID of the contact window.
186         
187         ContactUID = UID;
191 wxString frmContact::GetFilename(){
193         // Get the filename of the contact being displayed.
194         
195         return vCardFilename;
199 void frmContact::SetBackgroundColour(wxString backgroundColour){
200         
201         // Set the background colour.
202         
203         this->backgroundColour = backgroundColour;
204         
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