ET++: Box::ColsRowsSize()
Box::ColsRowsSize() returns the number of rows and columns of a box. It is provided here
to show a sample method of Box dealing with its grid structure. Note that the user need
not specify the exact number of rows or columns desired-- if one is negative, it is
computed from the other, and if both are negative, a roughly equal number of rows and
columns is used.
Point Box::ColsRowsSize()
{
int n= Size();
if (colsrows.y <= 0 && colsrows.x <= 0) {
int c= Math::Sqrt(n);
return Point(c, (n-1)/c+1);
}
if (colsrows.y <= 0)
return Point(colsrows.x, (n-1)/colsrows.x+1);
if (colsrows.x <= 0)
return Point((n-1)/colsrows.y+1, colsrows.y);
return colsrows;
}
Back to the graphical layout description
Back to the main ET++ page