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

Go to the SVN repository for this file.

1 /* $Id: submitter_panel_depr.cpp 42777 2019-04-11 15:54:35Z asztalos $
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: Andrea Asztalos
27  */
28 
29 
30 #include <ncbi_pch.hpp>
35 
40 
41 #include <wx/sizer.h>
42 #include <wx/textctrl.h>
43 #include <wx/choice.h>
44 #include <wx/button.h>
45 
46 
49 
50 
51 /*
52  * CSubmitterPanel_Depr type definition
53  */
54 
55 IMPLEMENT_DYNAMIC_CLASS(CSubmitterPanel_Depr, wxPanel )
56 
57 
58 /*
59  * CSubmitterPanel_Depr event table definition
60  */
61 
62 BEGIN_EVENT_TABLE(CSubmitterPanel_Depr, wxPanel )
63 
65 
66 
67 /*
68  * CSubmitterPanel_Depr constructors
69  */
70 
72 {
73  Init();
74 }
75 
76 CSubmitterPanel_Depr::CSubmitterPanel_Depr( wxWindow* parent, CContact_info& object, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
77  : m_Contact(&object)
78 {
79  Init();
80  Create(parent, id, pos, size, style);
81 }
82 
83 
84 /*
85  * CSubmitterPanel_Depr creator
86  */
87 
88 bool CSubmitterPanel_Depr::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
89 {
90 ////@begin CSubmitterPanel_Depr creation
91  wxPanel::Create( parent, id, pos, size, style );
92 
94  if (GetSizer())
95  {
96  GetSizer()->SetSizeHints(this);
97  }
98  Centre();
99 ////@end CSubmitterPanel_Depr creation
100  return true;
101 }
102 
103 
104 /*
105  * CSubmitterPanel_Depr destructor
106  */
107 
109 {
110 ////@begin CSubmitterPanel_Depr destruction
111 ////@end CSubmitterPanel_Depr destruction
112 }
113 
114 
115 /*
116  * Member initialisation
117  */
118 
120 {
121 ////@begin CSubmitterPanel_Depr member initialisation
122  m_First = NULL;
123  m_MI = NULL;
124  m_Last = NULL;
125  m_Suffix = NULL;
128 ////@end CSubmitterPanel_Depr member initialisation
129 }
130 
131 
132 /*
133  * Control creation for CSubmitterPanel_Depr
134  */
135 
137 {
138 ////@begin CSubmitterPanel_Depr content construction
139  // Generated by DialogBlocks, 19/12/2018 11:00:35 (unregistered)
140 
141  CSubmitterPanel_Depr* itemPanel1 = this;
142 
143  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
144  itemPanel1->SetSizer(itemBoxSizer2);
145 
146  wxFlexGridSizer* itemFlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
147  itemBoxSizer2->Add(itemFlexGridSizer1, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
148 
149  itemFlexGridSizer1->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL, 5);
150 
151  wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(2, 4, 0, 0);
152  itemFlexGridSizer1->Add(itemFlexGridSizer2, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
153 
154  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("First Name"), wxDefaultPosition, wxDefaultSize, 0 );
155  itemFlexGridSizer2->Add(itemStaticText4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
156 
157  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("M.I."), wxDefaultPosition, wxDefaultSize, 0 );
158  itemFlexGridSizer2->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
159 
160  wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("Last Name"), wxDefaultPosition, wxDefaultSize, 0 );
161  itemFlexGridSizer2->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
162 
163  wxStaticText* itemStaticText7 = new wxStaticText( itemPanel1, wxID_STATIC, _("Suffix"), wxDefaultPosition, wxDefaultSize, 0 );
164  itemFlexGridSizer2->Add(itemStaticText7, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
165 
166  m_First = new wxTextCtrl( itemPanel1, ID_TXT_SUBMITTER1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
167  itemFlexGridSizer2->Add(m_First, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
168 
169  m_MI = new wxTextCtrl( itemPanel1, ID_TXT_SUBMITTER2, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
170  itemFlexGridSizer2->Add(m_MI, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
171 
172  m_Last = new wxTextCtrl( itemPanel1, ID_TXT_SUBMITTER3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
173  itemFlexGridSizer2->Add(m_Last, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
174 
175  wxArrayString m_SuffixStrings;
176  m_SuffixStrings.Add(wxEmptyString);
177  m_SuffixStrings.Add(_("Jr."));
178  m_SuffixStrings.Add(_("Sr."));
179  m_SuffixStrings.Add(_("II"));
180  m_SuffixStrings.Add(_("III"));
181  m_SuffixStrings.Add(_("IV"));
182  m_SuffixStrings.Add(_("V"));
183  m_SuffixStrings.Add(_("VI"));
184  m_Suffix = new wxChoice( itemPanel1, ID_SUBMITTER_CHOICE, wxDefaultPosition, wxDefaultSize, m_SuffixStrings, 0 );
185  itemFlexGridSizer2->Add(m_Suffix, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
186 
187  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("Email (primary)"), wxDefaultPosition, wxDefaultSize, 0 );
188  itemFlexGridSizer1->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
189 
190  m_EmailPrimary = new wxTextCtrl( itemPanel1, ID_TXT_SUBMITTER4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
191  itemFlexGridSizer1->Add(m_EmailPrimary, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
192 
193  wxStaticText* itemStaticText9 = new wxStaticText(itemPanel1, wxID_STATIC, _("Email (secondary)"), wxDefaultPosition, wxDefaultSize, 0);
194  itemFlexGridSizer1->Add(itemStaticText9, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL, 5);
195 
196  m_EmailSecondary = new wxTextCtrl(itemPanel1, ID_TXT_SUBMITTER5, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
197  itemFlexGridSizer1->Add(m_EmailSecondary, 0, wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
198 
199 ////@end CSubmitterPanel_Depr content construction
200 }
201 
202 
204 {
205  if (!wxPanel::TransferDataToWindow()) {
206  return false;
207  }
208 
209  if (m_Contact->IsSetContact()
210  && m_Contact->GetContact().IsSetName()
211  && m_Contact->GetContact().GetName().IsName()) {
212  const CName_std& person = m_Contact->GetContact().GetName().GetName();
213  if (person.IsSetFirst()) {
214  m_First->SetValue(person.GetFirst());
215  }
216  if (person.IsSetLast()) {
217  m_Last->SetValue(person.GetLast());
218  }
219  if (person.IsSetSuffix()) {
220  m_Suffix->SetStringSelection (person.GetSuffix());
221  }
222  if (person.IsSetInitials()) {
223  string middle_init = CSingleAuthorPanel::s_ParseInitialsFromName(person);
224  m_MI->SetValue(middle_init);
225  }
226  }
227 
228  if (m_Contact->IsSetEmail()) {
229  vector<string> emails;
230  NStr::Split(m_Contact->GetEmail(), ",;", emails);
231  if (!emails.empty()) {
232  m_EmailPrimary->SetValue(ToWxString(emails[0]));
233  }
234  if (emails.size() > 1) {
235  m_EmailSecondary->SetValue(ToWxString(emails[1]));
236  }
237  }
238 
239  return true;
240 }
241 
243 {
244  if (!wxPanel::TransferDataFromWindow()) {
245  return false;
246  }
247 
248  CName_std& person = m_Contact->SetContact().SetName().SetName();
249  macro::CMacroFunction_AuthorFix::s_BuildName(
250  ToAsciiStdString(m_First->GetValue()),
251  ToAsciiStdString(m_MI->GetValue()),
252  ToAsciiStdString(m_Last->GetValue()),
253  ToAsciiStdString(m_Suffix->GetStringSelection()),
254  person);
255 
256  string email;
257  if (!m_EmailPrimary->IsEmpty()) {
258  email += ToStdString(m_EmailPrimary->GetValue());
259  }
260  if (!m_EmailSecondary->IsEmpty()) {
261  if (!email.empty()) {
262  email += "; ";
263  }
264  email += ToStdString(m_EmailSecondary->GetValue());
265  }
266  if (!email.empty()) {
267  m_Contact->SetEmail(email);
268  }
269  return true;
270 }
271 
273 {
274  m_Contact->Assign(contact);
276 }
277 
278 /*
279 bool CSubmitterPanel_Depr::IsContactNameSet() const
280 {
281  return (!m_First->IsEmpty() && !m_Last->IsEmpty());
282 }
283 
284 bool CSubmitterPanel_Depr::IsOneEmailSet() const
285 {
286  return (!m_EmailPrimary->IsEmpty() || !m_EmailSecondary->IsEmpty());
287 }
288 */
289 
291 {
292  if (m_First)
293  m_First->SetFocus();
294 }
295 
297 {
298  if (m_Last)
299  m_Last->SetFocus();
300 }
301 
303 {
304  if (m_EmailPrimary)
305  m_EmailPrimary->SetFocus();
306 }
307 
308 /*
309  * Should we show tooltips?
310  */
311 
313 {
314  return true;
315 }
316 
317 /*
318  * Get bitmap resources
319  */
320 
321 wxBitmap CSubmitterPanel_Depr::GetBitmapResource( const wxString& name )
322 {
323  // Bitmap retrieval
324 ////@begin CSubmitterPanel_Depr bitmap retrieval
325  wxUnusedVar(name);
326  return wxNullBitmap;
327 ////@end CSubmitterPanel_Depr bitmap retrieval
328 }
329 
330 /*
331  * Get icon resources
332  */
333 
334 wxIcon CSubmitterPanel_Depr::GetIconResource( const wxString& name )
335 {
336  // Icon retrieval
337 ////@begin CSubmitterPanel_Depr icon retrieval
338  wxUnusedVar(name);
339  return wxNullIcon;
340 ////@end CSubmitterPanel_Depr icon retrieval
341 }
342 
User-defined methods of the data storage class.
CContact_info –.
@Name_std.hpp User-defined methods of the data storage class.
Definition: Name_std.hpp:56
static string s_ParseInitialsFromName(const objects::CName_std &name)
static bool ShowToolTips()
Should we show tooltips?
CRef< objects::CContact_info > m_Contact
void Init()
Initialises member variables.
CSubmitterPanel_Depr()
Constructors.
virtual bool TransferDataToWindow()
virtual bool TransferDataFromWindow()
void CreateControls()
Creates the controls and sizers.
void SetData(const objects::CContact_info &contact)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool Create(wxWindow *parent, wxWindowID id=ID_CSubmitterPanel_Depr, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
#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 list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3457
bool IsSetSuffix(void) const
Jr, Sr, III Check if a value has been assigned to Suffix data member.
Definition: Name_std_.hpp:645
bool IsSetInitials(void) const
first + middle initials Check if a value has been assigned to Initials data member.
Definition: Name_std_.hpp:598
bool IsSetLast(void) const
Check if a value has been assigned to Last data member.
Definition: Name_std_.hpp:410
const TSuffix & GetSuffix(void) const
Get the Suffix member data.
Definition: Name_std_.hpp:657
const TFirst & GetFirst(void) const
Get the First member data.
Definition: Name_std_.hpp:469
const TLast & GetLast(void) const
Get the Last member data.
Definition: Name_std_.hpp:422
bool IsSetFirst(void) const
Check if a value has been assigned to First data member.
Definition: Name_std_.hpp:457
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(objects)
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
string ToAsciiStdString(const wxString &input)
Definition: wx_utils.hpp:166
Modified on Sun Mar 03 03:09:32 2024 by modify_doxy.py rev. 669887