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

Go to the SVN repository for this file.

1 /* $Id: vcf_sample_sel_panel.cpp 45881 2021-01-05 03:10:02Z rudnev $
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>
33 #include <wx/sizer.h>
34 #include <wx/checklst.h>
35 #include <wx/button.h>
36 #include <wx/wupdlock.h>
37 #include <wx/stattext.h>
38 
39 
41 
42 /*!
43  * CVcfSampleSelectionPanel type definition
44  */
45 
46 IMPLEMENT_DYNAMIC_CLASS( CVcfSampleSelectionPanel, wxPanel )
47 
48 
49 /*!
50  * CVcfSampleSelectionPanel event table definition
51  */
52 
53 BEGIN_EVENT_TABLE( CVcfSampleSelectionPanel, wxPanel )
54 
55 ////@begin CVcfSampleSelectionPanel event table entries
56  EVT_BUTTON( ID_SELECTALLSAMPLES, CVcfSampleSelectionPanel::OnSelectallSamplesClick )
57  EVT_BUTTON( ID_DESELECTALLSAMPLES, CVcfSampleSelectionPanel::OnDeselectallSamplesClick )
58 ////@end CVcfSampleSelectionPanel event table entries
59 
61 
62 
63 /*!
64  * CVcfSampleSelectionPanel constructors
65  */
66 
68 {
69  Init();
70 }
71 
72 CVcfSampleSelectionPanel::CVcfSampleSelectionPanel( 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  * CVcfSampleSelectionPanel creator
81  */
82 
83 bool CVcfSampleSelectionPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
84 {
85 ////@begin CVcfSampleSelectionPanel creation
86  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
87  wxPanel::Create( parent, id, pos, size, style );
88 
90  if (GetSizer())
91  {
92  GetSizer()->SetSizeHints(this);
93  }
94  Centre();
95 ////@end CVcfSampleSelectionPanel creation
96  return true;
97 }
98 
99 
100 /*!
101  * CVcfSampleSelectionPanel destructor
102  */
103 
105 {
106 ////@begin CVcfSampleSelectionPanel destruction
107 ////@end CVcfSampleSelectionPanel destruction
108 }
109 
110 
111 /*!
112  * Member initialisation
113  */
114 
116 {
117 ////@begin CVcfSampleSelectionPanel member initialisation
118  m_SampleList = NULL;
119 ////@end CVcfSampleSelectionPanel member initialisation
120 }
121 
122 
123 /*!
124  * Control creation for CVcfSampleSelectionPanel
125  */
126 
128 {
129 ////@begin CVcfSampleSelectionPanel content construction
130  CVcfSampleSelectionPanel* itemPanel1 = this;
131 
132  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
133  itemPanel1->SetSizer(itemBoxSizer2);
134 
135  wxStaticText* itemStaticText1 = new wxStaticText( itemPanel1, wxID_STATIC, _("Samples Columns"), wxDefaultPosition, wxDefaultSize, 0 );
136  itemBoxSizer2->Add(itemStaticText1, 0, wxALIGN_LEFT|wxALL, 5);
137 
138  wxArrayString m_SampleListStrings;
139  m_SampleList = new wxCheckListBox( itemPanel1, ID_SAMPLECHKLIST, wxDefaultPosition, wxDefaultSize, m_SampleListStrings, wxLB_SINGLE );
140  itemBoxSizer2->Add(m_SampleList, 1, wxGROW|wxALL, 5);
141 
142  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
143  itemBoxSizer2->Add(itemBoxSizer1, 0, wxALIGN_LEFT|wxTOP, 5);
144 
145  wxButton* itemButton2 = new wxButton( itemPanel1, ID_SELECTALLSAMPLES, _("Select All"), wxDefaultPosition, wxDefaultSize, 0 );
146  itemBoxSizer1->Add(itemButton2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
147 
148  wxButton* itemButton3 = new wxButton( itemPanel1, ID_DESELECTALLSAMPLES, _("Deselect All"), wxDefaultPosition, wxDefaultSize, 0 );
149  itemBoxSizer1->Add(itemButton3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
150 
151 ////@end CVcfSampleSelectionPanel content construction
152 }
153 
155 {
156  wxWindowUpdateLocker upd(m_SampleList);
157  m_SampleList->Clear();
158 
159  for (const auto& it : samples) {
160  m_SampleList->Append(it.second);
161  }
162 }
163 
165 {
166  selected.clear();
167  for (unsigned i = 0; i < m_SampleList->GetCount(); ++i) {
168  if (m_SampleList->IsChecked(i)) {
169  selected.emplace(i, ToStdString(m_SampleList->GetString(i)));
170  }
171  }
172 }
173 
175 {
176  wxArrayInt checkedItems;
177  m_SampleList->GetCheckedItems(checkedItems);
178  return (checkedItems.size() == m_SampleList->GetCount());
179 }
180 
181 /*!
182  * Should we show tooltips?
183  */
184 
186 {
187  return true;
188 }
189 
190 /*!
191  * Get bitmap resources
192  */
193 
194 wxBitmap CVcfSampleSelectionPanel::GetBitmapResource( const wxString& name )
195 {
196  // Bitmap retrieval
197 ////@begin CVcfSampleSelectionPanel bitmap retrieval
198  wxUnusedVar(name);
199  return wxNullBitmap;
200 ////@end CVcfSampleSelectionPanel bitmap retrieval
201 }
202 
203 /*!
204  * Get icon resources
205  */
206 
207 wxIcon CVcfSampleSelectionPanel::GetIconResource( const wxString& name )
208 {
209  // Icon retrieval
210 ////@begin CVcfSampleSelectionPanel icon retrieval
211  wxUnusedVar(name);
212  return wxNullIcon;
213 ////@end CVcfSampleSelectionPanel icon retrieval
214 }
215 
216 
217 /*!
218  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SELECTALLSAMPLES
219  */
220 
222 {
223  for (unsigned i = 0; i < m_SampleList->GetCount(); ++i)
224  m_SampleList->Check(i);
225 }
226 
227 
228 /*!
229  * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DESELECTALLSAMPLES
230  */
231 
233 {
234  for (unsigned i = 0; i < m_SampleList->GetCount(); ++i)
235  m_SampleList->Check(i, false);
236 }
237 
239 
void OnSelectallSamplesClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SELECTALLSAMPLES
void SetSamples(const map< unsigned, string > &samples)
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=ID_CVCFSAMPLESELECTIONPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
static bool ShowToolTips()
Should we show tooltips?
void GetSelectedSamples(map< unsigned, string > &selected)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void Init()
Initialises member variables.
void OnDeselectallSamplesClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DESELECTALLSAMPLES
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void clear()
Definition: map.hpp:169
#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
const struct ncbi::grid::netcache::search::fields::SIZE size
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Tue Apr 23 07:38:47 2024 by modify_doxy.py rev. 669887