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

Go to the SVN repository for this file.

1 /* $Id: job_results_dlg.cpp 44096 2019-10-25 15:20:48Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <wx/sizer.h>
35 #include <wx/button.h>
36 #include <wx/icon.h>
37 #include <wx/filedlg.h>
38 #include <wx/textbuf.h>
39 
40 ////@begin includes
41 ////@end includes
42 #include <html/html.hpp>
45 
46 ////@begin XPM images
47 ////@end XPM images
48 
50 
51 IMPLEMENT_DYNAMIC_CLASS( CJobResultsDlg, wxDialog )
52 
53 BEGIN_EVENT_TABLE( CJobResultsDlg, wxDialog )
54 
55 ////@begin CJobResultsDlg event table entries
57 ////@end CJobResultsDlg event table entries
58 
60 
62 {
63  Init();
64 }
65 
66 CJobResultsDlg::CJobResultsDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
67 {
68  Init();
69  Create(parent, id, caption, pos, size, style);
70 }
71 
72 bool CJobResultsDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
73 {
74 ////@begin CJobResultsDlg creation
75  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
76  wxDialog::Create( parent, id, caption, pos, size, style );
77 
79  if (GetSizer())
80  {
81  GetSizer()->SetSizeHints(this);
82  }
83  Centre();
84 ////@end CJobResultsDlg creation
85  return true;
86 }
87 
89 {
90 ////@begin CJobResultsDlg destruction
91 ////@end CJobResultsDlg destruction
92 }
93 
95 {
96 ////@begin CJobResultsDlg member initialisation
97 ////@end CJobResultsDlg member initialisation
98 }
99 
101 {
102 ////@begin CJobResultsDlg content construction
103  CJobResultsDlg* itemDialog1 = this;
104 
105  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
106  itemDialog1->SetSizer(itemBoxSizer2);
107 
108  wxHtmlWindow* itemHtmlWindow3 = new wxHtmlWindow( itemDialog1, ID_HTMLWINDOW1, wxDefaultPosition, itemDialog1->ConvertDialogToPixels(wxSize(350, 200)), wxHW_SCROLLBAR_AUTO|wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL );
109  itemBoxSizer2->Add(itemHtmlWindow3, 1, wxGROW|wxALL, 5);
110 
111  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
112  itemBoxSizer2->Add(itemBoxSizer5, 0, wxGROW|wxALL, 5);
113 
114  wxButton* itemButton11 = new wxButton(itemDialog1, ID_JOB_RESULTS_DLG_EXPORT, _("Export..."), wxDefaultPosition, wxDefaultSize, 0);
115  itemBoxSizer5->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
116 
117  itemBoxSizer5->AddStretchSpacer();
118 
119  wxButton* itemButton4 = new wxButton( itemDialog1, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
120  itemBoxSizer5->Add(itemButton4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
121 
122 ////@end CJobResultsDlg content construction
123 
124  wxHtmlWindow* htmlWnd = (wxHtmlWindow*)FindWindow(ID_HTMLWINDOW1);
125  if (htmlWnd) htmlWnd->SetPage(m_HTML);
126 }
127 
129 {
130  return true;
131 }
132 wxBitmap CJobResultsDlg::GetBitmapResource( const wxString& name )
133 {
134  // Bitmap retrieval
135 ////@begin CJobResultsDlg bitmap retrieval
136  wxUnusedVar(name);
137  return wxNullBitmap;
138 ////@end CJobResultsDlg bitmap retrieval
139 }
140 wxIcon CJobResultsDlg::GetIconResource( const wxString& name )
141 {
142  // Icon retrieval
143 ////@begin CJobResultsDlg icon retrieval
144  wxUnusedVar(name);
145  return wxNullIcon;
146 ////@end CJobResultsDlg icon retrieval
147 }
148 
149 void CJobResultsDlg::OnExportClick(wxCommandEvent& event)
150 {
151  wxFileDialog dlg(this, wxT("Select a file"), m_WorkDir, wxT(""),
153  wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
154 
155  if (dlg.ShowModal() != wxID_OK)
156  return;
157 
158  wxString path = dlg.GetPath();
159  if (!path.IsEmpty()) {
160  CNcbiOfstream os(path.fn_str(), ios::out);
161  string text = m_HTML.ToStdString();
162  NStr::ReplaceInPlace(text, "</h5>", wxString(wxTextBuffer::GetEOL()).ToStdString());
163  NStr::ReplaceInPlace(text, "<br />", wxString(wxTextBuffer::GetEOL()).ToStdString());
165  }
166 }
167 
static wxString GetDialogFilter(EFileType fileType)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnExportClick(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=10049, const wxString &caption=_("Job Results"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
static bool ShowToolTips()
#define _(proto)
Definition: ct_nlmzip_i.h:78
std::ofstream out("events_result.xml")
main entry point for tests
static void Init(void)
Definition: cursor6.c:76
static string StripHTML(const string &str)
Strip all HTML code from a string.
Definition: htmlhelper.hpp:173
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
Definition: ncbistre.hpp:500
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3405
HTML classes.
#define ID_JOB_RESULTS_DLG_EXPORT
#define ID_HTMLWINDOW1
END_EVENT_TABLE()
static void text(MDB_val *v)
Definition: mdb_dump.c:62
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Fri May 03 15:48:45 2024 by modify_doxy.py rev. 669887