Subversion Repositories Kolibri OS

Rev

Rev 7285 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7291 leency 1
dword CursorFile = FROM "pointer.cur";
2
 
6058 leency 3
struct _link
4
{
7291 leency 5
	CustomCursor CursorPointer;
6058 leency 6
	int count;
7
	int x[4096], y[4096], w[4096], h[4096];
8
	collection text;
9
	collection url;
10
	void clear();
11
	void add();
12
	int hover();
13
	int active;
7291 leency 14
	void draw_underline();
6058 leency 15
} link;
16
 
17
void _link::clear()
18
{
19
	text.drop();
20
	url.drop();
21
	count = 0;
22
}
23
 
24
void _link::add(int _xx, _yy, _ww, _hh, dword _textt, _urll )
25
{
26
	if (count==4095) return;
27
	x[count] = _xx;
28
	y[count] = _yy;
29
	w[count] = _ww;
30
	h[count] = _hh;
31
	text.add(_textt);
32
	url.add(_urll);
33
	count++;
34
}
35
 
7291 leency 36
void _link::draw_underline(dword i, color)
37
{
38
	DrawBar(x[i]+list.x, -list.first*list.item_h+y[i]+list.y+h[i]-1, w[i], 1, color);
39
}
40
 
6058 leency 41
int _link::hover()
42
{
43
	int i;
7291 leency 44
	int new_active = -1;
45
	int link_start_y = list.first*list.item_h;
6058 leency 46
	mouse.x = mouse.x - list.x;
47
	mouse.y = mouse.y - list.y;
7291 leency 48
	for (i=0; i
49
		if(y[i] > link_start_y) && (y[i] < link_start_y+list.h) {
50
			// debugln( sprintf(#param, "mx:%i my:%i x[i]:%i y[i]:%i", mx, my, x[i], y[i]) );
51
			if (mouse.x > x[i])
52
			&& (mouse.x < x[i]+w[i])
53
			&& (mouse.y > y[i]-link_start_y)
54
			&& (mouse.y < h[i]-link_start_y+link.y[i]) {
55
				new_active = i;
56
				break;
6059 leency 57
			}
6058 leency 58
		}
59
	}
7291 leency 60
 
61
	if (new_active != active)
62
	{
63
		if (-1 == new_active) {
64
			draw_underline(active, 0x0000FF);
65
			CursorPointer.Restore();
66
		}
67
		else {
68
			draw_underline(active, 0x0000FF);
69
			draw_underline(new_active, 0xFFFfff);
70
			CursorPointer.Load(#CursorFile);
71
			CursorPointer.Set();
72
		}
73
		active = new_active;
74
		return true;
75
	}
76
 
6058 leency 77
	return false;
78
}