Subversion Repositories Kolibri OS

Rev

Rev 7757 | 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;
2
dword CursorFile = FROM "../TWB/pointer.cur";
6738 leency 3
#include "..\lib\collection.h"
4497 leency 4
 
4550 leency 5
#define NOLINE    0
6
#define UNDERLINE 1
7
 
7752 leency 8
#define MAXLINKS 2000
6738 leency 9
 
4491 leency 10
struct array_link {
6795 leency 11
	dword link;
7757 leency 12
	unsigned int x,y,w,h;
13
	unsigned int unic_id;
6794 leency 14
	int underline, underline_h;
4491 leency 15
};
4488 leency 16
 
5772 leency 17
struct LinksArray {
6738 leency 18
	array_link links[MAXLINKS];
19
	collection page_links;
7757 leency 20
	unsigned int count;
21
	unsigned int unic_count;
22
	unsigned int active;
6795 leency 23
	bool HoverAndProceed();
4491 leency 24
	void AddLink();
25
	void AddText();
4488 leency 26
	dword GetURL();
27
	void Clear();
7757 leency 28
	void DrawUnderline();
5718 leency 29
} PageLinks;
4488 leency 30
 
6795 leency 31
void LinksArray::AddLink(dword lpath)
4488 leency 32
{
6738 leency 33
	if (count>= MAXLINKS) return;
34
	page_links.add(lpath);
7757 leency 35
	unic_count++;
4488 leency 36
}
37
 
6795 leency 38
void LinksArray::AddText(dword _x, _y, _w, _h, _link_underline, _underline_h)
4491 leency 39
{
6795 leency 40
	if (count>= MAXLINKS) return;
41
	links[count].x = _x;
42
	links[count].y = _y;
43
	links[count].w = _w;
44
	links[count].h = _h;
45
	links[count].underline = _link_underline;
46
	links[count].underline_h = _underline_h;
47
	links[count].link = page_links.get(page_links.count-1);
7757 leency 48
	links[count].unic_id = unic_count;
6795 leency 49
	count++;
4491 leency 50
}
51
 
4488 leency 52
dword LinksArray::GetURL(int id)
53
{
4491 leency 54
	return links[id].link;
55
}
56
 
7758 leency 57
bool open_new_window=false;
4491 leency 58
void LinksArray::Clear()
59
{
6738 leency 60
	page_links.drop();
61
	page_links.realloc_size = 4096 * 32;
4491 leency 62
	count = 0;
63
	active = -1;
7757 leency 64
	unic_count = 0;
4497 leency 65
	CursorPointer.Restore();
7758 leency 66
	open_new_window = false;
4491 leency 67
}
68
 
7757 leency 69
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
70
{
71
	int i;
72
	for (i=0; i
73
	{
74
		if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
75
			DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
76
		}
77
	}
78
}
79
 
7758 leency 80
PathShow_data status_text = {0, 17,250, 6, 250};
4497 leency 81
 
7757 leency 82
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
4491 leency 83
{
84
	int i;
7746 leency 85
	if (!count) return true;
4491 leency 86
	for (i=0; i
87
	{
7748 leency 88
		if (mx>links[i].x) && (my>links[i].y)
89
		&& (mx
7757 leency 90
		&& (my>list_y+list_first)
4488 leency 91
		{
6795 leency 92
			if (mouse.lkm) && (mouse.down) {
7757 leency 93
				DrawRectangle(links[active].x, -list_first + links[active].y,
6794 leency 94
				links[active].w, links[active].h, 0);
6795 leency 95
				return false;
96
			}
97
			if (mouse.mkm) && (mouse.up) {
7758 leency 98
				open_new_window = true;
99
				EventClickLink(PageLinks.GetURL(PageLinks.active));
100
				open_new_window = false;
6795 leency 101
				return false;
102
			}
103
			if (mouse.lkm) && (mouse.up) {
104
				CursorPointer.Restore();
7755 leency 105
				EventClickLink(PageLinks.GetURL(PageLinks.active));
6795 leency 106
				return false;
107
			}
108
			if (mouse.pkm) && (mouse.up) {
7037 leency 109
				EventShowLinkMenu(mouse.x, mouse.y);
6795 leency 110
				return false;
111
			}
112
			if (active==i) return false;
7282 leency 113
			CursorPointer.Load(#CursorFile);
4497 leency 114
			CursorPointer.Set();
7757 leency 115
 
116
			if (links[active].underline) {
117
				DrawUnderline(active, list_first, list_y, link_color_inactive);
118
			}
119
 
120
			if (links[i].underline) {
121
				DrawUnderline(i, list_first, list_y, page_bg);
122
			}
123
 
4491 leency 124
			active = i;
6795 leency 125
			DrawStatusBar(links[active].link);
126
			return true;
4488 leency 127
		}
128
	}
4497 leency 129
	if (active!=-1)
130
	{
131
		CursorPointer.Restore();
6795 leency 132
		if (links[active].underline) {
7757 leency 133
			DrawUnderline(active, list_first, list_y, link_color_inactive);
6795 leency 134
		}
7757 leency 135
		DrawStatusBar(NULL);
4497 leency 136
		active = -1;
137
	}
4488 leency 138
}
6795 leency 139