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

Go to the SVN repository for this file.

1 /* $Id: flatfile_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/choice.h>
34 #include <wx/bmpbuttn.h>
35 #include <wx/textctrl.h>
36 #include <wx/stattext.h>
37 #include <wx/valgen.h>
38 #include <wx/valtext.h>
39 #include <wx/msgdlg.h>
40 #include <wx/filedlg.h>
41 #include <wx/bitmap.h>
42 #include <wx/icon.h>
43 #include <wx/artprov.h>
44 
46 
47 ////@begin includes
48 ////@end includes
49 
50 #include "flatfile_export_page.hpp"
51 
52 ////@begin XPM images
53 ////@end XPM images
54 
56 
57 /*!
58  * CFlatFileExportPage type definition
59  */
60 
61 IMPLEMENT_DYNAMIC_CLASS( CFlatFileExportPage, wxPanel )
62 
63 
64 /*!
65  * CFlatFileExportPage event table definition
66  */
67 
68 BEGIN_EVENT_TABLE( CFlatFileExportPage, wxPanel )
69 
70 ////@begin CFlatFileExportPage event table entries
71  EVT_BUTTON( ID_BITMAPBUTTON4, CFlatFileExportPage::OnSelectFileClick )
72 
73 ////@end CFlatFileExportPage event table entries
74 
76 
77 
78 /*!
79  * CFlatFileExportPage constructors
80  */
81 
83 {
84  Init();
85 }
86 
87 CFlatFileExportPage::CFlatFileExportPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, long style )
88 {
89  Init();
90  Create(parent, id, pos, style);
91 }
92 
93 
94 /*!
95  * CFlatFileExportPage creator
96  */
97 
98 bool CFlatFileExportPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, long style )
99 {
100  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
101  wxPanel::Create( parent, id, pos, wxSize(0,0), style );
102  Hide();
103 
104  CreateControls();
105  if (GetSizer())
106  {
107  GetSizer()->SetSizeHints(this);
108  }
109  Centre();
110 
111  return true;
112 }
113 
114 
115 /*!
116  * CFlatFileExportPage destructor
117  */
118 
120 {
121 ////@begin CFlatFileExportPage destruction
122 ////@end CFlatFileExportPage destruction
123 }
124 
125 
126 /*!
127  * Member initialisation
128  */
129 
131 {
132 ////@begin CFlatFileExportPage member initialisation
134 ////@end CFlatFileExportPage member initialisation
135 }
136 
137 
138 /*!
139  * Control creation for CFlatFileExportPage
140  */
141 
143 {
144 ////@begin CFlatFileExportPage content construction
145  CFlatFileExportPage* itemPanel1 = this;
146 
147  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
148  itemPanel1->SetSizer(itemBoxSizer2);
149 
150  m_LocationSel = new CObjectListWidgetSel( itemPanel1, ID_PANEL3, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL|wxLC_SINGLE_SEL );
151  itemBoxSizer2->Add(m_LocationSel, 1, wxGROW|wxALL, 0);
152 
153  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
154  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_LEFT|wxALL, 0);
155 
156  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("Flat File Mode"), wxDefaultPosition, wxDefaultSize, 0 );
157  itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
158 
159  wxArrayString itemChoice6Strings;
160  itemChoice6Strings.Add(_("Genome Workbench"));
161  itemChoice6Strings.Add(_("Entrez"));
162  itemChoice6Strings.Add(_("Release"));
163  itemChoice6Strings.Add(_("Dump"));
164  wxChoice* itemChoice6 = new wxChoice( itemPanel1, ID_CHOICE3, wxDefaultPosition, wxDefaultSize, itemChoice6Strings, 0 );
165  itemChoice6->SetStringSelection(_("Genome Workbench"));
166  itemBoxSizer4->Add(itemChoice6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
167 
168  wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
169  itemBoxSizer2->Add(itemBoxSizer7, 0, wxGROW|wxALL, 0);
170 
171  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("File name"), wxDefaultPosition, wxDefaultSize, 0 );
172  itemBoxSizer7->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
173 
174  wxTextCtrl* itemTextCtrl9 = new wxTextCtrl( itemPanel1, ID_TEXTCTRL7, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
175  itemBoxSizer7->Add(itemTextCtrl9, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
176 
177  wxBitmapButton* itemBitmapButton10 = new wxBitmapButton( itemPanel1, ID_BITMAPBUTTON4, itemPanel1->GetBitmapResource(wxT("menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
178  itemBitmapButton10->SetHelpText(_("Select File"));
180  itemBitmapButton10->SetToolTip(_("Select File"));
181  itemBoxSizer7->Add(itemBitmapButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
182 
183  // Set validators
184  itemChoice6->SetValidator( wxGenericValidator(& GetData().m_Mode) );
185  itemTextCtrl9->SetValidator( wxTextValidator(wxFILTER_NONE, & GetData().m_FileName) );
186 ////@end CFlatFileExportPage content construction
187 
188  m_LocationSel->SetTitle(wxT("Select Location"));
189  m_SaveFile.reset(new CSaveFileHelper(this, *itemTextCtrl9));
190 }
191 
193 {
195 }
196 
197 /*!
198  * Should we show tooltips?
199  */
200 
202 {
203  return true;
204 }
205 
206 /*!
207  * Get bitmap resources
208  */
209 
210 wxBitmap CFlatFileExportPage::GetBitmapResource( const wxString& name )
211 {
212  return wxArtProvider::GetBitmap(name);
213 }
214 
215 /*!
216  * Get icon resources
217  */
218 
219 wxIcon CFlatFileExportPage::GetIconResource( const wxString& name )
220 {
221  // Icon retrieval
222 ////@begin CFlatFileExportPage icon retrieval
223  wxUnusedVar(name);
224  return wxNullIcon;
225 ////@end CFlatFileExportPage icon retrieval
226 }
227 
228 /*!
229  * Transfer data from the window
230  */
231 
233 {
234  if (!wxPanel::TransferDataFromWindow())
235  return false;
236 
238  m_data.m_SeqLoc = selection[0];
239 
240  wxString path = GetData().GetFileName();
242  return m_SaveFile->Validate(path);
243 }
244 
245 /*!
246  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON4
247  */
248 
249 void CFlatFileExportPage::OnSelectFileClick( wxCommandEvent& WXUNUSED(event) )
250 {
252  m_SaveFile->ShowSaveDialog(CFileExtensions::kGenBank);
253 }
254 
255 static const char* kLocationList = ".LocationList";
256 
257 void CFlatFileExportPage::SetRegistryPath(const string& path)
258 {
259  m_RegPath = path;
261 }
262 
264 {
266 }
267 
269 {
271 }
272 
virtual bool TransferDataFromWindow()
Transfer data from the window.
void CreateControls()
Creates the controls and sizers.
void SetObjects(map< string, TConstScopedObjects > *objects)
virtual void SaveSettings() const
static bool ShowToolTips()
Should we show tooltips?
CFlatFileExportParams & GetData()
Data access.
CObjectListWidgetSel * m_LocationSel
void Init()
Initialises member variables.
CFlatFileExportPage()
Constructors.
CFlatFileExportParams m_data
The data edited by this window.
std::unique_ptr< CSaveFileHelper > m_SaveFile
virtual void SetRegistryPath(const string &path)
IRegSettings.
bool Create(wxWindow *parent, wxWindowID id=ID_CFLATFILEEXPORTPAGE, const wxPoint &pos=wxDefaultPosition, long style=wxTAB_TRAVERSAL)
Creation.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnSelectFileClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON4
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
virtual void SetRegistryPath(const string &path)
IRegSettings.
TConstScopedObjects GetSelection() const
void SetObjects(const TObjectListMap &value)
void SetTitle(const wxString &value)
virtual void SaveSettings() const
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
static const char * kLocationList
#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
#define _ASSERT
Modified on Sun Mar 03 03:16:14 2024 by modify_doxy.py rev. 669887