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