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