2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
23 #include <FUiCtrlGallery.h>
24 #include "FUiCtrl_GalleryImpl.h"
26 using namespace Tizen::Graphics;
27 using namespace Tizen::Base;
28 using namespace Tizen::Ui::Effects;
30 namespace Tizen { namespace Ui { namespace Controls {
32 Gallery::Gallery(void)
37 Gallery::~Gallery(void)
42 Gallery::Construct(const Rectangle& rect)
44 SysAssertf(_GalleryImpl::GetInstance(*this) == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
46 _GalleryImpl* pGalleryImpl = _GalleryImpl::CreateGalleryImplN(this);
47 result r = GetLastResult();
48 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
49 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
51 _pControlImpl = pGalleryImpl;
53 r = Control::SetBounds(rect);
54 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
55 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
66 Gallery::Construct(const FloatRectangle& rect)
68 SysAssertf(_GalleryImpl::GetInstance(*this) == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
70 _GalleryImpl* pGalleryImpl = _GalleryImpl::CreateGalleryImplN(this);
71 result r = GetLastResult();
72 SysTryCatch(NID_UI_CTRL, r != E_OUT_OF_MEMORY, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
73 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
75 _pControlImpl = pGalleryImpl;
77 r = Control::SetBounds(rect);
78 SysTryCatch(NID_UI_CTRL, r != E_INVALID_ARG, , E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
79 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
90 Gallery::SetItemProvider(IGalleryItemProvider &provider)
92 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
93 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
95 result r = pGalleryImpl->SetItemProvider(provider);
101 Gallery::AddGalleryEventListener(IGalleryEventListener &listener)
103 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
104 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
106 pGalleryImpl->AddGalleryEventListener(listener);
107 result r = GetLastResult();
108 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
112 Gallery::RemoveGalleryEventListener(IGalleryEventListener &listener)
114 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
115 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
117 pGalleryImpl->RemoveGalleryEventListener(listener);
118 result r = GetLastResult();
119 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
123 Gallery::GetCurrentItemIndex(void) const
125 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
126 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
128 int currentItemIndex = pGalleryImpl->GetCurrentItemIndex();
130 return currentItemIndex;
134 Gallery::SetCurrentItemIndex(int index)
136 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
137 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
139 result r = pGalleryImpl->SetCurrentItemIndex(index);
140 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);
141 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
147 Gallery::GetItemCount(void) const
149 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
150 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
152 int itemCount = pGalleryImpl->GetItemCount();
157 Gallery::RefreshGallery(int itemIndex, GalleryRefreshType type)
159 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
160 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
162 result r = pGalleryImpl->RefreshGallery(itemIndex, type);
163 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);
164 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.");
165 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
171 Gallery::UpdateGallery(void)
173 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
174 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
176 result r = pGalleryImpl->UpdateGallery();
177 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.");
178 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
184 Gallery::SetTextOfEmptyGallery(const String &text)
186 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
187 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
189 result r = pGalleryImpl->SetTextOfEmptyGallery(text);
190 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
196 Gallery::GetTextOfEmptyGallery(void) const
198 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
199 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
201 String textOfEmptyGallery = pGalleryImpl->GetTextOfEmptyGallery();
202 result r = GetLastResult();
203 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, textOfEmptyGallery, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
205 return textOfEmptyGallery;
209 Gallery::SetBitmapOfEmptyGallery(const Bitmap* pBitmap)
211 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
212 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
214 result r = pGalleryImpl->SetBitmapOfEmptyGallery(pBitmap);
215 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
221 Gallery::SetSlideShowAnimation(GalleryAnimation animation)
223 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
224 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
226 result r = pGalleryImpl->SetSlideShowAnimation(animation);
227 SysTryReturn(NID_UI_CTRL, r != E_UNSUPPORTED_OPERATION, r, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
228 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
234 Gallery::GetSlideShowAnimation(void) const
236 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
237 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
239 GalleryAnimation slideShowAnimation = pGalleryImpl->GetSlideShowAnimation();
240 result r = GetLastResult();
241 SysTryReturn(NID_UI_CTRL, r != E_UNSUPPORTED_OPERATION, slideShowAnimation, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] This operation is not supported.");
242 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowAnimation, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
244 return slideShowAnimation;
248 Gallery::SetSlideShowAnimationDuration(int duration)
250 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
251 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
253 result r = pGalleryImpl->SetSlideShowAnimationDuration(duration);
254 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);
255 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
261 Gallery::GetSlideShowAnimationDuration(void) const
263 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
264 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
266 int slideShowAnimationDuration = pGalleryImpl->GetSlideShowAnimationDuration();
267 result r = GetLastResult();
268 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowAnimationDuration, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
270 return slideShowAnimationDuration;
274 Gallery::SetSlideShowViewDuration(int duration)
276 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
277 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
279 result r = pGalleryImpl->SetSlideShowViewDuration(duration);
280 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);
281 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
287 Gallery::GetSlideShowViewDuration(void) const
289 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
290 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
292 int slideShowViewDuration = pGalleryImpl->GetSlideShowViewDuration();
293 result r = GetLastResult();
294 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowViewDuration, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
296 return slideShowViewDuration;
300 Gallery::StartSlideShow(bool repeat)
302 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
303 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
305 result r = pGalleryImpl->StartSlideShow(repeat);
306 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.");
307 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
313 Gallery::StopSlideShow(void) const
315 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
316 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
318 result r = pGalleryImpl->StopSlideShow();
319 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.");
320 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
326 Gallery::IsSlideShowStarted(void) const
328 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
329 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
331 bool slideShowStarted = pGalleryImpl->IsSlideShowStarted();
332 result r = GetLastResult();
333 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, slideShowStarted, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
335 return slideShowStarted;
339 Gallery::SetZoomingEnabled(bool enable)
341 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
342 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
344 result r = pGalleryImpl->SetZoomingEnabled(enable);
345 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
351 Gallery::IsZoomingEnabled(void) const
353 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
354 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
356 bool zoomingEnable = pGalleryImpl->IsZoomingEnabled();
357 result r = GetLastResult();
358 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, zoomingEnable, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
360 return zoomingEnable;
364 Gallery::SetBackgroundColor(const Color& color)
366 _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
367 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
369 Color tempColor = color;
370 tempColor.SetAlpha(255);
371 pGalleryImpl->SetBackgroundColor(tempColor);
372 result r = GetLastResult();
373 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
379 Gallery::GetBackgroundColor(void) const
381 const _GalleryImpl* pGalleryImpl = _GalleryImpl::GetInstance(*this);
382 SysAssertf(pGalleryImpl != null, "Not yet constructed. Construct() should be called before use.");
384 Color backgroundColor = pGalleryImpl->GetBackgroundColor();
385 return backgroundColor;
388 }}} // Tizen::Ui::Controls