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

Go to the SVN repository for this file.

1 /* $Id: descriptortext_panel.cpp 43145 2019-05-21 17:08:04Z 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>
31 ////@begin includes
32 ////@end includes
33 
34 #include "descriptortext_panel.hpp"
35 
37 
38 ////@begin XPM images
39 ////@end XPM images
40 
43 
44 /*!
45  * CDescriptorTextPanel type definition
46  */
47 
48 IMPLEMENT_DYNAMIC_CLASS( CDescriptorTextPanel, wxPanel )
49 
50 
51 /*!
52  * CDescriptorTextPanel event table definition
53  */
54 
55 BEGIN_EVENT_TABLE( CDescriptorTextPanel, wxPanel )
56 
57 ////@begin CDescriptorTextPanel event table entries
58 ////@end CDescriptorTextPanel event table entries
59 
61 
62 
63 /*!
64  * CDescriptorTextPanel constructors
65  */
66 
68 {
69  Init();
70 }
71 
72 CDescriptorTextPanel::CDescriptorTextPanel( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
73 {
74  Init();
75  Create(parent, id, caption, pos, size, style);
76 }
77 
78 
79 /*!
80  * CDescriptorTextPanel creator
81  */
82 
83 bool CDescriptorTextPanel::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
84 {
85 ////@begin CDescriptorTextPanel creation
86  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
87  wxPanel::Create( parent, id, pos, size, style );
88 
90  if (GetSizer())
91  {
92  GetSizer()->SetSizeHints(this);
93  }
94  Centre();
95 ////@end CDescriptorTextPanel creation
96  return true;
97 }
98 
99 
100 /*!
101  * CDescriptorTextPanel destructor
102  */
103 
105 {
106 ////@begin CDescriptorTextPanel destruction
107 ////@end CDescriptorTextPanel destruction
108 }
109 
110 
111 /*!
112  * Member initialisation
113  */
114 
116 {
117 ////@begin CDescriptorTextPanel member initialisation
118  m_Text = NULL;
119 ////@end CDescriptorTextPanel member initialisation
120 }
121 
122 
123 /*!
124  * Control creation for CDescriptorTextPanel
125  */
126 
128 {
129 ////@begin CDescriptorTextPanel content construction
130  CDescriptorTextPanel* itemPanel1 = this;
131 
132  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
133  itemPanel1->SetSizer(itemBoxSizer2);
134 
135  m_Text = new wxTextCtrl( itemPanel1, ID_TEXTCTRL23, wxEmptyString, wxDefaultPosition, wxSize(400, 300), wxTE_MULTILINE );
136  itemBoxSizer2->Add(m_Text, 1, wxGROW|wxALL, 5);
137 
138 ////@end CDescriptorTextPanel content construction
139 }
140 
141 
142 void CDescriptorTextPanel::SetText( const wxString& value)
143 {
144  m_Text->SetValue (value);
145 }
146 
147 
149 {
150  return m_Text->GetValue ();
151 }
152 
153 
154 /*!
155  * Should we show tooltips?
156  */
157 
159 {
160  return true;
161 }
162 
163 /*!
164  * Get bitmap resources
165  */
166 
167 wxBitmap CDescriptorTextPanel::GetBitmapResource( const wxString& name )
168 {
169  // Bitmap retrieval
170 ////@begin CDescriptorTextPanel bitmap retrieval
171  wxUnusedVar(name);
172  return wxNullBitmap;
173 ////@end CDescriptorTextPanel bitmap retrieval
174 }
175 
176 /*!
177  * Get icon resources
178  */
179 
180 wxIcon CDescriptorTextPanel::GetIconResource( const wxString& name )
181 {
182  // Icon retrieval
183 ////@begin CDescriptorTextPanel icon retrieval
184  wxUnusedVar(name);
185  return wxNullIcon;
186 ////@end CDescriptorTextPanel icon retrieval
187 }
188 
189 
190 void CDescriptorTextPanel::ChangeSeqdesc(const objects::CSeqdesc& desc)
191 {
192  switch (desc.Which()) {
193  case CSeqdesc::e_Title:
194  m_Text->SetValue(ToWxString(desc.GetTitle()));
195  break;
196  case CSeqdesc::e_Comment:
197  m_Text->SetValue(ToWxString(desc.GetComment()));
198  break;
199  case CSeqdesc::e_Region:
200  m_Text->SetValue(ToWxString(desc.GetRegion()));
201  break;
202  case CSeqdesc::e_Name:
203  m_Text->SetValue(ToWxString(desc.GetName()));
204  break;
205  default:
206  m_Text->SetValue(wxEmptyString);
207  break;
208  }
209  m_Desc.Reset(new CSeqdesc);
210  m_Desc->Assign(desc);
211 }
212 
213 
214 void CDescriptorTextPanel::UpdateSeqdesc(objects::CSeqdesc& desc)
215 {
216  TransferDataFromWindow();
217  string text = ToStdString (m_Text->GetValue());
218  switch (desc.Which()) {
219  case CSeqdesc::e_Comment:
220  desc.SetComment(text);
221  break;
222  case CSeqdesc::e_Title:
223  desc.SetTitle(text);
224  break;
225  case CSeqdesc::e_Name:
226  desc.SetName(text);
227  break;
228  case CSeqdesc::e_Region:
229  desc.SetRegion(text);
230  break;
231  default:
232  break;
233  }
234 }
235 
237 {
238  return RunningInsideNCBI();
239 }
240 
242 {
243  return RunningInsideNCBI();
244 }
245 
247 {
248  if (m_Desc)
249  {
250  TransferDataFromWindow();
253  so->Assign(*m_Desc);
254  return so;
255  }
256  return CRef<CSerialObject>(NULL);
257 }
258 
260 {
261  CRef<CSeqdesc> desc(new CSeqdesc);
262  istr >> MSerial_AsnText >> *desc;
263  ChangeSeqdesc(*desc);
264  TransferDataToWindow();
265 }
266 
void SetText(const wxString &value)
virtual void UpdateSeqdesc(objects::CSeqdesc &desc)
CDescriptorTextPanel()
Constructors.
static bool ShowToolTips()
Should we show tooltips?
virtual void ChangeSeqdesc(const objects::CSeqdesc &desc)
virtual bool IsImportEnabled(void)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
virtual bool IsExportEnabled(void)
CRef< objects::CSeqdesc > m_Desc
virtual CRef< CSerialObject > OnExport(void)
void Init()
Initialises member variables.
bool Create(wxWindow *parent, wxWindowID id=ID_CDESCRIPTORTEXTPANEL, const wxString &caption=_("Descriptor Text Panel"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CreateControls()
Creates the controls and sizers.
virtual void OnImport(CNcbiIfstream &istr)
Base class for all serializable objects.
Definition: serialbase.hpp:150
USING_SCOPE(objects)
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.
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
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
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
@ e_Comment
a more extensive comment
Definition: Seqdesc_.hpp:117
@ e_Region
overall region (globin locus)
Definition: Seqdesc_.hpp:123
@ e_Title
a title for this sequence
Definition: Seqdesc_.hpp:115
@ e_Name
a name for this sequence
Definition: Seqdesc_.hpp:114
END_EVENT_TABLE()
static void text(MDB_val *v)
Definition: mdb_dump.c:62
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
bool RunningInsideNCBI()
Definition: wx_utils.cpp:1335
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed May 15 15:04:02 2024 by modify_doxy.py rev. 669887