Rev 7771 | 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) { |
7793 | leency | 101 | ProcessEvent(IN_NEW_TAB); |
7771 | leency | 102 | } else { |
7793 | leency | 103 | ProcessEvent(IN_NEW_WINDOW); |
7771 | leency | 104 | } |
6795 | leency | 105 | return false; |
106 | } |
||
107 | if (mouse.lkm) && (mouse.up) { |
||
108 | CursorPointer.Restore(); |
||
7755 | leency | 109 | EventClickLink(PageLinks.GetURL(PageLinks.active)); |
6795 | leency | 110 | return false; |
111 | } |
||
112 | if (mouse.pkm) && (mouse.up) { |
||
7770 | leency | 113 | EventShowLinkMenu(); |
6795 | leency | 114 | return false; |
115 | } |
||
116 | if (active==i) return false; |
||
7282 | leency | 117 | CursorPointer.Load(#CursorFile); |
4497 | leency | 118 | CursorPointer.Set(); |
7757 | leency | 119 | |
120 | if (links[active].underline) { |
||
7759 | leency | 121 | DrawUnderline(active, list_first, list_y, link_color_default); |
7757 | leency | 122 | } |
123 | |||
124 | if (links[i].underline) { |
||
125 | DrawUnderline(i, list_first, list_y, page_bg); |
||
126 | } |
||
127 | |||
4491 | leency | 128 | active = i; |
6795 | leency | 129 | DrawStatusBar(links[active].link); |
130 | return true; |
||
4488 | leency | 131 | } |
132 | } |
||
4497 | leency | 133 | if (active!=-1) |
134 | { |
||
135 | CursorPointer.Restore(); |
||
6795 | leency | 136 | if (links[active].underline) { |
7759 | leency | 137 | DrawUnderline(active, list_first, list_y, link_color_default); |
6795 | leency | 138 | } |
7757 | leency | 139 | DrawStatusBar(NULL); |
4497 | leency | 140 | active = -1; |
141 | } |
||
4488 | leency | 142 | } |
6795 | leency | 143 |