if (grid->GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL))
m_startValue = grid->GetTable()->GetValueAsBool(row, col);
else
- m_startValue = !!grid->GetTable()->GetValue(row, col);
+ {
+ wxString cellval( grid->GetTable()->GetValue(row, col) );
+ m_startValue = !( !cellval || (cellval == "0") );
+ }
CBox()->SetValue(m_startValue);
CBox()->SetFocus();
}
if ( grid.GetTable()->CanGetValueAs(row, col, wxGRID_VALUE_BOOL) )
value = grid.GetTable()->GetValueAsBool(row, col);
else
- value = !!grid.GetTable()->GetValue(row, col);
+ {
+ wxString cellval( grid.GetTable()->GetValue(row, col) );
+ value = !( !cellval || (cellval == "0") );
+ }
if ( value )
{
wxGridCellAttrProvider * attrProvider = m_table->GetAttrProvider();
if (attrProvider) {
attrProvider->UpdateAttrRows( pos, -((int)numRows) );
-// ifdef'd out following patch from Paul Gammans
-#if 0
+// ifdef'd out following patch from Paul Gammans
+#if 0
+ // No need to touch column attributes, unless we
// removed _all_ rows, in this case, we remove
// all column attributes.
// I hate to do this here, but the
if (attrProvider) {
attrProvider->UpdateAttrCols( pos, -((int)numCols) );
// ifdef'd out following patch from Paul Gammans
-#if 0
+#if 0
// No need to touch row attributes, unless we
// removed _all_ columns, in this case, we remove
// all row attributes.
{
if ( m_selectingKeyboard == wxGridNoCellCoords)
m_selectingKeyboard = coords;
- SelectBlock ( m_selectingKeyboard, coords );
+ HighlightBlock ( m_selectingKeyboard, coords );
}
else
{
if ( !IsSelection() )
{
- SelectBlock( coords, coords );
+ HighlightBlock( coords, coords );
}
else
{
- SelectBlock( m_currentCellCoords, coords );
+ HighlightBlock( m_currentCellCoords, coords );
}
}
SetCurrentCell( coords );
if ( m_selection->GetSelectionMode()
!= wxGrid::wxGridSelectCells)
- SelectBlock( coords, coords );
+ HighlightBlock( coords, coords );
}
m_waitForSlowClick = TRUE;
}
HideCellEditControl();
DisableCellEditControl();
- if ( IsVisible( m_currentCellCoords, FALSE ) ) // zzz
+ if ( IsVisible( m_currentCellCoords, FALSE ) )
{
wxRect r;
r = BlockToDeviceRect(m_currentCellCoords, m_currentCellCoords);
}
+void wxGrid::HighlightBlock( int topRow, int leftCol, int bottomRow, int rightCol )
+{
+ int temp;
+ wxGridCellCoords updateTopLeft, updateBottomRight;
+
+ if ( m_selection->GetSelectionMode() == wxGrid::wxGridSelectRows )
+ {
+ leftCol = 0;
+ rightCol = GetNumberCols() - 1;
+ }
+ else if ( m_selection->GetSelectionMode() == wxGrid::wxGridSelectColumns )
+ {
+ topRow = 0;
+ bottomRow = GetNumberRows() - 1;
+ }
+ if ( topRow > bottomRow )
+ {
+ temp = topRow;
+ topRow = bottomRow;
+ bottomRow = temp;
+ }
+
+ if ( leftCol > rightCol )
+ {
+ temp = leftCol;
+ leftCol = rightCol;
+ rightCol = temp;
+ }
+
+ updateTopLeft = wxGridCellCoords( topRow, leftCol );
+ updateBottomRight = wxGridCellCoords( bottomRow, rightCol );
+
+ if ( m_selectingTopLeft != updateTopLeft ||
+ m_selectingBottomRight != updateBottomRight )
+ {
+ // Compute two optimal update rectangles:
+ // Either one rectangle is a real subset of the
+ // other, or they are (almost) disjoint!
+ wxRect rect[4];
+ bool need_refresh[4];
+ need_refresh[0] =
+ need_refresh[1] =
+ need_refresh[2] =
+ need_refresh[3] = FALSE;
+ int i;
+
+ // Store intermediate values
+ wxCoord oldLeft = m_selectingTopLeft.GetCol();
+ wxCoord oldTop = m_selectingTopLeft.GetRow();
+ wxCoord oldRight = m_selectingBottomRight.GetCol();
+ wxCoord oldBottom = m_selectingBottomRight.GetRow();
+
+ // Determine the outer/inner coordinates.
+ if (oldLeft > leftCol)
+ {
+ temp = oldLeft;
+ oldLeft = leftCol;
+ leftCol = temp;
+ }
+ if (oldTop > topRow )
+ {
+ temp = oldTop;
+ oldTop = topRow;
+ topRow = temp;
+ }
+ if (oldRight < rightCol )
+ {
+ temp = oldRight;
+ oldRight = rightCol;
+ rightCol = temp;
+ }
+ if (oldBottom < bottomRow)
+ {
+ temp = oldBottom;
+ oldBottom = bottomRow;
+ bottomRow = temp;
+ }
+
+ // Now, either the stuff marked old is the outer
+ // rectangle or we don't have a situation where one
+ // is contained in the other.
+
+ if ( oldLeft < leftCol )
+ {
+ need_refresh[0] = TRUE;
+ rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
+ oldLeft ),
+ wxGridCellCoords ( oldBottom,
+ leftCol - 1 ) );
+ }
+
+ if ( oldTop < topRow )
+ {
+ need_refresh[1] = TRUE;
+ rect[1] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
+ leftCol ),
+ wxGridCellCoords ( topRow - 1,
+ rightCol ) );
+ }
+
+ if ( oldRight > rightCol )
+ {
+ need_refresh[2] = TRUE;
+ rect[2] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
+ rightCol + 1 ),
+ wxGridCellCoords ( oldBottom,
+ oldRight ) );
+ }
+
+ if ( oldBottom > bottomRow )
+ {
+ need_refresh[3] = TRUE;
+ rect[3] = BlockToDeviceRect( wxGridCellCoords ( bottomRow + 1,
+ leftCol ),
+ wxGridCellCoords ( oldBottom,
+ rightCol ) );
+ }
+
+
+ // Change Selection
+ m_selectingTopLeft = updateTopLeft;
+ m_selectingBottomRight = updateBottomRight;
+
+ // various Refresh() calls
+ for (i = 0; i < 4; i++ )
+ if ( need_refresh[i] && rect[i] != wxGridNoCellRect )
+ m_gridWin->Refresh( FALSE, &(rect[i]) );
+ }
+
+ // never generate an event as it will be generated from
+ // wxGridSelection::SelectBlock!
+ // (old comment from when this was the body of SelectBlock)
+}
+
+
//
// ------ functions to get/send data (see also public functions)
//
{
if ( !IsVisible( m_currentCellCoords ) )
{
- m_cellEditCtrlEnabled = false;
+ m_cellEditCtrlEnabled = FALSE;
return;
}
else
m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() - 1 );
MakeCellVisible( m_selectingKeyboard.GetRow(),
m_selectingKeyboard.GetCol() );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
}
else if ( m_currentCellCoords.GetRow() > 0 )
m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() + 1 );
MakeCellVisible( m_selectingKeyboard.GetRow(),
m_selectingKeyboard.GetCol() );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
}
else if ( m_currentCellCoords.GetRow() < m_numRows - 1 )
m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() - 1 );
MakeCellVisible( m_selectingKeyboard.GetRow(),
m_selectingKeyboard.GetCol() );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
}
else if ( m_currentCellCoords.GetCol() > 0 )
m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() + 1 );
MakeCellVisible( m_selectingKeyboard.GetRow(),
m_selectingKeyboard.GetCol() );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
}
else if ( m_currentCellCoords.GetCol() < m_numCols - 1 )
if ( expandSelection )
{
m_selectingKeyboard = wxGridCellCoords( row, col );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
{
if ( expandSelection )
{
m_selectingKeyboard = wxGridCellCoords( row, col );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
{
if ( expandSelection )
{
m_selectingKeyboard = wxGridCellCoords( row, col );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
{
if ( expandSelection )
{
m_selectingKeyboard = wxGridCellCoords( row, col );
- SelectBlock( m_currentCellCoords, m_selectingKeyboard );
+ HighlightBlock( m_currentCellCoords, m_selectingKeyboard );
}
else
{
if ( rect.height > 0 )
{
CalcScrolledPosition(0, rect.y, &rect.x, &rect.y);
- rect.x = m_left;
+ rect.x = 0;
rect.width = m_rowLabelWidth;
m_rowLabelWin->Refresh( TRUE, &rect );
}
if ( rect.width > 0 )
{
CalcScrolledPosition(rect.x, 0, &rect.x, &rect.y);
- rect.y = m_top;
+ rect.y = 0;
rect.height = m_colLabelHeight;
m_colLabelWin->Refresh( TRUE, &rect );
}
}
-void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol )
+void wxGrid::SelectBlock( int topRow, int leftCol, int bottomRow, int rightCol,
+ bool addToSelected )
{
- int temp;
- wxGridCellCoords updateTopLeft, updateBottomRight;
-
- if ( m_selection->GetSelectionMode() == wxGrid::wxGridSelectRows )
- {
- leftCol = 0;
- rightCol = GetNumberCols() - 1;
- }
- else if ( m_selection->GetSelectionMode() == wxGrid::wxGridSelectColumns )
- {
- topRow = 0;
- bottomRow = GetNumberRows() - 1;
- }
- if ( topRow > bottomRow )
- {
- temp = topRow;
- topRow = bottomRow;
- bottomRow = temp;
- }
-
- if ( leftCol > rightCol )
- {
- temp = leftCol;
- leftCol = rightCol;
- rightCol = temp;
- }
-
- updateTopLeft = wxGridCellCoords( topRow, leftCol );
- updateBottomRight = wxGridCellCoords( bottomRow, rightCol );
-
- if ( m_selectingTopLeft != updateTopLeft ||
- m_selectingBottomRight != updateBottomRight )
- {
- // Compute two optimal update rectangles:
- // Either one rectangle is a real subset of the
- // other, or they are (almost) disjoint!
- wxRect rect[4];
- bool need_refresh[4];
- need_refresh[0] =
- need_refresh[1] =
- need_refresh[2] =
- need_refresh[3] = FALSE;
- int i;
-
- // Store intermediate values
- wxCoord oldLeft = m_selectingTopLeft.GetCol();
- wxCoord oldTop = m_selectingTopLeft.GetRow();
- wxCoord oldRight = m_selectingBottomRight.GetCol();
- wxCoord oldBottom = m_selectingBottomRight.GetRow();
-
- // Determine the outer/inner coordinates.
- if (oldLeft > leftCol)
- {
- temp = oldLeft;
- oldLeft = leftCol;
- leftCol = temp;
- }
- if (oldTop > topRow )
- {
- temp = oldTop;
- oldTop = topRow;
- topRow = temp;
- }
- if (oldRight < rightCol )
- {
- temp = oldRight;
- oldRight = rightCol;
- rightCol = temp;
- }
- if (oldBottom < bottomRow)
- {
- temp = oldBottom;
- oldBottom = bottomRow;
- bottomRow = temp;
- }
-
- // Now, either the stuff marked old is the outer
- // rectangle or we don't have a situation where one
- // is contained in the other.
-
- if ( oldLeft < leftCol )
- {
- need_refresh[0] = TRUE;
- rect[0] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
- oldLeft ),
- wxGridCellCoords ( oldBottom,
- leftCol - 1 ) );
- }
-
- if ( oldTop < topRow )
- {
- need_refresh[1] = TRUE;
- rect[1] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
- leftCol ),
- wxGridCellCoords ( topRow - 1,
- rightCol ) );
- }
-
- if ( oldRight > rightCol )
- {
- need_refresh[2] = TRUE;
- rect[2] = BlockToDeviceRect( wxGridCellCoords ( oldTop,
- rightCol + 1 ),
- wxGridCellCoords ( oldBottom,
- oldRight ) );
- }
-
- if ( oldBottom > bottomRow )
- {
- need_refresh[3] = TRUE;
- rect[3] = BlockToDeviceRect( wxGridCellCoords ( bottomRow + 1,
- leftCol ),
- wxGridCellCoords ( oldBottom,
- rightCol ) );
- }
-
-
- // Change Selection
- m_selectingTopLeft = updateTopLeft;
- m_selectingBottomRight = updateBottomRight;
-
- // various Refresh() calls
- for (i = 0; i < 4; i++ )
- if ( need_refresh[i] && rect[i] != wxGridNoCellRect )
- m_gridWin->Refresh( FALSE, &(rect[i]) );
- }
+ if ( IsSelection() && !addToSelected )
+ ClearSelection();
- // never generate an event as it will be generated from
- // wxGridSelection::SelectBlock!
+ m_selection->SelectBlock( topRow, leftCol, bottomRow, rightCol,
+ FALSE, addToSelected );
}
+
void wxGrid::SelectAll()
{
m_selection->SelectBlock( 0, 0, m_numRows-1, m_numCols-1 );