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