Subversion Repositories Kolibri OS

Rev

Rev 9693 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9693 Rev 9854
Line 10... Line 10...
10
//                                                   //
10
//                                                   //
11
//===================================================//
11
//===================================================//
Line 12... Line 12...
12
 
12
 
13
dword picked_color;
13
dword picked_color;
-
 
14
char picked_color_string[7];
-
 
15
char picked_rgb_string[12];
-
 
16
 
14
char picked_color_string[7];
17
#define PICKED_SIZE 48
15
#define FORM_W 167
18
#define LABEL_RGB_W 97
16
#define FORM_H 60
19
#define PAD 11
-
 
20
#define PICKED_X PAD + LABEL_RGB_W + PAD
17
#define PICKED_SIZE 42
21
 
18
#define PICKED_PADDING FORM_H - PICKED_SIZE / 2
22
#define FORM_W PICKED_X + PICKED_SIZE + PAD + 1
-
 
23
#define FORM_H PAD + PICKED_SIZE + PAD + 3
19
#define PICKED_X FORM_W - PICKED_SIZE - PICKED_PADDING
24
 
-
 
25
#define BUTTON_CLOSE    1
20
#define BUTTON_CLOSE 1
26
#define BUTTON_PICK     2
21
#define BUTTON_COPY  2
27
#define BUTTON_COPY_HEX 3
-
 
28
#define BUTTON_COPY_RGB 4
-
 
29
 
-
 
30
#define COLOR_WIN_BG   0xD6D7DA
-
 
31
#define COLOR_PANE_BG  0xFFFfff
-
 
32
#define COLOR_3D_LIGHT 0xADAAA9
Line 22... Line 33...
22
#define BUTTON_PICK  3
33
#define COLOR_3D_DARK  0x888888
23
 
34
 
24
//===================================================//
35
//===================================================//
25
//                                                   //
36
//                                                   //
Line 47... Line 58...
47
			break;
58
			break;
Line 48... Line 59...
48
 
59
 
49
		case evButton:
60
		case evButton:
50
			@GetButtonID();
61
			@GetButtonID();
51
			if (EAX == BUTTON_CLOSE) ExitProcess();
62
			if (EAX == BUTTON_CLOSE) ExitProcess();
-
 
63
			else if (EAX == BUTTON_COPY_HEX) EventCopyHex();
52
			if (EAX == BUTTON_COPY) EventCopyHex();
64
			else if (EAX == BUTTON_COPY_RGB) EventCopyRgb();
53
			if (EAX == BUTTON_PICK) pick_active = true;
65
			else if (EAX == BUTTON_PICK) { pick_active = true; EventActivatePick(); }
Line 54... Line 66...
54
			break;
66
			break;
55
 
67
 
56
		case evKey:
68
		case evKey:
Line 66... Line 78...
66
	}
78
	}
67
}
79
}
Line 68... Line 80...
68
 
80
 
69
void draw_window()
81
void draw_window()
70
{
82
{
71
	DrawRectangle3D(0, 0, FORM_W, FORM_H, 0xCCCccc, 0x888888);
83
	DrawRectangle(0, 0, FORM_W, FORM_H, COLOR_3D_DARK);
-
 
84
	DrawRectangle(1, 1, FORM_W-2, FORM_H-2, COLOR_PANE_BG);
72
	DrawRectangle3D(1, 1, FORM_W-2, FORM_H-2, 0xCCCccc, 0x888888);
85
	DrawRectangle(2, 2, FORM_W-4, FORM_H-4, COLOR_3D_LIGHT);
73
	DrawBar(2,2,FORM_W-3,FORM_H-3,0xFFFfff);
-
 
74
 
86
	DrawBar(3,3,FORM_W-5,FORM_H-5, COLOR_WIN_BG);
75
	DrawRectangle(PICKED_X-2, PICKED_PADDING-2, PICKED_SIZE+3, PICKED_SIZE+3, 0xCBC6C5);
87
	DrawButton3D(PAD, PAD, 58, 21, BUTTON_COPY_HEX, COLOR_PANE_BG);
76
	DefineHiddenButton(PICKED_X-1, PICKED_PADDING-1, PICKED_SIZE+1, PICKED_SIZE+1, BUTTON_PICK);
-
 
77
 
88
	DrawButton3D(PAD, 41, LABEL_RGB_W, 21, BUTTON_COPY_RGB, COLOR_PANE_BG);
78
	DrawCopyButton(67, 11, 35, 14);
-
 
79
 
89
	DrawButton3D(PICKED_X-2, PAD, PICKED_SIZE+3, PICKED_SIZE+3, BUTTON_PICK, -1);
80
	EventUpdateWindowContent();
90
	EventUpdateWindowContent();
Line -... Line 91...
-
 
91
}
-
 
92
 
-
 
93
int DrawButton3D(dword _x, _y, _w, _h, _id, _col)
-
 
94
{
-
 
95
	DefineHiddenButton(_x+1, _y+1, _w-2, _h-2, _id);
-
 
96
	DrawRectangle3D(_x, _y, _w, _h, COLOR_3D_LIGHT, COLOR_3D_DARK);
-
 
97
	DrawRectangle3D(_x+1, _y+1, _w-2, _h-2, COLOR_PANE_BG, COLOR_PANE_BG);
-
 
98
	if (_col) DrawBar(_x+2, _y+2, _w-2, _h-2, _col);
81
}
99
}
82
 
100
 
83
//copy of sprintf() => %A
101
//copy of sprintf() => %A
84
void str2col(dword buf, number)
102
void str2col(dword buf, number)
85
{
103
{
86
	byte s;
104
	byte s;
87
	strlcpy(buf,"000000",6);
105
	strcpy(buf,"000000");
88
	buf+=6;
106
	buf+=6;
89
	while(number)
107
	while(number)
90
	{
108
	{
Line 99... Line 117...
99
void EventUpdateWindowContent()
117
void EventUpdateWindowContent()
100
{
118
{
101
	str2col(#picked_color_string, picked_color);
119
	str2col(#picked_color_string, picked_color);
102
	rgb.DwordToRgb(picked_color);
120
	rgb.DwordToRgb(picked_color);
Line 103... Line 121...
103
	
121
	
Line 104... Line 122...
104
	WriteTextWithBg(12,12, 0xD0, 0x000111, #picked_color_string, 0xFFFfff);
122
	WriteTextWithBg(PAD+5, PAD+4, 0xD0, 0x000111, #picked_color_string, COLOR_PANE_BG);
105
	
123
	
106
	WriteNumber(12,33, 0xD0, 0xff0000, 3<<16, rgb.r);
124
	WriteNumber(PAD+04, PAD+PAD+23, 0xD0, 0xff0000, 3<<16, rgb.r);
Line 107... Line 125...
107
	WriteNumber(44,33, 0xD0, 0x008000, 3<<16, rgb.g);
125
	WriteNumber(PAD+36, PAD+PAD+23, 0xD0, 0x008000, 3<<16, rgb.g);
108
	WriteNumber(75,33, 0xD0, 0x0000ff, 3<<16, rgb.b);
126
	WriteNumber(PAD+67, PAD+PAD+23, 0xD0, 0x0000ff, 3<<16, rgb.b);
Line 109... Line 127...
109
 
127
 
110
	DrawBar(PICKED_X, PICKED_PADDING, PICKED_SIZE, PICKED_SIZE, picked_color);
128
	DrawBar(PICKED_X, PAD+2, PICKED_SIZE, PICKED_SIZE, picked_color);
111
}
129
}
112
 
-
 
113
void DrawCopyButton(dword _x, _y, _w, _h)
130
 
114
{
131
void EventActivatePick()
Line 115... Line 132...
115
	DefineHiddenButton(_x+1, _y+1, _w-2, _h-2, BUTTON_COPY);
132
{
116
	DrawRectangle(_x, _y, _w, _h, 0x777777);
133
	DrawBar(PICKED_X, PAD+2, PICKED_SIZE, PICKED_SIZE, COLOR_PANE_BG);
117
	WriteText(_x+6, _h-8/2 + _y, 0x80, 0x555555, "Copy");
134
	WriteTextWithBg(-4*8+PICKED_SIZE/2+PICKED_X, PICKED_SIZE/2+PAD-5, 0xD0, 0x000111, "Pick", COLOR_PANE_BG);
-
 
135
}
-
 
136
 
-
 
137
void EventCopyHex()
118
}
138
{
119
 
139
	Clipboard__CopyText(#picked_color_string);
-
 
140
	WriteTextWithBg(PAD+5, PAD+4, 0xD0, 0xD100C6, "Copied", COLOR_PANE_BG);
-
 
141
	pause(50);
-
 
142
	draw_window();
-
 
143
}
-
 
144
 
-
 
145
void EventCopyRgb()
-
 
146
{
-
 
147
	strcpy(#picked_rgb_string, "000,000,000");
-
 
148
	rgb2str(#picked_rgb_string, rgb.r);
-
 
149
	rgb2str(#picked_rgb_string+4, rgb.g);
-
 
150
	rgb2str(#picked_rgb_string+8, rgb.b);
-
 
151
	Clipboard__CopyText(#picked_rgb_string);
-
 
152
	WriteTextWithBg(PAD+1, PAD+PAD+23, 0xD0, 0xD100C6, "   Copied   ", COLOR_PANE_BG);
-
 
153
	pause(50);
-
 
154
	draw_window();
-
 
155
}
-
 
156
 
-
 
157
void rgb2str(int _str, _i)
-
 
158
{
-
 
159
	if (_i < 10) {
-
 
160
		ESBYTE[_str+2] = _i + '0';
-
 
161
	} else if (_i < 100) {
-
 
162
		//23
-
 
163
		ESBYTE[_str+1] = _i / 10 + '0';
-
 
164
		ESBYTE[_str+2] = _i % 10 + '0';
-
 
165
	} else {
-
 
166
		//123
-
 
167
		ESBYTE[_str+0] = _i / 100 + '0';
-
 
168
		ESBYTE[_str+1] = _i / 10 % 10 + '0';