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

Go to the SVN repository for this file.

1 /* $Id: release_date_panel.cpp 27854 2013-04-12 20:52:44Z 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 #include <objects/general/Date.hpp>
36 
37 ////@begin includes
38 ////@end includes
39 
40 #include <wx/sizer.h>
41 #include <wx/textctrl.h>
42 #include <wx/choice.h>
44 
45 
47 
48 
49 ////@begin XPM images
50 ////@end XPM images
51 
52 
53 /*
54  * CReleaseDatePanel type definition
55  */
56 
57 IMPLEMENT_DYNAMIC_CLASS( CReleaseDatePanel, wxPanel )
58 
59 
60 /*
61  * CReleaseDatePanel event table definition
62  */
63 
64 BEGIN_EVENT_TABLE( CReleaseDatePanel, wxPanel )
65 
66 ////@begin CReleaseDatePanel event table entries
68 
70 
71 ////@end CReleaseDatePanel event table entries
72 
74 
75 
76 /*
77  * CReleaseDatePanel constructors
78  */
79 
81 {
82  Init();
83 }
84 
85 CReleaseDatePanel::CReleaseDatePanel( wxWindow* parent, CSerialObject& object, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
86  : m_Object(&object)
87 {
88  Init();
89  Create(parent, id, pos, size, style);
90 }
91 
92 
93 /*
94  * CReleaseDatePanel creator
95  */
96 
97 bool CReleaseDatePanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
98 {
99 ////@begin CReleaseDatePanel creation
100  wxPanel::Create( parent, id, pos, size, style );
101 
102  CreateControls();
103  if (GetSizer())
104  {
105  GetSizer()->SetSizeHints(this);
106  }
107  Centre();
108 ////@end CReleaseDatePanel creation
109  return true;
110 }
111 
112 
113 /*
114  * CReleaseDatePanel destructor
115  */
116 
118 {
119 ////@begin CReleaseDatePanel destruction
120 ////@end CReleaseDatePanel destruction
121 }
122 
123 
124 /*
125  * Member initialisation
126  */
127 
129 {
130 ////@begin CReleaseDatePanel member initialisation
132  m_HUP = NULL;
133  m_DateSizer = NULL;
134 ////@end CReleaseDatePanel member initialisation
135 }
136 
137 
138 /*
139  * Control creation for CReleaseDatePanel
140  */
141 
143 {
144 ////@begin CReleaseDatePanel content construction
145  CReleaseDatePanel* itemPanel1 = this;
146 
147  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
148  itemPanel1->SetSizer(itemBoxSizer2);
149 
150  wxStaticText* itemStaticText3 = new wxStaticText( itemPanel1, wxID_STATIC, _("When may we release your sequence record?"), wxDefaultPosition, wxDefaultSize, 0 );
151  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
152 
153  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
154  itemBoxSizer2->Add(itemBoxSizer4, 0, 0, 0);
155 
156  m_ImmediateRelease = new wxRadioButton( itemPanel1, ID_RADIOBUTTON, _("Immediately after processing"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
157  m_ImmediateRelease->SetValue(true);
158  itemBoxSizer4->Add(m_ImmediateRelease, 0, wxALIGN_LEFT|wxALL, 5);
159 
160  m_HUP = new wxRadioButton( itemPanel1, ID_RADIOBUTTON1, _("Release date:"), wxDefaultPosition, wxDefaultSize );
161  m_HUP->SetValue(false);
162  itemBoxSizer4->Add(m_HUP, 0, wxALIGN_LEFT|wxALL, 5);
163 
164  m_DateSizer = new wxBoxSizer(wxHORIZONTAL);
165  itemBoxSizer2->Add(m_DateSizer, 0, 0, 0);
166 
167 ////@end CReleaseDatePanel content construction
168  objects::CSubmit_block * block = dynamic_cast<objects::CSubmit_block*>(m_Object);
169  CRef<objects::CDate> r_date(&(block->SetReldate()));
170  CRef<objects::CDate> today( new objects::CDate(CTime(CTime::eCurrent), objects::CDate::ePrecision_day) );
171  m_Reldate = new CFlexibleDatePanel(itemPanel1, r_date, today->GetStd().GetYear(), 10);
172  m_DateSizer->Add ( m_Reldate, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
173  m_Reldate->Enable(false);
174 }
175 
176 
178 {
179  if (!wxPanel::TransferDataToWindow()) {
180  return false;
181  }
182  objects::CSubmit_block * block = dynamic_cast<objects::CSubmit_block*>(m_Object);
183  if (block->IsSetHup() && block->GetHup() && block->IsSetReldate()) {
184  m_ImmediateRelease->SetValue (false);
185  m_HUP->SetValue (true);
186  m_Reldate->Enable(true);
187  m_Reldate->SetDate(block->GetReldate());
189  } else {
190  m_ImmediateRelease->SetValue (true);
191  m_HUP->SetValue (false);
192  m_Reldate->Enable(false);
193  }
194 
195  return true;
196 }
197 
198 
200 {
201  if (!wxPanel::TransferDataFromWindow()) {
202  return false;
203  }
204  objects::CSubmit_block * block = dynamic_cast<objects::CSubmit_block*>(m_Object);
205  if (m_HUP->GetValue()) {
206  block->SetHup(true);
209  if (!r_date) {
210  block->SetHup(false);
211  block->ResetReldate();
212  } else {
213  block->SetReldate(*r_date);
214  }
215  } else {
216  block->SetHup(false);
217  block->ResetReldate();
218  }
219 
220  return true;
221 }
222 
223 
225 {
226  if (!(m_HUP->GetValue() && m_Reldate->GetDate()) && !m_ImmediateRelease->GetValue()) {
227  return "You must choose immediate release or select a release date!";
228  } else {
229  return "";
230  }
231 }
232 
233 
235 {
236  m_HUP->SetValue(false);
237  m_ImmediateRelease->SetValue(false);
238  m_Reldate->Clear();
239  m_Reldate->Enable(false);
240 }
241 
242 
243 /*
244  * Should we show tooltips?
245  */
246 
248 {
249  return true;
250 }
251 
252 /*
253  * Get bitmap resources
254  */
255 
256 wxBitmap CReleaseDatePanel::GetBitmapResource( const wxString& name )
257 {
258  // Bitmap retrieval
259 ////@begin CReleaseDatePanel bitmap retrieval
260  wxUnusedVar(name);
261  return wxNullBitmap;
262 ////@end CReleaseDatePanel bitmap retrieval
263 }
264 
265 /*
266  * Get icon resources
267  */
268 
269 wxIcon CReleaseDatePanel::GetIconResource( const wxString& name )
270 {
271  // Icon retrieval
272 ////@begin CReleaseDatePanel icon retrieval
273  wxUnusedVar(name);
274  return wxNullIcon;
275 ////@end CReleaseDatePanel icon retrieval
276 }
277 
278 
279 /*
280  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON
281  */
282 
284 {
285  m_Reldate->Enable(false);
286 }
287 
288 
289 /*
290  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON1
291  */
292 
293 void CReleaseDatePanel::OnHUPSelected( wxCommandEvent& event )
294 {
295  m_Reldate->Enable(true);
296 }
297 
User-defined methods of the data storage class.
CRef< objects::CDate > GetDate() const
void SetDate(const objects::CDate &a_date)
void OnHUPSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON1
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
bool Create(wxWindow *parent, wxWindowID id=10085, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void Init()
Initialises member variables.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxRadioButton * m_ImmediateRelease
void CreateControls()
Creates the controls and sizers.
virtual bool TransferDataFromWindow()
virtual bool TransferDataToWindow()
void OnImmediateReleaseSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RADIOBUTTON
~CReleaseDatePanel()
Destructor.
CReleaseDatePanel()
Constructors.
static bool ShowToolTips()
Should we show tooltips?
CSerialObject * m_Object
CFlexibleDatePanel * m_Reldate
Base class for all serializable objects.
Definition: serialbase.hpp:150
CTime –.
Definition: ncbitime.hpp:296
#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
@ eCurrent
Use current time. See also CCurrentTime.
Definition: ncbitime.hpp:300
#define ID_RADIOBUTTON1
#define ID_RADIOBUTTON
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
Modified on Sun Mar 03 03:10:19 2024 by modify_doxy.py rev. 669887