Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_GalleryItemImpl.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 #include <FBaseErrors.h>
18 #include <FUiCtrlGalleryItem.h>
19 #include <FBaseSysLog.h>
20 #include <FGrp_BitmapImpl.h>
21 #include "FUiCtrl_GalleryItemImpl.h"
22 #include "FUiCtrl_GalleryItem.h"
23 #include "FUiCtrl_GalleryBitmap.h"
24
25 using namespace Tizen::Graphics;
26 using namespace Tizen::Base;
27
28 namespace Tizen { namespace Ui { namespace Controls {
29
30 _GalleryItemImpl::_GalleryItemImpl(GalleryItem* pPublicGalleryItem, _GalleryItem* pCoreGalleryItem)
31         : __pPublicGalleryItem(pPublicGalleryItem)
32         , __pCoreGalleryItem(pCoreGalleryItem)
33 {
34         // Do nothing
35 }
36 _GalleryItemImpl::~_GalleryItemImpl(void)
37 {
38         delete __pCoreGalleryItem;
39 }
40
41 _GalleryItemImpl*
42 _GalleryItemImpl::CreateGalleryItemImplN(GalleryItem* pPubilcGalleryItem, const Bitmap& image,
43                                                                                                         GalleryImageRotation rotation, String filePath)
44 {
45         SysTryReturn(NID_UI_CTRL, pPubilcGalleryItem != null, null, E_INVALID_ARG,
46                                         "[E_INVALID_ARG] The public gallery item argument is null.");
47
48         _GalleryItem* pCoreGalleryItem = null;
49         _GalleryItemImpl* pImplGalleryItem = null;
50         _GalleryBitmap* pGalleryBitmap = null;
51
52         pGalleryBitmap = _GalleryBitmap::CreateGalleryBitmapN(const_cast<Bitmap*>(&image));
53         result r = GetLastResult();
54         SysTryCatch(NID_UI_CTRL, pGalleryBitmap != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
55
56         pGalleryBitmap->SetBitmapRotation(static_cast<_GalleryImageRotation>(rotation));
57
58         pCoreGalleryItem = new (std::nothrow) _GalleryItem(pGalleryBitmap, filePath, static_cast<_GalleryImageRotation>(rotation));
59         SysTryCatch(NID_UI_CTRL, pCoreGalleryItem != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
60
61         pImplGalleryItem = new (std::nothrow) _GalleryItemImpl(pPubilcGalleryItem, pCoreGalleryItem);
62         SysTryCatch(NID_UI_CTRL, pImplGalleryItem != null, pGalleryBitmap = null, E_OUT_OF_MEMORY,
63                                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
64
65         SetLastResult(E_SUCCESS);
66
67         return pImplGalleryItem;
68 CATCH:
69         //delete pImplGalleryItem;
70         delete pCoreGalleryItem;
71         delete pGalleryBitmap;
72
73         return null;
74 }
75
76 const char*
77 _GalleryItemImpl::GetPublicClassName(void) const
78 {
79         return "Tizen::Ui::Controls::GalleryItem";
80 }
81
82 const GalleryItem&
83 _GalleryItemImpl::GetPublic(void) const
84 {
85         return *__pPublicGalleryItem;
86 }
87
88 GalleryItem&
89 _GalleryItemImpl::GetPublic(void)
90 {
91         return *__pPublicGalleryItem;
92 }
93
94 const _GalleryItem&
95 _GalleryItemImpl::GetCore(void) const
96 {
97         return *__pCoreGalleryItem;
98 }
99
100 _GalleryItem&
101 _GalleryItemImpl::GetCore(void)
102 {
103         return *__pCoreGalleryItem;
104 }
105
106 _GalleryItemImpl*
107 _GalleryItemImpl::GetInstance(GalleryItem& galleryItem)
108 {
109         return static_cast<_GalleryItemImpl*> (galleryItem.__pImpl);
110 }
111
112 const _GalleryItemImpl*
113 _GalleryItemImpl::GetInstance(const GalleryItem& galleryItem)
114 {
115         return static_cast<const _GalleryItemImpl*> (galleryItem.__pImpl);
116 }
117
118 }}} // Tizen::Ui::Controls