Subversion Repositories Kolibri OS

Rev

Rev 5499 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4411 leency 1
//Надо будет переделать на "дерево поиска" или, что-то подобное
2
//будет нечитабельно, зато меньше и быстее
3
 
4
struct color_spec {
5
	char *name;
6
	int rgb;
7
};
8
 
7752 leency 9
dword text_colors[300];
10
dword text_color_index;
11
 
4411 leency 12
struct color_spec color_specs[] = {
5499 leency 13
	"aliceblue",	 0xF0F8FF,
4411 leency 14
	"antiquewhite",  0xFAEBD7,
5499 leency 15
	"aqua", 	 0x00FFFF,
16
	"aquamarine",	 0x7FFFD4,
4411 leency 17
	"azure",		 0xF0FFFF,
18
	"beige",		 0xF5F5DC,
19
	"bisque",		 0xFFE4C4,
20
	"black",		 0x000000,
21
	"blanchedalmond",0xFFEBCD,
5499 leency 22
	"blue", 	 0x0000FF,
23
	"blueviolet",	 0x8A2BE2,
4411 leency 24
	"brown",		 0xA52A2A,
5499 leency 25
	"burlywood",	 0xDEB887,
26
	"cadetblue",	 0x5F9EA0,
27
	"chartreuse",	 0x7FFF00,
28
	"chocolate",	 0xD2691E,
29
	"coral",	 0xFF7F50,
4411 leency 30
	"cornflowerblue",0x6495ED,
31
	"cornsilk",		 0xFFF8DC,
32
	"crimson",		 0xDC143C,
5499 leency 33
	"cyan", 	 0x00FFFF,
4411 leency 34
	"darkblue",	     0x00008B,
35
	"darkcyan",	     0x008B8B,
36
	"darkgoldenrod", 0xB8860B,
37
	"darkgray",	     0xA9A9A9,
5499 leency 38
	"darkgreen",	 0x006400,
39
	"darkkhaki",	 0xBDB76B,
40
	"darkmagenta",	 0x8B008B,
4411 leency 41
	"darkolivegreen",0x556B2F,
5499 leency 42
	"darkorange",	 0xFF8C00,
43
	"darkorchid",	 0x9932CC,
4411 leency 44
	"darkred",		 0x8B0000,
5499 leency 45
	"darksalmon",	 0xE9967A,
4411 leency 46
	"darkseagreen",  0x8FBC8F,
47
	"darkslateblue", 0x483D8B,
48
	"darkslategray", 0x2F4F4F,
49
	"darkturquoise", 0x00CED1,
5499 leency 50
	"darkviolet",	 0x9400D3,
51
	"deeppink",	 0xFF1493,
52
	"deepskyblue",	 0x00BFFF,
53
	"dimgray",	 0x696969,
54
	"dodgerblue",	 0x1E90FF,
55
	"firebrick",	 0xB22222,
56
	"floralwhite",	 0xFFFAF0,
57
	"forestgreen",	 0x228B22,
58
	"fuchsia",	 0xFF00FF,
59
	"gainsboro",	 0xDCDCDC,
60
	"ghostwhite",	 0xF8F8FF,
61
	"gold", 	 0xFFD700,
62
	"goldenrod",	 0xDAA520,
63
	"gray", 	 0x808080,
64
	"green",	 0x008000,
65
	"greenyellow",	 0xADFF2F,
66
	"honeydew",	 0xF0FFF0,
67
	"hotpink",	 0xFF69B4,
68
	"indianred",	 0xCD5C5C,
69
	"indigo",	 0x4B0082,
70
	"ivory",	 0xFFFFF0,
71
	"khaki",	 0xF0E68C,
72
	"lavender",	 0xE6E6FA,
4411 leency 73
	"lavenderblush", 0xFFF0F5,
5499 leency 74
	"lawngreen",	 0x7CFC00,
4411 leency 75
	"lemonchiffon",  0xFFFACD,
5499 leency 76
	"lightblue",	 0xADD8E6,
77
	"lightcoral",	 0xF08080,
78
	"lightcyan",	 0xE0FFFF,
79
	"lightgoldenrodyellow", 0xFAFAD2,
80
	"lightgreen",	 0x90EE90,
81
	"lightgrey",	 0xD3D3D3,
82
	"lightpink",	 0xFFB6C1,
83
	"lightsalmon",	 0xFFA07A,
4411 leency 84
	"lightseagreen", 0x20B2AA,
85
	"lightskyblue",  0x87CEFA,
86
	"lightslategray",0x778899,
87
	"lightsteelblue",0xB0C4DE,
5499 leency 88
	"lightyellow",	 0xFFFFE0,
89
	"lime", 	 0x00FF00,
90
	"limegreen",	 0x32CD32,
91
	"linen",	 0xFAF0E6,
92
	"magenta",	 0xFF00FF,
93
	"maroon",	 0x800000,
4411 leency 94
	"mediumaquamarine",0x66CDAA,
5499 leency 95
	"mediumblue",	 0x0000CD,
4411 leency 96
	"mediumorchid",  0xBA55D3,
97
	"mediumpurple",  0x9370DB,
98
	"mediumseagreen",0x3CB371,
99
	"mediumslateblue",0x7B68EE,
100
	"mediumspringgreen",0x00FA9A,
101
	"mediumturquoise",0x48D1CC,
102
	"mediumvioletred",0xC71585,
103
	"midnightblue",  0x191970,
5499 leency 104
	"mintcream",	 0xF5FFFA,
105
	"mistyrose",	 0xFFE4E1,
4411 leency 106
	"moccasin",	     0xFFE4B5,
5499 leency 107
	"navajowhite",	 0xFFDEAD,
108
	"navy", 	 0x000080,
109
	"oldlace",	 0xFDF5E6,
110
	"olive",	 0x808000,
111
	"olivedrab",	 0x6B8E23,
112
	"orange",	 0xFFA500,
113
	"orangered",	 0xFF4500,
114
	"orchid",	 0xDA70D6,
4411 leency 115
	"palegoldenrod", 0xEEE8AA,
5499 leency 116
	"palegreen",	 0x98FB98,
4411 leency 117
	"paleturquoise", 0xAFEEEE,
118
	"palevioletred", 0xDB7093,
5499 leency 119
	"papayawhip",	 0xFFEFD5,
120
	"peachpuff",	 0xFFDAB9,
121
	"peru", 	 0xCD853F,
122
	"pink", 	 0xFFC0CB,
123
	"plum", 	 0xDDA0DD,
124
	"powderblue",	 0xB0E0E6,
125
	"purple",	 0x800080,
126
	"red",		 0xFF0000,
127
	"rosybrown",	 0xBC8F8F,
128
	"royalblue",	 0x4169E1,
129
	"saddlebrown",	 0x8B4513,
130
	"salmon",	 0xFA8072,
131
	"sandybrown",	 0xF4A460,
132
	"seagreen",	 0x2E8B57,
133
	"seashell",	 0xFFF5EE,
134
	"sienna",	 0xA0522D,
135
	"silver",	 0xC0C0C0,
136
	"skyblue",	 0x87CEEB,
137
	"slateblue",	 0x6A5ACD,
138
	"slategray",	 0x708090,
139
	"snow", 	 0xFFFAFA,
140
	"springgreen",	 0x00FF7F,
141
	"steelblue",	 0x4682B4,
142
	"tan",		 0xD2B48C,
143
	"teal", 	 0x008080,
144
	"thistle",	 0xD8BFD8,
145
	"tomato",	 0xFF6347,
146
	"turquoise",	 0x40E0D0,
147
	"violet",	 0xEE82EE,
148
	"wheat",	 0xF5DEB3,
149
	"white",	 0xFFFFFF,
150
	"whitesmoke",	 0xF5F5F5,
151
	"yellow",	 0xFFFF00,
152
	"yellowgreen",	 0x9ACD32,
4411 leency 153
0};
154
 
155
dword StrToCol(char* htmlcolor)
156
{
157
	dword j=1,
158
		color=0,
159
		textlen=0;
160
	char ch=0x00;
161
 
162
	if (ESBYTE[htmlcolor]<>'#') return text_colors[0];
163
 
164
	textlen = strlen(htmlcolor);
165
 
166
	if (textlen==7) || (textlen==4)
167
	{
168
		FOR (;  j
169
		{
170
			ch=ESBYTE[htmlcolor+j];
171
			IF ((ch>='0') && (ch<='9')) ch -= '0';
172
			IF ((ch>='A') && (ch<='F')) ch -= 'A'-10;
173
			IF ((ch>='a') && (ch<='f')) ch -= 'a'-10;
174
			color = color*0x10 + ch;
175
			if (textlen==4) color = color*0x10 + ch; //#abc ->> #aabbcc (слава википедии!!1)
176
		}
177
		return color;
178
	}
5499 leency 179
 
4411 leency 180
	return text_colors[0];
181
}
182
 
183
dword GetColor(char* color_str)
184
{
185
	int ii;
186
 
187
	if (ESBYTE[color_str] == '#')
188
		return StrToCol(color_str);
189
	else
190
		for (ii=0; color_specs[ii].name!=0; ii++)
191
		{
5499 leency 192
			if (!strcmpi(color_str, color_specs[ii].name)) return color_specs[ii].rgb;
4411 leency 193
		}
194
 
195
	return text_colors[0];
196
}