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

Go to the SVN repository for this file.

1 /* $Id: feature_check_dialog.cpp 39666 2017-10-25 16:01:13Z katargir $
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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <wx/bitmap.h>
33 #include <wx/icon.h>
34 #include <wx/sizer.h>
35 #include <wx/stattext.h>
36 #include <wx/statbox.h>
37 #include <wx/button.h>
38 #include <wx/dialog.h>
39 #include <wx/srchctrl.h>
40 
41 ////@begin includes
42 ////@end includes
43 
48 
49 ////@begin XPM images
50 ////@end XPM images
51 
53 
54 static const char * kSelectedNodes = "SelectedNodes";
55 static const char * kExpandedNodes = "ExpandedNodes";
56 
57 /*!
58  * CFeatureCheckDialog type definition
59  */
60 
61 IMPLEMENT_DYNAMIC_CLASS( CFeatureCheckDialog, wxDialog )
62 
63 
64 /*!
65  * CFeatureCheckDialog event table definition
66  */
67 
68 BEGIN_EVENT_TABLE( CFeatureCheckDialog, wxDialog )
69 
70 ////@begin CFeatureCheckDialog event table entries
73 
74 ////@end CFeatureCheckDialog event table entries
75 
77 
78 
79 /*!
80  * CFeatureCheckDialog constructors
81  */
82 
84 {
85  Init();
86 }
87 
88 CFeatureCheckDialog::CFeatureCheckDialog( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
89 {
90  Init();
91  Create(parent, id, caption, pos, size, style);
92 }
93 
94 
95 /*!
96  * CFeatureSelectDialog creator
97  */
98 
99 bool CFeatureCheckDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
100 {
101 ////@begin CFeatureCheckDialog creation
102  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
103  wxDialog::Create( parent, id, caption, pos, size, style );
104 
105  CreateControls();
106  if (GetSizer())
107  {
108  GetSizer()->SetSizeHints(this);
109  }
110  Centre();
111 ////@end CFeatureCheckDialog creation
112  return true;
113 }
114 
115 
116 /*!
117  * CFeatureCheckDialog destructor
118  */
119 
121 {
122 ////@begin CFeatureCheckDialog destruction
123 ////@end CFeatureCheckDialog destruction
124 }
125 
126 
127 /*!
128  * Member initialisation
129  */
130 
132 {
133 ////@begin CFeatureCheckDialog member initialisation
134  m_Filter = NULL;
135  m_Panel = NULL;
136 ////@end CFeatureCheckDialog member initialisation
137 
138  m_RegPath = "";
139 
140 }
141 
142 
143 /*!
144  * Control creation for CFeatureSelectDialog
145  */
146 
148 {
149 ////@begin CFeatureCheckDialog content construction
150  CFeatureCheckDialog* itemDialog1 = this;
151 
152  wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(0, 1, 0, 0);
153  itemDialog1->SetSizer(itemFlexGridSizer2);
154 
155  wxStaticBox* itemStaticBoxSizer3Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Type any part of feature name to filter list"));
156  wxStaticBoxSizer* itemStaticBoxSizer3 = new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxVERTICAL);
157  itemFlexGridSizer2->Add(itemStaticBoxSizer3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
158 
159  m_Filter = new wxSearchCtrl( itemDialog1, ID_SEARCHCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
160  itemStaticBoxSizer3->Add(m_Filter, 0, wxGROW|wxALL, 5);
161 
162  m_Panel = new CFeatureCheckPanel( itemDialog1, ID_PANEL1, wxDefaultPosition, wxSize(240, 200), wxTAB_TRAVERSAL );
163  itemFlexGridSizer2->Add(m_Panel, 1, wxGROW|wxGROW|wxALL, 5);
164 
165  wxStaticLine* itemStaticLine6 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
166  itemFlexGridSizer2->Add(itemStaticLine6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
167 
168  wxStdDialogButtonSizer* itemStdDialogButtonSizer7 = new wxStdDialogButtonSizer;
169 
170  itemFlexGridSizer2->Add(itemStdDialogButtonSizer7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
171  wxButton* itemButton8 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
172  itemStdDialogButtonSizer7->AddButton(itemButton8);
173 
174  wxButton* itemButton9 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
175  itemStdDialogButtonSizer7->AddButton(itemButton9);
176 
177  itemStdDialogButtonSizer7->Realize();
178 
179  itemFlexGridSizer2->AddGrowableRow(1);
180  itemFlexGridSizer2->AddGrowableCol(0);
181 
182 ////@end CFeatureCheckDialog content construction
183  //m_Panel->SetFocus();
184 }
185 
186 
187 /*!
188  * Should we show tooltips?
189  */
190 
192 {
193  return true;
194 }
195 
196 /*!
197  * Get bitmap resources
198  */
199 
200 wxBitmap CFeatureCheckDialog::GetBitmapResource( const wxString& name )
201 {
202  // Bitmap retrieval
203 ////@begin CFeatureCheckDialog bitmap retrieval
204  wxUnusedVar(name);
205  return wxNullBitmap;
206 ////@end CFeatureCheckDialog bitmap retrieval
207 }
208 
209 /*!
210  * Get icon resources
211  */
212 
213 wxIcon CFeatureCheckDialog::GetIconResource( const wxString& name )
214 {
215  // Icon retrieval
216 ////@begin CFeatureCheckDialog icon retrieval
217  wxUnusedVar(name);
218  return wxNullIcon;
219 ////@end CFeatureCheckDialog icon retrieval
220 }
221 
223 {
224  ((CFeatureCheckPanel*)m_Panel)->GetSelected(feat_types);
225 }
226 
228 {
229  ((CFeatureCheckPanel*)m_Panel)->SetSelected(feat_types);
230 }
231 
232 void CFeatureCheckDialog::SetRegistryPath(const string & rpath)
233 {
234  m_RegPath = rpath;
235 }
236 
238 {
239  // restore state
240  x_Serialize(true);
241 
242  int action = wxDialog::ShowModal();
243 
244  if (action == wxID_OK ) {
245  x_Serialize(false);
246  }
247 
248  return action;
249 }
250 
252 {
253  if (!m_RegPath.empty()) {
255 
257 
258  if (bRead){
259  CRegistryReadView view = gui_reg.GetReadView(m_RegPath);
260  if (view.HasField(kSelectedNodes)) {
262  }
263  if (view.HasField(kExpandedNodes)) {
264  view.GetStringVec(kExpandedNodes, expand);
265  }
266  }
267 
268  ((CFeatureCheckPanel*)m_Panel)->AccessState(check, expand, bRead);
269 
270  if (!bRead) {
271  CRegistryWriteView view = gui_reg.GetWriteView(m_RegPath);
272  view.Set(kSelectedNodes, check);
273  view.Set(kExpandedNodes, expand);
274  }
275  }
276 }
277 
278 
279 
280 /*!
281  * wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN event handler for ID_SEARCHCTRL
282  */
283 
285 {
286  m_Panel->Filter(ToStdString(m_Filter->GetValue()));
287 ////@begin wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN event handler for ID_SEARCHCTRL in CFeatureCheckDialog.
288  // Before editing this code, remove the block markers.
289  event.Skip();
290 ////@end wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN event handler for ID_SEARCHCTRL in CFeatureCheckDialog.
291 }
292 
293 
294 /*!
295  * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHCTRL
296  */
297 
298 void CFeatureCheckDialog::OnSearchctrlTextUpdated( wxCommandEvent& event )
299 {
300  m_Panel->Filter(ToStdString(m_Filter->GetValue()));
301 ////@begin wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHCTRL in CFeatureCheckDialog.
302  // Before editing this code, remove the block markers.
303  event.Skip();
304 ////@end wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHCTRL in CFeatureCheckDialog.
305 }
306 
void OnSearchctrlSearchButtonClick(wxCommandEvent &event)
wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN event handler for ID_SEARCHCTRL
void Init()
Initialises member variables.
static bool ShowToolTips()
Should we show tooltips?
void SetRegistryPath(const string &rpath)
void GetSelected(TFeatTypeItemSet &feat_types)
CFeatureCheckDialog()
Constructors.
void OnSearchctrlTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHCTRL
bool Create(wxWindow *parent, wxWindowID id=ID_CFEATURECHECKDIALOG, const wxString &caption=_("Select Feature Types"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void SetSelected(TFeatTypeItemSet &feat_types)
CFeatureCheckPanel * m_Panel
void CreateControls()
Creates the controls and sizers.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void x_Serialize(bool bRead=true)
vector< string > TStateVector
CRegistryWriteView GetWriteView(const string &section)
get a read-write view at a particular level.
Definition: registry.cpp:462
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
CRegistryReadView GetReadView(const string &section) const
get a read-only view at a particular level.
Definition: registry.cpp:428
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
bool HasField(const string &key) const
Does a field with this section and key exist in this view?
Definition: reg_view.cpp:352
void GetStringVec(const string &key, vector< string > &val) const
Definition: reg_view.cpp:263
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
#define _(proto)
Definition: ct_nlmzip_i.h:78
static const char * kSelectedNodes
static const char * kExpandedNodes
static void Init(void)
Definition: cursor6.c:76
#define check(s)
Definition: describecol2.c:21
#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()
const struct ncbi::grid::netcache::search::fields::SIZE size
#define ID_SEARCHCTRL
static static static wxID_ANY
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Fri Sep 20 14:58:04 2024 by modify_doxy.py rev. 669887