Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_Colorf.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 /**
19  * @file                FUi_Colorf.h
20  * @brief               Header file of _Colorf class
21  *
22  * This file contains declarations _Colorf class.
23  */
24
25 #ifndef _FUI_INTERNAL_COLORF_H_
26 #define _FUI_INTERNAL_COLORF_H_
27
28 #include <FBaseErrors.h>
29
30 namespace Tizen { namespace Ui
31 {
32
33 class _Colorf
34 {
35 public:
36         _Colorf(void) { __r = __g = __b = 0.0f;__a = 1.0f;}
37         _Colorf(float red, float green, float blue, float alpha)
38                 : __r(red)
39                 , __g(green)
40                 , __b(blue)
41                 , __a(alpha)
42         {
43         }
44         _Colorf(const _Colorf& color)
45         {
46                 __r = color.__r;
47                 __g = color.__g;
48                 __b = color.__b;
49                 __a = color.__a;
50         }
51
52         virtual ~_Colorf(void) {}
53
54         _Colorf& operator =(const _Colorf& color)
55         {
56                 if (&color != this)
57                 {
58                         __r = color.__r;
59                         __g = color.__g;
60                         __b = color.__b;
61                         __a = color.__a;
62                 }
63
64                 return *this;
65         }
66
67         bool operator !=(const _Colorf& color) const
68         {
69                 return (__r != color.__r) || (__g != color.__g) || (__b != color.__b) || (__a != color.__a);
70         }
71
72         bool operator ==(const _Colorf& color) const
73         {
74                 // CHECKME: need float compare ???
75                 return (__r == color.__r) && (__g == color.__g) && (__b == color.__b) && (__a == color.__a);
76         }
77
78         result SetRGBAColor(float r, float g, float b, float a)
79         {
80                 __r = r;
81                 __g = g;
82                 __b = b;
83                 __a = a;
84                 return E_SUCCESS;
85         }
86
87         float& Red(void) { return __r;}
88         float& Green(void) { return __g;}
89         float& Blue(void) { return __b;}
90         float& Alpha(void) { return __a;}
91
92         float Red(void) const { return __r;}
93         float Green(void) const { return __g;}
94         float Blue(void) const { return __b;}
95         float Alpha(void) const { return __a;}
96
97 private:
98         float __r;
99         float __g;
100         float __b;
101         float __a;
102 };
103
104 }}
105
106 #endif  // Tizen::Ui
107