Subversion Repositories Kolibri OS

Rev

Rev 4059 | Rev 4073 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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