Objective Grid: Using covered cells as a recurring pattern

Article ID: 680
Last updated: 11 Apr, 2018
Article ID: 680
Last updated: 11 Apr, 2018
Revision: 3
Views: 1661
Posted: 23 Jan, 2001
by Meltreger B.
Updated: 11 Apr, 2018
by Meltreger B.

Problem


How can I efficiently use covered cells as a recurring pattern (e.g. covered cells are the same for each row)?


Cause



Action


Here is another approach to setting up covered cells in a recurring pattern.












// As the covered cells are the same for each row,
// I suggest creating one array of ROWCOLS 

// It is like a pattern (very similar to the 'quicken-like
// rows' FAQ.

ROWCOL awCoverCols[] = {
// start, end
2, 10,
12, 20,
22, 30,
32, 40,
42, 50,
52, 60,
62, 70,
72, 85,
0, 0 // end of list
};

CGXRange* C1stGridView::GetCoveredCellsRowCol(ROWCOL nRow, ROWCOL nCol, CGXRange& range)
{
if (nRow > 0)
// if (nRow > 0 && nRow % 2 == 0) // apply pattern to every second row only
// (just for testing here)
{
for (int n = 0; awCoverCols[n] > 0; n+=2)
{
if (nCol >= awCoverCols[n] && nCol <= awCoverCols[n+1])
{
range.SetCells(nRow, awCoverCols[n], nRow, awCoverCols[n+1]);
return &range;
}
}
}

// normal cell, not covered:
return NULL;
}


void C1stGridView::MergeCoveredCells(CGXRange& area)
{
if (area.bottom > 0)
// if (area.GetHeight() > 1 || area.top % 2 == 0 && area.top > 0)
// apply pattern to every second row only
// (just for testing here)
{
for (int n = 0; awCoverCols[n] > 0; n+=2)
{
if (area.left >= awCoverCols[n] && area.left <= awCoverCols[n+1])
area.left = awCoverCols[n];

if (area.right >= awCoverCols[n] && area.right <= awCoverCols[n+1])
area.right = awCoverCols[n+1];
}
}
}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 680
Last updated: 11 Apr, 2018
Revision: 3
Views: 1661
Posted: 23 Jan, 2001 by Meltreger B.
Updated: 11 Apr, 2018 by Meltreger B.

Others in this category