2015-12-17 18:48:28 +03:00
|
|
|
void PreparePage()
|
|
|
|
{
|
|
|
|
char line[4096]=0;
|
|
|
|
char char_width[255];
|
|
|
|
dword line_start;
|
|
|
|
byte ch;
|
2015-12-21 15:13:21 +03:00
|
|
|
dword bufoff, buflen;
|
2015-12-17 18:48:28 +03:00
|
|
|
dword line_length=30;
|
|
|
|
dword stroka_y = 5;
|
|
|
|
dword stroka=0;
|
|
|
|
int i, srch_pos;
|
2015-12-21 15:13:21 +03:00
|
|
|
|
2015-12-19 00:10:45 +03:00
|
|
|
label.changeSIZE();
|
2015-12-17 18:48:28 +03:00
|
|
|
list.w = Form.cwidth-scroll.size_x-1;
|
|
|
|
//get font chars width, need to increase performance
|
2015-12-19 00:10:45 +03:00
|
|
|
for (i=0; i<256; i++) char_width[i] = label.symbol_size(i);
|
2015-12-17 18:48:28 +03:00
|
|
|
//get font buffer height
|
2015-12-21 15:13:21 +03:00
|
|
|
buflen = strlen(io.buffer_data) + io.buffer_data;
|
|
|
|
for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
|
2015-12-17 18:48:28 +03:00
|
|
|
{
|
|
|
|
ch = ESBYTE[bufoff];
|
|
|
|
line_length += char_width[ch];
|
|
|
|
if (line_length>=list.w) || (ch==10) {
|
|
|
|
srch_pos = bufoff;
|
|
|
|
loop()
|
|
|
|
{
|
|
|
|
if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
|
|
|
|
if (srch_pos == line_start) break; //no white space found in whole line
|
|
|
|
srch_pos--;
|
|
|
|
}
|
|
|
|
line_start = bufoff;
|
|
|
|
line_length = 30;
|
|
|
|
stroka++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//draw text in buffer
|
|
|
|
list.count = stroka+2;
|
2015-12-19 00:10:45 +03:00
|
|
|
list.SetSizes(0, TOOLBAR_H, list.w, Form.cheight-TOOLBAR_H, label.size.pt+1);
|
2015-12-17 18:48:28 +03:00
|
|
|
if (list.count < list.visible) list.count = list.visible;
|
|
|
|
|
2015-12-19 00:10:45 +03:00
|
|
|
label.size.height = list.count+1*list.item_h;
|
|
|
|
label.raw_size = 0;
|
2015-12-17 18:48:28 +03:00
|
|
|
|
|
|
|
line_length = 30;
|
|
|
|
line_start = io.buffer_data;
|
2015-12-21 15:13:21 +03:00
|
|
|
for (bufoff=io.buffer_data; bufoff<buflen; bufoff++)
|
2015-12-17 18:48:28 +03:00
|
|
|
{
|
|
|
|
ch = ESBYTE[bufoff];
|
|
|
|
line_length += char_width[ch];
|
|
|
|
if (line_length>=list.w) || (ch==10)
|
|
|
|
{
|
|
|
|
//set word break
|
|
|
|
srch_pos = bufoff;
|
|
|
|
loop()
|
|
|
|
{
|
|
|
|
if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
|
|
|
|
if (srch_pos == line_start) break; //no white space found in whole line
|
|
|
|
srch_pos--;
|
|
|
|
}
|
|
|
|
i = bufoff-line_start;
|
|
|
|
strlcpy(#line, line_start, i);
|
2015-12-19 00:10:45 +03:00
|
|
|
label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, #line);
|
2015-12-17 18:48:28 +03:00
|
|
|
stroka_y += list.item_h;
|
|
|
|
line_start = bufoff;
|
|
|
|
line_length = 30;
|
|
|
|
}
|
|
|
|
}
|
2015-12-19 00:10:45 +03:00
|
|
|
label.write_buf(8,stroka_y,list.w,label.size.height, 0xFFFFFF, 0, label.size.pt, line_start);
|
|
|
|
label.apply_smooth();
|
2015-12-17 18:48:28 +03:00
|
|
|
DrawPage();
|
|
|
|
}
|