Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_GalleryPresenter.h
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 #ifndef _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H
18 #define _FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H
19
20 #include <FBaseString.h>
21 #include <FBaseRtITimerEventListener.h>
22 #include <FGrpFontCommon.h>
23 #include <FUiCtrlGalleryTypes.h>
24 #include "FUi_PropertyBase.h"
25 #include "FUiCtrl_GalleryTypes.h"
26 #include "FUiCtrl_IGalleryRendererNotiListener.h"
27
28 namespace Tizen { namespace Base { namespace Runtime {
29
30 class Timer;
31
32 }}} // Tizen::Base::RunTime
33
34 namespace Tizen { namespace Ui { namespace Controls {
35
36 const int MAX_CANVAS_COUNT = 4;
37 const int NOT_EXIST_CANVAS = -1;
38 const int NOT_USED_CANVAS = -1;
39 const int NO_CURRENT_IMAGE = -1;
40
41 class _GalleryViewEvent;
42 class _GalleryBitmap;
43 class _IGalleryRenderer;
44 class _IGalleryCoreEventListener;
45 class _GalleryViewEventHandler;
46 class _GalleryModel;
47 class _GalleryImageReader;
48 class _GalleryCoreEvent;
49 class _GalleryItemProvider;
50 class _GalleryBitmap;
51 class _GalleryItemProviderAdaptorImpl;
52
53 class _GalleryPresenter
54         : public Tizen::Ui::_PropertyBase
55         , public _IGalleryRendererNotiListener
56         , public Tizen::Ui::_IPropertyChangeEventListener
57         , public Tizen::Base::Runtime::ITimerEventListener
58         , virtual public Tizen::Base::Runtime::IEventListener
59 {
60 // Declare Properties
61         DECLARE_CLASS_BEGIN(_GalleryPresenter, _PropertyBase);
62         DECLARE_PROPERTY("slideShowViewDuration", GetPropertySlideShowViewDuration, SetPropertySlideShowViewDuration);
63         DECLARE_PROPERTY("slideShowAnimationDuration", GetPropertySlideShowAnimationDuration, SetPropertySlideShowAnimationDuration);
64         DECLARE_PROPERTY("textOfEmptyGallery", GetPropertyTextOfEmptyGallery, SetPropertyTextOfEmptyGallery);
65         DECLARE_PROPERTY("zoomingEnabled", GetPropertyZoomingEnabled, SetPropertyZoomingEnabled);
66         DECLARE_CLASS_END();
67
68 public:
69         virtual ~_GalleryPresenter(void);
70
71         static _GalleryPresenter* CreateGalleryPresenterN(_IGalleryRenderer& galleryRenderer, _GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor);
72
73         int GetCurrentItemIndex(void) const;
74         result SetCurrentItemIndex(int index, bool eventFire = true);
75         result SetCurrentItem(int index);
76
77         int GetItemCount(void) const;
78
79         void SetItemSpacing(int spacing);
80         int GetItemSpacing(void) const;
81
82         _GallerySlideShowType GetSlideShowType(void) const;
83         result SetSlideShowType(_GallerySlideShowType slideShowType);
84
85         int GetSlideShowAnimationDuration(void) const;
86         result SetSlideShowAnimationDuration(int duration);
87
88         int GetSlideShowViewDuration(void) const;
89         result SetSlideShowViewDuration(int duration);
90
91         result StartSlideShow(bool repeat = false);
92         result StopSlideShow(void);
93         bool IsSlideShowStarted(void) const;
94
95         Tizen::Base::String GetTextOfEmptyGallery(void) const;
96         result SetTextOfEmptyGallery(const Tizen::Base::String& text);
97         result SetBitmapOfEmptyGallery(const _GalleryBitmap* pBitmap);
98
99         result SetZoomingEnabled(bool enable);
100         bool IsZoomingEnabled(void) const;
101
102         bool PostEvent(_GalleryViewEvent& event);
103         bool OnBoundsChanged(void);
104         void OnDraw(void);
105
106         result SetCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
107         result RemoveCoreEventListener(const _IGalleryCoreEventListener& coreEventListener);
108
109         bool ClickedItem(void);
110         bool ChangedItem(void);
111
112         // model access
113         result RequestToLoadItem(int index);
114         result RequestToUnloadItem(int index);
115         result RequestToUnloadAllItems(void);
116         result RequestToUpdateItem(int index);
117         result RequestToUpdateAllItems(void);
118         result RequestToUpdateItemCount(void);
119
120         // timer
121         virtual void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
122
123         // renderer noti listener
124         virtual void OnTransitionCancel(void);
125         virtual void OnTransitionCompleted(void);
126         virtual void OnCanvasAnimationCancel(void);
127         virtual void OnCanvasAnimationCompleted(void);
128         virtual void OnCanvasAnimationStarted(void);
129
130         // data binding event listener
131         virtual void OnPropertyChanging(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
132         virtual void OnPropertyChanged(Tizen::Ui::_PropertyBase& source, const Tizen::Base::String& name, const Variant& oldProperty, const Variant& newProperty);
133
134         // font function
135         void SetFontSize(int size);
136         int GetFontSize(void) const;
137         void SetFontStyle(Tizen::Graphics::FontStyle style);
138         Tizen::Graphics::FontStyle GetFontStyle(void) const;
139         void OnFontChanged(void);
140
141         virtual void OnFontInfoRequested(unsigned long& style, int& size);
142
143
144 protected:
145         _GalleryPresenter(_IGalleryRenderer& galleryRenderer);
146         result Construct(_GalleryItemProviderAdaptorImpl* pGalleryItemProviderAdaptor);
147
148         // property getter/setter
149         Variant GetPropertySlideShowViewDuration(void) const;
150         result SetPropertySlideShowViewDuration(const Variant& variant);
151         Variant GetPropertySlideShowAnimationDuration(void) const;
152         result SetPropertySlideShowAnimationDuration(const Variant& variant);
153         Variant GetPropertyTextOfEmptyGallery(void) const;
154         result SetPropertyTextOfEmptyGallery(const Variant& variant);
155         Variant GetPropertyZoomingEnabled(void) const;
156         result SetPropertyZoomingEnabled(const Variant& variant);
157
158 private:
159         _GalleryPresenter(const _GalleryPresenter& rhs);
160         _GalleryPresenter& operator=(const _GalleryPresenter& rhs);
161
162         result SetCanvasImage(int itemIndex);
163         result SetPartialCanvasImage(void);
164         int SearchCanvasIndex(int itemIndex);
165         int GetEmptyCanvasIndex(void) const;
166         result SetCanvasIndex(int canvasIndex, int itemIndex);
167         int ClearCanvasIndex(int currentItemIndex);
168         void SortItemToCanvasIndex(int itemIndex, bool add);
169
170         result StartSlideShowTimer(int duration);
171         void StopSlideShowTimer(void);
172         result PlaySlideShow(void);
173
174 private:
175         _IGalleryRenderer& __galleryRenderer;
176         _GalleryViewEventHandler* __pGalleryViewEventHandler;
177         _GalleryCoreEvent* __pGalleryCoreEvent;
178         _GalleryItemProvider* __pGalleryItemProvider;
179         _GalleryModel* __pGalleryModel;
180         _GalleryImageReader* __pGalleryImageReader;
181
182         //_GalleryBitmap* __pPartialImage;
183         _GalleryBitmap* __pEmptyGalleryImage;
184         Tizen::Base::String __emptyText;
185         int __slideShowAnimationDuration;
186         int __slideShowViewDuration;
187         _GallerySlideShowType __gallerySlideShowType;
188         int __currentItemIndex;
189         bool __slideShowRepeat;
190         bool __slideShowStarted;
191         bool __zoomingEnabled;
192         Tizen::Base::Runtime::Timer* __pSlideShowTimer;
193         int __slideShowPlayCount;
194         int __itemSpacing;
195         int* __pItemToCanvas;
196         _GalleryFittingType __fittingType;
197         _GalleryVerticalAlignment __verticalAlignment;
198         _GalleryHorizontalAlignment __horizontalAlignment;
199
200         int __emptyFontSize;
201         Tizen::Graphics::FontStyle __emptyFontStyle;
202
203 friend class _GalleryViewEventHandler;
204 }; // _GalleryPresenter
205
206 }}} // Tizen::Ui::Controls
207
208 #endif //_FUI_CTRL_INTERNAL_GALLERY_PRESENTER_H