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

Go to the SVN repository for this file.

1 /* $Id: citsub_panel.cpp 36886 2016-11-09 18:08:53Z 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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
33 
35 #include <objects/general/Date.hpp>
36 
38 
39 ////@begin includes
40 ////@end includes
41 
42 #include <wx/sizer.h>
43 #include <wx/bitmap.h>
44 #include <wx/icon.h>
45 #include <wx/stattext.h>
46 #include <wx/textctrl.h>
47 #include <wx/radiobox.h>
48 #include <wx/choice.h>
49 #include <wx/textctrl.h>
50 #include <wx/datectrl.h>
51 
52 #include "citsub_panel.hpp"
54 
57 
58 ////@begin XPM images
59 ////@end XPM images
60 
61 
62 /*
63  * CCitSubPanel type definition
64  */
65 
66 IMPLEMENT_DYNAMIC_CLASS( CCitSubPanel, wxPanel )
67 
68 
69 /*
70  * CCitSubPanel event table definition
71  */
72 
73 BEGIN_EVENT_TABLE( CCitSubPanel, wxPanel )
74 
75 ////@begin CCitSubPanel event table entries
77 
78 ////@end CCitSubPanel event table entries
79 
81 
82 
83 /*
84  * CCitSubPanel constructors
85  */
86 
88 {
89  Init();
90 }
91 
92 CCitSubPanel::CCitSubPanel( wxWindow* parent, CSerialObject& object,
93  wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) :
94  m_Object(0)
95 {
96  Init();
97  m_Object = dynamic_cast<CCit_sub*>(&object);
98  const CCit_sub& citsub = dynamic_cast<const CCit_sub&>(*m_Object);
99  m_EditedCitSub.Reset((CSerialObject*)CCit_sub::GetTypeInfo()->Create());
100  m_EditedCitSub->Assign(citsub);
101  Create(parent, id, pos, size, style);
102 }
103 
104 
105 /*
106  * CCitSubPanel creator
107  */
108 
109 bool CCitSubPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
110 {
111 ////@begin CCitSubPanel creation
112  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
113  wxPanel::Create( parent, id, pos, size, style );
114 
115  CreateControls();
116  if (GetSizer())
117  {
118  GetSizer()->SetSizeHints(this);
119  }
120  Centre();
121 ////@end CCitSubPanel creation
122  return true;
123 }
124 
125 
126 /*
127  * CCitSubPanel destructor
128  */
129 
131 {
132 ////@begin CCitSubPanel destruction
133 ////@end CCitSubPanel destruction
134 }
135 
136 
137 /*
138  * Member initialisation
139  */
140 
142 {
143 ////@begin CCitSubPanel member initialisation
144  m_Remark = NULL;
146 ////@end CCitSubPanel member initialisation
147 }
148 
149 
150 /*
151  * Control creation for CCitSubPanel
152  */
153 
155 {
156 ////@begin CCitSubPanel content construction
157  CCitSubPanel* itemPanel1 = this;
158 
159  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
160  itemPanel1->SetSizer(itemBoxSizer2);
161 
162  wxStaticText* itemStaticText3 = new wxStaticText( itemPanel1, wxID_STATIC, _("Description"), wxDefaultPosition, wxDefaultSize, 0 );
163  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
164 
165  m_Remark = new wxTextCtrl( itemPanel1, ID_CITSUB_DESC, wxEmptyString, wxDefaultPosition, wxSize(400, 85), wxTE_MULTILINE );
166  itemBoxSizer2->Add(m_Remark, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
167 
168  wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(0, 2, 0, 0);
169  itemBoxSizer2->Add(itemFlexGridSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
170 
171  wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("Add standard remark text"), wxDefaultPosition, wxDefaultSize, 0 );
172  itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
173 
174  wxArrayString m_StandardRemarkStrings;
175  m_StandardRemarkStrings.Add(wxEmptyString);
176  m_StandardRemarkStrings.Add(_("AA by submitter"));
177  m_StandardRemarkStrings.Add(_("NT by submitter"));
178  m_StandardRemarkStrings.Add(_("NT and AA by submitter"));
179  m_StandardRemarkStrings.Add(_("AA by database"));
180  m_StandardRemarkStrings.Add(_("NT by database"));
181  m_StandardRemarkStrings.Add(_("NT and AA by database"));
182  m_StandardRemark = new wxChoice( itemPanel1, ID_CITSUB_ADD_STANDARD_REMARK, wxDefaultPosition, wxDefaultSize, m_StandardRemarkStrings, 0 );
183  itemFlexGridSizer5->Add(m_StandardRemark, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
184 
185  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("Submission Date"), wxDefaultPosition, wxDefaultSize, 0 );
186  itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
187 
188  wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
189  itemFlexGridSizer5->Add(itemBoxSizer9, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
190 
191 ////@end CCitSubPanel content construction
192 
193  CCit_sub& citsub = dynamic_cast<CCit_sub&>(*m_EditedCitSub);
194  m_Remark->SetValidator( CSerialTextValidator(citsub, "descr") );
195  CRef<objects::CDate> subdate(&(citsub.SetDate()));
196  m_date_ctrl = new CFlexibleDatePanel(itemPanel1, subdate);
197  itemBoxSizer9->Add(m_date_ctrl);
198 
199 }
200 
202 {
203  if (!wxPanel::TransferDataFromWindow()) {
204  return false;
205  }
206  m_date_ctrl->TransferDataFromWindow();
207  return true;
208 }
209 
211 {
212  if (!wxPanel::TransferDataToWindow()) {
213  return false;
214  }
215  m_date_ctrl->TransferDataToWindow();
216  return true;
217 }
218 
220 {
221  const CCit_sub& sub = dynamic_cast<const CCit_sub&>(*m_EditedCitSub);
222 
223  CRef<CCit_sub> ret(new CCit_sub());
224  ret->Assign(sub);
225  return ret;
226 }
227 
228 
229 /*
230  * Should we show tooltips?
231  */
232 
234 {
235  return true;
236 }
237 
238 /*
239  * Get bitmap resources
240  */
241 
242 wxBitmap CCitSubPanel::GetBitmapResource( const wxString& name )
243 {
244  // Bitmap retrieval
245 ////@begin CCitSubPanel bitmap retrieval
246  wxUnusedVar(name);
247  return wxNullBitmap;
248 ////@end CCitSubPanel bitmap retrieval
249 }
250 
251 /*
252  * Get icon resources
253  */
254 
255 wxIcon CCitSubPanel::GetIconResource( const wxString& name )
256 {
257  // Icon retrieval
258 ////@begin CCitSubPanel icon retrieval
259  wxUnusedVar(name);
260  return wxNullIcon;
261 ////@end CCitSubPanel icon retrieval
262 }
263 
264 
265 /*
266  * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CITSUB_ADD_STANDARD_REMARK
267  */
268 
270 {
271  wxString std_remark = m_StandardRemark->GetStringSelection();
272  wxString remark = std_remark;
273  if (std_remark == _("AA by submitter"))
274  remark = _("Amino acid sequence updated by submitter");
275  if (std_remark == _("NT by submitter"))
276  remark = _("Nucleotide sequence updated by submitter");
277  if (std_remark == _("NT and AA by submitter"))
278  remark = _("Nucleotide and amino acid sequences updated by submitter");
279  if (std_remark == _("AA by database"))
280  remark = _("Amino acid sequence updated by database staff");
281  if (std_remark == _("NT by database"))
282  remark = _("Nucleotide sequence updated by database staff");
283  if (std_remark == _("NT and AA by database"))
284  remark = _("Nucleotide and amino acid sequences updated by database staff");
285 
286  m_Remark->SetValue(remark);
287 }
288 
USING_SCOPE(objects)
#define ID_CITSUB_DESC
#define ID_CITSUB_ADD_STANDARD_REMARK
void OnCitsubAddStandardRemarkSelected(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CITSUB_ADD_STANDARD_REMARK
~CCitSubPanel()
Destructor.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxTextCtrl * m_Remark
virtual bool TransferDataToWindow()
static bool ShowToolTips()
Should we show tooltips?
bool Create(wxWindow *parent, wxWindowID id=10088, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
CRef< objects::CCit_sub > GetCit_sub() const
CCitSubPanel()
Constructors.
CRef< CSerialObject > m_EditedCitSub
virtual bool TransferDataFromWindow()
wxWindow * m_date_ctrl
wxChoice * m_StandardRemark
void Init()
Initialises member variables.
void CreateControls()
Creates the controls and sizers.
CSerialObject * m_Object
Base class for all serializable objects.
Definition: serialbase.hpp:150
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void SetDate(TDate &value)
Assign a value to Date data member.
Definition: Cit_sub_.cpp:101
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
Modified on Fri Sep 20 14:57:45 2024 by modify_doxy.py rev. 669887