Subversion Repositories Kolibri OS

Rev

Rev 5985 | 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;
7
	dword bufoff;
8
	dword line_length=30;
9
	dword stroka_y = 5;
10
	dword stroka=0;
11
	int i, srch_pos;
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
18
	for (bufoff=io.buffer_data; ESBYTE[bufoff]; bufoff++)
19
	{
20
		ch = ESBYTE[bufoff];
21
		line_length += char_width[ch];
22
		if (line_length>=list.w) || (ch==10) {
23
			srch_pos = bufoff;
24
			loop()
25
			{
26
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
27
				if (srch_pos == line_start) break; //no white space found in whole line
28
				srch_pos--;
29
			}
30
			line_start = bufoff;
31
			line_length = 30;
32
			stroka++;
33
		}
34
	}
35
	//draw text in buffer
36
	list.count = stroka+2;
5987 leency 37
	list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, label.size.pt+1);
5980 leency 38
	if (list.count < list.visible) list.count = list.visible;
39
 
5987 leency 40
	label.size.height = list.count+1*list.item_h;
41
	label.raw_size = 0;
5980 leency 42
 
43
	line_length = 30;
44
	line_start = io.buffer_data;
45
	for (bufoff=io.buffer_data; ESBYTE[bufoff]; bufoff++)
46
	{
47
		ch = ESBYTE[bufoff];
48
		line_length += char_width[ch];
49
		if (line_length>=list.w) || (ch==10)
50
		{
51
			//set word break
52
			srch_pos = bufoff;
53
			loop()
54
			{
55
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
56
				if (srch_pos == line_start) break; //no white space found in whole line
57
				srch_pos--;
58
			}
59
			i = bufoff-line_start;
60
			strlcpy(#line, line_start, i);
5987 leency 61
			label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, #line);
5980 leency 62
			stroka_y += list.item_h;
63
			line_start = bufoff;
64
			line_length = 30;
65
		}
66
	}
5987 leency 67
	label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
68
	label.apply_smooth();
5980 leency 69
	DrawPage();
70
}