File: attribute_style.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (78 lines) | stat: -rw-r--r-- 2,372 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "attribute_style.h"

StyleProperty::StyleProperty(int id,
                             const wxString& fgColour,
                             const wxString& bgColour,
                             const int fontSize,
                             const wxString& name,
                             const wxString& face,
                             bool bold,
                             bool italic,
                             bool underline,
                             bool eolFilled,
                             int alpha)
    : m_id(id)
    , m_fgColour(fgColour)
    , m_bgColour(bgColour)
    , m_fontSize(fontSize)
    , m_name(name)
    , m_faceName(face)
    , m_flags(0)
    , m_alpha(alpha)
{
    EnableFlag(kBold, bold);
    EnableFlag(kItalic, italic);
    EnableFlag(kUnderline, underline);
    EnableFlag(kEolFilled, eolFilled);
}

StyleProperty::StyleProperty()
    : m_id(0)
    , m_fgColour(_T("BLACK"))
    , m_bgColour(_T("WHITE"))
    , m_fontSize(10)
    , m_name(wxEmptyString)
    , m_faceName(_T("Courier"))
    , m_flags(0)
    , m_alpha(0)
{
}

StyleProperty& StyleProperty::operator=(const StyleProperty& rhs)
{
    m_fgColour = rhs.m_fgColour;
    m_bgColour = rhs.m_bgColour;
    m_faceName = rhs.m_faceName;
    m_fontSize = rhs.m_fontSize;
    m_name = rhs.m_name;
    m_id = rhs.m_id;
    m_alpha = rhs.m_alpha;
    m_flags = rhs.m_flags;
    return *this;
}

void StyleProperty::FromJSON(JSONElement json)
{
    m_id = json.namedObject("Id").toInt(0);
    m_name = json.namedObject("Name").toString("DEFAULT");
    m_flags = json.namedObject("Flags").toSize_t(0);
    m_alpha = json.namedObject("Alpha").toInt(50);
    m_faceName = json.namedObject("Face").toString("Courier");
    m_fgColour = json.namedObject("Colour").toString("BLACK");
    m_bgColour = json.namedObject("BgColour").toString("WHITE");
    m_fontSize = json.namedObject("Size").toInt(10);
}

JSONElement StyleProperty::ToJSON() const
{
    JSONElement json = JSONElement::createObject();
    json.addProperty("Id", GetId());
    json.addProperty("Name", GetName());
    json.addProperty("Flags", m_flags);
    json.addProperty("Alpha", GetAlpha());
    json.addProperty("Face", GetFaceName());
    json.addProperty("Colour", GetFgColour());
    json.addProperty("BgColour", GetBgColour());
    json.addProperty("Size", GetFontSize());
    return json;
}