GridCtrl: Selection fixes

git-svn-id: svn://ultimatepp.org/upp/trunk@15619 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-12-23 11:47:19 +00:00
parent ba3188b5a9
commit 90f35ca449
4 changed files with 22 additions and 6 deletions

View file

@ -1643,7 +1643,8 @@ class GridCtrl : public Ctrl
void UpdateSummary(bool b = true);
private:
bool IsSelect(int n, int m, bool relative);
bool TabKey(bool enter_mode);
bool Go0(int jump, bool scroll = true, bool goleft = false, bool ctrlmode = false);

View file

@ -113,13 +113,13 @@ void GridCtrl::LeftDown(Point p, dword keyflags)
moveRow = curpos.y;
if(keyflags & K_CTRL) {
SelectRange(oldcur, oldcur, !IsSelected(curpos.y, curpos.y, false), select_row);
SelectRange(curpos, curpos, !IsSelected(curpos.y, curpos.y, false), select_row);
SelectRange(curpos, curpos, !IsSelect(curpos.y, curpos.x, false), select_row);
}
else {
ClearSelection();
if((keyflags & K_SHIFT) && multi_select && IsValidCursor(oldcur)) {
SetCursor0(oldcur, CU_HIDECTRLS);
if(oldcur.y >= 0 && oldcur.x >= 0)
SetCursor0(oldcur, CU_HIDECTRLS);
Refresh();
}
}

View file

@ -343,6 +343,10 @@ void GridCtrl::Paint(Draw &w)
Rect r(anchor, curpos);
r.Normalize();
r.SetSize(r.GetSize() + 1);
if(select_row) {
r.left = 0;
r.right = INT_MAX;
}
if(r.Contains(Point(j, i)))
style |= GD::SELECT;
}

View file

@ -45,11 +45,14 @@ void GridCtrl::SelectRange(Point from, Point to, bool sel /* = true*/, bool full
t = from;
}
int ymin = f.y;
int ymax = t.y;
int ymin = min(f.y, t.y);
int ymax = max(f.y, t.y);
int xmin = f.x;
int xmax = t.x;
if(ymin < 0 || xmin < 0)
return;
if(xmin > xmax)
{
@ -224,6 +227,14 @@ bool GridCtrl::IsSelected(int n, bool relative)
return vitems[id].IsSelect() || vitems[id].IsCursor();
}
bool GridCtrl::IsSelect(int n, int m, bool relative)
{
int r = relative ? fixed_rows + n : n;
int c = relative ? fixed_cols + m : m;
Item &it = GetItem(r, c);
return it.IsSelect();
}
bool GridCtrl::IsSelected(int n, int m, bool relative)
{
int r = relative ? fixed_rows + n : n;