GlsMenu
gls_palette.h
Go to the documentation of this file.
1 
42 #if !defined(GLS_PALETTE_H)
43 #define GLS_PALETTE_H
44 
45 #ifdef WIN32
46 #pragma warning (disable:4786)
47 #endif
48 
49 #include <string>
50 #include "gls_color.h"
51 
52 //----------------------------------------------------------------------------
56 //----------------------------------------------------------------------------
57 namespace GlsPalette
58 {
59  typedef enum
60  {
77  } Color_t;
78 
80  static const char* COLOR_NAME[LAST_COLOR+1] =
81  {
82  "CLEAR",
83  "BLACK",
84  "WHITE",
85  "RED",
86  "GREEN",
87  "DARK_GREEN",
88  "LIGHT_GREEN",
89  "BLUE",
90  "YELLOW",
91  "PALE_YELLOW",
92  "CYAN",
93  "MAGENTA",
94  "BROWN",
95  "AMBER",
96  "GREY"
97  };
98 
100  static const disti::glsColor COLOR[LAST_COLOR+1] =
101  {
102  disti::glsColor(0x00,0x00,0x00,0x00), // Clear
103  disti::glsColor(0x00,0x00,0x00,0xFF), // Black
104  disti::glsColor(0xFF,0xFF,0xFF,0xFF), // White
105  disti::glsColor(0xDF,0x0F,0x0F,0xFF), // Red
106  disti::glsColor(0x00,0xDD,0x00,0xFF), // Green
107  disti::glsColor(0x00,0x77,0x00,0xFF), // Dark Green
108  disti::glsColor(0x00,0xFF,0x00,0xFF), // Light Green
109  disti::glsColor(0x32,0x64,0xFF,0xFF), // Blue
110  disti::glsColor(0xFF,0xFF,0x22,0xFF), // Yellow
111  disti::glsColor(0xFF,0xFF,0x77,0xFF), // Pale Yellow
112  disti::glsColor(0x00,0xFF,0xFF,0xFF), // Cyan
113  disti::glsColor(0xFF,0x00,0x7F,0xFF), // Magenta
114  disti::glsColor(0xB5,0x70,0x40,0xFF), // Brown
115  disti::glsColor(0xFF,0xD2,0x00,0xFF), // Amber
116  disti::glsColor(0x99,0x99,0x99,0xFF) // Grey
117  };
118 
119  static const disti::glsColor& CLEAR = COLOR[eCLEAR];
120  static const disti::glsColor& BLACK = COLOR[eBLACK];
121  static const disti::glsColor& WHITE = COLOR[eWHITE];
122  static const disti::glsColor& RED = COLOR[eRED];
123  static const disti::glsColor& GREEN = COLOR[eGREEN];
124  static const disti::glsColor& DARK_GREEN = COLOR[eDARK_GREEN];
125  static const disti::glsColor& LIGHT_GREEN = COLOR[eLIGHT_GREEN];
126  static const disti::glsColor& BLUE = COLOR[eBLUE];
127  static const disti::glsColor& YELLOW = COLOR[eYELLOW];
128  static const disti::glsColor& PALE_YELLOW = COLOR[ePALE_YELLOW];
129  static const disti::glsColor& CYAN = COLOR[eCYAN];
130  static const disti::glsColor& MAGENTA = COLOR[eMAGENTA];
131  static const disti::glsColor& BROWN = COLOR[eBROWN];
132  static const disti::glsColor& AMBER = COLOR[eAMBER];
133  static const disti::glsColor& GREY = COLOR[eGREY];
134 
135  //------------------------------------------------------------------------
140  //------------------------------------------------------------------------
141  inline const disti::glsColor& ColorFromName(const std::string& name)
142  {
143  Color_t index(eBLACK);
144 
145  for (int i = 0; i <= LAST_COLOR; ++i)
146  {
147  if (name == COLOR_NAME[i])
148  {
149  index = Color_t(i);
150  break;
151  }
152  }
153  return COLOR[index];
154  }
155 } // end namespace
156 
157 //----------------------------------------------------------------------------
158 inline std::istream& operator>>(std::istream& instr, GlsPalette::Color_t& color)
159 {
160  std::string str;
161  instr >> str;
162 
163  color = GlsPalette::eBLACK;
164 
165  for (int i = 0; i <= GlsPalette::LAST_COLOR; ++i)
166  {
167  if (str == GlsPalette::COLOR_NAME[i])
168  {
169  color = GlsPalette::Color_t(i);
170  break;
171  }
172  }
173  return instr;
174 }
175 
176 //----------------------------------------------------------------------------
177 inline std::ostream& operator<<(std::ostream& outstr, GlsPalette::Color_t color)
178 {
179  outstr << GlsPalette::COLOR_NAME[color];
180  return outstr;
181 }
182 
183 
184 #endif // GLS_PALETTE_H
static const disti::glsColor & GREEN
Definition: gls_palette.h:123
static const disti::glsColor & GREY
Definition: gls_palette.h:133
static const disti::glsColor & CLEAR
Definition: gls_palette.h:119
static const disti::glsColor & MAGENTA
Definition: gls_palette.h:130
static const disti::glsColor & BROWN
Definition: gls_palette.h:131
static const disti::glsColor & BLACK
Definition: gls_palette.h:120
static const disti::glsColor & LIGHT_GREEN
Definition: gls_palette.h:125
std::istream & operator>>(std::istream &instr, GlsPalette::Color_t &color)
Definition: gls_palette.h:158
static const disti::glsColor COLOR[LAST_COLOR+1]
Used to convert a color enum into a glsColor value.
Definition: gls_palette.h:100
static const char * COLOR_NAME[LAST_COLOR+1]
Used to convert a string into the proper color enum.
Definition: gls_palette.h:80
static const disti::glsColor & DARK_GREEN
Definition: gls_palette.h:124
std::ostream & operator<<(std::ostream &outstr, GlsPalette::Color_t color)
Definition: gls_palette.h:177
static const disti::glsColor & YELLOW
Definition: gls_palette.h:127
static const disti::glsColor & AMBER
Definition: gls_palette.h:132
static const disti::glsColor & WHITE
Definition: gls_palette.h:121
static const disti::glsColor & BLUE
Definition: gls_palette.h:126
static const disti::glsColor & CYAN
Definition: gls_palette.h:129
const disti::glsColor & ColorFromName(const std::string &name)
Definition: gls_palette.h:141
static const disti::glsColor & RED
Definition: gls_palette.h:122
static const disti::glsColor & PALE_YELLOW
Definition: gls_palette.h:128