Debian Codegraph @

plugins/dm.stimresponse/CustomStimEditor.h

raw
1 #pragma once
2
3 #include "StimTypes.h"
4 #include "SREntity.h"
5 #include <wx/event.h>
6 #include "wxutil/dataview/TreeModelFilter.h"
7 #include "wxutil/dataview/TreeView.h"
8 #include <memory>
9
10 class wxPanel;
11 class wxTextCtrl;
12 class wxStaticText;
13 class wxButton;
14 class wxMenu;
15 class wxMenuItem;
16 class wxBoxSizer;
17
18 namespace ui
19 {
20
21 class CustomStimEditor :
22 public wxEvtHandler
23 {
24 struct PropertyWidget
25 {
26 wxPanel* vbox;
27 wxStaticText* nameLabel;
28 wxTextCtrl* nameEntry;
29 } _propertyWidgets;
30
31 struct ListContextMenu {
32 std::unique_ptr<wxMenu> menu;
33 wxMenuItem* remove;
34 wxMenuItem* add;
35 } _contextMenu;
36
37 struct ListButtons
38 {
39 wxButton* add;
40 wxButton* remove;
41 } _listButtons;
42
43 // The filtered liststore
44 wxutil::TreeModelFilter::Ptr _customStimStore;
45
46 // The treeview and its selection
47 wxutil::TreeView* _list;
48
49 // Reference to the helper object (owned by StimResponseEditor)
50 StimTypes& _stimTypes;
51
52 // To avoid GTK callback loops
53 bool _updatesDisabled;
54
55 // The entity we're working on
56 SREntityPtr _entity;
57
58 public:
59 /** greebo: Constructor creates all the widgets
60 */
61 CustomStimEditor(wxWindow* parent, StimTypes& stimTypes);
62
63 /** greebo: Sets the new entity (is called by the subclasses)
64 */
65 void setEntity(const SREntityPtr& entity);
66
67 private:
68 /** greebo: Updates the property widgets on selection change
69 */
70 void update();
71
72 /** greebo: Returns the ID of the currently selected stim type
73 *
74 * @returns: the id (number) of the selected stim or -1 on failure
75 */
76 int getIdFromSelection();
77
78 /** greebo: Selects the given ID in the stim type list
79 */
80 void selectId(int id);
81
82 /** greebo: Adds/removes a (selected) stim type
83 */
84 void addStimType();
85 void removeStimType();
86
87 /** greebo: Widget creators
88 */
89 void createContextMenu();
90 wxBoxSizer* createListButtons(wxWindow* parent);
91
92 /** greebo: Creates all the widgets
93 */
94 void populatePage(wxWindow* parent);
95
96 // Callbacks
97 void onAddStimType(wxCommandEvent& ev);
98 void onRemoveStimType(wxCommandEvent& ev);
99 void onEntryChanged(wxCommandEvent& ev);
100 void onSelectionChange(wxDataViewEvent& ev);
101 void onContextMenu(wxDataViewEvent& ev);
102
103 void onContextMenuAdd(wxCommandEvent& ev);
104 void onContextMenuDelete(wxCommandEvent& ev);
105 };
106
107 } // namespace ui