2015-08-19 18:14:52 +03:00
|
|
|
|
2014-03-22 14:29:29 +04:00
|
|
|
scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
|
2013-12-27 16:30:42 +04:00
|
|
|
|
2015-08-19 15:48:31 +03:00
|
|
|
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
|
|
|
|
|
|
|
struct _style {
|
2020-03-21 17:33:54 +03:00
|
|
|
bool
|
2016-12-12 01:58:11 +03:00
|
|
|
b, u, s, h,
|
2015-08-19 15:48:31 +03:00
|
|
|
pre,
|
|
|
|
blq,
|
|
|
|
li,
|
|
|
|
li_tab,
|
2020-03-21 17:33:54 +03:00
|
|
|
button,
|
|
|
|
image,
|
2015-08-19 15:48:31 +03:00
|
|
|
align;
|
2020-03-21 21:49:45 +03:00
|
|
|
dword
|
|
|
|
bg_color;
|
2015-08-19 15:48:31 +03:00
|
|
|
};
|
2013-12-27 16:30:42 +04:00
|
|
|
|
2013-12-27 03:36:17 +04:00
|
|
|
struct TWebBrowser {
|
2014-01-28 00:16:33 +04:00
|
|
|
llist list;
|
2015-08-19 15:48:31 +03:00
|
|
|
_style style;
|
2014-01-18 15:46:58 +04:00
|
|
|
DrawBufer DrawBuf;
|
2016-12-21 13:56:06 +03:00
|
|
|
int zoom;
|
2020-03-22 22:50:16 +03:00
|
|
|
bool opened; //is this a "start tag" or "end tag"
|
|
|
|
void SetPageDefaults();
|
2015-08-23 13:12:13 +03:00
|
|
|
void Prepare();
|
|
|
|
void SetStyle();
|
|
|
|
void DrawStyle();
|
2013-12-27 03:36:17 +04:00
|
|
|
void DrawPage();
|
|
|
|
void DrawScroller();
|
2015-08-19 15:54:01 +03:00
|
|
|
void LoadInternalPage();
|
2014-03-15 19:16:08 +04:00
|
|
|
void NewLine();
|
2014-03-30 15:57:13 +04:00
|
|
|
void Perenos();
|
2015-08-19 18:14:52 +03:00
|
|
|
void BufEncode();
|
2014-03-23 21:12:21 +04:00
|
|
|
} WB1;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2015-08-19 15:48:31 +03:00
|
|
|
|
2020-03-21 17:33:54 +03:00
|
|
|
bool
|
2015-08-19 15:48:31 +03:00
|
|
|
link,
|
|
|
|
cur_encoding,
|
|
|
|
t_html,
|
|
|
|
t_body;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2015-09-01 12:36:58 +03:00
|
|
|
dword bufpointer=0;
|
|
|
|
dword o_bufpointer=0;
|
|
|
|
dword bufsize=0;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2013-12-29 16:48:06 +04:00
|
|
|
dword text_colors[300];
|
|
|
|
dword text_color_index;
|
2014-01-20 02:46:58 +04:00
|
|
|
dword link_color_inactive;
|
|
|
|
dword link_color_active;
|
2020-03-21 21:49:45 +03:00
|
|
|
dword page_bg;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2016-12-12 01:58:11 +03:00
|
|
|
int draw_y;
|
2013-12-29 16:48:06 +04:00
|
|
|
int stolbec;
|
|
|
|
int tab_len;
|
2016-12-12 01:58:11 +03:00
|
|
|
|
|
|
|
int body_magrin=5;
|
|
|
|
int basic_line_h=22;
|
2014-03-13 02:56:28 +04:00
|
|
|
|
2015-08-19 15:48:31 +03:00
|
|
|
char URL[10000];
|
|
|
|
char header[2048];
|
2013-12-29 16:48:06 +04:00
|
|
|
char line[500];
|
|
|
|
char tagparam[10000];
|
2015-08-19 15:48:31 +03:00
|
|
|
char tag[100];
|
2015-08-23 22:59:44 +03:00
|
|
|
char oldtag[100];
|
2015-08-19 15:48:31 +03:00
|
|
|
char attr[1200];
|
|
|
|
char val[4096];
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2015-12-20 18:50:48 +03:00
|
|
|
#include "..\TWB\absolute_url.h"
|
2014-03-23 21:12:21 +04:00
|
|
|
#include "..\TWB\links.h"
|
2020-03-18 03:45:36 +03:00
|
|
|
#include "..\TWB\anchors.h"
|
2013-12-27 03:36:17 +04:00
|
|
|
#include "..\TWB\colors.h"
|
|
|
|
#include "..\TWB\unicode_tags.h"
|
|
|
|
#include "..\TWB\img_cache.h"
|
|
|
|
#include "..\TWB\parce_tag.h"
|
2014-01-18 15:46:58 +04:00
|
|
|
|
|
|
|
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
2015-08-23 13:12:13 +03:00
|
|
|
void TWebBrowser::DrawStyle()
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2016-12-21 13:56:06 +03:00
|
|
|
dword start_x, line_length, stolbec_len;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
|
|
|
if (!header)
|
|
|
|
{
|
2017-09-28 21:59:04 +03:00
|
|
|
strcpy(#header, #line);
|
2013-12-27 03:36:17 +04:00
|
|
|
line = 0;
|
|
|
|
return;
|
|
|
|
}
|
2014-03-13 03:30:28 +04:00
|
|
|
if (t_html) && (!t_body) return;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2016-12-21 13:56:06 +03:00
|
|
|
if (line)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2016-12-12 01:58:11 +03:00
|
|
|
start_x = stolbec * list.font_w + body_magrin + list.x;
|
2016-12-21 13:56:06 +03:00
|
|
|
stolbec_len = strlen(#line) * zoom;
|
2015-08-23 22:59:44 +03:00
|
|
|
line_length = stolbec_len * list.font_w;
|
2015-08-05 01:21:08 +03:00
|
|
|
|
2020-03-21 21:49:45 +03:00
|
|
|
if (style.bg_color!=page_bg) {
|
|
|
|
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, style.bg_color);
|
|
|
|
}
|
|
|
|
|
2020-03-21 17:33:54 +03:00
|
|
|
if (style.image) {
|
2020-03-21 21:49:45 +03:00
|
|
|
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB);
|
2020-03-21 17:33:54 +03:00
|
|
|
}
|
|
|
|
if (style.button) {
|
|
|
|
DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
|
|
|
|
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
|
|
|
|
}
|
|
|
|
|
2020-03-18 03:45:36 +03:00
|
|
|
DrawBuf.WriteText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line);
|
|
|
|
if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line);
|
2016-12-21 13:56:06 +03:00
|
|
|
if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
|
|
|
|
if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
|
2015-03-16 17:20:32 +03:00
|
|
|
if (link) {
|
2020-03-22 22:54:20 +03:00
|
|
|
if (line[0]==' ') && (line[1]==NULL) {} else {
|
2020-03-22 22:50:16 +03:00
|
|
|
DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]);
|
|
|
|
PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom);
|
|
|
|
}
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2014-03-30 15:57:13 +04:00
|
|
|
stolbec += stolbec_len;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
}
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
|
|
|
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
|
|
|
|
bufsize = in_filesize;
|
|
|
|
bufpointer = bufpos;
|
2015-08-23 13:12:13 +03:00
|
|
|
Prepare();
|
2015-08-19 15:54:01 +03:00
|
|
|
}
|
|
|
|
//============================================================================================
|
2020-03-22 22:50:16 +03:00
|
|
|
void TWebBrowser::SetPageDefaults()
|
|
|
|
{
|
|
|
|
style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
|
|
|
|
style.li = link = text_color_index = text_colors[0] = style.li_tab = false;
|
2015-08-19 15:48:31 +03:00
|
|
|
style.align = ALIGN_LEFT;
|
2014-01-20 02:46:58 +04:00
|
|
|
link_color_inactive = 0x0000FF;
|
|
|
|
link_color_active = 0xFF0000;
|
2020-03-21 21:49:45 +03:00
|
|
|
page_bg = 0xFFFFFF;
|
|
|
|
style.bg_color = page_bg;
|
|
|
|
DrawBuf.Fill(0, page_bg);
|
2014-01-21 23:22:03 +04:00
|
|
|
PageLinks.Clear();
|
2013-12-27 03:36:17 +04:00
|
|
|
strcpy(#header, #version);
|
2020-03-22 22:50:16 +03:00
|
|
|
cur_encoding = CH_NULL;
|
2016-12-12 01:58:11 +03:00
|
|
|
draw_y = body_magrin;
|
2013-12-27 03:36:17 +04:00
|
|
|
stolbec = 0;
|
|
|
|
line = 0;
|
2020-03-22 22:50:16 +03:00
|
|
|
zoom = 1;
|
|
|
|
}
|
|
|
|
//============================================================================================
|
|
|
|
void TWebBrowser::Prepare(){
|
|
|
|
word bukva[2];
|
|
|
|
dword j;
|
|
|
|
bool ignor_param;
|
|
|
|
dword bufpos;
|
|
|
|
dword line_len;
|
|
|
|
SetPageDefaults();
|
|
|
|
if (strstri(bufpointer, "<html")==-1) style.pre = true; //show linebreaks for a plaint text
|
2020-03-23 04:11:31 +03:00
|
|
|
else if (strstri(bufpointer, "<body")==-1) t_body = true;
|
2015-08-27 02:45:56 +03:00
|
|
|
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-01-22 04:08:47 +04:00
|
|
|
bukva = ESBYTE[bufpos];
|
2013-12-27 03:36:17 +04:00
|
|
|
switch (bukva)
|
|
|
|
{
|
|
|
|
case 0x0a:
|
2015-08-19 15:48:31 +03:00
|
|
|
if (style.pre)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2015-09-01 12:36:58 +03:00
|
|
|
DrawStyle();
|
2016-12-04 21:51:23 +03:00
|
|
|
line = NULL;
|
2015-09-01 12:36:58 +03:00
|
|
|
NewLine();
|
2014-03-31 22:01:40 +04:00
|
|
|
break;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2016-12-04 21:51:23 +03:00
|
|
|
goto DEFAULT_MARK;
|
2013-12-27 03:36:17 +04:00
|
|
|
case '\9':
|
2016-11-21 23:25:00 +03:00
|
|
|
if (style.pre) //otherwise go to 0x0d
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-03-31 21:14:16 +04:00
|
|
|
tab_len = strlen(#line) % 4;
|
|
|
|
if (!tab_len) tab_len = 4;
|
2013-12-27 03:36:17 +04:00
|
|
|
for (j=0; j<tab_len; j++;) chrcat(#line,' ');
|
|
|
|
break;
|
|
|
|
}
|
2016-12-04 21:51:23 +03:00
|
|
|
goto DEFAULT_MARK;
|
2013-12-27 03:36:17 +04:00
|
|
|
case '&': // and so on
|
2014-01-22 04:08:47 +04:00
|
|
|
bufpos++;
|
2013-12-27 03:36:17 +04:00
|
|
|
tag=0;
|
2014-01-22 04:08:47 +04:00
|
|
|
for (j=0; (ESBYTE[bufpos]<>';') && (j<7); j++, bufpos++;)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-01-22 04:08:47 +04:00
|
|
|
bukva = ESBYTE[bufpos];
|
2013-12-27 03:36:17 +04:00
|
|
|
chrcat(#tag, bukva);
|
|
|
|
}
|
2013-12-29 16:48:06 +04:00
|
|
|
if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
|
2013-12-27 03:36:17 +04:00
|
|
|
break;
|
|
|
|
case '<':
|
2015-08-19 18:14:52 +03:00
|
|
|
bufpos++;
|
2015-08-23 22:59:44 +03:00
|
|
|
if (!strncmp(bufpos,"!--",3))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2017-09-17 15:35:45 +03:00
|
|
|
bufpos+=3;
|
|
|
|
while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize)
|
|
|
|
{
|
|
|
|
bufpos++;
|
|
|
|
}
|
2020-03-22 22:50:16 +03:00
|
|
|
bufpos+=2;
|
2017-09-17 15:35:45 +03:00
|
|
|
break;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-23 22:59:44 +03:00
|
|
|
tag = attr = tagparam = ignor_param = NULL;
|
2016-11-21 23:25:00 +03:00
|
|
|
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-01-22 04:08:47 +04:00
|
|
|
bukva = ESBYTE[bufpos];
|
2013-12-27 03:36:17 +04:00
|
|
|
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
|
|
|
|
if (!ignor_param) && (bukva <>' ')
|
|
|
|
{
|
2016-11-07 23:57:40 +03:00
|
|
|
if (strlen(#tag)+1<sizeof(tag)) chrcat(#tag, bukva);
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ignor_param = true;
|
2020-03-22 22:50:16 +03:00
|
|
|
if (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2014-01-22 04:08:47 +04:00
|
|
|
bufpos++;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
strlwr(#tag);
|
|
|
|
|
2020-03-22 22:50:16 +03:00
|
|
|
// ignore text inside the next tags
|
|
|
|
if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) {
|
2020-03-23 04:11:31 +03:00
|
|
|
sprintf(#tagparam, "</%s>", #tag);
|
|
|
|
j = strstri(bufpos, #tagparam);
|
2020-03-22 22:50:16 +03:00
|
|
|
if (j!=-1) {
|
|
|
|
bufpos = j;
|
|
|
|
}
|
2020-03-23 04:11:31 +03:00
|
|
|
tag = tagparam = NULL;
|
2020-03-22 22:50:16 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-12-27 03:36:17 +04:00
|
|
|
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
2014-03-31 22:01:40 +04:00
|
|
|
if (tagparam) GetNextParam();
|
2020-03-22 22:50:16 +03:00
|
|
|
|
|
|
|
if (tag[0] == '/')
|
|
|
|
{
|
|
|
|
opened = 0;
|
|
|
|
strcpy(#tag, #tag+1);
|
|
|
|
}
|
|
|
|
else opened = 1;
|
|
|
|
|
|
|
|
if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
|
|
|
|
Perenos();
|
|
|
|
DrawStyle();
|
|
|
|
line = NULL;
|
2020-03-23 04:11:31 +03:00
|
|
|
if (tag) SetStyle();
|
2020-03-22 22:50:16 +03:00
|
|
|
}
|
2016-11-07 23:57:40 +03:00
|
|
|
strlcpy(#oldtag, #tag, sizeof(oldtag));
|
2015-08-19 15:48:31 +03:00
|
|
|
tag = attr = tagparam = ignor_param = NULL;
|
2013-12-27 03:36:17 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
DEFAULT_MARK:
|
|
|
|
if (bukva<=15) bukva=' ';
|
2016-01-01 19:51:53 +03:00
|
|
|
line_len = strlen(#line);
|
2015-08-19 15:48:31 +03:00
|
|
|
if (!style.pre) && (bukva == ' ')
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-03-31 22:01:40 +04:00
|
|
|
if (line[line_len-1]==' ') break; //no double spaces
|
|
|
|
if (!stolbec) && (!line) break; //no paces at the beginning of the line
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2014-03-31 22:01:40 +04:00
|
|
|
if (line_len < sizeof(line)) chrcat(#line, bukva);
|
2015-08-23 22:59:44 +03:00
|
|
|
Perenos();
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
}
|
2015-08-23 13:12:13 +03:00
|
|
|
DrawStyle();
|
2014-03-24 02:49:49 +04:00
|
|
|
NewLine();
|
2016-12-12 01:58:11 +03:00
|
|
|
if (list.first == 0) list.count = draw_y;
|
2016-11-22 17:04:10 +03:00
|
|
|
DrawPage();
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
2014-03-30 15:57:13 +04:00
|
|
|
void TWebBrowser::Perenos()
|
|
|
|
{
|
|
|
|
int perenos_num;
|
|
|
|
char new_line_text[4096];
|
2016-12-21 13:56:06 +03:00
|
|
|
if (strlen(#line)*zoom + stolbec < list.column_max) return;
|
2014-03-30 15:57:13 +04:00
|
|
|
perenos_num = strrchr(#line, ' ');
|
2020-03-21 17:33:54 +03:00
|
|
|
if (!perenos_num) && (strlen(#line)*zoom>list.column_max) {
|
|
|
|
perenos_num=list.column_max/zoom;
|
|
|
|
if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt
|
|
|
|
}
|
2014-03-30 15:57:13 +04:00
|
|
|
strcpy(#new_line_text, #line + perenos_num);
|
|
|
|
line[perenos_num] = 0x00;
|
2015-08-23 13:12:13 +03:00
|
|
|
DrawStyle();
|
2014-03-30 15:57:13 +04:00
|
|
|
strcpy(#line, #new_line_text);
|
|
|
|
NewLine();
|
|
|
|
}
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
2015-08-27 02:45:56 +03:00
|
|
|
void TWebBrowser::SetStyle() {
|
2020-03-21 17:33:54 +03:00
|
|
|
char img_path[4096];
|
2016-12-12 01:58:11 +03:00
|
|
|
int left1 = body_magrin + list.x;
|
2020-03-21 17:33:54 +03:00
|
|
|
int meta_encoding;
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("html")) {
|
2014-03-13 03:30:28 +04:00
|
|
|
t_html = opened;
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if(istag("title")) {
|
2014-01-20 02:46:58 +04:00
|
|
|
if (opened) header=NULL;
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-19 15:48:31 +03:00
|
|
|
IF(istag("q"))
|
2014-01-20 02:46:58 +04:00
|
|
|
{
|
2015-08-19 15:48:31 +03:00
|
|
|
if (opened) strcat(#line, " \"");
|
|
|
|
if (!opened) strcat(#line, "\" ");
|
2015-08-19 18:14:52 +03:00
|
|
|
return;
|
2014-01-20 02:46:58 +04:00
|
|
|
}
|
2020-03-18 03:45:36 +03:00
|
|
|
if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last
|
|
|
|
anchors.add(#val, draw_y);
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("body")) {
|
2014-03-13 03:30:28 +04:00
|
|
|
t_body = opened;
|
2013-12-27 03:36:17 +04:00
|
|
|
do{
|
2015-08-19 15:48:31 +03:00
|
|
|
if (isattr("link=")) link_color_inactive = GetColor(#val);
|
|
|
|
if (isattr("alink=")) link_color_active = GetColor(#val);
|
|
|
|
if (isattr("text=")) text_colors[0]=GetColor(#val);
|
|
|
|
if (isattr("bgcolor="))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2020-03-21 21:49:45 +03:00
|
|
|
style.bg_color = page_bg = GetColor(#val);
|
|
|
|
DrawBuf.Fill(0, page_bg);
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
} while(GetNextParam());
|
2017-09-28 21:59:04 +03:00
|
|
|
if (opened) && (cur_encoding==CH_NULL) {
|
2020-03-21 17:33:54 +03:00
|
|
|
cur_encoding = CH_CP866;
|
|
|
|
//BufEncode(CH_UTF8);
|
|
|
|
debugln("Document has no information about encoding!");
|
2017-09-28 21:59:04 +03:00
|
|
|
}
|
|
|
|
if (opened) {
|
2018-03-23 18:04:20 +03:00
|
|
|
if (strcmp(#header, #version) != 0) {
|
2017-10-06 20:50:03 +03:00
|
|
|
ChangeCharset(charsets[cur_encoding], "CP866", #header);
|
|
|
|
sprintf(#header, "%s - %s", #header, #version);
|
|
|
|
}
|
2017-09-28 21:59:04 +03:00
|
|
|
DrawTitle(#header);
|
|
|
|
}
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("a")) {
|
2014-01-20 02:46:58 +04:00
|
|
|
if (opened)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2016-11-21 23:25:00 +03:00
|
|
|
if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
|
2013-12-27 03:36:17 +04:00
|
|
|
do{
|
2015-12-22 21:14:35 +03:00
|
|
|
if (isattr("href=")) && (!strstr(#val,"javascript:"))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
|
|
|
text_color_index++;
|
|
|
|
text_colors[text_color_index] = text_colors[text_color_index-1];
|
|
|
|
link = 1;
|
2014-01-20 02:46:58 +04:00
|
|
|
text_colors[text_color_index] = link_color_inactive;
|
2016-12-14 01:08:14 +03:00
|
|
|
PageLinks.AddLink(#val);
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
} while(GetNextParam());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
link = 0;
|
|
|
|
IF(text_color_index > 0) text_color_index--;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("font")) {
|
2020-03-21 21:49:45 +03:00
|
|
|
style.bg_color = page_bg;
|
2014-01-20 02:46:58 +04:00
|
|
|
if (opened)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
|
|
|
text_color_index++;
|
|
|
|
text_colors[text_color_index] = text_colors[text_color_index-1];
|
|
|
|
do{
|
2015-08-19 18:14:52 +03:00
|
|
|
if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
|
2020-03-21 21:49:45 +03:00
|
|
|
if (isattr("bg=")) style.bg_color = GetColor(#val);
|
2013-12-27 03:36:17 +04:00
|
|
|
} while(GetNextParam());
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
else if (text_color_index > 0) text_color_index--;
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
2020-03-22 22:50:16 +03:00
|
|
|
if (istag("div")) {
|
|
|
|
if (streq(#oldtag,"div")) && (opened) return;
|
|
|
|
NewLine();
|
|
|
|
//IF (oldtag[0] != 'h')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (istag("header")) || (istag("article")) || (istag("footer")) || (istag("figure")) {
|
|
|
|
NewLine();
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-08-19 15:48:31 +03:00
|
|
|
if (istag("p")) {
|
2020-03-22 22:50:16 +03:00
|
|
|
IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return;
|
2014-03-24 02:49:49 +04:00
|
|
|
NewLine();
|
2020-03-22 22:50:16 +03:00
|
|
|
//IF(opened) NewLine();
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("br")) { NewLine(); return; }
|
2015-12-20 18:50:48 +03:00
|
|
|
if (istag("tr")) { if (opened) NewLine(); return; }
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; }
|
2020-03-21 17:33:54 +03:00
|
|
|
if (istag("button")) { style.button = opened; stolbec++; return; }
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("u")) || (istag("ins")) { style.u=opened; return;}
|
|
|
|
if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; }
|
|
|
|
if (istag("dd")) { stolbec += 5; return; }
|
|
|
|
if (istag("blockquote")) { style.blq = opened; return; }
|
|
|
|
if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
|
2020-03-21 17:33:54 +03:00
|
|
|
if (istag("img")) {
|
|
|
|
do{
|
2020-03-23 04:11:31 +03:00
|
|
|
if (isattr("src=")) strncpy(#img_path, #val, sizeof(img_path)-1);
|
|
|
|
if (isattr("alt=")) && (strlen(#val)<sizeof(line)-3) sprintf(#line, "[%s]", #val);
|
|
|
|
if (isattr("title=")) && (strlen(#val)<sizeof(line)-3) sprintf(#line, "[%s]", #val);
|
2020-03-21 17:33:54 +03:00
|
|
|
} while(GetNextParam());
|
|
|
|
style.image = true;
|
|
|
|
text_color_index++;
|
|
|
|
text_colors[text_color_index] = 0x9A6F29;
|
|
|
|
if (!line) {
|
|
|
|
if (!strncmp(#img_path, "data:", 5)) img_path=0;
|
|
|
|
sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
|
|
|
|
line[50]= NULL;
|
|
|
|
}
|
|
|
|
if (strlen(#line) + stolbec > list.column_max) Perenos();
|
|
|
|
DrawStyle();
|
|
|
|
line=0;
|
|
|
|
text_color_index--;
|
|
|
|
style.image = false;
|
|
|
|
//ImgCache.Images( left1, draw_y, WB1.list.w);
|
|
|
|
return;
|
|
|
|
}
|
2018-03-23 18:04:20 +03:00
|
|
|
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) {
|
2015-08-23 22:59:44 +03:00
|
|
|
style.h = opened;
|
2014-01-20 02:46:58 +04:00
|
|
|
if (opened)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2016-12-12 01:58:11 +03:00
|
|
|
NewLine();
|
|
|
|
draw_y += 10;
|
2016-12-21 13:56:06 +03:00
|
|
|
WB1.zoom=2;
|
2016-01-08 05:19:41 +03:00
|
|
|
WB1.list.font_type |= 10011001b;
|
2015-08-19 15:48:31 +03:00
|
|
|
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
|
|
|
|
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
|
2016-12-12 01:58:11 +03:00
|
|
|
list.item_h = basic_line_h * 2;
|
2020-03-21 17:33:54 +03:00
|
|
|
if (istag("h1")) style.b = true;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-23 22:59:44 +03:00
|
|
|
else
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2020-03-21 17:33:54 +03:00
|
|
|
if (istag("h1")) style.b = false;
|
2016-12-12 01:58:11 +03:00
|
|
|
NewLine();
|
2016-12-21 13:56:06 +03:00
|
|
|
WB1.zoom=1;
|
2016-01-08 05:19:41 +03:00
|
|
|
WB1.list.font_type = 10011000b;
|
2015-08-19 15:48:31 +03:00
|
|
|
style.align = ALIGN_LEFT;
|
2016-12-12 01:58:11 +03:00
|
|
|
list.item_h = basic_line_h;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("dt")) {
|
2015-08-19 15:48:31 +03:00
|
|
|
style.li = opened;
|
2015-08-19 18:14:52 +03:00
|
|
|
if (opened) NewLine();
|
2013-12-29 16:48:06 +04:00
|
|
|
return;
|
|
|
|
}
|
2015-08-27 02:45:56 +03:00
|
|
|
if (istag("li")) || (istag("dt"))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2015-08-19 15:48:31 +03:00
|
|
|
style.li = opened;
|
2014-01-20 02:46:58 +04:00
|
|
|
if (opened)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-03-24 02:49:49 +04:00
|
|
|
NewLine();
|
2020-03-21 21:49:45 +03:00
|
|
|
stolbec = style.li_tab * 5 - 2;
|
2020-03-21 17:33:54 +03:00
|
|
|
strcpy(#line, "\31 ");
|
2020-03-21 21:49:45 +03:00
|
|
|
//stolbec-=2;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("ul")) || (istag("ol")) {
|
|
|
|
if (!opened)
|
|
|
|
{
|
|
|
|
style.li = opened;
|
|
|
|
style.li_tab--;
|
|
|
|
NewLine();
|
|
|
|
}
|
|
|
|
else style.li_tab++;
|
|
|
|
}
|
|
|
|
if (istag("hr")) {
|
2015-08-27 02:45:56 +03:00
|
|
|
if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
|
|
|
|
$push edi;
|
2014-03-24 02:49:49 +04:00
|
|
|
NewLine();
|
2015-08-27 02:45:56 +03:00
|
|
|
$pop edi;
|
2020-03-22 22:50:16 +03:00
|
|
|
draw_y += 10;
|
2016-12-12 01:58:11 +03:00
|
|
|
DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
|
2014-03-24 02:49:49 +04:00
|
|
|
NewLine();
|
2020-03-22 22:50:16 +03:00
|
|
|
draw_y += 10;
|
2015-08-27 02:45:56 +03:00
|
|
|
return;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-19 18:14:52 +03:00
|
|
|
if (istag("meta")) || (istag("?xml")) {
|
2016-01-08 05:19:41 +03:00
|
|
|
meta_encoding = CH_NULL;
|
2013-12-27 03:36:17 +04:00
|
|
|
do{
|
2015-08-19 15:48:31 +03:00
|
|
|
if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2016-11-21 23:25:00 +03:00
|
|
|
strcpy(#val, #val[strrchr(#val, '=')]); //search in content=
|
2015-08-19 15:48:31 +03:00
|
|
|
strlwr(#val);
|
2015-08-19 18:14:52 +03:00
|
|
|
if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8;
|
2015-08-19 15:48:31 +03:00
|
|
|
else if (isval("koi8-r")) || (isval("koi8-u")) meta_encoding = CH_KOI8;
|
|
|
|
else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251;
|
|
|
|
else if (isval("iso-8859-5")) || (isval("iso8859-5")) meta_encoding = CH_ISO8859_5;
|
|
|
|
else if (isval("dos")) || (isval("cp-866")) meta_encoding = CH_CP866;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
} while(GetNextParam());
|
2016-01-08 05:19:41 +03:00
|
|
|
if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-03-22 22:50:16 +03:00
|
|
|
//============================================================================================
|
2016-12-21 13:56:06 +03:00
|
|
|
void TWebBrowser::BufEncode(dword set_new_encoding)
|
2015-08-10 10:09:10 +03:00
|
|
|
{
|
2017-09-28 21:59:04 +03:00
|
|
|
if (cur_encoding == set_new_encoding) return;
|
2015-08-10 10:09:10 +03:00
|
|
|
if (o_bufpointer==0)
|
|
|
|
{
|
|
|
|
o_bufpointer = malloc(bufsize);
|
|
|
|
strcpy(o_bufpointer, bufpointer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(bufpointer, o_bufpointer);
|
|
|
|
}
|
2020-03-21 17:33:54 +03:00
|
|
|
//debugval("cur_encoding ", cur_encoding);
|
|
|
|
//debugval("set_new_encoding", set_new_encoding);
|
2017-09-28 21:59:04 +03:00
|
|
|
cur_encoding = set_new_encoding;
|
|
|
|
bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
|
2015-08-10 10:09:10 +03:00
|
|
|
}
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
2014-03-22 01:21:11 +04:00
|
|
|
void TWebBrowser::DrawScroller()
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2013-12-27 16:30:42 +04:00
|
|
|
scroll_wv.max_area = list.count;
|
|
|
|
scroll_wv.cur_area = list.visible;
|
|
|
|
scroll_wv.position = list.first;
|
2015-03-16 17:20:32 +03:00
|
|
|
scroll_wv.all_redraw = 0;
|
2014-01-19 21:12:45 +04:00
|
|
|
scroll_wv.start_x = list.x + list.w;
|
2014-01-22 04:08:47 +04:00
|
|
|
scroll_wv.start_y = list.y;
|
2015-08-05 01:21:08 +03:00
|
|
|
scroll_wv.size_y = list.h;
|
2013-12-27 16:30:42 +04:00
|
|
|
scrollbar_v_draw(#scroll_wv);
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
2014-03-24 02:49:49 +04:00
|
|
|
void TWebBrowser::NewLine()
|
2014-01-18 15:46:58 +04:00
|
|
|
{
|
2016-12-21 13:56:06 +03:00
|
|
|
dword onleft, ontop;
|
2020-03-21 17:33:54 +03:00
|
|
|
static int empty_line=0;
|
2014-03-24 02:49:49 +04:00
|
|
|
|
2016-12-12 01:58:11 +03:00
|
|
|
if (!stolbec) && (draw_y==body_magrin) return;
|
2020-03-21 17:33:54 +03:00
|
|
|
|
|
|
|
if (!stolbec) {
|
|
|
|
if (empty_line<1) empty_line++;
|
|
|
|
else return;
|
|
|
|
} else {
|
|
|
|
empty_line=0;
|
|
|
|
}
|
2016-12-12 01:58:11 +03:00
|
|
|
|
|
|
|
onleft = list.x + body_magrin;
|
|
|
|
ontop = draw_y + list.y;
|
2014-03-13 03:30:28 +04:00
|
|
|
if (t_html) && (!t_body) return;
|
2016-12-12 01:58:11 +03:00
|
|
|
draw_y += list.item_h;
|
2015-08-19 15:48:31 +03:00
|
|
|
if (style.blq) stolbec = 6; else stolbec = 0;
|
|
|
|
if (style.li) stolbec = style.li_tab * 5;
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
2015-08-19 15:54:01 +03:00
|
|
|
//============================================================================================
|
2016-12-21 13:56:06 +03:00
|
|
|
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
|
|
|
|
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
|
|
|
|
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
|
2015-08-23 13:12:13 +03:00
|
|
|
//============================================================================================
|
|
|
|
void TWebBrowser::DrawPage()
|
|
|
|
{
|
2016-12-12 01:58:11 +03:00
|
|
|
PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
|
2015-08-23 13:12:13 +03:00
|
|
|
DrawScroller();
|
|
|
|
}
|