X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcontacteditor%2FfrmContactEditor-Picture.cpp;h=acefe6babf2c5ad14c5bc733b38eecec0e8f800d;hb=49daaa0014c2af71cec36ba1cd643255726727f4;hp=ce2bb561530aae020d9353e72630ae1b9ecf010d;hpb=da64d37d0a13895554e4ad945c46dd0af6d1c0e6;p=xestiaab%2F.git
diff --git a/source/contacteditor/frmContactEditor-Picture.cpp b/source/contacteditor/frmContactEditor-Picture.cpp
index ce2bb56..acefe6b 100644
--- a/source/contacteditor/frmContactEditor-Picture.cpp
+++ b/source/contacteditor/frmContactEditor-Picture.cpp
@@ -1,6 +1,6 @@
// frmContactEditor-Picture.cpp - frmContactEditor Picture tab subroutines.
//
-// (c) 2012-2015 Xestia Software Development.
+// (c) 2012-2016 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
@@ -16,6 +16,7 @@
// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see
+#include
#include "frmContactEditor.h"
#include "frmContactEditorPicture.h"
#include "../common/base64.h"
@@ -26,18 +27,19 @@ void frmContactEditor::AddPicture( wxCommandEvent& event )
frmContactEditorPicture *frameCEPicture = new frmContactEditorPicture ( this );
frameCEPicture->SetEditorMode(FALSE);
- intResult = GetLastInt(&PicturesList);
- frameCEPicture->SetupPointers(&PicturesList,
- &PicturesListAltID,
- &PicturesListPID,
- &PicturesListType,
- &PicturesListPicEncType,
- &PicturesListPictureType,
- &PicturesListTokens,
- &PicturesListMediatype,
- &PicturesListPref,
+ intResult = GetLastInt(&ContactEditorData.PicturesList);
+ frameCEPicture->SetupPointers(&ContactEditorData.PicturesList,
+ &ContactEditorData.PicturesListAltID,
+ &ContactEditorData.PicturesListPID,
+ &ContactEditorData.PicturesListType,
+ &ContactEditorData.PicturesListPicEncType,
+ &ContactEditorData.PicturesListPictureType,
+ &ContactEditorData.PicturesListTokens,
+ &ContactEditorData.PicturesListMediatype,
+ &ContactEditorData.PicturesListPref,
lboPictures,
- (intValueSeek));
+ (intValueSeek),
+ TRUE);
frameCEPicture->ShowModal();
delete frameCEPicture;
frameCEPicture = NULL;
@@ -55,17 +57,18 @@ void frmContactEditor::ModifyPicture( wxCommandEvent& event )
}
frmContactEditorPicture *frameCEPicture = new frmContactEditorPicture ( this );
- frameCEPicture->SetupPointers(&PicturesList,
- &PicturesListAltID,
- &PicturesListPID,
- &PicturesListType,
- &PicturesListPicEncType,
- &PicturesListPictureType,
- &PicturesListTokens,
- &PicturesListMediatype,
- &PicturesListPref,
+ frameCEPicture->SetupPointers(&ContactEditorData.PicturesList,
+ &ContactEditorData.PicturesListAltID,
+ &ContactEditorData.PicturesListPID,
+ &ContactEditorData.PicturesListType,
+ &ContactEditorData.PicturesListPicEncType,
+ &ContactEditorData.PicturesListPictureType,
+ &ContactEditorData.PicturesListTokens,
+ &ContactEditorData.PicturesListMediatype,
+ &ContactEditorData.PicturesListPref,
lboPictures,
- intSelectedData);
+ intSelectedData,
+ TRUE);
frameCEPicture->SetEditorMode(TRUE);
frameCEPicture->ShowModal();
delete frameCEPicture;
@@ -87,9 +90,9 @@ void frmContactEditor::DeletePicture( wxCommandEvent& event )
lboPictures->DeleteItem(longSelected);
DeleteMapData(intSelectedData,
- &PicturesList, &PicturesListAltID, &PicturesListPID, &PicturesListType,
- &PicturesListPicEncType, &PicturesListPictureType, &PicturesListTokens,
- &PicturesListMediatype, &PicturesListPref);
+ &ContactEditorData.PicturesList, &ContactEditorData.PicturesListAltID, &ContactEditorData.PicturesListPID, &ContactEditorData.PicturesListType,
+ &ContactEditorData.PicturesListPicEncType, &ContactEditorData.PicturesListPictureType, &ContactEditorData.PicturesListTokens,
+ &ContactEditorData.PicturesListMediatype, &ContactEditorData.PicturesListPref);
wxMemoryInputStream istream(misc_emptyimage_png, sizeof(misc_emptyimage_png));
wxImage misc_emptyimage_png(istream, wxBITMAP_TYPE_PNG);
@@ -115,8 +118,8 @@ void frmContactEditor::LoadPicture( wxListEvent& event )
std::map::iterator initier;
std::map::iterator pictypeiter;
- initier = PicturesList.find(intSelectedData);
- pictypeiter = PicturesListPictureType.find(intSelectedData);
+ initier = ContactEditorData.PicturesList.find(intSelectedData);
+ pictypeiter = ContactEditorData.PicturesListPictureType.find(intSelectedData);
base64dec = base64_decode(initier->second);
@@ -158,3 +161,81 @@ void frmContactEditor::LoadPicture( wxListEvent& event )
imgPicture->SetBitmap(PictureImage);
}
+
+void frmContactEditor::SavePicture( wxCommandEvent &event )
+{
+
+ long longSelected = -1;
+ int intSelectedData = 0;
+
+ if (!GetSelectedItem(lboPictures,
+ &longSelected,
+ &intSelectedData)){
+
+ return;
+
+ }
+
+ wxString FileTypes;
+
+ wxString FinalFilename;
+
+ std::map::iterator initier;
+ std::map::iterator pictypeiter;
+
+ initier = ContactEditorData.PicturesList.find(intSelectedData);
+ pictypeiter = ContactEditorData.PicturesListPictureType.find(intSelectedData);
+
+ if (pictypeiter->second == wxT("image/jpeg")){
+
+ FileTypes.Append("JPEG Image (*.jpeg)|*.jpeg");
+
+ } else if (pictypeiter->second == wxT("image/png")){
+
+ FileTypes.Append("PNG Image (*.png)|*.png");
+
+ } else if (pictypeiter->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 Picture"), wxT(""), wxT(""),
+ FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
+
+ if (ExportDlg.ShowModal() == wxID_CANCEL){
+
+ return;
+
+ }
+
+ // Write out the picture to the file.
+
+ wxFile PictureFile;
+
+ if (PictureFile.Open(ExportDlg.GetPath(), wxFile::write)){
+
+ std::string base64dec;
+
+ initier = ContactEditorData.PicturesList.find(intSelectedData);
+ base64dec = base64_decode(initier->second);
+
+ PictureFile.Write(base64dec.c_str(), (size_t)base64dec.size());
+
+ PictureFile.Close();
+
+ } else {
+
+ wxMessageBox(_("An error occured whilst saving the picture. Check that you have free space and permissions to write the picture at this location."), _("Picture save error"), wxOK, this);
+ return;
+
+ }
+
+}
\ No newline at end of file