Subversion Repositories Kolibri OS

Rev

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