Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrlGalleryItem.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        FUiCtrlGalleryItem.cpp
19  * @brief       This is the header file for the GalleryItem class.
20  *
21  * This header file contains the declarations of the GalleryItem class and its helper classes.
22  */
23
24 //includes
25 #include <FIoFile.h>
26 #include <FUiCtrlGalleryItem.h>
27 #include <FBaseSysLog.h>
28 #include "FUiCtrl_GalleryItemImpl.h"
29
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Io;
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37
38 GalleryItem::GalleryItem(void)
39         : __pImpl(null)
40 {
41         // Do nothing
42 }
43
44 GalleryItem::~GalleryItem(void)
45 {
46         delete __pImpl;
47 }
48
49 result
50 GalleryItem::Construct(const Bitmap& bitmap, GalleryImageRotation rotation)
51 {
52         return Construct(bitmap, L"", rotation);
53 }
54
55 result
56 GalleryItem::Construct(const Bitmap& bitmap, const String& filePath, GalleryImageRotation rotation)
57 {
58         _GalleryItemImpl* pImpl = _GalleryItemImpl::GetInstance(*this);
59         SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
60
61         result r = E_SUCCESS;
62         if (filePath != L"")
63         {
64                 SysTryReturn(NID_UI_CTRL, File::IsFileExist(filePath), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND, "[E_FILE_NOT_FOUND] File does not exist.");
65         }
66
67         String imagefilePath(filePath);
68
69         pImpl = _GalleryItemImpl::CreateGalleryItemImplN(this, bitmap, rotation, imagefilePath);
70         r = GetLastResult();
71         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
72
73         __pImpl = pImpl;
74
75         return E_SUCCESS;
76
77 CATCH:
78         delete pImpl;
79
80         return r;
81 }
82
83 }}} // Tizen::Ui::Controls