libyui  3.3.2
YColor.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YColor.h
20 
21  Author: Stefan Hundhammer <sh@suse.de>
22 
23 /-*/
24 
25 #ifndef YColor_h
26 #define YColor_h
27 
28 typedef unsigned char uchar;
29 
30 
31 /**
32  * Helper class to define an RGB color.
33  **/
34 class YColor
35 {
36 public:
37  /**
38  * Constructor.
39  **/
40  YColor( uchar red, uchar green, uchar blue )
41  : _red ( red )
42  , _green( green )
43  , _blue ( blue )
44  , _undef( false )
45  {}
46 
47  /**
48  * Default constructor: Create "undefined" color.
49  **/
51  : _red( 0 ), _green( 0 ), _blue( 0 )
52  , _undef( true )
53  {}
54 
55  /**
56  * Return the red component (0: none, 255: bright red).
57  **/
58  uchar red() const { return _red; }
59 
60  /**
61  * Return the green component (0: none, 255: bright green).
62  **/
63  uchar green() const { return _green; }
64 
65  /**
66  * Return the blue component (0: none, 255: bright blue).
67  **/
68  uchar blue() const { return _blue; }
69 
70  /**
71  * Return 'true' if this color is undefined.
72  **/
73  bool isUndefined() const { return _undef; }
74 
75  /**
76  * Return 'true' if this color is defined.
77  **/
78  bool isDefined() const { return ! _undef; }
79 
80 private:
81 
82  uchar _red;
83  uchar _green;
84  uchar _blue;
85 
86  bool _undef;
87 };
88 
89 
90 #endif // YColor_h
uchar red() const
Return the red component (0: none, 255: bright red).
Definition: YColor.h:58
bool isUndefined() const
Return &#39;true&#39; if this color is undefined.
Definition: YColor.h:73
bool isDefined() const
Return &#39;true&#39; if this color is defined.
Definition: YColor.h:78
uchar green() const
Return the green component (0: none, 255: bright green).
Definition: YColor.h:63
Helper class to define an RGB color.
Definition: YColor.h:34
YColor()
Default constructor: Create "undefined" color.
Definition: YColor.h:50
YColor(uchar red, uchar green, uchar blue)
Constructor.
Definition: YColor.h:40
uchar blue() const
Return the blue component (0: none, 255: bright blue).
Definition: YColor.h:68