Debian Codegraph @

plugins/dm.objectives/ce/SpecifierEditCombo.h

raw
1 #pragma once
2
3 #include <wx/panel.h>
4 #include "../Specifier.h"
5 #include "specpanel/SpecifierPanel.h"
6
7 class wxChoice;
8
9 namespace objectives
10 {
11
12 namespace ce
13 {
14
15 /**
16 * Compound widget for changing specifier types and editing their values.
17 *
18 * A SpecifierEditCombo is a horizontal box containing two main elements. On the
19 * left is a ComboBox which contains the names of a number of different
20 * SpecifierType types, and on the right is a SpecifierPanel which is switched
21 * depending on the selected dropdown value. The SpecifierEditCombo therefore
22 * provides a means for the user to choose both a SpecifierType and its
23 * associated value.
24 *
25 * Since some Component types accept a different subset of the SpecifierType types,
26 * the SpecifierEditCombo can accept a std::set of SpecifierType types to display
27 * in its dropdown list. Alternatively the entire set of Specifiers can be
28 * made available.
29 */
30 class SpecifierEditCombo :
31 public wxPanel
32 {
33 private:
34 // Current SpecifierPanel
35 SpecifierPanelPtr _specPanel;
36
37 // Combo box containing Specifiers
38 wxChoice* _specifierCombo;
39
40 std::function<void()> _valueChanged;
41
42 private:
43
44 // Get the selected SpecifierType string
45 std::string getSpecName() const;
46
47 // Create the SpecifierPanel for the given specifier type
48 void createSpecifierPanel(const std::string& type);
49
50 // callback
51 void _onChange(wxCommandEvent& ev);
52
53 public:
54
55 /**
56 * Construct a SpecifierEditCombo with a subset of SpecifierType types
57 * available.
58 *
59 * @param set
60 * A SpecifierSet containing the subset of Specifiers which should be
61 * displayed in this edit combo. The default is the complete set of
62 * specifiers.
63 *
64 * @param valueChanged:
65 * A callback to be invoked when the edit combo (either type or argument) changes.
66 */
67 SpecifierEditCombo(wxWindow* parent, const std::function<void()>& valueChanged,
68 const SpecifierTypeSet& set = SpecifierType::SET_ALL());
69
70 /**
71 * Return the current value of the Specifier (type and value).
72 *
73 * @return
74 * A Specifier containing the type and value of the Specifier as currently
75 * shown by the edit widgets.
76 */
77 SpecifierPtr getSpecifier() const;
78
79 /**
80 * Set the Specifier to display in the ComboBox.
81 *
82 * @param
83 * A Specifier containing the type and value to be displayed in the edit
84 * widgets.
85 */
86 void setSpecifier(SpecifierPtr spec);
87 };
88
89 }
90
91 }