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

Go to the SVN repository for this file.

1 /* $Id: voucher_panel.cpp 29060 2013-10-01 19:21:17Z 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 
31 #include <ncbi_pch.hpp>
32 
33 
34 
35 ////@begin includes
36 ////@end includes
37 
40 #include <wx/stattext.h>
41 #include <wx/sizer.h>
42 
43 ////@begin XPM images
44 ////@end XPM images
45 
47 
48 /*
49  * CVoucherPanel type definition
50  */
51 
52 IMPLEMENT_DYNAMIC_CLASS( CVoucherPanel, CSrcModEditPanel )
53 
54 
55 /*
56  * CVoucherPanel event table definition
57  */
58 
59 BEGIN_EVENT_TABLE( CVoucherPanel, CSrcModEditPanel )
60 
61 ////@begin CVoucherPanel event table entries
63 
65 
67 
68 ////@end CVoucherPanel event table entries
69 
71 
72 
73 /*
74  * CVoucherPanel constructors
75  */
76 
78 {
79  Init();
80 }
81 
82 CVoucherPanel::CVoucherPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
84 {
85  Init();
86  Create(parent, id, pos, size, style);
87 }
88 
89 
90 /*
91  * CVoucherPanel creator
92  */
93 
94 bool CVoucherPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
95 {
96 ////@begin CVoucherPanel creation
97  CSrcModEditPanel::Create( parent, id, pos, size, style );
98 
100  if (GetSizer())
101  {
102  GetSizer()->SetSizeHints(this);
103  }
104  Centre();
105 ////@end CVoucherPanel creation
106  return true;
107 }
108 
109 
110 /*
111  * CVoucherPanel destructor
112  */
113 
115 {
116 ////@begin CVoucherPanel destruction
117 ////@end CVoucherPanel destruction
118 }
119 
120 
121 /*
122  * Member initialisation
123  */
124 
126 {
127 ////@begin CVoucherPanel member initialisation
128  m_Inst = NULL;
129  m_Coll = NULL;
130  m_ID = NULL;
131 ////@end CVoucherPanel member initialisation
132 }
133 
134 
135 /*
136  * Control creation for CVoucherPanel
137  */
138 
140 {
141 ////@begin CVoucherPanel content construction
142  CVoucherPanel* itemCSrcModEditPanel1 = this;
143 
144  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
145  itemCSrcModEditPanel1->SetSizer(itemBoxSizer2);
146 
147  wxStaticText* itemStaticText3 = new wxStaticText( itemCSrcModEditPanel1, wxID_STATIC, _("Inst"), wxDefaultPosition, wxDefaultSize, 0 );
148  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
149 
150  m_Inst = new wxTextCtrl( itemCSrcModEditPanel1, ID_VOUCHER_INST, wxEmptyString, wxDefaultPosition, wxSize(60, -1), 0 );
151  itemBoxSizer2->Add(m_Inst, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
152 
153  wxStaticText* itemStaticText5 = new wxStaticText( itemCSrcModEditPanel1, wxID_STATIC, _("Coll"), wxDefaultPosition, wxDefaultSize, 0 );
154  itemBoxSizer2->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
155 
156  m_Coll = new wxTextCtrl( itemCSrcModEditPanel1, ID_VOUCHER_COLL, wxEmptyString, wxDefaultPosition, wxSize(60, -1), 0 );
157  itemBoxSizer2->Add(m_Coll, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
158 
159  wxStaticText* itemStaticText7 = new wxStaticText( itemCSrcModEditPanel1, wxID_STATIC, _("SpecID/Text"), wxDefaultPosition, wxDefaultSize, 0 );
160  itemBoxSizer2->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
161 
162  m_ID = new wxTextCtrl( itemCSrcModEditPanel1, ID_VOUCHER_TEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
163  itemBoxSizer2->Add(m_ID, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
164 
165 ////@end CVoucherPanel content construction
166 }
167 
168 
169 /*
170  * Should we show tooltips?
171  */
172 
174 {
175  return true;
176 }
177 
178 /*
179  * Get bitmap resources
180  */
181 
182 wxBitmap CVoucherPanel::GetBitmapResource( const wxString& name )
183 {
184  // Bitmap retrieval
185 ////@begin CVoucherPanel bitmap retrieval
186  wxUnusedVar(name);
187  return wxNullBitmap;
188 ////@end CVoucherPanel bitmap retrieval
189 }
190 
191 /*
192  * Get icon resources
193  */
194 
195 wxIcon CVoucherPanel::GetIconResource( const wxString& name )
196 {
197  // Icon retrieval
198 ////@begin CVoucherPanel icon retrieval
199  wxUnusedVar(name);
200  return wxNullIcon;
201 ////@end CVoucherPanel icon retrieval
202 }
203 
204 
206 {
207  string inst = ToStdString(m_Inst->GetValue());
208  string coll = ToStdString(m_Coll->GetValue());
209  string id = ToStdString(m_ID->GetValue());
210 
211  if (NStr::IsBlank (inst) && NStr::IsBlank (coll) && NStr::IsBlank(id)) {
212  return "";
213  } else if (NStr::IsBlank (inst) && NStr::IsBlank(coll)) {
214  return id;
215  } else if (NStr::IsBlank (coll)) {
216  return inst + ":" + id;
217  } else {
218  return inst + ":" + coll + ":" + id;
219  }
220 }
221 
222 
223 void CVoucherPanel::SetValue(const string& val)
224 {
225  string inst = "";
226  string coll = "";
227  string id = "";
228 
229  size_t pos = NStr::Find(val, ":");
230  if (pos == string::npos) {
231  id = val;
232  } else {
233  inst = val.substr(0, pos);
234  string remainder = val.substr(pos + 1);
235  size_t pos = NStr::Find (remainder, ":");
236  if (pos == string::npos) {
237  id = remainder;
238  } else {
239  coll = remainder.substr(0, pos);
240  id = remainder.substr(pos + 1);
241  }
242  }
243  m_Inst->SetValue(ToWxString(inst));
244  m_Coll->SetValue(ToWxString(coll));
245  m_ID->SetValue(ToWxString(id));
246 }
247 
248 
249 bool CVoucherPanel::IsWellFormatted(const string& val)
250 {
251  return true;
252 }
253 
254 
255 /*
256  * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_VOUCHER_INST
257  */
258 
259 void CVoucherPanel::OnVoucherInstTextUpdated( wxCommandEvent& event )
260 {
261  x_NotifyParent();
262 }
263 
264 
265 /*
266  * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_VOUCHER_COLL
267  */
268 
269 void CVoucherPanel::OnVoucherCollTextUpdated( wxCommandEvent& event )
270 {
271  x_NotifyParent();
272 }
273 
274 
275 /*
276  * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_VOUCHER_TEXT
277  */
278 
279 void CVoucherPanel::OnVoucherTextTextUpdated( wxCommandEvent& event )
280 {
281  x_NotifyParent();
282 }
283 
284 
286 
287 
void OnVoucherTextTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_VOUCHER_TEXT
void CreateControls()
Creates the controls and sizers.
virtual void SetValue(const string &val)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnVoucherCollTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_VOUCHER_COLL
~CVoucherPanel()
Destructor.
virtual string GetValue()
static bool ShowToolTips()
Should we show tooltips?
virtual bool IsWellFormatted(const string &val)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool Create(wxWindow *parent, wxWindowID id=10005, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Creation.
void OnVoucherInstTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_VOUCHER_INST
CVoucherPanel()
Constructors.
wxTextCtrl * m_ID
wxTextCtrl * m_Inst
wxTextCtrl * m_Coll
void Init()
Initialises member variables.
#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 SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2887
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
#define ID_VOUCHER_INST
#define ID_VOUCHER_TEXT
#define ID_VOUCHER_COLL
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sun Mar 03 03:11:29 2024 by modify_doxy.py rev. 669887