2014-01-21 03:42:18 +04:00
|
|
|
CustomCursor CursorPointer;
|
2020-12-06 02:22:38 +03:00
|
|
|
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
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
struct PAGE_LINKS {
|
|
|
|
collection_int link;
|
|
|
|
collection_int x;
|
|
|
|
collection_int y;
|
|
|
|
collection_int w;
|
|
|
|
collection_int h;
|
|
|
|
collection_int id;
|
|
|
|
collection_int underline_h;
|
2014-01-30 22:28:50 +04:00
|
|
|
|
2016-11-22 17:04:10 +03:00
|
|
|
collection page_links;
|
2020-05-23 00:39:04 +03:00
|
|
|
signed int active;
|
|
|
|
dword active_url;
|
|
|
|
bool hover();
|
|
|
|
void add_link();
|
|
|
|
void add_text();
|
|
|
|
void clear();
|
|
|
|
void draw_underline();
|
|
|
|
} links;
|
|
|
|
|
|
|
|
void PAGE_LINKS::add_link(dword lpath)
|
2014-01-20 00:06:42 +04:00
|
|
|
{
|
2016-11-22 17:04:10 +03:00
|
|
|
page_links.add(lpath);
|
2014-01-20 02:46:58 +04:00
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
void PAGE_LINKS::add_text(dword _x, _y, _w, _h, _underline_h)
|
2014-01-20 02:46:58 +04:00
|
|
|
{
|
2020-05-23 00:39:04 +03:00
|
|
|
x.add(_x);
|
|
|
|
y.add(_y);
|
|
|
|
w.add(_w);
|
|
|
|
h.add(_h);
|
|
|
|
underline_h.add(_underline_h);
|
|
|
|
link.add(page_links.get_last());
|
|
|
|
id.add(page_links.count);
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
void PAGE_LINKS::clear()
|
2014-01-20 00:06:42 +04:00
|
|
|
{
|
2020-05-23 00:39:04 +03:00
|
|
|
x.drop();
|
|
|
|
y.drop();
|
|
|
|
w.drop();
|
|
|
|
h.drop();
|
|
|
|
underline_h.drop();
|
|
|
|
link.drop();
|
|
|
|
id.drop();
|
2014-01-20 02:46:58 +04:00
|
|
|
|
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
|
|
|
active = -1;
|
2020-05-23 00:39:04 +03:00
|
|
|
active_url = 0;
|
2014-01-21 03:42:18 +04:00
|
|
|
CursorPointer.Restore();
|
2014-01-20 02:46:58 +04:00
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
void PAGE_LINKS::draw_underline(signed _id, dword list_first, list_y, color)
|
2020-03-29 13:57:14 +03:00
|
|
|
{
|
|
|
|
int i;
|
2020-05-23 00:39:04 +03:00
|
|
|
if (_id == -1) return;
|
|
|
|
for (i=0; i<id.count; i++)
|
2020-03-29 13:57:14 +03:00
|
|
|
{
|
2020-05-23 00:39:04 +03:00
|
|
|
if (id.get(i) - id.get(_id) == 0)
|
|
|
|
&& (y.get(i) + h.get(i) - list_first > list_y) {
|
|
|
|
DrawBar(x.get(i), y.get(i) + h.get(i) - list_first,
|
|
|
|
w.get(i), underline_h.get(i), color);
|
2020-03-29 13:57:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
bool PAGE_LINKS::hover(dword list_y, list_first)
|
2014-01-20 02:46:58 +04:00
|
|
|
{
|
|
|
|
int i;
|
2020-05-23 00:39:04 +03:00
|
|
|
int mx = mouse.x;
|
|
|
|
int my = mouse.y + list_first;
|
|
|
|
if (!id.count) return false;
|
|
|
|
|
|
|
|
//Here we check is any link hovered
|
|
|
|
for (i=0; i<id.count; i++)
|
2014-01-20 02:46:58 +04:00
|
|
|
{
|
2020-05-23 00:39:04 +03:00
|
|
|
if (mx>x.get(i)) && (my>y.get(i))
|
|
|
|
&& (mx<x.get(i)+w.get(i)) && (my<y.get(i)+h.get(i))
|
2020-03-29 13:57:14 +03:00
|
|
|
&& (my>list_y+list_first)
|
2014-01-20 00:06:42 +04:00
|
|
|
{
|
2020-05-17 14:35:02 +03:00
|
|
|
if (active!=i) {
|
|
|
|
CursorPointer.Load(#CursorFile);
|
|
|
|
CursorPointer.Set();
|
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
draw_underline(active, list_first, list_y, link_color_default);
|
|
|
|
draw_underline(i, list_first, list_y, page_bg);
|
2020-03-29 13:57:14 +03:00
|
|
|
|
2020-05-23 00:39:04 +03:00
|
|
|
active_url = link.get(i);
|
2020-05-17 14:35:02 +03:00
|
|
|
active = i;
|
2020-05-23 00:39:04 +03:00
|
|
|
DrawStatusBar();
|
|
|
|
}
|
|
|
|
if (mouse.lkm) && (mouse.down) {
|
|
|
|
DrawRectangle(x.get(active), -list_first + y.get(active),
|
|
|
|
w.get(active), h.get(active), 0);
|
2020-03-29 13:57:14 +03:00
|
|
|
}
|
2016-12-14 01:08:14 +03:00
|
|
|
return true;
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
|
|
|
}
|
2020-05-23 00:39:04 +03:00
|
|
|
if (active_url) {
|
2014-01-21 03:42:18 +04:00
|
|
|
CursorPointer.Restore();
|
2020-05-23 00:39:04 +03:00
|
|
|
draw_underline(active, list_first, list_y, link_color_default);
|
|
|
|
active_url = 0;
|
2014-01-21 03:42:18 +04:00
|
|
|
active = -1;
|
2020-05-23 00:39:04 +03:00
|
|
|
DrawStatusBar();
|
2014-01-21 03:42:18 +04:00
|
|
|
}
|
2020-05-23 00:39:04 +03:00
|
|
|
return false;
|
2014-01-20 00:06:42 +04:00
|
|
|
}
|
2016-12-14 01:08:14 +03:00
|
|
|
|