Subversion Repositories Kolibri OS

Rev

Rev 9289 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4497 leency 1
CustomCursor CursorPointer;
8330 leency 2
dword CursorFile = FROM "TWB/pointer.cur";
6738 leency 3
#include "..\lib\collection.h"
4497 leency 4
 
7970 leency 5
struct PAGE_LINKS {
9296 leency 6
	collection unic_links;
7
	collection element_links;
9289 leency 8
 
7970 leency 9
	collection_int x;
10
	collection_int y;
11
	collection_int w;
12
	collection_int h;
13
	collection_int id;
14
	collection_int underline_h;
4550 leency 15
 
7970 leency 16
	signed int active;
17
	dword active_url;
18
	bool hover();
19
	void add_link();
20
	void add_text();
21
	void clear();
22
	void draw_underline();
23
} links;
4488 leency 24
 
7970 leency 25
void PAGE_LINKS::add_link(dword lpath)
4488 leency 26
{
9296 leency 27
	unic_links.add(lpath);
4488 leency 28
}
29
 
7970 leency 30
void PAGE_LINKS::add_text(dword _x, _y, _w, _h, _underline_h)
4491 leency 31
{
7970 leency 32
	x.add(_x);
33
	y.add(_y);
34
	w.add(_w);
35
	h.add(_h);
36
	underline_h.add(_underline_h);
9296 leency 37
	element_links.add(unic_links.get_last());
38
	id.add(unic_links.count);
4491 leency 39
}
40
 
7970 leency 41
void PAGE_LINKS::clear()
4488 leency 42
{
7970 leency 43
	x.drop();
44
	y.drop();
45
	w.drop();
46
	h.drop();
47
	underline_h.drop();
9296 leency 48
	element_links.drop();
49
	unic_links.drop();
7970 leency 50
	id.drop();
4491 leency 51
 
52
	active = -1;
7970 leency 53
	active_url = 0;
4497 leency 54
	CursorPointer.Restore();
4491 leency 55
}
56
 
7970 leency 57
void PAGE_LINKS::draw_underline(signed _id, dword list_first, list_y, color)
7757 leency 58
{
59
	int i;
7970 leency 60
	if (_id == -1) return;
61
	for (i=0; i
7757 leency 62
	{
7970 leency 63
		if (id.get(i) - id.get(_id) == 0)
64
		&& (y.get(i) + h.get(i) - list_first > list_y) {
65
			DrawBar(x.get(i), y.get(i) + h.get(i) - list_first,
66
				w.get(i), underline_h.get(i), color);
7757 leency 67
		}
68
	}
69
}
70
 
7970 leency 71
bool PAGE_LINKS::hover(dword list_y, list_first)
7936 leency 72
{
7970 leency 73
	int i;
74
	int mx = mouse.x;
75
	int my = mouse.y + list_first;
76
	if (!id.count) return false;
7936 leency 77
 
7970 leency 78
	//Here we check is any link hovered
79
	for (i=0; i
4491 leency 80
	{
7970 leency 81
		if (mx>x.get(i)) && (my>y.get(i))
82
		&& (mx
7757 leency 83
		&& (my>list_y+list_first)
4488 leency 84
		{
7936 leency 85
			if (active!=i) {
86
				CursorPointer.Load(#CursorFile);
87
				CursorPointer.Set();
88
 
7970 leency 89
				draw_underline(active, list_first, list_y, link_color_default);
8451 leency 90
				draw_underline(i, list_first, list_y, DEFAULT_BG_COL);
7757 leency 91
 
9296 leency 92
				active_url = element_links.get(i);
7936 leency 93
				active = i;
8413 leency 94
				DrawStatusBar(active_url);
7757 leency 95
			}
7970 leency 96
			if (mouse.lkm) && (mouse.down) {
97
				DrawRectangle(x.get(active), -list_first + y.get(active),
98
					w.get(active), h.get(active), 0);
99
			}
6795 leency 100
			return true;
4488 leency 101
		}
102
	}
7970 leency 103
	if (active_url) {
4497 leency 104
		CursorPointer.Restore();
7970 leency 105
		draw_underline(active, list_first, list_y, link_color_default);
106
		active_url = 0;
4497 leency 107
		active = -1;
8413 leency 108
		DrawStatusBar(NULL);
4497 leency 109
	}
7970 leency 110
	return false;
4488 leency 111
}
6795 leency 112