Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
5980 leency 1
void PreparePage()
2
{
3
	char line[4096]=0;
4
	char char_width[255];
5
	dword line_start;
6
	byte ch;
5995 leency 7
	dword bufoff, buflen;
5980 leency 8
	dword line_length=30;
9
	dword stroka_y = 5;
10
	dword stroka=0;
11
	int i, srch_pos;
5995 leency 12
 
5987 leency 13
	label.changeSIZE();
5980 leency 14
	list.w = Form.cwidth-scroll.size_x-1;
15
	//get font chars width, need to increase performance
5987 leency 16
	for (i=0; i<256; i++) char_width[i] = label.symbol_size(i);
5980 leency 17
	//get font buffer height
5995 leency 18
	buflen = strlen(io.buffer_data) + io.buffer_data;
19
	for (bufoff=io.buffer_data; bufoff
5980 leency 20
	{
21
		ch = ESBYTE[bufoff];
22
		line_length += char_width[ch];
23
		if (line_length>=list.w) || (ch==10) {
24
			srch_pos = bufoff;
25
			loop()
26
			{
27
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
28
				if (srch_pos == line_start) break; //no white space found in whole line
29
				srch_pos--;
30
			}
31
			line_start = bufoff;
32
			line_length = 30;
33
			stroka++;
34
		}
35
	}
36
	//draw text in buffer
37
	list.count = stroka+2;
5987 leency 38
	list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, label.size.pt+1);
5980 leency 39
	if (list.count < list.visible) list.count = list.visible;
40
 
5987 leency 41
	label.size.height = list.count+1*list.item_h;
42
	label.raw_size = 0;
5980 leency 43
 
44
	line_length = 30;
45
	line_start = io.buffer_data;
5995 leency 46
	for (bufoff=io.buffer_data; bufoff
5980 leency 47
	{
48
		ch = ESBYTE[bufoff];
49
		line_length += char_width[ch];
50
		if (line_length>=list.w) || (ch==10)
51
		{
52
			//set word break
53
			srch_pos = bufoff;
54
			loop()
55
			{
56
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
57
				if (srch_pos == line_start) break; //no white space found in whole line
58
				srch_pos--;
59
			}
60
			i = bufoff-line_start;
61
			strlcpy(#line, line_start, i);
5987 leency 62
			label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, #line);
5980 leency 63
			stroka_y += list.item_h;
64
			line_start = bufoff;
65
			line_length = 30;
66
		}
67
	}
5987 leency 68
	label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
69
	label.apply_smooth();
5980 leency 70
	DrawPage();
71
}