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

Go to the SVN repository for this file.

1 /* $Id: single_experiment_panel.cpp 38073 2017-03-23 16:34:10Z filippov $
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 
38 
39 ////@begin XPM images
40 ////@end XPM images
41 
43 
44 /*!
45  * CSingleExperimentPanel type definition
46  */
47 
48 IMPLEMENT_DYNAMIC_CLASS( CSingleExperimentPanel, CFormattedQualPanel )
49 
50 
51 /*!
52  * CSingleExperimentPanel event table definition
53  */
54 
55 BEGIN_EVENT_TABLE( CSingleExperimentPanel, CFormattedQualPanel )
56 
57 ////@begin CSingleExperimentPanel event table entries
58  EVT_TEXT( ID_EXPERIMENT_TXT, CSingleExperimentPanel::OnExperimentTxtTextUpdated )
59 ////@end CSingleExperimentPanel event table entries
60 
62 
63 
64 /*!
65  * CSingleExperimentPanel constructors
66  */
67 
69 {
70  Init();
71 }
72 
73 CSingleExperimentPanel::CSingleExperimentPanel( 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 
80 /*!
81  * CSingleExperimentPanel creator
82  */
83 
84 bool CSingleExperimentPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
85 {
86 ////@begin CSingleExperimentPanel creation
87  CFormattedQualPanel::Create( parent, id, pos, size, style );
88 
90  if (GetSizer())
91  {
92  GetSizer()->SetSizeHints(this);
93  }
94  Centre();
95 ////@end CSingleExperimentPanel creation
96  return true;
97 }
98 
99 
100 /*!
101  * CSingleExperimentPanel destructor
102  */
103 
105 {
106 ////@begin CSingleExperimentPanel destruction
107 ////@end CSingleExperimentPanel destruction
108 }
109 
110 
111 /*!
112  * Member initialisation
113  */
114 
116 {
117 ////@begin CSingleExperimentPanel member initialisation
118  m_Category = NULL;
119  m_Experiment = NULL;
120  m_PMID = NULL;
121 ////@end CSingleExperimentPanel member initialisation
122 }
123 
124 
125 /*!
126  * Control creation for CSingleExperimentPanel
127  */
128 
130 {
131 ////@begin CSingleExperimentPanel content construction
132  CSingleExperimentPanel* itemCFormattedQualPanel1 = this;
133 
134  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
135  itemCFormattedQualPanel1->SetSizer(itemBoxSizer2);
136 
137  wxArrayString m_CategoryStrings;
138  m_CategoryStrings.Add(wxEmptyString);
139  m_CategoryStrings.Add(_("COORDINATES"));
140  m_CategoryStrings.Add(_("DESCRIPTION"));
141  m_CategoryStrings.Add(_("EXISTENCE"));
142  m_Category = new wxChoice( itemCFormattedQualPanel1, ID_CHOICE18, wxDefaultPosition, wxDefaultSize, m_CategoryStrings, 0 );
143  itemBoxSizer2->Add(m_Category, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
144 
145  m_Experiment = new wxTextCtrl( itemCFormattedQualPanel1, ID_EXPERIMENT_TXT, wxEmptyString, wxDefaultPosition, wxSize(250, -1), 0 );
146  itemBoxSizer2->Add(m_Experiment, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
147 
148  m_PMID = new wxTextCtrl( itemCFormattedQualPanel1, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(120, -1), 0 );
149  itemBoxSizer2->Add(m_PMID, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
150 
151 ////@end CSingleExperimentPanel content construction
152 }
153 
154 
155 /*!
156  * Should we show tooltips?
157  */
158 
160 {
161  return true;
162 }
163 
164 /*!
165  * Get bitmap resources
166  */
167 
168 wxBitmap CSingleExperimentPanel::GetBitmapResource( const wxString& name )
169 {
170  // Bitmap retrieval
171 ////@begin CSingleExperimentPanel bitmap retrieval
172  wxUnusedVar(name);
173  return wxNullBitmap;
174 ////@end CSingleExperimentPanel bitmap retrieval
175 }
176 
177 /*!
178  * Get icon resources
179  */
180 
181 wxIcon CSingleExperimentPanel::GetIconResource( const wxString& name )
182 {
183  // Icon retrieval
184 ////@begin CSingleExperimentPanel icon retrieval
185  wxUnusedVar(name);
186  return wxNullIcon;
187 ////@end CSingleExperimentPanel icon retrieval
188 }
189 
190 
192 {
193  string category;
194  string experiment;
195  string doi;
196  objects::CGb_qual::ParseExperiment(val, category, experiment, doi);
197  if (NStr::IsBlank(category)) {
198  m_Category->SetSelection(0);
199  } else if (NStr::EqualNocase(category, "COORDINATES")) {
200  m_Category->SetSelection(1);
201  } else if (NStr::EqualNocase(category, "DESCRIPTION")) {
202  m_Category->SetSelection(2);
203  } else if (NStr::EqualNocase(category, "EXISTENCE")) {
204  m_Category->SetSelection(3);
205  }
206  m_Experiment->SetValue(experiment);
207  m_PMID->SetValue(doi);
208 }
209 
210 
212 {
213  string category = ToStdString(m_Category->GetStringSelection());
214  string experiment = ToStdString(m_Experiment->GetValue());
215  string doi = ToStdString(m_PMID->GetValue());
216 
217  string rval = objects::CGb_qual::BuildExperiment(category, experiment, doi);
218  return rval;
219 }
220 
221 
222 void CSingleExperimentPanel::GetDimensions(int *width, int *height)
223 {
224  *width = 10;
225  *height = 10;
226  int w = 0, h = 0;
227  m_Category->GetSize(&w, &h);
228  *height += h;
229  *width += w + 5;
230 
231  m_Experiment->GetSize(&w, &h);
232  *width += w + 5;
233 
234  m_PMID->GetSize(&w, &h);
235  *width += w + 5;
236 }
237 
238 
239 /*!
240  * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_EXPERIMENT_TXT
241  */
242 
244 {
246 }
247 
248 
250 
virtual void NotifyParentOfChange()
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
virtual void GetDimensions(int *width, int *height)
static bool ShowToolTips()
Should we show tooltips?
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=ID_CSINGLEEXPERIMENTPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnExperimentTxtTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_EXPERIMENT_TXT
void Init()
Initialises member variables.
virtual void SetValue(string val)
#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 IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sat Dec 02 09:23:03 2023 by modify_doxy.py rev. 669887