2015-08-19 17:14:52 +02:00
|
|
|
|
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2014-03-22 11:29:29 +01: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 13:30:42 +01:00
|
|
|
|
|
2015-08-19 14:48:31 +02:00
|
|
|
|
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
|
|
|
|
|
|
|
|
|
|
struct _style {
|
|
|
|
|
byte
|
2015-08-23 21:59:44 +02:00
|
|
|
|
b, i, u, s, h,
|
2015-08-19 14:48:31 +02:00
|
|
|
|
pre,
|
|
|
|
|
blq,
|
|
|
|
|
li,
|
|
|
|
|
li_tab,
|
|
|
|
|
align;
|
|
|
|
|
};
|
2013-12-27 13:30:42 +01:00
|
|
|
|
|
2013-12-27 00:36:17 +01:00
|
|
|
|
struct TWebBrowser {
|
2014-01-27 21:16:33 +01:00
|
|
|
|
llist list;
|
2015-08-19 14:48:31 +02:00
|
|
|
|
_style style;
|
2014-01-18 12:46:58 +01:00
|
|
|
|
DrawBufer DrawBuf;
|
2015-08-23 12:12:13 +02:00
|
|
|
|
void Prepare();
|
|
|
|
|
void SetStyle();
|
|
|
|
|
void DrawStyle();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
void DrawPage();
|
|
|
|
|
void DrawScroller();
|
2015-08-19 14:54:01 +02:00
|
|
|
|
void LoadInternalPage();
|
2014-03-15 16:16:08 +01:00
|
|
|
|
void NewLine();
|
2014-03-30 13:57:13 +02:00
|
|
|
|
void Perenos();
|
2015-08-19 17:14:52 +02:00
|
|
|
|
void BufEncode();
|
2014-03-23 18:12:21 +01:00
|
|
|
|
} WB1;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2015-08-19 14:48:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte
|
|
|
|
|
link,
|
|
|
|
|
ignor_text,
|
|
|
|
|
cur_encoding,
|
|
|
|
|
t_html,
|
|
|
|
|
t_body;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2015-08-19 17:14:52 +02:00
|
|
|
|
dword bufpointer;
|
|
|
|
|
dword o_bufpointer;
|
|
|
|
|
dword bufsize;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2013-12-29 13:48:06 +01:00
|
|
|
|
dword text_colors[300];
|
|
|
|
|
dword text_color_index;
|
2014-01-19 23:46:58 +01:00
|
|
|
|
dword link_color_inactive;
|
|
|
|
|
dword link_color_active;
|
2013-12-29 13:48:06 +01:00
|
|
|
|
dword bg_color;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2013-12-29 13:48:06 +01:00
|
|
|
|
int stroka;
|
|
|
|
|
int stolbec;
|
|
|
|
|
int tab_len;
|
|
|
|
|
int anchor_line_num;
|
2014-03-12 23:56:28 +01:00
|
|
|
|
|
2015-08-19 14:48:31 +02:00
|
|
|
|
char URL[10000];
|
|
|
|
|
char header[2048];
|
2013-12-29 13:48:06 +01:00
|
|
|
|
char line[500];
|
|
|
|
|
char tagparam[10000];
|
2015-08-19 14:48:31 +02:00
|
|
|
|
char tag[100];
|
2015-08-23 21:59:44 +02:00
|
|
|
|
char oldtag[100];
|
2015-08-19 14:48:31 +02:00
|
|
|
|
char attr[1200];
|
|
|
|
|
char val[4096];
|
2015-08-23 21:59:44 +02:00
|
|
|
|
char anchor[256]=0;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
#include "..\TWB\history.h"
|
2014-03-23 18:12:21 +01:00
|
|
|
|
#include "..\TWB\links.h"
|
2013-12-27 00:36:17 +01:00
|
|
|
|
#include "..\TWB\colors.h"
|
|
|
|
|
#include "..\TWB\unicode_tags.h"
|
|
|
|
|
#include "..\TWB\img_cache.h"
|
|
|
|
|
#include "..\TWB\parce_tag.h"
|
2014-01-18 12:46:58 +01:00
|
|
|
|
|
|
|
|
|
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
2015-08-23 12:12:13 +02:00
|
|
|
|
void TWebBrowser::DrawStyle()
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-23 12:12:13 +02:00
|
|
|
|
int start_x, start_y, line_length, stolbec_len, body_magrin=5;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
|
|
|
|
if (!header)
|
|
|
|
|
{
|
2015-08-13 14:23:35 +02:00
|
|
|
|
ChangeCharset("UTF-8", "CP866", #line);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
strcpy(#header, #line);
|
|
|
|
|
strcat(#header, " -");
|
|
|
|
|
strcat(#header, #version);
|
|
|
|
|
line = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-03-13 00:30:28 +01:00
|
|
|
|
if (t_html) && (!t_body) return;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2015-08-23 12:12:13 +02:00
|
|
|
|
if (line) && (!anchor)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-23 12:12:13 +02:00
|
|
|
|
start_x = stolbec * list.font_w + body_magrin * DrawBuf.zoom + list.x;
|
|
|
|
|
start_y = stroka * list.line_h + body_magrin;
|
2015-08-23 21:59:44 +02:00
|
|
|
|
stolbec_len = utf8_strlen(#line) * DrawBuf.zoom;
|
|
|
|
|
line_length = stolbec_len * list.font_w;
|
2015-08-05 00:21:08 +02:00
|
|
|
|
|
2015-08-23 21:59:44 +02:00
|
|
|
|
if (style.h) stroka++;
|
2015-08-23 12:12:13 +02:00
|
|
|
|
WriteBufText(start_x, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
|
|
|
|
|
if (style.b) WriteBufText(start_x+1, start_y, list.font_type, text_colors[text_color_index], #line, buf_data);
|
|
|
|
|
if (style.i) { stolbec++; DrawBuf.Skew(start_x, start_y, line_length, list.line_h); } // bug with zoom>1
|
|
|
|
|
if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
|
|
|
|
if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
2015-03-16 15:20:32 +01:00
|
|
|
|
if (link) {
|
2015-08-27 01:45:56 +02:00
|
|
|
|
DrawBuf.DrawBar(start_x, list.line_h*style.h + list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
|
|
|
|
|
PageLinks.AddText(#line, line_length, list.line_h*style.h + list.line_h, UNDERLINE);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
2014-03-30 13:57:13 +02:00
|
|
|
|
stolbec += stolbec_len;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
|
|
|
|
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
|
|
|
|
|
bufsize = in_filesize;
|
|
|
|
|
bufpointer = bufpos;
|
2015-08-23 12:12:13 +02:00
|
|
|
|
Prepare();
|
2015-08-19 14:54:01 +02:00
|
|
|
|
}
|
|
|
|
|
//============================================================================================
|
2015-08-23 12:12:13 +02:00
|
|
|
|
void TWebBrowser::Prepare(){
|
2013-12-27 00:36:17 +01:00
|
|
|
|
word bukva[2];
|
2014-03-30 13:57:13 +02:00
|
|
|
|
int j;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
byte ignor_param;
|
2015-08-27 01:45:56 +02:00
|
|
|
|
dword bufpos;
|
|
|
|
|
int line_len;
|
2015-08-23 21:59:44 +02:00
|
|
|
|
style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body =
|
2015-08-19 17:14:52 +02:00
|
|
|
|
style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
|
2015-08-19 14:48:31 +02:00
|
|
|
|
style.align = ALIGN_LEFT;
|
2014-01-19 23:46:58 +01:00
|
|
|
|
link_color_inactive = 0x0000FF;
|
|
|
|
|
link_color_active = 0xFF0000;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
bg_color = 0xFFFFFF;
|
2014-01-18 12:46:58 +01:00
|
|
|
|
DrawBuf.Fill(bg_color);
|
2014-01-21 20:22:03 +01:00
|
|
|
|
PageLinks.Clear();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
strcpy(#header, #version);
|
2013-12-27 12:15:17 +01:00
|
|
|
|
stroka = -list.first;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
stolbec = 0;
|
|
|
|
|
line = 0;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
//for plaint text use CP866 for other UTF
|
|
|
|
|
if (strstri(bufpointer, "html"))
|
|
|
|
|
{
|
|
|
|
|
style.pre = 0;
|
2015-08-27 01:45:56 +02:00
|
|
|
|
cur_encoding = CH_UTF8;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
style.pre = 1;
|
2015-08-27 01:45:56 +02:00
|
|
|
|
cur_encoding = CH_CP866;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
}
|
2015-08-27 01:45:56 +02:00
|
|
|
|
for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-27 01:45:56 +02:00
|
|
|
|
if (ignor_text) && (ESBYTE[bufpos]!='<') continue;
|
2014-01-22 01:08:47 +01:00
|
|
|
|
bukva = ESBYTE[bufpos];
|
2013-12-27 00:36:17 +01:00
|
|
|
|
switch (bukva)
|
|
|
|
|
{
|
|
|
|
|
case 0x0a:
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (style.pre)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2014-03-23 18:12:21 +01:00
|
|
|
|
chrcat(#line, ' ');
|
2014-03-30 13:57:13 +02:00
|
|
|
|
Perenos();
|
2014-03-31 20:01:40 +02:00
|
|
|
|
break;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
case '\9':
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (style.pre) //<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> 0x0d
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2014-03-31 19:14:16 +02:00
|
|
|
|
tab_len = strlen(#line) % 4;
|
|
|
|
|
if (!tab_len) tab_len = 4;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
for (j=0; j<tab_len; j++;) chrcat(#line,' ');
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
goto DEFAULT_MARK;
|
|
|
|
|
case '&': // and so on
|
2014-01-22 01:08:47 +01:00
|
|
|
|
bufpos++;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
tag=0;
|
2014-01-22 01:08:47 +01:00
|
|
|
|
for (j=0; (ESBYTE[bufpos]<>';') && (j<7); j++, bufpos++;)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2014-01-22 01:08:47 +01:00
|
|
|
|
bukva = ESBYTE[bufpos];
|
2013-12-27 00:36:17 +01:00
|
|
|
|
chrcat(#tag, bukva);
|
|
|
|
|
}
|
2013-12-29 13:48:06 +01:00
|
|
|
|
if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
break;
|
|
|
|
|
case '<':
|
2015-08-19 17:14:52 +02:00
|
|
|
|
bufpos++;
|
2015-08-23 21:59:44 +02:00
|
|
|
|
if (!strncmp(bufpos,"!--",3))
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-23 21:59:44 +02:00
|
|
|
|
if (!strncmp(bufpos,"-->",3)) || (bufpointer + bufsize <= bufpos) break;
|
2014-01-22 01:08:47 +01:00
|
|
|
|
bufpos++;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
2015-08-23 21:59:44 +02:00
|
|
|
|
tag = attr = tagparam = ignor_param = NULL;
|
2014-01-30 19:28:50 +01:00
|
|
|
|
while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2014-01-22 01:08:47 +01:00
|
|
|
|
bukva = ESBYTE[bufpos];
|
2013-12-27 00:36:17 +01:00
|
|
|
|
if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
|
|
|
|
|
if (!ignor_param) && (bukva <>' ')
|
|
|
|
|
{
|
2014-03-31 20:01:40 +02:00
|
|
|
|
if (strlen(#tag)<sizeof(tag)) chrcat(#tag, bukva);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ignor_param = true;
|
|
|
|
|
if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
|
|
|
|
|
}
|
2014-01-22 01:08:47 +01:00
|
|
|
|
bufpos++;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
strlwr(#tag);
|
|
|
|
|
|
|
|
|
|
if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
|
2014-03-31 20:01:40 +02:00
|
|
|
|
if (tagparam) GetNextParam();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2015-08-23 21:59:44 +02:00
|
|
|
|
Perenos();
|
2015-08-23 12:12:13 +02:00
|
|
|
|
DrawStyle();
|
2014-03-22 11:29:29 +01:00
|
|
|
|
line = NULL;
|
2015-08-27 01:45:56 +02:00
|
|
|
|
if (tag) SetStyle(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
2015-08-23 21:59:44 +02:00
|
|
|
|
strcpy(#oldtag, #tag);
|
2015-08-19 14:48:31 +02:00
|
|
|
|
tag = attr = tagparam = ignor_param = NULL;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
DEFAULT_MARK:
|
|
|
|
|
if (bukva<=15) bukva=' ';
|
2015-08-10 17:38:08 +02:00
|
|
|
|
line_len = utf8_strlen(#line);
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (!style.pre) && (bukva == ' ')
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2014-03-31 20:01:40 +02: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 00:36:17 +01:00
|
|
|
|
}
|
2014-03-31 20:01:40 +02:00
|
|
|
|
if (line_len < sizeof(line)) chrcat(#line, bukva);
|
2015-08-23 21:59:44 +02:00
|
|
|
|
Perenos();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-23 12:12:13 +02:00
|
|
|
|
DrawStyle();
|
2014-03-23 23:49:49 +01:00
|
|
|
|
NewLine();
|
2015-08-23 12:12:13 +02:00
|
|
|
|
DrawPage();
|
2013-12-27 12:15:17 +01:00
|
|
|
|
if (list.first == 0) list.count = stroka;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
if (anchor) //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
anchor=NULL;
|
2013-12-27 12:15:17 +01:00
|
|
|
|
list.first=anchor_line_num;
|
2015-08-23 12:12:13 +02:00
|
|
|
|
Prepare();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
2014-03-30 13:57:13 +02:00
|
|
|
|
void TWebBrowser::Perenos()
|
|
|
|
|
{
|
|
|
|
|
int perenos_num;
|
|
|
|
|
char new_line_text[4096];
|
2015-08-27 01:45:56 +02:00
|
|
|
|
if (utf8_strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return;
|
2014-03-30 13:57:13 +02:00
|
|
|
|
perenos_num = strrchr(#line, ' ');
|
2015-08-27 01:45:56 +02:00
|
|
|
|
if (!perenos_num) && (utf8_strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom;
|
2014-03-30 13:57:13 +02:00
|
|
|
|
strcpy(#new_line_text, #line + perenos_num);
|
|
|
|
|
line[perenos_num] = 0x00;
|
2015-08-23 12:12:13 +02:00
|
|
|
|
DrawStyle();
|
2014-03-30 13:57:13 +02:00
|
|
|
|
strcpy(#line, #new_line_text);
|
|
|
|
|
NewLine();
|
|
|
|
|
}
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
2015-08-27 01:45:56 +02:00
|
|
|
|
void TWebBrowser::SetStyle() {
|
|
|
|
|
int left1 = 5 + list.x;
|
|
|
|
|
int top1 = stroka * list.line_h + list.y + 5;
|
2014-01-19 23:46:58 +01:00
|
|
|
|
byte opened;
|
2014-03-12 23:56:28 +01:00
|
|
|
|
byte meta_encoding;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if (tag[0] == '/')
|
|
|
|
|
{
|
2014-01-19 23:46:58 +01:00
|
|
|
|
opened = 0;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
strcpy(#tag, #tag+1);
|
|
|
|
|
}
|
2014-01-19 23:46:58 +01:00
|
|
|
|
else opened = 1;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("html")) {
|
2014-03-13 00:30:28 +01:00
|
|
|
|
t_html = opened;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; }
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (istag("form")) if (!opened) ignor_text = false;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if(istag("title")) {
|
2014-01-19 23:46:58 +01:00
|
|
|
|
if (opened) header=NULL;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
else if (!stroka) DrawTitle(#header); //<2F><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (ignor_text) return;
|
|
|
|
|
|
2015-08-19 14:48:31 +02:00
|
|
|
|
IF(istag("q"))
|
2014-01-19 23:46:58 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (opened) strcat(#line, " \"");
|
|
|
|
|
if (!opened) strcat(#line, "\" ");
|
2015-08-19 17:14:52 +02:00
|
|
|
|
return;
|
2014-01-19 23:46:58 +01:00
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (anchor) && (isattr("id=")) { //<2F><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>!!! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (!strcmp(#anchor, #val)) anchor_line_num=list.first+stroka;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
}
|
|
|
|
|
if (istag("body")) {
|
2014-03-13 00:30:28 +01:00
|
|
|
|
t_body = opened;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
do{
|
2015-08-19 14:48:31 +02: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 00:36:17 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
bg_color=GetColor(#val);
|
2014-01-18 12:46:58 +01:00
|
|
|
|
DrawBuf.Fill(bg_color);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
} while(GetNextParam());
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (opened) && (cur_encoding==CH_NULL) debugln("Document has no information about encoding, UTF will be used");
|
2013-12-27 00:36:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("a")) {
|
2014-01-19 23:46:58 +01:00
|
|
|
|
if (opened)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
|
|
|
|
if (link) IF(text_color_index > 0) text_color_index--; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
do{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (isattr("href="))
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
|
|
|
|
text_color_index++;
|
|
|
|
|
text_colors[text_color_index] = text_colors[text_color_index-1];
|
|
|
|
|
link = 1;
|
2014-01-19 23:46:58 +01:00
|
|
|
|
text_colors[text_color_index] = link_color_inactive;
|
2015-08-19 14:48:31 +02:00
|
|
|
|
PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (anchor) && (isattr("name="))
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (!strcmp(#anchor, #val))
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2013-12-27 12:15:17 +01:00
|
|
|
|
anchor_line_num=list.first+stroka;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while(GetNextParam());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
link = 0;
|
|
|
|
|
IF(text_color_index > 0) text_color_index--;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("font")) {
|
2014-01-19 23:46:58 +01:00
|
|
|
|
if (opened)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
|
|
|
|
text_color_index++;
|
|
|
|
|
text_colors[text_color_index] = text_colors[text_color_index-1];
|
|
|
|
|
do{
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
} while(GetNextParam());
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
else if (text_color_index > 0) text_color_index--;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
|
2015-08-19 17:14:52 +02:00
|
|
|
|
IF(oldtag[0] != 'h') NewLine();
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (isattr("bgcolor="))
|
2015-03-01 22:36:17 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
bg_color=GetColor(#val);
|
2015-03-01 22:36:17 +01:00
|
|
|
|
DrawBuf.Fill(bg_color);
|
|
|
|
|
}
|
2013-12-27 00:36:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (istag("p")) {
|
2013-12-27 00:36:17 +01:00
|
|
|
|
IF(oldtag[0] == 'h') return;
|
2014-03-23 23:49:49 +01:00
|
|
|
|
NewLine();
|
|
|
|
|
IF(opened) NewLine();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("br")) { NewLine(); return; }
|
|
|
|
|
if (istag("tr")) { if (opened) { NewLine(); strcat(#line, "| "); } return; }
|
|
|
|
|
if (istag("td")) || (istag("th")) { if (!opened) strcat(#line, " | "); return; }
|
|
|
|
|
if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; }
|
|
|
|
|
if (istag("i")) || (istag("em")) || (istag("subtitle")) { style.i=opened; return; }
|
|
|
|
|
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; }
|
|
|
|
|
if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; }
|
|
|
|
|
if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
|
2015-08-23 21:59:44 +02:00
|
|
|
|
style.h = opened;
|
2014-03-23 23:49:49 +01:00
|
|
|
|
NewLine();
|
2014-01-19 23:46:58 +01:00
|
|
|
|
if (opened)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-23 21:59:44 +02:00
|
|
|
|
WB1.DrawBuf.zoom=2;
|
|
|
|
|
WB1.list.SetFont(8, 14, 10111001b);
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
|
|
|
|
|
if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
|
2015-08-23 21:59:44 +02:00
|
|
|
|
if (stroka>1) NewLine();
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
2015-08-23 21:59:44 +02:00
|
|
|
|
else
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-23 21:59:44 +02:00
|
|
|
|
WB1.DrawBuf.zoom=1;
|
|
|
|
|
WB1.list.SetFont(8, 14, 10111000b);
|
2015-08-19 14:48:31 +02:00
|
|
|
|
style.align = ALIGN_LEFT;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("dt")) {
|
2015-08-19 14:48:31 +02:00
|
|
|
|
style.li = opened;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (opened) NewLine();
|
2013-12-29 13:48:06 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-27 01:45:56 +02:00
|
|
|
|
if (istag("li")) || (istag("dt"))
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
style.li = opened;
|
2014-01-19 23:46:58 +01:00
|
|
|
|
if (opened)
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2014-03-23 23:49:49 +01:00
|
|
|
|
NewLine();
|
2015-08-27 01:45:56 +02:00
|
|
|
|
DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, stroka +1 * list.line_h - 3
|
|
|
|
|
- DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-08-19 17:14:52 +02: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 01:45:56 +02:00
|
|
|
|
if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
|
|
|
|
|
$push edi;
|
2014-03-23 23:49:49 +01:00
|
|
|
|
NewLine();
|
2015-08-27 01:45:56 +02:00
|
|
|
|
$pop edi;
|
|
|
|
|
DrawBuf.DrawBar(5, list.line_h*stroka+4, list.w-10, 1, EDI);
|
2014-03-23 23:49:49 +01:00
|
|
|
|
NewLine();
|
2015-08-27 01:45:56 +02:00
|
|
|
|
return;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (istag("meta")) || (istag("?xml")) {
|
2013-12-27 00:36:17 +01:00
|
|
|
|
do{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
strcpy(#val, #val[strrchr(#val, '=')]); //<2F><><EFBFBD><EFBFBD><EFBFBD> <20> content=
|
|
|
|
|
strlwr(#val);
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8;
|
2015-08-19 14:48:31 +02: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;
|
2015-08-19 17:14:52 +02:00
|
|
|
|
if (cur_encoding!=meta_encoding) BufEncode(meta_encoding);
|
2014-03-12 23:56:28 +01:00
|
|
|
|
return;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
} while(GetNextParam());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 17:14:52 +02:00
|
|
|
|
void TWebBrowser::BufEncode(int set_new_encoding)
|
2015-08-10 09:09:10 +02:00
|
|
|
|
{
|
|
|
|
|
int bufpointer_realsize;
|
|
|
|
|
cur_encoding = set_new_encoding;
|
|
|
|
|
if (o_bufpointer==0)
|
|
|
|
|
{
|
|
|
|
|
o_bufpointer = malloc(bufsize);
|
|
|
|
|
strcpy(o_bufpointer, bufpointer);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strcpy(bufpointer, o_bufpointer);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
2014-03-21 22:21:11 +01:00
|
|
|
|
void TWebBrowser::DrawScroller()
|
2013-12-27 00:36:17 +01:00
|
|
|
|
{
|
2013-12-27 13:30:42 +01:00
|
|
|
|
scroll_wv.max_area = list.count;
|
|
|
|
|
scroll_wv.cur_area = list.visible;
|
|
|
|
|
scroll_wv.position = list.first;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2015-03-16 15:20:32 +01:00
|
|
|
|
scroll_wv.all_redraw = 0;
|
2014-01-19 18:12:45 +01:00
|
|
|
|
scroll_wv.start_x = list.x + list.w;
|
2014-01-22 01:08:47 +01:00
|
|
|
|
scroll_wv.start_y = list.y;
|
2015-03-16 15:20:32 +01:00
|
|
|
|
|
2015-08-05 00:21:08 +02:00
|
|
|
|
scroll_wv.size_y = list.h;
|
|
|
|
|
scroll_wv.start_x = list.w * DrawBuf.zoom + list.x;
|
2013-12-27 00:36:17 +01:00
|
|
|
|
|
2013-12-27 13:30:42 +01:00
|
|
|
|
scrollbar_v_draw(#scroll_wv);
|
2013-12-27 00:36:17 +01:00
|
|
|
|
}
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
2014-03-23 23:49:49 +01:00
|
|
|
|
void TWebBrowser::NewLine()
|
2014-01-18 12:46:58 +01:00
|
|
|
|
{
|
2015-08-05 00:21:08 +02:00
|
|
|
|
int onleft, ontop;
|
2014-03-23 23:49:49 +01:00
|
|
|
|
|
|
|
|
|
onleft = list.x + 5;
|
|
|
|
|
ontop = stroka * list.line_h + list.y + 5;
|
2014-03-13 00:30:28 +01:00
|
|
|
|
if (t_html) && (!t_body) return;
|
2015-08-05 00:21:08 +02:00
|
|
|
|
if (stroka * list.line_h + 5 >= 0) && ( stroka + 1 * list.line_h + 5 < list.h) && (!anchor)
|
2014-01-18 12:46:58 +01:00
|
|
|
|
{
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
|
|
|
|
|
if (style.align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * list.font_w);
|
2014-01-18 12:46:58 +01:00
|
|
|
|
}
|
|
|
|
|
stroka++;
|
2015-08-19 14:48:31 +02:00
|
|
|
|
if (style.blq) stolbec = 6; else stolbec = 0;
|
|
|
|
|
if (style.li) stolbec = style.li_tab * 5;
|
2014-01-19 21:06:42 +01:00
|
|
|
|
}
|
2015-08-19 14:54:01 +02:00
|
|
|
|
//============================================================================================
|
2015-08-19 14:48:31 +02:00
|
|
|
|
int istag(dword text) { if (!strcmp(#tag,text)) return 1; else return 0; }
|
|
|
|
|
int isattr(dword text) { if (!strcmp(#attr,text)) return 1; else return 0; }
|
|
|
|
|
int isval(dword text) { if (!strcmp(#val,text)) return 1; else return 0; }
|
2015-08-23 12:12:13 +02:00
|
|
|
|
//============================================================================================
|
|
|
|
|
void TWebBrowser::DrawPage()
|
|
|
|
|
{
|
|
|
|
|
PutPaletteImage(list.first * list.line_h * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
|
|
|
|
|
DrawScroller();
|
|
|
|
|
}
|