X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Logo.cpp;h=5f0eba88891b69a0041e60246dc7cb125de51d84;hb=b19bbc6c6d83edfefba9c98e78a57d21eb8aa1a8;hp=b749bd62e20feede62c126b40e7635c4ca724e8b;hpb=5b2b2bcea1ab1dfd2b74589573cd16ee9326c4b9;p=xestiaab%2F.git
diff --git a/source/contacteditor/frmContactEditor-Logo.cpp b/source/contacteditor/frmContactEditor-Logo.cpp
index b749bd6..5f0eba8 100644
--- a/source/contacteditor/frmContactEditor-Logo.cpp
+++ b/source/contacteditor/frmContactEditor-Logo.cpp
@@ -1,3 +1,21 @@
+// 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"
@@ -116,3 +134,80 @@ void frmContactEditor::DeleteLogo( wxCommandEvent& event )
imgLogo->SetBitmap(LogoImage);
}
+void frmContactEditor::SaveLogo( wxCommandEvent &event )
+{
+
+ long longSelected = -1;
+ int intSelectedData = 0;
+
+ if (!GetSelectedItem(lboLogos,
+ &longSelected,
+ &intSelectedData)){
+
+ return;
+
+ }
+
+ wxString FileTypes;
+
+ wxString FinalFilename;
+
+ std::map::iterator initier;
+ std::map::iterator logotypeiter;
+
+ initier = LogosList.find(intSelectedData);
+ logotypeiter = LogosListPictureType.find(intSelectedData);
+
+ if (logotypeiter->second == wxT("image/jpeg")){
+
+ FileTypes.Append("JPEG Image (*.jpeg)|*.jpeg");
+
+ } else if (logotypeiter->second == wxT("image/png")){
+
+ FileTypes.Append("PNG Image (*.png)|*.png");
+
+ } else if (logotypeiter->second == wxT("image/gif")){
+
+ FileTypes.Append("GIF Image (*.gif)|*.gif");
+
+ } else {
+
+ wxMessageBox(_("Picture format for saving is not supported."), _("Picture format unsupported"), wxOK, this);
+ return;
+
+ }
+
+ // Open up the dialog to save the picture.
+
+ wxFileDialog ExportDlg(this, wxT("Save Logo"), wxT(""), wxT(""),
+ FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
+ if (ExportDlg.ShowModal() == wxID_CANCEL){
+
+ return;
+
+ }
+
+ // Write out the picture to the file.
+
+ wxFile LogoFile;
+
+ if (LogoFile.Open(ExportDlg.GetPath(), wxFile::write)){
+
+ std::string base64dec;
+
+ initier = LogosList.find(intSelectedData);
+ base64dec = base64_decode(initier->second);
+
+ LogoFile.Write(base64dec.c_str(), (size_t)base64dec.size());
+
+ LogoFile.Close();
+
+ } else {
+
+ wxMessageBox(_("An error occured whilst saving the logo. Check that you have free space and permissions to write the picture at this location."), _("Logo save error"), wxOK, this);
+ return;
+
+ }
+
+}
\ No newline at end of file