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

Go to the SVN repository for this file.

1 /* $Id: contactpanel.cpp 42280 2019-01-24 20:12:34Z 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: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
35 
42 
43 #include <wx/sizer.h>
44 #include <wx/textctrl.h>
45 #include <wx/choice.h>
46 #include <wx/button.h>
47 
48 
51 
52 
53 /*
54  * CContactPanel type definition
55  */
56 
57 IMPLEMENT_DYNAMIC_CLASS( CContactPanel, wxPanel )
58 
59 
60 /*
61  * CContactPanel event table definition
62  */
63 
64 BEGIN_EVENT_TABLE( CContactPanel, wxPanel )
65 
67 
68 
69 /*
70  * CContactPanel constructors
71  */
72 
74 {
75  Init();
76 }
77 
78 CContactPanel::CContactPanel( wxWindow* parent, CContact_info& object, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
79  : m_Contact(&object)
80 {
81  Init();
82  Create(parent, id, pos, size, style);
83 }
84 
85 
86 /*
87  * CContactPanel creator
88  */
89 
90 bool CContactPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
91 {
92 ////@begin CContactPanel creation
93  wxPanel::Create( parent, id, pos, size, style );
94 
96  if (GetSizer())
97  {
98  GetSizer()->SetSizeHints(this);
99  }
100  Centre();
101 ////@end CContactPanel creation
102  return true;
103 }
104 
105 
106 /*
107  * CContactPanel destructor
108  */
109 
111 {
112 ////@begin CContactPanel destruction
113 ////@end CContactPanel destruction
114 }
115 
116 
117 /*
118  * Member initialisation
119  */
120 
122 {
123 ////@begin CContactPanel member initialisation
124  m_First = NULL;
125  m_MI = NULL;
126  m_Last = NULL;
127  m_Suffix = NULL;
128  m_Phone = NULL;
129  m_Fax = NULL;
130 ////@end CContactPanel member initialisation
131 }
132 
133 
134 /*
135  * Control creation for CContactPanel
136  */
137 
139 {
140 ////@begin CContactPanel content construction
141  // Generated by DialogBlocks, 23/01/2019 16:44:14 (unregistered)
142 
143  CContactPanel* itemPanel1 = this;
144 
145  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
146  itemPanel1->SetSizer(itemBoxSizer2);
147 
148  wxFlexGridSizer* itemFlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
149  itemBoxSizer2->Add(itemFlexGridSizer1, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
150 
151  itemFlexGridSizer1->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
152 
153  wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(2, 4, 0, 0);
154  itemFlexGridSizer1->Add(itemFlexGridSizer2, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
155 
156  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("First Name"), wxDefaultPosition, wxDefaultSize, 0 );
157  itemFlexGridSizer2->Add(itemStaticText4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
158 
159  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("M.I."), wxDefaultPosition, wxDefaultSize, 0 );
160  itemFlexGridSizer2->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
161 
162  wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("Last Name"), wxDefaultPosition, wxDefaultSize, 0 );
163  itemFlexGridSizer2->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
164 
165  wxStaticText* itemStaticText7 = new wxStaticText( itemPanel1, wxID_STATIC, _("Suffix"), wxDefaultPosition, wxDefaultSize, 0 );
166  itemFlexGridSizer2->Add(itemStaticText7, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
167 
168  m_First = new wxTextCtrl( itemPanel1, ID_TXT_CONTACT1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
169  itemFlexGridSizer2->Add(m_First, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
170 
171  m_MI = new wxTextCtrl( itemPanel1, ID_TXT_CONTACT2, wxEmptyString, wxDefaultPosition, wxSize(50, -1), 0 );
172  itemFlexGridSizer2->Add(m_MI, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
173 
174  m_Last = new wxTextCtrl( itemPanel1, ID_TXT_CONTACT3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
175  itemFlexGridSizer2->Add(m_Last, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
176 
177  wxArrayString m_SuffixStrings;
178  m_SuffixStrings.Add(wxEmptyString);
179  m_SuffixStrings.Add(_("Jr."));
180  m_SuffixStrings.Add(_("Sr."));
181  m_SuffixStrings.Add(_("II"));
182  m_SuffixStrings.Add(_("III"));
183  m_SuffixStrings.Add(_("IV"));
184  m_SuffixStrings.Add(_("V"));
185  m_SuffixStrings.Add(_("VI"));
186  m_Suffix = new wxChoice( itemPanel1, ID_CHOICE, wxDefaultPosition, wxDefaultSize, m_SuffixStrings, 0 );
187  itemFlexGridSizer2->Add(m_Suffix, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
188 
189  wxStaticText* itemStaticText2 = new wxStaticText( itemPanel1, wxID_STATIC, _("Phone"), wxDefaultPosition, wxDefaultSize, 0 );
190  itemFlexGridSizer1->Add(itemStaticText2, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
191 
192  m_Phone = new wxTextCtrl( itemPanel1, ID_TXT_CONTACT4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
193  itemFlexGridSizer1->Add(m_Phone, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
194 
195  itemFlexGridSizer1->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
196 
197  wxStaticText* itemStaticText3 = new wxStaticText( itemPanel1, wxID_STATIC, _("Please include country code for non-U.S. phone numbers"), wxDefaultPosition, wxDefaultSize, 0 );
198  itemFlexGridSizer1->Add(itemStaticText3, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
199 
200  wxStaticText* itemStaticText1 = new wxStaticText( itemPanel1, wxID_STATIC, _("Fax"), wxDefaultPosition, wxDefaultSize, 0 );
201  itemFlexGridSizer1->Add(itemStaticText1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
202 
203  m_Fax = new wxTextCtrl( itemPanel1, ID_TXT_CONTACT5, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
204  itemFlexGridSizer1->Add(m_Fax, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
205 
206  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("Email"), wxDefaultPosition, wxDefaultSize, 0 );
207  itemFlexGridSizer1->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  wxTextCtrl* itemTextCtrl11 = new wxTextCtrl( itemPanel1, ID_TXT_CONTACT6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
210  itemFlexGridSizer1->Add(itemTextCtrl11, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
211 
212  // Set validators
213  m_Phone->SetValidator( CSerialTextValidator(*m_Contact, "phone") );
214  m_Fax->SetValidator( CSerialTextValidator(*m_Contact, "fax") );
215  itemTextCtrl11->SetValidator( CSerialTextValidator(*m_Contact, "email") );
216 ////@end CContactPanel content construction
217 }
218 
219 
221 {
222  if (!wxPanel::TransferDataToWindow()) {
223  return false;
224  }
225 
226  if (m_Contact->IsSetContact()
227  && m_Contact->GetContact().IsSetName()
228  && m_Contact->GetContact().GetName().IsName()) {
229  const CName_std& person = m_Contact->GetContact().GetName().GetName();
230  if (person.IsSetFirst()) {
231  m_First->SetValue(person.GetFirst());
232  }
233  if (person.IsSetLast()) {
234  m_Last->SetValue(person.GetLast());
235  }
236  if (person.IsSetSuffix()) {
237  m_Suffix->SetStringSelection (person.GetSuffix());
238  }
239  if (person.IsSetInitials()) {
240  string middle_init = CSingleAuthorPanel::s_ParseInitialsFromName(person);
241  m_MI->SetValue(middle_init);
242  }
243  }
244  return true;
245 }
246 
248 {
249  if (!wxPanel::TransferDataFromWindow()) {
250  return false;
251  }
252 
253  CName_std& person = m_Contact->SetContact().SetName().SetName();
254  macro::CMacroFunction_AuthorFix::s_BuildName(
255  ToAsciiStdString(m_First->GetValue()),
256  ToAsciiStdString(m_MI->GetValue()),
257  ToAsciiStdString(m_Last->GetValue()),
258  ToAsciiStdString(m_Suffix->GetStringSelection()),
259  person);
260 
261  return true;
262 }
263 
265 {
266  m_Contact->Assign(contact);
268 }
269 
270 /*
271  * Should we show tooltips?
272  */
273 
275 {
276  return true;
277 }
278 
279 /*
280  * Get bitmap resources
281  */
282 
283 wxBitmap CContactPanel::GetBitmapResource( const wxString& name )
284 {
285  // Bitmap retrieval
286 ////@begin CContactPanel bitmap retrieval
287  wxUnusedVar(name);
288  return wxNullBitmap;
289 ////@end CContactPanel bitmap retrieval
290 }
291 
292 /*
293  * Get icon resources
294  */
295 
296 wxIcon CContactPanel::GetIconResource( const wxString& name )
297 {
298  // Icon retrieval
299 ////@begin CContactPanel icon retrieval
300  wxUnusedVar(name);
301  return wxNullIcon;
302 ////@end CContactPanel icon retrieval
303 }
User-defined methods of the data storage class.
virtual bool TransferDataFromWindow()
void CreateControls()
Creates the controls and sizers.
~CContactPanel()
Destructor.
wxTextCtrl * m_Phone
void SetData(const objects::CContact_info &contact)
void Init()
Initialises member variables.
wxTextCtrl * m_Last
wxTextCtrl * m_MI
CContactPanel()
Constructors.
wxChoice * m_Suffix
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
static bool ShowToolTips()
Should we show tooltips?
CRef< objects::CContact_info > m_Contact
wxTextCtrl * m_First
virtual bool TransferDataToWindow()
wxTextCtrl * m_Fax
bool Create(wxWindow *parent, wxWindowID id=10053, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
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)
USING_SCOPE(objects)
#define ID_TXT_CONTACT1
#define ID_TXT_CONTACT2
#define ID_TXT_CONTACT4
#define ID_TXT_CONTACT3
#define ID_TXT_CONTACT5
#define ID_TXT_CONTACT6
#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
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
#define ID_CHOICE
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
string ToAsciiStdString(const wxString &input)
Definition: wx_utils.hpp:166
Modified on Wed May 01 14:22:42 2024 by modify_doxy.py rev. 669887