Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUi_UiBuilderControlLayout.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18 * @file         FUi_UiBuilderControlLayout.cpp
19 * @brief                This is the implementation file for _UiBuilderControlLayout class.
20 */
21
22 #include <stdlib.h>
23 #include <FBaseSysLog.h>
24 #include "FUi_UiBuilder.h"
25 #include "FUi_UiBuilderControlLayout.h"
26 #include "FUi_CoordinateSystemUtils.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui;
31
32 namespace Tizen { namespace Ui
33 {
34 _UiBuilderControlLayout::_UiBuilderControlLayout(void)
35         : __styleInformation(L"")
36 {
37 }
38
39 _UiBuilderControlLayout::~_UiBuilderControlLayout(void)
40 {
41 }
42
43 void
44 _UiBuilderControlLayout::SetStyle(const Tizen::Base::String& style)
45 {
46         __styleInformation = style;
47 }
48
49 void
50 _UiBuilderControlLayout::SetRect(const Tizen::Base::String& x, const Tizen::Base::String& y, Tizen::Base::String& width, Tizen::Base::String& height)
51 {
52     float floatX = 0.0f, floatY = 0.0f, floatWidth = 0.0f, floatHeight = 0.0f;
53
54         if (x.IsEmpty() == false)
55         {
56              floatX = _CoordinateSystemUtils::ConvertToFloat(x);
57         }
58         if (y.IsEmpty() == false)
59         {
60              floatY = _CoordinateSystemUtils::ConvertToFloat(y);
61         }
62         if (width.IsEmpty() == false)
63         {
64              floatWidth = _CoordinateSystemUtils::ConvertToFloat(width);
65         }
66         if (height.IsEmpty() == false)
67         {
68              floatHeight = _CoordinateSystemUtils::ConvertToFloat(height);
69         }
70
71     __floatRect.x = floatX;
72     __floatRect.y = floatY;
73     __floatRect.width = floatWidth;
74     __floatRect.height = floatHeight;
75 }
76
77 void
78 _UiBuilderControlLayout::SetRect(const float x, const float y, const float width, const float height)
79 {
80         __floatRect.x = x;
81         __floatRect.y = y;
82         __floatRect.width = width;
83         __floatRect.height = height;
84 }
85
86 String
87 _UiBuilderControlLayout::GetStyle(void) const
88 {
89         return __styleInformation;
90 }
91
92 Rectangle
93 _UiBuilderControlLayout::GetRect(void) const
94 {
95     return _CoordinateSystemUtils::ConvertToInteger(__floatRect);
96 }
97
98 FloatRectangle
99 _UiBuilderControlLayout::GetRectF(void) const
100 {
101         return __floatRect;
102 }
103
104
105 void
106 _UiBuilderControlLayout::SetLayoutElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value)
107 {
108         if (index >= UIBUILDER_CONTROL_ELEMENT_NUMBER)
109         {
110                 return;
111         }
112
113         __layoutElement[index].SetName(name);
114         __layoutElement[index].SetValue(value);
115
116 }
117
118 bool
119 _UiBuilderControlLayout::GetLayoutElement(const Tizen::Base::String& layoutElementName, Tizen::Base::String& outValue) const
120 {
121         int index = 0;
122         while (layoutElementName.IsEmpty() == false && index < UIBUILDER_CONTROL_ELEMENT_NUMBER)
123         {
124                 if (layoutElementName.Equals(__layoutElement[index].GetName(), false))
125                 {
126                         if (__layoutElement[index].GetValue().IsEmpty() == false)
127                         {
128                                 outValue = __layoutElement[index].GetValue();
129                                 return true;
130                         }
131                         else
132                         {
133                                 return false;
134                         }
135                 }
136                 else
137                 {
138                         index++;
139                 }
140         }
141
142         return false;
143 }
144
145 } }  // Tizen::Ui