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

Go to the SVN repository for this file.

1 /* $Id: phy_export_page.cpp 39318 2017-09-12 16:00:18Z evgeniev $
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 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <wx/sizer.h>
33 #include <wx/checkbox.h>
34 #include <wx/choice.h>
35 #include <wx/bmpbuttn.h>
36 #include <wx/textctrl.h>
37 #include <wx/stattext.h>
38 #include <wx/valgen.h>
39 #include <wx/valtext.h>
40 #include <wx/msgdlg.h>
41 #include <wx/filedlg.h>
42 #include <wx/bitmap.h>
43 #include <wx/icon.h>
44 #include <wx/artprov.h>
45 
46 #include <corelib/ncbifile.hpp>
47 
52 
53 ////@begin includes
54 ////@end includes
55 
56 #include "phy_export_page.hpp"
57 
58 ////@begin XPM images
59 ////@end XPM images
60 
61 
63 
64 /*!
65  * CPhyExportPage type definition
66  */
67 
68 IMPLEMENT_DYNAMIC_CLASS( CPhyExportPage, wxPanel )
69 
70 
71 /*!
72  * CPhyExportPage event table definition
73  */
74 
75 BEGIN_EVENT_TABLE( CPhyExportPage, wxPanel )
76 
77 ////@begin CPhyExportPage event table entries
78 EVT_BUTTON(ID_BITMAPBUTTON1, CPhyExportPage::OnButton2Click)
79 
80 ////@end CPhyExportPage event table entries
81 
83 
84 
85 /*!
86  * CPhyExportPage constructors
87  */
88 
90 {
91  Init();
92 }
93 
94 CPhyExportPage::CPhyExportPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
95 {
96  Init();
97  Create(parent, id, pos, size, style);
98 }
99 
100 
101 /*!
102  * CAgpPExportPage creator
103  */
104 
105 bool CPhyExportPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
106 {
107  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
108  wxPanel::Create( parent, id, pos, wxSize(0,0), style );
109  Hide();
110 
111  CreateControls();
112  if (GetSizer())
113  {
114  GetSizer()->SetSizeHints(this);
115  }
116  Centre();
117 ////@end CPhyExportPage creation
118  return true;
119 }
120 
121 
122 /*!
123  * CPhyExportPage destructor
124  */
125 
127 {
128 ////@begin CPhyExportPage destruction
129 ////@end CPhyExportPage destruction
130 }
131 
132 
133 /*!
134  * Member initialisation
135  */
136 
138 {
139 ////@begin CPhyExportPage member initialisation
141 ////@end CPhyExportPage member initialisation
142 }
143 
144 
145 /*!
146  * Control creation for CAgpPExportPage
147  */
148 
150 {
151 
152 
153 ////@begin CPhyExportPage content construction
154  CPhyExportPage* itemPanel1 = this;
155 
156  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
157  itemPanel1->SetSizer(itemBoxSizer2);
158 
159  m_LocationSel = new CObjectListWidget( itemPanel1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL|wxLC_SINGLE_SEL );
160  itemBoxSizer2->Add(m_LocationSel, 1, wxGROW|wxALL, 0);
161 
162  wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(2, 2, 0, 0);
163  itemBoxSizer2->Add(itemFlexGridSizer4, 0, wxALIGN_LEFT|wxALL, 0);
164 
165  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("Export Tree Format"), wxDefaultPosition, wxDefaultSize, 0 );
166  itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
167 
168  wxArrayString itemChoice6Strings;
169  itemChoice6Strings.Add(_("Newick"));
170  itemChoice6Strings.Add(_("Nexus"));
171  wxChoice* itemChoice6 = new wxChoice( itemPanel1, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, itemChoice6Strings, 0 );
172  itemFlexGridSizer4->Add(itemChoice6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
173 
174  wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
175  itemBoxSizer2->Add(itemBoxSizer10, 0, wxGROW|wxALL, 0);
176 
177  wxStaticText* itemStaticText11 = new wxStaticText( itemPanel1, wxID_STATIC, _("File name"), wxDefaultPosition, wxDefaultSize, 0 );
178  itemBoxSizer10->Add(itemStaticText11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
179 
180  wxTextCtrl* itemTextCtrl12 = new wxTextCtrl( itemPanel1, ID_TEXTCTRL5, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
181  itemBoxSizer10->Add(itemTextCtrl12, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
182 
183  wxBitmapButton* itemBitmapButton13 = new wxBitmapButton(itemPanel1, ID_BITMAPBUTTON1, itemPanel1->GetBitmapResource(wxT("menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
184  itemBitmapButton13->SetHelpText(_("Select File"));
186  itemBitmapButton13->SetToolTip(_("Select File"));
187  itemBoxSizer10->Add(itemBitmapButton13, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
188 
189  // Set validators
190  itemTextCtrl12->SetValidator( wxTextValidator(wxFILTER_NONE, GetData().SetFileName()) );
191 ////@end CPhyExportPage content construction
192 
193 // m_LocationSel->SetTitle(wxT("Objects To Export"));
194  m_SaveFile.reset(new CSaveFileHelper(this, *itemTextCtrl12));
195 }
196 
198 {
200 }
201 
202 /*!
203  * Should we show tooltips?
204  */
205 
207 {
208  return true;
209 }
210 
211 /*!
212  * Get bitmap resources
213  */
214 
215 wxBitmap CPhyExportPage::GetBitmapResource( const wxString& name )
216 {
217  return wxArtProvider::GetBitmap(name);
218 }
219 
220 /*!
221  * Get icon resources
222  */
223 
224 wxIcon CPhyExportPage::GetIconResource( const wxString& name )
225 {
226  // Icon retrieval
227 ////@begin CPhyExportPage icon retrieval
228  wxUnusedVar(name);
229  return wxNullIcon;
230 ////@end CPhyExportPage icon retrieval
231 }
232 
233 /*!
234  * Transfer data to the window
235  */
236 
238 {
239  wxChoice* choice = (wxChoice*)FindWindow(ID_CHOICE2);
240  choice->SetStringSelection(GetData().GetFileFormat());
241 
242  return wxPanel::TransferDataToWindow();
243 }
244 
245 /*!
246  * Transfer data from the window
247  */
248 
250 {
251  if (!wxPanel::TransferDataFromWindow())
252  return false;
253 
254  wxChoice* choice = (wxChoice*)FindWindow(ID_CHOICE2);
255  GetData().SetFileFormat(choice->GetStringSelection());
256 
257  wxString path = GetData().GetFileName();
259  return m_SaveFile->Validate(path);
260 }
261 
262 //static const char* kLocationList = ".LocationList";
263 
264 void CPhyExportPage::SetRegistryPath(const string& path)
265 {
266  m_RegPath = path;
267 // m_LocationSel->SetRegistryPath(m_RegPath + kLocationList);
268 }
269 
271 {
272 // m_LocationSel->SaveSettings();
273 }
274 
276 {
277  // m_LocationSel->LoadSettings();
278 }
279 
280 void CPhyExportPage::OnButton2Click( wxCommandEvent& event )
281 {
282  // Update file-choice dialog to show the file type selected by the user:
283  wxChoice* choice = (wxChoice*)FindWindow(ID_CHOICE2);
285 
286  if (choice != NULL) {
287  wxString s = choice->GetStringSelection();
288  if (s == _("Newick")) {
290  }
291  else if (s == _("Nexus")) {
293  }
294  else {
295  // Unsupported tree type
296  _ASSERT(false);
297  }
298  }
299 
301  m_SaveFile->ShowSaveDialog(file_type);
302 }
303 
CObjectListWidget - mediator widget.
void SetObjects(TConstScopedObjects &objects)
CObjectListWidget * m_LocationSel
static bool ShowToolTips()
Should we show tooltips?
virtual void SaveSettings() const
virtual bool TransferDataFromWindow()
Transfer data from the window.
virtual bool TransferDataToWindow()
Transfer data to the window.
void CreateControls()
Creates the controls and sizers.
virtual void SetRegistryPath(const string &path)
IRegSettings.
virtual void LoadSettings()
void Init()
Initialises member variables.
void SetObjects(TConstScopedObjects *objects)
std::unique_ptr< CSaveFileHelper > m_SaveFile
CPhyExportPage()
Constructors.
~CPhyExportPage()
Destructor.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool Create(wxWindow *parent, wxWindowID id=ID_CAGPPEXPORTPAGE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CPhyExportParams & GetData()
Data access.
void OnButton2Click(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON2
const wxString & GetFileFormat() const
void SetFileFormat(const wxString &value)
const wxString & GetFileName() const
#define _(proto)
Definition: ct_nlmzip_i.h:78
static ush * file_type
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#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()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
#define _ASSERT
Modified on Fri Sep 20 14:58:02 2024 by modify_doxy.py rev. 669887