Subversion Repositories Kolibri OS

Rev

Rev 7755 | 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
 
57
void LinksArray::Clear()
58
{
6738 leency 59
	page_links.drop();
60
	page_links.realloc_size = 4096 * 32;
4491 leency 61
	count = 0;
62
	active = -1;
7757 leency 63
	unic_count = 0;
4497 leency 64
	CursorPointer.Restore();
4491 leency 65
}
66
 
7757 leency 67
void LinksArray::DrawUnderline(dword und_id, list_first, list_y, color)
68
{
69
	int i;
70
	for (i=0; i
71
	{
72
		if (links[i].unic_id==links[und_id].unic_id) && (links[i].y + links[i].h - list_first > list_y) {
73
			DrawBar(links[i].x, links[i].y + links[i].h - list_first, links[i].w, links[i].underline_h, color);
74
		}
75
	}
76
}
77
 
7755 leency 78
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, NULL, 0};
4497 leency 79
 
7757 leency 80
bool LinksArray::HoverAndProceed(dword mx, my, list_y, list_first)
4491 leency 81
{
82
	int i;
7746 leency 83
	if (!count) return true;
4491 leency 84
	for (i=0; i
85
	{
7748 leency 86
		if (mx>links[i].x) && (my>links[i].y)
87
		&& (mx
7757 leency 88
		&& (my>list_y+list_first)
4488 leency 89
		{
6795 leency 90
			if (mouse.lkm) && (mouse.down) {
7757 leency 91
				DrawRectangle(links[active].x, -list_first + links[active].y,
6794 leency 92
				links[active].w, links[active].h, 0);
6795 leency 93
				return false;
94
			}
95
			if (mouse.mkm) && (mouse.up) {
7755 leency 96
				RunProgram(#program_path, PageLinks.GetURL(PageLinks.active));
6795 leency 97
				return false;
98
			}
99
			if (mouse.lkm) && (mouse.up) {
100
				CursorPointer.Restore();
7755 leency 101
				EventClickLink(PageLinks.GetURL(PageLinks.active));
6795 leency 102
				return false;
103
			}
104
			if (mouse.pkm) && (mouse.up) {
7037 leency 105
				EventShowLinkMenu(mouse.x, mouse.y);
6795 leency 106
				return false;
107
			}
108
			if (active==i) return false;
7282 leency 109
			CursorPointer.Load(#CursorFile);
4497 leency 110
			CursorPointer.Set();
7757 leency 111
 
112
			if (links[active].underline) {
113
				DrawUnderline(active, list_first, list_y, link_color_inactive);
114
			}
115
 
116
			if (links[i].underline) {
117
				DrawUnderline(i, list_first, list_y, page_bg);
118
			}
119
 
4491 leency 120
			active = i;
6795 leency 121
			DrawStatusBar(links[active].link);
122
			return true;
4488 leency 123
		}
124
	}
4497 leency 125
	if (active!=-1)
126
	{
127
		CursorPointer.Restore();
6795 leency 128
		if (links[active].underline) {
7757 leency 129
			DrawUnderline(active, list_first, list_y, link_color_inactive);
6795 leency 130
		}
7757 leency 131
		DrawStatusBar(NULL);
4497 leency 132
		active = -1;
133
	}
4488 leency 134
}
6795 leency 135