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

Go to the SVN repository for this file.

1 /* $Id: 5col_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 #include <ncbi_pch.hpp>
30 
31 #include <wx/sizer.h>
32 #include <wx/checkbox.h>
33 #include <wx/bmpbuttn.h>
34 #include <wx/textctrl.h>
35 #include <wx/stattext.h>
36 #include <wx/statbox.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 "5col_export_page.hpp"
51 
52 ////@begin XPM images
53 ////@end XPM images
54 
56 
57 /*!
58  * C5ColExportPage type definition
59  */
60 
61 IMPLEMENT_DYNAMIC_CLASS( C5ColExportPage, wxPanel )
62 
63 
64 /*!
65  * C5ColExportPage event table definition
66  */
67 
68 BEGIN_EVENT_TABLE( C5ColExportPage, wxPanel )
69 
70 ////@begin C5ColExportPage event table entries
71  EVT_BUTTON( ID_BITMAPBUTTON2, C5ColExportPage::OnSelectFileClcik )
72 
73 ////@end C5ColExportPage event table entries
74 
76 
77 
78 /*!
79  * C5ColExportPage constructors
80  */
81 
83 {
84  Init();
85 }
86 
87 C5ColExportPage::C5ColExportPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
88 {
89  Init();
90  Create(parent, id, pos, size, style);
91 }
92 
93 
94 /*!
95  * C5ColExportPage creator
96  */
97 
98 bool C5ColExportPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
99 {
100 ////@begin C5ColExportPage creation
101  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
102  wxPanel::Create( parent, id, pos, size, style );
103 
104  CreateControls();
105  if (GetSizer())
106  {
107  GetSizer()->SetSizeHints(this);
108  }
109  Centre();
110 ////@end C5ColExportPage creation
111  return true;
112 }
113 
114 
115 /*!
116  * C5ColExportPage destructor
117  */
118 
120 {
121 ////@begin C5ColExportPage destruction
122 ////@end C5ColExportPage destruction
123 }
124 
125 
126 /*!
127  * Member initialisation
128  */
129 
131 {
132 ////@begin C5ColExportPage member initialisation
135 ////@end C5ColExportPage member initialisation
136 }
137 
138 
139 /*!
140  * Control creation for C5ColExportPage
141  */
142 
144 {
145 ////@begin C5ColExportPage content construction
146  C5ColExportPage* itemPanel1 = this;
147 
148  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
149  itemPanel1->SetSizer(itemBoxSizer2);
150 
151  m_LocationSel = new CObjectListWidgetSel( itemPanel1, ID_OBJECT_LIST, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL|wxLC_SINGLE_SEL );
152  itemBoxSizer2->Add(m_LocationSel, 1, wxGROW|wxALL, 0);
153 
154  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
155  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_LEFT|wxALL, 0);
156 
157  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("Feature depth:"), wxDefaultPosition, wxDefaultSize, 0 );
158  itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
159 
160  wxTextCtrl* itemTextCtrl6 = new wxTextCtrl( itemPanel1, ID_TEXTCTRL10, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
161  itemBoxSizer4->Add(itemTextCtrl6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
162 
163  wxCheckBox* itemCheckBox7 = new wxCheckBox( itemPanel1, ID_CHECKBOX17, _("Set exact feature level"), wxDefaultPosition, wxDefaultSize, 0 );
164  itemCheckBox7->SetValue(false);
165  itemBoxSizer4->Add(itemCheckBox7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
166 
167  wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
168  itemBoxSizer2->Add(itemBoxSizer8, 0, wxGROW|wxALL, 0);
169 
170  wxStaticText* itemStaticText9 = new wxStaticText( itemPanel1, wxID_STATIC, _("File name"), wxDefaultPosition, wxDefaultSize, 0 );
171  itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
172 
173  m_FileNameCtrl = new wxTextCtrl( itemPanel1, ID_TEXTCTRL11, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
174  itemBoxSizer8->Add(m_FileNameCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
175 
176  wxBitmapButton* itemBitmapButton11 = new wxBitmapButton( itemPanel1, ID_BITMAPBUTTON2, itemPanel1->GetBitmapResource(wxT("menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
177  itemBitmapButton11->SetHelpText(_("Select File"));
179  itemBitmapButton11->SetToolTip(_("Select File"));
180  itemBoxSizer8->Add(itemBitmapButton11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
181 
182  // Set validators
183  itemTextCtrl6->SetValidator( wxTextValidator(wxFILTER_NUMERIC, & GetData().m_FeatureDepth) );
184  itemCheckBox7->SetValidator( wxGenericValidator(& GetData().m_ExactFlevel) );
185  m_FileNameCtrl->SetValidator( wxTextValidator(wxFILTER_NONE, & m_FileName) );
186 ////@end C5ColExportPage content construction
187 
188  m_LocationSel->SetTitle(wxT("Select Location"));
189  m_SaveFile.reset(new CSaveFileHelper(this, *m_FileNameCtrl));
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 C5ColExportPage::GetBitmapResource( const wxString& name )
211 {
212  return wxArtProvider::GetBitmap(name);
213 }
214 
215 /*!
216  * Get icon resources
217  */
218 
219 wxIcon C5ColExportPage::GetIconResource( const wxString& name )
220 {
221  // Icon retrieval
222 ////@begin C5ColExportPage icon retrieval
223  wxUnusedVar(name);
224  return wxNullIcon;
225 ////@end C5ColExportPage icon retrieval
226 }
227 
228 /*!
229  * Transfer data from the window
230  */
231 
233 {
234  if (!wxPanel::TransferDataFromWindow())
235  return false;
236 
238  if (selection.empty()) {
239  wxMessageBox(wxT("No objects were selected"), wxT("Error"),
240  wxOK | wxICON_ERROR, this);
241  m_LocationSel->SetFocus();
242  return false;
243  }
244 
245  m_SeqLoc = selection[0];
246 
247  m_FileName.Trim(false);
248  m_FileName.Trim(true);
249 
251  return m_SaveFile->Validate(m_FileName);
252 }
253 
254 
255 /*!
256  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON7
257  */
258 
259 void C5ColExportPage::OnSelectFileClcik( wxCommandEvent& event )
260 {
262  m_SaveFile->ShowSaveDialog(CFileExtensions::k5Column);
263 }
264 
265 static const char* kLocationList = ".LocationList";
266 
267 void C5ColExportPage::SetRegistryPath(const string& path)
268 {
269  m_RegPath = path;
271 }
272 
274 {
276 }
277 
279 {
281 }
282 
static const char * kLocationList
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
C5ColExportParams & GetData()
Data access.
void SetObjects(map< string, TConstScopedObjects > *objects)
wxTextCtrl * m_FileNameCtrl
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
SConstScopedObject m_SeqLoc
void CreateControls()
Creates the controls and sizers.
virtual bool TransferDataFromWindow()
Transfer data from the window.
void Init()
Initialises member variables.
~C5ColExportPage()
Destructor.
bool Create(wxWindow *parent, wxWindowID id=ID_C5COLEXPORTPAGE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void OnSelectFileClcik(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON2
CObjectListWidgetSel * m_LocationSel
virtual void LoadSettings()
virtual void SetRegistryPath(const string &path)
IRegSettings.
C5ColExportPage()
Constructors.
std::unique_ptr< CSaveFileHelper > m_SaveFile
virtual void SaveSettings() const
static bool ShowToolTips()
Should we show tooltips?
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
#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
#define _ASSERT
Modified on Wed Feb 28 07:13:45 2024 by modify_doxy.py rev. 669887