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