Subversion Repositories Kolibri OS

Rev

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