Debian Codegraph @

plugins/dm.objectives/ce/ComponentEditor.h

raw
1 #pragma once
2
3 #include <memory>
4
5 class wxWindow;
6
7 namespace objectives
8 {
9
10 class Component;
11
12 namespace ce
13 {
14
15 /**
16 * \namespace objectives::ce
17 * ComponentEditor subclasses for the ComponentsDialog.
18 *
19 * \ingroup objectives
20 */
21
22 /* FORWARD DECLS */
23 class ComponentEditor;
24
25 /**
26 * Shared pointer type for ComponentEditor subclasses.
27 */
28 typedef std::shared_ptr<ComponentEditor> ComponentEditorPtr;
29
30 /**
31 * Interface for component editors.
32 *
33 * A component editor is a GtkWidget containing additional widgets which are
34 * designed to adjust the properties for a particular objective Component type,
35 * such as "KILL" or "LOCATION". The ComponentsDialog will select an appropriate
36 * ComponentEditor based on the chosen component type, and pack it into a
37 * dedicated area in the dialog.
38 */
39 class ComponentEditor
40 {
41 public:
42 /**
43 * Destructor
44 */
45 virtual ~ComponentEditor() {}
46
47 /**
48 * Return a wxWidget for packing into the parent dialog.
49 *
50 * The top-level widget returned by getWxWidget() is owned by the
51 * ComponentEditor, and will be destroyed via Destroy() when the
52 * the ComponentEditor's destructor is invoked.
53 */
54 virtual wxWindow* getWidget() = 0;
55
56 /**
57 * Create another ComponentEditor of the same subclass type as this one.
58 * This is used for virtual construction by the ComponentEditorFactory.
59 *
60 * @param comp
61 * A reference to the Component object that the new ComponentEditor will
62 * display and edit.
63 *
64 * @return
65 * Shared pointer to a ComponentEditor of the same type as this one.
66 */
67 virtual ComponentEditorPtr create(wxWindow* parent, objectives::Component& comp) const = 0;
68
69 /**
70 * Instruct the ComponentEditor to commit its changes to the Component
71 * object.
72 *
73 * This method causes the current data contained within the
74 * ComponentEditor's GTK widgets to be written out to the Component object
75 * passed into the constructor. This method is intended for the owning
76 * dialog (e.g. ComponentsDialog) to invoke when an Apply button is clicked
77 * by the user.
78 */
79 virtual void writeToComponent() const = 0;
80
81 /**
82 * Component editors automatically write their values to the edited component
83 * which can be counter-productive during construction time. Use this method
84 * to activate the internal callbacks and allow the editor to push the values
85 * to the edited component.
86 */
87 virtual void setActive(bool active) = 0;
88
89 };
90
91 } // namespace
92
93 } // namespace