Subversion Repositories Kolibri OS

Rev

Rev 5784 | Rev 5829 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5784 Rev 5825
Line 7... Line 7...
7
#include "../lib/kolibri.h"
7
#include "../lib/kolibri.h"
8
#endif
8
#endif
Line 9... Line 9...
9
 
9
 
10
struct llist
10
struct llist
11
{
11
{
12
	int x, y, w, h, line_h, text_y;
12
	int x, y, w, h, item_h, item_w;
-
 
13
	int count, visible, first, column_max; //visible = row_max
-
 
14
	int cur_x, cur_y;
13
	int count, visible, first, current, column_max; //visible = row_max
15
	int text_y;
14
	byte font_w, font_h, font_type;
16
	byte font_w, font_h, font_type;
15
	byte wheel_size;
17
	byte wheel_size;
16
	byte active;
18
	byte active;
-
 
19
	byte no_selection;
17
	byte no_selection;
20
	byte horisontal_selelection;
18
	void ClearList();
21
	void ClearList();
19
	int MouseOver(int xx, yy);
22
	void SetSizes(int xx, yy, ww, hh, item_hh);
20
	int ProcessMouse(int xx, yy);
23
	void SetFont(dword font_ww, font_hh, font_tt);
-
 
24
	int ProcessKey(dword key);
-
 
25
	int ProcessMouse(int xx, yy);
-
 
26
	int MouseOver(int xx, yy);
21
	int ProcessKey(dword key);
27
	int MouseScroll(dword scroll_state);
22
	int KeyDown();
28
	int KeyDown(); 
23
	int KeyUp();
29
	int KeyUp(); 
24
	int KeyHome();
30
	int KeyHome(); 
25
	int KeyEnd();
31
	int KeyEnd(); 
26
	int KeyPgDown();
32
	int KeyPgDown(); 
-
 
33
	int KeyPgUp(); 
-
 
34
	int KeyLeft(); 
27
	int KeyPgUp();
35
	int KeyRight();
28
	void CheckDoesValuesOkey();
-
 
29
	void SetSizes(int xx, yy, ww, hh, line_hh);
-
 
30
	void SetFont(dword font_ww, font_hh, font_tt);
-
 
31
	int MouseScroll(dword scroll_state);
36
	void CheckDoesValuesOkey();
32
	void debug_values();
37
	void debug_values();
Line 33... Line -...
33
}; 
-
 
34
 
38
};
35
 
39
 
36
void llist::debug_values()
40
void llist::debug_values()
37
{
41
{
38
	char yi[128];
-
 
39
	sprintf(#yi, "%s %d %s %d %s %d %s %d", "current:", current, "first:", first,
42
	char yi[128];
40
	"visible:", visible, "count:", count);
43
	sprintf(#yi, "%s %d %s %d %s %d %s %d %s %d %s %d", "first:", first, "visible:", visible, "count:", count, "col_max:", column_max, "cur_y:", cur_y, "cur_x:", cur_x);
Line 41... Line -...
41
	debugln(#yi);
-
 
42
}
44
	debugln(#yi);
43
 
45
}
44
 
46
 
45
 
47
 
Line 46... Line 48...
46
void llist::ClearList()
48
void llist::ClearList()
47
{
49
{
48
	count = visible = first = current = 0;
50
	count = visible = first = cur_y = cur_x = 0;
49
}
51
}
50
 
52
 
51
 
53
 
52
void llist::SetSizes(int xx, yy, ww, hh, line_hh)
54
void llist::SetSizes(int xx, yy, ww, hh, item_hh)
53
{
55
{
54
	x = xx;
56
	x = xx;
55
	y = yy;
57
	y = yy;
56
	w = ww;
58
	w = ww;
57
	h = hh;
59
	h = hh;
Line 58... Line 60...
58
	line_h = line_hh;
60
	item_h = item_hh;
Line 95... Line 97...
95
	return 0;
97
	return 0;
96
}
98
}
Line 97... Line 99...
97
 
99
 
98
int llist::ProcessMouse(int xx, yy)
100
int llist::ProcessMouse(int xx, yy)
99
{
101
{
100
	int current_temp;
102
	int cur_y_temp, cur_x_temp, ret=0;
101
	if (MouseOver(xx, yy))
103
	if (MouseOver(xx, yy))
102
	{
104
	{
103
		current_temp = yy - y / line_h + first;
105
		cur_y_temp = yy - y / item_h + first;
104
		if (current_temp != current) && (current_temp
106
		if (cur_y_temp != cur_y) && (cur_y_temp
105
		{
107
		{
106
			current = current_temp;
108
			cur_y = cur_y_temp;
107
			return 1;
109
			ret = 1;
-
 
110
		}
-
 
111
		cur_x_temp = xx - x / item_w;
-
 
112
		if (cur_x_temp != cur_x) && (cur_x_temp
-
 
113
		{
-
 
114
			cur_x = cur_x_temp;
108
		}
115
			ret = 1;
-
 
116
		}
109
	}
117
	}
110
	return 0;
118
	return ret;
Line 111... Line 119...
111
}
119
}
112
 
120
 
113
int llist::ProcessKey(dword key)
121
int llist::ProcessKey(dword key)
Line 119... Line 127...
119
		case SCAN_CODE_HOME: return KeyHome();
127
		case SCAN_CODE_HOME: return KeyHome();
120
		case SCAN_CODE_END:  return KeyEnd();
128
		case SCAN_CODE_END:  return KeyEnd();
121
		case SCAN_CODE_PGUP: return KeyPgUp();
129
		case SCAN_CODE_PGUP: return KeyPgUp();
122
		case SCAN_CODE_PGDN: return KeyPgDown();
130
		case SCAN_CODE_PGDN: return KeyPgDown();
123
	}
131
	}
-
 
132
	if (horisontal_selelection) switch(key)
-
 
133
	{
-
 
134
		case SCAN_CODE_LEFT:  return KeyLeft();
-
 
135
		case SCAN_CODE_RIGHT: return KeyRight();
-
 
136
	}
124
	return 0;
137
	return 0;
125
}
138
}
Line 126... Line 139...
126
 
139
 
127
int llist::KeyDown()
140
int llist::KeyDown()
Line 131... Line 144...
131
		if (visible + first >= count) return 0;
144
		if (visible + first >= count) return 0;
132
		first++;
145
		first++;
133
		return 1;		
146
		return 1;		
134
	}
147
	}
Line 135... Line 148...
135
 
148
 
136
	if (current-first+1
149
	if (cur_y-first+1
137
	{
150
	{
138
		if (current + 1 >= count) return 0;
151
		if (cur_y + 1 >= count) return 0;
139
		current++;
152
		cur_y++;
140
	}
153
	}
141
	else 
154
	else 
142
	{
155
	{
143
		if (visible + first >= count) return 0;
156
		if (visible + first >= count) return 0;
144
		first++;
157
		first++;
145
		current++;
158
		cur_y++;
146
	}
159
	}
147
	if (current < first) || (current > first + visible)
160
	if (cur_y < first) || (cur_y > first + visible)
148
	{
161
	{
149
		first = current;
162
		first = cur_y;
150
		CheckDoesValuesOkey();
163
		CheckDoesValuesOkey();
151
	}
164
	}
152
	return 1;
165
	return 1;
Line 159... Line 172...
159
		if (first == 0) return 0;
172
		if (first == 0) return 0;
160
		first--;
173
		first--;
161
		return 1;
174
		return 1;
162
	}
175
	}
Line 163... Line 176...
163
 
176
 
164
	if (current > first)
177
	if (cur_y > first)
165
	{
178
	{
166
		current--;
179
		cur_y--;
167
	}
180
	}
168
	else
181
	else
169
	{
182
	{
170
		if (first == 0) return 0;
183
		if (first == 0) return 0;
171
		first--;
184
		first--;
172
		current--;
185
		cur_y--;
173
	}
186
	}
174
	if (current < first) || (current > first + visible)
187
	if (cur_y < first) || (cur_y > first + visible)
175
	{
188
	{
176
		first = current;
189
		first = cur_y;
177
		CheckDoesValuesOkey();
190
		CheckDoesValuesOkey();
178
	}
191
	}
179
	return 1;
192
	return 1;
Line 180... Line 193...
180
}
193
}
181
 
194
 
182
int llist::KeyHome()
195
int llist::KeyHome()
183
{
196
{
184
	if (current==0) && (first==0) return 0;
197
	if (cur_y==0) && (first==0) return 0;
185
	current = first = 0;
198
	cur_y = first = 0;
Line 186... Line 199...
186
	return 1;
199
	return 1;
187
}
200
}
188
 
201
 
189
int llist::KeyEnd()
202
int llist::KeyEnd()
190
{
203
{
191
	if (current==count-1) && (first==count-visible) return 0;
204
	if (cur_y==count-1) && (first==count-visible) return 0;
192
	current = count-1;
205
	cur_y = count-1;
Line 193... Line 206...
193
	first = count - visible;
206
	first = count - visible;
Line 214... Line 227...
214
 
227
 
215
void llist::CheckDoesValuesOkey()
228
void llist::CheckDoesValuesOkey()
216
{
229
{
217
	if (visible + first > count) first = count - visible;
230
	if (visible + first > count) first = count - visible;
218
	if (first < 0) first = 0;
231
	if (first < 0) first = 0;
-
 
232
	if (cur_y >= count) cur_y = count - 1;
219
	if (current >= count) current = count - 1;
233
	if (cur_y < 0) cur_y = 0;
220
	if (current < 0) current = 0;
234
	if (cur_x < 0) cur_x = 0;
Line -... Line 235...
-
 
235
}
-
 
236
 
-
 
237
int llist::KeyRight()
-
 
238
{
-
 
239
	if (cur_x < column_max)
-
 
240
	{
-
 
241
		cur_x++;
-
 
242
	}
-
 
243
	else 
-
 
244
	{
-
 
245
		if (!KeyDown()) return 0;
-
 
246
		cur_x = 0;
-
 
247
	}
-
 
248
	return 1;
-
 
249
}
-
 
250
 
-
 
251
int llist::KeyLeft()
-
 
252
{
-
 
253
	if (cur_x > 0)
-
 
254
	{
-
 
255
		cur_x--;
-
 
256
	}
-
 
257
	else 
-
 
258
	{
-
 
259
		if (!KeyUp()) return 0;
-
 
260
		cur_x = column_max;
-
 
261
	}
-
 
262
	return 1;
-
 
263
}
221
}
264
 
222
 
265
 
223
void llist_copy(dword dest, src)
266
void llist_copy(dword dest, src)
224
{
267
{
225
	EDI = dest;
268
	EDI = dest;
226
	ESI = src;
269
	ESI = src;
227
	EDI.llist.x = ESI.llist.x;
270
	EDI.llist.x = ESI.llist.x;
228
	EDI.llist.y = ESI.llist.y;
271
	EDI.llist.y = ESI.llist.y;
229
	EDI.llist.w = ESI.llist.w;
272
	EDI.llist.w = ESI.llist.w;
230
	EDI.llist.h = ESI.llist.h;
273
	EDI.llist.h = ESI.llist.h;
231
	EDI.llist.line_h = ESI.llist.line_h;
274
	EDI.llist.item_h = ESI.llist.item_h;
232
	EDI.llist.text_y = ESI.llist.text_y;
275
	EDI.llist.text_y = ESI.llist.text_y;
233
	EDI.llist.font_w = ESI.llist.font_w;
276
	EDI.llist.font_w = ESI.llist.font_w;
234
	EDI.llist.font_h = ESI.llist.font_h;
277
	EDI.llist.font_h = ESI.llist.font_h;
235
	EDI.llist.font_type = ESI.llist.font_type;
278
	EDI.llist.font_type = ESI.llist.font_type;
236
	EDI.llist.count = ESI.llist.count;
279
	EDI.llist.count = ESI.llist.count;
237
	EDI.llist.visible = ESI.llist.visible;
280
	EDI.llist.visible = ESI.llist.visible;
238
	EDI.llist.first = ESI.llist.first;
281
	EDI.llist.first = ESI.llist.first;
239
	EDI.llist.current = ESI.llist.current;
282
	EDI.llist.cur_y = ESI.llist.cur_y;
240
	EDI.llist.column_max = ESI.llist.column_max;
283
	EDI.llist.column_max = ESI.llist.column_max;
Line 241... Line 284...
241
	EDI.llist.active = ESI.llist.active;
284
	EDI.llist.active = ESI.llist.active;
242
}
285
}