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

Go to the SVN repository for this file.

1 /* $Id: ref_gene_track_loc_list_panel.cpp 40132 2017-12-22 15:45:12Z bollin $
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: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
33 
34 ////@begin includes
35 ////@end includes
36 
39 
40 ////@begin XPM images
41 ////@end XPM images
42 
45 
46 /*!
47  * CRefGeneTrackLocListPanel type definition
48  */
49 
50 IMPLEMENT_DYNAMIC_CLASS( CRefGeneTrackLocListPanel, wxPanel )
51 
52 
53 /*!
54  * CRefGeneTrackLocListPanel event table definition
55  */
56 
57 BEGIN_EVENT_TABLE( CRefGeneTrackLocListPanel, wxPanel )
58 
59 ////@begin CRefGeneTrackLocListPanel event table entries
60  EVT_CHOICE( ID_TYPE_CHOICE, CRefGeneTrackLocListPanel::OnTypeChoiceSelected )
61 
62 ////@end CRefGeneTrackLocListPanel event table entries
63 
65 
66 
67 /*!
68  * CRefGeneTrackLocListPanel constructors
69  */
70 
72 {
73  Init();
74 }
75 
76 CRefGeneTrackLocListPanel::CRefGeneTrackLocListPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
77 {
78  Init();
79  m_UserObj = new CUser_object();
80  Create(parent, id, pos, size, style);
82  if (m_Fields.size() > 0 && m_Fields.front()->IsSetLabel() && m_Fields.front()->GetLabel().IsStr()) {
83  m_Type->SetStringSelection(m_Fields.front()->GetLabel().GetStr());
84  }
85 }
86 
87 
88 /*!
89  * CRefGeneTrackLocListPanel creator
90  */
91 
92 bool CRefGeneTrackLocListPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
93 {
94 ////@begin CRefGeneTrackLocListPanel creation
95  wxPanel::Create( parent, id, pos, size, style );
96 
98  if (GetSizer())
99  {
100  GetSizer()->SetSizeHints(this);
101  }
102  Centre();
103 ////@end CRefGeneTrackLocListPanel creation
104  return true;
105 }
106 
107 
108 /*!
109  * CRefGeneTrackLocListPanel destructor
110  */
111 
113 {
114 ////@begin CRefGeneTrackLocListPanel destruction
115 ////@end CRefGeneTrackLocListPanel destruction
116  delete m_FieldManager;
117 }
118 
119 
120 /*!
121  * Member initialisation
122  */
123 
125 {
126 ////@begin CRefGeneTrackLocListPanel member initialisation
127  m_Type = NULL;
128 ////@end CRefGeneTrackLocListPanel member initialisation
130  m_Sizer = NULL;
132  SetNeedsEmptyLastRow(false);
133 }
134 
135 
136 /*!
137  * Control creation for CRefGeneTrackLocListPanel
138  */
139 
141 {
142 ////@begin CRefGeneTrackLocListPanel content construction
143  CRefGeneTrackLocListPanel* itemPanel1 = this;
144 
145  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
146  itemPanel1->SetSizer(itemBoxSizer2);
147 
148  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
149  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_LEFT|wxALL, 5);
150 
151  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
152  itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
153 
154  wxArrayString m_TypeStrings;
155  m_TypeStrings.Add(_("Assembly"));
156  m_TypeStrings.Add(_("IdenticalTo"));
157  m_Type = new wxChoice( itemPanel1, ID_TYPE_CHOICE, wxDefaultPosition, wxSize(100, -1), m_TypeStrings, 0 );
158  m_Type->SetStringSelection(_("Assembly"));
159  m_Type->SetName(_T("Type"));
160  itemBoxSizer3->Add(m_Type, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
161 
162  wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
163  itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_LEFT|wxALL, 5);
164 
165  wxStaticText* itemStaticText7 = new wxStaticText( itemPanel1, wxID_STATIC, _("Accession"), wxDefaultPosition, wxSize(100, -1), 0 );
166  itemBoxSizer6->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
167 
168  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("GI"), wxDefaultPosition, wxSize(100, -1), 0 );
169  itemBoxSizer6->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
170 
171  wxStaticText* itemStaticText9 = new wxStaticText( itemPanel1, wxID_STATIC, _("Start"), wxDefaultPosition, wxSize(100, -1), 0 );
172  itemBoxSizer6->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
173 
174  wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("Stop"), wxDefaultPosition, wxSize(100, -1), 0 );
175  itemBoxSizer6->Add(itemStaticText10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
176 
177  wxStaticText* itemStaticText11 = new wxStaticText( itemPanel1, wxID_STATIC, _("Comment"), wxDefaultPosition, wxSize(100, -1), 0 );
178  itemBoxSizer6->Add(itemStaticText11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
179 
180 ////@end CRefGeneTrackLocListPanel content construction
181  m_ScrolledWindow = new wxScrolledWindow( itemPanel1, wxID_ANY, wxDefaultPosition, wxSize(610, 100), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL );
182  itemBoxSizer2->Add(m_ScrolledWindow, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
183  m_ScrolledWindow->SetScrollbars(1, 1, 0, 0);
184  m_Sizer = new wxBoxSizer(wxVERTICAL);
185  m_ScrolledWindow->SetSizer(m_Sizer);
186 
187  m_ScrolledWindow->FitInside();
188 
189 }
190 
191 
192 /*!
193  * Should we show tooltips?
194  */
195 
197 {
198  return true;
199 }
200 
201 /*!
202  * Get bitmap resources
203  */
204 
205 wxBitmap CRefGeneTrackLocListPanel::GetBitmapResource( const wxString& name )
206 {
207  // Bitmap retrieval
208 ////@begin CRefGeneTrackLocListPanel bitmap retrieval
209  wxUnusedVar(name);
210  return wxNullBitmap;
211 ////@end CRefGeneTrackLocListPanel bitmap retrieval
212 }
213 
214 /*!
215  * Get icon resources
216  */
217 
218 wxIcon CRefGeneTrackLocListPanel::GetIconResource( const wxString& name )
219 {
220  // Icon retrieval
221 ////@begin CRefGeneTrackLocListPanel icon retrieval
222  wxUnusedVar(name);
223  return wxNullIcon;
224 ////@end CRefGeneTrackLocListPanel icon retrieval
225 }
226 
227 
229 {
230  bool add_last_row = false;
231  if (m_Fields.size() > 0 && m_Fields.front()->IsSetLabel() && m_Fields.front()->GetLabel().IsStr()) {
232  const string& field_type = m_Fields.front()->GetLabel().GetStr();
233  m_Type->SetStringSelection(field_type);
234  if (NStr::Equal(field_type, "IdenticalTo")) {
235  add_last_row = false;
236  } else {
237  add_last_row = true;
238  }
239  }
240  SetNeedsEmptyLastRow(add_last_row);
242 }
243 
244 
246 {
247  if (!wxPanel::TransferDataFromWindow())
248  return false;
249 
250  m_Fields.clear();
251  CRef<CUser_field> new_field(new CUser_field());
252  new_field->SetLabel().SetStr(ToStdString(m_Type->GetStringSelection()));
253  new_field->ResetData();
254 
255  wxSizerItemList::iterator node = m_Sizer->GetChildren().begin();
256  for (; node != m_Sizer->GetChildren().end(); ++node) {
257  wxWindow *w = (*node)->GetWindow();
258  if (!w) {
259  continue;
260  }
261  w->TransferDataFromWindow();
262  CRef<CUser_field> edited_field = m_FieldManager->GetUserField(w);
263  if (edited_field && !m_FieldManager->IsEmpty(*edited_field)) {
264  new_field->SetData().SetFields().push_back(edited_field);
265  }
266  }
267  if (new_field->IsSetData() && new_field->GetData().IsFields()) {
268  m_Fields.push_back(new_field);
269  }
270  return true;
271 }
272 
273 
274 /*!
275  * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_TYPE_CHOICE
276  */
277 
279 {
281  const string field_type = ToStdString(m_Type->GetStringSelection());
282  if (NStr::Equal(field_type, "IdenticalTo")) {
283  SetNeedsEmptyLastRow(false);
284  } else {
285  SetNeedsEmptyLastRow(true);
286  }
288 }
289 
290 
292 {
294  return m_Fields.empty();
295 }
296 
298 
bool Create(wxWindow *parent, wxWindowID id=ID_CREFGENETRACKLOCLISTPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void OnTypeChoiceSelected(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_TYPE_CHOICE
void Init()
Initialises member variables.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CreateControls()
Creates the controls and sizers.
static bool ShowToolTips()
Should we show tooltips?
wxScrolledWindow * m_ScrolledWindow
void SetNeedsEmptyLastRow(bool val)
virtual bool TransferDataToWindow()
vector< CRef< objects::CUser_field > > m_Fields
CRef< objects::CUser_object > m_UserObj
CUserFieldManager * m_FieldManager
virtual CRef< objects::CUser_field > GetUserField(wxWindow *ctrl)=0
virtual bool IsEmpty(const objects::CUser_field &field)=0
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5384
const TData & GetData(void) const
Get the Data member data.
bool IsFields(void) const
Check if variant Fields is selected.
void SetLabel(TLabel &value)
Assign a value to Label data member.
void SetData(TData &value)
Assign a value to Data data member.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
void ResetData(void)
Reset Data data member.
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(objects)
static static static wxID_ANY
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Mon Feb 26 03:59:20 2024 by modify_doxy.py rev. 669887