Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUi_CustomControlBaseImpl.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 /**
19  * @file        FUi_CustomControlBaseImpl.cpp
20  * @brief       This is the implementation for the _CustomControlBaseImpl class and default transformer.
21  */
22
23 #include <FBaseSysLog.h>
24 #include "FUi_LayoutImpl.h"
25 #include "FUi_CustomControlBaseImpl.h"
26 #include "FUi_Control.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Graphics;
31
32 namespace Tizen { namespace Ui
33 {
34
35 _CustomControlBaseImpl::~_CustomControlBaseImpl(void)
36 {
37 }
38
39 _CustomControlBaseImpl*
40 _CustomControlBaseImpl::CreateCustomControlBaseImplN(CustomControlBase* pPublic, const Rectangle& bounds,
41                                                                                 const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout,
42                                                                                 bool resizable, bool movable)
43 {
44         result r = E_SUCCESS;
45
46         _Control* pCore = _Control::CreateControlN();
47         SysTryReturn(NID_UI, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
48
49         _CustomControlBaseImpl* pImpl =
50                 new (std::nothrow) _CustomControlBaseImpl(pPublic, pCore, bounds,
51                                                                                                   pPublicPortraitLayout, pPublicLandscapeLayout,
52                                                                                                   resizable, movable);
53         r = CheckConstruction(pCore, pImpl);
54         SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
55
56         ClearLastResult();
57
58         return pImpl;
59 }
60
61 _CustomControlBaseImpl::_CustomControlBaseImpl(CustomControlBase* pCustomControlBase, _Control* pCore, const Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable)
62         : _ContainerImpl(pCustomControlBase, pCore, pPublicPortraitLayout, pPublicLandscapeLayout)
63 {
64         result r = E_SUCCESS;
65
66         r = GetLastResult();
67         if (IsFailed(r))
68         {
69                 return;
70         }
71
72         bool allOrNone = (pPublicPortraitLayout && pPublicLandscapeLayout) || (!pPublicPortraitLayout && !pPublicLandscapeLayout);
73         SysAssert(allOrNone);
74
75         r = SetBounds(bounds);
76         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
77
78         pCore->SetResizable(resizable);
79         pCore->SetMovable(movable);
80 }
81
82 const char*
83 _CustomControlBaseImpl::GetPublicClassName(void) const
84 {
85         return "Tizen::Ui::CustomControlBase";
86 }
87
88 const CustomControlBase&
89 _CustomControlBaseImpl::GetPublic(void) const
90 {
91         return static_cast <const CustomControlBase&>(_ControlImpl::GetPublic());
92 }
93
94 CustomControlBase&
95 _CustomControlBaseImpl::GetPublic(void)
96 {
97         return static_cast <CustomControlBase&>(_ControlImpl::GetPublic());
98 }
99
100 _CustomControlBaseImpl*
101 _CustomControlBaseImpl::GetInstance(CustomControlBase& pCustomControlBase)
102 {
103         return static_cast<_CustomControlBaseImpl*>(pCustomControlBase._pControlImpl);
104 }
105
106 const _CustomControlBaseImpl*
107 _CustomControlBaseImpl::GetInstance(const CustomControlBase& pCustomControlBase)
108 {
109         return static_cast<const _CustomControlBaseImpl*>(pCustomControlBase._pControlImpl);
110
111 }
112
113
114 result
115 _CustomControlBaseImpl::OnBoundsChanging(const Rectangle& bounds)
116 {
117         __oldBounds = GetBounds();
118         return GetPublic().PrepareBoundsChange(__oldBounds, bounds);
119 }
120
121 void
122 _CustomControlBaseImpl::OnBoundsChanged(void)
123 {
124         GetPublic().OnBoundsChanged(__oldBounds, GetBounds());
125 }
126
127 void
128 _CustomControlBaseImpl::OnEvaluateSize(Dimension& evaluatedSize)
129 {
130         GetPublic().EvaluateSize(evaluatedSize.width, evaluatedSize.height);
131 }
132
133 }} // Tizen::Ui