1 /* aguixcolor.hh
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2007-2019 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef AGUIXCOLOR_HH
23 #define AGUIXCOLOR_HH
24 
25 #include "aguixdefs.h"
26 #include <functional>
27 
28 class AGUIXColor {
29 public:
30     typedef enum { USER_COLOR, SYSTEM_COLOR, EXTRA_COLOR } color_type_t;
31 
32     AGUIXColor( int col, color_type_t type = USER_COLOR );
33 
34     int getColor() const;
35     color_type_t getColorType() const;
36 
37     struct compare_func : public std::binary_function<const AGUIXColor&, const AGUIXColor&, bool>
38     {
operator ()AGUIXColor::compare_func39         bool operator() ( const AGUIXColor &c1, const AGUIXColor &c2 ) const
40         {
41             if ( c1.getColorType() == AGUIXColor::SYSTEM_COLOR &&
42                  c2.getColorType() != AGUIXColor::SYSTEM_COLOR ) return true;
43             if ( c1.getColorType() == AGUIXColor::USER_COLOR &&
44                  c2.getColorType() == AGUIXColor::SYSTEM_COLOR ) return false;
45             if ( c1.getColorType() == AGUIXColor::USER_COLOR &&
46                  c2.getColorType() == AGUIXColor::EXTRA_COLOR ) return true;
47             if ( c1.getColorType() == AGUIXColor::EXTRA_COLOR &&
48                  c2.getColorType() != AGUIXColor::EXTRA_COLOR ) return false;
49             return c1.getColor() < c2.getColor();
50         }
51     };
52 private:
53     int m_color;
54     color_type_t m_color_type;
55 };
56 
57 #endif
58