2014-01-21 03:42:18 +04:00
|
|
|
CustomCursor CursorPointer;
|
|
|
|
dword CursorFile = FROM "../TWB/pointer.cur";
|
2016-11-22 17:04:10 +03:00
|
|
|
#include "..\lib\collection.h"
|
2014-01-21 03:42:18 +04:00
|
|
|
|
2014-01-30 22:28:50 +04:00
|
|
|
#define NOLINE 0
|
|
|
|
#define UNDERLINE 1
|
|
|
|
|
2020-03-26 03:12:32 +03:00
|
|
|
#define MAXLINKS 2000
|
2016-11-22 17:04:10 +03:00
|
|
|
|
2020-04-10 19:19:52 +03:00
|
|
|
bool open_new_window=false;
|
|
|
|
bool open_new_tab=false;
|
|
|
|
|
2014-01-20 02:46:58 +04:00
|
|
|
struct array_link {
|
2016-12-14 01:08:14 +03:00
|
|
|
dword link;
|
2020-03-29 13:57:14 +03:00
|
|
|
unsigned int x,y,w,h;
|
|
|
|
unsigned int unic_id;
|
2016-12-12 01:58:11 +03:00
|
|
|
int underline, underline_h;
|
2014-01-20 02:46:58 +04:00
|
|
|
};
|
2014-01-20 00:06:42 +04:00
|
|
|
|
2015-08-26 22:22:20 +03:00
|
|
|
struct LinksArray {
|
2016-11-22 17:04:10 +03:00
|
|
|
array_link links[MAXLINKS];
|
|
|
|
collection page_links;
|
2020-03-29 13:57:14 +03:00
|
|
|
unsigned int count;
|
|
|
|
unsigned int unic_count;
|
|
|
|
unsigned int active;
|
2016-12-14 01:08:14 +03:00
|
|
|
bool HoverAndProceed();
|
2014-01-20 02:46:58 +04:00
|
|
|
void AddLink();
|
|
|
|
void AddText();
|
2014-01-20 00:06:42 +04:00
|
|
|
dword GetURL();
|
|
|
|
void Clear();
|
2020-03-29 13:57:14 +03:00
|
|
|
void DrawUnderline();
|
2015-08-13 15:23:35 +03:00
|
|
|
} PageLinks;
|
2014-01-20 00:06:42 +04:00
|
|
|
|
2016-12-14 01:08:14 +03:00
|
|
|
void LinksArray::AddLink(dword lpath)
|
2014-01-20 00:06:42 +04:00
|
|
|
{
|
2016-11-22 17:04:10 +03:00
|
|
|
if (count>= MAXLINKS) return;
|
|
|
|
page_links.add(lpath);
|
2020-03-29 13:57:14 +03:00
|
|
|
unic_count++;
|
2014-01-20 02:46:58 +04:00
|
|
|
}
|
|
|
|
|
2016-12-14 01:08:14 +03:00
|
|
|
void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h)
|
2014-01-20 02:46:58 +04:00
|
|
|
{
|
2016-12-14 01:08:14 +03:00
|
|
|
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);
|
2020-03-29 13:57:14 +03:00
|
|
|
links[count].unic_id = unic_count;
|
2016-12-14 01:08:14 +03:00
|
|
|
count++;
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
dword LinksArray::GetURL(int id)
|
|
|
|
{
|
2014-01-20 02:46:58 +04:00
|
|
|
return links[id].link;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinksArray::Clear()
|
|
|
|
{
|
2016-11-22 17:04:10 +03:00
|
|
|
page_links.drop();
|
|
|
|
page_links.realloc_size = 4096 * 32;
|
2014-01-20 02:46:58 +04:00
|
|
|
count = 0;
|
|
|
|
active = -1;
|
2020-03-29 13:57:14 +03:00
|
|
|
unic_count = 0;
|
2014-01-21 03:42:18 +04:00
|
|
|
CursorPointer.Restore();
|
2020-03-31 00:29:52 +03:00
|
|
|
open_new_window = false;
|
2014-01-20 02:46:58 +04:00
|
|
|
}
|
|
|
|
|
2020-03-29 13:57:14 +03:00
|
|
|
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
|
|
|
|
DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-31 00:29:52 +03:00
|
|
|
PathShow_data status_text = {0, 17,250, 6, 250};
|
2014-01-21 03:42:18 +04:00
|
|
|
|
2020-03-29 13:57:14 +03:00
|
|
|
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
|
2014-01-20 02:46:58 +04:00
|
|
|
{
|
|
|
|
int i;
|
2020-03-22 22:50:16 +03:00
|
|
|
if (!count) return true;
|
2014-01-20 02:46:58 +04:00
|
|
|
for (i=0; i<count; i++)
|
|
|
|
{
|
2020-03-23 04:11:31 +03:00
|
|
|
if (mx>links[i].x) && (my>links[i].y)
|
|
|
|
&& (mx<links[i].x+links[i].w) && (my<links[i].y+links[i].h)
|
2020-03-29 13:57:14 +03:00
|
|
|
&& (my>list_y+list_first)
|
2014-01-20 00:06:42 +04:00
|
|
|
{
|
2016-12-14 01:08:14 +03:00
|
|
|
if (mouse.lkm) && (mouse.down) {
|
2020-03-29 13:57:14 +03:00
|
|
|
DrawRectangle(links[active].x, -list_first + links[active].y,
|
2016-12-12 01:58:11 +03:00
|
|
|
links[active].w, links[active].h, 0);
|
2016-12-14 01:08:14 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (mouse.mkm) && (mouse.up) {
|
2020-04-10 19:19:52 +03:00
|
|
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
2020-04-15 16:47:06 +03:00
|
|
|
open_new_window = true;
|
|
|
|
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
|
|
open_new_window = false;
|
2020-04-10 19:19:52 +03:00
|
|
|
} else {
|
2020-04-15 16:47:06 +03:00
|
|
|
open_new_tab = true;
|
|
|
|
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
|
|
|
open_new_tab = false;
|
2020-04-10 19:19:52 +03:00
|
|
|
}
|
2016-12-14 01:08:14 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (mouse.lkm) && (mouse.up) {
|
|
|
|
CursorPointer.Restore();
|
2020-03-27 13:38:54 +03:00
|
|
|
EventClickLink(PageLinks.GetURL(PageLinks.active));
|
2016-12-14 01:08:14 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (mouse.pkm) && (mouse.up) {
|
2020-04-06 22:54:05 +03:00
|
|
|
EventShowLinkMenu();
|
2016-12-14 01:08:14 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (active==i) return false;
|
2018-05-20 16:40:58 +03:00
|
|
|
CursorPointer.Load(#CursorFile);
|
2014-01-21 03:42:18 +04:00
|
|
|
CursorPointer.Set();
|
2020-03-29 13:57:14 +03:00
|
|
|
|
|
|
|
if (links[active].underline) {
|
2020-04-04 02:17:28 +03:00
|
|
|
DrawUnderline(active, list_first, list_y, link_color_default);
|
2020-03-29 13:57:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (links[i].underline) {
|
|
|
|
DrawUnderline(i, list_first, list_y, page_bg);
|
|
|
|
}
|
|
|
|
|
2014-01-20 02:46:58 +04:00
|
|
|
active = i;
|
2016-12-14 01:08:14 +03:00
|
|
|
DrawStatusBar(links[active].link);
|
|
|
|
return true;
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
|
|
|
}
|
2014-01-21 03:42:18 +04:00
|
|
|
if (active!=-1)
|
|
|
|
{
|
|
|
|
CursorPointer.Restore();
|
2016-12-14 01:08:14 +03:00
|
|
|
if (links[active].underline) {
|
2020-04-04 02:17:28 +03:00
|
|
|
DrawUnderline(active, list_first, list_y, link_color_default);
|
2016-12-14 01:08:14 +03:00
|
|
|
}
|
2020-03-29 13:57:14 +03:00
|
|
|
DrawStatusBar(NULL);
|
2014-01-21 03:42:18 +04:00
|
|
|
active = -1;
|
|
|
|
}
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
2016-12-14 01:08:14 +03:00
|
|
|
|