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.
18 * @file FUiCtrlGallery.cpp
19 * @brief This file contains implementation of Gallery class.
21 * This header file contains the declarations of the Gallery class and its helper classes.
25 #include <FUiCtrlGallery.h>
26 #include "FUiCtrl_GalleryImpl.h"
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Base;
30 using namespace Tizen::Ui::Effects;
32 namespace Tizen { namespace Ui { namespace Controls {
34 Gallery::Gallery(void)
39 Gallery::~Gallery(void)
44 Gallery::Construct(const Rectangle& rect)
46 SysAssertf(_GalleryImpl::GetInstance(*this) == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
48 _GalleryImpl* pGalleryImpl = _GalleryImpl::CreateGalleryImplN(this);
49 result r = GetLastResult();
50 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
51 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
53 _pControlImpl = pGalleryImpl;
55 r = Control::SetBounds(rect);
56 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
57 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
68 Gallery::SetItemProvider(IGalleryItemProvider &provider)
70 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
71 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
73 result r = pGalleryImpl->SetItemProvider(provider);
79 Gallery::AddGalleryEventListener(IGalleryEventListener &listener)
81 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
82 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
84 pGalleryImpl->AddGalleryEventListener(listener);
85 result r = GetLastResult();
86 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
90 Gallery::RemoveGalleryEventListener(IGalleryEventListener &listener)
92 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
93 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
95 pGalleryImpl->RemoveGalleryEventListener(listener);
96 result r = GetLastResult();
97 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
101 Gallery::GetCurrentItemIndex(void) const
103 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
104 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
106 int currentItemIndex = pGalleryImpl->GetCurrentItemIndex();
108 return currentItemIndex;
112 Gallery::SetCurrentItemIndex(int index)
114 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
115 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
117 result r = pGalleryImpl->SetCurrentItemIndex(index);
118 SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified %d index is out of range.", index);
119 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
125 Gallery::GetItemCount(void) const
127 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
128 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
130 int itemCount = pGalleryImpl->GetItemCount();
135 Gallery::RefreshGallery(int itemIndex, GalleryRefreshType type)
137 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
138 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
140 result r = pGalleryImpl->RefreshGallery(itemIndex, type);
141 SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified %d index is out of range.", itemIndex);
142 SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.");
143 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
149 Gallery::UpdateGallery(void)
151 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
152 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
154 result r = pGalleryImpl->UpdateGallery();
155 SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.");
156 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
162 Gallery::SetTextOfEmptyGallery(const String &text)
164 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
165 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
167 result r = pGalleryImpl->SetTextOfEmptyGallery(text);
168 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
174 Gallery::GetTextOfEmptyGallery(void) const
176 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
177 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
179 String textOfEmptyGallery = pGalleryImpl->GetTextOfEmptyGallery();
180 result r = GetLastResult();
181 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, textOfEmptyGallery, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
183 return textOfEmptyGallery;
187 Gallery::SetBitmapOfEmptyGallery(const Bitmap* pBitmap)
189 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
190 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
192 result r = pGalleryImpl->SetBitmapOfEmptyGallery(pBitmap);
193 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
199 Gallery::SetSlideShowAnimation(GalleryAnimation animation)
201 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
202 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
204 result r = pGalleryImpl->SetSlideShowAnimation(animation);
205 SysTryReturn(NID_UI_CTRL, r != E_UNSUPPORTED_OPERATION, r, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
206 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
212 Gallery::GetSlideShowAnimation(void) const
214 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
215 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
217 GalleryAnimation slideShowAnimation = pGalleryImpl->GetSlideShowAnimation();
218 result r = GetLastResult();
219 SysTryReturn(NID_UI_CTRL, r != E_UNSUPPORTED_OPERATION, slideShowAnimation, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
220 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowAnimation, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
222 return slideShowAnimation;
226 Gallery::SetSlideShowAnimationDuration(int duration)
228 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
229 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
231 result r = pGalleryImpl->SetSlideShowAnimationDuration(duration);
232 SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "The specified %d duration is out of the possible duration range.", duration);
233 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
239 Gallery::GetSlideShowAnimationDuration(void) const
241 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
242 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
244 int slideShowAnimationDuration = pGalleryImpl->GetSlideShowAnimationDuration();
245 result r = GetLastResult();
246 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowAnimationDuration, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
248 return slideShowAnimationDuration;
252 Gallery::SetSlideShowViewDuration(int duration)
254 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
255 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
257 result r = pGalleryImpl->SetSlideShowViewDuration(duration);
258 SysTryReturn(NID_UI_CTRL, r != E_OUT_OF_RANGE, r, E_OUT_OF_RANGE, "The specified %d duration is out of the possible duration range.", duration);
259 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
265 Gallery::GetSlideShowViewDuration(void) const
267 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
268 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
270 int slideShowViewDuration = pGalleryImpl->GetSlideShowViewDuration();
271 result r = GetLastResult();
272 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowViewDuration, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
274 return slideShowViewDuration;
278 Gallery::StartSlideShow(bool repeat)
280 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
281 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
283 result r = pGalleryImpl->StartSlideShow(repeat);
284 SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.");
285 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
291 Gallery::StopSlideShow(void) const
293 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
294 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
296 result r = pGalleryImpl->StopSlideShow();
297 SysTryReturn(NID_UI_CTRL, r != E_INVALID_OPERATION, r, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current state of the instance prohibits the execution of the specified operation.");
298 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
304 Gallery::IsSlideShowStarted(void) const
306 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
307 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
309 bool slideShowStarted = pGalleryImpl->IsSlideShowStarted();
310 result r = GetLastResult();
311 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowStarted, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
313 return slideShowStarted;
317 Gallery::SetZoomingEnabled(bool enable)
319 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
320 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
322 result r = pGalleryImpl->SetZoomingEnabled(enable);
323 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
329 Gallery::IsZoomingEnabled(void) const
331 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
332 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
334 bool zoomingEnable = pGalleryImpl->IsZoomingEnabled();
335 result r = GetLastResult();
336 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, zoomingEnable, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
338 return zoomingEnable;
342 Gallery::SetBackgroundColor(const Color& color)
344 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
345 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
347 Color tempColor = color;
348 tempColor.SetAlpha(255);
349 pGalleryImpl->SetBackgroundColor(tempColor);
350 result r = GetLastResult();
351 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
357 Gallery::GetBackgroundColor(void) const
359 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
360 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
362 Color backgroundColor = pGalleryImpl->GetBackgroundColor();
363 return backgroundColor;
366 }}} // Tizen::Ui::Controls