WebView 1.58: improve links on pages
git-svn-id: svn://kolibrios.org@6795 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b0a295dfce
commit
92e96b542d
@ -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());
|
||||
}
|
||||
|
@ -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; i<count; i++)
|
||||
{
|
||||
if (mx>links[i].x) && (my>links[i].y) && (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
|
||||
{
|
||||
if (mouse.down) DrawRectangle(links[active].x, -WB1.list.first + links[active].y,
|
||||
if (mouse.lkm) && (mouse.down) {
|
||||
DrawRectangle(links[active].x, -WB1.list.first + links[active].y,
|
||||
links[active].w, links[active].h, 0);
|
||||
if (mouse.up) ClickLink();
|
||||
if (active==i) return;
|
||||
return false;
|
||||
}
|
||||
if (mouse.mkm) && (mouse.up) {
|
||||
// strcpy(#URL_temp, links[active].link);
|
||||
// GetAbsoluteUrl(#URL_temp);
|
||||
// RunProgram(#program_path, #URL_temp);
|
||||
return false;
|
||||
}
|
||||
if (mouse.lkm) && (mouse.up) {
|
||||
CursorPointer.Restore();
|
||||
ClickLink();
|
||||
return false;
|
||||
}
|
||||
if (mouse.pkm) && (mouse.up) {
|
||||
// EventShowLinkMenu(mouse.x, mouse.y);
|
||||
return false;
|
||||
}
|
||||
if (active==i) return false;
|
||||
CursorPointer.Set();
|
||||
if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y
|
||||
+ links[active].h, links[active].w, links[i].underline_h, link_col_in);
|
||||
+ links[active].h, links[active].w, links[active].underline_h, link_color_inactive);
|
||||
if (links[i].underline) DrawBar(links[i].x, -WB1.list.first + links[i].y
|
||||
+ links[i].h, links[i].w, links[i].underline_h, bg_col);
|
||||
+ links[i].h, links[i].w, links[i].underline_h, bg_color);
|
||||
active = i;
|
||||
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 = links[active].link;
|
||||
PathShow_prepare stdcall(#status_text);
|
||||
PathShow_draw stdcall(#status_text);
|
||||
return;
|
||||
DrawStatusBar(links[active].link);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (active!=-1)
|
||||
{
|
||||
CursorPointer.Restore();
|
||||
if (links[active].underline) DrawBar(links[active].x, -WB1.list.first + links[active].y + links[active].h,links[active].w, WB1.DrawBuf.zoom, link_col_in);
|
||||
if (links[active].underline) {
|
||||
DrawBar(links[active].x, -WB1.list.first + links[active].y + links[active].h,links[active].w,
|
||||
links[active].underline_h, link_color_inactive);
|
||||
}
|
||||
DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
|
||||
active = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "..\lib\cursor.h"
|
||||
#include "..\lib\collection.h"
|
||||
#include "..\lib\menu.h"
|
||||
#include "..\lib\random.h"
|
||||
|
||||
//*.obj libraries
|
||||
#include "..\lib\obj\box_lib.h"
|
||||
@ -30,7 +31,7 @@
|
||||
char homepage[] = FROM "html\\homepage.htm""\0";
|
||||
|
||||
#ifdef LANG_RUS
|
||||
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.57";
|
||||
char version[]="’¥ªáâ®¢ë© ¡à 㧥à 1.58";
|
||||
?define IMAGES_CACHE_CLEARED "Šíè ª à⨮ª ®ç¨é¥"
|
||||
?define T_LAST_SLIDE "<EFBFBD>â® ¯®á«¥¤¨© á« ©¤"
|
||||
char loading[] = "‡ £à㧪 áâà ¨æë...<br>";
|
||||
@ -43,7 +44,7 @@ char rmb_menu[] =
|
||||
Žç¨áâ¨âì ªíè ª à⨮ª
|
||||
Œ¥¥¤¦¥à § £à㧮ª";
|
||||
#else
|
||||
char version[]="Text-based Browser 1.57";
|
||||
char version[]="Text-based Browser 1.58";
|
||||
?define IMAGES_CACHE_CLEARED "Images cache cleared"
|
||||
?define T_LAST_SLIDE "This slide is the last"
|
||||
char loading[] = "Loading...<br>";
|
||||
@ -57,6 +58,10 @@ Free image cache
|
||||
Download Manager";
|
||||
#endif
|
||||
|
||||
char link_menu[] =
|
||||
"Copy link
|
||||
Download link";
|
||||
|
||||
#define URL_SERVICE_HISTORY "WebView://history"
|
||||
#define URL_SERVICE_HOME "WebView://home"
|
||||
#define URL_SERVICE_SOURCE "WebView://source:"
|
||||
@ -87,15 +92,14 @@ enum {
|
||||
FORWARD_BUTTON,
|
||||
REFRESH_BUTTON,
|
||||
GOTOURL_BUTTON,
|
||||
SANDWICH_BUTTON
|
||||
};
|
||||
|
||||
enum {
|
||||
SANDWICH_BUTTON,
|
||||
VIEW_SOURCE=1100,
|
||||
EDIT_SOURCE,
|
||||
VIEW_HISTORY,
|
||||
FREE_IMG_CACHE,
|
||||
DOWNLOAD_MANAGER
|
||||
DOWNLOAD_MANAGER,
|
||||
COPY_LINK=1200,
|
||||
DOWNLOAD_LINK
|
||||
};
|
||||
|
||||
#include "..\TWB\TWB.c"
|
||||
@ -134,9 +138,9 @@ void main()
|
||||
mouse.get();
|
||||
if (WB1.list.MouseOver(mouse.x, mouse.y))
|
||||
{
|
||||
PageLinks.Hover(mouse.x, WB1.list.first + mouse.y, link_color_inactive, link_color_active, bg_color);
|
||||
if (bufsize) && (mouse.pkm) && (mouse.up) {
|
||||
EventShowMenu(mouse.x, mouse.y);
|
||||
if (PageLinks.HoverAndProceed(mouse.x, WB1.list.first + mouse.y))
|
||||
&& (bufsize) && (mouse.pkm) && (mouse.up) {
|
||||
EventShowPageMenu(mouse.x, mouse.y);
|
||||
break;
|
||||
}
|
||||
if (WB1.list.MouseScroll(mouse.vert)) WB1.DrawPage();
|
||||
@ -175,7 +179,7 @@ void main()
|
||||
ProcessEvent(menu.list.cur_y);
|
||||
menu.list.cur_y = 0;
|
||||
}
|
||||
DefineAndDrawWindow(GetScreenWidth()-800/2,GetScreenHeight()-600/2,800,600,0x73,col_bg,0,0);
|
||||
DefineAndDrawWindow(GetScreenWidth()-800/2-random(80),GetScreenHeight()-600/2-random(80),800,600,0x73,col_bg,0,0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window>2) { 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:
|
@ -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<h; j++)
|
||||
{
|
||||
for (i = y+j*bufw+x*4+8+buf_data; i<y+j*bufw+x+w*4+8+buf_data; i+=4) ESDWORD[i] = color;
|
||||
for (i = y+j*bufw+x<<2+8+buf_data; i<y+j*bufw+x+w<<2+8+buf_data; i+=4) ESDWORD[i] = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user