2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef HERE_GRAPHIC_COLOR_H
18 #define HERE_GRAPHIC_COLOR_H
20 #include "common/HereMaps_global.h"
21 #include "base/BaseObject.h"
23 TIZEN_MAPS_BEGIN_NAMESPACE
25 class EXPORT_API Color;
29 * @brief This template code makes a 32-bit combination from each color component.
32 * The following example demonstrates how to use this template code.
36 * #include <FGraphics.h>
38 * using namespace Tizen::Graphics;
40 * // 0xFFFF00FF: Opaque magenta
41 * const unsigned int MY_COLOR1 = Color32<255, 0, 255>::Value;
43 * // 0x80FF0000: Red with 50% opacity
44 * const unsigned int MY_COLOR2 = Color32<255, 0, 0, 128>::Value;
48 template <unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 0xFF>
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)
63 * Defines the color ID.
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. */
83 * @brief This class encapsulates a color.
87 * @final This class is not intended for extension.
89 * The %Color class provides an ARGB (Alpha, Red, Green, Blue) color model.
91 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/graphics/color.htm">Color</a>.
93 class Color : public Object
98 * This is the default constructor for this class.
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.
110 * @param[in] rhs An instance of %Color
112 Color(const Color& rhs);
115 * Initializes the instance of %Color with the specified ARGB values.
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
124 Color(byte r, byte g, byte b, byte a = 0xFF);
127 * Initializes the instance of %Color with the specified RGB value.
131 * @param[in] rgb The RGB color value
132 * @param[in] hasAlpha Set to @c true if @c rgb contains an alpha value, @n
135 Color(unsigned int rgb, bool hasAlpha = true);
138 * This is the destructor for this class.
142 virtual ~Color(void);
147 * Checks whether the two instances of %Color are equal.
151 * @return @c true if the values of the two instances of %Color are equal, @n
153 * @param[in] rhs An instance of %Color
155 bool operator ==(const Color& rhs) const;
158 * Checks whether the two instances of %Color are not equal.
162 * @return @c true if the values of the two instances of %Color are not equal, @n
164 * @param[in] rhs An instance of %Color
167 bool operator !=(const Color& rhs) const;
170 * Assigns the values of the RGB components of the specified instance to the current instance of %Color.
174 * @return The reference to the instance of %Color
175 * @param[in] rhs An instance of %Color
177 Color& operator =(const Color& rhs);
182 * Checks whether the current instance of %Color equals the specified instance of %Color.
186 * @return @c true if the values of the current instance is equal to the value of the specified instance, @n
188 * @param[in] rhs An instance of %Color
190 * - This method overrides Tizen::Base::Object::Equals().
191 * - This method uses the values of the RGB components to compare the two instances.
193 virtual bool Equals(const Object& rhs) const;
196 * Gets the hash value of the current instance of %Color.
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.
204 virtual long GetHashCode(void) const;
209 * Gets the value of the alpha component of the current instance of %Color.
213 * @return A @c byte representation of the alpha component of the current instance of %Color
215 byte GetAlpha(void) const;
218 * Gets the value of the red component of the current instance of %Color.
222 * @return A @c byte representation of the red component of the current instance of %Color
224 byte GetRed(void) const;
227 * Gets the value of the blue component of the current instance of %Color.
231 * @return A @c byte representation of the blue component of the current instance of %Color
233 byte GetBlue(void) const;
236 * Gets the value of the green component of the current instance of %Color.
240 * @return A @c byte representation of the green component of the current instance of %Color
242 byte GetGreen(void) const;
245 * Gets the ARGB components of the current instance of %Color.
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
254 void GetColorComponents(byte& r, byte& g, byte& b, byte& a) const;
257 * Gets the 32-bit integer value of the current instance of %Color.
261 * @return An @c unsigned integer value representing the current instance of %Color
263 unsigned int GetRGB32(void) const;
266 * Sets the value of the alpha component of the current instance of %Color.
270 * @param[in] a The new value of the alpha component
272 void SetAlpha(byte a);
275 * Sets the value of the red component of the current instance of %Color.
279 * @param[in] r The new value of the red component
284 * Sets the value of the green component of the current instance of %Color.
288 * @param[in] g The new value of the green component
290 void SetGreen(byte g);
293 * Sets the value of the blue component of the current instance of %Color.
297 * @param[in] b The new value of the blue component
299 void SetBlue(byte b);
302 * Sets the values of the ARGB components of the current instance of %Color.
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
311 void SetColorComponents(byte r, byte g, byte b, byte a = 0xFF);
314 * Sets the current instance of %Color to the specified 32-bit integer value.
318 * @param[in] rgb The new RGB color value
319 * @param[in] hasAlpha @c true if @c rgb contains alpha value, @n
322 void SetRGB32(unsigned int rgb, bool hasAlpha = true);
325 * Gets the %Color object for the specified color.
328 * @return The %Color object
329 * @param[in] colorId The enum value for the specified color
331 static Color GetColor(ColorId colorId);
337 * This attribute is pre-defined. Its value is black.
339 * @brief <i> [Deprecated] </i>
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).
346 const static Color COLOR_BLACK;
350 * This attribute is pre-defined. Its value is blue.
352 * @brief <i> [Deprecated] </i>
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).
359 const static Color COLOR_BLUE;
363 * This attribute is pre-defined. Its value is cyan.
365 * @brief <i> [Deprecated] </i>
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).
372 const static Color COLOR_CYAN;
376 * This attribute is pre-defined. Its value is green.
378 * @brief <i> [Deprecated] </i>
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).
385 const static Color COLOR_GREEN;
389 * This attribute is pre-defined. Its value is grey.
391 * @brief <i> [Deprecated] </i>
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).
398 const static Color COLOR_GREY;
402 * This attribute is pre-defined. Its value is magenta.
404 * @brief <i> [Deprecated] </i>
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).
411 const static Color COLOR_MAGENTA;
415 * This attribute is pre-defined. Its value is red.
417 * @brief <i> [Deprecated] </i>
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).
424 const static Color COLOR_RED;
428 * This attribute is pre-defined. Its value is violet.
430 * @brief <i> [Deprecated] </i>
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).
437 const static Color COLOR_VIOLET;
441 * This attribute is pre-defined. Its value is yellow.
443 * @brief <i> [Deprecated] </i>
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).
450 const static Color COLOR_YELLOW;
454 * This attribute is pre-defined. Its value is white.
456 * @brief <i> [Deprecated] </i>
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).
463 const static Color COLOR_WHITE;
467 unsigned int __color;
469 friend class _ColorImpl;
472 // This variable is for internal use only.
473 // Using this variable can cause behavioral, security-related, and consistency-related issues in the application.
477 class _ColorImpl * __pImpl;
481 TIZEN_MAPS_END_NAMESPACE
483 #endif /* HERE_GRAPHIC_COLOR_H */