1 // frmContactEditor-Logo.cpp - frmContactEditor Logo tab subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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::LoadLogo( wxListEvent& event )
26 long longSelected = -1;
27 int intSelectedData = 0;
29 if (!GetSelectedItem(lboLogos,
35 std::string base64dec;
37 std::map<int,std::string>::iterator initier;
39 initier = LogosList.find(intSelectedData);
41 base64dec = base64_decode(initier->second);
44 wxMemoryInputStream istream(base64dec.c_str(), (size_t)base64dec.size());
46 //wxMemoryInputStream istream(base64dec, (size_t)base64dec.size());
48 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
55 LogoImage = (wxBitmap)photo;
56 imgLogo->SetBitmap(LogoImage);
60 void frmContactEditor::AddLogo( wxCommandEvent& event )
64 frmContactEditorPicture *frameCELogo = new frmContactEditorPicture ( this );
65 frameCELogo->SetEditorMode(FALSE);
66 intResult = GetLastInt(&LogosList);
67 frameCELogo->SetupPointers(&LogosList,
72 &LogosListPictureType,
78 frameCELogo->ShowModal();
83 void frmContactEditor::ModifyLogo( wxCommandEvent& event )
85 long longSelected = -1;
86 int intSelectedData = 0;
88 if (!GetSelectedItem(lboLogos,
94 frmContactEditorPicture *frameCELogo = new frmContactEditorPicture ( this );
95 frameCELogo->SetupPointers(&LogosList,
100 &LogosListPictureType,
106 frameCELogo->SetEditorMode(TRUE);
107 frameCELogo->ShowModal();
112 void frmContactEditor::DeleteLogo( wxCommandEvent& event )
114 long longSelected = -1;
115 int intSelectedData = 0;
117 if (!GetSelectedItem(lboLogos,
123 lboLogos->DeleteItem(longSelected);
125 DeleteMapData(intSelectedData,
126 &LogosList, &LogosListAltID, &LogosListPID, &LogosListType,
127 &LogosListPicEncType, &LogosListPictureType, &LogosListTokens,
128 &LogosListMediatype, &LogosListPref);
130 wxMemoryInputStream istream(misc_emptyimage_png, sizeof(misc_emptyimage_png));
131 wxImage misc_emptyimage_png(istream, wxBITMAP_TYPE_PNG);
132 LogoImage = (wxBitmap)misc_emptyimage_png;
134 imgLogo->SetBitmap(LogoImage);
137 void frmContactEditor::SaveLogo( wxCommandEvent &event )