4#include "user_colors.h"
5#include "color_types.h"
9ColorScheme global_color_scheme = GLOBAL_COLOR_SCHEME_DAY;
11namespace user_colors {
13ColorScheme GetColorScheme() {
return global_color_scheme; }
15static const char *
const usercolors[] = {
22 "GREEN1;120;255;120;",
"GREEN2; 45;150; 45;",
"GREEN3;200;220;200;",
23 "GREEN4; 0;255; 0;",
"GREEN5;170;254; 0;",
"BLUE1; 170;170;255;",
24 "BLUE2; 45; 45;170;",
"BLUE3; 0; 0;255;",
"GREY1; 200;200;200;",
25 "GREY2; 230;230;230;",
"RED1; 220;200;200;",
"YELO1; 243;229; 47;",
26 "YELO2; 128; 80; 0;",
"TEAL1; 0;128;128;",
30 "UWHIT; 255;255;255;",
37 "DILG0; 255;255;255;",
39 "DILG0; 238;239;242;",
41 "DILG1; 212;208;200;",
42 "DILG2; 255;255;255;",
54 "CHGRF; 163; 180; 183;",
56 "CHYLW; 244; 218; 72;",
57 "CHWHT; 212; 234; 238;",
60 "UINFM; 197; 69; 195;",
62 "UINFG; 104; 228; 86;",
64 "UINFR; 241; 84; 105;",
65 "UINFF; 125; 137; 140;",
74 "NODTA; 163; 180; 183;",
76 "SNDG1; 125; 137; 140;",
78 "SCLBR; 235; 125; 54;",
81 "UIBDR; 125; 137; 140;",
82 "UIBCK; 212; 234; 238;",
83 "UINFB; 58; 120; 240;",
86 "UINFO; 235; 125; 54;",
89 "PLRTE; 220; 64; 37;",
90 "CHMGD; 197; 69; 195;",
94 "DASHB; 255;255;255;",
95 "DASHL; 175;175;175;",
100 "DASH1; 204;204;255;",
101 "DASH2; 122;131;172;",
102 "COMP1; 211;211;211;",
105 "GREY3; 40; 40; 40;",
106 "BLUE4; 100;100;200;",
107 "VIO01; 171; 33;141;",
108 "VIO02; 209;115;213;",
109 "BLUEBACK; 212;234;238;",
110 "LANDBACK; 201;185;122;",
116 "Table:DUSK",
"GREEN1; 60;128; 60;",
"GREEN2; 22; 75; 22;",
117 "GREEN3; 80;100; 80;",
"GREEN4; 0;128; 0;",
"BLUE1; 80; 80;160;",
118 "BLUE2; 30; 30;120;",
"BLUE3; 0; 0;128;",
"GREY1; 100;100;100;",
119 "GREY2; 128;128;128;",
"RED1; 150;100;100;",
"UBLCK; 0; 0; 0;",
120 "UWHIT; 255;255;255;",
"URED; 120; 54; 11;",
"UGREN; 35;110; 20;",
121 "YELO1; 120;115; 24;",
"YELO2; 64; 40; 0;",
"TEAL1; 0; 64; 64;",
122 "GREEN5; 85;128; 0;",
"COMPT; 124;126;121",
124 "CHGRF; 41; 46; 46;",
"UINFM; 58; 20; 57;",
"UINFG; 35; 76; 29;",
125 "UINFF; 41; 46; 46;",
"UINFR; 80; 28; 35;",
"SHIPS; 71; 78; 79;",
126 "CHYLW; 81; 73; 24;",
"CHWHT; 71; 78; 79;",
128 "DILG0; 110;110;110;",
129 "DILG1; 110;110;110;",
131 "DILG3; 130;130;130;",
133 "UITX1; 41; 46; 46;",
136 "UARTE; 64; 64; 64;",
138 "NODTA; 41; 46; 46;",
"CHBLK; 54; 60; 61;",
"SNDG1; 41; 46; 46;",
139 "SNDG2; 71; 78; 79;",
"SCLBR; 75; 38; 19;",
"UIBDR; 54; 60; 61;",
140 "UINFB; 19; 40; 80;",
"UINFD; 71; 78; 79;",
"UINFO; 75; 38; 19;",
141 "PLRTE; 73; 21; 12;",
"CHMGD; 74; 58; 81;",
"UIBCK; 7; 7; 7;",
143 "DASHB; 77; 77; 77;",
144 "DASHL; 54; 54; 54;",
146 "DASHR; 58; 21; 21;",
147 "DASHG; 21; 58; 21;",
148 "DASHN; 100; 50; 0;",
149 "DASH1; 76; 76;113;",
150 "DASH2; 48; 52; 72;",
151 "COMP1; 107;107;107;",
153 "GREY3; 20; 20; 20;",
154 "BLUE4; 80; 80;160;",
155 "VIO01; 128; 25;108;",
"VIO02; 171; 33;141;",
"BLUEBACK; 186;213;235;",
156 "LANDBACK; 201;185;122;",
162 "Table:NIGHT",
"GREEN1; 30; 80; 30;",
"GREEN2; 15; 60; 15;",
163 "GREEN3; 12; 23; 9;",
"GREEN4; 0; 64; 0;",
"BLUE1; 60; 60;100;",
164 "BLUE2; 22; 22; 85;",
"BLUE3; 0; 0; 40;",
"GREY1; 48; 48; 48;",
165 "GREY2; 32; 32; 32;",
"RED1; 100; 50; 50;",
"UWHIT; 255;255;255;",
166 "UBLCK; 0; 0; 0;",
"URED; 60; 27; 5;",
"UGREN; 17; 55; 10;",
167 "YELO1; 60; 65; 12;",
"YELO2; 32; 20; 0;",
"TEAL1; 0; 32; 32;",
168 "GREEN5; 44; 64; 0;",
"COMPT; 48; 49; 51",
169 "DILG0; 80; 80; 80;",
170 "DILG1; 80; 80; 80;",
172 "DILG3; 65; 65; 65;",
173 "DILG4; 220;220;220;",
174 "UITX1; 31; 34; 35;",
177 "UARTE; 64; 64; 64;",
179 "CHGRF; 16; 18; 18;",
"UINFM; 52; 18; 52;",
"UINFG; 22; 24; 7;",
180 "UINFF; 31; 34; 35;",
"UINFR; 59; 17; 10;",
"SHIPS; 37; 41; 41;",
181 "CHYLW; 31; 33; 10;",
"CHWHT; 37; 41; 41;",
183 "NODTA; 7; 7; 7;",
"CHBLK; 31; 34; 35;",
"SNDG1; 31; 34; 35;",
184 "SNDG2; 43; 48; 48;",
"SCLBR; 52; 28; 12;",
"UIBDR; 31; 34; 35;",
185 "UINFB; 21; 29; 69;",
"UINFD; 43; 48; 58;",
"UINFO; 52; 28; 12;",
186 "PLRTE; 66; 19; 11;",
"CHMGD; 52; 18; 52;",
"UIBCK; 7; 7; 7;",
189 "DASHL; 20; 20; 20;",
190 "DASHF; 64; 64; 64;",
191 "DASHR; 70; 15; 15;",
192 "DASHG; 15; 70; 15;",
193 "DASHN; 17; 80; 56;",
194 "DASH1; 48; 52; 72;",
195 "DASH2; 36; 36; 53;",
196 "COMP1; 24; 24; 24;",
198 "GREY3; 10; 10; 10;",
199 "BLUE4; 70; 70;140;",
200 "VIO01; 85; 16; 72;",
"VIO02; 128; 25;108;",
"BLUEBACK; 186;213;235;",
201 "LANDBACK; 201;185;122;",
205static wxArrayPtrVoid *UserColorTableArray = 0;
206static wxArrayPtrVoid *UserColourHashTableArray;
208static int get_static_line(
char *d,
const char *
const *p,
int index,
int n) {
209 if (!strcmp(p[index],
"*****"))
return 0;
211 strncpy(d, p[index], n);
216 const char *
const *p = usercolors;
224 UserColorTableArray =
new wxArrayPtrVoid;
225 UserColourHashTableArray =
new wxArrayPtrVoid;
229 ct->tableName =
new wxString(
"DAY");
230 ct->color =
new wxArrayPtrVoid;
231 UserColorTableArray->Add((
void *)ct);
234 ct->tableName =
new wxString(
"DUSK");
235 ct->color =
new wxArrayPtrVoid;
236 UserColorTableArray->Add((
void *)ct);
239 ct->tableName =
new wxString(
"NIGHT");
240 ct->color =
new wxArrayPtrVoid;
241 UserColorTableArray->Add((
void *)ct);
243 while ((get_static_line(buf, p, index,
sizeof(buf) - 1))) {
244 if (!strncmp(buf,
"Table", 5)) {
245 sscanf(buf,
"Table:%s", TableName);
247 for (
unsigned int it = 0; it < UserColorTableArray->GetCount(); it++) {
248 ctp = (colTable *)(UserColorTableArray->Item(it));
249 if (!strcmp(TableName, ctp->tableName->mb_str())) {
258 while (buf[j] !=
';' && j < 20) {
264 S52color *c =
new S52color;
265 strcpy(c->colName, name);
267 sscanf(&buf[j],
";%i;%i;%i", &R, &G, &B);
280 for (
unsigned int its = 0; its < UserColorTableArray->GetCount(); its++) {
281 wxColorHashMap *phash =
new wxColorHashMap;
282 UserColourHashTableArray->Add((
void *)phash);
284 colTable *ctp = (colTable *)(UserColorTableArray->Item(its));
286 for (
unsigned int ic = 0; ic < ctp->color->GetCount(); ic++) {
287 S52color *c2 = (S52color *)(ctp->color->Item(ic));
289 wxColour c(c2->R, c2->G, c2->B);
290 wxString key(c2->colName, wxConvUTF8);
298 (wxColorHashMap *)UserColourHashTableArray->Item(0);
301 if (!UserColorTableArray)
return;
302 for (
unsigned i = 0; i < UserColorTableArray->GetCount(); i++) {
303 colTable *ct = (colTable *)UserColorTableArray->Item(i);
305 for (
unsigned int j = 0; j < ct->color->GetCount(); j++) {
306 S52color *c = (S52color *)ct->color->Item(j);
310 delete ct->tableName;
316 delete UserColorTableArray;
318 for (
unsigned i = 0; i < UserColourHashTableArray->GetCount(); i++) {
319 wxColorHashMap *phash = (wxColorHashMap *)UserColourHashTableArray->Item(i);
323 delete UserColourHashTableArray;
326wxColorHashMap *GetMapByScheme(
const std::string &scheme_name) {
327 unsigned Usercolortable_index = 0;
328 for (
unsigned int i = 0; i < UserColorTableArray->GetCount(); i++) {
329 colTable *ct = (colTable *)UserColorTableArray->Item(i);
330 if (scheme_name == (*ct->tableName)) {
331 return (wxColorHashMap *)UserColourHashTableArray->Item(i);
337wxColor GetDimColor(wxColor c) {
338 if ((global_color_scheme == GLOBAL_COLOR_SCHEME_DAY) ||
339 (global_color_scheme == GLOBAL_COLOR_SCHEME_RGB))
343 if (global_color_scheme == GLOBAL_COLOR_SCHEME_DUSK) factor = 0.5;
344 if (global_color_scheme == GLOBAL_COLOR_SCHEME_NIGHT) factor = 0.25;
346 wxImage::RGBValue rgb(c.Red(), c.Green(), c.Blue());
347 wxImage::HSVValue hsv = wxImage::RGBtoHSV(rgb);
348 hsv.value = hsv.value * factor;
349 wxImage::RGBValue nrgb = wxImage::HSVtoRGB(hsv);
351 return wxColor(nrgb.red, nrgb.green, nrgb.blue);
wxColorHashMap * pcurrent_user_color_hash
Global instance.
Global color handling by name.