Rev 7291 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7291 | leency | 1 | dword CursorFile = FROM "pointer.cur"; |
2 | |||
6058 | leency | 3 | struct _link |
4 | { |
||
7291 | leency | 5 | CustomCursor CursorPointer; |
6058 | leency | 6 | int count; |
7 | int x[4096], y[4096], w[4096], h[4096]; |
||
8 | collection text; |
||
9 | collection url; |
||
10 | void clear(); |
||
11 | void add(); |
||
7293 | leency | 12 | dword get_active_url(); |
13 | void draw_underline(); |
||
6058 | leency | 14 | int hover(); |
15 | int active; |
||
16 | } link; |
||
17 | |||
18 | void _link::clear() |
||
19 | { |
||
20 | text.drop(); |
||
21 | url.drop(); |
||
22 | count = 0; |
||
23 | } |
||
24 | |||
25 | void _link::add(int _xx, _yy, _ww, _hh, dword _textt, _urll ) |
||
26 | { |
||
27 | if (count==4095) return; |
||
28 | x[count] = _xx; |
||
29 | y[count] = _yy; |
||
30 | w[count] = _ww; |
||
31 | h[count] = _hh; |
||
32 | text.add(_textt); |
||
33 | url.add(_urll); |
||
34 | count++; |
||
35 | } |
||
36 | |||
7293 | leency | 37 | dword _link::get_active_url() |
38 | { |
||
39 | return url.get(active); |
||
40 | } |
||
41 | |||
7291 | leency | 42 | void _link::draw_underline(dword i, color) |
43 | { |
||
7293 | leency | 44 | DrawBar(x[i]+list.x, -list.first*list.item_h+y[i]+list.y+h[i]-2, w[i], 1, color); |
7291 | leency | 45 | } |
46 | |||
7293 | leency | 47 | int _link::hover(dword mouse_x, mouse_y) |
6058 | leency | 48 | { |
49 | int i; |
||
7291 | leency | 50 | int new_active = -1; |
51 | int link_start_y = list.first*list.item_h; |
||
7293 | leency | 52 | mouse_x -= list.x; |
53 | mouse_y -= list.y; |
||
7291 | leency | 54 | for (i=0; i |
55 | if(y[i] > link_start_y) && (y[i] < link_start_y+list.h) { |
||
56 | // debugln( sprintf(#param, "mx:%i my:%i x[i]:%i y[i]:%i", mx, my, x[i], y[i]) ); |
||
7293 | leency | 57 | if (mouse_x > x[i]) |
58 | && (mouse_x < x[i]+w[i]) |
||
59 | && (mouse_y > y[i]-link_start_y) |
||
60 | && (mouse_y < h[i]-link_start_y+link.y[i]) { |
||
7291 | leency | 61 | new_active = i; |
62 | break; |
||
6059 | leency | 63 | } |
6058 | leency | 64 | } |
65 | } |
||
7291 | leency | 66 | |
67 | if (new_active != active) |
||
68 | { |
||
69 | if (-1 == new_active) { |
||
70 | draw_underline(active, 0x0000FF); |
||
71 | CursorPointer.Restore(); |
||
72 | } |
||
73 | else { |
||
74 | draw_underline(active, 0x0000FF); |
||
75 | draw_underline(new_active, 0xFFFfff); |
||
76 | CursorPointer.Load(#CursorFile); |
||
77 | CursorPointer.Set(); |
||
78 | } |
||
79 | active = new_active; |
||
80 | return true; |
||
81 | } |
||
82 | |||
6058 | leency | 83 | return false; |
84 | }>>> |