m_created = true;
}
+ InvalidateBestSize();
+
return m_created;
}
return PosToLinePos(x, true /* clip */, wxGridColumnOperations());
}
-// return the row number such that the y coord is near the edge of, or -1 if
+// return the row/col number such that the pos is near the edge of, or -1 if
// not near an edge.
//
// notice that position can only possibly be near an edge if the row/column is
// _never_ be considered to be near the edge).
int wxGrid::PosToEdgeOfLine(int pos, const wxGridOperations& oper) const
{
- const int line = oper.PosToLine(this, pos, true);
+ // Get the bottom or rightmost line that could match.
+ int line = oper.PosToLine(this, pos, true);
- if ( oper.GetLineSize(this, line) > WXGRID_LABEL_EDGE_ZONE )
+ // Go backwards until we find a line that is big enough.
+ while ( oper.GetLineSize(this, line) <= WXGRID_LABEL_EDGE_ZONE )
{
- // We know that we are in this line, test whether we are close enough
- // to start or end border, respectively.
- if ( abs(oper.GetLineEndPos(this, line) - pos) < WXGRID_LABEL_EDGE_ZONE )
- return line;
- else if ( line > 0 &&
- pos - oper.GetLineStartPos(this,
- line) < WXGRID_LABEL_EDGE_ZONE )
- {
- return oper.GetLineBefore(this, line);
- }
+ line = oper.GetLineBefore(this, line);
+ if ( line <= 0 )
+ break;
}
+ // If the bottom or right touches then we have a match
+ if ( abs(oper.GetLineEndPos(this, line) - pos) < WXGRID_LABEL_EDGE_ZONE )
+ return line;
+
return -1;
}
// We're showing back a previously hidden row/column.
wxASSERT_MSG( sizeNew == -1, wxS("New size must be positive or -1.") );
- wxASSERT_MSG( sizeCurrent < 0, wxS("May only show back if hidden.") );
+ // If it's already visible, simply do nothing.
+ if ( sizeCurrent >= 0 )
+ return 0;
+ // Otherwise show it by restoring its old size.
sizeCurrent = -sizeCurrent;
// This is positive which is correct.
else if ( sizeNew == 0 )
{
// We're hiding a row/column.
- wxASSERT_MSG( sizeCurrent > 0, wxS("Can't hide if already hidden.") );
+ // If it's already hidden, simply do nothing.
+ if ( sizeCurrent <= 0 )
+ return 0;
+
+ // Otherwise hide it and also remember the shown size to be able to
+ // restore it later.
sizeCurrent = -sizeCurrent;
// This is negative which is correct.