Rev 4409 | Rev 4533 | 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 | { |
||
4078 | leency | 5 | int x, y, w, h, min_h, line_h, text_y; |
4415 | leency | 6 | int column_max; |
3225 | leency | 7 | int count, visible, first, current; |
4409 | leency | 8 | int active; |
3225 | leency | 9 | void ClearList(); |
4073 | leency | 10 | int ProcessKey(dword key); |
4077 | leency | 11 | int MouseOver(int xx, yy); |
12 | int ProcessMouse(int xx, yy); |
||
4059 | leency | 13 | int KeyDown(); |
14 | int KeyUp(); |
||
4063 | leency | 15 | int KeyHome(); |
16 | int KeyEnd(); |
||
3225 | leency | 17 | void SetSizes(int xx, yy, ww, hh, min_hh, line_hh); |
18 | int MouseScroll(dword scroll_state); |
||
19 | }; |
||
20 | |||
21 | |||
22 | void llist::ClearList() |
||
23 | { |
||
24 | count = visible = first = current = 0; |
||
25 | } |
||
26 | |||
27 | |||
28 | void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh) |
||
29 | { |
||
30 | x = xx; |
||
31 | y = yy; |
||
32 | w = ww; |
||
33 | h = hh; |
||
34 | min_h = min_hh; |
||
35 | line_h = line_hh; |
||
4078 | leency | 36 | text_y = line_hh / 2 - 4; |
3368 | leency | 37 | visible = h / line_h; |
4078 | leency | 38 | if (visible > count) visible=count; |
3225 | leency | 39 | } |
40 | |||
41 | |||
42 | int llist::MouseScroll(dword scroll_state) |
||
43 | { |
||
44 | if (scroll_state == 65535) |
||
45 | { |
||
46 | if (first == 0) return 0; |
||
47 | if (first > 3) first -= 2; else first=0; |
||
48 | return 1; |
||
49 | } |
||
50 | if (scroll_state == 1) |
||
51 | { |
||
52 | if (visible+first+3 >= count) first = count - visible; else first+=2; |
||
53 | return 1; |
||
54 | } |
||
55 | return 0; |
||
4059 | leency | 56 | } |
57 | |||
4077 | leency | 58 | int llist::MouseOver(int xx, yy) |
59 | { |
||
60 | if (xx>x) && (xx |
||
61 | return 0; |
||
62 | } |
||
63 | |||
64 | int llist::ProcessMouse(int xx, yy) |
||
65 | { |
||
4078 | leency | 66 | int current_temp; |
4077 | leency | 67 | if (MouseOver(xx, yy)) |
68 | { |
||
69 | current_temp = yy - y / line_h + first; |
||
4078 | leency | 70 | if (current_temp != current) && (current_temp |
4077 | leency | 71 | { |
72 | current = current_temp; |
||
73 | return 1; |
||
74 | } |
||
75 | } |
||
76 | return 0; |
||
77 | } |
||
78 | |||
4073 | leency | 79 | int llist::ProcessKey(dword key) |
80 | { |
||
81 | switch(key) |
||
82 | { |
||
83 | case 177: return KeyDown(); |
||
84 | case 178: return KeyUp(); |
||
85 | case 180: return KeyHome(); |
||
86 | case 181: return KeyEnd(); |
||
87 | } |
||
88 | return 0; |
||
89 | } |
||
90 | |||
4059 | leency | 91 | int llist::KeyDown() |
92 | { |
||
93 | if (current-first+1 |
||
94 | { |
||
4063 | leency | 95 | if (current+1>=count) return 0; |
4059 | leency | 96 | current++; |
97 | } |
||
98 | else |
||
99 | { |
||
4063 | leency | 100 | if (visible+first>=count) return 0; |
4059 | leency | 101 | first++; |
102 | current++; |
||
103 | } |
||
104 | return 1; |
||
105 | } |
||
106 | |||
107 | int llist::KeyUp() |
||
108 | { |
||
109 | if (current>first) |
||
110 | { |
||
111 | current--; |
||
112 | } |
||
113 | else |
||
114 | { |
||
4063 | leency | 115 | if (first==0) return 0; |
4059 | leency | 116 | first--; |
117 | current--; |
||
118 | } |
||
119 | return 1; |
||
4063 | leency | 120 | } |
121 | |||
122 | int llist::KeyHome() |
||
123 | { |
||
124 | if (current==0) && (first==0) return 0; |
||
125 | current=0; |
||
126 | first=0; |
||
127 | return 1; |
||
128 | } |
||
129 | |||
130 | int llist::KeyEnd() |
||
131 | { |
||
132 | if (current==count-1) && (first==count-visible) return 0; |
||
133 | current=count-1; |
||
134 | first=count-visible; |
||
135 | return 1; |
||
3225 | leency | 136 | } |