Subversion Repositories Kolibri OS

Rev

Rev 8413 | Rev 9289 | Go to most recent revision | 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 {
6
	collection_int link;
7
	collection_int x;
8
	collection_int y;
9
	collection_int w;
10
	collection_int h;
11
	collection_int id;
12
	collection_int underline_h;
4550 leency 13
 
6738 leency 14
	collection page_links;
7970 leency 15
	signed int active;
16
	dword active_url;
17
	bool hover();
18
	void add_link();
19
	void add_text();
20
	void clear();
21
	void draw_underline();
22
} links;
4488 leency 23
 
7970 leency 24
void PAGE_LINKS::add_link(dword lpath)
4488 leency 25
{
6738 leency 26
	page_links.add(lpath);
4488 leency 27
}
28
 
7970 leency 29
void PAGE_LINKS::add_text(dword _x, _y, _w, _h, _underline_h)
4491 leency 30
{
7970 leency 31
	x.add(_x);
32
	y.add(_y);
33
	w.add(_w);
34
	h.add(_h);
35
	underline_h.add(_underline_h);
36
	link.add(page_links.get_last());
37
	id.add(page_links.count);
4491 leency 38
}
39
 
7970 leency 40
void PAGE_LINKS::clear()
4488 leency 41
{
7970 leency 42
	x.drop();
43
	y.drop();
44
	w.drop();
45
	h.drop();
46
	underline_h.drop();
47
	link.drop();
48
	id.drop();
4491 leency 49
 
6738 leency 50
	page_links.drop();
51
	page_links.realloc_size = 4096 * 32;
4491 leency 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
 
7970 leency 92
				active_url = link.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