Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license header to the C++ source and header files in the contacte...
[xestiaab/.git] / source / contacteditor / frmContactEditor-Picture.cpp
1 // frmContactEditor-Picture.cpp - frmContactEditor Picture tab subroutines.
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 "frmContactEditor.h"
20 #include "frmContactEditorPicture.h"
21 #include "../common/base64.h"
23 void frmContactEditor::AddPicture( wxCommandEvent& event )
24 {
25     int intResult = 0;
26     
27     frmContactEditorPicture *frameCEPicture = new frmContactEditorPicture ( this );
28     frameCEPicture->SetEditorMode(FALSE);
29     intResult = GetLastInt(&PicturesList);
30     frameCEPicture->SetupPointers(&PicturesList,
31                                   &PicturesListAltID,
32                                   &PicturesListPID,
33                                   &PicturesListType,
34                                   &PicturesListPicEncType,
35                                   &PicturesListPictureType,
36                                   &PicturesListTokens,
37                                   &PicturesListMediatype,
38                                   &PicturesListPref,
39                                   lboPictures,
40                                   (intValueSeek));
41     frameCEPicture->ShowModal();
42     delete frameCEPicture;
43     frameCEPicture = NULL;
44 }
46 void frmContactEditor::ModifyPicture( wxCommandEvent& event )
47 {
48     long longSelected = -1;
49     int intSelectedData = 0;
50     
51     if (!GetSelectedItem(lboPictures,
52                          &longSelected,
53                          &intSelectedData)){
54         return;
55     }
56     
57     frmContactEditorPicture *frameCEPicture = new frmContactEditorPicture ( this );
58     frameCEPicture->SetupPointers(&PicturesList,
59                                   &PicturesListAltID,
60                                   &PicturesListPID,
61                                   &PicturesListType,
62                                   &PicturesListPicEncType,
63                                   &PicturesListPictureType,
64                                   &PicturesListTokens,
65                                   &PicturesListMediatype,
66                                   &PicturesListPref,
67                                   lboPictures,
68                                   intSelectedData);
69     frameCEPicture->SetEditorMode(TRUE);
70     frameCEPicture->ShowModal();
71     delete frameCEPicture;
72     frameCEPicture = NULL;
73     
74 }
76 void frmContactEditor::DeletePicture( wxCommandEvent& event )
77 {
78     long longSelected = -1;
79     int intSelectedData = 0;
80     
81     if (!GetSelectedItem(lboPictures,
82                          &longSelected,
83                          &intSelectedData)){
84         return;
85     }
86     
87     lboPictures->DeleteItem(longSelected);
88     
89     DeleteMapData(intSelectedData,
90                   &PicturesList, &PicturesListAltID, &PicturesListPID, &PicturesListType,
91                   &PicturesListPicEncType, &PicturesListPictureType, &PicturesListTokens,
92                   &PicturesListMediatype, &PicturesListPref);
93     
94     wxMemoryInputStream istream(misc_emptyimage_png, sizeof(misc_emptyimage_png));
95     wxImage misc_emptyimage_png(istream, wxBITMAP_TYPE_PNG);
96     PictureImage = (wxBitmap)misc_emptyimage_png;
97     
98     imgPicture->SetBitmap(PictureImage);
99 }
101 void frmContactEditor::LoadPicture( wxListEvent& event )
103     
104     long longSelected = -1;
105     int intSelectedData = 0;
106     
107     if (!GetSelectedItem(lboPictures,
108                          &longSelected,
109                          &intSelectedData)){
110         return;
111     }
112     
113     std::string base64dec;
114     
115     std::map<int,std::string>::iterator initier;
116     std::map<int,wxString>::iterator pictypeiter;
117     
118     initier = PicturesList.find(intSelectedData);
119     pictypeiter = PicturesListPictureType.find(intSelectedData);
120     
121     base64dec = base64_decode(initier->second);
122     
123     wxMemoryInputStream istream(base64dec.c_str(), (size_t)base64dec.size());
124     wxImage photo;
125     //wxMemoryInputStream istream(base64dec, (size_t)base64dec.size());
126     
127     if (pictypeiter->second == wxT("image/jpeg")){
128         
129         if (!photo.LoadFile(istream, wxBITMAP_TYPE_JPEG)){
130         
131             return;
132         
133         }
134         
135     } else if (pictypeiter->second == wxT("image/png")){
136         
137         if (!photo.LoadFile(istream, wxBITMAP_TYPE_PNG)){
138             
139             return;
140             
141         }
142         
143     } else if (pictypeiter->second == wxT("image/gif")){
144         
145         if (!photo.LoadFile(istream, wxBITMAP_TYPE_GIF)){
146             
147             return;
148             
149         }
150         
151     } else {
152     
153         return;
154     
155     }
156     
157     PictureImage = (wxBitmap)photo;
158     imgPicture->SetBitmap(PictureImage);
159     
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