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

Go to the SVN repository for this file.

1 /* $Id: align_tab_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  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include <wx/sizer.h>
35 #include <wx/checkbox.h>
36 #include <wx/choice.h>
37 #include <wx/bmpbuttn.h>
38 #include <wx/textctrl.h>
39 #include <wx/stattext.h>
40 #include <wx/valgen.h>
41 #include <wx/valtext.h>
42 #include <wx/msgdlg.h>
43 #include <wx/filedlg.h>
44 #include <wx/bitmap.h>
45 #include <wx/icon.h>
46 #include <wx/artprov.h>
47 
49 
51 
54 
56 
57 IMPLEMENT_DYNAMIC_CLASS( CAlignTabExportPage, wxPanel )
58 
59 BEGIN_EVENT_TABLE( CAlignTabExportPage, wxPanel )
60 
61 ////@begin CAlignTabExportPage event table entries
63 
64 ////@end CAlignTabExportPage event table entries
65 
67 
69 {
70  Init();
71 }
72 
73 CAlignTabExportPage::CAlignTabExportPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
74 {
75  Init();
76  Create(parent, id, pos, size, style);
77 }
78 
79 bool CAlignTabExportPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
80 {
81 ////@begin CAlignTabExportPage creation
82  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
83  wxPanel::Create( parent, id, pos, size, style );
84 
86  if (GetSizer())
87  {
88  GetSizer()->SetSizeHints(this);
89  }
90  Centre();
91 ////@end CAlignTabExportPage creation
92  return true;
93 }
94 
96 {
97 ////@begin CAlignTabExportPage destruction
98 ////@end CAlignTabExportPage destruction
99 }
100 
102 {
103 ////@begin CAlignTabExportPage member initialisation
105 ////@end CAlignTabExportPage member initialisation
106 }
107 
109 {
110 ////@begin CAlignTabExportPage content construction
111  CAlignTabExportPage* itemPanel1 = this;
112 
113  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
114  itemPanel1->SetSizer(itemBoxSizer2);
115 
116  m_LocationSel = new CObjectListWidgetSel( itemPanel1, ID_PANEL4, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL|wxLC_SINGLE_SEL );
117  itemBoxSizer2->Add(m_LocationSel, 1, wxGROW|wxALL, 0);
118 
119  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
120  itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxALL, 0);
121 
122  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("File name"), wxDefaultPosition, wxDefaultSize, 0 );
123  itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
124 
125  wxTextCtrl* itemTextCtrl6 = new wxTextCtrl( itemPanel1, ID_TEXTCTRL14, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
126  itemBoxSizer4->Add(itemTextCtrl6, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
127 
128  wxBitmapButton* itemBitmapButton7 = new wxBitmapButton( itemPanel1, ID_BITMAPBUTTON, itemPanel1->GetBitmapResource(wxT("menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
129  itemBitmapButton7->SetHelpText(_("Select File"));
131  itemBitmapButton7->SetToolTip(_("Select File"));
132  itemBoxSizer4->Add(itemBitmapButton7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
133 
134  // Set validators
135  itemTextCtrl6->SetValidator( wxTextValidator(wxFILTER_NONE, & GetData().m_FileName) );
136 ////@end CAlignTabExportPage content construction
137 
138  m_LocationSel->SetTitle(wxT("Select Location"));
139 
140  m_SaveFile.reset(new CSaveFileHelper(this, *itemTextCtrl6));
141 }
142 
144 {
146 }
147 
148 
150 {
151  return true;
152 }
153 wxBitmap CAlignTabExportPage::GetBitmapResource( const wxString& name )
154 {
155  return wxArtProvider::GetBitmap(name);
156 }
157 wxIcon CAlignTabExportPage::GetIconResource( const wxString& name )
158 {
159  // Icon retrieval
160 ////@begin CAlignTabExportPage icon retrieval
161  wxUnusedVar(name);
162  return wxNullIcon;
163 ////@end CAlignTabExportPage icon retrieval
164 }
166 {
167  return wxPanel::TransferDataToWindow();
168 }
170 {
171  if (!wxPanel::TransferDataFromWindow())
172  return false;
173 
175  if (selection.size() != 1) {
176  wxMessageBox(wxT("Please select a single location"), wxT("Error"),
177  wxOK | wxICON_ERROR, this);
178  m_LocationSel->SetFocus();
179  return false;
180  }
181 
182  const objects::CSeq_loc* seq_loc = dynamic_cast<const objects::CSeq_loc*>(selection[0].object.GetPointerOrNull());
183  if (!seq_loc) {
184  wxMessageBox(wxT("Internal error. The selections is not a location,\n")
185  wxT("please, try to select another location"), wxT("Internal Error"),
186  wxOK | wxICON_ERROR, this);
187  m_LocationSel->SetFocus();
188  return false;
189  }
190 
191  GetData().SetObject() = selection[0];
192 
193  wxString path = GetData().GetFileName();
195  return m_SaveFile->Validate(path);
196 }
197 
198 static const char* kLocationList = ".LocationList";
199 
200 void CAlignTabExportPage::SetRegistryPath(const string& path)
201 {
202  m_RegPath = path;
204 }
205 
207 {
209 }
210 
212 {
214 }
215 
216 void CAlignTabExportPage::OnSelectFileClick( wxCommandEvent& event )
217 {
219  m_SaveFile->ShowSaveDialog(CFileExtensions::kTxt);
220 }
221 
static const char * kLocationList
CAlignTabExportParams & GetData()
virtual bool TransferDataToWindow()
void SetObjects(map< string, TConstScopedObjects > *objects)
void OnSelectFileClick(wxCommandEvent &event)
virtual void SaveSettings() const
std::unique_ptr< CSaveFileHelper > m_SaveFile
virtual void SetRegistryPath(const string &path)
IRegSettings.
wxIcon GetIconResource(const wxString &name)
CObjectListWidgetSel * m_LocationSel
virtual bool TransferDataFromWindow()
wxBitmap GetBitmapResource(const wxString &name)
bool Create(wxWindow *parent, wxWindowID id=ID_CALIGNTABEXPORTPAGE, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
SConstScopedObject & SetObject()
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 ID_BITMAPBUTTON
#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 Fri Sep 20 14:57:07 2024 by modify_doxy.py rev. 669887