Rev 4059 | Rev 4073 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3225 | leency | 1 | //list_box |
2 | |||
3 | struct llist |
||
4 | { |
||
4049 | leency | 5 | int x, y, w, h, min_h, line_h; |
3225 | leency | 6 | int count, visible, first, current; |
4049 | leency | 7 | int current_temp; |
3225 | leency | 8 | void ClearList(); |
4059 | leency | 9 | int KeyDown(); |
10 | int KeyUp(); |
||
4063 | leency | 11 | int KeyHome(); |
12 | int KeyEnd(); |
||
3225 | leency | 13 | void SetSizes(int xx, yy, ww, hh, min_hh, line_hh); |
14 | int MouseScroll(dword scroll_state); |
||
15 | }; |
||
16 | |||
17 | |||
18 | void llist::ClearList() |
||
19 | { |
||
20 | count = visible = first = current = 0; |
||
21 | } |
||
22 | |||
23 | |||
24 | void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh) |
||
25 | { |
||
26 | x = xx; |
||
27 | y = yy; |
||
28 | w = ww; |
||
29 | h = hh; |
||
30 | min_h = min_hh; |
||
31 | line_h = line_hh; |
||
3368 | leency | 32 | visible = h / line_h; |
3225 | leency | 33 | } |
34 | |||
35 | |||
36 | int llist::MouseScroll(dword scroll_state) |
||
37 | { |
||
38 | if (scroll_state == 65535) |
||
39 | { |
||
40 | if (first == 0) return 0; |
||
41 | if (first > 3) first -= 2; else first=0; |
||
42 | return 1; |
||
43 | } |
||
44 | if (scroll_state == 1) |
||
45 | { |
||
46 | if (visible+first+3 >= count) first = count - visible; else first+=2; |
||
47 | return 1; |
||
48 | } |
||
49 | return 0; |
||
4059 | leency | 50 | } |
51 | |||
52 | int llist::KeyDown() |
||
53 | { |
||
54 | if (current-first+1 |
||
55 | { |
||
4063 | leency | 56 | if (current+1>=count) return 0; |
4059 | leency | 57 | current++; |
58 | } |
||
59 | else |
||
60 | { |
||
4063 | leency | 61 | if (visible+first>=count) return 0; |
4059 | leency | 62 | first++; |
63 | current++; |
||
64 | } |
||
65 | return 1; |
||
66 | } |
||
67 | |||
68 | int llist::KeyUp() |
||
69 | { |
||
70 | if (current>first) |
||
71 | { |
||
72 | current--; |
||
73 | } |
||
74 | else |
||
75 | { |
||
4063 | leency | 76 | if (first==0) return 0; |
4059 | leency | 77 | first--; |
78 | current--; |
||
79 | } |
||
80 | return 1; |
||
4063 | leency | 81 | } |
82 | |||
83 | int llist::KeyHome() |
||
84 | { |
||
85 | if (current==0) && (first==0) return 0; |
||
86 | current=0; |
||
87 | first=0; |
||
88 | return 1; |
||
89 | } |
||
90 | |||
91 | int llist::KeyEnd() |
||
92 | { |
||
93 | if (current==count-1) && (first==count-visible) return 0; |
||
94 | current=count-1; |
||
95 | first=count-visible; |
||
96 | return 1; |
||
3225 | leency | 97 | } |