Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_ResourceManager.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 /**
18  * @file                FUi_ResourceManager.h
19  * @brief               This is the header file for _ResourceManager class.
20  * @version             3.0
21  *
22  * This header file contains declaration of _ResourceManager class.
23  * The ActionEvent class can call listener's method. So, when event occurred,
24  * application can handle it appropriately.
25  *
26  */
27 #ifndef _FUI_INTERNAL_RESOURCE_MANAGER_H_
28 #define _FUI_INTERNAL_RESOURCE_MANAGER_H_
29
30 #include <FOspConfig.h>
31 #include <FBaseString.h>
32 #include <FGrpBitmap.h>
33 #include "FUi_ControlManager.h"
34
35 namespace Tizen { namespace Base
36 {
37 class Integer;
38 }}//Tizen::Base::
39
40 namespace Tizen { namespace Base { namespace Collection
41 {
42 template<class Type> class ArrayListT;
43 }}}
44
45 namespace Tizen { namespace Graphics
46 {
47 class Bitmap;
48 class Dimension;
49 class Color;
50 class _ICoordinateSystemTransformer;
51 }}//Tizen::Graphics
52
53 namespace Tizen { namespace Ui { namespace _Resource
54 {
55 class StringLoader;
56 class ConfigLoader;
57 class MapContainer;
58 }}}
59
60 namespace Tizen { namespace Ui
61 {
62         namespace Controls { namespace __Internal
63         {
64         const int OVERLAY_REGION_MIN_LENGTH = 16;
65         }}//Tizen::Ui::Controls::__Internal
66
67 #define GET_SHAPE_CONFIG(shapeId, orientation, x)\
68         Tizen::Ui::_ResourceManager::GetInstance()->GetShape(#shapeId, orientation, x);
69
70 #define GET_DIMENSION_CONFIG(dimensionId, orientation, x)\
71         Tizen::Ui::_ResourceManager::GetInstance()->GetDimension(#dimensionId, orientation, x);
72
73 #define GET_COLOR_CONFIG(colorId, x) \
74         Tizen::Ui::_ResourceManager::GetInstance()->GetColor(#colorId, x);
75
76 #define GET_BITMAP_CONFIG_N(bitmapId, pixelFormat, pOutBitmap)\
77         Tizen::Ui::_ResourceManager::GetInstance()->GetBitmapN(#bitmapId, pixelFormat, _CONTROL_ORIENTATION_PORTRAIT, pOutBitmap);
78
79 #define GET_STRING_CONFIG(stringId, string)\
80         Tizen::Ui::_ResourceManager::GetInstance()->GetString(#stringId, string);
81
82 #define GET_FIXED_VALUE_CONFIG(fixedValueId, orientation, x)\
83         Tizen::Ui::_ResourceManager::GetInstance()->GetFixedValue(#fixedValueId, orientation, x);
84
85 #define IS_CUSTOM_BITMAP(bitmapId) \
86         Tizen::Ui::_ResourceManager::GetInstance()->IsCustomBitmap(#bitmapId);
87
88 #define IS_CUSTOM_COLOR(colorId) \
89         Tizen::Ui::_ResourceManager::GetInstance()->IsCustomColor(#colorId);
90
91
92 class _OSP_EXPORT_ _ResourceManager
93 {
94 public:
95         static _ResourceManager* GetInstance(void);
96         result GetBitmapN(const Tizen::Base::String& bitmapId, Tizen::Graphics::BitmapPixelFormat pixelFormat, _ControlOrientation orientation, Tizen::Graphics::Bitmap*& pBitmap);
97         result GetString(const Tizen::Base::String& stringId, Tizen::Base::String& string);
98         result GetColor(const Tizen::Base::String& colorId, Tizen::Graphics::Color& color);
99         result GetShape(const Tizen::Base::String& shapeId, _ControlOrientation orientation, int& value);
100         result GetFixedValue(const Tizen::Base::String& shapeId, _ControlOrientation orientation, int& value);
101         result GetDimension(const Tizen::Base::String& dimensionId, _ControlOrientation orientation, Tizen::Graphics::Dimension& dimension);
102         void GetThemeName(Tizen::Base::String& systemTheme, Tizen::Base::String& userTheme) const;
103         void ReloadTheme(Tizen::Base::String& themeName, bool userdefine);
104         bool IsCustomColor(const Tizen::Base::String& colorId);
105         bool IsCustomBitmap(const Tizen::Base::String& bitmapId);
106
107
108 private:
109         _ResourceManager(void);
110         ~_ResourceManager(void);
111         static void CreateInstance(void);
112
113         _ResourceManager(const _ResourceManager& rhs);
114         _ResourceManager& operator =(const _ResourceManager& rhs);
115
116         enum MapContainerType
117         {
118                 MAP_CONTAINER_TYPE_APP_BASE_PORTRAIT = 0,
119                 MAP_CONTAINER_TYPE_APP_BASE_LANDSCAPE = 1,
120                 MAP_CONTAINER_TYPE_DEFAULT_PORTRAIT = 2,
121                 MAP_CONTAINER_TYPE_DEFAULT_LANDSCAPE = 3,
122                 MAP_CONTAINER_TYPE_MAX = 4,
123         };
124         result GetBitmapInternalN(const Tizen::Base::String& fileName, Tizen::Graphics::BitmapPixelFormat pixelFormat, _ControlOrientation orientation, Tizen::Graphics::Bitmap*& pBitmap);
125         result GetDefaultShapeWithScaling(const Tizen::Base::String& shapeId, _ControlOrientation orientation, Tizen::Base::Integer& integer);
126         result GetDefaultShapeWithScaling(const Tizen::Base::String& shapeId, _ControlOrientation orientation, Tizen::Graphics::Dimension& dimension);
127         result LoadThemeInformation(Tizen::Base::String& systemTheme, Tizen::Base::String& userTheme);
128         bool InitializeTheme(_Resource::MapContainer& mapContainer);
129         void LoadConfig(const Tizen::Base::String& resolution, _Resource::MapContainer& mapContainer);
130         _Resource::MapContainer* GetMapContainer(MapContainerType type);
131         void SetSystemColor(void);
132         Tizen::Base::String FindImagePath(const Tizen::Base::String& fileName, int& findFolder);
133         bool GetDensityDirectory(const Tizen::Base::String directoryName, float scaleFactor);
134         bool GetResolutionDirectory(const Tizen::Base::String directoryName, float scaleFactor);
135
136 private:
137
138         struct ResourceFallbackItem
139         {
140                 float scaleFactor;
141                 Tizen::Base::String directoryName;
142         };
143
144         _Resource::StringLoader* __pStringLoader;
145         _Resource::MapContainer* __pMapContainer[MAP_CONTAINER_TYPE_MAX];
146         Tizen::Graphics::_ICoordinateSystemTransformer* __pTransformer;
147         Tizen::Base::String __appBasePortraitMode;
148         Tizen::Base::String __appBaseLandscapeMode;
149         Tizen::Base::String __targetPortraitMode;
150         Tizen::Base::String __targetLandscapeMode;
151         Tizen::Base::String __defaultPortraitMode;
152         Tizen::Base::String __defaultLandscapeMode;
153         Tizen::Base::String __systemTheme;
154         Tizen::Base::String __userTheme;
155         bool __appliedUserTheme;
156         int __appBaseWidth;
157         int __appBaseHeight;
158         int __targetWidth;
159         int __targetHeight;
160         int __deviceDPI;
161         Tizen::Base::Collection::ArrayListT<ResourceFallbackItem*>* __pFallbackList;
162 };
163
164 }}//Tizen::Ui
165
166 #endif // _FUI_INTERNAL_RESOURCE_MANAGER_H_