2013-02-04 14:15:13 +01:00
|
|
|
//list_box
|
|
|
|
|
|
|
|
struct llist
|
|
|
|
{
|
2013-10-17 23:02:47 +02:00
|
|
|
int x, y, w, h, min_h, line_h;
|
2013-02-04 14:15:13 +01:00
|
|
|
int count, visible, first, current;
|
2013-10-17 23:02:47 +02:00
|
|
|
int current_temp;
|
2013-02-04 14:15:13 +01:00
|
|
|
void ClearList();
|
2013-10-22 23:35:16 +02:00
|
|
|
int ProcessKey(dword key);
|
2013-10-20 14:20:57 +02:00
|
|
|
int KeyDown();
|
|
|
|
int KeyUp();
|
2013-10-21 00:47:10 +02:00
|
|
|
int KeyHome();
|
|
|
|
int KeyEnd();
|
2013-02-04 14:15:13 +01:00
|
|
|
void SetSizes(int xx, yy, ww, hh, min_hh, line_hh);
|
|
|
|
int MouseScroll(dword scroll_state);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void llist::ClearList()
|
|
|
|
{
|
|
|
|
count = visible = first = current = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void llist::SetSizes(int xx, yy, ww, hh, min_hh, line_hh)
|
|
|
|
{
|
|
|
|
x = xx;
|
|
|
|
y = yy;
|
|
|
|
w = ww;
|
|
|
|
h = hh;
|
|
|
|
min_h = min_hh;
|
|
|
|
line_h = line_hh;
|
2013-03-12 17:19:10 +01:00
|
|
|
visible = h / line_h;
|
2013-02-04 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int llist::MouseScroll(dword scroll_state)
|
|
|
|
{
|
|
|
|
if (scroll_state == 65535)
|
|
|
|
{
|
|
|
|
if (first == 0) return 0;
|
|
|
|
if (first > 3) first -= 2; else first=0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (scroll_state == 1)
|
|
|
|
{
|
|
|
|
if (visible+first+3 >= count) first = count - visible; else first+=2;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2013-10-20 14:20:57 +02:00
|
|
|
}
|
|
|
|
|
2013-10-22 23:35:16 +02:00
|
|
|
int llist::ProcessKey(dword key)
|
|
|
|
{
|
|
|
|
switch(key)
|
|
|
|
{
|
|
|
|
case 177: return KeyDown();
|
|
|
|
case 178: return KeyUp();
|
|
|
|
case 180: return KeyHome();
|
|
|
|
case 181: return KeyEnd();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-20 14:20:57 +02:00
|
|
|
int llist::KeyDown()
|
|
|
|
{
|
|
|
|
if (current-first+1<visible)
|
|
|
|
{
|
2013-10-21 00:47:10 +02:00
|
|
|
if (current+1>=count) return 0;
|
2013-10-20 14:20:57 +02:00
|
|
|
current++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-21 00:47:10 +02:00
|
|
|
if (visible+first>=count) return 0;
|
2013-10-20 14:20:57 +02:00
|
|
|
first++;
|
|
|
|
current++;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int llist::KeyUp()
|
|
|
|
{
|
|
|
|
if (current>first)
|
|
|
|
{
|
|
|
|
current--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-21 00:47:10 +02:00
|
|
|
if (first==0) return 0;
|
2013-10-20 14:20:57 +02:00
|
|
|
first--;
|
|
|
|
current--;
|
|
|
|
}
|
|
|
|
return 1;
|
2013-10-21 00:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int llist::KeyHome()
|
|
|
|
{
|
|
|
|
if (current==0) && (first==0) return 0;
|
|
|
|
current=0;
|
|
|
|
first=0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int llist::KeyEnd()
|
|
|
|
{
|
|
|
|
if (current==count-1) && (first==count-visible) return 0;
|
|
|
|
current=count-1;
|
|
|
|
first=count-visible;
|
|
|
|
return 1;
|
2013-02-04 14:15:13 +01:00
|
|
|
}
|