libaurum: apply smart pointer wider and extract impl out
[platform/core/uifw/aurum.git] / libaurum / src / Accessibility / AccessibleNode.cc
1 #include "AccessibleNode.h"
2 #include <string.h>
3 #include <iostream>
4 #include <vector>
5
6 #include <loguru.hpp>
7 #include "config.h"
8
9
10 AccessibleNode::~AccessibleNode()
11 {
12 }
13
14 AccessibleNode::AccessibleNode()
15     : mText{""}, mPkg{""}, mRole{""}, mRes{""}, mType{""}, mStyle{""},
16       mBoundingBox{0,0,0,0}, mSupportingIfaces(0), mFeatureProperty(0)
17 {
18 }
19
20 void AccessibleNode::print(int depth, int maxDepth)
21 {
22     if (maxDepth <= 0 || depth > maxDepth) return;
23
24     this->print(depth);
25     auto children = this->getChildren();
26     for ( auto &child : children ) {
27         if (child) child->print(depth +1, maxDepth);
28     }
29 }
30
31 void AccessibleNode::print(int d)
32 {
33     this->refresh();
34     LOG_F(INFO, "%s - %p(%s)  /  pkg:%s, text:%s",
35           std::string(d, ' ').c_str(), getRawHandler(), getText().c_str(),
36           getPkg().c_str(), getText().c_str());
37 }
38
39 bool AccessibleNode::isSupporting(AccessibleNodeInterface thisIface) const
40 {
41     return (mSupportingIfaces & static_cast<int>(thisIface)) != 0;
42 }
43
44 bool AccessibleNode::hasFeatureProperty(NodeFeatureProperties prop) const
45 {
46     return (mFeatureProperty & static_cast<int>(prop)) != 0;
47 }
48
49 void AccessibleNode::setFeatureProperty(NodeFeatureProperties prop, bool has)
50 {
51     if (has)
52         mFeatureProperty |= static_cast<int>(prop);
53     else
54         mFeatureProperty &= ~static_cast<int>(prop);
55 }
56
57
58 std::string AccessibleNode::getText() const
59 {
60     return mText;
61 }
62
63 std::string AccessibleNode::getPkg() const
64 {
65     return mPkg;
66 }
67
68 std::string AccessibleNode::getRes() const
69 {
70     return mRes;
71 }
72
73 std::string AccessibleNode::getRole() const
74 {
75     return mRole;
76 }
77
78 std::string AccessibleNode::getType() const
79 {
80     return mType;
81 }
82
83 std::string AccessibleNode::getStyle() const
84 {
85     return mStyle;
86 }
87
88 Rect<int> AccessibleNode::getBoundingBox() const
89 {
90     return mBoundingBox;
91 }
92
93 bool AccessibleNode::isCheckable() const
94 {
95     return hasFeatureProperty(NodeFeatureProperties::CHECKABLE);
96 }
97
98 bool AccessibleNode::isChecked() const
99 {
100     return hasFeatureProperty(NodeFeatureProperties::CHECKED);
101 }
102
103 bool AccessibleNode::isClickable() const
104 {
105     return hasFeatureProperty(NodeFeatureProperties::CLICKABLE);
106 }
107
108 bool AccessibleNode::isEnabled() const
109 {
110     return hasFeatureProperty(NodeFeatureProperties::ENABLED);
111 }
112
113 bool AccessibleNode::isFocusable() const
114 {
115     return hasFeatureProperty(NodeFeatureProperties::FOCUSABLE);
116 }
117
118 bool AccessibleNode::isFocused() const
119 {
120     return hasFeatureProperty(NodeFeatureProperties::FOCUSED);
121 }
122
123 bool AccessibleNode::isLongClickable() const
124 {
125     return hasFeatureProperty(NodeFeatureProperties::LONGCLICKABLE);
126 }
127
128 bool AccessibleNode::isScrollable() const
129 {
130     return hasFeatureProperty(NodeFeatureProperties::SCROLLABLE);
131 }
132
133 bool AccessibleNode::isSelectable() const
134 {
135     return hasFeatureProperty(NodeFeatureProperties::SELECTABLE);
136 }
137
138 bool AccessibleNode::isSelected() const
139 {
140     return hasFeatureProperty(NodeFeatureProperties::SELECTED);
141 }
142
143 bool AccessibleNode::isVisible() const
144 {
145     return hasFeatureProperty(NodeFeatureProperties::VISIBLE);
146 }
147
148 bool AccessibleNode::isShowing() const
149 {
150     return hasFeatureProperty(NodeFeatureProperties::SHOWING);
151 }
152
153 bool AccessibleNode::isActive() const
154 {
155     return hasFeatureProperty(NodeFeatureProperties::ACTIVE);
156 }