Merge "Change the way to conver Mbs to Wcs and vice versa" into tizen_2.1
[platform/framework/native/appfw.git] / src / app / FApp_AppResourceImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
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 /**
19  * @file        FApp_AppResourceImpl.h
20  * @brief       This is the header file of the _AppResourceImpl class.
21  */
22
23 #ifndef _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
24 #define _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_
25
26 #include <FBaseObject.h>
27 #include <FBaseString.h>
28
29 #include <FGrpBitmapCommon.h>
30
31 namespace Tizen { namespace Base { namespace Collection { class HashMap; } } }
32 namespace Tizen { namespace Graphics { class Bitmap; } }
33
34 namespace Tizen { namespace App
35 {
36
37 class AppResource;
38 class _AppResourceString;
39 class _IAppResourceBitmap;
40
41 enum AppResourceBy
42 {
43         APP_RESOURCE_DEFAULT,
44         APP_RESOURCE_BY_APP_ID,
45         APP_RESOURCE_BY_LIBRARY_NAME,
46         APP_RESOURCE_BITMAP
47 };
48
49 class _AppResourceImpl
50         : public Tizen::Base::Object
51 {
52 public:
53         /**
54         * This is the destructor for this class.
55         *
56         * @since                1.0
57         */
58         virtual ~_AppResourceImpl(void);
59
60         /**
61         * Gets the string at the specified resource ID.
62         *
63         * @since                1.0
64         * @return               An error code
65         * @param[in]    resourceId              The resource ID describing the String resource
66         * @param[out]   loadedString    The string obtained from the loaded application resource
67         * @exception    E_SUCCESS                                 The method was successful.
68         * @exception    E_FAILURE                       The argument passed is not found.
69         * @exception    E_INVALID_ARG                   The argument passed to a method contains an invalid resource ID.
70         */
71         result GetString(const Tizen::Base::String& resourceId, Tizen::Base::String& loadedString);
72
73         /**
74         * Gets the Bitmap at the specified path. @n
75         * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
76         * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
77         * Then, the system will first look for the image file in the folder specific to the current device resolution such as
78         * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
79         * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
80         * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
81         *
82         * @since                1.1
83         *
84         * @return               A Bitmap instance generated from the specified file
85         * @param[in]    imagePath                               The relative path starting from the directory "/res/screen-density-XXX/", @n
86         *                                       where A and B represents the screen width and height of the supported device models, respectively.
87         * @param[in]    pixelFormat                             The pixel format of the resulting bitmap
88         * @exception    E_SUCCESS                               The method was successful.
89         * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
90         * @exception    E_UNSUPPORTED_FORMAT    The image file format or specified pixel format is not supported.
91         * @exception    E_OUT_OF_MEMORY                 Insufficient memory.
92         * @exception    E_FILE_NOT_FOUND                The specified file could not be found.
93         * @exception    E_SYSTEM                                A system error occurred.
94         */
95         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat);
96
97         /**
98         * Gets the Bitmap at the specified path. @n
99         * This method interprets the given resource path and reads the best matching image file for the current device resolution. @n
100         * To load bitmap image from a file, you give the name of file as the input parameter not the file path (Ex: "img.png").
101         * Then, the system will first look for the image file in the folder specific to the current device resolution such as
102         * '320x480' and if the file does not exist, it will then search the folder that corresponds to the current screen density,
103         * such as 'ScreenDensity-Middle'. After searching density folder, all other density folders are searched in the order high to low.
104         * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
105         *
106         * In this method, the system decides the proper pixel format and whether to use chroma key composition to enable transparency. @n
107         * If the input image file has the alpha channel, the pixel format is set to Tizen::Graphics::BITMAP_PIXEL_FORMAT_ARGB8888.
108         * Otherwise, the pixel format is set to BITMAP_PIXEL_FORMAT_RGB565 and the masking color of the bitmap is set to magenta, Tizen::Graphics::Color(255, 0, 255). @n
109         * Typically, a WVGA Tizen device would support alpha channel, while WQVGA device would support bitmap with masking color, to support transparency.
110         * You can place a 32-bit version of the resource and a 16-bit version in the WQVGA resource folder at the same folder. To distinguish the pixel format, you can use a postfix '@@16' such as 'image@@.bmp'.
111         * If you don't use postfix, this API would load the correct image and set the pixel format from the image file, that is appropriate for the current device. @n
112         * Currently supported image formats are JPEG, GIF, PNG, BMP, TIFF, and WBMP.
113         *
114         * @since                1.1
115         *
116         * @return               A Bitmap instance generated from the specified file.
117         * @param[in]    imagePath                               The relative path starting from the density directory "/res/screen-density-XXX/", @n
118         *                                       where A and B represents the width and height of the screen of the supported device models, respectively
119         * @exception    E_SUCCESS                               The method was successful.
120         * @exception    E_INVALID_ARG                   A specified input parameter is invalid.
121         * @exception    E_UNSUPPORTED_FORMAT    The image file format is not supported.
122         * @exception    E_OUT_OF_MEMORY                 Insufficient memory.
123         * @exception    E_FILE_NOT_FOUND                The specified file could not be found.
124         * @exception    E_SYSTEM                                A system error occurred.
125         */
126         Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath);
127
128         static void Reinitialize(void);
129
130         /**
131         * Gets the AppResoruce instance pointer.
132         *
133         * @since  2.0
134         * @return An AppResoruce instance pointer, if successful @n
135         *                 @c null, if it fails
136         */
137         static _AppResourceImpl* GetInstance(void);
138
139         static AppResource* GetInstanceN(AppResourceBy type, const Tizen::Base::String& value = L"");
140         static _IAppResourceBitmap* Get_IAppResourceBitmapN(AppResourceBy type, const Tizen::Base::String& value = L"");
141
142         static void ReinitializeAll(void);
143         static result ReleaseInstance(const Tizen::Base::String& key);
144
145         static Tizen::Graphics::Bitmap* GetNonScalingBitmapN(const Tizen::Base::String& imagePath);
146 private:
147         /**
148         * This is the default constructor for this class.
149         *
150         * @since        1.0
151         */
152         _AppResourceImpl(void);
153
154         /**
155         * This is the copy constructor for this class.
156         *
157         * @since        1.0
158         */
159         _AppResourceImpl(const _AppResourceImpl& source);
160
161         /**
162          * This is the assignment operator for this class.
163          */
164         _AppResourceImpl& operator =(const _AppResourceImpl& source);
165
166 private:
167         _AppResourceString* __p_AppResourceString;
168         _IAppResourceBitmap* __p_IAppResourceBitmap;
169
170         AppResourceBy __type;
171         Tizen::Base::String __value;
172
173         static Tizen::Base::Collection::HashMap* __pContainer;
174
175 }; // _AppResourceImpl
176
177 } } // Tizen::App
178
179 #endif // _FAPP_INTERNAL_APP_RESOURCE_IMPL_H_