graphics header merge
[platform/framework/native/uifw.git] / inc / FGrpColor.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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        FGrpColor.h
20  * @brief       This is the header file for the %Color class.
21  *
22  * This header file contains the declarations of the %Color class.
23  *
24  */
25
26 #ifndef _FGRP_COLOR_H_
27 #define _FGRP_COLOR_H_
28
29 #include <FBaseTypes.h>
30 #include <FBaseObject.h>
31
32 namespace Tizen { namespace Graphics
33 {
34
35 /**
36  * @class    Color32
37  * @brief    This template code makes a 32-bit combination from each color component
38  * @since 2.0
39  *
40  * The following example demonstrates how to use this template code
41  *
42  * @code
43  *
44  *     #include <FGraphics.h>
45  *
46  *     using namespace Tizen::Graphics;
47  *
48  *     // 0xFFFF00FF: Opaque magenta
49  *     const unsigned int MY_COLOR1 = Color32<255, 0, 255>::Value;
50  *
51  *     // 0x80FF0000: Red with 50% opacity
52  *     const unsigned int MY_COLOR2 = Color32<255, 0, 0, 128>::Value;
53  *
54  * @endcode
55  */
56 template <unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 0xFF>
57 struct Color32
58 {
59         enum
60         {
61                 Value = static_cast<unsigned int>(alpha) << 24 |
62                                 static_cast<unsigned int>(red) << 16 |
63                                 static_cast<unsigned int>(green) << 8 |
64                                 static_cast<unsigned int>(blue)
65         };
66 };
67
68 /**
69  * @enum         ColorId
70  *
71  * Defines the color ID.
72  *
73  * @since 2.0
74  */
75 enum ColorId
76 {
77         COLOR_ID_BLACK, /**< This attribute is pre-defined. Its value is black. */
78         COLOR_ID_BLUE, /**< This attribute is pre-defined. Its value is blue. */
79         COLOR_ID_CYAN, /**< This attribute is pre-defined. Its value is cyan. */
80         COLOR_ID_GREEN, /**< This attribute is pre-defined. Its value is green. */
81         COLOR_ID_GREY, /**< This attribute is pre-defined. Its value is grey. */
82         COLOR_ID_MAGENTA, /**< This attribute is pre-defined. Its value is magenta. */
83         COLOR_ID_RED, /**< This attribute is pre-defined. Its value is red. */
84         COLOR_ID_VIOLET, /**< This attribute is pre-defined. Its value is violet. */
85         COLOR_ID_YELLOW, /**< This attribute is pre-defined. Its value is yellow. */
86         COLOR_ID_WHITE /**< This attribute is pre-defined. Its value is white. */
87 };
88
89 /**
90  * @class       Color
91  * @brief       This class encapsulates a color.
92  *
93  * @since       2.0
94  *
95  * @final       This class is not intended for extension.
96  *
97  * The %Color class provides an ARGB (Alpha, Red, Green, Blue) color model.
98  *
99  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/graphics/color.htm">Color</a>.
100  */
101 class _OSP_EXPORT_ Color
102         : public Tizen::Base::Object
103 {
104
105 public:
106         /**
107          * This is the default constructor for this class.
108          *
109          * @since       2.0
110          */
111         Color(void);
112
113         /**
114          * This is the copy constructor for the %Color class. @n
115          * This constructor initializes the instance of %Color with the attributes of the specified instance of %Color.
116          *
117          * @since                       2.0
118          *
119          * @param[in]   rhs     An instance of %Color
120          */
121         Color(const Color& rhs);
122
123         /**
124          * Initializes the instance of %Color with the specified ARGB values.
125          *
126          * @since                       2.0
127          *
128          * @param[in]   r       The red component
129          * @param[in]   g       The green component
130          * @param[in]   b       The blue component
131          * @param[in]   a       The alpha component
132          */
133         Color(byte r, byte g, byte b, byte a = 0xFF);
134
135         /**
136          * Initializes the instance of %Color with the specified RGB value.
137          *
138          * @since                       2.0
139          *
140          * @param[in]   rgb                     The RGB color value
141          * @param[in]   hasAlpha        Set to @c true if @c rgb contains an alpha value, @n
142          *                                              else @c false
143          */
144         Color(unsigned int rgb, bool hasAlpha = true);
145
146         /**
147          * This is the destructor for this class.
148          *
149          * @since       2.0
150          */
151         virtual ~Color(void);
152
153
154 public:
155         /**
156          * Checks whether the two instances of %Color are equal.
157          *
158          * @since                       2.0
159          *
160          * @return              @c true if the values of the two instances of %Color are equal, @n
161          *               else @c false
162          * @param[in]   rhs             An instance of %Color
163          */
164         bool operator ==(const Color& rhs) const;
165
166         /**
167          * Checks whether the two instances of %Color are not equal.
168          *
169          * @since                       2.0
170          *
171          * @return              @c true if the values of the two instances of %Color are not equal, @n
172          *               else @c false
173          * @param[in]   rhs             An instance of %Color
174          *
175          */
176         bool operator !=(const Color& rhs) const;
177
178         /**
179          * Assigns the values of the RGB components of the specified instance to the current instance of %Color.
180          *
181          * @since                       2.0
182          *
183          * @return              The reference to the instance of %Color
184          * @param[in]   rhs             An instance of %Color
185          */
186         Color& operator =(const Color& rhs);
187
188
189 public:
190         /**
191          * Checks whether the current instance of %Color equals the specified instance of %Color.
192          *
193          * @since                       2.0
194          *
195          * @return              @c true if the values of the current instance is equal to the value of the specified instance, @n
196          *               else @c false
197          * @param[in]   rhs             An instance of %Color
198          * @remarks     This method overrides Tizen::Base::Object::Equals(). This method uses the values of the RGB components to compare the two instances.
199          */
200         virtual bool Equals(const Tizen::Base::Object& rhs) const;
201
202         /**
203          * Gets the hash value of the current instance of %Color.
204          *
205          * @since               2.0
206          *
207          * @return              The hash value of the current instance
208          * @remarks     Two equal instances must return the same hash value. For better performance,
209          *                              the used hash function must generate a random distribution for all inputs.
210          */
211         virtual int GetHashCode(void) const;
212
213
214 public:
215         /**
216          * Gets the value of the alpha component of the current instance of %Color.
217          *
218          * @since               2.0
219          *
220          * @return      A @c byte representation of the alpha component of the current instance of %Color
221          */
222         byte GetAlpha(void) const;
223
224         /**
225          * Gets the value of the red component of the current instance of %Color.
226          *
227          * @since               2.0
228          *
229          * @return      A @c byte representation of the red component of the current instance of %Color
230          */
231         byte GetRed(void) const;
232
233         /**
234          * Gets the value of the blue component of the current instance of %Color.
235          *
236          * @since               2.0
237          *
238          * @return      A @c byte representation of the blue component of the current instance of %Color
239          */
240         byte GetBlue(void) const;
241
242         /**
243          * Gets the value of the green component of the current instance of %Color.
244          *
245          * @since               2.0
246          *
247          * @return      A @c byte representation of the green component of the current instance of %Color
248          */
249         byte GetGreen(void) const;
250
251         /**
252          * Gets the ARGB components of the current instance of %Color.
253          *
254          * @since                               2.0
255          *
256          * @param[out]  r       The red component
257          * @param[out]  g       The green component
258          * @param[out]  b       The blue component
259          * @param[out]  a       The alpha component
260          */
261         void GetColorComponents(byte& r, byte& g, byte& b, byte& a) const;
262
263         /**
264          * Gets the 32-bit integer value of the current instance of %Color.
265          *
266          * @since               2.0
267          *
268          * @return      An @c unsigned integer value representing the current instance of %Color
269          */
270         unsigned int GetRGB32(void) const;
271
272         /**
273          * Sets the value of the alpha component of the current instance of %Color.
274          *
275          * @since                       2.0
276          *
277          * @param[in]   a       The new value of the alpha component
278          */
279         void SetAlpha(byte a);
280
281         /**
282          * Sets the value of the red component of the current instance of %Color.
283          *
284          * @since                       2.0
285          *
286          * @param[in]   r       The new value of the red component
287          */
288         void SetRed(byte r);
289
290         /**
291          * Sets the value of the green component of the current instance of %Color.
292          *
293          * @since                       2.0
294          *
295          * @param[in]   g       The new value of the green component
296          */
297         void SetGreen(byte g);
298
299         /**
300          * Sets the value of the blue component of the current instance of %Color.
301          *
302          * @since                       2.0
303          *
304          * @param[in]   b       The new value of the blue component
305          */
306         void SetBlue(byte b);
307
308         /**
309          * Sets the values of the ARGB components of the current instance of %Color.
310          *
311          * @since                       2.0
312          *
313          * @param[in]   r       The red component
314          * @param[in]   g       The green component
315          * @param[in]   b       The blue component
316          * @param[in]   a       The alpha component
317          */
318         void SetColorComponents(byte r, byte g, byte b, byte a = 0xFF);
319
320         /**
321          * Sets the current instance of %Color to the specified 32-bit integer value.
322          *
323          * @since                       2.0
324          *
325          * @param[in]   rgb                     The new RGB color value
326          * @param[in]   hasAlpha        @c true if @c rgb contains alpha value, @n
327                                     else @c false
328          */
329         void SetRGB32(unsigned int rgb, bool hasAlpha = true);
330
331         /**
332          * Return the Color object for the specified color
333          *
334          * @since 2.0
335          * @return      Color   The Color object
336          * @param[in]   colorId The enum value for the specified color
337          */
338         static Color GetColor(ColorId colorId);
339
340
341 public:
342         /**
343          * @if OSPDEPREC
344          * This attribute is pre-defined. Its value is black.
345          *
346          * @brief       <i> [Deprecated] </i>
347          * @since                       2.0
348          *
349          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
350          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_BLACK)
351          * @endif
352          */
353         const static Color COLOR_BLACK;
354
355         /**
356          * @if OSPDEPREC
357          * This attribute is pre-defined. Its value is blue.
358          *
359          * @brief       <i> [Deprecated] </i>
360          * @since                       2.0
361          *
362          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
363          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_BLUE)
364          * @endif
365          */
366         const static Color COLOR_BLUE;
367
368         /**
369          * @if OSPDEPREC
370          * This attribute is pre-defined. Its value is cyan.
371          *
372          * @brief       <i> [Deprecated] </i>
373          * @since                       2.0
374          *
375          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
376          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_CYAN)
377          * @endif
378          */
379         const static Color COLOR_CYAN;
380
381         /**
382          * @if OSPDEPREC
383          * This attribute is pre-defined. Its value is green.
384          *
385          * @brief       <i> [Deprecated] </i>
386          * @since                       2.0
387          *
388          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
389          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_GREEN)
390          * @endif
391          */
392         const static Color COLOR_GREEN;
393
394         /**
395          * @if OSPDEPREC
396          * This attribute is pre-defined. Its value is grey.
397          *
398          * @brief       <i> [Deprecated] </i>
399          * @since                       2.0
400          *
401          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
402          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_GREY)
403          * @endif
404          */
405         const static Color COLOR_GREY;
406
407         /**
408          * @if OSPDEPREC
409          * This attribute is pre-defined. Its value is magenta.
410          *
411          * @brief       <i> [Deprecated] </i>
412          * @since                       2.0
413          *
414          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
415          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_MAGENTA)
416          * @endif
417          */
418         const static Color COLOR_MAGENTA;
419
420         /**
421          * @if OSPDEPREC
422          * This attribute is pre-defined. Its value is red.
423          *
424          * @brief       <i> [Deprecated] </i>
425          * @since                       2.0
426          *
427          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
428          * Instead of us        ing this static constant, it is recommended to use GetColor(COLOR_ID_RED)
429          * @endif
430          */
431         const static Color COLOR_RED;
432
433         /**
434          * @if OSPDEPREC
435          * This attribute is pre-defined. Its value is violet.
436          *
437          * @brief       <i> [Deprecated] </i>
438          * @since                       2.0
439          *
440          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
441          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_VIOLET)
442          * @endif
443          */
444         const static Color COLOR_VIOLET;
445
446         /**
447          * @if OSPDEPREC
448          * This attribute is pre-defined. Its value is yellow.
449          *
450          * @brief       <i> [Deprecated] </i>
451          * @since                       2.0
452          *
453          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
454          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_YELLOW)
455          * @endif
456          */
457         const static Color COLOR_YELLOW;
458
459         /**
460          * @if OSPDEPREC
461          * This attribute is pre-defined. Its value is cwhite.
462          *
463          * @brief       <i> [Deprecated] </i>
464          * @since                       2.0
465          *
466          * @deprecated This object is provided only for backward compatibility and will be deleted in a future release
467          * Instead of using this static constant, it is recommended to use GetColor(COLOR_ID_WHITE)
468          * @endif
469          */
470         const static Color COLOR_WHITE;
471
472
473 private:
474         unsigned int __color;
475
476         friend class _ColorImpl;
477
478         //
479         // This variable is for internal use only.
480         // Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
481         //
482         // @since 2.0
483         //
484         class _ColorImpl * __pImpl;
485
486 }; // Color
487
488 }} // Tizen::Graphics
489
490 #endif //_FGRP_COLOR_H_