merge with master
[platform/framework/native/uifw.git] / src / ui / FUiCustomControlBase.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 /**
19  * @file        FUiCustomControlBase.cpp
20  * @brief       This is the implementation for the CustomControlBase class.
21  */
22
23 #include <FUiCustomControlBase.h>
24 #include <FUiLayout.h>
25 #include <FBaseSysLog.h>
26 #include "FUi_CustomControlBaseImpl.h"
27 #include "FUi_ErrorMessages.h"
28
29 using namespace Tizen::Graphics;
30
31 namespace Tizen { namespace Ui {
32
33 CustomControlBase::CustomControlBase()
34 {
35 }
36
37 CustomControlBase::~CustomControlBase()
38 {
39 }
40
41 result
42 CustomControlBase::Construct(const Rectangle& rect, bool resizable, bool movable)
43 {
44         result r = E_SUCCESS;
45         SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
46
47         _CustomControlBaseImpl* pImpl = _CustomControlBaseImpl::CreateCustomControlBaseImplN(this, rect, null, null, resizable, movable);
48         r = GetLastResult();
49         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
50
51         _pControlImpl = pImpl;
52
53         return E_SUCCESS;
54 }
55
56 result
57 CustomControlBase::Construct(const Layout& layout, const Rectangle& rect, bool resizable, bool movable)
58 {
59         return Construct(layout, layout, rect, resizable, movable);
60 }
61
62 result
63 CustomControlBase::Construct(const Layout& portraitLayout, const Layout& landscapeLayout,
64                                                          const Rectangle& rect, bool resizable, bool movable)
65 {
66         result r = E_SUCCESS;
67         SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
68
69         _CustomControlBaseImpl* pImpl =
70                 _CustomControlBaseImpl::CreateCustomControlBaseImplN(this, rect, &portraitLayout, &landscapeLayout, resizable, movable);
71
72         r = GetLastResult();
73         SysTryReturn(NID_UI, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
74
75
76         _pControlImpl = pImpl;
77
78         return E_SUCCESS;
79 }
80
81 result
82 CustomControlBase::PrepareBoundsChange(const Rectangle& oldRect, const Rectangle& newRect)
83 {
84         return E_SUCCESS;
85 }
86
87 bool
88 CustomControlBase::EvaluateSize(int& width, int& height)
89 {
90         return true;
91 }
92
93 }} // Tizen::Ui