Debian Codegraph @

plugins/dm.objectives/ce/LocationComponentEditor.cpp

raw
1 #include "LocationComponentEditor.h"
2 #include "../SpecifierType.h"
3 #include "../Component.h"
4
5 #include "i18n.h"
6 #include <wx/stattext.h>
7
8 namespace objectives
9 {
10
11 namespace ce
12 {
13
14 // Registration helper, will register this editor in the factory
15 LocationComponentEditor::RegHelper LocationComponentEditor::regHelper;
16
17 // Constructor
18 LocationComponentEditor::LocationComponentEditor(wxWindow* parent, Component& component) :
19 ComponentEditorBase(parent),
20 _component(&component),
21 _entSpec(new SpecifierEditCombo(_panel, getChangeCallback())),
22 _locationSpec(new SpecifierEditCombo(_panel, getChangeCallback(), SpecifierType::SET_LOCATION()))
23 {
24 wxStaticText* label = new wxStaticText(_panel, wxID_ANY, _("Entity:"));
25 label->SetFont(label->GetFont().Bold());
26
27 _panel->GetSizer()->Add(label, 0, wxBOTTOM | wxEXPAND, 6);
28 _panel->GetSizer()->Add(_entSpec, 0, wxBOTTOM | wxEXPAND, 6);
29
30 label = new wxStaticText(_panel, wxID_ANY, _("Location:"));
31 label->SetFont(label->GetFont().Bold());
32
33 _panel->GetSizer()->Add(label, 0, wxBOTTOM | wxEXPAND, 6);
34 _panel->GetSizer()->Add(_locationSpec, 0, wxBOTTOM | wxEXPAND, 6);
35
36 // Populate the SpecifierEditCombo with the first specifier
37 _entSpec->setSpecifier(
38 component.getSpecifier(Specifier::FIRST_SPECIFIER)
39 );
40
41 _locationSpec->setSpecifier(
42 component.getSpecifier(Specifier::SECOND_SPECIFIER)
43 );
44 }
45
46 // Write to component
47 void LocationComponentEditor::writeToComponent() const
48 {
49 if (!_active) return; // still under construction
50
51 assert(_component);
52 _component->setSpecifier(
53 Specifier::FIRST_SPECIFIER, _entSpec->getSpecifier()
54 );
55
56 _component->setSpecifier(
57 Specifier::SECOND_SPECIFIER, _locationSpec->getSpecifier()
58 );
59
60 _component->clearArguments();
61 }
62
63 } // namespace ce
64
65 } // namespace objectives