2020-12-21 02:59:34 +01:00
|
|
|
CANVAS canvas;
|
|
|
|
|
2021-01-02 13:45:42 +01:00
|
|
|
void TWebBrowser::RenderLine(dword _line)
|
2020-12-21 02:59:34 +01:00
|
|
|
{
|
|
|
|
unsigned px; //paint x coordinate
|
|
|
|
unsigned pw; //paint y coordinate
|
|
|
|
dword pc; //paint color
|
|
|
|
int zoom;
|
|
|
|
|
|
|
|
if (style.title)
|
|
|
|
{
|
2021-01-02 13:45:42 +01:00
|
|
|
strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
|
2021-12-01 13:30:40 +01:00
|
|
|
if (!application_mode) {
|
|
|
|
strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
|
|
|
|
strncat(#header, #version, sizeof(TWebBrowser.header)-1);
|
|
|
|
}
|
2020-12-21 02:59:34 +01:00
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
else if (t_html) && (!t_body) {
|
|
|
|
//
|
2020-12-21 02:59:34 +01:00
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
else if (ESBYTE[_line])
|
2020-12-21 02:59:34 +01:00
|
|
|
{
|
2021-01-02 13:45:42 +01:00
|
|
|
pw = strlen(_line) * list.font_w;
|
2020-12-21 02:59:34 +01:00
|
|
|
zoom = list.font_w / BASIC_CHAR_W;
|
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
//there is some shit happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
2021-01-02 13:45:42 +01:00
|
|
|
if (pw > draw_w) {
|
2021-08-02 16:08:12 +02:00
|
|
|
//draw_w = pw;
|
2021-01-02 13:45:42 +01:00
|
|
|
NewLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (debug_mode) {
|
|
|
|
canvas.DrawBar(draw_x, draw_y, pw, list.item_h, 0xCCCccc);
|
|
|
|
debugln(_line);
|
|
|
|
}
|
|
|
|
|
2020-12-21 02:59:34 +01:00
|
|
|
style.cur_line_h = math.max(style.cur_line_h, list.item_h);
|
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
if (!secondrun) goto _SKIP_DRAW;
|
2020-12-21 02:59:34 +01:00
|
|
|
if (bg_colors.get_last() - bg_colors.get(0)) {
|
|
|
|
canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (style.image) {
|
|
|
|
canvas.DrawBar(draw_x, draw_y, pw, list.item_h-1, 0xF9DBCB);
|
|
|
|
}
|
|
|
|
if (style.button) {
|
|
|
|
canvas.DrawBar(draw_x, draw_y, pw, list.item_h - calc(zoom*2), 0xCCCccc);
|
|
|
|
canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2), pw, zoom, 0x999999);
|
|
|
|
}
|
|
|
|
|
|
|
|
pc = text_colors.get_last();
|
|
|
|
if (link) && (pc == text_colors.get(0)) pc = link_color_default;
|
|
|
|
|
2021-01-02 13:45:42 +01:00
|
|
|
canvas.WriteText(draw_x, draw_y, list.font_type, pc, _line, NULL);
|
|
|
|
if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, _line, NULL);
|
2020-12-21 02:59:34 +01:00
|
|
|
if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc);
|
|
|
|
if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc);
|
|
|
|
if (link) {
|
2021-01-02 13:45:42 +01:00
|
|
|
if (ESBYTE[_line]==' ') && (ESBYTE[_line+1]==NULL) {} else {
|
2020-12-21 02:59:34 +01:00
|
|
|
canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default);
|
|
|
|
links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);
|
|
|
|
}
|
|
|
|
}
|
2021-08-02 16:08:12 +02:00
|
|
|
_SKIP_DRAW:
|
2020-12-21 02:59:34 +01:00
|
|
|
draw_x += pw;
|
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
ESBYTE[_line] = NULL;
|
2020-12-21 02:59:34 +01:00
|
|
|
}
|
|
|
|
|
2020-12-28 22:43:46 +01:00
|
|
|
void TWebBrowser::RenderTextbuf()
|
|
|
|
{
|
2021-01-02 13:45:42 +01:00
|
|
|
dword lbp = #linebuf;
|
|
|
|
int br; //break position
|
|
|
|
char nul = '\0';
|
2021-11-21 12:42:21 +01:00
|
|
|
unsigned int len;
|
2020-12-28 22:43:46 +01:00
|
|
|
|
|
|
|
//Do we need a line break?
|
2021-11-21 12:42:21 +01:00
|
|
|
|
|
|
|
if (!linebuf[0]) return;
|
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
while (len = strlen(lbp)) && (len * list.font_w + draw_x - left_gap >= draw_w) {
|
2020-12-28 22:43:46 +01:00
|
|
|
//Yes, we do. Lets calculate where...
|
2021-08-02 16:08:12 +02:00
|
|
|
br = len;
|
|
|
|
|
|
|
|
//debugln(" \\n");
|
2020-12-28 22:43:46 +01:00
|
|
|
|
|
|
|
//Is a new line fits in the current line?
|
2021-08-02 16:08:12 +02:00
|
|
|
if (br * list.font_w + draw_x - left_gap >= draw_w) {
|
|
|
|
br = draw_w - draw_x + left_gap /list.font_w;
|
2021-01-02 13:45:42 +01:00
|
|
|
while(br) {
|
|
|
|
if (ESBYTE[lbp + br]==' ') {
|
|
|
|
br++;
|
2020-12-31 03:03:58 +01:00
|
|
|
break;
|
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
br--;
|
2020-12-31 03:03:58 +01:00
|
|
|
}
|
2020-12-28 22:43:46 +01:00
|
|
|
}
|
|
|
|
//Maybe a new line is too big for the whole new line? Then we have to split it
|
2021-01-02 13:45:42 +01:00
|
|
|
if (!br) && (len * list.font_w >= draw_w) {
|
|
|
|
br = draw_w - draw_x / list.font_w;
|
2020-12-28 22:43:46 +01:00
|
|
|
}
|
|
|
|
|
2021-01-02 13:45:42 +01:00
|
|
|
if (br) {
|
|
|
|
ESBYTE[lbp + br] >< nul;
|
|
|
|
RenderLine(lbp);
|
|
|
|
ESBYTE[lbp + br] >< nul;
|
|
|
|
lbp += br;
|
|
|
|
while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++;
|
|
|
|
if (ESBYTE[lbp]) NewLine();
|
2020-12-31 03:03:58 +01:00
|
|
|
} else {
|
|
|
|
NewLine();
|
2021-01-02 13:45:42 +01:00
|
|
|
RenderLine(lbp);
|
2020-12-31 03:03:58 +01:00
|
|
|
}
|
2020-12-28 22:43:46 +01:00
|
|
|
}
|
2021-01-02 13:45:42 +01:00
|
|
|
RenderLine(lbp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TWebBrowser::NewLine()
|
|
|
|
{
|
|
|
|
static bool empty_line = true;
|
|
|
|
|
|
|
|
if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return;
|
|
|
|
if (t_html) && (!t_body) return;
|
|
|
|
|
|
|
|
if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
|
|
|
|
if (!empty_line) empty_line=true; else return;
|
|
|
|
} else {
|
|
|
|
empty_line = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
draw_y += style.cur_line_h;
|
|
|
|
style.cur_line_h = list.item_h;
|
|
|
|
if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0; //left_gap += style.tag_list.level * 5 * list.font_w ???
|
|
|
|
draw_x += style.tag_list.level * 5 * list.font_w + left_gap;
|
2020-12-28 22:43:46 +01:00
|
|
|
}
|
|
|
|
|
2020-12-21 02:59:34 +01:00
|
|
|
bool TWebBrowser::RenderImage(dword cur_img)
|
|
|
|
{
|
|
|
|
int img_x, img_y, img_w, img_h;
|
|
|
|
dword imgbuf[44];
|
|
|
|
|
|
|
|
if (!cur_img) return false;
|
|
|
|
|
|
|
|
img_h = ESDWORD[cur_img+8];
|
|
|
|
img_w = ESDWORD[cur_img+4];
|
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
if (img_w + draw_x - left_gap >= draw_w) NewLine();
|
2020-12-21 02:59:34 +01:00
|
|
|
img_y = draw_y;
|
|
|
|
if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2;
|
|
|
|
style.cur_line_h = math.max(style.cur_line_h, img_h);
|
|
|
|
|
|
|
|
img_w = math.min(img_w, canvas.bufw - draw_x);
|
|
|
|
|
|
|
|
if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0);
|
|
|
|
|
|
|
|
if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
|
|
|
|
|
2021-08-02 16:08:12 +02:00
|
|
|
if (secondrun)
|
|
|
|
{
|
|
|
|
if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
|
|
|
|
img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
|
|
|
|
$push eax
|
|
|
|
img_destroy stdcall(cur_img);
|
|
|
|
$pop eax
|
|
|
|
cur_img = EAX;
|
|
|
|
if (!EAX) return false;
|
|
|
|
}
|
|
|
|
imgbuf[04] = canvas.bufw;
|
|
|
|
imgbuf[08] = canvas.bufh;
|
|
|
|
imgbuf[20] = IMAGE_BPP32;
|
|
|
|
imgbuf[24] = buf_data+8;
|
|
|
|
img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h);
|
2020-12-21 02:59:34 +01:00
|
|
|
img_destroy stdcall(cur_img);
|
|
|
|
}
|
|
|
|
|
|
|
|
draw_x += img_w;
|
2021-08-02 16:08:12 +02:00
|
|
|
if (draw_x - left_gap >= draw_w) NewLine();
|
2020-12-21 02:59:34 +01:00
|
|
|
return true;
|
|
|
|
}
|