Subversion Repositories Kolibri OS

Rev

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