Subversion Repositories Kolibri OS

Rev

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

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