41b1e77eb005b0267e3a1fe068745e95d9cd9960
[framework/osp/shell.git] / src / FShell_AppWidgetViewManager.h
1 //
2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://floralicense.org/license/
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                FShell_AppWidgetViewManager.h
18  * @brief               This is the header file for the _AppWidgetViewManager class.
19  *
20  * This header file contains the declarations of the %_AppWidgetViewManager class.
21  */
22 #ifndef _FSHELL_INTERNAL_APPWIDGET_VIEW_MANAGER_H_
23 #define _FSHELL_INTERNAL_APPWIDGET_VIEW_MANAGER_H_
24
25 #include <unique_ptr.h>
26 #include <FGrpBitmapCommon.h>
27 #include <FMediaImageTypes.h>
28
29 struct livebox;
30
31 namespace Tizen { namespace Base
32 {
33 class String;
34 }}
35
36 namespace Tizen { namespace Base { namespace Collection
37 {
38 template<class KeyType, class ValueType> class HashMapT;
39 }}}
40
41 namespace Tizen { namespace Graphics
42 {
43 class Bitmap;
44 class FloatDimension;
45 class _ICoordinateSystemTransformer;
46 }} // Tizen::Graphics
47
48 namespace Tizen { namespace Shell
49 {
50 class _AppWidgetView;
51 class _AppWidgetBuffer;
52
53 /**
54  * @class _AppWidgetViewManager
55  * @brief
56  * @since 2.1
57  */
58 class _AppWidgetViewManager
59 {
60 public:
61         static _AppWidgetViewManager* GetInstance(void);
62         livebox* AddAppWidgetView(_AppWidgetView* pAppWidgetView, const Tizen::Base::String& userInfo);
63         void RemoveAppWidgetView(_AppWidgetView* pAppWidgetView);
64         _AppWidgetView* GetAppWidgetView(livebox* pAppWidget) const;
65         Tizen::Graphics::FloatDimension GetAppWidgetSize(livebox* pAppWidget) const;
66         Tizen::Graphics::FloatDimension GetAppWidgetPopupSize(livebox* pAppWidget) const;
67         void SetAppWidgetSize(const _AppWidgetView& appwidgetView, const Tizen::Graphics::FloatDimension& size);
68         void AddFrameEventListener(void);
69         int GetAppWidgetSizeType(const Tizen::Graphics::FloatDimension& size) const;
70
71 private:
72         _AppWidgetViewManager(void);
73         ~_AppWidgetViewManager(void);
74         _AppWidgetViewManager(const _AppWidgetViewManager& rhs);
75         _AppWidgetViewManager& operator =(const _AppWidgetViewManager& rhs);
76
77         Tizen::Media::MediaPixelFormat GetPixelFormat(Tizen::Graphics::BitmapPixelFormat format) const;
78         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& fileName) const;
79         Tizen::Graphics::Bitmap* GetBitmapN(void* pBuffer, const Tizen::Graphics::FloatDimension& size) const;
80         bool IsGlMode(void) const;
81         void DumpBuffer(unsigned int pixmap);
82
83         void OnAppWidgetCreated(livebox* pAppWidget);
84         void OnAppWidgetUpdated(livebox* pAppWidget);
85         void OnAppWidgetDeleted(livebox* pAppWidget);
86         void OnAppWidgetPinUpChanged(livebox* pAppWidget);
87         void OnAppWidgetPopupUpdated(livebox* pAppWidget);
88
89         static int OnAppWidgetEventReceived(livebox* pAppWidget, livebox_event_type eventType, void* pData);
90         static int OnAppWidgetFaultReceived(livebox_fault_type faultType, const char* pAppId, const char* pFilename, const char *pFuncName, void* pData);
91         static void OnAppWidgetActivated(livebox* pAppWidget, int ret, void* pData);
92         static void OnAppWidgetAdded(livebox* pAppWidget, int ret, void* pData);
93         static void OnAppWidgetDeleted(livebox *pAppWidget, int ret, void* pData);
94         static void OnAppWidgetResized(livebox* pAppWidget, int ret, void* pData);
95
96         class _FrameEventListener
97                 : public Tizen::Ui::Controls::_IFrameEventListener
98         {
99         private:
100                 virtual void OnFrameActivated(const Tizen::Ui::Controls::_Frame& source);
101                 virtual void OnFrameDeactivated(const Tizen::Ui::Controls::_Frame& source);
102                 virtual void OnFrameMinimized(const Tizen::Ui::Controls::_Frame& source);
103                 virtual void OnFrameRestored(const Tizen::Ui::Controls::_Frame& source);
104         };
105
106 private:
107         struct _EventHandlerDeleter
108         {
109                 typedef int pointer;
110
111                 void operator()(int)
112                 {
113                         livebox_unset_event_handler(OnAppWidgetEventReceived);
114                 }
115         };
116
117         struct _FaultEventHandlerDeleter
118         {
119                 typedef int pointer;
120
121                 void operator()(int)
122                 {
123                         livebox_unset_fault_handler(OnAppWidgetFaultReceived);
124                 }
125         };
126
127         std::unique_ptr<Tizen::Base::Collection::HashMapT<livebox*, _AppWidgetView*> > __pViewMap;
128         std::unique_ptr<Tizen::Graphics::_ICoordinateSystemTransformer> __pCoordinateTransformer;
129         std::unique_ptr<int, _EventHandlerDeleter> __eventHandler;
130         std::unique_ptr<int, _FaultEventHandlerDeleter> __faultEventHandler;
131         std::unique_ptr<_FrameEventListener> __pFrameEventListener;
132         bool __glMode;
133         std::unique_ptr<_AppWidgetBuffer> __pAppWidgetBuffer;
134 };
135
136 }} // Tizen::Shell
137
138 #endif // _FSHELL_INTERNAL_APPWIDGET_VIEW_MANAGER_H_