2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
19 * @file FUiCtrl_Panel.cpp
20 * @brief This is the implementation file for the %_Panel class.
24 #include <FBaseErrorDefine.h>
25 #include <FBaseSysLog.h>
26 #include <FGrpBitmap.h>
27 #include <FGrp_BitmapImpl.h>
28 #include "FUi_ResourceManager.h"
29 #include "FUiAnim_VisualElement.h"
30 #include "FUiCtrl_Panel.h"
31 #include "FUi_DataBindingContext.h"
33 using namespace Tizen::Graphics;
34 using namespace Tizen::Ui;
36 namespace Tizen { namespace Ui { namespace Controls
41 , __pPanelPresenter(null)
42 , __groupStyle(GROUP_STYLE_NONE)
43 , __pGroupStyleBitmap(null)
44 , __pGroupStyleBackgroundBitmap(null)
45 , __backgroundBitmapStretch(false)
46 , __backgroundBitmapHorizontalAlign(PANEL_BACKGROUND_BITMAP_HORIZONTAL_ALIGN_CENTER)
47 , __backgroundBitmapVerticalAlign(PANEL_BACKGROUND_BITMAP_VERTICAL_ALIGN_MIDDLE)
48 , __pBackgroundBitmap(null)
55 delete __pBackgroundBitmap;
56 __pBackgroundBitmap = null;
58 delete __pGroupStyleBackgroundBitmap;
59 __pGroupStyleBackgroundBitmap = null;
61 delete __pGroupStyleBitmap;
62 __pGroupStyleBitmap = null;
64 delete __pPanelPresenter;
65 __pPanelPresenter = null;
69 _Panel::CreatePanelN(const Rectangle& rect, GroupStyle groupStyle)
74 _Panel* pPanel = new (std::nothrow) _Panel;
75 SysTryReturn(NID_UI_CTRL, pPanel != null, null, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
77 _PanelPresenter* pPresenter = new (std::nothrow) _PanelPresenter;
78 SysTryCatch(NID_UI_CTRL, pPresenter != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
80 r = pPresenter->Initialize(*pPanel);
81 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
83 r = pPanel->Initialize(*pPresenter);
84 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
86 pPanel->SetGroupStyle(groupStyle);
88 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
90 pPanel->AcquireHandle();
96 pPanel->__pPanelPresenter = null;
105 _Panel::Initialize(const _PanelPresenter& presenter)
109 SetPanelPresenter(&presenter);
111 result r = GetVisualElement()->SetSurfaceOpaque(false);
112 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
114 SetBackgroundColor(Color(0, 0, 0, 0));
116 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
118 // create data binding context
119 _DataBindingContext* pContext = new (std::nothrow) _DataBindingContext(*this);
120 SysTryCatch(NID_UI_CTRL, pContext != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] The memory is insufficient.", GetErrorMessage(E_OUT_OF_MEMORY));
122 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
124 SetDataBindingContext(pContext);
126 SetTouchMoveAllowance(TOUCH_MOVE_ALLOWANCE_NORMAL);
137 _Panel::SetPanelPresenter(const _PanelPresenter* panelPresenter)
141 __pPanelPresenter = const_cast <_PanelPresenter*>(panelPresenter);
151 if (__pPanelPresenter != null)
153 result r = __pPanelPresenter->Draw();
154 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
159 _Panel::SetBackgroundColor(const Tizen::Graphics::Color& color)
163 _Control::SetBackgroundColor(color);
165 if (__groupStyle != GROUP_STYLE_NONE)
172 _Panel::GetGroupStyle(void) const
180 _Panel::SetGroupStyle(GroupStyle groupStyle)
184 if (__groupStyle == groupStyle)
188 __groupStyle = groupStyle;
190 delete __pGroupStyleBackgroundBitmap;
191 __pGroupStyleBackgroundBitmap = null;
193 delete __pGroupStyleBitmap;
194 __pGroupStyleBitmap = null;
196 result r = E_SUCCESS;
197 switch (__groupStyle)
199 case GROUP_STYLE_TOP:
200 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_TOP_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap);
201 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
202 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_TOP_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap);
203 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
205 case GROUP_STYLE_MIDDLE:
206 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_MIDDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap);
207 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
208 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_MIDDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap);
209 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
211 case GROUP_STYLE_BOTTOM:
212 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_BOTTOM_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap);
213 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
214 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_BOTTOM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap);
215 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
217 case GROUP_STYLE_SINGLE:
218 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_SINGLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBitmap);
219 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
220 r = GET_BITMAP_CONFIG_N(Panel::GROUPED_SINGLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pGroupStyleBackgroundBitmap);
221 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
223 case GROUP_STYLE_NONE:
231 delete __pGroupStyleBackgroundBitmap;
232 __pGroupStyleBackgroundBitmap = null;
233 delete __pGroupStyleBitmap;
234 __pGroupStyleBitmap = null;
240 _Panel::GetGroupStyleBitmap(void) const
244 return __pGroupStyleBitmap;
248 _Panel::GetGroupStyleBackgroundBitmap(void) const
252 return __pGroupStyleBackgroundBitmap;
256 _Panel::IsBackgroundBitmapStretch(void) const
260 return __backgroundBitmapStretch;
264 _Panel::SetBackgroundBitmapStretch(bool stretch)
268 __backgroundBitmapStretch = stretch;
271 _PanelBackgroundBitmapHorizontalAlign
272 _Panel::GetBackgroundBitmapHorizontalAlign(void) const
276 return __backgroundBitmapHorizontalAlign;
280 _Panel::SetBackgroundBitmapHorizontalAlign(_PanelBackgroundBitmapHorizontalAlign align)
284 __backgroundBitmapHorizontalAlign = align;
287 _PanelBackgroundBitmapVerticalAlign
288 _Panel::GetBackgroundBitmapVerticalAlign(void) const
292 return __backgroundBitmapVerticalAlign;
296 _Panel::SetBackgroundBitmapVerticalAlign(_PanelBackgroundBitmapVerticalAlign align)
300 __backgroundBitmapVerticalAlign = align;
304 _Panel::SetBackgroundBitmapAlign(_PanelBackgroundBitmapHorizontalAlign horizontalAlign, _PanelBackgroundBitmapVerticalAlign verticalAlign)
308 SetBackgroundBitmapHorizontalAlign(horizontalAlign);
309 SetBackgroundBitmapVerticalAlign(verticalAlign);
313 _Panel::GetBackgroundBitmap(void) const
317 return __pBackgroundBitmap;
321 _Panel::SetBackgroundBitmap(Bitmap* bitmap)
325 if (__pBackgroundBitmap != bitmap)
327 delete __pBackgroundBitmap;
328 __pBackgroundBitmap = null;
336 __pBackgroundBitmap = _BitmapImpl::CloneN(*bitmap);
337 result r = GetLastResult();
338 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
344 }}} //Tizen::Ui::Controls