Subversion Repositories Kolibri OS

Rev

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