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