X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Logo.cpp;h=808e2d58769b07b0b6228e4a66cf29cfd54751b9;hb=bdb1cb146a16ae7f8e15aa9c9f084705a5249973;hp=94280d21839145161084ea44266091f57456b729;hpb=8398317ac255c2ece9e723aa4161f0e11ee0af3a;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Logo.cpp b/source/contacteditor/frmContactEditor-Logo.cpp index 94280d2..808e2d5 100644 --- a/source/contacteditor/frmContactEditor-Logo.cpp +++ b/source/contacteditor/frmContactEditor-Logo.cpp @@ -1,6 +1,6 @@ // frmContactEditor-Logo.cpp - frmContactEditor Logo tab subroutines. // -// (c) 2012-2015 Xestia Software Development. +// (c) 2012-2016 Xestia Software Development. // // This file is part of Xestia Address Book. // @@ -35,22 +35,46 @@ void frmContactEditor::LoadLogo( wxListEvent& event ) std::string base64dec; std::map::iterator initier; + std::map::iterator pictypeiter; - initier = LogosList.find(intSelectedData); + initier = ContactEditorData.LogosList.find(intSelectedData); + pictypeiter = ContactEditorData.LogosListPictureType.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)){ + if (pictypeiter->second == wxT("image/jpeg")){ - return; + if (!photo.LoadFile(istream, wxBITMAP_TYPE_JPEG)){ - } + return; + + } + + } else if (pictypeiter->second == wxT("image/png")){ + + if (!photo.LoadFile(istream, wxBITMAP_TYPE_PNG)){ + + return; + + } + + } else if (pictypeiter->second == wxT("image/gif")){ + + if (!photo.LoadFile(istream, wxBITMAP_TYPE_GIF)){ + + return; + + } + + } else { + return; + + } LogoImage = (wxBitmap)photo; imgLogo->SetBitmap(LogoImage); @@ -63,18 +87,19 @@ void frmContactEditor::AddLogo( wxCommandEvent& event ) frmContactEditorPicture *frameCELogo = new frmContactEditorPicture ( this ); frameCELogo->SetEditorMode(FALSE); - intResult = GetLastInt(&LogosList); - frameCELogo->SetupPointers(&LogosList, - &LogosListAltID, - &LogosListPID, - &LogosListType, - &LogosListPicEncType, - &LogosListPictureType, - &LogosListTokens, - &LogosListMediatype, - &LogosListPref, + intResult = GetLastInt(&ContactEditorData.LogosList); + frameCELogo->SetupPointers(&ContactEditorData.LogosList, + &ContactEditorData.LogosListAltID, + &ContactEditorData.LogosListPID, + &ContactEditorData.LogosListType, + &ContactEditorData.LogosListPicEncType, + &ContactEditorData.LogosListPictureType, + &ContactEditorData.LogosListTokens, + &ContactEditorData.LogosListMediatype, + &ContactEditorData.LogosListPref, lboLogos, - (intValueSeek)); + (intValueSeek), + FALSE); frameCELogo->ShowModal(); delete frameCELogo; frameCELogo = NULL; @@ -92,17 +117,18 @@ void frmContactEditor::ModifyLogo( wxCommandEvent& event ) } frmContactEditorPicture *frameCELogo = new frmContactEditorPicture ( this ); - frameCELogo->SetupPointers(&LogosList, - &LogosListAltID, - &LogosListPID, - &LogosListType, - &LogosListPicEncType, - &LogosListPictureType, - &LogosListTokens, - &LogosListMediatype, - &LogosListPref, + frameCELogo->SetupPointers(&ContactEditorData.LogosList, + &ContactEditorData.LogosListAltID, + &ContactEditorData.LogosListPID, + &ContactEditorData.LogosListType, + &ContactEditorData.LogosListPicEncType, + &ContactEditorData.LogosListPictureType, + &ContactEditorData.LogosListTokens, + &ContactEditorData.LogosListMediatype, + &ContactEditorData.LogosListPref, lboLogos, - intSelectedData); + intSelectedData, + FALSE); frameCELogo->SetEditorMode(TRUE); frameCELogo->ShowModal(); delete frameCELogo; @@ -123,9 +149,9 @@ void frmContactEditor::DeleteLogo( wxCommandEvent& event ) lboLogos->DeleteItem(longSelected); DeleteMapData(intSelectedData, - &LogosList, &LogosListAltID, &LogosListPID, &LogosListType, - &LogosListPicEncType, &LogosListPictureType, &LogosListTokens, - &LogosListMediatype, &LogosListPref); + &ContactEditorData.LogosList, &ContactEditorData.LogosListAltID, &ContactEditorData.LogosListPID, &ContactEditorData.LogosListType, + &ContactEditorData.LogosListPicEncType, &ContactEditorData.LogosListPictureType, &ContactEditorData.LogosListTokens, + &ContactEditorData.LogosListMediatype, &ContactEditorData.LogosListPref); wxMemoryInputStream istream(misc_emptyimage_png, sizeof(misc_emptyimage_png)); wxImage misc_emptyimage_png(istream, wxBITMAP_TYPE_PNG); @@ -137,6 +163,77 @@ void frmContactEditor::DeleteLogo( wxCommandEvent& event ) void frmContactEditor::SaveLogo( wxCommandEvent &event ) { - return; + 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 = ContactEditorData.LogosList.find(intSelectedData); + logotypeiter = ContactEditorData.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 = ContactEditorData.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