File indexing completed on 2024-04-06 12:11:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <stdexcept>
0015 #include <iostream>
0016 #include "TGFileDialog.h"
0017
0018
0019 #include "Fireworks/Core/interface/FWViewBase.h"
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 FWViewBase::FWViewBase(FWViewType::EType type, unsigned int iVersion)
0033 : FWConfigurableParameterizable(iVersion), m_type(type) {}
0034
0035
0036
0037
0038
0039
0040 FWViewBase::~FWViewBase() {}
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 void FWViewBase::destroy() { beingDestroyed_(this); }
0058
0059
0060
0061
0062 void FWViewBase::promptForSaveImageTo(TGFrame* iParent) const {
0063 if (typeId() < FWViewType::kTable) {
0064 try {
0065 static TString dir(".");
0066 const char* kImageExportTypes[] = {"PNG",
0067 "*.png",
0068 "GIF",
0069 "*.gif",
0070 "JPEG",
0071 "*.jpg",
0072 "PDF",
0073 "*.pdf",
0074 "Encapsulated PostScript",
0075 "*.eps",
0076 nullptr,
0077 nullptr};
0078
0079 TGFileInfo fi;
0080 fi.fFileTypes = kImageExportTypes;
0081 fi.fIniDir = StrDup(dir);
0082 new TGFileDialog(gClient->GetDefaultRoot(), iParent, kFDSave, &fi);
0083 dir = fi.fIniDir;
0084 if (fi.fFilename != nullptr) {
0085 std::string name = fi.fFilename;
0086
0087
0088
0089 std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
0090 if (name.find(ext) == name.npos)
0091 name += ext;
0092 saveImageTo(name);
0093 }
0094 } catch (std::runtime_error& e) {
0095 std::cout << e.what() << std::endl;
0096 }
0097 } else {
0098 saveImageTo("dummy");
0099 }
0100 }
0101
0102 FWViewContextMenuHandlerBase* FWViewBase::contextMenuHandler() const { return nullptr; }
0103
0104
0105
0106
0107 const std::string& FWViewBase::typeName() const { return m_type.name(); }