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

Go to the SVN repository for this file.

1 /* $Id: ld_filter_dlg.cpp 25491 2012-03-27 17:52:21Z kuznets $
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: Melvin Quintos
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 ////@begin includes
33 ////@end includes
34 
36 
37 ////@begin XPM images
38 ////@end XPM images
39 
41 
42 /*!
43  * CLDFilterDialog type definition
44  */
45 
46 IMPLEMENT_DYNAMIC_CLASS( CLDFilterDialog, wxDialog )
47 
48 
49 /*!
50  * CLDFilterDialog event table definition
51  */
52 
53 BEGIN_EVENT_TABLE( CLDFilterDialog, wxDialog )
54 
55 ////@begin CLDFilterDialog event table entries
57 
58  EVT_SLIDER( ID_SLIDER1, CLDFilterDialog::OnLengthSliderUpdated )
59 
60 ////@end CLDFilterDialog event table entries
61 
63 
64 
65 /*!
66  * CLDFilterDialog constructors
67  */
68 
70 {
71  Init();
72 }
73 
74 CLDFilterDialog::CLDFilterDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
75 {
76  Init();
77  CreateX(parent, id, caption, pos, size, style);
78 }
79 
80 
81 /*!
82  * CLDFilterDialog creator
83  */
84 
85 bool CLDFilterDialog::CreateX( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
86 {
87 ////@begin CLDFilterDialog creation
88  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
89  wxDialog::Create( parent, id, caption, pos, size, style );
90 
92  if (GetSizer())
93  {
94  GetSizer()->SetSizeHints(this);
95  }
96  Centre();
97 ////@end CLDFilterDialog creation
98  return true;
99 }
100 
101 
102 /*!
103  * CLDFilterDialog destructor
104  */
105 
107 {
108 ////@begin CLDFilterDialog destruction
109 ////@end CLDFilterDialog destruction
110 }
111 
112 
113 /*!
114  * Member initialisation
115  */
116 
118 {
119 ////@begin CLDFilterDialog member initialisation
120  m_ctrlScore = NULL;
121  m_txtScore = NULL;
122  m_ctrlLength = NULL;
123  m_txtLength = NULL;
124 ////@end CLDFilterDialog member initialisation
125 }
126 
127 
128 /*!
129  * Control creation for CLDFilterDialog
130  */
131 
133 {
134 ////@begin CLDFilterDialog content construction
135  CLDFilterDialog* itemDialog1 = this;
136 
137  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
138  itemDialog1->SetSizer(itemBoxSizer2);
139 
140  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
141  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
142 
143  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
144  itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
145 
146  wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Score"), wxDefaultPosition, wxSize(-1, 20), 0 );
147  itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
148 
149  wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Length"), wxDefaultPosition, wxSize(-1, 20), 0 );
150  itemBoxSizer4->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
151 
152  wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL);
153  itemBoxSizer3->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
154 
155  wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
156  itemBoxSizer7->Add(itemBoxSizer8, 0, wxALIGN_LEFT|wxALL, 0);
157 
158  m_ctrlScore = new wxSlider( itemDialog1, ID_SLIDER, 0, 0, 100, wxDefaultPosition, wxSize(-1, 20), wxSL_HORIZONTAL );
159  itemBoxSizer8->Add(m_ctrlScore, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
160 
161  m_txtScore = new wxStaticText( itemDialog1, wxID_STATIC, _("0.0"), wxDefaultPosition, wxDefaultSize, 0 );
162  itemBoxSizer8->Add(m_txtScore, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
163 
164  wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
165  itemBoxSizer7->Add(itemBoxSizer11, 0, wxALIGN_LEFT|wxALL, 0);
166 
167  m_ctrlLength = new wxSlider( itemDialog1, ID_SLIDER1, 0, 0, 7, wxDefaultPosition, wxSize(-1, 20), wxSL_HORIZONTAL );
168  itemBoxSizer11->Add(m_ctrlLength, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
169 
170  m_txtLength = new wxStaticText( itemDialog1, wxID_STATIC, _("10^0 b"), wxDefaultPosition, wxDefaultSize, 0 );
171  itemBoxSizer11->Add(m_txtLength, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
172 
173  wxStdDialogButtonSizer* itemStdDialogButtonSizer14 = new wxStdDialogButtonSizer;
174 
175  itemBoxSizer2->Add(itemStdDialogButtonSizer14, 0, wxALIGN_RIGHT|wxALL, 5);
176  wxButton* itemButton15 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
177  itemStdDialogButtonSizer14->AddButton(itemButton15);
178 
179  wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
180  itemStdDialogButtonSizer14->AddButton(itemButton16);
181 
182  itemStdDialogButtonSizer14->Realize();
183 
184  // Set validators
185  m_ctrlScore->SetValidator( wxGenericValidator(& GetData().m_nScore) );
186  m_ctrlLength->SetValidator( wxGenericValidator(& GetData().m_nLengthExp) );
187 ////@end CLDFilterDialog content construction
188 }
189 
190 
191 /*!
192  * Should we show tooltips?
193  */
194 
196 {
197  return true;
198 }
199 
200 /*!
201  * Get bitmap resources
202  */
203 
204 wxBitmap CLDFilterDialog::GetBitmapResource( const wxString& name )
205 {
206  // Bitmap retrieval
207 ////@begin CLDFilterDialog bitmap retrieval
208  wxUnusedVar(name);
209  return wxNullBitmap;
210 ////@end CLDFilterDialog bitmap retrieval
211 }
212 
213 /*!
214  * Get icon resources
215  */
216 
217 wxIcon CLDFilterDialog::GetIconResource( const wxString& name )
218 {
219  // Icon retrieval
220 ////@begin CLDFilterDialog icon retrieval
221  wxUnusedVar(name);
222  return wxNullIcon;
223 ////@end CLDFilterDialog icon retrieval
224 }
225 
226 
227 /*!
228  * wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER
229  */
230 
231 void CLDFilterDialog::OnScoreSliderUpdated( wxCommandEvent& event )
232 {
233  int v = m_ctrlScore->GetValue();
234  float score = (float)(v)/100;
235  wxString label = wxString::Format(wxT("%3.2f"), score);
236  m_txtScore->SetLabel(label);
237 
238  event.Skip();
239 }
240 
241 
242 /*!
243  * wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER1
244  */
245 
246 void CLDFilterDialog::OnLengthSliderUpdated( wxCommandEvent& event )
247 {
248  int v = m_ctrlLength->GetValue();
249 
250  wxString base = wxT("bp");
251  if (v < 3)
252  base = wxT(" bp");
253  else if (v < 6)
254  base = wxT(" Kbp");
255  else if (v < 9)
256  base = wxT(" Mbp");
257 
258  int lenPow = (int)pow(10.0f, v%3);
259  wxString label = wxString::Format(wxT("%d"), lenPow) + base;
260  m_txtLength->SetLabel(label);
261 
262  event.Skip();
263 }
264 
265 
267 {
268  bool res = wxDialog::TransferDataToWindow();
269 
270  wxCommandEvent dummy;
273 
274  return res;
275 }
276 
278 
unsigned dummy
Definition: block_cipher.h:0
wxSlider * m_ctrlLength
wxStaticText * m_txtScore
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CLDFilterParams & GetData()
Data access.
wxStaticText * m_txtLength
void CreateControls()
Creates the controls and sizers.
void OnLengthSliderUpdated(wxCommandEvent &event)
wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER1
void OnScoreSliderUpdated(wxCommandEvent &event)
wxEVT_COMMAND_SLIDER_UPDATED event handler for ID_SLIDER
void Init()
Initialises member variables.
wxSlider * m_ctrlScore
virtual bool TransferDataToWindow()
Transfer data to the window.
CLDFilterDialog()
Constructors.
~CLDFilterDialog()
Destructor.
bool CreateX(wxWindow *parent, wxWindowID id=ID_LDBLOCKFILTER, const wxString &caption=_("LD BLock Filter"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
static bool ShowToolTips()
Should we show tooltips?
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 ID_SLIDER
#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
static const char label[]
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
Format
Definition: njn_ioutil.hpp:52
Modified on Thu May 23 12:30:49 2024 by modify_doxy.py rev. 669887