Debian Codegraph @

wxcrafter/src/int_property.cpp

raw
1 #include "int_property.h"
2
3 IntProperty::IntProperty(const wxString& label, int value, const wxString& tooltip)
4 : PropertyBase(tooltip)
5 , m_value(value)
6 , m_uninitialized(false)
7 {
8 SetLabel(label);
9 }
10
11 IntProperty::IntProperty(const wxString& label, const wxString& tooltip)
12 : PropertyBase(tooltip)
13 , m_value(-1)
14 , m_uninitialized(true)
15 {
16 SetLabel(label);
17 }
18
19 IntProperty::~IntProperty() {}
20
21 PropertyeType IntProperty::GetType() { return PT_INT; }
22
23 wxString IntProperty::GetValue() const
24 {
25 wxString v;
26 v << m_value;
27 return v;
28 }
29
30 JSONElement IntProperty::Serialize() const
31 {
32 JSONElement json = JSONElement::createObject();
33 json.addProperty(wxT("type"), wxT("integer"));
34 DoBaseSerialize(json);
35 json.addProperty(wxT("m_value"), m_value);
36 return json;
37 }
38
39 void IntProperty::SetValue(const wxString& value)
40 {
41 long i(-1);
42 if(value.ToLong(&i)) {
43 m_value = i;
44 } else {
45 m_value = -1;
46 }
47 }
48
49 void IntProperty::UnSerialize(const JSONElement& json)
50 {
51 DoBaseUnSerialize(json);
52 m_value = json.namedObject(wxT("m_value")).toInt();
53 }