Subversion Repositories Kolibri OS

Rev

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

Rev 6651 Rev 6662
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
#ifndef INCLUDE_RGB_H
13
#ifndef INCLUDE_RGB_H
14
#include "../lib/patterns/rgb.h"
14
#include "../lib/patterns/rgb.h"
15
#endif
15
#endif
16
 
16
 
17
:void DrawRectangle(dword x,y,w,h,color1)
17
:void DrawRectangle(dword x,y,w,h,color1)
18
{
18
{
19
	if (w<=0) || (h<=0) return;
19
	if (w<=0) || (h<=0) return;
20
	DrawBar(x,y,w,1,color1);
20
	DrawBar(x,y,w,1,color1);
21
	DrawBar(x,y+h,w,1,color1);
21
	DrawBar(x,y+h,w,1,color1);
22
	DrawBar(x,y,1,h,color1);
22
	DrawBar(x,y,1,h,color1);
23
	DrawBar(x+w,y,1,h+1,color1);
23
	DrawBar(x+w,y,1,h+1,color1);
24
}
24
}
25
 
25
 
26
:void DrawWideRectangle(dword x,y,w,h,boder,color1)
26
:void DrawWideRectangle(dword x,y,w,h,boder,color1)
27
{
27
{
28
	if (w<=0) || (h<=0) return;
28
	if (w<=0) || (h<=0) return;
29
	DrawBar(x, y, w, boder, color1);
29
	DrawBar(x, y, w, boder, color1);
30
	DrawBar(x, y+h-boder, w, boder, color1);
30
	DrawBar(x, y+h-boder, w, boder, color1);
31
	DrawBar(x, y+boder, boder, h-boder-boder, color1);
31
	DrawBar(x, y+boder, boder, h-boder-boder, color1);
32
	DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1);
32
	DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1);
33
}
33
}
34
 
34
 
35
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
35
:void DrawRectangle3D(dword x,y,w,h,color1,color2)
36
{
36
{
37
	if (w<=0) || (h<=0) return;
37
	if (w<=0) || (h<=0) return;
38
	DrawBar(x,y,w+1,1,color1);
38
	DrawBar(x,y,w+1,1,color1);
39
	DrawBar(x,y+1,1,h-1,color1);
39
	DrawBar(x,y+1,1,h-1,color1);
40
	DrawBar(x+w,y+1,1,h,color2);
40
	DrawBar(x+w,y+1,1,h,color2);
41
	DrawBar(x,y+h,w,1,color2);
41
	DrawBar(x,y+h,w,1,color2);
42
}
42
}
43
 
43
 
44
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
44
:void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text)
45
{
45
{
46
	dword tx = -strlen(text)*8+w/2+x;
46
	dword tx = -strlen(text)*8+w/2+x;
47
	dword ty = h/2-7+y;
47
	dword ty = h/2-7+y;
48
 
48
 
49
	if (id>0) DefineButton(x,y,w,h,id,color_b);
49
	if (id>0) DefineButton(x,y,w,h,id,color_b);
50
	WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text);
50
	WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text);
51
	WriteText(tx,ty,0x90,color_t,text);
51
	WriteText(tx,ty,0x90,color_t,text);
52
}
52
}
53
 
53
 
54
:int DrawStandartCaptButton(dword x, y, id, text)
54
:int DrawStandartCaptButton(dword x, y, id, text)
55
{
55
{
56
	int padding_v = 5;
56
	int padding_v = 5;
57
	int padding_h = 15;
57
	int padding_h = 15;
58
	int right_margin = 12;
58
	int right_margin = 12;
59
	int tx = x + padding_h;
59
	int tx = x + padding_h;
60
	int ty = y + padding_v;
60
	int ty = y + padding_v;
61
	int h = padding_v + padding_v + 16; //16 font height
61
	int h = padding_v + padding_v + 16; //16 font height
62
	int w = strlen(text)*8 + padding_h + padding_h;
62
	int w = strlen(text)*8 + padding_h + padding_h;
63
 
63
 
64
	if (id>0) DefineButton(x,y,w,h,id,system.color.work_button);
64
	if (id>0) DefineButton(x,y,w,h,id,system.color.work_button);
65
	WriteText(tx+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text);
65
	WriteText(tx+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text);
66
	WriteText(tx,ty,0x90,system.color.work_button_text,text);
66
	WriteText(tx,ty,0x90,system.color.work_button_text,text);
67
	return w + right_margin;
67
	return w + right_margin;
68
}
68
}
69
 
69
 
70
:void WriteTextCenter(dword x,y,w,color_t,text)
70
:void WriteTextCenter(dword x,y,w,color_t,text)
71
{
71
{
72
	WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
72
	WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text);
73
}
73
}
74
 
74
 
75
:void DrawCircle(int x, y, r, color)
75
:void DrawCircle(int x, y, r, color)
76
{
76
{
77
	int i;
77
	int i;
78
	float px=0, py=r, ii = r * 3.1415926 * 2;
78
	float px=0, py=r, ii = r * 3.1415926 * 2;
79
	FOR (i = 0; i < ii; i++)
79
	FOR (i = 0; i < ii; i++)
80
	{
80
	{
81
        PutPixel(px + x, y - py, color);
81
        PutPixel(px + x, y - py, color);
82
        px = py / r + px;
82
        px = py / r + px;
83
        py = -px / r + py;
83
        py = -px / r + py;
84
	}
84
	}
85
}
85
}
86
 
86
 
87
:unsigned char checkbox_flag[507] = {
87
:unsigned char checkbox_flag[507] = {
88
	0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 
88
	0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 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F, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, 
116
	0x9F, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, 
117
	0x04, 0xF9, 0x98, 0x04, 0xFC, 0xB4, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 
117
	0x04, 0xF9, 0x98, 0x04, 0xFC, 0xB4, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 
118
	0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 
118
	0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 
119
	0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04
119
	0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04
120
};
120
};
121
 
121
 
122
:void CheckBox(dword x,y,bt_id, text, is_checked)
122
:void CheckBox(dword x,y,bt_id, text, is_checked)
123
{
123
{
124
	byte w=14, h=14;
124
	byte w=14, h=14;
125
	DefineButton(x-1, y-1, strlen(text)*8 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0);
125
	DefineButton(x-1, y-1, strlen(text)*8 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0);
126
	EDI = system.color.work;
126
	EDI = system.color.work;
127
	WriteText(x+w+8, h / 2 + y -7, 0xD0, system.color.work_text, text);
127
	WriteText(x+w+8, h / 2 + y -7, 0xD0, system.color.work_text, text);
128
	DrawRectangle(x, y, w, h, system.color.work_graph);
128
	DrawRectangle(x, y, w, h, system.color.work_graph);
129
	if (is_checked == 0)
129
	if (is_checked == 0)
130
	{
130
	{
131
		DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff);
131
		DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff);
132
		DrawBar(x+2, y+2, w-3, h-3, 0xffffff);
132
		DrawBar(x+2, y+2, w-3, h-3, 0xffffff);
133
	} 
133
	} 
134
	else if (is_checked == 1)
134
	else if (is_checked == 1)
135
	{
135
	{
136
		DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
136
		DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
137
		_PutImage(x+1, y+1, 13, 13, #checkbox_flag);
137
		_PutImage(x+1, y+1, 13, 13, #checkbox_flag);
138
	}
138
	}
139
	else if (is_checked == 2) //not active
139
	else if (is_checked == 2) //not active
140
	{
140
	{
141
		DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
141
		DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff);
142
		DrawBar(x+3, y+3, w-5, h-5, 0x888888);
142
		DrawBar(x+3, y+3, w-5, h-5, 0x888888);
143
	}
143
	}
144
	DrawRectangle3D(x-1,y-1,w+2,h+2,system.color.work_dark,system.color.work_light);
144
	DrawRectangle3D(x-1,y-1,w+2,h+2,system.color.work_dark,system.color.work_light);
145
}
145
}
146
 
146
 
147
:void MoreLessBox(dword x,y, bt_id_more, bt_id_less, value, text)
147
:void MoreLessBox(dword x,y, bt_id_more, bt_id_less, value, text)
148
{
148
{
149
	#define VALUE_FIELD_W 34
149
	#define VALUE_FIELD_W 34
150
	#define SIZE 18
150
	#define SIZE 18
151
	dword value_text = itoa(value);
151
	dword value_text = itoa(value);
152
 
152
 
153
	DrawRectangle(x, y, VALUE_FIELD_W, SIZE, system.color.work_graph);
153
	DrawRectangle(x, y, VALUE_FIELD_W, SIZE, system.color.work_graph);
154
	DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff);
154
	DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff);
155
	DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff);
155
	DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff);
156
	WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text);
156
	WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text);
157
 
157
 
158
	DrawCaptButton(VALUE_FIELD_W + x,     y, SIZE, SIZE, bt_id_more, system.color.work_button, system.color.work_button_text, "+");
158
	DrawCaptButton(VALUE_FIELD_W + x,     y, SIZE, SIZE, bt_id_more, system.color.work_button, system.color.work_button_text, "+");
159
	DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, bt_id_less, system.color.work_button, system.color.work_button_text, "-");
159
	DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, bt_id_less, system.color.work_button, system.color.work_button_text, "-");
160
	EDI = system.color.work;
160
	EDI = system.color.work;
161
	WriteText(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, system.color.work_text, text);
161
	WriteText(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, system.color.work_text, text);
162
	DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light);
162
	DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light);
163
}
163
}
164
 
164
 
165
:void DrawEditBox(dword edit_box_pointer)
165
:void DrawEditBox(dword edit_box_pointer)
166
{
166
{
167
	dword x,y,w,h,bg;
167
	dword x,y,w,h,bg;
168
	ESI = edit_box_pointer;
168
	ESI = edit_box_pointer;
169
	x = ESI.edit_box.left;
169
	x = ESI.edit_box.left;
170
	y = ESI.edit_box.top;
170
	y = ESI.edit_box.top;
171
	w = ESI.edit_box.width+1;
171
	w = ESI.edit_box.width+1;
172
	if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
172
	if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff;
173
	h = 15;
173
	h = 15;
174
	DrawRectangle(x-1, y-1, w+1, h+1, bg);
174
	DrawRectangle(x-1, y-1, w+1, h+1, bg);
175
	DrawRectangle3D(x-2, y-2, w+3, h+3, 0xDDDddd, bg);
175
	DrawRectangle3D(x-2, y-2, w+3, h+3, 0xDDDddd, bg);
176
	DrawRectangle(x-3, y-3, w+5, h+5, system.color.work_graph);
176
	DrawRectangle(x-3, y-3, w+5, h+5, system.color.work_graph);
177
	DrawRectangle3D(x-4, y-4, w+7, h+7, system.color.work_dark, system.color.work_light);
177
	DrawRectangle3D(x-4, y-4, w+7, h+7, system.color.work_dark, system.color.work_light);
178
	edit_box_draw  stdcall (edit_box_pointer);
178
	edit_box_draw  stdcall (edit_box_pointer);
179
}
179
}
180
 
180
 
181
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent)
181
:void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent)
182
{
182
{
183
	int progress_w;
183
	int progress_w;
184
	static int fill_old;
184
	static int fill_old;
185
	    
185
	    
186
	//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) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;}
187
	if (progress_percent<=0) || (progress_percent>=100) return;
187
	if (progress_percent<=0) || (progress_percent>=100) return;
188
	
188
	
189
	DrawRectangle(st_x, st_y, st_w,st_h, col_border);
189
	DrawRectangle(st_x, st_y, st_w,st_h, col_border);
190
	DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
190
	DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff);
191
 
191
 
192
	if (progress_percent>0) && (progress_percent<=100)
192
	if (progress_percent>0) && (progress_percent<=100)
193
	{
193
	{
194
		progress_w = st_w - 3 * progress_percent / 100;
194
		progress_w = st_w - 3 * progress_percent / 100;
195
		DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
195
		DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill);
196
		DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
196
		DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff);
197
	}
197
	}
198
}
198
}
199
 
199
 
200
:void DrawLink(dword x,y,font_type,btn_id, inscription)
200
:void DrawLink(dword x,y,font_type,btn_id, inscription)
201
{
201
{
202
	int w;
202
	int w;
203
	WriteText(x,y,font_type,0x4E00E7,inscription);
203
	WriteText(x,y,font_type,0x4E00E7,inscription);
204
	if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7;
204
	if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7;
205
	DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
205
	DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0);
206
	DrawBar(x,y+8,w,1,0x4E00E7);
206
	DrawBar(x,y+8,w,1,0x4E00E7);
207
}
207
}
208
 
208
 
209
:void PutShadow(dword x,y,w,h,skinned,strength)
209
:void PutShadow(dword x,y,w,h,skinned,strength)
210
{
210
{
211
	proc_info wForm;
211
	proc_info wForm;
212
	dword shadow_buf, skin_height;
212
	dword shadow_buf, skin_height;
213
	shadow_buf = mem_Alloc(w*h*3);
213
	shadow_buf = mem_Alloc(w*h*3);
214
 	GetProcessInfo(#wForm, SelfInfo);
214
 	GetProcessInfo(#wForm, SelfInfo);
215
	CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
215
	CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h);
216
	ShadowImage(shadow_buf, w, h, strength);
216
	ShadowImage(shadow_buf, w, h, strength);
217
	_PutImage(x,y,w,h,shadow_buf);
217
	_PutImage(x,y,w,h,shadow_buf);
218
	mem_Free(shadow_buf);
218
	mem_Free(shadow_buf);
219
}
219
}
220
 
220
 
221
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
221
:void DrawPopup(dword x,y,w,h,skinned, col_work,col_border)
222
{
222
{
223
	DrawRectangle(x,y,w,h,col_border);
223
	DrawRectangle(x,y,w,h,col_border);
224
	DrawBar(x+1,y+1,w-1,1,0xFFFfff);
224
	DrawBar(x+1,y+1,w-1,1,0xFFFfff);
225
	DrawBar(x+1,y+2,1,h-2,0xFFFfff);
225
	DrawBar(x+1,y+2,1,h-2,0xFFFfff);
226
	if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
226
	if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work);
227
	DrawPopupShadow(x,y,w,h-1,skinned);
227
	DrawPopupShadow(x,y,w,h-1,skinned);
228
}
228
}
229
 
229
 
230
:void DrawPopupShadow(dword x,y,w,h,skinned)
230
:void DrawPopupShadow(dword x,y,w,h,skinned)
231
{
231
{
232
	PutShadow(w+x+1,y,1,h+2,skinned,2);
232
	PutShadow(w+x+1,y,1,h+2,skinned,2);
233
	PutShadow(w+x+2,y+1,1,h+2,skinned,1);
233
	PutShadow(w+x+2,y+1,1,h+2,skinned,1);
234
	PutShadow(x,y+h+2,w+2,1,skinned,2);
234
	PutShadow(x,y+h+2,w+2,1,skinned,2);
235
	PutShadow(x+1,y+h+3,w+1,1,skinned,1);
235
	PutShadow(x+1,y+h+3,w+1,1,skinned,1);
236
}
236
}
237
 
237
 
238
:void GrayScaleImage(dword color_image, w, h)
238
:void GrayScaleImage(dword color_image, w, h)
239
{
239
{
240
	dword i,gray,to,rr,gg,bb;
240
	dword i,gray,to,rr,gg,bb;
241
	to = w*h*3 + color_image;
241
	to = w*h*3 + color_image;
242
	for (i = color_image; i < to; i+=3)
242
	for (i = color_image; i < to; i+=3)
243
	{
243
	{
244
		rr = DSBYTE[i];
244
		rr = DSBYTE[i];
245
		gg = DSBYTE[i+1];
245
		gg = DSBYTE[i+1];
246
		bb = DSBYTE[i+2];
246
		bb = DSBYTE[i+2];
247
		gray = rr*rr;
247
		gray = rr*rr;
248
		gray += gg*gg;
248
		gray += gg*gg;
249
		gray += bb*bb;
249
		gray += bb*bb;
250
		gray = sqrt(gray) / 3;
250
		gray = sqrt(gray) / 3;
251
		DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
251
		DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray;
252
	}
252
	}
253
}
253
}
254
 
254
 
255
:void ShadowImage(dword color_image, w, h, strength)
255
:void ShadowImage(dword color_image, w, h, strength)
256
{
256
{
257
	dword col, to;
257
	dword col, to;
258
	strength = 10 - strength;
258
	strength = 10 - strength;
259
	to = w*h*3 + color_image;
259
	to = w*h*3 + color_image;
260
	for ( ; color_image < to; color_image++)
260
	for ( ; color_image < to; color_image++)
261
	{
261
	{
262
		col = strength * DSBYTE[color_image] / 10;
262
		col = strength * DSBYTE[color_image] / 10;
263
		DSBYTE[color_image] = col;
263
		DSBYTE[color_image] = col;
264
	}
264
	}
265
}
265
}
266
 
266
 
267
:void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h)
267
:void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h)
268
{
268
{
269
	dword next_word_pointer = strchr(text_pointer, '\n');
269
	dword next_word_pointer = strchr(text_pointer, '\n');
270
	if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h);
270
	if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h);
271
	ESBYTE[next_word_pointer] = NULL;
271
	ESBYTE[next_word_pointer] = NULL;
272
	WriteText(dword x, y, byte fontType, dword color, text_pointer);
272
	WriteText(dword x, y, byte fontType, dword color, text_pointer);
273
	ESBYTE[next_word_pointer] = '\n';
273
	ESBYTE[next_word_pointer] = '\n';
274
}
274
}
275
 
275
 
276
/*
276
/*
277
We have a long text and need to show it in block.
277
We have a long text and need to show it in block.
278
Normal line break '\n' must be applied.
278
Normal line break '\n' must be applied.
279
Long lines should be breaked by word. 
279
Long lines should be breaked by word. 
280
TODO: scroll
280
TODO: scroll
281
*/
281
*/
282
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col)
282
:int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col)
283
{
283
{
284
	dword write_start;
284
	dword write_start;
285
	dword buf_end;
285
	dword buf_end;
286
	int line_h = 15;
286
	int line_h = 15;
287
	int label_length_max;
287
	int label_length_max;
288
	int write_length;
288
	int write_length;
289
	bool end_found;
289
	bool end_found;
290
 
290
 
291
	write_start = buf_start;
291
	write_start = buf_start;
292
	buf_end = strlen(buf_start) + buf_start;
292
	buf_end = strlen(buf_start) + buf_start;
293
	label_length_max  = w / 8; // 8 big font char width
293
	label_length_max  = w / 8; // 8 big font char width
294
 
294
 
295
	loop() 
295
	loop() 
296
	{
296
	{
297
		if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col);
297
		if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col);
298
		end_found = false;
298
		end_found = false;
299
		write_length = strchr(write_start, '\n') - write_start; //search normal line break
299
		write_length = strchr(write_start, '\n') - write_start; //search normal line break
300
		if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found
300
		if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found
301
		{ 
301
		{ 
302
			if (buf_end - write_start < label_length_max) //check does current line the last
302
			if (buf_end - write_start < label_length_max) //check does current line the last
303
			{ 
303
			{ 
304
				write_length = buf_end - write_start;
304
				write_length = buf_end - write_start;
305
				end_found = true;
305
				end_found = true;
306
			}
306
			}
307
			else
307
			else
308
			{
308
			{
309
				for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break
309
				for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break
310
					if (ESBYTE[write_start+write_length] == ' ') {
310
					if (ESBYTE[write_start+write_length] == ' ') {
311
						end_found = true;
311
						end_found = true;
312
						break;
312
						break;
313
					}
313
					}
314
				}
314
				}
315
			} 
315
			} 
316
			if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max
316
			if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max
317
		}
317
		}
318
		ESI = write_length; //set text length attribute for WriteText()
318
		ESI = write_length; //set text length attribute for WriteText()
319
		WriteText(x+1, y, 0x10, text_col, write_start);
319
		WriteText(x, y, 0x10, text_col, write_start);
320
		// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) {
320
		// if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) {
321
		// 	WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|");
321
		// 	WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|");
322
		// }
322
		// }
323
		write_start += write_length + 1;
323
		write_start += write_length + 1;
324
		y += line_h;
324
		y += line_h;
325
		if (write_start >= buf_end) break;
325
		if (write_start >= buf_end) break;
326
	}
326
	}
327
	if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col);
327
	if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col);
328
	return y+line_h;
328
	return y+line_h;
329
}
329
}
330
 
330
 
331
 
331
 
332
//this function increase falue and return it
332
//this function increase falue and return it
333
//useful for list of controls which goes one after one
333
//useful for list of controls which goes one after one
334
struct incn
334
struct incn
335
{
335
{
336
	dword n;
336
	dword n;
337
	dword inc(dword _addition);
337
	dword inc(dword _addition);
338
};
338
};
339
 
339
 
340
dword incn::inc(dword _addition)
340
dword incn::inc(dword _addition)
341
{
341
{
342
	n+=_addition;
342
	n+=_addition;
343
	return n;
343
	return n;
344
}
344
}
345
 
345
 
346
 
346
 
347
/*=========================================================
347
/*=========================================================
348
==
348
==
349
==                   TABS
349
==                   TABS
350
==
350
==
351
/========================================================*/
351
/========================================================*/
352
 
352
 
353
#define TAB_PADDING 25
353
#define TAB_PADDING 25
354
#define TAB_HEIGHT 25
354
#define TAB_HEIGHT 25
355
 
355
 
356
:struct _tabs
356
:struct _tabs
357
{
357
{
358
	int active_tab;
358
	int active_tab;
359
	void draw();
359
	void draw();
360
	int click();
360
	int click();
361
} tabs;
361
} tabs;
362
 
362
 
363
:void _tabs::draw(dword x,y, but_id, text)
363
:void _tabs::draw(dword x,y, but_id, text)
364
{
364
{
365
	dword col_bg, col_text;
365
	dword col_bg, col_text;
366
	dword w=strlen(text)*8+TAB_PADDING, h=TAB_HEIGHT;
366
	dword w=strlen(text)*8+TAB_PADDING, h=TAB_HEIGHT;
367
	y -= h;
367
	y -= h;
368
 
368
 
369
	if (but_id==active_tab)
369
	if (but_id==active_tab)
370
	{
370
	{
371
		col_bg=system.color.work_button;
371
		col_bg=system.color.work_button;
372
		col_text=system.color.work_button_text;
372
		col_text=system.color.work_button_text;
373
	}
373
	}
374
	else
374
	else
375
	{
375
	{
376
		col_bg=system.color.work;
376
		col_bg=system.color.work;
377
		col_text=system.color.work_text;
377
		col_text=system.color.work_text;
378
	} 
378
	} 
379
	DrawCaptButton(x,y, w-1,h+1, but_id, col_bg, col_text, text);
379
	DrawCaptButton(x,y, w-1,h+1, but_id, col_bg, col_text, text);
380
}
380
}
381
 
381
 
382
:int _tabs::click(int N)
382
:int _tabs::click(int N)
383
{
383
{
384
	if (N==active_tab) return false;
384
	if (N==active_tab) return false;
385
	active_tab = N;
385
	active_tab = N;
386
	return true;
386
	return true;
387
}
387
}
388
 
388
 
389
 
389
 
390
 
390
 
391
#endif
391
#endif
392
>
392
>