NCBI C++ ToolKit
save_hit_matrix_pdf_dlg.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 
2 #include <ncbi_pch.hpp>
7 
8 #include <gui/print/pdf.hpp>
9 
10 #include <corelib/ncbifile.hpp>
11 
12 #include <wx/utils.h>
13 #include <wx/msgdlg.h>
14 
15 #include <stdlib.h>
16 #include <string.h>
17 
18 // ----------------------------------------------------------------------------
19 // CSaveHitMatrixPdfDlg
20 // ----------------------------------------------------------------------------
21 
23 
25 
26 BEGIN_EVENT_TABLE(CSaveHitMatrixPdfDlg, CwxSavePdfBaseDlg)
28 
29 static const string kSavePdfBaseKey("SavePdfHitMatrixDialog");
30 
32  : CwxSavePdfBaseDlg(parent)
33  , m_Pane(pane)
34 {
35  LoadSettings(kSavePdfBaseKey);
36 
37  wxString path = ToWxString(m_Path);
38  if (!file_name.empty()) {
39  wxFileName file(path);
40  file.SetName(ToWxString(file_name));
41  path = file.GetFullPath();
42  }
43  m_FileNameBox->SetValue(path);
44 
45  m_IncludeToolTips->Hide();
46 }
47 
49 {
50  // For this pdf dialog, save the entire file path including filename
51  // since that is also chosen by the user
52  m_Path = m_FileNameBox->GetValue();
54 }
55 
56 void CSaveHitMatrixPdfDlg::x_Init(wxBoxSizer* mainsizer, int widget_width)
57 {
58 
59 }
60 
62 {
63 
64  return true;
65 }
66 
68 {
69  return true;
70 }
71 
73 {
74  SetCursor(*wxHOURGLASS_CURSOR);
75 
76  // add a progress bar to indicate that data are being updated
77  m_Info->SetLabel(_("Saving PDF File... Please Wait!"));
78  m_InfoSizer->Layout();
79  Layout();
80  m_Panel->Enable(false);
81  m_OpenButton->Enable(false);
82  m_SaveButton->Enable(false);
83  this->Update();
84 
85  CPdfGrabber grb_pdf(*m_Pane);
86 // grb_pdf.SaveTooltips(m_IncludeToolTips->GetValue());
87 
88  grb_pdf.SetOutputInfo(m_Path, m_FileName, "pdf");
90  grb_pdf.GrabImages(0/*dummy value, not used currently*/);
91 
92  // Set the cursor to its value prior to the save
93  SetCursor(*wxSTANDARD_CURSOR);
94  if (res == IImageGrabber::eOpenGLError) {
95  m_Info->SetLabel(_(""));
96  wxMessageBox(wxT("Graphics system does not support in-memory image save feature"),
97  wxT("Error Saving"), wxOK);
98  } else if (res == IImageGrabber::eFileError) {
99  m_Info->SetLabel(_(""));
100  m_Panel->Enable(true);
101  m_OpenButton->Enable(true);
102  m_SaveButton->Enable(true);
103  wxMessageBox(wxT("File error occured during save. Make sure file and directory names are valid."),
104  wxT("Error Saving"), wxOK);
105  } else {
106  m_Info->SetLabel(_("PDF file saved."));
107  if (m_OpenPdf) {
108  // May vary from actual name if user did not end file name with ".pdf"
109  wxString full_path = ToWxString(CDir::ConcatPath(m_Path, m_FileName + ".pdf"));
110  wxLaunchDefaultApplication(full_path);
111  m_OpenPdf = false;
112  }
113  }
114 
115  EndModal(wxID_CANCEL);
116 }
117 
118 
#define static
class CHitMatrixPane
virtual eCaptureResult GrabImages(int tex_size, IImageGrabberProgress *p=NULL)
Grab the requested images.
Definition: pdf_grabber.cpp:60
virtual void x_Init(wxBoxSizer *mainsizer, int widget_width)
void SaveSettings(const string &pdf_base_key) const
bool m_OpenPdf
view PDF file after finished.
void SetOutputInfo(const std::string &dir, const std::string &base_name, const std::string &img_format)
Set file output information.
#define _(proto)
Definition: ct_nlmzip_i.h:78
const char * file_name[]
IMPLEMENT_CLASS(CFloatingFrame, CFloatingFrameBaseClass) const static long kFloatFrameStyle
CFloatingFrame.
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
Definition: ncbifile.cpp:776
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
FILE * file
#define wxT(x)
Definition: muParser.cpp:41
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
static const string kSavePdfBaseKey("SavePdfHitMatrixDialog")
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
#define const
Definition: zconf.h:230
Modified on Mon Dec 11 02:35:50 2023 by modify_doxy.py rev. 669887