From 92e96b542d9e77c270643b47e6892a47d4870208 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Tue, 13 Dec 2016 22:08:14 +0000 Subject: [PATCH] WebView 1.58: improve links on pages git-svn-id: svn://kolibrios.org@6795 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 6 +-- programs/cmm/TWB/links.h | 80 +++++++++++++++++++--------------- programs/cmm/browser/WebView.c | 47 ++++++++++++++------ programs/cmm/lib/draw_buf.h | 21 +++++---- 4 files changed, 93 insertions(+), 61 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index a6b0caf680..3e0ffed324 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -97,8 +97,8 @@ void TWebBrowser::DrawStyle() if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); if (style.u) DrawBuf.DrawBar(start_x, list.item_h - DrawBuf.zoom - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); if (link) { - DrawBuf.DrawBar(start_x, draw_y + list.item_h - 2, line_length, DrawBuf.zoom, text_colors[text_color_index]); - PageLinks.AddText(line_length, list.item_h - 2, UNDERLINE, 1, #line); //TODO: set bigger underline_h for style.h + DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(DrawBuf.zoom*2), line_length, DrawBuf.zoom, text_colors[text_color_index]); + PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(DrawBuf.zoom*2), UNDERLINE, DrawBuf.zoom); //TODO: set bigger underline_h for style.h } stolbec += stolbec_len; } @@ -306,7 +306,7 @@ void TWebBrowser::SetStyle() { text_colors[text_color_index] = text_colors[text_color_index-1]; link = 1; text_colors[text_color_index] = link_color_inactive; - PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, draw_y + list.y); + PageLinks.AddLink(#val); } } while(GetNextParam()); } diff --git a/programs/cmm/TWB/links.h b/programs/cmm/TWB/links.h index 14f1dc3e0a..d3f0bfc7b9 100644 --- a/programs/cmm/TWB/links.h +++ b/programs/cmm/TWB/links.h @@ -8,7 +8,7 @@ dword CursorFile = FROM "../TWB/pointer.cur"; #define MAXLINKS 400 struct array_link { - dword link, text; + dword link; int x,y,w,h; int underline, underline_h; }; @@ -16,36 +16,32 @@ struct array_link { struct LinksArray { array_link links[MAXLINKS]; collection page_links; - dword buflen; - int count, active; - void Hover(); + int count; + int active; + bool HoverAndProceed(); void AddLink(); void AddText(); dword GetURL(); void Clear(); } PageLinks; -void LinksArray::AddLink(dword lpath, int link_x, link_y) +void LinksArray::AddLink(dword lpath) { if (count>= MAXLINKS) return; - links[count].x = link_x; - links[count].y = link_y; - page_links.add(lpath); - links[count].link = page_links.get(page_links.count-1); - count++; } -void LinksArray::AddText(dword link_w, link_h, link_underline, _underline_h, new_text) +void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h) { - if (count>= MAXLINKS) || (!count) return; - links[count-1].w = link_w; - links[count-1].h = link_h; - links[count-1].underline = link_underline; - links[count-1].underline_h = _underline_h; - - page_links.add(new_text); - links[count-1].text = page_links.get(page_links.count-1); + if (count>= MAXLINKS) return; + links[count].x = _x; + links[count].y = _y; + links[count].w = _w; + links[count].h = _h; + links[count].underline = _link_underline; + links[count].underline_h = _underline_h; + links[count].link = page_links.get(page_links.count-1); + count++; } dword LinksArray::GetURL(int id) @@ -65,38 +61,54 @@ void LinksArray::Clear() char temp[sizeof(URL)]; PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0}; -void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col) +bool LinksArray::HoverAndProceed(dword mx, my) { int i; for (i=0; ilinks[i].x) && (my>links[i].y) && (mx2) { DrawTitle(#header); break; } if (Form.height<120) { MoveSize(OLD,OLD,OLD,120); break; } @@ -343,7 +347,7 @@ void ProcessEvent(dword id__) else OpenPage(); return; case SANDWICH_BUTTON: - EventShowMenu(Form.cwidth - 215, TOOLBAR_H-6); + EventShowPageMenu(Form.cwidth - 215, TOOLBAR_H-6); return; case VIEW_SOURCE: WB1.list.first = 0; @@ -574,14 +578,31 @@ void ClickLink() OpenPage(); } -void EventShowMenu(dword _left, _top) +void EventShowPageMenu(dword _left, _top) { menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 220, #rmb_menu, VIEW_SOURCE); } +void EventShowLinkMenu(dword _left, _top) +{ + menu.show(Form.left+_left-6,Form.top+_top+skin_height+3, 180, #link_menu, COPY_LINK); +} + + void ShowErrorMessageThatHttpsIsNotSupportedYet() { notify("'HTTPS protocol is not supported yet' -E"); } +DrawStatusBar(dword _status_text) +{ + status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10; + status_text.start_y = Form.cheight - STATUSBAR_H + 3; + status_text.area_size_x = Form.cwidth - status_text.start_x -3; + DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg); + status_text.text_pointer = _status_text; + PathShow_prepare stdcall(#status_text); + PathShow_draw stdcall(#status_text); +} + stop: \ No newline at end of file diff --git a/programs/cmm/lib/draw_buf.h b/programs/cmm/lib/draw_buf.h index 940b56dfd4..9569f718b8 100644 --- a/programs/cmm/lib/draw_buf.h +++ b/programs/cmm/lib/draw_buf.h @@ -23,6 +23,13 @@ struct DrawBufer { void AlignRight(); }; +char draw_buf_not_enaught_ram[] = +"'DrawBufer needs more memory than currenly available. +Application could be unstable. + +Requested size: %i Kb +Free RAM: %i Kb' -E"; + bool DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) { dword alloc_size, free_ram_size; @@ -33,18 +40,10 @@ bool DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) bufw = i_bufw * zoom; bufh = i_bufh * zoom; free(buf_data); - $mov eax, 18 - $mov ebx, 16 - $int 0x40 - free_ram_size = EAX * 1024; + free_ram_size = GetFreeRAM() * 1024; alloc_size = bufw * bufh * 4 + 8; if (alloc_size >= free_ram_size) { - sprintf(#error_str, -"'DrawBufer needs more memory than currenly available. -Application could be unstable. - -Requested size: %i Kb -Free RAM: %i Kb' -E", alloc_size/1024, free_ram_size/1024); + sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size/1024, free_ram_size/1024); notify(#error_str); } buf_data = malloc(alloc_size); @@ -67,7 +66,7 @@ void DrawBufer::DrawBar(unsigned x, y, w, h, color) int i, j; for (j=0; j