Tizen 2.1 base
[framework/osp/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 Flora License, Version 1.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://floralicense.org/license/
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 <FBaseInteger.h>
25 #include "FUi_UiBuilder.h"
26 #include "FUi_UiBuilderControlLayout.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         int intX = 0, intY = 0, intWidth = 0, intHeight = 0;
53
54         if (x.IsEmpty() == false)
55         {
56                 Base::Integer::Parse(x, intX);
57         }
58         if (y.IsEmpty() == false)
59         {
60                 Base::Integer::Parse(y, intY);
61         }
62         if (width.IsEmpty() == false)
63         {
64                 Base::Integer::Parse(width, intWidth);
65         }
66         if (height.IsEmpty() == false)
67         {
68                 Base::Integer::Parse(height, intHeight);
69         }
70
71         _rect.x = intX;
72         _rect.y = intY;
73         _rect.width = intWidth;
74         _rect.height = intHeight;
75 }
76
77 void
78 _UiBuilderControlLayout::SetRect(const int x, const int y, const int width, const int height)
79 {
80         _rect.x = x;
81         _rect.y = y;
82         _rect.width = width;
83         _rect.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 const_cast<Tizen::Graphics::Rectangle&>(_rect);
96 }
97
98 void
99 _UiBuilderControlLayout::SetLayoutElement(int index, const Tizen::Base::String& name, const Tizen::Base::String& value)
100 {
101         if (index >= UIBUILDER_CONTROL_ELEMENT_NUMBER)
102         {
103                 return;
104         }
105
106         _layoutElement[index].SetName(name);
107         _layoutElement[index].SetValue(value);
108
109 }
110
111 bool
112 _UiBuilderControlLayout::GetLayoutElement(const Tizen::Base::String& layoutElementName, Tizen::Base::String& outValue) const
113 {
114         int index = 0;
115         while (layoutElementName.IsEmpty() == false && index < UIBUILDER_CONTROL_ELEMENT_NUMBER)
116         {
117                 if (layoutElementName.Equals(_layoutElement[index].GetName(), false))
118                 {
119                         if (_layoutElement[index].GetValue().IsEmpty() == false)
120                         {
121                                 outValue = _layoutElement[index].GetValue();
122                                 return true;
123                         }
124                         else
125                         {
126                                 return false;
127                         }
128                 }
129                 else
130                 {
131                         index++;
132                 }
133         }
134
135         return false;
136 }
137
138 } }  // Tizen::Ui