Subversion Repositories Kolibri OS

Rev

Rev 5678 | 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();
5718 leency 27
	int UrlAbsolute();
28
} PageLinks;
4488 leency 29
 
4491 leency 30
void LinksArray::AddLink(dword new_link, int link_x, link_y)
4488 leency 31
{
4491 leency 32
	links[count].x = link_x;
33
	links[count].y = link_y;
34
 
35
	links[count].link = buflen;
36
	strcpy(buflen, new_link);
37
	buflen += strlen(new_link)+1;
38
	count++;
4488 leency 39
}
40
 
4550 leency 41
void LinksArray::AddText(dword new_text, int link_w, link_h, link_underline)
4491 leency 42
{
43
	if (count<1) return;
44
	links[count-1].w = link_w;
45
	links[count-1].h = link_h;
4550 leency 46
	links[count-1].underline = link_underline;
4491 leency 47
 
48
	links[count-1].text = buflen;
49
	strcpy(buflen, new_text);
50
	buflen += strlen(new_text)+1;
51
}
52
 
4488 leency 53
dword LinksArray::GetURL(int id)
54
{
4491 leency 55
	return links[id].link;
56
}
57
 
58
void LinksArray::Clear()
59
{
4493 leency 60
	int i;
61
	for (i=0; i<=count; i++) DeleteButton(i+400);
4491 leency 62
	buflen = #page_links;
63
	count = 0;
64
	active = -1;
4497 leency 65
	CursorPointer.Restore();
4491 leency 66
}
67
 
4686 leency 68
char temp[sizeof(URL)];
4677 leency 69
PathShow_data status_text = {0, 17,250, 6, 250, 0, 0, 0x0, 0xFFFfff, 0, #temp, 0};
4497 leency 70
 
4492 leency 71
void LinksArray::Hover(dword mx, my, link_col_in, link_col_a, bg_col)
4491 leency 72
{
73
	int i;
74
	for (i=0; i
75
	{
76
		if (mx>links[i].x) && (my>links[i].y) && (mx
4488 leency 77
		{
4497 leency 78
			if (active==i) return;
79
			CursorPointer.Set();
5678 leency 80
			if (links[active].underline) DrawBar(links[active].x, WB1.list.line_h - WB1.DrawBuf.zoom + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
81
			if (links[i].underline) DrawBar(links[i].x, WB1.list.line_h - WB1.DrawBuf.zoom + links[i].y,links[i].w, WB1.DrawBuf.zoom, bg_col);
4491 leency 82
			active = i;
5519 leency 83
			status_text.start_x = wv_progress_bar.left + wv_progress_bar.width + 10;
84
			status_text.start_y = Form.cheight - STATUSBAR_H + 3;
4718 leency 85
			status_text.area_size_x = Form.cwidth - status_text.start_x -3;
86
			DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
4677 leency 87
			status_text.text_pointer = links[active].link;
88
			PathShow_prepare stdcall(#status_text);
89
			PathShow_draw stdcall(#status_text);
4491 leency 90
			return;
4488 leency 91
		}
92
	}
4497 leency 93
	if (active!=-1)
94
	{
95
		CursorPointer.Restore();
5678 leency 96
		if (links[active].underline) DrawBar(links[active].x, WB1.list.line_h - WB1.DrawBuf.zoom + links[active].y,links[active].w, WB1.DrawBuf.zoom, link_col_in);
4718 leency 97
		DrawBar(status_text.start_x, status_text.start_y, status_text.area_size_x, 9, col_bg);
4497 leency 98
		active = -1;
99
	}
4488 leency 100
}
101
 
5718 leency 102
int LinksArray::UrlAbsolute(dword in_URL)
103
{
104
	if(!strncmp(in_URL,"http:",5)) return 1;
105
	if(!strncmp(in_URL,"https:",6)) return 1;
106
	if(!strncmp(in_URL,"mailto:",7)) return 1;
107
	if(!strncmp(in_URL,"ftp:",4)) return 1;
108
	if(!strncmp(in_URL,"WebView:",8)) return 1;
109
	if(!strncmp(in_URL,"/sys/",5)) return 1;
110
	if(!strncmp(in_URL,"/hd/",4)) return 1;
111
	if(!strncmp(in_URL,"/fd/",4)) return 1;
112
	if(!strncmp(in_URL,"/rd/",4)) return 1;
113
	if(!strncmp(in_URL,"/tmp/",5)) return 1;
114
	if(!strncmp(in_URL,"/cd/",4)) return 1;
115
	if(!strncmp(in_URL,"/bd/",4)) return 1;
116
	if(!strncmp(in_URL,"/usbhd/",7)) return 1;
117
	if(!strncmp(in_URL,"/kolibrios/",11)) return 1;
118
	return 0;
119
}
120
 
121
void LinksArray::GetAbsoluteURL(dword in_URL)
122
{
123
	int i;
4686 leency 124
	dword orig_URL = in_URL;
125
	char newurl[sizeof(URL)];
5718 leency 126
 
127
	if (UrlAbsolute(in_URL)) return;
4686 leency 128
 
129
	IF (!strcmpn(in_URL,"./", 2)) in_URL+=2;
130
	strcpy(#newurl, BrowserHistory.CurrentUrl());
4491 leency 131
 
5625 leency 132
	if (ESBYTE[in_URL] == '/') //remove everything after site domain name
4686 leency 133
	{
134
		i = strchr(#newurl+8, '/');
5625 leency 135
		if (i) ESBYTE[i]=0;
4686 leency 136
		in_URL+=1;
137
	}
138
 
139
	_CUT_ST_LEVEL_MARK:
140
 
141
	if (newurl[strrchr(#newurl, '/')-2]<>'/')
142
	{
143
		newurl[strrchr(#newurl, '/')] = 0x00;
144
	}
145
 
146
	IF (!strncmp(in_URL,"../",3))
147
	{
148
		in_URL+=3;
149
		newurl[strrchr(#newurl, '/')-1] = 0x00;
150
		goto _CUT_ST_LEVEL_MARK;
151
	}
152
 
153
	if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
154
 
155
	strcat(#newurl, in_URL);
156
	strcpy(orig_URL, #newurl);
157
}
158
 
159