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.
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"
25 using namespace Tizen::Graphics;
26 using namespace Tizen::Base;
28 namespace Tizen { namespace Ui { namespace Controls {
30 _GalleryItemImpl::_GalleryItemImpl(GalleryItem* pPublicGalleryItem, _GalleryItem* pCoreGalleryItem)
31 : __pPublicGalleryItem(pPublicGalleryItem)
32 , __pCoreGalleryItem(pCoreGalleryItem)
36 _GalleryItemImpl::~_GalleryItemImpl(void)
38 delete __pCoreGalleryItem;
42 _GalleryItemImpl::CreateGalleryItemImplN(GalleryItem* pPubilcGalleryItem, const Bitmap& image,
43 GalleryImageRotation rotation, String filePath)
45 SysTryReturn(NID_UI_CTRL, pPubilcGalleryItem != null, null, E_INVALID_ARG,
46 "[E_INVALID_ARG] The public gallery item argument is null.");
48 _GalleryItem* pCoreGalleryItem = null;
49 _GalleryItemImpl* pImplGalleryItem = null;
50 _GalleryBitmap* pGalleryBitmap = null;
52 pGalleryBitmap = _GalleryBitmap::CreateGalleryBitmapN(const_cast<Bitmap*>(&image));
53 result r = GetLastResult();
54 SysTryCatch(NID_UI_CTRL, pGalleryBitmap != null, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(r));
56 pGalleryBitmap->SetBitmapRotation(static_cast<_GalleryImageRotation>(rotation));
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.");
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.");
65 SetLastResult(E_SUCCESS);
67 return pImplGalleryItem;
69 //delete pImplGalleryItem;
70 delete pCoreGalleryItem;
71 delete pGalleryBitmap;
77 _GalleryItemImpl::GetPublicClassName(void) const
79 return "Tizen::Ui::Controls::GalleryItem";
83 _GalleryItemImpl::GetPublic(void) const
85 return *__pPublicGalleryItem;
89 _GalleryItemImpl::GetPublic(void)
91 return *__pPublicGalleryItem;
95 _GalleryItemImpl::GetCore(void) const
97 return *__pCoreGalleryItem;
101 _GalleryItemImpl::GetCore(void)
103 return *__pCoreGalleryItem;
107 _GalleryItemImpl::GetInstance(GalleryItem& galleryItem)
109 return static_cast<_GalleryItemImpl*> (galleryItem.__pImpl);
112 const _GalleryItemImpl*
113 _GalleryItemImpl::GetInstance(const GalleryItem& galleryItem)
115 return static_cast<const _GalleryItemImpl*> (galleryItem.__pImpl);
118 }}} // Tizen::Ui::Controls