Subversion Repositories Kolibri OS

Rev

Rev 8944 | Rev 9439 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8944 Rev 8949
1
#ifndef INCLUDE_GUI_H
1
#ifndef INCLUDE_GUI_H
2
#define INCLUDE_GUI_H
2
#define INCLUDE_GUI_H
3
 
3
 
4
#ifndef INCLUDE_KOLIBRI_H
4
#ifndef INCLUDE_KOLIBRI_H
5
#include "../lib/kolibri.h"
5
#include "../lib/kolibri.h"
6
#endif
6
#endif
7
 
7
 
8
#ifndef INCLUDE_STRING_H
8
#ifndef INCLUDE_STRING_H
9
#include "../lib/strings.h"
9
#include "../lib/strings.h"
10
#endif
10
#endif
11
 
11
 
12
#ifndef INCLUDE_RGB_H
12
#ifndef INCLUDE_RGB_H
13
#include "../lib/patterns/rgb.h"
13
#include "../lib/patterns/rgb.h"
14
#endif
14
#endif
15
 
15
 
16
#ifndef INCLUDE_MATH_H
16
#ifndef INCLUDE_MATH_H
17
#include "../lib/math.h"
17
#include "../lib/math.h"
18
#endif
18
#endif
19
 
19
 
20
#include "../lib/gui/tabs.h"
20
#include "../lib/gui/tabs.h"
21
#include "../lib/gui/sensor.h"
21
#include "../lib/gui/sensor.h"
22
#include "../lib/gui/more_less_box.h"
22
#include "../lib/gui/more_less_box.h"
23
 
23
 
24
#ifndef INCLUDE_CHECKBOX
24
#ifndef INCLUDE_CHECKBOX
25
#include "../lib/gui/checkbox.h"
25
#include "../lib/gui/checkbox.h"
26
#endif
26
#endif
27
 
27
 
28
#include "../lib/gui/child_window.h"
28
#include "../lib/gui/child_window.h"
29
#include "../lib/gui/text_view_area.h"
29
#include "../lib/gui/text_view_area.h"
30
 
30
 
31
#ifndef INCLUDE_MENU_H
31
#ifndef INCLUDE_MENU_H
32
#include "../lib/gui/menu.h"
32
#include "../lib/gui/menu.h"
33
#endif
33
#endif
34
 
34
 
35
:int last_free_button_id = 1000;
35
:int last_free_button_id = 1000;
36
:int GetFreeButtonId()
36
:int GetFreeButtonId()
37
{
37
{
38
	last_free_button_id++;
38
	last_free_button_id++;
39
	return last_free_button_id;
39
	return last_free_button_id;
40
}
40
}
41
 
41
 
42
:void DrawRectangle(dword x,y,w,h,color1)
42
:void DrawRectangle(dword x,y,w,h,color1)
43
{
43
{
44
	DrawRectangle3D(x,y,w,h,color1,color1);
44
	DrawRectangle3D(x,y,w,h,color1,color1);
45
	/*
45
	/*
46
	DrawBar(x,y,w,1,color1);
46
	DrawBar(x,y,w,1,color1);
47
	DrawBar(x,y+h,w,1,color1);
47
	DrawBar(x,y+h,w,1,color1);
48
	DrawBar(x,y,1,h,color1);
48
	DrawBar(x,y,1,h,color1);
49
	DrawBar(x+w,y,1,h+1,color1);
49
	DrawBar(x+w,y,1,h+1,color1);
50
	*/
50
	*/
51
}
51
}
52
 
52
 
53
:void DrawWideRectangle(dword x,y,w,h,boder,color1)
53
:void DrawWideRectangle(dword x,y,w,h,boder,color1)
54
{
54
{
55
	DrawBar(x, y, w, boder, color1);
55
	DrawBar(x, y, w, boder, color1);
56
	DrawBar(x, y+h-boder, w, boder, color1);
56
	DrawBar(x, y+h-boder, w, boder, EDX);
57
	DrawBar(x, y+boder, boder, h-boder-boder, color1);
57
	DrawBar(x, y+boder, boder, h-boder-boder, EDX);
58
	DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1);
58
	DrawBar(x+w-boder, y+boder, boder, h-boder-boder, EDX);
59
}
59
}
60
 
60
 
61
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
61
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
62
{
62
{
63
	DrawBar(x,y,w+1,1,color1);
63
	DrawBar(x,y,w+1,1,color1);
64
	DrawBar(x,y+1,1,h-1,color1);
64
	DrawBar(x,y+1,1,h-1,EDX);
65
	DrawBar(x+w,y+1,1,h,color2);
65
	DrawBar(x+w,y+1,1,h,color2);
66
	DrawBar(x,y+h,w,1,color2);
66
	DrawBar(x,y+h,w,1,EDX);
67
}
67
}
68
 
68
 
69
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
69
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
70
{
70
{
71
	dword tx = -strlen(text)*8+w/2+x;
71
	dword tx = -strlen(text)*8+w/2+x;
72
	dword ty = h/2-7+y;
72
	dword ty = h/2-7+y;
73
	DefineButton(x,y,w,h,id,color_b);
73
	DefineButton(x,y,w,h,id,color_b);
74
	WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text);
74
	WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text);
75
	WriteText(tx,ty,0x90,color_t,text);
75
	WriteText(tx,ty,0x90,color_t,text);
76
}
76
}
77
 
77
 
78
:int active_button_id = 0;
78
:int active_button_id = 0;
79
:int DrawStandartCaptButton(dword x, y, id, text)
79
:int DrawStandartCaptButton(dword x, y, id, text)
80
{
80
{
81
	#define padding_v 5
81
	#define padding_v 5
82
	#define padding_h 15
82
	#define padding_h 15
83
	#define right_margin 12
83
	#define right_margin 12
84
	#define h padding_v + padding_v + 16 //16 font height
84
	#define h padding_v + padding_v + 16 //16 font height
85
	int tx = x + padding_h;
85
	int tx = x + padding_h;
86
	int ty = y + padding_v+1;
86
	int ty = y + padding_v+1;
87
	int tw = strlen(text)*8;
87
	int tw = strlen(text)*8;
88
	int w = tw + padding_h + padding_h;
88
	int w = tw + padding_h + padding_h;
89
	unsigned darker_color = MixColors(sc.button,0,230);
89
	unsigned darker_color = MixColors(sc.button,0,230);
90
 
90
 
91
 
91
 
92
	DefineButton(x,y,w,h,id,sc.button);
92
	DefineButton(x,y,w,h,id,sc.button);
93
 
93
 
94
	WriteText(tx+1,ty+1,0x90,darker_color,text);
94
	WriteText(tx+1,ty+1,0x90,darker_color,text);
95
	WriteText(tx,ty,0x90,sc.button_text,text);
95
	WriteText(tx,ty,0x90,sc.button_text,text);
96
 
96
 
97
	if (active_button_id==id) {
97
	if (active_button_id==id) {
98
		DrawBar(tx,ty+15,tw,1, darker_color);
98
		DrawBar(tx,ty+15,tw,1, darker_color);
99
		DrawBar(tx,ty+14,tw,1, sc.button_text);
99
		DrawBar(tx,ty+14,tw,1, sc.button_text);
100
	}
100
	}
101
 
101
 
102
	return w + right_margin;
102
	return w + right_margin;
103
}
103
}
104
 
104
 
105
/* UNSTABLE
105
/* UNSTABLE
106
:unsigned LightenDarkenColor(dword color, amt) {
106
:unsigned LightenDarkenColor(dword color, amt) {
107
	dword r = color >> 16 + amt << 16;
107
	dword r = color >> 16 + amt << 16;
108
	dword b = color >> 8 & 0x00FF + amt << 8;
108
	dword b = color >> 8 & 0x00FF + amt << 8;
109
	dword g = color & 0x0000FF + amt;
109
	dword g = color & 0x0000FF + amt;
110
	return g | b | r ;
110
	return g | b | r ;
111
}
111
}
112
*/
112
*/
113
 
113
 
114
:void ActiveButtonSwitch(int min, max)
114
:void ActiveButtonSwitch(int min, max)
115
{
115
{
116
	active_button_id++;
116
	active_button_id++;
117
	if (active_button_id>max) || (active_button_id
117
	if (active_button_id>max) || (active_button_id
118
}
118
}
119
 
119
 
120
:void WriteTextCenter(dword x,y,w,color_t,text)
120
:void WriteTextCenter(dword x,y,w,color_t,text)
121
{
121
{
122
	WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
122
	WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
123
}
123
}
124
 
124
 
125
:void DrawCircle(int x, y, r, color)
125
:void DrawCircle(int x, y, r, color)
126
{
126
{
127
	int i;
127
	int i;
128
	float px=0, py=r, ii = r * 3.1415926 * 2;
128
	float px=0, py=r, ii = r * 3.1415926 * 2;
129
	FOR (i = 0; i < ii; i++)
129
	FOR (i = 0; i < ii; i++)
130
	{
130
	{
131
        PutPixel(px + x, y - py, color);
131
        PutPixel(px + x, y - py, color);
132
        px = py / r + px;
132
        px = py / r + px;
133
        py = -px / r + py;
133
        py = -px / r + py;
134
	}
134
	}
135
}
135
}
136
 
136
 
137
:void DrawEditBox(dword edit_box_pointer)
137
:void DrawEditBox(dword edit_box_pointer)
138
{
138
{
139
	dword x,y,w,h,bg;
139
	dword x,y,w,h,bg;
140
	ESI = edit_box_pointer;
140
	ESI = edit_box_pointer;
141
	x = ESI.edit_box.left;
141
	x = ESI.edit_box.left;
142
	y = ESI.edit_box.top;
142
	y = ESI.edit_box.top;
143
	w = ESI.edit_box.width+1;
143
	w = ESI.edit_box.width+1;
144
	h = 22;
144
	h = 22;
145
	if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
145
	if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
146
	edit_box_draw  stdcall (edit_box_pointer);
146
	edit_box_draw  stdcall (edit_box_pointer);
147
	DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg);
147
	DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg);
148
	DrawRectangle(x-2, y-2, w+3, h+3, sc.work_graph);
148
	DrawRectangle(x-2, y-2, w+3, h+3, sc.work_graph);
149
	DrawRectangle3D(x-3, y-3, w+5, h+5, sc.work_dark, sc.work_light);
149
	DrawRectangle3D(x-3, y-3, w+5, h+5, sc.work_dark, sc.work_light);
150
}
150
}
151
 
151
 
152
#define DOT_W 37 
152
#define DOT_W 37 
153
:void DrawFileBox(dword edit_box_pointer, title, btn)
153
:void DrawFileBox(dword edit_box_pointer, title, btn)
154
{
154
{
155
	dword x,y,w,h,bg,t;
155
	dword x,y,w,h,bg,t;
156
	ESI = edit_box_pointer;
156
	ESI = edit_box_pointer;
157
	x = ESI.edit_box.left;
157
	x = ESI.edit_box.left;
158
	y = ESI.edit_box.top;
158
	y = ESI.edit_box.top;
159
	w = ESI.edit_box.width+1;
159
	w = ESI.edit_box.width+1;
160
	h = 22;
160
	h = 22;
161
 
161
 
162
	if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
162
	if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
163
	edit_box_draw  stdcall (edit_box_pointer);
163
	edit_box_draw  stdcall (edit_box_pointer);
164
	DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg);
164
	DrawRectangle3D(x-1, y-1, w+1, h+1, 0xE7E7E7, bg);
165
	DrawRectangle(x-2, y-2, w+3, h+3, sc.work_graph);
165
	DrawRectangle(x-2, y-2, w+3, h+3, sc.work_graph);
166
	DrawRectangle3D(x-3, y-3, w+DOT_W+5, h+5, sc.work_dark, sc.work_light);
166
	DrawRectangle3D(x-3, y-3, w+DOT_W+5, h+5, sc.work_dark, sc.work_light);
167
 
167
 
168
	WriteText(x-2, y-19, 0x90, sc.work_text, title);
168
	WriteText(x-2, y-19, 0x90, sc.work_text, title);
169
	DrawCaptButton(x+w+1, y-2, DOT_W, h+3, btn, sc.button, sc.button_text, "...");
169
	DrawCaptButton(x+w+1, y-2, DOT_W, h+3, btn, sc.button, sc.button_text, "...");
170
}
170
}
171
 
171
 
172
:void DrawEditBoxPos(dword x,y, edit_box_pointer)
172
:void DrawEditBoxPos(dword x,y, edit_box_pointer)
173
{
173
{
174
	ESI = edit_box_pointer;
174
	ESI = edit_box_pointer;
175
	ESI.edit_box.left = x;
175
	ESI.edit_box.left = x;
176
	ESI.edit_box.top = y;
176
	ESI.edit_box.top = y;
177
	DrawEditBox(dword edit_box_pointer);
177
	DrawEditBox(dword edit_box_pointer);
178
}
178
}
179
 
179
 
180
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, progress_percent)
180
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, progress_percent)
181
{
181
{
182
	int progress_w;
182
	int progress_w;
183
	static int fill_old;
183
	static int fill_old;
184
	    
184
	    
185
	//if (progress_percent<=0) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;}
185
	//if (progress_percent<=0) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;}
186
	if (progress_percent<=0) || (progress_percent>=100) return;
186
	if (progress_percent<=0) || (progress_percent>=100) return;
187
	
187
	
188
	DrawRectangle(st_x, st_y, st_w,st_h, col_border);
188
	DrawRectangle(st_x, st_y, st_w,st_h, col_border);
189
	DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
189
	DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
190
 
190
 
191
	if (progress_percent>0) && (progress_percent<=100)
191
	if (progress_percent>0) && (progress_percent<=100)
192
	{
192
	{
193
		progress_w = st_w - 3 * progress_percent / 100;
193
		progress_w = st_w - 3 * progress_percent / 100;
194
		DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
194
		DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
195
		DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
195
		DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
196
	}
196
	}
197
}
197
}
198
 
198
 
199
:void DrawLink(dword x,y,font_type,btn_id, inscription)
199
:void DrawLink(dword x,y,font_type,btn_id, inscription)
200
{
200
{
201
	int w;
201
	int w;
202
	WriteText(x,y,font_type,0x4E00E7,inscription);
202
	WriteText(x,y,font_type,0x4E00E7,inscription);
203
	if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*8;
203
	if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*8;
204
	DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
204
	DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
205
	DrawBar(x,y+8,w,1,0x4E00E7);
205
	DrawBar(x,y+8,w,1,0x4E00E7);
206
}
206
}
207
 
207
 
208
:void PutShadow(dword x,y,w,h,skinned, signed strength)
208
:void PutShadow(dword x,y,w,h,skinned, signed strength)
209
{
209
{
210
	proc_info wForm;
210
	proc_info wForm;
211
	dword shadow_buf = mem_Alloc(w*h*3);
211
	dword shadow_buf = mem_Alloc(w*h*3);
212
 	GetProcessInfo(#wForm, SelfInfo);
212
 	GetProcessInfo(#wForm, SelfInfo);
213
	CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
213
	CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
214
	ShadowImage(shadow_buf, w, h, strength);
214
	ShadowImage(shadow_buf, w, h, strength);
215
	_PutImage(x,y,w,h,shadow_buf);
215
	_PutImage(x,y,w,h,shadow_buf);
216
	mem_Free(shadow_buf);
216
	mem_Free(shadow_buf);
217
}
217
}
218
 
218
 
219
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
219
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
220
{
220
{
221
	DrawRectangle(x,y,w,h,col_border);
221
	DrawRectangle(x,y,w,h,col_border);
222
	DrawBar(x+1,y+1,w-1,1,0xFFFfff);
222
	DrawBar(x+1,y+1,w-1,1,0xFFFfff);
223
	DrawBar(x+1,y+2,1,h-2,0xFFFfff);
223
	DrawBar(x+1,y+2,1,h-2,EDX);
224
	if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
224
	if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
225
	DrawPopupShadow(x,y,w,h-1,skinned);
225
	DrawPopupShadow(x,y,w,h-1,skinned);
226
}
226
}
227
 
227
 
228
:void Draw3DPopup(dword x,y,w,h)
228
:void Draw3DPopup(dword x,y,w,h)
229
{
229
{
230
	DrawRectangle3D(x,y,w,h, sc.work_dark, sc.work_graph);
230
	DrawRectangle3D(x,y,w,h, sc.work_dark, sc.work_graph);
231
	DrawBar(x+1,y+1,w-1,1,sc.work_light);
231
	DrawBar(x+1,y+1,w-1,1,sc.work_light);
232
	DrawBar(x+1,y+2,1,h-2,sc.work_light);
232
	DrawBar(x+1,y+2,1,h-2,sc.work_light);
233
	DrawPopupShadow(x,y,w,h-1,0);
233
	DrawPopupShadow(x,y,w,h-1,0);
234
}
234
}
235
 
235
 
236
:void DrawPopupShadow(dword x,y,w,h,skinned)
236
:void DrawPopupShadow(dword x,y,w,h,skinned)
237
{
237
{
238
	PutShadow(w+x+1,y,1,h+2,skinned,2);
238
	PutShadow(w+x+1,y,1,h+2,skinned,2);
239
	PutShadow(w+x+2,y+1,1,h+2,skinned,1);
239
	PutShadow(w+x+2,y+1,1,h+2,skinned,1);
240
	PutShadow(x,y+h+2,w+2,1,skinned,2);
240
	PutShadow(x,y+h+2,w+2,1,skinned,2);
241
	PutShadow(x+1,y+h+3,w+1,1,skinned,1);
241
	PutShadow(x+1,y+h+3,w+1,1,skinned,1);
242
}
242
}
243
 
243
 
244
:dword GrayScaleImage(dword color_image, w, h)
244
:dword GrayScaleImage(dword color_image, w, h)
245
{
245
{
246
	dword i,gray,to,rr,gg,bb;
246
	dword i,gray,to,rr,gg,bb;
247
	to = w*h*3 + color_image;
247
	to = w*h*3 + color_image;
248
	for (i = color_image; i < to; i+=3)
248
	for (i = color_image; i < to; i+=3)
249
	{
249
	{
250
		rr = DSBYTE[i];
250
		rr = DSBYTE[i];
251
		gg = DSBYTE[i+1];
251
		gg = DSBYTE[i+1];
252
		bb = DSBYTE[i+2];
252
		bb = DSBYTE[i+2];
253
		gray = rr*rr;
253
		gray = rr*rr;
254
		gray += gg*gg;
254
		gray += gg*gg;
255
		gray += bb*bb;
255
		gray += bb*bb;
256
		gray = sqrt(gray) / 3;
256
		gray = sqrt(gray) / 3;
257
		DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
257
		DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
258
	}
258
	}
259
	return gray;
259
	return gray;
260
}
260
}
261
 
261
 
262
:void ShadowImage(dword color_image, w, h, signed strength)
262
:void ShadowImage(dword color_image, w, h, signed strength)
263
{
263
{
264
	byte col;
264
	byte col;
265
	dword to;
265
	dword to;
266
	strength = 10 - strength;
266
	strength = 10 - strength;
267
	to = w*h*3 + color_image;
267
	to = w*h*3 + color_image;
268
	for ( ; color_image < to; color_image++)
268
	for ( ; color_image < to; color_image++)
269
	{
269
	{
270
		col = math.min(strength * DSBYTE[color_image] / 10, 255);
270
		col = math.min(strength * DSBYTE[color_image] / 10, 255);
271
		DSBYTE[color_image] = col;
271
		DSBYTE[color_image] = col;
272
	}
272
	}
273
}
273
}
274
 
274
 
275
:void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h)
275
:void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h)
276
{
276
{
277
	dword next_word_pointer = strchr(text_pointer, '\n');
277
	dword next_word_pointer = strchr(text_pointer, '\n');
278
	if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h);
278
	if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h);
279
	ESBYTE[next_word_pointer] = NULL;
279
	ESBYTE[next_word_pointer] = NULL;
280
	WriteText(dword x, y, byte fontType, dword color, text_pointer);
280
	WriteText(dword x, y, byte fontType, dword color, text_pointer);
281
	ESBYTE[next_word_pointer] = '\n';
281
	ESBYTE[next_word_pointer] = '\n';
282
}
282
}
283
 
283
 
284
:void DrawOvalBorder(dword x,y,w,h, light,dark,right,dots)
284
:void DrawOvalBorder(dword x,y,w,h, light,dark,right,dots)
285
{
285
{
286
	DrawBar(x+1,    y,     w, 1,   light);
286
	DrawBar(x+1,    y,     w, 1,   light);
287
	DrawBar(x+1,    y+h+1, w, 1,   dark);
287
	DrawBar(x+1,    y+h+1, w, 1,   dark);
288
	DrawBar(x,      y+1,   1, h-1, light);
288
	DrawBar(x,      y+1,   1, h-1, light);
289
	DrawBar(x+w+1,  y+2,   1, h-2, right);
289
	DrawBar(x+w+1,  y+2,   1, h-2, right);
290
 
290
 
291
	PutPixel(x,     y,     dots);
291
	PutPixel(x,     y,     dots);
292
	PutPixel(x+w+1, y+h+1, dots);
292
	PutPixel(x+w+1, y+h+1, EDX);
293
	PutPixel(x,     y+h+1, dots);
293
	PutPixel(x,     y+h+1, EDX);
294
	PutPixel(x+w+1, y,     dots);
294
	PutPixel(x+w+1, y,     EDX);
295
	
295
	
296
	PutPixel(x,     y+h, dark);
296
	PutPixel(x,     y+h, dark);
297
	PutPixel(x+w+1, y+1, light);
297
	PutPixel(x+w+1, y+1, light);
298
	PutPixel(x+w+1, y+h, dark);	
298
	PutPixel(x+w+1, y+h, dark);	
299
}
299
}
300
 
300
 
301
:bool skin_is_dark()
301
:bool skin_is_dark()
302
{
302
{
303
	dword gray;
-
 
304
	dword color_image = #sc.work;
303
	ESI = #sc.work;
305
 
304
 
306
	gray = DSBYTE[color_image]*DSBYTE[color_image];
305
	EDI = DSBYTE[ESI]*DSBYTE[ESI];
307
	gray += DSBYTE[color_image+1]*DSBYTE[color_image+1];
306
	EDI += DSBYTE[ESI+1]*DSBYTE[ESI+1];
308
	gray += DSBYTE[color_image+2]*DSBYTE[color_image+2];
-
 
309
	gray = sqrt(gray) / 3;
307
	EDI += DSBYTE[ESI+2]*DSBYTE[ESI+2];
310
 
308
 
311
	if (gray < 65) {
309
	if (sqrt(EDI) / 3 < 65) {
312
		return true; 
310
		return true; 
313
	} else {
311
	} else {
314
		return false;
312
		return false;
315
	}
313
	}
316
}
314
}
317
 
315
 
318
//this function increase falue and return it
316
//this function increase falue and return it
319
//useful for list of controls which goes one after one
317
//useful for list of controls which goes one after one
320
:struct incn
318
:struct incn
321
{
319
{
322
	dword n;
320
	dword n;
323
	dword inc(dword _addition);
321
	dword inc(dword _addition);
324
	dword set(dword _new_val);
322
	dword set(dword _new_val);
325
};
323
};
326
 
324
 
327
:dword incn::inc(dword _addition)
325
:dword incn::inc(dword _addition)
328
{
326
{
329
	n += _addition;
327
	n += _addition;
330
	return n;
328
	return n;
331
}
329
}
332
 
330
 
333
:dword incn::set(dword _new_val)
331
:dword incn::set(dword _new_val)
334
{
332
{
335
	n =_new_val;
333
	n =_new_val;
336
	return n;
334
	return n;
337
}
335
}
338
 
336
 
339
//block with hover
337
//block with hover
340
struct block {
338
struct block {
341
	int x,y,w,h;
339
	int x,y,w,h;
342
	bool hovered();
340
	bool hovered();
343
	void set_size();
341
	void set_size();
344
};
342
};
345
 
343
 
346
:bool block::hovered() {
344
:bool block::hovered() {
347
	if ((mouse.x>=x) && (mouse.y>=y) 
345
	if ((mouse.x>=x) && (mouse.y>=y) 
348
	&& (mouse.y<=y+h) && (mouse.x<=x+w)) 
346
	&& (mouse.y<=y+h) && (mouse.x<=x+w)) 
349
		return true;
347
		return true;
350
	return false;
348
	return false;
351
}
349
}
352
 
350
 
353
:void block::set_size(dword _x, _y, _w, _h)
351
:void block::set_size(dword _x, _y, _w, _h)
354
{
352
{
355
	x=_x; 
353
	x=_x; 
356
	y=_y;
354
	y=_y;
357
	w=_w;
355
	w=_w;
358
	h=_h;
356
	h=_h;
359
}
357
}
360
 
358
 
361
 
359
 
362
 
360
 
363
 
361
 
364
 
362
 
365
#endif
363
#endif
366
>
364
>