4#include "user_colors.h"
5#include "color_types.h"
10ColorScheme global_color_scheme = GLOBAL_COLOR_SCHEME_DAY;
12namespace user_colors {
14ColorScheme GetColorScheme() {
return global_color_scheme; }
16static const char *
const usercolors[] = {
23 "GREEN1;120;255;120;",
"GREEN2; 45;150; 45;",
"GREEN3;200;220;200;",
24 "GREEN4; 0;255; 0;",
"GREEN5;170;254; 0;",
"BLUE1; 170;170;255;",
25 "BLUE2; 45; 45;170;",
"BLUE3; 0; 0;255;",
"GREY1; 200;200;200;",
26 "GREY2; 230;230;230;",
"RED1; 220;200;200;",
"YELO1; 243;229; 47;",
27 "YELO2; 128; 80; 0;",
"TEAL1; 0;128;128;",
31 "UWHIT; 255;255;255;",
38 "DILG0; 255;255;255;",
40 "DILG0; 238;239;242;",
42 "DILG1; 212;208;200;",
43 "DILG2; 255;255;255;",
55 "CHGRF; 163; 180; 183;",
57 "CHYLW; 244; 218; 72;",
58 "CHWHT; 212; 234; 238;",
61 "UINFM; 197; 69; 195;",
63 "UINFG; 104; 228; 86;",
65 "UINFR; 241; 84; 105;",
66 "UINFF; 125; 137; 140;",
75 "NODTA; 163; 180; 183;",
77 "SNDG1; 125; 137; 140;",
79 "SCLBR; 235; 125; 54;",
82 "UIBDR; 125; 137; 140;",
83 "UIBCK; 212; 234; 238;",
84 "UINFB; 58; 120; 240;",
87 "UINFO; 235; 125; 54;",
90 "PLRTE; 220; 64; 37;",
91 "CHMGD; 197; 69; 195;",
95 "DASHB; 255;255;255;",
96 "DASHL; 175;175;175;",
100 "DASHN; 200;120; 0;",
101 "DASH1; 204;204;255;",
102 "DASH2; 122;131;172;",
103 "COMP1; 211;211;211;",
106 "GREY3; 40; 40; 40;",
107 "BLUE4; 100;100;200;",
108 "VIO01; 171; 33;141;",
109 "VIO02; 209;115;213;",
110 "BLUEBACK; 212;234;238;",
111 "LANDBACK; 201;185;122;",
117 "Table:DUSK",
"GREEN1; 60;128; 60;",
"GREEN2; 22; 75; 22;",
118 "GREEN3; 80;100; 80;",
"GREEN4; 0;128; 0;",
"BLUE1; 80; 80;160;",
119 "BLUE2; 30; 30;120;",
"BLUE3; 0; 0;128;",
"GREY1; 100;100;100;",
120 "GREY2; 128;128;128;",
"RED1; 150;100;100;",
"UBLCK; 0; 0; 0;",
121 "UWHIT; 255;255;255;",
"URED; 120; 54; 11;",
"UGREN; 35;110; 20;",
122 "YELO1; 120;115; 24;",
"YELO2; 64; 40; 0;",
"TEAL1; 0; 64; 64;",
123 "GREEN5; 85;128; 0;",
"COMPT; 124;126;121",
125 "CHGRF; 41; 46; 46;",
"UINFM; 58; 20; 57;",
"UINFG; 35; 76; 29;",
126 "UINFF; 41; 46; 46;",
"UINFR; 80; 28; 35;",
"SHIPS; 71; 78; 79;",
127 "CHYLW; 81; 73; 24;",
"CHWHT; 71; 78; 79;",
129 "DILG0; 110;110;110;",
130 "DILG1; 110;110;110;",
132 "DILG3; 130;130;130;",
134 "UITX1; 41; 46; 46;",
137 "UARTE; 64; 64; 64;",
139 "NODTA; 41; 46; 46;",
"CHBLK; 54; 60; 61;",
"SNDG1; 41; 46; 46;",
140 "SNDG2; 71; 78; 79;",
"SCLBR; 75; 38; 19;",
"UIBDR; 54; 60; 61;",
141 "UINFB; 19; 40; 80;",
"UINFD; 71; 78; 79;",
"UINFO; 75; 38; 19;",
142 "PLRTE; 73; 21; 12;",
"CHMGD; 74; 58; 81;",
"UIBCK; 7; 7; 7;",
144 "DASHB; 77; 77; 77;",
145 "DASHL; 54; 54; 54;",
147 "DASHR; 58; 21; 21;",
148 "DASHG; 21; 58; 21;",
149 "DASHN; 100; 50; 0;",
150 "DASH1; 76; 76;113;",
151 "DASH2; 48; 52; 72;",
152 "COMP1; 107;107;107;",
154 "GREY3; 20; 20; 20;",
155 "BLUE4; 80; 80;160;",
156 "VIO01; 128; 25;108;",
"VIO02; 171; 33;141;",
"BLUEBACK; 186;213;235;",
157 "LANDBACK; 201;185;122;",
163 "Table:NIGHT",
"GREEN1; 30; 80; 30;",
"GREEN2; 15; 60; 15;",
164 "GREEN3; 12; 23; 9;",
"GREEN4; 0; 64; 0;",
"BLUE1; 60; 60;100;",
165 "BLUE2; 22; 22; 85;",
"BLUE3; 0; 0; 40;",
"GREY1; 48; 48; 48;",
166 "GREY2; 32; 32; 32;",
"RED1; 100; 50; 50;",
"UWHIT; 255;255;255;",
167 "UBLCK; 0; 0; 0;",
"URED; 60; 27; 5;",
"UGREN; 17; 55; 10;",
168 "YELO1; 60; 65; 12;",
"YELO2; 32; 20; 0;",
"TEAL1; 0; 32; 32;",
169 "GREEN5; 44; 64; 0;",
"COMPT; 48; 49; 51",
170 "DILG0; 80; 80; 80;",
171 "DILG1; 80; 80; 80;",
173 "DILG3; 180; 180; 180;",
174 "DILG4; 220;220;220;",
175 "UITX1; 31; 34; 35;",
178 "UARTE; 64; 64; 64;",
180 "CHGRF; 16; 18; 18;",
"UINFM; 52; 18; 52;",
"UINFG; 22; 24; 7;",
181 "UINFF; 31; 34; 35;",
"UINFR; 59; 17; 10;",
"SHIPS; 37; 41; 41;",
182 "CHYLW; 31; 33; 10;",
"CHWHT; 37; 41; 41;",
184 "NODTA; 7; 7; 7;",
"CHBLK; 31; 34; 35;",
"SNDG1; 31; 34; 35;",
185 "SNDG2; 43; 48; 48;",
"SCLBR; 52; 28; 12;",
"UIBDR; 31; 34; 35;",
186 "UINFB; 21; 29; 69;",
"UINFD; 43; 48; 58;",
"UINFO; 52; 28; 12;",
187 "PLRTE; 66; 19; 11;",
"CHMGD; 52; 18; 52;",
"UIBCK; 7; 7; 7;",
190 "DASHL; 20; 20; 20;",
191 "DASHF; 64; 64; 64;",
192 "DASHR; 70; 15; 15;",
193 "DASHG; 15; 70; 15;",
194 "DASHN; 17; 80; 56;",
195 "DASH1; 48; 52; 72;",
196 "DASH2; 36; 36; 53;",
197 "COMP1; 24; 24; 24;",
199 "GREY3; 10; 10; 10;",
200 "BLUE4; 70; 70;140;",
201 "VIO01; 85; 16; 72;",
"VIO02; 128; 25;108;",
"BLUEBACK; 186;213;235;",
202 "LANDBACK; 201;185;122;",
206static wxArrayPtrVoid *UserColorTableArray = 0;
207static wxArrayPtrVoid *UserColourHashTableArray;
209static int get_static_line(
char *d,
const char *
const *p,
int index,
int n) {
210 if (!strcmp(p[index],
"*****"))
return 0;
212 strncpy(d, p[index], n);
217 const char *
const *p = usercolors;
225 UserColorTableArray =
new wxArrayPtrVoid;
226 UserColourHashTableArray =
new wxArrayPtrVoid;
230 ct->tableName =
new wxString(
"DAY");
231 ct->color =
new wxArrayPtrVoid;
232 UserColorTableArray->Add((
void *)ct);
235 ct->tableName =
new wxString(
"DUSK");
236 ct->color =
new wxArrayPtrVoid;
237 UserColorTableArray->Add((
void *)ct);
240 ct->tableName =
new wxString(
"NIGHT");
241 ct->color =
new wxArrayPtrVoid;
242 UserColorTableArray->Add((
void *)ct);
244 while ((get_static_line(buf, p, index,
sizeof(buf) - 1))) {
245 if (!strncmp(buf,
"Table", 5)) {
246 sscanf(buf,
"Table:%s", TableName);
248 for (
unsigned int it = 0; it < UserColorTableArray->GetCount(); it++) {
249 ctp = (colTable *)(UserColorTableArray->Item(it));
250 if (!strcmp(TableName, ctp->tableName->mb_str())) {
259 while (buf[j] !=
';' && j < 20) {
265 S52color *c =
new S52color;
266 strcpy(c->colName, name);
268 sscanf(&buf[j],
";%i;%i;%i", &R, &G, &B);
281 for (
unsigned int its = 0; its < UserColorTableArray->GetCount(); its++) {
282 wxColorHashMap *phash =
new wxColorHashMap;
283 UserColourHashTableArray->Add((
void *)phash);
285 colTable *ctp = (colTable *)(UserColorTableArray->Item(its));
287 for (
unsigned int ic = 0; ic < ctp->color->GetCount(); ic++) {
288 S52color *c2 = (S52color *)(ctp->color->Item(ic));
290 wxColour c(c2->R, c2->G, c2->B);
291 wxString key(c2->colName, wxConvUTF8);
299 (wxColorHashMap *)UserColourHashTableArray->Item(0);
302 if (!UserColorTableArray)
return;
303 for (
unsigned i = 0; i < UserColorTableArray->GetCount(); i++) {
304 colTable *ct = (colTable *)UserColorTableArray->Item(i);
306 for (
unsigned int j = 0; j < ct->color->GetCount(); j++) {
307 S52color *c = (S52color *)ct->color->Item(j);
311 delete ct->tableName;
317 delete UserColorTableArray;
319 for (
unsigned i = 0; i < UserColourHashTableArray->GetCount(); i++) {
320 wxColorHashMap *phash = (wxColorHashMap *)UserColourHashTableArray->Item(i);
324 delete UserColourHashTableArray;
327wxColorHashMap *GetMapByScheme(
const std::string &scheme_name) {
328 std::string name = scheme_name;
329 if (g_hicon_colors) {
330 if (scheme_name ==
"DAY_HICON")
336 unsigned Usercolortable_index = 0;
337 for (
unsigned int i = 0; i < UserColorTableArray->GetCount(); i++) {
338 colTable *ct = (colTable *)UserColorTableArray->Item(i);
339 if (name == (*ct->tableName)) {
340 return (wxColorHashMap *)UserColourHashTableArray->Item(i);
346wxColor GetDimColor(wxColor c) {
347 if ((global_color_scheme == GLOBAL_COLOR_SCHEME_DAY) ||
348 (global_color_scheme == GLOBAL_COLOR_SCHEME_RGB))
352 if (global_color_scheme == GLOBAL_COLOR_SCHEME_DUSK) factor = 0.5;
353 if (global_color_scheme == GLOBAL_COLOR_SCHEME_NIGHT) factor = 0.25;
355 wxImage::RGBValue rgb(c.Red(), c.Green(), c.Blue());
356 wxImage::HSVValue hsv = wxImage::RGBtoHSV(rgb);
357 hsv.value = hsv.value * factor;
358 wxImage::RGBValue nrgb = wxImage::HSVtoRGB(hsv);
360 return wxColor(nrgb.red, nrgb.green, nrgb.blue);
wxColorHashMap * pcurrent_user_color_hash
Global instance.
Global color handling by name.
Global variables stored in configuration file.