// frmContactEditor-Logo.cpp - frmContactEditor Logo tab subroutines.
//
// (c) 2012-2015 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// Xestia Address Book is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, version 3 of the license.
//
// Xestia Address Book is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see
#include "frmContactEditor.h"
#include "frmContactEditorPicture.h"
#include "../common/base64.h"
void frmContactEditor::LoadLogo( wxListEvent& event )
{
long longSelected = -1;
int intSelectedData = 0;
if (!GetSelectedItem(lboLogos,
&longSelected,
&intSelectedData)){
return;
}
std::string base64dec;
std::map::iterator initier;
initier = LogosList.find(intSelectedData);
base64dec = base64_decode(initier->second);
wxMemoryInputStream istream(base64dec.c_str(), (size_t)base64dec.size());
wxImage photo;
//wxMemoryInputStream istream(base64dec, (size_t)base64dec.size());
if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
return;
}
LogoImage = (wxBitmap)photo;
imgLogo->SetBitmap(LogoImage);
}
void frmContactEditor::AddLogo( wxCommandEvent& event )
{
int intResult = 0;
frmContactEditorPicture *frameCELogo = new frmContactEditorPicture ( this );
frameCELogo->SetEditorMode(FALSE);
intResult = GetLastInt(&LogosList);
frameCELogo->SetupPointers(&LogosList,
&LogosListAltID,
&LogosListPID,
&LogosListType,
&LogosListPicEncType,
&LogosListPictureType,
&LogosListTokens,
&LogosListMediatype,
&LogosListPref,
lboLogos,
(intValueSeek));
frameCELogo->ShowModal();
delete frameCELogo;
frameCELogo = NULL;
}
void frmContactEditor::ModifyLogo( wxCommandEvent& event )
{
long longSelected = -1;
int intSelectedData = 0;
if (!GetSelectedItem(lboLogos,
&longSelected,
&intSelectedData)){
return;
}
frmContactEditorPicture *frameCELogo = new frmContactEditorPicture ( this );
frameCELogo->SetupPointers(&LogosList,
&LogosListAltID,
&LogosListPID,
&LogosListType,
&LogosListPicEncType,
&LogosListPictureType,
&LogosListTokens,
&LogosListMediatype,
&LogosListPref,
lboLogos,
intSelectedData);
frameCELogo->SetEditorMode(TRUE);
frameCELogo->ShowModal();
delete frameCELogo;
frameCELogo = NULL;
}
void frmContactEditor::DeleteLogo( wxCommandEvent& event )
{
long longSelected = -1;
int intSelectedData = 0;
if (!GetSelectedItem(lboLogos,
&longSelected,
&intSelectedData)){
return;
}
lboLogos->DeleteItem(longSelected);
DeleteMapData(intSelectedData,
&LogosList, &LogosListAltID, &LogosListPID, &LogosListType,
&LogosListPicEncType, &LogosListPictureType, &LogosListTokens,
&LogosListMediatype, &LogosListPref);
wxMemoryInputStream istream(misc_emptyimage_png, sizeof(misc_emptyimage_png));
wxImage misc_emptyimage_png(istream, wxBITMAP_TYPE_PNG);
LogoImage = (wxBitmap)misc_emptyimage_png;
imgLogo->SetBitmap(LogoImage);
}
void frmContactEditor::SaveLogo( wxCommandEvent &event )
{
return;
}