Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5598 pavelyakov 1
#ifndef INCLUDE_GUI_H
2
#define INCLUDE_GUI_H
5676 pavelyakov 3
#print "[include ]\n"
3107 leency 4
 
5598 pavelyakov 5
#ifndef INCLUDE_KOLIBRI_H
6
#include "../lib/kolibri.h"
7
#endif
8
 
9
#ifndef INCLUDE_STRING_H
10
#include "../lib/strings.h"
11
#endif
12
 
4005 leency 13
:void DrawRectangle(dword x,y,w,h,color1)
3067 leency 14
{
3225 leency 15
	if (w<=0) || (h<=0) return;
16
	DrawBar(x,y,w,1,color1);
17
	DrawBar(x,y+h,w,1,color1);
18
	DrawBar(x,y,1,h,color1);
19
	DrawBar(x+w,y,1,h+1,color1);
3067 leency 20
}
21
 
5738 leency 22
:void DrawWideRectangle(dword x,y,w,h,boder,color1)
23
{
24
	if (w<=0) || (h<=0) return;
25
	DrawBar(x, y, w, boder, color1);
26
	DrawBar(x, y+h-boder, w, boder, color1);
27
	DrawBar(x, y+boder, boder, h-boder-boder, color1);
28
	DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1);
29
}
30
 
4005 leency 31
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
3067 leency 32
{
3225 leency 33
	if (w<=0) || (h<=0) return;
34
	DrawBar(x,y,w+1,1,color1);
35
	DrawBar(x,y+1,1,h-1,color1);
36
	DrawBar(x+w,y+1,1,h,color2);
37
	DrawBar(x,y+h,w,1,color2);
3067 leency 38
}
39
 
4005 leency 40
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
3067 leency 41
{
4846 leency 42
	if (id>0) DefineButton(x,y,w,h,id,color_b);
3225 leency 43
	WriteText(-strlen(text)*6+w/2+x+1,h/2-3+y,0x80,color_t,text);
3067 leency 44
}
45
 
4846 leency 46
:void WriteTextCenter(dword x,y,w,color_t,text)
47
{
48
	WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
49
}
50
 
5519 leency 51
:void DrawCircle(int x, y, r, color)
3067 leency 52
{
53
	int i;
54
	float px=0, py=r, ii = r * 3.1415926 * 2;
55
	FOR (i = 0; i < ii; i++)
56
	{
5519 leency 57
        PutPixel(px + x, y - py, color);
3067 leency 58
        px = py / r + px;
59
        py = -px / r + py;
60
	}
3076 leency 61
}
3106 leency 62
 
3319 leency 63
:void CheckBox(dword x,y,w,h, bt_id, text, graph_color, text_color, is_checked)
3106 leency 64
{
65
	DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, graph_color);
5463 leency 66
	WriteText(x+w+8, h / 2 + y -3, 0x80, text_color, text);
3106 leency 67
	DrawRectangle(x, y, w, h, graph_color);
5477 leency 68
	if (is_checked == 0)
3106 leency 69
	{
5477 leency 70
		DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff);
71
		DrawBar(x+2, y+2, w-3, h-3, 0xffffff);
72
	}
73
	else if (is_checked == 1)
74
	{
3106 leency 75
		DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff);
5526 leency 76
		DrawRectangle(x+2, y+2, w-4, h-4, 0xffffff);
77
		DrawBar(x+3, y+3, w-5, h-5, graph_color);
3106 leency 78
	}
5477 leency 79
	else if (is_checked == 2) //not active
3106 leency 80
	{
81
		DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff);
5526 leency 82
		DrawRectangle(x+2, y+2, w-4, h-4, 0xffffff);
83
		DrawBar(x+3, y+3, w-5, h-5, 0x888888);
5477 leency 84
	}
3114 leency 85
}
86
 
5542 leency 87
:void MoreLessBox(dword x,y,s, bt_id_more, bt_id_less, colors_pointer, value, text)
5477 leency 88
{
89
	#define VALUE_FIELD_W 26;
5542 leency 90
	ESI = colors_pointer;
5674 pavelyakov 91
	system.color.work_graph = ESI.COLORS.work_graph;
92
	system.color.work_text = ESI.COLORS.work_text;
93
	system.color.work_button = ESI.COLORS.work_button;
94
	system.color.work_button_text = ESI.COLORS.work_button_text;
5542 leency 95
 
5674 pavelyakov 96
	DrawRectangle(x, y, VALUE_FIELD_W, s, system.color.work_graph);
5477 leency 97
	DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, s-2, 0xDDDddd, 0xffffff);
98
	DrawBar(x+2, y+2, VALUE_FIELD_W-3, s-3, 0xffffff);
5526 leency 99
	WriteText(x+6, s / 2 + y -3, 0x80, 0x000000, itoa(value));
5477 leency 100
 
5674 pavelyakov 101
	DrawCaptButton(VALUE_FIELD_W + x + 1,     y, s, s, bt_id_more, system.color.work_button, system.color.work_button_text, "+");
102
	DrawCaptButton(VALUE_FIELD_W + x + s + 2, y, s, s, bt_id_less, system.color.work_button, system.color.work_button_text, "-");
103
	WriteText(x+VALUE_FIELD_W+s+s+10, s / 2 + y -3, 0x80, system.color.work_text, text);
5477 leency 104
}
105
 
4686 leency 106
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent)
3114 leency 107
{
3225 leency 108
	int progress_w;
3114 leency 109
	static int fill_old;
110
 
3363 leency 111
	//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;}
112
	if (progress_percent<=0) || (progress_percent>=100) return;
3114 leency 113
 
114
	DrawRectangle(st_x, st_y, st_w,st_h, col_border);
115
	DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
3225 leency 116
 
117
	if (progress_percent>0) && (progress_percent<=100)
118
	{
119
		progress_w = st_w - 3 * progress_percent / 100;
120
		DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
121
		DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
122
	}
3363 leency 123
}
124
 
125
:void DrawLink(dword x,y,font_type,btn_id, inscription)
126
{
127
	int w;
128
	WriteText(x,y,font_type,0x4E00E7,inscription);
129
	if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7;
130
	DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
131
	DrawBar(x,y+8,w,1,0x4E00E7);
132
}
133
 
3991 leency 134
:void PutShadow(dword x,y,w,h,skinned,strength)
3363 leency 135
{
136
	proc_info wForm;
137
	dword shadow_buf, skin_height;
138
	shadow_buf = mem_Alloc(w*h*3);
139
 	GetProcessInfo(#wForm, SelfInfo);
3991 leency 140
	CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
3363 leency 141
	ShadowImage(shadow_buf, w, h, strength);
142
	_PutImage(x,y,w,h,shadow_buf);
143
	mem_Free(shadow_buf);
144
}
145
 
3991 leency 146
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
147
{
148
	DrawRectangle(x,y,w,h,col_border);
3992 leency 149
	DrawBar(x+1,y+1,w-1,1,0xFFFfff);
4029 leency 150
	DrawBar(x+1,y+2,1,h-2,0xFFFfff);
3992 leency 151
	if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
3991 leency 152
	DrawPopupShadow(x,y,w,h-1,skinned);
153
}
154
 
5499 leency 155
:void DrawPopupShadow(dword x,y,w,h,skinned)
156
{
157
	PutShadow(w+x+1,y,1,h+2,skinned,2);
158
	PutShadow(w+x+2,y+1,1,h+2,skinned,1);
159
	PutShadow(x,y+h+2,w+2,1,skinned,2);
160
	PutShadow(x+1,y+h+3,w+1,1,skinned,1);
161
}
162
 
3363 leency 163
:void GrayScaleImage(dword color_image, w, h)
164
{
5761 leency 165
	dword i,gray,to,rr,gg,bb;
166
	to = w*h*3 + color_image;
167
	for (i = color_image; i < to; i+=3)
3363 leency 168
	{
5761 leency 169
		rr = DSBYTE[i];
170
		gg = DSBYTE[i+1];
171
		bb = DSBYTE[i+2];
3363 leency 172
		gray = rr*rr;
173
		gray += gg*gg;
174
		gray += bb*bb;
175
		gray = sqrt(gray) / 3;
5761 leency 176
		DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
3363 leency 177
	}
178
}
179
 
180
:void ShadowImage(dword color_image, w, h, strength)
181
{
182
	dword col, to;
183
	strength = 10 - strength;
184
	to = w*h*3 + color_image;
185
	for ( ; color_image < to; color_image++)
186
	{
187
		col = strength * DSBYTE[color_image] / 10;
188
		DSBYTE[color_image] = col;
189
	}
5598 pavelyakov 190
}
191
 
192
#endif