NCBI C++ ToolKit
macro_panel_loader.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_EDIT___MACRO_PANEL_LOADER__HPP
2 #define GUI_WIDGETS_EDIT___MACRO_PANEL_LOADER__HPP
3 
4 /* $Id: macro_panel_loader.hpp 46715 2021-09-13 18:09:36Z asztalos $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Authors: Vladislav Evgeniev
30 */
31 
32 #include <string>
33 #include <vector>
34 #include <map>
35 #include <wx/window.h>
36 #include <wx/panel.h>
37 #include <wx/event.h>
38 
41 
42 class wxControl;
43 class wxListBox;
44 class wxRadioBox;
45 class wxRadioButton;
46 class wxTextCtrl;
47 class wxCheckBox;
48 class wxComboBox;
49 class wxChoice;
50 class wxCheckListBox;
51 class wxChoice;
52 class wxButton;
53 class wxToggleButton;
54 class wxStaticText;
55 
57 
58 enum class ECustomPanelType
59 {
75 };
76 
78  : public wxEvtHandler
79  , public ISubscriberT<bool>
80 {
81 public:
83 
84  static void Initialize();
85 
86  CMacroPanelLoader(wxWindow *parent, const string &panel_name, const TArgumentsVector &arguments);
87 
88  /// Initialize controls with a list of values
89  void SetControlValues(const string &ctrl_name, const vector<string> &values);
90  void SetSelection(const string &ctrl_name, int n);
91 
92  wxPanel* GetPanel() { return m_Panel; }
93  const CArgumentList& GetArgumentList() const { return m_Arguments; }
94  CArgumentList& SetArgumentList() { return m_Arguments; }
95 
96  bool TransferDataFromPanel();
97  bool TransferDataToPanel();
98 
99  wxPanel* LoadCustomPanel(ECustomPanelType type);
100  static bool s_IsTablePanel(ECustomPanelType& type);
101 protected:
102  void OnComboBoxSelectionChanged(wxCommandEvent& event);
103  void OnChoiceSelectionChanged(wxCommandEvent& event);
104  void OnTextCtrlTextChanged(wxCommandEvent& event);
105  void OnListBoxSelectionChanged(wxCommandEvent& event);
106  void OnRadioBoxClicked(wxCommandEvent& event);
107  void OnRadiobuttonClicked(wxCommandEvent& event);
108  void OnButtonClicked(wxCommandEvent& event);
109  void OnToggleButtonClicked(wxCommandEvent& event);
110  void OnCheckBoxClicked(wxCommandEvent& event);
111  void OnCheckListBoxSelectionChanged(wxCommandEvent& event);
112 
113  void Update(const bool& value);
114 
115 protected:
116  void BindEvents(wxControl& ctrl);
117  wxControl& FindControl(const string &name);
118  void Initialize(wxListBox &list_box, const vector<string> &values);
119  void Initialize(wxRadioBox &radio_box, const vector<string> &values);
120  void Initialize(wxTextCtrl &txt_ctrl, const vector<string> &values);
121  void Initialize(wxComboBox &combo_box, const vector<string> &values);
122  void Initialize(wxCheckListBox& chlist_box, const vector<string>& values);
123  void Initialize(wxChoice& choice, const vector<string>& values);
124  void Initialize(wxStaticText& st_text, const vector<string>& values);
125 
126  bool GetCtrlValue(TStdStringPublisher &value, const wxTextCtrl &txt_ctrl);
127  bool GetCtrlValue(TStdStringPublisher &value, const wxListBox &lst_box);
128  bool GetCtrlValue(TStdStringPublisher &value, const wxCheckListBox &chklist_box);
129  bool GetCtrlValue(TStdStringPublisher &value, const wxRadioBox &radio_box);
130  bool GetCtrlValue(TStdStringPublisher &value, const wxRadioButton &radio_btn);
131  bool GetCtrlValue(TStdStringPublisher &value, const wxCheckBox &chk_box);
132  bool GetCtrlValue(TStdStringPublisher &value, const wxComboBox &combo_box);
133  bool GetCtrlValue(TStdStringPublisher &value, const wxChoice &choice);
134 
135  bool SetCtrlValue(const TStdStringPublisher &value, wxTextCtrl &txt_ctrl);
136  bool SetCtrlValue(const TStdStringPublisher &value, wxListBox &lst_box);
137  bool SetCtrlValue(const TStdStringPublisher &value, wxCheckListBox &chklist_box);
138  bool SetCtrlValue(const TStdStringPublisher &value, wxRadioBox &radio_box);
139  bool SetCtrlValue(const TStdStringPublisher &value, wxRadioButton &radio_btn);
140  bool SetCtrlValue(const TStdStringPublisher &value, wxCheckBox &chk_box);
141  bool SetCtrlValue(const TStdStringPublisher &value, wxComboBox &combo_box);
142  bool SetCtrlValue(const TStdStringPublisher &value, wxChoice &choice);
143 
144  void ToArrayString(const vector<string>& in, wxArrayString& out);
145 
146 private:
147  string x_GetRadioboxSelection(const wxRadioBox& radio_box);
148  string x_GetRadiobuttonSelection(const wxRadioButton& radio_btn);
149  string x_GetCheckboxSelection(const wxCheckBox& chk_box);
150  string x_GetCheckListBoxSelection(const wxCheckListBox& chklist_box);
151 
153  void x_UpdateCtrlsOnRdButtonChange(const string& rdbname);
154  void x_UpdateCtrlsOnChoiceSelChange(const string& choice_name, const string& selected);
155  void x_UpdateCtrlsOnLBoxSelChange(const string& lstbox_name, const string& selected);
156 
159  wxPanel* m_Panel{ nullptr };
160  static bool m_Initialized;
162 };
163 
165 
166 #endif // GUI_WIDGETS_EDIT___MACRO_PANEL_LOADER__HPP
map< string, wxControl * > m_Controls
const CArgumentList & GetArgumentList() const
CArgumentList & SetArgumentList()
void x_UpdateBsrcPanelControls()
virtual void Update(const T &value)=0
std::ofstream out("events_result.xml")
main entry point for tests
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_EDIT_EXPORT
Definition: gui_export.h:526
yy_size_t n
@ eApplyMolinfoQualTable
vector< macro::SArgMetaData > TArgumentsVector
ECustomPanelType
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
std::istream & in(std::istream &in_, double &x_)
Definition: type.c:6
void ToArrayString(const vector< string > &out, wxArrayString &in)
Definition: wx_utils.cpp:353
Modified on Wed Sep 04 15:03:09 2024 by modify_doxy.py rev. 669887