xref: /inferno-os/libtk/colrs.c (revision f94b359d339cfcefb3725fe7c0e78211443815b4)
1 #include "lib9.h"
2 #include "draw.h"
3 #include "tk.h"
4 
5 #define RGB(R,G,B) ((R<<24)|(G<<16)|(B<<8)|(0xff))
6 
7 enum
8 {
9 	tkBackR		= 0xdd,		/* Background base color */
10 	tkBackG 	= 0xdd,
11 	tkBackB 	= 0xdd,
12 
13 	tkSelectR	= 0xb0,		/* Check box selected color */
14 	tkSelectG	= 0x30,
15 	tkSelectB	= 0x60,
16 
17 	tkSelectbgndR	= 0x40,		/* Selected item background */
18 	tkSelectbgndG	= 0x40,
19 	tkSelectbgndB	= 0x40
20 };
21 
22 typedef struct Coltab Coltab;
23 struct Coltab {
24 	int	c;
25 	ulong rgba;
26 	int shade;
27 };
28 
29 static Coltab coltab[] =
30 {
31 	TkCbackgnd,
32 		RGB(tkBackR, tkBackG, tkBackB),
33 		TkSameshade,
34 	TkCbackgndlght,
35 		RGB(tkBackR, tkBackG, tkBackB),
36 		TkLightshade,
37 	TkCbackgnddark,
38 		RGB(tkBackR, tkBackG, tkBackB),
39 		TkDarkshade,
40 	TkCactivebgnd,
41 		RGB(tkBackR+0x10, tkBackG+0x10, tkBackB+0x10),
42 		TkSameshade,
43 	TkCactivebgndlght,
44 		RGB(tkBackR+0x10, tkBackG+0x10, tkBackB+0x10),
45 		TkLightshade,
46 	TkCactivebgnddark,
47 		RGB(tkBackR+0x10, tkBackG+0x10, tkBackB+0x10),
48 		TkDarkshade,
49 	TkCactivefgnd,
50 		RGB(0, 0, 0),
51 		TkSameshade,
52 	TkCforegnd,
53 		RGB(0, 0, 0),
54 		TkSameshade,
55 	TkCselect,
56 		RGB(tkSelectR, tkSelectG, tkSelectB),
57 		TkSameshade,
58 	TkCselectbgnd,
59 		RGB(tkSelectbgndR, tkSelectbgndG, tkSelectbgndB),
60 		TkSameshade,
61 	TkCselectbgndlght,
62 		RGB(tkSelectbgndR, tkSelectbgndG, tkSelectbgndB),
63 		TkLightshade,
64 	TkCselectbgnddark,
65 		RGB(tkSelectbgndR, tkSelectbgndG, tkSelectbgndB),
66 		TkDarkshade,
67 	TkCselectfgnd,
68 		RGB(0xff, 0xff, 0xff),
69 		TkSameshade,
70 	TkCdisablefgnd,
71 		RGB(0x88, 0x88, 0x88),
72 		TkSameshade,
73 	TkChighlightfgnd,
74 		RGB(0, 0, 0),
75 		TkSameshade,
76 	TkCtransparent,
77 		DTransparent,
78 		TkSameshade,
79 	-1,
80 };
81 
82 void
tksetenvcolours(TkEnv * env)83 tksetenvcolours(TkEnv *env)
84 {
85 	Coltab *c;
86 
87 	c = &coltab[0];
88 	while(c->c != -1) {
89 		env->colors[c->c] = tkrgbashade(c->rgba, c->shade);
90 		env->set |= (1<<c->c);
91 		c++;
92 	}
93 }
94