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.
19 * @file FUiCtrlGallery.h
20 * @brief This is the header file for the %Gallery class.
22 * This header file contains the declarations of the %Gallery class and its helper classes.
25 #ifndef _FUI_CTRL_GALLERY_H_
26 #define _FUI_CTRL_GALLERY_H_
28 #include <FBaseObject.h>
29 #include <FBaseTypes.h>
30 #include <FBaseString.h>
31 #include <FGrpRectangle.h>
32 #include <FGrpDimension.h>
33 #include <FGrpBitmap.h>
34 #include <FUiControl.h>
35 #include <FUiContainer.h>
36 #include <FUiCtrlGalleryItem.h>
37 #include <FUiCtrlGalleryTypes.h>
38 #include <FUiCtrlIGalleryItemProvider.h>
39 #include <FUiCtrlIGalleryEventListener.h>
41 namespace Tizen { namespace Ui { namespace Controls
45 * @brief This class defines the common behavior of a %Gallery control.
49 * The %Gallery class displays an image viewer that contains a collection of images (1
50 * image at a time) in a horizontally scrolling list. It also supports a slide
51 * show that automatically displays all the images consecutively.
53 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_gallery.htm">Gallery</a>.
55 * The following example demonstrates how to use the %Gallery class.
58 // Sample code for GallerySample.h
62 : public Tizen::Ui::Controls::Form
63 , public Tizen::Ui::Controls::IGalleryItemProvider
64 , public Tizen::Ui::Controls::IGalleryEventListener
70 bool Initialize(void);
71 virtual result OnInitializing(void);
73 //IGalleryItemProvider
74 virtual Tizen::Ui::Controls::GalleryItem* CreateItem (int index);
75 virtual bool DeleteItem (int index, Tizen::Ui::Controls::GalleryItem *pItem);
76 virtual int GetItemCount(void);
78 // IGalleryEventListener
79 virtual void OnGalleryCurrentItemChanged(Tizen::Ui::Controls::Gallery &gallery, int index);
80 virtual void OnGalleryItemClicked(Tizen::Ui::Controls::Gallery &gallery, int index);
81 virtual void OnGallerySlideShowStarted(Tizen::Ui::Controls::Gallery& gallery);
82 virtual void OnGallerySlideShowStopped(Tizen::Ui::Controls::Gallery& gallery);
85 Tizen::Ui::Controls::Gallery* __pGallery;
90 // Sample code for GallerySample.cpp
92 #include <FGraphics.h>
94 #include "GallerySample.h"
96 using namespace Tizen::App;
97 using namespace Tizen::Ui;
98 using namespace Tizen::Ui::Controls;
99 using namespace Tizen::Graphics;
102 GallerySample::Initialize(void)
104 Construct(FORM_STYLE_NORMAL);
109 GallerySample::OnInitializing(void)
111 result r = E_SUCCESS;
113 // Creates an instance of Gallery
114 __pGallery = new Gallery();
115 __pGallery->Construct(GetBounds());
116 __pGallery->SetItemProvider(*this);
117 __pGallery->AddGalleryEventListener(*this);
119 AddControl(*__pGallery);
124 // IGalleryItemProvider implementation
126 GallerySample::CreateItem(int index)
128 // Gets an instance of Bitmap
129 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
130 Bitmap* pImageTemp = pAppResource->GetBitmapN(L"Image.jpg");
132 // Creates an instance of GalleryItem and registers the bitmap to the gallery item
133 GalleryItem* pGallery = new GalleryItem();
134 pGallery->Construct(*pImageTemp);
136 // Deallocates the bitmap
143 GallerySample::DeleteItem(int index, GalleryItem *pItem)
150 GallerySample::GetItemCount(void)
155 // IGalleryEventListener implementation
157 GallerySample::OnGalleryCurrentItemChanged(Gallery &gallery, int index)
163 GallerySample::OnGalleryItemClicked(Gallery &gallery, int index)
169 GallerySample::OnGallerySlideShowStarted(Gallery& gallery)
175 GallerySample::OnGallerySlideShowStopped(Gallery& gallery)
182 class _OSP_EXPORT_ Gallery
183 : public Tizen::Ui::Control
187 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
194 * This destructor overrides Tizen::Base::Object::~Object().
198 virtual ~Gallery(void);
202 * Initializes this instance of %Gallery with the specified parameter.
206 * @return An error code
207 * @param[in] rect An instance of the Graphics::Rectangle class @n
208 * This instance represents the x and y coordinates of the top-left corner of the created %Gallery control along with the
210 * @exception E_SUCCESS The method is successful.
211 * @exception E_INVALID_ARG The specified input parameter is invalid.
212 * @exception E_SYSTEM A system error has occurred.
214 result Construct(const Tizen::Graphics::Rectangle& rect);
217 * Initializes this instance of %Gallery with the specified parameter.
221 * @return An error code
222 * @param[in] rect An instance of the Graphics::FloatRectangle class @n
223 * This instance represents the x and y coordinates of the top-left corner of the created %Gallery control along with the
225 * @exception E_SUCCESS The method is successful.
226 * @exception E_INVALID_ARG The specified input parameter is invalid.
227 * @exception E_SYSTEM A system error has occurred.
229 result Construct(const Tizen::Graphics::FloatRectangle& rect);
232 * Sets the item provider that creates and deletes the items from the %Gallery control.
236 * @return An error code
237 * @param[in] provider The item provider to create and delete items
238 * @exception E_SUCCESS The method is successful.
239 * @remark If an item provider is not set for the %Gallery control, the method does not work. @n
240 * The item provider should be allocated on a heap memory.
242 result SetItemProvider(IGalleryItemProvider& provider);
245 * Adds an IGalleryEventListener instance. @n
246 * The added listener can listen to the item events when they are fired.
250 * @param[in] listener The listener to be added
252 void AddGalleryEventListener(IGalleryEventListener& listener);
255 * Removes an IGalleryEventListener instance. @n
256 * The removed listener cannot listen to events when they are fired.
260 * @param[in] listener The listener to be removed
262 void RemoveGalleryEventListener(IGalleryEventListener& listener);
265 * Gets the index of the current item.
269 * @return The current item index of the %Gallery control
270 * @remarks The specific error code can be accessed using the GetLastResult() method.
272 int GetCurrentItemIndex(void) const;
275 * Sets the index of the current item.
279 * @return An error code
280 * @param[in] index The index of the item
281 * @exception E_SUCCESS The method is successful.
282 * @exception E_OUT_OF_RANGE The specified @c index is out of range.
283 * @exception E_SYSTEM A system error has occurred.
286 result SetCurrentItemIndex(int index);
289 * Gets the total number of items.
293 * @return The total number of items, @n
294 * else @c -1 if an error occurs
296 int GetItemCount(void) const;
299 * Refreshes the item at the specified index.
303 * @return An error code
304 * @param[in] itemIndex The index of the item to be refreshed
305 * @param[in] type The type of change for an item
306 * @exception E_SUCCESS The method is successful.
307 * @exception E_OUT_OF_RANGE The specified @c index is out of range.
308 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
309 * @exception E_SYSTEM A system error has occurred.
311 result RefreshGallery(int itemIndex, GalleryRefreshType type);
314 * Updates all the items of a list.
318 * @return An error code
319 * @exception E_SUCCESS The method is successful.
320 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
321 * @exception E_SYSTEM A system error has occurred.
322 * @remarks This method clears items in the list and reinvokes methods of the item provider to fill the list.
324 result UpdateGallery(void);
327 * Sets the text of the empty %Gallery control.
331 * @return An error code
332 * @param[in] text The text of the empty %Gallery control
333 * @exception E_SUCCESS The method is successful.
334 * @exception E_SYSTEM A system error has occurred.
336 result SetTextOfEmptyGallery(const Tizen::Base::String& text);
339 * Gets the text of the empty %Gallery control.
343 * @return The text of the empty %Gallery control
344 * @exception E_SUCCESS The method is successful.
345 * @exception E_SYSTEM A system error has occurred.
346 * @remarks The specific error code can be accessed using the GetLastResult() method.
348 Tizen::Base::String GetTextOfEmptyGallery(void) const;
351 * Sets the background bitmap of the %Gallery control.
355 * @param[in] pBitmap The bitmap of the empty %Gallery control
356 * @exception E_SUCCESS The method is successful.
357 * @exception E_SYSTEM A system error has occurred.
358 * @remarks When @c pBitmap is @c null, the %Gallery control does not have a background bitmap. The default value for the background bitmap is @c null.
359 * @remarks The background bitmap has a priority over the background color. When both the background bitmap and the background color are specified,
360 * only the bitmap is displayed.
362 result SetBitmapOfEmptyGallery(const Tizen::Graphics::Bitmap* pBitmap);
365 * Sets the slide show transition animation type.
369 * @param[in] animation The animation type of the %Gallery control
370 * @exception E_SUCCESS The method is successful.
371 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
372 * @exception E_SYSTEM A system error has occurred.
373 * @remarks The method is not supported in 16-bit devices.
375 result SetSlideShowAnimation(GalleryAnimation animation);
378 * Gets the transition animation type of the slide show.
382 * @return The animation type of a %Gallery control
383 * @exception E_SUCCESS The method is successful.
384 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
385 * @exception E_SYSTEM A system error has occurred.
386 * @remarks The specific error code can be accessed using the GetLastResult() method.
387 * @remarks The method is not supported in 16-bit devices.
389 GalleryAnimation GetSlideShowAnimation(void) const;
392 * Sets the duration of the slide show transition animation.
396 * @param[in] duration The animation duration
397 * @exception E_SUCCESS The method is successful.
398 * @exception E_OUT_OF_RANGE The specified @c duration is out of the possible duration range. @n
399 * The specified duration should be greater than or equal to 300 or less than or equals to 20000.
400 * @exception E_SYSTEM A system error has occurred.
401 * @remarks The unit of the duration is in milliseconds.@n
402 * The default animation duration is different for each slide show animation type.
404 result SetSlideShowAnimationDuration(int duration);
407 * Gets the transition animation duration of the %Gallery control.
411 * @return The animation duration, @n
412 * else @c -1 if an error occurs
413 * @exception E_SUCCESS The method is successful.
414 * @exception E_SYSTEM A system error has occurred.
415 * @remarks The specific error code can be accessed using the GetLastResult() method.
417 int GetSlideShowAnimationDuration(void) const;
420 * Sets the duration of the slide-show item view.
424 * @param[in] duration The item view duration
425 * @exception E_SUCCESS The method is successful.
426 * @exception E_OUT_OF_RANGE The specified @c duration is out of possible duration range. @n
427 * - The specified @c duration should be greater than 10.
428 * @exception E_SYSTEM A system error has occurred.
429 * @remarks The unit of the duration is in milliseconds.@n
430 * The default animation duration is different for each slide show animation type.
432 result SetSlideShowViewDuration(int duration);
435 * Gets the duration of the slide-show item view.
439 * @return The item view duration, @n
440 * else @c -1 if an error occurs
441 * @exception E_SUCCESS The method is successful.
442 * @exception E_SYSTEM A system error has occurred.
443 * @remarks The specific error code can be accessed using @c GetLastResult() method.
445 int GetSlideShowViewDuration(void) const;
448 * Starts the slide show.
452 * @return An error code
453 * @param[in] repeat The repeat status
454 * @exception E_SUCCESS The method is successful.
455 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
456 * @exception E_SYSTEM A system error has occurred.
458 result StartSlideShow(bool repeat = false);
461 * Stops the slide show.
465 * @return An error code
466 * @exception E_SUCCESS The method is successful.
467 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
468 * @exception E_SYSTEM A system error has occurred.
470 result StopSlideShow(void) const;
473 * Checks whether the slide show has started.
477 * @return @c true if the slide show is running, @n
479 * @exception E_SUCCESS The method is successful.
480 * @exception E_SYSTEM A system error has occurred.
481 * @remarks The specific error code can be accessed using the GetLastResult() method.
483 bool IsSlideShowStarted(void) const;
486 * Enables or disables the image zooming.
490 * @return An error code
491 * @param[in] enable Set to @c true to enable zooming, @n
493 * @exception E_SUCCESS The method is successful.
494 * @exception E_SYSTEM A system error has occurred.
495 * @remarks When enabled, the user can enter the zoom mode by double-clicking or pinching the current image.
497 result SetZoomingEnabled(bool enable);
500 * Checks whether zooming is enabled.
504 * @return @c true if zooming is enabled, @n
506 * @exception E_SUCCESS The method is successful.
507 * @exception E_SYSTEM A system error has occurred.
508 * @remarks The specific error code can be accessed using the GetLastResult() method.
510 bool IsZoomingEnabled(void) const;
513 * Sets the background color of the %Gallery control.
517 * @return An error code
518 * @param[in] color The background color
519 * @exception E_SUCCESS The method is successful.
520 * @exception E_SYSTEM A system error has occurred.
521 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to 255.
523 result SetBackgroundColor(const Tizen::Graphics::Color& color);
526 * Gets the background color of the %Gallery control.
530 * @return The background color, @n
531 * else RGBA(0, 0, 0, 0) if an error occurs
532 * @exception E_SUCCESS The method is successful.
533 * @remarks The specific error code can be accessed using the GetLastResult() method.
535 Tizen::Graphics::Color GetBackgroundColor(void) const;
539 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
541 Gallery(const Gallery& rhs);
544 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
546 Gallery& operator =(const Gallery& rhs);
549 friend class _GalleryImpl;
552 }}} // Tizen::Ui::Controls
554 #endif // _FUI_CTRL_GALLERY_H_