Fixed MultiList scrolling bug

git-svn-id: svn://ultimatepp.org/upp/trunk@323 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
mrjtuk 2008-07-30 11:09:43 +00:00
parent 850b64038b
commit b87ea83029

View file

@ -499,13 +499,28 @@ void MultiList::SetSb()
int rcnt = GetCount()/ncl;
rcnt += (GetCount() % ncl) ? 1 : 0;
sb.SetTotal(rcnt*cy);
sb.SetPage((GetSize().cy-cy/2)/cy*cy + cy/4);
sb.SetLine(cy/4);
sb.SetPage((GetSize().cy/cy)*cy);
sb.SetLine(cy);
break;
}
}
}
void MultiList::ScrollInto(int pos)
{
switch (mode) {
case MODE_ROWS:
sb.ScrollInto((pos / ncl) * cy, max(0, sb.GetLine() - (GetSize().cy - sb.GetPage())));
return;
case MODE_COLUMNS:
sb.ScrollInto(pos / max(1, GetColumnItems()));
return;
case MODE_LIST:
sb.ScrollInto(pos);
return;
}
}
void MultiList::Layout()
{
if (mode == MODE_ROWS)
@ -597,21 +612,6 @@ void MultiList::SetSbPos(int y)
sb = minmax(y, 0, GetCount() - GetPageItems());
}
void MultiList::ScrollInto(int pos)
{
switch (mode) {
case MODE_ROWS:
sb.ScrollInto(pos / ncl * cy + sb.GetLine());
return;
case MODE_COLUMNS:
sb.ScrollInto(pos / max(1, GetColumnItems()));
return;
case MODE_LIST:
sb.ScrollInto(pos);
return;
}
}
void MultiList::KillCursor()
{
if(cursor < 0) return;
@ -1010,8 +1010,21 @@ void MultiList::InsertDrop(int ii, PasteClip& d)
void MultiList::Serialize(Stream& s) {
int version = 0;
s / version;
s / ncl;
int cnt;
s.Magic();
s / version / ncl / cnt;
if (s.IsLoading())
item.SetCount(cnt);
for (int i = 0; i < item.GetCount(); i++) {
Item &q = item[i];
s % q.key % q.value % q.canselect;
if (s.IsLoading()) {
q.display = NULL;
q.sel = false;
}
}
s.Magic();
Refresh();
SyncInfo();
}