Debian Codegraph @

wxcrafter/src/bool_property.cpp

raw
1 #include "bool_property.h"
2 #include <wx/checkbox.h>
3
4 BoolProperty::BoolProperty(const wxString& label, bool checked, const wxString& tooltip)
5 : PropertyBase(tooltip)
6 , m_value(checked)
7 {
8 SetLabel(label);
9 }
10
11 BoolProperty::BoolProperty()
12 : PropertyBase(wxT(""))
13 {
14 }
15
16 BoolProperty::~BoolProperty() {}
17
18 wxString BoolProperty::GetValue() const
19 {
20 if(m_value) {
21 return wxT("1");
22
23 } else {
24 return wxT("0");
25 }
26 }
27
28 void BoolProperty::SetValue(const wxString& value)
29 {
30 if(value == wxT("1")) {
31 m_value = true;
32 } else {
33 m_value = false;
34 }
35 NotifyChanged();
36 }
37
38 JSONElement BoolProperty::Serialize() const
39 {
40 JSONElement json = JSONElement::createObject();
41 json.addProperty(wxT("type"), wxT("bool"));
42 DoBaseSerialize(json);
43 json.addProperty(wxT("m_value"), m_value);
44 return json;
45 }
46
47 void BoolProperty::UnSerialize(const JSONElement& json)
48 {
49 DoBaseUnSerialize(json);
50 m_value = json.namedObject(wxT("m_value")).toBool();
51 }