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

Go to the SVN repository for this file.

1 /* $Id: seqsub_molinfo_panel.cpp 47619 2023-11-30 19:47:11Z 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>
35 
36 #include <wx/sizer.h>
37 #include <wx/listbook.h>
38 #include <wx/icon.h>
39 
40 
42 
43 /*
44  * CSubMolinfoPanel type definition
45  */
46 
47 IMPLEMENT_DYNAMIC_CLASS( CSubMolinfoPanel, wxPanel )
48 
49 
50 /*
51  * CSubMolinfoPanel event table definition
52  */
53 
54 BEGIN_EVENT_TABLE( CSubMolinfoPanel, wxPanel )
55  EVT_LISTBOOK_PAGE_CHANGED(ID_MOLINFONOTEBOOK, CSubMolinfoPanel::OnPageChanged)
56  EVT_LISTBOOK_PAGE_CHANGING(ID_MOLINFONOTEBOOK, CSubMolinfoPanel::OnPageChanging)
58 
59 
60 /*
61  * CSubMolinfoPanel constructors
62  */
63 
65 {
66  Init();
67 }
68 
69 CSubMolinfoPanel::CSubMolinfoPanel( wxWindow* parent, ICommandProccessor* cmdproc, objects::CSeq_entry_Handle seh, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
70  : m_CmdProcessor(cmdproc), m_Seh(seh)
71 {
72  Init();
73  Create(parent, id, pos, size, style);
74 }
75 
76 
77 /*
78  * CSubMolinfoPanel creator
79  */
80 
81 bool CSubMolinfoPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
82 {
83 ////@begin CSubMolinfoPanel creation
84  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
85  wxPanel::Create( parent, id, pos, size, style );
86 
88  if (GetSizer())
89  {
90  GetSizer()->SetSizeHints(this);
91  }
92  Centre();
93 ////@end CSubMolinfoPanel creation
94  return true;
95 }
96 
97 
98 /*
99  * CSubMolinfoPanel destructor
100  */
101 
103 {
104 ////@begin CSubMolinfoPanel destruction
105 ////@end CSubMolinfoPanel destruction
106 }
107 
108 
109 /*
110  * Member initialisation
111  */
112 
114 {
115 ////@begin CSubMolinfoPanel member initialisation
116  m_Listbook = NULL;
120 ////@end CSubMolinfoPanel member initialisation
121 }
122 
123 static const char* empty_xpm[] = {
124 "60 1 1 1",
125 " c None",
126 " " };
127 
128 /*
129  * Control creation for CSubMolinfoPanel
130  */
131 
133 {
134 ////@begin CSubMolinfoPanel content construction
135  CSubMolinfoPanel* itemPanel1 = this;
136 
137  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
138  itemPanel1->SetSizer(itemBoxSizer2);
139 
140  m_Listbook = new wxListbook( itemPanel1, ID_MOLINFONOTEBOOK, wxDefaultPosition, wxDefaultSize, wxBK_TOP|wxNO_BORDER );
141  itemBoxSizer2->Add(m_Listbook, 1, wxGROW | wxALL, 5);
142 
144  m_Listbook->AddPage(m_ChromosomePanel, _("Chromosome"));
145 
147  m_Listbook->AddPage(m_PlasmidPanel, _("Plasmid"));
148 
150  m_Listbook->AddPage(m_OrganellePanel, _("Organelle"));
151 
152 #ifdef __WXMSW__
153  wxBitmapBundle bmp_bundle(empty_xpm);
154  wxBookCtrlBase::Images m_Images(m_Listbook->GetPageCount(), bmp_bundle);
155  m_Listbook->SetImages(m_Images);
156  for (unsigned i = 0; i < m_Images.size(); ++i) {
157  m_Listbook->SetPageImage(i, i);
158  }
159 #endif
160 
161 ////@end CSubMolinfoPanel content construction
162 }
163 
165 {
166  return x_DoStepForward(m_Listbook);
167 }
168 
170 {
172 }
173 
174 void CSubMolinfoPanel::OnPageChanged(wxBookCtrlEvent& event)
175 {
176  GetParentWizard(this)->UpdateOnPageChange(this);
177 }
178 
179 /*
180  * Should we show tooltips?
181  */
182 
184 {
185  return true;
186 }
187 
188 /*
189  * Get bitmap resources
190  */
191 
192 wxBitmap CSubMolinfoPanel::GetBitmapResource( const wxString& name )
193 {
194  // Bitmap retrieval
195 ////@begin CSubMolinfoPanel bitmap retrieval
196  wxUnusedVar(name);
197  return wxNullBitmap;
198 ////@end CSubMolinfoPanel bitmap retrieval
199 }
200 
201 /*
202  * Get icon resources
203  */
204 
205 wxIcon CSubMolinfoPanel::GetIconResource( const wxString& name )
206 {
207  // Icon retrieval
208 ////@begin CSubMolinfoPanel icon retrieval
209  wxUnusedVar(name);
210  return wxNullIcon;
211 ////@end CSubMolinfoPanel icon retrieval
212 }
213 
215 {
216  for (size_t i = 0; i < m_Listbook->GetPageCount(); ++i) {
217  m_Listbook->GetPage(i)->TransferDataToWindow();
218  }
219  return wxPanel::TransferDataToWindow();
220 }
221 
222 void CSubMolinfoPanel::OnPageChanging(wxBookCtrlEvent& event)
223 {
224  ApplyCommand();
225 }
226 
228 {
229  auto page = x_GetCurrentPage();
230  if (page) {
231  page->ApplyCommand();
232  }
233 }
234 
236 {
237  ISubmissionPage* page = nullptr;
238  if (m_Listbook) {
239  wxWindow *win = m_Listbook->GetCurrentPage();
240  if (win) {
241  page = dynamic_cast<ISubmissionPage*>(win);
242  }
243  }
244  return page;
245 }
246 
247 void CSubMolinfoPanel::SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
248 {
249  m_Seh = seh;
253 }
254 
256 {
257  for (size_t i = 0; i < m_Listbook->GetPageCount(); ++i)
258  {
259  wxWindow* win = m_Listbook->GetPage(i);
260  ISubmissionPage* page = dynamic_cast<ISubmissionPage*>(win);
261  page->ReportMissingFields(text);
262  }
263 }
264 
266 {
267  auto page = x_GetCurrentPage();
268  if (page) {
269  return page->GetAnchor();
270  }
271  return wxEmptyString;
272 }
273 
275 {
276  auto page = x_GetCurrentPage();
277  if (page) {
278  return page->GetName();
279  }
280  return wxEmptyString;
281 }
282 
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
CSeqSubChromoPanel * m_ChromosomePanel
virtual bool StepBackward()
virtual void ApplyCommand()
void OnPageChanged(wxBookCtrlEvent &event)
ISubmissionPage * x_GetCurrentPage() const
virtual wxString GetAnchor()
~CSubMolinfoPanel()
Destructor.
CSeqSubOrganellePanel * m_OrganellePanel
virtual void ReportMissingFields(string &text)
void OnPageChanging(wxBookCtrlEvent &event)
bool Create(wxWindow *parent, wxWindowID id=ID_CSUBMOLINFOPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void Init()
Initialises member variables.
void CreateControls()
Creates the controls and sizers.
static bool ShowToolTips()
Should we show tooltips?
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
virtual wxString GetName() const
ICommandProccessor * m_CmdProcessor
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CSubMolinfoPanel()
Constructors.
CSeqSubPlasmidPanel * m_PlasmidPanel
objects::CSeq_entry_Handle m_Seh
virtual bool StepForward()
virtual bool TransferDataToWindow()
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
virtual void UpdateOnPageChange(wxWindow *current_page)=0
Undo/Redo interface for editing operations.
bool x_DoStepForward(wxListbook *book)
virtual void ReportMissingFields(string &text)
bool x_DoStepBackward(wxListbook *book)
CSubmissionPageChangeListener * GetParentWizard(wxWindow *wnd) const
#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
END_EVENT_TABLE()
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
const struct ncbi::grid::netcache::search::fields::SIZE size
static const char * empty_xpm[]
Modified on Fri Sep 20 14:57:27 2024 by modify_doxy.py rev. 669887