Subversion Repositories Kolibri OS

Rev

Rev 4677 | 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";
3
 
4550 leency 4
#define NOLINE    0
5
#define UNDERLINE 1
6
 
7
 
4491 leency 8
struct array_link {
9
	dword link, text;
10
	int x,y,w,h;
4550 leency 11
	int underline;
4491 leency 12
};
4488 leency 13
 
14
struct LinksArray
15
{
4493 leency 16
	array_link links[200];
17
	char page_links[64000];
4491 leency 18
	dword buflen;
19
	int count, active;
20
 
21
	void Hover();
22
	void AddLink();
23
	void AddText();
4488 leency 24
	dword GetURL();
25
	void Clear();
4686 leency 26
	void GetAbsoluteURL();
4491 leency 27
};
4488 leency 28
 
4491 leency 29
void LinksArray::AddLink(dword new_link, int link_x, link_y)
4488 leency 30
{
4491 leency 31
	links[count].x = link_x;
32
	links[count].y = link_y;
33
 
34
	links[count].link = buflen;
35
	strcpy(buflen, new_link);
36
	buflen += strlen(new_link)+1;
37
	count++;
4488 leency 38
}
39
 
4550 leency 40
void LinksArray::AddText(dword new_text, int link_w, link_h, link_underline)
4491 leency 41
{
42
	if (count<1) return;
43
	links[count-1].w = link_w;
44
	links[count-1].h = link_h;
4550 leency 45
	links[count-1].underline = link_underline;
4491 leency 46
 
47
	links[count-1].text = buflen;
48
	strcpy(buflen, new_text);
49
	buflen += strlen(new_text)+1;
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
{
4493 leency 59
	int i;
60
	for (i=0; i<=count; i++) DeleteButton(i+400);
4491 leency 61
	buflen = #page_links;
62
	count = 0;
63
	active = -1;
4497 leency 64
	CursorPointer.Restore();
4491 leency 65
}
66
 
4686 leency 67
char temp[sizeof(URL)];
4677 leency 68
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0};
4497 leency 69
 
4492 leency 70
void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
4491 leency 71
{
72
	int i;
73
	for (i=0; i
74
	{
75
		if (mx>links[i].x) && (my>links[i].y) && (mx
4488 leency 76
		{
4497 leency 77
			if (active==i) return;
78
			CursorPointer.Set();
4550 leency 79
			if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
80
			if (links[i].underline) DrawBar(links[i].x,links[i].y+8,links[i].w,1, bg_col);
4491 leency 81
			active = i;
4677 leency 82
			DrawBar(progress_bar.left+progress_bar.width+10, progress_bar.top+2, Form.cwidth-progress_bar.left-progress_bar.width-10, 9, col_bg);
83
			status_text.start_x = progress_bar.left+progress_bar.width+10;
84
			status_text.start_y = progress_bar.top+2;
85
			status_text.area_size_x = Form.cwidth-progress_bar.left-progress_bar.width-10;
86
			status_text.text_pointer = links[active].link;
87
			PathShow_prepare stdcall(#status_text);
88
			PathShow_draw stdcall(#status_text);
4491 leency 89
			return;
4488 leency 90
		}
91
	}
4497 leency 92
	if (active!=-1)
93
	{
94
		CursorPointer.Restore();
4550 leency 95
		if (links[active].underline) DrawBar(links[active].x,links[active].y+8,links[active].w,1, link_col_in);
4677 leency 96
		DrawBar(progress_bar.left+progress_bar.width+10, progress_bar.top+2, Form.cwidth-progress_bar.left-progress_bar.width-10, 9, col_bg);
4497 leency 97
		active = -1;
98
	}
4488 leency 99
}
100
 
4686 leency 101
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/",
102
"/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", "WebView:", 0};
103
void LinksArray::GetAbsoluteURL(dword in_URL){
104
	int i, len;
105
	dword orig_URL = in_URL;
106
	char newurl[sizeof(URL)];
107
 
108
	for (i=0; ABSOLUTE_LINKS[i]; i++)
109
	{
110
		len=strlen(ABSOLUTE_LINKS[i]);
111
		if (!strcmpn(in_URL, ABSOLUTE_LINKS[i], len)) return;
112
	}
113
	IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
114
	strcpy(#newurl, BrowserHistory.CurrentUrl());
4491 leency 115
 
4686 leency 116
	if (ESBYTE[in_URL] == '/')
117
	{
118
		i = strchr(#newurl+8, '/');
119
		if (i>0) newurl[i+7]=0;
120
		in_URL+=1;
121
	}
122
 
123
	_CUT_ST_LEVEL_MARK:
124
 
125
	if (newurl[strrchr(#newurl, '/')-2]<>'/')
126
	{
127
		newurl[strrchr(#newurl, '/')] = 0x00;
128
	}
129
 
130
	IF (!strncmp(in_URL,"../",3))
131
	{
132
		in_URL+=3;
133
		newurl[strrchr(#newurl, '/')-1] = 0x00;
134
		goto _CUT_ST_LEVEL_MARK;
135
	}
136
 
137
	if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
138
 
139
	strcat(#newurl, in_URL);
140
	strcpy(orig_URL, #newurl);
141
}
142
 
143
 
144
 
4493 leency 145
LinksArray PageLinks;