WebView 1.14: remove Zoom2x function, use system fonts

git-svn-id: svn://kolibrios.org@5678 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2015-08-04 22:21:08 +00:00
parent 872ac43496
commit b004b5af85
5 changed files with 48 additions and 72 deletions

View File

@ -10,7 +10,7 @@ char header[2048];
struct TWebBrowser {
llist list;
dword draw_line_height, draw_line_width, draw_list_height;
dword draw_line_width;
DrawBufer DrawBuf;
void Prepare();
void Parse();
@ -62,7 +62,8 @@ char anchor[256];
void TWebBrowser::DrawPage()
{
int start_x, start_y, zstart_x, zstart_y, line_length, zline_length, stolbec_len, magrin_left=5;
int start_x, start_y, line_length, stolbec_len, magrin_left=5;
dword font_type;
if (!header)
{
@ -76,23 +77,22 @@ void TWebBrowser::DrawPage()
if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
{
start_x = stolbec * 6 + list.x + magrin_left;
start_y = stroka * list.line_h + list.y + magrin_left;
zstart_x = stolbec * 6 + magrin_left * DrawBuf.zoomf + list.x;
zstart_y = stroka * list.line_h * DrawBuf.zoomf + magrin_left + list.y;
start_x = stolbec * 6 + magrin_left * DrawBuf.zoom + list.x;
start_y = stroka * list.line_h + magrin_left + list.y;
stolbec_len = strlen(#line);
line_length = stolbec_len * 6;
zline_length = stolbec_len * 6 * DrawBuf.zoomf;
line_length = stolbec_len * 6 * DrawBuf.zoom;
WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data);
if (b_text) WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data);
if (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); }
if (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
if (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
if (DrawBuf.zoom==1) font_type = 0x88; else font_type = 0x89;
WriteBufText(start_x, 0, font_type, text_colors[text_color_index], #line, buf_data);
if (b_text) WriteBufText(start_x+1, 0, font_type, text_colors[text_color_index], #line, buf_data);
if (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } // bug with zoom>1
if (s_text) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
if (u_text) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
if (link) {
DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
UnsafeDefineButton(zstart_x-2, zstart_y-1, zline_length + 3, DrawBuf.zoomf * 10, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
PageLinks.AddText(#line, zline_length, draw_line_height, UNDERLINE);
DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]);
UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, DrawBuf.zoom * 10, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
}
stolbec += stolbec_len;
}
@ -149,9 +149,7 @@ void TWebBrowser::Parse(){
stolbec = 0;
line = 0;
draw_line_height = list.line_h * DrawBuf.zoomf;
draw_line_width = list.w * DrawBuf.zoomf;
draw_list_height = list.h * DrawBuf.zoomf;
draw_line_width = list.w * DrawBuf.zoom;
if (pre_text<>2)
{
@ -255,7 +253,7 @@ void TWebBrowser::Parse(){
if (stolbec + strlen(#line) > list.column_max) Perenos();
DrawPage();
line = NULL;
if (tag) SetTextStyle(WB1.DrawBuf.zoomf * 5 + list.x, stroka * draw_line_height + list.y + 5); //îáðàáîòêà òåãîâ
if (tag) SetTextStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
tag = parametr = tagparam = ignor_param = NULL;
break;
default:
@ -273,8 +271,8 @@ void TWebBrowser::Parse(){
}
DrawPage();
NewLine();
DrawBar(list.x, stroka * draw_line_height + list.y + 5, draw_line_width, -stroka * draw_line_height + draw_list_height - 5, bg_color);
DrawBar(list.x, list.visible * draw_line_height + list.y + 4, draw_line_width, -list.visible * draw_line_height + draw_list_height - 4, bg_color);
DrawBar(list.x, stroka * list.line_h + list.y + 5, draw_line_width, -stroka * list.line_h + list.h - 5, bg_color);
DrawBar(list.x, list.visible * list.line_h + list.y + 4, draw_line_width, -list.visible * list.line_h + list.h - 4, bg_color);
if (list.first == 0) list.count = stroka;
if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
{
@ -388,7 +386,7 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
link = 1;
text_colors[text_color_index] = link_color_inactive;
PageLinks.AddLink(#options, DrawBuf.zoomf * stolbec*6+left1, top1-2);
PageLinks.AddLink(#options, DrawBuf.zoom * stolbec*6+left1, top1-DrawBuf.zoom);
}
if (anchor) && (!strcmp(#parametr, "name="))
{
@ -556,7 +554,8 @@ void TWebBrowser::SetTextStyle(int left1, top1) {
if (opened)
{
NewLine();
if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + list.x, list.line_h/2-2, 2, 2, 0x555555);
if (stroka > -1) && (stroka - 2 < list.visible)
DrawBuf.DrawBar(li_tab * 5 * 6 * DrawBuf.zoom + list.x, list.line_h / 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
}
return;
}
@ -618,8 +617,8 @@ void TWebBrowser::DrawScroller()
scroll_wv.start_x = list.x + list.w;
scroll_wv.start_y = list.y;
scroll_wv.size_y = list.h * DrawBuf.zoomf;
scroll_wv.start_x = list.w * DrawBuf.zoomf + list.x;
scroll_wv.size_y = list.h;
scroll_wv.start_x = list.w * DrawBuf.zoom + list.x;
scrollbar_v_draw(#scroll_wv);
}
@ -627,19 +626,17 @@ void TWebBrowser::DrawScroller()
void TWebBrowser::NewLine()
{
int onleft, ontop, zontop;
int onleft, ontop;
onleft = list.x + 5;
ontop = stroka * list.line_h + list.y + 5;
zontop = stroka * list.line_h * DrawBuf.zoomf + list.y + 5;
if (!stroka) DrawBar(list.x, list.y, draw_line_width, 5, bg_color);
if (t_html) && (!t_body) return;
if (ontop>=list.y) && ( ontop < list.h+list.y-10) && (!anchor)
if (stroka * list.line_h + 5 >= 0) && ( stroka + 1 * list.line_h + 5 < list.h) && (!anchor)
{
if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * 6);
if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * 6);
if (text_align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * 6);
if (text_align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * 6);
DrawBuf.bufy = ontop;
DrawBuf.zbufy = zontop;
DrawBuf.Show();
DrawBuf.Fill(bg_color);
}

View File

@ -76,8 +76,8 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
{
if (active==i) return;
CursorPointer.Set();
if (links[active].underline) DrawBar(links[active].x, WB1.list.line_h - WB1.DrawBuf.zoomf * WB1.DrawBuf.zoomf + links[active].y,links[active].w, WB1.DrawBuf.zoomf, link_col_in);
if (links[i].underline) DrawBar(links[i].x, WB1.list.line_h - WB1.DrawBuf.zoomf * WB1.DrawBuf.zoomf + links[i].y,links[i].w, WB1.DrawBuf.zoomf, bg_col);
if (links[active].underline) DrawBar(links[active].x, WB1.list.line_h - WB1.DrawBuf.zoom + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
if (links[i].underline) DrawBar(links[i].x, WB1.list.line_h - WB1.DrawBuf.zoom + links[i].y,links[i].w, WB1.DrawBuf.zoom, bg_col);
active = i;
status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
status_text.start_y = Form.cheight - STATUSBAR_H + 3;
@ -92,7 +92,7 @@ void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
if (active!=-1)
{
CursorPointer.Restore();
if (links[active].underline) DrawBar(links[active].x, WB1.list.line_h - WB1.DrawBuf.zoomf * WB1.DrawBuf.zoomf + links[active].y,links[active].w, WB1.DrawBuf.zoomf, link_col_in);
if (links[active].underline) DrawBar(links[active].x, WB1.list.line_h - WB1.DrawBuf.zoom + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
active = -1;
}

View File

@ -30,7 +30,7 @@
char homepage[] = FROM "html\\homepage.htm";
#ifdef LANG_RUS
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.12";
char version[]=" ’¥ªáâ®¢ë© ¡à ã§¥à 1.14";
?define IMAGES_CACHE_CLEARED "Šíè ª à⨭®ª ®ç¨é¥­"
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤­¨© á« ©¤"
char loading[] = "‡ £à㧪  áâà ­¨æë...<br>";
@ -130,7 +130,7 @@ void main()
Libimg_LoadImage(#skin, abspath("wv_skin.png"));
SetSkinColors();
WB1.DrawBuf.zoomf = 1;
WB1.DrawBuf.zoom = 1;
Form.width=WIN_W;
Form.height=WIN_H;
SetElementSizes();
@ -177,7 +177,7 @@ void main()
}
if (scroll_used)
{
mouse.y = mouse.y / WB1.DrawBuf.zoomf + 5;
mouse.y = mouse.y + 5;
half_scroll_size = WB1.list.h - 16 * WB1.list.visible / WB1.list.count - 3 /2;
if (half_scroll_size+WB1.list.y>mouse.y) || (mouse.y<0) || (mouse.y>4000) mouse.y=half_scroll_size+WB1.list.y;
btn=WB1.list.first;
@ -282,7 +282,8 @@ void SetElementSizes()
{
address_box.top = TOOLBAR_H-TAB_H/2-7+TAB_H;
address_box.width = Form.cwidth - address_box.left - 25 - 22;
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoomf, Form.cheight - TOOLBAR_H - STATUSBAR_H / WB1.DrawBuf.zoomf, 0, 11);
WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom,
Form.cheight - TOOLBAR_H - STATUSBAR_H, 0, 11*WB1.DrawBuf.zoom);
WB1.list.column_max = WB1.list.w - scroll_wv.size_x / 6;
WB1.list.visible = WB1.list.h - 5 / WB1.list.line_h;
WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, WB1.list.line_h);
@ -477,7 +478,7 @@ void Scan(int id)
CreateThread(#menu_rmb,#stak+4092);
return;
case 122:
if (WB1.DrawBuf.zoomf==1) WB1.DrawBuf.zoomf=2; else WB1.DrawBuf.zoomf=1;
if (WB1.DrawBuf.zoom==1) WB1.DrawBuf.zoom=2; else WB1.DrawBuf.zoom=1;
Draw_Window();
}
}

View File

@ -85,5 +85,5 @@ void DrawMenuList()
else
WriteText(5, _DOS*menu.line_h+7, 0x80, 0x777777, "\x10"); //show current encoding
if (WB1.DrawBuf.zoomf == 2) DrawBar(6, 4*menu.line_h+8, 6, 6, 0x777777);
if (WB1.DrawBuf.zoom == 2) DrawBar(6, 4*menu.line_h+8, 6, 6, 0x777777);
}

View File

@ -7,13 +7,11 @@
#endif
dword buf_data;
dword zbuf_data;
struct DrawBufer {
int bufx, bufy, bufw, bufh;
int zbufx, zbufy, zbufw, zbufh;
byte zoomf;
byte zoom;
void Init();
void Show();
@ -23,31 +21,18 @@ struct DrawBufer {
void PutPixel();
void AlignCenter();
void AlignRight();
void Zoom2x();
};
void DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh)
{
bufx = i_bufx;
bufy = i_bufy;
bufw = i_bufw;
bufh = i_bufh;
bufw = i_bufw * zoom;
bufh = i_bufh * zoom;
free(buf_data);
buf_data = malloc(bufw * bufh * 4 + 8);
ESDWORD[buf_data] = bufw;
ESDWORD[buf_data+4] = bufh;
if (zoomf != 1)
{
zbufx = bufx;
zbufy = bufy;
zbufw = bufw * zoomf;
zbufh = bufh * zoomf;
free(zbuf_data);
zbuf_data = malloc(zbufw * zbufh * 4 + 8);
ESDWORD[zbuf_data] = zbufw;
ESDWORD[zbuf_data+4] = zbufh;
}
}
void DrawBufer::Fill(dword fill_color)
@ -109,7 +94,7 @@ void DrawBufer::AlignCenter(dword x,y,w,h, content_width)
}
}
/*
void DrawBufer::Zoom2x()
{
int i, s;
@ -117,7 +102,7 @@ void DrawBufer::Zoom2x()
point_x = 0;
max_i = bufw * bufh * 4 + buf_data+8;
s_inc = zoomf * 4;
s_inc = zoom * 4;
zline_w = zbufw * 4;
for (i=buf_data+8, s=zbuf_data+8; i<max_i; i+=4, s+= s_inc) {
@ -125,7 +110,7 @@ void DrawBufer::Zoom2x()
ESDWORD[s+4] = ESDWORD[i];
ESDWORD[s+zline_w] = ESDWORD[i];
ESDWORD[s+zline_w+4] = ESDWORD[i];
if (zoomf==3)
if (zoom==3)
{
ESDWORD[s+8] = ESDWORD[i];
ESDWORD[zline_w+s+8] = ESDWORD[i];
@ -137,24 +122,17 @@ void DrawBufer::Zoom2x()
point_x++;
if (point_x >= bufw)
{
s += zoomf - 1 * zline_w;
s += zoom - 1 * zline_w;
point_x = 0;
}
}
}
*/
void DrawBufer::Show()
{
if (zoomf == 1)
{
PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32, 0);
}
else
{
Zoom2x();
PutPaletteImage(zbuf_data+8, zbufw, zbufh, zbufx, zbufy, 32, 0);
}
PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32, 0);
}
#endif