Color.h
Go to the documentation of this file.
1 /* -*- mode:c++ -*- */
2 
13 #ifndef _Color_H_
14 #define _Color_H_
15 
16 #include "pattern/libhippo.h"
17 
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 namespace hippodraw {
23 
38 {
39 
40 public:
41 
51  enum Value { red, green, blue, yellow, orange, cyan, magenta,
52  black, darkgray, lightgray, white };
53 
54  private:
55 
58  typedef std::map < std::string, Color > ColorMapByName_t;
59 
63 
66  static std::vector < std::string > s_color_names;
67 
69  int m_red;
70 
72  int m_green;
73 
75  int m_blue;
76 
79  static void initColorByNameMap ();
80 
81 public:
82 
86  explicit Color ( int red = 0, int green = 0, int blue = 0 );
87 
90  explicit Color ( Color::Value value );
91 
97  explicit Color ( const std::string & name );
98 
101  static bool isValid ( const std::string & name );
102 
105  static void addColor ( const char * name, const Color & color );
106 
109  static const std::vector < std::string > & colorNames ();
110 
115  void setColor ( const std::string & );
116 
118  void setColor ( int red = 0, int green = 0, int blue = 0 );
119 
122  void setColor ( Color::Value value );
123 
124  int getRed () const;
125 
126  int getGreen () const;
127 
128  int getBlue () const;
129 
133  static Color::Value getColor();
134 
137  static int colorIndex;
138 
139  bool operator==(Color c);
140 
141 };
142 
143 } // namespace hippodraw
144 
145 #endif // _Color_H_

Generated for HippoDraw Class Library by doxygen