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

Go to the SVN repository for this file.

1 /* $Id: generalid_panel.cpp 34886 2016-02-25 22:31:14Z 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>
34 #include <wx/sizer.h>
35 #include <wx/icon.h>
36 #include <wx/choice.h>
37 #include <wx/stattext.h>
38 #include <wx/textctrl.h>
39 
40 
42 
43 /*!
44  * CGeneralIDPanel type definition
45  */
46 
47 IMPLEMENT_DYNAMIC_CLASS( CGeneralIDPanel, CFieldNamePanel )
48 
49 
50 /*!
51  * CGeneralIDPanel event table definition
52  */
53 
54 BEGIN_EVENT_TABLE( CGeneralIDPanel, CFieldNamePanel )
55 
56 ////@begin CGeneralIDPanel event table entries
57  EVT_CHOICE( ID_CGENERALID_CHOICE, CGeneralIDPanel::OnGeneralIDChoice )
58 ////@end CGeneralIDPanel event table entries
59 
61 
62 
63 /*!
64  * CGeneralIDPanel constructors
65  */
66 
68 {
69  Init();
70 }
71 
72 CGeneralIDPanel::CGeneralIDPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
73 {
74  Init();
75  Create(parent, id, pos, size, style);
76 }
77 
78 
79 /*!
80  * CGeneralIDPanel creator
81  */
82 
83 bool CGeneralIDPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
84 {
85 ////@begin CGeneralIDPanel creation
86  CFieldNamePanel::Create(parent, id, pos, size, style);
87 
89  if (GetSizer())
90  {
91  GetSizer()->SetSizeHints(this);
92  }
93  Centre();
94 ////@end CGeneralIDPanel creation
95  return true;
96 }
97 
98 
99 /*!
100  * CGeneralIDPanel destructor
101  */
102 
104 {
105 ////@begin CGeneralIDPanel destruction
106 ////@end CGeneralIDPanel destruction
107 }
108 
109 
110 /*!
111  * Member initialisation
112  */
113 
115 {
116 ////@begin CGeneralIDPanel member initialisation
117  m_GenID = NULL;
118  m_Dblabel = NULL;
119  m_DbName = NULL;
120 ////@end CGeneralIDPanel member initialisation
121 }
122 
123 
124 /*!
125  * Control creation for CGeneralIDPanel
126  */
127 
129 {
130 ////@begin CGeneralIDPanel content construction
131  CGeneralIDPanel* itemPanel1 = this;
132 
133  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
134  itemPanel1->SetSizer(itemBoxSizer2);
135 
136  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
137  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
138 
139  wxArrayString m_GenIDStrings;
140  m_GenID = new wxChoice( itemPanel1, ID_CGENERALID_CHOICE, wxDefaultPosition, wxDefaultSize, m_GenIDStrings, 0 );
141  itemBoxSizer3->Add(m_GenID, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
142 
143  m_Dblabel = new wxStaticText( itemPanel1, wxID_STATIC, _("Db:"), wxDefaultPosition, wxDefaultSize, 0 );
144  itemBoxSizer3->Add(m_Dblabel, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
145 
146  m_DbName = new wxTextCtrl( itemPanel1, ID_CGENERALID_TEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
147  itemBoxSizer3->Add(m_DbName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
148 
149  vector<string> options = x_GetStrings();
150  ToArrayString(options, m_GenIDStrings);
151  m_GenID->Append(m_GenIDStrings);
152  m_GenID->SetSelection(0);
153 
154  m_Dblabel->Enable(false);
155  m_DbName->Enable(false);
156 
157 
158 ////@end CGeneralIDPanel content construction
159 }
160 
161 
163 {
164  vector<string> options;
165  unsigned int part = CGeneralIDField::eGenId;
166  for ( ; part <= CGeneralIDField::eGenIdTag; ++part) {
168  }
169 
170  return options;
171 }
172 
173 /*!
174  * Should we show tooltips?
175  */
176 
178 {
179  return true;
180 }
181 
182 /*!
183  * Get bitmap resources
184  */
185 
186 wxBitmap CGeneralIDPanel::GetBitmapResource( const wxString& name )
187 {
188  // Bitmap retrieval
189 ////@begin CGeneralIDPanel bitmap retrieval
190  wxUnusedVar(name);
191  return wxNullBitmap;
192 ////@end CGeneralIDPanel bitmap retrieval
193 }
194 
195 /*!
196  * Get icon resources
197  */
198 
199 wxIcon CGeneralIDPanel::GetIconResource( const wxString& name )
200 {
201  // Icon retrieval
202 ////@begin CGeneralIDPanel icon retrieval
203  wxUnusedVar(name);
204  return wxNullIcon;
205 ////@end CGeneralIDPanel icon retrieval
206 }
207 
208 
209 /*!
210  * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CGENERALID_CHOICE
211  */
212 
213 void CGeneralIDPanel::OnGeneralIDChoice( wxCommandEvent& event )
214 {
215  string selection =ToStdString(m_GenID->GetStringSelection());
217  m_Dblabel->Enable(true);
218  m_DbName->Enable(true);
219  } else {
220  m_Dblabel->Enable(false);
221  m_DbName->Enable(false);
222  }
223  event.Skip();
224 }
225 
226 string CGeneralIDPanel::GetFieldName(const bool subfield)
227 {
228  string field = kEmptyStr;
229  int val = m_GenID->GetSelection();
230  if (val > -1) {
231  field = ToStdString(m_GenID->GetString(val));
232  if (m_DbName->IsShown() && wxEmptyString != m_DbName->GetValue()) {
233  field = field + " " + ToStdString(m_DbName->GetValue());
234  }
235  }
236  return field;
237 }
238 
239 bool CGeneralIDPanel::SetFieldName(const string& field)
240 {
241  return true;
242 }
243 
245 
static const string & GetName_GeneralIDPart(EGeneralIDPart stype_part)
virtual bool SetFieldName(const string &field)
static bool ShowToolTips()
Should we show tooltips?
wxStaticText * m_Dblabel
wxTextCtrl * m_DbName
~CGeneralIDPanel()
Destructor.
void OnGeneralIDChoice(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CGENERALID_CHOICE
CGeneralIDPanel()
Constructors.
void CreateControls()
Creates the controls and sizers.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
bool Create(wxWindow *parent, wxWindowID id=ID_CGENERALIDPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
vector< string > x_GetStrings()
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
void Init()
Initialises member variables.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
#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
#define kEmptyStr
Definition: ncbistr.hpp:123
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
void ToArrayString(const vector< string > &out, wxArrayString &in)
Definition: wx_utils.cpp:353
Modified on Sun Mar 03 03:17:02 2024 by modify_doxy.py rev. 669887