Subversion Repositories Kolibri OS

Rev

Rev 4049 | Rev 4063 | 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();
3225 leency 11
	void SetSizes(int xx, yy, ww, hh, min_hh, line_hh);
12
	int MouseScroll(dword scroll_state);
13
};
14
 
15
 
16
void llist::ClearList()
17
{
18
	count = visible = first = current = 0;
19
}
20
 
21
 
22
void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh)
23
{
24
	x = xx;
25
	y = yy;
26
	w = ww;
27
	h = hh;
28
	min_h = min_hh;
29
	line_h = line_hh;
3368 leency 30
	visible = h / line_h;
3225 leency 31
}
32
 
33
 
34
int llist::MouseScroll(dword scroll_state)
35
{
36
	if (scroll_state == 65535)
37
	{
38
		if (first == 0) return 0;
39
		if (first > 3) first -= 2; else first=0;
40
		return 1;
41
	}
42
	if (scroll_state == 1)
43
	{
44
		if (visible+first+3 >= count) first = count - visible; else first+=2;
45
		return 1;
46
	}
47
	return 0;
4059 leency 48
}
49
 
50
int llist::KeyDown()
51
{
52
	if (current-first+1
53
	{
54
		if (current+1>=count) return -1;
55
		current++;
56
	}
57
	else
58
	{
59
		if (visible+first>=count) return -1;
60
		first++;
61
		current++;
62
	}
63
	return 1;
64
}
65
 
66
int llist::KeyUp()
67
{
68
	if (current>first)
69
	{
70
		current--;
71
	}
72
	else
73
	{
74
		if (first==0) return -1;
75
		first--;
76
		current--;
77
	}
78
	return 1;
3225 leency 79
}