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.
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. @n
188 * For full construction, the %Construct() method must be called right after calling this constructor.
195 * This destructor overrides Tizen::Base::Object::~Object().
199 virtual ~Gallery(void);
203 * Initializes this instance of %Gallery with the specified parameter.
207 * @return An error code
208 * @param[in] rect An instance of the Graphics::Rectangle class @n
209 * This instance represents the x and y coordinates of the top-left corner of the created %Gallery control along with the
210 * width and height. @n
211 * The optimal size of the control is defined in
212 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
213 * @exception E_SUCCESS The method is successful.
214 * @exception E_INVALID_ARG The specified input parameter is invalid.
215 * @exception E_SYSTEM A system error has occurred.
217 result Construct(const Tizen::Graphics::Rectangle& rect);
220 * Initializes this instance of %Gallery with the specified parameter.
224 * @return An error code
225 * @param[in] rect An instance of the Tizen::Graphics::FloatRectangle class @n
226 * This instance represents the x and y coordinates of the top-left corner of the created %Gallery control along with the
227 * width and height.@n
228 * The optimal size of the control is defined in
229 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
230 * @exception E_SUCCESS The method is successful.
231 * @exception E_INVALID_ARG The specified input parameter is invalid.
232 * @exception E_SYSTEM A system error has occurred.
234 result Construct(const Tizen::Graphics::FloatRectangle& rect);
237 * Sets the item provider that creates and deletes the items from the %Gallery control.
241 * @return An error code
242 * @param[in] provider The item provider to create and delete items
243 * @exception E_SUCCESS The method is successful.
244 * @remarks If an item provider is not set for the %Gallery control, the method does not work. @n
245 * The item provider should be allocated on a heap memory.
247 result SetItemProvider(IGalleryItemProvider& provider);
250 * Adds an IGalleryEventListener instance. @n
251 * The added listener can listen to the item events when they are fired.
255 * @param[in] listener The listener to add
257 void AddGalleryEventListener(IGalleryEventListener& listener);
260 * Removes an IGalleryEventListener instance. @n
261 * The removed listener cannot listen to events when they are fired.
265 * @param[in] listener The listener to remove
267 void RemoveGalleryEventListener(IGalleryEventListener& listener);
270 * Gets the index of the current item.
274 * @return The current item index of the %Gallery control
275 * @remarks The specific error code can be accessed using the GetLastResult() method.
277 int GetCurrentItemIndex(void) const;
280 * Sets the index of the current item.
284 * @return An error code
285 * @param[in] index The index of the item
286 * @exception E_SUCCESS The method is successful.
287 * @exception E_OUT_OF_RANGE The specified @c index is out of range.
288 * @exception E_SYSTEM A system error has occurred.
291 result SetCurrentItemIndex(int index);
294 * Gets the total number of items.
298 * @return The total number of items, @n
299 * else @c -1 if an error occurs
301 int GetItemCount(void) const;
304 * Refreshes the item at the specified index.
308 * @return An error code
309 * @param[in] itemIndex The index of the item to refresh
310 * @param[in] type The type of change for an item
311 * @exception E_SUCCESS The method is successful.
312 * @exception E_OUT_OF_RANGE The specified @c index is out of range.
313 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
314 * @exception E_SYSTEM A system error has occurred.
316 result RefreshGallery(int itemIndex, GalleryRefreshType type);
319 * Updates all the items of a list.
323 * @return An error code
324 * @exception E_SUCCESS The method is successful.
325 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
326 * @exception E_SYSTEM A system error has occurred.
327 * @remarks This method clears items in the list and reinvokes methods of the item provider to fill the list.
329 result UpdateGallery(void);
332 * Sets the text of the empty %Gallery control.
336 * @return An error code
337 * @param[in] text The text of the empty %Gallery control
338 * @exception E_SUCCESS The method is successful.
339 * @exception E_SYSTEM A system error has occurred.
341 result SetTextOfEmptyGallery(const Tizen::Base::String& text);
344 * Gets the text of the empty %Gallery control.
348 * @return The text of the empty %Gallery control
349 * @exception E_SUCCESS The method is successful.
350 * @exception E_SYSTEM A system error has occurred.
351 * @remarks The specific error code can be accessed using the GetLastResult() method.
353 Tizen::Base::String GetTextOfEmptyGallery(void) const;
356 * Sets the background bitmap of the %Gallery control.
360 * @param[in] pBitmap The bitmap of the empty %Gallery control
361 * @exception E_SUCCESS The method is successful.
362 * @exception E_SYSTEM A system error has occurred.
364 * - When @c pBitmap is @c null, the %Gallery control does not have a background bitmap. @n
365 * The default value for the background bitmap is @c null.
366 * - The background bitmap has a priority over the background color. When both the background bitmap and
367 * the background color are specified, only the bitmap is displayed.
369 result SetBitmapOfEmptyGallery(const Tizen::Graphics::Bitmap* pBitmap);
372 * Sets the slide show transition animation type.
376 * @param[in] animation The animation type of the %Gallery control
377 * @exception E_SUCCESS The method is successful.
378 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
379 * @exception E_SYSTEM A system error has occurred.
380 * @remarks The method is not supported in 16-bit devices.
382 result SetSlideShowAnimation(GalleryAnimation animation);
385 * Gets the transition animation type of the slide show.
389 * @return The animation type of a %Gallery control
390 * @exception E_SUCCESS The method is successful.
391 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
392 * @exception E_SYSTEM A system error has occurred.
394 * - The specific error code can be accessed using the GetLastResult() method.
395 * - The method is not supported in 16-bit devices.
397 GalleryAnimation GetSlideShowAnimation(void) const;
400 * Sets the duration of the slide show transition animation.
404 * @param[in] duration The animation duration
405 * @exception E_SUCCESS The method is successful.
406 * @exception E_OUT_OF_RANGE The specified @c duration is out of the possible duration range. @n
407 * The specified duration should be greater than or equal to 300 or less than or equals to @c 20000.
408 * @exception E_SYSTEM A system error has occurred.
410 * - The unit of the duration is in milliseconds.
411 * - The default animation duration is different for each slide show animation type.
413 result SetSlideShowAnimationDuration(int duration);
416 * Gets the transition animation duration of the %Gallery control.
420 * @return The animation duration, @n
421 * else @c -1 if an error occurs
422 * @exception E_SUCCESS The method is successful.
423 * @exception E_SYSTEM A system error has occurred.
424 * @remarks The specific error code can be accessed using the GetLastResult() method.
426 int GetSlideShowAnimationDuration(void) const;
429 * Sets the duration of the slide-show item view.
433 * @param[in] duration The item view duration
434 * @exception E_SUCCESS The method is successful.
435 * @exception E_OUT_OF_RANGE The specified @c duration is out of possible duration range. @n
436 * - The specified @c duration should be greater than @c 10.
437 * @exception E_SYSTEM A system error has occurred.
439 * - The unit of the duration is in milliseconds.
440 * - The default animation duration is different for each slide show animation type.
442 result SetSlideShowViewDuration(int duration);
445 * Gets the duration of the slide-show item view.
449 * @return The item view duration, @n
450 * else @c -1 if an error occurs
451 * @exception E_SUCCESS The method is successful.
452 * @exception E_SYSTEM A system error has occurred.
453 * @remarks The specific error code can be accessed using @c GetLastResult() method.
455 int GetSlideShowViewDuration(void) const;
458 * Starts the slide show.
462 * @return An error code
463 * @param[in] repeat The repeat status
464 * @exception E_SUCCESS The method is successful.
465 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
466 * @exception E_SYSTEM A system error has occurred.
468 result StartSlideShow(bool repeat = false);
471 * Stops the slide show.
475 * @return An error code
476 * @exception E_SUCCESS The method is successful.
477 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
478 * @exception E_SYSTEM A system error has occurred.
480 result StopSlideShow(void) const;
483 * Checks whether the slide show has started.
487 * @return @c true if the slide show is running, @n
489 * @exception E_SUCCESS The method is successful.
490 * @exception E_SYSTEM A system error has occurred.
491 * @remarks The specific error code can be accessed using the GetLastResult() method.
493 bool IsSlideShowStarted(void) const;
496 * Enables or disables the image zooming.
500 * @return An error code
501 * @param[in] enable Set to @c true to enable zooming, @n
503 * @exception E_SUCCESS The method is successful.
504 * @exception E_SYSTEM A system error has occurred.
505 * @remarks When enabled, the user can enter the zoom mode by double-clicking or pinching the current image.
507 result SetZoomingEnabled(bool enable);
510 * Checks whether zooming is enabled.
514 * @return @c true if zooming is enabled, @n
516 * @exception E_SUCCESS The method is successful.
517 * @exception E_SYSTEM A system error has occurred.
518 * @remarks The specific error code can be accessed using the GetLastResult() method.
520 bool IsZoomingEnabled(void) const;
523 * Sets the background color of the %Gallery control.
527 * @return An error code
528 * @param[in] color The background color
529 * @exception E_SUCCESS The method is successful.
530 * @exception E_SYSTEM A system error has occurred.
531 * @remarks The method ignores the alpha value of the @c color parameter and sets the alpha value to @c 255.
533 result SetBackgroundColor(const Tizen::Graphics::Color& color);
536 * Gets the background color of the %Gallery control.
540 * @return The background color, @n
541 * else RGBA(0, 0, 0, 0) if an error occurs
542 * @exception E_SUCCESS The method is successful.
543 * @remarks The specific error code can be accessed using the GetLastResult() method.
545 Tizen::Graphics::Color GetBackgroundColor(void) const;
549 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
551 Gallery(const Gallery& rhs);
554 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
556 Gallery& operator =(const Gallery& rhs);
559 friend class _GalleryImpl;
562 }}} // Tizen::Ui::Controls
564 #endif // _FUI_CTRL_GALLERY_H_